mhshow: Fixed segfault. (Care that c_charset is set.)
[mmh] / uip / mhshowsbr.c
index 4a7fc0c..4f67d32 100644 (file)
@@ -22,7 +22,6 @@ extern int debugsw;
 
 int nolist   = 0;
 char *formsw = NULL;
-pid_t xpid = 0;
 
 
 /* mhparse.c */
@@ -100,9 +99,6 @@ show_all_messages(CT *cts)
 static void
 show_single_message(CT ct, char *form)
 {
-       sigset_t set, oset;
-       int status;
-
        /*
        ** Allow user executable bit so that temporary directories created by
        ** the viewer (e.g., lynx) are going to be accessible
@@ -115,8 +111,6 @@ show_single_message(CT ct, char *form)
        */
        if (form)
                DisplayMsgHeader(ct, form);
-       else
-               xpid = 0;
 
        /* Show the body of the message */
        show_switch(ct, 0);
@@ -128,23 +122,6 @@ show_single_message(CT ct, char *form)
        if (ct->c_ceclosefnx)
                (*ct->c_ceclosefnx) (ct);
 
-       /* block a few signals */
-       sigemptyset(&set);
-       sigaddset(&set, SIGHUP);
-       sigaddset(&set, SIGINT);
-       sigaddset(&set, SIGQUIT);
-       sigaddset(&set, SIGTERM);
-       sigprocmask(SIG_BLOCK, &set, &oset);
-
-       while (wait(&status) != NOTOK) {
-               pidcheck(status);
-               continue;
-       }
-
-       /* reset the signal mask */
-       sigprocmask(SIG_SETMASK, &oset, &set);
-
-       xpid = 0;
        flush_errors();
 }
 
@@ -182,7 +159,7 @@ DisplayMsgHeader(CT ct, char *form)
                /* NOTREACHED */
 
        default:
-               xpid = child_id;
+               pidcheck(pidwait(child_id, NOTOK));
                break;
        }
 }
@@ -335,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':
@@ -459,11 +435,6 @@ show_content_aux2(CT ct, int alternate, char *cracked,
 {
        pid_t child_id;
 
-       if (xpid) {
-               pidcheck(pidwait(xpid, NOTOK));
-               xpid = 0;
-       }
-
        if (debugsw || cracked) {
                fflush(stdout);
 
@@ -541,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 {
@@ -742,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':