]> granicus.if.org Git - shadow/commitdiff
* libmisc/mail.c: Ignore the return value of puts().
authornekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Fri, 24 Apr 2009 22:22:57 +0000 (22:22 +0000)
committernekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Fri, 24 Apr 2009 22:22:57 +0000 (22:22 +0000)
* libmisc/mail.c: Prefer snprintf to sprintf, even if a small
context indicates no issues.

ChangeLog
libmisc/mail.c

index 07d1ca6eefb9e7745904f8ac3b20ddd029b15c03..589abdd879ab6e1fa90dd5180ce0f11cd8c4046c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
 
        * lib/commonio.c, lib/commonio.h, lib/groupio.c, lib/groupio.h,
index e75032a0882d8074f4dd7efe9b89e52324a4e743..5b70c73c351852b001aff9c3cec2b29e64197292 100644 (file)
@@ -57,13 +57,14 @@ void mailcheck (void)
        mailbox = getenv ("MAILDIR");
        if (NULL != mailbox) {
                char *newmail;
+               size_t len = strlen (mailbox) + 5;
 
-               newmail = xmalloc (strlen (mailbox) + 5);
-               sprintf (newmail, "%s/new", mailbox);
+               newmail = xmalloc (len);
+               snprintf (newmail, len, "%s/new", mailbox);
                if (stat (newmail, &statbuf) != -1 && statbuf.st_size != 0) {
                        if (statbuf.st_mtime > statbuf.st_atime) {
                                free (newmail);
-                               puts (_("You have new mail."));
+                               (void) puts (_("You have new mail."));
                                return;
                        }
                }
@@ -77,11 +78,11 @@ void mailcheck (void)
 
        if (   (stat (mailbox, &statbuf) == -1)
            || (statbuf.st_size == 0)) {
-               puts (_("No mail."));
+               (void) puts (_("No mail."));
        } else if (statbuf.st_atime > statbuf.st_mtime) {
-               puts (_("You have mail."));
+               (void) puts (_("You have mail."));
        } else {
-               puts (_("You have new mail."));
+               (void) puts (_("You have new mail."));
        }
 }