diff options
author | Lasse Collin <lasse.collin@tukaani.org> | 2008-09-12 22:41:40 +0300 |
---|---|---|
committer | Lasse Collin <lasse.collin@tukaani.org> | 2008-09-12 22:41:40 +0300 |
commit | 320601b2c7b08fc7da9da18d5bf7c3c1a189b080 (patch) | |
tree | 3846af51e6904d900e5cd8337baf0728a42a07fe /src/liblzma/common/stream_flags_encoder.c | |
parent | Simplified debug/known_sizes.c to match the relaxed (diff) | |
download | xz-320601b2c7b08fc7da9da18d5bf7c3c1a189b080.tar.xz |
Improved the Stream Flags handling API.
Diffstat (limited to 'src/liblzma/common/stream_flags_encoder.c')
-rw-r--r-- | src/liblzma/common/stream_flags_encoder.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/liblzma/common/stream_flags_encoder.c b/src/liblzma/common/stream_flags_encoder.c index 1d736a8a..88ed81e0 100644 --- a/src/liblzma/common/stream_flags_encoder.c +++ b/src/liblzma/common/stream_flags_encoder.c @@ -39,6 +39,9 @@ lzma_stream_header_encode(const lzma_stream_flags *options, uint8_t *out) assert(sizeof(lzma_header_magic) + LZMA_STREAM_FLAGS_SIZE + 4 == LZMA_STREAM_HEADER_SIZE); + if (options->version != 0) + return LZMA_HEADER_ERROR; + // Magic memcpy(out, lzma_header_magic, sizeof(lzma_header_magic)); @@ -63,10 +66,11 @@ lzma_stream_footer_encode(const lzma_stream_flags *options, uint8_t *out) assert(2 * 4 + LZMA_STREAM_FLAGS_SIZE + sizeof(lzma_footer_magic) == LZMA_STREAM_HEADER_SIZE); + if (options->version != 0) + return LZMA_HEADER_ERROR; + // Backward Size - if (options->backward_size < LZMA_BACKWARD_SIZE_MIN - || options->backward_size > LZMA_BACKWARD_SIZE_MAX - || (options->backward_size & 3)) + if (!is_backward_size_valid(options)) return LZMA_PROG_ERROR; integer_write_32(out + 4, options->backward_size / 4 - 1); |