summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Harris <jgh146exb@wizmail.org>2022-07-12 22:14:04 +0100
committerJeremy Harris <jgh146exb@wizmail.org>2022-07-12 22:15:04 +0100
commite7ec503729970a03d4509921342bc81313976126 (patch)
tree87ee1e025fd13b75aec66878a190d06d9be93327
parent18e8acda27c24cb66295071e4b21c1a73ca83e40 (diff)
downloadexim4-e7ec503729970a03d4509921342bc81313976126.tar.gz
Fix exit on attempt to rewrite a malformed address. Bug 2903
-rw-r--r--doc/doc-txt/ChangeLog5
-rw-r--r--src/src/rewrite.c9
-rw-r--r--test/confs/04717
-rw-r--r--test/log/04715
-rw-r--r--test/scripts/0000-Basic/04714
-rw-r--r--test/stderr/0471245
6 files changed, 267 insertions, 8 deletions
diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog
index 02ea32aa3..874d725f3 100644
--- a/doc/doc-txt/ChangeLog
+++ b/doc/doc-txt/ChangeLog
@@ -14,6 +14,11 @@ JH/02 Option default value updates:
JH/03 Cache static regex pattern compilations, for use by ACLs.
+JH/04 Bug 2903: avoid exit on an attempt to rewrite a malformed address.
+ Make the rewrite never match and keep the logging. Trust the
+ admin to be using verify=header-syntax (to actually reject the message).
+
+
Exim version 4.96
-----------------
diff --git a/src/src/rewrite.c b/src/src/rewrite.c
index bfd78b5f1..90614e626 100644
--- a/src/src/rewrite.c
+++ b/src/src/rewrite.c
@@ -497,15 +497,14 @@ while (*s)
if (!recipient)
{
- /* Handle unparesable addresses in the header. Slightly ugly because a
+ /* Log unparesable addresses in the header. Slightly ugly because a
null output from the extract can also result from a header without an
- address, "To: undisclosed recpients:;" being the classic case. */
+ address, "To: undisclosed recpients:;" being the classic case. Ignore
+ this one and carry on. */
if ((rewrite_rules || routed_old) && Ustrcmp(errmess, "empty address") != 0)
- {
log_write(0, LOG_MAIN, "rewrite: %s", errmess);
- exim_exit(EXIT_FAILURE);
- }
+
loop_reset_point = store_reset(loop_reset_point);
continue;
}
diff --git a/test/confs/0471 b/test/confs/0471
index a6b8a17ef..dcd476d4a 100644
--- a/test/confs/0471
+++ b/test/confs/0471
@@ -7,7 +7,14 @@ log_selector = +received_recipients
# ----- Main settings -----
+acl_not_smtp = check
+begin acl
+
+check:
+ warn !verify = header_syntax
+ logwrite = verify header_syntax fails
+ accept
# ----- Rewrite -----
diff --git a/test/log/0471 b/test/log/0471
index 7b974f7f6..9ad2e0d6c 100644
--- a/test/log/0471
+++ b/test/log/0471
@@ -2,4 +2,9 @@
1999-03-02 09:44:33 10HmaY-0005vi-00 <= CALLER@myhost.test.ex U=CALLER P=local S=sss for r2@test.ex
1999-03-02 09:44:33 10HmaZ-0005vi-00 <= CALLER@myhost.test.ex U=CALLER P=local S=sss for r3@test.ex
1999-03-02 09:44:33 10HmbA-0005vi-00 rewrite: address is ridiculously long: localpart_with_256_chars_567890123456789012345678901234567890123...
+1999-03-02 09:44:33 10HmbA-0005vi-00 verify header_syntax fails
+1999-03-02 09:44:33 10HmbA-0005vi-00 <= CALLER@myhost.test.ex U=CALLER P=local S=sss for r4@test.ex
1999-03-02 09:44:33 10HmbB-0005vi-00 <= CALLER@myhost.test.ex U=CALLER P=local S=sss for r5@test.ex
+1999-03-02 09:44:33 10HmbC-0005vi-00 rewrite: domain missing or malformed
+1999-03-02 09:44:33 10HmbC-0005vi-00 verify header_syntax fails
+1999-03-02 09:44:33 10HmbC-0005vi-00 <= CALLER@myhost.test.ex U=CALLER P=local S=sss for r6@test.ex
diff --git a/test/scripts/0000-Basic/0471 b/test/scripts/0000-Basic/0471
index 1154e78c4..423aec16f 100644
--- a/test/scripts/0000-Basic/0471
+++ b/test/scripts/0000-Basic/0471
@@ -169,11 +169,13 @@ To: localpart_with_056_chars_56789012345678901234567890123456@test.example
exim -d -odq r3@test.ex
To: localpart_with_236_chars_56789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456@test.example
****
-1
exim -d -odq r4@test.ex
To: localpart_with_256_chars_5678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456@test.example
****
exim -d -odq r5@test.ex
To: undisclosed recpients:;
****
+exim -d -odq r6@test.ex
+To: fred@
+****
no_msglog_check
diff --git a/test/stderr/0471 b/test/stderr/0471
index 7e4d62809..19058d4ff 100644
--- a/test/stderr/0471
+++ b/test/stderr/0471
@@ -25880,6 +25880,13 @@ P Received: from CALLER by myhost.test.ex with local (Exim x.yz)
id 10HmaX-0005vi-00
for r1@test.ex;
Tue, 2 Mar 1999 09:44:33 +0000
+using ACL "check"
+processing "warn" (TESTSUITE/test-config 15)
+check !verify = header_syntax
+warn: condition test failed in ACL "check"
+processing "accept" (TESTSUITE/test-config 17)
+accept: condition test succeeded in ACL "check"
+end of ACL "check": ACCEPT
Writing spool header file: TESTSUITE/spool//input//hdr.10HmaX-0005vi-00
DSN: **** SPOOL_OUT - address: <r1@test.ex> errorsto: <NULL> orcpt: <NULL> dsn_flags: 0x0
Renaming spool header file: TESTSUITE/spool//input//10HmaX-0005vi-00-H
@@ -26046,6 +26053,13 @@ P Received: from CALLER by myhost.test.ex with local (Exim x.yz)
id 10HmaY-0005vi-00
for r2@test.ex;
Tue, 2 Mar 1999 09:44:33 +0000
+using ACL "check"
+processing "warn" (TESTSUITE/test-config 15)
+check !verify = header_syntax
+warn: condition test failed in ACL "check"
+processing "accept" (TESTSUITE/test-config 17)
+accept: condition test succeeded in ACL "check"
+end of ACL "check": ACCEPT
Writing spool header file: TESTSUITE/spool//input//hdr.10HmaY-0005vi-00
DSN: **** SPOOL_OUT - address: <r2@test.ex> errorsto: <NULL> orcpt: <NULL> dsn_flags: 0x0
Renaming spool header file: TESTSUITE/spool//input//10HmaY-0005vi-00-H
@@ -26211,6 +26225,13 @@ P Received: from CALLER by myhost.test.ex with local (Exim x.yz)
id 10HmaZ-0005vi-00
for r3@test.ex;
Tue, 2 Mar 1999 09:44:33 +0000
+using ACL "check"
+processing "warn" (TESTSUITE/test-config 15)
+check !verify = header_syntax
+warn: condition test failed in ACL "check"
+processing "accept" (TESTSUITE/test-config 17)
+accept: condition test succeeded in ACL "check"
+end of ACL "check": ACCEPT
Writing spool header file: TESTSUITE/spool//input//hdr.10HmaZ-0005vi-00
DSN: **** SPOOL_OUT - address: <r3@test.ex> errorsto: <NULL> orcpt: <NULL> dsn_flags: 0x0
Renaming spool header file: TESTSUITE/spool//input//10HmaZ-0005vi-00-H
@@ -26304,8 +26325,71 @@ rewrite headers
To: localpart_with_256_chars_5678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456@test.example
LOG: MAIN
rewrite: address is ridiculously long: localpart_with_256_chars_567890123456789012345678901234567890123...
- search_tidyup called
->>>>>>>>>>>>>>>> Exim pid=p1237 (fresh-exec) terminating with rc=1 >>>>>>>>>>>>>>>>
+ rewrite_one_header: type=F:
+ From: CALLER_NAME <CALLER@myhost.test.ex>
+ address match test: subject=CALLER@myhost.test.ex pattern=^.{40,}@*
+ compiled RE '^.{40,}@*' found in local cache
+ CALLER@myhost.test.ex in "^.{40,}@*"? no (end of list)
+ address match test: subject=CALLER@myhost.test.ex pattern=*@*
+ myhost.test.ex in "*"? yes (matched "*")
+ CALLER@myhost.test.ex in "*@*"? yes (matched "*@*")
+ search_open: lsearch "TESTSUITE/aux-fixed/0471.rw"
+ cached open
+ search_find: file="TESTSUITE/aux-fixed/0471.rw"
+ key="myhost.test.ex" partial=2 affix=*. starflags=0 opts=NULL
+ LRU list:
+ 0TESTSUITE/aux-fixed/0471.rw
+ End
+ internal_search_find: file="TESTSUITE/aux-fixed/0471.rw"
+ type=lsearch key="myhost.test.ex" opts=NULL
+ cached data used for lookup of myhost.test.ex
+ in TESTSUITE/aux-fixed/0471.rw
+ lookup failed
+ trying partial match *.myhost.test.ex
+ internal_search_find: file="TESTSUITE/aux-fixed/0471.rw"
+ type=lsearch key="*.myhost.test.ex" opts=NULL
+ cached data used for lookup of *.myhost.test.ex
+ in TESTSUITE/aux-fixed/0471.rw
+ lookup failed
+ trying partial match *.test.ex
+ internal_search_find: file="TESTSUITE/aux-fixed/0471.rw"
+ type=lsearch key="*.test.ex" opts=NULL
+ cached data used for lookup of *.test.ex
+ in TESTSUITE/aux-fixed/0471.rw
+ lookup failed
+search_tidyup called
+>>Headers after rewriting and local additions:
+T To: localpart_with_256_chars_5678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456@test.example
+I Message-Id: <E10HmbA-0005vi-00@myhost.test.ex>
+F From: CALLER_NAME <CALLER@myhost.test.ex>
+ Date: Tue, 2 Mar 1999 09:44:33 +0000
+
+Data file name: TESTSUITE/spool//input//10HmbA-0005vi-00-D
+Data file written for message 10HmbA-0005vi-00
+>>Generated Received: header line
+P Received: from CALLER by myhost.test.ex with local (Exim x.yz)
+ (envelope-from <CALLER@myhost.test.ex>)
+ id 10HmbA-0005vi-00
+ for r4@test.ex;
+ Tue, 2 Mar 1999 09:44:33 +0000
+using ACL "check"
+processing "warn" (TESTSUITE/test-config 15)
+check !verify = header_syntax
+check logwrite = verify header_syntax fails
+LOG: MAIN
+ verify header_syntax fails
+warn: condition test succeeded in ACL "check"
+processing "accept" (TESTSUITE/test-config 17)
+accept: condition test succeeded in ACL "check"
+end of ACL "check": ACCEPT
+Writing spool header file: TESTSUITE/spool//input//hdr.10HmbA-0005vi-00
+DSN: **** SPOOL_OUT - address: <r4@test.ex> errorsto: <NULL> orcpt: <NULL> dsn_flags: 0x0
+Renaming spool header file: TESTSUITE/spool//input//10HmbA-0005vi-00-H
+Size of headers = sss
+LOG: MAIN
+ <= CALLER@myhost.test.ex U=CALLER P=local S=sss
+search_tidyup called
+>>>>>>>>>>>>>>>> Exim pid=p1237 (fresh-exec) terminating with rc=0 >>>>>>>>>>>>>>>>
Exim version x.yz ....
changed uid/gid: forcing real = effective
uid=uuuu gid=CALLER_GID pid=p1238
@@ -26436,6 +26520,13 @@ P Received: from CALLER by myhost.test.ex with local (Exim x.yz)
id 10HmbB-0005vi-00
for r5@test.ex;
Tue, 2 Mar 1999 09:44:33 +0000
+using ACL "check"
+processing "warn" (TESTSUITE/test-config 15)
+check !verify = header_syntax
+warn: condition test failed in ACL "check"
+processing "accept" (TESTSUITE/test-config 17)
+accept: condition test succeeded in ACL "check"
+end of ACL "check": ACCEPT
Writing spool header file: TESTSUITE/spool//input//hdr.10HmbB-0005vi-00
DSN: **** SPOOL_OUT - address: <r5@test.ex> errorsto: <NULL> orcpt: <NULL> dsn_flags: 0x0
Renaming spool header file: TESTSUITE/spool//input//10HmbB-0005vi-00-H
@@ -26444,3 +26535,153 @@ LOG: MAIN
<= CALLER@myhost.test.ex U=CALLER P=local S=sss
search_tidyup called
>>>>>>>>>>>>>>>> Exim pid=p1238 (fresh-exec) terminating with rc=0 >>>>>>>>>>>>>>>>
+Exim version x.yz ....
+changed uid/gid: forcing real = effective
+ uid=uuuu gid=CALLER_GID pid=p1239
+configuration file is TESTSUITE/test-config
+admin user
+changed uid/gid: privilege not needed
+ uid=EXIM_UID gid=EXIM_GID pid=p1239
+originator: uid=CALLER_UID gid=CALLER_GID login=CALLER name=CALLER_NAME
+sender address = CALLER@myhost.test.ex
+set_process_info: pppp accepting a local non-SMTP message from <CALLER@myhost.test.ex>
+spool directory space = nnnnnK inodes = nnnnn check_space = 10240K inodes = 100 msg_size = 0
+log directory space = nnnnnK inodes = nnnnn check_space = 10240K inodes = 100
+Sender: CALLER@myhost.test.ex
+Recipients:
+ r6@test.ex
+search_tidyup called
+>>Headers received:
+To: fred@
+
+qualify & rewrite recipients list
+ address match test: subject=r6@test.ex pattern=^.{40,}@*
+ compiled RE '^.{40,}@*' not found in local cache
+ compiled RE '^.{40,}@*' saved in local cache
+ r6@test.ex in "^.{40,}@*"? no (end of list)
+ address match test: subject=r6@test.ex pattern=*@*
+ test.ex in "*"? yes (matched "*")
+ r6@test.ex in "*@*"? yes (matched "*@*")
+ search_open: lsearch "TESTSUITE/aux-fixed/0471.rw"
+ search_find: file="TESTSUITE/aux-fixed/0471.rw"
+ key="test.ex" partial=2 affix=*. starflags=0 opts=NULL
+ LRU list:
+ 0TESTSUITE/aux-fixed/0471.rw
+ End
+ internal_search_find: file="TESTSUITE/aux-fixed/0471.rw"
+ type=lsearch key="test.ex" opts=NULL
+ file lookup required for test.ex
+ in TESTSUITE/aux-fixed/0471.rw
+ creating new cache entry
+ lookup failed
+ trying partial match *.test.ex
+ internal_search_find: file="TESTSUITE/aux-fixed/0471.rw"
+ type=lsearch key="*.test.ex" opts=NULL
+ file lookup required for *.test.ex
+ in TESTSUITE/aux-fixed/0471.rw
+ creating new cache entry
+ lookup failed
+global rewrite rules
+ address match test: subject=CALLER@myhost.test.ex pattern=^.{40,}@*
+ compiled RE '^.{40,}@*' found in local cache
+ CALLER@myhost.test.ex in "^.{40,}@*"? no (end of list)
+ address match test: subject=CALLER@myhost.test.ex pattern=*@*
+ myhost.test.ex in "*"? yes (matched "*")
+ CALLER@myhost.test.ex in "*@*"? yes (matched "*@*")
+ search_open: lsearch "TESTSUITE/aux-fixed/0471.rw"
+ cached open
+ search_find: file="TESTSUITE/aux-fixed/0471.rw"
+ key="myhost.test.ex" partial=2 affix=*. starflags=0 opts=NULL
+ LRU list:
+ 0TESTSUITE/aux-fixed/0471.rw
+ End
+ internal_search_find: file="TESTSUITE/aux-fixed/0471.rw"
+ type=lsearch key="myhost.test.ex" opts=NULL
+ file lookup required for myhost.test.ex
+ in TESTSUITE/aux-fixed/0471.rw
+ creating new cache entry
+ lookup failed
+ trying partial match *.myhost.test.ex
+ internal_search_find: file="TESTSUITE/aux-fixed/0471.rw"
+ type=lsearch key="*.myhost.test.ex" opts=NULL
+ file lookup required for *.myhost.test.ex
+ in TESTSUITE/aux-fixed/0471.rw
+ creating new cache entry
+ lookup failed
+ trying partial match *.test.ex
+ internal_search_find: file="TESTSUITE/aux-fixed/0471.rw"
+ type=lsearch key="*.test.ex" opts=NULL
+ cached data used for lookup of *.test.ex
+ in TESTSUITE/aux-fixed/0471.rw
+ lookup failed
+rewritten sender = CALLER@myhost.test.ex
+rewrite headers
+ rewrite_one_header: type=T:
+ To: fred@
+LOG: MAIN
+ rewrite: domain missing or malformed
+ rewrite_one_header: type=F:
+ From: CALLER_NAME <CALLER@myhost.test.ex>
+ address match test: subject=CALLER@myhost.test.ex pattern=^.{40,}@*
+ compiled RE '^.{40,}@*' found in local cache
+ CALLER@myhost.test.ex in "^.{40,}@*"? no (end of list)
+ address match test: subject=CALLER@myhost.test.ex pattern=*@*
+ myhost.test.ex in "*"? yes (matched "*")
+ CALLER@myhost.test.ex in "*@*"? yes (matched "*@*")
+ search_open: lsearch "TESTSUITE/aux-fixed/0471.rw"
+ cached open
+ search_find: file="TESTSUITE/aux-fixed/0471.rw"
+ key="myhost.test.ex" partial=2 affix=*. starflags=0 opts=NULL
+ LRU list:
+ 0TESTSUITE/aux-fixed/0471.rw
+ End
+ internal_search_find: file="TESTSUITE/aux-fixed/0471.rw"
+ type=lsearch key="myhost.test.ex" opts=NULL
+ cached data used for lookup of myhost.test.ex
+ in TESTSUITE/aux-fixed/0471.rw
+ lookup failed
+ trying partial match *.myhost.test.ex
+ internal_search_find: file="TESTSUITE/aux-fixed/0471.rw"
+ type=lsearch key="*.myhost.test.ex" opts=NULL
+ cached data used for lookup of *.myhost.test.ex
+ in TESTSUITE/aux-fixed/0471.rw
+ lookup failed
+ trying partial match *.test.ex
+ internal_search_find: file="TESTSUITE/aux-fixed/0471.rw"
+ type=lsearch key="*.test.ex" opts=NULL
+ cached data used for lookup of *.test.ex
+ in TESTSUITE/aux-fixed/0471.rw
+ lookup failed
+search_tidyup called
+>>Headers after rewriting and local additions:
+T To: fred@
+I Message-Id: <E10HmbC-0005vi-00@myhost.test.ex>
+F From: CALLER_NAME <CALLER@myhost.test.ex>
+ Date: Tue, 2 Mar 1999 09:44:33 +0000
+
+Data file name: TESTSUITE/spool//input//10HmbC-0005vi-00-D
+Data file written for message 10HmbC-0005vi-00
+>>Generated Received: header line
+P Received: from CALLER by myhost.test.ex with local (Exim x.yz)
+ (envelope-from <CALLER@myhost.test.ex>)
+ id 10HmbC-0005vi-00
+ for r6@test.ex;
+ Tue, 2 Mar 1999 09:44:33 +0000
+using ACL "check"
+processing "warn" (TESTSUITE/test-config 15)
+check !verify = header_syntax
+check logwrite = verify header_syntax fails
+LOG: MAIN
+ verify header_syntax fails
+warn: condition test succeeded in ACL "check"
+processing "accept" (TESTSUITE/test-config 17)
+accept: condition test succeeded in ACL "check"
+end of ACL "check": ACCEPT
+Writing spool header file: TESTSUITE/spool//input//hdr.10HmbC-0005vi-00
+DSN: **** SPOOL_OUT - address: <r6@test.ex> errorsto: <NULL> orcpt: <NULL> dsn_flags: 0x0
+Renaming spool header file: TESTSUITE/spool//input//10HmbC-0005vi-00-H
+Size of headers = sss
+LOG: MAIN
+ <= CALLER@myhost.test.ex U=CALLER P=local S=sss
+search_tidyup called
+>>>>>>>>>>>>>>>> Exim pid=p1239 (fresh-exec) terminating with rc=0 >>>>>>>>>>>>>>>>