]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
ieee1275: NULL pointer dereference in grub_ieee1275_encode_devname()
authorEric Snowberg <eric.snowberg@oracle.com>
Tue, 2 Apr 2019 16:40:31 +0000 (09:40 -0700)
committerDaniel Kiper <daniel.kiper@oracle.com>
Thu, 4 Apr 2019 16:34:05 +0000 (18:34 +0200)
Function grub_strndup() may return NULL, this is called from
function grub_ieee1275_get_devname() which is then called from
function grub_ieee1275_encode_devname() to set device. The device
variable could then be used with a NULL pointer.

Signed-off-by: Eric Snowberg <eric.snowberg@oracle.com>
Reviewed-by: Colin Watson <cjwatson@ubuntu.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
grub-core/kern/ieee1275/openfw.c

index 62929d983bfaa2c83158ee4fe6797125c6d6b844..4d493ab766194501a044d84fcfc45ce0189270df 100644 (file)
@@ -479,6 +479,9 @@ grub_ieee1275_encode_devname (const char *path)
   char *optr;
   const char *iptr;
 
+  if (! device)
+    return 0;
+
   encoding = grub_malloc (sizeof ("ieee1275/") + 2 * grub_strlen (device)
                          + sizeof (",XXXXXXXXXXXX"));
   if (!encoding)