aboutsummaryrefslogtreecommitdiffstats
path: root/g10/mainproc.c
diff options
context:
space:
mode:
authorDavid Shaw <[email protected]>2006-03-09 03:35:26 +0000
committerDavid Shaw <[email protected]>2006-03-09 03:35:26 +0000
commit54601532648f6f36808c54597509b43cd435d4c6 (patch)
tree6fa4d3ae09ea428fb41a879f8fc8c1c7d6c6c2a2 /g10/mainproc.c
parent* argparse.c (default_strusage): Update copyright year to 2006. (diff)
downloadgnupg-54601532648f6f36808c54597509b43cd435d4c6.tar.gz
gnupg-54601532648f6f36808c54597509b43cd435d4c6.zip
* mainproc.c (get_pka_address), keylist.c (show_notation): Remove
duplicate code by using notation functions.
Diffstat (limited to '')
-rw-r--r--g10/mainproc.c55
1 files changed, 20 insertions, 35 deletions
diff --git a/g10/mainproc.c b/g10/mainproc.c
index 36f15097b..336ad948d 100644
--- a/g10/mainproc.c
+++ b/g10/mainproc.c
@@ -1334,47 +1334,32 @@ do_proc_packets( CTX c, IOBUF a )
static pka_info_t *
get_pka_address (PKT_signature *sig)
{
- const unsigned char *p;
- size_t len, n1, n2;
- int seq = 0;
pka_info_t *pka = NULL;
+ struct notation *nd,*notation;
- while ((p = enum_sig_subpkt (sig->hashed, SIGSUBPKT_NOTATION,
- &len, &seq, NULL)))
+ notation=sig_to_notation(sig);
+
+ for(nd=notation;nd;nd=nd->next)
{
- if (len < 8)
- continue; /* Notation packet is too short. */
- n1 = (p[4]<<8)|p[5];
- n2 = (p[6]<<8)|p[7];
- if (8 + n1 + n2 != len)
- continue; /* Length fields of notation packet are inconsistent. */
- p += 8;
- if (n1 != 21 || memcmp (p, "[email protected]", 21))
+ if(strcmp(nd->name,"[email protected]")!=0)
continue; /* Not the notation we want. */
- p += n1;
- if (n2 < 3)
- continue; /* Impossible email address. */
-
- if (pka)
- break; /* For now we only use the first valid PKA notation. In
- future we might want to keep additional PKA
- notations in a linked list. */
-
- pka = xmalloc (sizeof *pka + n2);
- pka->valid = 0;
- pka->checked = 0;
- pka->uri = NULL;
- memcpy (pka->email, p, n2);
- pka->email[n2] = 0;
-
- if (!is_valid_mailbox (pka->email))
- {
- /* We don't accept invalid mail addresses. */
- xfree (pka);
- pka = NULL;
- }
+
+ /* For now we only use the first valid PKA notation. In future
+ we might want to keep additional PKA notations in a linked
+ list. */
+ if (is_valid_mailbox (pka->email))
+ {
+ pka = xmalloc (sizeof *pka + strlen(nd->value));
+ pka->valid = 0;
+ pka->checked = 0;
+ pka->uri = NULL;
+ strcpy (pka->email, nd->value);
+ break;
+ }
}
+ free_notation(notation);
+
return pka;
}