diff options
author | Richard Hughes <richard@hughsie.com> | 2022-09-09 12:54:28 +0100 |
---|---|---|
committer | Richard Hughes <richard@hughsie.com> | 2022-09-09 13:16:21 +0100 |
commit | d6f16fb540194ece1945e6beed6eafc4dac15336 (patch) | |
tree | 221eaacecedf7b8f22a954f23b8471eeeea7a805 | |
parent | 1e8528ad5b66b4a70bd76681dc1319614f4342f8 (diff) | |
download | gusb-d6f16fb540194ece1945e6beed6eafc4dac15336.tar.gz |
trivial: Be more careful with buffers in case the usb.ids file format changes
-rw-r--r-- | gusb/gusb-context.c | 5 |
1 files changed, 4 insertions, 1 deletions
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, |