mirror of
https://git.proxmox.com/git/fwupd
synced 2025-08-14 17:28:20 +00:00
ihex: Never add more than 1 Intel hex signature
If you can create a 1Mb file with hundreds of thousands of zero-byte signatures it takes a *long* time to parse the image.
This commit is contained in:
parent
ffbb1175d0
commit
665c5feaca
@ -196,6 +196,7 @@ fu_ihex_firmware_parse (FuFirmware *firmware,
|
|||||||
{
|
{
|
||||||
FuIhexFirmware *self = FU_IHEX_FIRMWARE (firmware);
|
FuIhexFirmware *self = FU_IHEX_FIRMWARE (firmware);
|
||||||
gboolean got_eof = FALSE;
|
gboolean got_eof = FALSE;
|
||||||
|
gboolean got_sig = FALSE;
|
||||||
guint32 abs_addr = 0x0;
|
guint32 abs_addr = 0x0;
|
||||||
guint32 addr_last = 0x0;
|
guint32 addr_last = 0x0;
|
||||||
guint32 img_addr = G_MAXUINT32;
|
guint32 img_addr = G_MAXUINT32;
|
||||||
@ -309,12 +310,21 @@ fu_ihex_firmware_parse (FuFirmware *firmware,
|
|||||||
g_debug (" seg_addr:\t0x%02x on line %u", seg_addr, rcd->ln);
|
g_debug (" seg_addr:\t0x%02x on line %u", seg_addr, rcd->ln);
|
||||||
break;
|
break;
|
||||||
case FU_IHEX_FIRMWARE_RECORD_TYPE_SIGNATURE:
|
case FU_IHEX_FIRMWARE_RECORD_TYPE_SIGNATURE:
|
||||||
|
if (got_sig) {
|
||||||
|
g_set_error_literal (error,
|
||||||
|
FWUPD_ERROR,
|
||||||
|
FWUPD_ERROR_INVALID_FILE,
|
||||||
|
"duplicate signature, perhaps "
|
||||||
|
"corrupt file");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
if (rcd->data->len > 0) {
|
if (rcd->data->len > 0) {
|
||||||
g_autoptr(GBytes) data_sig = g_bytes_new (rcd->data->data, rcd->data->len);
|
g_autoptr(GBytes) data_sig = g_bytes_new (rcd->data->data, rcd->data->len);
|
||||||
g_autoptr(FuFirmwareImage) img_sig = fu_firmware_image_new (data_sig);
|
g_autoptr(FuFirmwareImage) img_sig = fu_firmware_image_new (data_sig);
|
||||||
fu_firmware_image_set_id (img_sig, FU_FIRMWARE_IMAGE_ID_SIGNATURE);
|
fu_firmware_image_set_id (img_sig, FU_FIRMWARE_IMAGE_ID_SIGNATURE);
|
||||||
fu_firmware_add_image (firmware, img_sig);
|
fu_firmware_add_image (firmware, img_sig);
|
||||||
}
|
}
|
||||||
|
got_sig = TRUE;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
/* vendors sneak in nonstandard sections past the EOF */
|
/* vendors sneak in nonstandard sections past the EOF */
|
||||||
|
Loading…
Reference in New Issue
Block a user