aboutsummaryrefslogtreecommitdiffstats
path: root/g10/import.c
diff options
context:
space:
mode:
authorJustus Winter <[email protected]>2016-07-25 10:41:28 +0000
committerJustus Winter <[email protected]>2016-07-25 10:50:35 +0000
commit4ba11251aff578394000bf480f47160f0879c763 (patch)
tree5e5b60e8614f61b88514d4682c37c461d23fa019 /g10/import.c
parentgpgscm: Make function more general. (diff)
downloadgnupg-4ba11251aff578394000bf480f47160f0879c763.tar.gz
gnupg-4ba11251aff578394000bf480f47160f0879c763.zip
g10: Fix key import statistics.
'transfer_secret_keys' collects statistics on a subkey-basis, while the other code does not. This leads to inflated numbers when importing secret keys. E.g. 'count' is incremented by the main parsing loop in 'import', and again in 'transfer_secret_keys', leading to a total of 3 if one key with two secret subkeys is imported. * g10/import.c (import_secret_one): Adjust to the fact that 'transfer_secret_keys' collects subkey statistics. * tests/openpgp/Makefile.am (TESTS): Add new test. * tests/openpgp/issue2346.scm: New file. * tests/openpgp/samplekeys/issue2346.gpg: Likewise. GnuPG-bug-id: 2346 Signed-off-by: Justus Winter <[email protected]>
Diffstat (limited to '')
-rw-r--r--g10/import.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/g10/import.c b/g10/import.c
index 375bd03f8..b83f371ab 100644
--- a/g10/import.c
+++ b/g10/import.c
@@ -2067,8 +2067,11 @@ import_secret_one (ctrl_t ctrl, kbnode_t keyblock,
{
gpg_error_t err;
- nr_prev = stats->secret_imported;
- err = transfer_secret_keys (ctrl, stats, keyblock, batch, 0);
+ /* transfer_secret_keys collects subkey stats. */
+ struct import_stats_s subkey_stats = {0};
+
+ err = transfer_secret_keys (ctrl, &subkey_stats, keyblock,
+ batch, 0);
if (gpg_err_code (err) == GPG_ERR_NOT_PROCESSED)
{
/* TRANSLATORS: For smartcard, each private key on
@@ -2091,8 +2094,14 @@ import_secret_one (ctrl_t ctrl, kbnode_t keyblock,
if (!opt.quiet)
log_info (_("key %s: secret key imported\n"),
keystr_from_pk (pk));
- if (stats->secret_imported > nr_prev)
- status |= 1;
+ if (subkey_stats.secret_imported)
+ {
+ status |= 1;
+ stats->secret_imported += 1;
+ }
+ if (subkey_stats.secret_dups)
+ stats->secret_dups += 1;
+
if (is_status_enabled ())
print_import_ok (pk, status);
check_prefs (ctrl, node);