Blame SOURCES/0257-Fix-the-looking-up-grub.cfg-XXX-while-tftp-booting.patch

d9d99f
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
d9d99f
From: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
d9d99f
Date: Tue, 18 Dec 2018 21:27:45 -0500
d9d99f
Subject: [PATCH] Fix the looking up grub.cfg-XXX while tftp booting.
d9d99f
d9d99f
Currently, grub doesn't look up grub.cfg-UUID, grub.cfg-MAC and grub.cfg-IP
d9d99f
while the boot is from tftp. That is because the uuid size is got by
d9d99f
grub_snprintf(, 0, ,), but the grub_snprintf() always returns 0,
d9d99f
so grub judges there's no available uuid in the client and give up
d9d99f
the looking up grub.cfg-XXX.
d9d99f
d9d99f
This issue can be fixed by changing grub_snprintf(, 0, ,) behaivior
d9d99f
to like as snprintf() from glibc, however, somewhere may expect
d9d99f
such argument as the error, so it's risky.
d9d99f
d9d99f
Let's use sizeof() and grub_strlen() to calculate the uuid size
d9d99f
instead of grub_snprintf().
d9d99f
d9d99f
Resolves: rhbz#1658500
d9d99f
---
d9d99f
 grub-core/net/net.c | 8 +++-----
d9d99f
 1 file changed, 3 insertions(+), 5 deletions(-)
d9d99f
d9d99f
diff --git a/grub-core/net/net.c b/grub-core/net/net.c
b71686
index a011b9401..19ff2d486 100644
d9d99f
--- a/grub-core/net/net.c
d9d99f
+++ b/grub-core/net/net.c
d9d99f
@@ -1942,11 +1942,9 @@ grub_net_search_configfile (char *config)
d9d99f
       char *client_uuid_var;
d9d99f
       grub_size_t client_uuid_var_size;
d9d99f
 
d9d99f
-      client_uuid_var_size = grub_snprintf (NULL, 0,
d9d99f
-                     "net_%s_clientuuid", inf->name);
d9d99f
-      if (client_uuid_var_size <= 0)
d9d99f
-	continue;
d9d99f
-      client_uuid_var_size += 1;
d9d99f
+      client_uuid_var_size = sizeof ("net_") + grub_strlen (inf->name) +
d9d99f
+                     sizeof ("_clientuuid") + 1;
d9d99f
+
d9d99f
       client_uuid_var = grub_malloc(client_uuid_var_size);
d9d99f
       if (!client_uuid_var)
d9d99f
 	continue;