BZip2InputStream.Length reports an incorrect length
まだ誰も着手していません。
評価
調査の方向性
BZip2InputStream.Length エントリポイントから開始し、提供された StreamLengthTest の例で動作を再現します。報告された長さを、ストリームの読み取りによって返されるバイト数と比較し、その後、報告された長さが読み取り可能な非圧縮データと一致するように、リグレッションテストを追加または適応します。
索引モデルが issue の本文から書いたものです。
説明
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");
}
}
}
- 主要言語
- C#
- スター
- 3.9k
- フォーク
- 1k
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
icsharpcode/SharpZipLib のほかの issue
-
*no response* bug
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
icsharpcode/SharpZipLib#905 · コメント 1 件 ·
-
bug bzip2
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
icsharpcode/SharpZipLib#904 ·
-
SetLevel in ZipFileオープンenhancement zip
難易度 2/5 1〜2日 初心者へのやさしさ 55/100
icsharpcode/SharpZipLib#903 ·
-
*no response* bug
難易度 4/5 3〜5日 初心者へのやさしさ 32/100
icsharpcode/SharpZipLib#901 · コメント 1 件 ·
-
*no response* bug
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
icsharpcode/SharpZipLib#894 · コメント 1 件 ·
icsharpcode/SharpZipLib の issue をすべて見る
似ている issue
-
area-System.Numerics.Tensors untriaged
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
dotnet/runtime#134691 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
unoplatform/uno.templates#2277 ·
メンテナーはふだん 5 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
microsoft/fluentui-blazor#5344 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
difficulty/starter 🚀 good first issue kind/bug platform/all project/core-tools 🛠️ triage/untriaged
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
unoplatform/uno#24757 ·
メンテナーはふだん 1 日以内に返信
-
ci-failure-cause test-failure
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信