From 4b47e6fdb72809bdb695a29a25b04c67037dc72a Mon Sep 17 00:00:00 2001 From: Karl Ramm Date: Sat, 22 Aug 2009 23:39:24 +0000 Subject: Fix a casefolding bug. [64-bit] In valid_utf8_p(), uc was improperly typed and never initialized. On 64-bit systems, this means that success is dependent on previous stack contents. If the upper 32 bits are not zero, the null terminator is not caught and the function continues reading past the end of the string until: 1) Invalid UTF-8 is encountered 2) An invalid unicode codepoint is encountered. 3) segfault 1 and 2 are much more likely, but 3 is a danger. --- server/zstring.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'server/zstring.c') diff --git a/server/zstring.c b/server/zstring.c index de9e2fa..8ae9ade 100644 --- a/server/zstring.c +++ b/server/zstring.c @@ -24,8 +24,8 @@ static String *zhash[STRING_HASH_TABLE_SIZE]; int valid_utf8_p(const char* s) { - int len; - ssize_t uc; + ssize_t len; + int32_t uc; while ((len = utf8proc_iterate((const unsigned char *)s, -1, &uc))) { if (len <=0) return 0; /* Not valid UTF-8 encoding. */ -- cgit v1.2.3