summaryrefslogtreecommitdiff
path: root/server/zstring.c
diff options
context:
space:
mode:
authorGravatar Karl Ramm <kcr@1ts.org>2009-08-22 23:39:24 +0000
committerGravatar Karl Ramm <kcr@1ts.org>2009-08-22 23:39:24 +0000
commit4b47e6fdb72809bdb695a29a25b04c67037dc72a (patch)
tree89f1befe94c7556079a5edfe3e4a409f5cabcc39 /server/zstring.c
parent5c95701df3ae2d44e824aac4ec121750b4fcd4ba (diff)
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.
Diffstat (limited to 'server/zstring.c')
-rw-r--r--server/zstring.c4
1 files changed, 2 insertions, 2 deletions
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. */