From: Rob Browning <rlb@defaultvalue.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 10592@debbugs.gnu.org, 655118-forwarded@bugs.debian.org,
jmm@inutil.org, 655118@bugs.debian.org
Subject: bug#10592: Bug#655118: Please enabled hardened build flags
Date: Tue, 24 Jan 2012 20:22:52 -0600 [thread overview]
Message-ID: <8739b45xmr.fsf@trouble.defaultvalue.org> (raw)
In-Reply-To: <E1RpZWi-0006sb-8K@fencepost.gnu.org> (Eli Zaretskii's message of "Tue, 24 Jan 2012 01:06:40 -0500")
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
next prev parent reply other threads:[~2012-01-25 2:22 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20120108171359.6340.17517.reportbug@pisco.westfalen.local>
[not found] ` <20120108180151.GA919@pisco.westfalen.local>
2012-01-24 5:02 ` bug#10591: Bug#655118: Please enabled hardened build flags Rob Browning
2012-01-24 5:05 ` bug#10592: " Rob Browning
2012-01-24 6:06 ` Eli Zaretskii
2012-01-24 16:17 ` Rob Browning
2012-01-25 2:22 ` Rob Browning [this message]
2012-01-25 6:40 ` Eli Zaretskii
2012-01-26 3:13 ` Rob Browning
2012-01-26 3:25 ` Rob Browning
2012-01-31 4:22 ` Paul Eggert
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8739b45xmr.fsf@trouble.defaultvalue.org \
--to=rlb@defaultvalue.org \
--cc=10592@debbugs.gnu.org \
--cc=655118-forwarded@bugs.debian.org \
--cc=655118@bugs.debian.org \
--cc=eliz@gnu.org \
--cc=jmm@inutil.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).