Fix space bug in previous patch for "message" used with "accept".
authorPhilip Hazel <ph10@hermes.cam.ac.uk>
Mon, 20 Nov 2006 11:43:40 +0000 (11:43 +0000)
committerPhilip Hazel <ph10@hermes.cam.ac.uk>
Mon, 20 Nov 2006 11:43:40 +0000 (11:43 +0000)
src/src/exim.c
src/src/routers/redirect.c
src/src/smtp_in.c
test/scripts/0000-Basic/0546
test/stdout/0546

index 6f53c1ffbf433f2ecefe849ae5958d5ccdf14299..60e5b52617b68b49419a113e9e1d635d367c6d5c 100644 (file)
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/src/src/exim.c,v 1.49 2006/11/13 11:56:41 ph10 Exp $ */
+/* $Cambridge: exim/src/src/exim.c,v 1.50 2006/11/20 11:43:40 ph10 Exp $ */
 
 /*************************************************
 *     Exim - an Internet mail transport agent    *
 
 /*************************************************
 *     Exim - an Internet mail transport agent    *
@@ -1498,7 +1498,8 @@ regex_ismsgid =
   regex_must_compile(US"^(?:[^\\W_]{6}-){2}[^\\W_]{2}$", FALSE, TRUE);
 
 /* Precompile the regular expression that is used for matching an SMTP error
   regex_must_compile(US"^(?:[^\\W_]{6}-){2}[^\\W_]{2}$", FALSE, TRUE);
 
 /* Precompile the regular expression that is used for matching an SMTP error
-code, possibly extended, at the start of an error message. */
+code, possibly extended, at the start of an error message. Note that the
+terminating whitespace character is included. */
 
 regex_smtp_code =
   regex_must_compile(US"^\\d\\d\\d\\s(?:\\d\\.\\d\\d?\\d?\\.\\d\\d?\\d?\\s)?",
 
 regex_smtp_code =
   regex_must_compile(US"^\\d\\d\\d\\s(?:\\d\\.\\d\\d?\\d?\\.\\d\\d?\\d?\\s)?",
index 2a9d5e3b2c150966fb83172be7a2fb983537ce67..e22699216ec790d8ab93c4287e903a9fc9335c46 100644 (file)
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/src/src/routers/redirect.c,v 1.17 2006/07/13 13:53:33 ph10 Exp $ */
+/* $Cambridge: exim/src/src/routers/redirect.c,v 1.18 2006/11/20 11:43:40 ph10 Exp $ */
 
 /*************************************************
 *     Exim - an Internet mail transport agent    *
 
 /*************************************************
 *     Exim - an Internet mail transport agent    *
@@ -736,8 +736,8 @@ switch (frc)
     int ovector[3];
     if (ob->forbid_smtp_code &&
         pcre_exec(regex_smtp_code, NULL, CS addr->message,
     int ovector[3];
     if (ob->forbid_smtp_code &&
         pcre_exec(regex_smtp_code, NULL, CS addr->message,
-        Ustrlen(addr->message), 0, PCRE_EOPT,
-        ovector, sizeof(ovector)/sizeof(int)) >= 0)
+          Ustrlen(addr->message), 0, PCRE_EOPT,
+          ovector, sizeof(ovector)/sizeof(int)) >= 0)
       {
       DEBUG(D_route) debug_printf("SMTP code at start of error message "
         "is ignored because forbid_smtp_code is set\n");
       {
       DEBUG(D_route) debug_printf("SMTP code at start of error message "
         "is ignored because forbid_smtp_code is set\n");
index 97b721e550530a8e978b7dab72bb9a86aae9d84b..371ed5bb7e4a0e7b242ec003316c3021825e0fb6 100644 (file)
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/src/src/smtp_in.c,v 1.47 2006/11/14 16:40:36 ph10 Exp $ */
+/* $Cambridge: exim/src/src/smtp_in.c,v 1.48 2006/11/20 11:43:40 ph10 Exp $ */
 
 /*************************************************
 *     Exim - an Internet mail transport agent    *
 
 /*************************************************
 *     Exim - an Internet mail transport agent    *
@@ -1605,7 +1605,7 @@ else
   int codelen = 3;
   s = user_msg;
   smtp_message_code(&code, &codelen, &s, NULL);
   int codelen = 3;
   s = user_msg;
   smtp_message_code(&code, &codelen, &s, NULL);
-  if (codelen > 3)
+  if (codelen > 4)
     {
     esc = code + 4;
     esclen = codelen - 4;
     {
     esc = code + 4;
     esclen = codelen - 4;
@@ -1793,7 +1793,7 @@ output nothing for non-final calls, and only the first line for anything else.
 
 Arguments:
   code          SMTP code, may involve extended status codes
 
 Arguments:
   code          SMTP code, may involve extended status codes
-  codelen       length of smtp code; if > 3 there's an ESC
+  codelen       length of smtp code; if > 4 there's an ESC
   final         FALSE if the last line isn't the final line
   msg           message text, possibly containing newlines
 
   final         FALSE if the last line isn't the final line
   msg           message text, possibly containing newlines
 
@@ -1808,7 +1808,7 @@ uschar *esc = US"";
 
 if (!final && no_multiline_responses) return;
 
 
 if (!final && no_multiline_responses) return;
 
-if (codelen > 3)
+if (codelen > 4)
   {
   esc = code + 4;
   esclen = codelen - 4;
   {
   esc = code + 4;
   esclen = codelen - 4;
@@ -1856,9 +1856,12 @@ is actually going to be used (the original one).
 This function is global because it is called from receive.c as well as within
 this module.
 
 This function is global because it is called from receive.c as well as within
 this module.
 
+Note that the code length returned includes the terminating whitespace
+character, which is always included in the regex match.
+
 Arguments:
   code          SMTP code, may involve extended status codes
 Arguments:
   code          SMTP code, may involve extended status codes
-  codelen       length of smtp code; if > 3 there's an ESC
+  codelen       length of smtp code; if > 4 there's an ESC
   msg           message text
   log_msg       optional log message, to be adjusted with the new SMTP code
 
   msg           message text
   log_msg       optional log message, to be adjusted with the new SMTP code
 
@@ -2650,7 +2653,7 @@ while (done <= 0)
     tls_advertised = FALSE;
     #endif
 
     tls_advertised = FALSE;
     #endif
 
-    smtp_code = US"250";        /* Default response code */
+    smtp_code = US"250 ";        /* Default response code plus space*/
     if (user_msg == NULL)
       {
       s = string_sprintf("%.3s %s Hello %s%s%s",
     if (user_msg == NULL)
       {
       s = string_sprintf("%.3s %s Hello %s%s%s",
@@ -2672,14 +2675,16 @@ while (done <= 0)
         }
       }
 
         }
       }
 
-    /* A user-supplied EHLO greeting may not contain more than one line */
+    /* A user-supplied EHLO greeting may not contain more than one line. Note
+    that the code returned by smtp_message_code() includes the terminating
+    whitespace character. */
 
     else
       {
       char *ss;
 
     else
       {
       char *ss;
-      int codelen = 3;
+      int codelen = 4;
       smtp_message_code(&smtp_code, &codelen, &user_msg, NULL);
       smtp_message_code(&smtp_code, &codelen, &user_msg, NULL);
-      s = string_sprintf("%.*s %s", codelen, smtp_code, user_msg);
+      s = string_sprintf("%.*s%s", codelen, smtp_code, user_msg);
       if ((ss = strpbrk(CS s, "\r\n")) != NULL)
         {
         log_write(0, LOG_MAIN|LOG_PANIC, "EHLO/HELO response must not contain "
       if ((ss = strpbrk(CS s, "\r\n")) != NULL)
         {
         log_write(0, LOG_MAIN|LOG_PANIC, "EHLO/HELO response must not contain "
index 1486d35384f94e967aa7743c4d393fe64893ecf9..4374776c39596e767c6a30ecbbaf44f0b380bd3c 100644 (file)
@@ -16,4 +16,8 @@ mail from:<>
 rcpt to:<userx@test.ex>
 quit
 ****
 rcpt to:<userx@test.ex>
 quit
 ****
+exim -bs -DHELO_MSG='299 With code'
+ehlo a.b.c
+quit
+****
 no_msglog_check
 no_msglog_check
index 0865c5f17a2135d5bfcdba2b71e01d421eedfb12..7f123f85f0142ba3cef5844e697882c733b1826b 100644 (file)
@@ -18,3 +18,9 @@
 299 OK\r
 250 Bad number\r
 221 the.local.host.name closing connection\r
 299 OK\r
 250 Bad number\r
 221 the.local.host.name closing connection\r
+220 the.local.host.name ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000\r
+299-With code\r
+299-SIZE 52428800\r
+299-PIPELINING\r
+299 HELP\r
+221 the.local.host.name closing connection\r