aboutsummaryrefslogtreecommitdiff
path: root/src/liblzma/common/block_decoder.c
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2009-05-26 14:48:48 +0300
committerLasse Collin <lasse.collin@tukaani.org>2009-05-26 14:48:48 +0300
commit083c23c680ff844846d177cfc58bb7a874e7e6b9 (patch)
treea6263783a9cb49f21ba562df7553e39e38ddcf99 /src/liblzma/common/block_decoder.c
parentRemove undocumented alternative option names --bcj, --ppc, (diff)
downloadxz-083c23c680ff844846d177cfc58bb7a874e7e6b9.tar.xz
Make the raw value of the Check field available to applications
via lzma_block structure. This changes ABI but not doesn't break API.
Diffstat (limited to '')
-rw-r--r--src/liblzma/common/block_decoder.c34
1 files changed, 15 insertions, 19 deletions
diff --git a/src/liblzma/common/block_decoder.c b/src/liblzma/common/block_decoder.c
index 9b998e63..a3ce6f49 100644
--- a/src/liblzma/common/block_decoder.c
+++ b/src/liblzma/common/block_decoder.c
@@ -146,26 +146,22 @@ block_decode(lzma_coder *coder, lzma_allocator *allocator,
// Fall through
case SEQ_CHECK: {
- const bool chksup = lzma_check_is_supported(
- coder->block->check);
-
- while (*in_pos < in_size) {
- // coder->check.buffer[] may be uninitialized when
- // the Check ID is not supported.
- if (chksup && coder->check.buffer.u8[coder->check_pos]
- != in[*in_pos]) {
- ++*in_pos;
- return LZMA_DATA_ERROR;
- }
-
- ++*in_pos;
-
- if (++coder->check_pos == lzma_check_size(
- coder->block->check))
- return LZMA_STREAM_END;
- }
+ const size_t check_size = lzma_check_size(coder->block->check);
+ lzma_bufcpy(in, in_pos, in_size, coder->block->raw_check,
+ &coder->check_pos, check_size);
+ if (coder->check_pos < check_size)
+ return LZMA_OK;
+
+ // Validate the Check only if we support it.
+ // coder->check.buffer may be uninitialized
+ // when the Check ID is not supported.
+ if (lzma_check_is_supported(coder->block->check)
+ && memcmp(coder->block->raw_check,
+ coder->check.buffer.u8,
+ check_size) != 0)
+ return LZMA_DATA_ERROR;
- return LZMA_OK;
+ return LZMA_STREAM_END;
}
}