]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
* grub-core/script/execute.c (grub_script_arglist_to_argv): Fix
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Mon, 29 Apr 2013 10:02:26 +0000 (12:02 +0200)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Mon, 29 Apr 2013 10:02:26 +0000 (12:02 +0200)
handling of variables containing backslash.

ChangeLog
grub-core/script/execute.c

index bf413de6318875ead8095e8a45381e583fa27ffd..9dacb19b8ac9deea187cd2a3fa3f113f4ebfbde6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2013-04-29  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       * grub-core/script/execute.c (grub_script_arglist_to_argv): Fix
+       handling of variables containing backslash.
+
 2013-04-29  Vladimir Serbinenko  <phcoder@gmail.com>
 
        * include/grub/list.h (FOR_LIST_ELEMENTS_SAFE):Fix a NULL pointer
index a1dcc342d7f8b8525911e93d1cb4611836f70727..9babbeee20bd0a1814aac8ad2990ea6d77365064 100644 (file)
@@ -643,9 +643,38 @@ grub_script_arglist_to_argv (struct grub_script_arglist *arglist,
 
                  if (arg->type == GRUB_SCRIPT_ARG_TYPE_VAR)
                    {
-                     if (grub_script_argv_append (&result, values[i],
-                                                  grub_strlen (values[i])))
+                     int len;
+                     char ch;
+                     char *p;
+                     char *op;
+                     const char *s = values[i];
+
+                     len = grub_strlen (values[i]);
+                     /* \? -> \\\? */
+                     /* \* -> \\\* */
+                     /* \ -> \\ */
+                     p = grub_malloc (len * 2 + 1);
+                     if (! p)
                        goto fail;
+
+                     op = p;
+                     while ((ch = *s++))
+                       {
+                         if (ch == '\\')
+                           {
+                             *op++ = '\\';
+                             if (*s == '?' || *s == '*')
+                               *op++ = '\\';
+                           }
+                         *op++ = ch;
+                       }
+                     *op = '\0';
+
+                     if (grub_script_argv_append (&result, p, op - p))
+                       {
+                         grub_free (p);
+                         goto fail;
+                       }
                    }
                  else
                    {