* 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.
This commit is contained in:
Werner Koch 2003-12-17 12:26:56 +00:00
parent 8ab35a7d26
commit 23fa5c9792
6 changed files with 49 additions and 35 deletions

View File

@ -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

View File

@ -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)
{

View File

@ -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;
}

View File

@ -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);

View File

@ -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;

View File

@ -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