]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
UTF-8 string validity was checked incorrectly.
authorTimo Sirainen <tss@iki.fi>
Wed, 18 Aug 2010 14:17:40 +0000 (15:17 +0100)
committerTimo Sirainen <tss@iki.fi>
Wed, 18 Aug 2010 14:17:40 +0000 (15:17 +0100)
src/lib/unichar.c

index 8148173432345d3ee8ce4f5a297487d32002e9a5..9d5d406f6ac5f2d6e80d119dd704fc48b1c5ad62 100644 (file)
@@ -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;