2021-11-03 23:51:46 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Javier Martinez Canillas <javierm@redhat.com>
|
|
|
|
Date: Mon, 9 Mar 2020 15:30:05 +0100
|
|
|
|
Subject: [PATCH] efi/ip4_config: Improve check to detect literal IPv6
|
|
|
|
addresses
|
|
|
|
|
|
|
|
The grub_efi_string_to_ip4_address() function wrongly assumes that an IPv6
|
|
|
|
address is an IPv4 address, because it doesn't take into account the case
|
|
|
|
of a caller passing an IPv6 address as a string.
|
|
|
|
|
|
|
|
This leads to the grub_efi_net_parse_address() function to fail and print
|
|
|
|
the following error message:
|
|
|
|
|
|
|
|
error: net/efi/net.c:785:unrecognised network address '2000:dead:beef:a::1'
|
|
|
|
|
|
|
|
Resolves: rhbz#1732765
|
|
|
|
|
|
|
|
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
|
|
|
|
---
|
|
|
|
grub-core/net/efi/ip4_config.c | 13 ++++++++++++-
|
|
|
|
1 file changed, 12 insertions(+), 1 deletion(-)
|
|
|
|
|
|
|
|
diff --git a/grub-core/net/efi/ip4_config.c b/grub-core/net/efi/ip4_config.c
|
2023-03-28 09:02:12 +00:00
|
|
|
index b711a5d945..313c818b18 100644
|
2021-11-03 23:51:46 +00:00
|
|
|
--- a/grub-core/net/efi/ip4_config.c
|
|
|
|
+++ b/grub-core/net/efi/ip4_config.c
|
|
|
|
@@ -56,9 +56,20 @@ int
|
|
|
|
grub_efi_string_to_ip4_address (const char *val, grub_efi_ipv4_address_t *address, const char **rest)
|
|
|
|
{
|
|
|
|
grub_uint32_t newip = 0;
|
|
|
|
- int i;
|
|
|
|
+ int i, ncolon = 0;
|
|
|
|
const char *ptr = val;
|
|
|
|
|
|
|
|
+ /* Check that is not an IPv6 address */
|
|
|
|
+ for (i = 0; i < grub_strlen(ptr); i++)
|
|
|
|
+ {
|
|
|
|
+ if (ptr[i] == '[' && i == 0)
|
|
|
|
+ return 0;
|
|
|
|
+
|
|
|
|
+ if (ptr[i] == ':')
|
|
|
|
+ if (i == 0 || ++ncolon == 2)
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
{
|
|
|
|
unsigned long t;
|