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); } /* _______________________________________________ svn-src-stable-10@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10 To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"