[svn] gpgme - r1434 - trunk/src
svn author wk
cvs at cvs.gnupg.org
Tue Dec 1 12:00:28 CET 2009
Author: wk
Date: 2009-12-01 12:00:27 +0100 (Tue, 01 Dec 2009)
New Revision: 1434
Modified:
trunk/src/ChangeLog
trunk/src/gpgme-tool.c
Log:
Fix segv in printf like functions.
Modified: trunk/src/ChangeLog
===================================================================
--- trunk/src/ChangeLog 2009-11-26 17:53:06 UTC (rev 1433)
+++ trunk/src/ChangeLog 2009-12-01 11:00:27 UTC (rev 1434)
@@ -1,3 +1,12 @@
+2009-12-01 Werner Koch <wk at g10code.com>
+
+ * gpgme-tool.c (GT_GCC_A_SENTINEL, GT_GCC_A_PRINTF): New.
+ (gt_write_status): Use sentinel.
+ (argp_error, log_error): Use printf attribute.
+ (argp_parse): Remove extra argument to argp_error.
+ (_gt_progress_cb, gt_get_engine_info, gt_get_keylist_mode)
+ (gt_result): Add NULL arg.
+
2009-11-26 Marcus Brinkmann <marcus at g10code.de>
* opassuan.c (opassuan_start): Allocate result structure before
Modified: trunk/src/gpgme-tool.c
===================================================================
--- trunk/src/gpgme-tool.c 2009-11-26 17:53:06 UTC (rev 1433)
+++ trunk/src/gpgme-tool.c 2009-12-01 11:00:27 UTC (rev 1434)
@@ -39,6 +39,21 @@
#include "gpgme.h"
+/* GCC attributes. */
+#if __GNUC__ >= 4
+# define GT_GCC_A_SENTINEL(a) __attribute__ ((sentinel(a)))
+#else
+# define GT_GCC_A_SENTINEL(a)
+#endif
+
+#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 5 )
+# define GT_GCC_A_PRINTF(f, a) __attribute__ ((format (printf,f,a)))
+#else
+# define GT_GCC_A_PRINTF(f, a)
+#endif
+
+
+
#ifndef HAVE_ARGP_H
/* Minimal argp implementation. */
@@ -135,6 +150,11 @@
| ARGP_HELP_DOC | ARGP_HELP_BUG_ADDR)
+void argp_error (const struct argp_state *state,
+ const char *fmt, ...) GT_GCC_A_PRINTF(2, 3);
+
+
+
char *
_argp_pname (char *name)
{
@@ -397,7 +417,7 @@
rc = argp->parser (ARGP_KEY_ARGS, NULL, &state);
if (rc == ARGP_ERR_UNKNOWN)
{
- argp_error (&state, "Too many arguments", state.argv[idx]);
+ argp_error (&state, "Too many arguments");
goto argperror;
}
if (! rc && state.next == old_next)
@@ -450,6 +470,10 @@
FILE *log_stream;
char *program_name = "gpgme-tool";
+void log_error (int status, gpg_error_t errnum,
+ const char *fmt, ...) GT_GCC_A_PRINTF(3,4);
+
+
void
log_init (void)
{
@@ -518,7 +542,8 @@
/* Forward declaration. */
-void gt_write_status (gpgme_tool_t gt, status_t status, ...);
+void gt_write_status (gpgme_tool_t gt,
+ status_t status, ...) GT_GCC_A_SENTINEL(0);
void
_gt_progress_cb (void *opaque, const char *what,
@@ -528,7 +553,7 @@
char buf[100];
snprintf (buf, sizeof (buf), "0x%02x %i %i", type, current, total);
- gt_write_status (gt, STATUS_PROGRESS, what, buf);
+ gt_write_status (gt, STATUS_PROGRESS, what, buf, NULL);
}
@@ -763,7 +788,7 @@
gt_write_status (gt, STATUS_ENGINE,
gpgme_get_protocol_name (info->protocol),
info->file_name, info->version,
- info->req_version, info->home_dir);
+ info->req_version, info->home_dir, NULL);
info = info->next;
}
return 0;
@@ -896,7 +921,7 @@
modes[idx++] = NULL;
gt_write_status (gt, STATUS_KEYLIST_MODE, modes[0], modes[1], modes[2],
- modes[3], modes[4], modes[5], modes[6]);
+ modes[3], modes[4], modes[5], modes[6], NULL);
return 0;
}
@@ -1117,7 +1142,7 @@
while (invrec)
{
gt_write_status (gt, STATUS_ENCRYPT_RESULT, "invalid_recipient",
- invrec->fpr, invrec->reason);
+ invrec->fpr, invrec->reason, NULL);
invrec = invrec->next;
}
}
More information about the Gnupg-commits
mailing list