lib:compression: Fix undefined behavior in lzxpress
authorAndreas Schneider <asn@samba.org>
Thu, 22 Nov 2018 14:11:09 +0000 (15:11 +0100)
committerGary Lockyer <gary@samba.org>
Thu, 22 Nov 2018 21:13:27 +0000 (22:13 +0100)
lib/compression/lzxpress.c:228 runtime error: store to misaligned
address 0x5631d53ca9fe for type 'uint32_t', which requires 4 byte
alignment

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
lib/compression/lzxpress.c

index a4ded7e..024aba4 100644 (file)
@@ -225,7 +225,7 @@ ssize_t lzxpress_compress(const uint8_t *uncompressed,
                for (; (indic_bit % 32) != 0; indic_bit++)
                        indic |= 0 << (32 - ((indic_bit % 32) + 1));
 
-               *(uint32_t *)&compressed[compressed_pos] = 0;
+               SIVAL(compressed, compressed_pos, 0);
                SIVAL(indic_pos, 0, indic);
                compressed_pos += sizeof(uint32_t);
        }