diff options
Diffstat (limited to 'archival')
-rw-r--r-- | archival/bz/README | 2 | ||||
-rw-r--r-- | archival/libunarchive/decompress_bunzip2.c | 15 |
2 files changed, 10 insertions, 7 deletions
diff --git a/archival/bz/README b/archival/bz/README index 3015342cb..fffd47b8a 100644 --- a/archival/bz/README +++ b/archival/bz/README | |||
@@ -1,4 +1,4 @@ | |||
1 | This file is an abridged version of README from bizp2 1.0.4 | 1 | This file is an abridged version of README from bzip2 1.0.4 |
2 | Build instructions (which are not relevant to busyboxed bzip2) | 2 | Build instructions (which are not relevant to busyboxed bzip2) |
3 | are removed. | 3 | are removed. |
4 | =========================================================== | 4 | =========================================================== |
diff --git a/archival/libunarchive/decompress_bunzip2.c b/archival/libunarchive/decompress_bunzip2.c index 6da09fc1b..f5050449a 100644 --- a/archival/libunarchive/decompress_bunzip2.c +++ b/archival/libunarchive/decompress_bunzip2.c | |||
@@ -143,10 +143,12 @@ static unsigned get_bits(bunzip_data *bd, int bits_wanted) | |||
143 | static int get_next_block(bunzip_data *bd) | 143 | static int get_next_block(bunzip_data *bd) |
144 | { | 144 | { |
145 | struct group_data *hufGroup; | 145 | struct group_data *hufGroup; |
146 | int dbufCount, nextSym, dbufSize, groupCount, *base, *limit, selector, | 146 | int dbufCount, nextSym, dbufSize, groupCount, *base, selector, |
147 | i, j, k, t, runPos, symCount, symTotal, nSelectors, byteCount[256]; | 147 | i, j, k, t, runPos, symCount, symTotal, nSelectors, byteCount[256]; |
148 | unsigned char uc, symToByte[256], mtfSymbol[256], *selectors; | 148 | unsigned char uc, symToByte[256], mtfSymbol[256], *selectors; |
149 | unsigned *dbuf, origPtr; | 149 | /* limit was int* but was changed to unsigned* - grep for '[x]' |
150 | * in comment to see where it is important. -- vda */ | ||
151 | unsigned *dbuf, *limit, origPtr; | ||
150 | 152 | ||
151 | dbuf = bd->dbuf; | 153 | dbuf = bd->dbuf; |
152 | dbufSize = bd->dbufSize; | 154 | dbufSize = bd->dbufSize; |
@@ -288,7 +290,7 @@ static int get_next_block(bunzip_data *bd) | |||
288 | entry. We do this again when using them (during symbol decoding).*/ | 290 | entry. We do this again when using them (during symbol decoding).*/ |
289 | 291 | ||
290 | base = hufGroup->base - 1; | 292 | base = hufGroup->base - 1; |
291 | limit = hufGroup->limit - 1; | 293 | limit = (unsigned*)hufGroup->limit - 1; |
292 | 294 | ||
293 | /* Calculate permute[]. Concurently, initialize temp[] and limit[]. */ | 295 | /* Calculate permute[]. Concurently, initialize temp[] and limit[]. */ |
294 | 296 | ||
@@ -326,6 +328,7 @@ static int get_next_block(bunzip_data *bd) | |||
326 | base[i+1] = pp - t; | 328 | base[i+1] = pp - t; |
327 | } | 329 | } |
328 | limit[maxLen+1] = INT_MAX; /* Sentinel value for reading next sym. */ | 330 | limit[maxLen+1] = INT_MAX; /* Sentinel value for reading next sym. */ |
331 | /* [x] was observed to occasionally have -1 here: -- vda */ | ||
329 | limit[maxLen] = pp + temp[maxLen] - 1; | 332 | limit[maxLen] = pp + temp[maxLen] - 1; |
330 | base[minLen] = 0; | 333 | base[minLen] = 0; |
331 | } | 334 | } |
@@ -353,7 +356,7 @@ static int get_next_block(bunzip_data *bd) | |||
353 | if (selector >= nSelectors) return RETVAL_DATA_ERROR; | 356 | if (selector >= nSelectors) return RETVAL_DATA_ERROR; |
354 | hufGroup = bd->groups + selectors[selector++]; | 357 | hufGroup = bd->groups + selectors[selector++]; |
355 | base = hufGroup->base - 1; | 358 | base = hufGroup->base - 1; |
356 | limit = hufGroup->limit - 1; | 359 | limit = (unsigned*)hufGroup->limit - 1; |
357 | continue_this_group: | 360 | continue_this_group: |
358 | 361 | ||
359 | /* Read next Huffman-coded symbol. */ | 362 | /* Read next Huffman-coded symbol. */ |
@@ -384,7 +387,7 @@ static int get_next_block(bunzip_data *bd) | |||
384 | /* Figure how how many bits are in next symbol and unget extras */ | 387 | /* Figure how how many bits are in next symbol and unget extras */ |
385 | 388 | ||
386 | i = hufGroup->minLen; | 389 | i = hufGroup->minLen; |
387 | while (j > limit[i]) ++i; | 390 | while ((unsigned)j > limit[i]) ++i; |
388 | bd->inbufBitCount += (hufGroup->maxLen - i); | 391 | bd->inbufBitCount += (hufGroup->maxLen - i); |
389 | 392 | ||
390 | /* Huffman decode value to get nextSym (with bounds checking) */ | 393 | /* Huffman decode value to get nextSym (with bounds checking) */ |
@@ -507,7 +510,7 @@ static int get_next_block(bunzip_data *bd) | |||
507 | if (dbufCount) { | 510 | if (dbufCount) { |
508 | if ((int)origPtr >= dbufCount) return RETVAL_DATA_ERROR; | 511 | if ((int)origPtr >= dbufCount) return RETVAL_DATA_ERROR; |
509 | bd->writePos = dbuf[origPtr]; | 512 | bd->writePos = dbuf[origPtr]; |
510 | bd->writeCurrent = (unsigned char)(bd->writePos & 0xff); | 513 | bd->writeCurrent = (unsigned char)(bd->writePos & 0xff); |
511 | bd->writePos >>= 8; | 514 | bd->writePos >>= 8; |
512 | bd->writeRunCountdown = 5; | 515 | bd->writeRunCountdown = 5; |
513 | } | 516 | } |