diff options
author | Werner Koch <wk@gnupg.org> | 2014-10-09 21:01:49 +0200 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2014-10-09 21:01:49 +0200 |
commit | 2ca90f78cee91c43b8d538d1cb92728f8e1452d5 (patch) | |
tree | 2690fc51434a88b781e8efa836c72d51215fc42d /kbx | |
parent | gpg: Sync keylist output and warning messages. (diff) | |
download | gnupg2-2ca90f78cee91c43b8d538d1cb92728f8e1452d5.tar.xz gnupg2-2ca90f78cee91c43b8d538d1cb92728f8e1452d5.zip |
gpg: Skip overlong keys and a print a warning.
* kbx/keybox-search.c (keybox_search): Add arg r_skipped and skip too
long blobs.
* sm/keydb.c (keydb_search): Call keybox_search with a dummy param.
* g10/keydb.c (struct keydb_handle): Add field skipped_long_blobs.
(keydb_search_reset): Reset that field.
(keydb_search): Update that field.
(keydb_get_skipped_counter): New.
* g10/keylist.c (list_all): Print count of skipped keys.
Signed-off-by: Werner Koch <wk@gnupg.org>
Diffstat (limited to 'kbx')
-rw-r--r-- | kbx/keybox-search.c | 13 | ||||
-rw-r--r-- | kbx/keybox.h | 2 |
2 files changed, 12 insertions, 3 deletions
diff --git a/kbx/keybox-search.c b/kbx/keybox-search.c index ba284f9b5..bf47042a3 100644 --- a/kbx/keybox-search.c +++ b/kbx/keybox-search.c @@ -718,10 +718,12 @@ keybox_search_reset (KEYBOX_HANDLE hd) /* Note: When in ephemeral mode the search function does visit all - blobs but in standard mode, blobs flagged as ephemeral are ignored. */ + blobs but in standard mode, blobs flagged as ephemeral are ignored. + The value at R_SKIPPED is updated by the number of skipped long + records (counts PGP and X.509). */ int keybox_search (KEYBOX_HANDLE hd, KEYBOX_SEARCH_DESC *desc, size_t ndesc, - size_t *r_descindex) + size_t *r_descindex, unsigned long *r_skipped) { int rc; size_t n; @@ -852,6 +854,13 @@ keybox_search (KEYBOX_HANDLE hd, KEYBOX_SEARCH_DESC *desc, size_t ndesc, _keybox_release_blob (blob); blob = NULL; rc = _keybox_read_blob (&blob, hd->fp); + if (gpg_err_code (rc) == GPG_ERR_TOO_LARGE + && gpg_err_source (rc) == GPG_ERR_SOURCE_KEYBOX) + { + ++*r_skipped; + continue; /* Skip too large records. */ + } + if (rc) break; diff --git a/kbx/keybox.h b/kbx/keybox.h index 9067fb8a4..b44f1b2ba 100644 --- a/kbx/keybox.h +++ b/kbx/keybox.h @@ -87,7 +87,7 @@ int keybox_get_flags (KEYBOX_HANDLE hd, int what, int idx, unsigned int *value); int keybox_search_reset (KEYBOX_HANDLE hd); int keybox_search (KEYBOX_HANDLE hd, KEYBOX_SEARCH_DESC *desc, size_t ndesc, - size_t *r_descindex); + size_t *r_descindex, unsigned long *r_skipped); /*-- keybox-update.c --*/ |