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

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