mail(1): Avoid closing negative file descriptors.
CID: 1008105, 1008106 MFC after: 1 week
This commit is contained in:
parent
f4f3cadf4f
commit
8808ec7c8c
@ -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);
|
||||
|
@ -68,9 +68,12 @@ findmail(char *user, char *buf, int buflen)
|
||||
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);
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user