From 0f1b648b4531cb5ae94fbeaba3fe37e496fbcad4 Mon Sep 17 00:00:00 2001 From: Eric Snowberg Date: Tue, 2 Apr 2019 09:40:31 -0700 Subject: [PATCH] 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. Signed-off-by: Eric Snowberg Reviewed-by: Colin Watson Reviewed-by: Daniel Kiper --- grub-core/kern/ieee1275/openfw.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/grub-core/kern/ieee1275/openfw.c b/grub-core/kern/ieee1275/openfw.c index 62929d983..4d493ab76 100644 --- a/grub-core/kern/ieee1275/openfw.c +++ b/grub-core/kern/ieee1275/openfw.c @@ -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)