]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
kern/corecmd: Quote variable values when displayed by the set command
authorGlenn Washburn <development@efficientek.com>
Fri, 26 Aug 2022 00:53:51 +0000 (19:53 -0500)
committerDaniel Kiper <daniel.kiper@oracle.com>
Tue, 11 Oct 2022 12:28:06 +0000 (14:28 +0200)
Variable values may contain spaces at the end or newlines. However, when
displayed without quotes this is not obvious and can lead to confusion as
to the actual contents of variables. Also for some variables grub_env_get()
returns a NULL pointer instead of a pointer to an empty string and
previously would be printed as "var=(null)". Now such variables will be
displayed as "var=''".

Signed-off-by: Glenn Washburn <development@efficientek.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
grub-core/kern/corecmd.c

index fc54f43f2b827012cc8757a3171dffb5223ee265..62d434ba9a90004ed58c8b4a586548cfa00cf35f 100644 (file)
@@ -40,7 +40,10 @@ grub_core_cmd_set (struct grub_command *cmd __attribute__ ((unused)),
     {
       struct grub_env_var *env;
       FOR_SORTED_ENV (env)
-       grub_printf ("%s=%s\n", env->name, grub_env_get (env->name));
+       {
+         val = (char *) grub_env_get (env->name);
+         grub_printf ("%s='%s'\n", env->name, val == NULL ? "" : val);
+       }
       return 0;
     }