From f79c4faf50deeee2fda26c675b38da3ad019a489 Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Sun, 11 Jan 2004 04:28:52 +0000 Subject: if e_iconv() returns -1, check that errno != EINVAL - if errno *is* 2004-01-10 Jeffrey Stedfast * camel-mime-utils.c (rfc2047_encode_word): if e_iconv() returns -1, check that errno != EINVAL - if errno *is* EINVAL, it just means that our convlen wasn't long enough to include the whole sequence. This is fine, we'll just start where we left off next loop thru. Fixes bug #52593 (the buffer was duplicated because state wasn't flushed). (camel_header_encode_string): Fixed a type-o in loop where encoding=0, don't g_string_append_len starting at 'word' inptr-start bytes long - 'word' could be NULL and/or inptr-start could be longer than inptr-word. svn path=/trunk/; revision=24149 --- camel/camel-mime-utils.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'camel/camel-mime-utils.c') diff --git a/camel/camel-mime-utils.c b/camel/camel-mime-utils.c index 88a7c2ad9b..83caa8f1d2 100644 --- a/camel/camel-mime-utils.c +++ b/camel/camel-mime-utils.c @@ -1250,7 +1250,7 @@ rfc2047_encode_word(GString *outstring, const char *in, size_t len, const char * hopefully-small-enough chunks, and leave it at that */ convlen = MIN(inlen, CAMEL_FOLD_PREENCODED); p = inptr; - if (e_iconv (ic, &inptr, &convlen, &out, &outlen) == (size_t) -1) { + if (e_iconv (ic, &inptr, &convlen, &out, &outlen) == (size_t) -1 && errno != EINVAL) { w(g_warning("Conversion problem: conversion truncated: %s", strerror (errno))); /* blah, we include it anyway, better than infinite loop ... */ inptr = p + convlen; @@ -1279,7 +1279,7 @@ rfc2047_encode_word(GString *outstring, const char *in, size_t len, const char * g_string_append (outstring, ascii); } } - + if (ic != (iconv_t) -1) e_iconv_close (ic); } @@ -1334,13 +1334,14 @@ camel_header_encode_string (const unsigned char *in) if (g_unichar_isspace (c) && !last_was_space) { /* we've reached the end of a 'word' */ if (word && !(last_was_encoded && encoding)) { + /* output lwsp between non-encoded words */ g_string_append_len (out, start, word - start); start = word; } switch (encoding) { case 0: - out = g_string_append_len (out, word, inptr - start); + g_string_append_len (out, start, inptr - start); last_was_encoded = FALSE; break; case 1: @@ -1388,7 +1389,7 @@ camel_header_encode_string (const unsigned char *in) switch (encoding) { case 0: - out = g_string_append_len (out, start, inptr - start); + g_string_append_len (out, start, inptr - start); break; case 1: if (last_was_encoded) -- cgit v1.2.3