=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/msgs/Attic/msgs.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- src/usr.bin/msgs/Attic/msgs.c 1995/10/18 08:45:50 1.1 +++ src/usr.bin/msgs/Attic/msgs.c 1996/06/25 01:02:48 1.2 @@ -76,6 +76,7 @@ #include #include +#include #include #include #include @@ -139,7 +140,6 @@ time_t t; time_t keep; -char *mktemp(); char *nxtfld(); void onintr(); void onsusp(); @@ -717,7 +717,7 @@ char *prompt; { char inch; - int n, cmsg; + int n, cmsg, fd; off_t oldpos; FILE *cpfrom, *cpto; @@ -768,8 +768,10 @@ 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);