<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "http://bugs.gentoo.org/bugzilla.dtd">

<bugzilla version="2.22.7"
          urlbase="http://bugs.gentoo.org/"
          maintainer="bugzilla@gentoo.org"
>

    <bug>
          <bug_id>94584</bug_id>
          
          <creation_ts>2005-05-31 00:01 0000</creation_ts>
          <short_desc>app-arch/gzip: crash on bad input</short_desc>
          <delta_ts>2005-09-01 09:20:59 0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>Gentoo Linux</product>
          <component>Applications</component>
          <version>unspecified</version>
          <rep_platform>All</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          <bug_file_loc>http://dev.gentoo.org/~taviso/files/gzip-crash.gz</bug_file_loc>
          
          
          <priority>P2</priority>
          <bug_severity>trivial</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>taviso@gentoo.org</reporter>
          <assigned_to>base-system@gentoo.org</assigned_to>
          

      

      
          <long_desc isprivate="0">
            <who>taviso@gentoo.org</who>
            <bug_when>2005-05-31 00:01:57 0000</bug_when>
            <thetext>A QA test uncovered an input data stream that crashes gzip -d, there&apos;s a testcase in the URL field. Upstream informed, but no response yet.

Perhaps huft_build() should be returning non-zero around line 340 of inflate.c? At the moment it causes a NULL deref:

...
    336   if (c[0] == n)                /* null input--all zero length codes */
    337   {
    338     *t = (struct huft *)NULL;
    339     *m = 0;
    340     return 0;
    341   }
...</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>vapier@gentoo.org</who>
            <bug_when>2005-07-02 06:44:09 0000</bug_when>
            <thetext>the comment just about huft_build() says:
/* Given a list of code lengths and a maximum table size, make a set of
   tables to decode that set of codes.  Return zero on success, one if
   the given code set is incomplete (the tables are still built in this
   case), two if the input is invalid (all zero length codes or an
   oversubscribed set of lengths), and three if not enough memory. */

the case you&apos;re looking at is for &apos;all zero length codes&apos; which means it should
return 2 instead of 0 ... that does fix the crash so i&apos;ve added gzip-1.3.5-r8
with the fix</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>vapier@gentoo.org</who>
            <bug_when>2005-07-02 07:44:16 0000</bug_when>
            <thetext>forgot to close ...</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>ssjoholm@aha.com</who>
            <bug_when>2005-09-01 09:20:58 0000</bug_when>
            <thetext>Created an attachment (id=67422)
Gzip file which cannot be decompressed after applying the patch

The patch causes gzip -d to return &quot;gzip: stdin: invalid compressed
data--format violated&quot; when decompressing dynamic huffman encoded files which
don&apos;t have any matches, such as the one I am attaching.  When there are no
matches, then the distance huffman tree will have all zero length entries and
huft_build() will return 2, even though this is valid according to the gzip
spec, RFC1951.	Without the patch the file decompresses correctly.  I am
working on finding a fix for both problems now.</thetext>
          </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>67422</attachid>
            <date>2005-09-01 09:20 0000</date>
            <desc>Gzip file which cannot be decompressed after applying the patch</desc>
            <filename>one.gz</filename>
            <type>application/x-tar</type>
            <data encoding="base64">H4sIAAAAAAAAAwXAgQgAAAAAILb9pU6LntnTAQAAAA==
</data>        

          </attachment>
    </bug>

</bugzilla>