Pointer arithmetic on a null pointer yields undefined behavior, even
though it doesn't really matter in the real world (normally).
Found by Chris Eagle via Fortify.
static void set_desc(void)
{
const char *uuid = dmi_get_system_info(DMI_PRODUCT_UUID);
- const char *uptr = uuid + 24;
+ const char *vendor = dmi_get_system_info(DMI_SYS_VENDOR);
+ const char *name = dmi_get_system_info(DMI_PRODUCT_NAME);
+ const char *version = dmi_get_system_info(DMI_PRODUCT_VERSION);
+ const char *serial = dmi_get_system_info(DMI_PRODUCT_SERIAL);
+ const char *uptr;
if (!uuid || *uuid == '\0' || strlen(uuid) != 36)
return;
return;
/* Only set if the UUID is from Nicira. */
+ uptr = uuid + 24;
if (strncmp(uptr, NICIRA_OUI_STR, strlen(NICIRA_OUI_STR)))
return;
set_uuid_mac(struct net_device *netdev)
{
const char *uuid = dmi_get_system_info(DMI_PRODUCT_UUID);
- const char *uptr = uuid + 24;
+ const char *uptr;
uint8_t mac[ETH_ALEN];
int i;
/* Pull out the embedded MAC address. The kernel's sscanf doesn't
* support field widths on hex digits, so we use this hack. */
+ uptr = uuid + 24;
for (i=0; i<ETH_ALEN; i++) {
unsigned char d[3];