Skip to contentSkip to conversation

ieee1275: Null pointer dereference in grub_ieee1275_encode_devname

PATCH In review Eric Snowberg 3 participants 3 messages Apr 2, 2019 – Apr 4, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ieee1275: Null pointer dereference in grub_ieee1275_encode_devname

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.

---
 grub-core/kern/ieee1275/openfw.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
grub-core/kern/ieee1275/openfw.c +3 -0
index 62929d9..4d493ab 100644
@@ -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)
Signature · 1 line
1.7.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Eric Snowberg

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.

Makes sense to me, and the handling matches how the immediately-following possible grub_malloc failure is handled.

Signature · 1 line
Colin Watson                                       [[email protected]]
#2 lore raw
Quoted 10 lines · Colin Watson
Quoted 4 lines · Eric Snowberg

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.

Makes sense to me, and the handling matches how the immediately-following possible grub_malloc failure is handled.

Pushed! Thanks!

Daniel