From af4839123103f048de85bec0e9b15ac64e64f865 Mon Sep 17 00:00:00 2001 From: Jeremy Harris Date: Sun, 14 Feb 2016 23:04:08 +0000 Subject: [PATCH] Malware: fix error logged on a scanner connect fail. Bug 1796 --- doc/doc-txt/ChangeLog | 2 ++ src/src/ip.c | 20 ++++++++------------ 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog index 8df028e4e..2f39532e7 100644 --- a/doc/doc-txt/ChangeLog +++ b/doc/doc-txt/ChangeLog @@ -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/42 Bug 1796: Fix error logged on a malware scanner connection failure. + Exim version 4.86 diff --git a/src/src/ip.c b/src/src/ip.c index 1e3875aef..d5d8fceec 100644 --- a/src/src/ip.c +++ b/src/src/ip.c @@ -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. */ +callout_address = string_sprintf("[%s]:%d", address, port); 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) - { - callout_address = string_sprintf("[%s]:%d", address, port); 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. */ @@ -292,9 +290,7 @@ namelen = Ustrlen(hostname); 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); @@ -306,13 +302,13 @@ if (hostname[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 { - 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) { @@ -325,9 +321,9 @@ else 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) { @@ -393,6 +389,7 @@ if ((sock = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) 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'; @@ -404,7 +401,6 @@ if (connect(sock, (struct sockaddr *) &server, sizeof(server)) < 0) path, strerror(err)); return -1; } -callout_address = string_copy(path); return sock; } -- 2.25.1