BZip2InputStream.Length reports an incorrect length
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 2/5
- Tempo estimado
- 1-3 horas
- Facilidade para iniciantes
- 55/100
Direção de pesquisa
Comece pelo ponto de entrada BZip2InputStream.Length e reproduza o comportamento com o exemplo StreamLengthTest fornecido. Compare o comprimento informado com os bytes retornados ao ler o stream e, em seguida, adicione ou adapte um teste de regressão para que o comprimento informado corresponda aos dados descompactados legíveis.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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");
}
}
}
- Linguagem predominante
- C#
- Estrelas
- 3.9k
- Forks
- 1k
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Preparar o ambiente
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de icsharpcode/SharpZipLib
-
*no response* bug
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 78/100
icsharpcode/SharpZipLib#905 · 1 comentário ·
-
bug bzip2
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 45/100
icsharpcode/SharpZipLib#904 ·
-
SetLevel in ZipFileAbertaenhancement zip
Dificuldade 2/5 1-2 dias Facilidade para iniciantes 55/100
icsharpcode/SharpZipLib#903 ·
-
*no response* bug
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 32/100
icsharpcode/SharpZipLib#901 · 1 comentário ·
-
*no response* bug
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 35/100
icsharpcode/SharpZipLib#894 · 1 comentário ·
Todas as issues de icsharpcode/SharpZipLib
Issues semelhantes
-
[Simple] NavigationBar primary commands do not render AppBarButton.Content when it is a UIElementAbertacontrol/navigationbar kind/bug triage/untriaged
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 90/100
unoplatform/uno.toolkit.ui#1652 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 88/100
microsoft/copilot-camp#1053 ·
Mantenedores costumam responder em até 1 dia
-
bug effort:S P3
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 84/100
nightscout/nocturne#1861 ·
Mantenedores costumam responder em até 1 dia
-
agentic-workflows area/Docs partner/agentic-workflows
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
microsoft/fluentui-blazor#5364 ·
Mantenedores costumam responder em até 1 dia