15a2072
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
15a2072
From: Javier Martinez Canillas <javierm@redhat.com>
15a2072
Date: Thu, 7 Jun 2018 00:44:51 +0200
15a2072
Subject: [PATCH] Skip leading spaces on BLS field values
15a2072
15a2072
The GRUB 2 blscfg command doesn't parse correctly the BLS fields if these
15a2072
have extra spaces before the field values. For example, the following BLS
15a2072
fragment generates a wrong menu entry due using spaces to tabulate values:
15a2072
15a2072
title      Fedora 28 (Twenty Eight)
15a2072
version    4.16.13-300.fc28.x86_64
15a2072
machine-id e5c131dfee3249cbb9891c2641d8e350
15a2072
linux      /vmlinuz-4.16.13-300.fc28.x86_64
15a2072
initrd     /initramfs-4.16.13-300.fc28.x86_64.img
15a2072
options    root=/dev/mapper/fedora-root ro
15a2072
15a2072
Wrong generated menu entry:
15a2072
15a2072
load_video
15a2072
set gfx_payload=keep
15a2072
insmod gzio
15a2072
linux  ($root)    /vmlinuz-4.16.13-300.fc28.x86_64    root=/dev/mapper/fedora-root ro
15a2072
initrd ($root)    /initramfs-4.16.13-300.fc28.x86_64.img
15a2072
15a2072
Correct menu entry after the fix:
15a2072
15a2072
load_video
15a2072
set gfx_payload=keep
15a2072
insmod gzio
15a2072
linux ($root)/vmlinuz-4.16.13-300.fc28.x86_64 root=/dev/mapper/fedora-root ro
15a2072
initrd ($root)/initramfs-4.16.13-300.fc28.x86_64.img
15a2072
15a2072
Resolves: rhbz#1588184
15a2072
15a2072
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
15a2072
---
15a2072
 grub-core/commands/blscfg.c | 6 +++++-
15a2072
 1 file changed, 5 insertions(+), 1 deletion(-)
15a2072
15a2072
diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c
15a2072
index fb08d8e4c12..831cdcaccdf 100644
15a2072
--- a/grub-core/commands/blscfg.c
15a2072
+++ b/grub-core/commands/blscfg.c
15a2072
@@ -448,7 +448,11 @@ static int read_entry (
15a2072
 
15a2072
       separator[0] = '\0';
15a2072
 
15a2072
-      rc = bls_add_keyval (entry, buf, separator+1);
15a2072
+      do {
15a2072
+	separator++;
15a2072
+      } while (*separator == ' ' || *separator == '\t');
15a2072
+
15a2072
+      rc = bls_add_keyval (entry, buf, separator);
15a2072
       grub_free (buf);
15a2072
       if (rc < 0)
15a2072
 	break;