From: Ben Pfaff Date: Fri, 9 Jan 2009 01:06:54 +0000 (-0800) Subject: datapath: Check DMI strings for NULL. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f74d6b943a4795d3a812ed99653196ca0994a8a3;p=openvswitch datapath: Check DMI strings for NULL. dmi_get_system_info() can return NULL, so check for it. Found by Chris Eagle via Fortify. --- diff --git a/datapath/datapath.c b/datapath/datapath.c index 7f69d478..f7e3ad85 100644 --- a/datapath/datapath.c +++ b/datapath/datapath.c @@ -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)