From: Ken Hornstein Date: Wed, 11 Jan 2012 19:48:45 +0000 (-0500) Subject: Fix two errors in the conversion to m_mktemp2(): X-Git-Url: http://git.marmaro.de/?a=commitdiff_plain;h=01943d78230ead5bcc568e8a87d3cdbaac1f5584;p=mmh Fix two errors in the conversion to m_mktemp2(): - There was an off-by-one error that prevented the temporary file from being created in the same directory as the message it was being linked to. - When using "dist", the assumption was that the temporary file would not exist when m_scratch was called (it wanted to link() to the name). This was solved by simply unlink()ing the temporary file after it was created. --- diff --git a/sbr/m_mktemp.c b/sbr/m_mktemp.c index aa25636..9f99119 100644 --- a/sbr/m_mktemp.c +++ b/sbr/m_mktemp.c @@ -121,7 +121,7 @@ m_mktemp2 ( /* No directory component */ return m_mktemp(pfx_in, fd_ret, fp_ret); } - n = (int)(cp-dir_in-1); /* Length of dir component */ + n = (int)(cp-dir_in); /* Length of dir component */ snprintf(buffer, sizeof(buffer), "%.*s%s", n, dir_in, pfx_in); return m_mktemp(buffer, fd_ret, fp_ret); } diff --git a/uip/send.c b/uip/send.c index 39d425f..62bf60a 100644 --- a/uip/send.c +++ b/uip/send.c @@ -426,6 +426,7 @@ go_to_it: && altmsg) { vec[vecp++] = "-dist"; distfile = getcpy (m_mktemp2 (altmsg, invo_name, NULL, NULL)); + unlink(distfile); if (link (altmsg, distfile) == NOTOK) { if (errno != EXDEV #ifdef EISREMOTE diff --git a/uip/whatnowsbr.c b/uip/whatnowsbr.c index 7db5c58..c3d93ff 100644 --- a/uip/whatnowsbr.c +++ b/uip/whatnowsbr.c @@ -1313,6 +1313,7 @@ sendit (char *sp, char **arg, char *file, int pushed) && altmsg) { vec[vecp++] = "-dist"; distfile = getcpy (m_mktemp2(altmsg, invo_name, NULL, NULL)); + unlink(distfile); if (link (altmsg, distfile) == NOTOK) adios (distfile, "unable to link %s to", altmsg); } else {