From 69016bda04d31531fe8cf9fd8555cd2bf1a1084b Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Sun, 21 Mar 2021 18:35:30 +0000 Subject: [PATCH] ihex: Do not allow data sections after EOF --- libfwupdplugin/fu-ihex-firmware.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/libfwupdplugin/fu-ihex-firmware.c b/libfwupdplugin/fu-ihex-firmware.c index 72200a16d..6f939e380 100644 --- a/libfwupdplugin/fu-ihex-firmware.c +++ b/libfwupdplugin/fu-ihex-firmware.c @@ -228,6 +228,16 @@ fu_ihex_firmware_parse (FuFirmware *firmware, /* process different record types */ switch (rcd->record_type) { case FU_IHEX_FIRMWARE_RECORD_TYPE_DATA: + + /* does not make sense */ + if (got_eof) { + g_set_error_literal (error, + FWUPD_ERROR, + FWUPD_ERROR_INVALID_FILE, + "cannot process data after EOF"); + return FALSE; + } + /* base address for element */ if (img_addr == G_MAXUINT32) img_addr = addr;