Skip to content

Commit

Permalink
blah
Browse files Browse the repository at this point in the history
  • Loading branch information
ragusaa committed Jun 12, 2024
1 parent db0912b commit 73e6db4
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions libclamav/ole2_extract.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
Expand All @@ -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;
}

Expand Down

0 comments on commit 73e6db4

Please sign in to comment.