13ec90
From 74ba80e293eb2521d28916b24c3be59b3baf688a Mon Sep 17 00:00:00 2001
13ec90
From: Daniel Stenberg <daniel@haxx.se>
13ec90
Date: Thu, 18 Feb 2021 10:13:56 +0100
13ec90
Subject: [PATCH 1/2] urldata: remove the _ORIG suffix from string names
13ec90
13ec90
It doesn't provide any useful info but only makes the names longer.
13ec90
13ec90
Closes #6624
13ec90
13ec90
Upstream-commit: 70472a44deaff387cf8c8c197e04f3add2a96e2e
13ec90
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
13ec90
---
13ec90
 lib/setopt.c         | 32 ++++++++++++++++----------------
13ec90
 lib/url.c            | 32 ++++++++++++++++----------------
13ec90
 lib/urldata.h        | 28 ++++++++++++++--------------
13ec90
 lib/vtls/cyassl.c    |  2 +-
13ec90
 lib/vtls/darwinssl.c |  4 ++--
13ec90
 lib/vtls/gskit.c     |  2 +-
13ec90
 lib/vtls/gtls.c      |  2 +-
13ec90
 lib/vtls/mbedtls.c   |  2 +-
13ec90
 lib/vtls/nss.c       |  2 +-
13ec90
 lib/vtls/openssl.c   |  2 +-
13ec90
 lib/vtls/polarssl.c  |  2 +-
13ec90
 lib/vtls/schannel.c  |  2 +-
13ec90
 12 files changed, 56 insertions(+), 56 deletions(-)
13ec90
13ec90
diff --git a/lib/setopt.c b/lib/setopt.c
13ec90
index 4f04962..b07ccfe 100644
13ec90
--- a/lib/setopt.c
13ec90
+++ b/lib/setopt.c
13ec90
@@ -133,7 +133,7 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option,
13ec90
     break;
13ec90
   case CURLOPT_SSL_CIPHER_LIST:
13ec90
     /* set a list of cipher we want to use in the SSL connection */
