summaryrefslogtreecommitdiff
path: root/usr.bin/msgs
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1997-04-02 08:28:02 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1997-04-02 08:28:02 +0000
commit2f0dc0ff8aafef7094acbd44ad6e470ce646b4bd (patch)
treec381e30ecd60e281c6dcdcf9db05ac53966f6870 /usr.bin/msgs
parent75817beb279737b7f604b4dba716311946ef5ac9 (diff)
use mkstemp (millert, please double check)
Diffstat (limited to 'usr.bin/msgs')
-rw-r--r--usr.bin/msgs/msgs.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/usr.bin/msgs/msgs.c b/usr.bin/msgs/msgs.c
index c84cfec5f34..2615e96f5b9 100644
--- a/usr.bin/msgs/msgs.c
+++ b/usr.bin/msgs/msgs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: msgs.c,v 1.6 1996/12/22 03:25:56 tholo Exp $ */
+/* $OpenBSD: msgs.c,v 1.7 1997/04/02 08:28:01 deraadt Exp $ */
/* $NetBSD: msgs.c,v 1.7 1995/09/28 06:57:40 tls Exp $ */
/*-
@@ -44,7 +44,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)msgs.c 8.2 (Berkeley) 4/28/95";
#else
-static char rcsid[] = "$OpenBSD: msgs.c,v 1.6 1996/12/22 03:25:56 tholo Exp $";
+static char rcsid[] = "$OpenBSD: msgs.c,v 1.7 1997/04/02 08:28:01 deraadt Exp $";
#endif
#endif /* not lint */
@@ -764,16 +764,18 @@ char *prompt;
}
else
strcpy(fname, "Messages");
+ fd = open(fname, O_RDWR|O_EXCL|O_CREAT|O_APPEND);
}
else {
strcpy(fname, _PATH_TMPFILE);
- mktemp(fname);
- snprintf(cmdbuf, sizeof(cmdbuf), _PATH_MAIL, fname);
- mailing = YES;
+ fd = mkstemp(fname);
+ if (fd != -1) {
+ snprintf(cmdbuf, sizeof(cmdbuf), _PATH_MAIL, fname);
+ mailing = YES;
+ }
}
- if ((fd = open(fname, O_RDWR|O_EXCL|O_CREAT|O_APPEND)) == -1 ||
- (cpto = fdopen(fd, "a")) == NULL) {
- if (fd == -1)
+ if (fd == -1 || (cpto = fdopen(fd, "a")) == NULL) {
+ if (fd != -1)
close(fd);
perror(fname);
mailing = NO;