summaryrefslogtreecommitdiffstats
path: root/sm
diff options
context:
space:
mode:
authorMarcus Brinkmann <mb@g10code.com>2008-01-30 18:21:28 +0100
committerMarcus Brinkmann <mb@g10code.com>2008-01-30 18:21:28 +0100
commit8ac61bc708194f01e64c3c12127def1ec149687c (patch)
treed9f27be5f2530527a6a57984bf9cdb45e029dde6 /sm
parentFixed yesterday's W32 fix. (diff)
downloadgnupg2-8ac61bc708194f01e64c3c12127def1ec149687c.tar.xz
gnupg2-8ac61bc708194f01e64c3c12127def1ec149687c.zip
2008-01-29 Marcus Brinkmann <marcus@g10code.de>
* keylist.c (list_internal_keys): New variable lastcert. Use it to suppress duplicates which immediately follow each other.
Diffstat (limited to 'sm')
-rw-r--r--sm/ChangeLog5
-rw-r--r--sm/keylist.c17
2 files changed, 20 insertions, 2 deletions
diff --git a/sm/ChangeLog b/sm/ChangeLog
index 3f7374a4f..dcbbff3cf 100644
--- a/sm/ChangeLog
+++ b/sm/ChangeLog
@@ -1,3 +1,8 @@
+2008-01-29 Marcus Brinkmann <marcus@g10code.de>
+
+ * keylist.c (list_internal_keys): New variable lastcert. Use it
+ to suppress duplicates which immediately follow each other.
+
2008-01-27 Werner Koch <wk@g10code.com>
* import.c (popen_protect_tool): Set bit 7 in the flags for
diff --git a/sm/keylist.c b/sm/keylist.c
index 0f5313eb2..e9ca9b809 100644
--- a/sm/keylist.c
+++ b/sm/keylist.c
@@ -1171,6 +1171,7 @@ list_internal_keys (ctrl_t ctrl, strlist_t names, estream_t fp,
strlist_t sl;
int ndesc;
ksba_cert_t cert = NULL;
+ ksba_cert_t lastcert = NULL;
gpg_error_t rc = 0;
const char *lastresname, *resname;
int have_secret;
@@ -1228,6 +1229,7 @@ list_internal_keys (ctrl_t ctrl, strlist_t names, estream_t fp,
currently we stop at the first match. To do this we need an
extra flag to enable this feature so */
+ /* Suppress duplicates at least when they follow each other. */
lastresname = NULL;
while (!(rc = keydb_search (hd, desc, ndesc)))
{
@@ -1248,7 +1250,15 @@ list_internal_keys (ctrl_t ctrl, strlist_t names, estream_t fp,
log_error ("keydb_get_cert failed: %s\n", gpg_strerror (rc));
goto leave;
}
-
+ /* Skip duplicated certificates, at least if they follow each
+ others. This works best if a single key is searched for and
+ expected. FIXME: Non-sequential duplicates remain. */
+ if (gpgsm_certs_identical_p (cert, lastcert))
+ {
+ ksba_cert_release (cert);
+ continue;
+ }
+
resname = keydb_get_resource_name (hd);
if (lastresname != resname )
@@ -1301,7 +1311,9 @@ list_internal_keys (ctrl_t ctrl, strlist_t names, estream_t fp,
es_putc ('\n', fp);
}
}
- ksba_cert_release (cert);
+
+ ksba_cert_release (lastcert);
+ lastcert = cert;
cert = NULL;
}
if (gpg_err_code (rc) == GPG_ERR_EOF || rc == -1 )
@@ -1311,6 +1323,7 @@ list_internal_keys (ctrl_t ctrl, strlist_t names, estream_t fp,
leave:
ksba_cert_release (cert);
+ ksba_cert_release (lastcert);
xfree (desc);
keydb_release (hd);
return rc;