Skip to content

Commit c4d2876

Browse files
committed
smex: reject undersized fw-ready section
The fw-ready section was cast to a struct and field-read without checking its size, reading past a short section. Reject a section smaller than the struct. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
1 parent ed62cc6 commit c4d2876

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

smex/ldc.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ static int fw_version_copy(const struct elf_module *src,
2626
if (section_size < 0)
2727
return section_size;
2828

29+
if ((size_t)section_size < sizeof(struct sof_ipc_fw_ready)) {
30+
fprintf(stderr, "error: .fw_ready section too small: %d\n",
31+
section_size);
32+
free(buffer);
33+
return -EINVAL;
34+
}
35+
2936
memcpy(&header->version,
3037
&((struct sof_ipc_fw_ready *)buffer)->version,
3138
sizeof(header->version));

0 commit comments

Comments
 (0)