diff options
-rw-r--r-- | archival/libunarchive/decompress_unxz.c | 1 | ||||
-rw-r--r-- | archival/libunarchive/unxz/xz.h | 4 | ||||
-rw-r--r-- | archival/libunarchive/unxz/xz_dec_lzma2.c | 4 | ||||
-rw-r--r-- | archival/libunarchive/unxz/xz_dec_stream.c | 35 |
4 files changed, 11 insertions, 33 deletions
diff --git a/archival/libunarchive/decompress_unxz.c b/archival/libunarchive/decompress_unxz.c index 9edc2461a..924a52513 100644 --- a/archival/libunarchive/decompress_unxz.c +++ b/archival/libunarchive/decompress_unxz.c @@ -12,7 +12,6 @@ #include "libbb.h" #include "unarchive.h" -//#define XZ_DEBUG_MSG(...) bb_error_msg(__VA_ARGS) #define XZ_REALLOC_DICT_BUF(ptr, size) xrealloc(ptr, size) #define XZ_FUNC FAST_FUNC #define XZ_EXTERN static diff --git a/archival/libunarchive/unxz/xz.h b/archival/libunarchive/unxz/xz.h index 82f16ee22..dbb9ba92d 100644 --- a/archival/libunarchive/unxz/xz.h +++ b/archival/libunarchive/unxz/xz.h @@ -19,10 +19,6 @@ # include <stdint.h> #endif -#ifndef XZ_DEBUG_MSG -# define XZ_DEBUG_MSG(...) ((void)0) -#endif - /* In Linux, this is used to make extern functions static when needed. */ #ifndef XZ_EXTERN # define XZ_EXTERN extern diff --git a/archival/libunarchive/unxz/xz_dec_lzma2.c b/archival/libunarchive/unxz/xz_dec_lzma2.c index 890141b7c..c22dc5ba5 100644 --- a/archival/libunarchive/unxz/xz_dec_lzma2.c +++ b/archival/libunarchive/unxz/xz_dec_lzma2.c @@ -1117,10 +1117,8 @@ XZ_EXTERN enum xz_ret XZ_FUNC xz_dec_lzma2_reset( struct xz_dec_lzma2 *s, uint8_t props) { /* This limits dictionary size to 3 GiB to keep parsing simpler. */ - if (props > 39) { - XZ_DEBUG_MSG("props:%d", props); + if (props > 39) return XZ_OPTIONS_ERROR; - } s->dict.size = 2 + (props & 1); s->dict.size <<= (props >> 1) + 11; diff --git a/archival/libunarchive/unxz/xz_dec_stream.c b/archival/libunarchive/unxz/xz_dec_stream.c index e10c9413d..121c3b53a 100644 --- a/archival/libunarchive/unxz/xz_dec_stream.c +++ b/archival/libunarchive/unxz/xz_dec_stream.c @@ -365,16 +365,14 @@ static enum xz_ret XZ_FUNC dec_stream_header(struct xz_dec *s) /* * Decode the Stream Flags field. Of integrity checks, we support * only none (Check ID = 0) and CRC32 (Check ID = 1). + * We also accept CRC64 and SHA-256, but they will not be verified. */ if (s->temp.buf[HEADER_MAGIC_SIZE] != 0 - || (s->temp.buf[HEADER_MAGIC_SIZE + 1] > 1 - && s->temp.buf[HEADER_MAGIC_SIZE + 1] != 0x04 - && s->temp.buf[HEADER_MAGIC_SIZE + 1] != 0x0A - ) + || (s->temp.buf[HEADER_MAGIC_SIZE + 1] > 1 + && s->temp.buf[HEADER_MAGIC_SIZE + 1] != 0x04 /* CRC64 */ + && s->temp.buf[HEADER_MAGIC_SIZE + 1] != 0x0A /* SHA-256 */ + ) ) { - XZ_DEBUG_MSG("unsupported stream flags %x:%x", - s->temp.buf[HEADER_MAGIC_SIZE], - s->temp.buf[HEADER_MAGIC_SIZE+1]); return XZ_OPTIONS_ERROR; } @@ -435,10 +433,7 @@ static enum xz_ret XZ_FUNC dec_block_header(struct xz_dec *s) #else if (s->temp.buf[1] & 0x3F) #endif - { - XZ_DEBUG_MSG("s->temp.buf[1] & 0x3E/3F != 0"); return XZ_OPTIONS_ERROR; - } /* Compressed Size */ if (s->temp.buf[1] & 0x40) { @@ -466,10 +461,8 @@ static enum xz_ret XZ_FUNC dec_block_header(struct xz_dec *s) /* If there are two filters, the first one must be a BCJ filter. */ s->bcj_active = s->temp.buf[1] & 0x01; if (s->bcj_active) { - if (s->temp.size - s->temp.pos < 2) { - XZ_DEBUG_MSG("temp.size - temp.pos < 2"); + if (s->temp.size - s->temp.pos < 2) return XZ_OPTIONS_ERROR; - } ret = xz_dec_bcj_reset(s->bcj, s->temp.buf[s->temp.pos++]); if (ret != XZ_OK) @@ -479,10 +472,8 @@ static enum xz_ret XZ_FUNC dec_block_header(struct xz_dec *s) * We don't support custom start offset, * so Size of Properties must be zero. */ - if (s->temp.buf[s->temp.pos++] != 0x00) { - XZ_DEBUG_MSG("size of properties != 0"); + if (s->temp.buf[s->temp.pos++] != 0x00) return XZ_OPTIONS_ERROR; - } } #endif @@ -491,16 +482,12 @@ static enum xz_ret XZ_FUNC dec_block_header(struct xz_dec *s) return XZ_DATA_ERROR; /* Filter ID = LZMA2 */ - if (s->temp.buf[s->temp.pos++] != 0x21) { - XZ_DEBUG_MSG("filter ID != 0x21"); + if (s->temp.buf[s->temp.pos++] != 0x21) return XZ_OPTIONS_ERROR; - } /* Size of Properties = 1-byte Filter Properties */ - if (s->temp.buf[s->temp.pos++] != 0x01) { - XZ_DEBUG_MSG("size of properties != 1"); + if (s->temp.buf[s->temp.pos++] != 0x01) return XZ_OPTIONS_ERROR; - } /* Filter Properties contains LZMA2 dictionary size. */ if (s->temp.size - s->temp.pos < 1) @@ -512,10 +499,8 @@ static enum xz_ret XZ_FUNC dec_block_header(struct xz_dec *s) /* The rest must be Header Padding. */ while (s->temp.pos < s->temp.size) - if (s->temp.buf[s->temp.pos++] != 0x00) { - XZ_DEBUG_MSG("padding is not zero-filled"); + if (s->temp.buf[s->temp.pos++] != 0x00) return XZ_OPTIONS_ERROR; - } s->temp.pos = 0; s->block.compressed = 0; |