aboutsummaryrefslogtreecommitdiff
path: root/src/liblzma/common/index_decoder.c
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2008-11-19 20:46:52 +0200
committerLasse Collin <lasse.collin@tukaani.org>2008-11-19 20:46:52 +0200
commite114502b2bc371e4a45449832cb69be036360722 (patch)
tree449c41d0408f99926de202611091747f1fbe2f85 /src/liblzma/common/index_decoder.c
parentFixed the test that should have been fixed as part (diff)
downloadxz-e114502b2bc371e4a45449832cb69be036360722.tar.xz
Oh well, big messy commit again. Some highlights:
- Updated to the latest, probably final file format version. - Command line tool reworked to not use threads anymore. Threading will probably go into liblzma anyway. - Memory usage limit is now about 30 % for uncompression and about 90 % for compression. - Progress indicator with --verbose - Simplified --help and full --long-help - Upgraded to the last LGPLv2.1+ getopt_long from gnulib. - Some bug fixes
Diffstat (limited to 'src/liblzma/common/index_decoder.c')
-rw-r--r--src/liblzma/common/index_decoder.c31
1 files changed, 15 insertions, 16 deletions
diff --git a/src/liblzma/common/index_decoder.c b/src/liblzma/common/index_decoder.c
index ae66595a..5faac161 100644
--- a/src/liblzma/common/index_decoder.c
+++ b/src/liblzma/common/index_decoder.c
@@ -25,7 +25,7 @@ struct lzma_coder_s {
enum {
SEQ_INDICATOR,
SEQ_COUNT,
- SEQ_TOTAL,
+ SEQ_UNPADDED,
SEQ_UNCOMPRESSED,
SEQ_PADDING_INIT,
SEQ_PADDING,
@@ -38,8 +38,8 @@ struct lzma_coder_s {
/// Number of Records left to decode.
lzma_vli count;
- /// The most recent Total Size field
- lzma_vli total_size;
+ /// The most recent Unpadded Size field
+ lzma_vli unpadded_size;
/// The most recent Uncompressed Size field
lzma_vli uncompressed_size;
@@ -91,14 +91,14 @@ index_decode(lzma_coder *coder, lzma_allocator *allocator,
ret = LZMA_OK;
coder->pos = 0;
coder->sequence = coder->count == 0
- ? SEQ_PADDING_INIT : SEQ_TOTAL;
+ ? SEQ_PADDING_INIT : SEQ_UNPADDED;
break;
}
- case SEQ_TOTAL:
+ case SEQ_UNPADDED:
case SEQ_UNCOMPRESSED: {
- lzma_vli *size = coder->sequence == SEQ_TOTAL
- ? &coder->total_size
+ lzma_vli *size = coder->sequence == SEQ_UNPADDED
+ ? &coder->unpadded_size
: &coder->uncompressed_size;
ret = lzma_vli_decode(size, &coder->pos,
@@ -109,27 +109,26 @@ index_decode(lzma_coder *coder, lzma_allocator *allocator,
ret = LZMA_OK;
coder->pos = 0;
- if (coder->sequence == SEQ_TOTAL) {
- // Validate that encoded Total Size isn't too big.
- if (coder->total_size > TOTAL_SIZE_ENCODED_MAX)
+ if (coder->sequence == SEQ_UNPADDED) {
+ // Validate that encoded Unpadded Size isn't too small
+ // or too big.
+ if (coder->unpadded_size < UNPADDED_SIZE_MIN
+ || coder->unpadded_size
+ > UNPADDED_SIZE_MAX)
return LZMA_DATA_ERROR;
- // Convert the encoded Total Size to the real
- // Total Size.
- coder->total_size = total_size_decode(
- coder->total_size);
coder->sequence = SEQ_UNCOMPRESSED;
} else {
// Add the decoded Record to the Index.
return_if_error(lzma_index_append(
coder->index, allocator,
- coder->total_size,
+ coder->unpadded_size,
coder->uncompressed_size));
// Check if this was the last Record.
coder->sequence = --coder->count == 0
? SEQ_PADDING_INIT
- : SEQ_TOTAL;
+ : SEQ_UNPADDED;
}
break;