mhshow: Fixed segfault. (Care that c_charset is set.)
authormarkus schnalke <meillo@marmaro.de>
Sat, 14 Apr 2012 20:09:52 +0000 (22:09 +0200)
committermarkus schnalke <meillo@marmaro.de>
Sat, 14 Apr 2012 20:09:52 +0000 (22:09 +0200)
uip/mhshowsbr.c

index 3bcf84f..4f67d32 100644 (file)
@@ -312,9 +312,8 @@ show_content_aux(CT ct, int alternate, char *cp, char *cracked)
 
                        case 'c':
                                /* insert charset */
-                               if (ct->c_charset) {
-                                       strncpy(bp, ct->c_charset, buflen);
-                               }
+                               strncpy(bp, ct->c_charset ? ct->c_charset :
+                                               "US-ASCII", buflen);
                                break;
 
                        case 'd':
@@ -513,7 +512,8 @@ show_text(CT ct, int alternate)
        ** if it is not a text part of a multipart/alternative
        */
        if (!alternate || ct->c_subtype == TEXT_PLAIN) {
-               if (!check_charset(ct->c_charset, strlen(ct->c_charset))) {
+               if (ct->c_charset && !check_charset(ct->c_charset,
+                               strlen(ct->c_charset))) {
                        snprintf(buffer, sizeof(buffer), "%%liconv -f '%s'",
                                        ct->c_charset);
                } else {
@@ -714,9 +714,8 @@ show_multi_aux(CT ct, int alternate, char *cp)
 
                        case 'c':
                                /* insert charset */
-                               if (ct->c_charset) {
-                                       strncpy(bp, ct->c_charset, buflen);
-                               }
+                               strncpy(bp, ct->c_charset ? ct->c_charset :
+                                               "US-ASCII", buflen);
                                break;
 
                        case 'd':