[Midnightbsd-cvs] src [11483] trunk/usr.bin/mail: check for errors.
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Sat Jul 7 13:28:54 EDT 2018
Revision: 11483
http://svnweb.midnightbsd.org/src/?rev=11483
Author: laffer1
Date: 2018-07-07 13:28:53 -0400 (Sat, 07 Jul 2018)
Log Message:
-----------
check for errors.
Modified Paths:
--------------
trunk/usr.bin/mail/v7.local.c
trunk/usr.bin/mail/vars.c
Modified: trunk/usr.bin/mail/v7.local.c
===================================================================
--- trunk/usr.bin/mail/v7.local.c 2018-07-07 17:27:08 UTC (rev 11482)
+++ trunk/usr.bin/mail/v7.local.c 2018-07-07 17:28:53 UTC (rev 11483)
@@ -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/v7.local.c 303303 2016-07-25 15:04:15Z pfg $");
/*
* Mail -- a mail program
@@ -68,9 +69,12 @@
void
demail(void)
{
+ int fd;
if (value("keep") != NULL || rm(mailname) < 0)
- (void)close(open(mailname, O_CREAT | O_TRUNC | O_WRONLY, 0600));
+ if ((fd = open(mailname, O_CREAT | O_TRUNC | O_WRONLY, 0600)) >=
+ 0)
+ (void)close(fd);
}
/*
Modified: trunk/usr.bin/mail/vars.c
===================================================================
--- trunk/usr.bin/mail/vars.c 2018-07-07 17:27:08 UTC (rev 11482)
+++ trunk/usr.bin/mail/vars.c 2018-07-07 17:28:53 UTC (rev 11483)
@@ -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/vars.c 302968 2016-07-17 18:32:33Z pfg $");
#include "rcv.h"
#include "extern.h"
@@ -56,7 +57,8 @@
h = hash(name);
vp = lookup(name);
if (vp == NULL) {
- vp = calloc(sizeof(*vp), 1);
+ if ((vp = calloc(1, sizeof(*vp))) == NULL)
+ err(1, "Out of memory");
vp->v_name = vcopy(name);
vp->v_link = variables[h];
variables[h] = vp;
More information about the Midnightbsd-cvs
mailing list