summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Shea <dshea@redhat.com>2016-05-24 11:08:32 +0900
committerDaiki Ueno <ueno@gnu.org>2016-05-24 11:10:27 +0900
commit68ab0dafa99f1941b3ebb47b7cf969381e7310f4 (patch)
treeab594b884be963fcc181b6148c9e05240559e1cf
parent3b5753977df1653edd0db8223610ffd5661be27a (diff)
downloadexternal_gettext-68ab0dafa99f1941b3ebb47b7cf969381e7310f4.zip
external_gettext-68ab0dafa99f1941b3ebb47b7cf969381e7310f4.tar.gz
external_gettext-68ab0dafa99f1941b3ebb47b7cf969381e7310f4.tar.bz2
desktop: Fix invalid memory access
* gettext-tools/src/read-desktop.c (desktop_lex): Don't access memory deallocated with realloc(). Reported in: http://savannah.gnu.org/bugs/?47991
-rw-r--r--gettext-tools/src/read-desktop.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/gettext-tools/src/read-desktop.c b/gettext-tools/src/read-desktop.c
index 417c08a..e505045 100644
--- a/gettext-tools/src/read-desktop.c
+++ b/gettext-tools/src/read-desktop.c
@@ -326,8 +326,9 @@ desktop_lex (token_ty *tp)
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
{
- const char *locale = NULL;
- const char *value = NULL;
+ size_t locale_start;
+ bool found_locale = false;
+ size_t value_start;
for (;;)
{
APPEND (c);
@@ -353,7 +354,8 @@ desktop_lex (token_ty *tp)
case '[':
/* Finish the key part and start the locale part. */
APPEND (0);
- locale = &buffer[bufpos];
+ found_locale = true;
+ locale_start = bufpos;
for (;;)
{
@@ -428,7 +430,7 @@ desktop_lex (token_ty *tp)
break;
}
- value = &buffer[bufpos];
+ value_start = bufpos;
for (;;)
{
c = phase2_getc ();
@@ -439,8 +441,8 @@ desktop_lex (token_ty *tp)
APPEND (0);
tp->type = token_type_pair;
tp->string = xmemdup (buffer, bufpos);
- tp->locale = locale;
- tp->value = value;
+ tp->locale = found_locale ? &buffer[locale_start] : NULL;
+ tp->value = &buffer[value_start];
return;
}
default: