From: David Levine Date: Sat, 25 Jan 2014 03:10:03 +0000 (-0600) Subject: Removed 3 renames of temporary files in mhparse.c. They added X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/fb19d1fe7b522a05366f513387fef4456c336de8?ds=inline;hp=-c Removed 3 renames of temporary files in mhparse.c. They added unnecessary filename extensions to the temp files. They weren't good from a security standpoint and added a failure mode. --- fb19d1fe7b522a05366f513387fef4456c336de8 diff --git a/uip/mhparse.c b/uip/mhparse.c index 9489a8e4..58f3a81c 100644 --- a/uip/mhparse.c +++ b/uip/mhparse.c @@ -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); } }