Skip to content

Commit 01a0eed

Browse files
committed
rimage: avoid reading past the buffer scanning for the marker
The marker scan read a 32-bit word at each offset up to the last byte, reading a few bytes past the buffer at the tail. Stop once fewer than a word remains, in both scan sites. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
1 parent 9ba74f6 commit 01a0eed

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

tools/rimage/src/manifest.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1678,7 +1678,7 @@ int verify_image(struct image *image)
16781678
ret = file_error("unable to read whole file", image->verify_file);
16791679
goto out;
16801680
}
1681-
for (i = 0; i < size; i += sizeof(uint32_t)) {
1681+
for (i = 0; i + sizeof(uint32_t) <= size; i += sizeof(uint32_t)) {
16821682
/* find CSE header marker "$CPD" */
16831683
if (*(uint32_t *)(buffer + i) == CSE_HEADER_MAKER) {
16841684
image->fw_image = buffer + i;
@@ -1749,7 +1749,7 @@ int resign_image(struct image *image)
17491749

17501750
fclose(in_file);
17511751

1752-
for (i = 0; i < size; i += sizeof(uint32_t)) {
1752+
for (i = 0; i + sizeof(uint32_t) <= size; i += sizeof(uint32_t)) {
17531753
/* find CSE header marker "$CPD" */
17541754
if (*(uint32_t *)(buffer + i) == CSE_HEADER_MAKER) {
17551755
image->fw_image = buffer + i;

0 commit comments

Comments
 (0)