Use safer routine for possibly-overlapping copy
authorJeremy Harris <jgh146exb@wizmail.org>
Fri, 20 Oct 2017 22:21:27 +0000 (23:21 +0100)
committerJeremy Harris <jgh146exb@wizmail.org>
Fri, 20 Oct 2017 22:55:38 +0000 (23:55 +0100)
Fixes a logging bug seen on aarch64

doc/doc-txt/ChangeLog
src/src/transports/smtp.c

index 73c86a9ce9b6386660f4a8cbb7f750bbf9ec6d9a..e937ba2c7ba0952b17e7f3f54b6bfb45d6e80094 100644 (file)
@@ -54,6 +54,11 @@ JH/29 Fix queue_run_in_order to ignore the PID portion of the message ID.  This
       matters on fast-turnover and PID-randomising systems, which were getting
       out-of-order delivery.
 
+JH/30 Fix a logging bug on aarch64: an unsafe routine was previously used for
+      a possibly-overlapping copy.  The symptom was that "Remote host closed
+      connection in response to HELO" was logged instead of the actual 4xx
+      error for the HELO.
+
 
 Exim version 4.89
 -----------------
index 3217d81ada886f3126dd494b5e3355f854bbc951..e50827bcd76aad978d92b0c56678180c4046af0f 100644 (file)
@@ -1778,7 +1778,7 @@ goto SEND_QUIT;
        errno = ERRNO_SMTPCLOSED;
        goto EHLOHELO_FAILED;
        }
-      Ustrncpy(sx->buffer, rsp, sizeof(sx->buffer)/2);
+      memmove(sx->buffer, rsp, Ustrlen(rsp));
       goto RESPONSE_FAILED;
       }
     }
@@ -2108,11 +2108,6 @@ return OK;
     sx->send_quit = FALSE;
     goto FAILED;
 
-  /* This label is jumped to directly when a TLS negotiation has failed,
-  or was not done for a host for which it is required. Values will be set
-  in message and errno, and setting_up will always be true. Treat as
-  a temporary error. */
-
   EHLOHELO_FAILED:
     code = '4';
     message = string_sprintf("Remote host closed connection in response to %s"
@@ -2120,6 +2115,11 @@ return OK;
     sx->send_quit = FALSE;
     goto FAILED;
 
+  /* This label is jumped to directly when a TLS negotiation has failed,
+  or was not done for a host for which it is required. Values will be set
+  in message and errno, and setting_up will always be true. Treat as
+  a temporary error. */
+
 #ifdef SUPPORT_TLS
   TLS_FAILED:
     code = '4';