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>
This commit is contained in:
Lasse Collin 2011-05-01 19:38:42 +03:00 committed by Linus Torvalds
parent 3fd9952df4
commit 646032e3b0

View File

@ -969,6 +969,9 @@ XZ_EXTERN enum xz_ret xz_dec_lzma2_run(struct xz_dec_lzma2 *s,
*/ */
tmp = b->in[b->in_pos++]; tmp = b->in[b->in_pos++];
if (tmp == 0x00)
return XZ_STREAM_END;
if (tmp >= 0xE0 || tmp == 0x01) { if (tmp >= 0xE0 || tmp == 0x01) {
s->lzma2.need_props = true; s->lzma2.need_props = true;
s->lzma2.need_dict_reset = false; 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); lzma_reset(s);
} }
} else { } else {
if (tmp == 0x00)
return XZ_STREAM_END;
if (tmp > 0x02) if (tmp > 0x02)
return XZ_DATA_ERROR; return XZ_DATA_ERROR;