handling of variables containing backslash.
+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
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
{