Blame SOURCES/0100-Don-t-use-dynamic-sized-arrays-since-we-don-t-build-.patch

8631a2
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
8631a2
From: Peter Jones <pjones@redhat.com>
8631a2
Date: Mon, 26 Jun 2017 12:42:57 -0400
8631a2
Subject: [PATCH] Don't use dynamic sized arrays since we don't build with
8631a2
 -std=c99
8631a2
8631a2
---
8631a2
 grub-core/net/net.c | 17 ++++++++++++++---
8631a2
 1 file changed, 14 insertions(+), 3 deletions(-)
8631a2
8631a2
diff --git a/grub-core/net/net.c b/grub-core/net/net.c
b32e65
index 4be228d95..fa3e29126 100644
8631a2
--- a/grub-core/net/net.c
8631a2
+++ b/grub-core/net/net.c
8631a2
@@ -1853,14 +1853,25 @@ grub_net_search_configfile (char *config)
8631a2
     {
8631a2
       /* By the Client UUID. */
8631a2
 
8631a2
-      char client_uuid_var[sizeof ("net_") + grub_strlen (inf->name) +
8631a2
-                           sizeof ("_clientuuid") + 1];
8631a2
-      grub_snprintf (client_uuid_var, sizeof (client_uuid_var),
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 = grub_malloc(client_uuid_var_size);
8631a2
+      if (!client_uuid_var)
8631a2
+	continue;
8631a2
+      grub_snprintf (client_uuid_var, client_uuid_var_size,
8631a2
                      "net_%s_clientuuid", inf->name);
8631a2
 
8631a2
       const char *client_uuid;
8631a2
       client_uuid = grub_env_get (client_uuid_var);
8631a2
 
8631a2
+      grub_free(client_uuid_var);
8631a2
+
8631a2
       if (client_uuid)
8631a2
         {
8631a2
           grub_strcpy (suffix, client_uuid);