* libmisc/mail.c: Ignore the return value of puts().

* libmisc/mail.c: Prefer snprintf to sprintf, even if a small
	context indicates no issues.
This commit is contained in:
nekral-guest 2009-04-24 22:22:57 +00:00
parent 6e357e14fc
commit f28f5f3af4
2 changed files with 13 additions and 6 deletions

View File

@ -1,3 +1,9 @@
2009-04-25 Nicolas François <nicolas.francois@centraliens.net>
* libmisc/mail.c: Ignore the return value of puts().
* libmisc/mail.c: Prefer snprintf to sprintf, even if a small
context indicates no issues.
2009-04-22 Nicolas François <nicolas.francois@centraliens.net> 2009-04-22 Nicolas François <nicolas.francois@centraliens.net>
* lib/commonio.c, lib/commonio.h, lib/groupio.c, lib/groupio.h, * lib/commonio.c, lib/commonio.h, lib/groupio.c, lib/groupio.h,

View File

@ -57,13 +57,14 @@ void mailcheck (void)
mailbox = getenv ("MAILDIR"); mailbox = getenv ("MAILDIR");
if (NULL != mailbox) { if (NULL != mailbox) {
char *newmail; char *newmail;
size_t len = strlen (mailbox) + 5;
newmail = xmalloc (strlen (mailbox) + 5); newmail = xmalloc (len);
sprintf (newmail, "%s/new", mailbox); snprintf (newmail, len, "%s/new", mailbox);
if (stat (newmail, &statbuf) != -1 && statbuf.st_size != 0) { if (stat (newmail, &statbuf) != -1 && statbuf.st_size != 0) {
if (statbuf.st_mtime > statbuf.st_atime) { if (statbuf.st_mtime > statbuf.st_atime) {
free (newmail); free (newmail);
puts (_("You have new mail.")); (void) puts (_("You have new mail."));
return; return;
} }
} }
@ -77,11 +78,11 @@ void mailcheck (void)
if ( (stat (mailbox, &statbuf) == -1) if ( (stat (mailbox, &statbuf) == -1)
|| (statbuf.st_size == 0)) { || (statbuf.st_size == 0)) {
puts (_("No mail.")); (void) puts (_("No mail."));
} else if (statbuf.st_atime > statbuf.st_mtime) { } else if (statbuf.st_atime > statbuf.st_mtime) {
puts (_("You have mail.")); (void) puts (_("You have mail."));
} else { } else {
puts (_("You have new mail.")); (void) puts (_("You have new mail."));
} }
} }