Mercurial > dovecot > original-hg > dovecot-1.2
changeset 9600:ccc71865dea0 HEAD
UTF-8 string validity was checked incorrectly.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Wed, 18 Aug 2010 15:17:40 +0100 |
parents | be169f7464de |
children | 70fa6178380e |
files | src/lib/unichar.c |
diffstat | 1 files changed, 3 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib/unichar.c Mon Aug 16 20:36:44 2010 +0100 +++ b/src/lib/unichar.c Wed Aug 18 15:17:40 2010 +0100 @@ -315,9 +315,11 @@ if (unlikely(len > size || len == 1)) return 0; + /* the rest of the chars should be in 0x80..0xbf range. + anything else is start of a sequence or invalid */ for (i = 1; i < len; i++) { if (unlikely(uni_utf8_char_bytes(input[i]) != len-i || - input[i] < 192-2)) + input[i] < 0x80 || input[i] >= 0xbf)) return 0; } return len;