From: Timo Sirainen Date: Wed, 18 Aug 2010 14:17:40 +0000 (+0100) Subject: UTF-8 string validity was checked incorrectly. X-Git-Tag: 2.0.1~37 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6b4c4d92d296b082efb4ca9242232bf4b67f5a05;p=thirdparty%2Fdovecot%2Fcore.git UTF-8 string validity was checked incorrectly. --- diff --git a/src/lib/unichar.c b/src/lib/unichar.c index 8148173432..9d5d406f6a 100644 --- a/src/lib/unichar.c +++ b/src/lib/unichar.c @@ -322,9 +322,11 @@ is_valid_utf8_seq(const unsigned char *input, unsigned int size) 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;