mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-17 14:07:03 +01:00
gpg: Fix searching for mail addresses in keyrings.
* g10/keyring.c (compare_name): Fix KEYDB_SEARCH_MODE_MAIL* searches in keyrings when the UID is a plain addr-spec. -- Previously, 'gpg --list-key "<foo@example.org>"' failed if 1/ the keyring format is used and 2/ the key's UID is a plain addr-spec (cf. RFC2822 section 4.3), e.g. 'foo@example.org'. GnuPG-bug-id: 2930 Signed-off-by: Justus Winter <justus@g10code.com>
This commit is contained in:
parent
02a39f0d1e
commit
3f4f20ee6e
@ -928,13 +928,27 @@ compare_name (int mode, const char *name, const char *uid, size_t uidlen)
|
|||||||
else if ( mode == KEYDB_SEARCH_MODE_MAIL
|
else if ( mode == KEYDB_SEARCH_MODE_MAIL
|
||||||
|| mode == KEYDB_SEARCH_MODE_MAILSUB
|
|| mode == KEYDB_SEARCH_MODE_MAILSUB
|
||||||
|| mode == KEYDB_SEARCH_MODE_MAILEND) {
|
|| mode == KEYDB_SEARCH_MODE_MAILEND) {
|
||||||
|
int have_angles = 1;
|
||||||
for (i=0, s= uid; i < uidlen && *s != '<'; s++, i++)
|
for (i=0, s= uid; i < uidlen && *s != '<'; s++, i++)
|
||||||
;
|
;
|
||||||
|
if (i == uidlen)
|
||||||
|
{
|
||||||
|
/* The UID is a plain addr-spec (cf. RFC2822 section 4.3). */
|
||||||
|
have_angles = 0;
|
||||||
|
s = uid;
|
||||||
|
i = 0;
|
||||||
|
}
|
||||||
if (i < uidlen) {
|
if (i < uidlen) {
|
||||||
/* skip opening delim and one char and look for the closing one*/
|
if (have_angles)
|
||||||
s++; i++;
|
{
|
||||||
for (se=s+1, i++; i < uidlen && *se != '>'; se++, i++)
|
/* skip opening delim and one char and look for the closing one*/
|
||||||
;
|
s++; i++;
|
||||||
|
for (se=s+1, i++; i < uidlen && *se != '>'; se++, i++)
|
||||||
|
;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
se = s + uidlen;
|
||||||
|
|
||||||
if (i < uidlen) {
|
if (i < uidlen) {
|
||||||
i = se - s;
|
i = se - s;
|
||||||
if (mode == KEYDB_SEARCH_MODE_MAIL) {
|
if (mode == KEYDB_SEARCH_MODE_MAIL) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user