aboutsummaryrefslogtreecommitdiffstats
path: root/g10/keyring.c
diff options
context:
space:
mode:
authorNeal H. Walfield <[email protected]>2015-11-17 13:38:03 +0000
committerNeal H. Walfield <[email protected]>2015-11-17 13:53:05 +0000
commit58e4a492e2c8e908d16135486ed601f602f1e38d (patch)
treee45496bf0d8c6a2e890a3de6ae42772b951d58f3 /g10/keyring.c
parentgpg: Correctly handle an error. (diff)
downloadgnupg-58e4a492e2c8e908d16135486ed601f602f1e38d.tar.gz
gnupg-58e4a492e2c8e908d16135486ed601f602f1e38d.zip
gpg: Change keydb_search to not return legacy keys.
* g10/keyring.c (keyring_search): Take new argument, ignore_legacy. If set, skip any legacy keys. Update callers. * g10/keydb.c (keydb_search): Skip any legacy keys. (keydb_search_first): Don't skip legacy keys. Treat them as an error. (keydb_search_next): Likewise. (keydb_search_fpr): Likewise. * g10/export.c (do_export_stream): Likewise. * g10/getkey.c (lookup): Likewise. (have_secret_key_with_kid): Likewise. * g10/keylist.c (list_all): Likewise. (keyring_rebuild_cache): Likewise. * g10/keyserver.c (keyidlist): Likewise. * g10/trustdb.c (validate_key_list): Likewise. -- Signed-off-by: Neal H. Walfield <[email protected]>
Diffstat (limited to 'g10/keyring.c')
-rw-r--r--g10/keyring.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/g10/keyring.c b/g10/keyring.c
index cd569fd56..5ebea990b 100644
--- a/g10/keyring.c
+++ b/g10/keyring.c
@@ -429,7 +429,8 @@ keyring_get_keyblock (KEYRING_HANDLE hd, KBNODE *ret_kb)
}
else
/* Upper layer needs to handle this. */
- ;
+ {
+ }
break;
}
if (rc) {
@@ -967,7 +968,7 @@ compare_name (int mode, const char *name, const char *uid, size_t uidlen)
*/
int
keyring_search (KEYRING_HANDLE hd, KEYDB_SEARCH_DESC *desc,
- size_t ndesc, size_t *descindex)
+ size_t ndesc, size_t *descindex, int ignore_legacy)
{
int rc;
PACKET pkt;
@@ -1106,11 +1107,20 @@ keyring_search (KEYRING_HANDLE hd, KEYDB_SEARCH_DESC *desc,
if (DBG_LOOKUP)
log_debug ("%s: %ssearching from start of resource.\n",
__func__, scanned_from_start ? "" : "not ");
- while (!(rc=search_packet (hd->current.iobuf, &pkt, &offset, need_uid)))
+ while (1)
{
byte afp[MAX_FINGERPRINT_LEN];
size_t an;
+ rc = search_packet (hd->current.iobuf, &pkt, &offset, need_uid);
+ if (ignore_legacy && gpg_err_code (rc) == GPG_ERR_LEGACY_KEY)
+ {
+ free_packet (&pkt);
+ continue;
+ }
+ if (rc)
+ break;
+
if (pkt.pkttype == PKT_PUBLIC_KEY || pkt.pkttype == PKT_SECRET_KEY)
{
main_offset = offset;
@@ -1486,8 +1496,8 @@ keyring_rebuild_cache (void *token,int noisy)
for (;;)
{
- rc = keyring_search (hd, &desc, 1, NULL);
- if (rc && gpg_err_code (rc) != GPG_ERR_LEGACY_KEY)
+ rc = keyring_search (hd, &desc, 1, NULL, 0);
+ if (rc)
break; /* ready. */
desc.mode = KEYDB_SEARCH_MODE_NEXT;