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

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


details:   http://hg.dovecot.org/dovecot-1.1/rev/3fdeac838172
changeset: 8368:3fdeac838172
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 62ec6feb3870 -r 3fdeac838172 src/lib/unichar.c
--- a/src/lib/unichar.c	Sun Jan 24 23:18:12 2010 +0200
+++ 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