BZip2InputStream.Length reports an incorrect length
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 55/100
Direzione di ricerca
Parti dal punto di ingresso BZip2InputStream.Length e riproduci il comportamento con l'esempio StreamLengthTest fornito. Confronta la lunghezza riportata con i byte restituiti dalla lettura dello stream, quindi aggiungi o adatta un test di regressione in modo che la lunghezza riportata corrisponda ai dati non compressi leggibili.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Steps to reproduce
- Load already compressed bzip2 payload into a
MemoryStream - Create
BZip2InputStreamfrom saidMemoryStream Assert.AreNotEqual(memorystream.Length, bzip2stream.Length);
Example code is included below.
Expected behavior
BZip2InputStream.Length should return how many bytes the developer can expect to read from the stream.
Actual behavior
BZip2InputStream.Length returns 48, but only 11 bytes are actually available in the stream. Uncompressed data is a string of 11 bytes, compressed data blob is 48 bytes. It seems to just return the length reported by underlying stream.
Version of SharpZipLib
Version 1.3.1
Obtained from
- Package installed using NuGet
Example code
using System.IO;
using System.Threading.Tasks;
using ICSharpCode.SharpZipLib.BZip2;
using NUnit.Framework;
namespace Tests {
[TestFixture]
public class StreamLengthTest {
private static readonly byte[] CompressedChunk = {
0x42, 0x5a, 0x68, 0x39, 0x31, 0x41, 0x59, 0x26, 0x53, 0x59, 0xd5, 0xb7, 0x4b, 0xf5, 0x00, 0x00,
0x03, 0xc1, 0x80, 0x00, 0x10, 0x23, 0x84, 0x44, 0x00, 0x20, 0x00, 0x31, 0x0c, 0x08, 0x20, 0xd1,
0xb4, 0x8b, 0xa4, 0x28, 0x05, 0x3c, 0x5d, 0xc9, 0x14, 0xe1, 0x42, 0x43, 0x56, 0xdd, 0x2f, 0xd4
};
[Test]
public async Task Test() {
// Read the bzip2 blob into a memory stream
await using var memorystream = new MemoryStream(CompressedChunk);
// Create bzip2 stream from memorystream
await using var bzip2stream = new BZip2InputStream(memorystream);
// Sanity checks
Assert.AreEqual(48, CompressedChunk.Length, "The constant binary blob should have length 48");
Assert.AreEqual(CompressedChunk.Length, memorystream.Length, "memorystream should be a 1:1 representation of CompressedChunk. Lengths should match.");
Assert.IsTrue(memorystream.CanRead);
Assert.IsTrue(bzip2stream.CanRead);
// Read data from the stream
var expectedLength = bzip2stream.Length;
var actualLength = 0;
byte[] buffer = {0};
try {
while (0 < bzip2stream.Read(buffer, 0, 1)) {
actualLength++;
}
} catch { /* ignored */ }
// Observe results
Assert.AreEqual(expectedLength, actualLength, "Actual length should equal reported length");
}
}
}
- 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 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
-
FluentDataGrid: pinned column offsets leak into the grid of an open RowDetails (master-detail)ApertaNot reproducible
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
microsoft/fluentui-blazor#5350 · 4 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
python triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
microsoft/semantic-kernel#14491 ·
I maintainer di solito rispondono entro 2 giorni
-
area:jobads-cv FE mvp P3
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
klasolsson81/jobbliggaren#1878 ·
I maintainer di solito rispondono entro 1 giorno