Apparently, somebody started doing this, and never finished it.
I'm not totally thrilled by this, as m_scratch and m_tmpfil are *still* totally
busticated - we leak a file descriptor, and even worse, m_tmpfil unlinks the
file that mkstemp opened and returns the *string* (which is presumably then
*re*opened by the caller - introducing a hole for a symlink race after we've
taken care to avoid one inside mkstemp()....) The Right Fix for those two is
for the function to return an open file descriptor, and the callers use that.
I'm willing to chase that part down if people think it's a good idea.
--- nmh/sbr/m_scratch.c.mkstemp 2004-08-07 21:22:16.208995949 -0400
+++ nmh/sbr/m_scratch.c 2004-08-07 21:23:28.504808764 -0400
@@ -19,16 +19,11 @@ m_scratch (char *file, char *template)
static char buffer[BUFSIZ], tmpfil[BUFSIZ];
snprintf (tmpfil, sizeof(tmpfil), "%sXXXXXX", template);
-/*
- Mkstemp work postponed until later -Doug
#ifdef HAVE_MKSTEMP
mkstemp (tmpfil);
#else
-*/
mktemp (tmpfil);
-/*
#endif
-*/
/* nasty - this really means: if there is no '/' in the path */
if ((cp = r1bindex (file, '/')) == file)
strncpy (buffer, tmpfil, sizeof(buffer));
--- nmh/sbr/m_tmpfil.c.mkstemp 2004-08-07 21:23:46.369291484 -0400
+++ nmh/sbr/m_tmpfil.c 2004-08-07 21:24:08.912114981 -0400
@@ -18,15 +18,10 @@ m_tmpfil (char *template)
static char tmpfil[BUFSIZ];
snprintf (tmpfil, sizeof(tmpfil), "/tmp/%sXXXXXX", template);
-/*
- Mkstemp work postponed until later -Doug
#ifdef HAVE_MKSTEMP
unlink(mkstemp(tmpfil));
#else
-*/
unlink(mktemp(tmpfil));
-/*
#endif
-*/
return tmpfil;
}
--- nmh/uip/mshcmds.c.mkstemp 2003-10-24 16:17:39.000000000 -0400
+++ nmh/uip/mshcmds.c 2004-08-07 21:25:12.771116625 -0400
@@ -938,16 +938,11 @@ forwcmd (char **args)
/* foil search of .mh_profile */
snprintf (buf, sizeof(buf), "%sXXXXXX", invo_name);
-/*
- Mkstemp work postponed until later -Doug
#ifdef HAVE_MKSTEMP
vec[0] = (char *)mkstemp (buf);
#else
-*/
vec[0] = (char *)mktemp (buf);
-/*
#endif
-*/
vec[vecp++] = "-file";
vec[vecp] = NULL;
if (!msgp)
pgpj0eeaejmVz.pgp
Description: PGP signature
_______________________________________________
Nmh-workers mailing list
Nmh-workers(_at_)nongnu(_dot_)org
http://lists.nongnu.org/mailman/listinfo/nmh-workers