Fix off by one error in a test.
authorRob Landley <rob@landley.net>
Wed, 17 Jan 2007 21:31:23 +0000 (16:31 -0500)
committerRob Landley <rob@landley.net>
Wed, 17 Jan 2007 21:31:23 +0000 (16:31 -0500)
lib/bunzip.c

index 5c3b842..01daa78 100644 (file)
@@ -197,7 +197,9 @@ int read_bunzip_data(bunzip_data *bd)
                t = get_bits(bd, 5);
                for (i = 0; i < symCount; i++) {
                        for(;;) {
-                               if (MAX_HUFCODE_BITS < (unsigned)t-1) return RETVAL_DATA_ERROR;
+                               // !t || t > MAX_HUFCODE_BITS in one test.
+                               if (MAX_HUFCODE_BITS-1 < (unsigned)t-1)
+                                       return RETVAL_DATA_ERROR;
                                if(!get_bits(bd, 1)) break;    // Stop yet?
                                t += (1 - 2*get_bits(bd, 1));  // bit ? t-- : t++
                        }