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

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


details:   http://hg.dovecot.org/dovecot-1.2/rev/ccc71865dea0
changeset: 9600:ccc71865dea0
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 be169f7464de -r ccc71865dea0 src/lib/unichar.c
--- 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;


More information about the dovecot-cvs mailing list