Mercurial > dovecot > core-2.2
changeset 12007:8c46bf2c5176
UTF-8 string validity was checked incorrectly.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Wed, 18 Aug 2010 15:17:40 +0100 |
parents | 3ba227176cde |
children | 038f25c02bb7 |
files | src/lib/unichar.c |
diffstat | 1 files changed, 3 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib/unichar.c Tue Aug 17 19:16:03 2010 +0100 +++ b/src/lib/unichar.c Wed Aug 18 15:17:40 2010 +0100 @@ -322,9 +322,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;