summaryrefslogtreecommitdiff
path: root/lib/compression
diff options
context:
space:
mode:
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>2022-12-07 09:17:17 +1300
committerJeremy Allison <jra@samba.org>2022-12-19 22:32:35 +0000
commit628f14c149772dc4277c004018b8f02420fa3997 (patch)
tree48a803c276c275fb22190bb25a3a7a3185eb9156 /lib/compression
parent6b4d94c9877ec59081b9da946c00fa2647cad928 (diff)
downloadsamba-628f14c149772dc4277c004018b8f02420fa3997.tar.gz
compression/huffman: double check distance in matches (CID 1517278)
Because we just wrote the intermediate representation to have no zero distances, we can be sure it doesn't, but Coverity doesn't know. If distance is zero, `bitlen_nonzero_16(distance)` would be bad. CID 1517278 (#1 of 1): Bad bit shift operation (BAD_SHIFT)41. large_shift: In expression 1 << code_dist, left shifting by more than 31 bits has undefined behavior. The shift amount, code_dist, is 65535. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'lib/compression')
-rw-r--r--lib/compression/lzxpress_huffman.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/compression/lzxpress_huffman.c b/lib/compression/lzxpress_huffman.c
index 4b55c7b7e88..e6ff4ed3b02 100644
--- a/lib/compression/lzxpress_huffman.c
+++ b/lib/compression/lzxpress_huffman.c
@@ -1062,6 +1062,9 @@ static ssize_t write_compressed_bytes(uint16_t symbol_values[512],
} else {
return LZXPRESS_ERROR;
}
+ if (unlikely(distance == 0)) {
+ return LZXPRESS_ERROR;
+ }
/* len has already had 3 subtracted */
if (len >= 15) {
/*