aboutsummaryrefslogtreecommitdiffstats
path: root/g10/pkclist.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2017-12-18 15:38:02 +0000
committerWerner Koch <[email protected]>2017-12-18 15:42:59 +0000
commitc817e750283278e7e8317c1b47981e71ddcc9dbf (patch)
tree0865a55b588243ac2883c483959ec483c4c2e9ae /g10/pkclist.c
parentpo: Update Japanese translation. (diff)
parentgpgconf: Show --compliance in expert mode. (diff)
downloadgnupg-c817e750283278e7e8317c1b47981e71ddcc9dbf.tar.gz
gnupg-c817e750283278e7e8317c1b47981e71ddcc9dbf.zip
Merge branch 'STABLE-BRANCH-2-2' into master
-- Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'g10/pkclist.c')
-rw-r--r--g10/pkclist.c47
1 files changed, 21 insertions, 26 deletions
diff --git a/g10/pkclist.c b/g10/pkclist.c
index 220936c56..581cae407 100644
--- a/g10/pkclist.c
+++ b/g10/pkclist.c
@@ -730,40 +730,35 @@ key_present_in_pk_list(PK_LIST pk_list, PKT_public_key *pk)
}
-/****************
+/*
* Return a malloced string with a default recipient if there is any
+ * Fixme: We don't distinguish between malloc failure and no-default-recipient.
*/
static char *
-default_recipient(ctrl_t ctrl)
+default_recipient (ctrl_t ctrl)
{
- PKT_public_key *pk;
- byte fpr[MAX_FINGERPRINT_LEN+1];
- size_t n;
- char *p;
- int i;
+ PKT_public_key *pk;
+ char *result;
- if( opt.def_recipient )
- return xstrdup( opt.def_recipient );
- if( !opt.def_recipient_self )
- return NULL;
- pk = xmalloc_clear( sizeof *pk );
- i = get_seckey_default (ctrl, pk);
- if( i ) {
- free_public_key( pk );
- return NULL;
+ if (opt.def_recipient)
+ return xtrystrdup (opt.def_recipient);
+
+ if (!opt.def_recipient_self)
+ return NULL;
+ pk = xtrycalloc (1, sizeof *pk );
+ if (!pk)
+ return NULL;
+ if (get_seckey_default (ctrl, pk))
+ {
+ free_public_key (pk);
+ return NULL;
}
- n = MAX_FINGERPRINT_LEN;
- fingerprint_from_pk( pk, fpr, &n );
- free_public_key( pk );
- p = xmalloc( 2*n+3 );
- *p++ = '0';
- *p++ = 'x';
- for(i=0; i < n; i++ )
- sprintf( p+2*i, "%02X", fpr[i] );
- p -= 2;
- return p;
+ result = hexfingerprint (pk, NULL, 0);
+ free_public_key (pk);
+ return result;
}
+
static int
expand_id(const char *id,strlist_t *into,unsigned int flags)
{