Skip to content

Infinite loop 2 #128

Description

@tsvx

Here is the test data, 29 short files, each deflated with zlib format (header 78-9C and Adler32 footer):
https://www.dropbox.com/s/jrl5rmlx8idafm1/packets.zip?dl=0
First two of them are good, the remaining are bad (broken).
When inflating, some of the bad packets lead to an exception, but some other cause the ininite loop of endless repeated Inflate calls.

Steps to reproduce

  1. Take, for instance, file packet-03 or packet-05.
  2. Try to inflate the contents with Inflater.Inflate with a code like that:
var zbuf  = File.ReadAllBytes("packet-03");
var zlib = new Inflater();
var buf = new byte[1460];
var ms = new MemoryStream();
zlib.SetInput(zbuf);
int n;
while ((n = zlib.Inflate(buf)) > 0)
{
    ms.Write(buf, 0, n);
}
if (!zlib.IsFinished)
    throw new InvalidOperationException("Inflater not finished!");
return ms.ToArray();

Expected behavior

There should be an exception while inflating.

Actual behavior

You'll get into an infinite loop of generating endless zero bytes.

Version of SharpZipLib

0.86.0.518
master on 2016-08-03

Obtained from (place an x between the brackets for all that apply)

  • Compiled from source
    • branch: master
    • commit: _______
  • Downloaded DLL from GitHub
  • Downloaded DLL from SourceForge
  • Downloaded DLL from _______
  • DLL included as part of
  • Package installed using:
    • NuGet
    • MyGet
    • Chocolatey

Activity

  1. tsvx commented on Aug 6, 2016

    @tsvx
    Author

    I'm not sure if it is related to #88.

  2. self-assigned this
    on Aug 13, 2016
  3. piksel commented on Sep 16, 2018

    @piksel
    Member

    packets.zip

    Adding provided test file to issue.

  4. assigned and unassigned on Sep 16, 2018
  5. piksel commented on Nov 22, 2020

    @piksel
    Member

    Fixed by #316

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions