diff options
Diffstat (limited to '')
-rw-r--r-- | compress.c | 2 | ||||
-rw-r--r-- | decompress.c | 10 |
2 files changed, 9 insertions, 3 deletions
@@ -454,7 +454,7 @@ void sendMTFValues ( EState* s ) | |||
454 | 454 | ||
455 | AssertH( nGroups < 8, 3002 ); | 455 | AssertH( nGroups < 8, 3002 ); |
456 | AssertH( nSelectors < 32768 && | 456 | AssertH( nSelectors < 32768 && |
457 | nSelectors <= (2 + (900000 / BZ_G_SIZE)), | 457 | nSelectors <= BZ_MAX_SELECTORS, |
458 | 3003 ); | 458 | 3003 ); |
459 | 459 | ||
460 | 460 | ||
diff --git a/decompress.c b/decompress.c index 20ce493..3303499 100644 --- a/decompress.c +++ b/decompress.c | |||
@@ -287,7 +287,7 @@ Int32 BZ2_decompress ( DState* s ) | |||
287 | GET_BITS(BZ_X_SELECTOR_1, nGroups, 3); | 287 | GET_BITS(BZ_X_SELECTOR_1, nGroups, 3); |
288 | if (nGroups < 2 || nGroups > BZ_N_GROUPS) RETURN(BZ_DATA_ERROR); | 288 | if (nGroups < 2 || nGroups > BZ_N_GROUPS) RETURN(BZ_DATA_ERROR); |
289 | GET_BITS(BZ_X_SELECTOR_2, nSelectors, 15); | 289 | GET_BITS(BZ_X_SELECTOR_2, nSelectors, 15); |
290 | if (nSelectors < 1 || nSelectors > BZ_MAX_SELECTORS) RETURN(BZ_DATA_ERROR); | 290 | if (nSelectors < 1) RETURN(BZ_DATA_ERROR); |
291 | for (i = 0; i < nSelectors; i++) { | 291 | for (i = 0; i < nSelectors; i++) { |
292 | j = 0; | 292 | j = 0; |
293 | while (True) { | 293 | while (True) { |
@@ -296,8 +296,14 @@ Int32 BZ2_decompress ( DState* s ) | |||
296 | j++; | 296 | j++; |
297 | if (j >= nGroups) RETURN(BZ_DATA_ERROR); | 297 | if (j >= nGroups) RETURN(BZ_DATA_ERROR); |
298 | } | 298 | } |
299 | s->selectorMtf[i] = j; | 299 | /* Having more than BZ_MAX_SELECTORS doesn't make much sense |
300 | since they will never be used, but some implementations might | ||
301 | "round up" the number of selectors, so just ignore those. */ | ||
302 | if (i < BZ_MAX_SELECTORS) | ||
303 | s->selectorMtf[i] = j; | ||
300 | } | 304 | } |
305 | if (nSelectors > BZ_MAX_SELECTORS) | ||
306 | nSelectors = BZ_MAX_SELECTORS; | ||
301 | 307 | ||
302 | /*--- Undo the MTF values for the selectors. ---*/ | 308 | /*--- Undo the MTF values for the selectors. ---*/ |
303 | { | 309 | { |