lzxpress: avoid technically undefined shift
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Thu, 6 Aug 2020 05:17:01 +0000 (17:17 +1200)
committerJeremy Allison <jra@samba.org>
Mon, 31 Aug 2020 22:31:13 +0000 (22:31 +0000)
UBSAN:

  runtime error: left shift of 1 by 31 places cannot be represented in type 'int'

Credit to OSS-fuzz.

REF: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=22283

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Mon Aug 31 22:31:13 UTC 2020 on sn-devel-184

lib/compression/lzxpress.c

index d8326304455cbd1d05151c9b83930b5de343a09c..3453dd36f2aa91d918336adc369f94a7f41a6314 100644 (file)
@@ -180,7 +180,7 @@ ssize_t lzxpress_compress(const uint8_t *uncompressed,
                                }
                        }
 
-                       indic |= 1 << (32 - ((indic_bit % 32) + 1));
+                       indic |= 1U << (32 - ((indic_bit % 32) + 1));
 
                        if (best_len > 9) {
                                if (nibble_index == 0) {