← Commit list

2598915d4

Denys Vlasenko
Denys Vlasenko
2018-02-04
SUCCESS Duration: 145s

Subject

gunzip: fix from gzip-1.3.12 for gzip file with all zero length codes

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

archival/libarchive/decompress_gunzip.c+11 -4
@@ -280,8 +280,8 @@ static unsigned fill_bitbuffer(STATE_PARAM unsigned bitbuffer, unsigned *current
/* 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) - in this case stores NULL in *t.
+ * case), two if the input is invalid (an oversubscribed set of lengths)
+ * - in this case stores NULL in *t.
*
* b: code lengths in bits (all assumed <= BMAX)
* n: number of codes (assumed <= N_MAX)
@@ -330,8 +330,15 @@ static int huft_build(const unsigned *b, const unsigned n,
p++; /* can't combine with above line (Solaris bug) */
} while (--i);
if (c[0] == n) { /* null input - all zero length codes */
- *m = 0;
- return 2;
+ q = xzalloc(3 * sizeof(*q));
+ //q[0].v.t = NULL;
+ q[1].e = 99; /* invalid code marker */
+ q[1].b = 1;
+ q[2].e = 99; /* invalid code marker */
+ q[2].b = 1;
+ *t = q + 1;
+ *m = 1;
+ return 0;
}
/* Find minimum and maximum length, bound *m by those */