Skip site navigation (1)Skip section navigation (2)
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

--xHFwDpU9dbj6ez1V
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

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
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
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 =3D isworkfile ? workname : RCSname;
+#	if has_mktemp
+	int fd;
+#	endif
=20
 	dl =3D basefilename(name) - name;
 	bn =3D &dirtpname[newRCSdirtp_index + isworkfile];
@@ -1525,10 +1528,12 @@
 	catchints();
 #	if has_mktemp
 		VOID strcpy(tp, "XXXXXX");
-		if (!mktemp(np) || !*np)
+		fd =3D 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
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
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 =3D tpnames[n];
+#	if has_mktemp
+	int fd;
+#	endif
=20
 	if (t)
 		return t;
@@ -295,10 +298,12 @@
 	    size_t tplen =3D dir_useful_len(tp);
 	    p =3D testalloc(tplen + 10);
 	    VOID sprintf(p, "%.*s%cT%cXXXXXX", (int)tplen, tp, SLASH, '0'+n);
-	    if (!mktemp(p) || !*p)
+	    fd =3D 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 =3D tpnamebuf[n];


--xHFwDpU9dbj6ez1V
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.4 (FreeBSD)
Comment: For info see http://www.gnupg.org

iD8DBQE66+ZUWry0BWjoQKURAlWQAKDrDaXYxvqVpFvptA8rNiBJXaiWSgCfQrRl
ZDMvHkfbBd1bEHfKDeFet0A=
=ZodA
-----END PGP SIGNATURE-----

--xHFwDpU9dbj6ez1V--

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-audit" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010429030053.A79687>