summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Harris <jgh146exb@wizmail.org>2022-03-10 20:27:49 +0000
committerJeremy Harris <jgh146exb@wizmail.org>2022-03-10 21:55:08 +0000
commitfaa73f190673ae82a142f000a9ad2c13671f0376 (patch)
tree80bf79be93d5d44ed22275e7d832af6f7f36b971
parent7596f24296bffbb02eeb7e13b6580d67ccaf798e (diff)
downloadexim4-faa73f190673ae82a142f000a9ad2c13671f0376.tar.gz
Fix static address-list lookup return
-rw-r--r--doc/doc-txt/ChangeLog3
-rw-r--r--src/src/match.c44
-rw-r--r--test/stderr/00216
-rw-r--r--test/stderr/02796
4 files changed, 36 insertions, 23 deletions
diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog
index 02943dd99..5ba587b8e 100644
--- a/doc/doc-txt/ChangeLog
+++ b/doc/doc-txt/ChangeLog
@@ -92,6 +92,9 @@ JH/20 When built with NDBM for hints DB's check for nonexistence of a name
JH/21 Remove the "allow_insecure_tainted_data" main config option and the
"taint" log_selector. These were previously deprecated.
+JH/22 Fix static address-list lookups to properly return the matched item.
+ Previously only the domain part was returned.
+
Exim version 4.95
-----------------
diff --git a/src/src/match.c b/src/src/match.c
index a1ec5616b..0d2cdb57d 100644
--- a/src/src/match.c
+++ b/src/src/match.c
@@ -1005,15 +1005,16 @@ Returns: OK for a match
static int
check_address(void *arg, const uschar *pattern, const uschar **valueptr, uschar **error)
{
-check_address_block *cb = (check_address_block *)arg;
+check_address_block * cb = (check_address_block *)arg;
check_string_block csb;
int rc;
int expand_inc = 0;
-unsigned int *null = NULL;
-const uschar *listptr;
-uschar *subject = cb->address;
-const uschar *s;
-uschar *pdomain, *sdomain;
+unsigned int * null = NULL;
+const uschar * listptr;
+uschar * subject = cb->address;
+const uschar * s;
+uschar * pdomain, * sdomain;
+uschar * value = NULL;
DEBUG(D_lists) debug_printf_indent("address match test: subject=%s pattern=%s\n",
subject, pattern);
@@ -1064,7 +1065,7 @@ if (*s == ';')
because other patterns expect to have a local part and a domain to match
against. */
-if (*subject == 0) return (*pattern == 0)? OK : FAIL;
+if (!*subject) return *pattern ? FAIL : OK;
/* If the pattern starts with "@@" we have a split lookup, where the domain is
looked up to obtain a list of local parts. If the subject's local part is just
@@ -1186,6 +1187,7 @@ if (pdomain != NULL)
expand_nlength[cb->expand_setup] = sllen - cllen;
expand_inc = 1;
}
+ value = string_copyn(pattern + 1, cllen);
}
else
{
@@ -1194,6 +1196,7 @@ if (pdomain != NULL)
? strncmpic(subject, pattern, sllen) != 0
: Ustrncmp(subject, pattern, sllen) != 0) return FAIL;
}
+ value = string_copyn(pattern, sllen);
}
/* If the local part matched, or was not being checked, check the domain using
@@ -1218,16 +1221,23 @@ csb.at_is_special = TRUE;
listptr = pdomain ? pdomain + 1 : pattern;
if (valueptr) *valueptr = NULL;
-return match_check_list(
- &listptr, /* list of one item */
- UCHAR_MAX+1, /* impossible separator; single item */
- &domainlist_anchor, /* it's a domain list */
- &null, /* ptr to NULL means no caching */
- check_string, /* the function to do one test */
- &csb, /* its data */
- MCL_DOMAIN + MCL_NOEXPAND, /* domain list; don't expand */
- csb.subject, /* string for messages */
- valueptr); /* where to pass back lookup data */
+ {
+ const uschar * dvalue = NULL;
+ rc = match_check_list(
+ &listptr, /* list of one item */
+ UCHAR_MAX+1, /* impossible separator; single item */
+ &domainlist_anchor, /* it's a domain list */
+ &null, /* ptr to NULL means no caching */
+ check_string, /* the function to do one test */
+ &csb, /* its data */
+ MCL_DOMAIN + MCL_NOEXPAND, /* domain list; don't expand */
+ csb.subject, /* string for messages */
+ &dvalue); /* where to pass back lookup data */
+ if (valueptr && (value || dvalue))
+ *valueptr = string_sprintf("%s@%s",
+ value ? value : US"", dvalue ? dvalue : US"");
+ }
+return rc;
}
diff --git a/test/stderr/0021 b/test/stderr/0021
index b476c0340..1b1f6a605 100644
--- a/test/stderr/0021
+++ b/test/stderr/0021
@@ -78,7 +78,7 @@ test1 in "somewhere"? no (end of list)
address match test: subject=ok@test1 pattern=ok@test1
test1 in "test1"? yes (matched "test1")
ok@test1 in "ok@somewhere : ok@test1 : ok@test3"? yes (matched "ok@test1")
-data from lookup saved for cache for +ok_senders: key 'ok@test1' value 'test1'
+data from lookup saved for cache for +ok_senders: key 'ok@test1' value 'ok@test1'
ok@test1 in "+ok_senders"? yes (matched "+ok_senders")
check sender_domains = +ok_sender_domains
test1 in "somewhere : test1 : test3"? yes (matched "test1")
@@ -93,7 +93,7 @@ using ACL "rcpt"
processing "accept" (TESTSUITE/test-config 70)
check senders = +ok_senders
cached yes match for +ok_senders
-cached lookup data = test1
+cached lookup data = ok@test1
ok@test1 in "+ok_senders"? yes (matched "+ok_senders" - cached)
check sender_domains = +ok_sender_domains
cached yes match for +ok_sender_domains
@@ -175,7 +175,7 @@ test3 in "test1"? no (end of list)
address match test: subject=ok@test3 pattern=ok@test3
test3 in "test3"? yes (matched "test3")
ok@test3 in "ok@somewhere : ok@test1 : ok@test3"? yes (matched "ok@test3")
-data from lookup saved for cache for +ok_senders: key 'ok@test3' value 'test3'
+data from lookup saved for cache for +ok_senders: key 'ok@test3' value 'ok@test3'
ok@test3 in "+ok_senders"? yes (matched "+ok_senders")
check sender_domains = +ok_sender_domains
test3 in "somewhere : test1 : test3"? yes (matched "test3")
diff --git a/test/stderr/0279 b/test/stderr/0279
index b42f8acc7..d61b7fb8e 100644
--- a/test/stderr/0279
+++ b/test/stderr/0279
@@ -34,7 +34,7 @@ CALLER@test.ex in "never1@test.ex"? no (end of list)
address match test: subject=CALLER@test.ex pattern=CALLER@test.ex
test.ex in "test.ex"? yes (matched "test.ex")
CALLER@test.ex in "CALLER@test.ex"? yes (matched "CALLER@test.ex")
-data from lookup saved for cache for +local_addresses: key 'CALLER@test.ex' value 'test.ex'
+data from lookup saved for cache for +local_addresses: key 'CALLER@test.ex' value 'CALLER@test.ex'
CALLER@test.ex in "+never_addresses : +n1_addresses : ! +local_addresses"? no (matched "! +local_addresses")
r1 router skipped: senders mismatch
--------> r2 router <--------
@@ -47,7 +47,7 @@ cached no match for +n1_addresses
cached lookup data = NULL
CALLER@test.ex in "<; never2@test.ex ; +n1_addresses"? no (end of list)
cached yes match for +local_addresses
-cached lookup data = test.ex
+cached lookup data = CALLER@test.ex
CALLER@test.ex in "+never_addresses : +n2_addresses : !+local_addresses"? no (matched "!+local_addresses" - cached)
r2 router skipped: senders mismatch
--------> r3 router <--------
@@ -57,7 +57,7 @@ seeking password data for user "CALLER": using cached result
getpwnam() succeeded uid=CALLER_UID gid=CALLER_GID
checking senders
cached yes match for +local_addresses
-cached lookup data = test.ex
+cached lookup data = CALLER@test.ex
CALLER@test.ex in "+local_addresses"? yes (matched "+local_addresses" - cached)
calling r3 router
r3 router called for CALLER@test.ex