dovecot-2.2: lib-imap: imap_utf7_to_utf8() returns failure now f...

dovecot at dovecot.org dovecot at dovecot.org
Wed Apr 29 15:21:21 UTC 2015


details:   http://hg.dovecot.org/dovecot-2.2/rev/46065d7276ab
changeset: 18499:46065d7276ab
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Apr 29 17:19:34 2015 +0200
description:
lib-imap: imap_utf7_to_utf8() returns failure now for encoded NULs.
All the callers change the string to NUL-terminated string, so the earlier
behavior was just truncating the string at the encoded NUL. It's a bit safer
to just return failure so in future if the callers didn't convert the string
to NUL-terminated string it wouldn't be handled inconsistently in different
places.

diffstat:

 src/lib-imap/imap-utf7.c |  8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diffs (18 lines):

diff -r c5cdf42e398a -r 46065d7276ab src/lib-imap/imap-utf7.c
--- a/src/lib-imap/imap-utf7.c	Wed Apr 29 11:33:21 2015 +0200
+++ b/src/lib-imap/imap-utf7.c	Wed Apr 29 17:19:34 2015 +0200
@@ -149,6 +149,14 @@
 	    high > UTF16_SURROGATE_HIGH_MAX) {
 		/* single byte */
 		size_t oldlen = str_len(dest);
+
+		if (high == 0) {
+			/* Encoded NUL isn't going to work in Dovecot code,
+			   even though it's technically valid. Return failure
+			   so the callers don't even get a chance to handle the
+			   NUL in the string inconsistently. */
+			return -1;
+		}
 		uni_ucs4_to_utf8_c(high, dest);
 		if (str_len(dest) - oldlen == 1) {
 			unsigned char last = str_data(dest)[oldlen];


More information about the dovecot-cvs mailing list