srec: Detect overflow to avoid adding ~4GB of 0xFF padding

Fixes https://oss-fuzz.com/testcase-detail/5468114109202432
This commit is contained in:
Richard Hughes 2021-03-14 08:57:21 +00:00
parent 752c8de149
commit 1c0ed3ab1d

View File

@ -379,6 +379,14 @@ fu_srec_firmware_parse (FuFirmware *firmware,
if (img_address == 0x0)
img_address = rcd->addr;
addr32_last = rcd->addr + rcd->buf->len;
if (addr32_last < rcd->addr) {
g_set_error (error,
FWUPD_ERROR,
FWUPD_ERROR_INVALID_FILE,
"overflow from address 0x%x at line %u",
(guint) rcd->addr, rcd->ln);
return FALSE;
}
}
data_cnt++;
}