Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

InflaterInputStream doesn't reset position of underlying stream to end of deflated data

オープン
#584 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
45/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
csharp
領域
backend

調査の方向性

InflaterInputStream とその Read エントリポイントから始め、末尾データを含むファイルで例を再現して、基盤となるストリームの位置がどのように変化するかを確認します。インフレーション後に基盤となるストリームが圧縮データの末尾に位置し、その後の 4 バイトの読み取りでバッファリングされたバイトではなく末尾データが返されれば完了です。

索引モデルが issue の本文から書いたものです。

説明

Steps to reproduce
  1. 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.
  2. 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!
            }
        }
    }
  1. 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
主要言語
C#
スター
3.9k
フォーク
1k
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

icsharpcode/SharpZipLib のほかの issue

icsharpcode/SharpZipLib の issue をすべて見る

似ている issue

C# の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。