From: Alec Brown Date: Wed, 22 Jan 2025 18:04:44 +0000 (+0000) Subject: net: Check if returned pointer for allocated memory is NULL X-Git-Tag: archive/raspbian/2.12-8+rpi1^2~15 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=93cc584dce5fba9c488ba1008d27168cc73559e5;p=grub2.git net: Check if returned pointer for allocated memory is NULL When using grub_malloc(), the function can fail if we are out of memory. After allocating memory we should check if this function returned NULL and handle this error if it did. Signed-off-by: Alec Brown Reviewed-by: Daniel Kiper Gbp-Pq: Topic cve-2025-jan Gbp-Pq: Name net-Check-if-returned-pointer-for-allocated-memory-is-NUL.patch --- diff --git a/grub-core/net/net.c b/grub-core/net/net.c index fb41d27..7ec4823 100644 --- a/grub-core/net/net.c +++ b/grub-core/net/net.c @@ -230,6 +230,11 @@ grub_net_ipv6_get_slaac (struct grub_net_card *card, } slaac->name = grub_malloc (sz); + if (slaac->name == NULL) + { + grub_free (slaac); + return NULL; + } ptr = grub_stpcpy (slaac->name, card->name); if (grub_net_hwaddr_cmp (&card->default_address, hwaddr) != 0) {