diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 1996-07-30 20:34:56 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 1996-07-30 20:34:56 +0000 |
commit | fae6830ae508ba9f69d1147f0e3ac04fa23645b1 (patch) | |
tree | 232411b5bd148d491ddf49ef6e6458b756e341d2 | |
parent | 9f1ce502291b1ef4a0674512422a65282086574b (diff) |
use mkstemp() instead of mktemp() to close temp file race.
-rw-r--r-- | usr.bin/oldrdist/docmd.c | 8 | ||||
-rw-r--r-- | usr.bin/oldrdist/main.c | 5 |
2 files changed, 6 insertions, 7 deletions
diff --git a/usr.bin/oldrdist/docmd.c b/usr.bin/oldrdist/docmd.c index e2e28a9645c..4a179792b46 100644 --- a/usr.bin/oldrdist/docmd.c +++ b/usr.bin/oldrdist/docmd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: docmd.c,v 1.5 1996/07/25 05:13:47 millert Exp $ */ +/* $OpenBSD: docmd.c,v 1.6 1996/07/30 20:34:54 millert Exp $ */ /* * Copyright (c) 1983, 1993 @@ -35,7 +35,7 @@ #ifndef lint /* from: static char sccsid[] = "@(#)docmd.c 8.1 (Berkeley) 6/9/93"; */ -static char *rcsid = "$OpenBSD: docmd.c,v 1.5 1996/07/25 05:13:47 millert Exp $"; +static char *rcsid = "$OpenBSD: docmd.c,v 1.6 1996/07/30 20:34:54 millert Exp $"; #endif /* not lint */ #include "defs.h" @@ -148,7 +148,7 @@ doarrow(filev, files, rhost, cmds) signal(SIGPIPE, lostconn); if (!makeconn(rhost)) return; - if ((fd = open(tempfile, O_RDWR|O_EXCL|O_CREAT, 0666)) == -1 || + if ((fd = mkstemp(tempfile)) == -1 || (lfp = fdopen(fd, "w")) == NULL) { if (fd != -1) close(fd); @@ -399,7 +399,7 @@ dodcolon(filev, files, stamp, cmds) else { int fd; - if ((fd = open(tempfile, O_RDWR|O_EXCL|O_CREAT, 0666)) == -1 || + if ((fd = mkstemp(tempfile)) == -1 || (tfp = fdopen(fd, "w")) == NULL) { if (fd != -1) close(fd); diff --git a/usr.bin/oldrdist/main.c b/usr.bin/oldrdist/main.c index ab1679d6a17..cb6960b15b4 100644 --- a/usr.bin/oldrdist/main.c +++ b/usr.bin/oldrdist/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.3 1996/07/19 21:57:33 millert Exp $ */ +/* $OpenBSD: main.c,v 1.4 1996/07/30 20:34:55 millert Exp $ */ /* * Copyright (c) 1983, 1993 @@ -41,7 +41,7 @@ static char copyright[] = #ifndef lint /* from: static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/9/93"; */ -static char *rcsid = "$OpenBSD: main.c,v 1.3 1996/07/19 21:57:33 millert Exp $"; +static char *rcsid = "$OpenBSD: main.c,v 1.4 1996/07/30 20:34:55 millert Exp $"; #endif /* not lint */ #include "defs.h" @@ -197,7 +197,6 @@ main(argc, argv) exit(1); } #endif /* DIRECT_RCMD */ - mktemp(tempfile); if (iamremote) { server(); |