From 01943d78230ead5bcc568e8a87d3cdbaac1f5584 Mon Sep 17 00:00:00 2001 From: Ken Hornstein Date: Wed, 11 Jan 2012 14:48:45 -0500 Subject: [PATCH] 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. --- sbr/m_mktemp.c | 2 +- uip/send.c | 1 + uip/whatnowsbr.c | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) 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 { -- 1.7.10.4