datapath: Check DMI strings for NULL.
authorBen Pfaff <blp@nicira.com>
Fri, 9 Jan 2009 01:06:54 +0000 (17:06 -0800)
committerBen Pfaff <blp@nicira.com>
Tue, 13 Jan 2009 01:00:28 +0000 (17:00 -0800)
dmi_get_system_info() can return NULL, so check for it.

Found by Chris Eagle via Fortify.

datapath/datapath.c

index 7f69d478103ccf5cdc7bb94d1d04e41ffaf81cda..f7e3ad8539cc869ce608ae6e253d32277f182e5a 100644 (file)
@@ -1946,12 +1946,14 @@ static void set_desc(void)
        if (strncmp(uptr, NICIRA_OUI_STR, strlen(NICIRA_OUI_STR)))
                return;
 
-       strlcpy(mfr_desc, dmi_get_system_info(DMI_SYS_VENDOR), sizeof(mfr_desc));
-       snprintf(hw_desc, sizeof(hw_desc), "%s %s", 
-                       dmi_get_system_info(DMI_PRODUCT_NAME), 
-                       dmi_get_system_info(DMI_PRODUCT_VERSION));
-       strlcpy(serial_num, dmi_get_system_info(DMI_PRODUCT_SERIAL), 
-                       sizeof(serial_num));
+       if (vendor)
+               strlcpy(mfr_desc, vendor, sizeof(mfr_desc));
+       if (name || version)
+               snprintf(hw_desc, sizeof(hw_desc), "%s %s",
+                        name ? name : "",
+                        version ? version : "");
+       if (serial)
+               strlcpy(serial_num, serial, sizeof(serial_num));
 }
 
 static int __init dp_init(void)