Sam Varshavchik wrote:
> . A fix for a bug caused when invalid UTF-8 octet sequence gets parsed by  
> libidn.

Thank you for adding workaround. My case seems to be fixed.

One comment from me.

--- courier-imap-4.12.0/rfc822/rfc2047u.c
+++ courier-imap-4.12.20130220/rfc822/rfc2047u.c
@@ -312,41 +312,57 @@ int rfc822_display_addr_str(const char *
                            void *ptr)
 {
        const char *p;

        p=strchr(tok,'@');

        if (!p)
                p=tok;
        else
                ++p;

        if (chset != NULL)
        {
                int err=0;
                char *utf8_ptr;

                if (p > tok)
                        (*print_func)(tok, p-tok, ptr);

 #if LIBIDN
-               err=idna_to_unicode_8z8z(p, &utf8_ptr, 0);
+               /*
+               ** Invalid UTF-8 can make libidn go off the deep end. Add
+               ** padding as a workaround.
+               */
+               {
+                       size_t s=strlen(p)+16;
+                       char *cpy=malloc(s);
+
+                       if (!cpy)
+                               return 0;

Don't we want to fall back to utf8_ptr=0 rather than "return 0" because we
fall back to utf8_ptr=0 if idna_to_unicode_8z8z() did not return IDNA_SUCCESS.

+                       memset(cpy, 0, s);
+                       strcpy(cpy, p);
+
+                       err=idna_to_unicode_8z8z(cpy, &utf8_ptr, 0);
+                       free(cpy);
+               }
+
                if (err != IDNA_SUCCESS)
                        utf8_ptr=0;
 #else
                utf8_ptr=0;
 #endif

                if (utf8_ptr == 0)
                        (*print_func)(p, strlen(p), ptr);
                else
                {
                        char *q=libmail_u_convert_tobuf(utf8_ptr,
                                                        "utf-8",
                                                        chset, NULL);
                        if (q)
                        {
                                (*print_func)(q, strlen(q), ptr);
                                free(q);
                        }
                        else
                        {

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb
_______________________________________________
Courier-imap mailing list
[email protected]
Unsubscribe: https://lists.sourceforge.net/lists/listinfo/courier-imap

Reply via email to