From d6f16fb540194ece1945e6beed6eafc4dac15336 Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Fri, 9 Sep 2022 12:54:28 +0100 Subject: trivial: Be more careful with buffers in case the usb.ids file format changes --- gusb/gusb-context.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gusb/gusb-context.c b/gusb/gusb-context.c index 14816a1..19d534f 100644 --- a/gusb/gusb-context.c +++ b/gusb/gusb-context.c @@ -1028,8 +1028,9 @@ g_usb_context_load_usb_ids(GUsbContext *self, GError **error) break; if (lines[i][0] != '\t') { + if (strlen(lines[i]) < 7) + continue; lines[i][4] = '\0'; - vid = g_ascii_strtoull(lines[i], NULL, 16); if (vid == 0) break; @@ -1041,6 +1042,8 @@ g_usb_context_load_usb_ids(GUsbContext *self, GError **error) if (vid == 0x0000) break; + if (strlen(lines[i]) < 8) + continue; lines[i][5] = '\0'; pid = g_ascii_strtoull(lines[i] + 1, NULL, 16); g_hash_table_insert(priv->dict_usb_ids, -- cgit v1.2.1