summaryrefslogtreecommitdiffstats
path: root/g10
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2003-12-17 13:26:56 +0100
committerWerner Koch <wk@gnupg.org>2003-12-17 13:26:56 +0100
commit23fa5c97929a1206aaa662e2833eaec629d95c57 (patch)
tree5839ee2a1ea7224a0ae1175f4047e1a16d551da5 /g10
parent* gettime.c (asctimestamp): Add a note on a non-avoidable gcc warning. (diff)
downloadgnupg2-23fa5c97929a1206aaa662e2833eaec629d95c57.tar.xz
gnupg2-23fa5c97929a1206aaa662e2833eaec629d95c57.zip
* 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.
Diffstat (limited to 'g10')
-rw-r--r--g10/ChangeLog18
-rw-r--r--g10/card-util.c5
-rw-r--r--g10/keyedit.c4
-rw-r--r--g10/passphrase.c18
-rw-r--r--g10/tdbio.c31
-rw-r--r--g10/trustdb.c8
6 files changed, 49 insertions, 35 deletions
diff --git a/g10/ChangeLog b/g10/ChangeLog
index 849e6931a..f3399b510 100644
--- a/g10/ChangeLog
+++ b/g10/ChangeLog
@@ -1,3 +1,21 @@
+2003-12-17 Werner Koch <wk@gnupg.org>
+
+ * 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.
+
2003-12-15 Werner Koch <wk@gnupg.org>
* seckey-cert.c (protect_secret_key): Use gry_create_nonce for the
diff --git a/g10/card-util.c b/g10/card-util.c
index de445b796..c40cfd84d 100644
--- a/g10/card-util.c
+++ b/g10/card-util.c
@@ -169,8 +169,7 @@ print_sha1_fpr_colon (FILE *fp, const unsigned char *fpr)
static void
print_name (FILE *fp, const char *text, const char *name)
{
- tty_fprintf (fp, text);
-
+ tty_fprintf (fp, "%s", text);
/* FIXME: tty_printf_utf8_string2 eats everything after and
including an @ - e.g. when printing an url. */
@@ -192,7 +191,7 @@ print_isoname (FILE *fp, const char *text, const char *tag, const char *name)
if (opt.with_colons)
fprintf (fp, "%s:", tag);
else
- tty_fprintf (fp, text);
+ tty_fprintf (fp, "%s", text);
if (name && *name)
{
diff --git a/g10/keyedit.c b/g10/keyedit.c
index bd41772fd..4da174e3c 100644
--- a/g10/keyedit.c
+++ b/g10/keyedit.c
@@ -298,7 +298,7 @@ sign_mk_attrib( PKT_signature *sig, void *opaque )
}
static void
-trustsig_prompt(byte *trust_value,byte *trust_depth,char **regexp)
+trustsig_prompt(byte *trust_value, byte *trust_depth, char **regexp)
{
char *p;
@@ -344,7 +344,7 @@ trustsig_prompt(byte *trust_value,byte *trust_depth,char **regexp)
cpr_kill_prompt();
*trust_depth=atoi(p);
xfree (p);
- if(*trust_depth<1 || *trust_depth>255)
+ if(*trust_depth < 1 )
*trust_depth=0;
}
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);
diff --git a/g10/tdbio.c b/g10/tdbio.c
index d1b5ed32a..75687a3b0 100644
--- a/g10/tdbio.c
+++ b/g10/tdbio.c
@@ -782,9 +782,9 @@ upd_hashtable( ulong table, byte *key, int keylen, ulong newrecnum )
hashrec += msb / ITEMS_PER_HTBL_RECORD;
rc = tdbio_read_record( hashrec, &rec, RECTYPE_HTBL );
if( rc ) {
- log_error( db_name, "upd_hashtable: read failed: %s\n",
- gpg_strerror (rc) );
- return rc;
+ log_error ("upd_hashtable in `%s': read failed: %s\n", db_name,
+ gpg_strerror (rc) );
+ return rc;
}
item = rec.r.htbl.item[msb % ITEMS_PER_HTBL_RECORD];
@@ -792,8 +792,8 @@ upd_hashtable( ulong table, byte *key, int keylen, ulong newrecnum )
rec.r.htbl.item[msb % ITEMS_PER_HTBL_RECORD] = newrecnum;
rc = tdbio_write_record( &rec );
if( rc ) {
- log_error( db_name, "upd_hashtable: write htbl failed: %s\n",
- gpg_strerror (rc) );
+ log_error ("upd_hashtable in `%s': write htbl failed: %s\n",
+ db_name, gpg_strerror (rc) );
return rc;
}
}
@@ -931,8 +931,8 @@ drop_from_hashtable( ulong table, byte *key, int keylen, ulong recnum )
hashrec += msb / ITEMS_PER_HTBL_RECORD;
rc = tdbio_read_record( hashrec, &rec, RECTYPE_HTBL );
if( rc ) {
- log_error( db_name, "drop_from_hashtable: read failed: %s\n",
- gpg_strerror (rc) );
+ log_error ("drop_from_hashtable `%s': read failed: %s\n",
+ db_name, gpg_strerror (rc) );
return rc;
}
@@ -944,8 +944,8 @@ drop_from_hashtable( ulong table, byte *key, int keylen, ulong recnum )
rec.r.htbl.item[msb % ITEMS_PER_HTBL_RECORD] = 0;
rc = tdbio_write_record( &rec );
if( rc )
- log_error( db_name, "drop_from_hashtable: write htbl failed: %s\n",
- gpg_strerror (rc) );
+ log_error ("drop_from_hashtable `%s': write htbl failed: %s\n",
+ db_name, gpg_strerror (rc) );
return rc;
}
@@ -973,8 +973,9 @@ drop_from_hashtable( ulong table, byte *key, int keylen, ulong recnum )
rec.r.hlst.rnum[i] = 0; /* drop */
rc = tdbio_write_record( &rec );
if( rc )
- log_error( db_name, "drop_from_hashtable: write htbl failed: %s\n",
- gpg_strerror (rc) );
+ log_error ("drop_from_hashtable `%s': "
+ "write htbl failed: %s\n",
+ db_name, gpg_strerror (rc) );
return rc;
}
}
@@ -1020,7 +1021,8 @@ lookup_hashtable( ulong table, const byte *key, size_t keylen,
hashrec += msb / ITEMS_PER_HTBL_RECORD;
rc = tdbio_read_record( hashrec, rec, RECTYPE_HTBL );
if( rc ) {
- log_error( db_name, "lookup_hashtable failed: %s\n", gpg_strerror (rc) );
+ log_error ("lookup_hashtable in `%s' failed: %s\n",
+ db_name, gpg_strerror (rc) );
return rc;
}
@@ -1030,14 +1032,15 @@ lookup_hashtable( ulong table, const byte *key, size_t keylen,
rc = tdbio_read_record( item, rec, 0 );
if( rc ) {
- log_error( db_name, "hashtable read failed: %s\n", gpg_strerror (rc) );
+ log_error ("hashtable `%s' read failed: %s\n",
+ db_name, gpg_strerror (rc) );
return rc;
}
if( rec->rectype == RECTYPE_HTBL ) {
hashrec = item;
level++;
if( level >= keylen ) {
- log_error( db_name, "hashtable has invalid indirections\n");
+ log_error ("hashtable `%s' has invalid indirections\n", db_name);
return GPG_ERR_TRUSTDB;
}
goto next_level;
diff --git a/g10/trustdb.c b/g10/trustdb.c
index 864334f4f..b3a2b369e 100644
--- a/g10/trustdb.c
+++ b/g10/trustdb.c
@@ -1539,19 +1539,19 @@ mark_usable_uid_certs (KBNODE keyblock, KBNODE uidnode,
signature. Returns 1 for match, and 0 for no match or regex
error. */
static int
-check_regexp(const char *exp,const char *string)
+check_regexp(const char *expr,const char *string)
{
#ifdef DISABLE_REGEX
/* When DISABLE_REGEX is defined, assume all regexps do not
match. */
return 0;
#elif defined(__riscos__)
- return riscos_check_regexp(exp, string, DBG_TRUST);
+ return riscos_check_regexp(expr, string, DBG_TRUST);
#else
int ret;
regex_t pat;
- if(regcomp(&pat,exp,REG_ICASE|REG_NOSUB|REG_EXTENDED)!=0)
+ if(regcomp(&pat,expr,REG_ICASE|REG_NOSUB|REG_EXTENDED)!=0)
return 0;
ret=regexec(&pat,string,0,NULL,0);
@@ -1559,7 +1559,7 @@ check_regexp(const char *exp,const char *string)
regfree(&pat);
if(DBG_TRUST)
- log_debug("regexp \"%s\" on \"%s\": %s\n",exp,string,ret==0?"YES":"NO");
+ log_debug("regexp \"%s\" on \"%s\": %s\n",expr,string,ret==0?"YES":"NO");
return (ret==0);
#endif