Commit 710f14ed authored by Daniel Stenberg's avatar Daniel Stenberg
Browse files

handler: make 'protocol' always specified as a single bit

This makes the findprotocol() function work as intended so that libcurl
can properly be restricted to not support HTTP while still supporting
HTTPS - since the HTTPS handler previously set both the HTTP and HTTPS
bits in the protocol field.

This fixes --proto and --proto-redir for most SSL protocols.

This is done by adding a few new convenience defines that groups HTTP
and HTTPS, FTP and FTPS etc that should then be used when the code wants
to check for both protocols at once. PROTO_FAMILY_[protocol] style.

Bug: https://github.com/bagder/curl/pull/97
Reported-by: drizzt
parent cf9342e2
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -208,7 +208,7 @@ const struct Curl_handler Curl_handler_ftps = {
  ftp_disconnect,                  /* disconnect */
  ZERO_NULL,                       /* readwrite */
  PORT_FTPS,                       /* defport */
  CURLPROTO_FTP | CURLPROTO_FTPS,  /* protocol */
  CURLPROTO_FTPS,                  /* protocol */
  PROTOPT_SSL | PROTOPT_DUAL | PROTOPT_CLOSEACTION |
  PROTOPT_NEEDSPWD | PROTOPT_NOURLQUERY /* flags */
};
+4 −4
Original line number Diff line number Diff line
@@ -144,7 +144,7 @@ const struct Curl_handler Curl_handler_https = {
  ZERO_NULL,                            /* disconnect */
  ZERO_NULL,                            /* readwrite */
  PORT_HTTPS,                           /* defport */
  CURLPROTO_HTTP | CURLPROTO_HTTPS,     /* protocol */
  CURLPROTO_HTTPS,                      /* protocol */
  PROTOPT_SSL | PROTOPT_CREDSPERREQUEST /* flags */
};
#endif
@@ -1771,7 +1771,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
  }
  http->writebytecount = http->readbytecount = 0;

  if((conn->handler->protocol&(CURLPROTO_HTTP|CURLPROTO_FTP)) &&
  if((conn->handler->protocol&(PROTO_FAMILY_HTTP|CURLPROTO_FTP)) &&
     data->set.upload) {
    httpreq = HTTPREQ_PUT;
  }
@@ -1883,7 +1883,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
        Curl_compareheader(ptr, "Transfer-Encoding:", "chunked");
    }
    else {
      if((conn->handler->protocol&CURLPROTO_HTTP) &&
      if((conn->handler->protocol&PROTO_FAMILY_HTTP) &&
         data->set.upload &&
         (data->set.infilesize == -1)) {
        if(conn->bits.authneg)
@@ -3190,7 +3190,7 @@ CURLcode Curl_http_readwrite_headers(struct SessionHandle *data,
#define HEADER1 k->p /* no conversion needed, just use k->p */
#endif /* CURL_DOES_CONVERSIONS */

      if(conn->handler->protocol & CURLPROTO_HTTP) {
      if(conn->handler->protocol & PROTO_FAMILY_HTTP) {
        nc = sscanf(HEADER1,
                    " HTTP/%d.%d %3d",
                    &httpversion_major,
+1 −1
Original line number Diff line number Diff line
@@ -136,7 +136,7 @@ const struct Curl_handler Curl_handler_http2_ssl = {
  http2_disconnect,                     /* disconnect */
  ZERO_NULL,                            /* readwrite */
  PORT_HTTP,                            /* defport */
  CURLPROTO_HTTP | CURLPROTO_HTTPS,     /* protocol */
  CURLPROTO_HTTPS,                      /* protocol */
  PROTOPT_SSL                           /* flags */
};

+1 −1
Original line number Diff line number Diff line
@@ -155,7 +155,7 @@ const struct Curl_handler Curl_handler_imaps = {
  imap_disconnect,                  /* disconnect */
  ZERO_NULL,                        /* readwrite */
  PORT_IMAPS,                       /* defport */
  CURLPROTO_IMAP | CURLPROTO_IMAPS, /* protocol */
  CURLPROTO_IMAPS,                  /* protocol */
  PROTOPT_CLOSEACTION | PROTOPT_SSL |
  PROTOPT_NEEDSPWD                  /* flags */
};
+2 −2
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@
 *                | (__| |_| |  _ <| |___
 *                 \___|\___/|_| \_\_____|
 *
 * Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
 * Copyright (C) 1998 - 2014, 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
@@ -159,7 +159,7 @@ const struct Curl_handler Curl_handler_ldaps = {
  ZERO_NULL,                            /* disconnect */
  ZERO_NULL,                            /* readwrite */
  PORT_LDAPS,                           /* defport */
  CURLPROTO_LDAP | CURLPROTO_LDAPS,     /* protocol */
  CURLPROTO_LDAPS,                      /* protocol */
  PROTOPT_SSL                           /* flags */
};
#endif
Loading