A pathological case of huffman coding that uses 8 bits to code each of 256
authorRob Landley <rob@landley.net>
Sat, 28 Jun 2008 06:07:34 +0000 (01:07 -0500)
committerRob Landley <rob@landley.net>
Sat, 28 Jun 2008 06:07:34 +0000 (01:07 -0500)
symbols could cause an unsigned char limit[8] to wrap back to 0, setting
limit to -1 and making the decompressor exit with a data error.

lib/bunzip.c

index f923b0c..ae84289 100644 (file)
@@ -204,8 +204,9 @@ static int read_block_header(struct bunzip_data *bd, struct bwdata *bw)
        // literal symbols, plus two run symbols (RUNA, RUNB)
        symCount = bd->symTotal+2;
        for (jj=0; jj<bd->groupCount; jj++) {
-               unsigned char length[MAX_SYMBOLS], temp[MAX_HUFCODE_BITS+1];
-               int     minLen, maxLen, pp;
+               unsigned char length[MAX_SYMBOLS];
+               unsigned temp[MAX_HUFCODE_BITS+1];
+               int minLen, maxLen, pp;
 
                // Read lengths
                hh = get_bits(bd, 5);