mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-22 10:19:57 +01:00
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>
This commit is contained in:
parent
029924a46e
commit
d5126efd89
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user