Loading CHANGES +3 −0 Original line number Diff line number Diff line Loading @@ -7,6 +7,9 @@ Changelog Daniel (29 January 2005) - Adjusted the KNOWN_BUGS #17 fix a bit more since the FTP code also did some bad assumptions. - multi interface: when a request is denied due to "Maximum redirects followed" libcurl leaked the last Location: URL. Loading lib/connect.c +22 −1 Original line number Diff line number Diff line Loading @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * * Copyright (C) 1998 - 2004, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2005, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms Loading Loading @@ -429,6 +429,25 @@ static bool verifyconnect(curl_socket_t sockfd, int *error) return rc; } CURLcode Curl_store_ip_addr(struct connectdata *conn) { char addrbuf[256]; Curl_printable_address(conn->ip_addr, addrbuf, sizeof(addrbuf)); /* save the string */ Curl_safefree(conn->ip_addr_str); conn->ip_addr_str = strdup(addrbuf); if(!conn->ip_addr_str) return CURLE_OUT_OF_MEMORY; /* FAIL */ #ifdef PF_INET6 if(conn->ip_addr->ai_family == PF_INET6) conn->bits.ipv6 = TRUE; #endif return CURLE_OK; } /* Used within the multi interface. Try next IP address, return TRUE if no more address exists */ static bool trynextip(struct connectdata *conn, Loading @@ -450,6 +469,8 @@ static bool trynextip(struct connectdata *conn, /* store the new socket descriptor */ conn->sock[sockindex] = sockfd; conn->ip_addr = ai; Curl_store_ip_addr(conn); return FALSE; } ai = ai->ai_next; Loading lib/connect.h +3 −1 Original line number Diff line number Diff line Loading @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * * Copyright (C) 1998 - 2004, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2005, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms Loading Loading @@ -39,6 +39,8 @@ CURLcode Curl_connecthost(struct connectdata *conn, int Curl_ourerrno(void); CURLcode Curl_store_ip_addr(struct connectdata *conn); #define DEFAULT_CONNECT_TIMEOUT 300000 /* milliseconds == five minutes */ #endif lib/ftp.c +5 −9 Original line number Diff line number Diff line Loading @@ -1226,12 +1226,10 @@ CURLcode ftp_use_port(struct connectdata *conn) } #ifdef PF_INET6 if(!conn->bits.ftp_use_eprt && (conn->ip_addr->ai_family == PF_INET6)) { if(!conn->bits.ftp_use_eprt && conn->bits.ipv6) /* EPRT is disabled but we are connected to a IPv6 host, so we ignore the request! */ request and enable EPRT again! */ conn->bits.ftp_use_eprt = TRUE; } #endif for (fcmd = EPRT; fcmd != DONE; fcmd++) { Loading Loading @@ -1563,12 +1561,10 @@ CURLcode ftp_use_pasv(struct connectdata *conn, char newhost[NEWHOST_BUFSIZE]; #ifdef PF_INET6 if(!conn->bits.ftp_use_epsv && (conn->ip_addr->ai_family == PF_INET6)) { if(!conn->bits.ftp_use_epsv && conn->bits.ipv6) /* EPSV is disabled but we are connected to a IPv6 host, so we ignore the request! */ request and enable EPSV again! */ conn->bits.ftp_use_epsv = TRUE; } #endif for (modeoff = (conn->bits.ftp_use_epsv?0:1); Loading Loading @@ -1653,7 +1649,7 @@ CURLcode ftp_use_pasv(struct connectdata *conn, newport = num; /* We must use the same IP we are already connected to */ Curl_printable_address(conn->ip_addr, newhost, NEWHOST_BUFSIZE); snprintf(newhost, NEWHOST_BUFSIZE, "%s", conn->ip_addr_str); } } else Loading lib/url.c +3 −18 Original line number Diff line number Diff line Loading @@ -1959,6 +1959,8 @@ static CURLcode ConnectPlease(struct connectdata *conn, conn->dns_entry = hostaddr; conn->ip_addr = addr; Curl_store_ip_addr(conn); if (conn->data->set.proxytype == CURLPROXY_SOCKS5) { return handleSock5Proxy(conn->proxyuser, conn->proxypasswd, Loading @@ -1982,24 +1984,7 @@ static CURLcode ConnectPlease(struct connectdata *conn, */ static void verboseconnect(struct connectdata *conn) { struct SessionHandle *data = conn->data; char addrbuf[256]; /* Get a printable version of the network address. */ if(!conn->bits.reuse) { Curl_printable_address(conn->ip_addr, addrbuf, sizeof(addrbuf)); /* save the string */ if(conn->ip_addr_str) free(conn->ip_addr_str); conn->ip_addr_str = strdup(addrbuf); if(!conn->ip_addr_str) return; /* FAIL */ } /* else, Re-used, ip_addr is not safe to access. */ infof(data, "Connected to %s (%s) port %d\n", infof(conn->data, "Connected to %s (%s) port %d\n", conn->bits.httpproxy ? conn->proxy.dispname : conn->host.dispname, conn->ip_addr_str, conn->port); } Loading Loading
CHANGES +3 −0 Original line number Diff line number Diff line Loading @@ -7,6 +7,9 @@ Changelog Daniel (29 January 2005) - Adjusted the KNOWN_BUGS #17 fix a bit more since the FTP code also did some bad assumptions. - multi interface: when a request is denied due to "Maximum redirects followed" libcurl leaked the last Location: URL. Loading
lib/connect.c +22 −1 Original line number Diff line number Diff line Loading @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * * Copyright (C) 1998 - 2004, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2005, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms Loading Loading @@ -429,6 +429,25 @@ static bool verifyconnect(curl_socket_t sockfd, int *error) return rc; } CURLcode Curl_store_ip_addr(struct connectdata *conn) { char addrbuf[256]; Curl_printable_address(conn->ip_addr, addrbuf, sizeof(addrbuf)); /* save the string */ Curl_safefree(conn->ip_addr_str); conn->ip_addr_str = strdup(addrbuf); if(!conn->ip_addr_str) return CURLE_OUT_OF_MEMORY; /* FAIL */ #ifdef PF_INET6 if(conn->ip_addr->ai_family == PF_INET6) conn->bits.ipv6 = TRUE; #endif return CURLE_OK; } /* Used within the multi interface. Try next IP address, return TRUE if no more address exists */ static bool trynextip(struct connectdata *conn, Loading @@ -450,6 +469,8 @@ static bool trynextip(struct connectdata *conn, /* store the new socket descriptor */ conn->sock[sockindex] = sockfd; conn->ip_addr = ai; Curl_store_ip_addr(conn); return FALSE; } ai = ai->ai_next; Loading
lib/connect.h +3 −1 Original line number Diff line number Diff line Loading @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * * Copyright (C) 1998 - 2004, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2005, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms Loading Loading @@ -39,6 +39,8 @@ CURLcode Curl_connecthost(struct connectdata *conn, int Curl_ourerrno(void); CURLcode Curl_store_ip_addr(struct connectdata *conn); #define DEFAULT_CONNECT_TIMEOUT 300000 /* milliseconds == five minutes */ #endif
lib/ftp.c +5 −9 Original line number Diff line number Diff line Loading @@ -1226,12 +1226,10 @@ CURLcode ftp_use_port(struct connectdata *conn) } #ifdef PF_INET6 if(!conn->bits.ftp_use_eprt && (conn->ip_addr->ai_family == PF_INET6)) { if(!conn->bits.ftp_use_eprt && conn->bits.ipv6) /* EPRT is disabled but we are connected to a IPv6 host, so we ignore the request! */ request and enable EPRT again! */ conn->bits.ftp_use_eprt = TRUE; } #endif for (fcmd = EPRT; fcmd != DONE; fcmd++) { Loading Loading @@ -1563,12 +1561,10 @@ CURLcode ftp_use_pasv(struct connectdata *conn, char newhost[NEWHOST_BUFSIZE]; #ifdef PF_INET6 if(!conn->bits.ftp_use_epsv && (conn->ip_addr->ai_family == PF_INET6)) { if(!conn->bits.ftp_use_epsv && conn->bits.ipv6) /* EPSV is disabled but we are connected to a IPv6 host, so we ignore the request! */ request and enable EPSV again! */ conn->bits.ftp_use_epsv = TRUE; } #endif for (modeoff = (conn->bits.ftp_use_epsv?0:1); Loading Loading @@ -1653,7 +1649,7 @@ CURLcode ftp_use_pasv(struct connectdata *conn, newport = num; /* We must use the same IP we are already connected to */ Curl_printable_address(conn->ip_addr, newhost, NEWHOST_BUFSIZE); snprintf(newhost, NEWHOST_BUFSIZE, "%s", conn->ip_addr_str); } } else Loading
lib/url.c +3 −18 Original line number Diff line number Diff line Loading @@ -1959,6 +1959,8 @@ static CURLcode ConnectPlease(struct connectdata *conn, conn->dns_entry = hostaddr; conn->ip_addr = addr; Curl_store_ip_addr(conn); if (conn->data->set.proxytype == CURLPROXY_SOCKS5) { return handleSock5Proxy(conn->proxyuser, conn->proxypasswd, Loading @@ -1982,24 +1984,7 @@ static CURLcode ConnectPlease(struct connectdata *conn, */ static void verboseconnect(struct connectdata *conn) { struct SessionHandle *data = conn->data; char addrbuf[256]; /* Get a printable version of the network address. */ if(!conn->bits.reuse) { Curl_printable_address(conn->ip_addr, addrbuf, sizeof(addrbuf)); /* save the string */ if(conn->ip_addr_str) free(conn->ip_addr_str); conn->ip_addr_str = strdup(addrbuf); if(!conn->ip_addr_str) return; /* FAIL */ } /* else, Re-used, ip_addr is not safe to access. */ infof(data, "Connected to %s (%s) port %d\n", infof(conn->data, "Connected to %s (%s) port %d\n", conn->bits.httpproxy ? conn->proxy.dispname : conn->host.dispname, conn->ip_addr_str, conn->port); } Loading