From: Grzegorz Antoniak Date: Mon, 23 Dec 2019 07:20:28 +0000 (+0100) Subject: ZIP reader: support LZMA_STREAM_END marker in 'lzma alone' files X-Git-Tag: v3.4.1~3^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F1297%2Fhead;p=thirdparty%2Flibarchive.git ZIP reader: support LZMA_STREAM_END marker in 'lzma alone' files It appears that ZIPX files with type 14 stream ('lzma alone') can contain LZMA_STREAM_END markers at the end of the stream. The ZIP reader was displaying an "unknown error 1" status after encountering such marker. The fix handles such case, and the reader doesn't return error status anymore. Thus it should be possible to unpack files that contain the LZMA_STREAM_END marker at the end of the stream. Fixes #1257 --- diff --git a/libarchive/archive_read_support_format_zip.c b/libarchive/archive_read_support_format_zip.c index 9934bf150..6581ca0ac 100644 --- a/libarchive/archive_read_support_format_zip.c +++ b/libarchive/archive_read_support_format_zip.c @@ -1797,6 +1797,23 @@ zip_read_data_zipx_lzma_alone(struct archive_read *a, const void **buff, "lzma data error (error %d)", (int) lz_ret); return (ARCHIVE_FATAL); + /* This case is optional in lzma alone format. It can happen, + * but most of the files don't have it. (GitHub #1257) */ + case LZMA_STREAM_END: + lzma_end(&zip->zipx_lzma_stream); + zip->zipx_lzma_valid = 0; + if((int64_t) zip->zipx_lzma_stream.total_in != + zip->entry_bytes_remaining) + { + archive_set_error(&a->archive, + ARCHIVE_ERRNO_MISC, + "lzma alone premature end of stream"); + return (ARCHIVE_FATAL); + } + + zip->end_of_entry = 1; + break; + case LZMA_OK: break;