Commit 646032e3b05b32d3f20cb108a030593d9d792eb5

Authored by Lasse Collin
Committed by Linus Torvalds
1 parent 3fd9952df4

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>

Showing 1 changed file with 3 additions and 3 deletions Side-by-side Diff

lib/xz/xz_dec_lzma2.c
... ... @@ -969,6 +969,9 @@
969 969 */
970 970 tmp = b->in[b->in_pos++];
971 971  
  972 + if (tmp == 0x00)
  973 + return XZ_STREAM_END;
  974 +
972 975 if (tmp >= 0xE0 || tmp == 0x01) {
973 976 s->lzma2.need_props = true;
974 977 s->lzma2.need_dict_reset = false;
... ... @@ -1001,9 +1004,6 @@
1001 1004 lzma_reset(s);
1002 1005 }
1003 1006 } else {
1004   - if (tmp == 0x00)
1005   - return XZ_STREAM_END;
1006   -
1007 1007 if (tmp > 0x02)
1008 1008 return XZ_DATA_ERROR;
1009 1009