summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Lloyd <l-busybox@pgl22.co.uk>2018-03-05 00:17:02 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2018-03-05 00:19:33 +0100
commit804ce5a6fed63a2da6268a2d06f1ee2075435297 (patch)
treeb72e3cdcd4245f4574dd1def927f38759077cb90
parentd9aabfe578e58ef8a884c402d6294edc8dfda883 (diff)
downloadbusybox-w32-804ce5a6fed63a2da6268a2d06f1ee2075435297.tar.gz
busybox-w32-804ce5a6fed63a2da6268a2d06f1ee2075435297.tar.bz2
busybox-w32-804ce5a6fed63a2da6268a2d06f1ee2075435297.zip
wget: fix fetching of https URLs with http proxy
When fetching a https:// URL with HTTP proxy configured (e.g. with environment variable http_proxy=http://your-proxy:3128) busybox was making a https connection to the proxy. This was because the protocol scheme for the target URL was used to determine whether to connect to the proxy over SSL or not. When the proxy is in use, the decision on whether to connect to the proxy over https should based on the proxy URL not on the target URL. function old new delta wget_main 2381 2387 +6 Signed-off-by: Peter Lloyd <l-busybox@pgl22.co.uk> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--networking/wget.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/networking/wget.c b/networking/wget.c
index 3a5d68173..8969310a4 100644
--- a/networking/wget.c
+++ b/networking/wget.c
@@ -1011,7 +1011,6 @@ static void download_one_url(const char *url)
1011 len_and_sockaddr *lsa; 1011 len_and_sockaddr *lsa;
1012 FILE *sfp; /* socket to web/ftp server */ 1012 FILE *sfp; /* socket to web/ftp server */
1013 FILE *dfp; /* socket to ftp server (data) */ 1013 FILE *dfp; /* socket to ftp server (data) */
1014 char *proxy = NULL;
1015 char *fname_out_alloc; 1014 char *fname_out_alloc;
1016 char *redirected_path = NULL; 1015 char *redirected_path = NULL;
1017 struct host_info server; 1016 struct host_info server;
@@ -1027,13 +1026,14 @@ static void download_one_url(const char *url)
1027 /* Use the proxy if necessary */ 1026 /* Use the proxy if necessary */
1028 use_proxy = (strcmp(G.proxy_flag, "off") != 0); 1027 use_proxy = (strcmp(G.proxy_flag, "off") != 0);
1029 if (use_proxy) { 1028 if (use_proxy) {
1030 proxy = getenv(target.protocol[0] == 'f' ? "ftp_proxy" : "http_proxy"); 1029 char *proxy = getenv(target.protocol[0] == 'f' ? "ftp_proxy" : "http_proxy");
1031//FIXME: what if protocol is https? Ok to use http_proxy? 1030//FIXME: what if protocol is https? Ok to use http_proxy?
1032 use_proxy = (proxy && proxy[0]); 1031 use_proxy = (proxy && proxy[0]);
1033 if (use_proxy) 1032 if (use_proxy)
1034 parse_url(proxy, &server); 1033 parse_url(proxy, &server);
1035 } 1034 }
1036 if (!use_proxy) { 1035 if (!use_proxy) {
1036 server.protocol = target.protocol;
1037 server.port = target.port; 1037 server.port = target.port;
1038 if (ENABLE_FEATURE_IPV6) { 1038 if (ENABLE_FEATURE_IPV6) {
1039 //free(server.allocated); - can't be non-NULL 1039 //free(server.allocated); - can't be non-NULL
@@ -1098,7 +1098,7 @@ static void download_one_url(const char *url)
1098 /* Open socket to http(s) server */ 1098 /* Open socket to http(s) server */
1099#if ENABLE_FEATURE_WGET_OPENSSL 1099#if ENABLE_FEATURE_WGET_OPENSSL
1100 /* openssl (and maybe internal TLS) support is configured */ 1100 /* openssl (and maybe internal TLS) support is configured */
1101 if (target.protocol == P_HTTPS) { 1101 if (server.protocol == P_HTTPS) {
1102 /* openssl-based helper 1102 /* openssl-based helper
1103 * Inconvenient API since we can't give it an open fd 1103 * Inconvenient API since we can't give it an open fd
1104 */ 1104 */
@@ -1122,7 +1122,7 @@ static void download_one_url(const char *url)
1122#elif ENABLE_FEATURE_WGET_HTTPS 1122#elif ENABLE_FEATURE_WGET_HTTPS
1123 /* Only internal TLS support is configured */ 1123 /* Only internal TLS support is configured */
1124 sfp = open_socket(lsa); 1124 sfp = open_socket(lsa);
1125 if (target.protocol == P_HTTPS) 1125 if (server.protocol == P_HTTPS)
1126 spawn_ssl_client(server.host, fileno(sfp), /*flags*/ 0); 1126 spawn_ssl_client(server.host, fileno(sfp), /*flags*/ 0);
1127#else 1127#else
1128 /* ssl (https) support is not configured */ 1128 /* ssl (https) support is not configured */