ieee1275: Null pointer dereference in grub_ieee1275_encode_devname
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
@@ -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
Quoted 4 lines · Eric Snowberg
Function
grub_strndupmay return NULL, this is called from functiongrub_ieee1275_get_devnamewhich is then called from functiongrub_ieee1275_encode_devnameto 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]]
Quoted 10 lines · Colin Watson
Quoted 4 lines · Eric Snowberg
Function
grub_strndupmay return NULL, this is called from functiongrub_ieee1275_get_devnamewhich is then called from functiongrub_ieee1275_encode_devnameto 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_mallocfailure is handled.Reviewed-by Colin Watson <[email protected]>
Pushed! Thanks!
Daniel