diff options
author | Werner Koch <wk@gnupg.org> | 2016-01-07 19:05:35 +0100 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2016-01-07 19:09:16 +0100 |
commit | 8a56a38387c10c02ba0790c655dd5c1d08e4a724 (patch) | |
tree | 24ce7c5fa3c8fbb1f9fa7f17f9f12fbc327ae48a /g10 | |
parent | gpg: Fix warnings about useless assignments. (diff) | |
download | gnupg2-8a56a38387c10c02ba0790c655dd5c1d08e4a724.tar.xz gnupg2-8a56a38387c10c02ba0790c655dd5c1d08e4a724.zip |
gpg: Avoid warnings about possible NULL deref.
* g10/getkey.c (cache_public_key): Protect deref of CE which actually
can't happen.
* g10/keygen.c (quickgen_set_para): s/sprintf/snprintf/.
* g10/tofu.c (end_transaction, rollback_transaction): Allow NULL for
DB.
* g10/trustdb.c (update_min_ownertrust): Remove useless clearling of
ERR.
--
Signed-off-by: Werner Koch <wk@gnupg.org>
Diffstat (limited to 'g10')
-rw-r--r-- | g10/getkey.c | 2 | ||||
-rw-r--r-- | g10/keygen.c | 2 | ||||
-rw-r--r-- | g10/tofu.c | 6 | ||||
-rw-r--r-- | g10/trustdb.c | 1 |
4 files changed, 8 insertions, 3 deletions
diff --git a/g10/getkey.c b/g10/getkey.c index 6a1fce6da..e66be0de0 100644 --- a/g10/getkey.c +++ b/g10/getkey.c @@ -196,7 +196,7 @@ cache_public_key (PKT_public_key * pk) /* Remove the last 50% of the entries. */ for (ce = pk_cache, n = 0; ce && n < pk_cache_entries/2; n++) ce = ce->next; - if (ce != pk_cache && ce->next) + if (ce && ce != pk_cache && ce->next) { ce2 = ce->next; ce->next = NULL; diff --git a/g10/keygen.c b/g10/keygen.c index 40619ca61..94ea1262f 100644 --- a/g10/keygen.c +++ b/g10/keygen.c @@ -3395,7 +3395,7 @@ quickgen_set_para (struct para_data_s *para, int for_subkey, para = r; r = xmalloc_clear (sizeof *r + 20); r->key = for_subkey? pSUBKEYTYPE : pKEYTYPE; - sprintf (r->u.value, "%d", algo); + snprintf (r->u.value, 20, "%d", algo); r->next = para; para = r; diff --git a/g10/tofu.c b/g10/tofu.c index b7f61e98e..903f076b4 100644 --- a/g10/tofu.c +++ b/g10/tofu.c @@ -306,6 +306,9 @@ end_transaction (struct db *db, int only_batch) int rc; char *err = NULL; + if (!db) + return 0; /* Shortcut to allow for easier cleanup code. */ + if ((! batch_update || only_batch == 2) && db->batch_update) /* The batch transaction is still in open, but we left batch mode. */ @@ -353,6 +356,9 @@ rollback_transaction (struct db *db) int rc; char *err = NULL; + if (!db) + return 0; /* Shortcut to allow for easier cleanup code. */ + if (db->batch_update) /* Just undo the most recent update; don't revert any progress made by the batch transaction. */ diff --git a/g10/trustdb.c b/g10/trustdb.c index 9217dd991..cb2b5b98b 100644 --- a/g10/trustdb.c +++ b/g10/trustdb.c @@ -781,7 +781,6 @@ update_min_ownertrust (u32 *kid, unsigned int new_trust ) write_record (&rec); tdb_revalidation_mark (); do_sync (); - err = 0; } else { |