Fix MAIL TO option parsing for the case where the envelope-from has embedded space. exim-4_81_RC1
authorJeremy Harris <jgh146exb@wizmail.org>
Fri, 25 Jan 2013 18:56:21 +0000 (18:56 +0000)
committerJeremy Harris <jgh146exb@wizmail.org>
Sat, 26 Jan 2013 15:03:28 +0000 (15:03 +0000)
The current code order of parsing the options off the tail prior to
taking the address off the front seems bogus.  At best the option parser
has to deal with the address and discover it is not a known option.
When the address localpart has spaces (legal, if the localparte is quoted)
confusion ensues as the option-parser is not aware of the address quoting
rules.

12 files changed:
src/src/smtp_in.c
test/log/2002
test/log/2102
test/mail/2002.CALLER
test/mail/2102.CALLER
test/scripts/0000-Basic/0121
test/scripts/2000-GnuTLS/2002
test/scripts/2100-OpenSSL/2102
test/stderr/0121
test/stdout/0121
test/stdout/2002
test/stdout/2102

index 753f0955b19812db4c59657761e04a7e34696623..e630b1498fdbb576c92cff077f270e4c856b500f 100644 (file)
@@ -3315,17 +3315,12 @@ while (done <= 0)
         }
       if (mail_args->need_value && strcmpic(value, US"") == 0)
         break;
