dovecot-2.0: UTF-8 string validity was checked incorrectly.

dovecot at dovecot.org dovecot at dovecot.org
Wed Aug 18 17:20:07 EEST 2010


details:   http://hg.dovecot.org/dovecot-2.0/rev/8c46bf2c5176
changeset: 12007:8c46bf2c5176
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Aug 18 15:17:40 2010 +0100
description:
UTF-8 string validity was checked incorrectly.

diffstat:

 src/lib/unichar.c |  4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diffs (16 lines):

diff -r 3ba227176cde -r 8c46bf2c5176 src/lib/unichar.c
--- 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;


More information about the dovecot-cvs mailing list