Skip to content

Commit

Permalink
XZ decompressor: Fix decoding of empty LZMA2 streams
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Larhzu authored and torvalds committed May 2, 2011
1 parent 3fd9952 commit 646032e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/xz/xz_dec_lzma2.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 646032e

Please sign in to comment.