134 struct xz_dec_bcj *bcj;
139 #ifdef XZ_DEC_ANY_CHECK
141 static const uint8_t check_sizes[16] = {
159 size_t copy_size =
min_t(
size_t,
164 s->
temp.pos += copy_size;
176 size_t *in_pos,
size_t in_size)
183 while (*in_pos < in_size) {
189 if ((byte & 0x80) == 0) {
191 if (byte == 0 && s->
pos != 0)
227 ret = xz_dec_bcj_run(s->bcj, s->
lzma2, b);
240 || s->
block.uncompressed
251 != s->
block.compressed)
256 != s->
block.uncompressed)
260 + s->
block.compressed;
262 #ifdef XZ_DEC_ANY_CHECK
266 s->
block.hash.unpadded += 4;
269 s->
block.hash.uncompressed += s->
block.uncompressed;
281 static void index_update(
struct xz_dec *s,
const struct xz_buf *b)
284 s->
index.size += in_used;
307 switch (s->
index.sequence) {
308 case SEQ_INDEX_COUNT:
319 s->
index.sequence = SEQ_INDEX_UNPADDED;
322 case SEQ_INDEX_UNPADDED:
324 s->
index.sequence = SEQ_INDEX_UNCOMPRESSED;
327 case SEQ_INDEX_UNCOMPRESSED:
328 s->
index.hash.uncompressed += s->
vli;
331 sizeof(s->
index.hash),
332 s->
index.hash.crc32);
334 s->
index.sequence = SEQ_INDEX_UNPADDED;
337 }
while (s->
index.count > 0);
357 }
while (s->
pos < 32);
365 #ifdef XZ_DEC_ANY_CHECK
370 static bool check_skip(
struct xz_dec *s,
struct xz_buf *b)
407 #ifdef XZ_DEC_ANY_CHECK
435 if ((s->
index.size >> 2) != get_le32(s->
temp.buf + 4))
459 != get_le32(s->
temp.buf + s->
temp.size))
469 if (s->
temp.buf[1] & 0x3E)
471 if (s->
temp.buf[1] & 0x3F)
476 if (s->
temp.buf[1] & 0x40) {
487 if (s->
temp.buf[1] & 0x80) {
499 s->bcj_active = s->
temp.buf[1] & 0x01;
504 ret = xz_dec_bcj_reset(s->bcj, s->
temp.buf[s->
temp.pos++]);
512 if (s->
temp.buf[s->
temp.pos++] != 0x00)
522 if (s->
temp.buf[s->
temp.pos++] != 0x21)
526 if (s->
temp.buf[s->
temp.pos++] != 0x01)
539 if (s->
temp.buf[s->
temp.pos++] != 0x00)
543 s->
block.compressed = 0;
544 s->
block.uncompressed = 0;
561 case SEQ_STREAM_HEADER:
570 if (!fill_temp(s, b))
582 ret = dec_stream_header(s);
586 case SEQ_BLOCK_START:
609 case SEQ_BLOCK_HEADER:
610 if (!fill_temp(s, b))
613 ret = dec_block_header(s);
619 case SEQ_BLOCK_UNCOMPRESS:
620 ret = dec_block(s, b);
626 case SEQ_BLOCK_PADDING:
634 while (s->
block.compressed & 3) {
641 ++s->
block.compressed;
646 case SEQ_BLOCK_CHECK:
648 ret = crc32_validate(s, b);
652 #ifdef XZ_DEC_ANY_CHECK
653 else if (!check_skip(s, b)) {
662 ret = dec_index(s, b);
668 case SEQ_INDEX_PADDING:
685 sizeof(s->
block.hash)))
690 case SEQ_INDEX_CRC32:
691 ret = crc32_validate(s, b);
698 case SEQ_STREAM_FOOTER:
699 if (!fill_temp(s, b))
702 return dec_stream_footer(s);
745 ret = dec_main(s, b);
793 xz_dec_bcj_end(s->bcj);
817 xz_dec_bcj_end(s->bcj);