diff options
author | Victor Toso <victortoso@redhat.com> | 2021-11-15 12:35:12 +0100 |
---|---|---|
committer | Victor Toso <victortoso@redhat.com> | 2022-01-11 12:03:12 +0100 |
commit | dffc41c30d2535d02b670de96a438755ed130876 (patch) | |
tree | dbbb2b7f55b7ed9a56bcfecd3ba61dc408dd4e94 | |
parent | 9426fdb1a5d362b51c2c946681e94dba7e3bf3d9 (diff) |
usbredirect: fix leak on bad input
Found by covscan:
Error: RESOURCE_LEAK (CWE-772): [#def1] [important]
usbredir-0.12.0/tools/usbredirect.c:55: alloc_fn: Storage is returned from allocation function "g_strsplit".
usbredir-0.12.0/tools/usbredirect.c:55: var_assign: Assigning: "usbid" = storage returned from "g_strsplit(device, "-", 2)".
usbredir-0.12.0/tools/usbredirect.c:76: leaked_storage: Variable "usbid" going out of scope leaks the storage it points to.
# 74| if (i == n) {
# 75| libusb_free_device_list(list, true);
# 76|-> return false;
# 77| }
# 78|
and
Error: RESOURCE_LEAK (CWE-772): [#def2] [important]
usbredir-0.12.0/tools/usbredirect.c:55: alloc_fn: Storage is returned from allocation function "g_strsplit".
usbredir-0.12.0/tools/usbredirect.c:55: var_assign: Assigning: "usbid" = storage returned from "g_strsplit(device, "-", 2)".
usbredir-0.12.0/tools/usbredirect.c:85: leaked_storage: Variable "usbid" going out of scope leaks the storage it points to.
# 83|
# 84| libusb_free_device_list(list, true);
# 85|-> return true;
# 86| }
# 87|
Signed-off-by: Victor Toso <victortoso@redhat.com>
-rw-r--r-- | tools/usbredirect.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/tools/usbredirect.c b/tools/usbredirect.c index 98e5a8c..5e2376c 100644 --- a/tools/usbredirect.c +++ b/tools/usbredirect.c @@ -59,6 +59,7 @@ parse_opt_device(const char *device, int *vendor, int *product) } gint64 bus = g_ascii_strtoll(usbid[0], NULL, 10); gint64 addr = g_ascii_strtoll(usbid[1], NULL, 10); + g_strfreev(usbid); libusb_device **list = NULL; ssize_t i, n; |