Blame SOURCES/0018-spice_usbutil_parse_usbids-verify-at-least-one-vendo.patch

7492b2
From 032ca202f839fe1c49cddfd2b0459f9fecc23c86 Mon Sep 17 00:00:00 2001
7492b2
From: Uri Lublin <uril@redhat.com>
7492b2
Date: Wed, 11 Nov 2020 20:03:57 +0200
7492b2
Subject: [PATCH 18/22] spice_usbutil_parse_usbids: verify at least one vendor
7492b2
 and product
7492b2
7492b2
Fixes the following clang warning:
7492b2
  src/usbutil.c:148:52: warning: Use of zero-allocated memory
7492b2
  ...
7492b2
7492b2
   product_info[product_count].product_id = id;
7492b2
                                          ^
7492b2
   146|               while (isspace(line[0]))
7492b2
   147|                   line++;
7492b2
   148|->             product_info[product_count].product_id = id;
7492b2
   149|               snprintf(product_info[product_count].name,
7492b2
   150|                        PRODUCT_NAME_LEN, "%s", line);
7492b2
7492b2
Signed-off-by: Uri Lublin <uril@redhat.com>
7492b2
---
7492b2
 src/usbutil.c | 7 +++++++
7492b2
 1 file changed, 7 insertions(+)
7492b2
7492b2
diff --git a/src/usbutil.c b/src/usbutil.c
7492b2
index 7d7f38a..f29302b 100644
7492b2
--- a/src/usbutil.c
7492b2
+++ b/src/usbutil.c
7492b2
@@ -113,6 +113,13 @@ static gboolean spice_usbutil_parse_usbids(gchar *path)
7492b2
         usbids_vendor_count++;
7492b2
     }
7492b2
 
7492b2
+    if (usbids_vendor_info == 0 || product_count == 0) {
7492b2
+        usbids_vendor_count = -1;
7492b2
+        g_strfreev(lines);
7492b2
+        g_free(contents);
7492b2
+        return FALSE;
7492b2
+    }
7492b2
+
7492b2
     usbids_vendor_info = g_new(usb_vendor_info, usbids_vendor_count);
7492b2
     product_info = g_new(usb_product_info, product_count);
7492b2
 
7492b2
-- 
7492b2
2.28.0
7492b2