Blame SOURCES/0049-curl-7.29.0-8fa54098.patch

9d7d3f
From bf2eb071494dd48bf1730ce2bc7d21a8fd13b5c8 Mon Sep 17 00:00:00 2001
9d7d3f
From: Daniel Stenberg <daniel@haxx.se>
9d7d3f
Date: Sat, 26 Oct 2013 20:19:27 +0200
9d7d3f
Subject: [PATCH 1/7] FTP: make the data connection work when going through
9d7d3f
 proxy
9d7d3f
9d7d3f
This is a regression since the switch to always-multi internally
9d7d3f
c43127414d89c.
9d7d3f
9d7d3f
Upstream-commit: d44b0142714041b784ffd10792318674ecb1ed56
9d7d3f
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
9d7d3f
---
9d7d3f
 lib/connect.c |   2 +-
9d7d3f
 lib/ftp.c     | 183 +++++++++++++++++++++++++++++++---------------------------
9d7d3f
 lib/ftp.h     |   6 ++
9d7d3f
 lib/socks.c   |   4 ++
9d7d3f
 lib/url.c     |   9 ++-
9d7d3f
 lib/url.h     |   2 +-
9d7d3f
 6 files changed, 117 insertions(+), 89 deletions(-)
9d7d3f
9d7d3f
diff --git a/lib/connect.c b/lib/connect.c
9d7d3f
index 5aa53fe..78627e6 100644
9d7d3f
--- a/lib/connect.c
9d7d3f
+++ b/lib/connect.c
9d7d3f
@@ -715,7 +715,7 @@ CURLcode Curl_is_connected(struct connectdata *conn,
9d7d3f
       /* we are connected with TCP, awesome! */
9d7d3f
 
9d7d3f
       /* see if we need to do any proxy magic first once we connected */
9d7d3f
-      code = Curl_connected_proxy(conn);
9d7d3f
+      code = Curl_connected_proxy(conn, sockindex);
9d7d3f
       if(code)
9d7d3f
         return code;
9d7d3f
 
9d7d3f
diff --git a/lib/ftp.c b/lib/ftp.c
9d7d3f
index 63d1e64..b9fa12e 100644
9d7d3f
--- a/lib/ftp.c
9d7d3f
+++ b/lib/ftp.c
9d7d3f
@@ -1800,6 +1800,79 @@ static CURLcode ftp_epsv_disable(struct connectdata *conn)
9d7d3f
   return result;
9d7d3f
 }
9d7d3f
 
9d7d3f
+/*
9d7d3f
+ * Perform the necessary magic that needs to be done once the TCP connection
9d7d3f
+ * to the proxy has completed.
9d7d3f
+ */
9d7d3f
+static CURLcode proxy_magic(struct connectdata *conn,
9d7d3f
+                            char *newhost, unsigned short newport,
9d7d3f
+                            bool *magicdone)
9d7d3f
+{
9d7d3f
+  struct SessionHandle *data=conn->data;
9d7d3f
+  CURLcode result;
9d7d3f
+
9d7d3f
+  *magicdone = FALSE;
9d7d3f
+  switch(conn->proxytype) {
9d7d3f
+  case CURLPROXY_SOCKS5:
9d7d3f
+  case CURLPROXY_SOCKS5_HOSTNAME:
9d7d3f
+    result = Curl_SOCKS5(conn->proxyuser, conn->proxypasswd, newhost,
9d7d3f
+                         newport, SECONDARYSOCKET, conn);
9d7d3f
+    *magicdone = TRUE;
9d7d3f
+    break;
9d7d3f
+  case CURLPROXY_SOCKS4:
9d7d3f
+    result = Curl_SOCKS4(conn->proxyuser, newhost, newport,
9d7d3f
+                         SECONDARYSOCKET, conn, FALSE);
9d7d3f
+    *magicdone = TRUE;
9d7d3f
+    break;
9d7d3f
+  case CURLPROXY_SOCKS4A:
9d7d3f
+    result = Curl_SOCKS4(conn->proxyuser, newhost, newport,
9d7d3f
+                         SECONDARYSOCKET, conn, TRUE);
9d7d3f
+    *magicdone = TRUE;
9d7d3f
+    break;
9d7d3f
+  case CURLPROXY_HTTP:
9d7d3f
+  case CURLPROXY_HTTP_1_0:
9d7d3f
+    /* do nothing here. handled later. */
9d7d3f
+    break;
9d7d3f
+  default:
9d7d3f
+    failf(data, "unknown proxytype option given");
9d7d3f
+    result = CURLE_COULDNT_CONNECT;
9d7d3f
+    break;
9d7d3f
+  }
9d7d3f
+
9d7d3f
+  if(conn->bits.tunnel_proxy && conn->bits.httpproxy) {
9d7d3f
+    /* BLOCKING */
9d7d3f
+    /* We want "seamless" FTP operations through HTTP proxy tunnel */
9d7d3f
+
9d7d3f
+    /* Curl_proxyCONNECT is based on a pointer to a struct HTTP at the
9d7d3f
+     * member conn->proto.http; we want FTP through HTTP and we have to
9d7d3f
+     * change the member temporarily for connecting to the HTTP proxy. After
9d7d3f
+     * Curl_proxyCONNECT we have to set back the member to the original
9d7d3f
+     * struct FTP pointer
9d7d3f
+     */
9d7d3f
+    struct HTTP http_proxy;
9d7d3f
+    struct FTP *ftp_save = data->state.proto.ftp;
9d7d3f
+    memset(&http_proxy, 0, sizeof(http_proxy));
9d7d3f
+    data->state.proto.http = &http_proxy;
9d7d3f
+
9d7d3f
+    result = Curl_proxyCONNECT(conn, SECONDARYSOCKET, newhost, newport);
9d7d3f
+
9d7d3f
+    data->state.proto.ftp = ftp_save;
9d7d3f
+
9d7d3f
+    if(result)
9d7d3f
+      return result;
9d7d3f
+
9d7d3f
+    if(conn->tunnel_state[SECONDARYSOCKET] != TUNNEL_COMPLETE) {
9d7d3f
+      /* the CONNECT procedure is not complete, the tunnel is not yet up */
9d7d3f
+      state(conn, FTP_STOP); /* this phase is completed */
9d7d3f
+      conn->bits.tcpconnect[SECONDARYSOCKET] = FALSE;
9d7d3f
+      return result;
9d7d3f
+    }
9d7d3f
+    else
9d7d3f
+      *magicdone = TRUE;
9d7d3f
+  }
9d7d3f
+  return result;
9d7d3f
+}
9d7d3f
+
9d7d3f
 static CURLcode ftp_state_pasv_resp(struct connectdata *conn,
9d7d3f
                                     int ftpcode)
