InflaterInputStream doesn't reset position of underlying stream to end of deflated data
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 45/100
Direzione di ricerca
Inizia da InflaterInputStream e dal suo punto di ingresso Read, quindi riproduci l’esempio con un file contenente dati finali per osservare come cambia la posizione del flusso sottostante. Il lavoro è completo quando, dopo la decompressione, il flusso sottostante si trova alla fine dei dati compressi, così la successiva lettura di 4 byte restituisce i dati finali invece dei byte memorizzati nel buffer.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Steps to reproduce
- Obtain a file that contains a deflated blob with some other data following it. In my case, I have a binary file where there is a deflated blob, followed by some additional ints/floats/etc. It's important that there is trailing data after the deflated blob. It doesn't matter what the data is, it could be garbage. It just has to exist. The code below assumes there is at least 4 bytes in this trailing data.
- Run this simple program against it, after filling in appropriate values for InFile, InFileCompressedDataStartPos, InFileCompressedLength, and InFileUncompressedLength:
internal class Program
{
private static string InFile = @"";
private static int InFileCompressedDataStart = 0;
private static int InFileCompressedLength = 0;
private static int InFileUncompressedLength = 0;
public static void Main(string[] args)
{
using (var stream = File.OpenRead(InFile))
{
stream.Position = InFileCompressedDataStart;
//Encounter deflated blob in stream, and inflate it
using (var zStream = new InflaterInputStream(stream))
{
zStream.IsStreamOwner = false;
var buffer = new byte[InFileUncompressedLength];
var streamStartPos = stream.Position;
Console.WriteLine($"Stream position before inflate: {streamStartPos}");
var read = zStream.Read(buffer, 0, InFileCompressedLength);
Console.WriteLine($"InflaterInputStream read {read} bytes");
var streamEndPos = stream.Position;
Console.WriteLine($"Stream position after inflate: {streamEndPos}");
Console.WriteLine($"Stream position moved {streamEndPos - streamStartPos} bytes during read");
}
//Continue on with data following deflated blob
var testBuffer = new byte[4];
stream.Read(testBuffer, 0, 4); //This reads from the wrong offset in the file!
}
}
}
- Note the console output
Expected behavior
stream.Position should have progressed by InFileCompressedLength. (to allow the trailing data to be read independently)
Actual behavior
stream.Position progressed by some amount greater than InFileCompressedLength. (this is part way thru completely unrelated data!)
Version of SharpZipLib
1.3.1
Obtained from (only keep the relevant lines)
- Package installed using NuGet
- Lingua principale
- C#
- Stelle
- 3.9k
- Fork
- 1k
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di icsharpcode/SharpZipLib
-
*no response* bug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 78/100
icsharpcode/SharpZipLib#905 · 1 commento ·
-
bug bzip2
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
icsharpcode/SharpZipLib#904 ·
-
SetLevel in ZipFileApertaenhancement zip
Difficoltà 2/5 1-2 giorni Idoneità per principianti 55/100
icsharpcode/SharpZipLib#903 ·
-
*no response* bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 32/100
icsharpcode/SharpZipLib#901 · 1 commento ·
-
*no response* bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
icsharpcode/SharpZipLib#894 · 1 commento ·
Tutte le issue di icsharpcode/SharpZipLib
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
fluentassertions/fluentassertions#3353 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
-
Difficoltà 2/5 Mezza giornata Idoneità per principianti 78/100
unoplatform/uno#24769 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
AvaloniaUI/Avalonia#22323 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
microsoft/onnxruntime-genai#2633 ·
I maintainer di solito rispondono entro 1 giorno