Date: Mon, 25 Jul 2016 15:04:15 +0000 (UTC) From: "Pedro F. Giffuni" <pfg@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r303303 - stable/10/usr.bin/mail Message-ID: <201607251504.u6PF4FFd058145@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: pfg Date: Mon Jul 25 15:04:15 2016 New Revision: 303303 URL: https://svnweb.freebsd.org/changeset/base/303303 Log: MFC r302911: mail(1): Avoid closing negative file descriptors. CID: 1008105, 1008106 Modified: stable/10/usr.bin/mail/quit.c stable/10/usr.bin/mail/v7.local.c Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.bin/mail/quit.c ============================================================================== --- stable/10/usr.bin/mail/quit.c Mon Jul 25 15:03:14 2016 (r303302) +++ stable/10/usr.bin/mail/quit.c Mon Jul 25 15:04:15 2016 (r303303) @@ -228,7 +228,8 @@ quit(void) 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: stable/10/usr.bin/mail/v7.local.c ============================================================================== --- stable/10/usr.bin/mail/v7.local.c Mon Jul 25 15:03:14 2016 (r303302) +++ stable/10/usr.bin/mail/v7.local.c Mon Jul 25 15:04:15 2016 (r303303) @@ -68,9 +68,12 @@ findmail(char *user, char *buf, int bufl 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); } /*
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201607251504.u6PF4FFd058145>