aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/curl/lib
diff options
context:
space:
mode:
authorthegeorg <thegeorg@yandex-team.ru>2022-02-10 16:45:12 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:12 +0300
commit49116032d905455a7b1c994e4a696afc885c1e71 (patch)
treebe835aa92c6248212e705f25388ebafcf84bc7a1 /contrib/libs/curl/lib
parent4e839db24a3bbc9f1c610c43d6faaaa99824dcca (diff)
downloadydb-49116032d905455a7b1c994e4a696afc885c1e71.tar.gz
Restoring authorship annotation for <thegeorg@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/libs/curl/lib')
-rw-r--r--contrib/libs/curl/lib/altsvc.c364
-rw-r--r--contrib/libs/curl/lib/altsvc.h24
-rw-r--r--contrib/libs/curl/lib/amigaos.c4
-rw-r--r--contrib/libs/curl/lib/amigaos.h4
-rw-r--r--contrib/libs/curl/lib/arpa_telnet.h4
-rw-r--r--contrib/libs/curl/lib/asyn-ares.c100
-rw-r--r--contrib/libs/curl/lib/asyn-thread.c114
-rw-r--r--contrib/libs/curl/lib/asyn.h12
-rw-r--r--contrib/libs/curl/lib/base64.c10
-rw-r--r--contrib/libs/curl/lib/config-amigaos.h6
-rw-r--r--contrib/libs/curl/lib/config-dos.h4
-rw-r--r--contrib/libs/curl/lib/config-mac.h4
-rw-r--r--contrib/libs/curl/lib/config-os400.h4
-rw-r--r--contrib/libs/curl/lib/config-plan9.h6
-rw-r--r--contrib/libs/curl/lib/config-riscos.h4
-rw-r--r--contrib/libs/curl/lib/config-tpf.h6
-rw-r--r--contrib/libs/curl/lib/config-vxworks.h4
-rw-r--r--contrib/libs/curl/lib/config-win32.h44
-rw-r--r--contrib/libs/curl/lib/config-win32ce.h4
-rw-r--r--contrib/libs/curl/lib/conncache.c154
-rw-r--r--contrib/libs/curl/lib/conncache.h54
-rw-r--r--contrib/libs/curl/lib/connect.c544
-rw-r--r--contrib/libs/curl/lib/connect.h10
-rw-r--r--contrib/libs/curl/lib/content_encoding.c326
-rw-r--r--contrib/libs/curl/lib/content_encoding.h28
-rw-r--r--contrib/libs/curl/lib/cookie.c140
-rw-r--r--contrib/libs/curl/lib/cookie.h6
-rw-r--r--contrib/libs/curl/lib/curl_addrinfo.c76
-rw-r--r--contrib/libs/curl/lib/curl_addrinfo.h20
-rw-r--r--contrib/libs/curl/lib/curl_base64.h4
-rw-r--r--contrib/libs/curl/lib/curl_config-android.h4
-rw-r--r--contrib/libs/curl/lib/curl_config-linux.h120
-rw-r--r--contrib/libs/curl/lib/curl_config.h80
-rw-r--r--contrib/libs/curl/lib/curl_ctype.c4
-rw-r--r--contrib/libs/curl/lib/curl_ctype.h4
-rw-r--r--contrib/libs/curl/lib/curl_des.c4
-rw-r--r--contrib/libs/curl/lib/curl_des.h4
-rw-r--r--contrib/libs/curl/lib/curl_endian.c6
-rw-r--r--contrib/libs/curl/lib/curl_endian.h4
-rw-r--r--contrib/libs/curl/lib/curl_fnmatch.c4
-rw-r--r--contrib/libs/curl/lib/curl_fnmatch.h4
-rw-r--r--contrib/libs/curl/lib/curl_get_line.c14
-rw-r--r--contrib/libs/curl/lib/curl_get_line.h4
-rw-r--r--contrib/libs/curl/lib/curl_gethostname.c6
-rw-r--r--contrib/libs/curl/lib/curl_gethostname.h6
-rw-r--r--contrib/libs/curl/lib/curl_gssapi.c4
-rw-r--r--contrib/libs/curl/lib/curl_gssapi.h4
-rw-r--r--contrib/libs/curl/lib/curl_hmac.h42
-rw-r--r--contrib/libs/curl/lib/curl_krb5.h102
-rw-r--r--contrib/libs/curl/lib/curl_ldap.h4
-rw-r--r--contrib/libs/curl/lib/curl_md4.h8
-rw-r--r--contrib/libs/curl/lib/curl_md5.h28
-rw-r--r--contrib/libs/curl/lib/curl_memory.h4
-rw-r--r--contrib/libs/curl/lib/curl_memrchr.c4
-rw-r--r--contrib/libs/curl/lib/curl_memrchr.h4
-rw-r--r--contrib/libs/curl/lib/curl_multibyte.c170
-rw-r--r--contrib/libs/curl/lib/curl_multibyte.h56
-rw-r--r--contrib/libs/curl/lib/curl_ntlm_core.c50
-rw-r--r--contrib/libs/curl/lib/curl_ntlm_core.h24
-rw-r--r--contrib/libs/curl/lib/curl_ntlm_wb.c172
-rw-r--r--contrib/libs/curl/lib/curl_ntlm_wb.h4
-rw-r--r--contrib/libs/curl/lib/curl_path.c10
-rw-r--r--contrib/libs/curl/lib/curl_path.h4
-rw-r--r--contrib/libs/curl/lib/curl_printf.h4
-rw-r--r--contrib/libs/curl/lib/curl_range.c4
-rw-r--r--contrib/libs/curl/lib/curl_range.h4
-rw-r--r--contrib/libs/curl/lib/curl_rtmp.c16
-rw-r--r--contrib/libs/curl/lib/curl_rtmp.h4
-rw-r--r--contrib/libs/curl/lib/curl_sasl.c48
-rw-r--r--contrib/libs/curl/lib/curl_sasl.h4
-rw-r--r--contrib/libs/curl/lib/curl_setup.h110
-rw-r--r--contrib/libs/curl/lib/curl_setup_once.h14
-rw-r--r--contrib/libs/curl/lib/curl_sha256.h14
-rw-r--r--contrib/libs/curl/lib/curl_sspi.c22
-rw-r--r--contrib/libs/curl/lib/curl_sspi.h4
-rw-r--r--contrib/libs/curl/lib/curl_threads.c10
-rw-r--r--contrib/libs/curl/lib/curl_threads.h4
-rw-r--r--contrib/libs/curl/lib/curlx.h30
-rw-r--r--contrib/libs/curl/lib/dict.c152
-rw-r--r--contrib/libs/curl/lib/dict.h4
-rw-r--r--contrib/libs/curl/lib/doh.c422
-rw-r--r--contrib/libs/curl/lib/doh.h30
-rw-r--r--contrib/libs/curl/lib/dotdot.c12
-rw-r--r--contrib/libs/curl/lib/dotdot.h4
-rw-r--r--contrib/libs/curl/lib/dynbuf.c510
-rw-r--r--contrib/libs/curl/lib/dynbuf.h176
-rw-r--r--contrib/libs/curl/lib/easy.c340
-rw-r--r--contrib/libs/curl/lib/easygetopt.c192
-rw-r--r--contrib/libs/curl/lib/easyif.h4
-rw-r--r--contrib/libs/curl/lib/easyoptions.c706
-rw-r--r--contrib/libs/curl/lib/easyoptions.h70
-rw-r--r--contrib/libs/curl/lib/escape.c82
-rw-r--r--contrib/libs/curl/lib/escape.h20
-rw-r--r--contrib/libs/curl/lib/file.c24
-rw-r--r--contrib/libs/curl/lib/file.h4
-rw-r--r--contrib/libs/curl/lib/fileinfo.c4
-rw-r--r--contrib/libs/curl/lib/fileinfo.h6
-rw-r--r--contrib/libs/curl/lib/formdata.c32
-rw-r--r--contrib/libs/curl/lib/formdata.h8
-rw-r--r--contrib/libs/curl/lib/ftp.c1112
-rw-r--r--contrib/libs/curl/lib/ftp.h8
-rw-r--r--contrib/libs/curl/lib/ftplistparser.c10
-rw-r--r--contrib/libs/curl/lib/ftplistparser.h4
-rw-r--r--contrib/libs/curl/lib/getenv.c72
-rw-r--r--contrib/libs/curl/lib/getinfo.c228
-rw-r--r--contrib/libs/curl/lib/getinfo.h4
-rw-r--r--contrib/libs/curl/lib/gopher.c44
-rw-r--r--contrib/libs/curl/lib/gopher.h4
-rw-r--r--contrib/libs/curl/lib/hash.c84
-rw-r--r--contrib/libs/curl/lib/hash.h50
-rw-r--r--contrib/libs/curl/lib/hmac.c92
-rw-r--r--contrib/libs/curl/lib/hostasyn.c12
-rw-r--r--contrib/libs/curl/lib/hostcheck.c4
-rw-r--r--contrib/libs/curl/lib/hostcheck.h4
-rw-r--r--contrib/libs/curl/lib/hostip.c232
-rw-r--r--contrib/libs/curl/lib/hostip.h68
-rw-r--r--contrib/libs/curl/lib/hostip4.c298
-rw-r--r--contrib/libs/curl/lib/hostip6.c52
-rw-r--r--contrib/libs/curl/lib/hostsyn.c4
-rw-r--r--contrib/libs/curl/lib/hsts.c1044
-rw-r--r--contrib/libs/curl/lib/hsts.h130
-rw-r--r--contrib/libs/curl/lib/http.c870
-rw-r--r--contrib/libs/curl/lib/http.h38
-rw-r--r--contrib/libs/curl/lib/http2.c602
-rw-r--r--contrib/libs/curl/lib/http2.h12
-rw-r--r--contrib/libs/curl/lib/http_chunks.c70
-rw-r--r--contrib/libs/curl/lib/http_chunks.h24
-rw-r--r--contrib/libs/curl/lib/http_digest.c16
-rw-r--r--contrib/libs/curl/lib/http_digest.h4
-rw-r--r--contrib/libs/curl/lib/http_negotiate.c26
-rw-r--r--contrib/libs/curl/lib/http_negotiate.h10
-rw-r--r--contrib/libs/curl/lib/http_ntlm.c24
-rw-r--r--contrib/libs/curl/lib/http_ntlm.h10
-rw-r--r--contrib/libs/curl/lib/http_proxy.c198
-rw-r--r--contrib/libs/curl/lib/http_proxy.h6
-rw-r--r--contrib/libs/curl/lib/idn_win32.c12
-rw-r--r--contrib/libs/curl/lib/if2ip.c30
-rw-r--r--contrib/libs/curl/lib/if2ip.h4
-rw-r--r--contrib/libs/curl/lib/imap.c92
-rw-r--r--contrib/libs/curl/lib/imap.h8
-rw-r--r--contrib/libs/curl/lib/inet_ntop.c2
-rw-r--r--contrib/libs/curl/lib/inet_ntop.h4
-rw-r--r--contrib/libs/curl/lib/inet_pton.c4
-rw-r--r--contrib/libs/curl/lib/inet_pton.h4
-rw-r--r--contrib/libs/curl/lib/krb5.c1162
-rw-r--r--contrib/libs/curl/lib/ldap.c126
-rw-r--r--contrib/libs/curl/lib/llist.c16
-rw-r--r--contrib/libs/curl/lib/llist.h32
-rw-r--r--contrib/libs/curl/lib/md4.c96
-rw-r--r--contrib/libs/curl/lib/md5.c156
-rw-r--r--contrib/libs/curl/lib/memdebug.c26
-rw-r--r--contrib/libs/curl/lib/memdebug.h12
-rw-r--r--contrib/libs/curl/lib/mime.c458
-rw-r--r--contrib/libs/curl/lib/mime.h64
-rw-r--r--contrib/libs/curl/lib/mprintf.c134
-rw-r--r--contrib/libs/curl/lib/mqtt.c1248
-rw-r--r--contrib/libs/curl/lib/mqtt.h118
-rw-r--r--contrib/libs/curl/lib/multi.c698
-rw-r--r--contrib/libs/curl/lib/multihandle.h54
-rw-r--r--contrib/libs/curl/lib/multiif.h16
-rw-r--r--contrib/libs/curl/lib/netrc.c6
-rw-r--r--contrib/libs/curl/lib/netrc.h4
-rw-r--r--contrib/libs/curl/lib/non-ascii.c4
-rw-r--r--contrib/libs/curl/lib/non-ascii.h4
-rw-r--r--contrib/libs/curl/lib/nonblock.c4
-rw-r--r--contrib/libs/curl/lib/nonblock.h4
-rw-r--r--contrib/libs/curl/lib/openldap.c26
-rw-r--r--contrib/libs/curl/lib/parsedate.c94
-rw-r--r--contrib/libs/curl/lib/parsedate.h16
-rw-r--r--contrib/libs/curl/lib/pingpong.c76
-rw-r--r--contrib/libs/curl/lib/pingpong.h18
-rw-r--r--contrib/libs/curl/lib/pop3.c34
-rw-r--r--contrib/libs/curl/lib/pop3.h4
-rw-r--r--contrib/libs/curl/lib/progress.c48
-rw-r--r--contrib/libs/curl/lib/progress.h6
-rw-r--r--contrib/libs/curl/lib/psl.c4
-rw-r--r--contrib/libs/curl/lib/psl.h4
-rw-r--r--contrib/libs/curl/lib/quic.h18
-rw-r--r--contrib/libs/curl/lib/rand.c4
-rw-r--r--contrib/libs/curl/lib/rand.h4
-rw-r--r--contrib/libs/curl/lib/rename.c142
-rw-r--r--contrib/libs/curl/lib/rename.h54
-rw-r--r--contrib/libs/curl/lib/rtsp.c188
-rw-r--r--contrib/libs/curl/lib/rtsp.h4
-rw-r--r--contrib/libs/curl/lib/select.c394
-rw-r--r--contrib/libs/curl/lib/select.h56
-rw-r--r--contrib/libs/curl/lib/sendf.c178
-rw-r--r--contrib/libs/curl/lib/sendf.h4
-rw-r--r--contrib/libs/curl/lib/setopt.c648
-rw-r--r--contrib/libs/curl/lib/setopt.h8
-rw-r--r--contrib/libs/curl/lib/setup-os400.h18
-rw-r--r--contrib/libs/curl/lib/setup-vms.h10
-rw-r--r--contrib/libs/curl/lib/setup-win32.h244
-rw-r--r--contrib/libs/curl/lib/sha256.c508
-rw-r--r--contrib/libs/curl/lib/share.c14
-rw-r--r--contrib/libs/curl/lib/share.h8
-rw-r--r--contrib/libs/curl/lib/sigpipe.h4
-rw-r--r--contrib/libs/curl/lib/slist.c4
-rw-r--r--contrib/libs/curl/lib/slist.h4
-rw-r--r--contrib/libs/curl/lib/smb.c40
-rw-r--r--contrib/libs/curl/lib/smb.h10
-rw-r--r--contrib/libs/curl/lib/smtp.c614
-rw-r--r--contrib/libs/curl/lib/smtp.h14
-rw-r--r--contrib/libs/curl/lib/sockaddr.h4
-rw-r--r--contrib/libs/curl/lib/socketpair.c242
-rw-r--r--contrib/libs/curl/lib/socketpair.h72
-rw-r--r--contrib/libs/curl/lib/socks.c1558
-rw-r--r--contrib/libs/curl/lib/socks.h40
-rw-r--r--contrib/libs/curl/lib/socks_gssapi.c24
-rw-r--r--contrib/libs/curl/lib/socks_sspi.c16
-rw-r--r--contrib/libs/curl/lib/speedcheck.c4
-rw-r--r--contrib/libs/curl/lib/speedcheck.h4
-rw-r--r--contrib/libs/curl/lib/splay.c10
-rw-r--r--contrib/libs/curl/lib/splay.h10
-rw-r--r--contrib/libs/curl/lib/strcase.c176
-rw-r--r--contrib/libs/curl/lib/strcase.h6
-rw-r--r--contrib/libs/curl/lib/strdup.c10
-rw-r--r--contrib/libs/curl/lib/strdup.h4
-rw-r--r--contrib/libs/curl/lib/strerror.c494
-rw-r--r--contrib/libs/curl/lib/strerror.h12
-rw-r--r--contrib/libs/curl/lib/strtok.c6
-rw-r--r--contrib/libs/curl/lib/strtok.h4
-rw-r--r--contrib/libs/curl/lib/strtoofft.c4
-rw-r--r--contrib/libs/curl/lib/strtoofft.h4
-rw-r--r--contrib/libs/curl/lib/system_win32.c18
-rw-r--r--contrib/libs/curl/lib/system_win32.h4
-rw-r--r--contrib/libs/curl/lib/telnet.c60
-rw-r--r--contrib/libs/curl/lib/telnet.h4
-rw-r--r--contrib/libs/curl/lib/tftp.c80
-rw-r--r--contrib/libs/curl/lib/tftp.h4
-rw-r--r--contrib/libs/curl/lib/timeval.c6
-rw-r--r--contrib/libs/curl/lib/timeval.h4
-rw-r--r--contrib/libs/curl/lib/transfer.c244
-rw-r--r--contrib/libs/curl/lib/transfer.h4
-rw-r--r--contrib/libs/curl/lib/url.c946
-rw-r--r--contrib/libs/curl/lib/url.h28
-rw-r--r--contrib/libs/curl/lib/urlapi-int.h6
-rw-r--r--contrib/libs/curl/lib/urlapi.c314
-rw-r--r--contrib/libs/curl/lib/urldata.h832
-rw-r--r--contrib/libs/curl/lib/vauth/cleartext.c8
-rw-r--r--contrib/libs/curl/lib/vauth/cram.c6
-rw-r--r--contrib/libs/curl/lib/vauth/digest.c70
-rw-r--r--contrib/libs/curl/lib/vauth/digest.h4
-rw-r--r--contrib/libs/curl/lib/vauth/digest_sspi.c26
-rw-r--r--contrib/libs/curl/lib/vauth/krb5_gssapi.c4
-rw-r--r--contrib/libs/curl/lib/vauth/krb5_sspi.c14
-rw-r--r--contrib/libs/curl/lib/vauth/ntlm.c26
-rw-r--r--contrib/libs/curl/lib/vauth/ntlm.h4
-rw-r--r--contrib/libs/curl/lib/vauth/ntlm_sspi.c12
-rw-r--r--contrib/libs/curl/lib/vauth/oauth2.c4
-rw-r--r--contrib/libs/curl/lib/vauth/spnego_gssapi.c4
-rw-r--r--contrib/libs/curl/lib/vauth/spnego_sspi.c12
-rw-r--r--contrib/libs/curl/lib/vauth/vauth.c8
-rw-r--r--contrib/libs/curl/lib/vauth/vauth.h6
-rw-r--r--contrib/libs/curl/lib/version.c368
-rw-r--r--contrib/libs/curl/lib/version_win32.c452
-rw-r--r--contrib/libs/curl/lib/version_win32.h106
-rw-r--r--contrib/libs/curl/lib/vquic/ngtcp2.c1198
-rw-r--r--contrib/libs/curl/lib/vquic/quiche.c256
-rw-r--r--contrib/libs/curl/lib/vquic/vquic.c170
-rw-r--r--contrib/libs/curl/lib/vssh/libssh.c448
-rw-r--r--contrib/libs/curl/lib/vssh/libssh2.c1038
-rw-r--r--contrib/libs/curl/lib/vssh/ssh.h540
-rw-r--r--contrib/libs/curl/lib/vssh/wolfssh.c2312
-rw-r--r--contrib/libs/curl/lib/vtls/bearssl.c1754
-rw-r--r--contrib/libs/curl/lib/vtls/bearssl.h64
-rw-r--r--contrib/libs/curl/lib/vtls/gskit.c28
-rw-r--r--contrib/libs/curl/lib/vtls/gskit.h4
-rw-r--r--contrib/libs/curl/lib/vtls/gtls.c422
-rw-r--r--contrib/libs/curl/lib/vtls/gtls.h4
-rw-r--r--contrib/libs/curl/lib/vtls/keylog.c312
-rw-r--r--contrib/libs/curl/lib/vtls/keylog.h112
-rw-r--r--contrib/libs/curl/lib/vtls/mbedtls.c222
-rw-r--r--contrib/libs/curl/lib/vtls/mbedtls.h4
-rw-r--r--contrib/libs/curl/lib/vtls/mbedtls_threadlock.c288
-rw-r--r--contrib/libs/curl/lib/vtls/mesalink.c30
-rw-r--r--contrib/libs/curl/lib/vtls/mesalink.h6
-rw-r--r--contrib/libs/curl/lib/vtls/nss.c216
-rw-r--r--contrib/libs/curl/lib/vtls/nssg.h4
-rw-r--r--contrib/libs/curl/lib/vtls/openssl.c1694
-rw-r--r--contrib/libs/curl/lib/vtls/openssl.h4
-rw-r--r--contrib/libs/curl/lib/vtls/schannel.c758
-rw-r--r--contrib/libs/curl/lib/vtls/schannel.h12
-rw-r--r--contrib/libs/curl/lib/vtls/schannel_verify.c340
-rw-r--r--contrib/libs/curl/lib/vtls/sectransp.c340
-rw-r--r--contrib/libs/curl/lib/vtls/sectransp.h4
-rw-r--r--contrib/libs/curl/lib/vtls/vtls.c254
-rw-r--r--contrib/libs/curl/lib/vtls/vtls.h74
-rw-r--r--contrib/libs/curl/lib/vtls/wolfssl.c490
-rw-r--r--contrib/libs/curl/lib/vtls/wolfssl.h4
-rw-r--r--contrib/libs/curl/lib/warnless.c4
-rw-r--r--contrib/libs/curl/lib/warnless.h4
-rw-r--r--contrib/libs/curl/lib/wildcard.c4
-rw-r--r--contrib/libs/curl/lib/wildcard.h14
-rw-r--r--contrib/libs/curl/lib/x509asn1.c76
-rw-r--r--contrib/libs/curl/lib/x509asn1.h72
296 files changed, 19854 insertions, 19854 deletions
diff --git a/contrib/libs/curl/lib/altsvc.c b/contrib/libs/curl/lib/altsvc.c
index dcde69c1c7..4ab77fdfc8 100644
--- a/contrib/libs/curl/lib/altsvc.c
+++ b/contrib/libs/curl/lib/altsvc.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 2019 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2019 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -25,7 +25,7 @@
*/
#include "curl_setup.h"
-#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_ALTSVC)
+#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_ALTSVC)
#include <curl/curl.h>
#include "urldata.h"
#include "altsvc.h"
@@ -34,8 +34,8 @@
#include "parsedate.h"
#include "sendf.h"
#include "warnless.h"
-#include "rand.h"
-#include "rename.h"
+#include "rand.h"
+#include "rename.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
@@ -50,21 +50,21 @@
#define MAX_ALTSVC_ALPNLENSTR "10"
#define MAX_ALTSVC_ALPNLEN 10
-#if defined(USE_QUICHE) && !defined(UNITTESTS)
-#define H3VERSION "h3-29"
-#elif defined(USE_NGTCP2) && !defined(UNITTESTS)
-#define H3VERSION "h3-29"
-#else
-#define H3VERSION "h3"
-#endif
-
+#if defined(USE_QUICHE) && !defined(UNITTESTS)
+#define H3VERSION "h3-29"
+#elif defined(USE_NGTCP2) && !defined(UNITTESTS)
+#define H3VERSION "h3-29"
+#else
+#define H3VERSION "h3"
+#endif
+
static enum alpnid alpn2alpnid(char *name)
{
if(strcasecompare(name, "h1"))
return ALPN_h1;
if(strcasecompare(name, "h2"))
return ALPN_h2;
- if(strcasecompare(name, H3VERSION))
+ if(strcasecompare(name, H3VERSION))
return ALPN_h3;
return ALPN_none; /* unknown, probably rubbish input */
}
@@ -78,7 +78,7 @@ const char *Curl_alpnid2str(enum alpnid id)
case ALPN_h2:
return "h2";
case ALPN_h3:
- return H3VERSION;
+ return H3VERSION;
default:
return ""; /* bad */
}
@@ -162,7 +162,7 @@ static CURLcode altsvc_add(struct altsvcinfo *asi, char *line)
date, &persist, &prio);
if(9 == rc) {
struct altsvc *as;
- time_t expires = Curl_getdate_capped(date);
+ time_t expires = Curl_getdate_capped(date);
as = altsvc_create(srchost, dsthost, srcalpn, dstalpn, srcport, dstport);
if(as) {
as->expires = expires;
@@ -188,16 +188,16 @@ static CURLcode altsvc_load(struct altsvcinfo *asi, const char *file)
{
CURLcode result = CURLE_OK;
char *line = NULL;
- FILE *fp;
-
- /* we need a private copy of the file name so that the altsvc cache file
- name survives an easy handle reset */
- free(asi->filename);
- asi->filename = strdup(file);
- if(!asi->filename)
- return CURLE_OUT_OF_MEMORY;
-
- fp = fopen(file, FOPEN_READTEXT);
+ FILE *fp;
+
+ /* we need a private copy of the file name so that the altsvc cache file
+ name survives an easy handle reset */
+ free(asi->filename);
+ asi->filename = strdup(file);
+ if(!asi->filename)
+ return CURLE_OUT_OF_MEMORY;
+
+ fp = fopen(file, FOPEN_READTEXT);
if(fp) {
line = malloc(MAX_ALTSVC_LINE);
if(!line)
@@ -218,7 +218,7 @@ static CURLcode altsvc_load(struct altsvcinfo *asi, const char *file)
return result;
fail:
- Curl_safefree(asi->filename);
+ Curl_safefree(asi->filename);
free(line);
fclose(fp);
return CURLE_OUT_OF_MEMORY;
@@ -302,77 +302,77 @@ CURLcode Curl_altsvc_ctrl(struct altsvcinfo *asi, const long ctrl)
* Curl_altsvc_cleanup() frees an altsvc cache instance and all associated
* resources.
*/
-void Curl_altsvc_cleanup(struct altsvcinfo **altsvcp)
+void Curl_altsvc_cleanup(struct altsvcinfo **altsvcp)
{
- struct Curl_llist_element *e;
- struct Curl_llist_element *n;
- if(*altsvcp) {
- struct altsvcinfo *altsvc = *altsvcp;
+ struct Curl_llist_element *e;
+ struct Curl_llist_element *n;
+ if(*altsvcp) {
+ struct altsvcinfo *altsvc = *altsvcp;
for(e = altsvc->list.head; e; e = n) {
struct altsvc *as = e->ptr;
n = e->next;
altsvc_free(as);
}
- free(altsvc->filename);
+ free(altsvc->filename);
free(altsvc);
- *altsvcp = NULL; /* clear the pointer */
+ *altsvcp = NULL; /* clear the pointer */
}
}
/*
* Curl_altsvc_save() writes the altsvc cache to a file.
*/
-CURLcode Curl_altsvc_save(struct Curl_easy *data,
- struct altsvcinfo *altsvc, const char *file)
+CURLcode Curl_altsvc_save(struct Curl_easy *data,
+ struct altsvcinfo *altsvc, const char *file)
{
- struct Curl_llist_element *e;
- struct Curl_llist_element *n;
+ struct Curl_llist_element *e;
+ struct Curl_llist_element *n;
CURLcode result = CURLE_OK;
FILE *out;
- char *tempstore;
- unsigned char randsuffix[9];
+ char *tempstore;
+ unsigned char randsuffix[9];
if(!altsvc)
/* no cache activated */
return CURLE_OK;
- /* if not new name is given, use the one we stored from the load */
- if(!file && altsvc->filename)
- file = altsvc->filename;
-
- if((altsvc->flags & CURLALTSVC_READONLYFILE) || !file || !file[0])
- /* marked as read-only, no file or zero length file name */
+ /* if not new name is given, use the one we stored from the load */
+ if(!file && altsvc->filename)
+ file = altsvc->filename;
+
+ if((altsvc->flags & CURLALTSVC_READONLYFILE) || !file || !file[0])
+ /* marked as read-only, no file or zero length file name */
return CURLE_OK;
-
- if(Curl_rand_hex(data, randsuffix, sizeof(randsuffix)))
- return CURLE_FAILED_INIT;
-
- tempstore = aprintf("%s.%s.tmp", file, randsuffix);
- if(!tempstore)
- return CURLE_OUT_OF_MEMORY;
-
- out = fopen(tempstore, FOPEN_WRITETEXT);
+
+ if(Curl_rand_hex(data, randsuffix, sizeof(randsuffix)))
+ return CURLE_FAILED_INIT;
+
+ tempstore = aprintf("%s.%s.tmp", file, randsuffix);
+ if(!tempstore)
+ return CURLE_OUT_OF_MEMORY;
+
+ out = fopen(tempstore, FOPEN_WRITETEXT);
if(!out)
- result = CURLE_WRITE_ERROR;
- else {
- fputs("# Your alt-svc cache. https://curl.se/docs/alt-svc.html\n"
- "# This file was generated by libcurl! Edit at your own risk.\n",
- out);
- for(e = altsvc->list.head; e; e = n) {
- struct altsvc *as = e->ptr;
- n = e->next;
- result = altsvc_out(as, out);
- if(result)
- break;
- }
- fclose(out);
- if(!result && Curl_rename(tempstore, file))
- result = CURLE_WRITE_ERROR;
-
+ result = CURLE_WRITE_ERROR;
+ else {
+ fputs("# Your alt-svc cache. https://curl.se/docs/alt-svc.html\n"
+ "# This file was generated by libcurl! Edit at your own risk.\n",
+ out);
+ for(e = altsvc->list.head; e; e = n) {
+ struct altsvc *as = e->ptr;
+ n = e->next;
+ result = altsvc_out(as, out);
+ if(result)
+ break;
+ }
+ fclose(out);
+ if(!result && Curl_rename(tempstore, file))
+ result = CURLE_WRITE_ERROR;
+
if(result)
- unlink(tempstore);
+ unlink(tempstore);
}
- free(tempstore);
+ free(tempstore);
return result;
}
@@ -387,7 +387,7 @@ static CURLcode getalnum(const char **ptr, char *alpnbuf, size_t buflen)
while(*p && !ISBLANK(*p) && (*p != ';') && (*p != '='))
p++;
len = p - protop;
- *ptr = p;
+ *ptr = p;
if(!len || (len >= buflen))
return CURLE_BAD_FUNCTION_ARGUMENT;
@@ -401,8 +401,8 @@ static CURLcode getalnum(const char **ptr, char *alpnbuf, size_t buflen)
static void altsvc_flush(struct altsvcinfo *asi, enum alpnid srcalpnid,
const char *srchost, unsigned short srcport)
{
- struct Curl_llist_element *e;
- struct Curl_llist_element *n;
+ struct Curl_llist_element *e;
+ struct Curl_llist_element *n;
for(e = asi->list.head; e; e = n) {
struct altsvc *as = e->ptr;
n = e->next;
@@ -431,18 +431,18 @@ static time_t debugtime(void *unused)
#define time(x) debugtime(x)
#endif
-#define ISNEWLINE(x) (((x) == '\n') || (x) == '\r')
-
+#define ISNEWLINE(x) (((x) == '\n') || (x) == '\r')
+
/*
* Curl_altsvc_parse() takes an incoming alt-svc response header and stores
* the data correctly in the cache.
*
* 'value' points to the header *value*. That's contents to the right of the
* header name.
- *
- * Currently this function rejects invalid data without returning an error.
- * Invalid host name, port number will result in the specific alternative
- * being rejected. Unknown protocols are skipped.
+ *
+ * Currently this function rejects invalid data without returning an error.
+ * Invalid host name, port number will result in the specific alternative
+ * being rejected. Unknown protocols are skipped.
*/
CURLcode Curl_altsvc_parse(struct Curl_easy *data,
struct altsvcinfo *asi, const char *value,
@@ -456,13 +456,13 @@ CURLcode Curl_altsvc_parse(struct Curl_easy *data,
struct altsvc *as;
unsigned short dstport = srcport; /* the same by default */
CURLcode result = getalnum(&p, alpnbuf, sizeof(alpnbuf));
-#ifdef CURL_DISABLE_VERBOSE_STRINGS
- (void)data;
-#endif
- if(result) {
- infof(data, "Excessive alt-svc header, ignoring...\n");
- return CURLE_OK;
- }
+#ifdef CURL_DISABLE_VERBOSE_STRINGS
+ (void)data;
+#endif
+ if(result) {
+ infof(data, "Excessive alt-svc header, ignoring...\n");
+ return CURLE_OK;
+ }
DEBUGASSERT(asi);
@@ -477,17 +477,17 @@ CURLcode Curl_altsvc_parse(struct Curl_easy *data,
do {
if(*p == '=') {
/* [protocol]="[host][:port]" */
- enum alpnid dstalpnid = alpn2alpnid(alpnbuf); /* the same by default */
+ enum alpnid dstalpnid = alpn2alpnid(alpnbuf); /* the same by default */
p++;
if(*p == '\"') {
- const char *dsthost = "";
- const char *value_ptr;
- char option[32];
- unsigned long num;
- char *end_ptr;
- bool quoted = FALSE;
- time_t maxage = 24 * 3600; /* default is 24 hours */
- bool persist = FALSE;
+ const char *dsthost = "";
+ const char *value_ptr;
+ char option[32];
+ unsigned long num;
+ char *end_ptr;
+ bool quoted = FALSE;
+ time_t maxage = 24 * 3600; /* default is 24 hours */
+ bool persist = FALSE;
p++;
if(*p != ':') {
/* host name starts here */
@@ -495,15 +495,15 @@ CURLcode Curl_altsvc_parse(struct Curl_easy *data,
while(*p && (ISALNUM(*p) || (*p == '.') || (*p == '-')))
p++;
len = p - hostp;
- if(!len || (len >= MAX_ALTSVC_HOSTLEN)) {
- infof(data, "Excessive alt-svc host name, ignoring...\n");
- dstalpnid = ALPN_none;
- }
- else {
- memcpy(namebuf, hostp, len);
- namebuf[len] = 0;
- dsthost = namebuf;
- }
+ if(!len || (len >= MAX_ALTSVC_HOSTLEN)) {
+ infof(data, "Excessive alt-svc host name, ignoring...\n");
+ dstalpnid = ALPN_none;
+ }
+ else {
+ memcpy(namebuf, hostp, len);
+ namebuf[len] = 0;
+ dsthost = namebuf;
+ }
}
else {
/* no destination name, use source host */
@@ -514,82 +514,82 @@ CURLcode Curl_altsvc_parse(struct Curl_easy *data,
unsigned long port = strtoul(++p, &end_ptr, 10);
if(port > USHRT_MAX || end_ptr == p || *end_ptr != '\"') {
infof(data, "Unknown alt-svc port number, ignoring...\n");
- dstalpnid = ALPN_none;
+ dstalpnid = ALPN_none;
}
p = end_ptr;
dstport = curlx_ultous(port);
}
if(*p++ != '\"')
- break;
- /* Handle the optional 'ma' and 'persist' flags. Unknown flags
- are skipped. */
- for(;;) {
- while(ISBLANK(*p))
- p++;
- if(*p != ';')
- break;
- p++; /* pass the semicolon */
- if(!*p || ISNEWLINE(*p))
- break;
- result = getalnum(&p, option, sizeof(option));
- if(result) {
- /* skip option if name is too long */
- option[0] = '\0';
- }
- while(*p && ISBLANK(*p))
- p++;
- if(*p != '=')
- return CURLE_OK;
- p++;
- while(*p && ISBLANK(*p))
- p++;
- if(!*p)
- return CURLE_OK;
- if(*p == '\"') {
- /* quoted value */
- p++;
- quoted = TRUE;
- }
- value_ptr = p;
- if(quoted) {
- while(*p && *p != '\"')
- p++;
- if(!*p++)
- return CURLE_OK;
- }
- else {
- while(*p && !ISBLANK(*p) && *p!= ';' && *p != ',')
- p++;
- }
- num = strtoul(value_ptr, &end_ptr, 10);
- if((end_ptr != value_ptr) && (num < ULONG_MAX)) {
- if(strcasecompare("ma", option))
- maxage = num;
- else if(strcasecompare("persist", option) && (num == 1))
- persist = TRUE;
- }
+ break;
+ /* Handle the optional 'ma' and 'persist' flags. Unknown flags
+ are skipped. */
+ for(;;) {
+ while(ISBLANK(*p))
+ p++;
+ if(*p != ';')
+ break;
+ p++; /* pass the semicolon */
+ if(!*p || ISNEWLINE(*p))
+ break;
+ result = getalnum(&p, option, sizeof(option));
+ if(result) {
+ /* skip option if name is too long */
+ option[0] = '\0';
+ }
+ while(*p && ISBLANK(*p))
+ p++;
+ if(*p != '=')
+ return CURLE_OK;
+ p++;
+ while(*p && ISBLANK(*p))
+ p++;
+ if(!*p)
+ return CURLE_OK;
+ if(*p == '\"') {
+ /* quoted value */
+ p++;
+ quoted = TRUE;
+ }
+ value_ptr = p;
+ if(quoted) {
+ while(*p && *p != '\"')
+ p++;
+ if(!*p++)
+ return CURLE_OK;
+ }
+ else {
+ while(*p && !ISBLANK(*p) && *p!= ';' && *p != ',')
+ p++;
+ }
+ num = strtoul(value_ptr, &end_ptr, 10);
+ if((end_ptr != value_ptr) && (num < ULONG_MAX)) {
+ if(strcasecompare("ma", option))
+ maxage = num;
+ else if(strcasecompare("persist", option) && (num == 1))
+ persist = TRUE;
+ }
+ }
+ if(dstalpnid) {
+ as = altsvc_createid(srchost, dsthost,
+ srcalpnid, dstalpnid,
+ srcport, dstport);
+ if(as) {
+ /* The expires time also needs to take the Age: value (if any) into
+ account. [See RFC 7838 section 3.1] */
+ as->expires = maxage + time(NULL);
+ as->persist = persist;
+ Curl_llist_insert_next(&asi->list, asi->list.tail, as, &as->node);
+ infof(data, "Added alt-svc: %s:%d over %s\n", dsthost, dstport,
+ Curl_alpnid2str(dstalpnid));
+ }
+ }
+ else {
+ infof(data, "Unknown alt-svc protocol \"%s\", skipping...\n",
+ alpnbuf);
}
- if(dstalpnid) {
- as = altsvc_createid(srchost, dsthost,
- srcalpnid, dstalpnid,
- srcport, dstport);
- if(as) {
- /* The expires time also needs to take the Age: value (if any) into
- account. [See RFC 7838 section 3.1] */
- as->expires = maxage + time(NULL);
- as->persist = persist;
- Curl_llist_insert_next(&asi->list, asi->list.tail, as, &as->node);
- infof(data, "Added alt-svc: %s:%d over %s\n", dsthost, dstport,
- Curl_alpnid2str(dstalpnid));
- }
- }
- else {
- infof(data, "Unknown alt-svc protocol \"%s\", skipping...\n",
- alpnbuf);
- }
}
- else
- break;
+ else
+ break;
/* after the double quote there can be a comma if there's another
string or a semicolon if no more */
if(*p == ',') {
@@ -597,11 +597,11 @@ CURLcode Curl_altsvc_parse(struct Curl_easy *data,
p++;
result = getalnum(&p, alpnbuf, sizeof(alpnbuf));
if(result)
- break;
+ break;
}
}
- else
- break;
+ else
+ break;
} while(*p && (*p != ';') && (*p != '\n') && (*p != '\r'));
return CURLE_OK;
@@ -616,8 +616,8 @@ bool Curl_altsvc_lookup(struct altsvcinfo *asi,
struct altsvc **dstentry,
const int versions) /* one or more bits */
{
- struct Curl_llist_element *e;
- struct Curl_llist_element *n;
+ struct Curl_llist_element *e;
+ struct Curl_llist_element *n;
time_t now = time(NULL);
DEBUGASSERT(asi);
DEBUGASSERT(srchost);
@@ -644,4 +644,4 @@ bool Curl_altsvc_lookup(struct altsvcinfo *asi,
return FALSE;
}
-#endif /* !CURL_DISABLE_HTTP && !CURL_DISABLE_ALTSVC */
+#endif /* !CURL_DISABLE_HTTP && !CURL_DISABLE_ALTSVC */
diff --git a/contrib/libs/curl/lib/altsvc.h b/contrib/libs/curl/lib/altsvc.h
index a69c89beb4..2ab89e7059 100644
--- a/contrib/libs/curl/lib/altsvc.h
+++ b/contrib/libs/curl/lib/altsvc.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 2019 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2019 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -23,7 +23,7 @@
***************************************************************************/
#include "curl_setup.h"
-#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_ALTSVC)
+#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_ALTSVC)
#include <curl/curl.h>
#include "llist.h"
@@ -46,22 +46,22 @@ struct altsvc {
time_t expires;
bool persist;
int prio;
- struct Curl_llist_element node;
+ struct Curl_llist_element node;
};
struct altsvcinfo {
char *filename;
- struct Curl_llist list; /* list of entries */
+ struct Curl_llist list; /* list of entries */
long flags; /* the publicly set bitmask */
};
const char *Curl_alpnid2str(enum alpnid id);
struct altsvcinfo *Curl_altsvc_init(void);
CURLcode Curl_altsvc_load(struct altsvcinfo *asi, const char *file);
-CURLcode Curl_altsvc_save(struct Curl_easy *data,
- struct altsvcinfo *asi, const char *file);
+CURLcode Curl_altsvc_save(struct Curl_easy *data,
+ struct altsvcinfo *asi, const char *file);
CURLcode Curl_altsvc_ctrl(struct altsvcinfo *asi, const long ctrl);
-void Curl_altsvc_cleanup(struct altsvcinfo **altsvc);
+void Curl_altsvc_cleanup(struct altsvcinfo **altsvc);
CURLcode Curl_altsvc_parse(struct Curl_easy *data,
struct altsvcinfo *altsvc, const char *value,
enum alpnid srcalpn, const char *srchost,
@@ -70,10 +70,10 @@ bool Curl_altsvc_lookup(struct altsvcinfo *asi,
enum alpnid srcalpnid, const char *srchost,
int srcport,
struct altsvc **dstentry,
- const int versions); /* CURLALTSVC_H* bits */
+ const int versions); /* CURLALTSVC_H* bits */
#else
/* disabled */
-#define Curl_altsvc_save(a,b,c)
-#define Curl_altsvc_cleanup(x)
-#endif /* !CURL_DISABLE_HTTP && !CURL_DISABLE_ALTSVC */
+#define Curl_altsvc_save(a,b,c)
+#define Curl_altsvc_cleanup(x)
+#endif /* !CURL_DISABLE_HTTP && !CURL_DISABLE_ALTSVC */
#endif /* HEADER_CURL_ALTSVC_H */
diff --git a/contrib/libs/curl/lib/amigaos.c b/contrib/libs/curl/lib/amigaos.c
index 8cee60b90e..d3b00d9083 100644
--- a/contrib/libs/curl/lib/amigaos.c
+++ b/contrib/libs/curl/lib/amigaos.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/amigaos.h b/contrib/libs/curl/lib/amigaos.h
index 50c58b1327..02e5bb546a 100644
--- a/contrib/libs/curl/lib/amigaos.h
+++ b/contrib/libs/curl/lib/amigaos.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/arpa_telnet.h b/contrib/libs/curl/lib/arpa_telnet.h
index a493456bad..cbe31de5a3 100644
--- a/contrib/libs/curl/lib/arpa_telnet.h
+++ b/contrib/libs/curl/lib/arpa_telnet.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/asyn-ares.c b/contrib/libs/curl/lib/asyn-ares.c
index 4b79a0b78c..1747571889 100644
--- a/contrib/libs/curl/lib/asyn-ares.c
+++ b/contrib/libs/curl/lib/asyn-ares.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -67,8 +67,8 @@
#include "select.h"
#include "progress.h"
-# if defined(CURL_STATICLIB) && !defined(CARES_STATICLIB) && \
- defined(WIN32)
+# if defined(CURL_STATICLIB) && !defined(CARES_STATICLIB) && \
+ defined(WIN32)
# define CARES_STATICLIB
# endif
# include <ares.h>
@@ -85,10 +85,10 @@
#include "curl_memory.h"
#include "memdebug.h"
-struct thread_data {
+struct thread_data {
int num_pending; /* number of ares_gethostbyname() requests */
- struct Curl_addrinfo *temp_ai; /* intermediary result while fetching c-ares
- parts */
+ struct Curl_addrinfo *temp_ai; /* intermediary result while fetching c-ares
+ parts */
int last_status;
struct curltime happy_eyeballs_dns_time; /* when this timer started, or 0 */
};
@@ -229,8 +229,8 @@ static void destroy_async_data(struct Curl_async *async)
{
free(async->hostname);
- if(async->tdata) {
- struct thread_data *res = async->tdata;
+ if(async->tdata) {
+ struct thread_data *res = async->tdata;
if(res) {
if(res->temp_ai) {
Curl_freeaddrinfo(res->temp_ai);
@@ -238,7 +238,7 @@ static void destroy_async_data(struct Curl_async *async)
}
free(res);
}
- async->tdata = NULL;
+ async->tdata = NULL;
}
async->hostname = NULL;
@@ -286,7 +286,7 @@ int Curl_resolver_getsock(struct connectdata *conn,
* return number of sockets it worked on
*/
-static int waitperform(struct connectdata *conn, timediff_t timeout_ms)
+static int waitperform(struct connectdata *conn, timediff_t timeout_ms)
{
struct Curl_easy *data = conn->data;
int nfds;
@@ -349,11 +349,11 @@ CURLcode Curl_resolver_is_resolved(struct connectdata *conn,
struct Curl_dns_entry **dns)
{
struct Curl_easy *data = conn->data;
- struct thread_data *res = conn->async.tdata;
+ struct thread_data *res = conn->async.tdata;
CURLcode result = CURLE_OK;
- DEBUGASSERT(dns);
- *dns = NULL;
+ DEBUGASSERT(dns);
+ *dns = NULL;
waitperform(conn, 0);
@@ -381,18 +381,18 @@ CURLcode Curl_resolver_is_resolved(struct connectdata *conn,
}
if(res && !res->num_pending) {
- (void)Curl_addrinfo_callback(conn, res->last_status, res->temp_ai);
- /* temp_ai ownership is moved to the connection, so we need not free-up
- them */
- res->temp_ai = NULL;
-
+ (void)Curl_addrinfo_callback(conn, res->last_status, res->temp_ai);
+ /* temp_ai ownership is moved to the connection, so we need not free-up
+ them */
+ res->temp_ai = NULL;
+
if(!conn->async.dns) {
failf(data, "Could not resolve: %s (%s)",
conn->async.hostname, ares_strerror(conn->async.status));
result = conn->bits.proxy?CURLE_COULDNT_RESOLVE_PROXY:
CURLE_COULDNT_RESOLVE_HOST;
}
- else
+ else
*dns = conn->async.dns;
destroy_async_data(&conn->async);
@@ -407,7 +407,7 @@ CURLcode Curl_resolver_is_resolved(struct connectdata *conn,
* Waits for a resolve to finish. This function should be avoided since using
* this risk getting the multi interface to "hang".
*
- * 'entry' MUST be non-NULL.
+ * 'entry' MUST be non-NULL.
*
* Returns CURLE_COULDNT_RESOLVE_HOST if the host was not resolved,
* CURLE_OPERATION_TIMEDOUT if a time-out occurred, or other errors.
@@ -420,8 +420,8 @@ CURLcode Curl_resolver_wait_resolv(struct connectdata *conn,
timediff_t timeout;
struct curltime now = Curl_now();
- DEBUGASSERT(entry);
- *entry = NULL; /* clear on entry */
+ DEBUGASSERT(entry);
+ *entry = NULL; /* clear on entry */
timeout = Curl_timeleft(data, &now, TRUE);
if(timeout < 0) {
@@ -436,13 +436,13 @@ CURLcode Curl_resolver_wait_resolv(struct connectdata *conn,
while(!result) {
struct timeval *tvp, tv, store;
int itimeout;
- timediff_t timeout_ms;
+ timediff_t timeout_ms;
-#if TIMEDIFF_T_MAX > INT_MAX
- itimeout = (timeout > INT_MAX) ? INT_MAX : (int)timeout;
-#else
- itimeout = (int)timeout;
-#endif
+#if TIMEDIFF_T_MAX > INT_MAX
+ itimeout = (timeout > INT_MAX) ? INT_MAX : (int)timeout;
+#else
+ itimeout = (int)timeout;
+#endif
store.tv_sec = itimeout/1000;
store.tv_usec = (itimeout%1000)*1000;
@@ -453,12 +453,12 @@ CURLcode Curl_resolver_wait_resolv(struct connectdata *conn,
second is left, otherwise just use 1000ms to make sure the progress
callback gets called frequent enough */
if(!tvp->tv_sec)
- timeout_ms = (timediff_t)(tvp->tv_usec/1000);
+ timeout_ms = (timediff_t)(tvp->tv_usec/1000);
else
timeout_ms = 1000;
waitperform(conn, timeout_ms);
- result = Curl_resolver_is_resolved(conn, entry);
+ result = Curl_resolver_is_resolved(conn, entry);
if(result || conn->async.done)
break;
@@ -473,7 +473,7 @@ CURLcode Curl_resolver_wait_resolv(struct connectdata *conn,
else if(timediff > timeout)
timeout = -1;
else
- timeout -= timediff;
+ timeout -= timediff;
now = now2; /* for next loop */
}
if(timeout < 0)
@@ -497,10 +497,10 @@ CURLcode Curl_resolver_wait_resolv(struct connectdata *conn,
}
/* Connects results to the list */
-static void compound_results(struct thread_data *res,
- struct Curl_addrinfo *ai)
+static void compound_results(struct thread_data *res,
+ struct Curl_addrinfo *ai)
{
- struct Curl_addrinfo *ai_tail;
+ struct Curl_addrinfo *ai_tail;
if(!ai)
return;
ai_tail = ai;
@@ -526,7 +526,7 @@ static void query_completed_cb(void *arg, /* (struct connectdata *) */
struct hostent *hostent)
{
struct connectdata *conn = (struct connectdata *)arg;
- struct thread_data *res;
+ struct thread_data *res;
#ifdef HAVE_CARES_CALLBACK_TIMEOUTS
(void)timeouts; /* ignored */
@@ -537,12 +537,12 @@ static void query_completed_cb(void *arg, /* (struct connectdata *) */
be valid so only defer it when we know the 'status' says its fine! */
return;
- res = conn->async.tdata;
+ res = conn->async.tdata;
if(res) {
res->num_pending--;
if(CURL_ASYNC_SUCCESS == status) {
- struct Curl_addrinfo *ai = Curl_he2ai(hostent, conn->async.port);
+ struct Curl_addrinfo *ai = Curl_he2ai(hostent, conn->async.port);
if(ai) {
compound_results(res, ai);
}
@@ -621,10 +621,10 @@ static void query_completed_cb(void *arg, /* (struct connectdata *) */
* memory we need to free after use. That memory *MUST* be freed with
* Curl_freeaddrinfo(), nothing else.
*/
-struct Curl_addrinfo *Curl_resolver_getaddrinfo(struct connectdata *conn,
- const char *hostname,
- int port,
- int *waitp)
+struct Curl_addrinfo *Curl_resolver_getaddrinfo(struct connectdata *conn,
+ const char *hostname,
+ int port,
+ int *waitp)
{
char *bufp;
struct Curl_easy *data = conn->data;
@@ -632,7 +632,7 @@ struct Curl_addrinfo *Curl_resolver_getaddrinfo(struct connectdata *conn,
*waitp = 0; /* default to synchronous response */
-#ifdef ENABLE_IPV6
+#ifdef ENABLE_IPV6
switch(conn->ip_version) {
default:
#if ARES_VERSION >= 0x010601
@@ -648,30 +648,30 @@ struct Curl_addrinfo *Curl_resolver_getaddrinfo(struct connectdata *conn,
family = PF_INET6;
break;
}
-#endif /* ENABLE_IPV6 */
+#endif /* ENABLE_IPV6 */
bufp = strdup(hostname);
if(bufp) {
- struct thread_data *res = NULL;
+ struct thread_data *res = NULL;
free(conn->async.hostname);
conn->async.hostname = bufp;
conn->async.port = port;
conn->async.done = FALSE; /* not done */
conn->async.status = 0; /* clear */
conn->async.dns = NULL; /* clear */
- res = calloc(sizeof(struct thread_data), 1);
+ res = calloc(sizeof(struct thread_data), 1);
if(!res) {
free(conn->async.hostname);
conn->async.hostname = NULL;
return NULL;
}
- conn->async.tdata = res;
+ conn->async.tdata = res;
/* initial status - failed */
res->last_status = ARES_ENOTFOUND;
-#ifdef ENABLE_IPV6
+#ifdef ENABLE_IPV6
if(family == PF_UNSPEC) {
- if(Curl_ipv6works(conn)) {
+ if(Curl_ipv6works(conn)) {
res->num_pending = 2;
/* areschannel is already setup in the Curl_open() function */
@@ -689,7 +689,7 @@ struct Curl_addrinfo *Curl_resolver_getaddrinfo(struct connectdata *conn,
}
}
else
-#endif /* ENABLE_IPV6 */
+#endif /* ENABLE_IPV6 */
{
res->num_pending = 1;
diff --git a/contrib/libs/curl/lib/asyn-thread.c b/contrib/libs/curl/lib/asyn-thread.c
index fc018b1cd5..c49878bb55 100644
--- a/contrib/libs/curl/lib/asyn-thread.c
+++ b/contrib/libs/curl/lib/asyn-thread.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -21,7 +21,7 @@
***************************************************************************/
#include "curl_setup.h"
-#include "socketpair.h"
+#include "socketpair.h"
/***********************************************************************
* Only for threaded name resolves builds
@@ -74,7 +74,7 @@
#include "inet_ntop.h"
#include "curl_threads.h"
#include "connect.h"
-#include "socketpair.h"
+#include "socketpair.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
#include "curl_memory.h"
@@ -209,18 +209,18 @@ static bool init_resolve_thread(struct connectdata *conn,
/* Data for synchronization between resolver thread and its parent */
struct thread_sync_data {
- curl_mutex_t *mtx;
+ curl_mutex_t *mtx;
int done;
char *hostname; /* hostname to resolve, Curl_async.hostname
duplicate */
int port;
-#ifdef USE_SOCKETPAIR
+#ifdef USE_SOCKETPAIR
struct connectdata *conn;
curl_socket_t sock_pair[2]; /* socket pair */
#endif
int sock_error;
- struct Curl_addrinfo *res;
+ struct Curl_addrinfo *res;
#ifdef HAVE_GETADDRINFO
struct addrinfo hints;
#endif
@@ -230,7 +230,7 @@ struct thread_sync_data {
struct thread_data {
curl_thread_t thread_hnd;
unsigned int poll_interval;
- timediff_t interval_end;
+ timediff_t interval_end;
struct thread_sync_data tsd;
/* 'reserved' memory must be available in case the thread is orphaned */
void *reserved;
@@ -238,12 +238,12 @@ struct thread_data {
static struct thread_sync_data *conn_thread_sync_data(struct connectdata *conn)
{
- return &(conn->async.tdata->tsd);
+ return &(conn->async.tdata->tsd);
}
/* Destroy resolver thread synchronization data */
static
-void destroy_thread_sync_data(struct thread_sync_data *tsd)
+void destroy_thread_sync_data(struct thread_sync_data *tsd)
{
if(tsd->mtx) {
Curl_mutex_destroy(tsd->mtx);
@@ -255,7 +255,7 @@ void destroy_thread_sync_data(struct thread_sync_data *tsd)
if(tsd->res)
Curl_freeaddrinfo(tsd->res);
-#ifdef USE_SOCKETPAIR
+#ifdef USE_SOCKETPAIR
/*
* close one end of the socket pair (may be done in resolver thread);
* the other end (for reading) is always closed in the parent thread.
@@ -269,10 +269,10 @@ void destroy_thread_sync_data(struct thread_sync_data *tsd)
/* Initialize resolver thread synchronization data */
static
-int init_thread_sync_data(struct thread_data *td,
- const char *hostname,
- int port,
- const struct addrinfo *hints)
+int init_thread_sync_data(struct thread_data *td,
+ const char *hostname,
+ int port,
+ const struct addrinfo *hints)
{
struct thread_sync_data *tsd = &td->tsd;
@@ -301,9 +301,9 @@ int init_thread_sync_data(struct thread_data *td,
goto err_exit;
}
-#ifdef USE_SOCKETPAIR
- /* create socket pair, avoid AF_LOCAL since it doesn't build on Solaris */
- if(Curl_socketpair(AF_UNIX, SOCK_STREAM, 0, &tsd->sock_pair[0]) < 0) {
+#ifdef USE_SOCKETPAIR
+ /* create socket pair, avoid AF_LOCAL since it doesn't build on Solaris */
+ if(Curl_socketpair(AF_UNIX, SOCK_STREAM, 0, &tsd->sock_pair[0]) < 0) {
tsd->sock_pair[0] = CURL_SOCKET_BAD;
tsd->sock_pair[1] = CURL_SOCKET_BAD;
goto err_exit;
@@ -351,12 +351,12 @@ static int getaddrinfo_complete(struct connectdata *conn)
*/
static unsigned int CURL_STDCALL getaddrinfo_thread(void *arg)
{
- struct thread_sync_data *tsd = (struct thread_sync_data *)arg;
+ struct thread_sync_data *tsd = (struct thread_sync_data *)arg;
struct thread_data *td = tsd->td;
struct thread_list *orphan = NULL;
char service[12];
int rc;
-#ifdef USE_SOCKETPAIR
+#ifdef USE_SOCKETPAIR
char buf[1];
#endif
@@ -382,11 +382,11 @@ static unsigned int CURL_STDCALL getaddrinfo_thread(void *arg)
free(td);
}
else {
-#ifdef USE_SOCKETPAIR
+#ifdef USE_SOCKETPAIR
if(tsd->sock_pair[1] != CURL_SOCKET_BAD) {
/* DNS has been resolved, signal client task */
buf[0] = 1;
- if(swrite(tsd->sock_pair[1], buf, sizeof(buf)) < 0) {
+ if(swrite(tsd->sock_pair[1], buf, sizeof(buf)) < 0) {
/* update sock_erro to errno */
tsd->sock_error = SOCKERRNO;
}
@@ -447,10 +447,10 @@ static unsigned int CURL_STDCALL gethostbyname_thread(void *arg)
*/
static void destroy_async_data(struct Curl_async *async)
{
- if(async->tdata) {
- struct thread_data *td = async->tdata;
+ if(async->tdata) {
+ struct thread_data *td = async->tdata;
int done;
-#ifdef USE_SOCKETPAIR
+#ifdef USE_SOCKETPAIR
curl_socket_t sock_rd = td->tsd.sock_pair[0];
struct connectdata *conn = td->tsd.conn;
#endif
@@ -510,7 +510,7 @@ static void destroy_async_data(struct Curl_async *async)
free(td->reserved);
free(td);
}
-#ifdef USE_SOCKETPAIR
+#ifdef USE_SOCKETPAIR
/*
* ensure CURLMOPT_SOCKETFUNCTION fires CURL_POLL_REMOVE
* before the FD is invalidated to avoid EBADF on EPOLL_CTL_DEL
@@ -520,7 +520,7 @@ static void destroy_async_data(struct Curl_async *async)
sclose(sock_rd);
#endif
}
- async->tdata = NULL;
+ async->tdata = NULL;
free(async->hostname);
async->hostname = NULL;
@@ -539,7 +539,7 @@ static bool init_resolve_thread(struct connectdata *conn,
struct thread_data *td = calloc(1, sizeof(struct thread_data));
int err = ENOMEM;
- conn->async.tdata = td;
+ conn->async.tdata = td;
if(!td)
goto errno_exit;
@@ -551,7 +551,7 @@ static bool init_resolve_thread(struct connectdata *conn,
td->reserved = calloc(1, sizeof(struct thread_list));
if(!td->reserved || !init_thread_sync_data(td, hostname, port, hints)) {
- conn->async.tdata = NULL;
+ conn->async.tdata = NULL;
free(td->reserved);
free(td);
goto errno_exit;
@@ -598,14 +598,14 @@ static CURLcode resolver_error(struct connectdata *conn)
const char *host_or_proxy;
CURLcode result;
-#ifndef CURL_DISABLE_PROXY
+#ifndef CURL_DISABLE_PROXY
if(conn->bits.httpproxy) {
host_or_proxy = "proxy";
result = CURLE_COULDNT_RESOLVE_PROXY;
}
- else
-#endif
- {
+ else
+#endif
+ {
host_or_proxy = "host";
result = CURLE_COULDNT_RESOLVE_HOST;
}
@@ -616,14 +616,14 @@ static CURLcode resolver_error(struct connectdata *conn)
return result;
}
-/*
- * 'entry' may be NULL and then no data is returned
- */
+/*
+ * 'entry' may be NULL and then no data is returned
+ */
static CURLcode thread_wait_resolv(struct connectdata *conn,
struct Curl_dns_entry **entry,
bool report)
{
- struct thread_data *td = conn->async.tdata;
+ struct thread_data *td = conn->async.tdata;
CURLcode result = CURLE_OK;
DEBUGASSERT(conn && td);
@@ -661,7 +661,7 @@ static CURLcode thread_wait_resolv(struct connectdata *conn,
*/
void Curl_resolver_kill(struct connectdata *conn)
{
- struct thread_data *td = conn->async.tdata;
+ struct thread_data *td = conn->async.tdata;
/* If we're still resolving, we must wait for the threads to fully clean up,
unfortunately. Otherwise, we can simply cancel to clean up any resolver
@@ -700,10 +700,10 @@ CURLcode Curl_resolver_is_resolved(struct connectdata *conn,
struct Curl_dns_entry **entry)
{
struct Curl_easy *data = conn->data;
- struct thread_data *td = conn->async.tdata;
+ struct thread_data *td = conn->async.tdata;
int done = 0;
- DEBUGASSERT(entry);
+ DEBUGASSERT(entry);
*entry = NULL;
if(!td) {
@@ -729,8 +729,8 @@ CURLcode Curl_resolver_is_resolved(struct connectdata *conn,
else {
/* poll for name lookup done with exponential backoff up to 250ms */
/* should be fine even if this converts to 32 bit */
- timediff_t elapsed = Curl_timediff(Curl_now(),
- data->progress.t_startsingle);
+ timediff_t elapsed = Curl_timediff(Curl_now(),
+ data->progress.t_startsingle);
if(elapsed < 0)
elapsed = 0;
@@ -755,17 +755,17 @@ int Curl_resolver_getsock(struct connectdata *conn,
curl_socket_t *socks)
{
int ret_val = 0;
- timediff_t milli;
+ timediff_t milli;
timediff_t ms;
struct Curl_easy *data = conn->data;
struct resdata *reslv = (struct resdata *)data->state.resolver;
-#ifdef USE_SOCKETPAIR
- struct thread_data *td = conn->async.tdata;
+#ifdef USE_SOCKETPAIR
+ struct thread_data *td = conn->async.tdata;
#else
(void)socks;
#endif
-#ifdef USE_SOCKETPAIR
+#ifdef USE_SOCKETPAIR
if(td) {
/* return read fd to client for polling the DNS resolution status */
socks[0] = td->tsd.sock_pair[0];
@@ -779,13 +779,13 @@ int Curl_resolver_getsock(struct connectdata *conn,
if(ms < 3)
milli = 0;
else if(ms <= 50)
- milli = ms/3;
+ milli = ms/3;
else if(ms <= 250)
milli = 50;
else
milli = 200;
Curl_expire(data, milli, EXPIRE_ASYNC_NAME);
-#ifdef USE_SOCKETPAIR
+#ifdef USE_SOCKETPAIR
}
#endif
@@ -797,10 +797,10 @@ int Curl_resolver_getsock(struct connectdata *conn,
/*
* Curl_getaddrinfo() - for platforms without getaddrinfo
*/
-struct Curl_addrinfo *Curl_resolver_getaddrinfo(struct connectdata *conn,
- const char *hostname,
- int port,
- int *waitp)
+struct Curl_addrinfo *Curl_resolver_getaddrinfo(struct connectdata *conn,
+ const char *hostname,
+ int port,
+ int *waitp)
{
struct Curl_easy *data = conn->data;
struct resdata *reslv = (struct resdata *)data->state.resolver;
@@ -825,10 +825,10 @@ struct Curl_addrinfo *Curl_resolver_getaddrinfo(struct connectdata *conn,
/*
* Curl_resolver_getaddrinfo() - for getaddrinfo
*/
-struct Curl_addrinfo *Curl_resolver_getaddrinfo(struct connectdata *conn,
- const char *hostname,
- int port,
- int *waitp)
+struct Curl_addrinfo *Curl_resolver_getaddrinfo(struct connectdata *conn,
+ const char *hostname,
+ int port,
+ int *waitp)
{
struct addrinfo hints;
int pf = PF_INET;
@@ -853,7 +853,7 @@ struct Curl_addrinfo *Curl_resolver_getaddrinfo(struct connectdata *conn,
break;
}
- if((pf != PF_INET) && !Curl_ipv6works(conn))
+ if((pf != PF_INET) && !Curl_ipv6works(conn))
/* The stack seems to be a non-IPv6 one */
pf = PF_INET;
#endif /* CURLRES_IPV6 */
diff --git a/contrib/libs/curl/lib/asyn.h b/contrib/libs/curl/lib/asyn.h
index 1b7b7652bd..73a9b7268f 100644
--- a/contrib/libs/curl/lib/asyn.h
+++ b/contrib/libs/curl/lib/asyn.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -153,10 +153,10 @@ CURLcode Curl_resolver_wait_resolv(struct connectdata *conn,
* Each resolver backend must of course make sure to return data in the
* correct format to comply with this.
*/
-struct Curl_addrinfo *Curl_resolver_getaddrinfo(struct connectdata *conn,
- const char *hostname,
- int port,
- int *waitp);
+struct Curl_addrinfo *Curl_resolver_getaddrinfo(struct connectdata *conn,
+ const char *hostname,
+ int port,
+ int *waitp);
#ifndef CURLRES_ASYNCH
/* convert these functions if an asynch resolver isn't used */
diff --git a/contrib/libs/curl/lib/base64.c b/contrib/libs/curl/lib/base64.c
index dfb5ad347f..be6f163dc4 100644
--- a/contrib/libs/curl/lib/base64.c
+++ b/contrib/libs/curl/lib/base64.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -26,9 +26,9 @@
#if !defined(CURL_DISABLE_HTTP_AUTH) || defined(USE_SSH) || \
!defined(CURL_DISABLE_LDAP) || \
- !defined(CURL_DISABLE_SMTP) || \
- !defined(CURL_DISABLE_POP3) || \
- !defined(CURL_DISABLE_IMAP) || \
+ !defined(CURL_DISABLE_SMTP) || \
+ !defined(CURL_DISABLE_POP3) || \
+ !defined(CURL_DISABLE_IMAP) || \
!defined(CURL_DISABLE_DOH) || defined(USE_SSL)
#include "urldata.h" /* for the Curl_easy definition */
diff --git a/contrib/libs/curl/lib/config-amigaos.h b/contrib/libs/curl/lib/config-amigaos.h
index 22bd1e2381..3c9d76ef3d 100644
--- a/contrib/libs/curl/lib/config-amigaos.h
+++ b/contrib/libs/curl/lib/config-amigaos.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -96,7 +96,7 @@
#define OS "AmigaOS"
#define PACKAGE "curl"
-#define PACKAGE_BUGREPORT "a suitable mailing list: https://curl.se/mail/"
+#define PACKAGE_BUGREPORT "a suitable mailing list: https://curl.se/mail/"
#define PACKAGE_NAME "curl"
#define PACKAGE_STRING "curl -"
#define PACKAGE_TARNAME "curl"
diff --git a/contrib/libs/curl/lib/config-dos.h b/contrib/libs/curl/lib/config-dos.h
index a3503949c6..50816ac756 100644
--- a/contrib/libs/curl/lib/config-dos.h
+++ b/contrib/libs/curl/lib/config-dos.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/config-mac.h b/contrib/libs/curl/lib/config-mac.h
index 6224a80592..4e610562f6 100644
--- a/contrib/libs/curl/lib/config-mac.h
+++ b/contrib/libs/curl/lib/config-mac.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/config-os400.h b/contrib/libs/curl/lib/config-os400.h
index e5062b68fd..b8676113d7 100644
--- a/contrib/libs/curl/lib/config-os400.h
+++ b/contrib/libs/curl/lib/config-os400.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/config-plan9.h b/contrib/libs/curl/lib/config-plan9.h
index 58ebb1e849..cc8adde725 100644
--- a/contrib/libs/curl/lib/config-plan9.h
+++ b/contrib/libs/curl/lib/config-plan9.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -33,7 +33,7 @@
#define OS "plan9"
#define PACKAGE "curl"
#define PACKAGE_NAME "curl"
-#define PACKAGE_BUGREPORT "a suitable mailing list: https://curl.se/mail/"
+#define PACKAGE_BUGREPORT "a suitable mailing list: https://curl.se/mail/"
#define PACKAGE_STRING "curl -"
#define PACKAGE_TARNAME "curl"
#define PACKAGE_VERSION "-"
diff --git a/contrib/libs/curl/lib/config-riscos.h b/contrib/libs/curl/lib/config-riscos.h
index c162754f62..9b5f8da921 100644
--- a/contrib/libs/curl/lib/config-riscos.h
+++ b/contrib/libs/curl/lib/config-riscos.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/config-tpf.h b/contrib/libs/curl/lib/config-tpf.h
index 5ce2faf259..bf69179fd5 100644
--- a/contrib/libs/curl/lib/config-tpf.h
+++ b/contrib/libs/curl/lib/config-tpf.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -561,7 +561,7 @@
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT \
- "a suitable curl mailing list => https://curl.se/mail/"
+ "a suitable curl mailing list => https://curl.se/mail/"
/* Define to the full name of this package. */
#define PACKAGE_NAME "curl"
diff --git a/contrib/libs/curl/lib/config-vxworks.h b/contrib/libs/curl/lib/config-vxworks.h
index 3810570e59..73edd530b4 100644
--- a/contrib/libs/curl/lib/config-vxworks.h
+++ b/contrib/libs/curl/lib/config-vxworks.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/config-win32.h b/contrib/libs/curl/lib/config-win32.h
index 778f05d753..e3095576f8 100644
--- a/contrib/libs/curl/lib/config-win32.h
+++ b/contrib/libs/curl/lib/config-win32.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -183,7 +183,7 @@
/* #define HAVE_DOPRNT 1 */
/* Define if you have the ftruncate function. */
-/* #define HAVE_FTRUNCATE 1 */
+/* #define HAVE_FTRUNCATE 1 */
/* Define to 1 if you have the `getpeername' function. */
#define HAVE_GETPEERNAME 1
@@ -714,24 +714,24 @@ Vista
#endif
/* Define to use the Windows crypto library. */
-#if !defined(CURL_WINDOWS_APP)
+#if !defined(CURL_WINDOWS_APP)
#define USE_WIN32_CRYPTO
-#endif
+#endif
-/* On MinGW the ADDRESS_FAMILY typedef was committed alongside LUP_SECURE,
- so we use it to check for the presence of the typedef. */
-#include <ws2tcpip.h>
-#if !defined(__MINGW32__) || defined(LUP_SECURE)
+/* On MinGW the ADDRESS_FAMILY typedef was committed alongside LUP_SECURE,
+ so we use it to check for the presence of the typedef. */
+#include <ws2tcpip.h>
+#if !defined(__MINGW32__) || defined(LUP_SECURE)
/* Define to use Unix sockets. */
#define USE_UNIX_SOCKETS
-#if !defined(UNIX_PATH_MAX)
- /* Replicating logic present in afunix.h of newer Windows 10 SDK versions */
-# define UNIX_PATH_MAX 108
- /* !checksrc! disable TYPEDEFSTRUCT 1 */
- typedef struct sockaddr_un {
- ADDRESS_FAMILY sun_family;
- char sun_path[UNIX_PATH_MAX];
- } SOCKADDR_UN, *PSOCKADDR_UN;
+#if !defined(UNIX_PATH_MAX)
+ /* Replicating logic present in afunix.h of newer Windows 10 SDK versions */
+# define UNIX_PATH_MAX 108
+ /* !checksrc! disable TYPEDEFSTRUCT 1 */
+ typedef struct sockaddr_un {
+ ADDRESS_FAMILY sun_family;
+ char sun_path[UNIX_PATH_MAX];
+ } SOCKADDR_UN, *PSOCKADDR_UN;
#endif
#endif
@@ -745,12 +745,12 @@ Vista
#define OS "i386-pc-win32"
#elif defined(_M_X64) || defined(__x86_64__) /* x86_64 (MSVC >=2005 or gcc) */
#define OS "x86_64-pc-win32"
-#elif defined(_M_IA64) || defined(__ia64__) /* Itanium */
+#elif defined(_M_IA64) || defined(__ia64__) /* Itanium */
#define OS "ia64-pc-win32"
-#elif defined(_M_ARM_NT) || defined(__arm__) /* ARMv7-Thumb2 (Windows RT) */
-#define OS "thumbv7a-pc-win32"
-#elif defined(_M_ARM64) || defined(__aarch64__) /* ARM64 (Windows 10) */
-#define OS "aarch64-pc-win32"
+#elif defined(_M_ARM_NT) || defined(__arm__) /* ARMv7-Thumb2 (Windows RT) */
+#define OS "thumbv7a-pc-win32"
+#elif defined(_M_ARM64) || defined(__aarch64__) /* ARM64 (Windows 10) */
+#define OS "aarch64-pc-win32"
#else
#define OS "unknown-pc-win32"
#endif
diff --git a/contrib/libs/curl/lib/config-win32ce.h b/contrib/libs/curl/lib/config-win32ce.h
index 493d725742..9060836944 100644
--- a/contrib/libs/curl/lib/config-win32ce.h
+++ b/contrib/libs/curl/lib/config-win32ce.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/conncache.c b/contrib/libs/curl/lib/conncache.c
index d74c2a6860..cb3170c480 100644
--- a/contrib/libs/curl/lib/conncache.c
+++ b/contrib/libs/curl/lib/conncache.c
@@ -6,11 +6,11 @@
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2012 - 2016, Linus Nielsen Feltzing, <linus@haxx.se>
- * Copyright (C) 2012 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2012 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -49,57 +49,57 @@ static void conn_llist_dtor(void *user, void *element)
conn->bundle = NULL;
}
-static CURLcode bundle_create(struct connectbundle **bundlep)
+static CURLcode bundle_create(struct connectbundle **bundlep)
{
- DEBUGASSERT(*bundlep == NULL);
- *bundlep = malloc(sizeof(struct connectbundle));
- if(!*bundlep)
+ DEBUGASSERT(*bundlep == NULL);
+ *bundlep = malloc(sizeof(struct connectbundle));
+ if(!*bundlep)
return CURLE_OUT_OF_MEMORY;
- (*bundlep)->num_connections = 0;
- (*bundlep)->multiuse = BUNDLE_UNKNOWN;
+ (*bundlep)->num_connections = 0;
+ (*bundlep)->multiuse = BUNDLE_UNKNOWN;
- Curl_llist_init(&(*bundlep)->conn_list, (Curl_llist_dtor) conn_llist_dtor);
+ Curl_llist_init(&(*bundlep)->conn_list, (Curl_llist_dtor) conn_llist_dtor);
return CURLE_OK;
}
-static void bundle_destroy(struct connectbundle *bundle)
+static void bundle_destroy(struct connectbundle *bundle)
{
- if(!bundle)
+ if(!bundle)
return;
- Curl_llist_destroy(&bundle->conn_list, NULL);
+ Curl_llist_destroy(&bundle->conn_list, NULL);
- free(bundle);
+ free(bundle);
}
/* Add a connection to a bundle */
-static void bundle_add_conn(struct connectbundle *bundle,
+static void bundle_add_conn(struct connectbundle *bundle,
struct connectdata *conn)
{
- Curl_llist_insert_next(&bundle->conn_list, bundle->conn_list.tail, conn,
+ Curl_llist_insert_next(&bundle->conn_list, bundle->conn_list.tail, conn,
&conn->bundle_node);
- conn->bundle = bundle;
- bundle->num_connections++;
+ conn->bundle = bundle;
+ bundle->num_connections++;
}
/* Remove a connection from a bundle */
-static int bundle_remove_conn(struct connectbundle *bundle,
+static int bundle_remove_conn(struct connectbundle *bundle,
struct connectdata *conn)
{
- struct Curl_llist_element *curr;
+ struct Curl_llist_element *curr;
- curr = bundle->conn_list.head;
+ curr = bundle->conn_list.head;
while(curr) {
if(curr->ptr == conn) {
- Curl_llist_remove(&bundle->conn_list, curr, NULL);
- bundle->num_connections--;
+ Curl_llist_remove(&bundle->conn_list, curr, NULL);
+ bundle->num_connections--;
conn->bundle = NULL;
return 1; /* we removed a handle */
}
curr = curr->next;
}
- DEBUGASSERT(0);
+ DEBUGASSERT(0);
return 0;
}
@@ -121,8 +121,8 @@ int Curl_conncache_init(struct conncache *connc, int size)
rc = Curl_hash_init(&connc->hash, size, Curl_hash_str,
Curl_str_key_compare, free_bundle_hash_entry);
- if(rc)
- Curl_close(&connc->closure_handle);
+ if(rc)
+ Curl_close(&connc->closure_handle);
else
connc->closure_handle->state.conn_cache = connc;
@@ -143,16 +143,16 @@ static void hashkey(struct connectdata *conn, char *buf,
const char *hostname;
long port = conn->remote_port;
-#ifndef CURL_DISABLE_PROXY
+#ifndef CURL_DISABLE_PROXY
if(conn->bits.httpproxy && !conn->bits.tunnel_proxy) {
hostname = conn->http_proxy.host.name;
port = conn->port;
}
else
-#endif
- if(conn->bits.conn_to_host)
- hostname = conn->conn_to_host.name;
- else
+#endif
+ if(conn->bits.conn_to_host)
+ hostname = conn->conn_to_host.name;
+ else
hostname = conn->host.name;
if(hostp)
@@ -169,9 +169,9 @@ static void hashkey(struct connectdata *conn, char *buf,
size_t Curl_conncache_size(struct Curl_easy *data)
{
size_t num;
- CONNCACHE_LOCK(data);
+ CONNCACHE_LOCK(data);
num = data->state.conn_cache->num_conn;
- CONNCACHE_UNLOCK(data);
+ CONNCACHE_UNLOCK(data);
return num;
}
@@ -184,7 +184,7 @@ struct connectbundle *Curl_conncache_find_bundle(struct connectdata *conn,
const char **hostp)
{
struct connectbundle *bundle = NULL;
- CONNCACHE_LOCK(conn->data);
+ CONNCACHE_LOCK(conn->data);
if(connc) {
char key[HASHKEY_SIZE];
hashkey(conn, key, sizeof(key), hostp);
@@ -206,8 +206,8 @@ static bool conncache_add_bundle(struct conncache *connc,
static void conncache_remove_bundle(struct conncache *connc,
struct connectbundle *bundle)
{
- struct Curl_hash_iterator iter;
- struct Curl_hash_element *he;
+ struct Curl_hash_iterator iter;
+ struct Curl_hash_element *he;
if(!connc)
return;
@@ -231,7 +231,7 @@ CURLcode Curl_conncache_add_conn(struct conncache *connc,
struct connectdata *conn)
{
CURLcode result = CURLE_OK;
- struct connectbundle *bundle = NULL;
+ struct connectbundle *bundle = NULL;
struct Curl_easy *data = conn->data;
/* *find_bundle() locks the connection cache */
@@ -240,16 +240,16 @@ CURLcode Curl_conncache_add_conn(struct conncache *connc,
int rc;
char key[HASHKEY_SIZE];
- result = bundle_create(&bundle);
+ result = bundle_create(&bundle);
if(result) {
goto unlock;
}
hashkey(conn, key, sizeof(key), NULL);
- rc = conncache_add_bundle(data->state.conn_cache, key, bundle);
+ rc = conncache_add_bundle(data->state.conn_cache, key, bundle);
if(!rc) {
- bundle_destroy(bundle);
+ bundle_destroy(bundle);
result = CURLE_OUT_OF_MEMORY;
goto unlock;
}
@@ -264,17 +264,17 @@ CURLcode Curl_conncache_add_conn(struct conncache *connc,
conn->connection_id, connc->num_conn));
unlock:
- CONNCACHE_UNLOCK(data);
+ CONNCACHE_UNLOCK(data);
return result;
}
/*
- * Removes the connectdata object from the connection cache, but does *not*
- * clear the conn->data association. The transfer still owns this connection.
- *
- * Pass TRUE/FALSE in the 'lock' argument depending on if the parent function
- * already holds the lock or not.
+ * Removes the connectdata object from the connection cache, but does *not*
+ * clear the conn->data association. The transfer still owns this connection.
+ *
+ * Pass TRUE/FALSE in the 'lock' argument depending on if the parent function
+ * already holds the lock or not.
*/
void Curl_conncache_remove_conn(struct Curl_easy *data,
struct connectdata *conn, bool lock)
@@ -286,7 +286,7 @@ void Curl_conncache_remove_conn(struct Curl_easy *data,
due to a failed connection attempt, before being added to a bundle */
if(bundle) {
if(lock) {
- CONNCACHE_LOCK(data);
+ CONNCACHE_LOCK(data);
}
bundle_remove_conn(bundle, conn);
if(bundle->num_connections == 0)
@@ -298,7 +298,7 @@ void Curl_conncache_remove_conn(struct Curl_easy *data,
connc->num_conn));
}
if(lock) {
- CONNCACHE_UNLOCK(data);
+ CONNCACHE_UNLOCK(data);
}
}
}
@@ -320,14 +320,14 @@ bool Curl_conncache_foreach(struct Curl_easy *data,
void *param,
int (*func)(struct connectdata *conn, void *param))
{
- struct Curl_hash_iterator iter;
- struct Curl_llist_element *curr;
- struct Curl_hash_element *he;
+ struct Curl_hash_iterator iter;
+ struct Curl_llist_element *curr;
+ struct Curl_hash_element *he;
if(!connc)
return FALSE;
- CONNCACHE_LOCK(data);
+ CONNCACHE_LOCK(data);
Curl_hash_start_iterate(&connc->hash, &iter);
he = Curl_hash_next_element(&iter);
@@ -345,12 +345,12 @@ bool Curl_conncache_foreach(struct Curl_easy *data,
curr = curr->next;
if(1 == func(conn, param)) {
- CONNCACHE_UNLOCK(data);
+ CONNCACHE_UNLOCK(data);
return TRUE;
}
}
}
- CONNCACHE_UNLOCK(data);
+ CONNCACHE_UNLOCK(data);
return FALSE;
}
@@ -363,15 +363,15 @@ bool Curl_conncache_foreach(struct Curl_easy *data,
static struct connectdata *
conncache_find_first_connection(struct conncache *connc)
{
- struct Curl_hash_iterator iter;
- struct Curl_hash_element *he;
+ struct Curl_hash_iterator iter;
+ struct Curl_hash_element *he;
struct connectbundle *bundle;
Curl_hash_start_iterate(&connc->hash, &iter);
he = Curl_hash_next_element(&iter);
while(he) {
- struct Curl_llist_element *curr;
+ struct Curl_llist_element *curr;
bundle = he->ptr;
curr = bundle->conn_list.head;
@@ -391,8 +391,8 @@ conncache_find_first_connection(struct conncache *connc)
*
* Return TRUE if stored, FALSE if closed.
*/
-bool Curl_conncache_return_conn(struct Curl_easy *data,
- struct connectdata *conn)
+bool Curl_conncache_return_conn(struct Curl_easy *data,
+ struct connectdata *conn)
{
/* data->multi->maxconnects can be negative, deal with it. */
size_t maxconnects =
@@ -429,7 +429,7 @@ struct connectdata *
Curl_conncache_extract_bundle(struct Curl_easy *data,
struct connectbundle *bundle)
{
- struct Curl_llist_element *curr;
+ struct Curl_llist_element *curr;
timediff_t highscore = -1;
timediff_t score;
struct curltime now;
@@ -477,9 +477,9 @@ struct connectdata *
Curl_conncache_extract_oldest(struct Curl_easy *data)
{
struct conncache *connc = data->state.conn_cache;
- struct Curl_hash_iterator iter;
- struct Curl_llist_element *curr;
- struct Curl_hash_element *he;
+ struct Curl_hash_iterator iter;
+ struct Curl_llist_element *curr;
+ struct Curl_hash_element *he;
timediff_t highscore =- 1;
timediff_t score;
struct curltime now;
@@ -489,7 +489,7 @@ Curl_conncache_extract_oldest(struct Curl_easy *data)
now = Curl_now();
- CONNCACHE_LOCK(data);
+ CONNCACHE_LOCK(data);
Curl_hash_start_iterate(&connc->hash, &iter);
he = Curl_hash_next_element(&iter);
@@ -502,8 +502,8 @@ Curl_conncache_extract_oldest(struct Curl_easy *data)
while(curr) {
conn = curr->ptr;
- if(!CONN_INUSE(conn) && !conn->data && !conn->bits.close &&
- !conn->bits.connect_only) {
+ if(!CONN_INUSE(conn) && !conn->data && !conn->bits.close &&
+ !conn->bits.connect_only) {
/* Set higher score for the age passed since the connection was used */
score = Curl_timediff(now, conn->lastused);
@@ -526,7 +526,7 @@ Curl_conncache_extract_oldest(struct Curl_easy *data)
connc->num_conn));
conn_candidate->data = data; /* associate! */
}
- CONNCACHE_UNLOCK(data);
+ CONNCACHE_UNLOCK(data);
return conn_candidate;
}
@@ -534,11 +534,11 @@ Curl_conncache_extract_oldest(struct Curl_easy *data)
void Curl_conncache_close_all_connections(struct conncache *connc)
{
struct connectdata *conn;
- char buffer[READBUFFER_MIN + 1];
- if(!connc->closure_handle)
- return;
- connc->closure_handle->state.buffer = buffer;
- connc->closure_handle->set.buffer_size = READBUFFER_MIN;
+ char buffer[READBUFFER_MIN + 1];
+ if(!connc->closure_handle)
+ return;
+ connc->closure_handle->state.buffer = buffer;
+ connc->closure_handle->set.buffer_size = READBUFFER_MIN;
conn = conncache_find_first_connection(connc);
while(conn) {
@@ -548,21 +548,21 @@ void Curl_conncache_close_all_connections(struct conncache *connc)
sigpipe_ignore(conn->data, &pipe_st);
/* This will remove the connection from the cache */
connclose(conn, "kill all");
- Curl_conncache_remove_conn(conn->data, conn, TRUE);
+ Curl_conncache_remove_conn(conn->data, conn, TRUE);
(void)Curl_disconnect(connc->closure_handle, conn, FALSE);
sigpipe_restore(&pipe_st);
conn = conncache_find_first_connection(connc);
}
- connc->closure_handle->state.buffer = NULL;
+ connc->closure_handle->state.buffer = NULL;
if(connc->closure_handle) {
SIGPIPE_VARIABLE(pipe_st);
sigpipe_ignore(connc->closure_handle, &pipe_st);
Curl_hostcache_clean(connc->closure_handle,
connc->closure_handle->dns.hostcache);
- Curl_close(&connc->closure_handle);
+ Curl_close(&connc->closure_handle);
sigpipe_restore(&pipe_st);
}
}
@@ -571,9 +571,9 @@ void Curl_conncache_close_all_connections(struct conncache *connc)
/* Useful for debugging the connection cache */
void Curl_conncache_print(struct conncache *connc)
{
- struct Curl_hash_iterator iter;
- struct Curl_llist_element *curr;
- struct Curl_hash_element *he;
+ struct Curl_hash_iterator iter;
+ struct Curl_llist_element *curr;
+ struct Curl_hash_element *he;
if(!connc)
return;
diff --git a/contrib/libs/curl/lib/conncache.h b/contrib/libs/curl/lib/conncache.h
index 12c7d3f700..ac5460ff4b 100644
--- a/contrib/libs/curl/lib/conncache.h
+++ b/contrib/libs/curl/lib/conncache.h
@@ -7,12 +7,12 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 2015 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2015 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 2012 - 2014, Linus Nielsen Feltzing, <linus@haxx.se>
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -30,7 +30,7 @@
*/
struct conncache {
- struct Curl_hash hash;
+ struct Curl_hash hash;
size_t num_conn;
long next_connection_id;
struct curltime last_cleanup;
@@ -42,31 +42,31 @@ struct conncache {
#define BUNDLE_UNKNOWN 0 /* initial value */
#define BUNDLE_MULTIPLEX 2
-#ifdef CURLDEBUG
-/* the debug versions of these macros make extra certain that the lock is
- never doubly locked or unlocked */
-#define CONNCACHE_LOCK(x) if((x)->share) { \
- Curl_share_lock((x), CURL_LOCK_DATA_CONNECT, CURL_LOCK_ACCESS_SINGLE); \
- DEBUGASSERT(!(x)->state.conncache_lock); \
- (x)->state.conncache_lock = TRUE; \
- }
-
-#define CONNCACHE_UNLOCK(x) if((x)->share) { \
- DEBUGASSERT((x)->state.conncache_lock); \
- (x)->state.conncache_lock = FALSE; \
- Curl_share_unlock((x), CURL_LOCK_DATA_CONNECT); \
- }
-#else
-#define CONNCACHE_LOCK(x) if((x)->share) \
- Curl_share_lock((x), CURL_LOCK_DATA_CONNECT, CURL_LOCK_ACCESS_SINGLE)
-#define CONNCACHE_UNLOCK(x) if((x)->share) \
- Curl_share_unlock((x), CURL_LOCK_DATA_CONNECT)
-#endif
-
+#ifdef CURLDEBUG
+/* the debug versions of these macros make extra certain that the lock is
+ never doubly locked or unlocked */
+#define CONNCACHE_LOCK(x) if((x)->share) { \
+ Curl_share_lock((x), CURL_LOCK_DATA_CONNECT, CURL_LOCK_ACCESS_SINGLE); \
+ DEBUGASSERT(!(x)->state.conncache_lock); \
+ (x)->state.conncache_lock = TRUE; \
+ }
+
+#define CONNCACHE_UNLOCK(x) if((x)->share) { \
+ DEBUGASSERT((x)->state.conncache_lock); \
+ (x)->state.conncache_lock = FALSE; \
+ Curl_share_unlock((x), CURL_LOCK_DATA_CONNECT); \
+ }
+#else
+#define CONNCACHE_LOCK(x) if((x)->share) \
+ Curl_share_lock((x), CURL_LOCK_DATA_CONNECT, CURL_LOCK_ACCESS_SINGLE)
+#define CONNCACHE_UNLOCK(x) if((x)->share) \
+ Curl_share_unlock((x), CURL_LOCK_DATA_CONNECT)
+#endif
+
struct connectbundle {
int multiuse; /* supports multi-use */
size_t num_connections; /* Number of connections in the bundle */
- struct Curl_llist conn_list; /* The connectdata members of the bundle */
+ struct Curl_llist conn_list; /* The connectdata members of the bundle */
};
/* returns 1 on error, 0 is fine */
@@ -80,8 +80,8 @@ struct connectbundle *Curl_conncache_find_bundle(struct connectdata *conn,
/* returns number of connections currently held in the connection cache */
size_t Curl_conncache_size(struct Curl_easy *data);
-bool Curl_conncache_return_conn(struct Curl_easy *data,
- struct connectdata *conn);
+bool Curl_conncache_return_conn(struct Curl_easy *data,
+ struct connectdata *conn);
CURLcode Curl_conncache_add_conn(struct conncache *connc,
struct connectdata *conn) WARN_UNUSED_RESULT;
void Curl_conncache_remove_conn(struct Curl_easy *data,
diff --git a/contrib/libs/curl/lib/connect.c b/contrib/libs/curl/lib/connect.c
index 413ac2c7cd..e65d24d9e9 100644
--- a/contrib/libs/curl/lib/connect.c
+++ b/contrib/libs/curl/lib/connect.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -74,7 +74,7 @@
#include "warnless.h"
#include "conncache.h"
#include "multihandle.h"
-#include "version_win32.h"
+#include "version_win32.h"
#include "quic.h"
#include "socks.h"
@@ -161,13 +161,13 @@ tcpkeepalive(struct Curl_easy *data,
static CURLcode
singleipconnect(struct connectdata *conn,
- const struct Curl_addrinfo *ai, /* start connecting to this */
- int tempindex); /* 0 or 1 among the temp ones */
+ const struct Curl_addrinfo *ai, /* start connecting to this */
+ int tempindex); /* 0 or 1 among the temp ones */
/*
* Curl_timeleft() returns the amount of milliseconds left allowed for the
- * transfer/connection. If the value is 0, there's no timeout (ie there's
- * infinite time left). If the value is negative, the timeout time has already
+ * transfer/connection. If the value is 0, there's no timeout (ie there's
+ * infinite time left). If the value is negative, the timeout time has already
* elapsed.
*
* The start time is stored in progress.t_startsingle - as set with
@@ -551,22 +551,22 @@ static bool verifyconnect(curl_socket_t sockfd, int *error)
return rc;
}
-/* update tempaddr[tempindex] (to the next entry), makes sure to stick
- to the correct family */
-static struct Curl_addrinfo *ainext(struct connectdata *conn,
- int tempindex,
- bool next) /* use next entry? */
-{
- struct Curl_addrinfo *ai = conn->tempaddr[tempindex];
- if(ai && next)
- ai = ai->ai_next;
- while(ai && (ai->ai_family != conn->tempfamily[tempindex]))
- ai = ai->ai_next;
- conn->tempaddr[tempindex] = ai;
- return ai;
-}
-
-/* Used within the multi interface. Try next IP address, returns error if no
+/* update tempaddr[tempindex] (to the next entry), makes sure to stick
+ to the correct family */
+static struct Curl_addrinfo *ainext(struct connectdata *conn,
+ int tempindex,
+ bool next) /* use next entry? */
+{
+ struct Curl_addrinfo *ai = conn->tempaddr[tempindex];
+ if(ai && next)
+ ai = ai->ai_next;
+ while(ai && (ai->ai_family != conn->tempfamily[tempindex]))
+ ai = ai->ai_next;
+ conn->tempaddr[tempindex] = ai;
+ return ai;
+}
+
+/* Used within the multi interface. Try next IP address, returns error if no
more address exists or error */
static CURLcode trynextip(struct connectdata *conn,
int sockindex,
@@ -582,13 +582,13 @@ static CURLcode trynextip(struct connectdata *conn,
conn->tempsock[tempindex] = CURL_SOCKET_BAD;
if(sockindex == FIRSTSOCKET) {
- struct Curl_addrinfo *ai = conn->tempaddr[tempindex];
+ struct Curl_addrinfo *ai = conn->tempaddr[tempindex];
while(ai) {
if(ai) {
result = singleipconnect(conn, ai, tempindex);
if(result == CURLE_COULDNT_CONNECT) {
- ai = ainext(conn, tempindex, TRUE);
+ ai = ainext(conn, tempindex, TRUE);
continue;
}
}
@@ -652,7 +652,7 @@ bool Curl_addr2string(struct sockaddr *sa, curl_socklen_t salen,
#endif
#if defined(HAVE_SYS_UN_H) && defined(AF_UNIX)
case AF_UNIX:
- if(salen > (curl_socklen_t)sizeof(sa_family_t)) {
+ if(salen > (curl_socklen_t)sizeof(sa_family_t)) {
su = (struct sockaddr_un*)sa;
msnprintf(addr, MAX_IPADR_LEN, "%s", su->sun_path);
}
@@ -673,155 +673,155 @@ bool Curl_addr2string(struct sockaddr *sa, curl_socklen_t salen,
/* retrieves the start/end point information of a socket of an established
connection */
-void Curl_conninfo_remote(struct connectdata *conn, curl_socket_t sockfd)
+void Curl_conninfo_remote(struct connectdata *conn, curl_socket_t sockfd)
{
-#ifdef HAVE_GETPEERNAME
- char buffer[STRERROR_LEN];
- struct Curl_sockaddr_storage ssrem;
- curl_socklen_t plen;
- plen = sizeof(struct Curl_sockaddr_storage);
- if(getpeername(sockfd, (struct sockaddr*) &ssrem, &plen)) {
- int error = SOCKERRNO;
- failf(conn->data, "getpeername() failed with errno %d: %s",
- error, Curl_strerror(error, buffer, sizeof(buffer)));
+#ifdef HAVE_GETPEERNAME
+ char buffer[STRERROR_LEN];
+ struct Curl_sockaddr_storage ssrem;
+ curl_socklen_t plen;
+ plen = sizeof(struct Curl_sockaddr_storage);
+ if(getpeername(sockfd, (struct sockaddr*) &ssrem, &plen)) {
+ int error = SOCKERRNO;
+ failf(conn->data, "getpeername() failed with errno %d: %s",
+ error, Curl_strerror(error, buffer, sizeof(buffer)));
return;
- }
- if(!Curl_addr2string((struct sockaddr*)&ssrem, plen,
- conn->primary_ip, &conn->primary_port)) {
- failf(conn->data, "ssrem inet_ntop() failed with errno %d: %s",
- errno, Curl_strerror(errno, buffer, sizeof(buffer)));
- return;
- }
- memcpy(conn->ip_addr_str, conn->primary_ip, MAX_IPADR_LEN);
-#else
- (void)conn;
- (void)sockfd;
-#endif
-}
-
-/* retrieves the start/end point information of a socket of an established
- connection */
-void Curl_conninfo_local(struct connectdata *conn, curl_socket_t sockfd)
-{
+ }
+ if(!Curl_addr2string((struct sockaddr*)&ssrem, plen,
+ conn->primary_ip, &conn->primary_port)) {
+ failf(conn->data, "ssrem inet_ntop() failed with errno %d: %s",
+ errno, Curl_strerror(errno, buffer, sizeof(buffer)));
+ return;
+ }
+ memcpy(conn->ip_addr_str, conn->primary_ip, MAX_IPADR_LEN);
+#else
+ (void)conn;
+ (void)sockfd;
+#endif
+}
+
+/* retrieves the start/end point information of a socket of an established
+ connection */
+void Curl_conninfo_local(struct connectdata *conn, curl_socket_t sockfd)
+{
#ifdef HAVE_GETSOCKNAME
- char buffer[STRERROR_LEN];
- struct Curl_sockaddr_storage ssloc;
- curl_socklen_t slen;
- slen = sizeof(struct Curl_sockaddr_storage);
- memset(&ssloc, 0, sizeof(ssloc));
- if(getsockname(sockfd, (struct sockaddr*) &ssloc, &slen)) {
- int error = SOCKERRNO;
- failf(conn->data, "getsockname() failed with errno %d: %s",
- error, Curl_strerror(error, buffer, sizeof(buffer)));
- return;
+ char buffer[STRERROR_LEN];
+ struct Curl_sockaddr_storage ssloc;
+ curl_socklen_t slen;
+ slen = sizeof(struct Curl_sockaddr_storage);
+ memset(&ssloc, 0, sizeof(ssloc));
+ if(getsockname(sockfd, (struct sockaddr*) &ssloc, &slen)) {
+ int error = SOCKERRNO;
+ failf(conn->data, "getsockname() failed with errno %d: %s",
+ error, Curl_strerror(error, buffer, sizeof(buffer)));
+ return;
}
- if(!Curl_addr2string((struct sockaddr*)&ssloc, slen,
- conn->local_ip, &conn->local_port)) {
- failf(conn->data, "ssloc inet_ntop() failed with errno %d: %s",
- errno, Curl_strerror(errno, buffer, sizeof(buffer)));
- return;
- }
-#else
- (void)conn;
- (void)sockfd;
+ if(!Curl_addr2string((struct sockaddr*)&ssloc, slen,
+ conn->local_ip, &conn->local_port)) {
+ failf(conn->data, "ssloc inet_ntop() failed with errno %d: %s",
+ errno, Curl_strerror(errno, buffer, sizeof(buffer)));
+ return;
+ }
+#else
+ (void)conn;
+ (void)sockfd;
#endif
-}
-
-/* retrieves the start/end point information of a socket of an established
- connection */
-void Curl_updateconninfo(struct connectdata *conn, curl_socket_t sockfd)
-{
- if(conn->transport == TRNSPRT_TCP) {
- if(!conn->bits.reuse && !conn->bits.tcp_fastopen) {
- Curl_conninfo_remote(conn, sockfd);
- Curl_conninfo_local(conn, sockfd);
- }
- } /* end of TCP-only section */
-
+}
+
+/* retrieves the start/end point information of a socket of an established
+ connection */
+void Curl_updateconninfo(struct connectdata *conn, curl_socket_t sockfd)
+{
+ if(conn->transport == TRNSPRT_TCP) {
+ if(!conn->bits.reuse && !conn->bits.tcp_fastopen) {
+ Curl_conninfo_remote(conn, sockfd);
+ Curl_conninfo_local(conn, sockfd);
+ }
+ } /* end of TCP-only section */
+
/* persist connection info in session handle */
Curl_persistconninfo(conn);
}
-/* After a TCP connection to the proxy has been verified, this function does
- the next magic steps. If 'done' isn't set TRUE, it is not done yet and
- must be called again.
+/* After a TCP connection to the proxy has been verified, this function does
+ the next magic steps. If 'done' isn't set TRUE, it is not done yet and
+ must be called again.
Note: this function's sub-functions call failf()
*/
-static CURLcode connect_SOCKS(struct connectdata *conn, int sockindex,
- bool *done)
+static CURLcode connect_SOCKS(struct connectdata *conn, int sockindex,
+ bool *done)
{
CURLcode result = CURLE_OK;
-#ifndef CURL_DISABLE_PROXY
- CURLproxycode pxresult = CURLPX_OK;
+#ifndef CURL_DISABLE_PROXY
+ CURLproxycode pxresult = CURLPX_OK;
if(conn->bits.socksproxy) {
/* for the secondary socket (FTP), use the "connect to host"
* but ignore the "connect to port" (use the secondary port)
*/
- const char * const host =
- conn->bits.httpproxy ?
- conn->http_proxy.host.name :
- conn->bits.conn_to_host ?
- conn->conn_to_host.name :
- sockindex == SECONDARYSOCKET ?
- conn->secondaryhostname : conn->host.name;
- const int port =
- conn->bits.httpproxy ? (int)conn->http_proxy.port :
- sockindex == SECONDARYSOCKET ? conn->secondary_port :
- conn->bits.conn_to_port ? conn->conn_to_port :
- conn->remote_port;
+ const char * const host =
+ conn->bits.httpproxy ?
+ conn->http_proxy.host.name :
+ conn->bits.conn_to_host ?
+ conn->conn_to_host.name :
+ sockindex == SECONDARYSOCKET ?
+ conn->secondaryhostname : conn->host.name;
+ const int port =
+ conn->bits.httpproxy ? (int)conn->http_proxy.port :
+ sockindex == SECONDARYSOCKET ? conn->secondary_port :
+ conn->bits.conn_to_port ? conn->conn_to_port :
+ conn->remote_port;
switch(conn->socks_proxy.proxytype) {
case CURLPROXY_SOCKS5:
case CURLPROXY_SOCKS5_HOSTNAME:
- pxresult = Curl_SOCKS5(conn->socks_proxy.user, conn->socks_proxy.passwd,
- host, port, sockindex, conn, done);
+ pxresult = Curl_SOCKS5(conn->socks_proxy.user, conn->socks_proxy.passwd,
+ host, port, sockindex, conn, done);
break;
case CURLPROXY_SOCKS4:
case CURLPROXY_SOCKS4A:
- pxresult = Curl_SOCKS4(conn->socks_proxy.user, host, port, sockindex,
- conn, done);
+ pxresult = Curl_SOCKS4(conn->socks_proxy.user, host, port, sockindex,
+ conn, done);
break;
default:
failf(conn->data, "unknown proxytype option given");
result = CURLE_COULDNT_CONNECT;
} /* switch proxytype */
- if(pxresult) {
- result = CURLE_PROXY;
- conn->data->info.pxcode = pxresult;
- }
- }
- else
+ if(pxresult) {
+ result = CURLE_PROXY;
+ conn->data->info.pxcode = pxresult;
+ }
+ }
+ else
#else
- (void)conn;
- (void)sockindex;
+ (void)conn;
+ (void)sockindex;
#endif /* CURL_DISABLE_PROXY */
- *done = TRUE; /* no SOCKS proxy, so consider us connected */
+ *done = TRUE; /* no SOCKS proxy, so consider us connected */
return result;
}
/*
- * post_SOCKS() is called after a successful connect to the peer, which
- * *could* be a SOCKS proxy
- */
-static void post_SOCKS(struct connectdata *conn,
- int sockindex,
- bool *connected)
-{
- conn->bits.tcpconnect[sockindex] = TRUE;
-
- *connected = TRUE;
- if(sockindex == FIRSTSOCKET)
- Curl_pgrsTime(conn->data, TIMER_CONNECT); /* connect done */
- Curl_updateconninfo(conn, conn->sock[sockindex]);
- Curl_verboseconnect(conn);
- conn->data->info.numconnects++; /* to track the number of connections made */
-}
-
-/*
+ * post_SOCKS() is called after a successful connect to the peer, which
+ * *could* be a SOCKS proxy
+ */
+static void post_SOCKS(struct connectdata *conn,
+ int sockindex,
+ bool *connected)
+{
+ conn->bits.tcpconnect[sockindex] = TRUE;
+
+ *connected = TRUE;
+ if(sockindex == FIRSTSOCKET)
+ Curl_pgrsTime(conn->data, TIMER_CONNECT); /* connect done */
+ Curl_updateconninfo(conn, conn->sock[sockindex]);
+ Curl_verboseconnect(conn);
+ conn->data->info.numconnects++; /* to track the number of connections made */
+}
+
+/*
* Curl_is_connected() checks if the socket has connected.
*/
@@ -834,8 +834,8 @@ CURLcode Curl_is_connected(struct connectdata *conn,
timediff_t allow;
int error = 0;
struct curltime now;
- int rc = 0;
- unsigned int i;
+ int rc = 0;
+ unsigned int i;
DEBUGASSERT(sockindex >= FIRSTSOCKET && sockindex <= SECONDARYSOCKET);
@@ -858,62 +858,62 @@ CURLcode Curl_is_connected(struct connectdata *conn,
return CURLE_OPERATION_TIMEDOUT;
}
- if(SOCKS_STATE(conn->cnnct.state)) {
- /* still doing SOCKS */
- result = connect_SOCKS(conn, sockindex, connected);
- if(!result && *connected)
- post_SOCKS(conn, sockindex, connected);
- return result;
- }
-
+ if(SOCKS_STATE(conn->cnnct.state)) {
+ /* still doing SOCKS */
+ result = connect_SOCKS(conn, sockindex, connected);
+ if(!result && *connected)
+ post_SOCKS(conn, sockindex, connected);
+ return result;
+ }
+
for(i = 0; i<2; i++) {
const int other = i ^ 1;
if(conn->tempsock[i] == CURL_SOCKET_BAD)
continue;
- error = 0;
+ error = 0;
#ifdef ENABLE_QUIC
if(conn->transport == TRNSPRT_QUIC) {
result = Curl_quic_is_connected(conn, i, connected);
- if(!result && *connected) {
+ if(!result && *connected) {
/* use this socket from now on */
conn->sock[sockindex] = conn->tempsock[i];
conn->ip_addr = conn->tempaddr[i];
conn->tempsock[i] = CURL_SOCKET_BAD;
- post_SOCKS(conn, sockindex, connected);
+ post_SOCKS(conn, sockindex, connected);
connkeep(conn, "HTTP/3 default");
- return CURLE_OK;
+ return CURLE_OK;
}
- if(result)
- error = SOCKERRNO;
+ if(result)
+ error = SOCKERRNO;
}
- else
+ else
#endif
- {
+ {
#ifdef mpeix
- /* Call this function once now, and ignore the results. We do this to
- "clear" the error state on the socket so that we can later read it
- reliably. This is reported necessary on the MPE/iX operating
- system. */
- (void)verifyconnect(conn->tempsock[i], NULL);
+ /* Call this function once now, and ignore the results. We do this to
+ "clear" the error state on the socket so that we can later read it
+ reliably. This is reported necessary on the MPE/iX operating
+ system. */
+ (void)verifyconnect(conn->tempsock[i], NULL);
#endif
- /* check socket for connect */
- rc = SOCKET_WRITABLE(conn->tempsock[i], 0);
- }
+ /* check socket for connect */
+ rc = SOCKET_WRITABLE(conn->tempsock[i], 0);
+ }
if(rc == 0) { /* no connection yet */
- if(Curl_timediff(now, conn->connecttime) >=
- conn->timeoutms_per_addr[i]) {
+ if(Curl_timediff(now, conn->connecttime) >=
+ conn->timeoutms_per_addr[i]) {
infof(data, "After %" CURL_FORMAT_TIMEDIFF_T
- "ms connect time, move on!\n", conn->timeoutms_per_addr[i]);
+ "ms connect time, move on!\n", conn->timeoutms_per_addr[i]);
error = ETIMEDOUT;
}
/* should we try another protocol family? */
- if(i == 0 && !conn->bits.parallel_connect &&
+ if(i == 0 && !conn->bits.parallel_connect &&
(Curl_timediff(now, conn->connecttime) >=
data->set.happy_eyeballs_timeout)) {
- conn->bits.parallel_connect = TRUE; /* starting now */
+ conn->bits.parallel_connect = TRUE; /* starting now */
trynextip(conn, sockindex, 1);
}
}
@@ -935,20 +935,20 @@ CURLcode Curl_is_connected(struct connectdata *conn,
conn->tempsock[other] = CURL_SOCKET_BAD;
}
- /* see if we need to kick off any SOCKS proxy magic once we
- connected */
- result = connect_SOCKS(conn, sockindex, connected);
- if(result || !*connected)
+ /* see if we need to kick off any SOCKS proxy magic once we
+ connected */
+ result = connect_SOCKS(conn, sockindex, connected);
+ if(result || !*connected)
return result;
- post_SOCKS(conn, sockindex, connected);
+ post_SOCKS(conn, sockindex, connected);
return CURLE_OK;
}
}
- else if(rc & CURL_CSELECT_ERR) {
+ else if(rc & CURL_CSELECT_ERR) {
(void)verifyconnect(conn->tempsock[i], &error);
- }
+ }
/*
* The connection failed here, we should attempt to connect to the "next
@@ -959,19 +959,19 @@ CURLcode Curl_is_connected(struct connectdata *conn,
SET_SOCKERRNO(error);
if(conn->tempaddr[i]) {
CURLcode status;
-#ifndef CURL_DISABLE_VERBOSE_STRINGS
+#ifndef CURL_DISABLE_VERBOSE_STRINGS
char ipaddress[MAX_IPADR_LEN];
char buffer[STRERROR_LEN];
- Curl_printable_address(conn->tempaddr[i], ipaddress,
- sizeof(ipaddress));
+ Curl_printable_address(conn->tempaddr[i], ipaddress,
+ sizeof(ipaddress));
infof(data, "connect to %s port %ld failed: %s\n",
ipaddress, conn->port,
Curl_strerror(error, buffer, sizeof(buffer)));
-#endif
+#endif
- conn->timeoutms_per_addr[i] = conn->tempaddr[i]->ai_next == NULL ?
+ conn->timeoutms_per_addr[i] = conn->tempaddr[i]->ai_next == NULL ?
allow : allow / 2;
- ainext(conn, i, TRUE);
+ ainext(conn, i, TRUE);
status = trynextip(conn, sockindex, i);
if((status != CURLE_COULDNT_CONNECT) ||
conn->tempsock[other] == CURL_SOCKET_BAD)
@@ -981,48 +981,48 @@ CURLcode Curl_is_connected(struct connectdata *conn,
}
}
- if(result &&
- (conn->tempsock[0] == CURL_SOCKET_BAD) &&
- (conn->tempsock[1] == CURL_SOCKET_BAD)) {
+ if(result &&
+ (conn->tempsock[0] == CURL_SOCKET_BAD) &&
+ (conn->tempsock[1] == CURL_SOCKET_BAD)) {
/* no more addresses to try */
const char *hostname;
char buffer[STRERROR_LEN];
- /* if the first address family runs out of addresses to try before the
- happy eyeball timeout, go ahead and try the next family now */
- result = trynextip(conn, sockindex, 1);
- if(!result)
- return result;
+ /* if the first address family runs out of addresses to try before the
+ happy eyeball timeout, go ahead and try the next family now */
+ result = trynextip(conn, sockindex, 1);
+ if(!result)
+ return result;
-#ifndef CURL_DISABLE_PROXY
+#ifndef CURL_DISABLE_PROXY
if(conn->bits.socksproxy)
hostname = conn->socks_proxy.host.name;
else if(conn->bits.httpproxy)
hostname = conn->http_proxy.host.name;
else
-#endif
- if(conn->bits.conn_to_host)
- hostname = conn->conn_to_host.name;
- else
+#endif
+ if(conn->bits.conn_to_host)
+ hostname = conn->conn_to_host.name;
+ else
hostname = conn->host.name;
failf(data, "Failed to connect to %s port %ld: %s",
hostname, conn->port,
Curl_strerror(error, buffer, sizeof(buffer)));
-
- Curl_quic_disconnect(conn, 0);
- Curl_quic_disconnect(conn, 1);
-
-#ifdef WSAETIMEDOUT
- if(WSAETIMEDOUT == data->state.os_errno)
- result = CURLE_OPERATION_TIMEDOUT;
-#elif defined(ETIMEDOUT)
- if(ETIMEDOUT == data->state.os_errno)
- result = CURLE_OPERATION_TIMEDOUT;
-#endif
+
+ Curl_quic_disconnect(conn, 0);
+ Curl_quic_disconnect(conn, 1);
+
+#ifdef WSAETIMEDOUT
+ if(WSAETIMEDOUT == data->state.os_errno)
+ result = CURLE_OPERATION_TIMEDOUT;
+#elif defined(ETIMEDOUT)
+ if(ETIMEDOUT == data->state.os_errno)
+ result = CURLE_OPERATION_TIMEDOUT;
+#endif
}
- else
- result = CURLE_OK; /* still trying */
+ else
+ result = CURLE_OK; /* still trying */
return result;
}
@@ -1030,12 +1030,12 @@ CURLcode Curl_is_connected(struct connectdata *conn,
static void tcpnodelay(struct connectdata *conn, curl_socket_t sockfd)
{
#if defined(TCP_NODELAY)
- curl_socklen_t onoff = (curl_socklen_t) 1;
- int level = IPPROTO_TCP;
+ curl_socklen_t onoff = (curl_socklen_t) 1;
+ int level = IPPROTO_TCP;
#if !defined(CURL_DISABLE_VERBOSE_STRINGS)
struct Curl_easy *data = conn->data;
char buffer[STRERROR_LEN];
-#else
+#else
(void) conn;
#endif
@@ -1096,8 +1096,8 @@ void Curl_sndbufset(curl_socket_t sockfd)
static int detectOsState = DETECT_OS_NONE;
if(detectOsState == DETECT_OS_NONE) {
- if(curlx_verify_windows_version(6, 0, PLATFORM_WINNT,
- VERSION_GREATER_THAN_EQUAL))
+ if(curlx_verify_windows_version(6, 0, PLATFORM_WINNT,
+ VERSION_GREATER_THAN_EQUAL))
detectOsState = DETECT_OS_VISTA_OR_LATER;
else
detectOsState = DETECT_OS_PREVISTA;
@@ -1124,8 +1124,8 @@ void Curl_sndbufset(curl_socket_t sockfd)
* having connected.
*/
static CURLcode singleipconnect(struct connectdata *conn,
- const struct Curl_addrinfo *ai,
- int tempindex)
+ const struct Curl_addrinfo *ai,
+ int tempindex)
{
struct Curl_sockaddr_ex addr;
int rc = -1;
@@ -1141,12 +1141,12 @@ static CURLcode singleipconnect(struct connectdata *conn,
int optval = 1;
#endif
char buffer[STRERROR_LEN];
- curl_socket_t *sockp = &conn->tempsock[tempindex];
+ curl_socket_t *sockp = &conn->tempsock[tempindex];
*sockp = CURL_SOCKET_BAD;
result = Curl_socket(conn, ai, &addr, &sockfd);
if(result)
- return result;
+ return result;
/* store remote address and port used in this connection attempt */
if(!Curl_addr2string((struct sockaddr*)&addr.sa_addr, addr.addrlen,
@@ -1214,10 +1214,10 @@ static CURLcode singleipconnect(struct connectdata *conn,
(void)curlx_nonblock(sockfd, TRUE);
conn->connecttime = Curl_now();
- if(conn->num_addr > 1) {
- Curl_expire(data, conn->timeoutms_per_addr[0], EXPIRE_DNS_PER_NAME);
- Curl_expire(data, conn->timeoutms_per_addr[1], EXPIRE_DNS_PER_NAME2);
- }
+ if(conn->num_addr > 1) {
+ Curl_expire(data, conn->timeoutms_per_addr[0], EXPIRE_DNS_PER_NAME);
+ Curl_expire(data, conn->timeoutms_per_addr[1], EXPIRE_DNS_PER_NAME2);
+ }
/* Connect TCP and QUIC sockets */
if(!isconnected && (conn->transport != TRNSPRT_UDP)) {
@@ -1268,7 +1268,7 @@ static CURLcode singleipconnect(struct connectdata *conn,
else if(conn->transport == TRNSPRT_QUIC) {
/* pass in 'sockfd' separately since it hasn't been put into the
tempsock array at this point */
- result = Curl_quic_connect(conn, sockfd, tempindex,
+ result = Curl_quic_connect(conn, sockfd, tempindex,
&addr.sa_addr, addr.addrlen);
if(result)
error = SOCKERRNO;
@@ -1325,8 +1325,8 @@ CURLcode Curl_connecthost(struct connectdata *conn, /* context */
{
struct Curl_easy *data = conn->data;
CURLcode result = CURLE_COULDNT_CONNECT;
- int i;
- timediff_t timeout_ms = Curl_timeleft(data, NULL, TRUE);
+ int i;
+ timediff_t timeout_ms = Curl_timeleft(data, NULL, TRUE);
if(timeout_ms < 0) {
/* a precaution, no need to continue if time already is up */
@@ -1335,39 +1335,39 @@ CURLcode Curl_connecthost(struct connectdata *conn, /* context */
}
conn->num_addr = Curl_num_addresses(remotehost->addr);
- conn->tempaddr[0] = conn->tempaddr[1] = remotehost->addr;
- conn->tempsock[0] = conn->tempsock[1] = CURL_SOCKET_BAD;
+ conn->tempaddr[0] = conn->tempaddr[1] = remotehost->addr;
+ conn->tempsock[0] = conn->tempsock[1] = CURL_SOCKET_BAD;
/* Max time for the next connection attempt */
- conn->timeoutms_per_addr[0] =
+ conn->timeoutms_per_addr[0] =
conn->tempaddr[0]->ai_next == NULL ? timeout_ms : timeout_ms / 2;
- conn->timeoutms_per_addr[1] =
- conn->tempaddr[1]->ai_next == NULL ? timeout_ms : timeout_ms / 2;
-
- conn->tempfamily[0] = conn->tempaddr[0]?
- conn->tempaddr[0]->ai_family:0;
-#ifdef ENABLE_IPV6
- conn->tempfamily[1] = conn->tempfamily[0] == AF_INET6 ?
- AF_INET : AF_INET6;
-#else
- conn->tempfamily[1] = AF_UNSPEC;
-#endif
- ainext(conn, 1, FALSE); /* assigns conn->tempaddr[1] accordingly */
-
- DEBUGF(infof(data, "family0 == %s, family1 == %s\n",
- conn->tempfamily[0] == AF_INET ? "v4" : "v6",
- conn->tempfamily[1] == AF_INET ? "v4" : "v6"));
-
- /* get through the list in family order in case of quick failures */
- for(i = 0; (i < 2) && result; i++) {
- while(conn->tempaddr[i]) {
- result = singleipconnect(conn, conn->tempaddr[i], i);
- if(!result)
- break;
- ainext(conn, i, TRUE);
- }
+ conn->timeoutms_per_addr[1] =
+ conn->tempaddr[1]->ai_next == NULL ? timeout_ms : timeout_ms / 2;
+
+ conn->tempfamily[0] = conn->tempaddr[0]?
+ conn->tempaddr[0]->ai_family:0;
+#ifdef ENABLE_IPV6
+ conn->tempfamily[1] = conn->tempfamily[0] == AF_INET6 ?
+ AF_INET : AF_INET6;
+#else
+ conn->tempfamily[1] = AF_UNSPEC;
+#endif
+ ainext(conn, 1, FALSE); /* assigns conn->tempaddr[1] accordingly */
+
+ DEBUGF(infof(data, "family0 == %s, family1 == %s\n",
+ conn->tempfamily[0] == AF_INET ? "v4" : "v6",
+ conn->tempfamily[1] == AF_INET ? "v4" : "v6"));
+
+ /* get through the list in family order in case of quick failures */
+ for(i = 0; (i < 2) && result; i++) {
+ while(conn->tempaddr[i]) {
+ result = singleipconnect(conn, conn->tempaddr[i], i);
+ if(!result)
+ break;
+ ainext(conn, i, TRUE);
+ }
}
- if(result)
+ if(result)
return result;
Curl_expire(conn->data, data->set.happy_eyeballs_timeout,
@@ -1377,15 +1377,15 @@ CURLcode Curl_connecthost(struct connectdata *conn, /* context */
}
struct connfind {
- long id_tofind;
- struct connectdata *found;
+ long id_tofind;
+ struct connectdata *found;
};
static int conn_is_conn(struct connectdata *conn, void *param)
{
struct connfind *f = (struct connfind *)param;
- if(conn->connection_id == f->id_tofind) {
- f->found = conn;
+ if(conn->connection_id == f->id_tofind) {
+ f->found = conn;
return 1;
}
return 0;
@@ -1407,22 +1407,22 @@ curl_socket_t Curl_getconnectinfo(struct Curl_easy *data,
* - that is associated with a multi handle, and whose connection
* was detached with CURLOPT_CONNECT_ONLY
*/
- if((data->state.lastconnect_id != -1) && (data->multi_easy || data->multi)) {
- struct connectdata *c;
+ if((data->state.lastconnect_id != -1) && (data->multi_easy || data->multi)) {
+ struct connectdata *c;
struct connfind find;
- find.id_tofind = data->state.lastconnect_id;
- find.found = NULL;
+ find.id_tofind = data->state.lastconnect_id;
+ find.found = NULL;
Curl_conncache_foreach(data, data->multi_easy?
&data->multi_easy->conn_cache:
&data->multi->conn_cache, &find, conn_is_conn);
if(!find.found) {
- data->state.lastconnect_id = -1;
+ data->state.lastconnect_id = -1;
return CURL_SOCKET_BAD;
}
- c = find.found;
+ c = find.found;
if(connp) {
/* only store this if the caller cares for it */
*connp = c;
@@ -1430,7 +1430,7 @@ curl_socket_t Curl_getconnectinfo(struct Curl_easy *data,
}
return c->sock[FIRSTSOCKET];
}
- return CURL_SOCKET_BAD;
+ return CURL_SOCKET_BAD;
}
/*
@@ -1469,11 +1469,11 @@ int Curl_closesocket(struct connectdata *conn,
curl_socket_t sock)
{
if(conn && conn->fclosesocket) {
- if((sock == conn->sock[SECONDARYSOCKET]) && conn->bits.sock_accepted)
+ if((sock == conn->sock[SECONDARYSOCKET]) && conn->bits.sock_accepted)
/* if this socket matches the second socket, and that was created with
accept, then we MUST NOT call the callback but clear the accepted
status */
- conn->bits.sock_accepted = FALSE;
+ conn->bits.sock_accepted = FALSE;
else {
int rc;
Curl_multi_closed(conn->data, sock);
@@ -1503,7 +1503,7 @@ int Curl_closesocket(struct connectdata *conn,
*
*/
CURLcode Curl_socket(struct connectdata *conn,
- const struct Curl_addrinfo *ai,
+ const struct Curl_addrinfo *ai,
struct Curl_sockaddr_ex *addr,
curl_socket_t *sockfd)
{
@@ -1556,11 +1556,11 @@ CURLcode Curl_socket(struct connectdata *conn,
/* no socket, no connection */
return CURLE_COULDNT_CONNECT;
- if(conn->transport == TRNSPRT_QUIC) {
- /* QUIC sockets need to be nonblocking */
- (void)curlx_nonblock(*sockfd, TRUE);
- }
-
+ if(conn->transport == TRNSPRT_QUIC) {
+ /* QUIC sockets need to be nonblocking */
+ (void)curlx_nonblock(*sockfd, TRUE);
+ }
+
#if defined(ENABLE_IPV6) && defined(HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID)
if(conn->scope_id && (addr->family == AF_INET6)) {
struct sockaddr_in6 * const sa6 = (void *)&addr->sa_addr;
@@ -1585,7 +1585,7 @@ void Curl_conncontrol(struct connectdata *conn,
/* close if a connection, or a stream that isn't multiplexed */
bool closeit = (ctrl == CONNCTRL_CONNECTION) ||
((ctrl == CONNCTRL_STREAM) && !(conn->handler->flags & PROTOPT_STREAM));
- DEBUGASSERT(conn);
+ DEBUGASSERT(conn);
if((ctrl == CONNCTRL_STREAM) &&
(conn->handler->flags & PROTOPT_STREAM))
DEBUGF(infof(conn->data, "Kill stream: %s\n", reason));
@@ -1601,7 +1601,7 @@ void Curl_conncontrol(struct connectdata *conn,
bool Curl_conn_data_pending(struct connectdata *conn, int sockindex)
{
int readable;
- DEBUGASSERT(conn);
+ DEBUGASSERT(conn);
if(Curl_ssl_data_pending(conn, sockindex) ||
Curl_recv_has_postponed_data(conn, sockindex))
diff --git a/contrib/libs/curl/lib/connect.h b/contrib/libs/curl/lib/connect.h
index d3bcf460b3..9b1faf8fb7 100644
--- a/contrib/libs/curl/lib/connect.h
+++ b/contrib/libs/curl/lib/connect.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -75,8 +75,8 @@ void Curl_sndbufset(curl_socket_t sockfd);
#endif
void Curl_updateconninfo(struct connectdata *conn, curl_socket_t sockfd);
-void Curl_conninfo_remote(struct connectdata *conn, curl_socket_t sockfd);
-void Curl_conninfo_local(struct connectdata *conn, curl_socket_t sockfd);
+void Curl_conninfo_remote(struct connectdata *conn, curl_socket_t sockfd);
+void Curl_conninfo_local(struct connectdata *conn, curl_socket_t sockfd);
void Curl_persistconninfo(struct connectdata *conn);
int Curl_closesocket(struct connectdata *conn, curl_socket_t sock);
@@ -107,7 +107,7 @@ struct Curl_sockaddr_ex {
*
*/
CURLcode Curl_socket(struct connectdata *conn,
- const struct Curl_addrinfo *ai,
+ const struct Curl_addrinfo *ai,
struct Curl_sockaddr_ex *addr,
curl_socket_t *sockfd);
diff --git a/contrib/libs/curl/lib/content_encoding.c b/contrib/libs/curl/lib/content_encoding.c
index 7550ce25a0..68da3fa1cf 100644
--- a/contrib/libs/curl/lib/content_encoding.c
+++ b/contrib/libs/curl/lib/content_encoding.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -34,10 +34,10 @@
#error #include <brotli/decode.h>
#endif
-#ifdef HAVE_ZSTD
-#error #include <zstd.h>
-#endif
-
+#ifdef HAVE_ZSTD
+#error #include <zstd.h>
+#endif
+
#include "sendf.h"
#include "http.h"
#include "content_encoding.h"
@@ -81,11 +81,11 @@ typedef enum {
} zlibInitState;
/* Writer parameters. */
-struct zlib_params {
+struct zlib_params {
zlibInitState zlib_init; /* zlib init state */
uInt trailerlen; /* Remaining trailer byte count. */
z_stream z; /* State structure for zlib. */
-};
+};
static voidpf
@@ -133,8 +133,8 @@ exit_zlib(struct connectdata *conn,
return result;
}
-static CURLcode process_trailer(struct connectdata *conn,
- struct zlib_params *zp)
+static CURLcode process_trailer(struct connectdata *conn,
+ struct zlib_params *zp)
{
z_stream *z = &zp->z;
CURLcode result = CURLE_OK;
@@ -158,10 +158,10 @@ static CURLcode process_trailer(struct connectdata *conn,
}
static CURLcode inflate_stream(struct connectdata *conn,
- struct contenc_writer *writer,
- zlibInitState started)
+ struct contenc_writer *writer,
+ zlibInitState started)
{
- struct zlib_params *zp = (struct zlib_params *) &writer->params;
+ struct zlib_params *zp = (struct zlib_params *) &writer->params;
z_stream *z = &zp->z; /* zlib state structure */
uInt nread = z->avail_in;
Bytef *orig_in = z->next_in;
@@ -261,9 +261,9 @@ static CURLcode inflate_stream(struct connectdata *conn,
/* Deflate handler. */
static CURLcode deflate_init_writer(struct connectdata *conn,
- struct contenc_writer *writer)
+ struct contenc_writer *writer)
{
- struct zlib_params *zp = (struct zlib_params *) &writer->params;
+ struct zlib_params *zp = (struct zlib_params *) &writer->params;
z_stream *z = &zp->z; /* zlib state structure */
if(!writer->downstream)
@@ -280,10 +280,10 @@ static CURLcode deflate_init_writer(struct connectdata *conn,
}
static CURLcode deflate_unencode_write(struct connectdata *conn,
- struct contenc_writer *writer,
+ struct contenc_writer *writer,
const char *buf, size_t nbytes)
{
- struct zlib_params *zp = (struct zlib_params *) &writer->params;
+ struct zlib_params *zp = (struct zlib_params *) &writer->params;
z_stream *z = &zp->z; /* zlib state structure */
/* Set the compressed input when this function is called */
@@ -298,29 +298,29 @@ static CURLcode deflate_unencode_write(struct connectdata *conn,
}
static void deflate_close_writer(struct connectdata *conn,
- struct contenc_writer *writer)
+ struct contenc_writer *writer)
{
- struct zlib_params *zp = (struct zlib_params *) &writer->params;
+ struct zlib_params *zp = (struct zlib_params *) &writer->params;
z_stream *z = &zp->z; /* zlib state structure */
exit_zlib(conn, z, &zp->zlib_init, CURLE_OK);
}
-static const struct content_encoding deflate_encoding = {
+static const struct content_encoding deflate_encoding = {
"deflate",
NULL,
deflate_init_writer,
deflate_unencode_write,
deflate_close_writer,
- sizeof(struct zlib_params)
+ sizeof(struct zlib_params)
};
/* Gzip handler. */
static CURLcode gzip_init_writer(struct connectdata *conn,
- struct contenc_writer *writer)
+ struct contenc_writer *writer)
{
- struct zlib_params *zp = (struct zlib_params *) &writer->params;
+ struct zlib_params *zp = (struct zlib_params *) &writer->params;
z_stream *z = &zp->z; /* zlib state structure */
if(!writer->downstream)
@@ -434,10 +434,10 @@ static enum {
#endif
static CURLcode gzip_unencode_write(struct connectdata *conn,
- struct contenc_writer *writer,
+ struct contenc_writer *writer,
const char *buf, size_t nbytes)
{
- struct zlib_params *zp = (struct zlib_params *) &writer->params;
+ struct zlib_params *zp = (struct zlib_params *) &writer->params;
z_stream *z = &zp->z; /* zlib state structure */
if(zp->zlib_init == ZLIB_INIT_GZIP) {
@@ -562,21 +562,21 @@ static CURLcode gzip_unencode_write(struct connectdata *conn,
}
static void gzip_close_writer(struct connectdata *conn,
- struct contenc_writer *writer)
+ struct contenc_writer *writer)
{
- struct zlib_params *zp = (struct zlib_params *) &writer->params;
+ struct zlib_params *zp = (struct zlib_params *) &writer->params;
z_stream *z = &zp->z; /* zlib state structure */
exit_zlib(conn, z, &zp->zlib_init, CURLE_OK);
}
-static const struct content_encoding gzip_encoding = {
+static const struct content_encoding gzip_encoding = {
"gzip",
"x-gzip",
gzip_init_writer,
gzip_unencode_write,
gzip_close_writer,
- sizeof(struct zlib_params)
+ sizeof(struct zlib_params)
};
#endif /* HAVE_LIBZ */
@@ -584,9 +584,9 @@ static const struct content_encoding gzip_encoding = {
#ifdef HAVE_BROTLI
/* Writer parameters. */
-struct brotli_params {
+struct brotli_params {
BrotliDecoderState *br; /* State structure for brotli. */
-};
+};
static CURLcode brotli_map_error(BrotliDecoderErrorCode be)
{
@@ -627,9 +627,9 @@ static CURLcode brotli_map_error(BrotliDecoderErrorCode be)
}
static CURLcode brotli_init_writer(struct connectdata *conn,
- struct contenc_writer *writer)
+ struct contenc_writer *writer)
{
- struct brotli_params *bp = (struct brotli_params *) &writer->params;
+ struct brotli_params *bp = (struct brotli_params *) &writer->params;
(void) conn;
if(!writer->downstream)
@@ -640,10 +640,10 @@ static CURLcode brotli_init_writer(struct connectdata *conn,
}
static CURLcode brotli_unencode_write(struct connectdata *conn,
- struct contenc_writer *writer,
+ struct contenc_writer *writer,
const char *buf, size_t nbytes)
{
- struct brotli_params *bp = (struct brotli_params *) &writer->params;
+ struct brotli_params *bp = (struct brotli_params *) &writer->params;
const uint8_t *src = (const uint8_t *) buf;
char *decomp;
uint8_t *dst;
@@ -688,9 +688,9 @@ static CURLcode brotli_unencode_write(struct connectdata *conn,
}
static void brotli_close_writer(struct connectdata *conn,
- struct contenc_writer *writer)
+ struct contenc_writer *writer)
{
- struct brotli_params *bp = (struct brotli_params *) &writer->params;
+ struct brotli_params *bp = (struct brotli_params *) &writer->params;
(void) conn;
if(bp->br) {
@@ -699,129 +699,129 @@ static void brotli_close_writer(struct connectdata *conn,
}
}
-static const struct content_encoding brotli_encoding = {
+static const struct content_encoding brotli_encoding = {
"br",
NULL,
brotli_init_writer,
brotli_unencode_write,
brotli_close_writer,
- sizeof(struct brotli_params)
+ sizeof(struct brotli_params)
+};
+#endif
+
+
+#ifdef HAVE_ZSTD
+/* Writer parameters. */
+struct zstd_params {
+ ZSTD_DStream *zds; /* State structure for zstd. */
+ void *decomp;
+};
+
+static CURLcode zstd_init_writer(struct connectdata *conn,
+ struct contenc_writer *writer)
+{
+ struct zstd_params *zp = (struct zstd_params *)&writer->params;
+ (void)conn;
+
+ if(!writer->downstream)
+ return CURLE_WRITE_ERROR;
+
+ zp->zds = ZSTD_createDStream();
+ zp->decomp = NULL;
+ return zp->zds ? CURLE_OK : CURLE_OUT_OF_MEMORY;
+}
+
+static CURLcode zstd_unencode_write(struct connectdata *conn,
+ struct contenc_writer *writer,
+ const char *buf, size_t nbytes)
+{
+ CURLcode result = CURLE_OK;
+ struct zstd_params *zp = (struct zstd_params *)&writer->params;
+ ZSTD_inBuffer in;
+ ZSTD_outBuffer out;
+ size_t errorCode;
+
+ if(!zp->decomp) {
+ zp->decomp = malloc(DSIZ);
+ if(!zp->decomp)
+ return CURLE_OUT_OF_MEMORY;
+ }
+ in.pos = 0;
+ in.src = buf;
+ in.size = nbytes;
+
+ for(;;) {
+ out.pos = 0;
+ out.dst = zp->decomp;
+ out.size = DSIZ;
+
+ errorCode = ZSTD_decompressStream(zp->zds, &out, &in);
+ if(ZSTD_isError(errorCode)) {
+ return CURLE_BAD_CONTENT_ENCODING;
+ }
+ if(out.pos > 0) {
+ result = Curl_unencode_write(conn, writer->downstream,
+ zp->decomp, out.pos);
+ if(result)
+ break;
+ }
+ if((in.pos == nbytes) && (out.pos < out.size))
+ break;
+ }
+
+ return result;
+}
+
+static void zstd_close_writer(struct connectdata *conn,
+ struct contenc_writer *writer)
+{
+ struct zstd_params *zp = (struct zstd_params *)&writer->params;
+ (void)conn;
+
+ if(zp->decomp) {
+ free(zp->decomp);
+ zp->decomp = NULL;
+ }
+ if(zp->zds) {
+ ZSTD_freeDStream(zp->zds);
+ zp->zds = NULL;
+ }
+}
+
+static const struct content_encoding zstd_encoding = {
+ "zstd",
+ NULL,
+ zstd_init_writer,
+ zstd_unencode_write,
+ zstd_close_writer,
+ sizeof(struct zstd_params)
};
#endif
-#ifdef HAVE_ZSTD
-/* Writer parameters. */
-struct zstd_params {
- ZSTD_DStream *zds; /* State structure for zstd. */
- void *decomp;
-};
-
-static CURLcode zstd_init_writer(struct connectdata *conn,
- struct contenc_writer *writer)
-{
- struct zstd_params *zp = (struct zstd_params *)&writer->params;
- (void)conn;
-
- if(!writer->downstream)
- return CURLE_WRITE_ERROR;
-
- zp->zds = ZSTD_createDStream();
- zp->decomp = NULL;
- return zp->zds ? CURLE_OK : CURLE_OUT_OF_MEMORY;
-}
-
-static CURLcode zstd_unencode_write(struct connectdata *conn,
- struct contenc_writer *writer,
- const char *buf, size_t nbytes)
-{
- CURLcode result = CURLE_OK;
- struct zstd_params *zp = (struct zstd_params *)&writer->params;
- ZSTD_inBuffer in;
- ZSTD_outBuffer out;
- size_t errorCode;
-
- if(!zp->decomp) {
- zp->decomp = malloc(DSIZ);
- if(!zp->decomp)
- return CURLE_OUT_OF_MEMORY;
- }
- in.pos = 0;
- in.src = buf;
- in.size = nbytes;
-
- for(;;) {
- out.pos = 0;
- out.dst = zp->decomp;
- out.size = DSIZ;
-
- errorCode = ZSTD_decompressStream(zp->zds, &out, &in);
- if(ZSTD_isError(errorCode)) {
- return CURLE_BAD_CONTENT_ENCODING;
- }
- if(out.pos > 0) {
- result = Curl_unencode_write(conn, writer->downstream,
- zp->decomp, out.pos);
- if(result)
- break;
- }
- if((in.pos == nbytes) && (out.pos < out.size))
- break;
- }
-
- return result;
-}
-
-static void zstd_close_writer(struct connectdata *conn,
- struct contenc_writer *writer)
-{
- struct zstd_params *zp = (struct zstd_params *)&writer->params;
- (void)conn;
-
- if(zp->decomp) {
- free(zp->decomp);
- zp->decomp = NULL;
- }
- if(zp->zds) {
- ZSTD_freeDStream(zp->zds);
- zp->zds = NULL;
- }
-}
-
-static const struct content_encoding zstd_encoding = {
- "zstd",
- NULL,
- zstd_init_writer,
- zstd_unencode_write,
- zstd_close_writer,
- sizeof(struct zstd_params)
-};
-#endif
-
-
/* Identity handler. */
static CURLcode identity_init_writer(struct connectdata *conn,
- struct contenc_writer *writer)
+ struct contenc_writer *writer)
{
(void) conn;
return writer->downstream? CURLE_OK: CURLE_WRITE_ERROR;
}
static CURLcode identity_unencode_write(struct connectdata *conn,
- struct contenc_writer *writer,
+ struct contenc_writer *writer,
const char *buf, size_t nbytes)
{
return Curl_unencode_write(conn, writer->downstream, buf, nbytes);
}
static void identity_close_writer(struct connectdata *conn,
- struct contenc_writer *writer)
+ struct contenc_writer *writer)
{
(void) conn;
(void) writer;
}
-static const struct content_encoding identity_encoding = {
+static const struct content_encoding identity_encoding = {
"identity",
"none",
identity_init_writer,
@@ -832,7 +832,7 @@ static const struct content_encoding identity_encoding = {
/* supported content encodings table. */
-static const struct content_encoding * const encodings[] = {
+static const struct content_encoding * const encodings[] = {
&identity_encoding,
#ifdef HAVE_LIBZ
&deflate_encoding,
@@ -841,9 +841,9 @@ static const struct content_encoding * const encodings[] = {
#ifdef HAVE_BROTLI
&brotli_encoding,
#endif
-#ifdef HAVE_ZSTD
- &zstd_encoding,
-#endif
+#ifdef HAVE_ZSTD
+ &zstd_encoding,
+#endif
NULL
};
@@ -852,8 +852,8 @@ static const struct content_encoding * const encodings[] = {
char *Curl_all_content_encodings(void)
{
size_t len = 0;
- const struct content_encoding * const *cep;
- const struct content_encoding *ce;
+ const struct content_encoding * const *cep;
+ const struct content_encoding *ce;
char *ace;
for(cep = encodings; *cep; cep++) {
@@ -886,14 +886,14 @@ char *Curl_all_content_encodings(void)
/* Real client writer: no downstream. */
static CURLcode client_init_writer(struct connectdata *conn,
- struct contenc_writer *writer)
+ struct contenc_writer *writer)
{
(void) conn;
return writer->downstream? CURLE_WRITE_ERROR: CURLE_OK;
}
static CURLcode client_unencode_write(struct connectdata *conn,
- struct contenc_writer *writer,
+ struct contenc_writer *writer,
const char *buf, size_t nbytes)
{
struct Curl_easy *data = conn->data;
@@ -908,13 +908,13 @@ static CURLcode client_unencode_write(struct connectdata *conn,
}
static void client_close_writer(struct connectdata *conn,
- struct contenc_writer *writer)
+ struct contenc_writer *writer)
{
(void) conn;
(void) writer;
}
-static const struct content_encoding client_encoding = {
+static const struct content_encoding client_encoding = {
NULL,
NULL,
client_init_writer,
@@ -926,14 +926,14 @@ static const struct content_encoding client_encoding = {
/* Deferred error dummy writer. */
static CURLcode error_init_writer(struct connectdata *conn,
- struct contenc_writer *writer)
+ struct contenc_writer *writer)
{
(void) conn;
return writer->downstream? CURLE_OK: CURLE_WRITE_ERROR;
}
static CURLcode error_unencode_write(struct connectdata *conn,
- struct contenc_writer *writer,
+ struct contenc_writer *writer,
const char *buf, size_t nbytes)
{
char *all = Curl_all_content_encodings();
@@ -951,13 +951,13 @@ static CURLcode error_unencode_write(struct connectdata *conn,
}
static void error_close_writer(struct connectdata *conn,
- struct contenc_writer *writer)
+ struct contenc_writer *writer)
{
(void) conn;
(void) writer;
}
-static const struct content_encoding error_encoding = {
+static const struct content_encoding error_encoding = {
NULL,
NULL,
error_init_writer,
@@ -967,13 +967,13 @@ static const struct content_encoding error_encoding = {
};
/* Create an unencoding writer stage using the given handler. */
-static struct contenc_writer *
-new_unencoding_writer(struct connectdata *conn,
- const struct content_encoding *handler,
- struct contenc_writer *downstream)
+static struct contenc_writer *
+new_unencoding_writer(struct connectdata *conn,
+ const struct content_encoding *handler,
+ struct contenc_writer *downstream)
{
- size_t sz = offsetof(struct contenc_writer, params) + handler->paramsize;
- struct contenc_writer *writer = (struct contenc_writer *)calloc(1, sz);
+ size_t sz = offsetof(struct contenc_writer, params) + handler->paramsize;
+ struct contenc_writer *writer = (struct contenc_writer *)calloc(1, sz);
if(writer) {
writer->handler = handler;
@@ -988,8 +988,8 @@ new_unencoding_writer(struct connectdata *conn,
}
/* Write data using an unencoding writer stack. */
-CURLcode Curl_unencode_write(struct connectdata *conn,
- struct contenc_writer *writer,
+CURLcode Curl_unencode_write(struct connectdata *conn,
+ struct contenc_writer *writer,
const char *buf, size_t nbytes)
{
if(!nbytes)
@@ -1002,7 +1002,7 @@ void Curl_unencode_cleanup(struct connectdata *conn)
{
struct Curl_easy *data = conn->data;
struct SingleRequest *k = &data->req;
- struct contenc_writer *writer = k->writer_stack;
+ struct contenc_writer *writer = k->writer_stack;
while(writer) {
k->writer_stack = writer->downstream;
@@ -1013,13 +1013,13 @@ void Curl_unencode_cleanup(struct connectdata *conn)
}
/* Find the content encoding by name. */
-static const struct content_encoding *find_encoding(const char *name,
- size_t len)
+static const struct content_encoding *find_encoding(const char *name,
+ size_t len)
{
- const struct content_encoding * const *cep;
+ const struct content_encoding * const *cep;
for(cep = encodings; *cep; cep++) {
- const struct content_encoding *ce = *cep;
+ const struct content_encoding *ce = *cep;
if((strncasecompare(name, ce->name, len) && !ce->name[len]) ||
(ce->alias && strncasecompare(name, ce->alias, len) && !ce->alias[len]))
return ce;
@@ -1055,8 +1055,8 @@ CURLcode Curl_build_unencoding_stack(struct connectdata *conn,
Curl_httpchunk_init(conn); /* init our chunky engine. */
}
else if(namelen) {
- const struct content_encoding *encoding = find_encoding(name, namelen);
- struct contenc_writer *writer;
+ const struct content_encoding *encoding = find_encoding(name, namelen);
+ struct contenc_writer *writer;
if(!k->writer_stack) {
k->writer_stack = new_unencoding_writer(conn, &client_encoding, NULL);
@@ -1090,8 +1090,8 @@ CURLcode Curl_build_unencoding_stack(struct connectdata *conn,
return CURLE_NOT_BUILT_IN;
}
-CURLcode Curl_unencode_write(struct connectdata *conn,
- struct contenc_writer *writer,
+CURLcode Curl_unencode_write(struct connectdata *conn,
+ struct contenc_writer *writer,
const char *buf, size_t nbytes)
{
(void) conn;
diff --git a/contrib/libs/curl/lib/content_encoding.h b/contrib/libs/curl/lib/content_encoding.h
index b91c028902..70310875a0 100644
--- a/contrib/libs/curl/lib/content_encoding.h
+++ b/contrib/libs/curl/lib/content_encoding.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -23,31 +23,31 @@
***************************************************************************/
#include "curl_setup.h"
-struct contenc_writer {
- const struct content_encoding *handler; /* Encoding handler. */
- struct contenc_writer *downstream; /* Downstream writer. */
+struct contenc_writer {
+ const struct content_encoding *handler; /* Encoding handler. */
+ struct contenc_writer *downstream; /* Downstream writer. */
void *params; /* Encoding-specific storage (variable length). */
};
/* Content encoding writer. */
-struct content_encoding {
+struct content_encoding {
const char *name; /* Encoding name. */
const char *alias; /* Encoding name alias. */
- CURLcode (*init_writer)(struct connectdata *conn,
- struct contenc_writer *writer);
- CURLcode (*unencode_write)(struct connectdata *conn,
- struct contenc_writer *writer,
+ CURLcode (*init_writer)(struct connectdata *conn,
+ struct contenc_writer *writer);
+ CURLcode (*unencode_write)(struct connectdata *conn,
+ struct contenc_writer *writer,
const char *buf, size_t nbytes);
- void (*close_writer)(struct connectdata *conn,
- struct contenc_writer *writer);
+ void (*close_writer)(struct connectdata *conn,
+ struct contenc_writer *writer);
size_t paramsize;
};
CURLcode Curl_build_unencoding_stack(struct connectdata *conn,
const char *enclist, int maybechunked);
-CURLcode Curl_unencode_write(struct connectdata *conn,
- struct contenc_writer *writer,
+CURLcode Curl_unencode_write(struct connectdata *conn,
+ struct contenc_writer *writer,
const char *buf, size_t nbytes);
void Curl_unencode_cleanup(struct connectdata *conn);
char *Curl_all_content_encodings(void);
diff --git a/contrib/libs/curl/lib/cookie.c b/contrib/libs/curl/lib/cookie.c
index c74b6430b4..e88678c219 100644
--- a/contrib/libs/curl/lib/cookie.c
+++ b/contrib/libs/curl/lib/cookie.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -96,9 +96,9 @@ Example set of cookies:
#include "curl_get_line.h"
#include "curl_memrchr.h"
#include "inet_pton.h"
-#include "parsedate.h"
-#include "rand.h"
-#include "rename.h"
+#include "parsedate.h"
+#include "rand.h"
+#include "rename.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
@@ -245,17 +245,17 @@ pathmatched:
*/
static const char *get_top_domain(const char * const domain, size_t *outlen)
{
- size_t len = 0;
+ size_t len = 0;
const char *first = NULL, *last;
- if(domain) {
- len = strlen(domain);
- last = memrchr(domain, '.', len);
- if(last) {
- first = memrchr(domain, '.', (last - domain));
- if(first)
- len -= (++first - domain);
- }
+ if(domain) {
+ len = strlen(domain);
+ last = memrchr(domain, '.', len);
+ if(last) {
+ first = memrchr(domain, '.', (last - domain));
+ if(first)
+ len -= (++first - domain);
+ }
}
if(outlen)
@@ -538,9 +538,9 @@ Curl_cookie_add(struct Curl_easy *data,
* only test for names where that can possibly be true.
*/
if(nlen > 3 && name[0] == '_' && name[1] == '_') {
- if(!strncmp("__Secure-", name, 9))
+ if(!strncmp("__Secure-", name, 9))
co->prefix |= COOKIE_PREFIX__SECURE;
- else if(!strncmp("__Host-", name, 7))
+ else if(!strncmp("__Host-", name, 7))
co->prefix |= COOKIE_PREFIX__HOST;
}
@@ -717,7 +717,7 @@ Curl_cookie_add(struct Curl_easy *data,
else if(co->expirestr) {
/* Note that if the date couldn't get parsed for whatever reason,
the cookie will be treated as a session cookie */
- co->expires = Curl_getdate_capped(co->expirestr);
+ co->expires = Curl_getdate_capped(co->expirestr);
/* Session cookies have expires set to 0 so if we get that back
from the date parser let's add a second to make it a
@@ -755,7 +755,7 @@ Curl_cookie_add(struct Curl_easy *data,
co->path = malloc(pathlen + 1); /* one extra for the zero byte */
if(co->path) {
memcpy(co->path, path, pathlen);
- co->path[pathlen] = 0; /* null-terminate */
+ co->path[pathlen] = 0; /* null-terminate */
co->spath = sanitize_cookie_path(co->path);
if(!co->spath)
badcookie = TRUE; /* out of memory bad */
@@ -1047,7 +1047,7 @@ Curl_cookie_add(struct Curl_easy *data,
*clist = *co; /* then store all the new data */
- free(co); /* free the newly allocated memory */
+ free(co); /* free the newly allocated memory */
co = clist; /* point to the previous struct instead */
/* We have replaced a cookie, now skip the rest of the list but
@@ -1092,8 +1092,8 @@ Curl_cookie_add(struct Curl_easy *data,
*
* If 'newsession' is TRUE, discard all "session cookies" on read from file.
*
- * Note that 'data' might be called as NULL pointer.
- *
+ * Note that 'data' might be called as NULL pointer.
+ *
* Returns NULL on out of memory. Invalid cookies are ignored.
****************************************************************************/
struct CookieInfo *Curl_cookie_init(struct Curl_easy *data,
@@ -1164,8 +1164,8 @@ struct CookieInfo *Curl_cookie_init(struct Curl_easy *data,
}
c->running = TRUE; /* now, we're running */
- if(data)
- data->state.cookie_engine = TRUE;
+ if(data)
+ data->state.cookie_engine = TRUE;
return c;
@@ -1502,14 +1502,14 @@ static char *get_netscape_format(const struct Cookie *co)
*
* The function returns non-zero on write failure.
*/
-static int cookie_output(struct Curl_easy *data,
- struct CookieInfo *c, const char *filename)
+static int cookie_output(struct Curl_easy *data,
+ struct CookieInfo *c, const char *filename)
{
struct Cookie *co;
- FILE *out = NULL;
+ FILE *out = NULL;
bool use_stdout = FALSE;
- char *tempstore = NULL;
- bool error = false;
+ char *tempstore = NULL;
+ bool error = false;
if(!c)
/* no cookie engine alive */
@@ -1518,58 +1518,58 @@ static int cookie_output(struct Curl_easy *data,
/* at first, remove expired cookies */
remove_expired(c);
- if(!strcmp("-", filename)) {
+ if(!strcmp("-", filename)) {
/* use stdout */
out = stdout;
use_stdout = TRUE;
}
else {
- unsigned char randsuffix[9];
-
- if(Curl_rand_hex(data, randsuffix, sizeof(randsuffix)))
- return 2;
-
- tempstore = aprintf("%s.%s.tmp", filename, randsuffix);
- if(!tempstore)
- return 1;
-
- out = fopen(tempstore, FOPEN_WRITETEXT);
- if(!out)
- goto error;
+ unsigned char randsuffix[9];
+
+ if(Curl_rand_hex(data, randsuffix, sizeof(randsuffix)))
+ return 2;
+
+ tempstore = aprintf("%s.%s.tmp", filename, randsuffix);
+ if(!tempstore)
+ return 1;
+
+ out = fopen(tempstore, FOPEN_WRITETEXT);
+ if(!out)
+ goto error;
}
fputs("# Netscape HTTP Cookie File\n"
- "# https://curl.se/docs/http-cookies.html\n"
+ "# https://curl.se/docs/http-cookies.html\n"
"# This file was generated by libcurl! Edit at your own risk.\n\n",
out);
if(c->numcookies) {
unsigned int i;
- size_t nvalid = 0;
+ size_t nvalid = 0;
struct Cookie **array;
- array = calloc(1, sizeof(struct Cookie *) * c->numcookies);
+ array = calloc(1, sizeof(struct Cookie *) * c->numcookies);
if(!array) {
- goto error;
+ goto error;
}
- /* only sort the cookies with a domain property */
+ /* only sort the cookies with a domain property */
for(i = 0; i < COOKIE_HASH_SIZE; i++) {
for(co = c->cookies[i]; co; co = co->next) {
if(!co->domain)
continue;
- array[nvalid++] = co;
+ array[nvalid++] = co;
}
}
- qsort(array, nvalid, sizeof(struct Cookie *), cookie_sort_ct);
+ qsort(array, nvalid, sizeof(struct Cookie *), cookie_sort_ct);
- for(i = 0; i < nvalid; i++) {
+ for(i = 0; i < nvalid; i++) {
char *format_ptr = get_netscape_format(array[i]);
if(format_ptr == NULL) {
fprintf(out, "#\n# Fatal libcurl error\n");
free(array);
- goto error;
+ goto error;
}
fprintf(out, "%s\n", format_ptr);
free(format_ptr);
@@ -1577,24 +1577,24 @@ static int cookie_output(struct Curl_easy *data,
free(array);
}
-
- if(!use_stdout) {
+
+ if(!use_stdout) {
+ fclose(out);
+ out = NULL;
+ if(Curl_rename(tempstore, filename)) {
+ unlink(tempstore);
+ goto error;
+ }
+ }
+
+ goto cleanup;
+error:
+ error = true;
+cleanup:
+ if(out && !use_stdout)
fclose(out);
- out = NULL;
- if(Curl_rename(tempstore, filename)) {
- unlink(tempstore);
- goto error;
- }
- }
-
- goto cleanup;
-error:
- error = true;
-cleanup:
- if(out && !use_stdout)
- fclose(out);
- free(tempstore);
- return error ? 1 : 0;
+ free(tempstore);
+ return error ? 1 : 0;
}
static struct curl_slist *cookie_list(struct Curl_easy *data)
@@ -1640,7 +1640,7 @@ struct curl_slist *Curl_cookie_list(struct Curl_easy *data)
return list;
}
-void Curl_flush_cookies(struct Curl_easy *data, bool cleanup)
+void Curl_flush_cookies(struct Curl_easy *data, bool cleanup)
{
if(data->set.str[STRING_COOKIEJAR]) {
if(data->change.cookielist) {
@@ -1653,7 +1653,7 @@ void Curl_flush_cookies(struct Curl_easy *data, bool cleanup)
Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE);
/* if we have a destination file for all the cookies to get dumped to */
- if(cookie_output(data, data->cookies, data->set.str[STRING_COOKIEJAR]))
+ if(cookie_output(data, data->cookies, data->set.str[STRING_COOKIEJAR]))
infof(data, "WARNING: failed to save cookies in %s\n",
data->set.str[STRING_COOKIEJAR]);
}
@@ -1669,7 +1669,7 @@ void Curl_flush_cookies(struct Curl_easy *data, bool cleanup)
if(cleanup && (!data->share || (data->cookies != data->share->cookies))) {
Curl_cookie_cleanup(data->cookies);
- data->cookies = NULL;
+ data->cookies = NULL;
}
Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE);
}
diff --git a/contrib/libs/curl/lib/cookie.h b/contrib/libs/curl/lib/cookie.h
index 88da182baa..066396f0d5 100644
--- a/contrib/libs/curl/lib/cookie.h
+++ b/contrib/libs/curl/lib/cookie.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -109,7 +109,7 @@ void Curl_cookie_clearsess(struct CookieInfo *cookies);
#define Curl_cookie_cleanup(x) Curl_nop_stmt
#define Curl_flush_cookies(x,y) Curl_nop_stmt
#else
-void Curl_flush_cookies(struct Curl_easy *data, bool cleanup);
+void Curl_flush_cookies(struct Curl_easy *data, bool cleanup);
void Curl_cookie_cleanup(struct CookieInfo *);
struct CookieInfo *Curl_cookie_init(struct Curl_easy *data,
const char *, struct CookieInfo *, bool);
diff --git a/contrib/libs/curl/lib/curl_addrinfo.c b/contrib/libs/curl/lib/curl_addrinfo.c
index 4ff14a1dc6..9007259d4c 100644
--- a/contrib/libs/curl/lib/curl_addrinfo.c
+++ b/contrib/libs/curl/lib/curl_addrinfo.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -78,12 +78,12 @@
#endif
void
-Curl_freeaddrinfo(struct Curl_addrinfo *cahead)
+Curl_freeaddrinfo(struct Curl_addrinfo *cahead)
{
- struct Curl_addrinfo *vqualifier canext;
- struct Curl_addrinfo *ca;
+ struct Curl_addrinfo *vqualifier canext;
+ struct Curl_addrinfo *ca;
- for(ca = cahead; ca; ca = canext) {
+ for(ca = cahead; ca; ca = canext) {
canext = ca->ai_next;
free(ca);
}
@@ -109,13 +109,13 @@ int
Curl_getaddrinfo_ex(const char *nodename,
const char *servname,
const struct addrinfo *hints,
- struct Curl_addrinfo **result)
+ struct Curl_addrinfo **result)
{
const struct addrinfo *ai;
struct addrinfo *aihead;
- struct Curl_addrinfo *cafirst = NULL;
- struct Curl_addrinfo *calast = NULL;
- struct Curl_addrinfo *ca;
+ struct Curl_addrinfo *cafirst = NULL;
+ struct Curl_addrinfo *calast = NULL;
+ struct Curl_addrinfo *ca;
size_t ss_size;
int error;
@@ -128,7 +128,7 @@ Curl_getaddrinfo_ex(const char *nodename,
/* traverse the addrinfo list */
for(ai = aihead; ai != NULL; ai = ai->ai_next) {
- size_t namelen = ai->ai_canonname ? strlen(ai->ai_canonname) + 1 : 0;
+ size_t namelen = ai->ai_canonname ? strlen(ai->ai_canonname) + 1 : 0;
/* ignore elements with unsupported address family, */
/* settle family-specific sockaddr structure size. */
if(ai->ai_family == AF_INET)
@@ -148,7 +148,7 @@ Curl_getaddrinfo_ex(const char *nodename,
if((size_t)ai->ai_addrlen < ss_size)
continue;
- ca = malloc(sizeof(struct Curl_addrinfo) + ss_size + namelen);
+ ca = malloc(sizeof(struct Curl_addrinfo) + ss_size + namelen);
if(!ca) {
error = EAI_MEMORY;
break;
@@ -166,12 +166,12 @@ Curl_getaddrinfo_ex(const char *nodename,
ca->ai_canonname = NULL;
ca->ai_next = NULL;
- ca->ai_addr = (void *)((char *)ca + sizeof(struct Curl_addrinfo));
+ ca->ai_addr = (void *)((char *)ca + sizeof(struct Curl_addrinfo));
memcpy(ca->ai_addr, ai->ai_addr, ss_size);
- if(namelen) {
- ca->ai_canonname = (void *)((char *)ca->ai_addr + ss_size);
- memcpy(ca->ai_canonname, ai->ai_canonname, namelen);
+ if(namelen) {
+ ca->ai_canonname = (void *)((char *)ca->ai_addr + ss_size);
+ memcpy(ca->ai_canonname, ai->ai_canonname, namelen);
}
/* if the return list is empty, this becomes the first element */
@@ -255,12 +255,12 @@ Curl_getaddrinfo_ex(const char *nodename,
* #define h_addr h_addr_list[0]
*/
-struct Curl_addrinfo *
+struct Curl_addrinfo *
Curl_he2ai(const struct hostent *he, int port)
{
- struct Curl_addrinfo *ai;
- struct Curl_addrinfo *prevai = NULL;
- struct Curl_addrinfo *firstai = NULL;
+ struct Curl_addrinfo *ai;
+ struct Curl_addrinfo *prevai = NULL;
+ struct Curl_addrinfo *firstai = NULL;
struct sockaddr_in *addr;
#ifdef ENABLE_IPV6
struct sockaddr_in6 *addr6;
@@ -277,7 +277,7 @@ Curl_he2ai(const struct hostent *he, int port)
for(i = 0; (curr = he->h_addr_list[i]) != NULL; i++) {
size_t ss_size;
- size_t namelen = strlen(he->h_name) + 1; /* include zero termination */
+ size_t namelen = strlen(he->h_name) + 1; /* include zero termination */
#ifdef ENABLE_IPV6
if(he->h_addrtype == AF_INET6)
ss_size = sizeof(struct sockaddr_in6);
@@ -285,17 +285,17 @@ Curl_he2ai(const struct hostent *he, int port)
#endif
ss_size = sizeof(struct sockaddr_in);
- /* allocate memory to told the struct, the address and the name */
- ai = calloc(1, sizeof(struct Curl_addrinfo) + ss_size + namelen);
+ /* allocate memory to told the struct, the address and the name */
+ ai = calloc(1, sizeof(struct Curl_addrinfo) + ss_size + namelen);
if(!ai) {
result = CURLE_OUT_OF_MEMORY;
break;
}
- /* put the address after the struct */
- ai->ai_addr = (void *)((char *)ai + sizeof(struct Curl_addrinfo));
- /* then put the name after the address */
- ai->ai_canonname = (char *)ai->ai_addr + ss_size;
- memcpy(ai->ai_canonname, he->h_name, namelen);
+ /* put the address after the struct */
+ ai->ai_addr = (void *)((char *)ai + sizeof(struct Curl_addrinfo));
+ /* then put the name after the address */
+ ai->ai_canonname = (char *)ai->ai_addr + ss_size;
+ memcpy(ai->ai_canonname, he->h_name, namelen);
if(!firstai)
/* store the pointer we want to return from this function */
@@ -368,10 +368,10 @@ struct namebuff {
* given address/host
*/
-struct Curl_addrinfo *
+struct Curl_addrinfo *
Curl_ip2addr(int af, const void *inaddr, const char *hostname, int port)
{
- struct Curl_addrinfo *ai;
+ struct Curl_addrinfo *ai;
#if defined(__VMS) && \
defined(__INITIAL_POINTER_SIZE) && (__INITIAL_POINTER_SIZE == 64)
@@ -444,7 +444,7 @@ Curl_ip2addr(int af, const void *inaddr, const char *hostname, int port)
* Given an IPv4 or IPv6 dotted string address, this converts it to a proper
* allocated Curl_addrinfo struct and returns it.
*/
-struct Curl_addrinfo *Curl_str2addr(char *address, int port)
+struct Curl_addrinfo *Curl_str2addr(char *address, int port)
{
struct in_addr in;
if(Curl_inet_pton(AF_INET, address, &in) > 0)
@@ -467,19 +467,19 @@ struct Curl_addrinfo *Curl_str2addr(char *address, int port)
* struct initialized with this path.
* Set '*longpath' to TRUE if the error is a too long path.
*/
-struct Curl_addrinfo *Curl_unix2addr(const char *path, bool *longpath,
- bool abstract)
+struct Curl_addrinfo *Curl_unix2addr(const char *path, bool *longpath,
+ bool abstract)
{
- struct Curl_addrinfo *ai;
+ struct Curl_addrinfo *ai;
struct sockaddr_un *sa_un;
size_t path_len;
*longpath = FALSE;
- ai = calloc(1, sizeof(struct Curl_addrinfo) + sizeof(struct sockaddr_un));
+ ai = calloc(1, sizeof(struct Curl_addrinfo) + sizeof(struct sockaddr_un));
if(!ai)
return NULL;
- ai->ai_addr = (void *)((char *)ai + sizeof(struct Curl_addrinfo));
+ ai->ai_addr = (void *)((char *)ai + sizeof(struct Curl_addrinfo));
sa_un = (void *) ai->ai_addr;
sa_un->sun_family = AF_UNIX;
@@ -569,9 +569,9 @@ curl_dbg_getaddrinfo(const char *hostname,
* Work-arounds the sin6_port is always zero bug on iOS 9.3.2 and Mac OS X
* 10.11.5.
*/
-void Curl_addrinfo_set_port(struct Curl_addrinfo *addrinfo, int port)
+void Curl_addrinfo_set_port(struct Curl_addrinfo *addrinfo, int port)
{
- struct Curl_addrinfo *ca;
+ struct Curl_addrinfo *ca;
struct sockaddr_in *addr;
#ifdef ENABLE_IPV6
struct sockaddr_in6 *addr6;
diff --git a/contrib/libs/curl/lib/curl_addrinfo.h b/contrib/libs/curl/lib/curl_addrinfo.h
index 7bd53169ef..73a8c1b334 100644
--- a/contrib/libs/curl/lib/curl_addrinfo.h
+++ b/contrib/libs/curl/lib/curl_addrinfo.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -59,27 +59,27 @@ struct Curl_addrinfo {
};
void
-Curl_freeaddrinfo(struct Curl_addrinfo *cahead);
+Curl_freeaddrinfo(struct Curl_addrinfo *cahead);
#ifdef HAVE_GETADDRINFO
int
Curl_getaddrinfo_ex(const char *nodename,
const char *servname,
const struct addrinfo *hints,
- struct Curl_addrinfo **result);
+ struct Curl_addrinfo **result);
#endif
-struct Curl_addrinfo *
+struct Curl_addrinfo *
Curl_he2ai(const struct hostent *he, int port);
-struct Curl_addrinfo *
+struct Curl_addrinfo *
Curl_ip2addr(int af, const void *inaddr, const char *hostname, int port);
-struct Curl_addrinfo *Curl_str2addr(char *dotted, int port);
+struct Curl_addrinfo *Curl_str2addr(char *dotted, int port);
#ifdef USE_UNIX_SOCKETS
-struct Curl_addrinfo *Curl_unix2addr(const char *path, bool *longpath,
- bool abstract);
+struct Curl_addrinfo *Curl_unix2addr(const char *path, bool *longpath,
+ bool abstract);
#endif
#if defined(CURLDEBUG) && defined(HAVE_GETADDRINFO) && \
@@ -97,7 +97,7 @@ curl_dbg_getaddrinfo(const char *hostname, const char *service,
#ifdef HAVE_GETADDRINFO
#ifdef USE_RESOLVE_ON_IPS
-void Curl_addrinfo_set_port(struct Curl_addrinfo *addrinfo, int port);
+void Curl_addrinfo_set_port(struct Curl_addrinfo *addrinfo, int port);
#else
#define Curl_addrinfo_set_port(x,y)
#endif
diff --git a/contrib/libs/curl/lib/curl_base64.h b/contrib/libs/curl/lib/curl_base64.h
index 25f2c5a53d..d48edc4241 100644
--- a/contrib/libs/curl/lib/curl_base64.h
+++ b/contrib/libs/curl/lib/curl_base64.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/curl_config-android.h b/contrib/libs/curl/lib/curl_config-android.h
index f5f10e09fe..42719f78b0 100644
--- a/contrib/libs/curl/lib/curl_config-android.h
+++ b/contrib/libs/curl/lib/curl_config-android.h
@@ -1,2 +1,2 @@
-#pragma once
-#include "curl_config-linux.h"
+#pragma once
+#include "curl_config-linux.h"
diff --git a/contrib/libs/curl/lib/curl_config-linux.h b/contrib/libs/curl/lib/curl_config-linux.h
index 0f029d6d17..0dfa912535 100644
--- a/contrib/libs/curl/lib/curl_config-linux.h
+++ b/contrib/libs/curl/lib/curl_config-linux.h
@@ -16,9 +16,9 @@
/* Default SSL backend */
/* #undef CURL_DEFAULT_SSL_BACKEND */
-/* disable alt-svc */
-/* #undef CURL_DISABLE_ALTSVC */
-
+/* disable alt-svc */
+/* #undef CURL_DISABLE_ALTSVC */
+
/* to disable cookies support */
/* #undef CURL_DISABLE_COOKIES */
@@ -37,9 +37,9 @@
/* to disable FTP */
/* #undef CURL_DISABLE_FTP */
-/* to disable curl_easy_options */
-/* #undef CURL_DISABLE_GETOPTIONS */
-
+/* to disable curl_easy_options */
+/* #undef CURL_DISABLE_GETOPTIONS */
+
/* to disable Gopher */
/* #undef CURL_DISABLE_GOPHER */
@@ -64,9 +64,9 @@
/* disable mime API */
/* #undef CURL_DISABLE_MIME */
-/* to disable MQTT */
-/* #undef CURL_DISABLE_MQTT */
-
+/* to disable MQTT */
+/* #undef CURL_DISABLE_MQTT */
+
/* disable netrc parsing */
/* #undef CURL_DISABLE_NETRC */
@@ -97,9 +97,9 @@
/* to disable SMTP */
/* #undef CURL_DISABLE_SMTP */
-/* to disable socketpair support */
-/* #undef CURL_DISABLE_SOCKETPAIR */
-
+/* to disable socketpair support */
+/* #undef CURL_DISABLE_SOCKETPAIR */
+
/* to disable TELNET */
/* #undef CURL_DISABLE_TELNET */
@@ -438,15 +438,15 @@
/* Define to 1 if you have the `ssl' library (-lssl). */
#define HAVE_LIBSSL 1
-/* Define to 1 if you have the `wolfssh' library (-lwolfssh). */
-/* #undef HAVE_LIBWOLFSSH */
-
+/* Define to 1 if you have the `wolfssh' library (-lwolfssh). */
+/* #undef HAVE_LIBWOLFSSH */
+
/* if zlib is available */
#define HAVE_LIBZ 1
-/* Define to 1 if you have the `zstd' library (-lzstd). */
-/* #undef HAVE_LIBZSTD */
-
+/* Define to 1 if you have the `zstd' library (-lzstd). */
+/* #undef HAVE_LIBZSTD */
+
/* Define to 1 if you have the <linux/tcp.h> header file. */
#define HAVE_LINUX_TCP_H 1
@@ -508,9 +508,9 @@
*/
/* #undef HAVE_OLD_GSSMIT */
-/* Define to 1 if using OpenSSL 3 or later. */
-/* #undef HAVE_OPENSSL3 */
-
+/* Define to 1 if using OpenSSL 3 or later. */
+/* #undef HAVE_OPENSSL3 */
+
/* Define to 1 if you have the <openssl/crypto.h> header file. */
#define HAVE_OPENSSL_CRYPTO_H 1
@@ -565,9 +565,9 @@
/* Define to 1 if you have the <pwd.h> header file. */
#define HAVE_PWD_H 1
-/* Define to 1 if you have the `quiche_conn_set_qlog_fd' function. */
-/* #undef HAVE_QUICHE_CONN_SET_QLOG_FD */
-
+/* Define to 1 if you have the `quiche_conn_set_qlog_fd' function. */
+/* #undef HAVE_QUICHE_CONN_SET_QLOG_FD */
+
/* Define to 1 if you have the <quiche.h> header file. */
/* #undef HAVE_QUICHE_H */
@@ -643,9 +643,9 @@
/* Define to 1 if you have the `SSLv2_client_method' function. */
/* #undef HAVE_SSLV2_CLIENT_METHOD */
-/* Define to 1 if you have the `SSL_get_ech_status' function. */
-/* #undef HAVE_SSL_GET_ECH_STATUS */
-
+/* Define to 1 if you have the `SSL_get_ech_status' function. */
+/* #undef HAVE_SSL_GET_ECH_STATUS */
+
/* Define to 1 if you have the <ssl.h> header file. */
/* #undef HAVE_SSL_H */
@@ -689,7 +689,7 @@
/* #undef HAVE_STRNICMP */
/* Define to 1 if you have the <stropts.h> header file. */
-/* #undef HAVE_STROPTS_H */
+/* #undef HAVE_STROPTS_H */
/* Define to 1 if you have the strstr function. */
#define HAVE_STRSTR 1
@@ -706,9 +706,9 @@
/* Define to 1 if you have the timeval struct. */
#define HAVE_STRUCT_TIMEVAL 1
-/* Define to 1 if suseconds_t is an available type. */
-#define HAVE_SUSECONDS_T 1
-
+/* Define to 1 if suseconds_t is an available type. */
+#define HAVE_SUSECONDS_T 1
+
/* Define to 1 if you have the <sys/filio.h> header file. */
/* #undef HAVE_SYS_FILIO_H */
@@ -805,15 +805,15 @@
/* Define to 1 if you have the winsock.h header file. */
/* #undef HAVE_WINSOCK_H */
-/* Define to 1 if you have the <wolfssh/ssh.h> header file. */
-/* #undef HAVE_WOLFSSH_SSH_H */
-
+/* Define to 1 if you have the <wolfssh/ssh.h> header file. */
+/* #undef HAVE_WOLFSSH_SSH_H */
+
/* Define to 1 if you have the `wolfSSLv3_client_method' function. */
/* #undef HAVE_WOLFSSLV3_CLIENT_METHOD */
-/* if you have wolfSSL_DES_ecb_encrypt */
-/* #undef HAVE_WOLFSSL_DES_ECB_ENCRYPT */
-
+/* if you have wolfSSL_DES_ecb_encrypt */
+/* #undef HAVE_WOLFSSL_DES_ECB_ENCRYPT */
+
/* Define to 1 if you have the `wolfSSL_get_peer_certificate' function. */
/* #undef HAVE_WOLFSSL_GET_PEER_CERTIFICATE */
@@ -821,7 +821,7 @@
/* #undef HAVE_WOLFSSL_USEALPN */
/* Define this symbol if your OS supports changing the contents of argv */
-#define HAVE_WRITABLE_ARGV 1
+#define HAVE_WRITABLE_ARGV 1
/* Define to 1 if you have the writev function. */
#define HAVE_WRITEV 1
@@ -835,12 +835,12 @@
/* if you have the zlib.h header file */
#define HAVE_ZLIB_H 1
-/* if libzstd is in use */
-/* #undef HAVE_ZSTD */
-
-/* Define to 1 if you have the <zstd.h> header file. */
-/* #undef HAVE_ZSTD_H */
-
+/* if libzstd is in use */
+/* #undef HAVE_ZSTD */
+
+/* Define to 1 if you have the <zstd.h> header file. */
+/* #undef HAVE_ZSTD_H */
+
/* Define to the sub-directory where libtool stores uninstalled libraries. */
#define LT_OBJDIR ".libs/"
@@ -872,7 +872,7 @@
#define PACKAGE "curl"
/* Define to the address where bug reports for this package should be sent. */
-#define PACKAGE_BUGREPORT "a suitable curl mailing list: https://curl.se/mail/"
+#define PACKAGE_BUGREPORT "a suitable curl mailing list: https://curl.se/mail/"
/* Define to the full name of this package. */
#define PACKAGE_NAME "curl"
@@ -990,21 +990,21 @@
/* Define to enable c-ares support */
#define USE_ARES 1
-/* if BearSSL is enabled */
-/* #undef USE_BEARSSL */
-
-/* if ECH support is available */
-/* #undef USE_ECH */
-
+/* if BearSSL is enabled */
+/* #undef USE_BEARSSL */
+
+/* if ECH support is available */
+/* #undef USE_ECH */
+
/* if GnuTLS is enabled */
/* #undef USE_GNUTLS */
/* if GnuTLS uses nettle as crypto backend */
/* #undef USE_GNUTLS_NETTLE */
-/* to enable HSTS */
-/* #undef USE_HSTS */
-
+/* to enable HSTS */
+/* #undef USE_HSTS */
+
/* PSL support enabled */
/* #undef USE_LIBPSL */
@@ -1038,9 +1038,9 @@
/* if ngtcp2 is in use */
/* #undef USE_NGTCP2 */
-/* if ngtcp2_crypto_gnutls is in use */
-/* #undef USE_NGTCP2_CRYPTO_GNUTLS */
-
+/* if ngtcp2_crypto_gnutls is in use */
+/* #undef USE_NGTCP2_CRYPTO_GNUTLS */
+
/* if ngtcp2_crypto_openssl is in use */
/* #undef USE_NGTCP2_CRYPTO_OPENSSL */
@@ -1091,9 +1091,9 @@
/* to enable SSPI support */
/* #undef USE_WINDOWS_SSPI */
-/* if wolfSSH is in use */
-/* #undef USE_WOLFSSH */
-
+/* if wolfSSH is in use */
+/* #undef USE_WOLFSSH */
+
/* if wolfSSL is enabled */
/* #undef USE_WOLFSSL */
diff --git a/contrib/libs/curl/lib/curl_config.h b/contrib/libs/curl/lib/curl_config.h
index 224269b3ee..e58dec7079 100644
--- a/contrib/libs/curl/lib/curl_config.h
+++ b/contrib/libs/curl/lib/curl_config.h
@@ -17,51 +17,51 @@
#else
# include "curl_config-linux.h"
#endif
-
+
#if defined(_musl_)
# include "curl_config-musl.h"
#endif
-// Do not misrepresent host on Android and iOS.
-#undef OS
+// Do not misrepresent host on Android and iOS.
+#undef OS
#define OS "arcadia"
-// c-ares resolver is known to be buggy.
-//
-// There is no way to configure it properly without a JVM on Android,
-// because Android lacks traditional resolv.conf.
-//
-// For standalone Android programs, it is impossible
-// to contact ConnectionManager outside the JVM; this breaks c-ares DNS resolution.
-// As we can not distinguish builds of Android apps from standalone Android programs.
-//
-// During mapkit experiments, c-ares was adding about 10ms to each query timespan.
-//
-//
-// On Linux it caches /etc/resolv.conf contents and does not invalidate it properly
+// c-ares resolver is known to be buggy.
+//
+// There is no way to configure it properly without a JVM on Android,
+// because Android lacks traditional resolv.conf.
+//
+// For standalone Android programs, it is impossible
+// to contact ConnectionManager outside the JVM; this breaks c-ares DNS resolution.
+// As we can not distinguish builds of Android apps from standalone Android programs.
+//
+// During mapkit experiments, c-ares was adding about 10ms to each query timespan.
+//
+//
+// On Linux it caches /etc/resolv.conf contents and does not invalidate it properly
-#if defined(ARCADIA_CURL_DNS_RESOLVER_ARES)
- #define USE_ARES
-#elif defined(ARCADIA_CURL_DNS_RESOLVER_MULTITHREADED)
- #if defined(USE_ARES)
- #undef USE_ARES
- #endif
- #if defined(__linux__) && !defined(USE_THREADS_POSIX)
- #define USE_THREADS_POSIX 1
- #elif defined(_MSC_VER) && !defined(USE_THREADS_WIN32)
- #define USE_THREADS_WIN32 1
- #endif
-#elif defined(ARCADIA_CURL_DNS_RESOLVER_SYNCHRONOUS)
- // force using synchronous resolver by disabling thread support
- #if defined(USE_ARES)
- #undef USE_ARES
- #endif
- #if defined(USE_THREADS_POSIX)
- #undef USE_THREADS_POSIX
- #endif
- #if defined(USE_THREADS_WIN32)
- #undef USE_THREADS_WIN32
- #endif
-#else
- #error "No dns resolver is specified or resolver specification is wrong"
+#if defined(ARCADIA_CURL_DNS_RESOLVER_ARES)
+ #define USE_ARES
+#elif defined(ARCADIA_CURL_DNS_RESOLVER_MULTITHREADED)
+ #if defined(USE_ARES)
+ #undef USE_ARES
+ #endif
+ #if defined(__linux__) && !defined(USE_THREADS_POSIX)
+ #define USE_THREADS_POSIX 1
+ #elif defined(_MSC_VER) && !defined(USE_THREADS_WIN32)
+ #define USE_THREADS_WIN32 1
+ #endif
+#elif defined(ARCADIA_CURL_DNS_RESOLVER_SYNCHRONOUS)
+ // force using synchronous resolver by disabling thread support
+ #if defined(USE_ARES)
+ #undef USE_ARES
+ #endif
+ #if defined(USE_THREADS_POSIX)
+ #undef USE_THREADS_POSIX
+ #endif
+ #if defined(USE_THREADS_WIN32)
+ #undef USE_THREADS_WIN32
+ #endif
+#else
+ #error "No dns resolver is specified or resolver specification is wrong"
#endif
diff --git a/contrib/libs/curl/lib/curl_ctype.c b/contrib/libs/curl/lib/curl_ctype.c
index 7aeda2bcf8..d6cd08a077 100644
--- a/contrib/libs/curl/lib/curl_ctype.c
+++ b/contrib/libs/curl/lib/curl_ctype.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/curl_ctype.h b/contrib/libs/curl/lib/curl_ctype.h
index d167e6b31a..17dfaa0942 100644
--- a/contrib/libs/curl/lib/curl_ctype.h
+++ b/contrib/libs/curl/lib/curl_ctype.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/curl_des.c b/contrib/libs/curl/lib/curl_des.c
index f5f928a886..8c5af19cd2 100644
--- a/contrib/libs/curl/lib/curl_des.c
+++ b/contrib/libs/curl/lib/curl_des.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 2015 - 2020, Steve Holme, <steve_holme@hotmail.com>.
+ * Copyright (C) 2015 - 2020, Steve Holme, <steve_holme@hotmail.com>.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/curl_des.h b/contrib/libs/curl/lib/curl_des.h
index 4cd8431897..438706a0d2 100644
--- a/contrib/libs/curl/lib/curl_des.h
+++ b/contrib/libs/curl/lib/curl_des.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 2015 - 2020, Steve Holme, <steve_holme@hotmail.com>.
+ * Copyright (C) 2015 - 2020, Steve Holme, <steve_holme@hotmail.com>.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/curl_endian.c b/contrib/libs/curl/lib/curl_endian.c
index b54ee61063..2fc25bc173 100644
--- a/contrib/libs/curl/lib/curl_endian.c
+++ b/contrib/libs/curl/lib/curl_endian.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -81,7 +81,7 @@ unsigned short Curl_read16_be(const unsigned char *buf)
((unsigned short)buf[1]));
}
-#if (CURL_SIZEOF_CURL_OFF_T > 4)
+#if (CURL_SIZEOF_CURL_OFF_T > 4)
/*
* write32_le()
*
diff --git a/contrib/libs/curl/lib/curl_endian.h b/contrib/libs/curl/lib/curl_endian.h
index 083b6b94ef..341dfaf3cc 100644
--- a/contrib/libs/curl/lib/curl_endian.h
+++ b/contrib/libs/curl/lib/curl_endian.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/curl_fnmatch.c b/contrib/libs/curl/lib/curl_fnmatch.c
index c4b0cfd38b..4bfa58598e 100644
--- a/contrib/libs/curl/lib/curl_fnmatch.c
+++ b/contrib/libs/curl/lib/curl_fnmatch.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/curl_fnmatch.h b/contrib/libs/curl/lib/curl_fnmatch.h
index d6f169fabf..1c80ea7793 100644
--- a/contrib/libs/curl/lib/curl_fnmatch.h
+++ b/contrib/libs/curl/lib/curl_fnmatch.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/curl_get_line.c b/contrib/libs/curl/lib/curl_get_line.c
index 84fa07ab03..438ede7046 100644
--- a/contrib/libs/curl/lib/curl_get_line.c
+++ b/contrib/libs/curl/lib/curl_get_line.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -22,9 +22,9 @@
#include "curl_setup.h"
-#if !defined(CURL_DISABLE_COOKIES) || !defined(CURL_DISABLE_ALTSVC) || \
- defined(USE_HSTS)
-
+#if !defined(CURL_DISABLE_COOKIES) || !defined(CURL_DISABLE_ALTSVC) || \
+ defined(USE_HSTS)
+
#include "curl_get_line.h"
#include "curl_memory.h"
/* The last #include file should be: */
@@ -56,5 +56,5 @@ char *Curl_get_line(char *buf, int len, FILE *input)
}
return NULL;
}
-
-#endif /* if not disabled */
+
+#endif /* if not disabled */
diff --git a/contrib/libs/curl/lib/curl_get_line.h b/contrib/libs/curl/lib/curl_get_line.h
index d7ba9d0664..597aa09a9c 100644
--- a/contrib/libs/curl/lib/curl_get_line.h
+++ b/contrib/libs/curl/lib/curl_get_line.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/curl_gethostname.c b/contrib/libs/curl/lib/curl_gethostname.c
index d242a129ad..2d5ff61cf6 100644
--- a/contrib/libs/curl/lib/curl_gethostname.c
+++ b/contrib/libs/curl/lib/curl_gethostname.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -48,7 +48,7 @@
* For libcurl static library release builds no overriding takes place.
*/
-int Curl_gethostname(char * const name, GETHOSTNAME_TYPE_ARG2 namelen)
+int Curl_gethostname(char * const name, GETHOSTNAME_TYPE_ARG2 namelen)
{
#ifndef HAVE_GETHOSTNAME
diff --git a/contrib/libs/curl/lib/curl_gethostname.h b/contrib/libs/curl/lib/curl_gethostname.h
index 771989c724..2161c40ac3 100644
--- a/contrib/libs/curl/lib/curl_gethostname.h
+++ b/contrib/libs/curl/lib/curl_gethostname.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -26,6 +26,6 @@
#define HOSTNAME_MAX 1024
/* This returns the local machine's un-qualified hostname */
-int Curl_gethostname(char * const name, GETHOSTNAME_TYPE_ARG2 namelen);
+int Curl_gethostname(char * const name, GETHOSTNAME_TYPE_ARG2 namelen);
#endif /* HEADER_CURL_GETHOSTNAME_H */
diff --git a/contrib/libs/curl/lib/curl_gssapi.c b/contrib/libs/curl/lib/curl_gssapi.c
index 23d9378b92..f72430b26f 100644
--- a/contrib/libs/curl/lib/curl_gssapi.c
+++ b/contrib/libs/curl/lib/curl_gssapi.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 2011 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2011 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/curl_gssapi.h b/contrib/libs/curl/lib/curl_gssapi.h
index 50786ed31b..466d09ed0a 100644
--- a/contrib/libs/curl/lib/curl_gssapi.h
+++ b/contrib/libs/curl/lib/curl_gssapi.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 2011 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2011 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/curl_hmac.h b/contrib/libs/curl/lib/curl_hmac.h
index 68f313b74e..84c73121bd 100644
--- a/contrib/libs/curl/lib/curl_hmac.h
+++ b/contrib/libs/curl/lib/curl_hmac.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -24,8 +24,8 @@
#ifndef CURL_DISABLE_CRYPTO_AUTH
-#define HMAC_MD5_LENGTH 16
-
+#define HMAC_MD5_LENGTH 16
+
typedef void (* HMAC_hinit_func)(void *context);
typedef void (* HMAC_hupdate_func)(void *context,
const unsigned char *data,
@@ -34,39 +34,39 @@ typedef void (* HMAC_hfinal_func)(unsigned char *result, void *context);
/* Per-hash function HMAC parameters. */
-struct HMAC_params {
- HMAC_hinit_func
- hmac_hinit; /* Initialize context procedure. */
+struct HMAC_params {
+ HMAC_hinit_func
+ hmac_hinit; /* Initialize context procedure. */
HMAC_hupdate_func hmac_hupdate; /* Update context with data. */
HMAC_hfinal_func hmac_hfinal; /* Get final result procedure. */
unsigned int hmac_ctxtsize; /* Context structure size. */
unsigned int hmac_maxkeylen; /* Maximum key length (bytes). */
unsigned int hmac_resultlen; /* Result length (bytes). */
-};
+};
/* HMAC computation context. */
-struct HMAC_context {
- const struct HMAC_params *hmac_hash; /* Hash function definition. */
+struct HMAC_context {
+ const struct HMAC_params *hmac_hash; /* Hash function definition. */
void *hmac_hashctxt1; /* Hash function context 1. */
void *hmac_hashctxt2; /* Hash function context 2. */
-};
+};
/* Prototypes. */
-struct HMAC_context *Curl_HMAC_init(const struct HMAC_params *hashparams,
- const unsigned char *key,
- unsigned int keylen);
-int Curl_HMAC_update(struct HMAC_context *context,
+struct HMAC_context *Curl_HMAC_init(const struct HMAC_params *hashparams,
+ const unsigned char *key,
+ unsigned int keylen);
+int Curl_HMAC_update(struct HMAC_context *context,
const unsigned char *data,
unsigned int len);
-int Curl_HMAC_final(struct HMAC_context *context, unsigned char *result);
+int Curl_HMAC_final(struct HMAC_context *context, unsigned char *result);
+
+CURLcode Curl_hmacit(const struct HMAC_params *hashparams,
+ const unsigned char *key, const size_t keylen,
+ const unsigned char *data, const size_t datalen,
+ unsigned char *output);
-CURLcode Curl_hmacit(const struct HMAC_params *hashparams,
- const unsigned char *key, const size_t keylen,
- const unsigned char *data, const size_t datalen,
- unsigned char *output);
-
#endif
#endif /* HEADER_CURL_HMAC_H */
diff --git a/contrib/libs/curl/lib/curl_krb5.h b/contrib/libs/curl/lib/curl_krb5.h
index a4ed769cc4..f0a6fa69be 100644
--- a/contrib/libs/curl/lib/curl_krb5.h
+++ b/contrib/libs/curl/lib/curl_krb5.h
@@ -1,51 +1,51 @@
-#ifndef HEADER_CURL_KRB5_H
-#define HEADER_CURL_KRB5_H
-/***************************************************************************
- * _ _ ____ _
- * Project ___| | | | _ \| |
- * / __| | | | |_) | |
- * | (__| |_| | _ <| |___
- * \___|\___/|_| \_\_____|
- *
- * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
- *
- * You may opt to use, copy, modify, merge, publish, distribute and/or sell
- * copies of the Software, and permit persons to whom the Software is
- * furnished to do so, under the terms of the COPYING file.
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- ***************************************************************************/
-
-struct Curl_sec_client_mech {
- const char *name;
- size_t size;
- int (*init)(void *);
- int (*auth)(void *, struct connectdata *);
- void (*end)(void *);
- int (*check_prot)(void *, int);
- int (*overhead)(void *, int, int);
- int (*encode)(void *, const void *, int, int, void **);
- int (*decode)(void *, void *, int, int, struct connectdata *);
-};
-
-#define AUTH_OK 0
-#define AUTH_CONTINUE 1
-#define AUTH_ERROR 2
-
-#ifdef HAVE_GSSAPI
-int Curl_sec_read_msg(struct connectdata *conn, char *,
- enum protection_level);
-void Curl_sec_end(struct connectdata *);
-CURLcode Curl_sec_login(struct connectdata *);
-int Curl_sec_request_prot(struct connectdata *conn, const char *level);
-#else
-#define Curl_sec_end(x)
-#endif
-
-#endif /* HEADER_CURL_KRB5_H */
+#ifndef HEADER_CURL_KRB5_H
+#define HEADER_CURL_KRB5_H
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 1998 - 2020, 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
+ * are also available at https://curl.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+
+struct Curl_sec_client_mech {
+ const char *name;
+ size_t size;
+ int (*init)(void *);
+ int (*auth)(void *, struct connectdata *);
+ void (*end)(void *);
+ int (*check_prot)(void *, int);
+ int (*overhead)(void *, int, int);
+ int (*encode)(void *, const void *, int, int, void **);
+ int (*decode)(void *, void *, int, int, struct connectdata *);
+};
+
+#define AUTH_OK 0
+#define AUTH_CONTINUE 1
+#define AUTH_ERROR 2
+
+#ifdef HAVE_GSSAPI
+int Curl_sec_read_msg(struct connectdata *conn, char *,
+ enum protection_level);
+void Curl_sec_end(struct connectdata *);
+CURLcode Curl_sec_login(struct connectdata *);
+int Curl_sec_request_prot(struct connectdata *conn, const char *level);
+#else
+#define Curl_sec_end(x)
+#endif
+
+#endif /* HEADER_CURL_KRB5_H */
diff --git a/contrib/libs/curl/lib/curl_ldap.h b/contrib/libs/curl/lib/curl_ldap.h
index f4890a3f2c..124e18b133 100644
--- a/contrib/libs/curl/lib/curl_ldap.h
+++ b/contrib/libs/curl/lib/curl_ldap.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/curl_md4.h b/contrib/libs/curl/lib/curl_md4.h
index fc959dd8d1..f9dafcb53c 100644
--- a/contrib/libs/curl/lib/curl_md4.h
+++ b/contrib/libs/curl/lib/curl_md4.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -28,8 +28,8 @@
#define MD4_DIGEST_LENGTH 16
-void Curl_md4it(unsigned char *output, const unsigned char *input,
- const size_t len);
+void Curl_md4it(unsigned char *output, const unsigned char *input,
+ const size_t len);
#endif /* !defined(CURL_DISABLE_CRYPTO_AUTH) */
diff --git a/contrib/libs/curl/lib/curl_md5.h b/contrib/libs/curl/lib/curl_md5.h
index 56c6871697..5739c89ca4 100644
--- a/contrib/libs/curl/lib/curl_md5.h
+++ b/contrib/libs/curl/lib/curl_md5.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -33,30 +33,30 @@ typedef void (* Curl_MD5_update_func)(void *context,
unsigned int len);
typedef void (* Curl_MD5_final_func)(unsigned char *result, void *context);
-struct MD5_params {
+struct MD5_params {
Curl_MD5_init_func md5_init_func; /* Initialize context procedure */
Curl_MD5_update_func md5_update_func; /* Update context with data */
Curl_MD5_final_func md5_final_func; /* Get final result procedure */
unsigned int md5_ctxtsize; /* Context structure size */
unsigned int md5_resultlen; /* Result length (bytes) */
-};
+};
-struct MD5_context {
- const struct MD5_params *md5_hash; /* Hash function definition */
+struct MD5_context {
+ const struct MD5_params *md5_hash; /* Hash function definition */
void *md5_hashctx; /* Hash function context */
-};
+};
-extern const struct MD5_params Curl_DIGEST_MD5[1];
-extern const struct HMAC_params Curl_HMAC_MD5[1];
+extern const struct MD5_params Curl_DIGEST_MD5[1];
+extern const struct HMAC_params Curl_HMAC_MD5[1];
-void Curl_md5it(unsigned char *output, const unsigned char *input,
- const size_t len);
+void Curl_md5it(unsigned char *output, const unsigned char *input,
+ const size_t len);
-struct MD5_context *Curl_MD5_init(const struct MD5_params *md5params);
-CURLcode Curl_MD5_update(struct MD5_context *context,
+struct MD5_context *Curl_MD5_init(const struct MD5_params *md5params);
+CURLcode Curl_MD5_update(struct MD5_context *context,
const unsigned char *data,
unsigned int len);
-CURLcode Curl_MD5_final(struct MD5_context *context, unsigned char *result);
+CURLcode Curl_MD5_final(struct MD5_context *context, unsigned char *result);
#endif
diff --git a/contrib/libs/curl/lib/curl_memory.h b/contrib/libs/curl/lib/curl_memory.h
index b253d462fd..5806290637 100644
--- a/contrib/libs/curl/lib/curl_memory.h
+++ b/contrib/libs/curl/lib/curl_memory.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/curl_memrchr.c b/contrib/libs/curl/lib/curl_memrchr.c
index b79cc69488..0bd845f690 100644
--- a/contrib/libs/curl/lib/curl_memrchr.c
+++ b/contrib/libs/curl/lib/curl_memrchr.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/curl_memrchr.h b/contrib/libs/curl/lib/curl_memrchr.h
index 5968d0a40c..c8394bb433 100644
--- a/contrib/libs/curl/lib/curl_memrchr.h
+++ b/contrib/libs/curl/lib/curl_memrchr.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/curl_multibyte.c b/contrib/libs/curl/lib/curl_multibyte.c
index c10982c7ec..d327c8ba77 100644
--- a/contrib/libs/curl/lib/curl_multibyte.c
+++ b/contrib/libs/curl/lib/curl_multibyte.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -20,21 +20,21 @@
*
***************************************************************************/
-/*
- * This file is 'mem-include-scan' clean. See test 1132.
- */
-
+/*
+ * This file is 'mem-include-scan' clean. See test 1132.
+ */
+
#include "curl_setup.h"
-#if defined(WIN32)
+#if defined(WIN32)
#include "curl_multibyte.h"
-/*
- * MultiByte conversions using Windows kernel32 library.
- */
+/*
+ * MultiByte conversions using Windows kernel32 library.
+ */
-wchar_t *curlx_convert_UTF8_to_wchar(const char *str_utf8)
+wchar_t *curlx_convert_UTF8_to_wchar(const char *str_utf8)
{
wchar_t *str_w = NULL;
@@ -56,7 +56,7 @@ wchar_t *curlx_convert_UTF8_to_wchar(const char *str_utf8)
return str_w;
}
-char *curlx_convert_wchar_to_UTF8(const wchar_t *str_w)
+char *curlx_convert_wchar_to_UTF8(const wchar_t *str_w)
{
char *str_utf8 = NULL;
@@ -78,76 +78,76 @@ char *curlx_convert_wchar_to_UTF8(const wchar_t *str_w)
return str_utf8;
}
-#endif /* WIN32 */
-
-#if defined(USE_WIN32_LARGE_FILES) || defined(USE_WIN32_SMALL_FILES)
-
-FILE *curlx_win32_fopen(const char *filename, const char *mode)
-{
-#ifdef _UNICODE
- FILE *result = NULL;
- wchar_t *filename_w = curlx_convert_UTF8_to_wchar(filename);
- wchar_t *mode_w = curlx_convert_UTF8_to_wchar(mode);
- if(filename_w && mode_w)
- result = _wfopen(filename_w, mode_w);
- free(filename_w);
- free(mode_w);
- if(result)
- return result;
-#endif
-
- return (fopen)(filename, mode);
-}
-
-int curlx_win32_stat(const char *path, struct_stat *buffer)
-{
- int result = -1;
-#ifdef _UNICODE
- wchar_t *path_w = curlx_convert_UTF8_to_wchar(path);
-#endif /* _UNICODE */
-
-#if defined(USE_WIN32_SMALL_FILES)
-#if defined(_UNICODE)
- if(path_w)
- result = _wstat(path_w, buffer);
- else
-#endif /* _UNICODE */
- result = _stat(path, buffer);
-#else /* USE_WIN32_SMALL_FILES */
-#if defined(_UNICODE)
- if(path_w)
- result = _wstati64(path_w, buffer);
- else
-#endif /* _UNICODE */
- result = _stati64(path, buffer);
-#endif /* USE_WIN32_SMALL_FILES */
-
-#ifdef _UNICODE
- free(path_w);
-#endif
-
- return result;
-}
-
-int curlx_win32_access(const char *path, int mode)
-{
- int result = -1;
-#ifdef _UNICODE
- wchar_t *path_w = curlx_convert_UTF8_to_wchar(path);
-#endif /* _UNICODE */
-
-#if defined(_UNICODE)
- if(path_w)
- result = _waccess(path_w, mode);
- else
-#endif /* _UNICODE */
- result = _access(path, mode);
-
-#ifdef _UNICODE
- free(path_w);
-#endif
-
- return result;
-}
-
-#endif /* USE_WIN32_LARGE_FILES || USE_WIN32_SMALL_FILES */
+#endif /* WIN32 */
+
+#if defined(USE_WIN32_LARGE_FILES) || defined(USE_WIN32_SMALL_FILES)
+
+FILE *curlx_win32_fopen(const char *filename, const char *mode)
+{
+#ifdef _UNICODE
+ FILE *result = NULL;
+ wchar_t *filename_w = curlx_convert_UTF8_to_wchar(filename);
+ wchar_t *mode_w = curlx_convert_UTF8_to_wchar(mode);
+ if(filename_w && mode_w)
+ result = _wfopen(filename_w, mode_w);
+ free(filename_w);
+ free(mode_w);
+ if(result)
+ return result;
+#endif
+
+ return (fopen)(filename, mode);
+}
+
+int curlx_win32_stat(const char *path, struct_stat *buffer)
+{
+ int result = -1;
+#ifdef _UNICODE
+ wchar_t *path_w = curlx_convert_UTF8_to_wchar(path);
+#endif /* _UNICODE */
+
+#if defined(USE_WIN32_SMALL_FILES)
+#if defined(_UNICODE)
+ if(path_w)
+ result = _wstat(path_w, buffer);
+ else
+#endif /* _UNICODE */
+ result = _stat(path, buffer);
+#else /* USE_WIN32_SMALL_FILES */
+#if defined(_UNICODE)
+ if(path_w)
+ result = _wstati64(path_w, buffer);
+ else
+#endif /* _UNICODE */
+ result = _stati64(path, buffer);
+#endif /* USE_WIN32_SMALL_FILES */
+
+#ifdef _UNICODE
+ free(path_w);
+#endif
+
+ return result;
+}
+
+int curlx_win32_access(const char *path, int mode)
+{
+ int result = -1;
+#ifdef _UNICODE
+ wchar_t *path_w = curlx_convert_UTF8_to_wchar(path);
+#endif /* _UNICODE */
+
+#if defined(_UNICODE)
+ if(path_w)
+ result = _waccess(path_w, mode);
+ else
+#endif /* _UNICODE */
+ result = _access(path, mode);
+
+#ifdef _UNICODE
+ free(path_w);
+#endif
+
+ return result;
+}
+
+#endif /* USE_WIN32_LARGE_FILES || USE_WIN32_SMALL_FILES */
diff --git a/contrib/libs/curl/lib/curl_multibyte.h b/contrib/libs/curl/lib/curl_multibyte.h
index 101a2148be..8adaf49784 100644
--- a/contrib/libs/curl/lib/curl_multibyte.h
+++ b/contrib/libs/curl/lib/curl_multibyte.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -23,46 +23,46 @@
***************************************************************************/
#include "curl_setup.h"
-#if defined(WIN32)
+#if defined(WIN32)
/*
* MultiByte conversions using Windows kernel32 library.
*/
-wchar_t *curlx_convert_UTF8_to_wchar(const char *str_utf8);
-char *curlx_convert_wchar_to_UTF8(const wchar_t *str_w);
+wchar_t *curlx_convert_UTF8_to_wchar(const char *str_utf8);
+char *curlx_convert_wchar_to_UTF8(const wchar_t *str_w);
-#endif /* WIN32 */
+#endif /* WIN32 */
/*
- * Macros curlx_convert_UTF8_to_tchar(), curlx_convert_tchar_to_UTF8()
- * and curlx_unicodefree() main purpose is to minimize the number of
+ * Macros curlx_convert_UTF8_to_tchar(), curlx_convert_tchar_to_UTF8()
+ * and curlx_unicodefree() main purpose is to minimize the number of
* preprocessor conditional directives needed by code using these
* to differentiate UNICODE from non-UNICODE builds.
*
- * When building with UNICODE defined, these two macros
- * curlx_convert_UTF8_to_tchar() and curlx_convert_tchar_to_UTF8()
+ * When building with UNICODE defined, these two macros
+ * curlx_convert_UTF8_to_tchar() and curlx_convert_tchar_to_UTF8()
* return a pointer to a newly allocated memory area holding result.
* When the result is no longer needed, allocated memory is intended
- * to be free'ed with curlx_unicodefree().
+ * to be free'ed with curlx_unicodefree().
*
* When building without UNICODE defined, this macros
- * curlx_convert_UTF8_to_tchar() and curlx_convert_tchar_to_UTF8()
- * return the pointer received as argument. curlx_unicodefree() does
+ * curlx_convert_UTF8_to_tchar() and curlx_convert_tchar_to_UTF8()
+ * return the pointer received as argument. curlx_unicodefree() does
* no actual free'ing of this pointer it is simply set to NULL.
*/
-#if defined(UNICODE) && defined(WIN32)
+#if defined(UNICODE) && defined(WIN32)
-#define curlx_convert_UTF8_to_tchar(ptr) curlx_convert_UTF8_to_wchar((ptr))
-#define curlx_convert_tchar_to_UTF8(ptr) curlx_convert_wchar_to_UTF8((ptr))
-#define curlx_unicodefree(ptr) \
- do { \
- if(ptr) { \
- (free)(ptr); \
- (ptr) = NULL; \
- } \
- } while(0)
+#define curlx_convert_UTF8_to_tchar(ptr) curlx_convert_UTF8_to_wchar((ptr))
+#define curlx_convert_tchar_to_UTF8(ptr) curlx_convert_wchar_to_UTF8((ptr))
+#define curlx_unicodefree(ptr) \
+ do { \
+ if(ptr) { \
+ (free)(ptr); \
+ (ptr) = NULL; \
+ } \
+ } while(0)
typedef union {
unsigned short *tchar_ptr;
@@ -73,10 +73,10 @@ typedef union {
#else
-#define curlx_convert_UTF8_to_tchar(ptr) (ptr)
-#define curlx_convert_tchar_to_UTF8(ptr) (ptr)
-#define curlx_unicodefree(ptr) \
- do {(ptr) = NULL;} while(0)
+#define curlx_convert_UTF8_to_tchar(ptr) (ptr)
+#define curlx_convert_tchar_to_UTF8(ptr) (ptr)
+#define curlx_unicodefree(ptr) \
+ do {(ptr) = NULL;} while(0)
typedef union {
char *tchar_ptr;
@@ -85,6 +85,6 @@ typedef union {
const unsigned char *const_tbyte_ptr;
} xcharp_u;
-#endif /* UNICODE && WIN32 */
+#endif /* UNICODE && WIN32 */
#endif /* HEADER_CURL_MULTIBYTE_H */
diff --git a/contrib/libs/curl/lib/curl_ntlm_core.c b/contrib/libs/curl/lib/curl_ntlm_core.c
index d4d8c1b107..b35b566a71 100644
--- a/contrib/libs/curl/lib/curl_ntlm_core.c
+++ b/contrib/libs/curl/lib/curl_ntlm_core.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -22,7 +22,7 @@
#include "curl_setup.h"
-#if defined(USE_CURL_NTLM_CORE)
+#if defined(USE_CURL_NTLM_CORE)
/*
* NTLM details:
@@ -50,18 +50,18 @@
in NTLM type-3 messages.
*/
-#if defined(USE_OPENSSL) || defined(USE_WOLFSSL)
+#if defined(USE_OPENSSL) || defined(USE_WOLFSSL)
-#ifdef USE_WOLFSSL
-#error #include <wolfssl/options.h>
-#endif
+#ifdef USE_WOLFSSL
+#error #include <wolfssl/options.h>
+#endif
# include <openssl/des.h>
# include <openssl/md5.h>
# include <openssl/ssl.h>
# include <openssl/rand.h>
-# if (defined(OPENSSL_VERSION_NUMBER) && \
- (OPENSSL_VERSION_NUMBER < 0x00907001L)) && !defined(USE_WOLFSSL)
+# if (defined(OPENSSL_VERSION_NUMBER) && \
+ (OPENSSL_VERSION_NUMBER < 0x00907001L)) && !defined(USE_WOLFSSL)
# define DES_key_schedule des_key_schedule
# define DES_cblock des_cblock
# define DES_set_odd_parity des_set_odd_parity
@@ -139,7 +139,7 @@ static void extend_key_56_to_64(const unsigned char *key_56, char *key)
key[7] = (unsigned char) ((key_56[6] << 1) & 0xFF);
}
-#if defined(USE_OPENSSL) || defined(USE_WOLFSSL)
+#if defined(USE_OPENSSL) || defined(USE_WOLFSSL)
/*
* Turns a 56 bit key into the 64 bit, odd parity key and sets the key. The
* key schedule ks is also set.
@@ -343,7 +343,7 @@ static bool encrypt_des(const unsigned char *in, unsigned char *out,
/* Acquire the crypto provider */
if(!CryptAcquireContext(&hprov, NULL, NULL, PROV_RSA_FULL,
- CRYPT_VERIFYCONTEXT | CRYPT_SILENT))
+ CRYPT_VERIFYCONTEXT | CRYPT_SILENT))
return FALSE;
/* Setup the key blob structure */
@@ -388,7 +388,7 @@ void Curl_ntlm_core_lm_resp(const unsigned char *keys,
const unsigned char *plaintext,
unsigned char *results)
{
-#if defined(USE_OPENSSL) || defined(USE_WOLFSSL)
+#if defined(USE_OPENSSL) || defined(USE_WOLFSSL)
DES_key_schedule ks;
setup_des_key(keys, DESKEY(ks));
@@ -463,7 +463,7 @@ CURLcode Curl_ntlm_core_mk_lm_hash(struct Curl_easy *data,
{
/* Create LanManager hashed password. */
-#if defined(USE_OPENSSL) || defined(USE_WOLFSSL)
+#if defined(USE_OPENSSL) || defined(USE_WOLFSSL)
DES_key_schedule ks;
setup_des_key(pw, DESKEY(ks));
@@ -580,11 +580,11 @@ CURLcode Curl_ntlm_core_mk_ntlmv2_hash(const char *user, size_t userlen,
unsigned char *identity;
CURLcode result = CURLE_OK;
- if((userlen > CURL_MAX_INPUT_LENGTH) || (domlen > CURL_MAX_INPUT_LENGTH))
+ if((userlen > CURL_MAX_INPUT_LENGTH) || (domlen > CURL_MAX_INPUT_LENGTH))
return CURLE_OUT_OF_MEMORY;
identity_len = (userlen + domlen) * 2;
- identity = malloc(identity_len + 1);
+ identity = malloc(identity_len + 1);
if(!identity)
return CURLE_OUT_OF_MEMORY;
@@ -592,8 +592,8 @@ CURLcode Curl_ntlm_core_mk_ntlmv2_hash(const char *user, size_t userlen,
ascii_uppercase_to_unicode_le(identity, user, userlen);
ascii_to_unicode_le(identity + (userlen << 1), domain, domlen);
- result = Curl_hmacit(Curl_HMAC_MD5, ntlmhash, 16, identity, identity_len,
- ntlmv2hash);
+ result = Curl_hmacit(Curl_HMAC_MD5, ntlmhash, 16, identity, identity_len,
+ ntlmv2hash);
free(identity);
return result;
@@ -639,7 +639,7 @@ CURLcode Curl_ntlm_core_mk_ntlmv2_resp(unsigned char *ntlmv2hash,
unsigned int len = 0;
unsigned char *ptr = NULL;
- unsigned char hmac_output[HMAC_MD5_LENGTH];
+ unsigned char hmac_output[HMAC_MD5_LENGTH];
curl_off_t tw;
CURLcode result = CURLE_OK;
@@ -658,7 +658,7 @@ CURLcode Curl_ntlm_core_mk_ntlmv2_resp(unsigned char *ntlmv2hash,
tw = ((curl_off_t)time(NULL) + CURL_OFF_T_C(11644473600)) * 10000000;
/* Calculate the response len */
- len = HMAC_MD5_LENGTH + NTLMv2_BLOB_LEN;
+ len = HMAC_MD5_LENGTH + NTLMv2_BLOB_LEN;
/* Allocate the response */
ptr = calloc(1, len);
@@ -666,7 +666,7 @@ CURLcode Curl_ntlm_core_mk_ntlmv2_resp(unsigned char *ntlmv2hash,
return CURLE_OUT_OF_MEMORY;
/* Create the BLOB structure */
- msnprintf((char *)ptr + HMAC_MD5_LENGTH, NTLMv2_BLOB_LEN,
+ msnprintf((char *)ptr + HMAC_MD5_LENGTH, NTLMv2_BLOB_LEN,
"%c%c%c%c" /* NTLMv2_BLOB_SIGNATURE */
"%c%c%c%c", /* Reserved = 0 */
NTLMv2_BLOB_SIGNATURE[0], NTLMv2_BLOB_SIGNATURE[1],
@@ -679,7 +679,7 @@ CURLcode Curl_ntlm_core_mk_ntlmv2_resp(unsigned char *ntlmv2hash,
/* Concatenate the Type 2 challenge with the BLOB and do HMAC MD5 */
memcpy(ptr + 8, &ntlm->nonce[0], 8);
- result = Curl_hmacit(Curl_HMAC_MD5, ntlmv2hash, HMAC_MD5_LENGTH, ptr + 8,
+ result = Curl_hmacit(Curl_HMAC_MD5, ntlmv2hash, HMAC_MD5_LENGTH, ptr + 8,
NTLMv2_BLOB_LEN + 8, hmac_output);
if(result) {
free(ptr);
@@ -687,7 +687,7 @@ CURLcode Curl_ntlm_core_mk_ntlmv2_resp(unsigned char *ntlmv2hash,
}
/* Concatenate the HMAC MD5 output with the BLOB */
- memcpy(ptr, hmac_output, HMAC_MD5_LENGTH);
+ memcpy(ptr, hmac_output, HMAC_MD5_LENGTH);
/* Return the response */
*ntresp = ptr;
@@ -722,8 +722,8 @@ CURLcode Curl_ntlm_core_mk_lmv2_resp(unsigned char *ntlmv2hash,
memcpy(&data[0], challenge_server, 8);
memcpy(&data[8], challenge_client, 8);
- result = Curl_hmacit(Curl_HMAC_MD5, ntlmv2hash, 16, &data[0], 16,
- hmac_output);
+ result = Curl_hmacit(Curl_HMAC_MD5, ntlmv2hash, 16, &data[0], 16,
+ hmac_output);
if(result)
return result;
@@ -738,4 +738,4 @@ CURLcode Curl_ntlm_core_mk_lmv2_resp(unsigned char *ntlmv2hash,
#endif /* USE_NTRESPONSES */
-#endif /* USE_CURL_NTLM_CORE */
+#endif /* USE_CURL_NTLM_CORE */
diff --git a/contrib/libs/curl/lib/curl_ntlm_core.h b/contrib/libs/curl/lib/curl_ntlm_core.h
index abd4f5e5c8..0ed1b8d1e9 100644
--- a/contrib/libs/curl/lib/curl_ntlm_core.h
+++ b/contrib/libs/curl/lib/curl_ntlm_core.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -24,22 +24,22 @@
#include "curl_setup.h"
-#if defined(USE_CURL_NTLM_CORE)
+#if defined(USE_CURL_NTLM_CORE)
/* If NSS is the first available SSL backend (see order in curl_ntlm_core.c)
then it must be initialized to be used by NTLM. */
#if !defined(USE_OPENSSL) && \
- !defined(USE_WOLFSSL) && \
+ !defined(USE_WOLFSSL) && \
!defined(USE_GNUTLS_NETTLE) && \
!defined(USE_GNUTLS) && \
defined(USE_NSS)
#define NTLM_NEEDS_NSS_INIT
#endif
-#if defined(USE_OPENSSL) || defined(USE_WOLFSSL)
-#ifdef USE_WOLFSSL
-# error #include <wolfssl/options.h>
-#endif
+#if defined(USE_OPENSSL) || defined(USE_WOLFSSL)
+#ifdef USE_WOLFSSL
+# error #include <wolfssl/options.h>
+#endif
# include <openssl/ssl.h>
#endif
@@ -48,9 +48,9 @@
#define USE_NTRESPONSES
/* Define USE_NTLM2SESSION in order to make the type-3 message include the
- NTLM2Session response message, requires USE_NTRESPONSES defined to 1 and
- MD5 support */
-#if defined(USE_NTRESPONSES) && !defined(CURL_DISABLE_CRYPTO_AUTH)
+ NTLM2Session response message, requires USE_NTRESPONSES defined to 1 and
+ MD5 support */
+#if defined(USE_NTRESPONSES) && !defined(CURL_DISABLE_CRYPTO_AUTH)
#define USE_NTLM2SESSION
#endif
@@ -100,6 +100,6 @@ CURLcode Curl_ntlm_core_mk_lmv2_resp(unsigned char *ntlmv2hash,
#endif /* USE_NTRESPONSES */
-#endif /* USE_CURL_NTLM_CORE */
+#endif /* USE_CURL_NTLM_CORE */
#endif /* HEADER_CURL_NTLM_CORE_H */
diff --git a/contrib/libs/curl/lib/curl_ntlm_wb.c b/contrib/libs/curl/lib/curl_ntlm_wb.c
index e401ce99ec..c11757f557 100644
--- a/contrib/libs/curl/lib/curl_ntlm_wb.c
+++ b/contrib/libs/curl/lib/curl_ntlm_wb.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -76,22 +76,22 @@
# define sclose_nolog(x) close((x))
#endif
-static void ntlm_wb_cleanup(struct ntlmdata *ntlm)
+static void ntlm_wb_cleanup(struct ntlmdata *ntlm)
{
- if(ntlm->ntlm_auth_hlpr_socket != CURL_SOCKET_BAD) {
- sclose(ntlm->ntlm_auth_hlpr_socket);
- ntlm->ntlm_auth_hlpr_socket = CURL_SOCKET_BAD;
+ if(ntlm->ntlm_auth_hlpr_socket != CURL_SOCKET_BAD) {
+ sclose(ntlm->ntlm_auth_hlpr_socket);
+ ntlm->ntlm_auth_hlpr_socket = CURL_SOCKET_BAD;
}
- if(ntlm->ntlm_auth_hlpr_pid) {
+ if(ntlm->ntlm_auth_hlpr_pid) {
int i;
for(i = 0; i < 4; i++) {
- pid_t ret = waitpid(ntlm->ntlm_auth_hlpr_pid, NULL, WNOHANG);
- if(ret == ntlm->ntlm_auth_hlpr_pid || errno == ECHILD)
+ pid_t ret = waitpid(ntlm->ntlm_auth_hlpr_pid, NULL, WNOHANG);
+ if(ret == ntlm->ntlm_auth_hlpr_pid || errno == ECHILD)
break;
switch(i) {
case 0:
- kill(ntlm->ntlm_auth_hlpr_pid, SIGTERM);
+ kill(ntlm->ntlm_auth_hlpr_pid, SIGTERM);
break;
case 1:
/* Give the process another moment to shut down cleanly before
@@ -99,21 +99,21 @@ static void ntlm_wb_cleanup(struct ntlmdata *ntlm)
Curl_wait_ms(1);
break;
case 2:
- kill(ntlm->ntlm_auth_hlpr_pid, SIGKILL);
+ kill(ntlm->ntlm_auth_hlpr_pid, SIGKILL);
break;
case 3:
break;
}
}
- ntlm->ntlm_auth_hlpr_pid = 0;
+ ntlm->ntlm_auth_hlpr_pid = 0;
}
- Curl_safefree(ntlm->challenge);
- Curl_safefree(ntlm->response);
+ Curl_safefree(ntlm->challenge);
+ Curl_safefree(ntlm->response);
}
-static CURLcode ntlm_wb_init(struct Curl_easy *data, struct ntlmdata *ntlm,
- const char *userp)
+static CURLcode ntlm_wb_init(struct Curl_easy *data, struct ntlmdata *ntlm,
+ const char *userp)
{
curl_socket_t sockfds[2];
pid_t child_pid;
@@ -127,13 +127,13 @@ static CURLcode ntlm_wb_init(struct Curl_easy *data, struct ntlmdata *ntlm,
#endif
char buffer[STRERROR_LEN];
-#if defined(CURL_DISABLE_VERBOSE_STRINGS)
- (void) data;
-#endif
-
+#if defined(CURL_DISABLE_VERBOSE_STRINGS)
+ (void) data;
+#endif
+
/* Return if communication with ntlm_auth already set up */
- if(ntlm->ntlm_auth_hlpr_socket != CURL_SOCKET_BAD ||
- ntlm->ntlm_auth_hlpr_pid)
+ if(ntlm->ntlm_auth_hlpr_socket != CURL_SOCKET_BAD ||
+ ntlm->ntlm_auth_hlpr_pid)
return CURLE_OK;
username = userp;
@@ -184,13 +184,13 @@ static CURLcode ntlm_wb_init(struct Curl_easy *data, struct ntlmdata *ntlm,
ntlm_auth = NTLM_WB_FILE;
if(access(ntlm_auth, X_OK) != 0) {
- failf(data, "Could not access ntlm_auth: %s errno %d: %s",
+ failf(data, "Could not access ntlm_auth: %s errno %d: %s",
ntlm_auth, errno, Curl_strerror(errno, buffer, sizeof(buffer)));
goto done;
}
- if(Curl_socketpair(AF_UNIX, SOCK_STREAM, 0, sockfds)) {
- failf(data, "Could not open socket pair. errno %d: %s",
+ if(Curl_socketpair(AF_UNIX, SOCK_STREAM, 0, sockfds)) {
+ failf(data, "Could not open socket pair. errno %d: %s",
errno, Curl_strerror(errno, buffer, sizeof(buffer)));
goto done;
}
@@ -199,7 +199,7 @@ static CURLcode ntlm_wb_init(struct Curl_easy *data, struct ntlmdata *ntlm,
if(child_pid == -1) {
sclose(sockfds[0]);
sclose(sockfds[1]);
- failf(data, "Could not fork. errno %d: %s",
+ failf(data, "Could not fork. errno %d: %s",
errno, Curl_strerror(errno, buffer, sizeof(buffer)));
goto done;
}
@@ -211,13 +211,13 @@ static CURLcode ntlm_wb_init(struct Curl_easy *data, struct ntlmdata *ntlm,
/* Don't use sclose in the child since it fools the socket leak detector */
sclose_nolog(sockfds[0]);
if(dup2(sockfds[1], STDIN_FILENO) == -1) {
- failf(data, "Could not redirect child stdin. errno %d: %s",
+ failf(data, "Could not redirect child stdin. errno %d: %s",
errno, Curl_strerror(errno, buffer, sizeof(buffer)));
exit(1);
}
if(dup2(sockfds[1], STDOUT_FILENO) == -1) {
- failf(data, "Could not redirect child stdout. errno %d: %s",
+ failf(data, "Could not redirect child stdout. errno %d: %s",
errno, Curl_strerror(errno, buffer, sizeof(buffer)));
exit(1);
}
@@ -237,14 +237,14 @@ static CURLcode ntlm_wb_init(struct Curl_easy *data, struct ntlmdata *ntlm,
NULL);
sclose_nolog(sockfds[1]);
- failf(data, "Could not execl(). errno %d: %s",
+ failf(data, "Could not execl(). errno %d: %s",
errno, Curl_strerror(errno, buffer, sizeof(buffer)));
exit(1);
}
sclose(sockfds[1]);
- ntlm->ntlm_auth_hlpr_socket = sockfds[0];
- ntlm->ntlm_auth_hlpr_pid = child_pid;
+ ntlm->ntlm_auth_hlpr_socket = sockfds[0];
+ ntlm->ntlm_auth_hlpr_pid = child_pid;
free(domain);
free(ntlm_auth_alloc);
return CURLE_OK;
@@ -258,17 +258,17 @@ done:
/* if larger than this, something is seriously wrong */
#define MAX_NTLM_WB_RESPONSE 100000
-static CURLcode ntlm_wb_response(struct Curl_easy *data, struct ntlmdata *ntlm,
+static CURLcode ntlm_wb_response(struct Curl_easy *data, struct ntlmdata *ntlm,
const char *input, curlntlm state)
{
size_t len_in = strlen(input), len_out = 0;
- struct dynbuf b;
- char *ptr = NULL;
- unsigned char *buf = (unsigned char *)data->state.buffer;
- Curl_dyn_init(&b, MAX_NTLM_WB_RESPONSE);
+ struct dynbuf b;
+ char *ptr = NULL;
+ unsigned char *buf = (unsigned char *)data->state.buffer;
+ Curl_dyn_init(&b, MAX_NTLM_WB_RESPONSE);
while(len_in > 0) {
- ssize_t written = swrite(ntlm->ntlm_auth_hlpr_socket, input, len_in);
+ ssize_t written = swrite(ntlm->ntlm_auth_hlpr_socket, input, len_in);
if(written == -1) {
/* Interrupted by a signal, retry it */
if(errno == EINTR)
@@ -281,8 +281,8 @@ static CURLcode ntlm_wb_response(struct Curl_easy *data, struct ntlmdata *ntlm,
}
/* Read one line */
while(1) {
- ssize_t size =
- sread(ntlm->ntlm_auth_hlpr_socket, buf, data->set.buffer_size);
+ ssize_t size =
+ sread(ntlm->ntlm_auth_hlpr_socket, buf, data->set.buffer_size);
if(size == -1) {
if(errno == EINTR)
continue;
@@ -291,41 +291,41 @@ static CURLcode ntlm_wb_response(struct Curl_easy *data, struct ntlmdata *ntlm,
else if(size == 0)
goto done;
- if(Curl_dyn_addn(&b, buf, size))
- goto done;
+ if(Curl_dyn_addn(&b, buf, size))
+ goto done;
- len_out = Curl_dyn_len(&b);
- ptr = Curl_dyn_ptr(&b);
- if(len_out && ptr[len_out - 1] == '\n') {
- ptr[len_out - 1] = '\0';
- break; /* done! */
+ len_out = Curl_dyn_len(&b);
+ ptr = Curl_dyn_ptr(&b);
+ if(len_out && ptr[len_out - 1] == '\n') {
+ ptr[len_out - 1] = '\0';
+ break; /* done! */
}
- /* loop */
+ /* loop */
}
/* Samba/winbind installed but not configured */
if(state == NTLMSTATE_TYPE1 &&
len_out == 3 &&
- ptr[0] == 'P' && ptr[1] == 'W')
+ ptr[0] == 'P' && ptr[1] == 'W')
goto done;
/* invalid response */
if(len_out < 4)
goto done;
if(state == NTLMSTATE_TYPE1 &&
- (ptr[0]!='Y' || ptr[1]!='R' || ptr[2]!=' '))
+ (ptr[0]!='Y' || ptr[1]!='R' || ptr[2]!=' '))
goto done;
if(state == NTLMSTATE_TYPE2 &&
- (ptr[0]!='K' || ptr[1]!='K' || ptr[2]!=' ') &&
- (ptr[0]!='A' || ptr[1]!='F' || ptr[2]!=' '))
+ (ptr[0]!='K' || ptr[1]!='K' || ptr[2]!=' ') &&
+ (ptr[0]!='A' || ptr[1]!='F' || ptr[2]!=' '))
goto done;
- ntlm->response = strdup(ptr + 3);
- Curl_dyn_free(&b);
- if(!ntlm->response)
+ ntlm->response = strdup(ptr + 3);
+ Curl_dyn_free(&b);
+ if(!ntlm->response)
return CURLE_OUT_OF_MEMORY;
return CURLE_OK;
done:
- Curl_dyn_free(&b);
+ Curl_dyn_free(&b);
return CURLE_REMOTE_ACCESS_DENIED;
}
@@ -333,7 +333,7 @@ CURLcode Curl_input_ntlm_wb(struct connectdata *conn,
bool proxy,
const char *header)
{
- struct ntlmdata *ntlm = proxy ? &conn->proxyntlm : &conn->ntlm;
+ struct ntlmdata *ntlm = proxy ? &conn->proxyntlm : &conn->ntlm;
curlntlm *state = proxy ? &conn->proxy_ntlm_state : &conn->http_ntlm_state;
if(!checkprefix("NTLM", header))
@@ -344,8 +344,8 @@ CURLcode Curl_input_ntlm_wb(struct connectdata *conn,
header++;
if(*header) {
- ntlm->challenge = strdup(header);
- if(!ntlm->challenge)
+ ntlm->challenge = strdup(header);
+ if(!ntlm->challenge)
return CURLE_OUT_OF_MEMORY;
*state = NTLMSTATE_TYPE2; /* We got a type-2 message */
@@ -376,17 +376,17 @@ CURLcode Curl_input_ntlm_wb(struct connectdata *conn,
* This is for creating ntlm header output by delegating challenge/response
* to Samba's winbind daemon helper ntlm_auth.
*/
-CURLcode Curl_output_ntlm_wb(struct connectdata *conn, bool proxy)
+CURLcode Curl_output_ntlm_wb(struct connectdata *conn, bool proxy)
{
/* point to the address of the pointer that holds the string to send to the
server, which is for a plain host or for a HTTP proxy */
char **allocuserpwd;
/* point to the name and password for this */
const char *userp;
- struct ntlmdata *ntlm;
+ struct ntlmdata *ntlm;
curlntlm *state;
struct auth *authp;
- struct Curl_easy *data = conn->data;
+ struct Curl_easy *data = conn->data;
CURLcode res = CURLE_OK;
@@ -394,20 +394,20 @@ CURLcode Curl_output_ntlm_wb(struct connectdata *conn, bool proxy)
DEBUGASSERT(conn->data);
if(proxy) {
-#ifndef CURL_DISABLE_PROXY
- allocuserpwd = &data->state.aptr.proxyuserpwd;
+#ifndef CURL_DISABLE_PROXY
+ allocuserpwd = &data->state.aptr.proxyuserpwd;
userp = conn->http_proxy.user;
- ntlm = &conn->proxyntlm;
+ ntlm = &conn->proxyntlm;
state = &conn->proxy_ntlm_state;
authp = &conn->data->state.authproxy;
-#else
- return CURLE_NOT_BUILT_IN;
-#endif
+#else
+ return CURLE_NOT_BUILT_IN;
+#endif
}
else {
- allocuserpwd = &data->state.aptr.userpwd;
+ allocuserpwd = &data->state.aptr.userpwd;
userp = conn->user;
- ntlm = &conn->ntlm;
+ ntlm = &conn->ntlm;
state = &conn->http_ntlm_state;
authp = &conn->data->state.authhost;
}
@@ -433,36 +433,36 @@ CURLcode Curl_output_ntlm_wb(struct connectdata *conn, bool proxy)
* request handling process.
*/
/* Create communication with ntlm_auth */
- res = ntlm_wb_init(conn->data, ntlm, userp);
+ res = ntlm_wb_init(conn->data, ntlm, userp);
if(res)
return res;
- res = ntlm_wb_response(conn->data, ntlm, "YR\n", *state);
+ res = ntlm_wb_response(conn->data, ntlm, "YR\n", *state);
if(res)
return res;
free(*allocuserpwd);
- *allocuserpwd = aprintf("%sAuthorization: NTLM %s\r\n",
+ *allocuserpwd = aprintf("%sAuthorization: NTLM %s\r\n",
proxy ? "Proxy-" : "",
- ntlm->response);
+ ntlm->response);
DEBUG_OUT(fprintf(stderr, "**** Header %s\n ", *allocuserpwd));
- Curl_safefree(ntlm->response);
+ Curl_safefree(ntlm->response);
if(!*allocuserpwd)
return CURLE_OUT_OF_MEMORY;
break;
- case NTLMSTATE_TYPE2: {
- char *input = aprintf("TT %s\n", ntlm->challenge);
+ case NTLMSTATE_TYPE2: {
+ char *input = aprintf("TT %s\n", ntlm->challenge);
if(!input)
return CURLE_OUT_OF_MEMORY;
- res = ntlm_wb_response(conn->data, ntlm, input, *state);
+ res = ntlm_wb_response(conn->data, ntlm, input, *state);
free(input);
if(res)
return res;
free(*allocuserpwd);
- *allocuserpwd = aprintf("%sAuthorization: NTLM %s\r\n",
+ *allocuserpwd = aprintf("%sAuthorization: NTLM %s\r\n",
proxy ? "Proxy-" : "",
- ntlm->response);
+ ntlm->response);
DEBUG_OUT(fprintf(stderr, "**** %s\n ", *allocuserpwd));
*state = NTLMSTATE_TYPE3; /* we sent a type-3 */
authp->done = TRUE;
@@ -470,7 +470,7 @@ CURLcode Curl_output_ntlm_wb(struct connectdata *conn, bool proxy)
if(!*allocuserpwd)
return CURLE_OUT_OF_MEMORY;
break;
- }
+ }
case NTLMSTATE_TYPE3:
/* connection is already authenticated,
* don't send a header in future requests */
@@ -485,10 +485,10 @@ CURLcode Curl_output_ntlm_wb(struct connectdata *conn, bool proxy)
return CURLE_OK;
}
-void Curl_http_auth_cleanup_ntlm_wb(struct connectdata *conn)
-{
- ntlm_wb_cleanup(&conn->ntlm);
- ntlm_wb_cleanup(&conn->proxyntlm);
-}
-
+void Curl_http_auth_cleanup_ntlm_wb(struct connectdata *conn)
+{
+ ntlm_wb_cleanup(&conn->ntlm);
+ ntlm_wb_cleanup(&conn->proxyntlm);
+}
+
#endif /* !CURL_DISABLE_HTTP && USE_NTLM && NTLM_WB_ENABLED */
diff --git a/contrib/libs/curl/lib/curl_ntlm_wb.h b/contrib/libs/curl/lib/curl_ntlm_wb.h
index 1bf99088fd..4f847d22ca 100644
--- a/contrib/libs/curl/lib/curl_ntlm_wb.h
+++ b/contrib/libs/curl/lib/curl_ntlm_wb.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/curl_path.c b/contrib/libs/curl/lib/curl_path.c
index 098b471a33..8c8cbc2468 100644
--- a/contrib/libs/curl/lib/curl_path.c
+++ b/contrib/libs/curl/lib/curl_path.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -42,7 +42,7 @@ CURLcode Curl_getworkingpath(struct connectdata *conn,
size_t working_path_len;
CURLcode result =
Curl_urldecode(data, data->state.up.path, 0, &working_path,
- &working_path_len, REJECT_ZERO);
+ &working_path_len, REJECT_ZERO);
if(result)
return result;
@@ -168,7 +168,7 @@ CURLcode Curl_get_pathname(const char **cpp, char **path, char *homedir)
*cpp = cp + i + strspn(cp + i, WHITESPACE);
}
else {
- /* Read to end of filename - either to whitespace or terminator */
+ /* Read to end of filename - either to whitespace or terminator */
end = strpbrk(cp, WHITESPACE);
if(end == NULL)
end = strchr(cp, '\0');
@@ -184,7 +184,7 @@ CURLcode Curl_get_pathname(const char **cpp, char **path, char *homedir)
(*path)[pathLength] = '\0';
cp += 3;
}
- /* Copy path name up until first "whitespace" */
+ /* Copy path name up until first "whitespace" */
memcpy(&(*path)[pathLength], cp, (int)(end - cp));
pathLength += (int)(end - cp);
(*path)[pathLength] = '\0';
diff --git a/contrib/libs/curl/lib/curl_path.h b/contrib/libs/curl/lib/curl_path.h
index fcb8b6abe6..b601b48dfc 100644
--- a/contrib/libs/curl/lib/curl_path.h
+++ b/contrib/libs/curl/lib/curl_path.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/curl_printf.h b/contrib/libs/curl/lib/curl_printf.h
index a398bd6e3f..9fa625f108 100644
--- a/contrib/libs/curl/lib/curl_printf.h
+++ b/contrib/libs/curl/lib/curl_printf.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/curl_range.c b/contrib/libs/curl/lib/curl_range.c
index 075830bf8f..0a87b1ca52 100644
--- a/contrib/libs/curl/lib/curl_range.c
+++ b/contrib/libs/curl/lib/curl_range.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/curl_range.h b/contrib/libs/curl/lib/curl_range.h
index 8b938a11c3..d1f2c6d55f 100644
--- a/contrib/libs/curl/lib/curl_range.h
+++ b/contrib/libs/curl/lib/curl_range.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/curl_rtmp.c b/contrib/libs/curl/lib/curl_rtmp.c
index f7d9ad0387..ba471a2a19 100644
--- a/contrib/libs/curl/lib/curl_rtmp.c
+++ b/contrib/libs/curl/lib/curl_rtmp.c
@@ -5,12 +5,12 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 2012 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2012 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 2010, Howard Chu, <hyc@highlandsun.com>
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -79,7 +79,7 @@ const struct Curl_handler Curl_handler_rtmp = {
ZERO_NULL, /* connection_check */
PORT_RTMP, /* defport */
CURLPROTO_RTMP, /* protocol */
- CURLPROTO_RTMP, /* family */
+ CURLPROTO_RTMP, /* family */
PROTOPT_NONE /* flags*/
};
@@ -101,7 +101,7 @@ const struct Curl_handler Curl_handler_rtmpt = {
ZERO_NULL, /* connection_check */
PORT_RTMPT, /* defport */
CURLPROTO_RTMPT, /* protocol */
- CURLPROTO_RTMPT, /* family */
+ CURLPROTO_RTMPT, /* family */
PROTOPT_NONE /* flags*/
};
@@ -123,7 +123,7 @@ const struct Curl_handler Curl_handler_rtmpe = {
ZERO_NULL, /* connection_check */
PORT_RTMP, /* defport */
CURLPROTO_RTMPE, /* protocol */
- CURLPROTO_RTMPE, /* family */
+ CURLPROTO_RTMPE, /* family */
PROTOPT_NONE /* flags*/
};
@@ -145,7 +145,7 @@ const struct Curl_handler Curl_handler_rtmpte = {
ZERO_NULL, /* connection_check */
PORT_RTMPT, /* defport */
CURLPROTO_RTMPTE, /* protocol */
- CURLPROTO_RTMPTE, /* family */
+ CURLPROTO_RTMPTE, /* family */
PROTOPT_NONE /* flags*/
};
@@ -167,7 +167,7 @@ const struct Curl_handler Curl_handler_rtmps = {
ZERO_NULL, /* connection_check */
PORT_RTMPS, /* defport */
CURLPROTO_RTMPS, /* protocol */
- CURLPROTO_RTMP, /* family */
+ CURLPROTO_RTMP, /* family */
PROTOPT_NONE /* flags*/
};
@@ -189,7 +189,7 @@ const struct Curl_handler Curl_handler_rtmpts = {
ZERO_NULL, /* connection_check */
PORT_RTMPS, /* defport */
CURLPROTO_RTMPTS, /* protocol */
- CURLPROTO_RTMPT, /* family */
+ CURLPROTO_RTMPT, /* family */
PROTOPT_NONE /* flags*/
};
diff --git a/contrib/libs/curl/lib/curl_rtmp.h b/contrib/libs/curl/lib/curl_rtmp.h
index 4c70fd1872..f45fa71d12 100644
--- a/contrib/libs/curl/lib/curl_rtmp.h
+++ b/contrib/libs/curl/lib/curl_rtmp.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 2010 - 2020, Howard Chu, <hyc@highlandsun.com>
+ * Copyright (C) 2010 - 2020, Howard Chu, <hyc@highlandsun.com>
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/curl_sasl.c b/contrib/libs/curl/lib/curl_sasl.c
index 3be2d901bd..94b17a1d86 100644
--- a/contrib/libs/curl/lib/curl_sasl.c
+++ b/contrib/libs/curl/lib/curl_sasl.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 2012 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2012 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -264,20 +264,20 @@ CURLcode Curl_sasl_start(struct SASL *sasl, struct connectdata *conn,
size_t len = 0;
saslstate state1 = SASL_STOP;
saslstate state2 = SASL_FINAL;
-#ifndef CURL_DISABLE_PROXY
+#ifndef CURL_DISABLE_PROXY
const char * const hostname = SSL_IS_PROXY() ? conn->http_proxy.host.name :
conn->host.name;
const long int port = SSL_IS_PROXY() ? conn->port : conn->remote_port;
-#else
- const char * const hostname = conn->host.name;
- const long int port = conn->remote_port;
-#endif
+#else
+ const char * const hostname = conn->host.name;
+ const long int port = conn->remote_port;
+#endif
#if defined(USE_KERBEROS5) || defined(USE_NTLM)
const char *service = data->set.str[STRING_SERVICE_NAME] ?
data->set.str[STRING_SERVICE_NAME] :
sasl->params->service;
#endif
- const char *oauth_bearer = data->set.str[STRING_BEARER];
+ const char *oauth_bearer = data->set.str[STRING_BEARER];
sasl->force_ir = force_ir; /* Latch for future use */
sasl->authused = 0; /* No mechanism used yet */
@@ -347,7 +347,7 @@ CURLcode Curl_sasl_start(struct SASL *sasl, struct connectdata *conn,
}
else
#endif
- if((enabledmechs & SASL_MECH_OAUTHBEARER) && oauth_bearer) {
+ if((enabledmechs & SASL_MECH_OAUTHBEARER) && oauth_bearer) {
mech = SASL_MECH_STRING_OAUTHBEARER;
state1 = SASL_OAUTH2;
state2 = SASL_OAUTH2_RESP;
@@ -357,17 +357,17 @@ CURLcode Curl_sasl_start(struct SASL *sasl, struct connectdata *conn,
result = Curl_auth_create_oauth_bearer_message(data, conn->user,
hostname,
port,
- oauth_bearer,
+ oauth_bearer,
&resp, &len);
}
- else if((enabledmechs & SASL_MECH_XOAUTH2) && oauth_bearer) {
+ else if((enabledmechs & SASL_MECH_XOAUTH2) && oauth_bearer) {
mech = SASL_MECH_STRING_XOAUTH2;
state1 = SASL_OAUTH2;
sasl->authused = SASL_MECH_XOAUTH2;
if(force_ir || data->set.sasl_ir)
result = Curl_auth_create_xoauth_bearer_message(data, conn->user,
- oauth_bearer,
+ oauth_bearer,
&resp, &len);
}
else if(enabledmechs & SASL_MECH_PLAIN) {
@@ -422,27 +422,27 @@ CURLcode Curl_sasl_continue(struct SASL *sasl, struct connectdata *conn,
struct Curl_easy *data = conn->data;
saslstate newstate = SASL_FINAL;
char *resp = NULL;
-#ifndef CURL_DISABLE_PROXY
+#ifndef CURL_DISABLE_PROXY
const char * const hostname = SSL_IS_PROXY() ? conn->http_proxy.host.name :
conn->host.name;
const long int port = SSL_IS_PROXY() ? conn->port : conn->remote_port;
-#else
- const char * const hostname = conn->host.name;
- const long int port = conn->remote_port;
-#endif
+#else
+ const char * const hostname = conn->host.name;
+ const long int port = conn->remote_port;
+#endif
#if !defined(CURL_DISABLE_CRYPTO_AUTH)
char *chlg = NULL;
size_t chlglen = 0;
#endif
-#if !defined(CURL_DISABLE_CRYPTO_AUTH) || defined(USE_KERBEROS5) || \
- defined(USE_NTLM)
+#if !defined(CURL_DISABLE_CRYPTO_AUTH) || defined(USE_KERBEROS5) || \
+ defined(USE_NTLM)
const char *service = data->set.str[STRING_SERVICE_NAME] ?
- data->set.str[STRING_SERVICE_NAME] :
- sasl->params->service;
+ data->set.str[STRING_SERVICE_NAME] :
+ sasl->params->service;
char *serverdata;
#endif
size_t len = 0;
- const char *oauth_bearer = data->set.str[STRING_BEARER];
+ const char *oauth_bearer = data->set.str[STRING_BEARER];
*progress = SASL_INPROGRESS;
@@ -570,7 +570,7 @@ CURLcode Curl_sasl_continue(struct SASL *sasl, struct connectdata *conn,
result = Curl_auth_create_oauth_bearer_message(data, conn->user,
hostname,
port,
- oauth_bearer,
+ oauth_bearer,
&resp, &len);
/* Failures maybe sent by the server as continuations for OAUTHBEARER */
@@ -578,7 +578,7 @@ CURLcode Curl_sasl_continue(struct SASL *sasl, struct connectdata *conn,
}
else
result = Curl_auth_create_xoauth_bearer_message(data, conn->user,
- oauth_bearer,
+ oauth_bearer,
&resp, &len);
break;
diff --git a/contrib/libs/curl/lib/curl_sasl.h b/contrib/libs/curl/lib/curl_sasl.h
index 4b6bb7ae2c..ba40ec461a 100644
--- a/contrib/libs/curl/lib/curl_sasl.h
+++ b/contrib/libs/curl/lib/curl_sasl.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 2012 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2012 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/curl_setup.h b/contrib/libs/curl/lib/curl_setup.h
index 7cf94f56ac..83fabb0e01 100644
--- a/contrib/libs/curl/lib/curl_setup.h
+++ b/contrib/libs/curl/lib/curl_setup.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -27,18 +27,18 @@
#endif
/*
- * Disable Visual Studio warnings:
- * 4127 "conditional expression is constant"
- */
-#ifdef _MSC_VER
-#pragma warning(disable:4127)
-#endif
-
-/*
+ * Disable Visual Studio warnings:
+ * 4127 "conditional expression is constant"
+ */
+#ifdef _MSC_VER
+#pragma warning(disable:4127)
+#endif
+
+/*
* Define WIN32 when build target is Win32 API
*/
-#if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32)
+#if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32)
#define WIN32
#endif
@@ -226,20 +226,20 @@
#endif
/*
- * Windows setup file includes some system headers.
+ * Windows setup file includes some system headers.
*/
#ifdef HAVE_WINDOWS_H
-# include "setup-win32.h"
+# include "setup-win32.h"
#endif
/*
- * Use getaddrinfo to resolve the IPv4 address literal. If the current network
- * interface doesn't support IPv4, but supports IPv6, NAT64, and DNS64,
- * performing this task will result in a synthesized IPv6 address.
+ * Use getaddrinfo to resolve the IPv4 address literal. If the current network
+ * interface doesn't support IPv4, but supports IPv6, NAT64, and DNS64,
+ * performing this task will result in a synthesized IPv6 address.
*/
-#if defined(__APPLE__) && !defined(USE_ARES)
-#define USE_RESOLVE_ON_IPS 1
+#if defined(__APPLE__) && !defined(USE_ARES)
+#define USE_RESOLVE_ON_IPS 1
#endif
#ifdef USE_LWIPSOCK
@@ -277,16 +277,16 @@
# include <exec/execbase.h>
# include <proto/exec.h>
# include <proto/dos.h>
-# include <unistd.h>
+# include <unistd.h>
# ifdef HAVE_PROTO_BSDSOCKET_H
# error #include <proto/bsdsocket.h> /* ensure bsdsocket.library use */
# define select(a,b,c,d,e) WaitSelect(a,b,c,d,e,0)
# endif
-/*
- * In clib2 arpa/inet.h warns that some prototypes may clash
- * with bsdsocket.library. This avoids the definition of those.
- */
-# define __NO_NET_API
+/*
+ * In clib2 arpa/inet.h warns that some prototypes may clash
+ * with bsdsocket.library. This avoids the definition of those.
+ */
+# define __NO_NET_API
#endif
#include <stdio.h>
@@ -332,14 +332,14 @@
# undef fstat
# define fstat(fdes,stp) _fstati64(fdes, stp)
# undef stat
-# define stat(fname,stp) curlx_win32_stat(fname, stp)
+# define stat(fname,stp) curlx_win32_stat(fname, stp)
# define struct_stat struct _stati64
# define LSEEK_ERROR (__int64)-1
-# define fopen(fname,mode) curlx_win32_fopen(fname, mode)
-# define access(fname,mode) curlx_win32_access(fname, mode)
- int curlx_win32_stat(const char *path, struct_stat *buffer);
- FILE *curlx_win32_fopen(const char *filename, const char *mode);
- int curlx_win32_access(const char *path, int mode);
+# define fopen(fname,mode) curlx_win32_fopen(fname, mode)
+# define access(fname,mode) curlx_win32_access(fname, mode)
+ int curlx_win32_stat(const char *path, struct_stat *buffer);
+ FILE *curlx_win32_fopen(const char *filename, const char *mode);
+ int curlx_win32_access(const char *path, int mode);
#endif
/*
@@ -354,13 +354,13 @@
# undef lseek
# define lseek(fdes,offset,whence) _lseek(fdes, (long)offset, whence)
# define fstat(fdes,stp) _fstat(fdes, stp)
-# define stat(fname,stp) curlx_win32_stat(fname, stp)
+# define stat(fname,stp) curlx_win32_stat(fname, stp)
# define struct_stat struct _stat
-# define fopen(fname,mode) curlx_win32_fopen(fname, mode)
-# define access(fname,mode) curlx_win32_access(fname, mode)
- int curlx_win32_stat(const char *path, struct_stat *buffer);
- FILE *curlx_win32_fopen(const char *filename, const char *mode);
- int curlx_win32_access(const char *path, int mode);
+# define fopen(fname,mode) curlx_win32_fopen(fname, mode)
+# define access(fname,mode) curlx_win32_access(fname, mode)
+ int curlx_win32_stat(const char *path, struct_stat *buffer);
+ FILE *curlx_win32_fopen(const char *filename, const char *mode);
+ int curlx_win32_access(const char *path, int mode);
# endif
# define LSEEK_ERROR (long)-1
#endif
@@ -538,12 +538,12 @@
* Mutually exclusive CURLRES_* definitions.
*/
-#if defined(ENABLE_IPV6) && defined(HAVE_GETADDRINFO)
-# define CURLRES_IPV6
-#else
-# define CURLRES_IPV4
-#endif
-
+#if defined(ENABLE_IPV6) && defined(HAVE_GETADDRINFO)
+# define CURLRES_IPV6
+#else
+# define CURLRES_IPV4
+#endif
+
#ifdef USE_ARES
# define CURLRES_ASYNCH
# define CURLRES_ARES
@@ -611,8 +611,8 @@ int netware_init(void);
#if defined(USE_GNUTLS) || defined(USE_OPENSSL) || defined(USE_NSS) || \
defined(USE_MBEDTLS) || \
defined(USE_WOLFSSL) || defined(USE_SCHANNEL) || \
- defined(USE_SECTRANSP) || defined(USE_GSKIT) || defined(USE_MESALINK) || \
- defined(USE_BEARSSL)
+ defined(USE_SECTRANSP) || defined(USE_GSKIT) || defined(USE_MESALINK) || \
+ defined(USE_BEARSSL)
#define USE_SSL /* SSL support has been enabled */
#endif
@@ -630,12 +630,12 @@ int netware_init(void);
/* Single point where USE_NTLM definition might be defined */
#if !defined(CURL_DISABLE_NTLM) && !defined(CURL_DISABLE_CRYPTO_AUTH)
-#if defined(USE_OPENSSL) || defined(USE_MBEDTLS) || \
- defined(USE_GNUTLS) || defined(USE_NSS) || defined(USE_SECTRANSP) || \
- defined(USE_OS400CRYPTO) || defined(USE_WIN32_CRYPTO) || \
- (defined(USE_WOLFSSL) && defined(HAVE_WOLFSSL_DES_ECB_ENCRYPT))
+#if defined(USE_OPENSSL) || defined(USE_MBEDTLS) || \
+ defined(USE_GNUTLS) || defined(USE_NSS) || defined(USE_SECTRANSP) || \
+ defined(USE_OS400CRYPTO) || defined(USE_WIN32_CRYPTO) || \
+ (defined(USE_WOLFSSL) && defined(HAVE_WOLFSSL_DES_ECB_ENCRYPT))
-#define USE_CURL_NTLM_CORE
+#define USE_CURL_NTLM_CORE
# if defined(USE_MBEDTLS)
/* Get definition of MBEDTLS_MD4_C */
@@ -643,11 +643,11 @@ int netware_init(void);
# endif
#endif
-
-#if defined(USE_CURL_NTLM_CORE) || defined(USE_WINDOWS_SSPI)
-#define USE_NTLM
+
+#if defined(USE_CURL_NTLM_CORE) || defined(USE_WINDOWS_SSPI)
+#define USE_NTLM
+#endif
#endif
-#endif
#ifdef CURL_WANTS_CA_BUNDLE_ENV
#error "No longer supported. Set CURLOPT_CAINFO at runtime instead."
@@ -685,7 +685,7 @@ int netware_init(void);
*/
#ifndef Curl_nop_stmt
-# define Curl_nop_stmt do { } while(0)
+# define Curl_nop_stmt do { } while(0)
#endif
/*
@@ -698,7 +698,7 @@ int netware_init(void);
defined(HAVE_WINSOCK_H) || \
defined(HAVE_WINSOCK2_H) || \
defined(HAVE_WS2TCPIP_H)
-# error "WinSock and lwIP TCP/IP stack definitions shall not coexist!"
+# error "WinSock and lwIP TCP/IP stack definitions shall not coexist!"
# endif
#endif
diff --git a/contrib/libs/curl/lib/curl_setup_once.h b/contrib/libs/curl/lib/curl_setup_once.h
index a69d6d8c78..ef60bc7ae7 100644
--- a/contrib/libs/curl/lib/curl_setup_once.h
+++ b/contrib/libs/curl/lib/curl_setup_once.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -366,7 +366,7 @@ typedef int sig_atomic_t;
#ifdef DEBUGBUILD
#define DEBUGF(x) x
#else
-#define DEBUGF(x) do { } while(0)
+#define DEBUGF(x) do { } while(0)
#endif
@@ -374,11 +374,11 @@ typedef int sig_atomic_t;
* Macro used to include assertion code only in debug builds.
*/
-#undef DEBUGASSERT
+#undef DEBUGASSERT
#if defined(DEBUGBUILD) && defined(HAVE_ASSERT_H)
#define DEBUGASSERT(x) assert(x)
#else
-#define DEBUGASSERT(x) do { } while(0)
+#define DEBUGASSERT(x) do { } while(0)
#endif
@@ -481,8 +481,8 @@ typedef int sig_atomic_t;
#ifdef __VMS
#define argv_item_t __char_ptr32
-#elif defined(_UNICODE)
-#define argv_item_t wchar_t *
+#elif defined(_UNICODE)
+#define argv_item_t wchar_t *
#else
#define argv_item_t char *
#endif
diff --git a/contrib/libs/curl/lib/curl_sha256.h b/contrib/libs/curl/lib/curl_sha256.h
index 103fae33b8..0fceb6329a 100644
--- a/contrib/libs/curl/lib/curl_sha256.h
+++ b/contrib/libs/curl/lib/curl_sha256.h
@@ -7,12 +7,12 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 2017, Florin Petriuc, <petriuc.florin@gmail.com>
- * Copyright (C) 2018 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2017, Florin Petriuc, <petriuc.florin@gmail.com>
+ * Copyright (C) 2018 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -25,11 +25,11 @@
#ifndef CURL_DISABLE_CRYPTO_AUTH
-#define SHA256_DIGEST_LENGTH 32
+#define SHA256_DIGEST_LENGTH 32
+
+void Curl_sha256it(unsigned char *outbuffer, const unsigned char *input,
+ const size_t len);
-void Curl_sha256it(unsigned char *outbuffer, const unsigned char *input,
- const size_t len);
-
#endif
#endif /* HEADER_CURL_SHA256_H */
diff --git a/contrib/libs/curl/lib/curl_sspi.c b/contrib/libs/curl/lib/curl_sspi.c
index 0409c32c11..06841ddec6 100644
--- a/contrib/libs/curl/lib/curl_sspi.c
+++ b/contrib/libs/curl/lib/curl_sspi.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -28,7 +28,7 @@
#include "curl_sspi.h"
#include "curl_multibyte.h"
#include "system_win32.h"
-#include "version_win32.h"
+#include "version_win32.h"
#include "warnless.h"
/* The last #include files should be: */
@@ -83,7 +83,7 @@ CURLcode Curl_sspi_global_init(void)
* have both these DLLs (security.dll forwards calls to secur32.dll) */
/* Load SSPI dll into the address space of the calling process */
- if(curlx_verify_windows_version(4, 0, PLATFORM_WINNT, VERSION_EQUAL))
+ if(curlx_verify_windows_version(4, 0, PLATFORM_WINNT, VERSION_EQUAL))
s_hSecDll = Curl_load_library(TEXT("security.dll"));
else
s_hSecDll = Curl_load_library(TEXT("secur32.dll"));
@@ -152,7 +152,7 @@ CURLcode Curl_create_sspi_identity(const char *userp, const char *passwdp,
/* Initialize the identity */
memset(identity, 0, sizeof(*identity));
- useranddomain.tchar_ptr = curlx_convert_UTF8_to_tchar((char *)userp);
+ useranddomain.tchar_ptr = curlx_convert_UTF8_to_tchar((char *)userp);
if(!useranddomain.tchar_ptr)
return CURLE_OUT_OF_MEMORY;
@@ -174,7 +174,7 @@ CURLcode Curl_create_sspi_identity(const char *userp, const char *passwdp,
/* Setup the identity's user and length */
dup_user.tchar_ptr = _tcsdup(user.tchar_ptr);
if(!dup_user.tchar_ptr) {
- curlx_unicodefree(useranddomain.tchar_ptr);
+ curlx_unicodefree(useranddomain.tchar_ptr);
return CURLE_OUT_OF_MEMORY;
}
identity->User = dup_user.tbyte_ptr;
@@ -184,7 +184,7 @@ CURLcode Curl_create_sspi_identity(const char *userp, const char *passwdp,
/* Setup the identity's domain and length */
dup_domain.tchar_ptr = malloc(sizeof(TCHAR) * (domlen + 1));
if(!dup_domain.tchar_ptr) {
- curlx_unicodefree(useranddomain.tchar_ptr);
+ curlx_unicodefree(useranddomain.tchar_ptr);
return CURLE_OUT_OF_MEMORY;
}
_tcsncpy(dup_domain.tchar_ptr, domain.tchar_ptr, domlen);
@@ -193,22 +193,22 @@ CURLcode Curl_create_sspi_identity(const char *userp, const char *passwdp,
identity->DomainLength = curlx_uztoul(domlen);
dup_domain.tchar_ptr = NULL;
- curlx_unicodefree(useranddomain.tchar_ptr);
+ curlx_unicodefree(useranddomain.tchar_ptr);
/* Setup the identity's password and length */
- passwd.tchar_ptr = curlx_convert_UTF8_to_tchar((char *)passwdp);
+ passwd.tchar_ptr = curlx_convert_UTF8_to_tchar((char *)passwdp);
if(!passwd.tchar_ptr)
return CURLE_OUT_OF_MEMORY;
dup_passwd.tchar_ptr = _tcsdup(passwd.tchar_ptr);
if(!dup_passwd.tchar_ptr) {
- curlx_unicodefree(passwd.tchar_ptr);
+ curlx_unicodefree(passwd.tchar_ptr);
return CURLE_OUT_OF_MEMORY;
}
identity->Password = dup_passwd.tbyte_ptr;
identity->PasswordLength = curlx_uztoul(_tcslen(dup_passwd.tchar_ptr));
dup_passwd.tchar_ptr = NULL;
- curlx_unicodefree(passwd.tchar_ptr);
+ curlx_unicodefree(passwd.tchar_ptr);
/* Setup the identity's flags */
identity->Flags = SECFLAG_WINNT_AUTH_IDENTITY;
diff --git a/contrib/libs/curl/lib/curl_sspi.h b/contrib/libs/curl/lib/curl_sspi.h
index 9a928c4217..881384d4e4 100644
--- a/contrib/libs/curl/lib/curl_sspi.h
+++ b/contrib/libs/curl/lib/curl_sspi.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/curl_threads.c b/contrib/libs/curl/lib/curl_threads.c
index 021d2dda04..414614401d 100644
--- a/contrib/libs/curl/lib/curl_threads.c
+++ b/contrib/libs/curl/lib/curl_threads.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -41,14 +41,14 @@
#if defined(USE_THREADS_POSIX)
-struct Curl_actual_call {
+struct Curl_actual_call {
unsigned int (*func)(void *);
void *arg;
};
static void *curl_thread_create_thunk(void *arg)
{
- struct Curl_actual_call *ac = arg;
+ struct Curl_actual_call *ac = arg;
unsigned int (*func)(void *) = ac->func;
void *real_arg = ac->arg;
@@ -62,7 +62,7 @@ static void *curl_thread_create_thunk(void *arg)
curl_thread_t Curl_thread_create(unsigned int (*func) (void *), void *arg)
{
curl_thread_t t = malloc(sizeof(pthread_t));
- struct Curl_actual_call *ac = malloc(sizeof(struct Curl_actual_call));
+ struct Curl_actual_call *ac = malloc(sizeof(struct Curl_actual_call));
if(!(ac && t))
goto err;
diff --git a/contrib/libs/curl/lib/curl_threads.h b/contrib/libs/curl/lib/curl_threads.h
index bd28b3c650..55fc0ac559 100644
--- a/contrib/libs/curl/lib/curl_threads.h
+++ b/contrib/libs/curl/lib/curl_threads.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/curlx.h b/contrib/libs/curl/lib/curlx.h
index 4ade9f2fb5..9f21f60d5f 100644
--- a/contrib/libs/curl/lib/curlx.h
+++ b/contrib/libs/curl/lib/curlx.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -53,19 +53,19 @@
curlx_uztosi()
*/
-#include "curl_multibyte.h"
-/* "curl_multibyte.h" provides these functions and macros:
-
- curlx_convert_UTF8_to_wchar()
- curlx_convert_wchar_to_UTF8()
- curlx_convert_UTF8_to_tchar()
- curlx_convert_tchar_to_UTF8()
- curlx_unicodefree()
-*/
-
-#include "version_win32.h"
-/* "version_win32.h" provides curlx_verify_windows_version() */
-
+#include "curl_multibyte.h"
+/* "curl_multibyte.h" provides these functions and macros:
+
+ curlx_convert_UTF8_to_wchar()
+ curlx_convert_wchar_to_UTF8()
+ curlx_convert_UTF8_to_tchar()
+ curlx_convert_tchar_to_UTF8()
+ curlx_unicodefree()
+*/
+
+#include "version_win32.h"
+/* "version_win32.h" provides curlx_verify_windows_version() */
+
/* Now setup curlx_ * names for the functions that are to become curlx_ and
be removed from a future libcurl official API:
curlx_getenv
diff --git a/contrib/libs/curl/lib/dict.c b/contrib/libs/curl/lib/dict.c
index cc033be0cf..15d3954aa3 100644
--- a/contrib/libs/curl/lib/dict.c
+++ b/contrib/libs/curl/lib/dict.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -46,8 +46,8 @@
#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
-#elif defined(HAVE_UNISTD_H)
-#include <unistd.h>
+#elif defined(HAVE_UNISTD_H)
+#include <unistd.h>
#endif
#include "urldata.h"
@@ -57,7 +57,7 @@
#include "escape.h"
#include "progress.h"
#include "dict.h"
-#include "curl_printf.h"
+#include "curl_printf.h"
#include "strcase.h"
#include "curl_memory.h"
/* The last #include file should be: */
@@ -91,8 +91,8 @@ const struct Curl_handler Curl_handler_dict = {
ZERO_NULL, /* connection_check */
PORT_DICT, /* defport */
CURLPROTO_DICT, /* protocol */
- CURLPROTO_DICT, /* family */
- PROTOPT_NONE | PROTOPT_NOURLQUERY /* flags */
+ CURLPROTO_DICT, /* family */
+ PROTOPT_NONE | PROTOPT_NOURLQUERY /* flags */
};
static char *unescape_word(struct Curl_easy *data, const char *inputbuff)
@@ -101,8 +101,8 @@ static char *unescape_word(struct Curl_easy *data, const char *inputbuff)
char *dictp;
size_t len;
- CURLcode result = Curl_urldecode(data, inputbuff, 0, &newp, &len,
- REJECT_NADA);
+ CURLcode result = Curl_urldecode(data, inputbuff, 0, &newp, &len,
+ REJECT_NADA);
if(!newp || result)
return NULL;
@@ -128,51 +128,51 @@ static char *unescape_word(struct Curl_easy *data, const char *inputbuff)
return dictp;
}
-/* sendf() sends formatted data to the server */
-static CURLcode sendf(curl_socket_t sockfd, struct connectdata *conn,
- const char *fmt, ...)
-{
- struct Curl_easy *data = conn->data;
- ssize_t bytes_written;
- size_t write_len;
- CURLcode result = CURLE_OK;
- char *s;
- char *sptr;
- va_list ap;
- va_start(ap, fmt);
- s = vaprintf(fmt, ap); /* returns an allocated string */
- va_end(ap);
- if(!s)
- return CURLE_OUT_OF_MEMORY; /* failure */
-
- bytes_written = 0;
- write_len = strlen(s);
- sptr = s;
-
- for(;;) {
- /* Write the buffer to the socket */
- result = Curl_write(conn, sockfd, sptr, write_len, &bytes_written);
-
- if(result)
- break;
-
- Curl_debug(data, CURLINFO_DATA_OUT, sptr, (size_t)bytes_written);
-
- if((size_t)bytes_written != write_len) {
- /* if not all was written at once, we must advance the pointer, decrease
- the size left and try again! */
- write_len -= bytes_written;
- sptr += bytes_written;
- }
- else
- break;
- }
-
- free(s); /* free the output string */
-
- return result;
-}
-
+/* sendf() sends formatted data to the server */
+static CURLcode sendf(curl_socket_t sockfd, struct connectdata *conn,
+ const char *fmt, ...)
+{
+ struct Curl_easy *data = conn->data;
+ ssize_t bytes_written;
+ size_t write_len;
+ CURLcode result = CURLE_OK;
+ char *s;
+ char *sptr;
+ va_list ap;
+ va_start(ap, fmt);
+ s = vaprintf(fmt, ap); /* returns an allocated string */
+ va_end(ap);
+ if(!s)
+ return CURLE_OUT_OF_MEMORY; /* failure */
+
+ bytes_written = 0;
+ write_len = strlen(s);
+ sptr = s;
+
+ for(;;) {
+ /* Write the buffer to the socket */
+ result = Curl_write(conn, sockfd, sptr, write_len, &bytes_written);
+
+ if(result)
+ break;
+
+ Curl_debug(data, CURLINFO_DATA_OUT, sptr, (size_t)bytes_written);
+
+ if((size_t)bytes_written != write_len) {
+ /* if not all was written at once, we must advance the pointer, decrease
+ the size left and try again! */
+ write_len -= bytes_written;
+ sptr += bytes_written;
+ }
+ else
+ break;
+ }
+
+ free(s); /* free the output string */
+
+ return result;
+}
+
static CURLcode dict_do(struct connectdata *conn, bool *done)
{
char *word;
@@ -230,16 +230,16 @@ static CURLcode dict_do(struct connectdata *conn, bool *done)
if(!eword)
return CURLE_OUT_OF_MEMORY;
- result = sendf(sockfd, conn,
- "CLIENT " LIBCURL_NAME " " LIBCURL_VERSION "\r\n"
- "MATCH "
- "%s " /* database */
- "%s " /* strategy */
- "%s\r\n" /* word */
- "QUIT\r\n",
- database,
- strategy,
- eword);
+ result = sendf(sockfd, conn,
+ "CLIENT " LIBCURL_NAME " " LIBCURL_VERSION "\r\n"
+ "MATCH "
+ "%s " /* database */
+ "%s " /* strategy */
+ "%s\r\n" /* word */
+ "QUIT\r\n",
+ database,
+ strategy,
+ eword);
free(eword);
@@ -278,14 +278,14 @@ static CURLcode dict_do(struct connectdata *conn, bool *done)
if(!eword)
return CURLE_OUT_OF_MEMORY;
- result = sendf(sockfd, conn,
- "CLIENT " LIBCURL_NAME " " LIBCURL_VERSION "\r\n"
- "DEFINE "
- "%s " /* database */
- "%s\r\n" /* word */
- "QUIT\r\n",
- database,
- eword);
+ result = sendf(sockfd, conn,
+ "CLIENT " LIBCURL_NAME " " LIBCURL_VERSION "\r\n"
+ "DEFINE "
+ "%s " /* database */
+ "%s\r\n" /* word */
+ "QUIT\r\n",
+ database,
+ eword);
free(eword);
@@ -306,10 +306,10 @@ static CURLcode dict_do(struct connectdata *conn, bool *done)
if(ppath[i] == ':')
ppath[i] = ' ';
}
- result = sendf(sockfd, conn,
- "CLIENT " LIBCURL_NAME " " LIBCURL_VERSION "\r\n"
- "%s\r\n"
- "QUIT\r\n", ppath);
+ result = sendf(sockfd, conn,
+ "CLIENT " LIBCURL_NAME " " LIBCURL_VERSION "\r\n"
+ "%s\r\n"
+ "QUIT\r\n", ppath);
if(result) {
failf(data, "Failed sending DICT request");
return result;
diff --git a/contrib/libs/curl/lib/dict.h b/contrib/libs/curl/lib/dict.h
index cef04bdf40..6a6c772d13 100644
--- a/contrib/libs/curl/lib/dict.h
+++ b/contrib/libs/curl/lib/dict.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/doh.c b/contrib/libs/curl/lib/doh.c
index 484c92258f..c2b76de53a 100644
--- a/contrib/libs/curl/lib/doh.c
+++ b/contrib/libs/curl/lib/doh.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 2018 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2018 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -35,7 +35,7 @@
#include "curl_base64.h"
#include "connect.h"
#include "strdup.h"
-#include "dynbuf.h"
+#include "dynbuf.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
#include "curl_memory.h"
@@ -57,13 +57,13 @@ static const char * const errors[]={
"Unexpected TYPE",
"Unexpected CLASS",
"No content",
- "Bad ID",
- "Name too long"
+ "Bad ID",
+ "Name too long"
};
static const char *doh_strerror(DOHcode code)
{
- if((code >= DOH_OK) && (code <= DOH_DNS_NAME_TOO_LONG))
+ if((code >= DOH_OK) && (code <= DOH_DNS_NAME_TOO_LONG))
return errors[code];
return "bad error code";
}
@@ -75,50 +75,50 @@ static const char *doh_strerror(DOHcode code)
#define UNITTEST static
#endif
-/* @unittest 1655
- */
+/* @unittest 1655
+ */
UNITTEST DOHcode doh_encode(const char *host,
DNStype dnstype,
unsigned char *dnsp, /* buffer */
size_t len, /* buffer size */
size_t *olen) /* output length */
{
- const size_t hostlen = strlen(host);
+ const size_t hostlen = strlen(host);
unsigned char *orig = dnsp;
const char *hostp = host;
- /* The expected output length is 16 bytes more than the length of
- * the QNAME-encoding of the host name.
- *
- * A valid DNS name may not contain a zero-length label, except at
- * the end. For this reason, a name beginning with a dot, or
- * containing a sequence of two or more consecutive dots, is invalid
- * and cannot be encoded as a QNAME.
- *
- * If the host name ends with a trailing dot, the corresponding
- * QNAME-encoding is one byte longer than the host name. If (as is
- * also valid) the hostname is shortened by the omission of the
- * trailing dot, then its QNAME-encoding will be two bytes longer
- * than the host name.
- *
- * Each [ label, dot ] pair is encoded as [ length, label ],
- * preserving overall length. A final [ label ] without a dot is
- * also encoded as [ length, label ], increasing overall length
- * by one. The encoding is completed by appending a zero byte,
- * representing the zero-length root label, again increasing
- * the overall length by one.
- */
-
- size_t expected_len;
- DEBUGASSERT(hostlen);
- expected_len = 12 + 1 + hostlen + 4;
- if(host[hostlen-1]!='.')
- expected_len++;
-
- if(expected_len > (256 + 16)) /* RFCs 1034, 1035 */
- return DOH_DNS_NAME_TOO_LONG;
-
- if(len < expected_len)
+ /* The expected output length is 16 bytes more than the length of
+ * the QNAME-encoding of the host name.
+ *
+ * A valid DNS name may not contain a zero-length label, except at
+ * the end. For this reason, a name beginning with a dot, or
+ * containing a sequence of two or more consecutive dots, is invalid
+ * and cannot be encoded as a QNAME.
+ *
+ * If the host name ends with a trailing dot, the corresponding
+ * QNAME-encoding is one byte longer than the host name. If (as is
+ * also valid) the hostname is shortened by the omission of the
+ * trailing dot, then its QNAME-encoding will be two bytes longer
+ * than the host name.
+ *
+ * Each [ label, dot ] pair is encoded as [ length, label ],
+ * preserving overall length. A final [ label ] without a dot is
+ * also encoded as [ length, label ], increasing overall length
+ * by one. The encoding is completed by appending a zero byte,
+ * representing the zero-length root label, again increasing
+ * the overall length by one.
+ */
+
+ size_t expected_len;
+ DEBUGASSERT(hostlen);
+ expected_len = 12 + 1 + hostlen + 4;
+ if(host[hostlen-1]!='.')
+ expected_len++;
+
+ if(expected_len > (256 + 16)) /* RFCs 1034, 1035 */
+ return DOH_DNS_NAME_TOO_LONG;
+
+ if(len < expected_len)
return DOH_TOO_SMALL_BUFFER;
*dnsp++ = 0; /* 16 bit id */
@@ -134,53 +134,53 @@ UNITTEST DOHcode doh_encode(const char *host,
*dnsp++ = '\0';
*dnsp++ = '\0'; /* ARCOUNT */
- /* encode each label and store it in the QNAME */
- while(*hostp) {
- size_t labellen;
+ /* encode each label and store it in the QNAME */
+ while(*hostp) {
+ size_t labellen;
char *dot = strchr(hostp, '.');
- if(dot)
+ if(dot)
labellen = dot - hostp;
else
labellen = strlen(hostp);
- if((labellen > 63) || (!labellen)) {
- /* label is too long or too short, error out */
+ if((labellen > 63) || (!labellen)) {
+ /* label is too long or too short, error out */
*olen = 0;
return DOH_DNS_BAD_LABEL;
}
- /* label is non-empty, process it */
+ /* label is non-empty, process it */
*dnsp++ = (unsigned char)labellen;
memcpy(dnsp, hostp, labellen);
dnsp += labellen;
- hostp += labellen;
- /* advance past dot, but only if there is one */
- if(dot)
- hostp++;
- } /* next label */
-
- *dnsp++ = 0; /* append zero-length label for root */
-
- /* There are assigned TYPE codes beyond 255: use range [1..65535] */
- *dnsp++ = (unsigned char)(255 & (dnstype>>8)); /* upper 8 bit TYPE */
- *dnsp++ = (unsigned char)(255 & dnstype); /* lower 8 bit TYPE */
-
+ hostp += labellen;
+ /* advance past dot, but only if there is one */
+ if(dot)
+ hostp++;
+ } /* next label */
+
+ *dnsp++ = 0; /* append zero-length label for root */
+
+ /* There are assigned TYPE codes beyond 255: use range [1..65535] */
+ *dnsp++ = (unsigned char)(255 & (dnstype>>8)); /* upper 8 bit TYPE */
+ *dnsp++ = (unsigned char)(255 & dnstype); /* lower 8 bit TYPE */
+
*dnsp++ = '\0'; /* upper 8 bit CLASS */
*dnsp++ = DNS_CLASS_IN; /* IN - "the Internet" */
*olen = dnsp - orig;
-
- /* verify that our estimation of length is valid, since
- * this has led to buffer overflows in this function */
- DEBUGASSERT(*olen == expected_len);
+
+ /* verify that our estimation of length is valid, since
+ * this has led to buffer overflows in this function */
+ DEBUGASSERT(*olen == expected_len);
return DOH_OK;
}
static size_t
-doh_write_cb(const void *contents, size_t size, size_t nmemb, void *userp)
+doh_write_cb(const void *contents, size_t size, size_t nmemb, void *userp)
{
size_t realsize = size * nmemb;
- struct dynbuf *mem = (struct dynbuf *)userp;
+ struct dynbuf *mem = (struct dynbuf *)userp;
- if(Curl_dyn_addn(mem, contents, realsize))
+ if(Curl_dyn_addn(mem, contents, realsize))
return 0;
return realsize;
@@ -210,7 +210,7 @@ do { \
result = curl_easy_setopt(doh, x, y); \
if(result) \
goto error; \
-} while(0)
+} while(0)
static CURLcode dohprobe(struct Curl_easy *data,
struct dnsprobe *p, DNStype dnstype,
@@ -230,7 +230,7 @@ static CURLcode dohprobe(struct Curl_easy *data,
}
p->dnstype = dnstype;
- Curl_dyn_init(&p->serverdoh, DYN_DOH_RESPONSE);
+ Curl_dyn_init(&p->serverdoh, DYN_DOH_RESPONSE);
/* Note: this is code for sending the DoH request with GET but there's still
no logic that actually enables this. We should either add that ability or
@@ -252,16 +252,16 @@ static CURLcode dohprobe(struct Curl_easy *data,
}
timeout_ms = Curl_timeleft(data, NULL, TRUE);
- if(timeout_ms <= 0) {
- result = CURLE_OPERATION_TIMEDOUT;
- goto error;
- }
+ if(timeout_ms <= 0) {
+ result = CURLE_OPERATION_TIMEDOUT;
+ goto error;
+ }
/* Curl_open() is the internal version of curl_easy_init() */
result = Curl_open(&doh);
if(!result) {
/* pass in the struct pointer via a local variable to please coverity and
the gcc typecheck helpers */
- struct dynbuf *resp = &p->serverdoh;
+ struct dynbuf *resp = &p->serverdoh;
ERROR_CHECK_SETOPT(CURLOPT_URL, url);
ERROR_CHECK_SETOPT(CURLOPT_WRITEFUNCTION, doh_write_cb);
ERROR_CHECK_SETOPT(CURLOPT_WRITEDATA, resp);
@@ -276,9 +276,9 @@ static CURLcode dohprobe(struct Curl_easy *data,
#ifndef CURLDEBUG
/* enforce HTTPS if not debug */
ERROR_CHECK_SETOPT(CURLOPT_PROTOCOLS, CURLPROTO_HTTPS);
-#else
- /* in debug mode, also allow http */
- ERROR_CHECK_SETOPT(CURLOPT_PROTOCOLS, CURLPROTO_HTTP|CURLPROTO_HTTPS);
+#else
+ /* in debug mode, also allow http */
+ ERROR_CHECK_SETOPT(CURLOPT_PROTOCOLS, CURLPROTO_HTTP|CURLPROTO_HTTPS);
#endif
ERROR_CHECK_SETOPT(CURLOPT_TIMEOUT_MS, (long)timeout_ms);
if(data->set.verbose)
@@ -292,29 +292,29 @@ static CURLcode dohprobe(struct Curl_easy *data,
ERROR_CHECK_SETOPT(CURLOPT_SSL_FALSESTART, 1L);
if(data->set.ssl.primary.verifyhost)
ERROR_CHECK_SETOPT(CURLOPT_SSL_VERIFYHOST, 2L);
-#ifndef CURL_DISABLE_PROXY
+#ifndef CURL_DISABLE_PROXY
if(data->set.proxy_ssl.primary.verifyhost)
ERROR_CHECK_SETOPT(CURLOPT_PROXY_SSL_VERIFYHOST, 2L);
- if(data->set.proxy_ssl.primary.verifypeer)
- ERROR_CHECK_SETOPT(CURLOPT_PROXY_SSL_VERIFYPEER, 1L);
- if(data->set.str[STRING_SSL_CAFILE_PROXY]) {
- ERROR_CHECK_SETOPT(CURLOPT_PROXY_CAINFO,
- data->set.str[STRING_SSL_CAFILE_PROXY]);
- }
- if(data->set.str[STRING_SSL_CRLFILE_PROXY]) {
- ERROR_CHECK_SETOPT(CURLOPT_PROXY_CRLFILE,
- data->set.str[STRING_SSL_CRLFILE_PROXY]);
- }
- if(data->set.proxy_ssl.no_revoke)
- ERROR_CHECK_SETOPT(CURLOPT_PROXY_SSL_OPTIONS, CURLSSLOPT_NO_REVOKE);
- else if(data->set.proxy_ssl.revoke_best_effort)
- ERROR_CHECK_SETOPT(CURLOPT_PROXY_SSL_OPTIONS,
- CURLSSLOPT_REVOKE_BEST_EFFORT);
- if(data->set.str[STRING_SSL_CAPATH_PROXY]) {
- ERROR_CHECK_SETOPT(CURLOPT_PROXY_CAPATH,
- data->set.str[STRING_SSL_CAPATH_PROXY]);
- }
-#endif
+ if(data->set.proxy_ssl.primary.verifypeer)
+ ERROR_CHECK_SETOPT(CURLOPT_PROXY_SSL_VERIFYPEER, 1L);
+ if(data->set.str[STRING_SSL_CAFILE_PROXY]) {
+ ERROR_CHECK_SETOPT(CURLOPT_PROXY_CAINFO,
+ data->set.str[STRING_SSL_CAFILE_PROXY]);
+ }
+ if(data->set.str[STRING_SSL_CRLFILE_PROXY]) {
+ ERROR_CHECK_SETOPT(CURLOPT_PROXY_CRLFILE,
+ data->set.str[STRING_SSL_CRLFILE_PROXY]);
+ }
+ if(data->set.proxy_ssl.no_revoke)
+ ERROR_CHECK_SETOPT(CURLOPT_PROXY_SSL_OPTIONS, CURLSSLOPT_NO_REVOKE);
+ else if(data->set.proxy_ssl.revoke_best_effort)
+ ERROR_CHECK_SETOPT(CURLOPT_PROXY_SSL_OPTIONS,
+ CURLSSLOPT_REVOKE_BEST_EFFORT);
+ if(data->set.str[STRING_SSL_CAPATH_PROXY]) {
+ ERROR_CHECK_SETOPT(CURLOPT_PROXY_CAPATH,
+ data->set.str[STRING_SSL_CAPATH_PROXY]);
+ }
+#endif
if(data->set.ssl.primary.verifypeer)
ERROR_CHECK_SETOPT(CURLOPT_SSL_VERIFYPEER, 1L);
if(data->set.ssl.primary.verifystatus)
@@ -343,16 +343,16 @@ static CURLcode dohprobe(struct Curl_easy *data,
}
if(data->set.ssl.no_revoke)
ERROR_CHECK_SETOPT(CURLOPT_SSL_OPTIONS, CURLSSLOPT_NO_REVOKE);
- else if(data->set.ssl.revoke_best_effort)
- ERROR_CHECK_SETOPT(CURLOPT_SSL_OPTIONS, CURLSSLOPT_REVOKE_BEST_EFFORT);
+ else if(data->set.ssl.revoke_best_effort)
+ ERROR_CHECK_SETOPT(CURLOPT_SSL_OPTIONS, CURLSSLOPT_REVOKE_BEST_EFFORT);
if(data->set.ssl.fsslctx)
ERROR_CHECK_SETOPT(CURLOPT_SSL_CTX_FUNCTION, data->set.ssl.fsslctx);
if(data->set.ssl.fsslctxp)
ERROR_CHECK_SETOPT(CURLOPT_SSL_CTX_DATA, data->set.ssl.fsslctxp);
- if(data->set.str[STRING_SSL_EC_CURVES]) {
- ERROR_CHECK_SETOPT(CURLOPT_SSL_EC_CURVES,
- data->set.str[STRING_SSL_EC_CURVES]);
- }
+ if(data->set.str[STRING_SSL_EC_CURVES]) {
+ ERROR_CHECK_SETOPT(CURLOPT_SSL_EC_CURVES,
+ data->set.str[STRING_SSL_EC_CURVES]);
+ }
doh->set.fmultidone = Curl_doh_done;
doh->set.dohfor = data; /* identify for which transfer this is done */
@@ -369,7 +369,7 @@ static CURLcode dohprobe(struct Curl_easy *data,
error:
free(nurl);
- Curl_close(&doh);
+ Curl_close(&doh);
return result;
}
@@ -378,14 +378,14 @@ static CURLcode dohprobe(struct Curl_easy *data,
* 'Curl_addrinfo *' with the address information.
*/
-struct Curl_addrinfo *Curl_doh(struct connectdata *conn,
- const char *hostname,
- int port,
- int *waitp)
+struct Curl_addrinfo *Curl_doh(struct connectdata *conn,
+ const char *hostname,
+ int port,
+ int *waitp)
{
struct Curl_easy *data = conn->data;
CURLcode result = CURLE_OK;
- int slot;
+ int slot;
*waitp = TRUE; /* this never returns synchronously */
(void)conn;
(void)hostname;
@@ -394,7 +394,7 @@ struct Curl_addrinfo *Curl_doh(struct connectdata *conn,
/* start clean, consider allocating this struct on demand */
memset(&data->req.doh, 0, sizeof(struct dohdata));
- conn->bits.doh = TRUE;
+ conn->bits.doh = TRUE;
data->req.doh.host = hostname;
data->req.doh.port = port;
data->req.doh.headers =
@@ -405,8 +405,8 @@ struct Curl_addrinfo *Curl_doh(struct connectdata *conn,
if(conn->ip_version != CURL_IPRESOLVE_V6) {
/* create IPv4 DOH request */
- result = dohprobe(data, &data->req.doh.probe[DOH_PROBE_SLOT_IPADDR_V4],
- DNS_TYPE_A, hostname, data->set.str[STRING_DOH],
+ result = dohprobe(data, &data->req.doh.probe[DOH_PROBE_SLOT_IPADDR_V4],
+ DNS_TYPE_A, hostname, data->set.str[STRING_DOH],
data->multi, data->req.doh.headers);
if(result)
goto error;
@@ -415,8 +415,8 @@ struct Curl_addrinfo *Curl_doh(struct connectdata *conn,
if(conn->ip_version != CURL_IPRESOLVE_V4) {
/* create IPv6 DOH request */
- result = dohprobe(data, &data->req.doh.probe[DOH_PROBE_SLOT_IPADDR_V6],
- DNS_TYPE_AAAA, hostname, data->set.str[STRING_DOH],
+ result = dohprobe(data, &data->req.doh.probe[DOH_PROBE_SLOT_IPADDR_V6],
+ DNS_TYPE_AAAA, hostname, data->set.str[STRING_DOH],
data->multi, data->req.doh.headers);
if(result)
goto error;
@@ -427,13 +427,13 @@ struct Curl_addrinfo *Curl_doh(struct connectdata *conn,
error:
curl_slist_free_all(data->req.doh.headers);
data->req.doh.headers = NULL;
- for(slot = 0; slot < DOH_PROBE_SLOTS; slot++) {
- Curl_close(&data->req.doh.probe[slot].easy);
- }
+ for(slot = 0; slot < DOH_PROBE_SLOTS; slot++) {
+ Curl_close(&data->req.doh.probe[slot].easy);
+ }
return NULL;
}
-static DOHcode skipqname(const unsigned char *doh, size_t dohlen,
+static DOHcode skipqname(const unsigned char *doh, size_t dohlen,
unsigned int *indexp)
{
unsigned char length;
@@ -457,24 +457,24 @@ static DOHcode skipqname(const unsigned char *doh, size_t dohlen,
return DOH_OK;
}
-static unsigned short get16bit(const unsigned char *doh, int index)
+static unsigned short get16bit(const unsigned char *doh, int index)
{
return (unsigned short)((doh[index] << 8) | doh[index + 1]);
}
-static unsigned int get32bit(const unsigned char *doh, int index)
+static unsigned int get32bit(const unsigned char *doh, int index)
{
- /* make clang and gcc optimize this to bswap by incrementing
- the pointer first. */
- doh += index;
-
- /* avoid undefined behaviour by casting to unsigned before shifting
- 24 bits, possibly into the sign bit. codegen is same, but
- ub sanitizer won't be upset */
- return ( (unsigned)doh[0] << 24) | (doh[1] << 16) |(doh[2] << 8) | doh[3];
+ /* make clang and gcc optimize this to bswap by incrementing
+ the pointer first. */
+ doh += index;
+
+ /* avoid undefined behaviour by casting to unsigned before shifting
+ 24 bits, possibly into the sign bit. codegen is same, but
+ ub sanitizer won't be upset */
+ return ( (unsigned)doh[0] << 24) | (doh[1] << 16) |(doh[2] << 8) | doh[3];
}
-static DOHcode store_a(const unsigned char *doh, int index, struct dohentry *d)
+static DOHcode store_a(const unsigned char *doh, int index, struct dohentry *d)
{
/* silently ignore addresses over the limit */
if(d->numaddr < DOH_MAX_ADDR) {
@@ -486,9 +486,9 @@ static DOHcode store_a(const unsigned char *doh, int index, struct dohentry *d)
return DOH_OK;
}
-static DOHcode store_aaaa(const unsigned char *doh,
- int index,
- struct dohentry *d)
+static DOHcode store_aaaa(const unsigned char *doh,
+ int index,
+ struct dohentry *d)
{
/* silently ignore addresses over the limit */
if(d->numaddr < DOH_MAX_ADDR) {
@@ -500,12 +500,12 @@ static DOHcode store_aaaa(const unsigned char *doh,
return DOH_OK;
}
-static DOHcode store_cname(const unsigned char *doh,
+static DOHcode store_cname(const unsigned char *doh,
size_t dohlen,
unsigned int index,
struct dohentry *d)
{
- struct dynbuf *c;
+ struct dynbuf *c;
unsigned int loop = 128; /* a valid DNS name can never loop this much */
unsigned char length;
@@ -523,7 +523,7 @@ static DOHcode store_cname(const unsigned char *doh,
if((index + 1) >= dohlen)
return DOH_DNS_OUT_OF_RANGE;
- /* move to the new index */
+ /* move to the new index */
newpos = (length & 0x3f) << 8 | doh[index + 1];
index = newpos;
continue;
@@ -534,15 +534,15 @@ static DOHcode store_cname(const unsigned char *doh,
index++;
if(length) {
- if(Curl_dyn_len(c)) {
- if(Curl_dyn_add(c, "."))
- return DOH_OUT_OF_MEM;
+ if(Curl_dyn_len(c)) {
+ if(Curl_dyn_add(c, "."))
+ return DOH_OUT_OF_MEM;
}
if((index + length) > dohlen)
return DOH_DNS_BAD_LABEL;
- if(Curl_dyn_addn(c, &doh[index], length))
- return DOH_OUT_OF_MEM;
+ if(Curl_dyn_addn(c, &doh[index], length))
+ return DOH_OUT_OF_MEM;
index += length;
}
} while(length && --loop);
@@ -552,7 +552,7 @@ static DOHcode store_cname(const unsigned char *doh,
return DOH_OK;
}
-static DOHcode rdata(const unsigned char *doh,
+static DOHcode rdata(const unsigned char *doh,
size_t dohlen,
unsigned short rdlength,
unsigned short type,
@@ -585,9 +585,9 @@ static DOHcode rdata(const unsigned char *doh,
if(rc)
return rc;
break;
- case DNS_TYPE_DNAME:
- /* explicit for clarity; just skip; rely on synthesized CNAME */
- break;
+ case DNS_TYPE_DNAME:
+ /* explicit for clarity; just skip; rely on synthesized CNAME */
+ break;
default:
/* unsupported type, just skip it */
break;
@@ -595,17 +595,17 @@ static DOHcode rdata(const unsigned char *doh,
return DOH_OK;
}
-UNITTEST void de_init(struct dohentry *de)
+UNITTEST void de_init(struct dohentry *de)
{
- int i;
+ int i;
memset(de, 0, sizeof(*de));
de->ttl = INT_MAX;
- for(i = 0; i < DOH_MAX_CNAME; i++)
- Curl_dyn_init(&de->cname[i], DYN_DOH_CNAME);
+ for(i = 0; i < DOH_MAX_CNAME; i++)
+ Curl_dyn_init(&de->cname[i], DYN_DOH_CNAME);
}
-UNITTEST DOHcode doh_decode(const unsigned char *doh,
+UNITTEST DOHcode doh_decode(const unsigned char *doh,
size_t dohlen,
DNStype dnstype,
struct dohentry *d)
@@ -652,10 +652,10 @@ UNITTEST DOHcode doh_decode(const unsigned char *doh,
return DOH_DNS_OUT_OF_RANGE;
type = get16bit(doh, index);
- if((type != DNS_TYPE_CNAME) /* may be synthesized from DNAME */
- && (type != DNS_TYPE_DNAME) /* if present, accept and ignore */
- && (type != dnstype))
- /* Not the same type as was asked for nor CNAME nor DNAME */
+ if((type != DNS_TYPE_CNAME) /* may be synthesized from DNAME */
+ && (type != DNS_TYPE_DNAME) /* if present, accept and ignore */
+ && (type != dnstype))
+ /* Not the same type as was asked for nor CNAME nor DNAME */
return DOH_DNS_UNEXPECTED_TYPE;
index += 2;
@@ -745,12 +745,12 @@ UNITTEST DOHcode doh_decode(const unsigned char *doh,
#ifndef CURL_DISABLE_VERBOSE_STRINGS
static void showdoh(struct Curl_easy *data,
- const struct dohentry *d)
+ const struct dohentry *d)
{
int i;
infof(data, "TTL: %u seconds\n", d->ttl);
for(i = 0; i < d->numaddr; i++) {
- const struct dohaddr *a = &d->addr[i];
+ const struct dohaddr *a = &d->addr[i];
if(a->type == DNS_TYPE_A) {
infof(data, "DOH A: %u.%u.%u.%u\n",
a->ip.v4[0], a->ip.v4[1],
@@ -776,7 +776,7 @@ static void showdoh(struct Curl_easy *data,
}
}
for(i = 0; i < d->numcname; i++) {
- infof(data, "CNAME: %s\n", Curl_dyn_ptr(&d->cname[i]));
+ infof(data, "CNAME: %s\n", Curl_dyn_ptr(&d->cname[i]));
}
}
#else
@@ -796,19 +796,19 @@ static void showdoh(struct Curl_easy *data,
* must be an associated call later to Curl_freeaddrinfo().
*/
-static struct Curl_addrinfo *
+static struct Curl_addrinfo *
doh2ai(const struct dohentry *de, const char *hostname, int port)
{
- struct Curl_addrinfo *ai;
- struct Curl_addrinfo *prevai = NULL;
- struct Curl_addrinfo *firstai = NULL;
+ struct Curl_addrinfo *ai;
+ struct Curl_addrinfo *prevai = NULL;
+ struct Curl_addrinfo *firstai = NULL;
struct sockaddr_in *addr;
#ifdef ENABLE_IPV6
struct sockaddr_in6 *addr6;
#endif
CURLcode result = CURLE_OK;
int i;
- size_t hostlen = strlen(hostname) + 1; /* include zero terminator */
+ size_t hostlen = strlen(hostname) + 1; /* include zero terminator */
if(!de)
/* no input == no output! */
@@ -831,14 +831,14 @@ doh2ai(const struct dohentry *de, const char *hostname, int port)
addrtype = AF_INET;
}
- ai = calloc(1, sizeof(struct Curl_addrinfo) + ss_size + hostlen);
+ ai = calloc(1, sizeof(struct Curl_addrinfo) + ss_size + hostlen);
if(!ai) {
result = CURLE_OUT_OF_MEMORY;
break;
}
- ai->ai_addr = (void *)((char *)ai + sizeof(struct Curl_addrinfo));
- ai->ai_canonname = (void *)((char *)ai->ai_addr + ss_size);
- memcpy(ai->ai_canonname, hostname, hostlen);
+ ai->ai_addr = (void *)((char *)ai + sizeof(struct Curl_addrinfo));
+ ai->ai_canonname = (void *)((char *)ai->ai_addr + ss_size);
+ memcpy(ai->ai_canonname, hostname, hostlen);
if(!firstai)
/* store the pointer we want to return from this function */
@@ -863,7 +863,7 @@ doh2ai(const struct dohentry *de, const char *hostname, int port)
addr = (void *)ai->ai_addr; /* storage area for this info */
DEBUGASSERT(sizeof(struct in_addr) == sizeof(de->addr[i].ip.v4));
memcpy(&addr->sin_addr, &de->addr[i].ip.v4, sizeof(struct in_addr));
- addr->sin_family = addrtype;
+ addr->sin_family = addrtype;
addr->sin_port = htons((unsigned short)port);
break;
@@ -872,7 +872,7 @@ doh2ai(const struct dohentry *de, const char *hostname, int port)
addr6 = (void *)ai->ai_addr; /* storage area for this info */
DEBUGASSERT(sizeof(struct in6_addr) == sizeof(de->addr[i].ip.v6));
memcpy(&addr6->sin6_addr, &de->addr[i].ip.v6, sizeof(struct in6_addr));
- addr6->sin6_family = addrtype;
+ addr6->sin6_family = addrtype;
addr6->sin6_port = htons((unsigned short)port);
break;
#endif
@@ -900,54 +900,54 @@ UNITTEST void de_cleanup(struct dohentry *d)
{
int i = 0;
for(i = 0; i < d->numcname; i++) {
- Curl_dyn_free(&d->cname[i]);
+ Curl_dyn_free(&d->cname[i]);
}
}
CURLcode Curl_doh_is_resolved(struct connectdata *conn,
struct Curl_dns_entry **dnsp)
{
- CURLcode result;
+ CURLcode result;
struct Curl_easy *data = conn->data;
*dnsp = NULL; /* defaults to no response */
- if(!data->req.doh.probe[DOH_PROBE_SLOT_IPADDR_V4].easy &&
- !data->req.doh.probe[DOH_PROBE_SLOT_IPADDR_V6].easy) {
+ if(!data->req.doh.probe[DOH_PROBE_SLOT_IPADDR_V4].easy &&
+ !data->req.doh.probe[DOH_PROBE_SLOT_IPADDR_V6].easy) {
failf(data, "Could not DOH-resolve: %s", conn->async.hostname);
return conn->bits.proxy?CURLE_COULDNT_RESOLVE_PROXY:
CURLE_COULDNT_RESOLVE_HOST;
}
else if(!data->req.doh.pending) {
- DOHcode rc[DOH_PROBE_SLOTS] = {
- DOH_OK, DOH_OK
- };
+ DOHcode rc[DOH_PROBE_SLOTS] = {
+ DOH_OK, DOH_OK
+ };
struct dohentry de;
- int slot;
+ int slot;
/* remove DOH handles from multi handle and close them */
- for(slot = 0; slot < DOH_PROBE_SLOTS; slot++) {
- curl_multi_remove_handle(data->multi, data->req.doh.probe[slot].easy);
- Curl_close(&data->req.doh.probe[slot].easy);
- }
- /* parse the responses, create the struct and return it! */
- de_init(&de);
- for(slot = 0; slot < DOH_PROBE_SLOTS; slot++) {
- struct dnsprobe *p = &data->req.doh.probe[slot];
- if(!p->dnstype)
- continue;
- rc[slot] = doh_decode(Curl_dyn_uptr(&p->serverdoh),
- Curl_dyn_len(&p->serverdoh),
- p->dnstype,
- &de);
- Curl_dyn_free(&p->serverdoh);
- if(rc[slot]) {
- infof(data, "DOH: %s type %s for %s\n", doh_strerror(rc[slot]),
- type2name(p->dnstype), data->req.doh.host);
- }
- } /* next slot */
-
- result = CURLE_COULDNT_RESOLVE_HOST; /* until we know better */
- if(!rc[DOH_PROBE_SLOT_IPADDR_V4] || !rc[DOH_PROBE_SLOT_IPADDR_V6]) {
- /* we have an address, of one kind or other */
+ for(slot = 0; slot < DOH_PROBE_SLOTS; slot++) {
+ curl_multi_remove_handle(data->multi, data->req.doh.probe[slot].easy);
+ Curl_close(&data->req.doh.probe[slot].easy);
+ }
+ /* parse the responses, create the struct and return it! */
+ de_init(&de);
+ for(slot = 0; slot < DOH_PROBE_SLOTS; slot++) {
+ struct dnsprobe *p = &data->req.doh.probe[slot];
+ if(!p->dnstype)
+ continue;
+ rc[slot] = doh_decode(Curl_dyn_uptr(&p->serverdoh),
+ Curl_dyn_len(&p->serverdoh),
+ p->dnstype,
+ &de);
+ Curl_dyn_free(&p->serverdoh);
+ if(rc[slot]) {
+ infof(data, "DOH: %s type %s for %s\n", doh_strerror(rc[slot]),
+ type2name(p->dnstype), data->req.doh.host);
+ }
+ } /* next slot */
+
+ result = CURLE_COULDNT_RESOLVE_HOST; /* until we know better */
+ if(!rc[DOH_PROBE_SLOT_IPADDR_V4] || !rc[DOH_PROBE_SLOT_IPADDR_V6]) {
+ /* we have an address, of one kind or other */
struct Curl_dns_entry *dns;
struct Curl_addrinfo *ai;
@@ -969,26 +969,26 @@ CURLcode Curl_doh_is_resolved(struct connectdata *conn,
if(data->share)
Curl_share_unlock(data, CURL_LOCK_DATA_DNS);
- if(!dns) {
+ if(!dns) {
/* returned failure, bail out nicely */
Curl_freeaddrinfo(ai);
- }
+ }
else {
conn->async.dns = dns;
*dnsp = dns;
- result = CURLE_OK; /* address resolution OK */
+ result = CURLE_OK; /* address resolution OK */
}
- } /* address processing done */
-
- /* Now process any build-specific attributes retrieved from DNS */
-
- /* All done */
+ } /* address processing done */
+
+ /* Now process any build-specific attributes retrieved from DNS */
+
+ /* All done */
de_cleanup(&de);
- return result;
+ return result;
- } /* !data->req.doh.pending */
+ } /* !data->req.doh.pending */
- /* else wait for pending DOH transactions to complete */
+ /* else wait for pending DOH transactions to complete */
return CURLE_OK;
}
diff --git a/contrib/libs/curl/lib/doh.h b/contrib/libs/curl/lib/doh.h
index 5e14a87f42..0867584ced 100644
--- a/contrib/libs/curl/lib/doh.h
+++ b/contrib/libs/curl/lib/doh.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 2018 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2018 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -32,10 +32,10 @@
* and returns a 'Curl_addrinfo *' with the address information.
*/
-struct Curl_addrinfo *Curl_doh(struct connectdata *conn,
- const char *hostname,
- int port,
- int *waitp);
+struct Curl_addrinfo *Curl_doh(struct connectdata *conn,
+ const char *hostname,
+ int port,
+ int *waitp);
CURLcode Curl_doh_is_resolved(struct connectdata *conn,
struct Curl_dns_entry **dns);
@@ -55,16 +55,16 @@ typedef enum {
DOH_DNS_UNEXPECTED_TYPE, /* 9 */
DOH_DNS_UNEXPECTED_CLASS, /* 10 */
DOH_NO_CONTENT, /* 11 */
- DOH_DNS_BAD_ID, /* 12 */
- DOH_DNS_NAME_TOO_LONG /* 13 */
+ DOH_DNS_BAD_ID, /* 12 */
+ DOH_DNS_NAME_TOO_LONG /* 13 */
} DOHcode;
typedef enum {
DNS_TYPE_A = 1,
DNS_TYPE_NS = 2,
DNS_TYPE_CNAME = 5,
- DNS_TYPE_AAAA = 28,
- DNS_TYPE_DNAME = 39 /* RFC6672 */
+ DNS_TYPE_AAAA = 28,
+ DNS_TYPE_DNAME = 39 /* RFC6672 */
} DNStype;
#define DOH_MAX_ADDR 24
@@ -79,9 +79,9 @@ struct dohaddr {
};
struct dohentry {
- struct dynbuf cname[DOH_MAX_CNAME];
- struct dohaddr addr[DOH_MAX_ADDR];
- int numaddr;
+ struct dynbuf cname[DOH_MAX_CNAME];
+ struct dohaddr addr[DOH_MAX_ADDR];
+ int numaddr;
unsigned int ttl;
int numcname;
};
@@ -93,11 +93,11 @@ DOHcode doh_encode(const char *host,
unsigned char *dnsp, /* buffer */
size_t len, /* buffer size */
size_t *olen); /* output length */
-DOHcode doh_decode(const unsigned char *doh,
+DOHcode doh_decode(const unsigned char *doh,
size_t dohlen,
DNStype dnstype,
struct dohentry *d);
-void de_init(struct dohentry *d);
+void de_init(struct dohentry *d);
void de_cleanup(struct dohentry *d);
#endif
diff --git a/contrib/libs/curl/lib/dotdot.c b/contrib/libs/curl/lib/dotdot.c
index 7f0c51bcfd..3a1435f8ec 100644
--- a/contrib/libs/curl/lib/dotdot.c
+++ b/contrib/libs/curl/lib/dotdot.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -39,7 +39,7 @@
* Curl_dedotdotify()
* @unittest: 1395
*
- * This function gets a null-terminated path with dot and dotdot sequences
+ * This function gets a null-terminated path with dot and dotdot sequences
* passed in and strips them off according to the rules in RFC 3986 section
* 5.2.4.
*
@@ -62,7 +62,7 @@ char *Curl_dedotdotify(const char *input)
if(!out)
return NULL; /* out of memory */
- *out = 0; /* null-terminates, for inputs like "./" */
+ *out = 0; /* null-terminates, for inputs like "./" */
/* get a cloned copy of the input */
clone = strdup(input);
@@ -129,7 +129,7 @@ char *Curl_dedotdotify(const char *input)
if(*outptr == '/')
break;
}
- *outptr = 0; /* null-terminate where it stops */
+ *outptr = 0; /* null-terminate where it stops */
}
else if(!strcmp("/..", clone)) {
clone[2]='/';
@@ -141,7 +141,7 @@ char *Curl_dedotdotify(const char *input)
if(*outptr == '/')
break;
}
- *outptr = 0; /* null-terminate where it stops */
+ *outptr = 0; /* null-terminate where it stops */
}
/* D. if the input buffer consists only of "." or "..", then remove
diff --git a/contrib/libs/curl/lib/dotdot.h b/contrib/libs/curl/lib/dotdot.h
index 91121d51c9..ac1ea363e1 100644
--- a/contrib/libs/curl/lib/dotdot.h
+++ b/contrib/libs/curl/lib/dotdot.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/dynbuf.c b/contrib/libs/curl/lib/dynbuf.c
index 7d7c7f9251..ada7e0ccf5 100644
--- a/contrib/libs/curl/lib/dynbuf.c
+++ b/contrib/libs/curl/lib/dynbuf.c
@@ -1,255 +1,255 @@
-/***************************************************************************
- * _ _ ____ _
- * Project ___| | | | _ \| |
- * / __| | | | |_) | |
- * | (__| |_| | _ <| |___
- * \___|\___/|_| \_\_____|
- *
- * Copyright (C) 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
- *
- * You may opt to use, copy, modify, merge, publish, distribute and/or sell
- * copies of the Software, and permit persons to whom the Software is
- * furnished to do so, under the terms of the COPYING file.
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- ***************************************************************************/
-
-#include "curl_setup.h"
-#include "dynbuf.h"
-#include "curl_printf.h"
-#ifdef BUILDING_LIBCURL
-#include "curl_memory.h"
-#endif
-#include "memdebug.h"
-
-#define MIN_FIRST_ALLOC 32
-
-#define DYNINIT 0xbee51da /* random pattern */
-
-/*
- * Init a dynbuf struct.
- */
-void Curl_dyn_init(struct dynbuf *s, size_t toobig)
-{
- DEBUGASSERT(s);
- DEBUGASSERT(toobig);
- s->bufr = NULL;
- s->leng = 0;
- s->allc = 0;
- s->toobig = toobig;
-#ifdef DEBUGBUILD
- s->init = DYNINIT;
-#endif
-}
-
-/*
- * free the buffer and re-init the necessary fields. It doesn't touch the
- * 'init' field and thus this buffer can be reused to add data to again.
- */
-void Curl_dyn_free(struct dynbuf *s)
-{
- DEBUGASSERT(s);
- Curl_safefree(s->bufr);
- s->leng = s->allc = 0;
-}
-
-/*
- * Store/append an chunk of memory to the dynbuf.
- */
-static CURLcode dyn_nappend(struct dynbuf *s,
- const unsigned char *mem, size_t len)
-{
- size_t indx = s->leng;
- size_t a = s->allc;
- size_t fit = len + indx + 1; /* new string + old string + zero byte */
-
- /* try to detect if there's rubbish in the struct */
- DEBUGASSERT(s->init == DYNINIT);
- DEBUGASSERT(s->toobig);
- DEBUGASSERT(indx < s->toobig);
- DEBUGASSERT(!s->leng || s->bufr);
-
- if(fit > s->toobig) {
- Curl_dyn_free(s);
- return CURLE_OUT_OF_MEMORY;
- }
- else if(!a) {
- DEBUGASSERT(!indx);
- /* first invoke */
- if(fit < MIN_FIRST_ALLOC)
- a = MIN_FIRST_ALLOC;
- else
- a = fit;
- }
- else {
- while(a < fit)
- a *= 2;
- }
-
- if(a != s->allc) {
- /* this logic is not using Curl_saferealloc() to make the tool not have to
- include that as well when it uses this code */
- void *p = realloc(s->bufr, a);
- if(!p) {
- Curl_safefree(s->bufr);
- s->leng = s->allc = 0;
- return CURLE_OUT_OF_MEMORY;
- }
- s->bufr = p;
- s->allc = a;
- }
-
- if(len)
- memcpy(&s->bufr[indx], mem, len);
- s->leng = indx + len;
- s->bufr[s->leng] = 0;
- return CURLE_OK;
-}
-
-/*
- * Clears the string, keeps the allocation. This can also be called on a
- * buffer that already was freed.
- */
-void Curl_dyn_reset(struct dynbuf *s)
-{
- DEBUGASSERT(s);
- DEBUGASSERT(s->init == DYNINIT);
- DEBUGASSERT(!s->leng || s->bufr);
- if(s->leng)
- s->bufr[0] = 0;
- s->leng = 0;
-}
-
-#ifdef USE_NGTCP2
-/*
- * Specify the size of the tail to keep (number of bytes from the end of the
- * buffer). The rest will be dropped.
- */
-CURLcode Curl_dyn_tail(struct dynbuf *s, size_t trail)
-{
- DEBUGASSERT(s);
- DEBUGASSERT(s->init == DYNINIT);
- DEBUGASSERT(!s->leng || s->bufr);
- if(trail > s->leng)
- return CURLE_BAD_FUNCTION_ARGUMENT;
- else if(trail == s->leng)
- return CURLE_OK;
- else if(!trail) {
- Curl_dyn_reset(s);
- }
- else {
- memmove(&s->bufr[0], &s->bufr[s->leng - trail], trail);
- s->leng = trail;
- s->bufr[s->leng] = 0;
- }
- return CURLE_OK;
-
-}
-#endif
-
-/*
- * Appends a buffer with length.
- */
-CURLcode Curl_dyn_addn(struct dynbuf *s, const void *mem, size_t len)
-{
- DEBUGASSERT(s);
- DEBUGASSERT(s->init == DYNINIT);
- DEBUGASSERT(!s->leng || s->bufr);
- return dyn_nappend(s, mem, len);
-}
-
-/*
- * Append a null-terminated string at the end.
- */
-CURLcode Curl_dyn_add(struct dynbuf *s, const char *str)
-{
- size_t n = strlen(str);
- DEBUGASSERT(s);
- DEBUGASSERT(s->init == DYNINIT);
- DEBUGASSERT(!s->leng || s->bufr);
- return dyn_nappend(s, (unsigned char *)str, n);
-}
-
-/*
- * Append a string vprintf()-style
- */
-CURLcode Curl_dyn_vaddf(struct dynbuf *s, const char *fmt, va_list ap)
-{
-#ifdef BUILDING_LIBCURL
- int rc;
- DEBUGASSERT(s);
- DEBUGASSERT(s->init == DYNINIT);
- DEBUGASSERT(!s->leng || s->bufr);
- rc = Curl_dyn_vprintf(s, fmt, ap);
-
- if(!rc)
- return CURLE_OK;
-#else
- char *str;
- str = vaprintf(fmt, ap); /* this allocs a new string to append */
-
- if(str) {
- CURLcode result = dyn_nappend(s, (unsigned char *)str, strlen(str));
- free(str);
- return result;
- }
- /* If we failed, we cleanup the whole buffer and return error */
- Curl_dyn_free(s);
-#endif
- return CURLE_OUT_OF_MEMORY;
-}
-
-/*
- * Append a string printf()-style
- */
-CURLcode Curl_dyn_addf(struct dynbuf *s, const char *fmt, ...)
-{
- CURLcode result;
- va_list ap;
- DEBUGASSERT(s);
- DEBUGASSERT(s->init == DYNINIT);
- DEBUGASSERT(!s->leng || s->bufr);
- va_start(ap, fmt);
- result = Curl_dyn_vaddf(s, fmt, ap);
- va_end(ap);
- return result;
-}
-
-/*
- * Returns a pointer to the buffer.
- */
-char *Curl_dyn_ptr(const struct dynbuf *s)
-{
- DEBUGASSERT(s);
- DEBUGASSERT(s->init == DYNINIT);
- DEBUGASSERT(!s->leng || s->bufr);
- return s->bufr;
-}
-
-/*
- * Returns an unsigned pointer to the buffer.
- */
-unsigned char *Curl_dyn_uptr(const struct dynbuf *s)
-{
- DEBUGASSERT(s);
- DEBUGASSERT(s->init == DYNINIT);
- DEBUGASSERT(!s->leng || s->bufr);
- return (unsigned char *)s->bufr;
-}
-
-/*
- * Returns the length of the buffer.
- */
-size_t Curl_dyn_len(const struct dynbuf *s)
-{
- DEBUGASSERT(s);
- DEBUGASSERT(s->init == DYNINIT);
- DEBUGASSERT(!s->leng || s->bufr);
- return s->leng;
-}
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 2020, 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
+ * are also available at https://curl.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+
+#include "curl_setup.h"
+#include "dynbuf.h"
+#include "curl_printf.h"
+#ifdef BUILDING_LIBCURL
+#include "curl_memory.h"
+#endif
+#include "memdebug.h"
+
+#define MIN_FIRST_ALLOC 32
+
+#define DYNINIT 0xbee51da /* random pattern */
+
+/*
+ * Init a dynbuf struct.
+ */
+void Curl_dyn_init(struct dynbuf *s, size_t toobig)
+{
+ DEBUGASSERT(s);
+ DEBUGASSERT(toobig);
+ s->bufr = NULL;
+ s->leng = 0;
+ s->allc = 0;
+ s->toobig = toobig;
+#ifdef DEBUGBUILD
+ s->init = DYNINIT;
+#endif
+}
+
+/*
+ * free the buffer and re-init the necessary fields. It doesn't touch the
+ * 'init' field and thus this buffer can be reused to add data to again.
+ */
+void Curl_dyn_free(struct dynbuf *s)
+{
+ DEBUGASSERT(s);
+ Curl_safefree(s->bufr);
+ s->leng = s->allc = 0;
+}
+
+/*
+ * Store/append an chunk of memory to the dynbuf.
+ */
+static CURLcode dyn_nappend(struct dynbuf *s,
+ const unsigned char *mem, size_t len)
+{
+ size_t indx = s->leng;
+ size_t a = s->allc;
+ size_t fit = len + indx + 1; /* new string + old string + zero byte */
+
+ /* try to detect if there's rubbish in the struct */
+ DEBUGASSERT(s->init == DYNINIT);
+ DEBUGASSERT(s->toobig);
+ DEBUGASSERT(indx < s->toobig);
+ DEBUGASSERT(!s->leng || s->bufr);
+
+ if(fit > s->toobig) {
+ Curl_dyn_free(s);
+ return CURLE_OUT_OF_MEMORY;
+ }
+ else if(!a) {
+ DEBUGASSERT(!indx);
+ /* first invoke */
+ if(fit < MIN_FIRST_ALLOC)
+ a = MIN_FIRST_ALLOC;
+ else
+ a = fit;
+ }
+ else {
+ while(a < fit)
+ a *= 2;
+ }
+
+ if(a != s->allc) {
+ /* this logic is not using Curl_saferealloc() to make the tool not have to
+ include that as well when it uses this code */
+ void *p = realloc(s->bufr, a);
+ if(!p) {
+ Curl_safefree(s->bufr);
+ s->leng = s->allc = 0;
+ return CURLE_OUT_OF_MEMORY;
+ }
+ s->bufr = p;
+ s->allc = a;
+ }
+
+ if(len)
+ memcpy(&s->bufr[indx], mem, len);
+ s->leng = indx + len;
+ s->bufr[s->leng] = 0;
+ return CURLE_OK;
+}
+
+/*
+ * Clears the string, keeps the allocation. This can also be called on a
+ * buffer that already was freed.
+ */
+void Curl_dyn_reset(struct dynbuf *s)
+{
+ DEBUGASSERT(s);
+ DEBUGASSERT(s->init == DYNINIT);
+ DEBUGASSERT(!s->leng || s->bufr);
+ if(s->leng)
+ s->bufr[0] = 0;
+ s->leng = 0;
+}
+
+#ifdef USE_NGTCP2
+/*
+ * Specify the size of the tail to keep (number of bytes from the end of the
+ * buffer). The rest will be dropped.
+ */
+CURLcode Curl_dyn_tail(struct dynbuf *s, size_t trail)
+{
+ DEBUGASSERT(s);
+ DEBUGASSERT(s->init == DYNINIT);
+ DEBUGASSERT(!s->leng || s->bufr);
+ if(trail > s->leng)
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+ else if(trail == s->leng)
+ return CURLE_OK;
+ else if(!trail) {
+ Curl_dyn_reset(s);
+ }
+ else {
+ memmove(&s->bufr[0], &s->bufr[s->leng - trail], trail);
+ s->leng = trail;
+ s->bufr[s->leng] = 0;
+ }
+ return CURLE_OK;
+
+}
+#endif
+
+/*
+ * Appends a buffer with length.
+ */
+CURLcode Curl_dyn_addn(struct dynbuf *s, const void *mem, size_t len)
+{
+ DEBUGASSERT(s);
+ DEBUGASSERT(s->init == DYNINIT);
+ DEBUGASSERT(!s->leng || s->bufr);
+ return dyn_nappend(s, mem, len);
+}
+
+/*
+ * Append a null-terminated string at the end.
+ */
+CURLcode Curl_dyn_add(struct dynbuf *s, const char *str)
+{
+ size_t n = strlen(str);
+ DEBUGASSERT(s);
+ DEBUGASSERT(s->init == DYNINIT);
+ DEBUGASSERT(!s->leng || s->bufr);
+ return dyn_nappend(s, (unsigned char *)str, n);
+}
+
+/*
+ * Append a string vprintf()-style
+ */
+CURLcode Curl_dyn_vaddf(struct dynbuf *s, const char *fmt, va_list ap)
+{
+#ifdef BUILDING_LIBCURL
+ int rc;
+ DEBUGASSERT(s);
+ DEBUGASSERT(s->init == DYNINIT);
+ DEBUGASSERT(!s->leng || s->bufr);
+ rc = Curl_dyn_vprintf(s, fmt, ap);
+
+ if(!rc)
+ return CURLE_OK;
+#else
+ char *str;
+ str = vaprintf(fmt, ap); /* this allocs a new string to append */
+
+ if(str) {
+ CURLcode result = dyn_nappend(s, (unsigned char *)str, strlen(str));
+ free(str);
+ return result;
+ }
+ /* If we failed, we cleanup the whole buffer and return error */
+ Curl_dyn_free(s);
+#endif
+ return CURLE_OUT_OF_MEMORY;
+}
+
+/*
+ * Append a string printf()-style
+ */
+CURLcode Curl_dyn_addf(struct dynbuf *s, const char *fmt, ...)
+{
+ CURLcode result;
+ va_list ap;
+ DEBUGASSERT(s);
+ DEBUGASSERT(s->init == DYNINIT);
+ DEBUGASSERT(!s->leng || s->bufr);
+ va_start(ap, fmt);
+ result = Curl_dyn_vaddf(s, fmt, ap);
+ va_end(ap);
+ return result;
+}
+
+/*
+ * Returns a pointer to the buffer.
+ */
+char *Curl_dyn_ptr(const struct dynbuf *s)
+{
+ DEBUGASSERT(s);
+ DEBUGASSERT(s->init == DYNINIT);
+ DEBUGASSERT(!s->leng || s->bufr);
+ return s->bufr;
+}
+
+/*
+ * Returns an unsigned pointer to the buffer.
+ */
+unsigned char *Curl_dyn_uptr(const struct dynbuf *s)
+{
+ DEBUGASSERT(s);
+ DEBUGASSERT(s->init == DYNINIT);
+ DEBUGASSERT(!s->leng || s->bufr);
+ return (unsigned char *)s->bufr;
+}
+
+/*
+ * Returns the length of the buffer.
+ */
+size_t Curl_dyn_len(const struct dynbuf *s)
+{
+ DEBUGASSERT(s);
+ DEBUGASSERT(s->init == DYNINIT);
+ DEBUGASSERT(!s->leng || s->bufr);
+ return s->leng;
+}
diff --git a/contrib/libs/curl/lib/dynbuf.h b/contrib/libs/curl/lib/dynbuf.h
index 11b9d8ad8c..484e40c645 100644
--- a/contrib/libs/curl/lib/dynbuf.h
+++ b/contrib/libs/curl/lib/dynbuf.h
@@ -1,88 +1,88 @@
-#ifndef HEADER_CURL_DYNBUF_H
-#define HEADER_CURL_DYNBUF_H
-/***************************************************************************
- * _ _ ____ _
- * Project ___| | | | _ \| |
- * / __| | | | |_) | |
- * | (__| |_| | _ <| |___
- * \___|\___/|_| \_\_____|
- *
- * Copyright (C) 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
- *
- * You may opt to use, copy, modify, merge, publish, distribute and/or sell
- * copies of the Software, and permit persons to whom the Software is
- * furnished to do so, under the terms of the COPYING file.
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- ***************************************************************************/
-
-#ifndef BUILDING_LIBCURL
-/* this renames the functions so that the tool code can use the same code
- without getting symbol collisions */
-#define Curl_dyn_init(a,b) curlx_dyn_init(a,b)
-#define Curl_dyn_add(a,b) curlx_dyn_add(a,b)
-#define Curl_dyn_addn(a,b,c) curlx_dyn_addn(a,b,c)
-#define Curl_dyn_addf curlx_dyn_addf
-#define Curl_dyn_vaddf curlx_dyn_vaddf
-#define Curl_dyn_free(a) curlx_dyn_free(a)
-#define Curl_dyn_ptr(a) curlx_dyn_ptr(a)
-#define Curl_dyn_uptr(a) curlx_dyn_uptr(a)
-#define Curl_dyn_len(a) curlx_dyn_len(a)
-#define Curl_dyn_reset(a) curlx_dyn_reset(a)
-#define Curl_dyn_tail(a,b) curlx_dyn_tail(a,b)
-#define curlx_dynbuf dynbuf /* for the struct name */
-#endif
-
-struct dynbuf {
- char *bufr; /* point to a null-terminated allocated buffer */
- size_t leng; /* number of bytes *EXCLUDING* the zero terminator */
- size_t allc; /* size of the current allocation */
- size_t toobig; /* size limit for the buffer */
-#ifdef DEBUGBUILD
- int init; /* detect API usage mistakes */
-#endif
-};
-
-void Curl_dyn_init(struct dynbuf *s, size_t toobig);
-void Curl_dyn_free(struct dynbuf *s);
-CURLcode Curl_dyn_addn(struct dynbuf *s, const void *mem, size_t len)
- WARN_UNUSED_RESULT;
-CURLcode Curl_dyn_add(struct dynbuf *s, const char *str)
- WARN_UNUSED_RESULT;
-CURLcode Curl_dyn_addf(struct dynbuf *s, const char *fmt, ...)
- WARN_UNUSED_RESULT;
-CURLcode Curl_dyn_vaddf(struct dynbuf *s, const char *fmt, va_list ap)
- WARN_UNUSED_RESULT;
-void Curl_dyn_reset(struct dynbuf *s);
-CURLcode Curl_dyn_tail(struct dynbuf *s, size_t trail);
-char *Curl_dyn_ptr(const struct dynbuf *s);
-unsigned char *Curl_dyn_uptr(const struct dynbuf *s);
-size_t Curl_dyn_len(const struct dynbuf *s);
-
-/* returns 0 on success, -1 on error */
-/* The implementation of this function exists in mprintf.c */
-int Curl_dyn_vprintf(struct dynbuf *dyn, const char *format, va_list ap_save);
-
-/* Dynamic buffer max sizes */
-#define DYN_DOH_RESPONSE 3000
-#define DYN_DOH_CNAME 256
-#define DYN_PAUSE_BUFFER (64 * 1024 * 1024)
-#define DYN_HAXPROXY 2048
-#define DYN_HTTP_REQUEST (128*1024)
-#define DYN_H2_HEADERS (128*1024)
-#define DYN_H2_TRAILERS (128*1024)
-#define DYN_APRINTF 8000000
-#define DYN_RTSP_REQ_HEADER (64*1024)
-#define DYN_TRAILERS (64*1024)
-#define DYN_PROXY_CONNECT_HEADERS 16384
-#define DYN_QLOG_NAME 1024
-#define DYN_H1_TRAILER 4096
-#define DYN_PINGPPONG_CMD (64*1024)
-#define DYN_IMAP_CMD (64*1024)
-#endif
+#ifndef HEADER_CURL_DYNBUF_H
+#define HEADER_CURL_DYNBUF_H
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 2020, 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
+ * are also available at https://curl.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+
+#ifndef BUILDING_LIBCURL
+/* this renames the functions so that the tool code can use the same code
+ without getting symbol collisions */
+#define Curl_dyn_init(a,b) curlx_dyn_init(a,b)
+#define Curl_dyn_add(a,b) curlx_dyn_add(a,b)
+#define Curl_dyn_addn(a,b,c) curlx_dyn_addn(a,b,c)
+#define Curl_dyn_addf curlx_dyn_addf
+#define Curl_dyn_vaddf curlx_dyn_vaddf
+#define Curl_dyn_free(a) curlx_dyn_free(a)
+#define Curl_dyn_ptr(a) curlx_dyn_ptr(a)
+#define Curl_dyn_uptr(a) curlx_dyn_uptr(a)
+#define Curl_dyn_len(a) curlx_dyn_len(a)
+#define Curl_dyn_reset(a) curlx_dyn_reset(a)
+#define Curl_dyn_tail(a,b) curlx_dyn_tail(a,b)
+#define curlx_dynbuf dynbuf /* for the struct name */
+#endif
+
+struct dynbuf {
+ char *bufr; /* point to a null-terminated allocated buffer */
+ size_t leng; /* number of bytes *EXCLUDING* the zero terminator */
+ size_t allc; /* size of the current allocation */
+ size_t toobig; /* size limit for the buffer */
+#ifdef DEBUGBUILD
+ int init; /* detect API usage mistakes */
+#endif
+};
+
+void Curl_dyn_init(struct dynbuf *s, size_t toobig);
+void Curl_dyn_free(struct dynbuf *s);
+CURLcode Curl_dyn_addn(struct dynbuf *s, const void *mem, size_t len)
+ WARN_UNUSED_RESULT;
+CURLcode Curl_dyn_add(struct dynbuf *s, const char *str)
+ WARN_UNUSED_RESULT;
+CURLcode Curl_dyn_addf(struct dynbuf *s, const char *fmt, ...)
+ WARN_UNUSED_RESULT;
+CURLcode Curl_dyn_vaddf(struct dynbuf *s, const char *fmt, va_list ap)
+ WARN_UNUSED_RESULT;
+void Curl_dyn_reset(struct dynbuf *s);
+CURLcode Curl_dyn_tail(struct dynbuf *s, size_t trail);
+char *Curl_dyn_ptr(const struct dynbuf *s);
+unsigned char *Curl_dyn_uptr(const struct dynbuf *s);
+size_t Curl_dyn_len(const struct dynbuf *s);
+
+/* returns 0 on success, -1 on error */
+/* The implementation of this function exists in mprintf.c */
+int Curl_dyn_vprintf(struct dynbuf *dyn, const char *format, va_list ap_save);
+
+/* Dynamic buffer max sizes */
+#define DYN_DOH_RESPONSE 3000
+#define DYN_DOH_CNAME 256
+#define DYN_PAUSE_BUFFER (64 * 1024 * 1024)
+#define DYN_HAXPROXY 2048
+#define DYN_HTTP_REQUEST (128*1024)
+#define DYN_H2_HEADERS (128*1024)
+#define DYN_H2_TRAILERS (128*1024)
+#define DYN_APRINTF 8000000
+#define DYN_RTSP_REQ_HEADER (64*1024)
+#define DYN_TRAILERS (64*1024)
+#define DYN_PROXY_CONNECT_HEADERS 16384
+#define DYN_QLOG_NAME 1024
+#define DYN_H1_TRAILER 4096
+#define DYN_PINGPPONG_CMD (64*1024)
+#define DYN_IMAP_CMD (64*1024)
+#endif
diff --git a/contrib/libs/curl/lib/easy.c b/contrib/libs/curl/lib/easy.c
index f500a45d4f..dc790b01df 100644
--- a/contrib/libs/curl/lib/easy.c
+++ b/contrib/libs/curl/lib/easy.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -72,14 +72,14 @@
#include "warnless.h"
#include "multiif.h"
#include "sigpipe.h"
-#include "vssh/ssh.h"
+#include "vssh/ssh.h"
#include "setopt.h"
#include "http_digest.h"
#include "system_win32.h"
-#include "http2.h"
-#include "dynbuf.h"
-#include "altsvc.h"
-#include "hsts.h"
+#include "http2.h"
+#include "dynbuf.h"
+#include "altsvc.h"
+#include "hsts.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
@@ -147,20 +147,20 @@ static CURLcode global_init(long flags, bool memoryfuncs)
if(!Curl_ssl_init()) {
DEBUGF(fprintf(stderr, "Error: Curl_ssl_init failed\n"));
- goto fail;
+ goto fail;
}
#ifdef WIN32
if(Curl_win32_init(flags)) {
DEBUGF(fprintf(stderr, "Error: win32_init failed\n"));
- goto fail;
+ goto fail;
}
#endif
#ifdef __AMIGA__
if(!Curl_amiga_init()) {
DEBUGF(fprintf(stderr, "Error: Curl_amiga_init failed\n"));
- goto fail;
+ goto fail;
}
#endif
@@ -172,29 +172,29 @@ static CURLcode global_init(long flags, bool memoryfuncs)
if(Curl_resolver_global_init()) {
DEBUGF(fprintf(stderr, "Error: resolver_global_init failed\n"));
- goto fail;
+ goto fail;
}
#if defined(USE_SSH)
if(Curl_ssh_init()) {
- goto fail;
- }
-#endif
-
-#ifdef USE_WOLFSSH
- if(WS_SUCCESS != wolfSSH_Init()) {
- DEBUGF(fprintf(stderr, "Error: wolfSSH_Init failed\n"));
+ goto fail;
+ }
+#endif
+
+#ifdef USE_WOLFSSH
+ if(WS_SUCCESS != wolfSSH_Init()) {
+ DEBUGF(fprintf(stderr, "Error: wolfSSH_Init failed\n"));
return CURLE_FAILED_INIT;
}
#endif
init_flags = flags;
- return CURLE_OK;
+ return CURLE_OK;
- fail:
- initialized--; /* undo the increase */
- return CURLE_FAILED_INIT;
+ fail:
+ initialized--; /* undo the increase */
+ return CURLE_FAILED_INIT;
}
@@ -262,10 +262,10 @@ void curl_global_cleanup(void)
Curl_ssh_cleanup();
-#ifdef USE_WOLFSSH
- (void)wolfSSH_Cleanup();
-#endif
-
+#ifdef USE_WOLFSSH
+ (void)wolfSSH_Cleanup();
+#endif
+
init_flags = 0;
}
@@ -500,7 +500,7 @@ static CURLcode wait_or_timeout(struct Curl_multi *multi, struct events *ev)
before = Curl_now();
/* wait for activity or timeout */
- pollrc = Curl_poll(fds, numfds, ev->ms);
+ pollrc = Curl_poll(fds, numfds, ev->ms);
after = Curl_now();
@@ -671,7 +671,7 @@ static CURLcode easy_perform(struct Curl_easy *data, bool events)
mcode = curl_multi_add_handle(multi, data);
if(mcode) {
curl_multi_cleanup(multi);
- data->multi_easy = NULL;
+ data->multi_easy = NULL;
if(mcode == CURLM_OUT_OF_MEMORY)
return CURLE_OUT_OF_MEMORY;
return CURLE_FAILED_INIT;
@@ -726,7 +726,7 @@ void curl_easy_cleanup(struct Curl_easy *data)
return;
sigpipe_ignore(data, &pipe_st);
- Curl_close(&data);
+ Curl_close(&data);
sigpipe_restore(&pipe_st);
}
@@ -754,7 +754,7 @@ static CURLcode dupset(struct Curl_easy *dst, struct Curl_easy *src)
{
CURLcode result = CURLE_OK;
enum dupstring i;
- enum dupblob j;
+ enum dupblob j;
/* Copy src->set into dst->set first, then deal with the strings
afterwards */
@@ -771,16 +771,16 @@ static CURLcode dupset(struct Curl_easy *dst, struct Curl_easy *src)
return result;
}
- /* clear all blob pointers first */
- memset(dst->set.blobs, 0, BLOB_LAST * sizeof(struct curl_blob *));
- /* duplicate all blobs */
- for(j = (enum dupblob)0; j < BLOB_LAST; j++) {
- result = Curl_setblobopt(&dst->set.blobs[j], src->set.blobs[j]);
- /* Curl_setstropt return CURLE_BAD_FUNCTION_ARGUMENT with blob */
- if(result)
- return result;
- }
-
+ /* clear all blob pointers first */
+ memset(dst->set.blobs, 0, BLOB_LAST * sizeof(struct curl_blob *));
+ /* duplicate all blobs */
+ for(j = (enum dupblob)0; j < BLOB_LAST; j++) {
+ result = Curl_setblobopt(&dst->set.blobs[j], src->set.blobs[j]);
+ /* Curl_setstropt return CURLE_BAD_FUNCTION_ARGUMENT with blob */
+ if(result)
+ return result;
+ }
+
/* duplicate memory areas pointed to */
i = STRING_COPYPOSTFIELDS;
if(src->set.postfieldsize && src->set.str[i]) {
@@ -824,11 +824,11 @@ struct Curl_easy *curl_easy_duphandle(struct Curl_easy *data)
if(dupset(outcurl, data))
goto fail;
- Curl_dyn_init(&outcurl->state.headerb, CURL_MAX_HTTP_HEADER);
-
+ Curl_dyn_init(&outcurl->state.headerb, CURL_MAX_HTTP_HEADER);
+
/* the connection cache is setup on demand */
outcurl->state.conn_cache = NULL;
- outcurl->state.lastconnect_id = -1;
+ outcurl->state.lastconnect_id = -1;
outcurl->progress.flags = data->progress.flags;
outcurl->progress.callback = data->progress.callback;
@@ -873,54 +873,54 @@ struct Curl_easy *curl_easy_duphandle(struct Curl_easy *data)
goto fail;
}
-#ifdef USE_ALTSVC
- if(data->asi) {
- outcurl->asi = Curl_altsvc_init();
- if(!outcurl->asi)
- goto fail;
- if(outcurl->set.str[STRING_ALTSVC])
- (void)Curl_altsvc_load(outcurl->asi, outcurl->set.str[STRING_ALTSVC]);
- }
-#endif
-#ifdef USE_HSTS
- if(data->hsts) {
- outcurl->hsts = Curl_hsts_init();
- if(!outcurl->hsts)
- goto fail;
- if(outcurl->set.str[STRING_HSTS])
- (void)Curl_hsts_loadfile(outcurl,
- outcurl->hsts, outcurl->set.str[STRING_HSTS]);
- (void)Curl_hsts_loadcb(outcurl, outcurl->hsts);
- }
-#endif
+#ifdef USE_ALTSVC
+ if(data->asi) {
+ outcurl->asi = Curl_altsvc_init();
+ if(!outcurl->asi)
+ goto fail;
+ if(outcurl->set.str[STRING_ALTSVC])
+ (void)Curl_altsvc_load(outcurl->asi, outcurl->set.str[STRING_ALTSVC]);
+ }
+#endif
+#ifdef USE_HSTS
+ if(data->hsts) {
+ outcurl->hsts = Curl_hsts_init();
+ if(!outcurl->hsts)
+ goto fail;
+ if(outcurl->set.str[STRING_HSTS])
+ (void)Curl_hsts_loadfile(outcurl,
+ outcurl->hsts, outcurl->set.str[STRING_HSTS]);
+ (void)Curl_hsts_loadcb(outcurl, outcurl->hsts);
+ }
+#endif
/* Clone the resolver handle, if present, for the new handle */
if(Curl_resolver_duphandle(outcurl,
&outcurl->state.resolver,
data->state.resolver))
goto fail;
-#ifdef USE_ARES
- {
- CURLcode rc;
-
- rc = Curl_set_dns_servers(outcurl, data->set.str[STRING_DNS_SERVERS]);
- if(rc && rc != CURLE_NOT_BUILT_IN)
- goto fail;
-
- rc = Curl_set_dns_interface(outcurl, data->set.str[STRING_DNS_INTERFACE]);
- if(rc && rc != CURLE_NOT_BUILT_IN)
- goto fail;
-
- rc = Curl_set_dns_local_ip4(outcurl, data->set.str[STRING_DNS_LOCAL_IP4]);
- if(rc && rc != CURLE_NOT_BUILT_IN)
- goto fail;
-
- rc = Curl_set_dns_local_ip6(outcurl, data->set.str[STRING_DNS_LOCAL_IP6]);
- if(rc && rc != CURLE_NOT_BUILT_IN)
- goto fail;
- }
-#endif /* USE_ARES */
-
+#ifdef USE_ARES
+ {
+ CURLcode rc;
+
+ rc = Curl_set_dns_servers(outcurl, data->set.str[STRING_DNS_SERVERS]);
+ if(rc && rc != CURLE_NOT_BUILT_IN)
+ goto fail;
+
+ rc = Curl_set_dns_interface(outcurl, data->set.str[STRING_DNS_INTERFACE]);
+ if(rc && rc != CURLE_NOT_BUILT_IN)
+ goto fail;
+
+ rc = Curl_set_dns_local_ip4(outcurl, data->set.str[STRING_DNS_LOCAL_IP4]);
+ if(rc && rc != CURLE_NOT_BUILT_IN)
+ goto fail;
+
+ rc = Curl_set_dns_local_ip6(outcurl, data->set.str[STRING_DNS_LOCAL_IP6]);
+ if(rc && rc != CURLE_NOT_BUILT_IN)
+ goto fail;
+ }
+#endif /* USE_ARES */
+
Curl_convert_setup(outcurl);
Curl_initinfo(outcurl);
@@ -937,11 +937,11 @@ struct Curl_easy *curl_easy_duphandle(struct Curl_easy *data)
curl_slist_free_all(outcurl->change.cookielist);
outcurl->change.cookielist = NULL;
Curl_safefree(outcurl->state.buffer);
- Curl_dyn_free(&outcurl->state.headerb);
+ Curl_dyn_free(&outcurl->state.headerb);
Curl_safefree(outcurl->change.url);
Curl_safefree(outcurl->change.referer);
- Curl_altsvc_cleanup(&outcurl->asi);
- Curl_hsts_cleanup(&outcurl->hsts);
+ Curl_altsvc_cleanup(&outcurl->asi);
+ Curl_hsts_cleanup(&outcurl->hsts);
Curl_freeset(outcurl);
free(outcurl);
}
@@ -970,7 +970,7 @@ void curl_easy_reset(struct Curl_easy *data)
data->progress.flags |= PGRS_HIDE;
data->state.current_speed = -1; /* init to negative == impossible */
- data->state.retrycount = 0; /* reset the retry counter */
+ data->state.retrycount = 0; /* reset the retry counter */
/* zero out authentication data: */
memset(&data->state.authhost, 0, sizeof(struct auth));
@@ -996,102 +996,102 @@ void curl_easy_reset(struct Curl_easy *data)
*/
CURLcode curl_easy_pause(struct Curl_easy *data, int action)
{
- struct SingleRequest *k;
+ struct SingleRequest *k;
CURLcode result = CURLE_OK;
- int oldstate;
- int newstate;
-
- if(!GOOD_EASY_HANDLE(data) || !data->conn)
- /* crazy input, don't continue */
- return CURLE_BAD_FUNCTION_ARGUMENT;
-
- k = &data->req;
- oldstate = k->keepon & (KEEP_RECV_PAUSE| KEEP_SEND_PAUSE);
-
- /* first switch off both pause bits then set the new pause bits */
- newstate = (k->keepon &~ (KEEP_RECV_PAUSE| KEEP_SEND_PAUSE)) |
- ((action & CURLPAUSE_RECV)?KEEP_RECV_PAUSE:0) |
+ int oldstate;
+ int newstate;
+
+ if(!GOOD_EASY_HANDLE(data) || !data->conn)
+ /* crazy input, don't continue */
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+
+ k = &data->req;
+ oldstate = k->keepon & (KEEP_RECV_PAUSE| KEEP_SEND_PAUSE);
+
+ /* first switch off both pause bits then set the new pause bits */
+ newstate = (k->keepon &~ (KEEP_RECV_PAUSE| KEEP_SEND_PAUSE)) |
+ ((action & CURLPAUSE_RECV)?KEEP_RECV_PAUSE:0) |
((action & CURLPAUSE_SEND)?KEEP_SEND_PAUSE:0);
- if((newstate & (KEEP_RECV_PAUSE| KEEP_SEND_PAUSE)) == oldstate) {
- /* Not changing any pause state, return */
- DEBUGF(infof(data, "pause: no change, early return\n"));
- return CURLE_OK;
- }
-
- /* Unpause parts in active mime tree. */
- if((k->keepon & ~newstate & KEEP_SEND_PAUSE) &&
- (data->mstate == CURLM_STATE_PERFORM ||
- data->mstate == CURLM_STATE_TOOFAST) &&
- data->state.fread_func == (curl_read_callback) Curl_mime_read) {
- Curl_mime_unpause(data->state.in);
- }
-
+ if((newstate & (KEEP_RECV_PAUSE| KEEP_SEND_PAUSE)) == oldstate) {
+ /* Not changing any pause state, return */
+ DEBUGF(infof(data, "pause: no change, early return\n"));
+ return CURLE_OK;
+ }
+
+ /* Unpause parts in active mime tree. */
+ if((k->keepon & ~newstate & KEEP_SEND_PAUSE) &&
+ (data->mstate == CURLM_STATE_PERFORM ||
+ data->mstate == CURLM_STATE_TOOFAST) &&
+ data->state.fread_func == (curl_read_callback) Curl_mime_read) {
+ Curl_mime_unpause(data->state.in);
+ }
+
/* put it back in the keepon */
k->keepon = newstate;
- if(!(newstate & KEEP_RECV_PAUSE)) {
- Curl_http2_stream_pause(data, FALSE);
-
- if(data->state.tempcount) {
- /* there are buffers for sending that can be delivered as the receive
- pausing is lifted! */
- unsigned int i;
- unsigned int count = data->state.tempcount;
- struct tempbuf writebuf[3]; /* there can only be three */
- struct connectdata *conn = data->conn;
- struct Curl_easy *saved_data = NULL;
-
- /* copy the structs to allow for immediate re-pausing */
- for(i = 0; i < data->state.tempcount; i++) {
- writebuf[i] = data->state.tempwrite[i];
- Curl_dyn_init(&data->state.tempwrite[i].b, DYN_PAUSE_BUFFER);
- }
- data->state.tempcount = 0;
-
- /* set the connection's current owner */
- if(conn->data != data) {
- saved_data = conn->data;
- conn->data = data;
- }
-
- for(i = 0; i < count; i++) {
- /* even if one function returns error, this loops through and frees
- all buffers */
- if(!result)
- result = Curl_client_write(conn, writebuf[i].type,
- Curl_dyn_ptr(&writebuf[i].b),
- Curl_dyn_len(&writebuf[i].b));
- Curl_dyn_free(&writebuf[i].b);
- }
-
- /* recover previous owner of the connection */
- if(saved_data)
- conn->data = saved_data;
-
- if(result)
- return result;
- }
+ if(!(newstate & KEEP_RECV_PAUSE)) {
+ Curl_http2_stream_pause(data, FALSE);
+
+ if(data->state.tempcount) {
+ /* there are buffers for sending that can be delivered as the receive
+ pausing is lifted! */
+ unsigned int i;
+ unsigned int count = data->state.tempcount;
+ struct tempbuf writebuf[3]; /* there can only be three */
+ struct connectdata *conn = data->conn;
+ struct Curl_easy *saved_data = NULL;
+
+ /* copy the structs to allow for immediate re-pausing */
+ for(i = 0; i < data->state.tempcount; i++) {
+ writebuf[i] = data->state.tempwrite[i];
+ Curl_dyn_init(&data->state.tempwrite[i].b, DYN_PAUSE_BUFFER);
+ }
+ data->state.tempcount = 0;
+
+ /* set the connection's current owner */
+ if(conn->data != data) {
+ saved_data = conn->data;
+ conn->data = data;
+ }
+
+ for(i = 0; i < count; i++) {
+ /* even if one function returns error, this loops through and frees
+ all buffers */
+ if(!result)
+ result = Curl_client_write(conn, writebuf[i].type,
+ Curl_dyn_ptr(&writebuf[i].b),
+ Curl_dyn_len(&writebuf[i].b));
+ Curl_dyn_free(&writebuf[i].b);
+ }
+
+ /* recover previous owner of the connection */
+ if(saved_data)
+ conn->data = saved_data;
+
+ if(result)
+ return result;
+ }
}
/* if there's no error and we're not pausing both directions, we want
to have this handle checked soon */
- if((newstate & (KEEP_RECV_PAUSE|KEEP_SEND_PAUSE)) !=
- (KEEP_RECV_PAUSE|KEEP_SEND_PAUSE)) {
+ if((newstate & (KEEP_RECV_PAUSE|KEEP_SEND_PAUSE)) !=
+ (KEEP_RECV_PAUSE|KEEP_SEND_PAUSE)) {
Curl_expire(data, 0, EXPIRE_RUN_NOW); /* get this handle going again */
-
- if(!data->state.tempcount)
- /* if not pausing again, force a recv/send check of this connection as
- the data might've been read off the socket already */
- data->conn->cselect_bits = CURL_CSELECT_IN | CURL_CSELECT_OUT;
+
+ if(!data->state.tempcount)
+ /* if not pausing again, force a recv/send check of this connection as
+ the data might've been read off the socket already */
+ data->conn->cselect_bits = CURL_CSELECT_IN | CURL_CSELECT_OUT;
if(data->multi)
Curl_update_timer(data->multi);
}
- if(!data->state.done)
- /* This transfer may have been moved in or out of the bundle, update the
- corresponding socket callback, if used */
- Curl_updatesocket(data);
+ if(!data->state.done)
+ /* This transfer may have been moved in or out of the bundle, update the
+ corresponding socket callback, if used */
+ Curl_updatesocket(data);
return result;
}
diff --git a/contrib/libs/curl/lib/easygetopt.c b/contrib/libs/curl/lib/easygetopt.c
index 0a8b89ef38..7b2213fb24 100644
--- a/contrib/libs/curl/lib/easygetopt.c
+++ b/contrib/libs/curl/lib/easygetopt.c
@@ -1,96 +1,96 @@
-/***************************************************************************
- * _ _ ____ _
- * Project ___| | | | _ | |
- * / __| | | | |_) | |
- * | (__| |_| | _ <| |___
- * ___|___/|_| ______|
- *
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel.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
- * are also available at https://curl.se/docs/copyright.html.
- *
- * You may opt to use, copy, modify, merge, publish, distribute and/or sell
- * copies of the Software, and permit persons to whom the Software is
- * furnished to do so, under the terms of the COPYING file.
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- ***************************************************************************/
-
-#include "curl_setup.h"
-#include "strcase.h"
-#include "easyoptions.h"
-
-#ifndef CURL_DISABLE_GETOPTIONS
-
-/* Lookups easy options at runtime */
-static struct curl_easyoption *lookup(const char *name, CURLoption id)
-{
- DEBUGASSERT(name || id);
- DEBUGASSERT(!Curl_easyopts_check());
- if(name || id) {
- struct curl_easyoption *o = &Curl_easyopts[0];
- do {
- if(name) {
- if(strcasecompare(o->name, name))
- return o;
- }
- else {
- if((o->id == id) && !(o->flags & CURLOT_FLAG_ALIAS))
- /* don't match alias options */
- return o;
- }
- o++;
- } while(o->name);
- }
- return NULL;
-}
-
-const struct curl_easyoption *curl_easy_option_by_name(const char *name)
-{
- /* when name is used, the id argument is ignored */
- return lookup(name, CURLOPT_LASTENTRY);
-}
-
-const struct curl_easyoption *curl_easy_option_by_id(CURLoption id)
-{
- return lookup(NULL, id);
-}
-
-/* Iterates over available options */
-const struct curl_easyoption *
-curl_easy_option_next(const struct curl_easyoption *prev)
-{
- if(prev && prev->name) {
- prev++;
- if(prev->name)
- return prev;
- }
- else if(!prev)
- return &Curl_easyopts[0];
- return NULL;
-}
-
-#else
-const struct curl_easyoption *curl_easy_option_by_name(const char *name)
-{
- (void)name;
- return NULL;
-}
-
-const struct curl_easyoption *curl_easy_option_by_id (CURLoption id)
-{
- (void)id;
- return NULL;
-}
-
-const struct curl_easyoption *
-curl_easy_option_next(const struct curl_easyoption *prev)
-{
- (void)prev;
- return NULL;
-}
-#endif
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ | |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * ___|___/|_| ______|
+ *
+ * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel.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
+ * are also available at https://curl.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+
+#include "curl_setup.h"
+#include "strcase.h"
+#include "easyoptions.h"
+
+#ifndef CURL_DISABLE_GETOPTIONS
+
+/* Lookups easy options at runtime */
+static struct curl_easyoption *lookup(const char *name, CURLoption id)
+{
+ DEBUGASSERT(name || id);
+ DEBUGASSERT(!Curl_easyopts_check());
+ if(name || id) {
+ struct curl_easyoption *o = &Curl_easyopts[0];
+ do {
+ if(name) {
+ if(strcasecompare(o->name, name))
+ return o;
+ }
+ else {
+ if((o->id == id) && !(o->flags & CURLOT_FLAG_ALIAS))
+ /* don't match alias options */
+ return o;
+ }
+ o++;
+ } while(o->name);
+ }
+ return NULL;
+}
+
+const struct curl_easyoption *curl_easy_option_by_name(const char *name)
+{
+ /* when name is used, the id argument is ignored */
+ return lookup(name, CURLOPT_LASTENTRY);
+}
+
+const struct curl_easyoption *curl_easy_option_by_id(CURLoption id)
+{
+ return lookup(NULL, id);
+}
+
+/* Iterates over available options */
+const struct curl_easyoption *
+curl_easy_option_next(const struct curl_easyoption *prev)
+{
+ if(prev && prev->name) {
+ prev++;
+ if(prev->name)
+ return prev;
+ }
+ else if(!prev)
+ return &Curl_easyopts[0];
+ return NULL;
+}
+
+#else
+const struct curl_easyoption *curl_easy_option_by_name(const char *name)
+{
+ (void)name;
+ return NULL;
+}
+
+const struct curl_easyoption *curl_easy_option_by_id (CURLoption id)
+{
+ (void)id;
+ return NULL;
+}
+
+const struct curl_easyoption *
+curl_easy_option_next(const struct curl_easyoption *prev)
+{
+ (void)prev;
+ return NULL;
+}
+#endif
diff --git a/contrib/libs/curl/lib/easyif.h b/contrib/libs/curl/lib/easyif.h
index 1ad39b8cf9..3364418285 100644
--- a/contrib/libs/curl/lib/easyif.h
+++ b/contrib/libs/curl/lib/easyif.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/easyoptions.c b/contrib/libs/curl/lib/easyoptions.c
index c615568c7d..f236da23ab 100644
--- a/contrib/libs/curl/lib/easyoptions.c
+++ b/contrib/libs/curl/lib/easyoptions.c
@@ -1,353 +1,353 @@
-/***************************************************************************
- * _ _ ____ _
- * Project ___| | | | _ | |
- * / __| | | | |_) | |
- * | (__| |_| | _ <| |___
- * ___|___/|_| ______|
- *
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel.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
- * are also available at https://curl.se/docs/copyright.html.
- *
- * You may opt to use, copy, modify, merge, publish, distribute and/or sell
- * copies of the Software, and permit persons to whom the Software is
- * furnished to do so, under the terms of the COPYING file.
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- ***************************************************************************/
-
-/* This source code is generated by optiontable.pl - DO NOT EDIT BY HAND */
-
-#include "curl_setup.h"
-#include "easyoptions.h"
-
-/* all easy setopt options listed in alphabetical order */
-struct curl_easyoption Curl_easyopts[] = {
- {"ABSTRACT_UNIX_SOCKET", CURLOPT_ABSTRACT_UNIX_SOCKET, CURLOT_STRING, 0},
- {"ACCEPTTIMEOUT_MS", CURLOPT_ACCEPTTIMEOUT_MS, CURLOT_LONG, 0},
- {"ACCEPT_ENCODING", CURLOPT_ACCEPT_ENCODING, CURLOT_STRING, 0},
- {"ADDRESS_SCOPE", CURLOPT_ADDRESS_SCOPE, CURLOT_LONG, 0},
- {"ALTSVC", CURLOPT_ALTSVC, CURLOT_STRING, 0},
- {"ALTSVC_CTRL", CURLOPT_ALTSVC_CTRL, CURLOT_LONG, 0},
- {"APPEND", CURLOPT_APPEND, CURLOT_LONG, 0},
- {"AUTOREFERER", CURLOPT_AUTOREFERER, CURLOT_LONG, 0},
- {"BUFFERSIZE", CURLOPT_BUFFERSIZE, CURLOT_LONG, 0},
- {"CAINFO", CURLOPT_CAINFO, CURLOT_STRING, 0},
- {"CAPATH", CURLOPT_CAPATH, CURLOT_STRING, 0},
- {"CERTINFO", CURLOPT_CERTINFO, CURLOT_LONG, 0},
- {"CHUNK_BGN_FUNCTION", CURLOPT_CHUNK_BGN_FUNCTION, CURLOT_FUNCTION, 0},
- {"CHUNK_DATA", CURLOPT_CHUNK_DATA, CURLOT_CBPTR, 0},
- {"CHUNK_END_FUNCTION", CURLOPT_CHUNK_END_FUNCTION, CURLOT_FUNCTION, 0},
- {"CLOSESOCKETDATA", CURLOPT_CLOSESOCKETDATA, CURLOT_CBPTR, 0},
- {"CLOSESOCKETFUNCTION", CURLOPT_CLOSESOCKETFUNCTION, CURLOT_FUNCTION, 0},
- {"CONNECTTIMEOUT", CURLOPT_CONNECTTIMEOUT, CURLOT_LONG, 0},
- {"CONNECTTIMEOUT_MS", CURLOPT_CONNECTTIMEOUT_MS, CURLOT_LONG, 0},
- {"CONNECT_ONLY", CURLOPT_CONNECT_ONLY, CURLOT_LONG, 0},
- {"CONNECT_TO", CURLOPT_CONNECT_TO, CURLOT_SLIST, 0},
- {"CONV_FROM_NETWORK_FUNCTION", CURLOPT_CONV_FROM_NETWORK_FUNCTION,
- CURLOT_FUNCTION, 0},
- {"CONV_FROM_UTF8_FUNCTION", CURLOPT_CONV_FROM_UTF8_FUNCTION,
- CURLOT_FUNCTION, 0},
- {"CONV_TO_NETWORK_FUNCTION", CURLOPT_CONV_TO_NETWORK_FUNCTION,
- CURLOT_FUNCTION, 0},
- {"COOKIE", CURLOPT_COOKIE, CURLOT_STRING, 0},
- {"COOKIEFILE", CURLOPT_COOKIEFILE, CURLOT_STRING, 0},
- {"COOKIEJAR", CURLOPT_COOKIEJAR, CURLOT_STRING, 0},
- {"COOKIELIST", CURLOPT_COOKIELIST, CURLOT_STRING, 0},
- {"COOKIESESSION", CURLOPT_COOKIESESSION, CURLOT_LONG, 0},
- {"COPYPOSTFIELDS", CURLOPT_COPYPOSTFIELDS, CURLOT_OBJECT, 0},
- {"CRLF", CURLOPT_CRLF, CURLOT_LONG, 0},
- {"CRLFILE", CURLOPT_CRLFILE, CURLOT_STRING, 0},
- {"CURLU", CURLOPT_CURLU, CURLOT_OBJECT, 0},
- {"CUSTOMREQUEST", CURLOPT_CUSTOMREQUEST, CURLOT_STRING, 0},
- {"DEBUGDATA", CURLOPT_DEBUGDATA, CURLOT_CBPTR, 0},
- {"DEBUGFUNCTION", CURLOPT_DEBUGFUNCTION, CURLOT_FUNCTION, 0},
- {"DEFAULT_PROTOCOL", CURLOPT_DEFAULT_PROTOCOL, CURLOT_STRING, 0},
- {"DIRLISTONLY", CURLOPT_DIRLISTONLY, CURLOT_LONG, 0},
- {"DISALLOW_USERNAME_IN_URL", CURLOPT_DISALLOW_USERNAME_IN_URL,
- CURLOT_LONG, 0},
- {"DNS_CACHE_TIMEOUT", CURLOPT_DNS_CACHE_TIMEOUT, CURLOT_LONG, 0},
- {"DNS_INTERFACE", CURLOPT_DNS_INTERFACE, CURLOT_STRING, 0},
- {"DNS_LOCAL_IP4", CURLOPT_DNS_LOCAL_IP4, CURLOT_STRING, 0},
- {"DNS_LOCAL_IP6", CURLOPT_DNS_LOCAL_IP6, CURLOT_STRING, 0},
- {"DNS_SERVERS", CURLOPT_DNS_SERVERS, CURLOT_STRING, 0},
- {"DNS_SHUFFLE_ADDRESSES", CURLOPT_DNS_SHUFFLE_ADDRESSES, CURLOT_LONG, 0},
- {"DNS_USE_GLOBAL_CACHE", CURLOPT_DNS_USE_GLOBAL_CACHE, CURLOT_LONG, 0},
- {"DOH_URL", CURLOPT_DOH_URL, CURLOT_STRING, 0},
- {"EGDSOCKET", CURLOPT_EGDSOCKET, CURLOT_STRING, 0},
- {"ENCODING", CURLOPT_ACCEPT_ENCODING, CURLOT_STRING, CURLOT_FLAG_ALIAS},
- {"ERRORBUFFER", CURLOPT_ERRORBUFFER, CURLOT_OBJECT, 0},
- {"EXPECT_100_TIMEOUT_MS", CURLOPT_EXPECT_100_TIMEOUT_MS, CURLOT_LONG, 0},
- {"FAILONERROR", CURLOPT_FAILONERROR, CURLOT_LONG, 0},
- {"FILE", CURLOPT_WRITEDATA, CURLOT_CBPTR, CURLOT_FLAG_ALIAS},
- {"FILETIME", CURLOPT_FILETIME, CURLOT_LONG, 0},
- {"FNMATCH_DATA", CURLOPT_FNMATCH_DATA, CURLOT_CBPTR, 0},
- {"FNMATCH_FUNCTION", CURLOPT_FNMATCH_FUNCTION, CURLOT_FUNCTION, 0},
- {"FOLLOWLOCATION", CURLOPT_FOLLOWLOCATION, CURLOT_LONG, 0},
- {"FORBID_REUSE", CURLOPT_FORBID_REUSE, CURLOT_LONG, 0},
- {"FRESH_CONNECT", CURLOPT_FRESH_CONNECT, CURLOT_LONG, 0},
- {"FTPAPPEND", CURLOPT_APPEND, CURLOT_LONG, CURLOT_FLAG_ALIAS},
- {"FTPLISTONLY", CURLOPT_DIRLISTONLY, CURLOT_LONG, CURLOT_FLAG_ALIAS},
- {"FTPPORT", CURLOPT_FTPPORT, CURLOT_STRING, 0},
- {"FTPSSLAUTH", CURLOPT_FTPSSLAUTH, CURLOT_VALUES, 0},
- {"FTP_ACCOUNT", CURLOPT_FTP_ACCOUNT, CURLOT_STRING, 0},
- {"FTP_ALTERNATIVE_TO_USER", CURLOPT_FTP_ALTERNATIVE_TO_USER,
- CURLOT_STRING, 0},
- {"FTP_CREATE_MISSING_DIRS", CURLOPT_FTP_CREATE_MISSING_DIRS,
- CURLOT_LONG, 0},
- {"FTP_FILEMETHOD", CURLOPT_FTP_FILEMETHOD, CURLOT_VALUES, 0},
- {"FTP_RESPONSE_TIMEOUT", CURLOPT_FTP_RESPONSE_TIMEOUT, CURLOT_LONG, 0},
- {"FTP_SKIP_PASV_IP", CURLOPT_FTP_SKIP_PASV_IP, CURLOT_LONG, 0},
- {"FTP_SSL", CURLOPT_USE_SSL, CURLOT_VALUES, CURLOT_FLAG_ALIAS},
- {"FTP_SSL_CCC", CURLOPT_FTP_SSL_CCC, CURLOT_LONG, 0},
- {"FTP_USE_EPRT", CURLOPT_FTP_USE_EPRT, CURLOT_LONG, 0},
- {"FTP_USE_EPSV", CURLOPT_FTP_USE_EPSV, CURLOT_LONG, 0},
- {"FTP_USE_PRET", CURLOPT_FTP_USE_PRET, CURLOT_LONG, 0},
- {"GSSAPI_DELEGATION", CURLOPT_GSSAPI_DELEGATION, CURLOT_VALUES, 0},
- {"HAPPY_EYEBALLS_TIMEOUT_MS", CURLOPT_HAPPY_EYEBALLS_TIMEOUT_MS,
- CURLOT_LONG, 0},
- {"HAPROXYPROTOCOL", CURLOPT_HAPROXYPROTOCOL, CURLOT_LONG, 0},
- {"HEADER", CURLOPT_HEADER, CURLOT_LONG, 0},
- {"HEADERDATA", CURLOPT_HEADERDATA, CURLOT_CBPTR, 0},
- {"HEADERFUNCTION", CURLOPT_HEADERFUNCTION, CURLOT_FUNCTION, 0},
- {"HEADEROPT", CURLOPT_HEADEROPT, CURLOT_VALUES, 0},
- {"HSTS", CURLOPT_HSTS, CURLOT_STRING, 0},
- {"HSTSREADDATA", CURLOPT_HSTSREADDATA, CURLOT_CBPTR, 0},
- {"HSTSREADFUNCTION", CURLOPT_HSTSREADFUNCTION, CURLOT_FUNCTION, 0},
- {"HSTSWRITEDATA", CURLOPT_HSTSWRITEDATA, CURLOT_CBPTR, 0},
- {"HSTSWRITEFUNCTION", CURLOPT_HSTSWRITEFUNCTION, CURLOT_FUNCTION, 0},
- {"HSTS_CTRL", CURLOPT_HSTS_CTRL, CURLOT_LONG, 0},
- {"HTTP09_ALLOWED", CURLOPT_HTTP09_ALLOWED, CURLOT_LONG, 0},
- {"HTTP200ALIASES", CURLOPT_HTTP200ALIASES, CURLOT_SLIST, 0},
- {"HTTPAUTH", CURLOPT_HTTPAUTH, CURLOT_VALUES, 0},
- {"HTTPGET", CURLOPT_HTTPGET, CURLOT_LONG, 0},
- {"HTTPHEADER", CURLOPT_HTTPHEADER, CURLOT_SLIST, 0},
- {"HTTPPOST", CURLOPT_HTTPPOST, CURLOT_OBJECT, 0},
- {"HTTPPROXYTUNNEL", CURLOPT_HTTPPROXYTUNNEL, CURLOT_LONG, 0},
- {"HTTP_CONTENT_DECODING", CURLOPT_HTTP_CONTENT_DECODING, CURLOT_LONG, 0},
- {"HTTP_TRANSFER_DECODING", CURLOPT_HTTP_TRANSFER_DECODING, CURLOT_LONG, 0},
- {"HTTP_VERSION", CURLOPT_HTTP_VERSION, CURLOT_VALUES, 0},
- {"IGNORE_CONTENT_LENGTH", CURLOPT_IGNORE_CONTENT_LENGTH, CURLOT_LONG, 0},
- {"INFILE", CURLOPT_READDATA, CURLOT_CBPTR, CURLOT_FLAG_ALIAS},
- {"INFILESIZE", CURLOPT_INFILESIZE, CURLOT_LONG, 0},
- {"INFILESIZE_LARGE", CURLOPT_INFILESIZE_LARGE, CURLOT_OFF_T, 0},
- {"INTERFACE", CURLOPT_INTERFACE, CURLOT_STRING, 0},
- {"INTERLEAVEDATA", CURLOPT_INTERLEAVEDATA, CURLOT_CBPTR, 0},
- {"INTERLEAVEFUNCTION", CURLOPT_INTERLEAVEFUNCTION, CURLOT_FUNCTION, 0},
- {"IOCTLDATA", CURLOPT_IOCTLDATA, CURLOT_CBPTR, 0},
- {"IOCTLFUNCTION", CURLOPT_IOCTLFUNCTION, CURLOT_FUNCTION, 0},
- {"IPRESOLVE", CURLOPT_IPRESOLVE, CURLOT_VALUES, 0},
- {"ISSUERCERT", CURLOPT_ISSUERCERT, CURLOT_STRING, 0},
- {"ISSUERCERT_BLOB", CURLOPT_ISSUERCERT_BLOB, CURLOT_BLOB, 0},
- {"KEEP_SENDING_ON_ERROR", CURLOPT_KEEP_SENDING_ON_ERROR, CURLOT_LONG, 0},
- {"KEYPASSWD", CURLOPT_KEYPASSWD, CURLOT_STRING, 0},
- {"KRB4LEVEL", CURLOPT_KRBLEVEL, CURLOT_STRING, CURLOT_FLAG_ALIAS},
- {"KRBLEVEL", CURLOPT_KRBLEVEL, CURLOT_STRING, 0},
- {"LOCALPORT", CURLOPT_LOCALPORT, CURLOT_LONG, 0},
- {"LOCALPORTRANGE", CURLOPT_LOCALPORTRANGE, CURLOT_LONG, 0},
- {"LOGIN_OPTIONS", CURLOPT_LOGIN_OPTIONS, CURLOT_STRING, 0},
- {"LOW_SPEED_LIMIT", CURLOPT_LOW_SPEED_LIMIT, CURLOT_LONG, 0},
- {"LOW_SPEED_TIME", CURLOPT_LOW_SPEED_TIME, CURLOT_LONG, 0},
- {"MAIL_AUTH", CURLOPT_MAIL_AUTH, CURLOT_STRING, 0},
- {"MAIL_FROM", CURLOPT_MAIL_FROM, CURLOT_STRING, 0},
- {"MAIL_RCPT", CURLOPT_MAIL_RCPT, CURLOT_SLIST, 0},
- {"MAIL_RCPT_ALLLOWFAILS", CURLOPT_MAIL_RCPT_ALLLOWFAILS, CURLOT_LONG, 0},
- {"MAXAGE_CONN", CURLOPT_MAXAGE_CONN, CURLOT_LONG, 0},
- {"MAXCONNECTS", CURLOPT_MAXCONNECTS, CURLOT_LONG, 0},
- {"MAXFILESIZE", CURLOPT_MAXFILESIZE, CURLOT_LONG, 0},
- {"MAXFILESIZE_LARGE", CURLOPT_MAXFILESIZE_LARGE, CURLOT_OFF_T, 0},
- {"MAXREDIRS", CURLOPT_MAXREDIRS, CURLOT_LONG, 0},
- {"MAX_RECV_SPEED_LARGE", CURLOPT_MAX_RECV_SPEED_LARGE, CURLOT_OFF_T, 0},
- {"MAX_SEND_SPEED_LARGE", CURLOPT_MAX_SEND_SPEED_LARGE, CURLOT_OFF_T, 0},
- {"MIMEPOST", CURLOPT_MIMEPOST, CURLOT_OBJECT, 0},
- {"NETRC", CURLOPT_NETRC, CURLOT_VALUES, 0},
- {"NETRC_FILE", CURLOPT_NETRC_FILE, CURLOT_STRING, 0},
- {"NEW_DIRECTORY_PERMS", CURLOPT_NEW_DIRECTORY_PERMS, CURLOT_LONG, 0},
- {"NEW_FILE_PERMS", CURLOPT_NEW_FILE_PERMS, CURLOT_LONG, 0},
- {"NOBODY", CURLOPT_NOBODY, CURLOT_LONG, 0},
- {"NOPROGRESS", CURLOPT_NOPROGRESS, CURLOT_LONG, 0},
- {"NOPROXY", CURLOPT_NOPROXY, CURLOT_STRING, 0},
- {"NOSIGNAL", CURLOPT_NOSIGNAL, CURLOT_LONG, 0},
- {"OPENSOCKETDATA", CURLOPT_OPENSOCKETDATA, CURLOT_CBPTR, 0},
- {"OPENSOCKETFUNCTION", CURLOPT_OPENSOCKETFUNCTION, CURLOT_FUNCTION, 0},
- {"PASSWORD", CURLOPT_PASSWORD, CURLOT_STRING, 0},
- {"PATH_AS_IS", CURLOPT_PATH_AS_IS, CURLOT_LONG, 0},
- {"PINNEDPUBLICKEY", CURLOPT_PINNEDPUBLICKEY, CURLOT_STRING, 0},
- {"PIPEWAIT", CURLOPT_PIPEWAIT, CURLOT_LONG, 0},
- {"PORT", CURLOPT_PORT, CURLOT_LONG, 0},
- {"POST", CURLOPT_POST, CURLOT_LONG, 0},
- {"POST301", CURLOPT_POSTREDIR, CURLOT_VALUES, CURLOT_FLAG_ALIAS},
- {"POSTFIELDS", CURLOPT_POSTFIELDS, CURLOT_OBJECT, 0},
- {"POSTFIELDSIZE", CURLOPT_POSTFIELDSIZE, CURLOT_LONG, 0},
- {"POSTFIELDSIZE_LARGE", CURLOPT_POSTFIELDSIZE_LARGE, CURLOT_OFF_T, 0},
- {"POSTQUOTE", CURLOPT_POSTQUOTE, CURLOT_SLIST, 0},
- {"POSTREDIR", CURLOPT_POSTREDIR, CURLOT_VALUES, 0},
- {"PREQUOTE", CURLOPT_PREQUOTE, CURLOT_SLIST, 0},
- {"PRE_PROXY", CURLOPT_PRE_PROXY, CURLOT_STRING, 0},
- {"PRIVATE", CURLOPT_PRIVATE, CURLOT_OBJECT, 0},
- {"PROGRESSDATA", CURLOPT_XFERINFODATA, CURLOT_CBPTR, CURLOT_FLAG_ALIAS},
- {"PROGRESSFUNCTION", CURLOPT_PROGRESSFUNCTION, CURLOT_FUNCTION, 0},
- {"PROTOCOLS", CURLOPT_PROTOCOLS, CURLOT_LONG, 0},
- {"PROXY", CURLOPT_PROXY, CURLOT_STRING, 0},
- {"PROXYAUTH", CURLOPT_PROXYAUTH, CURLOT_VALUES, 0},
- {"PROXYHEADER", CURLOPT_PROXYHEADER, CURLOT_SLIST, 0},
- {"PROXYPASSWORD", CURLOPT_PROXYPASSWORD, CURLOT_STRING, 0},
- {"PROXYPORT", CURLOPT_PROXYPORT, CURLOT_LONG, 0},
- {"PROXYTYPE", CURLOPT_PROXYTYPE, CURLOT_VALUES, 0},
- {"PROXYUSERNAME", CURLOPT_PROXYUSERNAME, CURLOT_STRING, 0},
- {"PROXYUSERPWD", CURLOPT_PROXYUSERPWD, CURLOT_STRING, 0},
- {"PROXY_CAINFO", CURLOPT_PROXY_CAINFO, CURLOT_STRING, 0},
- {"PROXY_CAPATH", CURLOPT_PROXY_CAPATH, CURLOT_STRING, 0},
- {"PROXY_CRLFILE", CURLOPT_PROXY_CRLFILE, CURLOT_STRING, 0},
- {"PROXY_ISSUERCERT", CURLOPT_PROXY_ISSUERCERT, CURLOT_STRING, 0},
- {"PROXY_ISSUERCERT_BLOB", CURLOPT_PROXY_ISSUERCERT_BLOB, CURLOT_BLOB, 0},
- {"PROXY_KEYPASSWD", CURLOPT_PROXY_KEYPASSWD, CURLOT_STRING, 0},
- {"PROXY_PINNEDPUBLICKEY", CURLOPT_PROXY_PINNEDPUBLICKEY, CURLOT_STRING, 0},
- {"PROXY_SERVICE_NAME", CURLOPT_PROXY_SERVICE_NAME, CURLOT_STRING, 0},
- {"PROXY_SSLCERT", CURLOPT_PROXY_SSLCERT, CURLOT_STRING, 0},
- {"PROXY_SSLCERTTYPE", CURLOPT_PROXY_SSLCERTTYPE, CURLOT_STRING, 0},
- {"PROXY_SSLCERT_BLOB", CURLOPT_PROXY_SSLCERT_BLOB, CURLOT_BLOB, 0},
- {"PROXY_SSLKEY", CURLOPT_PROXY_SSLKEY, CURLOT_STRING, 0},
- {"PROXY_SSLKEYTYPE", CURLOPT_PROXY_SSLKEYTYPE, CURLOT_STRING, 0},
- {"PROXY_SSLKEY_BLOB", CURLOPT_PROXY_SSLKEY_BLOB, CURLOT_BLOB, 0},
- {"PROXY_SSLVERSION", CURLOPT_PROXY_SSLVERSION, CURLOT_VALUES, 0},
- {"PROXY_SSL_CIPHER_LIST", CURLOPT_PROXY_SSL_CIPHER_LIST, CURLOT_STRING, 0},
- {"PROXY_SSL_OPTIONS", CURLOPT_PROXY_SSL_OPTIONS, CURLOT_LONG, 0},
- {"PROXY_SSL_VERIFYHOST", CURLOPT_PROXY_SSL_VERIFYHOST, CURLOT_LONG, 0},
- {"PROXY_SSL_VERIFYPEER", CURLOPT_PROXY_SSL_VERIFYPEER, CURLOT_LONG, 0},
- {"PROXY_TLS13_CIPHERS", CURLOPT_PROXY_TLS13_CIPHERS, CURLOT_STRING, 0},
- {"PROXY_TLSAUTH_PASSWORD", CURLOPT_PROXY_TLSAUTH_PASSWORD,
- CURLOT_STRING, 0},
- {"PROXY_TLSAUTH_TYPE", CURLOPT_PROXY_TLSAUTH_TYPE, CURLOT_STRING, 0},
- {"PROXY_TLSAUTH_USERNAME", CURLOPT_PROXY_TLSAUTH_USERNAME,
- CURLOT_STRING, 0},
- {"PROXY_TRANSFER_MODE", CURLOPT_PROXY_TRANSFER_MODE, CURLOT_LONG, 0},
- {"PUT", CURLOPT_PUT, CURLOT_LONG, 0},
- {"QUOTE", CURLOPT_QUOTE, CURLOT_SLIST, 0},
- {"RANDOM_FILE", CURLOPT_RANDOM_FILE, CURLOT_STRING, 0},
- {"RANGE", CURLOPT_RANGE, CURLOT_STRING, 0},
- {"READDATA", CURLOPT_READDATA, CURLOT_CBPTR, 0},
- {"READFUNCTION", CURLOPT_READFUNCTION, CURLOT_FUNCTION, 0},
- {"REDIR_PROTOCOLS", CURLOPT_REDIR_PROTOCOLS, CURLOT_LONG, 0},
- {"REFERER", CURLOPT_REFERER, CURLOT_STRING, 0},
- {"REQUEST_TARGET", CURLOPT_REQUEST_TARGET, CURLOT_STRING, 0},
- {"RESOLVE", CURLOPT_RESOLVE, CURLOT_SLIST, 0},
- {"RESOLVER_START_DATA", CURLOPT_RESOLVER_START_DATA, CURLOT_CBPTR, 0},
- {"RESOLVER_START_FUNCTION", CURLOPT_RESOLVER_START_FUNCTION,
- CURLOT_FUNCTION, 0},
- {"RESUME_FROM", CURLOPT_RESUME_FROM, CURLOT_LONG, 0},
- {"RESUME_FROM_LARGE", CURLOPT_RESUME_FROM_LARGE, CURLOT_OFF_T, 0},
- {"RTSPHEADER", CURLOPT_HTTPHEADER, CURLOT_SLIST, CURLOT_FLAG_ALIAS},
- {"RTSP_CLIENT_CSEQ", CURLOPT_RTSP_CLIENT_CSEQ, CURLOT_LONG, 0},
- {"RTSP_REQUEST", CURLOPT_RTSP_REQUEST, CURLOT_VALUES, 0},
- {"RTSP_SERVER_CSEQ", CURLOPT_RTSP_SERVER_CSEQ, CURLOT_LONG, 0},
- {"RTSP_SESSION_ID", CURLOPT_RTSP_SESSION_ID, CURLOT_STRING, 0},
- {"RTSP_STREAM_URI", CURLOPT_RTSP_STREAM_URI, CURLOT_STRING, 0},
- {"RTSP_TRANSPORT", CURLOPT_RTSP_TRANSPORT, CURLOT_STRING, 0},
- {"SASL_AUTHZID", CURLOPT_SASL_AUTHZID, CURLOT_STRING, 0},
- {"SASL_IR", CURLOPT_SASL_IR, CURLOT_LONG, 0},
- {"SEEKDATA", CURLOPT_SEEKDATA, CURLOT_CBPTR, 0},
- {"SEEKFUNCTION", CURLOPT_SEEKFUNCTION, CURLOT_FUNCTION, 0},
- {"SERVER_RESPONSE_TIMEOUT", CURLOPT_FTP_RESPONSE_TIMEOUT,
- CURLOT_LONG, CURLOT_FLAG_ALIAS},
- {"SERVICE_NAME", CURLOPT_SERVICE_NAME, CURLOT_STRING, 0},
- {"SHARE", CURLOPT_SHARE, CURLOT_OBJECT, 0},
- {"SOCKOPTDATA", CURLOPT_SOCKOPTDATA, CURLOT_CBPTR, 0},
- {"SOCKOPTFUNCTION", CURLOPT_SOCKOPTFUNCTION, CURLOT_FUNCTION, 0},
- {"SOCKS5_AUTH", CURLOPT_SOCKS5_AUTH, CURLOT_LONG, 0},
- {"SOCKS5_GSSAPI_NEC", CURLOPT_SOCKS5_GSSAPI_NEC, CURLOT_LONG, 0},
- {"SOCKS5_GSSAPI_SERVICE", CURLOPT_SOCKS5_GSSAPI_SERVICE, CURLOT_STRING, 0},
- {"SSH_AUTH_TYPES", CURLOPT_SSH_AUTH_TYPES, CURLOT_VALUES, 0},
- {"SSH_COMPRESSION", CURLOPT_SSH_COMPRESSION, CURLOT_LONG, 0},
- {"SSH_HOST_PUBLIC_KEY_MD5", CURLOPT_SSH_HOST_PUBLIC_KEY_MD5,
- CURLOT_STRING, 0},
- {"SSH_KEYDATA", CURLOPT_SSH_KEYDATA, CURLOT_CBPTR, 0},
- {"SSH_KEYFUNCTION", CURLOPT_SSH_KEYFUNCTION, CURLOT_FUNCTION, 0},
- {"SSH_KNOWNHOSTS", CURLOPT_SSH_KNOWNHOSTS, CURLOT_STRING, 0},
- {"SSH_PRIVATE_KEYFILE", CURLOPT_SSH_PRIVATE_KEYFILE, CURLOT_STRING, 0},
- {"SSH_PUBLIC_KEYFILE", CURLOPT_SSH_PUBLIC_KEYFILE, CURLOT_STRING, 0},
- {"SSLCERT", CURLOPT_SSLCERT, CURLOT_STRING, 0},
- {"SSLCERTPASSWD", CURLOPT_KEYPASSWD, CURLOT_STRING, CURLOT_FLAG_ALIAS},
- {"SSLCERTTYPE", CURLOPT_SSLCERTTYPE, CURLOT_STRING, 0},
- {"SSLCERT_BLOB", CURLOPT_SSLCERT_BLOB, CURLOT_BLOB, 0},
- {"SSLENGINE", CURLOPT_SSLENGINE, CURLOT_STRING, 0},
- {"SSLENGINE_DEFAULT", CURLOPT_SSLENGINE_DEFAULT, CURLOT_LONG, 0},
- {"SSLKEY", CURLOPT_SSLKEY, CURLOT_STRING, 0},
- {"SSLKEYPASSWD", CURLOPT_KEYPASSWD, CURLOT_STRING, CURLOT_FLAG_ALIAS},
- {"SSLKEYTYPE", CURLOPT_SSLKEYTYPE, CURLOT_STRING, 0},
- {"SSLKEY_BLOB", CURLOPT_SSLKEY_BLOB, CURLOT_BLOB, 0},
- {"SSLVERSION", CURLOPT_SSLVERSION, CURLOT_VALUES, 0},
- {"SSL_CIPHER_LIST", CURLOPT_SSL_CIPHER_LIST, CURLOT_STRING, 0},
- {"SSL_CTX_DATA", CURLOPT_SSL_CTX_DATA, CURLOT_CBPTR, 0},
- {"SSL_CTX_FUNCTION", CURLOPT_SSL_CTX_FUNCTION, CURLOT_FUNCTION, 0},
- {"SSL_EC_CURVES", CURLOPT_SSL_EC_CURVES, CURLOT_STRING, 0},
- {"SSL_ENABLE_ALPN", CURLOPT_SSL_ENABLE_ALPN, CURLOT_LONG, 0},
- {"SSL_ENABLE_NPN", CURLOPT_SSL_ENABLE_NPN, CURLOT_LONG, 0},
- {"SSL_FALSESTART", CURLOPT_SSL_FALSESTART, CURLOT_LONG, 0},
- {"SSL_OPTIONS", CURLOPT_SSL_OPTIONS, CURLOT_VALUES, 0},
- {"SSL_SESSIONID_CACHE", CURLOPT_SSL_SESSIONID_CACHE, CURLOT_LONG, 0},
- {"SSL_VERIFYHOST", CURLOPT_SSL_VERIFYHOST, CURLOT_LONG, 0},
- {"SSL_VERIFYPEER", CURLOPT_SSL_VERIFYPEER, CURLOT_LONG, 0},
- {"SSL_VERIFYSTATUS", CURLOPT_SSL_VERIFYSTATUS, CURLOT_LONG, 0},
- {"STDERR", CURLOPT_STDERR, CURLOT_OBJECT, 0},
- {"STREAM_DEPENDS", CURLOPT_STREAM_DEPENDS, CURLOT_OBJECT, 0},
- {"STREAM_DEPENDS_E", CURLOPT_STREAM_DEPENDS_E, CURLOT_OBJECT, 0},
- {"STREAM_WEIGHT", CURLOPT_STREAM_WEIGHT, CURLOT_LONG, 0},
- {"SUPPRESS_CONNECT_HEADERS", CURLOPT_SUPPRESS_CONNECT_HEADERS,
- CURLOT_LONG, 0},
- {"TCP_FASTOPEN", CURLOPT_TCP_FASTOPEN, CURLOT_LONG, 0},
- {"TCP_KEEPALIVE", CURLOPT_TCP_KEEPALIVE, CURLOT_LONG, 0},
- {"TCP_KEEPIDLE", CURLOPT_TCP_KEEPIDLE, CURLOT_LONG, 0},
- {"TCP_KEEPINTVL", CURLOPT_TCP_KEEPINTVL, CURLOT_LONG, 0},
- {"TCP_NODELAY", CURLOPT_TCP_NODELAY, CURLOT_LONG, 0},
- {"TELNETOPTIONS", CURLOPT_TELNETOPTIONS, CURLOT_SLIST, 0},
- {"TFTP_BLKSIZE", CURLOPT_TFTP_BLKSIZE, CURLOT_LONG, 0},
- {"TFTP_NO_OPTIONS", CURLOPT_TFTP_NO_OPTIONS, CURLOT_LONG, 0},
- {"TIMECONDITION", CURLOPT_TIMECONDITION, CURLOT_VALUES, 0},
- {"TIMEOUT", CURLOPT_TIMEOUT, CURLOT_LONG, 0},
- {"TIMEOUT_MS", CURLOPT_TIMEOUT_MS, CURLOT_LONG, 0},
- {"TIMEVALUE", CURLOPT_TIMEVALUE, CURLOT_LONG, 0},
- {"TIMEVALUE_LARGE", CURLOPT_TIMEVALUE_LARGE, CURLOT_OFF_T, 0},
- {"TLS13_CIPHERS", CURLOPT_TLS13_CIPHERS, CURLOT_STRING, 0},
- {"TLSAUTH_PASSWORD", CURLOPT_TLSAUTH_PASSWORD, CURLOT_STRING, 0},
- {"TLSAUTH_TYPE", CURLOPT_TLSAUTH_TYPE, CURLOT_STRING, 0},
- {"TLSAUTH_USERNAME", CURLOPT_TLSAUTH_USERNAME, CURLOT_STRING, 0},
- {"TRAILERDATA", CURLOPT_TRAILERDATA, CURLOT_CBPTR, 0},
- {"TRAILERFUNCTION", CURLOPT_TRAILERFUNCTION, CURLOT_FUNCTION, 0},
- {"TRANSFERTEXT", CURLOPT_TRANSFERTEXT, CURLOT_LONG, 0},
- {"TRANSFER_ENCODING", CURLOPT_TRANSFER_ENCODING, CURLOT_LONG, 0},
- {"UNIX_SOCKET_PATH", CURLOPT_UNIX_SOCKET_PATH, CURLOT_STRING, 0},
- {"UNRESTRICTED_AUTH", CURLOPT_UNRESTRICTED_AUTH, CURLOT_LONG, 0},
- {"UPKEEP_INTERVAL_MS", CURLOPT_UPKEEP_INTERVAL_MS, CURLOT_LONG, 0},
- {"UPLOAD", CURLOPT_UPLOAD, CURLOT_LONG, 0},
- {"UPLOAD_BUFFERSIZE", CURLOPT_UPLOAD_BUFFERSIZE, CURLOT_LONG, 0},
- {"URL", CURLOPT_URL, CURLOT_STRING, 0},
- {"USERAGENT", CURLOPT_USERAGENT, CURLOT_STRING, 0},
- {"USERNAME", CURLOPT_USERNAME, CURLOT_STRING, 0},
- {"USERPWD", CURLOPT_USERPWD, CURLOT_STRING, 0},
- {"USE_SSL", CURLOPT_USE_SSL, CURLOT_VALUES, 0},
- {"VERBOSE", CURLOPT_VERBOSE, CURLOT_LONG, 0},
- {"WILDCARDMATCH", CURLOPT_WILDCARDMATCH, CURLOT_LONG, 0},
- {"WRITEDATA", CURLOPT_WRITEDATA, CURLOT_CBPTR, 0},
- {"WRITEFUNCTION", CURLOPT_WRITEFUNCTION, CURLOT_FUNCTION, 0},
- {"WRITEHEADER", CURLOPT_HEADERDATA, CURLOT_CBPTR, CURLOT_FLAG_ALIAS},
- {"XFERINFODATA", CURLOPT_XFERINFODATA, CURLOT_CBPTR, 0},
- {"XFERINFOFUNCTION", CURLOPT_XFERINFOFUNCTION, CURLOT_FUNCTION, 0},
- {"XOAUTH2_BEARER", CURLOPT_XOAUTH2_BEARER, CURLOT_STRING, 0},
- {NULL, CURLOPT_LASTENTRY, 0, 0} /* end of table */
-};
-
-#ifdef DEBUGBUILD
-/*
- * Curl_easyopts_check() is a debug-only function that returns non-zero
- * if this source file is not in sync with the options listed in curl/curl.h
- */
-int Curl_easyopts_check(void)
-{
- return (CURLOPT_LASTENTRY != (304 + 1));
-}
-#endif
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ | |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * ___|___/|_| ______|
+ *
+ * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel.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
+ * are also available at https://curl.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+
+/* This source code is generated by optiontable.pl - DO NOT EDIT BY HAND */
+
+#include "curl_setup.h"
+#include "easyoptions.h"
+
+/* all easy setopt options listed in alphabetical order */
+struct curl_easyoption Curl_easyopts[] = {
+ {"ABSTRACT_UNIX_SOCKET", CURLOPT_ABSTRACT_UNIX_SOCKET, CURLOT_STRING, 0},
+ {"ACCEPTTIMEOUT_MS", CURLOPT_ACCEPTTIMEOUT_MS, CURLOT_LONG, 0},
+ {"ACCEPT_ENCODING", CURLOPT_ACCEPT_ENCODING, CURLOT_STRING, 0},
+ {"ADDRESS_SCOPE", CURLOPT_ADDRESS_SCOPE, CURLOT_LONG, 0},
+ {"ALTSVC", CURLOPT_ALTSVC, CURLOT_STRING, 0},
+ {"ALTSVC_CTRL", CURLOPT_ALTSVC_CTRL, CURLOT_LONG, 0},
+ {"APPEND", CURLOPT_APPEND, CURLOT_LONG, 0},
+ {"AUTOREFERER", CURLOPT_AUTOREFERER, CURLOT_LONG, 0},
+ {"BUFFERSIZE", CURLOPT_BUFFERSIZE, CURLOT_LONG, 0},
+ {"CAINFO", CURLOPT_CAINFO, CURLOT_STRING, 0},
+ {"CAPATH", CURLOPT_CAPATH, CURLOT_STRING, 0},
+ {"CERTINFO", CURLOPT_CERTINFO, CURLOT_LONG, 0},
+ {"CHUNK_BGN_FUNCTION", CURLOPT_CHUNK_BGN_FUNCTION, CURLOT_FUNCTION, 0},
+ {"CHUNK_DATA", CURLOPT_CHUNK_DATA, CURLOT_CBPTR, 0},
+ {"CHUNK_END_FUNCTION", CURLOPT_CHUNK_END_FUNCTION, CURLOT_FUNCTION, 0},
+ {"CLOSESOCKETDATA", CURLOPT_CLOSESOCKETDATA, CURLOT_CBPTR, 0},
+ {"CLOSESOCKETFUNCTION", CURLOPT_CLOSESOCKETFUNCTION, CURLOT_FUNCTION, 0},
+ {"CONNECTTIMEOUT", CURLOPT_CONNECTTIMEOUT, CURLOT_LONG, 0},
+ {"CONNECTTIMEOUT_MS", CURLOPT_CONNECTTIMEOUT_MS, CURLOT_LONG, 0},
+ {"CONNECT_ONLY", CURLOPT_CONNECT_ONLY, CURLOT_LONG, 0},
+ {"CONNECT_TO", CURLOPT_CONNECT_TO, CURLOT_SLIST, 0},
+ {"CONV_FROM_NETWORK_FUNCTION", CURLOPT_CONV_FROM_NETWORK_FUNCTION,
+ CURLOT_FUNCTION, 0},
+ {"CONV_FROM_UTF8_FUNCTION", CURLOPT_CONV_FROM_UTF8_FUNCTION,
+ CURLOT_FUNCTION, 0},
+ {"CONV_TO_NETWORK_FUNCTION", CURLOPT_CONV_TO_NETWORK_FUNCTION,
+ CURLOT_FUNCTION, 0},
+ {"COOKIE", CURLOPT_COOKIE, CURLOT_STRING, 0},
+ {"COOKIEFILE", CURLOPT_COOKIEFILE, CURLOT_STRING, 0},
+ {"COOKIEJAR", CURLOPT_COOKIEJAR, CURLOT_STRING, 0},
+ {"COOKIELIST", CURLOPT_COOKIELIST, CURLOT_STRING, 0},
+ {"COOKIESESSION", CURLOPT_COOKIESESSION, CURLOT_LONG, 0},
+ {"COPYPOSTFIELDS", CURLOPT_COPYPOSTFIELDS, CURLOT_OBJECT, 0},
+ {"CRLF", CURLOPT_CRLF, CURLOT_LONG, 0},
+ {"CRLFILE", CURLOPT_CRLFILE, CURLOT_STRING, 0},
+ {"CURLU", CURLOPT_CURLU, CURLOT_OBJECT, 0},
+ {"CUSTOMREQUEST", CURLOPT_CUSTOMREQUEST, CURLOT_STRING, 0},
+ {"DEBUGDATA", CURLOPT_DEBUGDATA, CURLOT_CBPTR, 0},
+ {"DEBUGFUNCTION", CURLOPT_DEBUGFUNCTION, CURLOT_FUNCTION, 0},
+ {"DEFAULT_PROTOCOL", CURLOPT_DEFAULT_PROTOCOL, CURLOT_STRING, 0},
+ {"DIRLISTONLY", CURLOPT_DIRLISTONLY, CURLOT_LONG, 0},
+ {"DISALLOW_USERNAME_IN_URL", CURLOPT_DISALLOW_USERNAME_IN_URL,
+ CURLOT_LONG, 0},
+ {"DNS_CACHE_TIMEOUT", CURLOPT_DNS_CACHE_TIMEOUT, CURLOT_LONG, 0},
+ {"DNS_INTERFACE", CURLOPT_DNS_INTERFACE, CURLOT_STRING, 0},
+ {"DNS_LOCAL_IP4", CURLOPT_DNS_LOCAL_IP4, CURLOT_STRING, 0},
+ {"DNS_LOCAL_IP6", CURLOPT_DNS_LOCAL_IP6, CURLOT_STRING, 0},
+ {"DNS_SERVERS", CURLOPT_DNS_SERVERS, CURLOT_STRING, 0},
+ {"DNS_SHUFFLE_ADDRESSES", CURLOPT_DNS_SHUFFLE_ADDRESSES, CURLOT_LONG, 0},
+ {"DNS_USE_GLOBAL_CACHE", CURLOPT_DNS_USE_GLOBAL_CACHE, CURLOT_LONG, 0},
+ {"DOH_URL", CURLOPT_DOH_URL, CURLOT_STRING, 0},
+ {"EGDSOCKET", CURLOPT_EGDSOCKET, CURLOT_STRING, 0},
+ {"ENCODING", CURLOPT_ACCEPT_ENCODING, CURLOT_STRING, CURLOT_FLAG_ALIAS},
+ {"ERRORBUFFER", CURLOPT_ERRORBUFFER, CURLOT_OBJECT, 0},
+ {"EXPECT_100_TIMEOUT_MS", CURLOPT_EXPECT_100_TIMEOUT_MS, CURLOT_LONG, 0},
+ {"FAILONERROR", CURLOPT_FAILONERROR, CURLOT_LONG, 0},
+ {"FILE", CURLOPT_WRITEDATA, CURLOT_CBPTR, CURLOT_FLAG_ALIAS},
+ {"FILETIME", CURLOPT_FILETIME, CURLOT_LONG, 0},
+ {"FNMATCH_DATA", CURLOPT_FNMATCH_DATA, CURLOT_CBPTR, 0},
+ {"FNMATCH_FUNCTION", CURLOPT_FNMATCH_FUNCTION, CURLOT_FUNCTION, 0},
+ {"FOLLOWLOCATION", CURLOPT_FOLLOWLOCATION, CURLOT_LONG, 0},
+ {"FORBID_REUSE", CURLOPT_FORBID_REUSE, CURLOT_LONG, 0},
+ {"FRESH_CONNECT", CURLOPT_FRESH_CONNECT, CURLOT_LONG, 0},
+ {"FTPAPPEND", CURLOPT_APPEND, CURLOT_LONG, CURLOT_FLAG_ALIAS},
+ {"FTPLISTONLY", CURLOPT_DIRLISTONLY, CURLOT_LONG, CURLOT_FLAG_ALIAS},
+ {"FTPPORT", CURLOPT_FTPPORT, CURLOT_STRING, 0},
+ {"FTPSSLAUTH", CURLOPT_FTPSSLAUTH, CURLOT_VALUES, 0},
+ {"FTP_ACCOUNT", CURLOPT_FTP_ACCOUNT, CURLOT_STRING, 0},
+ {"FTP_ALTERNATIVE_TO_USER", CURLOPT_FTP_ALTERNATIVE_TO_USER,
+ CURLOT_STRING, 0},
+ {"FTP_CREATE_MISSING_DIRS", CURLOPT_FTP_CREATE_MISSING_DIRS,
+ CURLOT_LONG, 0},
+ {"FTP_FILEMETHOD", CURLOPT_FTP_FILEMETHOD, CURLOT_VALUES, 0},
+ {"FTP_RESPONSE_TIMEOUT", CURLOPT_FTP_RESPONSE_TIMEOUT, CURLOT_LONG, 0},
+ {"FTP_SKIP_PASV_IP", CURLOPT_FTP_SKIP_PASV_IP, CURLOT_LONG, 0},
+ {"FTP_SSL", CURLOPT_USE_SSL, CURLOT_VALUES, CURLOT_FLAG_ALIAS},
+ {"FTP_SSL_CCC", CURLOPT_FTP_SSL_CCC, CURLOT_LONG, 0},
+ {"FTP_USE_EPRT", CURLOPT_FTP_USE_EPRT, CURLOT_LONG, 0},
+ {"FTP_USE_EPSV", CURLOPT_FTP_USE_EPSV, CURLOT_LONG, 0},
+ {"FTP_USE_PRET", CURLOPT_FTP_USE_PRET, CURLOT_LONG, 0},
+ {"GSSAPI_DELEGATION", CURLOPT_GSSAPI_DELEGATION, CURLOT_VALUES, 0},
+ {"HAPPY_EYEBALLS_TIMEOUT_MS", CURLOPT_HAPPY_EYEBALLS_TIMEOUT_MS,
+ CURLOT_LONG, 0},
+ {"HAPROXYPROTOCOL", CURLOPT_HAPROXYPROTOCOL, CURLOT_LONG, 0},
+ {"HEADER", CURLOPT_HEADER, CURLOT_LONG, 0},
+ {"HEADERDATA", CURLOPT_HEADERDATA, CURLOT_CBPTR, 0},
+ {"HEADERFUNCTION", CURLOPT_HEADERFUNCTION, CURLOT_FUNCTION, 0},
+ {"HEADEROPT", CURLOPT_HEADEROPT, CURLOT_VALUES, 0},
+ {"HSTS", CURLOPT_HSTS, CURLOT_STRING, 0},
+ {"HSTSREADDATA", CURLOPT_HSTSREADDATA, CURLOT_CBPTR, 0},
+ {"HSTSREADFUNCTION", CURLOPT_HSTSREADFUNCTION, CURLOT_FUNCTION, 0},
+ {"HSTSWRITEDATA", CURLOPT_HSTSWRITEDATA, CURLOT_CBPTR, 0},
+ {"HSTSWRITEFUNCTION", CURLOPT_HSTSWRITEFUNCTION, CURLOT_FUNCTION, 0},
+ {"HSTS_CTRL", CURLOPT_HSTS_CTRL, CURLOT_LONG, 0},
+ {"HTTP09_ALLOWED", CURLOPT_HTTP09_ALLOWED, CURLOT_LONG, 0},
+ {"HTTP200ALIASES", CURLOPT_HTTP200ALIASES, CURLOT_SLIST, 0},
+ {"HTTPAUTH", CURLOPT_HTTPAUTH, CURLOT_VALUES, 0},
+ {"HTTPGET", CURLOPT_HTTPGET, CURLOT_LONG, 0},
+ {"HTTPHEADER", CURLOPT_HTTPHEADER, CURLOT_SLIST, 0},
+ {"HTTPPOST", CURLOPT_HTTPPOST, CURLOT_OBJECT, 0},
+ {"HTTPPROXYTUNNEL", CURLOPT_HTTPPROXYTUNNEL, CURLOT_LONG, 0},
+ {"HTTP_CONTENT_DECODING", CURLOPT_HTTP_CONTENT_DECODING, CURLOT_LONG, 0},
+ {"HTTP_TRANSFER_DECODING", CURLOPT_HTTP_TRANSFER_DECODING, CURLOT_LONG, 0},
+ {"HTTP_VERSION", CURLOPT_HTTP_VERSION, CURLOT_VALUES, 0},
+ {"IGNORE_CONTENT_LENGTH", CURLOPT_IGNORE_CONTENT_LENGTH, CURLOT_LONG, 0},
+ {"INFILE", CURLOPT_READDATA, CURLOT_CBPTR, CURLOT_FLAG_ALIAS},
+ {"INFILESIZE", CURLOPT_INFILESIZE, CURLOT_LONG, 0},
+ {"INFILESIZE_LARGE", CURLOPT_INFILESIZE_LARGE, CURLOT_OFF_T, 0},
+ {"INTERFACE", CURLOPT_INTERFACE, CURLOT_STRING, 0},
+ {"INTERLEAVEDATA", CURLOPT_INTERLEAVEDATA, CURLOT_CBPTR, 0},
+ {"INTERLEAVEFUNCTION", CURLOPT_INTERLEAVEFUNCTION, CURLOT_FUNCTION, 0},
+ {"IOCTLDATA", CURLOPT_IOCTLDATA, CURLOT_CBPTR, 0},
+ {"IOCTLFUNCTION", CURLOPT_IOCTLFUNCTION, CURLOT_FUNCTION, 0},
+ {"IPRESOLVE", CURLOPT_IPRESOLVE, CURLOT_VALUES, 0},
+ {"ISSUERCERT", CURLOPT_ISSUERCERT, CURLOT_STRING, 0},
+ {"ISSUERCERT_BLOB", CURLOPT_ISSUERCERT_BLOB, CURLOT_BLOB, 0},
+ {"KEEP_SENDING_ON_ERROR", CURLOPT_KEEP_SENDING_ON_ERROR, CURLOT_LONG, 0},
+ {"KEYPASSWD", CURLOPT_KEYPASSWD, CURLOT_STRING, 0},
+ {"KRB4LEVEL", CURLOPT_KRBLEVEL, CURLOT_STRING, CURLOT_FLAG_ALIAS},
+ {"KRBLEVEL", CURLOPT_KRBLEVEL, CURLOT_STRING, 0},
+ {"LOCALPORT", CURLOPT_LOCALPORT, CURLOT_LONG, 0},
+ {"LOCALPORTRANGE", CURLOPT_LOCALPORTRANGE, CURLOT_LONG, 0},
+ {"LOGIN_OPTIONS", CURLOPT_LOGIN_OPTIONS, CURLOT_STRING, 0},
+ {"LOW_SPEED_LIMIT", CURLOPT_LOW_SPEED_LIMIT, CURLOT_LONG, 0},
+ {"LOW_SPEED_TIME", CURLOPT_LOW_SPEED_TIME, CURLOT_LONG, 0},
+ {"MAIL_AUTH", CURLOPT_MAIL_AUTH, CURLOT_STRING, 0},
+ {"MAIL_FROM", CURLOPT_MAIL_FROM, CURLOT_STRING, 0},
+ {"MAIL_RCPT", CURLOPT_MAIL_RCPT, CURLOT_SLIST, 0},
+ {"MAIL_RCPT_ALLLOWFAILS", CURLOPT_MAIL_RCPT_ALLLOWFAILS, CURLOT_LONG, 0},
+ {"MAXAGE_CONN", CURLOPT_MAXAGE_CONN, CURLOT_LONG, 0},
+ {"MAXCONNECTS", CURLOPT_MAXCONNECTS, CURLOT_LONG, 0},
+ {"MAXFILESIZE", CURLOPT_MAXFILESIZE, CURLOT_LONG, 0},
+ {"MAXFILESIZE_LARGE", CURLOPT_MAXFILESIZE_LARGE, CURLOT_OFF_T, 0},
+ {"MAXREDIRS", CURLOPT_MAXREDIRS, CURLOT_LONG, 0},
+ {"MAX_RECV_SPEED_LARGE", CURLOPT_MAX_RECV_SPEED_LARGE, CURLOT_OFF_T, 0},
+ {"MAX_SEND_SPEED_LARGE", CURLOPT_MAX_SEND_SPEED_LARGE, CURLOT_OFF_T, 0},
+ {"MIMEPOST", CURLOPT_MIMEPOST, CURLOT_OBJECT, 0},
+ {"NETRC", CURLOPT_NETRC, CURLOT_VALUES, 0},
+ {"NETRC_FILE", CURLOPT_NETRC_FILE, CURLOT_STRING, 0},
+ {"NEW_DIRECTORY_PERMS", CURLOPT_NEW_DIRECTORY_PERMS, CURLOT_LONG, 0},
+ {"NEW_FILE_PERMS", CURLOPT_NEW_FILE_PERMS, CURLOT_LONG, 0},
+ {"NOBODY", CURLOPT_NOBODY, CURLOT_LONG, 0},
+ {"NOPROGRESS", CURLOPT_NOPROGRESS, CURLOT_LONG, 0},
+ {"NOPROXY", CURLOPT_NOPROXY, CURLOT_STRING, 0},
+ {"NOSIGNAL", CURLOPT_NOSIGNAL, CURLOT_LONG, 0},
+ {"OPENSOCKETDATA", CURLOPT_OPENSOCKETDATA, CURLOT_CBPTR, 0},
+ {"OPENSOCKETFUNCTION", CURLOPT_OPENSOCKETFUNCTION, CURLOT_FUNCTION, 0},
+ {"PASSWORD", CURLOPT_PASSWORD, CURLOT_STRING, 0},
+ {"PATH_AS_IS", CURLOPT_PATH_AS_IS, CURLOT_LONG, 0},
+ {"PINNEDPUBLICKEY", CURLOPT_PINNEDPUBLICKEY, CURLOT_STRING, 0},
+ {"PIPEWAIT", CURLOPT_PIPEWAIT, CURLOT_LONG, 0},
+ {"PORT", CURLOPT_PORT, CURLOT_LONG, 0},
+ {"POST", CURLOPT_POST, CURLOT_LONG, 0},
+ {"POST301", CURLOPT_POSTREDIR, CURLOT_VALUES, CURLOT_FLAG_ALIAS},
+ {"POSTFIELDS", CURLOPT_POSTFIELDS, CURLOT_OBJECT, 0},
+ {"POSTFIELDSIZE", CURLOPT_POSTFIELDSIZE, CURLOT_LONG, 0},
+ {"POSTFIELDSIZE_LARGE", CURLOPT_POSTFIELDSIZE_LARGE, CURLOT_OFF_T, 0},
+ {"POSTQUOTE", CURLOPT_POSTQUOTE, CURLOT_SLIST, 0},
+ {"POSTREDIR", CURLOPT_POSTREDIR, CURLOT_VALUES, 0},
+ {"PREQUOTE", CURLOPT_PREQUOTE, CURLOT_SLIST, 0},
+ {"PRE_PROXY", CURLOPT_PRE_PROXY, CURLOT_STRING, 0},
+ {"PRIVATE", CURLOPT_PRIVATE, CURLOT_OBJECT, 0},
+ {"PROGRESSDATA", CURLOPT_XFERINFODATA, CURLOT_CBPTR, CURLOT_FLAG_ALIAS},
+ {"PROGRESSFUNCTION", CURLOPT_PROGRESSFUNCTION, CURLOT_FUNCTION, 0},
+ {"PROTOCOLS", CURLOPT_PROTOCOLS, CURLOT_LONG, 0},
+ {"PROXY", CURLOPT_PROXY, CURLOT_STRING, 0},
+ {"PROXYAUTH", CURLOPT_PROXYAUTH, CURLOT_VALUES, 0},
+ {"PROXYHEADER", CURLOPT_PROXYHEADER, CURLOT_SLIST, 0},
+ {"PROXYPASSWORD", CURLOPT_PROXYPASSWORD, CURLOT_STRING, 0},
+ {"PROXYPORT", CURLOPT_PROXYPORT, CURLOT_LONG, 0},
+ {"PROXYTYPE", CURLOPT_PROXYTYPE, CURLOT_VALUES, 0},
+ {"PROXYUSERNAME", CURLOPT_PROXYUSERNAME, CURLOT_STRING, 0},
+ {"PROXYUSERPWD", CURLOPT_PROXYUSERPWD, CURLOT_STRING, 0},
+ {"PROXY_CAINFO", CURLOPT_PROXY_CAINFO, CURLOT_STRING, 0},
+ {"PROXY_CAPATH", CURLOPT_PROXY_CAPATH, CURLOT_STRING, 0},
+ {"PROXY_CRLFILE", CURLOPT_PROXY_CRLFILE, CURLOT_STRING, 0},
+ {"PROXY_ISSUERCERT", CURLOPT_PROXY_ISSUERCERT, CURLOT_STRING, 0},
+ {"PROXY_ISSUERCERT_BLOB", CURLOPT_PROXY_ISSUERCERT_BLOB, CURLOT_BLOB, 0},
+ {"PROXY_KEYPASSWD", CURLOPT_PROXY_KEYPASSWD, CURLOT_STRING, 0},
+ {"PROXY_PINNEDPUBLICKEY", CURLOPT_PROXY_PINNEDPUBLICKEY, CURLOT_STRING, 0},
+ {"PROXY_SERVICE_NAME", CURLOPT_PROXY_SERVICE_NAME, CURLOT_STRING, 0},
+ {"PROXY_SSLCERT", CURLOPT_PROXY_SSLCERT, CURLOT_STRING, 0},
+ {"PROXY_SSLCERTTYPE", CURLOPT_PROXY_SSLCERTTYPE, CURLOT_STRING, 0},
+ {"PROXY_SSLCERT_BLOB", CURLOPT_PROXY_SSLCERT_BLOB, CURLOT_BLOB, 0},
+ {"PROXY_SSLKEY", CURLOPT_PROXY_SSLKEY, CURLOT_STRING, 0},
+ {"PROXY_SSLKEYTYPE", CURLOPT_PROXY_SSLKEYTYPE, CURLOT_STRING, 0},
+ {"PROXY_SSLKEY_BLOB", CURLOPT_PROXY_SSLKEY_BLOB, CURLOT_BLOB, 0},
+ {"PROXY_SSLVERSION", CURLOPT_PROXY_SSLVERSION, CURLOT_VALUES, 0},
+ {"PROXY_SSL_CIPHER_LIST", CURLOPT_PROXY_SSL_CIPHER_LIST, CURLOT_STRING, 0},
+ {"PROXY_SSL_OPTIONS", CURLOPT_PROXY_SSL_OPTIONS, CURLOT_LONG, 0},
+ {"PROXY_SSL_VERIFYHOST", CURLOPT_PROXY_SSL_VERIFYHOST, CURLOT_LONG, 0},
+ {"PROXY_SSL_VERIFYPEER", CURLOPT_PROXY_SSL_VERIFYPEER, CURLOT_LONG, 0},
+ {"PROXY_TLS13_CIPHERS", CURLOPT_PROXY_TLS13_CIPHERS, CURLOT_STRING, 0},
+ {"PROXY_TLSAUTH_PASSWORD", CURLOPT_PROXY_TLSAUTH_PASSWORD,
+ CURLOT_STRING, 0},
+ {"PROXY_TLSAUTH_TYPE", CURLOPT_PROXY_TLSAUTH_TYPE, CURLOT_STRING, 0},
+ {"PROXY_TLSAUTH_USERNAME", CURLOPT_PROXY_TLSAUTH_USERNAME,
+ CURLOT_STRING, 0},
+ {"PROXY_TRANSFER_MODE", CURLOPT_PROXY_TRANSFER_MODE, CURLOT_LONG, 0},
+ {"PUT", CURLOPT_PUT, CURLOT_LONG, 0},
+ {"QUOTE", CURLOPT_QUOTE, CURLOT_SLIST, 0},
+ {"RANDOM_FILE", CURLOPT_RANDOM_FILE, CURLOT_STRING, 0},
+ {"RANGE", CURLOPT_RANGE, CURLOT_STRING, 0},
+ {"READDATA", CURLOPT_READDATA, CURLOT_CBPTR, 0},
+ {"READFUNCTION", CURLOPT_READFUNCTION, CURLOT_FUNCTION, 0},
+ {"REDIR_PROTOCOLS", CURLOPT_REDIR_PROTOCOLS, CURLOT_LONG, 0},
+ {"REFERER", CURLOPT_REFERER, CURLOT_STRING, 0},
+ {"REQUEST_TARGET", CURLOPT_REQUEST_TARGET, CURLOT_STRING, 0},
+ {"RESOLVE", CURLOPT_RESOLVE, CURLOT_SLIST, 0},
+ {"RESOLVER_START_DATA", CURLOPT_RESOLVER_START_DATA, CURLOT_CBPTR, 0},
+ {"RESOLVER_START_FUNCTION", CURLOPT_RESOLVER_START_FUNCTION,
+ CURLOT_FUNCTION, 0},
+ {"RESUME_FROM", CURLOPT_RESUME_FROM, CURLOT_LONG, 0},
+ {"RESUME_FROM_LARGE", CURLOPT_RESUME_FROM_LARGE, CURLOT_OFF_T, 0},
+ {"RTSPHEADER", CURLOPT_HTTPHEADER, CURLOT_SLIST, CURLOT_FLAG_ALIAS},
+ {"RTSP_CLIENT_CSEQ", CURLOPT_RTSP_CLIENT_CSEQ, CURLOT_LONG, 0},
+ {"RTSP_REQUEST", CURLOPT_RTSP_REQUEST, CURLOT_VALUES, 0},
+ {"RTSP_SERVER_CSEQ", CURLOPT_RTSP_SERVER_CSEQ, CURLOT_LONG, 0},
+ {"RTSP_SESSION_ID", CURLOPT_RTSP_SESSION_ID, CURLOT_STRING, 0},
+ {"RTSP_STREAM_URI", CURLOPT_RTSP_STREAM_URI, CURLOT_STRING, 0},
+ {"RTSP_TRANSPORT", CURLOPT_RTSP_TRANSPORT, CURLOT_STRING, 0},
+ {"SASL_AUTHZID", CURLOPT_SASL_AUTHZID, CURLOT_STRING, 0},
+ {"SASL_IR", CURLOPT_SASL_IR, CURLOT_LONG, 0},
+ {"SEEKDATA", CURLOPT_SEEKDATA, CURLOT_CBPTR, 0},
+ {"SEEKFUNCTION", CURLOPT_SEEKFUNCTION, CURLOT_FUNCTION, 0},
+ {"SERVER_RESPONSE_TIMEOUT", CURLOPT_FTP_RESPONSE_TIMEOUT,
+ CURLOT_LONG, CURLOT_FLAG_ALIAS},
+ {"SERVICE_NAME", CURLOPT_SERVICE_NAME, CURLOT_STRING, 0},
+ {"SHARE", CURLOPT_SHARE, CURLOT_OBJECT, 0},
+ {"SOCKOPTDATA", CURLOPT_SOCKOPTDATA, CURLOT_CBPTR, 0},
+ {"SOCKOPTFUNCTION", CURLOPT_SOCKOPTFUNCTION, CURLOT_FUNCTION, 0},
+ {"SOCKS5_AUTH", CURLOPT_SOCKS5_AUTH, CURLOT_LONG, 0},
+ {"SOCKS5_GSSAPI_NEC", CURLOPT_SOCKS5_GSSAPI_NEC, CURLOT_LONG, 0},
+ {"SOCKS5_GSSAPI_SERVICE", CURLOPT_SOCKS5_GSSAPI_SERVICE, CURLOT_STRING, 0},
+ {"SSH_AUTH_TYPES", CURLOPT_SSH_AUTH_TYPES, CURLOT_VALUES, 0},
+ {"SSH_COMPRESSION", CURLOPT_SSH_COMPRESSION, CURLOT_LONG, 0},
+ {"SSH_HOST_PUBLIC_KEY_MD5", CURLOPT_SSH_HOST_PUBLIC_KEY_MD5,
+ CURLOT_STRING, 0},
+ {"SSH_KEYDATA", CURLOPT_SSH_KEYDATA, CURLOT_CBPTR, 0},
+ {"SSH_KEYFUNCTION", CURLOPT_SSH_KEYFUNCTION, CURLOT_FUNCTION, 0},
+ {"SSH_KNOWNHOSTS", CURLOPT_SSH_KNOWNHOSTS, CURLOT_STRING, 0},
+ {"SSH_PRIVATE_KEYFILE", CURLOPT_SSH_PRIVATE_KEYFILE, CURLOT_STRING, 0},
+ {"SSH_PUBLIC_KEYFILE", CURLOPT_SSH_PUBLIC_KEYFILE, CURLOT_STRING, 0},
+ {"SSLCERT", CURLOPT_SSLCERT, CURLOT_STRING, 0},
+ {"SSLCERTPASSWD", CURLOPT_KEYPASSWD, CURLOT_STRING, CURLOT_FLAG_ALIAS},
+ {"SSLCERTTYPE", CURLOPT_SSLCERTTYPE, CURLOT_STRING, 0},
+ {"SSLCERT_BLOB", CURLOPT_SSLCERT_BLOB, CURLOT_BLOB, 0},
+ {"SSLENGINE", CURLOPT_SSLENGINE, CURLOT_STRING, 0},
+ {"SSLENGINE_DEFAULT", CURLOPT_SSLENGINE_DEFAULT, CURLOT_LONG, 0},
+ {"SSLKEY", CURLOPT_SSLKEY, CURLOT_STRING, 0},
+ {"SSLKEYPASSWD", CURLOPT_KEYPASSWD, CURLOT_STRING, CURLOT_FLAG_ALIAS},
+ {"SSLKEYTYPE", CURLOPT_SSLKEYTYPE, CURLOT_STRING, 0},
+ {"SSLKEY_BLOB", CURLOPT_SSLKEY_BLOB, CURLOT_BLOB, 0},
+ {"SSLVERSION", CURLOPT_SSLVERSION, CURLOT_VALUES, 0},
+ {"SSL_CIPHER_LIST", CURLOPT_SSL_CIPHER_LIST, CURLOT_STRING, 0},
+ {"SSL_CTX_DATA", CURLOPT_SSL_CTX_DATA, CURLOT_CBPTR, 0},
+ {"SSL_CTX_FUNCTION", CURLOPT_SSL_CTX_FUNCTION, CURLOT_FUNCTION, 0},
+ {"SSL_EC_CURVES", CURLOPT_SSL_EC_CURVES, CURLOT_STRING, 0},
+ {"SSL_ENABLE_ALPN", CURLOPT_SSL_ENABLE_ALPN, CURLOT_LONG, 0},
+ {"SSL_ENABLE_NPN", CURLOPT_SSL_ENABLE_NPN, CURLOT_LONG, 0},
+ {"SSL_FALSESTART", CURLOPT_SSL_FALSESTART, CURLOT_LONG, 0},
+ {"SSL_OPTIONS", CURLOPT_SSL_OPTIONS, CURLOT_VALUES, 0},
+ {"SSL_SESSIONID_CACHE", CURLOPT_SSL_SESSIONID_CACHE, CURLOT_LONG, 0},
+ {"SSL_VERIFYHOST", CURLOPT_SSL_VERIFYHOST, CURLOT_LONG, 0},
+ {"SSL_VERIFYPEER", CURLOPT_SSL_VERIFYPEER, CURLOT_LONG, 0},
+ {"SSL_VERIFYSTATUS", CURLOPT_SSL_VERIFYSTATUS, CURLOT_LONG, 0},
+ {"STDERR", CURLOPT_STDERR, CURLOT_OBJECT, 0},
+ {"STREAM_DEPENDS", CURLOPT_STREAM_DEPENDS, CURLOT_OBJECT, 0},
+ {"STREAM_DEPENDS_E", CURLOPT_STREAM_DEPENDS_E, CURLOT_OBJECT, 0},
+ {"STREAM_WEIGHT", CURLOPT_STREAM_WEIGHT, CURLOT_LONG, 0},
+ {"SUPPRESS_CONNECT_HEADERS", CURLOPT_SUPPRESS_CONNECT_HEADERS,
+ CURLOT_LONG, 0},
+ {"TCP_FASTOPEN", CURLOPT_TCP_FASTOPEN, CURLOT_LONG, 0},
+ {"TCP_KEEPALIVE", CURLOPT_TCP_KEEPALIVE, CURLOT_LONG, 0},
+ {"TCP_KEEPIDLE", CURLOPT_TCP_KEEPIDLE, CURLOT_LONG, 0},
+ {"TCP_KEEPINTVL", CURLOPT_TCP_KEEPINTVL, CURLOT_LONG, 0},
+ {"TCP_NODELAY", CURLOPT_TCP_NODELAY, CURLOT_LONG, 0},
+ {"TELNETOPTIONS", CURLOPT_TELNETOPTIONS, CURLOT_SLIST, 0},
+ {"TFTP_BLKSIZE", CURLOPT_TFTP_BLKSIZE, CURLOT_LONG, 0},
+ {"TFTP_NO_OPTIONS", CURLOPT_TFTP_NO_OPTIONS, CURLOT_LONG, 0},
+ {"TIMECONDITION", CURLOPT_TIMECONDITION, CURLOT_VALUES, 0},
+ {"TIMEOUT", CURLOPT_TIMEOUT, CURLOT_LONG, 0},
+ {"TIMEOUT_MS", CURLOPT_TIMEOUT_MS, CURLOT_LONG, 0},
+ {"TIMEVALUE", CURLOPT_TIMEVALUE, CURLOT_LONG, 0},
+ {"TIMEVALUE_LARGE", CURLOPT_TIMEVALUE_LARGE, CURLOT_OFF_T, 0},
+ {"TLS13_CIPHERS", CURLOPT_TLS13_CIPHERS, CURLOT_STRING, 0},
+ {"TLSAUTH_PASSWORD", CURLOPT_TLSAUTH_PASSWORD, CURLOT_STRING, 0},
+ {"TLSAUTH_TYPE", CURLOPT_TLSAUTH_TYPE, CURLOT_STRING, 0},
+ {"TLSAUTH_USERNAME", CURLOPT_TLSAUTH_USERNAME, CURLOT_STRING, 0},
+ {"TRAILERDATA", CURLOPT_TRAILERDATA, CURLOT_CBPTR, 0},
+ {"TRAILERFUNCTION", CURLOPT_TRAILERFUNCTION, CURLOT_FUNCTION, 0},
+ {"TRANSFERTEXT", CURLOPT_TRANSFERTEXT, CURLOT_LONG, 0},
+ {"TRANSFER_ENCODING", CURLOPT_TRANSFER_ENCODING, CURLOT_LONG, 0},
+ {"UNIX_SOCKET_PATH", CURLOPT_UNIX_SOCKET_PATH, CURLOT_STRING, 0},
+ {"UNRESTRICTED_AUTH", CURLOPT_UNRESTRICTED_AUTH, CURLOT_LONG, 0},
+ {"UPKEEP_INTERVAL_MS", CURLOPT_UPKEEP_INTERVAL_MS, CURLOT_LONG, 0},
+ {"UPLOAD", CURLOPT_UPLOAD, CURLOT_LONG, 0},
+ {"UPLOAD_BUFFERSIZE", CURLOPT_UPLOAD_BUFFERSIZE, CURLOT_LONG, 0},
+ {"URL", CURLOPT_URL, CURLOT_STRING, 0},
+ {"USERAGENT", CURLOPT_USERAGENT, CURLOT_STRING, 0},
+ {"USERNAME", CURLOPT_USERNAME, CURLOT_STRING, 0},
+ {"USERPWD", CURLOPT_USERPWD, CURLOT_STRING, 0},
+ {"USE_SSL", CURLOPT_USE_SSL, CURLOT_VALUES, 0},
+ {"VERBOSE", CURLOPT_VERBOSE, CURLOT_LONG, 0},
+ {"WILDCARDMATCH", CURLOPT_WILDCARDMATCH, CURLOT_LONG, 0},
+ {"WRITEDATA", CURLOPT_WRITEDATA, CURLOT_CBPTR, 0},
+ {"WRITEFUNCTION", CURLOPT_WRITEFUNCTION, CURLOT_FUNCTION, 0},
+ {"WRITEHEADER", CURLOPT_HEADERDATA, CURLOT_CBPTR, CURLOT_FLAG_ALIAS},
+ {"XFERINFODATA", CURLOPT_XFERINFODATA, CURLOT_CBPTR, 0},
+ {"XFERINFOFUNCTION", CURLOPT_XFERINFOFUNCTION, CURLOT_FUNCTION, 0},
+ {"XOAUTH2_BEARER", CURLOPT_XOAUTH2_BEARER, CURLOT_STRING, 0},
+ {NULL, CURLOPT_LASTENTRY, 0, 0} /* end of table */
+};
+
+#ifdef DEBUGBUILD
+/*
+ * Curl_easyopts_check() is a debug-only function that returns non-zero
+ * if this source file is not in sync with the options listed in curl/curl.h
+ */
+int Curl_easyopts_check(void)
+{
+ return (CURLOPT_LASTENTRY != (304 + 1));
+}
+#endif
diff --git a/contrib/libs/curl/lib/easyoptions.h b/contrib/libs/curl/lib/easyoptions.h
index a67bb0b310..91e11908bd 100644
--- a/contrib/libs/curl/lib/easyoptions.h
+++ b/contrib/libs/curl/lib/easyoptions.h
@@ -1,35 +1,35 @@
-#ifndef HEADER_CURL_EASYOPTIONS_H
-#define HEADER_CURL_EASYOPTIONS_H
-/***************************************************************************
- * _ _ ____ _
- * Project ___| | | | _ \| |
- * / __| | | | |_) | |
- * | (__| |_| | _ <| |___
- * \___|\___/|_| \_\_____|
- *
- * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
- *
- * You may opt to use, copy, modify, merge, publish, distribute and/or sell
- * copies of the Software, and permit persons to whom the Software is
- * furnished to do so, under the terms of the COPYING file.
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- ***************************************************************************/
-
-/* should probably go into the public header */
-
-#include <curl/curl.h>
-
-/* generated table with all easy options */
-extern struct curl_easyoption Curl_easyopts[];
-
-#ifdef DEBUGBUILD
-int Curl_easyopts_check(void);
-#endif
-#endif
+#ifndef HEADER_CURL_EASYOPTIONS_H
+#define HEADER_CURL_EASYOPTIONS_H
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 1998 - 2020, 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
+ * are also available at https://curl.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+
+/* should probably go into the public header */
+
+#include <curl/curl.h>
+
+/* generated table with all easy options */
+extern struct curl_easyoption Curl_easyopts[];
+
+#ifdef DEBUGBUILD
+int Curl_easyopts_check(void);
+#endif
+#endif
diff --git a/contrib/libs/curl/lib/escape.c b/contrib/libs/curl/lib/escape.c
index d9cf778dd1..683b6fc4a6 100644
--- a/contrib/libs/curl/lib/escape.c
+++ b/contrib/libs/curl/lib/escape.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -81,43 +81,43 @@ char *curl_easy_escape(struct Curl_easy *data, const char *string,
{
size_t length;
CURLcode result;
- struct dynbuf d;
+ struct dynbuf d;
if(inlength < 0)
return NULL;
- Curl_dyn_init(&d, CURL_MAX_INPUT_LENGTH * 3);
+ Curl_dyn_init(&d, CURL_MAX_INPUT_LENGTH * 3);
- length = (inlength?(size_t)inlength:strlen(string));
- if(!length)
- return strdup("");
+ length = (inlength?(size_t)inlength:strlen(string));
+ if(!length)
+ return strdup("");
while(length--) {
unsigned char in = *string; /* we need to treat the characters unsigned */
- if(Curl_isunreserved(in)) {
- /* append this */
- if(Curl_dyn_addn(&d, &in, 1))
- return NULL;
- }
+ if(Curl_isunreserved(in)) {
+ /* append this */
+ if(Curl_dyn_addn(&d, &in, 1))
+ return NULL;
+ }
else {
/* encode it */
- char encoded[4];
+ char encoded[4];
result = Curl_convert_to_network(data, (char *)&in, 1);
if(result) {
/* Curl_convert_to_network calls failf if unsuccessful */
- Curl_dyn_free(&d);
+ Curl_dyn_free(&d);
return NULL;
}
- msnprintf(encoded, sizeof(encoded), "%%%02X", in);
- if(Curl_dyn_add(&d, encoded))
- return NULL;
+ msnprintf(encoded, sizeof(encoded), "%%%02X", in);
+ if(Curl_dyn_add(&d, encoded))
+ return NULL;
}
string++;
}
-
- return Curl_dyn_ptr(&d);
+
+ return Curl_dyn_ptr(&d);
}
/*
@@ -128,34 +128,34 @@ char *curl_easy_escape(struct Curl_easy *data, const char *string,
*
* 'data' can be set to NULL but then this function can't convert network
* data to host for non-ascii.
- *
- * ctrl options:
- * - REJECT_NADA: accept everything
- * - REJECT_CTRL: rejects control characters (byte codes lower than 32) in
- * the data
- * - REJECT_ZERO: rejects decoded zero bytes
- *
- * The values for the enum starts at 2, to make the assert detect legacy
- * invokes that used TRUE/FALSE (0 and 1).
+ *
+ * ctrl options:
+ * - REJECT_NADA: accept everything
+ * - REJECT_CTRL: rejects control characters (byte codes lower than 32) in
+ * the data
+ * - REJECT_ZERO: rejects decoded zero bytes
+ *
+ * The values for the enum starts at 2, to make the assert detect legacy
+ * invokes that used TRUE/FALSE (0 and 1).
*/
-
+
CURLcode Curl_urldecode(struct Curl_easy *data,
const char *string, size_t length,
char **ostring, size_t *olen,
- enum urlreject ctrl)
+ enum urlreject ctrl)
{
- size_t alloc;
- char *ns;
+ size_t alloc;
+ char *ns;
size_t strindex = 0;
unsigned long hex;
CURLcode result = CURLE_OK;
- DEBUGASSERT(string);
- DEBUGASSERT(ctrl >= REJECT_NADA); /* crash on TRUE/FALSE */
-
- alloc = (length?length:strlen(string)) + 1;
- ns = malloc(alloc);
-
+ DEBUGASSERT(string);
+ DEBUGASSERT(ctrl >= REJECT_NADA); /* crash on TRUE/FALSE */
+
+ alloc = (length?length:strlen(string)) + 1;
+ ns = malloc(alloc);
+
if(!ns)
return CURLE_OUT_OF_MEMORY;
@@ -187,8 +187,8 @@ CURLcode Curl_urldecode(struct Curl_easy *data,
alloc -= 2;
}
- if(((ctrl == REJECT_CTRL) && (in < 0x20)) ||
- ((ctrl == REJECT_ZERO) && (in == 0))) {
+ if(((ctrl == REJECT_CTRL) && (in < 0x20)) ||
+ ((ctrl == REJECT_ZERO) && (in == 0))) {
free(ns);
return CURLE_URL_MALFORMAT;
}
@@ -222,7 +222,7 @@ char *curl_easy_unescape(struct Curl_easy *data, const char *string,
size_t inputlen = length;
size_t outputlen;
CURLcode res = Curl_urldecode(data, string, inputlen, &str, &outputlen,
- REJECT_NADA);
+ REJECT_NADA);
if(res)
return NULL;
diff --git a/contrib/libs/curl/lib/escape.h b/contrib/libs/curl/lib/escape.h
index 94f33ce814..46cb59039a 100644
--- a/contrib/libs/curl/lib/escape.h
+++ b/contrib/libs/curl/lib/escape.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -25,16 +25,16 @@
* allocated string or NULL if an error occurred. */
bool Curl_isunreserved(unsigned char in);
-
-enum urlreject {
- REJECT_NADA = 2,
- REJECT_CTRL,
- REJECT_ZERO
-};
-
+
+enum urlreject {
+ REJECT_NADA = 2,
+ REJECT_CTRL,
+ REJECT_ZERO
+};
+
CURLcode Curl_urldecode(struct Curl_easy *data,
const char *string, size_t length,
char **ostring, size_t *olen,
- enum urlreject ctrl);
+ enum urlreject ctrl);
#endif /* HEADER_CURL_ESCAPE_H */
diff --git a/contrib/libs/curl/lib/file.c b/contrib/libs/curl/lib/file.c
index 2ed0cc0fc8..a65eb7798d 100644
--- a/contrib/libs/curl/lib/file.c
+++ b/contrib/libs/curl/lib/file.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -67,7 +67,7 @@
#include "curl_memory.h"
#include "memdebug.h"
-#if defined(WIN32) || defined(MSDOS) || defined(__EMX__)
+#if defined(WIN32) || defined(MSDOS) || defined(__EMX__)
#define DOS_FILESYSTEM 1
#endif
@@ -111,7 +111,7 @@ const struct Curl_handler Curl_handler_file = {
ZERO_NULL, /* connection_check */
0, /* defport */
CURLPROTO_FILE, /* protocol */
- CURLPROTO_FILE, /* family */
+ CURLPROTO_FILE, /* family */
PROTOPT_NONETWORK | PROTOPT_NOURLQUERY /* flags */
};
@@ -119,8 +119,8 @@ const struct Curl_handler Curl_handler_file = {
static CURLcode file_setup_connection(struct connectdata *conn)
{
/* allocate the FILE specific struct */
- conn->data->req.p.file = calloc(1, sizeof(struct FILEPROTO));
- if(!conn->data->req.p.file)
+ conn->data->req.p.file = calloc(1, sizeof(struct FILEPROTO));
+ if(!conn->data->req.p.file)
return CURLE_OUT_OF_MEMORY;
return CURLE_OK;
@@ -135,7 +135,7 @@ static CURLcode file_connect(struct connectdata *conn, bool *done)
{
struct Curl_easy *data = conn->data;
char *real_path;
- struct FILEPROTO *file = data->req.p.file;
+ struct FILEPROTO *file = data->req.p.file;
int fd;
#ifdef DOS_FILESYSTEM
size_t i;
@@ -144,7 +144,7 @@ static CURLcode file_connect(struct connectdata *conn, bool *done)
size_t real_path_len;
CURLcode result = Curl_urldecode(data, data->state.up.path, 0, &real_path,
- &real_path_len, REJECT_ZERO);
+ &real_path_len, REJECT_ZERO);
if(result)
return result;
@@ -209,7 +209,7 @@ static CURLcode file_connect(struct connectdata *conn, bool *done)
static CURLcode file_done(struct connectdata *conn,
CURLcode status, bool premature)
{
- struct FILEPROTO *file = conn->data->req.p.file;
+ struct FILEPROTO *file = conn->data->req.p.file;
(void)status; /* not used */
(void)premature; /* not used */
@@ -228,7 +228,7 @@ static CURLcode file_disconnect(struct connectdata *conn,
bool dead_connection)
{
(void)dead_connection; /* not used */
- return file_done(conn, 0, 0);
+ return file_done(conn, 0, 0);
}
#ifdef DOS_FILESYSTEM
@@ -239,7 +239,7 @@ static CURLcode file_disconnect(struct connectdata *conn,
static CURLcode file_upload(struct connectdata *conn)
{
- struct FILEPROTO *file = conn->data->req.p.file;
+ struct FILEPROTO *file = conn->data->req.p.file;
const char *dir = strchr(file->path, DIRSEP);
int fd;
int mode;
@@ -381,7 +381,7 @@ static CURLcode file_do(struct connectdata *conn, bool *done)
if(data->set.upload)
return file_upload(conn);
- file = conn->data->req.p.file;
+ file = conn->data->req.p.file;
/* get the fd from the connection phase */
fd = file->fd;
diff --git a/contrib/libs/curl/lib/file.h b/contrib/libs/curl/lib/file.h
index 41a72d9502..338f92e46a 100644
--- a/contrib/libs/curl/lib/file.h
+++ b/contrib/libs/curl/lib/file.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/fileinfo.c b/contrib/libs/curl/lib/fileinfo.c
index 8ed11ade5b..b7e9f0f5e8 100644
--- a/contrib/libs/curl/lib/fileinfo.c
+++ b/contrib/libs/curl/lib/fileinfo.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 2010 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2010 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/fileinfo.h b/contrib/libs/curl/lib/fileinfo.h
index d79a691ffe..5ae23ad4a3 100644
--- a/contrib/libs/curl/lib/fileinfo.h
+++ b/contrib/libs/curl/lib/fileinfo.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 2010 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2010 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -27,7 +27,7 @@
struct fileinfo {
struct curl_fileinfo info;
- struct Curl_llist_element list;
+ struct Curl_llist_element list;
};
struct fileinfo *Curl_fileinfo_alloc(void);
diff --git a/contrib/libs/curl/lib/formdata.c b/contrib/libs/curl/lib/formdata.c
index 05f4b5c443..769f06a705 100644
--- a/contrib/libs/curl/lib/formdata.c
+++ b/contrib/libs/curl/lib/formdata.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -123,11 +123,11 @@ AddHttpPost(char *name, size_t namelength,
* parent_form_info is NULL.
*
***************************************************************************/
-static struct FormInfo *AddFormInfo(char *value,
- char *contenttype,
- struct FormInfo *parent_form_info)
+static struct FormInfo *AddFormInfo(char *value,
+ char *contenttype,
+ struct FormInfo *parent_form_info)
{
- struct FormInfo *form_info;
+ struct FormInfo *form_info;
form_info = calloc(1, sizeof(struct FormInfo));
if(form_info) {
if(value)
@@ -204,7 +204,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
struct curl_httppost **last_post,
va_list params)
{
- struct FormInfo *first_form, *current_form, *form = NULL;
+ struct FormInfo *first_form, *current_form, *form = NULL;
CURLFORMcode return_value = CURL_FORMADD_OK;
const char *prevtype = NULL;
struct curl_httppost *post = NULL;
@@ -521,7 +521,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
if(CURL_FORMADD_OK != return_value) {
/* On error, free allocated fields for all nodes of the FormInfo linked
list without deallocating nodes. List nodes are deallocated later on */
- struct FormInfo *ptr;
+ struct FormInfo *ptr;
for(ptr = first_form; ptr != NULL; ptr = ptr->more) {
if(ptr->name_alloc) {
Curl_safefree(ptr->name);
@@ -602,7 +602,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
/* Note that there's small risk that form->name is NULL here if the
app passed in a bad combo, so we better check for that first. */
if(form->name) {
- /* copy name (without strdup; possibly not null-terminated) */
+ /* copy name (without strdup; possibly not null-terminated) */
form->name = Curl_memdup(form->name, form->namelength?
form->namelength:
strlen(form->name) + 1);
@@ -650,7 +650,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
/* On error, free allocated fields for nodes of the FormInfo linked
list which are not already owned by the httppost linked list
without deallocating nodes. List nodes are deallocated later on */
- struct FormInfo *ptr;
+ struct FormInfo *ptr;
for(ptr = form; ptr != NULL; ptr = ptr->more) {
if(ptr->name_alloc) {
Curl_safefree(ptr->name);
@@ -676,7 +676,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
fields given that these have either been deallocated or are owned
now by the httppost linked list */
while(first_form) {
- struct FormInfo *ptr = first_form->more;
+ struct FormInfo *ptr = first_form->more;
free(first_form);
first_form = ptr;
}
@@ -728,10 +728,10 @@ int curl_formget(struct curl_httppost *form, void *arg,
if(!nread)
break;
- if(nread > sizeof(buffer) || append(arg, buffer, nread) != nread) {
- result = CURLE_READ_ERROR;
- if(nread == CURL_READFUNC_ABORT)
- result = CURLE_ABORTED_BY_CALLBACK;
+ if(nread > sizeof(buffer) || append(arg, buffer, nread) != nread) {
+ result = CURLE_READ_ERROR;
+ if(nread == CURL_READFUNC_ABORT)
+ result = CURLE_ABORTED_BY_CALLBACK;
}
}
@@ -771,7 +771,7 @@ void curl_formfree(struct curl_httppost *form)
}
-/* Set mime part name, taking care of non null-terminated name string. */
+/* Set mime part name, taking care of non null-terminated name string. */
static CURLcode setname(curl_mimepart *part, const char *name, size_t len)
{
char *zname;
diff --git a/contrib/libs/curl/lib/formdata.h b/contrib/libs/curl/lib/formdata.h
index 142bbc53ad..5a021ceb92 100644
--- a/contrib/libs/curl/lib/formdata.h
+++ b/contrib/libs/curl/lib/formdata.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -27,7 +27,7 @@
#ifndef CURL_DISABLE_MIME
/* used by FormAdd for temporary storage */
-struct FormInfo {
+struct FormInfo {
char *name;
bool name_alloc;
size_t namelength;
@@ -45,7 +45,7 @@ struct FormInfo {
char *userp; /* pointer for the read callback */
struct curl_slist *contentheader;
struct FormInfo *more;
-};
+};
CURLcode Curl_getformdata(struct Curl_easy *data,
curl_mimepart *,
diff --git a/contrib/libs/curl/lib/ftp.c b/contrib/libs/curl/lib/ftp.c
index 93aa90015c..bc35574217 100644
--- a/contrib/libs/curl/lib/ftp.c
+++ b/contrib/libs/curl/lib/ftp.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -59,7 +59,7 @@
#include "fileinfo.h"
#include "ftplistparser.h"
#include "curl_range.h"
-#include "curl_krb5.h"
+#include "curl_krb5.h"
#include "strtoofft.h"
#include "strcase.h"
#include "vtls/vtls.h"
@@ -77,7 +77,7 @@
#include "warnless.h"
#include "http_proxy.h"
#include "non-ascii.h"
-#include "socks.h"
+#include "socks.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
#include "curl_memory.h"
@@ -113,7 +113,7 @@ static CURLcode ftp_parse_url_path(struct connectdata *conn);
static CURLcode ftp_regular_transfer(struct connectdata *conn, bool *done);
#ifndef CURL_DISABLE_VERBOSE_STRINGS
static void ftp_pasv_verbose(struct connectdata *conn,
- struct Curl_addrinfo *ai,
+ struct Curl_addrinfo *ai,
char *newhost, /* ascii version */
int port);
#endif
@@ -136,7 +136,7 @@ static int ftp_getsock(struct connectdata *conn, curl_socket_t *socks);
static int ftp_domore_getsock(struct connectdata *conn, curl_socket_t *socks);
static CURLcode ftp_doing(struct connectdata *conn,
bool *dophase_done);
-static CURLcode ftp_setup_connection(struct connectdata *conn);
+static CURLcode ftp_setup_connection(struct connectdata *conn);
static CURLcode init_wc_data(struct connectdata *conn);
static CURLcode wc_statemach(struct connectdata *conn);
static void wc_data_dtor(void *ptr);
@@ -170,7 +170,7 @@ const struct Curl_handler Curl_handler_ftp = {
ZERO_NULL, /* connection_check */
PORT_FTP, /* defport */
CURLPROTO_FTP, /* protocol */
- CURLPROTO_FTP, /* family */
+ CURLPROTO_FTP, /* family */
PROTOPT_DUAL | PROTOPT_CLOSEACTION | PROTOPT_NEEDSPWD |
PROTOPT_NOURLQUERY | PROTOPT_PROXY_AS_HTTP |
PROTOPT_WILDCARD /* flags */
@@ -200,7 +200,7 @@ const struct Curl_handler Curl_handler_ftps = {
ZERO_NULL, /* connection_check */
PORT_FTPS, /* defport */
CURLPROTO_FTPS, /* protocol */
- CURLPROTO_FTP, /* family */
+ CURLPROTO_FTP, /* family */
PROTOPT_SSL | PROTOPT_DUAL | PROTOPT_CLOSEACTION |
PROTOPT_NEEDSPWD | PROTOPT_NOURLQUERY | PROTOPT_WILDCARD /* flags */
};
@@ -213,9 +213,9 @@ static void close_secondarysocket(struct connectdata *conn)
conn->sock[SECONDARYSOCKET] = CURL_SOCKET_BAD;
}
conn->bits.tcpconnect[SECONDARYSOCKET] = FALSE;
-#ifndef CURL_DISABLE_PROXY
- conn->bits.proxy_ssl_connected[SECONDARYSOCKET] = FALSE;
-#endif
+#ifndef CURL_DISABLE_PROXY
+ conn->bits.proxy_ssl_connected[SECONDARYSOCKET] = FALSE;
+#endif
}
/*
@@ -286,7 +286,7 @@ static CURLcode AcceptServerConnect(struct connectdata *conn)
conn->sock[SECONDARYSOCKET] = s;
(void)curlx_nonblock(s, TRUE); /* enable non-blocking */
- conn->bits.sock_accepted = TRUE;
+ conn->bits.sock_accepted = TRUE;
if(data->set.fsockopt) {
int error = 0;
@@ -329,7 +329,7 @@ static timediff_t ftp_timeleft_accept(struct Curl_easy *data)
now = Curl_now();
/* check if the generic timeout possibly is set shorter */
- other = Curl_timeleft(data, &now, FALSE);
+ other = Curl_timeleft(data, &now, FALSE);
if(other && (other < timeout_ms))
/* note that this also works fine for when other happens to be negative
due to it already having elapsed */
@@ -381,7 +381,7 @@ static CURLcode ReceivedServerConnect(struct connectdata *conn, bool *received)
if(pp->cache_size && pp->cache && pp->cache[0] > '3') {
/* Data connection could not be established, let's return */
infof(data, "There is negative response in cache while serv connect\n");
- (void)Curl_GetFTPResponse(&nread, conn, &ftpcode);
+ (void)Curl_GetFTPResponse(&nread, conn, &ftpcode);
return CURLE_FTP_ACCEPT_FAILED;
}
@@ -403,7 +403,7 @@ static CURLcode ReceivedServerConnect(struct connectdata *conn, bool *received)
}
else if(result & CURL_CSELECT_IN) {
infof(data, "Ctrl conn has data while waiting for data conn\n");
- (void)Curl_GetFTPResponse(&nread, conn, &ftpcode);
+ (void)Curl_GetFTPResponse(&nread, conn, &ftpcode);
if(ftpcode/100 > 3)
return CURLE_FTP_ACCEPT_FAILED;
@@ -506,7 +506,7 @@ static CURLcode AllowServerConnect(struct connectdata *conn, bool *connected)
}
else {
/* Add timeout to multi handle and break out of the loop */
- if(*connected == FALSE) {
+ if(*connected == FALSE) {
Curl_expire(data, data->set.accepttimeout > 0 ?
data->set.accepttimeout: DEFAULT_ACCEPT_TIMEOUT, 0);
}
@@ -627,8 +627,8 @@ CURLcode Curl_GetFTPResponse(ssize_t *nreadp, /* return number of bytes read */
while(!*ftpcode && !result) {
/* check and reset timeout value every lap */
- timediff_t timeout = Curl_pp_state_timeout(pp, FALSE);
- timediff_t interval_ms;
+ timediff_t timeout = Curl_pp_state_timeout(pp, FALSE);
+ timediff_t interval_ms;
if(timeout <= 0) {
failf(data, "FTP response timeout");
@@ -767,22 +767,22 @@ static void _state(struct connectdata *conn,
static CURLcode ftp_state_user(struct connectdata *conn)
{
- CURLcode result = Curl_pp_sendf(&conn->proto.ftpc.pp, "USER %s",
- conn->user?conn->user:"");
- if(!result) {
- state(conn, FTP_USER);
- conn->data->state.ftp_trying_alternative = FALSE;
- }
- return result;
+ CURLcode result = Curl_pp_sendf(&conn->proto.ftpc.pp, "USER %s",
+ conn->user?conn->user:"");
+ if(!result) {
+ state(conn, FTP_USER);
+ conn->data->state.ftp_trying_alternative = FALSE;
+ }
+ return result;
}
static CURLcode ftp_state_pwd(struct connectdata *conn)
{
- CURLcode result = Curl_pp_sendf(&conn->proto.ftpc.pp, "%s", "PWD");
- if(!result)
- state(conn, FTP_PWD);
+ CURLcode result = Curl_pp_sendf(&conn->proto.ftpc.pp, "%s", "PWD");
+ if(!result)
+ state(conn, FTP_PWD);
- return result;
+ return result;
}
/* For the FTP "protocol connect" and "doing" phases only */
@@ -802,12 +802,12 @@ static int ftp_domore_getsock(struct connectdata *conn, curl_socket_t *socks)
* handle ordinary commands.
*/
- if(SOCKS_STATE(conn->cnnct.state))
- return Curl_SOCKS_getsock(conn, socks, SECONDARYSOCKET);
-
+ if(SOCKS_STATE(conn->cnnct.state))
+ return Curl_SOCKS_getsock(conn, socks, SECONDARYSOCKET);
+
if(FTP_STOP == ftpc->state) {
int bits = GETSOCK_READSOCK(0);
- bool any = FALSE;
+ bool any = FALSE;
/* if stopped and still in this state, then we're also waiting for a
connect on the secondary connection */
@@ -822,11 +822,11 @@ static int ftp_domore_getsock(struct connectdata *conn, curl_socket_t *socks)
if(conn->tempsock[i] != CURL_SOCKET_BAD) {
socks[s] = conn->tempsock[i];
bits |= GETSOCK_WRITESOCK(s++);
- any = TRUE;
+ any = TRUE;
}
}
}
- if(!any) {
+ if(!any) {
socks[1] = conn->sock[SECONDARYSOCKET];
bits |= GETSOCK_WRITESOCK(1) | GETSOCK_READSOCK(1);
}
@@ -851,10 +851,10 @@ static CURLcode ftp_state_cwd(struct connectdata *conn)
/* already done and fine */
result = ftp_state_mdtm(conn);
else {
- /* FTPFILE_NOCWD with full path: expect ftpc->cwddone! */
- DEBUGASSERT((conn->data->set.ftp_filemethod != FTPFILE_NOCWD) ||
- !(ftpc->dirdepth && ftpc->dirs[0][0] == '/'));
-
+ /* FTPFILE_NOCWD with full path: expect ftpc->cwddone! */
+ DEBUGASSERT((conn->data->set.ftp_filemethod != FTPFILE_NOCWD) ||
+ !(ftpc->dirdepth && ftpc->dirs[0][0] == '/'));
+
ftpc->count2 = 0; /* count2 counts failed CWDs */
/* count3 is set to allow a MKD to fail once. In the case when first CWD
@@ -862,27 +862,27 @@ static CURLcode ftp_state_cwd(struct connectdata *conn)
dir) this then allows for a second try to CWD to it */
ftpc->count3 = (conn->data->set.ftp_create_missing_dirs == 2)?1:0;
- if(conn->bits.reuse && ftpc->entrypath &&
- /* no need to go to entrypath when we have an absolute path */
- !(ftpc->dirdepth && ftpc->dirs[0][0] == '/')) {
+ if(conn->bits.reuse && ftpc->entrypath &&
+ /* no need to go to entrypath when we have an absolute path */
+ !(ftpc->dirdepth && ftpc->dirs[0][0] == '/')) {
/* This is a re-used connection. Since we change directory to where the
transfer is taking place, we must first get back to the original dir
where we ended up after login: */
ftpc->cwdcount = 0; /* we count this as the first path, then we add one
for all upcoming ones in the ftp->dirs[] array */
- result = Curl_pp_sendf(&ftpc->pp, "CWD %s", ftpc->entrypath);
- if(!result)
- state(conn, FTP_CWD);
+ result = Curl_pp_sendf(&ftpc->pp, "CWD %s", ftpc->entrypath);
+ if(!result)
+ state(conn, FTP_CWD);
}
else {
if(ftpc->dirdepth) {
ftpc->cwdcount = 1;
/* issue the first CWD, the rest is sent when the CWD responses are
received... */
- result = Curl_pp_sendf(&ftpc->pp, "CWD %s",
- ftpc->dirs[ftpc->cwdcount -1]);
- if(!result)
- state(conn, FTP_CWD);
+ result = Curl_pp_sendf(&ftpc->pp, "CWD %s",
+ ftpc->dirs[ftpc->cwdcount -1]);
+ if(!result)
+ state(conn, FTP_CWD);
}
else {
/* No CWD necessary */
@@ -906,10 +906,10 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
struct ftp_conn *ftpc = &conn->proto.ftpc;
struct Curl_easy *data = conn->data;
curl_socket_t portsock = CURL_SOCKET_BAD;
- char myhost[MAX_IPADR_LEN + 1] = "";
+ char myhost[MAX_IPADR_LEN + 1] = "";
struct Curl_sockaddr_storage ss;
- struct Curl_addrinfo *res, *ai;
+ struct Curl_addrinfo *res, *ai;
curl_socklen_t sslen;
char hbuf[NI_MAXHOST];
struct sockaddr *sa = (struct sockaddr *)&ss;
@@ -918,7 +918,7 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
struct sockaddr_in6 * const sa6 = (void *)sa;
#endif
static const char mode[][5] = { "EPRT", "PORT" };
- enum resolve_t rc;
+ enum resolve_t rc;
int error;
char *host = NULL;
char *string_ftpport = data->set.str[STRING_FTPPORT];
@@ -1034,7 +1034,7 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
} /* data->set.ftpport */
if(!host) {
- const char *r;
+ const char *r;
/* not an interface and not a host name, get default by extracting
the IP from the control connection */
sslen = sizeof(ss);
@@ -1047,15 +1047,15 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
switch(sa->sa_family) {
#ifdef ENABLE_IPV6
case AF_INET6:
- r = Curl_inet_ntop(sa->sa_family, &sa6->sin6_addr, hbuf, sizeof(hbuf));
+ r = Curl_inet_ntop(sa->sa_family, &sa6->sin6_addr, hbuf, sizeof(hbuf));
break;
#endif
default:
- r = Curl_inet_ntop(sa->sa_family, &sa4->sin_addr, hbuf, sizeof(hbuf));
+ r = Curl_inet_ntop(sa->sa_family, &sa4->sin_addr, hbuf, sizeof(hbuf));
break;
}
- if(!r)
- return CURLE_FTP_PORT_FAILED;
+ if(!r)
+ return CURLE_FTP_PORT_FAILED;
host = hbuf; /* use this host name */
possibly_non_local = FALSE; /* we know it is local now */
}
@@ -1234,10 +1234,10 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
break;
}
if(PORT == fcmd) {
- /* large enough for [IP address],[num],[num] */
- char target[sizeof(myhost) + 20];
+ /* large enough for [IP address],[num],[num] */
+ char target[sizeof(myhost) + 20];
char *source = myhost;
- char *dest = target;
+ char *dest = target;
/* translate x.x.x.x to x,x,x,x */
while(source && *source) {
@@ -1251,7 +1251,7 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
*dest = 0;
msnprintf(dest, 20, ",%d,%d", (int)(port>>8), (int)(port&0xff));
- result = Curl_pp_sendf(&ftpc->pp, "%s %s", mode[fcmd], target);
+ result = Curl_pp_sendf(&ftpc->pp, "%s %s", mode[fcmd], target);
if(result) {
failf(data, "Failure sending PORT command: %s",
curl_easy_strerror(result));
@@ -1292,7 +1292,7 @@ static CURLcode ftp_state_use_pasv(struct connectdata *conn)
struct ftp_conn *ftpc = &conn->proto.ftpc;
CURLcode result = CURLE_OK;
/*
- Here's the executive summary on what to do:
+ Here's the executive summary on what to do:
PASV is RFC959, expect:
227 Entering Passive Mode (a1,a2,a3,a4,p1,p2)
@@ -1317,12 +1317,12 @@ static CURLcode ftp_state_use_pasv(struct connectdata *conn)
modeoff = conn->bits.ftp_use_epsv?0:1;
- result = Curl_pp_sendf(&ftpc->pp, "%s", mode[modeoff]);
- if(!result) {
- ftpc->count1 = modeoff;
- state(conn, FTP_PASV);
- infof(conn->data, "Connect data stream passively\n");
- }
+ result = Curl_pp_sendf(&ftpc->pp, "%s", mode[modeoff]);
+ if(!result) {
+ ftpc->count1 = modeoff;
+ state(conn, FTP_PASV);
+ infof(conn->data, "Connect data stream passively\n");
+ }
return result;
}
@@ -1336,7 +1336,7 @@ static CURLcode ftp_state_use_pasv(struct connectdata *conn)
static CURLcode ftp_state_prepare_transfer(struct connectdata *conn)
{
CURLcode result = CURLE_OK;
- struct FTP *ftp = conn->data->req.p.ftp;
+ struct FTP *ftp = conn->data->req.p.ftp;
struct Curl_easy *data = conn->data;
if(ftp->transfer != FTPTRANSFER_BODY) {
@@ -1355,22 +1355,22 @@ static CURLcode ftp_state_prepare_transfer(struct connectdata *conn)
if(data->set.ftp_use_pret) {
/* The user has requested that we send a PRET command
to prepare the server for the upcoming PASV */
- struct ftp_conn *ftpc = &conn->proto.ftpc;
- if(!conn->proto.ftpc.file)
- result = Curl_pp_sendf(&ftpc->pp, "PRET %s",
- data->set.str[STRING_CUSTOMREQUEST]?
- data->set.str[STRING_CUSTOMREQUEST]:
- (data->set.ftp_list_only?"NLST":"LIST"));
- else if(data->set.upload)
- result = Curl_pp_sendf(&ftpc->pp, "PRET STOR %s",
- conn->proto.ftpc.file);
- else
- result = Curl_pp_sendf(&ftpc->pp, "PRET RETR %s",
- conn->proto.ftpc.file);
- if(!result)
- state(conn, FTP_PRET);
+ struct ftp_conn *ftpc = &conn->proto.ftpc;
+ if(!conn->proto.ftpc.file)
+ result = Curl_pp_sendf(&ftpc->pp, "PRET %s",
+ data->set.str[STRING_CUSTOMREQUEST]?
+ data->set.str[STRING_CUSTOMREQUEST]:
+ (data->set.ftp_list_only?"NLST":"LIST"));
+ else if(data->set.upload)
+ result = Curl_pp_sendf(&ftpc->pp, "PRET STOR %s",
+ conn->proto.ftpc.file);
+ else
+ result = Curl_pp_sendf(&ftpc->pp, "PRET RETR %s",
+ conn->proto.ftpc.file);
+ if(!result)
+ state(conn, FTP_PRET);
}
- else
+ else
result = ftp_state_use_pasv(conn);
}
return result;
@@ -1379,7 +1379,7 @@ static CURLcode ftp_state_prepare_transfer(struct connectdata *conn)
static CURLcode ftp_state_rest(struct connectdata *conn)
{
CURLcode result = CURLE_OK;
- struct FTP *ftp = conn->data->req.p.ftp;
+ struct FTP *ftp = conn->data->req.p.ftp;
struct ftp_conn *ftpc = &conn->proto.ftpc;
if((ftp->transfer != FTPTRANSFER_BODY) && ftpc->file) {
@@ -1387,9 +1387,9 @@ static CURLcode ftp_state_rest(struct connectdata *conn)
/* Determine if server can respond to REST command and therefore
whether it supports range */
- result = Curl_pp_sendf(&ftpc->pp, "REST %d", 0);
- if(!result)
- state(conn, FTP_REST);
+ result = Curl_pp_sendf(&ftpc->pp, "REST %d", 0);
+ if(!result)
+ state(conn, FTP_REST);
}
else
result = ftp_state_prepare_transfer(conn);
@@ -1400,16 +1400,16 @@ static CURLcode ftp_state_rest(struct connectdata *conn)
static CURLcode ftp_state_size(struct connectdata *conn)
{
CURLcode result = CURLE_OK;
- struct FTP *ftp = conn->data->req.p.ftp;
+ struct FTP *ftp = conn->data->req.p.ftp;
struct ftp_conn *ftpc = &conn->proto.ftpc;
if((ftp->transfer == FTPTRANSFER_INFO) && ftpc->file) {
/* if a "head"-like request is being made (on a file) */
/* we know ftpc->file is a valid pointer to a file name */
- result = Curl_pp_sendf(&ftpc->pp, "SIZE %s", ftpc->file);
- if(!result)
- state(conn, FTP_SIZE);
+ result = Curl_pp_sendf(&ftpc->pp, "SIZE %s", ftpc->file);
+ if(!result)
+ state(conn, FTP_SIZE);
}
else
result = ftp_state_rest(conn);
@@ -1421,7 +1421,7 @@ static CURLcode ftp_state_list(struct connectdata *conn)
{
CURLcode result = CURLE_OK;
struct Curl_easy *data = conn->data;
- struct FTP *ftp = data->req.p.ftp;
+ struct FTP *ftp = data->req.p.ftp;
/* If this output is to be machine-parsed, the NLST command might be better
to use, since the LIST command output is not specified or standard in any
@@ -1429,37 +1429,37 @@ static CURLcode ftp_state_list(struct connectdata *conn)
servers either... */
/*
- if FTPFILE_NOCWD was specified, we should add the path
+ if FTPFILE_NOCWD was specified, we should add the path
as argument for the LIST / NLST / or custom command.
Whether the server will support this, is uncertain.
The other ftp_filemethods will CWD into dir/dir/ first and
then just do LIST (in that case: nothing to do here)
*/
- char *lstArg = NULL;
- char *cmd;
-
- if((data->set.ftp_filemethod == FTPFILE_NOCWD) && ftp->path) {
- /* url-decode before evaluation: e.g. paths starting/ending with %2f */
- const char *slashPos = NULL;
- char *rawPath = NULL;
- result = Curl_urldecode(data, ftp->path, 0, &rawPath, NULL, REJECT_CTRL);
- if(result)
- return result;
-
- slashPos = strrchr(rawPath, '/');
- if(slashPos) {
- /* chop off the file part if format is dir/file otherwise remove
- the trailing slash for dir/dir/ except for absolute path / */
- size_t n = slashPos - rawPath;
- if(n == 0)
- ++n;
-
- lstArg = rawPath;
- lstArg[n] = '\0';
+ char *lstArg = NULL;
+ char *cmd;
+
+ if((data->set.ftp_filemethod == FTPFILE_NOCWD) && ftp->path) {
+ /* url-decode before evaluation: e.g. paths starting/ending with %2f */
+ const char *slashPos = NULL;
+ char *rawPath = NULL;
+ result = Curl_urldecode(data, ftp->path, 0, &rawPath, NULL, REJECT_CTRL);
+ if(result)
+ return result;
+
+ slashPos = strrchr(rawPath, '/');
+ if(slashPos) {
+ /* chop off the file part if format is dir/file otherwise remove
+ the trailing slash for dir/dir/ except for absolute path / */
+ size_t n = slashPos - rawPath;
+ if(n == 0)
+ ++n;
+
+ lstArg = rawPath;
+ lstArg[n] = '\0';
}
- else
- free(rawPath);
+ else
+ free(rawPath);
}
cmd = aprintf("%s%s%s",
@@ -1468,16 +1468,16 @@ static CURLcode ftp_state_list(struct connectdata *conn)
(data->set.ftp_list_only?"NLST":"LIST"),
lstArg? " ": "",
lstArg? lstArg: "");
- free(lstArg);
+ free(lstArg);
- if(!cmd)
+ if(!cmd)
return CURLE_OUT_OF_MEMORY;
result = Curl_pp_sendf(&conn->proto.ftpc.pp, "%s", cmd);
free(cmd);
- if(!result)
- state(conn, FTP_LIST);
+ if(!result)
+ state(conn, FTP_LIST);
return result;
}
@@ -1497,7 +1497,7 @@ static CURLcode ftp_state_stor_prequote(struct connectdata *conn)
static CURLcode ftp_state_type(struct connectdata *conn)
{
CURLcode result = CURLE_OK;
- struct FTP *ftp = conn->data->req.p.ftp;
+ struct FTP *ftp = conn->data->req.p.ftp;
struct Curl_easy *data = conn->data;
struct ftp_conn *ftpc = &conn->proto.ftpc;
@@ -1538,10 +1538,10 @@ static CURLcode ftp_state_mdtm(struct connectdata *conn)
/* we have requested to get the modified-time of the file, this is a white
spot as the MDTM is not mentioned in RFC959 */
- result = Curl_pp_sendf(&ftpc->pp, "MDTM %s", ftpc->file);
+ result = Curl_pp_sendf(&ftpc->pp, "MDTM %s", ftpc->file);
- if(!result)
- state(conn, FTP_MDTM);
+ if(!result)
+ state(conn, FTP_MDTM);
}
else
result = ftp_state_type(conn);
@@ -1555,7 +1555,7 @@ static CURLcode ftp_state_ul_setup(struct connectdata *conn,
bool sizechecked)
{
CURLcode result = CURLE_OK;
- struct FTP *ftp = conn->data->req.p.ftp;
+ struct FTP *ftp = conn->data->req.p.ftp;
struct Curl_easy *data = conn->data;
struct ftp_conn *ftpc = &conn->proto.ftpc;
@@ -1577,9 +1577,9 @@ static CURLcode ftp_state_ul_setup(struct connectdata *conn,
if(data->state.resume_from < 0) {
/* Got no given size to start from, figure it out */
- result = Curl_pp_sendf(&ftpc->pp, "SIZE %s", ftpc->file);
- if(!result)
- state(conn, FTP_STOR_SIZE);
+ result = Curl_pp_sendf(&ftpc->pp, "SIZE %s", ftpc->file);
+ if(!result)
+ state(conn, FTP_STOR_SIZE);
return result;
}
@@ -1641,10 +1641,10 @@ static CURLcode ftp_state_ul_setup(struct connectdata *conn,
/* we've passed, proceed as normal */
} /* resume_from */
- result = Curl_pp_sendf(&ftpc->pp, data->set.ftp_append?"APPE %s":"STOR %s",
- ftpc->file);
- if(!result)
- state(conn, FTP_STOR);
+ result = Curl_pp_sendf(&ftpc->pp, data->set.ftp_append?"APPE %s":"STOR %s",
+ ftpc->file);
+ if(!result)
+ state(conn, FTP_STOR);
return result;
}
@@ -1655,7 +1655,7 @@ static CURLcode ftp_state_quote(struct connectdata *conn,
{
CURLcode result = CURLE_OK;
struct Curl_easy *data = conn->data;
- struct FTP *ftp = data->req.p.ftp;
+ struct FTP *ftp = data->req.p.ftp;
struct ftp_conn *ftpc = &conn->proto.ftpc;
bool quote = FALSE;
struct curl_slist *item;
@@ -1702,9 +1702,9 @@ static CURLcode ftp_state_quote(struct connectdata *conn,
else
ftpc->count2 = 0; /* failure means cancel operation */
- result = Curl_pp_sendf(&ftpc->pp, "%s", cmd);
- if(result)
- return result;
+ result = Curl_pp_sendf(&ftpc->pp, "%s", cmd);
+ if(result)
+ return result;
state(conn, instate);
quote = TRUE;
}
@@ -1733,14 +1733,14 @@ static CURLcode ftp_state_quote(struct connectdata *conn,
the server terminates it, otherwise the client stops if the
received byte count exceeds the reported file size. Set option
CURLOPT_IGNORE_CONTENT_LENGTH to 1 to enable this behavior.*/
- result = Curl_pp_sendf(&ftpc->pp, "RETR %s", ftpc->file);
- if(!result)
- state(conn, FTP_RETR);
+ result = Curl_pp_sendf(&ftpc->pp, "RETR %s", ftpc->file);
+ if(!result)
+ state(conn, FTP_RETR);
}
else {
- result = Curl_pp_sendf(&ftpc->pp, "SIZE %s", ftpc->file);
- if(!result)
- state(conn, FTP_RETR_SIZE);
+ result = Curl_pp_sendf(&ftpc->pp, "SIZE %s", ftpc->file);
+ if(!result)
+ state(conn, FTP_RETR_SIZE);
}
}
}
@@ -1762,11 +1762,11 @@ static CURLcode ftp_epsv_disable(struct connectdata *conn)
{
CURLcode result = CURLE_OK;
- if(conn->bits.ipv6
-#ifndef CURL_DISABLE_PROXY
- && !(conn->bits.tunnel_proxy || conn->bits.socksproxy)
-#endif
- ) {
+ if(conn->bits.ipv6
+#ifndef CURL_DISABLE_PROXY
+ && !(conn->bits.tunnel_proxy || conn->bits.socksproxy)
+#endif
+ ) {
/* We can't disable EPSV when doing IPv6, so this is instead a fail */
failf(conn->data, "Failed EPSV attempt, exiting\n");
return CURLE_WEIRD_SERVER_REPLY;
@@ -1777,12 +1777,12 @@ static CURLcode ftp_epsv_disable(struct connectdata *conn)
conn->bits.ftp_use_epsv = FALSE;
conn->data->state.errorbuf = FALSE; /* allow error message to get
rewritten */
- result = Curl_pp_sendf(&conn->proto.ftpc.pp, "%s", "PASV");
- if(!result) {
- conn->proto.ftpc.count1++;
- /* remain in/go to the FTP_PASV state */
- state(conn, FTP_PASV);
- }
+ result = Curl_pp_sendf(&conn->proto.ftpc.pp, "%s", "PASV");
+ if(!result) {
+ conn->proto.ftpc.count1++;
+ /* remain in/go to the FTP_PASV state */
+ state(conn, FTP_PASV);
+ }
return result;
}
@@ -1793,10 +1793,10 @@ static char *control_address(struct connectdata *conn)
If a proxy tunnel is used, returns the original host name instead, because
the effective control connection address is the proxy address,
not the ftp host. */
-#ifndef CURL_DISABLE_PROXY
+#ifndef CURL_DISABLE_PROXY
if(conn->bits.tunnel_proxy || conn->bits.socksproxy)
return conn->host.name;
-#endif
+#endif
return conn->ip_addr_str;
}
@@ -1807,7 +1807,7 @@ static CURLcode ftp_state_pasv_resp(struct connectdata *conn,
CURLcode result;
struct Curl_easy *data = conn->data;
struct Curl_dns_entry *addr = NULL;
- enum resolve_t rc;
+ enum resolve_t rc;
unsigned short connectport; /* the local port connect() should use! */
char *str = &data->state.buffer[4]; /* start on the first letter */
@@ -1861,8 +1861,8 @@ static CURLcode ftp_state_pasv_resp(struct connectdata *conn,
else if((ftpc->count1 == 1) &&
(ftpcode == 227)) {
/* positive PASV response */
- unsigned int ip[4] = {0, 0, 0, 0};
- unsigned int port[2] = {0, 0};
+ unsigned int ip[4] = {0, 0, 0, 0};
+ unsigned int port[2] = {0, 0};
/*
* Scan for a sequence of six comma-separated numbers and use them as
@@ -1913,7 +1913,7 @@ static CURLcode ftp_state_pasv_resp(struct connectdata *conn,
return CURLE_FTP_WEIRD_PASV_REPLY;
}
-#ifndef CURL_DISABLE_PROXY
+#ifndef CURL_DISABLE_PROXY
if(conn->bits.proxy) {
/*
* This connection uses a proxy and we need to connect to the proxy again
@@ -1936,21 +1936,21 @@ static CURLcode ftp_state_pasv_resp(struct connectdata *conn,
return CURLE_COULDNT_RESOLVE_PROXY;
}
}
- else
-#endif
- {
+ else
+#endif
+ {
/* normal, direct, ftp connection */
- DEBUGASSERT(ftpc->newhost);
-
- /* postponed address resolution in case of tcp fastopen */
- if(conn->bits.tcp_fastopen && !conn->bits.reuse && !ftpc->newhost[0]) {
- Curl_conninfo_remote(conn, conn->sock[FIRSTSOCKET]);
- Curl_safefree(ftpc->newhost);
- ftpc->newhost = strdup(control_address(conn));
- if(!ftpc->newhost)
- return CURLE_OUT_OF_MEMORY;
- }
-
+ DEBUGASSERT(ftpc->newhost);
+
+ /* postponed address resolution in case of tcp fastopen */
+ if(conn->bits.tcp_fastopen && !conn->bits.reuse && !ftpc->newhost[0]) {
+ Curl_conninfo_remote(conn, conn->sock[FIRSTSOCKET]);
+ Curl_safefree(ftpc->newhost);
+ ftpc->newhost = strdup(control_address(conn));
+ if(!ftpc->newhost)
+ return CURLE_OUT_OF_MEMORY;
+ }
+
rc = Curl_resolv(conn, ftpc->newhost, ftpc->newport, FALSE, &addr);
if(rc == CURLRESOLV_PENDING)
/* BLOCKING */
@@ -2041,7 +2041,7 @@ static CURLcode ftp_state_mdtm_resp(struct connectdata *conn,
{
CURLcode result = CURLE_OK;
struct Curl_easy *data = conn->data;
- struct FTP *ftp = data->req.p.ftp;
+ struct FTP *ftp = data->req.p.ftp;
struct ftp_conn *ftpc = &conn->proto.ftpc;
switch(ftpcode) {
@@ -2058,7 +2058,7 @@ static CURLcode ftp_state_mdtm_resp(struct connectdata *conn,
"%04d%02d%02d %02d:%02d:%02d GMT",
year, month, day, hour, minute, second);
/* now, convert this into a time() value: */
- data->info.filetime = Curl_getdate_capped(timebuf);
+ data->info.filetime = Curl_getdate_capped(timebuf);
}
#ifdef CURL_FTP_HTTPSTYLE_HEAD
@@ -2100,7 +2100,7 @@ static CURLcode ftp_state_mdtm_resp(struct connectdata *conn,
break;
case 550: /* "No such file or directory" */
failf(data, "Given file does not exist");
- result = CURLE_REMOTE_FILE_NOT_FOUND;
+ result = CURLE_REMOTE_FILE_NOT_FOUND;
break;
}
@@ -2174,7 +2174,7 @@ static CURLcode ftp_state_retr(struct connectdata *conn,
{
CURLcode result = CURLE_OK;
struct Curl_easy *data = conn->data;
- struct FTP *ftp = data->req.p.ftp;
+ struct FTP *ftp = data->req.p.ftp;
struct ftp_conn *ftpc = &conn->proto.ftpc;
if(data->set.max_filesize && (filesize > data->set.max_filesize)) {
@@ -2237,16 +2237,16 @@ static CURLcode ftp_state_retr(struct connectdata *conn,
infof(data, "Instructs server to resume from offset %"
CURL_FORMAT_CURL_OFF_T "\n", data->state.resume_from);
- result = Curl_pp_sendf(&ftpc->pp, "REST %" CURL_FORMAT_CURL_OFF_T,
- data->state.resume_from);
- if(!result)
- state(conn, FTP_RETR_REST);
+ result = Curl_pp_sendf(&ftpc->pp, "REST %" CURL_FORMAT_CURL_OFF_T,
+ data->state.resume_from);
+ if(!result)
+ state(conn, FTP_RETR_REST);
}
else {
/* no resume */
- result = Curl_pp_sendf(&ftpc->pp, "RETR %s", ftpc->file);
- if(!result)
- state(conn, FTP_RETR);
+ result = Curl_pp_sendf(&ftpc->pp, "RETR %s", ftpc->file);
+ if(!result)
+ state(conn, FTP_RETR);
}
return result;
@@ -2262,30 +2262,30 @@ static CURLcode ftp_state_size_resp(struct connectdata *conn,
char *buf = data->state.buffer;
/* get the size from the ascii string: */
- if(ftpcode == 213) {
- /* To allow servers to prepend "rubbish" in the response string, we scan
- for all the digits at the end of the response and parse only those as a
- number. */
- char *start = &buf[4];
- char *fdigit = strchr(start, '\r');
- if(fdigit) {
- do
- fdigit--;
- while(ISDIGIT(*fdigit) && (fdigit > start));
- if(!ISDIGIT(*fdigit))
- fdigit++;
- }
- else
- fdigit = start;
+ if(ftpcode == 213) {
+ /* To allow servers to prepend "rubbish" in the response string, we scan
+ for all the digits at the end of the response and parse only those as a
+ number. */
+ char *start = &buf[4];
+ char *fdigit = strchr(start, '\r');
+ if(fdigit) {
+ do
+ fdigit--;
+ while(ISDIGIT(*fdigit) && (fdigit > start));
+ if(!ISDIGIT(*fdigit))
+ fdigit++;
+ }
+ else
+ fdigit = start;
/* ignores parsing errors, which will make the size remain unknown */
- (void)curlx_strtoofft(fdigit, NULL, 0, &filesize);
-
- }
- else if(ftpcode == 550) { /* "No such file or directory" */
- failf(data, "The file does not exist");
- return CURLE_REMOTE_FILE_NOT_FOUND;
- }
-
+ (void)curlx_strtoofft(fdigit, NULL, 0, &filesize);
+
+ }
+ else if(ftpcode == 550) { /* "No such file or directory" */
+ failf(data, "The file does not exist");
+ return CURLE_REMOTE_FILE_NOT_FOUND;
+ }
+
if(instate == FTP_SIZE) {
#ifdef CURL_FTP_HTTPSTYLE_HEAD
if(-1 != filesize) {
@@ -2339,9 +2339,9 @@ static CURLcode ftp_state_rest_resp(struct connectdata *conn,
result = CURLE_FTP_COULDNT_USE_REST;
}
else {
- result = Curl_pp_sendf(&ftpc->pp, "RETR %s", ftpc->file);
- if(!result)
- state(conn, FTP_RETR);
+ result = Curl_pp_sendf(&ftpc->pp, "RETR %s", ftpc->file);
+ if(!result)
+ state(conn, FTP_RETR);
}
break;
}
@@ -2392,7 +2392,7 @@ static CURLcode ftp_state_get_resp(struct connectdata *conn,
{
CURLcode result = CURLE_OK;
struct Curl_easy *data = conn->data;
- struct FTP *ftp = data->req.p.ftp;
+ struct FTP *ftp = data->req.p.ftp;
if((ftpcode == 150) || (ftpcode == 125)) {
@@ -2518,7 +2518,7 @@ static CURLcode ftp_state_loggedin(struct connectdata *conn)
{
CURLcode result = CURLE_OK;
- if(conn->bits.ftp_use_control_ssl) {
+ if(conn->bits.ftp_use_control_ssl) {
/* PBSZ = PROTECTION BUFFER SIZE.
The 'draft-murray-auth-ftp-ssl' (draft 12, page 7) says:
@@ -2533,9 +2533,9 @@ static CURLcode ftp_state_loggedin(struct connectdata *conn)
parameter of '0' to indicate that no buffering is taking place
and the data connection should not be encapsulated.
*/
- result = Curl_pp_sendf(&conn->proto.ftpc.pp, "PBSZ %d", 0);
- if(!result)
- state(conn, FTP_PBSZ);
+ result = Curl_pp_sendf(&conn->proto.ftpc.pp, "PBSZ %d", 0);
+ if(!result)
+ state(conn, FTP_PBSZ);
}
else {
result = ftp_state_pwd(conn);
@@ -2557,9 +2557,9 @@ static CURLcode ftp_state_user_resp(struct connectdata *conn,
if((ftpcode == 331) && (ftpc->state == FTP_USER)) {
/* 331 Password required for ...
(the server requires to send the user's password too) */
- result = Curl_pp_sendf(&ftpc->pp, "PASS %s", conn->passwd?conn->passwd:"");
- if(!result)
- state(conn, FTP_PASS);
+ result = Curl_pp_sendf(&ftpc->pp, "PASS %s", conn->passwd?conn->passwd:"");
+ if(!result)
+ state(conn, FTP_PASS);
}
else if(ftpcode/100 == 2) {
/* 230 User ... logged in.
@@ -2568,10 +2568,10 @@ static CURLcode ftp_state_user_resp(struct connectdata *conn,
}
else if(ftpcode == 332) {
if(data->set.str[STRING_FTP_ACCOUNT]) {
- result = Curl_pp_sendf(&ftpc->pp, "ACCT %s",
- data->set.str[STRING_FTP_ACCOUNT]);
- if(!result)
- state(conn, FTP_ACCT);
+ result = Curl_pp_sendf(&ftpc->pp, "ACCT %s",
+ data->set.str[STRING_FTP_ACCOUNT]);
+ if(!result)
+ state(conn, FTP_ACCT);
}
else {
failf(data, "ACCT requested but none available");
@@ -2587,13 +2587,13 @@ static CURLcode ftp_state_user_resp(struct connectdata *conn,
if(conn->data->set.str[STRING_FTP_ALTERNATIVE_TO_USER] &&
!conn->data->state.ftp_trying_alternative) {
/* Ok, USER failed. Let's try the supplied command. */
- result =
- Curl_pp_sendf(&ftpc->pp, "%s",
- conn->data->set.str[STRING_FTP_ALTERNATIVE_TO_USER]);
- if(!result) {
- conn->data->state.ftp_trying_alternative = TRUE;
- state(conn, FTP_USER);
- }
+ result =
+ Curl_pp_sendf(&ftpc->pp, "%s",
+ conn->data->set.str[STRING_FTP_ALTERNATIVE_TO_USER]);
+ if(!result) {
+ conn->data->state.ftp_trying_alternative = TRUE;
+ state(conn, FTP_USER);
+ }
}
else {
failf(data, "Access denied: %03d", ftpcode);
@@ -2669,8 +2669,8 @@ static CURLcode ftp_statemach_act(struct connectdata *conn)
}
#endif
- if(data->set.use_ssl && !conn->bits.ftp_use_control_ssl) {
- /* We don't have a SSL/TLS control connection yet, but FTPS is
+ if(data->set.use_ssl && !conn->bits.ftp_use_control_ssl) {
+ /* We don't have a SSL/TLS control connection yet, but FTPS is
requested. Try a FTPS connection now */
ftpc->count3 = 0;
@@ -2689,11 +2689,11 @@ static CURLcode ftp_statemach_act(struct connectdata *conn)
(int)data->set.ftpsslauth);
return CURLE_UNKNOWN_OPTION; /* we don't know what to do */
}
- result = Curl_pp_sendf(&ftpc->pp, "AUTH %s", ftpauth[ftpc->count1]);
- if(!result)
- state(conn, FTP_AUTH);
+ result = Curl_pp_sendf(&ftpc->pp, "AUTH %s", ftpauth[ftpc->count1]);
+ if(!result)
+ state(conn, FTP_AUTH);
}
- else
+ else
result = ftp_state_user(conn);
break;
@@ -2712,7 +2712,7 @@ static CURLcode ftp_statemach_act(struct connectdata *conn)
result = Curl_ssl_connect(conn, FIRSTSOCKET);
if(!result) {
conn->bits.ftp_use_data_ssl = FALSE; /* clear-text data */
- conn->bits.ftp_use_control_ssl = TRUE; /* SSL on control */
+ conn->bits.ftp_use_control_ssl = TRUE; /* SSL on control */
result = ftp_state_user(conn);
}
}
@@ -2742,11 +2742,11 @@ static CURLcode ftp_statemach_act(struct connectdata *conn)
break;
case FTP_PBSZ:
- result =
- Curl_pp_sendf(&ftpc->pp, "PROT %c",
- data->set.use_ssl == CURLUSESSL_CONTROL ? 'C' : 'P');
- if(!result)
- state(conn, FTP_PROT);
+ result =
+ Curl_pp_sendf(&ftpc->pp, "PROT %c",
+ data->set.use_ssl == CURLUSESSL_CONTROL ? 'C' : 'P');
+ if(!result)
+ state(conn, FTP_PROT);
break;
case FTP_PROT:
@@ -2763,11 +2763,11 @@ static CURLcode ftp_statemach_act(struct connectdata *conn)
if(data->set.ftp_ccc) {
/* CCC - Clear Command Channel
*/
- result = Curl_pp_sendf(&ftpc->pp, "%s", "CCC");
- if(!result)
- state(conn, FTP_CCC);
+ result = Curl_pp_sendf(&ftpc->pp, "%s", "CCC");
+ if(!result)
+ state(conn, FTP_CCC);
}
- else
+ else
result = ftp_state_pwd(conn);
break;
@@ -2776,12 +2776,12 @@ static CURLcode ftp_statemach_act(struct connectdata *conn)
/* First shut down the SSL layer (note: this call will block) */
result = Curl_ssl_shutdown(conn, FIRSTSOCKET);
- if(result)
+ if(result)
failf(conn->data, "Failed to clear the command channel (CCC)");
}
- if(!result)
- /* Then continue as normal */
- result = ftp_state_pwd(conn);
+ if(!result)
+ /* Then continue as normal */
+ result = ftp_state_pwd(conn);
break;
case FTP_PWD:
@@ -2831,7 +2831,7 @@ static CURLcode ftp_statemach_act(struct connectdata *conn)
store++;
ptr++;
}
- *store = '\0'; /* null-terminate */
+ *store = '\0'; /* null-terminate */
}
if(entry_extracted) {
/* If the path name does not look like an absolute path (i.e.: it
@@ -2894,7 +2894,7 @@ static CURLcode ftp_statemach_act(struct connectdata *conn)
ptr++;
for(store = os; *ptr && *ptr != ' ';)
*store++ = *ptr++;
- *store = '\0'; /* null-terminate */
+ *store = '\0'; /* null-terminate */
/* Check for special servers here. */
@@ -2942,10 +2942,10 @@ static CURLcode ftp_statemach_act(struct connectdata *conn)
if((ftpcode >= 400) && !ftpc->count2) {
/* failure response code, and not allowed to fail */
failf(conn->data, "QUOT command failed with %03d", ftpcode);
- result = CURLE_QUOTE_ERROR;
+ result = CURLE_QUOTE_ERROR;
}
- else
- result = ftp_state_quote(conn, FALSE, ftpc->state);
+ else
+ result = ftp_state_quote(conn, FALSE, ftpc->state);
break;
case FTP_CWD:
@@ -2955,27 +2955,27 @@ static CURLcode ftp_statemach_act(struct connectdata *conn)
ftpc->cwdcount && !ftpc->count2) {
/* try making it */
ftpc->count2++; /* counter to prevent CWD-MKD loops */
- result = Curl_pp_sendf(&ftpc->pp, "MKD %s",
- ftpc->dirs[ftpc->cwdcount - 1]);
- if(!result)
- state(conn, FTP_MKD);
+ result = Curl_pp_sendf(&ftpc->pp, "MKD %s",
+ ftpc->dirs[ftpc->cwdcount - 1]);
+ if(!result)
+ state(conn, FTP_MKD);
}
else {
/* return failure */
failf(data, "Server denied you to change to the given directory");
ftpc->cwdfail = TRUE; /* don't remember this path as we failed
to enter it */
- result = CURLE_REMOTE_ACCESS_DENIED;
+ result = CURLE_REMOTE_ACCESS_DENIED;
}
}
else {
/* success */
ftpc->count2 = 0;
- if(++ftpc->cwdcount <= ftpc->dirdepth)
+ if(++ftpc->cwdcount <= ftpc->dirdepth)
/* send next CWD */
- result = Curl_pp_sendf(&ftpc->pp, "CWD %s",
- ftpc->dirs[ftpc->cwdcount - 1]);
- else
+ result = Curl_pp_sendf(&ftpc->pp, "CWD %s",
+ ftpc->dirs[ftpc->cwdcount - 1]);
+ else
result = ftp_state_mdtm(conn);
}
break;
@@ -2984,14 +2984,14 @@ static CURLcode ftp_statemach_act(struct connectdata *conn)
if((ftpcode/100 != 2) && !ftpc->count3--) {
/* failure to MKD the dir */
failf(data, "Failed to MKD dir: %03d", ftpcode);
- result = CURLE_REMOTE_ACCESS_DENIED;
+ result = CURLE_REMOTE_ACCESS_DENIED;
+ }
+ else {
+ state(conn, FTP_CWD);
+ /* send CWD */
+ result = Curl_pp_sendf(&ftpc->pp, "CWD %s",
+ ftpc->dirs[ftpc->cwdcount - 1]);
}
- else {
- state(conn, FTP_CWD);
- /* send CWD */
- result = Curl_pp_sendf(&ftpc->pp, "CWD %s",
- ftpc->dirs[ftpc->cwdcount - 1]);
- }
break;
case FTP_MDTM:
@@ -3094,7 +3094,7 @@ static CURLcode ftp_block_statemach(struct connectdata *conn)
*
*/
static CURLcode ftp_connect(struct connectdata *conn,
- bool *done) /* see description above */
+ bool *done) /* see description above */
{
CURLcode result;
struct ftp_conn *ftpc = &conn->proto.ftpc;
@@ -3115,10 +3115,10 @@ static CURLcode ftp_connect(struct connectdata *conn,
result = Curl_ssl_connect(conn, FIRSTSOCKET);
if(result)
return result;
- conn->bits.ftp_use_control_ssl = TRUE;
+ conn->bits.ftp_use_control_ssl = TRUE;
}
- Curl_pp_setup(pp); /* once per transfer */
+ Curl_pp_setup(pp); /* once per transfer */
Curl_pp_init(pp); /* init the generic pingpong data */
/* When we connect, we start in the state where we await the 220
@@ -3143,14 +3143,14 @@ static CURLcode ftp_done(struct connectdata *conn, CURLcode status,
bool premature)
{
struct Curl_easy *data = conn->data;
- struct FTP *ftp = data->req.p.ftp;
+ struct FTP *ftp = data->req.p.ftp;
struct ftp_conn *ftpc = &conn->proto.ftpc;
struct pingpong *pp = &ftpc->pp;
ssize_t nread;
int ftpcode;
CURLcode result = CURLE_OK;
- char *rawPath = NULL;
- size_t pathLen = 0;
+ char *rawPath = NULL;
+ size_t pathLen = 0;
if(!ftp)
return CURLE_OK;
@@ -3198,42 +3198,42 @@ static CURLcode ftp_done(struct connectdata *conn, CURLcode status,
}
if(!result)
- /* get the url-decoded "raw" path */
- result = Curl_urldecode(data, ftp->path, 0, &rawPath, &pathLen,
- REJECT_CTRL);
+ /* get the url-decoded "raw" path */
+ result = Curl_urldecode(data, ftp->path, 0, &rawPath, &pathLen,
+ REJECT_CTRL);
if(result) {
/* We can limp along anyway (and should try to since we may already be in
* the error path) */
ftpc->ctl_valid = FALSE; /* mark control connection as bad */
connclose(conn, "FTP: out of memory!"); /* mark for connection closure */
- free(ftpc->prevpath);
+ free(ftpc->prevpath);
ftpc->prevpath = NULL; /* no path remembering */
}
- else { /* remember working directory for connection reuse */
- if((data->set.ftp_filemethod == FTPFILE_NOCWD) && (rawPath[0] == '/'))
- free(rawPath); /* full path => no CWDs happened => keep ftpc->prevpath */
- else {
- free(ftpc->prevpath);
-
- if(!ftpc->cwdfail) {
- if(data->set.ftp_filemethod == FTPFILE_NOCWD)
- pathLen = 0; /* relative path => working directory is FTP home */
- else
- pathLen -= ftpc->file?strlen(ftpc->file):0; /* file is url-decoded */
-
- rawPath[pathLen] = '\0';
- ftpc->prevpath = rawPath;
+ else { /* remember working directory for connection reuse */
+ if((data->set.ftp_filemethod == FTPFILE_NOCWD) && (rawPath[0] == '/'))
+ free(rawPath); /* full path => no CWDs happened => keep ftpc->prevpath */
+ else {
+ free(ftpc->prevpath);
+
+ if(!ftpc->cwdfail) {
+ if(data->set.ftp_filemethod == FTPFILE_NOCWD)
+ pathLen = 0; /* relative path => working directory is FTP home */
+ else
+ pathLen -= ftpc->file?strlen(ftpc->file):0; /* file is url-decoded */
+
+ rawPath[pathLen] = '\0';
+ ftpc->prevpath = rawPath;
}
else {
- free(rawPath);
- ftpc->prevpath = NULL; /* no path */
+ free(rawPath);
+ ftpc->prevpath = NULL; /* no path */
}
}
-
- if(ftpc->prevpath)
- infof(data, "Remembering we are in dir \"%s\"\n", ftpc->prevpath);
+
+ if(ftpc->prevpath)
+ infof(data, "Remembering we are in dir \"%s\"\n", ftpc->prevpath);
}
-
+
/* free the dir tree and file parts */
freedirs(ftpc);
@@ -3274,7 +3274,7 @@ static CURLcode ftp_done(struct connectdata *conn, CURLcode status,
* data has been transferred. This happens when doing through NATs etc that
* abandon old silent connections.
*/
- timediff_t old_time = pp->response_time;
+ timediff_t old_time = pp->response_time;
pp->response_time = 60*1000; /* give it only a minute for now */
pp->response = Curl_now(); /* timeout relative now */
@@ -3302,18 +3302,18 @@ static CURLcode ftp_done(struct connectdata *conn, CURLcode status,
if(!ftpc->dont_check) {
/* 226 Transfer complete, 250 Requested file action okay, completed. */
- switch(ftpcode) {
- case 226:
- case 250:
- break;
- case 552:
- failf(data, "Exceeded storage allocation");
- result = CURLE_REMOTE_DISK_FULL;
- break;
- default:
+ switch(ftpcode) {
+ case 226:
+ case 250:
+ break;
+ case 552:
+ failf(data, "Exceeded storage allocation");
+ result = CURLE_REMOTE_DISK_FULL;
+ break;
+ default:
failf(data, "server did not report OK, got %d", ftpcode);
result = CURLE_PARTIAL_FILE;
- break;
+ break;
}
}
}
@@ -3388,11 +3388,11 @@ CURLcode ftp_sendquote(struct connectdata *conn, struct curl_slist *quote)
item = quote;
while(item) {
if(item->data) {
- ssize_t nread;
+ ssize_t nread;
char *cmd = item->data;
bool acceptfail = FALSE;
- CURLcode result;
- int ftpcode = 0;
+ CURLcode result;
+ int ftpcode = 0;
/* if a command starts with an asterisk, which a legal FTP command never
can, the command will be allowed to fail without it causing any
@@ -3404,11 +3404,11 @@ CURLcode ftp_sendquote(struct connectdata *conn, struct curl_slist *quote)
acceptfail = TRUE;
}
- result = Curl_pp_sendf(&ftpc->pp, "%s", cmd);
- if(!result) {
- pp->response = Curl_now(); /* timeout relative now */
- result = Curl_GetFTPResponse(&nread, conn, &ftpcode);
- }
+ result = Curl_pp_sendf(&ftpc->pp, "%s", cmd);
+ if(!result) {
+ pp->response = Curl_now(); /* timeout relative now */
+ result = Curl_GetFTPResponse(&nread, conn, &ftpcode);
+ }
if(result)
return result;
@@ -3456,14 +3456,14 @@ static CURLcode ftp_nb_type(struct connectdata *conn,
return ftp_state_type_resp(conn, 200, newstate);
}
- result = Curl_pp_sendf(&ftpc->pp, "TYPE %c", want);
- if(!result) {
- state(conn, newstate);
+ result = Curl_pp_sendf(&ftpc->pp, "TYPE %c", want);
+ if(!result) {
+ state(conn, newstate);
- /* keep track of our current transfer type */
- ftpc->transfertype = want;
- }
- return result;
+ /* keep track of our current transfer type */
+ ftpc->transfertype = want;
+ }
+ return result;
}
/***************************************************************************
@@ -3478,7 +3478,7 @@ static CURLcode ftp_nb_type(struct connectdata *conn,
#ifndef CURL_DISABLE_VERBOSE_STRINGS
static void
ftp_pasv_verbose(struct connectdata *conn,
- struct Curl_addrinfo *ai,
+ struct Curl_addrinfo *ai,
char *newhost, /* ascii version */
int port)
{
@@ -3508,7 +3508,7 @@ static CURLcode ftp_do_more(struct connectdata *conn, int *completep)
bool complete = FALSE;
/* the ftp struct is inited in ftp_connect() */
- struct FTP *ftp = data->req.p.ftp;
+ struct FTP *ftp = data->req.p.ftp;
/* if the second connection isn't done yet, wait for it */
if(!conn->bits.tcpconnect[SECONDARYSOCKET]) {
@@ -3536,7 +3536,7 @@ static CURLcode ftp_do_more(struct connectdata *conn, int *completep)
}
}
-#ifndef CURL_DISABLE_PROXY
+#ifndef CURL_DISABLE_PROXY
result = Curl_proxy_connect(conn, SECONDARYSOCKET);
if(result)
return result;
@@ -3547,7 +3547,7 @@ static CURLcode ftp_do_more(struct connectdata *conn, int *completep)
if(conn->bits.tunnel_proxy && conn->bits.httpproxy &&
Curl_connect_ongoing(conn))
return result;
-#endif
+#endif
if(ftpc->state) {
/* already in a state so skip the initial commands.
@@ -3558,13 +3558,13 @@ static CURLcode ftp_do_more(struct connectdata *conn, int *completep)
/* if we got an error or if we don't wait for a data connection return
immediately */
- if(result || !ftpc->wait_data_conn)
+ if(result || !ftpc->wait_data_conn)
return result;
- /* if we reach the end of the FTP state machine here, *complete will be
- TRUE but so is ftpc->wait_data_conn, which says we need to wait for the
- data connection and therefore we're not actually complete */
- *completep = 0;
+ /* if we reach the end of the FTP state machine here, *complete will be
+ TRUE but so is ftpc->wait_data_conn, which says we need to wait for the
+ data connection and therefore we're not actually complete */
+ *completep = 0;
}
if(ftp->transfer <= FTPTRANSFER_INFO) {
@@ -3598,8 +3598,8 @@ static CURLcode ftp_do_more(struct connectdata *conn, int *completep)
return result;
result = ftp_multi_statemach(conn, &complete);
- /* ftpc->wait_data_conn is always false here */
- *completep = (int)complete;
+ /* ftpc->wait_data_conn is always false here */
+ *completep = (int)complete;
}
else {
/* download */
@@ -3639,8 +3639,8 @@ static CURLcode ftp_do_more(struct connectdata *conn, int *completep)
return result;
}
- /* no data to transfer */
- Curl_setup_transfer(data, -1, -1, FALSE, -1);
+ /* no data to transfer */
+ Curl_setup_transfer(data, -1, -1, FALSE, -1);
if(!ftpc->wait_data_conn) {
/* no waiting for the data connection so this is now complete */
@@ -3673,7 +3673,7 @@ CURLcode ftp_perform(struct connectdata *conn,
if(conn->data->set.opt_no_body) {
/* requested no body means no transfer... */
- struct FTP *ftp = conn->data->req.p.ftp;
+ struct FTP *ftp = conn->data->req.p.ftp;
ftp->transfer = FTPTRANSFER_INFO;
}
@@ -3708,7 +3708,7 @@ static void wc_data_dtor(void *ptr)
static CURLcode init_wc_data(struct connectdata *conn)
{
char *last_slash;
- struct FTP *ftp = conn->data->req.p.ftp;
+ struct FTP *ftp = conn->data->req.p.ftp;
char *path = ftp->path;
struct WildcardData *wildcard = &(conn->data->wildcard);
CURLcode result = CURLE_OK;
@@ -3805,126 +3805,126 @@ static CURLcode wc_statemach(struct connectdata *conn)
struct WildcardData * const wildcard = &(conn->data->wildcard);
CURLcode result = CURLE_OK;
- for(;;) {
- switch(wildcard->state) {
- case CURLWC_INIT:
- result = init_wc_data(conn);
- if(wildcard->state == CURLWC_CLEAN)
- /* only listing! */
- return result;
- wildcard->state = result ? CURLWC_ERROR : CURLWC_MATCHING;
- return result;
-
- case CURLWC_MATCHING: {
- /* In this state is LIST response successfully parsed, so lets restore
- previous WRITEFUNCTION callback and WRITEDATA pointer */
- struct ftp_wc *ftpwc = wildcard->protdata;
- conn->data->set.fwrite_func = ftpwc->backup.write_function;
- conn->data->set.out = ftpwc->backup.file_descriptor;
- ftpwc->backup.write_function = ZERO_NULL;
- ftpwc->backup.file_descriptor = NULL;
- wildcard->state = CURLWC_DOWNLOADING;
-
- if(Curl_ftp_parselist_geterror(ftpwc->parser)) {
- /* error found in LIST parsing */
- wildcard->state = CURLWC_CLEAN;
- continue;
- }
- if(wildcard->filelist.size == 0) {
- /* no corresponding file */
- wildcard->state = CURLWC_CLEAN;
- return CURLE_REMOTE_FILE_NOT_FOUND;
- }
- continue;
+ for(;;) {
+ switch(wildcard->state) {
+ case CURLWC_INIT:
+ result = init_wc_data(conn);
+ if(wildcard->state == CURLWC_CLEAN)
+ /* only listing! */
+ return result;
+ wildcard->state = result ? CURLWC_ERROR : CURLWC_MATCHING;
+ return result;
+
+ case CURLWC_MATCHING: {
+ /* In this state is LIST response successfully parsed, so lets restore
+ previous WRITEFUNCTION callback and WRITEDATA pointer */
+ struct ftp_wc *ftpwc = wildcard->protdata;
+ conn->data->set.fwrite_func = ftpwc->backup.write_function;
+ conn->data->set.out = ftpwc->backup.file_descriptor;
+ ftpwc->backup.write_function = ZERO_NULL;
+ ftpwc->backup.file_descriptor = NULL;
+ wildcard->state = CURLWC_DOWNLOADING;
+
+ if(Curl_ftp_parselist_geterror(ftpwc->parser)) {
+ /* error found in LIST parsing */
+ wildcard->state = CURLWC_CLEAN;
+ continue;
+ }
+ if(wildcard->filelist.size == 0) {
+ /* no corresponding file */
+ wildcard->state = CURLWC_CLEAN;
+ return CURLE_REMOTE_FILE_NOT_FOUND;
+ }
+ continue;
}
- case CURLWC_DOWNLOADING: {
- /* filelist has at least one file, lets get first one */
- struct ftp_conn *ftpc = &conn->proto.ftpc;
- struct curl_fileinfo *finfo = wildcard->filelist.head->ptr;
- struct FTP *ftp = conn->data->req.p.ftp;
-
- char *tmp_path = aprintf("%s%s", wildcard->path, finfo->filename);
- if(!tmp_path)
- return CURLE_OUT_OF_MEMORY;
-
- /* switch default ftp->path and tmp_path */
- free(ftp->pathalloc);
- ftp->pathalloc = ftp->path = tmp_path;
-
- infof(conn->data, "Wildcard - START of \"%s\"\n", finfo->filename);
- if(conn->data->set.chunk_bgn) {
- long userresponse;
- Curl_set_in_callback(conn->data, true);
- userresponse = conn->data->set.chunk_bgn(
- finfo, wildcard->customptr, (int)wildcard->filelist.size);
- Curl_set_in_callback(conn->data, false);
- switch(userresponse) {
- case CURL_CHUNK_BGN_FUNC_SKIP:
- infof(conn->data, "Wildcard - \"%s\" skipped by user\n",
- finfo->filename);
- wildcard->state = CURLWC_SKIP;
- continue;
- case CURL_CHUNK_BGN_FUNC_FAIL:
- return CURLE_CHUNK_FAILED;
- }
- }
-
- if(finfo->filetype != CURLFILETYPE_FILE) {
+ case CURLWC_DOWNLOADING: {
+ /* filelist has at least one file, lets get first one */
+ struct ftp_conn *ftpc = &conn->proto.ftpc;
+ struct curl_fileinfo *finfo = wildcard->filelist.head->ptr;
+ struct FTP *ftp = conn->data->req.p.ftp;
+
+ char *tmp_path = aprintf("%s%s", wildcard->path, finfo->filename);
+ if(!tmp_path)
+ return CURLE_OUT_OF_MEMORY;
+
+ /* switch default ftp->path and tmp_path */
+ free(ftp->pathalloc);
+ ftp->pathalloc = ftp->path = tmp_path;
+
+ infof(conn->data, "Wildcard - START of \"%s\"\n", finfo->filename);
+ if(conn->data->set.chunk_bgn) {
+ long userresponse;
+ Curl_set_in_callback(conn->data, true);
+ userresponse = conn->data->set.chunk_bgn(
+ finfo, wildcard->customptr, (int)wildcard->filelist.size);
+ Curl_set_in_callback(conn->data, false);
+ switch(userresponse) {
+ case CURL_CHUNK_BGN_FUNC_SKIP:
+ infof(conn->data, "Wildcard - \"%s\" skipped by user\n",
+ finfo->filename);
+ wildcard->state = CURLWC_SKIP;
+ continue;
+ case CURL_CHUNK_BGN_FUNC_FAIL:
+ return CURLE_CHUNK_FAILED;
+ }
+ }
+
+ if(finfo->filetype != CURLFILETYPE_FILE) {
wildcard->state = CURLWC_SKIP;
- continue;
+ continue;
}
- if(finfo->flags & CURLFINFOFLAG_KNOWN_SIZE)
- ftpc->known_filesize = finfo->size;
-
- result = ftp_parse_url_path(conn);
- if(result)
- return result;
-
- /* we don't need the Curl_fileinfo of first file anymore */
- Curl_llist_remove(&wildcard->filelist, wildcard->filelist.head, NULL);
-
- if(wildcard->filelist.size == 0) { /* remains only one file to down. */
- wildcard->state = CURLWC_CLEAN;
- /* after that will be ftp_do called once again and no transfer
- will be done because of CURLWC_CLEAN state */
- return CURLE_OK;
- }
+ if(finfo->flags & CURLFINFOFLAG_KNOWN_SIZE)
+ ftpc->known_filesize = finfo->size;
+
+ result = ftp_parse_url_path(conn);
+ if(result)
+ return result;
+
+ /* we don't need the Curl_fileinfo of first file anymore */
+ Curl_llist_remove(&wildcard->filelist, wildcard->filelist.head, NULL);
+
+ if(wildcard->filelist.size == 0) { /* remains only one file to down. */
+ wildcard->state = CURLWC_CLEAN;
+ /* after that will be ftp_do called once again and no transfer
+ will be done because of CURLWC_CLEAN state */
+ return CURLE_OK;
+ }
return result;
}
- case CURLWC_SKIP: {
- if(conn->data->set.chunk_end) {
- Curl_set_in_callback(conn->data, true);
- conn->data->set.chunk_end(conn->data->wildcard.customptr);
- Curl_set_in_callback(conn->data, false);
- }
- Curl_llist_remove(&wildcard->filelist, wildcard->filelist.head, NULL);
- wildcard->state = (wildcard->filelist.size == 0) ?
- CURLWC_CLEAN : CURLWC_DOWNLOADING;
- continue;
+ case CURLWC_SKIP: {
+ if(conn->data->set.chunk_end) {
+ Curl_set_in_callback(conn->data, true);
+ conn->data->set.chunk_end(conn->data->wildcard.customptr);
+ Curl_set_in_callback(conn->data, false);
+ }
+ Curl_llist_remove(&wildcard->filelist, wildcard->filelist.head, NULL);
+ wildcard->state = (wildcard->filelist.size == 0) ?
+ CURLWC_CLEAN : CURLWC_DOWNLOADING;
+ continue;
+ }
+
+ case CURLWC_CLEAN: {
+ struct ftp_wc *ftpwc = wildcard->protdata;
+ result = CURLE_OK;
+ if(ftpwc)
+ result = Curl_ftp_parselist_geterror(ftpwc->parser);
+
+ wildcard->state = result ? CURLWC_ERROR : CURLWC_DONE;
+ return result;
}
- case CURLWC_CLEAN: {
- struct ftp_wc *ftpwc = wildcard->protdata;
- result = CURLE_OK;
- if(ftpwc)
- result = Curl_ftp_parselist_geterror(ftpwc->parser);
-
- wildcard->state = result ? CURLWC_ERROR : CURLWC_DONE;
- return result;
- }
-
- case CURLWC_DONE:
- case CURLWC_ERROR:
- case CURLWC_CLEAR:
- if(wildcard->dtor)
- wildcard->dtor(wildcard->protdata);
- return result;
- }
+ case CURLWC_DONE:
+ case CURLWC_ERROR:
+ case CURLWC_CLEAR:
+ if(wildcard->dtor)
+ wildcard->dtor(wildcard->protdata);
+ return result;
+ }
}
- /* UNREACHABLE */
+ /* UNREACHABLE */
}
/***********************************************************************
@@ -4028,12 +4028,12 @@ static CURLcode ftp_disconnect(struct connectdata *conn, bool dead_connection)
if(data->state.most_recent_ftp_entrypath == ftpc->entrypath) {
data->state.most_recent_ftp_entrypath = NULL;
}
- Curl_safefree(ftpc->entrypath);
+ Curl_safefree(ftpc->entrypath);
}
freedirs(ftpc);
- Curl_safefree(ftpc->prevpath);
- Curl_safefree(ftpc->server_os);
+ Curl_safefree(ftpc->prevpath);
+ Curl_safefree(ftpc->server_os);
Curl_pp_disconnect(pp);
Curl_sec_end(conn);
return CURLE_OK;
@@ -4051,144 +4051,144 @@ CURLcode ftp_parse_url_path(struct connectdata *conn)
{
struct Curl_easy *data = conn->data;
/* the ftp struct is already inited in ftp_connect() */
- struct FTP *ftp = data->req.p.ftp;
+ struct FTP *ftp = data->req.p.ftp;
struct ftp_conn *ftpc = &conn->proto.ftpc;
- const char *slashPos = NULL;
- const char *fileName = NULL;
- CURLcode result = CURLE_OK;
- char *rawPath = NULL; /* url-decoded "raw" path */
- size_t pathLen = 0;
+ const char *slashPos = NULL;
+ const char *fileName = NULL;
+ CURLcode result = CURLE_OK;
+ char *rawPath = NULL; /* url-decoded "raw" path */
+ size_t pathLen = 0;
ftpc->ctl_valid = FALSE;
ftpc->cwdfail = FALSE;
- /* url-decode ftp path before further evaluation */
- result = Curl_urldecode(data, ftp->path, 0, &rawPath, &pathLen, REJECT_CTRL);
- if(result)
- return result;
-
+ /* url-decode ftp path before further evaluation */
+ result = Curl_urldecode(data, ftp->path, 0, &rawPath, &pathLen, REJECT_CTRL);
+ if(result)
+ return result;
+
switch(data->set.ftp_filemethod) {
- case FTPFILE_NOCWD: /* fastest, but less standard-compliant */
-
- if((pathLen > 0) && (rawPath[pathLen - 1] != '/'))
- fileName = rawPath; /* this is a full file path */
- /*
- else: ftpc->file is not used anywhere other than for operations on
- a file. In other words, never for directory operations.
- So we can safely leave filename as NULL here and use it as a
- argument in dir/file decisions.
- */
- break;
-
- case FTPFILE_SINGLECWD:
- slashPos = strrchr(rawPath, '/');
- if(slashPos) {
- /* get path before last slash, except for / */
- size_t dirlen = slashPos - rawPath;
- if(dirlen == 0)
- dirlen++;
-
- ftpc->dirs = calloc(1, sizeof(ftpc->dirs[0]));
- if(!ftpc->dirs) {
- free(rawPath);
- return CURLE_OUT_OF_MEMORY;
- }
-
- ftpc->dirs[0] = calloc(1, dirlen + 1);
- if(!ftpc->dirs[0]) {
- free(rawPath);
- return CURLE_OUT_OF_MEMORY;
- }
-
- strncpy(ftpc->dirs[0], rawPath, dirlen);
- ftpc->dirdepth = 1; /* we consider it to be a single dir */
- fileName = slashPos + 1; /* rest is file name */
- }
- else
- fileName = rawPath; /* file name only (or empty) */
+ case FTPFILE_NOCWD: /* fastest, but less standard-compliant */
+
+ if((pathLen > 0) && (rawPath[pathLen - 1] != '/'))
+ fileName = rawPath; /* this is a full file path */
+ /*
+ else: ftpc->file is not used anywhere other than for operations on
+ a file. In other words, never for directory operations.
+ So we can safely leave filename as NULL here and use it as a
+ argument in dir/file decisions.
+ */
break;
- default: /* allow pretty much anything */
- case FTPFILE_MULTICWD: {
- /* current position: begin of next path component */
- const char *curPos = rawPath;
+ case FTPFILE_SINGLECWD:
+ slashPos = strrchr(rawPath, '/');
+ if(slashPos) {
+ /* get path before last slash, except for / */
+ size_t dirlen = slashPos - rawPath;
+ if(dirlen == 0)
+ dirlen++;
+
+ ftpc->dirs = calloc(1, sizeof(ftpc->dirs[0]));
+ if(!ftpc->dirs) {
+ free(rawPath);
+ return CURLE_OUT_OF_MEMORY;
+ }
- int dirAlloc = 0; /* number of entries allocated for the 'dirs' array */
- const char *str = rawPath;
- for(; *str != 0; ++str)
- if (*str == '/')
- ++dirAlloc;
+ ftpc->dirs[0] = calloc(1, dirlen + 1);
+ if(!ftpc->dirs[0]) {
+ free(rawPath);
+ return CURLE_OUT_OF_MEMORY;
+ }
- if(dirAlloc > 0) {
- ftpc->dirs = calloc(dirAlloc, sizeof(ftpc->dirs[0]));
- if(!ftpc->dirs) {
- free(rawPath);
- return CURLE_OUT_OF_MEMORY;
- }
+ strncpy(ftpc->dirs[0], rawPath, dirlen);
+ ftpc->dirdepth = 1; /* we consider it to be a single dir */
+ fileName = slashPos + 1; /* rest is file name */
+ }
+ else
+ fileName = rawPath; /* file name only (or empty) */
+ break;
+
+ default: /* allow pretty much anything */
+ case FTPFILE_MULTICWD: {
+ /* current position: begin of next path component */
+ const char *curPos = rawPath;
+
+ int dirAlloc = 0; /* number of entries allocated for the 'dirs' array */
+ const char *str = rawPath;
+ for(; *str != 0; ++str)
+ if (*str == '/')
+ ++dirAlloc;
+
+ if(dirAlloc > 0) {
+ ftpc->dirs = calloc(dirAlloc, sizeof(ftpc->dirs[0]));
+ if(!ftpc->dirs) {
+ free(rawPath);
+ return CURLE_OUT_OF_MEMORY;
+ }
- /* parse the URL path into separate path components */
- while((slashPos = strchr(curPos, '/')) != NULL) {
- size_t compLen = slashPos - curPos;
+ /* parse the URL path into separate path components */
+ while((slashPos = strchr(curPos, '/')) != NULL) {
+ size_t compLen = slashPos - curPos;
- /* path starts with a slash: add that as a directory */
- if((compLen == 0) && (ftpc->dirdepth == 0))
- ++compLen;
+ /* path starts with a slash: add that as a directory */
+ if((compLen == 0) && (ftpc->dirdepth == 0))
+ ++compLen;
/* we skip empty path components, like "x//y" since the FTP command
CWD requires a parameter and a non-existent parameter a) doesn't
work on many servers and b) has no effect on the others. */
- if(compLen > 0) {
- char *comp = calloc(1, compLen + 1);
- if(!comp) {
- free(rawPath);
+ if(compLen > 0) {
+ char *comp = calloc(1, compLen + 1);
+ if(!comp) {
+ free(rawPath);
return CURLE_OUT_OF_MEMORY;
}
- strncpy(comp, curPos, compLen);
- ftpc->dirs[ftpc->dirdepth++] = comp;
+ strncpy(comp, curPos, compLen);
+ ftpc->dirs[ftpc->dirdepth++] = comp;
}
- curPos = slashPos + 1;
+ curPos = slashPos + 1;
}
}
- DEBUGASSERT(ftpc->dirdepth <= dirAlloc);
- fileName = curPos; /* the rest is the file name (or empty) */
+ DEBUGASSERT(ftpc->dirdepth <= dirAlloc);
+ fileName = curPos; /* the rest is the file name (or empty) */
}
break;
} /* switch */
- if(fileName && *fileName)
- ftpc->file = strdup(fileName);
+ if(fileName && *fileName)
+ ftpc->file = strdup(fileName);
else
- ftpc->file = NULL; /* instead of point to a zero byte,
- we make it a NULL pointer */
+ ftpc->file = NULL; /* instead of point to a zero byte,
+ we make it a NULL pointer */
if(data->set.upload && !ftpc->file && (ftp->transfer == FTPTRANSFER_BODY)) {
/* We need a file name when uploading. Return error! */
failf(data, "Uploading to a URL without a file name!");
- free(rawPath);
+ free(rawPath);
return CURLE_URL_MALFORMAT;
}
ftpc->cwddone = FALSE; /* default to not done */
- if((data->set.ftp_filemethod == FTPFILE_NOCWD) && (rawPath[0] == '/'))
- ftpc->cwddone = TRUE; /* skip CWD for absolute paths */
- else { /* newly created FTP connections are already in entry path */
- const char *oldPath = conn->bits.reuse ? ftpc->prevpath : "";
- if(oldPath) {
- size_t n = pathLen;
- if(data->set.ftp_filemethod == FTPFILE_NOCWD)
- n = 0; /* CWD to entry for relative paths */
- else
- n -= ftpc->file?strlen(ftpc->file):0;
-
- if((strlen(oldPath) == n) && !strncmp(rawPath, oldPath, n)) {
- infof(data, "Request has same path as previous transfer\n");
- ftpc->cwddone = TRUE;
- }
+ if((data->set.ftp_filemethod == FTPFILE_NOCWD) && (rawPath[0] == '/'))
+ ftpc->cwddone = TRUE; /* skip CWD for absolute paths */
+ else { /* newly created FTP connections are already in entry path */
+ const char *oldPath = conn->bits.reuse ? ftpc->prevpath : "";
+ if(oldPath) {
+ size_t n = pathLen;
+ if(data->set.ftp_filemethod == FTPFILE_NOCWD)
+ n = 0; /* CWD to entry for relative paths */
+ else
+ n -= ftpc->file?strlen(ftpc->file):0;
+
+ if((strlen(oldPath) == n) && !strncmp(rawPath, oldPath, n)) {
+ infof(data, "Request has same path as previous transfer\n");
+ ftpc->cwddone = TRUE;
+ }
}
}
- free(rawPath);
+ free(rawPath);
return CURLE_OK;
}
@@ -4196,7 +4196,7 @@ CURLcode ftp_parse_url_path(struct connectdata *conn)
static CURLcode ftp_dophase_done(struct connectdata *conn,
bool connected)
{
- struct FTP *ftp = conn->data->req.p.ftp;
+ struct FTP *ftp = conn->data->req.p.ftp;
struct ftp_conn *ftpc = &conn->proto.ftpc;
if(connected) {
@@ -4293,7 +4293,7 @@ static CURLcode ftp_setup_connection(struct connectdata *conn)
char *type;
struct FTP *ftp;
- conn->data->req.p.ftp = ftp = calloc(sizeof(struct FTP), 1);
+ conn->data->req.p.ftp = ftp = calloc(sizeof(struct FTP), 1);
if(NULL == ftp)
return CURLE_OUT_OF_MEMORY;
diff --git a/contrib/libs/curl/lib/ftp.h b/contrib/libs/curl/lib/ftp.h
index 4507c6e896..3ca1458ed8 100644
--- a/contrib/libs/curl/lib/ftp.h
+++ b/contrib/libs/curl/lib/ftp.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -118,7 +118,7 @@ struct ftp_conn {
char *entrypath; /* the PWD reply when we logged on */
char **dirs; /* realloc()ed array for path components */
int dirdepth; /* number of entries used in the 'dirs' array */
- char *file; /* url-decoded file name (or path) */
+ char *file; /* url-decoded file name (or path) */
bool dont_check; /* Set to TRUE to prevent the final (post-transfer)
file size and 226/250 status check. It should still
read the line, just ignore the result. */
@@ -131,7 +131,7 @@ struct ftp_conn {
bool cwdfail; /* set TRUE if a CWD command fails, as then we must prevent
caching the current directory */
bool wait_data_conn; /* this is set TRUE if data connection is waited */
- char *prevpath; /* url-decoded conn->path from the previous transfer */
+ char *prevpath; /* url-decoded conn->path from the previous transfer */
char transfertype; /* set by ftp_transfertype for use by Curl_client_write()a
and others (A/I or zero) */
int count1; /* general purpose counter for the state machine */
diff --git a/contrib/libs/curl/lib/ftplistparser.c b/contrib/libs/curl/lib/ftplistparser.c
index a3a135f2ff..85b8a78d4f 100644
--- a/contrib/libs/curl/lib/ftplistparser.c
+++ b/contrib/libs/curl/lib/ftplistparser.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -274,7 +274,7 @@ static CURLcode ftp_pl_insert_finfo(struct connectdata *conn,
curl_fnmatch_callback compare;
struct WildcardData *wc = &conn->data->wildcard;
struct ftp_wc *ftpwc = wc->protdata;
- struct Curl_llist *llist = &wc->filelist;
+ struct Curl_llist *llist = &wc->filelist;
struct ftp_parselist_data *parser = ftpwc->parser;
bool add = TRUE;
struct curl_fileinfo *finfo = &infop->info;
@@ -418,8 +418,8 @@ size_t Curl_ftp_parselist(char *buffer, size_t size, size_t nmemb,
finfo->b_data[parser->item_length - 1] = 0;
if(strncmp("total ", finfo->b_data, 6) == 0) {
char *endptr = finfo->b_data + 6;
- /* here we can deal with directory size, pass the leading
- whitespace and then the digits */
+ /* here we can deal with directory size, pass the leading
+ whitespace and then the digits */
while(ISSPACE(*endptr))
endptr++;
while(ISDIGIT(*endptr))
diff --git a/contrib/libs/curl/lib/ftplistparser.h b/contrib/libs/curl/lib/ftplistparser.h
index 4ff9edfe98..e4cd8201d9 100644
--- a/contrib/libs/curl/lib/ftplistparser.h
+++ b/contrib/libs/curl/lib/ftplistparser.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/getenv.c b/contrib/libs/curl/lib/getenv.c
index 0c84959bc8..92c53505c6 100644
--- a/contrib/libs/curl/lib/getenv.c
+++ b/contrib/libs/curl/lib/getenv.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -27,44 +27,44 @@
#include "memdebug.h"
-static char *GetEnv(const char *variable)
+static char *GetEnv(const char *variable)
{
#if defined(_WIN32_WCE) || defined(CURL_WINDOWS_APP)
(void)variable;
return NULL;
-#elif defined(WIN32)
- /* This uses Windows API instead of C runtime getenv() to get the environment
- variable since some changes aren't always visible to the latter. #4774 */
- char *buf = NULL;
- char *tmp;
- DWORD bufsize;
- DWORD rc = 1;
- const DWORD max = 32768; /* max env var size from MSCRT source */
-
- for(;;) {
- tmp = realloc(buf, rc);
- if(!tmp) {
- free(buf);
- return NULL;
- }
-
- buf = tmp;
- bufsize = rc;
-
- /* It's possible for rc to be 0 if the variable was found but empty.
- Since getenv doesn't make that distinction we ignore it as well. */
- rc = GetEnvironmentVariableA(variable, buf, bufsize);
- if(!rc || rc == bufsize || rc > max) {
- free(buf);
- return NULL;
- }
-
- /* if rc < bufsize then rc is bytes written not including null */
- if(rc < bufsize)
- return buf;
-
- /* else rc is bytes needed, try again */
- }
+#elif defined(WIN32)
+ /* This uses Windows API instead of C runtime getenv() to get the environment
+ variable since some changes aren't always visible to the latter. #4774 */
+ char *buf = NULL;
+ char *tmp;
+ DWORD bufsize;
+ DWORD rc = 1;
+ const DWORD max = 32768; /* max env var size from MSCRT source */
+
+ for(;;) {
+ tmp = realloc(buf, rc);
+ if(!tmp) {
+ free(buf);
+ return NULL;
+ }
+
+ buf = tmp;
+ bufsize = rc;
+
+ /* It's possible for rc to be 0 if the variable was found but empty.
+ Since getenv doesn't make that distinction we ignore it as well. */
+ rc = GetEnvironmentVariableA(variable, buf, bufsize);
+ if(!rc || rc == bufsize || rc > max) {
+ free(buf);
+ return NULL;
+ }
+
+ /* if rc < bufsize then rc is bytes written not including null */
+ if(rc < bufsize)
+ return buf;
+
+ /* else rc is bytes needed, try again */
+ }
#else
char *env = getenv(variable);
return (env && env[0])?strdup(env):NULL;
diff --git a/contrib/libs/curl/lib/getinfo.c b/contrib/libs/curl/lib/getinfo.c
index a4bcd99e1d..fd8f4e8430 100644
--- a/contrib/libs/curl/lib/getinfo.c
+++ b/contrib/libs/curl/lib/getinfo.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -78,7 +78,7 @@ CURLcode Curl_initinfo(struct Curl_easy *data)
info->conn_local_ip[0] = '\0';
info->conn_primary_port = 0;
info->conn_local_port = 0;
- info->retry_after = 0;
+ info->retry_after = 0;
info->conn_scheme = 0;
info->conn_protocol = 0;
@@ -96,34 +96,34 @@ static CURLcode getinfo_char(struct Curl_easy *data, CURLINFO info,
case CURLINFO_EFFECTIVE_URL:
*param_charp = data->change.url?data->change.url:(char *)"";
break;
- case CURLINFO_EFFECTIVE_METHOD: {
- const char *m = data->set.str[STRING_CUSTOMREQUEST];
- if(!m) {
- if(data->set.opt_no_body)
- m = "HEAD";
- else {
- switch(data->state.httpreq) {
- case HTTPREQ_POST:
- case HTTPREQ_POST_FORM:
- case HTTPREQ_POST_MIME:
- m = "POST";
- break;
- case HTTPREQ_PUT:
- m = "PUT";
- break;
- default: /* this should never happen */
- case HTTPREQ_GET:
- m = "GET";
- break;
- case HTTPREQ_HEAD:
- m = "HEAD";
- break;
- }
- }
- }
- *param_charp = m;
- }
- break;
+ case CURLINFO_EFFECTIVE_METHOD: {
+ const char *m = data->set.str[STRING_CUSTOMREQUEST];
+ if(!m) {
+ if(data->set.opt_no_body)
+ m = "HEAD";
+ else {
+ switch(data->state.httpreq) {
+ case HTTPREQ_POST:
+ case HTTPREQ_POST_FORM:
+ case HTTPREQ_POST_MIME:
+ m = "POST";
+ break;
+ case HTTPREQ_PUT:
+ m = "PUT";
+ break;
+ default: /* this should never happen */
+ case HTTPREQ_GET:
+ m = "GET";
+ break;
+ case HTTPREQ_HEAD:
+ m = "HEAD";
+ break;
+ }
+ }
+ }
+ *param_charp = m;
+ }
+ break;
case CURLINFO_CONTENT_TYPE:
*param_charp = data->info.contenttype;
break;
@@ -176,33 +176,33 @@ static CURLcode getinfo_long(struct Curl_easy *data, CURLINFO info,
long *to_long;
} lptr;
-#ifdef DEBUGBUILD
- char *timestr = getenv("CURL_TIME");
- if(timestr) {
- unsigned long val = strtol(timestr, NULL, 10);
- switch(info) {
- case CURLINFO_LOCAL_PORT:
- *param_longp = (long)val;
- return CURLE_OK;
- default:
- break;
- }
- }
- /* use another variable for this to allow different values */
- timestr = getenv("CURL_DEBUG_SIZE");
- if(timestr) {
- unsigned long val = strtol(timestr, NULL, 10);
- switch(info) {
- case CURLINFO_HEADER_SIZE:
- case CURLINFO_REQUEST_SIZE:
- *param_longp = (long)val;
- return CURLE_OK;
- default:
- break;
- }
- }
-#endif
-
+#ifdef DEBUGBUILD
+ char *timestr = getenv("CURL_TIME");
+ if(timestr) {
+ unsigned long val = strtol(timestr, NULL, 10);
+ switch(info) {
+ case CURLINFO_LOCAL_PORT:
+ *param_longp = (long)val;
+ return CURLE_OK;
+ default:
+ break;
+ }
+ }
+ /* use another variable for this to allow different values */
+ timestr = getenv("CURL_DEBUG_SIZE");
+ if(timestr) {
+ unsigned long val = strtol(timestr, NULL, 10);
+ switch(info) {
+ case CURLINFO_HEADER_SIZE:
+ case CURLINFO_REQUEST_SIZE:
+ *param_longp = (long)val;
+ return CURLE_OK;
+ default:
+ break;
+ }
+ }
+#endif
+
switch(info) {
case CURLINFO_RESPONSE_CODE:
*param_longp = data->info.httpcode;
@@ -227,11 +227,11 @@ static CURLcode getinfo_long(struct Curl_easy *data, CURLINFO info,
case CURLINFO_SSL_VERIFYRESULT:
*param_longp = data->set.ssl.certverifyresult;
break;
-#ifndef CURL_DISABLE_PROXY
+#ifndef CURL_DISABLE_PROXY
case CURLINFO_PROXY_SSL_VERIFYRESULT:
*param_longp = data->set.proxy_ssl.certverifyresult;
break;
-#endif
+#endif
case CURLINFO_REDIRECT_COUNT:
*param_longp = data->set.followlocation;
break;
@@ -269,15 +269,15 @@ static CURLcode getinfo_long(struct Curl_easy *data, CURLINFO info,
/* Return the local port of the most recent (primary) connection */
*param_longp = data->info.conn_local_port;
break;
- case CURLINFO_PROXY_ERROR:
- *param_longp = (long)data->info.pxcode;
- break;
+ case CURLINFO_PROXY_ERROR:
+ *param_longp = (long)data->info.pxcode;
+ break;
case CURLINFO_CONDITION_UNMET:
- if(data->info.httpcode == 304)
- *param_longp = 1L;
- else
- /* return if the condition prevented the document to get transferred */
- *param_longp = data->info.timecond ? 1L : 0L;
+ if(data->info.httpcode == 304)
+ *param_longp = 1L;
+ else
+ /* return if the condition prevented the document to get transferred */
+ *param_longp = data->info.timecond ? 1L : 0L;
break;
case CURLINFO_RTSP_CLIENT_CSEQ:
*param_longp = data->state.rtsp_next_client_CSeq;
@@ -322,27 +322,27 @@ static CURLcode getinfo_long(struct Curl_easy *data, CURLINFO info,
static CURLcode getinfo_offt(struct Curl_easy *data, CURLINFO info,
curl_off_t *param_offt)
{
-#ifdef DEBUGBUILD
- char *timestr = getenv("CURL_TIME");
- if(timestr) {
- unsigned long val = strtol(timestr, NULL, 10);
- switch(info) {
- case CURLINFO_TOTAL_TIME_T:
- case CURLINFO_NAMELOOKUP_TIME_T:
- case CURLINFO_CONNECT_TIME_T:
- case CURLINFO_APPCONNECT_TIME_T:
- case CURLINFO_PRETRANSFER_TIME_T:
- case CURLINFO_STARTTRANSFER_TIME_T:
- case CURLINFO_REDIRECT_TIME_T:
- case CURLINFO_SPEED_DOWNLOAD_T:
- case CURLINFO_SPEED_UPLOAD_T:
- *param_offt = (curl_off_t)val;
- return CURLE_OK;
- default:
- break;
- }
- }
-#endif
+#ifdef DEBUGBUILD
+ char *timestr = getenv("CURL_TIME");
+ if(timestr) {
+ unsigned long val = strtol(timestr, NULL, 10);
+ switch(info) {
+ case CURLINFO_TOTAL_TIME_T:
+ case CURLINFO_NAMELOOKUP_TIME_T:
+ case CURLINFO_CONNECT_TIME_T:
+ case CURLINFO_APPCONNECT_TIME_T:
+ case CURLINFO_PRETRANSFER_TIME_T:
+ case CURLINFO_STARTTRANSFER_TIME_T:
+ case CURLINFO_REDIRECT_TIME_T:
+ case CURLINFO_SPEED_DOWNLOAD_T:
+ case CURLINFO_SPEED_UPLOAD_T:
+ *param_offt = (curl_off_t)val;
+ return CURLE_OK;
+ default:
+ break;
+ }
+ }
+#endif
switch(info) {
case CURLINFO_FILETIME_T:
*param_offt = (curl_off_t)data->info.filetime;
@@ -354,7 +354,7 @@ static CURLcode getinfo_offt(struct Curl_easy *data, CURLINFO info,
*param_offt = data->progress.downloaded;
break;
case CURLINFO_SPEED_DOWNLOAD_T:
- *param_offt = data->progress.dlspeed;
+ *param_offt = data->progress.dlspeed;
break;
case CURLINFO_SPEED_UPLOAD_T:
*param_offt = data->progress.ulspeed;
@@ -367,7 +367,7 @@ static CURLcode getinfo_offt(struct Curl_easy *data, CURLINFO info,
*param_offt = (data->progress.flags & PGRS_UL_SIZE_KNOWN)?
data->progress.size_ul:-1;
break;
- case CURLINFO_TOTAL_TIME_T:
+ case CURLINFO_TOTAL_TIME_T:
*param_offt = data->progress.timespent;
break;
case CURLINFO_NAMELOOKUP_TIME_T:
@@ -401,27 +401,27 @@ static CURLcode getinfo_offt(struct Curl_easy *data, CURLINFO info,
static CURLcode getinfo_double(struct Curl_easy *data, CURLINFO info,
double *param_doublep)
{
-#ifdef DEBUGBUILD
- char *timestr = getenv("CURL_TIME");
- if(timestr) {
- unsigned long val = strtol(timestr, NULL, 10);
- switch(info) {
- case CURLINFO_TOTAL_TIME:
- case CURLINFO_NAMELOOKUP_TIME:
- case CURLINFO_CONNECT_TIME:
- case CURLINFO_APPCONNECT_TIME:
- case CURLINFO_PRETRANSFER_TIME:
- case CURLINFO_STARTTRANSFER_TIME:
- case CURLINFO_REDIRECT_TIME:
- case CURLINFO_SPEED_DOWNLOAD:
- case CURLINFO_SPEED_UPLOAD:
- *param_doublep = (double)val;
- return CURLE_OK;
- default:
- break;
- }
- }
-#endif
+#ifdef DEBUGBUILD
+ char *timestr = getenv("CURL_TIME");
+ if(timestr) {
+ unsigned long val = strtol(timestr, NULL, 10);
+ switch(info) {
+ case CURLINFO_TOTAL_TIME:
+ case CURLINFO_NAMELOOKUP_TIME:
+ case CURLINFO_CONNECT_TIME:
+ case CURLINFO_APPCONNECT_TIME:
+ case CURLINFO_PRETRANSFER_TIME:
+ case CURLINFO_STARTTRANSFER_TIME:
+ case CURLINFO_REDIRECT_TIME:
+ case CURLINFO_SPEED_DOWNLOAD:
+ case CURLINFO_SPEED_UPLOAD:
+ *param_doublep = (double)val;
+ return CURLE_OK;
+ default:
+ break;
+ }
+ }
+#endif
switch(info) {
case CURLINFO_TOTAL_TIME:
*param_doublep = DOUBLE_SECS(data->progress.timespent);
@@ -442,13 +442,13 @@ static CURLcode getinfo_double(struct Curl_easy *data, CURLINFO info,
*param_doublep = DOUBLE_SECS(data->progress.t_starttransfer);
break;
case CURLINFO_SIZE_UPLOAD:
- *param_doublep = (double)data->progress.uploaded;
+ *param_doublep = (double)data->progress.uploaded;
break;
case CURLINFO_SIZE_DOWNLOAD:
*param_doublep = (double)data->progress.downloaded;
break;
case CURLINFO_SPEED_DOWNLOAD:
- *param_doublep = (double)data->progress.dlspeed;
+ *param_doublep = (double)data->progress.dlspeed;
break;
case CURLINFO_SPEED_UPLOAD:
*param_doublep = (double)data->progress.ulspeed;
diff --git a/contrib/libs/curl/lib/getinfo.h b/contrib/libs/curl/lib/getinfo.h
index 84c002eedf..f35d1b4b34 100644
--- a/contrib/libs/curl/lib/getinfo.h
+++ b/contrib/libs/curl/lib/getinfo.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/gopher.c b/contrib/libs/curl/lib/gopher.c
index 93b34b5645..b101c0ab68 100644
--- a/contrib/libs/curl/lib/gopher.c
+++ b/contrib/libs/curl/lib/gopher.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -28,7 +28,7 @@
#include <curl/curl.h>
#include "transfer.h"
#include "sendf.h"
-#include "connect.h"
+#include "connect.h"
#include "progress.h"
#include "gopher.h"
#include "select.h"
@@ -71,7 +71,7 @@ const struct Curl_handler Curl_handler_gopher = {
ZERO_NULL, /* connection_check */
PORT_GOPHER, /* defport */
CURLPROTO_GOPHER, /* protocol */
- CURLPROTO_GOPHER, /* family */
+ CURLPROTO_GOPHER, /* family */
PROTOPT_NONE /* flags */
};
@@ -85,10 +85,10 @@ static CURLcode gopher_do(struct connectdata *conn, bool *done)
char *query = data->state.up.query;
char *sel = NULL;
char *sel_org = NULL;
- timediff_t timeout_ms;
+ timediff_t timeout_ms;
ssize_t amount, k;
size_t len;
- int what;
+ int what;
*done = TRUE; /* unconditionally */
@@ -117,7 +117,7 @@ static CURLcode gopher_do(struct connectdata *conn, bool *done)
newp += 2;
/* ... and finally unescape */
- result = Curl_urldecode(data, newp, 0, &sel, &len, REJECT_ZERO);
+ result = Curl_urldecode(data, newp, 0, &sel, &len, REJECT_ZERO);
free(gopherpath);
if(result)
return result;
@@ -141,35 +141,35 @@ static CURLcode gopher_do(struct connectdata *conn, bool *done)
else
break;
- timeout_ms = Curl_timeleft(conn->data, NULL, FALSE);
- if(timeout_ms < 0) {
- result = CURLE_OPERATION_TIMEDOUT;
- break;
- }
- if(!timeout_ms)
- timeout_ms = TIMEDIFF_T_MAX;
-
+ timeout_ms = Curl_timeleft(conn->data, NULL, FALSE);
+ if(timeout_ms < 0) {
+ result = CURLE_OPERATION_TIMEDOUT;
+ break;
+ }
+ if(!timeout_ms)
+ timeout_ms = TIMEDIFF_T_MAX;
+
/* Don't busyloop. The entire loop thing is a work-around as it causes a
BLOCKING behavior which is a NO-NO. This function should rather be
split up in a do and a doing piece where the pieces that aren't
possible to send now will be sent in the doing function repeatedly
until the entire request is sent.
*/
- what = SOCKET_WRITABLE(sockfd, timeout_ms);
- if(what < 0) {
+ what = SOCKET_WRITABLE(sockfd, timeout_ms);
+ if(what < 0) {
result = CURLE_SEND_ERROR;
break;
}
- else if(!what) {
- result = CURLE_OPERATION_TIMEDOUT;
- break;
- }
+ else if(!what) {
+ result = CURLE_OPERATION_TIMEDOUT;
+ break;
+ }
}
free(sel_org);
if(!result)
- result = Curl_write(conn, sockfd, "\r\n", 2, &amount);
+ result = Curl_write(conn, sockfd, "\r\n", 2, &amount);
if(result) {
failf(data, "Failed sending Gopher request");
return result;
diff --git a/contrib/libs/curl/lib/gopher.h b/contrib/libs/curl/lib/gopher.h
index c3dd146168..b35fa45096 100644
--- a/contrib/libs/curl/lib/gopher.h
+++ b/contrib/libs/curl/lib/gopher.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/hash.c b/contrib/libs/curl/lib/hash.c
index 4840b3d81a..051c176269 100644
--- a/contrib/libs/curl/lib/hash.c
+++ b/contrib/libs/curl/lib/hash.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -34,8 +34,8 @@
static void
hash_element_dtor(void *user, void *element)
{
- struct Curl_hash *h = (struct Curl_hash *) user;
- struct Curl_hash_element *e = (struct Curl_hash_element *) element;
+ struct Curl_hash *h = (struct Curl_hash *) user;
+ struct Curl_hash_element *e = (struct Curl_hash_element *) element;
if(e->ptr) {
h->dtor(e->ptr);
@@ -54,11 +54,11 @@ hash_element_dtor(void *user, void *element)
* @unittest: 1603
*/
int
-Curl_hash_init(struct Curl_hash *h,
+Curl_hash_init(struct Curl_hash *h,
int slots,
hash_function hfunc,
comp_function comparator,
- Curl_hash_dtor dtor)
+ Curl_hash_dtor dtor)
{
if(!slots || !hfunc || !comparator ||!dtor) {
return 1; /* failure */
@@ -70,22 +70,22 @@ Curl_hash_init(struct Curl_hash *h,
h->size = 0;
h->slots = slots;
- h->table = malloc(slots * sizeof(struct Curl_llist));
+ h->table = malloc(slots * sizeof(struct Curl_llist));
if(h->table) {
int i;
for(i = 0; i < slots; ++i)
- Curl_llist_init(&h->table[i], (Curl_llist_dtor) hash_element_dtor);
+ Curl_llist_init(&h->table[i], (Curl_llist_dtor) hash_element_dtor);
return 0; /* fine */
}
h->slots = 0;
return 1; /* failure */
}
-static struct Curl_hash_element *
+static struct Curl_hash_element *
mk_hash_element(const void *key, size_t key_len, const void *p)
{
/* allocate the struct plus memory after it to store the key */
- struct Curl_hash_element *he = malloc(sizeof(struct Curl_hash_element) +
+ struct Curl_hash_element *he = malloc(sizeof(struct Curl_hash_element) +
key_len);
if(he) {
/* copy the key */
@@ -106,14 +106,14 @@ mk_hash_element(const void *key, size_t key_len, const void *p)
* @unittest: 1603
*/
void *
-Curl_hash_add(struct Curl_hash *h, void *key, size_t key_len, void *p)
+Curl_hash_add(struct Curl_hash *h, void *key, size_t key_len, void *p)
{
- struct Curl_hash_element *he;
- struct Curl_llist_element *le;
- struct Curl_llist *l = FETCH_LIST(h, key, key_len);
+ struct Curl_hash_element *he;
+ struct Curl_llist_element *le;
+ struct Curl_llist *l = FETCH_LIST(h, key, key_len);
for(le = l->head; le; le = le->next) {
- he = (struct Curl_hash_element *) le->ptr;
+ he = (struct Curl_hash_element *) le->ptr;
if(h->comp_func(he->key, he->key_len, key, key_len)) {
Curl_llist_remove(l, le, (void *)h);
--h->size;
@@ -136,13 +136,13 @@ Curl_hash_add(struct Curl_hash *h, void *key, size_t key_len, void *p)
*
* @unittest: 1603
*/
-int Curl_hash_delete(struct Curl_hash *h, void *key, size_t key_len)
+int Curl_hash_delete(struct Curl_hash *h, void *key, size_t key_len)
{
- struct Curl_llist_element *le;
- struct Curl_llist *l = FETCH_LIST(h, key, key_len);
+ struct Curl_llist_element *le;
+ struct Curl_llist *l = FETCH_LIST(h, key, key_len);
for(le = l->head; le; le = le->next) {
- struct Curl_hash_element *he = le->ptr;
+ struct Curl_hash_element *he = le->ptr;
if(h->comp_func(he->key, he->key_len, key, key_len)) {
Curl_llist_remove(l, le, (void *) h);
--h->size;
@@ -157,15 +157,15 @@ int Curl_hash_delete(struct Curl_hash *h, void *key, size_t key_len)
* @unittest: 1603
*/
void *
-Curl_hash_pick(struct Curl_hash *h, void *key, size_t key_len)
+Curl_hash_pick(struct Curl_hash *h, void *key, size_t key_len)
{
- struct Curl_llist_element *le;
- struct Curl_llist *l;
+ struct Curl_llist_element *le;
+ struct Curl_llist *l;
if(h) {
l = FETCH_LIST(h, key, key_len);
for(le = l->head; le; le = le->next) {
- struct Curl_hash_element *he = le->ptr;
+ struct Curl_hash_element *he = le->ptr;
if(h->comp_func(he->key, he->key_len, key, key_len)) {
return he->ptr;
}
@@ -177,17 +177,17 @@ Curl_hash_pick(struct Curl_hash *h, void *key, size_t key_len)
#if defined(DEBUGBUILD) && defined(AGGRESIVE_TEST)
void
-Curl_hash_apply(Curl_hash *h, void *user,
+Curl_hash_apply(Curl_hash *h, void *user,
void (*cb)(void *user, void *ptr))
{
- struct Curl_llist_element *le;
+ struct Curl_llist_element *le;
int i;
for(i = 0; i < h->slots; ++i) {
for(le = (h->table[i])->head;
le;
le = le->next) {
- Curl_hash_element *el = le->ptr;
+ Curl_hash_element *el = le->ptr;
cb(user, el->ptr);
}
}
@@ -202,7 +202,7 @@ Curl_hash_apply(Curl_hash *h, void *user,
* @unittest: 1603
*/
void
-Curl_hash_destroy(struct Curl_hash *h)
+Curl_hash_destroy(struct Curl_hash *h)
{
int i;
@@ -220,19 +220,19 @@ Curl_hash_destroy(struct Curl_hash *h)
* @unittest: 1602
*/
void
-Curl_hash_clean(struct Curl_hash *h)
+Curl_hash_clean(struct Curl_hash *h)
{
Curl_hash_clean_with_criterium(h, NULL, NULL);
}
/* Cleans all entries that pass the comp function criteria. */
void
-Curl_hash_clean_with_criterium(struct Curl_hash *h, void *user,
+Curl_hash_clean_with_criterium(struct Curl_hash *h, void *user,
int (*comp)(void *, void *))
{
- struct Curl_llist_element *le;
- struct Curl_llist_element *lnext;
- struct Curl_llist *list;
+ struct Curl_llist_element *le;
+ struct Curl_llist_element *lnext;
+ struct Curl_llist *list;
int i;
if(!h)
@@ -242,7 +242,7 @@ Curl_hash_clean_with_criterium(struct Curl_hash *h, void *user,
list = &h->table[i];
le = list->head; /* get first list entry */
while(le) {
- struct Curl_hash_element *he = le->ptr;
+ struct Curl_hash_element *he = le->ptr;
lnext = le->next;
/* ask the callback function if we shall remove this entry or not */
if(comp == NULL || comp(user, he->ptr)) {
@@ -277,18 +277,18 @@ size_t Curl_str_key_compare(void *k1, size_t key1_len,
return 0;
}
-void Curl_hash_start_iterate(struct Curl_hash *hash,
- struct Curl_hash_iterator *iter)
+void Curl_hash_start_iterate(struct Curl_hash *hash,
+ struct Curl_hash_iterator *iter)
{
iter->hash = hash;
iter->slot_index = 0;
iter->current_element = NULL;
}
-struct Curl_hash_element *
-Curl_hash_next_element(struct Curl_hash_iterator *iter)
+struct Curl_hash_element *
+Curl_hash_next_element(struct Curl_hash_iterator *iter)
{
- struct Curl_hash *h = iter->hash;
+ struct Curl_hash *h = iter->hash;
/* Get the next element in the current list, if any */
if(iter->current_element)
@@ -307,7 +307,7 @@ Curl_hash_next_element(struct Curl_hash_iterator *iter)
}
if(iter->current_element) {
- struct Curl_hash_element *he = iter->current_element->ptr;
+ struct Curl_hash_element *he = iter->current_element->ptr;
return he;
}
iter->current_element = NULL;
@@ -315,11 +315,11 @@ Curl_hash_next_element(struct Curl_hash_iterator *iter)
}
#if 0 /* useful function for debugging hashes and their contents */
-void Curl_hash_print(struct Curl_hash *h,
+void Curl_hash_print(struct Curl_hash *h,
void (*func)(void *))
{
- struct Curl_hash_iterator iter;
- struct Curl_hash_element *he;
+ struct Curl_hash_iterator iter;
+ struct Curl_hash_element *he;
int last_index = -1;
if(!h)
diff --git a/contrib/libs/curl/lib/hash.h b/contrib/libs/curl/lib/hash.h
index 1660dd46bb..b7f828e071 100644
--- a/contrib/libs/curl/lib/hash.h
+++ b/contrib/libs/curl/lib/hash.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -41,59 +41,59 @@ typedef size_t (*comp_function) (void *key1,
void *key2,
size_t key2_len);
-typedef void (*Curl_hash_dtor)(void *);
+typedef void (*Curl_hash_dtor)(void *);
-struct Curl_hash {
- struct Curl_llist *table;
+struct Curl_hash {
+ struct Curl_llist *table;
/* Hash function to be used for this hash table */
hash_function hash_func;
/* Comparator function to compare keys */
comp_function comp_func;
- Curl_hash_dtor dtor;
+ Curl_hash_dtor dtor;
int slots;
size_t size;
};
-struct Curl_hash_element {
- struct Curl_llist_element list;
+struct Curl_hash_element {
+ struct Curl_llist_element list;
void *ptr;
size_t key_len;
char key[1]; /* allocated memory following the struct */
};
-struct Curl_hash_iterator {
- struct Curl_hash *hash;
+struct Curl_hash_iterator {
+ struct Curl_hash *hash;
int slot_index;
- struct Curl_llist_element *current_element;
+ struct Curl_llist_element *current_element;
};
-int Curl_hash_init(struct Curl_hash *h,
+int Curl_hash_init(struct Curl_hash *h,
int slots,
hash_function hfunc,
comp_function comparator,
- Curl_hash_dtor dtor);
+ Curl_hash_dtor dtor);
-void *Curl_hash_add(struct Curl_hash *h, void *key, size_t key_len, void *p);
-int Curl_hash_delete(struct Curl_hash *h, void *key, size_t key_len);
-void *Curl_hash_pick(struct Curl_hash *, void *key, size_t key_len);
-void Curl_hash_apply(struct Curl_hash *h, void *user,
+void *Curl_hash_add(struct Curl_hash *h, void *key, size_t key_len, void *p);
+int Curl_hash_delete(struct Curl_hash *h, void *key, size_t key_len);
+void *Curl_hash_pick(struct Curl_hash *, void *key, size_t key_len);
+void Curl_hash_apply(struct Curl_hash *h, void *user,
void (*cb)(void *user, void *ptr));
#define Curl_hash_count(h) ((h)->size)
-void Curl_hash_destroy(struct Curl_hash *h);
-void Curl_hash_clean(struct Curl_hash *h);
-void Curl_hash_clean_with_criterium(struct Curl_hash *h, void *user,
+void Curl_hash_destroy(struct Curl_hash *h);
+void Curl_hash_clean(struct Curl_hash *h);
+void Curl_hash_clean_with_criterium(struct Curl_hash *h, void *user,
int (*comp)(void *, void *));
size_t Curl_hash_str(void *key, size_t key_length, size_t slots_num);
size_t Curl_str_key_compare(void *k1, size_t key1_len, void *k2,
size_t key2_len);
-void Curl_hash_start_iterate(struct Curl_hash *hash,
- struct Curl_hash_iterator *iter);
-struct Curl_hash_element *
-Curl_hash_next_element(struct Curl_hash_iterator *iter);
+void Curl_hash_start_iterate(struct Curl_hash *hash,
+ struct Curl_hash_iterator *iter);
+struct Curl_hash_element *
+Curl_hash_next_element(struct Curl_hash_iterator *iter);
-void Curl_hash_print(struct Curl_hash *h,
+void Curl_hash_print(struct Curl_hash *h,
void (*func)(void *));
diff --git a/contrib/libs/curl/lib/hmac.c b/contrib/libs/curl/lib/hmac.c
index 190b70a878..590abe6d2e 100644
--- a/contrib/libs/curl/lib/hmac.c
+++ b/contrib/libs/curl/lib/hmac.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -30,7 +30,7 @@
#include "curl_hmac.h"
#include "curl_memory.h"
-#include "warnless.h"
+#include "warnless.h"
/* The last #include file should be: */
#include "memdebug.h"
@@ -48,13 +48,13 @@ static const unsigned char hmac_opad = 0x5C;
-struct HMAC_context *
-Curl_HMAC_init(const struct HMAC_params *hashparams,
+struct HMAC_context *
+Curl_HMAC_init(const struct HMAC_params *hashparams,
const unsigned char *key,
unsigned int keylen)
{
size_t i;
- struct HMAC_context *ctxt;
+ struct HMAC_context *ctxt;
unsigned char *hkey;
unsigned char b;
@@ -101,7 +101,7 @@ Curl_HMAC_init(const struct HMAC_params *hashparams,
return ctxt;
}
-int Curl_HMAC_update(struct HMAC_context *ctxt,
+int Curl_HMAC_update(struct HMAC_context *ctxt,
const unsigned char *data,
unsigned int len)
{
@@ -111,9 +111,9 @@ int Curl_HMAC_update(struct HMAC_context *ctxt,
}
-int Curl_HMAC_final(struct HMAC_context *ctxt, unsigned char *result)
+int Curl_HMAC_final(struct HMAC_context *ctxt, unsigned char *result)
{
- const struct HMAC_params *hashparams = ctxt->hmac_hash;
+ const struct HMAC_params *hashparams = ctxt->hmac_hash;
/* Do not get result if called with a null parameter: only release
storage. */
@@ -130,41 +130,41 @@ int Curl_HMAC_final(struct HMAC_context *ctxt, unsigned char *result)
return 0;
}
-/*
- * Curl_hmacit()
- *
- * This is used to generate a HMAC hash, for the specified input data, given
- * the specified hash function and key.
- *
- * Parameters:
- *
- * hashparams [in] - The hash function (Curl_HMAC_MD5).
- * key [in] - The key to use.
- * keylen [in] - The length of the key.
- * data [in] - The data to encrypt.
- * datalen [in] - The length of the data.
- * output [in/out] - The output buffer.
- *
- * Returns CURLE_OK on success.
- */
-CURLcode Curl_hmacit(const struct HMAC_params *hashparams,
- const unsigned char *key, const size_t keylen,
- const unsigned char *data, const size_t datalen,
- unsigned char *output)
-{
- struct HMAC_context *ctxt =
- Curl_HMAC_init(hashparams, key, curlx_uztoui(keylen));
-
- if(!ctxt)
- return CURLE_OUT_OF_MEMORY;
-
- /* Update the digest with the given challenge */
- Curl_HMAC_update(ctxt, data, curlx_uztoui(datalen));
-
- /* Finalise the digest */
- Curl_HMAC_final(ctxt, output);
-
- return CURLE_OK;
-}
-
+/*
+ * Curl_hmacit()
+ *
+ * This is used to generate a HMAC hash, for the specified input data, given
+ * the specified hash function and key.
+ *
+ * Parameters:
+ *
+ * hashparams [in] - The hash function (Curl_HMAC_MD5).
+ * key [in] - The key to use.
+ * keylen [in] - The length of the key.
+ * data [in] - The data to encrypt.
+ * datalen [in] - The length of the data.
+ * output [in/out] - The output buffer.
+ *
+ * Returns CURLE_OK on success.
+ */
+CURLcode Curl_hmacit(const struct HMAC_params *hashparams,
+ const unsigned char *key, const size_t keylen,
+ const unsigned char *data, const size_t datalen,
+ unsigned char *output)
+{
+ struct HMAC_context *ctxt =
+ Curl_HMAC_init(hashparams, key, curlx_uztoui(keylen));
+
+ if(!ctxt)
+ return CURLE_OUT_OF_MEMORY;
+
+ /* Update the digest with the given challenge */
+ Curl_HMAC_update(ctxt, data, curlx_uztoui(datalen));
+
+ /* Finalise the digest */
+ Curl_HMAC_final(ctxt, output);
+
+ return CURLE_OK;
+}
+
#endif /* CURL_DISABLE_CRYPTO_AUTH */
diff --git a/contrib/libs/curl/lib/hostasyn.c b/contrib/libs/curl/lib/hostasyn.c
index eddf696f88..56a6fc2b72 100644
--- a/contrib/libs/curl/lib/hostasyn.c
+++ b/contrib/libs/curl/lib/hostasyn.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -117,10 +117,10 @@ CURLcode Curl_addrinfo_callback(struct connectdata *conn,
* name resolve layers (selected at build-time). They all take this same set
* of arguments
*/
-struct Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
- const char *hostname,
- int port,
- int *waitp)
+struct Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
+ const char *hostname,
+ int port,
+ int *waitp)
{
return Curl_resolver_getaddrinfo(conn, hostname, port, waitp);
}
diff --git a/contrib/libs/curl/lib/hostcheck.c b/contrib/libs/curl/lib/hostcheck.c
index 2dc13264e3..4d0614aeab 100644
--- a/contrib/libs/curl/lib/hostcheck.c
+++ b/contrib/libs/curl/lib/hostcheck.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/hostcheck.h b/contrib/libs/curl/lib/hostcheck.h
index d0234a24ea..52155f43b4 100644
--- a/contrib/libs/curl/lib/hostcheck.h
+++ b/contrib/libs/curl/lib/hostcheck.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/hostip.c b/contrib/libs/curl/lib/hostip.c
index aa7c1cf7fd..c6435f1f97 100644
--- a/contrib/libs/curl/lib/hostip.c
+++ b/contrib/libs/curl/lib/hostip.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -59,7 +59,7 @@
#include "strerror.h"
#include "url.h"
#include "inet_ntop.h"
-#include "inet_pton.h"
+#include "inet_pton.h"
#include "multiif.h"
#include "doh.h"
#include "warnless.h"
@@ -120,7 +120,7 @@ static void freednsentry(void *freethis);
/*
* Return # of addresses in a Curl_addrinfo struct
*/
-int Curl_num_addresses(const struct Curl_addrinfo *addr)
+int Curl_num_addresses(const struct Curl_addrinfo *addr)
{
int i = 0;
while(addr) {
@@ -131,35 +131,35 @@ int Curl_num_addresses(const struct Curl_addrinfo *addr)
}
/*
- * Curl_printable_address() stores a printable version of the 1st address
+ * Curl_printable_address() stores a printable version of the 1st address
* given in the 'ai' argument. The result will be stored in the buf that is
* bufsize bytes big.
*
- * If the conversion fails, the target buffer is empty.
+ * If the conversion fails, the target buffer is empty.
*/
-void Curl_printable_address(const struct Curl_addrinfo *ai, char *buf,
- size_t bufsize)
+void Curl_printable_address(const struct Curl_addrinfo *ai, char *buf,
+ size_t bufsize)
{
- DEBUGASSERT(bufsize);
- buf[0] = 0;
+ DEBUGASSERT(bufsize);
+ buf[0] = 0;
switch(ai->ai_family) {
- case AF_INET: {
- const struct sockaddr_in *sa4 = (const void *)ai->ai_addr;
- const struct in_addr *ipaddr4 = &sa4->sin_addr;
- (void)Curl_inet_ntop(ai->ai_family, (const void *)ipaddr4, buf, bufsize);
- break;
- }
+ case AF_INET: {
+ const struct sockaddr_in *sa4 = (const void *)ai->ai_addr;
+ const struct in_addr *ipaddr4 = &sa4->sin_addr;
+ (void)Curl_inet_ntop(ai->ai_family, (const void *)ipaddr4, buf, bufsize);
+ break;
+ }
#ifdef ENABLE_IPV6
- case AF_INET6: {
- const struct sockaddr_in6 *sa6 = (const void *)ai->ai_addr;
- const struct in6_addr *ipaddr6 = &sa6->sin6_addr;
- (void)Curl_inet_ntop(ai->ai_family, (const void *)ipaddr6, buf, bufsize);
- break;
- }
+ case AF_INET6: {
+ const struct sockaddr_in6 *sa6 = (const void *)ai->ai_addr;
+ const struct in6_addr *ipaddr6 = &sa6->sin6_addr;
+ (void)Curl_inet_ntop(ai->ai_family, (const void *)ipaddr6, buf, bufsize);
+ break;
+ }
#endif
- default:
- break;
+ default:
+ break;
}
}
@@ -206,7 +206,7 @@ hostcache_timestamp_remove(void *datap, void *hc)
* Prune the DNS cache. This assumes that a lock has already been taken.
*/
static void
-hostcache_prune(struct Curl_hash *hostcache, long cache_timeout, time_t now)
+hostcache_prune(struct Curl_hash *hostcache, long cache_timeout, time_t now)
{
struct hostcache_prune_data user;
@@ -334,7 +334,7 @@ Curl_fetch_addr(struct connectdata *conn,
#ifndef CURL_DISABLE_SHUFFLE_DNS
UNITTEST CURLcode Curl_shuffle_addr(struct Curl_easy *data,
- struct Curl_addrinfo **addr);
+ struct Curl_addrinfo **addr);
/*
* Curl_shuffle_addr() shuffles the order of addresses in a 'Curl_addrinfo'
* struct by re-linking its linked list.
@@ -348,13 +348,13 @@ UNITTEST CURLcode Curl_shuffle_addr(struct Curl_easy *data,
* @unittest: 1608
*/
UNITTEST CURLcode Curl_shuffle_addr(struct Curl_easy *data,
- struct Curl_addrinfo **addr)
+ struct Curl_addrinfo **addr)
{
CURLcode result = CURLE_OK;
const int num_addrs = Curl_num_addresses(*addr);
if(num_addrs > 1) {
- struct Curl_addrinfo **nodes;
+ struct Curl_addrinfo **nodes;
infof(data, "Shuffling %i addresses", num_addrs);
nodes = malloc(num_addrs*sizeof(*nodes));
@@ -373,7 +373,7 @@ UNITTEST CURLcode Curl_shuffle_addr(struct Curl_easy *data,
if(rnd) {
/* Fisher-Yates shuffle */
if(Curl_rand(data, (unsigned char *)rnd, rnd_size) == CURLE_OK) {
- struct Curl_addrinfo *swap_tmp;
+ struct Curl_addrinfo *swap_tmp;
for(i = num_addrs - 1; i > 0; i--) {
swap_tmp = nodes[rnd[i] % (i + 1)];
nodes[rnd[i] % (i + 1)] = nodes[i];
@@ -412,7 +412,7 @@ UNITTEST CURLcode Curl_shuffle_addr(struct Curl_easy *data,
*/
struct Curl_dns_entry *
Curl_cache_addr(struct Curl_easy *data,
- struct Curl_addrinfo *addr,
+ struct Curl_addrinfo *addr,
const char *hostname,
int port)
{
@@ -480,19 +480,19 @@ Curl_cache_addr(struct Curl_easy *data,
* CURLRESOLV_PENDING (1) = waiting for response, no pointer
*/
-enum resolve_t Curl_resolv(struct connectdata *conn,
- const char *hostname,
- int port,
- bool allowDOH,
- struct Curl_dns_entry **entry)
+enum resolve_t Curl_resolv(struct connectdata *conn,
+ const char *hostname,
+ int port,
+ bool allowDOH,
+ struct Curl_dns_entry **entry)
{
struct Curl_dns_entry *dns = NULL;
struct Curl_easy *data = conn->data;
CURLcode result;
- enum resolve_t rc = CURLRESOLV_ERROR; /* default to failure */
+ enum resolve_t rc = CURLRESOLV_ERROR; /* default to failure */
*entry = NULL;
- conn->bits.doh = FALSE; /* default is not */
+ conn->bits.doh = FALSE; /* default is not */
if(data->share)
Curl_share_lock(data, CURL_LOCK_DATA_DNS, CURL_LOCK_ACCESS_SINGLE);
@@ -511,13 +511,13 @@ enum resolve_t Curl_resolv(struct connectdata *conn,
if(!dns) {
/* The entry was not in the cache. Resolve it to IP address */
- struct Curl_addrinfo *addr = NULL;
+ struct Curl_addrinfo *addr = NULL;
int respwait = 0;
- struct in_addr in;
-#ifndef USE_RESOLVE_ON_IPS
- const
-#endif
- bool ipnum = FALSE;
+ struct in_addr in;
+#ifndef USE_RESOLVE_ON_IPS
+ const
+#endif
+ bool ipnum = FALSE;
/* notify the resolver start callback */
if(data->set.resolver_start) {
@@ -530,59 +530,59 @@ enum resolve_t Curl_resolv(struct connectdata *conn,
return CURLRESOLV_ERROR;
}
-#ifndef USE_RESOLVE_ON_IPS
- /* First check if this is an IPv4 address string */
- if(Curl_inet_pton(AF_INET, hostname, &in) > 0)
- /* This is a dotted IP address 123.123.123.123-style */
- addr = Curl_ip2addr(AF_INET, &in, hostname, port);
-#ifdef ENABLE_IPV6
- if(!addr) {
- struct in6_addr in6;
- /* check if this is an IPv6 address string */
- if(Curl_inet_pton(AF_INET6, hostname, &in6) > 0)
- /* This is an IPv6 address literal */
- addr = Curl_ip2addr(AF_INET6, &in6, hostname, port);
+#ifndef USE_RESOLVE_ON_IPS
+ /* First check if this is an IPv4 address string */
+ if(Curl_inet_pton(AF_INET, hostname, &in) > 0)
+ /* This is a dotted IP address 123.123.123.123-style */
+ addr = Curl_ip2addr(AF_INET, &in, hostname, port);
+#ifdef ENABLE_IPV6
+ if(!addr) {
+ struct in6_addr in6;
+ /* check if this is an IPv6 address string */
+ if(Curl_inet_pton(AF_INET6, hostname, &in6) > 0)
+ /* This is an IPv6 address literal */
+ addr = Curl_ip2addr(AF_INET6, &in6, hostname, port);
}
-#endif /* ENABLE_IPV6 */
-
-#else /* if USE_RESOLVE_ON_IPS */
- /* First check if this is an IPv4 address string */
- if(Curl_inet_pton(AF_INET, hostname, &in) > 0)
- /* This is a dotted IP address 123.123.123.123-style */
- ipnum = TRUE;
-#ifdef ENABLE_IPV6
+#endif /* ENABLE_IPV6 */
+
+#else /* if USE_RESOLVE_ON_IPS */
+ /* First check if this is an IPv4 address string */
+ if(Curl_inet_pton(AF_INET, hostname, &in) > 0)
+ /* This is a dotted IP address 123.123.123.123-style */
+ ipnum = TRUE;
+#ifdef ENABLE_IPV6
else {
- struct in6_addr in6;
- /* check if this is an IPv6 address string */
- if(Curl_inet_pton(AF_INET6, hostname, &in6) > 0)
- /* This is an IPv6 address literal */
- ipnum = TRUE;
- }
-#endif /* ENABLE_IPV6 */
-
-#endif /* !USE_RESOLVE_ON_IPS */
-
- if(!addr) {
- /* Check what IP specifics the app has requested and if we can provide
- * it. If not, bail out. */
- if(!Curl_ipvalid(conn))
- return CURLRESOLV_ERROR;
-
- if(allowDOH && data->set.doh && !ipnum) {
- addr = Curl_doh(conn, hostname, port, &respwait);
- }
- else {
- /* If Curl_getaddrinfo() returns NULL, 'respwait' might be set to a
- non-zero value indicating that we need to wait for the response to
- the resolve call */
- addr = Curl_getaddrinfo(conn,
+ struct in6_addr in6;
+ /* check if this is an IPv6 address string */
+ if(Curl_inet_pton(AF_INET6, hostname, &in6) > 0)
+ /* This is an IPv6 address literal */
+ ipnum = TRUE;
+ }
+#endif /* ENABLE_IPV6 */
+
+#endif /* !USE_RESOLVE_ON_IPS */
+
+ if(!addr) {
+ /* Check what IP specifics the app has requested and if we can provide
+ * it. If not, bail out. */
+ if(!Curl_ipvalid(conn))
+ return CURLRESOLV_ERROR;
+
+ if(allowDOH && data->set.doh && !ipnum) {
+ addr = Curl_doh(conn, hostname, port, &respwait);
+ }
+ else {
+ /* If Curl_getaddrinfo() returns NULL, 'respwait' might be set to a
+ non-zero value indicating that we need to wait for the response to
+ the resolve call */
+ addr = Curl_getaddrinfo(conn,
#ifdef DEBUGBUILD
- (data->set.str[STRING_DEVICE]
- && !strcmp(data->set.str[STRING_DEVICE],
- "LocalHost"))?"localhost":
+ (data->set.str[STRING_DEVICE]
+ && !strcmp(data->set.str[STRING_DEVICE],
+ "LocalHost"))?"localhost":
#endif
- hostname, port, &respwait);
- }
+ hostname, port, &respwait);
+ }
}
if(!addr) {
if(respwait) {
@@ -658,11 +658,11 @@ RETSIGTYPE alarmfunc(int sig)
* CURLRESOLV_PENDING (1) = waiting for response, no pointer
*/
-enum resolve_t Curl_resolv_timeout(struct connectdata *conn,
- const char *hostname,
- int port,
- struct Curl_dns_entry **entry,
- timediff_t timeoutms)
+enum resolve_t Curl_resolv_timeout(struct connectdata *conn,
+ const char *hostname,
+ int port,
+ struct Curl_dns_entry **entry,
+ timediff_t timeoutms)
{
#ifdef USE_ALARM_TIMEOUT
#ifdef HAVE_SIGACTION
@@ -678,7 +678,7 @@ enum resolve_t Curl_resolv_timeout(struct connectdata *conn,
volatile unsigned int prev_alarm = 0;
struct Curl_easy *data = conn->data;
#endif /* USE_ALARM_TIMEOUT */
- enum resolve_t rc;
+ enum resolve_t rc;
*entry = NULL;
@@ -787,7 +787,7 @@ clean_up:
conn->created) / 1000;
/* the alarm period is counted in even number of seconds */
- unsigned long alarm_set = (unsigned long)(prev_alarm - elapsed_secs);
+ unsigned long alarm_set = (unsigned long)(prev_alarm - elapsed_secs);
if(!alarm_set ||
((alarm_set >= 0x80000000) && (prev_alarm < 0x80000000)) ) {
@@ -843,7 +843,7 @@ static void freednsentry(void *freethis)
/*
* Curl_mk_dnscache() inits a new DNS cache and returns success/failure.
*/
-int Curl_mk_dnscache(struct Curl_hash *hash)
+int Curl_mk_dnscache(struct Curl_hash *hash)
{
return Curl_hash_init(hash, 7, Curl_hash_str, Curl_str_key_compare,
freednsentry);
@@ -857,7 +857,7 @@ int Curl_mk_dnscache(struct Curl_hash *hash)
*/
void Curl_hostcache_clean(struct Curl_easy *data,
- struct Curl_hash *hash)
+ struct Curl_hash *hash)
{
if(data && data->share)
Curl_share_lock(data, CURL_LOCK_DATA_DNS, CURL_LOCK_ACCESS_SINGLE);
@@ -906,7 +906,7 @@ CURLcode Curl_loadhostpairs(struct Curl_easy *data)
}
else {
struct Curl_dns_entry *dns;
- struct Curl_addrinfo *head = NULL, *tail = NULL;
+ struct Curl_addrinfo *head = NULL, *tail = NULL;
size_t entry_len;
char address[64];
#if !defined(CURL_DISABLE_VERBOSE_STRINGS)
@@ -940,7 +940,7 @@ CURLcode Curl_loadhostpairs(struct Curl_easy *data)
while(*end_ptr) {
size_t alen;
- struct Curl_addrinfo *ai;
+ struct Curl_addrinfo *ai;
addr_begin = end_ptr + 1;
addr_end = strchr(addr_begin, ',');
@@ -1059,11 +1059,11 @@ CURLcode Curl_loadhostpairs(struct Curl_easy *data)
CURLcode Curl_resolv_check(struct connectdata *conn,
struct Curl_dns_entry **dns)
{
-#if defined(CURL_DISABLE_DOH) && !defined(CURLRES_ASYNCH)
- (void)dns;
-#endif
-
- if(conn->bits.doh)
+#if defined(CURL_DISABLE_DOH) && !defined(CURLRES_ASYNCH)
+ (void)dns;
+#endif
+
+ if(conn->bits.doh)
return Curl_doh_is_resolved(conn, dns);
return Curl_resolver_is_resolved(conn, dns);
}
@@ -1072,7 +1072,7 @@ int Curl_resolv_getsock(struct connectdata *conn,
curl_socket_t *socks)
{
#ifdef CURLRES_ASYNCH
- if(conn->bits.doh)
+ if(conn->bits.doh)
/* nothing to wait for during DOH resolve, those handles have their own
sockets */
return GETSOCK_BLANK;
@@ -1101,12 +1101,12 @@ CURLcode Curl_once_resolved(struct connectdata *conn,
result = Curl_setup_conn(conn, protocol_done);
- if(result) {
- struct Curl_easy *data = conn->data;
- DEBUGASSERT(data);
- Curl_detach_connnection(data);
- Curl_conncache_remove_conn(data, conn, TRUE);
- Curl_disconnect(data, conn, TRUE);
- }
+ if(result) {
+ struct Curl_easy *data = conn->data;
+ DEBUGASSERT(data);
+ Curl_detach_connnection(data);
+ Curl_conncache_remove_conn(data, conn, TRUE);
+ Curl_disconnect(data, conn, TRUE);
+ }
return result;
}
diff --git a/contrib/libs/curl/lib/hostip.h b/contrib/libs/curl/lib/hostip.h
index 424db2b167..724a03d7fb 100644
--- a/contrib/libs/curl/lib/hostip.h
+++ b/contrib/libs/curl/lib/hostip.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -59,12 +59,12 @@ struct connectdata;
* Global DNS cache is general badness. Do not use. This will be removed in
* a future version. Use the share interface instead!
*
- * Returns a struct Curl_hash pointer on success, NULL on failure.
+ * Returns a struct Curl_hash pointer on success, NULL on failure.
*/
-struct Curl_hash *Curl_global_host_cache_init(void);
+struct Curl_hash *Curl_global_host_cache_init(void);
struct Curl_dns_entry {
- struct Curl_addrinfo *addr;
+ struct Curl_addrinfo *addr;
/* timestamp == 0 -- CURLOPT_RESOLVE entry, doesn't timeout */
time_t timestamp;
/* use-counter, use Curl_resolv_unlock to release reference */
@@ -79,29 +79,29 @@ struct Curl_dns_entry {
* use, or we'll leak memory!
*/
/* return codes */
-enum resolve_t {
- CURLRESOLV_TIMEDOUT = -2,
- CURLRESOLV_ERROR = -1,
- CURLRESOLV_RESOLVED = 0,
- CURLRESOLV_PENDING = 1
-};
-enum resolve_t Curl_resolv(struct connectdata *conn,
- const char *hostname,
- int port,
- bool allowDOH,
- struct Curl_dns_entry **dnsentry);
-enum resolve_t Curl_resolv_timeout(struct connectdata *conn,
- const char *hostname, int port,
- struct Curl_dns_entry **dnsentry,
- timediff_t timeoutms);
+enum resolve_t {
+ CURLRESOLV_TIMEDOUT = -2,
+ CURLRESOLV_ERROR = -1,
+ CURLRESOLV_RESOLVED = 0,
+ CURLRESOLV_PENDING = 1
+};
+enum resolve_t Curl_resolv(struct connectdata *conn,
+ const char *hostname,
+ int port,
+ bool allowDOH,
+ struct Curl_dns_entry **dnsentry);
+enum resolve_t Curl_resolv_timeout(struct connectdata *conn,
+ const char *hostname, int port,
+ struct Curl_dns_entry **dnsentry,
+ timediff_t timeoutms);
#ifdef CURLRES_IPV6
/*
* Curl_ipv6works() returns TRUE if IPv6 seems to work.
*/
-bool Curl_ipv6works(struct connectdata *conn);
+bool Curl_ipv6works(struct connectdata *conn);
#else
-#define Curl_ipv6works(x) FALSE
+#define Curl_ipv6works(x) FALSE
#endif
/*
@@ -117,10 +117,10 @@ bool Curl_ipvalid(struct connectdata *conn);
* name resolve layers (selected at build-time). They all take this same set
* of arguments
*/
-struct Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
- const char *hostname,
- int port,
- int *waitp);
+struct Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
+ const char *hostname,
+ int port,
+ int *waitp);
/* unlock a previously resolved dns entry */
@@ -128,13 +128,13 @@ void Curl_resolv_unlock(struct Curl_easy *data,
struct Curl_dns_entry *dns);
/* init a new dns cache and return success */
-int Curl_mk_dnscache(struct Curl_hash *hash);
+int Curl_mk_dnscache(struct Curl_hash *hash);
/* prune old entries from the DNS cache */
void Curl_hostcache_prune(struct Curl_easy *data);
/* Return # of addresses in a Curl_addrinfo struct */
-int Curl_num_addresses(const struct Curl_addrinfo *addr);
+int Curl_num_addresses(const struct Curl_addrinfo *addr);
#if defined(CURLDEBUG) && defined(HAVE_GETNAMEINFO)
int curl_dogetnameinfo(GETNAMEINFO_QUAL_ARG1 GETNAMEINFO_TYPE_ARG1 sa,
@@ -146,7 +146,7 @@ int curl_dogetnameinfo(GETNAMEINFO_QUAL_ARG1 GETNAMEINFO_TYPE_ARG1 sa,
#endif
/* IPv4 threadsafe resolve function used for synch and asynch builds */
-struct Curl_addrinfo *Curl_ipv4_resolve_r(const char *hostname, int port);
+struct Curl_addrinfo *Curl_ipv4_resolve_r(const char *hostname, int port);
CURLcode Curl_once_resolved(struct connectdata *conn, bool *protocol_connect);
@@ -158,15 +158,15 @@ CURLcode Curl_once_resolved(struct connectdata *conn, bool *protocol_connect);
*/
CURLcode Curl_addrinfo_callback(struct connectdata *conn,
int status,
- struct Curl_addrinfo *ai);
+ struct Curl_addrinfo *ai);
/*
* Curl_printable_address() returns a printable version of the 1st address
* given in the 'ip' argument. The result will be stored in the buf that is
* bufsize bytes big.
*/
-void Curl_printable_address(const struct Curl_addrinfo *ip,
- char *buf, size_t bufsize);
+void Curl_printable_address(const struct Curl_addrinfo *ip,
+ char *buf, size_t bufsize);
/*
* Curl_fetch_addr() fetches a 'Curl_dns_entry' already in the DNS cache.
@@ -187,7 +187,7 @@ Curl_fetch_addr(struct connectdata *conn,
* Returns the Curl_dns_entry entry pointer or NULL if the storage failed.
*/
struct Curl_dns_entry *
-Curl_cache_addr(struct Curl_easy *data, struct Curl_addrinfo *addr,
+Curl_cache_addr(struct Curl_easy *data, struct Curl_addrinfo *addr,
const char *hostname, int port);
#ifndef INADDR_NONE
@@ -234,7 +234,7 @@ CURLcode Curl_set_dns_local_ip6(struct Curl_easy *data,
/*
* Clean off entries from the cache
*/
-void Curl_hostcache_clean(struct Curl_easy *data, struct Curl_hash *hash);
+void Curl_hostcache_clean(struct Curl_easy *data, struct Curl_hash *hash);
/*
* Populate the cache with specified entries from CURLOPT_RESOLVE.
diff --git a/contrib/libs/curl/lib/hostip4.c b/contrib/libs/curl/lib/hostip4.c
index 1402e29a69..df83a2f12b 100644
--- a/contrib/libs/curl/lib/hostip4.c
+++ b/contrib/libs/curl/lib/hostip4.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -88,12 +88,12 @@ bool Curl_ipvalid(struct connectdata *conn)
* flavours have thread-safe versions of the plain gethostbyname() etc.
*
*/
-struct Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
- const char *hostname,
- int port,
- int *waitp)
+struct Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
+ const char *hostname,
+ int port,
+ int *waitp)
{
- struct Curl_addrinfo *ai = NULL;
+ struct Curl_addrinfo *ai = NULL;
#ifdef CURL_DISABLE_VERBOSE_STRINGS
(void)conn;
@@ -119,30 +119,30 @@ struct Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
* implying that only threadsafe code and function calls may be used.
*
*/
-struct Curl_addrinfo *Curl_ipv4_resolve_r(const char *hostname,
- int port)
+struct Curl_addrinfo *Curl_ipv4_resolve_r(const char *hostname,
+ int port)
{
#if !defined(HAVE_GETADDRINFO_THREADSAFE) && defined(HAVE_GETHOSTBYNAME_R_3)
int res;
#endif
- struct Curl_addrinfo *ai = NULL;
+ struct Curl_addrinfo *ai = NULL;
struct hostent *h = NULL;
struct hostent *buf = NULL;
#if defined(HAVE_GETADDRINFO_THREADSAFE)
- struct addrinfo hints;
- char sbuf[12];
- char *sbufptr = NULL;
-
- memset(&hints, 0, sizeof(hints));
- hints.ai_family = PF_INET;
- hints.ai_socktype = SOCK_STREAM;
- if(port) {
- msnprintf(sbuf, sizeof(sbuf), "%d", port);
- sbufptr = sbuf;
- }
+ struct addrinfo hints;
+ char sbuf[12];
+ char *sbufptr = NULL;
+
+ memset(&hints, 0, sizeof(hints));
+ hints.ai_family = PF_INET;
+ hints.ai_socktype = SOCK_STREAM;
+ if(port) {
+ msnprintf(sbuf, sizeof(sbuf), "%d", port);
+ sbufptr = sbuf;
+ }
- (void)Curl_getaddrinfo_ex(hostname, sbufptr, &hints, &ai);
+ (void)Curl_getaddrinfo_ex(hostname, sbufptr, &hints, &ai);
#elif defined(HAVE_GETHOSTBYNAME_R)
/*
@@ -150,140 +150,140 @@ struct Curl_addrinfo *Curl_ipv4_resolve_r(const char *hostname,
* Since there are three different versions of it, the following code is
* somewhat #ifdef-ridden.
*/
- int h_errnop;
+ int h_errnop;
- buf = calloc(1, CURL_HOSTENT_SIZE);
- if(!buf)
- return NULL; /* major failure */
- /*
- * The clearing of the buffer is a workaround for a gethostbyname_r bug in
- * qnx nto and it is also _required_ for some of these functions on some
- * platforms.
- */
+ buf = calloc(1, CURL_HOSTENT_SIZE);
+ if(!buf)
+ return NULL; /* major failure */
+ /*
+ * The clearing of the buffer is a workaround for a gethostbyname_r bug in
+ * qnx nto and it is also _required_ for some of these functions on some
+ * platforms.
+ */
#if defined(HAVE_GETHOSTBYNAME_R_5)
- /* Solaris, IRIX and more */
- h = gethostbyname_r(hostname,
- (struct hostent *)buf,
- (char *)buf + sizeof(struct hostent),
- CURL_HOSTENT_SIZE - sizeof(struct hostent),
- &h_errnop);
-
- /* If the buffer is too small, it returns NULL and sets errno to
- * ERANGE. The errno is thread safe if this is compiled with
- * -D_REENTRANT as then the 'errno' variable is a macro defined to get
- * used properly for threads.
- */
-
- if(h) {
- ;
- }
- else
+ /* Solaris, IRIX and more */
+ h = gethostbyname_r(hostname,
+ (struct hostent *)buf,
+ (char *)buf + sizeof(struct hostent),
+ CURL_HOSTENT_SIZE - sizeof(struct hostent),
+ &h_errnop);
+
+ /* If the buffer is too small, it returns NULL and sets errno to
+ * ERANGE. The errno is thread safe if this is compiled with
+ * -D_REENTRANT as then the 'errno' variable is a macro defined to get
+ * used properly for threads.
+ */
+
+ if(h) {
+ ;
+ }
+ else
#elif defined(HAVE_GETHOSTBYNAME_R_6)
- /* Linux */
-
- (void)gethostbyname_r(hostname,
- (struct hostent *)buf,
- (char *)buf + sizeof(struct hostent),
- CURL_HOSTENT_SIZE - sizeof(struct hostent),
- &h, /* DIFFERENCE */
- &h_errnop);
- /* Redhat 8, using glibc 2.2.93 changed the behavior. Now all of a
- * sudden this function returns EAGAIN if the given buffer size is too
- * small. Previous versions are known to return ERANGE for the same
- * problem.
- *
- * This wouldn't be such a big problem if older versions wouldn't
- * sometimes return EAGAIN on a common failure case. Alas, we can't
- * assume that EAGAIN *or* ERANGE means ERANGE for any given version of
- * glibc.
- *
- * For now, we do that and thus we may call the function repeatedly and
- * fail for older glibc versions that return EAGAIN, until we run out of
- * buffer size (step_size grows beyond CURL_HOSTENT_SIZE).
- *
- * If anyone has a better fix, please tell us!
- *
- * -------------------------------------------------------------------
- *
- * On October 23rd 2003, Dan C dug up more details on the mysteries of
- * gethostbyname_r() in glibc:
- *
- * In glibc 2.2.5 the interface is different (this has also been
- * discovered in glibc 2.1.1-6 as shipped by Redhat 6). What I can't
- * explain, is that tests performed on glibc 2.2.4-34 and 2.2.4-32
- * (shipped/upgraded by Redhat 7.2) don't show this behavior!
- *
- * In this "buggy" version, the return code is -1 on error and 'errno'
- * is set to the ERANGE or EAGAIN code. Note that 'errno' is not a
- * thread-safe variable.
- */
-
- if(!h) /* failure */
+ /* Linux */
+
+ (void)gethostbyname_r(hostname,
+ (struct hostent *)buf,
+ (char *)buf + sizeof(struct hostent),
+ CURL_HOSTENT_SIZE - sizeof(struct hostent),
+ &h, /* DIFFERENCE */
+ &h_errnop);
+ /* Redhat 8, using glibc 2.2.93 changed the behavior. Now all of a
+ * sudden this function returns EAGAIN if the given buffer size is too
+ * small. Previous versions are known to return ERANGE for the same
+ * problem.
+ *
+ * This wouldn't be such a big problem if older versions wouldn't
+ * sometimes return EAGAIN on a common failure case. Alas, we can't
+ * assume that EAGAIN *or* ERANGE means ERANGE for any given version of
+ * glibc.
+ *
+ * For now, we do that and thus we may call the function repeatedly and
+ * fail for older glibc versions that return EAGAIN, until we run out of
+ * buffer size (step_size grows beyond CURL_HOSTENT_SIZE).
+ *
+ * If anyone has a better fix, please tell us!
+ *
+ * -------------------------------------------------------------------
+ *
+ * On October 23rd 2003, Dan C dug up more details on the mysteries of
+ * gethostbyname_r() in glibc:
+ *
+ * In glibc 2.2.5 the interface is different (this has also been
+ * discovered in glibc 2.1.1-6 as shipped by Redhat 6). What I can't
+ * explain, is that tests performed on glibc 2.2.4-34 and 2.2.4-32
+ * (shipped/upgraded by Redhat 7.2) don't show this behavior!
+ *
+ * In this "buggy" version, the return code is -1 on error and 'errno'
+ * is set to the ERANGE or EAGAIN code. Note that 'errno' is not a
+ * thread-safe variable.
+ */
+
+ if(!h) /* failure */
#elif defined(HAVE_GETHOSTBYNAME_R_3)
- /* AIX, Digital Unix/Tru64, HPUX 10, more? */
-
- /* For AIX 4.3 or later, we don't use gethostbyname_r() at all, because of
- * the plain fact that it does not return unique full buffers on each
- * call, but instead several of the pointers in the hostent structs will
- * point to the same actual data! This have the unfortunate down-side that
- * our caching system breaks down horribly. Luckily for us though, AIX 4.3
- * and more recent versions have a "completely thread-safe"[*] libc where
- * all the data is stored in thread-specific memory areas making calls to
- * the plain old gethostbyname() work fine even for multi-threaded
- * programs.
- *
- * This AIX 4.3 or later detection is all made in the configure script.
- *
- * Troels Walsted Hansen helped us work this out on March 3rd, 2003.
- *
- * [*] = much later we've found out that it isn't at all "completely
- * thread-safe", but at least the gethostbyname() function is.
- */
-
- if(CURL_HOSTENT_SIZE >=
- (sizeof(struct hostent) + sizeof(struct hostent_data))) {
-
- /* August 22nd, 2000: Albert Chin-A-Young brought an updated version
- * that should work! September 20: Richard Prescott worked on the buffer
- * size dilemma.
- */
-
- res = gethostbyname_r(hostname,
- (struct hostent *)buf,
- (struct hostent_data *)((char *)buf +
- sizeof(struct hostent)));
- h_errnop = SOCKERRNO; /* we don't deal with this, but set it anyway */
- }
- else
- res = -1; /* failure, too smallish buffer size */
-
- if(!res) { /* success */
-
- h = buf; /* result expected in h */
-
- /* This is the worst kind of the different gethostbyname_r() interfaces.
- * Since we don't know how big buffer this particular lookup required,
- * we can't realloc down the huge alloc without doing closer analysis of
- * the returned data. Thus, we always use CURL_HOSTENT_SIZE for every
- * name lookup. Fixing this would require an extra malloc() and then
- * calling Curl_addrinfo_copy() that subsequent realloc()s down the new
- * memory area to the actually used amount.
- */
- }
- else
+ /* AIX, Digital Unix/Tru64, HPUX 10, more? */
+
+ /* For AIX 4.3 or later, we don't use gethostbyname_r() at all, because of
+ * the plain fact that it does not return unique full buffers on each
+ * call, but instead several of the pointers in the hostent structs will
+ * point to the same actual data! This have the unfortunate down-side that
+ * our caching system breaks down horribly. Luckily for us though, AIX 4.3
+ * and more recent versions have a "completely thread-safe"[*] libc where
+ * all the data is stored in thread-specific memory areas making calls to
+ * the plain old gethostbyname() work fine even for multi-threaded
+ * programs.
+ *
+ * This AIX 4.3 or later detection is all made in the configure script.
+ *
+ * Troels Walsted Hansen helped us work this out on March 3rd, 2003.
+ *
+ * [*] = much later we've found out that it isn't at all "completely
+ * thread-safe", but at least the gethostbyname() function is.
+ */
+
+ if(CURL_HOSTENT_SIZE >=
+ (sizeof(struct hostent) + sizeof(struct hostent_data))) {
+
+ /* August 22nd, 2000: Albert Chin-A-Young brought an updated version
+ * that should work! September 20: Richard Prescott worked on the buffer
+ * size dilemma.
+ */
+
+ res = gethostbyname_r(hostname,
+ (struct hostent *)buf,
+ (struct hostent_data *)((char *)buf +
+ sizeof(struct hostent)));
+ h_errnop = SOCKERRNO; /* we don't deal with this, but set it anyway */
+ }
+ else
+ res = -1; /* failure, too smallish buffer size */
+
+ if(!res) { /* success */
+
+ h = buf; /* result expected in h */
+
+ /* This is the worst kind of the different gethostbyname_r() interfaces.
+ * Since we don't know how big buffer this particular lookup required,
+ * we can't realloc down the huge alloc without doing closer analysis of
+ * the returned data. Thus, we always use CURL_HOSTENT_SIZE for every
+ * name lookup. Fixing this would require an extra malloc() and then
+ * calling Curl_addrinfo_copy() that subsequent realloc()s down the new
+ * memory area to the actually used amount.
+ */
+ }
+ else
#endif /* HAVE_...BYNAME_R_5 || HAVE_...BYNAME_R_6 || HAVE_...BYNAME_R_3 */
- {
- h = NULL; /* set return code to NULL */
- free(buf);
- }
+ {
+ h = NULL; /* set return code to NULL */
+ free(buf);
+ }
#else /* HAVE_GETADDRINFO_THREADSAFE || HAVE_GETHOSTBYNAME_R */
- /*
- * Here is code for platforms that don't have a thread safe
- * getaddrinfo() nor gethostbyname_r() function or for which
- * gethostbyname() is the preferred one.
- */
- h = gethostbyname((void *)hostname);
+ /*
+ * Here is code for platforms that don't have a thread safe
+ * getaddrinfo() nor gethostbyname_r() function or for which
+ * gethostbyname() is the preferred one.
+ */
+ h = gethostbyname((void *)hostname);
#endif /* HAVE_GETADDRINFO_THREADSAFE || HAVE_GETHOSTBYNAME_R */
if(h) {
diff --git a/contrib/libs/curl/lib/hostip6.c b/contrib/libs/curl/lib/hostip6.c
index 1a7ea66832..02b0ca298b 100644
--- a/contrib/libs/curl/lib/hostip6.c
+++ b/contrib/libs/curl/lib/hostip6.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -62,19 +62,19 @@
/*
* Curl_ipv6works() returns TRUE if IPv6 seems to work.
*/
-bool Curl_ipv6works(struct connectdata *conn)
+bool Curl_ipv6works(struct connectdata *conn)
{
- if(conn) {
- /* the nature of most system is that IPv6 status doesn't come and go
- during a program's lifetime so we only probe the first time and then we
- have the info kept for fast re-use */
- DEBUGASSERT(conn);
- DEBUGASSERT(conn->data);
- DEBUGASSERT(conn->data->multi);
- return conn->data->multi->ipv6_works;
- }
- else {
- int ipv6_works = -1;
+ if(conn) {
+ /* the nature of most system is that IPv6 status doesn't come and go
+ during a program's lifetime so we only probe the first time and then we
+ have the info kept for fast re-use */
+ DEBUGASSERT(conn);
+ DEBUGASSERT(conn->data);
+ DEBUGASSERT(conn->data->multi);
+ return conn->data->multi->ipv6_works;
+ }
+ else {
+ int ipv6_works = -1;
/* probe to see if we have a working IPv6 stack */
curl_socket_t s = socket(PF_INET6, SOCK_DGRAM, 0);
if(s == CURL_SOCKET_BAD)
@@ -84,7 +84,7 @@ bool Curl_ipv6works(struct connectdata *conn)
ipv6_works = 1;
Curl_closesocket(NULL, s);
}
- return (ipv6_works>0)?TRUE:FALSE;
+ return (ipv6_works>0)?TRUE:FALSE;
}
}
@@ -95,7 +95,7 @@ bool Curl_ipv6works(struct connectdata *conn)
bool Curl_ipvalid(struct connectdata *conn)
{
if(conn->ip_version == CURL_IPRESOLVE_V6)
- return Curl_ipv6works(conn);
+ return Curl_ipv6works(conn);
return TRUE;
}
@@ -103,16 +103,16 @@ bool Curl_ipvalid(struct connectdata *conn)
#if defined(CURLRES_SYNCH)
#ifdef DEBUG_ADDRINFO
-static void dump_addrinfo(struct connectdata *conn,
- const struct Curl_addrinfo *ai)
+static void dump_addrinfo(struct connectdata *conn,
+ const struct Curl_addrinfo *ai)
{
printf("dump_addrinfo:\n");
for(; ai; ai = ai->ai_next) {
char buf[INET6_ADDRSTRLEN];
printf(" fam %2d, CNAME %s, ",
ai->ai_family, ai->ai_canonname ? ai->ai_canonname : "<none>");
- Curl_printable_address(ai, buf, sizeof(buf));
- printf("%s\n", buf);
+ Curl_printable_address(ai, buf, sizeof(buf));
+ printf("%s\n", buf);
}
}
#else
@@ -128,13 +128,13 @@ static void dump_addrinfo(struct connectdata *conn,
* memory we need to free after use. That memory *MUST* be freed with
* Curl_freeaddrinfo(), nothing else.
*/
-struct Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
- const char *hostname,
- int port,
- int *waitp)
+struct Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
+ const char *hostname,
+ int port,
+ int *waitp)
{
struct addrinfo hints;
- struct Curl_addrinfo *res;
+ struct Curl_addrinfo *res;
int error;
char sbuf[12];
char *sbufptr = NULL;
@@ -161,7 +161,7 @@ struct Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
break;
}
- if((pf != PF_INET) && !Curl_ipv6works(conn))
+ if((pf != PF_INET) && !Curl_ipv6works(conn))
/* The stack seems to be a non-IPv6 one */
pf = PF_INET;
diff --git a/contrib/libs/curl/lib/hostsyn.c b/contrib/libs/curl/lib/hostsyn.c
index a0d44095dc..550b43a085 100644
--- a/contrib/libs/curl/lib/hostsyn.c
+++ b/contrib/libs/curl/lib/hostsyn.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/hsts.c b/contrib/libs/curl/lib/hsts.c
index cc2650f7cb..6f771284ff 100644
--- a/contrib/libs/curl/lib/hsts.c
+++ b/contrib/libs/curl/lib/hsts.c
@@ -1,522 +1,522 @@
-/***************************************************************************
- * _ _ ____ _
- * Project ___| | | | _ \| |
- * / __| | | | |_) | |
- * | (__| |_| | _ <| |___
- * \___|\___/|_| \_\_____|
- *
- * Copyright (C) 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
- *
- * You may opt to use, copy, modify, merge, publish, distribute and/or sell
- * copies of the Software, and permit persons to whom the Software is
- * furnished to do so, under the terms of the COPYING file.
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- ***************************************************************************/
-/*
- * The Strict-Transport-Security header is defined in RFC 6797:
- * https://tools.ietf.org/html/rfc6797
- */
-#include "curl_setup.h"
-
-#if !defined(CURL_DISABLE_HTTP) && defined(USE_HSTS)
-#include <curl/curl.h>
-#include "urldata.h"
-#include "llist.h"
-#include "hsts.h"
-#include "curl_get_line.h"
-#include "strcase.h"
-#include "sendf.h"
-#include "strtoofft.h"
-#include "parsedate.h"
-#include "rand.h"
-#include "rename.h"
-
-/* The last 3 #include files should be in this order */
-#include "curl_printf.h"
-#include "curl_memory.h"
-#include "memdebug.h"
-
-#define MAX_HSTS_LINE 4095
-#define MAX_HSTS_HOSTLEN 256
-#define MAX_HSTS_HOSTLENSTR "256"
-#define MAX_HSTS_SUBLEN 4
-#define MAX_HSTS_SUBLENSTR "4"
-#define MAX_HSTS_DATELEN 64
-#define MAX_HSTS_DATELENSTR "64"
-
-#ifdef DEBUGBUILD
-/* to play well with debug builds, we can *set* a fixed time this will
- return */
-time_t deltatime; /* allow for "adjustments" for unit test purposes */
-static time_t debugtime(void *unused)
-{
- char *timestr = getenv("CURL_TIME");
- (void)unused;
- if(timestr) {
- unsigned long val = strtol(timestr, NULL, 10) + deltatime;
- return (time_t)val;
- }
- return time(NULL);
-}
-#define time(x) debugtime(x)
-#endif
-
-struct hsts *Curl_hsts_init(void)
-{
- struct hsts *h = calloc(sizeof(struct hsts), 1);
- if(h) {
- Curl_llist_init(&h->list, NULL);
- }
- return h;
-}
-
-static void hsts_free(struct stsentry *e)
-{
- free((char *)e->host);
- free(e);
-}
-
-void Curl_hsts_cleanup(struct hsts **hp)
-{
- struct hsts *h = *hp;
- if(h) {
- struct Curl_llist_element *e;
- struct Curl_llist_element *n;
- for(e = h->list.head; e; e = n) {
- struct stsentry *sts = e->ptr;
- n = e->next;
- hsts_free(sts);
- }
- free(h->filename);
- free(h);
- *hp = NULL;
- }
-}
-
-static struct stsentry *hsts_entry(void)
-{
- return calloc(sizeof(struct stsentry), 1);
-}
-
-static CURLcode hsts_create(struct hsts *h,
- const char *hostname,
- bool subdomains,
- curl_off_t expires)
-{
- struct stsentry *sts = hsts_entry();
- if(!sts)
- return CURLE_OUT_OF_MEMORY;
-
- sts->expires = expires;
- sts->includeSubDomains = subdomains;
- sts->host = strdup(hostname);
- if(!sts->host) {
- free(sts);
- return CURLE_OUT_OF_MEMORY;
- }
- Curl_llist_insert_next(&h->list, h->list.tail, sts, &sts->node);
- return CURLE_OK;
-}
-
-CURLcode Curl_hsts_parse(struct hsts *h, const char *hostname,
- const char *header)
-{
- const char *p = header;
- curl_off_t expires = 0;
- bool gotma = FALSE;
- bool gotinc = FALSE;
- bool subdomains = FALSE;
- struct stsentry *sts;
- time_t now = time(NULL);
-
- do {
- while(*p && ISSPACE(*p))
- p++;
- if(Curl_strncasecompare("max-age=", p, 8)) {
- bool quoted = FALSE;
- CURLofft offt;
- char *endp;
-
- if(gotma)
- return CURLE_BAD_FUNCTION_ARGUMENT;
-
- p += 8;
- while(*p && ISSPACE(*p))
- p++;
- if(*p == '\"') {
- p++;
- quoted = TRUE;
- }
- offt = curlx_strtoofft(p, &endp, 10, &expires);
- if(offt == CURL_OFFT_FLOW)
- expires = CURL_OFF_T_MAX;
- else if(offt)
- /* invalid max-age */
- return CURLE_BAD_FUNCTION_ARGUMENT;
- p = endp;
- if(quoted) {
- if(*p != '\"')
- return CURLE_BAD_FUNCTION_ARGUMENT;
- p++;
- }
- gotma = TRUE;
- }
- else if(Curl_strncasecompare("includesubdomains", p, 17)) {
- if(gotinc)
- return CURLE_BAD_FUNCTION_ARGUMENT;
- subdomains = TRUE;
- p += 17;
- gotinc = TRUE;
- }
- else {
- /* unknown directive, do a lame attempt to skip */
- while(*p && (*p != ';'))
- p++;
- }
-
- while(*p && ISSPACE(*p))
- p++;
- if(*p == ';')
- p++;
- } while (*p);
-
- if(!gotma)
- /* max-age is mandatory */
- return CURLE_BAD_FUNCTION_ARGUMENT;
-
- if(!expires) {
- /* remove the entry if present verbatim (without subdomain match) */
- sts = Curl_hsts(h, hostname, FALSE);
- if(sts) {
- Curl_llist_remove(&h->list, &sts->node, NULL);
- hsts_free(sts);
- }
- return CURLE_OK;
- }
-
- if(CURL_OFF_T_MAX - now < expires)
- /* would overflow, use maximum value */
- expires = CURL_OFF_T_MAX;
- else
- expires += now;
-
- /* check if it already exists */
- sts = Curl_hsts(h, hostname, FALSE);
- if(sts) {
- /* just update these fields */
- sts->expires = expires;
- sts->includeSubDomains = subdomains;
- }
- else
- return hsts_create(h, hostname, subdomains, expires);
-
- return CURLE_OK;
-}
-
-/*
- * Return TRUE if the given host name is currently an HSTS one.
- *
- * The 'subdomain' argument tells the function if subdomain matching should be
- * attempted.
- */
-struct stsentry *Curl_hsts(struct hsts *h, const char *hostname,
- bool subdomain)
-{
- if(h) {
- time_t now = time(NULL);
- size_t hlen = strlen(hostname);
- struct Curl_llist_element *e;
- struct Curl_llist_element *n;
- for(e = h->list.head; e; e = n) {
- struct stsentry *sts = e->ptr;
- n = e->next;
- if(sts->expires <= now) {
- /* remove expired entries */
- Curl_llist_remove(&h->list, &sts->node, NULL);
- hsts_free(sts);
- continue;
- }
- if(subdomain && sts->includeSubDomains) {
- size_t ntail = strlen(sts->host);
- if(ntail < hlen) {
- size_t offs = hlen - ntail;
- if((hostname[offs-1] == '.') &&
- Curl_strncasecompare(&hostname[offs], sts->host, ntail))
- return sts;
- }
- }
- if(Curl_strcasecompare(hostname, sts->host))
- return sts;
- }
- }
- return NULL; /* no match */
-}
-
-/*
- * Send this HSTS entry to the write callback.
- */
-static CURLcode hsts_push(struct Curl_easy *data,
- struct curl_index *i,
- struct stsentry *sts,
- bool *stop)
-{
- struct curl_hstsentry e;
- CURLSTScode sc;
- struct tm stamp;
- CURLcode result;
-
- e.name = (char *)sts->host;
- e.namelen = strlen(sts->host);
- e.includeSubDomains = sts->includeSubDomains;
-
- result = Curl_gmtime(sts->expires, &stamp);
- if(result)
- return result;
-
- msnprintf(e.expire, sizeof(e.expire), "%d%02d%02d %02d:%02d:%02d",
- stamp.tm_year + 1900, stamp.tm_mon + 1, stamp.tm_mday,
- stamp.tm_hour, stamp.tm_min, stamp.tm_sec);
-
- sc = data->set.hsts_write(data, &e, i,
- data->set.hsts_write_userp);
- *stop = (sc != CURLSTS_OK);
- return sc == CURLSTS_FAIL ? CURLE_BAD_FUNCTION_ARGUMENT : CURLE_OK;
-}
-
-/*
- * Write this single hsts entry to a single output line
- */
-static CURLcode hsts_out(struct stsentry *sts, FILE *fp)
-{
- struct tm stamp;
- CURLcode result = Curl_gmtime(sts->expires, &stamp);
- if(result)
- return result;
-
- fprintf(fp, "%s%s \"%d%02d%02d %02d:%02d:%02d\"\n",
- sts->includeSubDomains ? ".": "", sts->host,
- stamp.tm_year + 1900, stamp.tm_mon + 1, stamp.tm_mday,
- stamp.tm_hour, stamp.tm_min, stamp.tm_sec);
- return CURLE_OK;
-}
-
-
-/*
- * Curl_https_save() writes the HSTS cache to file and callback.
- */
-CURLcode Curl_hsts_save(struct Curl_easy *data, struct hsts *h,
- const char *file)
-{
- struct Curl_llist_element *e;
- struct Curl_llist_element *n;
- CURLcode result = CURLE_OK;
- FILE *out;
- char *tempstore;
- unsigned char randsuffix[9];
-
- if(!h)
- /* no cache activated */
- return CURLE_OK;
-
- /* if not new name is given, use the one we stored from the load */
- if(!file && h->filename)
- file = h->filename;
-
- if((h->flags & CURLHSTS_READONLYFILE) || !file || !file[0])
- /* marked as read-only, no file or zero length file name */
- goto skipsave;
-
- if(Curl_rand_hex(data, randsuffix, sizeof(randsuffix)))
- return CURLE_FAILED_INIT;
-
- tempstore = aprintf("%s.%s.tmp", file, randsuffix);
- if(!tempstore)
- return CURLE_OUT_OF_MEMORY;
-
- out = fopen(tempstore, FOPEN_WRITETEXT);
- if(!out)
- result = CURLE_WRITE_ERROR;
- else {
- fputs("# Your HSTS cache. https://curl.se/docs/hsts.html\n"
- "# This file was generated by libcurl! Edit at your own risk.\n",
- out);
- for(e = h->list.head; e; e = n) {
- struct stsentry *sts = e->ptr;
- n = e->next;
- result = hsts_out(sts, out);
- if(result)
- break;
- }
- fclose(out);
- if(!result && Curl_rename(tempstore, file))
- result = CURLE_WRITE_ERROR;
-
- if(result)
- unlink(tempstore);
- }
- free(tempstore);
- skipsave:
- if(data->set.hsts_write) {
- /* if there's a write callback */
- struct curl_index i; /* count */
- i.total = h->list.size;
- i.index = 0;
- for(e = h->list.head; e; e = n) {
- struct stsentry *sts = e->ptr;
- bool stop;
- n = e->next;
- result = hsts_push(data, &i, sts, &stop);
- if(result || stop)
- break;
- i.index++;
- }
- }
- return result;
-}
-
-/* only returns SERIOUS errors */
-static CURLcode hsts_add(struct hsts *h, char *line)
-{
- /* Example lines:
- example.com "20191231 10:00:00"
- .example.net "20191231 10:00:00"
- */
- char host[MAX_HSTS_HOSTLEN + 1];
- char date[MAX_HSTS_DATELEN + 1];
- int rc;
-
- rc = sscanf(line,
- "%" MAX_HSTS_HOSTLENSTR "s \"%" MAX_HSTS_DATELENSTR "[^\"]\"",
- host, date);
- if(2 == rc) {
- time_t expires = Curl_getdate_capped(date);
- CURLcode result;
- char *p = host;
- bool subdomain = FALSE;
- if(p[0] == '.') {
- p++;
- subdomain = TRUE;
- }
- result = hsts_create(h, p, subdomain, expires);
- if(result)
- return result;
- }
-
- return CURLE_OK;
-}
-
-/*
- * Load HSTS data from callback.
- *
- */
-static CURLcode hsts_pull(struct Curl_easy *data, struct hsts *h)
-{
- /* if the HSTS read callback is set, use it */
- if(data->set.hsts_read) {
- CURLSTScode sc;
- DEBUGASSERT(h);
- do {
- char buffer[257];
- struct curl_hstsentry e;
- e.name = buffer;
- e.namelen = sizeof(buffer)-1;
- e.includeSubDomains = FALSE; /* default */
- e.expire[0] = 0;
- e.name[0] = 0; /* just to make it clean */
- sc = data->set.hsts_read(data, &e, data->set.hsts_read_userp);
- if(sc == CURLSTS_OK) {
- time_t expires;
- CURLcode result;
- if(!e.name[0])
- /* bail out if no name was stored */
- return CURLE_BAD_FUNCTION_ARGUMENT;
- if(e.expire[0])
- expires = Curl_getdate_capped(e.expire);
- else
- expires = TIME_T_MAX; /* the end of time */
- result = hsts_create(h, e.name, e.includeSubDomains, expires);
- if(result)
- return result;
- }
- else if(sc == CURLSTS_FAIL)
- return CURLE_BAD_FUNCTION_ARGUMENT;
- } while(sc == CURLSTS_OK);
- }
- return CURLE_OK;
-}
-
-/*
- * Load the HSTS cache from the given file. The text based line-oriented file
- * format is documented here:
- * https://github.com/curl/curl/wiki/HSTS
- *
- * This function only returns error on major problems that prevents hsts
- * handling to work completely. It will ignore individual syntactical errors
- * etc.
- */
-static CURLcode hsts_load(struct hsts *h, const char *file)
-{
- CURLcode result = CURLE_OK;
- char *line = NULL;
- FILE *fp;
-
- /* we need a private copy of the file name so that the hsts cache file
- name survives an easy handle reset */
- free(h->filename);
- h->filename = strdup(file);
- if(!h->filename)
- return CURLE_OUT_OF_MEMORY;
-
- fp = fopen(file, FOPEN_READTEXT);
- if(fp) {
- line = malloc(MAX_HSTS_LINE);
- if(!line)
- goto fail;
- while(Curl_get_line(line, MAX_HSTS_LINE, fp)) {
- char *lineptr = line;
- while(*lineptr && ISBLANK(*lineptr))
- lineptr++;
- if(*lineptr == '#')
- /* skip commented lines */
- continue;
-
- hsts_add(h, lineptr);
- }
- free(line); /* free the line buffer */
- fclose(fp);
- }
- return result;
-
- fail:
- Curl_safefree(h->filename);
- fclose(fp);
- return CURLE_OUT_OF_MEMORY;
-}
-
-/*
- * Curl_hsts_loadfile() loads HSTS from file
- */
-CURLcode Curl_hsts_loadfile(struct Curl_easy *data,
- struct hsts *h, const char *file)
-{
- DEBUGASSERT(h);
- (void)data;
- return hsts_load(h, file);
-}
-
-/*
- * Curl_hsts_loadcb() loads HSTS from callback
- */
-CURLcode Curl_hsts_loadcb(struct Curl_easy *data, struct hsts *h)
-{
- return hsts_pull(data, h);
-}
-
-#endif /* CURL_DISABLE_HTTP || USE_HSTS */
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 2020, 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
+ * are also available at https://curl.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+/*
+ * The Strict-Transport-Security header is defined in RFC 6797:
+ * https://tools.ietf.org/html/rfc6797
+ */
+#include "curl_setup.h"
+
+#if !defined(CURL_DISABLE_HTTP) && defined(USE_HSTS)
+#include <curl/curl.h>
+#include "urldata.h"
+#include "llist.h"
+#include "hsts.h"
+#include "curl_get_line.h"
+#include "strcase.h"
+#include "sendf.h"
+#include "strtoofft.h"
+#include "parsedate.h"
+#include "rand.h"
+#include "rename.h"
+
+/* The last 3 #include files should be in this order */
+#include "curl_printf.h"
+#include "curl_memory.h"
+#include "memdebug.h"
+
+#define MAX_HSTS_LINE 4095
+#define MAX_HSTS_HOSTLEN 256
+#define MAX_HSTS_HOSTLENSTR "256"
+#define MAX_HSTS_SUBLEN 4
+#define MAX_HSTS_SUBLENSTR "4"
+#define MAX_HSTS_DATELEN 64
+#define MAX_HSTS_DATELENSTR "64"
+
+#ifdef DEBUGBUILD
+/* to play well with debug builds, we can *set* a fixed time this will
+ return */
+time_t deltatime; /* allow for "adjustments" for unit test purposes */
+static time_t debugtime(void *unused)
+{
+ char *timestr = getenv("CURL_TIME");
+ (void)unused;
+ if(timestr) {
+ unsigned long val = strtol(timestr, NULL, 10) + deltatime;
+ return (time_t)val;
+ }
+ return time(NULL);
+}
+#define time(x) debugtime(x)
+#endif
+
+struct hsts *Curl_hsts_init(void)
+{
+ struct hsts *h = calloc(sizeof(struct hsts), 1);
+ if(h) {
+ Curl_llist_init(&h->list, NULL);
+ }
+ return h;
+}
+
+static void hsts_free(struct stsentry *e)
+{
+ free((char *)e->host);
+ free(e);
+}
+
+void Curl_hsts_cleanup(struct hsts **hp)
+{
+ struct hsts *h = *hp;
+ if(h) {
+ struct Curl_llist_element *e;
+ struct Curl_llist_element *n;
+ for(e = h->list.head; e; e = n) {
+ struct stsentry *sts = e->ptr;
+ n = e->next;
+ hsts_free(sts);
+ }
+ free(h->filename);
+ free(h);
+ *hp = NULL;
+ }
+}
+
+static struct stsentry *hsts_entry(void)
+{
+ return calloc(sizeof(struct stsentry), 1);
+}
+
+static CURLcode hsts_create(struct hsts *h,
+ const char *hostname,
+ bool subdomains,
+ curl_off_t expires)
+{
+ struct stsentry *sts = hsts_entry();
+ if(!sts)
+ return CURLE_OUT_OF_MEMORY;
+
+ sts->expires = expires;
+ sts->includeSubDomains = subdomains;
+ sts->host = strdup(hostname);
+ if(!sts->host) {
+ free(sts);
+ return CURLE_OUT_OF_MEMORY;
+ }
+ Curl_llist_insert_next(&h->list, h->list.tail, sts, &sts->node);
+ return CURLE_OK;
+}
+
+CURLcode Curl_hsts_parse(struct hsts *h, const char *hostname,
+ const char *header)
+{
+ const char *p = header;
+ curl_off_t expires = 0;
+ bool gotma = FALSE;
+ bool gotinc = FALSE;
+ bool subdomains = FALSE;
+ struct stsentry *sts;
+ time_t now = time(NULL);
+
+ do {
+ while(*p && ISSPACE(*p))
+ p++;
+ if(Curl_strncasecompare("max-age=", p, 8)) {
+ bool quoted = FALSE;
+ CURLofft offt;
+ char *endp;
+
+ if(gotma)
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+
+ p += 8;
+ while(*p && ISSPACE(*p))
+ p++;
+ if(*p == '\"') {
+ p++;
+ quoted = TRUE;
+ }
+ offt = curlx_strtoofft(p, &endp, 10, &expires);
+ if(offt == CURL_OFFT_FLOW)
+ expires = CURL_OFF_T_MAX;
+ else if(offt)
+ /* invalid max-age */
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+ p = endp;
+ if(quoted) {
+ if(*p != '\"')
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+ p++;
+ }
+ gotma = TRUE;
+ }
+ else if(Curl_strncasecompare("includesubdomains", p, 17)) {
+ if(gotinc)
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+ subdomains = TRUE;
+ p += 17;
+ gotinc = TRUE;
+ }
+ else {
+ /* unknown directive, do a lame attempt to skip */
+ while(*p && (*p != ';'))
+ p++;
+ }
+
+ while(*p && ISSPACE(*p))
+ p++;
+ if(*p == ';')
+ p++;
+ } while (*p);
+
+ if(!gotma)
+ /* max-age is mandatory */
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+
+ if(!expires) {
+ /* remove the entry if present verbatim (without subdomain match) */
+ sts = Curl_hsts(h, hostname, FALSE);
+ if(sts) {
+ Curl_llist_remove(&h->list, &sts->node, NULL);
+ hsts_free(sts);
+ }
+ return CURLE_OK;
+ }
+
+ if(CURL_OFF_T_MAX - now < expires)
+ /* would overflow, use maximum value */
+ expires = CURL_OFF_T_MAX;
+ else
+ expires += now;
+
+ /* check if it already exists */
+ sts = Curl_hsts(h, hostname, FALSE);
+ if(sts) {
+ /* just update these fields */
+ sts->expires = expires;
+ sts->includeSubDomains = subdomains;
+ }
+ else
+ return hsts_create(h, hostname, subdomains, expires);
+
+ return CURLE_OK;
+}
+
+/*
+ * Return TRUE if the given host name is currently an HSTS one.
+ *
+ * The 'subdomain' argument tells the function if subdomain matching should be
+ * attempted.
+ */
+struct stsentry *Curl_hsts(struct hsts *h, const char *hostname,
+ bool subdomain)
+{
+ if(h) {
+ time_t now = time(NULL);
+ size_t hlen = strlen(hostname);
+ struct Curl_llist_element *e;
+ struct Curl_llist_element *n;
+ for(e = h->list.head; e; e = n) {
+ struct stsentry *sts = e->ptr;
+ n = e->next;
+ if(sts->expires <= now) {
+ /* remove expired entries */
+ Curl_llist_remove(&h->list, &sts->node, NULL);
+ hsts_free(sts);
+ continue;
+ }
+ if(subdomain && sts->includeSubDomains) {
+ size_t ntail = strlen(sts->host);
+ if(ntail < hlen) {
+ size_t offs = hlen - ntail;
+ if((hostname[offs-1] == '.') &&
+ Curl_strncasecompare(&hostname[offs], sts->host, ntail))
+ return sts;
+ }
+ }
+ if(Curl_strcasecompare(hostname, sts->host))
+ return sts;
+ }
+ }
+ return NULL; /* no match */
+}
+
+/*
+ * Send this HSTS entry to the write callback.
+ */
+static CURLcode hsts_push(struct Curl_easy *data,
+ struct curl_index *i,
+ struct stsentry *sts,
+ bool *stop)
+{
+ struct curl_hstsentry e;
+ CURLSTScode sc;
+ struct tm stamp;
+ CURLcode result;
+
+ e.name = (char *)sts->host;
+ e.namelen = strlen(sts->host);
+ e.includeSubDomains = sts->includeSubDomains;
+
+ result = Curl_gmtime(sts->expires, &stamp);
+ if(result)
+ return result;
+
+ msnprintf(e.expire, sizeof(e.expire), "%d%02d%02d %02d:%02d:%02d",
+ stamp.tm_year + 1900, stamp.tm_mon + 1, stamp.tm_mday,
+ stamp.tm_hour, stamp.tm_min, stamp.tm_sec);
+
+ sc = data->set.hsts_write(data, &e, i,
+ data->set.hsts_write_userp);
+ *stop = (sc != CURLSTS_OK);
+ return sc == CURLSTS_FAIL ? CURLE_BAD_FUNCTION_ARGUMENT : CURLE_OK;
+}
+
+/*
+ * Write this single hsts entry to a single output line
+ */
+static CURLcode hsts_out(struct stsentry *sts, FILE *fp)
+{
+ struct tm stamp;
+ CURLcode result = Curl_gmtime(sts->expires, &stamp);
+ if(result)
+ return result;
+
+ fprintf(fp, "%s%s \"%d%02d%02d %02d:%02d:%02d\"\n",
+ sts->includeSubDomains ? ".": "", sts->host,
+ stamp.tm_year + 1900, stamp.tm_mon + 1, stamp.tm_mday,
+ stamp.tm_hour, stamp.tm_min, stamp.tm_sec);
+ return CURLE_OK;
+}
+
+
+/*
+ * Curl_https_save() writes the HSTS cache to file and callback.
+ */
+CURLcode Curl_hsts_save(struct Curl_easy *data, struct hsts *h,
+ const char *file)
+{
+ struct Curl_llist_element *e;
+ struct Curl_llist_element *n;
+ CURLcode result = CURLE_OK;
+ FILE *out;
+ char *tempstore;
+ unsigned char randsuffix[9];
+
+ if(!h)
+ /* no cache activated */
+ return CURLE_OK;
+
+ /* if not new name is given, use the one we stored from the load */
+ if(!file && h->filename)
+ file = h->filename;
+
+ if((h->flags & CURLHSTS_READONLYFILE) || !file || !file[0])
+ /* marked as read-only, no file or zero length file name */
+ goto skipsave;
+
+ if(Curl_rand_hex(data, randsuffix, sizeof(randsuffix)))
+ return CURLE_FAILED_INIT;
+
+ tempstore = aprintf("%s.%s.tmp", file, randsuffix);
+ if(!tempstore)
+ return CURLE_OUT_OF_MEMORY;
+
+ out = fopen(tempstore, FOPEN_WRITETEXT);
+ if(!out)
+ result = CURLE_WRITE_ERROR;
+ else {
+ fputs("# Your HSTS cache. https://curl.se/docs/hsts.html\n"
+ "# This file was generated by libcurl! Edit at your own risk.\n",
+ out);
+ for(e = h->list.head; e; e = n) {
+ struct stsentry *sts = e->ptr;
+ n = e->next;
+ result = hsts_out(sts, out);
+ if(result)
+ break;
+ }
+ fclose(out);
+ if(!result && Curl_rename(tempstore, file))
+ result = CURLE_WRITE_ERROR;
+
+ if(result)
+ unlink(tempstore);
+ }
+ free(tempstore);
+ skipsave:
+ if(data->set.hsts_write) {
+ /* if there's a write callback */
+ struct curl_index i; /* count */
+ i.total = h->list.size;
+ i.index = 0;
+ for(e = h->list.head; e; e = n) {
+ struct stsentry *sts = e->ptr;
+ bool stop;
+ n = e->next;
+ result = hsts_push(data, &i, sts, &stop);
+ if(result || stop)
+ break;
+ i.index++;
+ }
+ }
+ return result;
+}
+
+/* only returns SERIOUS errors */
+static CURLcode hsts_add(struct hsts *h, char *line)
+{
+ /* Example lines:
+ example.com "20191231 10:00:00"
+ .example.net "20191231 10:00:00"
+ */
+ char host[MAX_HSTS_HOSTLEN + 1];
+ char date[MAX_HSTS_DATELEN + 1];
+ int rc;
+
+ rc = sscanf(line,
+ "%" MAX_HSTS_HOSTLENSTR "s \"%" MAX_HSTS_DATELENSTR "[^\"]\"",
+ host, date);
+ if(2 == rc) {
+ time_t expires = Curl_getdate_capped(date);
+ CURLcode result;
+ char *p = host;
+ bool subdomain = FALSE;
+ if(p[0] == '.') {
+ p++;
+ subdomain = TRUE;
+ }
+ result = hsts_create(h, p, subdomain, expires);
+ if(result)
+ return result;
+ }
+
+ return CURLE_OK;
+}
+
+/*
+ * Load HSTS data from callback.
+ *
+ */
+static CURLcode hsts_pull(struct Curl_easy *data, struct hsts *h)
+{
+ /* if the HSTS read callback is set, use it */
+ if(data->set.hsts_read) {
+ CURLSTScode sc;
+ DEBUGASSERT(h);
+ do {
+ char buffer[257];
+ struct curl_hstsentry e;
+ e.name = buffer;
+ e.namelen = sizeof(buffer)-1;
+ e.includeSubDomains = FALSE; /* default */
+ e.expire[0] = 0;
+ e.name[0] = 0; /* just to make it clean */
+ sc = data->set.hsts_read(data, &e, data->set.hsts_read_userp);
+ if(sc == CURLSTS_OK) {
+ time_t expires;
+ CURLcode result;
+ if(!e.name[0])
+ /* bail out if no name was stored */
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+ if(e.expire[0])
+ expires = Curl_getdate_capped(e.expire);
+ else
+ expires = TIME_T_MAX; /* the end of time */
+ result = hsts_create(h, e.name, e.includeSubDomains, expires);
+ if(result)
+ return result;
+ }
+ else if(sc == CURLSTS_FAIL)
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+ } while(sc == CURLSTS_OK);
+ }
+ return CURLE_OK;
+}
+
+/*
+ * Load the HSTS cache from the given file. The text based line-oriented file
+ * format is documented here:
+ * https://github.com/curl/curl/wiki/HSTS
+ *
+ * This function only returns error on major problems that prevents hsts
+ * handling to work completely. It will ignore individual syntactical errors
+ * etc.
+ */
+static CURLcode hsts_load(struct hsts *h, const char *file)
+{
+ CURLcode result = CURLE_OK;
+ char *line = NULL;
+ FILE *fp;
+
+ /* we need a private copy of the file name so that the hsts cache file
+ name survives an easy handle reset */
+ free(h->filename);
+ h->filename = strdup(file);
+ if(!h->filename)
+ return CURLE_OUT_OF_MEMORY;
+
+ fp = fopen(file, FOPEN_READTEXT);
+ if(fp) {
+ line = malloc(MAX_HSTS_LINE);
+ if(!line)
+ goto fail;
+ while(Curl_get_line(line, MAX_HSTS_LINE, fp)) {
+ char *lineptr = line;
+ while(*lineptr && ISBLANK(*lineptr))
+ lineptr++;
+ if(*lineptr == '#')
+ /* skip commented lines */
+ continue;
+
+ hsts_add(h, lineptr);
+ }
+ free(line); /* free the line buffer */
+ fclose(fp);
+ }
+ return result;
+
+ fail:
+ Curl_safefree(h->filename);
+ fclose(fp);
+ return CURLE_OUT_OF_MEMORY;
+}
+
+/*
+ * Curl_hsts_loadfile() loads HSTS from file
+ */
+CURLcode Curl_hsts_loadfile(struct Curl_easy *data,
+ struct hsts *h, const char *file)
+{
+ DEBUGASSERT(h);
+ (void)data;
+ return hsts_load(h, file);
+}
+
+/*
+ * Curl_hsts_loadcb() loads HSTS from callback
+ */
+CURLcode Curl_hsts_loadcb(struct Curl_easy *data, struct hsts *h)
+{
+ return hsts_pull(data, h);
+}
+
+#endif /* CURL_DISABLE_HTTP || USE_HSTS */
diff --git a/contrib/libs/curl/lib/hsts.h b/contrib/libs/curl/lib/hsts.h
index 4d3b3ca9cc..ae5db74a24 100644
--- a/contrib/libs/curl/lib/hsts.h
+++ b/contrib/libs/curl/lib/hsts.h
@@ -1,65 +1,65 @@
-#ifndef HEADER_CURL_HSTS_H
-#define HEADER_CURL_HSTS_H
-/***************************************************************************
- * _ _ ____ _
- * Project ___| | | | _ \| |
- * / __| | | | |_) | |
- * | (__| |_| | _ <| |___
- * \___|\___/|_| \_\_____|
- *
- * Copyright (C) 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
- *
- * You may opt to use, copy, modify, merge, publish, distribute and/or sell
- * copies of the Software, and permit persons to whom the Software is
- * furnished to do so, under the terms of the COPYING file.
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- ***************************************************************************/
-#include "curl_setup.h"
-
-#if !defined(CURL_DISABLE_HTTP) && defined(USE_HSTS)
-#include <curl/curl.h>
-#include "llist.h"
-
-#ifdef DEBUGBUILD
-extern time_t deltatime;
-#endif
-
-struct stsentry {
- struct Curl_llist_element node;
- const char *host;
- bool includeSubDomains;
- time_t expires; /* the timestamp of this entry's expiry */
-};
-
-/* The HSTS cache. Needs to be able to tailmatch host names. */
-struct hsts {
- struct Curl_llist list;
- char *filename;
- unsigned int flags;
-};
-
-struct hsts *Curl_hsts_init(void);
-void Curl_hsts_cleanup(struct hsts **hp);
-CURLcode Curl_hsts_parse(struct hsts *h, const char *hostname,
- const char *sts);
-struct stsentry *Curl_hsts(struct hsts *h, const char *hostname,
- bool subdomain);
-CURLcode Curl_hsts_save(struct Curl_easy *data, struct hsts *h,
- const char *file);
-CURLcode Curl_hsts_loadfile(struct Curl_easy *data,
- struct hsts *h, const char *file);
-CURLcode Curl_hsts_loadcb(struct Curl_easy *data,
- struct hsts *h);
-#else
-#define Curl_hsts_cleanup(x)
-#define Curl_hsts_loadcb(x,y)
-#define Curl_hsts_save(x,y,z)
-#endif /* CURL_DISABLE_HTTP || USE_HSTS */
-#endif /* HEADER_CURL_HSTS_H */
+#ifndef HEADER_CURL_HSTS_H
+#define HEADER_CURL_HSTS_H
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 2020, 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
+ * are also available at https://curl.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+#include "curl_setup.h"
+
+#if !defined(CURL_DISABLE_HTTP) && defined(USE_HSTS)
+#include <curl/curl.h>
+#include "llist.h"
+
+#ifdef DEBUGBUILD
+extern time_t deltatime;
+#endif
+
+struct stsentry {
+ struct Curl_llist_element node;
+ const char *host;
+ bool includeSubDomains;
+ time_t expires; /* the timestamp of this entry's expiry */
+};
+
+/* The HSTS cache. Needs to be able to tailmatch host names. */
+struct hsts {
+ struct Curl_llist list;
+ char *filename;
+ unsigned int flags;
+};
+
+struct hsts *Curl_hsts_init(void);
+void Curl_hsts_cleanup(struct hsts **hp);
+CURLcode Curl_hsts_parse(struct hsts *h, const char *hostname,
+ const char *sts);
+struct stsentry *Curl_hsts(struct hsts *h, const char *hostname,
+ bool subdomain);
+CURLcode Curl_hsts_save(struct Curl_easy *data, struct hsts *h,
+ const char *file);
+CURLcode Curl_hsts_loadfile(struct Curl_easy *data,
+ struct hsts *h, const char *file);
+CURLcode Curl_hsts_loadcb(struct Curl_easy *data,
+ struct hsts *h);
+#else
+#define Curl_hsts_cleanup(x)
+#define Curl_hsts_loadcb(x,y)
+#define Curl_hsts_save(x,y,z)
+#endif /* CURL_DISABLE_HTTP || USE_HSTS */
+#endif /* HEADER_CURL_HSTS_H */
diff --git a/contrib/libs/curl/lib/http.c b/contrib/libs/curl/lib/http.c
index 9db4499040..c232ed4134 100644
--- a/contrib/libs/curl/lib/http.c
+++ b/contrib/libs/curl/lib/http.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -77,7 +77,7 @@
#include "connect.h"
#include "strdup.h"
#include "altsvc.h"
-#include "hsts.h"
+#include "hsts.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
@@ -126,9 +126,9 @@ const struct Curl_handler Curl_handler_http = {
ZERO_NULL, /* connection_check */
PORT_HTTP, /* defport */
CURLPROTO_HTTP, /* protocol */
- CURLPROTO_HTTP, /* family */
- PROTOPT_CREDSPERREQUEST | /* flags */
- PROTOPT_USERPWDCTRL
+ CURLPROTO_HTTP, /* family */
+ PROTOPT_CREDSPERREQUEST | /* flags */
+ PROTOPT_USERPWDCTRL
};
#ifdef USE_SSL
@@ -153,9 +153,9 @@ const struct Curl_handler Curl_handler_https = {
ZERO_NULL, /* connection_check */
PORT_HTTPS, /* defport */
CURLPROTO_HTTPS, /* protocol */
- CURLPROTO_HTTP, /* family */
- PROTOPT_SSL | PROTOPT_CREDSPERREQUEST | PROTOPT_ALPN_NPN | /* flags */
- PROTOPT_USERPWDCTRL
+ CURLPROTO_HTTP, /* family */
+ PROTOPT_SSL | PROTOPT_CREDSPERREQUEST | PROTOPT_ALPN_NPN | /* flags */
+ PROTOPT_USERPWDCTRL
};
#endif
@@ -165,14 +165,14 @@ static CURLcode http_setup_conn(struct connectdata *conn)
during this request */
struct HTTP *http;
struct Curl_easy *data = conn->data;
- DEBUGASSERT(data->req.p.http == NULL);
+ DEBUGASSERT(data->req.p.http == NULL);
http = calloc(1, sizeof(struct HTTP));
if(!http)
return CURLE_OUT_OF_MEMORY;
Curl_mime_initpart(&http->form, conn->data);
- data->req.p.http = http;
+ data->req.p.http = http;
if(data->set.httpversion == CURL_HTTP_VERSION_3) {
if(conn->handler->flags & PROTOPT_SSL)
@@ -273,7 +273,7 @@ char *Curl_copy_header_value(const char *header)
return NULL;
memcpy(value, start, len);
- value[len] = 0; /* null-terminate */
+ value[len] = 0; /* null-terminate */
return value;
}
@@ -297,21 +297,21 @@ static CURLcode http_output_basic(struct connectdata *conn, bool proxy)
char *out;
if(proxy) {
-#ifndef CURL_DISABLE_PROXY
- userp = &data->state.aptr.proxyuserpwd;
+#ifndef CURL_DISABLE_PROXY
+ userp = &data->state.aptr.proxyuserpwd;
user = conn->http_proxy.user;
pwd = conn->http_proxy.passwd;
-#else
- return CURLE_NOT_BUILT_IN;
-#endif
+#else
+ return CURLE_NOT_BUILT_IN;
+#endif
}
else {
- userp = &data->state.aptr.userpwd;
+ userp = &data->state.aptr.userpwd;
user = conn->user;
pwd = conn->passwd;
}
- out = aprintf("%s:%s", user, pwd ? pwd : "");
+ out = aprintf("%s:%s", user, pwd ? pwd : "");
if(!out)
return CURLE_OUT_OF_MEMORY;
@@ -349,12 +349,12 @@ static CURLcode http_output_bearer(struct connectdata *conn)
{
char **userp;
CURLcode result = CURLE_OK;
- struct Curl_easy *data = conn->data;
+ struct Curl_easy *data = conn->data;
- userp = &data->state.aptr.userpwd;
+ userp = &data->state.aptr.userpwd;
free(*userp);
*userp = aprintf("Authorization: Bearer %s\r\n",
- conn->data->set.str[STRING_BEARER]);
+ conn->data->set.str[STRING_BEARER]);
if(!*userp) {
result = CURLE_OUT_OF_MEMORY;
@@ -428,7 +428,7 @@ static bool pickoneauth(struct auth *pick, unsigned long mask)
static CURLcode http_perhapsrewind(struct connectdata *conn)
{
struct Curl_easy *data = conn->data;
- struct HTTP *http = data->req.p.http;
+ struct HTTP *http = data->req.p.http;
curl_off_t bytessent;
curl_off_t expectsend = -1; /* default is unknown */
@@ -437,7 +437,7 @@ static CURLcode http_perhapsrewind(struct connectdata *conn)
skip this rewinding stuff */
return CURLE_OK;
- switch(data->state.httpreq) {
+ switch(data->state.httpreq) {
case HTTPREQ_GET:
case HTTPREQ_HEAD:
return CURLE_OK;
@@ -458,7 +458,7 @@ static CURLcode http_perhapsrewind(struct connectdata *conn)
}
else {
/* figure out how much data we are expected to send */
- switch(data->state.httpreq) {
+ switch(data->state.httpreq) {
case HTTPREQ_POST:
case HTTPREQ_PUT:
if(data->state.infilesize != -1)
@@ -565,7 +565,7 @@ CURLcode Curl_http_auth_act(struct connectdata *conn)
CURLcode result = CURLE_OK;
unsigned long authmask = ~0ul;
- if(!data->set.str[STRING_BEARER])
+ if(!data->set.str[STRING_BEARER])
authmask &= (unsigned long)~CURLAUTH_BEARER;
if(100 <= data->req.httpcode && 199 >= data->req.httpcode)
@@ -575,7 +575,7 @@ CURLcode Curl_http_auth_act(struct connectdata *conn)
if(data->state.authproblem)
return data->set.http_fail_on_error?CURLE_HTTP_RETURNED_ERROR:CURLE_OK;
- if((conn->bits.user_passwd || data->set.str[STRING_BEARER]) &&
+ if((conn->bits.user_passwd || data->set.str[STRING_BEARER]) &&
((data->req.httpcode == 401) ||
(conn->bits.authneg && data->req.httpcode < 300))) {
pickhost = pickoneauth(&data->state.authhost, authmask);
@@ -588,7 +588,7 @@ CURLcode Curl_http_auth_act(struct connectdata *conn)
conn->data->set.httpversion = CURL_HTTP_VERSION_1_1;
}
}
-#ifndef CURL_DISABLE_PROXY
+#ifndef CURL_DISABLE_PROXY
if(conn->bits.proxy_user_passwd &&
((data->req.httpcode == 407) ||
(conn->bits.authneg && data->req.httpcode < 300))) {
@@ -597,11 +597,11 @@ CURLcode Curl_http_auth_act(struct connectdata *conn)
if(!pickproxy)
data->state.authproblem = TRUE;
}
-#endif
+#endif
if(pickhost || pickproxy) {
- if((data->state.httpreq != HTTPREQ_GET) &&
- (data->state.httpreq != HTTPREQ_HEAD) &&
+ if((data->state.httpreq != HTTPREQ_GET) &&
+ (data->state.httpreq != HTTPREQ_HEAD) &&
!conn->bits.rewindaftersend) {
result = http_perhapsrewind(conn);
if(result)
@@ -622,8 +622,8 @@ CURLcode Curl_http_auth_act(struct connectdata *conn)
authentication is not "done" yet and
no authentication seems to be required and
we didn't try HEAD or GET */
- if((data->state.httpreq != HTTPREQ_GET) &&
- (data->state.httpreq != HTTPREQ_HEAD)) {
+ if((data->state.httpreq != HTTPREQ_GET) &&
+ (data->state.httpreq != HTTPREQ_HEAD)) {
data->req.newurl = strdup(data->change.url); /* clone URL */
if(!data->req.newurl)
return CURLE_OUT_OF_MEMORY;
@@ -701,13 +701,13 @@ output_auth_headers(struct connectdata *conn,
#endif
if(authstatus->picked == CURLAUTH_BASIC) {
/* Basic */
- if(
-#ifndef CURL_DISABLE_PROXY
- (proxy && conn->bits.proxy_user_passwd &&
- !Curl_checkProxyheaders(conn, "Proxy-authorization")) ||
-#endif
- (!proxy && conn->bits.user_passwd &&
- !Curl_checkheaders(conn, "Authorization"))) {
+ if(
+#ifndef CURL_DISABLE_PROXY
+ (proxy && conn->bits.proxy_user_passwd &&
+ !Curl_checkProxyheaders(conn, "Proxy-authorization")) ||
+#endif
+ (!proxy && conn->bits.user_passwd &&
+ !Curl_checkheaders(conn, "Authorization"))) {
auth = "Basic";
result = http_output_basic(conn, proxy);
if(result)
@@ -720,7 +720,7 @@ output_auth_headers(struct connectdata *conn,
}
if(authstatus->picked == CURLAUTH_BEARER) {
/* Bearer */
- if((!proxy && data->set.str[STRING_BEARER] &&
+ if((!proxy && data->set.str[STRING_BEARER] &&
!Curl_checkheaders(conn, "Authorization:"))) {
auth = "Bearer";
result = http_output_bearer(conn);
@@ -734,15 +734,15 @@ output_auth_headers(struct connectdata *conn,
}
if(auth) {
-#ifndef CURL_DISABLE_PROXY
+#ifndef CURL_DISABLE_PROXY
infof(data, "%s auth using %s with user '%s'\n",
proxy ? "Proxy" : "Server", auth,
proxy ? (conn->http_proxy.user ? conn->http_proxy.user : "") :
- (conn->user ? conn->user : ""));
-#else
- infof(data, "Server auth using %s with user '%s'\n",
- auth, conn->user ? conn->user : "");
-#endif
+ (conn->user ? conn->user : ""));
+#else
+ infof(data, "Server auth using %s with user '%s'\n",
+ auth, conn->user ? conn->user : "");
+#endif
authstatus->multipass = (!authstatus->done) ? TRUE : FALSE;
}
else
@@ -782,11 +782,11 @@ Curl_http_output_auth(struct connectdata *conn,
authhost = &data->state.authhost;
authproxy = &data->state.authproxy;
- if(
-#ifndef CURL_DISABLE_PROXY
- (conn->bits.httpproxy && conn->bits.proxy_user_passwd) ||
-#endif
- conn->bits.user_passwd || data->set.str[STRING_BEARER])
+ if(
+#ifndef CURL_DISABLE_PROXY
+ (conn->bits.httpproxy && conn->bits.proxy_user_passwd) ||
+#endif
+ conn->bits.user_passwd || data->set.str[STRING_BEARER])
/* continue please */;
else {
authhost->done = TRUE;
@@ -1090,10 +1090,10 @@ static int http_should_fail(struct connectdata *conn)
*/
if((httpcode == 401) && !conn->bits.user_passwd)
return TRUE;
-#ifndef CURL_DISABLE_PROXY
+#ifndef CURL_DISABLE_PROXY
if((httpcode == 407) && !conn->bits.proxy_user_passwd)
return TRUE;
-#endif
+#endif
return data->state.authproblem;
}
@@ -1112,7 +1112,7 @@ static size_t readmoredata(char *buffer,
void *userp)
{
struct connectdata *conn = (struct connectdata *)userp;
- struct HTTP *http = conn->data->req.p.http;
+ struct HTTP *http = conn->data->req.p.http;
size_t fullsize = size * nitems;
if(!http->postsize)
@@ -1151,26 +1151,26 @@ static size_t readmoredata(char *buffer,
}
/*
- * Curl_buffer_send() sends a header buffer and frees all associated
+ * Curl_buffer_send() sends a header buffer and frees all associated
* memory. Body data may be appended to the header data if desired.
*
* Returns CURLcode
*/
-CURLcode Curl_buffer_send(struct dynbuf *in,
- struct connectdata *conn,
- /* add the number of sent bytes to this
- counter */
- curl_off_t *bytes_written,
- /* how much of the buffer contains body data */
- size_t included_body_bytes,
- int socketindex)
+CURLcode Curl_buffer_send(struct dynbuf *in,
+ struct connectdata *conn,
+ /* add the number of sent bytes to this
+ counter */
+ curl_off_t *bytes_written,
+ /* how much of the buffer contains body data */
+ size_t included_body_bytes,
+ int socketindex)
{
ssize_t amount;
CURLcode result;
char *ptr;
size_t size;
struct Curl_easy *data = conn->data;
- struct HTTP *http = data->req.p.http;
+ struct HTTP *http = data->req.p.http;
size_t sendsize;
curl_socket_t sockfd;
size_t headersize;
@@ -1182,8 +1182,8 @@ CURLcode Curl_buffer_send(struct dynbuf *in,
/* The looping below is required since we use non-blocking sockets, but due
to the circumstances we will just loop and try again and again etc */
- ptr = Curl_dyn_ptr(in);
- size = Curl_dyn_len(in);
+ ptr = Curl_dyn_ptr(in);
+ size = Curl_dyn_len(in);
headersize = size - included_body_bytes; /* the initial part that isn't body
is header */
@@ -1194,15 +1194,15 @@ CURLcode Curl_buffer_send(struct dynbuf *in,
/* Curl_convert_to_network calls failf if unsuccessful */
if(result) {
/* conversion failed, free memory and return to the caller */
- Curl_dyn_free(in);
+ Curl_dyn_free(in);
return result;
}
- if((conn->handler->flags & PROTOPT_SSL
-#ifndef CURL_DISABLE_PROXY
- || conn->http_proxy.proxytype == CURLPROXY_HTTPS
-#endif
- )
+ if((conn->handler->flags & PROTOPT_SSL
+#ifndef CURL_DISABLE_PROXY
+ || conn->http_proxy.proxytype == CURLPROXY_HTTPS
+#endif
+ )
&& conn->httpversion != 20) {
/* We never send more than CURL_MAX_WRITE_SIZE bytes in one single chunk
when we speak HTTPS, as if only a fraction of it is sent now, this data
@@ -1221,27 +1221,27 @@ CURLcode Curl_buffer_send(struct dynbuf *in,
result = Curl_get_upload_buffer(data);
if(result) {
/* malloc failed, free memory and return to the caller */
- Curl_dyn_free(in);
+ Curl_dyn_free(in);
return result;
}
memcpy(data->state.ulbuf, ptr, sendsize);
ptr = data->state.ulbuf;
}
- else {
-#ifdef CURLDEBUG
- /* Allow debug builds override this logic to force short initial sends */
- char *p = getenv("CURL_SMALLREQSEND");
- if(p) {
- size_t altsize = (size_t)strtoul(p, NULL, 10);
- if(altsize)
- sendsize = CURLMIN(size, altsize);
- else
- sendsize = size;
- }
- else
-#endif
+ else {
+#ifdef CURLDEBUG
+ /* Allow debug builds override this logic to force short initial sends */
+ char *p = getenv("CURL_SMALLREQSEND");
+ if(p) {
+ size_t altsize = (size_t)strtoul(p, NULL, 10);
+ if(altsize)
+ sendsize = CURLMIN(size, altsize);
+ else
+ sendsize = size;
+ }
+ else
+#endif
sendsize = size;
- }
+ }
result = Curl_write(conn, sockfd, ptr, sendsize, &amount);
@@ -1255,12 +1255,12 @@ CURLcode Curl_buffer_send(struct dynbuf *in,
size_t headlen = (size_t)amount>headersize ? headersize : (size_t)amount;
size_t bodylen = amount - headlen;
- /* this data _may_ contain binary stuff */
- Curl_debug(data, CURLINFO_HEADER_OUT, ptr, headlen);
- if(bodylen)
- /* there was body data sent beyond the initial header part, pass that on
- to the debug callback too */
- Curl_debug(data, CURLINFO_DATA_OUT, ptr + headlen, bodylen);
+ /* this data _may_ contain binary stuff */
+ Curl_debug(data, CURLINFO_HEADER_OUT, ptr, headlen);
+ if(bodylen)
+ /* there was body data sent beyond the initial header part, pass that on
+ to the debug callback too */
+ Curl_debug(data, CURLINFO_DATA_OUT, ptr + headlen, bodylen);
/* 'amount' can never be a very large value here so typecasting it so a
signed 31 bit value should not cause problems even if ssize_t is
@@ -1280,7 +1280,7 @@ CURLcode Curl_buffer_send(struct dynbuf *in,
size -= amount;
- ptr = Curl_dyn_ptr(in) + amount;
+ ptr = Curl_dyn_ptr(in) + amount;
/* backup the currently set pointers */
http->backup.fread_func = data->state.fread_func;
@@ -1294,7 +1294,7 @@ CURLcode Curl_buffer_send(struct dynbuf *in,
http->postdata = ptr;
http->postsize = (curl_off_t)size;
- http->send_buffer = *in; /* copy the whole struct */
+ http->send_buffer = *in; /* copy the whole struct */
http->sending = HTTPSEND_REQUEST;
return CURLE_OK;
@@ -1314,7 +1314,7 @@ CURLcode Curl_buffer_send(struct dynbuf *in,
return CURLE_SEND_ERROR;
}
}
- Curl_dyn_free(in);
+ Curl_dyn_free(in);
return result;
}
@@ -1352,7 +1352,7 @@ Curl_compareheader(const char *headerline, /* line to check */
/* pass the header */
start = &headerline[hlen];
- /* pass all whitespace */
+ /* pass all whitespace */
while(*start && ISSPACE(*start))
start++;
@@ -1391,7 +1391,7 @@ CURLcode Curl_http_connect(struct connectdata *conn, bool *done)
function to make the re-use checks properly be able to check this bit. */
connkeep(conn, "HTTP default");
-#ifndef CURL_DISABLE_PROXY
+#ifndef CURL_DISABLE_PROXY
/* the CONNECT procedure might not have been completed */
result = Curl_proxy_connect(conn, FIRSTSOCKET);
if(result)
@@ -1443,7 +1443,7 @@ static int http_getsock_do(struct connectdata *conn,
static CURLcode add_haproxy_protocol_header(struct connectdata *conn)
{
char proxy_header[128];
- struct dynbuf req;
+ struct dynbuf req;
CURLcode result;
char tcp_version[5];
@@ -1464,14 +1464,14 @@ static CURLcode add_haproxy_protocol_header(struct connectdata *conn)
conn->data->info.conn_local_port,
conn->data->info.conn_primary_port);
- Curl_dyn_init(&req, DYN_HAXPROXY);
+ Curl_dyn_init(&req, DYN_HAXPROXY);
- result = Curl_dyn_add(&req, proxy_header);
+ result = Curl_dyn_add(&req, proxy_header);
if(result)
return result;
- result = Curl_buffer_send(&req, conn, &conn->data->info.request_size,
- 0, FIRSTSOCKET);
+ result = Curl_buffer_send(&req, conn, &conn->data->info.request_size,
+ 0, FIRSTSOCKET);
return result;
}
@@ -1516,7 +1516,7 @@ CURLcode Curl_http_done(struct connectdata *conn,
CURLcode status, bool premature)
{
struct Curl_easy *data = conn->data;
- struct HTTP *http = data->req.p.http;
+ struct HTTP *http = data->req.p.http;
/* Clear multipass flag. If authentication isn't done yet, then it will get
* a chance to be set back to true when we output the next auth header */
@@ -1532,11 +1532,11 @@ CURLcode Curl_http_done(struct connectdata *conn,
if(!http)
return CURLE_OK;
- Curl_dyn_free(&http->send_buffer);
- Curl_http2_done(data, premature);
- Curl_quic_done(data, premature);
+ Curl_dyn_free(&http->send_buffer);
+ Curl_http2_done(data, premature);
+ Curl_quic_done(data, premature);
Curl_mime_cleanpart(&http->form);
- Curl_dyn_reset(&data->state.headerb);
+ Curl_dyn_reset(&data->state.headerb);
if(status)
return status;
@@ -1602,12 +1602,12 @@ static const char *get_http_string(const struct Curl_easy *data,
/* check and possibly add an Expect: header */
static CURLcode expect100(struct Curl_easy *data,
struct connectdata *conn,
- struct dynbuf *req)
+ struct dynbuf *req)
{
CURLcode result = CURLE_OK;
data->state.expect100header = FALSE; /* default to false unless it is set
to TRUE below */
- if(!data->state.disableexpect && use_http_1_1plus(data, conn) &&
+ if(!data->state.disableexpect && use_http_1_1plus(data, conn) &&
(conn->httpversion < 20)) {
/* if not doing HTTP 1.0 or version 2, or disabled explicitly, we add an
Expect: 100-continue to the headers which actually speeds up post
@@ -1618,7 +1618,7 @@ static CURLcode expect100(struct Curl_easy *data,
Curl_compareheader(ptr, "Expect:", "100-continue");
}
else {
- result = Curl_dyn_add(req, "Expect: 100-continue\r\n");
+ result = Curl_dyn_add(req, "Expect: 100-continue\r\n");
if(!result)
data->state.expect100header = TRUE;
}
@@ -1637,7 +1637,7 @@ enum proxy_use {
will return an error code if one of the headers is
not formatted correctly */
CURLcode Curl_http_compile_trailers(struct curl_slist *trailers,
- struct dynbuf *b,
+ struct dynbuf *b,
struct Curl_easy *handle)
{
char *ptr = NULL;
@@ -1663,24 +1663,24 @@ CURLcode Curl_http_compile_trailers(struct curl_slist *trailers,
/* only add correctly formatted trailers */
ptr = strchr(trailers->data, ':');
if(ptr && *(ptr + 1) == ' ') {
- result = Curl_dyn_add(b, trailers->data);
+ result = Curl_dyn_add(b, trailers->data);
+ if(result)
+ return result;
+ result = Curl_dyn_add(b, endofline_native);
if(result)
return result;
- result = Curl_dyn_add(b, endofline_native);
- if(result)
- return result;
}
else
infof(handle, "Malformatted trailing header ! Skipping trailer.");
trailers = trailers->next;
}
- result = Curl_dyn_add(b, endofline_network);
+ result = Curl_dyn_add(b, endofline_network);
return result;
}
CURLcode Curl_add_custom_headers(struct connectdata *conn,
bool is_connect,
- struct dynbuf *req)
+ struct dynbuf *req)
{
char *ptr;
struct curl_slist *h[2];
@@ -1689,7 +1689,7 @@ CURLcode Curl_add_custom_headers(struct connectdata *conn,
struct Curl_easy *data = conn->data;
int i;
-#ifndef CURL_DISABLE_PROXY
+#ifndef CURL_DISABLE_PROXY
enum proxy_use proxy;
if(is_connect)
@@ -1716,10 +1716,10 @@ CURLcode Curl_add_custom_headers(struct connectdata *conn,
h[0] = data->set.headers;
break;
}
-#else
- (void)is_connect;
- h[0] = data->set.headers;
-#endif
+#else
+ (void)is_connect;
+ h[0] = data->set.headers;
+#endif
/* loop through one or two lists */
for(i = 0; i < numlists; i++) {
@@ -1747,7 +1747,7 @@ CURLcode Curl_add_custom_headers(struct connectdata *conn,
/* copy the source */
semicolonp = strdup(headers->data);
if(!semicolonp) {
- Curl_dyn_free(req);
+ Curl_dyn_free(req);
return CURLE_OUT_OF_MEMORY;
}
/* put a colon where the semicolon is */
@@ -1771,16 +1771,16 @@ CURLcode Curl_add_custom_headers(struct connectdata *conn,
CURLcode result = CURLE_OK;
char *compare = semicolonp ? semicolonp : headers->data;
- if(data->state.aptr.host &&
+ if(data->state.aptr.host &&
/* a Host: header was sent already, don't pass on any custom Host:
header as that will produce *two* in the same request! */
checkprefix("Host:", compare))
;
- else if(data->state.httpreq == HTTPREQ_POST_FORM &&
+ else if(data->state.httpreq == HTTPREQ_POST_FORM &&
/* this header (extended by formdata.c) is sent later */
checkprefix("Content-Type:", compare))
;
- else if(data->state.httpreq == HTTPREQ_POST_MIME &&
+ else if(data->state.httpreq == HTTPREQ_POST_MIME &&
/* this header is sent later */
checkprefix("Content-Type:", compare))
;
@@ -1789,7 +1789,7 @@ CURLcode Curl_add_custom_headers(struct connectdata *conn,
we will force length zero then */
checkprefix("Content-Length:", compare))
;
- else if(data->state.aptr.te &&
+ else if(data->state.aptr.te &&
/* when asking for Transfer-Encoding, don't pass on a custom
Connection: */
checkprefix("Connection:", compare))
@@ -1808,7 +1808,7 @@ CURLcode Curl_add_custom_headers(struct connectdata *conn,
!strcasecompare(data->state.first_host, conn->host.name)))
;
else {
- result = Curl_dyn_addf(req, "%s\r\n", compare);
+ result = Curl_dyn_addf(req, "%s\r\n", compare);
}
if(semicolonp)
free(semicolonp);
@@ -1825,7 +1825,7 @@ CURLcode Curl_add_custom_headers(struct connectdata *conn,
#ifndef CURL_DISABLE_PARSEDATE
CURLcode Curl_add_timecondition(const struct connectdata *conn,
- struct dynbuf *req)
+ struct dynbuf *req)
{
struct Curl_easy *data = conn->data;
const struct tm *tm;
@@ -1884,17 +1884,17 @@ CURLcode Curl_add_timecondition(const struct connectdata *conn,
tm->tm_min,
tm->tm_sec);
- result = Curl_dyn_add(req, datestr);
+ result = Curl_dyn_add(req, datestr);
return result;
}
#else
/* disabled */
CURLcode Curl_add_timecondition(const struct connectdata *conn,
- struct dynbuf *req)
+ struct dynbuf *req)
{
(void)conn;
- (void)req;
+ (void)req;
return CURLE_OK;
}
#endif
@@ -1917,13 +1917,13 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
const char *te = ""; /* transfer-encoding */
const char *ptr;
const char *request;
- Curl_HttpReq httpreq = data->state.httpreq;
+ Curl_HttpReq httpreq = data->state.httpreq;
#if !defined(CURL_DISABLE_COOKIES)
char *addcookies = NULL;
#endif
curl_off_t included_body = 0;
const char *httpstring;
- struct dynbuf req;
+ struct dynbuf req;
curl_off_t postsize = 0; /* curl_off_t to handle large file sizes */
char *altused = NULL;
@@ -1951,14 +1951,14 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
#ifdef USE_NGHTTP2
if(conn->data->set.httpversion ==
CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE) {
-#ifndef CURL_DISABLE_PROXY
+#ifndef CURL_DISABLE_PROXY
if(conn->bits.httpproxy && !conn->bits.tunnel_proxy) {
/* We don't support HTTP/2 proxies yet. Also it's debatable
whether or not this setting should apply to HTTP/2 proxies. */
infof(data, "Ignoring HTTP/2 prior knowledge due to proxy\n");
break;
}
-#endif
+#endif
DEBUGF(infof(data, "HTTP/2 over clean TCP\n"));
conn->httpversion = 20;
@@ -1977,7 +1977,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
return result;
}
}
- http = data->req.p.http;
+ http = data->req.p.http;
DEBUGASSERT(http);
if(!data->state.this_is_a_follow) {
@@ -2029,8 +2029,8 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
with the user-agent string specified, we erase the previously made string
here. */
if(Curl_checkheaders(conn, "User-Agent")) {
- free(data->state.aptr.uagent);
- data->state.aptr.uagent = NULL;
+ free(data->state.aptr.uagent);
+ data->state.aptr.uagent = NULL;
}
/* setup the authentication headers */
@@ -2058,14 +2058,14 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
else
conn->bits.authneg = FALSE;
- Curl_safefree(data->state.aptr.ref);
+ Curl_safefree(data->state.aptr.ref);
if(data->change.referer && !Curl_checkheaders(conn, "Referer")) {
- data->state.aptr.ref = aprintf("Referer: %s\r\n", data->change.referer);
- if(!data->state.aptr.ref)
+ data->state.aptr.ref = aprintf("Referer: %s\r\n", data->change.referer);
+ if(!data->state.aptr.ref)
return CURLE_OUT_OF_MEMORY;
}
else
- data->state.aptr.ref = NULL;
+ data->state.aptr.ref = NULL;
#if !defined(CURL_DISABLE_COOKIES)
if(data->set.str[STRING_COOKIE] && !Curl_checkheaders(conn, "Cookie"))
@@ -2074,15 +2074,15 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
if(!Curl_checkheaders(conn, "Accept-Encoding") &&
data->set.str[STRING_ENCODING]) {
- Curl_safefree(data->state.aptr.accept_encoding);
- data->state.aptr.accept_encoding =
+ Curl_safefree(data->state.aptr.accept_encoding);
+ data->state.aptr.accept_encoding =
aprintf("Accept-Encoding: %s\r\n", data->set.str[STRING_ENCODING]);
- if(!data->state.aptr.accept_encoding)
+ if(!data->state.aptr.accept_encoding)
return CURLE_OUT_OF_MEMORY;
}
else {
- Curl_safefree(data->state.aptr.accept_encoding);
- data->state.aptr.accept_encoding = NULL;
+ Curl_safefree(data->state.aptr.accept_encoding);
+ data->state.aptr.accept_encoding = NULL;
}
#ifdef HAVE_LIBZ
@@ -2098,7 +2098,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
char *cptr = Curl_checkheaders(conn, "Connection");
#define TE_HEADER "TE: gzip\r\n"
- Curl_safefree(data->state.aptr.te);
+ Curl_safefree(data->state.aptr.te);
if(cptr) {
cptr = Curl_copy_header_value(cptr);
@@ -2107,11 +2107,11 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
}
/* Create the (updated) Connection: header */
- data->state.aptr.te = aprintf("Connection: %s%sTE\r\n" TE_HEADER,
+ data->state.aptr.te = aprintf("Connection: %s%sTE\r\n" TE_HEADER,
cptr ? cptr : "", (cptr && *cptr) ? ", ":"");
free(cptr);
- if(!data->state.aptr.te)
+ if(!data->state.aptr.te)
return CURLE_OUT_OF_MEMORY;
}
#endif
@@ -2194,7 +2194,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
te = "Transfer-Encoding: chunked\r\n";
}
- Curl_safefree(data->state.aptr.host);
+ Curl_safefree(data->state.aptr.host);
ptr = Curl_checkheaders(conn, "Host");
if(ptr && (!data->state.this_is_a_follow ||
@@ -2229,19 +2229,19 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
if(colon)
*colon = 0; /* The host must not include an embedded port number */
}
- Curl_safefree(data->state.aptr.cookiehost);
- data->state.aptr.cookiehost = cookiehost;
+ Curl_safefree(data->state.aptr.cookiehost);
+ data->state.aptr.cookiehost = cookiehost;
}
#endif
if(strcmp("Host:", ptr)) {
- data->state.aptr.host = aprintf("Host:%s\r\n", &ptr[5]);
- if(!data->state.aptr.host)
+ data->state.aptr.host = aprintf("Host:%s\r\n", &ptr[5]);
+ if(!data->state.aptr.host)
return CURLE_OUT_OF_MEMORY;
}
else
/* when clearing the header */
- data->state.aptr.host = NULL;
+ data->state.aptr.host = NULL;
}
else {
/* When building Host: headers, we must put the host name within
@@ -2253,18 +2253,18 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
(conn->remote_port == PORT_HTTP)) )
/* if(HTTPS on port 443) OR (HTTP on port 80) then don't include
the port number in the host string */
- data->state.aptr.host = aprintf("Host: %s%s%s\r\n",
+ data->state.aptr.host = aprintf("Host: %s%s%s\r\n",
conn->bits.ipv6_ip?"[":"",
host,
conn->bits.ipv6_ip?"]":"");
else
- data->state.aptr.host = aprintf("Host: %s%s%s:%d\r\n",
+ data->state.aptr.host = aprintf("Host: %s%s%s:%d\r\n",
conn->bits.ipv6_ip?"[":"",
host,
conn->bits.ipv6_ip?"]":"",
conn->remote_port);
- if(!data->state.aptr.host)
+ if(!data->state.aptr.host)
/* without Host: we can't make a nice request */
return CURLE_OUT_OF_MEMORY;
}
@@ -2309,7 +2309,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
return CURLE_OUT_OF_MEMORY;
}
}
- /* Extract the URL to use in the request. Store in STRING_TEMP_URL for
+ /* Extract the URL to use in the request. Store in STRING_TEMP_URL for
clean-up reasons if the function returns before the free() further
down. */
uc = curl_url_get(h, CURLUPART_URL, &data->set.str[STRING_TEMP_URL], 0);
@@ -2345,7 +2345,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
data->set.prefer_ascii ? 'a' : 'i');
}
}
- if(conn->bits.user_passwd)
+ if(conn->bits.user_passwd)
paste_ftp_userpwd = TRUE;
}
}
@@ -2435,21 +2435,21 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
if(((httpreq == HTTPREQ_GET) || (httpreq == HTTPREQ_HEAD)) &&
!Curl_checkheaders(conn, "Range")) {
/* if a line like this was already allocated, free the previous one */
- free(data->state.aptr.rangeline);
- data->state.aptr.rangeline = aprintf("Range: bytes=%s\r\n",
+ free(data->state.aptr.rangeline);
+ data->state.aptr.rangeline = aprintf("Range: bytes=%s\r\n",
data->state.range);
}
else if((httpreq == HTTPREQ_POST || httpreq == HTTPREQ_PUT) &&
!Curl_checkheaders(conn, "Content-Range")) {
/* if a line like this was already allocated, free the previous one */
- free(data->state.aptr.rangeline);
+ free(data->state.aptr.rangeline);
if(data->set.set_resume_from < 0) {
/* Upload resume was asked for, but we don't know the size of the
remote part so we tell the server (and act accordingly) that we
upload the whole file (again) */
- data->state.aptr.rangeline =
+ data->state.aptr.rangeline =
aprintf("Content-Range: bytes 0-%" CURL_FORMAT_CURL_OFF_T
"/%" CURL_FORMAT_CURL_OFF_T "\r\n",
data->state.infilesize - 1, data->state.infilesize);
@@ -2459,7 +2459,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
/* This is because "resume" was selected */
curl_off_t total_expected_size =
data->state.resume_from + data->state.infilesize;
- data->state.aptr.rangeline =
+ data->state.aptr.rangeline =
aprintf("Content-Range: bytes %s%" CURL_FORMAT_CURL_OFF_T
"/%" CURL_FORMAT_CURL_OFF_T "\r\n",
data->state.range, total_expected_size-1,
@@ -2468,11 +2468,11 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
else {
/* Range was selected and then we just pass the incoming range and
append total size */
- data->state.aptr.rangeline =
+ data->state.aptr.rangeline =
aprintf("Content-Range: bytes %s/%" CURL_FORMAT_CURL_OFF_T "\r\n",
data->state.range, data->state.infilesize);
}
- if(!data->state.aptr.rangeline)
+ if(!data->state.aptr.rangeline)
return CURLE_OUT_OF_MEMORY;
}
}
@@ -2480,11 +2480,11 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
httpstring = get_http_string(data, conn);
/* initialize a dynamic send-buffer */
- Curl_dyn_init(&req, DYN_HTTP_REQUEST);
+ Curl_dyn_init(&req, DYN_HTTP_REQUEST);
/* add the main request stuff */
/* GET/HEAD/POST/PUT */
- result = Curl_dyn_addf(&req, "%s ", request);
+ result = Curl_dyn_addf(&req, "%s ", request);
if(result)
return result;
@@ -2497,87 +2497,87 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
/* url */
if(conn->bits.httpproxy && !conn->bits.tunnel_proxy) {
char *url = data->set.str[STRING_TEMP_URL];
- result = Curl_dyn_add(&req, url);
+ result = Curl_dyn_add(&req, url);
Curl_safefree(data->set.str[STRING_TEMP_URL]);
}
else
#endif
if(paste_ftp_userpwd)
- result = Curl_dyn_addf(&req, "ftp://%s:%s@%s", conn->user, conn->passwd,
- path + sizeof("ftp://") - 1);
+ result = Curl_dyn_addf(&req, "ftp://%s:%s@%s", conn->user, conn->passwd,
+ path + sizeof("ftp://") - 1);
else {
- result = Curl_dyn_add(&req, path);
+ result = Curl_dyn_add(&req, path);
if(result)
return result;
if(query)
- result = Curl_dyn_addf(&req, "?%s", query);
+ result = Curl_dyn_addf(&req, "?%s", query);
}
if(result)
return result;
-#ifndef CURL_DISABLE_ALTSVC
+#ifndef CURL_DISABLE_ALTSVC
if(conn->bits.altused && !Curl_checkheaders(conn, "Alt-Used")) {
altused = aprintf("Alt-Used: %s:%d\r\n",
conn->conn_to_host.name, conn->conn_to_port);
- if(!altused) {
- Curl_dyn_free(&req);
+ if(!altused) {
+ Curl_dyn_free(&req);
return CURLE_OUT_OF_MEMORY;
- }
+ }
}
#endif
result =
- Curl_dyn_addf(&req,
- "%s" /* ftp typecode (;type=x) */
- " HTTP/%s\r\n" /* HTTP version */
- "%s" /* host */
- "%s" /* proxyuserpwd */
- "%s" /* userpwd */
- "%s" /* range */
- "%s" /* user agent */
- "%s" /* accept */
- "%s" /* TE: */
- "%s" /* accept-encoding */
- "%s" /* referer */
- "%s" /* Proxy-Connection */
- "%s" /* transfer-encoding */
- "%s",/* Alt-Used */
-
- ftp_typecode,
- httpstring,
- (data->state.aptr.host?data->state.aptr.host:""),
- data->state.aptr.proxyuserpwd?
- data->state.aptr.proxyuserpwd:"",
- data->state.aptr.userpwd?data->state.aptr.userpwd:"",
- (data->state.use_range && data->state.aptr.rangeline)?
- data->state.aptr.rangeline:"",
- (data->set.str[STRING_USERAGENT] &&
- *data->set.str[STRING_USERAGENT] &&
- data->state.aptr.uagent)?
- data->state.aptr.uagent:"",
- http->p_accept?http->p_accept:"",
- data->state.aptr.te?data->state.aptr.te:"",
- (data->set.str[STRING_ENCODING] &&
- *data->set.str[STRING_ENCODING] &&
- data->state.aptr.accept_encoding)?
- data->state.aptr.accept_encoding:"",
- (data->change.referer && data->state.aptr.ref)?
- data->state.aptr.ref:"" /* Referer: <data> */,
-#ifndef CURL_DISABLE_PROXY
- (conn->bits.httpproxy &&
- !conn->bits.tunnel_proxy &&
- !Curl_checkProxyheaders(conn, "Proxy-Connection"))?
- "Proxy-Connection: Keep-Alive\r\n":"",
-#else
- "",
-#endif
- te,
- altused ? altused : ""
+ Curl_dyn_addf(&req,
+ "%s" /* ftp typecode (;type=x) */
+ " HTTP/%s\r\n" /* HTTP version */
+ "%s" /* host */
+ "%s" /* proxyuserpwd */
+ "%s" /* userpwd */
+ "%s" /* range */
+ "%s" /* user agent */
+ "%s" /* accept */
+ "%s" /* TE: */
+ "%s" /* accept-encoding */
+ "%s" /* referer */
+ "%s" /* Proxy-Connection */
+ "%s" /* transfer-encoding */
+ "%s",/* Alt-Used */
+
+ ftp_typecode,
+ httpstring,
+ (data->state.aptr.host?data->state.aptr.host:""),
+ data->state.aptr.proxyuserpwd?
+ data->state.aptr.proxyuserpwd:"",
+ data->state.aptr.userpwd?data->state.aptr.userpwd:"",
+ (data->state.use_range && data->state.aptr.rangeline)?
+ data->state.aptr.rangeline:"",
+ (data->set.str[STRING_USERAGENT] &&
+ *data->set.str[STRING_USERAGENT] &&
+ data->state.aptr.uagent)?
+ data->state.aptr.uagent:"",
+ http->p_accept?http->p_accept:"",
+ data->state.aptr.te?data->state.aptr.te:"",
+ (data->set.str[STRING_ENCODING] &&
+ *data->set.str[STRING_ENCODING] &&
+ data->state.aptr.accept_encoding)?
+ data->state.aptr.accept_encoding:"",
+ (data->change.referer && data->state.aptr.ref)?
+ data->state.aptr.ref:"" /* Referer: <data> */,
+#ifndef CURL_DISABLE_PROXY
+ (conn->bits.httpproxy &&
+ !conn->bits.tunnel_proxy &&
+ !Curl_checkProxyheaders(conn, "Proxy-Connection"))?
+ "Proxy-Connection: Keep-Alive\r\n":"",
+#else
+ "",
+#endif
+ te,
+ altused ? altused : ""
);
/* clear userpwd and proxyuserpwd to avoid re-using old credentials
* from re-used connections */
- Curl_safefree(data->state.aptr.userpwd);
- Curl_safefree(data->state.aptr.proxyuserpwd);
+ Curl_safefree(data->state.aptr.userpwd);
+ Curl_safefree(data->state.aptr.proxyuserpwd);
free(altused);
if(result)
@@ -2588,7 +2588,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
(data->set.httpversion == CURL_HTTP_VERSION_2)) {
/* append HTTP2 upgrade magic stuff to the HTTP request if it isn't done
over SSL */
- result = Curl_http2_request_upgrade(&req, conn);
+ result = Curl_http2_request_upgrade(&req, conn);
if(result)
return result;
}
@@ -2598,11 +2598,11 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
struct Cookie *co = NULL; /* no cookies from start */
int count = 0;
- if(data->cookies && data->state.cookie_engine) {
+ if(data->cookies && data->state.cookie_engine) {
Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE);
co = Curl_cookie_getlist(data->cookies,
- data->state.aptr.cookiehost?
- data->state.aptr.cookiehost:host,
+ data->state.aptr.cookiehost?
+ data->state.aptr.cookiehost:host,
data->state.up.path,
(conn->handler->protocol&CURLPROTO_HTTPS)?
TRUE:FALSE);
@@ -2614,12 +2614,12 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
while(co) {
if(co->value) {
if(0 == count) {
- result = Curl_dyn_add(&req, "Cookie: ");
+ result = Curl_dyn_add(&req, "Cookie: ");
if(result)
break;
}
- result = Curl_dyn_addf(&req, "%s%s=%s", count?"; ":"",
- co->name, co->value);
+ result = Curl_dyn_addf(&req, "%s%s=%s", count?"; ":"",
+ co->name, co->value);
if(result)
break;
count++;
@@ -2630,25 +2630,25 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
}
if(addcookies && !result) {
if(!count)
- result = Curl_dyn_add(&req, "Cookie: ");
+ result = Curl_dyn_add(&req, "Cookie: ");
if(!result) {
- result = Curl_dyn_addf(&req, "%s%s", count?"; ":"", addcookies);
+ result = Curl_dyn_addf(&req, "%s%s", count?"; ":"", addcookies);
count++;
}
}
if(count && !result)
- result = Curl_dyn_add(&req, "\r\n");
+ result = Curl_dyn_add(&req, "\r\n");
if(result)
return result;
}
#endif
- result = Curl_add_timecondition(conn, &req);
+ result = Curl_add_timecondition(conn, &req);
if(result)
return result;
- result = Curl_add_custom_headers(conn, FALSE, &req);
+ result = Curl_add_custom_headers(conn, FALSE, &req);
if(result)
return result;
@@ -2671,20 +2671,20 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
if((postsize != -1) && !data->req.upload_chunky &&
(conn->bits.authneg || !Curl_checkheaders(conn, "Content-Length"))) {
/* only add Content-Length if not uploading chunked */
- result = Curl_dyn_addf(&req, "Content-Length: %" CURL_FORMAT_CURL_OFF_T
- "\r\n", postsize);
+ result = Curl_dyn_addf(&req, "Content-Length: %" CURL_FORMAT_CURL_OFF_T
+ "\r\n", postsize);
if(result)
return result;
}
if(postsize != 0) {
- result = expect100(data, conn, &req);
+ result = expect100(data, conn, &req);
if(result)
return result;
}
- /* end of headers */
- result = Curl_dyn_add(&req, "\r\n");
+ /* end of headers */
+ result = Curl_dyn_add(&req, "\r\n");
if(result)
return result;
@@ -2692,8 +2692,8 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
Curl_pgrsSetUploadSize(data, postsize);
/* this sends the buffer and frees all the buffer resources */
- result = Curl_buffer_send(&req, conn, &data->info.request_size, 0,
- FIRSTSOCKET);
+ result = Curl_buffer_send(&req, conn, &data->info.request_size, 0,
+ FIRSTSOCKET);
if(result)
failf(data, "Failed sending PUT request");
else
@@ -2709,12 +2709,12 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
/* This is form posting using mime data. */
if(conn->bits.authneg) {
/* nothing to post! */
- result = Curl_dyn_add(&req, "Content-Length: 0\r\n\r\n");
+ result = Curl_dyn_add(&req, "Content-Length: 0\r\n\r\n");
if(result)
return result;
- result = Curl_buffer_send(&req, conn, &data->info.request_size, 0,
- FIRSTSOCKET);
+ result = Curl_buffer_send(&req, conn, &data->info.request_size, 0,
+ FIRSTSOCKET);
if(result)
failf(data, "Failed sending POST request");
else
@@ -2732,9 +2732,9 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
(conn->bits.authneg || !Curl_checkheaders(conn, "Content-Length"))) {
/* we allow replacing this header if not during auth negotiation,
although it isn't very wise to actually set your own */
- result = Curl_dyn_addf(&req,
- "Content-Length: %" CURL_FORMAT_CURL_OFF_T
- "\r\n", postsize);
+ result = Curl_dyn_addf(&req,
+ "Content-Length: %" CURL_FORMAT_CURL_OFF_T
+ "\r\n", postsize);
if(result)
return result;
}
@@ -2745,7 +2745,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
struct curl_slist *hdr;
for(hdr = http->sendit->curlheaders; hdr; hdr = hdr->next) {
- result = Curl_dyn_addf(&req, "%s\r\n", hdr->data);
+ result = Curl_dyn_addf(&req, "%s\r\n", hdr->data);
if(result)
return result;
}
@@ -2762,7 +2762,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
Curl_compareheader(ptr, "Expect:", "100-continue");
}
else if(postsize > EXPECT_100_THRESHOLD || postsize < 0) {
- result = expect100(data, conn, &req);
+ result = expect100(data, conn, &req);
if(result)
return result;
}
@@ -2770,7 +2770,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
data->state.expect100header = FALSE;
/* make the request end in a true CRLF */
- result = Curl_dyn_add(&req, "\r\n");
+ result = Curl_dyn_add(&req, "\r\n");
if(result)
return result;
@@ -2783,8 +2783,8 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
http->sending = HTTPSEND_BODY;
/* this sends the buffer and frees all the buffer resources */
- result = Curl_buffer_send(&req, conn, &data->info.request_size, 0,
- FIRSTSOCKET);
+ result = Curl_buffer_send(&req, conn, &data->info.request_size, 0,
+ FIRSTSOCKET);
if(result)
failf(data, "Failed sending POST request");
else
@@ -2812,15 +2812,15 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
(conn->bits.authneg || !Curl_checkheaders(conn, "Content-Length"))) {
/* we allow replacing this header if not during auth negotiation,
although it isn't very wise to actually set your own */
- result = Curl_dyn_addf(&req, "Content-Length: %" CURL_FORMAT_CURL_OFF_T
- "\r\n", postsize);
+ result = Curl_dyn_addf(&req, "Content-Length: %" CURL_FORMAT_CURL_OFF_T
+ "\r\n", postsize);
if(result)
return result;
}
if(!Curl_checkheaders(conn, "Content-Type")) {
- result = Curl_dyn_add(&req, "Content-Type: application/"
- "x-www-form-urlencoded\r\n");
+ result = Curl_dyn_add(&req, "Content-Type: application/"
+ "x-www-form-urlencoded\r\n");
if(result)
return result;
}
@@ -2835,7 +2835,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
Curl_compareheader(ptr, "Expect:", "100-continue");
}
else if(postsize > EXPECT_100_THRESHOLD || postsize < 0) {
- result = expect100(data, conn, &req);
+ result = expect100(data, conn, &req);
if(result)
return result;
}
@@ -2856,38 +2856,38 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
is no magic limit but only set to prevent really huge POSTs to
get the data duplicated with malloc() and family. */
- /* end of headers! */
- result = Curl_dyn_add(&req, "\r\n");
+ /* end of headers! */
+ result = Curl_dyn_add(&req, "\r\n");
if(result)
return result;
if(!data->req.upload_chunky) {
/* We're not sending it 'chunked', append it to the request
already now to reduce the number if send() calls */
- result = Curl_dyn_addn(&req, data->set.postfields,
- (size_t)postsize);
+ result = Curl_dyn_addn(&req, data->set.postfields,
+ (size_t)postsize);
included_body = postsize;
}
else {
if(postsize) {
- char chunk[16];
+ char chunk[16];
/* Append the POST data chunky-style */
- msnprintf(chunk, sizeof(chunk), "%x\r\n", (int)postsize);
- result = Curl_dyn_add(&req, chunk);
+ msnprintf(chunk, sizeof(chunk), "%x\r\n", (int)postsize);
+ result = Curl_dyn_add(&req, chunk);
if(!result) {
- included_body = postsize + strlen(chunk);
- result = Curl_dyn_addn(&req, data->set.postfields,
- (size_t)postsize);
+ included_body = postsize + strlen(chunk);
+ result = Curl_dyn_addn(&req, data->set.postfields,
+ (size_t)postsize);
if(!result)
- result = Curl_dyn_add(&req, "\r\n");
- included_body += 2;
+ result = Curl_dyn_add(&req, "\r\n");
+ included_body += 2;
}
}
- if(!result) {
- result = Curl_dyn_add(&req, "\x30\x0d\x0a\x0d\x0a");
- /* 0 CR LF CR LF */
- included_body += 5;
- }
+ if(!result) {
+ result = Curl_dyn_add(&req, "\x30\x0d\x0a\x0d\x0a");
+ /* 0 CR LF CR LF */
+ included_body += 5;
+ }
}
if(result)
return result;
@@ -2907,22 +2907,22 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
/* set the upload size to the progress meter */
Curl_pgrsSetUploadSize(data, http->postsize);
- /* end of headers! */
- result = Curl_dyn_add(&req, "\r\n");
+ /* end of headers! */
+ result = Curl_dyn_add(&req, "\r\n");
if(result)
return result;
}
}
else {
- /* end of headers! */
- result = Curl_dyn_add(&req, "\r\n");
+ /* end of headers! */
+ result = Curl_dyn_add(&req, "\r\n");
if(result)
return result;
if(data->req.upload_chunky && conn->bits.authneg) {
/* Chunky upload is selected and we're negotiating auth still, send
end-of-data only */
- result = Curl_dyn_add(&req, (char *)"\x30\x0d\x0a\x0d\x0a");
+ result = Curl_dyn_add(&req, (char *)"\x30\x0d\x0a\x0d\x0a");
/* 0 CR LF CR LF */
if(result)
return result;
@@ -2942,8 +2942,8 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
}
}
/* issue the request */
- result = Curl_buffer_send(&req, conn, &data->info.request_size,
- (size_t)included_body, FIRSTSOCKET);
+ result = Curl_buffer_send(&req, conn, &data->info.request_size,
+ (size_t)included_body, FIRSTSOCKET);
if(result)
failf(data, "Failed sending HTTP POST request");
@@ -2953,24 +2953,24 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
break;
default:
- result = Curl_dyn_add(&req, "\r\n");
+ result = Curl_dyn_add(&req, "\r\n");
if(result)
return result;
/* issue the request */
- result = Curl_buffer_send(&req, conn, &data->info.request_size, 0,
- FIRSTSOCKET);
+ result = Curl_buffer_send(&req, conn, &data->info.request_size, 0,
+ FIRSTSOCKET);
if(result)
failf(data, "Failed sending HTTP request");
else
/* HTTP GET/HEAD download: */
- Curl_setup_transfer(data, FIRSTSOCKET, -1, TRUE, -1);
+ Curl_setup_transfer(data, FIRSTSOCKET, -1, TRUE, -1);
}
if(result)
return result;
- if(!postsize && (http->sending != HTTPSEND_REQUEST))
- data->req.upload_done = TRUE;
+ if(!postsize && (http->sending != HTTPSEND_REQUEST))
+ data->req.upload_done = TRUE;
if(data->req.writebytecount) {
/* if a request-body has been sent off, we make sure this progress is noted
@@ -3107,7 +3107,7 @@ checkprotoprefix(struct Curl_easy *data, struct connectdata *conn,
static void print_http_error(struct Curl_easy *data)
{
struct SingleRequest *k = &data->req;
- char *beg = Curl_dyn_ptr(&data->state.headerb);
+ char *beg = Curl_dyn_ptr(&data->state.headerb);
/* make sure that data->req.p points to the HTTP status line */
if(!strncmp(beg, "HTTP", 4)) {
@@ -3145,17 +3145,17 @@ static void print_http_error(struct Curl_easy *data)
* Read any HTTP header lines from the server and pass them to the client app.
*/
CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
- struct connectdata *conn,
- ssize_t *nread,
- bool *stop_reading)
+ struct connectdata *conn,
+ ssize_t *nread,
+ bool *stop_reading)
{
CURLcode result;
struct SingleRequest *k = &data->req;
ssize_t onread = *nread;
char *ostr = k->str;
- char *headp;
- char *str_start;
- char *end_ptr;
+ char *headp;
+ char *str_start;
+ char *end_ptr;
/* header line within buffer loop */
do {
@@ -3164,25 +3164,25 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
int writetype;
/* str_start is start of line within buf */
- str_start = k->str;
+ str_start = k->str;
/* data is in network encoding so use 0x0a instead of '\n' */
- end_ptr = memchr(str_start, 0x0a, *nread);
+ end_ptr = memchr(str_start, 0x0a, *nread);
- if(!end_ptr) {
+ if(!end_ptr) {
/* Not a complete header line within buffer, append the data to
the end of the headerbuff. */
- result = Curl_dyn_addn(&data->state.headerb, str_start, *nread);
+ result = Curl_dyn_addn(&data->state.headerb, str_start, *nread);
if(result)
return result;
if(!k->headerline) {
/* check if this looks like a protocol header */
- statusline st =
- checkprotoprefix(data, conn,
- Curl_dyn_ptr(&data->state.headerb),
- Curl_dyn_len(&data->state.headerb));
-
+ statusline st =
+ checkprotoprefix(data, conn,
+ Curl_dyn_ptr(&data->state.headerb),
+ Curl_dyn_len(&data->state.headerb));
+
if(st == STATUS_BAD) {
/* this is not the beginning of a protocol first header line */
k->header = FALSE;
@@ -3200,26 +3200,26 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
}
/* decrease the size of the remaining (supposed) header line */
- rest_length = (end_ptr - k->str) + 1;
+ rest_length = (end_ptr - k->str) + 1;
*nread -= (ssize_t)rest_length;
- k->str = end_ptr + 1; /* move past new line */
+ k->str = end_ptr + 1; /* move past new line */
- full_length = k->str - str_start;
+ full_length = k->str - str_start;
- result = Curl_dyn_addn(&data->state.headerb, str_start, full_length);
+ result = Curl_dyn_addn(&data->state.headerb, str_start, full_length);
if(result)
return result;
/****
- * We now have a FULL header line in 'headerb'.
+ * We now have a FULL header line in 'headerb'.
*****/
if(!k->headerline) {
/* the first read header */
- statusline st = checkprotoprefix(data, conn,
- Curl_dyn_ptr(&data->state.headerb),
- Curl_dyn_len(&data->state.headerb));
+ statusline st = checkprotoprefix(data, conn,
+ Curl_dyn_ptr(&data->state.headerb),
+ Curl_dyn_len(&data->state.headerb));
if(st == STATUS_BAD) {
streamclose(conn, "bad HTTP: No end-of-message indicator");
/* this is not the beginning of a protocol first header line */
@@ -3242,27 +3242,27 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
}
}
- /* headers are in network encoding so use 0x0a and 0x0d instead of '\n'
- and '\r' */
- headp = Curl_dyn_ptr(&data->state.headerb);
- if((0x0a == *headp) || (0x0d == *headp)) {
+ /* headers are in network encoding so use 0x0a and 0x0d instead of '\n'
+ and '\r' */
+ headp = Curl_dyn_ptr(&data->state.headerb);
+ if((0x0a == *headp) || (0x0d == *headp)) {
size_t headerlen;
/* Zero-length header line means end of headers! */
#ifdef CURL_DOES_CONVERSIONS
- if(0x0d == *headp) {
- *headp = '\r'; /* replace with CR in host encoding */
- headp++; /* pass the CR byte */
+ if(0x0d == *headp) {
+ *headp = '\r'; /* replace with CR in host encoding */
+ headp++; /* pass the CR byte */
}
- if(0x0a == *headp) {
- *headp = '\n'; /* replace with LF in host encoding */
- headp++; /* pass the LF byte */
+ if(0x0a == *headp) {
+ *headp = '\n'; /* replace with LF in host encoding */
+ headp++; /* pass the LF byte */
}
#else
- if('\r' == *headp)
- headp++; /* pass the \r byte */
- if('\n' == *headp)
- headp++; /* pass the \n byte */
+ if('\r' == *headp)
+ headp++; /* pass the \r byte */
+ if('\n' == *headp)
+ headp++; /* pass the \n byte */
#endif /* CURL_DOES_CONVERSIONS */
if(100 <= k->httpcode && 199 >= k->httpcode) {
@@ -3323,7 +3323,7 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
if((k->size == -1) && !k->chunk && !conn->bits.close &&
(conn->httpversion == 11) &&
!(conn->handler->protocol & CURLPROTO_RTSP) &&
- data->state.httpreq != HTTPREQ_HEAD) {
+ data->state.httpreq != HTTPREQ_HEAD) {
/* On HTTP 1.1, when connection is not to get closed, but no
Content-Length nor Transfer-Encoding chunked have been
received, according to RFC2616 section 4.4 point 5, we
@@ -3381,9 +3381,9 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
if(data->set.include_header)
writetype |= CLIENTWRITE_BODY;
- headerlen = Curl_dyn_len(&data->state.headerb);
+ headerlen = Curl_dyn_len(&data->state.headerb);
result = Curl_client_write(conn, writetype,
- Curl_dyn_ptr(&data->state.headerb),
+ Curl_dyn_ptr(&data->state.headerb),
headerlen);
if(result)
return result;
@@ -3418,7 +3418,7 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
* continue sending even if it gets discarded
*/
- switch(data->state.httpreq) {
+ switch(data->state.httpreq) {
case HTTPREQ_PUT:
case HTTPREQ_POST:
case HTTPREQ_POST_FORM:
@@ -3429,16 +3429,16 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
*/
Curl_expire_done(data, EXPIRE_100_TIMEOUT);
if(!k->upload_done) {
- if((k->httpcode == 417) && data->state.expect100header) {
- /* 417 Expectation Failed - try again without the Expect
- header */
- infof(data, "Got 417 while waiting for a 100\n");
- data->state.disableexpect = TRUE;
- DEBUGASSERT(!data->req.newurl);
- data->req.newurl = strdup(conn->data->change.url);
- Curl_done_sending(conn, k);
- }
- else if(data->set.http_keep_sending_on_error) {
+ if((k->httpcode == 417) && data->state.expect100header) {
+ /* 417 Expectation Failed - try again without the Expect
+ header */
+ infof(data, "Got 417 while waiting for a 100\n");
+ data->state.disableexpect = TRUE;
+ DEBUGASSERT(!data->req.newurl);
+ data->req.newurl = strdup(conn->data->change.url);
+ Curl_done_sending(conn, k);
+ }
+ else if(data->set.http_keep_sending_on_error) {
infof(data, "HTTP error before end of send, keep sending\n");
if(k->exp100 > EXP100_SEND_DATA) {
k->exp100 = EXP100_SEND_DATA;
@@ -3534,12 +3534,12 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
k->keepon &= ~KEEP_RECV;
}
- Curl_debug(data, CURLINFO_HEADER_IN, str_start, headerlen);
- break; /* exit header line loop */
+ Curl_debug(data, CURLINFO_HEADER_IN, str_start, headerlen);
+ break; /* exit header line loop */
}
- /* We continue reading headers, reset the line-based header */
- Curl_dyn_reset(&data->state.headerb);
+ /* We continue reading headers, reset the line-based header */
+ Curl_dyn_reset(&data->state.headerb);
continue;
}
@@ -3558,11 +3558,11 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
#define SCRATCHSIZE 21
CURLcode res;
char scratch[SCRATCHSIZE + 1]; /* "HTTP/major.minor 123" */
- /* We can't really convert this yet because we don't know if it's the
- 1st header line or the body. So we do a partial conversion into a
- scratch area, leaving the data at 'headp' as-is.
+ /* We can't really convert this yet because we don't know if it's the
+ 1st header line or the body. So we do a partial conversion into a
+ scratch area, leaving the data at 'headp' as-is.
*/
- strncpy(&scratch[0], headp, SCRATCHSIZE);
+ strncpy(&scratch[0], headp, SCRATCHSIZE);
scratch[SCRATCHSIZE] = 0; /* null terminate */
res = Curl_convert_from_network(data,
&scratch[0],
@@ -3571,7 +3571,7 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
/* Curl_convert_from_network calls failf if unsuccessful */
return res;
#else
-#define HEADER1 headp /* no conversion needed, just use headp */
+#define HEADER1 headp /* no conversion needed, just use headp */
#endif /* CURL_DOES_CONVERSIONS */
if(conn->handler->protocol & PROTO_FAMILY_HTTP) {
@@ -3622,11 +3622,11 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
compare header line against list of aliases
*/
if(!nc) {
- statusline check =
- checkhttpprefix(data,
- Curl_dyn_ptr(&data->state.headerb),
- Curl_dyn_len(&data->state.headerb));
- if(check == STATUS_DONE) {
+ statusline check =
+ checkhttpprefix(data,
+ Curl_dyn_ptr(&data->state.headerb),
+ Curl_dyn_len(&data->state.headerb));
+ if(check == STATUS_DONE) {
nc = 1;
k->httpcode = 200;
conn->httpversion = 10;
@@ -3672,18 +3672,18 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
* depending on how authentication is working. Other codes
* are definitely errors, so give up here.
*/
- if(data->state.resume_from && data->state.httpreq == HTTPREQ_GET &&
+ if(data->state.resume_from && data->state.httpreq == HTTPREQ_GET &&
k->httpcode == 416) {
/* "Requested Range Not Satisfiable", just proceed and
pretend this is no error */
k->ignorebody = TRUE; /* Avoid appending error msg to good data. */
}
else if(data->set.http_fail_on_error && (k->httpcode >= 400) &&
- ((k->httpcode != 401) || !conn->bits.user_passwd)
-#ifndef CURL_DISABLE_PROXY
- && ((k->httpcode != 407) || !conn->bits.proxy_user_passwd)
-#endif
- ) {
+ ((k->httpcode != 401) || !conn->bits.user_passwd)
+#ifndef CURL_DISABLE_PROXY
+ && ((k->httpcode != 407) || !conn->bits.proxy_user_passwd)
+#endif
+ ) {
/* serious error, go home! */
print_http_error(data);
return CURLE_HTTP_RETURNED_ERROR;
@@ -3699,8 +3699,8 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
else if(conn->httpversion == 20 ||
(k->upgr101 == UPGR101_REQUESTED && k->httpcode == 101)) {
DEBUGF(infof(data, "HTTP/2 found, allow multiplexing\n"));
- /* HTTP/2 cannot avoid multiplexing since it is a core functionality
- of the protocol */
+ /* HTTP/2 cannot avoid multiplexing since it is a core functionality
+ of the protocol */
conn->bundle->multiuse = BUNDLE_MULTIPLEX;
}
else if(conn->httpversion >= 11 &&
@@ -3740,16 +3740,16 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
}
}
- result = Curl_convert_from_network(data, headp, strlen(headp));
+ result = Curl_convert_from_network(data, headp, strlen(headp));
/* Curl_convert_from_network calls failf if unsuccessful */
if(result)
return result;
/* Check for Content-Length: header lines to get size */
if(!k->http_bodyless &&
- !data->set.ignorecl && checkprefix("Content-Length:", headp)) {
+ !data->set.ignorecl && checkprefix("Content-Length:", headp)) {
curl_off_t contentlength;
- CURLofft offt = curlx_strtoofft(headp + 15, NULL, 10, &contentlength);
+ CURLofft offt = curlx_strtoofft(headp + 15, NULL, 10, &contentlength);
if(offt == CURL_OFFT_OK) {
if(data->set.max_filesize &&
@@ -3780,8 +3780,8 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
}
}
/* check for Content-Type: header lines to get the MIME-type */
- else if(checkprefix("Content-Type:", headp)) {
- char *contenttype = Curl_copy_header_value(headp);
+ else if(checkprefix("Content-Type:", headp)) {
+ char *contenttype = Curl_copy_header_value(headp);
if(!contenttype)
return CURLE_OUT_OF_MEMORY;
if(!*contenttype)
@@ -3792,10 +3792,10 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
data->info.contenttype = contenttype;
}
}
-#ifndef CURL_DISABLE_PROXY
+#ifndef CURL_DISABLE_PROXY
else if((conn->httpversion == 10) &&
conn->bits.httpproxy &&
- Curl_compareheader(headp, "Proxy-Connection:", "keep-alive")) {
+ Curl_compareheader(headp, "Proxy-Connection:", "keep-alive")) {
/*
* When a HTTP/1.0 reply comes when using a proxy, the
* 'Proxy-Connection: keep-alive' line tells us the
@@ -3807,7 +3807,7 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
}
else if((conn->httpversion == 11) &&
conn->bits.httpproxy &&
- Curl_compareheader(headp, "Proxy-Connection:", "close")) {
+ Curl_compareheader(headp, "Proxy-Connection:", "close")) {
/*
* We get a HTTP/1.1 response from a proxy and it says it'll
* close down after this transfer.
@@ -3815,9 +3815,9 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
connclose(conn, "Proxy-Connection: asked to close after done");
infof(data, "HTTP/1.1 proxy connection set close!\n");
}
-#endif
+#endif
else if((conn->httpversion == 10) &&
- Curl_compareheader(headp, "Connection:", "keep-alive")) {
+ Curl_compareheader(headp, "Connection:", "keep-alive")) {
/*
* A HTTP/1.0 reply with the 'Connection: keep-alive' line
* tells us the connection will be kept alive for our
@@ -3827,7 +3827,7 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
connkeep(conn, "Connection keep-alive");
infof(data, "HTTP/1.0 connection set to keep alive!\n");
}
- else if(Curl_compareheader(headp, "Connection:", "close")) {
+ else if(Curl_compareheader(headp, "Connection:", "close")) {
/*
* [RFC 2616, section 8.1.2.1]
* "Connection: close" is HTTP/1.1 language and means that
@@ -3836,7 +3836,7 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
*/
streamclose(conn, "Connection: close used");
}
- else if(!k->http_bodyless && checkprefix("Transfer-Encoding:", headp)) {
+ else if(!k->http_bodyless && checkprefix("Transfer-Encoding:", headp)) {
/* One or more encodings. We check for chunked and/or a compression
algorithm. */
/*
@@ -3848,11 +3848,11 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
* of chunks, and a chunk-data set to zero signals the
* end-of-chunks. */
- result = Curl_build_unencoding_stack(conn, headp + 18, TRUE);
+ result = Curl_build_unencoding_stack(conn, headp + 18, TRUE);
if(result)
return result;
}
- else if(!k->http_bodyless && checkprefix("Content-Encoding:", headp) &&
+ else if(!k->http_bodyless && checkprefix("Content-Encoding:", headp) &&
data->set.str[STRING_ENCODING]) {
/*
* Process Content-Encoding. Look for the values: identity,
@@ -3861,24 +3861,24 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
* 2616). zlib cannot handle compress. However, errors are
* handled further down when the response body is processed
*/
- result = Curl_build_unencoding_stack(conn, headp + 17, FALSE);
+ result = Curl_build_unencoding_stack(conn, headp + 17, FALSE);
if(result)
return result;
}
- else if(checkprefix("Retry-After:", headp)) {
+ else if(checkprefix("Retry-After:", headp)) {
/* Retry-After = HTTP-date / delay-seconds */
curl_off_t retry_after = 0; /* zero for unknown or "now" */
- time_t date = Curl_getdate_capped(&headp[12]);
+ time_t date = Curl_getdate_capped(&headp[12]);
if(-1 == date) {
/* not a date, try it as a decimal number */
- (void)curlx_strtoofft(&headp[12], NULL, 10, &retry_after);
+ (void)curlx_strtoofft(&headp[12], NULL, 10, &retry_after);
}
else
/* convert date to number of seconds into the future */
retry_after = date - time(NULL);
data->info.retry_after = retry_after; /* store it */
}
- else if(!k->http_bodyless && checkprefix("Content-Range:", headp)) {
+ else if(!k->http_bodyless && checkprefix("Content-Range:", headp)) {
/* Content-Range: bytes [num]-
Content-Range: bytes: [num]-
Content-Range: [num]-
@@ -3890,7 +3890,7 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
The forth means the requested range was unsatisfied.
*/
- char *ptr = headp + 14;
+ char *ptr = headp + 14;
/* Move forward until first digit or asterisk */
while(*ptr && !ISDIGIT(*ptr) && *ptr != '*')
@@ -3908,35 +3908,35 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
data->state.resume_from = 0; /* get everything */
}
#if !defined(CURL_DISABLE_COOKIES)
- else if(data->cookies && data->state.cookie_engine &&
- checkprefix("Set-Cookie:", headp)) {
+ else if(data->cookies && data->state.cookie_engine &&
+ checkprefix("Set-Cookie:", headp)) {
Curl_share_lock(data, CURL_LOCK_DATA_COOKIE,
CURL_LOCK_ACCESS_SINGLE);
Curl_cookie_add(data,
- data->cookies, TRUE, FALSE, headp + 11,
+ data->cookies, TRUE, FALSE, headp + 11,
/* If there is a custom-set Host: name, use it
here, or else use real peer host name. */
- data->state.aptr.cookiehost?
- data->state.aptr.cookiehost:conn->host.name,
+ data->state.aptr.cookiehost?
+ data->state.aptr.cookiehost:conn->host.name,
data->state.up.path,
(conn->handler->protocol&CURLPROTO_HTTPS)?
TRUE:FALSE);
Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE);
}
#endif
- else if(!k->http_bodyless && checkprefix("Last-Modified:", headp) &&
+ else if(!k->http_bodyless && checkprefix("Last-Modified:", headp) &&
(data->set.timecondition || data->set.get_filetime) ) {
- k->timeofdoc = Curl_getdate_capped(headp + strlen("Last-Modified:"));
+ k->timeofdoc = Curl_getdate_capped(headp + strlen("Last-Modified:"));
if(data->set.get_filetime)
data->info.filetime = k->timeofdoc;
}
- else if((checkprefix("WWW-Authenticate:", headp) &&
+ else if((checkprefix("WWW-Authenticate:", headp) &&
(401 == k->httpcode)) ||
- (checkprefix("Proxy-authenticate:", headp) &&
+ (checkprefix("Proxy-authenticate:", headp) &&
(407 == k->httpcode))) {
bool proxy = (k->httpcode == 407) ? TRUE : FALSE;
- char *auth = Curl_copy_header_value(headp);
+ char *auth = Curl_copy_header_value(headp);
if(!auth)
return CURLE_OUT_OF_MEMORY;
@@ -3947,28 +3947,28 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
if(result)
return result;
}
-#ifdef USE_SPNEGO
- else if(checkprefix("Persistent-Auth", headp)) {
+#ifdef USE_SPNEGO
+ else if(checkprefix("Persistent-Auth", headp)) {
struct negotiatedata *negdata = &conn->negotiate;
struct auth *authp = &data->state.authhost;
if(authp->picked == CURLAUTH_NEGOTIATE) {
- char *persistentauth = Curl_copy_header_value(headp);
+ char *persistentauth = Curl_copy_header_value(headp);
if(!persistentauth)
return CURLE_OUT_OF_MEMORY;
- negdata->noauthpersist = checkprefix("false", persistentauth)?
- TRUE:FALSE;
+ negdata->noauthpersist = checkprefix("false", persistentauth)?
+ TRUE:FALSE;
negdata->havenoauthpersist = TRUE;
infof(data, "Negotiate: noauthpersist -> %d, header part: %s",
negdata->noauthpersist, persistentauth);
free(persistentauth);
}
}
-#endif
+#endif
else if((k->httpcode >= 300 && k->httpcode < 400) &&
- checkprefix("Location:", headp) &&
+ checkprefix("Location:", headp) &&
!data->req.location) {
/* this is the URL that the server advises us to use instead */
- char *location = Curl_copy_header_value(headp);
+ char *location = Curl_copy_header_value(headp);
if(!location)
return CURLE_OUT_OF_MEMORY;
if(!*location)
@@ -3991,26 +3991,26 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
}
}
}
-
-#ifdef USE_HSTS
+
+#ifdef USE_HSTS
+ /* If enabled, the header is incoming and this is over HTTPS */
+ else if(data->hsts && checkprefix("Strict-Transport-Security:", headp) &&
+ (conn->handler->flags & PROTOPT_SSL)) {
+ CURLcode check =
+ Curl_hsts_parse(data->hsts, data->state.up.hostname,
+ &headp[ sizeof("Strict-Transport-Security:") -1 ]);
+ if(check)
+ infof(data, "Illegal STS header skipped\n");
+#ifdef DEBUGBUILD
+ else
+ infof(data, "Parsed STS header fine (%zu entries)\n",
+ data->hsts->list.size);
+#endif
+ }
+#endif
+#ifndef CURL_DISABLE_ALTSVC
/* If enabled, the header is incoming and this is over HTTPS */
- else if(data->hsts && checkprefix("Strict-Transport-Security:", headp) &&
- (conn->handler->flags & PROTOPT_SSL)) {
- CURLcode check =
- Curl_hsts_parse(data->hsts, data->state.up.hostname,
- &headp[ sizeof("Strict-Transport-Security:") -1 ]);
- if(check)
- infof(data, "Illegal STS header skipped\n");
-#ifdef DEBUGBUILD
- else
- infof(data, "Parsed STS header fine (%zu entries)\n",
- data->hsts->list.size);
-#endif
- }
-#endif
-#ifndef CURL_DISABLE_ALTSVC
- /* If enabled, the header is incoming and this is over HTTPS */
- else if(data->asi && checkprefix("Alt-Svc:", headp) &&
+ else if(data->asi && checkprefix("Alt-Svc:", headp) &&
((conn->handler->flags & PROTOPT_SSL) ||
#ifdef CURLDEBUG
/* allow debug builds to circumvent the HTTPS restriction */
@@ -4022,7 +4022,7 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
/* the ALPN of the current request */
enum alpnid id = (conn->httpversion == 20) ? ALPN_h2 : ALPN_h1;
result = Curl_altsvc_parse(data, data->asi,
- &headp[ strlen("Alt-Svc:") ],
+ &headp[ strlen("Alt-Svc:") ],
id, conn->host.name,
curlx_uitous(conn->remote_port));
if(result)
@@ -4030,7 +4030,7 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
}
#endif
else if(conn->handler->protocol & CURLPROTO_RTSP) {
- result = Curl_rtsp_parseheader(conn, headp);
+ result = Curl_rtsp_parseheader(conn, headp);
if(result)
return result;
}
@@ -4043,18 +4043,18 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
if(data->set.include_header)
writetype |= CLIENTWRITE_BODY;
- Curl_debug(data, CURLINFO_HEADER_IN, headp,
- Curl_dyn_len(&data->state.headerb));
+ Curl_debug(data, CURLINFO_HEADER_IN, headp,
+ Curl_dyn_len(&data->state.headerb));
- result = Curl_client_write(conn, writetype, headp,
- Curl_dyn_len(&data->state.headerb));
+ result = Curl_client_write(conn, writetype, headp,
+ Curl_dyn_len(&data->state.headerb));
if(result)
return result;
- data->info.header_size += Curl_dyn_len(&data->state.headerb);
- data->req.headerbytecount += Curl_dyn_len(&data->state.headerb);
+ data->info.header_size += Curl_dyn_len(&data->state.headerb);
+ data->req.headerbytecount += Curl_dyn_len(&data->state.headerb);
- Curl_dyn_reset(&data->state.headerb);
+ Curl_dyn_reset(&data->state.headerb);
}
while(*k->str); /* header line within buffer */
diff --git a/contrib/libs/curl/lib/http.h b/contrib/libs/curl/lib/http.h
index 0cef417065..1aaec225e2 100644
--- a/contrib/libs/curl/lib/http.h
+++ b/contrib/libs/curl/lib/http.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -44,19 +44,19 @@ char *Curl_copy_header_value(const char *header);
char *Curl_checkProxyheaders(const struct connectdata *conn,
const char *thisheader);
-CURLcode Curl_buffer_send(struct dynbuf *in,
- struct connectdata *conn,
- curl_off_t *bytes_written,
- size_t included_body_bytes,
- int socketindex);
+CURLcode Curl_buffer_send(struct dynbuf *in,
+ struct connectdata *conn,
+ curl_off_t *bytes_written,
+ size_t included_body_bytes,
+ int socketindex);
CURLcode Curl_add_timecondition(const struct connectdata *conn,
- struct dynbuf *buf);
+ struct dynbuf *buf);
CURLcode Curl_add_custom_headers(struct connectdata *conn,
bool is_connect,
- struct dynbuf *req_buffer);
+ struct dynbuf *req_buffer);
CURLcode Curl_http_compile_trailers(struct curl_slist *trailers,
- struct dynbuf *buf,
+ struct dynbuf *buf,
struct Curl_easy *handle);
/* protocol-specific functions set up to be called by the main engine */
@@ -97,7 +97,7 @@ CURLcode Curl_http_auth_act(struct connectdata *conn);
*
*/
#ifndef EXPECT_100_THRESHOLD
-#define EXPECT_100_THRESHOLD (1024*1024)
+#define EXPECT_100_THRESHOLD (1024*1024)
#endif
#endif /* CURL_DISABLE_HTTP */
@@ -135,9 +135,9 @@ struct HTTP {
} sending;
#ifndef CURL_DISABLE_HTTP
- struct dynbuf send_buffer; /* used if the request couldn't be sent in one
- chunk, points to an allocated send_buffer
- struct */
+ struct dynbuf send_buffer; /* used if the request couldn't be sent in one
+ chunk, points to an allocated send_buffer
+ struct */
#endif
#ifdef USE_NGHTTP2
/*********** for HTTP/2 we store stream-local data here *************/
@@ -145,10 +145,10 @@ struct HTTP {
bool bodystarted;
/* We store non-final and final response headers here, per-stream */
- struct dynbuf header_recvbuf;
+ struct dynbuf header_recvbuf;
size_t nread_header_recvbuf; /* number of bytes in header_recvbuf fed into
upper layer */
- struct dynbuf trailer_recvbuf;
+ struct dynbuf trailer_recvbuf;
int status_code; /* HTTP status code */
const uint8_t *pausedata; /* pointer to data received in on_data_chunk */
size_t pauselen; /* the number of bytes left in data */
@@ -174,15 +174,15 @@ struct HTTP {
#ifdef ENABLE_QUIC
/*********** for HTTP/3 we store stream-local data here *************/
int64_t stream3_id; /* stream we are interested in */
- bool firstheader; /* FALSE until headers arrive */
+ bool firstheader; /* FALSE until headers arrive */
bool firstbody; /* FALSE until body arrives */
bool h3req; /* FALSE until request is issued */
bool upload_done;
#endif
#ifdef USE_NGHTTP3
- size_t unacked_window;
+ size_t unacked_window;
struct h3out *h3out; /* per-stream buffers for upload */
- struct dynbuf overflow; /* excess data received during a single Curl_read */
+ struct dynbuf overflow; /* excess data received during a single Curl_read */
#endif
};
diff --git a/contrib/libs/curl/lib/http2.c b/contrib/libs/curl/lib/http2.c
index 41c2c8e4d6..b138fb4b0f 100644
--- a/contrib/libs/curl/lib/http2.c
+++ b/contrib/libs/curl/lib/http2.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -36,7 +36,7 @@
#include "connect.h"
#include "strtoofft.h"
#include "strdup.h"
-#include "dynbuf.h"
+#include "dynbuf.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
#include "curl_memory.h"
@@ -44,11 +44,11 @@
#define H2_BUFSIZE 32768
-#if (NGHTTP2_VERSION_NUM < 0x010c00)
+#if (NGHTTP2_VERSION_NUM < 0x010c00)
#error too old nghttp2 version, upgrade!
#endif
-#ifdef CURL_DISABLE_VERBOSE_STRINGS
+#ifdef CURL_DISABLE_VERBOSE_STRINGS
#define nghttp2_session_callbacks_set_error_callback(x,y)
#endif
@@ -56,12 +56,12 @@
#define NGHTTP2_HAS_SET_LOCAL_WINDOW_SIZE 1
#endif
-#define HTTP2_HUGE_WINDOW_SIZE (32 * 1024 * 1024) /* 32 MB */
+#define HTTP2_HUGE_WINDOW_SIZE (32 * 1024 * 1024) /* 32 MB */
#ifdef DEBUG_HTTP2
#define H2BUGF(x) x
#else
-#define H2BUGF(x) do { } while(0)
+#define H2BUGF(x) do { } while(0)
#endif
@@ -125,7 +125,7 @@ static int http2_getsock(struct connectdata *conn,
static void http2_stream_free(struct HTTP *http)
{
if(http) {
- Curl_dyn_free(&http->header_recvbuf);
+ Curl_dyn_free(&http->header_recvbuf);
for(; http->push_headers_used > 0; --http->push_headers_used) {
free(http->push_headers[http->push_headers_used - 1]);
}
@@ -257,15 +257,15 @@ static unsigned int http2_conncheck(struct connectdata *check,
/* called from http_setup_conn */
void Curl_http2_setup_req(struct Curl_easy *data)
{
- struct HTTP *http = data->req.p.http;
+ struct HTTP *http = data->req.p.http;
http->bodystarted = FALSE;
http->status_code = -1;
http->pausedata = NULL;
http->pauselen = 0;
http->closed = FALSE;
http->close_handled = FALSE;
- http->mem = NULL;
- http->len = 0;
+ http->mem = NULL;
+ http->len = 0;
http->memlen = 0;
}
@@ -300,7 +300,7 @@ static const struct Curl_handler Curl_handler_http2 = {
http2_conncheck, /* connection_check */
PORT_HTTP, /* defport */
CURLPROTO_HTTP, /* protocol */
- CURLPROTO_HTTP, /* family */
+ CURLPROTO_HTTP, /* family */
PROTOPT_STREAM /* flags */
};
@@ -322,7 +322,7 @@ static const struct Curl_handler Curl_handler_http2_ssl = {
http2_conncheck, /* connection_check */
PORT_HTTP, /* defport */
CURLPROTO_HTTPS, /* protocol */
- CURLPROTO_HTTP, /* family */
+ CURLPROTO_HTTP, /* family */
PROTOPT_SSL | PROTOPT_STREAM /* flags */
};
@@ -333,7 +333,7 @@ static const struct Curl_handler Curl_handler_http2_ssl = {
int Curl_http2_ver(char *p, size_t len)
{
nghttp2_info *h2 = nghttp2_version(0);
- return msnprintf(p, len, "nghttp2/%s", h2->version_str);
+ return msnprintf(p, len, "nghttp2/%s", h2->version_str);
}
/*
@@ -393,7 +393,7 @@ char *curl_pushheader_bynum(struct curl_pushheaders *h, size_t num)
if(!h || !GOOD_EASY_HANDLE(h->data))
return NULL;
else {
- struct HTTP *stream = h->data->req.p.http;
+ struct HTTP *stream = h->data->req.p.http;
if(num < stream->push_headers_used)
return stream->push_headers[num];
}
@@ -415,7 +415,7 @@ char *curl_pushheader_byname(struct curl_pushheaders *h, const char *header)
!strcmp(header, ":") || strchr(header + 1, ':'))
return NULL;
else {
- struct HTTP *stream = h->data->req.p.http;
+ struct HTTP *stream = h->data->req.p.http;
size_t len = strlen(header);
size_t i;
for(i = 0; i<stream->push_headers_used; i++) {
@@ -459,64 +459,64 @@ static struct Curl_easy *duphandle(struct Curl_easy *data)
/* setup the request struct */
struct HTTP *http = calloc(1, sizeof(struct HTTP));
if(!http) {
- (void)Curl_close(&second);
+ (void)Curl_close(&second);
}
else {
- second->req.p.http = http;
- Curl_dyn_init(&http->header_recvbuf, DYN_H2_HEADERS);
- Curl_http2_setup_req(second);
- second->state.stream_weight = data->state.stream_weight;
+ second->req.p.http = http;
+ Curl_dyn_init(&http->header_recvbuf, DYN_H2_HEADERS);
+ Curl_http2_setup_req(second);
+ second->state.stream_weight = data->state.stream_weight;
}
}
return second;
}
-static int set_transfer_url(struct Curl_easy *data,
- struct curl_pushheaders *hp)
-{
- const char *v;
- CURLU *u = curl_url();
- CURLUcode uc;
- char *url;
-
- v = curl_pushheader_byname(hp, ":scheme");
- if(v) {
- uc = curl_url_set(u, CURLUPART_SCHEME, v, 0);
- if(uc)
- return 1;
- }
-
- v = curl_pushheader_byname(hp, ":authority");
- if(v) {
- uc = curl_url_set(u, CURLUPART_HOST, v, 0);
- if(uc)
- return 2;
- }
-
- v = curl_pushheader_byname(hp, ":path");
- if(v) {
- uc = curl_url_set(u, CURLUPART_PATH, v, 0);
- if(uc)
- return 3;
- }
-
- uc = curl_url_get(u, CURLUPART_URL, &url, 0);
- if(uc)
- return 4;
- curl_url_cleanup(u);
-
- if(data->change.url_alloc)
- free(data->change.url);
- data->change.url_alloc = TRUE;
- data->change.url = url;
- return 0;
-}
-
+static int set_transfer_url(struct Curl_easy *data,
+ struct curl_pushheaders *hp)
+{
+ const char *v;
+ CURLU *u = curl_url();
+ CURLUcode uc;
+ char *url;
+
+ v = curl_pushheader_byname(hp, ":scheme");
+ if(v) {
+ uc = curl_url_set(u, CURLUPART_SCHEME, v, 0);
+ if(uc)
+ return 1;
+ }
+
+ v = curl_pushheader_byname(hp, ":authority");
+ if(v) {
+ uc = curl_url_set(u, CURLUPART_HOST, v, 0);
+ if(uc)
+ return 2;
+ }
+
+ v = curl_pushheader_byname(hp, ":path");
+ if(v) {
+ uc = curl_url_set(u, CURLUPART_PATH, v, 0);
+ if(uc)
+ return 3;
+ }
+
+ uc = curl_url_get(u, CURLUPART_URL, &url, 0);
+ if(uc)
+ return 4;
+ curl_url_cleanup(u);
+
+ if(data->change.url_alloc)
+ free(data->change.url);
+ data->change.url_alloc = TRUE;
+ data->change.url = url;
+ return 0;
+}
+
static int push_promise(struct Curl_easy *data,
struct connectdata *conn,
const nghttp2_push_promise *frame)
{
- int rv; /* one of the CURL_PUSH_* defines */
+ int rv; /* one of the CURL_PUSH_* defines */
H2BUGF(infof(data, "PUSH_PROMISE received, stream %u!\n",
frame->promised_stream_id));
if(data->multi->push_cb) {
@@ -530,7 +530,7 @@ static int push_promise(struct Curl_easy *data,
struct Curl_easy *newhandle = duphandle(data);
if(!newhandle) {
infof(data, "failed to duplicate handle\n");
- rv = CURL_PUSH_DENY; /* FAIL HARD */
+ rv = CURL_PUSH_DENY; /* FAIL HARD */
goto fail;
}
@@ -539,20 +539,20 @@ static int push_promise(struct Curl_easy *data,
/* ask the application */
H2BUGF(infof(data, "Got PUSH_PROMISE, ask application!\n"));
- stream = data->req.p.http;
+ stream = data->req.p.http;
if(!stream) {
failf(data, "Internal NULL stream!\n");
- (void)Curl_close(&newhandle);
- rv = CURL_PUSH_DENY;
+ (void)Curl_close(&newhandle);
+ rv = CURL_PUSH_DENY;
+ goto fail;
+ }
+
+ rv = set_transfer_url(newhandle, &heads);
+ if(rv) {
+ rv = CURL_PUSH_DENY;
goto fail;
}
- rv = set_transfer_url(newhandle, &heads);
- if(rv) {
- rv = CURL_PUSH_DENY;
- goto fail;
- }
-
Curl_set_in_callback(data, true);
rv = data->multi->push_cb(data, newhandle,
stream->push_headers_used, &heads,
@@ -567,15 +567,15 @@ static int push_promise(struct Curl_easy *data,
stream->push_headers_used = 0;
if(rv) {
- DEBUGASSERT((rv > CURL_PUSH_OK) && (rv <= CURL_PUSH_ERROROUT));
+ DEBUGASSERT((rv > CURL_PUSH_OK) && (rv <= CURL_PUSH_ERROROUT));
/* denied, kill off the new handle again */
- http2_stream_free(newhandle->req.p.http);
- newhandle->req.p.http = NULL;
- (void)Curl_close(&newhandle);
+ http2_stream_free(newhandle->req.p.http);
+ newhandle->req.p.http = NULL;
+ (void)Curl_close(&newhandle);
goto fail;
}
- newstream = newhandle->req.p.http;
+ newstream = newhandle->req.p.http;
newstream->stream_id = frame->promised_stream_id;
newhandle->req.maxdownload = -1;
newhandle->req.size = -1;
@@ -585,10 +585,10 @@ static int push_promise(struct Curl_easy *data,
rc = Curl_multi_add_perform(data->multi, newhandle, conn);
if(rc) {
infof(data, "failed to add handle to multi\n");
- http2_stream_free(newhandle->req.p.http);
- newhandle->req.p.http = NULL;
- Curl_close(&newhandle);
- rv = CURL_PUSH_DENY;
+ http2_stream_free(newhandle->req.p.http);
+ newhandle->req.p.http = NULL;
+ Curl_close(&newhandle);
+ rv = CURL_PUSH_DENY;
goto fail;
}
@@ -600,13 +600,13 @@ static int push_promise(struct Curl_easy *data,
infof(data, "failed to set user_data for stream %d\n",
frame->promised_stream_id);
DEBUGASSERT(0);
- rv = CURL_PUSH_DENY;
+ rv = CURL_PUSH_DENY;
goto fail;
}
}
else {
H2BUGF(infof(data, "Got PUSH_PROMISE, ignore it!\n"));
- rv = CURL_PUSH_DENY;
+ rv = CURL_PUSH_DENY;
}
fail:
return rv;
@@ -669,7 +669,7 @@ static int on_frame_recv(nghttp2_session *session, const nghttp2_frame *frame,
return 0;
}
- stream = data_s->req.p.http;
+ stream = data_s->req.p.http;
if(!stream) {
H2BUGF(infof(data_s, "No proto pointer for stream: %x\n",
stream_id));
@@ -710,17 +710,17 @@ static int on_frame_recv(nghttp2_session *session, const nghttp2_frame *frame,
stream->status_code = -1;
}
- result = Curl_dyn_add(&stream->header_recvbuf, "\r\n");
+ result = Curl_dyn_add(&stream->header_recvbuf, "\r\n");
if(result)
return NGHTTP2_ERR_CALLBACK_FAILURE;
- left = Curl_dyn_len(&stream->header_recvbuf) -
- stream->nread_header_recvbuf;
+ left = Curl_dyn_len(&stream->header_recvbuf) -
+ stream->nread_header_recvbuf;
ncopy = CURLMIN(stream->len, left);
memcpy(&stream->mem[stream->memlen],
- Curl_dyn_ptr(&stream->header_recvbuf) +
- stream->nread_header_recvbuf,
+ Curl_dyn_ptr(&stream->header_recvbuf) +
+ stream->nread_header_recvbuf,
ncopy);
stream->nread_header_recvbuf += ncopy;
@@ -743,16 +743,16 @@ static int on_frame_recv(nghttp2_session *session, const nghttp2_frame *frame,
case NGHTTP2_PUSH_PROMISE:
rv = push_promise(data_s, conn, &frame->push_promise);
if(rv) { /* deny! */
- int h2;
- DEBUGASSERT((rv > CURL_PUSH_OK) && (rv <= CURL_PUSH_ERROROUT));
- h2 = nghttp2_submit_rst_stream(session, NGHTTP2_FLAG_NONE,
+ int h2;
+ DEBUGASSERT((rv > CURL_PUSH_OK) && (rv <= CURL_PUSH_ERROROUT));
+ h2 = nghttp2_submit_rst_stream(session, NGHTTP2_FLAG_NONE,
frame->push_promise.promised_stream_id,
NGHTTP2_CANCEL);
- if(nghttp2_is_fatal(h2))
- return NGHTTP2_ERR_CALLBACK_FAILURE;
- else if(rv == CURL_PUSH_ERROROUT) {
- DEBUGF(infof(data_s, "Fail the parent stream (too)\n"));
- return NGHTTP2_ERR_CALLBACK_FAILURE;
+ if(nghttp2_is_fatal(h2))
+ return NGHTTP2_ERR_CALLBACK_FAILURE;
+ else if(rv == CURL_PUSH_ERROROUT) {
+ DEBUGF(infof(data_s, "Fail the parent stream (too)\n"));
+ return NGHTTP2_ERR_CALLBACK_FAILURE;
}
}
break;
@@ -785,7 +785,7 @@ static int on_data_chunk_recv(nghttp2_session *session, uint8_t flags,
internal error more than anything else! */
return NGHTTP2_ERR_CALLBACK_FAILURE;
- stream = data_s->req.p.http;
+ stream = data_s->req.p.http;
if(!stream)
return NGHTTP2_ERR_CALLBACK_FAILURE;
@@ -850,15 +850,15 @@ static int on_stream_close(nghttp2_session *session, int32_t stream_id,
return 0;
}
H2BUGF(infof(data_s, "on_stream_close(), %s (err %d), stream %u\n",
- nghttp2_http2_strerror(error_code), error_code, stream_id));
- stream = data_s->req.p.http;
+ nghttp2_http2_strerror(error_code), error_code, stream_id));
+ stream = data_s->req.p.http;
if(!stream)
return NGHTTP2_ERR_CALLBACK_FAILURE;
stream->closed = TRUE;
httpc = &conn->proto.httpc;
drain_this(data_s, httpc);
- Curl_expire(data_s, 0, EXPIRE_RUN_NOW);
+ Curl_expire(data_s, 0, EXPIRE_RUN_NOW);
httpc->error_code = error_code;
/* remove the entry from the hash as the stream is now gone */
@@ -896,7 +896,7 @@ static int on_begin_headers(nghttp2_session *session,
return 0;
}
- stream = data_s->req.p.http;
+ stream = data_s->req.p.http;
if(!stream || !stream->bodystarted) {
return 0;
}
@@ -954,7 +954,7 @@ static int on_header(nghttp2_session *session, const nghttp2_frame *frame,
internal error more than anything else! */
return NGHTTP2_ERR_CALLBACK_FAILURE;
- stream = data_s->req.p.http;
+ stream = data_s->req.p.http;
if(!stream) {
failf(data_s, "Internal NULL stream! 5\n");
return NGHTTP2_ERR_CALLBACK_FAILURE;
@@ -972,9 +972,9 @@ static int on_header(nghttp2_session *session, const nghttp2_frame *frame,
if(!check)
/* no memory */
return NGHTTP2_ERR_CALLBACK_FAILURE;
- if(!Curl_strcasecompare(check, (const char *)value) &&
- ((conn->remote_port != conn->given->defport) ||
- !Curl_strcasecompare(conn->host.name, (const char *)value))) {
+ if(!Curl_strcasecompare(check, (const char *)value) &&
+ ((conn->remote_port != conn->given->defport) ||
+ !Curl_strcasecompare(conn->host.name, (const char *)value))) {
/* This is push is not for the same authority that was asked for in
* the URL. RFC 7540 section 8.2 says: "A client MUST treat a
* PUSH_PROMISE for which the server is not authoritative as a stream
@@ -1016,12 +1016,12 @@ static int on_header(nghttp2_session *session, const nghttp2_frame *frame,
}
if(stream->bodystarted) {
- /* This is a trailer */
+ /* This is a trailer */
H2BUGF(infof(data_s, "h2 trailer: %.*s: %.*s\n", namelen, name, valuelen,
value));
- result = Curl_dyn_addf(&stream->trailer_recvbuf,
- "%.*s: %.*s\r\n", namelen, name,
- valuelen, value);
+ result = Curl_dyn_addf(&stream->trailer_recvbuf,
+ "%.*s: %.*s\r\n", namelen, name,
+ valuelen, value);
if(result)
return NGHTTP2_ERR_CALLBACK_FAILURE;
@@ -1036,14 +1036,14 @@ static int on_header(nghttp2_session *session, const nghttp2_frame *frame,
stream->status_code = decode_status_code(value, valuelen);
DEBUGASSERT(stream->status_code != -1);
- result = Curl_dyn_add(&stream->header_recvbuf, "HTTP/2 ");
+ result = Curl_dyn_add(&stream->header_recvbuf, "HTTP/2 ");
if(result)
return NGHTTP2_ERR_CALLBACK_FAILURE;
- result = Curl_dyn_addn(&stream->header_recvbuf, value, valuelen);
+ result = Curl_dyn_addn(&stream->header_recvbuf, value, valuelen);
if(result)
return NGHTTP2_ERR_CALLBACK_FAILURE;
/* the space character after the status code is mandatory */
- result = Curl_dyn_add(&stream->header_recvbuf, " \r\n");
+ result = Curl_dyn_add(&stream->header_recvbuf, " \r\n");
if(result)
return NGHTTP2_ERR_CALLBACK_FAILURE;
/* if we receive data for another handle, wake that up */
@@ -1058,16 +1058,16 @@ static int on_header(nghttp2_session *session, const nghttp2_frame *frame,
/* nghttp2 guarantees that namelen > 0, and :status was already
received, and this is not pseudo-header field . */
/* convert to a HTTP1-style header */
- result = Curl_dyn_addn(&stream->header_recvbuf, name, namelen);
+ result = Curl_dyn_addn(&stream->header_recvbuf, name, namelen);
if(result)
return NGHTTP2_ERR_CALLBACK_FAILURE;
- result = Curl_dyn_add(&stream->header_recvbuf, ": ");
+ result = Curl_dyn_add(&stream->header_recvbuf, ": ");
if(result)
return NGHTTP2_ERR_CALLBACK_FAILURE;
- result = Curl_dyn_addn(&stream->header_recvbuf, value, valuelen);
+ result = Curl_dyn_addn(&stream->header_recvbuf, value, valuelen);
if(result)
return NGHTTP2_ERR_CALLBACK_FAILURE;
- result = Curl_dyn_add(&stream->header_recvbuf, "\r\n");
+ result = Curl_dyn_add(&stream->header_recvbuf, "\r\n");
if(result)
return NGHTTP2_ERR_CALLBACK_FAILURE;
/* if we receive data for another handle, wake that up */
@@ -1102,7 +1102,7 @@ static ssize_t data_source_read_callback(nghttp2_session *session,
internal error more than anything else! */
return NGHTTP2_ERR_CALLBACK_FAILURE;
- stream = data_s->req.p.http;
+ stream = data_s->req.p.http;
if(!stream)
return NGHTTP2_ERR_CALLBACK_FAILURE;
}
@@ -1130,7 +1130,7 @@ static ssize_t data_source_read_callback(nghttp2_session *session,
return nread;
}
-#if !defined(CURL_DISABLE_VERBOSE_STRINGS)
+#if !defined(CURL_DISABLE_VERBOSE_STRINGS)
static int error_callback(nghttp2_session *session,
const char *msg,
size_t len,
@@ -1147,10 +1147,10 @@ static void populate_settings(struct connectdata *conn,
struct http_conn *httpc)
{
nghttp2_settings_entry *iv = httpc->local_settings;
- DEBUGASSERT(conn->data);
+ DEBUGASSERT(conn->data);
iv[0].settings_id = NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS;
- iv[0].value = Curl_multi_max_concurrent_streams(conn->data->multi);
+ iv[0].value = Curl_multi_max_concurrent_streams(conn->data->multi);
iv[1].settings_id = NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE;
iv[1].value = HTTP2_HUGE_WINDOW_SIZE;
@@ -1161,26 +1161,26 @@ static void populate_settings(struct connectdata *conn,
httpc->local_settings_num = 3;
}
-void Curl_http2_done(struct Curl_easy *data, bool premature)
+void Curl_http2_done(struct Curl_easy *data, bool premature)
{
- struct HTTP *http = data->req.p.http;
- struct http_conn *httpc = &data->conn->proto.httpc;
+ struct HTTP *http = data->req.p.http;
+ struct http_conn *httpc = &data->conn->proto.httpc;
/* there might be allocated resources done before this got the 'h2' pointer
setup */
- Curl_dyn_free(&http->header_recvbuf);
- Curl_dyn_free(&http->trailer_recvbuf);
- if(http->push_headers) {
- /* if they weren't used and then freed before */
- for(; http->push_headers_used > 0; --http->push_headers_used) {
- free(http->push_headers[http->push_headers_used - 1]);
+ Curl_dyn_free(&http->header_recvbuf);
+ Curl_dyn_free(&http->trailer_recvbuf);
+ if(http->push_headers) {
+ /* if they weren't used and then freed before */
+ for(; http->push_headers_used > 0; --http->push_headers_used) {
+ free(http->push_headers[http->push_headers_used - 1]);
}
- free(http->push_headers);
- http->push_headers = NULL;
+ free(http->push_headers);
+ http->push_headers = NULL;
}
- if(!(data->conn->handler->protocol&PROTO_FAMILY_HTTP) ||
- !httpc->h2) /* not HTTP/2 ? */
+ if(!(data->conn->handler->protocol&PROTO_FAMILY_HTTP) ||
+ !httpc->h2) /* not HTTP/2 ? */
return;
if(premature) {
@@ -1266,7 +1266,7 @@ static CURLcode http2_init(struct connectdata *conn)
/*
* Append headers to ask for a HTTP1.1 to HTTP2 upgrade.
*/
-CURLcode Curl_http2_request_upgrade(struct dynbuf *req,
+CURLcode Curl_http2_request_upgrade(struct dynbuf *req,
struct connectdata *conn)
{
CURLcode result;
@@ -1283,9 +1283,9 @@ CURLcode Curl_http2_request_upgrade(struct dynbuf *req,
binlen = nghttp2_pack_settings_payload(binsettings, H2_BINSETTINGS_LEN,
httpc->local_settings,
httpc->local_settings_num);
- if(binlen <= 0) {
+ if(binlen <= 0) {
failf(conn->data, "nghttp2 unexpectedly failed on pack_settings_payload");
- Curl_dyn_free(req);
+ Curl_dyn_free(req);
return CURLE_FAILED_INIT;
}
conn->proto.httpc.binlen = binlen;
@@ -1293,15 +1293,15 @@ CURLcode Curl_http2_request_upgrade(struct dynbuf *req,
result = Curl_base64url_encode(conn->data, (const char *)binsettings, binlen,
&base64, &blen);
if(result) {
- Curl_dyn_free(req);
+ Curl_dyn_free(req);
return result;
}
- result = Curl_dyn_addf(req,
- "Connection: Upgrade, HTTP2-Settings\r\n"
- "Upgrade: %s\r\n"
- "HTTP2-Settings: %s\r\n",
- NGHTTP2_CLEARTEXT_PROTO_VERSION_ID, base64);
+ result = Curl_dyn_addf(req,
+ "Connection: Upgrade, HTTP2-Settings\r\n"
+ "Upgrade: %s\r\n"
+ "HTTP2-Settings: %s\r\n",
+ NGHTTP2_CLEARTEXT_PROTO_VERSION_ID, base64);
free(base64);
k->upgr101 = UPGR101_REQUESTED;
@@ -1366,14 +1366,14 @@ static int h2_process_pending_input(struct connectdata *conn,
return -1;
}
- if(nghttp2_session_check_request_allowed(httpc->h2) == 0) {
- /* No more requests are allowed in the current session, so
- the connection may not be reused. This is set when a
- GOAWAY frame has been received or when the limit of stream
- identifiers has been reached. */
- connclose(conn, "http/2: No new requests allowed");
- }
-
+ if(nghttp2_session_check_request_allowed(httpc->h2) == 0) {
+ /* No more requests are allowed in the current session, so
+ the connection may not be reused. This is set when a
+ GOAWAY frame has been received or when the limit of stream
+ identifiers has been reached. */
+ connclose(conn, "http/2: No new requests allowed");
+ }
+
if(should_close_session(httpc)) {
H2BUGF(infof(data,
"h2_process_pending_input: nothing to do in this session\n"));
@@ -1400,11 +1400,11 @@ CURLcode Curl_http2_done_sending(struct connectdata *conn)
(conn->handler == &Curl_handler_http2)) {
/* make sure this is only attempted for HTTP/2 transfers */
- struct HTTP *stream = conn->data->req.p.http;
+ struct HTTP *stream = conn->data->req.p.http;
+
+ struct http_conn *httpc = &conn->proto.httpc;
+ nghttp2_session *h2 = httpc->h2;
- struct http_conn *httpc = &conn->proto.httpc;
- nghttp2_session *h2 = httpc->h2;
-
if(stream->upload_left) {
/* If the stream still thinks there's data left to upload. */
@@ -1416,23 +1416,23 @@ CURLcode Curl_http2_done_sending(struct connectdata *conn)
(void)h2_process_pending_input(conn, httpc, &result);
}
-
- /* If nghttp2 still has pending frames unsent */
- if(nghttp2_session_want_write(h2)) {
- struct Curl_easy *data = conn->data;
- struct SingleRequest *k = &data->req;
- int rv;
-
- H2BUGF(infof(data, "HTTP/2 still wants to send data (easy %p)\n", data));
-
- /* re-set KEEP_SEND to make sure we are called again */
- k->keepon |= KEEP_SEND;
-
- /* and attempt to send the pending frames */
- rv = h2_session_send(data, h2);
- if(rv != 0)
- result = CURLE_SEND_ERROR;
- }
+
+ /* If nghttp2 still has pending frames unsent */
+ if(nghttp2_session_want_write(h2)) {
+ struct Curl_easy *data = conn->data;
+ struct SingleRequest *k = &data->req;
+ int rv;
+
+ H2BUGF(infof(data, "HTTP/2 still wants to send data (easy %p)\n", data));
+
+ /* re-set KEEP_SEND to make sure we are called again */
+ k->keepon |= KEEP_SEND;
+
+ /* and attempt to send the pending frames */
+ rv = h2_session_send(data, h2);
+ if(rv != 0)
+ result = CURLE_SEND_ERROR;
+ }
}
return result;
}
@@ -1469,7 +1469,7 @@ static ssize_t http2_handle_stream_close(struct connectdata *conn,
}
else if(httpc->error_code != NGHTTP2_NO_ERROR) {
failf(data, "HTTP/2 stream %d was not closed cleanly: %s (err %u)",
- stream->stream_id, nghttp2_http2_strerror(httpc->error_code),
+ stream->stream_id, nghttp2_http2_strerror(httpc->error_code),
httpc->error_code);
*err = CURLE_HTTP2_STREAM;
return -1;
@@ -1483,28 +1483,28 @@ static ssize_t http2_handle_stream_close(struct connectdata *conn,
return -1;
}
- if(Curl_dyn_len(&stream->trailer_recvbuf)) {
- char *trailp = Curl_dyn_ptr(&stream->trailer_recvbuf);
- char *lf;
-
- do {
- size_t len = 0;
- CURLcode result;
- /* each trailer line ends with a newline */
- lf = strchr(trailp, '\n');
- if(!lf)
- break;
- len = lf + 1 - trailp;
+ if(Curl_dyn_len(&stream->trailer_recvbuf)) {
+ char *trailp = Curl_dyn_ptr(&stream->trailer_recvbuf);
+ char *lf;
- Curl_debug(data, CURLINFO_HEADER_IN, trailp, len);
- /* pass the trailers one by one to the callback */
- result = Curl_client_write(conn, CLIENTWRITE_HEADER, trailp, len);
+ do {
+ size_t len = 0;
+ CURLcode result;
+ /* each trailer line ends with a newline */
+ lf = strchr(trailp, '\n');
+ if(!lf)
+ break;
+ len = lf + 1 - trailp;
+
+ Curl_debug(data, CURLINFO_HEADER_IN, trailp, len);
+ /* pass the trailers one by one to the callback */
+ result = Curl_client_write(conn, CLIENTWRITE_HEADER, trailp, len);
if(result) {
*err = result;
return -1;
}
- trailp = ++lf;
- } while(lf);
+ trailp = ++lf;
+ } while(lf);
}
stream->close_handled = TRUE;
@@ -1523,7 +1523,7 @@ static void h2_pri_spec(struct Curl_easy *data,
nghttp2_priority_spec *pri_spec)
{
struct HTTP *depstream = (data->set.stream_depends_on?
- data->set.stream_depends_on->req.p.http:NULL);
+ data->set.stream_depends_on->req.p.http:NULL);
int32_t depstream_id = depstream? depstream->stream_id:0;
nghttp2_priority_spec_init(pri_spec, depstream_id, data->set.stream_weight,
data->set.stream_depends_e);
@@ -1540,7 +1540,7 @@ static void h2_pri_spec(struct Curl_easy *data,
static int h2_session_send(struct Curl_easy *data,
nghttp2_session *h2)
{
- struct HTTP *stream = data->req.p.http;
+ struct HTTP *stream = data->req.p.http;
if((data->set.stream_weight != data->state.stream_weight) ||
(data->set.stream_depends_e != data->state.stream_depends_e) ||
(data->set.stream_depends_on != data->state.stream_depends_on) ) {
@@ -1552,7 +1552,7 @@ static int h2_session_send(struct Curl_easy *data,
H2BUGF(infof(data, "Queuing PRIORITY on stream %u (easy %p)\n",
stream->stream_id, data));
- DEBUGASSERT(stream->stream_id != -1);
+ DEBUGASSERT(stream->stream_id != -1);
rv = nghttp2_submit_priority(h2, NGHTTP2_FLAG_NONE, stream->stream_id,
&pri_spec);
if(rv)
@@ -1568,7 +1568,7 @@ static ssize_t http2_recv(struct connectdata *conn, int sockindex,
ssize_t nread;
struct http_conn *httpc = &conn->proto.httpc;
struct Curl_easy *data = conn->data;
- struct HTTP *stream = data->req.p.http;
+ struct HTTP *stream = data->req.p.http;
(void)sockindex; /* we always do HTTP2 on sockindex 0 */
@@ -1595,13 +1595,13 @@ static ssize_t http2_recv(struct connectdata *conn, int sockindex,
*/
if(stream->bodystarted &&
- stream->nread_header_recvbuf < Curl_dyn_len(&stream->header_recvbuf)) {
- /* If there is header data pending for this stream to return, do that */
+ stream->nread_header_recvbuf < Curl_dyn_len(&stream->header_recvbuf)) {
+ /* If there is header data pending for this stream to return, do that */
size_t left =
- Curl_dyn_len(&stream->header_recvbuf) - stream->nread_header_recvbuf;
+ Curl_dyn_len(&stream->header_recvbuf) - stream->nread_header_recvbuf;
size_t ncopy = CURLMIN(len, left);
- memcpy(mem, Curl_dyn_ptr(&stream->header_recvbuf) +
- stream->nread_header_recvbuf, ncopy);
+ memcpy(mem, Curl_dyn_ptr(&stream->header_recvbuf) +
+ stream->nread_header_recvbuf, ncopy);
stream->nread_header_recvbuf += ncopy;
H2BUGF(infof(data, "http2_recv: Got %d bytes from header_recvbuf\n",
@@ -1609,12 +1609,12 @@ static ssize_t http2_recv(struct connectdata *conn, int sockindex,
return ncopy;
}
- H2BUGF(infof(data, "http2_recv: easy %p (stream %u) win %u/%u\n",
- data, stream->stream_id,
- nghttp2_session_get_local_window_size(httpc->h2),
- nghttp2_session_get_stream_local_window_size(httpc->h2,
- stream->stream_id)
- ));
+ H2BUGF(infof(data, "http2_recv: easy %p (stream %u) win %u/%u\n",
+ data, stream->stream_id,
+ nghttp2_session_get_local_window_size(httpc->h2),
+ nghttp2_session_get_stream_local_window_size(httpc->h2,
+ stream->stream_id)
+ ));
if((data->state.drain) && stream->memlen) {
H2BUGF(infof(data, "http2_recv: DRAIN %zu bytes stream %u!! (%p => %p)\n",
@@ -1631,7 +1631,7 @@ static ssize_t http2_recv(struct connectdata *conn, int sockindex,
/* We have paused nghttp2, but we have no pause data (see
on_data_chunk_recv). */
httpc->pause_stream_id = 0;
- if(h2_process_pending_input(conn, httpc, err) != 0) {
+ if(h2_process_pending_input(conn, httpc, err) != 0) {
return -1;
}
}
@@ -1659,7 +1659,7 @@ static ssize_t http2_recv(struct connectdata *conn, int sockindex,
frames, then we have to call it again with 0-length data.
Without this, on_stream_close callback will not be called,
and stream could be hanged. */
- if(h2_process_pending_input(conn, httpc, err) != 0) {
+ if(h2_process_pending_input(conn, httpc, err) != 0) {
return -1;
}
}
@@ -1676,9 +1676,9 @@ static ssize_t http2_recv(struct connectdata *conn, int sockindex,
socket is not read. But it seems that usually streams are
notified with its drain property, and socket is read again
quickly. */
- if(stream->closed)
- /* closed overrides paused */
- return 0;
+ if(stream->closed)
+ /* closed overrides paused */
+ return 0;
H2BUGF(infof(data, "stream %x is paused, pause id: %x\n",
stream->stream_id, httpc->pause_stream_id));
*err = CURLE_AGAIN;
@@ -1693,10 +1693,10 @@ static ssize_t http2_recv(struct connectdata *conn, int sockindex,
if(httpc->inbuflen == 0) {
nread = ((Curl_recv *)httpc->recv_underlying)(
- conn, FIRSTSOCKET, httpc->inbuf, H2_BUFSIZE, err);
+ conn, FIRSTSOCKET, httpc->inbuf, H2_BUFSIZE, err);
if(nread == -1) {
- if(*err != CURLE_AGAIN)
+ if(*err != CURLE_AGAIN)
failf(data, "Failed receiving HTTP2 data");
else if(stream->closed)
/* received when the stream was already closed! */
@@ -1714,17 +1714,17 @@ static ssize_t http2_recv(struct connectdata *conn, int sockindex,
H2BUGF(infof(data, "nread=%zd\n", nread));
httpc->inbuflen = nread;
-
- DEBUGASSERT(httpc->nread_inbuf == 0);
+
+ DEBUGASSERT(httpc->nread_inbuf == 0);
}
else {
nread = httpc->inbuflen - httpc->nread_inbuf;
- (void)nread; /* silence warning, used in debug */
+ (void)nread; /* silence warning, used in debug */
H2BUGF(infof(data, "Use data left in connection buffer, nread=%zd\n",
nread));
}
- if(h2_process_pending_input(conn, httpc, err) != 0)
+ if(h2_process_pending_input(conn, httpc, err) != 0)
return -1;
}
if(stream->memlen) {
@@ -1760,9 +1760,9 @@ static ssize_t http2_recv(struct connectdata *conn, int sockindex,
field list. */
#define AUTHORITY_DST_IDX 3
-/* USHRT_MAX is 65535 == 0xffff */
+/* USHRT_MAX is 65535 == 0xffff */
#define HEADER_OVERFLOW(x) \
- (x.namelen > 0xffff || x.valuelen > 0xffff - x.namelen)
+ (x.namelen > 0xffff || x.valuelen > 0xffff - x.namelen)
/*
* Check header memory for the token "trailers".
@@ -1840,7 +1840,7 @@ static ssize_t http2_send(struct connectdata *conn, int sockindex,
*/
int rv;
struct http_conn *httpc = &conn->proto.httpc;
- struct HTTP *stream = conn->data->req.p.http;
+ struct HTTP *stream = conn->data->req.p.http;
nghttp2_nv *nva = NULL;
size_t nheader;
size_t i;
@@ -2012,9 +2012,9 @@ static ssize_t http2_send(struct connectdata *conn, int sockindex,
nva[i].namelen = strlen((char *)nva[i].name);
}
else {
- nva[i].namelen = (size_t)(end - hdbuf);
- /* Lower case the header name for HTTP/2 */
- Curl_strntolower((char *)hdbuf, hdbuf, nva[i].namelen);
+ nva[i].namelen = (size_t)(end - hdbuf);
+ /* Lower case the header name for HTTP/2 */
+ Curl_strntolower((char *)hdbuf, hdbuf, nva[i].namelen);
nva[i].name = (unsigned char *)hdbuf;
}
hdbuf = end + 1;
@@ -2070,17 +2070,17 @@ static ssize_t http2_send(struct connectdata *conn, int sockindex,
if(acc > MAX_ACC) {
infof(conn->data, "http2_send: Warning: The cumulative length of all "
- "headers exceeds %d bytes and that could cause the "
+ "headers exceeds %d bytes and that could cause the "
"stream to be rejected.\n", MAX_ACC);
}
}
h2_pri_spec(conn->data, &pri_spec);
- H2BUGF(infof(conn->data, "http2_send request allowed %d (easy handle %p)\n",
- nghttp2_session_check_request_allowed(h2), (void *)conn->data));
-
- switch(conn->data->state.httpreq) {
+ H2BUGF(infof(conn->data, "http2_send request allowed %d (easy handle %p)\n",
+ nghttp2_session_check_request_allowed(h2), (void *)conn->data));
+
+ switch(conn->data->state.httpreq) {
case HTTPREQ_POST:
case HTTPREQ_POST_FORM:
case HTTPREQ_POST_MIME:
@@ -2104,9 +2104,9 @@ static ssize_t http2_send(struct connectdata *conn, int sockindex,
Curl_safefree(nva);
if(stream_id < 0) {
- H2BUGF(infof(conn->data,
- "http2_send() nghttp2_submit_request error (%s)%d\n",
- nghttp2_strerror(stream_id), stream_id));
+ H2BUGF(infof(conn->data,
+ "http2_send() nghttp2_submit_request error (%s)%d\n",
+ nghttp2_strerror(stream_id), stream_id));
*err = CURLE_SEND_ERROR;
return -1;
}
@@ -2116,12 +2116,12 @@ static ssize_t http2_send(struct connectdata *conn, int sockindex,
stream->stream_id = stream_id;
/* this does not call h2_session_send() since there can not have been any
- * priority update since the nghttp2_submit_request() call above */
+ * priority update since the nghttp2_submit_request() call above */
rv = nghttp2_session_send(h2);
- if(rv != 0) {
- H2BUGF(infof(conn->data,
- "http2_send() nghttp2_session_send error (%s)%d\n",
- nghttp2_strerror(rv), rv));
+ if(rv != 0) {
+ H2BUGF(infof(conn->data,
+ "http2_send() nghttp2_session_send error (%s)%d\n",
+ nghttp2_strerror(rv), rv));
*err = CURLE_SEND_ERROR;
return -1;
@@ -2133,14 +2133,14 @@ static ssize_t http2_send(struct connectdata *conn, int sockindex,
return -1;
}
- /* If whole HEADERS frame was sent off to the underlying socket, the nghttp2
- library calls data_source_read_callback. But only it found that no data
- available, so it deferred the DATA transmission. Which means that
- nghttp2_session_want_write() returns 0 on http2_perform_getsock(), which
- results that no writable socket check is performed. To workaround this,
- we issue nghttp2_session_resume_data() here to bring back DATA
- transmission from deferred state. */
- nghttp2_session_resume_data(h2, stream->stream_id);
+ /* If whole HEADERS frame was sent off to the underlying socket, the nghttp2
+ library calls data_source_read_callback. But only it found that no data
+ available, so it deferred the DATA transmission. Which means that
+ nghttp2_session_want_write() returns 0 on http2_perform_getsock(), which
+ results that no writable socket check is performed. To workaround this,
+ we issue nghttp2_session_resume_data() here to bring back DATA
+ transmission from deferred state. */
+ nghttp2_session_resume_data(h2, stream->stream_id);
return len;
@@ -2154,14 +2154,14 @@ CURLcode Curl_http2_setup(struct connectdata *conn)
{
CURLcode result;
struct http_conn *httpc = &conn->proto.httpc;
- struct HTTP *stream = conn->data->req.p.http;
+ struct HTTP *stream = conn->data->req.p.http;
+
+ DEBUGASSERT(conn->data->state.buffer);
- DEBUGASSERT(conn->data->state.buffer);
-
stream->stream_id = -1;
- Curl_dyn_init(&stream->header_recvbuf, DYN_H2_HEADERS);
- Curl_dyn_init(&stream->trailer_recvbuf, DYN_H2_TRAILERS);
+ Curl_dyn_init(&stream->header_recvbuf, DYN_H2_HEADERS);
+ Curl_dyn_init(&stream->trailer_recvbuf, DYN_H2_TRAILERS);
if((conn->handler == &Curl_handler_http2_ssl) ||
(conn->handler == &Curl_handler_http2))
@@ -2174,7 +2174,7 @@ CURLcode Curl_http2_setup(struct connectdata *conn)
result = http2_init(conn);
if(result) {
- Curl_dyn_free(&stream->header_recvbuf);
+ Curl_dyn_free(&stream->header_recvbuf);
return result;
}
@@ -2182,8 +2182,8 @@ CURLcode Curl_http2_setup(struct connectdata *conn)
stream->upload_left = 0;
stream->upload_mem = NULL;
stream->upload_len = 0;
- stream->mem = conn->data->state.buffer;
- stream->len = conn->data->set.buffer_size;
+ stream->mem = conn->data->state.buffer;
+ stream->len = conn->data->set.buffer_size;
httpc->inbuflen = 0;
httpc->nread_inbuf = 0;
@@ -2208,7 +2208,7 @@ CURLcode Curl_http2_switched(struct connectdata *conn,
struct http_conn *httpc = &conn->proto.httpc;
int rv;
struct Curl_easy *data = conn->data;
- struct HTTP *stream = conn->data->req.p.http;
+ struct HTTP *stream = conn->data->req.p.http;
result = Curl_http2_setup(conn);
if(result)
@@ -2269,7 +2269,7 @@ CURLcode Curl_http2_switched(struct connectdata *conn,
data into stream->mem, overwriting data already there. */
if(H2_BUFSIZE < nread) {
failf(data, "connection buffer size is too small to store data following "
- "HTTP Upgrade response header: buflen=%d, datalen=%zu",
+ "HTTP Upgrade response header: buflen=%d, datalen=%zu",
H2_BUFSIZE, nread);
return CURLE_HTTP2;
}
@@ -2280,59 +2280,59 @@ CURLcode Curl_http2_switched(struct connectdata *conn,
if(nread)
memcpy(httpc->inbuf, mem, nread);
-
+
httpc->inbuflen = nread;
- DEBUGASSERT(httpc->nread_inbuf == 0);
+ DEBUGASSERT(httpc->nread_inbuf == 0);
- if(-1 == h2_process_pending_input(conn, httpc, &result))
+ if(-1 == h2_process_pending_input(conn, httpc, &result))
return CURLE_HTTP2;
- return CURLE_OK;
-}
-
-CURLcode Curl_http2_stream_pause(struct Curl_easy *data, bool pause)
-{
- DEBUGASSERT(data);
- DEBUGASSERT(data->conn);
- /* if it isn't HTTP/2, we're done */
- if(!data->conn->proto.httpc.h2)
- return CURLE_OK;
-#ifdef NGHTTP2_HAS_SET_LOCAL_WINDOW_SIZE
+ return CURLE_OK;
+}
+
+CURLcode Curl_http2_stream_pause(struct Curl_easy *data, bool pause)
+{
+ DEBUGASSERT(data);
+ DEBUGASSERT(data->conn);
+ /* if it isn't HTTP/2, we're done */
+ if(!data->conn->proto.httpc.h2)
+ return CURLE_OK;
+#ifdef NGHTTP2_HAS_SET_LOCAL_WINDOW_SIZE
else {
- struct HTTP *stream = data->req.p.http;
- struct http_conn *httpc = &data->conn->proto.httpc;
- uint32_t window = !pause * HTTP2_HUGE_WINDOW_SIZE;
- int rv = nghttp2_session_set_local_window_size(httpc->h2,
- NGHTTP2_FLAG_NONE,
- stream->stream_id,
- window);
- if(rv) {
- failf(data, "nghttp2_session_set_local_window_size() failed: %s(%d)",
- nghttp2_strerror(rv), rv);
- return CURLE_HTTP2;
- }
-
- /* make sure the window update gets sent */
- rv = h2_session_send(data, httpc->h2);
- if(rv)
- return CURLE_SEND_ERROR;
-
- DEBUGF(infof(data, "Set HTTP/2 window size to %u for stream %u\n",
- window, stream->stream_id));
-
-#ifdef DEBUGBUILD
- {
- /* read out the stream local window again */
- uint32_t window2 =
- nghttp2_session_get_stream_local_window_size(httpc->h2,
- stream->stream_id);
- DEBUGF(infof(data, "HTTP/2 window size is now %u for stream %u\n",
- window2, stream->stream_id));
- }
-#endif
- }
-#endif
+ struct HTTP *stream = data->req.p.http;
+ struct http_conn *httpc = &data->conn->proto.httpc;
+ uint32_t window = !pause * HTTP2_HUGE_WINDOW_SIZE;
+ int rv = nghttp2_session_set_local_window_size(httpc->h2,
+ NGHTTP2_FLAG_NONE,
+ stream->stream_id,
+ window);
+ if(rv) {
+ failf(data, "nghttp2_session_set_local_window_size() failed: %s(%d)",
+ nghttp2_strerror(rv), rv);
+ return CURLE_HTTP2;
+ }
+
+ /* make sure the window update gets sent */
+ rv = h2_session_send(data, httpc->h2);
+ if(rv)
+ return CURLE_SEND_ERROR;
+
+ DEBUGF(infof(data, "Set HTTP/2 window size to %u for stream %u\n",
+ window, stream->stream_id));
+
+#ifdef DEBUGBUILD
+ {
+ /* read out the stream local window again */
+ uint32_t window2 =
+ nghttp2_session_get_stream_local_window_size(httpc->h2,
+ stream->stream_id);
+ DEBUGF(infof(data, "HTTP/2 window size is now %u for stream %u\n",
+ window2, stream->stream_id));
+ }
+#endif
+ }
+#endif
return CURLE_OK;
}
diff --git a/contrib/libs/curl/lib/http2.h b/contrib/libs/curl/lib/http2.h
index 4ae5347f61..43a6863abe 100644
--- a/contrib/libs/curl/lib/http2.h
+++ b/contrib/libs/curl/lib/http2.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -42,7 +42,7 @@ const char *Curl_http2_strerror(uint32_t err);
CURLcode Curl_http2_init(struct connectdata *conn);
void Curl_http2_init_state(struct UrlState *state);
void Curl_http2_init_userset(struct UserDefined *set);
-CURLcode Curl_http2_request_upgrade(struct dynbuf *req,
+CURLcode Curl_http2_request_upgrade(struct dynbuf *req,
struct connectdata *conn);
CURLcode Curl_http2_setup(struct connectdata *conn);
CURLcode Curl_http2_switched(struct connectdata *conn,
@@ -50,7 +50,7 @@ CURLcode Curl_http2_switched(struct connectdata *conn,
/* called from http_setup_conn */
void Curl_http2_setup_conn(struct connectdata *conn);
void Curl_http2_setup_req(struct Curl_easy *data);
-void Curl_http2_done(struct Curl_easy *data, bool premature);
+void Curl_http2_done(struct Curl_easy *data, bool premature);
CURLcode Curl_http2_done_sending(struct connectdata *conn);
CURLcode Curl_http2_add_child(struct Curl_easy *parent,
struct Curl_easy *child,
@@ -58,7 +58,7 @@ CURLcode Curl_http2_add_child(struct Curl_easy *parent,
void Curl_http2_remove_child(struct Curl_easy *parent,
struct Curl_easy *child);
void Curl_http2_cleanup_dependencies(struct Curl_easy *data);
-CURLcode Curl_http2_stream_pause(struct Curl_easy *data, bool pause);
+CURLcode Curl_http2_stream_pause(struct Curl_easy *data, bool pause);
/* returns true if the HTTP/2 stream error was HTTP_1_1_REQUIRED */
bool Curl_h2_http_1_1_error(struct connectdata *conn);
@@ -75,7 +75,7 @@ bool Curl_h2_http_1_1_error(struct connectdata *conn);
#define Curl_http2_add_child(x, y, z)
#define Curl_http2_remove_child(x, y)
#define Curl_http2_cleanup_dependencies(x)
-#define Curl_http2_stream_pause(x, y)
+#define Curl_http2_stream_pause(x, y)
#define Curl_h2_http_1_1_error(x) 0
#endif
diff --git a/contrib/libs/curl/lib/http_chunks.c b/contrib/libs/curl/lib/http_chunks.c
index fc586a7531..498481475c 100644
--- a/contrib/libs/curl/lib/http_chunks.c
+++ b/contrib/libs/curl/lib/http_chunks.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -26,7 +26,7 @@
#include "urldata.h" /* it includes http_chunks.h */
#include "sendf.h" /* for the client write stuff */
-#include "dynbuf.h"
+#include "dynbuf.h"
#include "content_encoding.h"
#include "http.h"
#include "non-ascii.h" /* for Curl_convert_to_network prototype */
@@ -93,7 +93,7 @@ void Curl_httpchunk_init(struct connectdata *conn)
chunk->hexindex = 0; /* start at 0 */
chunk->dataleft = 0; /* no data left yet! */
chunk->state = CHUNK_HEX; /* we get hex first! */
- Curl_dyn_init(&conn->trailer, DYN_H1_TRAILER);
+ Curl_dyn_init(&conn->trailer, DYN_H1_TRAILER);
}
/*
@@ -110,8 +110,8 @@ void Curl_httpchunk_init(struct connectdata *conn)
CHUNKcode Curl_httpchunk_read(struct connectdata *conn,
char *datap,
ssize_t datalen,
- ssize_t *wrotep,
- CURLcode *extrap)
+ ssize_t *wrotep,
+ CURLcode *extrap)
{
CURLcode result = CURLE_OK;
struct Curl_easy *data = conn->data;
@@ -127,10 +127,10 @@ CHUNKcode Curl_httpchunk_read(struct connectdata *conn,
chunk read process, to properly calculate the content length*/
if(data->set.http_te_skip && !k->ignorebody) {
result = Curl_client_write(conn, CLIENTWRITE_BODY, datap, datalen);
- if(result) {
- *extrap = result;
- return CHUNKE_PASSTHRU_ERROR;
- }
+ if(result) {
+ *extrap = result;
+ return CHUNKE_PASSTHRU_ERROR;
+ }
}
while(length) {
@@ -200,10 +200,10 @@ CHUNKcode Curl_httpchunk_read(struct connectdata *conn,
else
result = Curl_client_write(conn, CLIENTWRITE_BODY, datap, piece);
- if(result) {
- *extrap = result;
- return CHUNKE_PASSTHRU_ERROR;
- }
+ if(result) {
+ *extrap = result;
+ return CHUNKE_PASSTHRU_ERROR;
+ }
}
*wrote += piece;
@@ -229,33 +229,33 @@ CHUNKcode Curl_httpchunk_read(struct connectdata *conn,
case CHUNK_TRAILER:
if((*datap == 0x0d) || (*datap == 0x0a)) {
- char *tr = Curl_dyn_ptr(&conn->trailer);
+ char *tr = Curl_dyn_ptr(&conn->trailer);
/* this is the end of a trailer, but if the trailer was zero bytes
there was no trailer and we move on */
- if(tr) {
- size_t trlen;
- result = Curl_dyn_add(&conn->trailer, (char *)"\x0d\x0a");
- if(result)
- return CHUNKE_OUT_OF_MEMORY;
+ if(tr) {
+ size_t trlen;
+ result = Curl_dyn_add(&conn->trailer, (char *)"\x0d\x0a");
+ if(result)
+ return CHUNKE_OUT_OF_MEMORY;
- tr = Curl_dyn_ptr(&conn->trailer);
- trlen = Curl_dyn_len(&conn->trailer);
+ tr = Curl_dyn_ptr(&conn->trailer);
+ trlen = Curl_dyn_len(&conn->trailer);
/* Convert to host encoding before calling Curl_client_write */
- result = Curl_convert_from_network(conn->data, tr, trlen);
+ result = Curl_convert_from_network(conn->data, tr, trlen);
if(result)
/* Curl_convert_from_network calls failf if unsuccessful */
/* Treat it as a bad chunk */
return CHUNKE_BAD_CHUNK;
if(!data->set.http_te_skip) {
- result = Curl_client_write(conn, CLIENTWRITE_HEADER, tr, trlen);
- if(result) {
- *extrap = result;
- return CHUNKE_PASSTHRU_ERROR;
- }
+ result = Curl_client_write(conn, CLIENTWRITE_HEADER, tr, trlen);
+ if(result) {
+ *extrap = result;
+ return CHUNKE_PASSTHRU_ERROR;
+ }
}
- Curl_dyn_reset(&conn->trailer);
+ Curl_dyn_reset(&conn->trailer);
ch->state = CHUNK_TRAILER_CR;
if(*datap == 0x0a)
/* already on the LF */
@@ -268,9 +268,9 @@ CHUNKcode Curl_httpchunk_read(struct connectdata *conn,
}
}
else {
- result = Curl_dyn_addn(&conn->trailer, datap, 1);
- if(result)
- return CHUNKE_OUT_OF_MEMORY;
+ result = Curl_dyn_addn(&conn->trailer, datap, 1);
+ if(result)
+ return CHUNKE_OUT_OF_MEMORY;
}
datap++;
length--;
@@ -331,9 +331,9 @@ const char *Curl_chunked_strerror(CHUNKcode code)
return "Illegal or missing hexadecimal sequence";
case CHUNKE_BAD_CHUNK:
return "Malformed encoding found";
- case CHUNKE_PASSTHRU_ERROR:
- DEBUGASSERT(0); /* never used */
- return "";
+ case CHUNKE_PASSTHRU_ERROR:
+ DEBUGASSERT(0); /* never used */
+ return "";
case CHUNKE_BAD_ENCODING:
return "Bad content-encoding found";
case CHUNKE_OUT_OF_MEMORY:
diff --git a/contrib/libs/curl/lib/http_chunks.h b/contrib/libs/curl/lib/http_chunks.h
index 92f399881e..c8f072a2de 100644
--- a/contrib/libs/curl/lib/http_chunks.h
+++ b/contrib/libs/curl/lib/http_chunks.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -21,9 +21,9 @@
* KIND, either express or implied.
*
***************************************************************************/
-
-struct connectdata;
-
+
+struct connectdata;
+
/*
* The longest possible hexadecimal number we support in a chunked transfer.
* Weird enough, RFC2616 doesn't set a maximum size! Since we use strtoul()
@@ -76,7 +76,7 @@ typedef enum {
CHUNKE_BAD_CHUNK,
CHUNKE_BAD_ENCODING,
CHUNKE_OUT_OF_MEMORY,
- CHUNKE_PASSTHRU_ERROR, /* Curl_httpchunk_read() returns a CURLcode to use */
+ CHUNKE_PASSTHRU_ERROR, /* Curl_httpchunk_read() returns a CURLcode to use */
CHUNKE_LAST
} CHUNKcode;
@@ -90,10 +90,10 @@ struct Curl_chunker {
size_t dataleft; /* untouched data amount at the end of the last buffer */
};
-/* The following functions are defined in http_chunks.c */
-void Curl_httpchunk_init(struct connectdata *conn);
-CHUNKcode Curl_httpchunk_read(struct connectdata *conn, char *datap,
- ssize_t length, ssize_t *wrote,
- CURLcode *passthru);
-
+/* The following functions are defined in http_chunks.c */
+void Curl_httpchunk_init(struct connectdata *conn);
+CHUNKcode Curl_httpchunk_read(struct connectdata *conn, char *datap,
+ ssize_t length, ssize_t *wrote,
+ CURLcode *passthru);
+
#endif /* HEADER_CURL_HTTP_CHUNKS_H */
diff --git a/contrib/libs/curl/lib/http_digest.c b/contrib/libs/curl/lib/http_digest.c
index f771415065..dfa40dcb61 100644
--- a/contrib/libs/curl/lib/http_digest.c
+++ b/contrib/libs/curl/lib/http_digest.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -94,19 +94,19 @@ CURLcode Curl_output_digest(struct connectdata *conn,
struct auth *authp;
if(proxy) {
-#ifdef CURL_DISABLE_PROXY
- return CURLE_NOT_BUILT_IN;
-#else
+#ifdef CURL_DISABLE_PROXY
+ return CURLE_NOT_BUILT_IN;
+#else
digest = &data->state.proxydigest;
- allocuserpwd = &data->state.aptr.proxyuserpwd;
+ allocuserpwd = &data->state.aptr.proxyuserpwd;
userp = conn->http_proxy.user;
passwdp = conn->http_proxy.passwd;
authp = &data->state.authproxy;
-#endif
+#endif
}
else {
digest = &data->state.digest;
- allocuserpwd = &data->state.aptr.userpwd;
+ allocuserpwd = &data->state.aptr.userpwd;
userp = conn->user;
passwdp = conn->passwd;
authp = &data->state.authhost;
diff --git a/contrib/libs/curl/lib/http_digest.h b/contrib/libs/curl/lib/http_digest.h
index 2589386899..f7001edec1 100644
--- a/contrib/libs/curl/lib/http_digest.h
+++ b/contrib/libs/curl/lib/http_digest.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/http_negotiate.c b/contrib/libs/curl/lib/http_negotiate.c
index 4238987cb1..872d172fc6 100644
--- a/contrib/libs/curl/lib/http_negotiate.c
+++ b/contrib/libs/curl/lib/http_negotiate.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -52,7 +52,7 @@ CURLcode Curl_input_negotiate(struct connectdata *conn, bool proxy,
curlnegotiate state;
if(proxy) {
-#ifndef CURL_DISABLE_PROXY
+#ifndef CURL_DISABLE_PROXY
userp = conn->http_proxy.user;
passwdp = conn->http_proxy.passwd;
service = data->set.str[STRING_PROXY_SERVICE_NAME] ?
@@ -60,9 +60,9 @@ CURLcode Curl_input_negotiate(struct connectdata *conn, bool proxy,
host = conn->http_proxy.host.name;
neg_ctx = &conn->proxyneg;
state = conn->proxy_negotiate_state;
-#else
- return CURLE_NOT_BUILT_IN;
-#endif
+#else
+ return CURLE_NOT_BUILT_IN;
+#endif
}
else {
userp = conn->user;
@@ -123,8 +123,8 @@ CURLcode Curl_output_negotiate(struct connectdata *conn, bool proxy)
struct auth *authp = proxy ? &conn->data->state.authproxy :
&conn->data->state.authhost;
curlnegotiate *state = proxy ? &conn->proxy_negotiate_state :
- &conn->http_negotiate_state;
- struct Curl_easy *data = conn->data;
+ &conn->http_negotiate_state;
+ struct Curl_easy *data = conn->data;
char *base64 = NULL;
size_t len = 0;
char *userp;
@@ -169,15 +169,15 @@ CURLcode Curl_output_negotiate(struct connectdata *conn, bool proxy)
return result;
userp = aprintf("%sAuthorization: Negotiate %s\r\n", proxy ? "Proxy-" : "",
- base64);
+ base64);
if(proxy) {
- Curl_safefree(data->state.aptr.proxyuserpwd);
- data->state.aptr.proxyuserpwd = userp;
+ Curl_safefree(data->state.aptr.proxyuserpwd);
+ data->state.aptr.proxyuserpwd = userp;
}
else {
- Curl_safefree(data->state.aptr.userpwd);
- data->state.aptr.userpwd = userp;
+ Curl_safefree(data->state.aptr.userpwd);
+ data->state.aptr.userpwd = userp;
}
free(base64);
diff --git a/contrib/libs/curl/lib/http_negotiate.h b/contrib/libs/curl/lib/http_negotiate.h
index 87bf394ae0..cf1d007dce 100644
--- a/contrib/libs/curl/lib/http_negotiate.h
+++ b/contrib/libs/curl/lib/http_negotiate.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -33,8 +33,8 @@ CURLcode Curl_output_negotiate(struct connectdata *conn, bool proxy);
void Curl_http_auth_cleanup_negotiate(struct connectdata *conn);
-#else /* !CURL_DISABLE_HTTP && USE_SPNEGO */
-#define Curl_http_auth_cleanup_negotiate(x)
-#endif
+#else /* !CURL_DISABLE_HTTP && USE_SPNEGO */
+#define Curl_http_auth_cleanup_negotiate(x)
+#endif
#endif /* HEADER_CURL_HTTP_NEGOTIATE_H */
diff --git a/contrib/libs/curl/lib/http_ntlm.c b/contrib/libs/curl/lib/http_ntlm.c
index 684f01bc14..91e1d1f714 100644
--- a/contrib/libs/curl/lib/http_ntlm.c
+++ b/contrib/libs/curl/lib/http_ntlm.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -44,7 +44,7 @@
/* SSL backend-specific #if branches in this file must be kept in the order
documented in curl_ntlm_core. */
-#if defined(USE_WINDOWS_SSPI)
+#if defined(USE_WINDOWS_SSPI)
#include "curl_sspi.h"
#endif
@@ -131,15 +131,15 @@ CURLcode Curl_output_ntlm(struct connectdata *conn, bool proxy)
struct ntlmdata *ntlm;
curlntlm *state;
struct auth *authp;
- struct Curl_easy *data = conn->data;
+ struct Curl_easy *data = conn->data;
+
-
DEBUGASSERT(conn);
- DEBUGASSERT(data);
+ DEBUGASSERT(data);
if(proxy) {
-#ifndef CURL_DISABLE_PROXY
- allocuserpwd = &data->state.aptr.proxyuserpwd;
+#ifndef CURL_DISABLE_PROXY
+ allocuserpwd = &data->state.aptr.proxyuserpwd;
userp = conn->http_proxy.user;
passwdp = conn->http_proxy.passwd;
service = conn->data->set.str[STRING_PROXY_SERVICE_NAME] ?
@@ -148,12 +148,12 @@ CURLcode Curl_output_ntlm(struct connectdata *conn, bool proxy)
ntlm = &conn->proxyntlm;
state = &conn->proxy_ntlm_state;
authp = &conn->data->state.authproxy;
-#else
- return CURLE_NOT_BUILT_IN;
-#endif
+#else
+ return CURLE_NOT_BUILT_IN;
+#endif
}
else {
- allocuserpwd = &data->state.aptr.userpwd;
+ allocuserpwd = &data->state.aptr.userpwd;
userp = conn->user;
passwdp = conn->passwd;
service = conn->data->set.str[STRING_SERVICE_NAME] ?
diff --git a/contrib/libs/curl/lib/http_ntlm.h b/contrib/libs/curl/lib/http_ntlm.h
index 791cc6dfc1..5ddf538727 100644
--- a/contrib/libs/curl/lib/http_ntlm.h
+++ b/contrib/libs/curl/lib/http_ntlm.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -35,8 +35,8 @@ CURLcode Curl_output_ntlm(struct connectdata *conn, bool proxy);
void Curl_http_auth_cleanup_ntlm(struct connectdata *conn);
-#else /* !CURL_DISABLE_HTTP && USE_NTLM */
-#define Curl_http_auth_cleanup_ntlm(x)
-#endif
+#else /* !CURL_DISABLE_HTTP && USE_NTLM */
+#define Curl_http_auth_cleanup_ntlm(x)
+#endif
#endif /* HEADER_CURL_HTTP_NTLM_H */
diff --git a/contrib/libs/curl/lib/http_proxy.c b/contrib/libs/curl/lib/http_proxy.c
index efc40813cb..4242251219 100644
--- a/contrib/libs/curl/lib/http_proxy.c
+++ b/contrib/libs/curl/lib/http_proxy.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -58,9 +58,9 @@ static CURLcode https_proxy_connect(struct connectdata *conn, int sockindex)
Curl_ssl_connect_nonblocking(conn, sockindex,
&conn->bits.proxy_ssl_connected[sockindex]);
if(result)
- /* a failed connection is marked for closure to prevent (bad) re-use or
- similar */
- connclose(conn, "TLS handshake failed");
+ /* a failed connection is marked for closure to prevent (bad) re-use or
+ similar */
+ connclose(conn, "TLS handshake failed");
}
return result;
#else
@@ -72,7 +72,7 @@ static CURLcode https_proxy_connect(struct connectdata *conn, int sockindex)
CURLcode Curl_proxy_connect(struct connectdata *conn, int sockindex)
{
- struct Curl_easy *data = conn->data;
+ struct Curl_easy *data = conn->data;
if(conn->http_proxy.proxytype == CURLPROXY_HTTPS) {
const CURLcode result = https_proxy_connect(conn, sockindex);
if(result)
@@ -102,9 +102,9 @@ CURLcode Curl_proxy_connect(struct connectdata *conn, int sockindex)
* This function might be called several times in the multi interface case
* if the proxy's CONNECT response is not instant.
*/
- prot_save = conn->data->req.p.http;
+ prot_save = conn->data->req.p.http;
memset(&http_proxy, 0, sizeof(http_proxy));
- conn->data->req.p.http = &http_proxy;
+ conn->data->req.p.http = &http_proxy;
connkeep(conn, "HTTP proxy CONNECT");
/* for the secondary socket (FTP), use the "connect to host"
@@ -125,10 +125,10 @@ CURLcode Curl_proxy_connect(struct connectdata *conn, int sockindex)
else
remote_port = conn->remote_port;
result = Curl_proxyCONNECT(conn, sockindex, hostname, remote_port);
- conn->data->req.p.http = prot_save;
+ conn->data->req.p.http = prot_save;
if(CURLE_OK != result)
return result;
- Curl_safefree(data->state.aptr.proxyuserpwd);
+ Curl_safefree(data->state.aptr.proxyuserpwd);
#else
return CURLE_NOT_BUILT_IN;
#endif
@@ -159,15 +159,15 @@ static CURLcode connect_init(struct connectdata *conn, bool reinit)
return CURLE_OUT_OF_MEMORY;
infof(conn->data, "allocate connect buffer!\n");
conn->connect_state = s;
- Curl_dyn_init(&s->rcvbuf, DYN_PROXY_CONNECT_HEADERS);
+ Curl_dyn_init(&s->rcvbuf, DYN_PROXY_CONNECT_HEADERS);
}
else {
DEBUGASSERT(conn->connect_state);
s = conn->connect_state;
- Curl_dyn_reset(&s->rcvbuf);
+ Curl_dyn_reset(&s->rcvbuf);
}
s->tunnel_state = TUNNEL_INIT;
- s->keepon = KEEPON_CONNECT;
+ s->keepon = KEEPON_CONNECT;
s->cl = 0;
s->close_connection = FALSE;
return CURLE_OK;
@@ -177,7 +177,7 @@ static void connect_done(struct connectdata *conn)
{
struct http_connect_state *s = conn->connect_state;
s->tunnel_state = TUNNEL_COMPLETE;
- Curl_dyn_free(&s->rcvbuf);
+ Curl_dyn_free(&s->rcvbuf);
infof(conn->data, "CONNECT phase completed!\n");
}
@@ -192,8 +192,8 @@ static CURLcode CONNECT(struct connectdata *conn,
CURLcode result;
curl_socket_t tunnelsocket = conn->sock[sockindex];
struct http_connect_state *s = conn->connect_state;
- char *linep;
- size_t perline;
+ char *linep;
+ size_t perline;
#define SELECT_OK 0
#define SELECT_ERROR 1
@@ -208,7 +208,7 @@ static CURLcode CONNECT(struct connectdata *conn,
if(TUNNEL_INIT == s->tunnel_state) {
/* BEGIN CONNECT PHASE */
char *host_port;
- struct dynbuf req;
+ struct dynbuf req;
infof(data, "Establish HTTP proxy tunnel to %s:%d\n",
hostname, remote_port);
@@ -220,12 +220,12 @@ static CURLcode CONNECT(struct connectdata *conn,
data->req.newurl = NULL;
host_port = aprintf("%s:%d", hostname, remote_port);
- if(!host_port)
+ if(!host_port)
return CURLE_OUT_OF_MEMORY;
- /* initialize a dynamic send-buffer */
- Curl_dyn_init(&req, DYN_HTTP_REQUEST);
-
+ /* initialize a dynamic send-buffer */
+ Curl_dyn_init(&req, DYN_HTTP_REQUEST);
+
/* Setup the proxy-authorization header, if any */
result = Curl_http_output_auth(conn, "CONNECT", host_port, TRUE);
@@ -235,8 +235,8 @@ static CURLcode CONNECT(struct connectdata *conn,
char *host = NULL;
const char *proxyconn = "";
const char *useragent = "";
- const char *httpv =
- (conn->http_proxy.proxytype == CURLPROXY_HTTP_1_0) ? "1.0" : "1.1";
+ const char *httpv =
+ (conn->http_proxy.proxytype == CURLPROXY_HTTP_1_0) ? "1.0" : "1.1";
bool ipv6_ip = conn->bits.ipv6_ip;
char *hostheader;
@@ -247,7 +247,7 @@ static CURLcode CONNECT(struct connectdata *conn,
aprintf("%s%s%s:%d", ipv6_ip?"[":"", hostname, ipv6_ip?"]":"",
remote_port);
if(!hostheader) {
- Curl_dyn_free(&req);
+ Curl_dyn_free(&req);
return CURLE_OUT_OF_MEMORY;
}
@@ -255,7 +255,7 @@ static CURLcode CONNECT(struct connectdata *conn,
host = aprintf("Host: %s\r\n", hostheader);
if(!host) {
free(hostheader);
- Curl_dyn_free(&req);
+ Curl_dyn_free(&req);
return CURLE_OUT_OF_MEMORY;
}
}
@@ -264,45 +264,45 @@ static CURLcode CONNECT(struct connectdata *conn,
if(!Curl_checkProxyheaders(conn, "User-Agent") &&
data->set.str[STRING_USERAGENT])
- useragent = data->state.aptr.uagent;
+ useragent = data->state.aptr.uagent;
result =
- Curl_dyn_addf(&req,
- "CONNECT %s HTTP/%s\r\n"
- "%s" /* Host: */
- "%s" /* Proxy-Authorization */
- "%s" /* User-Agent */
- "%s", /* Proxy-Connection */
- hostheader,
- httpv,
- host?host:"",
- data->state.aptr.proxyuserpwd?
- data->state.aptr.proxyuserpwd:"",
- useragent,
- proxyconn);
+ Curl_dyn_addf(&req,
+ "CONNECT %s HTTP/%s\r\n"
+ "%s" /* Host: */
+ "%s" /* Proxy-Authorization */
+ "%s" /* User-Agent */
+ "%s", /* Proxy-Connection */
+ hostheader,
+ httpv,
+ host?host:"",
+ data->state.aptr.proxyuserpwd?
+ data->state.aptr.proxyuserpwd:"",
+ useragent,
+ proxyconn);
if(host)
free(host);
free(hostheader);
if(!result)
- result = Curl_add_custom_headers(conn, TRUE, &req);
+ result = Curl_add_custom_headers(conn, TRUE, &req);
if(!result)
/* CRLF terminate the request */
- result = Curl_dyn_add(&req, "\r\n");
+ result = Curl_dyn_add(&req, "\r\n");
if(!result) {
/* Send the connect request to the proxy */
/* BLOCKING */
- result = Curl_buffer_send(&req, conn, &data->info.request_size, 0,
- sockindex);
+ result = Curl_buffer_send(&req, conn, &data->info.request_size, 0,
+ sockindex);
}
if(result)
failf(data, "Failed sending CONNECT to proxy");
}
- Curl_dyn_free(&req);
+ Curl_dyn_free(&req);
if(result)
return result;
@@ -324,13 +324,13 @@ static CURLcode CONNECT(struct connectdata *conn,
{ /* READING RESPONSE PHASE */
int error = SELECT_OK;
- while(s->keepon) {
+ while(s->keepon) {
ssize_t gotbytes;
- char byte;
+ char byte;
/* Read one byte at a time to avoid a race condition. Wait at most one
second before looping to ensure continuous pgrsUpdates. */
- result = Curl_read(conn, tunnelsocket, &byte, 1, &gotbytes);
+ result = Curl_read(conn, tunnelsocket, &byte, 1, &gotbytes);
if(result == CURLE_AGAIN)
/* socket buffer drained, return */
return CURLE_OK;
@@ -339,7 +339,7 @@ static CURLcode CONNECT(struct connectdata *conn,
return CURLE_ABORTED_BY_CALLBACK;
if(result) {
- s->keepon = KEEPON_DONE;
+ s->keepon = KEEPON_DONE;
break;
}
else if(gotbytes <= 0) {
@@ -353,11 +353,11 @@ static CURLcode CONNECT(struct connectdata *conn,
error = SELECT_ERROR;
failf(data, "Proxy CONNECT aborted");
}
- s->keepon = KEEPON_DONE;
+ s->keepon = KEEPON_DONE;
break;
}
- if(s->keepon == KEEPON_IGNORE) {
+ if(s->keepon == KEEPON_IGNORE) {
/* This means we are currently ignoring a response-body */
if(s->cl) {
@@ -365,7 +365,7 @@ static CURLcode CONNECT(struct connectdata *conn,
and make sure to break out of the loop when we're done! */
s->cl--;
if(s->cl <= 0) {
- s->keepon = KEEPON_DONE;
+ s->keepon = KEEPON_DONE;
s->tunnel_state = TUNNEL_COMPLETE;
break;
}
@@ -374,16 +374,16 @@ static CURLcode CONNECT(struct connectdata *conn,
/* chunked-encoded body, so we need to do the chunked dance
properly to know when the end of the body is reached */
CHUNKcode r;
- CURLcode extra;
+ CURLcode extra;
ssize_t tookcareof = 0;
/* now parse the chunked piece of data so that we can
properly tell when the stream ends */
- r = Curl_httpchunk_read(conn, &byte, 1, &tookcareof, &extra);
+ r = Curl_httpchunk_read(conn, &byte, 1, &tookcareof, &extra);
if(r == CHUNKE_STOP) {
/* we're done reading chunks! */
infof(data, "chunk reading DONE\n");
- s->keepon = KEEPON_DONE;
+ s->keepon = KEEPON_DONE;
/* we did the full CONNECT treatment, go COMPLETE */
s->tunnel_state = TUNNEL_COMPLETE;
}
@@ -391,26 +391,26 @@ static CURLcode CONNECT(struct connectdata *conn,
continue;
}
- if(Curl_dyn_addn(&s->rcvbuf, &byte, 1)) {
- failf(data, "CONNECT response too large!");
- return CURLE_RECV_ERROR;
- }
+ if(Curl_dyn_addn(&s->rcvbuf, &byte, 1)) {
+ failf(data, "CONNECT response too large!");
+ return CURLE_RECV_ERROR;
+ }
/* if this is not the end of a header line then continue */
- if(byte != 0x0a)
+ if(byte != 0x0a)
continue;
- linep = Curl_dyn_ptr(&s->rcvbuf);
- perline = Curl_dyn_len(&s->rcvbuf); /* amount of bytes in this line */
-
+ linep = Curl_dyn_ptr(&s->rcvbuf);
+ perline = Curl_dyn_len(&s->rcvbuf); /* amount of bytes in this line */
+
/* convert from the network encoding */
- result = Curl_convert_from_network(data, linep, perline);
+ result = Curl_convert_from_network(data, linep, perline);
/* Curl_convert_from_network calls failf if unsuccessful */
if(result)
return result;
/* output debug if that is requested */
- Curl_debug(data, CURLINFO_HEADER_IN, linep, perline);
+ Curl_debug(data, CURLINFO_HEADER_IN, linep, perline);
if(!data->set.suppress_connect_headers) {
/* send the header to the callback */
@@ -418,26 +418,26 @@ static CURLcode CONNECT(struct connectdata *conn,
if(data->set.include_header)
writetype |= CLIENTWRITE_BODY;
- result = Curl_client_write(conn, writetype, linep, perline);
+ result = Curl_client_write(conn, writetype, linep, perline);
if(result)
return result;
}
- data->info.header_size += (long)perline;
+ data->info.header_size += (long)perline;
/* Newlines are CRLF, so the CR is ignored as the line isn't
really terminated until the LF comes. Treat a following CR
as end-of-headers as well.*/
- if(('\r' == linep[0]) ||
- ('\n' == linep[0])) {
+ if(('\r' == linep[0]) ||
+ ('\n' == linep[0])) {
/* end of response-headers from the proxy */
-
+
if((407 == k->httpcode) && !data->state.authproblem) {
/* If we get a 407 response code with content length
when we have no auth problem, we must ignore the
whole response-body */
- s->keepon = KEEPON_IGNORE;
+ s->keepon = KEEPON_IGNORE;
if(s->cl) {
infof(data, "Ignore %" CURL_FORMAT_CURL_OFF_T
@@ -445,27 +445,27 @@ static CURLcode CONNECT(struct connectdata *conn,
}
else if(s->chunked_encoding) {
CHUNKcode r;
- CURLcode extra;
+ CURLcode extra;
infof(data, "Ignore chunked response-body\n");
- /* We set ignorebody true here since the chunked decoder
- function will acknowledge that. Pay attention so that this is
- cleared again when this function returns! */
+ /* We set ignorebody true here since the chunked decoder
+ function will acknowledge that. Pay attention so that this is
+ cleared again when this function returns! */
k->ignorebody = TRUE;
- if(linep[1] == '\n')
- /* this can only be a LF if the letter at index 0 was a CR */
- linep++;
+ if(linep[1] == '\n')
+ /* this can only be a LF if the letter at index 0 was a CR */
+ linep++;
- /* now parse the chunked piece of data so that we can properly
- tell when the stream ends */
- r = Curl_httpchunk_read(conn, linep + 1, 1, &gotbytes,
- &extra);
+ /* now parse the chunked piece of data so that we can properly
+ tell when the stream ends */
+ r = Curl_httpchunk_read(conn, linep + 1, 1, &gotbytes,
+ &extra);
if(r == CHUNKE_STOP) {
/* we're done reading chunks! */
infof(data, "chunk reading DONE\n");
- s->keepon = KEEPON_DONE;
+ s->keepon = KEEPON_DONE;
/* we did the full CONNECT treatment, go to COMPLETE */
s->tunnel_state = TUNNEL_COMPLETE;
}
@@ -474,24 +474,24 @@ static CURLcode CONNECT(struct connectdata *conn,
/* without content-length or chunked encoding, we
can't keep the connection alive since the close is
the end signal so we bail out at once instead */
- s->keepon = KEEPON_DONE;
+ s->keepon = KEEPON_DONE;
}
}
else
- s->keepon = KEEPON_DONE;
+ s->keepon = KEEPON_DONE;
if(!s->cl)
/* we did the full CONNECT treatment, go to COMPLETE */
s->tunnel_state = TUNNEL_COMPLETE;
continue;
}
- if((checkprefix("WWW-Authenticate:", linep) &&
+ if((checkprefix("WWW-Authenticate:", linep) &&
(401 == k->httpcode)) ||
- (checkprefix("Proxy-authenticate:", linep) &&
+ (checkprefix("Proxy-authenticate:", linep) &&
(407 == k->httpcode))) {
bool proxy = (k->httpcode == 407) ? TRUE : FALSE;
- char *auth = Curl_copy_header_value(linep);
+ char *auth = Curl_copy_header_value(linep);
if(!auth)
return CURLE_OUT_OF_MEMORY;
@@ -502,7 +502,7 @@ static CURLcode CONNECT(struct connectdata *conn,
if(result)
return result;
}
- else if(checkprefix("Content-Length:", linep)) {
+ else if(checkprefix("Content-Length:", linep)) {
if(k->httpcode/100 == 2) {
/* A client MUST ignore any Content-Length or Transfer-Encoding
header fields received in a successful response to CONNECT.
@@ -511,13 +511,13 @@ static CURLcode CONNECT(struct connectdata *conn,
k->httpcode);
}
else {
- (void)curlx_strtoofft(linep +
+ (void)curlx_strtoofft(linep +
strlen("Content-Length:"), NULL, 10, &s->cl);
}
}
- else if(Curl_compareheader(linep, "Connection:", "close"))
+ else if(Curl_compareheader(linep, "Connection:", "close"))
s->close_connection = TRUE;
- else if(checkprefix("Transfer-Encoding:", linep)) {
+ else if(checkprefix("Transfer-Encoding:", linep)) {
if(k->httpcode/100 == 2) {
/* A client MUST ignore any Content-Length or Transfer-Encoding
header fields received in a successful response to CONNECT.
@@ -525,7 +525,7 @@ static CURLcode CONNECT(struct connectdata *conn,
infof(data, "Ignoring Transfer-Encoding in "
"CONNECT %03d response\n", k->httpcode);
}
- else if(Curl_compareheader(linep,
+ else if(Curl_compareheader(linep,
"Transfer-Encoding:", "chunked")) {
infof(data, "CONNECT responded chunked\n");
s->chunked_encoding = TRUE;
@@ -533,16 +533,16 @@ static CURLcode CONNECT(struct connectdata *conn,
Curl_httpchunk_init(conn);
}
}
- else if(Curl_compareheader(linep, "Proxy-Connection:", "close"))
+ else if(Curl_compareheader(linep, "Proxy-Connection:", "close"))
s->close_connection = TRUE;
- else if(2 == sscanf(linep, "HTTP/1.%d %d",
+ else if(2 == sscanf(linep, "HTTP/1.%d %d",
&subversion,
&k->httpcode)) {
/* store the HTTP code from the proxy */
data->info.httpproxycode = k->httpcode;
}
- Curl_dyn_reset(&s->rcvbuf);
+ Curl_dyn_reset(&s->rcvbuf);
} /* while there's buffer left and loop is requested */
if(Curl_pgrsUpdate(conn))
@@ -603,7 +603,7 @@ static CURLcode CONNECT(struct connectdata *conn,
if(conn->bits.proxy_connect_closed)
/* this is not an error, just part of the connection negotiation */
return CURLE_OK;
- Curl_dyn_free(&s->rcvbuf);
+ Curl_dyn_free(&s->rcvbuf);
failf(data, "Received HTTP code %d from proxy after CONNECT",
data->req.httpcode);
return CURLE_RECV_ERROR;
@@ -614,8 +614,8 @@ static CURLcode CONNECT(struct connectdata *conn,
/* If a proxy-authorization header was used for the proxy, then we should
make sure that it isn't accidentally used for the document request
after we've connected. So let's free and clear it here. */
- Curl_safefree(data->state.aptr.proxyuserpwd);
- data->state.aptr.proxyuserpwd = NULL;
+ Curl_safefree(data->state.aptr.proxyuserpwd);
+ data->state.aptr.proxyuserpwd = NULL;
data->state.authproxy.done = TRUE;
data->state.authproxy.multipass = FALSE;
@@ -625,7 +625,7 @@ static CURLcode CONNECT(struct connectdata *conn,
data->req.ignorebody = FALSE; /* put it (back) to non-ignore state */
conn->bits.rewindaftersend = FALSE; /* make sure this isn't set for the
document request */
- Curl_dyn_free(&s->rcvbuf);
+ Curl_dyn_free(&s->rcvbuf);
return CURLE_OK;
}
diff --git a/contrib/libs/curl/lib/http_proxy.h b/contrib/libs/curl/lib/http_proxy.h
index f835cfc1ed..a595e8b553 100644
--- a/contrib/libs/curl/lib/http_proxy.h
+++ b/contrib/libs/curl/lib/http_proxy.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -47,6 +47,6 @@ bool Curl_connect_ongoing(struct connectdata *conn);
#endif
void Curl_connect_free(struct Curl_easy *data);
-void Curl_connect_done(struct Curl_easy *data);
+void Curl_connect_done(struct Curl_easy *data);
#endif /* HEADER_CURL_HTTP_PROXY_H */
diff --git a/contrib/libs/curl/lib/idn_win32.c b/contrib/libs/curl/lib/idn_win32.c
index 1474faefc7..1d475a4eff 100644
--- a/contrib/libs/curl/lib/idn_win32.c
+++ b/contrib/libs/curl/lib/idn_win32.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -72,13 +72,13 @@ bool curl_win32_idn_to_ascii(const char *in, char **out)
{
bool success = FALSE;
- wchar_t *in_w = curlx_convert_UTF8_to_wchar(in);
+ wchar_t *in_w = curlx_convert_UTF8_to_wchar(in);
if(in_w) {
wchar_t punycode[IDN_MAX_LENGTH];
int chars = IdnToAscii(0, in_w, -1, punycode, IDN_MAX_LENGTH);
free(in_w);
if(chars) {
- *out = curlx_convert_wchar_to_UTF8(punycode);
+ *out = curlx_convert_wchar_to_UTF8(punycode);
if(*out)
success = TRUE;
}
@@ -91,7 +91,7 @@ bool curl_win32_ascii_to_idn(const char *in, char **out)
{
bool success = FALSE;
- wchar_t *in_w = curlx_convert_UTF8_to_wchar(in);
+ wchar_t *in_w = curlx_convert_UTF8_to_wchar(in);
if(in_w) {
size_t in_len = wcslen(in_w) + 1;
wchar_t unicode[IDN_MAX_LENGTH];
@@ -99,7 +99,7 @@ bool curl_win32_ascii_to_idn(const char *in, char **out)
unicode, IDN_MAX_LENGTH);
free(in_w);
if(chars) {
- *out = curlx_convert_wchar_to_UTF8(unicode);
+ *out = curlx_convert_wchar_to_UTF8(unicode);
if(*out)
success = TRUE;
}
diff --git a/contrib/libs/curl/lib/if2ip.c b/contrib/libs/curl/lib/if2ip.c
index f6311c58c1..bf397aad45 100644
--- a/contrib/libs/curl/lib/if2ip.c
+++ b/contrib/libs/curl/lib/if2ip.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -115,7 +115,7 @@ if2ip_result_t Curl_if2ip(int af, unsigned int remote_scope,
if(iface->ifa_addr->sa_family == af) {
if(strcasecompare(iface->ifa_name, interf)) {
void *addr;
- const char *ip;
+ const char *ip;
char scope[12] = "";
char ipstr[64];
#ifdef ENABLE_IPV6
@@ -126,11 +126,11 @@ if2ip_result_t Curl_if2ip(int af, unsigned int remote_scope,
unsigned int ifscope = Curl_ipv6_scope(iface->ifa_addr);
if(ifscope != remote_scope) {
- /* We are interested only in interface addresses whose scope
- matches the remote address we want to connect to: global
- for global, link-local for link-local, etc... */
- if(res == IF2IP_NOT_FOUND)
- res = IF2IP_AF_NOT_SUPPORTED;
+ /* We are interested only in interface addresses whose scope
+ matches the remote address we want to connect to: global
+ for global, link-local for link-local, etc... */
+ if(res == IF2IP_NOT_FOUND)
+ res = IF2IP_AF_NOT_SUPPORTED;
continue;
}
@@ -150,15 +150,15 @@ if2ip_result_t Curl_if2ip(int af, unsigned int remote_scope,
}
if(scopeid)
- msnprintf(scope, sizeof(scope), "%%%u", scopeid);
+ msnprintf(scope, sizeof(scope), "%%%u", scopeid);
#endif
}
else
#endif
addr =
- &((struct sockaddr_in *)(void *)iface->ifa_addr)->sin_addr;
+ &((struct sockaddr_in *)(void *)iface->ifa_addr)->sin_addr;
res = IF2IP_FOUND;
- ip = Curl_inet_ntop(af, addr, ipstr, sizeof(ipstr));
+ ip = Curl_inet_ntop(af, addr, ipstr, sizeof(ipstr));
msnprintf(buf, buf_size, "%s%s", ip, scope);
break;
}
@@ -187,7 +187,7 @@ if2ip_result_t Curl_if2ip(int af, unsigned int remote_scope,
struct sockaddr_in *s;
curl_socket_t dummy;
size_t len;
- const char *r;
+ const char *r;
(void)remote_scope;
(void)local_scope_id;
@@ -217,11 +217,11 @@ if2ip_result_t Curl_if2ip(int af, unsigned int remote_scope,
s = (struct sockaddr_in *)(void *)&req.ifr_addr;
memcpy(&in, &s->sin_addr, sizeof(in));
- r = Curl_inet_ntop(s->sin_family, &in, buf, buf_size);
+ r = Curl_inet_ntop(s->sin_family, &in, buf, buf_size);
sclose(dummy);
- if(!r)
- return IF2IP_NOT_FOUND;
+ if(!r)
+ return IF2IP_NOT_FOUND;
return IF2IP_FOUND;
}
diff --git a/contrib/libs/curl/lib/if2ip.h b/contrib/libs/curl/lib/if2ip.h
index 9070f72915..e074e476dc 100644
--- a/contrib/libs/curl/lib/if2ip.h
+++ b/contrib/libs/curl/lib/if2ip.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/imap.c b/contrib/libs/curl/lib/imap.c
index 815da5f5de..c6dd7a2323 100644
--- a/contrib/libs/curl/lib/imap.c
+++ b/contrib/libs/curl/lib/imap.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -132,7 +132,7 @@ const struct Curl_handler Curl_handler_imap = {
ZERO_NULL, /* connection_check */
PORT_IMAP, /* defport */
CURLPROTO_IMAP, /* protocol */
- CURLPROTO_IMAP, /* family */
+ CURLPROTO_IMAP, /* family */
PROTOPT_CLOSEACTION| /* flags */
PROTOPT_URLOPTIONS
};
@@ -160,7 +160,7 @@ const struct Curl_handler Curl_handler_imaps = {
ZERO_NULL, /* connection_check */
PORT_IMAPS, /* defport */
CURLPROTO_IMAPS, /* protocol */
- CURLPROTO_IMAP, /* family */
+ CURLPROTO_IMAP, /* family */
PROTOPT_CLOSEACTION | PROTOPT_SSL | /* flags */
PROTOPT_URLOPTIONS
};
@@ -189,7 +189,7 @@ static void imap_to_imaps(struct connectdata *conn)
conn->handler = &Curl_handler_imaps;
/* Set the connection's upgraded to TLS flag */
- conn->bits.tls_upgraded = TRUE;
+ conn->bits.tls_upgraded = TRUE;
}
#else
#define imap_to_imaps(x) Curl_nop_stmt
@@ -246,7 +246,7 @@ static bool imap_matchresp(const char *line, size_t len, const char *cmd)
static bool imap_endofresp(struct connectdata *conn, char *line, size_t len,
int *resp)
{
- struct IMAP *imap = conn->data->req.p.imap;
+ struct IMAP *imap = conn->data->req.p.imap;
struct imap_conn *imapc = &conn->proto.imapc;
const char *id = imapc->resptag;
size_t id_len = strlen(id);
@@ -607,7 +607,7 @@ static CURLcode imap_perform_list(struct connectdata *conn)
{
CURLcode result = CURLE_OK;
struct Curl_easy *data = conn->data;
- struct IMAP *imap = data->req.p.imap;
+ struct IMAP *imap = data->req.p.imap;
if(imap->custom)
/* Send the custom request */
@@ -642,7 +642,7 @@ static CURLcode imap_perform_select(struct connectdata *conn)
{
CURLcode result = CURLE_OK;
struct Curl_easy *data = conn->data;
- struct IMAP *imap = data->req.p.imap;
+ struct IMAP *imap = data->req.p.imap;
struct imap_conn *imapc = &conn->proto.imapc;
char *mailbox;
@@ -681,7 +681,7 @@ static CURLcode imap_perform_select(struct connectdata *conn)
static CURLcode imap_perform_fetch(struct connectdata *conn)
{
CURLcode result = CURLE_OK;
- struct IMAP *imap = conn->data->req.p.imap;
+ struct IMAP *imap = conn->data->req.p.imap;
/* Check we have a UID */
if(imap->uid) {
@@ -729,7 +729,7 @@ static CURLcode imap_perform_append(struct connectdata *conn)
{
CURLcode result = CURLE_OK;
struct Curl_easy *data = conn->data;
- struct IMAP *imap = data->req.p.imap;
+ struct IMAP *imap = data->req.p.imap;
char *mailbox;
/* Check we have a mailbox */
@@ -799,7 +799,7 @@ static CURLcode imap_perform_append(struct connectdata *conn)
static CURLcode imap_perform_search(struct connectdata *conn)
{
CURLcode result = CURLE_OK;
- struct IMAP *imap = conn->data->req.p.imap;
+ struct IMAP *imap = conn->data->req.p.imap;
/* Check we have a query string */
if(!imap->query) {
@@ -1053,7 +1053,7 @@ static CURLcode imap_state_select_resp(struct connectdata *conn, int imapcode,
{
CURLcode result = CURLE_OK;
struct Curl_easy *data = conn->data;
- struct IMAP *imap = conn->data->req.p.imap;
+ struct IMAP *imap = conn->data->req.p.imap;
struct imap_conn *imapc = &conn->proto.imapc;
const char *line = data->state.buffer;
@@ -1178,9 +1178,9 @@ static CURLcode imap_state_fetch_resp(struct connectdata *conn, int imapcode,
else {
/* IMAP download */
data->req.maxdownload = size;
- /* force a recv/send check of this connection, as the data might've been
- read off the socket already */
- data->conn->cselect_bits = CURL_CSELECT_IN;
+ /* force a recv/send check of this connection, as the data might've been
+ read off the socket already */
+ data->conn->cselect_bits = CURL_CSELECT_IN;
Curl_setup_transfer(data, FIRSTSOCKET, size, FALSE, -1);
}
}
@@ -1311,7 +1311,7 @@ static CURLcode imap_statemach_act(struct connectdata *conn)
break;
case IMAP_LIST:
- case IMAP_SEARCH:
+ case IMAP_SEARCH:
result = imap_state_listsearch_resp(conn, imapcode, imapc->state);
break;
@@ -1385,7 +1385,7 @@ static CURLcode imap_init(struct connectdata *conn)
struct Curl_easy *data = conn->data;
struct IMAP *imap;
- imap = data->req.p.imap = calloc(sizeof(struct IMAP), 1);
+ imap = data->req.p.imap = calloc(sizeof(struct IMAP), 1);
if(!imap)
result = CURLE_OUT_OF_MEMORY;
@@ -1429,9 +1429,9 @@ static CURLcode imap_connect(struct connectdata *conn, bool *done)
imapc->preftype = IMAP_TYPE_ANY;
Curl_sasl_init(&imapc->sasl, &saslimap);
- Curl_dyn_init(&imapc->dyn, DYN_IMAP_CMD);
+ Curl_dyn_init(&imapc->dyn, DYN_IMAP_CMD);
/* Initialise the pingpong layer */
- Curl_pp_setup(pp);
+ Curl_pp_setup(pp);
Curl_pp_init(pp);
/* Parse the URL options */
@@ -1464,7 +1464,7 @@ static CURLcode imap_done(struct connectdata *conn, CURLcode status,
{
CURLcode result = CURLE_OK;
struct Curl_easy *data = conn->data;
- struct IMAP *imap = data->req.p.imap;
+ struct IMAP *imap = data->req.p.imap;
(void)premature;
@@ -1524,7 +1524,7 @@ static CURLcode imap_perform(struct connectdata *conn, bool *connected,
/* This is IMAP and no proxy */
CURLcode result = CURLE_OK;
struct Curl_easy *data = conn->data;
- struct IMAP *imap = data->req.p.imap;
+ struct IMAP *imap = data->req.p.imap;
struct imap_conn *imapc = &conn->proto.imapc;
bool selected = FALSE;
@@ -1633,7 +1633,7 @@ static CURLcode imap_disconnect(struct connectdata *conn, bool dead_connection)
/* Disconnect from the server */
Curl_pp_disconnect(&imapc->pp);
- Curl_dyn_free(&imapc->dyn);
+ Curl_dyn_free(&imapc->dyn);
/* Cleanup the SASL module */
Curl_sasl_cleanup(conn, imapc->sasl.authused);
@@ -1648,7 +1648,7 @@ static CURLcode imap_disconnect(struct connectdata *conn, bool dead_connection)
/* Call this when the DO phase has completed */
static CURLcode imap_dophase_done(struct connectdata *conn, bool connected)
{
- struct IMAP *imap = conn->data->req.p.imap;
+ struct IMAP *imap = conn->data->req.p.imap;
(void)connected;
@@ -1718,7 +1718,7 @@ static CURLcode imap_setup_connection(struct connectdata *conn)
return result;
/* Clear the TLS upgraded flag */
- conn->bits.tls_upgraded = FALSE;
+ conn->bits.tls_upgraded = FALSE;
return CURLE_OK;
}
@@ -1740,20 +1740,20 @@ static CURLcode imap_sendf(struct connectdata *conn, const char *fmt, ...)
/* Calculate the tag based on the connection ID and command ID */
msnprintf(imapc->resptag, sizeof(imapc->resptag), "%c%03d",
- 'A' + curlx_sltosi(conn->connection_id % 26),
- (++imapc->cmdid)%1000);
-
- /* start with a blank buffer */
- Curl_dyn_reset(&imapc->dyn);
-
- /* append tag + space + fmt */
- result = Curl_dyn_addf(&imapc->dyn, "%s %s", imapc->resptag, fmt);
- if(!result) {
- va_list ap;
- va_start(ap, fmt);
- result = Curl_pp_vsendf(&imapc->pp, Curl_dyn_ptr(&imapc->dyn), ap);
- va_end(ap);
- }
+ 'A' + curlx_sltosi(conn->connection_id % 26),
+ (++imapc->cmdid)%1000);
+
+ /* start with a blank buffer */
+ Curl_dyn_reset(&imapc->dyn);
+
+ /* append tag + space + fmt */
+ result = Curl_dyn_addf(&imapc->dyn, "%s %s", imapc->resptag, fmt);
+ if(!result) {
+ va_list ap;
+ va_start(ap, fmt);
+ result = Curl_pp_vsendf(&imapc->pp, Curl_dyn_ptr(&imapc->dyn), ap);
+ va_end(ap);
+ }
return result;
}
@@ -1945,7 +1945,7 @@ static CURLcode imap_parse_url_path(struct connectdata *conn)
/* The imap struct is already initialised in imap_connect() */
CURLcode result = CURLE_OK;
struct Curl_easy *data = conn->data;
- struct IMAP *imap = data->req.p.imap;
+ struct IMAP *imap = data->req.p.imap;
const char *begin = &data->state.up.path[1]; /* skip leading slash */
const char *ptr = begin;
@@ -1960,7 +1960,7 @@ static CURLcode imap_parse_url_path(struct connectdata *conn)
end--;
result = Curl_urldecode(data, begin, end - begin, &imap->mailbox, NULL,
- REJECT_CTRL);
+ REJECT_CTRL);
if(result)
return result;
}
@@ -1982,8 +1982,8 @@ static CURLcode imap_parse_url_path(struct connectdata *conn)
return CURLE_URL_MALFORMAT;
/* Decode the name parameter */
- result = Curl_urldecode(data, begin, ptr - begin, &name, NULL,
- REJECT_CTRL);
+ result = Curl_urldecode(data, begin, ptr - begin, &name, NULL,
+ REJECT_CTRL);
if(result)
return result;
@@ -1993,8 +1993,8 @@ static CURLcode imap_parse_url_path(struct connectdata *conn)
ptr++;
/* Decode the value parameter */
- result = Curl_urldecode(data, begin, ptr - begin, &value, &valuelen,
- REJECT_CTRL);
+ result = Curl_urldecode(data, begin, ptr - begin, &value, &valuelen,
+ REJECT_CTRL);
if(result) {
free(name);
return result;
@@ -2077,12 +2077,12 @@ static CURLcode imap_parse_custom_request(struct connectdata *conn)
{
CURLcode result = CURLE_OK;
struct Curl_easy *data = conn->data;
- struct IMAP *imap = data->req.p.imap;
+ struct IMAP *imap = data->req.p.imap;
const char *custom = data->set.str[STRING_CUSTOMREQUEST];
if(custom) {
/* URL decode the custom request */
- result = Curl_urldecode(data, custom, 0, &imap->custom, NULL, REJECT_CTRL);
+ result = Curl_urldecode(data, custom, 0, &imap->custom, NULL, REJECT_CTRL);
/* Extract the parameters if specified */
if(!result) {
diff --git a/contrib/libs/curl/lib/imap.h b/contrib/libs/curl/lib/imap.h
index 3817de4437..ef6515d8c2 100644
--- a/contrib/libs/curl/lib/imap.h
+++ b/contrib/libs/curl/lib/imap.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 2009 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2009 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -75,14 +75,14 @@ struct imap_conn {
bool preauth; /* Is this connection PREAUTH? */
struct SASL sasl; /* SASL-related parameters */
unsigned int preftype; /* Preferred authentication type */
- unsigned int cmdid; /* Last used command ID */
+ unsigned int cmdid; /* Last used command ID */
char resptag[5]; /* Response tag to wait for */
bool tls_supported; /* StartTLS capability supported by server */
bool login_disabled; /* LOGIN command disabled by server */
bool ir_supported; /* Initial response supported by server */
char *mailbox; /* The last selected mailbox */
char *mailbox_uidvalidity; /* UIDVALIDITY parsed from select response */
- struct dynbuf dyn; /* for the IMAP commands */
+ struct dynbuf dyn; /* for the IMAP commands */
};
extern const struct Curl_handler Curl_handler_imap;
diff --git a/contrib/libs/curl/lib/inet_ntop.c b/contrib/libs/curl/lib/inet_ntop.c
index 6ad88d7334..9a5af7f421 100644
--- a/contrib/libs/curl/lib/inet_ntop.c
+++ b/contrib/libs/curl/lib/inet_ntop.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1996-2019 Internet Software Consortium.
+ * Copyright (C) 1996-2019 Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
diff --git a/contrib/libs/curl/lib/inet_ntop.h b/contrib/libs/curl/lib/inet_ntop.h
index dece4e1ed5..067632aaee 100644
--- a/contrib/libs/curl/lib/inet_ntop.h
+++ b/contrib/libs/curl/lib/inet_ntop.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/inet_pton.c b/contrib/libs/curl/lib/inet_pton.c
index 47826633aa..4923cae245 100644
--- a/contrib/libs/curl/lib/inet_pton.c
+++ b/contrib/libs/curl/lib/inet_pton.c
@@ -1,6 +1,6 @@
/* This is from the BIND 4.9.4 release, modified to compile by itself */
-/* Copyright (c) 1996 - 2020 by Internet Software Consortium.
+/* Copyright (c) 1996 - 2020 by Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -112,7 +112,7 @@ inet_pton4(const char *src, unsigned char *dst)
if(val > 255)
return (0);
*tp = (unsigned char)val;
- if(!saw_digit) {
+ if(!saw_digit) {
if(++octets > 4)
return (0);
saw_digit = 1;
diff --git a/contrib/libs/curl/lib/inet_pton.h b/contrib/libs/curl/lib/inet_pton.h
index 7a4baa560e..ec1237309f 100644
--- a/contrib/libs/curl/lib/inet_pton.h
+++ b/contrib/libs/curl/lib/inet_pton.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/krb5.c b/contrib/libs/curl/lib/krb5.c
index b8bf42311f..66394f4f30 100644
--- a/contrib/libs/curl/lib/krb5.c
+++ b/contrib/libs/curl/lib/krb5.c
@@ -2,7 +2,7 @@
*
* Copyright (c) 1995, 1996, 1997, 1998, 1999 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
- * Copyright (c) 2004 - 2020 Daniel Stenberg
+ * Copyright (c) 2004 - 2020 Daniel Stenberg
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -45,73 +45,73 @@
#include "ftp.h"
#include "curl_gssapi.h"
#include "sendf.h"
-#include "curl_krb5.h"
+#include "curl_krb5.h"
#include "warnless.h"
-#include "non-ascii.h"
-#include "strcase.h"
-#include "strdup.h"
+#include "non-ascii.h"
+#include "strcase.h"
+#include "strdup.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
#include "curl_memory.h"
#include "memdebug.h"
-static CURLcode ftpsend(struct connectdata *conn, const char *cmd)
-{
- ssize_t bytes_written;
-#define SBUF_SIZE 1024
- char s[SBUF_SIZE];
- size_t write_len;
- char *sptr = s;
- CURLcode result = CURLE_OK;
-#ifdef HAVE_GSSAPI
- enum protection_level data_sec = conn->data_prot;
-#endif
-
- if(!cmd)
- return CURLE_BAD_FUNCTION_ARGUMENT;
-
- write_len = strlen(cmd);
- if(!write_len || write_len > (sizeof(s) -3))
- return CURLE_BAD_FUNCTION_ARGUMENT;
-
- memcpy(&s, cmd, write_len);
- strcpy(&s[write_len], "\r\n"); /* append a trailing CRLF */
- write_len += 2;
- bytes_written = 0;
-
- result = Curl_convert_to_network(conn->data, s, write_len);
- /* Curl_convert_to_network calls failf if unsuccessful */
- if(result)
- return result;
-
- for(;;) {
-#ifdef HAVE_GSSAPI
- conn->data_prot = PROT_CMD;
-#endif
- result = Curl_write(conn, conn->sock[FIRSTSOCKET], sptr, write_len,
- &bytes_written);
-#ifdef HAVE_GSSAPI
- DEBUGASSERT(data_sec > PROT_NONE && data_sec < PROT_LAST);
- conn->data_prot = data_sec;
-#endif
-
- if(result)
- break;
-
- Curl_debug(conn->data, CURLINFO_HEADER_OUT, sptr, (size_t)bytes_written);
-
- if(bytes_written != (ssize_t)write_len) {
- write_len -= bytes_written;
- sptr += bytes_written;
- }
- else
- break;
- }
-
- return result;
-}
-
+static CURLcode ftpsend(struct connectdata *conn, const char *cmd)
+{
+ ssize_t bytes_written;
+#define SBUF_SIZE 1024
+ char s[SBUF_SIZE];
+ size_t write_len;
+ char *sptr = s;
+ CURLcode result = CURLE_OK;
+#ifdef HAVE_GSSAPI
+ enum protection_level data_sec = conn->data_prot;
+#endif
+
+ if(!cmd)
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+
+ write_len = strlen(cmd);
+ if(!write_len || write_len > (sizeof(s) -3))
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+
+ memcpy(&s, cmd, write_len);
+ strcpy(&s[write_len], "\r\n"); /* append a trailing CRLF */
+ write_len += 2;
+ bytes_written = 0;
+
+ result = Curl_convert_to_network(conn->data, s, write_len);
+ /* Curl_convert_to_network calls failf if unsuccessful */
+ if(result)
+ return result;
+
+ for(;;) {
+#ifdef HAVE_GSSAPI
+ conn->data_prot = PROT_CMD;
+#endif
+ result = Curl_write(conn, conn->sock[FIRSTSOCKET], sptr, write_len,
+ &bytes_written);
+#ifdef HAVE_GSSAPI
+ DEBUGASSERT(data_sec > PROT_NONE && data_sec < PROT_LAST);
+ conn->data_prot = data_sec;
+#endif
+
+ if(result)
+ break;
+
+ Curl_debug(conn->data, CURLINFO_HEADER_OUT, sptr, (size_t)bytes_written);
+
+ if(bytes_written != (ssize_t)write_len) {
+ write_len -= bytes_written;
+ sptr += bytes_written;
+ }
+ else
+ break;
+ }
+
+ return result;
+}
+
static int
krb5_init(void *app_data)
{
@@ -242,7 +242,7 @@ krb5_auth(void *app_data, struct connectdata *conn)
for(;;) {
/* this really shouldn't be repeated here, but can't help it */
if(service == srv_host) {
- result = ftpsend(conn, "AUTH GSSAPI");
+ result = ftpsend(conn, "AUTH GSSAPI");
if(result)
return -2;
@@ -319,7 +319,7 @@ krb5_auth(void *app_data, struct connectdata *conn)
cmd = aprintf("ADAT %s", p);
if(cmd)
- result = ftpsend(conn, cmd);
+ result = ftpsend(conn, cmd);
else
result = CURLE_OUT_OF_MEMORY;
@@ -385,524 +385,524 @@ static void krb5_end(void *app_data)
}
}
-static struct Curl_sec_client_mech Curl_krb5_client_mech = {
- "GSSAPI",
- sizeof(gss_ctx_id_t),
- krb5_init,
- krb5_auth,
- krb5_end,
- krb5_check_prot,
- krb5_overhead,
- krb5_encode,
- krb5_decode
+static struct Curl_sec_client_mech Curl_krb5_client_mech = {
+ "GSSAPI",
+ sizeof(gss_ctx_id_t),
+ krb5_init,
+ krb5_auth,
+ krb5_end,
+ krb5_check_prot,
+ krb5_overhead,
+ krb5_encode,
+ krb5_decode
+};
+
+static const struct {
+ enum protection_level level;
+ const char *name;
+} level_names[] = {
+ { PROT_CLEAR, "clear" },
+ { PROT_SAFE, "safe" },
+ { PROT_CONFIDENTIAL, "confidential" },
+ { PROT_PRIVATE, "private" }
};
-static const struct {
- enum protection_level level;
- const char *name;
-} level_names[] = {
- { PROT_CLEAR, "clear" },
- { PROT_SAFE, "safe" },
- { PROT_CONFIDENTIAL, "confidential" },
- { PROT_PRIVATE, "private" }
-};
-
-static enum protection_level
-name_to_level(const char *name)
-{
- int i;
- for(i = 0; i < (int)sizeof(level_names)/(int)sizeof(level_names[0]); i++)
- if(checkprefix(name, level_names[i].name))
- return level_names[i].level;
- return PROT_NONE;
-}
-
-/* Convert a protocol |level| to its char representation.
- We take an int to catch programming mistakes. */
-static char level_to_char(int level)
-{
- switch(level) {
- case PROT_CLEAR:
- return 'C';
- case PROT_SAFE:
- return 'S';
- case PROT_CONFIDENTIAL:
- return 'E';
- case PROT_PRIVATE:
- return 'P';
- case PROT_CMD:
- /* Fall through */
- default:
- /* Those 2 cases should not be reached! */
- break;
- }
- DEBUGASSERT(0);
- /* Default to the most secure alternative. */
- return 'P';
-}
-
-/* Send an FTP command defined by |message| and the optional arguments. The
- function returns the ftp_code. If an error occurs, -1 is returned. */
-static int ftp_send_command(struct connectdata *conn, const char *message, ...)
-{
- int ftp_code;
- ssize_t nread = 0;
- va_list args;
- char print_buffer[50];
-
- va_start(args, message);
- mvsnprintf(print_buffer, sizeof(print_buffer), message, args);
- va_end(args);
-
- if(ftpsend(conn, print_buffer)) {
- ftp_code = -1;
- }
- else {
- if(Curl_GetFTPResponse(&nread, conn, &ftp_code))
- ftp_code = -1;
- }
-
- (void)nread; /* Unused */
- return ftp_code;
-}
-
-/* Read |len| from the socket |fd| and store it in |to|. Return a CURLcode
- saying whether an error occurred or CURLE_OK if |len| was read. */
-static CURLcode
-socket_read(curl_socket_t fd, void *to, size_t len)
-{
- char *to_p = to;
- CURLcode result;
- ssize_t nread = 0;
-
- while(len > 0) {
- result = Curl_read_plain(fd, to_p, len, &nread);
- if(!result) {
- len -= nread;
- to_p += nread;
- }
- else {
- if(result == CURLE_AGAIN)
- continue;
- return result;
- }
- }
- return CURLE_OK;
-}
-
-
-/* Write |len| bytes from the buffer |to| to the socket |fd|. Return a
- CURLcode saying whether an error occurred or CURLE_OK if |len| was
- written. */
-static CURLcode
-socket_write(struct connectdata *conn, curl_socket_t fd, const void *to,
- size_t len)
-{
- const char *to_p = to;
- CURLcode result;
- ssize_t written;
-
- while(len > 0) {
- result = Curl_write_plain(conn, fd, to_p, len, &written);
- if(!result) {
- len -= written;
- to_p += written;
- }
- else {
- if(result == CURLE_AGAIN)
- continue;
- return result;
- }
- }
- return CURLE_OK;
-}
-
-static CURLcode read_data(struct connectdata *conn,
- curl_socket_t fd,
- struct krb5buffer *buf)
-{
- int len;
- CURLcode result;
-
- result = socket_read(fd, &len, sizeof(len));
- if(result)
- return result;
-
- if(len) {
- /* only realloc if there was a length */
- len = ntohl(len);
- buf->data = Curl_saferealloc(buf->data, len);
- }
- if(!len || !buf->data)
- return CURLE_OUT_OF_MEMORY;
-
- result = socket_read(fd, buf->data, len);
- if(result)
- return result;
- buf->size = conn->mech->decode(conn->app_data, buf->data, len,
- conn->data_prot, conn);
- buf->index = 0;
- return CURLE_OK;
-}
-
-static size_t
-buffer_read(struct krb5buffer *buf, void *data, size_t len)
-{
- if(buf->size - buf->index < len)
- len = buf->size - buf->index;
- memcpy(data, (char *)buf->data + buf->index, len);
- buf->index += len;
- return len;
-}
-
-/* Matches Curl_recv signature */
-static ssize_t sec_recv(struct connectdata *conn, int sockindex,
- char *buffer, size_t len, CURLcode *err)
-{
- size_t bytes_read;
- size_t total_read = 0;
- curl_socket_t fd = conn->sock[sockindex];
-
- *err = CURLE_OK;
-
- /* Handle clear text response. */
- if(conn->sec_complete == 0 || conn->data_prot == PROT_CLEAR)
- return sread(fd, buffer, len);
-
- if(conn->in_buffer.eof_flag) {
- conn->in_buffer.eof_flag = 0;
- return 0;
- }
-
- bytes_read = buffer_read(&conn->in_buffer, buffer, len);
- len -= bytes_read;
- total_read += bytes_read;
- buffer += bytes_read;
-
- while(len > 0) {
- if(read_data(conn, fd, &conn->in_buffer))
- return -1;
- if(conn->in_buffer.size == 0) {
- if(bytes_read > 0)
- conn->in_buffer.eof_flag = 1;
- return bytes_read;
- }
- bytes_read = buffer_read(&conn->in_buffer, buffer, len);
- len -= bytes_read;
- total_read += bytes_read;
- buffer += bytes_read;
- }
- return total_read;
-}
-
-/* Send |length| bytes from |from| to the |fd| socket taking care of encoding
- and negotiating with the server. |from| can be NULL. */
-static void do_sec_send(struct connectdata *conn, curl_socket_t fd,
- const char *from, int length)
-{
- int bytes, htonl_bytes; /* 32-bit integers for htonl */
- char *buffer = NULL;
- char *cmd_buffer;
- size_t cmd_size = 0;
- CURLcode error;
- enum protection_level prot_level = conn->data_prot;
- bool iscmd = (prot_level == PROT_CMD)?TRUE:FALSE;
-
- DEBUGASSERT(prot_level > PROT_NONE && prot_level < PROT_LAST);
-
- if(iscmd) {
- if(!strncmp(from, "PASS ", 5) || !strncmp(from, "ACCT ", 5))
- prot_level = PROT_PRIVATE;
- else
- prot_level = conn->command_prot;
- }
- bytes = conn->mech->encode(conn->app_data, from, length, prot_level,
- (void **)&buffer);
- if(!buffer || bytes <= 0)
- return; /* error */
-
- if(iscmd) {
- error = Curl_base64_encode(conn->data, buffer, curlx_sitouz(bytes),
- &cmd_buffer, &cmd_size);
- if(error) {
- free(buffer);
- return; /* error */
- }
- if(cmd_size > 0) {
- static const char *enc = "ENC ";
- static const char *mic = "MIC ";
- if(prot_level == PROT_PRIVATE)
- socket_write(conn, fd, enc, 4);
- else
- socket_write(conn, fd, mic, 4);
-
- socket_write(conn, fd, cmd_buffer, cmd_size);
- socket_write(conn, fd, "\r\n", 2);
- infof(conn->data, "Send: %s%s\n", prot_level == PROT_PRIVATE?enc:mic,
- cmd_buffer);
- free(cmd_buffer);
- }
- }
- else {
- htonl_bytes = htonl(bytes);
- socket_write(conn, fd, &htonl_bytes, sizeof(htonl_bytes));
- socket_write(conn, fd, buffer, curlx_sitouz(bytes));
- }
- free(buffer);
-}
-
-static ssize_t sec_write(struct connectdata *conn, curl_socket_t fd,
- const char *buffer, size_t length)
-{
- ssize_t tx = 0, len = conn->buffer_size;
-
- len -= conn->mech->overhead(conn->app_data, conn->data_prot,
- curlx_sztosi(len));
- if(len <= 0)
- len = length;
- while(length) {
- if(length < (size_t)len)
- len = length;
-
- do_sec_send(conn, fd, buffer, curlx_sztosi(len));
- length -= len;
- buffer += len;
- tx += len;
- }
- return tx;
-}
-
-/* Matches Curl_send signature */
-static ssize_t sec_send(struct connectdata *conn, int sockindex,
- const void *buffer, size_t len, CURLcode *err)
-{
- curl_socket_t fd = conn->sock[sockindex];
- *err = CURLE_OK;
- return sec_write(conn, fd, buffer, len);
-}
-
-int Curl_sec_read_msg(struct connectdata *conn, char *buffer,
- enum protection_level level)
-{
- /* decoded_len should be size_t or ssize_t but conn->mech->decode returns an
- int */
- int decoded_len;
- char *buf;
- int ret_code = 0;
- size_t decoded_sz = 0;
- CURLcode error;
-
- if(!conn->mech)
- /* not inititalized, return error */
- return -1;
-
- DEBUGASSERT(level > PROT_NONE && level < PROT_LAST);
-
- error = Curl_base64_decode(buffer + 4, (unsigned char **)&buf, &decoded_sz);
- if(error || decoded_sz == 0)
- return -1;
-
- if(decoded_sz > (size_t)INT_MAX) {
- free(buf);
- return -1;
- }
- decoded_len = curlx_uztosi(decoded_sz);
-
- decoded_len = conn->mech->decode(conn->app_data, buf, decoded_len,
- level, conn);
- if(decoded_len <= 0) {
- free(buf);
- return -1;
- }
-
- {
- buf[decoded_len] = '\n';
- Curl_debug(conn->data, CURLINFO_HEADER_IN, buf, decoded_len + 1);
- }
-
- buf[decoded_len] = '\0';
- if(decoded_len <= 3)
- /* suspiciously short */
- return 0;
-
- if(buf[3] != '-')
- /* safe to ignore return code */
- (void)sscanf(buf, "%d", &ret_code);
-
- if(buf[decoded_len - 1] == '\n')
- buf[decoded_len - 1] = '\0';
- strcpy(buffer, buf);
- free(buf);
- return ret_code;
-}
-
-static int sec_set_protection_level(struct connectdata *conn)
-{
- int code;
- enum protection_level level = conn->request_data_prot;
-
- DEBUGASSERT(level > PROT_NONE && level < PROT_LAST);
-
- if(!conn->sec_complete) {
- infof(conn->data, "Trying to change the protection level after the"
- " completion of the data exchange.\n");
- return -1;
- }
-
- /* Bail out if we try to set up the same level */
- if(conn->data_prot == level)
- return 0;
-
- if(level) {
- char *pbsz;
- static unsigned int buffer_size = 1 << 20; /* 1048576 */
-
- code = ftp_send_command(conn, "PBSZ %u", buffer_size);
- if(code < 0)
- return -1;
-
- if(code/100 != 2) {
- failf(conn->data, "Failed to set the protection's buffer size.");
- return -1;
- }
- conn->buffer_size = buffer_size;
-
- pbsz = strstr(conn->data->state.buffer, "PBSZ=");
- if(pbsz) {
- /* ignore return code, use default value if it fails */
- (void)sscanf(pbsz, "PBSZ=%u", &buffer_size);
- if(buffer_size < conn->buffer_size)
- conn->buffer_size = buffer_size;
- }
- }
-
- /* Now try to negiociate the protection level. */
- code = ftp_send_command(conn, "PROT %c", level_to_char(level));
-
- if(code < 0)
- return -1;
-
- if(code/100 != 2) {
- failf(conn->data, "Failed to set the protection level.");
- return -1;
- }
-
- conn->data_prot = level;
- if(level == PROT_PRIVATE)
- conn->command_prot = level;
-
- return 0;
-}
-
-int
-Curl_sec_request_prot(struct connectdata *conn, const char *level)
-{
- enum protection_level l = name_to_level(level);
- if(l == PROT_NONE)
- return -1;
- DEBUGASSERT(l > PROT_NONE && l < PROT_LAST);
- conn->request_data_prot = l;
- return 0;
-}
-
-static CURLcode choose_mech(struct connectdata *conn)
-{
- int ret;
- struct Curl_easy *data = conn->data;
- void *tmp_allocation;
- const struct Curl_sec_client_mech *mech = &Curl_krb5_client_mech;
-
- tmp_allocation = realloc(conn->app_data, mech->size);
- if(tmp_allocation == NULL) {
- failf(data, "Failed realloc of size %zu", mech->size);
- mech = NULL;
- return CURLE_OUT_OF_MEMORY;
- }
- conn->app_data = tmp_allocation;
-
- if(mech->init) {
- ret = mech->init(conn->app_data);
- if(ret) {
- infof(data, "Failed initialization for %s. Skipping it.\n",
- mech->name);
- return CURLE_FAILED_INIT;
- }
- }
-
- infof(data, "Trying mechanism %s...\n", mech->name);
- ret = ftp_send_command(conn, "AUTH %s", mech->name);
- if(ret < 0)
- return CURLE_COULDNT_CONNECT;
-
- if(ret/100 != 3) {
- switch(ret) {
- case 504:
- infof(data, "Mechanism %s is not supported by the server (server "
- "returned ftp code: 504).\n", mech->name);
- break;
- case 534:
- infof(data, "Mechanism %s was rejected by the server (server returned "
- "ftp code: 534).\n", mech->name);
- break;
- default:
- if(ret/100 == 5) {
- infof(data, "server does not support the security extensions\n");
- return CURLE_USE_SSL_FAILED;
- }
- break;
- }
- return CURLE_LOGIN_DENIED;
- }
-
- /* Authenticate */
- ret = mech->auth(conn->app_data, conn);
-
- if(ret != AUTH_CONTINUE) {
- if(ret != AUTH_OK) {
- /* Mechanism has dumped the error to stderr, don't error here. */
- return CURLE_USE_SSL_FAILED;
- }
- DEBUGASSERT(ret == AUTH_OK);
-
- conn->mech = mech;
- conn->sec_complete = 1;
- conn->recv[FIRSTSOCKET] = sec_recv;
- conn->send[FIRSTSOCKET] = sec_send;
- conn->recv[SECONDARYSOCKET] = sec_recv;
- conn->send[SECONDARYSOCKET] = sec_send;
- conn->command_prot = PROT_SAFE;
- /* Set the requested protection level */
- /* BLOCKING */
- (void)sec_set_protection_level(conn);
- }
-
- return CURLE_OK;
-}
-
-CURLcode
-Curl_sec_login(struct connectdata *conn)
-{
- return choose_mech(conn);
-}
-
-
-void
-Curl_sec_end(struct connectdata *conn)
-{
- if(conn->mech != NULL && conn->mech->end)
- conn->mech->end(conn->app_data);
- free(conn->app_data);
- conn->app_data = NULL;
- if(conn->in_buffer.data) {
- free(conn->in_buffer.data);
- conn->in_buffer.data = NULL;
- conn->in_buffer.size = 0;
- conn->in_buffer.index = 0;
- conn->in_buffer.eof_flag = 0;
- }
- conn->sec_complete = 0;
- conn->data_prot = PROT_CLEAR;
- conn->mech = NULL;
-}
-
+static enum protection_level
+name_to_level(const char *name)
+{
+ int i;
+ for(i = 0; i < (int)sizeof(level_names)/(int)sizeof(level_names[0]); i++)
+ if(checkprefix(name, level_names[i].name))
+ return level_names[i].level;
+ return PROT_NONE;
+}
+
+/* Convert a protocol |level| to its char representation.
+ We take an int to catch programming mistakes. */
+static char level_to_char(int level)
+{
+ switch(level) {
+ case PROT_CLEAR:
+ return 'C';
+ case PROT_SAFE:
+ return 'S';
+ case PROT_CONFIDENTIAL:
+ return 'E';
+ case PROT_PRIVATE:
+ return 'P';
+ case PROT_CMD:
+ /* Fall through */
+ default:
+ /* Those 2 cases should not be reached! */
+ break;
+ }
+ DEBUGASSERT(0);
+ /* Default to the most secure alternative. */
+ return 'P';
+}
+
+/* Send an FTP command defined by |message| and the optional arguments. The
+ function returns the ftp_code. If an error occurs, -1 is returned. */
+static int ftp_send_command(struct connectdata *conn, const char *message, ...)
+{
+ int ftp_code;
+ ssize_t nread = 0;
+ va_list args;
+ char print_buffer[50];
+
+ va_start(args, message);
+ mvsnprintf(print_buffer, sizeof(print_buffer), message, args);
+ va_end(args);
+
+ if(ftpsend(conn, print_buffer)) {
+ ftp_code = -1;
+ }
+ else {
+ if(Curl_GetFTPResponse(&nread, conn, &ftp_code))
+ ftp_code = -1;
+ }
+
+ (void)nread; /* Unused */
+ return ftp_code;
+}
+
+/* Read |len| from the socket |fd| and store it in |to|. Return a CURLcode
+ saying whether an error occurred or CURLE_OK if |len| was read. */
+static CURLcode
+socket_read(curl_socket_t fd, void *to, size_t len)
+{
+ char *to_p = to;
+ CURLcode result;
+ ssize_t nread = 0;
+
+ while(len > 0) {
+ result = Curl_read_plain(fd, to_p, len, &nread);
+ if(!result) {
+ len -= nread;
+ to_p += nread;
+ }
+ else {
+ if(result == CURLE_AGAIN)
+ continue;
+ return result;
+ }
+ }
+ return CURLE_OK;
+}
+
+
+/* Write |len| bytes from the buffer |to| to the socket |fd|. Return a
+ CURLcode saying whether an error occurred or CURLE_OK if |len| was
+ written. */
+static CURLcode
+socket_write(struct connectdata *conn, curl_socket_t fd, const void *to,
+ size_t len)
+{
+ const char *to_p = to;
+ CURLcode result;
+ ssize_t written;
+
+ while(len > 0) {
+ result = Curl_write_plain(conn, fd, to_p, len, &written);
+ if(!result) {
+ len -= written;
+ to_p += written;
+ }
+ else {
+ if(result == CURLE_AGAIN)
+ continue;
+ return result;
+ }
+ }
+ return CURLE_OK;
+}
+
+static CURLcode read_data(struct connectdata *conn,
+ curl_socket_t fd,
+ struct krb5buffer *buf)
+{
+ int len;
+ CURLcode result;
+
+ result = socket_read(fd, &len, sizeof(len));
+ if(result)
+ return result;
+
+ if(len) {
+ /* only realloc if there was a length */
+ len = ntohl(len);
+ buf->data = Curl_saferealloc(buf->data, len);
+ }
+ if(!len || !buf->data)
+ return CURLE_OUT_OF_MEMORY;
+
+ result = socket_read(fd, buf->data, len);
+ if(result)
+ return result;
+ buf->size = conn->mech->decode(conn->app_data, buf->data, len,
+ conn->data_prot, conn);
+ buf->index = 0;
+ return CURLE_OK;
+}
+
+static size_t
+buffer_read(struct krb5buffer *buf, void *data, size_t len)
+{
+ if(buf->size - buf->index < len)
+ len = buf->size - buf->index;
+ memcpy(data, (char *)buf->data + buf->index, len);
+ buf->index += len;
+ return len;
+}
+
+/* Matches Curl_recv signature */
+static ssize_t sec_recv(struct connectdata *conn, int sockindex,
+ char *buffer, size_t len, CURLcode *err)
+{
+ size_t bytes_read;
+ size_t total_read = 0;
+ curl_socket_t fd = conn->sock[sockindex];
+
+ *err = CURLE_OK;
+
+ /* Handle clear text response. */
+ if(conn->sec_complete == 0 || conn->data_prot == PROT_CLEAR)
+ return sread(fd, buffer, len);
+
+ if(conn->in_buffer.eof_flag) {
+ conn->in_buffer.eof_flag = 0;
+ return 0;
+ }
+
+ bytes_read = buffer_read(&conn->in_buffer, buffer, len);
+ len -= bytes_read;
+ total_read += bytes_read;
+ buffer += bytes_read;
+
+ while(len > 0) {
+ if(read_data(conn, fd, &conn->in_buffer))
+ return -1;
+ if(conn->in_buffer.size == 0) {
+ if(bytes_read > 0)
+ conn->in_buffer.eof_flag = 1;
+ return bytes_read;
+ }
+ bytes_read = buffer_read(&conn->in_buffer, buffer, len);
+ len -= bytes_read;
+ total_read += bytes_read;
+ buffer += bytes_read;
+ }
+ return total_read;
+}
+
+/* Send |length| bytes from |from| to the |fd| socket taking care of encoding
+ and negotiating with the server. |from| can be NULL. */
+static void do_sec_send(struct connectdata *conn, curl_socket_t fd,
+ const char *from, int length)
+{
+ int bytes, htonl_bytes; /* 32-bit integers for htonl */
+ char *buffer = NULL;
+ char *cmd_buffer;
+ size_t cmd_size = 0;
+ CURLcode error;
+ enum protection_level prot_level = conn->data_prot;
+ bool iscmd = (prot_level == PROT_CMD)?TRUE:FALSE;
+
+ DEBUGASSERT(prot_level > PROT_NONE && prot_level < PROT_LAST);
+
+ if(iscmd) {
+ if(!strncmp(from, "PASS ", 5) || !strncmp(from, "ACCT ", 5))
+ prot_level = PROT_PRIVATE;
+ else
+ prot_level = conn->command_prot;
+ }
+ bytes = conn->mech->encode(conn->app_data, from, length, prot_level,
+ (void **)&buffer);
+ if(!buffer || bytes <= 0)
+ return; /* error */
+
+ if(iscmd) {
+ error = Curl_base64_encode(conn->data, buffer, curlx_sitouz(bytes),
+ &cmd_buffer, &cmd_size);
+ if(error) {
+ free(buffer);
+ return; /* error */
+ }
+ if(cmd_size > 0) {
+ static const char *enc = "ENC ";
+ static const char *mic = "MIC ";
+ if(prot_level == PROT_PRIVATE)
+ socket_write(conn, fd, enc, 4);
+ else
+ socket_write(conn, fd, mic, 4);
+
+ socket_write(conn, fd, cmd_buffer, cmd_size);
+ socket_write(conn, fd, "\r\n", 2);
+ infof(conn->data, "Send: %s%s\n", prot_level == PROT_PRIVATE?enc:mic,
+ cmd_buffer);
+ free(cmd_buffer);
+ }
+ }
+ else {
+ htonl_bytes = htonl(bytes);
+ socket_write(conn, fd, &htonl_bytes, sizeof(htonl_bytes));
+ socket_write(conn, fd, buffer, curlx_sitouz(bytes));
+ }
+ free(buffer);
+}
+
+static ssize_t sec_write(struct connectdata *conn, curl_socket_t fd,
+ const char *buffer, size_t length)
+{
+ ssize_t tx = 0, len = conn->buffer_size;
+
+ len -= conn->mech->overhead(conn->app_data, conn->data_prot,
+ curlx_sztosi(len));
+ if(len <= 0)
+ len = length;
+ while(length) {
+ if(length < (size_t)len)
+ len = length;
+
+ do_sec_send(conn, fd, buffer, curlx_sztosi(len));
+ length -= len;
+ buffer += len;
+ tx += len;
+ }
+ return tx;
+}
+
+/* Matches Curl_send signature */
+static ssize_t sec_send(struct connectdata *conn, int sockindex,
+ const void *buffer, size_t len, CURLcode *err)
+{
+ curl_socket_t fd = conn->sock[sockindex];
+ *err = CURLE_OK;
+ return sec_write(conn, fd, buffer, len);
+}
+
+int Curl_sec_read_msg(struct connectdata *conn, char *buffer,
+ enum protection_level level)
+{
+ /* decoded_len should be size_t or ssize_t but conn->mech->decode returns an
+ int */
+ int decoded_len;
+ char *buf;
+ int ret_code = 0;
+ size_t decoded_sz = 0;
+ CURLcode error;
+
+ if(!conn->mech)
+ /* not inititalized, return error */
+ return -1;
+
+ DEBUGASSERT(level > PROT_NONE && level < PROT_LAST);
+
+ error = Curl_base64_decode(buffer + 4, (unsigned char **)&buf, &decoded_sz);
+ if(error || decoded_sz == 0)
+ return -1;
+
+ if(decoded_sz > (size_t)INT_MAX) {
+ free(buf);
+ return -1;
+ }
+ decoded_len = curlx_uztosi(decoded_sz);
+
+ decoded_len = conn->mech->decode(conn->app_data, buf, decoded_len,
+ level, conn);
+ if(decoded_len <= 0) {
+ free(buf);
+ return -1;
+ }
+
+ {
+ buf[decoded_len] = '\n';
+ Curl_debug(conn->data, CURLINFO_HEADER_IN, buf, decoded_len + 1);
+ }
+
+ buf[decoded_len] = '\0';
+ if(decoded_len <= 3)
+ /* suspiciously short */
+ return 0;
+
+ if(buf[3] != '-')
+ /* safe to ignore return code */
+ (void)sscanf(buf, "%d", &ret_code);
+
+ if(buf[decoded_len - 1] == '\n')
+ buf[decoded_len - 1] = '\0';
+ strcpy(buffer, buf);
+ free(buf);
+ return ret_code;
+}
+
+static int sec_set_protection_level(struct connectdata *conn)
+{
+ int code;
+ enum protection_level level = conn->request_data_prot;
+
+ DEBUGASSERT(level > PROT_NONE && level < PROT_LAST);
+
+ if(!conn->sec_complete) {
+ infof(conn->data, "Trying to change the protection level after the"
+ " completion of the data exchange.\n");
+ return -1;
+ }
+
+ /* Bail out if we try to set up the same level */
+ if(conn->data_prot == level)
+ return 0;
+
+ if(level) {
+ char *pbsz;
+ static unsigned int buffer_size = 1 << 20; /* 1048576 */
+
+ code = ftp_send_command(conn, "PBSZ %u", buffer_size);
+ if(code < 0)
+ return -1;
+
+ if(code/100 != 2) {
+ failf(conn->data, "Failed to set the protection's buffer size.");
+ return -1;
+ }
+ conn->buffer_size = buffer_size;
+
+ pbsz = strstr(conn->data->state.buffer, "PBSZ=");
+ if(pbsz) {
+ /* ignore return code, use default value if it fails */
+ (void)sscanf(pbsz, "PBSZ=%u", &buffer_size);
+ if(buffer_size < conn->buffer_size)
+ conn->buffer_size = buffer_size;
+ }
+ }
+
+ /* Now try to negiociate the protection level. */
+ code = ftp_send_command(conn, "PROT %c", level_to_char(level));
+
+ if(code < 0)
+ return -1;
+
+ if(code/100 != 2) {
+ failf(conn->data, "Failed to set the protection level.");
+ return -1;
+ }
+
+ conn->data_prot = level;
+ if(level == PROT_PRIVATE)
+ conn->command_prot = level;
+
+ return 0;
+}
+
+int
+Curl_sec_request_prot(struct connectdata *conn, const char *level)
+{
+ enum protection_level l = name_to_level(level);
+ if(l == PROT_NONE)
+ return -1;
+ DEBUGASSERT(l > PROT_NONE && l < PROT_LAST);
+ conn->request_data_prot = l;
+ return 0;
+}
+
+static CURLcode choose_mech(struct connectdata *conn)
+{
+ int ret;
+ struct Curl_easy *data = conn->data;
+ void *tmp_allocation;
+ const struct Curl_sec_client_mech *mech = &Curl_krb5_client_mech;
+
+ tmp_allocation = realloc(conn->app_data, mech->size);
+ if(tmp_allocation == NULL) {
+ failf(data, "Failed realloc of size %zu", mech->size);
+ mech = NULL;
+ return CURLE_OUT_OF_MEMORY;
+ }
+ conn->app_data = tmp_allocation;
+
+ if(mech->init) {
+ ret = mech->init(conn->app_data);
+ if(ret) {
+ infof(data, "Failed initialization for %s. Skipping it.\n",
+ mech->name);
+ return CURLE_FAILED_INIT;
+ }
+ }
+
+ infof(data, "Trying mechanism %s...\n", mech->name);
+ ret = ftp_send_command(conn, "AUTH %s", mech->name);
+ if(ret < 0)
+ return CURLE_COULDNT_CONNECT;
+
+ if(ret/100 != 3) {
+ switch(ret) {
+ case 504:
+ infof(data, "Mechanism %s is not supported by the server (server "
+ "returned ftp code: 504).\n", mech->name);
+ break;
+ case 534:
+ infof(data, "Mechanism %s was rejected by the server (server returned "
+ "ftp code: 534).\n", mech->name);
+ break;
+ default:
+ if(ret/100 == 5) {
+ infof(data, "server does not support the security extensions\n");
+ return CURLE_USE_SSL_FAILED;
+ }
+ break;
+ }
+ return CURLE_LOGIN_DENIED;
+ }
+
+ /* Authenticate */
+ ret = mech->auth(conn->app_data, conn);
+
+ if(ret != AUTH_CONTINUE) {
+ if(ret != AUTH_OK) {
+ /* Mechanism has dumped the error to stderr, don't error here. */
+ return CURLE_USE_SSL_FAILED;
+ }
+ DEBUGASSERT(ret == AUTH_OK);
+
+ conn->mech = mech;
+ conn->sec_complete = 1;
+ conn->recv[FIRSTSOCKET] = sec_recv;
+ conn->send[FIRSTSOCKET] = sec_send;
+ conn->recv[SECONDARYSOCKET] = sec_recv;
+ conn->send[SECONDARYSOCKET] = sec_send;
+ conn->command_prot = PROT_SAFE;
+ /* Set the requested protection level */
+ /* BLOCKING */
+ (void)sec_set_protection_level(conn);
+ }
+
+ return CURLE_OK;
+}
+
+CURLcode
+Curl_sec_login(struct connectdata *conn)
+{
+ return choose_mech(conn);
+}
+
+
+void
+Curl_sec_end(struct connectdata *conn)
+{
+ if(conn->mech != NULL && conn->mech->end)
+ conn->mech->end(conn->app_data);
+ free(conn->app_data);
+ conn->app_data = NULL;
+ if(conn->in_buffer.data) {
+ free(conn->in_buffer.data);
+ conn->in_buffer.data = NULL;
+ conn->in_buffer.size = 0;
+ conn->in_buffer.index = 0;
+ conn->in_buffer.eof_flag = 0;
+ }
+ conn->sec_complete = 0;
+ conn->data_prot = PROT_CLEAR;
+ conn->mech = NULL;
+}
+
#endif /* HAVE_GSSAPI && !CURL_DISABLE_FTP */
diff --git a/contrib/libs/curl/lib/ldap.c b/contrib/libs/curl/lib/ldap.c
index 332025a745..ab60704225 100644
--- a/contrib/libs/curl/lib/ldap.c
+++ b/contrib/libs/curl/lib/ldap.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -75,7 +75,7 @@
/* Use our own implementation. */
-struct ldap_urldesc {
+struct ldap_urldesc {
char *lud_host;
int lud_port;
#if defined(USE_WIN32_LDAP)
@@ -95,10 +95,10 @@ struct ldap_urldesc {
size_t lud_attrs_dups; /* how many were dup'ed, this field is not in the
"real" struct so can only be used in code
without HAVE_LDAP_URL_PARSE defined */
-};
+};
#undef LDAPURLDesc
-#define LDAPURLDesc struct ldap_urldesc
+#define LDAPURLDesc struct ldap_urldesc
static int _ldap_url_parse(const struct connectdata *conn,
LDAPURLDesc **ludp);
@@ -112,20 +112,20 @@ static void _ldap_free_urldesc(LDAPURLDesc *ludp);
#define LDAP_TRACE(x) do { \
_ldap_trace("%u: ", __LINE__); \
_ldap_trace x; \
- } while(0)
+ } while(0)
static void _ldap_trace(const char *fmt, ...);
#else
#define LDAP_TRACE(x) Curl_nop_stmt
#endif
-#if defined(USE_WIN32_LDAP) && defined(ldap_err2string)
-/* Use ansi error strings in UNICODE builds */
-#undef ldap_err2string
-#define ldap_err2string ldap_err2stringA
-#endif
+#if defined(USE_WIN32_LDAP) && defined(ldap_err2string)
+/* Use ansi error strings in UNICODE builds */
+#undef ldap_err2string
+#define ldap_err2string ldap_err2stringA
+#endif
+
-
static CURLcode Curl_ldap(struct connectdata *conn, bool *done);
/*
@@ -150,7 +150,7 @@ const struct Curl_handler Curl_handler_ldap = {
ZERO_NULL, /* connection_check */
PORT_LDAP, /* defport */
CURLPROTO_LDAP, /* protocol */
- CURLPROTO_LDAP, /* family */
+ CURLPROTO_LDAP, /* family */
PROTOPT_NONE /* flags */
};
@@ -177,7 +177,7 @@ const struct Curl_handler Curl_handler_ldaps = {
ZERO_NULL, /* connection_check */
PORT_LDAPS, /* defport */
CURLPROTO_LDAPS, /* protocol */
- CURLPROTO_LDAP, /* family */
+ CURLPROTO_LDAP, /* family */
PROTOPT_SSL /* flags */
};
#endif
@@ -241,13 +241,13 @@ static int ldap_win_bind(struct connectdata *conn, LDAP *server,
PTCHAR inpass = NULL;
if(user && passwd && (conn->data->set.httpauth & CURLAUTH_BASIC)) {
- inuser = curlx_convert_UTF8_to_tchar((char *) user);
- inpass = curlx_convert_UTF8_to_tchar((char *) passwd);
+ inuser = curlx_convert_UTF8_to_tchar((char *) user);
+ inpass = curlx_convert_UTF8_to_tchar((char *) passwd);
rc = ldap_simple_bind_s(server, inuser, inpass);
- curlx_unicodefree(inuser);
- curlx_unicodefree(inpass);
+ curlx_unicodefree(inuser);
+ curlx_unicodefree(inpass);
}
#if defined(USE_WINDOWS_SSPI)
else {
@@ -259,13 +259,13 @@ static int ldap_win_bind(struct connectdata *conn, LDAP *server,
}
#endif /* #if defined(USE_WIN32_LDAP) */
-#if defined(USE_WIN32_LDAP)
-#define FREE_ON_WINLDAP(x) curlx_unicodefree(x)
-#else
-#define FREE_ON_WINLDAP(x)
-#endif
-
-
+#if defined(USE_WIN32_LDAP)
+#define FREE_ON_WINLDAP(x) curlx_unicodefree(x)
+#else
+#define FREE_ON_WINLDAP(x)
+#endif
+
+
static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
{
CURLcode result = CURLE_OK;
@@ -315,7 +315,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
ldap_ssl ? "encrypted" : "cleartext");
#if defined(USE_WIN32_LDAP)
- host = curlx_convert_UTF8_to_tchar(conn->host.name);
+ host = curlx_convert_UTF8_to_tchar(conn->host.name);
if(!host) {
result = CURLE_OUT_OF_MEMORY;
@@ -513,7 +513,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
#if defined(USE_WIN32_LDAP)
TCHAR *attribute;
#else
- char *attribute;
+ char *attribute;
#endif
int i;
@@ -523,7 +523,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
size_t name_len;
#if defined(USE_WIN32_LDAP)
TCHAR *dn = ldap_get_dn(server, entryIterator);
- name = curlx_convert_tchar_to_UTF8(dn);
+ name = curlx_convert_tchar_to_UTF8(dn);
if(!name) {
ldap_memfree(dn);
@@ -538,7 +538,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"DN: ", 4);
if(result) {
- FREE_ON_WINLDAP(name);
+ FREE_ON_WINLDAP(name);
ldap_memfree(dn);
goto quit;
}
@@ -546,14 +546,14 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *) name,
name_len);
if(result) {
- FREE_ON_WINLDAP(name);
+ FREE_ON_WINLDAP(name);
ldap_memfree(dn);
goto quit;
}
result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 1);
if(result) {
- FREE_ON_WINLDAP(name);
+ FREE_ON_WINLDAP(name);
ldap_memfree(dn);
goto quit;
@@ -561,7 +561,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
dlsize += name_len + 5;
- FREE_ON_WINLDAP(name);
+ FREE_ON_WINLDAP(name);
ldap_memfree(dn);
}
@@ -572,7 +572,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
BerValue **vals;
size_t attr_len;
#if defined(USE_WIN32_LDAP)
- char *attr = curlx_convert_tchar_to_UTF8(attribute);
+ char *attr = curlx_convert_tchar_to_UTF8(attribute);
if(!attr) {
if(ber)
ber_free(ber, 0);
@@ -592,7 +592,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\t", 1);
if(result) {
ldap_value_free_len(vals);
- FREE_ON_WINLDAP(attr);
+ FREE_ON_WINLDAP(attr);
ldap_memfree(attribute);
if(ber)
ber_free(ber, 0);
@@ -604,7 +604,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
(char *) attr, attr_len);
if(result) {
ldap_value_free_len(vals);
- FREE_ON_WINLDAP(attr);
+ FREE_ON_WINLDAP(attr);
ldap_memfree(attribute);
if(ber)
ber_free(ber, 0);
@@ -615,7 +615,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)": ", 2);
if(result) {
ldap_value_free_len(vals);
- FREE_ON_WINLDAP(attr);
+ FREE_ON_WINLDAP(attr);
ldap_memfree(attribute);
if(ber)
ber_free(ber, 0);
@@ -635,7 +635,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
&val_b64_sz);
if(result) {
ldap_value_free_len(vals);
- FREE_ON_WINLDAP(attr);
+ FREE_ON_WINLDAP(attr);
ldap_memfree(attribute);
if(ber)
ber_free(ber, 0);
@@ -649,7 +649,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
free(val_b64);
if(result) {
ldap_value_free_len(vals);
- FREE_ON_WINLDAP(attr);
+ FREE_ON_WINLDAP(attr);
ldap_memfree(attribute);
if(ber)
ber_free(ber, 0);
@@ -665,7 +665,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
vals[i]->bv_len);
if(result) {
ldap_value_free_len(vals);
- FREE_ON_WINLDAP(attr);
+ FREE_ON_WINLDAP(attr);
ldap_memfree(attribute);
if(ber)
ber_free(ber, 0);
@@ -679,7 +679,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 1);
if(result) {
ldap_value_free_len(vals);
- FREE_ON_WINLDAP(attr);
+ FREE_ON_WINLDAP(attr);
ldap_memfree(attribute);
if(ber)
ber_free(ber, 0);
@@ -695,7 +695,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
}
/* Free the attribute as we are done with it */
- FREE_ON_WINLDAP(attr);
+ FREE_ON_WINLDAP(attr);
ldap_memfree(attribute);
result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 1);
@@ -725,7 +725,7 @@ quit:
ldapssl_client_deinit();
#endif /* HAVE_LDAP_SSL && CURL_HAS_NOVELL_LDAPSDK */
- FREE_ON_WINLDAP(host);
+ FREE_ON_WINLDAP(host);
/* no data to transfer */
Curl_setup_transfer(data, -1, -1, FALSE, -1);
@@ -822,10 +822,10 @@ static bool split_str(char *str, char ***out, size_t *count)
static int _ldap_url_parse2(const struct connectdata *conn, LDAPURLDesc *ludp)
{
int rc = LDAP_SUCCESS;
- char *p;
+ char *p;
char *path;
- char *q = NULL;
- char *query = NULL;
+ char *q = NULL;
+ char *query = NULL;
size_t i;
if(!conn->data ||
@@ -843,13 +843,13 @@ static int _ldap_url_parse2(const struct connectdata *conn, LDAPURLDesc *ludp)
if(!path)
return LDAP_NO_MEMORY;
- /* Duplicate the query if present */
- if(conn->data->state.up.query) {
- q = query = strdup(conn->data->state.up.query);
- if(!query) {
- free(path);
- return LDAP_NO_MEMORY;
- }
+ /* Duplicate the query if present */
+ if(conn->data->state.up.query) {
+ q = query = strdup(conn->data->state.up.query);
+ if(!query) {
+ free(path);
+ return LDAP_NO_MEMORY;
+ }
}
/* Parse the DN (Distinguished Name) */
@@ -861,7 +861,7 @@ static int _ldap_url_parse2(const struct connectdata *conn, LDAPURLDesc *ludp)
LDAP_TRACE(("DN '%s'\n", dn));
/* Unescape the DN */
- result = Curl_urldecode(conn->data, dn, 0, &unescaped, NULL, REJECT_ZERO);
+ result = Curl_urldecode(conn->data, dn, 0, &unescaped, NULL, REJECT_ZERO);
if(result) {
rc = LDAP_NO_MEMORY;
@@ -870,10 +870,10 @@ static int _ldap_url_parse2(const struct connectdata *conn, LDAPURLDesc *ludp)
#if defined(USE_WIN32_LDAP)
/* Convert the unescaped string to a tchar */
- ludp->lud_dn = curlx_convert_UTF8_to_tchar(unescaped);
+ ludp->lud_dn = curlx_convert_UTF8_to_tchar(unescaped);
/* Free the unescaped string as we are done with it */
- curlx_unicodefree(unescaped);
+ curlx_unicodefree(unescaped);
if(!ludp->lud_dn) {
rc = LDAP_NO_MEMORY;
@@ -923,11 +923,11 @@ static int _ldap_url_parse2(const struct connectdata *conn, LDAPURLDesc *ludp)
char *unescaped;
CURLcode result;
- LDAP_TRACE(("attr[%zu] '%s'\n", i, attributes[i]));
+ LDAP_TRACE(("attr[%zu] '%s'\n", i, attributes[i]));
/* Unescape the attribute */
result = Curl_urldecode(conn->data, attributes[i], 0, &unescaped, NULL,
- REJECT_ZERO);
+ REJECT_ZERO);
if(result) {
free(attributes);
@@ -938,10 +938,10 @@ static int _ldap_url_parse2(const struct connectdata *conn, LDAPURLDesc *ludp)
#if defined(USE_WIN32_LDAP)
/* Convert the unescaped string to a tchar */
- ludp->lud_attrs[i] = curlx_convert_UTF8_to_tchar(unescaped);
+ ludp->lud_attrs[i] = curlx_convert_UTF8_to_tchar(unescaped);
/* Free the unescaped string as we are done with it */
- curlx_unicodefree(unescaped);
+ curlx_unicodefree(unescaped);
if(!ludp->lud_attrs[i]) {
free(attributes);
@@ -996,8 +996,8 @@ static int _ldap_url_parse2(const struct connectdata *conn, LDAPURLDesc *ludp)
LDAP_TRACE(("filter '%s'\n", filter));
/* Unescape the filter */
- result = Curl_urldecode(conn->data, filter, 0, &unescaped, NULL,
- REJECT_ZERO);
+ result = Curl_urldecode(conn->data, filter, 0, &unescaped, NULL,
+ REJECT_ZERO);
if(result) {
rc = LDAP_NO_MEMORY;
@@ -1006,10 +1006,10 @@ static int _ldap_url_parse2(const struct connectdata *conn, LDAPURLDesc *ludp)
#if defined(USE_WIN32_LDAP)
/* Convert the unescaped string to a tchar */
- ludp->lud_filter = curlx_convert_UTF8_to_tchar(unescaped);
+ ludp->lud_filter = curlx_convert_UTF8_to_tchar(unescaped);
/* Free the unescaped string as we are done with it */
- curlx_unicodefree(unescaped);
+ curlx_unicodefree(unescaped);
if(!ludp->lud_filter) {
rc = LDAP_NO_MEMORY;
diff --git a/contrib/libs/curl/lib/llist.c b/contrib/libs/curl/lib/llist.c
index b2c91918d1..17a7be1667 100644
--- a/contrib/libs/curl/lib/llist.c
+++ b/contrib/libs/curl/lib/llist.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -34,7 +34,7 @@
* @unittest: 1300
*/
void
-Curl_llist_init(struct Curl_llist *l, Curl_llist_dtor dtor)
+Curl_llist_init(struct Curl_llist *l, Curl_llist_dtor dtor)
{
l->size = 0;
l->dtor = dtor;
@@ -54,9 +54,9 @@ Curl_llist_init(struct Curl_llist *l, Curl_llist_dtor dtor)
* @unittest: 1300
*/
void
-Curl_llist_insert_next(struct Curl_llist *list, struct Curl_llist_element *e,
+Curl_llist_insert_next(struct Curl_llist *list, struct Curl_llist_element *e,
const void *p,
- struct Curl_llist_element *ne)
+ struct Curl_llist_element *ne)
{
ne->ptr = (void *) p;
if(list->size == 0) {
@@ -90,7 +90,7 @@ Curl_llist_insert_next(struct Curl_llist *list, struct Curl_llist_element *e,
* @unittest: 1300
*/
void
-Curl_llist_remove(struct Curl_llist *list, struct Curl_llist_element *e,
+Curl_llist_remove(struct Curl_llist *list, struct Curl_llist_element *e,
void *user)
{
void *ptr;
@@ -131,7 +131,7 @@ Curl_llist_remove(struct Curl_llist *list, struct Curl_llist_element *e,
}
void
-Curl_llist_destroy(struct Curl_llist *list, void *user)
+Curl_llist_destroy(struct Curl_llist *list, void *user)
{
if(list) {
while(list->size > 0)
@@ -140,7 +140,7 @@ Curl_llist_destroy(struct Curl_llist *list, void *user)
}
size_t
-Curl_llist_count(struct Curl_llist *list)
+Curl_llist_count(struct Curl_llist *list)
{
return list->size;
}
diff --git a/contrib/libs/curl/lib/llist.h b/contrib/libs/curl/lib/llist.h
index 7d10938a20..ceae2dd1b7 100644
--- a/contrib/libs/curl/lib/llist.h
+++ b/contrib/libs/curl/lib/llist.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -25,26 +25,26 @@
#include "curl_setup.h"
#include <stddef.h>
-typedef void (*Curl_llist_dtor)(void *, void *);
+typedef void (*Curl_llist_dtor)(void *, void *);
-struct Curl_llist_element {
+struct Curl_llist_element {
void *ptr;
- struct Curl_llist_element *prev;
- struct Curl_llist_element *next;
+ struct Curl_llist_element *prev;
+ struct Curl_llist_element *next;
};
-struct Curl_llist {
- struct Curl_llist_element *head;
- struct Curl_llist_element *tail;
- Curl_llist_dtor dtor;
+struct Curl_llist {
+ struct Curl_llist_element *head;
+ struct Curl_llist_element *tail;
+ Curl_llist_dtor dtor;
size_t size;
};
-void Curl_llist_init(struct Curl_llist *, Curl_llist_dtor);
-void Curl_llist_insert_next(struct Curl_llist *, struct Curl_llist_element *,
- const void *, struct Curl_llist_element *node);
-void Curl_llist_remove(struct Curl_llist *, struct Curl_llist_element *,
+void Curl_llist_init(struct Curl_llist *, Curl_llist_dtor);
+void Curl_llist_insert_next(struct Curl_llist *, struct Curl_llist_element *,
+ const void *, struct Curl_llist_element *node);
+void Curl_llist_remove(struct Curl_llist *, struct Curl_llist_element *,
void *);
-size_t Curl_llist_count(struct Curl_llist *);
-void Curl_llist_destroy(struct Curl_llist *, void *);
+size_t Curl_llist_count(struct Curl_llist *);
+void Curl_llist_destroy(struct Curl_llist *, void *);
#endif /* HEADER_CURL_LLIST_H */
diff --git a/contrib/libs/curl/lib/md4.c b/contrib/libs/curl/lib/md4.c
index 05057e2397..d3355ad929 100644
--- a/contrib/libs/curl/lib/md4.c
+++ b/contrib/libs/curl/lib/md4.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -29,20 +29,20 @@
#ifdef USE_OPENSSL
#include <openssl/opensslconf.h>
-#if defined(OPENSSL_VERSION_MAJOR) && (OPENSSL_VERSION_MAJOR >= 3)
-/* OpenSSL 3.0.0 marks the MD4 functions as deprecated */
-#define OPENSSL_NO_MD4
+#if defined(OPENSSL_VERSION_MAJOR) && (OPENSSL_VERSION_MAJOR >= 3)
+/* OpenSSL 3.0.0 marks the MD4 functions as deprecated */
+#define OPENSSL_NO_MD4
#endif
-#endif /* USE_OPENSSL */
-
+#endif /* USE_OPENSSL */
+
#ifdef USE_MBEDTLS
#error #include <mbedtls/config.h>
-#error #include <mbedtls/version.h>
-
-#if(MBEDTLS_VERSION_NUMBER >= 0x02070000)
- #define HAS_MBEDTLS_RESULT_CODE_BASED_FUNCTIONS
+#error #include <mbedtls/version.h>
+
+#if(MBEDTLS_VERSION_NUMBER >= 0x02070000)
+ #define HAS_MBEDTLS_RESULT_CODE_BASED_FUNCTIONS
#endif
-#endif /* USE_MBEDTLS */
+#endif /* USE_MBEDTLS */
#if defined(USE_GNUTLS_NETTLE)
@@ -75,11 +75,11 @@ static void MD4_Final(unsigned char *result, MD4_CTX *ctx)
#include <gcrypt.h>
#include "curl_memory.h"
-
+
/* The last #include file should be: */
#include "memdebug.h"
-typedef gcry_md_hd_t MD4_CTX;
+typedef gcry_md_hd_t MD4_CTX;
static void MD4_Init(MD4_CTX *ctx)
{
@@ -93,43 +93,43 @@ static void MD4_Update(MD4_CTX *ctx, const void *data, unsigned long size)
static void MD4_Final(unsigned char *result, MD4_CTX *ctx)
{
- memcpy(result, gcry_md_read(*ctx, 0), MD4_DIGEST_LENGTH);
- gcry_md_close(*ctx);
+ memcpy(result, gcry_md_read(*ctx, 0), MD4_DIGEST_LENGTH);
+ gcry_md_close(*ctx);
}
#elif defined(USE_OPENSSL) && !defined(OPENSSL_NO_MD4)
/* When OpenSSL is available we use the MD4-functions from OpenSSL */
#include <openssl/md4.h>
-#elif (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && \
- (__MAC_OS_X_VERSION_MAX_ALLOWED >= 1040) && \
- defined(__MAC_OS_X_VERSION_MIN_ALLOWED) && \
- (__MAC_OS_X_VERSION_MIN_ALLOWED < 101500)) || \
- (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && \
- (__IPHONE_OS_VERSION_MAX_ALLOWED >= 20000))
+#elif (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && \
+ (__MAC_OS_X_VERSION_MAX_ALLOWED >= 1040) && \
+ defined(__MAC_OS_X_VERSION_MIN_ALLOWED) && \
+ (__MAC_OS_X_VERSION_MIN_ALLOWED < 101500)) || \
+ (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && \
+ (__IPHONE_OS_VERSION_MAX_ALLOWED >= 20000))
#include <CommonCrypto/CommonDigest.h>
#include "curl_memory.h"
-
+
/* The last #include file should be: */
#include "memdebug.h"
-typedef CC_MD4_CTX MD4_CTX;
+typedef CC_MD4_CTX MD4_CTX;
static void MD4_Init(MD4_CTX *ctx)
{
- (void)CC_MD4_Init(ctx);
+ (void)CC_MD4_Init(ctx);
}
static void MD4_Update(MD4_CTX *ctx, const void *data, unsigned long size)
{
- (void)CC_MD4_Update(ctx, data, (CC_LONG)size);
+ (void)CC_MD4_Update(ctx, data, (CC_LONG)size);
}
static void MD4_Final(unsigned char *result, MD4_CTX *ctx)
{
- (void)CC_MD4_Final(result, ctx);
+ (void)CC_MD4_Final(result, ctx);
}
#elif defined(USE_WIN32_CRYPTO)
@@ -137,15 +137,15 @@ static void MD4_Final(unsigned char *result, MD4_CTX *ctx)
#include <wincrypt.h>
#include "curl_memory.h"
-
-/* The last #include file should be: */
+
+/* The last #include file should be: */
#include "memdebug.h"
-struct md4_ctx {
+struct md4_ctx {
HCRYPTPROV hCryptProv;
HCRYPTHASH hHash;
-};
-typedef struct md4_ctx MD4_CTX;
+};
+typedef struct md4_ctx MD4_CTX;
static void MD4_Init(MD4_CTX *ctx)
{
@@ -153,14 +153,14 @@ static void MD4_Init(MD4_CTX *ctx)
ctx->hHash = 0;
if(CryptAcquireContext(&ctx->hCryptProv, NULL, NULL, PROV_RSA_FULL,
- CRYPT_VERIFYCONTEXT | CRYPT_SILENT)) {
+ CRYPT_VERIFYCONTEXT | CRYPT_SILENT)) {
CryptCreateHash(ctx->hCryptProv, CALG_MD4, 0, 0, &ctx->hHash);
}
}
static void MD4_Update(MD4_CTX *ctx, const void *data, unsigned long size)
{
- CryptHashData(ctx->hHash, (BYTE *)data, (unsigned int) size, 0);
+ CryptHashData(ctx->hHash, (BYTE *)data, (unsigned int) size, 0);
}
static void MD4_Final(unsigned char *result, MD4_CTX *ctx)
@@ -183,15 +183,15 @@ static void MD4_Final(unsigned char *result, MD4_CTX *ctx)
#error #include <mbedtls/md4.h>
#include "curl_memory.h"
-
+
/* The last #include file should be: */
#include "memdebug.h"
-struct md4_ctx {
+struct md4_ctx {
void *data;
unsigned long size;
-};
-typedef struct md4_ctx MD4_CTX;
+};
+typedef struct md4_ctx MD4_CTX;
static void MD4_Init(MD4_CTX *ctx)
{
@@ -213,11 +213,11 @@ static void MD4_Update(MD4_CTX *ctx, const void *data, unsigned long size)
static void MD4_Final(unsigned char *result, MD4_CTX *ctx)
{
if(ctx->data != NULL) {
-#if !defined(HAS_MBEDTLS_RESULT_CODE_BASED_FUNCTIONS)
+#if !defined(HAS_MBEDTLS_RESULT_CODE_BASED_FUNCTIONS)
mbedtls_md4(ctx->data, ctx->size, result);
-#else
- (void) mbedtls_md4_ret(ctx->data, ctx->size, result);
-#endif
+#else
+ (void) mbedtls_md4_ret(ctx->data, ctx->size, result);
+#endif
Curl_safefree(ctx->data);
ctx->size = 0;
@@ -270,13 +270,13 @@ static void MD4_Final(unsigned char *result, MD4_CTX *ctx)
/* Any 32-bit or wider unsigned integer data type will do */
typedef unsigned int MD4_u32plus;
-struct md4_ctx {
+struct md4_ctx {
MD4_u32plus lo, hi;
MD4_u32plus a, b, c, d;
unsigned char buffer[64];
MD4_u32plus block[16];
-};
-typedef struct md4_ctx MD4_CTX;
+};
+typedef struct md4_ctx MD4_CTX;
static void MD4_Init(MD4_CTX *ctx);
static void MD4_Update(MD4_CTX *ctx, const void *data, unsigned long size);
@@ -516,11 +516,11 @@ static void MD4_Final(unsigned char *result, MD4_CTX *ctx)
#endif /* CRYPTO LIBS */
-void Curl_md4it(unsigned char *output, const unsigned char *input,
- const size_t len)
+void Curl_md4it(unsigned char *output, const unsigned char *input,
+ const size_t len)
{
MD4_CTX ctx;
-
+
MD4_Init(&ctx);
MD4_Update(&ctx, input, curlx_uztoui(len));
MD4_Final(output, &ctx);
diff --git a/contrib/libs/curl/lib/md5.c b/contrib/libs/curl/lib/md5.c
index d21287d317..ff0b369f02 100644
--- a/contrib/libs/curl/lib/md5.c
+++ b/contrib/libs/curl/lib/md5.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -30,14 +30,14 @@
#include "curl_hmac.h"
#include "warnless.h"
-#ifdef USE_MBEDTLS
-#error #include <mbedtls/version.h>
-
-#if(MBEDTLS_VERSION_NUMBER >= 0x02070000)
- #define HAS_MBEDTLS_RESULT_CODE_BASED_FUNCTIONS
-#endif
-#endif /* USE_MBEDTLS */
-
+#ifdef USE_MBEDTLS
+#error #include <mbedtls/version.h>
+
+#if(MBEDTLS_VERSION_NUMBER >= 0x02070000)
+ #define HAS_MBEDTLS_RESULT_CODE_BASED_FUNCTIONS
+#endif
+#endif /* USE_MBEDTLS */
+
#if defined(USE_GNUTLS_NETTLE)
#include <nettle/md5.h>
@@ -59,7 +59,7 @@ static void MD5_Update(MD5_CTX *ctx,
md5_update(ctx, inputLen, input);
}
-static void MD5_Final(unsigned char *digest, MD5_CTX *ctx)
+static void MD5_Final(unsigned char *digest, MD5_CTX *ctx)
{
md5_digest(ctx, 16, digest);
}
@@ -85,7 +85,7 @@ static void MD5_Update(MD5_CTX *ctx,
gcry_md_write(*ctx, input, inputLen);
}
-static void MD5_Final(unsigned char *digest, MD5_CTX *ctx)
+static void MD5_Final(unsigned char *digest, MD5_CTX *ctx)
{
memcpy(digest, gcry_md_read(*ctx, 0), 16);
gcry_md_close(*ctx);
@@ -98,50 +98,50 @@ static void MD5_Final(unsigned char *digest, MD5_CTX *ctx)
/* The last #include file should be: */
#include "memdebug.h"
-#elif defined(USE_MBEDTLS)
-
-#error #include <mbedtls/md5.h>
-
-#include "curl_memory.h"
-
-/* The last #include file should be: */
-#include "memdebug.h"
-
-typedef mbedtls_md5_context MD5_CTX;
-
-static void MD5_Init(MD5_CTX *ctx)
-{
-#if !defined(HAS_MBEDTLS_RESULT_CODE_BASED_FUNCTIONS)
- mbedtls_md5_starts(ctx);
-#else
- (void) mbedtls_md5_starts_ret(ctx);
-#endif
-}
-
-static void MD5_Update(MD5_CTX *ctx,
- const unsigned char *data,
- unsigned int length)
-{
-#if !defined(HAS_MBEDTLS_RESULT_CODE_BASED_FUNCTIONS)
- mbedtls_md5_update(ctx, data, length);
-#else
- (void) mbedtls_md5_update_ret(ctx, data, length);
-#endif
-}
-
-static void MD5_Final(unsigned char *digest, MD5_CTX *ctx)
-{
-#if !defined(HAS_MBEDTLS_RESULT_CODE_BASED_FUNCTIONS)
- mbedtls_md5_finish(ctx, digest);
-#else
- (void) mbedtls_md5_finish_ret(ctx, digest);
-#endif
-}
-
+#elif defined(USE_MBEDTLS)
+
+#error #include <mbedtls/md5.h>
+
+#include "curl_memory.h"
+
+/* The last #include file should be: */
+#include "memdebug.h"
+
+typedef mbedtls_md5_context MD5_CTX;
+
+static void MD5_Init(MD5_CTX *ctx)
+{
+#if !defined(HAS_MBEDTLS_RESULT_CODE_BASED_FUNCTIONS)
+ mbedtls_md5_starts(ctx);
+#else
+ (void) mbedtls_md5_starts_ret(ctx);
+#endif
+}
+
+static void MD5_Update(MD5_CTX *ctx,
+ const unsigned char *data,
+ unsigned int length)
+{
+#if !defined(HAS_MBEDTLS_RESULT_CODE_BASED_FUNCTIONS)
+ mbedtls_md5_update(ctx, data, length);
+#else
+ (void) mbedtls_md5_update_ret(ctx, data, length);
+#endif
+}
+
+static void MD5_Final(unsigned char *digest, MD5_CTX *ctx)
+{
+#if !defined(HAS_MBEDTLS_RESULT_CODE_BASED_FUNCTIONS)
+ mbedtls_md5_finish(ctx, digest);
+#else
+ (void) mbedtls_md5_finish_ret(ctx, digest);
+#endif
+}
+
#elif (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && \
- (__MAC_OS_X_VERSION_MAX_ALLOWED >= 1040) && \
- defined(__MAC_OS_X_VERSION_MIN_ALLOWED) && \
- (__MAC_OS_X_VERSION_MIN_ALLOWED < 101500)) || \
+ (__MAC_OS_X_VERSION_MAX_ALLOWED >= 1040) && \
+ defined(__MAC_OS_X_VERSION_MIN_ALLOWED) && \
+ (__MAC_OS_X_VERSION_MIN_ALLOWED < 101500)) || \
(defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && \
(__IPHONE_OS_VERSION_MAX_ALLOWED >= 20000))
@@ -169,28 +169,28 @@ static void MD5_Update(MD5_CTX *ctx,
CC_MD5_Update(ctx, input, inputLen);
}
-static void MD5_Final(unsigned char *digest, MD5_CTX *ctx)
+static void MD5_Final(unsigned char *digest, MD5_CTX *ctx)
{
CC_MD5_Final(digest, ctx);
}
-#elif defined(USE_WIN32_CRYPTO)
+#elif defined(USE_WIN32_CRYPTO)
#include <wincrypt.h>
#include "curl_memory.h"
/* The last #include file should be: */
#include "memdebug.h"
-struct md5_ctx {
+struct md5_ctx {
HCRYPTPROV hCryptProv;
HCRYPTHASH hHash;
-};
-typedef struct md5_ctx MD5_CTX;
+};
+typedef struct md5_ctx MD5_CTX;
static void MD5_Init(MD5_CTX *ctx)
{
- if(CryptAcquireContext(&ctx->hCryptProv, NULL, NULL, PROV_RSA_FULL,
- CRYPT_VERIFYCONTEXT | CRYPT_SILENT)) {
+ if(CryptAcquireContext(&ctx->hCryptProv, NULL, NULL, PROV_RSA_FULL,
+ CRYPT_VERIFYCONTEXT | CRYPT_SILENT)) {
CryptCreateHash(ctx->hCryptProv, CALG_MD5, 0, 0, &ctx->hHash);
}
}
@@ -202,7 +202,7 @@ static void MD5_Update(MD5_CTX *ctx,
CryptHashData(ctx->hHash, (unsigned char *)input, inputLen, 0);
}
-static void MD5_Final(unsigned char *digest, MD5_CTX *ctx)
+static void MD5_Final(unsigned char *digest, MD5_CTX *ctx)
{
unsigned long length = 0;
CryptGetHashParam(ctx->hHash, HP_HASHVAL, NULL, &length, 0);
@@ -215,9 +215,9 @@ static void MD5_Final(unsigned char *digest, MD5_CTX *ctx)
}
#else
-
+
/* When no other crypto library is available we use this code segment */
-
+
/*
* This is an OpenSSL-compatible implementation of the RSA Data Security, Inc.
* MD5 Message-Digest Algorithm (RFC 1321).
@@ -264,13 +264,13 @@ static void MD5_Final(unsigned char *digest, MD5_CTX *ctx)
/* Any 32-bit or wider unsigned integer data type will do */
typedef unsigned int MD5_u32plus;
-struct md5_ctx {
+struct md5_ctx {
MD5_u32plus lo, hi;
MD5_u32plus a, b, c, d;
unsigned char buffer[64];
MD5_u32plus block[16];
-};
-typedef struct md5_ctx MD5_CTX;
+};
+typedef struct md5_ctx MD5_CTX;
static void MD5_Init(MD5_CTX *ctx);
static void MD5_Update(MD5_CTX *ctx, const void *data, unsigned long size);
@@ -532,7 +532,7 @@ static void MD5_Final(unsigned char *result, MD5_CTX *ctx)
#endif /* CRYPTO LIBS */
-const struct HMAC_params Curl_HMAC_MD5[] = {
+const struct HMAC_params Curl_HMAC_MD5[] = {
{
/* Hash initialization function. */
CURLX_FUNCTION_CAST(HMAC_hinit_func, MD5_Init),
@@ -549,7 +549,7 @@ const struct HMAC_params Curl_HMAC_MD5[] = {
}
};
-const struct MD5_params Curl_DIGEST_MD5[] = {
+const struct MD5_params Curl_DIGEST_MD5[] = {
{
/* Digest initialization function */
CURLX_FUNCTION_CAST(Curl_MD5_init_func, MD5_Init),
@@ -567,19 +567,19 @@ const struct MD5_params Curl_DIGEST_MD5[] = {
/*
* @unittest: 1601
*/
-void Curl_md5it(unsigned char *outbuffer, const unsigned char *input,
- const size_t len)
+void Curl_md5it(unsigned char *outbuffer, const unsigned char *input,
+ const size_t len)
{
MD5_CTX ctx;
-
+
MD5_Init(&ctx);
- MD5_Update(&ctx, input, curlx_uztoui(len));
+ MD5_Update(&ctx, input, curlx_uztoui(len));
MD5_Final(outbuffer, &ctx);
}
-struct MD5_context *Curl_MD5_init(const struct MD5_params *md5params)
+struct MD5_context *Curl_MD5_init(const struct MD5_params *md5params)
{
- struct MD5_context *ctxt;
+ struct MD5_context *ctxt;
/* Create MD5 context */
ctxt = malloc(sizeof(*ctxt));
@@ -601,7 +601,7 @@ struct MD5_context *Curl_MD5_init(const struct MD5_params *md5params)
return ctxt;
}
-CURLcode Curl_MD5_update(struct MD5_context *context,
+CURLcode Curl_MD5_update(struct MD5_context *context,
const unsigned char *data,
unsigned int len)
{
@@ -610,7 +610,7 @@ CURLcode Curl_MD5_update(struct MD5_context *context,
return CURLE_OK;
}
-CURLcode Curl_MD5_final(struct MD5_context *context, unsigned char *result)
+CURLcode Curl_MD5_final(struct MD5_context *context, unsigned char *result)
{
(*context->md5_hash->md5_final_func)(result, context->md5_hashctx);
diff --git a/contrib/libs/curl/lib/memdebug.c b/contrib/libs/curl/lib/memdebug.c
index d6879f2265..881ee85c32 100644
--- a/contrib/libs/curl/lib/memdebug.c
+++ b/contrib/libs/curl/lib/memdebug.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -277,7 +277,7 @@ void curl_dbg_free(void *ptr, int line, const char *source)
(Curl_cfree)(mem);
}
- if(source && ptr)
+ if(source && ptr)
curl_dbg_log("MEM %s:%d free(%p)\n", source, line, (void *)ptr);
}
@@ -405,16 +405,16 @@ FILE *curl_dbg_fopen(const char *file, const char *mode,
return res;
}
-FILE *curl_dbg_fdopen(int filedes, const char *mode,
- int line, const char *source)
-{
- FILE *res = fdopen(filedes, mode);
- if(source)
- curl_dbg_log("FILE %s:%d fdopen(\"%d\",\"%s\") = %p\n",
- source, line, filedes, mode, (void *)res);
- return res;
-}
-
+FILE *curl_dbg_fdopen(int filedes, const char *mode,
+ int line, const char *source)
+{
+ FILE *res = fdopen(filedes, mode);
+ if(source)
+ curl_dbg_log("FILE %s:%d fdopen(\"%d\",\"%s\") = %p\n",
+ source, line, filedes, mode, (void *)res);
+ return res;
+}
+
int curl_dbg_fclose(FILE *file, int line, const char *source)
{
int res;
diff --git a/contrib/libs/curl/lib/memdebug.h b/contrib/libs/curl/lib/memdebug.h
index 1ecf9c8290..8e88cea580 100644
--- a/contrib/libs/curl/lib/memdebug.h
+++ b/contrib/libs/curl/lib/memdebug.h
@@ -8,11 +8,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -79,9 +79,9 @@ CURL_EXTERN RECV_TYPE_RETV curl_dbg_recv(RECV_TYPE_ARG1 sockfd,
/* FILE functions */
CURL_EXTERN FILE *curl_dbg_fopen(const char *file, const char *mode, int line,
const char *source);
-CURL_EXTERN FILE *curl_dbg_fdopen(int filedes, const char *mode,
- int line, const char *source);
-
+CURL_EXTERN FILE *curl_dbg_fdopen(int filedes, const char *mode,
+ int line, const char *source);
+
CURL_EXTERN int curl_dbg_fclose(FILE *file, int line, const char *source);
#ifndef MEMDEBUG_NODEFINES
@@ -172,6 +172,6 @@ CURL_EXTERN int curl_dbg_fclose(FILE *file, int line, const char *source);
*/
#define Curl_safefree(ptr) \
- do { free((ptr)); (ptr) = NULL;} while(0)
+ do { free((ptr)); (ptr) = NULL;} while(0)
#endif /* HEADER_CURL_MEMDEBUG_H */
diff --git a/contrib/libs/curl/lib/mime.c b/contrib/libs/curl/lib/mime.c
index 1d0867ef41..2ddd9b8b98 100644
--- a/contrib/libs/curl/lib/mime.c
+++ b/contrib/libs/curl/lib/mime.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -26,7 +26,7 @@
#include "mime.h"
#include "non-ascii.h"
-#include "warnless.h"
+#include "warnless.h"
#include "urldata.h"
#include "sendf.h"
@@ -53,11 +53,11 @@
#define READ_ERROR ((size_t) -1)
-#define STOP_FILLING ((size_t) -2)
+#define STOP_FILLING ((size_t) -2)
+
+static size_t mime_subparts_read(char *buffer, size_t size, size_t nitems,
+ void *instream, bool *hasread);
-static size_t mime_subparts_read(char *buffer, size_t size, size_t nitems,
- void *instream, bool *hasread);
-
/* Encoders. */
static size_t encoder_nop_read(char *buffer, size_t size, bool ateof,
curl_mimepart *part);
@@ -71,7 +71,7 @@ static size_t encoder_qp_read(char *buffer, size_t size, bool ateof,
curl_mimepart *part);
static curl_off_t encoder_qp_size(curl_mimepart *part);
-static const struct mime_encoder encoders[] = {
+static const struct mime_encoder encoders[] = {
{"binary", encoder_nop_read, encoder_nop_size},
{"8bit", encoder_nop_read, encoder_nop_size},
{"7bit", encoder_7bit_read, encoder_nop_size},
@@ -269,8 +269,8 @@ static char *Curl_basename(char *path)
/* Set readback state. */
-static void mimesetstate(struct mime_state *state,
- enum mimestate tok, void *ptr)
+static void mimesetstate(struct mime_state *state,
+ enum mimestate tok, void *ptr)
{
state->state = tok;
state->ptr = ptr;
@@ -343,7 +343,7 @@ static char *strippath(const char *fullfile)
}
/* Initialize data encoder state. */
-static void cleanup_encoder_state(struct mime_encoder_state *p)
+static void cleanup_encoder_state(struct mime_encoder_state *p)
{
p->pos = 0;
p->bufbeg = 0;
@@ -353,22 +353,22 @@ static void cleanup_encoder_state(struct mime_encoder_state *p)
/* Dummy encoder. This is used for 8bit and binary content encodings. */
static size_t encoder_nop_read(char *buffer, size_t size, bool ateof,
- struct curl_mimepart *part)
+ struct curl_mimepart *part)
{
- struct mime_encoder_state *st = &part->encstate;
+ struct mime_encoder_state *st = &part->encstate;
size_t insize = st->bufend - st->bufbeg;
(void) ateof;
- if(!size)
- return STOP_FILLING;
-
+ if(!size)
+ return STOP_FILLING;
+
if(size > insize)
size = insize;
-
+
if(size)
- memcpy(buffer, st->buf + st->bufbeg, size);
-
+ memcpy(buffer, st->buf + st->bufbeg, size);
+
st->bufbeg += size;
return size;
}
@@ -383,14 +383,14 @@ static curl_off_t encoder_nop_size(curl_mimepart *part)
static size_t encoder_7bit_read(char *buffer, size_t size, bool ateof,
curl_mimepart *part)
{
- struct mime_encoder_state *st = &part->encstate;
+ struct mime_encoder_state *st = &part->encstate;
size_t cursize = st->bufend - st->bufbeg;
(void) ateof;
- if(!size)
- return STOP_FILLING;
-
+ if(!size)
+ return STOP_FILLING;
+
if(size > cursize)
size = cursize;
@@ -409,7 +409,7 @@ static size_t encoder_7bit_read(char *buffer, size_t size, bool ateof,
static size_t encoder_base64_read(char *buffer, size_t size, bool ateof,
curl_mimepart *part)
{
- struct mime_encoder_state *st = &part->encstate;
+ struct mime_encoder_state *st = &part->encstate;
size_t cursize = 0;
int i;
char *ptr = buffer;
@@ -418,11 +418,11 @@ static size_t encoder_base64_read(char *buffer, size_t size, bool ateof,
/* Line full ? */
if(st->pos > MAX_ENCODED_LINE_LENGTH - 4) {
/* Yes, we need 2 characters for CRLF. */
- if(size < 2) {
- if(!cursize)
- return STOP_FILLING;
+ if(size < 2) {
+ if(!cursize)
+ return STOP_FILLING;
break;
- }
+ }
*ptr++ = '\r';
*ptr++ = '\n';
st->pos = 0;
@@ -431,13 +431,13 @@ static size_t encoder_base64_read(char *buffer, size_t size, bool ateof,
}
/* Be sure there is enough space and input data for a base64 group. */
- if(size < 4) {
- if(!cursize)
- return STOP_FILLING;
+ if(size < 4) {
+ if(!cursize)
+ return STOP_FILLING;
+ break;
+ }
+ if(st->bufend - st->bufbeg < 3)
break;
- }
- if(st->bufend - st->bufbeg < 3)
- break;
/* Encode three bytes as four characters. */
i = st->buf[st->bufbeg++] & 0xFF;
@@ -453,30 +453,30 @@ static size_t encoder_base64_read(char *buffer, size_t size, bool ateof,
}
/* If at eof, we have to flush the buffered data. */
- if(ateof) {
- if(size < 4) {
- if(!cursize)
- return STOP_FILLING;
- }
- else {
- /* Buffered data size can only be 0, 1 or 2. */
- ptr[2] = ptr[3] = '=';
- i = 0;
- switch(st->bufend - st->bufbeg) {
- case 2:
- i = (st->buf[st->bufbeg + 1] & 0xFF) << 8;
- /* FALLTHROUGH */
- case 1:
- i |= (st->buf[st->bufbeg] & 0xFF) << 16;
- ptr[0] = base64[(i >> 18) & 0x3F];
- ptr[1] = base64[(i >> 12) & 0x3F];
- if(++st->bufbeg != st->bufend) {
- ptr[2] = base64[(i >> 6) & 0x3F];
- st->bufbeg++;
- }
- cursize += 4;
- st->pos += 4;
- break;
+ if(ateof) {
+ if(size < 4) {
+ if(!cursize)
+ return STOP_FILLING;
+ }
+ else {
+ /* Buffered data size can only be 0, 1 or 2. */
+ ptr[2] = ptr[3] = '=';
+ i = 0;
+ switch(st->bufend - st->bufbeg) {
+ case 2:
+ i = (st->buf[st->bufbeg + 1] & 0xFF) << 8;
+ /* FALLTHROUGH */
+ case 1:
+ i |= (st->buf[st->bufbeg] & 0xFF) << 16;
+ ptr[0] = base64[(i >> 18) & 0x3F];
+ ptr[1] = base64[(i >> 12) & 0x3F];
+ if(++st->bufbeg != st->bufend) {
+ ptr[2] = base64[(i >> 6) & 0x3F];
+ st->bufbeg++;
+ }
+ cursize += 4;
+ st->pos += 4;
+ break;
}
}
}
@@ -513,7 +513,7 @@ static curl_off_t encoder_base64_size(curl_mimepart *part)
* Check if a CRLF or end of data is in input buffer at current position + n.
* Return -1 if more data needed, 1 if CRLF or end of data, else 0.
*/
-static int qp_lookahead_eol(struct mime_encoder_state *st, int ateof, size_t n)
+static int qp_lookahead_eol(struct mime_encoder_state *st, int ateof, size_t n)
{
n += st->bufbeg;
if(n >= st->bufend && ateof)
@@ -530,7 +530,7 @@ static int qp_lookahead_eol(struct mime_encoder_state *st, int ateof, size_t n)
static size_t encoder_qp_read(char *buffer, size_t size, bool ateof,
curl_mimepart *part)
{
- struct mime_encoder_state *st = &part->encstate;
+ struct mime_encoder_state *st = &part->encstate;
char *ptr = buffer;
size_t cursize = 0;
int softlinebreak;
@@ -608,11 +608,11 @@ static size_t encoder_qp_read(char *buffer, size_t size, bool ateof,
}
/* If the output buffer would overflow, do not store. */
- if(len > size) {
- if(!cursize)
- return STOP_FILLING;
+ if(len > size) {
+ if(!cursize)
+ return STOP_FILLING;
break;
- }
+ }
/* Append to output buffer. */
memcpy(ptr, buf, len);
@@ -642,17 +642,17 @@ static size_t mime_mem_read(char *buffer, size_t size, size_t nitems,
void *instream)
{
curl_mimepart *part = (curl_mimepart *) instream;
- size_t sz = curlx_sotouz(part->datasize - part->state.offset);
+ size_t sz = curlx_sotouz(part->datasize - part->state.offset);
(void) size; /* Always 1.*/
- if(!nitems)
- return STOP_FILLING;
-
+ if(!nitems)
+ return STOP_FILLING;
+
if(sz > nitems)
sz = nitems;
if(sz)
- memcpy(buffer, part->data + curlx_sotouz(part->state.offset), sz);
+ memcpy(buffer, part->data + curlx_sotouz(part->state.offset), sz);
return sz;
}
@@ -673,7 +673,7 @@ static int mime_mem_seek(void *instream, curl_off_t offset, int whence)
if(offset < 0 || offset > part->datasize)
return CURL_SEEKFUNC_FAIL;
- part->state.offset = offset;
+ part->state.offset = offset;
return CURL_SEEKFUNC_OK;
}
@@ -685,7 +685,7 @@ static void mime_mem_free(void *ptr)
/* Named file callbacks. */
/* Argument is a pointer to the mime part. */
-static int mime_open_file(curl_mimepart *part)
+static int mime_open_file(curl_mimepart *part)
{
/* Open a MIMEKIND_FILE part. */
@@ -700,9 +700,9 @@ static size_t mime_file_read(char *buffer, size_t size, size_t nitems,
{
curl_mimepart *part = (curl_mimepart *) instream;
- if(!nitems)
- return STOP_FILLING;
-
+ if(!nitems)
+ return STOP_FILLING;
+
if(mime_open_file(part))
return READ_ERROR;
@@ -740,22 +740,22 @@ static void mime_file_free(void *ptr)
/* Argument is a pointer to the mime structure. */
/* Readback a byte string segment. */
-static size_t readback_bytes(struct mime_state *state,
+static size_t readback_bytes(struct mime_state *state,
char *buffer, size_t bufsize,
const char *bytes, size_t numbytes,
const char *trail)
{
size_t sz;
- size_t offset = curlx_sotouz(state->offset);
+ size_t offset = curlx_sotouz(state->offset);
- if(numbytes > offset) {
- sz = numbytes - offset;
- bytes += offset;
+ if(numbytes > offset) {
+ sz = numbytes - offset;
+ bytes += offset;
}
else {
size_t tsz = strlen(trail);
- sz = offset - numbytes;
+ sz = offset - numbytes;
if(sz >= tsz)
return 0;
bytes = trail + sz;
@@ -772,79 +772,79 @@ static size_t readback_bytes(struct mime_state *state,
/* Read a non-encoded part content. */
static size_t read_part_content(curl_mimepart *part,
- char *buffer, size_t bufsize, bool *hasread)
+ char *buffer, size_t bufsize, bool *hasread)
{
size_t sz = 0;
- switch(part->lastreadstatus) {
- case 0:
- case CURL_READFUNC_ABORT:
- case CURL_READFUNC_PAUSE:
- case READ_ERROR:
- return part->lastreadstatus;
- default:
- break;
- }
-
- /* If we can determine we are at end of part data, spare a read. */
- if(part->datasize != (curl_off_t) -1 &&
- part->state.offset >= part->datasize) {
- /* sz is already zero. */
- }
- else {
- switch(part->kind) {
- case MIMEKIND_MULTIPART:
- /*
- * Cannot be processed as other kinds since read function requires
- * an additional parameter and is highly recursive.
- */
- sz = mime_subparts_read(buffer, 1, bufsize, part->arg, hasread);
- break;
- case MIMEKIND_FILE:
- if(part->fp && feof(part->fp))
- break; /* At EOF. */
- /* FALLTHROUGH */
- default:
- if(part->readfunc) {
- if(!(part->flags & MIME_FAST_READ)) {
- if(*hasread)
- return STOP_FILLING;
- *hasread = TRUE;
- }
- sz = part->readfunc(buffer, 1, bufsize, part->arg);
- }
- break;
- }
- }
-
- switch(sz) {
- case STOP_FILLING:
- break;
- case 0:
- case CURL_READFUNC_ABORT:
- case CURL_READFUNC_PAUSE:
- case READ_ERROR:
- part->lastreadstatus = sz;
- break;
- default:
- part->state.offset += sz;
- part->lastreadstatus = sz;
- break;
- }
-
+ switch(part->lastreadstatus) {
+ case 0:
+ case CURL_READFUNC_ABORT:
+ case CURL_READFUNC_PAUSE:
+ case READ_ERROR:
+ return part->lastreadstatus;
+ default:
+ break;
+ }
+
+ /* If we can determine we are at end of part data, spare a read. */
+ if(part->datasize != (curl_off_t) -1 &&
+ part->state.offset >= part->datasize) {
+ /* sz is already zero. */
+ }
+ else {
+ switch(part->kind) {
+ case MIMEKIND_MULTIPART:
+ /*
+ * Cannot be processed as other kinds since read function requires
+ * an additional parameter and is highly recursive.
+ */
+ sz = mime_subparts_read(buffer, 1, bufsize, part->arg, hasread);
+ break;
+ case MIMEKIND_FILE:
+ if(part->fp && feof(part->fp))
+ break; /* At EOF. */
+ /* FALLTHROUGH */
+ default:
+ if(part->readfunc) {
+ if(!(part->flags & MIME_FAST_READ)) {
+ if(*hasread)
+ return STOP_FILLING;
+ *hasread = TRUE;
+ }
+ sz = part->readfunc(buffer, 1, bufsize, part->arg);
+ }
+ break;
+ }
+ }
+
+ switch(sz) {
+ case STOP_FILLING:
+ break;
+ case 0:
+ case CURL_READFUNC_ABORT:
+ case CURL_READFUNC_PAUSE:
+ case READ_ERROR:
+ part->lastreadstatus = sz;
+ break;
+ default:
+ part->state.offset += sz;
+ part->lastreadstatus = sz;
+ break;
+ }
+
return sz;
}
/* Read and encode part content. */
-static size_t read_encoded_part_content(curl_mimepart *part, char *buffer,
- size_t bufsize, bool *hasread)
+static size_t read_encoded_part_content(curl_mimepart *part, char *buffer,
+ size_t bufsize, bool *hasread)
{
- struct mime_encoder_state *st = &part->encstate;
+ struct mime_encoder_state *st = &part->encstate;
size_t cursize = 0;
size_t sz;
bool ateof = FALSE;
- for(;;) {
+ for(;;) {
if(st->bufbeg < st->bufend || ateof) {
/* Encode buffered data. */
sz = part->encoder->encodefunc(buffer, bufsize, ateof, part);
@@ -854,7 +854,7 @@ static size_t read_encoded_part_content(curl_mimepart *part, char *buffer,
return cursize;
break;
case READ_ERROR:
- case STOP_FILLING:
+ case STOP_FILLING:
return cursize? cursize: sz;
default:
cursize += sz;
@@ -876,7 +876,7 @@ static size_t read_encoded_part_content(curl_mimepart *part, char *buffer,
if(st->bufend >= sizeof(st->buf))
return cursize? cursize: READ_ERROR; /* Buffer full. */
sz = read_part_content(part, st->buf + st->bufend,
- sizeof(st->buf) - st->bufend, hasread);
+ sizeof(st->buf) - st->bufend, hasread);
switch(sz) {
case 0:
ateof = TRUE;
@@ -884,7 +884,7 @@ static size_t read_encoded_part_content(curl_mimepart *part, char *buffer,
case CURL_READFUNC_ABORT:
case CURL_READFUNC_PAUSE:
case READ_ERROR:
- case STOP_FILLING:
+ case STOP_FILLING:
return cursize? cursize: sz;
default:
st->bufend += sz;
@@ -892,12 +892,12 @@ static size_t read_encoded_part_content(curl_mimepart *part, char *buffer,
}
}
- /* NOTREACHED */
+ /* NOTREACHED */
}
/* Readback a mime part. */
static size_t readback_part(curl_mimepart *part,
- char *buffer, size_t bufsize, bool *hasread)
+ char *buffer, size_t bufsize, bool *hasread)
{
size_t cursize = 0;
#ifdef CURL_DOES_CONVERSIONS
@@ -956,9 +956,9 @@ static size_t readback_part(curl_mimepart *part,
break;
case MIMESTATE_CONTENT:
if(part->encoder)
- sz = read_encoded_part_content(part, buffer, bufsize, hasread);
+ sz = read_encoded_part_content(part, buffer, bufsize, hasread);
else
- sz = read_part_content(part, buffer, bufsize, hasread);
+ sz = read_part_content(part, buffer, bufsize, hasread);
switch(sz) {
case 0:
mimesetstate(&part->state, MIMESTATE_END, NULL);
@@ -971,7 +971,7 @@ static size_t readback_part(curl_mimepart *part,
case CURL_READFUNC_ABORT:
case CURL_READFUNC_PAUSE:
case READ_ERROR:
- case STOP_FILLING:
+ case STOP_FILLING:
return cursize? cursize: sz;
}
break;
@@ -1000,9 +1000,9 @@ static size_t readback_part(curl_mimepart *part,
return cursize;
}
-/* Readback from mime. Warning: not a read callback function. */
+/* Readback from mime. Warning: not a read callback function. */
static size_t mime_subparts_read(char *buffer, size_t size, size_t nitems,
- void *instream, bool *hasread)
+ void *instream, bool *hasread)
{
curl_mime *mime = (curl_mime *) instream;
size_t cursize = 0;
@@ -1023,7 +1023,7 @@ static size_t mime_subparts_read(char *buffer, size_t size, size_t nitems,
#endif
mimesetstate(&mime->state, MIMESTATE_BOUNDARY1, mime->firstpart);
/* The first boundary always follows the header termination empty line,
- so is always preceded by a CRLF. We can then spare 2 characters
+ so is always preceded by a CRLF. We can then spare 2 characters
by skipping the leading CRLF in boundary. */
mime->state.offset += 2;
break;
@@ -1053,12 +1053,12 @@ static size_t mime_subparts_read(char *buffer, size_t size, size_t nitems,
mimesetstate(&mime->state, MIMESTATE_END, NULL);
break;
}
- sz = readback_part(part, buffer, nitems, hasread);
+ sz = readback_part(part, buffer, nitems, hasread);
switch(sz) {
case CURL_READFUNC_ABORT:
case CURL_READFUNC_PAUSE:
case READ_ERROR:
- case STOP_FILLING:
+ case STOP_FILLING:
return cursize? cursize: sz;
case 0:
#ifdef CURL_DOES_CONVERSIONS
@@ -1123,7 +1123,7 @@ static int mime_part_rewind(curl_mimepart *part)
if(res == CURL_SEEKFUNC_OK)
mimesetstate(&part->state, targetstate, NULL);
- part->lastreadstatus = 1; /* Successful read status. */
+ part->lastreadstatus = 1; /* Successful read status. */
return res;
}
@@ -1166,8 +1166,8 @@ static void cleanup_part_content(curl_mimepart *part)
part->datasize = (curl_off_t) 0; /* No size yet. */
cleanup_encoder_state(&part->encstate);
part->kind = MIMEKIND_NONE;
- part->flags &= ~MIME_FAST_READ;
- part->lastreadstatus = 1; /* Successful read status. */
+ part->flags &= ~MIME_FAST_READ;
+ part->lastreadstatus = 1; /* Successful read status. */
}
static void mime_subparts_free(void *ptr)
@@ -1230,8 +1230,8 @@ CURLcode Curl_mime_duppart(curl_mimepart *dst, const curl_mimepart *src)
const curl_mimepart *s;
CURLcode res = CURLE_OK;
- DEBUGASSERT(dst);
-
+ DEBUGASSERT(dst);
+
/* Duplicate content. */
switch(src->kind) {
case MIMEKIND_NONE:
@@ -1281,18 +1281,18 @@ CURLcode Curl_mime_duppart(curl_mimepart *dst, const curl_mimepart *src)
}
}
- if(!res) {
- /* Duplicate other fields. */
+ if(!res) {
+ /* Duplicate other fields. */
dst->encoder = src->encoder;
res = curl_mime_type(dst, src->mimetype);
- }
+ }
if(!res)
res = curl_mime_name(dst, src->name);
if(!res)
res = curl_mime_filename(dst, src->filename);
/* If an error occurred, rollback. */
- if(res)
+ if(res)
Curl_mime_cleanpart(dst);
return res;
@@ -1333,7 +1333,7 @@ void Curl_mime_initpart(curl_mimepart *part, struct Curl_easy *easy)
{
memset((char *) part, 0, sizeof(*part));
part->easy = easy;
- part->lastreadstatus = 1; /* Successful read status. */
+ part->lastreadstatus = 1; /* Successful read status. */
mimesetstate(&part->state, MIMESTATE_BEGIN, NULL);
}
@@ -1419,12 +1419,12 @@ CURLcode curl_mime_data(curl_mimepart *part,
if(datasize)
memcpy(part->data, data, datasize);
- part->data[datasize] = '\0'; /* Set a null terminator as sentinel. */
+ part->data[datasize] = '\0'; /* Set a null terminator as sentinel. */
part->readfunc = mime_mem_read;
part->seekfunc = mime_mem_seek;
part->freefunc = mime_mem_free;
- part->flags |= MIME_FAST_READ;
+ part->flags |= MIME_FAST_READ;
part->kind = MIMEKIND_DATA;
}
@@ -1502,7 +1502,7 @@ CURLcode curl_mime_type(curl_mimepart *part, const char *mimetype)
CURLcode curl_mime_encoder(curl_mimepart *part, const char *encoding)
{
CURLcode result = CURLE_BAD_FUNCTION_ARGUMENT;
- const struct mime_encoder *mep;
+ const struct mime_encoder *mep;
if(!part)
return result;
@@ -1599,7 +1599,7 @@ CURLcode Curl_mime_set_subparts(curl_mimepart *part,
}
subparts->parent = part;
- /* Subparts are processed internally: no read callback. */
+ /* Subparts are processed internally: no read callback. */
part->seekfunc = mime_subparts_seek;
part->freefunc = take_ownership? mime_subparts_free: mime_subparts_unbind;
part->arg = subparts;
@@ -1621,23 +1621,23 @@ CURLcode curl_mime_subparts(curl_mimepart *part, curl_mime *subparts)
size_t Curl_mime_read(char *buffer, size_t size, size_t nitems, void *instream)
{
curl_mimepart *part = (curl_mimepart *) instream;
- size_t ret;
- bool hasread;
+ size_t ret;
+ bool hasread;
(void) size; /* Always 1. */
-
- do {
- hasread = FALSE;
- ret = readback_part(part, buffer, nitems, &hasread);
- /*
- * If this is not possible to get some data without calling more than
- * one read callback (probably because a content encoder is not able to
- * deliver a new bunch for the few data accumulated so far), force another
- * read until we get enough data or a special exit code.
- */
- } while(ret == STOP_FILLING);
-
- return ret;
+
+ do {
+ hasread = FALSE;
+ ret = readback_part(part, buffer, nitems, &hasread);
+ /*
+ * If this is not possible to get some data without calling more than
+ * one read callback (probably because a content encoder is not able to
+ * deliver a new bunch for the few data accumulated so far), force another
+ * read until we get enough data or a special exit code.
+ */
+ } while(ret == STOP_FILLING);
+
+ return ret;
}
/* Rewind mime stream. */
@@ -1778,23 +1778,23 @@ const char *Curl_mime_contenttype(const char *filename)
return NULL;
}
-static bool content_type_match(const char *contenttype, const char *target)
-{
- size_t len = strlen(target);
-
- if(contenttype && strncasecompare(contenttype, target, len))
- switch(contenttype[len]) {
- case '\0':
- case '\t':
- case '\r':
- case '\n':
- case ' ':
- case ';':
- return TRUE;
- }
- return FALSE;
-}
-
+static bool content_type_match(const char *contenttype, const char *target)
+{
+ size_t len = strlen(target);
+
+ if(contenttype && strncasecompare(contenttype, target, len))
+ switch(contenttype[len]) {
+ case '\0':
+ case '\t':
+ case '\r':
+ case '\n':
+ case ' ':
+ case ';':
+ return TRUE;
+ }
+ return FALSE;
+}
+
CURLcode Curl_mime_prepare_headers(curl_mimepart *part,
const char *contenttype,
const char *disposition,
@@ -1846,7 +1846,7 @@ CURLcode Curl_mime_prepare_headers(curl_mimepart *part,
boundary = mime->boundary;
}
else if(contenttype && !customct &&
- content_type_match(contenttype, "text/plain"))
+ content_type_match(contenttype, "text/plain"))
if(strategy == MIMESTRATEGY_MAIL || !part->filename)
contenttype = NULL;
@@ -1922,7 +1922,7 @@ CURLcode Curl_mime_prepare_headers(curl_mimepart *part,
curl_mimepart *subpart;
disposition = NULL;
- if(content_type_match(contenttype, "multipart/form-data"))
+ if(content_type_match(contenttype, "multipart/form-data"))
disposition = "form-data";
for(subpart = mime->firstpart; subpart; subpart = subpart->nextpart) {
ret = Curl_mime_prepare_headers(subpart, NULL, disposition, strategy);
@@ -1933,26 +1933,26 @@ CURLcode Curl_mime_prepare_headers(curl_mimepart *part,
return ret;
}
-/* Recursively reset paused status in the given part. */
-void Curl_mime_unpause(curl_mimepart *part)
-{
- if(part) {
- if(part->lastreadstatus == CURL_READFUNC_PAUSE)
- part->lastreadstatus = 1; /* Successful read status. */
- if(part->kind == MIMEKIND_MULTIPART) {
- curl_mime *mime = (curl_mime *) part->arg;
-
- if(mime) {
- curl_mimepart *subpart;
-
- for(subpart = mime->firstpart; subpart; subpart = subpart->nextpart)
- Curl_mime_unpause(subpart);
- }
- }
- }
-}
-
-
+/* Recursively reset paused status in the given part. */
+void Curl_mime_unpause(curl_mimepart *part)
+{
+ if(part) {
+ if(part->lastreadstatus == CURL_READFUNC_PAUSE)
+ part->lastreadstatus = 1; /* Successful read status. */
+ if(part->kind == MIMEKIND_MULTIPART) {
+ curl_mime *mime = (curl_mime *) part->arg;
+
+ if(mime) {
+ curl_mimepart *subpart;
+
+ for(subpart = mime->firstpart; subpart; subpart = subpart->nextpart)
+ Curl_mime_unpause(subpart);
+ }
+ }
+ }
+}
+
+
#else /* !CURL_DISABLE_HTTP || !CURL_DISABLE_SMTP || !CURL_DISABLE_IMAP */
/* Mime not compiled in: define stubs for externally-referenced functions. */
@@ -2049,11 +2049,11 @@ CURLcode curl_mime_headers(curl_mimepart *part,
return CURLE_NOT_BUILT_IN;
}
-CURLcode Curl_mime_add_header(struct curl_slist **slp, const char *fmt, ...)
-{
- (void)slp;
- (void)fmt;
- return CURLE_NOT_BUILT_IN;
-}
-
+CURLcode Curl_mime_add_header(struct curl_slist **slp, const char *fmt, ...)
+{
+ (void)slp;
+ (void)fmt;
+ return CURLE_NOT_BUILT_IN;
+}
+
#endif /* if disabled */
diff --git a/contrib/libs/curl/lib/mime.h b/contrib/libs/curl/lib/mime.h
index f89a268ab5..ab89d52517 100644
--- a/contrib/libs/curl/lib/mime.h
+++ b/contrib/libs/curl/lib/mime.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -31,7 +31,7 @@
/* Part flags. */
#define MIME_USERHEADERS_OWNER (1 << 0)
#define MIME_BODY_ONLY (1 << 1)
-#define MIME_FAST_READ (1 << 2)
+#define MIME_FAST_READ (1 << 2)
#define FILE_CONTENTTYPE_DEFAULT "application/octet-stream"
#define MULTIPART_CONTENTTYPE_DEFAULT "multipart/mixed"
@@ -69,43 +69,43 @@ enum mimestrategy {
};
/* Content transfer encoder. */
-struct mime_encoder {
+struct mime_encoder {
const char * name; /* Encoding name. */
size_t (*encodefunc)(char *buffer, size_t size, bool ateof,
curl_mimepart *part); /* Encoded read. */
curl_off_t (*sizefunc)(curl_mimepart *part); /* Encoded size. */
-};
+};
/* Content transfer encoder state. */
-struct mime_encoder_state {
+struct mime_encoder_state {
size_t pos; /* Position on output line. */
size_t bufbeg; /* Next data index in input buffer. */
size_t bufend; /* First unused byte index in input buffer. */
char buf[ENCODING_BUFFER_SIZE]; /* Input buffer. */
-};
+};
/* Mime readback state. */
-struct mime_state {
+struct mime_state {
enum mimestate state; /* Current state token. */
void *ptr; /* State-dependent pointer. */
- curl_off_t offset; /* State-dependent offset. */
-};
+ curl_off_t offset; /* State-dependent offset. */
+};
/* minimum buffer size for the boundary string */
#define MIME_BOUNDARY_LEN (24 + MIME_RAND_BOUNDARY_CHARS + 1)
/* A mime multipart. */
-struct curl_mime {
+struct curl_mime {
struct Curl_easy *easy; /* The associated easy handle. */
curl_mimepart *parent; /* Parent part. */
curl_mimepart *firstpart; /* First part. */
curl_mimepart *lastpart; /* Last part. */
char boundary[MIME_BOUNDARY_LEN]; /* The part boundary. */
- struct mime_state state; /* Current readback state. */
+ struct mime_state state; /* Current readback state. */
};
/* A mime part. */
-struct curl_mimepart {
+struct curl_mimepart {
struct Curl_easy *easy; /* The associated easy handle. */
curl_mime *parent; /* Parent mime structure. */
curl_mimepart *nextpart; /* Forward linked list. */
@@ -123,35 +123,35 @@ struct curl_mimepart {
char *name; /* Data name. */
curl_off_t datasize; /* Expected data size. */
unsigned int flags; /* Flags. */
- struct mime_state state; /* Current readback state. */
- const struct mime_encoder *encoder; /* Content data encoder. */
- struct mime_encoder_state encstate; /* Data encoder state. */
- size_t lastreadstatus; /* Last read callback returned status. */
+ struct mime_state state; /* Current readback state. */
+ const struct mime_encoder *encoder; /* Content data encoder. */
+ struct mime_encoder_state encstate; /* Data encoder state. */
+ size_t lastreadstatus; /* Last read callback returned status. */
};
-CURLcode Curl_mime_add_header(struct curl_slist **slp, const char *fmt, ...);
-
-#if (!defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_MIME)) || \
+CURLcode Curl_mime_add_header(struct curl_slist **slp, const char *fmt, ...);
+
+#if (!defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_MIME)) || \
!defined(CURL_DISABLE_SMTP) || !defined(CURL_DISABLE_IMAP)
/* Prototypes. */
-void Curl_mime_initpart(struct curl_mimepart *part, struct Curl_easy *easy);
-void Curl_mime_cleanpart(struct curl_mimepart *part);
-CURLcode Curl_mime_duppart(struct curl_mimepart *dst,
- const curl_mimepart *src);
-CURLcode Curl_mime_set_subparts(struct curl_mimepart *part,
- struct curl_mime *subparts,
- int take_ownership);
-CURLcode Curl_mime_prepare_headers(struct curl_mimepart *part,
+void Curl_mime_initpart(struct curl_mimepart *part, struct Curl_easy *easy);
+void Curl_mime_cleanpart(struct curl_mimepart *part);
+CURLcode Curl_mime_duppart(struct curl_mimepart *dst,
+ const curl_mimepart *src);
+CURLcode Curl_mime_set_subparts(struct curl_mimepart *part,
+ struct curl_mime *subparts,
+ int take_ownership);
+CURLcode Curl_mime_prepare_headers(struct curl_mimepart *part,
const char *contenttype,
const char *disposition,
enum mimestrategy strategy);
-curl_off_t Curl_mime_size(struct curl_mimepart *part);
+curl_off_t Curl_mime_size(struct curl_mimepart *part);
size_t Curl_mime_read(char *buffer, size_t size, size_t nitems,
void *instream);
-CURLcode Curl_mime_rewind(struct curl_mimepart *part);
+CURLcode Curl_mime_rewind(struct curl_mimepart *part);
const char *Curl_mime_contenttype(const char *filename);
-void Curl_mime_unpause(struct curl_mimepart *part);
+void Curl_mime_unpause(struct curl_mimepart *part);
#else
/* if disabled */
@@ -163,7 +163,7 @@ void Curl_mime_unpause(struct curl_mimepart *part);
#define Curl_mime_size(x) (curl_off_t) -1
#define Curl_mime_read NULL
#define Curl_mime_rewind(x) ((void)x, CURLE_NOT_BUILT_IN)
-#define Curl_mime_unpause(x)
+#define Curl_mime_unpause(x)
#endif
diff --git a/contrib/libs/curl/lib/mprintf.c b/contrib/libs/curl/lib/mprintf.c
index 4a32ad4609..c681248dee 100644
--- a/contrib/libs/curl/lib/mprintf.c
+++ b/contrib/libs/curl/lib/mprintf.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1999 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1999 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -36,7 +36,7 @@
*/
#include "curl_setup.h"
-#include "dynbuf.h"
+#include "dynbuf.h"
#include <curl/mprintf.h>
#include "curl_memory.h"
@@ -99,13 +99,13 @@ static const char lower_digits[] = "0123456789abcdefghijklmnopqrstuvwxyz";
/* Upper-case digits. */
static const char upper_digits[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
-#define OUTCHAR(x) \
- do { \
+#define OUTCHAR(x) \
+ do { \
if(stream((unsigned char)(x), (FILE *)data) != -1) \
- done++; \
- else \
- return done; /* return immediately on failure */ \
- } while(0)
+ done++; \
+ else \
+ return done; /* return immediately on failure */ \
+ } while(0)
/* Data type to read from the arglist */
typedef enum {
@@ -146,7 +146,7 @@ enum {
FLAGS_FLOATG = 1<<19 /* %g or %G */
};
-struct va_stack {
+struct va_stack {
FormatType type;
int flags;
long width; /* width OR width parameter number */
@@ -160,7 +160,7 @@ struct va_stack {
} num;
double dnum;
} data;
-};
+};
struct nsprintf {
char *buffer;
@@ -169,23 +169,23 @@ struct nsprintf {
};
struct asprintf {
- struct dynbuf *b;
- bool fail; /* if an alloc has failed and thus the output is not the complete
- data */
+ struct dynbuf *b;
+ bool fail; /* if an alloc has failed and thus the output is not the complete
+ data */
};
static long dprintf_DollarString(char *input, char **end)
{
int number = 0;
while(ISDIGIT(*input)) {
- if(number < MAX_PARAMETERS) {
- number *= 10;
- number += *input - '0';
- }
+ if(number < MAX_PARAMETERS) {
+ number *= 10;
+ number += *input - '0';
+ }
input++;
}
- if(number <= MAX_PARAMETERS && ('$' == *input)) {
- *end = ++input;
+ if(number <= MAX_PARAMETERS && ('$' == *input)) {
+ *end = ++input;
return number;
}
return 0;
@@ -225,8 +225,8 @@ static bool dprintf_IsQualifierNoDollar(const char *fmt)
*
******************************************************************/
-static int dprintf_Pass1(const char *format, struct va_stack *vto,
- char **endpos, va_list arglist)
+static int dprintf_Pass1(const char *format, struct va_stack *vto,
+ char **endpos, va_list arglist)
{
char *fmt = (char *)format;
int param_num = 0;
@@ -379,8 +379,8 @@ static int dprintf_Pass1(const char *format, struct va_stack *vto,
if(width > max_param)
max_param = width;
break;
- case '\0':
- fmt--;
+ case '\0':
+ fmt--;
default:
break;
}
@@ -462,9 +462,9 @@ static int dprintf_Pass1(const char *format, struct va_stack *vto,
/* we have the width specified from a parameter, so we make that
parameter's info setup properly */
long k = width - 1;
- if((k < 0) || (k >= MAX_PARAMETERS))
- /* out of allowed range */
- return 1;
+ if((k < 0) || (k >= MAX_PARAMETERS))
+ /* out of allowed range */
+ return 1;
vto[i].width = k;
vto[k].type = FORMAT_WIDTH;
vto[k].flags = FLAGS_NEW;
@@ -476,9 +476,9 @@ static int dprintf_Pass1(const char *format, struct va_stack *vto,
/* we have the precision specified from a parameter, so we make that
parameter's info setup properly */
long k = precision - 1;
- if((k < 0) || (k >= MAX_PARAMETERS))
- /* out of allowed range */
- return 1;
+ if((k < 0) || (k >= MAX_PARAMETERS))
+ /* out of allowed range */
+ return 1;
vto[i].precision = k;
vto[k].type = FORMAT_WIDTH;
vto[k].flags = FLAGS_NEW;
@@ -486,7 +486,7 @@ static int dprintf_Pass1(const char *format, struct va_stack *vto,
vto[k].width = 0;
vto[k].precision = 0;
}
- *endpos++ = fmt + ((*fmt == '\0') ? 0 : 1); /* end of this sequence */
+ *endpos++ = fmt + ((*fmt == '\0') ? 0 : 1); /* end of this sequence */
}
}
@@ -580,11 +580,11 @@ static int dprintf_formatf(
long param; /* current parameter to read */
long param_num = 0; /* parameter counter */
- struct va_stack vto[MAX_PARAMETERS];
+ struct va_stack vto[MAX_PARAMETERS];
char *endpos[MAX_PARAMETERS];
char **end;
char work[BUFFSIZE];
- struct va_stack *p;
+ struct va_stack *p;
/* 'workend' points to the final buffer byte position, but with an extra
byte as margin to avoid the (false?) warning Coverity gives us
@@ -764,7 +764,7 @@ static int dprintf_formatf(
if(prec > 0) {
width -= prec;
- while(prec-- > 0 && w >= work)
+ while(prec-- > 0 && w >= work)
*w-- = '0';
}
@@ -878,7 +878,7 @@ static int dprintf_formatf(
OUTCHAR(' ');
for(point = strnil; *point != '\0'; ++point)
OUTCHAR(*point);
- if(!(p->flags & FLAGS_LEFT))
+ if(!(p->flags & FLAGS_LEFT))
while(width-- > 0)
OUTCHAR(' ');
}
@@ -928,8 +928,8 @@ static int dprintf_formatf(
precision */
size_t maxprec = sizeof(work) - 2;
double val = p->data.dnum;
- if(width > 0 && prec <= width)
- maxprec -= width;
+ if(width > 0 && prec <= width)
+ maxprec -= width;
while(val >= 10.0) {
val /= 10;
maxprec--;
@@ -937,8 +937,8 @@ static int dprintf_formatf(
if(prec > (long)maxprec)
prec = (long)maxprec-1;
- if(prec < 0)
- prec = 0;
+ if(prec < 0)
+ prec = 0;
/* RECURSIVE USAGE */
len = curl_msnprintf(fptr, left, ".%ld", prec);
fptr += len;
@@ -1042,61 +1042,61 @@ static int alloc_addbyter(int output, FILE *data)
struct asprintf *infop = (struct asprintf *)data;
unsigned char outc = (unsigned char)output;
- if(Curl_dyn_addn(infop->b, &outc, 1)) {
- infop->fail = 1;
- return -1; /* fail */
+ if(Curl_dyn_addn(infop->b, &outc, 1)) {
+ infop->fail = 1;
+ return -1; /* fail */
}
return outc; /* fputc() returns like this on success */
}
-extern int Curl_dyn_vprintf(struct dynbuf *dyn,
- const char *format, va_list ap_save);
-
-/* appends the formatted string, returns 0 on success, 1 on error */
-int Curl_dyn_vprintf(struct dynbuf *dyn, const char *format, va_list ap_save)
+extern int Curl_dyn_vprintf(struct dynbuf *dyn,
+ const char *format, va_list ap_save);
+
+/* appends the formatted string, returns 0 on success, 1 on error */
+int Curl_dyn_vprintf(struct dynbuf *dyn, const char *format, va_list ap_save)
{
int retcode;
struct asprintf info;
- info.b = dyn;
+ info.b = dyn;
info.fail = 0;
retcode = dprintf_formatf(&info, alloc_addbyter, format, ap_save);
if((-1 == retcode) || info.fail) {
- Curl_dyn_free(info.b);
- return 1;
+ Curl_dyn_free(info.b);
+ return 1;
}
- return 0;
+ return 0;
}
char *curl_mvaprintf(const char *format, va_list ap_save)
{
int retcode;
struct asprintf info;
- struct dynbuf dyn;
- info.b = &dyn;
- Curl_dyn_init(info.b, DYN_APRINTF);
+ struct dynbuf dyn;
+ info.b = &dyn;
+ Curl_dyn_init(info.b, DYN_APRINTF);
info.fail = 0;
retcode = dprintf_formatf(&info, alloc_addbyter, format, ap_save);
if((-1 == retcode) || info.fail) {
- Curl_dyn_free(info.b);
+ Curl_dyn_free(info.b);
return NULL;
}
- if(Curl_dyn_len(info.b))
- return Curl_dyn_ptr(info.b);
+ if(Curl_dyn_len(info.b))
+ return Curl_dyn_ptr(info.b);
return strdup("");
}
-char *curl_maprintf(const char *format, ...)
-{
- va_list ap_save;
- char *s;
- va_start(ap_save, format);
- s = curl_mvaprintf(format, ap_save);
- va_end(ap_save);
- return s;
-}
-
+char *curl_maprintf(const char *format, ...)
+{
+ va_list ap_save;
+ char *s;
+ va_start(ap_save, format);
+ s = curl_mvaprintf(format, ap_save);
+ va_end(ap_save);
+ return s;
+}
+
static int storebuffer(int output, FILE *data)
{
char **buffer = (char **)data;
diff --git a/contrib/libs/curl/lib/mqtt.c b/contrib/libs/curl/lib/mqtt.c
index 9981a57367..e324ec3dd7 100644
--- a/contrib/libs/curl/lib/mqtt.c
+++ b/contrib/libs/curl/lib/mqtt.c
@@ -1,624 +1,624 @@
-/***************************************************************************
- * _ _ ____ _
- * Project ___| | | | _ \| |
- * / __| | | | |_) | |
- * | (__| |_| | _ <| |___
- * \___|\___/|_| \_\_____|
- *
- * Copyright (C) 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
- * Copyright (C) 2019, Björn Stenberg, <bjorn@haxx.se>
- *
- * This software is licensed as described in the file COPYING, which
- * you should have received as part of this distribution. The terms
- * are also available at https://curl.se/docs/copyright.html.
- *
- * You may opt to use, copy, modify, merge, publish, distribute and/or sell
- * copies of the Software, and permit persons to whom the Software is
- * furnished to do so, under the terms of the COPYING file.
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- ***************************************************************************/
-
-#include "curl_setup.h"
-
-#ifndef CURL_DISABLE_MQTT
-
-#include "urldata.h"
-#include <curl/curl.h>
-#include "transfer.h"
-#include "sendf.h"
-#include "progress.h"
-#include "mqtt.h"
-#include "select.h"
-#include "strdup.h"
-#include "url.h"
-#include "escape.h"
-#include "warnless.h"
-#include "curl_printf.h"
-#include "curl_memory.h"
-#include "multiif.h"
-#include "rand.h"
-
-/* The last #include file should be: */
-#include "memdebug.h"
-
-#define MQTT_MSG_CONNECT 0x10
-#define MQTT_MSG_CONNACK 0x20
-#define MQTT_MSG_PUBLISH 0x30
-#define MQTT_MSG_SUBSCRIBE 0x82
-#define MQTT_MSG_SUBACK 0x90
-#define MQTT_MSG_DISCONNECT 0xe0
-
-#define MQTT_CONNACK_LEN 2
-#define MQTT_SUBACK_LEN 3
-#define MQTT_CLIENTID_LEN 12 /* "curl0123abcd" */
-
-/*
- * Forward declarations.
- */
-
-static CURLcode mqtt_do(struct connectdata *conn, bool *done);
-static CURLcode mqtt_doing(struct connectdata *conn, bool *done);
-static int mqtt_getsock(struct connectdata *conn, curl_socket_t *sock);
-static CURLcode mqtt_setup_conn(struct connectdata *conn);
-
-/*
- * MQTT protocol handler.
- */
-
-const struct Curl_handler Curl_handler_mqtt = {
- "MQTT", /* scheme */
- mqtt_setup_conn, /* setup_connection */
- mqtt_do, /* do_it */
- ZERO_NULL, /* done */
- ZERO_NULL, /* do_more */
- ZERO_NULL, /* connect_it */
- ZERO_NULL, /* connecting */
- mqtt_doing, /* doing */
- ZERO_NULL, /* proto_getsock */
- mqtt_getsock, /* doing_getsock */
- ZERO_NULL, /* domore_getsock */
- ZERO_NULL, /* perform_getsock */
- ZERO_NULL, /* disconnect */
- ZERO_NULL, /* readwrite */
- ZERO_NULL, /* connection_check */
- PORT_MQTT, /* defport */
- CURLPROTO_MQTT, /* protocol */
- CURLPROTO_MQTT, /* family */
- PROTOPT_NONE /* flags */
-};
-
-static CURLcode mqtt_setup_conn(struct connectdata *conn)
-{
- /* allocate the HTTP-specific struct for the Curl_easy, only to survive
- during this request */
- struct MQTT *mq;
- struct Curl_easy *data = conn->data;
- DEBUGASSERT(data->req.p.mqtt == NULL);
-
- mq = calloc(1, sizeof(struct MQTT));
- if(!mq)
- return CURLE_OUT_OF_MEMORY;
- data->req.p.mqtt = mq;
- return CURLE_OK;
-}
-
-static CURLcode mqtt_send(struct connectdata *conn,
- char *buf, size_t len)
-{
- CURLcode result = CURLE_OK;
- curl_socket_t sockfd = conn->sock[FIRSTSOCKET];
- struct Curl_easy *data = conn->data;
- struct MQTT *mq = data->req.p.mqtt;
- ssize_t n;
- result = Curl_write(conn, sockfd, buf, len, &n);
- if(!result)
- Curl_debug(data, CURLINFO_HEADER_OUT, buf, (size_t)n);
- if(len != (size_t)n) {
- size_t nsend = len - n;
- char *sendleftovers = Curl_memdup(&buf[n], nsend);
- if(!sendleftovers)
- return CURLE_OUT_OF_MEMORY;
- mq->sendleftovers = sendleftovers;
- mq->nsend = nsend;
- }
- return result;
-}
-
-/* Generic function called by the multi interface to figure out what socket(s)
- to wait for and for what actions during the DOING and PROTOCONNECT
- states */
-static int mqtt_getsock(struct connectdata *conn,
- curl_socket_t *sock)
-{
- sock[0] = conn->sock[FIRSTSOCKET];
- return GETSOCK_READSOCK(FIRSTSOCKET);
-}
-
-static CURLcode mqtt_connect(struct connectdata *conn)
-{
- CURLcode result = CURLE_OK;
- const size_t client_id_offset = 14;
- const size_t packetlen = client_id_offset + MQTT_CLIENTID_LEN;
- char client_id[MQTT_CLIENTID_LEN + 1] = "curl";
- const size_t clen = strlen("curl");
- char packet[32] = {
- MQTT_MSG_CONNECT, /* packet type */
- 0x00, /* remaining length */
- 0x00, 0x04, /* protocol length */
- 'M','Q','T','T', /* protocol name */
- 0x04, /* protocol level */
- 0x02, /* CONNECT flag: CleanSession */
- 0x00, 0x3c, /* keep-alive 0 = disabled */
- 0x00, 0x00 /* payload1 length */
- };
- packet[1] = (packetlen - 2) & 0x7f;
- packet[client_id_offset - 1] = MQTT_CLIENTID_LEN;
-
- result = Curl_rand_hex(conn->data, (unsigned char *)&client_id[clen],
- MQTT_CLIENTID_LEN - clen + 1);
- memcpy(&packet[client_id_offset], client_id, MQTT_CLIENTID_LEN);
- infof(conn->data, "Using client id '%s'\n", client_id);
- if(!result)
- result = mqtt_send(conn, packet, packetlen);
- return result;
-}
-
-static CURLcode mqtt_disconnect(struct connectdata *conn)
-{
- CURLcode result = CURLE_OK;
- result = mqtt_send(conn, (char *)"\xe0\x00", 2);
- return result;
-}
-
-static CURLcode mqtt_verify_connack(struct connectdata *conn)
-{
- CURLcode result;
- curl_socket_t sockfd = conn->sock[FIRSTSOCKET];
- unsigned char readbuf[MQTT_CONNACK_LEN];
- ssize_t nread;
- struct Curl_easy *data = conn->data;
-
- result = Curl_read(conn, sockfd, (char *)readbuf, MQTT_CONNACK_LEN, &nread);
- if(result)
- goto fail;
-
- Curl_debug(data, CURLINFO_HEADER_IN, (char *)readbuf, (size_t)nread);
-
- /* fixme */
- if(nread < MQTT_CONNACK_LEN) {
- result = CURLE_WEIRD_SERVER_REPLY;
- goto fail;
- }
-
- /* verify CONNACK */
- if(readbuf[0] != 0x00 || readbuf[1] != 0x00) {
- failf(data, "Expected %02x%02x but got %02x%02x",
- 0x00, 0x00, readbuf[0], readbuf[1]);
- result = CURLE_WEIRD_SERVER_REPLY;
- }
-
-fail:
- return result;
-}
-
-static CURLcode mqtt_get_topic(struct connectdata *conn,
- char **topic, size_t *topiclen)
-{
- CURLcode result = CURLE_OK;
- char *path = conn->data->state.up.path;
-
- if(strlen(path) > 1) {
- result = Curl_urldecode(conn->data, path + 1, 0, topic, topiclen,
- REJECT_NADA);
- }
- else {
- failf(conn->data, "Error: No topic specified.");
- result = CURLE_URL_MALFORMAT;
- }
- return result;
-}
-
-
-static int mqtt_encode_len(char *buf, size_t len)
-{
- unsigned char encoded;
- int i;
-
- for(i = 0; (len > 0) && (i<4); i++) {
- encoded = len % 0x80;
- len /= 0x80;
- if(len)
- encoded |= 0x80;
- buf[i] = encoded;
- }
-
- return i;
-}
-
-static CURLcode mqtt_subscribe(struct connectdata *conn)
-{
- CURLcode result = CURLE_OK;
- char *topic = NULL;
- size_t topiclen;
- unsigned char *packet = NULL;
- size_t packetlen;
- char encodedsize[4];
- size_t n;
-
- result = mqtt_get_topic(conn, &topic, &topiclen);
- if(result)
- goto fail;
-
- conn->proto.mqtt.packetid++;
-
- packetlen = topiclen + 5; /* packetid + topic (has a two byte length field)
- + 2 bytes topic length + QoS byte */
- n = mqtt_encode_len((char *)encodedsize, packetlen);
- packetlen += n + 1; /* add one for the control packet type byte */
-
- packet = malloc(packetlen);
- if(!packet) {
- result = CURLE_OUT_OF_MEMORY;
- goto fail;
- }
-
- packet[0] = MQTT_MSG_SUBSCRIBE;
- memcpy(&packet[1], encodedsize, n);
- packet[1 + n] = (conn->proto.mqtt.packetid >> 8) & 0xff;
- packet[2 + n] = conn->proto.mqtt.packetid & 0xff;
- packet[3 + n] = (topiclen >> 8) & 0xff;
- packet[4 + n ] = topiclen & 0xff;
- memcpy(&packet[5 + n], topic, topiclen);
- packet[5 + n + topiclen] = 0; /* QoS zero */
-
- result = mqtt_send(conn, (char *)packet, packetlen);
-
-fail:
- free(topic);
- free(packet);
- return result;
-}
-
-/*
- * Called when the first byte was already read.
- */
-static CURLcode mqtt_verify_suback(struct connectdata *conn)
-{
- CURLcode result;
- curl_socket_t sockfd = conn->sock[FIRSTSOCKET];
- unsigned char readbuf[MQTT_SUBACK_LEN];
- ssize_t nread;
- struct mqtt_conn *mqtt = &conn->proto.mqtt;
-
- result = Curl_read(conn, sockfd, (char *)readbuf, MQTT_SUBACK_LEN, &nread);
- if(result)
- goto fail;
-
- Curl_debug(conn->data, CURLINFO_HEADER_IN, (char *)readbuf, (size_t)nread);
-
- /* fixme */
- if(nread < MQTT_SUBACK_LEN) {
- result = CURLE_WEIRD_SERVER_REPLY;
- goto fail;
- }
-
- /* verify SUBACK */
- if(readbuf[0] != ((mqtt->packetid >> 8) & 0xff) ||
- readbuf[1] != (mqtt->packetid & 0xff) ||
- readbuf[2] != 0x00)
- result = CURLE_WEIRD_SERVER_REPLY;
-
-fail:
- return result;
-}
-
-static CURLcode mqtt_publish(struct connectdata *conn)
-{
- CURLcode result;
- char *payload = conn->data->set.postfields;
- size_t payloadlen = (size_t)conn->data->set.postfieldsize;
- char *topic = NULL;
- size_t topiclen;
- unsigned char *pkt = NULL;
- size_t i = 0;
- size_t remaininglength;
- size_t encodelen;
- char encodedbytes[4];
-
- result = mqtt_get_topic(conn, &topic, &topiclen);
- if(result)
- goto fail;
-
- remaininglength = payloadlen + 2 + topiclen;
- encodelen = mqtt_encode_len(encodedbytes, remaininglength);
-
- /* add the control byte and the encoded remaining length */
- pkt = malloc(remaininglength + 1 + encodelen);
- if(!pkt) {
- result = CURLE_OUT_OF_MEMORY;
- goto fail;
- }
-
- /* assemble packet */
- pkt[i++] = MQTT_MSG_PUBLISH;
- memcpy(&pkt[i], encodedbytes, encodelen);
- i += encodelen;
- pkt[i++] = (topiclen >> 8) & 0xff;
- pkt[i++] = (topiclen & 0xff);
- memcpy(&pkt[i], topic, topiclen);
- i += topiclen;
- memcpy(&pkt[i], payload, payloadlen);
- i += payloadlen;
- result = mqtt_send(conn, (char *)pkt, i);
-
-fail:
- free(pkt);
- free(topic);
- return result;
-}
-
-static size_t mqtt_decode_len(unsigned char *buf,
- size_t buflen, size_t *lenbytes)
-{
- size_t len = 0;
- size_t mult = 1;
- size_t i;
- unsigned char encoded = 128;
-
- for(i = 0; (i < buflen) && (encoded & 128); i++) {
- encoded = buf[i];
- len += (encoded & 127) * mult;
- mult *= 128;
- }
-
- if(lenbytes)
- *lenbytes = i;
-
- return len;
-}
-
-#ifdef CURLDEBUG
-static const char *statenames[]={
- "MQTT_FIRST",
- "MQTT_REMAINING_LENGTH",
- "MQTT_CONNACK",
- "MQTT_SUBACK",
- "MQTT_SUBACK_COMING",
- "MQTT_PUBWAIT",
- "MQTT_PUB_REMAIN",
-
- "NOT A STATE"
-};
-#endif
-
-/* The only way to change state */
-static void mqstate(struct connectdata *conn,
- enum mqttstate state,
- enum mqttstate nextstate) /* used if state == FIRST */
-{
- struct mqtt_conn *mqtt = &conn->proto.mqtt;
-#ifdef CURLDEBUG
- infof(conn->data, "%s (from %s) (next is %s)\n",
- statenames[state],
- statenames[mqtt->state],
- (state == MQTT_FIRST)? statenames[nextstate] : "");
-#endif
- mqtt->state = state;
- if(state == MQTT_FIRST)
- mqtt->nextstate = nextstate;
-}
-
-
-/* for the publish packet */
-#define MQTT_HEADER_LEN 5 /* max 5 bytes */
-
-static CURLcode mqtt_read_publish(struct connectdata *conn,
- bool *done)
-{
- CURLcode result = CURLE_OK;
- curl_socket_t sockfd = conn->sock[FIRSTSOCKET];
- ssize_t nread;
- struct Curl_easy *data = conn->data;
- unsigned char *pkt = (unsigned char *)data->state.buffer;
- size_t remlen;
- struct mqtt_conn *mqtt = &conn->proto.mqtt;
- struct MQTT *mq = data->req.p.mqtt;
- unsigned char packet;
-
- switch(mqtt->state) {
- MQTT_SUBACK_COMING:
- case MQTT_SUBACK_COMING:
- result = mqtt_verify_suback(conn);
- if(result)
- break;
-
- mqstate(conn, MQTT_FIRST, MQTT_PUBWAIT);
- break;
-
- case MQTT_SUBACK:
- case MQTT_PUBWAIT:
- /* we are expecting PUBLISH or SUBACK */
- packet = mq->firstbyte & 0xf0;
- if(packet == MQTT_MSG_PUBLISH)
- mqstate(conn, MQTT_PUB_REMAIN, MQTT_NOSTATE);
- else if(packet == MQTT_MSG_SUBACK) {
- mqstate(conn, MQTT_SUBACK_COMING, MQTT_NOSTATE);
- goto MQTT_SUBACK_COMING;
- }
- else if(packet == MQTT_MSG_DISCONNECT) {
- infof(data, "Got DISCONNECT\n");
- *done = TRUE;
- goto end;
- }
- else {
- result = CURLE_WEIRD_SERVER_REPLY;
- goto end;
- }
-
- /* -- switched state -- */
- remlen = mq->remaining_length;
- infof(data, "Remaining length: %zd bytes\n", remlen);
- Curl_pgrsSetDownloadSize(data, remlen);
- data->req.bytecount = 0;
- data->req.size = remlen;
- mq->npacket = remlen; /* get this many bytes */
- /* FALLTHROUGH */
- case MQTT_PUB_REMAIN: {
- /* read rest of packet, but no more. Cap to buffer size */
- struct SingleRequest *k = &data->req;
- size_t rest = mq->npacket;
- if(rest > (size_t)data->set.buffer_size)
- rest = (size_t)data->set.buffer_size;
- result = Curl_read(conn, sockfd, (char *)pkt, rest, &nread);
- if(result) {
- if(CURLE_AGAIN == result) {
- infof(data, "EEEE AAAAGAIN\n");
- }
- goto end;
- }
- if(!nread) {
- infof(data, "server disconnected\n");
- result = CURLE_PARTIAL_FILE;
- goto end;
- }
- Curl_debug(data, CURLINFO_DATA_IN, (char *)pkt, (size_t)nread);
-
- mq->npacket -= nread;
- k->bytecount += nread;
- Curl_pgrsSetDownloadCounter(data, k->bytecount);
-
- /* if QoS is set, message contains packet id */
-
- result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)pkt, nread);
- if(result)
- goto end;
-
- if(!mq->npacket)
- /* no more PUBLISH payload, back to subscribe wait state */
- mqstate(conn, MQTT_FIRST, MQTT_PUBWAIT);
- break;
- }
- default:
- DEBUGASSERT(NULL); /* illegal state */
- result = CURLE_WEIRD_SERVER_REPLY;
- goto end;
- }
- end:
- return result;
-}
-
-static CURLcode mqtt_do(struct connectdata *conn, bool *done)
-{
- CURLcode result = CURLE_OK;
- struct Curl_easy *data = conn->data;
-
- *done = FALSE; /* unconditionally */
-
- result = mqtt_connect(conn);
- if(result) {
- failf(data, "Error %d sending MQTT CONN request", result);
- return result;
- }
- mqstate(conn, MQTT_FIRST, MQTT_CONNACK);
- return CURLE_OK;
-}
-
-static CURLcode mqtt_doing(struct connectdata *conn, bool *done)
-{
- CURLcode result = CURLE_OK;
- struct mqtt_conn *mqtt = &conn->proto.mqtt;
- struct Curl_easy *data = conn->data;
- struct MQTT *mq = data->req.p.mqtt;
- ssize_t nread;
- curl_socket_t sockfd = conn->sock[FIRSTSOCKET];
- unsigned char *pkt = (unsigned char *)data->state.buffer;
- unsigned char byte;
-
- *done = FALSE;
-
- if(mq->nsend) {
- /* send the remainder of an outgoing packet */
- char *ptr = mq->sendleftovers;
- result = mqtt_send(conn, mq->sendleftovers, mq->nsend);
- free(ptr);
- if(result)
- return result;
- }
-
- infof(data, "mqtt_doing: state [%d]\n", (int) mqtt->state);
- switch(mqtt->state) {
- case MQTT_FIRST:
- /* Read the initial byte only */
- result = Curl_read(conn, sockfd, (char *)&mq->firstbyte, 1, &nread);
- if(result)
- break;
- Curl_debug(data, CURLINFO_HEADER_IN, (char *)&mq->firstbyte, 1);
- /* remember the first byte */
- mq->npacket = 0;
- mqstate(conn, MQTT_REMAINING_LENGTH, MQTT_NOSTATE);
- /* FALLTHROUGH */
- case MQTT_REMAINING_LENGTH:
- do {
- result = Curl_read(conn, sockfd, (char *)&byte, 1, &nread);
- if(result)
- break;
- Curl_debug(data, CURLINFO_HEADER_IN, (char *)&byte, 1);
- pkt[mq->npacket++] = byte;
- } while((byte & 0x80) && (mq->npacket < 4));
- if(result)
- break;
- mq->remaining_length = mqtt_decode_len(&pkt[0], mq->npacket, NULL);
- mq->npacket = 0;
- if(mq->remaining_length) {
- mqstate(conn, mqtt->nextstate, MQTT_NOSTATE);
- break;
- }
- mqstate(conn, MQTT_FIRST, MQTT_FIRST);
-
- if(mq->firstbyte == MQTT_MSG_DISCONNECT) {
- infof(data, "Got DISCONNECT\n");
- *done = TRUE;
- }
- break;
- case MQTT_CONNACK:
- result = mqtt_verify_connack(conn);
- if(result)
- break;
-
- if(conn->data->state.httpreq == HTTPREQ_POST) {
- result = mqtt_publish(conn);
- if(!result) {
- result = mqtt_disconnect(conn);
- *done = TRUE;
- }
- mqtt->nextstate = MQTT_FIRST;
- }
- else {
- result = mqtt_subscribe(conn);
- if(!result) {
- mqstate(conn, MQTT_FIRST, MQTT_SUBACK);
- }
- }
- break;
-
- case MQTT_SUBACK:
- case MQTT_PUBWAIT:
- case MQTT_PUB_REMAIN:
- result = mqtt_read_publish(conn, done);
- break;
-
- default:
- failf(conn->data, "State not handled yet");
- *done = TRUE;
- break;
- }
-
- if(result == CURLE_AGAIN)
- result = CURLE_OK;
- return result;
-}
-
-#endif /* CURL_DISABLE_MQTT */
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2019, Björn Stenberg, <bjorn@haxx.se>
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at https://curl.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+
+#include "curl_setup.h"
+
+#ifndef CURL_DISABLE_MQTT
+
+#include "urldata.h"
+#include <curl/curl.h>
+#include "transfer.h"
+#include "sendf.h"
+#include "progress.h"
+#include "mqtt.h"
+#include "select.h"
+#include "strdup.h"
+#include "url.h"
+#include "escape.h"
+#include "warnless.h"
+#include "curl_printf.h"
+#include "curl_memory.h"
+#include "multiif.h"
+#include "rand.h"
+
+/* The last #include file should be: */
+#include "memdebug.h"
+
+#define MQTT_MSG_CONNECT 0x10
+#define MQTT_MSG_CONNACK 0x20
+#define MQTT_MSG_PUBLISH 0x30
+#define MQTT_MSG_SUBSCRIBE 0x82
+#define MQTT_MSG_SUBACK 0x90
+#define MQTT_MSG_DISCONNECT 0xe0
+
+#define MQTT_CONNACK_LEN 2
+#define MQTT_SUBACK_LEN 3
+#define MQTT_CLIENTID_LEN 12 /* "curl0123abcd" */
+
+/*
+ * Forward declarations.
+ */
+
+static CURLcode mqtt_do(struct connectdata *conn, bool *done);
+static CURLcode mqtt_doing(struct connectdata *conn, bool *done);
+static int mqtt_getsock(struct connectdata *conn, curl_socket_t *sock);
+static CURLcode mqtt_setup_conn(struct connectdata *conn);
+
+/*
+ * MQTT protocol handler.
+ */
+
+const struct Curl_handler Curl_handler_mqtt = {
+ "MQTT", /* scheme */
+ mqtt_setup_conn, /* setup_connection */
+ mqtt_do, /* do_it */
+ ZERO_NULL, /* done */
+ ZERO_NULL, /* do_more */
+ ZERO_NULL, /* connect_it */
+ ZERO_NULL, /* connecting */
+ mqtt_doing, /* doing */
+ ZERO_NULL, /* proto_getsock */
+ mqtt_getsock, /* doing_getsock */
+ ZERO_NULL, /* domore_getsock */
+ ZERO_NULL, /* perform_getsock */
+ ZERO_NULL, /* disconnect */
+ ZERO_NULL, /* readwrite */
+ ZERO_NULL, /* connection_check */
+ PORT_MQTT, /* defport */
+ CURLPROTO_MQTT, /* protocol */
+ CURLPROTO_MQTT, /* family */
+ PROTOPT_NONE /* flags */
+};
+
+static CURLcode mqtt_setup_conn(struct connectdata *conn)
+{
+ /* allocate the HTTP-specific struct for the Curl_easy, only to survive
+ during this request */
+ struct MQTT *mq;
+ struct Curl_easy *data = conn->data;
+ DEBUGASSERT(data->req.p.mqtt == NULL);
+
+ mq = calloc(1, sizeof(struct MQTT));
+ if(!mq)
+ return CURLE_OUT_OF_MEMORY;
+ data->req.p.mqtt = mq;
+ return CURLE_OK;
+}
+
+static CURLcode mqtt_send(struct connectdata *conn,
+ char *buf, size_t len)
+{
+ CURLcode result = CURLE_OK;
+ curl_socket_t sockfd = conn->sock[FIRSTSOCKET];
+ struct Curl_easy *data = conn->data;
+ struct MQTT *mq = data->req.p.mqtt;
+ ssize_t n;
+ result = Curl_write(conn, sockfd, buf, len, &n);
+ if(!result)
+ Curl_debug(data, CURLINFO_HEADER_OUT, buf, (size_t)n);
+ if(len != (size_t)n) {
+ size_t nsend = len - n;
+ char *sendleftovers = Curl_memdup(&buf[n], nsend);
+ if(!sendleftovers)
+ return CURLE_OUT_OF_MEMORY;
+ mq->sendleftovers = sendleftovers;
+ mq->nsend = nsend;
+ }
+ return result;
+}
+
+/* Generic function called by the multi interface to figure out what socket(s)
+ to wait for and for what actions during the DOING and PROTOCONNECT
+ states */
+static int mqtt_getsock(struct connectdata *conn,
+ curl_socket_t *sock)
+{
+ sock[0] = conn->sock[FIRSTSOCKET];
+ return GETSOCK_READSOCK(FIRSTSOCKET);
+}
+
+static CURLcode mqtt_connect(struct connectdata *conn)
+{
+ CURLcode result = CURLE_OK;
+ const size_t client_id_offset = 14;
+ const size_t packetlen = client_id_offset + MQTT_CLIENTID_LEN;
+ char client_id[MQTT_CLIENTID_LEN + 1] = "curl";
+ const size_t clen = strlen("curl");
+ char packet[32] = {
+ MQTT_MSG_CONNECT, /* packet type */
+ 0x00, /* remaining length */
+ 0x00, 0x04, /* protocol length */
+ 'M','Q','T','T', /* protocol name */
+ 0x04, /* protocol level */
+ 0x02, /* CONNECT flag: CleanSession */
+ 0x00, 0x3c, /* keep-alive 0 = disabled */
+ 0x00, 0x00 /* payload1 length */
+ };
+ packet[1] = (packetlen - 2) & 0x7f;
+ packet[client_id_offset - 1] = MQTT_CLIENTID_LEN;
+
+ result = Curl_rand_hex(conn->data, (unsigned char *)&client_id[clen],
+ MQTT_CLIENTID_LEN - clen + 1);
+ memcpy(&packet[client_id_offset], client_id, MQTT_CLIENTID_LEN);
+ infof(conn->data, "Using client id '%s'\n", client_id);
+ if(!result)
+ result = mqtt_send(conn, packet, packetlen);
+ return result;
+}
+
+static CURLcode mqtt_disconnect(struct connectdata *conn)
+{
+ CURLcode result = CURLE_OK;
+ result = mqtt_send(conn, (char *)"\xe0\x00", 2);
+ return result;
+}
+
+static CURLcode mqtt_verify_connack(struct connectdata *conn)
+{
+ CURLcode result;
+ curl_socket_t sockfd = conn->sock[FIRSTSOCKET];
+ unsigned char readbuf[MQTT_CONNACK_LEN];
+ ssize_t nread;
+ struct Curl_easy *data = conn->data;
+
+ result = Curl_read(conn, sockfd, (char *)readbuf, MQTT_CONNACK_LEN, &nread);
+ if(result)
+ goto fail;
+
+ Curl_debug(data, CURLINFO_HEADER_IN, (char *)readbuf, (size_t)nread);
+
+ /* fixme */
+ if(nread < MQTT_CONNACK_LEN) {
+ result = CURLE_WEIRD_SERVER_REPLY;
+ goto fail;
+ }
+
+ /* verify CONNACK */
+ if(readbuf[0] != 0x00 || readbuf[1] != 0x00) {
+ failf(data, "Expected %02x%02x but got %02x%02x",
+ 0x00, 0x00, readbuf[0], readbuf[1]);
+ result = CURLE_WEIRD_SERVER_REPLY;
+ }
+
+fail:
+ return result;
+}
+
+static CURLcode mqtt_get_topic(struct connectdata *conn,
+ char **topic, size_t *topiclen)
+{
+ CURLcode result = CURLE_OK;
+ char *path = conn->data->state.up.path;
+
+ if(strlen(path) > 1) {
+ result = Curl_urldecode(conn->data, path + 1, 0, topic, topiclen,
+ REJECT_NADA);
+ }
+ else {
+ failf(conn->data, "Error: No topic specified.");
+ result = CURLE_URL_MALFORMAT;
+ }
+ return result;
+}
+
+
+static int mqtt_encode_len(char *buf, size_t len)
+{
+ unsigned char encoded;
+ int i;
+
+ for(i = 0; (len > 0) && (i<4); i++) {
+ encoded = len % 0x80;
+ len /= 0x80;
+ if(len)
+ encoded |= 0x80;
+ buf[i] = encoded;
+ }
+
+ return i;
+}
+
+static CURLcode mqtt_subscribe(struct connectdata *conn)
+{
+ CURLcode result = CURLE_OK;
+ char *topic = NULL;
+ size_t topiclen;
+ unsigned char *packet = NULL;
+ size_t packetlen;
+ char encodedsize[4];
+ size_t n;
+
+ result = mqtt_get_topic(conn, &topic, &topiclen);
+ if(result)
+ goto fail;
+
+ conn->proto.mqtt.packetid++;
+
+ packetlen = topiclen + 5; /* packetid + topic (has a two byte length field)
+ + 2 bytes topic length + QoS byte */
+ n = mqtt_encode_len((char *)encodedsize, packetlen);
+ packetlen += n + 1; /* add one for the control packet type byte */
+
+ packet = malloc(packetlen);
+ if(!packet) {
+ result = CURLE_OUT_OF_MEMORY;
+ goto fail;
+ }
+
+ packet[0] = MQTT_MSG_SUBSCRIBE;
+ memcpy(&packet[1], encodedsize, n);
+ packet[1 + n] = (conn->proto.mqtt.packetid >> 8) & 0xff;
+ packet[2 + n] = conn->proto.mqtt.packetid & 0xff;
+ packet[3 + n] = (topiclen >> 8) & 0xff;
+ packet[4 + n ] = topiclen & 0xff;
+ memcpy(&packet[5 + n], topic, topiclen);
+ packet[5 + n + topiclen] = 0; /* QoS zero */
+
+ result = mqtt_send(conn, (char *)packet, packetlen);
+
+fail:
+ free(topic);
+ free(packet);
+ return result;
+}
+
+/*
+ * Called when the first byte was already read.
+ */
+static CURLcode mqtt_verify_suback(struct connectdata *conn)
+{
+ CURLcode result;
+ curl_socket_t sockfd = conn->sock[FIRSTSOCKET];
+ unsigned char readbuf[MQTT_SUBACK_LEN];
+ ssize_t nread;
+ struct mqtt_conn *mqtt = &conn->proto.mqtt;
+
+ result = Curl_read(conn, sockfd, (char *)readbuf, MQTT_SUBACK_LEN, &nread);
+ if(result)
+ goto fail;
+
+ Curl_debug(conn->data, CURLINFO_HEADER_IN, (char *)readbuf, (size_t)nread);
+
+ /* fixme */
+ if(nread < MQTT_SUBACK_LEN) {
+ result = CURLE_WEIRD_SERVER_REPLY;
+ goto fail;
+ }
+
+ /* verify SUBACK */
+ if(readbuf[0] != ((mqtt->packetid >> 8) & 0xff) ||
+ readbuf[1] != (mqtt->packetid & 0xff) ||
+ readbuf[2] != 0x00)
+ result = CURLE_WEIRD_SERVER_REPLY;
+
+fail:
+ return result;
+}
+
+static CURLcode mqtt_publish(struct connectdata *conn)
+{
+ CURLcode result;
+ char *payload = conn->data->set.postfields;
+ size_t payloadlen = (size_t)conn->data->set.postfieldsize;
+ char *topic = NULL;
+ size_t topiclen;
+ unsigned char *pkt = NULL;
+ size_t i = 0;
+ size_t remaininglength;
+ size_t encodelen;
+ char encodedbytes[4];
+
+ result = mqtt_get_topic(conn, &topic, &topiclen);
+ if(result)
+ goto fail;
+
+ remaininglength = payloadlen + 2 + topiclen;
+ encodelen = mqtt_encode_len(encodedbytes, remaininglength);
+
+ /* add the control byte and the encoded remaining length */
+ pkt = malloc(remaininglength + 1 + encodelen);
+ if(!pkt) {
+ result = CURLE_OUT_OF_MEMORY;
+ goto fail;
+ }
+
+ /* assemble packet */
+ pkt[i++] = MQTT_MSG_PUBLISH;
+ memcpy(&pkt[i], encodedbytes, encodelen);
+ i += encodelen;
+ pkt[i++] = (topiclen >> 8) & 0xff;
+ pkt[i++] = (topiclen & 0xff);
+ memcpy(&pkt[i], topic, topiclen);
+ i += topiclen;
+ memcpy(&pkt[i], payload, payloadlen);
+ i += payloadlen;
+ result = mqtt_send(conn, (char *)pkt, i);
+
+fail:
+ free(pkt);
+ free(topic);
+ return result;
+}
+
+static size_t mqtt_decode_len(unsigned char *buf,
+ size_t buflen, size_t *lenbytes)
+{
+ size_t len = 0;
+ size_t mult = 1;
+ size_t i;
+ unsigned char encoded = 128;
+
+ for(i = 0; (i < buflen) && (encoded & 128); i++) {
+ encoded = buf[i];
+ len += (encoded & 127) * mult;
+ mult *= 128;
+ }
+
+ if(lenbytes)
+ *lenbytes = i;
+
+ return len;
+}
+
+#ifdef CURLDEBUG
+static const char *statenames[]={
+ "MQTT_FIRST",
+ "MQTT_REMAINING_LENGTH",
+ "MQTT_CONNACK",
+ "MQTT_SUBACK",
+ "MQTT_SUBACK_COMING",
+ "MQTT_PUBWAIT",
+ "MQTT_PUB_REMAIN",
+
+ "NOT A STATE"
+};
+#endif
+
+/* The only way to change state */
+static void mqstate(struct connectdata *conn,
+ enum mqttstate state,
+ enum mqttstate nextstate) /* used if state == FIRST */
+{
+ struct mqtt_conn *mqtt = &conn->proto.mqtt;
+#ifdef CURLDEBUG
+ infof(conn->data, "%s (from %s) (next is %s)\n",
+ statenames[state],
+ statenames[mqtt->state],
+ (state == MQTT_FIRST)? statenames[nextstate] : "");
+#endif
+ mqtt->state = state;
+ if(state == MQTT_FIRST)
+ mqtt->nextstate = nextstate;
+}
+
+
+/* for the publish packet */
+#define MQTT_HEADER_LEN 5 /* max 5 bytes */
+
+static CURLcode mqtt_read_publish(struct connectdata *conn,
+ bool *done)
+{
+ CURLcode result = CURLE_OK;
+ curl_socket_t sockfd = conn->sock[FIRSTSOCKET];
+ ssize_t nread;
+ struct Curl_easy *data = conn->data;
+ unsigned char *pkt = (unsigned char *)data->state.buffer;
+ size_t remlen;
+ struct mqtt_conn *mqtt = &conn->proto.mqtt;
+ struct MQTT *mq = data->req.p.mqtt;
+ unsigned char packet;
+
+ switch(mqtt->state) {
+ MQTT_SUBACK_COMING:
+ case MQTT_SUBACK_COMING:
+ result = mqtt_verify_suback(conn);
+ if(result)
+ break;
+
+ mqstate(conn, MQTT_FIRST, MQTT_PUBWAIT);
+ break;
+
+ case MQTT_SUBACK:
+ case MQTT_PUBWAIT:
+ /* we are expecting PUBLISH or SUBACK */
+ packet = mq->firstbyte & 0xf0;
+ if(packet == MQTT_MSG_PUBLISH)
+ mqstate(conn, MQTT_PUB_REMAIN, MQTT_NOSTATE);
+ else if(packet == MQTT_MSG_SUBACK) {
+ mqstate(conn, MQTT_SUBACK_COMING, MQTT_NOSTATE);
+ goto MQTT_SUBACK_COMING;
+ }
+ else if(packet == MQTT_MSG_DISCONNECT) {
+ infof(data, "Got DISCONNECT\n");
+ *done = TRUE;
+ goto end;
+ }
+ else {
+ result = CURLE_WEIRD_SERVER_REPLY;
+ goto end;
+ }
+
+ /* -- switched state -- */
+ remlen = mq->remaining_length;
+ infof(data, "Remaining length: %zd bytes\n", remlen);
+ Curl_pgrsSetDownloadSize(data, remlen);
+ data->req.bytecount = 0;
+ data->req.size = remlen;
+ mq->npacket = remlen; /* get this many bytes */
+ /* FALLTHROUGH */
+ case MQTT_PUB_REMAIN: {
+ /* read rest of packet, but no more. Cap to buffer size */
+ struct SingleRequest *k = &data->req;
+ size_t rest = mq->npacket;
+ if(rest > (size_t)data->set.buffer_size)
+ rest = (size_t)data->set.buffer_size;
+ result = Curl_read(conn, sockfd, (char *)pkt, rest, &nread);
+ if(result) {
+ if(CURLE_AGAIN == result) {
+ infof(data, "EEEE AAAAGAIN\n");
+ }
+ goto end;
+ }
+ if(!nread) {
+ infof(data, "server disconnected\n");
+ result = CURLE_PARTIAL_FILE;
+ goto end;
+ }
+ Curl_debug(data, CURLINFO_DATA_IN, (char *)pkt, (size_t)nread);
+
+ mq->npacket -= nread;
+ k->bytecount += nread;
+ Curl_pgrsSetDownloadCounter(data, k->bytecount);
+
+ /* if QoS is set, message contains packet id */
+
+ result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)pkt, nread);
+ if(result)
+ goto end;
+
+ if(!mq->npacket)
+ /* no more PUBLISH payload, back to subscribe wait state */
+ mqstate(conn, MQTT_FIRST, MQTT_PUBWAIT);
+ break;
+ }
+ default:
+ DEBUGASSERT(NULL); /* illegal state */
+ result = CURLE_WEIRD_SERVER_REPLY;
+ goto end;
+ }
+ end:
+ return result;
+}
+
+static CURLcode mqtt_do(struct connectdata *conn, bool *done)
+{
+ CURLcode result = CURLE_OK;
+ struct Curl_easy *data = conn->data;
+
+ *done = FALSE; /* unconditionally */
+
+ result = mqtt_connect(conn);
+ if(result) {
+ failf(data, "Error %d sending MQTT CONN request", result);
+ return result;
+ }
+ mqstate(conn, MQTT_FIRST, MQTT_CONNACK);
+ return CURLE_OK;
+}
+
+static CURLcode mqtt_doing(struct connectdata *conn, bool *done)
+{
+ CURLcode result = CURLE_OK;
+ struct mqtt_conn *mqtt = &conn->proto.mqtt;
+ struct Curl_easy *data = conn->data;
+ struct MQTT *mq = data->req.p.mqtt;
+ ssize_t nread;
+ curl_socket_t sockfd = conn->sock[FIRSTSOCKET];
+ unsigned char *pkt = (unsigned char *)data->state.buffer;
+ unsigned char byte;
+
+ *done = FALSE;
+
+ if(mq->nsend) {
+ /* send the remainder of an outgoing packet */
+ char *ptr = mq->sendleftovers;
+ result = mqtt_send(conn, mq->sendleftovers, mq->nsend);
+ free(ptr);
+ if(result)
+ return result;
+ }
+
+ infof(data, "mqtt_doing: state [%d]\n", (int) mqtt->state);
+ switch(mqtt->state) {
+ case MQTT_FIRST:
+ /* Read the initial byte only */
+ result = Curl_read(conn, sockfd, (char *)&mq->firstbyte, 1, &nread);
+ if(result)
+ break;
+ Curl_debug(data, CURLINFO_HEADER_IN, (char *)&mq->firstbyte, 1);
+ /* remember the first byte */
+ mq->npacket = 0;
+ mqstate(conn, MQTT_REMAINING_LENGTH, MQTT_NOSTATE);
+ /* FALLTHROUGH */
+ case MQTT_REMAINING_LENGTH:
+ do {
+ result = Curl_read(conn, sockfd, (char *)&byte, 1, &nread);
+ if(result)
+ break;
+ Curl_debug(data, CURLINFO_HEADER_IN, (char *)&byte, 1);
+ pkt[mq->npacket++] = byte;
+ } while((byte & 0x80) && (mq->npacket < 4));
+ if(result)
+ break;
+ mq->remaining_length = mqtt_decode_len(&pkt[0], mq->npacket, NULL);
+ mq->npacket = 0;
+ if(mq->remaining_length) {
+ mqstate(conn, mqtt->nextstate, MQTT_NOSTATE);
+ break;
+ }
+ mqstate(conn, MQTT_FIRST, MQTT_FIRST);
+
+ if(mq->firstbyte == MQTT_MSG_DISCONNECT) {
+ infof(data, "Got DISCONNECT\n");
+ *done = TRUE;
+ }
+ break;
+ case MQTT_CONNACK:
+ result = mqtt_verify_connack(conn);
+ if(result)
+ break;
+
+ if(conn->data->state.httpreq == HTTPREQ_POST) {
+ result = mqtt_publish(conn);
+ if(!result) {
+ result = mqtt_disconnect(conn);
+ *done = TRUE;
+ }
+ mqtt->nextstate = MQTT_FIRST;
+ }
+ else {
+ result = mqtt_subscribe(conn);
+ if(!result) {
+ mqstate(conn, MQTT_FIRST, MQTT_SUBACK);
+ }
+ }
+ break;
+
+ case MQTT_SUBACK:
+ case MQTT_PUBWAIT:
+ case MQTT_PUB_REMAIN:
+ result = mqtt_read_publish(conn, done);
+ break;
+
+ default:
+ failf(conn->data, "State not handled yet");
+ *done = TRUE;
+ break;
+ }
+
+ if(result == CURLE_AGAIN)
+ result = CURLE_OK;
+ return result;
+}
+
+#endif /* CURL_DISABLE_MQTT */
diff --git a/contrib/libs/curl/lib/mqtt.h b/contrib/libs/curl/lib/mqtt.h
index b16da802b3..fb52c72326 100644
--- a/contrib/libs/curl/lib/mqtt.h
+++ b/contrib/libs/curl/lib/mqtt.h
@@ -1,59 +1,59 @@
-#ifndef HEADER_CURL_MQTT_H
-#define HEADER_CURL_MQTT_H
-/***************************************************************************
- * _ _ ____ _
- * Project ___| | | | _ \| |
- * / __| | | | |_) | |
- * | (__| |_| | _ <| |___
- * \___|\___/|_| \_\_____|
- *
- * Copyright (C) 2019 - 2020, Björn Stenberg, <bjorn@haxx.se>
- *
- * This software is licensed as described in the file COPYING, which
- * you should have received as part of this distribution. The terms
- * are also available at https://curl.se/docs/copyright.html.
- *
- * You may opt to use, copy, modify, merge, publish, distribute and/or sell
- * copies of the Software, and permit persons to whom the Software is
- * furnished to do so, under the terms of the COPYING file.
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- ***************************************************************************/
-
-#ifndef CURL_DISABLE_MQTT
-extern const struct Curl_handler Curl_handler_mqtt;
-#endif
-
-enum mqttstate {
- MQTT_FIRST, /* 0 */
- MQTT_REMAINING_LENGTH, /* 1 */
- MQTT_CONNACK, /* 2 */
- MQTT_SUBACK, /* 3 */
- MQTT_SUBACK_COMING, /* 4 - the SUBACK remainder */
- MQTT_PUBWAIT, /* 5 - wait for publish */
- MQTT_PUB_REMAIN, /* 6 - wait for the remainder of the publish */
-
- MQTT_NOSTATE /* 7 - never used an actual state */
-};
-
-struct mqtt_conn {
- enum mqttstate state;
- enum mqttstate nextstate; /* switch to this after remaining length is
- done */
- unsigned int packetid;
-};
-
-/* protocol-specific transfer-related data */
-struct MQTT {
- char *sendleftovers;
- size_t nsend; /* size of sendleftovers */
-
- /* when receiving */
- size_t npacket; /* byte counter */
- unsigned char firstbyte;
- size_t remaining_length;
-};
-
-#endif /* HEADER_CURL_MQTT_H */
+#ifndef HEADER_CURL_MQTT_H
+#define HEADER_CURL_MQTT_H
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 2019 - 2020, Björn Stenberg, <bjorn@haxx.se>
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at https://curl.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+
+#ifndef CURL_DISABLE_MQTT
+extern const struct Curl_handler Curl_handler_mqtt;
+#endif
+
+enum mqttstate {
+ MQTT_FIRST, /* 0 */
+ MQTT_REMAINING_LENGTH, /* 1 */
+ MQTT_CONNACK, /* 2 */
+ MQTT_SUBACK, /* 3 */
+ MQTT_SUBACK_COMING, /* 4 - the SUBACK remainder */
+ MQTT_PUBWAIT, /* 5 - wait for publish */
+ MQTT_PUB_REMAIN, /* 6 - wait for the remainder of the publish */
+
+ MQTT_NOSTATE /* 7 - never used an actual state */
+};
+
+struct mqtt_conn {
+ enum mqttstate state;
+ enum mqttstate nextstate; /* switch to this after remaining length is
+ done */
+ unsigned int packetid;
+};
+
+/* protocol-specific transfer-related data */
+struct MQTT {
+ char *sendleftovers;
+ size_t nsend; /* size of sendleftovers */
+
+ /* when receiving */
+ size_t npacket; /* byte counter */
+ unsigned char firstbyte;
+ size_t remaining_length;
+};
+
+#endif /* HEADER_CURL_MQTT_H */
diff --git a/contrib/libs/curl/lib/multi.c b/contrib/libs/curl/lib/multi.c
index 08c6686157..f1c9e4dbfb 100644
--- a/contrib/libs/curl/lib/multi.c
+++ b/contrib/libs/curl/lib/multi.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -46,8 +46,8 @@
#include "connect.h"
#include "http_proxy.h"
#include "http2.h"
-#include "socketpair.h"
-#include "socks.h"
+#include "socketpair.h"
+#include "socks.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
#include "curl_memory.h"
@@ -111,7 +111,7 @@ static void Curl_init_completed(struct Curl_easy *data)
/* Important: reset the conn pointer so that we don't point to memory
that could be freed anytime */
- Curl_detach_connnection(data);
+ Curl_detach_connnection(data);
Curl_expire_clear(data); /* stop all timers */
}
@@ -168,11 +168,11 @@ static void mstate(struct Curl_easy *data, CURLMstate state
}
#endif
- if(state == CURLM_STATE_COMPLETED) {
+ if(state == CURLM_STATE_COMPLETED) {
/* changing to COMPLETED means there's one less easy handle 'alive' */
- DEBUGASSERT(data->multi->num_alive > 0);
+ DEBUGASSERT(data->multi->num_alive > 0);
data->multi->num_alive--;
- }
+ }
/* if this state has an init-function, run it */
if(finit[state])
@@ -190,7 +190,7 @@ static void mstate(struct Curl_easy *data, CURLMstate state
*/
struct Curl_sh_entry {
- struct Curl_hash transfers; /* hash of transfers using this socket */
+ struct Curl_hash transfers; /* hash of transfers using this socket */
unsigned int action; /* what combined action READ/WRITE this socket waits
for */
void *socketp; /* settable by users with curl_multi_assign() */
@@ -204,7 +204,7 @@ struct Curl_sh_entry {
#define SH_WRITE 2
/* look up a given socket in the socket hash, skip invalid sockets */
-static struct Curl_sh_entry *sh_getentry(struct Curl_hash *sh,
+static struct Curl_sh_entry *sh_getentry(struct Curl_hash *sh,
curl_socket_t s)
{
if(s != CURL_SOCKET_BAD) {
@@ -238,7 +238,7 @@ static void trhash_dtor(void *nada)
/* make sure this socket is present in the hash for this handle */
-static struct Curl_sh_entry *sh_addentry(struct Curl_hash *sh,
+static struct Curl_sh_entry *sh_addentry(struct Curl_hash *sh,
curl_socket_t s)
{
struct Curl_sh_entry *there = sh_getentry(sh, s);
@@ -262,7 +262,7 @@ static struct Curl_sh_entry *sh_addentry(struct Curl_hash *sh,
/* make/add new hash entry */
if(!Curl_hash_add(sh, (char *)&s, sizeof(curl_socket_t), check)) {
- Curl_hash_destroy(&check->transfers);
+ Curl_hash_destroy(&check->transfers);
free(check);
return NULL; /* major failure */
}
@@ -273,7 +273,7 @@ static struct Curl_sh_entry *sh_addentry(struct Curl_hash *sh,
/* delete the given socket + handle from the hash */
static void sh_delentry(struct Curl_sh_entry *entry,
- struct Curl_hash *sh, curl_socket_t s)
+ struct Curl_hash *sh, curl_socket_t s)
{
Curl_hash_destroy(&entry->transfers);
@@ -325,7 +325,7 @@ static size_t hash_fd(void *key, size_t key_length, size_t slots_num)
* per call."
*
*/
-static int sh_init(struct Curl_hash *hash, int hashsize)
+static int sh_init(struct Curl_hash *hash, int hashsize)
{
return Curl_hash_init(hash, hashsize, hash_fd, fd_key_compare,
sh_freeentry);
@@ -367,27 +367,27 @@ struct Curl_multi *Curl_multi_handle(int hashsize, /* socket hash */
Curl_llist_init(&multi->msglist, NULL);
Curl_llist_init(&multi->pending, NULL);
- multi->multiplexing = TRUE;
+ multi->multiplexing = TRUE;
/* -1 means it not set by user, use the default value */
multi->maxconnects = -1;
- multi->max_concurrent_streams = 100;
- multi->ipv6_works = Curl_ipv6works(NULL);
-
-#ifdef ENABLE_WAKEUP
- if(Curl_socketpair(AF_UNIX, SOCK_STREAM, 0, multi->wakeup_pair) < 0) {
- multi->wakeup_pair[0] = CURL_SOCKET_BAD;
- multi->wakeup_pair[1] = CURL_SOCKET_BAD;
- }
- else if(curlx_nonblock(multi->wakeup_pair[0], TRUE) < 0 ||
- curlx_nonblock(multi->wakeup_pair[1], TRUE) < 0) {
- sclose(multi->wakeup_pair[0]);
- sclose(multi->wakeup_pair[1]);
- multi->wakeup_pair[0] = CURL_SOCKET_BAD;
- multi->wakeup_pair[1] = CURL_SOCKET_BAD;
- }
-#endif
-
+ multi->max_concurrent_streams = 100;
+ multi->ipv6_works = Curl_ipv6works(NULL);
+
+#ifdef ENABLE_WAKEUP
+ if(Curl_socketpair(AF_UNIX, SOCK_STREAM, 0, multi->wakeup_pair) < 0) {
+ multi->wakeup_pair[0] = CURL_SOCKET_BAD;
+ multi->wakeup_pair[1] = CURL_SOCKET_BAD;
+ }
+ else if(curlx_nonblock(multi->wakeup_pair[0], TRUE) < 0 ||
+ curlx_nonblock(multi->wakeup_pair[1], TRUE) < 0) {
+ sclose(multi->wakeup_pair[0]);
+ sclose(multi->wakeup_pair[1]);
+ multi->wakeup_pair[0] = CURL_SOCKET_BAD;
+ multi->wakeup_pair[1] = CURL_SOCKET_BAD;
+ }
+#endif
+
return multi;
error:
@@ -455,7 +455,7 @@ CURLMcode curl_multi_add_handle(struct Curl_multi *multi,
data->state.conn_cache = &data->share->conn_cache;
else
data->state.conn_cache = &multi->conn_cache;
- data->state.lastconnect_id = -1;
+ data->state.lastconnect_id = -1;
#ifdef USE_LIBPSL
/* Do the same for PSL. */
@@ -508,7 +508,7 @@ CURLMcode curl_multi_add_handle(struct Curl_multi *multi,
easy handle is added */
memset(&multi->timer_lastcall, 0, sizeof(multi->timer_lastcall));
- CONNCACHE_LOCK(data);
+ CONNCACHE_LOCK(data);
/* The closure handle only ever has default timeouts set. To improve the
state somewhat we clone the timeouts from each added handle so that the
closure handle always has the same timeouts as the most recently added
@@ -518,7 +518,7 @@ CURLMcode curl_multi_add_handle(struct Curl_multi *multi,
data->set.server_response_timeout;
data->state.conn_cache->closure_handle->set.no_signal =
data->set.no_signal;
- CONNCACHE_UNLOCK(data);
+ CONNCACHE_UNLOCK(data);
Curl_update_timer(multi);
return CURLM_OK;
@@ -555,8 +555,8 @@ static CURLcode multi_done(struct Curl_easy *data,
/* Stop if multi_done() has already been called */
return CURLE_OK;
- conn->data = data; /* ensure the connection uses this transfer now */
-
+ conn->data = data; /* ensure the connection uses this transfer now */
+
/* Cancel the resolver (but not dns_entry yet). We used to call
Curl_resolver_kill here but that blocks waiting for incomplete resolve
threads (eg getaddrinfo has not returned), which may take a while. */
@@ -595,20 +595,20 @@ static CURLcode multi_done(struct Curl_easy *data,
process_pending_handles(data->multi); /* connection / multiplex */
- CONNCACHE_LOCK(data);
- Curl_detach_connnection(data);
+ CONNCACHE_LOCK(data);
+ Curl_detach_connnection(data);
if(CONN_INUSE(conn)) {
- /* Stop if still used. */
+ /* Stop if still used. */
/* conn->data must not remain pointing to this transfer since it is going
away! Find another to own it! */
conn->data = conn->easyq.head->ptr;
- CONNCACHE_UNLOCK(data);
+ CONNCACHE_UNLOCK(data);
DEBUGF(infof(data, "Connection still in use %zu, "
"no more multi_done now!\n",
conn->easyq.size));
return CURLE_OK;
}
- conn->data = NULL; /* the connection now has no owner */
+ conn->data = NULL; /* the connection now has no owner */
data->state.done = TRUE; /* called just now! */
if(conn->dns_entry) {
@@ -621,7 +621,7 @@ static CURLcode multi_done(struct Curl_easy *data,
/* if the transfer was completed in a paused state there can be buffered
data left to free */
for(i = 0; i < data->state.tempcount; i++) {
- Curl_dyn_free(&data->state.tempwrite[i].b);
+ Curl_dyn_free(&data->state.tempwrite[i].b);
}
data->state.tempcount = 0;
@@ -651,11 +651,11 @@ static CURLcode multi_done(struct Curl_easy *data,
#endif
) || conn->bits.close
|| (premature && !(conn->handler->flags & PROTOPT_STREAM))) {
- CURLcode res2;
- connclose(conn, "disconnecting");
- Curl_conncache_remove_conn(data, conn, FALSE);
- CONNCACHE_UNLOCK(data);
- res2 = Curl_disconnect(data, conn, premature);
+ CURLcode res2;
+ connclose(conn, "disconnecting");
+ Curl_conncache_remove_conn(data, conn, FALSE);
+ CONNCACHE_UNLOCK(data);
+ res2 = Curl_disconnect(data, conn, premature);
/* If we had an error already, make sure we return that one. But
if we got a new error, return that. */
@@ -664,61 +664,61 @@ static CURLcode multi_done(struct Curl_easy *data,
}
else {
char buffer[256];
- const char *host =
-#ifndef CURL_DISABLE_PROXY
- conn->bits.socksproxy ?
- conn->socks_proxy.host.dispname :
- conn->bits.httpproxy ? conn->http_proxy.host.dispname :
-#endif
- conn->bits.conn_to_host ? conn->conn_to_host.dispname :
- conn->host.dispname;
+ const char *host =
+#ifndef CURL_DISABLE_PROXY
+ conn->bits.socksproxy ?
+ conn->socks_proxy.host.dispname :
+ conn->bits.httpproxy ? conn->http_proxy.host.dispname :
+#endif
+ conn->bits.conn_to_host ? conn->conn_to_host.dispname :
+ conn->host.dispname;
/* create string before returning the connection */
msnprintf(buffer, sizeof(buffer),
"Connection #%ld to host %s left intact",
- conn->connection_id, host);
+ conn->connection_id, host);
/* the connection is no longer in use by this transfer */
- CONNCACHE_UNLOCK(data);
- if(Curl_conncache_return_conn(data, conn)) {
+ CONNCACHE_UNLOCK(data);
+ if(Curl_conncache_return_conn(data, conn)) {
/* remember the most recently used connection */
- data->state.lastconnect_id = conn->connection_id;
+ data->state.lastconnect_id = conn->connection_id;
infof(data, "%s\n", buffer);
}
else
- data->state.lastconnect_id = -1;
+ data->state.lastconnect_id = -1;
}
- Curl_safefree(data->state.buffer);
+ Curl_safefree(data->state.buffer);
Curl_free_request_state(data);
return result;
}
-static int close_connect_only(struct connectdata *conn, void *param)
-{
- struct Curl_easy *data = param;
-
- if(data->state.lastconnect_id != conn->connection_id)
- return 0;
-
- if(conn->data != data)
- return 1;
- conn->data = NULL;
-
- if(!conn->bits.connect_only)
- return 1;
-
- connclose(conn, "Removing connect-only easy handle");
- conn->bits.connect_only = FALSE;
-
- return 1;
-}
-
+static int close_connect_only(struct connectdata *conn, void *param)
+{
+ struct Curl_easy *data = param;
+
+ if(data->state.lastconnect_id != conn->connection_id)
+ return 0;
+
+ if(conn->data != data)
+ return 1;
+ conn->data = NULL;
+
+ if(!conn->bits.connect_only)
+ return 1;
+
+ connclose(conn, "Removing connect-only easy handle");
+ conn->bits.connect_only = FALSE;
+
+ return 1;
+}
+
CURLMcode curl_multi_remove_handle(struct Curl_multi *multi,
struct Curl_easy *data)
{
struct Curl_easy *easy = data;
bool premature;
bool easy_owns_conn;
- struct Curl_llist_element *e;
+ struct Curl_llist_element *e;
/* First, make some basic checks that the CURLM handle is a good handle */
if(!GOOD_MULTI_HANDLE(multi))
@@ -732,10 +732,10 @@ CURLMcode curl_multi_remove_handle(struct Curl_multi *multi,
if(!data->multi)
return CURLM_OK; /* it is already removed so let's say it is fine! */
- /* Prevent users from trying to remove an easy handle from the wrong multi */
- if(data->multi != multi)
- return CURLM_BAD_EASY_HANDLE;
-
+ /* Prevent users from trying to remove an easy handle from the wrong multi */
+ if(data->multi != multi)
+ return CURLM_BAD_EASY_HANDLE;
+
if(multi->in_callback)
return CURLM_RECURSIVE_API_CALL;
@@ -767,8 +767,8 @@ CURLMcode curl_multi_remove_handle(struct Curl_multi *multi,
we don't leave a half-baked one around */
if(easy_owns_conn) {
- /* multi_done() clears the association between the easy handle and the
- connection.
+ /* multi_done() clears the association between the easy handle and the
+ connection.
Note that this ignores the return code simply because there's
nothing really useful to do with it anyway! */
@@ -776,11 +776,11 @@ CURLMcode curl_multi_remove_handle(struct Curl_multi *multi,
}
}
- /* The timer must be shut down before data->multi is set to NULL, else the
- timenode will remain in the splay tree after curl_easy_cleanup is
- called. Do it after multi_done() in case that sets another time! */
- Curl_expire_clear(data);
-
+ /* The timer must be shut down before data->multi is set to NULL, else the
+ timenode will remain in the splay tree after curl_easy_cleanup is
+ called. Do it after multi_done() in case that sets another time! */
+ Curl_expire_clear(data);
+
if(data->connect_queue.ptr)
/* the handle was in the pending list waiting for an available connection,
so go ahead and remove it */
@@ -806,12 +806,12 @@ CURLMcode curl_multi_remove_handle(struct Curl_multi *multi,
vanish with this handle */
/* Remove the association between the connection and the handle */
- Curl_detach_connnection(data);
-
- if(data->state.lastconnect_id != -1) {
- /* Mark any connect-only connection for closure */
- Curl_conncache_foreach(data, data->state.conn_cache,
- data, &close_connect_only);
+ Curl_detach_connnection(data);
+
+ if(data->state.lastconnect_id != -1) {
+ /* Mark any connect-only connection for closure */
+ Curl_conncache_foreach(data, data->state.conn_cache,
+ data, &close_connect_only);
}
#ifdef USE_LIBPSL
@@ -820,10 +820,10 @@ CURLMcode curl_multi_remove_handle(struct Curl_multi *multi,
data->psl = NULL;
#endif
- /* as this was using a shared connection cache we clear the pointer to that
- since we're not part of that multi handle anymore */
- data->state.conn_cache = NULL;
-
+ /* as this was using a shared connection cache we clear the pointer to that
+ since we're not part of that multi handle anymore */
+ data->state.conn_cache = NULL;
+
data->multi = NULL; /* clear the association to this multi handle */
/* make sure there's no pending message in the queue sent from this easy
@@ -865,13 +865,13 @@ bool Curl_multiplex_wanted(const struct Curl_multi *multi)
return (multi && (multi->multiplexing));
}
-/*
- * Curl_detach_connnection() removes the given transfer from the connection.
- *
- * This is the only function that should clear data->conn. This will
- * occasionally be called with the data->conn pointer already cleared.
- */
-void Curl_detach_connnection(struct Curl_easy *data)
+/*
+ * Curl_detach_connnection() removes the given transfer from the connection.
+ *
+ * This is the only function that should clear data->conn. This will
+ * occasionally be called with the data->conn pointer already cleared.
+ */
+void Curl_detach_connnection(struct Curl_easy *data)
{
struct connectdata *conn = data->conn;
if(conn)
@@ -879,11 +879,11 @@ void Curl_detach_connnection(struct Curl_easy *data)
data->conn = NULL;
}
-/*
- * Curl_attach_connnection() attaches this transfer to this connection.
- *
- * This is the only function that should assign data->conn
- */
+/*
+ * Curl_attach_connnection() attaches this transfer to this connection.
+ *
+ * This is the only function that should assign data->conn
+ */
void Curl_attach_connnection(struct Curl_easy *data,
struct connectdata *conn)
{
@@ -902,15 +902,15 @@ static int waitconnect_getsock(struct connectdata *conn,
int rc = 0;
#ifdef USE_SSL
-#ifndef CURL_DISABLE_PROXY
+#ifndef CURL_DISABLE_PROXY
if(CONNECT_FIRSTSOCKET_PROXY_SSL())
return Curl_ssl_getsock(conn, sock);
#endif
-#endif
+#endif
+
+ if(SOCKS_STATE(conn->cnnct.state))
+ return Curl_SOCKS_getsock(conn, sock, FIRSTSOCKET);
- if(SOCKS_STATE(conn->cnnct.state))
- return Curl_SOCKS_getsock(conn, sock, FIRSTSOCKET);
-
for(i = 0; i<2; i++) {
if(conn->tempsock[i] != CURL_SOCKET_BAD) {
sock[s] = conn->tempsock[i];
@@ -1074,8 +1074,8 @@ static CURLMcode Curl_multi_wait(struct Curl_multi *multi,
unsigned int extra_nfds,
int timeout_ms,
int *ret,
- bool extrawait, /* when no socket, wait */
- bool use_wakeup)
+ bool extrawait, /* when no socket, wait */
+ bool use_wakeup)
{
struct Curl_easy *data;
curl_socket_t sockbunch[MAX_SOCKSPEREASYHANDLE];
@@ -1087,7 +1087,7 @@ static CURLMcode Curl_multi_wait(struct Curl_multi *multi,
int retcode = 0;
struct pollfd a_few_on_stack[NUM_POLLS_ON_STACK];
struct pollfd *ufds = &a_few_on_stack[0];
- bool ufds_malloc = FALSE;
+ bool ufds_malloc = FALSE;
if(!GOOD_MULTI_HANDLE(multi))
return CURLM_BAD_HANDLE;
@@ -1095,9 +1095,9 @@ static CURLMcode Curl_multi_wait(struct Curl_multi *multi,
if(multi->in_callback)
return CURLM_RECURSIVE_API_CALL;
- if(timeout_ms < 0)
- return CURLM_BAD_FUNCTION_ARGUMENT;
-
+ if(timeout_ms < 0)
+ return CURLM_BAD_FUNCTION_ARGUMENT;
+
/* Count up how many fds we have from the multi handle */
data = multi->easyp;
while(data) {
@@ -1132,12 +1132,12 @@ static CURLMcode Curl_multi_wait(struct Curl_multi *multi,
curlfds = nfds; /* number of internal file descriptors */
nfds += extra_nfds; /* add the externally provided ones */
-#ifdef ENABLE_WAKEUP
- if(use_wakeup && multi->wakeup_pair[0] != CURL_SOCKET_BAD) {
- ++nfds;
- }
-#endif
-
+#ifdef ENABLE_WAKEUP
+ if(use_wakeup && multi->wakeup_pair[0] != CURL_SOCKET_BAD) {
+ ++nfds;
+ }
+#endif
+
if(nfds > NUM_POLLS_ON_STACK) {
/* 'nfds' is a 32 bit value and 'struct pollfd' is typically 8 bytes
big, so at 2^29 sockets this value might wrap. When a process gets
@@ -1159,7 +1159,7 @@ static CURLMcode Curl_multi_wait(struct Curl_multi *multi,
while(data) {
bitmap = multi_getsock(data, sockbunch);
- for(i = 0; i < MAX_SOCKSPEREASYHANDLE; i++) {
+ for(i = 0; i < MAX_SOCKSPEREASYHANDLE; i++) {
curl_socket_t s = CURL_SOCKET_BAD;
if(bitmap & GETSOCK_READSOCK(i)) {
@@ -1196,17 +1196,17 @@ static CURLMcode Curl_multi_wait(struct Curl_multi *multi,
++nfds;
}
-#ifdef ENABLE_WAKEUP
- if(use_wakeup && multi->wakeup_pair[0] != CURL_SOCKET_BAD) {
- ufds[nfds].fd = multi->wakeup_pair[0];
- ufds[nfds].events = POLLIN;
- ++nfds;
- }
-#endif
-
+#ifdef ENABLE_WAKEUP
+ if(use_wakeup && multi->wakeup_pair[0] != CURL_SOCKET_BAD) {
+ ufds[nfds].fd = multi->wakeup_pair[0];
+ ufds[nfds].events = POLLIN;
+ ++nfds;
+ }
+#endif
+
if(nfds) {
/* wait... */
- int pollrc = Curl_poll(ufds, nfds, timeout_ms);
+ int pollrc = Curl_poll(ufds, nfds, timeout_ms);
if(pollrc > 0) {
retcode = pollrc;
/* copy revents results from the poll to the curl_multi_wait poll
@@ -1224,31 +1224,31 @@ static CURLMcode Curl_multi_wait(struct Curl_multi *multi,
mask |= CURL_WAIT_POLLPRI;
extra_fds[i].revents = mask;
}
-
-#ifdef ENABLE_WAKEUP
- if(use_wakeup && multi->wakeup_pair[0] != CURL_SOCKET_BAD) {
- if(ufds[curlfds + extra_nfds].revents & POLLIN) {
- char buf[64];
- ssize_t nread;
- while(1) {
- /* the reading socket is non-blocking, try to read
- data from it until it receives an error (except EINTR).
- In normal cases it will get EAGAIN or EWOULDBLOCK
- when there is no more data, breaking the loop. */
- nread = sread(multi->wakeup_pair[0], buf, sizeof(buf));
- if(nread <= 0) {
-#ifndef USE_WINSOCK
- if(nread < 0 && EINTR == SOCKERRNO)
- continue;
-#endif
- break;
- }
- }
- /* do not count the wakeup socket into the returned value */
- retcode--;
- }
- }
-#endif
+
+#ifdef ENABLE_WAKEUP
+ if(use_wakeup && multi->wakeup_pair[0] != CURL_SOCKET_BAD) {
+ if(ufds[curlfds + extra_nfds].revents & POLLIN) {
+ char buf[64];
+ ssize_t nread;
+ while(1) {
+ /* the reading socket is non-blocking, try to read
+ data from it until it receives an error (except EINTR).
+ In normal cases it will get EAGAIN or EWOULDBLOCK
+ when there is no more data, breaking the loop. */
+ nread = sread(multi->wakeup_pair[0], buf, sizeof(buf));
+ if(nread <= 0) {
+#ifndef USE_WINSOCK
+ if(nread < 0 && EINTR == SOCKERRNO)
+ continue;
+#endif
+ break;
+ }
+ }
+ /* do not count the wakeup socket into the returned value */
+ retcode--;
+ }
+ }
+#endif
}
}
@@ -1256,7 +1256,7 @@ static CURLMcode Curl_multi_wait(struct Curl_multi *multi,
free(ufds);
if(ret)
*ret = retcode;
- if(!extrawait || nfds)
+ if(!extrawait || nfds)
/* if any socket was checked */
;
else {
@@ -1266,11 +1266,11 @@ static CURLMcode Curl_multi_wait(struct Curl_multi *multi,
if(!curl_multi_timeout(multi, &sleep_ms) && sleep_ms) {
if(sleep_ms > timeout_ms)
sleep_ms = timeout_ms;
- /* when there are no easy handles in the multi, this holds a -1
- timeout */
- else if(sleep_ms < 0)
- sleep_ms = timeout_ms;
- Curl_wait_ms(sleep_ms);
+ /* when there are no easy handles in the multi, this holds a -1
+ timeout */
+ else if(sleep_ms < 0)
+ sleep_ms = timeout_ms;
+ Curl_wait_ms(sleep_ms);
}
}
@@ -1283,8 +1283,8 @@ CURLMcode curl_multi_wait(struct Curl_multi *multi,
int timeout_ms,
int *ret)
{
- return Curl_multi_wait(multi, extra_fds, extra_nfds, timeout_ms, ret, FALSE,
- FALSE);
+ return Curl_multi_wait(multi, extra_fds, extra_nfds, timeout_ms, ret, FALSE,
+ FALSE);
}
CURLMcode curl_multi_poll(struct Curl_multi *multi,
@@ -1293,57 +1293,57 @@ CURLMcode curl_multi_poll(struct Curl_multi *multi,
int timeout_ms,
int *ret)
{
- return Curl_multi_wait(multi, extra_fds, extra_nfds, timeout_ms, ret, TRUE,
- TRUE);
-}
-
-CURLMcode curl_multi_wakeup(struct Curl_multi *multi)
-{
- /* this function is usually called from another thread,
- it has to be careful only to access parts of the
- Curl_multi struct that are constant */
-
- /* GOOD_MULTI_HANDLE can be safely called */
- if(!GOOD_MULTI_HANDLE(multi))
- return CURLM_BAD_HANDLE;
-
-#ifdef ENABLE_WAKEUP
- /* the wakeup_pair variable is only written during init and cleanup,
- making it safe to access from another thread after the init part
- and before cleanup */
- if(multi->wakeup_pair[1] != CURL_SOCKET_BAD) {
- char buf[1];
- buf[0] = 1;
- while(1) {
- /* swrite() is not thread-safe in general, because concurrent calls
- can have their messages interleaved, but in this case the content
- of the messages does not matter, which makes it ok to call.
-
- The write socket is set to non-blocking, this way this function
- cannot block, making it safe to call even from the same thread
- that will call Curl_multi_wait(). If swrite() returns that it
- would block, it's considered successful because it means that
- previous calls to this function will wake up the poll(). */
- if(swrite(multi->wakeup_pair[1], buf, sizeof(buf)) < 0) {
- int err = SOCKERRNO;
- int return_success;
-#ifdef USE_WINSOCK
- return_success = WSAEWOULDBLOCK == err;
-#else
- if(EINTR == err)
- continue;
- return_success = EWOULDBLOCK == err || EAGAIN == err;
-#endif
- if(!return_success)
- return CURLM_WAKEUP_FAILURE;
- }
- return CURLM_OK;
- }
- }
-#endif
- return CURLM_WAKEUP_FAILURE;
-}
-
+ return Curl_multi_wait(multi, extra_fds, extra_nfds, timeout_ms, ret, TRUE,
+ TRUE);
+}
+
+CURLMcode curl_multi_wakeup(struct Curl_multi *multi)
+{
+ /* this function is usually called from another thread,
+ it has to be careful only to access parts of the
+ Curl_multi struct that are constant */
+
+ /* GOOD_MULTI_HANDLE can be safely called */
+ if(!GOOD_MULTI_HANDLE(multi))
+ return CURLM_BAD_HANDLE;
+
+#ifdef ENABLE_WAKEUP
+ /* the wakeup_pair variable is only written during init and cleanup,
+ making it safe to access from another thread after the init part
+ and before cleanup */
+ if(multi->wakeup_pair[1] != CURL_SOCKET_BAD) {
+ char buf[1];
+ buf[0] = 1;
+ while(1) {
+ /* swrite() is not thread-safe in general, because concurrent calls
+ can have their messages interleaved, but in this case the content
+ of the messages does not matter, which makes it ok to call.
+
+ The write socket is set to non-blocking, this way this function
+ cannot block, making it safe to call even from the same thread
+ that will call Curl_multi_wait(). If swrite() returns that it
+ would block, it's considered successful because it means that
+ previous calls to this function will wake up the poll(). */
+ if(swrite(multi->wakeup_pair[1], buf, sizeof(buf)) < 0) {
+ int err = SOCKERRNO;
+ int return_success;
+#ifdef USE_WINSOCK
+ return_success = WSAEWOULDBLOCK == err;
+#else
+ if(EINTR == err)
+ continue;
+ return_success = EWOULDBLOCK == err || EAGAIN == err;
+#endif
+ if(!return_success)
+ return CURLM_WAKEUP_FAILURE;
+ }
+ return CURLM_OK;
+ }
+ }
+#endif
+ return CURLM_WAKEUP_FAILURE;
+}
+
/*
* multi_ischanged() is called
*
@@ -1404,7 +1404,7 @@ static CURLcode multi_do(struct Curl_easy *data, bool *done)
DEBUGASSERT(conn);
DEBUGASSERT(conn->handler);
- DEBUGASSERT(conn->data == data);
+ DEBUGASSERT(conn->data == data);
if(conn->handler->do_it) {
/* generic protocol-specific function pointer set in curl_connect() */
@@ -1511,7 +1511,7 @@ static CURLcode protocol_connect(struct connectdata *conn,
}
if(!conn->bits.protoconnstart) {
-#ifndef CURL_DISABLE_PROXY
+#ifndef CURL_DISABLE_PROXY
result = Curl_proxy_connect(conn, FIRSTSOCKET);
if(result)
return result;
@@ -1525,7 +1525,7 @@ static CURLcode protocol_connect(struct connectdata *conn,
/* when using an HTTP tunnel proxy, await complete tunnel establishment
before proceeding further. Return CURLE_OK so we'll be called again */
return CURLE_OK;
-#endif
+#endif
if(conn->handler->connect_it) {
/* is there a protocol-specific connect() procedure? */
@@ -1544,24 +1544,24 @@ static CURLcode protocol_connect(struct connectdata *conn,
return result; /* pass back status */
}
-/*
- * Curl_preconnect() is called immediately before a connect starts. When a
- * redirect is followed, this is then called multiple times during a single
- * transfer.
- */
-CURLcode Curl_preconnect(struct Curl_easy *data)
-{
- if(!data->state.buffer) {
- data->state.buffer = malloc(data->set.buffer_size + 1);
- if(!data->state.buffer)
- return CURLE_OUT_OF_MEMORY;
- }
- return CURLE_OK;
-}
-
-
+/*
+ * Curl_preconnect() is called immediately before a connect starts. When a
+ * redirect is followed, this is then called multiple times during a single
+ * transfer.
+ */
+CURLcode Curl_preconnect(struct Curl_easy *data)
+{
+ if(!data->state.buffer) {
+ data->state.buffer = malloc(data->set.buffer_size + 1);
+ if(!data->state.buffer)
+ return CURLE_OUT_OF_MEMORY;
+ }
+ return CURLE_OK;
+}
+
+
static CURLMcode multi_runsingle(struct Curl_multi *multi,
- struct curltime *nowp,
+ struct curltime *nowp,
struct Curl_easy *data)
{
struct Curl_message *msg = NULL;
@@ -1602,7 +1602,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
(data->mstate < CURLM_STATE_COMPLETED)) {
/* we need to wait for the connect state as only then is the start time
stored, but we must not check already completed handles */
- timeout_ms = Curl_timeleft(data, nowp,
+ timeout_ms = Curl_timeleft(data, nowp,
(data->mstate <= CURLM_STATE_DO)?
TRUE:FALSE);
@@ -1611,25 +1611,25 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
if(data->mstate == CURLM_STATE_WAITRESOLVE)
failf(data, "Resolving timed out after %" CURL_FORMAT_TIMEDIFF_T
" milliseconds",
- Curl_timediff(*nowp, data->progress.t_startsingle));
+ Curl_timediff(*nowp, data->progress.t_startsingle));
else if(data->mstate == CURLM_STATE_WAITCONNECT)
failf(data, "Connection timed out after %" CURL_FORMAT_TIMEDIFF_T
" milliseconds",
- Curl_timediff(*nowp, data->progress.t_startsingle));
+ Curl_timediff(*nowp, data->progress.t_startsingle));
else {
struct SingleRequest *k = &data->req;
if(k->size != -1) {
failf(data, "Operation timed out after %" CURL_FORMAT_TIMEDIFF_T
" milliseconds with %" CURL_FORMAT_CURL_OFF_T " out of %"
CURL_FORMAT_CURL_OFF_T " bytes received",
- Curl_timediff(*nowp, data->progress.t_startsingle),
+ Curl_timediff(*nowp, data->progress.t_startsingle),
k->bytecount, k->size);
}
else {
failf(data, "Operation timed out after %" CURL_FORMAT_TIMEDIFF_T
" milliseconds with %" CURL_FORMAT_CURL_OFF_T
" bytes received",
- Curl_timediff(*nowp, data->progress.t_startsingle),
+ Curl_timediff(*nowp, data->progress.t_startsingle),
k->bytecount);
}
}
@@ -1654,7 +1654,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
if(!result) {
/* after init, go CONNECT */
multistate(data, CURLM_STATE_CONNECT);
- *nowp = Curl_pgrsTime(data, TIMER_STARTOP);
+ *nowp = Curl_pgrsTime(data, TIMER_STARTOP);
rc = CURLM_CALL_MULTI_PERFORM;
}
break;
@@ -1666,12 +1666,12 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
case CURLM_STATE_CONNECT:
/* Connect. We want to get a connection identifier filled in. */
- /* init this transfer. */
- result = Curl_preconnect(data);
- if(result)
- break;
-
- *nowp = Curl_pgrsTime(data, TIMER_STARTSINGLE);
+ /* init this transfer. */
+ result = Curl_preconnect(data);
+ if(result)
+ break;
+
+ *nowp = Curl_pgrsTime(data, TIMER_STARTSINGLE);
if(data->set.timeout)
Curl_expire(data, data->set.timeout, EXPIRE_TIMEOUT);
@@ -1728,12 +1728,12 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
const char *hostname;
DEBUGASSERT(conn);
-#ifndef CURL_DISABLE_PROXY
+#ifndef CURL_DISABLE_PROXY
if(conn->bits.httpproxy)
hostname = conn->http_proxy.host.name;
- else
-#endif
- if(conn->bits.conn_to_host)
+ else
+#endif
+ if(conn->bits.conn_to_host)
hostname = conn->conn_to_host.name;
else
hostname = conn->host.name;
@@ -1799,7 +1799,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
/* this is HTTP-specific, but sending CONNECT to a proxy is HTTP... */
DEBUGASSERT(data->conn);
result = Curl_http_connect(data->conn, &protocol_connected);
-#ifndef CURL_DISABLE_PROXY
+#ifndef CURL_DISABLE_PROXY
if(data->conn->bits.proxy_connect_closed) {
rc = CURLM_CALL_MULTI_PERFORM;
/* connect back to proxy again */
@@ -1807,21 +1807,21 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
multi_done(data, CURLE_OK, FALSE);
multistate(data, CURLM_STATE_CONNECT);
}
- else
-#endif
- if(!result) {
- if(
-#ifndef CURL_DISABLE_PROXY
- (data->conn->http_proxy.proxytype != CURLPROXY_HTTPS ||
- data->conn->bits.proxy_ssl_connected[FIRSTSOCKET]) &&
-#endif
- Curl_connect_complete(data->conn)) {
- rc = CURLM_CALL_MULTI_PERFORM;
- /* initiate protocol connect phase */
- multistate(data, CURLM_STATE_SENDPROTOCONNECT);
- }
+ else
+#endif
+ if(!result) {
+ if(
+#ifndef CURL_DISABLE_PROXY
+ (data->conn->http_proxy.proxytype != CURLPROXY_HTTPS ||
+ data->conn->bits.proxy_ssl_connected[FIRSTSOCKET]) &&
+#endif
+ Curl_connect_complete(data->conn)) {
+ rc = CURLM_CALL_MULTI_PERFORM;
+ /* initiate protocol connect phase */
+ multistate(data, CURLM_STATE_SENDPROTOCONNECT);
+ }
}
- else
+ else
stream_error = TRUE;
break;
#endif
@@ -1832,25 +1832,25 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
result = Curl_is_connected(data->conn, FIRSTSOCKET, &connected);
if(connected && !result) {
#ifndef CURL_DISABLE_HTTP
- if(
-#ifndef CURL_DISABLE_PROXY
- (data->conn->http_proxy.proxytype == CURLPROXY_HTTPS &&
- !data->conn->bits.proxy_ssl_connected[FIRSTSOCKET]) ||
-#endif
- Curl_connect_ongoing(data->conn)) {
+ if(
+#ifndef CURL_DISABLE_PROXY
+ (data->conn->http_proxy.proxytype == CURLPROXY_HTTPS &&
+ !data->conn->bits.proxy_ssl_connected[FIRSTSOCKET]) ||
+#endif
+ Curl_connect_ongoing(data->conn)) {
multistate(data, CURLM_STATE_WAITPROXYCONNECT);
break;
}
#endif
rc = CURLM_CALL_MULTI_PERFORM;
-#ifndef CURL_DISABLE_PROXY
- multistate(data,
- data->conn->bits.tunnel_proxy?
+#ifndef CURL_DISABLE_PROXY
+ multistate(data,
+ data->conn->bits.tunnel_proxy?
CURLM_STATE_WAITPROXYCONNECT:
CURLM_STATE_SENDPROTOCONNECT);
-#else
- multistate(data, CURLM_STATE_SENDPROTOCONNECT);
-#endif
+#else
+ multistate(data, CURLM_STATE_SENDPROTOCONNECT);
+#endif
}
else if(result) {
/* failure detected */
@@ -1871,7 +1871,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
multistate(data, CURLM_STATE_DO);
rc = CURLM_CALL_MULTI_PERFORM;
}
- else {
+ else {
/* failure detected */
Curl_posttransfer(data);
multi_done(data, result, TRUE);
@@ -2079,7 +2079,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
if(Curl_pgrsUpdate(data->conn))
result = CURLE_ABORTED_BY_CALLBACK;
else
- result = Curl_speedcheck(data, *nowp);
+ result = Curl_speedcheck(data, *nowp);
if(!result) {
send_timeout_ms = 0;
@@ -2089,7 +2089,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
data->progress.ul_limit_size,
data->set.max_send_speed,
data->progress.ul_limit_start,
- *nowp);
+ *nowp);
recv_timeout_ms = 0;
if(data->set.max_recv_speed > 0)
@@ -2098,11 +2098,11 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
data->progress.dl_limit_size,
data->set.max_recv_speed,
data->progress.dl_limit_start,
- *nowp);
+ *nowp);
if(!send_timeout_ms && !recv_timeout_ms) {
multistate(data, CURLM_STATE_PERFORM);
- Curl_ratelimit(data, *nowp);
+ Curl_ratelimit(data, *nowp);
}
else if(send_timeout_ms >= recv_timeout_ms)
Curl_expire(data, send_timeout_ms, EXPIRE_TOOFAST);
@@ -2116,7 +2116,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
char *newurl = NULL;
bool retry = FALSE;
bool comeback = FALSE;
- DEBUGASSERT(data->state.buffer);
+ DEBUGASSERT(data->state.buffer);
/* check if over send speed */
send_timeout_ms = 0;
if(data->set.max_send_speed > 0)
@@ -2124,7 +2124,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
data->progress.ul_limit_size,
data->set.max_send_speed,
data->progress.ul_limit_start,
- *nowp);
+ *nowp);
/* check if over recv speed */
recv_timeout_ms = 0;
@@ -2133,10 +2133,10 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
data->progress.dl_limit_size,
data->set.max_recv_speed,
data->progress.dl_limit_start,
- *nowp);
+ *nowp);
if(send_timeout_ms || recv_timeout_ms) {
- Curl_ratelimit(data, *nowp);
+ Curl_ratelimit(data, *nowp);
multistate(data, CURLM_STATE_TOOFAST);
if(send_timeout_ms >= recv_timeout_ms)
Curl_expire(data, send_timeout_ms, EXPIRE_TOOFAST);
@@ -2255,13 +2255,13 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
}
}
}
- else if(comeback) {
- /* This avoids CURLM_CALL_MULTI_PERFORM so that a very fast transfer
- won't get stuck on this transfer at the expense of other concurrent
- transfers */
- Curl_expire(data, 0, EXPIRE_RUN_NOW);
- rc = CURLM_OK;
- }
+ else if(comeback) {
+ /* This avoids CURLM_CALL_MULTI_PERFORM so that a very fast transfer
+ won't get stuck on this transfer at the expense of other concurrent
+ transfers */
+ Curl_expire(data, 0, EXPIRE_RUN_NOW);
+ rc = CURLM_OK;
+ }
break;
}
@@ -2289,7 +2289,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
* access free'd data, if the connection is free'd and the handle
* removed before we perform the processing in CURLM_STATE_COMPLETED
*/
- Curl_detach_connnection(data);
+ Curl_detach_connnection(data);
}
#ifndef CURL_DISABLE_FTP
@@ -2341,11 +2341,11 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
/* This is where we make sure that the conn pointer is reset.
We don't have to do this in every case block above where a
failure is detected */
- Curl_detach_connnection(data);
+ Curl_detach_connnection(data);
+
+ /* remove connection from cache */
+ Curl_conncache_remove_conn(data, conn, TRUE);
- /* remove connection from cache */
- Curl_conncache_remove_conn(data, conn, TRUE);
-
/* disconnect properly */
Curl_disconnect(data, conn, dead_connection);
}
@@ -2416,7 +2416,7 @@ CURLMcode curl_multi_perform(struct Curl_multi *multi, int *running_handles)
SIGPIPE_VARIABLE(pipe_st);
sigpipe_ignore(data, &pipe_st);
- result = multi_runsingle(multi, &now, data);
+ result = multi_runsingle(multi, &now, data);
sigpipe_restore(&pipe_st);
if(result)
@@ -2498,11 +2498,11 @@ CURLMcode curl_multi_cleanup(struct Curl_multi *multi)
Curl_hash_destroy(&multi->hostcache);
Curl_psl_destroy(&multi->psl);
-
-#ifdef ENABLE_WAKEUP
- sclose(multi->wakeup_pair[0]);
- sclose(multi->wakeup_pair[1]);
-#endif
+
+#ifdef ENABLE_WAKEUP
+ sclose(multi->wakeup_pair[0]);
+ sclose(multi->wakeup_pair[1]);
+#endif
free(multi);
return CURLM_OK;
@@ -2530,7 +2530,7 @@ CURLMsg *curl_multi_info_read(struct Curl_multi *multi, int *msgs_in_queue)
!multi->in_callback &&
Curl_llist_count(&multi->msglist)) {
/* there is one or more messages in the list */
- struct Curl_llist_element *e;
+ struct Curl_llist_element *e;
/* extract the head of the list to return */
e = multi->msglist.head;
@@ -2760,15 +2760,15 @@ static CURLMcode add_next_timeout(struct curltime now,
struct Curl_easy *d)
{
struct curltime *tv = &d->state.expiretime;
- struct Curl_llist *list = &d->state.timeoutlist;
- struct Curl_llist_element *e;
+ struct Curl_llist *list = &d->state.timeoutlist;
+ struct Curl_llist_element *e;
struct time_node *node = NULL;
/* move over the timeout list for this specific handle and remove all
timeouts that are now passed tense and store the next pending
timeout in *tv */
for(e = list->head; e;) {
- struct Curl_llist_element *n = e->next;
+ struct Curl_llist_element *n = e->next;
timediff_t diff;
node = (struct time_node *)e->ptr;
diff = Curl_timediff(node->time, now);
@@ -2838,8 +2838,8 @@ static CURLMcode multi_socket(struct Curl_multi *multi,
and just move on. */
;
else {
- struct Curl_hash_iterator iter;
- struct Curl_hash_element *he;
+ struct Curl_hash_iterator iter;
+ struct Curl_hash_element *he;
/* the socket can be shared by many transfers, iterate */
Curl_hash_start_iterate(&entry->transfers, &iter);
@@ -2886,7 +2886,7 @@ static CURLMcode multi_socket(struct Curl_multi *multi,
SIGPIPE_VARIABLE(pipe_st);
sigpipe_ignore(data, &pipe_st);
- result = multi_runsingle(multi, &now, data);
+ result = multi_runsingle(multi, &now, data);
sigpipe_restore(&pipe_st);
if(CURLM_OK >= result) {
@@ -2970,14 +2970,14 @@ CURLMcode curl_multi_setopt(struct Curl_multi *multi,
break;
case CURLMOPT_PIPELINING_SERVER_BL:
break;
- case CURLMOPT_MAX_CONCURRENT_STREAMS:
- {
- long streams = va_arg(param, long);
- if(streams < 1)
- streams = 100;
- multi->max_concurrent_streams = curlx_sltoui(streams);
- }
- break;
+ case CURLMOPT_MAX_CONCURRENT_STREAMS:
+ {
+ long streams = va_arg(param, long);
+ if(streams < 1)
+ streams = 100;
+ multi->max_concurrent_streams = curlx_sltoui(streams);
+ }
+ break;
default:
res = CURLM_UNKNOWN_OPTION;
break;
@@ -3121,8 +3121,8 @@ void Curl_update_timer(struct Curl_multi *multi)
static void
multi_deltimeout(struct Curl_easy *data, expire_id eid)
{
- struct Curl_llist_element *e;
- struct Curl_llist *timeoutlist = &data->state.timeoutlist;
+ struct Curl_llist_element *e;
+ struct Curl_llist *timeoutlist = &data->state.timeoutlist;
/* find and remove the specific node from the list */
for(e = timeoutlist->head; e; e = e->next) {
struct time_node *n = (struct time_node *)e->ptr;
@@ -3145,11 +3145,11 @@ multi_addtimeout(struct Curl_easy *data,
struct curltime *stamp,
expire_id eid)
{
- struct Curl_llist_element *e;
+ struct Curl_llist_element *e;
struct time_node *node;
- struct Curl_llist_element *prev = NULL;
+ struct Curl_llist_element *prev = NULL;
size_t n;
- struct Curl_llist *timeoutlist = &data->state.timeoutlist;
+ struct Curl_llist *timeoutlist = &data->state.timeoutlist;
node = &data->state.expires[eid];
@@ -3231,8 +3231,8 @@ void Curl_expire(struct Curl_easy *data, timediff_t milli, expire_id id)
/* Since this is an updated time, we must remove the previous entry from
the splay tree first and then re-add the new value */
- rc = Curl_splayremove(multi->timetree, &data->state.timenode,
- &multi->timetree);
+ rc = Curl_splayremove(multi->timetree, &data->state.timenode,
+ &multi->timetree);
if(rc)
infof(data, "Internal error removing splay node = %d\n", rc);
}
@@ -3275,11 +3275,11 @@ void Curl_expire_clear(struct Curl_easy *data)
if(nowp->tv_sec || nowp->tv_usec) {
/* Since this is an cleared time, we must remove the previous entry from
the splay tree */
- struct Curl_llist *list = &data->state.timeoutlist;
+ struct Curl_llist *list = &data->state.timeoutlist;
int rc;
- rc = Curl_splayremove(multi->timetree, &data->state.timenode,
- &multi->timetree);
+ rc = Curl_splayremove(multi->timetree, &data->state.timenode,
+ &multi->timetree);
if(rc)
infof(data, "Internal error clearing splay node = %d\n", rc);
@@ -3345,7 +3345,7 @@ void Curl_multiuse_state(struct connectdata *conn,
static void process_pending_handles(struct Curl_multi *multi)
{
- struct Curl_llist_element *e = multi->pending.head;
+ struct Curl_llist_element *e = multi->pending.head;
if(e) {
struct Curl_easy *data = e->ptr;
@@ -3413,9 +3413,9 @@ void Curl_multi_dump(struct Curl_multi *multi)
}
}
#endif
-
-unsigned int Curl_multi_max_concurrent_streams(struct Curl_multi *multi)
-{
- DEBUGASSERT(multi);
- return multi->max_concurrent_streams;
-}
+
+unsigned int Curl_multi_max_concurrent_streams(struct Curl_multi *multi)
+{
+ DEBUGASSERT(multi);
+ return multi->max_concurrent_streams;
+}
diff --git a/contrib/libs/curl/lib/multihandle.h b/contrib/libs/curl/lib/multihandle.h
index 9c8a7d5ac9..de4f74069e 100644
--- a/contrib/libs/curl/lib/multihandle.h
+++ b/contrib/libs/curl/lib/multihandle.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -24,10 +24,10 @@
#include "conncache.h"
#include "psl.h"
-#include "socketpair.h"
+#include "socketpair.h"
struct Curl_message {
- struct Curl_llist_element list;
+ struct Curl_llist_element list;
/* the 'CURLMsg' is the part that is visible to the external user */
struct CURLMsg extmsg;
};
@@ -67,21 +67,21 @@ typedef enum {
#define CURLPIPE_ANY (CURLPIPE_MULTIPLEX)
-#if defined(USE_SOCKETPAIR) && !defined(USE_BLOCKING_SOCKETS) && \
- !defined(CURL_DISABLE_SOCKETPAIR)
-#define ENABLE_WAKEUP
-#endif
-
-/* value for MAXIMUM CONCURRENT STREAMS upper limit */
-#define INITIAL_MAX_CONCURRENT_STREAMS ((1U << 31) - 1)
-
+#if defined(USE_SOCKETPAIR) && !defined(USE_BLOCKING_SOCKETS) && \
+ !defined(CURL_DISABLE_SOCKETPAIR)
+#define ENABLE_WAKEUP
+#endif
+
+/* value for MAXIMUM CONCURRENT STREAMS upper limit */
+#define INITIAL_MAX_CONCURRENT_STREAMS ((1U << 31) - 1)
+
/* This is the struct known as CURLM on the outside */
struct Curl_multi {
/* First a simple identifier to easier detect if a user mix up
this multi handle with an easy handle. Set this to CURL_MULTI_HANDLE. */
long type;
- /* We have a doubly-linked list with easy handles */
+ /* We have a doubly-linked list with easy handles */
struct Curl_easy *easyp;
struct Curl_easy *easylp; /* last node */
@@ -89,9 +89,9 @@ struct Curl_multi {
int num_alive; /* amount of easy handles that are added but have not yet
reached COMPLETE state */
- struct Curl_llist msglist; /* a list of messages from completed transfers */
+ struct Curl_llist msglist; /* a list of messages from completed transfers */
- struct Curl_llist pending; /* Curl_easys that are in the
+ struct Curl_llist pending; /* Curl_easys that are in the
CURLM_STATE_CONNECT_PEND state */
/* callback function and user data pointer for the *socket() API */
@@ -103,7 +103,7 @@ struct Curl_multi {
void *push_userp;
/* Hostname cache */
- struct Curl_hash hostcache;
+ struct Curl_hash hostcache;
#ifdef USE_LIBPSL
/* PSL cache. */
@@ -117,7 +117,7 @@ struct Curl_multi {
/* 'sockhash' is the lookup hash for socket descriptor => easy handles (note
the pluralis form, there can be more than one easy handle waiting on the
same actual socket) */
- struct Curl_hash sockhash;
+ struct Curl_hash sockhash;
/* Shared connection cache (bundles)*/
struct conncache conn_cache;
@@ -136,17 +136,17 @@ struct Curl_multi {
void *timer_userp;
struct curltime timer_lastcall; /* the fixed time for the timeout for the
previous callback */
- unsigned int max_concurrent_streams;
-
-#ifdef ENABLE_WAKEUP
- curl_socket_t wakeup_pair[2]; /* socketpair() used for wakeup
- 0 is used for read, 1 is used for write */
-#endif
- /* multiplexing wanted */
- bool multiplexing;
- bool recheckstate; /* see Curl_multi_connchanged */
+ unsigned int max_concurrent_streams;
+
+#ifdef ENABLE_WAKEUP
+ curl_socket_t wakeup_pair[2]; /* socketpair() used for wakeup
+ 0 is used for read, 1 is used for write */
+#endif
+ /* multiplexing wanted */
+ bool multiplexing;
+ bool recheckstate; /* see Curl_multi_connchanged */
bool in_callback; /* true while executing a callback */
- bool ipv6_works;
+ bool ipv6_works;
};
#endif /* HEADER_CURL_MULTIHANDLE_H */
diff --git a/contrib/libs/curl/lib/multiif.h b/contrib/libs/curl/lib/multiif.h
index 76fdaf057b..f0a57d9a6c 100644
--- a/contrib/libs/curl/lib/multiif.h
+++ b/contrib/libs/curl/lib/multiif.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -33,11 +33,11 @@ void Curl_expire_done(struct Curl_easy *data, expire_id id);
void Curl_update_timer(struct Curl_multi *multi);
void Curl_attach_connnection(struct Curl_easy *data,
struct connectdata *conn);
-void Curl_detach_connnection(struct Curl_easy *data);
+void Curl_detach_connnection(struct Curl_easy *data);
bool Curl_multiplex_wanted(const struct Curl_multi *multi);
void Curl_set_in_callback(struct Curl_easy *data, bool value);
bool Curl_is_in_callback(struct Curl_easy *easy);
-CURLcode Curl_preconnect(struct Curl_easy *data);
+CURLcode Curl_preconnect(struct Curl_easy *data);
/* Internal version of curl_multi_init() accepts size parameters for the
socket and connection hashes */
@@ -91,8 +91,8 @@ CURLMcode Curl_multi_add_perform(struct Curl_multi *multi,
struct Curl_easy *data,
struct connectdata *conn);
-
-/* Return the value of the CURLMOPT_MAX_CONCURRENT_STREAMS option */
-unsigned int Curl_multi_max_concurrent_streams(struct Curl_multi *multi);
-
+
+/* Return the value of the CURLMOPT_MAX_CONCURRENT_STREAMS option */
+unsigned int Curl_multi_max_concurrent_streams(struct Curl_multi *multi);
+
#endif /* HEADER_CURL_MULTIIF_H */
diff --git a/contrib/libs/curl/lib/netrc.c b/contrib/libs/curl/lib/netrc.c
index f8218c02c4..13610bb070 100644
--- a/contrib/libs/curl/lib/netrc.c
+++ b/contrib/libs/curl/lib/netrc.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -88,7 +88,7 @@ static int parsenetrc(const char *host,
if(tok && *tok == '#')
/* treat an initial hash as a comment line */
continue;
- while(tok) {
+ while(tok) {
if((login && *login) && (password && *password)) {
done = TRUE;
diff --git a/contrib/libs/curl/lib/netrc.h b/contrib/libs/curl/lib/netrc.h
index 8218dc3415..4938a5916a 100644
--- a/contrib/libs/curl/lib/netrc.h
+++ b/contrib/libs/curl/lib/netrc.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/non-ascii.c b/contrib/libs/curl/lib/non-ascii.c
index b291556b3e..30c240b637 100644
--- a/contrib/libs/curl/lib/non-ascii.c
+++ b/contrib/libs/curl/lib/non-ascii.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/non-ascii.h b/contrib/libs/curl/lib/non-ascii.h
index 968173fbf2..458e8ef091 100644
--- a/contrib/libs/curl/lib/non-ascii.h
+++ b/contrib/libs/curl/lib/non-ascii.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/nonblock.c b/contrib/libs/curl/lib/nonblock.c
index 3d46d5fdbf..4a7bde504f 100644
--- a/contrib/libs/curl/lib/nonblock.c
+++ b/contrib/libs/curl/lib/nonblock.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/nonblock.h b/contrib/libs/curl/lib/nonblock.h
index 68817e5462..761dab4f6d 100644
--- a/contrib/libs/curl/lib/nonblock.h
+++ b/contrib/libs/curl/lib/nonblock.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/openldap.c b/contrib/libs/curl/lib/openldap.c
index 8a4219566d..f8e3150308 100644
--- a/contrib/libs/curl/lib/openldap.c
+++ b/contrib/libs/curl/lib/openldap.c
@@ -6,11 +6,11 @@
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2010, Howard Chu, <hyc@openldap.org>
- * Copyright (C) 2011 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2011 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -107,7 +107,7 @@ const struct Curl_handler Curl_handler_ldap = {
ZERO_NULL, /* connection_check */
PORT_LDAP, /* defport */
CURLPROTO_LDAP, /* protocol */
- CURLPROTO_LDAP, /* family */
+ CURLPROTO_LDAP, /* family */
PROTOPT_NONE /* flags */
};
@@ -133,8 +133,8 @@ const struct Curl_handler Curl_handler_ldaps = {
ZERO_NULL, /* readwrite */
ZERO_NULL, /* connection_check */
PORT_LDAPS, /* defport */
- CURLPROTO_LDAPS, /* protocol */
- CURLPROTO_LDAP, /* family */
+ CURLPROTO_LDAPS, /* protocol */
+ CURLPROTO_LDAP, /* family */
PROTOPT_SSL /* flags */
};
#endif
@@ -164,10 +164,10 @@ struct ldapconninfo {
bool didbind;
};
-struct ldapreqinfo {
+struct ldapreqinfo {
int msgid;
int nument;
-};
+};
static CURLcode ldap_setup_connection(struct connectdata *conn)
{
@@ -376,7 +376,7 @@ static CURLcode ldap_disconnect(struct connectdata *conn, bool dead_connection)
static CURLcode ldap_do(struct connectdata *conn, bool *done)
{
struct ldapconninfo *li = conn->proto.ldapc;
- struct ldapreqinfo *lr;
+ struct ldapreqinfo *lr;
CURLcode status = CURLE_OK;
int rc = 0;
LDAPURLDesc *ludp = NULL;
@@ -408,11 +408,11 @@ static CURLcode ldap_do(struct connectdata *conn, bool *done)
failf(data, "LDAP local: ldap_search_ext %s", ldap_err2string(rc));
return CURLE_LDAP_SEARCH_FAILED;
}
- lr = calloc(1, sizeof(struct ldapreqinfo));
+ lr = calloc(1, sizeof(struct ldapreqinfo));
if(!lr)
return CURLE_OUT_OF_MEMORY;
lr->msgid = msgid;
- data->req.p.ldap = lr;
+ data->req.p.ldap = lr;
Curl_setup_transfer(data, FIRSTSOCKET, -1, FALSE, -1);
*done = TRUE;
return CURLE_OK;
@@ -421,7 +421,7 @@ static CURLcode ldap_do(struct connectdata *conn, bool *done)
static CURLcode ldap_done(struct connectdata *conn, CURLcode res,
bool premature)
{
- struct ldapreqinfo *lr = conn->data->req.p.ldap;
+ struct ldapreqinfo *lr = conn->data->req.p.ldap;
(void)res;
(void)premature;
@@ -433,7 +433,7 @@ static CURLcode ldap_done(struct connectdata *conn, CURLcode res,
ldap_abandon_ext(li->ld, lr->msgid, NULL, NULL);
lr->msgid = 0;
}
- conn->data->req.p.ldap = NULL;
+ conn->data->req.p.ldap = NULL;
free(lr);
}
@@ -445,7 +445,7 @@ static ssize_t ldap_recv(struct connectdata *conn, int sockindex, char *buf,
{
struct ldapconninfo *li = conn->proto.ldapc;
struct Curl_easy *data = conn->data;
- struct ldapreqinfo *lr = data->req.p.ldap;
+ struct ldapreqinfo *lr = data->req.p.ldap;
int rc, ret;
LDAPMessage *msg = NULL;
LDAPMessage *ent;
diff --git a/contrib/libs/curl/lib/parsedate.c b/contrib/libs/curl/lib/parsedate.c
index c9ce424a6e..3c38f2c4c2 100644
--- a/contrib/libs/curl/lib/parsedate.c
+++ b/contrib/libs/curl/lib/parsedate.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -100,21 +100,21 @@ static int parsedate(const char *date, time_t *output);
#define PARSEDATE_LATER 1
#define PARSEDATE_SOONER 2
-#if !defined(CURL_DISABLE_PARSEDATE) || !defined(CURL_DISABLE_FTP) || \
- !defined(CURL_DISABLE_FILE)
-/* These names are also used by FTP and FILE code */
+#if !defined(CURL_DISABLE_PARSEDATE) || !defined(CURL_DISABLE_FTP) || \
+ !defined(CURL_DISABLE_FILE)
+/* These names are also used by FTP and FILE code */
const char * const Curl_wkday[] =
{"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"};
const char * const Curl_month[]=
{ "Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
-#endif
+#endif
+
+#ifndef CURL_DISABLE_PARSEDATE
+static const char * const weekday[] =
+{ "Monday", "Tuesday", "Wednesday", "Thursday",
+ "Friday", "Saturday", "Sunday" };
-#ifndef CURL_DISABLE_PARSEDATE
-static const char * const weekday[] =
-{ "Monday", "Tuesday", "Wednesday", "Thursday",
- "Friday", "Saturday", "Sunday" };
-
struct tzinfo {
char name[5];
int offset; /* +/- in minutes */
@@ -275,21 +275,21 @@ enum assume {
DATE_TIME
};
-/*
- * time2epoch: time stamp to seconds since epoch in GMT time zone. Similar to
- * mktime but for GMT only.
+/*
+ * time2epoch: time stamp to seconds since epoch in GMT time zone. Similar to
+ * mktime but for GMT only.
*/
-static time_t time2epoch(int sec, int min, int hour,
- int mday, int mon, int year)
+static time_t time2epoch(int sec, int min, int hour,
+ int mday, int mon, int year)
{
static const int month_days_cumulative [12] =
{ 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 };
- int leap_days = year - (mon <= 1);
+ int leap_days = year - (mon <= 1);
leap_days = ((leap_days / 4) - (leap_days / 100) + (leap_days / 400)
- (1969 / 4) + (1969 / 100) - (1969 / 400));
- return ((((time_t) (year - 1970) * 365
- + leap_days + month_days_cumulative[mon] + mday - 1) * 24
- + hour) * 60 + min) * 60 + sec;
+ return ((((time_t) (year - 1970) * 365
+ + leap_days + month_days_cumulative[mon] + mday - 1) * 24
+ + hour) * 60 + min) * 60 + sec;
}
/*
@@ -505,11 +505,11 @@ static int parsedate(const char *date, time_t *output)
(hournum > 23) || (minnum > 59) || (secnum > 60))
return PARSEDATE_FAIL; /* clearly an illegal date */
- /* time2epoch() returns a time_t. time_t is often 32 bits, sometimes even on
+ /* time2epoch() returns a time_t. time_t is often 32 bits, sometimes even on
architectures that feature 64 bit 'long' but ultimately time_t is the
correct data type to use.
*/
- t = time2epoch(secnum, minnum, hournum, mdaynum, monnum, yearnum);
+ t = time2epoch(secnum, minnum, hournum, mdaynum, monnum, yearnum);
/* Add the time zone diff between local time zone and GMT. */
if(tzoff == -1)
@@ -552,30 +552,30 @@ time_t curl_getdate(const char *p, const time_t *now)
return -1;
}
-/* Curl_getdate_capped() differs from curl_getdate() in that this will return
- TIME_T_MAX in case the parsed time value was too big, instead of an
- error. */
-
-time_t Curl_getdate_capped(const char *p)
-{
- time_t parsed = -1;
- int rc = parsedate(p, &parsed);
-
- switch(rc) {
- case PARSEDATE_OK:
- if(parsed == -1)
- /* avoid returning -1 for a working scenario */
- parsed++;
- return parsed;
- case PARSEDATE_LATER:
- /* this returns the maximum time value */
- return parsed;
- default:
- return -1; /* everything else is fail */
- }
- /* UNREACHABLE */
-}
-
+/* Curl_getdate_capped() differs from curl_getdate() in that this will return
+ TIME_T_MAX in case the parsed time value was too big, instead of an
+ error. */
+
+time_t Curl_getdate_capped(const char *p)
+{
+ time_t parsed = -1;
+ int rc = parsedate(p, &parsed);
+
+ switch(rc) {
+ case PARSEDATE_OK:
+ if(parsed == -1)
+ /* avoid returning -1 for a working scenario */
+ parsed++;
+ return parsed;
+ case PARSEDATE_LATER:
+ /* this returns the maximum time value */
+ return parsed;
+ default:
+ return -1; /* everything else is fail */
+ }
+ /* UNREACHABLE */
+}
+
/*
* Curl_gmtime() is a gmtime() replacement for portability. Do not use the
* gmtime_r() or gmtime() functions anywhere else but here.
@@ -589,7 +589,7 @@ CURLcode Curl_gmtime(time_t intime, struct tm *store)
/* thread-safe version */
tm = (struct tm *)gmtime_r(&intime, store);
#else
- /* !checksrc! disable BANNEDFUNC 1 */
+ /* !checksrc! disable BANNEDFUNC 1 */
tm = gmtime(&intime);
if(tm)
*store = *tm; /* copy the pointed struct to the local copy */
diff --git a/contrib/libs/curl/lib/parsedate.h b/contrib/libs/curl/lib/parsedate.h
index 3e10aa2b36..a99faf9e36 100644
--- a/contrib/libs/curl/lib/parsedate.h
+++ b/contrib/libs/curl/lib/parsedate.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -27,10 +27,10 @@ extern const char * const Curl_month[12];
CURLcode Curl_gmtime(time_t intime, struct tm *store);
-/* Curl_getdate_capped() differs from curl_getdate() in that this will return
- TIME_T_MAX in case the parsed time value was too big, instead of an
- error. */
-
-time_t Curl_getdate_capped(const char *p);
-
+/* Curl_getdate_capped() differs from curl_getdate() in that this will return
+ TIME_T_MAX in case the parsed time value was too big, instead of an
+ error. */
+
+time_t Curl_getdate_capped(const char *p);
+
#endif /* HEADER_CURL_PARSEDATE_H */
diff --git a/contrib/libs/curl/lib/pingpong.c b/contrib/libs/curl/lib/pingpong.c
index 4572a380b6..5d6109a7df 100644
--- a/contrib/libs/curl/lib/pingpong.c
+++ b/contrib/libs/curl/lib/pingpong.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -44,12 +44,12 @@
/* Returns timeout in ms. 0 or negative number means the timeout has already
triggered */
-timediff_t Curl_pp_state_timeout(struct pingpong *pp, bool disconnecting)
+timediff_t Curl_pp_state_timeout(struct pingpong *pp, bool disconnecting)
{
struct connectdata *conn = pp->conn;
struct Curl_easy *data = conn->data;
- timediff_t timeout_ms; /* in milliseconds */
- timediff_t response_time = (data->set.server_response_timeout)?
+ timediff_t timeout_ms; /* in milliseconds */
+ timediff_t response_time = (data->set.server_response_timeout)?
data->set.server_response_timeout: pp->response_time;
/* if CURLOPT_SERVER_RESPONSE_TIMEOUT is set, use that to determine
@@ -60,12 +60,12 @@ timediff_t Curl_pp_state_timeout(struct pingpong *pp, bool disconnecting)
/* Without a requested timeout, we only wait 'response_time' seconds for the
full response to arrive before we bail out */
timeout_ms = response_time -
- Curl_timediff(Curl_now(), pp->response); /* spent time */
+ Curl_timediff(Curl_now(), pp->response); /* spent time */
if(data->set.timeout && !disconnecting) {
/* if timeout is requested, find out how much remaining time we have */
- timediff_t timeout2_ms = data->set.timeout - /* timeout time */
- Curl_timediff(Curl_now(), conn->now); /* spent time */
+ timediff_t timeout2_ms = data->set.timeout - /* timeout time */
+ Curl_timediff(Curl_now(), conn->now); /* spent time */
/* pick the lowest number */
timeout_ms = CURLMIN(timeout_ms, timeout2_ms);
@@ -83,8 +83,8 @@ CURLcode Curl_pp_statemach(struct pingpong *pp, bool block,
struct connectdata *conn = pp->conn;
curl_socket_t sock = conn->sock[FIRSTSOCKET];
int rc;
- timediff_t interval_ms;
- timediff_t timeout_ms = Curl_pp_state_timeout(pp, disconnecting);
+ timediff_t interval_ms;
+ timediff_t timeout_ms = Curl_pp_state_timeout(pp, disconnecting);
struct Curl_easy *data = conn->data;
CURLcode result = CURLE_OK;
@@ -146,11 +146,11 @@ void Curl_pp_init(struct pingpong *pp)
pp->response = Curl_now(); /* start response time-out now! */
}
-/* setup for the coming transfer */
-void Curl_pp_setup(struct pingpong *pp)
-{
- Curl_dyn_init(&pp->sendbuf, DYN_PINGPPONG_CMD);
-}
+/* setup for the coming transfer */
+void Curl_pp_setup(struct pingpong *pp)
+{
+ Curl_dyn_init(&pp->sendbuf, DYN_PINGPPONG_CMD);
+}
/***********************************************************************
*
@@ -166,7 +166,7 @@ CURLcode Curl_pp_vsendf(struct pingpong *pp,
const char *fmt,
va_list args)
{
- ssize_t bytes_written = 0;
+ ssize_t bytes_written = 0;
size_t write_len;
char *s;
CURLcode result;
@@ -186,39 +186,39 @@ CURLcode Curl_pp_vsendf(struct pingpong *pp,
return CURLE_SEND_ERROR;
data = conn->data;
- Curl_dyn_reset(&pp->sendbuf);
- result = Curl_dyn_vaddf(&pp->sendbuf, fmt, args);
- if(result)
- return result;
+ Curl_dyn_reset(&pp->sendbuf);
+ result = Curl_dyn_vaddf(&pp->sendbuf, fmt, args);
+ if(result)
+ return result;
- /* append CRLF */
- result = Curl_dyn_addn(&pp->sendbuf, "\r\n", 2);
- if(result)
- return result;
+ /* append CRLF */
+ result = Curl_dyn_addn(&pp->sendbuf, "\r\n", 2);
+ if(result)
+ return result;
- write_len = Curl_dyn_len(&pp->sendbuf);
- s = Curl_dyn_ptr(&pp->sendbuf);
+ write_len = Curl_dyn_len(&pp->sendbuf);
+ s = Curl_dyn_ptr(&pp->sendbuf);
Curl_pp_init(pp);
result = Curl_convert_to_network(data, s, write_len);
/* Curl_convert_to_network calls failf if unsuccessful */
- if(result)
+ if(result)
return result;
#ifdef HAVE_GSSAPI
conn->data_prot = PROT_CMD;
#endif
result = Curl_write(conn, conn->sock[FIRSTSOCKET], s, write_len,
- &bytes_written);
- if(result)
- return result;
+ &bytes_written);
+ if(result)
+ return result;
#ifdef HAVE_GSSAPI
data_sec = conn->data_prot;
DEBUGASSERT(data_sec > PROT_NONE && data_sec < PROT_LAST);
conn->data_prot = data_sec;
#endif
- Curl_debug(data, CURLINFO_HEADER_OUT, s, (size_t)bytes_written);
+ Curl_debug(data, CURLINFO_HEADER_OUT, s, (size_t)bytes_written);
if(bytes_written != (ssize_t)write_len) {
/* the whole chunk was not sent, keep it around and adjust sizes */
@@ -363,8 +363,8 @@ CURLcode Curl_pp_readresp(curl_socket_t sockfd,
#ifdef HAVE_GSSAPI
if(!conn->sec_complete)
#endif
- Curl_debug(data, CURLINFO_HEADER_IN,
- pp->linestart_resp, (size_t)perline);
+ Curl_debug(data, CURLINFO_HEADER_IN,
+ pp->linestart_resp, (size_t)perline);
/*
* We pass all response-lines to the callback function registered
@@ -378,10 +378,10 @@ CURLcode Curl_pp_readresp(curl_socket_t sockfd,
if(pp->endofresp(conn, pp->linestart_resp, perline, code)) {
/* This is the end of the last line, copy the last line to the
- start of the buffer and null-terminate, for old times sake */
+ start of the buffer and null-terminate, for old times sake */
size_t n = ptr - pp->linestart_resp;
memmove(buf, pp->linestart_resp, n);
- buf[n] = 0; /* null-terminate */
+ buf[n] = 0; /* null-terminate */
keepon = FALSE;
pp->linestart_resp = ptr + 1; /* advance pointer */
i++; /* skip this before getting out */
@@ -496,15 +496,15 @@ CURLcode Curl_pp_flushsend(struct pingpong *pp)
CURLcode Curl_pp_disconnect(struct pingpong *pp)
{
- Curl_dyn_free(&pp->sendbuf);
- Curl_safefree(pp->cache);
+ Curl_dyn_free(&pp->sendbuf);
+ Curl_safefree(pp->cache);
return CURLE_OK;
}
bool Curl_pp_moredata(struct pingpong *pp)
{
return (!pp->sendleft && pp->cache && pp->nread_resp < pp->cache_size) ?
- TRUE : FALSE;
+ TRUE : FALSE;
}
#endif
diff --git a/contrib/libs/curl/lib/pingpong.h b/contrib/libs/curl/lib/pingpong.h
index 72d69e7fc7..0d0c74afa0 100644
--- a/contrib/libs/curl/lib/pingpong.h
+++ b/contrib/libs/curl/lib/pingpong.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -60,11 +60,11 @@ struct pingpong {
size_t sendsize; /* total size of the sendthis buffer */
struct curltime response; /* set to Curl_now() when a command has been sent
off, used to time-out response reading */
- timediff_t response_time; /* When no timeout is given, this is the amount of
- milliseconds we await for a server response. */
+ timediff_t response_time; /* When no timeout is given, this is the amount of
+ milliseconds we await for a server response. */
struct connectdata *conn; /* points to the connectdata struct that this
belongs to */
- struct dynbuf sendbuf;
+ struct dynbuf sendbuf;
/* Function pointers the protocols MUST implement and provide for the
pingpong layer to function */
@@ -87,12 +87,12 @@ CURLcode Curl_pp_statemach(struct pingpong *pp, bool block,
/* initialize stuff to prepare for reading a fresh new response */
void Curl_pp_init(struct pingpong *pp);
-/* setup for the transfer */
-void Curl_pp_setup(struct pingpong *pp);
-
+/* setup for the transfer */
+void Curl_pp_setup(struct pingpong *pp);
+
/* Returns timeout in ms. 0 or negative number means the timeout has already
triggered */
-timediff_t Curl_pp_state_timeout(struct pingpong *pp, bool disconnecting);
+timediff_t Curl_pp_state_timeout(struct pingpong *pp, bool disconnecting);
/***********************************************************************
diff --git a/contrib/libs/curl/lib/pop3.c b/contrib/libs/curl/lib/pop3.c
index 4b0c5c15bc..e71860e48a 100644
--- a/contrib/libs/curl/lib/pop3.c
+++ b/contrib/libs/curl/lib/pop3.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -128,7 +128,7 @@ const struct Curl_handler Curl_handler_pop3 = {
ZERO_NULL, /* connection_check */
PORT_POP3, /* defport */
CURLPROTO_POP3, /* protocol */
- CURLPROTO_POP3, /* family */
+ CURLPROTO_POP3, /* family */
PROTOPT_CLOSEACTION | PROTOPT_NOURLQUERY | /* flags */
PROTOPT_URLOPTIONS
};
@@ -156,7 +156,7 @@ const struct Curl_handler Curl_handler_pop3s = {
ZERO_NULL, /* connection_check */
PORT_POP3S, /* defport */
CURLPROTO_POP3S, /* protocol */
- CURLPROTO_POP3, /* family */
+ CURLPROTO_POP3, /* family */
PROTOPT_CLOSEACTION | PROTOPT_SSL
| PROTOPT_NOURLQUERY | PROTOPT_URLOPTIONS /* flags */
};
@@ -180,7 +180,7 @@ static void pop3_to_pop3s(struct connectdata *conn)
conn->handler = &Curl_handler_pop3s;
/* Set the connection's upgraded to TLS flag */
- conn->bits.tls_upgraded = TRUE;
+ conn->bits.tls_upgraded = TRUE;
}
#else
#define pop3_to_pop3s(x) Curl_nop_stmt
@@ -414,7 +414,7 @@ static CURLcode pop3_perform_apop(struct connectdata *conn)
CURLcode result = CURLE_OK;
struct pop3_conn *pop3c = &conn->proto.pop3c;
size_t i;
- struct MD5_context *ctxt;
+ struct MD5_context *ctxt;
unsigned char digest[MD5_DIGEST_LEN];
char secret[2 * MD5_DIGEST_LEN + 1];
@@ -553,7 +553,7 @@ static CURLcode pop3_perform_command(struct connectdata *conn)
{
CURLcode result = CURLE_OK;
struct Curl_easy *data = conn->data;
- struct POP3 *pop3 = data->req.p.pop3;
+ struct POP3 *pop3 = data->req.p.pop3;
const char *command = NULL;
/* Calculate the default command */
@@ -886,7 +886,7 @@ static CURLcode pop3_state_command_resp(struct connectdata *conn,
{
CURLcode result = CURLE_OK;
struct Curl_easy *data = conn->data;
- struct POP3 *pop3 = data->req.p.pop3;
+ struct POP3 *pop3 = data->req.p.pop3;
struct pop3_conn *pop3c = &conn->proto.pop3c;
struct pingpong *pp = &pop3c->pp;
@@ -1048,7 +1048,7 @@ static CURLcode pop3_init(struct connectdata *conn)
struct Curl_easy *data = conn->data;
struct POP3 *pop3;
- pop3 = data->req.p.pop3 = calloc(sizeof(struct POP3), 1);
+ pop3 = data->req.p.pop3 = calloc(sizeof(struct POP3), 1);
if(!pop3)
result = CURLE_OUT_OF_MEMORY;
@@ -1093,7 +1093,7 @@ static CURLcode pop3_connect(struct connectdata *conn, bool *done)
Curl_sasl_init(&pop3c->sasl, &saslpop3);
/* Initialise the pingpong layer */
- Curl_pp_setup(pp);
+ Curl_pp_setup(pp);
Curl_pp_init(pp);
/* Parse the URL options */
@@ -1123,7 +1123,7 @@ static CURLcode pop3_done(struct connectdata *conn, CURLcode status,
{
CURLcode result = CURLE_OK;
struct Curl_easy *data = conn->data;
- struct POP3 *pop3 = data->req.p.pop3;
+ struct POP3 *pop3 = data->req.p.pop3;
(void)premature;
@@ -1157,7 +1157,7 @@ static CURLcode pop3_perform(struct connectdata *conn, bool *connected,
{
/* This is POP3 and no proxy */
CURLcode result = CURLE_OK;
- struct POP3 *pop3 = conn->data->req.p.pop3;
+ struct POP3 *pop3 = conn->data->req.p.pop3;
DEBUGF(infof(conn->data, "DO phase starts\n"));
@@ -1315,7 +1315,7 @@ static CURLcode pop3_setup_connection(struct connectdata *conn)
return result;
/* Clear the TLS upgraded flag */
- conn->bits.tls_upgraded = FALSE;
+ conn->bits.tls_upgraded = FALSE;
return CURLE_OK;
}
@@ -1389,11 +1389,11 @@ static CURLcode pop3_parse_url_path(struct connectdata *conn)
{
/* The POP3 struct is already initialised in pop3_connect() */
struct Curl_easy *data = conn->data;
- struct POP3 *pop3 = data->req.p.pop3;
+ struct POP3 *pop3 = data->req.p.pop3;
const char *path = &data->state.up.path[1]; /* skip leading path */
/* URL decode the path for the message ID */
- return Curl_urldecode(data, path, 0, &pop3->id, NULL, REJECT_CTRL);
+ return Curl_urldecode(data, path, 0, &pop3->id, NULL, REJECT_CTRL);
}
/***********************************************************************
@@ -1406,12 +1406,12 @@ static CURLcode pop3_parse_custom_request(struct connectdata *conn)
{
CURLcode result = CURLE_OK;
struct Curl_easy *data = conn->data;
- struct POP3 *pop3 = data->req.p.pop3;
+ struct POP3 *pop3 = data->req.p.pop3;
const char *custom = data->set.str[STRING_CUSTOMREQUEST];
/* URL decode the custom request */
if(custom)
- result = Curl_urldecode(data, custom, 0, &pop3->custom, NULL, REJECT_CTRL);
+ result = Curl_urldecode(data, custom, 0, &pop3->custom, NULL, REJECT_CTRL);
return result;
}
diff --git a/contrib/libs/curl/lib/pop3.h b/contrib/libs/curl/lib/pop3.h
index 95a757eceb..6ca3fd511f 100644
--- a/contrib/libs/curl/lib/pop3.h
+++ b/contrib/libs/curl/lib/pop3.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 2009 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2009 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/progress.c b/contrib/libs/curl/lib/progress.c
index f9bb8fadd5..658d05ab8e 100644
--- a/contrib/libs/curl/lib/progress.c
+++ b/contrib/libs/curl/lib/progress.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -164,13 +164,13 @@ void Curl_pgrsResetTransferSizes(struct Curl_easy *data)
}
/*
- *
- * Curl_pgrsTime(). Store the current time at the given label. This fetches a
- * fresh "now" and returns it.
- *
+ *
+ * Curl_pgrsTime(). Store the current time at the given label. This fetches a
+ * fresh "now" and returns it.
+ *
* @unittest: 1399
*/
-struct curltime Curl_pgrsTime(struct Curl_easy *data, timerid timer)
+struct curltime Curl_pgrsTime(struct Curl_easy *data, timerid timer)
{
struct curltime now = Curl_now();
timediff_t *delta = NULL;
@@ -213,7 +213,7 @@ struct curltime Curl_pgrsTime(struct Curl_easy *data, timerid timer)
* changing the t_starttransfer time.
*/
if(data->progress.is_t_startransfer_set) {
- return now;
+ return now;
}
else {
data->progress.is_t_startransfer_set = true;
@@ -232,7 +232,7 @@ struct curltime Curl_pgrsTime(struct Curl_easy *data, timerid timer)
us = 1; /* make sure at least one microsecond passed */
*delta += us;
}
- return now;
+ return now;
}
void Curl_pgrsStartNow(struct Curl_easy *data)
@@ -240,8 +240,8 @@ void Curl_pgrsStartNow(struct Curl_easy *data)
data->progress.speeder_c = 0; /* reset the progress meter display */
data->progress.start = Curl_now();
data->progress.is_t_startransfer_set = false;
- data->progress.ul_limit_start = data->progress.start;
- data->progress.dl_limit_start = data->progress.start;
+ data->progress.ul_limit_start = data->progress.start;
+ data->progress.dl_limit_start = data->progress.start;
data->progress.downloaded = 0;
data->progress.uploaded = 0;
/* clear all bits except HIDE and HEADERS_OUT */
@@ -285,9 +285,9 @@ timediff_t Curl_pgrsLimitWaitTime(curl_off_t cursize,
* stay below 'limit'.
*/
if(size < CURL_OFF_T_MAX/1000)
- minimum = (timediff_t) (CURL_OFF_T_C(1000) * size / limit);
+ minimum = (timediff_t) (CURL_OFF_T_C(1000) * size / limit);
else {
- minimum = (timediff_t) (size / limit);
+ minimum = (timediff_t) (size / limit);
if(minimum < TIMEDIFF_T_MAX/1000)
minimum *= 1000;
else
@@ -597,13 +597,13 @@ int Curl_pgrsUpdate(struct connectdata *conn)
data->progress.size_ul,
data->progress.uploaded);
Curl_set_in_callback(data, false);
- if(result != CURL_PROGRESSFUNC_CONTINUE) {
- if(result)
- failf(data, "Callback aborted");
- return result;
- }
+ if(result != CURL_PROGRESSFUNC_CONTINUE) {
+ if(result)
+ failf(data, "Callback aborted");
+ return result;
+ }
}
- else if(data->set.fprogress) {
+ else if(data->set.fprogress) {
int result;
/* The older deprecated callback is set, call that */
Curl_set_in_callback(data, true);
@@ -613,11 +613,11 @@ int Curl_pgrsUpdate(struct connectdata *conn)
(double)data->progress.size_ul,
(double)data->progress.uploaded);
Curl_set_in_callback(data, false);
- if(result != CURL_PROGRESSFUNC_CONTINUE) {
- if(result)
- failf(data, "Callback aborted");
- return result;
- }
+ if(result != CURL_PROGRESSFUNC_CONTINUE) {
+ if(result)
+ failf(data, "Callback aborted");
+ return result;
+ }
}
if(showprogress)
diff --git a/contrib/libs/curl/lib/progress.h b/contrib/libs/curl/lib/progress.h
index 8a42dafded..74680099f0 100644
--- a/contrib/libs/curl/lib/progress.h
+++ b/contrib/libs/curl/lib/progress.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -49,7 +49,7 @@ void Curl_pgrsSetUploadCounter(struct Curl_easy *data, curl_off_t size);
void Curl_ratelimit(struct Curl_easy *data, struct curltime now);
int Curl_pgrsUpdate(struct connectdata *);
void Curl_pgrsResetTransferSizes(struct Curl_easy *data);
-struct curltime Curl_pgrsTime(struct Curl_easy *data, timerid timer);
+struct curltime Curl_pgrsTime(struct Curl_easy *data, timerid timer);
timediff_t Curl_pgrsLimitWaitTime(curl_off_t cursize,
curl_off_t startsize,
curl_off_t limit,
diff --git a/contrib/libs/curl/lib/psl.c b/contrib/libs/curl/lib/psl.c
index 7c9efc3b75..e46091863f 100644
--- a/contrib/libs/curl/lib/psl.c
+++ b/contrib/libs/curl/lib/psl.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/psl.h b/contrib/libs/curl/lib/psl.h
index 5d35b6aaf0..2d9c99144c 100644
--- a/contrib/libs/curl/lib/psl.h
+++ b/contrib/libs/curl/lib/psl.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/quic.h b/contrib/libs/curl/lib/quic.h
index 196a0866e9..83e10cb44f 100644
--- a/contrib/libs/curl/lib/quic.h
+++ b/contrib/libs/curl/lib/quic.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -41,19 +41,19 @@ CURLcode Curl_quic_connect(struct connectdata *conn,
const struct sockaddr *addr,
socklen_t addrlen);
CURLcode Curl_quic_is_connected(struct connectdata *conn,
- int sockindex,
+ int sockindex,
bool *connected);
int Curl_quic_ver(char *p, size_t len);
CURLcode Curl_quic_done_sending(struct connectdata *conn);
-void Curl_quic_done(struct Curl_easy *data, bool premature);
-bool Curl_quic_data_pending(const struct Curl_easy *data);
-void Curl_quic_disconnect(struct connectdata *conn, int tempindex);
+void Curl_quic_done(struct Curl_easy *data, bool premature);
+bool Curl_quic_data_pending(const struct Curl_easy *data);
+void Curl_quic_disconnect(struct connectdata *conn, int tempindex);
#else /* ENABLE_QUIC */
#define Curl_quic_done_sending(x)
-#define Curl_quic_done(x,y)
-#define Curl_quic_data_pending(x)
-#define Curl_quic_disconnect(x,y)
+#define Curl_quic_done(x,y)
+#define Curl_quic_data_pending(x)
+#define Curl_quic_disconnect(x,y)
#endif /* !ENABLE_QUIC */
#endif /* HEADER_CURL_QUIC_H */
diff --git a/contrib/libs/curl/lib/rand.c b/contrib/libs/curl/lib/rand.c
index 075d0b9ceb..951fedb0a9 100644
--- a/contrib/libs/curl/lib/rand.c
+++ b/contrib/libs/curl/lib/rand.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/rand.h b/contrib/libs/curl/lib/rand.h
index 6193f7b216..02d95d8e64 100644
--- a/contrib/libs/curl/lib/rand.h
+++ b/contrib/libs/curl/lib/rand.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/rename.c b/contrib/libs/curl/lib/rename.c
index d910767c54..f858d43695 100644
--- a/contrib/libs/curl/lib/rename.c
+++ b/contrib/libs/curl/lib/rename.c
@@ -1,71 +1,71 @@
-/***************************************************************************
- * _ _ ____ _
- * Project ___| | | | _ \| |
- * / __| | | | |_) | |
- * | (__| |_| | _ <| |___
- * \___|\___/|_| \_\_____|
- *
- * Copyright (C) 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
- *
- * You may opt to use, copy, modify, merge, publish, distribute and/or sell
- * copies of the Software, and permit persons to whom the Software is
- * furnished to do so, under the terms of the COPYING file.
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- ***************************************************************************/
-
-#include "rename.h"
-
-#include "curl_setup.h"
-
-#if (!defined(CURL_DISABLE_HTTP) || !defined(CURL_DISABLE_COOKIES)) || \
- !defined(CURL_DISABLE_ALTSVC)
-
-#include "curl_multibyte.h"
-#include "timeval.h"
-
-/* The last 3 #include files should be in this order */
-#include "curl_printf.h"
-#include "curl_memory.h"
-#include "memdebug.h"
-
-/* return 0 on success, 1 on error */
-int Curl_rename(const char *oldpath, const char *newpath)
-{
-#ifdef WIN32
- /* rename() on Windows doesn't overwrite, so we can't use it here.
- MoveFileEx() will overwrite and is usually atomic, however it fails
- when there are open handles to the file. */
- const int max_wait_ms = 1000;
- struct curltime start = Curl_now();
- TCHAR *tchar_oldpath = curlx_convert_UTF8_to_tchar((char *)oldpath);
- TCHAR *tchar_newpath = curlx_convert_UTF8_to_tchar((char *)newpath);
- for(;;) {
- timediff_t diff;
- if(MoveFileEx(tchar_oldpath, tchar_newpath, MOVEFILE_REPLACE_EXISTING)) {
- curlx_unicodefree(tchar_oldpath);
- curlx_unicodefree(tchar_newpath);
- break;
- }
- diff = Curl_timediff(Curl_now(), start);
- if(diff < 0 || diff > max_wait_ms) {
- curlx_unicodefree(tchar_oldpath);
- curlx_unicodefree(tchar_newpath);
- return 1;
- }
- Sleep(1);
- }
-#else
- if(rename(oldpath, newpath))
- return 1;
-#endif
- return 0;
-}
-
-#endif
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 2020, 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
+ * are also available at https://curl.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+
+#include "rename.h"
+
+#include "curl_setup.h"
+
+#if (!defined(CURL_DISABLE_HTTP) || !defined(CURL_DISABLE_COOKIES)) || \
+ !defined(CURL_DISABLE_ALTSVC)
+
+#include "curl_multibyte.h"
+#include "timeval.h"
+
+/* The last 3 #include files should be in this order */
+#include "curl_printf.h"
+#include "curl_memory.h"
+#include "memdebug.h"
+
+/* return 0 on success, 1 on error */
+int Curl_rename(const char *oldpath, const char *newpath)
+{
+#ifdef WIN32
+ /* rename() on Windows doesn't overwrite, so we can't use it here.
+ MoveFileEx() will overwrite and is usually atomic, however it fails
+ when there are open handles to the file. */
+ const int max_wait_ms = 1000;
+ struct curltime start = Curl_now();
+ TCHAR *tchar_oldpath = curlx_convert_UTF8_to_tchar((char *)oldpath);
+ TCHAR *tchar_newpath = curlx_convert_UTF8_to_tchar((char *)newpath);
+ for(;;) {
+ timediff_t diff;
+ if(MoveFileEx(tchar_oldpath, tchar_newpath, MOVEFILE_REPLACE_EXISTING)) {
+ curlx_unicodefree(tchar_oldpath);
+ curlx_unicodefree(tchar_newpath);
+ break;
+ }
+ diff = Curl_timediff(Curl_now(), start);
+ if(diff < 0 || diff > max_wait_ms) {
+ curlx_unicodefree(tchar_oldpath);
+ curlx_unicodefree(tchar_newpath);
+ return 1;
+ }
+ Sleep(1);
+ }
+#else
+ if(rename(oldpath, newpath))
+ return 1;
+#endif
+ return 0;
+}
+
+#endif
diff --git a/contrib/libs/curl/lib/rename.h b/contrib/libs/curl/lib/rename.h
index a5a1dc857c..534f7471c8 100644
--- a/contrib/libs/curl/lib/rename.h
+++ b/contrib/libs/curl/lib/rename.h
@@ -1,27 +1,27 @@
-#ifndef HEADER_CURL_RENAME_H
-#define HEADER_CURL_RENAME_H
-/***************************************************************************
- * _ _ ____ _
- * Project ___| | | | _ \| |
- * / __| | | | |_) | |
- * | (__| |_| | _ <| |___
- * \___|\___/|_| \_\_____|
- *
- * Copyright (C) 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
- *
- * You may opt to use, copy, modify, merge, publish, distribute and/or sell
- * copies of the Software, and permit persons to whom the Software is
- * furnished to do so, under the terms of the COPYING file.
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- ***************************************************************************/
-
-int Curl_rename(const char *oldpath, const char *newpath);
-
-#endif /* HEADER_CURL_RENAME_H */
+#ifndef HEADER_CURL_RENAME_H
+#define HEADER_CURL_RENAME_H
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 2020, 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
+ * are also available at https://curl.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+
+int Curl_rename(const char *oldpath, const char *newpath);
+
+#endif /* HEADER_CURL_RENAME_H */
diff --git a/contrib/libs/curl/lib/rtsp.c b/contrib/libs/curl/lib/rtsp.c
index 1b6daaf35f..151ff4af27 100644
--- a/contrib/libs/curl/lib/rtsp.c
+++ b/contrib/libs/curl/lib/rtsp.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -106,7 +106,7 @@ const struct Curl_handler Curl_handler_rtsp = {
rtsp_conncheck, /* connection_check */
PORT_RTSP, /* defport */
CURLPROTO_RTSP, /* protocol */
- CURLPROTO_RTSP, /* family */
+ CURLPROTO_RTSP, /* family */
PROTOPT_NONE /* flags */
};
@@ -115,7 +115,7 @@ static CURLcode rtsp_setup_connection(struct connectdata *conn)
{
struct RTSP *rtsp;
- conn->data->req.p.rtsp = rtsp = calloc(1, sizeof(struct RTSP));
+ conn->data->req.p.rtsp = rtsp = calloc(1, sizeof(struct RTSP));
if(!rtsp)
return CURLE_OUT_OF_MEMORY;
@@ -200,7 +200,7 @@ static CURLcode rtsp_done(struct connectdata *conn,
CURLcode status, bool premature)
{
struct Curl_easy *data = conn->data;
- struct RTSP *rtsp = data->req.p.rtsp;
+ struct RTSP *rtsp = data->req.p.rtsp;
CURLcode httpStatus;
/* Bypass HTTP empty-reply checks on receive */
@@ -233,8 +233,8 @@ static CURLcode rtsp_do(struct connectdata *conn, bool *done)
struct Curl_easy *data = conn->data;
CURLcode result = CURLE_OK;
Curl_RtspReq rtspreq = data->set.rtspreq;
- struct RTSP *rtsp = data->req.p.rtsp;
- struct dynbuf req_buffer;
+ struct RTSP *rtsp = data->req.p.rtsp;
+ struct dynbuf req_buffer;
curl_off_t postsize = 0; /* for ANNOUNCE and SET_PARAMETER */
curl_off_t putsize = 0; /* for ANNOUNCE and SET_PARAMETER */
@@ -334,12 +334,12 @@ static CURLcode rtsp_do(struct connectdata *conn, bool *done)
if(rtspreq == RTSPREQ_SETUP && !p_transport) {
/* New Transport: setting? */
if(data->set.str[STRING_RTSP_TRANSPORT]) {
- Curl_safefree(data->state.aptr.rtsp_transport);
+ Curl_safefree(data->state.aptr.rtsp_transport);
- data->state.aptr.rtsp_transport =
+ data->state.aptr.rtsp_transport =
aprintf("Transport: %s\r\n",
data->set.str[STRING_RTSP_TRANSPORT]);
- if(!data->state.aptr.rtsp_transport)
+ if(!data->state.aptr.rtsp_transport)
return CURLE_OUT_OF_MEMORY;
}
else {
@@ -348,7 +348,7 @@ static CURLcode rtsp_do(struct connectdata *conn, bool *done)
return CURLE_BAD_FUNCTION_ARGUMENT;
}
- p_transport = data->state.aptr.rtsp_transport;
+ p_transport = data->state.aptr.rtsp_transport;
}
/* Accept Headers for DESCRIBE requests */
@@ -360,14 +360,14 @@ static CURLcode rtsp_do(struct connectdata *conn, bool *done)
/* Accept-Encoding header */
if(!Curl_checkheaders(conn, "Accept-Encoding") &&
data->set.str[STRING_ENCODING]) {
- Curl_safefree(data->state.aptr.accept_encoding);
- data->state.aptr.accept_encoding =
+ Curl_safefree(data->state.aptr.accept_encoding);
+ data->state.aptr.accept_encoding =
aprintf("Accept-Encoding: %s\r\n", data->set.str[STRING_ENCODING]);
- if(!data->state.aptr.accept_encoding)
+ if(!data->state.aptr.accept_encoding)
return CURLE_OUT_OF_MEMORY;
- p_accept_encoding = data->state.aptr.accept_encoding;
+ p_accept_encoding = data->state.aptr.accept_encoding;
}
}
@@ -375,13 +375,13 @@ static CURLcode rtsp_do(struct connectdata *conn, bool *done)
it might have been used in the proxy connect, but if we have got a header
with the user-agent string specified, we erase the previously made string
here. */
- if(Curl_checkheaders(conn, "User-Agent") && data->state.aptr.uagent) {
- Curl_safefree(data->state.aptr.uagent);
- data->state.aptr.uagent = NULL;
+ if(Curl_checkheaders(conn, "User-Agent") && data->state.aptr.uagent) {
+ Curl_safefree(data->state.aptr.uagent);
+ data->state.aptr.uagent = NULL;
}
else if(!Curl_checkheaders(conn, "User-Agent") &&
data->set.str[STRING_USERAGENT]) {
- p_uagent = data->state.aptr.uagent;
+ p_uagent = data->state.aptr.uagent;
}
/* setup the authentication headers */
@@ -389,17 +389,17 @@ static CURLcode rtsp_do(struct connectdata *conn, bool *done)
if(result)
return result;
- p_proxyuserpwd = data->state.aptr.proxyuserpwd;
- p_userpwd = data->state.aptr.userpwd;
+ p_proxyuserpwd = data->state.aptr.proxyuserpwd;
+ p_userpwd = data->state.aptr.userpwd;
/* Referrer */
- Curl_safefree(data->state.aptr.ref);
+ Curl_safefree(data->state.aptr.ref);
if(data->change.referer && !Curl_checkheaders(conn, "Referer"))
- data->state.aptr.ref = aprintf("Referer: %s\r\n", data->change.referer);
+ data->state.aptr.ref = aprintf("Referer: %s\r\n", data->change.referer);
else
- data->state.aptr.ref = NULL;
+ data->state.aptr.ref = NULL;
- p_referrer = data->state.aptr.ref;
+ p_referrer = data->state.aptr.ref;
/*
* Range Header
@@ -412,9 +412,9 @@ static CURLcode rtsp_do(struct connectdata *conn, bool *done)
/* Check to see if there is a range set in the custom headers */
if(!Curl_checkheaders(conn, "Range") && data->state.range) {
- Curl_safefree(data->state.aptr.rangeline);
- data->state.aptr.rangeline = aprintf("Range: %s\r\n", data->state.range);
- p_range = data->state.aptr.rangeline;
+ Curl_safefree(data->state.aptr.rangeline);
+ data->state.aptr.rangeline = aprintf("Range: %s\r\n", data->state.range);
+ p_range = data->state.aptr.rangeline;
}
}
@@ -431,13 +431,13 @@ static CURLcode rtsp_do(struct connectdata *conn, bool *done)
}
/* Initialize a dynamic send buffer */
- Curl_dyn_init(&req_buffer, DYN_RTSP_REQ_HEADER);
+ Curl_dyn_init(&req_buffer, DYN_RTSP_REQ_HEADER);
result =
- Curl_dyn_addf(&req_buffer,
- "%s %s RTSP/1.0\r\n" /* Request Stream-URI RTSP/1.0 */
- "CSeq: %ld\r\n", /* CSeq */
- p_request, p_stream_uri, rtsp->CSeq_sent);
+ Curl_dyn_addf(&req_buffer,
+ "%s %s RTSP/1.0\r\n" /* Request Stream-URI RTSP/1.0 */
+ "CSeq: %ld\r\n", /* CSeq */
+ p_request, p_stream_uri, rtsp->CSeq_sent);
if(result)
return result;
@@ -446,7 +446,7 @@ static CURLcode rtsp_do(struct connectdata *conn, bool *done)
* to make comparison easier
*/
if(p_session_id) {
- result = Curl_dyn_addf(&req_buffer, "Session: %s\r\n", p_session_id);
+ result = Curl_dyn_addf(&req_buffer, "Session: %s\r\n", p_session_id);
if(result)
return result;
}
@@ -454,42 +454,42 @@ static CURLcode rtsp_do(struct connectdata *conn, bool *done)
/*
* Shared HTTP-like options
*/
- result = Curl_dyn_addf(&req_buffer,
- "%s" /* transport */
- "%s" /* accept */
- "%s" /* accept-encoding */
- "%s" /* range */
- "%s" /* referrer */
- "%s" /* user-agent */
- "%s" /* proxyuserpwd */
- "%s" /* userpwd */
- ,
- p_transport ? p_transport : "",
- p_accept ? p_accept : "",
- p_accept_encoding ? p_accept_encoding : "",
- p_range ? p_range : "",
- p_referrer ? p_referrer : "",
- p_uagent ? p_uagent : "",
- p_proxyuserpwd ? p_proxyuserpwd : "",
- p_userpwd ? p_userpwd : "");
+ result = Curl_dyn_addf(&req_buffer,
+ "%s" /* transport */
+ "%s" /* accept */
+ "%s" /* accept-encoding */
+ "%s" /* range */
+ "%s" /* referrer */
+ "%s" /* user-agent */
+ "%s" /* proxyuserpwd */
+ "%s" /* userpwd */
+ ,
+ p_transport ? p_transport : "",
+ p_accept ? p_accept : "",
+ p_accept_encoding ? p_accept_encoding : "",
+ p_range ? p_range : "",
+ p_referrer ? p_referrer : "",
+ p_uagent ? p_uagent : "",
+ p_proxyuserpwd ? p_proxyuserpwd : "",
+ p_userpwd ? p_userpwd : "");
/*
* Free userpwd now --- cannot reuse this for Negotiate and possibly NTLM
* with basic and digest, it will be freed anyway by the next request
*/
- Curl_safefree(data->state.aptr.userpwd);
- data->state.aptr.userpwd = NULL;
+ Curl_safefree(data->state.aptr.userpwd);
+ data->state.aptr.userpwd = NULL;
if(result)
return result;
if((rtspreq == RTSPREQ_SETUP) || (rtspreq == RTSPREQ_DESCRIBE)) {
- result = Curl_add_timecondition(conn, &req_buffer);
+ result = Curl_add_timecondition(conn, &req_buffer);
if(result)
return result;
}
- result = Curl_add_custom_headers(conn, FALSE, &req_buffer);
+ result = Curl_add_custom_headers(conn, FALSE, &req_buffer);
if(result)
return result;
@@ -499,14 +499,14 @@ static CURLcode rtsp_do(struct connectdata *conn, bool *done)
if(data->set.upload) {
putsize = data->state.infilesize;
- data->state.httpreq = HTTPREQ_PUT;
+ data->state.httpreq = HTTPREQ_PUT;
}
else {
postsize = (data->state.infilesize != -1)?
data->state.infilesize:
(data->set.postfields? (curl_off_t)strlen(data->set.postfields):0);
- data->state.httpreq = HTTPREQ_POST;
+ data->state.httpreq = HTTPREQ_POST;
}
if(putsize > 0 || postsize > 0) {
@@ -514,9 +514,9 @@ static CURLcode rtsp_do(struct connectdata *conn, bool *done)
* actually set a custom Content-Length in the headers */
if(!Curl_checkheaders(conn, "Content-Length")) {
result =
- Curl_dyn_addf(&req_buffer,
- "Content-Length: %" CURL_FORMAT_CURL_OFF_T"\r\n",
- (data->set.upload ? putsize : postsize));
+ Curl_dyn_addf(&req_buffer,
+ "Content-Length: %" CURL_FORMAT_CURL_OFF_T"\r\n",
+ (data->set.upload ? putsize : postsize));
if(result)
return result;
}
@@ -524,8 +524,8 @@ static CURLcode rtsp_do(struct connectdata *conn, bool *done)
if(rtspreq == RTSPREQ_SET_PARAMETER ||
rtspreq == RTSPREQ_GET_PARAMETER) {
if(!Curl_checkheaders(conn, "Content-Type")) {
- result = Curl_dyn_addf(&req_buffer,
- "Content-Type: text/parameters\r\n");
+ result = Curl_dyn_addf(&req_buffer,
+ "Content-Type: text/parameters\r\n");
if(result)
return result;
}
@@ -533,8 +533,8 @@ static CURLcode rtsp_do(struct connectdata *conn, bool *done)
if(rtspreq == RTSPREQ_ANNOUNCE) {
if(!Curl_checkheaders(conn, "Content-Type")) {
- result = Curl_dyn_addf(&req_buffer,
- "Content-Type: application/sdp\r\n");
+ result = Curl_dyn_addf(&req_buffer,
+ "Content-Type: application/sdp\r\n");
if(result)
return result;
}
@@ -544,7 +544,7 @@ static CURLcode rtsp_do(struct connectdata *conn, bool *done)
}
else if(rtspreq == RTSPREQ_GET_PARAMETER) {
/* Check for an empty GET_PARAMETER (heartbeat) request */
- data->state.httpreq = HTTPREQ_HEAD;
+ data->state.httpreq = HTTPREQ_HEAD;
data->set.opt_no_body = TRUE;
}
}
@@ -552,20 +552,20 @@ static CURLcode rtsp_do(struct connectdata *conn, bool *done)
/* RTSP never allows chunked transfer */
data->req.forbidchunk = TRUE;
/* Finish the request buffer */
- result = Curl_dyn_add(&req_buffer, "\r\n");
+ result = Curl_dyn_add(&req_buffer, "\r\n");
if(result)
return result;
if(postsize > 0) {
- result = Curl_dyn_addn(&req_buffer, data->set.postfields,
- (size_t)postsize);
+ result = Curl_dyn_addn(&req_buffer, data->set.postfields,
+ (size_t)postsize);
if(result)
return result;
}
/* issue the request */
- result = Curl_buffer_send(&req_buffer, conn,
- &data->info.request_size, 0, FIRSTSOCKET);
+ result = Curl_buffer_send(&req_buffer, conn,
+ &data->info.request_size, 0, FIRSTSOCKET);
if(result) {
failf(data, "Failed sending RTSP request");
return result;
@@ -765,7 +765,7 @@ CURLcode Curl_rtsp_parseheader(struct connectdata *conn,
/* Store the received CSeq. Match is verified in rtsp_done */
int nc = sscanf(&header[4], ": %ld", &CSeq);
if(nc == 1) {
- struct RTSP *rtsp = data->req.p.rtsp;
+ struct RTSP *rtsp = data->req.p.rtsp;
rtsp->CSeq_recv = CSeq; /* mark the request */
data->state.rtsp_CSeq_recv = CSeq; /* update the handle */
}
@@ -776,8 +776,8 @@ CURLcode Curl_rtsp_parseheader(struct connectdata *conn,
}
else if(checkprefix("Session:", header)) {
char *start;
- char *end;
- size_t idlen;
+ char *end;
+ size_t idlen;
/* Find the first non-space letter */
start = header + 8;
@@ -786,25 +786,25 @@ CURLcode Curl_rtsp_parseheader(struct connectdata *conn,
if(!*start) {
failf(data, "Got a blank Session ID");
- return CURLE_RTSP_SESSION_ERROR;
+ return CURLE_RTSP_SESSION_ERROR;
}
-
- /* Find the end of Session ID
- *
- * Allow any non whitespace content, up to the field separator or end of
- * line. RFC 2326 isn't 100% clear on the session ID and for example
- * gstreamer does url-encoded session ID's not covered by the standard.
- */
- end = start;
- while(*end && *end != ';' && !ISSPACE(*end))
- end++;
- idlen = end - start;
-
- if(data->set.str[STRING_RTSP_SESSION_ID]) {
-
+
+ /* Find the end of Session ID
+ *
+ * Allow any non whitespace content, up to the field separator or end of
+ * line. RFC 2326 isn't 100% clear on the session ID and for example
+ * gstreamer does url-encoded session ID's not covered by the standard.
+ */
+ end = start;
+ while(*end && *end != ';' && !ISSPACE(*end))
+ end++;
+ idlen = end - start;
+
+ if(data->set.str[STRING_RTSP_SESSION_ID]) {
+
/* If the Session ID is set, then compare */
- if(strlen(data->set.str[STRING_RTSP_SESSION_ID]) != idlen ||
- strncmp(start, data->set.str[STRING_RTSP_SESSION_ID], idlen) != 0) {
+ if(strlen(data->set.str[STRING_RTSP_SESSION_ID]) != idlen ||
+ strncmp(start, data->set.str[STRING_RTSP_SESSION_ID], idlen) != 0) {
failf(data, "Got RTSP Session ID Line [%s], but wanted ID [%s]",
start, data->set.str[STRING_RTSP_SESSION_ID]);
return CURLE_RTSP_SESSION_ERROR;
@@ -816,11 +816,11 @@ CURLcode Curl_rtsp_parseheader(struct connectdata *conn,
*/
/* Copy the id substring into a new buffer */
- data->set.str[STRING_RTSP_SESSION_ID] = malloc(idlen + 1);
+ data->set.str[STRING_RTSP_SESSION_ID] = malloc(idlen + 1);
if(data->set.str[STRING_RTSP_SESSION_ID] == NULL)
return CURLE_OUT_OF_MEMORY;
- memcpy(data->set.str[STRING_RTSP_SESSION_ID], start, idlen);
- (data->set.str[STRING_RTSP_SESSION_ID])[idlen] = '\0';
+ memcpy(data->set.str[STRING_RTSP_SESSION_ID], start, idlen);
+ (data->set.str[STRING_RTSP_SESSION_ID])[idlen] = '\0';
}
}
return CURLE_OK;
diff --git a/contrib/libs/curl/lib/rtsp.h b/contrib/libs/curl/lib/rtsp.h
index 9847321f1d..bf7f0bc8ef 100644
--- a/contrib/libs/curl/lib/rtsp.h
+++ b/contrib/libs/curl/lib/rtsp.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/select.c b/contrib/libs/curl/lib/select.c
index 67276b1052..7d1f944cdb 100644
--- a/contrib/libs/curl/lib/select.c
+++ b/contrib/libs/curl/lib/select.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -22,12 +22,12 @@
#include "curl_setup.h"
-#include <limits.h>
-
+#include <limits.h>
+
#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
-#elif defined(HAVE_UNISTD_H)
-#include <unistd.h>
+#elif defined(HAVE_UNISTD_H)
+#include <unistd.h>
#endif
#if !defined(HAVE_SELECT) && !defined(HAVE_POLL_FINE)
@@ -52,7 +52,7 @@
#include "urldata.h"
#include "connect.h"
#include "select.h"
-#include "timeval.h"
+#include "timeval.h"
#include "warnless.h"
/*
@@ -71,7 +71,7 @@
* -1 = system call error, invalid timeout value, or interrupted
* 0 = specified timeout has elapsed
*/
-int Curl_wait_ms(timediff_t timeout_ms)
+int Curl_wait_ms(timediff_t timeout_ms)
{
int r = 0;
@@ -83,46 +83,46 @@ int Curl_wait_ms(timediff_t timeout_ms)
}
#if defined(MSDOS)
delay(timeout_ms);
-#elif defined(WIN32)
- /* prevent overflow, timeout_ms is typecast to ULONG/DWORD. */
-#if TIMEDIFF_T_MAX >= ULONG_MAX
- if(timeout_ms >= ULONG_MAX)
- timeout_ms = ULONG_MAX-1;
- /* don't use ULONG_MAX, because that is equal to INFINITE */
-#endif
- Sleep((ULONG)timeout_ms);
+#elif defined(WIN32)
+ /* prevent overflow, timeout_ms is typecast to ULONG/DWORD. */
+#if TIMEDIFF_T_MAX >= ULONG_MAX
+ if(timeout_ms >= ULONG_MAX)
+ timeout_ms = ULONG_MAX-1;
+ /* don't use ULONG_MAX, because that is equal to INFINITE */
+#endif
+ Sleep((ULONG)timeout_ms);
#else
#if defined(HAVE_POLL_FINE)
- /* prevent overflow, timeout_ms is typecast to int. */
-#if TIMEDIFF_T_MAX > INT_MAX
- if(timeout_ms > INT_MAX)
- timeout_ms = INT_MAX;
-#endif
- r = poll(NULL, 0, (int)timeout_ms);
+ /* prevent overflow, timeout_ms is typecast to int. */
+#if TIMEDIFF_T_MAX > INT_MAX
+ if(timeout_ms > INT_MAX)
+ timeout_ms = INT_MAX;
+#endif
+ r = poll(NULL, 0, (int)timeout_ms);
#else
- {
- struct timeval pending_tv;
- timediff_t tv_sec = timeout_ms / 1000;
- timediff_t tv_usec = (timeout_ms % 1000) * 1000; /* max=999999 */
-#ifdef HAVE_SUSECONDS_T
-#if TIMEDIFF_T_MAX > TIME_T_MAX
- /* tv_sec overflow check in case time_t is signed */
- if(tv_sec > TIME_T_MAX)
- tv_sec = TIME_T_MAX;
-#endif
- pending_tv.tv_sec = (time_t)tv_sec;
- pending_tv.tv_usec = (suseconds_t)tv_usec;
-#else
-#if TIMEDIFF_T_MAX > INT_MAX
- /* tv_sec overflow check in case time_t is signed */
- if(tv_sec > INT_MAX)
- tv_sec = INT_MAX;
-#endif
- pending_tv.tv_sec = (int)tv_sec;
- pending_tv.tv_usec = (int)tv_usec;
-#endif
+ {
+ struct timeval pending_tv;
+ timediff_t tv_sec = timeout_ms / 1000;
+ timediff_t tv_usec = (timeout_ms % 1000) * 1000; /* max=999999 */
+#ifdef HAVE_SUSECONDS_T
+#if TIMEDIFF_T_MAX > TIME_T_MAX
+ /* tv_sec overflow check in case time_t is signed */
+ if(tv_sec > TIME_T_MAX)
+ tv_sec = TIME_T_MAX;
+#endif
+ pending_tv.tv_sec = (time_t)tv_sec;
+ pending_tv.tv_usec = (suseconds_t)tv_usec;
+#else
+#if TIMEDIFF_T_MAX > INT_MAX
+ /* tv_sec overflow check in case time_t is signed */
+ if(tv_sec > INT_MAX)
+ tv_sec = INT_MAX;
+#endif
+ pending_tv.tv_sec = (int)tv_sec;
+ pending_tv.tv_usec = (int)tv_usec;
+#endif
r = select(0, NULL, NULL, NULL, &pending_tv);
- }
+ }
#endif /* HAVE_POLL_FINE */
#endif /* USE_WINSOCK */
if(r)
@@ -131,96 +131,96 @@ int Curl_wait_ms(timediff_t timeout_ms)
}
/*
- * This is a wrapper around select() to aid in Windows compatibility.
- * A negative timeout value makes this function wait indefinitely,
- * unless no valid file descriptor is given, when this happens the
- * negative timeout is ignored and the function times out immediately.
- *
- * Return values:
- * -1 = system call error or fd >= FD_SETSIZE
- * 0 = timeout
- * N = number of signalled file descriptors
- */
-int Curl_select(curl_socket_t maxfd, /* highest socket number */
- fd_set *fds_read, /* sockets ready for reading */
- fd_set *fds_write, /* sockets ready for writing */
- fd_set *fds_err, /* sockets with errors */
- timediff_t timeout_ms) /* milliseconds to wait */
-{
- struct timeval pending_tv;
- struct timeval *ptimeout;
-
-#ifdef USE_WINSOCK
- /* WinSock select() can't handle zero events. See the comment below. */
- if((!fds_read || fds_read->fd_count == 0) &&
- (!fds_write || fds_write->fd_count == 0) &&
- (!fds_err || fds_err->fd_count == 0)) {
- /* no sockets, just wait */
- return Curl_wait_ms(timeout_ms);
- }
-#endif
-
- ptimeout = &pending_tv;
- if(timeout_ms < 0) {
- ptimeout = NULL;
- }
- else if(timeout_ms > 0) {
- timediff_t tv_sec = timeout_ms / 1000;
- timediff_t tv_usec = (timeout_ms % 1000) * 1000; /* max=999999 */
-#ifdef HAVE_SUSECONDS_T
-#if TIMEDIFF_T_MAX > TIME_T_MAX
- /* tv_sec overflow check in case time_t is signed */
- if(tv_sec > TIME_T_MAX)
- tv_sec = TIME_T_MAX;
-#endif
- pending_tv.tv_sec = (time_t)tv_sec;
- pending_tv.tv_usec = (suseconds_t)tv_usec;
-#elif defined(WIN32) /* maybe also others in the future */
-#if TIMEDIFF_T_MAX > LONG_MAX
- /* tv_sec overflow check on Windows there we know it is long */
- if(tv_sec > LONG_MAX)
- tv_sec = LONG_MAX;
-#endif
- pending_tv.tv_sec = (long)tv_sec;
- pending_tv.tv_usec = (long)tv_usec;
-#else
-#if TIMEDIFF_T_MAX > INT_MAX
- /* tv_sec overflow check in case time_t is signed */
- if(tv_sec > INT_MAX)
- tv_sec = INT_MAX;
-#endif
- pending_tv.tv_sec = (int)tv_sec;
- pending_tv.tv_usec = (int)tv_usec;
-#endif
- }
- else {
- pending_tv.tv_sec = 0;
- pending_tv.tv_usec = 0;
- }
-
-#ifdef USE_WINSOCK
- /* WinSock select() must not be called with an fd_set that contains zero
- fd flags, or it will return WSAEINVAL. But, it also can't be called
- with no fd_sets at all! From the documentation:
-
- Any two of the parameters, readfds, writefds, or exceptfds, can be
- given as null. At least one must be non-null, and any non-null
- descriptor set must contain at least one handle to a socket.
-
- It is unclear why WinSock doesn't just handle this for us instead of
- calling this an error. Luckily, with WinSock, we can _also_ ask how
- many bits are set on an fd_set. So, let's just check it beforehand.
- */
- return select((int)maxfd + 1,
- fds_read && fds_read->fd_count ? fds_read : NULL,
- fds_write && fds_write->fd_count ? fds_write : NULL,
- fds_err && fds_err->fd_count ? fds_err : NULL, ptimeout);
-#else
- return select((int)maxfd + 1, fds_read, fds_write, fds_err, ptimeout);
-#endif
-}
-
-/*
+ * This is a wrapper around select() to aid in Windows compatibility.
+ * A negative timeout value makes this function wait indefinitely,
+ * unless no valid file descriptor is given, when this happens the
+ * negative timeout is ignored and the function times out immediately.
+ *
+ * Return values:
+ * -1 = system call error or fd >= FD_SETSIZE
+ * 0 = timeout
+ * N = number of signalled file descriptors
+ */
+int Curl_select(curl_socket_t maxfd, /* highest socket number */
+ fd_set *fds_read, /* sockets ready for reading */
+ fd_set *fds_write, /* sockets ready for writing */
+ fd_set *fds_err, /* sockets with errors */
+ timediff_t timeout_ms) /* milliseconds to wait */
+{
+ struct timeval pending_tv;
+ struct timeval *ptimeout;
+
+#ifdef USE_WINSOCK
+ /* WinSock select() can't handle zero events. See the comment below. */
+ if((!fds_read || fds_read->fd_count == 0) &&
+ (!fds_write || fds_write->fd_count == 0) &&
+ (!fds_err || fds_err->fd_count == 0)) {
+ /* no sockets, just wait */
+ return Curl_wait_ms(timeout_ms);
+ }
+#endif
+
+ ptimeout = &pending_tv;
+ if(timeout_ms < 0) {
+ ptimeout = NULL;
+ }
+ else if(timeout_ms > 0) {
+ timediff_t tv_sec = timeout_ms / 1000;
+ timediff_t tv_usec = (timeout_ms % 1000) * 1000; /* max=999999 */
+#ifdef HAVE_SUSECONDS_T
+#if TIMEDIFF_T_MAX > TIME_T_MAX
+ /* tv_sec overflow check in case time_t is signed */
+ if(tv_sec > TIME_T_MAX)
+ tv_sec = TIME_T_MAX;
+#endif
+ pending_tv.tv_sec = (time_t)tv_sec;
+ pending_tv.tv_usec = (suseconds_t)tv_usec;
+#elif defined(WIN32) /* maybe also others in the future */
+#if TIMEDIFF_T_MAX > LONG_MAX
+ /* tv_sec overflow check on Windows there we know it is long */
+ if(tv_sec > LONG_MAX)
+ tv_sec = LONG_MAX;
+#endif
+ pending_tv.tv_sec = (long)tv_sec;
+ pending_tv.tv_usec = (long)tv_usec;
+#else
+#if TIMEDIFF_T_MAX > INT_MAX
+ /* tv_sec overflow check in case time_t is signed */
+ if(tv_sec > INT_MAX)
+ tv_sec = INT_MAX;
+#endif
+ pending_tv.tv_sec = (int)tv_sec;
+ pending_tv.tv_usec = (int)tv_usec;
+#endif
+ }
+ else {
+ pending_tv.tv_sec = 0;
+ pending_tv.tv_usec = 0;
+ }
+
+#ifdef USE_WINSOCK
+ /* WinSock select() must not be called with an fd_set that contains zero
+ fd flags, or it will return WSAEINVAL. But, it also can't be called
+ with no fd_sets at all! From the documentation:
+
+ Any two of the parameters, readfds, writefds, or exceptfds, can be
+ given as null. At least one must be non-null, and any non-null
+ descriptor set must contain at least one handle to a socket.
+
+ It is unclear why WinSock doesn't just handle this for us instead of
+ calling this an error. Luckily, with WinSock, we can _also_ ask how
+ many bits are set on an fd_set. So, let's just check it beforehand.
+ */
+ return select((int)maxfd + 1,
+ fds_read && fds_read->fd_count ? fds_read : NULL,
+ fds_write && fds_write->fd_count ? fds_write : NULL,
+ fds_err && fds_err->fd_count ? fds_err : NULL, ptimeout);
+#else
+ return select((int)maxfd + 1, fds_read, fds_write, fds_err, ptimeout);
+#endif
+}
+
+/*
* Wait for read or write events on a set of file descriptors. It uses poll()
* when a fine poll() is available, in order to avoid limits with FD_SETSIZE,
* otherwise select() is used. An error is returned if select() is being used
@@ -243,7 +243,7 @@ int Curl_select(curl_socket_t maxfd, /* highest socket number */
int Curl_socket_check(curl_socket_t readfd0, /* two sockets to read from */
curl_socket_t readfd1,
curl_socket_t writefd, /* socket to write to */
- timediff_t timeout_ms) /* milliseconds to wait */
+ timediff_t timeout_ms) /* milliseconds to wait */
{
struct pollfd pfd[3];
int num;
@@ -252,7 +252,7 @@ int Curl_socket_check(curl_socket_t readfd0, /* two sockets to read from */
if((readfd0 == CURL_SOCKET_BAD) && (readfd1 == CURL_SOCKET_BAD) &&
(writefd == CURL_SOCKET_BAD)) {
/* no sockets, just wait */
- return Curl_wait_ms(timeout_ms);
+ return Curl_wait_ms(timeout_ms);
}
/* Avoid initial timestamp, avoid Curl_now() call, when elapsed
@@ -275,39 +275,39 @@ int Curl_socket_check(curl_socket_t readfd0, /* two sockets to read from */
}
if(writefd != CURL_SOCKET_BAD) {
pfd[num].fd = writefd;
- pfd[num].events = POLLWRNORM|POLLOUT|POLLPRI;
+ pfd[num].events = POLLWRNORM|POLLOUT|POLLPRI;
pfd[num].revents = 0;
num++;
}
- r = Curl_poll(pfd, num, timeout_ms);
- if(r <= 0)
- return r;
+ r = Curl_poll(pfd, num, timeout_ms);
+ if(r <= 0)
+ return r;
- r = 0;
+ r = 0;
num = 0;
if(readfd0 != CURL_SOCKET_BAD) {
if(pfd[num].revents & (POLLRDNORM|POLLIN|POLLERR|POLLHUP))
- r |= CURL_CSELECT_IN;
+ r |= CURL_CSELECT_IN;
if(pfd[num].revents & (POLLRDBAND|POLLPRI|POLLNVAL))
- r |= CURL_CSELECT_ERR;
+ r |= CURL_CSELECT_ERR;
num++;
}
if(readfd1 != CURL_SOCKET_BAD) {
if(pfd[num].revents & (POLLRDNORM|POLLIN|POLLERR|POLLHUP))
- r |= CURL_CSELECT_IN2;
+ r |= CURL_CSELECT_IN2;
if(pfd[num].revents & (POLLRDBAND|POLLPRI|POLLNVAL))
- r |= CURL_CSELECT_ERR;
+ r |= CURL_CSELECT_ERR;
num++;
}
if(writefd != CURL_SOCKET_BAD) {
if(pfd[num].revents & (POLLWRNORM|POLLOUT))
- r |= CURL_CSELECT_OUT;
- if(pfd[num].revents & (POLLERR|POLLHUP|POLLPRI|POLLNVAL))
- r |= CURL_CSELECT_ERR;
+ r |= CURL_CSELECT_OUT;
+ if(pfd[num].revents & (POLLERR|POLLHUP|POLLPRI|POLLNVAL))
+ r |= CURL_CSELECT_ERR;
}
- return r;
+ return r;
}
/*
@@ -323,11 +323,11 @@ int Curl_socket_check(curl_socket_t readfd0, /* two sockets to read from */
* 0 = timeout
* N = number of structures with non zero revent fields
*/
-int Curl_poll(struct pollfd ufds[], unsigned int nfds, timediff_t timeout_ms)
+int Curl_poll(struct pollfd ufds[], unsigned int nfds, timediff_t timeout_ms)
{
-#ifdef HAVE_POLL_FINE
- int pending_ms;
-#else
+#ifdef HAVE_POLL_FINE
+ int pending_ms;
+#else
fd_set fds_read;
fd_set fds_write;
fd_set fds_err;
@@ -346,8 +346,8 @@ int Curl_poll(struct pollfd ufds[], unsigned int nfds, timediff_t timeout_ms)
}
}
if(fds_none) {
- /* no sockets, just wait */
- return Curl_wait_ms(timeout_ms);
+ /* no sockets, just wait */
+ return Curl_wait_ms(timeout_ms);
}
/* Avoid initial timestamp, avoid Curl_now() call, when elapsed
@@ -357,20 +357,20 @@ int Curl_poll(struct pollfd ufds[], unsigned int nfds, timediff_t timeout_ms)
#ifdef HAVE_POLL_FINE
- /* prevent overflow, timeout_ms is typecast to int. */
-#if TIMEDIFF_T_MAX > INT_MAX
- if(timeout_ms > INT_MAX)
- timeout_ms = INT_MAX;
-#endif
- if(timeout_ms > 0)
- pending_ms = (int)timeout_ms;
- else if(timeout_ms < 0)
- pending_ms = -1;
- else
- pending_ms = 0;
- r = poll(ufds, nfds, pending_ms);
- if(r <= 0)
- return r;
+ /* prevent overflow, timeout_ms is typecast to int. */
+#if TIMEDIFF_T_MAX > INT_MAX
+ if(timeout_ms > INT_MAX)
+ timeout_ms = INT_MAX;
+#endif
+ if(timeout_ms > 0)
+ pending_ms = (int)timeout_ms;
+ else if(timeout_ms < 0)
+ pending_ms = -1;
+ else
+ pending_ms = 0;
+ r = poll(ufds, nfds, pending_ms);
+ if(r <= 0)
+ return r;
for(i = 0; i < nfds; i++) {
if(ufds[i].fd == CURL_SOCKET_BAD)
@@ -378,7 +378,7 @@ int Curl_poll(struct pollfd ufds[], unsigned int nfds, timediff_t timeout_ms)
if(ufds[i].revents & POLLHUP)
ufds[i].revents |= POLLIN;
if(ufds[i].revents & POLLERR)
- ufds[i].revents |= POLLIN|POLLOUT;
+ ufds[i].revents |= POLLIN|POLLOUT;
}
#else /* HAVE_POLL_FINE */
@@ -394,7 +394,7 @@ int Curl_poll(struct pollfd ufds[], unsigned int nfds, timediff_t timeout_ms)
continue;
VERIFY_SOCK(ufds[i].fd);
if(ufds[i].events & (POLLIN|POLLOUT|POLLPRI|
- POLLRDNORM|POLLWRNORM|POLLRDBAND)) {
+ POLLRDNORM|POLLWRNORM|POLLRDBAND)) {
if(ufds[i].fd > maxfd)
maxfd = ufds[i].fd;
if(ufds[i].events & (POLLRDNORM|POLLIN))
@@ -406,14 +406,14 @@ int Curl_poll(struct pollfd ufds[], unsigned int nfds, timediff_t timeout_ms)
}
}
- /*
- Note also that WinSock ignores the first argument, so we don't worry
- about the fact that maxfd is computed incorrectly with WinSock (since
- curl_socket_t is unsigned in such cases and thus -1 is the largest
- value).
- */
- r = Curl_select(maxfd, &fds_read, &fds_write, &fds_err, timeout_ms);
- if(r <= 0)
+ /*
+ Note also that WinSock ignores the first argument, so we don't worry
+ about the fact that maxfd is computed incorrectly with WinSock (since
+ curl_socket_t is unsigned in such cases and thus -1 is the largest
+ value).
+ */
+ r = Curl_select(maxfd, &fds_read, &fds_write, &fds_err, timeout_ms);
+ if(r <= 0)
return r;
r = 0;
@@ -421,24 +421,24 @@ int Curl_poll(struct pollfd ufds[], unsigned int nfds, timediff_t timeout_ms)
ufds[i].revents = 0;
if(ufds[i].fd == CURL_SOCKET_BAD)
continue;
- if(FD_ISSET(ufds[i].fd, &fds_read)) {
- if(ufds[i].events & POLLRDNORM)
- ufds[i].revents |= POLLRDNORM;
- if(ufds[i].events & POLLIN)
- ufds[i].revents |= POLLIN;
- }
- if(FD_ISSET(ufds[i].fd, &fds_write)) {
- if(ufds[i].events & POLLWRNORM)
- ufds[i].revents |= POLLWRNORM;
- if(ufds[i].events & POLLOUT)
- ufds[i].revents |= POLLOUT;
- }
- if(FD_ISSET(ufds[i].fd, &fds_err)) {
- if(ufds[i].events & POLLRDBAND)
- ufds[i].revents |= POLLRDBAND;
- if(ufds[i].events & POLLPRI)
- ufds[i].revents |= POLLPRI;
- }
+ if(FD_ISSET(ufds[i].fd, &fds_read)) {
+ if(ufds[i].events & POLLRDNORM)
+ ufds[i].revents |= POLLRDNORM;
+ if(ufds[i].events & POLLIN)
+ ufds[i].revents |= POLLIN;
+ }
+ if(FD_ISSET(ufds[i].fd, &fds_write)) {
+ if(ufds[i].events & POLLWRNORM)
+ ufds[i].revents |= POLLWRNORM;
+ if(ufds[i].events & POLLOUT)
+ ufds[i].revents |= POLLOUT;
+ }
+ if(FD_ISSET(ufds[i].fd, &fds_err)) {
+ if(ufds[i].events & POLLRDBAND)
+ ufds[i].revents |= POLLRDBAND;
+ if(ufds[i].events & POLLPRI)
+ ufds[i].revents |= POLLPRI;
+ }
if(ufds[i].revents != 0)
r++;
}
diff --git a/contrib/libs/curl/lib/select.h b/contrib/libs/curl/lib/select.h
index 961d122e54..1350950439 100644
--- a/contrib/libs/curl/lib/select.h
+++ b/contrib/libs/curl/lib/select.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -72,45 +72,45 @@ struct pollfd
therefore defined here */
#define CURL_CSELECT_IN2 (CURL_CSELECT_ERR << 1)
-int Curl_select(curl_socket_t maxfd,
- fd_set *fds_read,
- fd_set *fds_write,
- fd_set *fds_err,
- timediff_t timeout_ms);
-
+int Curl_select(curl_socket_t maxfd,
+ fd_set *fds_read,
+ fd_set *fds_write,
+ fd_set *fds_err,
+ timediff_t timeout_ms);
+
int Curl_socket_check(curl_socket_t readfd, curl_socket_t readfd2,
curl_socket_t writefd,
- timediff_t timeout_ms);
+ timediff_t timeout_ms);
#define SOCKET_READABLE(x,z) \
- Curl_socket_check(x, CURL_SOCKET_BAD, CURL_SOCKET_BAD, z)
+ Curl_socket_check(x, CURL_SOCKET_BAD, CURL_SOCKET_BAD, z)
#define SOCKET_WRITABLE(x,z) \
- Curl_socket_check(CURL_SOCKET_BAD, CURL_SOCKET_BAD, x, z)
+ Curl_socket_check(CURL_SOCKET_BAD, CURL_SOCKET_BAD, x, z)
-int Curl_poll(struct pollfd ufds[], unsigned int nfds, timediff_t timeout_ms);
-int Curl_wait_ms(timediff_t timeout_ms);
+int Curl_poll(struct pollfd ufds[], unsigned int nfds, timediff_t timeout_ms);
+int Curl_wait_ms(timediff_t timeout_ms);
#ifdef TPF
int tpf_select_libcurl(int maxfds, fd_set* reads, fd_set* writes,
- fd_set* excepts, struct timeval *tv);
+ fd_set* excepts, struct timeval *tv);
#endif
-/* TPF sockets are not in range [0..FD_SETSIZE-1], which
+/* TPF sockets are not in range [0..FD_SETSIZE-1], which
unfortunately makes it impossible for us to easily check if they're valid
-
- With Winsock the valid range is [0..INVALID_SOCKET-1] according to
- https://docs.microsoft.com/en-us/windows/win32/winsock/socket-data-type-2
+
+ With Winsock the valid range is [0..INVALID_SOCKET-1] according to
+ https://docs.microsoft.com/en-us/windows/win32/winsock/socket-data-type-2
*/
-#if defined(TPF)
+#if defined(TPF)
#define VALID_SOCK(x) 1
#define VERIFY_SOCK(x) Curl_nop_stmt
-#elif defined(USE_WINSOCK)
-#define VALID_SOCK(s) ((s) < INVALID_SOCKET)
-#define VERIFY_SOCK(x) do { \
- if(!VALID_SOCK(x)) { \
- SET_SOCKERRNO(WSAEINVAL); \
- return -1; \
- } \
-} while(0)
+#elif defined(USE_WINSOCK)
+#define VALID_SOCK(s) ((s) < INVALID_SOCKET)
+#define VERIFY_SOCK(x) do { \
+ if(!VALID_SOCK(x)) { \
+ SET_SOCKERRNO(WSAEINVAL); \
+ return -1; \
+ } \
+} while(0)
#else
#define VALID_SOCK(s) (((s) >= 0) && ((s) < FD_SETSIZE))
#define VERIFY_SOCK(x) do { \
@@ -118,7 +118,7 @@ int tpf_select_libcurl(int maxfds, fd_set* reads, fd_set* writes,
SET_SOCKERRNO(EINVAL); \
return -1; \
} \
-} while(0)
+} while(0)
#endif
#endif /* HEADER_CURL_SELECT_H */
diff --git a/contrib/libs/curl/lib/sendf.c b/contrib/libs/curl/lib/sendf.c
index 10980ef755..04cc725f5a 100644
--- a/contrib/libs/curl/lib/sendf.c
+++ b/contrib/libs/curl/lib/sendf.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -28,8 +28,8 @@
#ifdef HAVE_LINUX_TCP_H
#include <linux/tcp.h>
-#elif defined(HAVE_NETINET_TCP_H)
-#include <netinet/tcp.h>
+#elif defined(HAVE_NETINET_TCP_H)
+#include <netinet/tcp.h>
#endif
#include <curl/curl.h>
@@ -38,14 +38,14 @@
#include "sendf.h"
#include "connect.h"
#include "vtls/vtls.h"
-#include "vssh/ssh.h"
+#include "vssh/ssh.h"
#include "easyif.h"
#include "multiif.h"
#include "non-ascii.h"
#include "strerror.h"
#include "select.h"
#include "strdup.h"
-#include "http2.h"
+#include "http2.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
@@ -142,7 +142,7 @@ bool Curl_recv_has_postponed_data(struct connectdata *conn, int sockindex)
psnd->recv_size > psnd->recv_processed;
}
-static CURLcode pre_receive_plain(struct connectdata *conn, int num)
+static CURLcode pre_receive_plain(struct connectdata *conn, int num)
{
const curl_socket_t sockfd = conn->sock[num];
struct postponed_data * const psnd = &(conn->postponed[num]);
@@ -163,8 +163,8 @@ static CURLcode pre_receive_plain(struct connectdata *conn, int num)
/* Use buffer double default size for intermediate buffer */
psnd->allocated_size = 2 * conn->data->set.buffer_size;
psnd->buffer = malloc(psnd->allocated_size);
- if(!psnd->buffer)
- return CURLE_OUT_OF_MEMORY;
+ if(!psnd->buffer)
+ return CURLE_OUT_OF_MEMORY;
psnd->recv_size = 0;
psnd->recv_processed = 0;
#ifdef DEBUGBUILD
@@ -184,7 +184,7 @@ static CURLcode pre_receive_plain(struct connectdata *conn, int num)
psnd->allocated_size = 0;
}
}
- return CURLE_OK;
+ return CURLE_OK;
}
static ssize_t get_pre_recved(struct connectdata *conn, int num, char *buf,
@@ -230,7 +230,7 @@ bool Curl_recv_has_postponed_data(struct connectdata *conn, int sockindex)
(void)sockindex;
return false;
}
-#define pre_receive_plain(c,n) CURLE_OK
+#define pre_receive_plain(c,n) CURLE_OK
#define get_pre_recved(c,n,b,l) 0
#endif /* ! USE_RECV_BEFORE_SEND_WORKAROUND */
@@ -272,15 +272,15 @@ void Curl_failf(struct Curl_easy *data, const char *fmt, ...)
size_t len;
char error[CURL_ERROR_SIZE + 2];
va_start(ap, fmt);
- (void)mvsnprintf(error, CURL_ERROR_SIZE, fmt, ap);
+ (void)mvsnprintf(error, CURL_ERROR_SIZE, fmt, ap);
len = strlen(error);
if(data->set.errorbuffer && !data->state.errorbuf) {
strcpy(data->set.errorbuffer, error);
data->state.errorbuf = TRUE; /* wrote error string */
}
- error[len++] = '\n';
- Curl_debug(data, CURLINFO_TEXT, error, len);
+ error[len++] = '\n';
+ Curl_debug(data, CURLINFO_TEXT, error, len);
va_end(ap);
}
}
@@ -335,10 +335,10 @@ ssize_t Curl_send_plain(struct connectdata *conn, int num,
To avoid lossage of received data, recv() must be
performed before every send() if any incoming data is
available. */
- if(pre_receive_plain(conn, num)) {
- *code = CURLE_OUT_OF_MEMORY;
- return -1;
- }
+ if(pre_receive_plain(conn, num)) {
+ *code = CURLE_OUT_OF_MEMORY;
+ return -1;
+ }
#if defined(MSG_FASTOPEN) && !defined(TCP_FASTOPEN_CONNECT) /* Linux */
if(conn->bits.tcp_fastopen) {
@@ -460,9 +460,9 @@ static CURLcode pausewrite(struct Curl_easy *data,
unsigned int i;
bool newtype = TRUE;
- /* If this transfers over HTTP/2, pause the stream! */
- Curl_http2_stream_pause(data, TRUE);
-
+ /* If this transfers over HTTP/2, pause the stream! */
+ Curl_http2_stream_pause(data, TRUE);
+
if(s->tempcount) {
for(i = 0; i< s->tempcount; i++) {
if(s->tempwrite[i].type == type) {
@@ -476,18 +476,18 @@ static CURLcode pausewrite(struct Curl_easy *data,
else
i = 0;
- if(newtype) {
+ if(newtype) {
/* store this information in the state struct for later use */
- Curl_dyn_init(&s->tempwrite[i].b, DYN_PAUSE_BUFFER);
+ Curl_dyn_init(&s->tempwrite[i].b, DYN_PAUSE_BUFFER);
s->tempwrite[i].type = type;
if(newtype)
s->tempcount++;
}
- if(Curl_dyn_addn(&s->tempwrite[i].b, (unsigned char *)ptr, len))
- return CURLE_OUT_OF_MEMORY;
-
+ if(Curl_dyn_addn(&s->tempwrite[i].b, (unsigned char *)ptr, len))
+ return CURLE_OUT_OF_MEMORY;
+
/* mark the connection as RECV paused */
k->keepon |= KEEP_RECV_PAUSE;
@@ -552,7 +552,7 @@ static CURLcode chop_write(struct connectdata *conn,
return pausewrite(data, type, ptr, len);
}
if(wrote != chunklen) {
- failf(data, "Failure writing output to destination");
+ failf(data, "Failure writing output to destination");
return CURLE_WRITE_ERROR;
}
}
@@ -633,15 +633,15 @@ CURLcode Curl_read_plain(curl_socket_t sockfd,
ssize_t nread = sread(sockfd, buf, bytesfromsocket);
if(-1 == nread) {
- const int err = SOCKERRNO;
- const bool return_error =
+ const int err = SOCKERRNO;
+ const bool return_error =
#ifdef USE_WINSOCK
- WSAEWOULDBLOCK == err
+ WSAEWOULDBLOCK == err
#else
- EWOULDBLOCK == err || EAGAIN == err || EINTR == err
+ EWOULDBLOCK == err || EAGAIN == err || EINTR == err
#endif
- ;
- *n = 0; /* no data returned */
+ ;
+ *n = 0; /* no data returned */
if(return_error)
return CURLE_AGAIN;
return CURLE_RECV_ERROR;
@@ -693,73 +693,73 @@ int Curl_debug(struct Curl_easy *data, curl_infotype type,
char *ptr, size_t size)
{
int rc = 0;
- if(data->set.verbose) {
- static const char s_infotype[CURLINFO_END][3] = {
- "* ", "< ", "> ", "{ ", "} ", "{ ", "} " };
+ if(data->set.verbose) {
+ static const char s_infotype[CURLINFO_END][3] = {
+ "* ", "< ", "> ", "{ ", "} ", "{ ", "} " };
#ifdef CURL_DOES_CONVERSIONS
- char *buf = NULL;
- size_t conv_size = 0;
-
- switch(type) {
- case CURLINFO_HEADER_OUT:
- buf = Curl_memdup(ptr, size);
- if(!buf)
- return 1;
- conv_size = size;
-
- /* Special processing is needed for this block if it
- * contains both headers and data (separated by CRLFCRLF).
- * We want to convert just the headers, leaving the data as-is.
- */
- if(size > 4) {
- size_t i;
- for(i = 0; i < size-4; i++) {
- if(memcmp(&buf[i], "\x0d\x0a\x0d\x0a", 4) == 0) {
- /* convert everything through this CRLFCRLF but no further */
- conv_size = i + 4;
- break;
- }
+ char *buf = NULL;
+ size_t conv_size = 0;
+
+ switch(type) {
+ case CURLINFO_HEADER_OUT:
+ buf = Curl_memdup(ptr, size);
+ if(!buf)
+ return 1;
+ conv_size = size;
+
+ /* Special processing is needed for this block if it
+ * contains both headers and data (separated by CRLFCRLF).
+ * We want to convert just the headers, leaving the data as-is.
+ */
+ if(size > 4) {
+ size_t i;
+ for(i = 0; i < size-4; i++) {
+ if(memcmp(&buf[i], "\x0d\x0a\x0d\x0a", 4) == 0) {
+ /* convert everything through this CRLFCRLF but no further */
+ conv_size = i + 4;
+ break;
+ }
}
}
-
- Curl_convert_from_network(data, buf, conv_size);
- /* Curl_convert_from_network calls failf if unsuccessful */
- /* we might as well continue even if it fails... */
- ptr = buf; /* switch pointer to use my buffer instead */
- break;
- default:
- /* leave everything else as-is */
- break;
+
+ Curl_convert_from_network(data, buf, conv_size);
+ /* Curl_convert_from_network calls failf if unsuccessful */
+ /* we might as well continue even if it fails... */
+ ptr = buf; /* switch pointer to use my buffer instead */
+ break;
+ default:
+ /* leave everything else as-is */
+ break;
}
#endif /* CURL_DOES_CONVERSIONS */
- if(data->set.fdebug) {
- Curl_set_in_callback(data, true);
- rc = (*data->set.fdebug)(data, type, ptr, size, data->set.debugdata);
- Curl_set_in_callback(data, false);
- }
- else {
- switch(type) {
- case CURLINFO_TEXT:
- case CURLINFO_HEADER_OUT:
- case CURLINFO_HEADER_IN:
- fwrite(s_infotype[type], 2, 1, data->set.err);
- fwrite(ptr, size, 1, data->set.err);
+ if(data->set.fdebug) {
+ Curl_set_in_callback(data, true);
+ rc = (*data->set.fdebug)(data, type, ptr, size, data->set.debugdata);
+ Curl_set_in_callback(data, false);
+ }
+ else {
+ switch(type) {
+ case CURLINFO_TEXT:
+ case CURLINFO_HEADER_OUT:
+ case CURLINFO_HEADER_IN:
+ fwrite(s_infotype[type], 2, 1, data->set.err);
+ fwrite(ptr, size, 1, data->set.err);
#ifdef CURL_DOES_CONVERSIONS
- if(size != conv_size) {
- /* we had untranslated data so we need an explicit newline */
- fwrite("\n", 1, 1, data->set.err);
- }
-#endif
- break;
- default: /* nada */
- break;
+ if(size != conv_size) {
+ /* we had untranslated data so we need an explicit newline */
+ fwrite("\n", 1, 1, data->set.err);
+ }
+#endif
+ break;
+ default: /* nada */
+ break;
}
}
#ifdef CURL_DOES_CONVERSIONS
- free(buf);
+ free(buf);
#endif
- }
+ }
return rc;
}
diff --git a/contrib/libs/curl/lib/sendf.h b/contrib/libs/curl/lib/sendf.h
index 8e72d9fb1b..c7e67c7451 100644
--- a/contrib/libs/curl/lib/sendf.h
+++ b/contrib/libs/curl/lib/sendf.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/setopt.c b/contrib/libs/curl/lib/setopt.c
index 6ad394a716..58956c1e95 100644
--- a/contrib/libs/curl/lib/setopt.c
+++ b/contrib/libs/curl/lib/setopt.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -30,8 +30,8 @@
#ifdef HAVE_LINUX_TCP_H
#include <linux/tcp.h>
-#elif defined(HAVE_NETINET_TCP_H)
-#include <netinet/tcp.h>
+#elif defined(HAVE_NETINET_TCP_H)
+#include <netinet/tcp.h>
#endif
#include "urldata.h"
@@ -47,7 +47,7 @@
#include "setopt.h"
#include "multiif.h"
#include "altsvc.h"
-#include "hsts.h"
+#include "hsts.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
@@ -80,37 +80,37 @@ CURLcode Curl_setstropt(char **charp, const char *s)
return CURLE_OK;
}
-CURLcode Curl_setblobopt(struct curl_blob **blobp,
- const struct curl_blob *blob)
-{
- /* free the previous storage at `blobp' and replace by a dynamic storage
- copy of blob. If CURL_BLOB_COPY is set, the data is copied. */
-
- Curl_safefree(*blobp);
-
- if(blob) {
- struct curl_blob *nblob;
- if(blob->len > CURL_MAX_INPUT_LENGTH)
- return CURLE_BAD_FUNCTION_ARGUMENT;
- nblob = (struct curl_blob *)
- malloc(sizeof(struct curl_blob) +
- ((blob->flags & CURL_BLOB_COPY) ? blob->len : 0));
- if(!nblob)
- return CURLE_OUT_OF_MEMORY;
- *nblob = *blob;
- if(blob->flags & CURL_BLOB_COPY) {
- /* put the data after the blob struct in memory */
- nblob->data = (char *)nblob + sizeof(struct curl_blob);
- memcpy(nblob->data, blob->data, blob->len);
- }
-
- *blobp = nblob;
- return CURLE_OK;
- }
-
- return CURLE_OK;
-}
-
+CURLcode Curl_setblobopt(struct curl_blob **blobp,
+ const struct curl_blob *blob)
+{
+ /* free the previous storage at `blobp' and replace by a dynamic storage
+ copy of blob. If CURL_BLOB_COPY is set, the data is copied. */
+
+ Curl_safefree(*blobp);
+
+ if(blob) {
+ struct curl_blob *nblob;
+ if(blob->len > CURL_MAX_INPUT_LENGTH)
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+ nblob = (struct curl_blob *)
+ malloc(sizeof(struct curl_blob) +
+ ((blob->flags & CURL_BLOB_COPY) ? blob->len : 0));
+ if(!nblob)
+ return CURLE_OUT_OF_MEMORY;
+ *nblob = *blob;
+ if(blob->flags & CURL_BLOB_COPY) {
+ /* put the data after the blob struct in memory */
+ nblob->data = (char *)nblob + sizeof(struct curl_blob);
+ memcpy(nblob->data, blob->data, blob->len);
+ }
+
+ *blobp = nblob;
+ return CURLE_OK;
+ }
+
+ return CURLE_OK;
+}
+
static CURLcode setstropt_userpwd(char *option, char **userp, char **passwdp)
{
CURLcode result = CURLE_OK;
@@ -274,11 +274,11 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
* Do not include the body part in the output data stream.
*/
data->set.opt_no_body = (0 != va_arg(param, long)) ? TRUE : FALSE;
- if(data->set.opt_no_body)
- /* in HTTP lingo, no body means using the HEAD request... */
- data->set.method = HTTPREQ_HEAD;
- else if(data->set.method == HTTPREQ_HEAD)
- data->set.method = HTTPREQ_GET;
+ if(data->set.opt_no_body)
+ /* in HTTP lingo, no body means using the HEAD request... */
+ data->set.method = HTTPREQ_HEAD;
+ else if(data->set.method == HTTPREQ_HEAD)
+ data->set.method = HTTPREQ_GET;
break;
case CURLOPT_FAILONERROR:
/*
@@ -300,13 +300,13 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
data->set.upload = (0 != va_arg(param, long)) ? TRUE : FALSE;
if(data->set.upload) {
/* If this is HTTP, PUT is what's needed to "upload" */
- data->set.method = HTTPREQ_PUT;
+ data->set.method = HTTPREQ_PUT;
data->set.opt_no_body = FALSE; /* this is implied */
}
else
/* In HTTP, the opposite of upload is GET (unless NOBODY is true as
then this can be changed to HEAD later on) */
- data->set.method = HTTPREQ_GET;
+ data->set.method = HTTPREQ_GET;
break;
case CURLOPT_REQUEST_TARGET:
result = Curl_setstropt(&data->set.str[STRING_TARGET],
@@ -354,7 +354,7 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
* Parse the $HOME/.netrc file
*/
arg = va_arg(param, long);
- if((arg < CURL_NETRC_IGNORED) || (arg >= CURL_NETRC_LAST))
+ if((arg < CURL_NETRC_IGNORED) || (arg >= CURL_NETRC_LAST))
return CURLE_BAD_FUNCTION_ARGUMENT;
data->set.use_netrc = (enum CURL_NETRC_OPTION)arg;
break;
@@ -381,7 +381,7 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
* curl/curl.h header file.
*/
arg = va_arg(param, long);
- if((arg < CURL_TIMECOND_NONE) || (arg >= CURL_TIMECOND_LAST))
+ if((arg < CURL_TIMECOND_NONE) || (arg >= CURL_TIMECOND_LAST))
return CURLE_BAD_FUNCTION_ARGUMENT;
data->set.timecondition = (curl_TimeCond)arg;
break;
@@ -402,9 +402,9 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
break;
case CURLOPT_SSLVERSION:
-#ifndef CURL_DISABLE_PROXY
+#ifndef CURL_DISABLE_PROXY
case CURLOPT_PROXY_SSLVERSION:
-#endif
+#endif
/*
* Set explicit SSL version to try to connect with, as some SSL
* implementations are lame.
@@ -412,11 +412,11 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
#ifdef USE_SSL
{
long version, version_max;
- struct ssl_primary_config *primary = &data->set.ssl.primary;
-#ifndef CURL_DISABLE_PROXY
- if(option != CURLOPT_SSLVERSION)
- primary = &data->set.proxy_ssl.primary;
-#endif
+ struct ssl_primary_config *primary = &data->set.ssl.primary;
+#ifndef CURL_DISABLE_PROXY
+ if(option != CURLOPT_SSLVERSION)
+ primary = &data->set.proxy_ssl.primary;
+#endif
arg = va_arg(param, long);
@@ -433,12 +433,12 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
primary->version_max = version_max;
}
#else
- result = CURLE_NOT_BUILT_IN;
+ result = CURLE_NOT_BUILT_IN;
#endif
break;
- /* MQTT "borrows" some of the HTTP options */
-#if !defined(CURL_DISABLE_HTTP) || !defined(CURL_DISABLE_MQTT)
+ /* MQTT "borrows" some of the HTTP options */
+#if !defined(CURL_DISABLE_HTTP) || !defined(CURL_DISABLE_MQTT)
case CURLOPT_COPYPOSTFIELDS:
/*
* A string with POST data. Makes curl HTTP POST. Even if it is NULL.
@@ -483,7 +483,7 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
}
data->set.postfields = data->set.str[STRING_COPYPOSTFIELDS];
- data->set.method = HTTPREQ_POST;
+ data->set.method = HTTPREQ_POST;
break;
case CURLOPT_POSTFIELDS:
@@ -493,7 +493,7 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
data->set.postfields = va_arg(param, void *);
/* Release old copied data. */
(void) Curl_setstropt(&data->set.str[STRING_COPYPOSTFIELDS], NULL);
- data->set.method = HTTPREQ_POST;
+ data->set.method = HTTPREQ_POST;
break;
case CURLOPT_POSTFIELDSIZE:
@@ -533,107 +533,107 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
data->set.postfieldsize = bigsize;
break;
-#endif
-#ifndef CURL_DISABLE_HTTP
- case CURLOPT_AUTOREFERER:
- /*
- * Switch on automatic referer that gets set if curl follows locations.
- */
- data->set.http_auto_referer = (0 != va_arg(param, long)) ? TRUE : FALSE;
- break;
-
- case CURLOPT_ACCEPT_ENCODING:
- /*
- * String to use at the value of Accept-Encoding header.
- *
- * If the encoding is set to "" we use an Accept-Encoding header that
- * encompasses all the encodings we support.
- * If the encoding is set to NULL we don't send an Accept-Encoding header
- * and ignore an received Content-Encoding header.
- *
- */
- argptr = va_arg(param, char *);
- if(argptr && !*argptr) {
- argptr = Curl_all_content_encodings();
- if(!argptr)
- result = CURLE_OUT_OF_MEMORY;
- else {
- result = Curl_setstropt(&data->set.str[STRING_ENCODING], argptr);
- free(argptr);
- }
- }
- else
- result = Curl_setstropt(&data->set.str[STRING_ENCODING], argptr);
- break;
-
- case CURLOPT_TRANSFER_ENCODING:
- data->set.http_transfer_encoding = (0 != va_arg(param, long)) ?
- TRUE : FALSE;
- break;
-
- case CURLOPT_FOLLOWLOCATION:
- /*
- * Follow Location: header hints on a HTTP-server.
- */
- data->set.http_follow_location = (0 != va_arg(param, long)) ? TRUE : FALSE;
- break;
-
- case CURLOPT_UNRESTRICTED_AUTH:
- /*
- * Send authentication (user+password) when following locations, even when
- * hostname changed.
- */
- data->set.allow_auth_to_other_hosts =
- (0 != va_arg(param, long)) ? TRUE : FALSE;
- break;
-
- case CURLOPT_MAXREDIRS:
- /*
- * The maximum amount of hops you allow curl to follow Location:
- * headers. This should mostly be used to detect never-ending loops.
- */
- arg = va_arg(param, long);
- if(arg < -1)
- return CURLE_BAD_FUNCTION_ARGUMENT;
- data->set.maxredirs = arg;
- break;
-
- case CURLOPT_POSTREDIR:
- /*
- * Set the behaviour of POST when redirecting
- * CURL_REDIR_GET_ALL - POST is changed to GET after 301 and 302
- * CURL_REDIR_POST_301 - POST is kept as POST after 301
- * CURL_REDIR_POST_302 - POST is kept as POST after 302
- * CURL_REDIR_POST_303 - POST is kept as POST after 303
- * CURL_REDIR_POST_ALL - POST is kept as POST after 301, 302 and 303
- * other - POST is kept as POST after 301 and 302
- */
- arg = va_arg(param, long);
- if(arg < CURL_REDIR_GET_ALL)
- /* no return error on too high numbers since the bitmask could be
- extended in a future */
- return CURLE_BAD_FUNCTION_ARGUMENT;
- data->set.keep_post = arg & CURL_REDIR_POST_ALL;
- break;
-
- case CURLOPT_POST:
- /* Does this option serve a purpose anymore? Yes it does, when
- CURLOPT_POSTFIELDS isn't used and the POST data is read off the
- callback! */
- if(va_arg(param, long)) {
- data->set.method = HTTPREQ_POST;
- data->set.opt_no_body = FALSE; /* this is implied */
- }
- else
- data->set.method = HTTPREQ_GET;
- break;
-
+#endif
+#ifndef CURL_DISABLE_HTTP
+ case CURLOPT_AUTOREFERER:
+ /*
+ * Switch on automatic referer that gets set if curl follows locations.
+ */
+ data->set.http_auto_referer = (0 != va_arg(param, long)) ? TRUE : FALSE;
+ break;
+
+ case CURLOPT_ACCEPT_ENCODING:
+ /*
+ * String to use at the value of Accept-Encoding header.
+ *
+ * If the encoding is set to "" we use an Accept-Encoding header that
+ * encompasses all the encodings we support.
+ * If the encoding is set to NULL we don't send an Accept-Encoding header
+ * and ignore an received Content-Encoding header.
+ *
+ */
+ argptr = va_arg(param, char *);
+ if(argptr && !*argptr) {
+ argptr = Curl_all_content_encodings();
+ if(!argptr)
+ result = CURLE_OUT_OF_MEMORY;
+ else {
+ result = Curl_setstropt(&data->set.str[STRING_ENCODING], argptr);
+ free(argptr);
+ }
+ }
+ else
+ result = Curl_setstropt(&data->set.str[STRING_ENCODING], argptr);
+ break;
+
+ case CURLOPT_TRANSFER_ENCODING:
+ data->set.http_transfer_encoding = (0 != va_arg(param, long)) ?
+ TRUE : FALSE;
+ break;
+
+ case CURLOPT_FOLLOWLOCATION:
+ /*
+ * Follow Location: header hints on a HTTP-server.
+ */
+ data->set.http_follow_location = (0 != va_arg(param, long)) ? TRUE : FALSE;
+ break;
+
+ case CURLOPT_UNRESTRICTED_AUTH:
+ /*
+ * Send authentication (user+password) when following locations, even when
+ * hostname changed.
+ */
+ data->set.allow_auth_to_other_hosts =
+ (0 != va_arg(param, long)) ? TRUE : FALSE;
+ break;
+
+ case CURLOPT_MAXREDIRS:
+ /*
+ * The maximum amount of hops you allow curl to follow Location:
+ * headers. This should mostly be used to detect never-ending loops.
+ */
+ arg = va_arg(param, long);
+ if(arg < -1)
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+ data->set.maxredirs = arg;
+ break;
+
+ case CURLOPT_POSTREDIR:
+ /*
+ * Set the behaviour of POST when redirecting
+ * CURL_REDIR_GET_ALL - POST is changed to GET after 301 and 302
+ * CURL_REDIR_POST_301 - POST is kept as POST after 301
+ * CURL_REDIR_POST_302 - POST is kept as POST after 302
+ * CURL_REDIR_POST_303 - POST is kept as POST after 303
+ * CURL_REDIR_POST_ALL - POST is kept as POST after 301, 302 and 303
+ * other - POST is kept as POST after 301 and 302
+ */
+ arg = va_arg(param, long);
+ if(arg < CURL_REDIR_GET_ALL)
+ /* no return error on too high numbers since the bitmask could be
+ extended in a future */
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+ data->set.keep_post = arg & CURL_REDIR_POST_ALL;
+ break;
+
+ case CURLOPT_POST:
+ /* Does this option serve a purpose anymore? Yes it does, when
+ CURLOPT_POSTFIELDS isn't used and the POST data is read off the
+ callback! */
+ if(va_arg(param, long)) {
+ data->set.method = HTTPREQ_POST;
+ data->set.opt_no_body = FALSE; /* this is implied */
+ }
+ else
+ data->set.method = HTTPREQ_GET;
+ break;
+
case CURLOPT_HTTPPOST:
/*
* Set to make us do HTTP POST
*/
data->set.httppost = va_arg(param, struct curl_httppost *);
- data->set.method = HTTPREQ_POST_FORM;
+ data->set.method = HTTPREQ_POST_FORM;
data->set.opt_no_body = FALSE; /* this is implied */
break;
#endif /* CURL_DISABLE_HTTP */
@@ -645,7 +645,7 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
result = Curl_mime_set_subparts(&data->set.mimepost,
va_arg(param, curl_mime *), FALSE);
if(!result) {
- data->set.method = HTTPREQ_POST_MIME;
+ data->set.method = HTTPREQ_POST_MIME;
data->set.opt_no_body = FALSE; /* this is implied */
}
break;
@@ -725,9 +725,9 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
argptr = (char *)va_arg(param, void *);
if(argptr) {
struct curl_slist *cl;
- /* general protection against mistakes and abuse */
- if(strlen(argptr) > CURL_MAX_INPUT_LENGTH)
- return CURLE_BAD_FUNCTION_ARGUMENT;
+ /* general protection against mistakes and abuse */
+ if(strlen(argptr) > CURL_MAX_INPUT_LENGTH)
+ return CURLE_BAD_FUNCTION_ARGUMENT;
/* append the cookie file name to the list of file names, and deal with
them later */
cl = curl_slist_append(data->change.cookielist, argptr);
@@ -800,7 +800,7 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
}
else if(strcasecompare(argptr, "FLUSH")) {
/* flush cookies to file, takes care of the locking */
- Curl_flush_cookies(data, FALSE);
+ Curl_flush_cookies(data, FALSE);
}
else if(strcasecompare(argptr, "RELOAD")) {
/* reload cookies from file */
@@ -812,9 +812,9 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
/* if cookie engine was not running, activate it */
data->cookies = Curl_cookie_init(data, NULL, NULL, TRUE);
- /* general protection against mistakes and abuse */
- if(strlen(argptr) > CURL_MAX_INPUT_LENGTH)
- return CURLE_BAD_FUNCTION_ARGUMENT;
+ /* general protection against mistakes and abuse */
+ if(strlen(argptr) > CURL_MAX_INPUT_LENGTH)
+ return CURLE_BAD_FUNCTION_ARGUMENT;
argptr = strdup(argptr);
if(!argptr || !data->cookies) {
result = CURLE_OUT_OF_MEMORY;
@@ -846,7 +846,7 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
* Set to force us do HTTP GET
*/
if(va_arg(param, long)) {
- data->set.method = HTTPREQ_GET;
+ data->set.method = HTTPREQ_GET;
data->set.upload = FALSE; /* switch off upload */
data->set.opt_no_body = FALSE; /* this is implied */
}
@@ -869,7 +869,7 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
if(arg >= CURL_HTTP_VERSION_2)
return CURLE_UNSUPPORTED_PROTOCOL;
#else
- if(arg >= CURL_HTTP_VERSION_LAST)
+ if(arg >= CURL_HTTP_VERSION_LAST)
return CURLE_UNSUPPORTED_PROTOCOL;
if(arg == CURL_HTTP_VERSION_NONE)
arg = CURL_HTTP_VERSION_2TLS;
@@ -956,7 +956,7 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
va_arg(param, char *));
/* we don't set
- data->set.method = HTTPREQ_CUSTOM;
+ data->set.method = HTTPREQ_CUSTOM;
here, we continue as if we were using the already set type
and this just changes the actual request keyword */
break;
@@ -1080,7 +1080,7 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
break;
default:
/* reserve other values for future use */
- result = CURLE_BAD_FUNCTION_ARGUMENT;
+ result = CURLE_BAD_FUNCTION_ARGUMENT;
break;
}
break;
@@ -1160,7 +1160,7 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
* How do access files over FTP.
*/
arg = va_arg(param, long);
- if((arg < CURLFTPMETHOD_DEFAULT) || (arg >= CURLFTPMETHOD_LAST))
+ if((arg < CURLFTPMETHOD_DEFAULT) || (arg >= CURLFTPMETHOD_LAST))
return CURLE_BAD_FUNCTION_ARGUMENT;
data->set.ftp_filemethod = (curl_ftpfile)arg;
break;
@@ -1187,7 +1187,7 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
case CURLOPT_FTP_SSL_CCC:
arg = va_arg(param, long);
- if((arg < CURLFTPSSL_CCC_NONE) || (arg >= CURLFTPSSL_CCC_LAST))
+ if((arg < CURLFTPSSL_CCC_NONE) || (arg >= CURLFTPSSL_CCC_LAST))
return CURLE_BAD_FUNCTION_ARGUMENT;
data->set.ftp_ccc = (curl_ftpccc)arg;
break;
@@ -1215,7 +1215,7 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
* Set a specific auth for FTP-SSL transfers.
*/
arg = va_arg(param, long);
- if((arg < CURLFTPAUTH_DEFAULT) || (arg >= CURLFTPAUTH_LAST))
+ if((arg < CURLFTPAUTH_DEFAULT) || (arg >= CURLFTPAUTH_LAST))
return CURLE_BAD_FUNCTION_ARGUMENT;
data->set.ftpsslauth = (curl_ftpauth)arg;
break;
@@ -1233,13 +1233,13 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
* An FTP/SFTP option that modifies an upload to create missing
* directories on the server.
*/
- arg = va_arg(param, long);
- /* reserve other values for future use */
- if((arg < CURLFTP_CREATE_DIR_NONE) ||
- (arg > CURLFTP_CREATE_DIR_RETRY))
- result = CURLE_BAD_FUNCTION_ARGUMENT;
- else
- data->set.ftp_create_missing_dirs = (int)arg;
+ arg = va_arg(param, long);
+ /* reserve other values for future use */
+ if((arg < CURLFTP_CREATE_DIR_NONE) ||
+ (arg > CURLFTP_CREATE_DIR_RETRY))
+ result = CURLE_BAD_FUNCTION_ARGUMENT;
+ else
+ data->set.ftp_create_missing_dirs = (int)arg;
break;
case CURLOPT_READDATA:
/*
@@ -1649,13 +1649,13 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
result = Curl_setstropt(&data->set.str[STRING_CERT_ORIG],
va_arg(param, char *));
break;
- case CURLOPT_SSLCERT_BLOB:
- /*
- * Blob that holds file name of the SSL certificate to use
- */
- result = Curl_setblobopt(&data->set.blobs[BLOB_CERT_ORIG],
- va_arg(param, struct curl_blob *));
- break;
+ case CURLOPT_SSLCERT_BLOB:
+ /*
+ * Blob that holds file name of the SSL certificate to use
+ */
+ result = Curl_setblobopt(&data->set.blobs[BLOB_CERT_ORIG],
+ va_arg(param, struct curl_blob *));
+ break;
#ifndef CURL_DISABLE_PROXY
case CURLOPT_PROXY_SSLCERT:
/*
@@ -1664,13 +1664,13 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
result = Curl_setstropt(&data->set.str[STRING_CERT_PROXY],
va_arg(param, char *));
break;
- case CURLOPT_PROXY_SSLCERT_BLOB:
- /*
- * Blob that holds file name of the SSL certificate to use for proxy
- */
- result = Curl_setblobopt(&data->set.blobs[BLOB_CERT_PROXY],
- va_arg(param, struct curl_blob *));
- break;
+ case CURLOPT_PROXY_SSLCERT_BLOB:
+ /*
+ * Blob that holds file name of the SSL certificate to use for proxy
+ */
+ result = Curl_setblobopt(&data->set.blobs[BLOB_CERT_PROXY],
+ va_arg(param, struct curl_blob *));
+ break;
#endif
case CURLOPT_SSLCERTTYPE:
/*
@@ -1695,13 +1695,13 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
result = Curl_setstropt(&data->set.str[STRING_KEY_ORIG],
va_arg(param, char *));
break;
- case CURLOPT_SSLKEY_BLOB:
- /*
- * Blob that holds file name of the SSL key to use
- */
- result = Curl_setblobopt(&data->set.blobs[BLOB_KEY_ORIG],
- va_arg(param, struct curl_blob *));
- break;
+ case CURLOPT_SSLKEY_BLOB:
+ /*
+ * Blob that holds file name of the SSL key to use
+ */
+ result = Curl_setblobopt(&data->set.blobs[BLOB_KEY_ORIG],
+ va_arg(param, struct curl_blob *));
+ break;
#ifndef CURL_DISABLE_PROXY
case CURLOPT_PROXY_SSLKEY:
/*
@@ -1710,13 +1710,13 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
result = Curl_setstropt(&data->set.str[STRING_KEY_PROXY],
va_arg(param, char *));
break;
- case CURLOPT_PROXY_SSLKEY_BLOB:
- /*
- * Blob that holds file name of the SSL key to use for proxy
- */
- result = Curl_setblobopt(&data->set.blobs[BLOB_KEY_PROXY],
- va_arg(param, struct curl_blob *));
- break;
+ case CURLOPT_PROXY_SSLKEY_BLOB:
+ /*
+ * Blob that holds file name of the SSL key to use for proxy
+ */
+ result = Curl_setblobopt(&data->set.blobs[BLOB_KEY_PROXY],
+ va_arg(param, struct curl_blob *));
+ break;
#endif
case CURLOPT_SSLKEYTYPE:
/*
@@ -2041,30 +2041,30 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
result = Curl_setstropt(&data->set.str[STRING_SSL_ISSUERCERT_ORIG],
va_arg(param, char *));
break;
- case CURLOPT_ISSUERCERT_BLOB:
- /*
- * Blob that holds Issuer certificate to check certificates issuer
- */
- result = Curl_setblobopt(&data->set.blobs[BLOB_SSL_ISSUERCERT_ORIG],
- va_arg(param, struct curl_blob *));
- break;
-#ifndef CURL_DISABLE_PROXY
- case CURLOPT_PROXY_ISSUERCERT:
- /*
- * Set Issuer certificate file
- * to check certificates issuer
- */
- result = Curl_setstropt(&data->set.str[STRING_SSL_ISSUERCERT_PROXY],
- va_arg(param, char *));
- break;
- case CURLOPT_PROXY_ISSUERCERT_BLOB:
- /*
- * Blob that holds Issuer certificate to check certificates issuer
- */
- result = Curl_setblobopt(&data->set.blobs[BLOB_SSL_ISSUERCERT_PROXY],
- va_arg(param, struct curl_blob *));
- break;
-#endif
+ case CURLOPT_ISSUERCERT_BLOB:
+ /*
+ * Blob that holds Issuer certificate to check certificates issuer
+ */
+ result = Curl_setblobopt(&data->set.blobs[BLOB_SSL_ISSUERCERT_ORIG],
+ va_arg(param, struct curl_blob *));
+ break;
+#ifndef CURL_DISABLE_PROXY
+ case CURLOPT_PROXY_ISSUERCERT:
+ /*
+ * Set Issuer certificate file
+ * to check certificates issuer
+ */
+ result = Curl_setstropt(&data->set.str[STRING_SSL_ISSUERCERT_PROXY],
+ va_arg(param, char *));
+ break;
+ case CURLOPT_PROXY_ISSUERCERT_BLOB:
+ /*
+ * Blob that holds Issuer certificate to check certificates issuer
+ */
+ result = Curl_setblobopt(&data->set.blobs[BLOB_SSL_ISSUERCERT_PROXY],
+ va_arg(param, struct curl_blob *));
+ break;
+#endif
#ifndef CURL_DISABLE_TELNET
case CURLOPT_TELNETOPTIONS:
/*
@@ -2078,9 +2078,9 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
* The application kindly asks for a differently sized receive buffer.
* If it seems reasonable, we'll use it.
*/
- if(data->state.buffer)
- return CURLE_BAD_FUNCTION_ARGUMENT;
-
+ if(data->state.buffer)
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+
arg = va_arg(param, long);
if(arg > READBUFFER_MAX)
@@ -2210,7 +2210,7 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
* Make transfers attempt to use SSL/TLS.
*/
arg = va_arg(param, long);
- if((arg < CURLUSESSL_NONE) || (arg >= CURLUSESSL_LAST))
+ if((arg < CURLUSESSL_NONE) || (arg >= CURLUSESSL_LAST))
return CURLE_BAD_FUNCTION_ARGUMENT;
data->set.use_ssl = (curl_usessl)arg;
break;
@@ -2220,9 +2220,9 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
data->set.ssl.enable_beast =
(bool)((arg&CURLSSLOPT_ALLOW_BEAST) ? TRUE : FALSE);
data->set.ssl.no_revoke = !!(arg & CURLSSLOPT_NO_REVOKE);
- data->set.ssl.no_partialchain = !!(arg & CURLSSLOPT_NO_PARTIALCHAIN);
- data->set.ssl.revoke_best_effort = !!(arg & CURLSSLOPT_REVOKE_BEST_EFFORT);
- data->set.ssl.native_ca_store = !!(arg & CURLSSLOPT_NATIVE_CA);
+ data->set.ssl.no_partialchain = !!(arg & CURLSSLOPT_NO_PARTIALCHAIN);
+ data->set.ssl.revoke_best_effort = !!(arg & CURLSSLOPT_REVOKE_BEST_EFFORT);
+ data->set.ssl.native_ca_store = !!(arg & CURLSSLOPT_NATIVE_CA);
break;
#ifndef CURL_DISABLE_PROXY
@@ -2231,21 +2231,21 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
data->set.proxy_ssl.enable_beast =
(bool)((arg&CURLSSLOPT_ALLOW_BEAST) ? TRUE : FALSE);
data->set.proxy_ssl.no_revoke = !!(arg & CURLSSLOPT_NO_REVOKE);
- data->set.proxy_ssl.no_partialchain = !!(arg & CURLSSLOPT_NO_PARTIALCHAIN);
- data->set.proxy_ssl.native_ca_store = !!(arg & CURLSSLOPT_NATIVE_CA);
- data->set.proxy_ssl.revoke_best_effort =
- !!(arg & CURLSSLOPT_REVOKE_BEST_EFFORT);
+ data->set.proxy_ssl.no_partialchain = !!(arg & CURLSSLOPT_NO_PARTIALCHAIN);
+ data->set.proxy_ssl.native_ca_store = !!(arg & CURLSSLOPT_NATIVE_CA);
+ data->set.proxy_ssl.revoke_best_effort =
+ !!(arg & CURLSSLOPT_REVOKE_BEST_EFFORT);
break;
#endif
- case CURLOPT_SSL_EC_CURVES:
- /*
- * Set accepted curves in SSL connection setup.
- * Specify colon-delimited list of curve algorithm names.
- */
- result = Curl_setstropt(&data->set.str[STRING_SSL_EC_CURVES],
- va_arg(param, char *));
- break;
+ case CURLOPT_SSL_EC_CURVES:
+ /*
+ * Set accepted curves in SSL connection setup.
+ * Specify colon-delimited list of curve algorithm names.
+ */
+ result = Curl_setstropt(&data->set.str[STRING_SSL_EC_CURVES],
+ va_arg(param, char *));
+ break;
#endif
case CURLOPT_IPRESOLVE:
arg = va_arg(param, long);
@@ -2345,9 +2345,9 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
case CURLOPT_SSL_SESSIONID_CACHE:
data->set.ssl.primary.sessionid = (0 != va_arg(param, long)) ?
TRUE : FALSE;
-#ifndef CURL_DISABLE_PROXY
+#ifndef CURL_DISABLE_PROXY
data->set.proxy_ssl.primary.sessionid = data->set.ssl.primary.sessionid;
-#endif
+#endif
break;
#ifdef USE_SSH
@@ -2390,7 +2390,7 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
case CURLOPT_SSH_KEYFUNCTION:
/* setting to NULL is fine since the ssh.c functions themselves will
- then revert to use the internal default */
+ then revert to use the internal default */
data->set.ssh_keyfunc = va_arg(param, curl_sshkeycallback);
break;
@@ -2493,10 +2493,10 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
/* Set the list of mail recipients */
data->set.mail_rcpt = va_arg(param, struct curl_slist *);
break;
- case CURLOPT_MAIL_RCPT_ALLLOWFAILS:
- /* allow RCPT TO command to fail for some recipients */
- data->set.mail_rcpt_allowfails = (0 != va_arg(param, long)) ? TRUE : FALSE;
- break;
+ case CURLOPT_MAIL_RCPT_ALLLOWFAILS:
+ /* allow RCPT TO command to fail for some recipients */
+ data->set.mail_rcpt_allowfails = (0 != va_arg(param, long)) ? TRUE : FALSE;
+ break;
#endif
case CURLOPT_SASL_AUTHZID:
@@ -2516,9 +2516,9 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
* Set the RTSP request method (OPTIONS, SETUP, PLAY, etc...)
* Would this be better if the RTSPREQ_* were just moved into here?
*/
- long in_rtspreq = va_arg(param, long);
+ long in_rtspreq = va_arg(param, long);
Curl_RtspReq rtspreq = RTSPREQ_NONE;
- switch(in_rtspreq) {
+ switch(in_rtspreq) {
case CURL_RTSPREQ_OPTIONS:
rtspreq = RTSPREQ_OPTIONS;
break;
@@ -2608,7 +2608,7 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
case CURLOPT_RTSP_SERVER_CSEQ:
/* Same as the above, but for server-initiated requests */
- data->state.rtsp_next_server_CSeq = va_arg(param, long);
+ data->state.rtsp_next_server_CSeq = va_arg(param, long);
break;
case CURLOPT_INTERLEAVEDATA:
@@ -2649,11 +2649,11 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
case CURLOPT_PROXY_TLSAUTH_USERNAME:
result = Curl_setstropt(&data->set.str[STRING_TLSAUTH_USERNAME_PROXY],
va_arg(param, char *));
-#ifndef CURL_DISABLE_PROXY
+#ifndef CURL_DISABLE_PROXY
if(data->set.str[STRING_TLSAUTH_USERNAME_PROXY] &&
!data->set.proxy_ssl.authtype)
data->set.proxy_ssl.authtype = CURL_TLSAUTH_SRP; /* default to SRP */
-#endif
+#endif
break;
case CURLOPT_TLSAUTH_PASSWORD:
result = Curl_setstropt(&data->set.str[STRING_TLSAUTH_PASSWORD_ORIG],
@@ -2664,11 +2664,11 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
case CURLOPT_PROXY_TLSAUTH_PASSWORD:
result = Curl_setstropt(&data->set.str[STRING_TLSAUTH_PASSWORD_PROXY],
va_arg(param, char *));
-#ifndef CURL_DISABLE_PROXY
+#ifndef CURL_DISABLE_PROXY
if(data->set.str[STRING_TLSAUTH_USERNAME_PROXY] &&
!data->set.proxy_ssl.authtype)
data->set.proxy_ssl.authtype = CURL_TLSAUTH_SRP; /* default to SRP */
-#endif
+#endif
break;
case CURLOPT_TLSAUTH_TYPE:
argptr = va_arg(param, char *);
@@ -2678,7 +2678,7 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
else
data->set.ssl.authtype = CURL_TLSAUTH_NONE;
break;
-#ifndef CURL_DISABLE_PROXY
+#ifndef CURL_DISABLE_PROXY
case CURLOPT_PROXY_TLSAUTH_TYPE:
argptr = va_arg(param, char *);
if(!argptr ||
@@ -2688,35 +2688,35 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
data->set.proxy_ssl.authtype = CURL_TLSAUTH_NONE;
break;
#endif
-#endif
+#endif
#ifdef USE_ARES
case CURLOPT_DNS_SERVERS:
- result = Curl_setstropt(&data->set.str[STRING_DNS_SERVERS],
- va_arg(param, char *));
- if(result)
- return result;
- result = Curl_set_dns_servers(data, data->set.str[STRING_DNS_SERVERS]);
+ result = Curl_setstropt(&data->set.str[STRING_DNS_SERVERS],
+ va_arg(param, char *));
+ if(result)
+ return result;
+ result = Curl_set_dns_servers(data, data->set.str[STRING_DNS_SERVERS]);
break;
case CURLOPT_DNS_INTERFACE:
- result = Curl_setstropt(&data->set.str[STRING_DNS_INTERFACE],
- va_arg(param, char *));
- if(result)
- return result;
- result = Curl_set_dns_interface(data, data->set.str[STRING_DNS_INTERFACE]);
+ result = Curl_setstropt(&data->set.str[STRING_DNS_INTERFACE],
+ va_arg(param, char *));
+ if(result)
+ return result;
+ result = Curl_set_dns_interface(data, data->set.str[STRING_DNS_INTERFACE]);
break;
case CURLOPT_DNS_LOCAL_IP4:
- result = Curl_setstropt(&data->set.str[STRING_DNS_LOCAL_IP4],
- va_arg(param, char *));
- if(result)
- return result;
- result = Curl_set_dns_local_ip4(data, data->set.str[STRING_DNS_LOCAL_IP4]);
+ result = Curl_setstropt(&data->set.str[STRING_DNS_LOCAL_IP4],
+ va_arg(param, char *));
+ if(result)
+ return result;
+ result = Curl_set_dns_local_ip4(data, data->set.str[STRING_DNS_LOCAL_IP4]);
break;
case CURLOPT_DNS_LOCAL_IP6:
- result = Curl_setstropt(&data->set.str[STRING_DNS_LOCAL_IP6],
- va_arg(param, char *));
- if(result)
- return result;
- result = Curl_set_dns_local_ip6(data, data->set.str[STRING_DNS_LOCAL_IP6]);
+ result = Curl_setstropt(&data->set.str[STRING_DNS_LOCAL_IP6],
+ va_arg(param, char *));
+ if(result)
+ return result;
+ result = Curl_set_dns_local_ip6(data, data->set.str[STRING_DNS_LOCAL_IP6]);
break;
#endif
case CURLOPT_TCP_KEEPALIVE:
@@ -2842,46 +2842,46 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
data->set.trailer_data = va_arg(param, void *);
#endif
break;
-#ifdef USE_HSTS
- case CURLOPT_HSTSREADFUNCTION:
- data->set.hsts_read = va_arg(param, curl_hstsread_callback);
- break;
- case CURLOPT_HSTSREADDATA:
- data->set.hsts_read_userp = va_arg(param, void *);
- break;
- case CURLOPT_HSTSWRITEFUNCTION:
- data->set.hsts_write = va_arg(param, curl_hstswrite_callback);
- break;
- case CURLOPT_HSTSWRITEDATA:
- data->set.hsts_write_userp = va_arg(param, void *);
- break;
- case CURLOPT_HSTS:
- if(!data->hsts) {
- data->hsts = Curl_hsts_init();
- if(!data->hsts)
- return CURLE_OUT_OF_MEMORY;
- }
- argptr = va_arg(param, char *);
- result = Curl_setstropt(&data->set.str[STRING_HSTS], argptr);
- if(result)
- return result;
- if(argptr)
- (void)Curl_hsts_loadfile(data, data->hsts, argptr);
- break;
- case CURLOPT_HSTS_CTRL:
- arg = va_arg(param, long);
- if(arg & CURLHSTS_ENABLE) {
- if(!data->hsts) {
- data->hsts = Curl_hsts_init();
- if(!data->hsts)
- return CURLE_OUT_OF_MEMORY;
- }
- }
- else
- Curl_hsts_cleanup(&data->hsts);
- break;
-#endif
-#ifndef CURL_DISABLE_ALTSVC
+#ifdef USE_HSTS
+ case CURLOPT_HSTSREADFUNCTION:
+ data->set.hsts_read = va_arg(param, curl_hstsread_callback);
+ break;
+ case CURLOPT_HSTSREADDATA:
+ data->set.hsts_read_userp = va_arg(param, void *);
+ break;
+ case CURLOPT_HSTSWRITEFUNCTION:
+ data->set.hsts_write = va_arg(param, curl_hstswrite_callback);
+ break;
+ case CURLOPT_HSTSWRITEDATA:
+ data->set.hsts_write_userp = va_arg(param, void *);
+ break;
+ case CURLOPT_HSTS:
+ if(!data->hsts) {
+ data->hsts = Curl_hsts_init();
+ if(!data->hsts)
+ return CURLE_OUT_OF_MEMORY;
+ }
+ argptr = va_arg(param, char *);
+ result = Curl_setstropt(&data->set.str[STRING_HSTS], argptr);
+ if(result)
+ return result;
+ if(argptr)
+ (void)Curl_hsts_loadfile(data, data->hsts, argptr);
+ break;
+ case CURLOPT_HSTS_CTRL:
+ arg = va_arg(param, long);
+ if(arg & CURLHSTS_ENABLE) {
+ if(!data->hsts) {
+ data->hsts = Curl_hsts_init();
+ if(!data->hsts)
+ return CURLE_OUT_OF_MEMORY;
+ }
+ }
+ else
+ Curl_hsts_cleanup(&data->hsts);
+ break;
+#endif
+#ifndef CURL_DISABLE_ALTSVC
case CURLOPT_ALTSVC:
if(!data->asi) {
data->asi = Curl_altsvc_init();
@@ -2892,8 +2892,8 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
result = Curl_setstropt(&data->set.str[STRING_ALTSVC], argptr);
if(result)
return result;
- if(argptr)
- (void)Curl_altsvc_load(data->asi, argptr);
+ if(argptr)
+ (void)Curl_altsvc_load(data->asi, argptr);
break;
case CURLOPT_ALTSVC_CTRL:
if(!data->asi) {
diff --git a/contrib/libs/curl/lib/setopt.h b/contrib/libs/curl/lib/setopt.h
index 4e57811345..affbfd9960 100644
--- a/contrib/libs/curl/lib/setopt.h
+++ b/contrib/libs/curl/lib/setopt.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -23,8 +23,8 @@
***************************************************************************/
CURLcode Curl_setstropt(char **charp, const char *s);
-CURLcode Curl_setblobopt(struct curl_blob **blobp,
- const struct curl_blob *blob);
+CURLcode Curl_setblobopt(struct curl_blob **blobp,
+ const struct curl_blob *blob);
CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list arg);
#endif /* HEADER_CURL_SETOPT_H */
diff --git a/contrib/libs/curl/lib/setup-os400.h b/contrib/libs/curl/lib/setup-os400.h
index bb50f89eb7..8c97371e4d 100644
--- a/contrib/libs/curl/lib/setup-os400.h
+++ b/contrib/libs/curl/lib/setup-os400.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -200,21 +200,21 @@ extern OM_uint32 Curl_gss_delete_sec_context_a(OM_uint32 * minor_status,
/* Some socket functions must be wrapped to process textual addresses
like AF_UNIX. */
-extern int Curl_os400_connect(int sd, struct sockaddr *destaddr, int addrlen);
-extern int Curl_os400_bind(int sd, struct sockaddr *localaddr, int addrlen);
+extern int Curl_os400_connect(int sd, struct sockaddr *destaddr, int addrlen);
+extern int Curl_os400_bind(int sd, struct sockaddr *localaddr, int addrlen);
extern int Curl_os400_sendto(int sd, char *buffer, int buflen, int flags,
- struct sockaddr *dstaddr, int addrlen);
+ struct sockaddr *dstaddr, int addrlen);
extern int Curl_os400_recvfrom(int sd, char *buffer, int buflen, int flags,
struct sockaddr *fromaddr, int *addrlen);
-extern int Curl_os400_getpeername(int sd, struct sockaddr *addr, int *addrlen);
-extern int Curl_os400_getsockname(int sd, struct sockaddr *addr, int *addrlen);
+extern int Curl_os400_getpeername(int sd, struct sockaddr *addr, int *addrlen);
+extern int Curl_os400_getsockname(int sd, struct sockaddr *addr, int *addrlen);
#define connect Curl_os400_connect
#define bind Curl_os400_bind
#define sendto Curl_os400_sendto
#define recvfrom Curl_os400_recvfrom
-#define getpeername Curl_os400_getpeername
-#define getsockname Curl_os400_getsockname
+#define getpeername Curl_os400_getpeername
+#define getsockname Curl_os400_getsockname
#ifdef HAVE_LIBZ
#define zlibVersion Curl_os400_zlibVersion
diff --git a/contrib/libs/curl/lib/setup-vms.h b/contrib/libs/curl/lib/setup-vms.h
index ae13f72175..ba75dc295b 100644
--- a/contrib/libs/curl/lib/setup-vms.h
+++ b/contrib/libs/curl/lib/setup-vms.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -73,7 +73,7 @@ char *decc$getenv(const char *__name);
# endif
#endif
- struct passwd *decc_getpwuid(uid_t uid);
+ struct passwd *decc_getpwuid(uid_t uid);
#ifdef __DECC
# if __INITIAL_POINTER_SIZE == 32
@@ -138,9 +138,9 @@ static char *vms_getenv(const char *envvar)
static struct passwd vms_passwd_cache;
-static struct passwd *vms_getpwuid(uid_t uid)
+static struct passwd *vms_getpwuid(uid_t uid)
{
- struct passwd *my_passwd;
+ struct passwd *my_passwd;
/* Hack needed to support 64 bit builds, decc_getpwnam is 32 bit only */
#ifdef __DECC
diff --git a/contrib/libs/curl/lib/setup-win32.h b/contrib/libs/curl/lib/setup-win32.h
index 2bd432694d..c35dec88cb 100644
--- a/contrib/libs/curl/lib/setup-win32.h
+++ b/contrib/libs/curl/lib/setup-win32.h
@@ -1,122 +1,122 @@
-#ifndef HEADER_CURL_SETUP_WIN32_H
-#define HEADER_CURL_SETUP_WIN32_H
-/***************************************************************************
- * _ _ ____ _
- * Project ___| | | | _ \| |
- * / __| | | | |_) | |
- * | (__| |_| | _ <| |___
- * \___|\___/|_| \_\_____|
- *
- * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
- *
- * You may opt to use, copy, modify, merge, publish, distribute and/or sell
- * copies of the Software, and permit persons to whom the Software is
- * furnished to do so, under the terms of the COPYING file.
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- ***************************************************************************/
-
-/*
- * Include header files for windows builds before redefining anything.
- * Use this preprocessor block only to include or exclude windows.h,
- * winsock2.h, ws2tcpip.h or winsock.h. Any other windows thing belongs
- * to any other further and independent block. Under Cygwin things work
- * just as under linux (e.g. <sys/socket.h>) and the winsock headers should
- * never be included when __CYGWIN__ is defined. configure script takes
- * care of this, not defining HAVE_WINDOWS_H, HAVE_WINSOCK_H, HAVE_WINSOCK2_H,
- * neither HAVE_WS2TCPIP_H when __CYGWIN__ is defined.
- */
-
-#ifdef HAVE_WINDOWS_H
-# if defined(UNICODE) && !defined(_UNICODE)
-# define _UNICODE
-# endif
-# if defined(_UNICODE) && !defined(UNICODE)
-# define UNICODE
-# endif
-# include <winerror.h>
-# include <windows.h>
-# ifdef HAVE_WINSOCK2_H
-# include <winsock2.h>
-# ifdef HAVE_WS2TCPIP_H
-# include <ws2tcpip.h>
-# endif
-# else
-# ifdef HAVE_WINSOCK_H
-# include <winsock.h>
-# endif
-# endif
-# include <tchar.h>
-# ifdef UNICODE
- typedef wchar_t *(*curl_wcsdup_callback)(const wchar_t *str);
-# endif
-#endif
-
-/*
- * Define USE_WINSOCK to 2 if we have and use WINSOCK2 API, else
- * undefine USE_WINSOCK.
- */
-
-#undef USE_WINSOCK
-
-#ifdef HAVE_WINSOCK2_H
-# define USE_WINSOCK 2
-#else
-# ifdef HAVE_WINSOCK_H
-# error "WinSock version 1 is no longer supported, version 2 is required!"
-# endif
-#endif
-
-/*
- * Define _WIN32_WINNT_[OS] symbols because not all Windows build systems have
- * those symbols to compare against, and even those that do may be missing
- * newer symbols.
- */
-
-#ifndef _WIN32_WINNT_NT4
-#define _WIN32_WINNT_NT4 0x0400 /* Windows NT 4.0 */
-#endif
-#ifndef _WIN32_WINNT_WIN2K
-#define _WIN32_WINNT_WIN2K 0x0500 /* Windows 2000 */
-#endif
-#ifndef _WIN32_WINNT_WINXP
-#define _WIN32_WINNT_WINXP 0x0501 /* Windows XP */
-#endif
-#ifndef _WIN32_WINNT_WS03
-#define _WIN32_WINNT_WS03 0x0502 /* Windows Server 2003 */
-#endif
-#ifndef _WIN32_WINNT_WIN6
-#define _WIN32_WINNT_WIN6 0x0600 /* Windows Vista */
-#endif
-#ifndef _WIN32_WINNT_VISTA
-#define _WIN32_WINNT_VISTA 0x0600 /* Windows Vista */
-#endif
-#ifndef _WIN32_WINNT_WS08
-#define _WIN32_WINNT_WS08 0x0600 /* Windows Server 2008 */
-#endif
-#ifndef _WIN32_WINNT_LONGHORN
-#define _WIN32_WINNT_LONGHORN 0x0600 /* Windows Vista */
-#endif
-#ifndef _WIN32_WINNT_WIN7
-#define _WIN32_WINNT_WIN7 0x0601 /* Windows 7 */
-#endif
-#ifndef _WIN32_WINNT_WIN8
-#define _WIN32_WINNT_WIN8 0x0602 /* Windows 8 */
-#endif
-#ifndef _WIN32_WINNT_WINBLUE
-#define _WIN32_WINNT_WINBLUE 0x0603 /* Windows 8.1 */
-#endif
-#ifndef _WIN32_WINNT_WINTHRESHOLD
-#define _WIN32_WINNT_WINTHRESHOLD 0x0A00 /* Windows 10 */
-#endif
-#ifndef _WIN32_WINNT_WIN10
-#define _WIN32_WINNT_WIN10 0x0A00 /* Windows 10 */
-#endif
-
-#endif /* HEADER_CURL_SETUP_WIN32_H */
+#ifndef HEADER_CURL_SETUP_WIN32_H
+#define HEADER_CURL_SETUP_WIN32_H
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 1998 - 2020, 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
+ * are also available at https://curl.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+
+/*
+ * Include header files for windows builds before redefining anything.
+ * Use this preprocessor block only to include or exclude windows.h,
+ * winsock2.h, ws2tcpip.h or winsock.h. Any other windows thing belongs
+ * to any other further and independent block. Under Cygwin things work
+ * just as under linux (e.g. <sys/socket.h>) and the winsock headers should
+ * never be included when __CYGWIN__ is defined. configure script takes
+ * care of this, not defining HAVE_WINDOWS_H, HAVE_WINSOCK_H, HAVE_WINSOCK2_H,
+ * neither HAVE_WS2TCPIP_H when __CYGWIN__ is defined.
+ */
+
+#ifdef HAVE_WINDOWS_H
+# if defined(UNICODE) && !defined(_UNICODE)
+# define _UNICODE
+# endif
+# if defined(_UNICODE) && !defined(UNICODE)
+# define UNICODE
+# endif
+# include <winerror.h>
+# include <windows.h>
+# ifdef HAVE_WINSOCK2_H
+# include <winsock2.h>
+# ifdef HAVE_WS2TCPIP_H
+# include <ws2tcpip.h>
+# endif
+# else
+# ifdef HAVE_WINSOCK_H
+# include <winsock.h>
+# endif
+# endif
+# include <tchar.h>
+# ifdef UNICODE
+ typedef wchar_t *(*curl_wcsdup_callback)(const wchar_t *str);
+# endif
+#endif
+
+/*
+ * Define USE_WINSOCK to 2 if we have and use WINSOCK2 API, else
+ * undefine USE_WINSOCK.
+ */
+
+#undef USE_WINSOCK
+
+#ifdef HAVE_WINSOCK2_H
+# define USE_WINSOCK 2
+#else
+# ifdef HAVE_WINSOCK_H
+# error "WinSock version 1 is no longer supported, version 2 is required!"
+# endif
+#endif
+
+/*
+ * Define _WIN32_WINNT_[OS] symbols because not all Windows build systems have
+ * those symbols to compare against, and even those that do may be missing
+ * newer symbols.
+ */
+
+#ifndef _WIN32_WINNT_NT4
+#define _WIN32_WINNT_NT4 0x0400 /* Windows NT 4.0 */
+#endif
+#ifndef _WIN32_WINNT_WIN2K
+#define _WIN32_WINNT_WIN2K 0x0500 /* Windows 2000 */
+#endif
+#ifndef _WIN32_WINNT_WINXP
+#define _WIN32_WINNT_WINXP 0x0501 /* Windows XP */
+#endif
+#ifndef _WIN32_WINNT_WS03
+#define _WIN32_WINNT_WS03 0x0502 /* Windows Server 2003 */
+#endif
+#ifndef _WIN32_WINNT_WIN6
+#define _WIN32_WINNT_WIN6 0x0600 /* Windows Vista */
+#endif
+#ifndef _WIN32_WINNT_VISTA
+#define _WIN32_WINNT_VISTA 0x0600 /* Windows Vista */
+#endif
+#ifndef _WIN32_WINNT_WS08
+#define _WIN32_WINNT_WS08 0x0600 /* Windows Server 2008 */
+#endif
+#ifndef _WIN32_WINNT_LONGHORN
+#define _WIN32_WINNT_LONGHORN 0x0600 /* Windows Vista */
+#endif
+#ifndef _WIN32_WINNT_WIN7
+#define _WIN32_WINNT_WIN7 0x0601 /* Windows 7 */
+#endif
+#ifndef _WIN32_WINNT_WIN8
+#define _WIN32_WINNT_WIN8 0x0602 /* Windows 8 */
+#endif
+#ifndef _WIN32_WINNT_WINBLUE
+#define _WIN32_WINNT_WINBLUE 0x0603 /* Windows 8.1 */
+#endif
+#ifndef _WIN32_WINNT_WINTHRESHOLD
+#define _WIN32_WINNT_WINTHRESHOLD 0x0A00 /* Windows 10 */
+#endif
+#ifndef _WIN32_WINNT_WIN10
+#define _WIN32_WINNT_WIN10 0x0A00 /* Windows 10 */
+#endif
+
+#endif /* HEADER_CURL_SETUP_WIN32_H */
diff --git a/contrib/libs/curl/lib/sha256.c b/contrib/libs/curl/lib/sha256.c
index e1b3459bbb..7d2a4f705a 100644
--- a/contrib/libs/curl/lib/sha256.c
+++ b/contrib/libs/curl/lib/sha256.c
@@ -5,12 +5,12 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 2017, Florin Petriuc, <petriuc.florin@gmail.com>
- * Copyright (C) 2018 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2017, Florin Petriuc, <petriuc.florin@gmail.com>
+ * Copyright (C) 2018 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -36,208 +36,208 @@
#define USE_OPENSSL_SHA256
#endif
-#endif /* USE_OPENSSL */
-
-#ifdef USE_MBEDTLS
-#error #include <mbedtls/version.h>
-
-#if(MBEDTLS_VERSION_NUMBER >= 0x02070000)
- #define HAS_RESULT_CODE_BASED_FUNCTIONS
+#endif /* USE_OPENSSL */
+
+#ifdef USE_MBEDTLS
+#error #include <mbedtls/version.h>
+
+#if(MBEDTLS_VERSION_NUMBER >= 0x02070000)
+ #define HAS_RESULT_CODE_BASED_FUNCTIONS
#endif
-#endif /* USE_MBEDTLS */
-
-/* Please keep the SSL backend-specific #if branches in this order:
- *
- * 1. USE_OPENSSL
- * 2. USE_GNUTLS_NETTLE
- * 3. USE_GNUTLS
- * 4. USE_MBEDTLS
- * 5. USE_COMMON_CRYPTO
- * 6. USE_WIN32_CRYPTO
- *
- * This ensures that the same SSL branch gets activated throughout this source
- * file even if multiple backends are enabled at the same time.
- */
-
-#if defined(USE_OPENSSL_SHA256)
-
+#endif /* USE_MBEDTLS */
+
+/* Please keep the SSL backend-specific #if branches in this order:
+ *
+ * 1. USE_OPENSSL
+ * 2. USE_GNUTLS_NETTLE
+ * 3. USE_GNUTLS
+ * 4. USE_MBEDTLS
+ * 5. USE_COMMON_CRYPTO
+ * 6. USE_WIN32_CRYPTO
+ *
+ * This ensures that the same SSL branch gets activated throughout this source
+ * file even if multiple backends are enabled at the same time.
+ */
+
+#if defined(USE_OPENSSL_SHA256)
+
/* When OpenSSL is available we use the SHA256-function from OpenSSL */
#include <openssl/sha.h>
-
-#elif defined(USE_GNUTLS_NETTLE)
-
-#error #include <nettle/sha.h>
-
-#include "curl_memory.h"
-
-/* The last #include file should be: */
-#include "memdebug.h"
-
-typedef struct sha256_ctx SHA256_CTX;
-
-static void SHA256_Init(SHA256_CTX *ctx)
-{
- sha256_init(ctx);
-}
-
-static void SHA256_Update(SHA256_CTX *ctx,
- const unsigned char *data,
- unsigned int length)
-{
- sha256_update(ctx, length, data);
-}
-
-static void SHA256_Final(unsigned char *digest, SHA256_CTX *ctx)
-{
- sha256_digest(ctx, SHA256_DIGEST_SIZE, digest);
-}
-
-#elif defined(USE_GNUTLS)
-
-#include <gcrypt.h>
-
-#include "curl_memory.h"
-
-/* The last #include file should be: */
-#include "memdebug.h"
-
-typedef gcry_md_hd_t SHA256_CTX;
-
-static void SHA256_Init(SHA256_CTX *ctx)
-{
- gcry_md_open(ctx, GCRY_MD_SHA256, 0);
-}
-
-static void SHA256_Update(SHA256_CTX *ctx,
- const unsigned char *data,
- unsigned int length)
-{
- gcry_md_write(*ctx, data, length);
-}
-
-static void SHA256_Final(unsigned char *digest, SHA256_CTX *ctx)
-{
- memcpy(digest, gcry_md_read(*ctx, 0), SHA256_DIGEST_LENGTH);
- gcry_md_close(*ctx);
-}
-
-#elif defined(USE_MBEDTLS)
-
-#error #include <mbedtls/sha256.h>
-
-#include "curl_memory.h"
-
-/* The last #include file should be: */
-#include "memdebug.h"
-
-typedef mbedtls_sha256_context SHA256_CTX;
-
-static void SHA256_Init(SHA256_CTX *ctx)
-{
-#if !defined(HAS_RESULT_CODE_BASED_FUNCTIONS)
- mbedtls_sha256_starts(ctx, 0);
+
+#elif defined(USE_GNUTLS_NETTLE)
+
+#error #include <nettle/sha.h>
+
+#include "curl_memory.h"
+
+/* The last #include file should be: */
+#include "memdebug.h"
+
+typedef struct sha256_ctx SHA256_CTX;
+
+static void SHA256_Init(SHA256_CTX *ctx)
+{
+ sha256_init(ctx);
+}
+
+static void SHA256_Update(SHA256_CTX *ctx,
+ const unsigned char *data,
+ unsigned int length)
+{
+ sha256_update(ctx, length, data);
+}
+
+static void SHA256_Final(unsigned char *digest, SHA256_CTX *ctx)
+{
+ sha256_digest(ctx, SHA256_DIGEST_SIZE, digest);
+}
+
+#elif defined(USE_GNUTLS)
+
+#include <gcrypt.h>
+
+#include "curl_memory.h"
+
+/* The last #include file should be: */
+#include "memdebug.h"
+
+typedef gcry_md_hd_t SHA256_CTX;
+
+static void SHA256_Init(SHA256_CTX *ctx)
+{
+ gcry_md_open(ctx, GCRY_MD_SHA256, 0);
+}
+
+static void SHA256_Update(SHA256_CTX *ctx,
+ const unsigned char *data,
+ unsigned int length)
+{
+ gcry_md_write(*ctx, data, length);
+}
+
+static void SHA256_Final(unsigned char *digest, SHA256_CTX *ctx)
+{
+ memcpy(digest, gcry_md_read(*ctx, 0), SHA256_DIGEST_LENGTH);
+ gcry_md_close(*ctx);
+}
+
+#elif defined(USE_MBEDTLS)
+
+#error #include <mbedtls/sha256.h>
+
+#include "curl_memory.h"
+
+/* The last #include file should be: */
+#include "memdebug.h"
+
+typedef mbedtls_sha256_context SHA256_CTX;
+
+static void SHA256_Init(SHA256_CTX *ctx)
+{
+#if !defined(HAS_RESULT_CODE_BASED_FUNCTIONS)
+ mbedtls_sha256_starts(ctx, 0);
+#else
+ (void) mbedtls_sha256_starts_ret(ctx, 0);
+#endif
+}
+
+static void SHA256_Update(SHA256_CTX *ctx,
+ const unsigned char *data,
+ unsigned int length)
+{
+#if !defined(HAS_RESULT_CODE_BASED_FUNCTIONS)
+ mbedtls_sha256_update(ctx, data, length);
+#else
+ (void) mbedtls_sha256_update_ret(ctx, data, length);
+#endif
+}
+
+static void SHA256_Final(unsigned char *digest, SHA256_CTX *ctx)
+{
+#if !defined(HAS_RESULT_CODE_BASED_FUNCTIONS)
+ mbedtls_sha256_finish(ctx, digest);
+#else
+ (void) mbedtls_sha256_finish_ret(ctx, digest);
+#endif
+}
+
+#elif (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && \
+ (__MAC_OS_X_VERSION_MAX_ALLOWED >= 1040)) || \
+ (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && \
+ (__IPHONE_OS_VERSION_MAX_ALLOWED >= 20000))
+
+#include <CommonCrypto/CommonDigest.h>
+
+#include "curl_memory.h"
+
+/* The last #include file should be: */
+#include "memdebug.h"
+
+typedef CC_SHA256_CTX SHA256_CTX;
+
+static void SHA256_Init(SHA256_CTX *ctx)
+{
+ (void) CC_SHA256_Init(ctx);
+}
+
+static void SHA256_Update(SHA256_CTX *ctx,
+ const unsigned char *data,
+ unsigned int length)
+{
+ (void) CC_SHA256_Update(ctx, data, length);
+}
+
+static void SHA256_Final(unsigned char *digest, SHA256_CTX *ctx)
+{
+ (void) CC_SHA256_Final(digest, ctx);
+}
+
+#elif defined(USE_WIN32_CRYPTO)
+
+#include <wincrypt.h>
+
+struct sha256_ctx {
+ HCRYPTPROV hCryptProv;
+ HCRYPTHASH hHash;
+};
+typedef struct sha256_ctx SHA256_CTX;
+
+#if !defined(CALG_SHA_256)
+#define CALG_SHA_256 0x0000800c
+#endif
+
+static void SHA256_Init(SHA256_CTX *ctx)
+{
+ if(CryptAcquireContext(&ctx->hCryptProv, NULL, NULL, PROV_RSA_AES,
+ CRYPT_VERIFYCONTEXT | CRYPT_SILENT)) {
+ CryptCreateHash(ctx->hCryptProv, CALG_SHA_256, 0, 0, &ctx->hHash);
+ }
+}
+
+static void SHA256_Update(SHA256_CTX *ctx,
+ const unsigned char *data,
+ unsigned int length)
+{
+ CryptHashData(ctx->hHash, (unsigned char *) data, length, 0);
+}
+
+static void SHA256_Final(unsigned char *digest, SHA256_CTX *ctx)
+{
+ unsigned long length = 0;
+
+ CryptGetHashParam(ctx->hHash, HP_HASHVAL, NULL, &length, 0);
+ if(length == SHA256_DIGEST_LENGTH)
+ CryptGetHashParam(ctx->hHash, HP_HASHVAL, digest, &length, 0);
+
+ if(ctx->hHash)
+ CryptDestroyHash(ctx->hHash);
+
+ if(ctx->hCryptProv)
+ CryptReleaseContext(ctx->hCryptProv, 0);
+}
+
#else
- (void) mbedtls_sha256_starts_ret(ctx, 0);
-#endif
-}
-
-static void SHA256_Update(SHA256_CTX *ctx,
- const unsigned char *data,
- unsigned int length)
-{
-#if !defined(HAS_RESULT_CODE_BASED_FUNCTIONS)
- mbedtls_sha256_update(ctx, data, length);
-#else
- (void) mbedtls_sha256_update_ret(ctx, data, length);
-#endif
-}
-
-static void SHA256_Final(unsigned char *digest, SHA256_CTX *ctx)
-{
-#if !defined(HAS_RESULT_CODE_BASED_FUNCTIONS)
- mbedtls_sha256_finish(ctx, digest);
-#else
- (void) mbedtls_sha256_finish_ret(ctx, digest);
-#endif
-}
-
-#elif (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && \
- (__MAC_OS_X_VERSION_MAX_ALLOWED >= 1040)) || \
- (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && \
- (__IPHONE_OS_VERSION_MAX_ALLOWED >= 20000))
-
-#include <CommonCrypto/CommonDigest.h>
-
-#include "curl_memory.h"
-
-/* The last #include file should be: */
-#include "memdebug.h"
-
-typedef CC_SHA256_CTX SHA256_CTX;
-
-static void SHA256_Init(SHA256_CTX *ctx)
-{
- (void) CC_SHA256_Init(ctx);
-}
-
-static void SHA256_Update(SHA256_CTX *ctx,
- const unsigned char *data,
- unsigned int length)
-{
- (void) CC_SHA256_Update(ctx, data, length);
-}
-
-static void SHA256_Final(unsigned char *digest, SHA256_CTX *ctx)
-{
- (void) CC_SHA256_Final(digest, ctx);
-}
-
-#elif defined(USE_WIN32_CRYPTO)
-
-#include <wincrypt.h>
-
-struct sha256_ctx {
- HCRYPTPROV hCryptProv;
- HCRYPTHASH hHash;
-};
-typedef struct sha256_ctx SHA256_CTX;
-
-#if !defined(CALG_SHA_256)
-#define CALG_SHA_256 0x0000800c
-#endif
-
-static void SHA256_Init(SHA256_CTX *ctx)
-{
- if(CryptAcquireContext(&ctx->hCryptProv, NULL, NULL, PROV_RSA_AES,
- CRYPT_VERIFYCONTEXT | CRYPT_SILENT)) {
- CryptCreateHash(ctx->hCryptProv, CALG_SHA_256, 0, 0, &ctx->hHash);
- }
-}
-
-static void SHA256_Update(SHA256_CTX *ctx,
- const unsigned char *data,
- unsigned int length)
-{
- CryptHashData(ctx->hHash, (unsigned char *) data, length, 0);
-}
-
-static void SHA256_Final(unsigned char *digest, SHA256_CTX *ctx)
-{
- unsigned long length = 0;
-
- CryptGetHashParam(ctx->hHash, HP_HASHVAL, NULL, &length, 0);
- if(length == SHA256_DIGEST_LENGTH)
- CryptGetHashParam(ctx->hHash, HP_HASHVAL, digest, &length, 0);
-
- if(ctx->hHash)
- CryptDestroyHash(ctx->hHash);
-
- if(ctx->hCryptProv)
- CryptReleaseContext(ctx->hCryptProv, 0);
-}
-
-#else
-
+
/* When no other crypto library is available we use this code segment */
/* This is based on SHA256 implementation in LibTomCrypt that was released into
@@ -281,7 +281,7 @@ do { \
} while(0)
#endif
-struct sha256_state {
+struct sha256_state {
#ifdef HAVE_LONGLONG
unsigned long long length;
#else
@@ -289,10 +289,10 @@ struct sha256_state {
#endif
unsigned long state[8], curlen;
unsigned char buf[64];
-};
-typedef struct sha256_state SHA256_CTX;
-
-/* The K array */
+};
+typedef struct sha256_state SHA256_CTX;
+
+/* The K array */
static const unsigned long K[64] = {
0x428a2f98UL, 0x71374491UL, 0xb5c0fbcfUL, 0xe9b5dba5UL, 0x3956c25bUL,
0x59f111f1UL, 0x923f82a4UL, 0xab1c5ed5UL, 0xd807aa98UL, 0x12835b01UL,
@@ -308,7 +308,7 @@ static const unsigned long K[64] = {
0x682e6ff3UL, 0x748f82eeUL, 0x78a5636fUL, 0x84c87814UL, 0x8cc70208UL,
0x90befffaUL, 0xa4506cebUL, 0xbef9a3f7UL, 0xc67178f2UL
};
-
+
/* Various logical functions */
#define RORc(x, y) \
(((((unsigned long)(x) & 0xFFFFFFFFUL) >> (unsigned long)((y) & 31)) | \
@@ -321,15 +321,15 @@ static const unsigned long K[64] = {
#define Sigma1(x) (S(x, 6) ^ S(x, 11) ^ S(x, 25))
#define Gamma0(x) (S(x, 7) ^ S(x, 18) ^ R(x, 3))
#define Gamma1(x) (S(x, 17) ^ S(x, 19) ^ R(x, 10))
-
-/* Compress 512-bits */
+
+/* Compress 512-bits */
static int sha256_compress(struct sha256_state *md,
unsigned char *buf)
{
unsigned long S[8], W[64];
int i;
-
- /* Copy state into S */
+
+ /* Copy state into S */
for(i = 0; i < 8; i++) {
S[i] = md->state[i];
}
@@ -341,7 +341,7 @@ static int sha256_compress(struct sha256_state *md,
W[i] = Gamma1(W[i - 2]) + W[i - 7] + Gamma0(W[i - 15]) +
W[i - 16];
}
-
+
/* Compress */
#define RND(a,b,c,d,e,f,g,h,i) \
unsigned long t0 = h + Sigma1(e) + Ch(e, f, g) + K[i] + W[i]; \
@@ -354,15 +354,15 @@ static int sha256_compress(struct sha256_state *md,
t = S[7]; S[7] = S[6]; S[6] = S[5]; S[5] = S[4];
S[4] = S[3]; S[3] = S[2]; S[2] = S[1]; S[1] = S[0]; S[0] = t;
}
-
- /* Feedback */
+
+ /* Feedback */
for(i = 0; i < 8; i++) {
md->state[i] = md->state[i] + S[i];
}
-
+
return 0;
}
-
+
/* Initialize the hash state */
static void SHA256_Init(struct sha256_state *md)
{
@@ -377,8 +377,8 @@ static void SHA256_Init(struct sha256_state *md)
md->state[6] = 0x1F83D9ABUL;
md->state[7] = 0x5BE0CD19UL;
}
-
-/*
+
+/*
Process a block of memory though the hash
@param md The hash state
@param in The data to hash
@@ -390,7 +390,7 @@ static int SHA256_Update(struct sha256_state *md,
unsigned long inlen)
{
unsigned long n;
-
+
#define block_size 64
if(md->curlen > sizeof(md->buf))
return -1;
@@ -416,11 +416,11 @@ static int SHA256_Update(struct sha256_state *md,
}
}
}
-
+
return 0;
}
-
-/*
+
+/*
Terminate the hash to get the digest
@param md The hash state
@param out [out] The destination of the hash (32 bytes)
@@ -430,17 +430,17 @@ static int SHA256_Final(unsigned char *out,
struct sha256_state *md)
{
int i;
-
+
if(md->curlen >= sizeof(md->buf))
return -1;
-
- /* Increase the length of the message */
+
+ /* Increase the length of the message */
md->length += md->curlen * 8;
-
- /* Append the '1' bit */
+
+ /* Append the '1' bit */
md->buf[md->curlen++] = (unsigned char)0x80;
-
- /* If the length is currently above 56 bytes we append zeros
+
+ /* If the length is currently above 56 bytes we append zeros
* then compress. Then we can fall back to padding zeros and length
* encoding like normal.
*/
@@ -451,44 +451,44 @@ static int SHA256_Final(unsigned char *out,
sha256_compress(md, md->buf);
md->curlen = 0;
}
-
- /* Pad up to 56 bytes of zeroes */
+
+ /* Pad up to 56 bytes of zeroes */
while(md->curlen < 56) {
md->buf[md->curlen++] = (unsigned char)0;
}
-
- /* Store length */
+
+ /* Store length */
WPA_PUT_BE64(md->buf + 56, md->length);
sha256_compress(md, md->buf);
-
- /* Copy output */
+
+ /* Copy output */
for(i = 0; i < 8; i++)
WPA_PUT_BE32(out + (4 * i), md->state[i]);
-
+
return 0;
}
-#endif /* CRYPTO LIBS */
-
-/*
- * Curl_sha256it()
- *
- * Generates a SHA256 hash for the given input data.
- *
- * Parameters:
- *
- * output [in/out] - The output buffer.
- * input [in] - The input data.
- * length [in] - The input length.
- */
-void Curl_sha256it(unsigned char *output, const unsigned char *input,
- const size_t length)
+#endif /* CRYPTO LIBS */
+
+/*
+ * Curl_sha256it()
+ *
+ * Generates a SHA256 hash for the given input data.
+ *
+ * Parameters:
+ *
+ * output [in/out] - The output buffer.
+ * input [in] - The input data.
+ * length [in] - The input length.
+ */
+void Curl_sha256it(unsigned char *output, const unsigned char *input,
+ const size_t length)
{
SHA256_CTX ctx;
-
+
SHA256_Init(&ctx);
- SHA256_Update(&ctx, input, curlx_uztoui(length));
- SHA256_Final(output, &ctx);
+ SHA256_Update(&ctx, input, curlx_uztoui(length));
+ SHA256_Final(output, &ctx);
}
#endif /* CURL_DISABLE_CRYPTO_AUTH */
diff --git a/contrib/libs/curl/lib/share.c b/contrib/libs/curl/lib/share.c
index 289f89676c..5ce9830335 100644
--- a/contrib/libs/curl/lib/share.c
+++ b/contrib/libs/curl/lib/share.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -70,7 +70,7 @@ curl_share_setopt(struct Curl_share *share, CURLSHoption option, ...)
case CURLSHOPT_SHARE:
/* this is a type this share will share */
type = va_arg(param, int);
-
+
switch(type) {
case CURL_LOCK_DATA_DNS:
break;
@@ -92,7 +92,7 @@ curl_share_setopt(struct Curl_share *share, CURLSHoption option, ...)
if(!share->sslsession) {
share->max_ssl_sessions = 8;
share->sslsession = calloc(share->max_ssl_sessions,
- sizeof(struct Curl_ssl_session));
+ sizeof(struct Curl_ssl_session));
share->sessionage = 0;
if(!share->sslsession)
res = CURLSHE_NOMEM;
@@ -102,7 +102,7 @@ curl_share_setopt(struct Curl_share *share, CURLSHoption option, ...)
#endif
break;
- case CURL_LOCK_DATA_CONNECT:
+ case CURL_LOCK_DATA_CONNECT:
if(Curl_conncache_init(&share->conn_cache, 103))
res = CURLSHE_NOMEM;
break;
@@ -116,8 +116,8 @@ curl_share_setopt(struct Curl_share *share, CURLSHoption option, ...)
default:
res = CURLSHE_BAD_OPTION;
}
- if(!res)
- share->specifier |= (1<<type);
+ if(!res)
+ share->specifier |= (1<<type);
break;
case CURLSHOPT_UNSHARE:
diff --git a/contrib/libs/curl/lib/share.h b/contrib/libs/curl/lib/share.h
index 58863fc4ac..01aa9cda59 100644
--- a/contrib/libs/curl/lib/share.h
+++ b/contrib/libs/curl/lib/share.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -46,7 +46,7 @@ struct Curl_share {
curl_unlock_function unlockfunc;
void *clientdata;
struct conncache conn_cache;
- struct Curl_hash hostcache;
+ struct Curl_hash hostcache;
#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_COOKIES)
struct CookieInfo *cookies;
#endif
@@ -54,7 +54,7 @@ struct Curl_share {
struct PslCache psl;
#endif
- struct Curl_ssl_session *sslsession;
+ struct Curl_ssl_session *sslsession;
size_t max_ssl_sessions;
long sessionage;
};
diff --git a/contrib/libs/curl/lib/sigpipe.h b/contrib/libs/curl/lib/sigpipe.h
index ba54c80770..430cfc6489 100644
--- a/contrib/libs/curl/lib/sigpipe.h
+++ b/contrib/libs/curl/lib/sigpipe.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/slist.c b/contrib/libs/curl/lib/slist.c
index f5fb5161ca..907c203f38 100644
--- a/contrib/libs/curl/lib/slist.c
+++ b/contrib/libs/curl/lib/slist.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/slist.h b/contrib/libs/curl/lib/slist.h
index 4bb5c29631..3114259cfe 100644
--- a/contrib/libs/curl/lib/slist.h
+++ b/contrib/libs/curl/lib/slist.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/smb.c b/contrib/libs/curl/lib/smb.c
index d49c56b884..dd914a05bf 100644
--- a/contrib/libs/curl/lib/smb.c
+++ b/contrib/libs/curl/lib/smb.c
@@ -6,11 +6,11 @@
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2014, Bill Nagel <wnagel@tycoint.com>, Exacq Technologies
- * Copyright (C) 2016-2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2016-2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -23,7 +23,7 @@
#include "curl_setup.h"
-#if !defined(CURL_DISABLE_SMB) && defined(USE_CURL_NTLM_CORE) && \
+#if !defined(CURL_DISABLE_SMB) && defined(USE_CURL_NTLM_CORE) && \
(CURL_SIZEOF_CURL_OFF_T > 4)
#define BUILDING_CURL_SMB_C
@@ -86,7 +86,7 @@ const struct Curl_handler Curl_handler_smb = {
ZERO_NULL, /* connection_check */
PORT_SMB, /* defport */
CURLPROTO_SMB, /* protocol */
- CURLPROTO_SMB, /* family */
+ CURLPROTO_SMB, /* family */
PROTOPT_NONE /* flags */
};
@@ -112,7 +112,7 @@ const struct Curl_handler Curl_handler_smbs = {
ZERO_NULL, /* connection_check */
PORT_SMBS, /* defport */
CURLPROTO_SMBS, /* protocol */
- CURLPROTO_SMB, /* family */
+ CURLPROTO_SMB, /* family */
PROTOPT_SSL /* flags */
};
#endif
@@ -204,7 +204,7 @@ static void conn_state(struct connectdata *conn, enum smb_conn_state newstate)
static void request_state(struct connectdata *conn,
enum smb_req_state newstate)
{
- struct smb_request *req = conn->data->req.p.smb;
+ struct smb_request *req = conn->data->req.p.smb;
#if defined(DEBUGBUILD) && !defined(CURL_DISABLE_VERBOSE_STRINGS)
/* For debug purposes */
static const char * const names[] = {
@@ -234,7 +234,7 @@ static CURLcode smb_setup_connection(struct connectdata *conn)
struct smb_request *req;
/* Initialize the request state */
- conn->data->req.p.smb = req = calloc(1, sizeof(struct smb_request));
+ conn->data->req.p.smb = req = calloc(1, sizeof(struct smb_request));
if(!req)
return CURLE_OUT_OF_MEMORY;
@@ -342,7 +342,7 @@ static void smb_format_message(struct connectdata *conn, struct smb_header *h,
unsigned char cmd, size_t len)
{
struct smb_conn *smbc = &conn->proto.smbc;
- struct smb_request *req = conn->data->req.p.smb;
+ struct smb_request *req = conn->data->req.p.smb;
unsigned int pid;
memset(h, 0, sizeof(*h));
@@ -505,7 +505,7 @@ static CURLcode smb_send_tree_connect(struct connectdata *conn)
static CURLcode smb_send_open(struct connectdata *conn)
{
- struct smb_request *req = conn->data->req.p.smb;
+ struct smb_request *req = conn->data->req.p.smb;
struct smb_nt_create msg;
size_t byte_count;
@@ -535,7 +535,7 @@ static CURLcode smb_send_open(struct connectdata *conn)
static CURLcode smb_send_close(struct connectdata *conn)
{
- struct smb_request *req = conn->data->req.p.smb;
+ struct smb_request *req = conn->data->req.p.smb;
struct smb_close msg;
memset(&msg, 0, sizeof(msg));
@@ -556,7 +556,7 @@ static CURLcode smb_send_tree_disconnect(struct connectdata *conn)
static CURLcode smb_send_read(struct connectdata *conn)
{
- struct smb_request *req = conn->data->req.p.smb;
+ struct smb_request *req = conn->data->req.p.smb;
curl_off_t offset = conn->data->req.offset;
struct smb_read msg;
@@ -575,7 +575,7 @@ static CURLcode smb_send_read(struct connectdata *conn)
static CURLcode smb_send_write(struct connectdata *conn)
{
struct smb_write *msg;
- struct smb_request *req = conn->data->req.p.smb;
+ struct smb_request *req = conn->data->req.p.smb;
curl_off_t offset = conn->data->req.offset;
curl_off_t upload_size = conn->data->req.size - conn->data->req.bytecount;
CURLcode result = Curl_get_upload_buffer(conn->data);
@@ -682,8 +682,8 @@ static CURLcode smb_connection_state(struct connectdata *conn, bool *done)
switch(smbc->state) {
case SMB_NEGOTIATE:
- if((smbc->got < sizeof(*nrsp) + sizeof(smbc->challenge) - 1) ||
- h->status) {
+ if((smbc->got < sizeof(*nrsp) + sizeof(smbc->challenge) - 1) ||
+ h->status) {
connclose(conn, "SMB: negotiation failed");
return CURLE_COULDNT_CONNECT;
}
@@ -738,7 +738,7 @@ static void get_posix_time(time_t *out, curl_off_t timestamp)
static CURLcode smb_request_state(struct connectdata *conn, bool *done)
{
- struct smb_request *req = conn->data->req.p.smb;
+ struct smb_request *req = conn->data->req.p.smb;
struct smb_header *h;
struct smb_conn *smbc = &conn->proto.smbc;
enum smb_req_state next_state = SMB_DONE;
@@ -923,7 +923,7 @@ static CURLcode smb_done(struct connectdata *conn, CURLcode status,
bool premature)
{
(void) premature;
- Curl_safefree(conn->data->req.p.smb);
+ Curl_safefree(conn->data->req.p.smb);
return status;
}
@@ -957,14 +957,14 @@ static CURLcode smb_do(struct connectdata *conn, bool *done)
static CURLcode smb_parse_url_path(struct connectdata *conn)
{
struct Curl_easy *data = conn->data;
- struct smb_request *req = data->req.p.smb;
+ struct smb_request *req = data->req.p.smb;
struct smb_conn *smbc = &conn->proto.smbc;
char *path;
char *slash;
/* URL decode the path */
CURLcode result = Curl_urldecode(data, data->state.up.path, 0, &path, NULL,
- REJECT_CTRL);
+ REJECT_CTRL);
if(result)
return result;
@@ -996,5 +996,5 @@ static CURLcode smb_parse_url_path(struct connectdata *conn)
return CURLE_OK;
}
-#endif /* CURL_DISABLE_SMB && USE_CURL_NTLM_CORE &&
- CURL_SIZEOF_CURL_OFF_T > 4 */
+#endif /* CURL_DISABLE_SMB && USE_CURL_NTLM_CORE &&
+ CURL_SIZEOF_CURL_OFF_T > 4 */
diff --git a/contrib/libs/curl/lib/smb.h b/contrib/libs/curl/lib/smb.h
index a3939eefe9..907cf0c8e2 100644
--- a/contrib/libs/curl/lib/smb.h
+++ b/contrib/libs/curl/lib/smb.h
@@ -8,11 +8,11 @@
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2014, Bill Nagel <wnagel@tycoint.com>, Exacq Technologies
- * Copyright (C) 2018 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2018 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -243,13 +243,13 @@ struct smb_tree_disconnect {
#endif /* BUILDING_CURL_SMB_C */
-#if !defined(CURL_DISABLE_SMB) && defined(USE_CURL_NTLM_CORE) && \
+#if !defined(CURL_DISABLE_SMB) && defined(USE_CURL_NTLM_CORE) && \
(CURL_SIZEOF_CURL_OFF_T > 4)
extern const struct Curl_handler Curl_handler_smb;
extern const struct Curl_handler Curl_handler_smbs;
-#endif /* CURL_DISABLE_SMB && USE_CURL_NTLM_CORE &&
- CURL_SIZEOF_CURL_OFF_T > 4 */
+#endif /* CURL_DISABLE_SMB && USE_CURL_NTLM_CORE &&
+ CURL_SIZEOF_CURL_OFF_T > 4 */
#endif /* HEADER_CURL_SMB_H */
diff --git a/contrib/libs/curl/lib/smtp.c b/contrib/libs/curl/lib/smtp.c
index 8c721262a4..509d802f1c 100644
--- a/contrib/libs/curl/lib/smtp.c
+++ b/contrib/libs/curl/lib/smtp.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -27,9 +27,9 @@
* RFC4752 The Kerberos V5 ("GSSAPI") SASL Mechanism
* RFC4954 SMTP Authentication
* RFC5321 SMTP protocol
- * RFC5890 Internationalized Domain Names for Applications (IDNA)
- * RFC6531 SMTP Extension for Internationalized Email
- * RFC6532 Internationalized Email Headers
+ * RFC5890 Internationalized Domain Names for Applications (IDNA)
+ * RFC6531 SMTP Extension for Internationalized Email
+ * RFC6532 Internationalized Email Headers
* RFC6749 OAuth 2.0 Authorization Framework
* RFC8314 Use of TLS for Email Submission and Access
* Draft SMTP URL Interface <draft-earhart-url-smtp-00.txt>
@@ -104,8 +104,8 @@ static CURLcode smtp_setup_connection(struct connectdata *conn);
static CURLcode smtp_parse_url_options(struct connectdata *conn);
static CURLcode smtp_parse_url_path(struct connectdata *conn);
static CURLcode smtp_parse_custom_request(struct connectdata *conn);
-static CURLcode smtp_parse_address(struct connectdata *conn, const char *fqma,
- char **address, struct hostname *host);
+static CURLcode smtp_parse_address(struct connectdata *conn, const char *fqma,
+ char **address, struct hostname *host);
static CURLcode smtp_perform_auth(struct connectdata *conn, const char *mech,
const char *initresp);
static CURLcode smtp_continue_auth(struct connectdata *conn, const char *resp);
@@ -133,7 +133,7 @@ const struct Curl_handler Curl_handler_smtp = {
ZERO_NULL, /* connection_check */
PORT_SMTP, /* defport */
CURLPROTO_SMTP, /* protocol */
- CURLPROTO_SMTP, /* family */
+ CURLPROTO_SMTP, /* family */
PROTOPT_CLOSEACTION | PROTOPT_NOURLQUERY | /* flags */
PROTOPT_URLOPTIONS
};
@@ -161,7 +161,7 @@ const struct Curl_handler Curl_handler_smtps = {
ZERO_NULL, /* connection_check */
PORT_SMTPS, /* defport */
CURLPROTO_SMTPS, /* protocol */
- CURLPROTO_SMTP, /* family */
+ CURLPROTO_SMTP, /* family */
PROTOPT_CLOSEACTION | PROTOPT_SSL
| PROTOPT_NOURLQUERY | PROTOPT_URLOPTIONS /* flags */
};
@@ -185,7 +185,7 @@ static void smtp_to_smtps(struct connectdata *conn)
conn->handler = &Curl_handler_smtps;
/* Set the connection's upgraded to TLS flag */
- conn->bits.tls_upgraded = TRUE;
+ conn->bits.tls_upgraded = TRUE;
}
#else
#define smtp_to_smtps(x) Curl_nop_stmt
@@ -486,57 +486,57 @@ static CURLcode smtp_perform_command(struct connectdata *conn)
{
CURLcode result = CURLE_OK;
struct Curl_easy *data = conn->data;
- struct SMTP *smtp = data->req.p.smtp;
-
- if(smtp->rcpt) {
- /* We notify the server we are sending UTF-8 data if a) it supports the
- SMTPUTF8 extension and b) The mailbox contains UTF-8 charaacters, in
- either the local address or host name parts. This is regardless of
- whether the host name is encoded using IDN ACE */
- bool utf8 = FALSE;
-
- if((!smtp->custom) || (!smtp->custom[0])) {
- char *address = NULL;
- struct hostname host = { NULL, NULL, NULL, NULL };
-
- /* Parse the mailbox to verify into the local address and host name
- parts, converting the host name to an IDN A-label if necessary */
- result = smtp_parse_address(conn, smtp->rcpt->data,
- &address, &host);
- if(result)
- return result;
-
- /* Establish whether we should report SMTPUTF8 to the server for this
- mailbox as per RFC-6531 sect. 3.1 point 6 */
- utf8 = (conn->proto.smtpc.utf8_supported) &&
- ((host.encalloc) || (!Curl_is_ASCII_name(address)) ||
- (!Curl_is_ASCII_name(host.name)));
-
- /* Send the VRFY command (Note: The host name part may be absent when the
- host is a local system) */
- result = Curl_pp_sendf(&conn->proto.smtpc.pp, "VRFY %s%s%s%s",
- address,
- host.name ? "@" : "",
- host.name ? host.name : "",
- utf8 ? " SMTPUTF8" : "");
-
- Curl_free_idnconverted_hostname(&host);
- free(address);
- }
- else {
- /* Establish whether we should report that we support SMTPUTF8 for EXPN
- commands to the server as per RFC-6531 sect. 3.1 point 6 */
- utf8 = (conn->proto.smtpc.utf8_supported) &&
- (!strcmp(smtp->custom, "EXPN"));
-
- /* Send the custom recipient based command such as the EXPN command */
- result = Curl_pp_sendf(&conn->proto.smtpc.pp, "%s %s%s", smtp->custom,
- smtp->rcpt->data,
- utf8 ? " SMTPUTF8" : "");
- }
- }
+ struct SMTP *smtp = data->req.p.smtp;
+
+ if(smtp->rcpt) {
+ /* We notify the server we are sending UTF-8 data if a) it supports the
+ SMTPUTF8 extension and b) The mailbox contains UTF-8 charaacters, in
+ either the local address or host name parts. This is regardless of
+ whether the host name is encoded using IDN ACE */
+ bool utf8 = FALSE;
+
+ if((!smtp->custom) || (!smtp->custom[0])) {
+ char *address = NULL;
+ struct hostname host = { NULL, NULL, NULL, NULL };
+
+ /* Parse the mailbox to verify into the local address and host name
+ parts, converting the host name to an IDN A-label if necessary */
+ result = smtp_parse_address(conn, smtp->rcpt->data,
+ &address, &host);
+ if(result)
+ return result;
+
+ /* Establish whether we should report SMTPUTF8 to the server for this
+ mailbox as per RFC-6531 sect. 3.1 point 6 */
+ utf8 = (conn->proto.smtpc.utf8_supported) &&
+ ((host.encalloc) || (!Curl_is_ASCII_name(address)) ||
+ (!Curl_is_ASCII_name(host.name)));
+
+ /* Send the VRFY command (Note: The host name part may be absent when the
+ host is a local system) */
+ result = Curl_pp_sendf(&conn->proto.smtpc.pp, "VRFY %s%s%s%s",
+ address,
+ host.name ? "@" : "",
+ host.name ? host.name : "",
+ utf8 ? " SMTPUTF8" : "");
+
+ Curl_free_idnconverted_hostname(&host);
+ free(address);
+ }
+ else {
+ /* Establish whether we should report that we support SMTPUTF8 for EXPN
+ commands to the server as per RFC-6531 sect. 3.1 point 6 */
+ utf8 = (conn->proto.smtpc.utf8_supported) &&
+ (!strcmp(smtp->custom, "EXPN"));
+
+ /* Send the custom recipient based command such as the EXPN command */
+ result = Curl_pp_sendf(&conn->proto.smtpc.pp, "%s %s%s", smtp->custom,
+ smtp->rcpt->data,
+ utf8 ? " SMTPUTF8" : "");
+ }
+ }
else
- /* Send the non-recipient based command such as HELP */
+ /* Send the non-recipient based command such as HELP */
result = Curl_pp_sendf(&conn->proto.smtpc.pp, "%s",
smtp->custom && smtp->custom[0] != '\0' ?
smtp->custom : "HELP");
@@ -561,43 +561,43 @@ static CURLcode smtp_perform_mail(struct connectdata *conn)
CURLcode result = CURLE_OK;
struct Curl_easy *data = conn->data;
- /* We notify the server we are sending UTF-8 data if a) it supports the
- SMTPUTF8 extension and b) The mailbox contains UTF-8 charaacters, in
- either the local address or host name parts. This is regardless of
- whether the host name is encoded using IDN ACE */
- bool utf8 = FALSE;
-
+ /* We notify the server we are sending UTF-8 data if a) it supports the
+ SMTPUTF8 extension and b) The mailbox contains UTF-8 charaacters, in
+ either the local address or host name parts. This is regardless of
+ whether the host name is encoded using IDN ACE */
+ bool utf8 = FALSE;
+
/* Calculate the FROM parameter */
- if(data->set.str[STRING_MAIL_FROM]) {
- char *address = NULL;
- struct hostname host = { NULL, NULL, NULL, NULL };
-
- /* Parse the FROM mailbox into the local address and host name parts,
- converting the host name to an IDN A-label if necessary */
- result = smtp_parse_address(conn, data->set.str[STRING_MAIL_FROM],
- &address, &host);
- if(result)
- return result;
-
- /* Establish whether we should report SMTPUTF8 to the server for this
- mailbox as per RFC-6531 sect. 3.1 point 4 and sect. 3.4 */
- utf8 = (conn->proto.smtpc.utf8_supported) &&
- ((host.encalloc) || (!Curl_is_ASCII_name(address)) ||
- (!Curl_is_ASCII_name(host.name)));
-
- if(host.name) {
- from = aprintf("<%s@%s>", address, host.name);
-
- Curl_free_idnconverted_hostname(&host);
- }
- else
- /* An invalid mailbox was provided but we'll simply let the server worry
- about that and reply with a 501 error */
- from = aprintf("<%s>", address);
-
- free(address);
- }
- else
+ if(data->set.str[STRING_MAIL_FROM]) {
+ char *address = NULL;
+ struct hostname host = { NULL, NULL, NULL, NULL };
+
+ /* Parse the FROM mailbox into the local address and host name parts,
+ converting the host name to an IDN A-label if necessary */
+ result = smtp_parse_address(conn, data->set.str[STRING_MAIL_FROM],
+ &address, &host);
+ if(result)
+ return result;
+
+ /* Establish whether we should report SMTPUTF8 to the server for this
+ mailbox as per RFC-6531 sect. 3.1 point 4 and sect. 3.4 */
+ utf8 = (conn->proto.smtpc.utf8_supported) &&
+ ((host.encalloc) || (!Curl_is_ASCII_name(address)) ||
+ (!Curl_is_ASCII_name(host.name)));
+
+ if(host.name) {
+ from = aprintf("<%s@%s>", address, host.name);
+
+ Curl_free_idnconverted_hostname(&host);
+ }
+ else
+ /* An invalid mailbox was provided but we'll simply let the server worry
+ about that and reply with a 501 error */
+ from = aprintf("<%s>", address);
+
+ free(address);
+ }
+ else
/* Null reverse-path, RFC-5321, sect. 3.6.3 */
from = strdup("<>");
@@ -606,38 +606,38 @@ static CURLcode smtp_perform_mail(struct connectdata *conn)
/* Calculate the optional AUTH parameter */
if(data->set.str[STRING_MAIL_AUTH] && conn->proto.smtpc.sasl.authused) {
- if(data->set.str[STRING_MAIL_AUTH][0] != '\0') {
- char *address = NULL;
- struct hostname host = { NULL, NULL, NULL, NULL };
-
- /* Parse the AUTH mailbox into the local address and host name parts,
- converting the host name to an IDN A-label if necessary */
- result = smtp_parse_address(conn, data->set.str[STRING_MAIL_AUTH],
- &address, &host);
- if(result) {
- free(from);
- return result;
- }
-
- /* Establish whether we should report SMTPUTF8 to the server for this
- mailbox as per RFC-6531 sect. 3.1 point 4 and sect. 3.4 */
- if((!utf8) && (conn->proto.smtpc.utf8_supported) &&
- ((host.encalloc) || (!Curl_is_ASCII_name(address)) ||
- (!Curl_is_ASCII_name(host.name))))
- utf8 = TRUE;
-
- if(host.name) {
- auth = aprintf("<%s@%s>", address, host.name);
-
- Curl_free_idnconverted_hostname(&host);
- }
- else
- /* An invalid mailbox was provided but we'll simply let the server
- worry about it */
- auth = aprintf("<%s>", address);
-
- free(address);
- }
+ if(data->set.str[STRING_MAIL_AUTH][0] != '\0') {
+ char *address = NULL;
+ struct hostname host = { NULL, NULL, NULL, NULL };
+
+ /* Parse the AUTH mailbox into the local address and host name parts,
+ converting the host name to an IDN A-label if necessary */
+ result = smtp_parse_address(conn, data->set.str[STRING_MAIL_AUTH],
+ &address, &host);
+ if(result) {
+ free(from);
+ return result;
+ }
+
+ /* Establish whether we should report SMTPUTF8 to the server for this
+ mailbox as per RFC-6531 sect. 3.1 point 4 and sect. 3.4 */
+ if((!utf8) && (conn->proto.smtpc.utf8_supported) &&
+ ((host.encalloc) || (!Curl_is_ASCII_name(address)) ||
+ (!Curl_is_ASCII_name(host.name))))
+ utf8 = TRUE;
+
+ if(host.name) {
+ auth = aprintf("<%s@%s>", address, host.name);
+
+ Curl_free_idnconverted_hostname(&host);
+ }
+ else
+ /* An invalid mailbox was provided but we'll simply let the server
+ worry about it */
+ auth = aprintf("<%s>", address);
+
+ free(address);
+ }
else
/* Empty AUTH, RFC-2554, sect. 5 */
auth = strdup("<>");
@@ -671,7 +671,7 @@ static CURLcode smtp_perform_mail(struct connectdata *conn)
if(result) {
free(from);
free(auth);
-
+
return result;
}
@@ -694,33 +694,33 @@ static CURLcode smtp_perform_mail(struct connectdata *conn)
}
}
- /* If the mailboxes in the FROM and AUTH parameters don't include a UTF-8
- based address then quickly scan through the recipient list and check if
- any there do, as we need to correctly identify our support for SMTPUTF8
- in the envelope, as per RFC-6531 sect. 3.4 */
- if(conn->proto.smtpc.utf8_supported && !utf8) {
- struct SMTP *smtp = data->req.p.smtp;
- struct curl_slist *rcpt = smtp->rcpt;
-
- while(rcpt && !utf8) {
- /* Does the host name contain non-ASCII characters? */
- if(!Curl_is_ASCII_name(rcpt->data))
- utf8 = TRUE;
-
- rcpt = rcpt->next;
- }
- }
-
+ /* If the mailboxes in the FROM and AUTH parameters don't include a UTF-8
+ based address then quickly scan through the recipient list and check if
+ any there do, as we need to correctly identify our support for SMTPUTF8
+ in the envelope, as per RFC-6531 sect. 3.4 */
+ if(conn->proto.smtpc.utf8_supported && !utf8) {
+ struct SMTP *smtp = data->req.p.smtp;
+ struct curl_slist *rcpt = smtp->rcpt;
+
+ while(rcpt && !utf8) {
+ /* Does the host name contain non-ASCII characters? */
+ if(!Curl_is_ASCII_name(rcpt->data))
+ utf8 = TRUE;
+
+ rcpt = rcpt->next;
+ }
+ }
+
/* Send the MAIL command */
- result = Curl_pp_sendf(&conn->proto.smtpc.pp,
- "MAIL FROM:%s%s%s%s%s%s",
- from, /* Mandatory */
- auth ? " AUTH=" : "", /* Optional on AUTH support */
- auth ? auth : "", /* */
- size ? " SIZE=" : "", /* Optional on SIZE support */
- size ? size : "", /* */
- utf8 ? " SMTPUTF8" /* Internationalised mailbox */
- : ""); /* included in our envelope */
+ result = Curl_pp_sendf(&conn->proto.smtpc.pp,
+ "MAIL FROM:%s%s%s%s%s%s",
+ from, /* Mandatory */
+ auth ? " AUTH=" : "", /* Optional on AUTH support */
+ auth ? auth : "", /* */
+ size ? " SIZE=" : "", /* Optional on SIZE support */
+ size ? size : "", /* */
+ utf8 ? " SMTPUTF8" /* Internationalised mailbox */
+ : ""); /* included in our envelope */
free(from);
free(auth);
@@ -743,29 +743,29 @@ static CURLcode smtp_perform_rcpt_to(struct connectdata *conn)
{
CURLcode result = CURLE_OK;
struct Curl_easy *data = conn->data;
- struct SMTP *smtp = data->req.p.smtp;
- char *address = NULL;
- struct hostname host = { NULL, NULL, NULL, NULL };
-
- /* Parse the recipient mailbox into the local address and host name parts,
- converting the host name to an IDN A-label if necessary */
- result = smtp_parse_address(conn, smtp->rcpt->data,
- &address, &host);
- if(result)
- return result;
-
+ struct SMTP *smtp = data->req.p.smtp;
+ char *address = NULL;
+ struct hostname host = { NULL, NULL, NULL, NULL };
+
+ /* Parse the recipient mailbox into the local address and host name parts,
+ converting the host name to an IDN A-label if necessary */
+ result = smtp_parse_address(conn, smtp->rcpt->data,
+ &address, &host);
+ if(result)
+ return result;
+
/* Send the RCPT TO command */
- if(host.name)
- result = Curl_pp_sendf(&conn->proto.smtpc.pp, "RCPT TO:<%s@%s>", address,
- host.name);
+ if(host.name)
+ result = Curl_pp_sendf(&conn->proto.smtpc.pp, "RCPT TO:<%s@%s>", address,
+ host.name);
else
- /* An invalid mailbox was provided but we'll simply let the server worry
- about that and reply with a 501 error */
- result = Curl_pp_sendf(&conn->proto.smtpc.pp, "RCPT TO:<%s>", address);
-
- Curl_free_idnconverted_hostname(&host);
- free(address);
-
+ /* An invalid mailbox was provided but we'll simply let the server worry
+ about that and reply with a 501 error */
+ result = Curl_pp_sendf(&conn->proto.smtpc.pp, "RCPT TO:<%s>", address);
+
+ Curl_free_idnconverted_hostname(&host);
+ free(address);
+
if(!result)
state(conn, SMTP_RCPT);
@@ -865,10 +865,10 @@ static CURLcode smtp_state_ehlo_resp(struct connectdata *conn, int smtpcode,
else if(len >= 4 && !memcmp(line, "SIZE", 4))
smtpc->size_supported = TRUE;
- /* Does the server support the UTF-8 capability? */
- else if(len >= 8 && !memcmp(line, "SMTPUTF8", 8))
- smtpc->utf8_supported = TRUE;
-
+ /* Does the server support the UTF-8 capability? */
+ else if(len >= 8 && !memcmp(line, "SMTPUTF8", 8))
+ smtpc->utf8_supported = TRUE;
+
/* Does the server support authentication? */
else if(len >= 5 && !memcmp(line, "AUTH ", 5)) {
smtpc->auth_supported = TRUE;
@@ -991,7 +991,7 @@ static CURLcode smtp_state_command_resp(struct connectdata *conn, int smtpcode,
{
CURLcode result = CURLE_OK;
struct Curl_easy *data = conn->data;
- struct SMTP *smtp = data->req.p.smtp;
+ struct SMTP *smtp = data->req.p.smtp;
char *line = data->state.buffer;
size_t len = strlen(line);
@@ -1057,54 +1057,54 @@ static CURLcode smtp_state_rcpt_resp(struct connectdata *conn, int smtpcode,
{
CURLcode result = CURLE_OK;
struct Curl_easy *data = conn->data;
- struct SMTP *smtp = data->req.p.smtp;
- bool is_smtp_err = FALSE;
- bool is_smtp_blocking_err = FALSE;
+ struct SMTP *smtp = data->req.p.smtp;
+ bool is_smtp_err = FALSE;
+ bool is_smtp_blocking_err = FALSE;
(void)instate; /* no use for this yet */
- is_smtp_err = (smtpcode/100 != 2) ? TRUE : FALSE;
-
- /* If there's multiple RCPT TO to be issued, it's possible to ignore errors
- and proceed with only the valid addresses. */
- is_smtp_blocking_err =
- (is_smtp_err && !data->set.mail_rcpt_allowfails) ? TRUE : FALSE;
-
- if(is_smtp_err) {
- /* Remembering the last failure which we can report if all "RCPT TO" have
- failed and we cannot proceed. */
- smtp->rcpt_last_error = smtpcode;
-
- if(is_smtp_blocking_err) {
- failf(data, "RCPT failed: %d", smtpcode);
- result = CURLE_SEND_ERROR;
- }
+ is_smtp_err = (smtpcode/100 != 2) ? TRUE : FALSE;
+
+ /* If there's multiple RCPT TO to be issued, it's possible to ignore errors
+ and proceed with only the valid addresses. */
+ is_smtp_blocking_err =
+ (is_smtp_err && !data->set.mail_rcpt_allowfails) ? TRUE : FALSE;
+
+ if(is_smtp_err) {
+ /* Remembering the last failure which we can report if all "RCPT TO" have
+ failed and we cannot proceed. */
+ smtp->rcpt_last_error = smtpcode;
+
+ if(is_smtp_blocking_err) {
+ failf(data, "RCPT failed: %d", smtpcode);
+ result = CURLE_SEND_ERROR;
+ }
}
else {
- /* Some RCPT TO commands have succeeded. */
- smtp->rcpt_had_ok = TRUE;
- }
-
- if(!is_smtp_blocking_err) {
+ /* Some RCPT TO commands have succeeded. */
+ smtp->rcpt_had_ok = TRUE;
+ }
+
+ if(!is_smtp_blocking_err) {
smtp->rcpt = smtp->rcpt->next;
if(smtp->rcpt)
/* Send the next RCPT TO command */
result = smtp_perform_rcpt_to(conn);
else {
- /* We weren't able to issue a successful RCPT TO command while going
- over recipients (potentially multiple). Sending back last error. */
- if(!smtp->rcpt_had_ok) {
- failf(data, "RCPT failed: %d (last error)", smtp->rcpt_last_error);
- result = CURLE_SEND_ERROR;
- }
- else {
- /* Send the DATA command */
- result = Curl_pp_sendf(&conn->proto.smtpc.pp, "%s", "DATA");
-
- if(!result)
- state(conn, SMTP_DATA);
- }
+ /* We weren't able to issue a successful RCPT TO command while going
+ over recipients (potentially multiple). Sending back last error. */
+ if(!smtp->rcpt_had_ok) {
+ failf(data, "RCPT failed: %d (last error)", smtp->rcpt_last_error);
+ result = CURLE_SEND_ERROR;
+ }
+ else {
+ /* Send the DATA command */
+ result = Curl_pp_sendf(&conn->proto.smtpc.pp, "%s", "DATA");
+
+ if(!result)
+ state(conn, SMTP_DATA);
+ }
}
}
@@ -1280,7 +1280,7 @@ static CURLcode smtp_init(struct connectdata *conn)
struct Curl_easy *data = conn->data;
struct SMTP *smtp;
- smtp = data->req.p.smtp = calloc(sizeof(struct SMTP), 1);
+ smtp = data->req.p.smtp = calloc(sizeof(struct SMTP), 1);
if(!smtp)
result = CURLE_OUT_OF_MEMORY;
@@ -1324,7 +1324,7 @@ static CURLcode smtp_connect(struct connectdata *conn, bool *done)
Curl_sasl_init(&smtpc->sasl, &saslsmtp);
/* Initialise the pingpong layer */
- Curl_pp_setup(pp);
+ Curl_pp_setup(pp);
Curl_pp_init(pp);
/* Parse the URL options */
@@ -1359,7 +1359,7 @@ static CURLcode smtp_done(struct connectdata *conn, CURLcode status,
{
CURLcode result = CURLE_OK;
struct Curl_easy *data = conn->data;
- struct SMTP *smtp = data->req.p.smtp;
+ struct SMTP *smtp = data->req.p.smtp;
struct pingpong *pp = &conn->proto.smtpc.pp;
char *eob;
ssize_t len;
@@ -1445,7 +1445,7 @@ static CURLcode smtp_perform(struct connectdata *conn, bool *connected,
/* This is SMTP and no proxy */
CURLcode result = CURLE_OK;
struct Curl_easy *data = conn->data;
- struct SMTP *smtp = data->req.p.smtp;
+ struct SMTP *smtp = data->req.p.smtp;
DEBUGF(infof(conn->data, "DO phase starts\n"));
@@ -1459,12 +1459,12 @@ static CURLcode smtp_perform(struct connectdata *conn, bool *connected,
/* Store the first recipient (or NULL if not specified) */
smtp->rcpt = data->set.mail_rcpt;
- /* Track of whether we've successfully sent at least one RCPT TO command */
- smtp->rcpt_had_ok = FALSE;
-
- /* Track of the last error we've received by sending RCPT TO command */
- smtp->rcpt_last_error = 0;
-
+ /* Track of whether we've successfully sent at least one RCPT TO command */
+ smtp->rcpt_had_ok = FALSE;
+
+ /* Track of the last error we've received by sending RCPT TO command */
+ smtp->rcpt_last_error = 0;
+
/* Initial data character is the first character in line: it is implicitly
preceded by a virtual CRLF. */
smtp->trailing_crlf = TRUE;
@@ -1553,7 +1553,7 @@ static CURLcode smtp_disconnect(struct connectdata *conn, bool dead_connection)
/* Call this when the DO phase has completed */
static CURLcode smtp_dophase_done(struct connectdata *conn, bool connected)
{
- struct SMTP *smtp = conn->data->req.p.smtp;
+ struct SMTP *smtp = conn->data->req.p.smtp;
(void)connected;
@@ -1620,7 +1620,7 @@ static CURLcode smtp_setup_connection(struct connectdata *conn)
CURLcode result;
/* Clear the TLS upgraded flag */
- conn->bits.tls_upgraded = FALSE;
+ conn->bits.tls_upgraded = FALSE;
/* Initialise the SMTP layer */
result = smtp_init(conn);
@@ -1692,8 +1692,8 @@ static CURLcode smtp_parse_url_path(struct connectdata *conn)
}
/* URL decode the path and use it as the domain in our EHLO */
- return Curl_urldecode(conn->data, path, 0, &smtpc->domain, NULL,
- REJECT_CTRL);
+ return Curl_urldecode(conn->data, path, 0, &smtpc->domain, NULL,
+ REJECT_CTRL);
}
/***********************************************************************
@@ -1706,88 +1706,88 @@ static CURLcode smtp_parse_custom_request(struct connectdata *conn)
{
CURLcode result = CURLE_OK;
struct Curl_easy *data = conn->data;
- struct SMTP *smtp = data->req.p.smtp;
+ struct SMTP *smtp = data->req.p.smtp;
const char *custom = data->set.str[STRING_CUSTOMREQUEST];
/* URL decode the custom request */
if(custom)
- result = Curl_urldecode(data, custom, 0, &smtp->custom, NULL, REJECT_CTRL);
+ result = Curl_urldecode(data, custom, 0, &smtp->custom, NULL, REJECT_CTRL);
+
+ return result;
+}
+
+/***********************************************************************
+ *
+ * smtp_parse_address()
+ *
+ * Parse the fully qualified mailbox address into a local address part and the
+ * host name, converting the host name to an IDN A-label, as per RFC-5890, if
+ * necessary.
+ *
+ * Parameters:
+ *
+ * conn [in] - The connection handle.
+ * fqma [in] - The fully qualified mailbox address (which may or
+ * may not contain UTF-8 characters).
+ * address [in/out] - A new allocated buffer which holds the local
+ * address part of the mailbox. This buffer must be
+ * free'ed by the caller.
+ * host [in/out] - The host name structure that holds the original,
+ * and optionally encoded, host name.
+ * Curl_free_idnconverted_hostname() must be called
+ * once the caller has finished with the structure.
+ *
+ * Returns CURLE_OK on success.
+ *
+ * Notes:
+ *
+ * Should a UTF-8 host name require conversion to IDN ACE and we cannot honor
+ * that conversion then we shall return success. This allow the caller to send
+ * the data to the server as a U-label (as per RFC-6531 sect. 3.2).
+ *
+ * If an mailbox '@' separator cannot be located then the mailbox is considered
+ * to be either a local mailbox or an invalid mailbox (depending on what the
+ * calling function deems it to be) then the input will simply be returned in
+ * the address part with the host name being NULL.
+ */
+static CURLcode smtp_parse_address(struct connectdata *conn, const char *fqma,
+ char **address, struct hostname *host)
+{
+ CURLcode result = CURLE_OK;
+ size_t length;
+
+ /* Duplicate the fully qualified email address so we can manipulate it,
+ ensuring it doesn't contain the delimiters if specified */
+ char *dup = strdup(fqma[0] == '<' ? fqma + 1 : fqma);
+ if(!dup)
+ return CURLE_OUT_OF_MEMORY;
+
+ length = strlen(dup);
+ if(length) {
+ if(dup[length - 1] == '>')
+ dup[length - 1] = '\0';
+ }
+
+ /* Extract the host name from the address (if we can) */
+ host->name = strpbrk(dup, "@");
+ if(host->name) {
+ *host->name = '\0';
+ host->name = host->name + 1;
+
+ /* Attempt to convert the host name to IDN ACE */
+ (void) Curl_idnconvert_hostname(conn, host);
+
+ /* If Curl_idnconvert_hostname() fails then we shall attempt to continue
+ and send the host name using UTF-8 rather than as 7-bit ACE (which is
+ our preference) */
+ }
+
+ /* Extract the local address from the mailbox */
+ *address = dup;
return result;
}
-/***********************************************************************
- *
- * smtp_parse_address()
- *
- * Parse the fully qualified mailbox address into a local address part and the
- * host name, converting the host name to an IDN A-label, as per RFC-5890, if
- * necessary.
- *
- * Parameters:
- *
- * conn [in] - The connection handle.
- * fqma [in] - The fully qualified mailbox address (which may or
- * may not contain UTF-8 characters).
- * address [in/out] - A new allocated buffer which holds the local
- * address part of the mailbox. This buffer must be
- * free'ed by the caller.
- * host [in/out] - The host name structure that holds the original,
- * and optionally encoded, host name.
- * Curl_free_idnconverted_hostname() must be called
- * once the caller has finished with the structure.
- *
- * Returns CURLE_OK on success.
- *
- * Notes:
- *
- * Should a UTF-8 host name require conversion to IDN ACE and we cannot honor
- * that conversion then we shall return success. This allow the caller to send
- * the data to the server as a U-label (as per RFC-6531 sect. 3.2).
- *
- * If an mailbox '@' separator cannot be located then the mailbox is considered
- * to be either a local mailbox or an invalid mailbox (depending on what the
- * calling function deems it to be) then the input will simply be returned in
- * the address part with the host name being NULL.
- */
-static CURLcode smtp_parse_address(struct connectdata *conn, const char *fqma,
- char **address, struct hostname *host)
-{
- CURLcode result = CURLE_OK;
- size_t length;
-
- /* Duplicate the fully qualified email address so we can manipulate it,
- ensuring it doesn't contain the delimiters if specified */
- char *dup = strdup(fqma[0] == '<' ? fqma + 1 : fqma);
- if(!dup)
- return CURLE_OUT_OF_MEMORY;
-
- length = strlen(dup);
- if(length) {
- if(dup[length - 1] == '>')
- dup[length - 1] = '\0';
- }
-
- /* Extract the host name from the address (if we can) */
- host->name = strpbrk(dup, "@");
- if(host->name) {
- *host->name = '\0';
- host->name = host->name + 1;
-
- /* Attempt to convert the host name to IDN ACE */
- (void) Curl_idnconvert_hostname(conn, host);
-
- /* If Curl_idnconvert_hostname() fails then we shall attempt to continue
- and send the host name using UTF-8 rather than as 7-bit ACE (which is
- our preference) */
- }
-
- /* Extract the local address from the mailbox */
- *address = dup;
-
- return result;
-}
-
CURLcode Curl_smtp_escape_eob(struct connectdata *conn, const ssize_t nread)
{
/* When sending a SMTP payload we must detect CRLF. sequences making sure
@@ -1799,7 +1799,7 @@ CURLcode Curl_smtp_escape_eob(struct connectdata *conn, const ssize_t nread)
ssize_t i;
ssize_t si;
struct Curl_easy *data = conn->data;
- struct SMTP *smtp = data->req.p.smtp;
+ struct SMTP *smtp = data->req.p.smtp;
char *scratch = data->state.scratch;
char *newscratch = NULL;
char *oldscratch = NULL;
diff --git a/contrib/libs/curl/lib/smtp.h b/contrib/libs/curl/lib/smtp.h
index 0456d1b02d..c7c62ee857 100644
--- a/contrib/libs/curl/lib/smtp.h
+++ b/contrib/libs/curl/lib/smtp.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 2009 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2009 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -55,9 +55,9 @@ struct SMTP {
curl_pp_transfer transfer;
char *custom; /* Custom Request */
struct curl_slist *rcpt; /* Recipient list */
- bool rcpt_had_ok; /* Whether any of RCPT TO commands (depends on
- total number of recipients) succeeded so far */
- int rcpt_last_error; /* The last error received for RCPT TO command */
+ bool rcpt_had_ok; /* Whether any of RCPT TO commands (depends on
+ total number of recipients) succeeded so far */
+ int rcpt_last_error; /* The last error received for RCPT TO command */
size_t eob; /* Number of bytes of the EOB (End Of Body) that
have been received so far */
bool trailing_crlf; /* Specifies if the tailing CRLF is present */
@@ -74,8 +74,8 @@ struct smtp_conn {
bool tls_supported; /* StartTLS capability supported by server */
bool size_supported; /* If server supports SIZE extension according to
RFC 1870 */
- bool utf8_supported; /* If server supports SMTPUTF8 extension according
- to RFC 6531 */
+ bool utf8_supported; /* If server supports SMTPUTF8 extension according
+ to RFC 6531 */
bool auth_supported; /* AUTH capability supported by server */
};
diff --git a/contrib/libs/curl/lib/sockaddr.h b/contrib/libs/curl/lib/sockaddr.h
index 6c89eeac71..84c08d9bb5 100644
--- a/contrib/libs/curl/lib/sockaddr.h
+++ b/contrib/libs/curl/lib/sockaddr.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/socketpair.c b/contrib/libs/curl/lib/socketpair.c
index 184630617a..2c580ad2de 100644
--- a/contrib/libs/curl/lib/socketpair.c
+++ b/contrib/libs/curl/lib/socketpair.c
@@ -1,121 +1,121 @@
-/***************************************************************************
- * _ _ ____ _
- * Project ___| | | | _ \| |
- * / __| | | | |_) | |
- * | (__| |_| | _ <| |___
- * \___|\___/|_| \_\_____|
- *
- * Copyright (C) 2019 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
- *
- * You may opt to use, copy, modify, merge, publish, distribute and/or sell
- * copies of the Software, and permit persons to whom the Software is
- * furnished to do so, under the terms of the COPYING file.
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- ***************************************************************************/
-
-#include "curl_setup.h"
-#include "socketpair.h"
-
-#if !defined(HAVE_SOCKETPAIR) && !defined(CURL_DISABLE_SOCKETPAIR)
-#ifdef WIN32
-/*
- * This is a socketpair() implementation for Windows.
- */
-#include <string.h>
-#include <winsock2.h>
-#include <ws2tcpip.h>
-#include <windows.h>
-#include <io.h>
-#else
-#ifdef HAVE_NETDB_H
-#include <netdb.h>
-#endif
-#ifdef HAVE_NETINET_IN_H
-#include <netinet/in.h> /* IPPROTO_TCP */
-#endif
-#ifdef HAVE_ARPA_INET_H
-#include <arpa/inet.h>
-#endif
-#ifndef INADDR_LOOPBACK
-#define INADDR_LOOPBACK 0x7f000001
-#endif /* !INADDR_LOOPBACK */
-#endif /* !WIN32 */
-
-/* The last 3 #include files should be in this order */
-#include "curl_printf.h"
-#include "curl_memory.h"
-#include "memdebug.h"
-
-int Curl_socketpair(int domain, int type, int protocol,
- curl_socket_t socks[2])
-{
- union {
- struct sockaddr_in inaddr;
- struct sockaddr addr;
- } a;
- curl_socket_t listener;
- curl_socklen_t addrlen = sizeof(a.inaddr);
- int reuse = 1;
- char data[2][12];
- ssize_t dlen;
- (void)domain;
- (void)type;
- (void)protocol;
-
- listener = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
- if(listener == CURL_SOCKET_BAD)
- return -1;
-
- memset(&a, 0, sizeof(a));
- a.inaddr.sin_family = AF_INET;
- a.inaddr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
- a.inaddr.sin_port = 0;
-
- socks[0] = socks[1] = CURL_SOCKET_BAD;
-
- if(setsockopt(listener, SOL_SOCKET, SO_REUSEADDR,
- (char *)&reuse, (curl_socklen_t)sizeof(reuse)) == -1)
- goto error;
- if(bind(listener, &a.addr, sizeof(a.inaddr)) == -1)
- goto error;
- if(getsockname(listener, &a.addr, &addrlen) == -1)
- goto error;
- if(listen(listener, 1) == -1)
- goto error;
- socks[0] = socket(AF_INET, SOCK_STREAM, 0);
- if(socks[0] == CURL_SOCKET_BAD)
- goto error;
- if(connect(socks[0], &a.addr, sizeof(a.inaddr)) == -1)
- goto error;
- socks[1] = accept(listener, NULL, NULL);
- if(socks[1] == CURL_SOCKET_BAD)
- goto error;
-
- /* verify that nothing else connected */
- msnprintf(data[0], sizeof(data[0]), "%p", socks);
- dlen = strlen(data[0]);
- if(swrite(socks[0], data[0], dlen) != dlen)
- goto error;
- if(sread(socks[1], data[1], sizeof(data[1])) != dlen)
- goto error;
- if(memcmp(data[0], data[1], dlen))
- goto error;
-
- sclose(listener);
- return 0;
-
- error:
- sclose(listener);
- sclose(socks[0]);
- sclose(socks[1]);
- return -1;
-}
-
-#endif /* ! HAVE_SOCKETPAIR */
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 2019 - 2020, 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
+ * are also available at https://curl.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+
+#include "curl_setup.h"
+#include "socketpair.h"
+
+#if !defined(HAVE_SOCKETPAIR) && !defined(CURL_DISABLE_SOCKETPAIR)
+#ifdef WIN32
+/*
+ * This is a socketpair() implementation for Windows.
+ */
+#include <string.h>
+#include <winsock2.h>
+#include <ws2tcpip.h>
+#include <windows.h>
+#include <io.h>
+#else
+#ifdef HAVE_NETDB_H
+#include <netdb.h>
+#endif
+#ifdef HAVE_NETINET_IN_H
+#include <netinet/in.h> /* IPPROTO_TCP */
+#endif
+#ifdef HAVE_ARPA_INET_H
+#include <arpa/inet.h>
+#endif
+#ifndef INADDR_LOOPBACK
+#define INADDR_LOOPBACK 0x7f000001
+#endif /* !INADDR_LOOPBACK */
+#endif /* !WIN32 */
+
+/* The last 3 #include files should be in this order */
+#include "curl_printf.h"
+#include "curl_memory.h"
+#include "memdebug.h"
+
+int Curl_socketpair(int domain, int type, int protocol,
+ curl_socket_t socks[2])
+{
+ union {
+ struct sockaddr_in inaddr;
+ struct sockaddr addr;
+ } a;
+ curl_socket_t listener;
+ curl_socklen_t addrlen = sizeof(a.inaddr);
+ int reuse = 1;
+ char data[2][12];
+ ssize_t dlen;
+ (void)domain;
+ (void)type;
+ (void)protocol;
+
+ listener = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
+ if(listener == CURL_SOCKET_BAD)
+ return -1;
+
+ memset(&a, 0, sizeof(a));
+ a.inaddr.sin_family = AF_INET;
+ a.inaddr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
+ a.inaddr.sin_port = 0;
+
+ socks[0] = socks[1] = CURL_SOCKET_BAD;
+
+ if(setsockopt(listener, SOL_SOCKET, SO_REUSEADDR,
+ (char *)&reuse, (curl_socklen_t)sizeof(reuse)) == -1)
+ goto error;
+ if(bind(listener, &a.addr, sizeof(a.inaddr)) == -1)
+ goto error;
+ if(getsockname(listener, &a.addr, &addrlen) == -1)
+ goto error;
+ if(listen(listener, 1) == -1)
+ goto error;
+ socks[0] = socket(AF_INET, SOCK_STREAM, 0);
+ if(socks[0] == CURL_SOCKET_BAD)
+ goto error;
+ if(connect(socks[0], &a.addr, sizeof(a.inaddr)) == -1)
+ goto error;
+ socks[1] = accept(listener, NULL, NULL);
+ if(socks[1] == CURL_SOCKET_BAD)
+ goto error;
+
+ /* verify that nothing else connected */
+ msnprintf(data[0], sizeof(data[0]), "%p", socks);
+ dlen = strlen(data[0]);
+ if(swrite(socks[0], data[0], dlen) != dlen)
+ goto error;
+ if(sread(socks[1], data[1], sizeof(data[1])) != dlen)
+ goto error;
+ if(memcmp(data[0], data[1], dlen))
+ goto error;
+
+ sclose(listener);
+ return 0;
+
+ error:
+ sclose(listener);
+ sclose(socks[0]);
+ sclose(socks[1]);
+ return -1;
+}
+
+#endif /* ! HAVE_SOCKETPAIR */
diff --git a/contrib/libs/curl/lib/socketpair.h b/contrib/libs/curl/lib/socketpair.h
index 3c666d0dda..033a235aa2 100644
--- a/contrib/libs/curl/lib/socketpair.h
+++ b/contrib/libs/curl/lib/socketpair.h
@@ -1,36 +1,36 @@
-#ifndef HEADER_CURL_SOCKETPAIR_H
-#define HEADER_CURL_SOCKETPAIR_H
-/***************************************************************************
- * _ _ ____ _
- * Project ___| | | | _ \| |
- * / __| | | | |_) | |
- * | (__| |_| | _ <| |___
- * \___|\___/|_| \_\_____|
- *
- * Copyright (C) 2019 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
- *
- * You may opt to use, copy, modify, merge, publish, distribute and/or sell
- * copies of the Software, and permit persons to whom the Software is
- * furnished to do so, under the terms of the COPYING file.
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- ***************************************************************************/
-
-#include "curl_setup.h"
-#ifndef HAVE_SOCKETPAIR
-int Curl_socketpair(int domain, int type, int protocol,
- curl_socket_t socks[2]);
-#else
-#define Curl_socketpair(a,b,c,d) socketpair(a,b,c,d)
-#endif
-
-/* Defined here to allow specific build configs to disable it completely */
-#define USE_SOCKETPAIR 1
-
-#endif /* HEADER_CURL_SOCKETPAIR_H */
+#ifndef HEADER_CURL_SOCKETPAIR_H
+#define HEADER_CURL_SOCKETPAIR_H
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 2019 - 2020, 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
+ * are also available at https://curl.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+
+#include "curl_setup.h"
+#ifndef HAVE_SOCKETPAIR
+int Curl_socketpair(int domain, int type, int protocol,
+ curl_socket_t socks[2]);
+#else
+#define Curl_socketpair(a,b,c,d) socketpair(a,b,c,d)
+#endif
+
+/* Defined here to allow specific build configs to disable it completely */
+#define USE_SOCKETPAIR 1
+
+#endif /* HEADER_CURL_SOCKETPAIR_H */
diff --git a/contrib/libs/curl/lib/socks.c b/contrib/libs/curl/lib/socks.c
index 45c16fcdca..a2d1e621f9 100644
--- a/contrib/libs/curl/lib/socks.c
+++ b/contrib/libs/curl/lib/socks.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -37,19 +37,19 @@
#include "connect.h"
#include "timeval.h"
#include "socks.h"
-#include "multiif.h" /* for getsock macros */
+#include "multiif.h" /* for getsock macros */
-/* The last 3 #include files should be in this order */
-#include "curl_printf.h"
-#include "curl_memory.h"
+/* The last 3 #include files should be in this order */
+#include "curl_printf.h"
+#include "curl_memory.h"
#include "memdebug.h"
-#if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
+#if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
/*
* Helper read-from-socket functions. Does the same as Curl_read() but it
* blocks until all bytes amount of buffersize will be read. No more, no less.
*
- * This is STUPID BLOCKING behavior. Only used by the SOCKS GSSAPI functions.
+ * This is STUPID BLOCKING behavior. Only used by the SOCKS GSSAPI functions.
*/
int Curl_blockread_all(struct connectdata *conn, /* connection data */
curl_socket_t sockfd, /* read from this socket */
@@ -62,15 +62,15 @@ int Curl_blockread_all(struct connectdata *conn, /* connection data */
int result;
*n = 0;
for(;;) {
- timediff_t timeout_ms = Curl_timeleft(conn->data, NULL, TRUE);
- if(timeout_ms < 0) {
+ timediff_t timeout_ms = Curl_timeleft(conn->data, NULL, TRUE);
+ if(timeout_ms < 0) {
/* we already got the timeout */
result = CURLE_OPERATION_TIMEDOUT;
break;
}
- if(!timeout_ms)
- timeout_ms = TIMEDIFF_T_MAX;
- if(SOCKET_READABLE(sockfd, timeout_ms) <= 0) {
+ if(!timeout_ms)
+ timeout_ms = TIMEDIFF_T_MAX;
+ if(SOCKET_READABLE(sockfd, timeout_ms) <= 0) {
result = ~CURLE_OK;
break;
}
@@ -97,82 +97,82 @@ int Curl_blockread_all(struct connectdata *conn, /* connection data */
}
return result;
}
-#endif
-
-#ifndef DEBUGBUILD
-#define sxstate(x,y) socksstate(x,y)
-#else
-#define sxstate(x,y) socksstate(x,y, __LINE__)
-#endif
-
-
-/* always use this function to change state, to make debugging easier */
-static void socksstate(struct connectdata *conn,
- enum connect_t state
-#ifdef DEBUGBUILD
- , int lineno
-#endif
-)
-{
- enum connect_t oldstate = conn->cnnct.state;
-#if defined(DEBUGBUILD) && !defined(CURL_DISABLE_VERBOSE_STRINGS)
- /* synced with the state list in urldata.h */
- static const char * const statename[] = {
- "INIT",
- "SOCKS_INIT",
- "SOCKS_SEND",
- "SOCKS_READ_INIT",
- "SOCKS_READ",
- "GSSAPI_INIT",
- "AUTH_INIT",
- "AUTH_SEND",
- "AUTH_READ",
- "REQ_INIT",
- "RESOLVING",
- "RESOLVED",
- "RESOLVE_REMOTE",
- "REQ_SEND",
- "REQ_SENDING",
- "REQ_READ",
- "REQ_READ_MORE",
- "DONE"
- };
-#endif
-
- if(oldstate == state)
- /* don't bother when the new state is the same as the old state */
- return;
-
- conn->cnnct.state = state;
-
-#if defined(DEBUGBUILD) && !defined(CURL_DISABLE_VERBOSE_STRINGS)
- infof(conn->data,
- "SXSTATE: %s => %s conn %p; line %d\n",
- statename[oldstate], statename[conn->cnnct.state], conn,
- lineno);
-#endif
-}
-
-int Curl_SOCKS_getsock(struct connectdata *conn, curl_socket_t *sock,
- int sockindex)
-{
- int rc = 0;
- sock[0] = conn->sock[sockindex];
- switch(conn->cnnct.state) {
- case CONNECT_RESOLVING:
- case CONNECT_SOCKS_READ:
- case CONNECT_AUTH_READ:
- case CONNECT_REQ_READ:
- case CONNECT_REQ_READ_MORE:
- rc = GETSOCK_READSOCK(0);
- break;
- default:
- rc = GETSOCK_WRITESOCK(0);
- break;
- }
- return rc;
-}
-
+#endif
+
+#ifndef DEBUGBUILD
+#define sxstate(x,y) socksstate(x,y)
+#else
+#define sxstate(x,y) socksstate(x,y, __LINE__)
+#endif
+
+
+/* always use this function to change state, to make debugging easier */
+static void socksstate(struct connectdata *conn,
+ enum connect_t state
+#ifdef DEBUGBUILD
+ , int lineno
+#endif
+)
+{
+ enum connect_t oldstate = conn->cnnct.state;
+#if defined(DEBUGBUILD) && !defined(CURL_DISABLE_VERBOSE_STRINGS)
+ /* synced with the state list in urldata.h */
+ static const char * const statename[] = {
+ "INIT",
+ "SOCKS_INIT",
+ "SOCKS_SEND",
+ "SOCKS_READ_INIT",
+ "SOCKS_READ",
+ "GSSAPI_INIT",
+ "AUTH_INIT",
+ "AUTH_SEND",
+ "AUTH_READ",
+ "REQ_INIT",
+ "RESOLVING",
+ "RESOLVED",
+ "RESOLVE_REMOTE",
+ "REQ_SEND",
+ "REQ_SENDING",
+ "REQ_READ",
+ "REQ_READ_MORE",
+ "DONE"
+ };
+#endif
+
+ if(oldstate == state)
+ /* don't bother when the new state is the same as the old state */
+ return;
+
+ conn->cnnct.state = state;
+
+#if defined(DEBUGBUILD) && !defined(CURL_DISABLE_VERBOSE_STRINGS)
+ infof(conn->data,
+ "SXSTATE: %s => %s conn %p; line %d\n",
+ statename[oldstate], statename[conn->cnnct.state], conn,
+ lineno);
+#endif
+}
+
+int Curl_SOCKS_getsock(struct connectdata *conn, curl_socket_t *sock,
+ int sockindex)
+{
+ int rc = 0;
+ sock[0] = conn->sock[sockindex];
+ switch(conn->cnnct.state) {
+ case CONNECT_RESOLVING:
+ case CONNECT_SOCKS_READ:
+ case CONNECT_AUTH_READ:
+ case CONNECT_REQ_READ:
+ case CONNECT_REQ_READ_MORE:
+ rc = GETSOCK_READSOCK(0);
+ break;
+ default:
+ rc = GETSOCK_WRITESOCK(0);
+ break;
+ }
+ return rc;
+}
+
/*
* This function logs in to a SOCKS4 proxy and sends the specifics to the final
* destination server.
@@ -184,98 +184,98 @@ int Curl_SOCKS_getsock(struct connectdata *conn, curl_socket_t *sock,
* Set protocol4a=true for "SOCKS 4A (Simple Extension to SOCKS 4 Protocol)"
* Nonsupport "Identification Protocol (RFC1413)"
*/
-CURLproxycode Curl_SOCKS4(const char *proxy_user,
- const char *hostname,
- int remote_port,
- int sockindex,
- struct connectdata *conn,
- bool *done)
+CURLproxycode Curl_SOCKS4(const char *proxy_user,
+ const char *hostname,
+ int remote_port,
+ int sockindex,
+ struct connectdata *conn,
+ bool *done)
{
const bool protocol4a =
(conn->socks_proxy.proxytype == CURLPROXY_SOCKS4A) ? TRUE : FALSE;
- unsigned char *socksreq = &conn->cnnct.socksreq[0];
- CURLcode result;
- curl_socket_t sockfd = conn->sock[sockindex];
+ unsigned char *socksreq = &conn->cnnct.socksreq[0];
+ CURLcode result;
+ curl_socket_t sockfd = conn->sock[sockindex];
struct Curl_easy *data = conn->data;
- struct connstate *sx = &conn->cnnct;
- struct Curl_dns_entry *dns = NULL;
- ssize_t actualread;
- ssize_t written;
-
- if(!SOCKS_STATE(sx->state) && !*done)
- sxstate(conn, CONNECT_SOCKS_INIT);
-
- switch(sx->state) {
- case CONNECT_SOCKS_INIT:
- /* SOCKS4 can only do IPv4, insist! */
- conn->ip_version = CURL_IPRESOLVE_V4;
- if(conn->bits.httpproxy)
- infof(conn->data, "SOCKS4%s: connecting to HTTP proxy %s port %d\n",
- protocol4a ? "a" : "", hostname, remote_port);
-
- infof(data, "SOCKS4 communication to %s:%d\n", hostname, remote_port);
-
- /*
- * Compose socks4 request
- *
- * Request format
- *
- * +----+----+----+----+----+----+----+----+----+----+....+----+
- * | VN | CD | DSTPORT | DSTIP | USERID |NULL|
- * +----+----+----+----+----+----+----+----+----+----+....+----+
- * # of bytes: 1 1 2 4 variable 1
- */
-
- socksreq[0] = 4; /* version (SOCKS4) */
- socksreq[1] = 1; /* connect */
- socksreq[2] = (unsigned char)((remote_port >> 8) & 0xff); /* PORT MSB */
- socksreq[3] = (unsigned char)(remote_port & 0xff); /* PORT LSB */
-
- /* DNS resolve only for SOCKS4, not SOCKS4a */
- if(!protocol4a) {
- enum resolve_t rc =
- Curl_resolv(conn, hostname, remote_port, FALSE, &dns);
-
- if(rc == CURLRESOLV_ERROR)
- return CURLPX_RESOLVE_HOST;
- else if(rc == CURLRESOLV_PENDING) {
- sxstate(conn, CONNECT_RESOLVING);
- infof(data, "SOCKS4 non-blocking resolve of %s\n", hostname);
- return CURLPX_OK;
- }
- sxstate(conn, CONNECT_RESOLVED);
- goto CONNECT_RESOLVED;
- }
-
- /* socks4a doesn't resolve anything locally */
- sxstate(conn, CONNECT_REQ_INIT);
- goto CONNECT_REQ_INIT;
-
- case CONNECT_RESOLVING:
- /* check if we have the name resolved by now */
- dns = Curl_fetch_addr(conn, hostname, (int)conn->port);
-
- if(dns) {
-#ifdef CURLRES_ASYNCH
- conn->async.dns = dns;
- conn->async.done = TRUE;
-#endif
- infof(data, "Hostname '%s' was found\n", hostname);
- sxstate(conn, CONNECT_RESOLVED);
- }
- else {
- result = Curl_resolv_check(data->conn, &dns);
- if(!dns) {
- if(result)
- return CURLPX_RESOLVE_HOST;
- return CURLPX_OK;
- }
- }
- /* FALLTHROUGH */
- CONNECT_RESOLVED:
- case CONNECT_RESOLVED: {
- struct Curl_addrinfo *hp = NULL;
- char buf[64];
+ struct connstate *sx = &conn->cnnct;
+ struct Curl_dns_entry *dns = NULL;
+ ssize_t actualread;
+ ssize_t written;
+
+ if(!SOCKS_STATE(sx->state) && !*done)
+ sxstate(conn, CONNECT_SOCKS_INIT);
+
+ switch(sx->state) {
+ case CONNECT_SOCKS_INIT:
+ /* SOCKS4 can only do IPv4, insist! */
+ conn->ip_version = CURL_IPRESOLVE_V4;
+ if(conn->bits.httpproxy)
+ infof(conn->data, "SOCKS4%s: connecting to HTTP proxy %s port %d\n",
+ protocol4a ? "a" : "", hostname, remote_port);
+
+ infof(data, "SOCKS4 communication to %s:%d\n", hostname, remote_port);
+
+ /*
+ * Compose socks4 request
+ *
+ * Request format
+ *
+ * +----+----+----+----+----+----+----+----+----+----+....+----+
+ * | VN | CD | DSTPORT | DSTIP | USERID |NULL|
+ * +----+----+----+----+----+----+----+----+----+----+....+----+
+ * # of bytes: 1 1 2 4 variable 1
+ */
+
+ socksreq[0] = 4; /* version (SOCKS4) */
+ socksreq[1] = 1; /* connect */
+ socksreq[2] = (unsigned char)((remote_port >> 8) & 0xff); /* PORT MSB */
+ socksreq[3] = (unsigned char)(remote_port & 0xff); /* PORT LSB */
+
+ /* DNS resolve only for SOCKS4, not SOCKS4a */
+ if(!protocol4a) {
+ enum resolve_t rc =
+ Curl_resolv(conn, hostname, remote_port, FALSE, &dns);
+
+ if(rc == CURLRESOLV_ERROR)
+ return CURLPX_RESOLVE_HOST;
+ else if(rc == CURLRESOLV_PENDING) {
+ sxstate(conn, CONNECT_RESOLVING);
+ infof(data, "SOCKS4 non-blocking resolve of %s\n", hostname);
+ return CURLPX_OK;
+ }
+ sxstate(conn, CONNECT_RESOLVED);
+ goto CONNECT_RESOLVED;
+ }
+
+ /* socks4a doesn't resolve anything locally */
+ sxstate(conn, CONNECT_REQ_INIT);
+ goto CONNECT_REQ_INIT;
+
+ case CONNECT_RESOLVING:
+ /* check if we have the name resolved by now */
+ dns = Curl_fetch_addr(conn, hostname, (int)conn->port);
+
+ if(dns) {
+#ifdef CURLRES_ASYNCH
+ conn->async.dns = dns;
+ conn->async.done = TRUE;
+#endif
+ infof(data, "Hostname '%s' was found\n", hostname);
+ sxstate(conn, CONNECT_RESOLVED);
+ }
+ else {
+ result = Curl_resolv_check(data->conn, &dns);
+ if(!dns) {
+ if(result)
+ return CURLPX_RESOLVE_HOST;
+ return CURLPX_OK;
+ }
+ }
+ /* FALLTHROUGH */
+ CONNECT_RESOLVED:
+ case CONNECT_RESOLVED: {
+ struct Curl_addrinfo *hp = NULL;
+ char buf[64];
/*
* We cannot use 'hostent' as a struct that Curl_resolv() returns. It
* returns a Curl_addrinfo pointer that may not always look the same.
@@ -306,188 +306,188 @@ CURLproxycode Curl_SOCKS4(const char *proxy_user,
if(!hp) {
failf(data, "Failed to resolve \"%s\" for SOCKS4 connect.",
hostname);
- return CURLPX_RESOLVE_HOST;
+ return CURLPX_RESOLVE_HOST;
}
}
- /* FALLTHROUGH */
- CONNECT_REQ_INIT:
- case CONNECT_REQ_INIT:
- /*
- * This is currently not supporting "Identification Protocol (RFC1413)".
- */
- socksreq[8] = 0; /* ensure empty userid is NUL-terminated */
- if(proxy_user) {
- size_t plen = strlen(proxy_user);
- if(plen >= sizeof(sx->socksreq) - 8) {
- failf(data, "Too long SOCKS proxy user name, can't use!\n");
- return CURLPX_LONG_USER;
- }
- /* copy the proxy name WITH trailing zero */
- memcpy(socksreq + 8, proxy_user, plen + 1);
- }
-
- /*
- * Make connection
- */
- {
- size_t packetsize = 9 +
- strlen((char *)socksreq + 8); /* size including NUL */
-
- /* If SOCKS4a, set special invalid IP address 0.0.0.x */
- if(protocol4a) {
- size_t hostnamelen = 0;
- socksreq[4] = 0;
- socksreq[5] = 0;
- socksreq[6] = 0;
- socksreq[7] = 1;
- /* append hostname */
- hostnamelen = strlen(hostname) + 1; /* length including NUL */
- if(hostnamelen <= 255)
- strcpy((char *)socksreq + packetsize, hostname);
- else {
- failf(data, "SOCKS4: too long host name");
- return CURLPX_LONG_HOSTNAME;
- }
- packetsize += hostnamelen;
- }
- sx->outp = socksreq;
- sx->outstanding = packetsize;
- sxstate(conn, CONNECT_REQ_SENDING);
- }
- /* FALLTHROUGH */
- case CONNECT_REQ_SENDING:
+ /* FALLTHROUGH */
+ CONNECT_REQ_INIT:
+ case CONNECT_REQ_INIT:
+ /*
+ * This is currently not supporting "Identification Protocol (RFC1413)".
+ */
+ socksreq[8] = 0; /* ensure empty userid is NUL-terminated */
+ if(proxy_user) {
+ size_t plen = strlen(proxy_user);
+ if(plen >= sizeof(sx->socksreq) - 8) {
+ failf(data, "Too long SOCKS proxy user name, can't use!\n");
+ return CURLPX_LONG_USER;
+ }
+ /* copy the proxy name WITH trailing zero */
+ memcpy(socksreq + 8, proxy_user, plen + 1);
+ }
+
+ /*
+ * Make connection
+ */
+ {
+ size_t packetsize = 9 +
+ strlen((char *)socksreq + 8); /* size including NUL */
+
+ /* If SOCKS4a, set special invalid IP address 0.0.0.x */
+ if(protocol4a) {
+ size_t hostnamelen = 0;
+ socksreq[4] = 0;
+ socksreq[5] = 0;
+ socksreq[6] = 0;
+ socksreq[7] = 1;
+ /* append hostname */
+ hostnamelen = strlen(hostname) + 1; /* length including NUL */
+ if(hostnamelen <= 255)
+ strcpy((char *)socksreq + packetsize, hostname);
+ else {
+ failf(data, "SOCKS4: too long host name");
+ return CURLPX_LONG_HOSTNAME;
+ }
+ packetsize += hostnamelen;
+ }
+ sx->outp = socksreq;
+ sx->outstanding = packetsize;
+ sxstate(conn, CONNECT_REQ_SENDING);
+ }
+ /* FALLTHROUGH */
+ case CONNECT_REQ_SENDING:
/* Send request */
- result = Curl_write_plain(conn, sockfd, (char *)sx->outp,
- sx->outstanding, &written);
- if(result && (CURLE_AGAIN != result)) {
+ result = Curl_write_plain(conn, sockfd, (char *)sx->outp,
+ sx->outstanding, &written);
+ if(result && (CURLE_AGAIN != result)) {
failf(data, "Failed to send SOCKS4 connect request.");
- return CURLPX_SEND_CONNECT;
+ return CURLPX_SEND_CONNECT;
}
- if(written != sx->outstanding) {
- /* not done, remain in state */
- sx->outstanding -= written;
- sx->outp += written;
- return CURLPX_OK;
+ if(written != sx->outstanding) {
+ /* not done, remain in state */
+ sx->outstanding -= written;
+ sx->outp += written;
+ return CURLPX_OK;
}
- /* done sending! */
- sx->outstanding = 8; /* receive data size */
- sx->outp = socksreq;
- sxstate(conn, CONNECT_SOCKS_READ);
+ /* done sending! */
+ sx->outstanding = 8; /* receive data size */
+ sx->outp = socksreq;
+ sxstate(conn, CONNECT_SOCKS_READ);
- /* FALLTHROUGH */
- case CONNECT_SOCKS_READ:
+ /* FALLTHROUGH */
+ case CONNECT_SOCKS_READ:
/* Receive response */
- result = Curl_read_plain(sockfd, (char *)sx->outp,
- sx->outstanding, &actualread);
- if(result && (CURLE_AGAIN != result)) {
- failf(data, "SOCKS4: Failed receiving connect request ack: %s",
- curl_easy_strerror(result));
- return CURLPX_RECV_CONNECT;
- }
- else if(!result && !actualread) {
- /* connection closed */
- failf(data, "connection to proxy closed");
- return CURLPX_CLOSED;
- }
- else if(actualread != sx->outstanding) {
- /* remain in reading state */
- sx->outstanding -= actualread;
- sx->outp += actualread;
- return CURLPX_OK;
- }
- sxstate(conn, CONNECT_DONE);
- break;
- default: /* lots of unused states in SOCKS4 */
- break;
- }
-
- /*
- * Response format
- *
- * +----+----+----+----+----+----+----+----+
- * | VN | CD | DSTPORT | DSTIP |
- * +----+----+----+----+----+----+----+----+
- * # of bytes: 1 1 2 4
- *
- * VN is the version of the reply code and should be 0. CD is the result
- * code with one of the following values:
- *
- * 90: request granted
- * 91: request rejected or failed
- * 92: request rejected because SOCKS server cannot connect to
- * identd on the client
- * 93: request rejected because the client program and identd
- * report different user-ids
- */
-
- /* wrong version ? */
- if(socksreq[0] != 0) {
- failf(data,
- "SOCKS4 reply has wrong version, version should be 0.");
- return CURLPX_BAD_VERSION;
- }
-
- /* Result */
- switch(socksreq[1]) {
- case 90:
- infof(data, "SOCKS4%s request granted.\n", protocol4a?"a":"");
- break;
- case 91:
- failf(data,
- "Can't complete SOCKS4 connection to %d.%d.%d.%d:%d. (%d)"
- ", request rejected or failed.",
- (unsigned char)socksreq[4], (unsigned char)socksreq[5],
- (unsigned char)socksreq[6], (unsigned char)socksreq[7],
- (((unsigned char)socksreq[2] << 8) | (unsigned char)socksreq[3]),
- (unsigned char)socksreq[1]);
- return CURLPX_REQUEST_FAILED;
- case 92:
- failf(data,
- "Can't complete SOCKS4 connection to %d.%d.%d.%d:%d. (%d)"
- ", request rejected because SOCKS server cannot connect to "
- "identd on the client.",
- (unsigned char)socksreq[4], (unsigned char)socksreq[5],
- (unsigned char)socksreq[6], (unsigned char)socksreq[7],
- (((unsigned char)socksreq[2] << 8) | (unsigned char)socksreq[3]),
- (unsigned char)socksreq[1]);
- return CURLPX_IDENTD;
- case 93:
- failf(data,
- "Can't complete SOCKS4 connection to %d.%d.%d.%d:%d. (%d)"
- ", request rejected because the client program and identd "
- "report different user-ids.",
- (unsigned char)socksreq[4], (unsigned char)socksreq[5],
- (unsigned char)socksreq[6], (unsigned char)socksreq[7],
- (((unsigned char)socksreq[2] << 8) | (unsigned char)socksreq[3]),
- (unsigned char)socksreq[1]);
- return CURLPX_IDENTD_DIFFER;
- default:
- failf(data,
- "Can't complete SOCKS4 connection to %d.%d.%d.%d:%d. (%d)"
- ", Unknown.",
- (unsigned char)socksreq[4], (unsigned char)socksreq[5],
- (unsigned char)socksreq[6], (unsigned char)socksreq[7],
- (((unsigned char)socksreq[2] << 8) | (unsigned char)socksreq[3]),
- (unsigned char)socksreq[1]);
- return CURLPX_UNKNOWN_FAIL;
+ result = Curl_read_plain(sockfd, (char *)sx->outp,
+ sx->outstanding, &actualread);
+ if(result && (CURLE_AGAIN != result)) {
+ failf(data, "SOCKS4: Failed receiving connect request ack: %s",
+ curl_easy_strerror(result));
+ return CURLPX_RECV_CONNECT;
+ }
+ else if(!result && !actualread) {
+ /* connection closed */
+ failf(data, "connection to proxy closed");
+ return CURLPX_CLOSED;
+ }
+ else if(actualread != sx->outstanding) {
+ /* remain in reading state */
+ sx->outstanding -= actualread;
+ sx->outp += actualread;
+ return CURLPX_OK;
+ }
+ sxstate(conn, CONNECT_DONE);
+ break;
+ default: /* lots of unused states in SOCKS4 */
+ break;
+ }
+
+ /*
+ * Response format
+ *
+ * +----+----+----+----+----+----+----+----+
+ * | VN | CD | DSTPORT | DSTIP |
+ * +----+----+----+----+----+----+----+----+
+ * # of bytes: 1 1 2 4
+ *
+ * VN is the version of the reply code and should be 0. CD is the result
+ * code with one of the following values:
+ *
+ * 90: request granted
+ * 91: request rejected or failed
+ * 92: request rejected because SOCKS server cannot connect to
+ * identd on the client
+ * 93: request rejected because the client program and identd
+ * report different user-ids
+ */
+
+ /* wrong version ? */
+ if(socksreq[0] != 0) {
+ failf(data,
+ "SOCKS4 reply has wrong version, version should be 0.");
+ return CURLPX_BAD_VERSION;
}
- *done = TRUE;
- return CURLPX_OK; /* Proxy was successful! */
+ /* Result */
+ switch(socksreq[1]) {
+ case 90:
+ infof(data, "SOCKS4%s request granted.\n", protocol4a?"a":"");
+ break;
+ case 91:
+ failf(data,
+ "Can't complete SOCKS4 connection to %d.%d.%d.%d:%d. (%d)"
+ ", request rejected or failed.",
+ (unsigned char)socksreq[4], (unsigned char)socksreq[5],
+ (unsigned char)socksreq[6], (unsigned char)socksreq[7],
+ (((unsigned char)socksreq[2] << 8) | (unsigned char)socksreq[3]),
+ (unsigned char)socksreq[1]);
+ return CURLPX_REQUEST_FAILED;
+ case 92:
+ failf(data,
+ "Can't complete SOCKS4 connection to %d.%d.%d.%d:%d. (%d)"
+ ", request rejected because SOCKS server cannot connect to "
+ "identd on the client.",
+ (unsigned char)socksreq[4], (unsigned char)socksreq[5],
+ (unsigned char)socksreq[6], (unsigned char)socksreq[7],
+ (((unsigned char)socksreq[2] << 8) | (unsigned char)socksreq[3]),
+ (unsigned char)socksreq[1]);
+ return CURLPX_IDENTD;
+ case 93:
+ failf(data,
+ "Can't complete SOCKS4 connection to %d.%d.%d.%d:%d. (%d)"
+ ", request rejected because the client program and identd "
+ "report different user-ids.",
+ (unsigned char)socksreq[4], (unsigned char)socksreq[5],
+ (unsigned char)socksreq[6], (unsigned char)socksreq[7],
+ (((unsigned char)socksreq[2] << 8) | (unsigned char)socksreq[3]),
+ (unsigned char)socksreq[1]);
+ return CURLPX_IDENTD_DIFFER;
+ default:
+ failf(data,
+ "Can't complete SOCKS4 connection to %d.%d.%d.%d:%d. (%d)"
+ ", Unknown.",
+ (unsigned char)socksreq[4], (unsigned char)socksreq[5],
+ (unsigned char)socksreq[6], (unsigned char)socksreq[7],
+ (((unsigned char)socksreq[2] << 8) | (unsigned char)socksreq[3]),
+ (unsigned char)socksreq[1]);
+ return CURLPX_UNKNOWN_FAIL;
+ }
+
+ *done = TRUE;
+ return CURLPX_OK; /* Proxy was successful! */
}
/*
* This function logs in to a SOCKS5 proxy and sends the specifics to the final
* destination server.
*/
-CURLproxycode Curl_SOCKS5(const char *proxy_user,
- const char *proxy_password,
- const char *hostname,
- int remote_port,
- int sockindex,
- struct connectdata *conn,
- bool *done)
+CURLproxycode Curl_SOCKS5(const char *proxy_user,
+ const char *proxy_password,
+ const char *hostname,
+ int remote_port,
+ int sockindex,
+ struct connectdata *conn,
+ bool *done)
{
/*
According to the RFC1928, section "6. Replies". This is what a SOCK5
@@ -505,13 +505,13 @@ CURLproxycode Curl_SOCKS5(const char *proxy_user,
o REP Reply field:
o X'00' succeeded
*/
- unsigned char *socksreq = &conn->cnnct.socksreq[0];
- char dest[256] = "unknown"; /* printable hostname:port */
+ unsigned char *socksreq = &conn->cnnct.socksreq[0];
+ char dest[256] = "unknown"; /* printable hostname:port */
int idx;
ssize_t actualread;
ssize_t written;
- CURLcode result;
- curl_socket_t sockfd = conn->sock[sockindex];
+ CURLcode result;
+ curl_socket_t sockfd = conn->sock[sockindex];
struct Curl_easy *data = conn->data;
bool socks5_resolve_local =
(conn->socks_proxy.proxytype == CURLPROXY_SOCKS5) ? TRUE : FALSE;
@@ -519,148 +519,148 @@ CURLproxycode Curl_SOCKS5(const char *proxy_user,
ssize_t len = 0;
const unsigned long auth = data->set.socks5auth;
bool allow_gssapi = FALSE;
- struct connstate *sx = &conn->cnnct;
- struct Curl_dns_entry *dns = NULL;
-
- if(!SOCKS_STATE(sx->state) && !*done)
- sxstate(conn, CONNECT_SOCKS_INIT);
-
- switch(sx->state) {
- case CONNECT_SOCKS_INIT:
- if(conn->bits.httpproxy)
- infof(conn->data, "SOCKS5: connecting to HTTP proxy %s port %d\n",
- hostname, remote_port);
-
- /* RFC1928 chapter 5 specifies max 255 chars for domain name in packet */
- if(!socks5_resolve_local && hostname_len > 255) {
- infof(conn->data, "SOCKS5: server resolving disabled for hostnames of "
- "length > 255 [actual len=%zu]\n", hostname_len);
- socks5_resolve_local = TRUE;
- }
-
- if(auth & ~(CURLAUTH_BASIC | CURLAUTH_GSSAPI))
- infof(conn->data,
- "warning: unsupported value passed to CURLOPT_SOCKS5_AUTH: %lu\n",
- auth);
- if(!(auth & CURLAUTH_BASIC))
- /* disable username/password auth */
- proxy_user = NULL;
+ struct connstate *sx = &conn->cnnct;
+ struct Curl_dns_entry *dns = NULL;
+
+ if(!SOCKS_STATE(sx->state) && !*done)
+ sxstate(conn, CONNECT_SOCKS_INIT);
+
+ switch(sx->state) {
+ case CONNECT_SOCKS_INIT:
+ if(conn->bits.httpproxy)
+ infof(conn->data, "SOCKS5: connecting to HTTP proxy %s port %d\n",
+ hostname, remote_port);
+
+ /* RFC1928 chapter 5 specifies max 255 chars for domain name in packet */
+ if(!socks5_resolve_local && hostname_len > 255) {
+ infof(conn->data, "SOCKS5: server resolving disabled for hostnames of "
+ "length > 255 [actual len=%zu]\n", hostname_len);
+ socks5_resolve_local = TRUE;
+ }
+
+ if(auth & ~(CURLAUTH_BASIC | CURLAUTH_GSSAPI))
+ infof(conn->data,
+ "warning: unsupported value passed to CURLOPT_SOCKS5_AUTH: %lu\n",
+ auth);
+ if(!(auth & CURLAUTH_BASIC))
+ /* disable username/password auth */
+ proxy_user = NULL;
#if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
- if(auth & CURLAUTH_GSSAPI)
- allow_gssapi = TRUE;
+ if(auth & CURLAUTH_GSSAPI)
+ allow_gssapi = TRUE;
#endif
- idx = 0;
- socksreq[idx++] = 5; /* version */
- idx++; /* number of authentication methods */
- socksreq[idx++] = 0; /* no authentication */
- if(allow_gssapi)
- socksreq[idx++] = 1; /* GSS-API */
- if(proxy_user)
- socksreq[idx++] = 2; /* username/password */
- /* write the number of authentication methods */
- socksreq[1] = (unsigned char) (idx - 2);
-
- result = Curl_write_plain(conn, sockfd, (char *)socksreq, idx, &written);
- if(result && (CURLE_AGAIN != result)) {
- failf(data, "Unable to send initial SOCKS5 request.");
- return CURLPX_SEND_CONNECT;
- }
- if(written != idx) {
- sxstate(conn, CONNECT_SOCKS_SEND);
- sx->outstanding = idx - written;
- sx->outp = &socksreq[written];
- return CURLPX_OK;
- }
- sxstate(conn, CONNECT_SOCKS_READ);
- goto CONNECT_SOCKS_READ_INIT;
- case CONNECT_SOCKS_SEND:
- result = Curl_write_plain(conn, sockfd, (char *)sx->outp,
- sx->outstanding, &written);
- if(result && (CURLE_AGAIN != result)) {
- failf(data, "Unable to send initial SOCKS5 request.");
- return CURLPX_SEND_CONNECT;
- }
- if(written != sx->outstanding) {
- /* not done, remain in state */
- sx->outstanding -= written;
- sx->outp += written;
- return CURLPX_OK;
- }
- /* FALLTHROUGH */
- CONNECT_SOCKS_READ_INIT:
- case CONNECT_SOCKS_READ_INIT:
- sx->outstanding = 2; /* expect two bytes */
- sx->outp = socksreq; /* store it here */
- /* FALLTHROUGH */
- case CONNECT_SOCKS_READ:
- result = Curl_read_plain(sockfd, (char *)sx->outp,
- sx->outstanding, &actualread);
- if(result && (CURLE_AGAIN != result)) {
- failf(data, "Unable to receive initial SOCKS5 response.");
- return CURLPX_RECV_CONNECT;
- }
- else if(!result && !actualread) {
- /* connection closed */
- failf(data, "Connection to proxy closed");
- return CURLPX_CLOSED;
- }
- else if(actualread != sx->outstanding) {
- /* remain in reading state */
- sx->outstanding -= actualread;
- sx->outp += actualread;
- return CURLPX_OK;
- }
- else if(socksreq[0] != 5) {
- failf(data, "Received invalid version in initial SOCKS5 response.");
- return CURLPX_BAD_VERSION;
- }
- else if(socksreq[1] == 0) {
- /* DONE! No authentication needed. Send request. */
- sxstate(conn, CONNECT_REQ_INIT);
- goto CONNECT_REQ_INIT;
- }
- else if(socksreq[1] == 2) {
- /* regular name + password authentication */
- sxstate(conn, CONNECT_AUTH_INIT);
- goto CONNECT_AUTH_INIT;
- }
+ idx = 0;
+ socksreq[idx++] = 5; /* version */
+ idx++; /* number of authentication methods */
+ socksreq[idx++] = 0; /* no authentication */
+ if(allow_gssapi)
+ socksreq[idx++] = 1; /* GSS-API */
+ if(proxy_user)
+ socksreq[idx++] = 2; /* username/password */
+ /* write the number of authentication methods */
+ socksreq[1] = (unsigned char) (idx - 2);
+
+ result = Curl_write_plain(conn, sockfd, (char *)socksreq, idx, &written);
+ if(result && (CURLE_AGAIN != result)) {
+ failf(data, "Unable to send initial SOCKS5 request.");
+ return CURLPX_SEND_CONNECT;
+ }
+ if(written != idx) {
+ sxstate(conn, CONNECT_SOCKS_SEND);
+ sx->outstanding = idx - written;
+ sx->outp = &socksreq[written];
+ return CURLPX_OK;
+ }
+ sxstate(conn, CONNECT_SOCKS_READ);
+ goto CONNECT_SOCKS_READ_INIT;
+ case CONNECT_SOCKS_SEND:
+ result = Curl_write_plain(conn, sockfd, (char *)sx->outp,
+ sx->outstanding, &written);
+ if(result && (CURLE_AGAIN != result)) {
+ failf(data, "Unable to send initial SOCKS5 request.");
+ return CURLPX_SEND_CONNECT;
+ }
+ if(written != sx->outstanding) {
+ /* not done, remain in state */
+ sx->outstanding -= written;
+ sx->outp += written;
+ return CURLPX_OK;
+ }
+ /* FALLTHROUGH */
+ CONNECT_SOCKS_READ_INIT:
+ case CONNECT_SOCKS_READ_INIT:
+ sx->outstanding = 2; /* expect two bytes */
+ sx->outp = socksreq; /* store it here */
+ /* FALLTHROUGH */
+ case CONNECT_SOCKS_READ:
+ result = Curl_read_plain(sockfd, (char *)sx->outp,
+ sx->outstanding, &actualread);
+ if(result && (CURLE_AGAIN != result)) {
+ failf(data, "Unable to receive initial SOCKS5 response.");
+ return CURLPX_RECV_CONNECT;
+ }
+ else if(!result && !actualread) {
+ /* connection closed */
+ failf(data, "Connection to proxy closed");
+ return CURLPX_CLOSED;
+ }
+ else if(actualread != sx->outstanding) {
+ /* remain in reading state */
+ sx->outstanding -= actualread;
+ sx->outp += actualread;
+ return CURLPX_OK;
+ }
+ else if(socksreq[0] != 5) {
+ failf(data, "Received invalid version in initial SOCKS5 response.");
+ return CURLPX_BAD_VERSION;
+ }
+ else if(socksreq[1] == 0) {
+ /* DONE! No authentication needed. Send request. */
+ sxstate(conn, CONNECT_REQ_INIT);
+ goto CONNECT_REQ_INIT;
+ }
+ else if(socksreq[1] == 2) {
+ /* regular name + password authentication */
+ sxstate(conn, CONNECT_AUTH_INIT);
+ goto CONNECT_AUTH_INIT;
+ }
#if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
- else if(allow_gssapi && (socksreq[1] == 1)) {
- sxstate(conn, CONNECT_GSSAPI_INIT);
- result = Curl_SOCKS5_gssapi_negotiate(sockindex, conn);
- if(result) {
- failf(data, "Unable to negotiate SOCKS5 GSS-API context.");
- return CURLPX_GSSAPI;
- }
+ else if(allow_gssapi && (socksreq[1] == 1)) {
+ sxstate(conn, CONNECT_GSSAPI_INIT);
+ result = Curl_SOCKS5_gssapi_negotiate(sockindex, conn);
+ if(result) {
+ failf(data, "Unable to negotiate SOCKS5 GSS-API context.");
+ return CURLPX_GSSAPI;
+ }
}
#endif
- else {
- /* error */
- if(!allow_gssapi && (socksreq[1] == 1)) {
- failf(data,
- "SOCKS5 GSSAPI per-message authentication is not supported.");
- return CURLPX_GSSAPI_PERMSG;
- }
- else if(socksreq[1] == 255) {
- failf(data, "No authentication method was acceptable.");
- return CURLPX_NO_AUTH;
- }
- }
- failf(data,
- "Undocumented SOCKS5 mode attempted to be used by server.");
- return CURLPX_UNKNOWN_MODE;
-#if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
- case CONNECT_GSSAPI_INIT:
- /* GSSAPI stuff done non-blocking */
- break;
-#endif
-
- default: /* do nothing! */
- break;
-
- CONNECT_AUTH_INIT:
- case CONNECT_AUTH_INIT: {
+ else {
+ /* error */
+ if(!allow_gssapi && (socksreq[1] == 1)) {
+ failf(data,
+ "SOCKS5 GSSAPI per-message authentication is not supported.");
+ return CURLPX_GSSAPI_PERMSG;
+ }
+ else if(socksreq[1] == 255) {
+ failf(data, "No authentication method was acceptable.");
+ return CURLPX_NO_AUTH;
+ }
+ }
+ failf(data,
+ "Undocumented SOCKS5 mode attempted to be used by server.");
+ return CURLPX_UNKNOWN_MODE;
+#if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
+ case CONNECT_GSSAPI_INIT:
+ /* GSSAPI stuff done non-blocking */
+ break;
+#endif
+
+ default: /* do nothing! */
+ break;
+
+ CONNECT_AUTH_INIT:
+ case CONNECT_AUTH_INIT: {
/* Needs user name and password */
size_t proxy_user_len, proxy_password_len;
if(proxy_user && proxy_password) {
@@ -686,7 +686,7 @@ CURLproxycode Curl_SOCKS5(const char *proxy_user,
/* the length must fit in a single byte */
if(proxy_user_len >= 255) {
failf(data, "Excessive user name length for proxy auth");
- return CURLPX_LONG_USER;
+ return CURLPX_LONG_USER;
}
memcpy(socksreq + len, proxy_user, proxy_user_len);
}
@@ -696,336 +696,336 @@ CURLproxycode Curl_SOCKS5(const char *proxy_user,
/* the length must fit in a single byte */
if(proxy_password_len > 255) {
failf(data, "Excessive password length for proxy auth");
- return CURLPX_LONG_PASSWD;
+ return CURLPX_LONG_PASSWD;
}
memcpy(socksreq + len, proxy_password, proxy_password_len);
}
len += proxy_password_len;
- sxstate(conn, CONNECT_AUTH_SEND);
- sx->outstanding = len;
- sx->outp = socksreq;
- }
- /* FALLTHROUGH */
- case CONNECT_AUTH_SEND:
- result = Curl_write_plain(conn, sockfd, (char *)sx->outp,
- sx->outstanding, &written);
- if(result && (CURLE_AGAIN != result)) {
+ sxstate(conn, CONNECT_AUTH_SEND);
+ sx->outstanding = len;
+ sx->outp = socksreq;
+ }
+ /* FALLTHROUGH */
+ case CONNECT_AUTH_SEND:
+ result = Curl_write_plain(conn, sockfd, (char *)sx->outp,
+ sx->outstanding, &written);
+ if(result && (CURLE_AGAIN != result)) {
failf(data, "Failed to send SOCKS5 sub-negotiation request.");
- return CURLPX_SEND_AUTH;
- }
- if(sx->outstanding != written) {
- /* remain in state */
- sx->outstanding -= written;
- sx->outp += written;
- return CURLPX_OK;
- }
- sx->outp = socksreq;
- sx->outstanding = 2;
- sxstate(conn, CONNECT_AUTH_READ);
- /* FALLTHROUGH */
- case CONNECT_AUTH_READ:
- result = Curl_read_plain(sockfd, (char *)sx->outp,
- sx->outstanding, &actualread);
- if(result && (CURLE_AGAIN != result)) {
+ return CURLPX_SEND_AUTH;
+ }
+ if(sx->outstanding != written) {
+ /* remain in state */
+ sx->outstanding -= written;
+ sx->outp += written;
+ return CURLPX_OK;
+ }
+ sx->outp = socksreq;
+ sx->outstanding = 2;
+ sxstate(conn, CONNECT_AUTH_READ);
+ /* FALLTHROUGH */
+ case CONNECT_AUTH_READ:
+ result = Curl_read_plain(sockfd, (char *)sx->outp,
+ sx->outstanding, &actualread);
+ if(result && (CURLE_AGAIN != result)) {
failf(data, "Unable to receive SOCKS5 sub-negotiation response.");
- return CURLPX_RECV_AUTH;
- }
- else if(!result && !actualread) {
- /* connection closed */
- failf(data, "connection to proxy closed");
- return CURLPX_CLOSED;
- }
- else if(actualread != sx->outstanding) {
- /* remain in state */
- sx->outstanding -= actualread;
- sx->outp += actualread;
- return CURLPX_OK;
- }
+ return CURLPX_RECV_AUTH;
+ }
+ else if(!result && !actualread) {
+ /* connection closed */
+ failf(data, "connection to proxy closed");
+ return CURLPX_CLOSED;
+ }
+ else if(actualread != sx->outstanding) {
+ /* remain in state */
+ sx->outstanding -= actualread;
+ sx->outp += actualread;
+ return CURLPX_OK;
+ }
/* ignore the first (VER) byte */
- else if(socksreq[1] != 0) { /* status */
+ else if(socksreq[1] != 0) { /* status */
failf(data, "User was rejected by the SOCKS5 server (%d %d).",
socksreq[0], socksreq[1]);
- return CURLPX_USER_REJECTED;
+ return CURLPX_USER_REJECTED;
}
/* Everything is good so far, user was authenticated! */
- sxstate(conn, CONNECT_REQ_INIT);
- /* FALLTHROUGH */
- CONNECT_REQ_INIT:
- case CONNECT_REQ_INIT:
- if(socks5_resolve_local) {
- enum resolve_t rc = Curl_resolv(conn, hostname, remote_port,
- FALSE, &dns);
-
- if(rc == CURLRESOLV_ERROR)
- return CURLPX_RESOLVE_HOST;
-
- if(rc == CURLRESOLV_PENDING) {
- sxstate(conn, CONNECT_RESOLVING);
- return CURLPX_OK;
+ sxstate(conn, CONNECT_REQ_INIT);
+ /* FALLTHROUGH */
+ CONNECT_REQ_INIT:
+ case CONNECT_REQ_INIT:
+ if(socks5_resolve_local) {
+ enum resolve_t rc = Curl_resolv(conn, hostname, remote_port,
+ FALSE, &dns);
+
+ if(rc == CURLRESOLV_ERROR)
+ return CURLPX_RESOLVE_HOST;
+
+ if(rc == CURLRESOLV_PENDING) {
+ sxstate(conn, CONNECT_RESOLVING);
+ return CURLPX_OK;
}
- sxstate(conn, CONNECT_RESOLVED);
- goto CONNECT_RESOLVED;
- }
- goto CONNECT_RESOLVE_REMOTE;
-
- case CONNECT_RESOLVING:
- /* check if we have the name resolved by now */
- dns = Curl_fetch_addr(conn, hostname, remote_port);
-
- if(dns) {
-#ifdef CURLRES_ASYNCH
- conn->async.dns = dns;
- conn->async.done = TRUE;
-#endif
- infof(data, "SOCKS5: hostname '%s' found\n", hostname);
- }
-
- if(!dns) {
- result = Curl_resolv_check(data->conn, &dns);
- if(!dns) {
- if(result)
- return CURLPX_RESOLVE_HOST;
- return CURLPX_OK;
- }
- }
- /* FALLTHROUGH */
- CONNECT_RESOLVED:
- case CONNECT_RESOLVED: {
- struct Curl_addrinfo *hp = NULL;
- size_t destlen;
+ sxstate(conn, CONNECT_RESOLVED);
+ goto CONNECT_RESOLVED;
+ }
+ goto CONNECT_RESOLVE_REMOTE;
+
+ case CONNECT_RESOLVING:
+ /* check if we have the name resolved by now */
+ dns = Curl_fetch_addr(conn, hostname, remote_port);
+
+ if(dns) {
+#ifdef CURLRES_ASYNCH
+ conn->async.dns = dns;
+ conn->async.done = TRUE;
+#endif
+ infof(data, "SOCKS5: hostname '%s' found\n", hostname);
+ }
+
+ if(!dns) {
+ result = Curl_resolv_check(data->conn, &dns);
+ if(!dns) {
+ if(result)
+ return CURLPX_RESOLVE_HOST;
+ return CURLPX_OK;
+ }
+ }
+ /* FALLTHROUGH */
+ CONNECT_RESOLVED:
+ case CONNECT_RESOLVED: {
+ struct Curl_addrinfo *hp = NULL;
+ size_t destlen;
if(dns)
hp = dns->addr;
- if(!hp) {
- failf(data, "Failed to resolve \"%s\" for SOCKS5 connect.",
- hostname);
- return CURLPX_RESOLVE_HOST;
- }
-
- Curl_printable_address(hp, dest, sizeof(dest));
- destlen = strlen(dest);
- msnprintf(dest + destlen, sizeof(dest) - destlen, ":%d", remote_port);
-
- len = 0;
- socksreq[len++] = 5; /* version (SOCKS5) */
- socksreq[len++] = 1; /* connect */
- socksreq[len++] = 0; /* must be zero */
- if(hp->ai_family == AF_INET) {
- int i;
- struct sockaddr_in *saddr_in;
- socksreq[len++] = 1; /* ATYP: IPv4 = 1 */
-
- saddr_in = (struct sockaddr_in *)(void *)hp->ai_addr;
- for(i = 0; i < 4; i++) {
- socksreq[len++] = ((unsigned char *)&saddr_in->sin_addr.s_addr)[i];
+ if(!hp) {
+ failf(data, "Failed to resolve \"%s\" for SOCKS5 connect.",
+ hostname);
+ return CURLPX_RESOLVE_HOST;
+ }
+
+ Curl_printable_address(hp, dest, sizeof(dest));
+ destlen = strlen(dest);
+ msnprintf(dest + destlen, sizeof(dest) - destlen, ":%d", remote_port);
+
+ len = 0;
+ socksreq[len++] = 5; /* version (SOCKS5) */
+ socksreq[len++] = 1; /* connect */
+ socksreq[len++] = 0; /* must be zero */
+ if(hp->ai_family == AF_INET) {
+ int i;
+ struct sockaddr_in *saddr_in;
+ socksreq[len++] = 1; /* ATYP: IPv4 = 1 */
+
+ saddr_in = (struct sockaddr_in *)(void *)hp->ai_addr;
+ for(i = 0; i < 4; i++) {
+ socksreq[len++] = ((unsigned char *)&saddr_in->sin_addr.s_addr)[i];
}
-
- infof(data, "SOCKS5 connect to IPv4 %s (locally resolved)\n", dest);
- }
+
+ infof(data, "SOCKS5 connect to IPv4 %s (locally resolved)\n", dest);
+ }
#ifdef ENABLE_IPV6
- else if(hp->ai_family == AF_INET6) {
- int i;
- struct sockaddr_in6 *saddr_in6;
- socksreq[len++] = 4; /* ATYP: IPv6 = 4 */
-
- saddr_in6 = (struct sockaddr_in6 *)(void *)hp->ai_addr;
- for(i = 0; i < 16; i++) {
- socksreq[len++] =
- ((unsigned char *)&saddr_in6->sin6_addr.s6_addr)[i];
+ else if(hp->ai_family == AF_INET6) {
+ int i;
+ struct sockaddr_in6 *saddr_in6;
+ socksreq[len++] = 4; /* ATYP: IPv6 = 4 */
+
+ saddr_in6 = (struct sockaddr_in6 *)(void *)hp->ai_addr;
+ for(i = 0; i < 16; i++) {
+ socksreq[len++] =
+ ((unsigned char *)&saddr_in6->sin6_addr.s6_addr)[i];
}
- infof(data, "SOCKS5 connect to IPv6 %s (locally resolved)\n", dest);
+ infof(data, "SOCKS5 connect to IPv6 %s (locally resolved)\n", dest);
}
-#endif
- else {
- hp = NULL; /* fail! */
- failf(data, "SOCKS5 connection to %s not supported\n", dest);
+#endif
+ else {
+ hp = NULL; /* fail! */
+ failf(data, "SOCKS5 connection to %s not supported\n", dest);
}
- Curl_resolv_unlock(data, dns); /* not used anymore from now on */
- goto CONNECT_REQ_SEND;
+ Curl_resolv_unlock(data, dns); /* not used anymore from now on */
+ goto CONNECT_REQ_SEND;
}
- CONNECT_RESOLVE_REMOTE:
- case CONNECT_RESOLVE_REMOTE:
- /* Authentication is complete, now specify destination to the proxy */
- len = 0;
- socksreq[len++] = 5; /* version (SOCKS5) */
- socksreq[len++] = 1; /* connect */
- socksreq[len++] = 0; /* must be zero */
-
- if(!socks5_resolve_local) {
- socksreq[len++] = 3; /* ATYP: domain name = 3 */
- socksreq[len++] = (char) hostname_len; /* one byte address length */
- memcpy(&socksreq[len], hostname, hostname_len); /* address w/o NULL */
- len += hostname_len;
- infof(data, "SOCKS5 connect to %s:%d (remotely resolved)\n",
- hostname, remote_port);
- }
- /* FALLTHROUGH */
-
- CONNECT_REQ_SEND:
- case CONNECT_REQ_SEND:
- /* PORT MSB */
- socksreq[len++] = (unsigned char)((remote_port >> 8) & 0xff);
- /* PORT LSB */
- socksreq[len++] = (unsigned char)(remote_port & 0xff);
+ CONNECT_RESOLVE_REMOTE:
+ case CONNECT_RESOLVE_REMOTE:
+ /* Authentication is complete, now specify destination to the proxy */
+ len = 0;
+ socksreq[len++] = 5; /* version (SOCKS5) */
+ socksreq[len++] = 1; /* connect */
+ socksreq[len++] = 0; /* must be zero */
+ if(!socks5_resolve_local) {
+ socksreq[len++] = 3; /* ATYP: domain name = 3 */
+ socksreq[len++] = (char) hostname_len; /* one byte address length */
+ memcpy(&socksreq[len], hostname, hostname_len); /* address w/o NULL */
+ len += hostname_len;
+ infof(data, "SOCKS5 connect to %s:%d (remotely resolved)\n",
+ hostname, remote_port);
+ }
+ /* FALLTHROUGH */
+
+ CONNECT_REQ_SEND:
+ case CONNECT_REQ_SEND:
+ /* PORT MSB */
+ socksreq[len++] = (unsigned char)((remote_port >> 8) & 0xff);
+ /* PORT LSB */
+ socksreq[len++] = (unsigned char)(remote_port & 0xff);
+
+#if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
+ if(conn->socks5_gssapi_enctype) {
+ failf(data, "SOCKS5 GSS-API protection not yet implemented.");
+ return CURLPX_GSSAPI_PROTECTION;
+ }
+#endif
+ sx->outp = socksreq;
+ sx->outstanding = len;
+ sxstate(conn, CONNECT_REQ_SENDING);
+ /* FALLTHROUGH */
+ case CONNECT_REQ_SENDING:
+ result = Curl_write_plain(conn, sockfd, (char *)sx->outp,
+ sx->outstanding, &written);
+ if(result && (CURLE_AGAIN != result)) {
+ failf(data, "Failed to send SOCKS5 connect request.");
+ return CURLPX_SEND_REQUEST;
+ }
+ if(sx->outstanding != written) {
+ /* remain in state */
+ sx->outstanding -= written;
+ sx->outp += written;
+ return CURLPX_OK;
+ }
#if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
- if(conn->socks5_gssapi_enctype) {
- failf(data, "SOCKS5 GSS-API protection not yet implemented.");
- return CURLPX_GSSAPI_PROTECTION;
- }
+ if(conn->socks5_gssapi_enctype) {
+ failf(data, "SOCKS5 GSS-API protection not yet implemented.");
+ return CURLPX_GSSAPI_PROTECTION;
+ }
#endif
- sx->outp = socksreq;
- sx->outstanding = len;
- sxstate(conn, CONNECT_REQ_SENDING);
- /* FALLTHROUGH */
- case CONNECT_REQ_SENDING:
- result = Curl_write_plain(conn, sockfd, (char *)sx->outp,
- sx->outstanding, &written);
- if(result && (CURLE_AGAIN != result)) {
- failf(data, "Failed to send SOCKS5 connect request.");
- return CURLPX_SEND_REQUEST;
- }
- if(sx->outstanding != written) {
- /* remain in state */
- sx->outstanding -= written;
- sx->outp += written;
- return CURLPX_OK;
- }
-#if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
- if(conn->socks5_gssapi_enctype) {
- failf(data, "SOCKS5 GSS-API protection not yet implemented.");
- return CURLPX_GSSAPI_PROTECTION;
- }
-#endif
- sx->outstanding = 10; /* minimum packet size is 10 */
- sx->outp = socksreq;
- sxstate(conn, CONNECT_REQ_READ);
- /* FALLTHROUGH */
- case CONNECT_REQ_READ:
- result = Curl_read_plain(sockfd, (char *)sx->outp,
- sx->outstanding, &actualread);
- if(result && (CURLE_AGAIN != result)) {
- failf(data, "Failed to receive SOCKS5 connect request ack.");
- return CURLPX_RECV_REQACK;
- }
- else if(!result && !actualread) {
- /* connection closed */
- failf(data, "connection to proxy closed");
- return CURLPX_CLOSED;
- }
- else if(actualread != sx->outstanding) {
- /* remain in state */
- sx->outstanding -= actualread;
- sx->outp += actualread;
- return CURLPX_OK;
- }
-
- if(socksreq[0] != 5) { /* version */
- failf(data,
- "SOCKS5 reply has wrong version, version should be 5.");
- return CURLPX_BAD_VERSION;
- }
- else if(socksreq[1] != 0) { /* Anything besides 0 is an error */
- CURLproxycode rc = CURLPX_REPLY_UNASSIGNED;
- int code = socksreq[1];
- failf(data, "Can't complete SOCKS5 connection to %s. (%d)",
- hostname, (unsigned char)socksreq[1]);
- if(code < 9) {
- /* RFC 1928 section 6 lists: */
- static const CURLproxycode lookup[] = {
- CURLPX_OK,
- CURLPX_REPLY_GENERAL_SERVER_FAILURE,
- CURLPX_REPLY_NOT_ALLOWED,
- CURLPX_REPLY_NETWORK_UNREACHABLE,
- CURLPX_REPLY_HOST_UNREACHABLE,
- CURLPX_REPLY_CONNECTION_REFUSED,
- CURLPX_REPLY_TTL_EXPIRED,
- CURLPX_REPLY_COMMAND_NOT_SUPPORTED,
- CURLPX_REPLY_ADDRESS_TYPE_NOT_SUPPORTED,
- };
- rc = lookup[code];
- }
- return rc;
- }
-
- /* Fix: in general, returned BND.ADDR is variable length parameter by RFC
- 1928, so the reply packet should be read until the end to avoid errors
- at subsequent protocol level.
-
- +----+-----+-------+------+----------+----------+
- |VER | REP | RSV | ATYP | BND.ADDR | BND.PORT |
- +----+-----+-------+------+----------+----------+
- | 1 | 1 | X'00' | 1 | Variable | 2 |
- +----+-----+-------+------+----------+----------+
-
- ATYP:
- o IP v4 address: X'01', BND.ADDR = 4 byte
- o domain name: X'03', BND.ADDR = [ 1 byte length, string ]
- o IP v6 address: X'04', BND.ADDR = 16 byte
- */
-
- /* Calculate real packet size */
- if(socksreq[3] == 3) {
- /* domain name */
- int addrlen = (int) socksreq[4];
- len = 5 + addrlen + 2;
- }
- else if(socksreq[3] == 4) {
- /* IPv6 */
- len = 4 + 16 + 2;
- }
- else if(socksreq[3] == 1) {
- len = 4 + 4 + 2;
- }
- else {
- failf(data, "SOCKS5 reply has wrong address type.");
- return CURLPX_BAD_ADDRESS_TYPE;
- }
-
- /* At this point we already read first 10 bytes */
+ sx->outstanding = 10; /* minimum packet size is 10 */
+ sx->outp = socksreq;
+ sxstate(conn, CONNECT_REQ_READ);
+ /* FALLTHROUGH */
+ case CONNECT_REQ_READ:
+ result = Curl_read_plain(sockfd, (char *)sx->outp,
+ sx->outstanding, &actualread);
+ if(result && (CURLE_AGAIN != result)) {
+ failf(data, "Failed to receive SOCKS5 connect request ack.");
+ return CURLPX_RECV_REQACK;
+ }
+ else if(!result && !actualread) {
+ /* connection closed */
+ failf(data, "connection to proxy closed");
+ return CURLPX_CLOSED;
+ }
+ else if(actualread != sx->outstanding) {
+ /* remain in state */
+ sx->outstanding -= actualread;
+ sx->outp += actualread;
+ return CURLPX_OK;
+ }
+
+ if(socksreq[0] != 5) { /* version */
+ failf(data,
+ "SOCKS5 reply has wrong version, version should be 5.");
+ return CURLPX_BAD_VERSION;
+ }
+ else if(socksreq[1] != 0) { /* Anything besides 0 is an error */
+ CURLproxycode rc = CURLPX_REPLY_UNASSIGNED;
+ int code = socksreq[1];
+ failf(data, "Can't complete SOCKS5 connection to %s. (%d)",
+ hostname, (unsigned char)socksreq[1]);
+ if(code < 9) {
+ /* RFC 1928 section 6 lists: */
+ static const CURLproxycode lookup[] = {
+ CURLPX_OK,
+ CURLPX_REPLY_GENERAL_SERVER_FAILURE,
+ CURLPX_REPLY_NOT_ALLOWED,
+ CURLPX_REPLY_NETWORK_UNREACHABLE,
+ CURLPX_REPLY_HOST_UNREACHABLE,
+ CURLPX_REPLY_CONNECTION_REFUSED,
+ CURLPX_REPLY_TTL_EXPIRED,
+ CURLPX_REPLY_COMMAND_NOT_SUPPORTED,
+ CURLPX_REPLY_ADDRESS_TYPE_NOT_SUPPORTED,
+ };
+ rc = lookup[code];
+ }
+ return rc;
+ }
+
+ /* Fix: in general, returned BND.ADDR is variable length parameter by RFC
+ 1928, so the reply packet should be read until the end to avoid errors
+ at subsequent protocol level.
+
+ +----+-----+-------+------+----------+----------+
+ |VER | REP | RSV | ATYP | BND.ADDR | BND.PORT |
+ +----+-----+-------+------+----------+----------+
+ | 1 | 1 | X'00' | 1 | Variable | 2 |
+ +----+-----+-------+------+----------+----------+
+
+ ATYP:
+ o IP v4 address: X'01', BND.ADDR = 4 byte
+ o domain name: X'03', BND.ADDR = [ 1 byte length, string ]
+ o IP v6 address: X'04', BND.ADDR = 16 byte
+ */
+
+ /* Calculate real packet size */
+ if(socksreq[3] == 3) {
+ /* domain name */
+ int addrlen = (int) socksreq[4];
+ len = 5 + addrlen + 2;
+ }
+ else if(socksreq[3] == 4) {
+ /* IPv6 */
+ len = 4 + 16 + 2;
+ }
+ else if(socksreq[3] == 1) {
+ len = 4 + 4 + 2;
+ }
+ else {
+ failf(data, "SOCKS5 reply has wrong address type.");
+ return CURLPX_BAD_ADDRESS_TYPE;
+ }
+
+ /* At this point we already read first 10 bytes */
#if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
- if(!conn->socks5_gssapi_enctype) {
- /* decrypt_gssapi_blockread already read the whole packet */
+ if(!conn->socks5_gssapi_enctype) {
+ /* decrypt_gssapi_blockread already read the whole packet */
#endif
- if(len > 10) {
- sx->outstanding = len - 10; /* get the rest */
- sx->outp = &socksreq[10];
- sxstate(conn, CONNECT_REQ_READ_MORE);
+ if(len > 10) {
+ sx->outstanding = len - 10; /* get the rest */
+ sx->outp = &socksreq[10];
+ sxstate(conn, CONNECT_REQ_READ_MORE);
+ }
+ else {
+ sxstate(conn, CONNECT_DONE);
+ break;
}
- else {
- sxstate(conn, CONNECT_DONE);
- break;
- }
-#if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
+#if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
}
#endif
- /* FALLTHROUGH */
- case CONNECT_REQ_READ_MORE:
- result = Curl_read_plain(sockfd, (char *)sx->outp,
- sx->outstanding, &actualread);
- if(result && (CURLE_AGAIN != result)) {
- failf(data, "Failed to receive SOCKS5 connect request ack.");
- return CURLPX_RECV_ADDRESS;
- }
- else if(!result && !actualread) {
- /* connection closed */
- failf(data, "connection to proxy closed");
- return CURLPX_CLOSED;
- }
- else if(actualread != sx->outstanding) {
- /* remain in state */
- sx->outstanding -= actualread;
- sx->outp += actualread;
- return CURLPX_OK;
- }
- sxstate(conn, CONNECT_DONE);
+ /* FALLTHROUGH */
+ case CONNECT_REQ_READ_MORE:
+ result = Curl_read_plain(sockfd, (char *)sx->outp,
+ sx->outstanding, &actualread);
+ if(result && (CURLE_AGAIN != result)) {
+ failf(data, "Failed to receive SOCKS5 connect request ack.");
+ return CURLPX_RECV_ADDRESS;
+ }
+ else if(!result && !actualread) {
+ /* connection closed */
+ failf(data, "connection to proxy closed");
+ return CURLPX_CLOSED;
+ }
+ else if(actualread != sx->outstanding) {
+ /* remain in state */
+ sx->outstanding -= actualread;
+ sx->outp += actualread;
+ return CURLPX_OK;
+ }
+ sxstate(conn, CONNECT_DONE);
}
infof(data, "SOCKS5 request granted.\n");
- *done = TRUE;
- return CURLPX_OK; /* Proxy was successful! */
+ *done = TRUE;
+ return CURLPX_OK; /* Proxy was successful! */
}
#endif /* CURL_DISABLE_PROXY */
diff --git a/contrib/libs/curl/lib/socks.h b/contrib/libs/curl/lib/socks.h
index c23175e722..1fae58b6fa 100644
--- a/contrib/libs/curl/lib/socks.h
+++ b/contrib/libs/curl/lib/socks.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -27,13 +27,13 @@
#ifdef CURL_DISABLE_PROXY
#define Curl_SOCKS4(a,b,c,d,e) CURLE_NOT_BUILT_IN
#define Curl_SOCKS5(a,b,c,d,e,f) CURLE_NOT_BUILT_IN
-#define Curl_SOCKS_getsock(x,y,z) 0
+#define Curl_SOCKS_getsock(x,y,z) 0
#else
/*
* Helper read-from-socket functions. Does the same as Curl_read() but it
* blocks until all bytes amount of buffersize will be read. No more, no less.
*
- * This is STUPID BLOCKING behavior
+ * This is STUPID BLOCKING behavior
*/
int Curl_blockread_all(struct connectdata *conn,
curl_socket_t sockfd,
@@ -41,31 +41,31 @@ int Curl_blockread_all(struct connectdata *conn,
ssize_t buffersize,
ssize_t *n);
-int Curl_SOCKS_getsock(struct connectdata *conn,
- curl_socket_t *sock,
- int sockindex);
+int Curl_SOCKS_getsock(struct connectdata *conn,
+ curl_socket_t *sock,
+ int sockindex);
/*
* This function logs in to a SOCKS4(a) proxy and sends the specifics to the
* final destination server.
*/
-CURLproxycode Curl_SOCKS4(const char *proxy_name,
- const char *hostname,
- int remote_port,
- int sockindex,
- struct connectdata *conn,
- bool *done);
+CURLproxycode Curl_SOCKS4(const char *proxy_name,
+ const char *hostname,
+ int remote_port,
+ int sockindex,
+ struct connectdata *conn,
+ bool *done);
/*
* This function logs in to a SOCKS5 proxy and sends the specifics to the
* final destination server.
*/
-CURLproxycode Curl_SOCKS5(const char *proxy_name,
- const char *proxy_password,
- const char *hostname,
- int remote_port,
- int sockindex,
- struct connectdata *conn,
- bool *done);
+CURLproxycode Curl_SOCKS5(const char *proxy_name,
+ const char *proxy_password,
+ const char *hostname,
+ int remote_port,
+ int sockindex,
+ struct connectdata *conn,
+ bool *done);
#if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
/*
diff --git a/contrib/libs/curl/lib/socks_gssapi.c b/contrib/libs/curl/lib/socks_gssapi.c
index c7ec4b0a43..a96579692b 100644
--- a/contrib/libs/curl/lib/socks_gssapi.c
+++ b/contrib/libs/curl/lib/socks_gssapi.c
@@ -5,12 +5,12 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 2012 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2012 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 2009, Markus Moeller, <markus_moeller@compuserve.com>
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -115,7 +115,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
gss_buffer_desc gss_send_token = GSS_C_EMPTY_BUFFER;
gss_buffer_desc gss_recv_token = GSS_C_EMPTY_BUFFER;
gss_buffer_desc gss_w_token = GSS_C_EMPTY_BUFFER;
- gss_buffer_desc *gss_token = GSS_C_NO_BUFFER;
+ gss_buffer_desc *gss_token = GSS_C_NO_BUFFER;
gss_name_t server = GSS_C_NO_NAME;
gss_name_t gss_client_name = GSS_C_NO_NAME;
unsigned short us_length;
@@ -167,8 +167,8 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
return CURLE_COULDNT_CONNECT;
}
- (void)curlx_nonblock(sock, FALSE);
-
+ (void)curlx_nonblock(sock, FALSE);
+
/* As long as we need to keep sending some context info, and there's no */
/* errors, keep sending it... */
for(;;) {
@@ -227,8 +227,8 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
gss_release_buffer(&gss_status, &gss_send_token);
gss_release_buffer(&gss_status, &gss_recv_token);
- if(gss_major_status != GSS_S_CONTINUE_NEEDED)
- break;
+ if(gss_major_status != GSS_S_CONTINUE_NEEDED)
+ break;
/* analyse response */
@@ -328,7 +328,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
user[gss_send_token.length] = '\0';
gss_release_name(&gss_status, &gss_client_name);
gss_release_buffer(&gss_status, &gss_send_token);
- infof(data, "SOCKS5 server authenticated user %s with GSS-API.\n",user);
+ infof(data, "SOCKS5 server authenticated user %s with GSS-API.\n",user);
free(user);
user = NULL;
@@ -493,7 +493,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
gss_release_buffer(&gss_status, &gss_recv_token);
if(gss_w_token.length != 1) {
- failf(data, "Invalid GSS-API encryption response length (%zu).",
+ failf(data, "Invalid GSS-API encryption response length (%zu).",
gss_w_token.length);
gss_release_buffer(&gss_status, &gss_w_token);
gss_delete_sec_context(&gss_status, &gss_context, NULL);
@@ -505,7 +505,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
}
else {
if(gss_recv_token.length != 1) {
- failf(data, "Invalid GSS-API encryption response length (%zu).",
+ failf(data, "Invalid GSS-API encryption response length (%zu).",
gss_recv_token.length);
gss_release_buffer(&gss_status, &gss_recv_token);
gss_delete_sec_context(&gss_status, &gss_context, NULL);
@@ -516,8 +516,8 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
gss_release_buffer(&gss_status, &gss_recv_token);
}
- (void)curlx_nonblock(sock, TRUE);
-
+ (void)curlx_nonblock(sock, TRUE);
+
infof(data, "SOCKS5 access with%s protection granted.\n",
(socksreq[0] == 0)?"out GSS-API data":
((socksreq[0] == 1)?" GSS-API integrity":" GSS-API confidentiality"));
diff --git a/contrib/libs/curl/lib/socks_sspi.c b/contrib/libs/curl/lib/socks_sspi.c
index 7f35acb27d..b9ac2ade8e 100644
--- a/contrib/libs/curl/lib/socks_sspi.c
+++ b/contrib/libs/curl/lib/socks_sspi.c
@@ -5,12 +5,12 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 2012 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2012 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 2009, 2011, Markus Moeller, <markus_moeller@compuserve.com>
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -153,14 +153,14 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
return CURLE_COULDNT_CONNECT;
}
- (void)curlx_nonblock(sock, FALSE);
-
+ (void)curlx_nonblock(sock, FALSE);
+
/* As long as we need to keep sending some context info, and there's no */
/* errors, keep sending it... */
for(;;) {
TCHAR *sname;
- sname = curlx_convert_UTF8_to_tchar(service_name);
+ sname = curlx_convert_UTF8_to_tchar(service_name);
if(!sname)
return CURLE_OUT_OF_MEMORY;
@@ -180,7 +180,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
&sspi_ret_flags,
&expiry);
- curlx_unicodefree(sname);
+ curlx_unicodefree(sname);
if(sspi_recv_token.pvBuffer) {
s_pSecFn->FreeContextBuffer(sspi_recv_token.pvBuffer);
@@ -327,7 +327,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
failf(data, "Failed to determine user name.");
return CURLE_COULDNT_CONNECT;
}
- infof(data, "SOCKS5 server authenticated user %s with GSS-API.\n",
+ infof(data, "SOCKS5 server authenticated user %s with GSS-API.\n",
names.sUserName);
s_pSecFn->FreeContextBuffer(names.sUserName);
@@ -589,7 +589,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
memcpy(socksreq, sspi_w_token[0].pvBuffer, sspi_w_token[0].cbBuffer);
s_pSecFn->FreeContextBuffer(sspi_w_token[0].pvBuffer);
}
- (void)curlx_nonblock(sock, TRUE);
+ (void)curlx_nonblock(sock, TRUE);
infof(data, "SOCKS5 access with%s protection granted.\n",
(socksreq[0] == 0)?"out GSS-API data":
diff --git a/contrib/libs/curl/lib/speedcheck.c b/contrib/libs/curl/lib/speedcheck.c
index b4754d4ca3..2665a44c55 100644
--- a/contrib/libs/curl/lib/speedcheck.c
+++ b/contrib/libs/curl/lib/speedcheck.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/speedcheck.h b/contrib/libs/curl/lib/speedcheck.h
index ca6e6cdefe..1d4c7bfeff 100644
--- a/contrib/libs/curl/lib/speedcheck.h
+++ b/contrib/libs/curl/lib/speedcheck.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/splay.c b/contrib/libs/curl/lib/splay.c
index 9a6c1076e8..98baf5d871 100644
--- a/contrib/libs/curl/lib/splay.c
+++ b/contrib/libs/curl/lib/splay.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1997 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1997 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -206,9 +206,9 @@ struct Curl_tree *Curl_splaygetbest(struct curltime i,
*
* @unittest: 1309
*/
-int Curl_splayremove(struct Curl_tree *t,
- struct Curl_tree *removenode,
- struct Curl_tree **newroot)
+int Curl_splayremove(struct Curl_tree *t,
+ struct Curl_tree *removenode,
+ struct Curl_tree **newroot)
{
static const struct curltime KEY_NOTUSED = {
(time_t)-1, (unsigned int)-1
diff --git a/contrib/libs/curl/lib/splay.h b/contrib/libs/curl/lib/splay.h
index 390662e941..eb9f65f1e0 100644
--- a/contrib/libs/curl/lib/splay.h
+++ b/contrib/libs/curl/lib/splay.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1997 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1997 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -44,9 +44,9 @@ struct Curl_tree *Curl_splaygetbest(struct curltime key,
struct Curl_tree *t,
struct Curl_tree **removed);
-int Curl_splayremove(struct Curl_tree *t,
- struct Curl_tree *removenode,
- struct Curl_tree **newroot);
+int Curl_splayremove(struct Curl_tree *t,
+ struct Curl_tree *removenode,
+ struct Curl_tree **newroot);
#define Curl_splaycomparekeys(i,j) ( ((i.tv_sec) < (j.tv_sec)) ? -1 : \
( ((i.tv_sec) > (j.tv_sec)) ? 1 : \
diff --git a/contrib/libs/curl/lib/strcase.c b/contrib/libs/curl/lib/strcase.c
index 4c6a62a49b..955e3c79ea 100644
--- a/contrib/libs/curl/lib/strcase.c
+++ b/contrib/libs/curl/lib/strcase.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -26,8 +26,8 @@
#include "strcase.h"
-static char raw_tolower(char in);
-
+static char raw_tolower(char in);
+
/* Portable, consistent toupper (remember EBCDIC). Do not use toupper() because
its behavior is altered by the current locale. */
char Curl_raw_toupper(char in)
@@ -95,75 +95,75 @@ char Curl_raw_toupper(char in)
return in;
}
-
-/* Portable, consistent tolower (remember EBCDIC). Do not use tolower() because
- its behavior is altered by the current locale. */
-static char raw_tolower(char in)
-{
-#if !defined(CURL_DOES_CONVERSIONS)
- if(in >= 'A' && in <= 'Z')
- return (char)('a' + in - 'A');
-#else
- switch(in) {
- case 'A':
- return 'a';
- case 'B':
- return 'b';
- case 'C':
- return 'c';
- case 'D':
- return 'd';
- case 'E':
- return 'e';
- case 'F':
- return 'f';
- case 'G':
- return 'g';
- case 'H':
- return 'h';
- case 'I':
- return 'i';
- case 'J':
- return 'j';
- case 'K':
- return 'k';
- case 'L':
- return 'l';
- case 'M':
- return 'm';
- case 'N':
- return 'n';
- case 'O':
- return 'o';
- case 'P':
- return 'p';
- case 'Q':
- return 'q';
- case 'R':
- return 'r';
- case 'S':
- return 's';
- case 'T':
- return 't';
- case 'U':
- return 'u';
- case 'V':
- return 'v';
- case 'W':
- return 'w';
- case 'X':
- return 'x';
- case 'Y':
- return 'y';
- case 'Z':
- return 'z';
- }
-#endif
-
- return in;
-}
-
-
+
+/* Portable, consistent tolower (remember EBCDIC). Do not use tolower() because
+ its behavior is altered by the current locale. */
+static char raw_tolower(char in)
+{
+#if !defined(CURL_DOES_CONVERSIONS)
+ if(in >= 'A' && in <= 'Z')
+ return (char)('a' + in - 'A');
+#else
+ switch(in) {
+ case 'A':
+ return 'a';
+ case 'B':
+ return 'b';
+ case 'C':
+ return 'c';
+ case 'D':
+ return 'd';
+ case 'E':
+ return 'e';
+ case 'F':
+ return 'f';
+ case 'G':
+ return 'g';
+ case 'H':
+ return 'h';
+ case 'I':
+ return 'i';
+ case 'J':
+ return 'j';
+ case 'K':
+ return 'k';
+ case 'L':
+ return 'l';
+ case 'M':
+ return 'm';
+ case 'N':
+ return 'n';
+ case 'O':
+ return 'o';
+ case 'P':
+ return 'p';
+ case 'Q':
+ return 'q';
+ case 'R':
+ return 'r';
+ case 'S':
+ return 's';
+ case 'T':
+ return 't';
+ case 'U':
+ return 'u';
+ case 'V':
+ return 'v';
+ case 'W':
+ return 'w';
+ case 'X':
+ return 'x';
+ case 'Y':
+ return 'y';
+ case 'Z':
+ return 'z';
+ }
+#endif
+
+ return in;
+}
+
+
/*
* Curl_strcasecompare() is for doing "raw" case insensitive strings. This is
* meant to be locale independent and only compare strings we know are safe
@@ -236,21 +236,21 @@ void Curl_strntoupper(char *dest, const char *src, size_t n)
} while(*src++ && --n);
}
-/* Copy a lower case version of the string from src to dest. The
- * strings may overlap. No more than n characters of the string are copied
- * (including any NUL) and the destination string will NOT be
- * NUL-terminated if that limit is reached.
- */
-void Curl_strntolower(char *dest, const char *src, size_t n)
-{
- if(n < 1)
- return;
-
- do {
- *dest++ = raw_tolower(*src);
- } while(*src++ && --n);
-}
-
+/* Copy a lower case version of the string from src to dest. The
+ * strings may overlap. No more than n characters of the string are copied
+ * (including any NUL) and the destination string will NOT be
+ * NUL-terminated if that limit is reached.
+ */
+void Curl_strntolower(char *dest, const char *src, size_t n)
+{
+ if(n < 1)
+ return;
+
+ do {
+ *dest++ = raw_tolower(*src);
+ } while(*src++ && --n);
+}
+
/* --- public functions --- */
int curl_strequal(const char *first, const char *second)
diff --git a/contrib/libs/curl/lib/strcase.h b/contrib/libs/curl/lib/strcase.h
index 0a8cc5348d..10dc698817 100644
--- a/contrib/libs/curl/lib/strcase.h
+++ b/contrib/libs/curl/lib/strcase.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -46,6 +46,6 @@ char Curl_raw_toupper(char in);
#define checkprefix(a,b) curl_strnequal(a,b,strlen(a))
void Curl_strntoupper(char *dest, const char *src, size_t n);
-void Curl_strntolower(char *dest, const char *src, size_t n);
+void Curl_strntolower(char *dest, const char *src, size_t n);
#endif /* HEADER_CURL_STRCASE_H */
diff --git a/contrib/libs/curl/lib/strdup.c b/contrib/libs/curl/lib/strdup.c
index cd47909ade..9af47ea473 100644
--- a/contrib/libs/curl/lib/strdup.c
+++ b/contrib/libs/curl/lib/strdup.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -39,13 +39,13 @@ char *curlx_strdup(const char *str)
if(!str)
return (char *)NULL;
- len = strlen(str) + 1;
+ len = strlen(str) + 1;
- newstr = malloc(len);
+ newstr = malloc(len);
if(!newstr)
return (char *)NULL;
- memcpy(newstr, str, len);
+ memcpy(newstr, str, len);
return newstr;
}
#endif
diff --git a/contrib/libs/curl/lib/strdup.h b/contrib/libs/curl/lib/strdup.h
index fab4ff3587..0936956f89 100644
--- a/contrib/libs/curl/lib/strdup.h
+++ b/contrib/libs/curl/lib/strdup.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/strerror.c b/contrib/libs/curl/lib/strerror.c
index cb514962e0..1751fd38f5 100644
--- a/contrib/libs/curl/lib/strerror.c
+++ b/contrib/libs/curl/lib/strerror.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 2004 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2004 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -314,15 +314,15 @@ curl_easy_strerror(CURLcode error)
case CURLE_AUTH_ERROR:
return "An authentication function returned an error";
- case CURLE_HTTP3:
- return "HTTP/3 error";
-
- case CURLE_QUIC_CONNECT_ERROR:
- return "QUIC connection error";
-
- case CURLE_PROXY:
- return "proxy handshake error";
-
+ case CURLE_HTTP3:
+ return "HTTP/3 error";
+
+ case CURLE_QUIC_CONNECT_ERROR:
+ return "QUIC connection error";
+
+ case CURLE_PROXY:
+ return "proxy handshake error";
+
/* error codes not used by current libcurl */
case CURLE_OBSOLETE20:
case CURLE_OBSOLETE24:
@@ -395,12 +395,12 @@ curl_multi_strerror(CURLMcode error)
case CURLM_RECURSIVE_API_CALL:
return "API function called from within callback";
- case CURLM_WAKEUP_FAILURE:
- return "Wakeup is unavailable or failed";
-
- case CURLM_BAD_FUNCTION_ARGUMENT:
- return "A libcurl function was given a bad argument";
-
+ case CURLM_WAKEUP_FAILURE:
+ return "Wakeup is unavailable or failed";
+
+ case CURLM_BAD_FUNCTION_ARGUMENT:
+ return "A libcurl function was given a bad argument";
+
case CURLM_LAST:
break;
}
@@ -451,26 +451,26 @@ curl_share_strerror(CURLSHcode error)
}
#ifdef USE_WINSOCK
-/* This is a helper function for Curl_strerror that converts Winsock error
- * codes (WSAGetLastError) to error messages.
- * Returns NULL if no error message was found for error code.
+/* This is a helper function for Curl_strerror that converts Winsock error
+ * codes (WSAGetLastError) to error messages.
+ * Returns NULL if no error message was found for error code.
*/
static const char *
get_winsock_error (int err, char *buf, size_t len)
{
-#ifndef CURL_DISABLE_VERBOSE_STRINGS
- const char *p;
+#ifndef CURL_DISABLE_VERBOSE_STRINGS
+ const char *p;
#endif
- if(!len)
- return NULL;
-
- *buf = '\0';
-
-#ifdef CURL_DISABLE_VERBOSE_STRINGS
- (void)err;
- return NULL;
-#else
+ if(!len)
+ return NULL;
+
+ *buf = '\0';
+
+#ifdef CURL_DISABLE_VERBOSE_STRINGS
+ (void)err;
+ return NULL;
+#else
switch(err) {
case WSAEINTR:
p = "Call interrupted";
@@ -641,54 +641,54 @@ get_winsock_error (int err, char *buf, size_t len)
}
strncpy(buf, p, len);
buf [len-1] = '\0';
- return buf;
-#endif
-}
-#endif /* USE_WINSOCK */
-
-#if defined(WIN32) || defined(_WIN32_WCE)
-/* This is a helper function for Curl_strerror that converts Windows API error
- * codes (GetLastError) to error messages.
- * Returns NULL if no error message was found for error code.
- */
-static const char *
-get_winapi_error(int err, char *buf, size_t buflen)
-{
- char *p;
- wchar_t wbuf[256];
-
- if(!buflen)
- return NULL;
-
- *buf = '\0';
- *wbuf = L'\0';
-
- /* We return the local codepage version of the error string because if it is
- output to the user's terminal it will likely be with functions which
- expect the local codepage (eg fprintf, failf, infof).
- FormatMessageW -> wcstombs is used for Windows CE compatibility. */
- if(FormatMessageW((FORMAT_MESSAGE_FROM_SYSTEM |
- FORMAT_MESSAGE_IGNORE_INSERTS), NULL, err,
- LANG_NEUTRAL, wbuf, sizeof(wbuf)/sizeof(wchar_t), NULL)) {
- size_t written = wcstombs(buf, wbuf, buflen - 1);
- if(written != (size_t)-1)
- buf[written] = '\0';
- else
- *buf = '\0';
- }
-
- /* Truncate multiple lines */
- p = strchr(buf, '\n');
- if(p) {
- if(p > buf && *(p-1) == '\r')
- *(p-1) = '\0';
- else
- *p = '\0';
- }
-
- return (*buf ? buf : NULL);
+ return buf;
+#endif
+}
+#endif /* USE_WINSOCK */
+
+#if defined(WIN32) || defined(_WIN32_WCE)
+/* This is a helper function for Curl_strerror that converts Windows API error
+ * codes (GetLastError) to error messages.
+ * Returns NULL if no error message was found for error code.
+ */
+static const char *
+get_winapi_error(int err, char *buf, size_t buflen)
+{
+ char *p;
+ wchar_t wbuf[256];
+
+ if(!buflen)
+ return NULL;
+
+ *buf = '\0';
+ *wbuf = L'\0';
+
+ /* We return the local codepage version of the error string because if it is
+ output to the user's terminal it will likely be with functions which
+ expect the local codepage (eg fprintf, failf, infof).
+ FormatMessageW -> wcstombs is used for Windows CE compatibility. */
+ if(FormatMessageW((FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS), NULL, err,
+ LANG_NEUTRAL, wbuf, sizeof(wbuf)/sizeof(wchar_t), NULL)) {
+ size_t written = wcstombs(buf, wbuf, buflen - 1);
+ if(written != (size_t)-1)
+ buf[written] = '\0';
+ else
+ *buf = '\0';
+ }
+
+ /* Truncate multiple lines */
+ p = strchr(buf, '\n');
+ if(p) {
+ if(p > buf && *(p-1) == '\r')
+ *(p-1) = '\0';
+ else
+ *p = '\0';
+ }
+
+ return (*buf ? buf : NULL);
}
-#endif /* WIN32 || _WIN32_WCE */
+#endif /* WIN32 || _WIN32_WCE */
/*
* Our thread-safe and smart strerror() replacement.
@@ -700,14 +700,14 @@ get_winapi_error(int err, char *buf, size_t buflen)
*
* We don't do range checking (on systems other than Windows) since there is
* no good reliable and portable way to do it.
- *
- * On Windows different types of error codes overlap. This function has an
- * order of preference when trying to match error codes:
- * CRT (errno), Winsock (WSAGetLastError), Windows API (GetLastError).
- *
- * It may be more correct to call one of the variant functions instead:
- * Call Curl_sspi_strerror if the error code is definitely Windows SSPI.
- * Call Curl_winapi_strerror if the error code is definitely Windows API.
+ *
+ * On Windows different types of error codes overlap. This function has an
+ * order of preference when trying to match error codes:
+ * CRT (errno), Winsock (WSAGetLastError), Windows API (GetLastError).
+ *
+ * It may be more correct to call one of the variant functions instead:
+ * Call Curl_sspi_strerror if the error code is definitely Windows SSPI.
+ * Call Curl_winapi_strerror if the error code is definitely Windows API.
*/
const char *Curl_strerror(int err, char *buf, size_t buflen)
{
@@ -718,30 +718,30 @@ const char *Curl_strerror(int err, char *buf, size_t buflen)
char *p;
size_t max;
- if(!buflen)
- return NULL;
-
+ if(!buflen)
+ return NULL;
+
DEBUGASSERT(err >= 0);
max = buflen - 1;
*buf = '\0';
-#if defined(WIN32) || defined(_WIN32_WCE)
-#if defined(WIN32)
+#if defined(WIN32) || defined(_WIN32_WCE)
+#if defined(WIN32)
/* 'sys_nerr' is the maximum errno number, it is not widely portable */
if(err >= 0 && err < sys_nerr)
strncpy(buf, strerror(err), max);
- else
-#endif
- {
- if(
-#ifdef USE_WINSOCK
- !get_winsock_error(err, buf, max) &&
-#endif
- !get_winapi_error((DWORD)err, buf, max))
+ else
+#endif
+ {
+ if(
+#ifdef USE_WINSOCK
+ !get_winsock_error(err, buf, max) &&
+#endif
+ !get_winapi_error((DWORD)err, buf, max))
msnprintf(buf, max, "Unknown error %d (%#x)", err, err);
}
-#else /* not Windows coming up */
+#else /* not Windows coming up */
#if defined(HAVE_STRERROR_R) && defined(HAVE_POSIX_STRERROR_R)
/*
@@ -781,7 +781,7 @@ const char *Curl_strerror(int err, char *buf, size_t buflen)
}
#else
{
- const char *msg = strerror(err);
+ const char *msg = strerror(err);
if(msg)
strncpy(buf, msg, max);
else
@@ -789,9 +789,9 @@ const char *Curl_strerror(int err, char *buf, size_t buflen)
}
#endif
-#endif /* end of not Windows */
+#endif /* end of not Windows */
- buf[max] = '\0'; /* make sure the string is null-terminated */
+ buf[max] = '\0'; /* make sure the string is null-terminated */
/* strip trailing '\r\n' or '\n'. */
p = strrchr(buf, '\n');
@@ -812,52 +812,52 @@ const char *Curl_strerror(int err, char *buf, size_t buflen)
return buf;
}
-/*
- * Curl_winapi_strerror:
- * Variant of Curl_strerror if the error code is definitely Windows API.
- */
-#if defined(WIN32) || defined(_WIN32_WCE)
-const char *Curl_winapi_strerror(DWORD err, char *buf, size_t buflen)
-{
-#ifdef PRESERVE_WINDOWS_ERROR_CODE
- DWORD old_win_err = GetLastError();
-#endif
- int old_errno = errno;
-
- if(!buflen)
- return NULL;
-
- *buf = '\0';
-
-#ifndef CURL_DISABLE_VERBOSE_STRINGS
- if(!get_winapi_error(err, buf, buflen)) {
- msnprintf(buf, buflen, "Unknown error %u (0x%08X)", err, err);
- }
-#else
- {
- const char *txt = (err == ERROR_SUCCESS) ? "No error" : "Error";
- strncpy(buf, txt, buflen);
- buf[buflen - 1] = '\0';
- }
-#endif
-
- if(errno != old_errno)
- errno = old_errno;
-
-#ifdef PRESERVE_WINDOWS_ERROR_CODE
- if(old_win_err != GetLastError())
- SetLastError(old_win_err);
-#endif
-
- return buf;
-}
-#endif /* WIN32 || _WIN32_WCE */
-
+/*
+ * Curl_winapi_strerror:
+ * Variant of Curl_strerror if the error code is definitely Windows API.
+ */
+#if defined(WIN32) || defined(_WIN32_WCE)
+const char *Curl_winapi_strerror(DWORD err, char *buf, size_t buflen)
+{
+#ifdef PRESERVE_WINDOWS_ERROR_CODE
+ DWORD old_win_err = GetLastError();
+#endif
+ int old_errno = errno;
+
+ if(!buflen)
+ return NULL;
+
+ *buf = '\0';
+
+#ifndef CURL_DISABLE_VERBOSE_STRINGS
+ if(!get_winapi_error(err, buf, buflen)) {
+ msnprintf(buf, buflen, "Unknown error %u (0x%08X)", err, err);
+ }
+#else
+ {
+ const char *txt = (err == ERROR_SUCCESS) ? "No error" : "Error";
+ strncpy(buf, txt, buflen);
+ buf[buflen - 1] = '\0';
+ }
+#endif
+
+ if(errno != old_errno)
+ errno = old_errno;
+
+#ifdef PRESERVE_WINDOWS_ERROR_CODE
+ if(old_win_err != GetLastError())
+ SetLastError(old_win_err);
+#endif
+
+ return buf;
+}
+#endif /* WIN32 || _WIN32_WCE */
+
#ifdef USE_WINDOWS_SSPI
-/*
- * Curl_sspi_strerror:
- * Variant of Curl_strerror if the error code is definitely Windows SSPI.
- */
+/*
+ * Curl_sspi_strerror:
+ * Variant of Curl_strerror if the error code is definitely Windows SSPI.
+ */
const char *Curl_sspi_strerror(int err, char *buf, size_t buflen)
{
#ifdef PRESERVE_WINDOWS_ERROR_CODE
@@ -866,120 +866,120 @@ const char *Curl_sspi_strerror(int err, char *buf, size_t buflen)
int old_errno = errno;
const char *txt;
- if(!buflen)
- return NULL;
+ if(!buflen)
+ return NULL;
+
+ *buf = '\0';
- *buf = '\0';
-
#ifndef CURL_DISABLE_VERBOSE_STRINGS
switch(err) {
case SEC_E_OK:
txt = "No error";
break;
-#define SEC2TXT(sec) case sec: txt = #sec; break
- SEC2TXT(CRYPT_E_REVOKED);
- SEC2TXT(SEC_E_ALGORITHM_MISMATCH);
- SEC2TXT(SEC_E_BAD_BINDINGS);
- SEC2TXT(SEC_E_BAD_PKGID);
- SEC2TXT(SEC_E_BUFFER_TOO_SMALL);
- SEC2TXT(SEC_E_CANNOT_INSTALL);
- SEC2TXT(SEC_E_CANNOT_PACK);
- SEC2TXT(SEC_E_CERT_EXPIRED);
- SEC2TXT(SEC_E_CERT_UNKNOWN);
- SEC2TXT(SEC_E_CERT_WRONG_USAGE);
- SEC2TXT(SEC_E_CONTEXT_EXPIRED);
- SEC2TXT(SEC_E_CROSSREALM_DELEGATION_FAILURE);
- SEC2TXT(SEC_E_CRYPTO_SYSTEM_INVALID);
- SEC2TXT(SEC_E_DECRYPT_FAILURE);
- SEC2TXT(SEC_E_DELEGATION_POLICY);
- SEC2TXT(SEC_E_DELEGATION_REQUIRED);
- SEC2TXT(SEC_E_DOWNGRADE_DETECTED);
- SEC2TXT(SEC_E_ENCRYPT_FAILURE);
- SEC2TXT(SEC_E_ILLEGAL_MESSAGE);
- SEC2TXT(SEC_E_INCOMPLETE_CREDENTIALS);
- SEC2TXT(SEC_E_INCOMPLETE_MESSAGE);
- SEC2TXT(SEC_E_INSUFFICIENT_MEMORY);
- SEC2TXT(SEC_E_INTERNAL_ERROR);
- SEC2TXT(SEC_E_INVALID_HANDLE);
- SEC2TXT(SEC_E_INVALID_PARAMETER);
- SEC2TXT(SEC_E_INVALID_TOKEN);
- SEC2TXT(SEC_E_ISSUING_CA_UNTRUSTED);
- SEC2TXT(SEC_E_ISSUING_CA_UNTRUSTED_KDC);
- SEC2TXT(SEC_E_KDC_CERT_EXPIRED);
- SEC2TXT(SEC_E_KDC_CERT_REVOKED);
- SEC2TXT(SEC_E_KDC_INVALID_REQUEST);
- SEC2TXT(SEC_E_KDC_UNABLE_TO_REFER);
- SEC2TXT(SEC_E_KDC_UNKNOWN_ETYPE);
- SEC2TXT(SEC_E_LOGON_DENIED);
- SEC2TXT(SEC_E_MAX_REFERRALS_EXCEEDED);
- SEC2TXT(SEC_E_MESSAGE_ALTERED);
- SEC2TXT(SEC_E_MULTIPLE_ACCOUNTS);
- SEC2TXT(SEC_E_MUST_BE_KDC);
- SEC2TXT(SEC_E_NOT_OWNER);
- SEC2TXT(SEC_E_NO_AUTHENTICATING_AUTHORITY);
- SEC2TXT(SEC_E_NO_CREDENTIALS);
- SEC2TXT(SEC_E_NO_IMPERSONATION);
- SEC2TXT(SEC_E_NO_IP_ADDRESSES);
- SEC2TXT(SEC_E_NO_KERB_KEY);
- SEC2TXT(SEC_E_NO_PA_DATA);
- SEC2TXT(SEC_E_NO_S4U_PROT_SUPPORT);
- SEC2TXT(SEC_E_NO_TGT_REPLY);
- SEC2TXT(SEC_E_OUT_OF_SEQUENCE);
- SEC2TXT(SEC_E_PKINIT_CLIENT_FAILURE);
- SEC2TXT(SEC_E_PKINIT_NAME_MISMATCH);
- SEC2TXT(SEC_E_POLICY_NLTM_ONLY);
- SEC2TXT(SEC_E_QOP_NOT_SUPPORTED);
- SEC2TXT(SEC_E_REVOCATION_OFFLINE_C);
- SEC2TXT(SEC_E_REVOCATION_OFFLINE_KDC);
- SEC2TXT(SEC_E_SECPKG_NOT_FOUND);
- SEC2TXT(SEC_E_SECURITY_QOS_FAILED);
- SEC2TXT(SEC_E_SHUTDOWN_IN_PROGRESS);
- SEC2TXT(SEC_E_SMARTCARD_CERT_EXPIRED);
- SEC2TXT(SEC_E_SMARTCARD_CERT_REVOKED);
- SEC2TXT(SEC_E_SMARTCARD_LOGON_REQUIRED);
- SEC2TXT(SEC_E_STRONG_CRYPTO_NOT_SUPPORTED);
- SEC2TXT(SEC_E_TARGET_UNKNOWN);
- SEC2TXT(SEC_E_TIME_SKEW);
- SEC2TXT(SEC_E_TOO_MANY_PRINCIPALS);
- SEC2TXT(SEC_E_UNFINISHED_CONTEXT_DELETED);
- SEC2TXT(SEC_E_UNKNOWN_CREDENTIALS);
- SEC2TXT(SEC_E_UNSUPPORTED_FUNCTION);
- SEC2TXT(SEC_E_UNSUPPORTED_PREAUTH);
- SEC2TXT(SEC_E_UNTRUSTED_ROOT);
- SEC2TXT(SEC_E_WRONG_CREDENTIAL_HANDLE);
- SEC2TXT(SEC_E_WRONG_PRINCIPAL);
- SEC2TXT(SEC_I_COMPLETE_AND_CONTINUE);
- SEC2TXT(SEC_I_COMPLETE_NEEDED);
- SEC2TXT(SEC_I_CONTEXT_EXPIRED);
- SEC2TXT(SEC_I_CONTINUE_NEEDED);
- SEC2TXT(SEC_I_INCOMPLETE_CREDENTIALS);
- SEC2TXT(SEC_I_LOCAL_LOGON);
- SEC2TXT(SEC_I_NO_LSA_CONTEXT);
- SEC2TXT(SEC_I_RENEGOTIATE);
- SEC2TXT(SEC_I_SIGNATURE_NEEDED);
+#define SEC2TXT(sec) case sec: txt = #sec; break
+ SEC2TXT(CRYPT_E_REVOKED);
+ SEC2TXT(SEC_E_ALGORITHM_MISMATCH);
+ SEC2TXT(SEC_E_BAD_BINDINGS);
+ SEC2TXT(SEC_E_BAD_PKGID);
+ SEC2TXT(SEC_E_BUFFER_TOO_SMALL);
+ SEC2TXT(SEC_E_CANNOT_INSTALL);
+ SEC2TXT(SEC_E_CANNOT_PACK);
+ SEC2TXT(SEC_E_CERT_EXPIRED);
+ SEC2TXT(SEC_E_CERT_UNKNOWN);
+ SEC2TXT(SEC_E_CERT_WRONG_USAGE);
+ SEC2TXT(SEC_E_CONTEXT_EXPIRED);
+ SEC2TXT(SEC_E_CROSSREALM_DELEGATION_FAILURE);
+ SEC2TXT(SEC_E_CRYPTO_SYSTEM_INVALID);
+ SEC2TXT(SEC_E_DECRYPT_FAILURE);
+ SEC2TXT(SEC_E_DELEGATION_POLICY);
+ SEC2TXT(SEC_E_DELEGATION_REQUIRED);
+ SEC2TXT(SEC_E_DOWNGRADE_DETECTED);
+ SEC2TXT(SEC_E_ENCRYPT_FAILURE);
+ SEC2TXT(SEC_E_ILLEGAL_MESSAGE);
+ SEC2TXT(SEC_E_INCOMPLETE_CREDENTIALS);
+ SEC2TXT(SEC_E_INCOMPLETE_MESSAGE);
+ SEC2TXT(SEC_E_INSUFFICIENT_MEMORY);
+ SEC2TXT(SEC_E_INTERNAL_ERROR);
+ SEC2TXT(SEC_E_INVALID_HANDLE);
+ SEC2TXT(SEC_E_INVALID_PARAMETER);
+ SEC2TXT(SEC_E_INVALID_TOKEN);
+ SEC2TXT(SEC_E_ISSUING_CA_UNTRUSTED);
+ SEC2TXT(SEC_E_ISSUING_CA_UNTRUSTED_KDC);
+ SEC2TXT(SEC_E_KDC_CERT_EXPIRED);
+ SEC2TXT(SEC_E_KDC_CERT_REVOKED);
+ SEC2TXT(SEC_E_KDC_INVALID_REQUEST);
+ SEC2TXT(SEC_E_KDC_UNABLE_TO_REFER);
+ SEC2TXT(SEC_E_KDC_UNKNOWN_ETYPE);
+ SEC2TXT(SEC_E_LOGON_DENIED);
+ SEC2TXT(SEC_E_MAX_REFERRALS_EXCEEDED);
+ SEC2TXT(SEC_E_MESSAGE_ALTERED);
+ SEC2TXT(SEC_E_MULTIPLE_ACCOUNTS);
+ SEC2TXT(SEC_E_MUST_BE_KDC);
+ SEC2TXT(SEC_E_NOT_OWNER);
+ SEC2TXT(SEC_E_NO_AUTHENTICATING_AUTHORITY);
+ SEC2TXT(SEC_E_NO_CREDENTIALS);
+ SEC2TXT(SEC_E_NO_IMPERSONATION);
+ SEC2TXT(SEC_E_NO_IP_ADDRESSES);
+ SEC2TXT(SEC_E_NO_KERB_KEY);
+ SEC2TXT(SEC_E_NO_PA_DATA);
+ SEC2TXT(SEC_E_NO_S4U_PROT_SUPPORT);
+ SEC2TXT(SEC_E_NO_TGT_REPLY);
+ SEC2TXT(SEC_E_OUT_OF_SEQUENCE);
+ SEC2TXT(SEC_E_PKINIT_CLIENT_FAILURE);
+ SEC2TXT(SEC_E_PKINIT_NAME_MISMATCH);
+ SEC2TXT(SEC_E_POLICY_NLTM_ONLY);
+ SEC2TXT(SEC_E_QOP_NOT_SUPPORTED);
+ SEC2TXT(SEC_E_REVOCATION_OFFLINE_C);
+ SEC2TXT(SEC_E_REVOCATION_OFFLINE_KDC);
+ SEC2TXT(SEC_E_SECPKG_NOT_FOUND);
+ SEC2TXT(SEC_E_SECURITY_QOS_FAILED);
+ SEC2TXT(SEC_E_SHUTDOWN_IN_PROGRESS);
+ SEC2TXT(SEC_E_SMARTCARD_CERT_EXPIRED);
+ SEC2TXT(SEC_E_SMARTCARD_CERT_REVOKED);
+ SEC2TXT(SEC_E_SMARTCARD_LOGON_REQUIRED);
+ SEC2TXT(SEC_E_STRONG_CRYPTO_NOT_SUPPORTED);
+ SEC2TXT(SEC_E_TARGET_UNKNOWN);
+ SEC2TXT(SEC_E_TIME_SKEW);
+ SEC2TXT(SEC_E_TOO_MANY_PRINCIPALS);
+ SEC2TXT(SEC_E_UNFINISHED_CONTEXT_DELETED);
+ SEC2TXT(SEC_E_UNKNOWN_CREDENTIALS);
+ SEC2TXT(SEC_E_UNSUPPORTED_FUNCTION);
+ SEC2TXT(SEC_E_UNSUPPORTED_PREAUTH);
+ SEC2TXT(SEC_E_UNTRUSTED_ROOT);
+ SEC2TXT(SEC_E_WRONG_CREDENTIAL_HANDLE);
+ SEC2TXT(SEC_E_WRONG_PRINCIPAL);
+ SEC2TXT(SEC_I_COMPLETE_AND_CONTINUE);
+ SEC2TXT(SEC_I_COMPLETE_NEEDED);
+ SEC2TXT(SEC_I_CONTEXT_EXPIRED);
+ SEC2TXT(SEC_I_CONTINUE_NEEDED);
+ SEC2TXT(SEC_I_INCOMPLETE_CREDENTIALS);
+ SEC2TXT(SEC_I_LOCAL_LOGON);
+ SEC2TXT(SEC_I_NO_LSA_CONTEXT);
+ SEC2TXT(SEC_I_RENEGOTIATE);
+ SEC2TXT(SEC_I_SIGNATURE_NEEDED);
default:
txt = "Unknown error";
}
- if(err == SEC_E_ILLEGAL_MESSAGE) {
- msnprintf(buf, buflen,
+ if(err == SEC_E_ILLEGAL_MESSAGE) {
+ msnprintf(buf, buflen,
"SEC_E_ILLEGAL_MESSAGE (0x%08X) - This error usually occurs "
"when a fatal SSL/TLS alert is received (e.g. handshake failed)."
" More detail may be available in the Windows System event log.",
err);
- }
+ }
else {
- char txtbuf[80];
- char msgbuf[256];
-
+ char txtbuf[80];
+ char msgbuf[256];
+
msnprintf(txtbuf, sizeof(txtbuf), "%s (0x%08X)", txt, err);
- if(get_winapi_error(err, msgbuf, sizeof(msgbuf)))
- msnprintf(buf, buflen, "%s - %s", txtbuf, msgbuf);
- else {
- strncpy(buf, txtbuf, buflen);
- buf[buflen - 1] = '\0';
+ if(get_winapi_error(err, msgbuf, sizeof(msgbuf)))
+ msnprintf(buf, buflen, "%s - %s", txtbuf, msgbuf);
+ else {
+ strncpy(buf, txtbuf, buflen);
+ buf[buflen - 1] = '\0';
}
}
@@ -988,8 +988,8 @@ const char *Curl_sspi_strerror(int err, char *buf, size_t buflen)
txt = "No error";
else
txt = "Error";
- strncpy(buf, txt, buflen);
- buf[buflen - 1] = '\0';
+ strncpy(buf, txt, buflen);
+ buf[buflen - 1] = '\0';
#endif
if(errno != old_errno)
@@ -1000,6 +1000,6 @@ const char *Curl_sspi_strerror(int err, char *buf, size_t buflen)
SetLastError(old_win_err);
#endif
- return buf;
+ return buf;
}
#endif /* USE_WINDOWS_SSPI */
diff --git a/contrib/libs/curl/lib/strerror.h b/contrib/libs/curl/lib/strerror.h
index f0f2278ad4..96a7e27c51 100644
--- a/contrib/libs/curl/lib/strerror.h
+++ b/contrib/libs/curl/lib/strerror.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -24,12 +24,12 @@
#include "urldata.h"
-#define STRERROR_LEN 256 /* a suitable length */
+#define STRERROR_LEN 256 /* a suitable length */
const char *Curl_strerror(int err, char *buf, size_t buflen);
-#if defined(WIN32) || defined(_WIN32_WCE)
-const char *Curl_winapi_strerror(DWORD err, char *buf, size_t buflen);
-#endif
+#if defined(WIN32) || defined(_WIN32_WCE)
+const char *Curl_winapi_strerror(DWORD err, char *buf, size_t buflen);
+#endif
#ifdef USE_WINDOWS_SSPI
const char *Curl_sspi_strerror(int err, char *buf, size_t buflen);
#endif
diff --git a/contrib/libs/curl/lib/strtok.c b/contrib/libs/curl/lib/strtok.c
index 789cd13907..d53e587ab3 100644
--- a/contrib/libs/curl/lib/strtok.c
+++ b/contrib/libs/curl/lib/strtok.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -52,7 +52,7 @@ Curl_strtok_r(char *ptr, const char *sep, char **end)
if(**end) {
/* the end is not a null byte */
- **end = '\0'; /* null-terminate it! */
+ **end = '\0'; /* null-terminate it! */
++*end; /* advance the last pointer to beyond the null byte */
}
diff --git a/contrib/libs/curl/lib/strtok.h b/contrib/libs/curl/lib/strtok.h
index 14d5a4aacd..831ef0c009 100644
--- a/contrib/libs/curl/lib/strtok.h
+++ b/contrib/libs/curl/lib/strtok.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/strtoofft.c b/contrib/libs/curl/lib/strtoofft.c
index 08354b99d7..ac87cfc5bd 100644
--- a/contrib/libs/curl/lib/strtoofft.c
+++ b/contrib/libs/curl/lib/strtoofft.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/strtoofft.h b/contrib/libs/curl/lib/strtoofft.h
index 7a482fce47..4d22ba36c9 100644
--- a/contrib/libs/curl/lib/strtoofft.h
+++ b/contrib/libs/curl/lib/strtoofft.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/system_win32.c b/contrib/libs/curl/lib/system_win32.c
index ab3819ba18..b377da7d8b 100644
--- a/contrib/libs/curl/lib/system_win32.c
+++ b/contrib/libs/curl/lib/system_win32.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 2016 - 2020, Steve Holme, <steve_holme@hotmail.com>.
+ * Copyright (C) 2016 - 2020, Steve Holme, <steve_holme@hotmail.com>.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -26,7 +26,7 @@
#include <curl/curl.h>
#include "system_win32.h"
-#include "version_win32.h"
+#include "version_win32.h"
#include "curl_sspi.h"
#include "warnless.h"
@@ -55,7 +55,7 @@ CURLcode Curl_win32_init(long flags)
WSADATA wsaData;
int res;
- wVersionRequested = MAKEWORD(2, 2);
+ wVersionRequested = MAKEWORD(2, 2);
res = WSAStartup(wVersionRequested, &wsaData);
if(res != 0)
@@ -78,9 +78,9 @@ CURLcode Curl_win32_init(long flags)
return CURLE_FAILED_INIT;
}
/* The Windows Sockets DLL is acceptable. Proceed. */
-#elif defined(USE_LWIPSOCK)
+#elif defined(USE_LWIPSOCK)
lwip_init();
-#endif
+#endif
} /* CURL_GLOBAL_WIN32 */
#ifdef USE_WINDOWS_SSPI
@@ -102,14 +102,14 @@ CURLcode Curl_win32_init(long flags)
Curl_if_nametoindex = pIfNameToIndex;
}
- if(curlx_verify_windows_version(6, 0, PLATFORM_WINNT,
- VERSION_GREATER_THAN_EQUAL)) {
+ if(curlx_verify_windows_version(6, 0, PLATFORM_WINNT,
+ VERSION_GREATER_THAN_EQUAL)) {
Curl_isVistaOrGreater = TRUE;
}
else
Curl_isVistaOrGreater = FALSE;
- QueryPerformanceFrequency(&Curl_freq);
+ QueryPerformanceFrequency(&Curl_freq);
return CURLE_OK;
}
diff --git a/contrib/libs/curl/lib/system_win32.h b/contrib/libs/curl/lib/system_win32.h
index e471be07c7..69e0c812c0 100644
--- a/contrib/libs/curl/lib/system_win32.h
+++ b/contrib/libs/curl/lib/system_win32.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 2016 - 2020, Steve Holme, <steve_holme@hotmail.com>.
+ * Copyright (C) 2016 - 2020, Steve Holme, <steve_holme@hotmail.com>.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/telnet.c b/contrib/libs/curl/lib/telnet.c
index 85b90a8ac2..8bf64a9f2b 100644
--- a/contrib/libs/curl/lib/telnet.c
+++ b/contrib/libs/curl/lib/telnet.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -69,12 +69,12 @@
do { \
x->subend = x->subpointer; \
CURL_SB_CLEAR(x); \
- } while(0)
+ } while(0)
#define CURL_SB_ACCUM(x,c) \
do { \
if(x->subpointer < (x->subbuffer + sizeof(x->subbuffer))) \
*x->subpointer++ = (c); \
- } while(0)
+ } while(0)
#define CURL_SB_GET(x) ((*x->subpointer++)&0xff)
#define CURL_SB_LEN(x) (x->subend - x->subpointer)
@@ -188,7 +188,7 @@ const struct Curl_handler Curl_handler_telnet = {
ZERO_NULL, /* connection_check */
PORT_TELNET, /* defport */
CURLPROTO_TELNET, /* protocol */
- CURLPROTO_TELNET, /* family */
+ CURLPROTO_TELNET, /* family */
PROTOPT_NONE | PROTOPT_NOURLQUERY /* flags */
};
@@ -202,7 +202,7 @@ CURLcode init_telnet(struct connectdata *conn)
if(!tn)
return CURLE_OUT_OF_MEMORY;
- conn->data->req.p.telnet = tn; /* make us known */
+ conn->data->req.p.telnet = tn; /* make us known */
tn->telrcv_state = CURL_TS_DATA;
@@ -247,7 +247,7 @@ CURLcode init_telnet(struct connectdata *conn)
static void negotiate(struct connectdata *conn)
{
int i;
- struct TELNET *tn = (struct TELNET *) conn->data->req.p.telnet;
+ struct TELNET *tn = (struct TELNET *) conn->data->req.p.telnet;
for(i = 0; i < CURL_NTELOPTS; i++) {
if(i == CURL_TELOPT_ECHO)
@@ -320,7 +320,7 @@ static void send_negotiation(struct connectdata *conn, int cmd, int option)
static
void set_remote_option(struct connectdata *conn, int option, int newstate)
{
- struct TELNET *tn = (struct TELNET *)conn->data->req.p.telnet;
+ struct TELNET *tn = (struct TELNET *)conn->data->req.p.telnet;
if(newstate == CURL_YES) {
switch(tn->him[option]) {
case CURL_NO:
@@ -394,7 +394,7 @@ void set_remote_option(struct connectdata *conn, int option, int newstate)
static
void rec_will(struct connectdata *conn, int option)
{
- struct TELNET *tn = (struct TELNET *)conn->data->req.p.telnet;
+ struct TELNET *tn = (struct TELNET *)conn->data->req.p.telnet;
switch(tn->him[option]) {
case CURL_NO:
if(tn->him_preferred[option] == CURL_YES) {
@@ -442,7 +442,7 @@ void rec_will(struct connectdata *conn, int option)
static
void rec_wont(struct connectdata *conn, int option)
{
- struct TELNET *tn = (struct TELNET *)conn->data->req.p.telnet;
+ struct TELNET *tn = (struct TELNET *)conn->data->req.p.telnet;
switch(tn->him[option]) {
case CURL_NO:
/* Already disabled */
@@ -484,7 +484,7 @@ void rec_wont(struct connectdata *conn, int option)
static void
set_local_option(struct connectdata *conn, int option, int newstate)
{
- struct TELNET *tn = (struct TELNET *)conn->data->req.p.telnet;
+ struct TELNET *tn = (struct TELNET *)conn->data->req.p.telnet;
if(newstate == CURL_YES) {
switch(tn->us[option]) {
case CURL_NO:
@@ -558,7 +558,7 @@ set_local_option(struct connectdata *conn, int option, int newstate)
static
void rec_do(struct connectdata *conn, int option)
{
- struct TELNET *tn = (struct TELNET *)conn->data->req.p.telnet;
+ struct TELNET *tn = (struct TELNET *)conn->data->req.p.telnet;
switch(tn->us[option]) {
case CURL_NO:
if(tn->us_preferred[option] == CURL_YES) {
@@ -618,7 +618,7 @@ void rec_do(struct connectdata *conn, int option)
static
void rec_dont(struct connectdata *conn, int option)
{
- struct TELNET *tn = (struct TELNET *)conn->data->req.p.telnet;
+ struct TELNET *tn = (struct TELNET *)conn->data->req.p.telnet;
switch(tn->us[option]) {
case CURL_NO:
/* Already disabled */
@@ -777,7 +777,7 @@ static CURLcode check_telnet_options(struct connectdata *conn)
char option_keyword[128] = "";
char option_arg[256] = "";
struct Curl_easy *data = conn->data;
- struct TELNET *tn = (struct TELNET *)conn->data->req.p.telnet;
+ struct TELNET *tn = (struct TELNET *)conn->data->req.p.telnet;
CURLcode result = CURLE_OK;
int binary_option;
@@ -884,7 +884,7 @@ static void suboption(struct connectdata *conn)
char varname[128] = "";
char varval[128] = "";
struct Curl_easy *data = conn->data;
- struct TELNET *tn = (struct TELNET *)data->req.p.telnet;
+ struct TELNET *tn = (struct TELNET *)data->req.p.telnet;
printsub(data, '<', (unsigned char *)tn->subbuffer, CURL_SB_LEN(tn) + 2);
switch(CURL_SB_GET(tn)) {
@@ -959,7 +959,7 @@ static void sendsuboption(struct connectdata *conn, int option)
unsigned char *uc1, *uc2;
struct Curl_easy *data = conn->data;
- struct TELNET *tn = (struct TELNET *)data->req.p.telnet;
+ struct TELNET *tn = (struct TELNET *)data->req.p.telnet;
switch(option) {
case CURL_TELOPT_NAWS:
@@ -1017,7 +1017,7 @@ CURLcode telrcv(struct connectdata *conn,
int in = 0;
int startwrite = -1;
struct Curl_easy *data = conn->data;
- struct TELNET *tn = (struct TELNET *)data->req.p.telnet;
+ struct TELNET *tn = (struct TELNET *)data->req.p.telnet;
#define startskipping() \
if(startwrite >= 0) { \
@@ -1235,7 +1235,7 @@ static CURLcode send_telnet_data(struct connectdata *conn,
static CURLcode telnet_done(struct connectdata *conn,
CURLcode status, bool premature)
{
- struct TELNET *tn = (struct TELNET *)conn->data->req.p.telnet;
+ struct TELNET *tn = (struct TELNET *)conn->data->req.p.telnet;
(void)status; /* unused */
(void)premature; /* not used */
@@ -1245,7 +1245,7 @@ static CURLcode telnet_done(struct connectdata *conn,
curl_slist_free_all(tn->telnet_vars);
tn->telnet_vars = NULL;
- Curl_safefree(conn->data->req.p.telnet);
+ Curl_safefree(conn->data->req.p.telnet);
return CURLE_OK;
}
@@ -1265,7 +1265,7 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done)
DWORD readfile_read;
int err;
#else
- timediff_t interval_ms;
+ timediff_t interval_ms;
struct pollfd pfd[2];
int poll_cnt;
curl_off_t total_dl = 0;
@@ -1283,7 +1283,7 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done)
if(result)
return result;
- tn = data->req.p.telnet;
+ tn = data->req.p.telnet;
result = check_telnet_options(conn);
if(result)
@@ -1296,15 +1296,15 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done)
*/
/* First, create a sockets event object */
- event_handle = WSACreateEvent();
+ event_handle = WSACreateEvent();
if(event_handle == WSA_INVALID_EVENT) {
failf(data, "WSACreateEvent failed (%d)", SOCKERRNO);
return CURLE_FAILED_INIT;
}
/* Tell winsock what events we want to listen to */
- if(WSAEventSelect(sockfd, event_handle, FD_READ|FD_CLOSE) == SOCKET_ERROR) {
- WSACloseEvent(event_handle);
+ if(WSAEventSelect(sockfd, event_handle, FD_READ|FD_CLOSE) == SOCKET_ERROR) {
+ WSACloseEvent(event_handle);
return CURLE_OK;
}
@@ -1335,7 +1335,7 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done)
DWORD waitret = WaitForMultipleObjects(obj_count, objs,
FALSE, wait_timeout);
switch(waitret) {
-
+
case WAIT_TIMEOUT:
{
for(;;) {
@@ -1405,9 +1405,9 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done)
break;
case WAIT_OBJECT_0:
- {
+ {
events.lNetworkEvents = 0;
- if(WSAEnumNetworkEvents(sockfd, event_handle, &events) == SOCKET_ERROR) {
+ if(WSAEnumNetworkEvents(sockfd, event_handle, &events) == SOCKET_ERROR) {
err = SOCKERRNO;
if(err != EINPROGRESS) {
infof(data, "WSAEnumNetworkEvents failed (%d)", err);
@@ -1451,8 +1451,8 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done)
if(events.lNetworkEvents & FD_CLOSE) {
keepon = FALSE;
}
- }
- break;
+ }
+ break;
}
@@ -1467,7 +1467,7 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done)
}
/* We called WSACreateEvent, so call WSACloseEvent */
- if(!WSACloseEvent(event_handle)) {
+ if(!WSACloseEvent(event_handle)) {
infof(data, "WSACloseEvent failed (%d)", SOCKERRNO);
}
#else
diff --git a/contrib/libs/curl/lib/telnet.h b/contrib/libs/curl/lib/telnet.h
index 87631034ce..1427473a9f 100644
--- a/contrib/libs/curl/lib/telnet.h
+++ b/contrib/libs/curl/lib/telnet.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/tftp.c b/contrib/libs/curl/lib/tftp.c
index 7a7beb677b..fba3f5e8c2 100644
--- a/contrib/libs/curl/lib/tftp.c
+++ b/contrib/libs/curl/lib/tftp.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -115,11 +115,11 @@ typedef enum {
TFTP_ERR_NORESPONSE
} tftp_error_t;
-struct tftp_packet {
+struct tftp_packet {
unsigned char *data;
-};
+};
-struct tftp_state_data {
+struct tftp_state_data {
tftp_state_t state;
tftp_mode_t mode;
tftp_error_t error;
@@ -140,21 +140,21 @@ struct tftp_state_data {
int sbytes;
int blksize;
int requested_blksize;
- struct tftp_packet rpacket;
- struct tftp_packet spacket;
-};
+ struct tftp_packet rpacket;
+ struct tftp_packet spacket;
+};
/* Forward declarations */
-static CURLcode tftp_rx(struct tftp_state_data *state, tftp_event_t event);
-static CURLcode tftp_tx(struct tftp_state_data *state, tftp_event_t event);
+static CURLcode tftp_rx(struct tftp_state_data *state, tftp_event_t event);
+static CURLcode tftp_tx(struct tftp_state_data *state, tftp_event_t event);
static CURLcode tftp_connect(struct connectdata *conn, bool *done);
static CURLcode tftp_disconnect(struct connectdata *conn,
bool dead_connection);
static CURLcode tftp_do(struct connectdata *conn, bool *done);
static CURLcode tftp_done(struct connectdata *conn,
CURLcode, bool premature);
-static CURLcode tftp_setup_connection(struct connectdata *conn);
+static CURLcode tftp_setup_connection(struct connectdata *conn);
static CURLcode tftp_multi_statemach(struct connectdata *conn, bool *done);
static CURLcode tftp_doing(struct connectdata *conn, bool *dophase_done);
static int tftp_getsock(struct connectdata *conn, curl_socket_t *socks);
@@ -183,7 +183,7 @@ const struct Curl_handler Curl_handler_tftp = {
ZERO_NULL, /* connection_check */
PORT_TFTP, /* defport */
CURLPROTO_TFTP, /* protocol */
- CURLPROTO_TFTP, /* family */
+ CURLPROTO_TFTP, /* family */
PROTOPT_NONE | PROTOPT_NOURLQUERY /* flags */
};
@@ -197,7 +197,7 @@ const struct Curl_handler Curl_handler_tftp = {
*
*
**********************************************************/
-static CURLcode tftp_set_timeouts(struct tftp_state_data *state)
+static CURLcode tftp_set_timeouts(struct tftp_state_data *state)
{
time_t maxtime, timeout;
timediff_t timeout_ms;
@@ -280,25 +280,25 @@ static CURLcode tftp_set_timeouts(struct tftp_state_data *state)
*
**********************************************************/
-static void setpacketevent(struct tftp_packet *packet, unsigned short num)
+static void setpacketevent(struct tftp_packet *packet, unsigned short num)
{
packet->data[0] = (unsigned char)(num >> 8);
packet->data[1] = (unsigned char)(num & 0xff);
}
-static void setpacketblock(struct tftp_packet *packet, unsigned short num)
+static void setpacketblock(struct tftp_packet *packet, unsigned short num)
{
packet->data[2] = (unsigned char)(num >> 8);
packet->data[3] = (unsigned char)(num & 0xff);
}
-static unsigned short getrpacketevent(const struct tftp_packet *packet)
+static unsigned short getrpacketevent(const struct tftp_packet *packet)
{
return (unsigned short)((packet->data[0] << 8) | packet->data[1]);
}
-static unsigned short getrpacketblock(const struct tftp_packet *packet)
+static unsigned short getrpacketblock(const struct tftp_packet *packet)
{
return (unsigned short)((packet->data[2] << 8) | packet->data[3]);
}
@@ -331,7 +331,7 @@ static const char *tftp_option_get(const char *buf, size_t len,
return &buf[loc];
}
-static CURLcode tftp_parse_option_ack(struct tftp_state_data *state,
+static CURLcode tftp_parse_option_ack(struct tftp_state_data *state,
const char *ptr, int len)
{
const char *tmp = ptr;
@@ -404,7 +404,7 @@ static CURLcode tftp_parse_option_ack(struct tftp_state_data *state,
return CURLE_OK;
}
-static CURLcode tftp_option_add(struct tftp_state_data *state, size_t *csize,
+static CURLcode tftp_option_add(struct tftp_state_data *state, size_t *csize,
char *buf, const char *option)
{
if(( strlen(option) + *csize + 1) > (size_t)state->blksize)
@@ -414,7 +414,7 @@ static CURLcode tftp_option_add(struct tftp_state_data *state, size_t *csize,
return CURLE_OK;
}
-static CURLcode tftp_connect_for_tx(struct tftp_state_data *state,
+static CURLcode tftp_connect_for_tx(struct tftp_state_data *state,
tftp_event_t event)
{
CURLcode result;
@@ -430,7 +430,7 @@ static CURLcode tftp_connect_for_tx(struct tftp_state_data *state,
return tftp_tx(state, event);
}
-static CURLcode tftp_connect_for_rx(struct tftp_state_data *state,
+static CURLcode tftp_connect_for_rx(struct tftp_state_data *state,
tftp_event_t event)
{
CURLcode result;
@@ -446,8 +446,8 @@ static CURLcode tftp_connect_for_rx(struct tftp_state_data *state,
return tftp_rx(state, event);
}
-static CURLcode tftp_send_first(struct tftp_state_data *state,
- tftp_event_t event)
+static CURLcode tftp_send_first(struct tftp_state_data *state,
+ tftp_event_t event)
{
size_t sbytes;
ssize_t senddata;
@@ -488,7 +488,7 @@ static CURLcode tftp_send_first(struct tftp_state_data *state,
file name so we skip the always-present first letter of the path
string. */
result = Curl_urldecode(data, &state->conn->data->state.up.path[1], 0,
- &filename, NULL, REJECT_ZERO);
+ &filename, NULL, REJECT_ZERO);
if(result)
return result;
@@ -600,8 +600,8 @@ static CURLcode tftp_send_first(struct tftp_state_data *state,
* Event handler for the RX state
*
**********************************************************/
-static CURLcode tftp_rx(struct tftp_state_data *state,
- tftp_event_t event)
+static CURLcode tftp_rx(struct tftp_state_data *state,
+ tftp_event_t event)
{
ssize_t sbytes;
int rblock;
@@ -723,7 +723,7 @@ static CURLcode tftp_rx(struct tftp_state_data *state,
* Event handler for the TX state
*
**********************************************************/
-static CURLcode tftp_tx(struct tftp_state_data *state, tftp_event_t event)
+static CURLcode tftp_tx(struct tftp_state_data *state, tftp_event_t event)
{
struct Curl_easy *data = state->conn->data;
ssize_t sbytes;
@@ -923,7 +923,7 @@ static CURLcode tftp_translate_code(tftp_error_t error)
* The tftp state machine event dispatcher
*
**********************************************************/
-static CURLcode tftp_state_machine(struct tftp_state_data *state,
+static CURLcode tftp_state_machine(struct tftp_state_data *state,
tftp_event_t event)
{
CURLcode result = CURLE_OK;
@@ -964,7 +964,7 @@ static CURLcode tftp_state_machine(struct tftp_state_data *state,
**********************************************************/
static CURLcode tftp_disconnect(struct connectdata *conn, bool dead_connection)
{
- struct tftp_state_data *state = conn->proto.tftpc;
+ struct tftp_state_data *state = conn->proto.tftpc;
(void) dead_connection;
/* done, free dynamically allocated pkt buffers */
@@ -986,13 +986,13 @@ static CURLcode tftp_disconnect(struct connectdata *conn, bool dead_connection)
**********************************************************/
static CURLcode tftp_connect(struct connectdata *conn, bool *done)
{
- struct tftp_state_data *state;
+ struct tftp_state_data *state;
int blksize;
int need_blksize;
blksize = TFTP_BLKSIZE_DEFAULT;
- state = conn->proto.tftpc = calloc(1, sizeof(struct tftp_state_data));
+ state = conn->proto.tftpc = calloc(1, sizeof(struct tftp_state_data));
if(!state)
return CURLE_OUT_OF_MEMORY;
@@ -1081,7 +1081,7 @@ static CURLcode tftp_done(struct connectdata *conn, CURLcode status,
bool premature)
{
CURLcode result = CURLE_OK;
- struct tftp_state_data *state = conn->proto.tftpc;
+ struct tftp_state_data *state = conn->proto.tftpc;
(void)status; /* unused */
(void)premature; /* not used */
@@ -1122,7 +1122,7 @@ static CURLcode tftp_receive_packet(struct connectdata *conn)
curl_socklen_t fromlen;
CURLcode result = CURLE_OK;
struct Curl_easy *data = conn->data;
- struct tftp_state_data *state = conn->proto.tftpc;
+ struct tftp_state_data *state = conn->proto.tftpc;
struct SingleRequest *k = &data->req;
/* Receive the packet */
@@ -1209,8 +1209,8 @@ static CURLcode tftp_receive_packet(struct connectdata *conn)
**********************************************************/
static long tftp_state_timeout(struct connectdata *conn, tftp_event_t *event)
{
- time_t current;
- struct tftp_state_data *state = conn->proto.tftpc;
+ time_t current;
+ struct tftp_state_data *state = conn->proto.tftpc;
if(event)
*event = TFTP_EVENT_NONE;
@@ -1247,7 +1247,7 @@ static CURLcode tftp_multi_statemach(struct connectdata *conn, bool *done)
tftp_event_t event;
CURLcode result = CURLE_OK;
struct Curl_easy *data = conn->data;
- struct tftp_state_data *state = conn->proto.tftpc;
+ struct tftp_state_data *state = conn->proto.tftpc;
long timeout_ms = tftp_state_timeout(conn, &event);
*done = FALSE;
@@ -1331,7 +1331,7 @@ static CURLcode tftp_doing(struct connectdata *conn, bool *dophase_done)
static CURLcode tftp_perform(struct connectdata *conn, bool *dophase_done)
{
CURLcode result = CURLE_OK;
- struct tftp_state_data *state = conn->proto.tftpc;
+ struct tftp_state_data *state = conn->proto.tftpc;
*dophase_done = FALSE;
@@ -1361,7 +1361,7 @@ static CURLcode tftp_perform(struct connectdata *conn, bool *dophase_done)
static CURLcode tftp_do(struct connectdata *conn, bool *done)
{
- struct tftp_state_data *state;
+ struct tftp_state_data *state;
CURLcode result;
*done = FALSE;
@@ -1372,7 +1372,7 @@ static CURLcode tftp_do(struct connectdata *conn, bool *done)
return result;
}
- state = conn->proto.tftpc;
+ state = conn->proto.tftpc;
if(!state)
return CURLE_TFTP_ILLEGAL;
@@ -1387,7 +1387,7 @@ static CURLcode tftp_do(struct connectdata *conn, bool *done)
return result;
}
-static CURLcode tftp_setup_connection(struct connectdata *conn)
+static CURLcode tftp_setup_connection(struct connectdata *conn)
{
struct Curl_easy *data = conn->data;
char *type;
diff --git a/contrib/libs/curl/lib/tftp.h b/contrib/libs/curl/lib/tftp.h
index ca386c1bf4..4b5bea2757 100644
--- a/contrib/libs/curl/lib/tftp.h
+++ b/contrib/libs/curl/lib/tftp.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/timeval.c b/contrib/libs/curl/lib/timeval.c
index f467a03fa2..8523dad400 100644
--- a/contrib/libs/curl/lib/timeval.c
+++ b/contrib/libs/curl/lib/timeval.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -28,7 +28,7 @@
extern LARGE_INTEGER Curl_freq;
extern bool Curl_isVistaOrGreater;
-/* In case of bug fix this function has a counterpart in tool_util.c */
+/* In case of bug fix this function has a counterpart in tool_util.c */
struct curltime Curl_now(void)
{
struct curltime now;
diff --git a/contrib/libs/curl/lib/timeval.h b/contrib/libs/curl/lib/timeval.h
index bf70e950f7..685e72961d 100644
--- a/contrib/libs/curl/lib/timeval.h
+++ b/contrib/libs/curl/lib/timeval.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/transfer.c b/contrib/libs/curl/lib/transfer.c
index 482d4bc26a..bfd0218fef 100644
--- a/contrib/libs/curl/lib/transfer.c
+++ b/contrib/libs/curl/lib/transfer.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -48,8 +48,8 @@
#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
-#elif defined(HAVE_UNISTD_H)
-#include <unistd.h>
+#elif defined(HAVE_UNISTD_H)
+#include <unistd.h>
#endif
#ifndef HAVE_SOCKET
@@ -78,7 +78,7 @@
#include "mime.h"
#include "strcase.h"
#include "urlapi-int.h"
-#include "hsts.h"
+#include "hsts.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
@@ -129,13 +129,13 @@ static size_t Curl_trailers_read(char *buffer, size_t size, size_t nitems,
void *raw)
{
struct Curl_easy *data = (struct Curl_easy *)raw;
- struct dynbuf *trailers_buf = &data->state.trailers_buf;
- size_t bytes_left = Curl_dyn_len(trailers_buf) -
- data->state.trailers_bytes_sent;
+ struct dynbuf *trailers_buf = &data->state.trailers_buf;
+ size_t bytes_left = Curl_dyn_len(trailers_buf) -
+ data->state.trailers_bytes_sent;
size_t to_copy = (size*nitems < bytes_left) ? size*nitems : bytes_left;
if(to_copy) {
memcpy(buffer,
- Curl_dyn_ptr(trailers_buf) + data->state.trailers_bytes_sent,
+ Curl_dyn_ptr(trailers_buf) + data->state.trailers_bytes_sent,
to_copy);
data->state.trailers_bytes_sent += to_copy;
}
@@ -145,8 +145,8 @@ static size_t Curl_trailers_read(char *buffer, size_t size, size_t nitems,
static size_t Curl_trailers_left(void *raw)
{
struct Curl_easy *data = (struct Curl_easy *)raw;
- struct dynbuf *trailers_buf = &data->state.trailers_buf;
- return Curl_dyn_len(trailers_buf) - data->state.trailers_bytes_sent;
+ struct dynbuf *trailers_buf = &data->state.trailers_buf;
+ return Curl_dyn_len(trailers_buf) - data->state.trailers_bytes_sent;
}
#endif
@@ -168,7 +168,7 @@ CURLcode Curl_fillreadbuffer(struct connectdata *conn, size_t bytes,
bool sending_http_headers = FALSE;
if(conn->handler->protocol&(PROTO_FAMILY_HTTP|CURLPROTO_RTSP)) {
- const struct HTTP *http = data->req.p.http;
+ const struct HTTP *http = data->req.p.http;
if(http->sending == HTTPSEND_REQUEST)
/* We're sending the HTTP request headers, not the data.
@@ -188,8 +188,8 @@ CURLcode Curl_fillreadbuffer(struct connectdata *conn, size_t bytes,
infof(data,
"Moving trailers state machine from initialized to sending.\n");
data->state.trailers_state = TRAILERS_SENDING;
- Curl_dyn_init(&data->state.trailers_buf, DYN_TRAILERS);
-
+ Curl_dyn_init(&data->state.trailers_buf, DYN_TRAILERS);
+
data->state.trailers_bytes_sent = 0;
Curl_set_in_callback(data, true);
trailers_ret_code = data->set.trailer_callback(&trailers,
@@ -205,7 +205,7 @@ CURLcode Curl_fillreadbuffer(struct connectdata *conn, size_t bytes,
result = CURLE_ABORTED_BY_CALLBACK;
}
if(result) {
- Curl_dyn_free(&data->state.trailers_buf);
+ Curl_dyn_free(&data->state.trailers_buf);
curl_slist_free_all(trailers);
return result;
}
@@ -368,7 +368,7 @@ CURLcode Curl_fillreadbuffer(struct connectdata *conn, size_t bytes,
#ifndef CURL_DISABLE_HTTP
if(data->state.trailers_state == TRAILERS_SENDING &&
!Curl_trailers_left(data)) {
- Curl_dyn_free(&data->state.trailers_buf);
+ Curl_dyn_free(&data->state.trailers_buf);
data->state.trailers_state = TRAILERS_DONE;
data->set.trailer_data = NULL;
data->set.trailer_callback = NULL;
@@ -427,15 +427,15 @@ CURLcode Curl_readrewind(struct connectdata *conn)
CURLOPT_HTTPPOST, call app to rewind
*/
if(conn->handler->protocol & PROTO_FAMILY_HTTP) {
- struct HTTP *http = data->req.p.http;
+ struct HTTP *http = data->req.p.http;
if(http->sendit)
mimepart = http->sendit;
}
if(data->set.postfields)
; /* do nothing */
- else if(data->state.httpreq == HTTPREQ_POST_MIME ||
- data->state.httpreq == HTTPREQ_POST_FORM) {
+ else if(data->state.httpreq == HTTPREQ_POST_MIME ||
+ data->state.httpreq == HTTPREQ_POST_FORM) {
if(Curl_mime_rewind(mimepart)) {
failf(data, "Cannot rewind mime/post data");
return CURLE_SEND_FAIL_REWIND;
@@ -485,15 +485,15 @@ CURLcode Curl_readrewind(struct connectdata *conn)
return CURLE_OK;
}
-static int data_pending(const struct Curl_easy *data)
+static int data_pending(const struct Curl_easy *data)
{
- struct connectdata *conn = data->conn;
-
-#ifdef ENABLE_QUIC
- if(conn->transport == TRNSPRT_QUIC)
- return Curl_quic_data_pending(data);
-#endif
-
+ struct connectdata *conn = data->conn;
+
+#ifdef ENABLE_QUIC
+ if(conn->transport == TRNSPRT_QUIC)
+ return Curl_quic_data_pending(data);
+#endif
+
/* in the case of libssh2, we can never be really sure that we have emptied
its internal buffers so we MUST always try until we get EAGAIN back */
return conn->handler->protocol&(CURLPROTO_SCP|CURLPROTO_SFTP) ||
@@ -563,8 +563,8 @@ static CURLcode readwrite_data(struct Curl_easy *data,
size_t excess = 0; /* excess bytes read */
bool readmore = FALSE; /* used by RTP to signal for more data */
int maxloops = 100;
- char *buf = data->state.buffer;
- DEBUGASSERT(buf);
+ char *buf = data->state.buffer;
+ DEBUGASSERT(buf);
*done = FALSE;
*comeback = FALSE;
@@ -575,20 +575,20 @@ static CURLcode readwrite_data(struct Curl_easy *data,
bool is_empty_data = FALSE;
size_t buffersize = data->set.buffer_size;
size_t bytestoread = buffersize;
-#ifdef USE_NGHTTP2
- bool is_http2 = ((conn->handler->protocol & PROTO_FAMILY_HTTP) &&
- (conn->httpversion == 20));
-#endif
+#ifdef USE_NGHTTP2
+ bool is_http2 = ((conn->handler->protocol & PROTO_FAMILY_HTTP) &&
+ (conn->httpversion == 20));
+#endif
if(
-#ifdef USE_NGHTTP2
+#ifdef USE_NGHTTP2
/* For HTTP/2, read data without caring about the content
length. This is safe because body in HTTP/2 is always
segmented thanks to its framing layer. Meanwhile, we have to
call Curl_read to ensure that http2_handle_stream_close is
called when we read all incoming bytes for a particular
stream. */
- !is_http2 &&
+ !is_http2 &&
#endif
k->size != -1 && !k->header) {
/* make sure we don't read too much */
@@ -599,7 +599,7 @@ static CURLcode readwrite_data(struct Curl_easy *data,
if(bytestoread) {
/* receive data from the network! */
- result = Curl_read(conn, conn->sockfd, buf, bytestoread, &nread);
+ result = Curl_read(conn, conn->sockfd, buf, bytestoread, &nread);
/* read would've blocked */
if(CURLE_AGAIN == result)
@@ -627,24 +627,24 @@ static CURLcode readwrite_data(struct Curl_easy *data,
is_empty_data = ((nread == 0) && (k->bodywrites == 0)) ? TRUE : FALSE;
if(0 < nread || is_empty_data) {
- buf[nread] = 0;
+ buf[nread] = 0;
}
else {
- /* if we receive 0 or less here, either the http2 stream is closed or the
- server closed the connection and we bail out from this! */
-#ifdef USE_NGHTTP2
- if(is_http2 && !nread)
- DEBUGF(infof(data, "nread == 0, stream closed, bailing\n"));
- else
-#endif
- DEBUGF(infof(data, "nread <= 0, server closed connection, bailing\n"));
+ /* if we receive 0 or less here, either the http2 stream is closed or the
+ server closed the connection and we bail out from this! */
+#ifdef USE_NGHTTP2
+ if(is_http2 && !nread)
+ DEBUGF(infof(data, "nread == 0, stream closed, bailing\n"));
+ else
+#endif
+ DEBUGF(infof(data, "nread <= 0, server closed connection, bailing\n"));
k->keepon &= ~KEEP_RECV;
break;
}
/* Default buffer to use when we write the buffer, it may be changed
in the flow below before the actual storing is done. */
- k->str = buf;
+ k->str = buf;
if(conn->handler->readwrite) {
result = conn->handler->readwrite(data, conn, &nread, &readmore);
@@ -693,7 +693,7 @@ static CURLcode readwrite_data(struct Curl_easy *data,
/* This is not an 'else if' since it may be a rest from the header
parsing, where the beginning of the buffer is headers and the end
is non-headers. */
- if(!k->header && (nread > 0 || is_empty_data)) {
+ if(!k->header && (nread > 0 || is_empty_data)) {
if(data->set.opt_no_body) {
/* data arrives although we want none, bail out */
@@ -724,7 +724,7 @@ static CURLcode readwrite_data(struct Curl_easy *data,
infof(data, "Ignoring the response-body\n");
}
if(data->state.resume_from && !k->content_range &&
- (data->state.httpreq == HTTPREQ_GET) &&
+ (data->state.httpreq == HTTPREQ_GET) &&
!k->ignorebody) {
if(k->size == data->state.resume_from) {
@@ -774,9 +774,9 @@ static CURLcode readwrite_data(struct Curl_easy *data,
/* pass data to the debug function before it gets "dechunked" */
if(data->set.verbose) {
if(k->badheader) {
- Curl_debug(data, CURLINFO_DATA_IN,
- Curl_dyn_ptr(&data->state.headerb),
- Curl_dyn_len(&data->state.headerb));
+ Curl_debug(data, CURLINFO_DATA_IN,
+ Curl_dyn_ptr(&data->state.headerb),
+ Curl_dyn_len(&data->state.headerb));
if(k->badheader == HEADER_PARTHEADER)
Curl_debug(data, CURLINFO_DATA_IN,
k->str, (size_t)nread);
@@ -794,14 +794,14 @@ static CURLcode readwrite_data(struct Curl_easy *data,
* and writes away the data. The returned 'nread' holds the number
* of actual data it wrote to the client.
*/
- CURLcode extra;
+ CURLcode extra;
CHUNKcode res =
- Curl_httpchunk_read(conn, k->str, nread, &nread, &extra);
+ Curl_httpchunk_read(conn, k->str, nread, &nread, &extra);
if(CHUNKE_OK < res) {
- if(CHUNKE_PASSTHRU_ERROR == res) {
- failf(data, "Failed reading the chunked-encoded stream");
- return extra;
+ if(CHUNKE_PASSTHRU_ERROR == res) {
+ failf(data, "Failed reading the chunked-encoded stream");
+ return extra;
}
failf(data, "%s in chunked-encoding", Curl_chunked_strerror(res));
return CURLE_RECV_ERROR;
@@ -827,9 +827,9 @@ static CURLcode readwrite_data(struct Curl_easy *data,
/* Account for body content stored in the header buffer */
if((k->badheader == HEADER_PARTHEADER) && !k->ignorebody) {
- size_t headlen = Curl_dyn_len(&data->state.headerb);
- DEBUGF(infof(data, "Increasing bytecount by %zu\n", headlen));
- k->bytecount += headlen;
+ size_t headlen = Curl_dyn_len(&data->state.headerb);
+ DEBUGF(infof(data, "Increasing bytecount by %zu\n", headlen));
+ k->bytecount += headlen;
}
if((-1 != k->maxdownload) &&
@@ -844,7 +844,7 @@ static CURLcode readwrite_data(struct Curl_easy *data,
", maxdownload = %" CURL_FORMAT_CURL_OFF_T
", bytecount = %" CURL_FORMAT_CURL_OFF_T "\n",
excess, k->size, k->maxdownload, k->bytecount);
- connclose(conn, "excess found in a read");
+ connclose(conn, "excess found in a read");
}
nread = (ssize_t) (k->maxdownload - k->bytecount);
@@ -864,16 +864,16 @@ static CURLcode readwrite_data(struct Curl_easy *data,
if(k->badheader && !k->ignorebody) {
/* we parsed a piece of data wrongly assuming it was a header
and now we output it as body instead */
- size_t headlen = Curl_dyn_len(&data->state.headerb);
+ size_t headlen = Curl_dyn_len(&data->state.headerb);
/* Don't let excess data pollute body writes */
- if(k->maxdownload == -1 || (curl_off_t)headlen <= k->maxdownload)
+ if(k->maxdownload == -1 || (curl_off_t)headlen <= k->maxdownload)
result = Curl_client_write(conn, CLIENTWRITE_BODY,
- Curl_dyn_ptr(&data->state.headerb),
- headlen);
+ Curl_dyn_ptr(&data->state.headerb),
+ headlen);
else
result = Curl_client_write(conn, CLIENTWRITE_BODY,
- Curl_dyn_ptr(&data->state.headerb),
+ Curl_dyn_ptr(&data->state.headerb),
(size_t)k->maxdownload);
if(result)
@@ -907,14 +907,14 @@ static CURLcode readwrite_data(struct Curl_easy *data,
} /* if(!header and data to read) */
- if(conn->handler->readwrite && excess) {
+ if(conn->handler->readwrite && excess) {
/* Parse the excess data */
k->str += nread;
- if(&k->str[excess] > &buf[data->set.buffer_size]) {
+ if(&k->str[excess] > &buf[data->set.buffer_size]) {
/* the excess amount was too excessive(!), make sure
it doesn't read out of buffer */
- excess = &buf[data->set.buffer_size] - k->str;
+ excess = &buf[data->set.buffer_size] - k->str;
}
nread = (ssize_t)excess;
@@ -938,7 +938,7 @@ static CURLcode readwrite_data(struct Curl_easy *data,
break;
}
- } while(data_pending(data) && maxloops--);
+ } while(data_pending(data) && maxloops--);
if(maxloops <= 0) {
/* we mark it as read-again-please */
@@ -1029,7 +1029,7 @@ static CURLcode readwrite_upload(struct Curl_easy *data,
/* HTTP pollution, this should be written nicer to become more
protocol agnostic. */
size_t fillcount;
- struct HTTP *http = k->p.http;
+ struct HTTP *http = k->p.http;
if((k->exp100 == EXP100_SENDING_REQUEST) &&
(http->sending == HTTPSEND_BODY)) {
@@ -1153,9 +1153,9 @@ static CURLcode readwrite_upload(struct Curl_easy *data,
win_update_buffer_size(conn->writesockfd);
- /* show the data before we change the pointer upload_fromhere */
- Curl_debug(data, CURLINFO_DATA_OUT, k->upload_fromhere,
- (size_t)bytes_written);
+ /* show the data before we change the pointer upload_fromhere */
+ Curl_debug(data, CURLINFO_DATA_OUT, k->upload_fromhere,
+ (size_t)bytes_written);
k->writebytecount += bytes_written;
Curl_pgrsSetUploadCounter(data, k->writebytecount);
@@ -1193,7 +1193,7 @@ static CURLcode readwrite_upload(struct Curl_easy *data,
}
- } while(0); /* just to break out from! */
+ } while(0); /* just to break out from! */
return CURLE_OK;
}
@@ -1250,7 +1250,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
/* We go ahead and do a read if we have a readable socket or if
the stream was rewound (in which case we have data in a
buffer) */
- if((k->keepon & KEEP_RECV) && (select_res & CURL_CSELECT_IN)) {
+ if((k->keepon & KEEP_RECV) && (select_res & CURL_CSELECT_IN)) {
result = readwrite_data(data, conn, k, &didwhat, done, comeback);
if(result || *done)
return result;
@@ -1445,16 +1445,16 @@ CURLcode Curl_pretransfer(struct Curl_easy *data)
if(!data->change.url && data->set.uh) {
CURLUcode uc;
- free(data->set.str[STRING_SET_URL]);
+ free(data->set.str[STRING_SET_URL]);
uc = curl_url_get(data->set.uh,
- CURLUPART_URL, &data->set.str[STRING_SET_URL], 0);
+ CURLUPART_URL, &data->set.str[STRING_SET_URL], 0);
if(uc) {
failf(data, "No URL set!");
return CURLE_URL_MALFORMAT;
}
}
- data->state.httpreq = data->set.method;
+ data->state.httpreq = data->set.method;
data->change.url = data->set.str[STRING_SET_URL];
/* Init the SSL session ID cache here. We do it here since we want to do it
@@ -1475,10 +1475,10 @@ CURLcode Curl_pretransfer(struct Curl_easy *data)
data->state.authproxy.want = data->set.proxyauth;
Curl_safefree(data->info.wouldredirect);
- if(data->state.httpreq == HTTPREQ_PUT)
+ if(data->state.httpreq == HTTPREQ_PUT)
data->state.infilesize = data->set.filesize;
- else if((data->state.httpreq != HTTPREQ_GET) &&
- (data->state.httpreq != HTTPREQ_HEAD)) {
+ else if((data->state.httpreq != HTTPREQ_GET) &&
+ (data->state.httpreq != HTTPREQ_HEAD)) {
data->state.infilesize = data->set.postfieldsize;
if(data->set.postfields && (data->state.infilesize == -1))
data->state.infilesize = (curl_off_t)strlen(data->set.postfields);
@@ -1528,8 +1528,8 @@ CURLcode Curl_pretransfer(struct Curl_easy *data)
}
}
#endif
- Curl_http2_init_state(&data->state);
- Curl_hsts_loadcb(data, data->hsts);
+ Curl_http2_init_state(&data->state);
+ Curl_hsts_loadcb(data, data->hsts);
}
return result;
@@ -1611,8 +1611,8 @@ CURLcode Curl_follow(struct Curl_easy *data,
DEBUGASSERT(data->state.uh);
uc = curl_url_set(data->state.uh, CURLUPART_URL, newurl,
- (type == FOLLOW_FAKE) ? CURLU_NON_SUPPORT_SCHEME :
- ((type == FOLLOW_REDIR) ? CURLU_URLENCODE : 0) );
+ (type == FOLLOW_FAKE) ? CURLU_NON_SUPPORT_SCHEME :
+ ((type == FOLLOW_REDIR) ? CURLU_URLENCODE : 0) );
if(uc) {
if(type != FOLLOW_FAKE)
return Curl_uc_to_curlcode(uc);
@@ -1690,12 +1690,12 @@ CURLcode Curl_follow(struct Curl_easy *data,
* This behaviour is forbidden by RFC1945 and the obsolete RFC2616, and
* can be overridden with CURLOPT_POSTREDIR.
*/
- if((data->state.httpreq == HTTPREQ_POST
- || data->state.httpreq == HTTPREQ_POST_FORM
- || data->state.httpreq == HTTPREQ_POST_MIME)
+ if((data->state.httpreq == HTTPREQ_POST
+ || data->state.httpreq == HTTPREQ_POST_FORM
+ || data->state.httpreq == HTTPREQ_POST_MIME)
&& !(data->set.keep_post & CURL_REDIR_POST_301)) {
infof(data, "Switch from POST to GET\n");
- data->state.httpreq = HTTPREQ_GET;
+ data->state.httpreq = HTTPREQ_GET;
}
break;
case 302: /* Found */
@@ -1715,29 +1715,29 @@ CURLcode Curl_follow(struct Curl_easy *data,
* This behaviour is forbidden by RFC1945 and the obsolete RFC2616, and
* can be overridden with CURLOPT_POSTREDIR.
*/
- if((data->state.httpreq == HTTPREQ_POST
- || data->state.httpreq == HTTPREQ_POST_FORM
- || data->state.httpreq == HTTPREQ_POST_MIME)
+ if((data->state.httpreq == HTTPREQ_POST
+ || data->state.httpreq == HTTPREQ_POST_FORM
+ || data->state.httpreq == HTTPREQ_POST_MIME)
&& !(data->set.keep_post & CURL_REDIR_POST_302)) {
infof(data, "Switch from POST to GET\n");
- data->state.httpreq = HTTPREQ_GET;
+ data->state.httpreq = HTTPREQ_GET;
}
break;
case 303: /* See Other */
- /* 'See Other' location is not the resource but a substitute for the
- * resource. In this case we switch the method to GET/HEAD, unless the
- * method is POST and the user specified to keep it as POST.
- * https://github.com/curl/curl/issues/5237#issuecomment-614641049
- */
- if(data->state.httpreq != HTTPREQ_GET &&
- ((data->state.httpreq != HTTPREQ_POST &&
- data->state.httpreq != HTTPREQ_POST_FORM &&
- data->state.httpreq != HTTPREQ_POST_MIME) ||
- !(data->set.keep_post & CURL_REDIR_POST_303))) {
- data->state.httpreq = HTTPREQ_GET;
- data->set.upload = false;
- infof(data, "Switch to %s\n",
+ /* 'See Other' location is not the resource but a substitute for the
+ * resource. In this case we switch the method to GET/HEAD, unless the
+ * method is POST and the user specified to keep it as POST.
+ * https://github.com/curl/curl/issues/5237#issuecomment-614641049
+ */
+ if(data->state.httpreq != HTTPREQ_GET &&
+ ((data->state.httpreq != HTTPREQ_POST &&
+ data->state.httpreq != HTTPREQ_POST_FORM &&
+ data->state.httpreq != HTTPREQ_POST_MIME) ||
+ !(data->set.keep_post & CURL_REDIR_POST_303))) {
+ data->state.httpreq = HTTPREQ_GET;
+ data->set.upload = false;
+ infof(data, "Switch to %s\n",
data->set.opt_no_body?"HEAD":"GET");
}
break;
@@ -1804,15 +1804,15 @@ CURLcode Curl_retry_request(struct connectdata *conn,
retry = TRUE;
}
if(retry) {
-#define CONN_MAX_RETRIES 5
- if(data->state.retrycount++ >= CONN_MAX_RETRIES) {
- failf(data, "Connection died, tried %d times before giving up",
- CONN_MAX_RETRIES);
- data->state.retrycount = 0;
- return CURLE_SEND_ERROR;
- }
- infof(conn->data, "Connection died, retrying a fresh connect\
-(retry count: %d)\n", data->state.retrycount);
+#define CONN_MAX_RETRIES 5
+ if(data->state.retrycount++ >= CONN_MAX_RETRIES) {
+ failf(data, "Connection died, tried %d times before giving up",
+ CONN_MAX_RETRIES);
+ data->state.retrycount = 0;
+ return CURLE_SEND_ERROR;
+ }
+ infof(conn->data, "Connection died, retrying a fresh connect\
+(retry count: %d)\n", data->state.retrycount);
*url = strdup(conn->data->change.url);
if(!*url)
return CURLE_OUT_OF_MEMORY;
@@ -1854,21 +1854,21 @@ Curl_setup_transfer(
{
struct SingleRequest *k = &data->req;
struct connectdata *conn = data->conn;
- struct HTTP *http = data->req.p.http;
- bool httpsending = ((conn->handler->protocol&PROTO_FAMILY_HTTP) &&
- (http->sending == HTTPSEND_REQUEST));
+ struct HTTP *http = data->req.p.http;
+ bool httpsending = ((conn->handler->protocol&PROTO_FAMILY_HTTP) &&
+ (http->sending == HTTPSEND_REQUEST));
DEBUGASSERT(conn != NULL);
DEBUGASSERT((sockindex <= 1) && (sockindex >= -1));
- if(conn->bits.multiplex || conn->httpversion == 20 || httpsending) {
+ if(conn->bits.multiplex || conn->httpversion == 20 || httpsending) {
/* when multiplexing, the read/write sockets need to be the same! */
conn->sockfd = sockindex == -1 ?
((writesockindex == -1 ? CURL_SOCKET_BAD : conn->sock[writesockindex])) :
conn->sock[sockindex];
conn->writesockfd = conn->sockfd;
- if(httpsending)
- /* special and very HTTP-specific */
- writesockindex = FIRSTSOCKET;
+ if(httpsending)
+ /* special and very HTTP-specific */
+ writesockindex = FIRSTSOCKET;
}
else {
conn->sockfd = sockindex == -1 ?
diff --git a/contrib/libs/curl/lib/transfer.h b/contrib/libs/curl/lib/transfer.h
index 482820e9b7..178bb58fb0 100644
--- a/contrib/libs/curl/lib/transfer.h
+++ b/contrib/libs/curl/lib/transfer.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/url.c b/contrib/libs/curl/lib/url.c
index b82b3f54db..95e37dfeed 100644
--- a/contrib/libs/curl/lib/url.c
+++ b/contrib/libs/curl/lib/url.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -96,7 +96,7 @@ bool curl_win32_idn_to_ascii(const char *in, char **out);
#include "getinfo.h"
#include "urlapi-int.h"
#include "system_win32.h"
-#include "hsts.h"
+#include "hsts.h"
/* And now for the protocols */
#include "ftp.h"
@@ -107,7 +107,7 @@ bool curl_win32_idn_to_ascii(const char *in, char **out);
#include "http2.h"
#include "file.h"
#include "curl_ldap.h"
-#include "vssh/ssh.h"
+#include "vssh/ssh.h"
#include "imap.h"
#include "url.h"
#include "connect.h"
@@ -115,7 +115,7 @@ bool curl_win32_idn_to_ascii(const char *in, char **out);
#include "http_ntlm.h"
#include "curl_rtmp.h"
#include "gopher.h"
-#include "mqtt.h"
+#include "mqtt.h"
#include "http_proxy.h"
#include "conncache.h"
#include "multihandle.h"
@@ -123,7 +123,7 @@ bool curl_win32_idn_to_ascii(const char *in, char **out);
#include "strdup.h"
#include "setopt.h"
#include "altsvc.h"
-#include "dynbuf.h"
+#include "dynbuf.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
@@ -140,37 +140,37 @@ static void conn_free(struct connectdata *conn);
# error READBUFFER_SIZE is too small
#endif
-/*
-* get_protocol_family()
-*
-* This is used to return the protocol family for a given protocol.
-*
-* Parameters:
-*
-* 'h' [in] - struct Curl_handler pointer.
-*
-* Returns the family as a single bit protocol identifier.
-*/
-static unsigned int get_protocol_family(const struct Curl_handler *h)
-{
- DEBUGASSERT(h);
- DEBUGASSERT(h->family);
- return h->family;
-}
-
-
/*
- * Protocol table. Schemes (roughly) in 2019 popularity order:
- *
- * HTTPS, HTTP, FTP, FTPS, SFTP, FILE, SCP, SMTP, LDAP, IMAPS, TELNET, IMAP,
- * LDAPS, SMTPS, TFTP, SMB, POP3, GOPHER POP3S, RTSP, RTMP, SMBS, DICT
+* get_protocol_family()
+*
+* This is used to return the protocol family for a given protocol.
+*
+* Parameters:
+*
+* 'h' [in] - struct Curl_handler pointer.
+*
+* Returns the family as a single bit protocol identifier.
+*/
+static unsigned int get_protocol_family(const struct Curl_handler *h)
+{
+ DEBUGASSERT(h);
+ DEBUGASSERT(h->family);
+ return h->family;
+}
+
+
+/*
+ * Protocol table. Schemes (roughly) in 2019 popularity order:
+ *
+ * HTTPS, HTTP, FTP, FTPS, SFTP, FILE, SCP, SMTP, LDAP, IMAPS, TELNET, IMAP,
+ * LDAPS, SMTPS, TFTP, SMB, POP3, GOPHER POP3S, RTSP, RTMP, SMBS, DICT
*/
static const struct Curl_handler * const protocols[] = {
-#if defined(USE_SSL) && !defined(CURL_DISABLE_HTTP)
- &Curl_handler_https,
-#endif
-
+#if defined(USE_SSL) && !defined(CURL_DISABLE_HTTP)
+ &Curl_handler_https,
+#endif
+
#ifndef CURL_DISABLE_HTTP
&Curl_handler_http,
#endif
@@ -183,25 +183,25 @@ static const struct Curl_handler * const protocols[] = {
&Curl_handler_ftps,
#endif
-#if defined(USE_SSH)
- &Curl_handler_sftp,
+#if defined(USE_SSH)
+ &Curl_handler_sftp,
+#endif
+
+#ifndef CURL_DISABLE_FILE
+ &Curl_handler_file,
#endif
-#ifndef CURL_DISABLE_FILE
- &Curl_handler_file,
+#if defined(USE_SSH) && !defined(USE_WOLFSSH)
+ &Curl_handler_scp,
+#endif
+
+#ifndef CURL_DISABLE_SMTP
+ &Curl_handler_smtp,
+#ifdef USE_SSL
+ &Curl_handler_smtps,
+#endif
#endif
-#if defined(USE_SSH) && !defined(USE_WOLFSSH)
- &Curl_handler_scp,
-#endif
-
-#ifndef CURL_DISABLE_SMTP
- &Curl_handler_smtp,
-#ifdef USE_SSL
- &Curl_handler_smtps,
-#endif
-#endif
-
#ifndef CURL_DISABLE_LDAP
&Curl_handler_ldap,
#if !defined(CURL_DISABLE_LDAPS) && \
@@ -211,19 +211,19 @@ static const struct Curl_handler * const protocols[] = {
#endif
#endif
-#ifndef CURL_DISABLE_IMAP
- &Curl_handler_imap,
-#ifdef USE_SSL
- &Curl_handler_imaps,
+#ifndef CURL_DISABLE_IMAP
+ &Curl_handler_imap,
+#ifdef USE_SSL
+ &Curl_handler_imaps,
#endif
#endif
-#ifndef CURL_DISABLE_TELNET
- &Curl_handler_telnet,
+#ifndef CURL_DISABLE_TELNET
+ &Curl_handler_telnet,
#endif
-#ifndef CURL_DISABLE_TFTP
- &Curl_handler_tftp,
+#ifndef CURL_DISABLE_TFTP
+ &Curl_handler_tftp,
#endif
#ifndef CURL_DISABLE_POP3
@@ -233,8 +233,8 @@ static const struct Curl_handler * const protocols[] = {
#endif
#endif
-#if !defined(CURL_DISABLE_SMB) && defined(USE_CURL_NTLM_CORE) && \
- (CURL_SIZEOF_CURL_OFF_T > 4)
+#if !defined(CURL_DISABLE_SMB) && defined(USE_CURL_NTLM_CORE) && \
+ (CURL_SIZEOF_CURL_OFF_T > 4)
&Curl_handler_smb,
#ifdef USE_SSL
&Curl_handler_smbs,
@@ -245,10 +245,10 @@ static const struct Curl_handler * const protocols[] = {
&Curl_handler_rtsp,
#endif
-#ifndef CURL_DISABLE_MQTT
- &Curl_handler_mqtt,
-#endif
-
+#ifndef CURL_DISABLE_MQTT
+ &Curl_handler_mqtt,
+#endif
+
#ifndef CURL_DISABLE_GOPHER
&Curl_handler_gopher,
#endif
@@ -262,10 +262,10 @@ static const struct Curl_handler * const protocols[] = {
&Curl_handler_rtmpts,
#endif
-#ifndef CURL_DISABLE_DICT
- &Curl_handler_dict,
-#endif
-
+#ifndef CURL_DISABLE_DICT
+ &Curl_handler_dict,
+#endif
+
(struct Curl_handler *) NULL
};
@@ -291,7 +291,7 @@ static const struct Curl_handler Curl_handler_dummy = {
ZERO_NULL, /* connection_check */
0, /* defport */
0, /* protocol */
- 0, /* family */
+ 0, /* family */
PROTOPT_NONE /* flags */
};
@@ -299,16 +299,16 @@ void Curl_freeset(struct Curl_easy *data)
{
/* Free all dynamic strings stored in the data->set substructure. */
enum dupstring i;
- enum dupblob j;
-
+ enum dupblob j;
+
for(i = (enum dupstring)0; i < STRING_LAST; i++) {
Curl_safefree(data->set.str[i]);
}
- for(j = (enum dupblob)0; j < BLOB_LAST; j++) {
- Curl_safefree(data->set.blobs[j]);
- }
-
+ for(j = (enum dupblob)0; j < BLOB_LAST; j++) {
+ Curl_safefree(data->set.blobs[j]);
+ }
+
if(data->change.referer_alloc) {
Curl_safefree(data->change.referer);
data->change.referer_alloc = FALSE;
@@ -348,17 +348,17 @@ static void up_free(struct Curl_easy *data)
* when curl_easy_perform() is invoked.
*/
-CURLcode Curl_close(struct Curl_easy **datap)
+CURLcode Curl_close(struct Curl_easy **datap)
{
struct Curl_multi *m;
- struct Curl_easy *data;
+ struct Curl_easy *data;
- if(!datap || !*datap)
+ if(!datap || !*datap)
return CURLE_OK;
- data = *datap;
- *datap = NULL;
-
+ data = *datap;
+ *datap = NULL;
+
Curl_expire_clear(data); /* shut off timers */
m = data->multi;
@@ -407,13 +407,13 @@ CURLcode Curl_close(struct Curl_easy **datap)
up_free(data);
Curl_safefree(data->state.buffer);
- Curl_dyn_free(&data->state.headerb);
+ Curl_dyn_free(&data->state.headerb);
Curl_safefree(data->state.ulbuf);
- Curl_flush_cookies(data, TRUE);
- Curl_altsvc_save(data, data->asi, data->set.str[STRING_ALTSVC]);
- Curl_altsvc_cleanup(&data->asi);
- Curl_hsts_save(data, data->hsts, data->set.str[STRING_HSTS]);
- Curl_hsts_cleanup(&data->hsts);
+ Curl_flush_cookies(data, TRUE);
+ Curl_altsvc_save(data, data->asi, data->set.str[STRING_ALTSVC]);
+ Curl_altsvc_cleanup(&data->asi);
+ Curl_hsts_save(data, data->hsts, data->set.str[STRING_HSTS]);
+ Curl_hsts_cleanup(&data->hsts);
#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_CRYPTO_AUTH)
Curl_http_auth_cleanup_digest(data);
#endif
@@ -433,23 +433,23 @@ CURLcode Curl_close(struct Curl_easy **datap)
Curl_share_unlock(data, CURL_LOCK_DATA_SHARE);
}
- Curl_safefree(data->state.aptr.proxyuserpwd);
- Curl_safefree(data->state.aptr.uagent);
- Curl_safefree(data->state.aptr.userpwd);
- Curl_safefree(data->state.aptr.accept_encoding);
- Curl_safefree(data->state.aptr.te);
- Curl_safefree(data->state.aptr.rangeline);
- Curl_safefree(data->state.aptr.ref);
- Curl_safefree(data->state.aptr.host);
- Curl_safefree(data->state.aptr.cookiehost);
- Curl_safefree(data->state.aptr.rtsp_transport);
-
-#ifndef CURL_DISABLE_DOH
- Curl_dyn_free(&data->req.doh.probe[0].serverdoh);
- Curl_dyn_free(&data->req.doh.probe[1].serverdoh);
- curl_slist_free_all(data->req.doh.headers);
-#endif
-
+ Curl_safefree(data->state.aptr.proxyuserpwd);
+ Curl_safefree(data->state.aptr.uagent);
+ Curl_safefree(data->state.aptr.userpwd);
+ Curl_safefree(data->state.aptr.accept_encoding);
+ Curl_safefree(data->state.aptr.te);
+ Curl_safefree(data->state.aptr.rangeline);
+ Curl_safefree(data->state.aptr.ref);
+ Curl_safefree(data->state.aptr.host);
+ Curl_safefree(data->state.aptr.cookiehost);
+ Curl_safefree(data->state.aptr.rtsp_transport);
+
+#ifndef CURL_DISABLE_DOH
+ Curl_dyn_free(&data->req.doh.probe[0].serverdoh);
+ Curl_dyn_free(&data->req.doh.probe[1].serverdoh);
+ curl_slist_free_all(data->req.doh.headers);
+#endif
+
/* destruct wildcard structures if it is needed */
Curl_wildcard_dtor(&data->wildcard);
Curl_freeset(data);
@@ -490,14 +490,14 @@ CURLcode Curl_init_userdefined(struct Curl_easy *data)
set->postfieldsize = -1; /* unknown size */
set->maxredirs = -1; /* allow any amount by default */
- set->method = HTTPREQ_GET; /* Default HTTP request */
+ set->method = HTTPREQ_GET; /* Default HTTP request */
set->rtspreq = RTSPREQ_OPTIONS; /* Default RTSP request */
#ifndef CURL_DISABLE_FTP
set->ftp_use_epsv = TRUE; /* FTP defaults to EPSV operations */
set->ftp_use_eprt = TRUE; /* FTP defaults to EPRT operations */
set->ftp_use_pret = FALSE; /* mainly useful for drftpd servers */
set->ftp_filemethod = FTPFILE_MULTICWD;
- set->ftp_skip_ip = TRUE; /* skip PASV IP by default */
+ set->ftp_skip_ip = TRUE; /* skip PASV IP by default */
#endif
set->dns_cache_timeout = 60; /* Timeout every 60 seconds by default */
@@ -530,9 +530,9 @@ CURLcode Curl_init_userdefined(struct Curl_easy *data)
type */
set->ssl.primary.sessionid = TRUE; /* session ID caching enabled by
default */
-#ifndef CURL_DISABLE_PROXY
+#ifndef CURL_DISABLE_PROXY
set->proxy_ssl = set->ssl;
-#endif
+#endif
set->new_file_perms = 0644; /* Default permissions */
set->new_directory_perms = 0755; /* Default permissions */
@@ -641,22 +641,22 @@ CURLcode Curl_open(struct Curl_easy **curl)
return result;
}
- result = Curl_init_userdefined(data);
- if(!result) {
- Curl_dyn_init(&data->state.headerb, CURL_MAX_HTTP_HEADER);
- Curl_convert_init(data);
- Curl_initinfo(data);
+ result = Curl_init_userdefined(data);
+ if(!result) {
+ Curl_dyn_init(&data->state.headerb, CURL_MAX_HTTP_HEADER);
+ Curl_convert_init(data);
+ Curl_initinfo(data);
- /* most recent connection is not yet defined */
- data->state.lastconnect_id = -1;
+ /* most recent connection is not yet defined */
+ data->state.lastconnect_id = -1;
- data->progress.flags |= PGRS_HIDE;
- data->state.current_speed = -1; /* init to negative == impossible */
+ data->progress.flags |= PGRS_HIDE;
+ data->state.current_speed = -1; /* init to negative == impossible */
}
if(result) {
Curl_resolver_cleanup(data->state.resolver);
- Curl_dyn_free(&data->state.headerb);
+ Curl_dyn_free(&data->state.headerb);
Curl_freeset(data);
free(data);
data = NULL;
@@ -702,13 +702,13 @@ static void conn_reset_all_postponed_data(struct connectdata *conn)
}
#else /* ! USE_RECV_BEFORE_SEND_WORKAROUND */
/* Use "do-nothing" macro instead of function when workaround not used */
-#define conn_reset_all_postponed_data(c) do {} while(0)
+#define conn_reset_all_postponed_data(c) do {} while(0)
#endif /* ! USE_RECV_BEFORE_SEND_WORKAROUND */
static void conn_shutdown(struct connectdata *conn)
{
- DEBUGASSERT(conn);
+ DEBUGASSERT(conn);
infof(conn->data, "Closing connection %ld\n", conn->connection_id);
DEBUGASSERT(conn->data);
@@ -733,26 +733,26 @@ static void conn_shutdown(struct connectdata *conn)
static void conn_free(struct connectdata *conn)
{
- DEBUGASSERT(conn);
-
- Curl_free_idnconverted_hostname(&conn->host);
- Curl_free_idnconverted_hostname(&conn->conn_to_host);
-#ifndef CURL_DISABLE_PROXY
- Curl_free_idnconverted_hostname(&conn->http_proxy.host);
- Curl_free_idnconverted_hostname(&conn->socks_proxy.host);
- Curl_safefree(conn->http_proxy.user);
- Curl_safefree(conn->socks_proxy.user);
- Curl_safefree(conn->http_proxy.passwd);
- Curl_safefree(conn->socks_proxy.passwd);
- Curl_safefree(conn->http_proxy.host.rawalloc); /* http proxy name buffer */
- Curl_safefree(conn->socks_proxy.host.rawalloc); /* socks proxy name buffer */
- Curl_free_primary_ssl_config(&conn->proxy_ssl_config);
-#endif
+ DEBUGASSERT(conn);
+
+ Curl_free_idnconverted_hostname(&conn->host);
+ Curl_free_idnconverted_hostname(&conn->conn_to_host);
+#ifndef CURL_DISABLE_PROXY
+ Curl_free_idnconverted_hostname(&conn->http_proxy.host);
+ Curl_free_idnconverted_hostname(&conn->socks_proxy.host);
+ Curl_safefree(conn->http_proxy.user);
+ Curl_safefree(conn->socks_proxy.user);
+ Curl_safefree(conn->http_proxy.passwd);
+ Curl_safefree(conn->socks_proxy.passwd);
+ Curl_safefree(conn->http_proxy.host.rawalloc); /* http proxy name buffer */
+ Curl_safefree(conn->socks_proxy.host.rawalloc); /* socks proxy name buffer */
+ Curl_free_primary_ssl_config(&conn->proxy_ssl_config);
+#endif
Curl_safefree(conn->user);
Curl_safefree(conn->passwd);
Curl_safefree(conn->sasl_authzid);
Curl_safefree(conn->options);
- Curl_dyn_free(&conn->trailer);
+ Curl_dyn_free(&conn->trailer);
Curl_safefree(conn->host.rawalloc); /* host name buffer */
Curl_safefree(conn->conn_to_host.rawalloc); /* host name buffer */
Curl_safefree(conn->hostname_resolve);
@@ -791,18 +791,18 @@ static void conn_free(struct connectdata *conn)
CURLcode Curl_disconnect(struct Curl_easy *data,
struct connectdata *conn, bool dead_connection)
{
- /* there must be a connection to close */
- DEBUGASSERT(conn);
-
- /* it must be removed from the connection cache */
- DEBUGASSERT(!conn->bundle);
-
- /* there must be an associated transfer */
- DEBUGASSERT(data);
-
- /* the transfer must be detached from the connection */
- DEBUGASSERT(!data->conn);
-
+ /* there must be a connection to close */
+ DEBUGASSERT(conn);
+
+ /* it must be removed from the connection cache */
+ DEBUGASSERT(!conn->bundle);
+
+ /* there must be an associated transfer */
+ DEBUGASSERT(data);
+
+ /* the transfer must be detached from the connection */
+ DEBUGASSERT(!data->conn);
+
/*
* If this connection isn't marked to force-close, leave it open if there
* are other users of it
@@ -819,7 +819,7 @@ CURLcode Curl_disconnect(struct Curl_easy *data,
/* Cleanup NTLM connection-related data */
Curl_http_auth_cleanup_ntlm(conn);
-
+
/* Cleanup NEGOTIATE connection-related data */
Curl_http_auth_cleanup_negotiate(conn);
@@ -883,8 +883,8 @@ static int IsMultiplexingPossible(const struct Curl_easy *handle,
#ifndef CURL_DISABLE_PROXY
static bool
-proxy_info_matches(const struct proxy_info *data,
- const struct proxy_info *needle)
+proxy_info_matches(const struct proxy_info *data,
+ const struct proxy_info *needle)
{
if((data->proxytype == needle->proxytype) &&
(data->port == needle->port) &&
@@ -893,37 +893,37 @@ proxy_info_matches(const struct proxy_info *data,
return FALSE;
}
-
-static bool
-socks_proxy_info_matches(const struct proxy_info *data,
- const struct proxy_info *needle)
-{
- if(!proxy_info_matches(data, needle))
- return FALSE;
-
- /* the user information is case-sensitive
- or at least it is not defined as case-insensitive
- see https://tools.ietf.org/html/rfc3986#section-3.2.1 */
- if((data->user == NULL) != (needle->user == NULL))
- return FALSE;
- /* curl_strequal does a case insentive comparison, so do not use it here! */
- if(data->user &&
- needle->user &&
- strcmp(data->user, needle->user) != 0)
- return FALSE;
- if((data->passwd == NULL) != (needle->passwd == NULL))
- return FALSE;
- /* curl_strequal does a case insentive comparison, so do not use it here! */
- if(data->passwd &&
- needle->passwd &&
- strcmp(data->passwd, needle->passwd) != 0)
- return FALSE;
- return TRUE;
-}
+
+static bool
+socks_proxy_info_matches(const struct proxy_info *data,
+ const struct proxy_info *needle)
+{
+ if(!proxy_info_matches(data, needle))
+ return FALSE;
+
+ /* the user information is case-sensitive
+ or at least it is not defined as case-insensitive
+ see https://tools.ietf.org/html/rfc3986#section-3.2.1 */
+ if((data->user == NULL) != (needle->user == NULL))
+ return FALSE;
+ /* curl_strequal does a case insentive comparison, so do not use it here! */
+ if(data->user &&
+ needle->user &&
+ strcmp(data->user, needle->user) != 0)
+ return FALSE;
+ if((data->passwd == NULL) != (needle->passwd == NULL))
+ return FALSE;
+ /* curl_strequal does a case insentive comparison, so do not use it here! */
+ if(data->passwd &&
+ needle->passwd &&
+ strcmp(data->passwd, needle->passwd) != 0)
+ return FALSE;
+ return TRUE;
+}
#else
/* disabled, won't get called */
#define proxy_info_matches(x,y) FALSE
-#define socks_proxy_info_matches(x,y) FALSE
+#define socks_proxy_info_matches(x,y) FALSE
#endif
/* A connection has to have been idle for a shorter time than 'maxage_conn' to
@@ -1018,12 +1018,12 @@ static int call_extract_if_dead(struct connectdata *conn, void *param)
static void prune_dead_connections(struct Curl_easy *data)
{
struct curltime now = Curl_now();
- timediff_t elapsed;
-
- CONNCACHE_LOCK(data);
- elapsed =
+ timediff_t elapsed;
+
+ CONNCACHE_LOCK(data);
+ elapsed =
Curl_timediff(now, data->state.conn_cache->last_cleanup);
- CONNCACHE_UNLOCK(data);
+ CONNCACHE_UNLOCK(data);
if(elapsed >= 1000L) {
struct prunedead prune;
@@ -1031,17 +1031,17 @@ static void prune_dead_connections(struct Curl_easy *data)
prune.extracted = NULL;
while(Curl_conncache_foreach(data, data->state.conn_cache, &prune,
call_extract_if_dead)) {
- /* unlocked */
-
- /* remove connection from cache */
- Curl_conncache_remove_conn(data, prune.extracted, TRUE);
-
+ /* unlocked */
+
+ /* remove connection from cache */
+ Curl_conncache_remove_conn(data, prune.extracted, TRUE);
+
/* disconnect it */
- (void)Curl_disconnect(data, prune.extracted, TRUE);
+ (void)Curl_disconnect(data, prune.extracted, TRUE);
}
- CONNCACHE_LOCK(data);
+ CONNCACHE_LOCK(data);
data->state.conn_cache->last_cleanup = now;
- CONNCACHE_UNLOCK(data);
+ CONNCACHE_UNLOCK(data);
}
}
@@ -1074,15 +1074,15 @@ ConnectionExists(struct Curl_easy *data,
bool wantNTLMhttp = ((data->state.authhost.want &
(CURLAUTH_NTLM | CURLAUTH_NTLM_WB)) &&
(needle->handler->protocol & PROTO_FAMILY_HTTP));
-#ifndef CURL_DISABLE_PROXY
+#ifndef CURL_DISABLE_PROXY
bool wantProxyNTLMhttp = (needle->bits.proxy_user_passwd &&
((data->state.authproxy.want &
(CURLAUTH_NTLM | CURLAUTH_NTLM_WB)) &&
(needle->handler->protocol & PROTO_FAMILY_HTTP)));
-#else
- bool wantProxyNTLMhttp = FALSE;
+#else
+ bool wantProxyNTLMhttp = FALSE;
+#endif
#endif
-#endif
*force_reuse = FALSE;
*waitpipe = FALSE;
@@ -1093,7 +1093,7 @@ ConnectionExists(struct Curl_easy *data,
&hostbundle);
if(bundle) {
/* Max pipe length is zero (unlimited) for multiplexed connections */
- struct Curl_llist_element *curr;
+ struct Curl_llist_element *curr;
infof(data, "Found bundle for host %s: %p [%s]\n",
hostbundle, (void *)bundle, (bundle->multiuse == BUNDLE_MULTIPLEX ?
@@ -1102,10 +1102,10 @@ ConnectionExists(struct Curl_easy *data,
/* We can't multiplex if we don't know anything about the server */
if(canmultiplex) {
if(bundle->multiuse == BUNDLE_UNKNOWN) {
- if(data->set.pipewait) {
+ if(data->set.pipewait) {
infof(data, "Server doesn't support multiplex yet, wait\n");
*waitpipe = TRUE;
- CONNCACHE_UNLOCK(data);
+ CONNCACHE_UNLOCK(data);
return FALSE; /* no re-use */
}
@@ -1126,7 +1126,7 @@ ConnectionExists(struct Curl_easy *data,
curr = bundle->conn_list.head;
while(curr) {
bool match = FALSE;
- size_t multiplexed = 0;
+ size_t multiplexed = 0;
/*
* Note that if we use a HTTP proxy in normal mode (no tunneling), we
@@ -1135,21 +1135,21 @@ ConnectionExists(struct Curl_easy *data,
check = curr->ptr;
curr = curr->next;
- if(check->bits.connect_only || check->bits.close)
- /* connect-only or to-be-closed connections will not be reused */
+ if(check->bits.connect_only || check->bits.close)
+ /* connect-only or to-be-closed connections will not be reused */
continue;
- if(extract_if_dead(check, data)) {
- /* disconnect it */
- (void)Curl_disconnect(data, check, TRUE);
- continue;
- }
+ if(extract_if_dead(check, data)) {
+ /* disconnect it */
+ (void)Curl_disconnect(data, check, TRUE);
+ continue;
+ }
+
+ if(bundle->multiuse == BUNDLE_MULTIPLEX)
+ multiplexed = CONN_INUSE(check);
- if(bundle->multiuse == BUNDLE_MULTIPLEX)
- multiplexed = CONN_INUSE(check);
-
if(canmultiplex) {
- ;
+ ;
}
else {
if(multiplexed) {
@@ -1169,9 +1169,9 @@ ConnectionExists(struct Curl_easy *data,
}
}
- if(check->sock[FIRSTSOCKET] == CURL_SOCKET_BAD) {
- foundPendingCandidate = TRUE;
- /* Don't pick a connection that hasn't connected yet */
+ if(check->sock[FIRSTSOCKET] == CURL_SOCKET_BAD) {
+ foundPendingCandidate = TRUE;
+ /* Don't pick a connection that hasn't connected yet */
infof(data, "Connection #%ld isn't open enough, can't reuse\n",
check->connection_id);
continue;
@@ -1184,8 +1184,8 @@ ConnectionExists(struct Curl_easy *data,
continue;
if(strcmp(needle->unix_domain_socket, check->unix_domain_socket))
continue;
- if(needle->bits.abstract_unix_socket !=
- check->bits.abstract_unix_socket)
+ if(needle->bits.abstract_unix_socket !=
+ check->bits.abstract_unix_socket)
continue;
}
else if(check->unix_domain_socket)
@@ -1195,21 +1195,21 @@ ConnectionExists(struct Curl_easy *data,
if((needle->handler->flags&PROTOPT_SSL) !=
(check->handler->flags&PROTOPT_SSL))
/* don't do mixed SSL and non-SSL connections */
- if(get_protocol_family(check->handler) !=
- needle->handler->protocol || !check->bits.tls_upgraded)
+ if(get_protocol_family(check->handler) !=
+ needle->handler->protocol || !check->bits.tls_upgraded)
/* except protocols that have been upgraded via TLS */
continue;
-#ifndef CURL_DISABLE_PROXY
+#ifndef CURL_DISABLE_PROXY
if(needle->bits.httpproxy != check->bits.httpproxy ||
needle->bits.socksproxy != check->bits.socksproxy)
continue;
- if(needle->bits.socksproxy &&
- !socks_proxy_info_matches(&needle->socks_proxy,
- &check->socks_proxy))
+ if(needle->bits.socksproxy &&
+ !socks_proxy_info_matches(&needle->socks_proxy,
+ &check->socks_proxy))
continue;
-#endif
+#endif
if(needle->bits.conn_to_host != check->bits.conn_to_host)
/* don't mix connections that use the "connect to host" feature and
* connections that don't use this feature */
@@ -1220,7 +1220,7 @@ ConnectionExists(struct Curl_easy *data,
* connections that don't use this feature */
continue;
-#ifndef CURL_DISABLE_PROXY
+#ifndef CURL_DISABLE_PROXY
if(needle->bits.httpproxy) {
if(!proxy_info_matches(&needle->http_proxy, &check->http_proxy))
continue;
@@ -1247,7 +1247,7 @@ ConnectionExists(struct Curl_easy *data,
}
}
}
-#endif
+#endif
DEBUGASSERT(!check->data || GOOD_EASY_HANDLE(check->data));
@@ -1256,7 +1256,7 @@ ConnectionExists(struct Curl_easy *data,
already in use so we skip it */
continue;
- if(check->data && (check->data->multi != needle->data->multi))
+ if(check->data && (check->data->multi != needle->data->multi))
/* this could be subject for multiplex use, but only if they belong to
* the same multi handle */
continue;
@@ -1290,25 +1290,25 @@ ConnectionExists(struct Curl_easy *data,
}
}
- if((needle->handler->flags&PROTOPT_SSL)
-#ifndef CURL_DISABLE_PROXY
- || !needle->bits.httpproxy || needle->bits.tunnel_proxy
-#endif
- ) {
+ if((needle->handler->flags&PROTOPT_SSL)
+#ifndef CURL_DISABLE_PROXY
+ || !needle->bits.httpproxy || needle->bits.tunnel_proxy
+#endif
+ ) {
/* The requested connection does not use a HTTP proxy or it uses SSL or
it is a non-SSL protocol tunneled or it is a non-SSL protocol which
is allowed to be upgraded via TLS */
if((strcasecompare(needle->handler->scheme, check->handler->scheme) ||
- (get_protocol_family(check->handler) ==
- needle->handler->protocol && check->bits.tls_upgraded)) &&
+ (get_protocol_family(check->handler) ==
+ needle->handler->protocol && check->bits.tls_upgraded)) &&
(!needle->bits.conn_to_host || strcasecompare(
needle->conn_to_host.name, check->conn_to_host.name)) &&
(!needle->bits.conn_to_port ||
needle->conn_to_port == check->conn_to_port) &&
strcasecompare(needle->host.name, check->host.name) &&
needle->remote_port == check->remote_port) {
- /* The schemes match or the protocol family is the same and the
+ /* The schemes match or the protocol family is the same and the
previous connection was TLS upgraded, and the hostname and host
port match */
if(needle->handler->flags & PROTOPT_SSL) {
@@ -1349,21 +1349,21 @@ ConnectionExists(struct Curl_easy *data,
partway through a handshake!) */
if(wantNTLMhttp) {
if(strcmp(needle->user, check->user) ||
- strcmp(needle->passwd, check->passwd)) {
-
- /* we prefer a credential match, but this is at least a connection
- that can be reused and "upgraded" to NTLM */
- if(check->http_ntlm_state == NTLMSTATE_NONE)
- chosen = check;
+ strcmp(needle->passwd, check->passwd)) {
+
+ /* we prefer a credential match, but this is at least a connection
+ that can be reused and "upgraded" to NTLM */
+ if(check->http_ntlm_state == NTLMSTATE_NONE)
+ chosen = check;
continue;
- }
+ }
}
else if(check->http_ntlm_state != NTLMSTATE_NONE) {
/* Connection is using NTLM auth but we don't want NTLM */
continue;
}
-#ifndef CURL_DISABLE_PROXY
+#ifndef CURL_DISABLE_PROXY
/* Same for Proxy NTLM authentication */
if(wantProxyNTLMhttp) {
/* Both check->http_proxy.user and check->http_proxy.passwd can be
@@ -1379,7 +1379,7 @@ ConnectionExists(struct Curl_easy *data,
/* Proxy connection is using NTLM auth but we don't want NTLM */
continue;
}
-#endif
+#endif
if(wantNTLMhttp || wantProxyNTLMhttp) {
/* Credentials are already checked, we can use this connection */
chosen = check;
@@ -1417,13 +1417,13 @@ ConnectionExists(struct Curl_easy *data,
multiplexed);
continue;
}
- else if(multiplexed >=
- Curl_multi_max_concurrent_streams(needle->data->multi)) {
- infof(data, "client side MAX_CONCURRENT_STREAMS reached"
- ", skip (%zu)\n",
- multiplexed);
- continue;
- }
+ else if(multiplexed >=
+ Curl_multi_max_concurrent_streams(needle->data->multi)) {
+ infof(data, "client side MAX_CONCURRENT_STREAMS reached"
+ ", skip (%zu)\n",
+ multiplexed);
+ continue;
+ }
}
#endif
/* When not multiplexed, we have a match here! */
@@ -1443,12 +1443,12 @@ ConnectionExists(struct Curl_easy *data,
if(chosen) {
/* mark it as used before releasing the lock */
chosen->data = data; /* own it! */
- Curl_attach_connnection(data, chosen);
- CONNCACHE_UNLOCK(data);
+ Curl_attach_connnection(data, chosen);
+ CONNCACHE_UNLOCK(data);
*usethis = chosen;
return TRUE; /* yes, we found one to use! */
}
- CONNCACHE_UNLOCK(data);
+ CONNCACHE_UNLOCK(data);
if(foundPendingCandidate && data->set.pipewait) {
infof(data,
@@ -1467,10 +1467,10 @@ void Curl_verboseconnect(struct connectdata *conn)
{
if(conn->data->set.verbose)
infof(conn->data, "Connected to %s (%s) port %ld (#%ld)\n",
-#ifndef CURL_DISABLE_PROXY
+#ifndef CURL_DISABLE_PROXY
conn->bits.socksproxy ? conn->socks_proxy.host.dispname :
conn->bits.httpproxy ? conn->http_proxy.host.dispname :
-#endif
+#endif
conn->bits.conn_to_host ? conn->conn_to_host.dispname :
conn->host.dispname,
conn->ip_addr_str, conn->port, conn->connection_id);
@@ -1480,14 +1480,14 @@ void Curl_verboseconnect(struct connectdata *conn)
/*
* Helpers for IDNA conversions.
*/
-bool Curl_is_ASCII_name(const char *hostname)
+bool Curl_is_ASCII_name(const char *hostname)
{
- /* get an UNSIGNED local version of the pointer */
+ /* get an UNSIGNED local version of the pointer */
const unsigned char *ch = (const unsigned char *)hostname;
- if(!hostname) /* bad input, consider it ASCII! */
- return TRUE;
-
+ if(!hostname) /* bad input, consider it ASCII! */
+ return TRUE;
+
while(*ch) {
if(*ch++ & 0x80)
return FALSE;
@@ -1512,8 +1512,8 @@ static void strip_trailing_dot(struct hostname *host)
/*
* Perform any necessary IDN conversion of hostname
*/
-CURLcode Curl_idnconvert_hostname(struct connectdata *conn,
- struct hostname *host)
+CURLcode Curl_idnconvert_hostname(struct connectdata *conn,
+ struct hostname *host)
{
struct Curl_easy *data = conn->data;
@@ -1528,7 +1528,7 @@ CURLcode Curl_idnconvert_hostname(struct connectdata *conn,
host->dispname = host->name;
/* Check name for non-ASCII and convert hostname to ACE form if we can */
- if(!Curl_is_ASCII_name(host->name)) {
+ if(!Curl_is_ASCII_name(host->name)) {
#ifdef USE_LIBIDN2
if(idn2_check_version(IDN2_VERSION)) {
char *ace_hostname = NULL;
@@ -1561,9 +1561,9 @@ CURLcode Curl_idnconvert_hostname(struct connectdata *conn,
host->name = host->encalloc;
}
else {
- char buffer[STRERROR_LEN];
- failf(data, "Failed to convert %s to ACE; %s\n", host->name,
- Curl_winapi_strerror(GetLastError(), buffer, sizeof(buffer)));
+ char buffer[STRERROR_LEN];
+ failf(data, "Failed to convert %s to ACE; %s\n", host->name,
+ Curl_winapi_strerror(GetLastError(), buffer, sizeof(buffer)));
return CURLE_URL_MALFORMAT;
}
#else
@@ -1576,7 +1576,7 @@ CURLcode Curl_idnconvert_hostname(struct connectdata *conn,
/*
* Frees data allocated by idnconvert_hostname()
*/
-void Curl_free_idnconverted_hostname(struct hostname *host)
+void Curl_free_idnconverted_hostname(struct hostname *host)
{
#if defined(USE_LIBIDN2)
if(host->encalloc) {
@@ -1617,10 +1617,10 @@ static struct connectdata *allocate_conn(struct Curl_easy *data)
conn->ssl_extra = ssl;
conn->ssl[0].backend = (void *)ssl;
conn->ssl[1].backend = (void *)(ssl + sslsize);
-#ifndef CURL_DISABLE_PROXY
+#ifndef CURL_DISABLE_PROXY
conn->proxy_ssl[0].backend = (void *)(ssl + 2 * sslsize);
conn->proxy_ssl[1].backend = (void *)(ssl + 3 * sslsize);
-#endif
+#endif
}
#endif
@@ -1659,7 +1659,7 @@ static struct connectdata *allocate_conn(struct Curl_easy *data)
conn->data = data; /* Setup the association between this connection
and the Curl_easy */
-#ifndef CURL_DISABLE_PROXY
+#ifndef CURL_DISABLE_PROXY
conn->http_proxy.proxytype = data->set.proxytype;
conn->socks_proxy.proxytype = CURLPROXY_SOCKS4;
@@ -1693,20 +1693,20 @@ static struct connectdata *allocate_conn(struct Curl_easy *data)
conn->ssl_config.verifystatus = data->set.ssl.primary.verifystatus;
conn->ssl_config.verifypeer = data->set.ssl.primary.verifypeer;
conn->ssl_config.verifyhost = data->set.ssl.primary.verifyhost;
-#ifndef CURL_DISABLE_PROXY
+#ifndef CURL_DISABLE_PROXY
conn->proxy_ssl_config.verifystatus =
data->set.proxy_ssl.primary.verifystatus;
conn->proxy_ssl_config.verifypeer = data->set.proxy_ssl.primary.verifypeer;
conn->proxy_ssl_config.verifyhost = data->set.proxy_ssl.primary.verifyhost;
-#endif
+#endif
conn->ip_version = data->set.ipver;
conn->bits.connect_only = data->set.connect_only;
conn->transport = TRNSPRT_TCP; /* most of them are TCP streams */
#if !defined(CURL_DISABLE_HTTP) && defined(USE_NTLM) && \
defined(NTLM_WB_ENABLED)
- conn->ntlm.ntlm_auth_hlpr_socket = CURL_SOCKET_BAD;
- conn->proxyntlm.ntlm_auth_hlpr_socket = CURL_SOCKET_BAD;
+ conn->ntlm.ntlm_auth_hlpr_socket = CURL_SOCKET_BAD;
+ conn->proxyntlm.ntlm_auth_hlpr_socket = CURL_SOCKET_BAD;
#endif
/* Initialize the easy handle list */
@@ -1729,7 +1729,7 @@ static struct connectdata *allocate_conn(struct Curl_easy *data)
it may live on without (this specific) Curl_easy */
conn->fclosesocket = data->set.fclosesocket;
conn->closesocket_client = data->set.closesocket_client;
- conn->lastused = Curl_now(); /* used now */
+ conn->lastused = Curl_now(); /* used now */
return conn;
error:
@@ -1860,12 +1860,12 @@ static CURLcode parseurlandfillconn(struct Curl_easy *data,
CURLU *uh;
CURLUcode uc;
char *hostname;
- bool use_set_uh = (data->set.uh && !data->state.this_is_a_follow);
+ bool use_set_uh = (data->set.uh && !data->state.this_is_a_follow);
up_free(data); /* cleanup previous leftovers first */
/* parse the URL */
- if(use_set_uh) {
+ if(use_set_uh) {
uh = data->state.uh = curl_url_dup(data->set.uh);
}
else {
@@ -1888,8 +1888,8 @@ static CURLcode parseurlandfillconn(struct Curl_easy *data,
data->change.url_alloc = TRUE;
}
- if(!use_set_uh) {
- char *newurl;
+ if(!use_set_uh) {
+ char *newurl;
uc = curl_url_set(uh, CURLUPART_URL, data->change.url,
CURLU_GUESS_SCHEME |
CURLU_NON_SUPPORT_SCHEME |
@@ -1900,82 +1900,82 @@ static CURLcode parseurlandfillconn(struct Curl_easy *data,
DEBUGF(infof(data, "curl_url_set rejected %s\n", data->change.url));
return Curl_uc_to_curlcode(uc);
}
-
- /* after it was parsed, get the generated normalized version */
- uc = curl_url_get(uh, CURLUPART_URL, &newurl, 0);
- if(uc)
- return Curl_uc_to_curlcode(uc);
- if(data->change.url_alloc)
- free(data->change.url);
- data->change.url = newurl;
- data->change.url_alloc = TRUE;
+
+ /* after it was parsed, get the generated normalized version */
+ uc = curl_url_get(uh, CURLUPART_URL, &newurl, 0);
+ if(uc)
+ return Curl_uc_to_curlcode(uc);
+ if(data->change.url_alloc)
+ free(data->change.url);
+ data->change.url = newurl;
+ data->change.url_alloc = TRUE;
}
uc = curl_url_get(uh, CURLUPART_SCHEME, &data->state.up.scheme, 0);
if(uc)
return Curl_uc_to_curlcode(uc);
- uc = curl_url_get(uh, CURLUPART_HOST, &data->state.up.hostname, 0);
- if(uc) {
- if(!strcasecompare("file", data->state.up.scheme))
- return CURLE_OUT_OF_MEMORY;
- }
-
-#ifdef USE_HSTS
- if(data->hsts && strcasecompare("http", data->state.up.scheme)) {
- if(Curl_hsts(data->hsts, data->state.up.hostname, TRUE)) {
- char *url;
- Curl_safefree(data->state.up.scheme);
- uc = curl_url_set(uh, CURLUPART_SCHEME, "https", 0);
- if(uc)
- return Curl_uc_to_curlcode(uc);
- if(data->change.url_alloc)
- Curl_safefree(data->change.url);
- /* after update, get the updated version */
- uc = curl_url_get(uh, CURLUPART_URL, &url, 0);
- if(uc)
- return Curl_uc_to_curlcode(uc);
- uc = curl_url_get(uh, CURLUPART_SCHEME, &data->state.up.scheme, 0);
- if(uc)
- return Curl_uc_to_curlcode(uc);
- data->change.url = url;
- data->change.url_alloc = TRUE;
- infof(data, "Switched from HTTP to HTTPS due to HSTS => %s\n",
- data->change.url);
- }
- }
-#endif
-
+ uc = curl_url_get(uh, CURLUPART_HOST, &data->state.up.hostname, 0);
+ if(uc) {
+ if(!strcasecompare("file", data->state.up.scheme))
+ return CURLE_OUT_OF_MEMORY;
+ }
+
+#ifdef USE_HSTS
+ if(data->hsts && strcasecompare("http", data->state.up.scheme)) {
+ if(Curl_hsts(data->hsts, data->state.up.hostname, TRUE)) {
+ char *url;
+ Curl_safefree(data->state.up.scheme);
+ uc = curl_url_set(uh, CURLUPART_SCHEME, "https", 0);
+ if(uc)
+ return Curl_uc_to_curlcode(uc);
+ if(data->change.url_alloc)
+ Curl_safefree(data->change.url);
+ /* after update, get the updated version */
+ uc = curl_url_get(uh, CURLUPART_URL, &url, 0);
+ if(uc)
+ return Curl_uc_to_curlcode(uc);
+ uc = curl_url_get(uh, CURLUPART_SCHEME, &data->state.up.scheme, 0);
+ if(uc)
+ return Curl_uc_to_curlcode(uc);
+ data->change.url = url;
+ data->change.url_alloc = TRUE;
+ infof(data, "Switched from HTTP to HTTPS due to HSTS => %s\n",
+ data->change.url);
+ }
+ }
+#endif
+
result = findprotocol(data, conn, data->state.up.scheme);
if(result)
return result;
- /* we don't use the URL API's URL decoder option here since it rejects
- control codes and we want to allow them for some schemes in the user and
- password fields */
- uc = curl_url_get(uh, CURLUPART_USER, &data->state.up.user, 0);
+ /* we don't use the URL API's URL decoder option here since it rejects
+ control codes and we want to allow them for some schemes in the user and
+ password fields */
+ uc = curl_url_get(uh, CURLUPART_USER, &data->state.up.user, 0);
if(!uc) {
- char *decoded;
- result = Curl_urldecode(NULL, data->state.up.user, 0, &decoded, NULL,
- conn->handler->flags&PROTOPT_USERPWDCTRL ?
- REJECT_ZERO : REJECT_CTRL);
- if(result)
- return result;
- conn->user = decoded;
+ char *decoded;
+ result = Curl_urldecode(NULL, data->state.up.user, 0, &decoded, NULL,
+ conn->handler->flags&PROTOPT_USERPWDCTRL ?
+ REJECT_ZERO : REJECT_CTRL);
+ if(result)
+ return result;
+ conn->user = decoded;
conn->bits.user_passwd = TRUE;
}
else if(uc != CURLUE_NO_USER)
return Curl_uc_to_curlcode(uc);
- uc = curl_url_get(uh, CURLUPART_PASSWORD, &data->state.up.password, 0);
+ uc = curl_url_get(uh, CURLUPART_PASSWORD, &data->state.up.password, 0);
if(!uc) {
- char *decoded;
- result = Curl_urldecode(NULL, data->state.up.password, 0, &decoded, NULL,
- conn->handler->flags&PROTOPT_USERPWDCTRL ?
- REJECT_ZERO : REJECT_CTRL);
- if(result)
- return result;
- conn->passwd = decoded;
+ char *decoded;
+ result = Curl_urldecode(NULL, data->state.up.password, 0, &decoded, NULL,
+ conn->handler->flags&PROTOPT_USERPWDCTRL ?
+ REJECT_ZERO : REJECT_CTRL);
+ if(result)
+ return result;
+ conn->passwd = decoded;
conn->bits.user_passwd = TRUE;
}
else if(uc != CURLUE_NO_PASSWORD)
@@ -2009,7 +2009,7 @@ static CURLcode parseurlandfillconn(struct Curl_easy *data,
(void)curl_url_get(uh, CURLUPART_QUERY, &data->state.up.query, 0);
hostname = data->state.up.hostname;
- if(hostname && hostname[0] == '[') {
+ if(hostname && hostname[0] == '[') {
/* This looks like an IPv6 address literal. See if there is an address
scope. */
size_t hlen;
@@ -2023,7 +2023,7 @@ static CURLcode parseurlandfillconn(struct Curl_easy *data,
}
/* make sure the connect struct gets its own copy of the host name */
- conn->host.rawalloc = strdup(hostname ? hostname : "");
+ conn->host.rawalloc = strdup(hostname ? hostname : "");
if(!conn->host.rawalloc)
return CURLE_OUT_OF_MEMORY;
conn->host.name = conn->host.rawalloc;
@@ -2079,7 +2079,7 @@ static CURLcode setup_range(struct Curl_easy *data)
*/
static CURLcode setup_connection_internals(struct connectdata *conn)
{
- const struct Curl_handler *p;
+ const struct Curl_handler *p;
CURLcode result;
/* Perform setup complement if some. */
@@ -2109,13 +2109,13 @@ static CURLcode setup_connection_internals(struct connectdata *conn)
void Curl_free_request_state(struct Curl_easy *data)
{
- Curl_safefree(data->req.p.http);
+ Curl_safefree(data->req.p.http);
Curl_safefree(data->req.newurl);
-
-#ifndef CURL_DISABLE_DOH
- Curl_close(&data->req.doh.probe[0].easy);
- Curl_close(&data->req.doh.probe[1].easy);
-#endif
+
+#ifndef CURL_DISABLE_DOH
+ Curl_close(&data->req.doh.probe[0].easy);
+ Curl_close(&data->req.doh.probe[1].easy);
+#endif
}
@@ -2426,18 +2426,18 @@ static CURLcode parse_proxy(struct Curl_easy *data,
static CURLcode parse_proxy_auth(struct Curl_easy *data,
struct connectdata *conn)
{
- const char *proxyuser = data->set.str[STRING_PROXYUSERNAME] ?
- data->set.str[STRING_PROXYUSERNAME] : "";
- const char *proxypasswd = data->set.str[STRING_PROXYPASSWORD] ?
- data->set.str[STRING_PROXYPASSWORD] : "";
- CURLcode result = CURLE_OK;
-
- if(proxyuser)
- result = Curl_urldecode(data, proxyuser, 0, &conn->http_proxy.user, NULL,
- REJECT_ZERO);
- if(!result && proxypasswd)
+ const char *proxyuser = data->set.str[STRING_PROXYUSERNAME] ?
+ data->set.str[STRING_PROXYUSERNAME] : "";
+ const char *proxypasswd = data->set.str[STRING_PROXYPASSWORD] ?
+ data->set.str[STRING_PROXYPASSWORD] : "";
+ CURLcode result = CURLE_OK;
+
+ if(proxyuser)
+ result = Curl_urldecode(data, proxyuser, 0, &conn->http_proxy.user, NULL,
+ REJECT_ZERO);
+ if(!result && proxypasswd)
result = Curl_urldecode(data, proxypasswd, 0, &conn->http_proxy.passwd,
- NULL, REJECT_ZERO);
+ NULL, REJECT_ZERO);
return result;
}
@@ -2602,9 +2602,9 @@ static CURLcode create_conn_helper_init_proxy(struct connectdata *conn)
conn->bits.socksproxy = FALSE;
conn->bits.proxy_user_passwd = FALSE;
conn->bits.tunnel_proxy = FALSE;
- /* CURLPROXY_HTTPS does not have its own flag in conn->bits, yet we need
- to signal that CURLPROXY_HTTPS is not used for this connection */
- conn->http_proxy.proxytype = CURLPROXY_HTTP;
+ /* CURLPROXY_HTTPS does not have its own flag in conn->bits, yet we need
+ to signal that CURLPROXY_HTTPS is not used for this connection */
+ conn->http_proxy.proxytype = CURLPROXY_HTTP;
}
out:
@@ -2658,12 +2658,12 @@ CURLcode Curl_parse_login_details(const char *login, const size_t len,
size_t plen;
size_t olen;
- /* the input length check is because this is called directcly from setopt
- and isn't going through the regular string length check */
- size_t llen = strlen(login);
- if(llen > CURL_MAX_INPUT_LENGTH)
- return CURLE_BAD_FUNCTION_ARGUMENT;
-
+ /* the input length check is because this is called directcly from setopt
+ and isn't going through the regular string length check */
+ size_t llen = strlen(login);
+ if(llen > CURL_MAX_INPUT_LENGTH)
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+
/* Attempt to find the password separator */
if(passwdp) {
psep = strchr(login, ':');
@@ -2860,14 +2860,14 @@ static CURLcode override_login(struct Curl_easy *data,
/* for updated strings, we update them in the URL */
if(user_changed) {
- uc = curl_url_set(data->state.uh, CURLUPART_USER, *userp,
- CURLU_URLENCODE);
+ uc = curl_url_set(data->state.uh, CURLUPART_USER, *userp,
+ CURLU_URLENCODE);
if(uc)
return Curl_uc_to_curlcode(uc);
}
if(passwd_changed) {
- uc = curl_url_set(data->state.uh, CURLUPART_PASSWORD, *passwdp,
- CURLU_URLENCODE);
+ uc = curl_url_set(data->state.uh, CURLUPART_PASSWORD, *passwdp,
+ CURLU_URLENCODE);
if(uc)
return Curl_uc_to_curlcode(uc);
}
@@ -3124,16 +3124,16 @@ static CURLcode parse_connect_to_slist(struct Curl_easy *data,
conn_to_host = conn_to_host->next;
}
-#ifndef CURL_DISABLE_ALTSVC
+#ifndef CURL_DISABLE_ALTSVC
if(data->asi && !host && (port == -1) &&
- ((conn->handler->protocol == CURLPROTO_HTTPS) ||
-#ifdef CURLDEBUG
- /* allow debug builds to circumvent the HTTPS restriction */
- getenv("CURL_ALTSVC_HTTP")
-#else
- 0
-#endif
- )) {
+ ((conn->handler->protocol == CURLPROTO_HTTPS) ||
+#ifdef CURLDEBUG
+ /* allow debug builds to circumvent the HTTPS restriction */
+ getenv("CURL_ALTSVC_HTTP")
+#else
+ 0
+#endif
+ )) {
/* no connect_to match, try alt-svc! */
enum alpnid srcalpnid;
bool hit;
@@ -3225,7 +3225,7 @@ static CURLcode resolve_server(struct Curl_easy *data,
else {
/* this is a fresh connect */
int rc;
- struct Curl_dns_entry *hostaddr = NULL;
+ struct Curl_dns_entry *hostaddr = NULL;
#ifdef USE_UNIX_SOCKETS
if(conn->unix_domain_socket) {
@@ -3240,7 +3240,7 @@ static CURLcode resolve_server(struct Curl_easy *data,
else {
bool longpath = FALSE;
hostaddr->addr = Curl_unix2addr(path, &longpath,
- conn->bits.abstract_unix_socket);
+ conn->bits.abstract_unix_socket);
if(hostaddr->addr)
hostaddr->inuse++;
else {
@@ -3258,7 +3258,7 @@ static CURLcode resolve_server(struct Curl_easy *data,
}
else
#endif
-
+
if(!conn->bits.proxy) {
struct hostname *connhost;
if(conn->bits.conn_to_host)
@@ -3287,11 +3287,11 @@ static CURLcode resolve_server(struct Curl_easy *data,
else if(!hostaddr) {
failf(data, "Couldn't resolve host '%s'", connhost->dispname);
- result = CURLE_COULDNT_RESOLVE_HOST;
+ result = CURLE_COULDNT_RESOLVE_HOST;
/* don't return yet, we need to clean up the timeout first */
}
}
-#ifndef CURL_DISABLE_PROXY
+#ifndef CURL_DISABLE_PROXY
else {
/* This is a proxy that hasn't been resolved yet. */
@@ -3317,7 +3317,7 @@ static CURLcode resolve_server(struct Curl_easy *data,
/* don't return yet, we need to clean up the timeout first */
}
}
-#endif
+#endif
DEBUGASSERT(conn->dns_entry == NULL);
conn->dns_entry = hostaddr;
}
@@ -3333,14 +3333,14 @@ static CURLcode resolve_server(struct Curl_easy *data,
static void reuse_conn(struct connectdata *old_conn,
struct connectdata *conn)
{
-#ifndef CURL_DISABLE_PROXY
- Curl_free_idnconverted_hostname(&old_conn->http_proxy.host);
- Curl_free_idnconverted_hostname(&old_conn->socks_proxy.host);
+#ifndef CURL_DISABLE_PROXY
+ Curl_free_idnconverted_hostname(&old_conn->http_proxy.host);
+ Curl_free_idnconverted_hostname(&old_conn->socks_proxy.host);
free(old_conn->http_proxy.host.rawalloc);
free(old_conn->socks_proxy.host.rawalloc);
- Curl_free_primary_ssl_config(&old_conn->proxy_ssl_config);
-#endif
+ Curl_free_primary_ssl_config(&old_conn->proxy_ssl_config);
+#endif
/* free the SSL config struct from this connection struct as this was
allocated in vain and is targeted for destruction */
Curl_free_primary_ssl_config(&old_conn->ssl_config);
@@ -3360,7 +3360,7 @@ static void reuse_conn(struct connectdata *old_conn,
old_conn->passwd = NULL;
}
-#ifndef CURL_DISABLE_PROXY
+#ifndef CURL_DISABLE_PROXY
conn->bits.proxy_user_passwd = old_conn->bits.proxy_user_passwd;
if(conn->bits.proxy_user_passwd) {
/* use the new proxy user name and proxy password though */
@@ -3377,16 +3377,16 @@ static void reuse_conn(struct connectdata *old_conn,
old_conn->http_proxy.passwd = NULL;
old_conn->socks_proxy.passwd = NULL;
}
- Curl_safefree(old_conn->http_proxy.user);
- Curl_safefree(old_conn->socks_proxy.user);
- Curl_safefree(old_conn->http_proxy.passwd);
- Curl_safefree(old_conn->socks_proxy.passwd);
-#endif
+ Curl_safefree(old_conn->http_proxy.user);
+ Curl_safefree(old_conn->socks_proxy.user);
+ Curl_safefree(old_conn->http_proxy.passwd);
+ Curl_safefree(old_conn->socks_proxy.passwd);
+#endif
/* host can change, when doing keepalive with a proxy or if the case is
different this time etc */
- Curl_free_idnconverted_hostname(&conn->host);
- Curl_free_idnconverted_hostname(&conn->conn_to_host);
+ Curl_free_idnconverted_hostname(&conn->host);
+ Curl_free_idnconverted_hostname(&conn->conn_to_host);
Curl_safefree(conn->host.rawalloc);
Curl_safefree(conn->conn_to_host.rawalloc);
conn->host = old_conn->host;
@@ -3493,7 +3493,7 @@ static CURLcode create_conn(struct Curl_easy *data,
result = CURLE_OUT_OF_MEMORY;
goto out;
}
- conn->bits.abstract_unix_socket = data->set.abstract_unix_socket;
+ conn->bits.abstract_unix_socket = data->set.abstract_unix_socket;
}
#endif
@@ -3510,7 +3510,7 @@ static CURLcode create_conn(struct Curl_easy *data,
*************************************************************/
if((conn->given->flags&PROTOPT_SSL) && conn->bits.httpproxy)
conn->bits.tunnel_proxy = TRUE;
-#endif
+#endif
/*************************************************************
* Figure out the remote port number and fix it in the URL
@@ -3541,26 +3541,26 @@ static CURLcode create_conn(struct Curl_easy *data,
/*************************************************************
* IDN-convert the hostnames
*************************************************************/
- result = Curl_idnconvert_hostname(conn, &conn->host);
+ result = Curl_idnconvert_hostname(conn, &conn->host);
if(result)
goto out;
if(conn->bits.conn_to_host) {
- result = Curl_idnconvert_hostname(conn, &conn->conn_to_host);
+ result = Curl_idnconvert_hostname(conn, &conn->conn_to_host);
if(result)
goto out;
}
-#ifndef CURL_DISABLE_PROXY
+#ifndef CURL_DISABLE_PROXY
if(conn->bits.httpproxy) {
- result = Curl_idnconvert_hostname(conn, &conn->http_proxy.host);
+ result = Curl_idnconvert_hostname(conn, &conn->http_proxy.host);
if(result)
goto out;
}
if(conn->bits.socksproxy) {
- result = Curl_idnconvert_hostname(conn, &conn->socks_proxy.host);
+ result = Curl_idnconvert_hostname(conn, &conn->socks_proxy.host);
if(result)
goto out;
}
-#endif
+#endif
/*************************************************************
* Check whether the host and the "connect to host" are equal.
@@ -3579,7 +3579,7 @@ static CURLcode create_conn(struct Curl_easy *data,
conn->bits.conn_to_port = FALSE;
}
-#ifndef CURL_DISABLE_PROXY
+#ifndef CURL_DISABLE_PROXY
/*************************************************************
* If the "connect to" feature is used with an HTTP proxy,
* we set the tunnel_proxy bit.
@@ -3587,7 +3587,7 @@ static CURLcode create_conn(struct Curl_easy *data,
if((conn->bits.conn_to_host || conn->bits.conn_to_port) &&
conn->bits.httpproxy)
conn->bits.tunnel_proxy = TRUE;
-#endif
+#endif
/*************************************************************
* Setup internals depending on protocol. Needs to be done after
@@ -3620,7 +3620,7 @@ static CURLcode create_conn(struct Curl_easy *data,
if(!result) {
conn->bits.tcpconnect[FIRSTSOCKET] = TRUE; /* we are "connected */
- Curl_attach_connnection(data, conn);
+ Curl_attach_connnection(data, conn);
result = Curl_conncache_add_conn(data->state.conn_cache, conn);
if(result)
goto out;
@@ -3655,19 +3655,19 @@ static CURLcode create_conn(struct Curl_easy *data,
copies will be separately allocated.
*/
data->set.ssl.primary.CApath = data->set.str[STRING_SSL_CAPATH_ORIG];
- data->set.ssl.primary.CAfile = data->set.str[STRING_SSL_CAFILE_ORIG];
- data->set.ssl.primary.random_file = data->set.str[STRING_SSL_RANDOM_FILE];
- data->set.ssl.primary.egdsocket = data->set.str[STRING_SSL_EGDSOCKET];
- data->set.ssl.primary.cipher_list =
- data->set.str[STRING_SSL_CIPHER_LIST_ORIG];
- data->set.ssl.primary.cipher_list13 =
- data->set.str[STRING_SSL_CIPHER13_LIST_ORIG];
- data->set.ssl.primary.pinned_key =
- data->set.str[STRING_SSL_PINNEDPUBLICKEY_ORIG];
- data->set.ssl.primary.cert_blob = data->set.blobs[BLOB_CERT_ORIG];
- data->set.ssl.primary.curves = data->set.str[STRING_SSL_EC_CURVES];
-
-#ifndef CURL_DISABLE_PROXY
+ data->set.ssl.primary.CAfile = data->set.str[STRING_SSL_CAFILE_ORIG];
+ data->set.ssl.primary.random_file = data->set.str[STRING_SSL_RANDOM_FILE];
+ data->set.ssl.primary.egdsocket = data->set.str[STRING_SSL_EGDSOCKET];
+ data->set.ssl.primary.cipher_list =
+ data->set.str[STRING_SSL_CIPHER_LIST_ORIG];
+ data->set.ssl.primary.cipher_list13 =
+ data->set.str[STRING_SSL_CIPHER13_LIST_ORIG];
+ data->set.ssl.primary.pinned_key =
+ data->set.str[STRING_SSL_PINNEDPUBLICKEY_ORIG];
+ data->set.ssl.primary.cert_blob = data->set.blobs[BLOB_CERT_ORIG];
+ data->set.ssl.primary.curves = data->set.str[STRING_SSL_EC_CURVES];
+
+#ifndef CURL_DISABLE_PROXY
data->set.proxy_ssl.primary.CApath = data->set.str[STRING_SSL_CAPATH_PROXY];
data->set.proxy_ssl.primary.CAfile = data->set.str[STRING_SSL_CAFILE_PROXY];
data->set.proxy_ssl.primary.random_file =
@@ -3677,18 +3677,18 @@ static CURLcode create_conn(struct Curl_easy *data,
data->set.str[STRING_SSL_CIPHER_LIST_PROXY];
data->set.proxy_ssl.primary.cipher_list13 =
data->set.str[STRING_SSL_CIPHER13_LIST_PROXY];
- data->set.proxy_ssl.primary.pinned_key =
- data->set.str[STRING_SSL_PINNEDPUBLICKEY_PROXY];
- data->set.proxy_ssl.primary.cert_blob = data->set.blobs[BLOB_CERT_PROXY];
- data->set.proxy_ssl.CRLfile = data->set.str[STRING_SSL_CRLFILE_PROXY];
- data->set.proxy_ssl.issuercert = data->set.str[STRING_SSL_ISSUERCERT_PROXY];
- data->set.proxy_ssl.cert_type = data->set.str[STRING_CERT_TYPE_PROXY];
- data->set.proxy_ssl.key = data->set.str[STRING_KEY_PROXY];
- data->set.proxy_ssl.key_type = data->set.str[STRING_KEY_TYPE_PROXY];
- data->set.proxy_ssl.key_passwd = data->set.str[STRING_KEY_PASSWD_PROXY];
- data->set.proxy_ssl.primary.clientcert = data->set.str[STRING_CERT_PROXY];
- data->set.proxy_ssl.key_blob = data->set.blobs[BLOB_KEY_PROXY];
-#endif
+ data->set.proxy_ssl.primary.pinned_key =
+ data->set.str[STRING_SSL_PINNEDPUBLICKEY_PROXY];
+ data->set.proxy_ssl.primary.cert_blob = data->set.blobs[BLOB_CERT_PROXY];
+ data->set.proxy_ssl.CRLfile = data->set.str[STRING_SSL_CRLFILE_PROXY];
+ data->set.proxy_ssl.issuercert = data->set.str[STRING_SSL_ISSUERCERT_PROXY];
+ data->set.proxy_ssl.cert_type = data->set.str[STRING_CERT_TYPE_PROXY];
+ data->set.proxy_ssl.key = data->set.str[STRING_KEY_PROXY];
+ data->set.proxy_ssl.key_type = data->set.str[STRING_KEY_TYPE_PROXY];
+ data->set.proxy_ssl.key_passwd = data->set.str[STRING_KEY_PASSWD_PROXY];
+ data->set.proxy_ssl.primary.clientcert = data->set.str[STRING_CERT_PROXY];
+ data->set.proxy_ssl.key_blob = data->set.blobs[BLOB_KEY_PROXY];
+#endif
data->set.ssl.CRLfile = data->set.str[STRING_SSL_CRLFILE_ORIG];
data->set.ssl.issuercert = data->set.str[STRING_SSL_ISSUERCERT_ORIG];
data->set.ssl.cert_type = data->set.str[STRING_CERT_TYPE_ORIG];
@@ -3698,29 +3698,29 @@ static CURLcode create_conn(struct Curl_easy *data,
data->set.ssl.primary.clientcert = data->set.str[STRING_CERT_ORIG];
#ifdef USE_TLS_SRP
data->set.ssl.username = data->set.str[STRING_TLSAUTH_USERNAME_ORIG];
- data->set.ssl.password = data->set.str[STRING_TLSAUTH_PASSWORD_ORIG];
-#ifndef CURL_DISABLE_PROXY
+ data->set.ssl.password = data->set.str[STRING_TLSAUTH_PASSWORD_ORIG];
+#ifndef CURL_DISABLE_PROXY
data->set.proxy_ssl.username = data->set.str[STRING_TLSAUTH_USERNAME_PROXY];
data->set.proxy_ssl.password = data->set.str[STRING_TLSAUTH_PASSWORD_PROXY];
#endif
-#endif
+#endif
+
+ data->set.ssl.key_blob = data->set.blobs[BLOB_KEY_ORIG];
+ data->set.ssl.issuercert_blob = data->set.blobs[BLOB_SSL_ISSUERCERT_ORIG];
- data->set.ssl.key_blob = data->set.blobs[BLOB_KEY_ORIG];
- data->set.ssl.issuercert_blob = data->set.blobs[BLOB_SSL_ISSUERCERT_ORIG];
-
if(!Curl_clone_primary_ssl_config(&data->set.ssl.primary,
- &conn->ssl_config)) {
+ &conn->ssl_config)) {
result = CURLE_OUT_OF_MEMORY;
goto out;
}
-#ifndef CURL_DISABLE_PROXY
+#ifndef CURL_DISABLE_PROXY
if(!Curl_clone_primary_ssl_config(&data->set.proxy_ssl.primary,
&conn->proxy_ssl_config)) {
result = CURLE_OUT_OF_MEMORY;
goto out;
}
-#endif
+#endif
prune_dead_connections(data);
@@ -3758,17 +3758,17 @@ static CURLcode create_conn(struct Curl_easy *data,
conn = conn_temp;
*in_connect = conn;
-#ifndef CURL_DISABLE_PROXY
+#ifndef CURL_DISABLE_PROXY
infof(data, "Re-using existing connection! (#%ld) with %s %s\n",
conn->connection_id,
conn->bits.proxy?"proxy":"host",
conn->socks_proxy.host.name ? conn->socks_proxy.host.dispname :
conn->http_proxy.host.name ? conn->http_proxy.host.dispname :
- conn->host.dispname);
-#else
- infof(data, "Re-using existing connection! (#%ld) with host %s\n",
- conn->connection_id, conn->host.dispname);
-#endif
+ conn->host.dispname);
+#else
+ infof(data, "Re-using existing connection! (#%ld) with host %s\n",
+ conn->connection_id, conn->host.dispname);
+#endif
}
else {
/* We have decided that we want a new connection. However, we may not
@@ -3800,10 +3800,10 @@ static CURLcode create_conn(struct Curl_easy *data,
/* The bundle is full. Extract the oldest connection. */
conn_candidate = Curl_conncache_extract_bundle(data, bundle);
- CONNCACHE_UNLOCK(data);
+ CONNCACHE_UNLOCK(data);
if(conn_candidate)
- (void)Curl_disconnect(data, conn_candidate, FALSE);
+ (void)Curl_disconnect(data, conn_candidate, FALSE);
else {
infof(data, "No more connections allowed to host %s: %zu\n",
bundlehost, max_host_connections);
@@ -3811,7 +3811,7 @@ static CURLcode create_conn(struct Curl_easy *data,
}
}
else
- CONNCACHE_UNLOCK(data);
+ CONNCACHE_UNLOCK(data);
}
@@ -3823,7 +3823,7 @@ static CURLcode create_conn(struct Curl_easy *data,
/* The cache is full. Let's see if we can kill a connection. */
conn_candidate = Curl_conncache_extract_oldest(data);
if(conn_candidate)
- (void)Curl_disconnect(data, conn_candidate, FALSE);
+ (void)Curl_disconnect(data, conn_candidate, FALSE);
else {
infof(data, "No connections available in cache\n");
connections_available = FALSE;
@@ -3844,8 +3844,8 @@ static CURLcode create_conn(struct Curl_easy *data,
* This is a brand new connection, so let's store it in the connection
* cache of ours!
*/
- Curl_attach_connnection(data, conn);
-
+ Curl_attach_connnection(data, conn);
+
result = Curl_conncache_add_conn(data->state.conn_cache, conn);
if(result)
goto out;
@@ -3897,12 +3897,12 @@ static CURLcode create_conn(struct Curl_easy *data,
/* Strip trailing dots. resolve_server copied the name. */
strip_trailing_dot(&conn->host);
-#ifndef CURL_DISABLE_PROXY
+#ifndef CURL_DISABLE_PROXY
if(conn->bits.httpproxy)
strip_trailing_dot(&conn->http_proxy.host);
if(conn->bits.socksproxy)
strip_trailing_dot(&conn->socks_proxy.host);
-#endif
+#endif
if(conn->bits.conn_to_host)
strip_trailing_dot(&conn->conn_to_host);
@@ -3933,23 +3933,23 @@ CURLcode Curl_setup_conn(struct connectdata *conn,
}
*protocol_done = FALSE; /* default to not done */
-#ifndef CURL_DISABLE_PROXY
+#ifndef CURL_DISABLE_PROXY
/* set proxy_connect_closed to false unconditionally already here since it
is used strictly to provide extra information to a parent function in the
case of proxy CONNECT failures and we must make sure we don't have it
lingering set from a previous invoke */
conn->bits.proxy_connect_closed = FALSE;
-#endif
+#endif
/*
* Set user-agent. Used for HTTP, but since we can attempt to tunnel
* basically anything through a http proxy we can't limit this based on
* protocol.
*/
if(data->set.str[STRING_USERAGENT]) {
- Curl_safefree(data->state.aptr.uagent);
- data->state.aptr.uagent =
+ Curl_safefree(data->state.aptr.uagent);
+ data->state.aptr.uagent =
aprintf("User-Agent: %s\r\n", data->set.str[STRING_USERAGENT]);
- if(!data->state.aptr.uagent)
+ if(!data->state.aptr.uagent)
return CURLE_OUT_OF_MEMORY;
}
@@ -3971,9 +3971,9 @@ CURLcode Curl_setup_conn(struct connectdata *conn,
}
else {
Curl_pgrsTime(data, TIMER_CONNECT); /* we're connected already */
- if(conn->ssl[FIRSTSOCKET].use ||
- (conn->handler->protocol & PROTO_FAMILY_SSH))
- Curl_pgrsTime(data, TIMER_APPCONNECT); /* we're connected already */
+ if(conn->ssl[FIRSTSOCKET].use ||
+ (conn->handler->protocol & PROTO_FAMILY_SSH))
+ Curl_pgrsTime(data, TIMER_APPCONNECT); /* we're connected already */
conn->bits.tcpconnect[FIRSTSOCKET] = TRUE;
*protocol_done = TRUE;
Curl_updateconninfo(conn, conn->sock[FIRSTSOCKET]);
@@ -4003,7 +4003,7 @@ CURLcode Curl_connect(struct Curl_easy *data,
result = create_conn(data, &conn, asyncp);
if(!result) {
- if(CONN_INUSE(conn) > 1)
+ if(CONN_INUSE(conn) > 1)
/* multiplexed */
*protocol_done = TRUE;
else if(!*asyncp) {
@@ -4020,8 +4020,8 @@ CURLcode Curl_connect(struct Curl_easy *data,
else if(result && conn) {
/* We're not allowed to return failure with memory left allocated in the
connectdata struct, free those here */
- Curl_detach_connnection(data);
- Curl_conncache_remove_conn(data, conn, TRUE);
+ Curl_detach_connnection(data);
+ Curl_conncache_remove_conn(data, conn, TRUE);
Curl_disconnect(data, conn, TRUE);
}
@@ -4042,11 +4042,11 @@ CURLcode Curl_init_do(struct Curl_easy *data, struct connectdata *conn)
{
struct SingleRequest *k = &data->req;
- /* if this is a pushed stream, we need this: */
- CURLcode result = Curl_preconnect(data);
- if(result)
- return result;
-
+ /* if this is a pushed stream, we need this: */
+ CURLcode result = Curl_preconnect(data);
+ if(result)
+ return result;
+
if(conn) {
conn->bits.do_more = FALSE; /* by default there's no curl_do_more() to
use */
@@ -4061,7 +4061,7 @@ CURLcode Curl_init_do(struct Curl_easy *data, struct connectdata *conn)
if(data->set.opt_no_body)
/* in HTTP lingo, no body means using the HEAD request... */
- data->state.httpreq = HTTPREQ_HEAD;
+ data->state.httpreq = HTTPREQ_HEAD;
k->start = Curl_now(); /* start time */
k->now = k->start; /* current time is now */
diff --git a/contrib/libs/curl/lib/url.h b/contrib/libs/curl/lib/url.h
index 43c0212abe..a9d5bda29c 100644
--- a/contrib/libs/curl/lib/url.h
+++ b/contrib/libs/curl/lib/url.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -47,9 +47,9 @@ CURLcode Curl_init_do(struct Curl_easy *data, struct connectdata *conn);
CURLcode Curl_open(struct Curl_easy **curl);
CURLcode Curl_init_userdefined(struct Curl_easy *data);
-void Curl_freeset(struct Curl_easy *data);
+void Curl_freeset(struct Curl_easy *data);
CURLcode Curl_uc_to_curlcode(CURLUcode uc);
-CURLcode Curl_close(struct Curl_easy **datap); /* opposite of curl_open() */
+CURLcode Curl_close(struct Curl_easy **datap); /* opposite of curl_open() */
CURLcode Curl_connect(struct Curl_easy *, bool *async, bool *protocol_connect);
CURLcode Curl_disconnect(struct Curl_easy *data,
struct connectdata *, bool dead_connection);
@@ -62,11 +62,11 @@ CURLcode Curl_parse_login_details(const char *login, const size_t len,
const struct Curl_handler *Curl_builtin_scheme(const char *scheme);
-bool Curl_is_ASCII_name(const char *hostname);
-CURLcode Curl_idnconvert_hostname(struct connectdata *conn,
- struct hostname *host);
-void Curl_free_idnconverted_hostname(struct hostname *host);
-
+bool Curl_is_ASCII_name(const char *hostname);
+CURLcode Curl_idnconvert_hostname(struct connectdata *conn,
+ struct hostname *host);
+void Curl_free_idnconverted_hostname(struct hostname *host);
+
#define CURL_DEFAULT_PROXY_PORT 1080 /* default proxy port unless specified */
#define CURL_DEFAULT_HTTPS_PROXY_PORT 443 /* default https proxy port unless
specified */
@@ -77,10 +77,10 @@ void Curl_free_idnconverted_hostname(struct hostname *host);
void Curl_verboseconnect(struct connectdata *conn);
#endif
-#ifdef CURL_DISABLE_PROXY
-#define CONNECT_PROXY_SSL() FALSE
-#else
-
+#ifdef CURL_DISABLE_PROXY
+#define CONNECT_PROXY_SSL() FALSE
+#else
+
#define CONNECT_PROXY_SSL()\
(conn->http_proxy.proxytype == CURLPROXY_HTTPS &&\
!conn->bits.proxy_ssl_connected[sockindex])
@@ -92,6 +92,6 @@ void Curl_verboseconnect(struct connectdata *conn);
#define CONNECT_SECONDARYSOCKET_PROXY_SSL()\
(conn->http_proxy.proxytype == CURLPROXY_HTTPS &&\
!conn->bits.proxy_ssl_connected[SECONDARYSOCKET])
-#endif /* !CURL_DISABLE_PROXY */
+#endif /* !CURL_DISABLE_PROXY */
#endif /* HEADER_CURL_URL_H */
diff --git a/contrib/libs/curl/lib/urlapi-int.h b/contrib/libs/curl/lib/urlapi-int.h
index ade63100e5..4257233094 100644
--- a/contrib/libs/curl/lib/urlapi-int.h
+++ b/contrib/libs/curl/lib/urlapi-int.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -28,7 +28,7 @@
bool Curl_is_absolute_url(const char *url, char *scheme, size_t buflen);
#ifdef DEBUGBUILD
-CURLUcode Curl_parse_port(struct Curl_URL *u, char *hostname, bool);
+CURLUcode Curl_parse_port(struct Curl_URL *u, char *hostname, bool);
#endif
#endif /* HEADER_CURL_URLAPI_INT_H */
diff --git a/contrib/libs/curl/lib/urlapi.c b/contrib/libs/curl/lib/urlapi.c
index 535bd9d909..ae75963595 100644
--- a/contrib/libs/curl/lib/urlapi.c
+++ b/contrib/libs/curl/lib/urlapi.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -64,7 +64,7 @@ struct Curl_URL {
char *fragment;
char *scratch; /* temporary scratch area */
- char *temppath; /* temporary path pointer */
+ char *temppath; /* temporary path pointer */
long portnum; /* the numerical version */
};
@@ -83,7 +83,7 @@ static void free_urlhandle(struct Curl_URL *u)
free(u->query);
free(u->fragment);
free(u->scratch);
- free(u->temppath);
+ free(u->temppath);
}
/* move the full contents of one handle onto another and
@@ -225,7 +225,7 @@ static void strcpy_url(char *output, const char *url, bool relative)
break;
}
}
- *optr = 0; /* null-terminate output buffer */
+ *optr = 0; /* null-terminate output buffer */
}
@@ -353,7 +353,7 @@ static char *concat_url(const char *base, const char *relurl)
else {
/* We got a new absolute path for this server */
- if(relurl[1] == '/') {
+ if(relurl[1] == '/') {
/* the new URL starts with //, just keep the protocol part from the
original one */
*protsep = 0;
@@ -436,7 +436,7 @@ static CURLUcode parse_hostname_login(struct Curl_URL *u,
char *userp = NULL;
char *passwdp = NULL;
char *optionsp = NULL;
- const struct Curl_handler *h = NULL;
+ const struct Curl_handler *h = NULL;
/* At this point, we're hoping all the other special cases have
* been taken care of, so conn->host.name is at most
@@ -456,10 +456,10 @@ static CURLUcode parse_hostname_login(struct Curl_URL *u,
* ftp://user:password@ftp.my.site:8021/README */
*hostname = ++ptr;
- /* if this is a known scheme, get some details */
- if(u->scheme)
- h = Curl_builtin_scheme(u->scheme);
-
+ /* if this is a known scheme, get some details */
+ if(u->scheme)
+ h = Curl_builtin_scheme(u->scheme);
+
/* We could use the login information in the URL so extract it. Only parse
options if the handler says we should. Note that 'h' might be NULL! */
ccode = Curl_parse_login_details(login, ptr - login - 1,
@@ -497,8 +497,8 @@ static CURLUcode parse_hostname_login(struct Curl_URL *u,
return result;
}
-UNITTEST CURLUcode Curl_parse_port(struct Curl_URL *u, char *hostname,
- bool has_scheme)
+UNITTEST CURLUcode Curl_parse_port(struct Curl_URL *u, char *hostname,
+ bool has_scheme)
{
char *portptr = NULL;
char endbracket;
@@ -543,14 +543,14 @@ UNITTEST CURLUcode Curl_parse_port(struct Curl_URL *u, char *hostname,
/* Browser behavior adaptation. If there's a colon with no digits after,
just cut off the name there which makes us ignore the colon and just
- use the default port. Firefox, Chrome and Safari all do that.
-
- Don't do it if the URL has no scheme, to make something that looks like
- a scheme not work!
- */
+ use the default port. Firefox, Chrome and Safari all do that.
+
+ Don't do it if the URL has no scheme, to make something that looks like
+ a scheme not work!
+ */
if(!portptr[1]) {
*portptr = '\0';
- return has_scheme ? CURLUE_OK : CURLUE_BAD_PORT_NUMBER;
+ return has_scheme ? CURLUE_OK : CURLUE_BAD_PORT_NUMBER;
}
if(!ISDIGIT(portptr[1]))
@@ -580,7 +580,7 @@ UNITTEST CURLUcode Curl_parse_port(struct Curl_URL *u, char *hostname,
}
/* scan for byte values < 31 or 127 */
-static CURLUcode junkscan(const char *part)
+static CURLUcode junkscan(const char *part)
{
if(part) {
static const char badbytes[]={
@@ -589,7 +589,7 @@ static CURLUcode junkscan(const char *part)
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
0x7f,
- 0x00 /* null-terminate */
+ 0x00 /* null-terminate */
};
size_t n = strlen(part);
size_t nfine = strcspn(part, badbytes);
@@ -607,12 +607,12 @@ static CURLUcode hostname_check(struct Curl_URL *u, char *hostname)
size_t hlen = strlen(hostname);
if(hostname[0] == '[') {
-#ifdef ENABLE_IPV6
+#ifdef ENABLE_IPV6
char dest[16]; /* fits a binary IPv6 address */
-#endif
+#endif
const char *l = "0123456789abcdefABCDEF:.";
- if(hlen < 4) /* '[::]' is the shortest possible valid string */
- return CURLUE_MALFORMED_INPUT;
+ if(hlen < 4) /* '[::]' is the shortest possible valid string */
+ return CURLUE_MALFORMED_INPUT;
hostname++;
hlen -= 2;
@@ -677,7 +677,7 @@ static CURLUcode seturl(const char *url, CURLU *u, unsigned int flags)
CURLUcode result;
bool url_has_scheme = FALSE;
char schemebuf[MAX_SCHEME_LEN + 1];
- const char *schemep = NULL;
+ const char *schemep = NULL;
size_t schemelen = 0;
size_t urllen;
@@ -798,7 +798,7 @@ static CURLUcode seturl(const char *url, CURLU *u, unsigned int flags)
if(junkscan(schemep))
return CURLUE_MALFORMED_INPUT;
-
+
}
else {
/* no scheme! */
@@ -806,7 +806,7 @@ static CURLUcode seturl(const char *url, CURLU *u, unsigned int flags)
if(!(flags & (CURLU_DEFAULT_SCHEME|CURLU_GUESS_SCHEME)))
return CURLUE_MALFORMED_INPUT;
if(flags & CURLU_DEFAULT_SCHEME)
- schemep = DEFAULT_SCHEME;
+ schemep = DEFAULT_SCHEME;
/*
* The URL was badly formatted, let's try without scheme specified.
@@ -819,83 +819,83 @@ static CURLUcode seturl(const char *url, CURLU *u, unsigned int flags)
p++;
len = p - hostp;
- if(len) {
- memcpy(hostname, hostp, len);
- hostname[len] = 0;
+ if(len) {
+ memcpy(hostname, hostp, len);
+ hostname[len] = 0;
+ }
+ else {
+ if(!(flags & CURLU_NO_AUTHORITY))
+ return CURLUE_MALFORMED_INPUT;
}
- else {
- if(!(flags & CURLU_NO_AUTHORITY))
- return CURLUE_MALFORMED_INPUT;
- }
len = strlen(p);
memcpy(path, p, len);
path[len] = 0;
- if(schemep) {
- u->scheme = strdup(schemep);
- if(!u->scheme)
- return CURLUE_OUT_OF_MEMORY;
- }
+ if(schemep) {
+ u->scheme = strdup(schemep);
+ if(!u->scheme)
+ return CURLUE_OUT_OF_MEMORY;
+ }
}
if(junkscan(path))
return CURLUE_MALFORMED_INPUT;
- if((flags & CURLU_URLENCODE) && path[0]) {
- /* worst case output length is 3x the original! */
- char *newp = malloc(strlen(path) * 3);
- if(!newp)
- return CURLUE_OUT_OF_MEMORY;
- path_alloced = TRUE;
- strcpy_url(newp, path, TRUE); /* consider it relative */
- u->temppath = path = newp;
- }
-
- fragment = strchr(path, '#');
- if(fragment) {
- *fragment++ = 0;
- if(fragment[0]) {
- u->fragment = strdup(fragment);
- if(!u->fragment)
- return CURLUE_OUT_OF_MEMORY;
- }
- }
-
+ if((flags & CURLU_URLENCODE) && path[0]) {
+ /* worst case output length is 3x the original! */
+ char *newp = malloc(strlen(path) * 3);
+ if(!newp)
+ return CURLUE_OUT_OF_MEMORY;
+ path_alloced = TRUE;
+ strcpy_url(newp, path, TRUE); /* consider it relative */
+ u->temppath = path = newp;
+ }
+
+ fragment = strchr(path, '#');
+ if(fragment) {
+ *fragment++ = 0;
+ if(fragment[0]) {
+ u->fragment = strdup(fragment);
+ if(!u->fragment)
+ return CURLUE_OUT_OF_MEMORY;
+ }
+ }
+
query = strchr(path, '?');
- if(query) {
+ if(query) {
*query++ = 0;
- /* done even if the query part is a blank string */
- u->query = strdup(query);
- if(!u->query)
- return CURLUE_OUT_OF_MEMORY;
- }
+ /* done even if the query part is a blank string */
+ u->query = strdup(query);
+ if(!u->query)
+ return CURLUE_OUT_OF_MEMORY;
+ }
if(!path[0])
- /* if there's no path left set, unset */
+ /* if there's no path left set, unset */
path = NULL;
- else {
- if(!(flags & CURLU_PATH_AS_IS)) {
- /* remove ../ and ./ sequences according to RFC3986 */
- char *newp = Curl_dedotdotify(path);
- if(!newp)
- return CURLUE_OUT_OF_MEMORY;
-
- if(strcmp(newp, path)) {
- /* if we got a new version */
- if(path_alloced)
- Curl_safefree(u->temppath);
- u->temppath = path = newp;
- path_alloced = TRUE;
- }
- else
- free(newp);
+ else {
+ if(!(flags & CURLU_PATH_AS_IS)) {
+ /* remove ../ and ./ sequences according to RFC3986 */
+ char *newp = Curl_dedotdotify(path);
+ if(!newp)
+ return CURLUE_OUT_OF_MEMORY;
+
+ if(strcmp(newp, path)) {
+ /* if we got a new version */
+ if(path_alloced)
+ Curl_safefree(u->temppath);
+ u->temppath = path = newp;
+ path_alloced = TRUE;
+ }
+ else
+ free(newp);
}
-
+
u->path = path_alloced?path:strdup(path);
if(!u->path)
return CURLUE_OUT_OF_MEMORY;
- u->temppath = NULL; /* used now */
+ u->temppath = NULL; /* used now */
}
if(hostname) {
@@ -905,52 +905,52 @@ static CURLUcode seturl(const char *url, CURLU *u, unsigned int flags)
if(junkscan(hostname))
return CURLUE_MALFORMED_INPUT;
- result = parse_hostname_login(u, &hostname, flags);
+ result = parse_hostname_login(u, &hostname, flags);
if(result)
return result;
- result = Curl_parse_port(u, hostname, url_has_scheme);
+ result = Curl_parse_port(u, hostname, url_has_scheme);
if(result)
return result;
- if(0 == strlen(hostname) && (flags & CURLU_NO_AUTHORITY)) {
- /* Skip hostname check, it's allowed to be empty. */
- }
- else {
- result = hostname_check(u, hostname);
- if(result)
- return result;
- }
+ if(0 == strlen(hostname) && (flags & CURLU_NO_AUTHORITY)) {
+ /* Skip hostname check, it's allowed to be empty. */
+ }
+ else {
+ result = hostname_check(u, hostname);
+ if(result)
+ return result;
+ }
u->host = strdup(hostname);
if(!u->host)
return CURLUE_OUT_OF_MEMORY;
- if((flags & CURLU_GUESS_SCHEME) && !schemep) {
- /* legacy curl-style guess based on host name */
- if(checkprefix("ftp.", hostname))
- schemep = "ftp";
- else if(checkprefix("dict.", hostname))
- schemep = "dict";
- else if(checkprefix("ldap.", hostname))
- schemep = "ldap";
- else if(checkprefix("imap.", hostname))
- schemep = "imap";
- else if(checkprefix("smtp.", hostname))
- schemep = "smtp";
- else if(checkprefix("pop3.", hostname))
- schemep = "pop3";
- else
- schemep = "http";
-
- u->scheme = strdup(schemep);
- if(!u->scheme)
- return CURLUE_OUT_OF_MEMORY;
- }
+ if((flags & CURLU_GUESS_SCHEME) && !schemep) {
+ /* legacy curl-style guess based on host name */
+ if(checkprefix("ftp.", hostname))
+ schemep = "ftp";
+ else if(checkprefix("dict.", hostname))
+ schemep = "dict";
+ else if(checkprefix("ldap.", hostname))
+ schemep = "ldap";
+ else if(checkprefix("imap.", hostname))
+ schemep = "imap";
+ else if(checkprefix("smtp.", hostname))
+ schemep = "smtp";
+ else if(checkprefix("pop3.", hostname))
+ schemep = "pop3";
+ else
+ schemep = "http";
+
+ u->scheme = strdup(schemep);
+ if(!u->scheme)
+ return CURLUE_OUT_OF_MEMORY;
+ }
}
- Curl_safefree(u->scratch);
- Curl_safefree(u->temppath);
+ Curl_safefree(u->scratch);
+ Curl_safefree(u->temppath);
return CURLUE_OK;
}
@@ -1115,23 +1115,23 @@ CURLUcode curl_url_get(CURLU *u, CURLUPart what,
else
return CURLUE_NO_SCHEME;
- h = Curl_builtin_scheme(scheme);
- if(!port && (flags & CURLU_DEFAULT_PORT)) {
- /* there's no stored port number, but asked to deliver
- a default one for the scheme */
- if(h) {
- msnprintf(portbuf, sizeof(portbuf), "%ld", h->defport);
- port = portbuf;
+ h = Curl_builtin_scheme(scheme);
+ if(!port && (flags & CURLU_DEFAULT_PORT)) {
+ /* there's no stored port number, but asked to deliver
+ a default one for the scheme */
+ if(h) {
+ msnprintf(portbuf, sizeof(portbuf), "%ld", h->defport);
+ port = portbuf;
}
}
- else if(port) {
- /* there is a stored port number, but asked to inhibit if it matches
- the default one for the scheme */
- if(h && (h->defport == u->portnum) &&
- (flags & CURLU_NO_DEFAULT_PORT))
- port = NULL;
- }
-
+ else if(port) {
+ /* there is a stored port number, but asked to inhibit if it matches
+ the default one for the scheme */
+ if(h && (h->defport == u->portnum) &&
+ (flags & CURLU_NO_DEFAULT_PORT))
+ port = NULL;
+ }
+
if(h && !(h->flags & PROTOPT_URLOPTIONS))
options = NULL;
@@ -1190,10 +1190,10 @@ CURLUcode curl_url_get(CURLU *u, CURLUPart what,
if(urldecode) {
char *decoded;
size_t dlen;
- /* this unconditional rejection of control bytes is documented
- API behavior */
- CURLcode res = Curl_urldecode(NULL, *part, 0, &decoded, &dlen,
- REJECT_CTRL);
+ /* this unconditional rejection of control bytes is documented
+ API behavior */
+ CURLcode res = Curl_urldecode(NULL, *part, 0, &decoded, &dlen,
+ REJECT_CTRL);
free(*part);
if(res) {
*part = NULL;
@@ -1260,7 +1260,7 @@ CURLUcode curl_url_set(CURLU *u, CURLUPart what,
return CURLUE_UNKNOWN_PART;
}
if(storep && *storep) {
- Curl_safefree(*storep);
+ Curl_safefree(*storep);
}
return CURLUE_OK;
}
@@ -1288,7 +1288,7 @@ CURLUcode curl_url_set(CURLU *u, CURLUPart what,
break;
case CURLUPART_HOST:
storep = &u->host;
- Curl_safefree(u->zoneid);
+ Curl_safefree(u->zoneid);
break;
case CURLUPART_ZONEID:
storep = &u->zoneid;
@@ -1380,8 +1380,8 @@ CURLUcode curl_url_set(CURLU *u, CURLUPart what,
default:
return CURLUE_UNKNOWN_PART;
}
- DEBUGASSERT(storep);
- {
+ DEBUGASSERT(storep);
+ {
const char *newp = part;
size_t nalloc = strlen(part);
@@ -1395,14 +1395,14 @@ CURLUcode curl_url_set(CURLU *u, CURLUPart what,
char *enc = malloc(nalloc * 3 + 1); /* for worst case! */
if(!enc)
return CURLUE_OUT_OF_MEMORY;
- for(i = (const unsigned char *)part, o = enc; *i; i++) {
- if((*i == ' ') && plusencode) {
- *o = '+';
- o++;
+ for(i = (const unsigned char *)part, o = enc; *i; i++) {
+ if((*i == ' ') && plusencode) {
+ *o = '+';
+ o++;
}
- else if(Curl_isunreserved(*i) ||
- ((*i == '/') && urlskipslash) ||
- ((*i == '=') && equalsencode)) {
+ else if(Curl_isunreserved(*i) ||
+ ((*i == '/') && urlskipslash) ||
+ ((*i == '=') && equalsencode)) {
if((*i == '=') && equalsencode)
/* only skip the first equals sign */
equalsencode = FALSE;
@@ -1414,7 +1414,7 @@ CURLUcode curl_url_set(CURLU *u, CURLUPart what,
o += 3;
}
}
- *o = 0; /* null-terminate */
+ *o = 0; /* null-terminate */
newp = enc;
}
else {
@@ -1460,15 +1460,15 @@ CURLUcode curl_url_set(CURLU *u, CURLUPart what,
}
if(what == CURLUPART_HOST) {
- if(0 == strlen(newp) && (flags & CURLU_NO_AUTHORITY)) {
- /* Skip hostname check, it's allowed to be empty. */
+ if(0 == strlen(newp) && (flags & CURLU_NO_AUTHORITY)) {
+ /* Skip hostname check, it's allowed to be empty. */
+ }
+ else {
+ if(hostname_check(u, (char *)newp)) {
+ free((char *)newp);
+ return CURLUE_MALFORMED_INPUT;
+ }
}
- else {
- if(hostname_check(u, (char *)newp)) {
- free((char *)newp);
- return CURLUE_MALFORMED_INPUT;
- }
- }
}
free(*storep);
diff --git a/contrib/libs/curl/lib/urldata.h b/contrib/libs/curl/lib/urldata.h
index cc4a82c501..b824856427 100644
--- a/contrib/libs/curl/lib/urldata.h
+++ b/contrib/libs/curl/lib/urldata.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -49,7 +49,7 @@
#define PORT_RTMPT PORT_HTTP
#define PORT_RTMPS PORT_HTTPS
#define PORT_GOPHER 70
-#define PORT_MQTT 1883
+#define PORT_MQTT 1883
#define DICT_MATCH "/MATCH:"
#define DICT_MATCH2 "/M:"
@@ -69,17 +69,17 @@
#define PROTO_FAMILY_POP3 (CURLPROTO_POP3|CURLPROTO_POP3S)
#define PROTO_FAMILY_SMB (CURLPROTO_SMB|CURLPROTO_SMBS)
#define PROTO_FAMILY_SMTP (CURLPROTO_SMTP|CURLPROTO_SMTPS)
-#define PROTO_FAMILY_SSH (CURLPROTO_SCP|CURLPROTO_SFTP)
+#define PROTO_FAMILY_SSH (CURLPROTO_SCP|CURLPROTO_SFTP)
#define DEFAULT_CONNCACHE_SIZE 5
/* length of longest IPv6 address string including the trailing null */
#define MAX_IPADR_LEN sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")
-/* Default FTP/IMAP etc response timeout in milliseconds */
+/* Default FTP/IMAP etc response timeout in milliseconds */
#define RESP_TIMEOUT (120*1000)
-/* Max string input length is a precaution against abuse and to detect junk
+/* Max string input length is a precaution against abuse and to detect junk
input easier and better. */
#define CURL_MAX_INPUT_LENGTH 8000000
@@ -102,7 +102,7 @@
#include "hostip.h"
#include "hash.h"
#include "splay.h"
-#include "dynbuf.h"
+#include "dynbuf.h"
/* return the count of bytes sent, or -1 on error */
typedef ssize_t (Curl_send)(struct connectdata *conn, /* connection data */
@@ -124,11 +124,11 @@ typedef ssize_t (Curl_recv)(struct connectdata *conn, /* connection data */
#include "smtp.h"
#include "ftp.h"
#include "file.h"
-#include "vssh/ssh.h"
+#include "vssh/ssh.h"
#include "http.h"
#include "rtsp.h"
#include "smb.h"
-#include "mqtt.h"
+#include "mqtt.h"
#include "wildcard.h"
#include "multihandle.h"
#include "quic.h"
@@ -156,13 +156,13 @@ typedef ssize_t (Curl_recv)(struct connectdata *conn, /* connection data */
((x) && ((x)->magic == CURLEASY_MAGIC_NUMBER))
/* the type we use for storing a single boolean bit */
-#ifdef _MSC_VER
-typedef bool bit;
-#define BIT(x) bool x
-#else
+#ifdef _MSC_VER
+typedef bool bit;
+#define BIT(x) bool x
+#else
typedef unsigned int bit;
-#define BIT(x) bit x:1
-#endif
+#define BIT(x) bit x:1
+#endif
#ifdef HAVE_GSSAPI
/* Types needed for krb5-ftp connections */
@@ -170,7 +170,7 @@ struct krb5buffer {
void *data;
size_t size;
size_t index;
- BIT(eof_flag);
+ BIT(eof_flag);
};
enum protection_level {
@@ -210,10 +210,10 @@ struct ssl_connect_data {
#if defined(USE_SSL)
struct ssl_backend_data *backend;
#endif
- /* Use ssl encrypted communications TRUE/FALSE. The library is not
- necessarily using ssl at the moment but at least asked to or means to use
- it. See 'state' for the exact current state of the connection. */
- BIT(use);
+ /* Use ssl encrypted communications TRUE/FALSE. The library is not
+ necessarily using ssl at the moment but at least asked to or means to use
+ it. See 'state' for the exact current state of the connection. */
+ BIT(use);
};
struct ssl_primary_config {
@@ -226,13 +226,13 @@ struct ssl_primary_config {
char *egdsocket; /* path to file containing the EGD daemon socket */
char *cipher_list; /* list of ciphers to use */
char *cipher_list13; /* list of TLS 1.3 cipher suites to use */
- char *pinned_key;
- struct curl_blob *cert_blob;
- char *curves; /* list of curves to use */
- BIT(verifypeer); /* set TRUE if this is desired */
- BIT(verifyhost); /* set TRUE if CN/SAN must match hostname */
- BIT(verifystatus); /* set TRUE if certificate status must be checked */
- BIT(sessionid); /* cache session IDs or not */
+ char *pinned_key;
+ struct curl_blob *cert_blob;
+ char *curves; /* list of curves to use */
+ BIT(verifypeer); /* set TRUE if this is desired */
+ BIT(verifyhost); /* set TRUE if CN/SAN must match hostname */
+ BIT(verifystatus); /* set TRUE if certificate status must be checked */
+ BIT(sessionid); /* cache session IDs or not */
};
struct ssl_config_data {
@@ -240,12 +240,12 @@ struct ssl_config_data {
long certverifyresult; /* result from the certificate verification */
char *CRLfile; /* CRL to check certificate revocation */
char *issuercert;/* optional issuer certificate filename */
- struct curl_blob *issuercert_blob;
+ struct curl_blob *issuercert_blob;
curl_ssl_ctx_callback fsslctx; /* function to initialize ssl ctx */
void *fsslctxp; /* parameter for call back */
char *cert_type; /* format for certificate (default: PEM)*/
char *key; /* private key file name */
- struct curl_blob *key_blob;
+ struct curl_blob *key_blob;
char *key_type; /* format for private key (default: PEM) */
char *key_passwd; /* plain text private key password */
#ifdef USE_TLS_SRP
@@ -253,14 +253,14 @@ struct ssl_config_data {
char *password; /* TLS password (for, e.g., SRP) */
enum CURL_TLSAUTH authtype; /* TLS authentication type (default SRP) */
#endif
- BIT(certinfo); /* gather lots of certificate info */
- BIT(falsestart);
- BIT(enable_beast); /* allow this flaw for interoperability's sake*/
- BIT(no_revoke); /* disable SSL certificate revocation checks */
- BIT(no_partialchain); /* don't accept partial certificate chains */
- BIT(revoke_best_effort); /* ignore SSL revocation offline/missing revocation
- list errors */
- BIT(native_ca_store); /* use the native ca store of operating system */
+ BIT(certinfo); /* gather lots of certificate info */
+ BIT(falsestart);
+ BIT(enable_beast); /* allow this flaw for interoperability's sake*/
+ BIT(no_revoke); /* disable SSL certificate revocation checks */
+ BIT(no_partialchain); /* don't accept partial certificate chains */
+ BIT(revoke_best_effort); /* ignore SSL revocation offline/missing revocation
+ list errors */
+ BIT(native_ca_store); /* use the native ca store of operating system */
};
struct ssl_general_config {
@@ -268,7 +268,7 @@ struct ssl_general_config {
};
/* information stored about one single SSL session */
-struct Curl_ssl_session {
+struct Curl_ssl_session {
char *name; /* host name for which this ID was used */
char *conn_to_host; /* host name for the connection (may be NULL) */
const char *scheme; /* protocol scheme used */
@@ -303,8 +303,8 @@ struct digestdata {
char *qop;
char *algorithm;
int nc; /* nounce count */
- BIT(stale); /* set true for re-negotiation */
- BIT(userhash);
+ BIT(stale); /* set true for re-negotiation */
+ BIT(userhash);
#endif
};
@@ -370,15 +370,15 @@ struct ntlmdata {
unsigned char nonce[8];
void *target_info; /* TargetInfo received in the ntlm type-2 message */
unsigned int target_info_len;
-
-#if defined(NTLM_WB_ENABLED)
- /* used for communication with Samba's winbind daemon helper ntlm_auth */
- curl_socket_t ntlm_auth_hlpr_socket;
- pid_t ntlm_auth_hlpr_pid;
- char *challenge; /* The received base64 encoded ntlm type-2 message */
- char *response; /* The generated base64 ntlm type-1/type-3 message */
+
+#if defined(NTLM_WB_ENABLED)
+ /* used for communication with Samba's winbind daemon helper ntlm_auth */
+ curl_socket_t ntlm_auth_hlpr_socket;
+ pid_t ntlm_auth_hlpr_pid;
+ char *challenge; /* The received base64 encoded ntlm type-2 message */
+ char *response; /* The generated base64 ntlm type-1/type-3 message */
+#endif
#endif
-#endif
};
#endif
@@ -406,10 +406,10 @@ struct negotiatedata {
size_t output_token_length;
#endif
#endif
- BIT(noauthpersist);
- BIT(havenoauthpersist);
- BIT(havenegdata);
- BIT(havemultiplerequests);
+ BIT(noauthpersist);
+ BIT(havenoauthpersist);
+ BIT(havenegdata);
+ BIT(havemultiplerequests);
};
#endif
@@ -418,76 +418,76 @@ struct negotiatedata {
* Boolean values that concerns this connection.
*/
struct ConnectBits {
- bool tcpconnect[2]; /* the TCP layer (or similar) is connected, this is set
- the first time on the first connect function call */
-#ifndef CURL_DISABLE_PROXY
+ bool tcpconnect[2]; /* the TCP layer (or similar) is connected, this is set
+ the first time on the first connect function call */
+#ifndef CURL_DISABLE_PROXY
bool proxy_ssl_connected[2]; /* TRUE when SSL initialization for HTTPS proxy
is complete */
- BIT(httpproxy); /* if set, this transfer is done through a http proxy */
- BIT(socksproxy); /* if set, this transfer is done through a socks proxy */
- BIT(proxy_user_passwd); /* user+password for the proxy? */
- BIT(tunnel_proxy); /* if CONNECT is used to "tunnel" through the proxy.
- This is implicit when SSL-protocols are used through
- proxies, but can also be enabled explicitly by
- apps */
- BIT(proxy_connect_closed); /* TRUE if a proxy disconnected the connection
- in a CONNECT request with auth, so that
- libcurl should reconnect and continue. */
-#endif
- /* always modify bits.close with the connclose() and connkeep() macros! */
- BIT(close); /* if set, we close the connection after this request */
- BIT(reuse); /* if set, this is a re-used connection */
- BIT(altused); /* this is an alt-svc "redirect" */
- BIT(conn_to_host); /* if set, this connection has a "connect to host"
- that overrides the host in the URL */
- BIT(conn_to_port); /* if set, this connection has a "connect to port"
- that overrides the port in the URL (remote port) */
- BIT(proxy); /* if set, this transfer is done through a proxy - any type */
- BIT(user_passwd); /* do we use user+password for this connection? */
- BIT(ipv6_ip); /* we communicate with a remote site specified with pure IPv6
- IP address */
- BIT(ipv6); /* we communicate with a site using an IPv6 address */
- BIT(do_more); /* this is set TRUE if the ->curl_do_more() function is
- supposed to be called, after ->curl_do() */
- BIT(protoconnstart);/* the protocol layer has STARTED its operation after
- the TCP layer connect */
- BIT(retry); /* this connection is about to get closed and then
- re-attempted at another connection. */
- BIT(authneg); /* TRUE when the auth phase has started, which means
- that we are creating a request with an auth header,
- but it is not the final request in the auth
- negotiation. */
- BIT(rewindaftersend);/* TRUE when the sending couldn't be stopped even
- though it will be discarded. When the whole send
- operation is done, we must call the data rewind
- callback. */
+ BIT(httpproxy); /* if set, this transfer is done through a http proxy */
+ BIT(socksproxy); /* if set, this transfer is done through a socks proxy */
+ BIT(proxy_user_passwd); /* user+password for the proxy? */
+ BIT(tunnel_proxy); /* if CONNECT is used to "tunnel" through the proxy.
+ This is implicit when SSL-protocols are used through
+ proxies, but can also be enabled explicitly by
+ apps */
+ BIT(proxy_connect_closed); /* TRUE if a proxy disconnected the connection
+ in a CONNECT request with auth, so that
+ libcurl should reconnect and continue. */
+#endif
+ /* always modify bits.close with the connclose() and connkeep() macros! */
+ BIT(close); /* if set, we close the connection after this request */
+ BIT(reuse); /* if set, this is a re-used connection */
+ BIT(altused); /* this is an alt-svc "redirect" */
+ BIT(conn_to_host); /* if set, this connection has a "connect to host"
+ that overrides the host in the URL */
+ BIT(conn_to_port); /* if set, this connection has a "connect to port"
+ that overrides the port in the URL (remote port) */
+ BIT(proxy); /* if set, this transfer is done through a proxy - any type */
+ BIT(user_passwd); /* do we use user+password for this connection? */
+ BIT(ipv6_ip); /* we communicate with a remote site specified with pure IPv6
+ IP address */
+ BIT(ipv6); /* we communicate with a site using an IPv6 address */
+ BIT(do_more); /* this is set TRUE if the ->curl_do_more() function is
+ supposed to be called, after ->curl_do() */
+ BIT(protoconnstart);/* the protocol layer has STARTED its operation after
+ the TCP layer connect */
+ BIT(retry); /* this connection is about to get closed and then
+ re-attempted at another connection. */
+ BIT(authneg); /* TRUE when the auth phase has started, which means
+ that we are creating a request with an auth header,
+ but it is not the final request in the auth
+ negotiation. */
+ BIT(rewindaftersend);/* TRUE when the sending couldn't be stopped even
+ though it will be discarded. When the whole send
+ operation is done, we must call the data rewind
+ callback. */
#ifndef CURL_DISABLE_FTP
- BIT(ftp_use_epsv); /* As set with CURLOPT_FTP_USE_EPSV, but if we find out
- EPSV doesn't work we disable it for the forthcoming
- requests */
- BIT(ftp_use_eprt); /* As set with CURLOPT_FTP_USE_EPRT, but if we find out
- EPRT doesn't work we disable it for the forthcoming
- requests */
- BIT(ftp_use_data_ssl); /* Enabled SSL for the data connection */
- BIT(ftp_use_control_ssl); /* Enabled SSL for the control connection */
+ BIT(ftp_use_epsv); /* As set with CURLOPT_FTP_USE_EPSV, but if we find out
+ EPSV doesn't work we disable it for the forthcoming
+ requests */
+ BIT(ftp_use_eprt); /* As set with CURLOPT_FTP_USE_EPRT, but if we find out
+ EPRT doesn't work we disable it for the forthcoming
+ requests */
+ BIT(ftp_use_data_ssl); /* Enabled SSL for the data connection */
+ BIT(ftp_use_control_ssl); /* Enabled SSL for the control connection */
#endif
- BIT(netrc); /* name+password provided by netrc */
- BIT(bound); /* set true if bind() has already been done on this socket/
- connection */
- BIT(multiplex); /* connection is multiplexed */
- BIT(tcp_fastopen); /* use TCP Fast Open */
- BIT(tls_enable_npn); /* TLS NPN extension? */
- BIT(tls_enable_alpn); /* TLS ALPN extension? */
- BIT(connect_only);
- BIT(doh);
-#ifdef USE_UNIX_SOCKETS
- BIT(abstract_unix_socket);
-#endif
- BIT(tls_upgraded);
- BIT(sock_accepted); /* TRUE if the SECONDARYSOCKET was created with
- accept() */
- BIT(parallel_connect); /* set TRUE when a parallel connect attempt has
- started (happy eyeballs) */
+ BIT(netrc); /* name+password provided by netrc */
+ BIT(bound); /* set true if bind() has already been done on this socket/
+ connection */
+ BIT(multiplex); /* connection is multiplexed */
+ BIT(tcp_fastopen); /* use TCP Fast Open */
+ BIT(tls_enable_npn); /* TLS NPN extension? */
+ BIT(tls_enable_alpn); /* TLS ALPN extension? */
+ BIT(connect_only);
+ BIT(doh);
+#ifdef USE_UNIX_SOCKETS
+ BIT(abstract_unix_socket);
+#endif
+ BIT(tls_upgraded);
+ BIT(sock_accepted); /* TRUE if the SECONDARYSOCKET was created with
+ accept() */
+ BIT(parallel_connect); /* set TRUE when a parallel connect attempt has
+ started (happy eyeballs) */
};
struct hostname {
@@ -519,8 +519,8 @@ struct Curl_async {
int port;
struct Curl_dns_entry *dns;
int status; /* if done is TRUE, this is the status from the callback */
- struct thread_data *tdata;
- BIT(done); /* set TRUE when the lookup is complete */
+ struct thread_data *tdata;
+ BIT(done); /* set TRUE when the lookup is complete */
};
#define FIRSTSOCKET 0
@@ -547,22 +547,22 @@ enum upgrade101 {
UPGR101_WORKING /* talking upgraded protocol */
};
-enum doh_slots {
- /* Explicit values for first two symbols so as to match hard-coded
- * constants in existing code
- */
- DOH_PROBE_SLOT_IPADDR_V4 = 0, /* make 'V4' stand out for readability */
- DOH_PROBE_SLOT_IPADDR_V6 = 1, /* 'V6' likewise */
-
- /* Space here for (possibly build-specific) additional slot definitions */
-
- /* for example */
- /* #ifdef WANT_DOH_FOOBAR_TXT */
- /* DOH_PROBE_SLOT_FOOBAR_TXT, */
- /* #endif */
-
- /* AFTER all slot definitions, establish how many we have */
- DOH_PROBE_SLOTS
+enum doh_slots {
+ /* Explicit values for first two symbols so as to match hard-coded
+ * constants in existing code
+ */
+ DOH_PROBE_SLOT_IPADDR_V4 = 0, /* make 'V4' stand out for readability */
+ DOH_PROBE_SLOT_IPADDR_V6 = 1, /* 'V6' likewise */
+
+ /* Space here for (possibly build-specific) additional slot definitions */
+
+ /* for example */
+ /* #ifdef WANT_DOH_FOOBAR_TXT */
+ /* DOH_PROBE_SLOT_FOOBAR_TXT, */
+ /* #endif */
+
+ /* AFTER all slot definitions, establish how many we have */
+ DOH_PROBE_SLOTS
};
/* one of these for each DoH request */
@@ -571,12 +571,12 @@ struct dnsprobe {
int dnstype;
unsigned char dohbuffer[512];
size_t dohlen;
- struct dynbuf serverdoh;
+ struct dynbuf serverdoh;
};
struct dohdata {
struct curl_slist *headers;
- struct dnsprobe probe[DOH_PROBE_SLOTS];
+ struct dnsprobe probe[DOH_PROBE_SLOTS];
unsigned int pending; /* still outstanding requests */
const char *host;
int port;
@@ -624,8 +624,8 @@ struct SingleRequest {
enum expect100 exp100; /* expect 100 continue state */
enum upgrade101 upgr101; /* 101 upgrade state */
- /* Content unencoding stack. See sec 3.5, RFC2616. */
- struct contenc_writer *writer_stack;
+ /* Content unencoding stack. See sec 3.5, RFC2616. */
+ struct contenc_writer *writer_stack;
time_t timeofdoc;
long bodywrites;
int keepon;
@@ -643,40 +643,40 @@ struct SingleRequest {
and the 'upload_present' contains the number of bytes available at this
position */
char *upload_fromhere;
-
- /* Allocated protocol-specific data. Each protocol handler makes sure this
- points to data it needs. */
- union {
- struct FILEPROTO *file;
- struct FTP *ftp;
- struct HTTP *http;
- struct IMAP *imap;
- struct ldapreqinfo *ldap;
- struct MQTT *mqtt;
- struct POP3 *pop3;
- struct RTSP *rtsp;
- struct smb_request *smb;
- struct SMTP *smtp;
- struct SSHPROTO *ssh;
- struct TELNET *telnet;
- } p;
+
+ /* Allocated protocol-specific data. Each protocol handler makes sure this
+ points to data it needs. */
+ union {
+ struct FILEPROTO *file;
+ struct FTP *ftp;
+ struct HTTP *http;
+ struct IMAP *imap;
+ struct ldapreqinfo *ldap;
+ struct MQTT *mqtt;
+ struct POP3 *pop3;
+ struct RTSP *rtsp;
+ struct smb_request *smb;
+ struct SMTP *smtp;
+ struct SSHPROTO *ssh;
+ struct TELNET *telnet;
+ } p;
#ifndef CURL_DISABLE_DOH
struct dohdata doh; /* DoH specific data for this request */
#endif
- BIT(header); /* incoming data has HTTP header */
- BIT(content_range); /* set TRUE if Content-Range: was found */
- BIT(upload_done); /* set to TRUE when doing chunked transfer-encoding
- upload and we're uploading the last chunk */
- BIT(ignorebody); /* we read a response-body but we ignore it! */
- BIT(http_bodyless); /* HTTP response status code is between 100 and 199,
- 204 or 304 */
- BIT(chunk); /* if set, this is a chunked transfer-encoding */
- BIT(upload_chunky); /* set TRUE if we are doing chunked transfer-encoding
- on upload */
- BIT(getheader); /* TRUE if header parsing is wanted */
- BIT(forbidchunk); /* used only to explicitly forbid chunk-upload for
- specific upload buffers. See readmoredata() in http.c
- for details. */
+ BIT(header); /* incoming data has HTTP header */
+ BIT(content_range); /* set TRUE if Content-Range: was found */
+ BIT(upload_done); /* set to TRUE when doing chunked transfer-encoding
+ upload and we're uploading the last chunk */
+ BIT(ignorebody); /* we read a response-body but we ignore it! */
+ BIT(http_bodyless); /* HTTP response status code is between 100 and 199,
+ 204 or 304 */
+ BIT(chunk); /* if set, this is a chunked transfer-encoding */
+ BIT(upload_chunky); /* set TRUE if we are doing chunked transfer-encoding
+ on upload */
+ BIT(getheader); /* TRUE if header parsing is wanted */
+ BIT(forbidchunk); /* used only to explicitly forbid chunk-upload for
+ specific upload buffers. See readmoredata() in http.c
+ for details. */
};
/*
@@ -753,8 +753,8 @@ struct Curl_handler {
long defport; /* Default port. */
unsigned int protocol; /* See CURLPROTO_* - this needs to be the single
specific protocol bit */
- unsigned int family; /* single bit for protocol family; basically the
- non-TLS name of the protocol this is */
+ unsigned int family; /* single bit for protocol family; basically the
+ non-TLS name of the protocol this is */
unsigned int flags; /* Extra particular characteristics, see PROTOPT_* */
};
@@ -782,8 +782,8 @@ struct Curl_handler {
HTTP proxy as HTTP proxies may know
this protocol and act as a gateway */
#define PROTOPT_WILDCARD (1<<12) /* protocol supports wildcard matching */
-#define PROTOPT_USERPWDCTRL (1<<13) /* Allow "control bytes" (< 32 ascii) in
- user name and password */
+#define PROTOPT_USERPWDCTRL (1<<13) /* Allow "control bytes" (< 32 ascii) in
+ user name and password */
#define CONNCHECK_NONE 0 /* No checks */
#define CONNCHECK_ISDEAD (1<<0) /* Check if the connection is dead. */
@@ -816,59 +816,59 @@ struct proxy_info {
/* struct for HTTP CONNECT state data */
struct http_connect_state {
- struct dynbuf rcvbuf;
- enum keeponval {
- KEEPON_DONE,
- KEEPON_CONNECT,
- KEEPON_IGNORE
- } keepon;
+ struct dynbuf rcvbuf;
+ enum keeponval {
+ KEEPON_DONE,
+ KEEPON_CONNECT,
+ KEEPON_IGNORE
+ } keepon;
curl_off_t cl; /* size of content to read and ignore */
enum {
TUNNEL_INIT, /* init/default/no tunnel state */
TUNNEL_CONNECT, /* CONNECT has been sent off */
TUNNEL_COMPLETE /* CONNECT response received completely */
} tunnel_state;
- BIT(chunked_encoding);
- BIT(close_connection);
+ BIT(chunked_encoding);
+ BIT(close_connection);
};
struct ldapconninfo;
-/* for the (SOCKS) connect state machine */
-enum connect_t {
- CONNECT_INIT,
- CONNECT_SOCKS_INIT, /* 1 */
- CONNECT_SOCKS_SEND, /* 2 waiting to send more first data */
- CONNECT_SOCKS_READ_INIT, /* 3 set up read */
- CONNECT_SOCKS_READ, /* 4 read server response */
- CONNECT_GSSAPI_INIT, /* 5 */
- CONNECT_AUTH_INIT, /* 6 setup outgoing auth buffer */
- CONNECT_AUTH_SEND, /* 7 send auth */
- CONNECT_AUTH_READ, /* 8 read auth response */
- CONNECT_REQ_INIT, /* 9 init SOCKS "request" */
- CONNECT_RESOLVING, /* 10 */
- CONNECT_RESOLVED, /* 11 */
- CONNECT_RESOLVE_REMOTE, /* 12 */
- CONNECT_REQ_SEND, /* 13 */
- CONNECT_REQ_SENDING, /* 14 */
- CONNECT_REQ_READ, /* 15 */
- CONNECT_REQ_READ_MORE, /* 16 */
- CONNECT_DONE /* 17 connected fine to the remote or the SOCKS proxy */
-};
-
-#define SOCKS_STATE(x) (((x) >= CONNECT_SOCKS_INIT) && \
- ((x) < CONNECT_DONE))
-#define SOCKS_REQUEST_BUFSIZE 600 /* room for large user/pw (255 max each) */
-
-struct connstate {
- enum connect_t state;
- unsigned char socksreq[SOCKS_REQUEST_BUFSIZE];
-
- /* CONNECT_SOCKS_SEND */
- ssize_t outstanding; /* send this many bytes more */
- unsigned char *outp; /* send from this pointer */
-};
-
+/* for the (SOCKS) connect state machine */
+enum connect_t {
+ CONNECT_INIT,
+ CONNECT_SOCKS_INIT, /* 1 */
+ CONNECT_SOCKS_SEND, /* 2 waiting to send more first data */
+ CONNECT_SOCKS_READ_INIT, /* 3 set up read */
+ CONNECT_SOCKS_READ, /* 4 read server response */
+ CONNECT_GSSAPI_INIT, /* 5 */
+ CONNECT_AUTH_INIT, /* 6 setup outgoing auth buffer */
+ CONNECT_AUTH_SEND, /* 7 send auth */
+ CONNECT_AUTH_READ, /* 8 read auth response */
+ CONNECT_REQ_INIT, /* 9 init SOCKS "request" */
+ CONNECT_RESOLVING, /* 10 */
+ CONNECT_RESOLVED, /* 11 */
+ CONNECT_RESOLVE_REMOTE, /* 12 */
+ CONNECT_REQ_SEND, /* 13 */
+ CONNECT_REQ_SENDING, /* 14 */
+ CONNECT_REQ_READ, /* 15 */
+ CONNECT_REQ_READ_MORE, /* 16 */
+ CONNECT_DONE /* 17 connected fine to the remote or the SOCKS proxy */
+};
+
+#define SOCKS_STATE(x) (((x) >= CONNECT_SOCKS_INIT) && \
+ ((x) < CONNECT_DONE))
+#define SOCKS_REQUEST_BUFSIZE 600 /* room for large user/pw (255 max each) */
+
+struct connstate {
+ enum connect_t state;
+ unsigned char socksreq[SOCKS_REQUEST_BUFSIZE];
+
+ /* CONNECT_SOCKS_SEND */
+ ssize_t outstanding; /* send this many bytes more */
+ unsigned char *outp; /* send from this pointer */
+};
+
/*
* The connectdata struct contains all fields and variables that should be
* unique for an entire connection.
@@ -878,8 +878,8 @@ struct connectdata {
caution that this might very well vary between different times this
connection is used! */
struct Curl_easy *data;
- struct connstate cnnct;
- struct Curl_llist_element bundle_node; /* conncache */
+ struct connstate cnnct;
+ struct Curl_llist_element bundle_node; /* conncache */
/* chunk is for HTTP chunked encoding, but is in the general connectdata
struct only because we can do just about any protocol through a HTTP proxy
@@ -901,15 +901,15 @@ struct connectdata {
/* 'dns_entry' is the particular host we use. This points to an entry in the
DNS cache and it will not get pruned while locked. It gets unlocked in
- multi_done(). This entry will be NULL if the connection is re-used as then
+ multi_done(). This entry will be NULL if the connection is re-used as then
there is no name resolve done. */
struct Curl_dns_entry *dns_entry;
/* 'ip_addr' is the particular IP we connected to. It points to a struct
within the DNS cache, so this pointer is only valid as long as the DNS
- cache entry remains locked. It gets unlocked in multi_done() */
- struct Curl_addrinfo *ip_addr;
- struct Curl_addrinfo *tempaddr[2]; /* for happy eyeballs */
+ cache entry remains locked. It gets unlocked in multi_done() */
+ struct Curl_addrinfo *ip_addr;
+ struct Curl_addrinfo *tempaddr[2]; /* for happy eyeballs */
/* 'ip_addr_str' is the ip_addr data as a human readable string.
It remains available as long as the connection does, which is longer than
@@ -934,10 +934,10 @@ struct connectdata {
char *secondaryhostname; /* secondary socket host name (ftp) */
struct hostname conn_to_host; /* the host to connect to. valid only if
bits.conn_to_host is set */
-#ifndef CURL_DISABLE_PROXY
+#ifndef CURL_DISABLE_PROXY
struct proxy_info socks_proxy;
struct proxy_info http_proxy;
-#endif
+#endif
long port; /* which port to use locally */
int remote_port; /* the remote port, not the proxy port! */
int conn_to_port; /* the remote port to connect to. valid only if
@@ -977,7 +977,7 @@ struct connectdata {
curl_socket_t sock[2]; /* two sockets, the second is used for the data
transfer when doing FTP */
curl_socket_t tempsock[2]; /* temporary sockets for happy eyeballs */
- int tempfamily[2]; /* family used for the temp sockets */
+ int tempfamily[2]; /* family used for the temp sockets */
Curl_recv *recv[2];
Curl_send *send[2];
@@ -985,16 +985,16 @@ struct connectdata {
struct postponed_data postponed[2]; /* two buffers for two sockets */
#endif /* USE_RECV_BEFORE_SEND_WORKAROUND */
struct ssl_connect_data ssl[2]; /* this is for ssl-stuff */
-#ifndef CURL_DISABLE_PROXY
+#ifndef CURL_DISABLE_PROXY
struct ssl_connect_data proxy_ssl[2]; /* this is for proxy ssl-stuff */
-#endif
+#endif
#ifdef USE_SSL
void *ssl_extra; /* separately allocated backend-specific data */
#endif
struct ssl_primary_config ssl_config;
-#ifndef CURL_DISABLE_PROXY
+#ifndef CURL_DISABLE_PROXY
struct ssl_primary_config proxy_ssl_config;
-#endif
+#endif
struct ConnectBits bits; /* various state-flags for this connection */
/* connecttime: when connect() is called on the current IP address. Used to
@@ -1004,10 +1004,10 @@ struct connectdata {
/* The two fields below get set in Curl_connecthost */
int num_addr; /* number of addresses to try to connect to */
- /* how long time in milliseconds to spend on trying to connect to each IP
- address, per family */
- timediff_t timeoutms_per_addr[2];
-
+ /* how long time in milliseconds to spend on trying to connect to each IP
+ address, per family */
+ timediff_t timeoutms_per_addr[2];
+
const struct Curl_handler *handler; /* Connection's protocol handler */
const struct Curl_handler *given; /* The protocol first given */
@@ -1028,7 +1028,7 @@ struct connectdata {
CURL_SOCKET_BAD disables */
#ifdef HAVE_GSSAPI
- BIT(sec_complete); /* if Kerberos is enabled for this connection */
+ BIT(sec_complete); /* if Kerberos is enabled for this connection */
enum protection_level command_prot;
enum protection_level data_prot;
enum protection_level request_data_prot;
@@ -1043,7 +1043,7 @@ struct connectdata {
struct kerberos5data krb5; /* variables into the structure definition, */
#endif /* however, some of them are ftp specific. */
- struct Curl_llist easyq; /* List of easy handles using this connection */
+ struct Curl_llist easyq; /* List of easy handles using this connection */
curl_seek_callback seek_func; /* function that seeks the input */
void *seek_client; /* pointer to pass to the seek() above */
@@ -1073,8 +1073,8 @@ struct connectdata {
/* data used for the asynch name resolve callback */
struct Curl_async async;
- /* for chunked-encoded trailer */
- struct dynbuf trailer;
+ /* for chunked-encoded trailer */
+ struct dynbuf trailer;
union {
struct ftp_conn ftpc;
@@ -1088,7 +1088,7 @@ struct connectdata {
struct smb_conn smbc;
void *rtmp;
struct ldapconninfo *ldapc;
- struct mqtt_conn mqtt;
+ struct mqtt_conn mqtt;
} proto;
int cselect_bits; /* bitmask of socket events */
@@ -1153,9 +1153,9 @@ struct PureInfo {
OpenSSL, GnuTLS, Schannel, NSS and GSKit
builds. Asked for with CURLOPT_CERTINFO
/ CURLINFO_CERTINFO */
- CURLproxycode pxcode;
- BIT(timecond); /* set to TRUE if the time condition didn't match, which
- thus made the document NOT get fetched */
+ CURLproxycode pxcode;
+ BIT(timecond); /* set to TRUE if the time condition didn't match, which
+ thus made the document NOT get fetched */
};
@@ -1202,8 +1202,8 @@ struct Progress {
curl_off_t speeder[ CURR_TIME ];
struct curltime speeder_time[ CURR_TIME ];
int speeder_c;
- BIT(callback); /* set when progress callback is used */
- BIT(is_t_startransfer_set);
+ BIT(callback); /* set when progress callback is used */
+ BIT(is_t_startransfer_set);
};
typedef enum {
@@ -1239,12 +1239,12 @@ struct auth {
unsigned long picked;
unsigned long avail; /* Bitmask for what the server reports to support for
this resource */
- BIT(done); /* TRUE when the auth phase is done and ready to do the
- actual request */
- BIT(multipass); /* TRUE if this is not yet authenticated but within the
- auth multipass negotiation */
- BIT(iestyle); /* TRUE if digest should be done IE-style or FALSE if it
- should be RFC compliant */
+ BIT(done); /* TRUE when the auth phase is done and ready to do the
+ actual request */
+ BIT(multipass); /* TRUE if this is not yet authenticated but within the
+ auth multipass negotiation */
+ BIT(iestyle); /* TRUE if digest should be done IE-style or FALSE if it
+ should be RFC compliant */
};
struct Curl_http2_dep {
@@ -1258,7 +1258,7 @@ struct Curl_http2_dep {
* BODY).
*/
struct tempbuf {
- struct dynbuf b;
+ struct dynbuf b;
int type; /* type of the 'tempwrite' buffer as a bitmask that is used with
Curl_client_write() */
};
@@ -1268,8 +1268,8 @@ typedef enum {
EXPIRE_100_TIMEOUT,
EXPIRE_ASYNC_NAME,
EXPIRE_CONNECTTIMEOUT,
- EXPIRE_DNS_PER_NAME, /* family1 */
- EXPIRE_DNS_PER_NAME2, /* family2 */
+ EXPIRE_DNS_PER_NAME, /* family1 */
+ EXPIRE_DNS_PER_NAME2, /* family2 */
EXPIRE_HAPPY_EYEBALLS_DNS, /* See asyn-ares.c */
EXPIRE_HAPPY_EYEBALLS,
EXPIRE_MULTI_PENDING,
@@ -1294,7 +1294,7 @@ typedef enum {
* One instance for each timeout an easy handle can set.
*/
struct time_node {
- struct Curl_llist_element list;
+ struct Curl_llist_element list;
struct curltime time;
expire_id eid;
};
@@ -1315,13 +1315,13 @@ struct UrlState {
/* Points to the connection cache */
struct conncache *conn_cache;
- int retrycount; /* number of retries on a new connection */
-
+ int retrycount; /* number of retries on a new connection */
+
/* buffers to store authentication data in, as parsed from input options */
struct curltime keeps_speed; /* for the progress meter really */
- long lastconnect_id; /* The last connection, -1 if undefined */
- struct dynbuf headerb; /* buffer to store headers in */
+ long lastconnect_id; /* The last connection, -1 if undefined */
+ struct dynbuf headerb; /* buffer to store headers in */
char *buffer; /* download buffer */
char *ulbuf; /* allocated upload buffer or NULL */
@@ -1334,7 +1334,7 @@ struct UrlState {
strdup() data.
*/
int first_remote_port; /* remote port of the first (not followed) request */
- struct Curl_ssl_session *session; /* array of 'max_ssl_sessions' size */
+ struct Curl_ssl_session *session; /* array of 'max_ssl_sessions' size */
long sessionage; /* number of the most recent session */
unsigned int tempcount; /* number of entries in use in tempwrite, 0 - 3 */
struct tempbuf tempwrite[3]; /* BOTH, HEADER, BODY */
@@ -1358,7 +1358,7 @@ struct UrlState {
#endif /* USE_OPENSSL */
struct curltime expiretime; /* set this with Curl_expire() only */
struct Curl_tree timenode; /* for the splay stuff */
- struct Curl_llist timeoutlist; /* list of pending timeouts */
+ struct Curl_llist timeoutlist; /* list of pending timeouts */
struct time_node expires[EXPIRE_LAST]; /* nodes for each expire type */
/* a place to store the most recently set FTP entrypath */
@@ -1367,11 +1367,11 @@ struct UrlState {
int httpversion; /* the lowest HTTP version*10 reported by any server
involved in this request */
-#if !defined(WIN32) && !defined(MSDOS) && !defined(__EMX__)
+#if !defined(WIN32) && !defined(MSDOS) && !defined(__EMX__)
/* do FTP line-end conversions on most platforms */
#define CURL_DO_LINEEND_CONV
/* for FTP downloads: track CRLF sequences that span blocks */
- BIT(prev_block_had_trailing_cr);
+ BIT(prev_block_had_trailing_cr);
/* for FTP downloads: how many CRLFs did we converted to LFs? */
curl_off_t crlf_conversions;
#endif
@@ -1398,60 +1398,60 @@ struct UrlState {
int stream_weight;
CURLU *uh; /* URL handle for the current parsed URL */
struct urlpieces up;
- Curl_HttpReq httpreq; /* what kind of HTTP request (if any) is this */
+ Curl_HttpReq httpreq; /* what kind of HTTP request (if any) is this */
#ifndef CURL_DISABLE_HTTP
size_t trailers_bytes_sent;
- struct dynbuf trailers_buf; /* a buffer containing the compiled trailing
- headers */
+ struct dynbuf trailers_buf; /* a buffer containing the compiled trailing
+ headers */
#endif
trailers_state trailers_state; /* whether we are sending trailers
and what stage are we at */
-
- /* Dynamically allocated strings, MUST be freed before this struct is
- killed. */
- struct dynamically_allocated_data {
- char *proxyuserpwd;
- char *uagent;
- char *accept_encoding;
- char *userpwd;
- char *rangeline;
- char *ref;
- char *host;
- char *cookiehost;
- char *rtsp_transport;
- char *te; /* TE: request header */
- } aptr;
-
+
+ /* Dynamically allocated strings, MUST be freed before this struct is
+ killed. */
+ struct dynamically_allocated_data {
+ char *proxyuserpwd;
+ char *uagent;
+ char *accept_encoding;
+ char *userpwd;
+ char *rangeline;
+ char *ref;
+ char *host;
+ char *cookiehost;
+ char *rtsp_transport;
+ char *te; /* TE: request header */
+ } aptr;
+
#ifdef CURLDEBUG
- BIT(conncache_lock);
+ BIT(conncache_lock);
#endif
/* when curl_easy_perform() is called, the multi handle is "owned" by
the easy handle so curl_easy_cleanup() on such an easy handle will
also close the multi handle! */
- BIT(multi_owned_by_easy);
+ BIT(multi_owned_by_easy);
- BIT(this_is_a_follow); /* this is a followed Location: request */
- BIT(refused_stream); /* this was refused, try again */
- BIT(errorbuf); /* Set to TRUE if the error buffer is already filled in.
+ BIT(this_is_a_follow); /* this is a followed Location: request */
+ BIT(refused_stream); /* this was refused, try again */
+ BIT(errorbuf); /* Set to TRUE if the error buffer is already filled in.
This must be set to FALSE every time _easy_perform() is
called. */
- BIT(allow_port); /* Is set.use_port allowed to take effect or not. This
+ BIT(allow_port); /* Is set.use_port allowed to take effect or not. This
is always set TRUE when curl_easy_perform() is called. */
- BIT(authproblem); /* TRUE if there's some problem authenticating */
+ BIT(authproblem); /* TRUE if there's some problem authenticating */
/* set after initial USER failure, to prevent an authentication loop */
- BIT(ftp_trying_alternative);
- BIT(wildcardmatch); /* enable wildcard matching */
- BIT(expect100header); /* TRUE if we added Expect: 100-continue */
- BIT(disableexpect); /* TRUE if Expect: is disabled due to a previous
- 417 response */
- BIT(use_range);
- BIT(rangestringalloc); /* the range string is malloc()'ed */
- BIT(done); /* set to FALSE when Curl_init_do() is called and set to TRUE
+ BIT(ftp_trying_alternative);
+ BIT(wildcardmatch); /* enable wildcard matching */
+ BIT(expect100header); /* TRUE if we added Expect: 100-continue */
+ BIT(disableexpect); /* TRUE if Expect: is disabled due to a previous
+ 417 response */
+ BIT(use_range);
+ BIT(rangestringalloc); /* the range string is malloc()'ed */
+ BIT(done); /* set to FALSE when Curl_init_do() is called and set to TRUE
when multi_done() is called, to prevent multi_done() to get
invoked twice when the multi interface is used. */
- BIT(stream_depends_e); /* set or don't set the Exclusive bit */
- BIT(previouslypending); /* this transfer WAS in the multi->pending queue */
- BIT(cookie_engine);
+ BIT(stream_depends_e); /* set or don't set the Exclusive bit */
+ BIT(previouslypending); /* this transfer WAS in the multi->pending queue */
+ BIT(cookie_engine);
};
@@ -1469,9 +1469,9 @@ struct DynamicStatic {
curl_easy_setopt(COOKIEFILE) calls */
struct curl_slist *resolve; /* set to point to the set.resolve list when
this should be dealt with in pretransfer */
- BIT(url_alloc); /* URL string is malloc()'ed */
- BIT(referer_alloc); /* referer string is malloc()ed */
- BIT(wildcard_resolve); /* Set to true if any resolve change is a
+ BIT(url_alloc); /* URL string is malloc()'ed */
+ BIT(referer_alloc); /* referer string is malloc()ed */
+ BIT(wildcard_resolve); /* Set to true if any resolve change is a
wildcard */
};
@@ -1486,14 +1486,14 @@ struct DynamicStatic {
struct Curl_multi; /* declared and used only in multi.c */
-/*
- * This enumeration MUST not use conditional directives (#ifdefs), new
- * null terminated strings MUST be added to the enumeration immediately
- * before STRING_LASTZEROTERMINATED, binary fields immediately before
- * STRING_LAST. When doing so, ensure that the packages/OS400/chkstring.c
- * test is updated and applicable changes for EBCDIC to ASCII conversion
- * are catered for in curl_easy_setopt_ccsid()
- */
+/*
+ * This enumeration MUST not use conditional directives (#ifdefs), new
+ * null terminated strings MUST be added to the enumeration immediately
+ * before STRING_LASTZEROTERMINATED, binary fields immediately before
+ * STRING_LAST. When doing so, ensure that the packages/OS400/chkstring.c
+ * test is updated and applicable changes for EBCDIC to ASCII conversion
+ * are catered for in curl_easy_setopt_ccsid()
+ */
enum dupstring {
STRING_CERT_ORIG, /* client certificate file name */
STRING_CERT_PROXY, /* client certificate file name */
@@ -1567,37 +1567,37 @@ enum dupstring {
STRING_TARGET, /* CURLOPT_REQUEST_TARGET */
STRING_DOH, /* CURLOPT_DOH_URL */
STRING_ALTSVC, /* CURLOPT_ALTSVC */
- STRING_HSTS, /* CURLOPT_HSTS */
+ STRING_HSTS, /* CURLOPT_HSTS */
STRING_SASL_AUTHZID, /* CURLOPT_SASL_AUTHZID */
STRING_TEMP_URL, /* temp URL storage for proxy use */
- STRING_DNS_SERVERS,
- STRING_DNS_INTERFACE,
- STRING_DNS_LOCAL_IP4,
- STRING_DNS_LOCAL_IP6,
- STRING_SSL_EC_CURVES,
-
- /* -- end of null-terminated strings -- */
-
+ STRING_DNS_SERVERS,
+ STRING_DNS_INTERFACE,
+ STRING_DNS_LOCAL_IP4,
+ STRING_DNS_LOCAL_IP6,
+ STRING_SSL_EC_CURVES,
+
+ /* -- end of null-terminated strings -- */
+
STRING_LASTZEROTERMINATED,
/* -- below this are pointers to binary data that cannot be strdup'ed. --- */
STRING_COPYPOSTFIELDS, /* if POST, set the fields' values here */
-
+
STRING_LAST /* not used, just an end-of-list marker */
};
-enum dupblob {
- BLOB_CERT_ORIG,
- BLOB_CERT_PROXY,
- BLOB_KEY_ORIG,
- BLOB_KEY_PROXY,
- BLOB_SSL_ISSUERCERT_ORIG,
- BLOB_SSL_ISSUERCERT_PROXY,
- BLOB_LAST
-};
-
+enum dupblob {
+ BLOB_CERT_ORIG,
+ BLOB_CERT_PROXY,
+ BLOB_KEY_ORIG,
+ BLOB_KEY_PROXY,
+ BLOB_SSL_ISSUERCERT_ORIG,
+ BLOB_SSL_ISSUERCERT_PROXY,
+ BLOB_LAST
+};
+
/* callback that gets called when this easy handle is completed within a multi
handle. Only used for internally created transfers, like for example
DoH. */
@@ -1658,12 +1658,12 @@ struct UserDefined {
curl_conv_callback convtonetwork;
/* function to convert from UTF-8 encoding: */
curl_conv_callback convfromutf8;
-#ifdef USE_HSTS
- curl_hstsread_callback hsts_read;
- void *hsts_read_userp;
- curl_hstswrite_callback hsts_write;
- void *hsts_write_userp;
-#endif
+#ifdef USE_HSTS
+ curl_hstsread_callback hsts_read;
+ void *hsts_read_userp;
+ curl_hstswrite_callback hsts_write;
+ void *hsts_write_userp;
+#endif
void *progress_client; /* pointer to pass to the progress callback */
void *ioctl_client; /* pointer to pass to the ioctl callback */
long timeout; /* in milliseconds, 0 means no timeout */
@@ -1700,13 +1700,13 @@ struct UserDefined {
the hostname and port to connect to */
curl_TimeCond timecondition; /* kind of time/date comparison */
time_t timevalue; /* what time to compare with */
- Curl_HttpReq method; /* what kind of HTTP request (if any) is this */
+ Curl_HttpReq method; /* what kind of HTTP request (if any) is this */
long httpversion; /* when non-zero, a specific HTTP version requested to
be used in the library's request(s) */
struct ssl_config_data ssl; /* user defined SSL stuff */
-#ifndef CURL_DISABLE_PROXY
+#ifndef CURL_DISABLE_PROXY
struct ssl_config_data proxy_ssl; /* user defined SSL stuff for proxy */
-#endif
+#endif
struct ssl_general_config general_ssl; /* general user defined SSL stuff */
curl_proxytype proxytype; /* what kind of proxy that is in use */
long dns_cache_timeout; /* DNS cache timeout */
@@ -1736,7 +1736,7 @@ struct UserDefined {
long new_directory_perms; /* Permissions to use when creating remote dirs */
long ssh_auth_types; /* allowed SSH auth types */
char *str[STRING_LAST]; /* array of strings, pointing to allocated memory */
- struct curl_blob *blobs[BLOB_LAST];
+ struct curl_blob *blobs[BLOB_LAST];
unsigned int scope_id; /* Scope id for IPv6 */
long allowed_protocols;
long redir_protocols;
@@ -1774,88 +1774,88 @@ struct UserDefined {
CURLU *uh; /* URL handle for the current parsed URL */
void *trailer_data; /* pointer to pass to trailer data callback */
curl_trailer_callback trailer_callback; /* trailing data callback */
- BIT(is_fread_set); /* has read callback been set to non-NULL? */
- BIT(is_fwrite_set); /* has write callback been set to non-NULL? */
- BIT(free_referer); /* set TRUE if 'referer' points to a string we
+ BIT(is_fread_set); /* has read callback been set to non-NULL? */
+ BIT(is_fwrite_set); /* has write callback been set to non-NULL? */
+ BIT(free_referer); /* set TRUE if 'referer' points to a string we
allocated */
- BIT(tftp_no_options); /* do not send TFTP options requests */
- BIT(sep_headers); /* handle host and proxy headers separately */
- BIT(cookiesession); /* new cookie session? */
- BIT(crlf); /* convert crlf on ftp upload(?) */
- BIT(strip_path_slash); /* strip off initial slash from path */
- BIT(ssh_compression); /* enable SSH compression */
+ BIT(tftp_no_options); /* do not send TFTP options requests */
+ BIT(sep_headers); /* handle host and proxy headers separately */
+ BIT(cookiesession); /* new cookie session? */
+ BIT(crlf); /* convert crlf on ftp upload(?) */
+ BIT(strip_path_slash); /* strip off initial slash from path */
+ BIT(ssh_compression); /* enable SSH compression */
/* Here follows boolean settings that define how to behave during
this session. They are STATIC, set by libcurl users or at least initially
and they don't change during operations. */
- BIT(get_filetime); /* get the time and get of the remote file */
- BIT(tunnel_thru_httpproxy); /* use CONNECT through a HTTP proxy */
- BIT(prefer_ascii); /* ASCII rather than binary */
- BIT(ftp_append); /* append, not overwrite, on upload */
- BIT(ftp_list_only); /* switch FTP command for listing directories */
+ BIT(get_filetime); /* get the time and get of the remote file */
+ BIT(tunnel_thru_httpproxy); /* use CONNECT through a HTTP proxy */
+ BIT(prefer_ascii); /* ASCII rather than binary */
+ BIT(ftp_append); /* append, not overwrite, on upload */
+ BIT(ftp_list_only); /* switch FTP command for listing directories */
#ifndef CURL_DISABLE_FTP
- BIT(ftp_use_port); /* use the FTP PORT command */
- BIT(ftp_use_epsv); /* if EPSV is to be attempted or not */
- BIT(ftp_use_eprt); /* if EPRT is to be attempted or not */
- BIT(ftp_use_pret); /* if PRET is to be used before PASV or not */
- BIT(ftp_skip_ip); /* skip the IP address the FTP server passes on to
+ BIT(ftp_use_port); /* use the FTP PORT command */
+ BIT(ftp_use_epsv); /* if EPSV is to be attempted or not */
+ BIT(ftp_use_eprt); /* if EPRT is to be attempted or not */
+ BIT(ftp_use_pret); /* if PRET is to be used before PASV or not */
+ BIT(ftp_skip_ip); /* skip the IP address the FTP server passes on to
us */
#endif
- BIT(hide_progress); /* don't use the progress meter */
- BIT(http_fail_on_error); /* fail on HTTP error codes >= 400 */
- BIT(http_keep_sending_on_error); /* for HTTP status codes >= 300 */
- BIT(http_follow_location); /* follow HTTP redirects */
- BIT(http_transfer_encoding); /* request compressed HTTP transfer-encoding */
- BIT(allow_auth_to_other_hosts);
- BIT(include_header); /* include received protocol headers in data output */
- BIT(http_set_referer); /* is a custom referer used */
- BIT(http_auto_referer); /* set "correct" referer when following
- location: */
- BIT(opt_no_body); /* as set with CURLOPT_NOBODY */
- BIT(upload); /* upload request */
- BIT(verbose); /* output verbosity */
- BIT(krb); /* Kerberos connection requested */
- BIT(reuse_forbid); /* forbidden to be reused, close after use */
- BIT(reuse_fresh); /* do not re-use an existing connection */
- BIT(no_signal); /* do not use any signal/alarm handler */
- BIT(tcp_nodelay); /* whether to enable TCP_NODELAY or not */
- BIT(ignorecl); /* ignore content length */
- BIT(connect_only); /* make connection, let application use the socket */
- BIT(http_te_skip); /* pass the raw body data to the user, even when
- transfer-encoded (chunked, compressed) */
- BIT(http_ce_skip); /* pass the raw body data to the user, even when
- content-encoded (chunked, compressed) */
- BIT(proxy_transfer_mode); /* set transfer mode (;type=<a|i>) when doing
- FTP via an HTTP proxy */
+ BIT(hide_progress); /* don't use the progress meter */
+ BIT(http_fail_on_error); /* fail on HTTP error codes >= 400 */
+ BIT(http_keep_sending_on_error); /* for HTTP status codes >= 300 */
+ BIT(http_follow_location); /* follow HTTP redirects */
+ BIT(http_transfer_encoding); /* request compressed HTTP transfer-encoding */
+ BIT(allow_auth_to_other_hosts);
+ BIT(include_header); /* include received protocol headers in data output */
+ BIT(http_set_referer); /* is a custom referer used */
+ BIT(http_auto_referer); /* set "correct" referer when following
+ location: */
+ BIT(opt_no_body); /* as set with CURLOPT_NOBODY */
+ BIT(upload); /* upload request */
+ BIT(verbose); /* output verbosity */
+ BIT(krb); /* Kerberos connection requested */
+ BIT(reuse_forbid); /* forbidden to be reused, close after use */
+ BIT(reuse_fresh); /* do not re-use an existing connection */
+ BIT(no_signal); /* do not use any signal/alarm handler */
+ BIT(tcp_nodelay); /* whether to enable TCP_NODELAY or not */
+ BIT(ignorecl); /* ignore content length */
+ BIT(connect_only); /* make connection, let application use the socket */
+ BIT(http_te_skip); /* pass the raw body data to the user, even when
+ transfer-encoded (chunked, compressed) */
+ BIT(http_ce_skip); /* pass the raw body data to the user, even when
+ content-encoded (chunked, compressed) */
+ BIT(proxy_transfer_mode); /* set transfer mode (;type=<a|i>) when doing
+ FTP via an HTTP proxy */
#if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
- BIT(socks5_gssapi_nec); /* Flag to support NEC SOCKS5 server */
+ BIT(socks5_gssapi_nec); /* Flag to support NEC SOCKS5 server */
#endif
- BIT(sasl_ir); /* Enable/disable SASL initial response */
- BIT(wildcard_enabled); /* enable wildcard matching */
- BIT(tcp_keepalive); /* use TCP keepalives */
- BIT(tcp_fastopen); /* use TCP Fast Open */
- BIT(ssl_enable_npn); /* TLS NPN extension? */
- BIT(ssl_enable_alpn);/* TLS ALPN extension? */
- BIT(path_as_is); /* allow dotdots? */
- BIT(pipewait); /* wait for multiplex status before starting a new
- connection */
- BIT(suppress_connect_headers); /* suppress proxy CONNECT response headers
- from user callbacks */
- BIT(dns_shuffle_addresses); /* whether to shuffle addresses before use */
- BIT(stream_depends_e); /* set or don't set the Exclusive bit */
- BIT(haproxyprotocol); /* whether to send HAProxy PROXY protocol v1
- header */
- BIT(abstract_unix_socket);
- BIT(disallow_username_in_url); /* disallow username in url */
- BIT(doh); /* DNS-over-HTTPS enabled */
- BIT(doh_get); /* use GET for DoH requests, instead of POST */
- BIT(http09_allowed); /* allow HTTP/0.9 responses */
- BIT(mail_rcpt_allowfails); /* allow RCPT TO command to fail for some
- recipients */
+ BIT(sasl_ir); /* Enable/disable SASL initial response */
+ BIT(wildcard_enabled); /* enable wildcard matching */
+ BIT(tcp_keepalive); /* use TCP keepalives */
+ BIT(tcp_fastopen); /* use TCP Fast Open */
+ BIT(ssl_enable_npn); /* TLS NPN extension? */
+ BIT(ssl_enable_alpn);/* TLS ALPN extension? */
+ BIT(path_as_is); /* allow dotdots? */
+ BIT(pipewait); /* wait for multiplex status before starting a new
+ connection */
+ BIT(suppress_connect_headers); /* suppress proxy CONNECT response headers
+ from user callbacks */
+ BIT(dns_shuffle_addresses); /* whether to shuffle addresses before use */
+ BIT(stream_depends_e); /* set or don't set the Exclusive bit */
+ BIT(haproxyprotocol); /* whether to send HAProxy PROXY protocol v1
+ header */
+ BIT(abstract_unix_socket);
+ BIT(disallow_username_in_url); /* disallow username in url */
+ BIT(doh); /* DNS-over-HTTPS enabled */
+ BIT(doh_get); /* use GET for DoH requests, instead of POST */
+ BIT(http09_allowed); /* allow HTTP/0.9 responses */
+ BIT(mail_rcpt_allowfails); /* allow RCPT TO command to fail for some
+ recipients */
};
struct Names {
- struct Curl_hash *hostcache;
+ struct Curl_hash *hostcache;
enum {
HCACHE_NONE, /* not pointing to anything */
HCACHE_MULTI, /* points to a shared one in the multi handle */
@@ -1879,8 +1879,8 @@ struct Curl_easy {
struct Curl_easy *prev;
struct connectdata *conn;
- struct Curl_llist_element connect_queue;
- struct Curl_llist_element conn_queue; /* list per connectdata */
+ struct Curl_llist_element connect_queue;
+ struct Curl_llist_element conn_queue; /* list per connectdata */
CURLMstate mstate; /* the handle's state */
CURLcode result; /* previous result */
@@ -1914,10 +1914,10 @@ struct Curl_easy {
NOTE that the 'cookie' field in the
UserDefined struct defines if the "engine"
is to be used or not. */
-#ifdef USE_HSTS
- struct hsts *hsts;
-#endif
-#ifndef CURL_DISABLE_ALTSVC
+#ifdef USE_HSTS
+ struct hsts *hsts;
+#endif
+#ifndef CURL_DISABLE_ALTSVC
struct altsvcinfo *asi; /* the alt-svc cache */
#endif
struct Progress progress; /* for all the progress meter data */
diff --git a/contrib/libs/curl/lib/vauth/cleartext.c b/contrib/libs/curl/lib/vauth/cleartext.c
index e56e46c1f4..620dba03ef 100644
--- a/contrib/libs/curl/lib/vauth/cleartext.c
+++ b/contrib/libs/curl/lib/vauth/cleartext.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -81,8 +81,8 @@ CURLcode Curl_auth_create_plain_message(struct Curl_easy *data,
plen = strlen(passwd);
/* Compute binary message length. Check for overflows. */
- if((zlen > SIZE_T_MAX/4) || (clen > SIZE_T_MAX/4) ||
- (plen > (SIZE_T_MAX/2 - 2)))
+ if((zlen > SIZE_T_MAX/4) || (clen > SIZE_T_MAX/4) ||
+ (plen > (SIZE_T_MAX/2 - 2)))
return CURLE_OUT_OF_MEMORY;
plainlen = zlen + clen + plen + 2;
diff --git a/contrib/libs/curl/lib/vauth/cram.c b/contrib/libs/curl/lib/vauth/cram.c
index 4c31eb5f0f..1a376259a8 100644
--- a/contrib/libs/curl/lib/vauth/cram.c
+++ b/contrib/libs/curl/lib/vauth/cram.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -96,7 +96,7 @@ CURLcode Curl_auth_create_cram_md5_message(struct Curl_easy *data,
{
CURLcode result = CURLE_OK;
size_t chlglen = 0;
- struct HMAC_context *ctxt;
+ struct HMAC_context *ctxt;
unsigned char digest[MD5_DIGEST_LEN];
char *response;
diff --git a/contrib/libs/curl/lib/vauth/digest.c b/contrib/libs/curl/lib/vauth/digest.c
index 92fd182274..5fc9285263 100644
--- a/contrib/libs/curl/lib/vauth/digest.c
+++ b/contrib/libs/curl/lib/vauth/digest.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -62,7 +62,7 @@
what ultimately goes over the network.
*/
#define CURL_OUTPUT_DIGEST_CONV(a, b) \
- result = Curl_convert_to_network(a, b, strlen(b)); \
+ result = Curl_convert_to_network(a, b, strlen(b)); \
if(result) { \
free(b); \
return result; \
@@ -358,7 +358,7 @@ CURLcode Curl_auth_create_digest_md5_message(struct Curl_easy *data,
char **outptr, size_t *outlen)
{
size_t i;
- struct MD5_context *ctxt;
+ struct MD5_context *ctxt;
char *response = NULL;
unsigned char digest[MD5_DIGEST_LEN];
char HA1_hex[2 * MD5_DIGEST_LEN + 1];
@@ -660,7 +660,7 @@ CURLcode Curl_auth_decode_digest_http_message(const char *chlg,
}
/*
- * auth_create_digest_http_message()
+ * auth_create_digest_http_message()
*
* This is used to generate a HTTP DIGEST response message ready for sending
* to the recipient.
@@ -679,7 +679,7 @@ CURLcode Curl_auth_decode_digest_http_message(const char *chlg,
*
* Returns CURLE_OK on success.
*/
-static CURLcode auth_create_digest_http_message(
+static CURLcode auth_create_digest_http_message(
struct Curl_easy *data,
const char *userp,
const char *passwdp,
@@ -688,8 +688,8 @@ static CURLcode auth_create_digest_http_message(
struct digestdata *digest,
char **outptr, size_t *outlen,
void (*convert_to_ascii)(unsigned char *, unsigned char *),
- void (*hash)(unsigned char *, const unsigned char *,
- const size_t))
+ void (*hash)(unsigned char *, const unsigned char *,
+ const size_t))
{
CURLcode result;
unsigned char hashbuf[32]; /* 32 bytes/256 bits */
@@ -701,7 +701,7 @@ static CURLcode auth_create_digest_http_message(
size_t cnonce_sz = 0;
char *userp_quoted;
char *response = NULL;
- char *hashthis = NULL;
+ char *hashthis = NULL;
char *tmp = NULL;
if(!digest->nc)
@@ -723,12 +723,12 @@ static CURLcode auth_create_digest_http_message(
}
if(digest->userhash) {
- hashthis = aprintf("%s:%s", userp, digest->realm);
+ hashthis = aprintf("%s:%s", userp, digest->realm);
if(!hashthis)
return CURLE_OUT_OF_MEMORY;
CURL_OUTPUT_DIGEST_CONV(data, hashthis);
- hash(hashbuf, (unsigned char *) hashthis, strlen(hashthis));
+ hash(hashbuf, (unsigned char *) hashthis, strlen(hashthis));
free(hashthis);
convert_to_ascii(hashbuf, (unsigned char *)userh);
}
@@ -744,13 +744,13 @@ static CURLcode auth_create_digest_http_message(
unq(nonce-value) ":" unq(cnonce-value)
*/
- hashthis = aprintf("%s:%s:%s", digest->userhash ? userh : userp,
- digest->realm, passwdp);
+ hashthis = aprintf("%s:%s:%s", digest->userhash ? userh : userp,
+ digest->realm, passwdp);
if(!hashthis)
return CURLE_OUT_OF_MEMORY;
CURL_OUTPUT_DIGEST_CONV(data, hashthis); /* convert on non-ASCII machines */
- hash(hashbuf, (unsigned char *) hashthis, strlen(hashthis));
+ hash(hashbuf, (unsigned char *) hashthis, strlen(hashthis));
free(hashthis);
convert_to_ascii(hashbuf, ha1);
@@ -763,7 +763,7 @@ static CURLcode auth_create_digest_http_message(
return CURLE_OUT_OF_MEMORY;
CURL_OUTPUT_DIGEST_CONV(data, tmp); /* Convert on non-ASCII machines */
- hash(hashbuf, (unsigned char *) tmp, strlen(tmp));
+ hash(hashbuf, (unsigned char *) tmp, strlen(tmp));
free(tmp);
convert_to_ascii(hashbuf, ha1);
}
@@ -781,19 +781,19 @@ static CURLcode auth_create_digest_http_message(
5.1.1 of RFC 2616)
*/
- hashthis = aprintf("%s:%s", request, uripath);
+ hashthis = aprintf("%s:%s", request, uripath);
if(!hashthis)
return CURLE_OUT_OF_MEMORY;
if(digest->qop && strcasecompare(digest->qop, "auth-int")) {
/* We don't support auth-int for PUT or POST */
char hashed[65];
- char *hashthis2;
+ char *hashthis2;
- hash(hashbuf, (const unsigned char *)"", 0);
+ hash(hashbuf, (const unsigned char *)"", 0);
convert_to_ascii(hashbuf, (unsigned char *)hashed);
- hashthis2 = aprintf("%s:%s", hashthis, hashed);
+ hashthis2 = aprintf("%s:%s", hashthis, hashed);
free(hashthis);
hashthis = hashthis2;
}
@@ -802,23 +802,23 @@ static CURLcode auth_create_digest_http_message(
return CURLE_OUT_OF_MEMORY;
CURL_OUTPUT_DIGEST_CONV(data, hashthis); /* convert on non-ASCII machines */
- hash(hashbuf, (unsigned char *) hashthis, strlen(hashthis));
+ hash(hashbuf, (unsigned char *) hashthis, strlen(hashthis));
free(hashthis);
convert_to_ascii(hashbuf, ha2);
if(digest->qop) {
- hashthis = aprintf("%s:%s:%08x:%s:%s:%s", ha1, digest->nonce, digest->nc,
- digest->cnonce, digest->qop, ha2);
+ hashthis = aprintf("%s:%s:%08x:%s:%s:%s", ha1, digest->nonce, digest->nc,
+ digest->cnonce, digest->qop, ha2);
}
else {
- hashthis = aprintf("%s:%s:%s", ha1, digest->nonce, ha2);
+ hashthis = aprintf("%s:%s:%s", ha1, digest->nonce, ha2);
}
if(!hashthis)
return CURLE_OUT_OF_MEMORY;
CURL_OUTPUT_DIGEST_CONV(data, hashthis); /* convert on non-ASCII machines */
- hash(hashbuf, (unsigned char *) hashthis, strlen(hashthis));
+ hash(hashbuf, (unsigned char *) hashthis, strlen(hashthis));
free(hashthis);
convert_to_ascii(hashbuf, request_digest);
@@ -891,7 +891,7 @@ static CURLcode auth_create_digest_http_message(
if(digest->algorithm) {
/* Append the algorithm */
- tmp = aprintf("%s, algorithm=%s", response, digest->algorithm);
+ tmp = aprintf("%s, algorithm=%s", response, digest->algorithm);
free(response);
if(!tmp)
return CURLE_OUT_OF_MEMORY;
@@ -947,21 +947,21 @@ CURLcode Curl_auth_create_digest_http_message(struct Curl_easy *data,
switch(digest->algo) {
case CURLDIGESTALGO_MD5:
case CURLDIGESTALGO_MD5SESS:
- return auth_create_digest_http_message(data, userp, passwdp,
- request, uripath, digest,
- outptr, outlen,
- auth_digest_md5_to_ascii,
- Curl_md5it);
+ return auth_create_digest_http_message(data, userp, passwdp,
+ request, uripath, digest,
+ outptr, outlen,
+ auth_digest_md5_to_ascii,
+ Curl_md5it);
case CURLDIGESTALGO_SHA256:
case CURLDIGESTALGO_SHA256SESS:
case CURLDIGESTALGO_SHA512_256:
case CURLDIGESTALGO_SHA512_256SESS:
- return auth_create_digest_http_message(data, userp, passwdp,
- request, uripath, digest,
- outptr, outlen,
- auth_digest_sha256_to_ascii,
- Curl_sha256it);
+ return auth_create_digest_http_message(data, userp, passwdp,
+ request, uripath, digest,
+ outptr, outlen,
+ auth_digest_sha256_to_ascii,
+ Curl_sha256it);
default:
return CURLE_UNSUPPORTED_PROTOCOL;
diff --git a/contrib/libs/curl/lib/vauth/digest.h b/contrib/libs/curl/lib/vauth/digest.h
index d502de9e6d..ee373cd82e 100644
--- a/contrib/libs/curl/lib/vauth/digest.h
+++ b/contrib/libs/curl/lib/vauth/digest.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/vauth/digest_sspi.c b/contrib/libs/curl/lib/vauth/digest_sspi.c
index 1bc0d8e05b..91d18c992b 100644
--- a/contrib/libs/curl/lib/vauth/digest_sspi.c
+++ b/contrib/libs/curl/lib/vauth/digest_sspi.c
@@ -6,11 +6,11 @@
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2014 - 2016, Steve Holme, <steve_holme@hotmail.com>.
- * Copyright (C) 2015 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2015 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -134,8 +134,8 @@ CURLcode Curl_auth_create_digest_md5_message(struct Curl_easy *data,
if(status != SEC_E_OK) {
free(input_token);
- failf(data, "SSPI: couldn't get auth info\n");
- return CURLE_AUTH_ERROR;
+ failf(data, "SSPI: couldn't get auth info\n");
+ return CURLE_AUTH_ERROR;
}
token_max = SecurityPackage->cbMaxToken;
@@ -289,13 +289,13 @@ CURLcode Curl_override_sspi_http_realm(const char *chlg,
if(strcasecompare(value, "realm")) {
/* Setup identity's domain and length */
- domain.tchar_ptr = curlx_convert_UTF8_to_tchar((char *) content);
+ domain.tchar_ptr = curlx_convert_UTF8_to_tchar((char *) content);
if(!domain.tchar_ptr)
return CURLE_OUT_OF_MEMORY;
dup_domain.tchar_ptr = _tcsdup(domain.tchar_ptr);
if(!dup_domain.tchar_ptr) {
- curlx_unicodefree(domain.tchar_ptr);
+ curlx_unicodefree(domain.tchar_ptr);
return CURLE_OUT_OF_MEMORY;
}
@@ -304,7 +304,7 @@ CURLcode Curl_override_sspi_http_realm(const char *chlg,
identity->DomainLength = curlx_uztoul(_tcslen(dup_domain.tchar_ptr));
dup_domain.tchar_ptr = NULL;
- curlx_unicodefree(domain.tchar_ptr);
+ curlx_unicodefree(domain.tchar_ptr);
}
else {
/* Unknown specifier, ignore it! */
@@ -432,10 +432,10 @@ CURLcode Curl_auth_create_digest_http_message(struct Curl_easy *data,
/* Query the security package for DigestSSP */
status = s_pSecFn->QuerySecurityPackageInfo((TCHAR *) TEXT(SP_NAME_DIGEST),
&SecurityPackage);
- if(status != SEC_E_OK) {
- failf(data, "SSPI: couldn't get auth info\n");
- return CURLE_AUTH_ERROR;
- }
+ if(status != SEC_E_OK) {
+ failf(data, "SSPI: couldn't get auth info\n");
+ return CURLE_AUTH_ERROR;
+ }
token_max = SecurityPackage->cbMaxToken;
@@ -583,7 +583,7 @@ CURLcode Curl_auth_create_digest_http_message(struct Curl_easy *data,
resp_buf.pvBuffer = output_token;
resp_buf.cbBuffer = curlx_uztoul(token_max);
- spn = curlx_convert_UTF8_to_tchar((char *) uripath);
+ spn = curlx_convert_UTF8_to_tchar((char *) uripath);
if(!spn) {
s_pSecFn->FreeCredentialsHandle(&credentials);
@@ -605,7 +605,7 @@ CURLcode Curl_auth_create_digest_http_message(struct Curl_easy *data,
&chlg_desc, 0,
digest->http_context,
&resp_desc, &attrs, &expiry);
- curlx_unicodefree(spn);
+ curlx_unicodefree(spn);
if(status == SEC_I_COMPLETE_NEEDED ||
status == SEC_I_COMPLETE_AND_CONTINUE)
diff --git a/contrib/libs/curl/lib/vauth/krb5_gssapi.c b/contrib/libs/curl/lib/vauth/krb5_gssapi.c
index a5eb39c4a7..0412815e93 100644
--- a/contrib/libs/curl/lib/vauth/krb5_gssapi.c
+++ b/contrib/libs/curl/lib/vauth/krb5_gssapi.c
@@ -6,11 +6,11 @@
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2014 - 2019, Steve Holme, <steve_holme@hotmail.com>.
- * Copyright (C) 2015 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2015 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/vauth/krb5_sspi.c b/contrib/libs/curl/lib/vauth/krb5_sspi.c
index c4c5f8d29c..8e56a82409 100644
--- a/contrib/libs/curl/lib/vauth/krb5_sspi.c
+++ b/contrib/libs/curl/lib/vauth/krb5_sspi.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 2014 - 2020, Steve Holme, <steve_holme@hotmail.com>.
+ * Copyright (C) 2014 - 2020, Steve Holme, <steve_holme@hotmail.com>.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -125,8 +125,8 @@ CURLcode Curl_auth_create_gssapi_user_message(struct Curl_easy *data,
TEXT(SP_NAME_KERBEROS),
&SecurityPackage);
if(status != SEC_E_OK) {
- failf(data, "SSPI: couldn't get auth info\n");
- return CURLE_AUTH_ERROR;
+ failf(data, "SSPI: couldn't get auth info\n");
+ return CURLE_AUTH_ERROR;
}
krb5->token_max = SecurityPackage->cbMaxToken;
@@ -396,7 +396,7 @@ CURLcode Curl_auth_create_gssapi_security_message(struct Curl_easy *data,
return CURLE_OUT_OF_MEMORY;
/* Convert the user name to UTF8 when operating with Unicode */
- user_name = curlx_convert_tchar_to_UTF8(names.sUserName);
+ user_name = curlx_convert_tchar_to_UTF8(names.sUserName);
if(!user_name) {
free(trailer);
@@ -408,7 +408,7 @@ CURLcode Curl_auth_create_gssapi_security_message(struct Curl_easy *data,
message = malloc(messagelen);
if(!message) {
free(trailer);
- curlx_unicodefree(user_name);
+ curlx_unicodefree(user_name);
return CURLE_OUT_OF_MEMORY;
}
@@ -421,7 +421,7 @@ CURLcode Curl_auth_create_gssapi_security_message(struct Curl_easy *data,
outdata = htonl(max_size) | sec_layer;
memcpy(message, &outdata, sizeof(outdata));
strcpy((char *) message + sizeof(outdata), user_name);
- curlx_unicodefree(user_name);
+ curlx_unicodefree(user_name);
/* Allocate the padding */
padding = malloc(sizes.cbBlockSize);
diff --git a/contrib/libs/curl/lib/vauth/ntlm.c b/contrib/libs/curl/lib/vauth/ntlm.c
index 93396a30cb..a3117f3fee 100644
--- a/contrib/libs/curl/lib/vauth/ntlm.c
+++ b/contrib/libs/curl/lib/vauth/ntlm.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -40,7 +40,7 @@
#include "curl_ntlm_core.h"
#include "curl_gethostname.h"
#include "curl_multibyte.h"
-#include "curl_md5.h"
+#include "curl_md5.h"
#include "warnless.h"
#include "rand.h"
#include "vtls/vtls.h"
@@ -191,7 +191,7 @@ static CURLcode ntlm_decode_type2_target(struct Curl_easy *data,
return CURLE_BAD_CONTENT_ENCODING;
}
- free(ntlm->target_info); /* replace any previous data */
+ free(ntlm->target_info); /* replace any previous data */
ntlm->target_info = malloc(target_info_len);
if(!ntlm->target_info)
return CURLE_OUT_OF_MEMORY;
@@ -600,14 +600,14 @@ CURLcode Curl_auth_create_ntlm_type3_message(struct Curl_easy *data,
#endif
#if defined(USE_NTRESPONSES) && defined(USE_NTLM2SESSION)
-
-#define CURL_MD5_DIGEST_LENGTH 16 /* fixed size */
-
+
+#define CURL_MD5_DIGEST_LENGTH 16 /* fixed size */
+
/* We don't support NTLM2 if we don't have USE_NTRESPONSES */
if(ntlm->flags & NTLMFLAG_NEGOTIATE_NTLM_KEY) {
unsigned char ntbuffer[0x18];
unsigned char tmp[0x18];
- unsigned char md5sum[CURL_MD5_DIGEST_LENGTH];
+ unsigned char md5sum[CURL_MD5_DIGEST_LENGTH];
unsigned char entropy[8];
/* Need to create 8 bytes random data */
@@ -625,11 +625,11 @@ CURLcode Curl_auth_create_ntlm_type3_message(struct Curl_easy *data,
memcpy(tmp, &ntlm->nonce[0], 8);
memcpy(tmp + 8, entropy, 8);
- Curl_md5it(md5sum, tmp, 16);
-
- /* We shall only use the first 8 bytes of md5sum, but the des code in
- Curl_ntlm_core_lm_resp only encrypt the first 8 bytes */
- result = Curl_ntlm_core_mk_nt_hash(data, passwdp, ntbuffer);
+ Curl_md5it(md5sum, tmp, 16);
+
+ /* We shall only use the first 8 bytes of md5sum, but the des code in
+ Curl_ntlm_core_lm_resp only encrypt the first 8 bytes */
+ result = Curl_ntlm_core_mk_nt_hash(data, passwdp, ntbuffer);
if(result)
return result;
diff --git a/contrib/libs/curl/lib/vauth/ntlm.h b/contrib/libs/curl/lib/vauth/ntlm.h
index 9beb089ba9..8ec23ad4f5 100644
--- a/contrib/libs/curl/lib/vauth/ntlm.h
+++ b/contrib/libs/curl/lib/vauth/ntlm.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/vauth/ntlm_sspi.c b/contrib/libs/curl/lib/vauth/ntlm_sspi.c
index 2e5d2e5c48..28bc3efdaa 100644
--- a/contrib/libs/curl/lib/vauth/ntlm_sspi.c
+++ b/contrib/libs/curl/lib/vauth/ntlm_sspi.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -105,10 +105,10 @@ CURLcode Curl_auth_create_ntlm_type1_message(struct Curl_easy *data,
/* Query the security package for NTLM */
status = s_pSecFn->QuerySecurityPackageInfo((TCHAR *) TEXT(SP_NAME_NTLM),
&SecurityPackage);
- if(status != SEC_E_OK) {
- failf(data, "SSPI: couldn't get auth info\n");
- return CURLE_AUTH_ERROR;
- }
+ if(status != SEC_E_OK) {
+ failf(data, "SSPI: couldn't get auth info\n");
+ return CURLE_AUTH_ERROR;
+ }
ntlm->token_max = SecurityPackage->cbMaxToken;
diff --git a/contrib/libs/curl/lib/vauth/oauth2.c b/contrib/libs/curl/lib/vauth/oauth2.c
index fb723edca7..ca5842a7c0 100644
--- a/contrib/libs/curl/lib/vauth/oauth2.c
+++ b/contrib/libs/curl/lib/vauth/oauth2.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/vauth/spnego_gssapi.c b/contrib/libs/curl/lib/vauth/spnego_gssapi.c
index 7f663c2725..120925ff33 100644
--- a/contrib/libs/curl/lib/vauth/spnego_gssapi.c
+++ b/contrib/libs/curl/lib/vauth/spnego_gssapi.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/vauth/spnego_sspi.c b/contrib/libs/curl/lib/vauth/spnego_sspi.c
index 8f8c69acfa..e7482a43e2 100644
--- a/contrib/libs/curl/lib/vauth/spnego_sspi.c
+++ b/contrib/libs/curl/lib/vauth/spnego_sspi.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -129,10 +129,10 @@ CURLcode Curl_auth_decode_spnego_message(struct Curl_easy *data,
nego->status = s_pSecFn->QuerySecurityPackageInfo((TCHAR *)
TEXT(SP_NAME_NEGOTIATE),
&SecurityPackage);
- if(nego->status != SEC_E_OK) {
- failf(data, "SSPI: couldn't get auth info\n");
- return CURLE_AUTH_ERROR;
- }
+ if(nego->status != SEC_E_OK) {
+ failf(data, "SSPI: couldn't get auth info\n");
+ return CURLE_AUTH_ERROR;
+ }
nego->token_max = SecurityPackage->cbMaxToken;
diff --git a/contrib/libs/curl/lib/vauth/vauth.c b/contrib/libs/curl/lib/vauth/vauth.c
index d35ef808be..129b8f8b57 100644
--- a/contrib/libs/curl/lib/vauth/vauth.c
+++ b/contrib/libs/curl/lib/vauth/vauth.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 2014 - 2020, Steve Holme, <steve_holme@hotmail.com>.
+ * Copyright (C) 2014 - 2020, Steve Holme, <steve_holme@hotmail.com>.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -89,7 +89,7 @@ TCHAR *Curl_auth_build_spn(const char *service, const char *host,
}
/* Allocate our TCHAR based SPN */
- tchar_spn = curlx_convert_UTF8_to_tchar(utf8_spn);
+ tchar_spn = curlx_convert_UTF8_to_tchar(utf8_spn);
if(!tchar_spn) {
free(utf8_spn);
@@ -97,7 +97,7 @@ TCHAR *Curl_auth_build_spn(const char *service, const char *host,
}
/* Release the UTF8 variant when operating with Unicode */
- curlx_unicodefree(utf8_spn);
+ curlx_unicodefree(utf8_spn);
/* Return our newly allocated SPN */
return tchar_spn;
diff --git a/contrib/libs/curl/lib/vauth/vauth.h b/contrib/libs/curl/lib/vauth/vauth.h
index c756139a92..f25cfc329f 100644
--- a/contrib/libs/curl/lib/vauth/vauth.h
+++ b/contrib/libs/curl/lib/vauth/vauth.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 2014 - 2020, Steve Holme, <steve_holme@hotmail.com>.
+ * Copyright (C) 2014 - 2020, Steve Holme, <steve_holme@hotmail.com>.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -43,7 +43,7 @@ struct negotiatedata;
#endif
#if defined(USE_WINDOWS_SSPI)
-#define GSS_ERROR(status) ((status) & 0x80000000)
+#define GSS_ERROR(status) ((status) & 0x80000000)
#endif
/* This is used to build a SPN string */
diff --git a/contrib/libs/curl/lib/version.c b/contrib/libs/curl/lib/version.c
index 3f3aa05ec3..5e8512ef05 100644
--- a/contrib/libs/curl/lib/version.c
+++ b/contrib/libs/curl/lib/version.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -26,13 +26,13 @@
#include "urldata.h"
#include "vtls/vtls.h"
#include "http2.h"
-#include "vssh/ssh.h"
+#include "vssh/ssh.h"
#include "quic.h"
#include "curl_printf.h"
#ifdef USE_ARES
-# if defined(CURL_STATICLIB) && !defined(CARES_STATICLIB) && \
- defined(WIN32)
+# if defined(CURL_STATICLIB) && !defined(CARES_STATICLIB) && \
+ defined(WIN32)
# define CARES_STATICLIB
# endif
# include <ares.h>
@@ -62,9 +62,9 @@
#error #include <brotli/decode.h>
#endif
-#ifdef HAVE_ZSTD
-#error #include <zstd.h>
-#endif
+#ifdef HAVE_ZSTD
+#error #include <zstd.h>
+#endif
#ifdef HAVE_BROTLI
static size_t brotli_version(char *buf, size_t bufsz)
@@ -78,139 +78,139 @@ static size_t brotli_version(char *buf, size_t bufsz)
}
#endif
-#ifdef HAVE_ZSTD
-static size_t zstd_version(char *buf, size_t bufsz)
+#ifdef HAVE_ZSTD
+static size_t zstd_version(char *buf, size_t bufsz)
{
- unsigned long zstd_version = (unsigned long)ZSTD_versionNumber();
- unsigned int major = (unsigned int)(zstd_version / (100 * 100));
- unsigned int minor = (unsigned int)((zstd_version -
- (major * 100 * 100)) / 100);
- unsigned int patch = (unsigned int)(zstd_version -
- (major * 100 * 100) - (minor * 100));
-
- return msnprintf(buf, bufsz, "%u.%u.%u", major, minor, patch);
-}
-#endif
-
-/*
- * curl_version() returns a pointer to a static buffer.
- *
- * It is implemented to work multi-threaded by making sure repeated invokes
- * generate the exact same string and never write any temporary data like
- * zeros in the data.
- */
-
-#define VERSION_PARTS 14 /* number of substrings we can concatenate */
-
-char *curl_version(void)
-{
- static char out[300];
- char *outp;
- size_t outlen;
- const char *src[VERSION_PARTS];
-#ifdef USE_SSL
- char ssl_version[200];
-#endif
-#ifdef HAVE_LIBZ
- char z_version[40];
-#endif
-#ifdef HAVE_BROTLI
- char br_version[40] = "brotli/";
-#endif
-#ifdef HAVE_ZSTD
- char zst_version[40] = "zstd/";
-#endif
-#ifdef USE_ARES
- char cares_version[40];
-#endif
-#if defined(USE_LIBIDN2)
- char idn_version[40];
-#endif
-#ifdef USE_LIBPSL
- char psl_version[40];
-#endif
-#if defined(HAVE_ICONV) && defined(CURL_DOES_CONVERSIONS)
- char iconv_version[40]="iconv";
-#endif
-#ifdef USE_SSH
- char ssh_version[40];
-#endif
-#ifdef USE_NGHTTP2
- char h2_version[40];
-#endif
-#ifdef ENABLE_QUIC
- char h3_version[40];
-#endif
-#ifdef USE_LIBRTMP
- char rtmp_version[40];
-#endif
- int i = 0;
- int j;
-
-#ifdef DEBUGBUILD
- /* Override version string when environment variable CURL_VERSION is set */
- const char *debugversion = getenv("CURL_VERSION");
- if(debugversion) {
- strncpy(out, debugversion, sizeof(out)-1);
- out[sizeof(out)-1] = '\0';
- return out;
+ unsigned long zstd_version = (unsigned long)ZSTD_versionNumber();
+ unsigned int major = (unsigned int)(zstd_version / (100 * 100));
+ unsigned int minor = (unsigned int)((zstd_version -
+ (major * 100 * 100)) / 100);
+ unsigned int patch = (unsigned int)(zstd_version -
+ (major * 100 * 100) - (minor * 100));
+
+ return msnprintf(buf, bufsz, "%u.%u.%u", major, minor, patch);
+}
+#endif
+
+/*
+ * curl_version() returns a pointer to a static buffer.
+ *
+ * It is implemented to work multi-threaded by making sure repeated invokes
+ * generate the exact same string and never write any temporary data like
+ * zeros in the data.
+ */
+
+#define VERSION_PARTS 14 /* number of substrings we can concatenate */
+
+char *curl_version(void)
+{
+ static char out[300];
+ char *outp;
+ size_t outlen;
+ const char *src[VERSION_PARTS];
+#ifdef USE_SSL
+ char ssl_version[200];
+#endif
+#ifdef HAVE_LIBZ
+ char z_version[40];
+#endif
+#ifdef HAVE_BROTLI
+ char br_version[40] = "brotli/";
+#endif
+#ifdef HAVE_ZSTD
+ char zst_version[40] = "zstd/";
+#endif
+#ifdef USE_ARES
+ char cares_version[40];
+#endif
+#if defined(USE_LIBIDN2)
+ char idn_version[40];
+#endif
+#ifdef USE_LIBPSL
+ char psl_version[40];
+#endif
+#if defined(HAVE_ICONV) && defined(CURL_DOES_CONVERSIONS)
+ char iconv_version[40]="iconv";
+#endif
+#ifdef USE_SSH
+ char ssh_version[40];
+#endif
+#ifdef USE_NGHTTP2
+ char h2_version[40];
+#endif
+#ifdef ENABLE_QUIC
+ char h3_version[40];
+#endif
+#ifdef USE_LIBRTMP
+ char rtmp_version[40];
+#endif
+ int i = 0;
+ int j;
+
+#ifdef DEBUGBUILD
+ /* Override version string when environment variable CURL_VERSION is set */
+ const char *debugversion = getenv("CURL_VERSION");
+ if(debugversion) {
+ strncpy(out, debugversion, sizeof(out)-1);
+ out[sizeof(out)-1] = '\0';
+ return out;
}
-#endif
+#endif
- src[i++] = LIBCURL_NAME "/" LIBCURL_VERSION;
-#ifdef USE_SSL
- Curl_ssl_version(ssl_version, sizeof(ssl_version));
- src[i++] = ssl_version;
-#endif
+ src[i++] = LIBCURL_NAME "/" LIBCURL_VERSION;
+#ifdef USE_SSL
+ Curl_ssl_version(ssl_version, sizeof(ssl_version));
+ src[i++] = ssl_version;
+#endif
#ifdef HAVE_LIBZ
- msnprintf(z_version, sizeof(z_version), "zlib/%s", zlibVersion());
- src[i++] = z_version;
+ msnprintf(z_version, sizeof(z_version), "zlib/%s", zlibVersion());
+ src[i++] = z_version;
#endif
#ifdef HAVE_BROTLI
- brotli_version(&br_version[7], sizeof(br_version) - 7);
- src[i++] = br_version;
+ brotli_version(&br_version[7], sizeof(br_version) - 7);
+ src[i++] = br_version;
+#endif
+#ifdef HAVE_ZSTD
+ zstd_version(&zst_version[5], sizeof(zst_version) - 5);
+ src[i++] = zst_version;
#endif
-#ifdef HAVE_ZSTD
- zstd_version(&zst_version[5], sizeof(zst_version) - 5);
- src[i++] = zst_version;
-#endif
#ifdef USE_ARES
- msnprintf(cares_version, sizeof(cares_version),
- "c-ares/%s", ares_version(NULL));
- src[i++] = cares_version;
+ msnprintf(cares_version, sizeof(cares_version),
+ "c-ares/%s", ares_version(NULL));
+ src[i++] = cares_version;
#endif
#ifdef USE_LIBIDN2
- msnprintf(idn_version, sizeof(idn_version),
- "libidn2/%s", idn2_check_version(NULL));
- src[i++] = idn_version;
-#elif defined(USE_WIN32_IDN)
- src[i++] = (char *)"WinIDN";
+ msnprintf(idn_version, sizeof(idn_version),
+ "libidn2/%s", idn2_check_version(NULL));
+ src[i++] = idn_version;
+#elif defined(USE_WIN32_IDN)
+ src[i++] = (char *)"WinIDN";
#endif
-
+
#ifdef USE_LIBPSL
- msnprintf(psl_version, sizeof(psl_version), "libpsl/%s", psl_get_version());
- src[i++] = psl_version;
+ msnprintf(psl_version, sizeof(psl_version), "libpsl/%s", psl_get_version());
+ src[i++] = psl_version;
#endif
#if defined(HAVE_ICONV) && defined(CURL_DOES_CONVERSIONS)
#ifdef _LIBICONV_VERSION
- msnprintf(iconv_version, sizeof(iconv_version), "iconv/%d.%d",
- _LIBICONV_VERSION >> 8, _LIBICONV_VERSION & 255);
+ msnprintf(iconv_version, sizeof(iconv_version), "iconv/%d.%d",
+ _LIBICONV_VERSION >> 8, _LIBICONV_VERSION & 255);
#else
- /* version unknown, let the default stand */
+ /* version unknown, let the default stand */
#endif /* _LIBICONV_VERSION */
- src[i++] = iconv_version;
+ src[i++] = iconv_version;
#endif
#ifdef USE_SSH
- Curl_ssh_version(ssh_version, sizeof(ssh_version));
- src[i++] = ssh_version;
+ Curl_ssh_version(ssh_version, sizeof(ssh_version));
+ src[i++] = ssh_version;
#endif
#ifdef USE_NGHTTP2
- Curl_http2_ver(h2_version, sizeof(h2_version));
- src[i++] = h2_version;
+ Curl_http2_ver(h2_version, sizeof(h2_version));
+ src[i++] = h2_version;
#endif
#ifdef ENABLE_QUIC
- Curl_quic_ver(h3_version, sizeof(h3_version));
- src[i++] = h3_version;
+ Curl_quic_ver(h3_version, sizeof(h3_version));
+ src[i++] = h3_version;
#endif
#ifdef USE_LIBRTMP
{
@@ -222,34 +222,34 @@ char *curl_version(void)
else
suff[0] = '\0';
- msnprintf(rtmp_version, sizeof(rtmp_version), "librtmp/%d.%d%s",
+ msnprintf(rtmp_version, sizeof(rtmp_version), "librtmp/%d.%d%s",
RTMP_LIB_VERSION >> 16, (RTMP_LIB_VERSION >> 8) & 0xff,
suff);
- src[i++] = rtmp_version;
- }
-#endif
-
- DEBUGASSERT(i <= VERSION_PARTS);
-
- outp = &out[0];
- outlen = sizeof(out);
- for(j = 0; j < i; j++) {
- size_t n = strlen(src[j]);
- /* we need room for a space, the string and the final zero */
- if(outlen <= (n + 2))
- break;
- if(j) {
- /* prepend a space if not the first */
- *outp++ = ' ';
- outlen--;
- }
- memcpy(outp, src[j], n);
- outp += n;
- outlen -= n;
+ src[i++] = rtmp_version;
+ }
+#endif
+
+ DEBUGASSERT(i <= VERSION_PARTS);
+
+ outp = &out[0];
+ outlen = sizeof(out);
+ for(j = 0; j < i; j++) {
+ size_t n = strlen(src[j]);
+ /* we need room for a space, the string and the final zero */
+ if(outlen <= (n + 2))
+ break;
+ if(j) {
+ /* prepend a space if not the first */
+ *outp++ = ' ';
+ outlen--;
+ }
+ memcpy(outp, src[j], n);
+ outp += n;
+ outlen -= n;
}
- *outp = 0;
+ *outp = 0;
- return out;
+ return out;
}
/* data for curl_version_info
@@ -294,9 +294,9 @@ static const char * const protocols[] = {
"ldaps",
#endif
#endif
-#ifndef CURL_DISABLE_MQTT
- "mqtt",
-#endif
+#ifndef CURL_DISABLE_MQTT
+ "mqtt",
+#endif
#ifndef CURL_DISABLE_POP3
"pop3",
#endif
@@ -309,14 +309,14 @@ static const char * const protocols[] = {
#ifndef CURL_DISABLE_RTSP
"rtsp",
#endif
-#if defined(USE_SSH) && !defined(USE_WOLFSSH)
+#if defined(USE_SSH) && !defined(USE_WOLFSSH)
"scp",
-#endif
-#ifdef USE_SSH
+#endif
+#ifdef USE_SSH
"sftp",
#endif
-#if !defined(CURL_DISABLE_SMB) && defined(USE_CURL_NTLM_CORE) && \
- (CURL_SIZEOF_CURL_OFF_T > 4)
+#if !defined(CURL_DISABLE_SMB) && defined(USE_CURL_NTLM_CORE) && \
+ (CURL_SIZEOF_CURL_OFF_T > 4)
"smb",
# ifdef USE_SSL
"smbs",
@@ -385,9 +385,9 @@ static curl_version_info_data version_info = {
( (SIZEOF_OFF_T > 4) || defined(USE_WIN32_LARGE_FILES) )
| CURL_VERSION_LARGEFILE
#endif
-#if defined(WIN32) && defined(UNICODE) && defined(_UNICODE)
- | CURL_VERSION_UNICODE
-#endif
+#if defined(WIN32) && defined(UNICODE) && defined(_UNICODE)
+ | CURL_VERSION_UNICODE
+#endif
#if defined(CURL_DOES_CONVERSIONS)
| CURL_VERSION_CONV
#endif
@@ -412,15 +412,15 @@ static curl_version_info_data version_info = {
#if defined(HAVE_BROTLI)
| CURL_VERSION_BROTLI
#endif
-#if defined(HAVE_ZSTD)
- | CURL_VERSION_ZSTD
-#endif
-#ifndef CURL_DISABLE_ALTSVC
+#if defined(HAVE_ZSTD)
+ | CURL_VERSION_ZSTD
+#endif
+#ifndef CURL_DISABLE_ALTSVC
| CURL_VERSION_ALTSVC
#endif
-#if defined(USE_HSTS)
- | CURL_VERSION_HSTS
-#endif
+#if defined(USE_HSTS)
+ | CURL_VERSION_HSTS
+#endif
,
NULL, /* ssl_version */
0, /* ssl_version_num, this is kept at zero */
@@ -435,19 +435,19 @@ static curl_version_info_data version_info = {
NULL, /* brotli version */
0, /* nghttp2 version number */
NULL, /* nghttp2 version string */
- NULL, /* quic library string */
-#ifdef CURL_CA_BUNDLE
- CURL_CA_BUNDLE, /* cainfo */
-#else
- NULL,
-#endif
-#ifdef CURL_CA_PATH
- CURL_CA_PATH, /* capath */
-#else
- NULL,
-#endif
- 0, /* zstd_ver_num */
- NULL /* zstd version */
+ NULL, /* quic library string */
+#ifdef CURL_CA_BUNDLE
+ CURL_CA_BUNDLE, /* cainfo */
+#else
+ NULL,
+#endif
+#ifdef CURL_CA_PATH
+ CURL_CA_PATH, /* capath */
+#else
+ NULL,
+#endif
+ 0, /* zstd_ver_num */
+ NULL /* zstd version */
};
curl_version_info_data *curl_version_info(CURLversion stamp)
@@ -465,21 +465,21 @@ curl_version_info_data *curl_version_info(CURLversion stamp)
#ifdef HAVE_BROTLI
static char brotli_buffer[80];
#endif
-#ifdef HAVE_ZSTD
- static char zstd_buffer[80];
-#endif
+#ifdef HAVE_ZSTD
+ static char zstd_buffer[80];
+#endif
#ifdef USE_SSL
Curl_ssl_version(ssl_buffer, sizeof(ssl_buffer));
version_info.ssl_version = ssl_buffer;
-#ifndef CURL_DISABLE_PROXY
+#ifndef CURL_DISABLE_PROXY
if(Curl_ssl->supports & SSLSUPP_HTTPS_PROXY)
version_info.features |= CURL_VERSION_HTTPS_PROXY;
else
version_info.features &= ~CURL_VERSION_HTTPS_PROXY;
#endif
-#endif
+#endif
#ifdef HAVE_LIBZ
version_info.libz_version = zlibVersion();
@@ -522,12 +522,12 @@ curl_version_info_data *curl_version_info(CURLversion stamp)
version_info.brotli_version = brotli_buffer;
#endif
-#ifdef HAVE_ZSTD
- version_info.zstd_ver_num = (unsigned int)ZSTD_versionNumber();
- zstd_version(zstd_buffer, sizeof(zstd_buffer));
- version_info.zstd_version = zstd_buffer;
-#endif
-
+#ifdef HAVE_ZSTD
+ version_info.zstd_ver_num = (unsigned int)ZSTD_versionNumber();
+ zstd_version(zstd_buffer, sizeof(zstd_buffer));
+ version_info.zstd_version = zstd_buffer;
+#endif
+
#ifdef USE_NGHTTP2
{
nghttp2_info *h2 = nghttp2_version(0);
diff --git a/contrib/libs/curl/lib/version_win32.c b/contrib/libs/curl/lib/version_win32.c
index e7f67eaf8f..b8157e9893 100644
--- a/contrib/libs/curl/lib/version_win32.c
+++ b/contrib/libs/curl/lib/version_win32.c
@@ -1,226 +1,226 @@
-/***************************************************************************
- * _ _ ____ _
- * Project ___| | | | _ \| |
- * / __| | | | |_) | |
- * | (__| |_| | _ <| |___
- * \___|\___/|_| \_\_____|
- *
- * Copyright (C) 2016 - 2020, Steve Holme, <steve_holme@hotmail.com>.
- *
- * This software is licensed as described in the file COPYING, which
- * you should have received as part of this distribution. The terms
- * are also available at https://curl.se/docs/copyright.html.
- *
- * You may opt to use, copy, modify, merge, publish, distribute and/or sell
- * copies of the Software, and permit persons to whom the Software is
- * furnished to do so, under the terms of the COPYING file.
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- ***************************************************************************/
-
-#include "curl_setup.h"
-
-#if defined(WIN32)
-
-#include <curl/curl.h>
-#include "version_win32.h"
-
-/* The last #include files should be: */
-#include "curl_memory.h"
-#include "memdebug.h"
-
-/*
- * curlx_verify_windows_version()
- *
- * This is used to verify if we are running on a specific windows version.
- *
- * Parameters:
- *
- * majorVersion [in] - The major version number.
- * minorVersion [in] - The minor version number.
- * platform [in] - The optional platform identifier.
- * condition [in] - The test condition used to specifier whether we are
- * checking a version less then, equal to or greater than
- * what is specified in the major and minor version
- * numbers.
- *
- * Returns TRUE if matched; otherwise FALSE.
- */
-bool curlx_verify_windows_version(const unsigned int majorVersion,
- const unsigned int minorVersion,
- const PlatformIdentifier platform,
- const VersionCondition condition)
-{
- bool matched = FALSE;
-
-#if defined(CURL_WINDOWS_APP)
- /* We have no way to determine the Windows version from Windows apps,
- so let's assume we're running on the target Windows version. */
- const WORD fullVersion = MAKEWORD(minorVersion, majorVersion);
- const WORD targetVersion = (WORD)_WIN32_WINNT;
-
- switch(condition) {
- case VERSION_LESS_THAN:
- matched = targetVersion < fullVersion;
- break;
-
- case VERSION_LESS_THAN_EQUAL:
- matched = targetVersion <= fullVersion;
- break;
-
- case VERSION_EQUAL:
- matched = targetVersion == fullVersion;
- break;
-
- case VERSION_GREATER_THAN_EQUAL:
- matched = targetVersion >= fullVersion;
- break;
-
- case VERSION_GREATER_THAN:
- matched = targetVersion > fullVersion;
- break;
- }
-
- if(matched && (platform == PLATFORM_WINDOWS)) {
- /* we're always running on PLATFORM_WINNT */
- matched = FALSE;
- }
-#elif !defined(_WIN32_WINNT) || !defined(_WIN32_WINNT_WIN2K) || \
- (_WIN32_WINNT < _WIN32_WINNT_WIN2K)
- OSVERSIONINFO osver;
-
- memset(&osver, 0, sizeof(osver));
- osver.dwOSVersionInfoSize = sizeof(osver);
-
- /* Find out Windows version */
- if(GetVersionEx(&osver)) {
- /* Verify the Operating System version number */
- switch(condition) {
- case VERSION_LESS_THAN:
- if(osver.dwMajorVersion < majorVersion ||
- (osver.dwMajorVersion == majorVersion &&
- osver.dwMinorVersion < minorVersion))
- matched = TRUE;
- break;
-
- case VERSION_LESS_THAN_EQUAL:
- if(osver.dwMajorVersion < majorVersion ||
- (osver.dwMajorVersion == majorVersion &&
- osver.dwMinorVersion <= minorVersion))
- matched = TRUE;
- break;
-
- case VERSION_EQUAL:
- if(osver.dwMajorVersion == majorVersion &&
- osver.dwMinorVersion == minorVersion)
- matched = TRUE;
- break;
-
- case VERSION_GREATER_THAN_EQUAL:
- if(osver.dwMajorVersion > majorVersion ||
- (osver.dwMajorVersion == majorVersion &&
- osver.dwMinorVersion >= minorVersion))
- matched = TRUE;
- break;
-
- case VERSION_GREATER_THAN:
- if(osver.dwMajorVersion > majorVersion ||
- (osver.dwMajorVersion == majorVersion &&
- osver.dwMinorVersion > minorVersion))
- matched = TRUE;
- break;
- }
-
- /* Verify the platform identifier (if necessary) */
- if(matched) {
- switch(platform) {
- case PLATFORM_WINDOWS:
- if(osver.dwPlatformId != VER_PLATFORM_WIN32_WINDOWS)
- matched = FALSE;
- break;
-
- case PLATFORM_WINNT:
- if(osver.dwPlatformId != VER_PLATFORM_WIN32_NT)
- matched = FALSE;
-
- default: /* like platform == PLATFORM_DONT_CARE */
- break;
- }
- }
- }
-#else
- ULONGLONG cm = 0;
- OSVERSIONINFOEX osver;
- BYTE majorCondition;
- BYTE minorCondition;
- BYTE spMajorCondition;
- BYTE spMinorCondition;
-
- switch(condition) {
- case VERSION_LESS_THAN:
- majorCondition = VER_LESS;
- minorCondition = VER_LESS;
- spMajorCondition = VER_LESS_EQUAL;
- spMinorCondition = VER_LESS_EQUAL;
- break;
-
- case VERSION_LESS_THAN_EQUAL:
- majorCondition = VER_LESS_EQUAL;
- minorCondition = VER_LESS_EQUAL;
- spMajorCondition = VER_LESS_EQUAL;
- spMinorCondition = VER_LESS_EQUAL;
- break;
-
- case VERSION_EQUAL:
- majorCondition = VER_EQUAL;
- minorCondition = VER_EQUAL;
- spMajorCondition = VER_GREATER_EQUAL;
- spMinorCondition = VER_GREATER_EQUAL;
- break;
-
- case VERSION_GREATER_THAN_EQUAL:
- majorCondition = VER_GREATER_EQUAL;
- minorCondition = VER_GREATER_EQUAL;
- spMajorCondition = VER_GREATER_EQUAL;
- spMinorCondition = VER_GREATER_EQUAL;
- break;
-
- case VERSION_GREATER_THAN:
- majorCondition = VER_GREATER;
- minorCondition = VER_GREATER;
- spMajorCondition = VER_GREATER_EQUAL;
- spMinorCondition = VER_GREATER_EQUAL;
- break;
-
- default:
- return FALSE;
- }
-
- memset(&osver, 0, sizeof(osver));
- osver.dwOSVersionInfoSize = sizeof(osver);
- osver.dwMajorVersion = majorVersion;
- osver.dwMinorVersion = minorVersion;
- if(platform == PLATFORM_WINDOWS)
- osver.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS;
- else if(platform == PLATFORM_WINNT)
- osver.dwPlatformId = VER_PLATFORM_WIN32_NT;
-
- cm = VerSetConditionMask(cm, VER_MAJORVERSION, majorCondition);
- cm = VerSetConditionMask(cm, VER_MINORVERSION, minorCondition);
- cm = VerSetConditionMask(cm, VER_SERVICEPACKMAJOR, spMajorCondition);
- cm = VerSetConditionMask(cm, VER_SERVICEPACKMINOR, spMinorCondition);
- if(platform != PLATFORM_DONT_CARE)
- cm = VerSetConditionMask(cm, VER_PLATFORMID, VER_EQUAL);
-
- if(VerifyVersionInfo(&osver, (VER_MAJORVERSION | VER_MINORVERSION |
- VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR),
- cm))
- matched = TRUE;
-#endif
-
- return matched;
-}
-
-#endif /* WIN32 */
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 2016 - 2020, Steve Holme, <steve_holme@hotmail.com>.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at https://curl.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+
+#include "curl_setup.h"
+
+#if defined(WIN32)
+
+#include <curl/curl.h>
+#include "version_win32.h"
+
+/* The last #include files should be: */
+#include "curl_memory.h"
+#include "memdebug.h"
+
+/*
+ * curlx_verify_windows_version()
+ *
+ * This is used to verify if we are running on a specific windows version.
+ *
+ * Parameters:
+ *
+ * majorVersion [in] - The major version number.
+ * minorVersion [in] - The minor version number.
+ * platform [in] - The optional platform identifier.
+ * condition [in] - The test condition used to specifier whether we are
+ * checking a version less then, equal to or greater than
+ * what is specified in the major and minor version
+ * numbers.
+ *
+ * Returns TRUE if matched; otherwise FALSE.
+ */
+bool curlx_verify_windows_version(const unsigned int majorVersion,
+ const unsigned int minorVersion,
+ const PlatformIdentifier platform,
+ const VersionCondition condition)
+{
+ bool matched = FALSE;
+
+#if defined(CURL_WINDOWS_APP)
+ /* We have no way to determine the Windows version from Windows apps,
+ so let's assume we're running on the target Windows version. */
+ const WORD fullVersion = MAKEWORD(minorVersion, majorVersion);
+ const WORD targetVersion = (WORD)_WIN32_WINNT;
+
+ switch(condition) {
+ case VERSION_LESS_THAN:
+ matched = targetVersion < fullVersion;
+ break;
+
+ case VERSION_LESS_THAN_EQUAL:
+ matched = targetVersion <= fullVersion;
+ break;
+
+ case VERSION_EQUAL:
+ matched = targetVersion == fullVersion;
+ break;
+
+ case VERSION_GREATER_THAN_EQUAL:
+ matched = targetVersion >= fullVersion;
+ break;
+
+ case VERSION_GREATER_THAN:
+ matched = targetVersion > fullVersion;
+ break;
+ }
+
+ if(matched && (platform == PLATFORM_WINDOWS)) {
+ /* we're always running on PLATFORM_WINNT */
+ matched = FALSE;
+ }
+#elif !defined(_WIN32_WINNT) || !defined(_WIN32_WINNT_WIN2K) || \
+ (_WIN32_WINNT < _WIN32_WINNT_WIN2K)
+ OSVERSIONINFO osver;
+
+ memset(&osver, 0, sizeof(osver));
+ osver.dwOSVersionInfoSize = sizeof(osver);
+
+ /* Find out Windows version */
+ if(GetVersionEx(&osver)) {
+ /* Verify the Operating System version number */
+ switch(condition) {
+ case VERSION_LESS_THAN:
+ if(osver.dwMajorVersion < majorVersion ||
+ (osver.dwMajorVersion == majorVersion &&
+ osver.dwMinorVersion < minorVersion))
+ matched = TRUE;
+ break;
+
+ case VERSION_LESS_THAN_EQUAL:
+ if(osver.dwMajorVersion < majorVersion ||
+ (osver.dwMajorVersion == majorVersion &&
+ osver.dwMinorVersion <= minorVersion))
+ matched = TRUE;
+ break;
+
+ case VERSION_EQUAL:
+ if(osver.dwMajorVersion == majorVersion &&
+ osver.dwMinorVersion == minorVersion)
+ matched = TRUE;
+ break;
+
+ case VERSION_GREATER_THAN_EQUAL:
+ if(osver.dwMajorVersion > majorVersion ||
+ (osver.dwMajorVersion == majorVersion &&
+ osver.dwMinorVersion >= minorVersion))
+ matched = TRUE;
+ break;
+
+ case VERSION_GREATER_THAN:
+ if(osver.dwMajorVersion > majorVersion ||
+ (osver.dwMajorVersion == majorVersion &&
+ osver.dwMinorVersion > minorVersion))
+ matched = TRUE;
+ break;
+ }
+
+ /* Verify the platform identifier (if necessary) */
+ if(matched) {
+ switch(platform) {
+ case PLATFORM_WINDOWS:
+ if(osver.dwPlatformId != VER_PLATFORM_WIN32_WINDOWS)
+ matched = FALSE;
+ break;
+
+ case PLATFORM_WINNT:
+ if(osver.dwPlatformId != VER_PLATFORM_WIN32_NT)
+ matched = FALSE;
+
+ default: /* like platform == PLATFORM_DONT_CARE */
+ break;
+ }
+ }
+ }
+#else
+ ULONGLONG cm = 0;
+ OSVERSIONINFOEX osver;
+ BYTE majorCondition;
+ BYTE minorCondition;
+ BYTE spMajorCondition;
+ BYTE spMinorCondition;
+
+ switch(condition) {
+ case VERSION_LESS_THAN:
+ majorCondition = VER_LESS;
+ minorCondition = VER_LESS;
+ spMajorCondition = VER_LESS_EQUAL;
+ spMinorCondition = VER_LESS_EQUAL;
+ break;
+
+ case VERSION_LESS_THAN_EQUAL:
+ majorCondition = VER_LESS_EQUAL;
+ minorCondition = VER_LESS_EQUAL;
+ spMajorCondition = VER_LESS_EQUAL;
+ spMinorCondition = VER_LESS_EQUAL;
+ break;
+
+ case VERSION_EQUAL:
+ majorCondition = VER_EQUAL;
+ minorCondition = VER_EQUAL;
+ spMajorCondition = VER_GREATER_EQUAL;
+ spMinorCondition = VER_GREATER_EQUAL;
+ break;
+
+ case VERSION_GREATER_THAN_EQUAL:
+ majorCondition = VER_GREATER_EQUAL;
+ minorCondition = VER_GREATER_EQUAL;
+ spMajorCondition = VER_GREATER_EQUAL;
+ spMinorCondition = VER_GREATER_EQUAL;
+ break;
+
+ case VERSION_GREATER_THAN:
+ majorCondition = VER_GREATER;
+ minorCondition = VER_GREATER;
+ spMajorCondition = VER_GREATER_EQUAL;
+ spMinorCondition = VER_GREATER_EQUAL;
+ break;
+
+ default:
+ return FALSE;
+ }
+
+ memset(&osver, 0, sizeof(osver));
+ osver.dwOSVersionInfoSize = sizeof(osver);
+ osver.dwMajorVersion = majorVersion;
+ osver.dwMinorVersion = minorVersion;
+ if(platform == PLATFORM_WINDOWS)
+ osver.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS;
+ else if(platform == PLATFORM_WINNT)
+ osver.dwPlatformId = VER_PLATFORM_WIN32_NT;
+
+ cm = VerSetConditionMask(cm, VER_MAJORVERSION, majorCondition);
+ cm = VerSetConditionMask(cm, VER_MINORVERSION, minorCondition);
+ cm = VerSetConditionMask(cm, VER_SERVICEPACKMAJOR, spMajorCondition);
+ cm = VerSetConditionMask(cm, VER_SERVICEPACKMINOR, spMinorCondition);
+ if(platform != PLATFORM_DONT_CARE)
+ cm = VerSetConditionMask(cm, VER_PLATFORMID, VER_EQUAL);
+
+ if(VerifyVersionInfo(&osver, (VER_MAJORVERSION | VER_MINORVERSION |
+ VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR),
+ cm))
+ matched = TRUE;
+#endif
+
+ return matched;
+}
+
+#endif /* WIN32 */
diff --git a/contrib/libs/curl/lib/version_win32.h b/contrib/libs/curl/lib/version_win32.h
index 45e87ee101..9b1bd88874 100644
--- a/contrib/libs/curl/lib/version_win32.h
+++ b/contrib/libs/curl/lib/version_win32.h
@@ -1,53 +1,53 @@
-#ifndef HEADER_CURL_VERSION_WIN32_H
-#define HEADER_CURL_VERSION_WIN32_H
-/***************************************************************************
- * _ _ ____ _
- * Project ___| | | | _ \| |
- * / __| | | | |_) | |
- * | (__| |_| | _ <| |___
- * \___|\___/|_| \_\_____|
- *
- * Copyright (C) 2016 - 2020, Steve Holme, <steve_holme@hotmail.com>.
- *
- * This software is licensed as described in the file COPYING, which
- * you should have received as part of this distribution. The terms
- * are also available at https://curl.se/docs/copyright.html.
- *
- * You may opt to use, copy, modify, merge, publish, distribute and/or sell
- * copies of the Software, and permit persons to whom the Software is
- * furnished to do so, under the terms of the COPYING file.
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- ***************************************************************************/
-
-#include "curl_setup.h"
-
-#if defined(WIN32)
-
-/* Version condition */
-typedef enum {
- VERSION_LESS_THAN,
- VERSION_LESS_THAN_EQUAL,
- VERSION_EQUAL,
- VERSION_GREATER_THAN_EQUAL,
- VERSION_GREATER_THAN
-} VersionCondition;
-
-/* Platform identifier */
-typedef enum {
- PLATFORM_DONT_CARE,
- PLATFORM_WINDOWS,
- PLATFORM_WINNT
-} PlatformIdentifier;
-
-/* This is used to verify if we are running on a specific windows version */
-bool curlx_verify_windows_version(const unsigned int majorVersion,
- const unsigned int minorVersion,
- const PlatformIdentifier platform,
- const VersionCondition condition);
-
-#endif /* WIN32 */
-
-#endif /* HEADER_CURL_VERSION_WIN32_H */
+#ifndef HEADER_CURL_VERSION_WIN32_H
+#define HEADER_CURL_VERSION_WIN32_H
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 2016 - 2020, Steve Holme, <steve_holme@hotmail.com>.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at https://curl.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+
+#include "curl_setup.h"
+
+#if defined(WIN32)
+
+/* Version condition */
+typedef enum {
+ VERSION_LESS_THAN,
+ VERSION_LESS_THAN_EQUAL,
+ VERSION_EQUAL,
+ VERSION_GREATER_THAN_EQUAL,
+ VERSION_GREATER_THAN
+} VersionCondition;
+
+/* Platform identifier */
+typedef enum {
+ PLATFORM_DONT_CARE,
+ PLATFORM_WINDOWS,
+ PLATFORM_WINNT
+} PlatformIdentifier;
+
+/* This is used to verify if we are running on a specific windows version */
+bool curlx_verify_windows_version(const unsigned int majorVersion,
+ const unsigned int minorVersion,
+ const PlatformIdentifier platform,
+ const VersionCondition condition);
+
+#endif /* WIN32 */
+
+#endif /* HEADER_CURL_VERSION_WIN32_H */
diff --git a/contrib/libs/curl/lib/vquic/ngtcp2.c b/contrib/libs/curl/lib/vquic/ngtcp2.c
index 1df4366dc0..17c419d3e4 100644
--- a/contrib/libs/curl/lib/vquic/ngtcp2.c
+++ b/contrib/libs/curl/lib/vquic/ngtcp2.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -26,9 +26,9 @@
#error #include <ngtcp2/ngtcp2.h>
#error #include <ngtcp2/ngtcp2_crypto.h>
#error #include <nghttp3/nghttp3.h>
-#ifdef USE_OPENSSL
+#ifdef USE_OPENSSL
#include <openssl/err.h>
-#endif
+#endif
#include "urldata.h"
#include "sendf.h"
#include "strdup.h"
@@ -38,9 +38,9 @@
#include "strcase.h"
#include "connect.h"
#include "strerror.h"
-#include "dynbuf.h"
-#error #include "vquic.h"
-#include "vtls/keylog.h"
+#include "dynbuf.h"
+#error #include "vquic.h"
+#include "vtls/keylog.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
@@ -48,13 +48,13 @@
#include "memdebug.h"
/* #define DEBUG_NGTCP2 */
-#ifdef CURLDEBUG
+#ifdef CURLDEBUG
#define DEBUG_HTTP3
-#endif
+#endif
#ifdef DEBUG_HTTP3
#define H3BUGF(x) x
#else
-#define H3BUGF(x) do { } while(0)
+#define H3BUGF(x) do { } while(0)
#endif
/*
@@ -74,18 +74,18 @@ struct h3out {
#define QUIC_MAX_STREAMS (256*1024)
#define QUIC_MAX_DATA (1*1024*1024)
#define QUIC_IDLE_TIMEOUT 60000 /* milliseconds */
-
-#ifdef USE_OPENSSL
+
+#ifdef USE_OPENSSL
#define QUIC_CIPHERS \
"TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_" \
"POLY1305_SHA256:TLS_AES_128_CCM_SHA256"
#define QUIC_GROUPS "P-256:X25519:P-384:P-521"
-#elif defined(USE_GNUTLS)
-#define QUIC_PRIORITY \
- "NORMAL:-VERS-ALL:+VERS-TLS1.3:-CIPHER-ALL:+AES-128-GCM:+AES-256-GCM:" \
- "+CHACHA20-POLY1305:+AES-128-CCM:-GROUP-ALL:+GROUP-SECP256R1:" \
- "+GROUP-X25519:+GROUP-SECP384R1:+GROUP-SECP521R1"
-#endif
+#elif defined(USE_GNUTLS)
+#define QUIC_PRIORITY \
+ "NORMAL:-VERS-ALL:+VERS-TLS1.3:-CIPHER-ALL:+AES-128-GCM:+AES-256-GCM:" \
+ "+CHACHA20-POLY1305:+AES-128-CCM:-GROUP-ALL:+GROUP-SECP256R1:" \
+ "+GROUP-X25519:+GROUP-SECP384R1:+GROUP-SECP521R1"
+#endif
static CURLcode ng_process_ingress(struct connectdata *conn,
curl_socket_t sockfd,
@@ -114,7 +114,7 @@ static void quic_printf(void *user_data, const char *fmt, ...)
}
#endif
-#ifdef USE_OPENSSL
+#ifdef USE_OPENSSL
static ngtcp2_crypto_level
quic_from_ossl_level(OSSL_ENCRYPTION_LEVEL ossl_level)
{
@@ -126,50 +126,50 @@ quic_from_ossl_level(OSSL_ENCRYPTION_LEVEL ossl_level)
case ssl_encryption_handshake:
return NGTCP2_CRYPTO_LEVEL_HANDSHAKE;
case ssl_encryption_application:
- return NGTCP2_CRYPTO_LEVEL_APPLICATION;
+ return NGTCP2_CRYPTO_LEVEL_APPLICATION;
+ default:
+ assert(0);
+ }
+}
+#elif defined(USE_GNUTLS)
+static ngtcp2_crypto_level
+quic_from_gtls_level(gnutls_record_encryption_level_t gtls_level)
+{
+ switch(gtls_level) {
+ case GNUTLS_ENCRYPTION_LEVEL_INITIAL:
+ return NGTCP2_CRYPTO_LEVEL_INITIAL;
+ case GNUTLS_ENCRYPTION_LEVEL_EARLY:
+ return NGTCP2_CRYPTO_LEVEL_EARLY;
+ case GNUTLS_ENCRYPTION_LEVEL_HANDSHAKE:
+ return NGTCP2_CRYPTO_LEVEL_HANDSHAKE;
+ case GNUTLS_ENCRYPTION_LEVEL_APPLICATION:
+ return NGTCP2_CRYPTO_LEVEL_APPLICATION;
default:
assert(0);
}
}
-#elif defined(USE_GNUTLS)
-static ngtcp2_crypto_level
-quic_from_gtls_level(gnutls_record_encryption_level_t gtls_level)
-{
- switch(gtls_level) {
- case GNUTLS_ENCRYPTION_LEVEL_INITIAL:
- return NGTCP2_CRYPTO_LEVEL_INITIAL;
- case GNUTLS_ENCRYPTION_LEVEL_EARLY:
- return NGTCP2_CRYPTO_LEVEL_EARLY;
- case GNUTLS_ENCRYPTION_LEVEL_HANDSHAKE:
- return NGTCP2_CRYPTO_LEVEL_HANDSHAKE;
- case GNUTLS_ENCRYPTION_LEVEL_APPLICATION:
- return NGTCP2_CRYPTO_LEVEL_APPLICATION;
- default:
- assert(0);
- }
-}
-#endif
-
-static void qlog_callback(void *user_data, uint32_t flags,
- const void *data, size_t datalen)
+#endif
+
+static void qlog_callback(void *user_data, uint32_t flags,
+ const void *data, size_t datalen)
{
- struct quicsocket *qs = (struct quicsocket *)user_data;
- (void)flags;
- if(qs->qlogfd != -1) {
- ssize_t rc = write(qs->qlogfd, data, datalen);
- if(rc == -1) {
- /* on write error, stop further write attempts */
- close(qs->qlogfd);
- qs->qlogfd = -1;
- }
- }
+ struct quicsocket *qs = (struct quicsocket *)user_data;
+ (void)flags;
+ if(qs->qlogfd != -1) {
+ ssize_t rc = write(qs->qlogfd, data, datalen);
+ if(rc == -1) {
+ /* on write error, stop further write attempts */
+ close(qs->qlogfd);
+ qs->qlogfd = -1;
+ }
+ }
}
-static void quic_settings(struct quicsocket *qs,
+static void quic_settings(struct quicsocket *qs,
uint64_t stream_buffer_size)
{
- ngtcp2_settings *s = &qs->settings;
+ ngtcp2_settings *s = &qs->settings;
ngtcp2_settings_default(s);
#ifdef DEBUG_NGTCP2
s->log_printf = quic_printf;
@@ -177,55 +177,55 @@ static void quic_settings(struct quicsocket *qs,
s->log_printf = NULL;
#endif
s->initial_ts = timestamp();
- s->transport_params.initial_max_stream_data_bidi_local = stream_buffer_size;
- s->transport_params.initial_max_stream_data_bidi_remote = QUIC_MAX_STREAMS;
- s->transport_params.initial_max_stream_data_uni = QUIC_MAX_STREAMS;
- s->transport_params.initial_max_data = QUIC_MAX_DATA;
- s->transport_params.initial_max_streams_bidi = 1;
- s->transport_params.initial_max_streams_uni = 3;
- s->transport_params.max_idle_timeout = QUIC_IDLE_TIMEOUT;
- if(qs->qlogfd != -1) {
- s->qlog.write = qlog_callback;
- }
+ s->transport_params.initial_max_stream_data_bidi_local = stream_buffer_size;
+ s->transport_params.initial_max_stream_data_bidi_remote = QUIC_MAX_STREAMS;
+ s->transport_params.initial_max_stream_data_uni = QUIC_MAX_STREAMS;
+ s->transport_params.initial_max_data = QUIC_MAX_DATA;
+ s->transport_params.initial_max_streams_bidi = 1;
+ s->transport_params.initial_max_streams_uni = 3;
+ s->transport_params.max_idle_timeout = QUIC_IDLE_TIMEOUT;
+ if(qs->qlogfd != -1) {
+ s->qlog.write = qlog_callback;
+ }
}
-#ifdef USE_OPENSSL
+#ifdef USE_OPENSSL
static void keylog_callback(const SSL *ssl, const char *line)
{
(void)ssl;
- Curl_tls_keylog_write_line(line);
+ Curl_tls_keylog_write_line(line);
}
-#elif defined(USE_GNUTLS)
-static int keylog_callback(gnutls_session_t session, const char *label,
- const gnutls_datum_t *secret)
+#elif defined(USE_GNUTLS)
+static int keylog_callback(gnutls_session_t session, const char *label,
+ const gnutls_datum_t *secret)
{
- gnutls_datum_t crandom;
- gnutls_datum_t srandom;
+ gnutls_datum_t crandom;
+ gnutls_datum_t srandom;
- gnutls_session_get_random(session, &crandom, &srandom);
- if(crandom.size != 32) {
- return -1;
- }
+ gnutls_session_get_random(session, &crandom, &srandom);
+ if(crandom.size != 32) {
+ return -1;
+ }
- Curl_tls_keylog_write(label, crandom.data, secret->data, secret->size);
- return 0;
+ Curl_tls_keylog_write(label, crandom.data, secret->data, secret->size);
+ return 0;
}
-#endif
+#endif
-static int init_ngh3_conn(struct quicsocket *qs);
-
-static int write_client_handshake(struct quicsocket *qs,
- ngtcp2_crypto_level level,
- const uint8_t *data, size_t len)
+static int init_ngh3_conn(struct quicsocket *qs);
+
+static int write_client_handshake(struct quicsocket *qs,
+ ngtcp2_crypto_level level,
+ const uint8_t *data, size_t len)
{
struct quic_handshake *crypto_data;
int rv;
- crypto_data = &qs->crypto_data[level];
+ crypto_data = &qs->crypto_data[level];
if(crypto_data->buf == NULL) {
crypto_data->buf = malloc(4096);
- if(!crypto_data->buf)
- return 0;
+ if(!crypto_data->buf)
+ return 0;
crypto_data->alloclen = 4096;
}
@@ -237,51 +237,51 @@ static int write_client_handshake(struct quicsocket *qs,
crypto_data->len += len;
rv = ngtcp2_conn_submit_crypto_data(
- qs->qconn, level, (uint8_t *)(&crypto_data->buf[crypto_data->len] - len),
- len);
+ qs->qconn, level, (uint8_t *)(&crypto_data->buf[crypto_data->len] - len),
+ len);
if(rv) {
- H3BUGF(fprintf(stderr, "write_client_handshake failed\n"));
+ H3BUGF(fprintf(stderr, "write_client_handshake failed\n"));
}
assert(0 == rv);
return 1;
}
-#ifdef USE_OPENSSL
-static int quic_set_encryption_secrets(SSL *ssl,
- OSSL_ENCRYPTION_LEVEL ossl_level,
- const uint8_t *rx_secret,
- const uint8_t *tx_secret,
- size_t secretlen)
-{
- struct quicsocket *qs = (struct quicsocket *)SSL_get_app_data(ssl);
- int level = quic_from_ossl_level(ossl_level);
-
- if(ngtcp2_crypto_derive_and_install_rx_key(
- qs->qconn, NULL, NULL, NULL, level, rx_secret, secretlen) != 0)
- return 0;
-
- if(ngtcp2_crypto_derive_and_install_tx_key(
- qs->qconn, NULL, NULL, NULL, level, tx_secret, secretlen) != 0)
- return 0;
-
- if(level == NGTCP2_CRYPTO_LEVEL_APPLICATION) {
- if(init_ngh3_conn(qs) != CURLE_OK)
- return 0;
- }
-
- return 1;
-}
-
-static int quic_add_handshake_data(SSL *ssl, OSSL_ENCRYPTION_LEVEL ossl_level,
- const uint8_t *data, size_t len)
-{
- struct quicsocket *qs = (struct quicsocket *)SSL_get_app_data(ssl);
- ngtcp2_crypto_level level = quic_from_ossl_level(ossl_level);
-
- return write_client_handshake(qs, level, data, len);
-}
-
+#ifdef USE_OPENSSL
+static int quic_set_encryption_secrets(SSL *ssl,
+ OSSL_ENCRYPTION_LEVEL ossl_level,
+ const uint8_t *rx_secret,
+ const uint8_t *tx_secret,
+ size_t secretlen)
+{
+ struct quicsocket *qs = (struct quicsocket *)SSL_get_app_data(ssl);
+ int level = quic_from_ossl_level(ossl_level);
+
+ if(ngtcp2_crypto_derive_and_install_rx_key(
+ qs->qconn, NULL, NULL, NULL, level, rx_secret, secretlen) != 0)
+ return 0;
+
+ if(ngtcp2_crypto_derive_and_install_tx_key(
+ qs->qconn, NULL, NULL, NULL, level, tx_secret, secretlen) != 0)
+ return 0;
+
+ if(level == NGTCP2_CRYPTO_LEVEL_APPLICATION) {
+ if(init_ngh3_conn(qs) != CURLE_OK)
+ return 0;
+ }
+
+ return 1;
+}
+
+static int quic_add_handshake_data(SSL *ssl, OSSL_ENCRYPTION_LEVEL ossl_level,
+ const uint8_t *data, size_t len)
+{
+ struct quicsocket *qs = (struct quicsocket *)SSL_get_app_data(ssl);
+ ngtcp2_crypto_level level = quic_from_ossl_level(ossl_level);
+
+ return write_client_handshake(qs, level, data, len);
+}
+
static int quic_flush_flight(SSL *ssl)
{
(void)ssl;
@@ -312,9 +312,9 @@ static SSL_CTX *quic_ssl_ctx(struct Curl_easy *data)
SSL_CTX_set_default_verify_paths(ssl_ctx);
if(SSL_CTX_set_ciphersuites(ssl_ctx, QUIC_CIPHERS) != 1) {
- char error_buffer[256];
- ERR_error_string_n(ERR_get_error(), error_buffer, sizeof(error_buffer));
- failf(data, "SSL_CTX_set_ciphersuites: %s", error_buffer);
+ char error_buffer[256];
+ ERR_error_string_n(ERR_get_error(), error_buffer, sizeof(error_buffer));
+ failf(data, "SSL_CTX_set_ciphersuites: %s", error_buffer);
return NULL;
}
@@ -325,10 +325,10 @@ static SSL_CTX *quic_ssl_ctx(struct Curl_easy *data)
SSL_CTX_set_quic_method(ssl_ctx, &quic_method);
- /* Open the file if a TLS or QUIC backend has not done this before. */
- Curl_tls_keylog_open();
- if(Curl_tls_keylog_enabled()) {
- SSL_CTX_set_keylog_callback(ssl_ctx, keylog_callback);
+ /* Open the file if a TLS or QUIC backend has not done this before. */
+ Curl_tls_keylog_open();
+ if(Curl_tls_keylog_enabled()) {
+ SSL_CTX_set_keylog_callback(ssl_ctx, keylog_callback);
}
return ssl_ctx;
@@ -343,14 +343,14 @@ static int quic_init_ssl(struct quicsocket *qs)
/* this will need some attention when HTTPS proxy over QUIC get fixed */
const char * const hostname = qs->conn->host.name;
- DEBUGASSERT(!qs->ssl);
+ DEBUGASSERT(!qs->ssl);
qs->ssl = SSL_new(qs->sslctx);
SSL_set_app_data(qs->ssl, qs);
SSL_set_connect_state(qs->ssl);
- alpn = (const uint8_t *)NGHTTP3_ALPN_H3;
- alpnlen = sizeof(NGHTTP3_ALPN_H3) - 1;
+ alpn = (const uint8_t *)NGHTTP3_ALPN_H3;
+ alpnlen = sizeof(NGHTTP3_ALPN_H3) - 1;
if(alpn)
SSL_set_alpn_protos(qs->ssl, alpn, (int)alpnlen);
@@ -358,186 +358,186 @@ static int quic_init_ssl(struct quicsocket *qs)
SSL_set_tlsext_host_name(qs->ssl, hostname);
return 0;
}
-#elif defined(USE_GNUTLS)
-static int secret_func(gnutls_session_t ssl,
- gnutls_record_encryption_level_t gtls_level,
- const void *rx_secret,
- const void *tx_secret, size_t secretlen)
-{
- struct quicsocket *qs = gnutls_session_get_ptr(ssl);
- int level = quic_from_gtls_level(gtls_level);
-
- if(level != NGTCP2_CRYPTO_LEVEL_EARLY &&
- ngtcp2_crypto_derive_and_install_rx_key(
- qs->qconn, NULL, NULL, NULL, level, rx_secret, secretlen) != 0)
- return 0;
-
- if(ngtcp2_crypto_derive_and_install_tx_key(
- qs->qconn, NULL, NULL, NULL, level, tx_secret, secretlen) != 0)
- return 0;
-
- if(level == NGTCP2_CRYPTO_LEVEL_APPLICATION) {
- if(init_ngh3_conn(qs) != CURLE_OK)
- return -1;
- }
-
- return 0;
-}
-
-static int read_func(gnutls_session_t ssl,
- gnutls_record_encryption_level_t gtls_level,
- gnutls_handshake_description_t htype, const void *data,
- size_t len)
+#elif defined(USE_GNUTLS)
+static int secret_func(gnutls_session_t ssl,
+ gnutls_record_encryption_level_t gtls_level,
+ const void *rx_secret,
+ const void *tx_secret, size_t secretlen)
{
- struct quicsocket *qs = gnutls_session_get_ptr(ssl);
- ngtcp2_crypto_level level = quic_from_gtls_level(gtls_level);
- int rv;
+ struct quicsocket *qs = gnutls_session_get_ptr(ssl);
+ int level = quic_from_gtls_level(gtls_level);
- if(htype == GNUTLS_HANDSHAKE_CHANGE_CIPHER_SPEC)
- return 0;
+ if(level != NGTCP2_CRYPTO_LEVEL_EARLY &&
+ ngtcp2_crypto_derive_and_install_rx_key(
+ qs->qconn, NULL, NULL, NULL, level, rx_secret, secretlen) != 0)
+ return 0;
+
+ if(ngtcp2_crypto_derive_and_install_tx_key(
+ qs->qconn, NULL, NULL, NULL, level, tx_secret, secretlen) != 0)
+ return 0;
+
+ if(level == NGTCP2_CRYPTO_LEVEL_APPLICATION) {
+ if(init_ngh3_conn(qs) != CURLE_OK)
+ return -1;
+ }
- rv = write_client_handshake(qs, level, data, len);
- if(rv == 0)
- return -1;
-
return 0;
}
-static int alert_read_func(gnutls_session_t ssl,
- gnutls_record_encryption_level_t gtls_level,
- gnutls_alert_level_t alert_level,
- gnutls_alert_description_t alert_desc)
-{
- struct quicsocket *qs = gnutls_session_get_ptr(ssl);
- (void)gtls_level;
- (void)alert_level;
-
- qs->tls_alert = alert_desc;
- return 1;
-}
-
-static int tp_recv_func(gnutls_session_t ssl, const uint8_t *data,
- size_t data_size)
-{
- struct quicsocket *qs = gnutls_session_get_ptr(ssl);
- ngtcp2_transport_params params;
-
- if(ngtcp2_decode_transport_params(
- &params, NGTCP2_TRANSPORT_PARAMS_TYPE_ENCRYPTED_EXTENSIONS,
- data, data_size) != 0)
- return -1;
-
- if(ngtcp2_conn_set_remote_transport_params(qs->qconn, &params) != 0)
- return -1;
-
- return 0;
-}
-
-static int tp_send_func(gnutls_session_t ssl, gnutls_buffer_t extdata)
-{
- struct quicsocket *qs = gnutls_session_get_ptr(ssl);
- uint8_t paramsbuf[64];
- ngtcp2_transport_params params;
- ssize_t nwrite;
- int rc;
-
- ngtcp2_conn_get_local_transport_params(qs->qconn, &params);
- nwrite = ngtcp2_encode_transport_params(
- paramsbuf, sizeof(paramsbuf), NGTCP2_TRANSPORT_PARAMS_TYPE_CLIENT_HELLO,
- &params);
- if(nwrite < 0) {
- H3BUGF(fprintf(stderr, "ngtcp2_encode_transport_params: %s\n",
- ngtcp2_strerror((int)nwrite)));
- return -1;
- }
-
- rc = gnutls_buffer_append_data(extdata, paramsbuf, nwrite);
- if(rc < 0)
- return rc;
-
- return (int)nwrite;
-}
-
-static int quic_init_ssl(struct quicsocket *qs)
-{
- gnutls_datum_t alpn = {NULL, 0};
- /* this will need some attention when HTTPS proxy over QUIC get fixed */
- const char * const hostname = qs->conn->host.name;
- int rc;
-
- DEBUGASSERT(!qs->ssl);
-
- gnutls_init(&qs->ssl, GNUTLS_CLIENT);
- gnutls_session_set_ptr(qs->ssl, qs);
-
- rc = gnutls_priority_set_direct(qs->ssl, QUIC_PRIORITY, NULL);
- if(rc < 0) {
- H3BUGF(fprintf(stderr, "gnutls_priority_set_direct failed: %s\n",
- gnutls_strerror(rc)));
- return 1;
- }
-
- gnutls_handshake_set_secret_function(qs->ssl, secret_func);
- gnutls_handshake_set_read_function(qs->ssl, read_func);
- gnutls_alert_set_read_function(qs->ssl, alert_read_func);
-
- rc = gnutls_session_ext_register(qs->ssl, "QUIC Transport Parameters",
- 0xffa5, GNUTLS_EXT_TLS,
- tp_recv_func, tp_send_func,
- NULL, NULL, NULL,
- GNUTLS_EXT_FLAG_TLS |
- GNUTLS_EXT_FLAG_CLIENT_HELLO |
- GNUTLS_EXT_FLAG_EE);
- if(rc < 0) {
- H3BUGF(fprintf(stderr, "gnutls_session_ext_register failed: %s\n",
- gnutls_strerror(rc)));
- return 1;
- }
-
- /* Open the file if a TLS or QUIC backend has not done this before. */
- Curl_tls_keylog_open();
- if(Curl_tls_keylog_enabled()) {
- gnutls_session_set_keylog_function(qs->ssl, keylog_callback);
- }
-
- if(qs->cred)
- gnutls_certificate_free_credentials(qs->cred);
-
- rc = gnutls_certificate_allocate_credentials(&qs->cred);
- if(rc < 0) {
- H3BUGF(fprintf(stderr,
- "gnutls_certificate_allocate_credentials failed: %s\n",
- gnutls_strerror(rc)));
- return 1;
- }
-
- rc = gnutls_certificate_set_x509_system_trust(qs->cred);
- if(rc < 0) {
- H3BUGF(fprintf(stderr,
- "gnutls_certificate_set_x509_system_trust failed: %s\n",
- gnutls_strerror(rc)));
- return 1;
- }
-
- rc = gnutls_credentials_set(qs->ssl, GNUTLS_CRD_CERTIFICATE, qs->cred);
- if(rc < 0) {
- H3BUGF(fprintf(stderr, "gnutls_credentials_set failed: %s\n",
- gnutls_strerror(rc)));
- return 1;
- }
-
- /* strip the first byte (the length) from NGHTTP3_ALPN_H3 */
- alpn.data = (unsigned char *)NGHTTP3_ALPN_H3 + 1;
- alpn.size = sizeof(NGHTTP3_ALPN_H3) - 2;
- if(alpn.data)
- gnutls_alpn_set_protocols(qs->ssl, &alpn, 1, 0);
-
- /* set SNI */
- gnutls_server_name_set(qs->ssl, GNUTLS_NAME_DNS, hostname, strlen(hostname));
- return 0;
-}
-#endif
-
+static int read_func(gnutls_session_t ssl,
+ gnutls_record_encryption_level_t gtls_level,
+ gnutls_handshake_description_t htype, const void *data,
+ size_t len)
+{
+ struct quicsocket *qs = gnutls_session_get_ptr(ssl);
+ ngtcp2_crypto_level level = quic_from_gtls_level(gtls_level);
+ int rv;
+
+ if(htype == GNUTLS_HANDSHAKE_CHANGE_CIPHER_SPEC)
+ return 0;
+
+ rv = write_client_handshake(qs, level, data, len);
+ if(rv == 0)
+ return -1;
+
+ return 0;
+}
+
+static int alert_read_func(gnutls_session_t ssl,
+ gnutls_record_encryption_level_t gtls_level,
+ gnutls_alert_level_t alert_level,
+ gnutls_alert_description_t alert_desc)
+{
+ struct quicsocket *qs = gnutls_session_get_ptr(ssl);
+ (void)gtls_level;
+ (void)alert_level;
+
+ qs->tls_alert = alert_desc;
+ return 1;
+}
+
+static int tp_recv_func(gnutls_session_t ssl, const uint8_t *data,
+ size_t data_size)
+{
+ struct quicsocket *qs = gnutls_session_get_ptr(ssl);
+ ngtcp2_transport_params params;
+
+ if(ngtcp2_decode_transport_params(
+ &params, NGTCP2_TRANSPORT_PARAMS_TYPE_ENCRYPTED_EXTENSIONS,
+ data, data_size) != 0)
+ return -1;
+
+ if(ngtcp2_conn_set_remote_transport_params(qs->qconn, &params) != 0)
+ return -1;
+
+ return 0;
+}
+
+static int tp_send_func(gnutls_session_t ssl, gnutls_buffer_t extdata)
+{
+ struct quicsocket *qs = gnutls_session_get_ptr(ssl);
+ uint8_t paramsbuf[64];
+ ngtcp2_transport_params params;
+ ssize_t nwrite;
+ int rc;
+
+ ngtcp2_conn_get_local_transport_params(qs->qconn, &params);
+ nwrite = ngtcp2_encode_transport_params(
+ paramsbuf, sizeof(paramsbuf), NGTCP2_TRANSPORT_PARAMS_TYPE_CLIENT_HELLO,
+ &params);
+ if(nwrite < 0) {
+ H3BUGF(fprintf(stderr, "ngtcp2_encode_transport_params: %s\n",
+ ngtcp2_strerror((int)nwrite)));
+ return -1;
+ }
+
+ rc = gnutls_buffer_append_data(extdata, paramsbuf, nwrite);
+ if(rc < 0)
+ return rc;
+
+ return (int)nwrite;
+}
+
+static int quic_init_ssl(struct quicsocket *qs)
+{
+ gnutls_datum_t alpn = {NULL, 0};
+ /* this will need some attention when HTTPS proxy over QUIC get fixed */
+ const char * const hostname = qs->conn->host.name;
+ int rc;
+
+ DEBUGASSERT(!qs->ssl);
+
+ gnutls_init(&qs->ssl, GNUTLS_CLIENT);
+ gnutls_session_set_ptr(qs->ssl, qs);
+
+ rc = gnutls_priority_set_direct(qs->ssl, QUIC_PRIORITY, NULL);
+ if(rc < 0) {
+ H3BUGF(fprintf(stderr, "gnutls_priority_set_direct failed: %s\n",
+ gnutls_strerror(rc)));
+ return 1;
+ }
+
+ gnutls_handshake_set_secret_function(qs->ssl, secret_func);
+ gnutls_handshake_set_read_function(qs->ssl, read_func);
+ gnutls_alert_set_read_function(qs->ssl, alert_read_func);
+
+ rc = gnutls_session_ext_register(qs->ssl, "QUIC Transport Parameters",
+ 0xffa5, GNUTLS_EXT_TLS,
+ tp_recv_func, tp_send_func,
+ NULL, NULL, NULL,
+ GNUTLS_EXT_FLAG_TLS |
+ GNUTLS_EXT_FLAG_CLIENT_HELLO |
+ GNUTLS_EXT_FLAG_EE);
+ if(rc < 0) {
+ H3BUGF(fprintf(stderr, "gnutls_session_ext_register failed: %s\n",
+ gnutls_strerror(rc)));
+ return 1;
+ }
+
+ /* Open the file if a TLS or QUIC backend has not done this before. */
+ Curl_tls_keylog_open();
+ if(Curl_tls_keylog_enabled()) {
+ gnutls_session_set_keylog_function(qs->ssl, keylog_callback);
+ }
+
+ if(qs->cred)
+ gnutls_certificate_free_credentials(qs->cred);
+
+ rc = gnutls_certificate_allocate_credentials(&qs->cred);
+ if(rc < 0) {
+ H3BUGF(fprintf(stderr,
+ "gnutls_certificate_allocate_credentials failed: %s\n",
+ gnutls_strerror(rc)));
+ return 1;
+ }
+
+ rc = gnutls_certificate_set_x509_system_trust(qs->cred);
+ if(rc < 0) {
+ H3BUGF(fprintf(stderr,
+ "gnutls_certificate_set_x509_system_trust failed: %s\n",
+ gnutls_strerror(rc)));
+ return 1;
+ }
+
+ rc = gnutls_credentials_set(qs->ssl, GNUTLS_CRD_CERTIFICATE, qs->cred);
+ if(rc < 0) {
+ H3BUGF(fprintf(stderr, "gnutls_credentials_set failed: %s\n",
+ gnutls_strerror(rc)));
+ return 1;
+ }
+
+ /* strip the first byte (the length) from NGHTTP3_ALPN_H3 */
+ alpn.data = (unsigned char *)NGHTTP3_ALPN_H3 + 1;
+ alpn.size = sizeof(NGHTTP3_ALPN_H3) - 2;
+ if(alpn.data)
+ gnutls_alpn_set_protocols(qs->ssl, &alpn, 1, 0);
+
+ /* set SNI */
+ gnutls_server_name_set(qs->ssl, GNUTLS_NAME_DNS, hostname, strlen(hostname));
+ return 0;
+}
+#endif
+
static int
cb_recv_crypto_data(ngtcp2_conn *tconn, ngtcp2_crypto_level crypto_level,
uint64_t offset,
@@ -545,9 +545,9 @@ cb_recv_crypto_data(ngtcp2_conn *tconn, ngtcp2_crypto_level crypto_level,
void *user_data)
{
(void)offset;
- (void)user_data;
+ (void)user_data;
- if(ngtcp2_crypto_read_write_crypto_data(tconn, crypto_level, data,
+ if(ngtcp2_crypto_read_write_crypto_data(tconn, crypto_level, data,
datalen) != 0)
return NGTCP2_ERR_CRYPTO;
@@ -563,24 +563,24 @@ static int cb_handshake_completed(ngtcp2_conn *tconn, void *user_data)
return 0;
}
-static void extend_stream_window(ngtcp2_conn *tconn,
- struct HTTP *stream)
-{
- size_t thismuch = stream->unacked_window;
- ngtcp2_conn_extend_max_stream_offset(tconn, stream->stream3_id, thismuch);
- ngtcp2_conn_extend_max_offset(tconn, thismuch);
- stream->unacked_window = 0;
-}
-
-
-static int cb_recv_stream_data(ngtcp2_conn *tconn, uint32_t flags,
- int64_t stream_id, uint64_t offset,
+static void extend_stream_window(ngtcp2_conn *tconn,
+ struct HTTP *stream)
+{
+ size_t thismuch = stream->unacked_window;
+ ngtcp2_conn_extend_max_stream_offset(tconn, stream->stream3_id, thismuch);
+ ngtcp2_conn_extend_max_offset(tconn, thismuch);
+ stream->unacked_window = 0;
+}
+
+
+static int cb_recv_stream_data(ngtcp2_conn *tconn, uint32_t flags,
+ int64_t stream_id, uint64_t offset,
const uint8_t *buf, size_t buflen,
void *user_data, void *stream_user_data)
{
struct quicsocket *qs = (struct quicsocket *)user_data;
ssize_t nconsumed;
- int fin = flags & NGTCP2_STREAM_DATA_FLAG_FIN ? 1 : 0;
+ int fin = flags & NGTCP2_STREAM_DATA_FLAG_FIN ? 1 : 0;
(void)offset;
(void)stream_user_data;
@@ -592,9 +592,9 @@ static int cb_recv_stream_data(ngtcp2_conn *tconn, uint32_t flags,
return NGTCP2_ERR_CALLBACK_FAILURE;
}
- /* number of bytes inside buflen which consists of framing overhead
- * including QPACK HEADERS. In other words, it does not consume payload of
- * DATA frame. */
+ /* number of bytes inside buflen which consists of framing overhead
+ * including QPACK HEADERS. In other words, it does not consume payload of
+ * DATA frame. */
ngtcp2_conn_extend_max_stream_offset(tconn, stream_id, nconsumed);
ngtcp2_conn_extend_max_offset(tconn, nconsumed);
@@ -718,7 +718,7 @@ static int cb_get_new_connection_id(ngtcp2_conn *tconn, ngtcp2_cid *cid,
}
static ngtcp2_conn_callbacks ng_callbacks = {
- ngtcp2_crypto_client_initial_cb,
+ ngtcp2_crypto_client_initial_cb,
NULL, /* recv_client_initial */
cb_recv_crypto_data,
cb_handshake_completed,
@@ -732,24 +732,24 @@ static ngtcp2_conn_callbacks ng_callbacks = {
NULL, /* stream_open */
cb_stream_close,
NULL, /* recv_stateless_reset */
- ngtcp2_crypto_recv_retry_cb,
+ ngtcp2_crypto_recv_retry_cb,
cb_extend_max_local_streams_bidi,
NULL, /* extend_max_local_streams_uni */
NULL, /* rand */
cb_get_new_connection_id,
NULL, /* remove_connection_id */
- ngtcp2_crypto_update_key_cb, /* update_key */
+ ngtcp2_crypto_update_key_cb, /* update_key */
NULL, /* path_validation */
NULL, /* select_preferred_addr */
cb_stream_reset,
NULL, /* extend_max_remote_streams_bidi */
NULL, /* extend_max_remote_streams_uni */
cb_extend_max_stream_data,
- NULL, /* dcid_status */
- NULL, /* handshake_confirmed */
- NULL, /* recv_new_token */
- ngtcp2_crypto_delete_crypto_aead_ctx_cb,
- ngtcp2_crypto_delete_crypto_cipher_ctx_cb
+ NULL, /* dcid_status */
+ NULL, /* handshake_confirmed */
+ NULL, /* recv_new_token */
+ ngtcp2_crypto_delete_crypto_aead_ctx_cb,
+ ngtcp2_crypto_delete_crypto_cipher_ctx_cb
};
/*
@@ -769,32 +769,32 @@ CURLcode Curl_quic_connect(struct connectdata *conn,
struct quicsocket *qs = &conn->hequic[sockindex];
char ipbuf[40];
long port;
- int qfd;
+ int qfd;
- if(qs->conn)
- Curl_quic_disconnect(conn, sockindex);
+ if(qs->conn)
+ Curl_quic_disconnect(conn, sockindex);
qs->conn = conn;
/* extract the used address as a string */
if(!Curl_addr2string((struct sockaddr*)addr, addrlen, ipbuf, &port)) {
char buffer[STRERROR_LEN];
failf(data, "ssrem inet_ntop() failed with errno %d: %s",
- SOCKERRNO, Curl_strerror(SOCKERRNO, buffer, sizeof(buffer)));
+ SOCKERRNO, Curl_strerror(SOCKERRNO, buffer, sizeof(buffer)));
return CURLE_BAD_FUNCTION_ARGUMENT;
}
infof(data, "Connect socket %d over QUIC to %s:%ld\n",
sockfd, ipbuf, port);
- qs->version = NGTCP2_PROTO_VER_MAX;
-#ifdef USE_OPENSSL
+ qs->version = NGTCP2_PROTO_VER_MAX;
+#ifdef USE_OPENSSL
qs->sslctx = quic_ssl_ctx(data);
if(!qs->sslctx)
- return CURLE_QUIC_CONNECT_ERROR;
-#endif
+ return CURLE_QUIC_CONNECT_ERROR;
+#endif
if(quic_init_ssl(qs))
- return CURLE_QUIC_CONNECT_ERROR;
+ return CURLE_QUIC_CONNECT_ERROR;
qs->dcid.datalen = NGTCP2_MAX_CIDLEN;
result = Curl_rand(data, qs->dcid.data, NGTCP2_MAX_CIDLEN);
@@ -806,27 +806,27 @@ CURLcode Curl_quic_connect(struct connectdata *conn,
if(result)
return result;
- (void)Curl_qlogdir(data, qs->scid.data, NGTCP2_MAX_CIDLEN, &qfd);
- qs->qlogfd = qfd; /* -1 if failure above */
- quic_settings(qs, data->set.buffer_size);
+ (void)Curl_qlogdir(data, qs->scid.data, NGTCP2_MAX_CIDLEN, &qfd);
+ qs->qlogfd = qfd; /* -1 if failure above */
+ quic_settings(qs, data->set.buffer_size);
qs->local_addrlen = sizeof(qs->local_addr);
rv = getsockname(sockfd, (struct sockaddr *)&qs->local_addr,
&qs->local_addrlen);
if(rv == -1)
- return CURLE_QUIC_CONNECT_ERROR;
+ return CURLE_QUIC_CONNECT_ERROR;
- ngtcp2_addr_init(&path.local, (struct sockaddr *)&qs->local_addr,
- qs->local_addrlen, NULL);
- ngtcp2_addr_init(&path.remote, addr, addrlen, NULL);
+ ngtcp2_addr_init(&path.local, (struct sockaddr *)&qs->local_addr,
+ qs->local_addrlen, NULL);
+ ngtcp2_addr_init(&path.remote, addr, addrlen, NULL);
- rc = ngtcp2_conn_client_new(&qs->qconn, &qs->dcid, &qs->scid, &path,
- NGTCP2_PROTO_VER_MIN, &ng_callbacks,
- &qs->settings, NULL, qs);
+ rc = ngtcp2_conn_client_new(&qs->qconn, &qs->dcid, &qs->scid, &path,
+ NGTCP2_PROTO_VER_MIN, &ng_callbacks,
+ &qs->settings, NULL, qs);
if(rc)
- return CURLE_QUIC_CONNECT_ERROR;
+ return CURLE_QUIC_CONNECT_ERROR;
- ngtcp2_conn_set_tls_native_handle(qs->qconn, qs->ssl);
+ ngtcp2_conn_set_tls_native_handle(qs->qconn, qs->ssl);
return CURLE_OK;
}
@@ -839,7 +839,7 @@ int Curl_quic_ver(char *p, size_t len)
{
ngtcp2_info *ng2 = ngtcp2_version(0);
nghttp3_info *ht3 = nghttp3_version(0);
- return msnprintf(p, len, "ngtcp2/%s nghttp3/%s",
+ return msnprintf(p, len, "ngtcp2/%s nghttp3/%s",
ng2->version_str, ht3->version_str);
}
@@ -867,49 +867,49 @@ static int ng_perform_getsock(const struct connectdata *conn,
return ng_getsock((struct connectdata *)conn, socks);
}
-static void qs_disconnect(struct quicsocket *qs)
-{
- int i;
- if(!qs->conn) /* already closed */
- return;
- qs->conn = NULL;
- if(qs->qlogfd != -1) {
- close(qs->qlogfd);
- qs->qlogfd = -1;
- }
- if(qs->ssl)
-#ifdef USE_OPENSSL
- SSL_free(qs->ssl);
-#elif defined(USE_GNUTLS)
- gnutls_deinit(qs->ssl);
-#endif
- qs->ssl = NULL;
-#ifdef USE_GNUTLS
- if(qs->cred)
- gnutls_certificate_free_credentials(qs->cred);
-#endif
- for(i = 0; i < 3; i++)
- Curl_safefree(qs->crypto_data[i].buf);
- nghttp3_conn_del(qs->h3conn);
- ngtcp2_conn_del(qs->qconn);
-#ifdef USE_OPENSSL
- SSL_CTX_free(qs->sslctx);
-#endif
-}
-
-void Curl_quic_disconnect(struct connectdata *conn,
- int tempindex)
-{
- if(conn->transport == TRNSPRT_QUIC)
- qs_disconnect(&conn->hequic[tempindex]);
-}
-
+static void qs_disconnect(struct quicsocket *qs)
+{
+ int i;
+ if(!qs->conn) /* already closed */
+ return;
+ qs->conn = NULL;
+ if(qs->qlogfd != -1) {
+ close(qs->qlogfd);
+ qs->qlogfd = -1;
+ }
+ if(qs->ssl)
+#ifdef USE_OPENSSL
+ SSL_free(qs->ssl);
+#elif defined(USE_GNUTLS)
+ gnutls_deinit(qs->ssl);
+#endif
+ qs->ssl = NULL;
+#ifdef USE_GNUTLS
+ if(qs->cred)
+ gnutls_certificate_free_credentials(qs->cred);
+#endif
+ for(i = 0; i < 3; i++)
+ Curl_safefree(qs->crypto_data[i].buf);
+ nghttp3_conn_del(qs->h3conn);
+ ngtcp2_conn_del(qs->qconn);
+#ifdef USE_OPENSSL
+ SSL_CTX_free(qs->sslctx);
+#endif
+}
+
+void Curl_quic_disconnect(struct connectdata *conn,
+ int tempindex)
+{
+ if(conn->transport == TRNSPRT_QUIC)
+ qs_disconnect(&conn->hequic[tempindex]);
+}
+
static CURLcode ng_disconnect(struct connectdata *conn,
bool dead_connection)
{
(void)dead_connection;
- Curl_quic_disconnect(conn, 0);
- Curl_quic_disconnect(conn, 1);
+ Curl_quic_disconnect(conn, 0);
+ Curl_quic_disconnect(conn, 1);
return CURLE_OK;
}
@@ -939,7 +939,7 @@ static const struct Curl_handler Curl_handler_http3 = {
ng_conncheck, /* connection_check */
PORT_HTTP, /* defport */
CURLPROTO_HTTPS, /* protocol */
- CURLPROTO_HTTP, /* family */
+ CURLPROTO_HTTP, /* family */
PROTOPT_SSL | PROTOPT_STREAM /* flags */
};
@@ -948,63 +948,63 @@ static int cb_h3_stream_close(nghttp3_conn *conn, int64_t stream_id,
void *stream_user_data)
{
struct Curl_easy *data = stream_user_data;
- struct HTTP *stream = data->req.p.http;
+ struct HTTP *stream = data->req.p.http;
(void)conn;
(void)stream_id;
(void)app_error_code;
(void)user_data;
- H3BUGF(infof(data, "cb_h3_stream_close CALLED\n"));
+ H3BUGF(infof(data, "cb_h3_stream_close CALLED\n"));
stream->closed = TRUE;
Curl_expire(data, 0, EXPIRE_QUIC);
- /* make sure that ngh3_stream_recv is called again to complete the transfer
- even if there are no more packets to be received from the server. */
- data->state.drain = 1;
+ /* make sure that ngh3_stream_recv is called again to complete the transfer
+ even if there are no more packets to be received from the server. */
+ data->state.drain = 1;
return 0;
}
-/*
- * write_data() copies data to the stream's receive buffer. If not enough
- * space is available in the receive buffer, it copies the rest to the
- * stream's overflow buffer.
- */
-static CURLcode write_data(struct HTTP *stream, const void *mem, size_t memlen)
-{
- CURLcode result = CURLE_OK;
- const char *buf = mem;
- size_t ncopy = memlen;
- /* copy as much as possible to the receive buffer */
- if(stream->len) {
- size_t len = CURLMIN(ncopy, stream->len);
- memcpy(stream->mem, buf, len);
- stream->len -= len;
- stream->memlen += len;
- stream->mem += len;
- buf += len;
- ncopy -= len;
- }
- /* copy the rest to the overflow buffer */
- if(ncopy)
- result = Curl_dyn_addn(&stream->overflow, buf, ncopy);
- return result;
-}
-
+/*
+ * write_data() copies data to the stream's receive buffer. If not enough
+ * space is available in the receive buffer, it copies the rest to the
+ * stream's overflow buffer.
+ */
+static CURLcode write_data(struct HTTP *stream, const void *mem, size_t memlen)
+{
+ CURLcode result = CURLE_OK;
+ const char *buf = mem;
+ size_t ncopy = memlen;
+ /* copy as much as possible to the receive buffer */
+ if(stream->len) {
+ size_t len = CURLMIN(ncopy, stream->len);
+ memcpy(stream->mem, buf, len);
+ stream->len -= len;
+ stream->memlen += len;
+ stream->mem += len;
+ buf += len;
+ ncopy -= len;
+ }
+ /* copy the rest to the overflow buffer */
+ if(ncopy)
+ result = Curl_dyn_addn(&stream->overflow, buf, ncopy);
+ return result;
+}
+
static int cb_h3_recv_data(nghttp3_conn *conn, int64_t stream_id,
const uint8_t *buf, size_t buflen,
void *user_data, void *stream_user_data)
{
struct Curl_easy *data = stream_user_data;
- struct HTTP *stream = data->req.p.http;
- CURLcode result = CURLE_OK;
+ struct HTTP *stream = data->req.p.http;
+ CURLcode result = CURLE_OK;
(void)conn;
- result = write_data(stream, buf, buflen);
- if(result) {
- return -1;
+ result = write_data(stream, buf, buflen);
+ if(result) {
+ return -1;
}
- stream->unacked_window += buflen;
- (void)stream_id;
- (void)user_data;
+ stream->unacked_window += buflen;
+ (void)stream_id;
+ (void)user_data;
return 0;
}
@@ -1015,7 +1015,7 @@ static int cb_h3_deferred_consume(nghttp3_conn *conn, int64_t stream_id,
struct quicsocket *qs = user_data;
(void)conn;
(void)stream_user_data;
- (void)stream_id;
+ (void)stream_id;
ngtcp2_conn_extend_max_stream_offset(qs->qconn, stream_id, consumed);
ngtcp2_conn_extend_max_offset(qs->qconn, consumed);
@@ -1053,18 +1053,18 @@ static int cb_h3_end_headers(nghttp3_conn *conn, int64_t stream_id,
void *user_data, void *stream_user_data)
{
struct Curl_easy *data = stream_user_data;
- struct HTTP *stream = data->req.p.http;
- CURLcode result = CURLE_OK;
+ struct HTTP *stream = data->req.p.http;
+ CURLcode result = CURLE_OK;
(void)conn;
(void)stream_id;
(void)user_data;
- /* add a CRLF only if we've received some headers */
- if(stream->firstheader) {
- result = write_data(stream, "\r\n", 2);
- if(result) {
- return -1;
- }
+ /* add a CRLF only if we've received some headers */
+ if(stream->firstheader) {
+ result = write_data(stream, "\r\n", 2);
+ if(result) {
+ return -1;
+ }
}
return 0;
}
@@ -1077,8 +1077,8 @@ static int cb_h3_recv_header(nghttp3_conn *conn, int64_t stream_id,
nghttp3_vec h3name = nghttp3_rcbuf_get_buf(name);
nghttp3_vec h3val = nghttp3_rcbuf_get_buf(value);
struct Curl_easy *data = stream_user_data;
- struct HTTP *stream = data->req.p.http;
- CURLcode result = CURLE_OK;
+ struct HTTP *stream = data->req.p.http;
+ CURLcode result = CURLE_OK;
(void)conn;
(void)stream_id;
(void)token;
@@ -1087,37 +1087,37 @@ static int cb_h3_recv_header(nghttp3_conn *conn, int64_t stream_id,
if(h3name.len == sizeof(":status") - 1 &&
!memcmp(":status", h3name.base, h3name.len)) {
- char line[14]; /* status line is always 13 characters long */
- size_t ncopy;
+ char line[14]; /* status line is always 13 characters long */
+ size_t ncopy;
int status = decode_status_code(h3val.base, h3val.len);
DEBUGASSERT(status != -1);
- ncopy = msnprintf(line, sizeof(line), "HTTP/3 %03d \r\n", status);
- result = write_data(stream, line, ncopy);
- if(result) {
- return -1;
- }
+ ncopy = msnprintf(line, sizeof(line), "HTTP/3 %03d \r\n", status);
+ result = write_data(stream, line, ncopy);
+ if(result) {
+ return -1;
+ }
}
else {
/* store as a HTTP1-style header */
- result = write_data(stream, h3name.base, h3name.len);
- if(result) {
- return -1;
- }
- result = write_data(stream, ": ", 2);
- if(result) {
- return -1;
- }
- result = write_data(stream, h3val.base, h3val.len);
- if(result) {
- return -1;
- }
- result = write_data(stream, "\r\n", 2);
- if(result) {
- return -1;
- }
- }
-
- stream->firstheader = TRUE;
+ result = write_data(stream, h3name.base, h3name.len);
+ if(result) {
+ return -1;
+ }
+ result = write_data(stream, ": ", 2);
+ if(result) {
+ return -1;
+ }
+ result = write_data(stream, h3val.base, h3val.len);
+ if(result) {
+ return -1;
+ }
+ result = write_data(stream, "\r\n", 2);
+ if(result) {
+ return -1;
+ }
+ }
+
+ stream->firstheader = TRUE;
return 0;
}
@@ -1152,7 +1152,7 @@ static nghttp3_conn_callbacks ngh3_callbacks = {
cb_h3_send_stop_sending,
NULL, /* push_stream */
NULL, /* end_stream */
- NULL, /* reset_stream */
+ NULL, /* reset_stream */
};
static int init_ngh3_conn(struct quicsocket *qs)
@@ -1163,7 +1163,7 @@ static int init_ngh3_conn(struct quicsocket *qs)
if(ngtcp2_conn_get_max_local_streams_uni(qs->qconn) < 3) {
failf(qs->conn->data, "too few available QUIC streams");
- return CURLE_QUIC_CONNECT_ERROR;
+ return CURLE_QUIC_CONNECT_ERROR;
}
nghttp3_conn_settings_default(&qs->h3settings);
@@ -1180,32 +1180,32 @@ static int init_ngh3_conn(struct quicsocket *qs)
rc = ngtcp2_conn_open_uni_stream(qs->qconn, &ctrl_stream_id, NULL);
if(rc) {
- result = CURLE_QUIC_CONNECT_ERROR;
+ result = CURLE_QUIC_CONNECT_ERROR;
goto fail;
}
rc = nghttp3_conn_bind_control_stream(qs->h3conn, ctrl_stream_id);
if(rc) {
- result = CURLE_QUIC_CONNECT_ERROR;
+ result = CURLE_QUIC_CONNECT_ERROR;
goto fail;
}
rc = ngtcp2_conn_open_uni_stream(qs->qconn, &qpack_enc_stream_id, NULL);
if(rc) {
- result = CURLE_QUIC_CONNECT_ERROR;
+ result = CURLE_QUIC_CONNECT_ERROR;
goto fail;
}
rc = ngtcp2_conn_open_uni_stream(qs->qconn, &qpack_dec_stream_id, NULL);
if(rc) {
- result = CURLE_QUIC_CONNECT_ERROR;
+ result = CURLE_QUIC_CONNECT_ERROR;
goto fail;
}
rc = nghttp3_conn_bind_qpack_streams(qs->h3conn, qpack_enc_stream_id,
qpack_dec_stream_id);
if(rc) {
- result = CURLE_QUIC_CONNECT_ERROR;
+ result = CURLE_QUIC_CONNECT_ERROR;
goto fail;
}
@@ -1218,22 +1218,22 @@ static int init_ngh3_conn(struct quicsocket *qs)
static Curl_recv ngh3_stream_recv;
static Curl_send ngh3_stream_send;
-static size_t drain_overflow_buffer(struct HTTP *stream)
-{
- size_t overlen = Curl_dyn_len(&stream->overflow);
- size_t ncopy = CURLMIN(overlen, stream->len);
- if(ncopy > 0) {
- memcpy(stream->mem, Curl_dyn_ptr(&stream->overflow), ncopy);
- stream->len -= ncopy;
- stream->mem += ncopy;
- stream->memlen += ncopy;
- if(ncopy != overlen)
- /* make the buffer only keep the tail */
- (void)Curl_dyn_tail(&stream->overflow, overlen - ncopy);
- }
- return ncopy;
-}
-
+static size_t drain_overflow_buffer(struct HTTP *stream)
+{
+ size_t overlen = Curl_dyn_len(&stream->overflow);
+ size_t ncopy = CURLMIN(overlen, stream->len);
+ if(ncopy > 0) {
+ memcpy(stream->mem, Curl_dyn_ptr(&stream->overflow), ncopy);
+ stream->len -= ncopy;
+ stream->mem += ncopy;
+ stream->memlen += ncopy;
+ if(ncopy != overlen)
+ /* make the buffer only keep the tail */
+ (void)Curl_dyn_tail(&stream->overflow, overlen - ncopy);
+ }
+ return ncopy;
+}
+
/* incoming data frames on the h3 stream */
static ssize_t ngh3_stream_recv(struct connectdata *conn,
int sockindex,
@@ -1242,7 +1242,7 @@ static ssize_t ngh3_stream_recv(struct connectdata *conn,
CURLcode *curlcode)
{
curl_socket_t sockfd = conn->sock[sockindex];
- struct HTTP *stream = conn->data->req.p.http;
+ struct HTTP *stream = conn->data->req.p.http;
struct quicsocket *qs = conn->quic;
if(!stream->memlen) {
@@ -1253,10 +1253,10 @@ static ssize_t ngh3_stream_recv(struct connectdata *conn,
}
/* else, there's data in the buffer already */
- /* if there's data in the overflow buffer from a previous call, copy as much
- as possible to the receive buffer before receiving more */
- drain_overflow_buffer(stream);
-
+ /* if there's data in the overflow buffer from a previous call, copy as much
+ as possible to the receive buffer before receiving more */
+ drain_overflow_buffer(stream);
+
if(ng_process_ingress(conn, sockfd, qs)) {
*curlcode = CURLE_RECV_ERROR;
return -1;
@@ -1274,13 +1274,13 @@ static ssize_t ngh3_stream_recv(struct connectdata *conn,
stream->memlen = 0;
stream->mem = buf;
stream->len = buffersize;
- /* extend the stream window with the data we're consuming and send out
- any additional packets to tell the server that we can receive more */
- extend_stream_window(qs->qconn, stream);
- if(ng_flush_egress(conn, sockfd, qs)) {
- *curlcode = CURLE_SEND_ERROR;
- return -1;
- }
+ /* extend the stream window with the data we're consuming and send out
+ any additional packets to tell the server that we can receive more */
+ extend_stream_window(qs->qconn, stream);
+ if(ng_flush_egress(conn, sockfd, qs)) {
+ *curlcode = CURLE_SEND_ERROR;
+ return -1;
+ }
return memlen;
}
@@ -1300,39 +1300,39 @@ static int cb_h3_acked_stream_data(nghttp3_conn *conn, int64_t stream_id,
void *stream_user_data)
{
struct Curl_easy *data = stream_user_data;
- struct HTTP *stream = data->req.p.http;
+ struct HTTP *stream = data->req.p.http;
(void)conn;
(void)stream_id;
(void)user_data;
if(!data->set.postfields) {
stream->h3out->used -= datalen;
- H3BUGF(infof(data,
- "cb_h3_acked_stream_data, %zd bytes, %zd left unacked\n",
- datalen, stream->h3out->used));
+ H3BUGF(infof(data,
+ "cb_h3_acked_stream_data, %zd bytes, %zd left unacked\n",
+ datalen, stream->h3out->used));
DEBUGASSERT(stream->h3out->used < H3_SEND_SIZE);
}
return 0;
}
-static ssize_t cb_h3_readfunction(nghttp3_conn *conn, int64_t stream_id,
- nghttp3_vec *vec, size_t veccnt,
- uint32_t *pflags, void *user_data,
- void *stream_user_data)
+static ssize_t cb_h3_readfunction(nghttp3_conn *conn, int64_t stream_id,
+ nghttp3_vec *vec, size_t veccnt,
+ uint32_t *pflags, void *user_data,
+ void *stream_user_data)
{
struct Curl_easy *data = stream_user_data;
size_t nread;
- struct HTTP *stream = data->req.p.http;
+ struct HTTP *stream = data->req.p.http;
(void)conn;
(void)stream_id;
(void)user_data;
- (void)veccnt;
+ (void)veccnt;
if(data->set.postfields) {
- vec[0].base = data->set.postfields;
- vec[0].len = data->state.infilesize;
+ vec[0].base = data->set.postfields;
+ vec[0].len = data->state.infilesize;
*pflags = NGHTTP3_DATA_FLAG_EOF;
- return 1;
+ return 1;
}
nread = CURLMIN(stream->upload_len, H3_SEND_SIZE - stream->h3out->used);
@@ -1350,8 +1350,8 @@ static ssize_t cb_h3_readfunction(nghttp3_conn *conn, int64_t stream_id,
out->used += nread;
/* that's the chunk we return to nghttp3 */
- vec[0].base = &out->buf[out->windex];
- vec[0].len = nread;
+ vec[0].base = &out->buf[out->windex];
+ vec[0].len = nread;
if(out->windex == H3_SEND_SIZE)
out->windex = 0; /* wrap */
@@ -1362,20 +1362,20 @@ static ssize_t cb_h3_readfunction(nghttp3_conn *conn, int64_t stream_id,
if(!stream->upload_left)
*pflags = NGHTTP3_DATA_FLAG_EOF;
}
- H3BUGF(infof(data, "cb_h3_readfunction %zd bytes%s (at %zd unacked)\n",
- nread, *pflags == NGHTTP3_DATA_FLAG_EOF?" EOF":"",
- out->used));
+ H3BUGF(infof(data, "cb_h3_readfunction %zd bytes%s (at %zd unacked)\n",
+ nread, *pflags == NGHTTP3_DATA_FLAG_EOF?" EOF":"",
+ out->used));
}
if(stream->upload_done && !stream->upload_len &&
(stream->upload_left <= 0)) {
H3BUGF(infof(data, "!!!!!!!!! cb_h3_readfunction sets EOF\n"));
*pflags = NGHTTP3_DATA_FLAG_EOF;
- return 0;
+ return 0;
}
else if(!nread) {
return NGHTTP3_ERR_WOULDBLOCK;
}
- return 1;
+ return 1;
}
/* Index where :authority header field will appear in request header
@@ -1385,7 +1385,7 @@ static ssize_t cb_h3_readfunction(nghttp3_conn *conn, int64_t stream_id,
static CURLcode http_request(struct connectdata *conn, const void *mem,
size_t len)
{
- struct HTTP *stream = conn->data->req.p.http;
+ struct HTTP *stream = conn->data->req.p.http;
size_t nheader;
size_t i;
size_t authority_idx;
@@ -1408,7 +1408,7 @@ static CURLcode http_request(struct connectdata *conn, const void *mem,
stream->stream3_id = stream3_id;
stream->h3req = TRUE; /* senf off! */
- Curl_dyn_init(&stream->overflow, CURL_MAX_READ_SIZE);
+ Curl_dyn_init(&stream->overflow, CURL_MAX_READ_SIZE);
/* Calculate number of headers contained in [mem, mem + len). Assumes a
correctly generated HTTP header field block. */
@@ -1507,9 +1507,9 @@ static CURLcode http_request(struct connectdata *conn, const void *mem,
nva[i].namelen = strlen((char *)nva[i].name);
}
else {
- nva[i].namelen = (size_t)(end - hdbuf);
- /* Lower case the header name for HTTP/3 */
- Curl_strntolower((char *)hdbuf, hdbuf, nva[i].namelen);
+ nva[i].namelen = (size_t)(end - hdbuf);
+ /* Lower case the header name for HTTP/3 */
+ Curl_strntolower((char *)hdbuf, hdbuf, nva[i].namelen);
nva[i].name = (unsigned char *)hdbuf;
}
nva[i].flags = NGHTTP3_NV_FLAG_NONE;
@@ -1560,12 +1560,12 @@ static CURLcode http_request(struct connectdata *conn, const void *mem,
if(acc > MAX_ACC) {
infof(data, "http_request: Warning: The cumulative length of all "
- "headers exceeds %d bytes and that could cause the "
+ "headers exceeds %d bytes and that could cause the "
"stream to be rejected.\n", MAX_ACC);
}
}
- switch(data->state.httpreq) {
+ switch(data->state.httpreq) {
case HTTPREQ_POST:
case HTTPREQ_POST_FORM:
case HTTPREQ_POST_MIME:
@@ -1628,7 +1628,7 @@ static ssize_t ngh3_stream_send(struct connectdata *conn,
ssize_t sent;
struct quicsocket *qs = conn->quic;
curl_socket_t sockfd = conn->sock[sockindex];
- struct HTTP *stream = conn->data->req.p.http;
+ struct HTTP *stream = conn->data->req.p.http;
if(!stream->h3req) {
CURLcode result = http_request(conn, mem, len);
@@ -1639,8 +1639,8 @@ static ssize_t ngh3_stream_send(struct connectdata *conn,
sent = len;
}
else {
- H3BUGF(infof(conn->data, "ngh3_stream_send() wants to send %zd bytes\n",
- len));
+ H3BUGF(infof(conn->data, "ngh3_stream_send() wants to send %zd bytes\n",
+ len));
if(!stream->upload_len) {
stream->upload_mem = mem;
stream->upload_len = len;
@@ -1687,11 +1687,11 @@ CURLcode Curl_quic_is_connected(struct connectdata *conn,
result = ng_process_ingress(conn, sockfd, qs);
if(result)
- goto error;
+ goto error;
result = ng_flush_egress(conn, sockfd, qs);
if(result)
- goto error;
+ goto error;
if(ngtcp2_conn_get_handshake_completed(qs->qconn)) {
*done = TRUE;
@@ -1699,14 +1699,14 @@ CURLcode Curl_quic_is_connected(struct connectdata *conn,
}
return result;
- error:
- (void)qs_disconnect(qs);
- return result;
-
+ error:
+ (void)qs_disconnect(qs);
+ return result;
+
}
-static CURLcode ng_process_ingress(struct connectdata *conn,
- curl_socket_t sockfd,
+static CURLcode ng_process_ingress(struct connectdata *conn,
+ curl_socket_t sockfd,
struct quicsocket *qs)
{
ssize_t recvd;
@@ -1717,29 +1717,29 @@ static CURLcode ng_process_ingress(struct connectdata *conn,
socklen_t remote_addrlen;
ngtcp2_path path;
ngtcp2_tstamp ts = timestamp();
- ngtcp2_pkt_info pi = { 0 };
+ ngtcp2_pkt_info pi = { 0 };
for(;;) {
remote_addrlen = sizeof(remote_addr);
- while((recvd = recvfrom(sockfd, (char *)buf, bufsize, 0,
+ while((recvd = recvfrom(sockfd, (char *)buf, bufsize, 0,
(struct sockaddr *)&remote_addr,
&remote_addrlen)) == -1 &&
- SOCKERRNO == EINTR)
+ SOCKERRNO == EINTR)
;
if(recvd == -1) {
- if(SOCKERRNO == EAGAIN || SOCKERRNO == EWOULDBLOCK)
+ if(SOCKERRNO == EAGAIN || SOCKERRNO == EWOULDBLOCK)
break;
- failf(conn->data, "ngtcp2: recvfrom() unexpectedly returned %zd", recvd);
+ failf(conn->data, "ngtcp2: recvfrom() unexpectedly returned %zd", recvd);
return CURLE_RECV_ERROR;
}
- ngtcp2_addr_init(&path.local, (struct sockaddr *)&qs->local_addr,
+ ngtcp2_addr_init(&path.local, (struct sockaddr *)&qs->local_addr,
qs->local_addrlen, NULL);
- ngtcp2_addr_init(&path.remote, (struct sockaddr *)&remote_addr,
- remote_addrlen, NULL);
+ ngtcp2_addr_init(&path.remote, (struct sockaddr *)&remote_addr,
+ remote_addrlen, NULL);
- rv = ngtcp2_conn_read_pkt(qs->qconn, &path, &pi, buf, recvd, ts);
+ rv = ngtcp2_conn_read_pkt(qs->qconn, &path, &pi, buf, recvd, ts);
if(rv != 0) {
/* TODO Send CONNECTION_CLOSE if possible */
return CURLE_RECV_ERROR;
@@ -1772,11 +1772,11 @@ static CURLcode ng_flush_egress(struct connectdata *conn, int sockfd,
case AF_INET:
pktlen = NGTCP2_MAX_PKTLEN_IPV4;
break;
-#ifdef ENABLE_IPV6
+#ifdef ENABLE_IPV6
case AF_INET6:
pktlen = NGTCP2_MAX_PKTLEN_IPV6;
break;
-#endif
+#endif
default:
assert(0);
}
@@ -1801,12 +1801,12 @@ static CURLcode ng_flush_egress(struct connectdata *conn, int sockfd,
return CURLE_SEND_ERROR;
}
else if(veccnt > 0) {
- uint32_t flags = NGTCP2_WRITE_STREAM_FLAG_MORE |
- (fin ? NGTCP2_WRITE_STREAM_FLAG_FIN : 0);
+ uint32_t flags = NGTCP2_WRITE_STREAM_FLAG_MORE |
+ (fin ? NGTCP2_WRITE_STREAM_FLAG_FIN : 0);
outlen =
- ngtcp2_conn_writev_stream(qs->qconn, &ps.path, NULL,
+ ngtcp2_conn_writev_stream(qs->qconn, &ps.path, NULL,
out, pktlen, &ndatalen,
- flags, stream_id,
+ flags, stream_id,
(const ngtcp2_vec *)vec, veccnt, ts);
if(outlen == 0) {
break;
@@ -1814,7 +1814,7 @@ static CURLcode ng_flush_egress(struct connectdata *conn, int sockfd,
if(outlen < 0) {
if(outlen == NGTCP2_ERR_STREAM_DATA_BLOCKED ||
outlen == NGTCP2_ERR_STREAM_SHUT_WR) {
- assert(ndatalen == -1);
+ assert(ndatalen == -1);
rv = nghttp3_conn_block_stream(qs->h3conn, stream_id);
if(rv != 0) {
failf(conn->data,
@@ -1824,7 +1824,7 @@ static CURLcode ng_flush_egress(struct connectdata *conn, int sockfd,
}
continue;
}
- else if(outlen == NGTCP2_ERR_WRITE_MORE) {
+ else if(outlen == NGTCP2_ERR_WRITE_MORE) {
assert(ndatalen > 0);
rv = nghttp3_conn_add_write_offset(qs->h3conn, stream_id,
ndatalen);
@@ -1837,20 +1837,20 @@ static CURLcode ng_flush_egress(struct connectdata *conn, int sockfd,
continue;
}
else {
- assert(ndatalen == -1);
+ assert(ndatalen == -1);
failf(conn->data, "ngtcp2_conn_writev_stream returned error: %s\n",
ngtcp2_strerror((int)outlen));
return CURLE_SEND_ERROR;
}
}
- else {
- assert(ndatalen == -1);
+ else {
+ assert(ndatalen == -1);
}
}
}
if(outlen < 0) {
- outlen = ngtcp2_conn_write_pkt(qs->qconn, &ps.path, NULL,
- out, pktlen, ts);
+ outlen = ngtcp2_conn_write_pkt(qs->qconn, &ps.path, NULL,
+ out, pktlen, ts);
if(outlen < 0) {
failf(conn->data, "ngtcp2_conn_write_pkt returned error: %s\n",
ngtcp2_strerror((int)outlen));
@@ -1861,17 +1861,17 @@ static CURLcode ng_flush_egress(struct connectdata *conn, int sockfd,
}
memcpy(&remote_addr, ps.path.remote.addr, ps.path.remote.addrlen);
- while((sent = send(sockfd, (const char *)out, outlen, 0)) == -1 &&
- SOCKERRNO == EINTR)
+ while((sent = send(sockfd, (const char *)out, outlen, 0)) == -1 &&
+ SOCKERRNO == EINTR)
;
if(sent == -1) {
- if(SOCKERRNO == EAGAIN || SOCKERRNO == EWOULDBLOCK) {
+ if(SOCKERRNO == EAGAIN || SOCKERRNO == EWOULDBLOCK) {
/* TODO Cache packet */
break;
}
else {
- failf(conn->data, "send() returned %zd (errno %d)\n", sent,
+ failf(conn->data, "send() returned %zd (errno %d)\n", sent,
SOCKERRNO);
return CURLE_SEND_ERROR;
}
@@ -1899,7 +1899,7 @@ CURLcode Curl_quic_done_sending(struct connectdata *conn)
{
if(conn->handler == &Curl_handler_http3) {
/* only for HTTP/3 transfers */
- struct HTTP *stream = conn->data->req.p.http;
+ struct HTTP *stream = conn->data->req.p.http;
struct quicsocket *qs = conn->quic;
stream->upload_done = TRUE;
(void)nghttp3_conn_resume_stream(qs->h3conn, stream->stream3_id);
@@ -1907,32 +1907,32 @@ CURLcode Curl_quic_done_sending(struct connectdata *conn)
return CURLE_OK;
}
-
-/*
- * Called from http.c:Curl_http_done when a request completes.
- */
-void Curl_quic_done(struct Curl_easy *data, bool premature)
-{
- (void)premature;
- if(data->conn->handler == &Curl_handler_http3) {
- /* only for HTTP/3 transfers */
- struct HTTP *stream = data->req.p.http;
- Curl_dyn_free(&stream->overflow);
- }
-}
-
-/*
- * Called from transfer.c:data_pending to know if we should keep looping
- * to receive more data from the connection.
- */
-bool Curl_quic_data_pending(const struct Curl_easy *data)
-{
- /* We may have received more data than we're able to hold in the receive
- buffer and allocated an overflow buffer. Since it's possible that
- there's no more data coming on the socket, we need to keep reading
- until the overflow buffer is empty. */
- const struct HTTP *stream = data->req.p.http;
- return Curl_dyn_len(&stream->overflow) > 0;
-}
-
+
+/*
+ * Called from http.c:Curl_http_done when a request completes.
+ */
+void Curl_quic_done(struct Curl_easy *data, bool premature)
+{
+ (void)premature;
+ if(data->conn->handler == &Curl_handler_http3) {
+ /* only for HTTP/3 transfers */
+ struct HTTP *stream = data->req.p.http;
+ Curl_dyn_free(&stream->overflow);
+ }
+}
+
+/*
+ * Called from transfer.c:data_pending to know if we should keep looping
+ * to receive more data from the connection.
+ */
+bool Curl_quic_data_pending(const struct Curl_easy *data)
+{
+ /* We may have received more data than we're able to hold in the receive
+ buffer and allocated an overflow buffer. Since it's possible that
+ there's no more data coming on the socket, we need to keep reading
+ until the overflow buffer is empty. */
+ const struct HTTP *stream = data->req.p.http;
+ return Curl_dyn_len(&stream->overflow) > 0;
+}
+
#endif
diff --git a/contrib/libs/curl/lib/vquic/quiche.c b/contrib/libs/curl/lib/vquic/quiche.c
index 6b3eaf470e..c50cccd4b3 100644
--- a/contrib/libs/curl/lib/vquic/quiche.c
+++ b/contrib/libs/curl/lib/vquic/quiche.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -34,7 +34,7 @@
#include "multiif.h"
#include "connect.h"
#include "strerror.h"
-#error #include "vquic.h"
+#error #include "vquic.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
@@ -46,12 +46,12 @@
#ifdef DEBUG_HTTP3
#define H3BUGF(x) x
#else
-#define H3BUGF(x) do { } while(0)
+#define H3BUGF(x) do { } while(0)
#endif
#define QUIC_MAX_STREAMS (256*1024)
#define QUIC_MAX_DATA (1*1024*1024)
-#define QUIC_IDLE_TIMEOUT (60 * 1000) /* milliseconds */
+#define QUIC_IDLE_TIMEOUT (60 * 1000) /* milliseconds */
static CURLcode process_ingress(struct connectdata *conn,
curl_socket_t sockfd,
@@ -89,43 +89,43 @@ static int quiche_perform_getsock(const struct connectdata *conn,
return quiche_getsock((struct connectdata *)conn, socks);
}
-static CURLcode qs_disconnect(struct connectdata *conn,
- struct quicsocket *qs)
-{
- if(qs->conn) {
- (void)quiche_conn_close(qs->conn, TRUE, 0, NULL, 0);
- /* flushing the egress is not a failsafe way to deliver all the
- outstanding packets, but we also don't want to get stuck here... */
- (void)flush_egress(conn, qs->sockfd, qs);
- quiche_conn_free(qs->conn);
- qs->conn = NULL;
- }
- if(qs->h3config)
- quiche_h3_config_free(qs->h3config);
- if(qs->h3c)
- quiche_h3_conn_free(qs->h3c);
- if(qs->cfg) {
- quiche_config_free(qs->cfg);
- qs->cfg = NULL;
- }
- return CURLE_OK;
-}
-
+static CURLcode qs_disconnect(struct connectdata *conn,
+ struct quicsocket *qs)
+{
+ if(qs->conn) {
+ (void)quiche_conn_close(qs->conn, TRUE, 0, NULL, 0);
+ /* flushing the egress is not a failsafe way to deliver all the
+ outstanding packets, but we also don't want to get stuck here... */
+ (void)flush_egress(conn, qs->sockfd, qs);
+ quiche_conn_free(qs->conn);
+ qs->conn = NULL;
+ }
+ if(qs->h3config)
+ quiche_h3_config_free(qs->h3config);
+ if(qs->h3c)
+ quiche_h3_conn_free(qs->h3c);
+ if(qs->cfg) {
+ quiche_config_free(qs->cfg);
+ qs->cfg = NULL;
+ }
+ return CURLE_OK;
+}
+
static CURLcode quiche_disconnect(struct connectdata *conn,
bool dead_connection)
{
struct quicsocket *qs = conn->quic;
(void)dead_connection;
- return qs_disconnect(conn, qs);
+ return qs_disconnect(conn, qs);
+}
+
+void Curl_quic_disconnect(struct connectdata *conn,
+ int tempindex)
+{
+ if(conn->transport == TRNSPRT_QUIC)
+ qs_disconnect(conn, &conn->hequic[tempindex]);
}
-void Curl_quic_disconnect(struct connectdata *conn,
- int tempindex)
-{
- if(conn->transport == TRNSPRT_QUIC)
- qs_disconnect(conn, &conn->hequic[tempindex]);
-}
-
static unsigned int quiche_conncheck(struct connectdata *conn,
unsigned int checks_to_perform)
{
@@ -136,7 +136,7 @@ static unsigned int quiche_conncheck(struct connectdata *conn,
static CURLcode quiche_do(struct connectdata *conn, bool *done)
{
- struct HTTP *stream = conn->data->req.p.http;
+ struct HTTP *stream = conn->data->req.p.http;
stream->h3req = FALSE; /* not sent */
return Curl_http(conn, done);
}
@@ -159,7 +159,7 @@ static const struct Curl_handler Curl_handler_http3 = {
quiche_conncheck, /* connection_check */
PORT_HTTP, /* defport */
CURLPROTO_HTTPS, /* protocol */
- CURLPROTO_HTTP, /* family */
+ CURLPROTO_HTTP, /* family */
PROTOPT_SSL | PROTOPT_STREAM /* flags */
};
@@ -178,7 +178,7 @@ CURLcode Curl_quic_connect(struct connectdata *conn, curl_socket_t sockfd,
CURLcode result;
struct quicsocket *qs = &conn->hequic[sockindex];
struct Curl_easy *data = conn->data;
- char *keylog_file = NULL;
+ char *keylog_file = NULL;
#ifdef DEBUG_QUICHE
/* initialize debug log callback only once */
@@ -192,14 +192,14 @@ CURLcode Curl_quic_connect(struct connectdata *conn, curl_socket_t sockfd,
(void)addr;
(void)addrlen;
- qs->sockfd = sockfd;
+ qs->sockfd = sockfd;
qs->cfg = quiche_config_new(QUICHE_PROTOCOL_VERSION);
if(!qs->cfg) {
failf(data, "can't create quiche config");
return CURLE_FAILED_INIT;
}
- quiche_config_set_max_idle_timeout(qs->cfg, QUIC_IDLE_TIMEOUT);
+ quiche_config_set_max_idle_timeout(qs->cfg, QUIC_IDLE_TIMEOUT);
quiche_config_set_initial_max_data(qs->cfg, QUIC_MAX_DATA);
quiche_config_set_initial_max_stream_data_bidi_local(qs->cfg, QUIC_MAX_DATA);
quiche_config_set_initial_max_stream_data_bidi_remote(qs->cfg,
@@ -217,9 +217,9 @@ CURLcode Curl_quic_connect(struct connectdata *conn, curl_socket_t sockfd,
if(result)
return result;
- keylog_file = getenv("SSLKEYLOGFILE");
-
- if(keylog_file)
+ keylog_file = getenv("SSLKEYLOGFILE");
+
+ if(keylog_file)
quiche_config_log_keys(qs->cfg);
qs->conn = quiche_connect(conn->host.name, (const uint8_t *) qs->scid,
@@ -229,53 +229,53 @@ CURLcode Curl_quic_connect(struct connectdata *conn, curl_socket_t sockfd,
return CURLE_OUT_OF_MEMORY;
}
- if(keylog_file)
- quiche_conn_set_keylog_path(qs->conn, keylog_file);
-
- /* Known to not work on Windows */
-#if !defined(WIN32) && defined(HAVE_QUICHE_CONN_SET_QLOG_FD)
- {
- int qfd;
- (void)Curl_qlogdir(data, qs->scid, sizeof(qs->scid), &qfd);
- if(qfd != -1)
- quiche_conn_set_qlog_fd(qs->conn, qfd,
- "qlog title", "curl qlog");
- }
-#endif
-
+ if(keylog_file)
+ quiche_conn_set_keylog_path(qs->conn, keylog_file);
+
+ /* Known to not work on Windows */
+#if !defined(WIN32) && defined(HAVE_QUICHE_CONN_SET_QLOG_FD)
+ {
+ int qfd;
+ (void)Curl_qlogdir(data, qs->scid, sizeof(qs->scid), &qfd);
+ if(qfd != -1)
+ quiche_conn_set_qlog_fd(qs->conn, qfd,
+ "qlog title", "curl qlog");
+ }
+#endif
+
result = flush_egress(conn, sockfd, qs);
if(result)
return result;
/* store the used address as a string */
- if(!Curl_addr2string((struct sockaddr*)addr, addrlen,
+ if(!Curl_addr2string((struct sockaddr*)addr, addrlen,
conn->primary_ip, &conn->primary_port)) {
char buffer[STRERROR_LEN];
failf(data, "ssrem inet_ntop() failed with errno %d: %s",
- SOCKERRNO, Curl_strerror(SOCKERRNO, buffer, sizeof(buffer)));
+ SOCKERRNO, Curl_strerror(SOCKERRNO, buffer, sizeof(buffer)));
return CURLE_BAD_FUNCTION_ARGUMENT;
}
memcpy(conn->ip_addr_str, conn->primary_ip, MAX_IPADR_LEN);
- Curl_persistconninfo(conn);
-
+ Curl_persistconninfo(conn);
+
/* for connection reuse purposes: */
conn->ssl[FIRSTSOCKET].state = ssl_connection_complete;
- {
- unsigned char alpn_protocols[] = QUICHE_H3_APPLICATION_PROTOCOL;
- unsigned alpn_len, offset = 0;
-
- /* Replace each ALPN length prefix by a comma. */
- while(offset < sizeof(alpn_protocols) - 1) {
- alpn_len = alpn_protocols[offset];
- alpn_protocols[offset] = ',';
- offset += 1 + alpn_len;
- }
-
- infof(data, "Sent QUIC client Initial, ALPN: %s\n",
- alpn_protocols + 1);
- }
-
+ {
+ unsigned char alpn_protocols[] = QUICHE_H3_APPLICATION_PROTOCOL;
+ unsigned alpn_len, offset = 0;
+
+ /* Replace each ALPN length prefix by a comma. */
+ while(offset < sizeof(alpn_protocols) - 1) {
+ alpn_len = alpn_protocols[offset];
+ alpn_protocols[offset] = ',';
+ offset += 1 + alpn_len;
+ }
+
+ infof(data, "Sent QUIC client Initial, ALPN: %s\n",
+ alpn_protocols + 1);
+ }
+
return CURLE_OK;
}
@@ -293,7 +293,7 @@ static CURLcode quiche_has_connected(struct connectdata *conn,
conn->httpversion = 30;
conn->bundle->multiuse = BUNDLE_MULTIPLEX;
- qs->h3config = quiche_h3_config_new();
+ qs->h3config = quiche_h3_config_new();
if(!qs->h3config)
return CURLE_OUT_OF_MEMORY;
@@ -329,11 +329,11 @@ CURLcode Curl_quic_is_connected(struct connectdata *conn, int sockindex,
result = process_ingress(conn, sockfd, qs);
if(result)
- goto error;
+ goto error;
result = flush_egress(conn, sockfd, qs);
if(result)
- goto error;
+ goto error;
if(quiche_conn_is_established(qs->conn)) {
*done = TRUE;
@@ -342,9 +342,9 @@ CURLcode Curl_quic_is_connected(struct connectdata *conn, int sockindex,
}
return result;
- error:
- qs_disconnect(conn, qs);
- return result;
+ error:
+ qs_disconnect(conn, qs);
+ return result;
}
static CURLcode process_ingress(struct connectdata *conn, int sockfd,
@@ -360,11 +360,11 @@ static CURLcode process_ingress(struct connectdata *conn, int sockfd,
do {
recvd = recv(sockfd, buf, bufsize, 0);
- if((recvd < 0) && ((SOCKERRNO == EAGAIN) || (SOCKERRNO == EWOULDBLOCK)))
+ if((recvd < 0) && ((SOCKERRNO == EAGAIN) || (SOCKERRNO == EWOULDBLOCK)))
break;
if(recvd < 0) {
- failf(conn->data, "quiche: recv() unexpectedly returned %zd "
+ failf(conn->data, "quiche: recv() unexpectedly returned %zd "
"(errno: %d, socket %d)", recvd, SOCKERRNO, sockfd);
return CURLE_RECV_ERROR;
}
@@ -374,7 +374,7 @@ static CURLcode process_ingress(struct connectdata *conn, int sockfd,
break;
if(recvd < 0) {
- failf(conn->data, "quiche_conn_recv() == %zd", recvd);
+ failf(conn->data, "quiche_conn_recv() == %zd", recvd);
return CURLE_RECV_ERROR;
}
} while(1);
@@ -390,7 +390,7 @@ static CURLcode flush_egress(struct connectdata *conn, int sockfd,
struct quicsocket *qs)
{
ssize_t sent;
- uint8_t out[1200];
+ uint8_t out[1200];
int64_t timeout_ns;
do {
@@ -438,9 +438,9 @@ static int cb_each_header(uint8_t *name, size_t name_len,
headers->destlen, "HTTP/3 %.*s\n",
(int) value_len, value);
}
- else if(!headers->nlen) {
- return CURLE_HTTP3;
- }
+ else if(!headers->nlen) {
+ return CURLE_HTTP3;
+ }
else {
msnprintf(headers->dest,
headers->destlen, "%.*s: %.*s\n",
@@ -466,14 +466,14 @@ static ssize_t h3_stream_recv(struct connectdata *conn,
quiche_h3_event *ev;
int rc;
struct h3h1header headers;
- struct Curl_easy *data = conn->data;
- struct HTTP *stream = data->req.p.http;
+ struct Curl_easy *data = conn->data;
+ struct HTTP *stream = data->req.p.http;
headers.dest = buf;
headers.destlen = buffersize;
headers.nlen = 0;
if(process_ingress(conn, sockfd, qs)) {
- infof(data, "h3_stream_recv returns on ingress\n");
+ infof(data, "h3_stream_recv returns on ingress\n");
*curlcode = CURLE_RECV_ERROR;
return -1;
}
@@ -486,7 +486,7 @@ static ssize_t h3_stream_recv(struct connectdata *conn,
if(s != stream->stream3_id) {
/* another transfer, ignore for now */
- infof(data, "Got h3 for stream %u, expects %u\n",
+ infof(data, "Got h3 for stream %u, expects %u\n",
s, stream->stream3_id);
continue;
}
@@ -495,9 +495,9 @@ static ssize_t h3_stream_recv(struct connectdata *conn,
case QUICHE_H3_EVENT_HEADERS:
rc = quiche_h3_event_for_each_header(ev, cb_each_header, &headers);
if(rc) {
- *curlcode = rc;
- failf(data, "Error in HTTP/3 response header");
- break;
+ *curlcode = rc;
+ failf(data, "Error in HTTP/3 response header");
+ break;
}
recvd = headers.nlen;
break;
@@ -523,7 +523,7 @@ static ssize_t h3_stream_recv(struct connectdata *conn,
break;
case QUICHE_H3_EVENT_FINISHED:
- streamclose(conn, "End of stream");
+ streamclose(conn, "End of stream");
recvd = 0; /* end of stream */
break;
default:
@@ -540,9 +540,9 @@ static ssize_t h3_stream_recv(struct connectdata *conn,
*curlcode = (-1 == recvd)? CURLE_AGAIN : CURLE_OK;
if(recvd >= 0)
/* Get this called again to drain the event queue */
- Curl_expire(data, 0, EXPIRE_QUIC);
-
- data->state.drain = (recvd >= 0) ? 1 : 0;
+ Curl_expire(data, 0, EXPIRE_QUIC);
+
+ data->state.drain = (recvd >= 0) ? 1 : 0;
return recvd;
}
@@ -555,7 +555,7 @@ static ssize_t h3_stream_send(struct connectdata *conn,
ssize_t sent;
struct quicsocket *qs = conn->quic;
curl_socket_t sockfd = conn->sock[sockindex];
- struct HTTP *stream = conn->data->req.p.http;
+ struct HTTP *stream = conn->data->req.p.http;
if(!stream->h3req) {
CURLcode result = http_request(conn, mem, len);
@@ -591,7 +591,7 @@ static ssize_t h3_stream_send(struct connectdata *conn,
*/
int Curl_quic_ver(char *p, size_t len)
{
- return msnprintf(p, len, "quiche/%s", quiche_version());
+ return msnprintf(p, len, "quiche/%s", quiche_version());
}
/* Index where :authority header field will appear in request header
@@ -603,7 +603,7 @@ static CURLcode http_request(struct connectdata *conn, const void *mem,
{
/*
*/
- struct HTTP *stream = conn->data->req.p.http;
+ struct HTTP *stream = conn->data->req.p.http;
size_t nheader;
size_t i;
size_t authority_idx;
@@ -711,9 +711,9 @@ static CURLcode http_request(struct connectdata *conn, const void *mem,
nva[i].name_len = strlen((char *)nva[i].name);
}
else {
- nva[i].name_len = (size_t)(end - hdbuf);
- /* Lower case the header name for HTTP/3 */
- Curl_strntolower((char *)hdbuf, hdbuf, nva[i].name_len);
+ nva[i].name_len = (size_t)(end - hdbuf);
+ /* Lower case the header name for HTTP/3 */
+ Curl_strntolower((char *)hdbuf, hdbuf, nva[i].name_len);
nva[i].name = (unsigned char *)hdbuf;
}
hdbuf = end + 1;
@@ -768,12 +768,12 @@ static CURLcode http_request(struct connectdata *conn, const void *mem,
if(acc > MAX_ACC) {
infof(data, "http_request: Warning: The cumulative length of all "
- "headers exceeds %d bytes and that could cause the "
+ "headers exceeds %d bytes and that could cause the "
"stream to be rejected.\n", MAX_ACC);
}
}
- switch(data->state.httpreq) {
+ switch(data->state.httpreq) {
case HTTPREQ_POST:
case HTTPREQ_POST_FORM:
case HTTPREQ_POST_MIME:
@@ -831,7 +831,7 @@ CURLcode Curl_quic_done_sending(struct connectdata *conn)
if(conn->handler == &Curl_handler_http3) {
/* only for HTTP/3 transfers */
ssize_t sent;
- struct HTTP *stream = conn->data->req.p.http;
+ struct HTTP *stream = conn->data->req.p.http;
struct quicsocket *qs = conn->quic;
fprintf(stderr, "!!! Curl_quic_done_sending\n");
stream->upload_done = TRUE;
@@ -844,23 +844,23 @@ CURLcode Curl_quic_done_sending(struct connectdata *conn)
return CURLE_OK;
}
-/*
- * Called from http.c:Curl_http_done when a request completes.
- */
-void Curl_quic_done(struct Curl_easy *data, bool premature)
-{
- (void)data;
- (void)premature;
-}
-
-/*
- * Called from transfer.c:data_pending to know if we should keep looping
- * to receive more data from the connection.
- */
-bool Curl_quic_data_pending(const struct Curl_easy *data)
-{
- (void)data;
- return FALSE;
-}
-
+/*
+ * Called from http.c:Curl_http_done when a request completes.
+ */
+void Curl_quic_done(struct Curl_easy *data, bool premature)
+{
+ (void)data;
+ (void)premature;
+}
+
+/*
+ * Called from transfer.c:data_pending to know if we should keep looping
+ * to receive more data from the connection.
+ */
+bool Curl_quic_data_pending(const struct Curl_easy *data)
+{
+ (void)data;
+ return FALSE;
+}
+
#endif
diff --git a/contrib/libs/curl/lib/vquic/vquic.c b/contrib/libs/curl/lib/vquic/vquic.c
index 6a435f68dc..e01e575834 100644
--- a/contrib/libs/curl/lib/vquic/vquic.c
+++ b/contrib/libs/curl/lib/vquic/vquic.c
@@ -1,85 +1,85 @@
-/***************************************************************************
- * _ _ ____ _
- * Project ___| | | | _ \| |
- * / __| | | | |_) | |
- * | (__| |_| | _ <| |___
- * \___|\___/|_| \_\_____|
- *
- * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
- *
- * You may opt to use, copy, modify, merge, publish, distribute and/or sell
- * copies of the Software, and permit persons to whom the Software is
- * furnished to do so, under the terms of the COPYING file.
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- ***************************************************************************/
-
-#include "curl_setup.h"
-
-#ifdef ENABLE_QUIC
-
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-#include "urldata.h"
-#include "dynbuf.h"
-#include "curl_printf.h"
-#error #include "vquic.h"
-
-#ifdef O_BINARY
-#define QLOGMODE O_WRONLY|O_CREAT|O_BINARY
-#else
-#define QLOGMODE O_WRONLY|O_CREAT
-#endif
-
-/*
- * If the QLOGDIR environment variable is set, open and return a file
- * descriptor to write the log to.
- *
- * This function returns error if something failed outside of failing to
- * create the file. Open file success is deemed by seeing if the returned fd
- * is != -1.
- */
-CURLcode Curl_qlogdir(struct Curl_easy *data,
- unsigned char *scid,
- size_t scidlen,
- int *qlogfdp)
-{
- const char *qlog_dir = getenv("QLOGDIR");
- *qlogfdp = -1;
- if(qlog_dir) {
- struct dynbuf fname;
- CURLcode result;
- unsigned int i;
- Curl_dyn_init(&fname, DYN_QLOG_NAME);
- result = Curl_dyn_add(&fname, qlog_dir);
- if(!result)
- result = Curl_dyn_add(&fname, "/");
- for(i = 0; (i < scidlen) && !result; i++) {
- char hex[3];
- msnprintf(hex, 3, "%02x", scid[i]);
- result = Curl_dyn_add(&fname, hex);
- }
- if(!result)
- result = Curl_dyn_add(&fname, ".qlog");
-
- if(!result) {
- int qlogfd = open(Curl_dyn_ptr(&fname), QLOGMODE,
- data->set.new_file_perms);
- if(qlogfd != -1)
- *qlogfdp = qlogfd;
- }
- Curl_dyn_free(&fname);
- if(result)
- return result;
- }
-
- return CURLE_OK;
-}
-#endif
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 1998 - 2020, 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
+ * are also available at https://curl.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+
+#include "curl_setup.h"
+
+#ifdef ENABLE_QUIC
+
+#ifdef HAVE_FCNTL_H
+#include <fcntl.h>
+#endif
+#include "urldata.h"
+#include "dynbuf.h"
+#include "curl_printf.h"
+#error #include "vquic.h"
+
+#ifdef O_BINARY
+#define QLOGMODE O_WRONLY|O_CREAT|O_BINARY
+#else
+#define QLOGMODE O_WRONLY|O_CREAT
+#endif
+
+/*
+ * If the QLOGDIR environment variable is set, open and return a file
+ * descriptor to write the log to.
+ *
+ * This function returns error if something failed outside of failing to
+ * create the file. Open file success is deemed by seeing if the returned fd
+ * is != -1.
+ */
+CURLcode Curl_qlogdir(struct Curl_easy *data,
+ unsigned char *scid,
+ size_t scidlen,
+ int *qlogfdp)
+{
+ const char *qlog_dir = getenv("QLOGDIR");
+ *qlogfdp = -1;
+ if(qlog_dir) {
+ struct dynbuf fname;
+ CURLcode result;
+ unsigned int i;
+ Curl_dyn_init(&fname, DYN_QLOG_NAME);
+ result = Curl_dyn_add(&fname, qlog_dir);
+ if(!result)
+ result = Curl_dyn_add(&fname, "/");
+ for(i = 0; (i < scidlen) && !result; i++) {
+ char hex[3];
+ msnprintf(hex, 3, "%02x", scid[i]);
+ result = Curl_dyn_add(&fname, hex);
+ }
+ if(!result)
+ result = Curl_dyn_add(&fname, ".qlog");
+
+ if(!result) {
+ int qlogfd = open(Curl_dyn_ptr(&fname), QLOGMODE,
+ data->set.new_file_perms);
+ if(qlogfd != -1)
+ *qlogfdp = qlogfd;
+ }
+ Curl_dyn_free(&fname);
+ if(result)
+ return result;
+ }
+
+ return CURLE_OK;
+}
+#endif
diff --git a/contrib/libs/curl/lib/vssh/libssh.c b/contrib/libs/curl/lib/vssh/libssh.c
index bb54204263..87d6187544 100644
--- a/contrib/libs/curl/lib/vssh/libssh.c
+++ b/contrib/libs/curl/lib/vssh/libssh.c
@@ -5,14 +5,14 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 2017 - 2020 Red Hat, Inc.
+ * Copyright (C) 2017 - 2020 Red Hat, Inc.
*
* Authors: Nikos Mavrogiannopoulos, Tomas Mraz, Stanislav Zidek,
* Robert Kolcun, Andreas Schneider
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -97,13 +97,13 @@
/* A recent macro provided by libssh. Or make our own. */
#ifndef SSH_STRING_FREE_CHAR
-#define SSH_STRING_FREE_CHAR(x) \
- do { \
- if(x) { \
- ssh_string_free_char(x); \
- x = NULL; \
- } \
- } while(0)
+#define SSH_STRING_FREE_CHAR(x) \
+ do { \
+ if(x) { \
+ ssh_string_free_char(x); \
+ x = NULL; \
+ } \
+ } while(0)
#endif
/* Local functions: */
@@ -158,7 +158,7 @@ const struct Curl_handler Curl_handler_scp = {
ZERO_NULL, /* connection_check */
PORT_SSH, /* defport */
CURLPROTO_SCP, /* protocol */
- CURLPROTO_SCP, /* family */
+ CURLPROTO_SCP, /* family */
PROTOPT_DIRLOCK | PROTOPT_CLOSEACTION | PROTOPT_NOURLQUERY /* flags */
};
@@ -184,7 +184,7 @@ const struct Curl_handler Curl_handler_sftp = {
ZERO_NULL, /* connection_check */
PORT_SSH, /* defport */
CURLPROTO_SFTP, /* protocol */
- CURLPROTO_SFTP, /* family */
+ CURLPROTO_SFTP, /* family */
PROTOPT_DIRLOCK | PROTOPT_CLOSEACTION
| PROTOPT_NOURLQUERY /* flags */
};
@@ -324,50 +324,50 @@ static int myssh_is_known(struct connectdata *conn)
ssh_key pubkey;
size_t hlen;
unsigned char *hash = NULL;
- char *found_base64 = NULL;
- char *known_base64 = NULL;
+ char *found_base64 = NULL;
+ char *known_base64 = NULL;
int vstate;
enum curl_khmatch keymatch;
struct curl_khkey foundkey;
- struct curl_khkey *knownkeyp = NULL;
+ struct curl_khkey *knownkeyp = NULL;
curl_sshkeycallback func =
data->set.ssh_keyfunc;
-#if LIBSSH_VERSION_INT >= SSH_VERSION_INT(0,9,0)
- struct ssh_knownhosts_entry *knownhostsentry = NULL;
- struct curl_khkey knownkey;
-#endif
-
-#if LIBSSH_VERSION_INT >= SSH_VERSION_INT(0,8,0)
- rc = ssh_get_server_publickey(sshc->ssh_session, &pubkey);
-#else
+#if LIBSSH_VERSION_INT >= SSH_VERSION_INT(0,9,0)
+ struct ssh_knownhosts_entry *knownhostsentry = NULL;
+ struct curl_khkey knownkey;
+#endif
+
+#if LIBSSH_VERSION_INT >= SSH_VERSION_INT(0,8,0)
+ rc = ssh_get_server_publickey(sshc->ssh_session, &pubkey);
+#else
rc = ssh_get_publickey(sshc->ssh_session, &pubkey);
-#endif
+#endif
if(rc != SSH_OK)
return rc;
if(data->set.str[STRING_SSH_HOST_PUBLIC_KEY_MD5]) {
- int i;
- char md5buffer[33];
- const char *pubkey_md5 = data->set.str[STRING_SSH_HOST_PUBLIC_KEY_MD5];
-
+ int i;
+ char md5buffer[33];
+ const char *pubkey_md5 = data->set.str[STRING_SSH_HOST_PUBLIC_KEY_MD5];
+
rc = ssh_get_publickey_hash(pubkey, SSH_PUBLICKEY_HASH_MD5,
&hash, &hlen);
- if(rc != SSH_OK || hlen != 16) {
- failf(data,
- "Denied establishing ssh session: md5 fingerprint not available");
+ if(rc != SSH_OK || hlen != 16) {
+ failf(data,
+ "Denied establishing ssh session: md5 fingerprint not available");
goto cleanup;
- }
-
- for(i = 0; i < 16; i++)
- msnprintf(&md5buffer[i*2], 3, "%02x", (unsigned char)hash[i]);
-
- infof(data, "SSH MD5 fingerprint: %s\n", md5buffer);
-
- if(!strcasecompare(md5buffer, pubkey_md5)) {
- failf(data,
- "Denied establishing ssh session: mismatch md5 fingerprint. "
- "Remote %s is not equal to %s", md5buffer, pubkey_md5);
+ }
+
+ for(i = 0; i < 16; i++)
+ msnprintf(&md5buffer[i*2], 3, "%02x", (unsigned char)hash[i]);
+
+ infof(data, "SSH MD5 fingerprint: %s\n", md5buffer);
+
+ if(!strcasecompare(md5buffer, pubkey_md5)) {
+ failf(data,
+ "Denied establishing ssh session: mismatch md5 fingerprint. "
+ "Remote %s is not equal to %s", md5buffer, pubkey_md5);
rc = SSH_ERROR;
goto cleanup;
}
@@ -381,68 +381,68 @@ static int myssh_is_known(struct connectdata *conn)
goto cleanup;
}
-#if LIBSSH_VERSION_INT >= SSH_VERSION_INT(0,9,0)
- /* Get the known_key from the known hosts file */
- vstate = ssh_session_get_known_hosts_entry(sshc->ssh_session,
- &knownhostsentry);
-
- /* Case an entry was found in a known hosts file */
- if(knownhostsentry) {
- if(knownhostsentry->publickey) {
- rc = ssh_pki_export_pubkey_base64(knownhostsentry->publickey,
- &known_base64);
- if(rc != SSH_OK) {
- goto cleanup;
- }
- knownkey.key = known_base64;
- knownkey.len = strlen(known_base64);
-
- switch(ssh_key_type(knownhostsentry->publickey)) {
- case SSH_KEYTYPE_RSA:
- knownkey.keytype = CURLKHTYPE_RSA;
- break;
- case SSH_KEYTYPE_RSA1:
- knownkey.keytype = CURLKHTYPE_RSA1;
- break;
- case SSH_KEYTYPE_ECDSA:
- case SSH_KEYTYPE_ECDSA_P256:
- case SSH_KEYTYPE_ECDSA_P384:
- case SSH_KEYTYPE_ECDSA_P521:
- knownkey.keytype = CURLKHTYPE_ECDSA;
- break;
- case SSH_KEYTYPE_ED25519:
- knownkey.keytype = CURLKHTYPE_ED25519;
- break;
- case SSH_KEYTYPE_DSS:
- knownkey.keytype = CURLKHTYPE_DSS;
- break;
- default:
- rc = SSH_ERROR;
- goto cleanup;
- }
- knownkeyp = &knownkey;
- }
- }
-
- switch(vstate) {
- case SSH_KNOWN_HOSTS_OK:
- keymatch = CURLKHMATCH_OK;
- break;
- case SSH_KNOWN_HOSTS_OTHER:
- /* fallthrough */
- case SSH_KNOWN_HOSTS_NOT_FOUND:
- /* fallthrough */
- case SSH_KNOWN_HOSTS_UNKNOWN:
- /* fallthrough */
- case SSH_KNOWN_HOSTS_ERROR:
- keymatch = CURLKHMATCH_MISSING;
- break;
- default:
- keymatch = CURLKHMATCH_MISMATCH;
- break;
- }
-
-#else
+#if LIBSSH_VERSION_INT >= SSH_VERSION_INT(0,9,0)
+ /* Get the known_key from the known hosts file */
+ vstate = ssh_session_get_known_hosts_entry(sshc->ssh_session,
+ &knownhostsentry);
+
+ /* Case an entry was found in a known hosts file */
+ if(knownhostsentry) {
+ if(knownhostsentry->publickey) {
+ rc = ssh_pki_export_pubkey_base64(knownhostsentry->publickey,
+ &known_base64);
+ if(rc != SSH_OK) {
+ goto cleanup;
+ }
+ knownkey.key = known_base64;
+ knownkey.len = strlen(known_base64);
+
+ switch(ssh_key_type(knownhostsentry->publickey)) {
+ case SSH_KEYTYPE_RSA:
+ knownkey.keytype = CURLKHTYPE_RSA;
+ break;
+ case SSH_KEYTYPE_RSA1:
+ knownkey.keytype = CURLKHTYPE_RSA1;
+ break;
+ case SSH_KEYTYPE_ECDSA:
+ case SSH_KEYTYPE_ECDSA_P256:
+ case SSH_KEYTYPE_ECDSA_P384:
+ case SSH_KEYTYPE_ECDSA_P521:
+ knownkey.keytype = CURLKHTYPE_ECDSA;
+ break;
+ case SSH_KEYTYPE_ED25519:
+ knownkey.keytype = CURLKHTYPE_ED25519;
+ break;
+ case SSH_KEYTYPE_DSS:
+ knownkey.keytype = CURLKHTYPE_DSS;
+ break;
+ default:
+ rc = SSH_ERROR;
+ goto cleanup;
+ }
+ knownkeyp = &knownkey;
+ }
+ }
+
+ switch(vstate) {
+ case SSH_KNOWN_HOSTS_OK:
+ keymatch = CURLKHMATCH_OK;
+ break;
+ case SSH_KNOWN_HOSTS_OTHER:
+ /* fallthrough */
+ case SSH_KNOWN_HOSTS_NOT_FOUND:
+ /* fallthrough */
+ case SSH_KNOWN_HOSTS_UNKNOWN:
+ /* fallthrough */
+ case SSH_KNOWN_HOSTS_ERROR:
+ keymatch = CURLKHMATCH_MISSING;
+ break;
+ default:
+ keymatch = CURLKHMATCH_MISMATCH;
+ break;
+ }
+
+#else
vstate = ssh_is_server_known(sshc->ssh_session);
switch(vstate) {
case SSH_SERVER_KNOWN_OK:
@@ -457,15 +457,15 @@ static int myssh_is_known(struct connectdata *conn)
keymatch = CURLKHMATCH_MISMATCH;
break;
}
-#endif
+#endif
if(func) { /* use callback to determine action */
- rc = ssh_pki_export_pubkey_base64(pubkey, &found_base64);
+ rc = ssh_pki_export_pubkey_base64(pubkey, &found_base64);
if(rc != SSH_OK)
goto cleanup;
- foundkey.key = found_base64;
- foundkey.len = strlen(found_base64);
+ foundkey.key = found_base64;
+ foundkey.len = strlen(found_base64);
switch(ssh_key_type(pubkey)) {
case SSH_KEYTYPE_RSA:
@@ -475,11 +475,11 @@ static int myssh_is_known(struct connectdata *conn)
foundkey.keytype = CURLKHTYPE_RSA1;
break;
case SSH_KEYTYPE_ECDSA:
-#if LIBSSH_VERSION_INT >= SSH_VERSION_INT(0,9,0)
- case SSH_KEYTYPE_ECDSA_P256:
- case SSH_KEYTYPE_ECDSA_P384:
- case SSH_KEYTYPE_ECDSA_P521:
-#endif
+#if LIBSSH_VERSION_INT >= SSH_VERSION_INT(0,9,0)
+ case SSH_KEYTYPE_ECDSA_P256:
+ case SSH_KEYTYPE_ECDSA_P384:
+ case SSH_KEYTYPE_ECDSA_P521:
+#endif
foundkey.keytype = CURLKHTYPE_ECDSA;
break;
#if LIBSSH_VERSION_INT >= SSH_VERSION_INT(0,7,0)
@@ -496,18 +496,18 @@ static int myssh_is_known(struct connectdata *conn)
}
Curl_set_in_callback(data, true);
- rc = func(data, knownkeyp, /* from the knownhosts file */
- &foundkey, /* from the remote host */
+ rc = func(data, knownkeyp, /* from the knownhosts file */
+ &foundkey, /* from the remote host */
keymatch, data->set.ssh_keyfunc_userp);
Curl_set_in_callback(data, false);
switch(rc) {
case CURLKHSTAT_FINE_ADD_TO_FILE:
-#if LIBSSH_VERSION_INT >= SSH_VERSION_INT(0,8,0)
- rc = ssh_session_update_known_hosts(sshc->ssh_session);
-#else
+#if LIBSSH_VERSION_INT >= SSH_VERSION_INT(0,8,0)
+ rc = ssh_session_update_known_hosts(sshc->ssh_session);
+#else
rc = ssh_write_knownhost(sshc->ssh_session);
-#endif
+#endif
if(rc != SSH_OK) {
goto cleanup;
}
@@ -528,20 +528,20 @@ static int myssh_is_known(struct connectdata *conn)
rc = SSH_OK;
cleanup:
- if(found_base64) {
- free(found_base64);
- }
- if(known_base64) {
- free(known_base64);
- }
+ if(found_base64) {
+ free(found_base64);
+ }
+ if(known_base64) {
+ free(known_base64);
+ }
if(hash)
ssh_clean_pubkey_hash(&hash);
ssh_key_free(pubkey);
-#if LIBSSH_VERSION_INT >= SSH_VERSION_INT(0,9,0)
- if(knownhostsentry) {
- ssh_knownhosts_entry_free(knownhostsentry);
- }
-#endif
+#if LIBSSH_VERSION_INT >= SSH_VERSION_INT(0,9,0)
+ if(knownhostsentry) {
+ ssh_knownhosts_entry_free(knownhostsentry);
+ }
+#endif
return rc;
}
@@ -607,7 +607,7 @@ restart:
return SSH_ERROR;
nprompts = ssh_userauth_kbdint_getnprompts(sshc->ssh_session);
- if(nprompts != 1)
+ if(nprompts != 1)
return SSH_ERROR;
rc = ssh_userauth_kbdint_setanswer(sshc->ssh_session, 0, conn->passwd);
@@ -664,7 +664,7 @@ static CURLcode myssh_statemach_act(struct connectdata *conn, bool *block)
{
CURLcode result = CURLE_OK;
struct Curl_easy *data = conn->data;
- struct SSHPROTO *protop = data->req.p.ssh;
+ struct SSHPROTO *protop = data->req.p.ssh;
struct ssh_conn *sshc = &conn->proto.sshc;
curl_socket_t sock = conn->sock[FIRSTSOCKET];
int rc = SSH_NO_ERROR, err;
@@ -1432,8 +1432,8 @@ static CURLcode myssh_statemach_act(struct connectdata *conn, bool *block)
data->req.bytecount += sshc->readdir_len + 1;
/* output debug output if that is requested */
- Curl_debug(data, CURLINFO_DATA_OUT, (char *)sshc->readdir_filename,
- sshc->readdir_len);
+ Curl_debug(data, CURLINFO_DATA_OUT, (char *)sshc->readdir_filename,
+ sshc->readdir_len);
}
else {
sshc->readdir_currLen = strlen(sshc->readdir_longentry);
@@ -1467,7 +1467,7 @@ static CURLcode myssh_statemach_act(struct connectdata *conn, bool *block)
break;
}
}
- else if(sftp_dir_eof(sshc->sftp_dir)) {
+ else if(sftp_dir_eof(sshc->sftp_dir)) {
state(conn, SSH_SFTP_READDIR_DONE);
break;
}
@@ -1546,8 +1546,8 @@ static CURLcode myssh_statemach_act(struct connectdata *conn, bool *block)
if(!result) {
/* output debug output if that is requested */
- Curl_debug(data, CURLINFO_DATA_OUT, sshc->readdir_line,
- sshc->readdir_currLen);
+ Curl_debug(data, CURLINFO_DATA_OUT, sshc->readdir_line,
+ sshc->readdir_currLen);
data->req.bytecount += sshc->readdir_currLen;
}
Curl_safefree(sshc->readdir_line);
@@ -2106,7 +2106,7 @@ static CURLcode myssh_block_statemach(struct connectdata *conn,
}
}
- if(block) {
+ if(block) {
curl_socket_t fd_read = conn->sock[FIRSTSOCKET];
/* wait for the socket to become ready */
(void) Curl_socket_check(fd_read, CURL_SOCKET_BAD,
@@ -2125,7 +2125,7 @@ static CURLcode myssh_setup_connection(struct connectdata *conn)
{
struct SSHPROTO *ssh;
- conn->data->req.p.ssh = ssh = calloc(1, sizeof(struct SSHPROTO));
+ conn->data->req.p.ssh = ssh = calloc(1, sizeof(struct SSHPROTO));
if(!ssh)
return CURLE_OUT_OF_MEMORY;
@@ -2145,10 +2145,10 @@ static CURLcode myssh_connect(struct connectdata *conn, bool *done)
CURLcode result;
curl_socket_t sock = conn->sock[FIRSTSOCKET];
struct Curl_easy *data = conn->data;
- int rc;
+ int rc;
/* initialize per-handle data if not already */
- if(!data->req.p.ssh)
+ if(!data->req.p.ssh)
myssh_setup_connection(conn);
/* We default to persistent connections. We set this already in this connect
@@ -2172,70 +2172,70 @@ static CURLcode myssh_connect(struct connectdata *conn, bool *done)
return CURLE_FAILED_INIT;
}
- rc = ssh_options_set(ssh->ssh_session, SSH_OPTIONS_HOST, conn->host.name);
- if(rc != SSH_OK) {
- failf(data, "Could not set remote host");
- return CURLE_FAILED_INIT;
- }
-
- rc = ssh_options_parse_config(ssh->ssh_session, NULL);
- if(rc != SSH_OK) {
- infof(data, "Could not parse SSH configuration files");
- /* ignore */
- }
-
- rc = ssh_options_set(ssh->ssh_session, SSH_OPTIONS_FD, &sock);
- if(rc != SSH_OK) {
- failf(data, "Could not set socket");
- return CURLE_FAILED_INIT;
- }
-
- if(conn->user && conn->user[0] != '\0') {
+ rc = ssh_options_set(ssh->ssh_session, SSH_OPTIONS_HOST, conn->host.name);
+ if(rc != SSH_OK) {
+ failf(data, "Could not set remote host");
+ return CURLE_FAILED_INIT;
+ }
+
+ rc = ssh_options_parse_config(ssh->ssh_session, NULL);
+ if(rc != SSH_OK) {
+ infof(data, "Could not parse SSH configuration files");
+ /* ignore */
+ }
+
+ rc = ssh_options_set(ssh->ssh_session, SSH_OPTIONS_FD, &sock);
+ if(rc != SSH_OK) {
+ failf(data, "Could not set socket");
+ return CURLE_FAILED_INIT;
+ }
+
+ if(conn->user && conn->user[0] != '\0') {
infof(data, "User: %s\n", conn->user);
- rc = ssh_options_set(ssh->ssh_session, SSH_OPTIONS_USER, conn->user);
- if(rc != SSH_OK) {
- failf(data, "Could not set user");
- return CURLE_FAILED_INIT;
- }
+ rc = ssh_options_set(ssh->ssh_session, SSH_OPTIONS_USER, conn->user);
+ if(rc != SSH_OK) {
+ failf(data, "Could not set user");
+ return CURLE_FAILED_INIT;
+ }
}
if(data->set.str[STRING_SSH_KNOWNHOSTS]) {
infof(data, "Known hosts: %s\n", data->set.str[STRING_SSH_KNOWNHOSTS]);
- rc = ssh_options_set(ssh->ssh_session, SSH_OPTIONS_KNOWNHOSTS,
- data->set.str[STRING_SSH_KNOWNHOSTS]);
- if(rc != SSH_OK) {
- failf(data, "Could not set known hosts file path");
- return CURLE_FAILED_INIT;
- }
+ rc = ssh_options_set(ssh->ssh_session, SSH_OPTIONS_KNOWNHOSTS,
+ data->set.str[STRING_SSH_KNOWNHOSTS]);
+ if(rc != SSH_OK) {
+ failf(data, "Could not set known hosts file path");
+ return CURLE_FAILED_INIT;
+ }
}
- if(conn->remote_port) {
- rc = ssh_options_set(ssh->ssh_session, SSH_OPTIONS_PORT,
- &conn->remote_port);
- if(rc != SSH_OK) {
- failf(data, "Could not set remote port");
- return CURLE_FAILED_INIT;
- }
- }
+ if(conn->remote_port) {
+ rc = ssh_options_set(ssh->ssh_session, SSH_OPTIONS_PORT,
+ &conn->remote_port);
+ if(rc != SSH_OK) {
+ failf(data, "Could not set remote port");
+ return CURLE_FAILED_INIT;
+ }
+ }
if(data->set.ssh_compression) {
- rc = ssh_options_set(ssh->ssh_session, SSH_OPTIONS_COMPRESSION,
- "zlib,zlib@openssh.com,none");
- if(rc != SSH_OK) {
- failf(data, "Could not set compression");
- return CURLE_FAILED_INIT;
- }
+ rc = ssh_options_set(ssh->ssh_session, SSH_OPTIONS_COMPRESSION,
+ "zlib,zlib@openssh.com,none");
+ if(rc != SSH_OK) {
+ failf(data, "Could not set compression");
+ return CURLE_FAILED_INIT;
+ }
}
ssh->privkey = NULL;
ssh->pubkey = NULL;
if(data->set.str[STRING_SSH_PUBLIC_KEY]) {
- rc = ssh_pki_import_pubkey_file(data->set.str[STRING_SSH_PUBLIC_KEY],
- &ssh->pubkey);
+ rc = ssh_pki_import_pubkey_file(data->set.str[STRING_SSH_PUBLIC_KEY],
+ &ssh->pubkey);
if(rc != SSH_OK) {
failf(data, "Could not load public key file");
- return CURLE_FAILED_INIT;
+ return CURLE_FAILED_INIT;
}
}
@@ -2349,7 +2349,7 @@ static CURLcode scp_disconnect(struct connectdata *conn,
static CURLcode myssh_done(struct connectdata *conn, CURLcode status)
{
CURLcode result = CURLE_OK;
- struct SSHPROTO *protop = conn->data->req.p.ssh;
+ struct SSHPROTO *protop = conn->data->req.p.ssh;
if(!status) {
/* run the state-machine */
@@ -2602,7 +2602,7 @@ static void sftp_quote(struct connectdata *conn)
{
const char *cp;
struct Curl_easy *data = conn->data;
- struct SSHPROTO *protop = data->req.p.ssh;
+ struct SSHPROTO *protop = data->req.p.ssh;
struct ssh_conn *sshc = &conn->proto.sshc;
CURLcode result;
@@ -2632,9 +2632,9 @@ static void sftp_quote(struct connectdata *conn)
sshc->nextstate = SSH_NO_STATE;
return;
}
- Curl_debug(data, CURLINFO_HEADER_OUT, (char *) "PWD\n", 4);
- Curl_debug(data, CURLINFO_HEADER_IN, tmp, strlen(tmp));
-
+ Curl_debug(data, CURLINFO_HEADER_OUT, (char *) "PWD\n", 4);
+ Curl_debug(data, CURLINFO_HEADER_IN, tmp, strlen(tmp));
+
/* this sends an FTP-like "header" to the header callback so that the
current directory can be read very similar to how it is read when
using ordinary FTP. */
@@ -2687,9 +2687,9 @@ static void sftp_quote(struct connectdata *conn)
*/
if(strncasecompare(cmd, "chgrp ", 6) ||
strncasecompare(cmd, "chmod ", 6) ||
- strncasecompare(cmd, "chown ", 6) ||
- strncasecompare(cmd, "atime ", 6) ||
- strncasecompare(cmd, "mtime ", 6)) {
+ strncasecompare(cmd, "chown ", 6) ||
+ strncasecompare(cmd, "atime ", 6) ||
+ strncasecompare(cmd, "mtime ", 6)) {
/* attribute change */
/* sshc->quote_path1 contains the mode to set */
@@ -2699,7 +2699,7 @@ static void sftp_quote(struct connectdata *conn)
if(result == CURLE_OUT_OF_MEMORY)
failf(data, "Out of memory");
else
- failf(data, "Syntax error in chgrp/chmod/chown/atime/mtime: "
+ failf(data, "Syntax error in chgrp/chmod/chown/atime/mtime: "
"Bad second parameter");
Curl_safefree(sshc->quote_path1);
state(conn, SSH_SFTP_CLOSE);
@@ -2860,34 +2860,34 @@ static void sftp_quote_stat(struct connectdata *conn)
}
sshc->quote_attrs->flags |= SSH_FILEXFER_ATTR_UIDGID;
}
- else if(strncasecompare(cmd, "atime", 5)) {
- time_t date = Curl_getdate_capped(sshc->quote_path1);
- if(date == -1) {
- Curl_safefree(sshc->quote_path1);
- Curl_safefree(sshc->quote_path2);
- failf(data, "Syntax error: incorrect access date format");
- state(conn, SSH_SFTP_CLOSE);
- sshc->nextstate = SSH_NO_STATE;
- sshc->actualcode = CURLE_QUOTE_ERROR;
- return;
- }
- sshc->quote_attrs->atime = (uint32_t)date;
- sshc->quote_attrs->flags |= SSH_FILEXFER_ATTR_ACMODTIME;
- }
- else if(strncasecompare(cmd, "mtime", 5)) {
- time_t date = Curl_getdate_capped(sshc->quote_path1);
- if(date == -1) {
- Curl_safefree(sshc->quote_path1);
- Curl_safefree(sshc->quote_path2);
- failf(data, "Syntax error: incorrect modification date format");
- state(conn, SSH_SFTP_CLOSE);
- sshc->nextstate = SSH_NO_STATE;
- sshc->actualcode = CURLE_QUOTE_ERROR;
- return;
- }
- sshc->quote_attrs->mtime = (uint32_t)date;
- sshc->quote_attrs->flags |= SSH_FILEXFER_ATTR_ACMODTIME;
- }
+ else if(strncasecompare(cmd, "atime", 5)) {
+ time_t date = Curl_getdate_capped(sshc->quote_path1);
+ if(date == -1) {
+ Curl_safefree(sshc->quote_path1);
+ Curl_safefree(sshc->quote_path2);
+ failf(data, "Syntax error: incorrect access date format");
+ state(conn, SSH_SFTP_CLOSE);
+ sshc->nextstate = SSH_NO_STATE;
+ sshc->actualcode = CURLE_QUOTE_ERROR;
+ return;
+ }
+ sshc->quote_attrs->atime = (uint32_t)date;
+ sshc->quote_attrs->flags |= SSH_FILEXFER_ATTR_ACMODTIME;
+ }
+ else if(strncasecompare(cmd, "mtime", 5)) {
+ time_t date = Curl_getdate_capped(sshc->quote_path1);
+ if(date == -1) {
+ Curl_safefree(sshc->quote_path1);
+ Curl_safefree(sshc->quote_path2);
+ failf(data, "Syntax error: incorrect modification date format");
+ state(conn, SSH_SFTP_CLOSE);
+ sshc->nextstate = SSH_NO_STATE;
+ sshc->actualcode = CURLE_QUOTE_ERROR;
+ return;
+ }
+ sshc->quote_attrs->mtime = (uint32_t)date;
+ sshc->quote_attrs->flags |= SSH_FILEXFER_ATTR_ACMODTIME;
+ }
/* Now send the completed structure... */
state(conn, SSH_SFTP_QUOTE_SETSTAT);
diff --git a/contrib/libs/curl/lib/vssh/libssh2.c b/contrib/libs/curl/lib/vssh/libssh2.c
index 90fe770559..b282bf23f4 100644
--- a/contrib/libs/curl/lib/vssh/libssh2.c
+++ b/contrib/libs/curl/lib/vssh/libssh2.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -93,17 +93,17 @@
#define HAS_STATVFS_SUPPORT 1
#endif
-#define sftp_libssh2_realpath(s,p,t,m) \
- libssh2_sftp_symlink_ex((s), (p), curlx_uztoui(strlen(p)), \
- (t), (m), LIBSSH2_SFTP_REALPATH)
+#define sftp_libssh2_realpath(s,p,t,m) \
+ libssh2_sftp_symlink_ex((s), (p), curlx_uztoui(strlen(p)), \
+ (t), (m), LIBSSH2_SFTP_REALPATH)
/* Local functions: */
-static const char *sftp_libssh2_strerror(unsigned long err);
+static const char *sftp_libssh2_strerror(unsigned long err);
static LIBSSH2_ALLOC_FUNC(my_libssh2_malloc);
static LIBSSH2_REALLOC_FUNC(my_libssh2_realloc);
static LIBSSH2_FREE_FUNC(my_libssh2_free);
-static CURLcode ssh_force_knownhost_key_type(struct connectdata *conn);
+static CURLcode ssh_force_knownhost_key_type(struct connectdata *conn);
static CURLcode ssh_connect(struct connectdata *conn, bool *done);
static CURLcode ssh_multi_statemach(struct connectdata *conn, bool *done);
static CURLcode ssh_do(struct connectdata *conn, bool *done);
@@ -150,7 +150,7 @@ const struct Curl_handler Curl_handler_scp = {
ZERO_NULL, /* connection_check */
PORT_SSH, /* defport */
CURLPROTO_SCP, /* protocol */
- CURLPROTO_SCP, /* family */
+ CURLPROTO_SCP, /* family */
PROTOPT_DIRLOCK | PROTOPT_CLOSEACTION
| PROTOPT_NOURLQUERY /* flags */
};
@@ -178,7 +178,7 @@ const struct Curl_handler Curl_handler_sftp = {
ZERO_NULL, /* connection_check */
PORT_SSH, /* defport */
CURLPROTO_SFTP, /* protocol */
- CURLPROTO_SFTP, /* family */
+ CURLPROTO_SFTP, /* family */
PROTOPT_DIRLOCK | PROTOPT_CLOSEACTION
| PROTOPT_NOURLQUERY /* flags */
};
@@ -212,7 +212,7 @@ kbd_callback(const char *name, int name_len, const char *instruction,
(void)abstract;
} /* kbd_callback */
-static CURLcode sftp_libssh2_error_to_CURLE(unsigned long err)
+static CURLcode sftp_libssh2_error_to_CURLE(unsigned long err)
{
switch(err) {
case LIBSSH2_FX_OK:
@@ -444,7 +444,7 @@ static CURLcode ssh_knownhost(struct connectdata *conn)
if(data->set.str[STRING_SSH_KNOWNHOSTS]) {
/* we're asked to verify the host against a file */
struct ssh_conn *sshc = &conn->proto.sshc;
- struct libssh2_knownhost *host = NULL;
+ struct libssh2_knownhost *host = NULL;
int rc;
int keytype;
size_t keylen;
@@ -466,95 +466,95 @@ static CURLcode ssh_knownhost(struct connectdata *conn)
struct curl_khkey *knownkeyp = NULL;
struct curl_khkey foundkey;
- switch(keytype) {
- case LIBSSH2_HOSTKEY_TYPE_RSA:
- keybit = LIBSSH2_KNOWNHOST_KEY_SSHRSA;
- break;
- case LIBSSH2_HOSTKEY_TYPE_DSS:
- keybit = LIBSSH2_KNOWNHOST_KEY_SSHDSS;
- break;
-#ifdef LIBSSH2_HOSTKEY_TYPE_ECDSA_256
- case LIBSSH2_HOSTKEY_TYPE_ECDSA_256:
- keybit = LIBSSH2_KNOWNHOST_KEY_ECDSA_256;
- break;
-#endif
-#ifdef LIBSSH2_HOSTKEY_TYPE_ECDSA_384
- case LIBSSH2_HOSTKEY_TYPE_ECDSA_384:
- keybit = LIBSSH2_KNOWNHOST_KEY_ECDSA_384;
- break;
-#endif
-#ifdef LIBSSH2_HOSTKEY_TYPE_ECDSA_521
- case LIBSSH2_HOSTKEY_TYPE_ECDSA_521:
- keybit = LIBSSH2_KNOWNHOST_KEY_ECDSA_521;
- break;
-#endif
-#ifdef LIBSSH2_HOSTKEY_TYPE_ED25519
- case LIBSSH2_HOSTKEY_TYPE_ED25519:
- keybit = LIBSSH2_KNOWNHOST_KEY_ED25519;
- break;
-#endif
- default:
- infof(data, "unsupported key type, can't check knownhosts!\n");
- keybit = 0;
- break;
- }
- if(!keybit)
- /* no check means failure! */
- rc = CURLKHSTAT_REJECT;
- else {
+ switch(keytype) {
+ case LIBSSH2_HOSTKEY_TYPE_RSA:
+ keybit = LIBSSH2_KNOWNHOST_KEY_SSHRSA;
+ break;
+ case LIBSSH2_HOSTKEY_TYPE_DSS:
+ keybit = LIBSSH2_KNOWNHOST_KEY_SSHDSS;
+ break;
+#ifdef LIBSSH2_HOSTKEY_TYPE_ECDSA_256
+ case LIBSSH2_HOSTKEY_TYPE_ECDSA_256:
+ keybit = LIBSSH2_KNOWNHOST_KEY_ECDSA_256;
+ break;
+#endif
+#ifdef LIBSSH2_HOSTKEY_TYPE_ECDSA_384
+ case LIBSSH2_HOSTKEY_TYPE_ECDSA_384:
+ keybit = LIBSSH2_KNOWNHOST_KEY_ECDSA_384;
+ break;
+#endif
+#ifdef LIBSSH2_HOSTKEY_TYPE_ECDSA_521
+ case LIBSSH2_HOSTKEY_TYPE_ECDSA_521:
+ keybit = LIBSSH2_KNOWNHOST_KEY_ECDSA_521;
+ break;
+#endif
+#ifdef LIBSSH2_HOSTKEY_TYPE_ED25519
+ case LIBSSH2_HOSTKEY_TYPE_ED25519:
+ keybit = LIBSSH2_KNOWNHOST_KEY_ED25519;
+ break;
+#endif
+ default:
+ infof(data, "unsupported key type, can't check knownhosts!\n");
+ keybit = 0;
+ break;
+ }
+ if(!keybit)
+ /* no check means failure! */
+ rc = CURLKHSTAT_REJECT;
+ else {
#ifdef HAVE_LIBSSH2_KNOWNHOST_CHECKP
- keycheck = libssh2_knownhost_checkp(sshc->kh,
- conn->host.name,
- (conn->remote_port != PORT_SSH)?
- conn->remote_port:-1,
- remotekey, keylen,
- LIBSSH2_KNOWNHOST_TYPE_PLAIN|
- LIBSSH2_KNOWNHOST_KEYENC_RAW|
- keybit,
- &host);
+ keycheck = libssh2_knownhost_checkp(sshc->kh,
+ conn->host.name,
+ (conn->remote_port != PORT_SSH)?
+ conn->remote_port:-1,
+ remotekey, keylen,
+ LIBSSH2_KNOWNHOST_TYPE_PLAIN|
+ LIBSSH2_KNOWNHOST_KEYENC_RAW|
+ keybit,
+ &host);
#else
- keycheck = libssh2_knownhost_check(sshc->kh,
- conn->host.name,
- remotekey, keylen,
- LIBSSH2_KNOWNHOST_TYPE_PLAIN|
- LIBSSH2_KNOWNHOST_KEYENC_RAW|
- keybit,
- &host);
+ keycheck = libssh2_knownhost_check(sshc->kh,
+ conn->host.name,
+ remotekey, keylen,
+ LIBSSH2_KNOWNHOST_TYPE_PLAIN|
+ LIBSSH2_KNOWNHOST_KEYENC_RAW|
+ keybit,
+ &host);
#endif
- infof(data, "SSH host check: %d, key: %s\n", keycheck,
- (keycheck <= LIBSSH2_KNOWNHOST_CHECK_MISMATCH)?
- host->key:"<none>");
-
- /* setup 'knownkey' */
- if(keycheck <= LIBSSH2_KNOWNHOST_CHECK_MISMATCH) {
- knownkey.key = host->key;
- knownkey.len = 0;
- knownkey.keytype = (keytype == LIBSSH2_HOSTKEY_TYPE_RSA)?
- CURLKHTYPE_RSA : CURLKHTYPE_DSS;
- knownkeyp = &knownkey;
- }
-
- /* setup 'foundkey' */
- foundkey.key = remotekey;
- foundkey.len = keylen;
- foundkey.keytype = (keytype == LIBSSH2_HOSTKEY_TYPE_RSA)?
+ infof(data, "SSH host check: %d, key: %s\n", keycheck,
+ (keycheck <= LIBSSH2_KNOWNHOST_CHECK_MISMATCH)?
+ host->key:"<none>");
+
+ /* setup 'knownkey' */
+ if(keycheck <= LIBSSH2_KNOWNHOST_CHECK_MISMATCH) {
+ knownkey.key = host->key;
+ knownkey.len = 0;
+ knownkey.keytype = (keytype == LIBSSH2_HOSTKEY_TYPE_RSA)?
+ CURLKHTYPE_RSA : CURLKHTYPE_DSS;
+ knownkeyp = &knownkey;
+ }
+
+ /* setup 'foundkey' */
+ foundkey.key = remotekey;
+ foundkey.len = keylen;
+ foundkey.keytype = (keytype == LIBSSH2_HOSTKEY_TYPE_RSA)?
CURLKHTYPE_RSA : CURLKHTYPE_DSS;
- /*
- * if any of the LIBSSH2_KNOWNHOST_CHECK_* defines and the
- * curl_khmatch enum are ever modified, we need to introduce a
- * translation table here!
- */
- keymatch = (enum curl_khmatch)keycheck;
-
- /* Ask the callback how to behave */
- Curl_set_in_callback(data, true);
- rc = func(data, knownkeyp, /* from the knownhosts file */
- &foundkey, /* from the remote host */
- keymatch, data->set.ssh_keyfunc_userp);
- Curl_set_in_callback(data, false);
- }
+ /*
+ * if any of the LIBSSH2_KNOWNHOST_CHECK_* defines and the
+ * curl_khmatch enum are ever modified, we need to introduce a
+ * translation table here!
+ */
+ keymatch = (enum curl_khmatch)keycheck;
+
+ /* Ask the callback how to behave */
+ Curl_set_in_callback(data, true);
+ rc = func(data, knownkeyp, /* from the knownhosts file */
+ &foundkey, /* from the remote host */
+ keymatch, data->set.ssh_keyfunc_userp);
+ Curl_set_in_callback(data, false);
+ }
}
else
/* no remotekey means failure! */
@@ -570,13 +570,13 @@ static CURLcode ssh_knownhost(struct connectdata *conn)
/* DEFER means bail out but keep the SSH_HOSTKEY state */
result = sshc->actualcode = CURLE_PEER_FAILED_VERIFICATION;
break;
- case CURLKHSTAT_FINE_REPLACE:
- /* remove old host+key that doesn't match */
- if(host)
- libssh2_knownhost_del(sshc->kh, host);
- /*FALLTHROUGH*/
+ case CURLKHSTAT_FINE_REPLACE:
+ /* remove old host+key that doesn't match */
+ if(host)
+ libssh2_knownhost_del(sshc->kh, host);
+ /*FALLTHROUGH*/
case CURLKHSTAT_FINE:
- /*FALLTHROUGH*/
+ /*FALLTHROUGH*/
case CURLKHSTAT_FINE_ADD_TO_FILE:
/* proceed */
if(keycheck != LIBSSH2_KNOWNHOST_CHECK_MATCH) {
@@ -591,8 +591,8 @@ static CURLcode ssh_knownhost(struct connectdata *conn)
if(addrc)
infof(data, "Warning adding the known host %s failed!\n",
conn->host.name);
- else if(rc == CURLKHSTAT_FINE_ADD_TO_FILE ||
- rc == CURLKHSTAT_FINE_REPLACE) {
+ else if(rc == CURLKHSTAT_FINE_ADD_TO_FILE ||
+ rc == CURLKHSTAT_FINE_REPLACE) {
/* now we write the entire in-memory list of known hosts to the
known_hosts file */
int wrc =
@@ -656,138 +656,138 @@ static CURLcode ssh_check_fingerprint(struct connectdata *conn)
}
/*
- * ssh_force_knownhost_key_type() will check the known hosts file and try to
- * force a specific public key type from the server if an entry is found.
- */
-static CURLcode ssh_force_knownhost_key_type(struct connectdata *conn)
-{
- CURLcode result = CURLE_OK;
-
-#ifdef HAVE_LIBSSH2_KNOWNHOST_API
-
-#ifdef LIBSSH2_KNOWNHOST_KEY_ED25519
- static const char * const hostkey_method_ssh_ed25519
- = "ssh-ed25519";
-#endif
-#ifdef LIBSSH2_KNOWNHOST_KEY_ECDSA_521
- static const char * const hostkey_method_ssh_ecdsa_521
- = "ecdsa-sha2-nistp521";
-#endif
-#ifdef LIBSSH2_KNOWNHOST_KEY_ECDSA_384
- static const char * const hostkey_method_ssh_ecdsa_384
- = "ecdsa-sha2-nistp384";
-#endif
-#ifdef LIBSSH2_KNOWNHOST_KEY_ECDSA_256
- static const char * const hostkey_method_ssh_ecdsa_256
- = "ecdsa-sha2-nistp256";
-#endif
- static const char * const hostkey_method_ssh_rsa
- = "ssh-rsa";
- static const char * const hostkey_method_ssh_dss
- = "ssh-dss";
-
- const char *hostkey_method = NULL;
- struct ssh_conn *sshc = &conn->proto.sshc;
- struct Curl_easy *data = conn->data;
- struct libssh2_knownhost* store = NULL;
- const char *kh_name_end = NULL;
- size_t kh_name_size = 0;
- int port = 0;
- bool found = false;
-
- if(sshc->kh && !data->set.str[STRING_SSH_HOST_PUBLIC_KEY_MD5]) {
- /* lets try to find our host in the known hosts file */
- while(!libssh2_knownhost_get(sshc->kh, &store, store)) {
- /* For non-standard ports, the name will be enclosed in */
- /* square brackets, followed by a colon and the port */
- if(store) {
- if(store->name) {
- if(store->name[0] == '[') {
- kh_name_end = strstr(store->name, "]:");
- if(!kh_name_end) {
- infof(data, "Invalid host pattern %s in %s\n",
- store->name, data->set.str[STRING_SSH_KNOWNHOSTS]);
- continue;
- }
- port = atoi(kh_name_end + 2);
- if(kh_name_end && (port == conn->remote_port)) {
- kh_name_size = strlen(store->name) - 1 - strlen(kh_name_end);
- if(strncmp(store->name + 1,
- conn->host.name, kh_name_size) == 0) {
- found = true;
- break;
- }
- }
- }
- else if(strcmp(store->name, conn->host.name) == 0) {
- found = true;
- break;
- }
- }
- else {
- found = true;
- break;
- }
- }
- }
-
- if(found) {
- infof(data, "Found host %s in %s\n",
- conn->host.name, data->set.str[STRING_SSH_KNOWNHOSTS]);
-
- switch(store->typemask & LIBSSH2_KNOWNHOST_KEY_MASK) {
-#ifdef LIBSSH2_KNOWNHOST_KEY_ED25519
- case LIBSSH2_KNOWNHOST_KEY_ED25519:
- hostkey_method = hostkey_method_ssh_ed25519;
- break;
-#endif
-#ifdef LIBSSH2_KNOWNHOST_KEY_ECDSA_521
- case LIBSSH2_KNOWNHOST_KEY_ECDSA_521:
- hostkey_method = hostkey_method_ssh_ecdsa_521;
- break;
-#endif
-#ifdef LIBSSH2_KNOWNHOST_KEY_ECDSA_384
- case LIBSSH2_KNOWNHOST_KEY_ECDSA_384:
- hostkey_method = hostkey_method_ssh_ecdsa_384;
- break;
-#endif
-#ifdef LIBSSH2_KNOWNHOST_KEY_ECDSA_256
- case LIBSSH2_KNOWNHOST_KEY_ECDSA_256:
- hostkey_method = hostkey_method_ssh_ecdsa_256;
- break;
-#endif
- case LIBSSH2_KNOWNHOST_KEY_SSHRSA:
- hostkey_method = hostkey_method_ssh_rsa;
- break;
- case LIBSSH2_KNOWNHOST_KEY_SSHDSS:
- hostkey_method = hostkey_method_ssh_dss;
- break;
- case LIBSSH2_KNOWNHOST_KEY_RSA1:
- failf(data, "Found host key type RSA1 which is not supported\n");
- return CURLE_SSH;
- default:
- failf(data, "Unknown host key type: %i\n",
- (store->typemask & LIBSSH2_KNOWNHOST_KEY_MASK));
- return CURLE_SSH;
- }
-
- infof(data, "Set \"%s\" as SSH hostkey type\n", hostkey_method);
- result = libssh2_session_error_to_CURLE(
- libssh2_session_method_pref(
- sshc->ssh_session, LIBSSH2_METHOD_HOSTKEY, hostkey_method));
- }
- else {
- infof(data, "Did not find host %s in %s\n",
- conn->host.name, data->set.str[STRING_SSH_KNOWNHOSTS]);
- }
- }
-
-#endif /* HAVE_LIBSSH2_KNOWNHOST_API */
-
- return result;
-}
-
-/*
+ * ssh_force_knownhost_key_type() will check the known hosts file and try to
+ * force a specific public key type from the server if an entry is found.
+ */
+static CURLcode ssh_force_knownhost_key_type(struct connectdata *conn)
+{
+ CURLcode result = CURLE_OK;
+
+#ifdef HAVE_LIBSSH2_KNOWNHOST_API
+
+#ifdef LIBSSH2_KNOWNHOST_KEY_ED25519
+ static const char * const hostkey_method_ssh_ed25519
+ = "ssh-ed25519";
+#endif
+#ifdef LIBSSH2_KNOWNHOST_KEY_ECDSA_521
+ static const char * const hostkey_method_ssh_ecdsa_521
+ = "ecdsa-sha2-nistp521";
+#endif
+#ifdef LIBSSH2_KNOWNHOST_KEY_ECDSA_384
+ static const char * const hostkey_method_ssh_ecdsa_384
+ = "ecdsa-sha2-nistp384";
+#endif
+#ifdef LIBSSH2_KNOWNHOST_KEY_ECDSA_256
+ static const char * const hostkey_method_ssh_ecdsa_256
+ = "ecdsa-sha2-nistp256";
+#endif
+ static const char * const hostkey_method_ssh_rsa
+ = "ssh-rsa";
+ static const char * const hostkey_method_ssh_dss
+ = "ssh-dss";
+
+ const char *hostkey_method = NULL;
+ struct ssh_conn *sshc = &conn->proto.sshc;
+ struct Curl_easy *data = conn->data;
+ struct libssh2_knownhost* store = NULL;
+ const char *kh_name_end = NULL;
+ size_t kh_name_size = 0;
+ int port = 0;
+ bool found = false;
+
+ if(sshc->kh && !data->set.str[STRING_SSH_HOST_PUBLIC_KEY_MD5]) {
+ /* lets try to find our host in the known hosts file */
+ while(!libssh2_knownhost_get(sshc->kh, &store, store)) {
+ /* For non-standard ports, the name will be enclosed in */
+ /* square brackets, followed by a colon and the port */
+ if(store) {
+ if(store->name) {
+ if(store->name[0] == '[') {
+ kh_name_end = strstr(store->name, "]:");
+ if(!kh_name_end) {
+ infof(data, "Invalid host pattern %s in %s\n",
+ store->name, data->set.str[STRING_SSH_KNOWNHOSTS]);
+ continue;
+ }
+ port = atoi(kh_name_end + 2);
+ if(kh_name_end && (port == conn->remote_port)) {
+ kh_name_size = strlen(store->name) - 1 - strlen(kh_name_end);
+ if(strncmp(store->name + 1,
+ conn->host.name, kh_name_size) == 0) {
+ found = true;
+ break;
+ }
+ }
+ }
+ else if(strcmp(store->name, conn->host.name) == 0) {
+ found = true;
+ break;
+ }
+ }
+ else {
+ found = true;
+ break;
+ }
+ }
+ }
+
+ if(found) {
+ infof(data, "Found host %s in %s\n",
+ conn->host.name, data->set.str[STRING_SSH_KNOWNHOSTS]);
+
+ switch(store->typemask & LIBSSH2_KNOWNHOST_KEY_MASK) {
+#ifdef LIBSSH2_KNOWNHOST_KEY_ED25519
+ case LIBSSH2_KNOWNHOST_KEY_ED25519:
+ hostkey_method = hostkey_method_ssh_ed25519;
+ break;
+#endif
+#ifdef LIBSSH2_KNOWNHOST_KEY_ECDSA_521
+ case LIBSSH2_KNOWNHOST_KEY_ECDSA_521:
+ hostkey_method = hostkey_method_ssh_ecdsa_521;
+ break;
+#endif
+#ifdef LIBSSH2_KNOWNHOST_KEY_ECDSA_384
+ case LIBSSH2_KNOWNHOST_KEY_ECDSA_384:
+ hostkey_method = hostkey_method_ssh_ecdsa_384;
+ break;
+#endif
+#ifdef LIBSSH2_KNOWNHOST_KEY_ECDSA_256
+ case LIBSSH2_KNOWNHOST_KEY_ECDSA_256:
+ hostkey_method = hostkey_method_ssh_ecdsa_256;
+ break;
+#endif
+ case LIBSSH2_KNOWNHOST_KEY_SSHRSA:
+ hostkey_method = hostkey_method_ssh_rsa;
+ break;
+ case LIBSSH2_KNOWNHOST_KEY_SSHDSS:
+ hostkey_method = hostkey_method_ssh_dss;
+ break;
+ case LIBSSH2_KNOWNHOST_KEY_RSA1:
+ failf(data, "Found host key type RSA1 which is not supported\n");
+ return CURLE_SSH;
+ default:
+ failf(data, "Unknown host key type: %i\n",
+ (store->typemask & LIBSSH2_KNOWNHOST_KEY_MASK));
+ return CURLE_SSH;
+ }
+
+ infof(data, "Set \"%s\" as SSH hostkey type\n", hostkey_method);
+ result = libssh2_session_error_to_CURLE(
+ libssh2_session_method_pref(
+ sshc->ssh_session, LIBSSH2_METHOD_HOSTKEY, hostkey_method));
+ }
+ else {
+ infof(data, "Did not find host %s in %s\n",
+ conn->host.name, data->set.str[STRING_SSH_KNOWNHOSTS]);
+ }
+ }
+
+#endif /* HAVE_LIBSSH2_KNOWNHOST_API */
+
+ return result;
+}
+
+/*
* ssh_statemach_act() runs the SSH state machine as far as it can without
* blocking and without reaching the end. The data the pointer 'block' points
* to will be set to TRUE if the libssh2 function returns LIBSSH2_ERROR_EAGAIN
@@ -798,14 +798,14 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
{
CURLcode result = CURLE_OK;
struct Curl_easy *data = conn->data;
- struct SSHPROTO *sftp_scp = data->req.p.ssh;
+ struct SSHPROTO *sftp_scp = data->req.p.ssh;
struct ssh_conn *sshc = &conn->proto.sshc;
curl_socket_t sock = conn->sock[FIRSTSOCKET];
int rc = LIBSSH2_ERROR_NONE;
- int ssherr;
- unsigned long sftperr;
+ int ssherr;
+ unsigned long sftperr;
int seekerr = CURL_SEEKFUNC_OK;
- size_t readdir_len;
+ size_t readdir_len;
*block = 0; /* we're not blocking by default */
do {
@@ -820,13 +820,13 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
non-blocking */
libssh2_session_set_blocking(sshc->ssh_session, 0);
- result = ssh_force_knownhost_key_type(conn);
- if(result) {
- state(conn, SSH_SESSION_FREE);
- sshc->actualcode = result;
- break;
- }
-
+ result = ssh_force_knownhost_key_type(conn);
+ if(result) {
+ state(conn, SSH_SESSION_FREE);
+ sshc->actualcode = result;
+ break;
+ }
+
state(conn, SSH_S_STARTUP);
/* FALLTHROUGH */
@@ -882,12 +882,12 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
state(conn, SSH_AUTH_DONE);
break;
}
- ssherr = libssh2_session_last_errno(sshc->ssh_session);
- if(ssherr == LIBSSH2_ERROR_EAGAIN)
+ ssherr = libssh2_session_last_errno(sshc->ssh_session);
+ if(ssherr == LIBSSH2_ERROR_EAGAIN)
rc = LIBSSH2_ERROR_EAGAIN;
else {
state(conn, SSH_SESSION_FREE);
- sshc->actualcode = libssh2_session_error_to_CURLE(ssherr);
+ sshc->actualcode = libssh2_session_error_to_CURLE(ssherr);
}
break;
}
@@ -1257,16 +1257,16 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
}
else {
/* Return the error type */
- sftperr = libssh2_sftp_last_error(sshc->sftp_session);
- if(sftperr)
- result = sftp_libssh2_error_to_CURLE(sftperr);
+ sftperr = libssh2_sftp_last_error(sshc->sftp_session);
+ if(sftperr)
+ result = sftp_libssh2_error_to_CURLE(sftperr);
else
/* in this case, the error wasn't in the SFTP level but for example
a time-out or similar */
result = CURLE_SSH;
sshc->actualcode = result;
- DEBUGF(infof(data, "error = %lu makes libcurl = %d\n",
- sftperr, (int)result));
+ DEBUGF(infof(data, "error = %lu makes libcurl = %d\n",
+ sftperr, (int)result));
state(conn, SSH_STOP);
break;
}
@@ -1343,9 +1343,9 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
sshc->nextstate = SSH_NO_STATE;
break;
}
- Curl_debug(data, CURLINFO_HEADER_OUT, (char *)"PWD\n", 4);
- Curl_debug(data, CURLINFO_HEADER_IN, tmp, strlen(tmp));
-
+ Curl_debug(data, CURLINFO_HEADER_OUT, (char *)"PWD\n", 4);
+ Curl_debug(data, CURLINFO_HEADER_IN, tmp, strlen(tmp));
+
/* this sends an FTP-like "header" to the header callback so that the
current directory can be read very similar to how it is read when
using ordinary FTP. */
@@ -1367,8 +1367,8 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
*/
cp = strchr(cmd, ' ');
if(cp == NULL) {
- failf(data, "Syntax error command '%s'. Missing parameter!",
- cmd);
+ failf(data, "Syntax error command '%s'. Missing parameter!",
+ cmd);
state(conn, SSH_SFTP_CLOSE);
sshc->nextstate = SSH_NO_STATE;
sshc->actualcode = CURLE_QUOTE_ERROR;
@@ -1384,7 +1384,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
if(result == CURLE_OUT_OF_MEMORY)
failf(data, "Out of memory");
else
- failf(data, "Syntax error: Bad first parameter to '%s'", cmd);
+ failf(data, "Syntax error: Bad first parameter to '%s'", cmd);
state(conn, SSH_SFTP_CLOSE);
sshc->nextstate = SSH_NO_STATE;
sshc->actualcode = result;
@@ -1399,9 +1399,9 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
*/
if(strncasecompare(cmd, "chgrp ", 6) ||
strncasecompare(cmd, "chmod ", 6) ||
- strncasecompare(cmd, "chown ", 6) ||
- strncasecompare(cmd, "atime ", 6) ||
- strncasecompare(cmd, "mtime ", 6)) {
+ strncasecompare(cmd, "chown ", 6) ||
+ strncasecompare(cmd, "atime ", 6) ||
+ strncasecompare(cmd, "mtime ", 6)) {
/* attribute change */
/* sshc->quote_path1 contains the mode to set */
@@ -1411,7 +1411,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
if(result == CURLE_OUT_OF_MEMORY)
failf(data, "Out of memory");
else
- failf(data, "Syntax error in %s: Bad second parameter", cmd);
+ failf(data, "Syntax error in %s: Bad second parameter", cmd);
Curl_safefree(sshc->quote_path1);
state(conn, SSH_SFTP_CLOSE);
sshc->nextstate = SSH_NO_STATE;
@@ -1542,11 +1542,11 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
break;
}
if(rc != 0 && !sshc->acceptfail) { /* get those attributes */
- sftperr = libssh2_sftp_last_error(sshc->sftp_session);
+ sftperr = libssh2_sftp_last_error(sshc->sftp_session);
Curl_safefree(sshc->quote_path1);
Curl_safefree(sshc->quote_path2);
failf(data, "Attempt to get SFTP stats failed: %s",
- sftp_libssh2_strerror(sftperr));
+ sftp_libssh2_strerror(sftperr));
state(conn, SSH_SFTP_CLOSE);
sshc->nextstate = SSH_NO_STATE;
sshc->actualcode = CURLE_QUOTE_ERROR;
@@ -1598,34 +1598,34 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
break;
}
}
- else if(strncasecompare(cmd, "atime", 5)) {
- time_t date = Curl_getdate_capped(sshc->quote_path1);
- if(date == -1) {
- Curl_safefree(sshc->quote_path1);
- Curl_safefree(sshc->quote_path2);
- failf(data, "Syntax error: incorrect access date format");
- state(conn, SSH_SFTP_CLOSE);
- sshc->nextstate = SSH_NO_STATE;
- sshc->actualcode = CURLE_QUOTE_ERROR;
- break;
- }
- sshc->quote_attrs.atime = (unsigned long)date;
- sshc->quote_attrs.flags = LIBSSH2_SFTP_ATTR_ACMODTIME;
- }
- else if(strncasecompare(cmd, "mtime", 5)) {
- time_t date = Curl_getdate_capped(sshc->quote_path1);
- if(date == -1) {
- Curl_safefree(sshc->quote_path1);
- Curl_safefree(sshc->quote_path2);
- failf(data, "Syntax error: incorrect modification date format");
- state(conn, SSH_SFTP_CLOSE);
- sshc->nextstate = SSH_NO_STATE;
- sshc->actualcode = CURLE_QUOTE_ERROR;
- break;
- }
- sshc->quote_attrs.mtime = (unsigned long)date;
- sshc->quote_attrs.flags = LIBSSH2_SFTP_ATTR_ACMODTIME;
- }
+ else if(strncasecompare(cmd, "atime", 5)) {
+ time_t date = Curl_getdate_capped(sshc->quote_path1);
+ if(date == -1) {
+ Curl_safefree(sshc->quote_path1);
+ Curl_safefree(sshc->quote_path2);
+ failf(data, "Syntax error: incorrect access date format");
+ state(conn, SSH_SFTP_CLOSE);
+ sshc->nextstate = SSH_NO_STATE;
+ sshc->actualcode = CURLE_QUOTE_ERROR;
+ break;
+ }
+ sshc->quote_attrs.atime = (unsigned long)date;
+ sshc->quote_attrs.flags = LIBSSH2_SFTP_ATTR_ACMODTIME;
+ }
+ else if(strncasecompare(cmd, "mtime", 5)) {
+ time_t date = Curl_getdate_capped(sshc->quote_path1);
+ if(date == -1) {
+ Curl_safefree(sshc->quote_path1);
+ Curl_safefree(sshc->quote_path2);
+ failf(data, "Syntax error: incorrect modification date format");
+ state(conn, SSH_SFTP_CLOSE);
+ sshc->nextstate = SSH_NO_STATE;
+ sshc->actualcode = CURLE_QUOTE_ERROR;
+ break;
+ }
+ sshc->quote_attrs.mtime = (unsigned long)date;
+ sshc->quote_attrs.flags = LIBSSH2_SFTP_ATTR_ACMODTIME;
+ }
/* Now send the completed structure... */
state(conn, SSH_SFTP_QUOTE_SETSTAT);
@@ -1641,11 +1641,11 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
break;
}
if(rc != 0 && !sshc->acceptfail) {
- sftperr = libssh2_sftp_last_error(sshc->sftp_session);
+ sftperr = libssh2_sftp_last_error(sshc->sftp_session);
Curl_safefree(sshc->quote_path1);
Curl_safefree(sshc->quote_path2);
failf(data, "Attempt to set SFTP stats failed: %s",
- sftp_libssh2_strerror(sftperr));
+ sftp_libssh2_strerror(sftperr));
state(conn, SSH_SFTP_CLOSE);
sshc->nextstate = SSH_NO_STATE;
sshc->actualcode = CURLE_QUOTE_ERROR;
@@ -1664,11 +1664,11 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
break;
}
if(rc != 0 && !sshc->acceptfail) {
- sftperr = libssh2_sftp_last_error(sshc->sftp_session);
+ sftperr = libssh2_sftp_last_error(sshc->sftp_session);
Curl_safefree(sshc->quote_path1);
Curl_safefree(sshc->quote_path2);
failf(data, "symlink command failed: %s",
- sftp_libssh2_strerror(sftperr));
+ sftp_libssh2_strerror(sftperr));
state(conn, SSH_SFTP_CLOSE);
sshc->nextstate = SSH_NO_STATE;
sshc->actualcode = CURLE_QUOTE_ERROR;
@@ -1685,10 +1685,10 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
break;
}
if(rc != 0 && !sshc->acceptfail) {
- sftperr = libssh2_sftp_last_error(sshc->sftp_session);
+ sftperr = libssh2_sftp_last_error(sshc->sftp_session);
Curl_safefree(sshc->quote_path1);
- failf(data, "mkdir command failed: %s",
- sftp_libssh2_strerror(sftperr));
+ failf(data, "mkdir command failed: %s",
+ sftp_libssh2_strerror(sftperr));
state(conn, SSH_SFTP_CLOSE);
sshc->nextstate = SSH_NO_STATE;
sshc->actualcode = CURLE_QUOTE_ERROR;
@@ -1710,11 +1710,11 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
break;
}
if(rc != 0 && !sshc->acceptfail) {
- sftperr = libssh2_sftp_last_error(sshc->sftp_session);
+ sftperr = libssh2_sftp_last_error(sshc->sftp_session);
Curl_safefree(sshc->quote_path1);
Curl_safefree(sshc->quote_path2);
- failf(data, "rename command failed: %s",
- sftp_libssh2_strerror(sftperr));
+ failf(data, "rename command failed: %s",
+ sftp_libssh2_strerror(sftperr));
state(conn, SSH_SFTP_CLOSE);
sshc->nextstate = SSH_NO_STATE;
sshc->actualcode = CURLE_QUOTE_ERROR;
@@ -1730,10 +1730,10 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
break;
}
if(rc != 0 && !sshc->acceptfail) {
- sftperr = libssh2_sftp_last_error(sshc->sftp_session);
+ sftperr = libssh2_sftp_last_error(sshc->sftp_session);
Curl_safefree(sshc->quote_path1);
- failf(data, "rmdir command failed: %s",
- sftp_libssh2_strerror(sftperr));
+ failf(data, "rmdir command failed: %s",
+ sftp_libssh2_strerror(sftperr));
state(conn, SSH_SFTP_CLOSE);
sshc->nextstate = SSH_NO_STATE;
sshc->actualcode = CURLE_QUOTE_ERROR;
@@ -1749,9 +1749,9 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
break;
}
if(rc != 0 && !sshc->acceptfail) {
- sftperr = libssh2_sftp_last_error(sshc->sftp_session);
+ sftperr = libssh2_sftp_last_error(sshc->sftp_session);
Curl_safefree(sshc->quote_path1);
- failf(data, "rm command failed: %s", sftp_libssh2_strerror(sftperr));
+ failf(data, "rm command failed: %s", sftp_libssh2_strerror(sftperr));
state(conn, SSH_SFTP_CLOSE);
sshc->nextstate = SSH_NO_STATE;
sshc->actualcode = CURLE_QUOTE_ERROR;
@@ -1772,10 +1772,10 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
break;
}
if(rc != 0 && !sshc->acceptfail) {
- sftperr = libssh2_sftp_last_error(sshc->sftp_session);
+ sftperr = libssh2_sftp_last_error(sshc->sftp_session);
Curl_safefree(sshc->quote_path1);
- failf(data, "statvfs command failed: %s",
- sftp_libssh2_strerror(sftperr));
+ failf(data, "statvfs command failed: %s",
+ sftp_libssh2_strerror(sftperr));
state(conn, SSH_SFTP_CLOSE);
sshc->nextstate = SSH_NO_STATE;
sshc->actualcode = CURLE_QUOTE_ERROR;
@@ -1912,21 +1912,21 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
if(LIBSSH2_ERROR_SFTP_PROTOCOL == rc)
/* only when there was an SFTP protocol error can we extract
the sftp error! */
- sftperr = libssh2_sftp_last_error(sshc->sftp_session);
+ sftperr = libssh2_sftp_last_error(sshc->sftp_session);
else
- sftperr = LIBSSH2_FX_OK; /* not an sftp error at all */
+ sftperr = LIBSSH2_FX_OK; /* not an sftp error at all */
if(sshc->secondCreateDirs) {
state(conn, SSH_SFTP_CLOSE);
- sshc->actualcode = sftperr != LIBSSH2_FX_OK ?
- sftp_libssh2_error_to_CURLE(sftperr):CURLE_SSH;
+ sshc->actualcode = sftperr != LIBSSH2_FX_OK ?
+ sftp_libssh2_error_to_CURLE(sftperr):CURLE_SSH;
failf(data, "Creating the dir/file failed: %s",
- sftp_libssh2_strerror(sftperr));
+ sftp_libssh2_strerror(sftperr));
break;
}
- if(((sftperr == LIBSSH2_FX_NO_SUCH_FILE) ||
- (sftperr == LIBSSH2_FX_FAILURE) ||
- (sftperr == LIBSSH2_FX_NO_SUCH_PATH)) &&
+ if(((sftperr == LIBSSH2_FX_NO_SUCH_FILE) ||
+ (sftperr == LIBSSH2_FX_FAILURE) ||
+ (sftperr == LIBSSH2_FX_NO_SUCH_PATH)) &&
(data->set.ftp_create_missing_dirs &&
(strlen(sftp_scp->path) > 1))) {
/* try to create the path remotely */
@@ -1936,19 +1936,19 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
break;
}
state(conn, SSH_SFTP_CLOSE);
- sshc->actualcode = sftperr != LIBSSH2_FX_OK ?
- sftp_libssh2_error_to_CURLE(sftperr):CURLE_SSH;
+ sshc->actualcode = sftperr != LIBSSH2_FX_OK ?
+ sftp_libssh2_error_to_CURLE(sftperr):CURLE_SSH;
if(!sshc->actualcode) {
- /* Sometimes, for some reason libssh2_sftp_last_error() returns zero
- even though libssh2_sftp_open() failed previously! We need to
- work around that! */
+ /* Sometimes, for some reason libssh2_sftp_last_error() returns zero
+ even though libssh2_sftp_open() failed previously! We need to
+ work around that! */
sshc->actualcode = CURLE_SSH;
- sftperr = LIBSSH2_FX_OK;
+ sftperr = LIBSSH2_FX_OK;
}
- failf(data, "Upload failed: %s (%lu/%d)",
- sftperr != LIBSSH2_FX_OK ?
- sftp_libssh2_strerror(sftperr):"ssh error",
- sftperr, rc);
+ failf(data, "Upload failed: %s (%lu/%d)",
+ sftperr != LIBSSH2_FX_OK ?
+ sftp_libssh2_strerror(sftperr):"ssh error",
+ sftperr, rc);
break;
}
@@ -2075,11 +2075,11 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
* permission was denied (creation might succeed further down the
* path) - retry on unspecific FAILURE also
*/
- sftperr = libssh2_sftp_last_error(sshc->sftp_session);
- if((sftperr != LIBSSH2_FX_FILE_ALREADY_EXISTS) &&
- (sftperr != LIBSSH2_FX_FAILURE) &&
- (sftperr != LIBSSH2_FX_PERMISSION_DENIED)) {
- result = sftp_libssh2_error_to_CURLE(sftperr);
+ sftperr = libssh2_sftp_last_error(sshc->sftp_session);
+ if((sftperr != LIBSSH2_FX_FILE_ALREADY_EXISTS) &&
+ (sftperr != LIBSSH2_FX_FAILURE) &&
+ (sftperr != LIBSSH2_FX_PERMISSION_DENIED)) {
+ result = sftp_libssh2_error_to_CURLE(sftperr);
state(conn, SSH_SFTP_CLOSE);
sshc->actualcode = result?result:CURLE_SSH;
break;
@@ -2111,11 +2111,11 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
rc = LIBSSH2_ERROR_EAGAIN;
break;
}
- sftperr = libssh2_sftp_last_error(sshc->sftp_session);
+ sftperr = libssh2_sftp_last_error(sshc->sftp_session);
failf(data, "Could not open directory for reading: %s",
- sftp_libssh2_strerror(sftperr));
+ sftp_libssh2_strerror(sftperr));
state(conn, SSH_SFTP_CLOSE);
- result = sftp_libssh2_error_to_CURLE(sftperr);
+ result = sftp_libssh2_error_to_CURLE(sftperr);
sshc->actualcode = result?result:CURLE_SSH;
break;
}
@@ -2132,7 +2132,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
sshc->actualcode = CURLE_OUT_OF_MEMORY;
break;
}
- Curl_dyn_init(&sshc->readdir, PATH_MAX * 2);
+ Curl_dyn_init(&sshc->readdir, PATH_MAX * 2);
state(conn, SSH_SFTP_READDIR);
break;
@@ -2147,49 +2147,49 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
break;
}
if(rc > 0) {
- readdir_len = (size_t) rc;
- sshc->readdir_filename[readdir_len] = '\0';
+ readdir_len = (size_t) rc;
+ sshc->readdir_filename[readdir_len] = '\0';
if(data->set.ftp_list_only) {
result = Curl_client_write(conn, CLIENTWRITE_BODY,
- sshc->readdir_filename,
- readdir_len);
- if(!result)
- result = Curl_client_write(conn, CLIENTWRITE_BODY,
- (char *)"\n", 1);
+ sshc->readdir_filename,
+ readdir_len);
+ if(!result)
+ result = Curl_client_write(conn, CLIENTWRITE_BODY,
+ (char *)"\n", 1);
if(result) {
state(conn, SSH_STOP);
break;
}
/* since this counts what we send to the client, we include the
newline in this counter */
- data->req.bytecount += readdir_len + 1;
+ data->req.bytecount += readdir_len + 1;
/* output debug output if that is requested */
- Curl_debug(data, CURLINFO_DATA_IN, sshc->readdir_filename,
- readdir_len);
- Curl_debug(data, CURLINFO_DATA_IN, (char *)"\n", 1);
+ Curl_debug(data, CURLINFO_DATA_IN, sshc->readdir_filename,
+ readdir_len);
+ Curl_debug(data, CURLINFO_DATA_IN, (char *)"\n", 1);
}
else {
- result = Curl_dyn_add(&sshc->readdir, sshc->readdir_longentry);
-
- if(!result) {
- if((sshc->readdir_attrs.flags & LIBSSH2_SFTP_ATTR_PERMISSIONS) &&
- ((sshc->readdir_attrs.permissions & LIBSSH2_SFTP_S_IFMT) ==
- LIBSSH2_SFTP_S_IFLNK)) {
- Curl_dyn_init(&sshc->readdir_link, PATH_MAX);
- result = Curl_dyn_add(&sshc->readdir_link, sftp_scp->path);
- state(conn, SSH_SFTP_READDIR_LINK);
- if(!result)
- break;
- }
- else {
- state(conn, SSH_SFTP_READDIR_BOTTOM);
+ result = Curl_dyn_add(&sshc->readdir, sshc->readdir_longentry);
+
+ if(!result) {
+ if((sshc->readdir_attrs.flags & LIBSSH2_SFTP_ATTR_PERMISSIONS) &&
+ ((sshc->readdir_attrs.permissions & LIBSSH2_SFTP_S_IFMT) ==
+ LIBSSH2_SFTP_S_IFLNK)) {
+ Curl_dyn_init(&sshc->readdir_link, PATH_MAX);
+ result = Curl_dyn_add(&sshc->readdir_link, sftp_scp->path);
+ state(conn, SSH_SFTP_READDIR_LINK);
+ if(!result)
+ break;
+ }
+ else {
+ state(conn, SSH_SFTP_READDIR_BOTTOM);
break;
}
}
- sshc->actualcode = result;
- state(conn, SSH_SFTP_CLOSE);
+ sshc->actualcode = result;
+ state(conn, SSH_SFTP_CLOSE);
break;
}
}
@@ -2200,11 +2200,11 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
break;
}
else if(rc < 0) {
- sftperr = libssh2_sftp_last_error(sshc->sftp_session);
- result = sftp_libssh2_error_to_CURLE(sftperr);
+ sftperr = libssh2_sftp_last_error(sshc->sftp_session);
+ result = sftp_libssh2_error_to_CURLE(sftperr);
sshc->actualcode = result?result:CURLE_SSH;
failf(data, "Could not open remote file for reading: %s :: %d",
- sftp_libssh2_strerror(sftperr),
+ sftp_libssh2_strerror(sftperr),
libssh2_session_last_errno(sshc->ssh_session));
Curl_safefree(sshc->readdir_filename);
Curl_safefree(sshc->readdir_longentry);
@@ -2216,25 +2216,25 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
case SSH_SFTP_READDIR_LINK:
rc =
libssh2_sftp_symlink_ex(sshc->sftp_session,
- Curl_dyn_ptr(&sshc->readdir_link),
- (int)Curl_dyn_len(&sshc->readdir_link),
+ Curl_dyn_ptr(&sshc->readdir_link),
+ (int)Curl_dyn_len(&sshc->readdir_link),
sshc->readdir_filename,
PATH_MAX, LIBSSH2_SFTP_READLINK);
if(rc == LIBSSH2_ERROR_EAGAIN) {
break;
}
- readdir_len = (size_t) rc;
- Curl_dyn_free(&sshc->readdir_link);
+ readdir_len = (size_t) rc;
+ Curl_dyn_free(&sshc->readdir_link);
- /* append filename and extra output */
- result = Curl_dyn_addf(&sshc->readdir, " -> %s", sshc->readdir_filename);
-
- if(result) {
+ /* append filename and extra output */
+ result = Curl_dyn_addf(&sshc->readdir, " -> %s", sshc->readdir_filename);
+
+ if(result) {
sshc->readdir_line = NULL;
Curl_safefree(sshc->readdir_filename);
Curl_safefree(sshc->readdir_longentry);
state(conn, SSH_SFTP_CLOSE);
- sshc->actualcode = result;
+ sshc->actualcode = result;
break;
}
@@ -2242,27 +2242,27 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
break;
case SSH_SFTP_READDIR_BOTTOM:
- result = Curl_dyn_addn(&sshc->readdir, "\n", 1);
- if(!result)
- result = Curl_client_write(conn, CLIENTWRITE_BODY,
- Curl_dyn_ptr(&sshc->readdir),
- Curl_dyn_len(&sshc->readdir));
+ result = Curl_dyn_addn(&sshc->readdir, "\n", 1);
+ if(!result)
+ result = Curl_client_write(conn, CLIENTWRITE_BODY,
+ Curl_dyn_ptr(&sshc->readdir),
+ Curl_dyn_len(&sshc->readdir));
if(!result) {
/* output debug output if that is requested */
- Curl_debug(data, CURLINFO_DATA_IN,
- Curl_dyn_ptr(&sshc->readdir),
- Curl_dyn_len(&sshc->readdir));
- data->req.bytecount += Curl_dyn_len(&sshc->readdir);
+ Curl_debug(data, CURLINFO_DATA_IN,
+ Curl_dyn_ptr(&sshc->readdir),
+ Curl_dyn_len(&sshc->readdir));
+ data->req.bytecount += Curl_dyn_len(&sshc->readdir);
}
if(result) {
- Curl_dyn_free(&sshc->readdir);
+ Curl_dyn_free(&sshc->readdir);
state(conn, SSH_STOP);
}
- else {
- Curl_dyn_reset(&sshc->readdir);
+ else {
+ Curl_dyn_reset(&sshc->readdir);
state(conn, SSH_SFTP_READDIR);
- }
+ }
break;
case SSH_SFTP_READDIR_DONE:
@@ -2295,11 +2295,11 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
rc = LIBSSH2_ERROR_EAGAIN;
break;
}
- sftperr = libssh2_sftp_last_error(sshc->sftp_session);
+ sftperr = libssh2_sftp_last_error(sshc->sftp_session);
failf(data, "Could not open remote file for reading: %s",
- sftp_libssh2_strerror(sftperr));
+ sftp_libssh2_strerror(sftperr));
state(conn, SSH_SFTP_CLOSE);
- result = sftp_libssh2_error_to_CURLE(sftperr);
+ result = sftp_libssh2_error_to_CURLE(sftperr);
sshc->actualcode = result?result:CURLE_SSH;
break;
}
@@ -2564,9 +2564,9 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
}
/* upload data */
- data->req.size = data->state.infilesize;
- Curl_pgrsSetUploadSize(data, data->state.infilesize);
- Curl_setup_transfer(data, -1, -1, FALSE, FIRSTSOCKET);
+ data->req.size = data->state.infilesize;
+ Curl_pgrsSetUploadSize(data, data->state.infilesize);
+ Curl_setup_transfer(data, -1, -1, FALSE, FIRSTSOCKET);
/* not set by Curl_setup_transfer to preserve keepon bits */
conn->sockfd = conn->writesockfd;
@@ -2636,7 +2636,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
/* download data */
bytecount = (curl_off_t)sb.st_size;
- data->req.maxdownload = (curl_off_t)sb.st_size;
+ data->req.maxdownload = (curl_off_t)sb.st_size;
Curl_setup_transfer(data, FIRSTSOCKET, bytecount, FALSE, -1);
/* not set by Curl_setup_transfer to preserve keepon bits */
@@ -2843,7 +2843,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
Curl_safefree(sshc->readdir_filename);
Curl_safefree(sshc->readdir_longentry);
Curl_safefree(sshc->readdir_line);
- Curl_dyn_free(&sshc->readdir);
+ Curl_dyn_free(&sshc->readdir);
/* the code we are about to return */
result = sshc->actualcode;
@@ -2948,7 +2948,7 @@ static CURLcode ssh_multi_statemach(struct connectdata *conn, bool *done)
}
static CURLcode ssh_block_statemach(struct connectdata *conn,
- bool duringconnect)
+ bool duringconnect)
{
struct ssh_conn *sshc = &conn->proto.sshc;
CURLcode result = CURLE_OK;
@@ -2963,20 +2963,20 @@ static CURLcode ssh_block_statemach(struct connectdata *conn,
if(result)
break;
- if(Curl_pgrsUpdate(conn))
- return CURLE_ABORTED_BY_CALLBACK;
+ if(Curl_pgrsUpdate(conn))
+ return CURLE_ABORTED_BY_CALLBACK;
- result = Curl_speedcheck(data, now);
- if(result)
- break;
+ result = Curl_speedcheck(data, now);
+ if(result)
+ break;
- left = Curl_timeleft(data, NULL, duringconnect);
- if(left < 0) {
- failf(data, "Operation timed out");
- return CURLE_OPERATION_TIMEDOUT;
+ left = Curl_timeleft(data, NULL, duringconnect);
+ if(left < 0) {
+ failf(data, "Operation timed out");
+ return CURLE_OPERATION_TIMEDOUT;
}
- if(block) {
+ if(block) {
int dir = libssh2_session_block_directions(sshc->ssh_session);
curl_socket_t sock = conn->sock[FIRSTSOCKET];
curl_socket_t fd_read = CURL_SOCKET_BAD;
@@ -2987,7 +2987,7 @@ static CURLcode ssh_block_statemach(struct connectdata *conn,
fd_write = sock;
/* wait for the socket to become ready */
(void)Curl_socket_check(fd_read, CURL_SOCKET_BAD, fd_write,
- left>1000?1000:left);
+ left>1000?1000:left);
}
}
@@ -3001,7 +3001,7 @@ static CURLcode ssh_setup_connection(struct connectdata *conn)
{
struct SSHPROTO *ssh;
- conn->data->req.p.ssh = ssh = calloc(1, sizeof(struct SSHPROTO));
+ conn->data->req.p.ssh = ssh = calloc(1, sizeof(struct SSHPROTO));
if(!ssh)
return CURLE_OUT_OF_MEMORY;
@@ -3011,54 +3011,54 @@ static CURLcode ssh_setup_connection(struct connectdata *conn)
static Curl_recv scp_recv, sftp_recv;
static Curl_send scp_send, sftp_send;
-#ifndef CURL_DISABLE_PROXY
-static ssize_t ssh_tls_recv(libssh2_socket_t sock, void *buffer,
- size_t length, int flags, void **abstract)
-{
- struct connectdata *conn = (struct connectdata *)*abstract;
- ssize_t nread;
- CURLcode result;
- Curl_recv *backup = conn->recv[0];
- struct ssh_conn *ssh = &conn->proto.sshc;
- (void)flags;
-
- /* swap in the TLS reader function for this call only, and then swap back
- the SSH one again */
- conn->recv[0] = ssh->tls_recv;
- result = Curl_read(conn, sock, buffer, length, &nread);
- conn->recv[0] = backup;
- if(result == CURLE_AGAIN)
- return -EAGAIN; /* magic return code for libssh2 */
- else if(result)
- return -1; /* generic error */
- Curl_debug(conn->data, CURLINFO_DATA_IN, (char *)buffer, (size_t)nread);
- return nread;
-}
-
-static ssize_t ssh_tls_send(libssh2_socket_t sock, const void *buffer,
- size_t length, int flags, void **abstract)
-{
- struct connectdata *conn = (struct connectdata *)*abstract;
- ssize_t nwrite;
- CURLcode result;
- Curl_send *backup = conn->send[0];
- struct ssh_conn *ssh = &conn->proto.sshc;
- (void)flags;
-
- /* swap in the TLS writer function for this call only, and then swap back
- the SSH one again */
- conn->send[0] = ssh->tls_send;
- result = Curl_write(conn, sock, buffer, length, &nwrite);
- conn->send[0] = backup;
- if(result == CURLE_AGAIN)
- return -EAGAIN; /* magic return code for libssh2 */
- else if(result)
- return -1; /* error */
- Curl_debug(conn->data, CURLINFO_DATA_OUT, (char *)buffer, (size_t)nwrite);
- return nwrite;
-}
-#endif
-
+#ifndef CURL_DISABLE_PROXY
+static ssize_t ssh_tls_recv(libssh2_socket_t sock, void *buffer,
+ size_t length, int flags, void **abstract)
+{
+ struct connectdata *conn = (struct connectdata *)*abstract;
+ ssize_t nread;
+ CURLcode result;
+ Curl_recv *backup = conn->recv[0];
+ struct ssh_conn *ssh = &conn->proto.sshc;
+ (void)flags;
+
+ /* swap in the TLS reader function for this call only, and then swap back
+ the SSH one again */
+ conn->recv[0] = ssh->tls_recv;
+ result = Curl_read(conn, sock, buffer, length, &nread);
+ conn->recv[0] = backup;
+ if(result == CURLE_AGAIN)
+ return -EAGAIN; /* magic return code for libssh2 */
+ else if(result)
+ return -1; /* generic error */
+ Curl_debug(conn->data, CURLINFO_DATA_IN, (char *)buffer, (size_t)nread);
+ return nread;
+}
+
+static ssize_t ssh_tls_send(libssh2_socket_t sock, const void *buffer,
+ size_t length, int flags, void **abstract)
+{
+ struct connectdata *conn = (struct connectdata *)*abstract;
+ ssize_t nwrite;
+ CURLcode result;
+ Curl_send *backup = conn->send[0];
+ struct ssh_conn *ssh = &conn->proto.sshc;
+ (void)flags;
+
+ /* swap in the TLS writer function for this call only, and then swap back
+ the SSH one again */
+ conn->send[0] = ssh->tls_send;
+ result = Curl_write(conn, sock, buffer, length, &nwrite);
+ conn->send[0] = backup;
+ if(result == CURLE_AGAIN)
+ return -EAGAIN; /* magic return code for libssh2 */
+ else if(result)
+ return -1; /* error */
+ Curl_debug(conn->data, CURLINFO_DATA_OUT, (char *)buffer, (size_t)nwrite);
+ return nwrite;
+}
+#endif
+
/*
* Curl_ssh_connect() gets called from Curl_protocol_connect() to allow us to
* do protocol-specific actions at connect-time.
@@ -3073,7 +3073,7 @@ static CURLcode ssh_connect(struct connectdata *conn, bool *done)
struct Curl_easy *data = conn->data;
/* initialize per-handle data if not already */
- if(!data->req.p.ssh)
+ if(!data->req.p.ssh)
ssh_setup_connection(conn);
/* We default to persistent connections. We set this already in this connect
@@ -3100,61 +3100,61 @@ static CURLcode ssh_connect(struct connectdata *conn, bool *done)
return CURLE_FAILED_INIT;
}
-#ifndef CURL_DISABLE_PROXY
- if(conn->http_proxy.proxytype == CURLPROXY_HTTPS) {
- /*
- * This crazy union dance is here to avoid assigning a void pointer a
- * function pointer as it is invalid C. The problem is of course that
- * libssh2 has such an API...
- */
- union receive {
- void *recvp;
- ssize_t (*recvptr)(libssh2_socket_t, void *, size_t, int, void **);
- };
- union transfer {
- void *sendp;
- ssize_t (*sendptr)(libssh2_socket_t, const void *, size_t, int, void **);
- };
- union receive sshrecv;
- union transfer sshsend;
-
- sshrecv.recvptr = ssh_tls_recv;
- sshsend.sendptr = ssh_tls_send;
-
- infof(data, "Uses HTTPS proxy!\n");
- /*
- Setup libssh2 callbacks to make it read/write TLS from the socket.
-
- ssize_t
- recvcb(libssh2_socket_t sock, void *buffer, size_t length,
- int flags, void **abstract);
-
- ssize_t
- sendcb(libssh2_socket_t sock, const void *buffer, size_t length,
- int flags, void **abstract);
-
- */
- libssh2_session_callback_set(ssh->ssh_session,
- LIBSSH2_CALLBACK_RECV, sshrecv.recvp);
- libssh2_session_callback_set(ssh->ssh_session,
- LIBSSH2_CALLBACK_SEND, sshsend.sendp);
-
- /* Store the underlying TLS recv/send function pointers to be used when
- reading from the proxy */
- ssh->tls_recv = conn->recv[FIRSTSOCKET];
- ssh->tls_send = conn->send[FIRSTSOCKET];
- }
-
-#endif /* CURL_DISABLE_PROXY */
- if(conn->handler->protocol & CURLPROTO_SCP) {
- conn->recv[FIRSTSOCKET] = scp_recv;
- conn->send[FIRSTSOCKET] = scp_send;
- }
- else {
- conn->recv[FIRSTSOCKET] = sftp_recv;
- conn->send[FIRSTSOCKET] = sftp_send;
- }
-
+#ifndef CURL_DISABLE_PROXY
+ if(conn->http_proxy.proxytype == CURLPROXY_HTTPS) {
+ /*
+ * This crazy union dance is here to avoid assigning a void pointer a
+ * function pointer as it is invalid C. The problem is of course that
+ * libssh2 has such an API...
+ */
+ union receive {
+ void *recvp;
+ ssize_t (*recvptr)(libssh2_socket_t, void *, size_t, int, void **);
+ };
+ union transfer {
+ void *sendp;
+ ssize_t (*sendptr)(libssh2_socket_t, const void *, size_t, int, void **);
+ };
+ union receive sshrecv;
+ union transfer sshsend;
+
+ sshrecv.recvptr = ssh_tls_recv;
+ sshsend.sendptr = ssh_tls_send;
+
+ infof(data, "Uses HTTPS proxy!\n");
+ /*
+ Setup libssh2 callbacks to make it read/write TLS from the socket.
+
+ ssize_t
+ recvcb(libssh2_socket_t sock, void *buffer, size_t length,
+ int flags, void **abstract);
+
+ ssize_t
+ sendcb(libssh2_socket_t sock, const void *buffer, size_t length,
+ int flags, void **abstract);
+
+ */
+ libssh2_session_callback_set(ssh->ssh_session,
+ LIBSSH2_CALLBACK_RECV, sshrecv.recvp);
+ libssh2_session_callback_set(ssh->ssh_session,
+ LIBSSH2_CALLBACK_SEND, sshsend.sendp);
+
+ /* Store the underlying TLS recv/send function pointers to be used when
+ reading from the proxy */
+ ssh->tls_recv = conn->recv[FIRSTSOCKET];
+ ssh->tls_send = conn->send[FIRSTSOCKET];
+ }
+
+#endif /* CURL_DISABLE_PROXY */
+ if(conn->handler->protocol & CURLPROTO_SCP) {
+ conn->recv[FIRSTSOCKET] = scp_recv;
+ conn->send[FIRSTSOCKET] = scp_send;
+ }
+ else {
+ conn->recv[FIRSTSOCKET] = sftp_recv;
+ conn->send[FIRSTSOCKET] = sftp_send;
+ }
+
if(data->set.ssh_compression) {
#if LIBSSH2_VERSION_NUM >= 0x010208
if(libssh2_session_flag(ssh->ssh_session, LIBSSH2_FLAG_COMPRESS, 1) < 0)
@@ -3288,7 +3288,7 @@ static CURLcode scp_disconnect(struct connectdata *conn, bool dead_connection)
state(conn, SSH_SESSION_DISCONNECT);
- result = ssh_block_statemach(conn, FALSE);
+ result = ssh_block_statemach(conn, FALSE);
}
return result;
@@ -3299,7 +3299,7 @@ static CURLcode scp_disconnect(struct connectdata *conn, bool dead_connection)
static CURLcode ssh_done(struct connectdata *conn, CURLcode status)
{
CURLcode result = CURLE_OK;
- struct SSHPROTO *sftp_scp = conn->data->req.p.ssh;
+ struct SSHPROTO *sftp_scp = conn->data->req.p.ssh;
if(!status) {
/* run the state-machine */
@@ -3437,7 +3437,7 @@ static CURLcode sftp_disconnect(struct connectdata *conn, bool dead_connection)
if(conn->proto.sshc.ssh_session) {
/* only if there's a session still around to use! */
state(conn, SSH_SFTP_SHUTDOWN);
- result = ssh_block_statemach(conn, FALSE);
+ result = ssh_block_statemach(conn, FALSE);
}
DEBUGF(infof(conn->data, "SSH DISCONNECT is done\n"));
@@ -3512,7 +3512,7 @@ static ssize_t sftp_recv(struct connectdata *conn, int sockindex,
return nread;
}
-static const char *sftp_libssh2_strerror(unsigned long err)
+static const char *sftp_libssh2_strerror(unsigned long err)
{
switch(err) {
case LIBSSH2_FX_NO_SUCH_FILE:
diff --git a/contrib/libs/curl/lib/vssh/ssh.h b/contrib/libs/curl/lib/vssh/ssh.h
index ead9d65a07..00a70bac27 100644
--- a/contrib/libs/curl/lib/vssh/ssh.h
+++ b/contrib/libs/curl/lib/vssh/ssh.h
@@ -1,270 +1,270 @@
-#ifndef HEADER_CURL_SSH_H
-#define HEADER_CURL_SSH_H
-/***************************************************************************
- * _ _ ____ _
- * Project ___| | | | _ \| |
- * / __| | | | |_) | |
- * | (__| |_| | _ <| |___
- * \___|\___/|_| \_\_____|
- *
- * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
- *
- * You may opt to use, copy, modify, merge, publish, distribute and/or sell
- * copies of the Software, and permit persons to whom the Software is
- * furnished to do so, under the terms of the COPYING file.
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- ***************************************************************************/
-
-#include "curl_setup.h"
-
-#if defined(HAVE_LIBSSH2_H)
-#error #include <libssh2.h>
-#error #include <libssh2_sftp.h>
-#elif defined(HAVE_LIBSSH_LIBSSH_H)
-#error #include <libssh/libssh.h>
-#error #include <libssh/sftp.h>
-#elif defined(USE_WOLFSSH)
-#error #include <wolfssh/ssh.h>
-#error #include <wolfssh/wolfsftp.h>
-#endif
-
-/****************************************************************************
- * SSH unique setup
- ***************************************************************************/
-typedef enum {
- SSH_NO_STATE = -1, /* Used for "nextState" so say there is none */
- SSH_STOP = 0, /* do nothing state, stops the state machine */
-
- SSH_INIT, /* First state in SSH-CONNECT */
- SSH_S_STARTUP, /* Session startup */
- SSH_HOSTKEY, /* verify hostkey */
- SSH_AUTHLIST,
- SSH_AUTH_PKEY_INIT,
- SSH_AUTH_PKEY,
- SSH_AUTH_PASS_INIT,
- SSH_AUTH_PASS,
- SSH_AUTH_AGENT_INIT, /* initialize then wait for connection to agent */
- SSH_AUTH_AGENT_LIST, /* ask for list then wait for entire list to come */
- SSH_AUTH_AGENT, /* attempt one key at a time */
- SSH_AUTH_HOST_INIT,
- SSH_AUTH_HOST,
- SSH_AUTH_KEY_INIT,
- SSH_AUTH_KEY,
- SSH_AUTH_GSSAPI,
- SSH_AUTH_DONE,
- SSH_SFTP_INIT,
- SSH_SFTP_REALPATH, /* Last state in SSH-CONNECT */
-
- SSH_SFTP_QUOTE_INIT, /* First state in SFTP-DO */
- SSH_SFTP_POSTQUOTE_INIT, /* (Possibly) First state in SFTP-DONE */
- SSH_SFTP_QUOTE,
- SSH_SFTP_NEXT_QUOTE,
- SSH_SFTP_QUOTE_STAT,
- SSH_SFTP_QUOTE_SETSTAT,
- SSH_SFTP_QUOTE_SYMLINK,
- SSH_SFTP_QUOTE_MKDIR,
- SSH_SFTP_QUOTE_RENAME,
- SSH_SFTP_QUOTE_RMDIR,
- SSH_SFTP_QUOTE_UNLINK,
- SSH_SFTP_QUOTE_STATVFS,
- SSH_SFTP_GETINFO,
- SSH_SFTP_FILETIME,
- SSH_SFTP_TRANS_INIT,
- SSH_SFTP_UPLOAD_INIT,
- SSH_SFTP_CREATE_DIRS_INIT,
- SSH_SFTP_CREATE_DIRS,
- SSH_SFTP_CREATE_DIRS_MKDIR,
- SSH_SFTP_READDIR_INIT,
- SSH_SFTP_READDIR,
- SSH_SFTP_READDIR_LINK,
- SSH_SFTP_READDIR_BOTTOM,
- SSH_SFTP_READDIR_DONE,
- SSH_SFTP_DOWNLOAD_INIT,
- SSH_SFTP_DOWNLOAD_STAT, /* Last state in SFTP-DO */
- SSH_SFTP_CLOSE, /* Last state in SFTP-DONE */
- SSH_SFTP_SHUTDOWN, /* First state in SFTP-DISCONNECT */
- SSH_SCP_TRANS_INIT, /* First state in SCP-DO */
- SSH_SCP_UPLOAD_INIT,
- SSH_SCP_DOWNLOAD_INIT,
- SSH_SCP_DOWNLOAD,
- SSH_SCP_DONE,
- SSH_SCP_SEND_EOF,
- SSH_SCP_WAIT_EOF,
- SSH_SCP_WAIT_CLOSE,
- SSH_SCP_CHANNEL_FREE, /* Last state in SCP-DONE */
- SSH_SESSION_DISCONNECT, /* First state in SCP-DISCONNECT */
- SSH_SESSION_FREE, /* Last state in SCP/SFTP-DISCONNECT */
- SSH_QUIT,
- SSH_LAST /* never used */
-} sshstate;
-
-/* this struct is used in the HandleData struct which is part of the
- Curl_easy, which means this is used on a per-easy handle basis.
- Everything that is strictly related to a connection is banned from this
- struct. */
-struct SSHPROTO {
- char *path; /* the path we operate on */
-};
-
-/* ssh_conn is used for struct connection-oriented data in the connectdata
- struct */
-struct ssh_conn {
- const char *authlist; /* List of auth. methods, managed by libssh2 */
-
- /* common */
- const char *passphrase; /* pass-phrase to use */
- char *rsa_pub; /* path name */
- char *rsa; /* path name */
- bool authed; /* the connection has been authenticated fine */
- sshstate state; /* always use ssh.c:state() to change state! */
- sshstate nextstate; /* the state to goto after stopping */
- CURLcode actualcode; /* the actual error code */
- struct curl_slist *quote_item; /* for the quote option */
- char *quote_path1; /* two generic pointers for the QUOTE stuff */
- char *quote_path2;
-
- bool acceptfail; /* used by the SFTP_QUOTE (continue if
- quote command fails) */
- char *homedir; /* when doing SFTP we figure out home dir in the
- connect phase */
- char *readdir_line;
- /* end of READDIR stuff */
-
- int secondCreateDirs; /* counter use by the code to see if the
- second attempt has been made to change
- to/create a directory */
- char *slash_pos; /* used by the SFTP_CREATE_DIRS state */
-
- int orig_waitfor; /* default READ/WRITE bits wait for */
-
-#if defined(USE_LIBSSH)
- char *readdir_linkPath;
- size_t readdir_len, readdir_totalLen, readdir_currLen;
-/* our variables */
- unsigned kbd_state; /* 0 or 1 */
- ssh_key privkey;
- ssh_key pubkey;
- int auth_methods;
- ssh_session ssh_session;
- ssh_scp scp_session;
- sftp_session sftp_session;
- sftp_file sftp_file;
- sftp_dir sftp_dir;
-
- unsigned sftp_recv_state; /* 0 or 1 */
- int sftp_file_index; /* for async read */
- sftp_attributes readdir_attrs; /* used by the SFTP readdir actions */
- sftp_attributes readdir_link_attrs; /* used by the SFTP readdir actions */
- sftp_attributes quote_attrs; /* used by the SFTP_QUOTE state */
-
- const char *readdir_filename; /* points within readdir_attrs */
- const char *readdir_longentry;
- char *readdir_tmp;
-#elif defined(USE_LIBSSH2)
- struct dynbuf readdir_link;
- struct dynbuf readdir;
- char *readdir_filename;
- char *readdir_longentry;
-
- LIBSSH2_SFTP_ATTRIBUTES quote_attrs; /* used by the SFTP_QUOTE state */
-
- /* Here's a set of struct members used by the SFTP_READDIR state */
- LIBSSH2_SFTP_ATTRIBUTES readdir_attrs;
- LIBSSH2_SESSION *ssh_session; /* Secure Shell session */
- LIBSSH2_CHANNEL *ssh_channel; /* Secure Shell channel handle */
- LIBSSH2_SFTP *sftp_session; /* SFTP handle */
- LIBSSH2_SFTP_HANDLE *sftp_handle;
-
-#ifndef CURL_DISABLE_PROXY
- /* for HTTPS proxy storage */
- Curl_recv *tls_recv;
- Curl_send *tls_send;
-#endif
-
-#ifdef HAVE_LIBSSH2_AGENT_API
- LIBSSH2_AGENT *ssh_agent; /* proxy to ssh-agent/pageant */
- struct libssh2_agent_publickey *sshagent_identity,
- *sshagent_prev_identity;
-#endif
-
- /* note that HAVE_LIBSSH2_KNOWNHOST_API is a define set in the libssh2.h
- header */
-#ifdef HAVE_LIBSSH2_KNOWNHOST_API
- LIBSSH2_KNOWNHOSTS *kh;
-#endif
-#elif defined(USE_WOLFSSH)
- WOLFSSH *ssh_session;
- WOLFSSH_CTX *ctx;
- word32 handleSz;
- byte handle[WOLFSSH_MAX_HANDLE];
- curl_off_t offset;
-#endif /* USE_LIBSSH */
-};
-
-#if defined(USE_LIBSSH)
-
-#define CURL_LIBSSH_VERSION ssh_version(0)
-
-#elif defined(USE_LIBSSH2)
-
-/* Feature detection based on version numbers to better work with
- non-configure platforms */
-
-#if !defined(LIBSSH2_VERSION_NUM) || (LIBSSH2_VERSION_NUM < 0x001000)
-# error "SCP/SFTP protocols require libssh2 0.16 or later"
-#endif
-
-#if LIBSSH2_VERSION_NUM >= 0x010000
-#define HAVE_LIBSSH2_SFTP_SEEK64 1
-#endif
-
-#if LIBSSH2_VERSION_NUM >= 0x010100
-#define HAVE_LIBSSH2_VERSION 1
-#endif
-
-#if LIBSSH2_VERSION_NUM >= 0x010205
-#define HAVE_LIBSSH2_INIT 1
-#define HAVE_LIBSSH2_EXIT 1
-#endif
-
-#if LIBSSH2_VERSION_NUM >= 0x010206
-#define HAVE_LIBSSH2_KNOWNHOST_CHECKP 1
-#define HAVE_LIBSSH2_SCP_SEND64 1
-#endif
-
-#if LIBSSH2_VERSION_NUM >= 0x010208
-#define HAVE_LIBSSH2_SESSION_HANDSHAKE 1
-#endif
-
-#ifdef HAVE_LIBSSH2_VERSION
-/* get it run-time if possible */
-#define CURL_LIBSSH2_VERSION libssh2_version(0)
-#else
-/* use build-time if run-time not possible */
-#define CURL_LIBSSH2_VERSION LIBSSH2_VERSION
-#endif
-
-#endif /* USE_LIBSSH2 */
-
-#ifdef USE_SSH
-
-extern const struct Curl_handler Curl_handler_scp;
-extern const struct Curl_handler Curl_handler_sftp;
-
-/* generic SSH backend functions */
-CURLcode Curl_ssh_init(void);
-void Curl_ssh_cleanup(void);
-size_t Curl_ssh_version(char *buffer, size_t buflen);
-#else
-/* for non-SSH builds */
-#define Curl_ssh_cleanup()
-#endif
-
-#endif /* HEADER_CURL_SSH_H */
+#ifndef HEADER_CURL_SSH_H
+#define HEADER_CURL_SSH_H
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 1998 - 2020, 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
+ * are also available at https://curl.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+
+#include "curl_setup.h"
+
+#if defined(HAVE_LIBSSH2_H)
+#error #include <libssh2.h>
+#error #include <libssh2_sftp.h>
+#elif defined(HAVE_LIBSSH_LIBSSH_H)
+#error #include <libssh/libssh.h>
+#error #include <libssh/sftp.h>
+#elif defined(USE_WOLFSSH)
+#error #include <wolfssh/ssh.h>
+#error #include <wolfssh/wolfsftp.h>
+#endif
+
+/****************************************************************************
+ * SSH unique setup
+ ***************************************************************************/
+typedef enum {
+ SSH_NO_STATE = -1, /* Used for "nextState" so say there is none */
+ SSH_STOP = 0, /* do nothing state, stops the state machine */
+
+ SSH_INIT, /* First state in SSH-CONNECT */
+ SSH_S_STARTUP, /* Session startup */
+ SSH_HOSTKEY, /* verify hostkey */
+ SSH_AUTHLIST,
+ SSH_AUTH_PKEY_INIT,
+ SSH_AUTH_PKEY,
+ SSH_AUTH_PASS_INIT,
+ SSH_AUTH_PASS,
+ SSH_AUTH_AGENT_INIT, /* initialize then wait for connection to agent */
+ SSH_AUTH_AGENT_LIST, /* ask for list then wait for entire list to come */
+ SSH_AUTH_AGENT, /* attempt one key at a time */
+ SSH_AUTH_HOST_INIT,
+ SSH_AUTH_HOST,
+ SSH_AUTH_KEY_INIT,
+ SSH_AUTH_KEY,
+ SSH_AUTH_GSSAPI,
+ SSH_AUTH_DONE,
+ SSH_SFTP_INIT,
+ SSH_SFTP_REALPATH, /* Last state in SSH-CONNECT */
+
+ SSH_SFTP_QUOTE_INIT, /* First state in SFTP-DO */
+ SSH_SFTP_POSTQUOTE_INIT, /* (Possibly) First state in SFTP-DONE */
+ SSH_SFTP_QUOTE,
+ SSH_SFTP_NEXT_QUOTE,
+ SSH_SFTP_QUOTE_STAT,
+ SSH_SFTP_QUOTE_SETSTAT,
+ SSH_SFTP_QUOTE_SYMLINK,
+ SSH_SFTP_QUOTE_MKDIR,
+ SSH_SFTP_QUOTE_RENAME,
+ SSH_SFTP_QUOTE_RMDIR,
+ SSH_SFTP_QUOTE_UNLINK,
+ SSH_SFTP_QUOTE_STATVFS,
+ SSH_SFTP_GETINFO,
+ SSH_SFTP_FILETIME,
+ SSH_SFTP_TRANS_INIT,
+ SSH_SFTP_UPLOAD_INIT,
+ SSH_SFTP_CREATE_DIRS_INIT,
+ SSH_SFTP_CREATE_DIRS,
+ SSH_SFTP_CREATE_DIRS_MKDIR,
+ SSH_SFTP_READDIR_INIT,
+ SSH_SFTP_READDIR,
+ SSH_SFTP_READDIR_LINK,
+ SSH_SFTP_READDIR_BOTTOM,
+ SSH_SFTP_READDIR_DONE,
+ SSH_SFTP_DOWNLOAD_INIT,
+ SSH_SFTP_DOWNLOAD_STAT, /* Last state in SFTP-DO */
+ SSH_SFTP_CLOSE, /* Last state in SFTP-DONE */
+ SSH_SFTP_SHUTDOWN, /* First state in SFTP-DISCONNECT */
+ SSH_SCP_TRANS_INIT, /* First state in SCP-DO */
+ SSH_SCP_UPLOAD_INIT,
+ SSH_SCP_DOWNLOAD_INIT,
+ SSH_SCP_DOWNLOAD,
+ SSH_SCP_DONE,
+ SSH_SCP_SEND_EOF,
+ SSH_SCP_WAIT_EOF,
+ SSH_SCP_WAIT_CLOSE,
+ SSH_SCP_CHANNEL_FREE, /* Last state in SCP-DONE */
+ SSH_SESSION_DISCONNECT, /* First state in SCP-DISCONNECT */
+ SSH_SESSION_FREE, /* Last state in SCP/SFTP-DISCONNECT */
+ SSH_QUIT,
+ SSH_LAST /* never used */
+} sshstate;
+
+/* this struct is used in the HandleData struct which is part of the
+ Curl_easy, which means this is used on a per-easy handle basis.
+ Everything that is strictly related to a connection is banned from this
+ struct. */
+struct SSHPROTO {
+ char *path; /* the path we operate on */
+};
+
+/* ssh_conn is used for struct connection-oriented data in the connectdata
+ struct */
+struct ssh_conn {
+ const char *authlist; /* List of auth. methods, managed by libssh2 */
+
+ /* common */
+ const char *passphrase; /* pass-phrase to use */
+ char *rsa_pub; /* path name */
+ char *rsa; /* path name */
+ bool authed; /* the connection has been authenticated fine */
+ sshstate state; /* always use ssh.c:state() to change state! */
+ sshstate nextstate; /* the state to goto after stopping */
+ CURLcode actualcode; /* the actual error code */
+ struct curl_slist *quote_item; /* for the quote option */
+ char *quote_path1; /* two generic pointers for the QUOTE stuff */
+ char *quote_path2;
+
+ bool acceptfail; /* used by the SFTP_QUOTE (continue if
+ quote command fails) */
+ char *homedir; /* when doing SFTP we figure out home dir in the
+ connect phase */
+ char *readdir_line;
+ /* end of READDIR stuff */
+
+ int secondCreateDirs; /* counter use by the code to see if the
+ second attempt has been made to change
+ to/create a directory */
+ char *slash_pos; /* used by the SFTP_CREATE_DIRS state */
+
+ int orig_waitfor; /* default READ/WRITE bits wait for */
+
+#if defined(USE_LIBSSH)
+ char *readdir_linkPath;
+ size_t readdir_len, readdir_totalLen, readdir_currLen;
+/* our variables */
+ unsigned kbd_state; /* 0 or 1 */
+ ssh_key privkey;
+ ssh_key pubkey;
+ int auth_methods;
+ ssh_session ssh_session;
+ ssh_scp scp_session;
+ sftp_session sftp_session;
+ sftp_file sftp_file;
+ sftp_dir sftp_dir;
+
+ unsigned sftp_recv_state; /* 0 or 1 */
+ int sftp_file_index; /* for async read */
+ sftp_attributes readdir_attrs; /* used by the SFTP readdir actions */
+ sftp_attributes readdir_link_attrs; /* used by the SFTP readdir actions */
+ sftp_attributes quote_attrs; /* used by the SFTP_QUOTE state */
+
+ const char *readdir_filename; /* points within readdir_attrs */
+ const char *readdir_longentry;
+ char *readdir_tmp;
+#elif defined(USE_LIBSSH2)
+ struct dynbuf readdir_link;
+ struct dynbuf readdir;
+ char *readdir_filename;
+ char *readdir_longentry;
+
+ LIBSSH2_SFTP_ATTRIBUTES quote_attrs; /* used by the SFTP_QUOTE state */
+
+ /* Here's a set of struct members used by the SFTP_READDIR state */
+ LIBSSH2_SFTP_ATTRIBUTES readdir_attrs;
+ LIBSSH2_SESSION *ssh_session; /* Secure Shell session */
+ LIBSSH2_CHANNEL *ssh_channel; /* Secure Shell channel handle */
+ LIBSSH2_SFTP *sftp_session; /* SFTP handle */
+ LIBSSH2_SFTP_HANDLE *sftp_handle;
+
+#ifndef CURL_DISABLE_PROXY
+ /* for HTTPS proxy storage */
+ Curl_recv *tls_recv;
+ Curl_send *tls_send;
+#endif
+
+#ifdef HAVE_LIBSSH2_AGENT_API
+ LIBSSH2_AGENT *ssh_agent; /* proxy to ssh-agent/pageant */
+ struct libssh2_agent_publickey *sshagent_identity,
+ *sshagent_prev_identity;
+#endif
+
+ /* note that HAVE_LIBSSH2_KNOWNHOST_API is a define set in the libssh2.h
+ header */
+#ifdef HAVE_LIBSSH2_KNOWNHOST_API
+ LIBSSH2_KNOWNHOSTS *kh;
+#endif
+#elif defined(USE_WOLFSSH)
+ WOLFSSH *ssh_session;
+ WOLFSSH_CTX *ctx;
+ word32 handleSz;
+ byte handle[WOLFSSH_MAX_HANDLE];
+ curl_off_t offset;
+#endif /* USE_LIBSSH */
+};
+
+#if defined(USE_LIBSSH)
+
+#define CURL_LIBSSH_VERSION ssh_version(0)
+
+#elif defined(USE_LIBSSH2)
+
+/* Feature detection based on version numbers to better work with
+ non-configure platforms */
+
+#if !defined(LIBSSH2_VERSION_NUM) || (LIBSSH2_VERSION_NUM < 0x001000)
+# error "SCP/SFTP protocols require libssh2 0.16 or later"
+#endif
+
+#if LIBSSH2_VERSION_NUM >= 0x010000
+#define HAVE_LIBSSH2_SFTP_SEEK64 1
+#endif
+
+#if LIBSSH2_VERSION_NUM >= 0x010100
+#define HAVE_LIBSSH2_VERSION 1
+#endif
+
+#if LIBSSH2_VERSION_NUM >= 0x010205
+#define HAVE_LIBSSH2_INIT 1
+#define HAVE_LIBSSH2_EXIT 1
+#endif
+
+#if LIBSSH2_VERSION_NUM >= 0x010206
+#define HAVE_LIBSSH2_KNOWNHOST_CHECKP 1
+#define HAVE_LIBSSH2_SCP_SEND64 1
+#endif
+
+#if LIBSSH2_VERSION_NUM >= 0x010208
+#define HAVE_LIBSSH2_SESSION_HANDSHAKE 1
+#endif
+
+#ifdef HAVE_LIBSSH2_VERSION
+/* get it run-time if possible */
+#define CURL_LIBSSH2_VERSION libssh2_version(0)
+#else
+/* use build-time if run-time not possible */
+#define CURL_LIBSSH2_VERSION LIBSSH2_VERSION
+#endif
+
+#endif /* USE_LIBSSH2 */
+
+#ifdef USE_SSH
+
+extern const struct Curl_handler Curl_handler_scp;
+extern const struct Curl_handler Curl_handler_sftp;
+
+/* generic SSH backend functions */
+CURLcode Curl_ssh_init(void);
+void Curl_ssh_cleanup(void);
+size_t Curl_ssh_version(char *buffer, size_t buflen);
+#else
+/* for non-SSH builds */
+#define Curl_ssh_cleanup()
+#endif
+
+#endif /* HEADER_CURL_SSH_H */
diff --git a/contrib/libs/curl/lib/vssh/wolfssh.c b/contrib/libs/curl/lib/vssh/wolfssh.c
index d0cb5ed360..d2bd77b513 100644
--- a/contrib/libs/curl/lib/vssh/wolfssh.c
+++ b/contrib/libs/curl/lib/vssh/wolfssh.c
@@ -1,1156 +1,1156 @@
-/***************************************************************************
- * _ _ ____ _
- * Project ___| | | | _ \| |
- * / __| | | | |_) | |
- * | (__| |_| | _ <| |___
- * \___|\___/|_| \_\_____|
- *
- * Copyright (C) 2019 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
- *
- * You may opt to use, copy, modify, merge, publish, distribute and/or sell
- * copies of the Software, and permit persons to whom the Software is
- * furnished to do so, under the terms of the COPYING file.
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- ***************************************************************************/
-
-#include "curl_setup.h"
-
-#ifdef USE_WOLFSSH
-
-#include <limits.h>
-
-#error #include <wolfssh/ssh.h>
-#error #include <wolfssh/wolfsftp.h>
-#include "urldata.h"
-#include "connect.h"
-#include "sendf.h"
-#include "progress.h"
-#include "curl_path.h"
-#include "strtoofft.h"
-#include "transfer.h"
-#include "speedcheck.h"
-#include "select.h"
-#include "multiif.h"
-#include "warnless.h"
-
-/* The last 3 #include files should be in this order */
-#include "curl_printf.h"
-#include "curl_memory.h"
-#include "memdebug.h"
-
-static CURLcode wssh_connect(struct connectdata *conn, bool *done);
-static CURLcode wssh_multi_statemach(struct connectdata *conn, bool *done);
-static CURLcode wssh_do(struct connectdata *conn, bool *done);
-#if 0
-static CURLcode wscp_done(struct connectdata *conn,
- CURLcode, bool premature);
-static CURLcode wscp_doing(struct connectdata *conn,
- bool *dophase_done);
-static CURLcode wscp_disconnect(struct connectdata *conn,
- bool dead_connection);
-#endif
-static CURLcode wsftp_done(struct connectdata *conn,
- CURLcode, bool premature);
-static CURLcode wsftp_doing(struct connectdata *conn,
- bool *dophase_done);
-static CURLcode wsftp_disconnect(struct connectdata *conn, bool dead);
-static int wssh_getsock(struct connectdata *conn,
- curl_socket_t *sock);
-static int wssh_perform_getsock(const struct connectdata *conn,
- curl_socket_t *sock);
-static CURLcode wssh_setup_connection(struct connectdata *conn);
-
-#if 0
-/*
- * SCP protocol handler.
- */
-
-const struct Curl_handler Curl_handler_scp = {
- "SCP", /* scheme */
- wssh_setup_connection, /* setup_connection */
- wssh_do, /* do_it */
- wscp_done, /* done */
- ZERO_NULL, /* do_more */
- wssh_connect, /* connect_it */
- wssh_multi_statemach, /* connecting */
- wscp_doing, /* doing */
- wssh_getsock, /* proto_getsock */
- wssh_getsock, /* doing_getsock */
- ZERO_NULL, /* domore_getsock */
- wssh_perform_getsock, /* perform_getsock */
- wscp_disconnect, /* disconnect */
- ZERO_NULL, /* readwrite */
- ZERO_NULL, /* connection_check */
- PORT_SSH, /* defport */
- CURLPROTO_SCP, /* protocol */
- PROTOPT_DIRLOCK | PROTOPT_CLOSEACTION
- | PROTOPT_NOURLQUERY /* flags */
-};
-
-#endif
-
-/*
- * SFTP protocol handler.
- */
-
-const struct Curl_handler Curl_handler_sftp = {
- "SFTP", /* scheme */
- wssh_setup_connection, /* setup_connection */
- wssh_do, /* do_it */
- wsftp_done, /* done */
- ZERO_NULL, /* do_more */
- wssh_connect, /* connect_it */
- wssh_multi_statemach, /* connecting */
- wsftp_doing, /* doing */
- wssh_getsock, /* proto_getsock */
- wssh_getsock, /* doing_getsock */
- ZERO_NULL, /* domore_getsock */
- wssh_perform_getsock, /* perform_getsock */
- wsftp_disconnect, /* disconnect */
- ZERO_NULL, /* readwrite */
- ZERO_NULL, /* connection_check */
- PORT_SSH, /* defport */
- CURLPROTO_SFTP, /* protocol */
- PROTOPT_DIRLOCK | PROTOPT_CLOSEACTION
- | PROTOPT_NOURLQUERY /* flags */
-};
-
-/*
- * SSH State machine related code
- */
-/* This is the ONLY way to change SSH state! */
-static void state(struct connectdata *conn, sshstate nowstate)
-{
- struct ssh_conn *sshc = &conn->proto.sshc;
-#if defined(DEBUGBUILD) && !defined(CURL_DISABLE_VERBOSE_STRINGS)
- /* for debug purposes */
- static const char * const names[] = {
- "SSH_STOP",
- "SSH_INIT",
- "SSH_S_STARTUP",
- "SSH_HOSTKEY",
- "SSH_AUTHLIST",
- "SSH_AUTH_PKEY_INIT",
- "SSH_AUTH_PKEY",
- "SSH_AUTH_PASS_INIT",
- "SSH_AUTH_PASS",
- "SSH_AUTH_AGENT_INIT",
- "SSH_AUTH_AGENT_LIST",
- "SSH_AUTH_AGENT",
- "SSH_AUTH_HOST_INIT",
- "SSH_AUTH_HOST",
- "SSH_AUTH_KEY_INIT",
- "SSH_AUTH_KEY",
- "SSH_AUTH_GSSAPI",
- "SSH_AUTH_DONE",
- "SSH_SFTP_INIT",
- "SSH_SFTP_REALPATH",
- "SSH_SFTP_QUOTE_INIT",
- "SSH_SFTP_POSTQUOTE_INIT",
- "SSH_SFTP_QUOTE",
- "SSH_SFTP_NEXT_QUOTE",
- "SSH_SFTP_QUOTE_STAT",
- "SSH_SFTP_QUOTE_SETSTAT",
- "SSH_SFTP_QUOTE_SYMLINK",
- "SSH_SFTP_QUOTE_MKDIR",
- "SSH_SFTP_QUOTE_RENAME",
- "SSH_SFTP_QUOTE_RMDIR",
- "SSH_SFTP_QUOTE_UNLINK",
- "SSH_SFTP_QUOTE_STATVFS",
- "SSH_SFTP_GETINFO",
- "SSH_SFTP_FILETIME",
- "SSH_SFTP_TRANS_INIT",
- "SSH_SFTP_UPLOAD_INIT",
- "SSH_SFTP_CREATE_DIRS_INIT",
- "SSH_SFTP_CREATE_DIRS",
- "SSH_SFTP_CREATE_DIRS_MKDIR",
- "SSH_SFTP_READDIR_INIT",
- "SSH_SFTP_READDIR",
- "SSH_SFTP_READDIR_LINK",
- "SSH_SFTP_READDIR_BOTTOM",
- "SSH_SFTP_READDIR_DONE",
- "SSH_SFTP_DOWNLOAD_INIT",
- "SSH_SFTP_DOWNLOAD_STAT",
- "SSH_SFTP_CLOSE",
- "SSH_SFTP_SHUTDOWN",
- "SSH_SCP_TRANS_INIT",
- "SSH_SCP_UPLOAD_INIT",
- "SSH_SCP_DOWNLOAD_INIT",
- "SSH_SCP_DOWNLOAD",
- "SSH_SCP_DONE",
- "SSH_SCP_SEND_EOF",
- "SSH_SCP_WAIT_EOF",
- "SSH_SCP_WAIT_CLOSE",
- "SSH_SCP_CHANNEL_FREE",
- "SSH_SESSION_DISCONNECT",
- "SSH_SESSION_FREE",
- "QUIT"
- };
-
- /* a precaution to make sure the lists are in sync */
- DEBUGASSERT(sizeof(names)/sizeof(names[0]) == SSH_LAST);
-
- if(sshc->state != nowstate) {
- infof(conn->data, "wolfssh %p state change from %s to %s\n",
- (void *)sshc, names[sshc->state], names[nowstate]);
- }
-#endif
-
- sshc->state = nowstate;
-}
-
-static ssize_t wscp_send(struct connectdata *conn, int sockindex,
- const void *mem, size_t len, CURLcode *err)
-{
- ssize_t nwrite = 0;
- (void)conn;
- (void)sockindex; /* we only support SCP on the fixed known primary socket */
- (void)mem;
- (void)len;
- (void)err;
-
- return nwrite;
-}
-
-static ssize_t wscp_recv(struct connectdata *conn, int sockindex,
- char *mem, size_t len, CURLcode *err)
-{
- ssize_t nread = 0;
- (void)conn;
- (void)sockindex; /* we only support SCP on the fixed known primary socket */
- (void)mem;
- (void)len;
- (void)err;
-
- return nread;
-}
-
-/* return number of sent bytes */
-static ssize_t wsftp_send(struct connectdata *conn, int sockindex,
- const void *mem, size_t len, CURLcode *err)
-{
- struct ssh_conn *sshc = &conn->proto.sshc;
- word32 offset[2];
- int rc;
- (void)sockindex;
-
- offset[0] = (word32)sshc->offset&0xFFFFFFFF;
- offset[1] = (word32)(sshc->offset>>32)&0xFFFFFFFF;
-
- rc = wolfSSH_SFTP_SendWritePacket(sshc->ssh_session, sshc->handle,
- sshc->handleSz,
- &offset[0],
- (byte *)mem, (word32)len);
-
- if(rc == WS_FATAL_ERROR)
- rc = wolfSSH_get_error(sshc->ssh_session);
- if(rc == WS_WANT_READ) {
- conn->waitfor = KEEP_RECV;
- *err = CURLE_AGAIN;
- return -1;
- }
- else if(rc == WS_WANT_WRITE) {
- conn->waitfor = KEEP_SEND;
- *err = CURLE_AGAIN;
- return -1;
- }
- if(rc < 0) {
- failf(conn->data, "wolfSSH_SFTP_SendWritePacket returned %d\n", rc);
- return -1;
- }
- DEBUGASSERT(rc == (int)len);
- infof(conn->data, "sent %zd bytes SFTP from offset %zd\n",
- len, sshc->offset);
- sshc->offset += len;
- return (ssize_t)rc;
-}
-
-/*
- * Return number of received (decrypted) bytes
- * or <0 on error
- */
-static ssize_t wsftp_recv(struct connectdata *conn, int sockindex,
- char *mem, size_t len, CURLcode *err)
-{
- int rc;
- struct ssh_conn *sshc = &conn->proto.sshc;
- word32 offset[2];
- (void)sockindex;
-
- offset[0] = (word32)sshc->offset&0xFFFFFFFF;
- offset[1] = (word32)(sshc->offset>>32)&0xFFFFFFFF;
-
- rc = wolfSSH_SFTP_SendReadPacket(sshc->ssh_session, sshc->handle,
- sshc->handleSz,
- &offset[0],
- (byte *)mem, (word32)len);
- if(rc == WS_FATAL_ERROR)
- rc = wolfSSH_get_error(sshc->ssh_session);
- if(rc == WS_WANT_READ) {
- conn->waitfor = KEEP_RECV;
- *err = CURLE_AGAIN;
- return -1;
- }
- else if(rc == WS_WANT_WRITE) {
- conn->waitfor = KEEP_SEND;
- *err = CURLE_AGAIN;
- return -1;
- }
-
- DEBUGASSERT(rc <= (int)len);
-
- if(rc < 0) {
- failf(conn->data, "wolfSSH_SFTP_SendReadPacket returned %d\n", rc);
- return -1;
- }
- sshc->offset += len;
-
- return (ssize_t)rc;
-}
-
-/*
- * SSH setup and connection
- */
-static CURLcode wssh_setup_connection(struct connectdata *conn)
-{
- struct SSHPROTO *ssh;
-
- conn->data->req.p.ssh = ssh = calloc(1, sizeof(struct SSHPROTO));
- if(!ssh)
- return CURLE_OUT_OF_MEMORY;
-
- return CURLE_OK;
-}
-
-static Curl_recv wscp_recv, wsftp_recv;
-static Curl_send wscp_send, wsftp_send;
-
-static int userauth(byte authtype,
- WS_UserAuthData* authdata,
- void *ctx)
-{
- struct connectdata *conn = ctx;
- DEBUGF(infof(conn->data, "wolfssh callback: type %s\n",
- authtype == WOLFSSH_USERAUTH_PASSWORD ? "PASSWORD" :
- "PUBLICCKEY"));
- if(authtype == WOLFSSH_USERAUTH_PASSWORD) {
- authdata->sf.password.password = (byte *)conn->passwd;
- authdata->sf.password.passwordSz = (word32) strlen(conn->passwd);
- }
-
- return 0;
-}
-
-static CURLcode wssh_connect(struct connectdata *conn, bool *done)
-{
- struct Curl_easy *data = conn->data;
- struct ssh_conn *sshc;
- curl_socket_t sock = conn->sock[FIRSTSOCKET];
- int rc;
-
- /* initialize per-handle data if not already */
- if(!data->req.p.ssh)
- wssh_setup_connection(conn);
-
- /* We default to persistent connections. We set this already in this connect
- function to make the re-use checks properly be able to check this bit. */
- connkeep(conn, "SSH default");
-
- if(conn->handler->protocol & CURLPROTO_SCP) {
- conn->recv[FIRSTSOCKET] = wscp_recv;
- conn->send[FIRSTSOCKET] = wscp_send;
- }
- else {
- conn->recv[FIRSTSOCKET] = wsftp_recv;
- conn->send[FIRSTSOCKET] = wsftp_send;
- }
- sshc = &conn->proto.sshc;
- sshc->ctx = wolfSSH_CTX_new(WOLFSSH_ENDPOINT_CLIENT, NULL);
- if(!sshc->ctx) {
- failf(data, "No wolfSSH context");
- goto error;
- }
-
- sshc->ssh_session = wolfSSH_new(sshc->ctx);
- if(sshc->ssh_session == NULL) {
- failf(data, "No wolfSSH session");
- goto error;
- }
-
- rc = wolfSSH_SetUsername(sshc->ssh_session, conn->user);
- if(rc != WS_SUCCESS) {
- failf(data, "wolfSSH failed to set user name");
- goto error;
- }
-
- /* set callback for authentication */
- wolfSSH_SetUserAuth(sshc->ctx, userauth);
- wolfSSH_SetUserAuthCtx(sshc->ssh_session, conn);
-
- rc = wolfSSH_set_fd(sshc->ssh_session, (int)sock);
- if(rc) {
- failf(data, "wolfSSH failed to set socket");
- goto error;
- }
-
-#if 0
- wolfSSH_Debugging_ON();
-#endif
-
- *done = TRUE;
- if(conn->handler->protocol & CURLPROTO_SCP)
- state(conn, SSH_INIT);
- else
- state(conn, SSH_SFTP_INIT);
-
- return wssh_multi_statemach(conn, done);
- error:
- wolfSSH_free(sshc->ssh_session);
- wolfSSH_CTX_free(sshc->ctx);
- return CURLE_FAILED_INIT;
-}
-
-/*
- * wssh_statemach_act() runs the SSH state machine as far as it can without
- * blocking and without reaching the end. The data the pointer 'block' points
- * to will be set to TRUE if the wolfssh function returns EAGAIN meaning it
- * wants to be called again when the socket is ready
- */
-
-static CURLcode wssh_statemach_act(struct connectdata *conn, bool *block)
-{
- CURLcode result = CURLE_OK;
- struct ssh_conn *sshc = &conn->proto.sshc;
- struct Curl_easy *data = conn->data;
- struct SSHPROTO *sftp_scp = data->req.p.ssh;
- WS_SFTPNAME *name;
- int rc = 0;
- *block = FALSE; /* we're not blocking by default */
-
- do {
- switch(sshc->state) {
- case SSH_INIT:
- state(conn, SSH_S_STARTUP);
- /* FALLTHROUGH */
- case SSH_S_STARTUP:
- rc = wolfSSH_connect(sshc->ssh_session);
- if(rc != WS_SUCCESS)
- rc = wolfSSH_get_error(sshc->ssh_session);
- if(rc == WS_WANT_READ) {
- *block = TRUE;
- conn->waitfor = KEEP_RECV;
- return CURLE_OK;
- }
- else if(rc == WS_WANT_WRITE) {
- *block = TRUE;
- conn->waitfor = KEEP_SEND;
- return CURLE_OK;
- }
- else if(rc != WS_SUCCESS) {
- state(conn, SSH_STOP);
- return CURLE_SSH;
- }
- infof(data, "wolfssh connected!\n");
- state(conn, SSH_STOP);
- break;
- case SSH_STOP:
- break;
-
- case SSH_SFTP_INIT:
- rc = wolfSSH_SFTP_connect(sshc->ssh_session);
- if(rc != WS_SUCCESS)
- rc = wolfSSH_get_error(sshc->ssh_session);
- if(rc == WS_WANT_READ) {
- *block = TRUE;
- conn->waitfor = KEEP_RECV;
- return CURLE_OK;
- }
- else if(rc == WS_WANT_WRITE) {
- *block = TRUE;
- conn->waitfor = KEEP_SEND;
- return CURLE_OK;
- }
- else if(rc == WS_SUCCESS) {
- infof(data, "wolfssh SFTP connected!\n");
- state(conn, SSH_SFTP_REALPATH);
- }
- else {
- failf(data, "wolfssh SFTP connect error %d", rc);
- return CURLE_SSH;
- }
- break;
- case SSH_SFTP_REALPATH:
- name = wolfSSH_SFTP_RealPath(sshc->ssh_session, (char *)".");
- rc = wolfSSH_get_error(sshc->ssh_session);
- if(rc == WS_WANT_READ) {
- *block = TRUE;
- conn->waitfor = KEEP_RECV;
- return CURLE_OK;
- }
- else if(rc == WS_WANT_WRITE) {
- *block = TRUE;
- conn->waitfor = KEEP_SEND;
- return CURLE_OK;
- }
- else if(name && (rc == WS_SUCCESS)) {
- sshc->homedir = malloc(name->fSz + 1);
- if(!sshc->homedir) {
- sshc->actualcode = CURLE_OUT_OF_MEMORY;
- }
- else {
- memcpy(sshc->homedir, name->fName, name->fSz);
- sshc->homedir[name->fSz] = 0;
- infof(data, "wolfssh SFTP realpath succeeded!\n");
- }
- wolfSSH_SFTPNAME_list_free(name);
- state(conn, SSH_STOP);
- return CURLE_OK;
- }
- failf(data, "wolfssh SFTP realpath %d", rc);
- return CURLE_SSH;
-
- case SSH_SFTP_QUOTE_INIT:
- result = Curl_getworkingpath(conn, sshc->homedir, &sftp_scp->path);
- if(result) {
- sshc->actualcode = result;
- state(conn, SSH_STOP);
- break;
- }
-
- if(data->set.quote) {
- infof(data, "Sending quote commands\n");
- sshc->quote_item = data->set.quote;
- state(conn, SSH_SFTP_QUOTE);
- }
- else {
- state(conn, SSH_SFTP_GETINFO);
- }
- break;
- case SSH_SFTP_GETINFO:
- if(data->set.get_filetime) {
- state(conn, SSH_SFTP_FILETIME);
- }
- else {
- state(conn, SSH_SFTP_TRANS_INIT);
- }
- break;
- case SSH_SFTP_TRANS_INIT:
- if(data->set.upload)
- state(conn, SSH_SFTP_UPLOAD_INIT);
- else {
- if(sftp_scp->path[strlen(sftp_scp->path)-1] == '/')
- state(conn, SSH_SFTP_READDIR_INIT);
- else
- state(conn, SSH_SFTP_DOWNLOAD_INIT);
- }
- break;
- case SSH_SFTP_UPLOAD_INIT: {
- word32 flags;
- WS_SFTP_FILEATRB createattrs;
- if(data->state.resume_from) {
- WS_SFTP_FILEATRB attrs;
- if(data->state.resume_from < 0) {
- rc = wolfSSH_SFTP_STAT(sshc->ssh_session, sftp_scp->path,
- &attrs);
- if(rc != WS_SUCCESS)
- break;
-
- if(rc) {
- data->state.resume_from = 0;
- }
- else {
- curl_off_t size = ((curl_off_t)attrs.sz[1] << 32) | attrs.sz[0];
- if(size < 0) {
- failf(data, "Bad file size (%" CURL_FORMAT_CURL_OFF_T ")", size);
- return CURLE_BAD_DOWNLOAD_RESUME;
- }
- data->state.resume_from = size;
- }
- }
- }
-
- if(data->set.ftp_append)
- /* Try to open for append, but create if nonexisting */
- flags = WOLFSSH_FXF_WRITE|WOLFSSH_FXF_CREAT|WOLFSSH_FXF_APPEND;
- else if(data->state.resume_from > 0)
- /* If we have restart position then open for append */
- flags = WOLFSSH_FXF_WRITE|WOLFSSH_FXF_APPEND;
- else
- /* Clear file before writing (normal behaviour) */
- flags = WOLFSSH_FXF_WRITE|WOLFSSH_FXF_CREAT|WOLFSSH_FXF_TRUNC;
-
- memset(&createattrs, 0, sizeof(createattrs));
- createattrs.per = (word32)data->set.new_file_perms;
- sshc->handleSz = sizeof(sshc->handle);
- rc = wolfSSH_SFTP_Open(sshc->ssh_session, sftp_scp->path,
- flags, &createattrs,
- sshc->handle, &sshc->handleSz);
- if(rc == WS_FATAL_ERROR)
- rc = wolfSSH_get_error(sshc->ssh_session);
- if(rc == WS_WANT_READ) {
- *block = TRUE;
- conn->waitfor = KEEP_RECV;
- return CURLE_OK;
- }
- else if(rc == WS_WANT_WRITE) {
- *block = TRUE;
- conn->waitfor = KEEP_SEND;
- return CURLE_OK;
- }
- else if(rc == WS_SUCCESS) {
- infof(data, "wolfssh SFTP open succeeded!\n");
- }
- else {
- failf(data, "wolfssh SFTP upload open failed: %d", rc);
- return CURLE_SSH;
- }
- state(conn, SSH_SFTP_DOWNLOAD_STAT);
-
- /* If we have a restart point then we need to seek to the correct
- position. */
- if(data->state.resume_from > 0) {
- /* Let's read off the proper amount of bytes from the input. */
- int seekerr = CURL_SEEKFUNC_OK;
- if(conn->seek_func) {
- Curl_set_in_callback(data, true);
- seekerr = conn->seek_func(conn->seek_client, data->state.resume_from,
- SEEK_SET);
- Curl_set_in_callback(data, false);
- }
-
- if(seekerr != CURL_SEEKFUNC_OK) {
- curl_off_t passed = 0;
-
- if(seekerr != CURL_SEEKFUNC_CANTSEEK) {
- failf(data, "Could not seek stream");
- return CURLE_FTP_COULDNT_USE_REST;
- }
- /* seekerr == CURL_SEEKFUNC_CANTSEEK (can't seek to offset) */
- do {
- size_t readthisamountnow =
- (data->state.resume_from - passed > data->set.buffer_size) ?
- (size_t)data->set.buffer_size :
- curlx_sotouz(data->state.resume_from - passed);
-
- size_t actuallyread;
- Curl_set_in_callback(data, true);
- actuallyread = data->state.fread_func(data->state.buffer, 1,
- readthisamountnow,
- data->state.in);
- Curl_set_in_callback(data, false);
-
- passed += actuallyread;
- if((actuallyread == 0) || (actuallyread > readthisamountnow)) {
- /* this checks for greater-than only to make sure that the
- CURL_READFUNC_ABORT return code still aborts */
- failf(data, "Failed to read data");
- return CURLE_FTP_COULDNT_USE_REST;
- }
- } while(passed < data->state.resume_from);
- }
-
- /* now, decrease the size of the read */
- if(data->state.infilesize > 0) {
- data->state.infilesize -= data->state.resume_from;
- data->req.size = data->state.infilesize;
- Curl_pgrsSetUploadSize(data, data->state.infilesize);
- }
-
- sshc->offset += data->state.resume_from;
- }
- if(data->state.infilesize > 0) {
- data->req.size = data->state.infilesize;
- Curl_pgrsSetUploadSize(data, data->state.infilesize);
- }
- /* upload data */
- Curl_setup_transfer(data, -1, -1, FALSE, FIRSTSOCKET);
-
- /* not set by Curl_setup_transfer to preserve keepon bits */
- conn->sockfd = conn->writesockfd;
-
- if(result) {
- state(conn, SSH_SFTP_CLOSE);
- sshc->actualcode = result;
- }
- else {
- /* store this original bitmask setup to use later on if we can't
- figure out a "real" bitmask */
- sshc->orig_waitfor = data->req.keepon;
-
- /* we want to use the _sending_ function even when the socket turns
- out readable as the underlying libssh2 sftp send function will deal
- with both accordingly */
- conn->cselect_bits = CURL_CSELECT_OUT;
-
- /* since we don't really wait for anything at this point, we want the
- state machine to move on as soon as possible so we set a very short
- timeout here */
- Curl_expire(data, 0, EXPIRE_RUN_NOW);
-
- state(conn, SSH_STOP);
- }
- break;
- }
- case SSH_SFTP_DOWNLOAD_INIT:
- sshc->handleSz = sizeof(sshc->handle);
- rc = wolfSSH_SFTP_Open(sshc->ssh_session, sftp_scp->path,
- WOLFSSH_FXF_READ, NULL,
- sshc->handle, &sshc->handleSz);
- if(rc == WS_FATAL_ERROR)
- rc = wolfSSH_get_error(sshc->ssh_session);
- if(rc == WS_WANT_READ) {
- *block = TRUE;
- conn->waitfor = KEEP_RECV;
- return CURLE_OK;
- }
- else if(rc == WS_WANT_WRITE) {
- *block = TRUE;
- conn->waitfor = KEEP_SEND;
- return CURLE_OK;
- }
- else if(rc == WS_SUCCESS) {
- infof(data, "wolfssh SFTP open succeeded!\n");
- state(conn, SSH_SFTP_DOWNLOAD_STAT);
- return CURLE_OK;
- }
-
- failf(data, "wolfssh SFTP open failed: %d", rc);
- return CURLE_SSH;
-
- case SSH_SFTP_DOWNLOAD_STAT: {
- WS_SFTP_FILEATRB attrs;
- curl_off_t size;
-
- rc = wolfSSH_SFTP_STAT(sshc->ssh_session, sftp_scp->path, &attrs);
- if(rc == WS_FATAL_ERROR)
- rc = wolfSSH_get_error(sshc->ssh_session);
- if(rc == WS_WANT_READ) {
- *block = TRUE;
- conn->waitfor = KEEP_RECV;
- return CURLE_OK;
- }
- else if(rc == WS_WANT_WRITE) {
- *block = TRUE;
- conn->waitfor = KEEP_SEND;
- return CURLE_OK;
- }
- else if(rc == WS_SUCCESS) {
- infof(data, "wolfssh STAT succeeded!\n");
- }
- else {
- failf(data, "wolfssh SFTP open failed: %d", rc);
- data->req.size = -1;
- data->req.maxdownload = -1;
- Curl_pgrsSetDownloadSize(data, -1);
- return CURLE_SSH;
- }
-
- size = ((curl_off_t)attrs.sz[1] <<32) | attrs.sz[0];
-
- data->req.size = size;
- data->req.maxdownload = size;
- Curl_pgrsSetDownloadSize(data, size);
-
- infof(data, "SFTP download %" CURL_FORMAT_CURL_OFF_T " bytes\n", size);
-
- /* We cannot seek with wolfSSH so resuming and range requests are not
- possible */
- if(conn->data->state.use_range || data->state.resume_from) {
- infof(data, "wolfSSH cannot do range/seek on SFTP\n");
- return CURLE_BAD_DOWNLOAD_RESUME;
- }
-
- /* Setup the actual download */
- if(data->req.size == 0) {
- /* no data to transfer */
- Curl_setup_transfer(data, -1, -1, FALSE, -1);
- infof(data, "File already completely downloaded\n");
- state(conn, SSH_STOP);
- break;
- }
- Curl_setup_transfer(data, FIRSTSOCKET, data->req.size, FALSE, -1);
-
- /* not set by Curl_setup_transfer to preserve keepon bits */
- conn->writesockfd = conn->sockfd;
-
- /* we want to use the _receiving_ function even when the socket turns
- out writableable as the underlying libssh2 recv function will deal
- with both accordingly */
- conn->cselect_bits = CURL_CSELECT_IN;
-
- if(result) {
- /* this should never occur; the close state should be entered
- at the time the error occurs */
- state(conn, SSH_SFTP_CLOSE);
- sshc->actualcode = result;
- }
- else {
- state(conn, SSH_STOP);
- }
- break;
- }
- case SSH_SFTP_CLOSE:
- if(sshc->handleSz)
- rc = wolfSSH_SFTP_Close(sshc->ssh_session, sshc->handle,
- sshc->handleSz);
- else
- rc = WS_SUCCESS; /* directory listing */
- if(rc == WS_WANT_READ) {
- *block = TRUE;
- conn->waitfor = KEEP_RECV;
- return CURLE_OK;
- }
- else if(rc == WS_WANT_WRITE) {
- *block = TRUE;
- conn->waitfor = KEEP_SEND;
- return CURLE_OK;
- }
- else if(rc == WS_SUCCESS) {
- state(conn, SSH_STOP);
- return CURLE_OK;
- }
-
- failf(data, "wolfssh SFTP CLOSE failed: %d", rc);
- return CURLE_SSH;
-
- case SSH_SFTP_READDIR_INIT:
- Curl_pgrsSetDownloadSize(data, -1);
- if(data->set.opt_no_body) {
- state(conn, SSH_STOP);
- break;
- }
- state(conn, SSH_SFTP_READDIR);
- /* FALLTHROUGH */
- case SSH_SFTP_READDIR:
- name = wolfSSH_SFTP_LS(sshc->ssh_session, sftp_scp->path);
- if(!name)
- rc = wolfSSH_get_error(sshc->ssh_session);
- else
- rc = WS_SUCCESS;
-
- if(rc == WS_WANT_READ) {
- *block = TRUE;
- conn->waitfor = KEEP_RECV;
- return CURLE_OK;
- }
- else if(rc == WS_WANT_WRITE) {
- *block = TRUE;
- conn->waitfor = KEEP_SEND;
- return CURLE_OK;
- }
- else if(name && (rc == WS_SUCCESS)) {
- WS_SFTPNAME *origname = name;
- result = CURLE_OK;
- while(name) {
- char *line = aprintf("%s\n",
- data->set.ftp_list_only ?
- name->fName : name->lName);
- if(line == NULL) {
- state(conn, SSH_SFTP_CLOSE);
- sshc->actualcode = CURLE_OUT_OF_MEMORY;
- break;
- }
- result = Curl_client_write(conn, CLIENTWRITE_BODY,
- line, strlen(line));
- free(line);
- if(result) {
- sshc->actualcode = result;
- break;
- }
- name = name->next;
- }
- wolfSSH_SFTPNAME_list_free(origname);
- state(conn, SSH_STOP);
- return result;
- }
- failf(data, "wolfssh SFTP ls failed: %d", rc);
- return CURLE_SSH;
-
- case SSH_SFTP_SHUTDOWN:
- Curl_safefree(sshc->homedir);
- wolfSSH_free(sshc->ssh_session);
- wolfSSH_CTX_free(sshc->ctx);
- state(conn, SSH_STOP);
- return CURLE_OK;
- default:
- break;
- }
- } while(!rc && (sshc->state != SSH_STOP));
- return result;
-}
-
-/* called repeatedly until done from multi.c */
-static CURLcode wssh_multi_statemach(struct connectdata *conn, bool *done)
-{
- struct ssh_conn *sshc = &conn->proto.sshc;
- CURLcode result = CURLE_OK;
- bool block; /* we store the status and use that to provide a ssh_getsock()
- implementation */
- do {
- result = wssh_statemach_act(conn, &block);
- *done = (sshc->state == SSH_STOP) ? TRUE : FALSE;
- /* if there's no error, it isn't done and it didn't EWOULDBLOCK, then
- try again */
- if(*done) {
- DEBUGF(infof(conn->data, "wssh_statemach_act says DONE\n"));
- }
- } while(!result && !*done && !block);
-
- return result;
-}
-
-static
-CURLcode wscp_perform(struct connectdata *conn,
- bool *connected,
- bool *dophase_done)
-{
- (void)conn;
- (void)connected;
- (void)dophase_done;
- return CURLE_OK;
-}
-
-static
-CURLcode wsftp_perform(struct connectdata *conn,
- bool *connected,
- bool *dophase_done)
-{
- CURLcode result = CURLE_OK;
-
- DEBUGF(infof(conn->data, "DO phase starts\n"));
-
- *dophase_done = FALSE; /* not done yet */
-
- /* start the first command in the DO phase */
- state(conn, SSH_SFTP_QUOTE_INIT);
-
- /* run the state-machine */
- result = wssh_multi_statemach(conn, dophase_done);
-
- *connected = conn->bits.tcpconnect[FIRSTSOCKET];
-
- if(*dophase_done) {
- DEBUGF(infof(conn->data, "DO phase is complete\n"));
- }
-
- return result;
-}
-
-/*
- * The DO function is generic for both protocols.
- */
-static CURLcode wssh_do(struct connectdata *conn, bool *done)
-{
- CURLcode result;
- bool connected = 0;
- struct Curl_easy *data = conn->data;
- struct ssh_conn *sshc = &conn->proto.sshc;
-
- *done = FALSE; /* default to false */
- data->req.size = -1; /* make sure this is unknown at this point */
- sshc->actualcode = CURLE_OK; /* reset error code */
- sshc->secondCreateDirs = 0; /* reset the create dir attempt state
- variable */
-
- Curl_pgrsSetUploadCounter(data, 0);
- Curl_pgrsSetDownloadCounter(data, 0);
- Curl_pgrsSetUploadSize(data, -1);
- Curl_pgrsSetDownloadSize(data, -1);
-
- if(conn->handler->protocol & CURLPROTO_SCP)
- result = wscp_perform(conn, &connected, done);
- else
- result = wsftp_perform(conn, &connected, done);
-
- return result;
-}
-
-static CURLcode wssh_block_statemach(struct connectdata *conn,
- bool disconnect)
-{
- struct ssh_conn *sshc = &conn->proto.sshc;
- CURLcode result = CURLE_OK;
- struct Curl_easy *data = conn->data;
-
- while((sshc->state != SSH_STOP) && !result) {
- bool block;
- timediff_t left = 1000;
- struct curltime now = Curl_now();
-
- result = wssh_statemach_act(conn, &block);
- if(result)
- break;
-
- if(!disconnect) {
- if(Curl_pgrsUpdate(conn))
- return CURLE_ABORTED_BY_CALLBACK;
-
- result = Curl_speedcheck(data, now);
- if(result)
- break;
-
- left = Curl_timeleft(data, NULL, FALSE);
- if(left < 0) {
- failf(data, "Operation timed out");
- return CURLE_OPERATION_TIMEDOUT;
- }
- }
-
- if(!result) {
- int dir = conn->waitfor;
- curl_socket_t sock = conn->sock[FIRSTSOCKET];
- curl_socket_t fd_read = CURL_SOCKET_BAD;
- curl_socket_t fd_write = CURL_SOCKET_BAD;
- if(dir == KEEP_RECV)
- fd_read = sock;
- else if(dir == KEEP_SEND)
- fd_write = sock;
-
- /* wait for the socket to become ready */
- (void)Curl_socket_check(fd_read, CURL_SOCKET_BAD, fd_write,
- left>1000?1000:left); /* ignore result */
- }
- }
-
- return result;
-}
-
-/* generic done function for both SCP and SFTP called from their specific
- done functions */
-static CURLcode wssh_done(struct connectdata *conn, CURLcode status)
-{
- CURLcode result = CURLE_OK;
- struct SSHPROTO *sftp_scp = conn->data->req.p.ssh;
-
- if(!status) {
- /* run the state-machine */
- result = wssh_block_statemach(conn, FALSE);
- }
- else
- result = status;
-
- if(sftp_scp)
- Curl_safefree(sftp_scp->path);
- if(Curl_pgrsDone(conn))
- return CURLE_ABORTED_BY_CALLBACK;
-
- conn->data->req.keepon = 0; /* clear all bits */
- return result;
-}
-
-#if 0
-static CURLcode wscp_done(struct connectdata *conn,
- CURLcode code, bool premature)
-{
- CURLcode result = CURLE_OK;
- (void)conn;
- (void)code;
- (void)premature;
-
- return result;
-}
-
-static CURLcode wscp_doing(struct connectdata *conn,
- bool *dophase_done)
-{
- CURLcode result = CURLE_OK;
- (void)conn;
- (void)dophase_done;
-
- return result;
-}
-
-static CURLcode wscp_disconnect(struct connectdata *conn, bool dead_connection)
-{
- CURLcode result = CURLE_OK;
- (void)conn;
- (void)dead_connection;
-
- return result;
-}
-#endif
-
-static CURLcode wsftp_done(struct connectdata *conn,
- CURLcode code, bool premature)
-{
- (void)premature;
- state(conn, SSH_SFTP_CLOSE);
-
- return wssh_done(conn, code);
-}
-
-static CURLcode wsftp_doing(struct connectdata *conn,
- bool *dophase_done)
-{
- CURLcode result = wssh_multi_statemach(conn, dophase_done);
-
- if(*dophase_done) {
- DEBUGF(infof(conn->data, "DO phase is complete\n"));
- }
- return result;
-}
-
-static CURLcode wsftp_disconnect(struct connectdata *conn, bool dead)
-{
- CURLcode result = CURLE_OK;
- (void)dead;
-
- DEBUGF(infof(conn->data, "SSH DISCONNECT starts now\n"));
-
- if(conn->proto.sshc.ssh_session) {
- /* only if there's a session still around to use! */
- state(conn, SSH_SFTP_SHUTDOWN);
- result = wssh_block_statemach(conn, TRUE);
- }
-
- DEBUGF(infof(conn->data, "SSH DISCONNECT is done\n"));
- return result;
-}
-
-static int wssh_getsock(struct connectdata *conn,
- curl_socket_t *sock)
-{
- return wssh_perform_getsock(conn, sock);
-}
-
-static int wssh_perform_getsock(const struct connectdata *conn,
- curl_socket_t *sock)
-{
- int bitmap = GETSOCK_BLANK;
- int dir = conn->waitfor;
- sock[0] = conn->sock[FIRSTSOCKET];
-
- if(dir == KEEP_RECV)
- bitmap |= GETSOCK_READSOCK(FIRSTSOCKET);
- else if(dir == KEEP_SEND)
- bitmap |= GETSOCK_WRITESOCK(FIRSTSOCKET);
-
- return bitmap;
-}
-
-size_t Curl_ssh_version(char *buffer, size_t buflen)
-{
- return msnprintf(buffer, buflen, "wolfssh/%s", LIBWOLFSSH_VERSION_STRING);
-}
-
-CURLcode Curl_ssh_init(void)
-{
- if(WS_SUCCESS != wolfSSH_Init()) {
- DEBUGF(fprintf(stderr, "Error: wolfSSH_Init failed\n"));
- return CURLE_FAILED_INIT;
- }
-
- return CURLE_OK;
-}
-void Curl_ssh_cleanup(void)
-{
-}
-
-#endif /* USE_WOLFSSH */
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 2019 - 2020, 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
+ * are also available at https://curl.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+
+#include "curl_setup.h"
+
+#ifdef USE_WOLFSSH
+
+#include <limits.h>
+
+#error #include <wolfssh/ssh.h>
+#error #include <wolfssh/wolfsftp.h>
+#include "urldata.h"
+#include "connect.h"
+#include "sendf.h"
+#include "progress.h"
+#include "curl_path.h"
+#include "strtoofft.h"
+#include "transfer.h"
+#include "speedcheck.h"
+#include "select.h"
+#include "multiif.h"
+#include "warnless.h"
+
+/* The last 3 #include files should be in this order */
+#include "curl_printf.h"
+#include "curl_memory.h"
+#include "memdebug.h"
+
+static CURLcode wssh_connect(struct connectdata *conn, bool *done);
+static CURLcode wssh_multi_statemach(struct connectdata *conn, bool *done);
+static CURLcode wssh_do(struct connectdata *conn, bool *done);
+#if 0
+static CURLcode wscp_done(struct connectdata *conn,
+ CURLcode, bool premature);
+static CURLcode wscp_doing(struct connectdata *conn,
+ bool *dophase_done);
+static CURLcode wscp_disconnect(struct connectdata *conn,
+ bool dead_connection);
+#endif
+static CURLcode wsftp_done(struct connectdata *conn,
+ CURLcode, bool premature);
+static CURLcode wsftp_doing(struct connectdata *conn,
+ bool *dophase_done);
+static CURLcode wsftp_disconnect(struct connectdata *conn, bool dead);
+static int wssh_getsock(struct connectdata *conn,
+ curl_socket_t *sock);
+static int wssh_perform_getsock(const struct connectdata *conn,
+ curl_socket_t *sock);
+static CURLcode wssh_setup_connection(struct connectdata *conn);
+
+#if 0
+/*
+ * SCP protocol handler.
+ */
+
+const struct Curl_handler Curl_handler_scp = {
+ "SCP", /* scheme */
+ wssh_setup_connection, /* setup_connection */
+ wssh_do, /* do_it */
+ wscp_done, /* done */
+ ZERO_NULL, /* do_more */
+ wssh_connect, /* connect_it */
+ wssh_multi_statemach, /* connecting */
+ wscp_doing, /* doing */
+ wssh_getsock, /* proto_getsock */
+ wssh_getsock, /* doing_getsock */
+ ZERO_NULL, /* domore_getsock */
+ wssh_perform_getsock, /* perform_getsock */
+ wscp_disconnect, /* disconnect */
+ ZERO_NULL, /* readwrite */
+ ZERO_NULL, /* connection_check */
+ PORT_SSH, /* defport */
+ CURLPROTO_SCP, /* protocol */
+ PROTOPT_DIRLOCK | PROTOPT_CLOSEACTION
+ | PROTOPT_NOURLQUERY /* flags */
+};
+
+#endif
+
+/*
+ * SFTP protocol handler.
+ */
+
+const struct Curl_handler Curl_handler_sftp = {
+ "SFTP", /* scheme */
+ wssh_setup_connection, /* setup_connection */
+ wssh_do, /* do_it */
+ wsftp_done, /* done */
+ ZERO_NULL, /* do_more */
+ wssh_connect, /* connect_it */
+ wssh_multi_statemach, /* connecting */
+ wsftp_doing, /* doing */
+ wssh_getsock, /* proto_getsock */
+ wssh_getsock, /* doing_getsock */
+ ZERO_NULL, /* domore_getsock */
+ wssh_perform_getsock, /* perform_getsock */
+ wsftp_disconnect, /* disconnect */
+ ZERO_NULL, /* readwrite */
+ ZERO_NULL, /* connection_check */
+ PORT_SSH, /* defport */
+ CURLPROTO_SFTP, /* protocol */
+ PROTOPT_DIRLOCK | PROTOPT_CLOSEACTION
+ | PROTOPT_NOURLQUERY /* flags */
+};
+
+/*
+ * SSH State machine related code
+ */
+/* This is the ONLY way to change SSH state! */
+static void state(struct connectdata *conn, sshstate nowstate)
+{
+ struct ssh_conn *sshc = &conn->proto.sshc;
+#if defined(DEBUGBUILD) && !defined(CURL_DISABLE_VERBOSE_STRINGS)
+ /* for debug purposes */
+ static const char * const names[] = {
+ "SSH_STOP",
+ "SSH_INIT",
+ "SSH_S_STARTUP",
+ "SSH_HOSTKEY",
+ "SSH_AUTHLIST",
+ "SSH_AUTH_PKEY_INIT",
+ "SSH_AUTH_PKEY",
+ "SSH_AUTH_PASS_INIT",
+ "SSH_AUTH_PASS",
+ "SSH_AUTH_AGENT_INIT",
+ "SSH_AUTH_AGENT_LIST",
+ "SSH_AUTH_AGENT",
+ "SSH_AUTH_HOST_INIT",
+ "SSH_AUTH_HOST",
+ "SSH_AUTH_KEY_INIT",
+ "SSH_AUTH_KEY",
+ "SSH_AUTH_GSSAPI",
+ "SSH_AUTH_DONE",
+ "SSH_SFTP_INIT",
+ "SSH_SFTP_REALPATH",
+ "SSH_SFTP_QUOTE_INIT",
+ "SSH_SFTP_POSTQUOTE_INIT",
+ "SSH_SFTP_QUOTE",
+ "SSH_SFTP_NEXT_QUOTE",
+ "SSH_SFTP_QUOTE_STAT",
+ "SSH_SFTP_QUOTE_SETSTAT",
+ "SSH_SFTP_QUOTE_SYMLINK",
+ "SSH_SFTP_QUOTE_MKDIR",
+ "SSH_SFTP_QUOTE_RENAME",
+ "SSH_SFTP_QUOTE_RMDIR",
+ "SSH_SFTP_QUOTE_UNLINK",
+ "SSH_SFTP_QUOTE_STATVFS",
+ "SSH_SFTP_GETINFO",
+ "SSH_SFTP_FILETIME",
+ "SSH_SFTP_TRANS_INIT",
+ "SSH_SFTP_UPLOAD_INIT",
+ "SSH_SFTP_CREATE_DIRS_INIT",
+ "SSH_SFTP_CREATE_DIRS",
+ "SSH_SFTP_CREATE_DIRS_MKDIR",
+ "SSH_SFTP_READDIR_INIT",
+ "SSH_SFTP_READDIR",
+ "SSH_SFTP_READDIR_LINK",
+ "SSH_SFTP_READDIR_BOTTOM",
+ "SSH_SFTP_READDIR_DONE",
+ "SSH_SFTP_DOWNLOAD_INIT",
+ "SSH_SFTP_DOWNLOAD_STAT",
+ "SSH_SFTP_CLOSE",
+ "SSH_SFTP_SHUTDOWN",
+ "SSH_SCP_TRANS_INIT",
+ "SSH_SCP_UPLOAD_INIT",
+ "SSH_SCP_DOWNLOAD_INIT",
+ "SSH_SCP_DOWNLOAD",
+ "SSH_SCP_DONE",
+ "SSH_SCP_SEND_EOF",
+ "SSH_SCP_WAIT_EOF",
+ "SSH_SCP_WAIT_CLOSE",
+ "SSH_SCP_CHANNEL_FREE",
+ "SSH_SESSION_DISCONNECT",
+ "SSH_SESSION_FREE",
+ "QUIT"
+ };
+
+ /* a precaution to make sure the lists are in sync */
+ DEBUGASSERT(sizeof(names)/sizeof(names[0]) == SSH_LAST);
+
+ if(sshc->state != nowstate) {
+ infof(conn->data, "wolfssh %p state change from %s to %s\n",
+ (void *)sshc, names[sshc->state], names[nowstate]);
+ }
+#endif
+
+ sshc->state = nowstate;
+}
+
+static ssize_t wscp_send(struct connectdata *conn, int sockindex,
+ const void *mem, size_t len, CURLcode *err)
+{
+ ssize_t nwrite = 0;
+ (void)conn;
+ (void)sockindex; /* we only support SCP on the fixed known primary socket */
+ (void)mem;
+ (void)len;
+ (void)err;
+
+ return nwrite;
+}
+
+static ssize_t wscp_recv(struct connectdata *conn, int sockindex,
+ char *mem, size_t len, CURLcode *err)
+{
+ ssize_t nread = 0;
+ (void)conn;
+ (void)sockindex; /* we only support SCP on the fixed known primary socket */
+ (void)mem;
+ (void)len;
+ (void)err;
+
+ return nread;
+}
+
+/* return number of sent bytes */
+static ssize_t wsftp_send(struct connectdata *conn, int sockindex,
+ const void *mem, size_t len, CURLcode *err)
+{
+ struct ssh_conn *sshc = &conn->proto.sshc;
+ word32 offset[2];
+ int rc;
+ (void)sockindex;
+
+ offset[0] = (word32)sshc->offset&0xFFFFFFFF;
+ offset[1] = (word32)(sshc->offset>>32)&0xFFFFFFFF;
+
+ rc = wolfSSH_SFTP_SendWritePacket(sshc->ssh_session, sshc->handle,
+ sshc->handleSz,
+ &offset[0],
+ (byte *)mem, (word32)len);
+
+ if(rc == WS_FATAL_ERROR)
+ rc = wolfSSH_get_error(sshc->ssh_session);
+ if(rc == WS_WANT_READ) {
+ conn->waitfor = KEEP_RECV;
+ *err = CURLE_AGAIN;
+ return -1;
+ }
+ else if(rc == WS_WANT_WRITE) {
+ conn->waitfor = KEEP_SEND;
+ *err = CURLE_AGAIN;
+ return -1;
+ }
+ if(rc < 0) {
+ failf(conn->data, "wolfSSH_SFTP_SendWritePacket returned %d\n", rc);
+ return -1;
+ }
+ DEBUGASSERT(rc == (int)len);
+ infof(conn->data, "sent %zd bytes SFTP from offset %zd\n",
+ len, sshc->offset);
+ sshc->offset += len;
+ return (ssize_t)rc;
+}
+
+/*
+ * Return number of received (decrypted) bytes
+ * or <0 on error
+ */
+static ssize_t wsftp_recv(struct connectdata *conn, int sockindex,
+ char *mem, size_t len, CURLcode *err)
+{
+ int rc;
+ struct ssh_conn *sshc = &conn->proto.sshc;
+ word32 offset[2];
+ (void)sockindex;
+
+ offset[0] = (word32)sshc->offset&0xFFFFFFFF;
+ offset[1] = (word32)(sshc->offset>>32)&0xFFFFFFFF;
+
+ rc = wolfSSH_SFTP_SendReadPacket(sshc->ssh_session, sshc->handle,
+ sshc->handleSz,
+ &offset[0],
+ (byte *)mem, (word32)len);
+ if(rc == WS_FATAL_ERROR)
+ rc = wolfSSH_get_error(sshc->ssh_session);
+ if(rc == WS_WANT_READ) {
+ conn->waitfor = KEEP_RECV;
+ *err = CURLE_AGAIN;
+ return -1;
+ }
+ else if(rc == WS_WANT_WRITE) {
+ conn->waitfor = KEEP_SEND;
+ *err = CURLE_AGAIN;
+ return -1;
+ }
+
+ DEBUGASSERT(rc <= (int)len);
+
+ if(rc < 0) {
+ failf(conn->data, "wolfSSH_SFTP_SendReadPacket returned %d\n", rc);
+ return -1;
+ }
+ sshc->offset += len;
+
+ return (ssize_t)rc;
+}
+
+/*
+ * SSH setup and connection
+ */
+static CURLcode wssh_setup_connection(struct connectdata *conn)
+{
+ struct SSHPROTO *ssh;
+
+ conn->data->req.p.ssh = ssh = calloc(1, sizeof(struct SSHPROTO));
+ if(!ssh)
+ return CURLE_OUT_OF_MEMORY;
+
+ return CURLE_OK;
+}
+
+static Curl_recv wscp_recv, wsftp_recv;
+static Curl_send wscp_send, wsftp_send;
+
+static int userauth(byte authtype,
+ WS_UserAuthData* authdata,
+ void *ctx)
+{
+ struct connectdata *conn = ctx;
+ DEBUGF(infof(conn->data, "wolfssh callback: type %s\n",
+ authtype == WOLFSSH_USERAUTH_PASSWORD ? "PASSWORD" :
+ "PUBLICCKEY"));
+ if(authtype == WOLFSSH_USERAUTH_PASSWORD) {
+ authdata->sf.password.password = (byte *)conn->passwd;
+ authdata->sf.password.passwordSz = (word32) strlen(conn->passwd);
+ }
+
+ return 0;
+}
+
+static CURLcode wssh_connect(struct connectdata *conn, bool *done)
+{
+ struct Curl_easy *data = conn->data;
+ struct ssh_conn *sshc;
+ curl_socket_t sock = conn->sock[FIRSTSOCKET];
+ int rc;
+
+ /* initialize per-handle data if not already */
+ if(!data->req.p.ssh)
+ wssh_setup_connection(conn);
+
+ /* We default to persistent connections. We set this already in this connect
+ function to make the re-use checks properly be able to check this bit. */
+ connkeep(conn, "SSH default");
+
+ if(conn->handler->protocol & CURLPROTO_SCP) {
+ conn->recv[FIRSTSOCKET] = wscp_recv;
+ conn->send[FIRSTSOCKET] = wscp_send;
+ }
+ else {
+ conn->recv[FIRSTSOCKET] = wsftp_recv;
+ conn->send[FIRSTSOCKET] = wsftp_send;
+ }
+ sshc = &conn->proto.sshc;
+ sshc->ctx = wolfSSH_CTX_new(WOLFSSH_ENDPOINT_CLIENT, NULL);
+ if(!sshc->ctx) {
+ failf(data, "No wolfSSH context");
+ goto error;
+ }
+
+ sshc->ssh_session = wolfSSH_new(sshc->ctx);
+ if(sshc->ssh_session == NULL) {
+ failf(data, "No wolfSSH session");
+ goto error;
+ }
+
+ rc = wolfSSH_SetUsername(sshc->ssh_session, conn->user);
+ if(rc != WS_SUCCESS) {
+ failf(data, "wolfSSH failed to set user name");
+ goto error;
+ }
+
+ /* set callback for authentication */
+ wolfSSH_SetUserAuth(sshc->ctx, userauth);
+ wolfSSH_SetUserAuthCtx(sshc->ssh_session, conn);
+
+ rc = wolfSSH_set_fd(sshc->ssh_session, (int)sock);
+ if(rc) {
+ failf(data, "wolfSSH failed to set socket");
+ goto error;
+ }
+
+#if 0
+ wolfSSH_Debugging_ON();
+#endif
+
+ *done = TRUE;
+ if(conn->handler->protocol & CURLPROTO_SCP)
+ state(conn, SSH_INIT);
+ else
+ state(conn, SSH_SFTP_INIT);
+
+ return wssh_multi_statemach(conn, done);
+ error:
+ wolfSSH_free(sshc->ssh_session);
+ wolfSSH_CTX_free(sshc->ctx);
+ return CURLE_FAILED_INIT;
+}
+
+/*
+ * wssh_statemach_act() runs the SSH state machine as far as it can without
+ * blocking and without reaching the end. The data the pointer 'block' points
+ * to will be set to TRUE if the wolfssh function returns EAGAIN meaning it
+ * wants to be called again when the socket is ready
+ */
+
+static CURLcode wssh_statemach_act(struct connectdata *conn, bool *block)
+{
+ CURLcode result = CURLE_OK;
+ struct ssh_conn *sshc = &conn->proto.sshc;
+ struct Curl_easy *data = conn->data;
+ struct SSHPROTO *sftp_scp = data->req.p.ssh;
+ WS_SFTPNAME *name;
+ int rc = 0;
+ *block = FALSE; /* we're not blocking by default */
+
+ do {
+ switch(sshc->state) {
+ case SSH_INIT:
+ state(conn, SSH_S_STARTUP);
+ /* FALLTHROUGH */
+ case SSH_S_STARTUP:
+ rc = wolfSSH_connect(sshc->ssh_session);
+ if(rc != WS_SUCCESS)
+ rc = wolfSSH_get_error(sshc->ssh_session);
+ if(rc == WS_WANT_READ) {
+ *block = TRUE;
+ conn->waitfor = KEEP_RECV;
+ return CURLE_OK;
+ }
+ else if(rc == WS_WANT_WRITE) {
+ *block = TRUE;
+ conn->waitfor = KEEP_SEND;
+ return CURLE_OK;
+ }
+ else if(rc != WS_SUCCESS) {
+ state(conn, SSH_STOP);
+ return CURLE_SSH;
+ }
+ infof(data, "wolfssh connected!\n");
+ state(conn, SSH_STOP);
+ break;
+ case SSH_STOP:
+ break;
+
+ case SSH_SFTP_INIT:
+ rc = wolfSSH_SFTP_connect(sshc->ssh_session);
+ if(rc != WS_SUCCESS)
+ rc = wolfSSH_get_error(sshc->ssh_session);
+ if(rc == WS_WANT_READ) {
+ *block = TRUE;
+ conn->waitfor = KEEP_RECV;
+ return CURLE_OK;
+ }
+ else if(rc == WS_WANT_WRITE) {
+ *block = TRUE;
+ conn->waitfor = KEEP_SEND;
+ return CURLE_OK;
+ }
+ else if(rc == WS_SUCCESS) {
+ infof(data, "wolfssh SFTP connected!\n");
+ state(conn, SSH_SFTP_REALPATH);
+ }
+ else {
+ failf(data, "wolfssh SFTP connect error %d", rc);
+ return CURLE_SSH;
+ }
+ break;
+ case SSH_SFTP_REALPATH:
+ name = wolfSSH_SFTP_RealPath(sshc->ssh_session, (char *)".");
+ rc = wolfSSH_get_error(sshc->ssh_session);
+ if(rc == WS_WANT_READ) {
+ *block = TRUE;
+ conn->waitfor = KEEP_RECV;
+ return CURLE_OK;
+ }
+ else if(rc == WS_WANT_WRITE) {
+ *block = TRUE;
+ conn->waitfor = KEEP_SEND;
+ return CURLE_OK;
+ }
+ else if(name && (rc == WS_SUCCESS)) {
+ sshc->homedir = malloc(name->fSz + 1);
+ if(!sshc->homedir) {
+ sshc->actualcode = CURLE_OUT_OF_MEMORY;
+ }
+ else {
+ memcpy(sshc->homedir, name->fName, name->fSz);
+ sshc->homedir[name->fSz] = 0;
+ infof(data, "wolfssh SFTP realpath succeeded!\n");
+ }
+ wolfSSH_SFTPNAME_list_free(name);
+ state(conn, SSH_STOP);
+ return CURLE_OK;
+ }
+ failf(data, "wolfssh SFTP realpath %d", rc);
+ return CURLE_SSH;
+
+ case SSH_SFTP_QUOTE_INIT:
+ result = Curl_getworkingpath(conn, sshc->homedir, &sftp_scp->path);
+ if(result) {
+ sshc->actualcode = result;
+ state(conn, SSH_STOP);
+ break;
+ }
+
+ if(data->set.quote) {
+ infof(data, "Sending quote commands\n");
+ sshc->quote_item = data->set.quote;
+ state(conn, SSH_SFTP_QUOTE);
+ }
+ else {
+ state(conn, SSH_SFTP_GETINFO);
+ }
+ break;
+ case SSH_SFTP_GETINFO:
+ if(data->set.get_filetime) {
+ state(conn, SSH_SFTP_FILETIME);
+ }
+ else {
+ state(conn, SSH_SFTP_TRANS_INIT);
+ }
+ break;
+ case SSH_SFTP_TRANS_INIT:
+ if(data->set.upload)
+ state(conn, SSH_SFTP_UPLOAD_INIT);
+ else {
+ if(sftp_scp->path[strlen(sftp_scp->path)-1] == '/')
+ state(conn, SSH_SFTP_READDIR_INIT);
+ else
+ state(conn, SSH_SFTP_DOWNLOAD_INIT);
+ }
+ break;
+ case SSH_SFTP_UPLOAD_INIT: {
+ word32 flags;
+ WS_SFTP_FILEATRB createattrs;
+ if(data->state.resume_from) {
+ WS_SFTP_FILEATRB attrs;
+ if(data->state.resume_from < 0) {
+ rc = wolfSSH_SFTP_STAT(sshc->ssh_session, sftp_scp->path,
+ &attrs);
+ if(rc != WS_SUCCESS)
+ break;
+
+ if(rc) {
+ data->state.resume_from = 0;
+ }
+ else {
+ curl_off_t size = ((curl_off_t)attrs.sz[1] << 32) | attrs.sz[0];
+ if(size < 0) {
+ failf(data, "Bad file size (%" CURL_FORMAT_CURL_OFF_T ")", size);
+ return CURLE_BAD_DOWNLOAD_RESUME;
+ }
+ data->state.resume_from = size;
+ }
+ }
+ }
+
+ if(data->set.ftp_append)
+ /* Try to open for append, but create if nonexisting */
+ flags = WOLFSSH_FXF_WRITE|WOLFSSH_FXF_CREAT|WOLFSSH_FXF_APPEND;
+ else if(data->state.resume_from > 0)
+ /* If we have restart position then open for append */
+ flags = WOLFSSH_FXF_WRITE|WOLFSSH_FXF_APPEND;
+ else
+ /* Clear file before writing (normal behaviour) */
+ flags = WOLFSSH_FXF_WRITE|WOLFSSH_FXF_CREAT|WOLFSSH_FXF_TRUNC;
+
+ memset(&createattrs, 0, sizeof(createattrs));
+ createattrs.per = (word32)data->set.new_file_perms;
+ sshc->handleSz = sizeof(sshc->handle);
+ rc = wolfSSH_SFTP_Open(sshc->ssh_session, sftp_scp->path,
+ flags, &createattrs,
+ sshc->handle, &sshc->handleSz);
+ if(rc == WS_FATAL_ERROR)
+ rc = wolfSSH_get_error(sshc->ssh_session);
+ if(rc == WS_WANT_READ) {
+ *block = TRUE;
+ conn->waitfor = KEEP_RECV;
+ return CURLE_OK;
+ }
+ else if(rc == WS_WANT_WRITE) {
+ *block = TRUE;
+ conn->waitfor = KEEP_SEND;
+ return CURLE_OK;
+ }
+ else if(rc == WS_SUCCESS) {
+ infof(data, "wolfssh SFTP open succeeded!\n");
+ }
+ else {
+ failf(data, "wolfssh SFTP upload open failed: %d", rc);
+ return CURLE_SSH;
+ }
+ state(conn, SSH_SFTP_DOWNLOAD_STAT);
+
+ /* If we have a restart point then we need to seek to the correct
+ position. */
+ if(data->state.resume_from > 0) {
+ /* Let's read off the proper amount of bytes from the input. */
+ int seekerr = CURL_SEEKFUNC_OK;
+ if(conn->seek_func) {
+ Curl_set_in_callback(data, true);
+ seekerr = conn->seek_func(conn->seek_client, data->state.resume_from,
+ SEEK_SET);
+ Curl_set_in_callback(data, false);
+ }
+
+ if(seekerr != CURL_SEEKFUNC_OK) {
+ curl_off_t passed = 0;
+
+ if(seekerr != CURL_SEEKFUNC_CANTSEEK) {
+ failf(data, "Could not seek stream");
+ return CURLE_FTP_COULDNT_USE_REST;
+ }
+ /* seekerr == CURL_SEEKFUNC_CANTSEEK (can't seek to offset) */
+ do {
+ size_t readthisamountnow =
+ (data->state.resume_from - passed > data->set.buffer_size) ?
+ (size_t)data->set.buffer_size :
+ curlx_sotouz(data->state.resume_from - passed);
+
+ size_t actuallyread;
+ Curl_set_in_callback(data, true);
+ actuallyread = data->state.fread_func(data->state.buffer, 1,
+ readthisamountnow,
+ data->state.in);
+ Curl_set_in_callback(data, false);
+
+ passed += actuallyread;
+ if((actuallyread == 0) || (actuallyread > readthisamountnow)) {
+ /* this checks for greater-than only to make sure that the
+ CURL_READFUNC_ABORT return code still aborts */
+ failf(data, "Failed to read data");
+ return CURLE_FTP_COULDNT_USE_REST;
+ }
+ } while(passed < data->state.resume_from);
+ }
+
+ /* now, decrease the size of the read */
+ if(data->state.infilesize > 0) {
+ data->state.infilesize -= data->state.resume_from;
+ data->req.size = data->state.infilesize;
+ Curl_pgrsSetUploadSize(data, data->state.infilesize);
+ }
+
+ sshc->offset += data->state.resume_from;
+ }
+ if(data->state.infilesize > 0) {
+ data->req.size = data->state.infilesize;
+ Curl_pgrsSetUploadSize(data, data->state.infilesize);
+ }
+ /* upload data */
+ Curl_setup_transfer(data, -1, -1, FALSE, FIRSTSOCKET);
+
+ /* not set by Curl_setup_transfer to preserve keepon bits */
+ conn->sockfd = conn->writesockfd;
+
+ if(result) {
+ state(conn, SSH_SFTP_CLOSE);
+ sshc->actualcode = result;
+ }
+ else {
+ /* store this original bitmask setup to use later on if we can't
+ figure out a "real" bitmask */
+ sshc->orig_waitfor = data->req.keepon;
+
+ /* we want to use the _sending_ function even when the socket turns
+ out readable as the underlying libssh2 sftp send function will deal
+ with both accordingly */
+ conn->cselect_bits = CURL_CSELECT_OUT;
+
+ /* since we don't really wait for anything at this point, we want the
+ state machine to move on as soon as possible so we set a very short
+ timeout here */
+ Curl_expire(data, 0, EXPIRE_RUN_NOW);
+
+ state(conn, SSH_STOP);
+ }
+ break;
+ }
+ case SSH_SFTP_DOWNLOAD_INIT:
+ sshc->handleSz = sizeof(sshc->handle);
+ rc = wolfSSH_SFTP_Open(sshc->ssh_session, sftp_scp->path,
+ WOLFSSH_FXF_READ, NULL,
+ sshc->handle, &sshc->handleSz);
+ if(rc == WS_FATAL_ERROR)
+ rc = wolfSSH_get_error(sshc->ssh_session);
+ if(rc == WS_WANT_READ) {
+ *block = TRUE;
+ conn->waitfor = KEEP_RECV;
+ return CURLE_OK;
+ }
+ else if(rc == WS_WANT_WRITE) {
+ *block = TRUE;
+ conn->waitfor = KEEP_SEND;
+ return CURLE_OK;
+ }
+ else if(rc == WS_SUCCESS) {
+ infof(data, "wolfssh SFTP open succeeded!\n");
+ state(conn, SSH_SFTP_DOWNLOAD_STAT);
+ return CURLE_OK;
+ }
+
+ failf(data, "wolfssh SFTP open failed: %d", rc);
+ return CURLE_SSH;
+
+ case SSH_SFTP_DOWNLOAD_STAT: {
+ WS_SFTP_FILEATRB attrs;
+ curl_off_t size;
+
+ rc = wolfSSH_SFTP_STAT(sshc->ssh_session, sftp_scp->path, &attrs);
+ if(rc == WS_FATAL_ERROR)
+ rc = wolfSSH_get_error(sshc->ssh_session);
+ if(rc == WS_WANT_READ) {
+ *block = TRUE;
+ conn->waitfor = KEEP_RECV;
+ return CURLE_OK;
+ }
+ else if(rc == WS_WANT_WRITE) {
+ *block = TRUE;
+ conn->waitfor = KEEP_SEND;
+ return CURLE_OK;
+ }
+ else if(rc == WS_SUCCESS) {
+ infof(data, "wolfssh STAT succeeded!\n");
+ }
+ else {
+ failf(data, "wolfssh SFTP open failed: %d", rc);
+ data->req.size = -1;
+ data->req.maxdownload = -1;
+ Curl_pgrsSetDownloadSize(data, -1);
+ return CURLE_SSH;
+ }
+
+ size = ((curl_off_t)attrs.sz[1] <<32) | attrs.sz[0];
+
+ data->req.size = size;
+ data->req.maxdownload = size;
+ Curl_pgrsSetDownloadSize(data, size);
+
+ infof(data, "SFTP download %" CURL_FORMAT_CURL_OFF_T " bytes\n", size);
+
+ /* We cannot seek with wolfSSH so resuming and range requests are not
+ possible */
+ if(conn->data->state.use_range || data->state.resume_from) {
+ infof(data, "wolfSSH cannot do range/seek on SFTP\n");
+ return CURLE_BAD_DOWNLOAD_RESUME;
+ }
+
+ /* Setup the actual download */
+ if(data->req.size == 0) {
+ /* no data to transfer */
+ Curl_setup_transfer(data, -1, -1, FALSE, -1);
+ infof(data, "File already completely downloaded\n");
+ state(conn, SSH_STOP);
+ break;
+ }
+ Curl_setup_transfer(data, FIRSTSOCKET, data->req.size, FALSE, -1);
+
+ /* not set by Curl_setup_transfer to preserve keepon bits */
+ conn->writesockfd = conn->sockfd;
+
+ /* we want to use the _receiving_ function even when the socket turns
+ out writableable as the underlying libssh2 recv function will deal
+ with both accordingly */
+ conn->cselect_bits = CURL_CSELECT_IN;
+
+ if(result) {
+ /* this should never occur; the close state should be entered
+ at the time the error occurs */
+ state(conn, SSH_SFTP_CLOSE);
+ sshc->actualcode = result;
+ }
+ else {
+ state(conn, SSH_STOP);
+ }
+ break;
+ }
+ case SSH_SFTP_CLOSE:
+ if(sshc->handleSz)
+ rc = wolfSSH_SFTP_Close(sshc->ssh_session, sshc->handle,
+ sshc->handleSz);
+ else
+ rc = WS_SUCCESS; /* directory listing */
+ if(rc == WS_WANT_READ) {
+ *block = TRUE;
+ conn->waitfor = KEEP_RECV;
+ return CURLE_OK;
+ }
+ else if(rc == WS_WANT_WRITE) {
+ *block = TRUE;
+ conn->waitfor = KEEP_SEND;
+ return CURLE_OK;
+ }
+ else if(rc == WS_SUCCESS) {
+ state(conn, SSH_STOP);
+ return CURLE_OK;
+ }
+
+ failf(data, "wolfssh SFTP CLOSE failed: %d", rc);
+ return CURLE_SSH;
+
+ case SSH_SFTP_READDIR_INIT:
+ Curl_pgrsSetDownloadSize(data, -1);
+ if(data->set.opt_no_body) {
+ state(conn, SSH_STOP);
+ break;
+ }
+ state(conn, SSH_SFTP_READDIR);
+ /* FALLTHROUGH */
+ case SSH_SFTP_READDIR:
+ name = wolfSSH_SFTP_LS(sshc->ssh_session, sftp_scp->path);
+ if(!name)
+ rc = wolfSSH_get_error(sshc->ssh_session);
+ else
+ rc = WS_SUCCESS;
+
+ if(rc == WS_WANT_READ) {
+ *block = TRUE;
+ conn->waitfor = KEEP_RECV;
+ return CURLE_OK;
+ }
+ else if(rc == WS_WANT_WRITE) {
+ *block = TRUE;
+ conn->waitfor = KEEP_SEND;
+ return CURLE_OK;
+ }
+ else if(name && (rc == WS_SUCCESS)) {
+ WS_SFTPNAME *origname = name;
+ result = CURLE_OK;
+ while(name) {
+ char *line = aprintf("%s\n",
+ data->set.ftp_list_only ?
+ name->fName : name->lName);
+ if(line == NULL) {
+ state(conn, SSH_SFTP_CLOSE);
+ sshc->actualcode = CURLE_OUT_OF_MEMORY;
+ break;
+ }
+ result = Curl_client_write(conn, CLIENTWRITE_BODY,
+ line, strlen(line));
+ free(line);
+ if(result) {
+ sshc->actualcode = result;
+ break;
+ }
+ name = name->next;
+ }
+ wolfSSH_SFTPNAME_list_free(origname);
+ state(conn, SSH_STOP);
+ return result;
+ }
+ failf(data, "wolfssh SFTP ls failed: %d", rc);
+ return CURLE_SSH;
+
+ case SSH_SFTP_SHUTDOWN:
+ Curl_safefree(sshc->homedir);
+ wolfSSH_free(sshc->ssh_session);
+ wolfSSH_CTX_free(sshc->ctx);
+ state(conn, SSH_STOP);
+ return CURLE_OK;
+ default:
+ break;
+ }
+ } while(!rc && (sshc->state != SSH_STOP));
+ return result;
+}
+
+/* called repeatedly until done from multi.c */
+static CURLcode wssh_multi_statemach(struct connectdata *conn, bool *done)
+{
+ struct ssh_conn *sshc = &conn->proto.sshc;
+ CURLcode result = CURLE_OK;
+ bool block; /* we store the status and use that to provide a ssh_getsock()
+ implementation */
+ do {
+ result = wssh_statemach_act(conn, &block);
+ *done = (sshc->state == SSH_STOP) ? TRUE : FALSE;
+ /* if there's no error, it isn't done and it didn't EWOULDBLOCK, then
+ try again */
+ if(*done) {
+ DEBUGF(infof(conn->data, "wssh_statemach_act says DONE\n"));
+ }
+ } while(!result && !*done && !block);
+
+ return result;
+}
+
+static
+CURLcode wscp_perform(struct connectdata *conn,
+ bool *connected,
+ bool *dophase_done)
+{
+ (void)conn;
+ (void)connected;
+ (void)dophase_done;
+ return CURLE_OK;
+}
+
+static
+CURLcode wsftp_perform(struct connectdata *conn,
+ bool *connected,
+ bool *dophase_done)
+{
+ CURLcode result = CURLE_OK;
+
+ DEBUGF(infof(conn->data, "DO phase starts\n"));
+
+ *dophase_done = FALSE; /* not done yet */
+
+ /* start the first command in the DO phase */
+ state(conn, SSH_SFTP_QUOTE_INIT);
+
+ /* run the state-machine */
+ result = wssh_multi_statemach(conn, dophase_done);
+
+ *connected = conn->bits.tcpconnect[FIRSTSOCKET];
+
+ if(*dophase_done) {
+ DEBUGF(infof(conn->data, "DO phase is complete\n"));
+ }
+
+ return result;
+}
+
+/*
+ * The DO function is generic for both protocols.
+ */
+static CURLcode wssh_do(struct connectdata *conn, bool *done)
+{
+ CURLcode result;
+ bool connected = 0;
+ struct Curl_easy *data = conn->data;
+ struct ssh_conn *sshc = &conn->proto.sshc;
+
+ *done = FALSE; /* default to false */
+ data->req.size = -1; /* make sure this is unknown at this point */
+ sshc->actualcode = CURLE_OK; /* reset error code */
+ sshc->secondCreateDirs = 0; /* reset the create dir attempt state
+ variable */
+
+ Curl_pgrsSetUploadCounter(data, 0);
+ Curl_pgrsSetDownloadCounter(data, 0);
+ Curl_pgrsSetUploadSize(data, -1);
+ Curl_pgrsSetDownloadSize(data, -1);
+
+ if(conn->handler->protocol & CURLPROTO_SCP)
+ result = wscp_perform(conn, &connected, done);
+ else
+ result = wsftp_perform(conn, &connected, done);
+
+ return result;
+}
+
+static CURLcode wssh_block_statemach(struct connectdata *conn,
+ bool disconnect)
+{
+ struct ssh_conn *sshc = &conn->proto.sshc;
+ CURLcode result = CURLE_OK;
+ struct Curl_easy *data = conn->data;
+
+ while((sshc->state != SSH_STOP) && !result) {
+ bool block;
+ timediff_t left = 1000;
+ struct curltime now = Curl_now();
+
+ result = wssh_statemach_act(conn, &block);
+ if(result)
+ break;
+
+ if(!disconnect) {
+ if(Curl_pgrsUpdate(conn))
+ return CURLE_ABORTED_BY_CALLBACK;
+
+ result = Curl_speedcheck(data, now);
+ if(result)
+ break;
+
+ left = Curl_timeleft(data, NULL, FALSE);
+ if(left < 0) {
+ failf(data, "Operation timed out");
+ return CURLE_OPERATION_TIMEDOUT;
+ }
+ }
+
+ if(!result) {
+ int dir = conn->waitfor;
+ curl_socket_t sock = conn->sock[FIRSTSOCKET];
+ curl_socket_t fd_read = CURL_SOCKET_BAD;
+ curl_socket_t fd_write = CURL_SOCKET_BAD;
+ if(dir == KEEP_RECV)
+ fd_read = sock;
+ else if(dir == KEEP_SEND)
+ fd_write = sock;
+
+ /* wait for the socket to become ready */
+ (void)Curl_socket_check(fd_read, CURL_SOCKET_BAD, fd_write,
+ left>1000?1000:left); /* ignore result */
+ }
+ }
+
+ return result;
+}
+
+/* generic done function for both SCP and SFTP called from their specific
+ done functions */
+static CURLcode wssh_done(struct connectdata *conn, CURLcode status)
+{
+ CURLcode result = CURLE_OK;
+ struct SSHPROTO *sftp_scp = conn->data->req.p.ssh;
+
+ if(!status) {
+ /* run the state-machine */
+ result = wssh_block_statemach(conn, FALSE);
+ }
+ else
+ result = status;
+
+ if(sftp_scp)
+ Curl_safefree(sftp_scp->path);
+ if(Curl_pgrsDone(conn))
+ return CURLE_ABORTED_BY_CALLBACK;
+
+ conn->data->req.keepon = 0; /* clear all bits */
+ return result;
+}
+
+#if 0
+static CURLcode wscp_done(struct connectdata *conn,
+ CURLcode code, bool premature)
+{
+ CURLcode result = CURLE_OK;
+ (void)conn;
+ (void)code;
+ (void)premature;
+
+ return result;
+}
+
+static CURLcode wscp_doing(struct connectdata *conn,
+ bool *dophase_done)
+{
+ CURLcode result = CURLE_OK;
+ (void)conn;
+ (void)dophase_done;
+
+ return result;
+}
+
+static CURLcode wscp_disconnect(struct connectdata *conn, bool dead_connection)
+{
+ CURLcode result = CURLE_OK;
+ (void)conn;
+ (void)dead_connection;
+
+ return result;
+}
+#endif
+
+static CURLcode wsftp_done(struct connectdata *conn,
+ CURLcode code, bool premature)
+{
+ (void)premature;
+ state(conn, SSH_SFTP_CLOSE);
+
+ return wssh_done(conn, code);
+}
+
+static CURLcode wsftp_doing(struct connectdata *conn,
+ bool *dophase_done)
+{
+ CURLcode result = wssh_multi_statemach(conn, dophase_done);
+
+ if(*dophase_done) {
+ DEBUGF(infof(conn->data, "DO phase is complete\n"));
+ }
+ return result;
+}
+
+static CURLcode wsftp_disconnect(struct connectdata *conn, bool dead)
+{
+ CURLcode result = CURLE_OK;
+ (void)dead;
+
+ DEBUGF(infof(conn->data, "SSH DISCONNECT starts now\n"));
+
+ if(conn->proto.sshc.ssh_session) {
+ /* only if there's a session still around to use! */
+ state(conn, SSH_SFTP_SHUTDOWN);
+ result = wssh_block_statemach(conn, TRUE);
+ }
+
+ DEBUGF(infof(conn->data, "SSH DISCONNECT is done\n"));
+ return result;
+}
+
+static int wssh_getsock(struct connectdata *conn,
+ curl_socket_t *sock)
+{
+ return wssh_perform_getsock(conn, sock);
+}
+
+static int wssh_perform_getsock(const struct connectdata *conn,
+ curl_socket_t *sock)
+{
+ int bitmap = GETSOCK_BLANK;
+ int dir = conn->waitfor;
+ sock[0] = conn->sock[FIRSTSOCKET];
+
+ if(dir == KEEP_RECV)
+ bitmap |= GETSOCK_READSOCK(FIRSTSOCKET);
+ else if(dir == KEEP_SEND)
+ bitmap |= GETSOCK_WRITESOCK(FIRSTSOCKET);
+
+ return bitmap;
+}
+
+size_t Curl_ssh_version(char *buffer, size_t buflen)
+{
+ return msnprintf(buffer, buflen, "wolfssh/%s", LIBWOLFSSH_VERSION_STRING);
+}
+
+CURLcode Curl_ssh_init(void)
+{
+ if(WS_SUCCESS != wolfSSH_Init()) {
+ DEBUGF(fprintf(stderr, "Error: wolfSSH_Init failed\n"));
+ return CURLE_FAILED_INIT;
+ }
+
+ return CURLE_OK;
+}
+void Curl_ssh_cleanup(void)
+{
+}
+
+#endif /* USE_WOLFSSH */
diff --git a/contrib/libs/curl/lib/vtls/bearssl.c b/contrib/libs/curl/lib/vtls/bearssl.c
index 8599844c1d..b0c3dc2f07 100644
--- a/contrib/libs/curl/lib/vtls/bearssl.c
+++ b/contrib/libs/curl/lib/vtls/bearssl.c
@@ -1,877 +1,877 @@
-/***************************************************************************
- * _ _ ____ _
- * Project ___| | | | _ \| |
- * / __| | | | |_) | |
- * | (__| |_| | _ <| |___
- * \___|\___/|_| \_\_____|
- *
- * Copyright (C) 2019 - 2020, Michael Forney, <mforney@mforney.org>
- *
- * This software is licensed as described in the file COPYING, which
- * you should have received as part of this distribution. The terms
- * are also available at https://curl.se/docs/copyright.html.
- *
- * You may opt to use, copy, modify, merge, publish, distribute and/or sell
- * copies of the Software, and permit persons to whom the Software is
- * furnished to do so, under the terms of the COPYING file.
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- ***************************************************************************/
-#include "curl_setup.h"
-
-#ifdef USE_BEARSSL
-
-#include <bearssl.h>
-
-#include "bearssl.h"
-#include "urldata.h"
-#include "sendf.h"
-#include "inet_pton.h"
-#include "vtls.h"
-#include "connect.h"
-#include "select.h"
-#include "multiif.h"
-#include "curl_printf.h"
-#include "curl_memory.h"
-
-struct x509_context {
- const br_x509_class *vtable;
- br_x509_minimal_context minimal;
- bool verifyhost;
- bool verifypeer;
-};
-
-struct ssl_backend_data {
- br_ssl_client_context ctx;
- struct x509_context x509;
- unsigned char buf[BR_SSL_BUFSIZE_BIDI];
- br_x509_trust_anchor *anchors;
- size_t anchors_len;
- const char *protocols[2];
- /* SSL client context is active */
- bool active;
- /* size of pending write, yet to be flushed */
- size_t pending_write;
-};
-
-struct cafile_parser {
- CURLcode err;
- bool in_cert;
- br_x509_decoder_context xc;
- /* array of trust anchors loaded from CAfile */
- br_x509_trust_anchor *anchors;
- size_t anchors_len;
- /* buffer for DN data */
- unsigned char dn[1024];
- size_t dn_len;
-};
-
-static void append_dn(void *ctx, const void *buf, size_t len)
-{
- struct cafile_parser *ca = ctx;
-
- if(ca->err != CURLE_OK || !ca->in_cert)
- return;
- if(sizeof(ca->dn) - ca->dn_len < len) {
- ca->err = CURLE_FAILED_INIT;
- return;
- }
- memcpy(ca->dn + ca->dn_len, buf, len);
- ca->dn_len += len;
-}
-
-static void x509_push(void *ctx, const void *buf, size_t len)
-{
- struct cafile_parser *ca = ctx;
-
- if(ca->in_cert)
- br_x509_decoder_push(&ca->xc, buf, len);
-}
-
-static CURLcode load_cafile(const char *path, br_x509_trust_anchor **anchors,
- size_t *anchors_len)
-{
- struct cafile_parser ca;
- br_pem_decoder_context pc;
- br_x509_trust_anchor *ta;
- size_t ta_size;
- br_x509_trust_anchor *new_anchors;
- size_t new_anchors_len;
- br_x509_pkey *pkey;
- FILE *fp;
- unsigned char buf[BUFSIZ], *p;
- const char *name;
- size_t n, i, pushed;
-
- fp = fopen(path, "rb");
- if(!fp)
- return CURLE_SSL_CACERT_BADFILE;
-
- ca.err = CURLE_OK;
- ca.in_cert = FALSE;
- ca.anchors = NULL;
- ca.anchors_len = 0;
- br_pem_decoder_init(&pc);
- br_pem_decoder_setdest(&pc, x509_push, &ca);
- for(;;) {
- n = fread(buf, 1, sizeof(buf), fp);
- if(n == 0)
- break;
- p = buf;
- while(n) {
- pushed = br_pem_decoder_push(&pc, p, n);
- if(ca.err)
- goto fail;
- p += pushed;
- n -= pushed;
-
- switch(br_pem_decoder_event(&pc)) {
- case 0:
- break;
- case BR_PEM_BEGIN_OBJ:
- name = br_pem_decoder_name(&pc);
- if(strcmp(name, "CERTIFICATE") && strcmp(name, "X509 CERTIFICATE"))
- break;
- br_x509_decoder_init(&ca.xc, append_dn, &ca);
- if(ca.anchors_len == SIZE_MAX / sizeof(ca.anchors[0])) {
- ca.err = CURLE_OUT_OF_MEMORY;
- goto fail;
- }
- new_anchors_len = ca.anchors_len + 1;
- new_anchors = realloc(ca.anchors,
- new_anchors_len * sizeof(ca.anchors[0]));
- if(!new_anchors) {
- ca.err = CURLE_OUT_OF_MEMORY;
- goto fail;
- }
- ca.anchors = new_anchors;
- ca.anchors_len = new_anchors_len;
- ca.in_cert = TRUE;
- ca.dn_len = 0;
- ta = &ca.anchors[ca.anchors_len - 1];
- ta->dn.data = NULL;
- break;
- case BR_PEM_END_OBJ:
- if(!ca.in_cert)
- break;
- ca.in_cert = FALSE;
- if(br_x509_decoder_last_error(&ca.xc)) {
- ca.err = CURLE_SSL_CACERT_BADFILE;
- goto fail;
- }
- ta->flags = 0;
- if(br_x509_decoder_isCA(&ca.xc))
- ta->flags |= BR_X509_TA_CA;
- pkey = br_x509_decoder_get_pkey(&ca.xc);
- if(!pkey) {
- ca.err = CURLE_SSL_CACERT_BADFILE;
- goto fail;
- }
- ta->pkey = *pkey;
-
- /* calculate space needed for trust anchor data */
- ta_size = ca.dn_len;
- switch(pkey->key_type) {
- case BR_KEYTYPE_RSA:
- ta_size += pkey->key.rsa.nlen + pkey->key.rsa.elen;
- break;
- case BR_KEYTYPE_EC:
- ta_size += pkey->key.ec.qlen;
- break;
- default:
- ca.err = CURLE_FAILED_INIT;
- goto fail;
- }
-
- /* fill in trust anchor DN and public key data */
- ta->dn.data = malloc(ta_size);
- if(!ta->dn.data) {
- ca.err = CURLE_OUT_OF_MEMORY;
- goto fail;
- }
- memcpy(ta->dn.data, ca.dn, ca.dn_len);
- ta->dn.len = ca.dn_len;
- switch(pkey->key_type) {
- case BR_KEYTYPE_RSA:
- ta->pkey.key.rsa.n = ta->dn.data + ta->dn.len;
- memcpy(ta->pkey.key.rsa.n, pkey->key.rsa.n, pkey->key.rsa.nlen);
- ta->pkey.key.rsa.e = ta->pkey.key.rsa.n + ta->pkey.key.rsa.nlen;
- memcpy(ta->pkey.key.rsa.e, pkey->key.rsa.e, pkey->key.rsa.elen);
- break;
- case BR_KEYTYPE_EC:
- ta->pkey.key.ec.q = ta->dn.data + ta->dn.len;
- memcpy(ta->pkey.key.ec.q, pkey->key.ec.q, pkey->key.ec.qlen);
- break;
- }
- break;
- default:
- ca.err = CURLE_SSL_CACERT_BADFILE;
- goto fail;
- }
- }
- }
- if(ferror(fp))
- ca.err = CURLE_READ_ERROR;
-
-fail:
- fclose(fp);
- if(ca.err == CURLE_OK) {
- *anchors = ca.anchors;
- *anchors_len = ca.anchors_len;
- }
- else {
- for(i = 0; i < ca.anchors_len; ++i)
- free(ca.anchors[i].dn.data);
- free(ca.anchors);
- }
-
- return ca.err;
-}
-
-static void x509_start_chain(const br_x509_class **ctx,
- const char *server_name)
-{
- struct x509_context *x509 = (struct x509_context *)ctx;
-
- if(!x509->verifyhost)
- server_name = NULL;
- x509->minimal.vtable->start_chain(&x509->minimal.vtable, server_name);
-}
-
-static void x509_start_cert(const br_x509_class **ctx, uint32_t length)
-{
- struct x509_context *x509 = (struct x509_context *)ctx;
-
- x509->minimal.vtable->start_cert(&x509->minimal.vtable, length);
-}
-
-static void x509_append(const br_x509_class **ctx, const unsigned char *buf,
- size_t len)
-{
- struct x509_context *x509 = (struct x509_context *)ctx;
-
- x509->minimal.vtable->append(&x509->minimal.vtable, buf, len);
-}
-
-static void x509_end_cert(const br_x509_class **ctx)
-{
- struct x509_context *x509 = (struct x509_context *)ctx;
-
- x509->minimal.vtable->end_cert(&x509->minimal.vtable);
-}
-
-static unsigned x509_end_chain(const br_x509_class **ctx)
-{
- struct x509_context *x509 = (struct x509_context *)ctx;
- unsigned err;
-
- err = x509->minimal.vtable->end_chain(&x509->minimal.vtable);
- if(err && !x509->verifypeer) {
- /* ignore any X.509 errors */
- err = BR_ERR_OK;
- }
-
- return err;
-}
-
-static const br_x509_pkey *x509_get_pkey(const br_x509_class *const *ctx,
- unsigned *usages)
-{
- struct x509_context *x509 = (struct x509_context *)ctx;
-
- return x509->minimal.vtable->get_pkey(&x509->minimal.vtable, usages);
-}
-
-static const br_x509_class x509_vtable = {
- sizeof(struct x509_context),
- x509_start_chain,
- x509_start_cert,
- x509_append,
- x509_end_cert,
- x509_end_chain,
- x509_get_pkey
-};
-
-static CURLcode bearssl_connect_step1(struct connectdata *conn, int sockindex)
-{
- struct Curl_easy *data = conn->data;
- struct ssl_connect_data *connssl = &conn->ssl[sockindex];
- struct ssl_backend_data *backend = connssl->backend;
- const char * const ssl_cafile = SSL_CONN_CONFIG(CAfile);
-#ifndef CURL_DISABLE_PROXY
- const char *hostname = SSL_IS_PROXY() ? conn->http_proxy.host.name :
- conn->host.name;
-#else
- const char *hostname = conn->host.name;
-#endif
- const bool verifypeer = SSL_CONN_CONFIG(verifypeer);
- const bool verifyhost = SSL_CONN_CONFIG(verifyhost);
- CURLcode ret;
- unsigned version_min, version_max;
-#ifdef ENABLE_IPV6
- struct in6_addr addr;
-#else
- struct in_addr addr;
-#endif
-
- switch(SSL_CONN_CONFIG(version)) {
- case CURL_SSLVERSION_SSLv2:
- failf(data, "BearSSL does not support SSLv2");
- return CURLE_SSL_CONNECT_ERROR;
- case CURL_SSLVERSION_SSLv3:
- failf(data, "BearSSL does not support SSLv3");
- return CURLE_SSL_CONNECT_ERROR;
- case CURL_SSLVERSION_TLSv1_0:
- version_min = BR_TLS10;
- version_max = BR_TLS10;
- break;
- case CURL_SSLVERSION_TLSv1_1:
- version_min = BR_TLS11;
- version_max = BR_TLS11;
- break;
- case CURL_SSLVERSION_TLSv1_2:
- version_min = BR_TLS12;
- version_max = BR_TLS12;
- break;
- case CURL_SSLVERSION_DEFAULT:
- case CURL_SSLVERSION_TLSv1:
- version_min = BR_TLS10;
- version_max = BR_TLS12;
- break;
- default:
- failf(data, "BearSSL: unknown CURLOPT_SSLVERSION");
- return CURLE_SSL_CONNECT_ERROR;
- }
-
- if(ssl_cafile) {
- ret = load_cafile(ssl_cafile, &backend->anchors, &backend->anchors_len);
- if(ret != CURLE_OK) {
- if(verifypeer) {
- failf(data, "error setting certificate verify locations:\n"
- " CAfile: %s\n", ssl_cafile);
- return ret;
- }
- infof(data, "error setting certificate verify locations,"
- " continuing anyway:\n");
- }
- }
-
- /* initialize SSL context */
- br_ssl_client_init_full(&backend->ctx, &backend->x509.minimal,
- backend->anchors, backend->anchors_len);
- br_ssl_engine_set_versions(&backend->ctx.eng, version_min, version_max);
- br_ssl_engine_set_buffer(&backend->ctx.eng, backend->buf,
- sizeof(backend->buf), 1);
-
- /* initialize X.509 context */
- backend->x509.vtable = &x509_vtable;
- backend->x509.verifypeer = verifypeer;
- backend->x509.verifyhost = verifyhost;
- br_ssl_engine_set_x509(&backend->ctx.eng, &backend->x509.vtable);
-
- if(SSL_SET_OPTION(primary.sessionid)) {
- void *session;
-
- Curl_ssl_sessionid_lock(conn);
- if(!Curl_ssl_getsessionid(conn, &session, NULL, sockindex)) {
- br_ssl_engine_set_session_parameters(&backend->ctx.eng, session);
- infof(data, "BearSSL: re-using session ID\n");
- }
- Curl_ssl_sessionid_unlock(conn);
- }
-
- if(conn->bits.tls_enable_alpn) {
- int cur = 0;
-
- /* NOTE: when adding more protocols here, increase the size of the
- * protocols array in `struct ssl_backend_data`.
- */
-
-#ifdef USE_NGHTTP2
- if(data->set.httpversion >= CURL_HTTP_VERSION_2
-#ifndef CURL_DISABLE_PROXY
- && (!SSL_IS_PROXY() || !conn->bits.tunnel_proxy)
-#endif
- ) {
- backend->protocols[cur++] = NGHTTP2_PROTO_VERSION_ID;
- infof(data, "ALPN, offering %s\n", NGHTTP2_PROTO_VERSION_ID);
- }
-#endif
-
- backend->protocols[cur++] = ALPN_HTTP_1_1;
- infof(data, "ALPN, offering %s\n", ALPN_HTTP_1_1);
-
- br_ssl_engine_set_protocol_names(&backend->ctx.eng,
- backend->protocols, cur);
- }
-
- if((1 == Curl_inet_pton(AF_INET, hostname, &addr))
-#ifdef ENABLE_IPV6
- || (1 == Curl_inet_pton(AF_INET6, hostname, &addr))
-#endif
- ) {
- if(verifyhost) {
- failf(data, "BearSSL: "
- "host verification of IP address is not supported");
- return CURLE_PEER_FAILED_VERIFICATION;
- }
- hostname = NULL;
- }
-
- if(!br_ssl_client_reset(&backend->ctx, hostname, 0))
- return CURLE_FAILED_INIT;
- backend->active = TRUE;
-
- connssl->connecting_state = ssl_connect_2;
-
- return CURLE_OK;
-}
-
-static CURLcode bearssl_run_until(struct connectdata *conn, int sockindex,
- unsigned target)
-{
- struct Curl_easy *data = conn->data;
- struct ssl_connect_data *connssl = &conn->ssl[sockindex];
- struct ssl_backend_data *backend = connssl->backend;
- curl_socket_t sockfd = conn->sock[sockindex];
- unsigned state;
- unsigned char *buf;
- size_t len;
- ssize_t ret;
- int err;
-
- for(;;) {
- state = br_ssl_engine_current_state(&backend->ctx.eng);
- if(state & BR_SSL_CLOSED) {
- err = br_ssl_engine_last_error(&backend->ctx.eng);
- switch(err) {
- case BR_ERR_OK:
- /* TLS close notify */
- if(connssl->state != ssl_connection_complete) {
- failf(data, "SSL: connection closed during handshake");
- return CURLE_SSL_CONNECT_ERROR;
- }
- return CURLE_OK;
- case BR_ERR_X509_EXPIRED:
- failf(data, "SSL: X.509 verification: "
- "certificate is expired or not yet valid");
- return CURLE_PEER_FAILED_VERIFICATION;
- case BR_ERR_X509_BAD_SERVER_NAME:
- failf(data, "SSL: X.509 verification: "
- "expected server name was not found in the chain");
- return CURLE_PEER_FAILED_VERIFICATION;
- case BR_ERR_X509_NOT_TRUSTED:
- failf(data, "SSL: X.509 verification: "
- "chain could not be linked to a trust anchor");
- return CURLE_PEER_FAILED_VERIFICATION;
- }
- /* X.509 errors are documented to have the range 32..63 */
- if(err >= 32 && err < 64)
- return CURLE_PEER_FAILED_VERIFICATION;
- return CURLE_SSL_CONNECT_ERROR;
- }
- if(state & target)
- return CURLE_OK;
- if(state & BR_SSL_SENDREC) {
- buf = br_ssl_engine_sendrec_buf(&backend->ctx.eng, &len);
- ret = swrite(sockfd, buf, len);
- if(ret == -1) {
- if(SOCKERRNO == EAGAIN || SOCKERRNO == EWOULDBLOCK) {
- if(connssl->state != ssl_connection_complete)
- connssl->connecting_state = ssl_connect_2_writing;
- return CURLE_AGAIN;
- }
- return CURLE_WRITE_ERROR;
- }
- br_ssl_engine_sendrec_ack(&backend->ctx.eng, ret);
- }
- else if(state & BR_SSL_RECVREC) {
- buf = br_ssl_engine_recvrec_buf(&backend->ctx.eng, &len);
- ret = sread(sockfd, buf, len);
- if(ret == 0) {
- failf(data, "SSL: EOF without close notify");
- return CURLE_READ_ERROR;
- }
- if(ret == -1) {
- if(SOCKERRNO == EAGAIN || SOCKERRNO == EWOULDBLOCK) {
- if(connssl->state != ssl_connection_complete)
- connssl->connecting_state = ssl_connect_2_reading;
- return CURLE_AGAIN;
- }
- return CURLE_READ_ERROR;
- }
- br_ssl_engine_recvrec_ack(&backend->ctx.eng, ret);
- }
- }
-}
-
-static CURLcode bearssl_connect_step2(struct connectdata *conn, int sockindex)
-{
- struct Curl_easy *data = conn->data;
- struct ssl_connect_data *connssl = &conn->ssl[sockindex];
- struct ssl_backend_data *backend = connssl->backend;
- CURLcode ret;
-
- ret = bearssl_run_until(conn, sockindex, BR_SSL_SENDAPP | BR_SSL_RECVAPP);
- if(ret == CURLE_AGAIN)
- return CURLE_OK;
- if(ret == CURLE_OK) {
- if(br_ssl_engine_current_state(&backend->ctx.eng) == BR_SSL_CLOSED) {
- failf(data, "SSL: connection closed during handshake");
- return CURLE_SSL_CONNECT_ERROR;
- }
- connssl->connecting_state = ssl_connect_3;
- }
- return ret;
-}
-
-static CURLcode bearssl_connect_step3(struct connectdata *conn, int sockindex)
-{
- struct Curl_easy *data = conn->data;
- struct ssl_connect_data *connssl = &conn->ssl[sockindex];
- struct ssl_backend_data *backend = connssl->backend;
- CURLcode ret;
-
- DEBUGASSERT(ssl_connect_3 == connssl->connecting_state);
-
- if(conn->bits.tls_enable_alpn) {
- const char *protocol;
-
- protocol = br_ssl_engine_get_selected_protocol(&backend->ctx.eng);
- if(protocol) {
- infof(data, "ALPN, server accepted to use %s\n", protocol);
-
-#ifdef USE_NGHTTP2
- if(!strcmp(protocol, NGHTTP2_PROTO_VERSION_ID))
- conn->negnpn = CURL_HTTP_VERSION_2;
- else
-#endif
- if(!strcmp(protocol, ALPN_HTTP_1_1))
- conn->negnpn = CURL_HTTP_VERSION_1_1;
- else
- infof(data, "ALPN, unrecognized protocol %s\n", protocol);
- Curl_multiuse_state(conn, conn->negnpn == CURL_HTTP_VERSION_2 ?
- BUNDLE_MULTIPLEX : BUNDLE_NO_MULTIUSE);
- }
- else
- infof(data, "ALPN, server did not agree to a protocol\n");
- }
-
- if(SSL_SET_OPTION(primary.sessionid)) {
- bool incache;
- void *oldsession;
- br_ssl_session_parameters *session;
-
- session = malloc(sizeof(*session));
- if(!session)
- return CURLE_OUT_OF_MEMORY;
- br_ssl_engine_get_session_parameters(&backend->ctx.eng, session);
- Curl_ssl_sessionid_lock(conn);
- incache = !(Curl_ssl_getsessionid(conn, &oldsession, NULL, sockindex));
- if(incache)
- Curl_ssl_delsessionid(conn, oldsession);
- ret = Curl_ssl_addsessionid(conn, session, 0, sockindex);
- Curl_ssl_sessionid_unlock(conn);
- if(ret) {
- free(session);
- return CURLE_OUT_OF_MEMORY;
- }
- }
-
- connssl->connecting_state = ssl_connect_done;
-
- return CURLE_OK;
-}
-
-static ssize_t bearssl_send(struct connectdata *conn, int sockindex,
- const void *buf, size_t len, CURLcode *err)
-{
- struct Curl_easy *data = conn->data;
- struct ssl_connect_data *connssl = &conn->ssl[sockindex];
- struct ssl_backend_data *backend = connssl->backend;
- unsigned char *app;
- size_t applen;
-
- for(;;) {
- *err = bearssl_run_until(conn, sockindex, BR_SSL_SENDAPP);
- if (*err != CURLE_OK)
- return -1;
- app = br_ssl_engine_sendapp_buf(&backend->ctx.eng, &applen);
- if(!app) {
- failf(data, "SSL: connection closed during write");
- *err = CURLE_SEND_ERROR;
- return -1;
- }
- if(backend->pending_write) {
- applen = backend->pending_write;
- backend->pending_write = 0;
- return applen;
- }
- if(applen > len)
- applen = len;
- memcpy(app, buf, applen);
- br_ssl_engine_sendapp_ack(&backend->ctx.eng, applen);
- br_ssl_engine_flush(&backend->ctx.eng, 0);
- backend->pending_write = applen;
- }
-}
-
-static ssize_t bearssl_recv(struct connectdata *conn, int sockindex,
- char *buf, size_t len, CURLcode *err)
-{
- struct ssl_connect_data *connssl = &conn->ssl[sockindex];
- struct ssl_backend_data *backend = connssl->backend;
- unsigned char *app;
- size_t applen;
-
- *err = bearssl_run_until(conn, sockindex, BR_SSL_RECVAPP);
- if(*err != CURLE_OK)
- return -1;
- app = br_ssl_engine_recvapp_buf(&backend->ctx.eng, &applen);
- if(!app)
- return 0;
- if(applen > len)
- applen = len;
- memcpy(buf, app, applen);
- br_ssl_engine_recvapp_ack(&backend->ctx.eng, applen);
-
- return applen;
-}
-
-static CURLcode bearssl_connect_common(struct connectdata *conn,
- int sockindex,
- bool nonblocking,
- bool *done)
-{
- CURLcode ret;
- struct Curl_easy *data = conn->data;
- struct ssl_connect_data *connssl = &conn->ssl[sockindex];
- curl_socket_t sockfd = conn->sock[sockindex];
- timediff_t timeout_ms;
- int what;
-
- /* check if the connection has already been established */
- if(ssl_connection_complete == connssl->state) {
- *done = TRUE;
- return CURLE_OK;
- }
-
- if(ssl_connect_1 == connssl->connecting_state) {
- ret = bearssl_connect_step1(conn, sockindex);
- if(ret)
- return ret;
- }
-
- while(ssl_connect_2 == connssl->connecting_state ||
- ssl_connect_2_reading == connssl->connecting_state ||
- ssl_connect_2_writing == connssl->connecting_state) {
- /* check allowed time left */
- timeout_ms = Curl_timeleft(data, NULL, TRUE);
-
- if(timeout_ms < 0) {
- /* no need to continue if time already is up */
- failf(data, "SSL connection timeout");
- return CURLE_OPERATION_TIMEDOUT;
- }
-
- /* if ssl is expecting something, check if it's available. */
- if(ssl_connect_2_reading == connssl->connecting_state ||
- ssl_connect_2_writing == connssl->connecting_state) {
-
- curl_socket_t writefd = ssl_connect_2_writing ==
- connssl->connecting_state?sockfd:CURL_SOCKET_BAD;
- curl_socket_t readfd = ssl_connect_2_reading ==
- connssl->connecting_state?sockfd:CURL_SOCKET_BAD;
-
- what = Curl_socket_check(readfd, CURL_SOCKET_BAD, writefd,
- nonblocking?0:timeout_ms);
- if(what < 0) {
- /* fatal error */
- failf(data, "select/poll on SSL socket, errno: %d", SOCKERRNO);
- return CURLE_SSL_CONNECT_ERROR;
- }
- else if(0 == what) {
- if(nonblocking) {
- *done = FALSE;
- return CURLE_OK;
- }
- else {
- /* timeout */
- failf(data, "SSL connection timeout");
- return CURLE_OPERATION_TIMEDOUT;
- }
- }
- /* socket is readable or writable */
- }
-
- /* Run transaction, and return to the caller if it failed or if this
- * connection is done nonblocking and this loop would execute again. This
- * permits the owner of a multi handle to abort a connection attempt
- * before step2 has completed while ensuring that a client using select()
- * or epoll() will always have a valid fdset to wait on.
- */
- ret = bearssl_connect_step2(conn, sockindex);
- if(ret || (nonblocking &&
- (ssl_connect_2 == connssl->connecting_state ||
- ssl_connect_2_reading == connssl->connecting_state ||
- ssl_connect_2_writing == connssl->connecting_state)))
- return ret;
- }
-
- if(ssl_connect_3 == connssl->connecting_state) {
- ret = bearssl_connect_step3(conn, sockindex);
- if(ret)
- return ret;
- }
-
- if(ssl_connect_done == connssl->connecting_state) {
- connssl->state = ssl_connection_complete;
- conn->recv[sockindex] = bearssl_recv;
- conn->send[sockindex] = bearssl_send;
- *done = TRUE;
- }
- else
- *done = FALSE;
-
- /* Reset our connect state machine */
- connssl->connecting_state = ssl_connect_1;
-
- return CURLE_OK;
-}
-
-static size_t Curl_bearssl_version(char *buffer, size_t size)
-{
- return msnprintf(buffer, size, "BearSSL");
-}
-
-static bool Curl_bearssl_data_pending(const struct connectdata *conn,
- int connindex)
-{
- const struct ssl_connect_data *connssl = &conn->ssl[connindex];
- struct ssl_backend_data *backend = connssl->backend;
- return br_ssl_engine_current_state(&backend->ctx.eng) & BR_SSL_RECVAPP;
-}
-
-static CURLcode Curl_bearssl_random(struct Curl_easy *data UNUSED_PARAM,
- unsigned char *entropy, size_t length)
-{
- static br_hmac_drbg_context ctx;
- static bool seeded = FALSE;
-
- if(!seeded) {
- br_prng_seeder seeder;
-
- br_hmac_drbg_init(&ctx, &br_sha256_vtable, NULL, 0);
- seeder = br_prng_seeder_system(NULL);
- if(!seeder || !seeder(&ctx.vtable))
- return CURLE_FAILED_INIT;
- seeded = TRUE;
- }
- br_hmac_drbg_generate(&ctx, entropy, length);
-
- return CURLE_OK;
-}
-
-static CURLcode Curl_bearssl_connect(struct connectdata *conn, int sockindex)
-{
- CURLcode ret;
- bool done = FALSE;
-
- ret = bearssl_connect_common(conn, sockindex, FALSE, &done);
- if(ret)
- return ret;
-
- DEBUGASSERT(done);
-
- return CURLE_OK;
-}
-
-static CURLcode Curl_bearssl_connect_nonblocking(struct connectdata *conn,
- int sockindex, bool *done)
-{
- return bearssl_connect_common(conn, sockindex, TRUE, done);
-}
-
-static void *Curl_bearssl_get_internals(struct ssl_connect_data *connssl,
- CURLINFO info UNUSED_PARAM)
-{
- struct ssl_backend_data *backend = connssl->backend;
- return &backend->ctx;
-}
-
-static void Curl_bearssl_close(struct connectdata *conn, int sockindex)
-{
- struct ssl_connect_data *connssl = &conn->ssl[sockindex];
- struct ssl_backend_data *backend = connssl->backend;
- size_t i;
-
- if(backend->active) {
- br_ssl_engine_close(&backend->ctx.eng);
- (void)bearssl_run_until(conn, sockindex, BR_SSL_CLOSED);
- }
- for(i = 0; i < backend->anchors_len; ++i)
- free(backend->anchors[i].dn.data);
- free(backend->anchors);
-}
-
-static void Curl_bearssl_session_free(void *ptr)
-{
- free(ptr);
-}
-
-static CURLcode Curl_bearssl_md5sum(unsigned char *input,
- size_t inputlen,
- unsigned char *md5sum,
- size_t md5len UNUSED_PARAM)
-{
- br_md5_context ctx;
-
- br_md5_init(&ctx);
- br_md5_update(&ctx, input, inputlen);
- br_md5_out(&ctx, md5sum);
- return CURLE_OK;
-}
-
-static CURLcode Curl_bearssl_sha256sum(const unsigned char *input,
- size_t inputlen,
- unsigned char *sha256sum,
- size_t sha256len UNUSED_PARAM)
-{
- br_sha256_context ctx;
-
- br_sha256_init(&ctx);
- br_sha256_update(&ctx, input, inputlen);
- br_sha256_out(&ctx, sha256sum);
- return CURLE_OK;
-}
-
-const struct Curl_ssl Curl_ssl_bearssl = {
- { CURLSSLBACKEND_BEARSSL, "bearssl" },
- 0,
- sizeof(struct ssl_backend_data),
-
- Curl_none_init,
- Curl_none_cleanup,
- Curl_bearssl_version,
- Curl_none_check_cxn,
- Curl_none_shutdown,
- Curl_bearssl_data_pending,
- Curl_bearssl_random,
- Curl_none_cert_status_request,
- Curl_bearssl_connect,
- Curl_bearssl_connect_nonblocking,
- Curl_bearssl_get_internals,
- Curl_bearssl_close,
- Curl_none_close_all,
- Curl_bearssl_session_free,
- Curl_none_set_engine,
- Curl_none_set_engine_default,
- Curl_none_engines_list,
- Curl_none_false_start,
- Curl_bearssl_md5sum,
- Curl_bearssl_sha256sum
-};
-
-#endif /* USE_BEARSSL */
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 2019 - 2020, Michael Forney, <mforney@mforney.org>
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at https://curl.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+#include "curl_setup.h"
+
+#ifdef USE_BEARSSL
+
+#include <bearssl.h>
+
+#include "bearssl.h"
+#include "urldata.h"
+#include "sendf.h"
+#include "inet_pton.h"
+#include "vtls.h"
+#include "connect.h"
+#include "select.h"
+#include "multiif.h"
+#include "curl_printf.h"
+#include "curl_memory.h"
+
+struct x509_context {
+ const br_x509_class *vtable;
+ br_x509_minimal_context minimal;
+ bool verifyhost;
+ bool verifypeer;
+};
+
+struct ssl_backend_data {
+ br_ssl_client_context ctx;
+ struct x509_context x509;
+ unsigned char buf[BR_SSL_BUFSIZE_BIDI];
+ br_x509_trust_anchor *anchors;
+ size_t anchors_len;
+ const char *protocols[2];
+ /* SSL client context is active */
+ bool active;
+ /* size of pending write, yet to be flushed */
+ size_t pending_write;
+};
+
+struct cafile_parser {
+ CURLcode err;
+ bool in_cert;
+ br_x509_decoder_context xc;
+ /* array of trust anchors loaded from CAfile */
+ br_x509_trust_anchor *anchors;
+ size_t anchors_len;
+ /* buffer for DN data */
+ unsigned char dn[1024];
+ size_t dn_len;
+};
+
+static void append_dn(void *ctx, const void *buf, size_t len)
+{
+ struct cafile_parser *ca = ctx;
+
+ if(ca->err != CURLE_OK || !ca->in_cert)
+ return;
+ if(sizeof(ca->dn) - ca->dn_len < len) {
+ ca->err = CURLE_FAILED_INIT;
+ return;
+ }
+ memcpy(ca->dn + ca->dn_len, buf, len);
+ ca->dn_len += len;
+}
+
+static void x509_push(void *ctx, const void *buf, size_t len)
+{
+ struct cafile_parser *ca = ctx;
+
+ if(ca->in_cert)
+ br_x509_decoder_push(&ca->xc, buf, len);
+}
+
+static CURLcode load_cafile(const char *path, br_x509_trust_anchor **anchors,
+ size_t *anchors_len)
+{
+ struct cafile_parser ca;
+ br_pem_decoder_context pc;
+ br_x509_trust_anchor *ta;
+ size_t ta_size;
+ br_x509_trust_anchor *new_anchors;
+ size_t new_anchors_len;
+ br_x509_pkey *pkey;
+ FILE *fp;
+ unsigned char buf[BUFSIZ], *p;
+ const char *name;
+ size_t n, i, pushed;
+
+ fp = fopen(path, "rb");
+ if(!fp)
+ return CURLE_SSL_CACERT_BADFILE;
+
+ ca.err = CURLE_OK;
+ ca.in_cert = FALSE;
+ ca.anchors = NULL;
+ ca.anchors_len = 0;
+ br_pem_decoder_init(&pc);
+ br_pem_decoder_setdest(&pc, x509_push, &ca);
+ for(;;) {
+ n = fread(buf, 1, sizeof(buf), fp);
+ if(n == 0)
+ break;
+ p = buf;
+ while(n) {
+ pushed = br_pem_decoder_push(&pc, p, n);
+ if(ca.err)
+ goto fail;
+ p += pushed;
+ n -= pushed;
+
+ switch(br_pem_decoder_event(&pc)) {
+ case 0:
+ break;
+ case BR_PEM_BEGIN_OBJ:
+ name = br_pem_decoder_name(&pc);
+ if(strcmp(name, "CERTIFICATE") && strcmp(name, "X509 CERTIFICATE"))
+ break;
+ br_x509_decoder_init(&ca.xc, append_dn, &ca);
+ if(ca.anchors_len == SIZE_MAX / sizeof(ca.anchors[0])) {
+ ca.err = CURLE_OUT_OF_MEMORY;
+ goto fail;
+ }
+ new_anchors_len = ca.anchors_len + 1;
+ new_anchors = realloc(ca.anchors,
+ new_anchors_len * sizeof(ca.anchors[0]));
+ if(!new_anchors) {
+ ca.err = CURLE_OUT_OF_MEMORY;
+ goto fail;
+ }
+ ca.anchors = new_anchors;
+ ca.anchors_len = new_anchors_len;
+ ca.in_cert = TRUE;
+ ca.dn_len = 0;
+ ta = &ca.anchors[ca.anchors_len - 1];
+ ta->dn.data = NULL;
+ break;
+ case BR_PEM_END_OBJ:
+ if(!ca.in_cert)
+ break;
+ ca.in_cert = FALSE;
+ if(br_x509_decoder_last_error(&ca.xc)) {
+ ca.err = CURLE_SSL_CACERT_BADFILE;
+ goto fail;
+ }
+ ta->flags = 0;
+ if(br_x509_decoder_isCA(&ca.xc))
+ ta->flags |= BR_X509_TA_CA;
+ pkey = br_x509_decoder_get_pkey(&ca.xc);
+ if(!pkey) {
+ ca.err = CURLE_SSL_CACERT_BADFILE;
+ goto fail;
+ }
+ ta->pkey = *pkey;
+
+ /* calculate space needed for trust anchor data */
+ ta_size = ca.dn_len;
+ switch(pkey->key_type) {
+ case BR_KEYTYPE_RSA:
+ ta_size += pkey->key.rsa.nlen + pkey->key.rsa.elen;
+ break;
+ case BR_KEYTYPE_EC:
+ ta_size += pkey->key.ec.qlen;
+ break;
+ default:
+ ca.err = CURLE_FAILED_INIT;
+ goto fail;
+ }
+
+ /* fill in trust anchor DN and public key data */
+ ta->dn.data = malloc(ta_size);
+ if(!ta->dn.data) {
+ ca.err = CURLE_OUT_OF_MEMORY;
+ goto fail;
+ }
+ memcpy(ta->dn.data, ca.dn, ca.dn_len);
+ ta->dn.len = ca.dn_len;
+ switch(pkey->key_type) {
+ case BR_KEYTYPE_RSA:
+ ta->pkey.key.rsa.n = ta->dn.data + ta->dn.len;
+ memcpy(ta->pkey.key.rsa.n, pkey->key.rsa.n, pkey->key.rsa.nlen);
+ ta->pkey.key.rsa.e = ta->pkey.key.rsa.n + ta->pkey.key.rsa.nlen;
+ memcpy(ta->pkey.key.rsa.e, pkey->key.rsa.e, pkey->key.rsa.elen);
+ break;
+ case BR_KEYTYPE_EC:
+ ta->pkey.key.ec.q = ta->dn.data + ta->dn.len;
+ memcpy(ta->pkey.key.ec.q, pkey->key.ec.q, pkey->key.ec.qlen);
+ break;
+ }
+ break;
+ default:
+ ca.err = CURLE_SSL_CACERT_BADFILE;
+ goto fail;
+ }
+ }
+ }
+ if(ferror(fp))
+ ca.err = CURLE_READ_ERROR;
+
+fail:
+ fclose(fp);
+ if(ca.err == CURLE_OK) {
+ *anchors = ca.anchors;
+ *anchors_len = ca.anchors_len;
+ }
+ else {
+ for(i = 0; i < ca.anchors_len; ++i)
+ free(ca.anchors[i].dn.data);
+ free(ca.anchors);
+ }
+
+ return ca.err;
+}
+
+static void x509_start_chain(const br_x509_class **ctx,
+ const char *server_name)
+{
+ struct x509_context *x509 = (struct x509_context *)ctx;
+
+ if(!x509->verifyhost)
+ server_name = NULL;
+ x509->minimal.vtable->start_chain(&x509->minimal.vtable, server_name);
+}
+
+static void x509_start_cert(const br_x509_class **ctx, uint32_t length)
+{
+ struct x509_context *x509 = (struct x509_context *)ctx;
+
+ x509->minimal.vtable->start_cert(&x509->minimal.vtable, length);
+}
+
+static void x509_append(const br_x509_class **ctx, const unsigned char *buf,
+ size_t len)
+{
+ struct x509_context *x509 = (struct x509_context *)ctx;
+
+ x509->minimal.vtable->append(&x509->minimal.vtable, buf, len);
+}
+
+static void x509_end_cert(const br_x509_class **ctx)
+{
+ struct x509_context *x509 = (struct x509_context *)ctx;
+
+ x509->minimal.vtable->end_cert(&x509->minimal.vtable);
+}
+
+static unsigned x509_end_chain(const br_x509_class **ctx)
+{
+ struct x509_context *x509 = (struct x509_context *)ctx;
+ unsigned err;
+
+ err = x509->minimal.vtable->end_chain(&x509->minimal.vtable);
+ if(err && !x509->verifypeer) {
+ /* ignore any X.509 errors */
+ err = BR_ERR_OK;
+ }
+
+ return err;
+}
+
+static const br_x509_pkey *x509_get_pkey(const br_x509_class *const *ctx,
+ unsigned *usages)
+{
+ struct x509_context *x509 = (struct x509_context *)ctx;
+
+ return x509->minimal.vtable->get_pkey(&x509->minimal.vtable, usages);
+}
+
+static const br_x509_class x509_vtable = {
+ sizeof(struct x509_context),
+ x509_start_chain,
+ x509_start_cert,
+ x509_append,
+ x509_end_cert,
+ x509_end_chain,
+ x509_get_pkey
+};
+
+static CURLcode bearssl_connect_step1(struct connectdata *conn, int sockindex)
+{
+ struct Curl_easy *data = conn->data;
+ struct ssl_connect_data *connssl = &conn->ssl[sockindex];
+ struct ssl_backend_data *backend = connssl->backend;
+ const char * const ssl_cafile = SSL_CONN_CONFIG(CAfile);
+#ifndef CURL_DISABLE_PROXY
+ const char *hostname = SSL_IS_PROXY() ? conn->http_proxy.host.name :
+ conn->host.name;
+#else
+ const char *hostname = conn->host.name;
+#endif
+ const bool verifypeer = SSL_CONN_CONFIG(verifypeer);
+ const bool verifyhost = SSL_CONN_CONFIG(verifyhost);
+ CURLcode ret;
+ unsigned version_min, version_max;
+#ifdef ENABLE_IPV6
+ struct in6_addr addr;
+#else
+ struct in_addr addr;
+#endif
+
+ switch(SSL_CONN_CONFIG(version)) {
+ case CURL_SSLVERSION_SSLv2:
+ failf(data, "BearSSL does not support SSLv2");
+ return CURLE_SSL_CONNECT_ERROR;
+ case CURL_SSLVERSION_SSLv3:
+ failf(data, "BearSSL does not support SSLv3");
+ return CURLE_SSL_CONNECT_ERROR;
+ case CURL_SSLVERSION_TLSv1_0:
+ version_min = BR_TLS10;
+ version_max = BR_TLS10;
+ break;
+ case CURL_SSLVERSION_TLSv1_1:
+ version_min = BR_TLS11;
+ version_max = BR_TLS11;
+ break;
+ case CURL_SSLVERSION_TLSv1_2:
+ version_min = BR_TLS12;
+ version_max = BR_TLS12;
+ break;
+ case CURL_SSLVERSION_DEFAULT:
+ case CURL_SSLVERSION_TLSv1:
+ version_min = BR_TLS10;
+ version_max = BR_TLS12;
+ break;
+ default:
+ failf(data, "BearSSL: unknown CURLOPT_SSLVERSION");
+ return CURLE_SSL_CONNECT_ERROR;
+ }
+
+ if(ssl_cafile) {
+ ret = load_cafile(ssl_cafile, &backend->anchors, &backend->anchors_len);
+ if(ret != CURLE_OK) {
+ if(verifypeer) {
+ failf(data, "error setting certificate verify locations:\n"
+ " CAfile: %s\n", ssl_cafile);
+ return ret;
+ }
+ infof(data, "error setting certificate verify locations,"
+ " continuing anyway:\n");
+ }
+ }
+
+ /* initialize SSL context */
+ br_ssl_client_init_full(&backend->ctx, &backend->x509.minimal,
+ backend->anchors, backend->anchors_len);
+ br_ssl_engine_set_versions(&backend->ctx.eng, version_min, version_max);
+ br_ssl_engine_set_buffer(&backend->ctx.eng, backend->buf,
+ sizeof(backend->buf), 1);
+
+ /* initialize X.509 context */
+ backend->x509.vtable = &x509_vtable;
+ backend->x509.verifypeer = verifypeer;
+ backend->x509.verifyhost = verifyhost;
+ br_ssl_engine_set_x509(&backend->ctx.eng, &backend->x509.vtable);
+
+ if(SSL_SET_OPTION(primary.sessionid)) {
+ void *session;
+
+ Curl_ssl_sessionid_lock(conn);
+ if(!Curl_ssl_getsessionid(conn, &session, NULL, sockindex)) {
+ br_ssl_engine_set_session_parameters(&backend->ctx.eng, session);
+ infof(data, "BearSSL: re-using session ID\n");
+ }
+ Curl_ssl_sessionid_unlock(conn);
+ }
+
+ if(conn->bits.tls_enable_alpn) {
+ int cur = 0;
+
+ /* NOTE: when adding more protocols here, increase the size of the
+ * protocols array in `struct ssl_backend_data`.
+ */
+
+#ifdef USE_NGHTTP2
+ if(data->set.httpversion >= CURL_HTTP_VERSION_2
+#ifndef CURL_DISABLE_PROXY
+ && (!SSL_IS_PROXY() || !conn->bits.tunnel_proxy)
+#endif
+ ) {
+ backend->protocols[cur++] = NGHTTP2_PROTO_VERSION_ID;
+ infof(data, "ALPN, offering %s\n", NGHTTP2_PROTO_VERSION_ID);
+ }
+#endif
+
+ backend->protocols[cur++] = ALPN_HTTP_1_1;
+ infof(data, "ALPN, offering %s\n", ALPN_HTTP_1_1);
+
+ br_ssl_engine_set_protocol_names(&backend->ctx.eng,
+ backend->protocols, cur);
+ }
+
+ if((1 == Curl_inet_pton(AF_INET, hostname, &addr))
+#ifdef ENABLE_IPV6
+ || (1 == Curl_inet_pton(AF_INET6, hostname, &addr))
+#endif
+ ) {
+ if(verifyhost) {
+ failf(data, "BearSSL: "
+ "host verification of IP address is not supported");
+ return CURLE_PEER_FAILED_VERIFICATION;
+ }
+ hostname = NULL;
+ }
+
+ if(!br_ssl_client_reset(&backend->ctx, hostname, 0))
+ return CURLE_FAILED_INIT;
+ backend->active = TRUE;
+
+ connssl->connecting_state = ssl_connect_2;
+
+ return CURLE_OK;
+}
+
+static CURLcode bearssl_run_until(struct connectdata *conn, int sockindex,
+ unsigned target)
+{
+ struct Curl_easy *data = conn->data;
+ struct ssl_connect_data *connssl = &conn->ssl[sockindex];
+ struct ssl_backend_data *backend = connssl->backend;
+ curl_socket_t sockfd = conn->sock[sockindex];
+ unsigned state;
+ unsigned char *buf;
+ size_t len;
+ ssize_t ret;
+ int err;
+
+ for(;;) {
+ state = br_ssl_engine_current_state(&backend->ctx.eng);
+ if(state & BR_SSL_CLOSED) {
+ err = br_ssl_engine_last_error(&backend->ctx.eng);
+ switch(err) {
+ case BR_ERR_OK:
+ /* TLS close notify */
+ if(connssl->state != ssl_connection_complete) {
+ failf(data, "SSL: connection closed during handshake");
+ return CURLE_SSL_CONNECT_ERROR;
+ }
+ return CURLE_OK;
+ case BR_ERR_X509_EXPIRED:
+ failf(data, "SSL: X.509 verification: "
+ "certificate is expired or not yet valid");
+ return CURLE_PEER_FAILED_VERIFICATION;
+ case BR_ERR_X509_BAD_SERVER_NAME:
+ failf(data, "SSL: X.509 verification: "
+ "expected server name was not found in the chain");
+ return CURLE_PEER_FAILED_VERIFICATION;
+ case BR_ERR_X509_NOT_TRUSTED:
+ failf(data, "SSL: X.509 verification: "
+ "chain could not be linked to a trust anchor");
+ return CURLE_PEER_FAILED_VERIFICATION;
+ }
+ /* X.509 errors are documented to have the range 32..63 */
+ if(err >= 32 && err < 64)
+ return CURLE_PEER_FAILED_VERIFICATION;
+ return CURLE_SSL_CONNECT_ERROR;
+ }
+ if(state & target)
+ return CURLE_OK;
+ if(state & BR_SSL_SENDREC) {
+ buf = br_ssl_engine_sendrec_buf(&backend->ctx.eng, &len);
+ ret = swrite(sockfd, buf, len);
+ if(ret == -1) {
+ if(SOCKERRNO == EAGAIN || SOCKERRNO == EWOULDBLOCK) {
+ if(connssl->state != ssl_connection_complete)
+ connssl->connecting_state = ssl_connect_2_writing;
+ return CURLE_AGAIN;
+ }
+ return CURLE_WRITE_ERROR;
+ }
+ br_ssl_engine_sendrec_ack(&backend->ctx.eng, ret);
+ }
+ else if(state & BR_SSL_RECVREC) {
+ buf = br_ssl_engine_recvrec_buf(&backend->ctx.eng, &len);
+ ret = sread(sockfd, buf, len);
+ if(ret == 0) {
+ failf(data, "SSL: EOF without close notify");
+ return CURLE_READ_ERROR;
+ }
+ if(ret == -1) {
+ if(SOCKERRNO == EAGAIN || SOCKERRNO == EWOULDBLOCK) {
+ if(connssl->state != ssl_connection_complete)
+ connssl->connecting_state = ssl_connect_2_reading;
+ return CURLE_AGAIN;
+ }
+ return CURLE_READ_ERROR;
+ }
+ br_ssl_engine_recvrec_ack(&backend->ctx.eng, ret);
+ }
+ }
+}
+
+static CURLcode bearssl_connect_step2(struct connectdata *conn, int sockindex)
+{
+ struct Curl_easy *data = conn->data;
+ struct ssl_connect_data *connssl = &conn->ssl[sockindex];
+ struct ssl_backend_data *backend = connssl->backend;
+ CURLcode ret;
+
+ ret = bearssl_run_until(conn, sockindex, BR_SSL_SENDAPP | BR_SSL_RECVAPP);
+ if(ret == CURLE_AGAIN)
+ return CURLE_OK;
+ if(ret == CURLE_OK) {
+ if(br_ssl_engine_current_state(&backend->ctx.eng) == BR_SSL_CLOSED) {
+ failf(data, "SSL: connection closed during handshake");
+ return CURLE_SSL_CONNECT_ERROR;
+ }
+ connssl->connecting_state = ssl_connect_3;
+ }
+ return ret;
+}
+
+static CURLcode bearssl_connect_step3(struct connectdata *conn, int sockindex)
+{
+ struct Curl_easy *data = conn->data;
+ struct ssl_connect_data *connssl = &conn->ssl[sockindex];
+ struct ssl_backend_data *backend = connssl->backend;
+ CURLcode ret;
+
+ DEBUGASSERT(ssl_connect_3 == connssl->connecting_state);
+
+ if(conn->bits.tls_enable_alpn) {
+ const char *protocol;
+
+ protocol = br_ssl_engine_get_selected_protocol(&backend->ctx.eng);
+ if(protocol) {
+ infof(data, "ALPN, server accepted to use %s\n", protocol);
+
+#ifdef USE_NGHTTP2
+ if(!strcmp(protocol, NGHTTP2_PROTO_VERSION_ID))
+ conn->negnpn = CURL_HTTP_VERSION_2;
+ else
+#endif
+ if(!strcmp(protocol, ALPN_HTTP_1_1))
+ conn->negnpn = CURL_HTTP_VERSION_1_1;
+ else
+ infof(data, "ALPN, unrecognized protocol %s\n", protocol);
+ Curl_multiuse_state(conn, conn->negnpn == CURL_HTTP_VERSION_2 ?
+ BUNDLE_MULTIPLEX : BUNDLE_NO_MULTIUSE);
+ }
+ else
+ infof(data, "ALPN, server did not agree to a protocol\n");
+ }
+
+ if(SSL_SET_OPTION(primary.sessionid)) {
+ bool incache;
+ void *oldsession;
+ br_ssl_session_parameters *session;
+
+ session = malloc(sizeof(*session));
+ if(!session)
+ return CURLE_OUT_OF_MEMORY;
+ br_ssl_engine_get_session_parameters(&backend->ctx.eng, session);
+ Curl_ssl_sessionid_lock(conn);
+ incache = !(Curl_ssl_getsessionid(conn, &oldsession, NULL, sockindex));
+ if(incache)
+ Curl_ssl_delsessionid(conn, oldsession);
+ ret = Curl_ssl_addsessionid(conn, session, 0, sockindex);
+ Curl_ssl_sessionid_unlock(conn);
+ if(ret) {
+ free(session);
+ return CURLE_OUT_OF_MEMORY;
+ }
+ }
+
+ connssl->connecting_state = ssl_connect_done;
+
+ return CURLE_OK;
+}
+
+static ssize_t bearssl_send(struct connectdata *conn, int sockindex,
+ const void *buf, size_t len, CURLcode *err)
+{
+ struct Curl_easy *data = conn->data;
+ struct ssl_connect_data *connssl = &conn->ssl[sockindex];
+ struct ssl_backend_data *backend = connssl->backend;
+ unsigned char *app;
+ size_t applen;
+
+ for(;;) {
+ *err = bearssl_run_until(conn, sockindex, BR_SSL_SENDAPP);
+ if (*err != CURLE_OK)
+ return -1;
+ app = br_ssl_engine_sendapp_buf(&backend->ctx.eng, &applen);
+ if(!app) {
+ failf(data, "SSL: connection closed during write");
+ *err = CURLE_SEND_ERROR;
+ return -1;
+ }
+ if(backend->pending_write) {
+ applen = backend->pending_write;
+ backend->pending_write = 0;
+ return applen;
+ }
+ if(applen > len)
+ applen = len;
+ memcpy(app, buf, applen);
+ br_ssl_engine_sendapp_ack(&backend->ctx.eng, applen);
+ br_ssl_engine_flush(&backend->ctx.eng, 0);
+ backend->pending_write = applen;
+ }
+}
+
+static ssize_t bearssl_recv(struct connectdata *conn, int sockindex,
+ char *buf, size_t len, CURLcode *err)
+{
+ struct ssl_connect_data *connssl = &conn->ssl[sockindex];
+ struct ssl_backend_data *backend = connssl->backend;
+ unsigned char *app;
+ size_t applen;
+
+ *err = bearssl_run_until(conn, sockindex, BR_SSL_RECVAPP);
+ if(*err != CURLE_OK)
+ return -1;
+ app = br_ssl_engine_recvapp_buf(&backend->ctx.eng, &applen);
+ if(!app)
+ return 0;
+ if(applen > len)
+ applen = len;
+ memcpy(buf, app, applen);
+ br_ssl_engine_recvapp_ack(&backend->ctx.eng, applen);
+
+ return applen;
+}
+
+static CURLcode bearssl_connect_common(struct connectdata *conn,
+ int sockindex,
+ bool nonblocking,
+ bool *done)
+{
+ CURLcode ret;
+ struct Curl_easy *data = conn->data;
+ struct ssl_connect_data *connssl = &conn->ssl[sockindex];
+ curl_socket_t sockfd = conn->sock[sockindex];
+ timediff_t timeout_ms;
+ int what;
+
+ /* check if the connection has already been established */
+ if(ssl_connection_complete == connssl->state) {
+ *done = TRUE;
+ return CURLE_OK;
+ }
+
+ if(ssl_connect_1 == connssl->connecting_state) {
+ ret = bearssl_connect_step1(conn, sockindex);
+ if(ret)
+ return ret;
+ }
+
+ while(ssl_connect_2 == connssl->connecting_state ||
+ ssl_connect_2_reading == connssl->connecting_state ||
+ ssl_connect_2_writing == connssl->connecting_state) {
+ /* check allowed time left */
+ timeout_ms = Curl_timeleft(data, NULL, TRUE);
+
+ if(timeout_ms < 0) {
+ /* no need to continue if time already is up */
+ failf(data, "SSL connection timeout");
+ return CURLE_OPERATION_TIMEDOUT;
+ }
+
+ /* if ssl is expecting something, check if it's available. */
+ if(ssl_connect_2_reading == connssl->connecting_state ||
+ ssl_connect_2_writing == connssl->connecting_state) {
+
+ curl_socket_t writefd = ssl_connect_2_writing ==
+ connssl->connecting_state?sockfd:CURL_SOCKET_BAD;
+ curl_socket_t readfd = ssl_connect_2_reading ==
+ connssl->connecting_state?sockfd:CURL_SOCKET_BAD;
+
+ what = Curl_socket_check(readfd, CURL_SOCKET_BAD, writefd,
+ nonblocking?0:timeout_ms);
+ if(what < 0) {
+ /* fatal error */
+ failf(data, "select/poll on SSL socket, errno: %d", SOCKERRNO);
+ return CURLE_SSL_CONNECT_ERROR;
+ }
+ else if(0 == what) {
+ if(nonblocking) {
+ *done = FALSE;
+ return CURLE_OK;
+ }
+ else {
+ /* timeout */
+ failf(data, "SSL connection timeout");
+ return CURLE_OPERATION_TIMEDOUT;
+ }
+ }
+ /* socket is readable or writable */
+ }
+
+ /* Run transaction, and return to the caller if it failed or if this
+ * connection is done nonblocking and this loop would execute again. This
+ * permits the owner of a multi handle to abort a connection attempt
+ * before step2 has completed while ensuring that a client using select()
+ * or epoll() will always have a valid fdset to wait on.
+ */
+ ret = bearssl_connect_step2(conn, sockindex);
+ if(ret || (nonblocking &&
+ (ssl_connect_2 == connssl->connecting_state ||
+ ssl_connect_2_reading == connssl->connecting_state ||
+ ssl_connect_2_writing == connssl->connecting_state)))
+ return ret;
+ }
+
+ if(ssl_connect_3 == connssl->connecting_state) {
+ ret = bearssl_connect_step3(conn, sockindex);
+ if(ret)
+ return ret;
+ }
+
+ if(ssl_connect_done == connssl->connecting_state) {
+ connssl->state = ssl_connection_complete;
+ conn->recv[sockindex] = bearssl_recv;
+ conn->send[sockindex] = bearssl_send;
+ *done = TRUE;
+ }
+ else
+ *done = FALSE;
+
+ /* Reset our connect state machine */
+ connssl->connecting_state = ssl_connect_1;
+
+ return CURLE_OK;
+}
+
+static size_t Curl_bearssl_version(char *buffer, size_t size)
+{
+ return msnprintf(buffer, size, "BearSSL");
+}
+
+static bool Curl_bearssl_data_pending(const struct connectdata *conn,
+ int connindex)
+{
+ const struct ssl_connect_data *connssl = &conn->ssl[connindex];
+ struct ssl_backend_data *backend = connssl->backend;
+ return br_ssl_engine_current_state(&backend->ctx.eng) & BR_SSL_RECVAPP;
+}
+
+static CURLcode Curl_bearssl_random(struct Curl_easy *data UNUSED_PARAM,
+ unsigned char *entropy, size_t length)
+{
+ static br_hmac_drbg_context ctx;
+ static bool seeded = FALSE;
+
+ if(!seeded) {
+ br_prng_seeder seeder;
+
+ br_hmac_drbg_init(&ctx, &br_sha256_vtable, NULL, 0);
+ seeder = br_prng_seeder_system(NULL);
+ if(!seeder || !seeder(&ctx.vtable))
+ return CURLE_FAILED_INIT;
+ seeded = TRUE;
+ }
+ br_hmac_drbg_generate(&ctx, entropy, length);
+
+ return CURLE_OK;
+}
+
+static CURLcode Curl_bearssl_connect(struct connectdata *conn, int sockindex)
+{
+ CURLcode ret;
+ bool done = FALSE;
+
+ ret = bearssl_connect_common(conn, sockindex, FALSE, &done);
+ if(ret)
+ return ret;
+
+ DEBUGASSERT(done);
+
+ return CURLE_OK;
+}
+
+static CURLcode Curl_bearssl_connect_nonblocking(struct connectdata *conn,
+ int sockindex, bool *done)
+{
+ return bearssl_connect_common(conn, sockindex, TRUE, done);
+}
+
+static void *Curl_bearssl_get_internals(struct ssl_connect_data *connssl,
+ CURLINFO info UNUSED_PARAM)
+{
+ struct ssl_backend_data *backend = connssl->backend;
+ return &backend->ctx;
+}
+
+static void Curl_bearssl_close(struct connectdata *conn, int sockindex)
+{
+ struct ssl_connect_data *connssl = &conn->ssl[sockindex];
+ struct ssl_backend_data *backend = connssl->backend;
+ size_t i;
+
+ if(backend->active) {
+ br_ssl_engine_close(&backend->ctx.eng);
+ (void)bearssl_run_until(conn, sockindex, BR_SSL_CLOSED);
+ }
+ for(i = 0; i < backend->anchors_len; ++i)
+ free(backend->anchors[i].dn.data);
+ free(backend->anchors);
+}
+
+static void Curl_bearssl_session_free(void *ptr)
+{
+ free(ptr);
+}
+
+static CURLcode Curl_bearssl_md5sum(unsigned char *input,
+ size_t inputlen,
+ unsigned char *md5sum,
+ size_t md5len UNUSED_PARAM)
+{
+ br_md5_context ctx;
+
+ br_md5_init(&ctx);
+ br_md5_update(&ctx, input, inputlen);
+ br_md5_out(&ctx, md5sum);
+ return CURLE_OK;
+}
+
+static CURLcode Curl_bearssl_sha256sum(const unsigned char *input,
+ size_t inputlen,
+ unsigned char *sha256sum,
+ size_t sha256len UNUSED_PARAM)
+{
+ br_sha256_context ctx;
+
+ br_sha256_init(&ctx);
+ br_sha256_update(&ctx, input, inputlen);
+ br_sha256_out(&ctx, sha256sum);
+ return CURLE_OK;
+}
+
+const struct Curl_ssl Curl_ssl_bearssl = {
+ { CURLSSLBACKEND_BEARSSL, "bearssl" },
+ 0,
+ sizeof(struct ssl_backend_data),
+
+ Curl_none_init,
+ Curl_none_cleanup,
+ Curl_bearssl_version,
+ Curl_none_check_cxn,
+ Curl_none_shutdown,
+ Curl_bearssl_data_pending,
+ Curl_bearssl_random,
+ Curl_none_cert_status_request,
+ Curl_bearssl_connect,
+ Curl_bearssl_connect_nonblocking,
+ Curl_bearssl_get_internals,
+ Curl_bearssl_close,
+ Curl_none_close_all,
+ Curl_bearssl_session_free,
+ Curl_none_set_engine,
+ Curl_none_set_engine_default,
+ Curl_none_engines_list,
+ Curl_none_false_start,
+ Curl_bearssl_md5sum,
+ Curl_bearssl_sha256sum
+};
+
+#endif /* USE_BEARSSL */
diff --git a/contrib/libs/curl/lib/vtls/bearssl.h b/contrib/libs/curl/lib/vtls/bearssl.h
index 182c13d73f..d72b7d0e26 100644
--- a/contrib/libs/curl/lib/vtls/bearssl.h
+++ b/contrib/libs/curl/lib/vtls/bearssl.h
@@ -1,32 +1,32 @@
-#ifndef HEADER_CURL_BEARSSL_H
-#define HEADER_CURL_BEARSSL_H
-/***************************************************************************
- * _ _ ____ _
- * Project ___| | | | _ \| |
- * / __| | | | |_) | |
- * | (__| |_| | _ <| |___
- * \___|\___/|_| \_\_____|
- *
- * Copyright (C) 2019 - 2020, Michael Forney, <mforney@mforney.org>
- *
- * This software is licensed as described in the file COPYING, which
- * you should have received as part of this distribution. The terms
- * are also available at https://curl.se/docs/copyright.html.
- *
- * You may opt to use, copy, modify, merge, publish, distribute and/or sell
- * copies of the Software, and permit persons to whom the Software is
- * furnished to do so, under the terms of the COPYING file.
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- ***************************************************************************/
-
-#include "curl_setup.h"
-
-#ifdef USE_BEARSSL
-
-extern const struct Curl_ssl Curl_ssl_bearssl;
-
-#endif /* USE_BEARSSL */
-#endif /* HEADER_CURL_BEARSSL_H */
+#ifndef HEADER_CURL_BEARSSL_H
+#define HEADER_CURL_BEARSSL_H
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 2019 - 2020, Michael Forney, <mforney@mforney.org>
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at https://curl.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+
+#include "curl_setup.h"
+
+#ifdef USE_BEARSSL
+
+extern const struct Curl_ssl Curl_ssl_bearssl;
+
+#endif /* USE_BEARSSL */
+#endif /* HEADER_CURL_BEARSSL_H */
diff --git a/contrib/libs/curl/lib/vtls/gskit.c b/contrib/libs/curl/lib/vtls/gskit.c
index e8b53d7e41..17584c750f 100644
--- a/contrib/libs/curl/lib/vtls/gskit.c
+++ b/contrib/libs/curl/lib/vtls/gskit.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -26,8 +26,8 @@
#include <gskssl.h>
#include <qsoasync.h>
-#undef HAVE_SOCKETPAIR /* because the native one isn't good enough */
-#include "socketpair.h"
+#undef HAVE_SOCKETPAIR /* because the native one isn't good enough */
+#include "socketpair.h"
/* Some symbols are undefined/unsupported on OS400 versions < V7R1. */
#ifndef GSK_SSL_EXTN_SERVERNAME_REQUEST
@@ -108,13 +108,13 @@ struct ssl_backend_data {
#define BACKEND connssl->backend
/* Supported ciphers. */
-struct gskit_cipher {
+struct gskit_cipher {
const char *name; /* Cipher name. */
const char *gsktoken; /* Corresponding token for GSKit String. */
unsigned int versions; /* SSL version flags. */
-};
+};
-static const struct gskit_cipher ciphertable[] = {
+static const struct gskit_cipher ciphertable[] = {
{ "null-md5", "01",
CURL_GSKPROTO_SSLV3_MASK | CURL_GSKPROTO_TLSV10_MASK |
CURL_GSKPROTO_TLSV11_MASK | CURL_GSKPROTO_TLSV12_MASK },
@@ -307,7 +307,7 @@ static CURLcode set_ciphers(struct connectdata *conn,
struct Curl_easy *data = conn->data;
const char *cipherlist = SSL_CONN_CONFIG(cipher_list);
const char *clp;
- const struct gskit_cipher *ctp;
+ const struct gskit_cipher *ctp;
int i;
int l;
bool unsupported;
@@ -543,7 +543,7 @@ static int pipe_ssloverssl(struct connectdata *conn, int sockindex,
if(n < conn->sock[sockindex])
n = conn->sock[sockindex];
}
- i = Curl_select(n + 1, &fds_read, &fds_write, NULL, 0);
+ i = Curl_select(n + 1, &fds_read, &fds_write, NULL, 0);
if(i < 0)
return -1; /* Select error. */
@@ -705,7 +705,7 @@ static CURLcode gskit_connect_step1(struct connectdata *conn, int sockindex)
int rc;
const char * const keyringfile = SSL_CONN_CONFIG(CAfile);
const char * const keyringpwd = SSL_SET_OPTION(key_passwd);
- const char * const keyringlabel = SSL_SET_OPTION(primary.clientcert);
+ const char * const keyringlabel = SSL_SET_OPTION(primary.clientcert);
const long int ssl_version = SSL_CONN_CONFIG(version);
const bool verifypeer = SSL_CONN_CONFIG(verifypeer);
const char * const hostname = SSL_IS_PROXY()? conn->http_proxy.host.name:
@@ -762,7 +762,7 @@ static CURLcode gskit_connect_step1(struct connectdata *conn, int sockindex)
/* Establish a pipelining socket pair for SSL over SSL. */
if(conn->proxy_ssl[sockindex].use) {
- if(Curl_socketpair(0, 0, 0, sockpair))
+ if(Curl_socketpair(0, 0, 0, sockpair))
return CURLE_SSL_CONNECT_ERROR;
BACKEND->localfd = sockpair[0];
BACKEND->remotefd = sockpair[1];
@@ -819,7 +819,7 @@ static CURLcode gskit_connect_step1(struct connectdata *conn, int sockindex)
if(!result) {
/* Compute the handshake timeout. Since GSKit granularity is 1 second,
we round up the required value. */
- timediff_t timeout = Curl_timeleft(data, NULL, TRUE);
+ timediff_t timeout = Curl_timeleft(data, NULL, TRUE);
if(timeout < 0)
result = CURLE_OPERATION_TIMEDOUT;
else
@@ -932,7 +932,7 @@ static CURLcode gskit_connect_step2(struct connectdata *conn, int sockindex,
/* Poll or wait for end of SSL asynchronous handshake. */
for(;;) {
- timediff_t timeout_ms = nonblocking? 0: Curl_timeleft(data, NULL, TRUE);
+ timediff_t timeout_ms = nonblocking? 0: Curl_timeleft(data, NULL, TRUE);
if(timeout_ms < 0)
timeout_ms = 0;
stmv.tv_sec = timeout_ms / 1000;
@@ -1064,7 +1064,7 @@ static CURLcode gskit_connect_common(struct connectdata *conn, int sockindex,
{
struct Curl_easy *data = conn->data;
struct ssl_connect_data *connssl = &conn->ssl[sockindex];
- timediff_t timeout_ms;
+ timediff_t timeout_ms;
CURLcode result = CURLE_OK;
*done = connssl->state == ssl_connection_complete;
diff --git a/contrib/libs/curl/lib/vtls/gskit.h b/contrib/libs/curl/lib/vtls/gskit.h
index 4d0dc01c2b..202df7e07c 100644
--- a/contrib/libs/curl/lib/vtls/gskit.h
+++ b/contrib/libs/curl/lib/vtls/gskit.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/vtls/gtls.c b/contrib/libs/curl/lib/vtls/gtls.c
index c8465ce5b5..e848c3f05a 100644
--- a/contrib/libs/curl/lib/vtls/gtls.c
+++ b/contrib/libs/curl/lib/vtls/gtls.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -72,8 +72,8 @@ static void tls_log_func(int level, const char *str)
#endif
static bool gtls_inited = FALSE;
-#if !defined(GNUTLS_VERSION_NUMBER) || (GNUTLS_VERSION_NUMBER < 0x03010a)
-#error "too old GnuTLS version"
+#if !defined(GNUTLS_VERSION_NUMBER) || (GNUTLS_VERSION_NUMBER < 0x03010a)
+#error "too old GnuTLS version"
#endif
# include <gnutls/ocsp.h>
@@ -81,7 +81,7 @@ static bool gtls_inited = FALSE;
struct ssl_backend_data {
gnutls_session_t session;
gnutls_certificate_credentials_t cred;
-#ifdef HAVE_GNUTLS_SRP
+#ifdef HAVE_GNUTLS_SRP
gnutls_srp_client_credentials_t srp_client_cred;
#endif
};
@@ -207,12 +207,12 @@ static CURLcode handshake(struct connectdata *conn,
{
struct Curl_easy *data = conn->data;
struct ssl_connect_data *connssl = &conn->ssl[sockindex];
- struct ssl_backend_data *backend = connssl->backend;
- gnutls_session_t session = backend->session;
+ struct ssl_backend_data *backend = connssl->backend;
+ gnutls_session_t session = backend->session;
curl_socket_t sockfd = conn->sock[sockindex];
for(;;) {
- timediff_t timeout_ms;
+ timediff_t timeout_ms;
int rc;
/* check allowed time left */
@@ -304,7 +304,7 @@ static gnutls_x509_crt_fmt_t do_file_type(const char *type)
return GNUTLS_X509_FMT_PEM;
if(strcasecompare(type, "DER"))
return GNUTLS_X509_FMT_DER;
- return GNUTLS_X509_FMT_PEM; /* default to PEM */
+ return GNUTLS_X509_FMT_PEM; /* default to PEM */
}
#define GNUTLS_CIPHERS "NORMAL:-ARCFOUR-128:-CTYPE-ALL:+CTYPE-X509"
@@ -324,54 +324,54 @@ set_ssl_version_min_max(const char **prioritylist, struct connectdata *conn)
ssl_version_max = CURL_SSLVERSION_MAX_DEFAULT;
}
switch(ssl_version | ssl_version_max) {
- case CURL_SSLVERSION_TLSv1_0 | CURL_SSLVERSION_MAX_TLSv1_0:
- *prioritylist = GNUTLS_CIPHERS ":-VERS-SSL3.0:-VERS-TLS-ALL:"
- "+VERS-TLS1.0";
- return CURLE_OK;
- case CURL_SSLVERSION_TLSv1_0 | CURL_SSLVERSION_MAX_TLSv1_1:
- *prioritylist = GNUTLS_CIPHERS ":-VERS-SSL3.0:-VERS-TLS-ALL:"
- "+VERS-TLS1.0:+VERS-TLS1.1";
- return CURLE_OK;
- case CURL_SSLVERSION_TLSv1_0 | CURL_SSLVERSION_MAX_TLSv1_2:
- *prioritylist = GNUTLS_CIPHERS ":-VERS-SSL3.0:-VERS-TLS-ALL:"
- "+VERS-TLS1.0:+VERS-TLS1.1:+VERS-TLS1.2";
- return CURLE_OK;
- case CURL_SSLVERSION_TLSv1_1 | CURL_SSLVERSION_MAX_TLSv1_1:
- *prioritylist = GNUTLS_CIPHERS ":-VERS-SSL3.0:-VERS-TLS-ALL:"
- "+VERS-TLS1.1";
- return CURLE_OK;
- case CURL_SSLVERSION_TLSv1_1 | CURL_SSLVERSION_MAX_TLSv1_2:
- *prioritylist = GNUTLS_CIPHERS ":-VERS-SSL3.0:-VERS-TLS-ALL:"
- "+VERS-TLS1.1:+VERS-TLS1.2";
- return CURLE_OK;
- case CURL_SSLVERSION_TLSv1_2 | CURL_SSLVERSION_MAX_TLSv1_2:
- *prioritylist = GNUTLS_CIPHERS ":-VERS-SSL3.0:-VERS-TLS-ALL:"
- "+VERS-TLS1.2";
- return CURLE_OK;
- case CURL_SSLVERSION_TLSv1_3 | CURL_SSLVERSION_MAX_TLSv1_3:
- *prioritylist = GNUTLS_CIPHERS ":-VERS-SSL3.0:-VERS-TLS-ALL:"
- "+VERS-TLS1.3";
- return CURLE_OK;
- case CURL_SSLVERSION_TLSv1_0 | CURL_SSLVERSION_MAX_DEFAULT:
- *prioritylist = GNUTLS_CIPHERS ":-VERS-SSL3.0:-VERS-TLS-ALL:"
- "+VERS-TLS1.0:+VERS-TLS1.1:+VERS-TLS1.2"
- ":+VERS-TLS1.3";
- return CURLE_OK;
- case CURL_SSLVERSION_TLSv1_1 | CURL_SSLVERSION_MAX_DEFAULT:
- *prioritylist = GNUTLS_CIPHERS ":-VERS-SSL3.0:-VERS-TLS-ALL:"
- "+VERS-TLS1.1:+VERS-TLS1.2"
- ":+VERS-TLS1.3";
- return CURLE_OK;
- case CURL_SSLVERSION_TLSv1_2 | CURL_SSLVERSION_MAX_DEFAULT:
- *prioritylist = GNUTLS_CIPHERS ":-VERS-SSL3.0:-VERS-TLS-ALL:"
- "+VERS-TLS1.2"
- ":+VERS-TLS1.3";
- return CURLE_OK;
- case CURL_SSLVERSION_TLSv1_3 | CURL_SSLVERSION_MAX_DEFAULT:
- *prioritylist = GNUTLS_CIPHERS ":-VERS-SSL3.0:-VERS-TLS-ALL:"
- "+VERS-TLS1.2"
- ":+VERS-TLS1.3";
- return CURLE_OK;
+ case CURL_SSLVERSION_TLSv1_0 | CURL_SSLVERSION_MAX_TLSv1_0:
+ *prioritylist = GNUTLS_CIPHERS ":-VERS-SSL3.0:-VERS-TLS-ALL:"
+ "+VERS-TLS1.0";
+ return CURLE_OK;
+ case CURL_SSLVERSION_TLSv1_0 | CURL_SSLVERSION_MAX_TLSv1_1:
+ *prioritylist = GNUTLS_CIPHERS ":-VERS-SSL3.0:-VERS-TLS-ALL:"
+ "+VERS-TLS1.0:+VERS-TLS1.1";
+ return CURLE_OK;
+ case CURL_SSLVERSION_TLSv1_0 | CURL_SSLVERSION_MAX_TLSv1_2:
+ *prioritylist = GNUTLS_CIPHERS ":-VERS-SSL3.0:-VERS-TLS-ALL:"
+ "+VERS-TLS1.0:+VERS-TLS1.1:+VERS-TLS1.2";
+ return CURLE_OK;
+ case CURL_SSLVERSION_TLSv1_1 | CURL_SSLVERSION_MAX_TLSv1_1:
+ *prioritylist = GNUTLS_CIPHERS ":-VERS-SSL3.0:-VERS-TLS-ALL:"
+ "+VERS-TLS1.1";
+ return CURLE_OK;
+ case CURL_SSLVERSION_TLSv1_1 | CURL_SSLVERSION_MAX_TLSv1_2:
+ *prioritylist = GNUTLS_CIPHERS ":-VERS-SSL3.0:-VERS-TLS-ALL:"
+ "+VERS-TLS1.1:+VERS-TLS1.2";
+ return CURLE_OK;
+ case CURL_SSLVERSION_TLSv1_2 | CURL_SSLVERSION_MAX_TLSv1_2:
+ *prioritylist = GNUTLS_CIPHERS ":-VERS-SSL3.0:-VERS-TLS-ALL:"
+ "+VERS-TLS1.2";
+ return CURLE_OK;
+ case CURL_SSLVERSION_TLSv1_3 | CURL_SSLVERSION_MAX_TLSv1_3:
+ *prioritylist = GNUTLS_CIPHERS ":-VERS-SSL3.0:-VERS-TLS-ALL:"
+ "+VERS-TLS1.3";
+ return CURLE_OK;
+ case CURL_SSLVERSION_TLSv1_0 | CURL_SSLVERSION_MAX_DEFAULT:
+ *prioritylist = GNUTLS_CIPHERS ":-VERS-SSL3.0:-VERS-TLS-ALL:"
+ "+VERS-TLS1.0:+VERS-TLS1.1:+VERS-TLS1.2"
+ ":+VERS-TLS1.3";
+ return CURLE_OK;
+ case CURL_SSLVERSION_TLSv1_1 | CURL_SSLVERSION_MAX_DEFAULT:
+ *prioritylist = GNUTLS_CIPHERS ":-VERS-SSL3.0:-VERS-TLS-ALL:"
+ "+VERS-TLS1.1:+VERS-TLS1.2"
+ ":+VERS-TLS1.3";
+ return CURLE_OK;
+ case CURL_SSLVERSION_TLSv1_2 | CURL_SSLVERSION_MAX_DEFAULT:
+ *prioritylist = GNUTLS_CIPHERS ":-VERS-SSL3.0:-VERS-TLS-ALL:"
+ "+VERS-TLS1.2"
+ ":+VERS-TLS1.3";
+ return CURLE_OK;
+ case CURL_SSLVERSION_TLSv1_3 | CURL_SSLVERSION_MAX_DEFAULT:
+ *prioritylist = GNUTLS_CIPHERS ":-VERS-SSL3.0:-VERS-TLS-ALL:"
+ "+VERS-TLS1.2"
+ ":+VERS-TLS1.3";
+ return CURLE_OK;
}
failf(data, "GnuTLS: cannot set ssl protocol");
@@ -384,7 +384,7 @@ gtls_connect_step1(struct connectdata *conn,
{
struct Curl_easy *data = conn->data;
struct ssl_connect_data *connssl = &conn->ssl[sockindex];
- struct ssl_backend_data *backend = connssl->backend;
+ struct ssl_backend_data *backend = connssl->backend;
unsigned int init_flags;
gnutls_session_t session;
int rc;
@@ -399,8 +399,8 @@ gtls_connect_step1(struct connectdata *conn,
#endif
const char *prioritylist;
const char *err = NULL;
- const char * const hostname = SSL_HOST_NAME();
- long * const certverifyresult = &SSL_SET_OPTION_LVALUE(certverifyresult);
+ const char * const hostname = SSL_HOST_NAME();
+ long * const certverifyresult = &SSL_SET_OPTION_LVALUE(certverifyresult);
if(connssl->state == ssl_connection_complete)
/* to make us tolerant against being called more than once for the
@@ -410,9 +410,9 @@ gtls_connect_step1(struct connectdata *conn,
if(!gtls_inited)
Curl_gtls_init();
- /* Initialize certverifyresult to OK */
- *certverifyresult = 0;
-
+ /* Initialize certverifyresult to OK */
+ *certverifyresult = 0;
+
if(SSL_CONN_CONFIG(version) == CURL_SSLVERSION_SSLv2) {
failf(data, "GnuTLS does not support SSLv2");
return CURLE_SSL_CONNECT_ERROR;
@@ -421,25 +421,25 @@ gtls_connect_step1(struct connectdata *conn,
sni = FALSE; /* SSLv3 has no SNI */
/* allocate a cred struct */
- rc = gnutls_certificate_allocate_credentials(&backend->cred);
+ rc = gnutls_certificate_allocate_credentials(&backend->cred);
if(rc != GNUTLS_E_SUCCESS) {
failf(data, "gnutls_cert_all_cred() failed: %s", gnutls_strerror(rc));
return CURLE_SSL_CONNECT_ERROR;
}
-#ifdef HAVE_GNUTLS_SRP
+#ifdef HAVE_GNUTLS_SRP
if(SSL_SET_OPTION(authtype) == CURL_TLSAUTH_SRP) {
infof(data, "Using TLS-SRP username: %s\n", SSL_SET_OPTION(username));
rc = gnutls_srp_allocate_client_credentials(
- &backend->srp_client_cred);
+ &backend->srp_client_cred);
if(rc != GNUTLS_E_SUCCESS) {
failf(data, "gnutls_srp_allocate_client_cred() failed: %s",
gnutls_strerror(rc));
return CURLE_OUT_OF_MEMORY;
}
- rc = gnutls_srp_set_client_credentials(backend->srp_client_cred,
+ rc = gnutls_srp_set_client_credentials(backend->srp_client_cred,
SSL_SET_OPTION(username),
SSL_SET_OPTION(password));
if(rc != GNUTLS_E_SUCCESS) {
@@ -452,19 +452,19 @@ gtls_connect_step1(struct connectdata *conn,
if(SSL_CONN_CONFIG(CAfile)) {
/* set the trusted CA cert bundle file */
- gnutls_certificate_set_verify_flags(backend->cred,
+ gnutls_certificate_set_verify_flags(backend->cred,
GNUTLS_VERIFY_ALLOW_X509_V1_CA_CRT);
- rc = gnutls_certificate_set_x509_trust_file(backend->cred,
+ rc = gnutls_certificate_set_x509_trust_file(backend->cred,
SSL_CONN_CONFIG(CAfile),
GNUTLS_X509_FMT_PEM);
if(rc < 0) {
infof(data, "error reading ca cert file %s (%s)\n",
SSL_CONN_CONFIG(CAfile), gnutls_strerror(rc));
- if(SSL_CONN_CONFIG(verifypeer)) {
- *certverifyresult = rc;
+ if(SSL_CONN_CONFIG(verifypeer)) {
+ *certverifyresult = rc;
return CURLE_SSL_CACERT_BADFILE;
- }
+ }
}
else
infof(data, "found %d certificates in %s\n", rc,
@@ -473,16 +473,16 @@ gtls_connect_step1(struct connectdata *conn,
if(SSL_CONN_CONFIG(CApath)) {
/* set the trusted CA cert directory */
- rc = gnutls_certificate_set_x509_trust_dir(backend->cred,
+ rc = gnutls_certificate_set_x509_trust_dir(backend->cred,
SSL_CONN_CONFIG(CApath),
GNUTLS_X509_FMT_PEM);
if(rc < 0) {
infof(data, "error reading ca cert file %s (%s)\n",
SSL_CONN_CONFIG(CApath), gnutls_strerror(rc));
- if(SSL_CONN_CONFIG(verifypeer)) {
- *certverifyresult = rc;
+ if(SSL_CONN_CONFIG(verifypeer)) {
+ *certverifyresult = rc;
return CURLE_SSL_CACERT_BADFILE;
- }
+ }
}
else
infof(data, "found %d certificates in %s\n",
@@ -493,13 +493,13 @@ gtls_connect_step1(struct connectdata *conn,
/* use system ca certificate store as fallback */
if(SSL_CONN_CONFIG(verifypeer) &&
!(SSL_CONN_CONFIG(CAfile) || SSL_CONN_CONFIG(CApath))) {
- gnutls_certificate_set_x509_system_trust(backend->cred);
+ gnutls_certificate_set_x509_system_trust(backend->cred);
}
#endif
if(SSL_SET_OPTION(CRLfile)) {
/* set the CRL list file */
- rc = gnutls_certificate_set_x509_crl_file(backend->cred,
+ rc = gnutls_certificate_set_x509_crl_file(backend->cred,
SSL_SET_OPTION(CRLfile),
GNUTLS_X509_FMT_PEM);
if(rc < 0) {
@@ -515,23 +515,23 @@ gtls_connect_step1(struct connectdata *conn,
/* Initialize TLS session as a client */
init_flags = GNUTLS_CLIENT;
-#if defined(GNUTLS_FORCE_CLIENT_CERT)
- init_flags |= GNUTLS_FORCE_CLIENT_CERT;
-#endif
-
+#if defined(GNUTLS_FORCE_CLIENT_CERT)
+ init_flags |= GNUTLS_FORCE_CLIENT_CERT;
+#endif
+
#if defined(GNUTLS_NO_TICKETS)
/* Disable TLS session tickets */
init_flags |= GNUTLS_NO_TICKETS;
#endif
- rc = gnutls_init(&backend->session, init_flags);
+ rc = gnutls_init(&backend->session, init_flags);
if(rc != GNUTLS_E_SUCCESS) {
failf(data, "gnutls_init() failed: %d", rc);
return CURLE_SSL_CONNECT_ERROR;
}
/* convenient assign */
- session = backend->session;
+ session = backend->session;
if((0 == Curl_inet_pton(AF_INET, hostname, &addr)) &&
#ifdef ENABLE_IPV6
@@ -557,11 +557,11 @@ gtls_connect_step1(struct connectdata *conn,
break;
case CURL_SSLVERSION_DEFAULT:
case CURL_SSLVERSION_TLSv1:
- prioritylist = GNUTLS_CIPHERS ":-VERS-SSL3.0"
+ prioritylist = GNUTLS_CIPHERS ":-VERS-SSL3.0"
#ifdef HAS_TLS13
- ":+VERS-TLS1.3"
+ ":+VERS-TLS1.3"
#endif
- ;
+ ;
break;
case CURL_SSLVERSION_TLSv1_0:
case CURL_SSLVERSION_TLSv1_1:
@@ -581,32 +581,32 @@ gtls_connect_step1(struct connectdata *conn,
return CURLE_SSL_CONNECT_ERROR;
}
-#ifdef HAVE_GNUTLS_SRP
- /* Only add SRP to the cipher list if SRP is requested. Otherwise
- * GnuTLS will disable TLS 1.3 support. */
- if(SSL_SET_OPTION(authtype) == CURL_TLSAUTH_SRP) {
- size_t len = strlen(prioritylist);
-
- char *prioritysrp = malloc(len + sizeof(GNUTLS_SRP) + 1);
- if(!prioritysrp)
- return CURLE_OUT_OF_MEMORY;
- strcpy(prioritysrp, prioritylist);
- strcpy(prioritysrp + len, ":" GNUTLS_SRP);
-
- rc = gnutls_priority_set_direct(session, prioritysrp, &err);
- free(prioritysrp);
-
- if((rc == GNUTLS_E_INVALID_REQUEST) && err) {
+#ifdef HAVE_GNUTLS_SRP
+ /* Only add SRP to the cipher list if SRP is requested. Otherwise
+ * GnuTLS will disable TLS 1.3 support. */
+ if(SSL_SET_OPTION(authtype) == CURL_TLSAUTH_SRP) {
+ size_t len = strlen(prioritylist);
+
+ char *prioritysrp = malloc(len + sizeof(GNUTLS_SRP) + 1);
+ if(!prioritysrp)
+ return CURLE_OUT_OF_MEMORY;
+ strcpy(prioritysrp, prioritylist);
+ strcpy(prioritysrp + len, ":" GNUTLS_SRP);
+
+ rc = gnutls_priority_set_direct(session, prioritysrp, &err);
+ free(prioritysrp);
+
+ if((rc == GNUTLS_E_INVALID_REQUEST) && err) {
infof(data, "This GnuTLS does not support SRP\n");
}
}
- else {
-#endif
- rc = gnutls_priority_set_direct(session, prioritylist, &err);
-#ifdef HAVE_GNUTLS_SRP
- }
-#endif
-
+ else {
+#endif
+ rc = gnutls_priority_set_direct(session, prioritylist, &err);
+#ifdef HAVE_GNUTLS_SRP
+ }
+#endif
+
if(rc != GNUTLS_E_SUCCESS) {
failf(data, "Error %d setting GnuTLS cipher list starting with %s",
rc, err);
@@ -618,11 +618,11 @@ gtls_connect_step1(struct connectdata *conn,
gnutls_datum_t protocols[2];
#ifdef USE_NGHTTP2
- if(data->set.httpversion >= CURL_HTTP_VERSION_2
-#ifndef CURL_DISABLE_PROXY
- && (!SSL_IS_PROXY() || !conn->bits.tunnel_proxy)
-#endif
- ) {
+ if(data->set.httpversion >= CURL_HTTP_VERSION_2
+#ifndef CURL_DISABLE_PROXY
+ && (!SSL_IS_PROXY() || !conn->bits.tunnel_proxy)
+#endif
+ ) {
protocols[cur].data = (unsigned char *)NGHTTP2_PROTO_VERSION_ID;
protocols[cur].size = NGHTTP2_PROTO_VERSION_ID_LEN;
cur++;
@@ -638,7 +638,7 @@ gtls_connect_step1(struct connectdata *conn,
gnutls_alpn_set_protocols(session, protocols, cur, 0);
}
- if(SSL_SET_OPTION(primary.clientcert)) {
+ if(SSL_SET_OPTION(primary.clientcert)) {
if(SSL_SET_OPTION(key_passwd)) {
const unsigned int supported_key_encryption_algorithms =
GNUTLS_PKCS_USE_PKCS12_3DES | GNUTLS_PKCS_USE_PKCS12_ARCFOUR |
@@ -646,10 +646,10 @@ gtls_connect_step1(struct connectdata *conn,
GNUTLS_PKCS_USE_PBES2_AES_128 | GNUTLS_PKCS_USE_PBES2_AES_192 |
GNUTLS_PKCS_USE_PBES2_AES_256;
rc = gnutls_certificate_set_x509_key_file2(
- backend->cred,
- SSL_SET_OPTION(primary.clientcert),
+ backend->cred,
+ SSL_SET_OPTION(primary.clientcert),
SSL_SET_OPTION(key) ?
- SSL_SET_OPTION(key) : SSL_SET_OPTION(primary.clientcert),
+ SSL_SET_OPTION(key) : SSL_SET_OPTION(primary.clientcert),
do_file_type(SSL_SET_OPTION(cert_type)),
SSL_SET_OPTION(key_passwd),
supported_key_encryption_algorithms);
@@ -662,10 +662,10 @@ gtls_connect_step1(struct connectdata *conn,
}
else {
if(gnutls_certificate_set_x509_key_file(
- backend->cred,
- SSL_SET_OPTION(primary.clientcert),
+ backend->cred,
+ SSL_SET_OPTION(primary.clientcert),
SSL_SET_OPTION(key) ?
- SSL_SET_OPTION(key) : SSL_SET_OPTION(primary.clientcert),
+ SSL_SET_OPTION(key) : SSL_SET_OPTION(primary.clientcert),
do_file_type(SSL_SET_OPTION(cert_type)) ) !=
GNUTLS_E_SUCCESS) {
failf(data, "error reading X.509 key or certificate file");
@@ -674,11 +674,11 @@ gtls_connect_step1(struct connectdata *conn,
}
}
-#ifdef HAVE_GNUTLS_SRP
+#ifdef HAVE_GNUTLS_SRP
/* put the credentials to the current session */
if(SSL_SET_OPTION(authtype) == CURL_TLSAUTH_SRP) {
rc = gnutls_credentials_set(session, GNUTLS_CRD_SRP,
- backend->srp_client_cred);
+ backend->srp_client_cred);
if(rc != GNUTLS_E_SUCCESS) {
failf(data, "gnutls_credentials_set() failed: %s", gnutls_strerror(rc));
return CURLE_SSL_CONNECT_ERROR;
@@ -688,22 +688,22 @@ gtls_connect_step1(struct connectdata *conn,
#endif
{
rc = gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE,
- backend->cred);
+ backend->cred);
if(rc != GNUTLS_E_SUCCESS) {
failf(data, "gnutls_credentials_set() failed: %s", gnutls_strerror(rc));
return CURLE_SSL_CONNECT_ERROR;
}
}
-#ifndef CURL_DISABLE_PROXY
+#ifndef CURL_DISABLE_PROXY
if(conn->proxy_ssl[sockindex].use) {
transport_ptr = conn->proxy_ssl[sockindex].backend->session;
gnutls_transport_push = Curl_gtls_push_ssl;
gnutls_transport_pull = Curl_gtls_pull_ssl;
}
- else
-#endif
- {
+ else
+#endif
+ {
/* file descriptor for the socket */
transport_ptr = &conn->sock[sockindex];
gnutls_transport_push = Curl_gtls_push;
@@ -815,15 +815,15 @@ gtls_connect_step3(struct connectdata *conn,
unsigned int verify_status = 0;
gnutls_x509_crt_t x509_cert, x509_issuer;
gnutls_datum_t issuerp;
- gnutls_datum_t certfields;
- char certname[65] = ""; /* limited to 64 chars by ASN.1 */
+ gnutls_datum_t certfields;
+ char certname[65] = ""; /* limited to 64 chars by ASN.1 */
size_t size;
time_t certclock;
const char *ptr;
struct Curl_easy *data = conn->data;
struct ssl_connect_data *connssl = &conn->ssl[sockindex];
- struct ssl_backend_data *backend = connssl->backend;
- gnutls_session_t session = backend->session;
+ struct ssl_backend_data *backend = connssl->backend;
+ gnutls_session_t session = backend->session;
int rc;
gnutls_datum_t proto;
CURLcode result = CURLE_OK;
@@ -832,8 +832,8 @@ gtls_connect_step3(struct connectdata *conn,
unsigned int bits;
gnutls_protocol_t version = gnutls_protocol_get_version(session);
#endif
- const char * const hostname = SSL_HOST_NAME();
- long * const certverifyresult = &SSL_SET_OPTION_LVALUE(certverifyresult);
+ const char * const hostname = SSL_HOST_NAME();
+ long * const certverifyresult = &SSL_SET_OPTION_LVALUE(certverifyresult);
/* the name of the cipher suite used, e.g. ECDHE_RSA_AES_256_GCM_SHA384. */
ptr = gnutls_cipher_suite_get_name(gnutls_kx_get(session),
@@ -854,7 +854,7 @@ gtls_connect_step3(struct connectdata *conn,
if(SSL_CONN_CONFIG(verifypeer) ||
SSL_CONN_CONFIG(verifyhost) ||
SSL_SET_OPTION(issuercert)) {
-#ifdef HAVE_GNUTLS_SRP
+#ifdef HAVE_GNUTLS_SRP
if(SSL_SET_OPTION(authtype) == CURL_TLSAUTH_SRP
&& SSL_SET_OPTION(username) != NULL
&& !SSL_CONN_CONFIG(verifypeer)
@@ -865,9 +865,9 @@ gtls_connect_step3(struct connectdata *conn,
else {
#endif
failf(data, "failed to get server cert");
- *certverifyresult = GNUTLS_E_NO_CERTIFICATE_FOUND;
+ *certverifyresult = GNUTLS_E_NO_CERTIFICATE_FOUND;
return CURLE_PEER_FAILED_VERIFICATION;
-#ifdef HAVE_GNUTLS_SRP
+#ifdef HAVE_GNUTLS_SRP
}
#endif
}
@@ -902,12 +902,12 @@ gtls_connect_step3(struct connectdata *conn,
rc = gnutls_certificate_verify_peers2(session, &verify_status);
if(rc < 0) {
failf(data, "server cert verify failed: %d", rc);
- *certverifyresult = rc;
+ *certverifyresult = rc;
return CURLE_SSL_CONNECT_ERROR;
}
- *certverifyresult = verify_status;
-
+ *certverifyresult = verify_status;
+
/* verify_status is a bitmask of gnutls_certificate_status bits */
if(verify_status & GNUTLS_CERT_INVALID) {
if(SSL_CONN_CONFIG(verifypeer)) {
@@ -1054,11 +1054,11 @@ gtls_connect_step3(struct connectdata *conn,
SSL_SET_OPTION(issuercert)?SSL_SET_OPTION(issuercert):"none");
}
- size = sizeof(certname);
+ size = sizeof(certname);
rc = gnutls_x509_crt_get_dn_by_oid(x509_cert, GNUTLS_OID_X520_COMMON_NAME,
0, /* the first and only one */
FALSE,
- certname,
+ certname,
&size);
if(rc) {
infof(data, "error fetching CN from cert:%s\n",
@@ -1116,16 +1116,16 @@ gtls_connect_step3(struct connectdata *conn,
if(!rc) {
if(SSL_CONN_CONFIG(verifyhost)) {
failf(data, "SSL: certificate subject name (%s) does not match "
- "target host name '%s'", certname, SSL_HOST_DISPNAME());
+ "target host name '%s'", certname, SSL_HOST_DISPNAME());
gnutls_x509_crt_deinit(x509_cert);
return CURLE_PEER_FAILED_VERIFICATION;
}
else
infof(data, "\t common name: %s (does not match '%s')\n",
- certname, SSL_HOST_DISPNAME());
+ certname, SSL_HOST_DISPNAME());
}
else
- infof(data, "\t common name: %s (matched)\n", certname);
+ infof(data, "\t common name: %s (matched)\n", certname);
/* Check for time-based validity */
certclock = gnutls_x509_crt_get_expiration_time(x509_cert);
@@ -1133,7 +1133,7 @@ gtls_connect_step3(struct connectdata *conn,
if(certclock == (time_t)-1) {
if(SSL_CONN_CONFIG(verifypeer)) {
failf(data, "server cert expiration date verify failed");
- *certverifyresult = GNUTLS_CERT_EXPIRED;
+ *certverifyresult = GNUTLS_CERT_EXPIRED;
gnutls_x509_crt_deinit(x509_cert);
return CURLE_SSL_CONNECT_ERROR;
}
@@ -1144,7 +1144,7 @@ gtls_connect_step3(struct connectdata *conn,
if(certclock < time(NULL)) {
if(SSL_CONN_CONFIG(verifypeer)) {
failf(data, "server certificate expiration date has passed.");
- *certverifyresult = GNUTLS_CERT_EXPIRED;
+ *certverifyresult = GNUTLS_CERT_EXPIRED;
gnutls_x509_crt_deinit(x509_cert);
return CURLE_PEER_FAILED_VERIFICATION;
}
@@ -1160,7 +1160,7 @@ gtls_connect_step3(struct connectdata *conn,
if(certclock == (time_t)-1) {
if(SSL_CONN_CONFIG(verifypeer)) {
failf(data, "server cert activation date verify failed");
- *certverifyresult = GNUTLS_CERT_NOT_ACTIVATED;
+ *certverifyresult = GNUTLS_CERT_NOT_ACTIVATED;
gnutls_x509_crt_deinit(x509_cert);
return CURLE_SSL_CONNECT_ERROR;
}
@@ -1171,7 +1171,7 @@ gtls_connect_step3(struct connectdata *conn,
if(certclock > time(NULL)) {
if(SSL_CONN_CONFIG(verifypeer)) {
failf(data, "server certificate not activated yet.");
- *certverifyresult = GNUTLS_CERT_NOT_ACTIVATED;
+ *certverifyresult = GNUTLS_CERT_NOT_ACTIVATED;
gnutls_x509_crt_deinit(x509_cert);
return CURLE_PEER_FAILED_VERIFICATION;
}
@@ -1214,29 +1214,29 @@ gtls_connect_step3(struct connectdata *conn,
gnutls_x509_crt_get_version(x509_cert));
- rc = gnutls_x509_crt_get_dn2(x509_cert, &certfields);
- if(rc)
- infof(data, "Failed to get certificate name\n");
- else {
- infof(data, "\t subject: %s\n", certfields.data);
-
- certclock = gnutls_x509_crt_get_activation_time(x509_cert);
- showtime(data, "start date", certclock);
-
- certclock = gnutls_x509_crt_get_expiration_time(x509_cert);
- showtime(data, "expire date", certclock);
-
- gnutls_free(certfields.data);
- }
-
- rc = gnutls_x509_crt_get_issuer_dn2(x509_cert, &certfields);
- if(rc)
- infof(data, "Failed to get certificate issuer\n");
- else {
- infof(data, "\t issuer: %s\n", certfields.data);
-
- gnutls_free(certfields.data);
- }
+ rc = gnutls_x509_crt_get_dn2(x509_cert, &certfields);
+ if(rc)
+ infof(data, "Failed to get certificate name\n");
+ else {
+ infof(data, "\t subject: %s\n", certfields.data);
+
+ certclock = gnutls_x509_crt_get_activation_time(x509_cert);
+ showtime(data, "start date", certclock);
+
+ certclock = gnutls_x509_crt_get_expiration_time(x509_cert);
+ showtime(data, "expire date", certclock);
+
+ gnutls_free(certfields.data);
+ }
+
+ rc = gnutls_x509_crt_get_issuer_dn2(x509_cert, &certfields);
+ if(rc)
+ infof(data, "Failed to get certificate issuer\n");
+ else {
+ infof(data, "\t issuer: %s\n", certfields.data);
+
+ gnutls_free(certfields.data);
+ }
#endif
gnutls_x509_crt_deinit(x509_cert);
@@ -1383,18 +1383,18 @@ static bool Curl_gtls_data_pending(const struct connectdata *conn,
{
const struct ssl_connect_data *connssl = &conn->ssl[connindex];
bool res = FALSE;
- struct ssl_backend_data *backend = connssl->backend;
- if(backend->session &&
- 0 != gnutls_record_check_pending(backend->session))
+ struct ssl_backend_data *backend = connssl->backend;
+ if(backend->session &&
+ 0 != gnutls_record_check_pending(backend->session))
res = TRUE;
-#ifndef CURL_DISABLE_PROXY
+#ifndef CURL_DISABLE_PROXY
connssl = &conn->proxy_ssl[connindex];
- backend = connssl->backend;
- if(backend->session &&
- 0 != gnutls_record_check_pending(backend->session))
+ backend = connssl->backend;
+ if(backend->session &&
+ 0 != gnutls_record_check_pending(backend->session))
res = TRUE;
-#endif
+#endif
return res;
}
@@ -1406,8 +1406,8 @@ static ssize_t gtls_send(struct connectdata *conn,
CURLcode *curlcode)
{
struct ssl_connect_data *connssl = &conn->ssl[sockindex];
- struct ssl_backend_data *backend = connssl->backend;
- ssize_t rc = gnutls_record_send(backend->session, mem, len);
+ struct ssl_backend_data *backend = connssl->backend;
+ ssize_t rc = gnutls_record_send(backend->session, mem, len);
if(rc < 0) {
*curlcode = (rc == GNUTLS_E_AGAIN)
@@ -1422,20 +1422,20 @@ static ssize_t gtls_send(struct connectdata *conn,
static void close_one(struct ssl_connect_data *connssl)
{
- struct ssl_backend_data *backend = connssl->backend;
- if(backend->session) {
- gnutls_bye(backend->session, GNUTLS_SHUT_WR);
- gnutls_deinit(backend->session);
- backend->session = NULL;
+ struct ssl_backend_data *backend = connssl->backend;
+ if(backend->session) {
+ gnutls_bye(backend->session, GNUTLS_SHUT_WR);
+ gnutls_deinit(backend->session);
+ backend->session = NULL;
}
- if(backend->cred) {
- gnutls_certificate_free_credentials(backend->cred);
- backend->cred = NULL;
+ if(backend->cred) {
+ gnutls_certificate_free_credentials(backend->cred);
+ backend->cred = NULL;
}
-#ifdef HAVE_GNUTLS_SRP
- if(backend->srp_client_cred) {
- gnutls_srp_free_client_credentials(backend->srp_client_cred);
- backend->srp_client_cred = NULL;
+#ifdef HAVE_GNUTLS_SRP
+ if(backend->srp_client_cred) {
+ gnutls_srp_free_client_credentials(backend->srp_client_cred);
+ backend->srp_client_cred = NULL;
}
#endif
}
@@ -1443,9 +1443,9 @@ static void close_one(struct ssl_connect_data *connssl)
static void Curl_gtls_close(struct connectdata *conn, int sockindex)
{
close_one(&conn->ssl[sockindex]);
-#ifndef CURL_DISABLE_PROXY
+#ifndef CURL_DISABLE_PROXY
close_one(&conn->proxy_ssl[sockindex]);
-#endif
+#endif
}
/*
@@ -1455,7 +1455,7 @@ static void Curl_gtls_close(struct connectdata *conn, int sockindex)
static int Curl_gtls_shutdown(struct connectdata *conn, int sockindex)
{
struct ssl_connect_data *connssl = &conn->ssl[sockindex];
- struct ssl_backend_data *backend = connssl->backend;
+ struct ssl_backend_data *backend = connssl->backend;
int retval = 0;
struct Curl_easy *data = conn->data;
@@ -1466,10 +1466,10 @@ static int Curl_gtls_shutdown(struct connectdata *conn, int sockindex)
we do not send one. Let's hope other servers do the same... */
if(data->set.ftp_ccc == CURLFTPSSL_CCC_ACTIVE)
- gnutls_bye(backend->session, GNUTLS_SHUT_WR);
+ gnutls_bye(backend->session, GNUTLS_SHUT_WR);
#endif
- if(backend->session) {
+ if(backend->session) {
ssize_t result;
bool done = FALSE;
char buf[120];
@@ -1480,7 +1480,7 @@ static int Curl_gtls_shutdown(struct connectdata *conn, int sockindex)
if(what > 0) {
/* Something to read, let's do it and hope that it is the close
notify alert from the server */
- result = gnutls_record_recv(backend->session,
+ result = gnutls_record_recv(backend->session,
buf, sizeof(buf));
switch(result) {
case 0:
@@ -1510,18 +1510,18 @@ static int Curl_gtls_shutdown(struct connectdata *conn, int sockindex)
done = TRUE;
}
}
- gnutls_deinit(backend->session);
+ gnutls_deinit(backend->session);
}
- gnutls_certificate_free_credentials(backend->cred);
+ gnutls_certificate_free_credentials(backend->cred);
-#ifdef HAVE_GNUTLS_SRP
+#ifdef HAVE_GNUTLS_SRP
if(SSL_SET_OPTION(authtype) == CURL_TLSAUTH_SRP
&& SSL_SET_OPTION(username) != NULL)
- gnutls_srp_free_client_credentials(backend->srp_client_cred);
+ gnutls_srp_free_client_credentials(backend->srp_client_cred);
#endif
- backend->cred = NULL;
- backend->session = NULL;
+ backend->cred = NULL;
+ backend->session = NULL;
return retval;
}
@@ -1533,10 +1533,10 @@ static ssize_t gtls_recv(struct connectdata *conn, /* connection data */
CURLcode *curlcode)
{
struct ssl_connect_data *connssl = &conn->ssl[num];
- struct ssl_backend_data *backend = connssl->backend;
+ struct ssl_backend_data *backend = connssl->backend;
ssize_t ret;
- ret = gnutls_record_recv(backend->session, buf, buffersize);
+ ret = gnutls_record_recv(backend->session, buf, buffersize);
if((ret == GNUTLS_E_AGAIN) || (ret == GNUTLS_E_INTERRUPTED)) {
*curlcode = CURLE_AGAIN;
return -1;
@@ -1658,9 +1658,9 @@ static bool Curl_gtls_cert_status_request(void)
static void *Curl_gtls_get_internals(struct ssl_connect_data *connssl,
CURLINFO info UNUSED_PARAM)
{
- struct ssl_backend_data *backend = connssl->backend;
+ struct ssl_backend_data *backend = connssl->backend;
(void)info;
- return backend->session;
+ return backend->session;
}
const struct Curl_ssl Curl_ssl_gnutls = {
diff --git a/contrib/libs/curl/lib/vtls/gtls.h b/contrib/libs/curl/lib/vtls/gtls.h
index 6eb03d45b3..1a146a3a93 100644
--- a/contrib/libs/curl/lib/vtls/gtls.h
+++ b/contrib/libs/curl/lib/vtls/gtls.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/vtls/keylog.c b/contrib/libs/curl/lib/vtls/keylog.c
index d23ca68998..a45945f8f5 100644
--- a/contrib/libs/curl/lib/vtls/keylog.c
+++ b/contrib/libs/curl/lib/vtls/keylog.c
@@ -1,156 +1,156 @@
-/***************************************************************************
- * _ _ ____ _
- * Project ___| | | | _ \| |
- * / __| | | | |_) | |
- * | (__| |_| | _ <| |___
- * \___|\___/|_| \_\_____|
- *
- * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
- *
- * You may opt to use, copy, modify, merge, publish, distribute and/or sell
- * copies of the Software, and permit persons to whom the Software is
- * furnished to do so, under the terms of the COPYING file.
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- ***************************************************************************/
-#include "curl_setup.h"
-
-#include "keylog.h"
-
-/* The last #include files should be: */
-#include "curl_memory.h"
-#include "memdebug.h"
-
-#define KEYLOG_LABEL_MAXLEN (sizeof("CLIENT_HANDSHAKE_TRAFFIC_SECRET") - 1)
-
-#define CLIENT_RANDOM_SIZE 32
-
-/*
- * The master secret in TLS 1.2 and before is always 48 bytes. In TLS 1.3, the
- * secret size depends on the cipher suite's hash function which is 32 bytes
- * for SHA-256 and 48 bytes for SHA-384.
- */
-#define SECRET_MAXLEN 48
-
-
-/* The fp for the open SSLKEYLOGFILE, or NULL if not open */
-static FILE *keylog_file_fp;
-
-void
-Curl_tls_keylog_open(void)
-{
- char *keylog_file_name;
-
- if(!keylog_file_fp) {
- keylog_file_name = curl_getenv("SSLKEYLOGFILE");
- if(keylog_file_name) {
- keylog_file_fp = fopen(keylog_file_name, FOPEN_APPENDTEXT);
- if(keylog_file_fp) {
-#ifdef WIN32
- if(setvbuf(keylog_file_fp, NULL, _IONBF, 0))
-#else
- if(setvbuf(keylog_file_fp, NULL, _IOLBF, 4096))
-#endif
- {
- fclose(keylog_file_fp);
- keylog_file_fp = NULL;
- }
- }
- Curl_safefree(keylog_file_name);
- }
- }
-}
-
-void
-Curl_tls_keylog_close(void)
-{
- if(keylog_file_fp) {
- fclose(keylog_file_fp);
- keylog_file_fp = NULL;
- }
-}
-
-bool
-Curl_tls_keylog_enabled(void)
-{
- return keylog_file_fp != NULL;
-}
-
-bool
-Curl_tls_keylog_write_line(const char *line)
-{
- /* The current maximum valid keylog line length LF and NUL is 195. */
- size_t linelen;
- char buf[256];
-
- if(!keylog_file_fp || !line) {
- return false;
- }
-
- linelen = strlen(line);
- if(linelen == 0 || linelen > sizeof(buf) - 2) {
- /* Empty line or too big to fit in a LF and NUL. */
- return false;
- }
-
- memcpy(buf, line, linelen);
- if(line[linelen - 1] != '\n') {
- buf[linelen++] = '\n';
- }
- buf[linelen] = '\0';
-
- /* Using fputs here instead of fprintf since libcurl's fprintf replacement
- may not be thread-safe. */
- fputs(buf, keylog_file_fp);
- return true;
-}
-
-bool
-Curl_tls_keylog_write(const char *label,
- const unsigned char client_random[CLIENT_RANDOM_SIZE],
- const unsigned char *secret, size_t secretlen)
-{
- const char *hex = "0123456789ABCDEF";
- size_t pos, i;
- char line[KEYLOG_LABEL_MAXLEN + 1 + 2 * CLIENT_RANDOM_SIZE + 1 +
- 2 * SECRET_MAXLEN + 1 + 1];
-
- if(!keylog_file_fp) {
- return false;
- }
-
- pos = strlen(label);
- if(pos > KEYLOG_LABEL_MAXLEN || !secretlen || secretlen > SECRET_MAXLEN) {
- /* Should never happen - sanity check anyway. */
- return false;
- }
-
- memcpy(line, label, pos);
- line[pos++] = ' ';
-
- /* Client Random */
- for(i = 0; i < CLIENT_RANDOM_SIZE; i++) {
- line[pos++] = hex[client_random[i] >> 4];
- line[pos++] = hex[client_random[i] & 0xF];
- }
- line[pos++] = ' ';
-
- /* Secret */
- for(i = 0; i < secretlen; i++) {
- line[pos++] = hex[secret[i] >> 4];
- line[pos++] = hex[secret[i] & 0xF];
- }
- line[pos++] = '\n';
- line[pos] = '\0';
-
- /* Using fputs here instead of fprintf since libcurl's fprintf replacement
- may not be thread-safe. */
- fputs(line, keylog_file_fp);
- return true;
-}
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 1998 - 2020, 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
+ * are also available at https://curl.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+#include "curl_setup.h"
+
+#include "keylog.h"
+
+/* The last #include files should be: */
+#include "curl_memory.h"
+#include "memdebug.h"
+
+#define KEYLOG_LABEL_MAXLEN (sizeof("CLIENT_HANDSHAKE_TRAFFIC_SECRET") - 1)
+
+#define CLIENT_RANDOM_SIZE 32
+
+/*
+ * The master secret in TLS 1.2 and before is always 48 bytes. In TLS 1.3, the
+ * secret size depends on the cipher suite's hash function which is 32 bytes
+ * for SHA-256 and 48 bytes for SHA-384.
+ */
+#define SECRET_MAXLEN 48
+
+
+/* The fp for the open SSLKEYLOGFILE, or NULL if not open */
+static FILE *keylog_file_fp;
+
+void
+Curl_tls_keylog_open(void)
+{
+ char *keylog_file_name;
+
+ if(!keylog_file_fp) {
+ keylog_file_name = curl_getenv("SSLKEYLOGFILE");
+ if(keylog_file_name) {
+ keylog_file_fp = fopen(keylog_file_name, FOPEN_APPENDTEXT);
+ if(keylog_file_fp) {
+#ifdef WIN32
+ if(setvbuf(keylog_file_fp, NULL, _IONBF, 0))
+#else
+ if(setvbuf(keylog_file_fp, NULL, _IOLBF, 4096))
+#endif
+ {
+ fclose(keylog_file_fp);
+ keylog_file_fp = NULL;
+ }
+ }
+ Curl_safefree(keylog_file_name);
+ }
+ }
+}
+
+void
+Curl_tls_keylog_close(void)
+{
+ if(keylog_file_fp) {
+ fclose(keylog_file_fp);
+ keylog_file_fp = NULL;
+ }
+}
+
+bool
+Curl_tls_keylog_enabled(void)
+{
+ return keylog_file_fp != NULL;
+}
+
+bool
+Curl_tls_keylog_write_line(const char *line)
+{
+ /* The current maximum valid keylog line length LF and NUL is 195. */
+ size_t linelen;
+ char buf[256];
+
+ if(!keylog_file_fp || !line) {
+ return false;
+ }
+
+ linelen = strlen(line);
+ if(linelen == 0 || linelen > sizeof(buf) - 2) {
+ /* Empty line or too big to fit in a LF and NUL. */
+ return false;
+ }
+
+ memcpy(buf, line, linelen);
+ if(line[linelen - 1] != '\n') {
+ buf[linelen++] = '\n';
+ }
+ buf[linelen] = '\0';
+
+ /* Using fputs here instead of fprintf since libcurl's fprintf replacement
+ may not be thread-safe. */
+ fputs(buf, keylog_file_fp);
+ return true;
+}
+
+bool
+Curl_tls_keylog_write(const char *label,
+ const unsigned char client_random[CLIENT_RANDOM_SIZE],
+ const unsigned char *secret, size_t secretlen)
+{
+ const char *hex = "0123456789ABCDEF";
+ size_t pos, i;
+ char line[KEYLOG_LABEL_MAXLEN + 1 + 2 * CLIENT_RANDOM_SIZE + 1 +
+ 2 * SECRET_MAXLEN + 1 + 1];
+
+ if(!keylog_file_fp) {
+ return false;
+ }
+
+ pos = strlen(label);
+ if(pos > KEYLOG_LABEL_MAXLEN || !secretlen || secretlen > SECRET_MAXLEN) {
+ /* Should never happen - sanity check anyway. */
+ return false;
+ }
+
+ memcpy(line, label, pos);
+ line[pos++] = ' ';
+
+ /* Client Random */
+ for(i = 0; i < CLIENT_RANDOM_SIZE; i++) {
+ line[pos++] = hex[client_random[i] >> 4];
+ line[pos++] = hex[client_random[i] & 0xF];
+ }
+ line[pos++] = ' ';
+
+ /* Secret */
+ for(i = 0; i < secretlen; i++) {
+ line[pos++] = hex[secret[i] >> 4];
+ line[pos++] = hex[secret[i] & 0xF];
+ }
+ line[pos++] = '\n';
+ line[pos] = '\0';
+
+ /* Using fputs here instead of fprintf since libcurl's fprintf replacement
+ may not be thread-safe. */
+ fputs(line, keylog_file_fp);
+ return true;
+}
diff --git a/contrib/libs/curl/lib/vtls/keylog.h b/contrib/libs/curl/lib/vtls/keylog.h
index 858ddbb9f1..63626da90a 100644
--- a/contrib/libs/curl/lib/vtls/keylog.h
+++ b/contrib/libs/curl/lib/vtls/keylog.h
@@ -1,56 +1,56 @@
-#ifndef HEADER_CURL_KEYLOG_H
-#define HEADER_CURL_KEYLOG_H
-/***************************************************************************
- * _ _ ____ _
- * Project ___| | | | _ \| |
- * / __| | | | |_) | |
- * | (__| |_| | _ <| |___
- * \___|\___/|_| \_\_____|
- *
- * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
- *
- * You may opt to use, copy, modify, merge, publish, distribute and/or sell
- * copies of the Software, and permit persons to whom the Software is
- * furnished to do so, under the terms of the COPYING file.
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- ***************************************************************************/
-#include "curl_setup.h"
-
-/*
- * Opens the TLS key log file if requested by the user. The SSLKEYLOGFILE
- * environment variable specifies the output file.
- */
-void Curl_tls_keylog_open(void);
-
-/*
- * Closes the TLS key log file if not already.
- */
-void Curl_tls_keylog_close(void);
-
-/*
- * Returns true if the user successfully enabled the TLS key log file.
- */
-bool Curl_tls_keylog_enabled(void);
-
-/*
- * Appends a key log file entry.
- * Returns true iff the key log file is open and a valid entry was provided.
- */
-bool Curl_tls_keylog_write(const char *label,
- const unsigned char client_random[32],
- const unsigned char *secret, size_t secretlen);
-
-/*
- * Appends a line to the key log file, ensure it is terminated by a LF.
- * Returns true iff the key log file is open and a valid line was provided.
- */
-bool Curl_tls_keylog_write_line(const char *line);
-
-#endif /* HEADER_CURL_KEYLOG_H */
+#ifndef HEADER_CURL_KEYLOG_H
+#define HEADER_CURL_KEYLOG_H
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 1998 - 2020, 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
+ * are also available at https://curl.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+#include "curl_setup.h"
+
+/*
+ * Opens the TLS key log file if requested by the user. The SSLKEYLOGFILE
+ * environment variable specifies the output file.
+ */
+void Curl_tls_keylog_open(void);
+
+/*
+ * Closes the TLS key log file if not already.
+ */
+void Curl_tls_keylog_close(void);
+
+/*
+ * Returns true if the user successfully enabled the TLS key log file.
+ */
+bool Curl_tls_keylog_enabled(void);
+
+/*
+ * Appends a key log file entry.
+ * Returns true iff the key log file is open and a valid entry was provided.
+ */
+bool Curl_tls_keylog_write(const char *label,
+ const unsigned char client_random[32],
+ const unsigned char *secret, size_t secretlen);
+
+/*
+ * Appends a line to the key log file, ensure it is terminated by a LF.
+ * Returns true iff the key log file is open and a valid line was provided.
+ */
+bool Curl_tls_keylog_write_line(const char *line);
+
+#endif /* HEADER_CURL_KEYLOG_H */
diff --git a/contrib/libs/curl/lib/vtls/mbedtls.c b/contrib/libs/curl/lib/vtls/mbedtls.c
index ef85bc0944..e30f660fbb 100644
--- a/contrib/libs/curl/lib/vtls/mbedtls.c
+++ b/contrib/libs/curl/lib/vtls/mbedtls.c
@@ -6,11 +6,11 @@
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2010 - 2011, Hoi-Ho Chan, <hoiho.chan@gmail.com>
- * Copyright (C) 2012 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2012 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -31,9 +31,9 @@
#ifdef USE_MBEDTLS
-/* Define this to enable lots of debugging for mbedTLS */
-/* #define MBEDTLS_DEBUG */
-
+/* Define this to enable lots of debugging for mbedTLS */
+/* #define MBEDTLS_DEBUG */
+
#error #include <mbedtls/version.h>
#if MBEDTLS_VERSION_NUMBER >= 0x02040000
#error #include <mbedtls/net_sockets.h>
@@ -49,12 +49,12 @@
#error #include <mbedtls/ctr_drbg.h>
#error #include <mbedtls/sha256.h>
-#if MBEDTLS_VERSION_MAJOR >= 2
-# ifdef MBEDTLS_DEBUG
-# error #include <mbedtls/debug.h>
-# endif
-#endif
-
+#if MBEDTLS_VERSION_MAJOR >= 2
+# ifdef MBEDTLS_DEBUG
+# error #include <mbedtls/debug.h>
+# endif
+#endif
+
#include "urldata.h"
#include "sendf.h"
#include "inet_pton.h"
@@ -64,7 +64,7 @@
#include "connect.h" /* for the connect timeout */
#include "select.h"
#include "multiif.h"
-#error #include "mbedtls_threadlock.h"
+#error #include "mbedtls_threadlock.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
@@ -98,12 +98,12 @@ static int entropy_init_initialized = 0;
static void entropy_init_mutex(mbedtls_entropy_context *ctx)
{
/* lock 0 = entropy_init_mutex() */
- Curl_mbedtlsthreadlock_lock_function(0);
+ Curl_mbedtlsthreadlock_lock_function(0);
if(entropy_init_initialized == 0) {
mbedtls_entropy_init(ctx);
entropy_init_initialized = 1;
}
- Curl_mbedtlsthreadlock_unlock_function(0);
+ Curl_mbedtlsthreadlock_unlock_function(0);
}
/* end of entropy_init_mutex() */
@@ -112,9 +112,9 @@ static int entropy_func_mutex(void *data, unsigned char *output, size_t len)
{
int ret;
/* lock 1 = entropy_func_mutex() */
- Curl_mbedtlsthreadlock_lock_function(1);
+ Curl_mbedtlsthreadlock_lock_function(1);
ret = mbedtls_entropy_func(data, output, len);
- Curl_mbedtlsthreadlock_unlock_function(1);
+ Curl_mbedtlsthreadlock_unlock_function(1);
return ret;
}
@@ -200,7 +200,7 @@ set_ssl_version_min_max(struct connectdata *conn, int sockindex)
{
struct Curl_easy *data = conn->data;
struct ssl_connect_data *connssl = &conn->ssl[sockindex];
- struct ssl_backend_data *backend = connssl->backend;
+ struct ssl_backend_data *backend = connssl->backend;
int mbedtls_ver_min = MBEDTLS_SSL_MINOR_VERSION_1;
int mbedtls_ver_max = MBEDTLS_SSL_MINOR_VERSION_1;
long ssl_version = SSL_CONN_CONFIG(version);
@@ -232,9 +232,9 @@ set_ssl_version_min_max(struct connectdata *conn, int sockindex)
return result;
}
- mbedtls_ssl_conf_min_version(&backend->config, MBEDTLS_SSL_MAJOR_VERSION_3,
+ mbedtls_ssl_conf_min_version(&backend->config, MBEDTLS_SSL_MAJOR_VERSION_3,
mbedtls_ver_min);
- mbedtls_ssl_conf_max_version(&backend->config, MBEDTLS_SSL_MAJOR_VERSION_3,
+ mbedtls_ssl_conf_max_version(&backend->config, MBEDTLS_SSL_MAJOR_VERSION_3,
mbedtls_ver_max);
return result;
@@ -245,21 +245,21 @@ mbed_connect_step1(struct connectdata *conn,
int sockindex)
{
struct Curl_easy *data = conn->data;
- struct ssl_connect_data *connssl = &conn->ssl[sockindex];
- struct ssl_backend_data *backend = connssl->backend;
+ struct ssl_connect_data *connssl = &conn->ssl[sockindex];
+ struct ssl_backend_data *backend = connssl->backend;
const char * const ssl_cafile = SSL_CONN_CONFIG(CAfile);
const bool verifypeer = SSL_CONN_CONFIG(verifypeer);
const char * const ssl_capath = SSL_CONN_CONFIG(CApath);
- char * const ssl_cert = SSL_SET_OPTION(primary.clientcert);
+ char * const ssl_cert = SSL_SET_OPTION(primary.clientcert);
const char * const ssl_crlfile = SSL_SET_OPTION(CRLfile);
-#ifndef CURL_DISABLE_PROXY
+#ifndef CURL_DISABLE_PROXY
const char * const hostname = SSL_IS_PROXY() ? conn->http_proxy.host.name :
conn->host.name;
const long int port = SSL_IS_PROXY() ? conn->port : conn->remote_port;
-#else
- const char * const hostname = conn->host.name;
- const long int port = conn->remote_port;
-#endif
+#else
+ const char * const hostname = conn->host.name;
+ const long int port = conn->remote_port;
+#endif
int ret = -1;
char errorbuf[128];
errorbuf[0] = 0;
@@ -272,9 +272,9 @@ mbed_connect_step1(struct connectdata *conn,
#ifdef THREADING_SUPPORT
entropy_init_mutex(&ts_entropy);
- mbedtls_ctr_drbg_init(&backend->ctr_drbg);
+ mbedtls_ctr_drbg_init(&backend->ctr_drbg);
- ret = mbedtls_ctr_drbg_seed(&backend->ctr_drbg, entropy_func_mutex,
+ ret = mbedtls_ctr_drbg_seed(&backend->ctr_drbg, entropy_func_mutex,
&ts_entropy, NULL, 0);
if(ret) {
#ifdef MBEDTLS_ERROR_C
@@ -284,11 +284,11 @@ mbed_connect_step1(struct connectdata *conn,
-ret, errorbuf);
}
#else
- mbedtls_entropy_init(&backend->entropy);
- mbedtls_ctr_drbg_init(&backend->ctr_drbg);
+ mbedtls_entropy_init(&backend->entropy);
+ mbedtls_ctr_drbg_init(&backend->ctr_drbg);
- ret = mbedtls_ctr_drbg_seed(&backend->ctr_drbg, mbedtls_entropy_func,
- &backend->entropy, NULL, 0);
+ ret = mbedtls_ctr_drbg_seed(&backend->ctr_drbg, mbedtls_entropy_func,
+ &backend->entropy, NULL, 0);
if(ret) {
#ifdef MBEDTLS_ERROR_C
mbedtls_strerror(ret, errorbuf, sizeof(errorbuf));
@@ -299,10 +299,10 @@ mbed_connect_step1(struct connectdata *conn,
#endif /* THREADING_SUPPORT */
/* Load the trusted CA */
- mbedtls_x509_crt_init(&backend->cacert);
+ mbedtls_x509_crt_init(&backend->cacert);
if(ssl_cafile) {
- ret = mbedtls_x509_crt_parse_file(&backend->cacert, ssl_cafile);
+ ret = mbedtls_x509_crt_parse_file(&backend->cacert, ssl_cafile);
if(ret<0) {
#ifdef MBEDTLS_ERROR_C
@@ -317,7 +317,7 @@ mbed_connect_step1(struct connectdata *conn,
}
if(ssl_capath) {
- ret = mbedtls_x509_crt_parse_path(&backend->cacert, ssl_capath);
+ ret = mbedtls_x509_crt_parse_path(&backend->cacert, ssl_capath);
if(ret<0) {
#ifdef MBEDTLS_ERROR_C
@@ -332,10 +332,10 @@ mbed_connect_step1(struct connectdata *conn,
}
/* Load the client certificate */
- mbedtls_x509_crt_init(&backend->clicert);
+ mbedtls_x509_crt_init(&backend->clicert);
if(ssl_cert) {
- ret = mbedtls_x509_crt_parse_file(&backend->clicert, ssl_cert);
+ ret = mbedtls_x509_crt_parse_file(&backend->clicert, ssl_cert);
if(ret) {
#ifdef MBEDTLS_ERROR_C
@@ -349,13 +349,13 @@ mbed_connect_step1(struct connectdata *conn,
}
/* Load the client private key */
- mbedtls_pk_init(&backend->pk);
+ mbedtls_pk_init(&backend->pk);
if(SSL_SET_OPTION(key)) {
- ret = mbedtls_pk_parse_keyfile(&backend->pk, SSL_SET_OPTION(key),
+ ret = mbedtls_pk_parse_keyfile(&backend->pk, SSL_SET_OPTION(key),
SSL_SET_OPTION(key_passwd));
- if(ret == 0 && !(mbedtls_pk_can_do(&backend->pk, MBEDTLS_PK_RSA) ||
- mbedtls_pk_can_do(&backend->pk, MBEDTLS_PK_ECKEY)))
+ if(ret == 0 && !(mbedtls_pk_can_do(&backend->pk, MBEDTLS_PK_RSA) ||
+ mbedtls_pk_can_do(&backend->pk, MBEDTLS_PK_ECKEY)))
ret = MBEDTLS_ERR_PK_TYPE_MISMATCH;
if(ret) {
@@ -370,10 +370,10 @@ mbed_connect_step1(struct connectdata *conn,
}
/* Load the CRL */
- mbedtls_x509_crl_init(&backend->crl);
+ mbedtls_x509_crl_init(&backend->crl);
if(ssl_crlfile) {
- ret = mbedtls_x509_crl_parse_file(&backend->crl, ssl_crlfile);
+ ret = mbedtls_x509_crl_parse_file(&backend->crl, ssl_crlfile);
if(ret) {
#ifdef MBEDTLS_ERROR_C
@@ -388,14 +388,14 @@ mbed_connect_step1(struct connectdata *conn,
infof(data, "mbedTLS: Connecting to %s:%ld\n", hostname, port);
- mbedtls_ssl_config_init(&backend->config);
+ mbedtls_ssl_config_init(&backend->config);
- mbedtls_ssl_init(&backend->ssl);
- if(mbedtls_ssl_setup(&backend->ssl, &backend->config)) {
+ mbedtls_ssl_init(&backend->ssl);
+ if(mbedtls_ssl_setup(&backend->ssl, &backend->config)) {
failf(data, "mbedTLS: ssl_init failed");
return CURLE_SSL_CONNECT_ERROR;
}
- ret = mbedtls_ssl_config_defaults(&backend->config,
+ ret = mbedtls_ssl_config_defaults(&backend->config,
MBEDTLS_SSL_IS_CLIENT,
MBEDTLS_SSL_TRANSPORT_STREAM,
MBEDTLS_SSL_PRESET_DEFAULT);
@@ -405,20 +405,20 @@ mbed_connect_step1(struct connectdata *conn,
}
/* new profile with RSA min key len = 1024 ... */
- mbedtls_ssl_conf_cert_profile(&backend->config,
+ mbedtls_ssl_conf_cert_profile(&backend->config,
&mbedtls_x509_crt_profile_fr);
switch(SSL_CONN_CONFIG(version)) {
case CURL_SSLVERSION_DEFAULT:
case CURL_SSLVERSION_TLSv1:
- mbedtls_ssl_conf_min_version(&backend->config, MBEDTLS_SSL_MAJOR_VERSION_3,
+ mbedtls_ssl_conf_min_version(&backend->config, MBEDTLS_SSL_MAJOR_VERSION_3,
MBEDTLS_SSL_MINOR_VERSION_1);
infof(data, "mbedTLS: Set min SSL version to TLS 1.0\n");
break;
case CURL_SSLVERSION_SSLv3:
- mbedtls_ssl_conf_min_version(&backend->config, MBEDTLS_SSL_MAJOR_VERSION_3,
+ mbedtls_ssl_conf_min_version(&backend->config, MBEDTLS_SSL_MAJOR_VERSION_3,
MBEDTLS_SSL_MINOR_VERSION_0);
- mbedtls_ssl_conf_max_version(&backend->config, MBEDTLS_SSL_MAJOR_VERSION_3,
+ mbedtls_ssl_conf_max_version(&backend->config, MBEDTLS_SSL_MAJOR_VERSION_3,
MBEDTLS_SSL_MINOR_VERSION_0);
infof(data, "mbedTLS: Set SSL version to SSLv3\n");
break;
@@ -437,25 +437,25 @@ mbed_connect_step1(struct connectdata *conn,
return CURLE_SSL_CONNECT_ERROR;
}
- mbedtls_ssl_conf_authmode(&backend->config, MBEDTLS_SSL_VERIFY_OPTIONAL);
+ mbedtls_ssl_conf_authmode(&backend->config, MBEDTLS_SSL_VERIFY_OPTIONAL);
- mbedtls_ssl_conf_rng(&backend->config, mbedtls_ctr_drbg_random,
- &backend->ctr_drbg);
- mbedtls_ssl_set_bio(&backend->ssl, &conn->sock[sockindex],
+ mbedtls_ssl_conf_rng(&backend->config, mbedtls_ctr_drbg_random,
+ &backend->ctr_drbg);
+ mbedtls_ssl_set_bio(&backend->ssl, &conn->sock[sockindex],
mbedtls_net_send,
mbedtls_net_recv,
NULL /* rev_timeout() */);
- mbedtls_ssl_conf_ciphersuites(&backend->config,
+ mbedtls_ssl_conf_ciphersuites(&backend->config,
mbedtls_ssl_list_ciphersuites());
#if defined(MBEDTLS_SSL_RENEGOTIATION)
- mbedtls_ssl_conf_renegotiation(&backend->config,
+ mbedtls_ssl_conf_renegotiation(&backend->config,
MBEDTLS_SSL_RENEGOTIATION_ENABLED);
#endif
#if defined(MBEDTLS_SSL_SESSION_TICKETS)
- mbedtls_ssl_conf_session_tickets(&backend->config,
+ mbedtls_ssl_conf_session_tickets(&backend->config,
MBEDTLS_SSL_SESSION_TICKETS_DISABLED);
#endif
@@ -465,7 +465,7 @@ mbed_connect_step1(struct connectdata *conn,
Curl_ssl_sessionid_lock(conn);
if(!Curl_ssl_getsessionid(conn, &old_session, NULL, sockindex)) {
- ret = mbedtls_ssl_set_session(&backend->ssl, old_session);
+ ret = mbedtls_ssl_set_session(&backend->ssl, old_session);
if(ret) {
Curl_ssl_sessionid_unlock(conn);
failf(data, "mbedtls_ssl_set_session returned -0x%x", -ret);
@@ -476,15 +476,15 @@ mbed_connect_step1(struct connectdata *conn,
Curl_ssl_sessionid_unlock(conn);
}
- mbedtls_ssl_conf_ca_chain(&backend->config,
- &backend->cacert,
- &backend->crl);
+ mbedtls_ssl_conf_ca_chain(&backend->config,
+ &backend->cacert,
+ &backend->crl);
if(SSL_SET_OPTION(key)) {
- mbedtls_ssl_conf_own_cert(&backend->config,
- &backend->clicert, &backend->pk);
+ mbedtls_ssl_conf_own_cert(&backend->config,
+ &backend->clicert, &backend->pk);
}
- if(mbedtls_ssl_set_hostname(&backend->ssl, hostname)) {
+ if(mbedtls_ssl_set_hostname(&backend->ssl, hostname)) {
/* mbedtls_ssl_set_hostname() sets the name to use in CN/SAN checks *and*
the name to set in the SNI extension. So even if curl connects to a
host specified as an IP address, this function must be used. */
@@ -494,7 +494,7 @@ mbed_connect_step1(struct connectdata *conn,
#ifdef HAS_ALPN
if(conn->bits.tls_enable_alpn) {
- const char **p = &backend->protocols[0];
+ const char **p = &backend->protocols[0];
#ifdef USE_NGHTTP2
if(data->set.httpversion >= CURL_HTTP_VERSION_2)
*p++ = NGHTTP2_PROTO_VERSION_ID;
@@ -503,19 +503,19 @@ mbed_connect_step1(struct connectdata *conn,
*p = NULL;
/* this function doesn't clone the protocols array, which is why we need
to keep it around */
- if(mbedtls_ssl_conf_alpn_protocols(&backend->config,
- &backend->protocols[0])) {
+ if(mbedtls_ssl_conf_alpn_protocols(&backend->config,
+ &backend->protocols[0])) {
failf(data, "Failed setting ALPN protocols");
return CURLE_SSL_CONNECT_ERROR;
}
- for(p = &backend->protocols[0]; *p; ++p)
+ for(p = &backend->protocols[0]; *p; ++p)
infof(data, "ALPN, offering %s\n", *p);
}
#endif
#ifdef MBEDTLS_DEBUG
/* In order to make that work in mbedtls MBEDTLS_DEBUG_C must be defined. */
- mbedtls_ssl_conf_dbg(&backend->config, mbed_debug, data);
+ mbedtls_ssl_conf_dbg(&backend->config, mbed_debug, data);
/* - 0 No debug
* - 1 Error
* - 2 State change
@@ -527,7 +527,7 @@ mbed_connect_step1(struct connectdata *conn,
/* give application a chance to interfere with mbedTLS set up. */
if(data->set.ssl.fsslctx) {
- ret = (*data->set.ssl.fsslctx)(data, &backend->config,
+ ret = (*data->set.ssl.fsslctx)(data, &backend->config,
data->set.ssl.fsslctxp);
if(ret) {
failf(data, "error signaled by ssl ctx callback");
@@ -546,22 +546,22 @@ mbed_connect_step2(struct connectdata *conn,
{
int ret;
struct Curl_easy *data = conn->data;
- struct ssl_connect_data *connssl = &conn->ssl[sockindex];
- struct ssl_backend_data *backend = connssl->backend;
+ struct ssl_connect_data *connssl = &conn->ssl[sockindex];
+ struct ssl_backend_data *backend = connssl->backend;
const mbedtls_x509_crt *peercert;
-#ifndef CURL_DISABLE_PROXY
+#ifndef CURL_DISABLE_PROXY
const char * const pinnedpubkey = SSL_IS_PROXY() ?
- data->set.str[STRING_SSL_PINNEDPUBLICKEY_PROXY] :
- data->set.str[STRING_SSL_PINNEDPUBLICKEY_ORIG];
-#else
- const char * const pinnedpubkey =
- data->set.str[STRING_SSL_PINNEDPUBLICKEY_ORIG];
-#endif
+ data->set.str[STRING_SSL_PINNEDPUBLICKEY_PROXY] :
+ data->set.str[STRING_SSL_PINNEDPUBLICKEY_ORIG];
+#else
+ const char * const pinnedpubkey =
+ data->set.str[STRING_SSL_PINNEDPUBLICKEY_ORIG];
+#endif
conn->recv[sockindex] = mbed_recv;
conn->send[sockindex] = mbed_send;
- ret = mbedtls_ssl_handshake(&backend->ssl);
+ ret = mbedtls_ssl_handshake(&backend->ssl);
if(ret == MBEDTLS_ERR_SSL_WANT_READ) {
connssl->connecting_state = ssl_connect_2_reading;
@@ -583,10 +583,10 @@ mbed_connect_step2(struct connectdata *conn,
}
infof(data, "mbedTLS: Handshake complete, cipher is %s\n",
- mbedtls_ssl_get_ciphersuite(&backend->ssl)
+ mbedtls_ssl_get_ciphersuite(&backend->ssl)
);
- ret = mbedtls_ssl_get_verify_result(&backend->ssl);
+ ret = mbedtls_ssl_get_verify_result(&backend->ssl);
if(!SSL_CONN_CONFIG(verifyhost))
/* Ignore hostname errors if verifyhost is disabled */
@@ -605,13 +605,13 @@ mbed_connect_step2(struct connectdata *conn,
else if(ret & MBEDTLS_X509_BADCERT_NOT_TRUSTED)
failf(data, "Cert verify failed: BADCERT_NOT_TRUSTED");
- else if(ret & MBEDTLS_X509_BADCERT_FUTURE)
- failf(data, "Cert verify failed: BADCERT_FUTURE");
-
+ else if(ret & MBEDTLS_X509_BADCERT_FUTURE)
+ failf(data, "Cert verify failed: BADCERT_FUTURE");
+
return CURLE_PEER_FAILED_VERIFICATION;
}
- peercert = mbedtls_ssl_get_peer_cert(&backend->ssl);
+ peercert = mbedtls_ssl_get_peer_cert(&backend->ssl);
if(peercert && data->set.verbose) {
const size_t bufsize = 16384;
@@ -681,7 +681,7 @@ mbed_connect_step2(struct connectdata *conn,
#ifdef HAS_ALPN
if(conn->bits.tls_enable_alpn) {
- const char *next_protocol = mbedtls_ssl_get_alpn_protocol(&backend->ssl);
+ const char *next_protocol = mbedtls_ssl_get_alpn_protocol(&backend->ssl);
if(next_protocol) {
infof(data, "ALPN, server accepted to use %s\n", next_protocol);
@@ -718,7 +718,7 @@ mbed_connect_step3(struct connectdata *conn,
{
CURLcode retcode = CURLE_OK;
struct ssl_connect_data *connssl = &conn->ssl[sockindex];
- struct ssl_backend_data *backend = connssl->backend;
+ struct ssl_backend_data *backend = connssl->backend;
struct Curl_easy *data = conn->data;
DEBUGASSERT(ssl_connect_3 == connssl->connecting_state);
@@ -734,7 +734,7 @@ mbed_connect_step3(struct connectdata *conn,
mbedtls_ssl_session_init(our_ssl_sessionid);
- ret = mbedtls_ssl_get_session(&backend->ssl, our_ssl_sessionid);
+ ret = mbedtls_ssl_get_session(&backend->ssl, our_ssl_sessionid);
if(ret) {
if(ret != MBEDTLS_ERR_SSL_ALLOC_FAILED)
mbedtls_ssl_session_free(our_ssl_sessionid);
@@ -768,10 +768,10 @@ static ssize_t mbed_send(struct connectdata *conn, int sockindex,
CURLcode *curlcode)
{
struct ssl_connect_data *connssl = &conn->ssl[sockindex];
- struct ssl_backend_data *backend = connssl->backend;
+ struct ssl_backend_data *backend = connssl->backend;
int ret = -1;
- ret = mbedtls_ssl_write(&backend->ssl,
+ ret = mbedtls_ssl_write(&backend->ssl,
(unsigned char *)mem, len);
if(ret < 0) {
@@ -791,16 +791,16 @@ static void Curl_mbedtls_close_all(struct Curl_easy *data)
static void Curl_mbedtls_close(struct connectdata *conn, int sockindex)
{
struct ssl_connect_data *connssl = &conn->ssl[sockindex];
- struct ssl_backend_data *backend = connssl->backend;
- mbedtls_pk_free(&backend->pk);
- mbedtls_x509_crt_free(&backend->clicert);
- mbedtls_x509_crt_free(&backend->cacert);
- mbedtls_x509_crl_free(&backend->crl);
- mbedtls_ssl_config_free(&backend->config);
- mbedtls_ssl_free(&backend->ssl);
- mbedtls_ctr_drbg_free(&backend->ctr_drbg);
+ struct ssl_backend_data *backend = connssl->backend;
+ mbedtls_pk_free(&backend->pk);
+ mbedtls_x509_crt_free(&backend->clicert);
+ mbedtls_x509_crt_free(&backend->cacert);
+ mbedtls_x509_crl_free(&backend->crl);
+ mbedtls_ssl_config_free(&backend->config);
+ mbedtls_ssl_free(&backend->ssl);
+ mbedtls_ctr_drbg_free(&backend->ctr_drbg);
#ifndef THREADING_SUPPORT
- mbedtls_entropy_free(&backend->entropy);
+ mbedtls_entropy_free(&backend->entropy);
#endif /* THREADING_SUPPORT */
}
@@ -809,12 +809,12 @@ static ssize_t mbed_recv(struct connectdata *conn, int num,
CURLcode *curlcode)
{
struct ssl_connect_data *connssl = &conn->ssl[num];
- struct ssl_backend_data *backend = connssl->backend;
+ struct ssl_backend_data *backend = connssl->backend;
int ret = -1;
ssize_t len = -1;
memset(buf, 0, buffersize);
- ret = mbedtls_ssl_read(&backend->ssl, (unsigned char *)buf,
+ ret = mbedtls_ssl_read(&backend->ssl, (unsigned char *)buf,
buffersize);
if(ret <= 0) {
@@ -908,7 +908,7 @@ mbed_connect_common(struct connectdata *conn,
struct Curl_easy *data = conn->data;
struct ssl_connect_data *connssl = &conn->ssl[sockindex];
curl_socket_t sockfd = conn->sock[sockindex];
- timediff_t timeout_ms;
+ timediff_t timeout_ms;
int what;
/* check if the connection has already been established */
@@ -1038,20 +1038,20 @@ static CURLcode Curl_mbedtls_connect(struct connectdata *conn, int sockindex)
*/
static int Curl_mbedtls_init(void)
{
- return Curl_mbedtlsthreadlock_thread_setup();
+ return Curl_mbedtlsthreadlock_thread_setup();
}
static void Curl_mbedtls_cleanup(void)
{
- (void)Curl_mbedtlsthreadlock_thread_cleanup();
+ (void)Curl_mbedtlsthreadlock_thread_cleanup();
}
static bool Curl_mbedtls_data_pending(const struct connectdata *conn,
int sockindex)
{
const struct ssl_connect_data *connssl = &conn->ssl[sockindex];
- struct ssl_backend_data *backend = connssl->backend;
- return mbedtls_ssl_get_bytes_avail(&backend->ssl) != 0;
+ struct ssl_backend_data *backend = connssl->backend;
+ return mbedtls_ssl_get_bytes_avail(&backend->ssl) != 0;
}
static CURLcode Curl_mbedtls_sha256sum(const unsigned char *input,
@@ -1073,9 +1073,9 @@ static CURLcode Curl_mbedtls_sha256sum(const unsigned char *input,
static void *Curl_mbedtls_get_internals(struct ssl_connect_data *connssl,
CURLINFO info UNUSED_PARAM)
{
- struct ssl_backend_data *backend = connssl->backend;
+ struct ssl_backend_data *backend = connssl->backend;
(void)info;
- return &backend->ssl;
+ return &backend->ssl;
}
const struct Curl_ssl Curl_ssl_mbedtls = {
diff --git a/contrib/libs/curl/lib/vtls/mbedtls.h b/contrib/libs/curl/lib/vtls/mbedtls.h
index b263d67318..1abd331ea9 100644
--- a/contrib/libs/curl/lib/vtls/mbedtls.h
+++ b/contrib/libs/curl/lib/vtls/mbedtls.h
@@ -7,12 +7,12 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 2012 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2012 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 2010, Hoi-Ho Chan, <hoiho.chan@gmail.com>
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/vtls/mbedtls_threadlock.c b/contrib/libs/curl/lib/vtls/mbedtls_threadlock.c
index 3216118500..d3c4698131 100644
--- a/contrib/libs/curl/lib/vtls/mbedtls_threadlock.c
+++ b/contrib/libs/curl/lib/vtls/mbedtls_threadlock.c
@@ -1,144 +1,144 @@
-/***************************************************************************
- * _ _ ____ _
- * Project ___| | | | _ \| |
- * / __| | | | |_) | |
- * | (__| |_| | _ <| |___
- * \___|\___/|_| \_\_____|
- *
- * Copyright (C) 2013 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
- * Copyright (C) 2010, 2011, Hoi-Ho Chan, <hoiho.chan@gmail.com>
- *
- * This software is licensed as described in the file COPYING, which
- * you should have received as part of this distribution. The terms
- * are also available at https://curl.se/docs/copyright.html.
- *
- * You may opt to use, copy, modify, merge, publish, distribute and/or sell
- * copies of the Software, and permit persons to whom the Software is
- * furnished to do so, under the terms of the COPYING file.
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- ***************************************************************************/
-#include "curl_setup.h"
-
-#if defined(USE_MBEDTLS) && \
- ((defined(USE_THREADS_POSIX) && defined(HAVE_PTHREAD_H)) || \
- (defined(USE_THREADS_WIN32) && defined(HAVE_PROCESS_H)))
-
-#if defined(USE_THREADS_POSIX) && defined(HAVE_PTHREAD_H)
-# include <pthread.h>
-# define MBEDTLS_MUTEX_T pthread_mutex_t
-#elif defined(USE_THREADS_WIN32) && defined(HAVE_PROCESS_H)
-# include <process.h>
-# define MBEDTLS_MUTEX_T HANDLE
-#endif
-
-#error #include "mbedtls_threadlock.h"
-#include "curl_printf.h"
-#include "curl_memory.h"
-/* The last #include file should be: */
-#include "memdebug.h"
-
-/* number of thread locks */
-#define NUMT 2
-
-/* This array will store all of the mutexes available to Mbedtls. */
-static MBEDTLS_MUTEX_T *mutex_buf = NULL;
-
-int Curl_mbedtlsthreadlock_thread_setup(void)
-{
- int i;
-
- mutex_buf = calloc(NUMT * sizeof(MBEDTLS_MUTEX_T), 1);
- if(!mutex_buf)
- return 0; /* error, no number of threads defined */
-
- for(i = 0; i < NUMT; i++) {
- int ret;
-#if defined(USE_THREADS_POSIX) && defined(HAVE_PTHREAD_H)
- ret = pthread_mutex_init(&mutex_buf[i], NULL);
- if(ret)
- return 0; /* pthread_mutex_init failed */
-#elif defined(USE_THREADS_WIN32) && defined(HAVE_PROCESS_H)
- mutex_buf[i] = CreateMutex(0, FALSE, 0);
- if(mutex_buf[i] == 0)
- return 0; /* CreateMutex failed */
-#endif /* USE_THREADS_POSIX && HAVE_PTHREAD_H */
- }
-
- return 1; /* OK */
-}
-
-int Curl_mbedtlsthreadlock_thread_cleanup(void)
-{
- int i;
-
- if(!mutex_buf)
- return 0; /* error, no threads locks defined */
-
- for(i = 0; i < NUMT; i++) {
- int ret;
-#if defined(USE_THREADS_POSIX) && defined(HAVE_PTHREAD_H)
- ret = pthread_mutex_destroy(&mutex_buf[i]);
- if(ret)
- return 0; /* pthread_mutex_destroy failed */
-#elif defined(USE_THREADS_WIN32) && defined(HAVE_PROCESS_H)
- ret = CloseHandle(mutex_buf[i]);
- if(!ret)
- return 0; /* CloseHandle failed */
-#endif /* USE_THREADS_POSIX && HAVE_PTHREAD_H */
- }
- free(mutex_buf);
- mutex_buf = NULL;
-
- return 1; /* OK */
-}
-
-int Curl_mbedtlsthreadlock_lock_function(int n)
-{
- if(n < NUMT) {
- int ret;
-#if defined(USE_THREADS_POSIX) && defined(HAVE_PTHREAD_H)
- ret = pthread_mutex_lock(&mutex_buf[n]);
- if(ret) {
- DEBUGF(fprintf(stderr,
- "Error: mbedtlsthreadlock_lock_function failed\n"));
- return 0; /* pthread_mutex_lock failed */
- }
-#elif defined(USE_THREADS_WIN32) && defined(HAVE_PROCESS_H)
- ret = (WaitForSingleObject(mutex_buf[n], INFINITE) == WAIT_FAILED?1:0);
- if(ret) {
- DEBUGF(fprintf(stderr,
- "Error: mbedtlsthreadlock_lock_function failed\n"));
- return 0; /* pthread_mutex_lock failed */
- }
-#endif /* USE_THREADS_POSIX && HAVE_PTHREAD_H */
- }
- return 1; /* OK */
-}
-
-int Curl_mbedtlsthreadlock_unlock_function(int n)
-{
- if(n < NUMT) {
- int ret;
-#if defined(USE_THREADS_POSIX) && defined(HAVE_PTHREAD_H)
- ret = pthread_mutex_unlock(&mutex_buf[n]);
- if(ret) {
- DEBUGF(fprintf(stderr,
- "Error: mbedtlsthreadlock_unlock_function failed\n"));
- return 0; /* pthread_mutex_unlock failed */
- }
-#elif defined(USE_THREADS_WIN32) && defined(HAVE_PROCESS_H)
- ret = ReleaseMutex(mutex_buf[n]);
- if(!ret) {
- DEBUGF(fprintf(stderr,
- "Error: mbedtlsthreadlock_unlock_function failed\n"));
- return 0; /* pthread_mutex_lock failed */
- }
-#endif /* USE_THREADS_POSIX && HAVE_PTHREAD_H */
- }
- return 1; /* OK */
-}
-
-#endif /* USE_MBEDTLS */
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 2013 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2010, 2011, Hoi-Ho Chan, <hoiho.chan@gmail.com>
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at https://curl.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+#include "curl_setup.h"
+
+#if defined(USE_MBEDTLS) && \
+ ((defined(USE_THREADS_POSIX) && defined(HAVE_PTHREAD_H)) || \
+ (defined(USE_THREADS_WIN32) && defined(HAVE_PROCESS_H)))
+
+#if defined(USE_THREADS_POSIX) && defined(HAVE_PTHREAD_H)
+# include <pthread.h>
+# define MBEDTLS_MUTEX_T pthread_mutex_t
+#elif defined(USE_THREADS_WIN32) && defined(HAVE_PROCESS_H)
+# include <process.h>
+# define MBEDTLS_MUTEX_T HANDLE
+#endif
+
+#error #include "mbedtls_threadlock.h"
+#include "curl_printf.h"
+#include "curl_memory.h"
+/* The last #include file should be: */
+#include "memdebug.h"
+
+/* number of thread locks */
+#define NUMT 2
+
+/* This array will store all of the mutexes available to Mbedtls. */
+static MBEDTLS_MUTEX_T *mutex_buf = NULL;
+
+int Curl_mbedtlsthreadlock_thread_setup(void)
+{
+ int i;
+
+ mutex_buf = calloc(NUMT * sizeof(MBEDTLS_MUTEX_T), 1);
+ if(!mutex_buf)
+ return 0; /* error, no number of threads defined */
+
+ for(i = 0; i < NUMT; i++) {
+ int ret;
+#if defined(USE_THREADS_POSIX) && defined(HAVE_PTHREAD_H)
+ ret = pthread_mutex_init(&mutex_buf[i], NULL);
+ if(ret)
+ return 0; /* pthread_mutex_init failed */
+#elif defined(USE_THREADS_WIN32) && defined(HAVE_PROCESS_H)
+ mutex_buf[i] = CreateMutex(0, FALSE, 0);
+ if(mutex_buf[i] == 0)
+ return 0; /* CreateMutex failed */
+#endif /* USE_THREADS_POSIX && HAVE_PTHREAD_H */
+ }
+
+ return 1; /* OK */
+}
+
+int Curl_mbedtlsthreadlock_thread_cleanup(void)
+{
+ int i;
+
+ if(!mutex_buf)
+ return 0; /* error, no threads locks defined */
+
+ for(i = 0; i < NUMT; i++) {
+ int ret;
+#if defined(USE_THREADS_POSIX) && defined(HAVE_PTHREAD_H)
+ ret = pthread_mutex_destroy(&mutex_buf[i]);
+ if(ret)
+ return 0; /* pthread_mutex_destroy failed */
+#elif defined(USE_THREADS_WIN32) && defined(HAVE_PROCESS_H)
+ ret = CloseHandle(mutex_buf[i]);
+ if(!ret)
+ return 0; /* CloseHandle failed */
+#endif /* USE_THREADS_POSIX && HAVE_PTHREAD_H */
+ }
+ free(mutex_buf);
+ mutex_buf = NULL;
+
+ return 1; /* OK */
+}
+
+int Curl_mbedtlsthreadlock_lock_function(int n)
+{
+ if(n < NUMT) {
+ int ret;
+#if defined(USE_THREADS_POSIX) && defined(HAVE_PTHREAD_H)
+ ret = pthread_mutex_lock(&mutex_buf[n]);
+ if(ret) {
+ DEBUGF(fprintf(stderr,
+ "Error: mbedtlsthreadlock_lock_function failed\n"));
+ return 0; /* pthread_mutex_lock failed */
+ }
+#elif defined(USE_THREADS_WIN32) && defined(HAVE_PROCESS_H)
+ ret = (WaitForSingleObject(mutex_buf[n], INFINITE) == WAIT_FAILED?1:0);
+ if(ret) {
+ DEBUGF(fprintf(stderr,
+ "Error: mbedtlsthreadlock_lock_function failed\n"));
+ return 0; /* pthread_mutex_lock failed */
+ }
+#endif /* USE_THREADS_POSIX && HAVE_PTHREAD_H */
+ }
+ return 1; /* OK */
+}
+
+int Curl_mbedtlsthreadlock_unlock_function(int n)
+{
+ if(n < NUMT) {
+ int ret;
+#if defined(USE_THREADS_POSIX) && defined(HAVE_PTHREAD_H)
+ ret = pthread_mutex_unlock(&mutex_buf[n]);
+ if(ret) {
+ DEBUGF(fprintf(stderr,
+ "Error: mbedtlsthreadlock_unlock_function failed\n"));
+ return 0; /* pthread_mutex_unlock failed */
+ }
+#elif defined(USE_THREADS_WIN32) && defined(HAVE_PROCESS_H)
+ ret = ReleaseMutex(mutex_buf[n]);
+ if(!ret) {
+ DEBUGF(fprintf(stderr,
+ "Error: mbedtlsthreadlock_unlock_function failed\n"));
+ return 0; /* pthread_mutex_lock failed */
+ }
+#endif /* USE_THREADS_POSIX && HAVE_PTHREAD_H */
+ }
+ return 1; /* OK */
+}
+
+#endif /* USE_MBEDTLS */
diff --git a/contrib/libs/curl/lib/vtls/mesalink.c b/contrib/libs/curl/lib/vtls/mesalink.c
index 4b57a78b8f..309786cf83 100644
--- a/contrib/libs/curl/lib/vtls/mesalink.c
+++ b/contrib/libs/curl/lib/vtls/mesalink.c
@@ -6,11 +6,11 @@
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2017 - 2018, Yiming Jing, <jingyiming@baidu.com>
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -158,8 +158,8 @@ mesalink_connect_step1(struct connectdata *conn, int sockindex)
SSL_CONN_CONFIG(CApath))) {
if(SSL_CONN_CONFIG(verifypeer)) {
failf(data,
- "error setting certificate verify locations: "
- " CAfile: %s CApath: %s",
+ "error setting certificate verify locations: "
+ " CAfile: %s CApath: %s",
SSL_CONN_CONFIG(CAfile) ?
SSL_CONN_CONFIG(CAfile) : "none",
SSL_CONN_CONFIG(CApath) ?
@@ -173,18 +173,18 @@ mesalink_connect_step1(struct connectdata *conn, int sockindex)
else {
infof(data, "successfully set certificate verify locations:\n");
}
- infof(data, " CAfile: %s\n",
- SSL_CONN_CONFIG(CAfile) ? SSL_CONN_CONFIG(CAfile): "none");
- infof(data, " CApath: %s\n",
- SSL_CONN_CONFIG(CApath) ? SSL_CONN_CONFIG(CApath): "none");
+ infof(data, " CAfile: %s\n",
+ SSL_CONN_CONFIG(CAfile) ? SSL_CONN_CONFIG(CAfile): "none");
+ infof(data, " CApath: %s\n",
+ SSL_CONN_CONFIG(CApath) ? SSL_CONN_CONFIG(CApath): "none");
}
- if(SSL_SET_OPTION(primary.clientcert) && SSL_SET_OPTION(key)) {
+ if(SSL_SET_OPTION(primary.clientcert) && SSL_SET_OPTION(key)) {
int file_type = do_file_type(SSL_SET_OPTION(cert_type));
- if(SSL_CTX_use_certificate_chain_file(BACKEND->ctx,
- SSL_SET_OPTION(primary.clientcert),
- file_type) != 1) {
+ if(SSL_CTX_use_certificate_chain_file(BACKEND->ctx,
+ SSL_SET_OPTION(primary.clientcert),
+ file_type) != 1) {
failf(data, "unable to use client certificate (no key or wrong pass"
" phrase?)");
return CURLE_SSL_CONNECT_ERROR;
@@ -492,7 +492,7 @@ mesalink_connect_common(struct connectdata *conn, int sockindex,
struct Curl_easy *data = conn->data;
struct ssl_connect_data *connssl = &conn->ssl[sockindex];
curl_socket_t sockfd = conn->sock[sockindex];
- timediff_t timeout_ms;
+ timediff_t timeout_ms;
int what;
/* check if the connection has already been established */
@@ -540,8 +540,8 @@ mesalink_connect_common(struct connectdata *conn, int sockindex,
? sockfd
: CURL_SOCKET_BAD;
- what = Curl_socket_check(readfd, CURL_SOCKET_BAD, writefd,
- nonblocking ? 0 : timeout_ms);
+ what = Curl_socket_check(readfd, CURL_SOCKET_BAD, writefd,
+ nonblocking ? 0 : timeout_ms);
if(what < 0) {
/* fatal error */
failf(data, "select/poll on SSL socket, errno: %d", SOCKERRNO);
diff --git a/contrib/libs/curl/lib/vtls/mesalink.h b/contrib/libs/curl/lib/vtls/mesalink.h
index 58cc3321cc..03f520c1dc 100644
--- a/contrib/libs/curl/lib/vtls/mesalink.h
+++ b/contrib/libs/curl/lib/vtls/mesalink.h
@@ -7,12 +7,12 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 2017 - 2018, Yiming Jing, <jingyiming@baidu.com>
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2017 - 2018, Yiming Jing, <jingyiming@baidu.com>
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/vtls/nss.c b/contrib/libs/curl/lib/vtls/nss.c
index c979d7cc72..59649ccc3a 100644
--- a/contrib/libs/curl/lib/vtls/nss.c
+++ b/contrib/libs/curl/lib/vtls/nss.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -83,7 +83,7 @@ struct ssl_backend_data {
PRFileDesc *handle;
char *client_nickname;
struct Curl_easy *data;
- struct Curl_llist obj_list;
+ struct Curl_llist obj_list;
PK11GenericObject *obj_clicert;
};
@@ -91,32 +91,32 @@ static PRLock *nss_initlock = NULL;
static PRLock *nss_crllock = NULL;
static PRLock *nss_findslot_lock = NULL;
static PRLock *nss_trustload_lock = NULL;
-static struct Curl_llist nss_crl_list;
+static struct Curl_llist nss_crl_list;
static NSSInitContext *nss_context = NULL;
static volatile int initialized = 0;
/* type used to wrap pointers as list nodes */
struct ptr_list_wrap {
void *ptr;
- struct Curl_llist_element node;
+ struct Curl_llist_element node;
};
-struct cipher_s {
+struct cipher_s {
const char *name;
int num;
-};
+};
#define PK11_SETATTRS(_attr, _idx, _type, _val, _len) do { \
CK_ATTRIBUTE *ptr = (_attr) + ((_idx)++); \
ptr->type = (_type); \
ptr->pValue = (_val); \
ptr->ulValueLen = (_len); \
-} while(0)
+} while(0)
#define CERT_NewTempCertificate __CERT_NewTempCertificate
#define NUM_OF_CIPHERS sizeof(cipherlist)/sizeof(cipherlist[0])
-static const struct cipher_s cipherlist[] = {
+static const struct cipher_s cipherlist[] = {
/* SSL2 cipher suites */
{"rc4", SSL_EN_RC4_128_WITH_MD5},
{"rc4-md5", SSL_EN_RC4_128_WITH_MD5},
@@ -430,7 +430,7 @@ static PK11SlotInfo* nss_find_slot_by_name(const char *slot_name)
}
/* wrap 'ptr' as list node and tail-insert into 'list' */
-static CURLcode insert_wrapped_ptr(struct Curl_llist *list, void *ptr)
+static CURLcode insert_wrapped_ptr(struct Curl_llist *list, void *ptr)
{
struct ptr_list_wrap *wrap = malloc(sizeof(*wrap));
if(!wrap)
@@ -460,7 +460,7 @@ static CURLcode nss_create_object(struct ssl_connect_data *connssl,
const int slot_id = (cacert) ? 0 : 1;
char *slot_name = aprintf("PEM Token #%d", slot_id);
- struct ssl_backend_data *backend = connssl->backend;
+ struct ssl_backend_data *backend = connssl->backend;
if(!slot_name)
return CURLE_OUT_OF_MEMORY;
@@ -494,14 +494,14 @@ static CURLcode nss_create_object(struct ssl_connect_data *connssl,
if(!obj)
return result;
- if(insert_wrapped_ptr(&backend->obj_list, obj) != CURLE_OK) {
+ if(insert_wrapped_ptr(&backend->obj_list, obj) != CURLE_OK) {
PK11_DestroyGenericObject(obj);
return CURLE_OUT_OF_MEMORY;
}
if(!cacert && CKO_CERTIFICATE == obj_class)
/* store reference to a client certificate */
- backend->obj_clicert = obj;
+ backend->obj_clicert = obj;
return CURLE_OK;
}
@@ -1027,7 +1027,7 @@ static SECStatus BadCertHandler(void *arg, PRFileDesc *sock)
CERTCertificate *cert;
/* remember the cert verification result */
- SSL_SET_OPTION_LVALUE(certverifyresult) = err;
+ SSL_SET_OPTION_LVALUE(certverifyresult) = err;
if(err == SSL_ERROR_BAD_CERT_DOMAIN && !SSL_CONN_CONFIG(verifyhost))
/* we are asked not to verify the host name */
@@ -1080,8 +1080,8 @@ static CURLcode cmp_peer_pubkey(struct ssl_connect_data *connssl,
const char *pinnedpubkey)
{
CURLcode result = CURLE_SSL_PINNEDPUBKEYNOTMATCH;
- struct ssl_backend_data *backend = connssl->backend;
- struct Curl_easy *data = backend->data;
+ struct ssl_backend_data *backend = connssl->backend;
+ struct Curl_easy *data = backend->data;
CERTCertificate *cert;
if(!pinnedpubkey)
@@ -1089,7 +1089,7 @@ static CURLcode cmp_peer_pubkey(struct ssl_connect_data *connssl,
return CURLE_OK;
/* get peer certificate */
- cert = SSL_PeerCertificate(backend->handle);
+ cert = SSL_PeerCertificate(backend->handle);
if(cert) {
/* extract public key from peer certificate */
SECKEYPublicKey *pubkey = CERT_ExtractPublicKey(cert);
@@ -1133,12 +1133,12 @@ static SECStatus SelectClientCert(void *arg, PRFileDesc *sock,
struct SECKEYPrivateKeyStr **pRetKey)
{
struct ssl_connect_data *connssl = (struct ssl_connect_data *)arg;
- struct ssl_backend_data *backend = connssl->backend;
- struct Curl_easy *data = backend->data;
- const char *nickname = backend->client_nickname;
+ struct ssl_backend_data *backend = connssl->backend;
+ struct Curl_easy *data = backend->data;
+ const char *nickname = backend->client_nickname;
static const char pem_slotname[] = "PEM Token #1";
- if(backend->obj_clicert) {
+ if(backend->obj_clicert) {
/* use the cert/key provided by PEM reader */
SECItem cert_der = { 0, NULL, 0 };
void *proto_win = SSL_RevealPinArg(sock);
@@ -1151,7 +1151,7 @@ static SECStatus SelectClientCert(void *arg, PRFileDesc *sock,
return SECFailure;
}
- if(PK11_ReadRawAttribute(PK11_TypeGeneric, backend->obj_clicert, CKA_VALUE,
+ if(PK11_ReadRawAttribute(PK11_TypeGeneric, backend->obj_clicert, CKA_VALUE,
&cert_der) != SECSuccess) {
failf(data, "NSS: CKA_VALUE not found in PK11 generic object");
PK11_FreeSlot(slot);
@@ -1501,12 +1501,12 @@ static void Curl_nss_cleanup(void)
static int Curl_nss_check_cxn(struct connectdata *conn)
{
struct ssl_connect_data *connssl = &conn->ssl[FIRSTSOCKET];
- struct ssl_backend_data *backend = connssl->backend;
+ struct ssl_backend_data *backend = connssl->backend;
int rc;
char buf;
rc =
- PR_Recv(backend->handle, (void *)&buf, 1, PR_MSG_PEEK,
+ PR_Recv(backend->handle, (void *)&buf, 1, PR_MSG_PEEK,
PR_SecondsToInterval(1));
if(rc > 0)
return 1; /* connection still in place */
@@ -1520,27 +1520,27 @@ static int Curl_nss_check_cxn(struct connectdata *conn)
static void nss_close(struct ssl_connect_data *connssl)
{
/* before the cleanup, check whether we are using a client certificate */
- struct ssl_backend_data *backend = connssl->backend;
- const bool client_cert = (backend->client_nickname != NULL)
- || (backend->obj_clicert != NULL);
+ struct ssl_backend_data *backend = connssl->backend;
+ const bool client_cert = (backend->client_nickname != NULL)
+ || (backend->obj_clicert != NULL);
- free(backend->client_nickname);
- backend->client_nickname = NULL;
+ free(backend->client_nickname);
+ backend->client_nickname = NULL;
/* destroy all NSS objects in order to avoid failure of NSS shutdown */
- Curl_llist_destroy(&backend->obj_list, NULL);
- backend->obj_clicert = NULL;
+ Curl_llist_destroy(&backend->obj_list, NULL);
+ backend->obj_clicert = NULL;
- if(backend->handle) {
+ if(backend->handle) {
if(client_cert)
/* A server might require different authentication based on the
* particular path being requested by the client. To support this
* scenario, we must ensure that a connection will never reuse the
* authentication data from a previous connection. */
- SSL_InvalidateSession(backend->handle);
+ SSL_InvalidateSession(backend->handle);
- PR_Close(backend->handle);
- backend->handle = NULL;
+ PR_Close(backend->handle);
+ backend->handle = NULL;
}
}
@@ -1550,31 +1550,31 @@ static void nss_close(struct ssl_connect_data *connssl)
static void Curl_nss_close(struct connectdata *conn, int sockindex)
{
struct ssl_connect_data *connssl = &conn->ssl[sockindex];
-#ifndef CURL_DISABLE_PROXY
+#ifndef CURL_DISABLE_PROXY
struct ssl_connect_data *connssl_proxy = &conn->proxy_ssl[sockindex];
-#endif
- struct ssl_backend_data *backend = connssl->backend;
-
- if(backend->handle
-#ifndef CURL_DISABLE_PROXY
- || connssl_proxy->backend->handle
-#endif
- ) {
+#endif
+ struct ssl_backend_data *backend = connssl->backend;
+
+ if(backend->handle
+#ifndef CURL_DISABLE_PROXY
+ || connssl_proxy->backend->handle
+#endif
+ ) {
/* NSS closes the socket we previously handed to it, so we must mark it
as closed to avoid double close */
fake_sclose(conn->sock[sockindex]);
conn->sock[sockindex] = CURL_SOCKET_BAD;
}
-#ifndef CURL_DISABLE_PROXY
- if(backend->handle)
+#ifndef CURL_DISABLE_PROXY
+ if(backend->handle)
/* nss_close(connssl) will transitively close also
connssl_proxy->backend->handle if both are used. Clear it to avoid
a double close leading to crash. */
connssl_proxy->backend->handle = NULL;
- nss_close(connssl_proxy);
-#endif
+ nss_close(connssl_proxy);
+#endif
nss_close(connssl);
}
@@ -1626,8 +1626,8 @@ static CURLcode nss_load_ca_certificates(struct connectdata *conn,
if(capath && !capath[0])
capath = NULL;
- infof(data, " CAfile: %s\n", cafile ? cafile : "none");
- infof(data, " CApath: %s\n", capath ? capath : "none");
+ infof(data, " CAfile: %s\n", cafile ? cafile : "none");
+ infof(data, " CApath: %s\n", capath ? capath : "none");
/* load libnssckbi.so if no other trust roots were specified */
use_trust_module = !cafile && !capath;
@@ -1667,8 +1667,8 @@ static CURLcode nss_load_ca_certificates(struct connectdata *conn,
if(!dir)
return CURLE_SSL_CACERT_BADFILE;
- while((entry =
- PR_ReadDir(dir, (PRDirFlags)(PR_SKIP_BOTH | PR_SKIP_HIDDEN)))) {
+ while((entry =
+ PR_ReadDir(dir, (PRDirFlags)(PR_SKIP_BOTH | PR_SKIP_HIDDEN)))) {
char *fullpath = aprintf("%s/%s", capath, entry->name);
if(!fullpath) {
PR_CloseDir(dir);
@@ -1782,7 +1782,7 @@ static CURLcode nss_fail_connect(struct ssl_connect_data *connssl,
CURLcode curlerr)
{
PRErrorCode err = 0;
- struct ssl_backend_data *backend = connssl->backend;
+ struct ssl_backend_data *backend = connssl->backend;
if(is_nss_error(curlerr)) {
/* read NSPR error code */
@@ -1798,7 +1798,7 @@ static CURLcode nss_fail_connect(struct ssl_connect_data *connssl,
}
/* cleanup on connection failure */
- Curl_llist_destroy(&backend->obj_list, NULL);
+ Curl_llist_destroy(&backend->obj_list, NULL);
return curlerr;
}
@@ -1809,11 +1809,11 @@ static CURLcode nss_set_blocking(struct ssl_connect_data *connssl,
bool blocking)
{
static PRSocketOptionData sock_opt;
- struct ssl_backend_data *backend = connssl->backend;
+ struct ssl_backend_data *backend = connssl->backend;
sock_opt.option = PR_SockOpt_Nonblocking;
sock_opt.value.non_blocking = !blocking;
- if(PR_SetSocketOption(backend->handle, &sock_opt) != PR_SUCCESS)
+ if(PR_SetSocketOption(backend->handle, &sock_opt) != PR_SUCCESS)
return nss_fail_connect(connssl, data, CURLE_SSL_CONNECT_ERROR);
return CURLE_OK;
@@ -1829,7 +1829,7 @@ static CURLcode nss_setup_connect(struct connectdata *conn, int sockindex)
struct Curl_easy *data = conn->data;
curl_socket_t sockfd = conn->sock[sockindex];
struct ssl_connect_data *connssl = &conn->ssl[sockindex];
- struct ssl_backend_data *backend = connssl->backend;
+ struct ssl_backend_data *backend = connssl->backend;
CURLcode result;
bool second_layer = FALSE;
SSLVersionRange sslver_supported;
@@ -1847,10 +1847,10 @@ static CURLcode nss_setup_connect(struct connectdata *conn, int sockindex)
#endif
};
- backend->data = data;
+ backend->data = data;
/* list of all NSS objects we need to destroy in Curl_nss_close() */
- Curl_llist_init(&backend->obj_list, nss_destroy_object);
+ Curl_llist_init(&backend->obj_list, nss_destroy_object);
PR_Lock(nss_initlock);
result = nss_init(conn->data);
@@ -1937,7 +1937,7 @@ static CURLcode nss_setup_connect(struct connectdata *conn, int sockindex)
goto error;
/* not checked yet */
- SSL_SET_OPTION_LVALUE(certverifyresult) = 0;
+ SSL_SET_OPTION_LVALUE(certverifyresult) = 0;
if(SSL_BadCertHook(model, BadCertHandler, conn) != SECSuccess)
goto error;
@@ -1965,15 +1965,15 @@ static CURLcode nss_setup_connect(struct connectdata *conn, int sockindex)
infof(data, " CRLfile: %s\n", SSL_SET_OPTION(CRLfile));
}
- if(SSL_SET_OPTION(primary.clientcert)) {
- char *nickname = dup_nickname(data, SSL_SET_OPTION(primary.clientcert));
+ if(SSL_SET_OPTION(primary.clientcert)) {
+ char *nickname = dup_nickname(data, SSL_SET_OPTION(primary.clientcert));
if(nickname) {
/* we are not going to use libnsspem.so to read the client cert */
- backend->obj_clicert = NULL;
+ backend->obj_clicert = NULL;
}
else {
- CURLcode rv = cert_stuff(conn, sockindex,
- SSL_SET_OPTION(primary.clientcert),
+ CURLcode rv = cert_stuff(conn, sockindex,
+ SSL_SET_OPTION(primary.clientcert),
SSL_SET_OPTION(key));
if(rv) {
/* failf() is already done in cert_stuff() */
@@ -1983,10 +1983,10 @@ static CURLcode nss_setup_connect(struct connectdata *conn, int sockindex)
}
/* store the nickname for SelectClientCert() called during handshake */
- backend->client_nickname = nickname;
+ backend->client_nickname = nickname;
}
else
- backend->client_nickname = NULL;
+ backend->client_nickname = NULL;
if(SSL_GetClientAuthDataHook(model, SelectClientCert,
(void *)connssl) != SECSuccess) {
@@ -1994,14 +1994,14 @@ static CURLcode nss_setup_connect(struct connectdata *conn, int sockindex)
goto error;
}
-#ifndef CURL_DISABLE_PROXY
+#ifndef CURL_DISABLE_PROXY
if(conn->proxy_ssl[sockindex].use) {
DEBUGASSERT(ssl_connection_complete == conn->proxy_ssl[sockindex].state);
DEBUGASSERT(conn->proxy_ssl[sockindex].backend->handle != NULL);
nspr_io = conn->proxy_ssl[sockindex].backend->handle;
second_layer = TRUE;
}
-#endif
+#endif
else {
/* wrap OS file descriptor by NSPR's file descriptor abstraction */
nspr_io = PR_ImportTCPSocket(sockfd);
@@ -2029,8 +2029,8 @@ static CURLcode nss_setup_connect(struct connectdata *conn, int sockindex)
}
/* import our model socket onto the current I/O stack */
- backend->handle = SSL_ImportFD(model, nspr_io);
- if(!backend->handle) {
+ backend->handle = SSL_ImportFD(model, nspr_io);
+ if(!backend->handle) {
if(!second_layer)
PR_Close(nspr_io);
goto error;
@@ -2041,36 +2041,36 @@ static CURLcode nss_setup_connect(struct connectdata *conn, int sockindex)
/* This is the password associated with the cert that we're using */
if(SSL_SET_OPTION(key_passwd)) {
- SSL_SetPKCS11PinArg(backend->handle, SSL_SET_OPTION(key_passwd));
+ SSL_SetPKCS11PinArg(backend->handle, SSL_SET_OPTION(key_passwd));
}
#ifdef SSL_ENABLE_OCSP_STAPLING
if(SSL_CONN_CONFIG(verifystatus)) {
- if(SSL_OptionSet(backend->handle, SSL_ENABLE_OCSP_STAPLING, PR_TRUE)
+ if(SSL_OptionSet(backend->handle, SSL_ENABLE_OCSP_STAPLING, PR_TRUE)
!= SECSuccess)
goto error;
}
#endif
#ifdef SSL_ENABLE_NPN
- if(SSL_OptionSet(backend->handle, SSL_ENABLE_NPN, conn->bits.tls_enable_npn
+ if(SSL_OptionSet(backend->handle, SSL_ENABLE_NPN, conn->bits.tls_enable_npn
? PR_TRUE : PR_FALSE) != SECSuccess)
goto error;
#endif
#ifdef SSL_ENABLE_ALPN
- if(SSL_OptionSet(backend->handle, SSL_ENABLE_ALPN, conn->bits.tls_enable_alpn
+ if(SSL_OptionSet(backend->handle, SSL_ENABLE_ALPN, conn->bits.tls_enable_alpn
? PR_TRUE : PR_FALSE) != SECSuccess)
goto error;
#endif
#if NSSVERNUM >= 0x030f04 /* 3.15.4 */
if(data->set.ssl.falsestart) {
- if(SSL_OptionSet(backend->handle, SSL_ENABLE_FALSE_START, PR_TRUE)
+ if(SSL_OptionSet(backend->handle, SSL_ENABLE_FALSE_START, PR_TRUE)
!= SECSuccess)
goto error;
- if(SSL_SetCanFalseStartCallback(backend->handle, CanFalseStartCallback,
+ if(SSL_SetCanFalseStartCallback(backend->handle, CanFalseStartCallback,
conn) != SECSuccess)
goto error;
}
@@ -2082,11 +2082,11 @@ static CURLcode nss_setup_connect(struct connectdata *conn, int sockindex)
unsigned char protocols[128];
#ifdef USE_NGHTTP2
- if(data->set.httpversion >= CURL_HTTP_VERSION_2
-#ifndef CURL_DISABLE_PROXY
- && (!SSL_IS_PROXY() || !conn->bits.tunnel_proxy)
-#endif
- ) {
+ if(data->set.httpversion >= CURL_HTTP_VERSION_2
+#ifndef CURL_DISABLE_PROXY
+ && (!SSL_IS_PROXY() || !conn->bits.tunnel_proxy)
+#endif
+ ) {
protocols[cur++] = NGHTTP2_PROTO_VERSION_ID_LEN;
memcpy(&protocols[cur], NGHTTP2_PROTO_VERSION_ID,
NGHTTP2_PROTO_VERSION_ID_LEN);
@@ -2097,23 +2097,23 @@ static CURLcode nss_setup_connect(struct connectdata *conn, int sockindex)
memcpy(&protocols[cur], ALPN_HTTP_1_1, ALPN_HTTP_1_1_LENGTH);
cur += ALPN_HTTP_1_1_LENGTH;
- if(SSL_SetNextProtoNego(backend->handle, protocols, cur) != SECSuccess)
+ if(SSL_SetNextProtoNego(backend->handle, protocols, cur) != SECSuccess)
goto error;
}
#endif
/* Force handshake on next I/O */
- if(SSL_ResetHandshake(backend->handle, /* asServer */ PR_FALSE)
+ if(SSL_ResetHandshake(backend->handle, /* asServer */ PR_FALSE)
!= SECSuccess)
goto error;
/* propagate hostname to the TLS layer */
- if(SSL_SetURL(backend->handle, SSL_HOST_NAME()) != SECSuccess)
+ if(SSL_SetURL(backend->handle, SSL_HOST_NAME()) != SECSuccess)
goto error;
/* prevent NSS from re-using the session for a different hostname */
- if(SSL_SetSockPeerID(backend->handle, SSL_HOST_NAME()) != SECSuccess)
+ if(SSL_SetSockPeerID(backend->handle, SSL_HOST_NAME()) != SECSuccess)
goto error;
return CURLE_OK;
@@ -2128,13 +2128,13 @@ error:
static CURLcode nss_do_connect(struct connectdata *conn, int sockindex)
{
struct ssl_connect_data *connssl = &conn->ssl[sockindex];
- struct ssl_backend_data *backend = connssl->backend;
+ struct ssl_backend_data *backend = connssl->backend;
struct Curl_easy *data = conn->data;
CURLcode result = CURLE_SSL_CONNECT_ERROR;
PRUint32 timeout;
/* check timeout situation */
- const timediff_t time_left = Curl_timeleft(data, NULL, TRUE);
+ const timediff_t time_left = Curl_timeleft(data, NULL, TRUE);
if(time_left < 0) {
failf(data, "timed out before SSL handshake");
result = CURLE_OPERATION_TIMEDOUT;
@@ -2143,18 +2143,18 @@ static CURLcode nss_do_connect(struct connectdata *conn, int sockindex)
/* Force the handshake now */
timeout = PR_MillisecondsToInterval((PRUint32) time_left);
- if(SSL_ForceHandshakeWithTimeout(backend->handle, timeout) != SECSuccess) {
+ if(SSL_ForceHandshakeWithTimeout(backend->handle, timeout) != SECSuccess) {
if(PR_GetError() == PR_WOULD_BLOCK_ERROR)
/* blocking direction is updated by nss_update_connecting_state() */
return CURLE_AGAIN;
- else if(SSL_SET_OPTION(certverifyresult) == SSL_ERROR_BAD_CERT_DOMAIN)
+ else if(SSL_SET_OPTION(certverifyresult) == SSL_ERROR_BAD_CERT_DOMAIN)
result = CURLE_PEER_FAILED_VERIFICATION;
- else if(SSL_SET_OPTION(certverifyresult) != 0)
+ else if(SSL_SET_OPTION(certverifyresult) != 0)
result = CURLE_PEER_FAILED_VERIFICATION;
goto error;
}
- result = display_conn_info(conn, backend->handle);
+ result = display_conn_info(conn, backend->handle);
if(result)
goto error;
@@ -2163,7 +2163,7 @@ static CURLcode nss_do_connect(struct connectdata *conn, int sockindex)
char *nickname = dup_nickname(data, SSL_SET_OPTION(issuercert));
if(nickname) {
/* we support only nicknames in case of issuercert for now */
- ret = check_issuer_cert(backend->handle, nickname);
+ ret = check_issuer_cert(backend->handle, nickname);
free(nickname);
}
@@ -2177,7 +2177,7 @@ static CURLcode nss_do_connect(struct connectdata *conn, int sockindex)
}
}
- result = cmp_peer_pubkey(connssl, SSL_PINNED_PUB_KEY());
+ result = cmp_peer_pubkey(connssl, SSL_PINNED_PUB_KEY());
if(result)
/* status already printed */
goto error;
@@ -2267,14 +2267,14 @@ static ssize_t nss_send(struct connectdata *conn, /* connection data */
CURLcode *curlcode)
{
struct ssl_connect_data *connssl = &conn->ssl[sockindex];
- struct ssl_backend_data *backend = connssl->backend;
+ struct ssl_backend_data *backend = connssl->backend;
ssize_t rc;
/* The SelectClientCert() hook uses this for infof() and failf() but the
handle stored in nss_setup_connect() could have already been freed. */
- backend->data = conn->data;
+ backend->data = conn->data;
- rc = PR_Send(backend->handle, mem, (int)len, 0, PR_INTERVAL_NO_WAIT);
+ rc = PR_Send(backend->handle, mem, (int)len, 0, PR_INTERVAL_NO_WAIT);
if(rc < 0) {
PRInt32 err = PR_GetError();
if(err == PR_WOULD_BLOCK_ERROR)
@@ -2305,14 +2305,14 @@ static ssize_t nss_recv(struct connectdata *conn, /* connection data */
CURLcode *curlcode)
{
struct ssl_connect_data *connssl = &conn->ssl[sockindex];
- struct ssl_backend_data *backend = connssl->backend;
+ struct ssl_backend_data *backend = connssl->backend;
ssize_t nread;
/* The SelectClientCert() hook uses this for infof() and failf() but the
handle stored in nss_setup_connect() could have already been freed. */
- backend->data = conn->data;
+ backend->data = conn->data;
- nread = PR_Recv(backend->handle, buf, (int)buffersize, 0,
+ nread = PR_Recv(backend->handle, buf, (int)buffersize, 0,
PR_INTERVAL_NO_WAIT);
if(nread < 0) {
/* failed SSL read */
@@ -2373,9 +2373,9 @@ static CURLcode Curl_nss_md5sum(unsigned char *tmp, /* input */
PK11Context *MD5pw = PK11_CreateDigestContext(SEC_OID_MD5);
unsigned int MD5out;
- if(!MD5pw)
- return CURLE_NOT_BUILT_IN;
-
+ if(!MD5pw)
+ return CURLE_NOT_BUILT_IN;
+
PK11_DigestOp(MD5pw, tmp, curlx_uztoui(tmplen));
PK11_DigestFinal(MD5pw, md5sum, &MD5out, curlx_uztoui(md5len));
PK11_DestroyContext(MD5pw, PR_TRUE);
@@ -2391,9 +2391,9 @@ static CURLcode Curl_nss_sha256sum(const unsigned char *tmp, /* input */
PK11Context *SHA256pw = PK11_CreateDigestContext(SEC_OID_SHA256);
unsigned int SHA256out;
- if(!SHA256pw)
- return CURLE_NOT_BUILT_IN;
-
+ if(!SHA256pw)
+ return CURLE_NOT_BUILT_IN;
+
PK11_DigestOp(SHA256pw, tmp, curlx_uztoui(tmplen));
PK11_DigestFinal(SHA256pw, sha256sum, &SHA256out, curlx_uztoui(sha256len));
PK11_DestroyContext(SHA256pw, PR_TRUE);
@@ -2422,9 +2422,9 @@ static bool Curl_nss_false_start(void)
static void *Curl_nss_get_internals(struct ssl_connect_data *connssl,
CURLINFO info UNUSED_PARAM)
{
- struct ssl_backend_data *backend = connssl->backend;
+ struct ssl_backend_data *backend = connssl->backend;
(void)info;
- return backend->handle;
+ return backend->handle;
}
const struct Curl_ssl Curl_ssl_nss = {
diff --git a/contrib/libs/curl/lib/vtls/nssg.h b/contrib/libs/curl/lib/vtls/nssg.h
index 63a607bec0..37b364647b 100644
--- a/contrib/libs/curl/lib/vtls/nssg.h
+++ b/contrib/libs/curl/lib/vtls/nssg.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/vtls/openssl.c b/contrib/libs/curl/lib/vtls/openssl.c
index 3dd9d62ca5..e9c535f8f4 100644
--- a/contrib/libs/curl/lib/vtls/openssl.c
+++ b/contrib/libs/curl/lib/vtls/openssl.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -31,18 +31,18 @@
#include <limits.h>
-/* Wincrypt must be included before anything that could include OpenSSL. */
-#if defined(USE_WIN32_CRYPTO)
-#include <wincrypt.h>
-/* Undefine wincrypt conflicting symbols for BoringSSL. */
-#undef X509_NAME
-#undef X509_EXTENSIONS
-#undef PKCS7_ISSUER_AND_SERIAL
-#undef PKCS7_SIGNER_INFO
-#undef OCSP_REQUEST
-#undef OCSP_RESPONSE
-#endif
-
+/* Wincrypt must be included before anything that could include OpenSSL. */
+#if defined(USE_WIN32_CRYPTO)
+#include <wincrypt.h>
+/* Undefine wincrypt conflicting symbols for BoringSSL. */
+#undef X509_NAME
+#undef X509_EXTENSIONS
+#undef PKCS7_ISSUER_AND_SERIAL
+#undef PKCS7_SIGNER_INFO
+#undef OCSP_REQUEST
+#undef OCSP_RESPONSE
+#endif
+
#include "urldata.h"
#include "sendf.h"
#include "formdata.h" /* for the boundary function */
@@ -53,13 +53,13 @@
#include "slist.h"
#include "select.h"
#include "vtls.h"
-#include "keylog.h"
+#include "keylog.h"
#include "strcase.h"
#include "hostcheck.h"
#include "multiif.h"
-#include "strerror.h"
+#include "strerror.h"
#include "curl_printf.h"
-
+
#include <openssl/ssl.h>
#include <openssl/rand.h>
#include <openssl/x509v3.h>
@@ -200,10 +200,10 @@
!defined(OPENSSL_IS_BORINGSSL))
#define HAVE_SSL_CTX_SET_CIPHERSUITES
#define HAVE_SSL_CTX_SET_POST_HANDSHAKE_AUTH
-/* SET_EC_CURVES available under the same preconditions: see
- * https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set1_groups.html
- */
-#define HAVE_SSL_CTX_SET_EC_CURVES
+/* SET_EC_CURVES available under the same preconditions: see
+ * https://www.openssl.org/docs/manmaster/man3/SSL_CTX_set1_groups.html
+ */
+#define HAVE_SSL_CTX_SET_EC_CURVES
#endif
#if defined(LIBRESSL_VERSION_NUMBER)
@@ -225,22 +225,22 @@
"ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH"
#endif
-#ifdef HAVE_OPENSSL_SRP
-/* the function exists */
-#ifdef USE_TLS_SRP
-/* the functionality is not disabled */
-#define USE_OPENSSL_SRP
-#endif
-#endif
+#ifdef HAVE_OPENSSL_SRP
+/* the function exists */
+#ifdef USE_TLS_SRP
+/* the functionality is not disabled */
+#define USE_OPENSSL_SRP
+#endif
+#endif
struct ssl_backend_data {
/* these ones requires specific SSL-types */
SSL_CTX* ctx;
SSL* handle;
X509* server_cert;
-#ifndef HAVE_KEYLOG_CALLBACK
- /* Set to true once a valid keylog entry has been created to avoid dupes. */
- bool keylog_done;
+#ifndef HAVE_KEYLOG_CALLBACK
+ /* Set to true once a valid keylog entry has been created to avoid dupes. */
+ bool keylog_done;
#endif
};
@@ -257,22 +257,22 @@ static void ossl_keylog_callback(const SSL *ssl, const char *line)
{
(void)ssl;
- Curl_tls_keylog_write_line(line);
+ Curl_tls_keylog_write_line(line);
}
#else
/*
- * ossl_log_tls12_secret is called by libcurl to make the CLIENT_RANDOMs if the
- * OpenSSL being used doesn't have native support for doing that.
+ * ossl_log_tls12_secret is called by libcurl to make the CLIENT_RANDOMs if the
+ * OpenSSL being used doesn't have native support for doing that.
*/
-static void
-ossl_log_tls12_secret(const SSL *ssl, bool *keylog_done)
+static void
+ossl_log_tls12_secret(const SSL *ssl, bool *keylog_done)
{
const SSL_SESSION *session = SSL_get_session(ssl);
unsigned char client_random[SSL3_RANDOM_SIZE];
unsigned char master_key[SSL_MAX_MASTER_KEY_LENGTH];
int master_key_length = 0;
- if(!session || *keylog_done)
+ if(!session || *keylog_done)
return;
#if OPENSSL_VERSION_NUMBER >= 0x10100000L && \
@@ -291,15 +291,15 @@ ossl_log_tls12_secret(const SSL *ssl, bool *keylog_done)
}
#endif
- /* The handshake has not progressed sufficiently yet, or this is a TLS 1.3
- * session (when curl was built with older OpenSSL headers and running with
- * newer OpenSSL runtime libraries). */
+ /* The handshake has not progressed sufficiently yet, or this is a TLS 1.3
+ * session (when curl was built with older OpenSSL headers and running with
+ * newer OpenSSL runtime libraries). */
if(master_key_length <= 0)
return;
- *keylog_done = true;
- Curl_tls_keylog_write("CLIENT_RANDOM", client_random,
- master_key, master_key_length);
+ *keylog_done = true;
+ Curl_tls_keylog_write("CLIENT_RANDOM", client_random,
+ master_key, master_key_length);
}
#endif /* !HAVE_KEYLOG_CALLBACK */
@@ -345,20 +345,20 @@ static const char *SSL_ERROR_to_str(int err)
*/
static char *ossl_strerror(unsigned long error, char *buf, size_t size)
{
- if(size)
- *buf = '\0';
-
+ if(size)
+ *buf = '\0';
+
#ifdef OPENSSL_IS_BORINGSSL
ERR_error_string_n((uint32_t)error, buf, size);
#else
ERR_error_string_n(error, buf, size);
#endif
-
- if(size > 1 && !*buf) {
- strncpy(buf, (error ? "Unknown error" : "No error"), size);
- buf[size - 1] = '\0';
- }
-
+
+ if(size > 1 && !*buf) {
+ strncpy(buf, (error ? "Unknown error" : "No error"), size);
+ buf[size - 1] = '\0';
+ }
+
return buf;
}
@@ -575,138 +575,138 @@ static bool is_pkcs11_uri(const char *string)
static CURLcode Curl_ossl_set_engine(struct Curl_easy *data,
const char *engine);
-static int
-SSL_CTX_use_certificate_bio(SSL_CTX *ctx, BIO *in, int type,
- const char *key_passwd)
-{
- int ret = 0;
- X509 *x = NULL;
-
- if(type == SSL_FILETYPE_ASN1) {
- /* j = ERR_R_ASN1_LIB; */
- x = d2i_X509_bio(in, NULL);
- }
- else if(type == SSL_FILETYPE_PEM) {
- /* ERR_R_PEM_LIB; */
- x = PEM_read_bio_X509(in, NULL,
- passwd_callback, (void *)key_passwd);
- }
- else {
- ret = 0;
- goto end;
- }
-
- if(x == NULL) {
- ret = 0;
- goto end;
- }
-
- ret = SSL_CTX_use_certificate(ctx, x);
- end:
- X509_free(x);
- return ret;
-}
-
-static int
-SSL_CTX_use_PrivateKey_bio(SSL_CTX *ctx, BIO* in, int type,
- const char *key_passwd)
-{
- int ret = 0;
- EVP_PKEY *pkey = NULL;
-
- if(type == SSL_FILETYPE_PEM)
- pkey = PEM_read_bio_PrivateKey(in, NULL, passwd_callback,
- (void *)key_passwd);
- else if(type == SSL_FILETYPE_ASN1)
- pkey = d2i_PrivateKey_bio(in, NULL);
- else {
- ret = 0;
- goto end;
- }
- if(pkey == NULL) {
- ret = 0;
- goto end;
- }
- ret = SSL_CTX_use_PrivateKey(ctx, pkey);
- EVP_PKEY_free(pkey);
- end:
- return ret;
-}
-
-static int
-SSL_CTX_use_certificate_chain_bio(SSL_CTX *ctx, BIO* in,
- const char *key_passwd)
-{
-/* SSL_CTX_add1_chain_cert introduced in OpenSSL 1.0.2 */
-#if (OPENSSL_VERSION_NUMBER >= 0x1000200fL) && /* OpenSSL 1.0.2 or later */ \
- !(defined(LIBRESSL_VERSION_NUMBER) && \
- (LIBRESSL_VERSION_NUMBER < 0x2090100fL)) /* LibreSSL 2.9.1 or later */
- int ret = 0;
- X509 *x = NULL;
- void *passwd_callback_userdata = (void *)key_passwd;
-
- ERR_clear_error();
-
- x = PEM_read_bio_X509_AUX(in, NULL,
- passwd_callback, (void *)key_passwd);
-
- if(x == NULL) {
- ret = 0;
- goto end;
- }
-
- ret = SSL_CTX_use_certificate(ctx, x);
-
- if(ERR_peek_error() != 0)
- ret = 0;
-
- if(ret) {
- X509 *ca;
- unsigned long err;
-
- if(!SSL_CTX_clear_chain_certs(ctx)) {
- ret = 0;
- goto end;
- }
-
- while((ca = PEM_read_bio_X509(in, NULL, passwd_callback,
- passwd_callback_userdata))
- != NULL) {
-
- if(!SSL_CTX_add0_chain_cert(ctx, ca)) {
- X509_free(ca);
- ret = 0;
- goto end;
- }
- }
-
- err = ERR_peek_last_error();
- if((ERR_GET_LIB(err) == ERR_LIB_PEM) &&
- (ERR_GET_REASON(err) == PEM_R_NO_START_LINE))
- ERR_clear_error();
- else
- ret = 0;
- }
-
- end:
- X509_free(x);
- return ret;
-#else
- (void)ctx; /* unused */
- (void)in; /* unused */
- (void)key_passwd; /* unused */
- return 0;
-#endif
-}
-
+static int
+SSL_CTX_use_certificate_bio(SSL_CTX *ctx, BIO *in, int type,
+ const char *key_passwd)
+{
+ int ret = 0;
+ X509 *x = NULL;
+
+ if(type == SSL_FILETYPE_ASN1) {
+ /* j = ERR_R_ASN1_LIB; */
+ x = d2i_X509_bio(in, NULL);
+ }
+ else if(type == SSL_FILETYPE_PEM) {
+ /* ERR_R_PEM_LIB; */
+ x = PEM_read_bio_X509(in, NULL,
+ passwd_callback, (void *)key_passwd);
+ }
+ else {
+ ret = 0;
+ goto end;
+ }
+
+ if(x == NULL) {
+ ret = 0;
+ goto end;
+ }
+
+ ret = SSL_CTX_use_certificate(ctx, x);
+ end:
+ X509_free(x);
+ return ret;
+}
+
+static int
+SSL_CTX_use_PrivateKey_bio(SSL_CTX *ctx, BIO* in, int type,
+ const char *key_passwd)
+{
+ int ret = 0;
+ EVP_PKEY *pkey = NULL;
+
+ if(type == SSL_FILETYPE_PEM)
+ pkey = PEM_read_bio_PrivateKey(in, NULL, passwd_callback,
+ (void *)key_passwd);
+ else if(type == SSL_FILETYPE_ASN1)
+ pkey = d2i_PrivateKey_bio(in, NULL);
+ else {
+ ret = 0;
+ goto end;
+ }
+ if(pkey == NULL) {
+ ret = 0;
+ goto end;
+ }
+ ret = SSL_CTX_use_PrivateKey(ctx, pkey);
+ EVP_PKEY_free(pkey);
+ end:
+ return ret;
+}
+
+static int
+SSL_CTX_use_certificate_chain_bio(SSL_CTX *ctx, BIO* in,
+ const char *key_passwd)
+{
+/* SSL_CTX_add1_chain_cert introduced in OpenSSL 1.0.2 */
+#if (OPENSSL_VERSION_NUMBER >= 0x1000200fL) && /* OpenSSL 1.0.2 or later */ \
+ !(defined(LIBRESSL_VERSION_NUMBER) && \
+ (LIBRESSL_VERSION_NUMBER < 0x2090100fL)) /* LibreSSL 2.9.1 or later */
+ int ret = 0;
+ X509 *x = NULL;
+ void *passwd_callback_userdata = (void *)key_passwd;
+
+ ERR_clear_error();
+
+ x = PEM_read_bio_X509_AUX(in, NULL,
+ passwd_callback, (void *)key_passwd);
+
+ if(x == NULL) {
+ ret = 0;
+ goto end;
+ }
+
+ ret = SSL_CTX_use_certificate(ctx, x);
+
+ if(ERR_peek_error() != 0)
+ ret = 0;
+
+ if(ret) {
+ X509 *ca;
+ unsigned long err;
+
+ if(!SSL_CTX_clear_chain_certs(ctx)) {
+ ret = 0;
+ goto end;
+ }
+
+ while((ca = PEM_read_bio_X509(in, NULL, passwd_callback,
+ passwd_callback_userdata))
+ != NULL) {
+
+ if(!SSL_CTX_add0_chain_cert(ctx, ca)) {
+ X509_free(ca);
+ ret = 0;
+ goto end;
+ }
+ }
+
+ err = ERR_peek_last_error();
+ if((ERR_GET_LIB(err) == ERR_LIB_PEM) &&
+ (ERR_GET_REASON(err) == PEM_R_NO_START_LINE))
+ ERR_clear_error();
+ else
+ ret = 0;
+ }
+
+ end:
+ X509_free(x);
+ return ret;
+#else
+ (void)ctx; /* unused */
+ (void)in; /* unused */
+ (void)key_passwd; /* unused */
+ return 0;
+#endif
+}
+
static
int cert_stuff(struct connectdata *conn,
SSL_CTX* ctx,
char *cert_file,
- BIO *cert_bio,
+ BIO *cert_bio,
const char *cert_type,
char *key_file,
- BIO* key_bio,
+ BIO* key_bio,
const char *key_type,
char *key_passwd)
{
@@ -716,11 +716,11 @@ int cert_stuff(struct connectdata *conn,
int file_type = do_file_type(cert_type);
- if(cert_file || cert_bio || (file_type == SSL_FILETYPE_ENGINE)) {
+ if(cert_file || cert_bio || (file_type == SSL_FILETYPE_ENGINE)) {
SSL *ssl;
X509 *x509;
int cert_done = 0;
- int cert_use_result;
+ int cert_use_result;
if(key_passwd) {
/* set the password in the callback userdata */
@@ -733,10 +733,10 @@ int cert_stuff(struct connectdata *conn,
switch(file_type) {
case SSL_FILETYPE_PEM:
/* SSL_CTX_use_certificate_chain_file() only works on PEM files */
- cert_use_result = cert_bio ?
- SSL_CTX_use_certificate_chain_bio(ctx, cert_bio, key_passwd) :
- SSL_CTX_use_certificate_chain_file(ctx, cert_file);
- if(cert_use_result != 1) {
+ cert_use_result = cert_bio ?
+ SSL_CTX_use_certificate_chain_bio(ctx, cert_bio, key_passwd) :
+ SSL_CTX_use_certificate_chain_file(ctx, cert_file);
+ if(cert_use_result != 1) {
failf(data,
"could not load PEM client certificate, " OSSL_PACKAGE
" error %s, "
@@ -751,12 +751,12 @@ int cert_stuff(struct connectdata *conn,
/* SSL_CTX_use_certificate_file() works with either PEM or ASN1, but
we use the case above for PEM so this can only be performed with
ASN1 files. */
-
- cert_use_result = cert_bio ?
- SSL_CTX_use_certificate_bio(ctx, cert_bio,
- file_type, key_passwd) :
- SSL_CTX_use_certificate_file(ctx, cert_file, file_type);
- if(cert_use_result != 1) {
+
+ cert_use_result = cert_bio ?
+ SSL_CTX_use_certificate_bio(ctx, cert_bio,
+ file_type, key_passwd) :
+ SSL_CTX_use_certificate_file(ctx, cert_file, file_type);
+ if(cert_use_result != 1) {
failf(data,
"could not load ASN1 client certificate, " OSSL_PACKAGE
" error %s, "
@@ -836,31 +836,31 @@ int cert_stuff(struct connectdata *conn,
PKCS12 *p12 = NULL;
EVP_PKEY *pri;
STACK_OF(X509) *ca = NULL;
- if(!cert_bio) {
- fp = BIO_new(BIO_s_file());
- if(fp == NULL) {
- failf(data,
- "BIO_new return NULL, " OSSL_PACKAGE
- " error %s",
- ossl_strerror(ERR_get_error(), error_buffer,
- sizeof(error_buffer)) );
- return 0;
- }
-
- if(BIO_read_filename(fp, cert_file) <= 0) {
- failf(data, "could not open PKCS12 file '%s'", cert_file);
- BIO_free(fp);
- return 0;
- }
+ if(!cert_bio) {
+ fp = BIO_new(BIO_s_file());
+ if(fp == NULL) {
+ failf(data,
+ "BIO_new return NULL, " OSSL_PACKAGE
+ " error %s",
+ ossl_strerror(ERR_get_error(), error_buffer,
+ sizeof(error_buffer)) );
+ return 0;
+ }
+
+ if(BIO_read_filename(fp, cert_file) <= 0) {
+ failf(data, "could not open PKCS12 file '%s'", cert_file);
+ BIO_free(fp);
+ return 0;
+ }
}
- p12 = d2i_PKCS12_bio(cert_bio ? cert_bio : fp, NULL);
- if(fp)
+ p12 = d2i_PKCS12_bio(cert_bio ? cert_bio : fp, NULL);
+ if(fp)
BIO_free(fp);
if(!p12) {
- failf(data, "error reading PKCS12 file '%s'",
- cert_bio ? "(memory blob)" : cert_file);
+ failf(data, "error reading PKCS12 file '%s'",
+ cert_bio ? "(memory blob)" : cert_file);
return 0;
}
@@ -941,10 +941,10 @@ int cert_stuff(struct connectdata *conn,
return 0;
}
- if((!key_file) && (!key_bio)) {
+ if((!key_file) && (!key_bio)) {
key_file = cert_file;
- key_bio = cert_bio;
- }
+ key_bio = cert_bio;
+ }
else
file_type = do_file_type(key_type);
@@ -954,12 +954,12 @@ int cert_stuff(struct connectdata *conn,
break;
/* FALLTHROUGH */
case SSL_FILETYPE_ASN1:
- cert_use_result = key_bio ?
- SSL_CTX_use_PrivateKey_bio(ctx, key_bio, file_type, key_passwd) :
- SSL_CTX_use_PrivateKey_file(ctx, key_file, file_type);
- if(cert_use_result != 1) {
+ cert_use_result = key_bio ?
+ SSL_CTX_use_PrivateKey_bio(ctx, key_bio, file_type, key_passwd) :
+ SSL_CTX_use_PrivateKey_file(ctx, key_file, file_type);
+ if(cert_use_result != 1) {
failf(data, "unable to set private key file: '%s' type %s",
- key_file?key_file:"(memory blob)", key_type?key_type:"PEM");
+ key_file?key_file:"(memory blob)", key_type?key_type:"PEM");
return 0;
}
break;
@@ -1115,21 +1115,21 @@ static int x509_name_oneline(X509_NAME *a, char *buf, size_t size)
*/
static int Curl_ossl_init(void)
{
-#if (OPENSSL_VERSION_NUMBER >= 0x10100000L) && \
- !defined(LIBRESSL_VERSION_NUMBER)
- const uint64_t flags =
-#ifdef OPENSSL_INIT_ENGINE_ALL_BUILTIN
- /* not present in BoringSSL */
- OPENSSL_INIT_ENGINE_ALL_BUILTIN |
-#endif
-#ifdef CURL_DISABLE_OPENSSL_AUTO_LOAD_CONFIG
- OPENSSL_INIT_NO_LOAD_CONFIG |
-#else
- OPENSSL_INIT_LOAD_CONFIG |
-#endif
- 0;
- OPENSSL_init_ssl(flags, NULL);
-#else
+#if (OPENSSL_VERSION_NUMBER >= 0x10100000L) && \
+ !defined(LIBRESSL_VERSION_NUMBER)
+ const uint64_t flags =
+#ifdef OPENSSL_INIT_ENGINE_ALL_BUILTIN
+ /* not present in BoringSSL */
+ OPENSSL_INIT_ENGINE_ALL_BUILTIN |
+#endif
+#ifdef CURL_DISABLE_OPENSSL_AUTO_LOAD_CONFIG
+ OPENSSL_INIT_NO_LOAD_CONFIG |
+#else
+ OPENSSL_INIT_LOAD_CONFIG |
+#endif
+ 0;
+ OPENSSL_init_ssl(flags, NULL);
+#else
OPENSSL_load_builtin_modules();
#ifdef USE_OPENSSL_ENGINE
@@ -1158,7 +1158,7 @@ static int Curl_ossl_init(void)
OpenSSL_add_all_algorithms();
#endif
- Curl_tls_keylog_open();
+ Curl_tls_keylog_open();
/* Initialize the extra data indexes */
if(ossl_get_ssl_conn_index() < 0 || ossl_get_ssl_sockindex_index() < 0)
@@ -1201,7 +1201,7 @@ static void Curl_ossl_cleanup(void)
#endif
#endif
- Curl_tls_keylog_close();
+ Curl_tls_keylog_close();
}
/*
@@ -1348,17 +1348,17 @@ static struct curl_slist *Curl_ossl_engines_list(struct Curl_easy *data)
static void ossl_close(struct ssl_connect_data *connssl)
{
- struct ssl_backend_data *backend = connssl->backend;
- if(backend->handle) {
- (void)SSL_shutdown(backend->handle);
- SSL_set_connect_state(backend->handle);
+ struct ssl_backend_data *backend = connssl->backend;
+ if(backend->handle) {
+ (void)SSL_shutdown(backend->handle);
+ SSL_set_connect_state(backend->handle);
- SSL_free(backend->handle);
- backend->handle = NULL;
+ SSL_free(backend->handle);
+ backend->handle = NULL;
}
- if(backend->ctx) {
- SSL_CTX_free(backend->ctx);
- backend->ctx = NULL;
+ if(backend->ctx) {
+ SSL_CTX_free(backend->ctx);
+ backend->ctx = NULL;
}
}
@@ -1368,9 +1368,9 @@ static void ossl_close(struct ssl_connect_data *connssl)
static void Curl_ossl_close(struct connectdata *conn, int sockindex)
{
ossl_close(&conn->ssl[sockindex]);
-#ifndef CURL_DISABLE_PROXY
+#ifndef CURL_DISABLE_PROXY
ossl_close(&conn->proxy_ssl[sockindex]);
-#endif
+#endif
}
/*
@@ -1389,7 +1389,7 @@ static int Curl_ossl_shutdown(struct connectdata *conn, int sockindex)
int buffsize;
int err;
bool done = FALSE;
- struct ssl_backend_data *backend = connssl->backend;
+ struct ssl_backend_data *backend = connssl->backend;
#ifndef CURL_DISABLE_FTP
/* This has only been tested on the proftpd server, and the mod_tls code
@@ -1398,10 +1398,10 @@ static int Curl_ossl_shutdown(struct connectdata *conn, int sockindex)
we do not send one. Let's hope other servers do the same... */
if(data->set.ftp_ccc == CURLFTPSSL_CCC_ACTIVE)
- (void)SSL_shutdown(backend->handle);
+ (void)SSL_shutdown(backend->handle);
#endif
- if(backend->handle) {
+ if(backend->handle) {
buffsize = (int)sizeof(buf);
while(!done) {
int what = SOCKET_READABLE(conn->sock[sockindex],
@@ -1411,8 +1411,8 @@ static int Curl_ossl_shutdown(struct connectdata *conn, int sockindex)
/* Something to read, let's do it and hope that it is the close
notify alert from the server */
- nread = (ssize_t)SSL_read(backend->handle, buf, buffsize);
- err = SSL_get_error(backend->handle, (int)nread);
+ nread = (ssize_t)SSL_read(backend->handle, buf, buffsize);
+ err = SSL_get_error(backend->handle, (int)nread);
switch(err) {
case SSL_ERROR_NONE: /* this is not an error */
@@ -1457,7 +1457,7 @@ static int Curl_ossl_shutdown(struct connectdata *conn, int sockindex)
if(data->set.verbose) {
#ifdef HAVE_SSL_GET_SHUTDOWN
- switch(SSL_get_shutdown(backend->handle)) {
+ switch(SSL_get_shutdown(backend->handle)) {
case SSL_SENT_SHUTDOWN:
infof(data, "SSL_get_shutdown() returned SSL_SENT_SHUTDOWN\n");
break;
@@ -1472,8 +1472,8 @@ static int Curl_ossl_shutdown(struct connectdata *conn, int sockindex)
#endif
}
- SSL_free(backend->handle);
- backend->handle = NULL;
+ SSL_free(backend->handle);
+ backend->handle = NULL;
}
return retval;
}
@@ -1597,8 +1597,8 @@ static CURLcode verifyhost(struct connectdata *conn, X509 *server_cert)
CURLcode result = CURLE_OK;
bool dNSName = FALSE; /* if a dNSName field exists in the cert */
bool iPAddress = FALSE; /* if a iPAddress field exists in the cert */
- const char * const hostname = SSL_HOST_NAME();
- const char * const dispname = SSL_HOST_DISPNAME();
+ const char * const hostname = SSL_HOST_NAME();
+ const char * const dispname = SSL_HOST_DISPNAME();
#ifdef ENABLE_IPV6
if(conn->bits.ipv6_ip &&
@@ -1656,7 +1656,7 @@ static CURLcode verifyhost(struct connectdata *conn, X509 *server_cert)
type itself: for example for an IA5String the data will be ASCII"
It has been however verified that in 0.9.6 and 0.9.7, IA5String
- is always null-terminated.
+ is always null-terminated.
*/
if((altlen == strlen(altptr)) &&
/* if this isn't true, there was an embedded zero in the name
@@ -1794,14 +1794,14 @@ static CURLcode verifystatus(struct connectdata *conn,
OCSP_BASICRESP *br = NULL;
X509_STORE *st = NULL;
STACK_OF(X509) *ch = NULL;
- struct ssl_backend_data *backend = connssl->backend;
- X509 *cert;
- OCSP_CERTID *id = NULL;
- int cert_status, crl_reason;
- ASN1_GENERALIZEDTIME *rev, *thisupd, *nextupd;
- int ret;
+ struct ssl_backend_data *backend = connssl->backend;
+ X509 *cert;
+ OCSP_CERTID *id = NULL;
+ int cert_status, crl_reason;
+ ASN1_GENERALIZEDTIME *rev, *thisupd, *nextupd;
+ int ret;
- long len = SSL_get_tlsext_status_ocsp_resp(backend->handle, &status);
+ long len = SSL_get_tlsext_status_ocsp_resp(backend->handle, &status);
if(!status) {
failf(data, "No OCSP response received");
@@ -1831,8 +1831,8 @@ static CURLcode verifystatus(struct connectdata *conn,
goto end;
}
- ch = SSL_get_peer_cert_chain(backend->handle);
- st = SSL_CTX_get_cert_store(backend->ctx);
+ ch = SSL_get_peer_cert_chain(backend->handle);
+ st = SSL_CTX_get_cert_store(backend->ctx);
#if ((OPENSSL_VERSION_NUMBER <= 0x1000201fL) /* Fixed after 1.0.2a */ || \
(defined(LIBRESSL_VERSION_NUMBER) && \
@@ -1868,68 +1868,68 @@ static CURLcode verifystatus(struct connectdata *conn,
goto end;
}
- /* Compute the certificate's ID */
- cert = SSL_get_peer_certificate(backend->handle);
- if(!cert) {
- failf(data, "Error getting peer certficate");
- result = CURLE_SSL_INVALIDCERTSTATUS;
- goto end;
- }
-
- for(i = 0; i < sk_X509_num(ch); i++) {
- X509 *issuer = sk_X509_value(ch, i);
- if(X509_check_issued(issuer, cert) == X509_V_OK) {
- id = OCSP_cert_to_id(EVP_sha1(), cert, issuer);
- break;
- }
- }
- X509_free(cert);
-
- if(!id) {
- failf(data, "Error computing OCSP ID");
- result = CURLE_SSL_INVALIDCERTSTATUS;
- goto end;
- }
-
- /* Find the single OCSP response corresponding to the certificate ID */
- ret = OCSP_resp_find_status(br, id, &cert_status, &crl_reason, &rev,
- &thisupd, &nextupd);
- OCSP_CERTID_free(id);
- if(ret != 1) {
- failf(data, "Could not find certificate ID in OCSP response");
- result = CURLE_SSL_INVALIDCERTSTATUS;
- goto end;
- }
-
- /* Validate the corresponding single OCSP response */
- if(!OCSP_check_validity(thisupd, nextupd, 300L, -1L)) {
- failf(data, "OCSP response has expired");
- result = CURLE_SSL_INVALIDCERTSTATUS;
- goto end;
- }
-
- infof(data, "SSL certificate status: %s (%d)\n",
- OCSP_cert_status_str(cert_status), cert_status);
-
- switch(cert_status) {
- case V_OCSP_CERTSTATUS_GOOD:
- break;
-
- case V_OCSP_CERTSTATUS_REVOKED:
- result = CURLE_SSL_INVALIDCERTSTATUS;
- failf(data, "SSL certificate revocation reason: %s (%d)",
- OCSP_crl_reason_str(crl_reason), crl_reason);
- goto end;
-
- case V_OCSP_CERTSTATUS_UNKNOWN:
- default:
- result = CURLE_SSL_INVALIDCERTSTATUS;
- goto end;
+ /* Compute the certificate's ID */
+ cert = SSL_get_peer_certificate(backend->handle);
+ if(!cert) {
+ failf(data, "Error getting peer certficate");
+ result = CURLE_SSL_INVALIDCERTSTATUS;
+ goto end;
+ }
+
+ for(i = 0; i < sk_X509_num(ch); i++) {
+ X509 *issuer = sk_X509_value(ch, i);
+ if(X509_check_issued(issuer, cert) == X509_V_OK) {
+ id = OCSP_cert_to_id(EVP_sha1(), cert, issuer);
+ break;
+ }
+ }
+ X509_free(cert);
+
+ if(!id) {
+ failf(data, "Error computing OCSP ID");
+ result = CURLE_SSL_INVALIDCERTSTATUS;
+ goto end;
+ }
+
+ /* Find the single OCSP response corresponding to the certificate ID */
+ ret = OCSP_resp_find_status(br, id, &cert_status, &crl_reason, &rev,
+ &thisupd, &nextupd);
+ OCSP_CERTID_free(id);
+ if(ret != 1) {
+ failf(data, "Could not find certificate ID in OCSP response");
+ result = CURLE_SSL_INVALIDCERTSTATUS;
+ goto end;
+ }
+
+ /* Validate the corresponding single OCSP response */
+ if(!OCSP_check_validity(thisupd, nextupd, 300L, -1L)) {
+ failf(data, "OCSP response has expired");
+ result = CURLE_SSL_INVALIDCERTSTATUS;
+ goto end;
+ }
+
+ infof(data, "SSL certificate status: %s (%d)\n",
+ OCSP_cert_status_str(cert_status), cert_status);
+
+ switch(cert_status) {
+ case V_OCSP_CERTSTATUS_GOOD:
+ break;
+
+ case V_OCSP_CERTSTATUS_REVOKED:
+ result = CURLE_SSL_INVALIDCERTSTATUS;
+ failf(data, "SSL certificate revocation reason: %s (%d)",
+ OCSP_crl_reason_str(crl_reason), crl_reason);
+ goto end;
+
+ case V_OCSP_CERTSTATUS_UNKNOWN:
+ default:
+ result = CURLE_SSL_INVALIDCERTSTATUS;
+ goto end;
}
end:
- if(br)
- OCSP_BASICRESP_free(br);
+ if(br)
+ OCSP_BASICRESP_free(br);
OCSP_RESPONSE_free(rsp);
return result;
@@ -2275,13 +2275,13 @@ set_ssl_version_min_max(SSL_CTX *ctx, struct connectdata *conn)
long curl_ssl_version_max;
/* convert cURL min SSL version option to OpenSSL constant */
-#if defined(OPENSSL_IS_BORINGSSL) || defined(LIBRESSL_VERSION_NUMBER)
- uint16_t ossl_ssl_version_min = 0;
- uint16_t ossl_ssl_version_max = 0;
-#else
+#if defined(OPENSSL_IS_BORINGSSL) || defined(LIBRESSL_VERSION_NUMBER)
+ uint16_t ossl_ssl_version_min = 0;
+ uint16_t ossl_ssl_version_max = 0;
+#else
long ossl_ssl_version_min = 0;
long ossl_ssl_version_max = 0;
-#endif
+#endif
switch(curl_ssl_version_min) {
case CURL_SSLVERSION_TLSv1: /* TLS 1.x */
case CURL_SSLVERSION_TLSv1_0:
@@ -2301,10 +2301,10 @@ set_ssl_version_min_max(SSL_CTX *ctx, struct connectdata *conn)
}
/* CURL_SSLVERSION_DEFAULT means that no option was selected.
- We don't want to pass 0 to SSL_CTX_set_min_proto_version as
- it would enable all versions down to the lowest supported by
- the library.
- So we skip this, and stay with the OS default
+ We don't want to pass 0 to SSL_CTX_set_min_proto_version as
+ it would enable all versions down to the lowest supported by
+ the library.
+ So we skip this, and stay with the OS default
*/
if(curl_ssl_version_min != CURL_SSLVERSION_DEFAULT) {
if(!SSL_CTX_set_min_proto_version(ctx, ossl_ssl_version_min)) {
@@ -2374,7 +2374,7 @@ set_ssl_version_min_max_legacy(ctx_option_t *ctx_options,
#ifdef TLS1_3_VERSION
{
struct ssl_connect_data *connssl = &conn->ssl[sockindex];
- SSL_CTX_set_max_proto_version(backend->ctx, TLS1_3_VERSION);
+ SSL_CTX_set_max_proto_version(backend->ctx, TLS1_3_VERSION);
*ctx_options |= SSL_OP_NO_TLSv1_2;
}
#else
@@ -2502,8 +2502,8 @@ static CURLcode ossl_connect_step1(struct connectdata *conn, int sockindex)
#ifdef SSL_CTRL_SET_TLSEXT_HOSTNAME
bool sni;
- const char * const hostname = SSL_HOST_NAME();
-
+ const char * const hostname = SSL_HOST_NAME();
+
#ifdef ENABLE_IPV6
struct in6_addr addr;
#else
@@ -2511,19 +2511,19 @@ static CURLcode ossl_connect_step1(struct connectdata *conn, int sockindex)
#endif
#endif
const long int ssl_version = SSL_CONN_CONFIG(version);
-#ifdef USE_OPENSSL_SRP
+#ifdef USE_OPENSSL_SRP
const enum CURL_TLSAUTH ssl_authtype = SSL_SET_OPTION(authtype);
#endif
- char * const ssl_cert = SSL_SET_OPTION(primary.clientcert);
- const struct curl_blob *ssl_cert_blob = SSL_SET_OPTION(primary.cert_blob);
+ char * const ssl_cert = SSL_SET_OPTION(primary.clientcert);
+ const struct curl_blob *ssl_cert_blob = SSL_SET_OPTION(primary.cert_blob);
const char * const ssl_cert_type = SSL_SET_OPTION(cert_type);
const char * const ssl_cafile = SSL_CONN_CONFIG(CAfile);
const char * const ssl_capath = SSL_CONN_CONFIG(CApath);
const bool verifypeer = SSL_CONN_CONFIG(verifypeer);
const char * const ssl_crlfile = SSL_SET_OPTION(CRLfile);
char error_buffer[256];
- struct ssl_backend_data *backend = connssl->backend;
- bool imported_native_ca = false;
+ struct ssl_backend_data *backend = connssl->backend;
+ bool imported_native_ca = false;
DEBUGASSERT(ssl_connect_1 == connssl->connecting_state);
@@ -2532,7 +2532,7 @@ static CURLcode ossl_connect_step1(struct connectdata *conn, int sockindex)
if(result)
return result;
- SSL_SET_OPTION_LVALUE(certverifyresult) = !X509_V_OK;
+ SSL_SET_OPTION_LVALUE(certverifyresult) = !X509_V_OK;
/* check to see if we've been told to use an explicit SSL/TLS version */
@@ -2556,7 +2556,7 @@ static CURLcode ossl_connect_step1(struct connectdata *conn, int sockindex)
failf(data, OSSL_PACKAGE " was built without SSLv2 support");
return CURLE_NOT_BUILT_IN;
#else
-#ifdef USE_OPENSSL_SRP
+#ifdef USE_OPENSSL_SRP
if(ssl_authtype == CURL_TLSAUTH_SRP)
return CURLE_SSL_CONNECT_ERROR;
#endif
@@ -2569,7 +2569,7 @@ static CURLcode ossl_connect_step1(struct connectdata *conn, int sockindex)
failf(data, OSSL_PACKAGE " was built without SSLv3 support");
return CURLE_NOT_BUILT_IN;
#else
-#ifdef USE_OPENSSL_SRP
+#ifdef USE_OPENSSL_SRP
if(ssl_authtype == CURL_TLSAUTH_SRP)
return CURLE_SSL_CONNECT_ERROR;
#endif
@@ -2582,25 +2582,25 @@ static CURLcode ossl_connect_step1(struct connectdata *conn, int sockindex)
return CURLE_SSL_CONNECT_ERROR;
}
- if(backend->ctx)
- SSL_CTX_free(backend->ctx);
- backend->ctx = SSL_CTX_new(req_method);
+ if(backend->ctx)
+ SSL_CTX_free(backend->ctx);
+ backend->ctx = SSL_CTX_new(req_method);
- if(!backend->ctx) {
+ if(!backend->ctx) {
failf(data, "SSL: couldn't create a context: %s",
ossl_strerror(ERR_peek_error(), error_buffer, sizeof(error_buffer)));
return CURLE_OUT_OF_MEMORY;
}
#ifdef SSL_MODE_RELEASE_BUFFERS
- SSL_CTX_set_mode(backend->ctx, SSL_MODE_RELEASE_BUFFERS);
+ SSL_CTX_set_mode(backend->ctx, SSL_MODE_RELEASE_BUFFERS);
#endif
#ifdef SSL_CTRL_SET_MSG_CALLBACK
if(data->set.fdebug && data->set.verbose) {
/* the SSL trace callback is only used for verbose logging */
- SSL_CTX_set_msg_callback(backend->ctx, ssl_tls_trace);
- SSL_CTX_set_msg_callback_arg(backend->ctx, conn);
+ SSL_CTX_set_msg_callback(backend->ctx, ssl_tls_trace);
+ SSL_CTX_set_msg_callback_arg(backend->ctx, conn);
}
#endif
@@ -2666,8 +2666,8 @@ static CURLcode ossl_connect_step1(struct connectdata *conn, int sockindex)
/* "--sslv2" option means SSLv2 only, disable all others */
case CURL_SSLVERSION_SSLv2:
#if OPENSSL_VERSION_NUMBER >= 0x10100000L /* 1.1.0 */
- SSL_CTX_set_min_proto_version(backend->ctx, SSL2_VERSION);
- SSL_CTX_set_max_proto_version(backend->ctx, SSL2_VERSION);
+ SSL_CTX_set_min_proto_version(backend->ctx, SSL2_VERSION);
+ SSL_CTX_set_max_proto_version(backend->ctx, SSL2_VERSION);
#else
ctx_options |= SSL_OP_NO_SSLv3;
ctx_options |= SSL_OP_NO_TLSv1;
@@ -2684,8 +2684,8 @@ static CURLcode ossl_connect_step1(struct connectdata *conn, int sockindex)
/* "--sslv3" option means SSLv3 only, disable all others */
case CURL_SSLVERSION_SSLv3:
#if OPENSSL_VERSION_NUMBER >= 0x10100000L /* 1.1.0 */
- SSL_CTX_set_min_proto_version(backend->ctx, SSL3_VERSION);
- SSL_CTX_set_max_proto_version(backend->ctx, SSL3_VERSION);
+ SSL_CTX_set_min_proto_version(backend->ctx, SSL3_VERSION);
+ SSL_CTX_set_max_proto_version(backend->ctx, SSL3_VERSION);
#else
ctx_options |= SSL_OP_NO_SSLv2;
ctx_options |= SSL_OP_NO_TLSv1;
@@ -2712,7 +2712,7 @@ static CURLcode ossl_connect_step1(struct connectdata *conn, int sockindex)
ctx_options |= SSL_OP_NO_SSLv3;
#if (OPENSSL_VERSION_NUMBER >= 0x10100000L) /* 1.1.0 */
- result = set_ssl_version_min_max(backend->ctx, conn);
+ result = set_ssl_version_min_max(backend->ctx, conn);
#else
result = set_ssl_version_min_max_legacy(&ctx_options, conn, sockindex);
#endif
@@ -2725,11 +2725,11 @@ static CURLcode ossl_connect_step1(struct connectdata *conn, int sockindex)
return CURLE_SSL_CONNECT_ERROR;
}
- SSL_CTX_set_options(backend->ctx, ctx_options);
+ SSL_CTX_set_options(backend->ctx, ctx_options);
#ifdef HAS_NPN
if(conn->bits.tls_enable_npn)
- SSL_CTX_set_next_proto_select_cb(backend->ctx, select_next_proto_cb, conn);
+ SSL_CTX_set_next_proto_select_cb(backend->ctx, select_next_proto_cb, conn);
#endif
#ifdef HAS_ALPN
@@ -2738,11 +2738,11 @@ static CURLcode ossl_connect_step1(struct connectdata *conn, int sockindex)
unsigned char protocols[128];
#ifdef USE_NGHTTP2
- if(data->set.httpversion >= CURL_HTTP_VERSION_2
-#ifndef CURL_DISABLE_PROXY
- && (!SSL_IS_PROXY() || !conn->bits.tunnel_proxy)
-#endif
- ) {
+ if(data->set.httpversion >= CURL_HTTP_VERSION_2
+#ifndef CURL_DISABLE_PROXY
+ && (!SSL_IS_PROXY() || !conn->bits.tunnel_proxy)
+#endif
+ ) {
protocols[cur++] = NGHTTP2_PROTO_VERSION_ID_LEN;
memcpy(&protocols[cur], NGHTTP2_PROTO_VERSION_ID,
@@ -2760,47 +2760,47 @@ static CURLcode ossl_connect_step1(struct connectdata *conn, int sockindex)
/* expects length prefixed preference ordered list of protocols in wire
* format
*/
- SSL_CTX_set_alpn_protos(backend->ctx, protocols, cur);
+ SSL_CTX_set_alpn_protos(backend->ctx, protocols, cur);
}
#endif
- if(ssl_cert || ssl_cert_blob || ssl_cert_type) {
- BIO *ssl_cert_bio = NULL;
- BIO *ssl_key_bio = NULL;
- if(ssl_cert_blob) {
- /* the typecast of blob->len is fine since it is guaranteed to never be
- larger than CURL_MAX_INPUT_LENGTH */
- ssl_cert_bio = BIO_new_mem_buf(ssl_cert_blob->data,
- (int)ssl_cert_blob->len);
- if(!ssl_cert_bio)
- result = CURLE_OUT_OF_MEMORY;
- }
- if(!result && SSL_SET_OPTION(key_blob)) {
- ssl_key_bio = BIO_new_mem_buf(SSL_SET_OPTION(key_blob)->data,
- (int)SSL_SET_OPTION(key_blob)->len);
- if(!ssl_key_bio)
- result = CURLE_OUT_OF_MEMORY;
- }
- if(!result &&
- !cert_stuff(conn, backend->ctx,
- ssl_cert, ssl_cert_bio, ssl_cert_type,
- SSL_SET_OPTION(key), ssl_key_bio,
- SSL_SET_OPTION(key_type), SSL_SET_OPTION(key_passwd)))
- result = CURLE_SSL_CERTPROBLEM;
- if(ssl_cert_bio)
- BIO_free(ssl_cert_bio);
- if(ssl_key_bio)
- BIO_free(ssl_key_bio);
- if(result)
+ if(ssl_cert || ssl_cert_blob || ssl_cert_type) {
+ BIO *ssl_cert_bio = NULL;
+ BIO *ssl_key_bio = NULL;
+ if(ssl_cert_blob) {
+ /* the typecast of blob->len is fine since it is guaranteed to never be
+ larger than CURL_MAX_INPUT_LENGTH */
+ ssl_cert_bio = BIO_new_mem_buf(ssl_cert_blob->data,
+ (int)ssl_cert_blob->len);
+ if(!ssl_cert_bio)
+ result = CURLE_OUT_OF_MEMORY;
+ }
+ if(!result && SSL_SET_OPTION(key_blob)) {
+ ssl_key_bio = BIO_new_mem_buf(SSL_SET_OPTION(key_blob)->data,
+ (int)SSL_SET_OPTION(key_blob)->len);
+ if(!ssl_key_bio)
+ result = CURLE_OUT_OF_MEMORY;
+ }
+ if(!result &&
+ !cert_stuff(conn, backend->ctx,
+ ssl_cert, ssl_cert_bio, ssl_cert_type,
+ SSL_SET_OPTION(key), ssl_key_bio,
+ SSL_SET_OPTION(key_type), SSL_SET_OPTION(key_passwd)))
+ result = CURLE_SSL_CERTPROBLEM;
+ if(ssl_cert_bio)
+ BIO_free(ssl_cert_bio);
+ if(ssl_key_bio)
+ BIO_free(ssl_key_bio);
+ if(result)
/* failf() is already done in cert_stuff() */
- return result;
+ return result;
}
ciphers = SSL_CONN_CONFIG(cipher_list);
if(!ciphers)
ciphers = (char *)DEFAULT_CIPHER_SELECTION;
if(ciphers) {
- if(!SSL_CTX_set_cipher_list(backend->ctx, ciphers)) {
+ if(!SSL_CTX_set_cipher_list(backend->ctx, ciphers)) {
failf(data, "failed setting cipher list: %s", ciphers);
return CURLE_SSL_CIPHER;
}
@@ -2811,7 +2811,7 @@ static CURLcode ossl_connect_step1(struct connectdata *conn, int sockindex)
{
char *ciphers13 = SSL_CONN_CONFIG(cipher_list13);
if(ciphers13) {
- if(!SSL_CTX_set_ciphersuites(backend->ctx, ciphers13)) {
+ if(!SSL_CTX_set_ciphersuites(backend->ctx, ciphers13)) {
failf(data, "failed setting TLS 1.3 cipher suite: %s", ciphers13);
return CURLE_SSL_CIPHER;
}
@@ -2822,39 +2822,39 @@ static CURLcode ossl_connect_step1(struct connectdata *conn, int sockindex)
#ifdef HAVE_SSL_CTX_SET_POST_HANDSHAKE_AUTH
/* OpenSSL 1.1.1 requires clients to opt-in for PHA */
- SSL_CTX_set_post_handshake_auth(backend->ctx, 1);
-#endif
-
-#ifdef HAVE_SSL_CTX_SET_EC_CURVES
- {
- char *curves = SSL_CONN_CONFIG(curves);
- if(curves) {
- if(!SSL_CTX_set1_curves_list(backend->ctx, curves)) {
- failf(data, "failed setting curves list: '%s'", curves);
- return CURLE_SSL_CIPHER;
- }
- }
- }
-#endif
-
-#ifdef USE_OPENSSL_SRP
+ SSL_CTX_set_post_handshake_auth(backend->ctx, 1);
+#endif
+
+#ifdef HAVE_SSL_CTX_SET_EC_CURVES
+ {
+ char *curves = SSL_CONN_CONFIG(curves);
+ if(curves) {
+ if(!SSL_CTX_set1_curves_list(backend->ctx, curves)) {
+ failf(data, "failed setting curves list: '%s'", curves);
+ return CURLE_SSL_CIPHER;
+ }
+ }
+ }
+#endif
+
+#ifdef USE_OPENSSL_SRP
if(ssl_authtype == CURL_TLSAUTH_SRP) {
char * const ssl_username = SSL_SET_OPTION(username);
infof(data, "Using TLS-SRP username: %s\n", ssl_username);
- if(!SSL_CTX_set_srp_username(backend->ctx, ssl_username)) {
+ if(!SSL_CTX_set_srp_username(backend->ctx, ssl_username)) {
failf(data, "Unable to set SRP user name");
return CURLE_BAD_FUNCTION_ARGUMENT;
}
- if(!SSL_CTX_set_srp_password(backend->ctx, SSL_SET_OPTION(password))) {
+ if(!SSL_CTX_set_srp_password(backend->ctx, SSL_SET_OPTION(password))) {
failf(data, "failed setting SRP password");
return CURLE_BAD_FUNCTION_ARGUMENT;
}
if(!SSL_CONN_CONFIG(cipher_list)) {
infof(data, "Setting cipher list SRP\n");
- if(!SSL_CTX_set_cipher_list(backend->ctx, "SRP")) {
+ if(!SSL_CTX_set_cipher_list(backend->ctx, "SRP")) {
failf(data, "failed setting SRP cipher list");
return CURLE_SSL_CIPHER;
}
@@ -2862,195 +2862,195 @@ static CURLcode ossl_connect_step1(struct connectdata *conn, int sockindex)
}
#endif
-
-#if defined(USE_WIN32_CRYPTO)
- /* Import certificates from the Windows root certificate store if requested.
- https://stackoverflow.com/questions/9507184/
- https://github.com/d3x0r/SACK/blob/master/src/netlib/ssl_layer.c#L1037
- https://tools.ietf.org/html/rfc5280 */
- if((SSL_CONN_CONFIG(verifypeer) || SSL_CONN_CONFIG(verifyhost)) &&
- (SSL_SET_OPTION(native_ca_store))) {
- X509_STORE *store = SSL_CTX_get_cert_store(backend->ctx);
- HCERTSTORE hStore = CertOpenSystemStore((HCRYPTPROV_LEGACY)NULL,
- TEXT("ROOT"));
-
- if(hStore) {
- PCCERT_CONTEXT pContext = NULL;
- /* The array of enhanced key usage OIDs will vary per certificate and is
- declared outside of the loop so that rather than malloc/free each
- iteration we can grow it with realloc, when necessary. */
- CERT_ENHKEY_USAGE *enhkey_usage = NULL;
- DWORD enhkey_usage_size = 0;
-
- /* This loop makes a best effort to import all valid certificates from
- the MS root store. If a certificate cannot be imported it is skipped.
- 'result' is used to store only hard-fail conditions (such as out of
- memory) that cause an early break. */
- result = CURLE_OK;
- for(;;) {
- X509 *x509;
- FILETIME now;
- BYTE key_usage[2];
- DWORD req_size;
- const unsigned char *encoded_cert;
-#if defined(DEBUGBUILD) && !defined(CURL_DISABLE_VERBOSE_STRINGS)
- char cert_name[256];
-#endif
-
- pContext = CertEnumCertificatesInStore(hStore, pContext);
- if(!pContext)
- break;
-
-#if defined(DEBUGBUILD) && !defined(CURL_DISABLE_VERBOSE_STRINGS)
- if(!CertGetNameStringA(pContext, CERT_NAME_SIMPLE_DISPLAY_TYPE, 0,
- NULL, cert_name, sizeof(cert_name))) {
- strcpy(cert_name, "Unknown");
- }
- infof(data, "SSL: Checking cert \"%s\"\n", cert_name);
-#endif
-
- encoded_cert = (const unsigned char *)pContext->pbCertEncoded;
- if(!encoded_cert)
- continue;
-
- GetSystemTimeAsFileTime(&now);
- if(CompareFileTime(&pContext->pCertInfo->NotBefore, &now) > 0 ||
- CompareFileTime(&now, &pContext->pCertInfo->NotAfter) > 0)
- continue;
-
- /* If key usage exists check for signing attribute */
- if(CertGetIntendedKeyUsage(pContext->dwCertEncodingType,
- pContext->pCertInfo,
- key_usage, sizeof(key_usage))) {
- if(!(key_usage[0] & CERT_KEY_CERT_SIGN_KEY_USAGE))
- continue;
- }
- else if(GetLastError())
- continue;
-
- /* If enhanced key usage exists check for server auth attribute.
- *
- * Note "In a Microsoft environment, a certificate might also have EKU
- * extended properties that specify valid uses for the certificate."
- * The call below checks both, and behavior varies depending on what is
- * found. For more details see CertGetEnhancedKeyUsage doc.
- */
- if(CertGetEnhancedKeyUsage(pContext, 0, NULL, &req_size)) {
- if(req_size && req_size > enhkey_usage_size) {
- void *tmp = realloc(enhkey_usage, req_size);
-
- if(!tmp) {
- failf(data, "SSL: Out of memory allocating for OID list");
- result = CURLE_OUT_OF_MEMORY;
- break;
- }
-
- enhkey_usage = (CERT_ENHKEY_USAGE *)tmp;
- enhkey_usage_size = req_size;
- }
-
- if(CertGetEnhancedKeyUsage(pContext, 0, enhkey_usage, &req_size)) {
- if(!enhkey_usage->cUsageIdentifier) {
- /* "If GetLastError returns CRYPT_E_NOT_FOUND, the certificate is
- good for all uses. If it returns zero, the certificate has no
- valid uses." */
- if((HRESULT)GetLastError() != CRYPT_E_NOT_FOUND)
- continue;
- }
- else {
- DWORD i;
- bool found = false;
-
- for(i = 0; i < enhkey_usage->cUsageIdentifier; ++i) {
- if(!strcmp("1.3.6.1.5.5.7.3.1" /* OID server auth */,
- enhkey_usage->rgpszUsageIdentifier[i])) {
- found = true;
- break;
- }
- }
-
- if(!found)
- continue;
- }
- }
- else
- continue;
- }
- else
- continue;
-
- x509 = d2i_X509(NULL, &encoded_cert, pContext->cbCertEncoded);
- if(!x509)
- continue;
-
- /* Try to import the certificate. This may fail for legitimate reasons
- such as duplicate certificate, which is allowed by MS but not
- OpenSSL. */
- if(X509_STORE_add_cert(store, x509) == 1) {
-#if defined(DEBUGBUILD) && !defined(CURL_DISABLE_VERBOSE_STRINGS)
- infof(data, "SSL: Imported cert \"%s\"\n", cert_name);
-#endif
- imported_native_ca = true;
- }
- X509_free(x509);
- }
-
- free(enhkey_usage);
- CertFreeCertificateContext(pContext);
- CertCloseStore(hStore, 0);
-
- if(result)
- return result;
- }
- if(imported_native_ca)
- infof(data, "successfully imported windows ca store\n");
- else
- infof(data, "error importing windows ca store, continuing anyway\n");
- }
-#endif
-
-#if defined(OPENSSL_VERSION_MAJOR) && (OPENSSL_VERSION_MAJOR >= 3)
- /* OpenSSL 3.0.0 has deprecated SSL_CTX_load_verify_locations */
- {
- if(ssl_cafile) {
- if(!SSL_CTX_load_verify_file(backend->ctx, ssl_cafile)) {
- if(verifypeer && !imported_native_ca) {
- /* Fail if we insist on successfully verifying the server. */
- failf(data, "error setting certificate file: %s", ssl_cafile);
- return CURLE_SSL_CACERT_BADFILE;
- }
- /* Continue with a warning if no certificate verif is required. */
- infof(data, "error setting certificate file, continuing anyway\n");
- }
- infof(data, " CAfile: %s\n", ssl_cafile);
- }
- if(ssl_capath) {
- if(!SSL_CTX_load_verify_dir(backend->ctx, ssl_capath)) {
- if(verifypeer && !imported_native_ca) {
- /* Fail if we insist on successfully verifying the server. */
- failf(data, "error setting certificate path: %s", ssl_capath);
- return CURLE_SSL_CACERT_BADFILE;
- }
- /* Continue with a warning if no certificate verif is required. */
- infof(data, "error setting certificate path, continuing anyway\n");
- }
- infof(data, " CApath: %s\n", ssl_capath);
- }
- }
-#else
+
+#if defined(USE_WIN32_CRYPTO)
+ /* Import certificates from the Windows root certificate store if requested.
+ https://stackoverflow.com/questions/9507184/
+ https://github.com/d3x0r/SACK/blob/master/src/netlib/ssl_layer.c#L1037
+ https://tools.ietf.org/html/rfc5280 */
+ if((SSL_CONN_CONFIG(verifypeer) || SSL_CONN_CONFIG(verifyhost)) &&
+ (SSL_SET_OPTION(native_ca_store))) {
+ X509_STORE *store = SSL_CTX_get_cert_store(backend->ctx);
+ HCERTSTORE hStore = CertOpenSystemStore((HCRYPTPROV_LEGACY)NULL,
+ TEXT("ROOT"));
+
+ if(hStore) {
+ PCCERT_CONTEXT pContext = NULL;
+ /* The array of enhanced key usage OIDs will vary per certificate and is
+ declared outside of the loop so that rather than malloc/free each
+ iteration we can grow it with realloc, when necessary. */
+ CERT_ENHKEY_USAGE *enhkey_usage = NULL;
+ DWORD enhkey_usage_size = 0;
+
+ /* This loop makes a best effort to import all valid certificates from
+ the MS root store. If a certificate cannot be imported it is skipped.
+ 'result' is used to store only hard-fail conditions (such as out of
+ memory) that cause an early break. */
+ result = CURLE_OK;
+ for(;;) {
+ X509 *x509;
+ FILETIME now;
+ BYTE key_usage[2];
+ DWORD req_size;
+ const unsigned char *encoded_cert;
+#if defined(DEBUGBUILD) && !defined(CURL_DISABLE_VERBOSE_STRINGS)
+ char cert_name[256];
+#endif
+
+ pContext = CertEnumCertificatesInStore(hStore, pContext);
+ if(!pContext)
+ break;
+
+#if defined(DEBUGBUILD) && !defined(CURL_DISABLE_VERBOSE_STRINGS)
+ if(!CertGetNameStringA(pContext, CERT_NAME_SIMPLE_DISPLAY_TYPE, 0,
+ NULL, cert_name, sizeof(cert_name))) {
+ strcpy(cert_name, "Unknown");
+ }
+ infof(data, "SSL: Checking cert \"%s\"\n", cert_name);
+#endif
+
+ encoded_cert = (const unsigned char *)pContext->pbCertEncoded;
+ if(!encoded_cert)
+ continue;
+
+ GetSystemTimeAsFileTime(&now);
+ if(CompareFileTime(&pContext->pCertInfo->NotBefore, &now) > 0 ||
+ CompareFileTime(&now, &pContext->pCertInfo->NotAfter) > 0)
+ continue;
+
+ /* If key usage exists check for signing attribute */
+ if(CertGetIntendedKeyUsage(pContext->dwCertEncodingType,
+ pContext->pCertInfo,
+ key_usage, sizeof(key_usage))) {
+ if(!(key_usage[0] & CERT_KEY_CERT_SIGN_KEY_USAGE))
+ continue;
+ }
+ else if(GetLastError())
+ continue;
+
+ /* If enhanced key usage exists check for server auth attribute.
+ *
+ * Note "In a Microsoft environment, a certificate might also have EKU
+ * extended properties that specify valid uses for the certificate."
+ * The call below checks both, and behavior varies depending on what is
+ * found. For more details see CertGetEnhancedKeyUsage doc.
+ */
+ if(CertGetEnhancedKeyUsage(pContext, 0, NULL, &req_size)) {
+ if(req_size && req_size > enhkey_usage_size) {
+ void *tmp = realloc(enhkey_usage, req_size);
+
+ if(!tmp) {
+ failf(data, "SSL: Out of memory allocating for OID list");
+ result = CURLE_OUT_OF_MEMORY;
+ break;
+ }
+
+ enhkey_usage = (CERT_ENHKEY_USAGE *)tmp;
+ enhkey_usage_size = req_size;
+ }
+
+ if(CertGetEnhancedKeyUsage(pContext, 0, enhkey_usage, &req_size)) {
+ if(!enhkey_usage->cUsageIdentifier) {
+ /* "If GetLastError returns CRYPT_E_NOT_FOUND, the certificate is
+ good for all uses. If it returns zero, the certificate has no
+ valid uses." */
+ if((HRESULT)GetLastError() != CRYPT_E_NOT_FOUND)
+ continue;
+ }
+ else {
+ DWORD i;
+ bool found = false;
+
+ for(i = 0; i < enhkey_usage->cUsageIdentifier; ++i) {
+ if(!strcmp("1.3.6.1.5.5.7.3.1" /* OID server auth */,
+ enhkey_usage->rgpszUsageIdentifier[i])) {
+ found = true;
+ break;
+ }
+ }
+
+ if(!found)
+ continue;
+ }
+ }
+ else
+ continue;
+ }
+ else
+ continue;
+
+ x509 = d2i_X509(NULL, &encoded_cert, pContext->cbCertEncoded);
+ if(!x509)
+ continue;
+
+ /* Try to import the certificate. This may fail for legitimate reasons
+ such as duplicate certificate, which is allowed by MS but not
+ OpenSSL. */
+ if(X509_STORE_add_cert(store, x509) == 1) {
+#if defined(DEBUGBUILD) && !defined(CURL_DISABLE_VERBOSE_STRINGS)
+ infof(data, "SSL: Imported cert \"%s\"\n", cert_name);
+#endif
+ imported_native_ca = true;
+ }
+ X509_free(x509);
+ }
+
+ free(enhkey_usage);
+ CertFreeCertificateContext(pContext);
+ CertCloseStore(hStore, 0);
+
+ if(result)
+ return result;
+ }
+ if(imported_native_ca)
+ infof(data, "successfully imported windows ca store\n");
+ else
+ infof(data, "error importing windows ca store, continuing anyway\n");
+ }
+#endif
+
+#if defined(OPENSSL_VERSION_MAJOR) && (OPENSSL_VERSION_MAJOR >= 3)
+ /* OpenSSL 3.0.0 has deprecated SSL_CTX_load_verify_locations */
+ {
+ if(ssl_cafile) {
+ if(!SSL_CTX_load_verify_file(backend->ctx, ssl_cafile)) {
+ if(verifypeer && !imported_native_ca) {
+ /* Fail if we insist on successfully verifying the server. */
+ failf(data, "error setting certificate file: %s", ssl_cafile);
+ return CURLE_SSL_CACERT_BADFILE;
+ }
+ /* Continue with a warning if no certificate verif is required. */
+ infof(data, "error setting certificate file, continuing anyway\n");
+ }
+ infof(data, " CAfile: %s\n", ssl_cafile);
+ }
+ if(ssl_capath) {
+ if(!SSL_CTX_load_verify_dir(backend->ctx, ssl_capath)) {
+ if(verifypeer && !imported_native_ca) {
+ /* Fail if we insist on successfully verifying the server. */
+ failf(data, "error setting certificate path: %s", ssl_capath);
+ return CURLE_SSL_CACERT_BADFILE;
+ }
+ /* Continue with a warning if no certificate verif is required. */
+ infof(data, "error setting certificate path, continuing anyway\n");
+ }
+ infof(data, " CApath: %s\n", ssl_capath);
+ }
+ }
+#else
if(ssl_cafile || ssl_capath) {
/* tell SSL where to find CA certificates that are used to verify
the servers certificate. */
- if(!SSL_CTX_load_verify_locations(backend->ctx, ssl_cafile, ssl_capath)) {
- if(verifypeer && !imported_native_ca) {
+ if(!SSL_CTX_load_verify_locations(backend->ctx, ssl_cafile, ssl_capath)) {
+ if(verifypeer && !imported_native_ca) {
/* Fail if we insist on successfully verifying the server. */
- failf(data, "error setting certificate verify locations:"
- " CAfile: %s CApath: %s",
+ failf(data, "error setting certificate verify locations:"
+ " CAfile: %s CApath: %s",
ssl_cafile ? ssl_cafile : "none",
ssl_capath ? ssl_capath : "none");
return CURLE_SSL_CACERT_BADFILE;
}
- /* Just continue with a warning if no strict certificate verification
+ /* Just continue with a warning if no strict certificate verification
is required. */
infof(data, "error setting certificate verify locations,"
" continuing anyway:\n");
@@ -3059,23 +3059,23 @@ static CURLcode ossl_connect_step1(struct connectdata *conn, int sockindex)
/* Everything is fine. */
infof(data, "successfully set certificate verify locations:\n");
}
- infof(data, " CAfile: %s\n", ssl_cafile ? ssl_cafile : "none");
- infof(data, " CApath: %s\n", ssl_capath ? ssl_capath : "none");
+ infof(data, " CAfile: %s\n", ssl_cafile ? ssl_cafile : "none");
+ infof(data, " CApath: %s\n", ssl_capath ? ssl_capath : "none");
}
-#endif
-
+#endif
+
#ifdef CURL_CA_FALLBACK
- if(verifypeer && !ssl_cafile && !ssl_capath && !imported_native_ca) {
+ if(verifypeer && !ssl_cafile && !ssl_capath && !imported_native_ca) {
/* verifying the peer without any CA certificates won't
work so use openssl's built in default as fallback */
- SSL_CTX_set_default_verify_paths(backend->ctx);
+ SSL_CTX_set_default_verify_paths(backend->ctx);
}
#endif
if(ssl_crlfile) {
/* tell SSL where to find CRL file that is used to check certificate
* revocation */
- lookup = X509_STORE_add_lookup(SSL_CTX_get_cert_store(backend->ctx),
+ lookup = X509_STORE_add_lookup(SSL_CTX_get_cert_store(backend->ctx),
X509_LOOKUP_file());
if(!lookup ||
(!X509_load_crl_file(lookup, ssl_crlfile, X509_FILETYPE_PEM)) ) {
@@ -3084,50 +3084,50 @@ static CURLcode ossl_connect_step1(struct connectdata *conn, int sockindex)
}
/* Everything is fine. */
infof(data, "successfully load CRL file:\n");
- X509_STORE_set_flags(SSL_CTX_get_cert_store(backend->ctx),
+ X509_STORE_set_flags(SSL_CTX_get_cert_store(backend->ctx),
X509_V_FLAG_CRL_CHECK|X509_V_FLAG_CRL_CHECK_ALL);
infof(data, " CRLfile: %s\n", ssl_crlfile);
}
if(verifypeer) {
- /* Try building a chain using issuers in the trusted store first to avoid
- problems with server-sent legacy intermediates. Newer versions of
- OpenSSL do alternate chain checking by default but we do not know how to
- determine that in a reliable manner.
- https://rt.openssl.org/Ticket/Display.html?id=3621&user=guest&pass=guest
- */
-#if defined(X509_V_FLAG_TRUSTED_FIRST)
- X509_STORE_set_flags(SSL_CTX_get_cert_store(backend->ctx),
+ /* Try building a chain using issuers in the trusted store first to avoid
+ problems with server-sent legacy intermediates. Newer versions of
+ OpenSSL do alternate chain checking by default but we do not know how to
+ determine that in a reliable manner.
+ https://rt.openssl.org/Ticket/Display.html?id=3621&user=guest&pass=guest
+ */
+#if defined(X509_V_FLAG_TRUSTED_FIRST)
+ X509_STORE_set_flags(SSL_CTX_get_cert_store(backend->ctx),
X509_V_FLAG_TRUSTED_FIRST);
#endif
-#ifdef X509_V_FLAG_PARTIAL_CHAIN
- if(!SSL_SET_OPTION(no_partialchain) && !ssl_crlfile) {
- /* Have intermediate certificates in the trust store be treated as
- trust-anchors, in the same way as self-signed root CA certificates
- are. This allows users to verify servers using the intermediate cert
- only, instead of needing the whole chain.
-
- Due to OpenSSL bug https://github.com/openssl/openssl/issues/5081 we
- cannot do partial chains with CRL check.
- */
- X509_STORE_set_flags(SSL_CTX_get_cert_store(backend->ctx),
- X509_V_FLAG_PARTIAL_CHAIN);
- }
-#endif
- }
-
+#ifdef X509_V_FLAG_PARTIAL_CHAIN
+ if(!SSL_SET_OPTION(no_partialchain) && !ssl_crlfile) {
+ /* Have intermediate certificates in the trust store be treated as
+ trust-anchors, in the same way as self-signed root CA certificates
+ are. This allows users to verify servers using the intermediate cert
+ only, instead of needing the whole chain.
+
+ Due to OpenSSL bug https://github.com/openssl/openssl/issues/5081 we
+ cannot do partial chains with CRL check.
+ */
+ X509_STORE_set_flags(SSL_CTX_get_cert_store(backend->ctx),
+ X509_V_FLAG_PARTIAL_CHAIN);
+ }
+#endif
+ }
+
/* SSL always tries to verify the peer, this only says whether it should
* fail to connect if the verification fails, or if it should continue
* anyway. In the latter case the result of the verification is checked with
* SSL_get_verify_result() below. */
- SSL_CTX_set_verify(backend->ctx,
+ SSL_CTX_set_verify(backend->ctx,
verifypeer ? SSL_VERIFY_PEER : SSL_VERIFY_NONE, NULL);
/* Enable logging of secrets to the file specified in env SSLKEYLOGFILE. */
-#ifdef HAVE_KEYLOG_CALLBACK
- if(Curl_tls_keylog_enabled()) {
- SSL_CTX_set_keylog_callback(backend->ctx, ossl_keylog_callback);
+#ifdef HAVE_KEYLOG_CALLBACK
+ if(Curl_tls_keylog_enabled()) {
+ SSL_CTX_set_keylog_callback(backend->ctx, ossl_keylog_callback);
}
#endif
@@ -3135,16 +3135,16 @@ static CURLcode ossl_connect_step1(struct connectdata *conn, int sockindex)
* callback. Use the "external storage" mode to avoid that OpenSSL creates
* an internal session cache.
*/
- SSL_CTX_set_session_cache_mode(backend->ctx,
+ SSL_CTX_set_session_cache_mode(backend->ctx,
SSL_SESS_CACHE_CLIENT | SSL_SESS_CACHE_NO_INTERNAL);
- SSL_CTX_sess_set_new_cb(backend->ctx, ossl_new_session_cb);
+ SSL_CTX_sess_set_new_cb(backend->ctx, ossl_new_session_cb);
/* give application a chance to interfere with SSL set up. */
if(data->set.ssl.fsslctx) {
- Curl_set_in_callback(data, true);
- result = (*data->set.ssl.fsslctx)(data, backend->ctx,
+ Curl_set_in_callback(data, true);
+ result = (*data->set.ssl.fsslctx)(data, backend->ctx,
data->set.ssl.fsslctxp);
- Curl_set_in_callback(data, false);
+ Curl_set_in_callback(data, false);
if(result) {
failf(data, "error signaled by ssl ctx callback");
return result;
@@ -3152,10 +3152,10 @@ static CURLcode ossl_connect_step1(struct connectdata *conn, int sockindex)
}
/* Lets make an SSL structure */
- if(backend->handle)
- SSL_free(backend->handle);
- backend->handle = SSL_new(backend->ctx);
- if(!backend->handle) {
+ if(backend->handle)
+ SSL_free(backend->handle);
+ backend->handle = SSL_new(backend->ctx);
+ if(!backend->handle) {
failf(data, "SSL: couldn't create a context (handle)!");
return CURLE_OUT_OF_MEMORY;
}
@@ -3163,23 +3163,23 @@ static CURLcode ossl_connect_step1(struct connectdata *conn, int sockindex)
#if (OPENSSL_VERSION_NUMBER >= 0x0090808fL) && !defined(OPENSSL_NO_TLSEXT) && \
!defined(OPENSSL_NO_OCSP)
if(SSL_CONN_CONFIG(verifystatus))
- SSL_set_tlsext_status_type(backend->handle, TLSEXT_STATUSTYPE_ocsp);
+ SSL_set_tlsext_status_type(backend->handle, TLSEXT_STATUSTYPE_ocsp);
#endif
#if defined(OPENSSL_IS_BORINGSSL) && defined(ALLOW_RENEG)
- SSL_set_renegotiate_mode(backend->handle, ssl_renegotiate_freely);
+ SSL_set_renegotiate_mode(backend->handle, ssl_renegotiate_freely);
#endif
- SSL_set_connect_state(backend->handle);
+ SSL_set_connect_state(backend->handle);
- backend->server_cert = 0x0;
+ backend->server_cert = 0x0;
#ifdef SSL_CTRL_SET_TLSEXT_HOSTNAME
if((0 == Curl_inet_pton(AF_INET, hostname, &addr)) &&
#ifdef ENABLE_IPV6
(0 == Curl_inet_pton(AF_INET6, hostname, &addr)) &&
#endif
sni &&
- !SSL_set_tlsext_host_name(backend->handle, hostname))
+ !SSL_set_tlsext_host_name(backend->handle, hostname))
infof(data, "WARNING: failed to configure server name indication (SNI) "
"TLS extension\n");
#endif
@@ -3193,14 +3193,14 @@ static CURLcode ossl_connect_step1(struct connectdata *conn, int sockindex)
if(connectdata_idx >= 0 && sockindex_idx >= 0) {
/* Store the data needed for the "new session" callback.
* The sockindex is stored as a pointer to an array element. */
- SSL_set_ex_data(backend->handle, connectdata_idx, conn);
- SSL_set_ex_data(backend->handle, sockindex_idx, conn->sock + sockindex);
+ SSL_set_ex_data(backend->handle, connectdata_idx, conn);
+ SSL_set_ex_data(backend->handle, sockindex_idx, conn->sock + sockindex);
}
Curl_ssl_sessionid_lock(conn);
if(!Curl_ssl_getsessionid(conn, &ssl_sessionid, NULL, sockindex)) {
/* we got a session id, use it! */
- if(!SSL_set_session(backend->handle, ssl_sessionid)) {
+ if(!SSL_set_session(backend->handle, ssl_sessionid)) {
Curl_ssl_sessionid_unlock(conn);
failf(data, "SSL: SSL_set_session failed: %s",
ossl_strerror(ERR_get_error(), error_buffer,
@@ -3213,7 +3213,7 @@ static CURLcode ossl_connect_step1(struct connectdata *conn, int sockindex)
Curl_ssl_sessionid_unlock(conn);
}
-#ifndef CURL_DISABLE_PROXY
+#ifndef CURL_DISABLE_PROXY
if(conn->proxy_ssl[sockindex].use) {
BIO *const bio = BIO_new(BIO_f_ssl());
SSL *handle = conn->proxy_ssl[sockindex].backend->handle;
@@ -3221,11 +3221,11 @@ static CURLcode ossl_connect_step1(struct connectdata *conn, int sockindex)
DEBUGASSERT(handle != NULL);
DEBUGASSERT(bio != NULL);
BIO_set_ssl(bio, handle, FALSE);
- SSL_set_bio(backend->handle, bio, bio);
+ SSL_set_bio(backend->handle, bio, bio);
}
- else
-#endif
- if(!SSL_set_fd(backend->handle, (int)sockfd)) {
+ else
+#endif
+ if(!SSL_set_fd(backend->handle, (int)sockfd)) {
/* pass the raw socket into the SSL layers */
failf(data, "SSL: SSL_set_fd failed: %s",
ossl_strerror(ERR_get_error(), error_buffer, sizeof(error_buffer)));
@@ -3242,28 +3242,28 @@ static CURLcode ossl_connect_step2(struct connectdata *conn, int sockindex)
struct Curl_easy *data = conn->data;
int err;
struct ssl_connect_data *connssl = &conn->ssl[sockindex];
- struct ssl_backend_data *backend = connssl->backend;
+ struct ssl_backend_data *backend = connssl->backend;
DEBUGASSERT(ssl_connect_2 == connssl->connecting_state
|| ssl_connect_2_reading == connssl->connecting_state
|| ssl_connect_2_writing == connssl->connecting_state);
ERR_clear_error();
- err = SSL_connect(backend->handle);
-#ifndef HAVE_KEYLOG_CALLBACK
- if(Curl_tls_keylog_enabled()) {
- /* If key logging is enabled, wait for the handshake to complete and then
- * proceed with logging secrets (for TLS 1.2 or older).
- */
- ossl_log_tls12_secret(backend->handle, &backend->keylog_done);
- }
+ err = SSL_connect(backend->handle);
+#ifndef HAVE_KEYLOG_CALLBACK
+ if(Curl_tls_keylog_enabled()) {
+ /* If key logging is enabled, wait for the handshake to complete and then
+ * proceed with logging secrets (for TLS 1.2 or older).
+ */
+ ossl_log_tls12_secret(backend->handle, &backend->keylog_done);
+ }
#endif
/* 1 is fine
0 is "not successful but was shut down controlled"
<0 is "handshake was not successful, because a fatal error occurred" */
if(1 != err) {
- int detail = SSL_get_error(backend->handle, err);
+ int detail = SSL_get_error(backend->handle, err);
if(SSL_ERROR_WANT_READ == detail) {
connssl->connecting_state = ssl_connect_2_reading;
@@ -3300,13 +3300,13 @@ static CURLcode ossl_connect_step2(struct connectdata *conn, int sockindex)
reason = ERR_GET_REASON(errdetail);
if((lib == ERR_LIB_SSL) &&
- ((reason == SSL_R_CERTIFICATE_VERIFY_FAILED) ||
- (reason == SSL_R_SSLV3_ALERT_CERTIFICATE_EXPIRED))) {
+ ((reason == SSL_R_CERTIFICATE_VERIFY_FAILED) ||
+ (reason == SSL_R_SSLV3_ALERT_CERTIFICATE_EXPIRED))) {
result = CURLE_PEER_FAILED_VERIFICATION;
- lerr = SSL_get_verify_result(backend->handle);
+ lerr = SSL_get_verify_result(backend->handle);
if(lerr != X509_V_OK) {
- SSL_SET_OPTION_LVALUE(certverifyresult) = lerr;
+ SSL_SET_OPTION_LVALUE(certverifyresult) = lerr;
msnprintf(error_buffer, sizeof(error_buffer),
"SSL certificate problem: %s",
X509_verify_cert_error_string(lerr));
@@ -3328,19 +3328,19 @@ static CURLcode ossl_connect_step2(struct connectdata *conn, int sockindex)
* the SO_ERROR is also lost.
*/
if(CURLE_SSL_CONNECT_ERROR == result && errdetail == 0) {
- const char * const hostname = SSL_HOST_NAME();
-#ifndef CURL_DISABLE_PROXY
+ const char * const hostname = SSL_HOST_NAME();
+#ifndef CURL_DISABLE_PROXY
const long int port = SSL_IS_PROXY() ? conn->port : conn->remote_port;
-#else
- const long int port = conn->remote_port;
-#endif
- char extramsg[80]="";
- int sockerr = SOCKERRNO;
- if(sockerr && detail == SSL_ERROR_SYSCALL)
- Curl_strerror(sockerr, extramsg, sizeof(extramsg));
+#else
+ const long int port = conn->remote_port;
+#endif
+ char extramsg[80]="";
+ int sockerr = SOCKERRNO;
+ if(sockerr && detail == SSL_ERROR_SYSCALL)
+ Curl_strerror(sockerr, extramsg, sizeof(extramsg));
failf(data, OSSL_PACKAGE " SSL_connect: %s in connection to %s:%ld ",
- extramsg[0] ? extramsg : SSL_ERROR_to_str(detail),
- hostname, port);
+ extramsg[0] ? extramsg : SSL_ERROR_to_str(detail),
+ hostname, port);
return result;
}
@@ -3356,8 +3356,8 @@ static CURLcode ossl_connect_step2(struct connectdata *conn, int sockindex)
/* Informational message */
infof(data, "SSL connection using %s / %s\n",
- get_ssl_version_txt(backend->handle),
- SSL_get_cipher(backend->handle));
+ get_ssl_version_txt(backend->handle),
+ SSL_get_cipher(backend->handle));
#ifdef HAS_ALPN
/* Sets data and len to negotiated protocol, len is 0 if no protocol was
@@ -3366,7 +3366,7 @@ static CURLcode ossl_connect_step2(struct connectdata *conn, int sockindex)
if(conn->bits.tls_enable_alpn) {
const unsigned char *neg_protocol;
unsigned int len;
- SSL_get0_alpn_selected(backend->handle, &neg_protocol, &len);
+ SSL_get0_alpn_selected(backend->handle, &neg_protocol, &len);
if(len != 0) {
infof(data, "ALPN, server accepted to use %.*s\n", len, neg_protocol);
@@ -3416,7 +3416,7 @@ do { \
Curl_ssl_push_certinfo_len(data, _num, _label, ptr, info_len); \
if(1 != BIO_reset(mem)) \
break; \
-} while(0)
+} while(0)
static void pubkey_show(struct Curl_easy *data,
BIO *mem,
@@ -3448,10 +3448,10 @@ do { \
if(_type->_name) { \
pubkey_show(data, mem, _num, #_type, #_name, _type->_name); \
} \
-} while(0)
+} while(0)
#endif
-static void X509V3_ext(struct Curl_easy *data,
+static void X509V3_ext(struct Curl_easy *data,
int certnum,
CONST_EXTS STACK_OF(X509_EXTENSION) *exts)
{
@@ -3459,7 +3459,7 @@ static void X509V3_ext(struct Curl_easy *data,
if((int)sk_X509_EXTENSION_num(exts) <= 0)
/* no extensions, bail out */
- return;
+ return;
for(i = 0; i < (int)sk_X509_EXTENSION_num(exts); i++) {
ASN1_OBJECT *obj;
@@ -3469,7 +3469,7 @@ static void X509V3_ext(struct Curl_easy *data,
BIO *bio_out = BIO_new(BIO_s_mem());
if(!bio_out)
- return;
+ return;
obj = X509_EXTENSION_get_object(ext);
@@ -3479,8 +3479,8 @@ static void X509V3_ext(struct Curl_easy *data,
ASN1_STRING_print(bio_out, (ASN1_STRING *)X509_EXTENSION_get_data(ext));
BIO_get_mem_ptr(bio_out, &biomem);
- Curl_ssl_push_certinfo_len(data, certnum, namebuf, biomem->data,
- biomem->length);
+ Curl_ssl_push_certinfo_len(data, certnum, namebuf, biomem->data,
+ biomem->length);
BIO_free(bio_out);
}
}
@@ -3500,9 +3500,9 @@ static CURLcode get_cert_chain(struct connectdata *conn,
struct Curl_easy *data = conn->data;
numcert_t numcerts;
BIO *mem;
- struct ssl_backend_data *backend = connssl->backend;
+ struct ssl_backend_data *backend = connssl->backend;
- sk = SSL_get_peer_cert_chain(backend->handle);
+ sk = SSL_get_peer_cert_chain(backend->handle);
if(!sk) {
return CURLE_OUT_OF_MEMORY;
}
@@ -3786,14 +3786,14 @@ static CURLcode servercert(struct connectdata *conn,
char buffer[2048];
const char *ptr;
BIO *mem = BIO_new(BIO_s_mem());
- struct ssl_backend_data *backend = connssl->backend;
+ struct ssl_backend_data *backend = connssl->backend;
if(data->set.ssl.certinfo)
/* we've been asked to gather certificate info! */
(void)get_cert_chain(conn, connssl);
- backend->server_cert = SSL_get_peer_certificate(backend->handle);
- if(!backend->server_cert) {
+ backend->server_cert = SSL_get_peer_certificate(backend->handle);
+ if(!backend->server_cert) {
BIO_free(mem);
if(!strict)
return CURLE_OK;
@@ -3804,19 +3804,19 @@ static CURLcode servercert(struct connectdata *conn,
infof(data, "%s certificate:\n", SSL_IS_PROXY() ? "Proxy" : "Server");
- rc = x509_name_oneline(X509_get_subject_name(backend->server_cert),
+ rc = x509_name_oneline(X509_get_subject_name(backend->server_cert),
buffer, sizeof(buffer));
infof(data, " subject: %s\n", rc?"[NONE]":buffer);
#ifndef CURL_DISABLE_VERBOSE_STRINGS
{
long len;
- ASN1_TIME_print(mem, X509_get0_notBefore(backend->server_cert));
+ ASN1_TIME_print(mem, X509_get0_notBefore(backend->server_cert));
len = BIO_get_mem_data(mem, (char **) &ptr);
infof(data, " start date: %.*s\n", len, ptr);
(void)BIO_reset(mem);
- ASN1_TIME_print(mem, X509_get0_notAfter(backend->server_cert));
+ ASN1_TIME_print(mem, X509_get0_notAfter(backend->server_cert));
len = BIO_get_mem_data(mem, (char **) &ptr);
infof(data, " expire date: %.*s\n", len, ptr);
(void)BIO_reset(mem);
@@ -3826,15 +3826,15 @@ static CURLcode servercert(struct connectdata *conn,
BIO_free(mem);
if(SSL_CONN_CONFIG(verifyhost)) {
- result = verifyhost(conn, backend->server_cert);
+ result = verifyhost(conn, backend->server_cert);
if(result) {
- X509_free(backend->server_cert);
- backend->server_cert = NULL;
+ X509_free(backend->server_cert);
+ backend->server_cert = NULL;
return result;
}
}
- rc = x509_name_oneline(X509_get_issuer_name(backend->server_cert),
+ rc = x509_name_oneline(X509_get_issuer_name(backend->server_cert),
buffer, sizeof(buffer));
if(rc) {
if(strict)
@@ -3848,32 +3848,32 @@ static CURLcode servercert(struct connectdata *conn,
deallocating the certificate. */
/* e.g. match issuer name with provided issuer certificate */
- if(SSL_SET_OPTION(issuercert) || SSL_SET_OPTION(issuercert_blob)) {
- if(SSL_SET_OPTION(issuercert_blob))
- fp = BIO_new_mem_buf(SSL_SET_OPTION(issuercert_blob)->data,
- (int)SSL_SET_OPTION(issuercert_blob)->len);
- else {
- fp = BIO_new(BIO_s_file());
- if(fp == NULL) {
- failf(data,
- "BIO_new return NULL, " OSSL_PACKAGE
- " error %s",
- ossl_strerror(ERR_get_error(), error_buffer,
- sizeof(error_buffer)) );
- X509_free(backend->server_cert);
- backend->server_cert = NULL;
- return CURLE_OUT_OF_MEMORY;
- }
-
- if(BIO_read_filename(fp, SSL_SET_OPTION(issuercert)) <= 0) {
- if(strict)
- failf(data, "SSL: Unable to open issuer cert (%s)",
- SSL_SET_OPTION(issuercert));
- BIO_free(fp);
- X509_free(backend->server_cert);
- backend->server_cert = NULL;
- return CURLE_SSL_ISSUER_ERROR;
- }
+ if(SSL_SET_OPTION(issuercert) || SSL_SET_OPTION(issuercert_blob)) {
+ if(SSL_SET_OPTION(issuercert_blob))
+ fp = BIO_new_mem_buf(SSL_SET_OPTION(issuercert_blob)->data,
+ (int)SSL_SET_OPTION(issuercert_blob)->len);
+ else {
+ fp = BIO_new(BIO_s_file());
+ if(fp == NULL) {
+ failf(data,
+ "BIO_new return NULL, " OSSL_PACKAGE
+ " error %s",
+ ossl_strerror(ERR_get_error(), error_buffer,
+ sizeof(error_buffer)) );
+ X509_free(backend->server_cert);
+ backend->server_cert = NULL;
+ return CURLE_OUT_OF_MEMORY;
+ }
+
+ if(BIO_read_filename(fp, SSL_SET_OPTION(issuercert)) <= 0) {
+ if(strict)
+ failf(data, "SSL: Unable to open issuer cert (%s)",
+ SSL_SET_OPTION(issuercert));
+ BIO_free(fp);
+ X509_free(backend->server_cert);
+ backend->server_cert = NULL;
+ return CURLE_SSL_ISSUER_ERROR;
+ }
}
issuer = PEM_read_bio_X509(fp, NULL, ZERO_NULL, NULL);
@@ -3883,19 +3883,19 @@ static CURLcode servercert(struct connectdata *conn,
SSL_SET_OPTION(issuercert));
BIO_free(fp);
X509_free(issuer);
- X509_free(backend->server_cert);
- backend->server_cert = NULL;
+ X509_free(backend->server_cert);
+ backend->server_cert = NULL;
return CURLE_SSL_ISSUER_ERROR;
}
- if(X509_check_issued(issuer, backend->server_cert) != X509_V_OK) {
+ if(X509_check_issued(issuer, backend->server_cert) != X509_V_OK) {
if(strict)
failf(data, "SSL: Certificate issuer check failed (%s)",
SSL_SET_OPTION(issuercert));
BIO_free(fp);
X509_free(issuer);
- X509_free(backend->server_cert);
- backend->server_cert = NULL;
+ X509_free(backend->server_cert);
+ backend->server_cert = NULL;
return CURLE_SSL_ISSUER_ERROR;
}
@@ -3905,9 +3905,9 @@ static CURLcode servercert(struct connectdata *conn,
X509_free(issuer);
}
- lerr = SSL_get_verify_result(backend->handle);
- SSL_SET_OPTION_LVALUE(certverifyresult) = lerr;
- if(lerr != X509_V_OK) {
+ lerr = SSL_get_verify_result(backend->handle);
+ SSL_SET_OPTION_LVALUE(certverifyresult) = lerr;
+ if(lerr != X509_V_OK) {
if(SSL_CONN_CONFIG(verifypeer)) {
/* We probably never reach this, because SSL_connect() will fail
and we return earlier if verifypeer is set? */
@@ -3930,8 +3930,8 @@ static CURLcode servercert(struct connectdata *conn,
if(SSL_CONN_CONFIG(verifystatus)) {
result = verifystatus(conn, connssl);
if(result) {
- X509_free(backend->server_cert);
- backend->server_cert = NULL;
+ X509_free(backend->server_cert);
+ backend->server_cert = NULL;
return result;
}
}
@@ -3944,13 +3944,13 @@ static CURLcode servercert(struct connectdata *conn,
ptr = SSL_IS_PROXY() ? data->set.str[STRING_SSL_PINNEDPUBLICKEY_PROXY] :
data->set.str[STRING_SSL_PINNEDPUBLICKEY_ORIG];
if(!result && ptr) {
- result = pkp_pin_peer_pubkey(data, backend->server_cert, ptr);
+ result = pkp_pin_peer_pubkey(data, backend->server_cert, ptr);
if(result)
failf(data, "SSL: public key does not match pinned public key!");
}
- X509_free(backend->server_cert);
- backend->server_cert = NULL;
+ X509_free(backend->server_cert);
+ backend->server_cert = NULL;
connssl->connecting_state = ssl_connect_done;
return result;
@@ -4001,7 +4001,7 @@ static CURLcode ossl_connect_common(struct connectdata *conn,
if(ssl_connect_1 == connssl->connecting_state) {
/* Find out how much more time we're allowed */
- const timediff_t timeout_ms = Curl_timeleft(data, NULL, TRUE);
+ const timediff_t timeout_ms = Curl_timeleft(data, NULL, TRUE);
if(timeout_ms < 0) {
/* no need to continue if time already is up */
@@ -4019,7 +4019,7 @@ static CURLcode ossl_connect_common(struct connectdata *conn,
ssl_connect_2_writing == connssl->connecting_state) {
/* check allowed time left */
- const timediff_t timeout_ms = Curl_timeleft(data, NULL, TRUE);
+ const timediff_t timeout_ms = Curl_timeleft(data, NULL, TRUE);
if(timeout_ms < 0) {
/* no need to continue if time already is up */
@@ -4118,13 +4118,13 @@ static bool Curl_ossl_data_pending(const struct connectdata *conn,
const struct ssl_connect_data *connssl = &conn->ssl[connindex];
if(connssl->backend->handle && SSL_pending(connssl->backend->handle))
return TRUE;
-#ifndef CURL_DISABLE_PROXY
- {
- const struct ssl_connect_data *proxyssl = &conn->proxy_ssl[connindex];
- if(proxyssl->backend->handle && SSL_pending(proxyssl->backend->handle))
- return TRUE;
- }
-#endif
+#ifndef CURL_DISABLE_PROXY
+ {
+ const struct ssl_connect_data *proxyssl = &conn->proxy_ssl[connindex];
+ if(proxyssl->backend->handle && SSL_pending(proxyssl->backend->handle))
+ return TRUE;
+ }
+#endif
return FALSE;
}
@@ -4144,15 +4144,15 @@ static ssize_t ossl_send(struct connectdata *conn,
int memlen;
int rc;
struct ssl_connect_data *connssl = &conn->ssl[sockindex];
- struct ssl_backend_data *backend = connssl->backend;
+ struct ssl_backend_data *backend = connssl->backend;
ERR_clear_error();
memlen = (len > (size_t)INT_MAX) ? INT_MAX : (int)len;
- rc = SSL_write(backend->handle, mem, memlen);
+ rc = SSL_write(backend->handle, mem, memlen);
if(rc <= 0) {
- err = SSL_get_error(backend->handle, rc);
+ err = SSL_get_error(backend->handle, rc);
switch(err) {
case SSL_ERROR_WANT_READ:
@@ -4163,33 +4163,33 @@ static ssize_t ossl_send(struct connectdata *conn,
*curlcode = CURLE_AGAIN;
return -1;
case SSL_ERROR_SYSCALL:
- {
- int sockerr = SOCKERRNO;
- sslerror = ERR_get_error();
- if(sslerror)
- ossl_strerror(sslerror, error_buffer, sizeof(error_buffer));
- else if(sockerr)
- Curl_strerror(sockerr, error_buffer, sizeof(error_buffer));
- else {
- strncpy(error_buffer, SSL_ERROR_to_str(err), sizeof(error_buffer));
- error_buffer[sizeof(error_buffer) - 1] = '\0';
- }
- failf(conn->data, OSSL_PACKAGE " SSL_write: %s, errno %d",
- error_buffer, sockerr);
- *curlcode = CURLE_SEND_ERROR;
- return -1;
- }
+ {
+ int sockerr = SOCKERRNO;
+ sslerror = ERR_get_error();
+ if(sslerror)
+ ossl_strerror(sslerror, error_buffer, sizeof(error_buffer));
+ else if(sockerr)
+ Curl_strerror(sockerr, error_buffer, sizeof(error_buffer));
+ else {
+ strncpy(error_buffer, SSL_ERROR_to_str(err), sizeof(error_buffer));
+ error_buffer[sizeof(error_buffer) - 1] = '\0';
+ }
+ failf(conn->data, OSSL_PACKAGE " SSL_write: %s, errno %d",
+ error_buffer, sockerr);
+ *curlcode = CURLE_SEND_ERROR;
+ return -1;
+ }
case SSL_ERROR_SSL:
/* A failure in the SSL library occurred, usually a protocol error.
The OpenSSL error queue contains more information on the error. */
sslerror = ERR_get_error();
if(ERR_GET_LIB(sslerror) == ERR_LIB_SSL &&
ERR_GET_REASON(sslerror) == SSL_R_BIO_NOT_SET &&
- conn->ssl[sockindex].state == ssl_connection_complete
-#ifndef CURL_DISABLE_PROXY
- && conn->proxy_ssl[sockindex].state == ssl_connection_complete
-#endif
- ) {
+ conn->ssl[sockindex].state == ssl_connection_complete
+#ifndef CURL_DISABLE_PROXY
+ && conn->proxy_ssl[sockindex].state == ssl_connection_complete
+#endif
+ ) {
char ver[120];
Curl_ossl_version(ver, 120);
failf(conn->data, "Error: %s does not support double SSL tunneling.",
@@ -4222,25 +4222,25 @@ static ssize_t ossl_recv(struct connectdata *conn, /* connection data */
ssize_t nread;
int buffsize;
struct ssl_connect_data *connssl = &conn->ssl[num];
- struct ssl_backend_data *backend = connssl->backend;
+ struct ssl_backend_data *backend = connssl->backend;
ERR_clear_error();
buffsize = (buffersize > (size_t)INT_MAX) ? INT_MAX : (int)buffersize;
- nread = (ssize_t)SSL_read(backend->handle, buf, buffsize);
+ nread = (ssize_t)SSL_read(backend->handle, buf, buffsize);
if(nread <= 0) {
/* failed SSL_read */
- int err = SSL_get_error(backend->handle, (int)nread);
+ int err = SSL_get_error(backend->handle, (int)nread);
switch(err) {
case SSL_ERROR_NONE: /* this is not an error */
break;
case SSL_ERROR_ZERO_RETURN: /* no more data */
/* close_notify alert */
- if(num == FIRSTSOCKET)
- /* mark the connection for close if it is indeed the control
- connection */
- connclose(conn, "TLS close_notify");
+ if(num == FIRSTSOCKET)
+ /* mark the connection for close if it is indeed the control
+ connection */
+ connclose(conn, "TLS close_notify");
break;
case SSL_ERROR_WANT_READ:
case SSL_ERROR_WANT_WRITE:
@@ -4255,44 +4255,44 @@ static ssize_t ossl_recv(struct connectdata *conn, /* connection data */
if((nread < 0) || sslerror) {
/* If the return code was negative or there actually is an error in the
queue */
- int sockerr = SOCKERRNO;
- if(sslerror)
- ossl_strerror(sslerror, error_buffer, sizeof(error_buffer));
- else if(sockerr && err == SSL_ERROR_SYSCALL)
- Curl_strerror(sockerr, error_buffer, sizeof(error_buffer));
- else {
- strncpy(error_buffer, SSL_ERROR_to_str(err), sizeof(error_buffer));
- error_buffer[sizeof(error_buffer) - 1] = '\0';
- }
+ int sockerr = SOCKERRNO;
+ if(sslerror)
+ ossl_strerror(sslerror, error_buffer, sizeof(error_buffer));
+ else if(sockerr && err == SSL_ERROR_SYSCALL)
+ Curl_strerror(sockerr, error_buffer, sizeof(error_buffer));
+ else {
+ strncpy(error_buffer, SSL_ERROR_to_str(err), sizeof(error_buffer));
+ error_buffer[sizeof(error_buffer) - 1] = '\0';
+ }
failf(conn->data, OSSL_PACKAGE " SSL_read: %s, errno %d",
- error_buffer, sockerr);
+ error_buffer, sockerr);
*curlcode = CURLE_RECV_ERROR;
return -1;
}
- /* For debug builds be a little stricter and error on any
- SSL_ERROR_SYSCALL. For example a server may have closed the connection
- abruptly without a close_notify alert. For compatibility with older
- peers we don't do this by default. #4624
-
- We can use this to gauge how many users may be affected, and
- if it goes ok eventually transition to allow in dev and release with
- the newest OpenSSL: #if (OPENSSL_VERSION_NUMBER >= 0x10101000L) */
-#ifdef DEBUGBUILD
- if(err == SSL_ERROR_SYSCALL) {
- int sockerr = SOCKERRNO;
- if(sockerr)
- Curl_strerror(sockerr, error_buffer, sizeof(error_buffer));
- else {
- msnprintf(error_buffer, sizeof(error_buffer),
- "Connection closed abruptly");
- }
- failf(conn->data, OSSL_PACKAGE " SSL_read: %s, errno %d"
- " (Fatal because this is a curl debug build)",
- error_buffer, sockerr);
- *curlcode = CURLE_RECV_ERROR;
- return -1;
- }
-#endif
+ /* For debug builds be a little stricter and error on any
+ SSL_ERROR_SYSCALL. For example a server may have closed the connection
+ abruptly without a close_notify alert. For compatibility with older
+ peers we don't do this by default. #4624
+
+ We can use this to gauge how many users may be affected, and
+ if it goes ok eventually transition to allow in dev and release with
+ the newest OpenSSL: #if (OPENSSL_VERSION_NUMBER >= 0x10101000L) */
+#ifdef DEBUGBUILD
+ if(err == SSL_ERROR_SYSCALL) {
+ int sockerr = SOCKERRNO;
+ if(sockerr)
+ Curl_strerror(sockerr, error_buffer, sizeof(error_buffer));
+ else {
+ msnprintf(error_buffer, sizeof(error_buffer),
+ "Connection closed abruptly");
+ }
+ failf(conn->data, OSSL_PACKAGE " SSL_read: %s, errno %d"
+ " (Fatal because this is a curl debug build)",
+ error_buffer, sockerr);
+ *curlcode = CURLE_RECV_ERROR;
+ return -1;
+ }
+#endif
}
}
return nread;
@@ -4300,35 +4300,35 @@ static ssize_t ossl_recv(struct connectdata *conn, /* connection data */
static size_t Curl_ossl_version(char *buffer, size_t size)
{
-#ifdef LIBRESSL_VERSION_NUMBER
-#if LIBRESSL_VERSION_NUMBER < 0x2070100fL
- return msnprintf(buffer, size, "%s/%lx.%lx.%lx",
- OSSL_PACKAGE,
- (LIBRESSL_VERSION_NUMBER>>28)&0xf,
- (LIBRESSL_VERSION_NUMBER>>20)&0xff,
- (LIBRESSL_VERSION_NUMBER>>12)&0xff);
-#else /* OpenSSL_version() first appeared in LibreSSL 2.7.1 */
- char *p;
- int count;
- const char *ver = OpenSSL_version(OPENSSL_VERSION);
- const char expected[] = OSSL_PACKAGE " "; /* ie "LibreSSL " */
- if(Curl_strncasecompare(ver, expected, sizeof(expected) - 1)) {
- ver += sizeof(expected) - 1;
- }
- count = msnprintf(buffer, size, "%s/%s", OSSL_PACKAGE, ver);
- for(p = buffer; *p; ++p) {
- if(ISSPACE(*p))
- *p = '_';
- }
- return count;
-#endif
-#elif defined(OPENSSL_IS_BORINGSSL)
+#ifdef LIBRESSL_VERSION_NUMBER
+#if LIBRESSL_VERSION_NUMBER < 0x2070100fL
+ return msnprintf(buffer, size, "%s/%lx.%lx.%lx",
+ OSSL_PACKAGE,
+ (LIBRESSL_VERSION_NUMBER>>28)&0xf,
+ (LIBRESSL_VERSION_NUMBER>>20)&0xff,
+ (LIBRESSL_VERSION_NUMBER>>12)&0xff);
+#else /* OpenSSL_version() first appeared in LibreSSL 2.7.1 */
+ char *p;
+ int count;
+ const char *ver = OpenSSL_version(OPENSSL_VERSION);
+ const char expected[] = OSSL_PACKAGE " "; /* ie "LibreSSL " */
+ if(Curl_strncasecompare(ver, expected, sizeof(expected) - 1)) {
+ ver += sizeof(expected) - 1;
+ }
+ count = msnprintf(buffer, size, "%s/%s", OSSL_PACKAGE, ver);
+ for(p = buffer; *p; ++p) {
+ if(ISSPACE(*p))
+ *p = '_';
+ }
+ return count;
+#endif
+#elif defined(OPENSSL_IS_BORINGSSL)
return msnprintf(buffer, size, OSSL_PACKAGE);
#elif defined(HAVE_OPENSSL_VERSION) && defined(OPENSSL_VERSION_STRING)
return msnprintf(buffer, size, "%s/%s",
OSSL_PACKAGE, OpenSSL_version(OPENSSL_VERSION_STRING));
#else
- /* not LibreSSL, BoringSSL and not using OpenSSL_version */
+ /* not LibreSSL, BoringSSL and not using OpenSSL_version */
char sub[3];
unsigned long ssleay_value;
@@ -4396,9 +4396,9 @@ static CURLcode Curl_ossl_md5sum(unsigned char *tmp, /* input */
(void) unused;
mdctx = EVP_MD_CTX_create();
- if(!mdctx)
- return CURLE_OUT_OF_MEMORY;
- EVP_DigestInit(mdctx, EVP_md5());
+ if(!mdctx)
+ return CURLE_OUT_OF_MEMORY;
+ EVP_DigestInit(mdctx, EVP_md5());
EVP_DigestUpdate(mdctx, tmp, tmplen);
EVP_DigestFinal_ex(mdctx, md5sum, &len);
EVP_MD_CTX_destroy(mdctx);
@@ -4415,10 +4415,10 @@ static CURLcode Curl_ossl_sha256sum(const unsigned char *tmp, /* input */
unsigned int len = 0;
(void) unused;
- mdctx = EVP_MD_CTX_create();
- if(!mdctx)
- return CURLE_OUT_OF_MEMORY;
- EVP_DigestInit(mdctx, EVP_sha256());
+ mdctx = EVP_MD_CTX_create();
+ if(!mdctx)
+ return CURLE_OUT_OF_MEMORY;
+ EVP_DigestInit(mdctx, EVP_sha256());
EVP_DigestUpdate(mdctx, tmp, tmplen);
EVP_DigestFinal_ex(mdctx, sha256sum, &len);
EVP_MD_CTX_destroy(mdctx);
@@ -4440,9 +4440,9 @@ static void *Curl_ossl_get_internals(struct ssl_connect_data *connssl,
CURLINFO info)
{
/* Legacy: CURLINFO_TLS_SESSION must return an SSL_CTX pointer. */
- struct ssl_backend_data *backend = connssl->backend;
+ struct ssl_backend_data *backend = connssl->backend;
return info == CURLINFO_TLS_SESSION ?
- (void *)backend->ctx : (void *)backend->handle;
+ (void *)backend->ctx : (void *)backend->handle;
}
const struct Curl_ssl Curl_ssl_openssl = {
diff --git a/contrib/libs/curl/lib/vtls/openssl.h b/contrib/libs/curl/lib/vtls/openssl.h
index 1a1b638c62..2f6e1b2db8 100644
--- a/contrib/libs/curl/lib/vtls/openssl.h
+++ b/contrib/libs/curl/lib/vtls/openssl.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/vtls/schannel.c b/contrib/libs/curl/lib/vtls/schannel.c
index 2bc1d7f839..d7bc38917f 100644
--- a/contrib/libs/curl/lib/vtls/schannel.c
+++ b/contrib/libs/curl/lib/vtls/schannel.c
@@ -7,11 +7,11 @@
*
* Copyright (C) 2012 - 2016, Marc Hoersken, <info@marc-hoersken.de>
* Copyright (C) 2012, Mark Salisbury, <mark.salisbury@hp.com>
- * Copyright (C) 2012 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2012 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -39,20 +39,20 @@
#include "schannel.h"
#include "vtls.h"
-#include "strcase.h"
+#include "strcase.h"
#include "sendf.h"
#include "connect.h" /* for the connect timeout */
#include "strerror.h"
-#include "select.h" /* for the socket readiness */
+#include "select.h" /* for the socket readiness */
#include "inet_pton.h" /* for IP addr SNI check */
#include "curl_multibyte.h"
#include "warnless.h"
#include "x509asn1.h"
#include "curl_printf.h"
#include "multiif.h"
-#include "version_win32.h"
+#include "version_win32.h"
-/* The last #include file should be: */
+/* The last #include file should be: */
#include "curl_memory.h"
#include "memdebug.h"
@@ -170,25 +170,25 @@ set_ssl_version_min_max(SCHANNEL_CRED *schannel_cred, struct connectdata *conn)
long i = ssl_version;
switch(ssl_version_max) {
- case CURL_SSLVERSION_MAX_NONE:
- case CURL_SSLVERSION_MAX_DEFAULT:
- ssl_version_max = CURL_SSLVERSION_MAX_TLSv1_2;
- break;
+ case CURL_SSLVERSION_MAX_NONE:
+ case CURL_SSLVERSION_MAX_DEFAULT:
+ ssl_version_max = CURL_SSLVERSION_MAX_TLSv1_2;
+ break;
}
for(; i <= (ssl_version_max >> 16); ++i) {
switch(i) {
- case CURL_SSLVERSION_TLSv1_0:
- schannel_cred->grbitEnabledProtocols |= SP_PROT_TLS1_0_CLIENT;
- break;
- case CURL_SSLVERSION_TLSv1_1:
- schannel_cred->grbitEnabledProtocols |= SP_PROT_TLS1_1_CLIENT;
- break;
- case CURL_SSLVERSION_TLSv1_2:
- schannel_cred->grbitEnabledProtocols |= SP_PROT_TLS1_2_CLIENT;
- break;
- case CURL_SSLVERSION_TLSv1_3:
- failf(data, "schannel: TLS 1.3 is not yet supported");
- return CURLE_SSL_CONNECT_ERROR;
+ case CURL_SSLVERSION_TLSv1_0:
+ schannel_cred->grbitEnabledProtocols |= SP_PROT_TLS1_0_CLIENT;
+ break;
+ case CURL_SSLVERSION_TLSv1_1:
+ schannel_cred->grbitEnabledProtocols |= SP_PROT_TLS1_1_CLIENT;
+ break;
+ case CURL_SSLVERSION_TLSv1_2:
+ schannel_cred->grbitEnabledProtocols |= SP_PROT_TLS1_2_CLIENT;
+ break;
+ case CURL_SSLVERSION_TLSv1_3:
+ failf(data, "schannel: TLS 1.3 is not yet supported");
+ return CURLE_SSL_CONNECT_ERROR;
}
}
return CURLE_OK;
@@ -196,9 +196,9 @@ set_ssl_version_min_max(SCHANNEL_CRED *schannel_cred, struct connectdata *conn)
/*longest is 26, buffer is slightly bigger*/
#define LONGEST_ALG_ID 32
-#define CIPHEROPTION(X) \
- if(strcmp(#X, tmp) == 0) \
- return X
+#define CIPHEROPTION(X) \
+ if(strcmp(#X, tmp) == 0) \
+ return X
static int
get_alg_id_by_name(char *name)
@@ -274,11 +274,11 @@ get_alg_id_by_name(char *name)
#ifdef CALG_HMAC
CIPHEROPTION(CALG_HMAC);
#endif
-#if !defined(__W32API_MAJOR_VERSION) || \
- !defined(__W32API_MINOR_VERSION) || \
- defined(__MINGW64_VERSION_MAJOR) || \
- (__W32API_MAJOR_VERSION > 5) || \
- ((__W32API_MAJOR_VERSION == 5) && (__W32API_MINOR_VERSION > 0))
+#if !defined(__W32API_MAJOR_VERSION) || \
+ !defined(__W32API_MINOR_VERSION) || \
+ defined(__MINGW64_VERSION_MAJOR) || \
+ (__W32API_MAJOR_VERSION > 5) || \
+ ((__W32API_MAJOR_VERSION == 5) && (__W32API_MINOR_VERSION > 0))
/* CALG_TLS1PRF has a syntax error in MinGW's w32api up to version 5.0,
see https://osdn.net/projects/mingw/ticket/38391 */
CIPHEROPTION(CALG_TLS1PRF);
@@ -340,14 +340,14 @@ set_ssl_ciphers(SCHANNEL_CRED *schannel_cred, char *ciphers)
if(startCur)
startCur++;
}
- schannel_cred->palgSupportedAlgs = algIds;
+ schannel_cred->palgSupportedAlgs = algIds;
schannel_cred->cSupportedAlgs = algCount;
return CURLE_OK;
}
#ifdef HAS_CLIENT_CERT_PATH
-
-/* Function allocates memory for store_path only if CURLE_OK is returned */
+
+/* Function allocates memory for store_path only if CURLE_OK is returned */
static CURLcode
get_cert_location(TCHAR *path, DWORD *store_name, TCHAR **store_path,
TCHAR **thumbprint)
@@ -390,10 +390,10 @@ get_cert_location(TCHAR *path, DWORD *store_name, TCHAR **store_path,
if(sep == NULL)
return CURLE_SSL_CERTPROBLEM;
- *thumbprint = sep + 1;
- if(_tcslen(*thumbprint) != CERT_THUMBPRINT_STR_LEN)
- return CURLE_SSL_CERTPROBLEM;
-
+ *thumbprint = sep + 1;
+ if(_tcslen(*thumbprint) != CERT_THUMBPRINT_STR_LEN)
+ return CURLE_SSL_CERTPROBLEM;
+
*sep = TEXT('\0');
*store_path = _tcsdup(store_path_start);
*sep = TEXT('\\');
@@ -420,40 +420,40 @@ schannel_connect_step1(struct connectdata *conn, int sockindex)
SCHANNEL_CRED schannel_cred;
PCCERT_CONTEXT client_certs[1] = { NULL };
SECURITY_STATUS sspi_status = SEC_E_OK;
- struct Curl_schannel_cred *old_cred = NULL;
+ struct Curl_schannel_cred *old_cred = NULL;
struct in_addr addr;
#ifdef ENABLE_IPV6
struct in6_addr addr6;
#endif
TCHAR *host_name;
CURLcode result;
-#ifndef CURL_DISABLE_PROXY
+#ifndef CURL_DISABLE_PROXY
char * const hostname = SSL_IS_PROXY() ? conn->http_proxy.host.name :
conn->host.name;
-#else
- char * const hostname = conn->host.name;
-#endif
+#else
+ char * const hostname = conn->host.name;
+#endif
DEBUGF(infof(data,
"schannel: SSL/TLS connection with %s port %hu (step 1/3)\n",
hostname, conn->remote_port));
- if(curlx_verify_windows_version(5, 1, PLATFORM_WINNT,
- VERSION_LESS_THAN_EQUAL)) {
- /* Schannel in Windows XP (OS version 5.1) uses legacy handshakes and
- algorithms that may not be supported by all servers. */
- infof(data, "schannel: Windows version is old and may not be able to "
- "connect to some servers due to lack of SNI, algorithms, etc.\n");
+ if(curlx_verify_windows_version(5, 1, PLATFORM_WINNT,
+ VERSION_LESS_THAN_EQUAL)) {
+ /* Schannel in Windows XP (OS version 5.1) uses legacy handshakes and
+ algorithms that may not be supported by all servers. */
+ infof(data, "schannel: Windows version is old and may not be able to "
+ "connect to some servers due to lack of SNI, algorithms, etc.\n");
}
#ifdef HAS_ALPN
/* ALPN is only supported on Windows 8.1 / Server 2012 R2 and above.
Also it doesn't seem to be supported for Wine, see curl bug #983. */
BACKEND->use_alpn = conn->bits.tls_enable_alpn &&
- !GetProcAddress(GetModuleHandle(TEXT("ntdll")),
- "wine_get_version") &&
- curlx_verify_windows_version(6, 3, PLATFORM_WINNT,
- VERSION_GREATER_THAN_EQUAL);
+ !GetProcAddress(GetModuleHandle(TEXT("ntdll")),
+ "wine_get_version") &&
+ curlx_verify_windows_version(6, 3, PLATFORM_WINNT,
+ VERSION_GREATER_THAN_EQUAL);
#else
BACKEND->use_alpn = false;
#endif
@@ -469,8 +469,8 @@ schannel_connect_step1(struct connectdata *conn, int sockindex)
#else
#ifdef HAS_MANUAL_VERIFY_API
if(SSL_CONN_CONFIG(CAfile)) {
- if(curlx_verify_windows_version(6, 1, PLATFORM_WINNT,
- VERSION_GREATER_THAN_EQUAL)) {
+ if(curlx_verify_windows_version(6, 1, PLATFORM_WINNT,
+ VERSION_GREATER_THAN_EQUAL)) {
BACKEND->use_manual_cred_validation = true;
}
else {
@@ -527,15 +527,15 @@ schannel_connect_step1(struct connectdata *conn, int sockindex)
DEBUGF(infof(data, "schannel: disabled server certificate revocation "
"checks\n"));
}
- else if(data->set.ssl.revoke_best_effort) {
- schannel_cred.dwFlags |= SCH_CRED_IGNORE_NO_REVOCATION_CHECK |
- SCH_CRED_IGNORE_REVOCATION_OFFLINE | SCH_CRED_REVOCATION_CHECK_CHAIN;
-
- DEBUGF(infof(data, "schannel: ignore revocation offline errors"));
- }
+ else if(data->set.ssl.revoke_best_effort) {
+ schannel_cred.dwFlags |= SCH_CRED_IGNORE_NO_REVOCATION_CHECK |
+ SCH_CRED_IGNORE_REVOCATION_OFFLINE | SCH_CRED_REVOCATION_CHECK_CHAIN;
+
+ DEBUGF(infof(data, "schannel: ignore revocation offline errors"));
+ }
else {
schannel_cred.dwFlags |= SCH_CRED_REVOCATION_CHECK_CHAIN;
-
+
DEBUGF(infof(data,
"schannel: checking server certificate revocation\n"));
}
@@ -562,12 +562,12 @@ schannel_connect_step1(struct connectdata *conn, int sockindex)
case CURL_SSLVERSION_TLSv1_1:
case CURL_SSLVERSION_TLSv1_2:
case CURL_SSLVERSION_TLSv1_3:
- {
- result = set_ssl_version_min_max(&schannel_cred, conn);
- if(result != CURLE_OK)
- return result;
- break;
- }
+ {
+ result = set_ssl_version_min_max(&schannel_cred, conn);
+ if(result != CURLE_OK)
+ return result;
+ break;
+ }
case CURL_SSLVERSION_SSLv3:
schannel_cred.grbitEnabledProtocols = SP_PROT_SSL3_CLIENT;
break;
@@ -590,199 +590,199 @@ schannel_connect_step1(struct connectdata *conn, int sockindex)
#ifdef HAS_CLIENT_CERT_PATH
/* client certificate */
- if(data->set.ssl.primary.clientcert || data->set.ssl.primary.cert_blob) {
- DWORD cert_store_name = 0;
- TCHAR *cert_store_path = NULL;
- TCHAR *cert_thumbprint_str = NULL;
+ if(data->set.ssl.primary.clientcert || data->set.ssl.primary.cert_blob) {
+ DWORD cert_store_name = 0;
+ TCHAR *cert_store_path = NULL;
+ TCHAR *cert_thumbprint_str = NULL;
CRYPT_HASH_BLOB cert_thumbprint;
BYTE cert_thumbprint_data[CERT_THUMBPRINT_DATA_LEN];
- HCERTSTORE cert_store = NULL;
- FILE *fInCert = NULL;
- void *certdata = NULL;
- size_t certsize = 0;
- bool blob = data->set.ssl.primary.cert_blob != NULL;
- TCHAR *cert_path = NULL;
- if(blob) {
- certdata = data->set.ssl.primary.cert_blob->data;
- certsize = data->set.ssl.primary.cert_blob->len;
- }
- else {
- cert_path = curlx_convert_UTF8_to_tchar(
- data->set.ssl.primary.clientcert);
- if(!cert_path)
- return CURLE_OUT_OF_MEMORY;
-
- result = get_cert_location(cert_path, &cert_store_name,
- &cert_store_path, &cert_thumbprint_str);
-
- if(result && (data->set.ssl.primary.clientcert[0]!='\0'))
- fInCert = fopen(data->set.ssl.primary.clientcert, "rb");
-
- if(result && !fInCert) {
- failf(data, "schannel: Failed to get certificate location"
- " or file for %s",
- data->set.ssl.primary.clientcert);
- curlx_unicodefree(cert_path);
- return result;
- }
+ HCERTSTORE cert_store = NULL;
+ FILE *fInCert = NULL;
+ void *certdata = NULL;
+ size_t certsize = 0;
+ bool blob = data->set.ssl.primary.cert_blob != NULL;
+ TCHAR *cert_path = NULL;
+ if(blob) {
+ certdata = data->set.ssl.primary.cert_blob->data;
+ certsize = data->set.ssl.primary.cert_blob->len;
+ }
+ else {
+ cert_path = curlx_convert_UTF8_to_tchar(
+ data->set.ssl.primary.clientcert);
+ if(!cert_path)
+ return CURLE_OUT_OF_MEMORY;
+
+ result = get_cert_location(cert_path, &cert_store_name,
+ &cert_store_path, &cert_thumbprint_str);
+
+ if(result && (data->set.ssl.primary.clientcert[0]!='\0'))
+ fInCert = fopen(data->set.ssl.primary.clientcert, "rb");
+
+ if(result && !fInCert) {
+ failf(data, "schannel: Failed to get certificate location"
+ " or file for %s",
+ data->set.ssl.primary.clientcert);
+ curlx_unicodefree(cert_path);
+ return result;
+ }
}
- if((fInCert || blob) && (data->set.ssl.cert_type) &&
- (!strcasecompare(data->set.ssl.cert_type, "P12"))) {
- failf(data, "schannel: certificate format compatibility error "
- " for %s",
- blob ? "(memory blob)" : data->set.ssl.primary.clientcert);
- curlx_unicodefree(cert_path);
+ if((fInCert || blob) && (data->set.ssl.cert_type) &&
+ (!strcasecompare(data->set.ssl.cert_type, "P12"))) {
+ failf(data, "schannel: certificate format compatibility error "
+ " for %s",
+ blob ? "(memory blob)" : data->set.ssl.primary.clientcert);
+ curlx_unicodefree(cert_path);
return CURLE_SSL_CERTPROBLEM;
}
- if(fInCert || blob) {
- /* Reading a .P12 or .pfx file, like the example at bottom of
- https://social.msdn.microsoft.com/Forums/windowsdesktop/
- en-US/3e7bc95f-b21a-4bcd-bd2c-7f996718cae5
- */
- CRYPT_DATA_BLOB datablob;
- WCHAR* pszPassword;
- size_t pwd_len = 0;
- int str_w_len = 0;
- const char *cert_showfilename_error = blob ?
- "(memory blob)" : data->set.ssl.primary.clientcert;
- curlx_unicodefree(cert_path);
- if(fInCert) {
- long cert_tell = 0;
- bool continue_reading = fseek(fInCert, 0, SEEK_END) == 0;
- if(continue_reading)
- cert_tell = ftell(fInCert);
- if(cert_tell < 0)
- continue_reading = FALSE;
- else
- certsize = (size_t)cert_tell;
- if(continue_reading)
- continue_reading = fseek(fInCert, 0, SEEK_SET) == 0;
- if(continue_reading)
- certdata = malloc(certsize + 1);
- if((!certdata) ||
- ((int) fread(certdata, certsize, 1, fInCert) != 1))
- continue_reading = FALSE;
- fclose(fInCert);
- if(!continue_reading) {
- failf(data, "schannel: Failed to read cert file %s",
- data->set.ssl.primary.clientcert);
- free(certdata);
- return CURLE_SSL_CERTPROBLEM;
- }
- }
-
- /* Convert key-pair data to the in-memory certificate store */
- datablob.pbData = (BYTE*)certdata;
- datablob.cbData = (DWORD)certsize;
-
- if(data->set.ssl.key_passwd != NULL)
- pwd_len = strlen(data->set.ssl.key_passwd);
- pszPassword = (WCHAR*)malloc(sizeof(WCHAR)*(pwd_len + 1));
- if(pszPassword) {
- if(pwd_len > 0)
- str_w_len = MultiByteToWideChar(CP_UTF8,
- MB_ERR_INVALID_CHARS,
- data->set.ssl.key_passwd, (int)pwd_len,
- pszPassword, (int)(pwd_len + 1));
-
- if((str_w_len >= 0) && (str_w_len <= (int)pwd_len))
- pszPassword[str_w_len] = 0;
- else
- pszPassword[0] = 0;
-
- cert_store = PFXImportCertStore(&datablob, pszPassword, 0);
- free(pszPassword);
- }
- if(!blob)
- free(certdata);
- if(cert_store == NULL) {
- DWORD errorcode = GetLastError();
- if(errorcode == ERROR_INVALID_PASSWORD)
- failf(data, "schannel: Failed to import cert file %s, "
- "password is bad",
- cert_showfilename_error);
- else
- failf(data, "schannel: Failed to import cert file %s, "
- "last error is 0x%x",
- cert_showfilename_error, errorcode);
- return CURLE_SSL_CERTPROBLEM;
- }
-
- client_certs[0] = CertFindCertificateInStore(
- cert_store, X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, 0,
- CERT_FIND_ANY, NULL, NULL);
-
- if(client_certs[0] == NULL) {
- failf(data, "schannel: Failed to get certificate from file %s"
- ", last error is 0x%x",
- cert_showfilename_error, GetLastError());
- CertCloseStore(cert_store, 0);
- return CURLE_SSL_CERTPROBLEM;
- }
-
+ if(fInCert || blob) {
+ /* Reading a .P12 or .pfx file, like the example at bottom of
+ https://social.msdn.microsoft.com/Forums/windowsdesktop/
+ en-US/3e7bc95f-b21a-4bcd-bd2c-7f996718cae5
+ */
+ CRYPT_DATA_BLOB datablob;
+ WCHAR* pszPassword;
+ size_t pwd_len = 0;
+ int str_w_len = 0;
+ const char *cert_showfilename_error = blob ?
+ "(memory blob)" : data->set.ssl.primary.clientcert;
+ curlx_unicodefree(cert_path);
+ if(fInCert) {
+ long cert_tell = 0;
+ bool continue_reading = fseek(fInCert, 0, SEEK_END) == 0;
+ if(continue_reading)
+ cert_tell = ftell(fInCert);
+ if(cert_tell < 0)
+ continue_reading = FALSE;
+ else
+ certsize = (size_t)cert_tell;
+ if(continue_reading)
+ continue_reading = fseek(fInCert, 0, SEEK_SET) == 0;
+ if(continue_reading)
+ certdata = malloc(certsize + 1);
+ if((!certdata) ||
+ ((int) fread(certdata, certsize, 1, fInCert) != 1))
+ continue_reading = FALSE;
+ fclose(fInCert);
+ if(!continue_reading) {
+ failf(data, "schannel: Failed to read cert file %s",
+ data->set.ssl.primary.clientcert);
+ free(certdata);
+ return CURLE_SSL_CERTPROBLEM;
+ }
+ }
+
+ /* Convert key-pair data to the in-memory certificate store */
+ datablob.pbData = (BYTE*)certdata;
+ datablob.cbData = (DWORD)certsize;
+
+ if(data->set.ssl.key_passwd != NULL)
+ pwd_len = strlen(data->set.ssl.key_passwd);
+ pszPassword = (WCHAR*)malloc(sizeof(WCHAR)*(pwd_len + 1));
+ if(pszPassword) {
+ if(pwd_len > 0)
+ str_w_len = MultiByteToWideChar(CP_UTF8,
+ MB_ERR_INVALID_CHARS,
+ data->set.ssl.key_passwd, (int)pwd_len,
+ pszPassword, (int)(pwd_len + 1));
+
+ if((str_w_len >= 0) && (str_w_len <= (int)pwd_len))
+ pszPassword[str_w_len] = 0;
+ else
+ pszPassword[0] = 0;
+
+ cert_store = PFXImportCertStore(&datablob, pszPassword, 0);
+ free(pszPassword);
+ }
+ if(!blob)
+ free(certdata);
+ if(cert_store == NULL) {
+ DWORD errorcode = GetLastError();
+ if(errorcode == ERROR_INVALID_PASSWORD)
+ failf(data, "schannel: Failed to import cert file %s, "
+ "password is bad",
+ cert_showfilename_error);
+ else
+ failf(data, "schannel: Failed to import cert file %s, "
+ "last error is 0x%x",
+ cert_showfilename_error, errorcode);
+ return CURLE_SSL_CERTPROBLEM;
+ }
+
+ client_certs[0] = CertFindCertificateInStore(
+ cert_store, X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, 0,
+ CERT_FIND_ANY, NULL, NULL);
+
+ if(client_certs[0] == NULL) {
+ failf(data, "schannel: Failed to get certificate from file %s"
+ ", last error is 0x%x",
+ cert_showfilename_error, GetLastError());
+ CertCloseStore(cert_store, 0);
+ return CURLE_SSL_CERTPROBLEM;
+ }
+
schannel_cred.cCreds = 1;
schannel_cred.paCred = client_certs;
}
else {
- cert_store =
- CertOpenStore(CURL_CERT_STORE_PROV_SYSTEM, 0,
- (HCRYPTPROV)NULL,
- CERT_STORE_OPEN_EXISTING_FLAG | cert_store_name,
- cert_store_path);
- if(!cert_store) {
- failf(data, "schannel: Failed to open cert store %x %s, "
- "last error is 0x%x",
- cert_store_name, cert_store_path, GetLastError());
- free(cert_store_path);
- curlx_unicodefree(cert_path);
- return CURLE_SSL_CERTPROBLEM;
- }
- free(cert_store_path);
-
- cert_thumbprint.pbData = cert_thumbprint_data;
- cert_thumbprint.cbData = CERT_THUMBPRINT_DATA_LEN;
-
- if(!CryptStringToBinary(cert_thumbprint_str,
- CERT_THUMBPRINT_STR_LEN,
- CRYPT_STRING_HEX,
- cert_thumbprint_data,
- &cert_thumbprint.cbData,
- NULL, NULL)) {
- curlx_unicodefree(cert_path);
- CertCloseStore(cert_store, 0);
- return CURLE_SSL_CERTPROBLEM;
- }
-
- client_certs[0] = CertFindCertificateInStore(
- cert_store, X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, 0,
- CERT_FIND_HASH, &cert_thumbprint, NULL);
-
- curlx_unicodefree(cert_path);
-
- if(client_certs[0]) {
- schannel_cred.cCreds = 1;
- schannel_cred.paCred = client_certs;
- }
- else {
- /* CRYPT_E_NOT_FOUND / E_INVALIDARG */
- CertCloseStore(cert_store, 0);
- return CURLE_SSL_CERTPROBLEM;
- }
+ cert_store =
+ CertOpenStore(CURL_CERT_STORE_PROV_SYSTEM, 0,
+ (HCRYPTPROV)NULL,
+ CERT_STORE_OPEN_EXISTING_FLAG | cert_store_name,
+ cert_store_path);
+ if(!cert_store) {
+ failf(data, "schannel: Failed to open cert store %x %s, "
+ "last error is 0x%x",
+ cert_store_name, cert_store_path, GetLastError());
+ free(cert_store_path);
+ curlx_unicodefree(cert_path);
+ return CURLE_SSL_CERTPROBLEM;
+ }
+ free(cert_store_path);
+
+ cert_thumbprint.pbData = cert_thumbprint_data;
+ cert_thumbprint.cbData = CERT_THUMBPRINT_DATA_LEN;
+
+ if(!CryptStringToBinary(cert_thumbprint_str,
+ CERT_THUMBPRINT_STR_LEN,
+ CRYPT_STRING_HEX,
+ cert_thumbprint_data,
+ &cert_thumbprint.cbData,
+ NULL, NULL)) {
+ curlx_unicodefree(cert_path);
+ CertCloseStore(cert_store, 0);
+ return CURLE_SSL_CERTPROBLEM;
+ }
+
+ client_certs[0] = CertFindCertificateInStore(
+ cert_store, X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, 0,
+ CERT_FIND_HASH, &cert_thumbprint, NULL);
+
+ curlx_unicodefree(cert_path);
+
+ if(client_certs[0]) {
+ schannel_cred.cCreds = 1;
+ schannel_cred.paCred = client_certs;
+ }
+ else {
+ /* CRYPT_E_NOT_FOUND / E_INVALIDARG */
+ CertCloseStore(cert_store, 0);
+ return CURLE_SSL_CERTPROBLEM;
+ }
}
CertCloseStore(cert_store, 0);
}
#else
- if(data->set.ssl.primary.clientcert || data->set.ssl.primary.cert_blob) {
+ if(data->set.ssl.primary.clientcert || data->set.ssl.primary.cert_blob) {
failf(data, "schannel: client cert support not built in");
return CURLE_NOT_BUILT_IN;
}
#endif
/* allocate memory for the re-usable credential handle */
- BACKEND->cred = (struct Curl_schannel_cred *)
- calloc(1, sizeof(struct Curl_schannel_cred));
+ BACKEND->cred = (struct Curl_schannel_cred *)
+ calloc(1, sizeof(struct Curl_schannel_cred));
if(!BACKEND->cred) {
failf(data, "schannel: unable to allocate memory");
@@ -794,7 +794,7 @@ schannel_connect_step1(struct connectdata *conn, int sockindex)
BACKEND->cred->refcount = 1;
/* https://msdn.microsoft.com/en-us/library/windows/desktop/aa374716.aspx
- */
+ */
sspi_status =
s_pSecFn->AcquireCredentialsHandle(NULL, (TCHAR *)UNISP_NAME,
SECPKG_CRED_OUTBOUND, NULL,
@@ -811,15 +811,15 @@ schannel_connect_step1(struct connectdata *conn, int sockindex)
Curl_sspi_strerror(sspi_status, buffer, sizeof(buffer)));
Curl_safefree(BACKEND->cred);
switch(sspi_status) {
- case SEC_E_INSUFFICIENT_MEMORY:
- return CURLE_OUT_OF_MEMORY;
- case SEC_E_NO_CREDENTIALS:
- case SEC_E_SECPKG_NOT_FOUND:
- case SEC_E_NOT_OWNER:
- case SEC_E_UNKNOWN_CREDENTIALS:
- case SEC_E_INTERNAL_ERROR:
- default:
- return CURLE_SSL_CONNECT_ERROR;
+ case SEC_E_INSUFFICIENT_MEMORY:
+ return CURLE_OUT_OF_MEMORY;
+ case SEC_E_NO_CREDENTIALS:
+ case SEC_E_SECPKG_NOT_FOUND:
+ case SEC_E_NOT_OWNER:
+ case SEC_E_UNKNOWN_CREDENTIALS:
+ case SEC_E_INTERNAL_ERROR:
+ default:
+ return CURLE_SSL_CONNECT_ERROR;
}
}
}
@@ -841,7 +841,7 @@ schannel_connect_step1(struct connectdata *conn, int sockindex)
unsigned short* list_len = NULL;
/* The first four bytes will be an unsigned int indicating number
- of bytes of data in the rest of the buffer. */
+ of bytes of data in the rest of the buffer. */
extension_len = (unsigned int *)(&alpn_buffer[cur]);
cur += sizeof(unsigned int);
@@ -896,14 +896,14 @@ schannel_connect_step1(struct connectdata *conn, int sockindex)
ISC_REQ_STREAM;
/* allocate memory for the security context handle */
- BACKEND->ctxt = (struct Curl_schannel_ctxt *)
- calloc(1, sizeof(struct Curl_schannel_ctxt));
+ BACKEND->ctxt = (struct Curl_schannel_ctxt *)
+ calloc(1, sizeof(struct Curl_schannel_ctxt));
if(!BACKEND->ctxt) {
failf(data, "schannel: unable to allocate memory");
return CURLE_OUT_OF_MEMORY;
}
- host_name = curlx_convert_UTF8_to_tchar(hostname);
+ host_name = curlx_convert_UTF8_to_tchar(hostname);
if(!host_name)
return CURLE_OUT_OF_MEMORY;
@@ -920,35 +920,35 @@ schannel_connect_step1(struct connectdata *conn, int sockindex)
0, &BACKEND->ctxt->ctxt_handle,
&outbuf_desc, &BACKEND->ret_flags, &BACKEND->ctxt->time_stamp);
- curlx_unicodefree(host_name);
+ curlx_unicodefree(host_name);
if(sspi_status != SEC_I_CONTINUE_NEEDED) {
char buffer[STRERROR_LEN];
Curl_safefree(BACKEND->ctxt);
switch(sspi_status) {
- case SEC_E_INSUFFICIENT_MEMORY:
- failf(data, "schannel: initial InitializeSecurityContext failed: %s",
- Curl_sspi_strerror(sspi_status, buffer, sizeof(buffer)));
- return CURLE_OUT_OF_MEMORY;
- case SEC_E_WRONG_PRINCIPAL:
- failf(data, "schannel: SNI or certificate check failed: %s",
- Curl_sspi_strerror(sspi_status, buffer, sizeof(buffer)));
- return CURLE_PEER_FAILED_VERIFICATION;
- /*
- case SEC_E_INVALID_HANDLE:
- case SEC_E_INVALID_TOKEN:
- case SEC_E_LOGON_DENIED:
- case SEC_E_TARGET_UNKNOWN:
- case SEC_E_NO_AUTHENTICATING_AUTHORITY:
- case SEC_E_INTERNAL_ERROR:
- case SEC_E_NO_CREDENTIALS:
- case SEC_E_UNSUPPORTED_FUNCTION:
- case SEC_E_APPLICATION_PROTOCOL_MISMATCH:
- */
- default:
- failf(data, "schannel: initial InitializeSecurityContext failed: %s",
- Curl_sspi_strerror(sspi_status, buffer, sizeof(buffer)));
- return CURLE_SSL_CONNECT_ERROR;
+ case SEC_E_INSUFFICIENT_MEMORY:
+ failf(data, "schannel: initial InitializeSecurityContext failed: %s",
+ Curl_sspi_strerror(sspi_status, buffer, sizeof(buffer)));
+ return CURLE_OUT_OF_MEMORY;
+ case SEC_E_WRONG_PRINCIPAL:
+ failf(data, "schannel: SNI or certificate check failed: %s",
+ Curl_sspi_strerror(sspi_status, buffer, sizeof(buffer)));
+ return CURLE_PEER_FAILED_VERIFICATION;
+ /*
+ case SEC_E_INVALID_HANDLE:
+ case SEC_E_INVALID_TOKEN:
+ case SEC_E_LOGON_DENIED:
+ case SEC_E_TARGET_UNKNOWN:
+ case SEC_E_NO_AUTHENTICATING_AUTHORITY:
+ case SEC_E_INTERNAL_ERROR:
+ case SEC_E_NO_CREDENTIALS:
+ case SEC_E_UNSUPPORTED_FUNCTION:
+ case SEC_E_APPLICATION_PROTOCOL_MISMATCH:
+ */
+ default:
+ failf(data, "schannel: initial InitializeSecurityContext failed: %s",
+ Curl_sspi_strerror(sspi_status, buffer, sizeof(buffer)));
+ return CURLE_SSL_CONNECT_ERROR;
}
}
@@ -994,12 +994,12 @@ schannel_connect_step2(struct connectdata *conn, int sockindex)
SECURITY_STATUS sspi_status = SEC_E_OK;
CURLcode result;
bool doread;
-#ifndef CURL_DISABLE_PROXY
+#ifndef CURL_DISABLE_PROXY
char * const hostname = SSL_IS_PROXY() ? conn->http_proxy.host.name :
conn->host.name;
-#else
- char * const hostname = conn->host.name;
-#endif
+#else
+ char * const hostname = conn->host.name;
+#endif
const char *pubkey_ptr;
doread = (connssl->connecting_state != ssl_connect_2_writing) ? TRUE : FALSE;
@@ -1107,18 +1107,18 @@ schannel_connect_step2(struct connectdata *conn, int sockindex)
memcpy(inbuf[0].pvBuffer, BACKEND->encdata_buffer,
BACKEND->encdata_offset);
- host_name = curlx_convert_UTF8_to_tchar(hostname);
+ host_name = curlx_convert_UTF8_to_tchar(hostname);
if(!host_name)
return CURLE_OUT_OF_MEMORY;
/* https://msdn.microsoft.com/en-us/library/windows/desktop/aa375924.aspx
- */
+ */
sspi_status = s_pSecFn->InitializeSecurityContext(
&BACKEND->cred->cred_handle, &BACKEND->ctxt->ctxt_handle,
host_name, BACKEND->req_flags, 0, 0, &inbuf_desc, 0, NULL,
&outbuf_desc, &BACKEND->ret_flags, &BACKEND->ctxt->time_stamp);
- curlx_unicodefree(host_name);
+ curlx_unicodefree(host_name);
/* free buffer for received handshake data */
Curl_safefree(inbuf[0].pvBuffer);
@@ -1173,33 +1173,33 @@ schannel_connect_step2(struct connectdata *conn, int sockindex)
else {
char buffer[STRERROR_LEN];
switch(sspi_status) {
- case SEC_E_INSUFFICIENT_MEMORY:
- failf(data, "schannel: next InitializeSecurityContext failed: %s",
- Curl_sspi_strerror(sspi_status, buffer, sizeof(buffer)));
- return CURLE_OUT_OF_MEMORY;
- case SEC_E_WRONG_PRINCIPAL:
- failf(data, "schannel: SNI or certificate check failed: %s",
- Curl_sspi_strerror(sspi_status, buffer, sizeof(buffer)));
- return CURLE_PEER_FAILED_VERIFICATION;
- case SEC_E_UNTRUSTED_ROOT:
- failf(data, "schannel: %s",
- Curl_sspi_strerror(sspi_status, buffer, sizeof(buffer)));
- return CURLE_PEER_FAILED_VERIFICATION;
- /*
- case SEC_E_INVALID_HANDLE:
- case SEC_E_INVALID_TOKEN:
- case SEC_E_LOGON_DENIED:
- case SEC_E_TARGET_UNKNOWN:
- case SEC_E_NO_AUTHENTICATING_AUTHORITY:
- case SEC_E_INTERNAL_ERROR:
- case SEC_E_NO_CREDENTIALS:
- case SEC_E_UNSUPPORTED_FUNCTION:
- case SEC_E_APPLICATION_PROTOCOL_MISMATCH:
- */
- default:
- failf(data, "schannel: next InitializeSecurityContext failed: %s",
- Curl_sspi_strerror(sspi_status, buffer, sizeof(buffer)));
- return CURLE_SSL_CONNECT_ERROR;
+ case SEC_E_INSUFFICIENT_MEMORY:
+ failf(data, "schannel: next InitializeSecurityContext failed: %s",
+ Curl_sspi_strerror(sspi_status, buffer, sizeof(buffer)));
+ return CURLE_OUT_OF_MEMORY;
+ case SEC_E_WRONG_PRINCIPAL:
+ failf(data, "schannel: SNI or certificate check failed: %s",
+ Curl_sspi_strerror(sspi_status, buffer, sizeof(buffer)));
+ return CURLE_PEER_FAILED_VERIFICATION;
+ case SEC_E_UNTRUSTED_ROOT:
+ failf(data, "schannel: %s",
+ Curl_sspi_strerror(sspi_status, buffer, sizeof(buffer)));
+ return CURLE_PEER_FAILED_VERIFICATION;
+ /*
+ case SEC_E_INVALID_HANDLE:
+ case SEC_E_INVALID_TOKEN:
+ case SEC_E_LOGON_DENIED:
+ case SEC_E_TARGET_UNKNOWN:
+ case SEC_E_NO_AUTHENTICATING_AUTHORITY:
+ case SEC_E_INTERNAL_ERROR:
+ case SEC_E_NO_CREDENTIALS:
+ case SEC_E_UNSUPPORTED_FUNCTION:
+ case SEC_E_APPLICATION_PROTOCOL_MISMATCH:
+ */
+ default:
+ failf(data, "schannel: next InitializeSecurityContext failed: %s",
+ Curl_sspi_strerror(sspi_status, buffer, sizeof(buffer)));
+ return CURLE_SSL_CONNECT_ERROR;
}
}
@@ -1308,7 +1308,7 @@ struct Adder_args
struct connectdata *conn;
CURLcode result;
int idx;
- int certs_count;
+ int certs_count;
};
static bool
@@ -1319,9 +1319,9 @@ add_cert_to_certinfo(const CERT_CONTEXT *ccert_context, void *raw_arg)
if(valid_cert_encoding(ccert_context)) {
const char *beg = (const char *) ccert_context->pbCertEncoded;
const char *end = beg + ccert_context->cbCertEncoded;
- int insert_index = (args->certs_count - 1) - args->idx;
- args->result = Curl_extract_certinfo(args->conn, insert_index, beg, end);
- args->idx++;
+ int insert_index = (args->certs_count - 1) - args->idx;
+ args->result = Curl_extract_certinfo(args->conn, insert_index, beg, end);
+ args->idx++;
}
return args->result == CURLE_OK;
}
@@ -1368,10 +1368,10 @@ schannel_connect_step3(struct connectdata *conn, int sockindex)
#ifdef HAS_ALPN
if(BACKEND->use_alpn) {
- sspi_status =
- s_pSecFn->QueryContextAttributes(&BACKEND->ctxt->ctxt_handle,
- SECPKG_ATTR_APPLICATION_PROTOCOL,
- &alpn_result);
+ sspi_status =
+ s_pSecFn->QueryContextAttributes(&BACKEND->ctxt->ctxt_handle,
+ SECPKG_ATTR_APPLICATION_PROTOCOL,
+ &alpn_result);
if(sspi_status != SEC_E_OK) {
failf(data, "schannel: failed to retrieve ALPN result");
@@ -1382,21 +1382,21 @@ schannel_connect_step3(struct connectdata *conn, int sockindex)
SecApplicationProtocolNegotiationStatus_Success) {
infof(data, "schannel: ALPN, server accepted to use %.*s\n",
- alpn_result.ProtocolIdSize, alpn_result.ProtocolId);
+ alpn_result.ProtocolIdSize, alpn_result.ProtocolId);
#ifdef USE_NGHTTP2
if(alpn_result.ProtocolIdSize == NGHTTP2_PROTO_VERSION_ID_LEN &&
!memcmp(NGHTTP2_PROTO_VERSION_ID, alpn_result.ProtocolId,
- NGHTTP2_PROTO_VERSION_ID_LEN)) {
+ NGHTTP2_PROTO_VERSION_ID_LEN)) {
conn->negnpn = CURL_HTTP_VERSION_2;
}
else
#endif
- if(alpn_result.ProtocolIdSize == ALPN_HTTP_1_1_LENGTH &&
- !memcmp(ALPN_HTTP_1_1, alpn_result.ProtocolId,
- ALPN_HTTP_1_1_LENGTH)) {
- conn->negnpn = CURL_HTTP_VERSION_1_1;
- }
+ if(alpn_result.ProtocolIdSize == ALPN_HTTP_1_1_LENGTH &&
+ !memcmp(ALPN_HTTP_1_1, alpn_result.ProtocolId,
+ ALPN_HTTP_1_1_LENGTH)) {
+ conn->negnpn = CURL_HTTP_VERSION_1_1;
+ }
}
else
infof(data, "ALPN, server did not agree to a protocol\n");
@@ -1408,7 +1408,7 @@ schannel_connect_step3(struct connectdata *conn, int sockindex)
/* save the current session data for possible re-use */
if(SSL_SET_OPTION(primary.sessionid)) {
bool incache;
- struct Curl_schannel_cred *old_cred = NULL;
+ struct Curl_schannel_cred *old_cred = NULL;
Curl_ssl_sessionid_lock(conn);
incache = !(Curl_ssl_getsessionid(conn, (void **)&old_cred, NULL,
@@ -1424,7 +1424,7 @@ schannel_connect_step3(struct connectdata *conn, int sockindex)
}
if(!incache) {
result = Curl_ssl_addsessionid(conn, (void *)BACKEND->cred,
- sizeof(struct Curl_schannel_cred),
+ sizeof(struct Curl_schannel_cred),
sockindex);
if(result) {
Curl_ssl_sessionid_unlock(conn);
@@ -1443,10 +1443,10 @@ schannel_connect_step3(struct connectdata *conn, int sockindex)
if(data->set.ssl.certinfo) {
int certs_count = 0;
- sspi_status =
- s_pSecFn->QueryContextAttributes(&BACKEND->ctxt->ctxt_handle,
- SECPKG_ATTR_REMOTE_CERT_CONTEXT,
- &ccert_context);
+ sspi_status =
+ s_pSecFn->QueryContextAttributes(&BACKEND->ctxt->ctxt_handle,
+ SECPKG_ATTR_REMOTE_CERT_CONTEXT,
+ &ccert_context);
if((sspi_status != SEC_E_OK) || (ccert_context == NULL)) {
failf(data, "schannel: failed to retrieve remote cert context");
@@ -1460,7 +1460,7 @@ schannel_connect_step3(struct connectdata *conn, int sockindex)
struct Adder_args args;
args.conn = conn;
args.idx = 0;
- args.certs_count = certs_count;
+ args.certs_count = certs_count;
traverse_cert_store(ccert_context, add_cert_to_certinfo, &args);
result = args.result;
}
@@ -1482,7 +1482,7 @@ schannel_connect_common(struct connectdata *conn, int sockindex,
struct Curl_easy *data = conn->data;
struct ssl_connect_data *connssl = &conn->ssl[sockindex];
curl_socket_t sockfd = conn->sock[sockindex];
- timediff_t timeout_ms;
+ timediff_t timeout_ms;
int what;
/* check if the connection has already been established */
@@ -1678,10 +1678,10 @@ schannel_send(struct connectdata *conn, int sockindex,
/* send entire message or fail */
while(len > (size_t)written) {
- ssize_t this_write = 0;
+ ssize_t this_write = 0;
int what;
- timediff_t timeout_ms = Curl_timeleft(conn->data, NULL, FALSE);
- if(timeout_ms < 0) {
+ timediff_t timeout_ms = Curl_timeleft(conn->data, NULL, FALSE);
+ if(timeout_ms < 0) {
/* we already got the timeout */
failf(conn->data, "schannel: timed out sending data "
"(bytes sent: %zd)", written);
@@ -1689,9 +1689,9 @@ schannel_send(struct connectdata *conn, int sockindex,
written = -1;
break;
}
- else if(!timeout_ms)
- timeout_ms = TIMEDIFF_T_MAX;
- what = SOCKET_WRITABLE(conn->sock[sockindex], timeout_ms);
+ else if(!timeout_ms)
+ timeout_ms = TIMEDIFF_T_MAX;
+ what = SOCKET_WRITABLE(conn->sock[sockindex], timeout_ms);
if(what < 0) {
/* fatal error */
failf(conn->data, "select/poll on SSL socket, errno: %d", SOCKERRNO);
@@ -1785,8 +1785,8 @@ schannel_recv(struct connectdata *conn, int sockindex,
}
else if(!len) {
/* It's debatable what to return when !len. Regardless we can't return
- immediately because there may be data to decrypt (in the case we want to
- decrypt all encrypted cached data) so handle !len later in cleanup.
+ immediately because there may be data to decrypt (in the case we want to
+ decrypt all encrypted cached data) so handle !len later in cleanup.
*/
; /* do nothing */
}
@@ -1796,7 +1796,7 @@ schannel_recv(struct connectdata *conn, int sockindex,
if(size < CURL_SCHANNEL_BUFFER_FREE_SIZE ||
BACKEND->encdata_length < min_encdata_length) {
reallocated_length = BACKEND->encdata_offset +
- CURL_SCHANNEL_BUFFER_FREE_SIZE;
+ CURL_SCHANNEL_BUFFER_FREE_SIZE;
if(reallocated_length < min_encdata_length) {
reallocated_length = min_encdata_length;
}
@@ -1864,7 +1864,7 @@ schannel_recv(struct connectdata *conn, int sockindex,
InitSecBufferDesc(&inbuf_desc, inbuf, 4);
/* https://msdn.microsoft.com/en-us/library/windows/desktop/aa375348.aspx
- */
+ */
sspi_status = s_pSecFn->DecryptMessage(&BACKEND->ctxt->ctxt_handle,
&inbuf_desc, 0, NULL);
@@ -1880,7 +1880,7 @@ schannel_recv(struct connectdata *conn, int sockindex,
/* increase buffer in order to fit the received amount of data */
size = inbuf[1].cbBuffer > CURL_SCHANNEL_BUFFER_FREE_SIZE ?
- inbuf[1].cbBuffer : CURL_SCHANNEL_BUFFER_FREE_SIZE;
+ inbuf[1].cbBuffer : CURL_SCHANNEL_BUFFER_FREE_SIZE;
if(BACKEND->decdata_length - BACKEND->decdata_offset < size ||
BACKEND->decdata_length < len) {
/* increase internal decrypted data buffer */
@@ -1950,7 +1950,7 @@ schannel_recv(struct connectdata *conn, int sockindex,
if(BACKEND->encdata_offset) {
*err = CURLE_RECV_ERROR;
infof(data, "schannel: can't renogotiate, "
- "encrypted data available\n");
+ "encrypted data available\n");
goto cleanup;
}
/* begin renegotiation */
@@ -1987,9 +1987,9 @@ schannel_recv(struct connectdata *conn, int sockindex,
goto cleanup;
}
else {
-#ifndef CURL_DISABLE_VERBOSE_STRINGS
+#ifndef CURL_DISABLE_VERBOSE_STRINGS
char buffer[STRERROR_LEN];
-#endif
+#endif
*err = CURLE_RECV_ERROR;
infof(data, "schannel: failed to read data from server: %s\n",
Curl_sspi_strerror(sspi_status, buffer, sizeof(buffer)));
@@ -2005,25 +2005,25 @@ schannel_recv(struct connectdata *conn, int sockindex,
"schannel: decrypted data buffer: offset %zu length %zu\n",
BACKEND->decdata_offset, BACKEND->decdata_length));
- cleanup:
+ cleanup:
/* Warning- there is no guarantee the encdata state is valid at this point */
DEBUGF(infof(data, "schannel: schannel_recv cleanup\n"));
/* Error if the connection has closed without a close_notify.
-
- The behavior here is a matter of debate. We don't want to be vulnerable
- to a truncation attack however there's some browser precedent for
- ignoring the close_notify for compatibility reasons.
-
- Additionally, Windows 2000 (v5.0) is a special case since it seems it
- doesn't return close_notify. In that case if the connection was closed we
- assume it was graceful (close_notify) since there doesn't seem to be a
- way to tell.
+
+ The behavior here is a matter of debate. We don't want to be vulnerable
+ to a truncation attack however there's some browser precedent for
+ ignoring the close_notify for compatibility reasons.
+
+ Additionally, Windows 2000 (v5.0) is a special case since it seems it
+ doesn't return close_notify. In that case if the connection was closed we
+ assume it was graceful (close_notify) since there doesn't seem to be a
+ way to tell.
*/
if(len && !BACKEND->decdata_offset && BACKEND->recv_connection_closed &&
!BACKEND->recv_sspi_close_notify) {
- bool isWin2k = curlx_verify_windows_version(5, 0, PLATFORM_WINNT,
- VERSION_EQUAL);
+ bool isWin2k = curlx_verify_windows_version(5, 0, PLATFORM_WINNT,
+ VERSION_EQUAL);
if(isWin2k && sspi_status == SEC_E_OK)
BACKEND->recv_sspi_close_notify = true;
@@ -2035,7 +2035,7 @@ schannel_recv(struct connectdata *conn, int sockindex,
/* Any error other than CURLE_AGAIN is an unrecoverable error. */
if(*err && *err != CURLE_AGAIN)
- BACKEND->recv_unrecoverable_err = *err;
+ BACKEND->recv_unrecoverable_err = *err;
size = len < BACKEND->decdata_offset ? len : BACKEND->decdata_offset;
if(size) {
@@ -2052,11 +2052,11 @@ schannel_recv(struct connectdata *conn, int sockindex,
}
if(!*err && !BACKEND->recv_connection_closed)
- *err = CURLE_AGAIN;
+ *err = CURLE_AGAIN;
- /* It's debatable what to return when !len. We could return whatever error
- we got from decryption but instead we override here so the return is
- consistent.
+ /* It's debatable what to return when !len. We could return whatever error
+ we got from decryption but instead we override here so the return is
+ consistent.
*/
if(!len)
*err = CURLE_OK;
@@ -2106,7 +2106,7 @@ static void Curl_schannel_close(struct connectdata *conn, int sockindex)
static void Curl_schannel_session_free(void *ptr)
{
/* this is expected to be called under sessionid lock */
- struct Curl_schannel_cred *cred = ptr;
+ struct Curl_schannel_cred *cred = ptr;
cred->refcount--;
if(cred->refcount == 0) {
@@ -2122,12 +2122,12 @@ static int Curl_schannel_shutdown(struct connectdata *conn, int sockindex)
*/
struct Curl_easy *data = conn->data;
struct ssl_connect_data *connssl = &conn->ssl[sockindex];
-#ifndef CURL_DISABLE_PROXY
+#ifndef CURL_DISABLE_PROXY
char * const hostname = SSL_IS_PROXY() ? conn->http_proxy.host.name :
conn->host.name;
-#else
- char * const hostname = conn->host.name;
-#endif
+#else
+ char * const hostname = conn->host.name;
+#endif
DEBUGASSERT(data);
@@ -2156,7 +2156,7 @@ static int Curl_schannel_shutdown(struct connectdata *conn, int sockindex)
Curl_sspi_strerror(sspi_status, buffer, sizeof(buffer)));
}
- host_name = curlx_convert_UTF8_to_tchar(hostname);
+ host_name = curlx_convert_UTF8_to_tchar(hostname);
if(!host_name)
return CURLE_OUT_OF_MEMORY;
@@ -2178,7 +2178,7 @@ static int Curl_schannel_shutdown(struct connectdata *conn, int sockindex)
&BACKEND->ret_flags,
&BACKEND->ctxt->time_stamp);
- curlx_unicodefree(host_name);
+ curlx_unicodefree(host_name);
if((sspi_status == SEC_E_OK) || (sspi_status == SEC_I_CONTEXT_EXPIRED)) {
/* send close message which is in output buffer */
@@ -2287,8 +2287,8 @@ static CURLcode pkp_pin_peer_pubkey(struct connectdata *conn, int sockindex,
SECURITY_STATUS sspi_status;
const char *x509_der;
DWORD x509_der_len;
- struct Curl_X509certificate x509_parsed;
- struct Curl_asn1Element *pubkey;
+ struct Curl_X509certificate x509_parsed;
+ struct Curl_asn1Element *pubkey;
sspi_status =
s_pSecFn->QueryContextAttributes(&BACKEND->ctxt->ctxt_handle,
@@ -2304,7 +2304,7 @@ static CURLcode pkp_pin_peer_pubkey(struct connectdata *conn, int sockindex,
if(!(((pCertContextServer->dwCertEncodingType & X509_ASN_ENCODING) != 0) &&
- (pCertContextServer->cbCertEncoded > 0)))
+ (pCertContextServer->cbCertEncoded > 0)))
break;
x509_der = (const char *)pCertContextServer->pbCertEncoded;
@@ -2353,7 +2353,7 @@ static void Curl_schannel_checksum(const unsigned char *input,
memset(checksum, 0, checksumlen);
if(!CryptAcquireContext(&hProv, NULL, NULL, provType,
- CRYPT_VERIFYCONTEXT | CRYPT_SILENT))
+ CRYPT_VERIFYCONTEXT | CRYPT_SILENT))
return; /* failed */
do {
@@ -2395,9 +2395,9 @@ static CURLcode Curl_schannel_md5sum(unsigned char *input,
}
static CURLcode Curl_schannel_sha256sum(const unsigned char *input,
- size_t inputlen,
- unsigned char *sha256sum,
- size_t sha256len)
+ size_t inputlen,
+ unsigned char *sha256sum,
+ size_t sha256len)
{
Curl_schannel_checksum(input, inputlen, sha256sum, sha256len,
PROV_RSA_AES, CALG_SHA_256);
diff --git a/contrib/libs/curl/lib/vtls/schannel.h b/contrib/libs/curl/lib/vtls/schannel.h
index a361c4ca5d..085b3f455c 100644
--- a/contrib/libs/curl/lib/vtls/schannel.h
+++ b/contrib/libs/curl/lib/vtls/schannel.h
@@ -8,11 +8,11 @@
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2012, Marc Hoersken, <info@marc-hoersken.de>, et al.
- * Copyright (C) 2012 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2012 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -70,20 +70,20 @@ CURLcode Curl_verify_certificate(struct connectdata *conn, int sockindex);
#endif
#endif
-struct Curl_schannel_cred {
+struct Curl_schannel_cred {
CredHandle cred_handle;
TimeStamp time_stamp;
int refcount;
};
-struct Curl_schannel_ctxt {
+struct Curl_schannel_ctxt {
CtxtHandle ctxt_handle;
TimeStamp time_stamp;
};
struct ssl_backend_data {
- struct Curl_schannel_cred *cred;
- struct Curl_schannel_ctxt *ctxt;
+ struct Curl_schannel_cred *cred;
+ struct Curl_schannel_ctxt *ctxt;
SecPkgContext_StreamSizes stream_sizes;
size_t encdata_length, decdata_length;
size_t encdata_offset, decdata_offset;
diff --git a/contrib/libs/curl/lib/vtls/schannel_verify.c b/contrib/libs/curl/lib/vtls/schannel_verify.c
index 94462d1812..31b3b2f02f 100644
--- a/contrib/libs/curl/lib/vtls/schannel_verify.c
+++ b/contrib/libs/curl/lib/vtls/schannel_verify.c
@@ -7,11 +7,11 @@
*
* Copyright (C) 2012 - 2016, Marc Hoersken, <info@marc-hoersken.de>
* Copyright (C) 2012, Mark Salisbury, <mark.salisbury@hp.com>
- * Copyright (C) 2012 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2012 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -45,7 +45,7 @@
#include "curl_multibyte.h"
#include "curl_printf.h"
#include "hostcheck.h"
-#include "version_win32.h"
+#include "version_win32.h"
/* The last #include file should be: */
#include "curl_memory.h"
@@ -57,7 +57,7 @@
#define BEGIN_CERT "-----BEGIN CERTIFICATE-----"
#define END_CERT "\n-----END CERTIFICATE-----"
-struct cert_chain_engine_config_win7 {
+struct cert_chain_engine_config_win7 {
DWORD cbSize;
HCERTSTORE hRestrictedRoot;
HCERTSTORE hRestrictedTrust;
@@ -70,7 +70,7 @@ struct cert_chain_engine_config_win7 {
DWORD CycleDetectionModulus;
HCERTSTORE hExclusiveRoot;
HCERTSTORE hExclusiveTrustedPeople;
-};
+};
static int is_cr_or_lf(char c)
{
@@ -94,13 +94,13 @@ static CURLcode add_certs_to_store(HCERTSTORE trust_store,
int num_certs = 0;
size_t END_CERT_LEN;
- ca_file_tstr = curlx_convert_UTF8_to_tchar((char *)ca_file);
+ ca_file_tstr = curlx_convert_UTF8_to_tchar((char *)ca_file);
if(!ca_file_tstr) {
char buffer[STRERROR_LEN];
failf(data,
"schannel: invalid path name for CA file '%s': %s",
- ca_file,
- Curl_winapi_strerror(GetLastError(), buffer, sizeof(buffer)));
+ ca_file,
+ Curl_winapi_strerror(GetLastError(), buffer, sizeof(buffer)));
result = CURLE_SSL_CACERT_BADFILE;
goto cleanup;
}
@@ -112,7 +112,7 @@ static CURLcode add_certs_to_store(HCERTSTORE trust_store,
*/
ca_file_handle = CreateFile(ca_file_tstr,
GENERIC_READ,
- FILE_SHARE_READ,
+ FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
@@ -121,8 +121,8 @@ static CURLcode add_certs_to_store(HCERTSTORE trust_store,
char buffer[STRERROR_LEN];
failf(data,
"schannel: failed to open CA file '%s': %s",
- ca_file,
- Curl_winapi_strerror(GetLastError(), buffer, sizeof(buffer)));
+ ca_file,
+ Curl_winapi_strerror(GetLastError(), buffer, sizeof(buffer)));
result = CURLE_SSL_CACERT_BADFILE;
goto cleanup;
}
@@ -131,8 +131,8 @@ static CURLcode add_certs_to_store(HCERTSTORE trust_store,
char buffer[STRERROR_LEN];
failf(data,
"schannel: failed to determine size of CA file '%s': %s",
- ca_file,
- Curl_winapi_strerror(GetLastError(), buffer, sizeof(buffer)));
+ ca_file,
+ Curl_winapi_strerror(GetLastError(), buffer, sizeof(buffer)));
result = CURLE_SSL_CACERT_BADFILE;
goto cleanup;
}
@@ -162,8 +162,8 @@ static CURLcode add_certs_to_store(HCERTSTORE trust_store,
char buffer[STRERROR_LEN];
failf(data,
"schannel: failed to read from CA file '%s': %s",
- ca_file,
- Curl_winapi_strerror(GetLastError(), buffer, sizeof(buffer)));
+ ca_file,
+ Curl_winapi_strerror(GetLastError(), buffer, sizeof(buffer)));
result = CURLE_SSL_CACERT_BADFILE;
goto cleanup;
}
@@ -227,7 +227,7 @@ static CURLcode add_certs_to_store(HCERTSTORE trust_store,
"schannel: failed to extract certificate from CA file "
"'%s': %s",
ca_file,
- Curl_winapi_strerror(GetLastError(), buffer, sizeof(buffer)));
+ Curl_winapi_strerror(GetLastError(), buffer, sizeof(buffer)));
result = CURLE_SSL_CACERT_BADFILE;
more_certs = 0;
}
@@ -256,8 +256,8 @@ static CURLcode add_certs_to_store(HCERTSTORE trust_store,
"schannel: failed to add certificate from CA file '%s' "
"to certificate store: %s",
ca_file,
- Curl_winapi_strerror(GetLastError(), buffer,
- sizeof(buffer)));
+ Curl_winapi_strerror(GetLastError(), buffer,
+ sizeof(buffer)));
result = CURLE_SSL_CACERT_BADFILE;
more_certs = 0;
}
@@ -288,138 +288,138 @@ cleanup:
CloseHandle(ca_file_handle);
}
Curl_safefree(ca_file_buffer);
- curlx_unicodefree(ca_file_tstr);
+ curlx_unicodefree(ca_file_tstr);
return result;
}
-/*
- * Returns the number of characters necessary to populate all the host_names.
- * If host_names is not NULL, populate it with all the host names. Each string
- * in the host_names is null-terminated and the last string is double
- * null-terminated. If no DNS names are found, a single null-terminated empty
- * string is returned.
- */
-static DWORD cert_get_name_string(struct Curl_easy *data,
- CERT_CONTEXT *cert_context,
- LPTSTR host_names,
- DWORD length)
-{
- DWORD actual_length = 0;
- BOOL compute_content = FALSE;
- CERT_INFO *cert_info = NULL;
- CERT_EXTENSION *extension = NULL;
- CRYPT_DECODE_PARA decode_para = {0, 0, 0};
- CERT_ALT_NAME_INFO *alt_name_info = NULL;
- DWORD alt_name_info_size = 0;
- BOOL ret_val = FALSE;
- LPTSTR current_pos = NULL;
- DWORD i;
-
- /* CERT_NAME_SEARCH_ALL_NAMES_FLAG is available from Windows 8 onwards. */
- if(curlx_verify_windows_version(6, 2, PLATFORM_WINNT,
- VERSION_GREATER_THAN_EQUAL)) {
-#ifdef CERT_NAME_SEARCH_ALL_NAMES_FLAG
- /* CertGetNameString will provide the 8-bit character string without
- * any decoding */
- DWORD name_flags =
- CERT_NAME_DISABLE_IE4_UTF8_FLAG | CERT_NAME_SEARCH_ALL_NAMES_FLAG;
- actual_length = CertGetNameString(cert_context,
- CERT_NAME_DNS_TYPE,
- name_flags,
- NULL,
- host_names,
- length);
- return actual_length;
-#endif
- }
-
- compute_content = host_names != NULL && length != 0;
-
- /* Initialize default return values. */
- actual_length = 1;
- if(compute_content) {
- *host_names = '\0';
- }
-
- if(!cert_context) {
- failf(data, "schannel: Null certificate context.");
- return actual_length;
- }
-
- cert_info = cert_context->pCertInfo;
- if(!cert_info) {
- failf(data, "schannel: Null certificate info.");
- return actual_length;
- }
-
- extension = CertFindExtension(szOID_SUBJECT_ALT_NAME2,
- cert_info->cExtension,
- cert_info->rgExtension);
- if(!extension) {
- failf(data, "schannel: CertFindExtension() returned no extension.");
- return actual_length;
- }
-
- decode_para.cbSize = sizeof(CRYPT_DECODE_PARA);
-
- ret_val =
- CryptDecodeObjectEx(X509_ASN_ENCODING | PKCS_7_ASN_ENCODING,
- szOID_SUBJECT_ALT_NAME2,
- extension->Value.pbData,
- extension->Value.cbData,
- CRYPT_DECODE_ALLOC_FLAG | CRYPT_DECODE_NOCOPY_FLAG,
- &decode_para,
- &alt_name_info,
- &alt_name_info_size);
- if(!ret_val) {
- failf(data,
- "schannel: CryptDecodeObjectEx() returned no alternate name "
- "information.");
- return actual_length;
- }
-
- current_pos = host_names;
-
- /* Iterate over the alternate names and populate host_names. */
- for(i = 0; i < alt_name_info->cAltEntry; i++) {
- const CERT_ALT_NAME_ENTRY *entry = &alt_name_info->rgAltEntry[i];
- wchar_t *dns_w = NULL;
- size_t current_length = 0;
-
- if(entry->dwAltNameChoice != CERT_ALT_NAME_DNS_NAME) {
- continue;
- }
- if(entry->pwszDNSName == NULL) {
- infof(data, "schannel: Empty DNS name.");
- continue;
- }
- current_length = wcslen(entry->pwszDNSName) + 1;
- if(!compute_content) {
- actual_length += (DWORD)current_length;
- continue;
- }
- /* Sanity check to prevent buffer overrun. */
- if((actual_length + current_length) > length) {
- failf(data, "schannel: Not enough memory to list all host names.");
- break;
- }
- dns_w = entry->pwszDNSName;
- /* pwszDNSName is in ia5 string format and hence doesn't contain any
- * non-ascii characters. */
- while(*dns_w != '\0') {
- *current_pos++ = (char)(*dns_w++);
- }
- *current_pos++ = '\0';
- actual_length += (DWORD)current_length;
- }
- if(compute_content) {
- /* Last string has double null-terminator. */
- *current_pos = '\0';
- }
- return actual_length;
-}
-
+/*
+ * Returns the number of characters necessary to populate all the host_names.
+ * If host_names is not NULL, populate it with all the host names. Each string
+ * in the host_names is null-terminated and the last string is double
+ * null-terminated. If no DNS names are found, a single null-terminated empty
+ * string is returned.
+ */
+static DWORD cert_get_name_string(struct Curl_easy *data,
+ CERT_CONTEXT *cert_context,
+ LPTSTR host_names,
+ DWORD length)
+{
+ DWORD actual_length = 0;
+ BOOL compute_content = FALSE;
+ CERT_INFO *cert_info = NULL;
+ CERT_EXTENSION *extension = NULL;
+ CRYPT_DECODE_PARA decode_para = {0, 0, 0};
+ CERT_ALT_NAME_INFO *alt_name_info = NULL;
+ DWORD alt_name_info_size = 0;
+ BOOL ret_val = FALSE;
+ LPTSTR current_pos = NULL;
+ DWORD i;
+
+ /* CERT_NAME_SEARCH_ALL_NAMES_FLAG is available from Windows 8 onwards. */
+ if(curlx_verify_windows_version(6, 2, PLATFORM_WINNT,
+ VERSION_GREATER_THAN_EQUAL)) {
+#ifdef CERT_NAME_SEARCH_ALL_NAMES_FLAG
+ /* CertGetNameString will provide the 8-bit character string without
+ * any decoding */
+ DWORD name_flags =
+ CERT_NAME_DISABLE_IE4_UTF8_FLAG | CERT_NAME_SEARCH_ALL_NAMES_FLAG;
+ actual_length = CertGetNameString(cert_context,
+ CERT_NAME_DNS_TYPE,
+ name_flags,
+ NULL,
+ host_names,
+ length);
+ return actual_length;
+#endif
+ }
+
+ compute_content = host_names != NULL && length != 0;
+
+ /* Initialize default return values. */
+ actual_length = 1;
+ if(compute_content) {
+ *host_names = '\0';
+ }
+
+ if(!cert_context) {
+ failf(data, "schannel: Null certificate context.");
+ return actual_length;
+ }
+
+ cert_info = cert_context->pCertInfo;
+ if(!cert_info) {
+ failf(data, "schannel: Null certificate info.");
+ return actual_length;
+ }
+
+ extension = CertFindExtension(szOID_SUBJECT_ALT_NAME2,
+ cert_info->cExtension,
+ cert_info->rgExtension);
+ if(!extension) {
+ failf(data, "schannel: CertFindExtension() returned no extension.");
+ return actual_length;
+ }
+
+ decode_para.cbSize = sizeof(CRYPT_DECODE_PARA);
+
+ ret_val =
+ CryptDecodeObjectEx(X509_ASN_ENCODING | PKCS_7_ASN_ENCODING,
+ szOID_SUBJECT_ALT_NAME2,
+ extension->Value.pbData,
+ extension->Value.cbData,
+ CRYPT_DECODE_ALLOC_FLAG | CRYPT_DECODE_NOCOPY_FLAG,
+ &decode_para,
+ &alt_name_info,
+ &alt_name_info_size);
+ if(!ret_val) {
+ failf(data,
+ "schannel: CryptDecodeObjectEx() returned no alternate name "
+ "information.");
+ return actual_length;
+ }
+
+ current_pos = host_names;
+
+ /* Iterate over the alternate names and populate host_names. */
+ for(i = 0; i < alt_name_info->cAltEntry; i++) {
+ const CERT_ALT_NAME_ENTRY *entry = &alt_name_info->rgAltEntry[i];
+ wchar_t *dns_w = NULL;
+ size_t current_length = 0;
+
+ if(entry->dwAltNameChoice != CERT_ALT_NAME_DNS_NAME) {
+ continue;
+ }
+ if(entry->pwszDNSName == NULL) {
+ infof(data, "schannel: Empty DNS name.");
+ continue;
+ }
+ current_length = wcslen(entry->pwszDNSName) + 1;
+ if(!compute_content) {
+ actual_length += (DWORD)current_length;
+ continue;
+ }
+ /* Sanity check to prevent buffer overrun. */
+ if((actual_length + current_length) > length) {
+ failf(data, "schannel: Not enough memory to list all host names.");
+ break;
+ }
+ dns_w = entry->pwszDNSName;
+ /* pwszDNSName is in ia5 string format and hence doesn't contain any
+ * non-ascii characters. */
+ while(*dns_w != '\0') {
+ *current_pos++ = (char)(*dns_w++);
+ }
+ *current_pos++ = '\0';
+ actual_length += (DWORD)current_length;
+ }
+ if(compute_content) {
+ /* Last string has double null-terminator. */
+ *current_pos = '\0';
+ }
+ return actual_length;
+}
+
static CURLcode verify_host(struct Curl_easy *data,
CERT_CONTEXT *pCertContextServer,
const char * const conn_hostname)
@@ -431,7 +431,7 @@ static CURLcode verify_host(struct Curl_easy *data,
DWORD actual_len = 0;
/* Determine the size of the string needed for the cert hostname */
- len = cert_get_name_string(data, pCertContextServer, NULL, 0);
+ len = cert_get_name_string(data, pCertContextServer, NULL, 0);
if(len == 0) {
failf(data,
"schannel: CertGetNameString() returned no "
@@ -448,8 +448,8 @@ static CURLcode verify_host(struct Curl_easy *data,
result = CURLE_OUT_OF_MEMORY;
goto cleanup;
}
- actual_len = cert_get_name_string(
- data, pCertContextServer, (LPTSTR)cert_hostname_buff, len);
+ actual_len = cert_get_name_string(
+ data, pCertContextServer, (LPTSTR)cert_hostname_buff, len);
/* Sanity check */
if(actual_len != len) {
@@ -476,7 +476,7 @@ static CURLcode verify_host(struct Curl_easy *data,
* is acceptable since both values are assumed to use ASCII
* (or some equivalent) encoding
*/
- cert_hostname = curlx_convert_tchar_to_UTF8(
+ cert_hostname = curlx_convert_tchar_to_UTF8(
&cert_hostname_buff[cert_hostname_buff_index]);
if(!cert_hostname) {
result = CURLE_OUT_OF_MEMORY;
@@ -508,7 +508,7 @@ static CURLcode verify_host(struct Curl_easy *data,
result = CURLE_PEER_FAILED_VERIFICATION;
}
- curlx_unicodefree(cert_hostname);
+ curlx_unicodefree(cert_hostname);
}
}
@@ -522,7 +522,7 @@ static CURLcode verify_host(struct Curl_easy *data,
failf(data, "schannel: server certificate name verification failed");
cleanup:
- curlx_unicodefree(cert_hostname_buff);
+ curlx_unicodefree(cert_hostname_buff);
return result;
}
@@ -537,13 +537,13 @@ CURLcode Curl_verify_certificate(struct connectdata *conn, int sockindex)
const CERT_CHAIN_CONTEXT *pChainContext = NULL;
HCERTCHAINENGINE cert_chain_engine = NULL;
HCERTSTORE trust_store = NULL;
-#ifndef CURL_DISABLE_PROXY
+#ifndef CURL_DISABLE_PROXY
const char * const conn_hostname = SSL_IS_PROXY() ?
conn->http_proxy.host.name :
conn->host.name;
-#else
- const char * const conn_hostname = conn->host.name;
-#endif
+#else
+ const char * const conn_hostname = conn->host.name;
+#endif
sspi_status =
s_pSecFn->QueryContextAttributes(&BACKEND->ctxt->ctxt_handle,
@@ -564,7 +564,7 @@ CURLcode Curl_verify_certificate(struct connectdata *conn, int sockindex)
* trusted certificates. This is only supported on Windows 7+.
*/
- if(curlx_verify_windows_version(6, 1, PLATFORM_WINNT, VERSION_LESS_THAN)) {
+ if(curlx_verify_windows_version(6, 1, PLATFORM_WINNT, VERSION_LESS_THAN)) {
failf(data, "schannel: this version of Windows is too old to support "
"certificate verification via CA bundle file.");
result = CURLE_SSL_CACERT_BADFILE;
@@ -579,7 +579,7 @@ CURLcode Curl_verify_certificate(struct connectdata *conn, int sockindex)
if(!trust_store) {
char buffer[STRERROR_LEN];
failf(data, "schannel: failed to create certificate store: %s",
- Curl_winapi_strerror(GetLastError(), buffer, sizeof(buffer)));
+ Curl_winapi_strerror(GetLastError(), buffer, sizeof(buffer)));
result = CURLE_SSL_CACERT_BADFILE;
}
else {
@@ -589,7 +589,7 @@ CURLcode Curl_verify_certificate(struct connectdata *conn, int sockindex)
}
if(result == CURLE_OK) {
- struct cert_chain_engine_config_win7 engine_config;
+ struct cert_chain_engine_config_win7 engine_config;
BOOL create_engine_result;
memset(&engine_config, 0, sizeof(engine_config));
@@ -608,7 +608,7 @@ CURLcode Curl_verify_certificate(struct connectdata *conn, int sockindex)
char buffer[STRERROR_LEN];
failf(data,
"schannel: failed to create certificate chain engine: %s",
- Curl_winapi_strerror(GetLastError(), buffer, sizeof(buffer)));
+ Curl_winapi_strerror(GetLastError(), buffer, sizeof(buffer)));
result = CURLE_SSL_CACERT_BADFILE;
}
}
@@ -631,7 +631,7 @@ CURLcode Curl_verify_certificate(struct connectdata *conn, int sockindex)
&pChainContext)) {
char buffer[STRERROR_LEN];
failf(data, "schannel: CertGetCertificateChain failed: %s",
- Curl_winapi_strerror(GetLastError(), buffer, sizeof(buffer)));
+ Curl_winapi_strerror(GetLastError(), buffer, sizeof(buffer)));
pChainContext = NULL;
result = CURLE_PEER_FAILED_VERIFICATION;
}
@@ -640,15 +640,15 @@ CURLcode Curl_verify_certificate(struct connectdata *conn, int sockindex)
CERT_SIMPLE_CHAIN *pSimpleChain = pChainContext->rgpChain[0];
DWORD dwTrustErrorMask = ~(DWORD)(CERT_TRUST_IS_NOT_TIME_NESTED);
dwTrustErrorMask &= pSimpleChain->TrustStatus.dwErrorStatus;
-
- if(data->set.ssl.revoke_best_effort) {
- /* Ignore errors when root certificates are missing the revocation
- * list URL, or when the list could not be downloaded because the
- * server is currently unreachable. */
- dwTrustErrorMask &= ~(DWORD)(CERT_TRUST_REVOCATION_STATUS_UNKNOWN |
- CERT_TRUST_IS_OFFLINE_REVOCATION);
- }
-
+
+ if(data->set.ssl.revoke_best_effort) {
+ /* Ignore errors when root certificates are missing the revocation
+ * list URL, or when the list could not be downloaded because the
+ * server is currently unreachable. */
+ dwTrustErrorMask &= ~(DWORD)(CERT_TRUST_REVOCATION_STATUS_UNKNOWN |
+ CERT_TRUST_IS_OFFLINE_REVOCATION);
+ }
+
if(dwTrustErrorMask) {
if(dwTrustErrorMask & CERT_TRUST_IS_REVOKED)
failf(data, "schannel: CertGetCertificateChain trust error"
diff --git a/contrib/libs/curl/lib/vtls/sectransp.c b/contrib/libs/curl/lib/vtls/sectransp.c
index d2e6eabc33..8ef60cb1f3 100644
--- a/contrib/libs/curl/lib/vtls/sectransp.c
+++ b/contrib/libs/curl/lib/vtls/sectransp.c
@@ -6,11 +6,11 @@
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2012 - 2017, Nick Zitzmann, <nickzman@gmail.com>.
- * Copyright (C) 2012 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2012 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -79,7 +79,7 @@
/* These macros mean "the following code is present to allow runtime backward
compatibility with at least this cat or earlier":
(You set this at build-time using the compiler command line option
- "-mmacosx-version-min.") */
+ "-mmacosx-version-min.") */
#define CURL_SUPPORT_MAC_10_5 MAC_OS_X_VERSION_MIN_REQUIRED <= 1050
#define CURL_SUPPORT_MAC_10_6 MAC_OS_X_VERSION_MIN_REQUIRED <= 1060
#define CURL_SUPPORT_MAC_10_7 MAC_OS_X_VERSION_MIN_REQUIRED <= 1070
@@ -199,8 +199,8 @@ static OSStatus SocketRead(SSLConnectionRef connection,
UInt8 *currData = (UInt8 *)data;
/*int sock = *(int *)connection;*/
struct ssl_connect_data *connssl = (struct ssl_connect_data *)connection;
- struct ssl_backend_data *backend = connssl->backend;
- int sock = backend->ssl_sockfd;
+ struct ssl_backend_data *backend = connssl->backend;
+ int sock = backend->ssl_sockfd;
OSStatus rtn = noErr;
size_t bytesRead;
ssize_t rrtn;
@@ -229,7 +229,7 @@ static OSStatus SocketRead(SSLConnectionRef connection,
break;
case EAGAIN:
rtn = errSSLWouldBlock;
- backend->ssl_direction = false;
+ backend->ssl_direction = false;
break;
default:
rtn = ioErr;
@@ -260,8 +260,8 @@ static OSStatus SocketWrite(SSLConnectionRef connection,
size_t bytesSent = 0;
/*int sock = *(int *)connection;*/
struct ssl_connect_data *connssl = (struct ssl_connect_data *)connection;
- struct ssl_backend_data *backend = connssl->backend;
- int sock = backend->ssl_sockfd;
+ struct ssl_backend_data *backend = connssl->backend;
+ int sock = backend->ssl_sockfd;
ssize_t length;
size_t dataLen = *dataLength;
const UInt8 *dataPtr = (UInt8 *)data;
@@ -281,7 +281,7 @@ static OSStatus SocketWrite(SSLConnectionRef connection,
theErr = errno;
if(theErr == EAGAIN) {
ortn = errSSLWouldBlock;
- backend->ssl_direction = true;
+ backend->ssl_direction = true;
}
else {
ortn = ioErr;
@@ -1126,12 +1126,12 @@ static OSStatus CopyIdentityWithLabel(char *label,
}
static OSStatus CopyIdentityFromPKCS12File(const char *cPath,
- const struct curl_blob *blob,
+ const struct curl_blob *blob,
const char *cPassword,
SecIdentityRef *out_cert_and_key)
{
OSStatus status = errSecItemNotFound;
- CFURLRef pkcs_url = NULL;
+ CFURLRef pkcs_url = NULL;
CFStringRef password = cPassword ? CFStringCreateWithCString(NULL,
cPassword, kCFStringEncodingUTF8) : NULL;
CFDataRef pkcs_data = NULL;
@@ -1140,26 +1140,26 @@ static OSStatus CopyIdentityFromPKCS12File(const char *cPath,
/* These constants are documented as having first appeared in 10.6 but they
raise linker errors when used on that cat for some reason. */
#if CURL_BUILD_MAC_10_7 || CURL_BUILD_IOS
- bool resource_imported;
-
- if(blob) {
- pkcs_data = CFDataCreate(kCFAllocatorDefault,
- (const unsigned char *)blob->data, blob->len);
- status = (pkcs_data != NULL) ? errSecSuccess : errSecAllocate;
- resource_imported = (pkcs_data != NULL);
- }
- else {
- pkcs_url =
- CFURLCreateFromFileSystemRepresentation(NULL,
- (const UInt8 *)cPath,
- strlen(cPath), false);
- resource_imported =
- CFURLCreateDataAndPropertiesFromResource(NULL,
- pkcs_url, &pkcs_data,
- NULL, NULL, &status);
- }
-
- if(resource_imported) {
+ bool resource_imported;
+
+ if(blob) {
+ pkcs_data = CFDataCreate(kCFAllocatorDefault,
+ (const unsigned char *)blob->data, blob->len);
+ status = (pkcs_data != NULL) ? errSecSuccess : errSecAllocate;
+ resource_imported = (pkcs_data != NULL);
+ }
+ else {
+ pkcs_url =
+ CFURLCreateFromFileSystemRepresentation(NULL,
+ (const UInt8 *)cPath,
+ strlen(cPath), false);
+ resource_imported =
+ CFURLCreateDataAndPropertiesFromResource(NULL,
+ pkcs_url, &pkcs_data,
+ NULL, NULL, &status);
+ }
+
+ if(resource_imported) {
CFArrayRef items = NULL;
/* On iOS SecPKCS12Import will never add the client certificate to the
@@ -1182,7 +1182,7 @@ static OSStatus CopyIdentityFromPKCS12File(const char *cPath,
* the Keychain.
*
* As this doesn't match iOS, and apps may not want to see their client
- * certificate saved in the user's keychain, we use SecItemImport
+ * certificate saved in the user's keychain, we use SecItemImport
* with a NULL keychain to avoid importing it.
*
* This returns a SecCertificateRef from which we can construct a
@@ -1237,8 +1237,8 @@ static OSStatus CopyIdentityFromPKCS12File(const char *cPath,
#endif /* CURL_BUILD_MAC_10_7 || CURL_BUILD_IOS */
if(password)
CFRelease(password);
- if(pkcs_url)
- CFRelease(pkcs_url);
+ if(pkcs_url)
+ CFRelease(pkcs_url);
return status;
}
@@ -1295,7 +1295,7 @@ set_ssl_version_min_max(struct connectdata *conn, int sockindex)
{
struct Curl_easy *data = conn->data;
struct ssl_connect_data *connssl = &conn->ssl[sockindex];
- struct ssl_backend_data *backend = connssl->backend;
+ struct ssl_backend_data *backend = connssl->backend;
long ssl_version = SSL_CONN_CONFIG(version);
long ssl_version_max = SSL_CONN_CONFIG(version_max);
long max_supported_version_by_os;
@@ -1346,30 +1346,30 @@ set_ssl_version_min_max(struct connectdata *conn, int sockindex)
return result;
}
- (void)SSLSetProtocolVersionMin(backend->ssl_ctx, darwin_ver_min);
- (void)SSLSetProtocolVersionMax(backend->ssl_ctx, darwin_ver_max);
+ (void)SSLSetProtocolVersionMin(backend->ssl_ctx, darwin_ver_min);
+ (void)SSLSetProtocolVersionMax(backend->ssl_ctx, darwin_ver_max);
return result;
}
else {
#if CURL_SUPPORT_MAC_10_8
long i = ssl_version;
- (void)SSLSetProtocolVersionEnabled(backend->ssl_ctx,
+ (void)SSLSetProtocolVersionEnabled(backend->ssl_ctx,
kSSLProtocolAll,
false);
for(; i <= (ssl_version_max >> 16); i++) {
switch(i) {
case CURL_SSLVERSION_TLSv1_0:
- (void)SSLSetProtocolVersionEnabled(backend->ssl_ctx,
+ (void)SSLSetProtocolVersionEnabled(backend->ssl_ctx,
kTLSProtocol1,
true);
break;
case CURL_SSLVERSION_TLSv1_1:
- (void)SSLSetProtocolVersionEnabled(backend->ssl_ctx,
+ (void)SSLSetProtocolVersionEnabled(backend->ssl_ctx,
kTLSProtocol11,
true);
break;
case CURL_SSLVERSION_TLSv1_2:
- (void)SSLSetProtocolVersionEnabled(backend->ssl_ctx,
+ (void)SSLSetProtocolVersionEnabled(backend->ssl_ctx,
kTLSProtocol12,
true);
break;
@@ -1393,20 +1393,20 @@ static CURLcode sectransp_connect_step1(struct connectdata *conn,
struct Curl_easy *data = conn->data;
curl_socket_t sockfd = conn->sock[sockindex];
struct ssl_connect_data *connssl = &conn->ssl[sockindex];
- struct ssl_backend_data *backend = connssl->backend;
+ struct ssl_backend_data *backend = connssl->backend;
const char * const ssl_cafile = SSL_CONN_CONFIG(CAfile);
- const struct curl_blob *ssl_cablob = NULL;
+ const struct curl_blob *ssl_cablob = NULL;
const bool verifypeer = SSL_CONN_CONFIG(verifypeer);
- char * const ssl_cert = SSL_SET_OPTION(primary.clientcert);
- const struct curl_blob *ssl_cert_blob = SSL_SET_OPTION(primary.cert_blob);
-#ifndef CURL_DISABLE_PROXY
+ char * const ssl_cert = SSL_SET_OPTION(primary.clientcert);
+ const struct curl_blob *ssl_cert_blob = SSL_SET_OPTION(primary.cert_blob);
+#ifndef CURL_DISABLE_PROXY
const char * const hostname = SSL_IS_PROXY() ? conn->http_proxy.host.name :
conn->host.name;
const long int port = SSL_IS_PROXY() ? conn->port : conn->remote_port;
-#else
- const char * const hostname = conn->host.name;
- const long int port = conn->remote_port;
-#endif
+#else
+ const char * const hostname = conn->host.name;
+ const long int port = conn->remote_port;
+#endif
#ifdef ENABLE_IPV6
struct in6_addr addr;
#else
@@ -1423,10 +1423,10 @@ static CURLcode sectransp_connect_step1(struct connectdata *conn,
#if CURL_BUILD_MAC_10_8 || CURL_BUILD_IOS
if(SSLCreateContext != NULL) { /* use the newer API if available */
- if(backend->ssl_ctx)
- CFRelease(backend->ssl_ctx);
- backend->ssl_ctx = SSLCreateContext(NULL, kSSLClientSide, kSSLStreamType);
- if(!backend->ssl_ctx) {
+ if(backend->ssl_ctx)
+ CFRelease(backend->ssl_ctx);
+ backend->ssl_ctx = SSLCreateContext(NULL, kSSLClientSide, kSSLStreamType);
+ if(!backend->ssl_ctx) {
failf(data, "SSL: couldn't create a context!");
return CURLE_OUT_OF_MEMORY;
}
@@ -1434,9 +1434,9 @@ static CURLcode sectransp_connect_step1(struct connectdata *conn,
else {
/* The old ST API does not exist under iOS, so don't compile it: */
#if CURL_SUPPORT_MAC_10_8
- if(backend->ssl_ctx)
- (void)SSLDisposeContext(backend->ssl_ctx);
- err = SSLNewContext(false, &(backend->ssl_ctx));
+ if(backend->ssl_ctx)
+ (void)SSLDisposeContext(backend->ssl_ctx);
+ err = SSLNewContext(false, &(backend->ssl_ctx));
if(err != noErr) {
failf(data, "SSL: couldn't create a context: OSStatus %d", err);
return CURLE_OUT_OF_MEMORY;
@@ -1444,31 +1444,31 @@ static CURLcode sectransp_connect_step1(struct connectdata *conn,
#endif /* CURL_SUPPORT_MAC_10_8 */
}
#else
- if(backend->ssl_ctx)
- (void)SSLDisposeContext(backend->ssl_ctx);
- err = SSLNewContext(false, &(backend->ssl_ctx));
+ if(backend->ssl_ctx)
+ (void)SSLDisposeContext(backend->ssl_ctx);
+ err = SSLNewContext(false, &(backend->ssl_ctx));
if(err != noErr) {
failf(data, "SSL: couldn't create a context: OSStatus %d", err);
return CURLE_OUT_OF_MEMORY;
}
#endif /* CURL_BUILD_MAC_10_8 || CURL_BUILD_IOS */
- backend->ssl_write_buffered_length = 0UL; /* reset buffered write length */
+ backend->ssl_write_buffered_length = 0UL; /* reset buffered write length */
/* check to see if we've been told to use an explicit SSL/TLS version */
#if CURL_BUILD_MAC_10_8 || CURL_BUILD_IOS
if(SSLSetProtocolVersionMax != NULL) {
switch(conn->ssl_config.version) {
case CURL_SSLVERSION_TLSv1:
- (void)SSLSetProtocolVersionMin(backend->ssl_ctx, kTLSProtocol1);
+ (void)SSLSetProtocolVersionMin(backend->ssl_ctx, kTLSProtocol1);
#if (CURL_BUILD_MAC_10_13 || CURL_BUILD_IOS_11) && HAVE_BUILTIN_AVAILABLE == 1
if(__builtin_available(macOS 10.13, iOS 11.0, *)) {
- (void)SSLSetProtocolVersionMax(backend->ssl_ctx, kTLSProtocol13);
+ (void)SSLSetProtocolVersionMax(backend->ssl_ctx, kTLSProtocol13);
}
else {
- (void)SSLSetProtocolVersionMax(backend->ssl_ctx, kTLSProtocol12);
+ (void)SSLSetProtocolVersionMax(backend->ssl_ctx, kTLSProtocol12);
}
#else
- (void)SSLSetProtocolVersionMax(backend->ssl_ctx, kTLSProtocol12);
+ (void)SSLSetProtocolVersionMax(backend->ssl_ctx, kTLSProtocol12);
#endif /* (CURL_BUILD_MAC_10_13 || CURL_BUILD_IOS_11) &&
HAVE_BUILTIN_AVAILABLE == 1 */
break;
@@ -1484,20 +1484,20 @@ static CURLcode sectransp_connect_step1(struct connectdata *conn,
break;
}
case CURL_SSLVERSION_SSLv3:
- err = SSLSetProtocolVersionMin(backend->ssl_ctx, kSSLProtocol3);
+ err = SSLSetProtocolVersionMin(backend->ssl_ctx, kSSLProtocol3);
if(err != noErr) {
failf(data, "Your version of the OS does not support SSLv3");
return CURLE_SSL_CONNECT_ERROR;
}
- (void)SSLSetProtocolVersionMax(backend->ssl_ctx, kSSLProtocol3);
+ (void)SSLSetProtocolVersionMax(backend->ssl_ctx, kSSLProtocol3);
break;
case CURL_SSLVERSION_SSLv2:
- err = SSLSetProtocolVersionMin(backend->ssl_ctx, kSSLProtocol2);
+ err = SSLSetProtocolVersionMin(backend->ssl_ctx, kSSLProtocol2);
if(err != noErr) {
failf(data, "Your version of the OS does not support SSLv2");
return CURLE_SSL_CONNECT_ERROR;
}
- (void)SSLSetProtocolVersionMax(backend->ssl_ctx, kSSLProtocol2);
+ (void)SSLSetProtocolVersionMax(backend->ssl_ctx, kSSLProtocol2);
break;
default:
failf(data, "Unrecognized parameter passed via CURLOPT_SSLVERSION");
@@ -1506,19 +1506,19 @@ static CURLcode sectransp_connect_step1(struct connectdata *conn,
}
else {
#if CURL_SUPPORT_MAC_10_8
- (void)SSLSetProtocolVersionEnabled(backend->ssl_ctx,
+ (void)SSLSetProtocolVersionEnabled(backend->ssl_ctx,
kSSLProtocolAll,
false);
switch(conn->ssl_config.version) {
case CURL_SSLVERSION_DEFAULT:
case CURL_SSLVERSION_TLSv1:
- (void)SSLSetProtocolVersionEnabled(backend->ssl_ctx,
+ (void)SSLSetProtocolVersionEnabled(backend->ssl_ctx,
kTLSProtocol1,
true);
- (void)SSLSetProtocolVersionEnabled(backend->ssl_ctx,
+ (void)SSLSetProtocolVersionEnabled(backend->ssl_ctx,
kTLSProtocol11,
true);
- (void)SSLSetProtocolVersionEnabled(backend->ssl_ctx,
+ (void)SSLSetProtocolVersionEnabled(backend->ssl_ctx,
kTLSProtocol12,
true);
break;
@@ -1533,7 +1533,7 @@ static CURLcode sectransp_connect_step1(struct connectdata *conn,
break;
}
case CURL_SSLVERSION_SSLv3:
- err = SSLSetProtocolVersionEnabled(backend->ssl_ctx,
+ err = SSLSetProtocolVersionEnabled(backend->ssl_ctx,
kSSLProtocol3,
true);
if(err != noErr) {
@@ -1542,7 +1542,7 @@ static CURLcode sectransp_connect_step1(struct connectdata *conn,
}
break;
case CURL_SSLVERSION_SSLv2:
- err = SSLSetProtocolVersionEnabled(backend->ssl_ctx,
+ err = SSLSetProtocolVersionEnabled(backend->ssl_ctx,
kSSLProtocol2,
true);
if(err != noErr) {
@@ -1562,12 +1562,12 @@ static CURLcode sectransp_connect_step1(struct connectdata *conn,
" SSL/TLS version");
return CURLE_SSL_CONNECT_ERROR;
}
- (void)SSLSetProtocolVersionEnabled(backend->ssl_ctx, kSSLProtocolAll, false);
+ (void)SSLSetProtocolVersionEnabled(backend->ssl_ctx, kSSLProtocolAll, false);
switch(conn->ssl_config.version) {
case CURL_SSLVERSION_DEFAULT:
case CURL_SSLVERSION_TLSv1:
case CURL_SSLVERSION_TLSv1_0:
- (void)SSLSetProtocolVersionEnabled(backend->ssl_ctx,
+ (void)SSLSetProtocolVersionEnabled(backend->ssl_ctx,
kTLSProtocol1,
true);
break;
@@ -1581,7 +1581,7 @@ static CURLcode sectransp_connect_step1(struct connectdata *conn,
failf(data, "Your version of the OS does not support TLSv1.3");
return CURLE_SSL_CONNECT_ERROR;
case CURL_SSLVERSION_SSLv2:
- err = SSLSetProtocolVersionEnabled(backend->ssl_ctx,
+ err = SSLSetProtocolVersionEnabled(backend->ssl_ctx,
kSSLProtocol2,
true);
if(err != noErr) {
@@ -1590,7 +1590,7 @@ static CURLcode sectransp_connect_step1(struct connectdata *conn,
}
break;
case CURL_SSLVERSION_SSLv3:
- err = SSLSetProtocolVersionEnabled(backend->ssl_ctx,
+ err = SSLSetProtocolVersionEnabled(backend->ssl_ctx,
kSSLProtocol3,
true);
if(err != noErr) {
@@ -1611,11 +1611,11 @@ static CURLcode sectransp_connect_step1(struct connectdata *conn,
&kCFTypeArrayCallBacks);
#ifdef USE_NGHTTP2
- if(data->set.httpversion >= CURL_HTTP_VERSION_2
-#ifndef CURL_DISABLE_PROXY
- && (!SSL_IS_PROXY() || !conn->bits.tunnel_proxy)
-#endif
- ) {
+ if(data->set.httpversion >= CURL_HTTP_VERSION_2
+#ifndef CURL_DISABLE_PROXY
+ && (!SSL_IS_PROXY() || !conn->bits.tunnel_proxy)
+#endif
+ ) {
CFArrayAppendValue(alpnArr, CFSTR(NGHTTP2_PROTO_VERSION_ID));
infof(data, "ALPN, offering %s\n", NGHTTP2_PROTO_VERSION_ID);
}
@@ -1627,7 +1627,7 @@ static CURLcode sectransp_connect_step1(struct connectdata *conn,
/* expects length prefixed preference ordered list of protocols in wire
* format
*/
- err = SSLSetALPNProtocols(backend->ssl_ctx, alpnArr);
+ err = SSLSetALPNProtocols(backend->ssl_ctx, alpnArr);
if(err != noErr)
infof(data, "WARNING: failed to set ALPN protocols; OSStatus %d\n",
err);
@@ -1641,16 +1641,16 @@ static CURLcode sectransp_connect_step1(struct connectdata *conn,
"Transport. The private key must be in the Keychain.\n");
}
- if(ssl_cert || ssl_cert_blob) {
- bool is_cert_data = ssl_cert_blob != NULL;
- bool is_cert_file = (!is_cert_data) && is_file(ssl_cert);
+ if(ssl_cert || ssl_cert_blob) {
+ bool is_cert_data = ssl_cert_blob != NULL;
+ bool is_cert_file = (!is_cert_data) && is_file(ssl_cert);
SecIdentityRef cert_and_key = NULL;
/* User wants to authenticate with a client cert. Look for it:
If we detect that this is a file on disk, then let's load it.
Otherwise, assume that the user wants to use an identity loaded
from the Keychain. */
- if(is_cert_file || is_cert_data) {
+ if(is_cert_file || is_cert_data) {
if(!SSL_SET_OPTION(cert_type))
infof(data, "WARNING: SSL: Certificate type not set, assuming "
"PKCS#12 format.\n");
@@ -1659,7 +1659,7 @@ static CURLcode sectransp_connect_step1(struct connectdata *conn,
infof(data, "WARNING: SSL: The Security framework only supports "
"loading identities that are in PKCS#12 format.\n");
- err = CopyIdentityFromPKCS12File(ssl_cert, ssl_cert_blob,
+ err = CopyIdentityFromPKCS12File(ssl_cert, ssl_cert_blob,
SSL_SET_OPTION(key_passwd), &cert_and_key);
}
else
@@ -1689,7 +1689,7 @@ static CURLcode sectransp_connect_step1(struct connectdata *conn,
certs_c[0] = cert_and_key;
certs = CFArrayCreate(NULL, (const void **)certs_c, 1L,
&kCFTypeArrayCallBacks);
- err = SSLSetCertificate(backend->ssl_ctx, certs);
+ err = SSLSetCertificate(backend->ssl_ctx, certs);
if(certs)
CFRelease(certs);
if(err != noErr) {
@@ -1699,30 +1699,30 @@ static CURLcode sectransp_connect_step1(struct connectdata *conn,
CFRelease(cert_and_key);
}
else {
- const char *cert_showfilename_error =
- is_cert_data ? "(memory blob)" : ssl_cert;
-
+ const char *cert_showfilename_error =
+ is_cert_data ? "(memory blob)" : ssl_cert;
+
switch(err) {
case errSecAuthFailed: case -25264: /* errSecPkcs12VerifyFailure */
failf(data, "SSL: Incorrect password for the certificate \"%s\" "
- "and its private key.", cert_showfilename_error);
+ "and its private key.", cert_showfilename_error);
break;
case -26275: /* errSecDecode */ case -25257: /* errSecUnknownFormat */
failf(data, "SSL: Couldn't make sense of the data in the "
"certificate \"%s\" and its private key.",
- cert_showfilename_error);
+ cert_showfilename_error);
break;
case -25260: /* errSecPassphraseRequired */
failf(data, "SSL The certificate \"%s\" requires a password.",
- cert_showfilename_error);
+ cert_showfilename_error);
break;
case errSecItemNotFound:
failf(data, "SSL: Can't find the certificate \"%s\" and its private "
- "key in the Keychain.", cert_showfilename_error);
+ "key in the Keychain.", cert_showfilename_error);
break;
default:
failf(data, "SSL: Can't load the certificate \"%s\" and its private "
- "key: OSStatus %d", cert_showfilename_error, err);
+ "key: OSStatus %d", cert_showfilename_error, err);
break;
}
return CURLE_SSL_CERTPROBLEM;
@@ -1754,9 +1754,9 @@ static CURLcode sectransp_connect_step1(struct connectdata *conn,
#else
if(SSLSetSessionOption != NULL) {
#endif /* CURL_BUILD_MAC */
- bool break_on_auth = !conn->ssl_config.verifypeer ||
- ssl_cafile || ssl_cablob;
- err = SSLSetSessionOption(backend->ssl_ctx,
+ bool break_on_auth = !conn->ssl_config.verifypeer ||
+ ssl_cafile || ssl_cablob;
+ err = SSLSetSessionOption(backend->ssl_ctx,
kSSLSessionOptionBreakOnServerAuth,
break_on_auth);
if(err != noErr) {
@@ -1766,7 +1766,7 @@ static CURLcode sectransp_connect_step1(struct connectdata *conn,
}
else {
#if CURL_SUPPORT_MAC_10_8
- err = SSLSetEnableCertVerify(backend->ssl_ctx,
+ err = SSLSetEnableCertVerify(backend->ssl_ctx,
conn->ssl_config.verifypeer?true:false);
if(err != noErr) {
failf(data, "SSL: SSLSetEnableCertVerify() failed: OSStatus %d", err);
@@ -1775,7 +1775,7 @@ static CURLcode sectransp_connect_step1(struct connectdata *conn,
#endif /* CURL_SUPPORT_MAC_10_8 */
}
#else
- err = SSLSetEnableCertVerify(backend->ssl_ctx,
+ err = SSLSetEnableCertVerify(backend->ssl_ctx,
conn->ssl_config.verifypeer?true:false);
if(err != noErr) {
failf(data, "SSL: SSLSetEnableCertVerify() failed: OSStatus %d", err);
@@ -1783,11 +1783,11 @@ static CURLcode sectransp_connect_step1(struct connectdata *conn,
}
#endif /* CURL_BUILD_MAC_10_6 || CURL_BUILD_IOS */
- if((ssl_cafile || ssl_cablob) && verifypeer) {
- bool is_cert_data = ssl_cablob != NULL;
- bool is_cert_file = (!is_cert_data) && is_file(ssl_cafile);
+ if((ssl_cafile || ssl_cablob) && verifypeer) {
+ bool is_cert_data = ssl_cablob != NULL;
+ bool is_cert_file = (!is_cert_data) && is_file(ssl_cafile);
- if(!(is_cert_file || is_cert_data)) {
+ if(!(is_cert_file || is_cert_data)) {
failf(data, "SSL: can't load CA certificate file %s", ssl_cafile);
return CURLE_SSL_CACERT_BADFILE;
}
@@ -1797,7 +1797,7 @@ static CURLcode sectransp_connect_step1(struct connectdata *conn,
* Both hostname check and SNI require SSLSetPeerDomainName().
* Also: the verifyhost setting influences SNI usage */
if(conn->ssl_config.verifyhost) {
- err = SSLSetPeerDomainName(backend->ssl_ctx, hostname,
+ err = SSLSetPeerDomainName(backend->ssl_ctx, hostname,
strlen(hostname));
if(err != noErr) {
@@ -1823,7 +1823,7 @@ static CURLcode sectransp_connect_step1(struct connectdata *conn,
higher priority, but it's probably better that we not connect at all than
to give the user a false sense of security if the server only supports
insecure ciphers. (Note: We don't care about SSLv2-only ciphers.) */
- err = SSLGetNumberSupportedCiphers(backend->ssl_ctx, &all_ciphers_count);
+ err = SSLGetNumberSupportedCiphers(backend->ssl_ctx, &all_ciphers_count);
if(err != noErr) {
failf(data, "SSL: SSLGetNumberSupportedCiphers() failed: OSStatus %d",
err);
@@ -1840,7 +1840,7 @@ static CURLcode sectransp_connect_step1(struct connectdata *conn,
failf(data, "SSL: Failed to allocate memory for allowed ciphers");
return CURLE_OUT_OF_MEMORY;
}
- err = SSLGetSupportedCiphers(backend->ssl_ctx, all_ciphers,
+ err = SSLGetSupportedCiphers(backend->ssl_ctx, all_ciphers,
&all_ciphers_count);
if(err != noErr) {
Curl_safefree(all_ciphers);
@@ -1927,7 +1927,7 @@ static CURLcode sectransp_connect_step1(struct connectdata *conn,
break;
}
}
- err = SSLSetEnabledCiphers(backend->ssl_ctx, allowed_ciphers,
+ err = SSLSetEnabledCiphers(backend->ssl_ctx, allowed_ciphers,
allowed_ciphers_count);
Curl_safefree(all_ciphers);
Curl_safefree(allowed_ciphers);
@@ -1940,9 +1940,9 @@ static CURLcode sectransp_connect_step1(struct connectdata *conn,
/* We want to enable 1/n-1 when using a CBC cipher unless the user
specifically doesn't want us doing that: */
if(SSLSetSessionOption != NULL) {
- SSLSetSessionOption(backend->ssl_ctx, kSSLSessionOptionSendOneByteRecord,
+ SSLSetSessionOption(backend->ssl_ctx, kSSLSessionOptionSendOneByteRecord,
!data->set.ssl.enable_beast);
- SSLSetSessionOption(backend->ssl_ctx, kSSLSessionOptionFalseStart,
+ SSLSetSessionOption(backend->ssl_ctx, kSSLSessionOptionFalseStart,
data->set.ssl.falsestart); /* false start support */
}
#endif /* CURL_BUILD_MAC_10_9 || CURL_BUILD_IOS_7 */
@@ -1956,7 +1956,7 @@ static CURLcode sectransp_connect_step1(struct connectdata *conn,
if(!Curl_ssl_getsessionid(conn, (void **)&ssl_sessionid,
&ssl_sessionid_len, sockindex)) {
/* we got a session id, use it! */
- err = SSLSetPeerID(backend->ssl_ctx, ssl_sessionid, ssl_sessionid_len);
+ err = SSLSetPeerID(backend->ssl_ctx, ssl_sessionid, ssl_sessionid_len);
Curl_ssl_sessionid_unlock(conn);
if(err != noErr) {
failf(data, "SSL: SSLSetPeerID() failed: OSStatus %d", err);
@@ -1970,11 +1970,11 @@ static CURLcode sectransp_connect_step1(struct connectdata *conn,
else {
CURLcode result;
ssl_sessionid =
- aprintf("%s:%d:%d:%s:%ld", ssl_cafile,
+ aprintf("%s:%d:%d:%s:%ld", ssl_cafile,
verifypeer, SSL_CONN_CONFIG(verifyhost), hostname, port);
ssl_sessionid_len = strlen(ssl_sessionid);
- err = SSLSetPeerID(backend->ssl_ctx, ssl_sessionid, ssl_sessionid_len);
+ err = SSLSetPeerID(backend->ssl_ctx, ssl_sessionid, ssl_sessionid_len);
if(err != noErr) {
Curl_ssl_sessionid_unlock(conn);
failf(data, "SSL: SSLSetPeerID() failed: OSStatus %d", err);
@@ -1991,7 +1991,7 @@ static CURLcode sectransp_connect_step1(struct connectdata *conn,
}
}
- err = SSLSetIOFuncs(backend->ssl_ctx, SocketRead, SocketWrite);
+ err = SSLSetIOFuncs(backend->ssl_ctx, SocketRead, SocketWrite);
if(err != noErr) {
failf(data, "SSL: SSLSetIOFuncs() failed: OSStatus %d", err);
return CURLE_SSL_CONNECT_ERROR;
@@ -2001,8 +2001,8 @@ static CURLcode sectransp_connect_step1(struct connectdata *conn,
/* We need to store the FD in a constant memory address, because
* SSLSetConnection() will not copy that address. I've found that
* conn->sock[sockindex] may change on its own. */
- backend->ssl_sockfd = sockfd;
- err = SSLSetConnection(backend->ssl_ctx, connssl);
+ backend->ssl_sockfd = sockfd;
+ err = SSLSetConnection(backend->ssl_ctx, connssl);
if(err != noErr) {
failf(data, "SSL: SSLSetConnection() failed: %d", err);
return CURLE_SSL_CONNECT_ERROR;
@@ -2189,7 +2189,7 @@ static CURLcode verify_cert(const char *cafile, struct Curl_easy *data,
if(res < 0) {
free(certbuf);
CFRelease(array);
- failf(data, "SSL: invalid CA certificate #%d (offset %zu) in bundle",
+ failf(data, "SSL: invalid CA certificate #%d (offset %zu) in bundle",
n, offset);
return CURLE_SSL_CACERT_BADFILE;
}
@@ -2383,28 +2383,28 @@ sectransp_connect_step2(struct connectdata *conn, int sockindex)
{
struct Curl_easy *data = conn->data;
struct ssl_connect_data *connssl = &conn->ssl[sockindex];
- struct ssl_backend_data *backend = connssl->backend;
+ struct ssl_backend_data *backend = connssl->backend;
OSStatus err;
SSLCipherSuite cipher;
SSLProtocol protocol = 0;
-#ifndef CURL_DISABLE_PROXY
+#ifndef CURL_DISABLE_PROXY
const char * const hostname = SSL_IS_PROXY() ? conn->http_proxy.host.name :
conn->host.name;
-#else
- const char * const hostname = conn->host.name;
-#endif
+#else
+ const char * const hostname = conn->host.name;
+#endif
DEBUGASSERT(ssl_connect_2 == connssl->connecting_state
|| ssl_connect_2_reading == connssl->connecting_state
|| ssl_connect_2_writing == connssl->connecting_state);
/* Here goes nothing: */
- err = SSLHandshake(backend->ssl_ctx);
+ err = SSLHandshake(backend->ssl_ctx);
if(err != noErr) {
switch(err) {
case errSSLWouldBlock: /* they're not done with us yet */
- connssl->connecting_state = backend->ssl_direction ?
+ connssl->connecting_state = backend->ssl_direction ?
ssl_connect_2_writing : ssl_connect_2_reading;
return CURLE_OK;
@@ -2413,7 +2413,7 @@ sectransp_connect_step2(struct connectdata *conn, int sockindex)
case -9841:
if(SSL_CONN_CONFIG(CAfile) && SSL_CONN_CONFIG(verifypeer)) {
CURLcode result = verify_cert(SSL_CONN_CONFIG(CAfile), data,
- backend->ssl_ctx);
+ backend->ssl_ctx);
if(result)
return result;
}
@@ -2622,7 +2622,7 @@ sectransp_connect_step2(struct connectdata *conn, int sockindex)
#ifdef SECTRANSP_PINNEDPUBKEY
if(data->set.str[STRING_SSL_PINNEDPUBLICKEY_ORIG]) {
- CURLcode result = pkp_pin_peer_pubkey(data, backend->ssl_ctx,
+ CURLcode result = pkp_pin_peer_pubkey(data, backend->ssl_ctx,
data->set.str[STRING_SSL_PINNEDPUBLICKEY_ORIG]);
if(result) {
failf(data, "SSL: public key does not match pinned public key!");
@@ -2632,8 +2632,8 @@ sectransp_connect_step2(struct connectdata *conn, int sockindex)
#endif /* SECTRANSP_PINNEDPUBKEY */
/* Informational message */
- (void)SSLGetNegotiatedCipher(backend->ssl_ctx, &cipher);
- (void)SSLGetNegotiatedProtocolVersion(backend->ssl_ctx, &protocol);
+ (void)SSLGetNegotiatedCipher(backend->ssl_ctx, &cipher);
+ (void)SSLGetNegotiatedProtocolVersion(backend->ssl_ctx, &protocol);
switch(protocol) {
case kSSLProtocol2:
infof(data, "SSL 2.0 connection using %s\n",
@@ -2673,7 +2673,7 @@ sectransp_connect_step2(struct connectdata *conn, int sockindex)
if(__builtin_available(macOS 10.13.4, iOS 11, tvOS 11, *)) {
CFArrayRef alpnArr = NULL;
CFStringRef chosenProtocol = NULL;
- err = SSLCopyALPNProtocols(backend->ssl_ctx, &alpnArr);
+ err = SSLCopyALPNProtocols(backend->ssl_ctx, &alpnArr);
if(err == noErr && alpnArr && CFArrayGetCount(alpnArr) >= 1)
chosenProtocol = CFArrayGetValueAtIndex(alpnArr, 0);
@@ -2716,20 +2716,20 @@ show_verbose_server_cert(struct connectdata *conn,
{
struct Curl_easy *data = conn->data;
struct ssl_connect_data *connssl = &conn->ssl[sockindex];
- struct ssl_backend_data *backend = connssl->backend;
+ struct ssl_backend_data *backend = connssl->backend;
CFArrayRef server_certs = NULL;
SecCertificateRef server_cert;
OSStatus err;
CFIndex i, count;
SecTrustRef trust = NULL;
- if(!backend->ssl_ctx)
+ if(!backend->ssl_ctx)
return;
#if CURL_BUILD_MAC_10_7 || CURL_BUILD_IOS
#if CURL_BUILD_IOS
#pragma unused(server_certs)
- err = SSLCopyPeerTrust(backend->ssl_ctx, &trust);
+ err = SSLCopyPeerTrust(backend->ssl_ctx, &trust);
/* For some reason, SSLCopyPeerTrust() can return noErr and yet return
a null trust, so be on guard for that: */
if(err == noErr && trust) {
@@ -2755,7 +2755,7 @@ show_verbose_server_cert(struct connectdata *conn,
Lion or later. */
if(SecTrustEvaluateAsync != NULL) {
#pragma unused(server_certs)
- err = SSLCopyPeerTrust(backend->ssl_ctx, &trust);
+ err = SSLCopyPeerTrust(backend->ssl_ctx, &trust);
/* For some reason, SSLCopyPeerTrust() can return noErr and yet return
a null trust, so be on guard for that: */
if(err == noErr && trust) {
@@ -2775,7 +2775,7 @@ show_verbose_server_cert(struct connectdata *conn,
}
else {
#if CURL_SUPPORT_MAC_10_8
- err = SSLCopyPeerCertificates(backend->ssl_ctx, &server_certs);
+ err = SSLCopyPeerCertificates(backend->ssl_ctx, &server_certs);
/* Just in case SSLCopyPeerCertificates() returns null too... */
if(err == noErr && server_certs) {
count = CFArrayGetCount(server_certs);
@@ -2797,7 +2797,7 @@ show_verbose_server_cert(struct connectdata *conn,
#endif /* CURL_BUILD_IOS */
#else
#pragma unused(trust)
- err = SSLCopyPeerCertificates(backend->ssl_ctx, &server_certs);
+ err = SSLCopyPeerCertificates(backend->ssl_ctx, &server_certs);
if(err == noErr) {
count = CFArrayGetCount(server_certs);
for(i = 0L ; i < count ; i++) {
@@ -2858,7 +2858,7 @@ sectransp_connect_common(struct connectdata *conn,
if(ssl_connect_1 == connssl->connecting_state) {
/* Find out how much more time we're allowed */
- const timediff_t timeout_ms = Curl_timeleft(data, NULL, TRUE);
+ const timediff_t timeout_ms = Curl_timeleft(data, NULL, TRUE);
if(timeout_ms < 0) {
/* no need to continue if time already is up */
@@ -2876,7 +2876,7 @@ sectransp_connect_common(struct connectdata *conn,
ssl_connect_2_writing == connssl->connecting_state) {
/* check allowed time left */
- const timediff_t timeout_ms = Curl_timeleft(data, NULL, TRUE);
+ const timediff_t timeout_ms = Curl_timeleft(data, NULL, TRUE);
if(timeout_ms < 0) {
/* no need to continue if time already is up */
@@ -2894,7 +2894,7 @@ sectransp_connect_common(struct connectdata *conn,
connssl->connecting_state?sockfd:CURL_SOCKET_BAD;
what = Curl_socket_check(readfd, CURL_SOCKET_BAD, writefd,
- nonblocking ? 0 : timeout_ms);
+ nonblocking ? 0 : timeout_ms);
if(what < 0) {
/* fatal error */
failf(data, "select/poll on SSL socket, errno: %d", SOCKERRNO);
@@ -2975,36 +2975,36 @@ static CURLcode Curl_sectransp_connect(struct connectdata *conn, int sockindex)
static void Curl_sectransp_close(struct connectdata *conn, int sockindex)
{
struct ssl_connect_data *connssl = &conn->ssl[sockindex];
- struct ssl_backend_data *backend = connssl->backend;
+ struct ssl_backend_data *backend = connssl->backend;
- if(backend->ssl_ctx) {
- (void)SSLClose(backend->ssl_ctx);
+ if(backend->ssl_ctx) {
+ (void)SSLClose(backend->ssl_ctx);
#if CURL_BUILD_MAC_10_8 || CURL_BUILD_IOS
if(SSLCreateContext != NULL)
- CFRelease(backend->ssl_ctx);
+ CFRelease(backend->ssl_ctx);
#if CURL_SUPPORT_MAC_10_8
else
- (void)SSLDisposeContext(backend->ssl_ctx);
+ (void)SSLDisposeContext(backend->ssl_ctx);
#endif /* CURL_SUPPORT_MAC_10_8 */
#else
- (void)SSLDisposeContext(backend->ssl_ctx);
+ (void)SSLDisposeContext(backend->ssl_ctx);
#endif /* CURL_BUILD_MAC_10_8 || CURL_BUILD_IOS */
- backend->ssl_ctx = NULL;
+ backend->ssl_ctx = NULL;
}
- backend->ssl_sockfd = 0;
+ backend->ssl_sockfd = 0;
}
static int Curl_sectransp_shutdown(struct connectdata *conn, int sockindex)
{
struct ssl_connect_data *connssl = &conn->ssl[sockindex];
- struct ssl_backend_data *backend = connssl->backend;
+ struct ssl_backend_data *backend = connssl->backend;
struct Curl_easy *data = conn->data;
ssize_t nread;
int what;
int rc;
char buf[120];
- if(!backend->ssl_ctx)
+ if(!backend->ssl_ctx)
return 0;
#ifndef CURL_DISABLE_FTP
@@ -3077,12 +3077,12 @@ static size_t Curl_sectransp_version(char *buffer, size_t size)
static int Curl_sectransp_check_cxn(struct connectdata *conn)
{
struct ssl_connect_data *connssl = &conn->ssl[FIRSTSOCKET];
- struct ssl_backend_data *backend = connssl->backend;
+ struct ssl_backend_data *backend = connssl->backend;
OSStatus err;
SSLSessionState state;
- if(backend->ssl_ctx) {
- err = SSLGetSessionState(backend->ssl_ctx, &state);
+ if(backend->ssl_ctx) {
+ err = SSLGetSessionState(backend->ssl_ctx, &state);
if(err == noErr)
return state == kSSLConnected || state == kSSLHandshake;
return -1;
@@ -3094,12 +3094,12 @@ static bool Curl_sectransp_data_pending(const struct connectdata *conn,
int connindex)
{
const struct ssl_connect_data *connssl = &conn->ssl[connindex];
- struct ssl_backend_data *backend = connssl->backend;
+ struct ssl_backend_data *backend = connssl->backend;
OSStatus err;
size_t buffer;
- if(backend->ssl_ctx) { /* SSL is in use */
- err = SSLGetBufferedReadSize(backend->ssl_ctx, &buffer);
+ if(backend->ssl_ctx) { /* SSL is in use */
+ err = SSLGetBufferedReadSize(backend->ssl_ctx, &buffer);
if(err == noErr)
return buffer > 0UL;
return false;
@@ -3165,7 +3165,7 @@ static ssize_t sectransp_send(struct connectdata *conn,
{
/*struct Curl_easy *data = conn->data;*/
struct ssl_connect_data *connssl = &conn->ssl[sockindex];
- struct ssl_backend_data *backend = connssl->backend;
+ struct ssl_backend_data *backend = connssl->backend;
size_t processed = 0UL;
OSStatus err;
@@ -3184,15 +3184,15 @@ static ssize_t sectransp_send(struct connectdata *conn,
over again with no new data until it quits returning errSSLWouldBlock. */
/* Do we have buffered data to write from the last time we were called? */
- if(backend->ssl_write_buffered_length) {
+ if(backend->ssl_write_buffered_length) {
/* Write the buffered data: */
- err = SSLWrite(backend->ssl_ctx, NULL, 0UL, &processed);
+ err = SSLWrite(backend->ssl_ctx, NULL, 0UL, &processed);
switch(err) {
case noErr:
/* processed is always going to be 0 because we didn't write to
the buffer, so return how much was written to the socket */
- processed = backend->ssl_write_buffered_length;
- backend->ssl_write_buffered_length = 0UL;
+ processed = backend->ssl_write_buffered_length;
+ backend->ssl_write_buffered_length = 0UL;
break;
case errSSLWouldBlock: /* argh, try again */
*curlcode = CURLE_AGAIN;
@@ -3205,13 +3205,13 @@ static ssize_t sectransp_send(struct connectdata *conn,
}
else {
/* We've got new data to write: */
- err = SSLWrite(backend->ssl_ctx, mem, len, &processed);
+ err = SSLWrite(backend->ssl_ctx, mem, len, &processed);
if(err != noErr) {
switch(err) {
case errSSLWouldBlock:
/* Data was buffered but not sent, we have to tell the caller
to try sending again, and remember how much was buffered */
- backend->ssl_write_buffered_length = len;
+ backend->ssl_write_buffered_length = len;
*curlcode = CURLE_AGAIN;
return -1L;
default:
@@ -3232,12 +3232,12 @@ static ssize_t sectransp_recv(struct connectdata *conn,
{
/*struct Curl_easy *data = conn->data;*/
struct ssl_connect_data *connssl = &conn->ssl[num];
- struct ssl_backend_data *backend = connssl->backend;
+ struct ssl_backend_data *backend = connssl->backend;
size_t processed = 0UL;
OSStatus err;
again:
- err = SSLRead(backend->ssl_ctx, buf, buffersize, &processed);
+ err = SSLRead(backend->ssl_ctx, buf, buffersize, &processed);
if(err != noErr) {
switch(err) {
@@ -3263,7 +3263,7 @@ static ssize_t sectransp_recv(struct connectdata *conn,
case -9841:
if(SSL_CONN_CONFIG(CAfile) && SSL_CONN_CONFIG(verifypeer)) {
CURLcode result = verify_cert(SSL_CONN_CONFIG(CAfile), conn->data,
- backend->ssl_ctx);
+ backend->ssl_ctx);
if(result)
return result;
}
@@ -3281,9 +3281,9 @@ static ssize_t sectransp_recv(struct connectdata *conn,
static void *Curl_sectransp_get_internals(struct ssl_connect_data *connssl,
CURLINFO info UNUSED_PARAM)
{
- struct ssl_backend_data *backend = connssl->backend;
+ struct ssl_backend_data *backend = connssl->backend;
(void)info;
- return backend->ssl_ctx;
+ return backend->ssl_ctx;
}
const struct Curl_ssl Curl_ssl_sectransp = {
diff --git a/contrib/libs/curl/lib/vtls/sectransp.h b/contrib/libs/curl/lib/vtls/sectransp.h
index 6b85a367da..0febd6613a 100644
--- a/contrib/libs/curl/lib/vtls/sectransp.h
+++ b/contrib/libs/curl/lib/vtls/sectransp.h
@@ -8,11 +8,11 @@
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2012 - 2014, Nick Zitzmann, <nickzman@gmail.com>.
- * Copyright (C) 2012 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2012 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/vtls/vtls.c b/contrib/libs/curl/lib/vtls/vtls.c
index 5da28209a9..3bd51fdaf2 100644
--- a/contrib/libs/curl/lib/vtls/vtls.c
+++ b/contrib/libs/curl/lib/vtls/vtls.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -63,7 +63,7 @@
#include "warnless.h"
#include "curl_base64.h"
#include "curl_printf.h"
-#include "strdup.h"
+#include "strdup.h"
/* The last #include files should be: */
#include "curl_memory.h"
@@ -83,63 +83,63 @@
else \
dest->var = NULL;
-#define CLONE_BLOB(var) \
- if(blobdup(&dest->var, source->var)) \
- return FALSE;
-
-static CURLcode blobdup(struct curl_blob **dest,
- struct curl_blob *src)
-{
- DEBUGASSERT(dest);
- DEBUGASSERT(!*dest);
- if(src) {
- /* only if there's data to dupe! */
- struct curl_blob *d;
- d = malloc(sizeof(struct curl_blob) + src->len);
- if(!d)
- return CURLE_OUT_OF_MEMORY;
- d->len = src->len;
- /* Always duplicate because the connection may survive longer than the
- handle that passed in the blob. */
- d->flags = CURL_BLOB_COPY;
- d->data = (void *)((char *)d + sizeof(struct curl_blob));
- memcpy(d->data, src->data, src->len);
- *dest = d;
- }
- return CURLE_OK;
-}
-
-/* returns TRUE if the blobs are identical */
-static bool blobcmp(struct curl_blob *first, struct curl_blob *second)
-{
- if(!first && !second) /* both are NULL */
- return TRUE;
- if(!first || !second) /* one is NULL */
- return FALSE;
- if(first->len != second->len) /* different sizes */
- return FALSE;
- return !memcmp(first->data, second->data, first->len); /* same data */
-}
-
+#define CLONE_BLOB(var) \
+ if(blobdup(&dest->var, source->var)) \
+ return FALSE;
+
+static CURLcode blobdup(struct curl_blob **dest,
+ struct curl_blob *src)
+{
+ DEBUGASSERT(dest);
+ DEBUGASSERT(!*dest);
+ if(src) {
+ /* only if there's data to dupe! */
+ struct curl_blob *d;
+ d = malloc(sizeof(struct curl_blob) + src->len);
+ if(!d)
+ return CURLE_OUT_OF_MEMORY;
+ d->len = src->len;
+ /* Always duplicate because the connection may survive longer than the
+ handle that passed in the blob. */
+ d->flags = CURL_BLOB_COPY;
+ d->data = (void *)((char *)d + sizeof(struct curl_blob));
+ memcpy(d->data, src->data, src->len);
+ *dest = d;
+ }
+ return CURLE_OK;
+}
+
+/* returns TRUE if the blobs are identical */
+static bool blobcmp(struct curl_blob *first, struct curl_blob *second)
+{
+ if(!first && !second) /* both are NULL */
+ return TRUE;
+ if(!first || !second) /* one is NULL */
+ return FALSE;
+ if(first->len != second->len) /* different sizes */
+ return FALSE;
+ return !memcmp(first->data, second->data, first->len); /* same data */
+}
+
bool
-Curl_ssl_config_matches(struct ssl_primary_config *data,
- struct ssl_primary_config *needle)
+Curl_ssl_config_matches(struct ssl_primary_config *data,
+ struct ssl_primary_config *needle)
{
if((data->version == needle->version) &&
(data->version_max == needle->version_max) &&
(data->verifypeer == needle->verifypeer) &&
(data->verifyhost == needle->verifyhost) &&
(data->verifystatus == needle->verifystatus) &&
- blobcmp(data->cert_blob, needle->cert_blob) &&
+ blobcmp(data->cert_blob, needle->cert_blob) &&
Curl_safe_strcasecompare(data->CApath, needle->CApath) &&
Curl_safe_strcasecompare(data->CAfile, needle->CAfile) &&
Curl_safe_strcasecompare(data->clientcert, needle->clientcert) &&
Curl_safe_strcasecompare(data->random_file, needle->random_file) &&
Curl_safe_strcasecompare(data->egdsocket, needle->egdsocket) &&
Curl_safe_strcasecompare(data->cipher_list, needle->cipher_list) &&
- Curl_safe_strcasecompare(data->cipher_list13, needle->cipher_list13) &&
- Curl_safe_strcasecompare(data->curves, needle->curves) &&
- Curl_safe_strcasecompare(data->pinned_key, needle->pinned_key))
+ Curl_safe_strcasecompare(data->cipher_list13, needle->cipher_list13) &&
+ Curl_safe_strcasecompare(data->curves, needle->curves) &&
+ Curl_safe_strcasecompare(data->pinned_key, needle->pinned_key))
return TRUE;
return FALSE;
@@ -156,7 +156,7 @@ Curl_clone_primary_ssl_config(struct ssl_primary_config *source,
dest->verifystatus = source->verifystatus;
dest->sessionid = source->sessionid;
- CLONE_BLOB(cert_blob);
+ CLONE_BLOB(cert_blob);
CLONE_STRING(CApath);
CLONE_STRING(CAfile);
CLONE_STRING(clientcert);
@@ -164,13 +164,13 @@ Curl_clone_primary_ssl_config(struct ssl_primary_config *source,
CLONE_STRING(egdsocket);
CLONE_STRING(cipher_list);
CLONE_STRING(cipher_list13);
- CLONE_STRING(pinned_key);
- CLONE_STRING(curves);
+ CLONE_STRING(pinned_key);
+ CLONE_STRING(curves);
return TRUE;
}
-void Curl_free_primary_ssl_config(struct ssl_primary_config *sslc)
+void Curl_free_primary_ssl_config(struct ssl_primary_config *sslc)
{
Curl_safefree(sslc->CApath);
Curl_safefree(sslc->CAfile);
@@ -179,9 +179,9 @@ void Curl_free_primary_ssl_config(struct ssl_primary_config *sslc)
Curl_safefree(sslc->egdsocket);
Curl_safefree(sslc->cipher_list);
Curl_safefree(sslc->cipher_list13);
- Curl_safefree(sslc->pinned_key);
- Curl_safefree(sslc->cert_blob);
- Curl_safefree(sslc->curves);
+ Curl_safefree(sslc->pinned_key);
+ Curl_safefree(sslc->cert_blob);
+ Curl_safefree(sslc->curves);
}
#ifdef USE_SSL
@@ -219,9 +219,9 @@ int Curl_ssl_init(void)
return Curl_ssl->init();
}
-#if defined(CURL_WITH_MULTI_SSL)
-static const struct Curl_ssl Curl_ssl_multi;
-#endif
+#if defined(CURL_WITH_MULTI_SSL)
+static const struct Curl_ssl Curl_ssl_multi;
+#endif
/* Global cleanup */
void Curl_ssl_cleanup(void)
@@ -229,9 +229,9 @@ void Curl_ssl_cleanup(void)
if(init_ssl) {
/* only cleanup if we did a previous init */
Curl_ssl->cleanup();
-#if defined(CURL_WITH_MULTI_SSL)
- Curl_ssl = &Curl_ssl_multi;
-#endif
+#if defined(CURL_WITH_MULTI_SSL)
+ Curl_ssl = &Curl_ssl_multi;
+#endif
init_ssl = FALSE;
}
}
@@ -260,7 +260,7 @@ static bool ssl_prefs_check(struct Curl_easy *data)
return TRUE;
}
-#ifndef CURL_DISABLE_PROXY
+#ifndef CURL_DISABLE_PROXY
static CURLcode
ssl_connect_init_proxy(struct connectdata *conn, int sockindex)
{
@@ -284,20 +284,20 @@ ssl_connect_init_proxy(struct connectdata *conn, int sockindex)
}
return CURLE_OK;
}
-#endif
+#endif
CURLcode
Curl_ssl_connect(struct connectdata *conn, int sockindex)
{
CURLcode result;
-#ifndef CURL_DISABLE_PROXY
+#ifndef CURL_DISABLE_PROXY
if(conn->bits.proxy_ssl_connected[sockindex]) {
result = ssl_connect_init_proxy(conn, sockindex);
if(result)
return result;
}
-#endif
+#endif
if(!ssl_prefs_check(conn->data))
return CURLE_SSL_CONNECT_ERROR;
@@ -319,13 +319,13 @@ Curl_ssl_connect_nonblocking(struct connectdata *conn, int sockindex,
bool *done)
{
CURLcode result;
-#ifndef CURL_DISABLE_PROXY
+#ifndef CURL_DISABLE_PROXY
if(conn->bits.proxy_ssl_connected[sockindex]) {
result = ssl_connect_init_proxy(conn, sockindex);
if(result)
return result;
}
-#endif
+#endif
if(!ssl_prefs_check(conn->data))
return CURLE_SSL_CONNECT_ERROR;
@@ -365,27 +365,27 @@ bool Curl_ssl_getsessionid(struct connectdata *conn,
size_t *idsize, /* set 0 if unknown */
int sockindex)
{
- struct Curl_ssl_session *check;
+ struct Curl_ssl_session *check;
struct Curl_easy *data = conn->data;
size_t i;
long *general_age;
bool no_match = TRUE;
-#ifndef CURL_DISABLE_PROXY
+#ifndef CURL_DISABLE_PROXY
const bool isProxy = CONNECT_PROXY_SSL();
struct ssl_primary_config * const ssl_config = isProxy ?
&conn->proxy_ssl_config :
&conn->ssl_config;
- const char * const name = isProxy ?
- conn->http_proxy.host.name : conn->host.name;
+ const char * const name = isProxy ?
+ conn->http_proxy.host.name : conn->host.name;
int port = isProxy ? (int)conn->port : conn->remote_port;
-#else
- /* no proxy support */
- struct ssl_primary_config * const ssl_config = &conn->ssl_config;
- const char * const name = conn->host.name;
- int port = conn->remote_port;
- (void)sockindex;
-#endif
+#else
+ /* no proxy support */
+ struct ssl_primary_config * const ssl_config = &conn->ssl_config;
+ const char * const name = conn->host.name;
+ int port = conn->remote_port;
+ (void)sockindex;
+#endif
*ssl_sessionid = NULL;
DEBUGASSERT(SSL_SET_OPTION(primary.sessionid));
@@ -432,7 +432,7 @@ bool Curl_ssl_getsessionid(struct connectdata *conn,
/*
* Kill a single session ID entry in the cache.
*/
-void Curl_ssl_kill_session(struct Curl_ssl_session *session)
+void Curl_ssl_kill_session(struct Curl_ssl_session *session)
{
if(session->sessionid) {
/* defensive check */
@@ -459,7 +459,7 @@ void Curl_ssl_delsessionid(struct connectdata *conn, void *ssl_sessionid)
struct Curl_easy *data = conn->data;
for(i = 0; i < data->set.general_ssl.max_ssl_sessions; i++) {
- struct Curl_ssl_session *check = &data->state.session[i];
+ struct Curl_ssl_session *check = &data->state.session[i];
if(check->sessionid == ssl_sessionid) {
Curl_ssl_kill_session(check);
@@ -481,29 +481,29 @@ CURLcode Curl_ssl_addsessionid(struct connectdata *conn,
{
size_t i;
struct Curl_easy *data = conn->data; /* the mother of all structs */
- struct Curl_ssl_session *store = &data->state.session[0];
+ struct Curl_ssl_session *store = &data->state.session[0];
long oldest_age = data->state.session[0].age; /* zero if unused */
char *clone_host;
char *clone_conn_to_host;
int conn_to_port;
long *general_age;
-#ifndef CURL_DISABLE_PROXY
+#ifndef CURL_DISABLE_PROXY
const bool isProxy = CONNECT_PROXY_SSL();
struct ssl_primary_config * const ssl_config = isProxy ?
&conn->proxy_ssl_config :
&conn->ssl_config;
- const char *hostname = isProxy ? conn->http_proxy.host.name :
- conn->host.name;
-#else
- /* proxy support disabled */
- const bool isProxy = FALSE;
- struct ssl_primary_config * const ssl_config = &conn->ssl_config;
- const char *hostname = conn->host.name;
- (void)sockindex;
-#endif
+ const char *hostname = isProxy ? conn->http_proxy.host.name :
+ conn->host.name;
+#else
+ /* proxy support disabled */
+ const bool isProxy = FALSE;
+ struct ssl_primary_config * const ssl_config = &conn->ssl_config;
+ const char *hostname = conn->host.name;
+ (void)sockindex;
+#endif
DEBUGASSERT(SSL_SET_OPTION(primary.sessionid));
- clone_host = strdup(hostname);
+ clone_host = strdup(hostname);
if(!clone_host)
return CURLE_OUT_OF_MEMORY; /* bail out */
@@ -562,7 +562,7 @@ CURLcode Curl_ssl_addsessionid(struct connectdata *conn,
store->scheme = conn->handler->scheme;
if(!Curl_clone_primary_ssl_config(ssl_config, &store->ssl_config)) {
- Curl_free_primary_ssl_config(&store->ssl_config);
+ Curl_free_primary_ssl_config(&store->ssl_config);
store->sessionid = NULL; /* let caller free sessionid */
free(clone_host);
free(clone_conn_to_host);
@@ -590,8 +590,8 @@ void Curl_ssl_close_all(struct Curl_easy *data)
}
#if defined(USE_OPENSSL) || defined(USE_GNUTLS) || defined(USE_SCHANNEL) || \
- defined(USE_SECTRANSP) || defined(USE_NSS) || \
- defined(USE_MBEDTLS) || defined(USE_WOLFSSL) || defined(USE_BEARSSL)
+ defined(USE_SECTRANSP) || defined(USE_NSS) || \
+ defined(USE_MBEDTLS) || defined(USE_WOLFSSL) || defined(USE_BEARSSL)
int Curl_ssl_getsock(struct connectdata *conn, curl_socket_t *socks)
{
struct ssl_connect_data *connssl = &conn->ssl[FIRSTSOCKET];
@@ -624,7 +624,7 @@ void Curl_ssl_close(struct connectdata *conn, int sockindex)
{
DEBUGASSERT((sockindex <= 1) && (sockindex >= -1));
Curl_ssl->close_one(conn, sockindex);
- conn->ssl[sockindex].state = ssl_connection_none;
+ conn->ssl[sockindex].state = ssl_connection_none;
}
CURLcode Curl_ssl_shutdown(struct connectdata *conn, int sockindex)
@@ -667,13 +667,13 @@ struct curl_slist *Curl_ssl_engines_list(struct Curl_easy *data)
*/
CURLcode Curl_ssl_initsessions(struct Curl_easy *data, size_t amount)
{
- struct Curl_ssl_session *session;
+ struct Curl_ssl_session *session;
if(data->state.session)
/* this is just a precaution to prevent multiple inits */
return CURLE_OK;
- session = calloc(amount, sizeof(struct Curl_ssl_session));
+ session = calloc(amount, sizeof(struct Curl_ssl_session));
if(!session)
return CURLE_OUT_OF_MEMORY;
@@ -752,7 +752,7 @@ CURLcode Curl_ssl_init_certinfo(struct Curl_easy *data, int num)
}
/*
- * 'value' is NOT a null-terminated string
+ * 'value' is NOT a null-terminated string
*/
CURLcode Curl_ssl_push_certinfo_len(struct Curl_easy *data,
int certnum,
@@ -774,10 +774,10 @@ CURLcode Curl_ssl_push_certinfo_len(struct Curl_easy *data,
/* sprintf the label and colon */
msnprintf(output, outlen, "%s:", label);
- /* memcpy the value (it might not be null-terminated) */
+ /* memcpy the value (it might not be null-terminated) */
memcpy(&output[labellen + 1], value, valuelen);
- /* null-terminate the output */
+ /* null-terminate the output */
output[labellen + 1 + valuelen] = 0;
nl = Curl_slist_append_nodup(ci->certinfo[certnum], output);
@@ -1152,7 +1152,7 @@ bool Curl_none_false_start(void)
CURLcode Curl_none_md5sum(unsigned char *input, size_t inputlen,
unsigned char *md5sum, size_t md5len UNUSED_PARAM)
{
- struct MD5_context *MD5pw;
+ struct MD5_context *MD5pw;
(void)md5len;
@@ -1262,8 +1262,8 @@ const struct Curl_ssl *Curl_ssl =
&Curl_ssl_schannel;
#elif defined(USE_MESALINK)
&Curl_ssl_mesalink;
-#elif defined(USE_BEARSSL)
- &Curl_ssl_bearssl;
+#elif defined(USE_BEARSSL)
+ &Curl_ssl_bearssl;
#else
#error "Missing struct Curl_ssl for selected SSL backend"
#endif
@@ -1296,9 +1296,9 @@ static const struct Curl_ssl *available_backends[] = {
#if defined(USE_MESALINK)
&Curl_ssl_mesalink,
#endif
-#if defined(USE_BEARSSL)
- &Curl_ssl_bearssl,
-#endif
+#if defined(USE_BEARSSL)
+ &Curl_ssl_bearssl,
+#endif
NULL
};
@@ -1306,7 +1306,7 @@ static size_t Curl_multissl_version(char *buffer, size_t size)
{
static const struct Curl_ssl *selected;
static char backends[200];
- static size_t backends_len;
+ static size_t backends_len;
const struct Curl_ssl *current;
current = Curl_ssl == &Curl_ssl_multi ? available_backends[0] : Curl_ssl;
@@ -1318,32 +1318,32 @@ static size_t Curl_multissl_version(char *buffer, size_t size)
selected = current;
- backends[0] = '\0';
-
- for(i = 0; available_backends[i]; ++i) {
- char vb[200];
- bool paren = (selected != available_backends[i]);
-
- if(available_backends[i]->version(vb, sizeof(vb))) {
- p += msnprintf(p, end - p, "%s%s%s%s", (p != backends ? " " : ""),
- (paren ? "(" : ""), vb, (paren ? ")" : ""));
- }
+ backends[0] = '\0';
+
+ for(i = 0; available_backends[i]; ++i) {
+ char vb[200];
+ bool paren = (selected != available_backends[i]);
+
+ if(available_backends[i]->version(vb, sizeof(vb))) {
+ p += msnprintf(p, end - p, "%s%s%s%s", (p != backends ? " " : ""),
+ (paren ? "(" : ""), vb, (paren ? ")" : ""));
+ }
}
-
- backends_len = p - backends;
+
+ backends_len = p - backends;
}
- if(!size)
- return 0;
-
- if(size <= backends_len) {
- strncpy(buffer, backends, size - 1);
+ if(!size)
+ return 0;
+
+ if(size <= backends_len) {
+ strncpy(buffer, backends, size - 1);
buffer[size - 1] = '\0';
- return size - 1;
+ return size - 1;
}
- strcpy(buffer, backends);
- return backends_len;
+ strcpy(buffer, backends);
+ return backends_len;
}
static int multissl_init(const struct Curl_ssl *backend)
diff --git a/contrib/libs/curl/lib/vtls/vtls.h b/contrib/libs/curl/lib/vtls/vtls.h
index aeb1cb6537..f4cab9988f 100644
--- a/contrib/libs/curl/lib/vtls/vtls.h
+++ b/contrib/libs/curl/lib/vtls/vtls.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -107,7 +107,7 @@ CURLcode Curl_none_md5sum(unsigned char *input, size_t inputlen,
#include "sectransp.h" /* SecureTransport (Darwin) version */
#include "mbedtls.h" /* mbedTLS versions */
#include "mesalink.h" /* MesaLink versions */
-#include "bearssl.h" /* BearSSL versions */
+#include "bearssl.h" /* BearSSL versions */
#ifndef MAX_PINNED_PUBKEY_SIZE
#define MAX_PINNED_PUBKEY_SIZE 1048576 /* 1MB */
@@ -123,41 +123,41 @@ CURLcode Curl_none_md5sum(unsigned char *input, size_t inputlen,
/* set of helper macros for the backends to access the correct fields. For the
proxy or for the remote host - to properly support HTTPS proxy */
-#ifndef CURL_DISABLE_PROXY
-#define SSL_IS_PROXY() \
- (CURLPROXY_HTTPS == conn->http_proxy.proxytype && \
- ssl_connection_complete != \
- conn->proxy_ssl[conn->sock[SECONDARYSOCKET] == \
- CURL_SOCKET_BAD ? FIRSTSOCKET : SECONDARYSOCKET].state)
-#define SSL_SET_OPTION(var) \
- (SSL_IS_PROXY() ? data->set.proxy_ssl.var : data->set.ssl.var)
-#define SSL_SET_OPTION_LVALUE(var) \
- (*(SSL_IS_PROXY() ? &data->set.proxy_ssl.var : &data->set.ssl.var))
-#define SSL_CONN_CONFIG(var) \
- (SSL_IS_PROXY() ? conn->proxy_ssl_config.var : conn->ssl_config.var)
-#define SSL_HOST_NAME() \
- (SSL_IS_PROXY() ? conn->http_proxy.host.name : conn->host.name)
-#define SSL_HOST_DISPNAME() \
- (SSL_IS_PROXY() ? conn->http_proxy.host.dispname : conn->host.dispname)
-#define SSL_PINNED_PUB_KEY() (SSL_IS_PROXY() \
- ? data->set.str[STRING_SSL_PINNEDPUBLICKEY_PROXY] \
- : data->set.str[STRING_SSL_PINNEDPUBLICKEY_ORIG])
-#else
-#define SSL_IS_PROXY() FALSE
-#define SSL_SET_OPTION(var) data->set.ssl.var
-#define SSL_SET_OPTION_LVALUE(var) data->set.ssl.var
-#define SSL_CONN_CONFIG(var) conn->ssl_config.var
-#define SSL_HOST_NAME() conn->host.name
-#define SSL_HOST_DISPNAME() conn->host.dispname
-#define SSL_PINNED_PUB_KEY() \
- data->set.str[STRING_SSL_PINNEDPUBLICKEY_ORIG]
-#endif
-
-bool Curl_ssl_config_matches(struct ssl_primary_config *data,
- struct ssl_primary_config *needle);
+#ifndef CURL_DISABLE_PROXY
+#define SSL_IS_PROXY() \
+ (CURLPROXY_HTTPS == conn->http_proxy.proxytype && \
+ ssl_connection_complete != \
+ conn->proxy_ssl[conn->sock[SECONDARYSOCKET] == \
+ CURL_SOCKET_BAD ? FIRSTSOCKET : SECONDARYSOCKET].state)
+#define SSL_SET_OPTION(var) \
+ (SSL_IS_PROXY() ? data->set.proxy_ssl.var : data->set.ssl.var)
+#define SSL_SET_OPTION_LVALUE(var) \
+ (*(SSL_IS_PROXY() ? &data->set.proxy_ssl.var : &data->set.ssl.var))
+#define SSL_CONN_CONFIG(var) \
+ (SSL_IS_PROXY() ? conn->proxy_ssl_config.var : conn->ssl_config.var)
+#define SSL_HOST_NAME() \
+ (SSL_IS_PROXY() ? conn->http_proxy.host.name : conn->host.name)
+#define SSL_HOST_DISPNAME() \
+ (SSL_IS_PROXY() ? conn->http_proxy.host.dispname : conn->host.dispname)
+#define SSL_PINNED_PUB_KEY() (SSL_IS_PROXY() \
+ ? data->set.str[STRING_SSL_PINNEDPUBLICKEY_PROXY] \
+ : data->set.str[STRING_SSL_PINNEDPUBLICKEY_ORIG])
+#else
+#define SSL_IS_PROXY() FALSE
+#define SSL_SET_OPTION(var) data->set.ssl.var
+#define SSL_SET_OPTION_LVALUE(var) data->set.ssl.var
+#define SSL_CONN_CONFIG(var) conn->ssl_config.var
+#define SSL_HOST_NAME() conn->host.name
+#define SSL_HOST_DISPNAME() conn->host.dispname
+#define SSL_PINNED_PUB_KEY() \
+ data->set.str[STRING_SSL_PINNEDPUBLICKEY_ORIG]
+#endif
+
+bool Curl_ssl_config_matches(struct ssl_primary_config *data,
+ struct ssl_primary_config *needle);
bool Curl_clone_primary_ssl_config(struct ssl_primary_config *source,
struct ssl_primary_config *dest);
-void Curl_free_primary_ssl_config(struct ssl_primary_config *sslc);
+void Curl_free_primary_ssl_config(struct ssl_primary_config *sslc);
int Curl_ssl_getsock(struct connectdata *conn, curl_socket_t *socks);
int Curl_ssl_backend(void);
@@ -235,7 +235,7 @@ CURLcode Curl_ssl_addsessionid(struct connectdata *conn,
* take sessionid object ownership from sessionid cache
* (e.g. decrement refcount).
*/
-void Curl_ssl_kill_session(struct Curl_ssl_session *session);
+void Curl_ssl_kill_session(struct Curl_ssl_session *session);
/* delete a session from the cache
* Sessionid mutex must be locked (see Curl_ssl_sessionid_lock).
* This will call engine-specific curlssl_session_free function, which must
diff --git a/contrib/libs/curl/lib/vtls/wolfssl.c b/contrib/libs/curl/lib/vtls/wolfssl.c
index 8b37965f93..ac9818824d 100644
--- a/contrib/libs/curl/lib/vtls/wolfssl.c
+++ b/contrib/libs/curl/lib/vtls/wolfssl.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -63,7 +63,7 @@
#include "sendf.h"
#include "inet_pton.h"
#include "vtls.h"
-#include "keylog.h"
+#include "keylog.h"
#include "parsedate.h"
#include "connect.h" /* for the connect timeout */
#include "select.h"
@@ -100,107 +100,107 @@ struct ssl_backend_data {
static Curl_recv wolfssl_recv;
static Curl_send wolfssl_send;
-#ifdef OPENSSL_EXTRA
-/*
- * Availability note:
- * The TLS 1.3 secret callback (wolfSSL_set_tls13_secret_cb) was added in
- * WolfSSL 4.4.0, but requires the -DHAVE_SECRET_CALLBACK build option. If that
- * option is not set, then TLS 1.3 will not be logged.
- * For TLS 1.2 and before, we use wolfSSL_get_keys().
- * SSL_get_client_random and wolfSSL_get_keys require OPENSSL_EXTRA
- * (--enable-opensslextra or --enable-all).
- */
-#if defined(HAVE_SECRET_CALLBACK) && defined(WOLFSSL_TLS13)
-static int
-wolfssl_tls13_secret_callback(SSL *ssl, int id, const unsigned char *secret,
- int secretSz, void *ctx)
-{
- const char *label;
- unsigned char client_random[SSL3_RANDOM_SIZE];
- (void)ctx;
-
- if(!ssl || !Curl_tls_keylog_enabled()) {
- return 0;
- }
-
- switch(id) {
- case CLIENT_EARLY_TRAFFIC_SECRET:
- label = "CLIENT_EARLY_TRAFFIC_SECRET";
- break;
- case CLIENT_HANDSHAKE_TRAFFIC_SECRET:
- label = "CLIENT_HANDSHAKE_TRAFFIC_SECRET";
- break;
- case SERVER_HANDSHAKE_TRAFFIC_SECRET:
- label = "SERVER_HANDSHAKE_TRAFFIC_SECRET";
- break;
- case CLIENT_TRAFFIC_SECRET:
- label = "CLIENT_TRAFFIC_SECRET_0";
- break;
- case SERVER_TRAFFIC_SECRET:
- label = "SERVER_TRAFFIC_SECRET_0";
- break;
- case EARLY_EXPORTER_SECRET:
- label = "EARLY_EXPORTER_SECRET";
- break;
- case EXPORTER_SECRET:
- label = "EXPORTER_SECRET";
- break;
- default:
- return 0;
- }
-
- if(SSL_get_client_random(ssl, client_random, SSL3_RANDOM_SIZE) == 0) {
- /* Should never happen as wolfSSL_KeepArrays() was called before. */
- return 0;
- }
-
- Curl_tls_keylog_write(label, client_random, secret, secretSz);
- return 0;
-}
-#endif /* defined(HAVE_SECRET_CALLBACK) && defined(WOLFSSL_TLS13) */
-
-static void
-wolfssl_log_tls12_secret(SSL *ssl)
-{
- unsigned char *ms, *sr, *cr;
- unsigned int msLen, srLen, crLen, i, x = 0;
-
-#if LIBWOLFSSL_VERSION_HEX >= 0x0300d000 /* >= 3.13.0 */
- /* wolfSSL_GetVersion is available since 3.13, we use it instead of
- * SSL_version since the latter relies on OPENSSL_ALL (--enable-opensslall or
- * --enable-all). Failing to perform this check could result in an unusable
- * key log line when TLS 1.3 is actually negotiated. */
- switch(wolfSSL_GetVersion(ssl)) {
- case WOLFSSL_SSLV3:
- case WOLFSSL_TLSV1:
- case WOLFSSL_TLSV1_1:
- case WOLFSSL_TLSV1_2:
- break;
- default:
- /* TLS 1.3 does not use this mechanism, the "master secret" returned below
- * is not directly usable. */
- return;
- }
-#endif
-
- if(SSL_get_keys(ssl, &ms, &msLen, &sr, &srLen, &cr, &crLen) != SSL_SUCCESS) {
- return;
- }
-
- /* Check for a missing master secret and skip logging. That can happen if
- * curl rejects the server certificate and aborts the handshake.
- */
- for(i = 0; i < msLen; i++) {
- x |= ms[i];
- }
- if(x == 0) {
- return;
- }
-
- Curl_tls_keylog_write("CLIENT_RANDOM", cr, ms, msLen);
-}
-#endif /* OPENSSL_EXTRA */
-
+#ifdef OPENSSL_EXTRA
+/*
+ * Availability note:
+ * The TLS 1.3 secret callback (wolfSSL_set_tls13_secret_cb) was added in
+ * WolfSSL 4.4.0, but requires the -DHAVE_SECRET_CALLBACK build option. If that
+ * option is not set, then TLS 1.3 will not be logged.
+ * For TLS 1.2 and before, we use wolfSSL_get_keys().
+ * SSL_get_client_random and wolfSSL_get_keys require OPENSSL_EXTRA
+ * (--enable-opensslextra or --enable-all).
+ */
+#if defined(HAVE_SECRET_CALLBACK) && defined(WOLFSSL_TLS13)
+static int
+wolfssl_tls13_secret_callback(SSL *ssl, int id, const unsigned char *secret,
+ int secretSz, void *ctx)
+{
+ const char *label;
+ unsigned char client_random[SSL3_RANDOM_SIZE];
+ (void)ctx;
+
+ if(!ssl || !Curl_tls_keylog_enabled()) {
+ return 0;
+ }
+
+ switch(id) {
+ case CLIENT_EARLY_TRAFFIC_SECRET:
+ label = "CLIENT_EARLY_TRAFFIC_SECRET";
+ break;
+ case CLIENT_HANDSHAKE_TRAFFIC_SECRET:
+ label = "CLIENT_HANDSHAKE_TRAFFIC_SECRET";
+ break;
+ case SERVER_HANDSHAKE_TRAFFIC_SECRET:
+ label = "SERVER_HANDSHAKE_TRAFFIC_SECRET";
+ break;
+ case CLIENT_TRAFFIC_SECRET:
+ label = "CLIENT_TRAFFIC_SECRET_0";
+ break;
+ case SERVER_TRAFFIC_SECRET:
+ label = "SERVER_TRAFFIC_SECRET_0";
+ break;
+ case EARLY_EXPORTER_SECRET:
+ label = "EARLY_EXPORTER_SECRET";
+ break;
+ case EXPORTER_SECRET:
+ label = "EXPORTER_SECRET";
+ break;
+ default:
+ return 0;
+ }
+
+ if(SSL_get_client_random(ssl, client_random, SSL3_RANDOM_SIZE) == 0) {
+ /* Should never happen as wolfSSL_KeepArrays() was called before. */
+ return 0;
+ }
+
+ Curl_tls_keylog_write(label, client_random, secret, secretSz);
+ return 0;
+}
+#endif /* defined(HAVE_SECRET_CALLBACK) && defined(WOLFSSL_TLS13) */
+
+static void
+wolfssl_log_tls12_secret(SSL *ssl)
+{
+ unsigned char *ms, *sr, *cr;
+ unsigned int msLen, srLen, crLen, i, x = 0;
+
+#if LIBWOLFSSL_VERSION_HEX >= 0x0300d000 /* >= 3.13.0 */
+ /* wolfSSL_GetVersion is available since 3.13, we use it instead of
+ * SSL_version since the latter relies on OPENSSL_ALL (--enable-opensslall or
+ * --enable-all). Failing to perform this check could result in an unusable
+ * key log line when TLS 1.3 is actually negotiated. */
+ switch(wolfSSL_GetVersion(ssl)) {
+ case WOLFSSL_SSLV3:
+ case WOLFSSL_TLSV1:
+ case WOLFSSL_TLSV1_1:
+ case WOLFSSL_TLSV1_2:
+ break;
+ default:
+ /* TLS 1.3 does not use this mechanism, the "master secret" returned below
+ * is not directly usable. */
+ return;
+ }
+#endif
+
+ if(SSL_get_keys(ssl, &ms, &msLen, &sr, &srLen, &cr, &crLen) != SSL_SUCCESS) {
+ return;
+ }
+
+ /* Check for a missing master secret and skip logging. That can happen if
+ * curl rejects the server certificate and aborts the handshake.
+ */
+ for(i = 0; i < msLen; i++) {
+ x |= ms[i];
+ }
+ if(x == 0) {
+ return;
+ }
+
+ Curl_tls_keylog_write("CLIENT_RANDOM", cr, ms, msLen);
+}
+#endif /* OPENSSL_EXTRA */
+
static int do_file_type(const char *type)
{
if(!type || !type[0])
@@ -222,8 +222,8 @@ wolfssl_connect_step1(struct connectdata *conn,
{
char *ciphers;
struct Curl_easy *data = conn->data;
- struct ssl_connect_data *connssl = &conn->ssl[sockindex];
- struct ssl_backend_data *backend = connssl->backend;
+ struct ssl_connect_data *connssl = &conn->ssl[sockindex];
+ struct ssl_backend_data *backend = connssl->backend;
SSL_METHOD* req_method = NULL;
curl_socket_t sockfd = conn->sock[sockindex];
#ifdef HAVE_SNI
@@ -303,11 +303,11 @@ wolfssl_connect_step1(struct connectdata *conn,
return CURLE_OUT_OF_MEMORY;
}
- if(backend->ctx)
- SSL_CTX_free(backend->ctx);
- backend->ctx = SSL_CTX_new(req_method);
+ if(backend->ctx)
+ SSL_CTX_free(backend->ctx);
+ backend->ctx = SSL_CTX_new(req_method);
- if(!backend->ctx) {
+ if(!backend->ctx) {
failf(data, "SSL: couldn't create a context!");
return CURLE_OUT_OF_MEMORY;
}
@@ -322,11 +322,11 @@ wolfssl_connect_step1(struct connectdata *conn,
* defaults to TLS 1.1) so we have this short circuit evaluation to find
* the minimum supported TLS version.
*/
- if((wolfSSL_CTX_SetMinVersion(backend->ctx, WOLFSSL_TLSV1) != 1) &&
- (wolfSSL_CTX_SetMinVersion(backend->ctx, WOLFSSL_TLSV1_1) != 1) &&
- (wolfSSL_CTX_SetMinVersion(backend->ctx, WOLFSSL_TLSV1_2) != 1)
+ if((wolfSSL_CTX_SetMinVersion(backend->ctx, WOLFSSL_TLSV1) != 1) &&
+ (wolfSSL_CTX_SetMinVersion(backend->ctx, WOLFSSL_TLSV1_1) != 1) &&
+ (wolfSSL_CTX_SetMinVersion(backend->ctx, WOLFSSL_TLSV1_2) != 1)
#ifdef WOLFSSL_TLS13
- && (wolfSSL_CTX_SetMinVersion(backend->ctx, WOLFSSL_TLSV1_3) != 1)
+ && (wolfSSL_CTX_SetMinVersion(backend->ctx, WOLFSSL_TLSV1_3) != 1)
#endif
) {
failf(data, "SSL: couldn't set the minimum protocol version");
@@ -338,7 +338,7 @@ wolfssl_connect_step1(struct connectdata *conn,
ciphers = SSL_CONN_CONFIG(cipher_list);
if(ciphers) {
- if(!SSL_CTX_set_cipher_list(backend->ctx, ciphers)) {
+ if(!SSL_CTX_set_cipher_list(backend->ctx, ciphers)) {
failf(data, "failed setting cipher list: %s", ciphers);
return CURLE_SSL_CIPHER;
}
@@ -348,13 +348,13 @@ wolfssl_connect_step1(struct connectdata *conn,
#ifndef NO_FILESYSTEM
/* load trusted cacert */
if(SSL_CONN_CONFIG(CAfile)) {
- if(1 != SSL_CTX_load_verify_locations(backend->ctx,
+ if(1 != SSL_CTX_load_verify_locations(backend->ctx,
SSL_CONN_CONFIG(CAfile),
SSL_CONN_CONFIG(CApath))) {
if(SSL_CONN_CONFIG(verifypeer)) {
/* Fail if we insist on successfully verifying the server. */
- failf(data, "error setting certificate verify locations:"
- " CAfile: %s CApath: %s",
+ failf(data, "error setting certificate verify locations:"
+ " CAfile: %s CApath: %s",
SSL_CONN_CONFIG(CAfile)?
SSL_CONN_CONFIG(CAfile): "none",
SSL_CONN_CONFIG(CApath)?
@@ -372,26 +372,26 @@ wolfssl_connect_step1(struct connectdata *conn,
/* Everything is fine. */
infof(data, "successfully set certificate verify locations:\n");
}
- infof(data, " CAfile: %s\n",
- SSL_CONN_CONFIG(CAfile) ? SSL_CONN_CONFIG(CAfile) : "none");
- infof(data, " CApath: %s\n",
- SSL_CONN_CONFIG(CApath) ? SSL_CONN_CONFIG(CApath) : "none");
+ infof(data, " CAfile: %s\n",
+ SSL_CONN_CONFIG(CAfile) ? SSL_CONN_CONFIG(CAfile) : "none");
+ infof(data, " CApath: %s\n",
+ SSL_CONN_CONFIG(CApath) ? SSL_CONN_CONFIG(CApath) : "none");
}
/* Load the client certificate, and private key */
- if(SSL_SET_OPTION(primary.clientcert) && SSL_SET_OPTION(key)) {
+ if(SSL_SET_OPTION(primary.clientcert) && SSL_SET_OPTION(key)) {
int file_type = do_file_type(SSL_SET_OPTION(cert_type));
- if(SSL_CTX_use_certificate_file(backend->ctx,
- SSL_SET_OPTION(primary.clientcert),
- file_type) != 1) {
+ if(SSL_CTX_use_certificate_file(backend->ctx,
+ SSL_SET_OPTION(primary.clientcert),
+ file_type) != 1) {
failf(data, "unable to use client certificate (no key or wrong pass"
" phrase?)");
return CURLE_SSL_CONNECT_ERROR;
}
file_type = do_file_type(SSL_SET_OPTION(key_type));
- if(SSL_CTX_use_PrivateKey_file(backend->ctx, SSL_SET_OPTION(key),
+ if(SSL_CTX_use_PrivateKey_file(backend->ctx, SSL_SET_OPTION(key),
file_type) != 1) {
failf(data, "unable to set private key");
return CURLE_SSL_CONNECT_ERROR;
@@ -403,7 +403,7 @@ wolfssl_connect_step1(struct connectdata *conn,
* fail to connect if the verification fails, or if it should continue
* anyway. In the latter case the result of the verification is checked with
* SSL_get_verify_result() below. */
- SSL_CTX_set_verify(backend->ctx,
+ SSL_CTX_set_verify(backend->ctx,
SSL_CONN_CONFIG(verifypeer)?SSL_VERIFY_PEER:
SSL_VERIFY_NONE,
NULL);
@@ -414,19 +414,19 @@ wolfssl_connect_step1(struct connectdata *conn,
#ifdef ENABLE_IPV6
struct in6_addr addr6;
#endif
-#ifndef CURL_DISABLE_PROXY
+#ifndef CURL_DISABLE_PROXY
const char * const hostname = SSL_IS_PROXY() ? conn->http_proxy.host.name :
conn->host.name;
-#else
- const char * const hostname = conn->host.name;
-#endif
+#else
+ const char * const hostname = conn->host.name;
+#endif
size_t hostname_len = strlen(hostname);
if((hostname_len < USHRT_MAX) &&
(0 == Curl_inet_pton(AF_INET, hostname, &addr4)) &&
#ifdef ENABLE_IPV6
(0 == Curl_inet_pton(AF_INET6, hostname, &addr6)) &&
#endif
- (wolfSSL_CTX_UseSNI(backend->ctx, WOLFSSL_SNI_HOST_NAME, hostname,
+ (wolfSSL_CTX_UseSNI(backend->ctx, WOLFSSL_SNI_HOST_NAME, hostname,
(unsigned short)hostname_len) != 1)) {
infof(data, "WARNING: failed to configure server name indication (SNI) "
"TLS extension\n");
@@ -436,7 +436,7 @@ wolfssl_connect_step1(struct connectdata *conn,
/* give application a chance to interfere with SSL set up. */
if(data->set.ssl.fsslctx) {
- CURLcode result = (*data->set.ssl.fsslctx)(data, backend->ctx,
+ CURLcode result = (*data->set.ssl.fsslctx)(data, backend->ctx,
data->set.ssl.fsslctxp);
if(result) {
failf(data, "error signaled by ssl ctx callback");
@@ -454,10 +454,10 @@ wolfssl_connect_step1(struct connectdata *conn,
#endif
/* Let's make an SSL structure */
- if(backend->handle)
- SSL_free(backend->handle);
- backend->handle = SSL_new(backend->ctx);
- if(!backend->handle) {
+ if(backend->handle)
+ SSL_free(backend->handle);
+ backend->handle = SSL_new(backend->ctx);
+ if(!backend->handle) {
failf(data, "SSL: couldn't create a context (handle)!");
return CURLE_OUT_OF_MEMORY;
}
@@ -480,7 +480,7 @@ wolfssl_connect_step1(struct connectdata *conn,
strcpy(protocols + strlen(protocols), ALPN_HTTP_1_1);
infof(data, "ALPN, offering %s\n", ALPN_HTTP_1_1);
- if(wolfSSL_UseALPN(backend->handle, protocols,
+ if(wolfSSL_UseALPN(backend->handle, protocols,
(unsigned)strlen(protocols),
WOLFSSL_ALPN_CONTINUE_ON_MISMATCH) != SSL_SUCCESS) {
failf(data, "SSL: failed setting ALPN protocols");
@@ -489,17 +489,17 @@ wolfssl_connect_step1(struct connectdata *conn,
}
#endif /* HAVE_ALPN */
-#ifdef OPENSSL_EXTRA
- if(Curl_tls_keylog_enabled()) {
- /* Ensure the Client Random is preserved. */
- wolfSSL_KeepArrays(backend->handle);
-#if defined(HAVE_SECRET_CALLBACK) && defined(WOLFSSL_TLS13)
- wolfSSL_set_tls13_secret_cb(backend->handle,
- wolfssl_tls13_secret_callback, NULL);
-#endif
- }
-#endif /* OPENSSL_EXTRA */
-
+#ifdef OPENSSL_EXTRA
+ if(Curl_tls_keylog_enabled()) {
+ /* Ensure the Client Random is preserved. */
+ wolfSSL_KeepArrays(backend->handle);
+#if defined(HAVE_SECRET_CALLBACK) && defined(WOLFSSL_TLS13)
+ wolfSSL_set_tls13_secret_cb(backend->handle,
+ wolfssl_tls13_secret_callback, NULL);
+#endif
+ }
+#endif /* OPENSSL_EXTRA */
+
/* Check if there's a cached ID we can/should use here! */
if(SSL_SET_OPTION(primary.sessionid)) {
void *ssl_sessionid = NULL;
@@ -507,11 +507,11 @@ wolfssl_connect_step1(struct connectdata *conn,
Curl_ssl_sessionid_lock(conn);
if(!Curl_ssl_getsessionid(conn, &ssl_sessionid, NULL, sockindex)) {
/* we got a session id, use it! */
- if(!SSL_set_session(backend->handle, ssl_sessionid)) {
+ if(!SSL_set_session(backend->handle, ssl_sessionid)) {
char error_buffer[WOLFSSL_MAX_ERROR_SZ];
Curl_ssl_sessionid_unlock(conn);
failf(data, "SSL: SSL_set_session failed: %s",
- ERR_error_string(SSL_get_error(backend->handle, 0),
+ ERR_error_string(SSL_get_error(backend->handle, 0),
error_buffer));
return CURLE_SSL_CONNECT_ERROR;
}
@@ -522,7 +522,7 @@ wolfssl_connect_step1(struct connectdata *conn,
}
/* pass the raw socket into the SSL layer */
- if(!SSL_set_fd(backend->handle, (int)sockfd)) {
+ if(!SSL_set_fd(backend->handle, (int)sockfd)) {
failf(data, "SSL: SSL_set_fd failed");
return CURLE_SSL_CONNECT_ERROR;
}
@@ -538,62 +538,62 @@ wolfssl_connect_step2(struct connectdata *conn,
{
int ret = -1;
struct Curl_easy *data = conn->data;
- struct ssl_connect_data *connssl = &conn->ssl[sockindex];
- struct ssl_backend_data *backend = connssl->backend;
-#ifndef CURL_DISABLE_PROXY
+ struct ssl_connect_data *connssl = &conn->ssl[sockindex];
+ struct ssl_backend_data *backend = connssl->backend;
+#ifndef CURL_DISABLE_PROXY
const char * const hostname = SSL_IS_PROXY() ? conn->http_proxy.host.name :
conn->host.name;
const char * const dispname = SSL_IS_PROXY() ?
conn->http_proxy.host.dispname : conn->host.dispname;
const char * const pinnedpubkey = SSL_IS_PROXY() ?
- data->set.str[STRING_SSL_PINNEDPUBLICKEY_PROXY] :
- data->set.str[STRING_SSL_PINNEDPUBLICKEY_ORIG];
-#else
- const char * const hostname = conn->host.name;
- const char * const dispname = conn->host.dispname;
- const char * const pinnedpubkey =
- data->set.str[STRING_SSL_PINNEDPUBLICKEY_ORIG];
-#endif
+ data->set.str[STRING_SSL_PINNEDPUBLICKEY_PROXY] :
+ data->set.str[STRING_SSL_PINNEDPUBLICKEY_ORIG];
+#else
+ const char * const hostname = conn->host.name;
+ const char * const dispname = conn->host.dispname;
+ const char * const pinnedpubkey =
+ data->set.str[STRING_SSL_PINNEDPUBLICKEY_ORIG];
+#endif
conn->recv[sockindex] = wolfssl_recv;
conn->send[sockindex] = wolfssl_send;
/* Enable RFC2818 checks */
if(SSL_CONN_CONFIG(verifyhost)) {
- ret = wolfSSL_check_domain_name(backend->handle, hostname);
+ ret = wolfSSL_check_domain_name(backend->handle, hostname);
if(ret == SSL_FAILURE)
return CURLE_OUT_OF_MEMORY;
}
- ret = SSL_connect(backend->handle);
-
-#ifdef OPENSSL_EXTRA
- if(Curl_tls_keylog_enabled()) {
- /* If key logging is enabled, wait for the handshake to complete and then
- * proceed with logging secrets (for TLS 1.2 or older).
- *
- * During the handshake (ret==-1), wolfSSL_want_read() is true as it waits
- * for the server response. At that point the master secret is not yet
- * available, so we must not try to read it.
- * To log the secret on completion with a handshake failure, detect
- * completion via the observation that there is nothing to read or write.
- * Note that OpenSSL SSL_want_read() is always true here. If wolfSSL ever
- * changes, the worst case is that no key is logged on error.
- */
- if(ret == SSL_SUCCESS ||
- (!wolfSSL_want_read(backend->handle) &&
- !wolfSSL_want_write(backend->handle))) {
- wolfssl_log_tls12_secret(backend->handle);
- /* Client Random and master secrets are no longer needed, erase these.
- * Ignored while the handshake is still in progress. */
- wolfSSL_FreeArrays(backend->handle);
- }
- }
-#endif /* OPENSSL_EXTRA */
-
+ ret = SSL_connect(backend->handle);
+
+#ifdef OPENSSL_EXTRA
+ if(Curl_tls_keylog_enabled()) {
+ /* If key logging is enabled, wait for the handshake to complete and then
+ * proceed with logging secrets (for TLS 1.2 or older).
+ *
+ * During the handshake (ret==-1), wolfSSL_want_read() is true as it waits
+ * for the server response. At that point the master secret is not yet
+ * available, so we must not try to read it.
+ * To log the secret on completion with a handshake failure, detect
+ * completion via the observation that there is nothing to read or write.
+ * Note that OpenSSL SSL_want_read() is always true here. If wolfSSL ever
+ * changes, the worst case is that no key is logged on error.
+ */
+ if(ret == SSL_SUCCESS ||
+ (!wolfSSL_want_read(backend->handle) &&
+ !wolfSSL_want_write(backend->handle))) {
+ wolfssl_log_tls12_secret(backend->handle);
+ /* Client Random and master secrets are no longer needed, erase these.
+ * Ignored while the handshake is still in progress. */
+ wolfSSL_FreeArrays(backend->handle);
+ }
+ }
+#endif /* OPENSSL_EXTRA */
+
if(ret != 1) {
char error_buffer[WOLFSSL_MAX_ERROR_SZ];
- int detail = SSL_get_error(backend->handle, ret);
+ int detail = SSL_get_error(backend->handle, ret);
if(SSL_ERROR_WANT_READ == detail) {
connssl->connecting_state = ssl_connect_2_reading;
@@ -658,11 +658,11 @@ wolfssl_connect_step2(struct connectdata *conn,
X509 *x509;
const char *x509_der;
int x509_der_len;
- struct Curl_X509certificate x509_parsed;
- struct Curl_asn1Element *pubkey;
+ struct Curl_X509certificate x509_parsed;
+ struct Curl_asn1Element *pubkey;
CURLcode result;
- x509 = SSL_get_peer_certificate(backend->handle);
+ x509 = SSL_get_peer_certificate(backend->handle);
if(!x509) {
failf(data, "SSL: failed retrieving server certificate");
return CURLE_SSL_PINNEDPUBKEYNOTMATCH;
@@ -704,7 +704,7 @@ wolfssl_connect_step2(struct connectdata *conn,
char *protocol = NULL;
unsigned short protocol_len = 0;
- rc = wolfSSL_ALPN_GetProtocol(backend->handle, &protocol, &protocol_len);
+ rc = wolfSSL_ALPN_GetProtocol(backend->handle, &protocol, &protocol_len);
if(rc == SSL_SUCCESS) {
infof(data, "ALPN, server accepted to use %.*s\n", protocol_len,
@@ -738,8 +738,8 @@ wolfssl_connect_step2(struct connectdata *conn,
connssl->connecting_state = ssl_connect_3;
#if (LIBWOLFSSL_VERSION_HEX >= 0x03009010)
infof(data, "SSL connection using %s / %s\n",
- wolfSSL_get_version(backend->handle),
- wolfSSL_get_cipher_name(backend->handle));
+ wolfSSL_get_version(backend->handle),
+ wolfSSL_get_cipher_name(backend->handle));
#else
infof(data, "SSL connected\n");
#endif
@@ -755,7 +755,7 @@ wolfssl_connect_step3(struct connectdata *conn,
CURLcode result = CURLE_OK;
struct Curl_easy *data = conn->data;
struct ssl_connect_data *connssl = &conn->ssl[sockindex];
- struct ssl_backend_data *backend = connssl->backend;
+ struct ssl_backend_data *backend = connssl->backend;
DEBUGASSERT(ssl_connect_3 == connssl->connecting_state);
@@ -764,7 +764,7 @@ wolfssl_connect_step3(struct connectdata *conn,
SSL_SESSION *our_ssl_sessionid;
void *old_ssl_sessionid = NULL;
- our_ssl_sessionid = SSL_get_session(backend->handle);
+ our_ssl_sessionid = SSL_get_session(backend->handle);
Curl_ssl_sessionid_lock(conn);
incache = !(Curl_ssl_getsessionid(conn, &old_ssl_sessionid, NULL,
@@ -802,13 +802,13 @@ static ssize_t wolfssl_send(struct connectdata *conn,
CURLcode *curlcode)
{
struct ssl_connect_data *connssl = &conn->ssl[sockindex];
- struct ssl_backend_data *backend = connssl->backend;
+ struct ssl_backend_data *backend = connssl->backend;
char error_buffer[WOLFSSL_MAX_ERROR_SZ];
- int memlen = (len > (size_t)INT_MAX) ? INT_MAX : (int)len;
- int rc = SSL_write(backend->handle, mem, memlen);
+ int memlen = (len > (size_t)INT_MAX) ? INT_MAX : (int)len;
+ int rc = SSL_write(backend->handle, mem, memlen);
if(rc < 0) {
- int err = SSL_get_error(backend->handle, rc);
+ int err = SSL_get_error(backend->handle, rc);
switch(err) {
case SSL_ERROR_WANT_READ:
@@ -830,33 +830,33 @@ static ssize_t wolfssl_send(struct connectdata *conn,
static void Curl_wolfssl_close(struct connectdata *conn, int sockindex)
{
struct ssl_connect_data *connssl = &conn->ssl[sockindex];
- struct ssl_backend_data *backend = connssl->backend;
+ struct ssl_backend_data *backend = connssl->backend;
- if(backend->handle) {
- (void)SSL_shutdown(backend->handle);
- SSL_free(backend->handle);
- backend->handle = NULL;
+ if(backend->handle) {
+ (void)SSL_shutdown(backend->handle);
+ SSL_free(backend->handle);
+ backend->handle = NULL;
}
- if(backend->ctx) {
- SSL_CTX_free(backend->ctx);
- backend->ctx = NULL;
+ if(backend->ctx) {
+ SSL_CTX_free(backend->ctx);
+ backend->ctx = NULL;
}
}
static ssize_t wolfssl_recv(struct connectdata *conn,
- int num,
- char *buf,
- size_t buffersize,
- CURLcode *curlcode)
+ int num,
+ char *buf,
+ size_t buffersize,
+ CURLcode *curlcode)
{
struct ssl_connect_data *connssl = &conn->ssl[num];
- struct ssl_backend_data *backend = connssl->backend;
+ struct ssl_backend_data *backend = connssl->backend;
char error_buffer[WOLFSSL_MAX_ERROR_SZ];
- int buffsize = (buffersize > (size_t)INT_MAX) ? INT_MAX : (int)buffersize;
- int nread = SSL_read(backend->handle, buf, buffsize);
+ int buffsize = (buffersize > (size_t)INT_MAX) ? INT_MAX : (int)buffersize;
+ int nread = SSL_read(backend->handle, buf, buffsize);
if(nread < 0) {
- int err = SSL_get_error(backend->handle, nread);
+ int err = SSL_get_error(backend->handle, nread);
switch(err) {
case SSL_ERROR_ZERO_RETURN: /* no more data */
@@ -897,9 +897,9 @@ static size_t Curl_wolfssl_version(char *buffer, size_t size)
static int Curl_wolfssl_init(void)
{
-#ifdef OPENSSL_EXTRA
- Curl_tls_keylog_open();
-#endif
+#ifdef OPENSSL_EXTRA
+ Curl_tls_keylog_open();
+#endif
return (wolfSSL_Init() == SSL_SUCCESS);
}
@@ -907,19 +907,19 @@ static int Curl_wolfssl_init(void)
static void Curl_wolfssl_cleanup(void)
{
wolfSSL_Cleanup();
-#ifdef OPENSSL_EXTRA
- Curl_tls_keylog_close();
-#endif
+#ifdef OPENSSL_EXTRA
+ Curl_tls_keylog_close();
+#endif
}
-static bool Curl_wolfssl_data_pending(const struct connectdata *conn,
- int connindex)
+static bool Curl_wolfssl_data_pending(const struct connectdata *conn,
+ int connindex)
{
const struct ssl_connect_data *connssl = &conn->ssl[connindex];
- struct ssl_backend_data *backend = connssl->backend;
- if(backend->handle) /* SSL is in use */
- return (0 != SSL_pending(backend->handle)) ? TRUE : FALSE;
+ struct ssl_backend_data *backend = connssl->backend;
+ if(backend->handle) /* SSL is in use */
+ return (0 != SSL_pending(backend->handle)) ? TRUE : FALSE;
else
return FALSE;
}
@@ -933,11 +933,11 @@ static int Curl_wolfssl_shutdown(struct connectdata *conn, int sockindex)
{
int retval = 0;
struct ssl_connect_data *connssl = &conn->ssl[sockindex];
- struct ssl_backend_data *backend = connssl->backend;
+ struct ssl_backend_data *backend = connssl->backend;
- if(backend->handle) {
- SSL_free(backend->handle);
- backend->handle = NULL;
+ if(backend->handle) {
+ SSL_free(backend->handle);
+ backend->handle = NULL;
}
return retval;
}
@@ -963,7 +963,7 @@ wolfssl_connect_common(struct connectdata *conn,
if(ssl_connect_1 == connssl->connecting_state) {
/* Find out how much more time we're allowed */
- const timediff_t timeout_ms = Curl_timeleft(data, NULL, TRUE);
+ const timediff_t timeout_ms = Curl_timeleft(data, NULL, TRUE);
if(timeout_ms < 0) {
/* no need to continue if time already is up */
@@ -981,7 +981,7 @@ wolfssl_connect_common(struct connectdata *conn,
ssl_connect_2_writing == connssl->connecting_state) {
/* check allowed time left */
- const timediff_t timeout_ms = Curl_timeleft(data, NULL, TRUE);
+ const timediff_t timeout_ms = Curl_timeleft(data, NULL, TRUE);
if(timeout_ms < 0) {
/* no need to continue if time already is up */
@@ -1080,7 +1080,7 @@ static CURLcode Curl_wolfssl_connect(struct connectdata *conn, int sockindex)
static CURLcode Curl_wolfssl_random(struct Curl_easy *data,
unsigned char *entropy, size_t length)
{
- WC_RNG rng;
+ WC_RNG rng;
(void)data;
if(wc_InitRng(&rng))
return CURLE_FAILED_INIT;
@@ -1094,11 +1094,11 @@ static CURLcode Curl_wolfssl_random(struct Curl_easy *data,
}
static CURLcode Curl_wolfssl_sha256sum(const unsigned char *tmp, /* input */
- size_t tmplen,
- unsigned char *sha256sum /* output */,
- size_t unused)
+ size_t tmplen,
+ unsigned char *sha256sum /* output */,
+ size_t unused)
{
- wc_Sha256 SHA256pw;
+ wc_Sha256 SHA256pw;
(void)unused;
wc_InitSha256(&SHA256pw);
wc_Sha256Update(&SHA256pw, tmp, (word32)tmplen);
@@ -1107,11 +1107,11 @@ static CURLcode Curl_wolfssl_sha256sum(const unsigned char *tmp, /* input */
}
static void *Curl_wolfssl_get_internals(struct ssl_connect_data *connssl,
- CURLINFO info UNUSED_PARAM)
+ CURLINFO info UNUSED_PARAM)
{
- struct ssl_backend_data *backend = connssl->backend;
+ struct ssl_backend_data *backend = connssl->backend;
(void)info;
- return backend->handle;
+ return backend->handle;
}
const struct Curl_ssl Curl_ssl_wolfssl = {
diff --git a/contrib/libs/curl/lib/vtls/wolfssl.h b/contrib/libs/curl/lib/vtls/wolfssl.h
index 7c8b9e07dd..d411e6913e 100644
--- a/contrib/libs/curl/lib/vtls/wolfssl.h
+++ b/contrib/libs/curl/lib/vtls/wolfssl.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/warnless.c b/contrib/libs/curl/lib/warnless.c
index bfd7721776..908ee6cb70 100644
--- a/contrib/libs/curl/lib/warnless.c
+++ b/contrib/libs/curl/lib/warnless.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/warnless.h b/contrib/libs/curl/lib/warnless.h
index 81940b718a..ca3737859b 100644
--- a/contrib/libs/curl/lib/warnless.h
+++ b/contrib/libs/curl/lib/warnless.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/wildcard.c b/contrib/libs/curl/lib/wildcard.c
index 5f2a5d0913..105bcce4ed 100644
--- a/contrib/libs/curl/lib/wildcard.c
+++ b/contrib/libs/curl/lib/wildcard.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
diff --git a/contrib/libs/curl/lib/wildcard.h b/contrib/libs/curl/lib/wildcard.h
index 52584f4a6a..081be9ed93 100644
--- a/contrib/libs/curl/lib/wildcard.h
+++ b/contrib/libs/curl/lib/wildcard.h
@@ -7,11 +7,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 2010 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2010 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -39,18 +39,18 @@ typedef enum {
CURLWC_ERROR, /* error cases */
CURLWC_DONE /* if is wildcard->state == CURLWC_DONE wildcard loop
will end */
-} wildcard_states;
+} wildcard_states;
-typedef void (*wildcard_dtor)(void *ptr);
+typedef void (*wildcard_dtor)(void *ptr);
/* struct keeping information about wildcard download process */
struct WildcardData {
- wildcard_states state;
+ wildcard_states state;
char *path; /* path to the directory, where we trying wildcard-match */
char *pattern; /* wildcard pattern */
- struct Curl_llist filelist; /* llist with struct Curl_fileinfo */
+ struct Curl_llist filelist; /* llist with struct Curl_fileinfo */
void *protdata; /* pointer to protocol specific temporary data */
- wildcard_dtor dtor;
+ wildcard_dtor dtor;
void *customptr; /* for CURLOPT_CHUNK_DATA pointer */
};
diff --git a/contrib/libs/curl/lib/x509asn1.c b/contrib/libs/curl/lib/x509asn1.c
index f3bf0fd7f6..d7cf9eb2af 100644
--- a/contrib/libs/curl/lib/x509asn1.c
+++ b/contrib/libs/curl/lib/x509asn1.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -44,7 +44,7 @@
static const char cnOID[] = "2.5.4.3"; /* Common name. */
static const char sanOID[] = "2.5.29.17"; /* Subject alternative name. */
-static const struct Curl_OID OIDtable[] = {
+static const struct Curl_OID OIDtable[] = {
{ "1.2.840.10040.4.1", "dsa" },
{ "1.2.840.10040.4.3", "dsa-with-sha1" },
{ "1.2.840.10045.2.1", "ecPublicKey" },
@@ -103,16 +103,16 @@ static const struct Curl_OID OIDtable[] = {
* Please note there is no pretention here to rewrite a full SSL library.
*/
-static const char *getASN1Element(struct Curl_asn1Element *elem,
+static const char *getASN1Element(struct Curl_asn1Element *elem,
const char *beg, const char *end)
WARN_UNUSED_RESULT;
-static const char *getASN1Element(struct Curl_asn1Element *elem,
+static const char *getASN1Element(struct Curl_asn1Element *elem,
const char *beg, const char *end)
{
unsigned char b;
unsigned long len;
- struct Curl_asn1Element lelem;
+ struct Curl_asn1Element lelem;
/* Get a single ASN.1 element into `elem', parse ASN.1 string at `beg'
ending at `end'.
@@ -176,9 +176,9 @@ static const char *getASN1Element(struct Curl_asn1Element *elem,
* Search the null terminated OID or OID identifier in local table.
* Return the table entry pointer or NULL if not found.
*/
-static const struct Curl_OID *searchOID(const char *oid)
+static const struct Curl_OID *searchOID(const char *oid)
{
- const struct Curl_OID *op;
+ const struct Curl_OID *op;
for(op = OIDtable; op->numoid; op++)
if(!strcmp(op->numoid, oid) || strcasecompare(op->textoid, oid))
return op;
@@ -445,7 +445,7 @@ static const char *OID2str(const char *beg, const char *end, bool symbolic)
buf[buflen] = '\0';
if(symbolic) {
- const struct Curl_OID *op = searchOID(buf);
+ const struct Curl_OID *op = searchOID(buf);
if(op) {
free(buf);
buf = strdup(op->textoid);
@@ -565,7 +565,7 @@ static const char *UTime2str(const char *beg, const char *end)
* Convert an ASN.1 element to a printable string.
* Return the dynamically allocated string, or NULL if an error occurs.
*/
-static const char *ASN1tostr(struct Curl_asn1Element *elem, int type)
+static const char *ASN1tostr(struct Curl_asn1Element *elem, int type)
{
if(elem->constructed)
return NULL; /* No conversion of structured elements. */
@@ -609,12 +609,12 @@ static const char *ASN1tostr(struct Curl_asn1Element *elem, int type)
* ASCII encode distinguished name at `dn' into the `buflen'-sized buffer at
* `buf'. Return the total string length, even if larger than `buflen'.
*/
-static ssize_t encodeDN(char *buf, size_t buflen, struct Curl_asn1Element *dn)
+static ssize_t encodeDN(char *buf, size_t buflen, struct Curl_asn1Element *dn)
{
- struct Curl_asn1Element rdn;
- struct Curl_asn1Element atv;
- struct Curl_asn1Element oid;
- struct Curl_asn1Element value;
+ struct Curl_asn1Element rdn;
+ struct Curl_asn1Element atv;
+ struct Curl_asn1Element oid;
+ struct Curl_asn1Element value;
size_t l = 0;
const char *p1;
const char *p2;
@@ -683,7 +683,7 @@ static ssize_t encodeDN(char *buf, size_t buflen, struct Curl_asn1Element *dn)
* Convert an ASN.1 distinguished name into a printable string.
* Return the dynamically allocated string, or NULL if an error occurs.
*/
-static const char *DNtostr(struct Curl_asn1Element *dn)
+static const char *DNtostr(struct Curl_asn1Element *dn)
{
char *buf = NULL;
ssize_t buflen = encodeDN(NULL, 0, dn);
@@ -703,11 +703,11 @@ static const char *DNtostr(struct Curl_asn1Element *dn)
* Syntax is assumed to have already been checked by the SSL backend.
* See RFC 5280.
*/
-int Curl_parseX509(struct Curl_X509certificate *cert,
+int Curl_parseX509(struct Curl_X509certificate *cert,
const char *beg, const char *end)
{
- struct Curl_asn1Element elem;
- struct Curl_asn1Element tbsCertificate;
+ struct Curl_asn1Element elem;
+ struct Curl_asn1Element tbsCertificate;
const char *ccp;
static const char defaultVersion = 0; /* v1. */
@@ -835,10 +835,10 @@ static size_t copySubstring(char *to, const char *from)
return i;
}
-static const char *dumpAlgo(struct Curl_asn1Element *param,
+static const char *dumpAlgo(struct Curl_asn1Element *param,
const char *beg, const char *end)
{
- struct Curl_asn1Element oid;
+ struct Curl_asn1Element oid;
/* Get algorithm parameters and return algorithm name. */
@@ -855,7 +855,7 @@ static const char *dumpAlgo(struct Curl_asn1Element *param,
}
static void do_pubkey_field(struct Curl_easy *data, int certnum,
- const char *label, struct Curl_asn1Element *elem)
+ const char *label, struct Curl_asn1Element *elem)
{
const char *output;
@@ -872,11 +872,11 @@ static void do_pubkey_field(struct Curl_easy *data, int certnum,
}
static void do_pubkey(struct Curl_easy *data, int certnum,
- const char *algo, struct Curl_asn1Element *param,
- struct Curl_asn1Element *pubkey)
+ const char *algo, struct Curl_asn1Element *param,
+ struct Curl_asn1Element *pubkey)
{
- struct Curl_asn1Element elem;
- struct Curl_asn1Element pk;
+ struct Curl_asn1Element elem;
+ struct Curl_asn1Element pk;
const char *p;
/* Generate all information records for the public key. */
@@ -950,9 +950,9 @@ CURLcode Curl_extract_certinfo(struct connectdata *conn,
const char *beg,
const char *end)
{
- struct Curl_X509certificate cert;
+ struct Curl_X509certificate cert;
struct Curl_easy *data = conn->data;
- struct Curl_asn1Element param;
+ struct Curl_asn1Element param;
const char *ccp;
char *cp1;
size_t cl1;
@@ -1111,7 +1111,7 @@ CURLcode Curl_extract_certinfo(struct connectdata *conn,
static const char *checkOID(const char *beg, const char *end,
const char *oid)
{
- struct Curl_asn1Element e;
+ struct Curl_asn1Element e;
const char *ccp;
const char *p;
bool matched;
@@ -1136,21 +1136,21 @@ CURLcode Curl_verifyhost(struct connectdata *conn,
const char *beg, const char *end)
{
struct Curl_easy *data = conn->data;
- struct Curl_X509certificate cert;
- struct Curl_asn1Element dn;
- struct Curl_asn1Element elem;
- struct Curl_asn1Element ext;
- struct Curl_asn1Element name;
+ struct Curl_X509certificate cert;
+ struct Curl_asn1Element dn;
+ struct Curl_asn1Element elem;
+ struct Curl_asn1Element ext;
+ struct Curl_asn1Element name;
const char *p;
const char *q;
char *dnsname;
int matched = -1;
size_t addrlen = (size_t) -1;
ssize_t len;
- const char *const hostname = SSL_IS_PROXY()?
- conn->http_proxy.host.name : conn->host.name;
- const char *const dispname = SSL_IS_PROXY()?
- conn->http_proxy.host.dispname : conn->host.dispname;
+ const char *const hostname = SSL_IS_PROXY()?
+ conn->http_proxy.host.name : conn->host.name;
+ const char *const dispname = SSL_IS_PROXY()?
+ conn->http_proxy.host.dispname : conn->host.dispname;
#ifdef ENABLE_IPV6
struct in6_addr addr;
#else
diff --git a/contrib/libs/curl/lib/x509asn1.h b/contrib/libs/curl/lib/x509asn1.h
index e63f4afc08..849714492d 100644
--- a/contrib/libs/curl/lib/x509asn1.h
+++ b/contrib/libs/curl/lib/x509asn1.h
@@ -8,11 +8,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, 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
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -79,51 +79,51 @@
*/
/* ASN.1 parsed element. */
-struct Curl_asn1Element {
- const char *header; /* Pointer to header byte. */
- const char *beg; /* Pointer to element data. */
- const char *end; /* Pointer to 1st byte after element. */
- unsigned char class; /* ASN.1 element class. */
- unsigned char tag; /* ASN.1 element tag. */
- bool constructed; /* Element is constructed. */
-};
+struct Curl_asn1Element {
+ const char *header; /* Pointer to header byte. */
+ const char *beg; /* Pointer to element data. */
+ const char *end; /* Pointer to 1st byte after element. */
+ unsigned char class; /* ASN.1 element class. */
+ unsigned char tag; /* ASN.1 element tag. */
+ bool constructed; /* Element is constructed. */
+};
/* ASN.1 OID table entry. */
-struct Curl_OID {
- const char *numoid; /* Dotted-numeric OID. */
- const char *textoid; /* OID name. */
-};
+struct Curl_OID {
+ const char *numoid; /* Dotted-numeric OID. */
+ const char *textoid; /* OID name. */
+};
/* X509 certificate: RFC 5280. */
-struct Curl_X509certificate {
- struct Curl_asn1Element certificate;
- struct Curl_asn1Element version;
- struct Curl_asn1Element serialNumber;
- struct Curl_asn1Element signatureAlgorithm;
- struct Curl_asn1Element signature;
- struct Curl_asn1Element issuer;
- struct Curl_asn1Element notBefore;
- struct Curl_asn1Element notAfter;
- struct Curl_asn1Element subject;
- struct Curl_asn1Element subjectPublicKeyInfo;
- struct Curl_asn1Element subjectPublicKeyAlgorithm;
- struct Curl_asn1Element subjectPublicKey;
- struct Curl_asn1Element issuerUniqueID;
- struct Curl_asn1Element subjectUniqueID;
- struct Curl_asn1Element extensions;
-};
+struct Curl_X509certificate {
+ struct Curl_asn1Element certificate;
+ struct Curl_asn1Element version;
+ struct Curl_asn1Element serialNumber;
+ struct Curl_asn1Element signatureAlgorithm;
+ struct Curl_asn1Element signature;
+ struct Curl_asn1Element issuer;
+ struct Curl_asn1Element notBefore;
+ struct Curl_asn1Element notAfter;
+ struct Curl_asn1Element subject;
+ struct Curl_asn1Element subjectPublicKeyInfo;
+ struct Curl_asn1Element subjectPublicKeyAlgorithm;
+ struct Curl_asn1Element subjectPublicKey;
+ struct Curl_asn1Element issuerUniqueID;
+ struct Curl_asn1Element subjectUniqueID;
+ struct Curl_asn1Element extensions;
+};
/*
* Prototypes.
*/
-const char *Curl_getASN1Element(struct Curl_asn1Element *elem,
- const char *beg, const char *end);
-const char *Curl_ASN1tostr(struct Curl_asn1Element *elem, int type);
-const char *Curl_DNtostr(struct Curl_asn1Element *dn);
-int Curl_parseX509(struct Curl_X509certificate *cert,
+const char *Curl_getASN1Element(struct Curl_asn1Element *elem,
+ const char *beg, const char *end);
+const char *Curl_ASN1tostr(struct Curl_asn1Element *elem, int type);
+const char *Curl_DNtostr(struct Curl_asn1Element *dn);
+int Curl_parseX509(struct Curl_X509certificate *cert,
const char *beg, const char *end);
CURLcode Curl_extract_certinfo(struct connectdata *conn, int certnum,
const char *beg, const char *end);