mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-08 12:44:23 +01:00
common,tools: Always escape newlines when escaping data.
* common/stringhelp.c (do_percent_escape): Always escape newlines. * tools/gpgconf-comp.c (gc_percent_escape): Likewise. -- Newlines always pose a problem for a line-based communication format. GnuPG-bug-id: 2387 Signed-off-by: Justus Winter <justus@g10code.com>
This commit is contained in:
parent
3cdb792007
commit
e064c75b08
@ -1052,7 +1052,8 @@ do_percent_escape (const char *str, const char *extra, int die)
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
for (i=j=0; str[i]; i++)
|
for (i=j=0; str[i]; i++)
|
||||||
if (str[i] == ':' || str[i] == '%' || (extra && strchr (extra, str[i])))
|
if (str[i] == ':' || str[i] == '%' || str[i] == '\n'
|
||||||
|
|| (extra && strchr (extra, str[i])))
|
||||||
j++;
|
j++;
|
||||||
if (die)
|
if (die)
|
||||||
ptr = xmalloc (i + 2 * j + 1);
|
ptr = xmalloc (i + 2 * j + 1);
|
||||||
@ -1077,6 +1078,13 @@ do_percent_escape (const char *str, const char *extra, int die)
|
|||||||
ptr[i++] = '2';
|
ptr[i++] = '2';
|
||||||
ptr[i++] = '5';
|
ptr[i++] = '5';
|
||||||
}
|
}
|
||||||
|
else if (*str == '\n')
|
||||||
|
{
|
||||||
|
/* The newline is problematic in a line-based format. */
|
||||||
|
ptr[i++] = '%';
|
||||||
|
ptr[i++] = '0';
|
||||||
|
ptr[i++] = 'a';
|
||||||
|
}
|
||||||
else if (extra && strchr (extra, *str))
|
else if (extra && strchr (extra, *str))
|
||||||
{
|
{
|
||||||
ptr[i++] = '%';
|
ptr[i++] = '%';
|
||||||
|
@ -1491,6 +1491,13 @@ gc_percent_escape (const char *src)
|
|||||||
*(dst++) = '2';
|
*(dst++) = '2';
|
||||||
*(dst++) = 'c';
|
*(dst++) = 'c';
|
||||||
}
|
}
|
||||||
|
else if (*src == '\n')
|
||||||
|
{
|
||||||
|
/* The newline is problematic in a line-based format. */
|
||||||
|
*(dst++) = '%';
|
||||||
|
*(dst++) = '0';
|
||||||
|
*(dst++) = 'a';
|
||||||
|
}
|
||||||
else
|
else
|
||||||
*(dst++) = *(src);
|
*(dst++) = *(src);
|
||||||
src++;
|
src++;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user