summaryrefslogtreecommitdiffstats
path: root/lib/xz/xz_dec_lzma2.c
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2011-05-01 19:38:42 +0300
committerLinus Torvalds <torvalds@linux-foundation.org>2011-05-02 08:46:12 -0700
commit646032e3b05b32d3f20cb108a030593d9d792eb5 (patch)
tree1ced1d6ba3628d76ae389175b0f2c24711358d84 /lib/xz/xz_dec_lzma2.c
parent3fd9952df4964fac7d5868ba48eadcc9dae3ba46 (diff)
downloadlinux-646032e3b05b32d3f20cb108a030593d9d792eb5.tar.gz
linux-646032e3b05b32d3f20cb108a030593d9d792eb5.tar.bz2
linux-646032e3b05b32d3f20cb108a030593d9d792eb5.zip
XZ decompressor: Fix decoding of empty LZMA2 streams
The old code considered valid empty LZMA2 streams to be corrupt. Note that a typical empty .xz file has no LZMA2 data at all, and thus most .xz files having no uncompressed data are handled correctly even without this fix. Signed-off-by: Lasse Collin <lasse.collin@tukaani.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'lib/xz/xz_dec_lzma2.c')
-rw-r--r--lib/xz/xz_dec_lzma2.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/xz/xz_dec_lzma2.c b/lib/xz/xz_dec_lzma2.c
index ea5fa4fe9d67..a6cdc969ea42 100644
--- a/lib/xz/xz_dec_lzma2.c
+++ b/lib/xz/xz_dec_lzma2.c
@@ -969,6 +969,9 @@ XZ_EXTERN enum xz_ret xz_dec_lzma2_run(struct xz_dec_lzma2 *s,
*/
tmp = b->in[b->in_pos++];
+ if (tmp == 0x00)
+ return XZ_STREAM_END;
+
if (tmp >= 0xE0 || tmp == 0x01) {
s->lzma2.need_props = true;
s->lzma2.need_dict_reset = false;
@@ -1001,9 +1004,6 @@ XZ_EXTERN enum xz_ret xz_dec_lzma2_run(struct xz_dec_lzma2 *s,
lzma_reset(s);
}
} else {
- if (tmp == 0x00)
- return XZ_STREAM_END;
-
if (tmp > 0x02)
return XZ_DATA_ERROR;