Skip to contentSkip to conversation

envblk: ignore empty new lines while parsing env files

PATCH In review Shreenidhi Shedi 2 participants 3 messages May 15, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 envblk: ignore empty new lines while parsing env files

From: Shreenidhi Shedi <[email protected]>

---
 grub-core/lib/envblk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
grub-core/lib/envblk.c +1 -1
index 2e4e78b13..f08dabaad 100644
@@ -235,7 +235,7 @@ grub_envblk_iterate (grub_envblk_t envblk,
 
   while (p < pend)
     {
-      if (*p != '#')
+      if (*p != '#' && *p != '\n')
         {
           char *name;
           char *value;
Signature · 7 lines
2.40.4


_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
#1 lore raw

PATCH 2/2 cmdline: fix command line parsing in grub

From: Shreenidhi Shedi <[email protected]>

- Stop escaping single and double quotes
- Kernel command line handler doesn't support escape quotes

---
 grub-core/lib/cmdline.c | 17 +++--------------
 1 file changed, 3 insertions(+), 14 deletions(-)
grub-core/lib/cmdline.c +3 -14
index ed0b149dc..57c96a151 100644
@@ -22,7 +22,6 @@
 
 static unsigned int check_arg (char *c, int *has_space)
 {
-  int space = 0;
   unsigned int size = 0;
 
   while (*c)
@@ -51,15 +50,9 @@ unsigned int grub_loader_cmdline_size (int argc, char *argv[])
   unsigned int size = 0;
 
   for (i = 0; i < argc; i++)
-    {
       size += check_arg (argv[i], 0);
-      size++; /* Separator space or NULL.  */
-    }
-
-  if (size == 0)
-    size = 1;
 
-  return size;
+  return size ? size : 1;
 }
 
 grub_err_t
@@ -73,8 +66,8 @@ grub_create_loader_cmdline (int argc, char *argv[], char *buf,
   for (i = 0; i < argc; i++)
     {
       c = argv[i];
+      space = 0;
       arg_size = check_arg(argv[i], &space);
-      arg_size++; /* Separator space or NULL.  */
 
       if (size < arg_size)
 	break;
@@ -86,11 +79,7 @@ grub_create_loader_cmdline (int argc, char *argv[], char *buf,
 
       while (*c)
 	{
-	  if (*c == '\\' || *c == '\'' || *c == '"')
-	    *buf++ = '\\';
-
-	  *buf++ = *c;
-	  c++;
+	  *buf++ = *c++;
 	}
 
       if (space)
Signature · 7 lines
2.40.4


_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel