diff options
Diffstat (limited to 'gettext-tools/src')
-rw-r--r-- | gettext-tools/src/ChangeLog | 7 | ||||
-rw-r--r-- | gettext-tools/src/x-c.c | 26 |
2 files changed, 22 insertions, 11 deletions
diff --git a/gettext-tools/src/ChangeLog b/gettext-tools/src/ChangeLog index 5b03bac..ad56f27 100644 --- a/gettext-tools/src/ChangeLog +++ b/gettext-tools/src/ChangeLog @@ -1,5 +1,12 @@ 2015-06-25 Daiki Ueno <ueno@gnu.org> + * x-c.c (literalstring_parse): Bail out if C == NUL. Also adjust + the loop invariant in Unicode literal handling. + Reported by Hanno Boeck in: + <http://savannah.gnu.org/bugs/?45391>. + +2015-06-25 Daiki Ueno <ueno@gnu.org> + * x-c.c (literalstring_parse): Add more NUL checks. Change the loop invariant so that C always points to the character previously pointed by P. diff --git a/gettext-tools/src/x-c.c b/gettext-tools/src/x-c.c index 722f4b6..68e9f5d 100644 --- a/gettext-tools/src/x-c.c +++ b/gettext-tools/src/x-c.c @@ -1129,23 +1129,24 @@ literalstring_parse (const char *string, lex_pos_ty *pos, case 'U': case 'u': { unsigned char buf[8]; - int length = c == 'u' ? 4 : 8; + int prefix = c; + int length = prefix == 'u' ? 4 : 8; int n, j; for (n = 0, j = 0; j < length; j++) { - int c1 = *p++; - - if (c1 >= '0' && c1 <= '9') - n = (n << 4) + (c1 - '0'); - else if (c1 >= 'A' && c1 <= 'F') - n = (n << 4) + (c1 - 'A' + 10); - else if (c1 >= 'a' && c1 <= 'f') - n = (n << 4) + (c1 - 'a' + 10); + c = *p++; + + if (c >= '0' && c <= '9') + n = (n << 4) + (c - '0'); + else if (c >= 'A' && c <= 'F') + n = (n << 4) + (c - 'A' + 10); + else if (c >= 'a' && c <= 'f') + n = (n << 4) + (c - 'a' + 10); else break; - buf[j] = c1; + buf[j] = c; } if (j == length) @@ -1167,7 +1168,7 @@ warning: invalid Unicode character")); int i; mixed_string_buffer_append_char (bp, '\\'); - mixed_string_buffer_append_char (bp, c); + mixed_string_buffer_append_char (bp, prefix); for (i = 0; i < j; i++) mixed_string_buffer_append_char (bp, buf[i]); @@ -1178,6 +1179,9 @@ warning: invalid Unicode character")); continue; } + if (c == '\0') + break; + mixed_string_buffer_append_char (bp, c); } |