summaryrefslogtreecommitdiffstats
path: root/kbx/keybox-search.c
diff options
context:
space:
mode:
authorNeal H. Walfield <neal@g10code.com>2015-12-15 12:21:30 +0100
committerNeal H. Walfield <neal@g10code.com>2015-12-15 12:21:30 +0100
commit2e4e10c1dcd8dfeafec51f44ebf26acfeb770c41 (patch)
treeeb1c054a94fc82708178c618d30e0dc31760697f /kbx/keybox-search.c
parentgpg: Use more descriptive names. (diff)
downloadgnupg2-2e4e10c1dcd8dfeafec51f44ebf26acfeb770c41.tar.xz
gnupg2-2e4e10c1dcd8dfeafec51f44ebf26acfeb770c41.zip
gpg: Improve the keyblock cache's transparency.
* kbx/keybox-search.c (keybox_offset): New function. * g10/keydb.c (struct keyblock_cache): Add fields resource and offset. (keyblock_cache_clear): Reset HD->KEYBLOCK_CACHE.RESOURCE and HD->KEYBLOCK_CACHE.OFFSET. (keydb_search): Don't use the cached result if it comes before the current file position. When caching an entry, also record the position at which it was found. -- Signed-off-by: Neal H. Walfield <neal@g10code.com> GnuPG-bug-id: 2187
Diffstat (limited to 'kbx/keybox-search.c')
-rw-r--r--kbx/keybox-search.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/kbx/keybox-search.c b/kbx/keybox-search.c
index 78e0c23b7..df959b67d 100644
--- a/kbx/keybox-search.c
+++ b/kbx/keybox-search.c
@@ -1188,3 +1188,11 @@ keybox_get_flags (KEYBOX_HANDLE hd, int what, int idx, unsigned int *value)
ec = get_flag_from_image (buffer, length, what, value);
return ec? gpg_error (ec):0;
}
+
+off_t
+keybox_offset (KEYBOX_HANDLE hd)
+{
+ if (!hd->fp)
+ return 0;
+ return ftello (hd->fp);
+}