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 <eric.snowberg@oracle.com>
Reviewed-by: Colin Watson <cjwatson@ubuntu.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
This commit is contained in:
Eric Snowberg 2019-04-02 09:40:31 -07:00 committed by Daniel Kiper
parent fa20550f16
commit 0f1b648b45

View 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)