Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Password zip is inconsisent

Aperta
#873 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
25/100
Tipo di issue
Bug
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
csharp, postgresql

Direzione di ricerca

Inizia con il metodo CreateBackup fornito, in particolare con ZipOutputStream.Password e AESKeySize, e riproduci con 7zip il comportamento delle password di 98 caratteri rispetto a quelle di 99 caratteri. Confronta il comportamento dell’archivio generato e determina se le password lunghe dovrebbero funzionare; il lavoro è completato quando il comportamento è riproducibile e il risultato è corretto o chiaramente documentato.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

*no response* bug
Describe the bug

Only passwords with length up to 98 seem to work, if i use 99 and i even copy/paste the password directly unzipping the archive using 7zip does not work. how come?

Seems a bit random and not sure if it would be safe for db backups in this case.

private static async Task CreateBackup(string zipFile, string pgDumpArgs)
{
    ProcessStartInfo processInfo = new()
    {
        FileName = @"C:\Program Files\PostgreSQL\16\bin\pg_dump.exe",
        Arguments = pgDumpArgs,
        RedirectStandardOutput = true,
        RedirectStandardError = true, // Capture error output
        UseShellExecute = false,
        CreateNoWindow = true
    };

    using Process process = Process.Start(processInfo);
    if (process == null)
    {
        Console.WriteLine("Failed to start pg_dump process.");
        return;
    }

    using (FileStream fsOut = File.Create(zipFile))
    using (ZipOutputStream zipStream = new(fsOut))
    {
        zipStream.SetLevel(3); // 0-9, 9 being the highest level of compression
        zipStream.Password = "z4KpjH+}H9H*g3K3Jb-9}M^jnMN^-!Zs+8UZ3sfxWg5T~@ZHJ:Eoz!AFNMwdf!g_2QpX#)}4WKwHLL%C?s1BB*wx%:cia0j=m7.W";
        zipStream.UseZip64 = UseZip64.On; // Set to AsNeeded if you need Zip64

        ZipEntry newEntry = new ZipEntry($"backup_{DateTime.Now:yyyyMMdd_HHmmss}.backup")
        {
            DateTime = DateTime.Now,
            AESKeySize = 256 // AES-256 encryption
        };

        zipStream.PutNextEntry(newEntry);

        var outputTask = process.StandardOutput.BaseStream.CopyToAsync(zipStream);
        var errorTask = process.StandardError.ReadToEndAsync();

        await Task.WhenAll(outputTask, errorTask);
        zipStream.CloseEntry();

        string errorOutput = await errorTask;

        if (!string.IsNullOrEmpty(errorOutput))
        {
            Console.WriteLine($"pg_dump reported the following errors:\n{errorOutput}");
        }
    }

    await process.WaitForExitAsync();

    if (process.ExitCode != 0)
    {
        Console.WriteLine($"pg_dump failed with exit code {process.ExitCode}");
    }
    else
    {
        Console.WriteLine($"{zipFile} Database backup successfully completed.");
    }
}
Reproduction Code

No response

Steps to reproduce

zip zip

Expected behavior

work

Operating System

Windows

Framework Version

Other

Tags

No response

Additional context

No response

Lingua principale
C#
Stelle
3.9k
Fork
1k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di icsharpcode/SharpZipLib

Tutte le issue di icsharpcode/SharpZipLib

Issue simili

Altre issue su C#

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.