Date: Sun, 29 Apr 2001 03:00:53 -0700 From: Kris Kennaway <kris@obsecurity.org> To: audit@FreeBSD.org Subject: RCS mkstemp fixes Message-ID: <20010429030053.A79687@xor.obsecurity.org>
next in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
Another one obtained from OpenBSD. Please review. The #ifdef
has_mktemp is misnamed, but since the RCS code seems to be
unmaintained thesedays, there's probably not much point in making it
into a separate has_mkstemp.
Kris
Index: rcsedit.c
===================================================================
RCS file: /mnt/ncvs/src/gnu/usr.bin/rcs/lib/rcsedit.c,v
retrieving revision 1.11
diff -u -r1.11 rcsedit.c
--- rcsedit.c 2000/01/11 11:55:26 1.11
+++ rcsedit.c 2001/04/29 09:53:13
@@ -1507,6 +1507,9 @@
register size_t dl;
register struct buf *bn;
register char const *name = isworkfile ? workname : RCSname;
+# if has_mktemp
+ int fd;
+# endif
dl = basefilename(name) - name;
bn = &dirtpname[newRCSdirtp_index + isworkfile];
@@ -1525,10 +1528,12 @@
catchints();
# if has_mktemp
VOID strcpy(tp, "XXXXXX");
- if (!mktemp(np) || !*np)
+ fd = mkstemp(np);
+ if (fd < 0 || !*np)
faterror("can't make temporary pathname `%.*s_%cXXXXXX'",
(int)dl, name, '0'+isworkfile
);
+ close(fd);
# else
/*
* Posix 1003.1-1990 has no reliable way
Index: rcsfnms.c
===================================================================
RCS file: /mnt/ncvs/src/gnu/usr.bin/rcs/lib/rcsfnms.c,v
retrieving revision 1.10
diff -u -r1.10 rcsfnms.c
--- rcsfnms.c 1999/08/27 23:36:46 1.10
+++ rcsfnms.c 2001/04/29 09:56:04
@@ -284,6 +284,9 @@
{
char *p;
char const *t = tpnames[n];
+# if has_mktemp
+ int fd;
+# endif
if (t)
return t;
@@ -295,10 +298,12 @@
size_t tplen = dir_useful_len(tp);
p = testalloc(tplen + 10);
VOID sprintf(p, "%.*s%cT%cXXXXXX", (int)tplen, tp, SLASH, '0'+n);
- if (!mktemp(p) || !*p)
+ fd = mkstemp(p);
+ if (fd < 0 || !*p)
faterror("can't make temporary pathname `%.*s%cT%cXXXXXX'",
(int)tplen, tp, SLASH, '0'+n
);
+ close(fd);
# else
static char tpnamebuf[TEMPNAMES][L_tmpnam];
p = tpnamebuf[n];
[-- Attachment #2 --]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.4 (FreeBSD)
Comment: For info see http://www.gnupg.org
iD8DBQE66+ZUWry0BWjoQKURAlWQAKDrDaXYxvqVpFvptA8rNiBJXaiWSgCfQrRl
ZDMvHkfbBd1bEHfKDeFet0A=
=ZodA
-----END PGP SIGNATURE-----
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010429030053.A79687>
