From b14c227e81e60d9d87b6a56074d47f8b92727db8 Mon Sep 17 00:00:00 2001 From: dartraiden Date: Wed, 4 Jun 2025 10:22:08 +0300 Subject: libcurl: update to 8.14.1 --- libs/libcurl/src/CMakeLists.txt | 9 +- libs/libcurl/src/Makefile.am | 9 -- libs/libcurl/src/Makefile.in | 112 +++++++-------- libs/libcurl/src/altsvc.c | 2 +- libs/libcurl/src/asyn-thrdd.c | 13 +- libs/libcurl/src/cf-https-connect.c | 2 +- libs/libcurl/src/cfilters.c | 5 + libs/libcurl/src/cfilters.h | 5 + libs/libcurl/src/config-win32.h | 11 +- libs/libcurl/src/curl_addrinfo.c | 4 +- libs/libcurl/src/curl_config.h.cmake | 4 +- libs/libcurl/src/curl_config.h.in | 4 +- libs/libcurl/src/curl_setup.h | 10 ++ libs/libcurl/src/curl_sspi.c | 4 +- libs/libcurl/src/curl_sspi.h | 2 +- libs/libcurl/src/curlx/base64.c | 10 +- libs/libcurl/src/dllmain.c | 13 +- libs/libcurl/src/doh.c | 2 +- libs/libcurl/src/dynhds.h | 4 +- libs/libcurl/src/ftp.c | 13 +- libs/libcurl/src/headers.c | 4 +- libs/libcurl/src/hsts.c | 4 +- libs/libcurl/src/http.c | 24 +++- libs/libcurl/src/http1.c | 2 +- libs/libcurl/src/http_aws_sigv4.c | 4 +- libs/libcurl/src/http_aws_sigv4.h | 2 +- libs/libcurl/src/http_chunks.h | 4 +- libs/libcurl/src/imap.c | 2 +- libs/libcurl/src/inet_ntop.c | 2 +- libs/libcurl/src/multi.c | 5 +- libs/libcurl/src/multi_ev.c | 2 +- libs/libcurl/src/noproxy.c | 2 +- libs/libcurl/src/pop3.c | 2 +- libs/libcurl/src/setopt.c | 4 +- libs/libcurl/src/smb.c | 4 +- libs/libcurl/src/smtp.c | 6 +- libs/libcurl/src/socks.c | 2 +- libs/libcurl/src/strcase.c | 6 +- libs/libcurl/src/strdup.c | 2 +- libs/libcurl/src/system_win32.c | 2 +- libs/libcurl/src/transfer.h | 2 +- libs/libcurl/src/uint-table.h | 2 +- libs/libcurl/src/url.c | 2 +- libs/libcurl/src/vauth/digest.c | 2 +- libs/libcurl/src/vauth/digest_sspi.c | 2 +- libs/libcurl/src/vauth/vauth.c | 2 +- libs/libcurl/src/vauth/vauth.h | 2 +- libs/libcurl/src/vquic/curl_osslq.c | 2 +- libs/libcurl/src/vssh/libssh.c | 6 +- libs/libcurl/src/vssh/libssh2.c | 2 +- libs/libcurl/src/vtls/gtls.c | 2 +- libs/libcurl/src/vtls/keylog.c | 2 +- libs/libcurl/src/vtls/keylog.h | 2 +- libs/libcurl/src/vtls/openssl.c | 8 +- libs/libcurl/src/vtls/schannel_verify.c | 2 +- libs/libcurl/src/vtls/vtls.c | 8 +- libs/libcurl/src/vtls/vtls_scache.c | 13 +- libs/libcurl/src/vtls/vtls_scache.h | 2 +- libs/libcurl/src/vtls/wolfssl.c | 24 ++-- libs/libcurl/src/vtls/x509asn1.c | 2 +- libs/libcurl/src/ws.c | 236 ++++++++++++++++++++++---------- 61 files changed, 365 insertions(+), 283 deletions(-) (limited to 'libs/libcurl/src') diff --git a/libs/libcurl/src/CMakeLists.txt b/libs/libcurl/src/CMakeLists.txt index 83af0375c7..e37b62b031 100644 --- a/libs/libcurl/src/CMakeLists.txt +++ b/libs/libcurl/src/CMakeLists.txt @@ -179,15 +179,8 @@ if(BUILD_SHARED_LIBS) list(APPEND libcurl_export ${LIB_SHARED}) add_library(${LIB_SHARED} SHARED ${LIB_SOURCE}) add_library(${PROJECT_NAME}::${LIB_SHARED} ALIAS ${LIB_SHARED}) - if(WIN32 OR CYGWIN) - if(CYGWIN) - # For Cygwin always compile dllmain.c as a separate unit since it - # includes windows.h, which should not be included in other units. - set_source_files_properties("dllmain.c" PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON) - endif() - set_property(TARGET ${LIB_SHARED} APPEND PROPERTY SOURCES "dllmain.c") - endif() if(WIN32) + set_property(TARGET ${LIB_SHARED} APPEND PROPERTY SOURCES "dllmain.c") set_property(TARGET ${LIB_SHARED} APPEND PROPERTY SOURCES "libcurl.rc") if(CURL_HIDES_PRIVATE_SYMBOLS) set_property(TARGET ${LIB_SHARED} APPEND PROPERTY SOURCES "${PROJECT_SOURCE_DIR}/lib/libcurl.def") diff --git a/libs/libcurl/src/Makefile.am b/libs/libcurl/src/Makefile.am index 29cc31dfab..c91619fd6e 100644 --- a/libs/libcurl/src/Makefile.am +++ b/libs/libcurl/src/Makefile.am @@ -74,10 +74,6 @@ include Makefile.inc if DOING_NATIVE_WINDOWS CSOURCES += dllmain.c -else -if DOING_CYGWIN -CSOURCES += dllmain.c -endif endif if USE_UNITY @@ -89,11 +85,6 @@ if CURLDEBUG # applying to it. curl_EXCLUDE += memdebug.c endif -# For Cygwin always compile dllmain.c as a separate unit since it -# includes windows.h, which should not be included in other units. -if DOING_CYGWIN -curl_EXCLUDE += dllmain.c -endif libcurl_unity.c: $(top_srcdir)/scripts/mk-unity.pl $(CSOURCES) @PERL@ $(top_srcdir)/scripts/mk-unity.pl $(srcdir) $(CSOURCES) --exclude $(curl_EXCLUDE) > libcurl_unity.c diff --git a/libs/libcurl/src/Makefile.in b/libs/libcurl/src/Makefile.in index bbd7e6c17c..b019dc913c 100644 --- a/libs/libcurl/src/Makefile.in +++ b/libs/libcurl/src/Makefile.in @@ -141,24 +141,20 @@ host_triplet = @host@ # Makefile.inc provides the CSOURCES and HHEADERS defines @DOING_NATIVE_WINDOWS_TRUE@am__append_3 = dllmain.c -@DOING_CYGWIN_TRUE@@DOING_NATIVE_WINDOWS_FALSE@am__append_4 = dllmain.c # We must compile this source separately to avoid memdebug.h redefinitions # applying to it. -@CURLDEBUG_TRUE@@USE_UNITY_TRUE@am__append_5 = memdebug.c -# For Cygwin always compile dllmain.c as a separate unit since it -# includes windows.h, which should not be included in other units. -@DOING_CYGWIN_TRUE@@USE_UNITY_TRUE@am__append_6 = dllmain.c -@CURL_LT_SHLIB_USE_VERSION_INFO_TRUE@am__append_7 = $(VERSIONINFO) -@CURL_LT_SHLIB_USE_NO_UNDEFINED_TRUE@am__append_8 = -no-undefined -@CURL_LT_SHLIB_USE_MIMPURE_TEXT_TRUE@am__append_9 = -mimpure-text -@CURL_LT_SHLIB_USE_VERSIONED_SYMBOLS_TRUE@am__append_10 = -Wl,--version-script=libcurl.vers +@CURLDEBUG_TRUE@@USE_UNITY_TRUE@am__append_4 = memdebug.c +@CURL_LT_SHLIB_USE_VERSION_INFO_TRUE@am__append_5 = $(VERSIONINFO) +@CURL_LT_SHLIB_USE_NO_UNDEFINED_TRUE@am__append_6 = -no-undefined +@CURL_LT_SHLIB_USE_MIMPURE_TEXT_TRUE@am__append_7 = -mimpure-text +@CURL_LT_SHLIB_USE_VERSIONED_SYMBOLS_TRUE@am__append_8 = -Wl,--version-script=libcurl.vers # if symbol-hiding is enabled, hide them! -@CURL_LT_SHLIB_USE_VERSIONED_SYMBOLS_FALSE@@DOING_CURL_SYMBOL_HIDING_TRUE@am__append_11 = -export-symbols-regex '^curl_.*' -@USE_CPPFLAG_CURL_STATICLIB_TRUE@am__append_12 = -DCURL_STATICLIB -@HAVE_WINDRES_TRUE@@USE_CPPFLAG_CURL_STATICLIB_FALSE@am__append_13 = $(LIB_RCFILES) -@DOING_CURL_SYMBOL_HIDING_TRUE@am__append_14 = -DCURL_HIDDEN_SYMBOLS -@DOING_CURL_SYMBOL_HIDING_TRUE@am__append_15 = $(CFLAG_CURL_SYMBOL_HIDING) -@CURL_WERROR_TRUE@am__append_16 = --warnings-as-errors=* +@CURL_LT_SHLIB_USE_VERSIONED_SYMBOLS_FALSE@@DOING_CURL_SYMBOL_HIDING_TRUE@am__append_9 = -export-symbols-regex '^curl_.*' +@USE_CPPFLAG_CURL_STATICLIB_TRUE@am__append_10 = -DCURL_STATICLIB +@HAVE_WINDRES_TRUE@@USE_CPPFLAG_CURL_STATICLIB_FALSE@am__append_11 = $(LIB_RCFILES) +@DOING_CURL_SYMBOL_HIDING_TRUE@am__append_12 = -DCURL_HIDDEN_SYMBOLS +@DOING_CURL_SYMBOL_HIDING_TRUE@am__append_13 = $(CFLAG_CURL_SYMBOL_HIDING) +@CURL_WERROR_TRUE@am__append_14 = --warnings-as-errors=* subdir = lib ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/curl-amissl.m4 \ @@ -388,27 +384,23 @@ am__objects_6 = curlx/libcurl_la-base64.lo curlx/libcurl_la-dynbuf.lo \ curlx/libcurl_la-version_win32.lo curlx/libcurl_la-warnless.lo \ curlx/libcurl_la-winapi.lo @DOING_NATIVE_WINDOWS_TRUE@am__objects_7 = libcurl_la-dllmain.lo -@DOING_CYGWIN_TRUE@@DOING_NATIVE_WINDOWS_FALSE@am__objects_8 = libcurl_la-dllmain.lo -am__objects_9 = $(am__objects_1) $(am__objects_2) $(am__objects_3) \ +am__objects_8 = $(am__objects_1) $(am__objects_2) $(am__objects_3) \ $(am__objects_4) $(am__objects_5) $(am__objects_6) \ - $(am__objects_7) $(am__objects_8) -am__objects_10 = -am__objects_11 = $(am__objects_10) $(am__objects_10) $(am__objects_10) \ - $(am__objects_10) $(am__objects_10) $(am__objects_10) -am__objects_12 = libcurl.lo -@HAVE_WINDRES_TRUE@@USE_CPPFLAG_CURL_STATICLIB_FALSE@am__objects_13 = $(am__objects_12) -@CURLDEBUG_TRUE@@USE_UNITY_TRUE@am__objects_14 = \ + $(am__objects_7) +am__objects_9 = +am__objects_10 = $(am__objects_9) $(am__objects_9) $(am__objects_9) \ + $(am__objects_9) $(am__objects_9) $(am__objects_9) +am__objects_11 = libcurl.lo +@HAVE_WINDRES_TRUE@@USE_CPPFLAG_CURL_STATICLIB_FALSE@am__objects_12 = $(am__objects_11) +@CURLDEBUG_TRUE@@USE_UNITY_TRUE@am__objects_13 = \ @CURLDEBUG_TRUE@@USE_UNITY_TRUE@ libcurl_la-memdebug.lo -@DOING_CYGWIN_TRUE@@USE_UNITY_TRUE@am__objects_15 = \ -@DOING_CYGWIN_TRUE@@USE_UNITY_TRUE@ libcurl_la-dllmain.lo -@USE_UNITY_TRUE@am__objects_16 = libcurl_la-curl_threads.lo \ +@USE_UNITY_TRUE@am__objects_14 = libcurl_la-curl_threads.lo \ @USE_UNITY_TRUE@ curlx/libcurl_la-timediff.lo \ -@USE_UNITY_TRUE@ curlx/libcurl_la-warnless.lo $(am__objects_14) \ -@USE_UNITY_TRUE@ $(am__objects_15) -@USE_UNITY_FALSE@am_libcurl_la_OBJECTS = $(am__objects_9) \ -@USE_UNITY_FALSE@ $(am__objects_11) $(am__objects_13) -@USE_UNITY_TRUE@am_libcurl_la_OBJECTS = $(am__objects_16) \ -@USE_UNITY_TRUE@ $(am__objects_13) +@USE_UNITY_TRUE@ curlx/libcurl_la-warnless.lo $(am__objects_13) +@USE_UNITY_FALSE@am_libcurl_la_OBJECTS = $(am__objects_8) \ +@USE_UNITY_FALSE@ $(am__objects_10) $(am__objects_12) +@USE_UNITY_TRUE@am_libcurl_la_OBJECTS = $(am__objects_14) \ +@USE_UNITY_TRUE@ $(am__objects_12) @USE_UNITY_TRUE@nodist_libcurl_la_OBJECTS = \ @USE_UNITY_TRUE@ libcurl_la-libcurl_unity.lo libcurl_la_OBJECTS = $(am_libcurl_la_OBJECTS) \ @@ -500,7 +492,7 @@ am__libcurlu_la_SOURCES_DIST = altsvc.c amigaos.c asyn-ares.c \ curlx/multibyte.h curlx/nonblock.h curlx/strparse.h \ curlx/timediff.h curlx/timeval.h curlx/version_win32.h \ curlx/warnless.h curlx/winapi.h -am__objects_17 = libcurlu_la-altsvc.lo libcurlu_la-amigaos.lo \ +am__objects_15 = libcurlu_la-altsvc.lo libcurlu_la-amigaos.lo \ libcurlu_la-asyn-ares.lo libcurlu_la-asyn-base.lo \ libcurlu_la-asyn-thrdd.lo libcurlu_la-bufq.lo \ libcurlu_la-bufref.lo libcurlu_la-cf-h1-proxy.lo \ @@ -559,7 +551,7 @@ am__objects_17 = libcurlu_la-altsvc.lo libcurlu_la-amigaos.lo \ libcurlu_la-uint-hash.lo libcurlu_la-uint-spbset.lo \ libcurlu_la-uint-table.lo libcurlu_la-url.lo \ libcurlu_la-urlapi.lo libcurlu_la-version.lo libcurlu_la-ws.lo -am__objects_18 = vauth/libcurlu_la-cleartext.lo \ +am__objects_16 = vauth/libcurlu_la-cleartext.lo \ vauth/libcurlu_la-cram.lo vauth/libcurlu_la-digest.lo \ vauth/libcurlu_la-digest_sspi.lo vauth/libcurlu_la-gsasl.lo \ vauth/libcurlu_la-krb5_gssapi.lo \ @@ -567,7 +559,7 @@ am__objects_18 = vauth/libcurlu_la-cleartext.lo \ vauth/libcurlu_la-ntlm_sspi.lo vauth/libcurlu_la-oauth2.lo \ vauth/libcurlu_la-spnego_gssapi.lo \ vauth/libcurlu_la-spnego_sspi.lo vauth/libcurlu_la-vauth.lo -am__objects_19 = vtls/libcurlu_la-bearssl.lo \ +am__objects_17 = vtls/libcurlu_la-bearssl.lo \ vtls/libcurlu_la-cipher_suite.lo vtls/libcurlu_la-gtls.lo \ vtls/libcurlu_la-hostcheck.lo vtls/libcurlu_la-keylog.lo \ vtls/libcurlu_la-mbedtls.lo \ @@ -578,37 +570,34 @@ am__objects_19 = vtls/libcurlu_la-bearssl.lo \ vtls/libcurlu_la-sectransp.lo vtls/libcurlu_la-vtls.lo \ vtls/libcurlu_la-vtls_scache.lo vtls/libcurlu_la-vtls_spack.lo \ vtls/libcurlu_la-wolfssl.lo vtls/libcurlu_la-x509asn1.lo -am__objects_20 = vquic/libcurlu_la-curl_msh3.lo \ +am__objects_18 = vquic/libcurlu_la-curl_msh3.lo \ vquic/libcurlu_la-curl_ngtcp2.lo \ vquic/libcurlu_la-curl_osslq.lo \ vquic/libcurlu_la-curl_quiche.lo vquic/libcurlu_la-vquic.lo \ vquic/libcurlu_la-vquic-tls.lo -am__objects_21 = vssh/libcurlu_la-libssh.lo \ +am__objects_19 = vssh/libcurlu_la-libssh.lo \ vssh/libcurlu_la-libssh2.lo vssh/libcurlu_la-curl_path.lo \ vssh/libcurlu_la-wolfssh.lo -am__objects_22 = curlx/libcurlu_la-base64.lo \ +am__objects_20 = curlx/libcurlu_la-base64.lo \ curlx/libcurlu_la-dynbuf.lo curlx/libcurlu_la-inet_pton.lo \ curlx/libcurlu_la-multibyte.lo curlx/libcurlu_la-nonblock.lo \ curlx/libcurlu_la-strparse.lo curlx/libcurlu_la-timediff.lo \ curlx/libcurlu_la-timeval.lo \ curlx/libcurlu_la-version_win32.lo \ curlx/libcurlu_la-warnless.lo curlx/libcurlu_la-winapi.lo -@DOING_NATIVE_WINDOWS_TRUE@am__objects_23 = libcurlu_la-dllmain.lo -@DOING_CYGWIN_TRUE@@DOING_NATIVE_WINDOWS_FALSE@am__objects_24 = libcurlu_la-dllmain.lo -am__objects_25 = $(am__objects_17) $(am__objects_18) $(am__objects_19) \ - $(am__objects_20) $(am__objects_21) $(am__objects_22) \ - $(am__objects_23) $(am__objects_24) -@CURLDEBUG_TRUE@@USE_UNITY_TRUE@am__objects_26 = \ +@DOING_NATIVE_WINDOWS_TRUE@am__objects_21 = libcurlu_la-dllmain.lo +am__objects_22 = $(am__objects_15) $(am__objects_16) $(am__objects_17) \ + $(am__objects_18) $(am__objects_19) $(am__objects_20) \ + $(am__objects_21) +@CURLDEBUG_TRUE@@USE_UNITY_TRUE@am__objects_23 = \ @CURLDEBUG_TRUE@@USE_UNITY_TRUE@ libcurlu_la-memdebug.lo -@DOING_CYGWIN_TRUE@@USE_UNITY_TRUE@am__objects_27 = \ -@DOING_CYGWIN_TRUE@@USE_UNITY_TRUE@ libcurlu_la-dllmain.lo -@USE_UNITY_TRUE@am__objects_28 = libcurlu_la-curl_threads.lo \ +@USE_UNITY_TRUE@am__objects_24 = libcurlu_la-curl_threads.lo \ @USE_UNITY_TRUE@ curlx/libcurlu_la-timediff.lo \ @USE_UNITY_TRUE@ curlx/libcurlu_la-warnless.lo \ -@USE_UNITY_TRUE@ $(am__objects_26) $(am__objects_27) -@USE_UNITY_FALSE@am_libcurlu_la_OBJECTS = $(am__objects_25) \ -@USE_UNITY_FALSE@ $(am__objects_11) -@USE_UNITY_TRUE@am_libcurlu_la_OBJECTS = $(am__objects_28) +@USE_UNITY_TRUE@ $(am__objects_23) +@USE_UNITY_FALSE@am_libcurlu_la_OBJECTS = $(am__objects_22) \ +@USE_UNITY_FALSE@ $(am__objects_10) +@USE_UNITY_TRUE@am_libcurlu_la_OBJECTS = $(am__objects_24) @USE_UNITY_TRUE@nodist_libcurlu_la_OBJECTS = \ @USE_UNITY_TRUE@ libcurlu_la-libcurl_unity.lo libcurlu_la_OBJECTS = $(am_libcurlu_la_OBJECTS) \ @@ -1642,7 +1631,7 @@ LIB_HFILES = \ LIB_RCFILES = libcurl.rc CSOURCES = $(LIB_CFILES) $(LIB_VAUTH_CFILES) $(LIB_VTLS_CFILES) \ $(LIB_VQUIC_CFILES) $(LIB_VSSH_CFILES) $(LIB_CURLX_CFILES) \ - $(am__append_3) $(am__append_4) + $(am__append_3) HHEADERS = $(LIB_HFILES) $(LIB_VAUTH_HFILES) $(LIB_VTLS_HFILES) \ $(LIB_VQUIC_HFILES) $(LIB_VSSH_HFILES) $(LIB_CURLX_HFILES) @@ -1650,20 +1639,19 @@ HHEADERS = $(LIB_HFILES) $(LIB_VAUTH_HFILES) $(LIB_VTLS_HFILES) \ # Keep these separate to avoid duplicate definitions when linking libtests # in static mode. @USE_UNITY_TRUE@curl_EXCLUDE = curl_threads.c curlx/timediff.c \ -@USE_UNITY_TRUE@ curlx/warnless.c $(am__append_5) \ -@USE_UNITY_TRUE@ $(am__append_6) +@USE_UNITY_TRUE@ curlx/warnless.c $(am__append_4) @USE_UNITY_TRUE@nodist_libcurl_la_SOURCES = libcurl_unity.c @USE_UNITY_FALSE@libcurl_la_SOURCES = $(CSOURCES) $(HHEADERS) \ -@USE_UNITY_FALSE@ $(am__append_13) -@USE_UNITY_TRUE@libcurl_la_SOURCES = $(curl_EXCLUDE) $(am__append_13) +@USE_UNITY_FALSE@ $(am__append_11) +@USE_UNITY_TRUE@libcurl_la_SOURCES = $(curl_EXCLUDE) $(am__append_11) @USE_UNITY_TRUE@nodist_libcurlu_la_SOURCES = libcurl_unity.c @USE_UNITY_FALSE@libcurlu_la_SOURCES = $(CSOURCES) $(HHEADERS) @USE_UNITY_TRUE@libcurlu_la_SOURCES = $(curl_EXCLUDE) @USE_UNITY_TRUE@CLEANFILES = libcurl_unity.c -libcurl_la_CPPFLAGS_EXTRA = $(am__append_12) $(am__append_14) -libcurl_la_LDFLAGS_EXTRA = $(am__append_7) $(am__append_8) \ - $(am__append_9) $(am__append_10) $(am__append_11) -libcurl_la_CFLAGS_EXTRA = $(am__append_15) +libcurl_la_CPPFLAGS_EXTRA = $(am__append_10) $(am__append_12) +libcurl_la_LDFLAGS_EXTRA = $(am__append_5) $(am__append_6) \ + $(am__append_7) $(am__append_8) $(am__append_9) +libcurl_la_CFLAGS_EXTRA = $(am__append_13) libcurl_la_CPPFLAGS = $(AM_CPPFLAGS) $(libcurl_la_CPPFLAGS_EXTRA) libcurl_la_LDFLAGS = $(AM_LDFLAGS) $(libcurl_la_LDFLAGS_EXTRA) $(CURL_LDFLAGS_LIB) $(LIBCURL_PC_LIBS_PRIVATE) libcurl_la_CFLAGS = $(AM_CFLAGS) $(libcurl_la_CFLAGS_EXTRA) @@ -1677,7 +1665,7 @@ CS_ = $(CS_0) # disable the tests that are mostly causing false positives TIDYFLAGS := -checks=-clang-analyzer-security.insecureAPI.strcpy,-clang-analyzer-optin.performance.Padding,-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling \ - -quiet $(am__append_16) + -quiet $(am__append_14) TIDY := clang-tidy all: curl_config.h $(MAKE) $(AM_MAKEFLAGS) all-am diff --git a/libs/libcurl/src/altsvc.c b/libs/libcurl/src/altsvc.c index fd568742bb..599fb5a5e5 100644 --- a/libs/libcurl/src/altsvc.c +++ b/libs/libcurl/src/altsvc.c @@ -190,7 +190,7 @@ static CURLcode altsvc_add(struct altsvcinfo *asi, const char *line) char dbuf[MAX_ALTSVC_DATELEN + 1]; time_t expires; - /* The date parser works on a null terminated string. The maximum length + /* The date parser works on a null-terminated string. The maximum length is upheld by curlx_str_quotedword(). */ memcpy(dbuf, curlx_str(&date), curlx_strlen(&date)); dbuf[curlx_strlen(&date)] = 0; diff --git a/libs/libcurl/src/asyn-thrdd.c b/libs/libcurl/src/asyn-thrdd.c index f0495a7d2e..3911ea0e01 100644 --- a/libs/libcurl/src/asyn-thrdd.c +++ b/libs/libcurl/src/asyn-thrdd.c @@ -595,16 +595,15 @@ CURLcode Curl_async_is_resolved(struct Curl_easy *data, if(!result) { struct Curl_https_rrinfo *lhrr; lhrr = Curl_httpsrr_dup_move(&thrdd->rr.hinfo); - if(!lhrr) { - async_thrdd_destroy(data); - return CURLE_OUT_OF_MEMORY; - } - data->state.async.dns->hinfo = lhrr; + if(!lhrr) + result = CURLE_OUT_OF_MEMORY; + else + data->state.async.dns->hinfo = lhrr; } } #endif - if(!result && data->state.async.dns) - result = Curl_dnscache_add(data, data->state.async.dns); + if(!result && data->state.async.dns) + result = Curl_dnscache_add(data, data->state.async.dns); } if(!result && !data->state.async.dns) diff --git a/libs/libcurl/src/cf-https-connect.c b/libs/libcurl/src/cf-https-connect.c index c66bcba2b2..49b3332cac 100644 --- a/libs/libcurl/src/cf-https-connect.c +++ b/libs/libcurl/src/cf-https-connect.c @@ -658,7 +658,7 @@ CURLcode Curl_cf_https_setup(struct Curl_easy *data, if(conn->bits.tls_enable_alpn) { #ifdef USE_HTTPSRR - /* Is there a HTTPSRR use its ALPNs here. + /* Is there an HTTPSRR use its ALPNs here. * We are here after having selected a connection to a host+port and * can no longer change that. Any HTTPSRR advice for other hosts and ports * we need to ignore. */ diff --git a/libs/libcurl/src/cfilters.c b/libs/libcurl/src/cfilters.c index 5dd3271f20..43a5e004eb 100644 --- a/libs/libcurl/src/cfilters.c +++ b/libs/libcurl/src/cfilters.c @@ -497,6 +497,11 @@ out: return result; } +bool Curl_conn_is_setup(struct connectdata *conn, int sockindex) +{ + return (conn->cfilter[sockindex] != NULL); +} + bool Curl_conn_is_connected(struct connectdata *conn, int sockindex) { struct Curl_cfilter *cf; diff --git a/libs/libcurl/src/cfilters.h b/libs/libcurl/src/cfilters.h index e93bca96a8..9da69327aa 100644 --- a/libs/libcurl/src/cfilters.h +++ b/libs/libcurl/src/cfilters.h @@ -370,6 +370,11 @@ bool Curl_conn_cf_needs_flush(struct Curl_cfilter *cf, CURLcode Curl_conn_connect(struct Curl_easy *data, int sockindex, bool blocking, bool *done); +/** + * Check if a filter chain at `sockindex` for connection `conn` exists. + */ +bool Curl_conn_is_setup(struct connectdata *conn, int sockindex); + /** * Check if the filter chain at `sockindex` for connection `conn` is * completely connected. diff --git a/libs/libcurl/src/config-win32.h b/libs/libcurl/src/config-win32.h index 9ec03e3294..03d7ed2f40 100644 --- a/libs/libcurl/src/config-win32.h +++ b/libs/libcurl/src/config-win32.h @@ -159,10 +159,6 @@ /* Define if you have the select function. */ #define HAVE_SELECT 1 -/* Define if libSSH2 is in use */ -#define USE_LIBSSH2 1 -#define HAVE_LIBSSH2_H 1 - #ifndef UNDER_CE /* Define if you have the setlocale function. */ #define HAVE_SETLOCALE 1 @@ -229,9 +225,9 @@ /* Vista */ #if (defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x600) && !defined(UNDER_CE) -/* Define to 1 if you have a IPv6 capable working inet_ntop function. */ +/* Define to 1 if you have an IPv6 capable working inet_ntop function. */ #define HAVE_INET_NTOP 1 -/* Define to 1 if you have a IPv6 capable working inet_pton function. */ +/* Define to 1 if you have an IPv6 capable working inet_pton function. */ #define HAVE_INET_PTON 1 #endif @@ -457,9 +453,6 @@ Vista #define USE_WIN32_LDAP 1 #endif -/* if SSL is enabled */ -#define USE_OPENSSL 1 - /* Define to use the Windows crypto library. */ #ifndef CURL_WINDOWS_UWP #define USE_WIN32_CRYPTO diff --git a/libs/libcurl/src/curl_addrinfo.c b/libs/libcurl/src/curl_addrinfo.c index 98b02d3050..f169932275 100644 --- a/libs/libcurl/src/curl_addrinfo.c +++ b/libs/libcurl/src/curl_addrinfo.c @@ -218,7 +218,7 @@ Curl_getaddrinfo_ex(const char *nodename, * * This function returns a pointer to the first element of a newly allocated * Curl_addrinfo struct linked list filled with the data of a given hostent. - * Curl_addrinfo is meant to work like the addrinfo struct does for a IPv6 + * Curl_addrinfo is meant to work like the addrinfo struct does for an IPv6 * stack, but usable also for IPv4, all hosts and environments. * * The memory allocated by this function *MUST* be free'd later on calling @@ -468,7 +468,7 @@ struct Curl_addrinfo *Curl_unix2addr(const char *path, bool *longpath, sa_un = (void *) ai->ai_addr; sa_un->sun_family = AF_UNIX; - /* sun_path must be able to store the NUL-terminated path */ + /* sun_path must be able to store the null-terminated path */ path_len = strlen(path) + 1; if(path_len > sizeof(sa_un->sun_path)) { free(ai); diff --git a/libs/libcurl/src/curl_config.h.cmake b/libs/libcurl/src/curl_config.h.cmake index 57af226987..bc10b15ee9 100644 --- a/libs/libcurl/src/curl_config.h.cmake +++ b/libs/libcurl/src/curl_config.h.cmake @@ -327,10 +327,10 @@ /* Define to 1 if you have the header file. */ #cmakedefine HAVE_IFADDRS_H 1 -/* Define to 1 if you have a IPv6 capable working inet_ntop function. */ +/* Define to 1 if you have an IPv6 capable working inet_ntop function. */ #cmakedefine HAVE_INET_NTOP 1 -/* Define to 1 if you have a IPv6 capable working inet_pton function. */ +/* Define to 1 if you have an IPv6 capable working inet_pton function. */ #cmakedefine HAVE_INET_PTON 1 /* Define to 1 if symbol `sa_family_t' exists */ diff --git a/libs/libcurl/src/curl_config.h.in b/libs/libcurl/src/curl_config.h.in index e540b6d005..ff6927a35f 100644 --- a/libs/libcurl/src/curl_config.h.in +++ b/libs/libcurl/src/curl_config.h.in @@ -336,10 +336,10 @@ /* Define to 1 if you have the `if_nametoindex' function. */ #undef HAVE_IF_NAMETOINDEX -/* Define to 1 if you have a IPv6 capable working inet_ntop function. */ +/* Define to 1 if you have an IPv6 capable working inet_ntop function. */ #undef HAVE_INET_NTOP -/* Define to 1 if you have a IPv6 capable working inet_pton function. */ +/* Define to 1 if you have an IPv6 capable working inet_pton function. */ #undef HAVE_INET_PTON /* Define to 1 if you have the header file. */ diff --git a/libs/libcurl/src/curl_setup.h b/libs/libcurl/src/curl_setup.h index 7fd1a98f9a..a69b222044 100644 --- a/libs/libcurl/src/curl_setup.h +++ b/libs/libcurl/src/curl_setup.h @@ -105,6 +105,16 @@ # ifndef NOGDI # define NOGDI # endif +/* Detect Windows App environment which has a restricted access + * to the Win32 APIs. */ +# if (defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0602)) || \ + defined(WINAPI_FAMILY) +# include +# if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && \ + !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) +# define CURL_WINDOWS_UWP +# endif +# endif #endif /* Avoid bogus format check warnings with mingw32ce gcc 4.4.0 in diff --git a/libs/libcurl/src/curl_sspi.c b/libs/libcurl/src/curl_sspi.c index ddfa8e8525..3bfd85e00d 100644 --- a/libs/libcurl/src/curl_sspi.c +++ b/libs/libcurl/src/curl_sspi.c @@ -129,7 +129,7 @@ void Curl_sspi_global_cleanup(void) /* * Curl_create_sspi_identity() * - * This is used to populate a SSPI identity structure based on the supplied + * This is used to populate an SSPI identity structure based on the supplied * username and password. * * Parameters: @@ -221,7 +221,7 @@ CURLcode Curl_create_sspi_identity(const char *userp, const char *passwdp, /* * Curl_sspi_free_identity() * - * This is used to free the contents of a SSPI identifier structure. + * This is used to free the contents of an SSPI identifier structure. * * Parameters: * diff --git a/libs/libcurl/src/curl_sspi.h b/libs/libcurl/src/curl_sspi.h index 6d72774862..0a4c2c10e5 100644 --- a/libs/libcurl/src/curl_sspi.h +++ b/libs/libcurl/src/curl_sspi.h @@ -45,7 +45,7 @@ CURLcode Curl_sspi_global_init(void); void Curl_sspi_global_cleanup(void); -/* This is used to populate the domain in a SSPI identity structure */ +/* This is used to populate the domain in an SSPI identity structure */ CURLcode Curl_override_sspi_http_realm(const char *chlg, SEC_WINNT_AUTH_IDENTITY *identity); diff --git a/libs/libcurl/src/curlx/base64.c b/libs/libcurl/src/curlx/base64.c index 5396eba41a..d988cc8e08 100644 --- a/libs/libcurl/src/curlx/base64.c +++ b/libs/libcurl/src/curlx/base64.c @@ -61,9 +61,9 @@ static const unsigned char decodetable[] = /* * curlx_base64_decode() * - * Given a base64 NUL-terminated string at src, decode it and return a - * pointer in *outptr to a newly allocated memory area holding decoded - * data. Size of decoded data is returned in variable pointed by outlen. + * Given a base64 null-terminated string at src, decode it and return a + * pointer in *outptr to a newly allocated memory area holding decoded data. + * Size of decoded data is returned in variable pointed by outlen. * * Returns CURLE_OK on success, otherwise specific error code. Function * output shall not be considered valid unless CURLE_OK is returned. @@ -247,7 +247,7 @@ static CURLcode base64_encode(const char *table64, * encoded data. Size of encoded data is returned in variable pointed by * outlen. * - * Input length of 0 indicates input buffer holds a NUL-terminated string. + * Input length of 0 indicates input buffer holds a null-terminated string. * * Returns CURLE_OK on success, otherwise specific error code. Function * output shall not be considered valid unless CURLE_OK is returned. @@ -269,7 +269,7 @@ CURLcode curlx_base64_encode(const char *inputbuff, size_t insize, * encoded data. Size of encoded data is returned in variable pointed by * outlen. * - * Input length of 0 indicates input buffer holds a NUL-terminated string. + * Input length of 0 indicates input buffer holds a null-terminated string. * * Returns CURLE_OK on success, otherwise specific error code. Function * output shall not be considered valid unless CURLE_OK is returned. diff --git a/libs/libcurl/src/dllmain.c b/libs/libcurl/src/dllmain.c index ad064c8b9d..2507cf8c47 100644 --- a/libs/libcurl/src/dllmain.c +++ b/libs/libcurl/src/dllmain.c @@ -28,22 +28,13 @@ #include #endif -/* The fourth-to-last include */ -#ifdef __CYGWIN__ -#define WIN32_LEAN_AND_MEAN -#include -#ifdef _WIN32 -#undef _WIN32 -#endif -#endif - /* The last 3 #include files should be in this order */ #include "curl_printf.h" #include "curl_memory.h" #include "memdebug.h" -/* DllMain() must only be defined for Windows and Cygwin DLL builds. */ -#if (defined(_WIN32) || defined(__CYGWIN__)) && !defined(CURL_STATICLIB) +/* DllMain() must only be defined for Windows DLL builds. */ +#if defined(_WIN32) && !defined(CURL_STATICLIB) #if defined(USE_OPENSSL) && \ !defined(OPENSSL_IS_AWSLC) && \ diff --git a/libs/libcurl/src/doh.c b/libs/libcurl/src/doh.c index 693d96bc0f..5f9ede520d 100644 --- a/libs/libcurl/src/doh.c +++ b/libs/libcurl/src/doh.c @@ -921,7 +921,7 @@ static void doh_show(struct Curl_easy *data, * This function returns a pointer to the first element of a newly allocated * Curl_addrinfo struct linked list filled with the data from a set of DoH * lookups. Curl_addrinfo is meant to work like the addrinfo struct does for - * a IPv6 stack, but usable also for IPv4, all hosts and environments. + * an IPv6 stack, but usable also for IPv4, all hosts and environments. * * The memory allocated by this function *MUST* be free'd later on calling * Curl_freeaddrinfo(). For each successful call to this function there diff --git a/libs/libcurl/src/dynhds.h b/libs/libcurl/src/dynhds.h index aab4bfc375..3b95934b11 100644 --- a/libs/libcurl/src/dynhds.h +++ b/libs/libcurl/src/dynhds.h @@ -32,7 +32,7 @@ struct dynbuf; /** * A single header entry. - * `name` and `value` are non-NULL and always NUL terminated. + * `name` and `value` are non-NULL and always null-terminated. */ struct dynhds_entry { char *name; @@ -113,7 +113,7 @@ size_t Curl_dynhds_count_name(struct dynhds *dynhds, const char *name, size_t namelen); /** - * Return how often the given 0-terminated name appears in `dynhds`. + * Return how often the given null-terminated name appears in `dynhds`. * Names are case-insensitive. */ size_t Curl_dynhds_ccount_name(struct dynhds *dynhds, const char *name); diff --git a/libs/libcurl/src/ftp.c b/libs/libcurl/src/ftp.c index 2c667a5799..8682e56988 100644 --- a/libs/libcurl/src/ftp.c +++ b/libs/libcurl/src/ftp.c @@ -1146,7 +1146,7 @@ static CURLcode ftp_state_use_port(struct Curl_easy *data, #ifdef USE_IPV6 if(!conn->bits.ftp_use_eprt && conn->bits.ipv6) - /* EPRT is disabled but we are connected to a IPv6 host, so we ignore the + /* EPRT is disabled but we are connected to an IPv6 host, so we ignore the request and enable EPRT again! */ conn->bits.ftp_use_eprt = TRUE; #endif @@ -1278,7 +1278,7 @@ static CURLcode ftp_state_use_pasv(struct Curl_easy *data, #ifdef PF_INET6 if(!conn->bits.ftp_use_epsv && conn->bits.ipv6) - /* EPSV is disabled but we are connected to a IPv6 host, so we ignore the + /* EPSV is disabled but we are connected to an IPv6 host, so we ignore the request and enable EPSV again! */ conn->bits.ftp_use_epsv = TRUE; #endif @@ -1752,8 +1752,7 @@ static CURLcode ftp_epsv_disable(struct Curl_easy *data, infof(data, "Failed EPSV attempt. Disabling EPSV"); /* disable it for next transfer */ conn->bits.ftp_use_epsv = FALSE; - Curl_conn_close(data, SECONDARYSOCKET); - Curl_conn_cf_discard_all(data, conn, SECONDARYSOCKET); + close_secondarysocket(data, ftpc); data->state.errorbuf = FALSE; /* allow error message to get rewritten */ result = Curl_pp_sendf(data, &ftpc->pp, "%s", "PASV"); @@ -2716,8 +2715,8 @@ static CURLcode ftp_pp_statemachine(struct Curl_easy *data, #endif if(data->set.use_ssl && !conn->bits.ftp_use_control_ssl) { - /* We do not have a SSL/TLS control connection yet, but FTPS is - requested. Try a FTPS connection now */ + /* We do not have an SSL/TLS control connection yet, but FTPS is + requested. Try an FTPS connection now */ ftpc->count3 = 0; switch(data->set.ftpsslauth) { @@ -3322,7 +3321,7 @@ static CURLcode ftp_done(struct Curl_easy *data, CURLcode status, shutdown(conn->sock[SECONDARYSOCKET], 2); /* SD_BOTH */ #endif - if(conn->sock[SECONDARYSOCKET] != CURL_SOCKET_BAD) { + if(Curl_conn_is_setup(conn, SECONDARYSOCKET)) { if(!result && ftpc->dont_check && data->req.maxdownload > 0) { /* partial download completed */ result = Curl_pp_sendf(data, pp, "%s", "ABOR"); diff --git a/libs/libcurl/src/headers.c b/libs/libcurl/src/headers.c index 821e9e289c..ca6527062c 100644 --- a/libs/libcurl/src/headers.c +++ b/libs/libcurl/src/headers.c @@ -217,7 +217,7 @@ static CURLcode namevalue(char *header, size_t hlen, unsigned int type, /* skip all trailing space letters */ while((end > header) && ISBLANK(*end)) - *end-- = 0; /* nul terminate */ + *end-- = 0; /* null-terminate */ return CURLE_OK; } @@ -323,7 +323,7 @@ CURLcode Curl_headers_push(struct Curl_easy *data, const char *header, if(!hs) return CURLE_OUT_OF_MEMORY; memcpy(hs->buffer, header, hlen); - hs->buffer[hlen] = 0; /* nul terminate */ + hs->buffer[hlen] = 0; /* null-terminate */ result = namevalue(hs->buffer, hlen, type, &name, &value); if(!result) { diff --git a/libs/libcurl/src/hsts.c b/libs/libcurl/src/hsts.c index 5aea001792..3ee266a50f 100644 --- a/libs/libcurl/src/hsts.c +++ b/libs/libcurl/src/hsts.c @@ -279,7 +279,7 @@ struct stsentry *Curl_hsts(struct hsts *h, const char *hostname, blen = ntail; } } - /* avoid strcasecompare because the host name is not null terminated */ + /* avoid strcasecompare because the host name is not null-terminated */ if((hlen == ntail) && strncasecompare(hostname, sts->host, hlen)) return sts; } @@ -430,7 +430,7 @@ static CURLcode hsts_add(struct hsts *h, const char *line) time_t expires; const char *hp = curlx_str(&host); - /* The date parser works on a null terminated string. The maximum length + /* The date parser works on a null-terminated string. The maximum length is upheld by curlx_str_quotedword(). */ memcpy(dbuf, curlx_str(&date), curlx_strlen(&date)); dbuf[curlx_strlen(&date)] = 0; diff --git a/libs/libcurl/src/http.c b/libs/libcurl/src/http.c index 69147a4699..f3e4121d3a 100644 --- a/libs/libcurl/src/http.c +++ b/libs/libcurl/src/http.c @@ -1176,6 +1176,8 @@ CURLcode Curl_http_follow(struct Curl_easy *data, const char *newurl, bool reachedmax = FALSE; char *follow_url = NULL; CURLUcode uc; + CURLcode rewind_result; + bool switch_to_get = FALSE; DEBUGASSERT(type != FOLLOW_NONE); @@ -1333,7 +1335,7 @@ CURLcode Curl_http_follow(struct Curl_easy *data, const char *newurl, data->state.url = follow_url; data->state.url_alloc = TRUE; - Curl_req_soft_reset(&data->req, data); + rewind_result = Curl_req_soft_reset(&data->req, data); infof(data, "Issue another request to this URL: '%s'", data->state.url); if((data->set.http_follow_mode == CURLFOLLOW_FIRSTONLY) && data->set.str[STRING_CUSTOMREQUEST] && @@ -1382,8 +1384,10 @@ CURLcode Curl_http_follow(struct Curl_easy *data, const char *newurl, 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)) + && !(data->set.keep_post & CURL_REDIR_POST_301)) { http_switch_to_get(data, 301); + switch_to_get = TRUE; + } break; case 302: /* Found */ /* (quote from RFC7231, section 6.4.3) @@ -1405,8 +1409,10 @@ CURLcode Curl_http_follow(struct Curl_easy *data, const char *newurl, 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)) + && !(data->set.keep_post & CURL_REDIR_POST_302)) { http_switch_to_get(data, 302); + switch_to_get = TRUE; + } break; case 303: /* See Other */ @@ -1419,8 +1425,10 @@ CURLcode Curl_http_follow(struct Curl_easy *data, const char *newurl, ((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->set.keep_post & CURL_REDIR_POST_303))) { http_switch_to_get(data, 303); + switch_to_get = TRUE; + } break; case 304: /* Not Modified */ /* 304 means we did a conditional request and it was "Not modified". @@ -1437,6 +1445,12 @@ CURLcode Curl_http_follow(struct Curl_easy *data, const char *newurl, */ break; } + + /* When rewind of upload data failed and we are not switching to GET, + * we need to fail the follow, as we cannot send the data again. */ + if(rewind_result && !switch_to_get) + return rewind_result; + Curl_pgrsTime(data, TIMER_REDIRECT); Curl_pgrsResetTransferSizes(data); @@ -3624,7 +3638,7 @@ static CURLcode http_on_response(struct Curl_easy *data, /* We expect more response from HTTP/2 later */ k->header = TRUE; k->headerline = 0; /* restart the header line counter */ - k->httpversion_sent = 20; /* It's a HTTP/2 request now */ + k->httpversion_sent = 20; /* It's an HTTP/2 request now */ /* Any remaining `buf` bytes are already HTTP/2 and passed to * be processed. */ result = Curl_http2_upgrade(data, conn, FIRSTSOCKET, buf, blen); diff --git a/libs/libcurl/src/http1.c b/libs/libcurl/src/http1.c index 301c402dbc..57e1732c13 100644 --- a/libs/libcurl/src/http1.c +++ b/libs/libcurl/src/http1.c @@ -209,7 +209,7 @@ static CURLcode start_req(struct h1_req_parser *parser, path = target; path_len = target_len; - /* URL parser wants 0-termination */ + /* URL parser wants null-termination */ if(target_len >= sizeof(tmp)) goto out; memcpy(tmp, target, target_len); diff --git a/libs/libcurl/src/http_aws_sigv4.c b/libs/libcurl/src/http_aws_sigv4.c index 754e3777a8..38c2e882b9 100644 --- a/libs/libcurl/src/http_aws_sigv4.c +++ b/libs/libcurl/src/http_aws_sigv4.c @@ -9,7 +9,7 @@ * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms - * are also available at https://curl.haxx.se/docs/copyright.html. + * are also available at https://curl.se/docs/copyright.html. * * You may opt to use, copy, modify, merge, publish, distribute and/or sell * copies of the Software, and permit persons to whom the Software is @@ -133,7 +133,7 @@ static void trim_headers(struct curl_slist *head) else *store++ = *value++; } - *store = 0; /* null terminate */ + *store = 0; /* null-terminate */ } } diff --git a/libs/libcurl/src/http_aws_sigv4.h b/libs/libcurl/src/http_aws_sigv4.h index 79865fe715..f095588ab7 100644 --- a/libs/libcurl/src/http_aws_sigv4.h +++ b/libs/libcurl/src/http_aws_sigv4.h @@ -11,7 +11,7 @@ * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms - * are also available at https://curl.haxx.se/docs/copyright.html. + * are also available at https://curl.se/docs/copyright.html. * * You 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/libs/libcurl/src/http_chunks.h b/libs/libcurl/src/http_chunks.h index 6c05d76cb4..46983a50dd 100644 --- a/libs/libcurl/src/http_chunks.h +++ b/libs/libcurl/src/http_chunks.h @@ -49,7 +49,7 @@ typedef enum { POST_CR state. */ CHUNK_DATA, - /* POSTLF should get a CR and then a LF and nothing else, then move back to + /* POSTLF should get a CR and then an LF and nothing else, then move back to HEX as the CRLF combination marks the end of a chunk. A missing CR is no big deal. */ CHUNK_POSTLF, @@ -64,7 +64,7 @@ typedef enum { CHUNK_TRAILER, /* A trailer CR has been found - next state is CHUNK_TRAILER_POSTCR. - Next char must be a LF */ + Next char must be an LF */ CHUNK_TRAILER_CR, /* A trailer LF must be found now, otherwise CHUNKE_BAD_CHUNK will be diff --git a/libs/libcurl/src/imap.c b/libs/libcurl/src/imap.c index 7a84ed473b..81f0db12a4 100644 --- a/libs/libcurl/src/imap.c +++ b/libs/libcurl/src/imap.c @@ -1032,7 +1032,7 @@ static CURLcode imap_state_capability_resp(struct Curl_easy *data, (void)instate; /* no use for this yet */ - /* Do we have a untagged response? */ + /* Do we have an untagged response? */ if(imapcode == '*') { line += 2; diff --git a/libs/libcurl/src/inet_ntop.c b/libs/libcurl/src/inet_ntop.c index 0c7c178182..60b9e4a6c7 100644 --- a/libs/libcurl/src/inet_ntop.c +++ b/libs/libcurl/src/inet_ntop.c @@ -56,7 +56,7 @@ * Returns `dst' (as a const) * Note: * - uses no statics - * - takes a unsigned char* not an in_addr as input + * - takes an unsigned char* not an in_addr as input */ static char *inet_ntop4(const unsigned char *src, char *dst, size_t size) { diff --git a/libs/libcurl/src/multi.c b/libs/libcurl/src/multi.c index 942331df87..d325e92f38 100644 --- a/libs/libcurl/src/multi.c +++ b/libs/libcurl/src/multi.c @@ -347,7 +347,8 @@ static CURLMcode multi_xfers_add(struct Curl_multi *multi, if(unused <= min_unused) { /* make it a 64 multiple, since our bitsets frow by that and * small (easy_multi) grows to at least 64 on first resize. */ - unsigned int newsize = ((capacity + min_unused) + 63) / 64; + unsigned int newsize = (((capacity + min_unused) + 63) / 64) * 64; + DEBUGASSERT(newsize > capacity); /* Grow the bitsets first. Should one fail, we do not need * to downsize the already resized ones. The sets continue * to work properly when larger than the table, but not @@ -3181,7 +3182,7 @@ static CURLMcode multi_timeout(struct Curl_multi *multi, /* splay the lowest to the bottom */ multi->timetree = Curl_splay(tv_zero, multi->timetree); - /* this will not return NULL from a non-emtpy tree, but some compilers + /* this will not return NULL from a non-empty tree, but some compilers * are not convinced of that. Analyzers are hard. */ *expire_time = multi->timetree ? multi->timetree->key : tv_zero; diff --git a/libs/libcurl/src/multi_ev.c b/libs/libcurl/src/multi_ev.c index 55fe3614d7..dc6556d58f 100644 --- a/libs/libcurl/src/multi_ev.c +++ b/libs/libcurl/src/multi_ev.c @@ -303,7 +303,7 @@ static CURLMcode mev_pollset_diff(struct Curl_multi *multi, CURLMcode mresult; /* The transfer `data` reports in `ps` the sockets it is interested - * in and which combinatino of CURL_POLL_IN/CURL_POLL_OUT it wants + * in and which combination of CURL_POLL_IN/CURL_POLL_OUT it wants * to have monitored for events. * There can be more than 1 transfer interested in the same socket * and 1 transfer might be interested in more than 1 socket. diff --git a/libs/libcurl/src/noproxy.c b/libs/libcurl/src/noproxy.c index 6ab99566f3..f1f40aeaa5 100644 --- a/libs/libcurl/src/noproxy.c +++ b/libs/libcurl/src/noproxy.c @@ -234,7 +234,7 @@ bool Curl_check_noproxy(const char *name, const char *no_proxy) /* if the bits variable gets a crazy value here, that is fine as the value will then be rejected in the cidr function */ bits = (unsigned int)atoi(slash + 1); - *slash = 0; /* null terminate there */ + *slash = 0; /* null-terminate there */ } if(type == TYPE_IPV6) match = Curl_cidr6_match(name, check, bits); diff --git a/libs/libcurl/src/pop3.c b/libs/libcurl/src/pop3.c index ae64e0452b..a61973520b 100644 --- a/libs/libcurl/src/pop3.c +++ b/libs/libcurl/src/pop3.c @@ -874,7 +874,7 @@ static CURLcode pop3_state_capa_resp(struct Curl_easy *data, int pop3code, line = curlx_dyn_ptr(&pop3c->pp.recvbuf); len = pop3c->pp.nfinal; - /* Do we have a untagged continuation response? */ + /* Do we have an untagged continuation response? */ if(pop3code == '*') { /* Does the server support the STLS capability? */ if(len >= 4 && !memcmp(line, "STLS", 4)) diff --git a/libs/libcurl/src/setopt.c b/libs/libcurl/src/setopt.c index 6e0838b326..349ddf6ae3 100644 --- a/libs/libcurl/src/setopt.c +++ b/libs/libcurl/src/setopt.c @@ -2022,7 +2022,7 @@ static CURLcode setopt_cptr(struct Curl_easy *data, CURLoption option, break; case CURLOPT_SSL_CTX_DATA: /* - * Set a SSL_CTX callback parameter pointer + * Set an SSL_CTX callback parameter pointer */ #ifdef USE_SSL if(Curl_ssl_supports(data, SSLSUPP_SSL_CTX)) { @@ -2787,7 +2787,7 @@ static CURLcode setopt_func(struct Curl_easy *data, CURLoption option, break; case CURLOPT_SSL_CTX_FUNCTION: /* - * Set a SSL_CTX callback + * Set an SSL_CTX callback */ #ifdef USE_SSL if(Curl_ssl_supports(data, SSLSUPP_SSL_CTX)) { diff --git a/libs/libcurl/src/smb.c b/libs/libcurl/src/smb.c index 2313eeff96..bf8394eb08 100644 --- a/libs/libcurl/src/smb.c +++ b/libs/libcurl/src/smb.c @@ -723,7 +723,7 @@ static CURLcode smb_send_setup(struct Curl_easy *data) "%s%c" /* OS */ "%s", /* client name */ smbc->user, 0, smbc->domain, 0, CURL_OS, 0, CLIENTNAME); - p++; /* count the final null termination */ + p++; /* count the final null-termination */ DEBUGASSERT(byte_count == (size_t)(p - msg.bytes)); msg.byte_count = smb_swap16((unsigned short)byte_count); @@ -754,7 +754,7 @@ static CURLcode smb_send_tree_connect(struct Curl_easy *data, "%s%c" /* share */ "%s", /* service */ conn->host.name, smbc->share, 0, SERVICENAME); - p++; /* count the final null termination */ + p++; /* count the final null-termination */ DEBUGASSERT(byte_count == (size_t)(p - msg.bytes)); msg.byte_count = smb_swap16((unsigned short)byte_count); diff --git a/libs/libcurl/src/smtp.c b/libs/libcurl/src/smtp.c index b7c9ba8558..0392c98561 100644 --- a/libs/libcurl/src/smtp.c +++ b/libs/libcurl/src/smtp.c @@ -483,7 +483,7 @@ static CURLcode smtp_perform_upgrade_tls(struct Curl_easy *data, result, ssldone)); if(!result && ssldone) { smtpc->ssldone = ssldone; - /* perform EHLO now, changes smpt->state out of SMTP_UPGRADETLS */ + /* perform EHLO now, changes smtp->state out of SMTP_UPGRADETLS */ result = smtp_perform_ehlo(data, smtpc); } out: @@ -601,7 +601,7 @@ static CURLcode smtp_perform_authentication(struct Curl_easy *data, * * smtp_perform_command() * - * Sends a SMTP based command. + * Sends an SMTP based command. */ static CURLcode smtp_perform_command(struct Curl_easy *data, struct smtp_conn *smtpc, @@ -1036,7 +1036,7 @@ static CURLcode smtp_state_ehlo_resp(struct Curl_easy *data, if(smtpcode != 1) { if(data->set.use_ssl && !Curl_conn_is_ssl(data->conn, FIRSTSOCKET)) { - /* We do not have a SSL/TLS connection yet, but SSL is requested */ + /* We do not have an SSL/TLS connection yet, but SSL is requested */ if(smtpc->tls_supported) /* Switch to TLS connection now */ result = smtp_perform_starttls(data, smtpc); diff --git a/libs/libcurl/src/socks.c b/libs/libcurl/src/socks.c index 794f4296ff..cf99ab1f53 100644 --- a/libs/libcurl/src/socks.c +++ b/libs/libcurl/src/socks.c @@ -394,7 +394,7 @@ CONNECT_REQ_INIT: /* * This is currently not supporting "Identification Protocol (RFC1413)". */ - socksreq[8] = 0; /* ensure empty userid is NUL-terminated */ + socksreq[8] = 0; /* ensure empty userid is null-terminated */ if(sx->proxy_user) { size_t plen = strlen(sx->proxy_user); if(plen > 255) { diff --git a/libs/libcurl/src/strcase.c b/libs/libcurl/src/strcase.c index efdaa7911c..f21e76f094 100644 --- a/libs/libcurl/src/strcase.c +++ b/libs/libcurl/src/strcase.c @@ -85,7 +85,7 @@ char Curl_raw_tolower(char in) /* Copy an upper 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. + * null-terminated if that limit is reached. */ void Curl_strntoupper(char *dest, const char *src, size_t n) { @@ -100,7 +100,7 @@ void Curl_strntoupper(char *dest, const char *src, size_t 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. + * null-terminated if that limit is reached. */ void Curl_strntolower(char *dest, const char *src, size_t n) { @@ -112,7 +112,7 @@ void Curl_strntolower(char *dest, const char *src, size_t n) } while(*src++ && --n); } -/* Compare case-sensitive NUL-terminated strings, taking care of possible +/* Compare case-sensitive null-terminated strings, taking care of possible * null pointers. Return true if arguments match. */ bool Curl_safecmp(char *a, char *b) diff --git a/libs/libcurl/src/strdup.c b/libs/libcurl/src/strdup.c index e9f8535c6d..94caa05fb8 100644 --- a/libs/libcurl/src/strdup.c +++ b/libs/libcurl/src/strdup.c @@ -104,7 +104,7 @@ void *Curl_memdup(const void *src, size_t length) * Curl_memdup0(source, length) * * Copies the 'source' string to a newly allocated buffer (that is returned). - * Copies 'length' bytes then adds a null terminator. + * Copies 'length' bytes then adds a null-terminator. * * Returns the new pointer or NULL on failure. * diff --git a/libs/libcurl/src/system_win32.c b/libs/libcurl/src/system_win32.c index 0e96998ad9..836e1b1d57 100644 --- a/libs/libcurl/src/system_win32.c +++ b/libs/libcurl/src/system_win32.c @@ -214,7 +214,7 @@ HMODULE Curl_load_library(LPCTSTR filename) /* Attempt to get the Windows system path */ UINT systemdirlen = GetSystemDirectory(NULL, 0); if(systemdirlen) { - /* Allocate space for the full DLL path (Room for the null terminator + /* Allocate space for the full DLL path (Room for the null-terminator is included in systemdirlen) */ size_t filenamelen = _tcslen(filename); TCHAR *path = malloc(sizeof(TCHAR) * (systemdirlen + 1 + filenamelen)); diff --git a/libs/libcurl/src/transfer.h b/libs/libcurl/src/transfer.h index bc39b0181b..025cb448f8 100644 --- a/libs/libcurl/src/transfer.h +++ b/libs/libcurl/src/transfer.h @@ -59,7 +59,7 @@ bool Curl_xfer_write_is_paused(struct Curl_easy *data); /** * Write a single "header" line from a server response. - * @param hd0 the 0-terminated, single header line + * @param hd0 the null-terminated, single header line * @param hdlen the length of the header line * @param is_eos TRUE iff this is the end of the response */ diff --git a/libs/libcurl/src/uint-table.h b/libs/libcurl/src/uint-table.h index cf265f1113..ab610d9890 100644 --- a/libs/libcurl/src/uint-table.h +++ b/libs/libcurl/src/uint-table.h @@ -34,7 +34,7 @@ struct uint_tbl { void **rows; /* array of void* holding entries */ Curl_uint_tbl_entry_dtor *entry_dtor; unsigned int nrows; /* length of `rows` array */ - unsigned int nentries; /* entris in table */ + unsigned int nentries; /* entries in table */ unsigned int last_key_added; /* UINT_MAX or last key added */ #ifdef DEBUGBUILD int init; diff --git a/libs/libcurl/src/url.c b/libs/libcurl/src/url.c index 0e462be922..8329acef58 100644 --- a/libs/libcurl/src/url.c +++ b/libs/libcurl/src/url.c @@ -1135,7 +1135,7 @@ static bool url_match_destination(struct connectdata *conn, /* We are in an IMAPS vs IMAP like case. We expect `conn` to have SSL */ if(!Curl_conn_is_ssl(conn, FIRSTSOCKET)) { DEBUGF(infof(m->data, - "Connection #%" FMT_OFF_T " has compatible protocol famiy, " + "Connection #%" FMT_OFF_T " has compatible protocol family, " "but no SSL, no match", conn->connection_id)); return FALSE; } diff --git a/libs/libcurl/src/vauth/digest.c b/libs/libcurl/src/vauth/digest.c index d7d6562185..be0f7c099f 100644 --- a/libs/libcurl/src/vauth/digest.c +++ b/libs/libcurl/src/vauth/digest.c @@ -165,7 +165,7 @@ static char *auth_digest_string_quoted(const char *source) { char *dest; const char *s = source; - size_t n = 1; /* null terminator */ + size_t n = 1; /* null-terminator */ /* Calculate size needed */ while(*s) { diff --git a/libs/libcurl/src/vauth/digest_sspi.c b/libs/libcurl/src/vauth/digest_sspi.c index 9bf4c796c6..b950f8f6b8 100644 --- a/libs/libcurl/src/vauth/digest_sspi.c +++ b/libs/libcurl/src/vauth/digest_sspi.c @@ -242,7 +242,7 @@ CURLcode Curl_auth_create_digest_md5_message(struct Curl_easy *data, /* * Curl_override_sspi_http_realm() * - * This is used to populate the domain in a SSPI identity structure + * This is used to populate the domain in an SSPI identity structure * The realm is extracted from the challenge message and used as the * domain if it is not already explicitly set. * diff --git a/libs/libcurl/src/vauth/vauth.c b/libs/libcurl/src/vauth/vauth.c index b98197bbdb..0a3b9acfed 100644 --- a/libs/libcurl/src/vauth/vauth.c +++ b/libs/libcurl/src/vauth/vauth.c @@ -39,7 +39,7 @@ /* * Curl_auth_build_spn() * - * This is used to build a SPN string in the following formats: + * This is used to build an SPN string in the following formats: * * service/host@realm (Not currently used) * service/host (Not used by GSS-API) diff --git a/libs/libcurl/src/vauth/vauth.h b/libs/libcurl/src/vauth/vauth.h index 933bb4e737..0960f4a45a 100644 --- a/libs/libcurl/src/vauth/vauth.h +++ b/libs/libcurl/src/vauth/vauth.h @@ -60,7 +60,7 @@ struct gsasldata; */ bool Curl_auth_allowed_to_host(struct Curl_easy *data); -/* This is used to build a SPN string */ +/* This is used to build an SPN string */ #if !defined(USE_WINDOWS_SSPI) char *Curl_auth_build_spn(const char *service, const char *host, const char *realm); diff --git a/libs/libcurl/src/vquic/curl_osslq.c b/libs/libcurl/src/vquic/curl_osslq.c index 3067ccfbda..3a7f9b185e 100644 --- a/libs/libcurl/src/vquic/curl_osslq.c +++ b/libs/libcurl/src/vquic/curl_osslq.c @@ -2370,7 +2370,7 @@ static CURLcode cf_osslq_query(struct Curl_cfilter *cf, #else *pres1 = 100; #endif - CURL_TRC_CF(data, cf, "query max_conncurrent -> %d", *pres1); + CURL_TRC_CF(data, cf, "query max_concurrent -> %d", *pres1); return CURLE_OK; } case CF_QUERY_CONNECT_REPLY_MS: diff --git a/libs/libcurl/src/vssh/libssh.c b/libs/libcurl/src/vssh/libssh.c index 569aa1a996..8de13c5e26 100644 --- a/libs/libcurl/src/vssh/libssh.c +++ b/libs/libcurl/src/vssh/libssh.c @@ -922,8 +922,8 @@ static int myssh_state_upload_init(struct Curl_easy *data, return rc; } -static int myssh_state_sftp_dowload_stat(struct Curl_easy *data, - struct ssh_conn *sshc) +static int myssh_state_sftp_download_stat(struct Curl_easy *data, + struct ssh_conn *sshc) { curl_off_t size; int rc = 0; @@ -1751,7 +1751,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, break; case SSH_SFTP_DOWNLOAD_STAT: - rc = myssh_state_sftp_dowload_stat(data, sshc); + rc = myssh_state_sftp_download_stat(data, sshc); break; case SSH_SFTP_CLOSE: diff --git a/libs/libcurl/src/vssh/libssh2.c b/libs/libcurl/src/vssh/libssh2.c index 7bf1ed9fb5..f0081ecb0b 100644 --- a/libs/libcurl/src/vssh/libssh2.c +++ b/libs/libcurl/src/vssh/libssh2.c @@ -2007,7 +2007,7 @@ static CURLcode ssh_state_sftp_realpath(struct Curl_easy *data, return CURLE_AGAIN; if(rc > 0) { - /* It seems that this string is not always NULL terminated */ + /* It seems that this string is not always null-terminated */ sshp->readdir_filename[rc] = '\0'; free(sshc->homedir); sshc->homedir = strdup(sshp->readdir_filename); diff --git a/libs/libcurl/src/vtls/gtls.c b/libs/libcurl/src/vtls/gtls.c index 1bd7793111..7f2401afd5 100644 --- a/libs/libcurl/src/vtls/gtls.c +++ b/libs/libcurl/src/vtls/gtls.c @@ -233,7 +233,7 @@ static void unload_file(gnutls_datum_t data) } -/* this function does a SSL/TLS (re-)handshake */ +/* this function does an SSL/TLS (re-)handshake */ static CURLcode handshake(struct Curl_cfilter *cf, struct Curl_easy *data) { diff --git a/libs/libcurl/src/vtls/keylog.c b/libs/libcurl/src/vtls/keylog.c index 77321c9f76..3e6bdff54e 100644 --- a/libs/libcurl/src/vtls/keylog.c +++ b/libs/libcurl/src/vtls/keylog.c @@ -94,7 +94,7 @@ Curl_tls_keylog_write_line(const char *line) linelen = strlen(line); if(linelen == 0 || linelen > sizeof(buf) - 2) { - /* Empty line or too big to fit in a LF and NUL. */ + /* Empty line or too big to fit in an LF and NUL. */ return FALSE; } diff --git a/libs/libcurl/src/vtls/keylog.h b/libs/libcurl/src/vtls/keylog.h index 5b2df7fe8f..88151dea2d 100644 --- a/libs/libcurl/src/vtls/keylog.h +++ b/libs/libcurl/src/vtls/keylog.h @@ -61,7 +61,7 @@ bool Curl_tls_keylog_write(const char *label, const unsigned char *secret, size_t secretlen); /* - * Appends a line to the key log file, ensure it is terminated by a LF. + * Appends a line to the key log file, ensure it is terminated by an 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); diff --git a/libs/libcurl/src/vtls/openssl.c b/libs/libcurl/src/vtls/openssl.c index b5ae754a96..2556b5c57f 100644 --- a/libs/libcurl/src/vtls/openssl.c +++ b/libs/libcurl/src/vtls/openssl.c @@ -698,9 +698,11 @@ static long ossl_bio_cf_ctrl(BIO *bio, int cmd, long num, void *ptr) ret = 1; break; #ifdef BIO_CTRL_EOF - case BIO_CTRL_EOF: + case BIO_CTRL_EOF: { /* EOF has been reached on input? */ - return !cf->next || !cf->next->connected; + struct ssl_connect_data *connssl = cf->ctx; + return connssl->peer_closed; + } #endif default: ret = 0; @@ -4048,7 +4050,7 @@ CURLcode Curl_ossl_ctx_init(struct ossl_ctx *octx, CVE-2010-4180 when using previous OpenSSL versions we no longer enable this option regardless of OpenSSL version and SSL_OP_ALL definition. - OpenSSL added a work-around for a SSL 3.0/TLS 1.0 CBC vulnerability: + OpenSSL added a work-around for an SSL 3.0/TLS 1.0 CBC vulnerability: https://web.archive.org/web/20240114184648/openssl.org/~bodo/tls-cbc.txt. In 0.9.6e they added a bit to SSL_OP_ALL that _disables_ that work-around despite the fact that SSL_OP_ALL is documented to do "rather harmless" diff --git a/libs/libcurl/src/vtls/schannel_verify.c b/libs/libcurl/src/vtls/schannel_verify.c index 69d79182cf..b4d7241790 100644 --- a/libs/libcurl/src/vtls/schannel_verify.c +++ b/libs/libcurl/src/vtls/schannel_verify.c @@ -331,7 +331,7 @@ static CURLcode add_certs_file_to_store(HCERTSTORE trust_store, } } - /* Null terminate the buffer */ + /* null-terminate the buffer */ ca_file_buffer[ca_file_bufsize] = '\0'; result = add_certs_data_to_store(trust_store, diff --git a/libs/libcurl/src/vtls/vtls.c b/libs/libcurl/src/vtls/vtls.c index 37aaea9358..f707e92577 100644 --- a/libs/libcurl/src/vtls/vtls.c +++ b/libs/libcurl/src/vtls/vtls.c @@ -768,8 +768,8 @@ CURLcode Curl_pin_peer_pubkey(struct Curl_easy *data, do { end_pos = strstr(begin_pos, ";sha256//"); /* - * if there is an end_pos, null terminate, - * otherwise it will go to the end of the original string + * if there is an end_pos, null-terminate, otherwise it will go to the + * end of the original string */ if(end_pos) end_pos[0] = '\0'; @@ -845,8 +845,8 @@ CURLcode Curl_pin_peer_pubkey(struct Curl_easy *data, } /* - * Otherwise we will assume it is PEM and try to decode it - * after placing null terminator + * Otherwise we will assume it is PEM and try to decode it after placing + * null-terminator */ pem_read = pubkey_pem_to_der(curlx_dyn_ptr(&buf), &pem_ptr, &pem_len); /* if it was not read successfully, exit */ diff --git a/libs/libcurl/src/vtls/vtls_scache.c b/libs/libcurl/src/vtls/vtls_scache.c index d2d2718e51..3e1825d635 100644 --- a/libs/libcurl/src/vtls/vtls_scache.c +++ b/libs/libcurl/src/vtls/vtls_scache.c @@ -108,7 +108,7 @@ static struct Curl_ssl_scache *cf_ssl_scache_get(struct Curl_easy *data) return scache; } -static void cf_ssl_scache_sesssion_ldestroy(void *udata, void *obj) +static void cf_ssl_scache_session_ldestroy(void *udata, void *obj) { struct Curl_ssl_session *s = obj; (void)udata; @@ -161,7 +161,7 @@ Curl_ssl_session_create2(void *sdata, size_t sdata_len, if(alpn) { s->alpn = strdup(alpn); if(!s->alpn) { - cf_ssl_scache_sesssion_ldestroy(NULL, s); + cf_ssl_scache_session_ldestroy(NULL, s); return CURLE_OUT_OF_MEMORY; } } @@ -176,7 +176,7 @@ void Curl_ssl_session_destroy(struct Curl_ssl_session *s) if(Curl_node_llist(&s->list)) Curl_node_remove(&s->list); else { - cf_ssl_scache_sesssion_ldestroy(NULL, s); + cf_ssl_scache_session_ldestroy(NULL, s); } } } @@ -341,7 +341,7 @@ CURLcode Curl_ssl_scache_create(size_t max_peers, for(i = 0; i < scache->peer_count; ++i) { scache->peers[i].max_sessions = max_sessions_per_peer; Curl_llist_init(&scache->peers[i].sessions, - cf_ssl_scache_sesssion_ldestroy); + cf_ssl_scache_session_ldestroy); } *pscache = scache; @@ -598,9 +598,8 @@ CURLcode Curl_ssl_peer_key_make(struct Curl_cfilter *cf, goto out; *ppeer_key = curlx_dyn_take(&buf, &key_len); - /* we just added printable char, and dynbuf always 0 terminates, - * no need to track length */ - + /* we just added printable char, and dynbuf always null-terminates, no need + * to track length */ out: curlx_dyn_free(&buf); diff --git a/libs/libcurl/src/vtls/vtls_scache.h b/libs/libcurl/src/vtls/vtls_scache.h index 9bce4c36a5..3f2a3978c8 100644 --- a/libs/libcurl/src/vtls/vtls_scache.h +++ b/libs/libcurl/src/vtls/vtls_scache.h @@ -113,7 +113,7 @@ CURLcode Curl_ssl_scache_add_obj(struct Curl_cfilter *cf, void *sobj, Curl_ssl_scache_obj_dtor *sobj_dtor_cb); -/* All about a SSL session ticket */ +/* All about an SSL session ticket */ struct Curl_ssl_session { const void *sdata; /* session ticket data, plain bytes */ size_t sdata_len; /* number of bytes in sdata */ diff --git a/libs/libcurl/src/vtls/wolfssl.c b/libs/libcurl/src/vtls/wolfssl.c index fad04a997f..0971895859 100644 --- a/libs/libcurl/src/vtls/wolfssl.c +++ b/libs/libcurl/src/vtls/wolfssl.c @@ -299,9 +299,11 @@ static long wssl_bio_cf_ctrl(WOLFSSL_BIO *bio, int cmd, long num, void *ptr) ret = 1; break; #ifdef WOLFSSL_BIO_CTRL_EOF - case WOLFSSL_BIO_CTRL_EOF: + case WOLFSSL_BIO_CTRL_EOF: { /* EOF has been reached on input? */ - return !cf->next || !cf->next->connected; + struct ssl_connect_data *connssl = cf->ctx; + return connssl->peer_closed; + } #endif default: ret = 0; @@ -509,7 +511,7 @@ static CURLcode wssl_on_session_reuse(struct Curl_cfilter *cf, *do_early_data = FALSE; #ifdef WOLFSSL_EARLY_DATA connssl->earlydata_max = wolfSSL_SESSION_get_max_early_data( - wolfSSL_get_session(wssl->ssl)); + wolfSSL_get_session(wssl->ssl)); #else (void)wssl; connssl->earlydata_max = 0; @@ -574,11 +576,19 @@ wssl_setup_session(struct Curl_cfilter *cf, if(result) goto out; } +#ifdef WOLFSSL_EARLY_DATA if(do_early_data) { + unsigned int edmax = (scs->earlydata_max < UINT_MAX) ? + (unsigned int)scs->earlydata_max : UINT_MAX; /* We only try the ALPN protocol the session used before, * otherwise we might send early data for the wrong protocol */ Curl_alpn_restrict_to(alpns, scs->alpn); + wolfSSL_set_max_early_data(wss->ssl, edmax); } +#else + /* Should never enable when not supported */ + DEBUGASSERT(!do_early_data); +#endif } } wolfSSL_SESSION_free(session); @@ -931,14 +941,6 @@ wssl_legacy_CTX_set_max_proto_version(WOLFSSL_CTX* ctx, int version) "POLY1305_SHA256:TLS_AES_128_CCM_SHA256" #define QUIC_GROUPS "P-256:P-384:P-521" -#if defined(HAVE_SECRET_CALLBACK) -static void keylog_callback(const WOLFSSL *ssl, const char *line) -{ - (void)ssl; - Curl_tls_keylog_write_line(line); -} -#endif - CURLcode Curl_wssl_ctx_init(struct wssl_ctx *wctx, struct Curl_cfilter *cf, struct Curl_easy *data, diff --git a/libs/libcurl/src/vtls/x509asn1.c b/libs/libcurl/src/vtls/x509asn1.c index d9c970d7d2..1b4821484c 100644 --- a/libs/libcurl/src/vtls/x509asn1.c +++ b/libs/libcurl/src/vtls/x509asn1.c @@ -256,7 +256,7 @@ static const char *getASN1Element(struct Curl_asn1Element *elem, #ifdef WANT_EXTRACT_CERTINFO /* - * Search the null terminated OID or OID identifier in local table. + * 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) diff --git a/libs/libcurl/src/ws.c b/libs/libcurl/src/ws.c index 691710db06..e522c8941b 100644 --- a/libs/libcurl/src/ws.c +++ b/libs/libcurl/src/ws.c @@ -145,35 +145,77 @@ static int ws_frame_firstbyte2flags(struct Curl_easy *data, unsigned char firstbyte, int cont_flags) { switch(firstbyte) { + /* 0x00 - intermediate TEXT/BINARY fragment */ case WSBIT_OPCODE_CONT: - /* continuation of a previous fragment: restore stored flags */ + if(!(cont_flags & CURLWS_CONT)) { + failf(data, "[WS] no ongoing fragmented message to resume"); + return 0; + } return cont_flags | CURLWS_CONT; + /* 0x80 - final TEXT/BIN fragment */ case (WSBIT_OPCODE_CONT | WSBIT_FIN): - /* continuation of a previous fragment: restore stored flags */ + if(!(cont_flags & CURLWS_CONT)) { + failf(data, "[WS] no ongoing fragmented message to resume"); + return 0; + } return cont_flags & ~CURLWS_CONT; + /* 0x01 - first TEXT fragment */ case WSBIT_OPCODE_TEXT: + if(cont_flags & CURLWS_CONT) { + failf(data, "[WS] fragmented message interrupted by new TEXT msg"); + return 0; + } return CURLWS_TEXT | CURLWS_CONT; + /* 0x81 - unfragmented TEXT msg */ case (WSBIT_OPCODE_TEXT | WSBIT_FIN): + if(cont_flags & CURLWS_CONT) { + failf(data, "[WS] fragmented message interrupted by new TEXT msg"); + return 0; + } return CURLWS_TEXT; + /* 0x02 - first BINARY fragment */ case WSBIT_OPCODE_BIN: + if(cont_flags & CURLWS_CONT) { + failf(data, "[WS] fragmented message interrupted by new BINARY msg"); + return 0; + } return CURLWS_BINARY | CURLWS_CONT; + /* 0x82 - unfragmented BINARY msg */ case (WSBIT_OPCODE_BIN | WSBIT_FIN): + if(cont_flags & CURLWS_CONT) { + failf(data, "[WS] fragmented message interrupted by new BINARY msg"); + return 0; + } return CURLWS_BINARY; + /* 0x08 - first CLOSE fragment */ + case WSBIT_OPCODE_CLOSE: + failf(data, "[WS] invalid fragmented CLOSE frame"); + return 0; + /* 0x88 - unfragmented CLOSE */ case (WSBIT_OPCODE_CLOSE | WSBIT_FIN): return CURLWS_CLOSE; + /* 0x09 - first PING fragment */ + case WSBIT_OPCODE_PING: + failf(data, "[WS] invalid fragmented PING frame"); + return 0; + /* 0x89 - unfragmented PING */ case (WSBIT_OPCODE_PING | WSBIT_FIN): return CURLWS_PING; + /* 0x0a - first PONG fragment */ + case WSBIT_OPCODE_PONG: + failf(data, "[WS] invalid fragmented PONG frame"); + return 0; + /* 0x8a - unfragmented PONG */ case (WSBIT_OPCODE_PONG | WSBIT_FIN): return CURLWS_PONG; + /* invalid first byte */ default: - if(firstbyte & WSBIT_RSV_MASK) { - failf(data, "WS: unknown reserved bit: %x", - firstbyte & WSBIT_RSV_MASK); - } - else { - failf(data, "WS: unknown opcode: %x", - firstbyte & WSBIT_OPCODE_MASK); - } + if(firstbyte & WSBIT_RSV_MASK) + /* any of the reserved bits 0x40/0x20/0x10 are set */ + failf(data, "[WS] invalid reserved bits: %02x", firstbyte); + else + /* any of the reserved opcodes 0x3-0x7 or 0xb-0xf is used */ + failf(data, "[WS] invalid opcode: %02x", firstbyte); return 0; } } @@ -186,20 +228,20 @@ static unsigned char ws_frame_flags2firstbyte(struct Curl_easy *data, switch(flags & ~CURLWS_OFFSET) { case 0: if(contfragment) { - infof(data, "WS: no flags given; interpreting as continuation " + infof(data, "[WS] no flags given; interpreting as continuation " "fragment for compatibility"); return (WSBIT_OPCODE_CONT | WSBIT_FIN); } - failf(data, "WS: no flags given"); + failf(data, "[WS] no flags given"); *err = CURLE_BAD_FUNCTION_ARGUMENT; return 0xff; case CURLWS_CONT: if(contfragment) { - infof(data, "WS: setting CURLWS_CONT flag without message type is " + infof(data, "[WS] setting CURLWS_CONT flag without message type is " "supported for compatibility but highly discouraged"); return WSBIT_OPCODE_CONT; } - failf(data, "WS: No ongoing fragmented message to continue"); + failf(data, "[WS] No ongoing fragmented message to continue"); *err = CURLE_BAD_FUNCTION_ARGUMENT; return 0xff; case CURLWS_TEXT: @@ -215,24 +257,24 @@ static unsigned char ws_frame_flags2firstbyte(struct Curl_easy *data, case CURLWS_CLOSE: return WSBIT_OPCODE_CLOSE | WSBIT_FIN; case (CURLWS_CLOSE | CURLWS_CONT): - failf(data, "WS: CLOSE frame must not be fragmented"); + failf(data, "[WS] CLOSE frame must not be fragmented"); *err = CURLE_BAD_FUNCTION_ARGUMENT; return 0xff; case CURLWS_PING: return WSBIT_OPCODE_PING | WSBIT_FIN; case (CURLWS_PING | CURLWS_CONT): - failf(data, "WS: PING frame must not be fragmented"); + failf(data, "[WS] PING frame must not be fragmented"); *err = CURLE_BAD_FUNCTION_ARGUMENT; return 0xff; case CURLWS_PONG: return WSBIT_OPCODE_PONG | WSBIT_FIN; case (CURLWS_PONG | CURLWS_CONT): - failf(data, "WS: PONG frame must not be fragmented"); + failf(data, "[WS] PONG frame must not be fragmented"); *err = CURLE_BAD_FUNCTION_ARGUMENT; return 0xff; default: - failf(data, "WS: unknown flags: %x", flags); - *err = CURLE_SEND_ERROR; + failf(data, "[WS] unknown flags: %x", flags); + *err = CURLE_BAD_FUNCTION_ARGUMENT; return 0xff; } } @@ -244,23 +286,23 @@ static void ws_dec_info(struct ws_decoder *dec, struct Curl_easy *data, case 0: break; case 1: - CURL_TRC_WRITE(data, "websocket, decoded %s [%s%s]", msg, - ws_frame_name_of_op(dec->head[0]), - (dec->head[0] & WSBIT_FIN) ? "" : " NON-FINAL"); + CURL_TRC_WS(data, "decoded %s [%s%s]", msg, + ws_frame_name_of_op(dec->head[0]), + (dec->head[0] & WSBIT_FIN) ? "" : " NON-FINAL"); break; default: if(dec->head_len < dec->head_total) { - CURL_TRC_WRITE(data, "websocket, decoded %s [%s%s](%d/%d)", msg, - ws_frame_name_of_op(dec->head[0]), - (dec->head[0] & WSBIT_FIN) ? "" : " NON-FINAL", - dec->head_len, dec->head_total); + CURL_TRC_WS(data, "decoded %s [%s%s](%d/%d)", msg, + ws_frame_name_of_op(dec->head[0]), + (dec->head[0] & WSBIT_FIN) ? "" : " NON-FINAL", + dec->head_len, dec->head_total); } else { - CURL_TRC_WRITE(data, "websocket, decoded %s [%s%s payload=%" - FMT_OFF_T "/%" FMT_OFF_T "]", - msg, ws_frame_name_of_op(dec->head[0]), - (dec->head[0] & WSBIT_FIN) ? "" : " NON-FINAL", - dec->payload_offset, dec->payload_len); + CURL_TRC_WS(data, "decoded %s [%s%s payload=%" + FMT_OFF_T "/%" FMT_OFF_T "]", + msg, ws_frame_name_of_op(dec->head[0]), + (dec->head[0] & WSBIT_FIN) ? "" : " NON-FINAL", + dec->payload_offset, dec->payload_len); } break; } @@ -318,17 +360,15 @@ static CURLcode ws_dec_read_head(struct ws_decoder *dec, dec->frame_flags = ws_frame_firstbyte2flags(data, dec->head[0], dec->cont_flags); if(!dec->frame_flags) { - failf(data, "WS: invalid first byte: %x", dec->head[0]); ws_dec_reset(dec); return CURLE_RECV_ERROR; } - if(dec->frame_flags & CURLWS_CONT) { + /* fragmentation only applies to data frames (text/binary); + * control frames (close/ping/pong) do not affect the CONT status */ + if(dec->frame_flags & (CURLWS_TEXT | CURLWS_BINARY)) { dec->cont_flags = dec->frame_flags; } - else { - dec->cont_flags = 0; - } dec->head_len = 1; /* ws_dec_info(dec, data, "seeing opcode"); */ @@ -341,10 +381,30 @@ static CURLcode ws_dec_read_head(struct ws_decoder *dec, if(dec->head[1] & WSBIT_MASK) { /* A client MUST close a connection if it detects a masked frame. */ - failf(data, "WS: masked input frame"); + failf(data, "[WS] masked input frame"); ws_dec_reset(dec); return CURLE_RECV_ERROR; } + if(dec->frame_flags & CURLWS_PING && dec->head[1] > 125) { + /* The maximum valid size of PING frames is 125 bytes. + Accepting overlong pings would mean sending equivalent pongs! */ + failf(data, "[WS] received PING frame is too big"); + ws_dec_reset(dec); + return CURLE_RECV_ERROR; + } + if(dec->frame_flags & CURLWS_PONG && dec->head[1] > 125) { + /* The maximum valid size of PONG frames is 125 bytes. */ + failf(data, "[WS] received PONG frame is too big"); + ws_dec_reset(dec); + return CURLE_RECV_ERROR; + } + if(dec->frame_flags & CURLWS_CLOSE && dec->head[1] > 125) { + /* The maximum valid size of CLOSE frames is 125 bytes. */ + failf(data, "[WS] received CLOSE frame is too big"); + ws_dec_reset(dec); + return CURLE_RECV_ERROR; + } + /* How long is the frame head? */ if(dec->head[1] == 126) { dec->head_total = 4; @@ -379,7 +439,7 @@ static CURLcode ws_dec_read_head(struct ws_decoder *dec, break; case 10: if(dec->head[2] > 127) { - failf(data, "WS: frame length longer than 64 signed not supported"); + failf(data, "[WS] frame length longer than 64 signed not supported"); return CURLE_RECV_ERROR; } dec->payload_len = ((curl_off_t)dec->head[2] << 56) | @@ -394,7 +454,7 @@ static CURLcode ws_dec_read_head(struct ws_decoder *dec, default: /* this should never happen */ DEBUGASSERT(0); - failf(data, "WS: unexpected frame header length"); + failf(data, "[WS] unexpected frame header length"); return CURLE_RECV_ERROR; } @@ -430,8 +490,8 @@ static CURLcode ws_dec_pass_payload(struct ws_decoder *dec, Curl_bufq_skip(inraw, (size_t)nwritten); dec->payload_offset += (curl_off_t)nwritten; remain = dec->payload_len - dec->payload_offset; - CURL_TRC_WRITE(data, "websocket, passed %zd bytes payload, %" - FMT_OFF_T " remain", nwritten, remain); + CURL_TRC_WS(data, "passed %zd bytes payload, %" + FMT_OFF_T " remain", nwritten, remain); } return remain ? CURLE_AGAIN : CURLE_OK; @@ -457,7 +517,7 @@ static CURLcode ws_dec_pass(struct ws_decoder *dec, result = ws_dec_read_head(dec, data, inraw); if(result) { if(result != CURLE_AGAIN) { - infof(data, "WS: decode error %d", (int)result); + infof(data, "[WS] decode error %d", (int)result); break; /* real error */ } /* incomplete ws frame head */ @@ -555,7 +615,7 @@ static ssize_t ws_cw_dec_next(const unsigned char *buf, size_t buflen, if(auto_pong && (frame_flags & CURLWS_PING) && !remain) { /* auto-respond to PINGs, only works for single-frame payloads atm */ size_t bytes; - infof(data, "WS: auto-respond to PING with a PONG"); + infof(data, "[WS] auto-respond to PING with a PONG"); /* send back the exact same content as a PONG */ *err = curl_ws_send(data, buf, buflen, &bytes, 0, CURLWS_PONG); if(*err) @@ -588,7 +648,7 @@ static CURLcode ws_cw_write(struct Curl_easy *data, ws = Curl_conn_meta_get(data->conn, CURL_META_PROTO_WS_CONN); if(!ws) { - failf(data, "WS: not a websocket transfer"); + failf(data, "[WS] not a websocket transfer"); return CURLE_FAILED_INIT; } @@ -597,7 +657,7 @@ static CURLcode ws_cw_write(struct Curl_easy *data, nwritten = Curl_bufq_write(&ctx->buf, (const unsigned char *)buf, nbytes, &result); if(nwritten < 0) { - infof(data, "WS: error adding data to buffer %d", result); + infof(data, "[WS] error adding data to buffer %d", result); return result; } } @@ -613,17 +673,17 @@ static CURLcode ws_cw_write(struct Curl_easy *data, if(result == CURLE_AGAIN) { /* insufficient amount of data, keep it for later. * we pretend to have written all since we have a copy */ - CURL_TRC_WRITE(data, "websocket, buffered incomplete frame head"); + CURL_TRC_WS(data, "buffered incomplete frame head"); return CURLE_OK; } else if(result) { - infof(data, "WS: decode error %d", (int)result); + infof(data, "[WS] decode error %d", (int)result); return result; } } if((type & CLIENTWRITE_EOS) && !Curl_bufq_is_empty(&ctx->buf)) { - infof(data, "WS: decode ending with %zd frame bytes remaining", + failf(data, "[WS] decode ending with %zd frame bytes remaining", Curl_bufq_len(&ctx->buf)); return CURLE_RECV_ERROR; } @@ -645,10 +705,11 @@ static const struct Curl_cwtype ws_cw_decode = { static void ws_enc_info(struct ws_encoder *enc, struct Curl_easy *data, const char *msg) { - infof(data, "WS-ENC: %s [%s%s payload=%" FMT_OFF_T "/%" FMT_OFF_T "]", - msg, ws_frame_name_of_op(enc->firstbyte), - (enc->firstbyte & WSBIT_FIN) ? "" : " NON-FIN", - enc->payload_len - enc->payload_remain, enc->payload_len); + CURL_TRC_WS(data, "WS-ENC: %s [%s%s payload=%" + FMT_OFF_T "/%" FMT_OFF_T "]", + msg, ws_frame_name_of_op(enc->firstbyte), + (enc->firstbyte & WSBIT_FIN) ? "" : " NON-FIN", + enc->payload_len - enc->payload_remain, enc->payload_len); } static void ws_enc_reset(struct ws_encoder *enc) @@ -699,7 +760,7 @@ static ssize_t ws_enc_write_head(struct Curl_easy *data, ssize_t n; if(payload_len < 0) { - failf(data, "WS: starting new frame with negative payload length %" + failf(data, "[WS] starting new frame with negative payload length %" FMT_OFF_T, payload_len); *err = CURLE_SEND_ERROR; return -1; @@ -707,7 +768,7 @@ static ssize_t ws_enc_write_head(struct Curl_easy *data, if(enc->payload_remain > 0) { /* trying to write a new frame before the previous one is finished */ - failf(data, "WS: starting new frame with %zd bytes from last one " + failf(data, "[WS] starting new frame with %zd bytes from last one " "remaining to be sent", (ssize_t)enc->payload_remain); *err = CURLE_SEND_ERROR; return -1; @@ -715,7 +776,6 @@ static ssize_t ws_enc_write_head(struct Curl_easy *data, firstbyte = ws_frame_flags2firstbyte(data, flags, enc->contfragment, err); if(*err) { - failf(data, "WS: provided flags not valid: %x", flags); return -1; } @@ -725,6 +785,25 @@ static ssize_t ws_enc_write_head(struct Curl_easy *data, enc->contfragment = (flags & CURLWS_CONT) ? (bit)TRUE : (bit)FALSE; } + if(flags & CURLWS_PING && payload_len > 125) { + /* The maximum valid size of PING frames is 125 bytes. */ + failf(data, "[WS] given PING frame is too big"); + *err = CURLE_TOO_LARGE; + return -1; + } + if(flags & CURLWS_PONG && payload_len > 125) { + /* The maximum valid size of PONG frames is 125 bytes. */ + failf(data, "[WS] given PONG frame is too big"); + *err = CURLE_TOO_LARGE; + return -1; + } + if(flags & CURLWS_CLOSE && payload_len > 125) { + /* The maximum valid size of CLOSE frames is 125 bytes. */ + failf(data, "[WS] given CLOSE frame is too big"); + *err = CURLE_TOO_LARGE; + return -1; + } + head[0] = enc->firstbyte = firstbyte; if(payload_len > 65535) { head[1] = 127 | WSBIT_MASK; @@ -952,7 +1031,14 @@ CURLcode Curl_ws_accept(struct Curl_easy *data, sizeof(ws->enc.mask)); if(result) return result; - infof(data, "Received 101, switch to WebSocket; mask %02x%02x%02x%02x", + +#ifdef DEBUGBUILD + if(getenv("CURL_WS_FORCE_ZERO_MASK")) + /* force the bit mask to 0x00000000, effectively disabling masking */ + memset(ws->enc.mask, 0, sizeof(ws->enc.mask)); +#endif + + infof(data, "[WS] Received 101, switch to WebSocket; mask %02x%02x%02x%02x", ws->enc.mask[0], ws->enc.mask[1], ws->enc.mask[2], ws->enc.mask[3]); /* Install our client writer that decodes WS frames payload */ @@ -976,7 +1062,7 @@ CURLcode Curl_ws_accept(struct Curl_easy *data, nread, &result); if(nwritten < 0) return result; - infof(data, "%zu bytes websocket payload", nread); + CURL_TRC_WS(data, "%zu bytes payload", nread); } else { /* !connect_only */ /* And pass any additional data to the writers */ @@ -1025,7 +1111,7 @@ static ssize_t ws_client_collect(const unsigned char *buf, size_t buflen, if(auto_pong && (frame_flags & CURLWS_PING) && !remain) { /* auto-respond to PINGs, only works for single-frame payloads atm */ size_t bytes; - infof(ctx->data, "WS: auto-respond to PING with a PONG"); + infof(ctx->data, "[WS] auto-respond to PING with a PONG"); /* send back the exact same content as a PONG */ *err = curl_ws_send(ctx->data, buf, buflen, &bytes, 0, CURLWS_PONG); if(*err) @@ -1079,19 +1165,19 @@ CURL_EXTERN CURLcode curl_ws_recv(CURL *d, void *buffer, if(!conn) { /* Unhappy hack with lifetimes of transfers and connection */ if(!data->set.connect_only) { - failf(data, "CONNECT_ONLY is required"); + failf(data, "[WS] CONNECT_ONLY is required"); return CURLE_UNSUPPORTED_PROTOCOL; } Curl_getconnectinfo(data, &conn); if(!conn) { - failf(data, "connection not found"); + failf(data, "[WS] connection not found"); return CURLE_BAD_FUNCTION_ARGUMENT; } } ws = Curl_conn_meta_get(conn, CURL_META_PROTO_WS_CONN); if(!ws) { - failf(data, "connection is not setup for websocket"); + failf(data, "[WS] connection is not setup for websocket"); return CURLE_BAD_FUNCTION_ARGUMENT; } @@ -1112,7 +1198,7 @@ CURL_EXTERN CURLcode curl_ws_recv(CURL *d, void *buffer, } else if(n == 0) { /* connection closed */ - infof(data, "connection expectedly closed?"); + infof(data, "[WS] connection expectedly closed?"); return CURLE_GOT_NOTHING; } CURL_TRC_WS(data, "curl_ws_recv, added %zu bytes from network", @@ -1196,11 +1282,11 @@ static CURLcode ws_flush(struct Curl_easy *data, struct websocket *ws, return result; } else if(result) { - failf(data, "WS: flush, write error %d", result); + failf(data, "[WS] flush, write error %d", result); return result; } else { - infof(data, "WS: flushed %zu bytes", n); + CURL_TRC_WS(data, "flushed %zu bytes", n); Curl_bufq_skip(&ws->sendbuf, n); } } @@ -1232,7 +1318,7 @@ static CURLcode ws_send_raw_blocking(CURL *d, struct websocket *ws, buflen); left_ms = Curl_timeleft(data, NULL, FALSE); if(left_ms < 0) { - failf(data, "Timeout waiting for socket becoming writable"); + failf(data, "[WS] Timeout waiting for socket becoming writable"); return CURLE_SEND_ERROR; } @@ -1242,7 +1328,7 @@ static CURLcode ws_send_raw_blocking(CURL *d, struct websocket *ws, ev = Curl_socket_check(CURL_SOCKET_BAD, CURL_SOCKET_BAD, sock, left_ms ? left_ms : 500); if(ev < 0) { - failf(data, "Error while waiting for socket becoming writable"); + failf(data, "[WS] Error while waiting for socket becoming writable"); return CURLE_SEND_ERROR; } } @@ -1258,7 +1344,7 @@ static CURLcode ws_send_raw(struct Curl_easy *data, const void *buffer, ws = Curl_conn_meta_get(data->conn, CURL_META_PROTO_WS_CONN); if(!ws) { - failf(data, "Not a websocket transfer"); + failf(data, "[WS] Not a websocket transfer"); return CURLE_SEND_ERROR; } if(!buflen) @@ -1308,13 +1394,13 @@ CURL_EXTERN CURLcode curl_ws_send(CURL *d, const void *buffer_arg, goto out; } if(!data->conn) { - failf(data, "No associated connection"); + failf(data, "[WS] No associated connection"); result = CURLE_SEND_ERROR; goto out; } ws = Curl_conn_meta_get(data->conn, CURL_META_PROTO_WS_CONN); if(!ws) { - failf(data, "Not a websocket transfer"); + failf(data, "[WS] Not a websocket transfer"); result = CURLE_SEND_ERROR; goto out; } @@ -1327,7 +1413,7 @@ CURL_EXTERN CURLcode curl_ws_send(CURL *d, const void *buffer_arg, goto out; if(fragsize || flags) { - failf(data, "ws_send, raw mode: fragsize and flags cannot be non-zero"); + failf(data, "[WS] fragsize and flags must be zero in raw mode"); return CURLE_BAD_FUNCTION_ARGUMENT; } result = ws_send_raw(data, buffer, buflen, sent); @@ -1342,7 +1428,7 @@ CURL_EXTERN CURLcode curl_ws_send(CURL *d, const void *buffer_arg, if(buflen < ws->sendbuf_payload) { /* We have been called with LESS buffer data than before. This * is not how it's supposed too work. */ - failf(data, "curl_ws_send() called with smaller 'buflen' than " + failf(data, "[WS] curl_ws_send() called with smaller 'buflen' than " "bytes already buffered in previous call, %zu vs %zu", buflen, ws->sendbuf_payload); result = CURLE_BAD_FUNCTION_ARGUMENT; @@ -1351,7 +1437,7 @@ CURL_EXTERN CURLcode curl_ws_send(CURL *d, const void *buffer_arg, if((curl_off_t)buflen > (ws->enc.payload_remain + (curl_off_t)ws->sendbuf_payload)) { /* too large buflen beyond payload length of frame */ - infof(data, "WS: unaligned frame size (sending %zu instead of %" + failf(data, "[WS] unaligned frame size (sending %zu instead of %" FMT_OFF_T ")", buflen, ws->enc.payload_remain + ws->sendbuf_payload); result = CURLE_BAD_FUNCTION_ARGUMENT; @@ -1384,11 +1470,15 @@ CURL_EXTERN CURLcode curl_ws_send(CURL *d, const void *buffer_arg, if(n < 0 && (result != CURLE_AGAIN)) goto out; ws->sendbuf_payload += Curl_bufq_len(&ws->sendbuf) - prev_len; + if(!ws->sendbuf_payload) { + result = CURLE_AGAIN; + goto out; + } } /* flush, blocking when in callback */ result = ws_flush(data, ws, Curl_is_in_callback(data)); - if(!result) { + if(!result && ws->sendbuf_payload > 0) { *sent += ws->sendbuf_payload; buffer += ws->sendbuf_payload; buflen -= ws->sendbuf_payload; -- cgit v1.2.3