From owner-freebsd-audit Sun Apr 29 3: 1: 0 2001 Delivered-To: freebsd-audit@freebsd.org Received: from obsecurity.dyndns.org (adsl-63-207-60-27.dsl.lsan03.pacbell.net [63.207.60.27]) by hub.freebsd.org (Postfix) with ESMTP id D07A637B43C for ; Sun, 29 Apr 2001 03:00:53 -0700 (PDT) (envelope-from kris@obsecurity.org) Received: by obsecurity.dyndns.org (Postfix, from userid 1000) id 5DD9B66DB9; Sun, 29 Apr 2001 03:00:53 -0700 (PDT) Date: Sun, 29 Apr 2001 03:00:53 -0700 From: Kris Kennaway To: audit@FreeBSD.org Subject: RCS mkstemp fixes Message-ID: <20010429030053.A79687@xor.obsecurity.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-md5; protocol="application/pgp-signature"; boundary="xHFwDpU9dbj6ez1V" Content-Disposition: inline User-Agent: Mutt/1.2.5i Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG --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