--- a/libpurple/util.c Sun Feb 19 03:30:18 2017 +0000
+++ b/libpurple/util.c Wed Mar 01 03:13:00 2017 +0000
@@ -978,18 +978,29 @@
pln = "\302\256"; /* or use g_unichar_to_utf8(0xae); */
else if(IS_ENTITY("'"))
- else if(*(text+1) == '#' &&
- (sscanf(text, "&#%u%1[;]", £, temp) == 2 ||
- sscanf(text, "&#x%x%1[;]", £, temp) == 2) &&
+ else if(text[1] == '#' && g_ascii_isxdigit(text[2])) { - int buflen = g_unichar_to_utf8((gunichar)pound, buf);
+ const char *start = text + 2; + pound = g_ascii_strtoull(start, &end, base); + if (pound == 0 || pound > INT_MAX || *end != ';') { + len = (end - text) + 1; + buflen = g_unichar_to_utf8((gunichar)pound, buf);
- len = (*(text+2) == 'x' ? 3 : 2);
- while(isxdigit((gint) text[len])) len++;
- if(text[len] == ';') len++;