aboutsummaryrefslogtreecommitdiff
path: root/src/liblzma/common
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2008-12-15 23:26:43 +0200
committerLasse Collin <lasse.collin@tukaani.org>2008-12-15 23:26:43 +0200
commit653e457e3756ef35e5d1b2be3523b3e4b1e9ee4d (patch)
tree6c022308b5bc98eb120b20143ea1fcc4564020b1 /src/liblzma/common
parentBunch of liblzma API cleanups and fixes. (diff)
downloadxz-653e457e3756ef35e5d1b2be3523b3e4b1e9ee4d.tar.xz
Fix a dumb bug in .lzma decoder which was introduced in
the previous commit. (Probably the previous commit has other bugs too, it wasn't tested.)
Diffstat (limited to '')
-rw-r--r--src/liblzma/common/alone_decoder.c29
1 files changed, 14 insertions, 15 deletions
diff --git a/src/liblzma/common/alone_decoder.c b/src/liblzma/common/alone_decoder.c
index 32d44311..6845537f 100644
--- a/src/liblzma/common/alone_decoder.c
+++ b/src/liblzma/common/alone_decoder.c
@@ -104,28 +104,27 @@ alone_decode(lzma_coder *coder,
case SEQ_UNCOMPRESSED_SIZE:
coder->uncompressed_size
|= (lzma_vli)(in[*in_pos]) << (coder->pos * 8);
-
- if (++coder->pos == 8) {
- // Another hack to ditch false positives: Assume that
- // if the uncompressed size is known, it must be less
- // than 256 GiB. Again, if someone complains, this
- // will be reconsidered.
- if (coder->uncompressed_size != LZMA_VLI_UNKNOWN
- && coder->uncompressed_size
- >= (LZMA_VLI_C(1) << 38))
- return LZMA_FORMAT_ERROR;
-
- coder->pos = 0;
- coder->sequence = SEQ_CODER_INIT;
- }
-
++*in_pos;
+ if (++coder->pos < 8)
+ break;
+
+ // Another hack to ditch false positives: Assume that
+ // if the uncompressed size is known, it must be less
+ // than 256 GiB. Again, if someone complains, this
+ // will be reconsidered.
+ if (coder->uncompressed_size != LZMA_VLI_UNKNOWN
+ && coder->uncompressed_size
+ >= (LZMA_VLI_C(1) << 38))
+ return LZMA_FORMAT_ERROR;
// Calculate the memory usage so that it is ready
// for SEQ_CODER_INIT.
coder->memusage = lzma_lzma_decoder_memusage(&coder->options)
+ LZMA_MEMUSAGE_BASE;
+ coder->pos = 0;
+ coder->sequence = SEQ_CODER_INIT;
+
// Fall through
case SEQ_CODER_INIT: {