1 From: Justus Winter <justus@g10code.com>
2 Date: Wed, 25 Jan 2017 16:33:20 +0100
3 Subject: gpg: Fix searching for mail addresses in keyrings.
5 * g10/keyring.c (compare_name): Fix KEYDB_SEARCH_MODE_MAIL* searches
6 in keyrings when the UID is a plain addr-spec.
8 Previously, 'gpg --list-key "<foo@example.org>"' failed if 1/ the
9 keyring format is used and 2/ the key's UID is a plain addr-spec
10 (cf. RFC2822 section 4.3), e.g. 'foo@example.org'.
13 Signed-off-by: Justus Winter <justus@g10code.com>
14 (cherry picked from commit 3f4f20ee6eff052c88647b820d9ecfdbd8df0f40)
16 g10/keyring.c | 22 ++++++++++++++++++----
17 1 file changed, 18 insertions(+), 4 deletions(-)
19 diff --git a/g10/keyring.c b/g10/keyring.c
20 index f1281e98e..328290ed8 100644
23 @@ -928,13 +928,27 @@ compare_name (int mode, const char *name, const char *uid, size_t uidlen)
24 else if ( mode == KEYDB_SEARCH_MODE_MAIL
25 || mode == KEYDB_SEARCH_MODE_MAILSUB
26 || mode == KEYDB_SEARCH_MODE_MAILEND) {
27 + int have_angles = 1;
28 for (i=0, s= uid; i < uidlen && *s != '<'; s++, i++)
32 + /* The UID is a plain addr-spec (cf. RFC2822 section 4.3). */
38 - /* skip opening delim and one char and look for the closing one*/
40 - for (se=s+1, i++; i < uidlen && *se != '>'; se++, i++)
44 + /* skip opening delim and one char and look for the closing one*/
46 + for (se=s+1, i++; i < uidlen && *se != '>'; se++, i++)
54 if (mode == KEYDB_SEARCH_MODE_MAIL) {