1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-22 10:19:57 +01:00

kbx: Fix searching for FPR20 in version 2 blob.

* kbx/keybox-search.c (blob_cmp_fpr_part): Don't change FPROFF, since
it's caller which tweaks the offset.
(has_short_kid, has_long_kid): Examine the key flags to determine if
fingerprint 32 or 20.

--

GnuPG-bug-id: 5888
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
NIIBE Yutaka 2022-03-24 13:16:52 +09:00
parent ed53d41b4c
commit 01329da8a7

View File

@ -304,8 +304,6 @@ blob_cmp_fpr_part (KEYBOXBLOB blob, const unsigned char *fpr,
if (pos + (uint64_t)keyinfolen*nkeys > (uint64_t)length)
return 0; /* out of bounds */
if (fpr32)
fproff = 0; /* keyid are the high-order bits. */
for (idx=0; idx < nkeys; idx++)
{
off = pos + idx*keyinfolen;
@ -702,7 +700,7 @@ has_short_kid (KEYBOXBLOB blob, u32 lkid)
buf[2] = lkid >> 8;
buf[3] = lkid;
if (fpr32)
if (fpr32 && (get16 (buffer + 20 + 32) & 0x80))
return blob_cmp_fpr_part (blob, buf, 0, 4);
else
return blob_cmp_fpr_part (blob, buf, 16, 4);
@ -732,7 +730,7 @@ has_long_kid (KEYBOXBLOB blob, u32 mkid, u32 lkid)
buf[6] = lkid >> 8;
buf[7] = lkid;
if (fpr32)
if (fpr32 && (get16 (buffer + 20 + 32) & 0x80))
return blob_cmp_fpr_part (blob, buf, 0, 8);
else
return blob_cmp_fpr_part (blob, buf, 12, 8);