From 23fa5c97929a1206aaa662e2833eaec629d95c57 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Wed, 17 Dec 2003 12:26:56 +0000 Subject: * card-util.c (print_name): Fixed bad format string usage. (print_isoname): Ditto. * trustdb.c (check_regexp): s/exp/expr/. * keyedit.c (trustsig_prompt): Removed a "> 255" term; it is always false due to the data type. * passphrase.c (agent_get_passphrase): Use xasprintf and avoid non-literal format strings. * tdbio.c (upd_hashtable, drop_from_hashtable, lookup_hashtable): Fixed log_error format string bugs. Kudos to the now working gcc-3.3 -Wformat-nonliteral and Florian Weimer's investigations in gnupg 1.2.3. --- g10/passphrase.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'g10/passphrase.c') diff --git a/g10/passphrase.c b/g10/passphrase.c index ac7e71591..0db9404b9 100644 --- a/g10/passphrase.c +++ b/g10/passphrase.c @@ -673,32 +673,26 @@ agent_get_passphrase ( u32 *keyid, int mode, const char *tryagain_text, const char *algo_name = gcry_pk_algo_name ( pk->pubkey_algo ); const char *timestr; char *maink; - const char *fmtstr; if ( !algo_name ) algo_name = "?"; - fmtstr = _(" (main key ID %08lX)"); - maink = xmalloc ( strlen (fmtstr) + 20 ); if( keyid[2] && keyid[3] && keyid[0] != keyid[2] && keyid[1] != keyid[3] ) - sprintf( maink, fmtstr, (ulong)keyid[3] ); + maink = xasprintf ( _(" (main key ID %08lX)"), (ulong)keyid[3] ); else - *maink = 0; + maink = NULL; uid = get_user_id ( keyid, &uidlen ); timestr = strtimestamp (pk->timestamp); - fmtstr = _("You need a passphrase to unlock the" + atext = xasprintf ( + _("You need a passphrase to unlock the" " secret key for user:\n" "\"%.*s\"\n" - "%u-bit %s key, ID %08lX, created %s%s\n" ); - atext = xmalloc ( 100 + strlen (fmtstr) - + uidlen + 15 + strlen(algo_name) + 8 - + strlen (timestr) + strlen (maink) ); - sprintf (atext, fmtstr, + "%u-bit %s key, ID %08lX, created %s%s\n" ), uidlen, uid, nbits_from_pk (pk), algo_name, (ulong)keyid[1], timestr, - maink ); + maink?maink:"" ); xfree (uid); xfree (maink); -- cgit v1.2.3