summaryrefslogtreecommitdiffstats
path: root/dirmngr
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2021-06-21 09:22:17 +0200
committerWerner Koch <wk@gnupg.org>2021-06-21 09:32:16 +0200
commitd5126efd895bc2af0a7e63dbf4aa782ce47ecc40 (patch)
tree32f80184480a18afa4b83eac6d0d096ce25e03ab /dirmngr
parentscd:p15: Add pre-check for ascii-numeric PINs. (diff)
downloadgnupg2-d5126efd895bc2af0a7e63dbf4aa782ce47ecc40.tar.xz
gnupg2-d5126efd895bc2af0a7e63dbf4aa782ce47ecc40.zip
dirmngr: Fix regression in KS_GET for mail address pattern.
* dirmngr/ks-engine-hkp.c (ks_hkp_search): Munge mail address pattern. (ks_hkp_get): Allow for mail addresses. - Before the keyserver changes in 2.2.28 gpg passed dirmngr a pail address as an exact pattern (e.g. "=foo@example.org"). Since 2.2.28 the mail address is detected gpg gpg and we see for example "<foo@example.org>". This patch fixes this to turn a mail address into an exact match again. GnuPG-bug-id: 5497 Signed-off-by: Werner Koch <wk@gnupg.org>
Diffstat (limited to 'dirmngr')
-rw-r--r--dirmngr/ks-engine-hkp.c40
1 files changed, 39 insertions, 1 deletions
diff --git a/dirmngr/ks-engine-hkp.c b/dirmngr/ks-engine-hkp.c
index e72c2c16d..a2b4607cb 100644
--- a/dirmngr/ks-engine-hkp.c
+++ b/dirmngr/ks-engine-hkp.c
@@ -1485,6 +1485,7 @@ ks_hkp_search (ctrl_t ctrl, parsed_uri_t uri, const char *pattern,
gpg_error_t err;
KEYDB_SEARCH_DESC desc;
char fprbuf[2+64+1];
+ char *namebuffer = NULL;
char *hostport = NULL;
char *request = NULL;
estream_t fp = NULL;
@@ -1509,10 +1510,26 @@ ks_hkp_search (ctrl_t ctrl, parsed_uri_t uri, const char *pattern,
{
case KEYDB_SEARCH_MODE_EXACT:
case KEYDB_SEARCH_MODE_SUBSTR:
- case KEYDB_SEARCH_MODE_MAIL:
case KEYDB_SEARCH_MODE_MAILSUB:
pattern = desc.u.name;
break;
+ case KEYDB_SEARCH_MODE_MAIL:
+ namebuffer = xtrystrdup (desc.u.name);
+ if (!namebuffer)
+ {
+ err = gpg_error_from_syserror ();
+ goto leave;
+ }
+ /* Strip trailing angle bracket. */
+ if (namebuffer[0] && namebuffer[1]
+ && namebuffer[strlen (namebuffer)-1] == '>')
+ namebuffer[strlen(namebuffer)-1] = 0;
+ /* Strip optional leading angle bracket. */
+ if (*namebuffer == '<' && namebuffer[1])
+ pattern = namebuffer + 1;
+ else
+ pattern = namebuffer;
+ break;
case KEYDB_SEARCH_MODE_SHORT_KID:
snprintf (fprbuf, sizeof fprbuf, "0x%08lX", (ulong)desc.u.kid[1]);
pattern = fprbuf;
@@ -1616,6 +1633,7 @@ ks_hkp_search (ctrl_t ctrl, parsed_uri_t uri, const char *pattern,
xfree (request);
xfree (hostport);
xfree (httphost);
+ xfree (namebuffer);
return err;
}
@@ -1631,6 +1649,7 @@ ks_hkp_get (ctrl_t ctrl, parsed_uri_t uri, const char *keyspec, estream_t *r_fp)
KEYDB_SEARCH_DESC desc;
char kidbuf[2+64+1];
const char *exactname = NULL;
+ char *namebuffer = NULL;
char *searchkey = NULL;
char *hostport = NULL;
char *request = NULL;
@@ -1676,6 +1695,24 @@ ks_hkp_get (ctrl_t ctrl, parsed_uri_t uri, const char *keyspec, estream_t *r_fp)
exactname = desc.u.name;
break;
+ case KEYDB_SEARCH_MODE_MAIL:
+ namebuffer = xtrystrdup (desc.u.name);
+ if (!namebuffer)
+ {
+ err = gpg_error_from_syserror ();
+ goto leave;
+ }
+ /* Strip trailing angle bracket. */
+ if (namebuffer[0] && namebuffer[1]
+ && namebuffer[strlen (namebuffer)-1] == '>')
+ namebuffer[strlen(namebuffer)-1] = 0;
+ /* Strip optional leading angle bracket. */
+ if (*namebuffer == '<' && namebuffer[1])
+ exactname = namebuffer + 1;
+ else
+ exactname = namebuffer;
+ break;
+
default:
return gpg_error (GPG_ERR_INV_USER_ID);
}
@@ -1737,6 +1774,7 @@ ks_hkp_get (ctrl_t ctrl, parsed_uri_t uri, const char *keyspec, estream_t *r_fp)
leave:
es_fclose (fp);
+ xfree (namebuffer);
xfree (request);
xfree (hostport);
xfree (httphost);