rfc2553_connect_to(): When failing set errno later
authorFabian Keil <fk@fabiankeil.de>
Sun, 23 Aug 2020 16:26:19 +0000 (18:26 +0200)
committerFabian Keil <fk@fabiankeil.de>
Tue, 1 Sep 2020 10:22:42 +0000 (12:22 +0200)
... to reduce the chances that it gets cloberred before
the caller has a chance to read it.

Previously Privoxy could send a "Connection failure" message
instead of the "DNS failure" message.

Sponsored by: Robert Klemme

jbsockets.c

index 556c927..5e4b28c 100644 (file)
@@ -254,10 +254,10 @@ static jb_socket rfc2553_connect_to(const char *host, int portnum, struct client
    {
       log_error(LOG_LEVEL_INFO,
          "Can not resolve %s: %s", host, gai_strerror(retval));
    {
       log_error(LOG_LEVEL_INFO,
          "Can not resolve %s: %s", host, gai_strerror(retval));
-      /* XXX: Should find a better way to propagate this error. */
-      errno = EINVAL;
       csp->error_message = strdup(gai_strerror(retval));
       csp->http->host_ip_addr_str = strdup("unknown");
       csp->error_message = strdup(gai_strerror(retval));
       csp->http->host_ip_addr_str = strdup("unknown");
+      /* XXX: Should find a better way to propagate this error. */
+      errno = EINVAL;
       return(JB_INVALID_SOCKET);
    }
 
       return(JB_INVALID_SOCKET);
    }