mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
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 <justus@g10code.com>
This commit is contained in:
parent
9ee23a715d
commit
4ba11251af
4 changed files with 104 additions and 4 deletions
17
g10/import.c
17
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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue