Bring in fix from gzip 1.3.3 to avoid crashes when processing certain corrupt
input files: 1999-06-25 Paul Eggert <eggert@twinsun.com> * inflate.c (huft_build): Set n to length of v, to detect improper tables. Don't accidentally grow j past z. MFC after: 3 days
This commit is contained in:
parent
5c1b7fdc2d
commit
0fcf790be9
@ -360,6 +360,7 @@ int *m; /* maximum lookup bits, returns actual */
|
||||
if ((j = *p++) != 0)
|
||||
v[x[j]++] = i;
|
||||
} while (++i < n);
|
||||
n = x[g]; /* set n to length of v */
|
||||
|
||||
|
||||
/* Generate the Huffman codes and for each, make the table entries */
|
||||
@ -390,12 +391,13 @@ int *m; /* maximum lookup bits, returns actual */
|
||||
{ /* too few codes for k-w bit table */
|
||||
f -= a + 1; /* deduct codes from patterns left */
|
||||
xp = c + k;
|
||||
while (++j < z) /* try smaller tables up to z bits */
|
||||
{
|
||||
if ((f <<= 1) <= *++xp)
|
||||
break; /* enough codes to use up j bits */
|
||||
f -= *xp; /* else deduct codes from patterns */
|
||||
}
|
||||
if (j < z)
|
||||
while (++j < z) /* try smaller tables up to z bits */
|
||||
{
|
||||
if ((f <<= 1) <= *++xp)
|
||||
break; /* enough codes to use up j bits */
|
||||
f -= *xp; /* else deduct codes from patterns */
|
||||
}
|
||||
}
|
||||
z = 1 << j; /* table entries for j-bit table */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user