Skip to content

Commit 076c316

Browse files
committed
rimage: bound extended manifest header read to the section
The extended-manifest validator copied a fixed header from an offset that could leave fewer than a header's worth of bytes, reading past the section. Require a whole header to remain before the copy. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
1 parent 6d469e0 commit 076c316

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

tools/rimage/src/ext_manifest.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ static int ext_man_validate(uint32_t section_size, const void *section_data)
6969

7070
/* copy each head to local struct to omit memory align issues */
7171
while (offset < section_size) {
72+
/* make sure a whole header remains before copying it out */
73+
if (offset + sizeof(head) > section_size) {
74+
fprintf(stderr,
75+
"error: extended manifest header straddles section end\n");
76+
return -EINVAL;
77+
}
7278
memcpy(&head, &sbuf[offset], sizeof(head));
7379
fprintf(stdout, "Extended manifest found module, type: 0x%04X size: 0x%04X (%4d) offset: 0x%04X\n",
7480
head.type, head.elem_size, head.elem_size, offset);

0 commit comments

Comments
 (0)