13ec90
-    result = Curl_setstropt(&data->set.str[STRING_SSL_CIPHER_LIST_ORIG],
13ec90
+    result = Curl_setstropt(&data->set.str[STRING_SSL_CIPHER_LIST],
13ec90
                             va_arg(param, char *));
13ec90
     break;
13ec90
   case CURLOPT_PROXY_SSL_CIPHER_LIST:
13ec90
@@ -145,7 +145,7 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option,
13ec90
   case CURLOPT_TLS13_CIPHERS:
13ec90
     if(Curl_ssl_tls13_ciphersuites()) {
13ec90
       /* set preferred list of TLS 1.3 cipher suites */
13ec90
-      result = Curl_setstropt(&data->set.str[STRING_SSL_CIPHER13_LIST_ORIG],
13ec90
+      result = Curl_setstropt(&data->set.str[STRING_SSL_CIPHER13_LIST],
13ec90
                               va_arg(param, char *));
13ec90
     }
13ec90
     else
13ec90
@@ -1532,7 +1532,7 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option,
13ec90
     /*
13ec90
      * String that holds file name of the SSL certificate to use
13ec90
      */
13ec90
-    result = Curl_setstropt(&data->set.str[STRING_CERT_ORIG],
13ec90
+    result = Curl_setstropt(&data->set.str[STRING_CERT],
13ec90
                             va_arg(param, char *));
13ec90
     break;
13ec90
   case CURLOPT_PROXY_SSLCERT:
13ec90
@@ -1546,7 +1546,7 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option,
13ec90
     /*
13ec90
      * String that holds file type of the SSL certificate to use
13ec90
      */
13ec90
-    result = Curl_setstropt(&data->set.str[STRING_CERT_TYPE_ORIG],
13ec90
+    result = Curl_setstropt(&data->set.str[STRING_CERT_TYPE],
13ec90
                             va_arg(param, char *));
13ec90
     break;
13ec90
   case CURLOPT_PROXY_SSLCERTTYPE:
13ec90
@@ -1560,7 +1560,7 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option,
13ec90
     /*
13ec90
      * String that holds file name of the SSL key to use
13ec90
      */
13ec90
-    result = Curl_setstropt(&data->set.str[STRING_KEY_ORIG],
13ec90
+    result = Curl_setstropt(&data->set.str[STRING_KEY],
13ec90
                             va_arg(param, char *));
13ec90
     break;
13ec90
   case CURLOPT_PROXY_SSLKEY:
13ec90
@@ -1574,7 +1574,7 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option,
13ec90
     /*
13ec90
      * String that holds file type of the SSL key to use
13ec90
      */
13ec90
-    result = Curl_setstropt(&data->set.str[STRING_KEY_TYPE_ORIG],
13ec90
+    result = Curl_setstropt(&data->set.str[STRING_KEY_TYPE],
13ec90
                             va_arg(param, char *));
13ec90
     break;
13ec90
   case CURLOPT_PROXY_SSLKEYTYPE:
13ec90
@@ -1588,7 +1588,7 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option,
13ec90
     /*
13ec90
      * String that holds the SSL or SSH private key password.
13ec90
      */
13ec90
-    result = Curl_setstropt(&data->set.str[STRING_KEY_PASSWD_ORIG],
13ec90
+    result = Curl_setstropt(&data->set.str[STRING_KEY_PASSWD],
13ec90
                             va_arg(param, char *));
13ec90
     break;
13ec90
   case CURLOPT_PROXY_KEYPASSWD:
13ec90
@@ -1815,7 +1815,7 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option,
13ec90
      */
13ec90
 #ifdef USE_SSL
13ec90
     if(Curl_ssl->supports & SSLSUPP_PINNEDPUBKEY)
13ec90
-      result = Curl_setstropt(&data->set.str[STRING_SSL_PINNEDPUBLICKEY_ORIG],
13ec90
+      result = Curl_setstropt(&data->set.str[STRING_SSL_PINNEDPUBLICKEY],
13ec90
                               va_arg(param, char *));
13ec90
     else
13ec90
 #endif
13ec90
@@ -1838,7 +1838,7 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option,
13ec90
     /*
13ec90
      * Set CA info for SSL connection. Specify file name of the CA certificate
13ec90
      */
13ec90
-    result = Curl_setstropt(&data->set.str[STRING_SSL_CAFILE_ORIG],
13ec90
+    result = Curl_setstropt(&data->set.str[STRING_SSL_CAFILE],
13ec90
                             va_arg(param, char *));
13ec90
     break;
13ec90
   case CURLOPT_PROXY_CAINFO:
13ec90
@@ -1857,7 +1857,7 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option,
13ec90
 #ifdef USE_SSL
13ec90
     if(Curl_ssl->supports & SSLSUPP_CA_PATH)
13ec90
       /* This does not work on windows. */
13ec90
-      result = Curl_setstropt(&data->set.str[STRING_SSL_CAPATH_ORIG],
13ec90
+      result = Curl_setstropt(&data->set.str[STRING_SSL_CAPATH],
13ec90
                               va_arg(param, char *));
13ec90
     else
13ec90
 #endif
13ec90
@@ -1882,7 +1882,7 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option,
13ec90
      * Set CRL file info for SSL connection. Specify file name of the CRL
13ec90
      * to check certificates revocation
13ec90
      */
13ec90
-    result = Curl_setstropt(&data->set.str[STRING_SSL_CRLFILE_ORIG],
13ec90
+    result = Curl_setstropt(&data->set.str[STRING_SSL_CRLFILE],
13ec90
                             va_arg(param, char *));
13ec90
     break;
13ec90
   case CURLOPT_PROXY_CRLFILE:
13ec90
@@ -1898,7 +1898,7 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option,
13ec90
      * Set Issuer certificate file
13ec90
      * to check certificates issuer
13ec90
      */
13ec90
-    result = Curl_setstropt(&data->set.str[STRING_SSL_ISSUERCERT_ORIG],
13ec90
+    result = Curl_setstropt(&data->set.str[STRING_SSL_ISSUERCERT],
13ec90
                             va_arg(param, char *));
13ec90
     break;
13ec90
   case CURLOPT_TELNETOPTIONS:
13ec90
@@ -2449,9 +2449,9 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option,
13ec90
     break;
13ec90
 #ifdef USE_TLS_SRP
13ec90
   case CURLOPT_TLSAUTH_USERNAME:
13ec90
-    result = Curl_setstropt(&data->set.str[STRING_TLSAUTH_USERNAME_ORIG],
13ec90
+    result = Curl_setstropt(&data->set.str[STRING_TLSAUTH_USERNAME],
13ec90
                             va_arg(param, char *));
13ec90
-    if(data->set.str[STRING_TLSAUTH_USERNAME_ORIG] && !data->set.ssl.authtype)
13ec90
+    if(data->set.str[STRING_TLSAUTH_USERNAME] && !data->set.ssl.authtype)
13ec90
       data->set.ssl.authtype = CURL_TLSAUTH_SRP; /* default to SRP */
13ec90
     break;
13ec90
   case CURLOPT_PROXY_TLSAUTH_USERNAME:
13ec90
@@ -2462,9 +2462,9 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option,
13ec90
       data->set.proxy_ssl.authtype = CURL_TLSAUTH_SRP; /* default to SRP */
13ec90
     break;
13ec90
   case CURLOPT_TLSAUTH_PASSWORD:
13ec90
-    result = Curl_setstropt(&data->set.str[STRING_TLSAUTH_PASSWORD_ORIG],
13ec90
+    result = Curl_setstropt(&data->set.str[STRING_TLSAUTH_PASSWORD],
13ec90
                             va_arg(param, char *));
13ec90
-    if(data->set.str[STRING_TLSAUTH_USERNAME_ORIG] && !data->set.ssl.authtype)
13ec90
+    if(data->set.str[STRING_TLSAUTH_USERNAME] && !data->set.ssl.authtype)
13ec90
       data->set.ssl.authtype = CURL_TLSAUTH_SRP; /* default to SRP */
13ec90
     break;
13ec90
   case CURLOPT_PROXY_TLSAUTH_PASSWORD:
13ec90
diff --git a/lib/url.c b/lib/url.c
13ec90
index bb9d107..a6bc012 100644
13ec90
--- a/lib/url.c
13ec90
+++ b/lib/url.c
13ec90
@@ -496,7 +496,7 @@ CURLcode Curl_init_userdefined(struct Curl_easy *data)
13ec90
    */
13ec90
   if(Curl_ssl_backend() != CURLSSLBACKEND_SCHANNEL) {
13ec90
 #if defined(CURL_CA_BUNDLE)
13ec90
-    result = Curl_setstropt(&set->str[STRING_SSL_CAFILE_ORIG], CURL_CA_BUNDLE);
13ec90
+    result = Curl_setstropt(&set->str[STRING_SSL_CAFILE], CURL_CA_BUNDLE);
13ec90
     if(result)
13ec90
       return result;
13ec90
 
13ec90
@@ -506,7 +506,7 @@ CURLcode Curl_init_userdefined(struct Curl_easy *data)
13ec90
       return result;
13ec90
 #endif
13ec90
 #if defined(CURL_CA_PATH)
13ec90
-    result = Curl_setstropt(&set->str[STRING_SSL_CAPATH_ORIG], CURL_CA_PATH);
13ec90
+    result = Curl_setstropt(&set->str[STRING_SSL_CAPATH], CURL_CA_PATH);
13ec90
     if(result)
13ec90
       return result;
13ec90
 
13ec90
@@ -4333,9 +4333,9 @@ static CURLcode create_conn(struct Curl_easy *data,
13ec90
      that will be freed as part of the Curl_easy struct, but all cloned
13ec90
      copies will be separately allocated.
13ec90
   */
13ec90
-  data->set.ssl.primary.CApath = data->set.str[STRING_SSL_CAPATH_ORIG];
13ec90
+  data->set.ssl.primary.CApath = data->set.str[STRING_SSL_CAPATH];
13ec90
   data->set.proxy_ssl.primary.CApath = data->set.str[STRING_SSL_CAPATH_PROXY];
13ec90
-  data->set.ssl.primary.CAfile = data->set.str[STRING_SSL_CAFILE_ORIG];
13ec90
+  data->set.ssl.primary.CAfile = data->set.str[STRING_SSL_CAFILE];
13ec90
   data->set.proxy_ssl.primary.CAfile = data->set.str[STRING_SSL_CAFILE_PROXY];
13ec90
   data->set.ssl.primary.random_file = data->set.str[STRING_SSL_RANDOM_FILE];
13ec90
   data->set.proxy_ssl.primary.random_file =
13ec90
@@ -4343,34 +4343,34 @@ static CURLcode create_conn(struct Curl_easy *data,
13ec90
   data->set.ssl.primary.egdsocket = data->set.str[STRING_SSL_EGDSOCKET];
13ec90
   data->set.proxy_ssl.primary.egdsocket = data->set.str[STRING_SSL_EGDSOCKET];
13ec90
   data->set.ssl.primary.cipher_list =
13ec90
-    data->set.str[STRING_SSL_CIPHER_LIST_ORIG];
13ec90
+    data->set.str[STRING_SSL_CIPHER_LIST];
13ec90
   data->set.proxy_ssl.primary.cipher_list =
13ec90
     data->set.str[STRING_SSL_CIPHER_LIST_PROXY];
13ec90
   data->set.ssl.primary.cipher_list13 =
13ec90
-    data->set.str[STRING_SSL_CIPHER13_LIST_ORIG];
13ec90
+    data->set.str[STRING_SSL_CIPHER13_LIST];
13ec90
   data->set.proxy_ssl.primary.cipher_list13 =
13ec90
     data->set.str[STRING_SSL_CIPHER13_LIST_PROXY];
13ec90
 
13ec90
-  data->set.ssl.CRLfile = data->set.str[STRING_SSL_CRLFILE_ORIG];
13ec90
+  data->set.ssl.CRLfile = data->set.str[STRING_SSL_CRLFILE];
13ec90
   data->set.proxy_ssl.CRLfile = data->set.str[STRING_SSL_CRLFILE_PROXY];
13ec90
-  data->set.ssl.issuercert = data->set.str[STRING_SSL_ISSUERCERT_ORIG];
13ec90
+  data->set.ssl.issuercert = data->set.str[STRING_SSL_ISSUERCERT];
13ec90
   data->set.proxy_ssl.issuercert = data->set.str[STRING_SSL_ISSUERCERT_PROXY];
13ec90
-  data->set.ssl.cert = data->set.str[STRING_CERT_ORIG];
13ec90
+  data->set.ssl.cert = data->set.str[STRING_CERT];
13ec90
   data->set.proxy_ssl.cert = data->set.str[STRING_CERT_PROXY];
13ec90
-  data->set.ssl.cert_type = data->set.str[STRING_CERT_TYPE_ORIG];
13ec90
+  data->set.ssl.cert_type = data->set.str[STRING_CERT_TYPE];
13ec90
   data->set.proxy_ssl.cert_type = data->set.str[STRING_CERT_TYPE_PROXY];
13ec90
-  data->set.ssl.key = data->set.str[STRING_KEY_ORIG];
13ec90
+  data->set.ssl.key = data->set.str[STRING_KEY];
13ec90
   data->set.proxy_ssl.key = data->set.str[STRING_KEY_PROXY];
13ec90
-  data->set.ssl.key_type = data->set.str[STRING_KEY_TYPE_ORIG];
13ec90
+  data->set.ssl.key_type = data->set.str[STRING_KEY_TYPE];
13ec90
   data->set.proxy_ssl.key_type = data->set.str[STRING_KEY_TYPE_PROXY];
13ec90
-  data->set.ssl.key_passwd = data->set.str[STRING_KEY_PASSWD_ORIG];
13ec90
+  data->set.ssl.key_passwd = data->set.str[STRING_KEY_PASSWD];
13ec90
   data->set.proxy_ssl.key_passwd = data->set.str[STRING_KEY_PASSWD_PROXY];
13ec90
-  data->set.ssl.primary.clientcert = data->set.str[STRING_CERT_ORIG];
13ec90
+  data->set.ssl.primary.clientcert = data->set.str[STRING_CERT];
13ec90
   data->set.proxy_ssl.primary.clientcert = data->set.str[STRING_CERT_PROXY];
13ec90
 #ifdef USE_TLS_SRP
13ec90
-  data->set.ssl.username = data->set.str[STRING_TLSAUTH_USERNAME_ORIG];
13ec90
+  data->set.ssl.username = data->set.str[STRING_TLSAUTH_USERNAME];
13ec90
   data->set.proxy_ssl.username = data->set.str[STRING_TLSAUTH_USERNAME_PROXY];
13ec90
-  data->set.ssl.password = data->set.str[STRING_TLSAUTH_PASSWORD_ORIG];
13ec90
+  data->set.ssl.password = data->set.str[STRING_TLSAUTH_PASSWORD];
13ec90
   data->set.proxy_ssl.password = data->set.str[STRING_TLSAUTH_PASSWORD_PROXY];
13ec90
 #endif
13ec90
 
13ec90
diff --git a/lib/urldata.h b/lib/urldata.h
13ec90
index c70290a..1f8f364 100644
13ec90
--- a/lib/urldata.h
13ec90
+++ b/lib/urldata.h
13ec90
@@ -1366,9 +1366,9 @@ struct DynamicStatic {
13ec90
 struct Curl_multi;    /* declared and used only in multi.c */
13ec90
 
13ec90
 enum dupstring {
13ec90
-  STRING_CERT_ORIG,       /* client certificate file name */
13ec90
+  STRING_CERT,            /* client certificate file name */
13ec90
   STRING_CERT_PROXY,      /* client certificate file name */
13ec90
-  STRING_CERT_TYPE_ORIG,  /* format for certificate (default: PEM)*/
13ec90
+  STRING_CERT_TYPE,       /* format for certificate (default: PEM)*/
13ec90
   STRING_CERT_TYPE_PROXY, /* format for certificate (default: PEM)*/
13ec90
   STRING_COOKIE,          /* HTTP cookie string to send */
13ec90
   STRING_COOKIEJAR,       /* dump all cookies to this file */
13ec90
@@ -1379,11 +1379,11 @@ enum dupstring {
13ec90
   STRING_FTP_ACCOUNT,     /* ftp account data */
13ec90
   STRING_FTP_ALTERNATIVE_TO_USER, /* command to send if USER/PASS fails */
13ec90
   STRING_FTPPORT,         /* port to send with the FTP PORT command */
13ec90
-  STRING_KEY_ORIG,        /* private key file name */
13ec90
+  STRING_KEY,             /* private key file name */
13ec90
   STRING_KEY_PROXY,       /* private key file name */
13ec90
-  STRING_KEY_PASSWD_ORIG, /* plain text private key password */
13ec90
+  STRING_KEY_PASSWD,      /* plain text private key password */
13ec90
   STRING_KEY_PASSWD_PROXY, /* plain text private key password */
13ec90
-  STRING_KEY_TYPE_ORIG,   /* format for private key (default: PEM) */
13ec90
+  STRING_KEY_TYPE,        /* format for private key (default: PEM) */
13ec90
   STRING_KEY_TYPE_PROXY,  /* format for private key (default: PEM) */
13ec90
   STRING_KRB_LEVEL,       /* krb security level */
13ec90
   STRING_NETRC_FILE,      /* if not NULL, use this instead of trying to find
13ec90
@@ -1393,22 +1393,22 @@ enum dupstring {
13ec90
   STRING_SET_RANGE,       /* range, if used */
13ec90
   STRING_SET_REFERER,     /* custom string for the HTTP referer field */
13ec90
   STRING_SET_URL,         /* what original URL to work on */
13ec90
-  STRING_SSL_CAPATH_ORIG, /* CA directory name (doesn't work on windows) */
13ec90
+  STRING_SSL_CAPATH,      /* CA directory name (doesn't work on windows) */
13ec90
   STRING_SSL_CAPATH_PROXY, /* CA directory name (doesn't work on windows) */
13ec90
-  STRING_SSL_CAFILE_ORIG, /* certificate file to verify peer against */
13ec90
+  STRING_SSL_CAFILE,      /* certificate file to verify peer against */
13ec90
   STRING_SSL_CAFILE_PROXY, /* certificate file to verify peer against */
13ec90
-  STRING_SSL_PINNEDPUBLICKEY_ORIG, /* public key file to verify peer against */
13ec90
+  STRING_SSL_PINNEDPUBLICKEY, /* public key file to verify peer against */
13ec90
   STRING_SSL_PINNEDPUBLICKEY_PROXY, /* public key file to verify proxy */
13ec90
-  STRING_SSL_CIPHER_LIST_ORIG, /* list of ciphers to use */
13ec90
+  STRING_SSL_CIPHER_LIST, /* list of ciphers to use */
13ec90
   STRING_SSL_CIPHER_LIST_PROXY, /* list of ciphers to use */
13ec90
-  STRING_SSL_CIPHER13_LIST_ORIG, /* list of TLS 1.3 ciphers to use */
13ec90
+  STRING_SSL_CIPHER13_LIST, /* list of TLS 1.3 ciphers to use */
13ec90
   STRING_SSL_CIPHER13_LIST_PROXY, /* list of TLS 1.3 ciphers to use */
13ec90
   STRING_SSL_EGDSOCKET,   /* path to file containing the EGD daemon socket */
13ec90
   STRING_SSL_RANDOM_FILE, /* path to file containing "random" data */
13ec90
   STRING_USERAGENT,       /* User-Agent string */
13ec90
-  STRING_SSL_CRLFILE_ORIG, /* crl file to check certificate */
13ec90
+  STRING_SSL_CRLFILE,     /* crl file to check certificate */
13ec90
   STRING_SSL_CRLFILE_PROXY, /* crl file to check certificate */
13ec90
-  STRING_SSL_ISSUERCERT_ORIG, /* issuer cert file to check certificate */
13ec90
+  STRING_SSL_ISSUERCERT, /* issuer cert file to check certificate */
13ec90
   STRING_SSL_ISSUERCERT_PROXY, /* issuer cert file to check certificate */
13ec90
   STRING_SSL_ENGINE,      /* name of ssl engine */
13ec90
   STRING_USERNAME,        /* <username>, if used */
13ec90
@@ -1433,9 +1433,9 @@ enum dupstring {
13ec90
   STRING_MAIL_AUTH,
13ec90
 
13ec90
 #ifdef USE_TLS_SRP
13ec90
-  STRING_TLSAUTH_USERNAME_ORIG,  /* TLS auth <username> */
13ec90
+  STRING_TLSAUTH_USERNAME,  /* TLS auth <username> */
13ec90
   STRING_TLSAUTH_USERNAME_PROXY, /* TLS auth <username> */
13ec90
-  STRING_TLSAUTH_PASSWORD_ORIG,  /* TLS auth <password> */
13ec90
+  STRING_TLSAUTH_PASSWORD,  /* TLS auth <password> */
13ec90
   STRING_TLSAUTH_PASSWORD_PROXY, /* TLS auth <password> */
13ec90
 #endif
13ec90
   STRING_BEARER,                /* <bearer>, if used */
13ec90
diff --git a/lib/vtls/cyassl.c b/lib/vtls/cyassl.c
13ec90
index e10398a..ffd116d 100644
13ec90
--- a/lib/vtls/cyassl.c
13ec90
+++ b/lib/vtls/cyassl.c
13ec90
@@ -474,7 +474,7 @@ cyassl_connect_step2(struct connectdata *conn,
13ec90
     conn->http_proxy.host.dispname : conn->host.dispname;
13ec90
   const char * const pinnedpubkey = SSL_IS_PROXY() ?
13ec90
                         data->set.str[STRING_SSL_PINNEDPUBLICKEY_PROXY] :
13ec90
-                        data->set.str[STRING_SSL_PINNEDPUBLICKEY_ORIG];
13ec90
+                        data->set.str[STRING_SSL_PINNEDPUBLICKEY];
13ec90
 
13ec90
   conn->recv[sockindex] = cyassl_recv;
13ec90
   conn->send[sockindex] = cyassl_send;
13ec90
diff --git a/lib/vtls/darwinssl.c b/lib/vtls/darwinssl.c
13ec90
index 1aea0dc..572e8bf 100644
13ec90
--- a/lib/vtls/darwinssl.c
13ec90
+++ b/lib/vtls/darwinssl.c
13ec90
@@ -2449,9 +2449,9 @@ darwinssl_connect_step2(struct connectdata *conn, int sockindex)
13ec90
     connssl->connecting_state = ssl_connect_3;
13ec90
 
13ec90
 #ifdef DARWIN_SSL_PINNEDPUBKEY
13ec90
-    if(data->set.str[STRING_SSL_PINNEDPUBLICKEY_ORIG]) {
13ec90
+    if(data->set.str[STRING_SSL_PINNEDPUBLICKEY]) {
13ec90
       CURLcode result = pkp_pin_peer_pubkey(data, BACKEND->ssl_ctx,
13ec90
-                            data->set.str[STRING_SSL_PINNEDPUBLICKEY_ORIG]);
13ec90
+                            data->set.str[STRING_SSL_PINNEDPUBLICKEY]);
13ec90
       if(result) {
13ec90
         failf(data, "SSL: public key does not match pinned public key!");
13ec90
         return result;
13ec90
diff --git a/lib/vtls/gskit.c b/lib/vtls/gskit.c
13ec90
index a0b4960..b4c7b8a 100644
13ec90
--- a/lib/vtls/gskit.c
13ec90
+++ b/lib/vtls/gskit.c
13ec90
@@ -1136,7 +1136,7 @@ static CURLcode gskit_connect_step3(struct connectdata *conn, int sockindex)
13ec90
 
13ec90
   /* Check pinned public key. */
13ec90
   ptr = SSL_IS_PROXY() ? data->set.str[STRING_SSL_PINNEDPUBLICKEY_PROXY] :
13ec90
-                         data->set.str[STRING_SSL_PINNEDPUBLICKEY_ORIG];
13ec90
+    data->set.str[STRING_SSL_PINNEDPUBLICKEY];
13ec90
   if(!result && ptr) {
13ec90
     curl_X509certificate x509;
13ec90
     curl_asn1Element *p;
13ec90
diff --git a/lib/vtls/gtls.c b/lib/vtls/gtls.c
13ec90
index 207b0fd..c5eb948 100644
13ec90
--- a/lib/vtls/gtls.c
13ec90
+++ b/lib/vtls/gtls.c
13ec90
@@ -1329,7 +1329,7 @@ gtls_connect_step3(struct connectdata *conn,
13ec90
   }
13ec90
 
13ec90
   ptr = SSL_IS_PROXY() ? data->set.str[STRING_SSL_PINNEDPUBLICKEY_PROXY] :
13ec90
-        data->set.str[STRING_SSL_PINNEDPUBLICKEY_ORIG];
13ec90
+    data->set.str[STRING_SSL_PINNEDPUBLICKEY];
13ec90
   if(ptr) {
13ec90
     result = pkp_pin_peer_pubkey(data, x509_cert, ptr);
13ec90
     if(result != CURLE_OK) {
13ec90
diff --git a/lib/vtls/mbedtls.c b/lib/vtls/mbedtls.c
13ec90
index d7759dc..48010ae 100644
13ec90
--- a/lib/vtls/mbedtls.c
13ec90
+++ b/lib/vtls/mbedtls.c
13ec90
@@ -540,7 +540,7 @@ mbed_connect_step2(struct connectdata *conn,
13ec90
   const mbedtls_x509_crt *peercert;
13ec90
   const char * const pinnedpubkey = SSL_IS_PROXY() ?
13ec90
         data->set.str[STRING_SSL_PINNEDPUBLICKEY_PROXY] :
13ec90
-        data->set.str[STRING_SSL_PINNEDPUBLICKEY_ORIG];
13ec90
+        data->set.str[STRING_SSL_PINNEDPUBLICKEY];
13ec90
 
13ec90
 #ifdef HAS_ALPN
13ec90
   const char *next_protocol;
13ec90
diff --git a/lib/vtls/nss.c b/lib/vtls/nss.c
13ec90
index 89f8183..366bf9e 100644
13ec90
--- a/lib/vtls/nss.c
13ec90
+++ b/lib/vtls/nss.c
13ec90
@@ -2067,7 +2067,7 @@ static CURLcode nss_do_connect(struct connectdata *conn, int sockindex)
13ec90
     &data->set.proxy_ssl.certverifyresult : &data->set.ssl.certverifyresult;
13ec90
   const char * const pinnedpubkey = SSL_IS_PROXY() ?
13ec90
               data->set.str[STRING_SSL_PINNEDPUBLICKEY_PROXY] :
13ec90
-              data->set.str[STRING_SSL_PINNEDPUBLICKEY_ORIG];
13ec90
+              data->set.str[STRING_SSL_PINNEDPUBLICKEY];
13ec90
 
13ec90
 
13ec90
   /* check timeout situation */
13ec90
diff --git a/lib/vtls/openssl.c b/lib/vtls/openssl.c
13ec90
index 35cd652..8c97c1d 100644
13ec90
--- a/lib/vtls/openssl.c
13ec90
+++ b/lib/vtls/openssl.c
13ec90
@@ -3388,7 +3388,7 @@ static CURLcode servercert(struct connectdata *conn,
13ec90
     result = CURLE_OK;
13ec90
 
13ec90
   ptr = SSL_IS_PROXY() ? data->set.str[STRING_SSL_PINNEDPUBLICKEY_PROXY] :
13ec90
-                         data->set.str[STRING_SSL_PINNEDPUBLICKEY_ORIG];
13ec90
+    data->set.str[STRING_SSL_PINNEDPUBLICKEY];
13ec90
   if(!result && ptr) {
13ec90
     result = pkp_pin_peer_pubkey(data, BACKEND->server_cert, ptr);
13ec90
     if(result)
13ec90
diff --git a/lib/vtls/polarssl.c b/lib/vtls/polarssl.c
13ec90
index 604cb4c..f284ad1 100644
13ec90
--- a/lib/vtls/polarssl.c
13ec90
+++ b/lib/vtls/polarssl.c
13ec90
@@ -459,7 +459,7 @@ polarssl_connect_step2(struct connectdata *conn,
13ec90
   char buffer[1024];
13ec90
   const char * const pinnedpubkey = SSL_IS_PROXY() ?
13ec90
             data->set.str[STRING_SSL_PINNEDPUBLICKEY_PROXY] :
13ec90
-            data->set.str[STRING_SSL_PINNEDPUBLICKEY_ORIG];
13ec90
+            data->set.str[STRING_SSL_PINNEDPUBLICKEY];
13ec90
 
13ec90
 
13ec90
   char errorbuf[128];
13ec90
diff --git a/lib/vtls/schannel.c b/lib/vtls/schannel.c
13ec90
index 8f6c301..95c060b 100644
13ec90
--- a/lib/vtls/schannel.c
13ec90
+++ b/lib/vtls/schannel.c
13ec90
@@ -1060,7 +1060,7 @@ schannel_connect_step2(struct connectdata *conn, int sockindex)
13ec90
 
13ec90
   pubkey_ptr = SSL_IS_PROXY() ?
13ec90
     data->set.str[STRING_SSL_PINNEDPUBLICKEY_PROXY] :
13ec90
-    data->set.str[STRING_SSL_PINNEDPUBLICKEY_ORIG];
13ec90
+    data->set.str[STRING_SSL_PINNEDPUBLICKEY];
13ec90
   if(pubkey_ptr) {
13ec90
     result = pkp_pin_peer_pubkey(conn, sockindex, pubkey_ptr);
13ec90
     if(result) {
13ec90
-- 
13ec90
2.31.1
13ec90
13ec90
13ec90
From 040fa4f60f9b809972d51184dfa4980ba44d8b6b Mon Sep 17 00:00:00 2001
13ec90
From: Daniel Stenberg <daniel@haxx.se>
13ec90
Date: Sat, 19 Jun 2021 00:42:28 +0200
13ec90
Subject: [PATCH 2/2] vtls: fix connection reuse checks for issuer cert and
13ec90
 case sensitivity
13ec90
13ec90
CVE-2021-22924
13ec90
13ec90
Reported-by: Harry Sintonen
13ec90
Bug: https://curl.se/docs/CVE-2021-22924.html
13ec90
13ec90
Upstream-commit: 5ea3145850ebff1dc2b13d17440300a01ca38161
13ec90
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
13ec90
---
13ec90
 lib/url.c          |  5 +++--
13ec90
 lib/urldata.h      |  2 +-
13ec90
 lib/vtls/gtls.c    | 10 +++++-----
13ec90
 lib/vtls/nss.c     |  4 ++--
13ec90
 lib/vtls/openssl.c | 12 ++++++------
13ec90
 lib/vtls/vtls.c    | 21 ++++++++++++++++-----
13ec90
 6 files changed, 33 insertions(+), 21 deletions(-)
13ec90
13ec90
diff --git a/lib/url.c b/lib/url.c
13ec90
index a6bc012..4803653 100644
13ec90
--- a/lib/url.c
13ec90
+++ b/lib/url.c
13ec90
@@ -4337,6 +4337,9 @@ static CURLcode create_conn(struct Curl_easy *data,
13ec90
   data->set.proxy_ssl.primary.CApath = data->set.str[STRING_SSL_CAPATH_PROXY];
13ec90
   data->set.ssl.primary.CAfile = data->set.str[STRING_SSL_CAFILE];
13ec90
   data->set.proxy_ssl.primary.CAfile = data->set.str[STRING_SSL_CAFILE_PROXY];
13ec90
+  data->set.ssl.primary.issuercert = data->set.str[STRING_SSL_ISSUERCERT];
13ec90
+  data->set.proxy_ssl.primary.issuercert =
13ec90
+    data->set.str[STRING_SSL_ISSUERCERT_PROXY];
13ec90
   data->set.ssl.primary.random_file = data->set.str[STRING_SSL_RANDOM_FILE];
13ec90
   data->set.proxy_ssl.primary.random_file =
13ec90
     data->set.str[STRING_SSL_RANDOM_FILE];
13ec90
@@ -4353,8 +4356,6 @@ static CURLcode create_conn(struct Curl_easy *data,
13ec90
 
13ec90
   data->set.ssl.CRLfile = data->set.str[STRING_SSL_CRLFILE];
13ec90
   data->set.proxy_ssl.CRLfile = data->set.str[STRING_SSL_CRLFILE_PROXY];
13ec90
-  data->set.ssl.issuercert = data->set.str[STRING_SSL_ISSUERCERT];
13ec90
-  data->set.proxy_ssl.issuercert = data->set.str[STRING_SSL_ISSUERCERT_PROXY];
13ec90
   data->set.ssl.cert = data->set.str[STRING_CERT];
13ec90
   data->set.proxy_ssl.cert = data->set.str[STRING_CERT_PROXY];
13ec90
   data->set.ssl.cert_type = data->set.str[STRING_CERT_TYPE];
13ec90
diff --git a/lib/urldata.h b/lib/urldata.h
13ec90
index 1f8f364..72a36fb 100644
13ec90
--- a/lib/urldata.h
13ec90
+++ b/lib/urldata.h
13ec90
@@ -223,6 +223,7 @@ struct ssl_primary_config {
13ec90
   bool sessionid;        /* cache session IDs or not */
13ec90
   char *CApath;          /* certificate dir (doesn't work on windows) */
13ec90
   char *CAfile;          /* certificate to verify peer against */
13ec90
+  char *issuercert;      /* optional issuer certificate filename */
13ec90
   char *clientcert;
13ec90
   char *random_file;     /* path to file containing "random" data */
13ec90
   char *egdsocket;       /* path to file containing the EGD daemon socket */
13ec90
@@ -238,7 +239,6 @@ struct ssl_config_data {
13ec90
   bool no_partialchain;  /* don't accept partial certificate chains */
13ec90
   long certverifyresult; /* result from the certificate verification */
13ec90
   char *CRLfile;   /* CRL to check certificate revocation */
13ec90
-  char *issuercert;/* optional issuer certificate filename */
13ec90
   curl_ssl_ctx_callback fsslctx; /* function to initialize ssl ctx */
13ec90
   void *fsslctxp;        /* parameter for call back */
13ec90
   bool certinfo;         /* gather lots of certificate info */
13ec90
diff --git a/lib/vtls/gtls.c b/lib/vtls/gtls.c
13ec90
index c5eb948..0cb59c8 100644
13ec90
--- a/lib/vtls/gtls.c
13ec90
+++ b/lib/vtls/gtls.c
13ec90
@@ -1002,7 +1002,7 @@ gtls_connect_step3(struct connectdata *conn,
13ec90
   if(!chainp) {
13ec90
     if(SSL_CONN_CONFIG(verifypeer) ||
13ec90
        SSL_CONN_CONFIG(verifyhost) ||
13ec90
-       SSL_SET_OPTION(issuercert)) {
13ec90
+       SSL_CONN_CONFIG(issuercert)) {
13ec90
 #ifdef USE_TLS_SRP
13ec90
       if(SSL_SET_OPTION(authtype) == CURL_TLSAUTH_SRP
13ec90
          && SSL_SET_OPTION(username) != NULL
13ec90
@@ -1184,21 +1184,21 @@ gtls_connect_step3(struct connectdata *conn,
13ec90
        gnutls_x509_crt_t format */
13ec90
     gnutls_x509_crt_import(x509_cert, chainp, GNUTLS_X509_FMT_DER);
13ec90
 
13ec90
-  if(SSL_SET_OPTION(issuercert)) {
13ec90
+  if(SSL_CONN_CONFIG(issuercert)) {
13ec90
     gnutls_x509_crt_init(&x509_issuer);
13ec90
-    issuerp = load_file(SSL_SET_OPTION(issuercert));
13ec90
+    issuerp = load_file(SSL_CONN_CONFIG(issuercert));
13ec90
     gnutls_x509_crt_import(x509_issuer, &issuerp, GNUTLS_X509_FMT_PEM);
13ec90
     rc = gnutls_x509_crt_check_issuer(x509_cert, x509_issuer);
13ec90
     gnutls_x509_crt_deinit(x509_issuer);
13ec90
     unload_file(issuerp);
13ec90
     if(rc <= 0) {
13ec90
       failf(data, "server certificate issuer check failed (IssuerCert: %s)",
13ec90
-            SSL_SET_OPTION(issuercert)?SSL_SET_OPTION(issuercert):"none");
13ec90
+            SSL_CONN_CONFIG(issuercert)?SSL_CONN_CONFIG(issuercert):"none");
13ec90
       gnutls_x509_crt_deinit(x509_cert);
13ec90
       return CURLE_SSL_ISSUER_ERROR;
13ec90
     }
13ec90
     infof(data, "\t server certificate issuer check OK (Issuer Cert: %s)\n",
13ec90
-          SSL_SET_OPTION(issuercert)?SSL_SET_OPTION(issuercert):"none");
13ec90
+          SSL_CONN_CONFIG(issuercert)?SSL_CONN_CONFIG(issuercert):"none");
13ec90
   }
13ec90
 
13ec90
   size = sizeof(certbuf);
13ec90
diff --git a/lib/vtls/nss.c b/lib/vtls/nss.c
13ec90
index 366bf9e..2d9581d 100644
13ec90
--- a/lib/vtls/nss.c
13ec90
+++ b/lib/vtls/nss.c
13ec90
@@ -2095,9 +2095,9 @@ static CURLcode nss_do_connect(struct connectdata *conn, int sockindex)
13ec90
   if(result)
13ec90
     goto error;
13ec90
 
13ec90
-  if(SSL_SET_OPTION(issuercert)) {
13ec90
+  if(SSL_CONN_CONFIG(issuercert)) {
13ec90
     SECStatus ret = SECFailure;
13ec90
-    char *nickname = dup_nickname(data, SSL_SET_OPTION(issuercert));
13ec90
+    char *nickname = dup_nickname(data, SSL_CONN_CONFIG(issuercert));
13ec90
     if(nickname) {
13ec90
       /* we support only nicknames in case of issuercert for now */
13ec90
       ret = check_issuer_cert(BACKEND->handle, nickname);
13ec90
diff --git a/lib/vtls/openssl.c b/lib/vtls/openssl.c
13ec90
index 8c97c1d..28eaa6d 100644
13ec90
--- a/lib/vtls/openssl.c
13ec90
+++ b/lib/vtls/openssl.c
13ec90
@@ -3311,11 +3311,11 @@ static CURLcode servercert(struct connectdata *conn,
13ec90
        deallocating the certificate. */
13ec90
 
13ec90
     /* e.g. match issuer name with provided issuer certificate */
13ec90
-    if(SSL_SET_OPTION(issuercert)) {
13ec90
-      if(BIO_read_filename(fp, SSL_SET_OPTION(issuercert)) <= 0) {
13ec90
+    if(SSL_CONN_CONFIG(issuercert)) {
13ec90
+      if(BIO_read_filename(fp, SSL_CONN_CONFIG(issuercert)) <= 0) {
13ec90
         if(strict)
13ec90
           failf(data, "SSL: Unable to open issuer cert (%s)",
13ec90
-                SSL_SET_OPTION(issuercert));
13ec90
+                SSL_CONN_CONFIG(issuercert));
13ec90
         BIO_free(fp);
13ec90
         X509_free(BACKEND->server_cert);
13ec90
         BACKEND->server_cert = NULL;
13ec90
@@ -3326,7 +3326,7 @@ static CURLcode servercert(struct connectdata *conn,
13ec90
       if(!issuer) {
13ec90
         if(strict)
13ec90
           failf(data, "SSL: Unable to read issuer cert (%s)",
13ec90
-                SSL_SET_OPTION(issuercert));
13ec90
+                SSL_CONN_CONFIG(issuercert));
13ec90
         BIO_free(fp);
13ec90
         X509_free(issuer);
13ec90
         X509_free(BACKEND->server_cert);
13ec90
@@ -3337,7 +3337,7 @@ static CURLcode servercert(struct connectdata *conn,
13ec90
       if(X509_check_issued(issuer, BACKEND->server_cert) != X509_V_OK) {
13ec90
         if(strict)
13ec90
           failf(data, "SSL: Certificate issuer check failed (%s)",
13ec90
-                SSL_SET_OPTION(issuercert));
13ec90
+                SSL_CONN_CONFIG(issuercert));
13ec90
         BIO_free(fp);
13ec90
         X509_free(issuer);
13ec90
         X509_free(BACKEND->server_cert);
13ec90
@@ -3346,7 +3346,7 @@ static CURLcode servercert(struct connectdata *conn,
13ec90
       }
13ec90
 
13ec90
       infof(data, " SSL certificate issuer check ok (%s)\n",
13ec90
-            SSL_SET_OPTION(issuercert));
13ec90
+            SSL_CONN_CONFIG(issuercert));
13ec90
       X509_free(issuer);
13ec90
     }
13ec90
 
13ec90
diff --git a/lib/vtls/vtls.c b/lib/vtls/vtls.c
13ec90
index b61c640..18672a5 100644
13ec90
--- a/lib/vtls/vtls.c
13ec90
+++ b/lib/vtls/vtls.c
13ec90
@@ -82,6 +82,15 @@
13ec90
   else                                       \
13ec90
     dest->var = NULL;
13ec90
 
13ec90
+static bool safecmp(char *a, char *b)
13ec90
+{
13ec90
+  if(a && b)
13ec90
+    return !strcmp(a, b);
13ec90
+  else if(!a && !b)
13ec90
+    return TRUE; /* match */
13ec90
+  return FALSE; /* no match */
13ec90
+}
13ec90
+
13ec90
 bool
13ec90
 Curl_ssl_config_matches(struct ssl_primary_config* data,
13ec90
                         struct ssl_primary_config* needle)
13ec90
@@ -91,11 +100,11 @@ Curl_ssl_config_matches(struct ssl_primary_config* data,
13ec90
      (data->verifypeer == needle->verifypeer) &&
13ec90
      (data->verifyhost == needle->verifyhost) &&
13ec90
      (data->verifystatus == needle->verifystatus) &&
13ec90
-     Curl_safe_strcasecompare(data->CApath, needle->CApath) &&
13ec90
-     Curl_safe_strcasecompare(data->CAfile, needle->CAfile) &&
13ec90
-     Curl_safe_strcasecompare(data->clientcert, needle->clientcert) &&
13ec90
-     Curl_safe_strcasecompare(data->random_file, needle->random_file) &&
13ec90
-     Curl_safe_strcasecompare(data->egdsocket, needle->egdsocket) &&
13ec90
+     safecmp(data->CApath, needle->CApath) &&
13ec90
+     safecmp(data->CAfile, needle->CAfile) &&
13ec90
+     safecmp(data->clientcert, needle->clientcert) &&
13ec90
+     safecmp(data->random_file, needle->random_file) &&
13ec90
+     safecmp(data->egdsocket, needle->egdsocket) &&
13ec90
      Curl_safe_strcasecompare(data->cipher_list, needle->cipher_list) &&
13ec90
      Curl_safe_strcasecompare(data->cipher_list13, needle->cipher_list13))
13ec90
     return TRUE;
13ec90
@@ -116,6 +125,7 @@ Curl_clone_primary_ssl_config(struct ssl_primary_config *source,
13ec90
 
13ec90
   CLONE_STRING(CApath);
13ec90
   CLONE_STRING(CAfile);
13ec90
+  CLONE_STRING(issuercert);
13ec90
   CLONE_STRING(clientcert);
13ec90
   CLONE_STRING(random_file);
13ec90
   CLONE_STRING(egdsocket);
13ec90
@@ -129,6 +139,7 @@ void Curl_free_primary_ssl_config(struct ssl_primary_config* sslc)
13ec90
 {
13ec90
   Curl_safefree(sslc->CApath);
13ec90
   Curl_safefree(sslc->CAfile);
13ec90
+  Curl_safefree(sslc->issuercert);
13ec90
   Curl_safefree(sslc->clientcert);
13ec90
   Curl_safefree(sslc->random_file);
13ec90
   Curl_safefree(sslc->egdsocket);
13ec90
-- 
13ec90
2.31.1
13ec90