Fix quoting in legacy parser.
* grub-core/lib/legacy_parse.c (grub_legacy_escape): Correctly handle single quotes. (grub_legacy_parse): Likewise. Reported by: Jordan Uggla. Tested by: Jordan Uggla.
This commit is contained in:
parent
03f80960cf
commit
22e7dbb2bb
2 changed files with 32 additions and 9 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
||||||
|
2010-11-14 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
Fix quoting in legacy parser.
|
||||||
|
|
||||||
|
* grub-core/lib/legacy_parse.c (grub_legacy_escape): Correctly handle
|
||||||
|
single quotes.
|
||||||
|
(grub_legacy_parse): Likewise.
|
||||||
|
Reported by: Jordan Uggla.
|
||||||
|
Tested by: Jordan Uggla.
|
||||||
|
|
||||||
2010-11-14 Vladimir Serbinenko <phcoder@gmail.com>
|
2010-11-14 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
Don't add -lgcc on i386 and x86_64.
|
Don't add -lgcc on i386 and x86_64.
|
||||||
|
|
|
@ -326,16 +326,22 @@ grub_legacy_escape (const char *in, grub_size_t len)
|
||||||
char *ret, *outptr;
|
char *ret, *outptr;
|
||||||
int overhead = 0;
|
int overhead = 0;
|
||||||
for (ptr = in; ptr < in + len && *ptr; ptr++)
|
for (ptr = in; ptr < in + len && *ptr; ptr++)
|
||||||
if (*ptr == '\'' || *ptr == '\\')
|
if (*ptr == '\'')
|
||||||
overhead++;
|
overhead += 3;
|
||||||
ret = grub_malloc (ptr - in + overhead + 1);
|
ret = grub_malloc (ptr - in + overhead + 1);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
return NULL;
|
return NULL;
|
||||||
outptr = ret;
|
outptr = ret;
|
||||||
for (ptr = in; ptr < in + len && *ptr; ptr++)
|
for (ptr = in; ptr < in + len && *ptr; ptr++)
|
||||||
{
|
{
|
||||||
if (*ptr == '\'' || *ptr == '\\')
|
if (*ptr == '\'')
|
||||||
*outptr++ = '\\';
|
{
|
||||||
|
*outptr++ = '\'';
|
||||||
|
*outptr++ = '\\';
|
||||||
|
*outptr++ = '\'';
|
||||||
|
*outptr++ = '\'';
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
*outptr++ = *ptr;
|
*outptr++ = *ptr;
|
||||||
}
|
}
|
||||||
|
@ -622,12 +628,13 @@ grub_legacy_parse (const char *buf, char **entryname, char **suffix)
|
||||||
{
|
{
|
||||||
for (; *ptr && grub_isspace (*ptr); ptr++);
|
for (; *ptr && grub_isspace (*ptr); ptr++);
|
||||||
for (; *ptr && !grub_isspace (*ptr); ptr++)
|
for (; *ptr && !grub_isspace (*ptr); ptr++)
|
||||||
if (*ptr == '\\' || *ptr == '\'')
|
if (*ptr == '\'')
|
||||||
overhead++;
|
overhead += 3;
|
||||||
if (*ptr)
|
if (*ptr)
|
||||||
ptr++;
|
ptr++;
|
||||||
overhead += 3;
|
overhead += 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
outptr0 = args[i] = grub_malloc (overhead + (ptr - curarg));
|
outptr0 = args[i] = grub_malloc (overhead + (ptr - curarg));
|
||||||
if (!outptr0)
|
if (!outptr0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -641,9 +648,15 @@ grub_legacy_parse (const char *buf, char **entryname, char **suffix)
|
||||||
*outptr++ = '\'';
|
*outptr++ = '\'';
|
||||||
for (; *ptr && !grub_isspace (*ptr); ptr++)
|
for (; *ptr && !grub_isspace (*ptr); ptr++)
|
||||||
{
|
{
|
||||||
if (*ptr == '\\' || *ptr == '\'')
|
if (*ptr == '\'')
|
||||||
*outptr++ = '\\';
|
{
|
||||||
*outptr++ = *ptr;
|
*outptr++ = '\'';
|
||||||
|
*outptr++ = '\\';
|
||||||
|
*outptr++ = '\'';
|
||||||
|
*outptr++ = '\'';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
*outptr++ = *ptr;
|
||||||
}
|
}
|
||||||
*outptr++ = '\'';
|
*outptr++ = '\'';
|
||||||
if (*ptr)
|
if (*ptr)
|
||||||
|
|
Loading…
Reference in a new issue