diff --git a/libclamav/ole2_extract.c b/libclamav/ole2_extract.c index e47781b614..b79e2a0747 100644 --- a/libclamav/ole2_extract.c +++ b/libclamav/ole2_extract.c @@ -782,16 +782,16 @@ static void test_for_encryption(const property_t *word_block, ole2_header_t *hdr } } -static bool read_uint16(const uint8_t *const ptr, uint32_t ptr_size, uint32_t *idx, uint16_t *dst) +static size_t read_uint16(const uint8_t *const ptr, uint32_t ptr_size, uint32_t *idx, uint16_t *dst) { if (*idx + sizeof(uint16_t) >= ptr_size) { - return false; + return 0; } memcpy(dst, &(ptr[*idx]), 2); *dst = ole2_endian_convert_16(*dst); *idx += sizeof(uint16_t); - return true; + return sizeof(uint16_t); } /* Search for the FILE_PASS number. If I don't find it, the next two bytes are @@ -806,11 +806,11 @@ static bool find_file_pass(const uint8_t *const ptr, uint32_t ptr_size, uint32_t const uint32_t FILE_PASS_NUM = 47; while (true) { - if (!read_uint16(ptr, ptr_size, idx, &val)) { + if (sizeof(uint16_t) != read_uint16(ptr, ptr_size, idx, &val)) { return false; } - if (!read_uint16(ptr, ptr_size, idx, &size)) { + if (sizeof(uint16_t) != read_uint16(ptr, ptr_size, idx, &size)) { return false; } @@ -845,7 +845,7 @@ static void test_for_xls_encryption(const property_t *word_block, ole2_header_t /*Validate keyword*/ idx = 0; - if (!read_uint16(ptr, block_size, &idx, &tmp16)) { + if (sizeof(uint16_t) != read_uint16(ptr, block_size, &idx, &tmp16)) { return; } @@ -856,7 +856,7 @@ static void test_for_xls_encryption(const property_t *word_block, ole2_header_t /*Skip past this size.*/ memcpy(&tmp16, &(ptr[idx]), 2); - if (!read_uint16(ptr, block_size, &idx, &tmp16)) { + if (sizeof(uint16_t) != read_uint16(ptr, block_size, &idx, &tmp16)) { return; } idx += tmp16; @@ -865,7 +865,7 @@ static void test_for_xls_encryption(const property_t *word_block, ole2_header_t return; } - if (!read_uint16(ptr, block_size, &idx, &tmp16)) { + if (sizeof(uint16_t) != read_uint16(ptr, block_size, &idx, &tmp16)) { return; }