diff options
author | Werner Koch <wk@gnupg.org> | 1999-06-05 15:36:15 +0200 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 1999-06-05 15:36:15 +0200 |
commit | 717bce345c5da62de5abc10ea4f58ac71755bd13 (patch) | |
tree | 0cd530b8b55c9c44e19af22295e0cd45c03d4707 /g10 | |
parent | See ChangeLog: Wed Jun 2 14:17:19 CEST 1999 Werner Koch (diff) | |
download | gnupg2-717bce345c5da62de5abc10ea4f58ac71755bd13.tar.xz gnupg2-717bce345c5da62de5abc10ea4f58ac71755bd13.zip |
See ChangeLog: Sat Jun 5 15:30:33 CEST 1999 Werner Koch
Diffstat (limited to 'g10')
-rw-r--r-- | g10/pkclist.c | 56 |
1 files changed, 44 insertions, 12 deletions
diff --git a/g10/pkclist.c b/g10/pkclist.c index a170a3dd3..39ed0e5f2 100644 --- a/g10/pkclist.c +++ b/g10/pkclist.c @@ -547,6 +547,17 @@ release_pk_list( PK_LIST pk_list ) } } + +static int +key_present_in_pk_list(PK_LIST pk_list, PKT_public_key *pk) +{ + for( ; pk_list; pk_list = pk_list->next) + if (cmp_public_keys(pk_list->pk, pk) == 0) + return 0; + + return -1; +} + int build_pk_list( STRLIST remusr, PK_LIST *ret_pk_list, unsigned use ) { @@ -569,13 +580,22 @@ build_pk_list( STRLIST remusr, PK_LIST *ret_pk_list, unsigned use ) log_error(_("%s: skipped: %s\n"), rov->d, g10_errstr(rc) ); } else if( !(rc=check_pubkey_algo2(pk->pubkey_algo, use )) ) { - PK_LIST r; - r = m_alloc( sizeof *r ); - r->pk = pk; pk = NULL; - r->next = pk_list; - r->mark = 0; - pk_list = r; + /* Skip the actual key if the key is already present + * in the list */ + if (key_present_in_pk_list(pk_list, pk) == 0) { + free_public_key(pk); pk = NULL; + log_info(_("%s: skipped: public key already present\n"), + rov->d); + } + else { + PK_LIST r; + r = m_alloc( sizeof *r ); + r->pk = pk; pk = NULL; + r->next = pk_list; + r->mark = 0; + pk_list = r; + } } else { free_public_key( pk ); pk = NULL; @@ -655,14 +675,26 @@ build_pk_list( STRLIST remusr, PK_LIST *ret_pk_list, unsigned use ) } else if( do_we_trust_pre( pk, trustlevel ) ) { /* note: do_we_trust may have changed the trustlevel */ - PK_LIST r; - r = m_alloc( sizeof *r ); - r->pk = pk; pk = NULL; - r->next = pk_list; - r->mark = 0; - pk_list = r; + /* We have at least one valid recipient. It doesn't matters + * if this recipient is already present. */ any_recipients = 1; + + /* Skip the actual key if the key is already present + * in the list */ + if (key_present_in_pk_list(pk_list, pk) == 0) { + free_public_key(pk); pk = NULL; + log_info(_("%s: skipped: public key already present\n"), + remusr->d); + } + else { + PK_LIST r; + r = m_alloc( sizeof *r ); + r->pk = pk; pk = NULL; + r->next = pk_list; + r->mark = 0; + pk_list = r; + } } else { /* we don't trust this pk */ free_public_key( pk ); pk = NULL; |