* grub-core/script/execute.c (grub_script_arglist_to_argv): Fix

handling of variables containing backslash.
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2013-04-29 12:02:26 +02:00
parent e9e46c9a0c
commit bdc4add8ca
2 changed files with 36 additions and 2 deletions

View File

@ -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

View 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
{