bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#10592: Bug#655118: Please enabled hardened build flags


From: Rob Browning
Subject: bug#10592: Bug#655118: Please enabled hardened build flags
Date: Tue, 24 Jan 2012 20:22:52 -0600
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux)

Eli Zaretskii <eliz@gnu.org> writes:

> I think the right fix for this is to declare `error' with the
> appropriate printf attribute.  Alternatively, you could use variable
> argument lists and call vprintf instead.

Would something like this be acceptable, and if not, how would you like
to see it adjusted?  The patch changes error() to use an ANSI
declaration, and it relies on the printf format attribute:

diff --git a/lib-src/movemail.c b/lib-src/movemail.c
index 58add49..6b2fc20 100644
--- a/lib-src/movemail.c
+++ b/lib-src/movemail.c
@@ -60,6 +60,7 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 #include <sys/file.h>
 #include <stdio.h>
 #include <errno.h>
+#include <stdarg.h>
 #include <time.h>
 
 #include <getopt.h>
@@ -152,7 +153,7 @@ extern char *rindex __P((const char *, int));
 #endif
 
 void fatal ();
-void error ();
+void error (const char *template, ...) __attribute__ ((format (printf, 1, 2)));
 void pfatal_with_name ();
 void pfatal_and_delete ();
 char *concat ();
@@ -610,16 +611,13 @@ fatal (s1, s2, s3)
    are args for it or null. */
 
 void
-error (s1, s2, s3)
-     char *s1, *s2, *s3;
+error (const char *template, ...)
 {
+  va_list ap;
   fprintf (stderr, "movemail: ");
-  if (s3)
-    fprintf (stderr, s1, s2, s3);
-  else if (s2)
-    fprintf (stderr, s1, s2);
-  else
-    fprintf (stderr, s1);
+  va_start (ap, template);
+  vfprintf (stderr, template, ap);
+  va_end (ap);
   fprintf (stderr, "\n");
 }
 
@@ -733,13 +731,13 @@ popmail (mailbox, outfile, preserve, password, 
reverse_order)
   server = pop_open (hostname, user, password, POP_NO_GETPASS);
   if (! server)
     {
-      error ("Error connecting to POP server: %s", pop_error, 0);
+      error ("Error connecting to POP server: %s", pop_error);
       return EXIT_FAILURE;
     }
 
   if (pop_stat (server, &nmsgs, &nbytes))
     {
-      error ("Error getting message count from POP server: %s", pop_error, 0);
+      error ("Error getting message count from POP server: %s", pop_error);
       return EXIT_FAILURE;
     }
 
@@ -761,7 +759,7 @@ popmail (mailbox, outfile, preserve, password, 
reverse_order)
   if ((mbf = fdopen (mbfi, "wb")) == NULL)
     {
       pop_close (server);
-      error ("Error in fdopen: %s", strerror (errno), 0);
+      error ("Error in fdopen: %s", strerror (errno));
       close (mbfi);
       unlink (outfile);
       return EXIT_FAILURE;
@@ -785,7 +783,7 @@ popmail (mailbox, outfile, preserve, password, 
reverse_order)
       mbx_delimit_begin (mbf);
       if (pop_retr (server, i, mbf) != OK)
        {
-         error ("%s", Errmsg, 0);
+         error ("%s", Errmsg);
          close (mbfi);
          return EXIT_FAILURE;
        }
@@ -793,7 +791,7 @@ popmail (mailbox, outfile, preserve, password, 
reverse_order)
       fflush (mbf);
       if (ferror (mbf))
        {
-         error ("Error in fflush: %s", strerror (errno), 0);
+         error ("Error in fflush: %s", strerror (errno));
          pop_close (server);
          close (mbfi);
          return EXIT_FAILURE;
@@ -809,14 +807,14 @@ popmail (mailbox, outfile, preserve, password, 
reverse_order)
 #ifdef BSD_SYSTEM
   if (fsync (mbfi) < 0)
     {
-      error ("Error in fsync: %s", strerror (errno), 0);
+      error ("Error in fsync: %s", strerror (errno));
       return EXIT_FAILURE;
     }
 #endif
 
   if (close (mbfi) == -1)
     {
-      error ("Error in close: %s", strerror (errno), 0);
+      error ("Error in close: %s", strerror (errno));
       return EXIT_FAILURE;
     }
 
@@ -825,7 +823,7 @@ popmail (mailbox, outfile, preserve, password, 
reverse_order)
       {
        if (pop_delete (server, i))
          {
-           error ("Error from POP server: %s", pop_error, 0);
+           error ("Error from POP server: %s", pop_error);
            pop_close (server);
            return EXIT_FAILURE;
          }
@@ -833,7 +831,7 @@ popmail (mailbox, outfile, preserve, password, 
reverse_order)
 
   if (pop_quit (server))
     {
-      error ("Error from POP server: %s", pop_error, 0);
+      error ("Error from POP server: %s", pop_error);
       return EXIT_FAILURE;
     }
 
-- 
Rob Browning
rlb @defaultvalue.org and @debian.org
GPG as of 2002-11-03 14DD 432F AE39 534D B592 F9A0 25C8 D377 8C7E 73A4





reply via email to

[Prev in Thread] Current Thread [Next in Thread]