diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-06-26 03:42:14 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-06-26 03:42:14 +0000 |
commit | 2333f9633b94f25c04c44fb46b8384a969e37e07 (patch) | |
tree | 3a2d9cd632000b6366ab46574d3128d844a4acfc /usr.bin/oldrdist | |
parent | 3ed880dac0ac490038c5e826e7faabd621b3d3a0 (diff) |
open + fdopen
Diffstat (limited to 'usr.bin/oldrdist')
-rw-r--r-- | usr.bin/oldrdist/docmd.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/usr.bin/oldrdist/docmd.c b/usr.bin/oldrdist/docmd.c index 5fc534421d7..bc05fcac0c8 100644 --- a/usr.bin/oldrdist/docmd.c +++ b/usr.bin/oldrdist/docmd.c @@ -33,7 +33,7 @@ #ifndef lint /* from: static char sccsid[] = "@(#)docmd.c 8.1 (Berkeley) 6/9/93"; */ -static char *rcsid = "$Id: docmd.c,v 1.1 1996/02/03 12:11:55 dm Exp $"; +static char *rcsid = "$Id: docmd.c,v 1.2 1996/06/26 03:42:13 deraadt Exp $"; #endif /* not lint */ #include "defs.h" @@ -139,12 +139,17 @@ doarrow(filev, files, rhost, cmds) if (nflag) printf("updating host %s\n", rhost); else { + int fd; + if (setjmp(env)) goto done; signal(SIGPIPE, lostconn); if (!makeconn(rhost)) return; - if ((lfp = fopen(tempfile, "w")) == NULL) { + if ((fd = open(tempfile, O_RDWR|O_EXCL|O_CREAT, 0666)) == -1 || + (lfp = fdopen(fd, "w")) == NULL) { + if (fd != -1) + close(fd); fatal("cannot open %s\n", tempfile); exit(1); } @@ -367,7 +372,12 @@ dodcolon(filev, files, stamp, cmds) if (nflag || (options & VERIFY)) tfp = NULL; else { - if ((tfp = fopen(tempfile, "w")) == NULL) { + int fd; + + if ((fd = open(tempfile, O_RDWR|O_EXCL|O_CREAT, 0666)) == -1 || + (tfp = fdopen(fd, "w")) == NULL) { + if (fd != -1) + close(fd); error("%s: %s\n", stamp, strerror(errno)); return; } |