2019-11-27 11:10:51 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Javier Martinez Canillas <javierm@redhat.com>
|
|
|
|
Date: Tue, 26 Nov 2019 09:51:41 +0100
|
|
|
|
Subject: [PATCH] blscfg: add a space char when appending fields for variable
|
|
|
|
expansion
|
|
|
|
|
|
|
|
The GRUB variables are expanded and replaced by their values before adding
|
|
|
|
menu entries, but they didn't include space characters after the values so
|
|
|
|
the result was not correct.
|
|
|
|
|
|
|
|
For the common case this wasn't a problem but it is if there are variables
|
|
|
|
that are part of the values of other variables.
|
|
|
|
|
|
|
|
Resolves: rhbz#1669252
|
|
|
|
|
|
|
|
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
|
|
|
|
---
|
2019-12-05 16:03:13 +00:00
|
|
|
grub-core/commands/blscfg.c | 31 ++++++++++++++++++-------------
|
|
|
|
1 file changed, 18 insertions(+), 13 deletions(-)
|
2019-11-27 11:10:51 +00:00
|
|
|
|
|
|
|
diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c
|
2019-12-05 16:03:13 +00:00
|
|
|
index 471975fd2e5..d78cff79f97 100644
|
2019-11-27 11:10:51 +00:00
|
|
|
--- a/grub-core/commands/blscfg.c
|
|
|
|
+++ b/grub-core/commands/blscfg.c
|
2019-12-05 16:03:13 +00:00
|
|
|
@@ -593,26 +593,29 @@ static char **bls_make_list (struct bls_entry *entry, const char *key, int *num)
|
|
|
|
|
|
|
|
static char *field_append(bool is_var, char *buffer, char *start, char *end)
|
|
|
|
{
|
|
|
|
- char *temp = grub_strndup(start, end - start + 1);
|
|
|
|
- const char *field = temp;
|
|
|
|
+ char *tmp = grub_strndup(start, end - start + 1);
|
|
|
|
+ const char *field = tmp;
|
|
|
|
+ int term = is_var ? 2 : 1;
|
|
|
|
|
|
|
|
if (is_var) {
|
|
|
|
- field = grub_env_get (temp);
|
|
|
|
+ field = grub_env_get (tmp);
|
|
|
|
if (!field)
|
2019-11-27 11:10:51 +00:00
|
|
|
return buffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
- if (!buffer) {
|
|
|
|
- buffer = grub_strdup(field);
|
|
|
|
- if (!buffer)
|
|
|
|
- return NULL;
|
|
|
|
- } else {
|
|
|
|
- buffer = grub_realloc (buffer, grub_strlen(buffer) + grub_strlen(field));
|
|
|
|
- if (!buffer)
|
|
|
|
- return NULL;
|
|
|
|
+ if (!buffer)
|
2019-12-05 16:03:13 +00:00
|
|
|
+ buffer = grub_zalloc (grub_strlen(field) + term);
|
2019-11-27 11:10:51 +00:00
|
|
|
+ else
|
2019-12-05 16:03:13 +00:00
|
|
|
+ buffer = grub_realloc (buffer, grub_strlen(buffer) + grub_strlen(field) + term);
|
2019-11-27 11:10:51 +00:00
|
|
|
|
|
|
|
- grub_stpcpy (buffer + grub_strlen(buffer), field);
|
|
|
|
- }
|
|
|
|
+ if (!buffer)
|
|
|
|
+ return NULL;
|
|
|
|
+
|
2019-12-05 16:03:13 +00:00
|
|
|
+ tmp = buffer + grub_strlen(buffer);
|
|
|
|
+ tmp = grub_stpcpy (tmp, field);
|
|
|
|
+
|
|
|
|
+ if (is_var)
|
|
|
|
+ tmp = grub_stpcpy (tmp, " ");
|
2019-11-27 11:10:51 +00:00
|
|
|
|
|
|
|
return buffer;
|
|
|
|
}
|
2019-12-05 16:03:13 +00:00
|
|
|
@@ -642,6 +645,8 @@ static char *expand_val(char *value)
|
|
|
|
buffer = field_append(is_var, buffer, start, end);
|
|
|
|
is_var = false;
|
|
|
|
start = value;
|
|
|
|
+ if (*start == ' ')
|
|
|
|
+ start++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|