From 12fab4b0af476cf9d4bd389a2c4ebf7ff76e8252 Mon Sep 17 00:00:00 2001 From: Jeremy Harris Date: Sun, 31 Dec 2023 22:12:17 +0000 Subject: [PATCH] Address qualification: ensure maformed addresses are logged. Bug 3061 --- doc/doc-txt/ChangeLog | 3 +++ src/src/rewrite.c | 4 ++-- test/log/0026 | 4 ++++ test/log/0072 | 1 + test/log/0162 | 3 +++ test/log/0214 | 1 + test/log/0365 | 4 ++++ test/log/0465 | 1 + test/log/0471 | 4 ++-- test/log/0560 | 2 ++ test/log/4004 | 1 + test/log/4207 | 3 +++ test/log/5701 | 1 + test/stderr/0026 | 1 + test/stderr/0086 | 5 +++++ test/stderr/0087 | 1 + test/stderr/0121 | 1 + test/stderr/0249 | 2 +- test/stderr/0465 | 2 ++ test/stderr/0471 | 4 ++-- test/stderr/0569 | 1 + 21 files changed, 42 insertions(+), 7 deletions(-) diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog index 49d81084d..21c84e091 100644 --- a/doc/doc-txt/ChangeLog +++ b/doc/doc-txt/ChangeLog @@ -72,6 +72,9 @@ JH/14 Bug 3061: Avoid a split log line when trtying to rewrite a malformed there is only one) the terminating newline was part of the logged information. +JH/15 Bug 3061: Ensure a log line is written for a malformed address in a + header, when parsing for address-qualification. Previously one was only + written if there were rewrite rules. Exim version 4.97 diff --git a/src/src/rewrite.c b/src/src/rewrite.c index 318cda215..70bd79e26 100644 --- a/src/src/rewrite.c +++ b/src/src/rewrite.c @@ -510,8 +510,8 @@ while (*s) 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); + if (Ustrcmp(errmess, "empty address") != 0) + log_write(0, LOG_MAIN, "qualify/rewrite: %s", errmess); loop_reset_point = store_reset(loop_reset_point); continue; diff --git a/test/log/0026 b/test/log/0026 index a537c7a25..5974b7ced 100644 --- a/test/log/0026 +++ b/test/log/0026 @@ -1,9 +1,13 @@ 1999-03-02 09:44:33 10HmbD-000000005vi-0000 $h_from: 'x@y' 1999-03-02 09:44:33 10HmbD-000000005vi-0000 <= x@y U=CALLER P=local-smtp S=sss +1999-03-02 09:44:33 10HmaX-000000005vi-0000 qualify/rewrite: domain missing or malformed 1999-03-02 09:44:33 10HmaX-000000005vi-0000 $h_from: '@' 1999-03-02 09:44:33 10HmaX-000000005vi-0000 U=CALLER F= rejected after DATA: domain missing or malformed: failing address in "From:" header is: @ +1999-03-02 09:44:33 10HmaY-000000005vi-0000 qualify/rewrite: '>' missing at end of address +1999-03-02 09:44:33 10HmaY-000000005vi-0000 qualify/rewrite: '>' missing at end of address 1999-03-02 09:44:33 10HmaY-000000005vi-0000 $h_from: ' rejected after DATA: '>' missing at end of address: failing address in "To:" header is: , @' 1999-03-02 09:44:33 10HmaZ-000000005vi-0000 U=CALLER F=<> rejected after DATA: domain missing or malformed: failing address in "From:" header is: @ 1999-03-02 09:44:33 10HmbA-000000005vi-0000 $h_from: '' diff --git a/test/log/0072 b/test/log/0072 index 0730df728..89789a459 100644 --- a/test/log/0072 +++ b/test/log/0072 @@ -31,6 +31,7 @@ 1999-03-02 09:44:33 10HmbH-000000005vi-0000 Completed 1999-03-02 09:44:33 10HmbG-000000005vi-0000 => userx R=reply T=reply 1999-03-02 09:44:33 10HmbG-000000005vi-0000 Completed +1999-03-02 09:44:33 10HmbI-000000005vi-0000 qualify/rewrite: missing or malformed local part (expected word or "<") 1999-03-02 09:44:33 10HmbI-000000005vi-0000 <= CALLER@test.ex U=CALLER P=local S=sss 1999-03-02 09:44:33 10HmbI-000000005vi-0000 ** >**bad-reply** R=filter: filter autoreply generated syntactically invalid recipient 1999-03-02 09:44:33 10HmbI-000000005vi-0000 >**bad-reply** : error ignored diff --git a/test/log/0162 b/test/log/0162 index f463f6931..3ea2941cc 100644 --- a/test/log/0162 +++ b/test/log/0162 @@ -1 +1,4 @@ +1999-03-02 09:44:33 10HmaX-000000005vi-0000 qualify/rewrite: malformed address: ">, + , + may not follow rejected after DATA: malformed address: ">,\n ,\n may not follow ,\n ,\n ,\n ,\n ,\n ,\n ,\n ,\n ,\n ,\n ,\n ,\n ,\n ,\n ,\n ,\n ,\n ,\n ,\n ,\n ,\n ,\n ,\n ,\n ,\n ,\n ,\n ,\n ,\n ,\n ,\n ,\n ,\n ,\n ,\n ,\n ,\n ,\n ,\n ,\n ,\n ,\n rejected after DATA: malformed address: ;bad@address;bad@address;bad@add may not follow bad@address: failing address in "To:" header begins: bad@address;bad@address;bad@address;bad@address;bad@address;bad@address;\n bad@address;bad@address;bad@address;bad@address;bad@address;bad@address;\n bad@address;bad@address;bad@address;bad@address;bad@address;bad@address;\n bad@address;bad@address;bad@address;bad@address;bad@address;bad@address;\n bad@address;bad@address;bad@address;bad@address;bad@address;bad@address;\n bad@address;bad@address;bad@address;bad@address;bad@address;bad@address;\n bad@address;bad@address;bad@address;bad@address;bad@address;bad@address;\n bad@address;bad@address;bad@address;bad@address;bad@address;bad@address;\n bad@address;bad@address;bad@address;bad@address;bad@address;bad@address;\n bad@address;bad@address;bad@address;bad@address;bad@address;bad@address;\n bad@address;bad@address;bad@address;bad@address;bad@address;bad@address;\n bad@address;bad@address;bad@address;bad@address;bad@address;bad@address;\n bad@address;bad@address;bad@address;bad@address;bad@address;bad@address;\n bad@address;bad@address diff --git a/test/log/0365 b/test/log/0365 index a484a8b17..55ae1c787 100644 --- a/test/log/0365 +++ b/test/log/0365 @@ -1,19 +1,23 @@ +1999-03-02 09:44:33 10HmaX-000000005vi-0000 qualify/rewrite: '>' missing at end of address 1999-03-02 09:44:33 10HmaX-000000005vi-0000 U=CALLER F=<> rejected after DATA: '>' missing at end of address: failing address in "From:" header is: rejected after DATA: there is no valid sender in any header line 1999-03-02 09:44:33 recipient verify defer (making calloout connection): T=smtp Network Error 1999-03-02 09:44:33 U=CALLER sender verify defer for : Could not complete sender verify callout: V4NET.0.0.0 [V4NET.0.0.0] : Network Error 1999-03-02 09:44:33 U=CALLER F= temporarily rejected RCPT : Could not complete sender verify callout +1999-03-02 09:44:33 10HmaZ-000000005vi-0000 qualify/rewrite: '>' missing at end of address 1999-03-02 09:44:33 10HmaZ-000000005vi-0000 U=CALLER F= rejected after DATA 1999-03-02 09:44:33 10HmbA-000000005vi-0000 U=CALLER F=<> rejected after DATA: there is no valid sender in any header line 1999-03-02 09:44:33 sender verify defer (making calloout connection): T=smtp Network Error 1999-03-02 09:44:33 U=CALLER F= temporarily rejected RCPT : Could not complete recipient verify callout: V4NET.0.0.0 [V4NET.0.0.0] : Network Error 1999-03-02 09:44:33 U=CALLER F=<> rejected RCPT : failure message 1999-03-02 09:44:33 U=CALLER F=<> temporarily rejected RCPT : defer message +1999-03-02 09:44:33 10HmbB-000000005vi-0000 qualify/rewrite: '>' missing at end of address 1999-03-02 09:44:33 10HmbB-000000005vi-0000 U=CALLER F=<> rejected after DATA: '>' missing at end of address: failing address in "From:" header is: rejected after DATA: there is no valid sender in any header line 1999-03-02 09:44:33 recipient verify defer (making calloout connection): T=smtp Network Error 1999-03-02 09:44:33 U=CALLER sender verify defer for : Could not complete sender verify callout: V4NET.0.0.0 [V4NET.0.0.0] : Network Error 1999-03-02 09:44:33 U=CALLER F= temporarily rejected RCPT : Could not complete sender verify callout +1999-03-02 09:44:33 10HmbD-000000005vi-0000 qualify/rewrite: '>' missing at end of address 1999-03-02 09:44:33 10HmbD-000000005vi-0000 U=CALLER F= rejected after DATA 1999-03-02 09:44:33 10HmbE-000000005vi-0000 U=CALLER F=<> rejected after DATA: there is no valid sender in any header line 1999-03-02 09:44:33 sender verify defer (making calloout connection): T=smtp Network Error diff --git a/test/log/0465 b/test/log/0465 index c8bc1458d..6b7628c32 100644 --- a/test/log/0465 +++ b/test/log/0465 @@ -1,3 +1,4 @@ 1999-03-02 09:44:33 10HmaY-000000005vi-0000 <= <> U=CALLER P=local-smtp S=sss 1999-03-02 09:44:33 10HmaZ-000000005vi-0000 <= abc@somewhere U=CALLER P=local S=sss +1999-03-02 09:44:33 10HmaX-000000005vi-0000 qualify/rewrite: domain missing or malformed 1999-03-02 09:44:33 10HmaX-000000005vi-0000 U=CALLER F=<> rejected after DATA: domain missing or malformed: failing address in "To:" header is: abc@xyz. diff --git a/test/log/0471 b/test/log/0471 index c80286d97..4d963cb55 100644 --- a/test/log/0471 +++ b/test/log/0471 @@ -1,10 +1,10 @@ 1999-03-02 09:44:33 10HmaX-000000005vi-0000 <= CALLER@myhost.test.ex U=CALLER P=local S=sss for r1@test.ex 1999-03-02 09:44:33 10HmaY-000000005vi-0000 <= CALLER@myhost.test.ex U=CALLER P=local S=sss for r2@test.ex 1999-03-02 09:44:33 10HmaZ-000000005vi-0000 <= CALLER@myhost.test.ex U=CALLER P=local S=sss for r3@test.ex -1999-03-02 09:44:33 10HmbA-000000005vi-0000 rewrite: address is ridiculously long: localpart_with_256_chars_567890123456789012345678901234567890123... +1999-03-02 09:44:33 10HmbA-000000005vi-0000 qualify/rewrite: address is ridiculously long: localpart_with_256_chars_567890123456789012345678901234567890123... 1999-03-02 09:44:33 10HmbA-000000005vi-0000 verify header_syntax fails 1999-03-02 09:44:33 10HmbA-000000005vi-0000 <= CALLER@myhost.test.ex U=CALLER P=local S=sss for r4@test.ex 1999-03-02 09:44:33 10HmbB-000000005vi-0000 <= CALLER@myhost.test.ex U=CALLER P=local S=sss for r5@test.ex -1999-03-02 09:44:33 10HmbC-000000005vi-0000 rewrite: domain missing or malformed +1999-03-02 09:44:33 10HmbC-000000005vi-0000 qualify/rewrite: domain missing or malformed 1999-03-02 09:44:33 10HmbC-000000005vi-0000 verify header_syntax fails 1999-03-02 09:44:33 10HmbC-000000005vi-0000 <= CALLER@myhost.test.ex U=CALLER P=local S=sss for r6@test.ex diff --git a/test/log/0560 b/test/log/0560 index 9be1ae0cf..f7d8b8993 100644 --- a/test/log/0560 +++ b/test/log/0560 @@ -1 +1,3 @@ +1999-03-02 09:44:33 10HmaX-000000005vi-0000 qualify/rewrite: malformed address: another@another.ex may not follow first@test.ex + 1999-03-02 09:44:33 10HmaX-000000005vi-0000 <= CALLER@myhost.test.ex U=CALLER P=local S=sss diff --git a/test/log/4004 b/test/log/4004 index 82e195fb9..5a04f6290 100644 --- a/test/log/4004 +++ b/test/log/4004 @@ -1,3 +1,4 @@ +1999-03-02 09:44:33 10HmaX-000000005vi-0000 qualify/rewrite: missing or malformed local part 1999-03-02 09:44:33 10HmaX-000000005vi-0000 U=CALLER Warning: reject Action: reject\n Symbol: FAKE_SYMBOL_A(15.00)\n Symbol: FAKE_SYMBOL_B(0.00)\n Message-ID: undef 1999-03-02 09:44:33 10HmaX-000000005vi-0000 <= CALLER@myhost.test.ex U=CALLER P=local-esmtp S=sss 1999-03-02 09:44:33 10HmaX-000000005vi-0000 => :blackhole: R=r diff --git a/test/log/4207 b/test/log/4207 index f3cc864c5..24521c670 100644 --- a/test/log/4207 +++ b/test/log/4207 @@ -10,8 +10,11 @@ ******** SERVER ******** 1999-03-02 09:44:33 exim x.yz daemon started: pid=p1234, no queue runs, listening for SMTP on port PORT_D +1999-03-02 09:44:33 10HmaY-000000005vi-0000 qualify/rewrite: domain missing or malformed 1999-03-02 09:44:33 10HmaY-000000005vi-0000 <= xn--ihqwcrb4cv8a8dqg056pqjye@hebrew.xn--4dbcagdahymbxekheh6e0a7fei0b.com H=localhost (the.local.host.name) [127.0.0.1] P=esmtp S=sss id=E10HmaX-000000005vi-0000@the.local.host.name for xn--user1.-g95ww2bm7c8xj18gesgrby74dwqh18as2ft0ab05f5nc9w1befas47alnaxwd256esy4hea33e@test.ex +1999-03-02 09:44:33 10HmbA-000000005vi-0000 qualify/rewrite: domain missing or malformed 1999-03-02 09:44:33 10HmbA-000000005vi-0000 <= xn--ihqwcrb4cv8a8dqg056pqjye@hebrew.xn--4dbcagdahymbxekheh6e0a7fei0b.com H=localhost (the.local.host.name) [127.0.0.1] P=esmtp S=sss id=E10HmaZ-000000005vi-0000@the.local.host.name for xn--user2.-g95ww2bm7c8xj18gesgrby74dwqh18as2ft0ab05f5nc9w1befas47alnaxwd256esy4hea33e@test.ex +1999-03-02 09:44:33 10HmbC-000000005vi-0000 qualify/rewrite: domain missing or malformed 1999-03-02 09:44:33 10HmbC-000000005vi-0000 <= xn--ihqwcrb4cv8a8dqg056pqjye@hebrew.xn--4dbcagdahymbxekheh6e0a7fei0b.com H=localhost (the.local.host.name) [127.0.0.1] P=esmtp S=sss id=E10HmbB-000000005vi-0000@the.local.host.name for xn--user3.-g95ww2bm7c8xj18gesgrby74dwqh18as2ft0ab05f5nc9w1befas47alnaxwd256esy4hea33e@test.ex 1999-03-02 09:44:33 Start queue run: pid=p1235 -qqff 1999-03-02 09:44:33 10HmaY-000000005vi-0000 => :blackhole: R=localuser diff --git a/test/log/5701 b/test/log/5701 index 531dc63f7..657f2f807 100644 --- a/test/log/5701 +++ b/test/log/5701 @@ -1,3 +1,4 @@ +1999-03-02 09:44:33 10HmaX-000000005vi-0000 qualify/rewrite: missing or malformed local part (expected word or "<") 1999-03-02 09:44:33 10HmaX-000000005vi-0000 <= CALLER@the.local.host.name U=CALLER P=local S=sss 1999-03-02 09:44:33 10HmaX-000000005vi-0000 ** >**bad-reply** R=router_filter T=reply: filter autoreply generated syntactically invalid recipient 1999-03-02 09:44:33 10HmaX-000000005vi-0000 event msg:fail:delivery diff --git a/test/stderr/0026 b/test/stderr/0026 index 5ab7d4da7..8fdd0ef01 100644 --- a/test/stderr/0026 +++ b/test/stderr/0026 @@ -14,6 +14,7 @@ >>> accept: condition test succeeded in inline ACL >>> end of inline ACL: ACCEPT >>> host in ignore_fromline_hosts? no (option unset) +LOG: 10HmbI-000000005vi-0000 qualify/rewrite: domain missing or malformed >>> using ACL "acl_data" >>> processing "deny" (TESTSUITE/test-config 21) >>> l_message: body contains trigger diff --git a/test/stderr/0086 b/test/stderr/0086 index ad5234ec9..0ff15c6aa 100644 --- a/test/stderr/0086 +++ b/test/stderr/0086 @@ -16,6 +16,7 @@ >>> accept: condition test succeeded in inline ACL >>> end of inline ACL: ACCEPT >>> host in ignore_fromline_hosts? no (option unset) +LOG: 10HmaY-000000005vi-0000 qualify/rewrite: '>' missing at end of address >>> using ACL "check_message" >>> processing "deny" (TESTSUITE/test-config 19) >>> check !verify = header_syntax @@ -43,6 +44,8 @@ LOG: 10HmaY-000000005vi-0000 H=(test) [V4NET.10.10.10] F= re >>> accept: condition test succeeded in inline ACL >>> end of inline ACL: ACCEPT >>> host in ignore_fromline_hosts? no (option unset) +LOG: 10HmaZ-000000005vi-0000 qualify/rewrite: '>' missing at end of address +LOG: 10HmaZ-000000005vi-0000 qualify/rewrite: '>' missing at end of address >>> using ACL "check_message" >>> processing "deny" (TESTSUITE/test-config 19) >>> check !verify = header_syntax @@ -70,6 +73,7 @@ LOG: 10HmaZ-000000005vi-0000 H=(test) [V4NET.10.10.10] F= re >>> accept: condition test succeeded in inline ACL >>> end of inline ACL: ACCEPT >>> host in ignore_fromline_hosts? no (option unset) +LOG: 10HmbA-000000005vi-0000 qualify/rewrite: '>' missing at end of address >>> using ACL "check_message" >>> processing "deny" (TESTSUITE/test-config 19) >>> check !verify = header_syntax @@ -97,6 +101,7 @@ LOG: 10HmbA-000000005vi-0000 H=(test) [V4NET.10.10.10] F= re >>> accept: condition test succeeded in inline ACL >>> end of inline ACL: ACCEPT >>> host in ignore_fromline_hosts? no (option unset) +LOG: 10HmbB-000000005vi-0000 qualify/rewrite: unmatched doublequote in local part >>> using ACL "check_message" >>> processing "deny" (TESTSUITE/test-config 19) >>> check !verify = header_syntax diff --git a/test/stderr/0087 b/test/stderr/0087 index 1226a7dfd..29ea14896 100644 --- a/test/stderr/0087 +++ b/test/stderr/0087 @@ -96,6 +96,7 @@ LOG: 10HmaX-000000005vi-0000 <= userx@test.ex H=(test) [V4NET.10.10.10] P=smtp S >>> accept: condition test succeeded in ACL "check_recipient" >>> end of ACL "check_recipient": ACCEPT >>> host in ignore_fromline_hosts? no (option unset) +LOG: 10HmaY-000000005vi-0000 qualify/rewrite: '>' missing at end of address >>> using ACL "check_message" >>> processing "require" (TESTSUITE/test-config 26) >>> check verify = header_sender diff --git a/test/stderr/0121 b/test/stderr/0121 index 8e6e33d1c..283bb7111 100644 --- a/test/stderr/0121 +++ b/test/stderr/0121 @@ -163,6 +163,7 @@ LOG: 10HmaX-000000005vi-0000 H=(test) [127.0.0.1] F= rejected aft >>> accept: condition test succeeded in ACL "check_recipient" >>> end of ACL "check_recipient": ACCEPT >>> host in ignore_fromline_hosts? no (option unset) +LOG: 10HmaY-000000005vi-0000 qualify/rewrite: missing or malformed local part >>> using ACL "check_message" >>> processing "require" (TESTSUITE/test-config 27) >>> check verify = header_sender diff --git a/test/stderr/0249 b/test/stderr/0249 index fd603f069..ff905a491 100644 --- a/test/stderr/0249 +++ b/test/stderr/0249 @@ -76,5 +76,5 @@ LOG: address_rewrite MAIN >>> list element: c.domain >>> some.domain in "c.domain"? no (end of list) >>> someone@some.domain in "*@c.domain"? no (end of list) -LOG: 10HmaX-000000005vi-0000 rewrite: malformed address: @c may not follow a@b +LOG: 10HmaX-000000005vi-0000 qualify/rewrite: malformed address: @c may not follow a@b LOG: 10HmaX-000000005vi-0000 <= a@b H=(tester) [127.0.0.1] P=smtp S=sss diff --git a/test/stderr/0465 b/test/stderr/0465 index 76820b09d..5bcd5a1ce 100644 --- a/test/stderr/0465 +++ b/test/stderr/0465 @@ -147,6 +147,8 @@ rewrite rules on sender address qualify and rewrite headers rewrite_one_header: type=T: To: abc@xyz. +LOG: MAIN + qualify/rewrite: domain missing or malformed search_tidyup called >>Headers after rewriting and local additions: T To: abc@xyz. diff --git a/test/stderr/0471 b/test/stderr/0471 index c1b27e63c..a0950c7a3 100644 --- a/test/stderr/0471 +++ b/test/stderr/0471 @@ -27373,7 +27373,7 @@ qualify and rewrite headers 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... + qualify/rewrite: address is ridiculously long: localpart_with_256_chars_567890123456789012345678901234567890123... rewrite_one_header: type=F: From: CALLER_NAME CALLER@myhost.test.ex in "^.{40,}@*"? @@ -27704,7 +27704,7 @@ qualify and rewrite headers rewrite_one_header: type=T: To: fred@ LOG: MAIN - rewrite: domain missing or malformed + qualify/rewrite: domain missing or malformed rewrite_one_header: type=F: From: CALLER_NAME CALLER@myhost.test.ex in "^.{40,}@*"? diff --git a/test/stderr/0569 b/test/stderr/0569 index 706e61db5..8c41999d9 100644 --- a/test/stderr/0569 +++ b/test/stderr/0569 @@ -26,6 +26,7 @@ >>> accept: condition test succeeded in inline ACL >>> end of inline ACL: ACCEPT >>> host in ignore_fromline_hosts? no (option unset) +LOG: 10HmaX-000000005vi-0000 qualify/rewrite: '>' missing at end of address >>> using ACL "check_message" >>> processing "require" (TESTSUITE/test-config 25) >>> message: ${if def:acl_m_message {$acl_m_message}} -- 2.30.2