[Midnightbsd-cvs] src [11485] trunk/usr.bin/mail: more sanity checks
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Sat Jul 7 13:29:30 EDT 2018
Revision: 11485
http://svnweb.midnightbsd.org/src/?rev=11485
Author: laffer1
Date: 2018-07-07 13:29:29 -0400 (Sat, 07 Jul 2018)
Log Message:
-----------
more sanity checks
Modified Paths:
--------------
trunk/usr.bin/mail/quit.c
trunk/usr.bin/mail/send.c
Modified: trunk/usr.bin/mail/quit.c
===================================================================
--- trunk/usr.bin/mail/quit.c 2018-07-07 17:29:10 UTC (rev 11484)
+++ trunk/usr.bin/mail/quit.c 2018-07-07 17:29:29 UTC (rev 11485)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1980, 1993
* The Regents of the University of California. All rights reserved.
@@ -33,7 +34,7 @@
#endif
#endif /* not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/usr.bin/mail/quit.c 303303 2016-07-25 15:04:15Z pfg $");
#include "rcv.h"
#include <fcntl.h>
@@ -228,7 +229,8 @@
return;
}
(void)Fclose(obuf);
- (void)close(open(mbox, O_CREAT | O_TRUNC | O_WRONLY, 0600));
+ if ((fd = open(mbox, O_CREAT | O_TRUNC | O_WRONLY, 0600)) >= 0)
+ (void)close(fd);
if ((obuf = Fopen(mbox, "r+")) == NULL) {
warn("%s", mbox);
(void)Fclose(ibuf);
Modified: trunk/usr.bin/mail/send.c
===================================================================
--- trunk/usr.bin/mail/send.c 2018-07-07 17:29:10 UTC (rev 11484)
+++ trunk/usr.bin/mail/send.c 2018-07-07 17:29:29 UTC (rev 11485)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1980, 1993
* The Regents of the University of California. All rights reserved.
@@ -33,7 +34,7 @@
#endif
#endif /* not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/usr.bin/mail/send.c 313324 2017-02-06 05:34:47Z delphij $");
#include "rcv.h"
#include "extern.h"
@@ -59,7 +60,7 @@
FILE *ibuf;
char *cp, *cp2, line[LINESIZE];
int ishead, infld, ignoring, dostat, firstline;
- int c, length, prefixlen;
+ int c = 0, length, prefixlen;
/*
* Compute the prefix string, without trailing whitespace
@@ -566,8 +567,13 @@
char buf[BUFSIZ];
int i;
time_t now;
+ mode_t saved_umask;
- if ((fo = Fopen(name, "a")) == NULL) {
+ saved_umask = umask(077);
+ fo = Fopen(name, "a");
+ umask(saved_umask);
+
+ if (fo == NULL) {
warn("%s", name);
return (-1);
}
More information about the Midnightbsd-cvs
mailing list