aboutsummaryrefslogtreecommitdiff
path: root/src/liblzma/common/alone_decoder.c
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2008-12-27 19:27:49 +0200
committerLasse Collin <lasse.collin@tukaani.org>2008-12-27 19:27:49 +0200
commite33194e79d8f5ce07cb4aca909b324ae75098f7e (patch)
tree6a1db024ccdbe49ea8d03dacf9ab0ebcedaa6688 /src/liblzma/common/alone_decoder.c
parentUpdated Makefile.am that was missing from the previous commit. (diff)
downloadxz-e33194e79d8f5ce07cb4aca909b324ae75098f7e.tar.xz
Bunch of liblzma tweaks, including some API changes.
The API and ABI should now be very close to stable, although the code behind it isn't yet.
Diffstat (limited to 'src/liblzma/common/alone_decoder.c')
-rw-r--r--src/liblzma/common/alone_decoder.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/src/liblzma/common/alone_decoder.c b/src/liblzma/common/alone_decoder.c
index 6845537f..e850a926 100644
--- a/src/liblzma/common/alone_decoder.c
+++ b/src/liblzma/common/alone_decoder.c
@@ -75,24 +75,24 @@ alone_decode(lzma_coder *coder,
|= (size_t)(in[*in_pos]) << (coder->pos * 8);
if (++coder->pos == 4) {
- if (coder->options.dict_size > (UINT32_C(1) << 30))
- return LZMA_FORMAT_ERROR;
-
- // A hack to ditch tons of false positives: We allow
- // only dictionary sizes that are 2^n or 2^n + 2^(n-1).
- // LZMA_Alone created only files with 2^n, but accepts
- // any dictionary size. If someone complains, this
- // will be reconsidered.
- uint32_t d = coder->options.dict_size - 1;
- d |= d >> 2;
- d |= d >> 3;
- d |= d >> 4;
- d |= d >> 8;
- d |= d >> 16;
- ++d;
-
- if (d != coder->options.dict_size)
- return LZMA_FORMAT_ERROR;
+ if (coder->options.dict_size != UINT32_MAX) {
+ // A hack to ditch tons of false positives:
+ // We allow only dictionary sizes that are
+ // 2^n or 2^n + 2^(n-1). LZMA_Alone created
+ // only files with 2^n, but accepts any
+ // dictionary size. If someone complains, this
+ // will be reconsidered.
+ uint32_t d = coder->options.dict_size - 1;
+ d |= d >> 2;
+ d |= d >> 3;
+ d |= d >> 4;
+ d |= d >> 8;
+ d |= d >> 16;
+ ++d;
+
+ if (d != coder->options.dict_size)
+ return LZMA_FORMAT_ERROR;
+ }
coder->pos = 0;
coder->sequence = SEQ_UNCOMPRESSED_SIZE;