summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1996-06-25 01:02:49 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1996-06-25 01:02:49 +0000
commit4ba67c724eb49e1ef2b6b8af6d6bcda67035bb3c (patch)
treedbb5a481fb1f123c71bb0f24e06a6d218ba98354
parent8836bbccf0219ae5838892bb88af88ec8a91c6d8 (diff)
mktemp open/fdopen
-rw-r--r--usr.bin/msgs/msgs.c10
1 files 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 <sys/param.h>
#include <sys/ioctl.h>
+#include <sys/file.h>
#include <sys/stat.h>
#include <dirent.h>
#include <ctype.h>
@@ -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);