]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
cab reader: Fix use of uninitialized values from Huffman table 2979/head
authorTyler Yankee <tyler.yankee@kitware.com>
Thu, 23 Apr 2026 12:02:52 +0000 (08:02 -0400)
committerTyler Yankee <tyler.yankee@kitware.com>
Thu, 23 Apr 2026 12:02:52 +0000 (08:02 -0400)
Initialize the Huffman table to invalid values, which doesn't otherwise
affect the computation but avoids use of uninitialized values upon
extraction of some archives (as reported by `valgrind`).

libarchive/archive_read_support_format_cab.c

index bf8ac6b1ca7700c678e88c9a37211ed44943b919..3b14646296a8c211103235a688d9d6378ab116e3 100644 (file)
@@ -3211,6 +3211,10 @@ lzx_make_huffman_table(struct huffman *hf)
        bitlen = hf->bitlen;
        len_avail = hf->len_size;
        hf->tree_used = 0;
+       /* Initialize table to invalid values */
+       for (i = 0; i < tbl_size; i++) {
+               tbl[i] = (uint16_t)hf->len_size;
+       }
        for (i = 0; i < len_avail; i++) {
                uint16_t *p;
                int len, cnt;