9d7d3f
 {
9d7d3f
@@ -1810,13 +1883,7 @@ static CURLcode ftp_state_pasv_resp(struct connectdata *conn,
9d7d3f
   struct Curl_dns_entry *addr=NULL;
9d7d3f
   int rc;
9d7d3f
   unsigned short connectport; /* the local port connect() should use! */
9d7d3f
-  unsigned short newport=0; /* remote port */
9d7d3f
   bool connected;
9d7d3f
-
9d7d3f
-  /* newhost must be able to hold a full IP-style address in ASCII, which
9d7d3f
-     in the IPv6 case means 5*8-1 = 39 letters */
9d7d3f
-#define NEWHOST_BUFSIZE 48
9d7d3f
-  char newhost[NEWHOST_BUFSIZE];
9d7d3f
   char *str=&data->state.buffer[4];  /* start on the first letter */
9d7d3f
 
9d7d3f
   if((ftpc->count1 == 0) &&
9d7d3f
@@ -1849,7 +1916,7 @@ static CURLcode ftp_state_pasv_resp(struct connectdata *conn,
9d7d3f
           return CURLE_FTP_WEIRD_PASV_REPLY;
9d7d3f
         }
9d7d3f
         if(ptr) {
9d7d3f
-          newport = (unsigned short)(num & 0xffff);
9d7d3f
+          ftpc->newport = (unsigned short)(num & 0xffff);
9d7d3f
 
9d7d3f
           if(conn->bits.tunnel_proxy ||
9d7d3f
              conn->proxytype == CURLPROXY_SOCKS5 ||
9d7d3f
@@ -1858,10 +1925,11 @@ static CURLcode ftp_state_pasv_resp(struct connectdata *conn,
9d7d3f
              conn->proxytype == CURLPROXY_SOCKS4A)
9d7d3f
             /* proxy tunnel -> use other host info because ip_addr_str is the
9d7d3f
                proxy address not the ftp host */
9d7d3f
-            snprintf(newhost, sizeof(newhost), "%s", conn->host.name);
9d7d3f
+            snprintf(ftpc->newhost, sizeof(ftpc->newhost), "%s",
9d7d3f
+                     conn->host.name);
9d7d3f
           else
9d7d3f
             /* use the same IP we are already connected to */
9d7d3f
-            snprintf(newhost, NEWHOST_BUFSIZE, "%s", conn->ip_addr_str);
9d7d3f
+            snprintf(ftpc->newhost, NEWHOST_BUFSIZE, "%s", conn->ip_addr_str);
9d7d3f
         }
9d7d3f
       }
9d7d3f
       else
9d7d3f
@@ -1914,14 +1982,15 @@ static CURLcode ftp_state_pasv_resp(struct connectdata *conn,
9d7d3f
          conn->proxytype == CURLPROXY_SOCKS4A)
9d7d3f
         /* proxy tunnel -> use other host info because ip_addr_str is the
9d7d3f
            proxy address not the ftp host */
9d7d3f
-        snprintf(newhost, sizeof(newhost), "%s", conn->host.name);
9d7d3f
+        snprintf(ftpc->newhost, sizeof(ftpc->newhost), "%s", conn->host.name);
9d7d3f
       else
9d7d3f
-        snprintf(newhost, sizeof(newhost), "%s", conn->ip_addr_str);
9d7d3f
+        snprintf(ftpc->newhost, sizeof(ftpc->newhost), "%s",
9d7d3f
+                 conn->ip_addr_str);
9d7d3f
     }
9d7d3f
     else
9d7d3f
-      snprintf(newhost, sizeof(newhost),
9d7d3f
+      snprintf(ftpc->newhost, sizeof(ftpc->newhost),
9d7d3f
                "%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]);
9d7d3f
-    newport = (unsigned short)(((port[0]<<8) + port[1]) & 0xffff);
9d7d3f
+    ftpc->newport = (unsigned short)(((port[0]<<8) + port[1]) & 0xffff);
9d7d3f
   }
9d7d3f
   else if(ftpc->count1 == 0) {
9d7d3f
     /* EPSV failed, move on to PASV */
9d7d3f
@@ -1957,15 +2026,15 @@ static CURLcode ftp_state_pasv_resp(struct connectdata *conn,
9d7d3f
   }
9d7d3f
   else {
9d7d3f
     /* normal, direct, ftp connection */
9d7d3f
-    rc = Curl_resolv(conn, newhost, newport, &addr);
9d7d3f
+    rc = Curl_resolv(conn, ftpc->newhost, ftpc->newport, &addr);
9d7d3f
     if(rc == CURLRESOLV_PENDING)
9d7d3f
       /* BLOCKING */
9d7d3f
       (void)Curl_resolver_wait_resolv(conn, &addr);
9d7d3f
 
9d7d3f
-    connectport = newport; /* we connect to the remote port */
9d7d3f
+    connectport = ftpc->newport; /* we connect to the remote port */
9d7d3f
 
9d7d3f
     if(!addr) {
9d7d3f
-      failf(data, "Can't resolve new host %s:%hu", newhost, connectport);
9d7d3f
+      failf(data, "Can't resolve new host %s:%hu", ftpc->newhost, connectport);
9d7d3f
       return CURLE_FTP_CANT_GET_HOST;
9d7d3f
     }
9d7d3f
   }
9d7d3f
@@ -1990,80 +2059,20 @@ static CURLcode ftp_state_pasv_resp(struct connectdata *conn,
9d7d3f
   /*
9d7d3f
    * When this is used from the multi interface, this might've returned with
9d7d3f
    * the 'connected' set to FALSE and thus we are now awaiting a non-blocking
9d7d3f
-   * connect to connect and we should not be "hanging" here waiting.
9d7d3f
+   * connect to connect.
9d7d3f
    */
9d7d3f
 
9d7d3f
   if(data->set.verbose)
9d7d3f
     /* this just dumps information about this second connection */
9d7d3f
-    ftp_pasv_verbose(conn, conninfo, newhost, connectport);
9d7d3f
-
9d7d3f
-  switch(conn->proxytype) {
9d7d3f
-    /* FIX: this MUST wait for a proper connect first if 'connected' is
9d7d3f
-     * FALSE */
9d7d3f
-  case CURLPROXY_SOCKS5:
9d7d3f
-  case CURLPROXY_SOCKS5_HOSTNAME:
9d7d3f
-    result = Curl_SOCKS5(conn->proxyuser, conn->proxypasswd, newhost, newport,
9d7d3f
-                         SECONDARYSOCKET, conn);
9d7d3f
-    connected = TRUE;
9d7d3f
-    break;
9d7d3f
-  case CURLPROXY_SOCKS4:
9d7d3f
-    result = Curl_SOCKS4(conn->proxyuser, newhost, newport,
9d7d3f
-                         SECONDARYSOCKET, conn, FALSE);
9d7d3f
-    connected = TRUE;
9d7d3f
-    break;
9d7d3f
-  case CURLPROXY_SOCKS4A:
9d7d3f
-    result = Curl_SOCKS4(conn->proxyuser, newhost, newport,
9d7d3f
-                         SECONDARYSOCKET, conn, TRUE);
9d7d3f
-    connected = TRUE;
9d7d3f
-    break;
9d7d3f
-  case CURLPROXY_HTTP:
9d7d3f
-  case CURLPROXY_HTTP_1_0:
9d7d3f
-    /* do nothing here. handled later. */
9d7d3f
-    break;
9d7d3f
-  default:
9d7d3f
-    failf(data, "unknown proxytype option given");
9d7d3f
-    result = CURLE_COULDNT_CONNECT;
9d7d3f
-    break;
9d7d3f
-  }
9d7d3f
-
9d7d3f
-  if(result) {
9d7d3f
-    if(ftpc->count1 == 0 && ftpcode == 229)
9d7d3f
-      return ftp_epsv_disable(conn);
9d7d3f
-    return result;
9d7d3f
-  }
9d7d3f
-
9d7d3f
-  if(conn->bits.tunnel_proxy && conn->bits.httpproxy) {
9d7d3f
-    /* FIX: this MUST wait for a proper connect first if 'connected' is
9d7d3f
-     * FALSE */
9d7d3f
-
9d7d3f
-    /* BLOCKING */
9d7d3f
-    /* We want "seamless" FTP operations through HTTP proxy tunnel */
9d7d3f
-
9d7d3f
-    /* Curl_proxyCONNECT is based on a pointer to a struct HTTP at the member
9d7d3f
-     * conn->proto.http; we want FTP through HTTP and we have to change the
9d7d3f
-     * member temporarily for connecting to the HTTP proxy. After
9d7d3f
-     * Curl_proxyCONNECT we have to set back the member to the original struct
9d7d3f
-     * FTP pointer
9d7d3f
-     */
9d7d3f
-    struct HTTP http_proxy;
9d7d3f
-    struct FTP *ftp_save = data->state.proto.ftp;
9d7d3f
-    memset(&http_proxy, 0, sizeof(http_proxy));
9d7d3f
-    data->state.proto.http = &http_proxy;
9d7d3f
-
9d7d3f
-    result = Curl_proxyCONNECT(conn, SECONDARYSOCKET, newhost, newport);
9d7d3f
+    ftp_pasv_verbose(conn, conninfo, ftpc->newhost, connectport);
9d7d3f
 
9d7d3f
-    data->state.proto.ftp = ftp_save;
9d7d3f
-
9d7d3f
-    if(result)
9d7d3f
-      return result;
9d7d3f
-
9d7d3f
-    if(conn->tunnel_state[SECONDARYSOCKET] != TUNNEL_COMPLETE) {
9d7d3f
-      /* the CONNECT procedure is not complete, the tunnel is not yet up */
9d7d3f
-      state(conn, FTP_STOP); /* this phase is completed */
9d7d3f
-      conn->bits.tcpconnect[SECONDARYSOCKET] = FALSE;
9d7d3f
-
9d7d3f
-      return result;
9d7d3f
-    }
9d7d3f
+  if(connected) {
9d7d3f
+    /* Only do the proxy connection magic if we're actually connected.  We do
9d7d3f
+       this little trick and send in the same 'connected' variable here again
9d7d3f
+       and it will be set FALSE by proxy_magic() for when for example the
9d7d3f
+       CONNECT procedure doesn't complete */
9d7d3f
+    infof(data, "Connection to proxy confirmed almost instantly\n");
9d7d3f
+    result = proxy_magic(conn, ftpc->newhost, ftpc->newport, &connected);
9d7d3f
   }
9d7d3f
 
9d7d3f
   conn->bits.tcpconnect[SECONDARYSOCKET] = connected;
9d7d3f
@@ -3686,6 +3695,10 @@ static CURLcode ftp_do_more(struct connectdata *conn, int *completep)
9d7d3f
     /* Ready to do more? */
9d7d3f
     if(connected) {
9d7d3f
       DEBUGF(infof(data, "DO-MORE connected phase starts\n"));
9d7d3f
+      if(conn->bits.proxy) {
9d7d3f
+        infof(data, "Connection to proxy confirmed\n");
9d7d3f
+        result = proxy_magic(conn, ftpc->newhost, ftpc->newport, &connected);
9d7d3f
+      }
9d7d3f
     }
9d7d3f
     else {
9d7d3f
       if(result && (ftpc->count1 == 0)) {
9d7d3f
diff --git a/lib/ftp.h b/lib/ftp.h
9d7d3f
index d359f28..4b4a488 100644
9d7d3f
--- a/lib/ftp.h
9d7d3f
+++ b/lib/ftp.h
9d7d3f
@@ -154,6 +154,12 @@ struct ftp_conn {
9d7d3f
   curl_off_t known_filesize; /* file size is different from -1, if wildcard
9d7d3f
                                 LIST parsing was done and wc_statemach set
9d7d3f
                                 it */
9d7d3f
+  /* newhost must be able to hold a full IP-style address in ASCII, which
9d7d3f
+     in the IPv6 case means 5*8-1 = 39 letters */
9d7d3f
+#define NEWHOST_BUFSIZE 48
9d7d3f
+  char newhost[NEWHOST_BUFSIZE]; /* this is the pair to connect the DATA... */
9d7d3f
+  unsigned short newport;        /* connection to */
9d7d3f
+
9d7d3f
 };
9d7d3f
 
9d7d3f
 #define DEFAULT_ACCEPT_TIMEOUT   60000 /* milliseconds == one minute */
9d7d3f
diff --git a/lib/socks.c b/lib/socks.c
9d7d3f
index 51bb946..0cf397c 100644
9d7d3f
--- a/lib/socks.c
9d7d3f
+++ b/lib/socks.c
9d7d3f
@@ -129,6 +129,8 @@ CURLcode Curl_SOCKS4(const char *proxy_name,
9d7d3f
 
9d7d3f
   curlx_nonblock(sock, FALSE);
9d7d3f
 
9d7d3f
+  infof(data, "SOCKS4 communication to %s:%d\n", hostname, remote_port);
9d7d3f
+
9d7d3f
   /*
9d7d3f
    * Compose socks4 request
9d7d3f
    *
9d7d3f
@@ -182,6 +184,8 @@ CURLcode Curl_SOCKS4(const char *proxy_name,
9d7d3f
       else
9d7d3f
         hp = NULL; /* fail! */
9d7d3f
 
9d7d3f
+      infof(data, "SOCKS4 connect to %s (locally resolved)\n", buf);
9d7d3f
+
9d7d3f
       Curl_resolv_unlock(data, dns); /* not used anymore from now on */
9d7d3f
 
9d7d3f
     }
9d7d3f
diff --git a/lib/url.c b/lib/url.c
9d7d3f
index cfc2744..11e0ff5 100644
9d7d3f
--- a/lib/url.c
9d7d3f
+++ b/lib/url.c
9d7d3f
@@ -3103,8 +3103,13 @@ static CURLcode ConnectionStore(struct SessionHandle *data,
9d7d3f
    Note: this function's sub-functions call failf()
9d7d3f
 
9d7d3f
 */
9d7d3f
-CURLcode Curl_connected_proxy(struct connectdata *conn)
9d7d3f
+CURLcode Curl_connected_proxy(struct connectdata *conn, int sockindex)
9d7d3f
 {
9d7d3f
+  if(!conn->bits.proxy || sockindex)
9d7d3f
+    /* this magic only works for the primary socket as the secondary is used
9d7d3f
+       for FTP only and it has FTP specific magic in ftp.c */
9d7d3f
+    return CURLE_OK;
9d7d3f
+
9d7d3f
   switch(conn->proxytype) {
9d7d3f
 #ifndef CURL_DISABLE_PROXY
9d7d3f
   case CURLPROXY_SOCKS5:
9d7d3f
@@ -3162,7 +3167,7 @@ static CURLcode ConnectPlease(struct SessionHandle *data,
9d7d3f
     conn->ip_addr = addr;
9d7d3f
 
9d7d3f
     if(*connected) {
9d7d3f
-      result = Curl_connected_proxy(conn);
9d7d3f
+      result = Curl_connected_proxy(conn, FIRSTSOCKET);
9d7d3f
       if(!result) {
9d7d3f
         conn->bits.tcpconnect[FIRSTSOCKET] = TRUE;
9d7d3f
         Curl_pgrsTime(data, TIMER_CONNECT); /* connect done */
9d7d3f
diff --git a/lib/url.h b/lib/url.h
9d7d3f
index c0d9c38..1da9be3 100644
9d7d3f
--- a/lib/url.h
9d7d3f
+++ b/lib/url.h
9d7d3f
@@ -74,7 +74,7 @@ void Curl_reset_reqproto(struct connectdata *conn);
9d7d3f
 #define CURL_DEFAULT_SOCKS5_GSSAPI_SERVICE "rcmd" /* default socks5 gssapi
9d7d3f
                                                      service */
9d7d3f
 
9d7d3f
-CURLcode Curl_connected_proxy(struct connectdata *conn);
9d7d3f
+CURLcode Curl_connected_proxy(struct connectdata *conn, int sockindex);
9d7d3f
 
9d7d3f
 #ifdef CURL_DISABLE_VERBOSE_STRINGS
9d7d3f
 #define Curl_verboseconnect(x)  Curl_nop_stmt
9d7d3f
-- 
9d7d3f
2.9.3
9d7d3f
9d7d3f
9d7d3f
From 4157798db51c859a1130203cebf377e77f56398a Mon Sep 17 00:00:00 2001
9d7d3f
From: Steve Holme <steve_holme@hotmail.com>
9d7d3f
Date: Sun, 27 Oct 2013 00:00:01 +0100
9d7d3f
Subject: [PATCH 2/7] ftp: Fixed compiler warning
9d7d3f
9d7d3f
warning: 'result' may be used uninitialized in this function
9d7d3f
9d7d3f
Upstream-commit: 9f503a254b0c720706124cb75922a0123f0079f0
9d7d3f
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
9d7d3f
---
9d7d3f
 lib/ftp.c | 2 +-
9d7d3f
 1 file changed, 1 insertion(+), 1 deletion(-)
9d7d3f
9d7d3f
diff --git a/lib/ftp.c b/lib/ftp.c
9d7d3f
index b9fa12e..9c863b9 100644
9d7d3f
--- a/lib/ftp.c
9d7d3f
+++ b/lib/ftp.c
9d7d3f
@@ -1808,8 +1808,8 @@ static CURLcode proxy_magic(struct connectdata *conn,
9d7d3f
                             char *newhost, unsigned short newport,
9d7d3f
                             bool *magicdone)
9d7d3f
 {
9d7d3f
+  CURLcode result = CURLE_OK;
9d7d3f
   struct SessionHandle *data=conn->data;
9d7d3f
-  CURLcode result;
9d7d3f
 
9d7d3f
   *magicdone = FALSE;
9d7d3f
   switch(conn->proxytype) {
9d7d3f
-- 
9d7d3f
2.9.3
9d7d3f
9d7d3f
9d7d3f
From 30566b76d17d9c5e13e3af621ecae0f4cafc3ac8 Mon Sep 17 00:00:00 2001
9d7d3f
From: Daniel Stenberg <daniel@haxx.se>
9d7d3f
Date: Sat, 19 Jul 2014 23:58:58 +0200
9d7d3f
Subject: [PATCH 3/7] CONNECT: Revert Curl_proxyCONNECT back to 7.29.0 design
9d7d3f
9d7d3f
This reverts commit cb3e6dfa3511 and instead fixes the problem
9d7d3f
differently.
9d7d3f
9d7d3f
The reverted commit addressed a test failure in test 1021 by simplifying
9d7d3f
and generalizing the code flow in a way that damaged the
9d7d3f
performance. Now we modify the flow so that Curl_proxyCONNECT() again
9d7d3f
does as much as possible in one go, yet still do test 1021 with and
9d7d3f
without valgrind. It failed due to mistakes in the multi state machine.
9d7d3f
9d7d3f
Bug: http://curl.haxx.se/bug/view.cgi?id=1397
9d7d3f
Reported-by: Paul Saab
9d7d3f
9d7d3f
Upstream-commit: a4cece3d47cf092da00cf9910e87bb60b9eff533
9d7d3f
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
9d7d3f
---
9d7d3f
 lib/http_proxy.c | 47 ++++++++++++++++++++++++++++++-----------------
9d7d3f
 lib/multi.c      | 16 ++++++++++------
9d7d3f
 2 files changed, 40 insertions(+), 23 deletions(-)
9d7d3f
9d7d3f
diff --git a/lib/http_proxy.c b/lib/http_proxy.c
9d7d3f
index c2eb667..d311b89 100644
9d7d3f
--- a/lib/http_proxy.c
9d7d3f
+++ b/lib/http_proxy.c
9d7d3f
@@ -98,8 +98,6 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn,
9d7d3f
   struct SessionHandle *data=conn->data;
9d7d3f
   struct SingleRequest *k = &data->req;
9d7d3f
   CURLcode result;
9d7d3f
-  long timeout =
9d7d3f
-    data->set.timeout?data->set.timeout:PROXY_TIMEOUT; /* in milliseconds */
9d7d3f
   curl_socket_t tunnelsocket = conn->sock[sockindex];
9d7d3f
   curl_off_t cl=0;
9d7d3f
   bool closeConnection = FALSE;
9d7d3f
@@ -223,14 +221,25 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn,
9d7d3f
         return result;
9d7d3f
 
9d7d3f
       conn->tunnel_state[sockindex] = TUNNEL_CONNECT;
9d7d3f
+    } /* END CONNECT PHASE */
9d7d3f
+
9d7d3f
+    check = Curl_timeleft(data, NULL, TRUE);
9d7d3f
+    if(check <= 0) {
9d7d3f
+      failf(data, "Proxy CONNECT aborted due to timeout");
9d7d3f
+      return CURLE_RECV_ERROR;
9d7d3f
+    }
9d7d3f
 
9d7d3f
-      /* now we've issued the CONNECT and we're waiting to hear back, return
9d7d3f
-         and get called again polling-style */
9d7d3f
+    if(0 == Curl_socket_ready(tunnelsocket, CURL_SOCKET_BAD, 0))
9d7d3f
+      /* return so we'll be called again polling-style */
9d7d3f
       return CURLE_OK;
9d7d3f
+    else {
9d7d3f
+      DEBUGF(infof(data,
9d7d3f
+                   "Read response immediately from proxy CONNECT\n"));
9d7d3f
+    }
9d7d3f
 
9d7d3f
-    } /* END CONNECT PHASE */
9d7d3f
+    /* at this point, the tunnel_connecting phase is over. */
9d7d3f
 
9d7d3f
-    { /* BEGIN NEGOTIATION PHASE */
9d7d3f
+    { /* READING RESPONSE PHASE */
9d7d3f
       size_t nread;   /* total size read */
9d7d3f
       int perline; /* count bytes per line */
9d7d3f
       int keepon=TRUE;
9d7d3f
@@ -247,9 +256,7 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn,
9d7d3f
 
9d7d3f
       while((nread
9d7d3f
 
9d7d3f
-        /* if timeout is requested, find out how much remaining time we have */
9d7d3f
-        check = timeout - /* timeout time */
9d7d3f
-          Curl_tvdiff(Curl_tvnow(), conn->now); /* spent time */
9d7d3f
+        check = Curl_timeleft(data, NULL, TRUE);
9d7d3f
         if(check <= 0) {
9d7d3f
           failf(data, "Proxy CONNECT aborted due to timeout");
9d7d3f
           error = SELECT_TIMEOUT; /* already too little time */
9d7d3f
@@ -279,6 +286,7 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn,
9d7d3f
               /* proxy auth was requested and there was proxy auth available,
9d7d3f
                  then deem this as "mere" proxy disconnect */
9d7d3f
               conn->bits.proxy_connect_closed = TRUE;
9d7d3f
+              infof(data, "Proxy CONNECT connection closed");
9d7d3f
             }
9d7d3f
             else {
9d7d3f
               error = SELECT_ERROR;
9d7d3f
@@ -519,7 +527,7 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn,
9d7d3f
         conn->sock[sockindex] = CURL_SOCKET_BAD;
9d7d3f
         break;
9d7d3f
       }
9d7d3f
-    } /* END NEGOTIATION PHASE */
9d7d3f
+    } /* END READING RESPONSE PHASE */
9d7d3f
 
9d7d3f
     /* If we are supposed to continue and request a new URL, which basically
9d7d3f
      * means the HTTP authentication is still going on so if the tunnel
9d7d3f
@@ -534,13 +542,11 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn,
9d7d3f
   } while(data->req.newurl);
9d7d3f
 
9d7d3f
   if(200 != data->req.httpcode) {
9d7d3f
-    failf(data, "Received HTTP code %d from proxy after CONNECT",
9d7d3f
-          data->req.httpcode);
9d7d3f
-
9d7d3f
-    if(closeConnection && data->req.newurl)
9d7d3f
+    if(closeConnection && data->req.newurl) {
9d7d3f
       conn->bits.proxy_connect_closed = TRUE;
9d7d3f
-
9d7d3f
-    if(data->req.newurl) {
9d7d3f
+      infof(data, "Connect me again please\n");
9d7d3f
+    }
9d7d3f
+    else if(data->req.newurl) {
9d7d3f
       /* this won't be used anymore for the CONNECT so free it now */
9d7d3f
       free(data->req.newurl);
9d7d3f
       data->req.newurl = NULL;
9d7d3f
@@ -549,7 +555,14 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn,
9d7d3f
     /* to back to init state */
9d7d3f
     conn->tunnel_state[sockindex] = TUNNEL_INIT;
9d7d3f
 
9d7d3f
-    return CURLE_RECV_ERROR;
9d7d3f
+    if(conn->bits.proxy_connect_closed)
9d7d3f
+      /* this is not an error, just part of the connection negotiation */
9d7d3f
+      return CURLE_OK;
9d7d3f
+    else {
9d7d3f
+      failf(data, "Received HTTP code %d from proxy after CONNECT",
9d7d3f
+            data->req.httpcode);
9d7d3f
+      return CURLE_RECV_ERROR;
9d7d3f
+    }
9d7d3f
   }
9d7d3f
 
9d7d3f
   conn->tunnel_state[sockindex] = TUNNEL_COMPLETE;
9d7d3f
diff --git a/lib/multi.c b/lib/multi.c
9d7d3f
index 0e0bb19..3029fa6 100644
9d7d3f
--- a/lib/multi.c
9d7d3f
+++ b/lib/multi.c
9d7d3f
@@ -1134,11 +1134,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
9d7d3f
       easy->result = Curl_http_connect(easy->easy_conn, &protocol_connect);
9d7d3f
 
9d7d3f
       if(easy->easy_conn->bits.proxy_connect_closed) {
9d7d3f
-        /* reset the error buffer */
9d7d3f
-        if(data->set.errorbuffer)
9d7d3f
-          data->set.errorbuffer[0] = '\0';
9d7d3f
-        data->state.errorbuf = FALSE;
9d7d3f
-
9d7d3f
+        /* connect back to proxy again */
9d7d3f
         easy->result = CURLE_OK;
9d7d3f
         result = CURLM_CALL_MULTI_PERFORM;
9d7d3f
         multistate(easy, CURLM_STATE_CONNECT);
9d7d3f
@@ -1164,7 +1160,15 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
9d7d3f
                                                &protocol_connect);
9d7d3f
       }
9d7d3f
 
9d7d3f
-      if(CURLE_OK != easy->result) {
9d7d3f
+      if(easy->easy_conn->bits.proxy_connect_closed) {
9d7d3f
+        /* connect back to proxy again since it was closed in a proxy CONNECT
9d7d3f
+           setup */
9d7d3f
+        easy->result = CURLE_OK;
9d7d3f
+        result = CURLM_CALL_MULTI_PERFORM;
9d7d3f
+        multistate(easy, CURLM_STATE_CONNECT);
9d7d3f
+        break;
9d7d3f
+      }
9d7d3f
+      else if(CURLE_OK != easy->result) {
9d7d3f
         /* failure detected */
9d7d3f
         /* Just break, the cleaning up is handled all in one place */
9d7d3f
         disconnect_conn = TRUE;
9d7d3f
-- 
9d7d3f
2.9.3
9d7d3f
9d7d3f
9d7d3f
From 6ab9346d63e88ddfb8fd3f509ad350cab24c37f4 Mon Sep 17 00:00:00 2001
9d7d3f
From: Daniel Stenberg <daniel@haxx.se>
9d7d3f
Date: Wed, 17 Jun 2015 00:30:06 +0200
9d7d3f
Subject: [PATCH 4/7] FTP: do the HTTP CONNECT for data connection blocking
9d7d3f
9d7d3f
** WORK-AROUND **
9d7d3f
9d7d3f
The introduced non-blocking general behaviour for Curl_proxyCONNECT()
9d7d3f
didn't work for the data connection establishment unless it was very
9d7d3f
fast. The newly introduced function argument makes it operate in a more
9d7d3f
blocking manner, more like it used to work in the past. This blocking
9d7d3f
approach is only used when the FTP data connecting through HTTP proxy.
9d7d3f
9d7d3f
Blocking like this is bad. A better fix would make it work more
9d7d3f
asynchronously.
9d7d3f
9d7d3f
Bug: https://github.com/bagder/curl/issues/278
9d7d3f
9d7d3f
Upstream-commit: b88f980a7437abc1159a1185c04d381347c8f5b1
9d7d3f
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
9d7d3f
---
9d7d3f
 lib/ftp.c        |  4 ++--
9d7d3f
 lib/http_proxy.c | 22 ++++++++++++++--------
9d7d3f
 lib/http_proxy.h |  3 ++-
9d7d3f
 3 files changed, 18 insertions(+), 11 deletions(-)
9d7d3f
9d7d3f
diff --git a/lib/ftp.c b/lib/ftp.c
9d7d3f
index 63d1e64..db1e29e 100644
9d7d3f
--- a/lib/ftp.c
9d7d3f
+++ b/lib/ftp.c
9d7d3f
@@ -1854,7 +1854,7 @@ static CURLcode proxy_magic(struct connectdata *conn,
9d7d3f
     memset(&http_proxy, 0, sizeof(http_proxy));
9d7d3f
     data->state.proto.http = &http_proxy;
9d7d3f
 
9d7d3f
-    result = Curl_proxyCONNECT(conn, SECONDARYSOCKET, newhost, newport);
9d7d3f
+    result = Curl_proxyCONNECT(conn, SECONDARYSOCKET, newhost, newport, TRUE);
9d7d3f
 
9d7d3f
     data->state.proto.ftp = ftp_save;
9d7d3f
 
9d7d3f
@@ -3685,7 +3685,7 @@ static CURLcode ftp_do_more(struct connectdata *conn, int *completep)
9d7d3f
     if(conn->tunnel_state[SECONDARYSOCKET] == TUNNEL_CONNECT) {
9d7d3f
       /* As we're in TUNNEL_CONNECT state now, we know the proxy name and port
9d7d3f
          aren't used so we blank their arguments. TODO: make this nicer */
9d7d3f
-      result = Curl_proxyCONNECT(conn, SECONDARYSOCKET, NULL, 0);
9d7d3f
+      result = Curl_proxyCONNECT(conn, SECONDARYSOCKET, NULL, 0, FALSE);
9d7d3f
 
9d7d3f
       return result;
9d7d3f
     }
9d7d3f
diff --git a/lib/http_proxy.c b/lib/http_proxy.c
9d7d3f
index d311b89..4ab280f 100644
9d7d3f
--- a/lib/http_proxy.c
9d7d3f
+++ b/lib/http_proxy.c
9d7d3f
@@ -71,7 +71,7 @@ CURLcode Curl_proxy_connect(struct connectdata *conn)
9d7d3f
     conn->data->state.proto.http = &http_proxy;
9d7d3f
     conn->bits.close = FALSE;
9d7d3f
     result = Curl_proxyCONNECT(conn, FIRSTSOCKET,
9d7d3f
-                               conn->host.name, conn->remote_port);
9d7d3f
+                               conn->host.name, conn->remote_port, FALSE);
9d7d3f
     conn->data->state.proto.generic = prot_save;
9d7d3f
     if(CURLE_OK != result)
9d7d3f
       return result;
9d7d3f
@@ -87,12 +87,16 @@ CURLcode Curl_proxy_connect(struct connectdata *conn)
9d7d3f
  * Curl_proxyCONNECT() requires that we're connected to a HTTP proxy. This
9d7d3f
  * function will issue the necessary commands to get a seamless tunnel through
9d7d3f
  * this proxy. After that, the socket can be used just as a normal socket.
9d7d3f
+ *
9d7d3f
+ * 'blocking' set to TRUE means that this function will do the entire CONNECT
9d7d3f
+ * + response in a blocking fashion. Should be avoided!
9d7d3f
  */
9d7d3f
 
9d7d3f
 CURLcode Curl_proxyCONNECT(struct connectdata *conn,
9d7d3f
                            int sockindex,
9d7d3f
                            const char *hostname,
9d7d3f
-                           unsigned short remote_port)
9d7d3f
+                           unsigned short remote_port,
9d7d3f
+                           bool blocking)
9d7d3f
 {
9d7d3f
   int subversion=0;
9d7d3f
   struct SessionHandle *data=conn->data;
9d7d3f
@@ -229,12 +233,14 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn,
9d7d3f
       return CURLE_RECV_ERROR;
9d7d3f
     }
9d7d3f
 
9d7d3f
-    if(0 == Curl_socket_ready(tunnelsocket, CURL_SOCKET_BAD, 0))
9d7d3f
-      /* return so we'll be called again polling-style */
9d7d3f
-      return CURLE_OK;
9d7d3f
-    else {
9d7d3f
-      DEBUGF(infof(data,
9d7d3f
-                   "Read response immediately from proxy CONNECT\n"));
9d7d3f
+    if(!blocking) {
9d7d3f
+      if(0 == Curl_socket_ready(tunnelsocket, CURL_SOCKET_BAD, 0))
9d7d3f
+        /* return so we'll be called again polling-style */
9d7d3f
+        return CURLE_OK;
9d7d3f
+      else {
9d7d3f
+        DEBUGF(infof(data,
9d7d3f
+               "Read response immediately from proxy CONNECT\n"));
9d7d3f
+      }
9d7d3f
     }
9d7d3f
 
9d7d3f
     /* at this point, the tunnel_connecting phase is over. */
9d7d3f
diff --git a/lib/http_proxy.h b/lib/http_proxy.h
9d7d3f
index 518c093..4dddc3b 100644
9d7d3f
--- a/lib/http_proxy.h
9d7d3f
+++ b/lib/http_proxy.h
9d7d3f
@@ -26,7 +26,8 @@
9d7d3f
 /* ftp can use this as well */
9d7d3f
 CURLcode Curl_proxyCONNECT(struct connectdata *conn,
9d7d3f
                            int tunnelsocket,
9d7d3f
-                           const char *hostname, unsigned short remote_port);
9d7d3f
+                           const char *hostname, unsigned short remote_port,
9d7d3f
+                           bool blocking);
9d7d3f
 
9d7d3f
 /* Default proxy timeout in milliseconds */
9d7d3f
 #define PROXY_TIMEOUT (3600*1000)
9d7d3f
-- 
9d7d3f
2.9.3
9d7d3f
9d7d3f
9d7d3f
From 7be64d4d3e1b966d491c6cde4fe3b6d69f03185b Mon Sep 17 00:00:00 2001
9d7d3f
From: Kamil Dudka <kdudka@redhat.com>
9d7d3f
Date: Thu, 9 Feb 2017 16:21:52 +0100
9d7d3f
Subject: [PATCH 5/7] nss: make FTPS work with --proxytunnel
9d7d3f
9d7d3f
If the NSS code was in the middle of a non-blocking handshake and it
9d7d3f
was asked to finish the handshake in blocking mode, it unexpectedly
9d7d3f
continued in the non-blocking mode, which caused a FTPS connection
9d7d3f
over CONNECT to fail with "(81) Socket not ready for send/recv".
9d7d3f
9d7d3f
Bug: https://bugzilla.redhat.com/1420327
9d7d3f
9d7d3f
Upstream-commit: 8fa5409800668ad5305e7517597286014c7708fb
9d7d3f
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
9d7d3f
---
9d7d3f
 lib/nss.c | 23 +++++++++++------------
9d7d3f
 1 file changed, 11 insertions(+), 12 deletions(-)
9d7d3f
9d7d3f
diff --git a/lib/nss.c b/lib/nss.c
9d7d3f
index 848ce86..cf45f3a 100644
9d7d3f
--- a/lib/nss.c
9d7d3f
+++ b/lib/nss.c
9d7d3f
@@ -1305,13 +1305,14 @@ static CURLcode nss_fail_connect(struct ssl_connect_data *connssl,
9d7d3f
   return curlerr;
9d7d3f
 }
9d7d3f
 
9d7d3f
-/* Switch the SSL socket into non-blocking mode. */
9d7d3f
-static CURLcode nss_set_nonblock(struct ssl_connect_data *connssl,
9d7d3f
-                                 struct SessionHandle *data)
9d7d3f
+/* Switch the SSL socket into blocking or non-blocking mode. */
9d7d3f
+static CURLcode nss_set_blocking(struct ssl_connect_data *connssl,
9d7d3f
+                                 struct SessionHandle *data,
9d7d3f
+                                 bool blocking)
9d7d3f
 {
9d7d3f
   static PRSocketOptionData sock_opt;
9d7d3f
   sock_opt.option = PR_SockOpt_Nonblocking;
9d7d3f
-  sock_opt.value.non_blocking = PR_TRUE;
9d7d3f
+  sock_opt.value.non_blocking = !blocking;
9d7d3f
 
9d7d3f
   if(PR_SetSocketOption(connssl->handle, &sock_opt) != PR_SUCCESS)
9d7d3f
     return nss_fail_connect(connssl, data, CURLE_SSL_CONNECT_ERROR);
9d7d3f
@@ -1615,16 +1616,14 @@ static CURLcode nss_connect_common(struct connectdata *conn, int sockindex,
9d7d3f
       /* we do not expect CURLE_AGAIN from nss_setup_connect() */
9d7d3f
       return rv;
9d7d3f
 
9d7d3f
-    if(!blocking) {
9d7d3f
-      /* in non-blocking mode, set NSS non-blocking mode before handshake */
9d7d3f
-      rv = nss_set_nonblock(connssl, data);
9d7d3f
-      if(rv)
9d7d3f
-        return rv;
9d7d3f
-    }
9d7d3f
-
9d7d3f
     connssl->connecting_state = ssl_connect_2;
9d7d3f
   }
9d7d3f
 
9d7d3f
+  /* enable/disable blocking mode before handshake */
9d7d3f
+  rv = nss_set_blocking(connssl, data, blocking);
9d7d3f
+  if(rv)
9d7d3f
+    return rv;
9d7d3f
+
9d7d3f
   rv = nss_do_connect(conn, sockindex);
9d7d3f
   switch(rv) {
9d7d3f
   case CURLE_OK:
9d7d3f
@@ -1640,7 +1639,7 @@ static CURLcode nss_connect_common(struct connectdata *conn, int sockindex,
9d7d3f
 
9d7d3f
   if(blocking) {
9d7d3f
     /* in blocking mode, set NSS non-blocking mode _after_ SSL handshake */
9d7d3f
-    rv = nss_set_nonblock(connssl, data);
9d7d3f
+    rv = nss_set_blocking(connssl, data, /* blocking */ FALSE);
9d7d3f
     if(rv)
9d7d3f
       return rv;
9d7d3f
   }
9d7d3f
-- 
9d7d3f
2.7.4
9d7d3f
9d7d3f
9d7d3f
From 9dbd6550acdc143da0b044ae3b06368a87c8449a Mon Sep 17 00:00:00 2001
9d7d3f
From: Kamil Dudka <kdudka@redhat.com>
9d7d3f
Date: Mon, 27 Mar 2017 18:00:44 +0200
9d7d3f
Subject: [PATCH 6/7] url: plug memory leaks triggered by
9d7d3f
 curl-7_37_1-19-ga4cece3
9d7d3f
9d7d3f
---
9d7d3f
 lib/url.c | 9 +++++++++
9d7d3f
 1 file changed, 9 insertions(+)
9d7d3f
9d7d3f
diff --git a/lib/url.c b/lib/url.c
9d7d3f
index cfc2744..ed72be1 100644
9d7d3f
--- a/lib/url.c
9d7d3f
+++ b/lib/url.c
9d7d3f
@@ -421,6 +421,7 @@ CURLcode Curl_close(struct SessionHandle *data)
9d7d3f
   data->state.path = NULL;
9d7d3f
 
9d7d3f
   Curl_safefree(data->state.proto.generic);
9d7d3f
+  Curl_safefree(data->req.newurl);
9d7d3f
 
9d7d3f
   /* Close down all open SSL info and sessions */
9d7d3f
   Curl_ssl_close_all(data);
9d7d3f
@@ -3923,6 +3924,14 @@ static CURLcode setup_connection_internals(struct connectdata *conn)
9d7d3f
   const struct Curl_handler * p;
9d7d3f
   CURLcode result;
9d7d3f
 
9d7d3f
+  /* XXX: picked from curl-7_32_0-2-g4ad8e14 */
9d7d3f
+  /* in some case in the multi state-machine, we go back to the CONNECT state
9d7d3f
+     and then a second (or third or...) call to this function will be made
9d7d3f
+     without doing a DISCONNECT or DONE in between (since the connection is
9d7d3f
+     yet in place) and therefore this function needs to first make sure
9d7d3f
+     there's no lingering previous data allocated. */
9d7d3f
+  Curl_safefree(conn->data->req.newurl);
9d7d3f
+
9d7d3f
   conn->socktype = SOCK_STREAM; /* most of them are TCP streams */
9d7d3f
 
9d7d3f
   /* Scan protocol handler table. */
9d7d3f
-- 
9d7d3f
2.9.3
9d7d3f
9d7d3f
9d7d3f
From cfb58b02f5bb78a2f4b17f3bb6ce6acd196b3ec6 Mon Sep 17 00:00:00 2001
9d7d3f
From: Kamil Dudka <kdudka@redhat.com>
9d7d3f
Date: Tue, 28 Mar 2017 15:50:59 +0200
9d7d3f
Subject: [PATCH 7/7] http: do not treat FTPS over CONNECT as HTTPS
9d7d3f
9d7d3f
If we use FTPS over CONNECT, the TLS handshake for the FTPS control
9d7d3f
connection needs to be initiated in the SENDPROTOCONNECT state, not
9d7d3f
the WAITPROXYCONNECT state.  Otherwise, if the TLS handshake completed
9d7d3f
without blocking, the information about the completed TLS handshake
9d7d3f
would be saved to a wrong flag.  Consequently, the TLS handshake would
9d7d3f
be initiated in the SENDPROTOCONNECT state once again on the same
9d7d3f
connection, resulting in a failure of the TLS handshake.  I was able to
9d7d3f
observe the failure with the NSS backend if curl ran through valgrind.
9d7d3f
9d7d3f
Note that this commit partially reverts curl-7_21_6-52-ge34131d.
9d7d3f
9d7d3f
Upstream-commit: 2549831daaa3aef394f7b42e750cba1afae35642
9d7d3f
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
9d7d3f
---
9d7d3f
 lib/http.c | 2 +-
9d7d3f
 1 file changed, 1 insertion(+), 1 deletion(-)
9d7d3f
9d7d3f
diff --git a/lib/http.c b/lib/http.c
9d7d3f
index 04beeb1..db37cf9 100644
9d7d3f
--- a/lib/http.c
9d7d3f
+++ b/lib/http.c
9d7d3f
@@ -1310,7 +1310,7 @@ CURLcode Curl_http_connect(struct connectdata *conn, bool *done)
9d7d3f
     /* nothing else to do except wait right now - we're not done here. */
9d7d3f
     return CURLE_OK;
9d7d3f
 
9d7d3f
-  if(conn->given->flags & PROTOPT_SSL) {
9d7d3f
+  if(conn->given->protocol & CURLPROTO_HTTPS) {
9d7d3f
     /* perform SSL initialization */
9d7d3f
     result = https_connecting(conn, done);
9d7d3f
     if(result)
9d7d3f
-- 
9d7d3f
2.9.3
9d7d3f