Update version number and copyright year.
[exim.git] / src / src / smtp_in.c
index 97b721e550530a8e978b7dab72bb9a86aae9d84b..7e80c6209afd643bcae18a84c27a2b729ffea838 100644 (file)
@@ -1,10 +1,10 @@
-/* $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.49 2007/01/08 10:50:18 ph10 Exp $ */
 
 /*************************************************
 *     Exim - an Internet mail transport agent    *
 *************************************************/
 
 
 /*************************************************
 *     Exim - an Internet mail transport agent    *
 *************************************************/
 
-/* Copyright (c) University of Cambridge 1995 - 2006 */
+/* Copyright (c) University of Cambridge 1995 - 2007 */
 /* See the file NOTICE for conditions of use and distribution. */
 
 /* Functions for handling an incoming SMTP call. */
 /* See the file NOTICE for conditions of use and distribution. */
 
 /* Functions for handling an incoming SMTP call. */
@@ -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 "