Malware: fix error logged on a scanner connect fail. Bug 1796
authorJeremy Harris <jgh146exb@wizmail.org>
Sun, 14 Feb 2016 23:04:08 +0000 (23:04 +0000)
committerJeremy Harris <jgh146exb@wizmail.org>
Sun, 14 Feb 2016 23:40:52 +0000 (23:40 +0000)
doc/doc-txt/ChangeLog
src/src/ip.c

index 8df028e4e912a28396572444e610dad6d35ecb10..2f39532e7e23150d78d29fb4dbbd613aab42139d 100644 (file)
@@ -171,6 +171,8 @@ JH/40 Fix crash in queryprogram router when compiled with EXPERIMENTAL_SRS.
 JH/41 Bug 1792: Fix selection of headers to sign for DKIM: bottom-up.  While
       we're in there, support oversigning also; bug 1309.
 
 JH/41 Bug 1792: Fix selection of headers to sign for DKIM: bottom-up.  While
       we're in there, support oversigning also; bug 1309.
 
+JH/42 Bug 1796: Fix error logged on a malware scanner connection failure.
+
 
 
 Exim version 4.86
 
 
 Exim version 4.86
index 1e3875aef51e388034af1c3f68d3bf805ab9b220..d5d8fceecacf5eff32a1e73eaf1deae45bebbb93 100644 (file)
@@ -218,6 +218,7 @@ IPv6 support. */
 /* If no connection timeout is set, just call connect() without setting a
 timer, thereby allowing the inbuilt OS timeout to operate. */
 
 /* If no connection timeout is set, just call connect() without setting a
 timer, thereby allowing the inbuilt OS timeout to operate. */
 
+callout_address = string_sprintf("[%s]:%d", address, port);
 sigalrm_seen = FALSE;
 if (timeout > 0) alarm(timeout);
 rc = connect(sock, s_ptr, s_len);
 sigalrm_seen = FALSE;
 if (timeout > 0) alarm(timeout);
 rc = connect(sock, s_ptr, s_len);
@@ -238,10 +239,7 @@ if (running_in_test_harness  && save_errno == ECONNREFUSED && timeout == 999999)
 /* Success */
 
 if (rc >= 0)
 /* Success */
 
 if (rc >= 0)
-  {
-  callout_address = string_sprintf("[%s]:%d", address, port);
   return 0;
   return 0;
-  }
 
 /* A failure whose error code is "Interrupted system call" is in fact
 an externally applied timeout if the signal handler has been run. */
 
 /* A failure whose error code is "Interrupted system call" is in fact
 an externally applied timeout if the signal handler has been run. */
@@ -292,9 +290,7 @@ namelen = Ustrlen(hostname);
 if (hostname[0] == '[' &&
     hostname[namelen - 1] == ']')
   {
 if (hostname[0] == '[' &&
     hostname[namelen - 1] == ']')
   {
-  uschar * host = string_copy(hostname);
-  host[namelen - 1] = 0;
-  host++;
+  uschar * host = string_copyn(hostname+1, namelen-2);
   if (string_is_ip_address(host, NULL) == 0)
     {
     *errstr = string_sprintf("malformed IP address \"%s\"", hostname);
   if (string_is_ip_address(host, NULL) == 0)
     {
     *errstr = string_sprintf("malformed IP address \"%s\"", hostname);
@@ -306,13 +302,13 @@ if (hostname[0] == '[' &&
 /* Otherwise check for an unadorned IP address */
 
 else if (string_is_ip_address(hostname, NULL) != 0)
 /* Otherwise check for an unadorned IP address */
 
 else if (string_is_ip_address(hostname, NULL) != 0)
-  shost.name = shost.address = string_copy(hostname);
+  shost.name = shost.address = string_copyn(hostname, namelen);
 
 /* Otherwise lookup IP address(es) from the name */
 
 else
   {
 
 /* Otherwise lookup IP address(es) from the name */
 
 else
   {
-  shost.name = string_copy(hostname);
+  shost.name = string_copyn(hostname, namelen);
   if (host_find_byname(&shost, NULL, HOST_FIND_QUALIFY_SINGLE,
       NULL, FALSE) != HOST_FOUND)
     {
   if (host_find_byname(&shost, NULL, HOST_FIND_QUALIFY_SINGLE,
       NULL, FALSE) != HOST_FOUND)
     {
@@ -325,9 +321,9 @@ else
 
 for (h = &shost; h != NULL; h = h->next)
   {
 
 for (h = &shost; h != NULL; h = h->next)
   {
-  fd = (Ustrchr(h->address, ':') != 0)
-    ? (fd6 < 0) ? (fd6 = ip_socket(type, af = AF_INET6)) : fd6
-    : (fd4 < 0) ? (fd4 = ip_socket(type, af = AF_INET )) : fd4;
+  fd = Ustrchr(h->address, ':') != 0
+    ? fd6 < 0 ? (fd6 = ip_socket(type, af = AF_INET6)) : fd6
+    : fd4 < 0 ? (fd4 = ip_socket(type, af = AF_INET )) : fd4;
 
   if (fd < 0)
     {
 
   if (fd < 0)
     {
@@ -393,6 +389,7 @@ if ((sock = socket(AF_UNIX, SOCK_STREAM, 0)) < 0)
   return -1;
   }
 
   return -1;
   }
 
+callout_address = string_copy(path);
 server.sun_family = AF_UNIX;
 Ustrncpy(server.sun_path, path, sizeof(server.sun_path)-1);
 server.sun_path[sizeof(server.sun_path)-1] = '\0';
 server.sun_family = AF_UNIX;
 Ustrncpy(server.sun_path, path, sizeof(server.sun_path)-1);
 server.sun_path[sizeof(server.sun_path)-1] = '\0';
@@ -404,7 +401,6 @@ if (connect(sock, (struct sockaddr *) &server, sizeof(server)) < 0)
                path, strerror(err));
   return -1;
   }
                path, strerror(err));
   return -1;
   }
-callout_address = string_copy(path);
 return sock;
 }
 
 return sock;
 }