|
|
9874f4 |
From 6077051e173770cf357703a3d776ceac2c53d963 Mon Sep 17 00:00:00 2001
|
|
|
9874f4 |
From: Richard Hughes <richard@hughsie.com>
|
|
|
9874f4 |
Date: Mon, 8 Feb 2021 18:10:38 +0000
|
|
|
9874f4 |
Subject: [PATCH 10/11] ihex: Fix a buffer-overread spotted by AddressSanitizer
|
|
|
9874f4 |
|
|
|
9874f4 |
---
|
|
|
9874f4 |
libfwupdplugin/fu-ihex-firmware.c | 8 +++-----
|
|
|
9874f4 |
1 file changed, 3 insertions(+), 5 deletions(-)
|
|
|
9874f4 |
|
|
|
9874f4 |
diff --git libfwupdplugin/fu-ihex-firmware.c libfwupdplugin/fu-ihex-firmware.c
|
|
|
9874f4 |
index 8d4fc6a6..5df8a948 100644
|
|
|
9874f4 |
--- libfwupdplugin/fu-ihex-firmware.c
|
|
|
9874f4 |
+++ libfwupdplugin/fu-ihex-firmware.c
|
|
|
9874f4 |
@@ -90,11 +90,6 @@ fu_ihex_firmware_record_new (guint ln, const gchar *line,
|
|
|
9874f4 |
rcd->ln = ln;
|
|
|
9874f4 |
rcd->data = g_byte_array_new ();
|
|
|
9874f4 |
rcd->buf = g_string_new (line);
|
|
|
9874f4 |
- rcd->byte_cnt = fu_firmware_strparse_uint8 (line + 1);
|
|
|
9874f4 |
- rcd->addr = fu_firmware_strparse_uint16 (line + 3);
|
|
|
9874f4 |
- rcd->record_type = fu_firmware_strparse_uint8 (line + 7);
|
|
|
9874f4 |
-
|
|
|
9874f4 |
- /* check there's enough data for the smallest possible record */
|
|
|
9874f4 |
if (rcd->buf->len < 11) {
|
|
|
9874f4 |
g_set_error (error,
|
|
|
9874f4 |
FWUPD_ERROR,
|
|
|
9874f4 |
@@ -103,6 +98,9 @@ fu_ihex_firmware_record_new (guint ln, const gchar *line,
|
|
|
9874f4 |
(guint) rcd->buf->len);
|
|
|
9874f4 |
return NULL;
|
|
|
9874f4 |
}
|
|
|
9874f4 |
+ rcd->byte_cnt = fu_firmware_strparse_uint8 (line + 1);
|
|
|
9874f4 |
+ rcd->addr = fu_firmware_strparse_uint16 (line + 3);
|
|
|
9874f4 |
+ rcd->record_type = fu_firmware_strparse_uint8 (line + 7);
|
|
|
9874f4 |
|
|
|
9874f4 |
/* position of checksum */
|
|
|
9874f4 |
line_end = 9 + rcd->byte_cnt * 2;
|
|
|
9874f4 |
--
|
|
|
9874f4 |
2.29.2
|
|
|
9874f4 |
|