From 84227d174eec333d01ff494695bea0febf11575e Mon Sep 17 00:00:00 2001 From: "Heiko Schlittermann (HS12-RIPE)" Date: Mon, 19 Apr 2021 22:23:14 +0200 Subject: [PATCH] Honour the outcome of parse_extract_address(), testsuite 471 (cherry picked from commit 39d83bf19fc0c4364e0a665360b14194c62e4ab4) --- src/src/exim.c | 9 ++-- src/src/receive.c | 9 ++-- src/src/rewrite.c | 14 +++++- test/log/0471 | 1 + test/scripts/0000-Basic/0471 | 4 ++ test/stderr/0471 | 89 +++++++++++++++++++++++++++++++++--- 6 files changed, 110 insertions(+), 16 deletions(-) diff --git a/src/src/exim.c b/src/src/exim.c index a5f0bd578..6a9a1477f 100644 --- a/src/src/exim.c +++ b/src/src/exim.c @@ -5593,11 +5593,12 @@ while (more) parse_extract_address(s, &errmess, &start, &end, &domain, FALSE); #ifdef SUPPORT_I18N - if (string_is_utf8(recipient)) - message_smtputf8 = TRUE; - else - allow_utf8_domains = b; + if (recipient) + if (string_is_utf8(recipient)) message_smtputf8 = TRUE; + else allow_utf8_domains = b; } +#else + ; #endif if (domain == 0 && !f.allow_unqualified_recipient) { diff --git a/src/src/receive.c b/src/src/receive.c index 750744016..2223d4645 100644 --- a/src/src/receive.c +++ b/src/src/receive.c @@ -2561,11 +2561,12 @@ if (extract_recip) &domain, FALSE); #ifdef SUPPORT_I18N - if (string_is_utf8(recipient)) - message_smtputf8 = TRUE; - else - allow_utf8_domains = b; + if (recipient) + if (string_is_utf8(recipient)) message_smtputf8 = TRUE; + else allow_utf8_domains = b; } +#else + ; #endif /* Keep a list of all the bad addresses so we can send a single diff --git a/src/src/rewrite.c b/src/src/rewrite.c index ab5f78020..f40c73c51 100644 --- a/src/src/rewrite.c +++ b/src/src/rewrite.c @@ -468,8 +468,9 @@ while (*s) { uschar *sprev; uschar *ss = parse_find_address_end(s, FALSE); - uschar *recipient, *new, *errmess; + uschar *recipient, *new; rmark loop_reset_point = store_mark(); + uschar *errmess = NULL; BOOL changed = FALSE; int terminator = *ss; int start, end, domain; @@ -486,10 +487,19 @@ while (*s) while (isspace(*s)) s++; /* There isn't much we can do for syntactic disasters at this stage. - Pro tem (possibly for ever) ignore them. */ + Pro tem (possibly for ever) ignore them. + If we got nothing, they there was any sort of error: non-parsable address, + empty address, overlong addres. Sometimes the result matters, sometimes not. + It seems this function is called for *any* header we see. */ + if (!recipient) { + if (rewrite_rules || routed_old) + { + 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/log/0471 b/test/log/0471 index fc09b4692..96d495748 100644 --- a/test/log/0471 +++ b/test/log/0471 @@ -1,3 +1,4 @@ 1999-03-02 09:44:33 10HmaX-0005vi-00 <= CALLER@myhost.test.ex U=CALLER P=local S=sss for r1@test.ex 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... diff --git a/test/scripts/0000-Basic/0471 b/test/scripts/0000-Basic/0471 index e01ca28d2..9cf52943f 100644 --- a/test/scripts/0000-Basic/0471 +++ b/test/scripts/0000-Basic/0471 @@ -167,6 +167,10 @@ exim -d -odq r2@test.ex 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 **** no_msglog_check diff --git a/test/stderr/0471 b/test/stderr/0471 index 76b9b4a56..070b8447c 100644 --- a/test/stderr/0471 +++ b/test/stderr/0471 @@ -25894,7 +25894,7 @@ Recipients: r3@test.ex search_tidyup called >>Headers received: -To: localpart_with_256_chars_5678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456@test.example +To: localpart_with_236_chars_56789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456@test.example address match test: subject=r3@test.ex pattern=^.{40,}@* r3@test.ex in "^.{40,}@*"? no (end of list) @@ -25953,11 +25953,11 @@ CALLER@myhost.test.ex in "*@*"? yes (matched "*@*") lookup failed rewritten sender = CALLER@myhost.test.ex rewrite_one_header: type=T: - To: localpart_with_256_chars_5678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456@test.example -address match test: subject=localpart_with_256_chars_5678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456@test.example pattern=^.{40,}@* -localpart_with_256_chars_5678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456@test.example in "^.{40,}@*"? yes (matched "^.{40,}@*") + To: localpart_with_236_chars_56789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456@test.example +address match test: subject=localpart_with_236_chars_56789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456@test.example pattern=^.{40,}@* +localpart_with_236_chars_56789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456@test.example in "^.{40,}@*"? yes (matched "^.{40,}@*") LOG: address_rewrite MAIN - "localpart_with_256_chars_5678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456@test.example" from to: rewritten as "deny_me@test.example" by rule 1 + "localpart_with_236_chars_56789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456@test.example" from to: rewritten as "deny_me@test.example" by rule 1 address match test: subject=deny_me@test.example pattern=*@* test.example in "*"? yes (matched "*") deny_me@test.example in "*@*"? yes (matched "*@*") @@ -26012,7 +26012,7 @@ CALLER@myhost.test.ex in "*@*"? yes (matched "*@*") lookup failed search_tidyup called >>Headers after rewriting and local additions: -* To: localpart_with_256_chars_5678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456@test.example +* To: localpart_with_236_chars_56789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456@test.example T To: deny_me@rwtest.example I Message-Id: F From: CALLER_NAME @@ -26034,3 +26034,80 @@ LOG: MAIN <= CALLER@myhost.test.ex U=CALLER P=local S=sss search_tidyup called >>>>>>>>>>>>>>>> Exim pid=pppp (fresh-exec) terminating with rc=0 >>>>>>>>>>>>>>>> +Exim version x.yz .... +changed uid/gid: forcing real = effective + uid=uuuu gid=CALLER_GID pid=pppp +configuration file is TESTSUITE/test-config +admin user +changed uid/gid: privilege not needed + uid=EXIM_UID gid=EXIM_GID pid=pppp +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 +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: + r4@test.ex +search_tidyup called +>>Headers received: +To: localpart_with_256_chars_5678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456@test.example + +address match test: subject=r4@test.ex pattern=^.{40,}@* +r4@test.ex in "^.{40,}@*"? no (end of list) +address match test: subject=r4@test.ex pattern=*@* +test.ex in "*"? yes (matched "*") +r4@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 + 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 + lookup failed +address match test: subject=CALLER@myhost.test.ex pattern=^.{40,}@* +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 + 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 + 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_one_header: type=T: + 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=pppp (fresh-exec) terminating with rc=1 >>>>>>>>>>>>>>>> -- 2.30.2