summaryrefslogtreecommitdiffstats
path: root/kbx/keybox-search.c
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2015-01-19 14:58:06 +0100
committerWerner Koch <wk@gnupg.org>2015-01-19 14:58:06 +0100
commit7be1b7d8017cb7ebf1a3855edec0ef5e342cc9c5 (patch)
tree3b825d28d380caf1dfcfc4fa27241261ee616bca /kbx/keybox-search.c
parentkbx: Call skipfnc callback to filter out keys (diff)
downloadgnupg2-7be1b7d8017cb7ebf1a3855edec0ef5e342cc9c5.tar.xz
gnupg2-7be1b7d8017cb7ebf1a3855edec0ef5e342cc9c5.zip
kbx: Minor cleanup for the previous fix.
* kbx/keybox-search.c (blob_get_keyid): Rename to blob_get_first_keyid. Check number of keys and remove blob type check. -- There is no need to check the blob type. We already know that it is a key blob type and keyids are used for X.509 and OpenPGP. Also added check for number of keys because the other parser functions do it as well. Signed-off-by: Werner Koch <wk@gnupg.org>
Diffstat (limited to '')
-rw-r--r--kbx/keybox-search.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/kbx/keybox-search.c b/kbx/keybox-search.c
index 2126ecec5..0a3ed43d0 100644
--- a/kbx/keybox-search.c
+++ b/kbx/keybox-search.c
@@ -79,21 +79,21 @@ blob_get_blob_flags (KEYBOXBLOB blob)
}
+/* Return the first keyid from the blob. Returns true if
+ available. */
static int
-blob_get_keyid (KEYBOXBLOB blob, u32 *kid)
+blob_get_first_keyid (KEYBOXBLOB blob, u32 *kid)
{
const unsigned char *buffer;
- size_t length, keyinfolen;
+ size_t length, nkeys, keyinfolen;
buffer = _keybox_get_blob_image (blob, &length);
if (length < 48)
return 0; /* blob too short */
- if (buffer[4] != KEYBOX_BLOBTYPE_PGP)
- return 0; /* don't know what to do with X.509 blobs */
-
+ nkeys = get16 (buffer + 16);
keyinfolen = get16 (buffer + 18);
- if (keyinfolen < 28)
+ if (!nkeys || keyinfolen < 28)
return 0; /* invalid blob */
kid[0] = get32 (buffer + 32);
@@ -994,7 +994,7 @@ keybox_search (KEYBOX_HANDLE hd, KEYBOX_SEARCH_DESC *desc, size_t ndesc,
u32 kid[2];
if (desc[n].skipfnc
- && blob_get_keyid (blob, kid)
+ && blob_get_first_keyid (blob, kid)
&& desc[n].skipfnc (desc[n].skipfncvalue, kid, NULL))
break;
}