From 4ba67c724eb49e1ef2b6b8af6d6bcda67035bb3c Mon Sep 17 00:00:00 2001 From: Theo de Raadt Date: Tue, 25 Jun 1996 01:02:49 +0000 Subject: mktemp open/fdopen --- usr.bin/msgs/msgs.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/usr.bin/msgs/msgs.c b/usr.bin/msgs/msgs.c index 67c4637ebb1..0c1d73ef49f 100644 --- a/usr.bin/msgs/msgs.c +++ b/usr.bin/msgs/msgs.c @@ -76,6 +76,7 @@ static char rcsid[] = "$NetBSD: msgs.c,v 1.7 1995/09/28 06:57:40 tls Exp $"; #include #include +#include #include #include #include @@ -139,7 +140,6 @@ int Lpp = 0; time_t t; time_t keep; -char *mktemp(); char *nxtfld(); void onintr(); void onsusp(); @@ -717,7 +717,7 @@ ask(prompt) char *prompt; { char inch; - int n, cmsg; + int n, cmsg, fd; off_t oldpos; FILE *cpfrom, *cpto; @@ -768,8 +768,10 @@ char *prompt; sprintf(cmdbuf, _PATH_MAIL, fname); mailing = YES; } - cpto = fopen(fname, "a"); - if (!cpto) { + if ((fd = open(fname, O_RDWR|O_EXCL|O_CREAT|O_APPEND)) == -1 || + (cpto = fdopen(fd, "a")) == NULL) { + if (fd == -1) + close(fd); perror(fname); mailing = NO; fseek(newmsg, oldpos, 0); -- cgit v1.2.3