dovecot-1.0: str_sanitize*() didn't properly limit string length...

dovecot at dovecot.org dovecot at dovecot.org
Sun Dec 2 14:06:16 EET 2007


details:   http://hg.dovecot.org/dovecot-1.0/rev/652713b19082
changeset: 5477:652713b19082
user:      Timo Sirainen <tss at iki.fi>
date:      Sun Dec 02 14:06:12 2007 +0200
description:
str_sanitize*() didn't properly limit string length. Also changed to treat
0x80..0x9f as control characters.

diffstat:

1 file changed, 3 insertions(+), 3 deletions(-)
src/lib/str-sanitize.c |    6 +++---

diffs (21 lines):

diff -r 4b2bfa37041e -r 652713b19082 src/lib/str-sanitize.c
--- a/src/lib/str-sanitize.c	Sat Dec 01 10:39:11 2007 +0200
+++ b/src/lib/str-sanitize.c	Sun Dec 02 14:06:12 2007 +0200
@@ -8,14 +8,14 @@ void str_sanitize_append(string_t *dest,
 {
 	const char *p;
 
-	for (p = src; *p != '\0'; p++) {
-		if ((unsigned char)*p < 32)
+	for (p = src; *p != '\0' && max_len > 0; p++, max_len--) {
+		if (((unsigned char)*p & 0x7f) < 32)
 			break;
 	}
 
 	str_append_n(dest, src, (size_t)(p - src));
 	for (; *p != '\0' && max_len > 0; p++, max_len--) {
-		if ((unsigned char)*p < 32)
+		if (((unsigned char)*p & 0x7f) < 32)
 			str_append_c(dest, '?');
 		else
 			str_append_c(dest, *p);


More information about the dovecot-cvs mailing list