aboutsummaryrefslogtreecommitdiffstats
path: root/g10/keyring.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2015-12-03 11:18:32 +0000
committerWerner Koch <[email protected]>2015-12-03 11:18:32 +0000
commita28ac99efead8be73ea1704abe1611ccc4811c54 (patch)
treec1370b2f8f80e8f3280d89b30142753e4694923f /g10/keyring.c
parentgpg: Change some error messages. (diff)
downloadgnupg-a28ac99efead8be73ea1704abe1611ccc4811c54.tar.gz
gnupg-a28ac99efead8be73ea1704abe1611ccc4811c54.zip
gpg: Take care of keydb_new returning NULL.
* g10/keydb.c (keydb_new): Print an error message if needed. Also use xtrycalloc because we return an error anyway. * g10/delkey.c (do_delete_key): Handle error retruned by keydb_new. * g10/export.c (do_export_stream): Ditto. * g10/getkey.c (get_pubkey): Ditto. (get_pubkey_fast): Ditto. (get_pubkeyblock): Ditto. (get_seckey): Ditto. (key_byname): Ditto. (get_pubkey_byfprint): Ditto. (get_pubkey_byfprint_fast): Ditto. (parse_def_secret_key): Ditto. (have_secret_key_with_kid): Ditto. * g10/import.c (import_one): Ditto. (import_revoke_cert): Ditto. * g10/keyedit.c (keyedit_quick_adduid): Ditto. * g10/keygen.c (quick_generate_keypair): Ditto. (do_generate_keypair): Ditto. * g10/trustdb.c (validate_keys): Ditto. * g10/keyserver.c (keyidlist): Ditto. * g10/revoke.c (gen_desig_revoke): Ditto. (gen_revoke): Ditto. * g10/gpg.c (check_user_ids): Ditto. (main): Do not print an error message for keydb_new error. * g10/keylist.c (list_all): Use actual error code returned by keydb_new. * g10/t-keydb-get-keyblock.c (do_test): Abort on keydb_new error. * g10/t-keydb.c (do_test): Ditto. * g10/keyring.c (keyring_new): Actually return an error so that the existing keydb_new error checking makes sense for a keyring resource. (keyring_rebuild_cache): Take care of keyring_new returning an error. -- Commit 04a6b903 changed keydb_new to return an error. However the error was not checked at most places which we fix with this patch. To make things easier keydb_new prints an error message itself. Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'g10/keyring.c')
-rw-r--r--g10/keyring.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/g10/keyring.c b/g10/keyring.c
index cf67eb0cd..6ba5202ac 100644
--- a/g10/keyring.c
+++ b/g10/keyring.c
@@ -250,7 +250,7 @@ keyring_is_writable (void *token)
/* Create a new handle for the resource associated with TOKEN.
-
+ On error NULL is returned and ERRNO is set.
The returned handle must be released using keyring_release (). */
KEYRING_HANDLE
keyring_new (void *token)
@@ -260,7 +260,9 @@ keyring_new (void *token)
assert (resource);
- hd = xmalloc_clear (sizeof *hd);
+ hd = xtrycalloc (1, sizeof *hd);
+ if (!hd)
+ return hd;
hd->resource = resource;
active_handles++;
return hd;
@@ -1487,6 +1489,8 @@ keyring_rebuild_cache (void *token,int noisy)
ulong count = 0, sigcount = 0;
hd = keyring_new (token);
+ if (!hd)
+ return gpg_error_from_syserror ();
memset (&desc, 0, sizeof desc);
desc.mode = KEYDB_SEARCH_MODE_FIRST;