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