Re: [gmime-devel] Issue with header decoding (continues)



Hi,

Thanks for the fix! I'll apply your patch to git.

Jeff

On 12/14/2011 01:26 PM, evil legacy wrote:
Hi, 

After more debugging, I found that the problem is when iconv (cd, NULL, NULL, &outbuf, &outleft) tries to flush the buffer to outbuf, but outbuf isn't big enough to hold it.
This little patch to the charset_convert function seems to fix this problem (works for me):

<patch>

diff --git a/gmime/gmime-utils.c b/gmime/gmime-utils.c
index ca32b61..093deee 100644
--- a/gmime/gmime-utils.c
+++ b/gmime/gmime-utils.c
@@ -1553,7 +1553,15 @@ charset_convert (iconv_t cd, const char *inbuf, size_t inleft, char **outp, size
                }
        } while (inleft > 0);
        
-       iconv (cd, NULL, NULL, &outbuf, &outleft);
+       while (iconv (cd, NULL, NULL, &outbuf, &outleft) == (size_t) -1)
+               if (errno == E2BIG) {
+                       outlen += 16;
+                       rc = (size_t) (outbuf - out);
+                       out = g_realloc (out, outlen + 1);
+                       outleft = outlen - rc;
+                       outbuf = out + rc;
+               }
+
        *outbuf++ = '\0';
        
        *outlenp = outlen;

</patch>

Best Regards
_______________________________________________ gmime-devel-list mailing list gmime-devel-list gnome org http://mail.gnome.org/mailman/listinfo/gmime-devel-list



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]