]> diplodocus.org Git - nmh/blobdiff - uip/mhstoresbr.c
Fixed quoting of filename, expanded C-T parameter values, etc.,
[nmh] / uip / mhstoresbr.c
index fab168001004c5716260d47304cf04cb042b91a1..7b1dbd519b5c3655eed7d734b5ed4b5ac94b6d0b 100644 (file)
@@ -135,13 +135,11 @@ store_switch (CT ct)
     switch (ct->c_type) {
        case CT_MULTIPART:
            return store_multi (ct);
-           break;
 
        case CT_MESSAGE:
            switch (ct->c_subtype) {
                case MESSAGE_PARTIAL:
                    return store_partial (ct);
-                   break;
 
                case MESSAGE_EXTERNAL:
                    return store_external (ct);
@@ -149,24 +147,19 @@ store_switch (CT ct)
                case MESSAGE_RFC822:
                default:
                    return store_generic (ct);
-                   break;
            }
-           break;
 
        case CT_APPLICATION:
            return store_application (ct);
-           break;
 
        case CT_TEXT:
        case CT_AUDIO:
        case CT_IMAGE:
        case CT_VIDEO:
            return store_generic (ct);
-           break;
 
        default:
            adios (NULL, "unknown content type %d", ct->c_type);
-           break;
     }
 
     return OK; /* NOT REACHED */
@@ -569,7 +562,10 @@ store_content (CT ct, CT p)
            char *tmpfilenam, *folder;
 
            /* Store content in temporary file for now */
-           tmpfilenam = m_mktemp(invo_name, NULL, NULL);
+           if ((tmpfilenam = m_mktemp(invo_name, NULL, NULL)) == NULL) {
+               adios(NULL, "unable to create temporary file in %s",
+                     get_temp_dir());
+           }
            ct->c_storage = add (tmpfilenam, NULL);
 
            /* Get the folder name */
@@ -607,7 +603,13 @@ store_content (CT ct, CT p)
        if ((ct->c_storage = clobber_check (add (buffer, NULL))) == NULL) {
            return NOTOK;
        }
-    } /* else output filename was explicitly specified, so use it */
+    } else {
+        /* The output filename was explicitly specified, so use it. */
+       if ((ct->c_storage = clobber_check (add (ct->c_storage, NULL))) ==
+            NULL) {
+           return NOTOK;
+       }
+    }
 
 got_filename:
     /* flush the output stream */
@@ -624,7 +626,7 @@ got_filename:
      */
     if (ct->c_folder && (!is_partial || last_partial)) {
        msgnum = output_content_folder (ct->c_folder, ct->c_storage);
-       unlink (ct->c_storage);
+       (void) m_unlink (ct->c_storage);
        if (msgnum == NOTOK)
            return NOTOK;
     }