]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
compression: Fix writing output flags
authorJoseph Sutton <josephsutton@catalyst.net.nz>
Mon, 7 Mar 2022 23:02:13 +0000 (12:02 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 12 May 2022 02:22:35 +0000 (02:22 +0000)
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 <josephsutton@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
lib/compression/lzxpress.c
selftest/knownfail.d/lzxpress [deleted file]

index 5e52fa8b669c820de3b7082b8537d70adafddc41..7ee2e9e5d5646a8701fbb771b3113f2f3f11be6b 100644 (file)
@@ -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 (file)
index 922401e..0000000
+++ /dev/null
@@ -1 +0,0 @@
-samba4.local.compression.lzxpress6