| ... | ... |
@@ -646,7 +646,6 @@ int cli_scanxar(cli_ctx *ctx) |
| 646 | 646 |
|
| 647 | 647 |
xar_hash_update(a_hash_ctx, blockp, CLI_LZMA_HDR_SIZE, a_hash); |
| 648 | 648 |
|
| 649 |
- |
|
| 650 | 649 |
rc = cli_LzmaInit(&lz, 0); |
| 651 | 650 |
if (rc != LZMA_RESULT_OK) {
|
| 652 | 651 |
cli_errmsg("cli_scanxar: cli_LzmaInit() fails: %i.\n", rc);
|
| ... | ... |
@@ -660,12 +659,13 @@ int cli_scanxar(cli_ctx *ctx) |
| 660 | 660 |
while (at < map->len && at < offset+hdr.toc_length_compressed+hdr.size+length) {
|
| 661 | 661 |
SizeT avail_in; |
| 662 | 662 |
SizeT avail_out; |
| 663 |
+ void * next_in; |
|
| 663 | 664 |
unsigned long in_consumed; |
| 664 | 665 |
|
| 665 | 666 |
lz.next_out = buff; |
| 666 | 667 |
lz.avail_out = CLI_LZMA_OBUF_SIZE; |
| 667 | 668 |
lz.avail_in = avail_in = MIN(CLI_LZMA_OBUF_SIZE>>CLI_LZMA_CRATIO_SHIFT, in_remaining); |
| 668 |
- lz.next_in = (void*)fmap_need_off_once(map, at, lz.avail_in); |
|
| 669 |
+ lz.next_in = next_in = (void*)fmap_need_off_once(map, at, lz.avail_in); |
|
| 669 | 670 |
if (lz.next_in == NULL) {
|
| 670 | 671 |
cli_errmsg("cli_scanxar: Can't read %li bytes @ %li, errno: %s.\n",
|
| 671 | 672 |
length, at, strerror(errno)); |
| ... | ... |
@@ -675,8 +675,6 @@ int cli_scanxar(cli_ctx *ctx) |
| 675 | 675 |
goto exit_tmpfile; |
| 676 | 676 |
} |
| 677 | 677 |
|
| 678 |
- xar_hash_update(a_hash_ctx, lz.next_in, avail_in, a_hash); |
|
| 679 |
- |
|
| 680 | 678 |
rc = cli_LzmaDecode(&lz); |
| 681 | 679 |
if (rc != LZMA_RESULT_OK && rc != LZMA_STREAM_END) {
|
| 682 | 680 |
cli_errmsg("cli_scanxar: cli_LzmaDecode() fails: %i.\n", rc);
|
| ... | ... |
@@ -691,21 +689,17 @@ int cli_scanxar(cli_ctx *ctx) |
| 691 | 691 |
at += in_consumed; |
| 692 | 692 |
avail_out = CLI_LZMA_OBUF_SIZE - lz.avail_out; |
| 693 | 693 |
|
| 694 |
- if (avail_out == 0) {
|
|
| 695 |
- cli_errmsg("cli_scanxar: cli_LzmaDecode() produces no output for "
|
|
| 694 |
+ if (avail_out == 0) |
|
| 695 |
+ cli_dbgmsg("cli_scanxar: cli_LzmaDecode() produces no output for "
|
|
| 696 | 696 |
"avail_in %lu, avail_out %lu.\n", avail_in, avail_out); |
| 697 |
- rc = CL_EFORMAT; |
|
| 698 |
- __lzma_wrap_free(NULL, buff); |
|
| 699 |
- cli_LzmaShutdown(&lz); |
|
| 700 |
- goto exit_tmpfile; |
|
| 701 |
- } |
|
| 702 |
- |
|
| 697 |
+ |
|
| 698 |
+ xar_hash_update(a_hash_ctx, next_in, in_consumed, a_hash); |
|
| 703 | 699 |
xar_hash_update(e_hash_ctx, buff, avail_out, e_hash); |
| 704 | 700 |
|
| 705 | 701 |
/* Write a decompressed block. */ |
| 706 |
- cli_dbgmsg("Writing %li bytes to LZMA decompress temp file, "
|
|
| 707 |
- "consumed %li of %li available compressed bytes.\n", |
|
| 708 |
- avail_out, in_consumed, avail_in); |
|
| 702 |
+ /* cli_dbgmsg("Writing %li bytes to LZMA decompress temp file, " */
|
|
| 703 |
+ /* "consumed %li of %li available compressed bytes.\n", */ |
|
| 704 |
+ /* avail_out, in_consumed, avail_in); */ |
|
| 709 | 705 |
|
| 710 | 706 |
if (cli_writen(fd, buff, avail_out) < 0) {
|
| 711 | 707 |
cli_dbgmsg("cli_scanxar: cli_writen error writing lzma temp file for %li bytes.\n",
|
| ... | ... |
@@ -736,7 +730,6 @@ int cli_scanxar(cli_ctx *ctx) |
| 736 | 736 |
case CL_TYPE_ANY: |
| 737 | 737 |
{
|
| 738 | 738 |
/* for uncompressed, bzip2, and unknown, just pull the file, cli_magic_scandesc does the rest */ |
| 739 |
- // TODO ensure correct bounds for at/length |
|
| 740 | 739 |
unsigned long write_len; |
| 741 | 740 |
|
| 742 | 741 |
if (ctx->engine->maxfilesize) |