Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 8 Jan 2000 22:10:38 -0800 (PST)
From:      Kris Kennaway <kris@hub.freebsd.org>
To:        audit@freebsd.org
Subject:   ldconfig and mkstemp
Message-ID:  <Pine.BSF.4.21.0001082151540.33985-200000@hub.freebsd.org>

next in thread | raw e-mail | index | archive | help

[-- Attachment #1 --]
This patch removes the tempfile race in ldconfig..please review

Kris

[-- Attachment #2 --]
Index: ldconfig.c
===================================================================
RCS file: /home/ncvs/src/sbin/ldconfig/ldconfig.c,v
retrieving revision 1.30
diff -u -r1.30 ldconfig.c
--- ldconfig.c	1999/08/28 00:13:21	1.30
+++ ldconfig.c	2000/01/09 05:50:09
@@ -465,15 +465,10 @@
 		errx(1, "str_index(%d) != strtab_sz(%d)", str_index, strtab_sz);
 	}
 
-	tmpfile = concat(hints_file, ".XXXXXX", "");
-	if ((tmpfile = mktemp(tmpfile)) == NULL) {
-		warn("%s", tmpfile);
-		return -1;
-	}
-
+	tmpfile = concat(hints_file, ".XXXXXXXXXX", "");
 	umask(0);	/* Create with exact permissions */
-	if ((fd = open(tmpfile, O_RDWR|O_CREAT|O_TRUNC, 0444)) == -1) {
-		warn("%s", hints_file);
+	if ((fd = mkstemp(tmpfile)) == -1) {
+		warn("%s", tmpfile);
 		return -1;
 	}
 

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0001082151540.33985-200000>