From: Joseph Sutton Date: Mon, 7 Mar 2022 23:02:13 +0000 (+1300) Subject: compression: Fix writing output flags X-Git-Tag: talloc-2.3.4~165 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=430bcd7a083a2dfbd12361f1ad352bc33e7963cb;p=thirdparty%2Fsamba.git compression: Fix writing output flags If indic_bit == 0, the shift amount of 32 - indic_bit == 32 will equal the width of a 32-bit integer type, and these shifts will invoke undefined behaviour, which is likely to cause incorrect output. Fix this by not shifting a 32-bit integer type by 32 bits or more. Signed-off-by: Joseph Sutton Reviewed-by: Douglas Bagnall --- diff --git a/lib/compression/lzxpress.c b/lib/compression/lzxpress.c index 5e52fa8b669..7ee2e9e5d56 100644 --- a/lib/compression/lzxpress.c +++ b/lib/compression/lzxpress.c @@ -202,8 +202,10 @@ ssize_t lzxpress_compress(const uint8_t *uncompressed, } } - indic <<= 32 - indic_bit; - indic |= (1 << (32 - indic_bit)) - 1; + if (indic_bit != 0) { + indic <<= 32 - indic_bit; + } + indic |= UINT32_MAX >> indic_bit; PUSH_LE_U32(compressed, indic_pos, indic); return compressed_pos; diff --git a/selftest/knownfail.d/lzxpress b/selftest/knownfail.d/lzxpress deleted file mode 100644 index 922401eaa03..00000000000 --- a/selftest/knownfail.d/lzxpress +++ /dev/null @@ -1 +0,0 @@ -samba4.local.compression.lzxpress6