]> diplodocus.org Git - nmh/commitdiff
Removed 3 renames of temporary files in mhparse.c. They added
authorDavid Levine <levinedl@acm.org>
Sat, 25 Jan 2014 03:10:03 +0000 (21:10 -0600)
committerDavid Levine <levinedl@acm.org>
Sat, 25 Jan 2014 03:10:03 +0000 (21:10 -0600)
unnecessary filename extensions to the temp files.  They weren't good
from a security standpoint and added a failure mode.

uip/mhparse.c

index 9489a8e4c01840ac64bb3c8dc459998954ecd0e7..58f3a81c7b5d0cefa435ba0ca4178e59ebde288b 100644 (file)
@@ -1669,17 +1669,7 @@ openBase64 (CT ct, char **file)
         cp = context_find (buffer);
     }
     if (cp != NULL && *cp != '\0') {
-        if (ce->ce_unlink) {
-            /* Temporary file already exists, so we rename to
-               version with extension. */
-            char *file_org = strdup(ce->ce_file);
-            ce->ce_file = add (cp, ce->ce_file);
-            if (rename(file_org, ce->ce_file)) {
-                adios (ce->ce_file, "unable to rename %s to ", file_org);
-            }
-            free(file_org);
-
-        } else {
+        if (! ce->ce_unlink) {
             ce->ce_file = add (cp, ce->ce_file);
         }
     }
@@ -1908,17 +1898,7 @@ openQuoted (CT ct, char **file)
         cp = context_find (buffer);
     }
     if (cp != NULL && *cp != '\0') {
-        if (ce->ce_unlink) {
-            /* Temporary file already exists, so we rename to
-               version with extension. */
-            char *file_org = strdup(ce->ce_file);
-            ce->ce_file = add (cp, ce->ce_file);
-            if (rename(file_org, ce->ce_file)) {
-                adios (ce->ce_file, "unable to rename %s to ", file_org);
-            }
-            free(file_org);
-
-        } else {
+        if (! ce->ce_unlink) {
             ce->ce_file = add (cp, ce->ce_file);
         }
     }
@@ -2137,17 +2117,7 @@ open7Bit (CT ct, char **file)
         cp = context_find (buffer);
     }
     if (cp != NULL && *cp != '\0') {
-        if (ce->ce_unlink) {
-            /* Temporary file already exists, so we rename to
-               version with extension. */
-            char *file_org = strdup(ce->ce_file);
-            ce->ce_file = add (cp, ce->ce_file);
-            if (rename(file_org, ce->ce_file)) {
-                adios (ce->ce_file, "unable to rename %s to ", file_org);
-            }
-            free(file_org);
-
-        } else {
+        if (! ce->ce_unlink) {
             ce->ce_file = add (cp, ce->ce_file);
         }
     }