summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJia Tan <jiat0218@gmail.com>2022-09-21 19:28:53 +0800
committerLasse Collin <lasse.collin@tukaani.org>2022-09-29 16:54:39 +0300
commit4ed5fd54c676b735e3f58158f214af68755d59b5 (patch)
tree68520ff4cbf8648a6249dec7962a9b846b781a71
parentc4476f695291a2d7376d5fa406d32e354f858858 (diff)
downloadxz-4ed5fd54c676b735e3f58158f214af68755d59b5.tar.gz
liblzma: Fix copying of check type statistics in lzma_index_cat().
The check type of the last Stream in dest was never copied to dest->checks (the code tried to copy it but it was done too late). This meant that the value returned by lzma_index_checks() would only include the check type of the last Stream when multiple lzma_indexes had been concatenated. In xz --list this meant that the summary would only list the check type of the last Stream, so in this sense this was only a visual bug. However, it's possible that some applications use this information for purposes other than merely showing it to the users in an informational message. I'm not aware of such applications though and it's quite possible that such applications don't exist. Regular streamed decompression in xz or any other application doesn't use lzma_index_cat() and so this bug cannot affect them.
-rw-r--r--src/liblzma/common/index.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/liblzma/common/index.c b/src/liblzma/common/index.c
index 010e1f8..e0b14a3 100644
--- a/src/liblzma/common/index.c
+++ b/src/liblzma/common/index.c
@@ -839,6 +839,11 @@ lzma_index_cat(lzma_index *restrict dest, lzma_index *restrict src,
}
}
+ // dest->checks includes the check types of all except the last Stream
+ // in dest. Set the bit for the check type of the last Stream now so
+ // that it won't get lost when Stream(s) from src are appended to dest.
+ dest->checks = lzma_index_checks(dest);
+
// Add all the Streams from src to dest. Update the base offsets
// of each Stream from src.
const index_cat_info info = {
@@ -855,7 +860,7 @@ lzma_index_cat(lzma_index *restrict dest, lzma_index *restrict src,
dest->total_size += src->total_size;
dest->record_count += src->record_count;
dest->index_list_size += src->index_list_size;
- dest->checks = lzma_index_checks(dest) | src->checks;
+ dest->checks |= src->checks;
// There's nothing else left in src than the base structure.
lzma_free(src, allocator);