mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-31 11:41:32 +01:00
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>
This commit is contained in:
parent
c5956592c1
commit
7be1b7d801
@ -79,21 +79,21 @@ blob_get_blob_flags (KEYBOXBLOB blob)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Return the first keyid from the blob. Returns true if
|
||||||
|
available. */
|
||||||
static int
|
static int
|
||||||
blob_get_keyid (KEYBOXBLOB blob, u32 *kid)
|
blob_get_first_keyid (KEYBOXBLOB blob, u32 *kid)
|
||||||
{
|
{
|
||||||
const unsigned char *buffer;
|
const unsigned char *buffer;
|
||||||
size_t length, keyinfolen;
|
size_t length, nkeys, keyinfolen;
|
||||||
|
|
||||||
buffer = _keybox_get_blob_image (blob, &length);
|
buffer = _keybox_get_blob_image (blob, &length);
|
||||||
if (length < 48)
|
if (length < 48)
|
||||||
return 0; /* blob too short */
|
return 0; /* blob too short */
|
||||||
|
|
||||||
if (buffer[4] != KEYBOX_BLOBTYPE_PGP)
|
nkeys = get16 (buffer + 16);
|
||||||
return 0; /* don't know what to do with X.509 blobs */
|
|
||||||
|
|
||||||
keyinfolen = get16 (buffer + 18);
|
keyinfolen = get16 (buffer + 18);
|
||||||
if (keyinfolen < 28)
|
if (!nkeys || keyinfolen < 28)
|
||||||
return 0; /* invalid blob */
|
return 0; /* invalid blob */
|
||||||
|
|
||||||
kid[0] = get32 (buffer + 32);
|
kid[0] = get32 (buffer + 32);
|
||||||
@ -994,7 +994,7 @@ keybox_search (KEYBOX_HANDLE hd, KEYBOX_SEARCH_DESC *desc, size_t ndesc,
|
|||||||
u32 kid[2];
|
u32 kid[2];
|
||||||
|
|
||||||
if (desc[n].skipfnc
|
if (desc[n].skipfnc
|
||||||
&& blob_get_keyid (blob, kid)
|
&& blob_get_first_keyid (blob, kid)
|
||||||
&& desc[n].skipfnc (desc[n].skipfncvalue, kid, NULL))
|
&& desc[n].skipfnc (desc[n].skipfncvalue, kid, NULL))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user