changeset 736:edd896dda3bd HEAD

We shouldn't be strdup()ing the buffer, it's not \0 terminated.
author Timo Sirainen <tss@iki.fi>
date Sun, 01 Dec 2002 20:16:35 +0200
parents ce93054db96b
children eae61c3f4f3c
files src/lib-charset/charset-iconv.c
diffstat 1 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-charset/charset-iconv.c	Sun Dec 01 20:00:03 2002 +0200
+++ b/src/lib-charset/charset-iconv.c	Sun Dec 01 20:16:35 2002 +0200
@@ -116,8 +116,11 @@
 	size_t inleft, outleft, outsize, pos;
 
 	if (charset == NULL || strcasecmp(charset, "us-ascii") == 0 ||
-	    strcasecmp(charset, "ascii") == 0)
-		return str_ucase(t_strdup_noconst(buf));
+	    strcasecmp(charset, "ascii") == 0) {
+		outbuf = t_malloc(*size);
+		memcpy(outbuf, buf, *size);
+		return str_ucase(outbuf);
+	}
 
 	cd = iconv_open("UTF-8", charset);
 	if (cd == (iconv_t)-1) {