synaptics-prometheus: Add a sanity check to fix a fuzzing failure

Fixes https://oss-fuzz.com/testcase-detail/6232454836387840
This commit is contained in:
Richard Hughes 2022-04-27 19:38:20 +01:00
parent 3553336eff
commit 2b81290829

View File

@ -104,6 +104,17 @@ fu_synaprom_firmware_parse(FuFirmware *firmware,
tag);
return FALSE;
}
/* sanity check */
img = fu_firmware_get_image_by_idx(firmware, tag, NULL);
if (img != NULL) {
g_set_error(error,
G_IO_ERROR,
G_IO_ERROR_INVALID_DATA,
"tag 0x%04x already present in image",
tag);
return FALSE;
}
hdrsz = GUINT32_FROM_LE(header.bufsz);
if (hdrsz == 0) {
g_set_error(error,