]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
compression: Use explicit data sizes
authorJoseph Sutton <josephsutton@catalyst.net.nz>
Mon, 7 Mar 2022 06:30:43 +0000 (19:30 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 12 May 2022 02:22:35 +0000 (02:22 +0000)
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
lib/compression/lzxpress.c

index a428d0397c80137a8bb1aa0de07d6ae17a0e2605..d75f031c7645a6f9bab253e19314be0dbb3601be 100644 (file)
@@ -288,7 +288,7 @@ ssize_t lzxpress_decompress(const uint8_t *input,
 
        do {
                if (indicator_bit == 0) {
-                       CHECK_INPUT_BYTES(4);
+                       CHECK_INPUT_BYTES(sizeof(uint32_t));
                        indicator = PULL_LE_UINT32(input, input_index);
                        input_index += sizeof(uint32_t);
                        indicator_bit = 32;
@@ -301,13 +301,13 @@ ssize_t lzxpress_decompress(const uint8_t *input,
                 * check whether the 4th bit of the value in indicator is set
                 */
                if (((indicator >> indicator_bit) & 1) == 0) {
-                       CHECK_INPUT_BYTES(1);
-                       CHECK_OUTPUT_BYTES(1);
+                       CHECK_INPUT_BYTES(sizeof(uint8_t));
+                       CHECK_OUTPUT_BYTES(sizeof(uint8_t));
                        output[output_index] = input[input_index];
                        input_index += sizeof(uint8_t);
                        output_index += sizeof(uint8_t);
                } else {
-                       CHECK_INPUT_BYTES(2);
+                       CHECK_INPUT_BYTES(sizeof(uint16_t));
                        length = PULL_LE_UINT16(input, input_index);
                        input_index += sizeof(uint16_t);
                        offset = (length / 8) + 1;
@@ -315,7 +315,7 @@ ssize_t lzxpress_decompress(const uint8_t *input,
 
                        if (length == 7) {
                                if (nibble_index == 0) {
-                                       CHECK_INPUT_BYTES(1);
+                                       CHECK_INPUT_BYTES(sizeof(uint8_t));
                                        nibble_index = input_index;
                                        length = input[input_index] % 16;
                                        input_index += sizeof(uint8_t);
@@ -325,15 +325,15 @@ ssize_t lzxpress_decompress(const uint8_t *input,
                                }
 
                                if (length == 15) {
-                                       CHECK_INPUT_BYTES(1);
+                                       CHECK_INPUT_BYTES(sizeof(uint8_t));
                                        length = input[input_index];
                                        input_index += sizeof(uint8_t);
                                        if (length == 255) {
-                                               CHECK_INPUT_BYTES(2);
+                                               CHECK_INPUT_BYTES(sizeof(uint16_t));
                                                length = PULL_LE_UINT16(input, input_index);
                                                input_index += sizeof(uint16_t);
                                                if (length == 0) {
-                                                       CHECK_INPUT_BYTES(4);
+                                                       CHECK_INPUT_BYTES(sizeof(uint32_t));
                                                        length = PULL_LE_UINT32(input, input_index);
                                                        input_index += sizeof(uint32_t);
                                                }
@@ -357,7 +357,7 @@ ssize_t lzxpress_decompress(const uint8_t *input,
                                if (offset > output_index) {
                                        return -1;
                                }
-                               CHECK_OUTPUT_BYTES(1);
+                               CHECK_OUTPUT_BYTES(sizeof(uint8_t));
                                output[output_index] = output[output_index - offset];
                                output_index += sizeof(uint8_t);
                        }