-      /* This doesn't seem right to use
-        if ((char *)mail_args >= (char *)env_mail_type_list + sizeof(env_mail_type_list))
-        goto BAD_MAIL_ARGS;
-      */
 
       switch(mail_args->value)
         {
         /* Handle SIZE= by reading the value. We don't do the check till later,
         in order to be able to log the sender address on failure. */
         case ENV_MAIL_OPT_SIZE:
-          /* if (strcmpic(name, US"SIZE") == 0 && */
           if (((size = Ustrtoul(value, &end, 10)), *end == 0))
             {
             if ((size == ULONG_MAX && errno == ERANGE) || size > INT_MAX)
@@ -3377,8 +3372,8 @@ while (done <= 0)
             if (auth_xtextdecode(value, &authenticated_sender) < 0)
               {
               /* Put back terminator overrides for error message */
-              name[-1] = ' ';
               value[-1] = '=';
+              name[-1] = ' ';
               done = synprot_error(L_smtp_syntax_error, 501, NULL,
                 US"invalid data for AUTH");
               goto COMMAND_LOOP;
@@ -3421,8 +3416,8 @@ while (done <= 0)
               overrides for error message */
   
               default:
-              name[-1] = ' ';
               value[-1] = '=';
+              name[-1] = ' ';
               (void)smtp_handle_acl_fail(ACL_WHERE_MAILAUTH, rc, user_msg,
                 log_msg);
               goto COMMAND_LOOP;
@@ -3438,12 +3433,13 @@ while (done <= 0)
 #endif
 
         /* Unknown option. Stick back the terminator characters and break
-        the loop. An error for a malformed address will occur. */
+        the loop.  Do the name-terminator second as extract_option sets
+       value==name when it found no space.
+       An error for a malformed address will occur. */
         default:
-          /* BAD_MAIL_ARGS: */
-BAD_MAIL_ARGS:
-          name[-1] = ' ';
           value[-1] = '=';
+          name[-1] = ' ';
+          arg_error = TRUE;
           break;
         }
       /* Break out of for loop if switch() had bad argument or
index 4b0512a14446e74f6dd8e787f9c68e960213bac6..774495514786280fd66c8596a50c3dfc935ae7c3 100644 (file)
@@ -1,10 +1,13 @@
 1999-03-02 09:44:33 exim x.yz daemon started: pid=pppp, no queue runs, listening for SMTP on port 1225
 1999-03-02 09:44:33 10HmaX-0005vi-00 <= CALLER@test.ex H=[127.0.0.1] P=smtps X=TLS1.x:xxxxRSA_AES_256_CBC_SHAnnn:256 S=sss
+1999-03-02 09:44:33 10HmaY-0005vi-00 <= "name with spaces"@test.ex H=[127.0.0.1] P=smtps X=TLS1.x:xxxxRSA_AES_256_CBC_SHAnnn:256 S=sss
 1999-03-02 09:44:33 TLS error on connection from (rhu.barb) [ip4.ip4.ip4.ip4] (gnutls_handshake): The peer did not send any certificate.
-1999-03-02 09:44:33 10HmaY-0005vi-00 <= CALLER@test.ex H=[ip4.ip4.ip4.ip4] P=smtps X=TLS1.x:xxxxRSA_AES_256_CBC_SHAnnn:256 DN="C=UK,O=The Exim Maintainers,OU=Test Suite,CN=Phil Pennock" S=sss
+1999-03-02 09:44:33 10HmaZ-0005vi-00 <= CALLER@test.ex H=[ip4.ip4.ip4.ip4] P=smtps X=TLS1.x:xxxxRSA_AES_256_CBC_SHAnnn:256 DN="C=UK,O=The Exim Maintainers,OU=Test Suite,CN=Phil Pennock" S=sss
 1999-03-02 09:44:33 Start queue run: pid=pppp -qf
 1999-03-02 09:44:33 10HmaX-0005vi-00 => CALLER <CALLER@test.ex> R=abc T=local_delivery
 1999-03-02 09:44:33 10HmaX-0005vi-00 Completed
 1999-03-02 09:44:33 10HmaY-0005vi-00 => CALLER <CALLER@test.ex> R=abc T=local_delivery
 1999-03-02 09:44:33 10HmaY-0005vi-00 Completed
+1999-03-02 09:44:33 10HmaZ-0005vi-00 => CALLER <CALLER@test.ex> R=abc T=local_delivery
+1999-03-02 09:44:33 10HmaZ-0005vi-00 Completed
 1999-03-02 09:44:33 End queue run: pid=pppp -qf
index a0d9fc2058109038481a49008e72d705146a3a7b..da4ee49d721e183ae725dce51f4ce00a12566bbd 100644 (file)
@@ -1,11 +1,14 @@
 1999-03-02 09:44:33 exim x.yz daemon started: pid=pppp, no queue runs, listening for SMTP on port 1225
 1999-03-02 09:44:33 10HmaX-0005vi-00 <= CALLER@test.ex H=[127.0.0.1] P=smtps X=TLSv1:AES256-SHA:256 S=sss
+1999-03-02 09:44:33 10HmaY-0005vi-00 <= "name with spaces"@test.ex H=[127.0.0.1] P=smtps X=TLSv1:AES256-SHA:256 S=sss
 1999-03-02 09:44:33 TLS error on connection from (rhu.barb) [ip4.ip4.ip4.ip4] (SSL_accept): error: <<detail omitted>>
 1999-03-02 09:44:33 TLS client disconnected cleanly (rejected our certificate?)
-1999-03-02 09:44:33 10HmaY-0005vi-00 <= CALLER@test.ex H=[ip4.ip4.ip4.ip4] P=smtps X=TLSv1:AES256-SHA:256 DN="/C=UK/O=The Exim Maintainers/OU=Test Suite/CN=Phil Pennock" S=sss
+1999-03-02 09:44:33 10HmaZ-0005vi-00 <= CALLER@test.ex H=[ip4.ip4.ip4.ip4] P=smtps X=TLSv1:AES256-SHA:256 DN="/C=UK/O=The Exim Maintainers/OU=Test Suite/CN=Phil Pennock" S=sss
 1999-03-02 09:44:33 Start queue run: pid=pppp -qf
 1999-03-02 09:44:33 10HmaX-0005vi-00 => CALLER <CALLER@test.ex> R=abc T=local_delivery
 1999-03-02 09:44:33 10HmaX-0005vi-00 Completed
 1999-03-02 09:44:33 10HmaY-0005vi-00 => CALLER <CALLER@test.ex> R=abc T=local_delivery
 1999-03-02 09:44:33 10HmaY-0005vi-00 Completed
+1999-03-02 09:44:33 10HmaZ-0005vi-00 => CALLER <CALLER@test.ex> R=abc T=local_delivery
+1999-03-02 09:44:33 10HmaZ-0005vi-00 Completed
 1999-03-02 09:44:33 End queue run: pid=pppp -qf
index cc606bb0ea455c6be0aaa163a74d103d601e7852..a4e0dd526a79c506329f241ed387d49c3f0ea753 100644 (file)
@@ -10,12 +10,24 @@ TLS: cipher=TLS1.x:xxxxRSA_AES_256_CBC_SHAnnn:256 peerdn=
 
 This is a test encrypted message.
 
+From "name with spaces"@test.ex Tue Mar 02 09:44:33 1999
+Received: from [127.0.0.1]
+       by myhost.test.ex with smtps (TLS1.x:xxxxRSA_AES_256_CBC_SHAnnn:256)
+       (Exim x.yz)
+       (envelope-from <"name with spaces"@test.ex>)
+       id 10HmaY-0005vi-00
+       for CALLER@test.ex; Tue, 2 Mar 1999 09:44:33 +0000
+tls-certificate-verified: 0
+TLS: cipher=TLS1.x:xxxxRSA_AES_256_CBC_SHAnnn:256 peerdn=
+
+This is a test encrypted message.
+
 From CALLER@test.ex Tue Mar 02 09:44:33 1999
 Received: from [ip4.ip4.ip4.ip4]
        by myhost.test.ex with smtps (TLS1.x:xxxxRSA_AES_256_CBC_SHAnnn:256)
        (Exim x.yz)
        (envelope-from <CALLER@test.ex>)
-       id 10HmaY-0005vi-00
+       id 10HmaZ-0005vi-00
        for CALLER@test.ex; Tue, 2 Mar 1999 09:44:33 +0000
 tls-certificate-verified: 1
 TLS: cipher=TLS1.x:xxxxRSA_AES_256_CBC_SHAnnn:256 peerdn=C=UK,O=The Exim Maintainers,OU=Test Suite,CN=Phil Pennock
index 0a2adcf1c64a8b3e1061bc7695969238bf187007..e4be6a342d1f0a059e1f030da08ff30d14d1958a 100644 (file)
@@ -10,12 +10,24 @@ TLS: cipher=TLSv1:AES256-SHA:256 peerdn=
 
 This is a test encrypted message.
 
+From "name with spaces"@test.ex Tue Mar 02 09:44:33 1999
+Received: from [127.0.0.1]
+       by myhost.test.ex with smtps (TLSv1:AES256-SHA:256)
+       (Exim x.yz)
+       (envelope-from <"name with spaces"@test.ex>)
+       id 10HmaY-0005vi-00
+       for CALLER@test.ex; Tue, 2 Mar 1999 09:44:33 +0000
+tls-certificate-verified: 0
+TLS: cipher=TLSv1:AES256-SHA:256 peerdn=
+
+This is a test encrypted message.
+
 From CALLER@test.ex Tue Mar 02 09:44:33 1999
 Received: from [ip4.ip4.ip4.ip4]
        by myhost.test.ex with smtps (TLSv1:AES256-SHA:256)
        (Exim x.yz)
        (envelope-from <CALLER@test.ex>)
-       id 10HmaY-0005vi-00
+       id 10HmaZ-0005vi-00
        for CALLER@test.ex; Tue, 2 Mar 1999 09:44:33 +0000
 tls-certificate-verified: 1
 TLS: cipher=TLSv1:AES256-SHA:256 peerdn=/C=UK/O=The Exim Maintainers/OU=Test Suite/CN=Phil Pennock
index 4bcb99b4767584344ad3aa5c1eb111044259b5e3..9ff68fa13b7a69ecba29d0f8c40c90dd1a35cd20 100644 (file)
@@ -6,6 +6,9 @@ rset
 mail from:<userx@unknown.dom.ain>
 rcpt to:<userx@test.ex>
 rset
+mail from:<"unknown with spaces"@test.ex>
+rcpt to:<userx@test.ex>
+rset
 mail from:<userx@test.ex>
 rcpt to:<userx@test.ex>
 data
index 06e1a82575ba7056766b22ebcd710a238d50c0ac..06a7b31d0165d8be16640f922911847ad7e6a9b8 100644 (file)
@@ -25,6 +25,29 @@ This is a test encrypted message.
 quit
 ??? 221
 ****
+client-gnutls 127.0.0.1 PORT_D
+??? 220
+ehlo rhu.barb
+??? 250-
+??? 250-
+??? 250-
+??? 250-
+??? 250-
+??? 250
+starttls
+??? 220
+mail from:<"name with spaces"@test.ex>
+??? 250
+rcpt to:<CALLER@test.ex>
+??? 250
+DATA
+??? 3
+This is a test encrypted message.
+.
+??? 250
+quit
+??? 221
+****
 client-gnutls HOSTIPV4 PORT_D
 ??? 220
 ehlo rhu.barb
index 7f9279acd12160a53ef2b33fba3d31e277d887cd..2e7dca0a65e82976b512588b46a2aa194be4a606 100644 (file)
@@ -24,6 +24,29 @@ This is a test encrypted message.
 quit
 ??? 221
 ****
+client-ssl 127.0.0.1 PORT_D
+??? 220
+ehlo rhu.barb
+??? 250-
+??? 250-
+??? 250-
+??? 250-
+??? 250-
+??? 250
+starttls
+??? 220
+mail from:<"name with spaces"@test.ex>
+??? 250
+rcpt to:<CALLER@test.ex>
+??? 250
+DATA
+??? 3
+This is a test encrypted message.
+.
+??? 250
+quit
+??? 221
+****
 client-ssl HOSTIPV4 PORT_D
 ??? 220
 ehlo rhu.barb
index c7fcec4018a5bde4e0bbc9dd33acc55af79a00ae..39cdfba9bfdc268cbf28fa434f7354bc969f73bb 100644 (file)
@@ -38,6 +38,20 @@ LOG: H=[127.0.0.1] F=<userx@unknown.dom.ain> rejected RCPT <userx@test.ex>: Send
 >>> processing "require"
 >>> check verify = sender
 >>> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+>>> routing "unknown with spaces"@test.ex
+>>> test.ex in "test.ex"? yes (matched "test.ex")
+>>> test.ex in "! +local_domains"? no (matched "! +local_domains")
+>>> unknown with spaces in "defer"? no (end of list)
+>>> unknown with spaces in "userx"? no (end of list)
+>>> no more routers
+>>> ----------- end verify ------------
+>>> require: condition test failed in ACL "check_recipient"
+LOG: H=[127.0.0.1] sender verify fail for <"unknown with spaces"@test.ex>: Unrouteable address
+LOG: H=[127.0.0.1] F=<"unknown with spaces"@test.ex> rejected RCPT <userx@test.ex>: Sender verify failed
+>>> using ACL "check_recipient"
+>>> processing "require"
+>>> check verify = sender
+>>> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 >>> routing userx@test.ex
 >>> test.ex in "test.ex"? yes (matched "test.ex")
 >>> test.ex in "! +local_domains"? no (matched "! +local_domains")
index 7ef5e4024cf997254d341ae88faaf6411030369c..5e3968243567ed87c0c3c9d449daeee0a790435f 100644 (file)
 550 Sender verify failed\r
 250 Reset OK\r
 250 OK\r
+550-Verification failed for <"unknown with spaces"@test.ex>\r
+550-Unrouteable address\r
+550 Sender verify failed\r
+250 Reset OK\r
+250 OK\r
 250 Accepted\r
 354 Enter message, ending with "." on a line by itself\r
 550 Administrative prohibition\r
index 7b2a47fca3889181b6ccefbce88c19c7298d4231..a248be7c0a2aee565bc71d09814e96755f664f6b 100644 (file)
@@ -36,6 +36,44 @@ Succeeded in starting TLS
 ??? 221
 <<< 221 myhost.test.ex closing connection
 End of script
+Connecting to 127.0.0.1 port 1225 ... connected
+??? 220
+<<< 220 myhost.test.ex ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000
+>>> ehlo rhu.barb
+??? 250-
+<<< 250-myhost.test.ex Hello rhu.barb [127.0.0.1]
+??? 250-
+<<< 250-SIZE 52428800
+??? 250-
+<<< 250-8BITMIME
+??? 250-
+<<< 250-PIPELINING
+??? 250-
+<<< 250-STARTTLS
+??? 250
+<<< 250 HELP
+>>> starttls
+??? 220
+<<< 220 TLS go ahead
+Attempting to start TLS
+Succeeded in starting TLS
+>>> mail from:<"name with spaces"@test.ex>
+??? 250
+<<< 250 OK
+>>> rcpt to:<CALLER@test.ex>
+??? 250
+<<< 250 Accepted
+>>> DATA
+??? 3
+<<< 354 Enter message, ending with "." on a line by itself
+>>> This is a test encrypted message.
+>>> .
+??? 250
+<<< 250 OK id=10HmaY-0005vi-00
+>>> quit
+??? 221
+<<< 221 myhost.test.ex closing connection
+End of script
 Connecting to ip4.ip4.ip4.ip4 port 1225 ... connected
 ??? 220
 <<< 220 myhost.test.ex ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000
@@ -93,7 +131,7 @@ Succeeded in starting TLS
 >>> This is a test encrypted message from a verified host.
 >>> .
 ??? 250
-<<< 250 OK id=10HmaY-0005vi-00
+<<< 250 OK id=10HmaZ-0005vi-00
 >>> quit
 ??? 221
 <<< 221 myhost.test.ex closing connection
index d3c18a8bfeeecf96402df17ca477126060a14370..23c39cdf4e041a7b1b743d8316ea4cd69920db3e 100644 (file)
@@ -52,6 +52,60 @@ Succeeded in starting TLS
 ??? 221
 <<< 221 myhost.test.ex closing connection
 End of script
+Connecting to 127.0.0.1 port 1225 ... connected
+??? 220
+<<< 220 myhost.test.ex ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000
+>>> ehlo rhu.barb
+??? 250-
+<<< 250-myhost.test.ex Hello rhu.barb [127.0.0.1]
+??? 250-
+<<< 250-SIZE 52428800
+??? 250-
+<<< 250-8BITMIME
+??? 250-
+<<< 250-PIPELINING
+??? 250-
+<<< 250-STARTTLS
+??? 250
+<<< 250 HELP
+>>> starttls
+??? 220
+<<< 220 TLS go ahead
+Attempting to start TLS
+SSL info: before/connect initialization
+SSL info: before/connect initialization
+SSL info: SSLv2/v3 write client hello A
+SSL info: SSLv3 read server hello A
+SSL info: SSLv3 read server certificate A
+SSL info: SSLv3 read server key exchange A
+SSL info: SSLv3 read server done A
+SSL info: SSLv3 write client key exchange A
+SSL info: SSLv3 write change cipher spec A
+SSL info: SSLv3 write finished A
+SSL info: SSLv3 flush data
+SSL info: SSLv3 read server session ticket A
+SSL info: SSLv3 read finished A
+SSL info: SSL negotiation finished successfully
+SSL info: SSL negotiation finished successfully
+SSL connection using AES256-SHA
+Succeeded in starting TLS
+>>> mail from:<"name with spaces"@test.ex>
+??? 250
+<<< 250 OK
+>>> rcpt to:<CALLER@test.ex>
+??? 250
+<<< 250 Accepted
+>>> DATA
+??? 3
+<<< 354 Enter message, ending with "." on a line by itself
+>>> This is a test encrypted message.
+>>> .
+??? 250
+<<< 250 OK id=10HmaY-0005vi-00
+>>> quit
+??? 221
+<<< 221 myhost.test.ex closing connection
+End of script
 Connecting to ip4.ip4.ip4.ip4 port 1225 ... connected
 ??? 220
 <<< 220 myhost.test.ex ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000
@@ -144,7 +198,7 @@ Succeeded in starting TLS
 >>> This is a test encrypted message from a verified host.
 >>> .
 ??? 250
-<<< 250 OK id=10HmaY-0005vi-00
+<<< 250 OK id=10HmaZ-0005vi-00
 >>> quit
 ??? 221
 <<< 221 myhost.test.ex closing connection