* grub-core/commands/wildcard.c (make_regex): Escape brackets.

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2010-09-12 20:15:30 +02:00
parent 84fb3b3d73
commit d8a84076ea
2 changed files with 9 additions and 1 deletions

View file

@ -1,3 +1,7 @@
2010-09-12 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/commands/wildcard.c (make_regex): Escape brackets.
2010-09-12 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/commands/ls.c (grub_cmd_ls): Accept multiple files.

View file

@ -137,8 +137,10 @@ make_regex (const char *start, const char *end, regex_t *regexp)
break;
case '.':
case '(':
case ')':
buffer[i++] = '\\';
buffer[i++] = '.';
buffer[i++] = ch;
break;
case '*':
@ -152,6 +154,7 @@ make_regex (const char *start, const char *end, regex_t *regexp)
}
buffer[i++] = '$';
buffer[i] = '\0';
grub_dprintf ("expand", "Regexp is %s\n", buffer);
if (regcomp (regexp, buffer, RE_SYNTAX_GNU_AWK))
{
@ -224,6 +227,7 @@ match_devices (const regex_t *regexp, int noparts)
grub_dprintf ("expand", "matching: %s\n", buffer);
if (regexec (regexp, buffer, 0, 0, 0))
{
grub_dprintf ("expand", "not matched\n");
grub_free (buffer);
return 0;
}