]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
cab: Fix Kraft's inequality check
authorTobias Stoeckmann <tobias@stoeckmann.org>
Mon, 6 Jul 2026 15:38:52 +0000 (17:38 +0200)
committerTobias Stoeckmann <tobias@stoeckmann.org>
Thu, 9 Jul 2026 06:37:34 +0000 (08:37 +0200)
We really have to check if Kraft's inequality is 1 (in our case it's
0x10000) or 0 for an empty tree. Anything else is an error.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
libarchive/archive_read_support_format_cab.c

index 9a37fb2425932ba266849a66868517ef85423d74..ad7e848bea734e77f677683f8fe2bce4d7bc023d 100644 (file)
@@ -3290,7 +3290,7 @@ lzx_make_huffman_table(struct huffman *hf)
                }
        }
        /* Verify Kraft's inequality. */
-       if ((ptn & 0xffff) != 0 || maxbits > hf->tbl_bits)
+       if ((ptn != 0 && ptn != 0x10000) || maxbits > hf->tbl_bits)
                return (0);/* Invalid */
 
        hf->max_bits = maxbits;