summaryrefslogtreecommitdiffstats
path: root/kbx/keybox-update.c
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2014-10-31 12:15:34 +0100
committerWerner Koch <wk@gnupg.org>2014-10-31 12:15:34 +0100
commit935edf88ab29b2f63afc2a0e3af1b33c92033ab7 (patch)
treeeed38381131b8d98f4aa95a2a6aa9227ec576699 /kbx/keybox-update.c
parentgpg: Fix --rebuild-keydb-caches. (diff)
downloadgnupg2-935edf88ab29b2f63afc2a0e3af1b33c92033ab7.tar.xz
gnupg2-935edf88ab29b2f63afc2a0e3af1b33c92033ab7.zip
kbx: Let keydb_search skip unwanted blobs.
* kbx/keybox.h (keybox_blobtype_t): New. * kbx/keybox-defs.h (BLOBTYPE_*): Replace by KEYBOX_BLOBTYPE_*. * kbx/keybox-search.c (keybox_search): Add arg want_blobtype and skip non-matching blobs. * sm/keydb.c (keydb_search): Pass KEYBOX_BLOBTYPE_X509 to keybox_search. * g10/keydb.c (keydb_search): Pass KEYBOX_BLOBTYPE_PGP to keybox_search. -- Without this fix a listing of all keys would fail because the wrong blob type would be returned for the gpg or gpgsm. Signed-off-by: Werner Koch <wk@gnupg.org>
Diffstat (limited to 'kbx/keybox-update.c')
-rw-r--r--kbx/keybox-update.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/kbx/keybox-update.c b/kbx/keybox-update.c
index 693b7324a..11861ac14 100644
--- a/kbx/keybox-update.c
+++ b/kbx/keybox-update.c
@@ -282,7 +282,8 @@ blob_filecopy (int mode, const char *fname, KEYBOXBLOB blob,
failsafe the blob type.) */
while ( (nread = fread (buffer, 1, DIM(buffer), fp)) > 0 )
{
- if (first_record && for_openpgp && buffer[4] == BLOBTYPE_HEADER)
+ if (first_record && for_openpgp
+ && buffer[4] == KEYBOX_BLOBTYPE_HEADER)
{
first_record = 0;
buffer[7] |= 0x02; /* OpenPGP data may be available. */
@@ -446,7 +447,7 @@ keybox_update_keyblock (KEYBOX_HANDLE hd, const void *image, size_t imagelen)
return gpg_error (GPG_ERR_INV_VALUE);
if (!hd->found.blob)
return gpg_error (GPG_ERR_NOTHING_FOUND);
- if (blob_get_type (hd->found.blob) != BLOBTYPE_PGP)
+ if (blob_get_type (hd->found.blob) != KEYBOX_BLOBTYPE_PGP)
return gpg_error (GPG_ERR_WRONG_BLOB_TYPE);
fname = hd->kb->fname;
if (!fname)
@@ -704,7 +705,7 @@ keybox_compress (KEYBOX_HANDLE hd)
size_t length;
buffer = _keybox_get_blob_image (blob, &length);
- if (length > 4 && buffer[4] == BLOBTYPE_HEADER)
+ if (length > 4 && buffer[4] == KEYBOX_BLOBTYPE_HEADER)
{
u32 last_maint = ((buffer[20] << 24) | (buffer[20+1] << 16)
| (buffer[20+2] << 8) | (buffer[20+3]));
@@ -751,7 +752,7 @@ keybox_compress (KEYBOX_HANDLE hd)
if (first_blob)
{
first_blob = 0;
- if (length > 4 && buffer[4] == BLOBTYPE_HEADER)
+ if (length > 4 && buffer[4] == KEYBOX_BLOBTYPE_HEADER)
{
/* Write out the blob with an updated maintenance time
stamp and if needed (ie. used by gpg) set the openpgp
@@ -769,7 +770,7 @@ keybox_compress (KEYBOX_HANDLE hd)
break;
any_changes = 1;
}
- else if (length > 4 && buffer[4] == BLOBTYPE_HEADER)
+ else if (length > 4 && buffer[4] == KEYBOX_BLOBTYPE_HEADER)
{
/* Oops: There is another header record - remove it. */
any_changes = 1;