X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=unlzh.c;h=7a88fee6294c3fde0b00bbef1c8fe7531481df2f;hb=c9eb602f6f5c10a521e7274640033f6a35deca1d;hp=b1c6ac675a318948b5a5bf82da7dd50c10a083cc;hpb=0095746c83f59e1f45c9e803d61e205ab6cbfa83;p=gzip diff --git a/unlzh.c b/unlzh.c index b1c6ac6..7a88fee 100644 --- a/unlzh.c +++ b/unlzh.c @@ -69,11 +69,7 @@ local void make_table OF((int nchar, uch bitlen[], #define NT (CODE_BIT + 3) #define PBIT 4 /* smallest integer such that (1U << PBIT) > NP */ #define TBIT 5 /* smallest integer such that (1U << TBIT) > NT */ -#if NT > NP -# define NPT NT -#else -# define NPT NP -#endif +#define NPT (1< 1 << tablebits) + error("Bad table\n"); for (i = start[len]; i < nextcode; i++) table[i] = ch; } else { k = start[len]; @@ -223,6 +221,8 @@ local void read_pt_len(nn, nbit, i_special) if (c == 7) { mask = (unsigned) 1 << (BITBUFSIZ - 1 - 3); while (mask & bitbuf) { mask >>= 1; c++; } + if (c > 16) + error("Bad table\n"); } fillbuf((c < 7) ? 3 : c - 3); pt_len[i++] = c;