From 27a7cf40bb7e8771c356fb3b16714f77f1d126d8 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 21 Nov 2025 02:14:59 +0000 Subject: [PATCH 001/415] GHA: update dependency wolfSSL/wolfssl to v5.8.4 Closes #19633 --- .github/workflows/http3-linux.yml | 2 +- .github/workflows/linux.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/http3-linux.yml b/.github/workflows/http3-linux.yml index ff32e6c5d9d9..223c6afbf46d 100644 --- a/.github/workflows/http3-linux.yml +++ b/.github/workflows/http3-linux.yml @@ -49,7 +49,7 @@ env: # renovate: datasource=github-tags depName=gnutls/gnutls versioning=semver registryUrl=https://github.com GNUTLS_VERSION: 3.8.10 # renovate: datasource=github-tags depName=wolfSSL/wolfssl versioning=semver extractVersion=^v?(?.+)-stable$ registryUrl=https://github.com - WOLFSSL_VERSION: 5.8.2 + WOLFSSL_VERSION: 5.8.4 # renovate: datasource=github-tags depName=ngtcp2/nghttp3 versioning=semver registryUrl=https://github.com NGHTTP3_VERSION: 1.12.0 # renovate: datasource=github-tags depName=ngtcp2/ngtcp2 versioning=semver registryUrl=https://github.com diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index a6823b4c9da4..0db8ca33b4ec 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -40,7 +40,7 @@ env: # renovate: datasource=github-tags depName=libressl/portable versioning=semver registryUrl=https://github.com LIBRESSL_VERSION: 4.2.1 # renovate: datasource=github-tags depName=wolfSSL/wolfssl versioning=semver extractVersion=^v?(?.+)-stable$ registryUrl=https://github.com - WOLFSSL_VERSION: 5.8.2 + WOLFSSL_VERSION: 5.8.4 # renovate: datasource=github-tags depName=Mbed-TLS/mbedtls versioning=semver registryUrl=https://github.com MBEDTLS_VERSION: 4.0.0 # renovate: datasource=github-tags depName=Mbed-TLS/mbedtls versioning=semver:^3.0.0 registryUrl=https://github.com From fdacf34aaeac79ad14fa48dcafae24a6de68823d Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Fri, 21 Nov 2025 02:44:08 +0100 Subject: [PATCH 002/415] GHA/codeql: add tweak to successfully build libtests for CodeQL Turns out the cause of CodeQL hangs (or probably just extreme long compile) is the header `curl/typecheck-gcc.h`. By accident I noticed that the preprocessed output of libtests.c is 75 MB (megabytes). This is much higher than the amounf of source code hinted, also compared to e.g. units.c or other build targets. The reason for the extreme size is each easy option call pulling in the large checker logic defined in this header. By compiling with `-DCURL_DISABLE_TYPECHECK`, preprocessed output drops to 2.2 MB (34x), and the libtests target builds without issues. Also build all tests and examples with the Linux HTTP/3 config, covering 3 more files. With these, CodeQL C coverage is 893 out of 930 (96%) (was: 645 69%) Follow-up to 71fc11e6bbf530b90bf6e93a02cb32bdaecc933b #18695 Follow-up to a333fd4411b95fc0c3061b2d675de9287b6123e0 #18557 Follow-up to b4922b1295333dc6679eb1d588ddc2fb6b7fd5b7 #18564 Closes https://github.com/vszakats/curl/pull/11 Closes #19632 --- .github/workflows/codeql.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index c7b6383cf1dc..c42d71773567 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -109,24 +109,24 @@ jobs: # MultiSSL export PKG_CONFIG_PATH; PKG_CONFIG_PATH="$(brew --prefix c-ares)/lib/pkgconfig:$(brew --prefix mbedtls)/lib/pkgconfig:$(brew --prefix rustls-ffi)/lib/pkgconfig:$(brew --prefix gsasl)/lib/pkgconfig" cmake -B _bld1 -G Ninja -DENABLE_DEBUG=ON \ + -DCMAKE_C_FLAGS=-DCURL_DISABLE_TYPECHECK \ -DCURL_USE_GNUTLS=ON -DCURL_USE_MBEDTLS=ON -DCURL_USE_RUSTLS=ON -DCURL_USE_WOLFSSL=ON \ -DUSE_LIBRTMP=ON -DCURL_USE_GSASL=ON -DCURL_USE_GSSAPI=ON -DUSE_SSLS_EXPORT=ON -DUSE_ECH=ON -DENABLE_ARES=ON \ -DCURL_DISABLE_VERBOSE_STRINGS=ON cmake --build _bld1 - cmake --build _bld1 --target curlinfo - cmake --build _bld1 --target servers - cmake --build _bld1 --target tunits - cmake --build _bld1 --target units + cmake --build _bld1 --target testdeps cmake --build _bld1 --target curl-examples-build # HTTP/3 export PKG_CONFIG_PATH; PKG_CONFIG_PATH="$(brew --prefix libnghttp3)/lib/pkgconfig:$(brew --prefix libngtcp2)/lib/pkgconfig:$(brew --prefix gsasl)/lib/pkgconfig" cmake -B _bld2 -G Ninja \ + -DCMAKE_C_FLAGS=-DCURL_DISABLE_TYPECHECK \ -DCURL_USE_OPENSSL=ON -DOPENSSL_ROOT_DIR="$(brew --prefix openssl)" -DUSE_NGTCP2=ON \ -DCURL_USE_LIBSSH2=OFF -DCURL_USE_LIBSSH=ON \ -DUSE_LIBRTMP=ON -DCURL_USE_GSASL=ON -DCURL_USE_GSSAPI=ON -DUSE_SSLS_EXPORT=ON cmake --build _bld2 - cmake --build _bld2 --target servers + cmake --build _bld2 --target testdeps + cmake --build _bld2 --target curl-examples-build _bld1/src/curl --disable --version _bld2/src/curl --disable --version From b4220bde0ba79486c63e60de71037df912134dfb Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Fri, 21 Nov 2025 03:52:04 +0100 Subject: [PATCH 003/415] GHA/checksrc: switch xmllint job to Linux (from macOS) macOS was chosen because xmllint comes preinstalled, saving the prereq install step. But, macOS's xmllint jobs sometimes doesn't finish in 1m (instead of under 1 second) and gets cancelled, causing flaky failures. Go with Linux and an install phase (of 15s) instead. Examples: https://github.com/curl/curl/actions/runs/19558021722/job/56004334495 Closes #19634 --- .github/workflows/checksrc.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/checksrc.yml b/.github/workflows/checksrc.yml index 32f825214d6c..2f7b0b0e941c 100644 --- a/.github/workflows/checksrc.yml +++ b/.github/workflows/checksrc.yml @@ -120,9 +120,17 @@ jobs: xmllint: name: 'xmllint' - runs-on: macos-latest + runs-on: ubuntu-latest timeout-minutes: 1 steps: + - name: 'install prereqs' + run: | + sudo rm -f /etc/apt/sources.list.d/microsoft-prod.list + sudo apt-get -o Dpkg::Use-Pty=0 update + sudo rm -f /var/lib/man-db/auto-update + sudo apt-get -o Dpkg::Use-Pty=0 install \ + libxml2-utils + - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 with: persist-credentials: false From fd23d9505c7263814bfb2963e9c406a53b0295a2 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Thu, 20 Nov 2025 17:39:53 +0100 Subject: [PATCH 004/415] src: move `memdebug.h` to be the last include `memdebug.h` must be included last within each source. This breaks when including it in a header, which ends up being included in the middle of other headers, and `memdebug.h` also ending up in the middle of includes. Follow-up to c255d2fdcbf27b4bfd668ae3784bb657449d6889 #19602 Closes #19629 --- src/tool_cfgable.h | 1 - src/tool_ssls.c | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/tool_cfgable.h b/src/tool_cfgable.h index 717d35a1f522..dc78f2db44f6 100644 --- a/src/tool_cfgable.h +++ b/src/tool_cfgable.h @@ -29,7 +29,6 @@ #include "tool_sdecls.h" #include "tool_urlglob.h" #include "var.h" -#include "memdebug.h" /* keep this as LAST include */ /* the type we use for storing a single boolean bit */ #ifndef BIT diff --git a/src/tool_ssls.c b/src/tool_ssls.c index ab78014c0a86..4c9d1ee00857 100644 --- a/src/tool_ssls.c +++ b/src/tool_ssls.c @@ -30,6 +30,8 @@ #include "tool_ssls.h" #include "tool_parsecfg.h" +#include "memdebug.h" /* keep this as LAST include */ + /* The maximum line length for an ecoded session ticket */ #define MAX_SSLS_LINE (64 * 1024) From 529f61388f8c235fc250aa466163396a8965b362 Mon Sep 17 00:00:00 2001 From: Marc Aldorasi Date: Wed, 19 Nov 2025 11:12:31 -0500 Subject: [PATCH 005/415] gnutls: implement CURLOPT_CAINFO_BLOB This adds support for in-memory CA certs using CURLOPT_CAINFO_BLOB to the GnuTLS backend. Closes #19612 --- docs/libcurl/opts/CURLOPT_CAINFO_BLOB.md | 3 ++- lib/vtls/gtls.c | 27 +++++++++++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/docs/libcurl/opts/CURLOPT_CAINFO_BLOB.md b/docs/libcurl/opts/CURLOPT_CAINFO_BLOB.md index 149c9b795f61..99bfaf11e673 100644 --- a/docs/libcurl/opts/CURLOPT_CAINFO_BLOB.md +++ b/docs/libcurl/opts/CURLOPT_CAINFO_BLOB.md @@ -13,6 +13,7 @@ See-also: - CURLOPT_SSL_VERIFYPEER (3) TLS-backend: - OpenSSL + - GnuTLS - mbedTLS - rustls - wolfSSL @@ -80,7 +81,7 @@ int main(void) # HISTORY This option is supported by the mbedTLS (since 7.81.0), Rustls (since 7.82.0), -wolfSSL (since 8.2.0), OpenSSL and Schannel backends. +wolfSSL (since 8.2.0), GnuTLS (since 8.18.0), OpenSSL and Schannel backends. # %AVAILABILITY% diff --git a/lib/vtls/gtls.c b/lib/vtls/gtls.c index eba5fb36f09f..c0e248642b25 100644 --- a/lib/vtls/gtls.c +++ b/lib/vtls/gtls.c @@ -477,7 +477,31 @@ static CURLcode gtls_populate_creds(struct Curl_cfilter *cf, #endif } - if(config->CAfile) { + if(config->ca_info_blob) { + gnutls_datum_t ca_info_datum; + if(config->ca_info_blob->len > (size_t)UINT_MAX) { + failf(data, "certificate blob too long: %zu bytes", + config->ca_info_blob->len); + return CURLE_SSL_CACERT_BADFILE; + } + ca_info_datum.data = config->ca_info_blob->data; + ca_info_datum.size = (unsigned int)config->ca_info_blob->len; + rc = gnutls_certificate_set_x509_trust_mem(creds, &ca_info_datum, + GNUTLS_X509_FMT_PEM); + creds_are_empty = creds_are_empty && (rc <= 0); + if(rc < 0) { + infof(data, "error reading ca cert blob (%s)%s", gnutls_strerror(rc), + (creds_are_empty ? "" : ", continuing anyway")); + if(creds_are_empty) { + ssl_config->certverifyresult = rc; + return CURLE_SSL_CACERT_BADFILE; + } + } + else + infof(data, " CA Blob: %d certificates", rc); + } + /* CURLOPT_CAINFO_BLOB overrides CURLOPT_CAINFO */ + else if(config->CAfile) { /* set the trusted CA cert bundle file */ gnutls_certificate_set_verify_flags(creds, GNUTLS_VERIFY_ALLOW_X509_V1_CA_CRT); @@ -2335,6 +2359,7 @@ const struct Curl_ssl Curl_ssl_gnutls = { SSLSUPP_CERTINFO | SSLSUPP_PINNEDPUBKEY | SSLSUPP_HTTPS_PROXY | + SSLSUPP_CAINFO_BLOB | SSLSUPP_CIPHER_LIST | SSLSUPP_CA_CACHE, From 49ab46c9c50511dcc304a92f3a2e458d4a9fa131 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 19 Nov 2025 15:05:17 +0100 Subject: [PATCH 006/415] gtls: drop support for GnuTLS < 3.6.5 Release date 2018-12-01. Has TLS 1.3 support. Closes #19609 --- docs/INTERNALS.md | 2 +- lib/vtls/gtls.c | 49 ++--------------------------------------------- 2 files changed, 3 insertions(+), 48 deletions(-) diff --git a/docs/INTERNALS.md b/docs/INTERNALS.md index d957c69ab77a..e9bb82a33d8e 100644 --- a/docs/INTERNALS.md +++ b/docs/INTERNALS.md @@ -26,7 +26,7 @@ versions of libs and build tools. - OpenSSL 3.0.0 (2021-09-07) - LibreSSL 2.9.1 (2019-04-22) - - GnuTLS 3.1.10 (2013-03-22) + - GnuTLS 3.6.5 (2018-12-01) - mbedTLS 3.2.0 (2022-07-11) - zlib 1.2.5.2 (2011-12-11) - libssh2 1.9.0 (2019-06-20) diff --git a/lib/vtls/gtls.c b/lib/vtls/gtls.c index c0e248642b25..dbb442f36314 100644 --- a/lib/vtls/gtls.c +++ b/lib/vtls/gtls.c @@ -73,7 +73,7 @@ static void tls_log_func(int level, const char *str) } #endif -#if !defined(GNUTLS_VERSION_NUMBER) || (GNUTLS_VERSION_NUMBER < 0x03010a) +#if !defined(GNUTLS_VERSION_NUMBER) || (GNUTLS_VERSION_NUMBER < 0x030605) #error "too old GnuTLS version" #endif @@ -767,10 +767,8 @@ int Curl_glts_get_ietf_proto(gnutls_session_t session) return CURL_IETF_PROTO_TLS1_1; case GNUTLS_TLS1_2: return CURL_IETF_PROTO_TLS1_2; -#if GNUTLS_VERSION_NUMBER >= 0x030603 case GNUTLS_TLS1_3: return CURL_IETF_PROTO_TLS1_3; -#endif default: return CURL_IETF_PROTO_UNKNOWN; } @@ -1841,51 +1839,8 @@ Curl_gtls_verifyserver(struct Curl_cfilter *cf, rc = (int)gnutls_x509_crt_check_hostname(x509_cert, peer->sni ? peer->sni : peer->hostname); -#if GNUTLS_VERSION_NUMBER < 0x030306 - /* Before 3.3.6, gnutls_x509_crt_check_hostname() did not check IP - addresses. */ - if(!rc) { -#ifdef USE_IPV6 - #define use_addr in6_addr -#else - #define use_addr in_addr -#endif - unsigned char addrbuf[sizeof(struct use_addr)]; - size_t addrlen = 0; - - if(curlx_inet_pton(AF_INET, peer->hostname, addrbuf) > 0) - addrlen = 4; -#ifdef USE_IPV6 - else if(curlx_inet_pton(AF_INET6, peer->hostname, addrbuf) > 0) - addrlen = 16; -#endif - - if(addrlen) { - unsigned char certaddr[sizeof(struct use_addr)]; - int i; - - for(i = 0; ; i++) { - size_t certaddrlen = sizeof(certaddr); - int ret = gnutls_x509_crt_get_subject_alt_name(x509_cert, i, certaddr, - &certaddrlen, NULL); - /* If this happens, it was not an IP address. */ - if(ret == GNUTLS_E_SHORT_MEMORY_BUFFER) - continue; - if(ret < 0) - break; - if(ret != GNUTLS_SAN_IPADDRESS) - continue; - if(certaddrlen == addrlen && !memcmp(addrbuf, certaddr, addrlen)) { - rc = 1; - break; - } - } - } - } -#endif - result = (!rc && config->verifyhost) ? - CURLE_PEER_FAILED_VERIFICATION : CURLE_OK; + CURLE_PEER_FAILED_VERIFICATION : CURLE_OK; gtls_msg_verify_result(data, peer, x509_cert, rc, config->verifyhost); if(result) goto out; From de7ee1c96265013c71a367575abbcf97b843fde3 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 21 Nov 2025 09:19:21 +0100 Subject: [PATCH 007/415] GHA: disable TLS in the linux-old build There are no supported TLS libraries left in "stretch". --- .github/workflows/linux-old.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/linux-old.yml b/.github/workflows/linux-old.yml index f79cee94ac36..64958f4bd61c 100644 --- a/.github/workflows/linux-old.yml +++ b/.github/workflows/linux-old.yml @@ -72,7 +72,7 @@ jobs: dpkg -i freexian-archive-keyring_2022.06.08_all.deb echo 'deb http://deb.freexian.com/extended-lts stretch-lts main contrib non-free' | tee /etc/apt/sources.list.d/extended-lts.list apt-get -o Dpkg::Use-Pty=0 update - apt-get -o Dpkg::Use-Pty=0 install -y --no-install-suggests --no-install-recommends cmake make automake autoconf libtool gcc pkg-config libpsl-dev libzstd-dev zlib1g-dev libgnutls28-dev libc-ares-dev libkrb5-dev libldap2-dev librtmp-dev stunnel4 groff + apt-get -o Dpkg::Use-Pty=0 install -y --no-install-suggests --no-install-recommends cmake make automake autoconf libtool gcc pkg-config libpsl-dev libzstd-dev zlib1g-dev libc-ares-dev libkrb5-dev libldap2-dev librtmp-dev stunnel4 groff # GitHub's actions/checkout needs newer glibc and libstdc++. The latter also depends on # gcc-8-base, but it does not actually seem used in our situation and is not available in # the main repo, so force the install. @@ -89,7 +89,7 @@ jobs: mkdir bld-1 cd bld-1 cmake .. -DCMAKE_UNITY_BUILD=ON -DCURL_WERROR=ON -DBUILD_SHARED_LIBS=ON \ - -DCURL_USE_GNUTLS=ON -DENABLE_ARES=OFF -DCURL_ZSTD=OFF -DCURL_USE_GSSAPI=OFF -DCURL_USE_LIBSSH2=OFF -DCURL_USE_LIBSSH=OFF -DUSE_LIBRTMP=ON + -DCURL_ENABLE_SSL=OFF -DENABLE_ARES=OFF -DCURL_ZSTD=OFF -DCURL_USE_GSSAPI=OFF -DCURL_USE_LIBSSH2=OFF -DCURL_USE_LIBSSH=OFF -DUSE_LIBRTMP=ON - name: 'CM build-only build' run: VERBOSE=1 make -C bld-1 install @@ -113,7 +113,7 @@ jobs: mkdir bld-cares cd bld-cares cmake .. -DCMAKE_UNITY_BUILD=ON -DCURL_WERROR=ON -DBUILD_SHARED_LIBS=ON \ - -DCURL_USE_GNUTLS=ON -DENABLE_ARES=ON -DCURL_USE_GSSAPI=ON -DCURL_USE_LIBSSH2=OFF -DCURL_USE_LIBSSH=OFF -DUSE_LIBRTMP=ON \ + -DCURL_ENABLE_SSL=OFF -DENABLE_ARES=ON -DCURL_USE_GSSAPI=ON -DCURL_USE_LIBSSH2=OFF -DCURL_USE_LIBSSH=OFF -DUSE_LIBRTMP=ON \ -DCURL_LIBCURL_VERSIONED_SYMBOLS=ON - name: 'CM configure log' @@ -151,7 +151,7 @@ jobs: mkdir bld-am cd bld-am ../configure --disable-dependency-tracking --enable-unity --enable-warnings --enable-werror \ - --with-gnutls --enable-ares --without-libssh2 --with-zstd --with-gssapi --with-librtmp \ + --without-ssl --enable-ares --without-libssh2 --with-zstd --with-gssapi --with-librtmp \ --prefix="$PWD"/../curl-install-am - name: 'AM configure log' From dd36dacd3e1518c1744e233d4aa3ec5a3a1c7bbc Mon Sep 17 00:00:00 2001 From: Stefan Eissing Date: Thu, 20 Nov 2025 13:17:03 +0100 Subject: [PATCH 008/415] openssl: no verify failf message unless strict If verifypeer and verifyhost are disabled, to not generate a failf() message for failed verifications. Fixes #19615 Reported-by: ncaklovic on github Closes #19625 --- lib/vtls/openssl.c | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/lib/vtls/openssl.c b/lib/vtls/openssl.c index 80d01c31604b..909c9a135b24 100644 --- a/lib/vtls/openssl.c +++ b/lib/vtls/openssl.c @@ -4557,7 +4557,7 @@ static CURLcode ossl_check_issuer(struct Curl_cfilter *cf, X509 *issuer = NULL; BIO *fp = NULL; char err_buf[256]=""; - bool strict = (conn_config->verifypeer || conn_config->verifyhost); + bool verify_enabled = (conn_config->verifypeer || conn_config->verifyhost); CURLcode result = CURLE_OK; /* e.g. match issuer name with provided issuer certificate */ @@ -4581,7 +4581,7 @@ static CURLcode ossl_check_issuer(struct Curl_cfilter *cf, } if(BIO_read_filename(fp, conn_config->issuercert) <= 0) { - if(strict) + if(verify_enabled) failf(data, "SSL: Unable to open issuer cert (%s)", conn_config->issuercert); result = CURLE_SSL_ISSUER_ERROR; @@ -4592,7 +4592,7 @@ static CURLcode ossl_check_issuer(struct Curl_cfilter *cf, if(fp) { issuer = PEM_read_bio_X509(fp, NULL, ZERO_NULL, NULL); if(!issuer) { - if(strict) + if(verify_enabled) failf(data, "SSL: Unable to read issuer cert (%s)", conn_config->issuercert); result = CURLE_SSL_ISSUER_ERROR; @@ -4600,7 +4600,7 @@ static CURLcode ossl_check_issuer(struct Curl_cfilter *cf, } if(X509_check_issued(issuer, server_cert) != X509_V_OK) { - if(strict) + if(verify_enabled) failf(data, "SSL: Certificate issuer check failed (%s)", conn_config->issuercert); result = CURLE_SSL_ISSUER_ERROR; @@ -4648,8 +4648,6 @@ static CURLcode ossl_infof_cert(struct Curl_cfilter *cf, struct Curl_easy *data, X509 *server_cert) { - struct ssl_primary_config *conn_config = Curl_ssl_cf_get_primary_config(cf); - bool strict = (conn_config->verifypeer || conn_config->verifyhost); BIO *mem = NULL; struct dynbuf dname; char err_buf[256] = ""; @@ -4686,12 +4684,8 @@ static CURLcode ossl_infof_cert(struct Curl_cfilter *cf, (void)BIO_reset(mem); result = x509_name_oneline(X509_get_issuer_name(server_cert), &dname); - if(result) { - if(strict) - failf(data, "SSL: could not get X509-issuer name"); - result = CURLE_PEER_FAILED_VERIFICATION; + if(result) /* should be only fatal stuff like OOM */ goto out; - } infof(data, " issuer: %s", curlx_dyn_ptr(&dname)); out: @@ -4788,7 +4782,6 @@ CURLcode Curl_ossl_check_peer_cert(struct Curl_cfilter *cf, struct ssl_primary_config *conn_config = Curl_ssl_cf_get_primary_config(cf); CURLcode result = CURLE_OK; long ossl_verify; - bool strict = (conn_config->verifypeer || conn_config->verifyhost); X509 *server_cert; bool verified = FALSE; #ifdef USE_APPLE_SECTRUST @@ -4805,7 +4798,8 @@ CURLcode Curl_ossl_check_peer_cert(struct Curl_cfilter *cf, server_cert = SSL_get1_peer_certificate(octx->ssl); if(!server_cert) { - if(!strict) + /* no verification at all, this maybe acceptable */ + if(!(conn_config->verifypeer || conn_config->verifyhost)) goto out; failf(data, "SSL: could not get peer certificate"); @@ -4825,6 +4819,7 @@ CURLcode Curl_ossl_check_peer_cert(struct Curl_cfilter *cf, if(result) goto out; } + /* `verifyhost` is either OK or not requested from here on */ ossl_verify = SSL_get_verify_result(octx->ssl); ssl_config->certverifyresult = ossl_verify; @@ -4853,11 +4848,12 @@ CURLcode Curl_ossl_check_peer_cert(struct Curl_cfilter *cf, if(!verified) { /* no trust established, report the OpenSSL status */ - failf(data, "SSL certificate OpenSSL verify result: %s (%ld)", - X509_verify_cert_error_string(ossl_verify), ossl_verify); - result = CURLE_PEER_FAILED_VERIFICATION; - if(conn_config->verifypeer) + if(conn_config->verifypeer) { + failf(data, "SSL certificate OpenSSL verify result: %s (%ld)", + X509_verify_cert_error_string(ossl_verify), ossl_verify); + result = CURLE_PEER_FAILED_VERIFICATION; goto out; + } infof(data, " SSL certificate verification failed, continuing anyway!"); } From 3561f2c7bfe8d6c4d535a038b67d5f731fe0012f Mon Sep 17 00:00:00 2001 From: x2018 Date: Wed, 19 Nov 2025 23:25:57 +0800 Subject: [PATCH 009/415] lib: cleanup some whitespace nits Closes #19588 --- lib/vtls/openssl.c | 2 +- src/tool_operhlp.c | 2 +- src/tool_setopt.c | 2 +- src/tool_ssls.c | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/vtls/openssl.c b/lib/vtls/openssl.c index 909c9a135b24..5d35ba1a1530 100644 --- a/lib/vtls/openssl.c +++ b/lib/vtls/openssl.c @@ -277,7 +277,7 @@ static CURLcode X509V3_ext(struct Curl_easy *data, if(asn1_object_dump(obj, namebuf, sizeof(namebuf))) /* make sure the name is null-terminated */ - namebuf [ sizeof(namebuf) - 1] = 0; + namebuf[sizeof(namebuf) - 1] = 0; if(!X509V3_EXT_print(bio_out, ext, 0, 0)) ASN1_STRING_print(bio_out, (ASN1_STRING *)X509_EXTENSION_get_data(ext)); diff --git a/src/tool_operhlp.c b/src/tool_operhlp.c index e17955bec306..0d6c2cb6e0e5 100644 --- a/src/tool_operhlp.c +++ b/src/tool_operhlp.c @@ -92,7 +92,7 @@ CURLcode add_file_name_to_url(CURL *curl, char **inurlp, const char *filename) if(uh) { char *ptr; uerr = curl_url_set(uh, CURLUPART_URL, *inurlp, - CURLU_GUESS_SCHEME|CURLU_NON_SUPPORT_SCHEME); + CURLU_GUESS_SCHEME|CURLU_NON_SUPPORT_SCHEME); if(uerr) { result = urlerr_cvt(uerr); goto fail; diff --git a/src/tool_setopt.c b/src/tool_setopt.c index ccecd3a7e030..b7039fbb4881 100644 --- a/src/tool_setopt.c +++ b/src/tool_setopt.c @@ -623,7 +623,7 @@ CURLcode tool_setopt_offt(CURL *curl, const char *name, CURLoption tag, if(global->libcurl && !ret && lval) { /* we only use this for real if --libcurl was used */ ret = easysrc_addf(&easysrc_code, "curl_easy_setopt(hnd, %s, (curl_off_t)%" - CURL_FORMAT_CURL_OFF_T ");", name, lval); + CURL_FORMAT_CURL_OFF_T ");", name, lval); } return ret; diff --git a/src/tool_ssls.c b/src/tool_ssls.c index 4c9d1ee00857..40e67a8044c9 100644 --- a/src/tool_ssls.c +++ b/src/tool_ssls.c @@ -156,8 +156,8 @@ static CURLcode tool_ssls_exp(CURL *easy, void *userptr, (void)earlydata_max; if(!ctx->exported) fputs("# Your SSL session cache. https://curl.se/docs/ssl-sessions.html\n" - "# This file was generated by libcurl! Edit at your own risk.\n", - ctx->fp); + "# This file was generated by libcurl! Edit at your own risk.\n", + ctx->fp); r = curlx_base64_encode((const char *)shmac, shmac_len, &enc, &enc_len); if(r) From eaa7651374898cef89e5783b0219bdffcc0eb60e Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Mon, 17 Nov 2025 23:49:15 +0100 Subject: [PATCH 010/415] lib: replace `_tcsncpy`/`wcsncpy`/`wcscpy` with `_s` counterparts (Windows) Replace: - curl_sspi: macro `_tcsncpy()` with `_tcsncpy_s()`. - curlx/fopen: `wcsncpy()` with `wcsncpy_s()`. - curlx/fopen: `wcscpy()` with `wcscpy_s()`. Use of the pre-existing functions were safe. This patch aims to use the recommended Windows CRT functions. Handle errors returned by them. Also to avoid the compiler warnings silenced via `_CRT_SECURE_NO_WARNINGS`: ``` lib/curl_sspi.c(152): warning C4996: 'wcsncpy': This function or variable may be unsafe. Consider using wcsncpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. lib/curlx/fopen.c(161): warning C4996: 'wcsncpy': This function or variable may be unsafe. Consider using wcsncpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. lib/curlx/fopen.c(162): warning C4996: 'wcscpy': This function or variable may be unsafe. Consider using wcscpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. lib/curlx/fopen.c(174): warning C4996: 'wcsncpy': This function or variable may be unsafe. Consider using wcsncpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. lib/curlx/fopen.c(175): warning C4996: 'wcscpy': This function or variable may be unsafe. Consider using wcscpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. ``` Refs: https://learn.microsoft.com/cpp/c-runtime-library/reference/strncpy-strncpy-l-wcsncpy-wcsncpy-l-mbsncpy-mbsncpy-l https://learn.microsoft.com/cpp/c-runtime-library/reference/strncpy-s-strncpy-s-l-wcsncpy-s-wcsncpy-s-l-mbsncpy-s-mbsncpy-s-l https://learn.microsoft.com/cpp/c-runtime-library/security-features-in-the-crt Cherry-picked from #19581 (in part) Closes #19589 --- lib/curl_setup.h | 2 +- lib/curl_sspi.c | 7 +++++-- lib/curlx/fopen.c | 20 ++++++++++++++++---- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/lib/curl_setup.h b/lib/curl_setup.h index 0df96d5efd28..05e6149f6139 100644 --- a/lib/curl_setup.h +++ b/lib/curl_setup.h @@ -98,7 +98,7 @@ #define _CRT_SECURE_NO_WARNINGS /* for __sys_errlist, __sys_nerr, _open(), _wfopen(), _wopen(), fopen(), freopen(), getenv(), gmtime(), mbstowcs(), sprintf(), - strcpy(), wcscpy(), wcsncpy(), wcstombs(), + strcpy(), wcstombs(), in tests: localtime(), open(), sscanf() */ #endif #endif /* _MSC_VER */ diff --git a/lib/curl_sspi.c b/lib/curl_sspi.c index 32b4c894d6b5..369cf18967a3 100644 --- a/lib/curl_sspi.c +++ b/lib/curl_sspi.c @@ -149,8 +149,11 @@ CURLcode Curl_create_sspi_identity(const char *userp, const char *passwdp, curlx_unicodefree(useranddomain.tchar_ptr); return CURLE_OUT_OF_MEMORY; } - _tcsncpy(dup_domain.tchar_ptr, domain.tchar_ptr, domlen); - *(dup_domain.tchar_ptr + domlen) = TEXT('\0'); + if(_tcsncpy_s(dup_domain.tchar_ptr, domlen + 1, domain.tchar_ptr, domlen)) { + curlx_unicodefree(dup_domain.tchar_ptr); + curlx_unicodefree(useranddomain.tchar_ptr); + return CURLE_OUT_OF_MEMORY; + } identity->Domain = dup_domain.tbyte_ptr; identity->DomainLength = curlx_uztoul(domlen); dup_domain.tchar_ptr = NULL; diff --git a/lib/curlx/fopen.c b/lib/curlx/fopen.c index 333eff7de7e2..f33075316250 100644 --- a/lib/curlx/fopen.c +++ b/lib/curlx/fopen.c @@ -158,8 +158,14 @@ static bool fix_excessive_path(const TCHAR *in, TCHAR **out) if(!temp) goto cleanup; - wcsncpy(temp, L"\\\\?\\UNC\\", 8); - wcscpy(temp + 8, fbuf + 2); + if(wcsncpy_s(temp, needed, L"\\\\?\\UNC\\", 8)) { + (free)(temp); + goto cleanup; + } + if(wcscpy_s(temp + 8, needed, fbuf + 2)) { + (free)(temp); + goto cleanup; + } } else { /* "\\?\" + full path + null */ @@ -171,8 +177,14 @@ static bool fix_excessive_path(const TCHAR *in, TCHAR **out) if(!temp) goto cleanup; - wcsncpy(temp, L"\\\\?\\", 4); - wcscpy(temp + 4, fbuf); + if(wcsncpy_s(temp, needed, L"\\\\?\\", 4)) { + (free)(temp); + goto cleanup; + } + if(wcscpy_s(temp + 4, needed, fbuf)) { + (free)(temp); + goto cleanup; + } } (free)(fbuf); From 9e6f1c5efb7a70e1f33e467a738f3e3f652f3174 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Fri, 21 Nov 2025 12:43:54 +0100 Subject: [PATCH 011/415] build: add build-level `CURL_DISABLE_TYPECHECK` options Usage: - autotools: `--disable-typecheck` (or `--enable-typecheck` (default)) - cmake: `-DCURL_DISABLE_TYPECHECK=ON`. To disable `curl_easy_setopt()`/`curl_easy_getinfo()` type checking with supported (new) gcc and clang compilers. It is useful to improve build performance for the `tests/libtest` target. In particular the CodeQL analyzer may take above an hour to compile with type checking enabled, and disabling it brings it down to seconds. On local machines it may also cut build times in half when build testdeps, depending on platform and compiler. Other than these cases, we recommend leaving type checking enabled. Ref: fdacf34aaeac79ad14fa48dcafae24a6de68823d #19632 Also: - GHA/codeql: use it. - test1165: check in `include/curl`. - lib1912: delete stray todo comment. - spelling and comment nits. Closes #19637 --- .github/workflows/codeql.yml | 6 +-- CMakeLists.txt | 4 +- configure.ac | 82 +++++++++++++++++++++++------------- docs/CURL-DISABLE.md | 10 ++++- docs/INSTALL-CMAKE.md | 3 +- include/curl/typecheck-gcc.h | 4 +- lib/curl_config.h.cmake | 5 ++- tests/libtest/lib1912.c | 3 +- tests/test1165.pl | 3 +- 9 files changed, 76 insertions(+), 44 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index c42d71773567..9ee723cf73ec 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -108,8 +108,7 @@ jobs: # MultiSSL export PKG_CONFIG_PATH; PKG_CONFIG_PATH="$(brew --prefix c-ares)/lib/pkgconfig:$(brew --prefix mbedtls)/lib/pkgconfig:$(brew --prefix rustls-ffi)/lib/pkgconfig:$(brew --prefix gsasl)/lib/pkgconfig" - cmake -B _bld1 -G Ninja -DENABLE_DEBUG=ON \ - -DCMAKE_C_FLAGS=-DCURL_DISABLE_TYPECHECK \ + cmake -B _bld1 -G Ninja -DCURL_DISABLE_TYPECHECK=ON -DENABLE_DEBUG=ON \ -DCURL_USE_GNUTLS=ON -DCURL_USE_MBEDTLS=ON -DCURL_USE_RUSTLS=ON -DCURL_USE_WOLFSSL=ON \ -DUSE_LIBRTMP=ON -DCURL_USE_GSASL=ON -DCURL_USE_GSSAPI=ON -DUSE_SSLS_EXPORT=ON -DUSE_ECH=ON -DENABLE_ARES=ON \ -DCURL_DISABLE_VERBOSE_STRINGS=ON @@ -119,8 +118,7 @@ jobs: # HTTP/3 export PKG_CONFIG_PATH; PKG_CONFIG_PATH="$(brew --prefix libnghttp3)/lib/pkgconfig:$(brew --prefix libngtcp2)/lib/pkgconfig:$(brew --prefix gsasl)/lib/pkgconfig" - cmake -B _bld2 -G Ninja \ - -DCMAKE_C_FLAGS=-DCURL_DISABLE_TYPECHECK \ + cmake -B _bld2 -G Ninja -DCURL_DISABLE_TYPECHECK=ON \ -DCURL_USE_OPENSSL=ON -DOPENSSL_ROOT_DIR="$(brew --prefix openssl)" -DUSE_NGTCP2=ON \ -DCURL_USE_LIBSSH2=OFF -DCURL_USE_LIBSSH=ON \ -DUSE_LIBRTMP=ON -DCURL_USE_GSASL=ON -DCURL_USE_GSSAPI=ON -DUSE_SSLS_EXPORT=ON diff --git a/CMakeLists.txt b/CMakeLists.txt index 7de2162c6cd3..20336e097c0e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -462,7 +462,7 @@ option(CURL_DISABLE_SMB "Disable SMB" OFF) mark_as_advanced(CURL_DISABLE_SMB) option(CURL_DISABLE_SMTP "Disable SMTP" OFF) mark_as_advanced(CURL_DISABLE_SMTP) -option(CURL_DISABLE_SOCKETPAIR "Disable use of socketpair for curl_multi_poll" OFF) +option(CURL_DISABLE_SOCKETPAIR "Disable use of socketpair for curl_multi_poll()" OFF) mark_as_advanced(CURL_DISABLE_SOCKETPAIR) option(CURL_DISABLE_WEBSOCKETS "Disable WebSocket" OFF) mark_as_advanced(CURL_DISABLE_WEBSOCKETS) @@ -470,6 +470,8 @@ option(CURL_DISABLE_TELNET "Disable Telnet" OFF) mark_as_advanced(CURL_DISABLE_TELNET) option(CURL_DISABLE_TFTP "Disable TFTP" OFF) mark_as_advanced(CURL_DISABLE_TFTP) +option(CURL_DISABLE_TYPECHECK "Disable curl_easy_setopt()/curl_easy_getinfo() type checking" OFF) +mark_as_advanced(CURL_DISABLE_TYPECHECK) option(CURL_DISABLE_VERBOSE_STRINGS "Disable verbose strings" OFF) mark_as_advanced(CURL_DISABLE_VERBOSE_STRINGS) diff --git a/configure.ac b/configure.ac index 6c1b9c9ba666..d72b33d5287b 100644 --- a/configure.ac +++ b/configure.ac @@ -140,36 +140,37 @@ AC_SUBST(VERSIONNUM) dnl dnl initialize all the info variables - curl_ssl_msg="no (--with-{openssl,gnutls,mbedtls,wolfssl,schannel,amissl,rustls} )" - curl_ssh_msg="no (--with-{libssh,libssh2})" - curl_zlib_msg="no (--with-zlib)" - curl_brotli_msg="no (--with-brotli)" - curl_zstd_msg="no (--with-zstd)" - curl_gss_msg="no (--with-gssapi)" - curl_gsasl_msg="no (--with-gsasl)" -curl_tls_srp_msg="no (--enable-tls-srp)" - curl_res_msg="blocking (--enable-ares / --enable-threaded-resolver)" - curl_ipv6_msg="no (--enable-ipv6)" -curl_unix_sockets_msg="no (--enable-unix-sockets)" - curl_idn_msg="no (--with-{libidn2,winidn})" - curl_docs_msg="enabled (--disable-docs)" - curl_manual_msg="no (--enable-manual)" -curl_libcurl_msg="enabled (--disable-libcurl-option)" -curl_verbose_msg="enabled (--disable-verbose)" - curl_sspi_msg="no (--enable-sspi)" - curl_ldap_msg="no (--enable-ldap / --with-ldap-lib / --with-lber-lib)" - curl_ldaps_msg="no (--enable-ldaps)" - curl_ipfs_msg="no (--enable-ipfs)" - curl_rtsp_msg="no (--enable-rtsp)" - curl_rtmp_msg="no (--with-librtmp)" - curl_psl_msg="no (--with-libpsl)" - curl_altsvc_msg="enabled (--disable-alt-svc)" -curl_headers_msg="enabled (--disable-headers-api)" - curl_hsts_msg="enabled (--disable-hsts)" - ssl_backends= - curl_h1_msg="enabled (internal)" - curl_h2_msg="no (--with-nghttp2)" - curl_h3_msg="no (--with-ngtcp2 --with-nghttp3, --with-quiche, --with-openssl-quic)" + curl_ssl_msg="no (--with-{openssl,gnutls,mbedtls,wolfssl,schannel,amissl,rustls} )" + curl_ssh_msg="no (--with-{libssh,libssh2})" + curl_zlib_msg="no (--with-zlib)" + curl_brotli_msg="no (--with-brotli)" + curl_zstd_msg="no (--with-zstd)" + curl_gss_msg="no (--with-gssapi)" + curl_gsasl_msg="no (--with-gsasl)" + curl_tls_srp_msg="no (--enable-tls-srp)" + curl_res_msg="blocking (--enable-ares / --enable-threaded-resolver)" + curl_ipv6_msg="no (--enable-ipv6)" +curl_unix_sockets_msg="no (--enable-unix-sockets)" + curl_idn_msg="no (--with-{libidn2,winidn})" + curl_docs_msg="enabled (--disable-docs)" + curl_manual_msg="no (--enable-manual)" + curl_libcurl_msg="enabled (--disable-libcurl-option)" + curl_typecheck_msg="enabled (--disable-typecheck)" + curl_verbose_msg="enabled (--disable-verbose)" + curl_sspi_msg="no (--enable-sspi)" + curl_ldap_msg="no (--enable-ldap / --with-ldap-lib / --with-lber-lib)" + curl_ldaps_msg="no (--enable-ldaps)" + curl_ipfs_msg="no (--enable-ipfs)" + curl_rtsp_msg="no (--enable-rtsp)" + curl_rtmp_msg="no (--with-librtmp)" + curl_psl_msg="no (--with-libpsl)" + curl_altsvc_msg="enabled (--disable-alt-svc)" + curl_headers_msg="enabled (--disable-headers-api)" + curl_hsts_msg="enabled (--disable-hsts)" + ssl_backends= + curl_h1_msg="enabled (internal)" + curl_h2_msg="no (--with-nghttp2)" + curl_h3_msg="no (--with-ngtcp2 --with-nghttp3, --with-quiche, --with-openssl-quic)" enable_altsvc="yes" hsts="yes" @@ -4345,6 +4346,26 @@ AC_CHECK_HEADER(dirent.h, CURL_CONVERT_INCLUDE_TO_ISYSTEM +dnl ************************************************************ +dnl disable curl_easy_setopt()/curl_easy_getinfo() type checking +dnl +AC_MSG_CHECKING([whether to enable curl_easy_setopt()/curl_easy_getinfo() type checking]) +AC_ARG_ENABLE(typecheck, +AS_HELP_STRING([--enable-typecheck],[Enable type checking (default)]) +AS_HELP_STRING([--disable-typecheck],[Disable type checking]), +[ case "$enableval" in + no) + AC_MSG_RESULT(no) + AC_DEFINE(CURL_DISABLE_TYPECHECK, 1, [to disable type checking]) + curl_typecheck_msg="no" + ;; + *) + AC_MSG_RESULT(yes) + ;; + esac ], + AC_MSG_RESULT(yes) +) + dnl ************************************************************ dnl disable verbose text strings dnl @@ -5521,6 +5542,7 @@ AC_MSG_NOTICE([Configured to build curl/libcurl: Build libcurl: Shared=${enable_shared}, Static=${enable_static} Built-in manual: ${curl_manual_msg} --libcurl option: ${curl_libcurl_msg} + Type checking: ${curl_typecheck_msg} Verbose errors: ${curl_verbose_msg} Code coverage: ${curl_coverage_msg} SSPI: ${curl_sspi_msg} diff --git a/docs/CURL-DISABLE.md b/docs/CURL-DISABLE.md index 63de4026a6d2..c266f0c0adc9 100644 --- a/docs/CURL-DISABLE.md +++ b/docs/CURL-DISABLE.md @@ -68,8 +68,8 @@ Disable the FTP (and FTPS) protocol ## `CURL_DISABLE_GETOPTIONS` -Disable the `curl_easy_options` API calls that lets users get information -about existing options to `curl_easy_setopt`. +Disable the `curl_easy_options()` API calls that lets users get information +about existing options to `curl_easy_setopt()`. ## `CURL_DISABLE_GOPHER` @@ -182,6 +182,12 @@ Disable the TELNET protocol Disable the TFTP protocol +## `CURL_DISABLE_TYPECHECK` + +Disable `curl_easy_setopt()`/`curl_easy_getinfo()` type checking. + +Useful to improve build performance for the `tests/libtest` test tool. + ## `CURL_DISABLE_VERBOSE_STRINGS` Disable verbose strings and error messages. diff --git a/docs/INSTALL-CMAKE.md b/docs/INSTALL-CMAKE.md index 9921fbf12c4c..bd9555b61461 100644 --- a/docs/INSTALL-CMAKE.md +++ b/docs/INSTALL-CMAKE.md @@ -317,10 +317,11 @@ target_link_libraries(my_target PRIVATE CURL::libcurl) - `CURL_DISABLE_SHUFFLE_DNS`: Disable shuffle DNS feature. Default: `OFF` - `CURL_DISABLE_SMB`: Disable SMB. Default: `OFF` - `CURL_DISABLE_SMTP`: Disable SMTP. Default: `OFF` -- `CURL_DISABLE_SOCKETPAIR`: Disable use of socketpair for curl_multi_poll. Default: `OFF` +- `CURL_DISABLE_SOCKETPAIR`: Disable use of socketpair for curl_multi_poll(). Default: `OFF` - `CURL_DISABLE_SRP`: Disable TLS-SRP support. Default: `OFF` - `CURL_DISABLE_TELNET`: Disable Telnet. Default: `OFF` - `CURL_DISABLE_TFTP`: Disable TFTP. Default: `OFF` +- `CURL_DISABLE_TYPECHECK`: Disable curl_easy_setopt()/curl_easy_getinfo() type checking. Default: `OFF` - `CURL_DISABLE_VERBOSE_STRINGS`: Disable verbose strings. Default: `OFF` - `CURL_DISABLE_WEBSOCKETS`: Disable WebSocket. Default: `OFF` - `HTTP_ONLY`: Disable all protocols except HTTP (This overrides all `CURL_DISABLE_*` options). Default: `OFF` diff --git a/include/curl/typecheck-gcc.h b/include/curl/typecheck-gcc.h index 063cea57e6f2..bf03e0d9359b 100644 --- a/include/curl/typecheck-gcc.h +++ b/include/curl/typecheck-gcc.h @@ -24,7 +24,7 @@ * ***************************************************************************/ -/* wraps curl_easy_setopt() with typechecking */ +/* wraps curl_easy_setopt() with type checking */ /* To add a new kind of warning, add an * if(curlcheck_sometype_option(_curl_opt)) @@ -159,7 +159,7 @@ curl_easy_setopt(handle, option, value); \ }) -/* wraps curl_easy_getinfo() with typechecking */ +/* wraps curl_easy_getinfo() with type checking */ #define curl_easy_getinfo(handle, info, arg) \ __extension__({ \ if(__builtin_constant_p(info)) { \ diff --git a/lib/curl_config.h.cmake b/lib/curl_config.h.cmake index 88b991d7ef94..acbb428575cc 100644 --- a/lib/curl_config.h.cmake +++ b/lib/curl_config.h.cmake @@ -151,7 +151,7 @@ /* disabled WebSocket */ #cmakedefine CURL_DISABLE_WEBSOCKETS 1 -/* disables use of socketpair for curl_multi_poll */ +/* disables use of socketpair for curl_multi_poll() */ #cmakedefine CURL_DISABLE_SOCKETPAIR 1 /* disables TELNET */ @@ -160,6 +160,9 @@ /* disables TFTP */ #cmakedefine CURL_DISABLE_TFTP 1 +/* disables curl_easy_setopt()/curl_easy_getinfo() type checking */ +#cmakedefine CURL_DISABLE_TYPECHECK 1 + /* disables verbose strings */ #cmakedefine CURL_DISABLE_VERBOSE_STRINGS 1 diff --git a/tests/libtest/lib1912.c b/tests/libtest/lib1912.c index dd3e63881656..0dd246e4612b 100644 --- a/tests/libtest/lib1912.c +++ b/tests/libtest/lib1912.c @@ -31,7 +31,7 @@ static CURLcode test_lib1912(const char *URL) { -/* Only test if GCC typechecking is available */ +/* Only test if GCC/clang type checking is available */ int error = 0; #ifdef CURLINC_TYPECHECK_GCC_H const struct curl_easyoption *o; @@ -73,7 +73,6 @@ static CURLcode test_lib1912(const char *URL) print_err(o->name, "CURLOT_OBJECT"); error++; } - /* Todo: no gcc typecheck for CURLOPTTYPE_BLOB types? */ } #endif (void)URL; diff --git a/tests/test1165.pl b/tests/test1165.pl index 654a2ad64265..049b764647fd 100755 --- a/tests/test1165.pl +++ b/tests/test1165.pl @@ -86,7 +86,7 @@ sub scan_cmake_config_h { scanconf_cmake(\%disable_cmake_config_h, "$root/lib/curl_config.h.cmake"); } -my %whitelisted = ("CURL_DISABLE_TYPECHECK" => 1); +my %whitelisted = ('CURL_DISABLE_DEPRECATION' => 1); sub scan_file { my ($source)=@_; @@ -114,6 +114,7 @@ sub scan_dir { } sub scan_sources { + scan_dir("$root/include/curl"); scan_dir("$root/src"); scan_dir("$root/lib"); scan_dir("$root/lib/vtls"); From 6aa8fa3fdfdb1a0d4d022cc04e478f13e2b6b880 Mon Sep 17 00:00:00 2001 From: Stefan Eissing Date: Fri, 21 Nov 2025 13:06:00 +0100 Subject: [PATCH 012/415] apple-sectrust: always ask when `native_ca_store` is in use When OpenSSL fails to verify the peer certificate, we checked for one specific reason code and did not ask Apple SecTrust for any other failure. Always ask Apple SecTrust after OpenSSL fails when the `native_ca_store` is enabled. If the user configures a CAfile or CApath, the native store is disabled, so this does not affect use cases where users asks curl to use a specific set of trust anchors. Do the same for GnuTLS Fixes #19636 Reported-by: ffath-vo on github Closes #19638 --- lib/vtls/gtls.c | 3 +-- lib/vtls/openssl.c | 4 +--- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/vtls/gtls.c b/lib/vtls/gtls.c index dbb442f36314..55a75fa72150 100644 --- a/lib/vtls/gtls.c +++ b/lib/vtls/gtls.c @@ -1687,8 +1687,7 @@ Curl_gtls_verifyserver(struct Curl_cfilter *cf, infof(data, " SSL certificate verified by GnuTLS"); #ifdef USE_APPLE_SECTRUST - if(!verified && ssl_config->native_ca_store && - (verify_status & GNUTLS_CERT_SIGNER_NOT_FOUND)) { + if(!verified && ssl_config->native_ca_store) { result = glts_apple_verify(cf, data, peer, &chain, &verified); if(result && (result != CURLE_PEER_FAILED_VERIFICATION)) goto out; /* unexpected error */ diff --git a/lib/vtls/openssl.c b/lib/vtls/openssl.c index 5d35ba1a1530..8991d965d9be 100644 --- a/lib/vtls/openssl.c +++ b/lib/vtls/openssl.c @@ -4829,9 +4829,7 @@ CURLcode Curl_ossl_check_peer_cert(struct Curl_cfilter *cf, infof(data, "SSL certificate verified via OpenSSL."); #ifdef USE_APPLE_SECTRUST - if(!verified && - conn_config->verifypeer && ssl_config->native_ca_store && - (ossl_verify == X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY)) { + if(!verified && conn_config->verifypeer && ssl_config->native_ca_store) { /* we verify using Apple SecTrust *unless* OpenSSL already verified. * This may happen if the application intercepted the OpenSSL callback * and installed its own. */ From 047b36d7a698c952b7d76ea3ce303a3d58ae637a Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 21 Nov 2025 14:34:31 +0100 Subject: [PATCH 013/415] smb: fix a size check to be overflow safe In smb_send_message, although it could never actually overflow it might as well be done correctly. Also do the check earlier. Closes #19640 --- lib/smb.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/smb.c b/lib/smb.c index 2aa8e96644a9..4ef35c295d15 100644 --- a/lib/smb.c +++ b/lib/smb.c @@ -668,12 +668,12 @@ static CURLcode smb_send_message(struct Curl_easy *data, unsigned char cmd, const void *msg, size_t msg_len) { - smb_format_message(smbc, req, (struct smb_header *)smbc->send_buf, - cmd, msg_len); - if((sizeof(struct smb_header) + msg_len) > MAX_MESSAGE_SIZE) { + if((MAX_MESSAGE_SIZE - sizeof(struct smb_header)) < msg_len) { DEBUGASSERT(0); return CURLE_SEND_ERROR; } + smb_format_message(smbc, req, (struct smb_header *)smbc->send_buf, + cmd, msg_len); memcpy(smbc->send_buf + sizeof(struct smb_header), msg, msg_len); return smb_send(data, smbc, sizeof(struct smb_header) + msg_len, 0); From e2be5689744716b63477d2e250b53fcac1f8c3b4 Mon Sep 17 00:00:00 2001 From: Stefan Eissing Date: Thu, 20 Nov 2025 10:58:54 +0100 Subject: [PATCH 014/415] multi: make max_total_* members size_t Check size_t conversion on setting these members via CURLMIPT_*. Use members without casting. Closes #19618 --- lib/cshutdn.c | 3 +-- lib/curl_setup.h | 3 +++ lib/curlx/warnless.c | 12 ++++++++++++ lib/curlx/warnless.h | 4 ++++ lib/multi.c | 6 ++++-- lib/multihandle.h | 9 ++++----- lib/url.c | 2 +- 7 files changed, 29 insertions(+), 10 deletions(-) diff --git a/lib/cshutdn.c b/lib/cshutdn.c index f9f636640a03..e039d027625b 100644 --- a/lib/cshutdn.c +++ b/lib/cshutdn.c @@ -414,8 +414,7 @@ void Curl_cshutdn_add(struct cshutdn *cshutdn, size_t conns_in_pool) { struct Curl_easy *data = cshutdn->multi->admin; - size_t max_total = (cshutdn->multi->max_total_connections > 0) ? - (size_t)cshutdn->multi->max_total_connections : 0; + size_t max_total = cshutdn->multi->max_total_connections; /* Add the connection to our shutdown list for non-blocking shutdown * during multi processing. */ diff --git a/lib/curl_setup.h b/lib/curl_setup.h index 05e6149f6139..d75de9416cbf 100644 --- a/lib/curl_setup.h +++ b/lib/curl_setup.h @@ -627,6 +627,9 @@ #endif #endif +#if SIZEOF_LONG > SIZEOF_SIZE_T +#error "unexpected: 'long' is larger than 'size_t'" +#endif /* * Arg 2 type for gethostname in case it has not been defined in config file. */ diff --git a/lib/curlx/warnless.c b/lib/curlx/warnless.c index 5ed27b3e4cbf..fafa83c98c97 100644 --- a/lib/curlx/warnless.c +++ b/lib/curlx/warnless.c @@ -333,6 +333,18 @@ bool curlx_sotouz_fits(curl_off_t sonum, size_t *puznum) return TRUE; } + +bool curlx_sltouz(long slnum, size_t *puznum) +{ + if(slnum < 0) { + *puznum = 0; + return FALSE; + } + /* We error in curl_setup.h if SIZEOF_LONG > SIZEOF_SIZE_T */ + *puznum = (size_t)slnum; + return TRUE; +} + curl_off_t curlx_uztoso(size_t uznum) { #if SIZEOF_SIZE_T >= SIZEOF_CURL_OFF_T diff --git a/lib/curlx/warnless.h b/lib/curlx/warnless.h index c8861d8488c3..52e7ec2a5c5d 100644 --- a/lib/curlx/warnless.h +++ b/lib/curlx/warnless.h @@ -73,6 +73,10 @@ bool curlx_sztouz(ssize_t sznum, size_t *puznum); * too large and set 0 */ bool curlx_sotouz_fits(curl_off_t sonum, size_t *puznum); +/* Convert a long to size_t, return FALSE if negative or too large + * and set 0 */ +bool curlx_sltouz(long sznum, size_t *puznum); + #ifdef _WIN32 #undef read #define read(fd, buf, count) (ssize_t)_read(fd, buf, curlx_uztoui(count)) diff --git a/lib/multi.c b/lib/multi.c index c52ee54c7723..3fc1c948f507 100644 --- a/lib/multi.c +++ b/lib/multi.c @@ -3271,10 +3271,12 @@ CURLMcode curl_multi_setopt(CURLM *m, multi->maxconnects = (unsigned int)uarg; break; case CURLMOPT_MAX_HOST_CONNECTIONS: - multi->max_host_connections = va_arg(param, long); + if(!curlx_sltouz(va_arg(param, long), &multi->max_host_connections)) + res = CURLM_BAD_FUNCTION_ARGUMENT; break; case CURLMOPT_MAX_TOTAL_CONNECTIONS: - multi->max_total_connections = va_arg(param, long); + if(!curlx_sltouz(va_arg(param, long), &multi->max_total_connections)) + res = CURLM_BAD_FUNCTION_ARGUMENT; break; /* options formerly used for pipelining */ case CURLMOPT_MAX_PIPELINE_LENGTH: diff --git a/lib/multihandle.h b/lib/multihandle.h index 69f977bb94ed..fbb8bdfeeb59 100644 --- a/lib/multihandle.h +++ b/lib/multihandle.h @@ -149,11 +149,10 @@ struct Curl_multi { struct cshutdn cshutdn; /* connection shutdown handling */ struct cpool cpool; /* connection pool (bundles) */ - long max_host_connections; /* if >0, a fixed limit of the maximum number - of connections per host */ - - long max_total_connections; /* if >0, a fixed limit of the maximum number - of connections in total */ + size_t max_host_connections; /* if >0, a fixed limit of the maximum number + of connections per host */ + size_t max_total_connections; /* if >0, a fixed limit of the maximum number + of connections in total */ /* timer callback and user data pointer for the *socket() API */ curl_multi_timer_callback timer_cb; diff --git a/lib/url.c b/lib/url.c index b4069e30f18b..7e4d455a8cd8 100644 --- a/lib/url.c +++ b/lib/url.c @@ -3690,7 +3690,7 @@ static CURLcode create_conn(struct Curl_easy *data, CURL_TRC_M(data, "Allowing sub-requests (like DoH) to override " "max connection limit"); else { - infof(data, "No connections available, total of %ld reached.", + infof(data, "No connections available, total of %zu reached.", data->multi->max_total_connections); connections_available = FALSE; } From a439fc0e372c3de7df3b8ae3ca7752bc3cbca826 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 20 Nov 2025 05:59:59 +0000 Subject: [PATCH 015/415] GHA: update gnutls/gnutls to 3.8.11 from 3.8.10 Closes #19613 --- .github/workflows/http3-linux.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/http3-linux.yml b/.github/workflows/http3-linux.yml index 223c6afbf46d..10aac5e0c699 100644 --- a/.github/workflows/http3-linux.yml +++ b/.github/workflows/http3-linux.yml @@ -47,7 +47,7 @@ env: # renovate: datasource=github-tags depName=google/boringssl versioning=semver registryUrl=https://github.com BORINGSSL_VERSION: 0.20251110.0 # renovate: datasource=github-tags depName=gnutls/gnutls versioning=semver registryUrl=https://github.com - GNUTLS_VERSION: 3.8.10 + GNUTLS_VERSION: 3.8.11 # renovate: datasource=github-tags depName=wolfSSL/wolfssl versioning=semver extractVersion=^v?(?.+)-stable$ registryUrl=https://github.com WOLFSSL_VERSION: 5.8.4 # renovate: datasource=github-tags depName=ngtcp2/nghttp3 versioning=semver registryUrl=https://github.com From acfcc2b28806a1be7e027205673b1a33618ddfb5 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Fri, 21 Nov 2025 15:57:17 +0100 Subject: [PATCH 016/415] checksrc: ban `_tcsncpy`, `wcscpy`, `wcsncpy` Follow-up to eaa7651374898cef89e5783b0219bdffcc0eb60e #19589 Closes #19641 --- scripts/checksrc.pl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/checksrc.pl b/scripts/checksrc.pl index c9f008f1a1df..88db59f116d1 100755 --- a/scripts/checksrc.pl +++ b/scripts/checksrc.pl @@ -78,11 +78,14 @@ "_mbsncat" => 1, "_tcscat" => 1, "_tcsdup" => 1, + "_tcsncpy" => 1, "_tcsncat" => 1, "_wcscat" => 1, "_wcsncat" => 1, "_wcsdup" => 1, "wcsdup" => 1, + "wcscpy" => 1, + "wcsncpy" => 1, "LoadLibrary" => 1, "LoadLibraryA" => 1, "LoadLibraryW" => 1, From 18b94293133c1e035b5ac5b4fde854d1f17418a3 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Tue, 18 Nov 2025 01:48:04 +0100 Subject: [PATCH 017/415] curlx: replace `mbstowcs`/`wcstombs` with `_s` counterparts (Windows) They are used in Windows-specific `fopen()`, `freopen`, `open()` and `curlx_get_winapi_error()` calls, and in `fix_excessive_path()` in Unicode builds. Refs: https://learn.microsoft.com/cpp/c-runtime-library/reference/mbstowcs-mbstowcs-l https://learn.microsoft.com/cpp/c-runtime-library/reference/mbstowcs-s-mbstowcs-s-l https://learn.microsoft.com/cpp/c-runtime-library/reference/wcstombs-wcstombs-l https://learn.microsoft.com/cpp/c-runtime-library/reference/wcstombs-s-wcstombs-s-l Also ban these functions via checksrc. Co-authored-by: Jay Satiro Closes #19581 --- lib/curl_setup.h | 3 +-- lib/curlx/fopen.c | 22 ++++++++++++---------- lib/curlx/winapi.c | 30 +++++++++++++----------------- scripts/checksrc.pl | 2 ++ 4 files changed, 28 insertions(+), 29 deletions(-) diff --git a/lib/curl_setup.h b/lib/curl_setup.h index d75de9416cbf..db438a8b0a47 100644 --- a/lib/curl_setup.h +++ b/lib/curl_setup.h @@ -97,8 +97,7 @@ #ifndef _CRT_SECURE_NO_WARNINGS #define _CRT_SECURE_NO_WARNINGS /* for __sys_errlist, __sys_nerr, _open(), _wfopen(), _wopen(), fopen(), freopen(), - getenv(), gmtime(), mbstowcs(), sprintf(), - strcpy(), wcstombs(), + getenv(), gmtime(), sprintf(), strcpy(), in tests: localtime(), open(), sscanf() */ #endif #endif /* _MSC_VER */ diff --git a/lib/curlx/fopen.c b/lib/curlx/fopen.c index f33075316250..dc1c2bb4e67d 100644 --- a/lib/curlx/fopen.c +++ b/lib/curlx/fopen.c @@ -97,15 +97,16 @@ static bool fix_excessive_path(const TCHAR *in, TCHAR **out) #ifndef _UNICODE /* convert multibyte input to unicode */ - needed = mbstowcs(NULL, in, 0); - if(needed == (size_t)-1 || needed >= max_path_len) + if(mbstowcs_s(&needed, NULL, 0, in, 0)) + goto cleanup; + if(!needed || needed >= max_path_len) goto cleanup; - ++needed; /* for NUL */ ibuf = (malloc)(needed * sizeof(wchar_t)); if(!ibuf) goto cleanup; - count = mbstowcs(ibuf, in, needed); - if(count == (size_t)-1 || count >= needed) + if(mbstowcs_s(&count, ibuf, needed, in, needed - 1)) + goto cleanup; + if(count != needed) goto cleanup; in_w = ibuf; #else @@ -193,15 +194,16 @@ static bool fix_excessive_path(const TCHAR *in, TCHAR **out) #ifndef _UNICODE /* convert unicode full path to multibyte output */ - needed = wcstombs(NULL, fbuf, 0); - if(needed == (size_t)-1 || needed >= max_path_len) + if(wcstombs_s(&needed, NULL, 0, fbuf, 0)) + goto cleanup; + if(!needed || needed >= max_path_len) goto cleanup; - ++needed; /* for NUL */ obuf = (malloc)(needed); if(!obuf) goto cleanup; - count = wcstombs(obuf, fbuf, needed); - if(count == (size_t)-1 || count >= needed) + if(wcstombs_s(&count, obuf, needed, fbuf, needed - 1)) + goto cleanup; + if(count != needed) goto cleanup; *out = obuf; obuf = NULL; diff --git a/lib/curlx/winapi.c b/lib/curlx/winapi.c index 2dc277c1c1fa..7b3d6b60369c 100644 --- a/lib/curlx/winapi.c +++ b/lib/curlx/winapi.c @@ -52,6 +52,7 @@ const char *curlx_get_winapi_error(DWORD err, char *buf, size_t buflen) { char *p; wchar_t wbuf[256]; + DWORD wlen; if(!buflen) return NULL; @@ -62,23 +63,18 @@ const char *curlx_get_winapi_error(DWORD err, char *buf, size_t buflen) /* 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). */ - if(FormatMessageW((FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS), NULL, err, - LANG_NEUTRAL, wbuf, CURL_ARRAYSIZE(wbuf), 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'; + wlen = FormatMessageW((FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS), NULL, err, + LANG_NEUTRAL, wbuf, CURL_ARRAYSIZE(wbuf), NULL); + if(wlen && !wcstombs_s(NULL, buf, buflen, wbuf, wlen)) { + /* 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; diff --git a/scripts/checksrc.pl b/scripts/checksrc.pl index 88db59f116d1..a2f458b6c1ac 100755 --- a/scripts/checksrc.pl +++ b/scripts/checksrc.pl @@ -86,6 +86,8 @@ "wcsdup" => 1, "wcscpy" => 1, "wcsncpy" => 1, + "mbstowcs" => 1, + "wcstombs" => 1, "LoadLibrary" => 1, "LoadLibraryA" => 1, "LoadLibraryW" => 1, From 905b718de3fb9287c7c0037b2737aa395f01ad3c Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 21 Nov 2025 16:53:51 +0100 Subject: [PATCH 018/415] Revert "GHA: update gnutls/gnutls to 3.8.11 from 3.8.10" This reverts commit a439fc0e372c3de7df3b8ae3ca7752bc3cbca826. It requires a version of libnettle that is not included in these Ubuntu versions: "Libnettle 3.10 was not found" Closes #19642 --- .github/workflows/http3-linux.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/http3-linux.yml b/.github/workflows/http3-linux.yml index 10aac5e0c699..223c6afbf46d 100644 --- a/.github/workflows/http3-linux.yml +++ b/.github/workflows/http3-linux.yml @@ -47,7 +47,7 @@ env: # renovate: datasource=github-tags depName=google/boringssl versioning=semver registryUrl=https://github.com BORINGSSL_VERSION: 0.20251110.0 # renovate: datasource=github-tags depName=gnutls/gnutls versioning=semver registryUrl=https://github.com - GNUTLS_VERSION: 3.8.11 + GNUTLS_VERSION: 3.8.10 # renovate: datasource=github-tags depName=wolfSSL/wolfssl versioning=semver extractVersion=^v?(?.+)-stable$ registryUrl=https://github.com WOLFSSL_VERSION: 5.8.4 # renovate: datasource=github-tags depName=ngtcp2/nghttp3 versioning=semver registryUrl=https://github.com From 7d75c728a65be961c63169fcf9f307c3324e440b Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 20 Nov 2025 23:57:04 +0100 Subject: [PATCH 019/415] KNOWN_RISKS: known risks when running and using curl and libcurl Closes #19631 --- docs/KNOWN_RISKS.md | 138 ++++++++++++++++++++++++++++++++++++++++++++ docs/Makefile.am | 1 + 2 files changed, 139 insertions(+) create mode 100644 docs/KNOWN_RISKS.md diff --git a/docs/KNOWN_RISKS.md b/docs/KNOWN_RISKS.md new file mode 100644 index 000000000000..3773b94f86bd --- /dev/null +++ b/docs/KNOWN_RISKS.md @@ -0,0 +1,138 @@ + + +# Known Risks + +This is an incomplete list of known risks when running and using curl and +libcurl. + +## Insecure transfers + +When using curl to perform transfers with protocols that are insecure or the +server identity is unverified, everything that is sent and received can be +intercepted by eavesdroppers and the servers can easily be spoofed by +impostors. + +## Untrusted input + +You should **never** run curl command lines or use curl config files provided +to you from untrusted sources. + +curl can do a lot of things, and you should only ask it do things you want and +deem correct. + +Even just accepting just the URL part without careful vetting might make curl +do things you do not like. Like accessing internal hosts, like connecting to +rogue servers that redirect to even weirder places, like using ports or +protocols that play tricks on you. + +## Command line misuse + +The command line tool and its options should be used and be expected to work +as documented. Relying on undocumented functions or side-effects is unreliable +as they may cause problems or get changed behavior between releases. + +For several command line options, you can confuse either curl or the involved +server endpoint by using characters or byte sequences for the option that are +not expected. For example, adding line feeds and/or carriage returns to inputs +can produce unexpected, invalid, or insecure results. + +## API misuse + +Applications using the libcurl API in a way that is not documented to work or +even documented to not work, is unsafe and might cause security problems. We +only guarantee secure and proper functionality when the APIs are used as +documented. + +## Local attackers already present + +When there is a local attacker present locally, curl cannot prevent such an +adversary to use curl's full potential. Possibly in malicious ways. + +## Remote attackers already present + +When there is a remote attacker already present in the server, curl cannot +protect its operations against mischief. For example, if an attacker manages +to insert a symlink in your remote upload directory the upload may cause +havoc. Maybe the attacker makes certain responses come back with unexpected +content. + +## Debug & Experiments + +We encourage users to test curl experiments and use debug code, but only in +controlled environments and setups - never in production. + +Using debug builds and experimental curl features in production is a security +risk. Do not do that. + +The same applies to scripts and software which are not installed by default +through the make install rule: they are not intended or made for production +use. + +## URL inconsistencies + +URL parser inconsistencies between browsers and curl are expected and are not +considered security vulnerabilities. The WHATWG URL Specification and RFC +3986+ (the plus meaning that it is an extended version) [are not completely +interoperable](https://github.com/bagder/docs/blob/master/URL-interop.md). + +You must never expect two independent URL parsers to treat every URL +identically. + +## Visible command line arguments + +The curl command blanks the contents of a number of command line arguments to +prevent them from appearing in process listings. It does not blank all +arguments, even though some that are not blanked might contain sensitive data. + + - not all systems allow the arguments to be blanked in the first place + - since curl blanks the argument itself they are readable for a short moment + no matter what + - virtually every argument can contain sensitive data, depending on use + - blanking all arguments would make it impractical for users to differentiate + curl command lines in process listings + +## HTTP headers in redirects + +It is powerful to provide a set of custom headers to curl. Beware that when +asking curl to follow HTTP redirects, it also sends those headers to the new +URL which might be a different server. That might do another redirect etc. + +curl makes some limited attempts to not leak credentials this way when set +using the standard curl options, but when you pass on custom headers curl +cannot know what headers or details in those headers are sensitive. + +## Verbose logs + +When asked to provide verbose output and trace logging, curl may output and +show details that are private and sensitive. Like for example raw credentials +or the password weakly disguised using base64 encoding. + +## Terminal output and escape sequences + +Content that is transferred from a server and gets displayed in a terminal by +curl may contain escape sequences or use other tricks to fool the user. Escape +sequences, moving cursor, changing color etc, is also frequently used for +good. To reduce the risk of getting fooled, save files and browse them after +download using a display method that minimizes risks. + +## Legacy dependencies + +Every curl build is made to use a range of third party libraries. Each third +party library also needs to be safe and secure for the entire operation to be +risk-free. + +Relying on legacy dependencies is a risk. + +## Weak algorithms + +curl supports several cryptographic algorithms that are considered weak, like +DES and MD5. These algorithms are still in use because some protocols and +transfer options require use of them. For example NTLM or legacy HTTP Digest +authentication. + +curl users should consider switching to servers and options that use modern +and secure algorithms. diff --git a/docs/Makefile.am b/docs/Makefile.am index 65ba28c0eb50..5349c63cc22d 100644 --- a/docs/Makefile.am +++ b/docs/Makefile.am @@ -108,6 +108,7 @@ EXTRA_DIST = \ INTERNALS.md \ IPFS.md \ KNOWN_BUGS \ + KNOWN_RISKS.md \ MAIL-ETIQUETTE.md \ MANUAL.md \ options-in-versions \ From 4ebef2f0d9e3d14c31bdc342235863ef30bdf7d1 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sat, 22 Nov 2025 18:03:40 +0100 Subject: [PATCH 020/415] tool_operate: fix case of ignoring return code in single_transfer When glob_url() returns error, stop. Closes #19649 --- src/tool_operate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tool_operate.c b/src/tool_operate.c index b969375422c3..eea5ff37a260 100644 --- a/src/tool_operate.c +++ b/src/tool_operate.c @@ -1199,7 +1199,7 @@ static CURLcode single_transfer(struct OperationConfig *config, if(u->infile) { if(!config->globoff && !glob_inuse(&state->inglob)) result = glob_url(&state->inglob, u->infile, &state->upnum, err); - if(!state->uploadfile) { + if(!result && !state->uploadfile) { if(glob_inuse(&state->inglob)) result = glob_next_url(&state->uploadfile, &state->inglob); else if(!state->upidx) { From 36b9987acbc42734b1dab0e3f96d64aba1350839 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sat, 22 Nov 2025 19:09:42 +0100 Subject: [PATCH 021/415] tool_operate: fix a case of ignoring return code in operate() If get_args() returns error, do not overwrite the variable in the next call. Also, avoid allocating memory for the default user-agent. Closes #19650 --- src/config2setopts.c | 4 +++- src/tool_operate.c | 24 +++++++++++++----------- src/tool_paramhlp.c | 17 ----------------- 3 files changed, 16 insertions(+), 29 deletions(-) diff --git a/src/config2setopts.c b/src/config2setopts.c index 154319231f11..d3bd39c8647c 100644 --- a/src/config2setopts.c +++ b/src/config2setopts.c @@ -37,6 +37,7 @@ #include "tool_cb_see.h" #include "tool_cb_dbg.h" #include "tool_helpers.h" +#include "tool_version.h" #define BUFFER_SIZE 102400L @@ -874,7 +875,8 @@ CURLcode config2setopts(struct OperationConfig *config, if(proto_http || proto_rtsp) { MY_SETOPT_STR(curl, CURLOPT_REFERER, config->referer); - MY_SETOPT_STR(curl, CURLOPT_USERAGENT, config->useragent); + MY_SETOPT_STR(curl, CURLOPT_USERAGENT, config->useragent ? + config->useragent : CURL_NAME "/" CURL_VERSION); } if(use_proto == proto_http || use_proto == proto_https) { diff --git a/src/tool_operate.c b/src/tool_operate.c index eea5ff37a260..69cfef96d786 100644 --- a/src/tool_operate.c +++ b/src/tool_operate.c @@ -2321,17 +2321,19 @@ CURLcode operate(int argc, argv_item_t argv[]) operation = operation->next; } while(!result && operation); - /* Set the current operation pointer */ - global->current = global->first; - - /* now run! */ - result = run_all_transfers(share, result); - - if(global->ssl_sessions && feature_ssls_export) { - CURLcode r2 = tool_ssls_save(global->first, share, - global->ssl_sessions); - if(r2 && !result) - result = r2; + if(!result) { + /* Set the current operation pointer */ + global->current = global->first; + + /* now run! */ + result = run_all_transfers(share, result); + + if(global->ssl_sessions && feature_ssls_export) { + CURLcode r2 = tool_ssls_save(global->first, share, + global->ssl_sessions); + if(r2 && !result) + result = r2; + } } } diff --git a/src/tool_paramhlp.c b/src/tool_paramhlp.c index 2e7b98f26eb0..15293c0cc6ce 100644 --- a/src/tool_paramhlp.c +++ b/src/tool_paramhlp.c @@ -650,14 +650,6 @@ long delegation(const char *str) return CURLGSSAPI_DELEGATION_NONE; } -/* - * my_useragent: returns allocated string with default user agent - */ -static char *my_useragent(void) -{ - return strdup(CURL_NAME "/" CURL_VERSION); -} - #define isheadersep(x) ((((x)==':') || ((x)==';'))) /* @@ -705,15 +697,6 @@ CURLcode get_args(struct OperationConfig *config, const size_t i) if(!result && config->proxyuserpwd) result = checkpasswd("proxy", i, last, &config->proxyuserpwd); - /* Check if we have a user agent */ - if(!result && !config->useragent) { - config->useragent = my_useragent(); - if(!config->useragent) { - errorf("out of memory"); - result = CURLE_OUT_OF_MEMORY; - } - } - return result; } From f13f320dee7ea37bc01cc7b4282450b6165373c9 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sat, 22 Nov 2025 22:44:39 +0100 Subject: [PATCH 022/415] tool_msgs: make voutf() use stack instead of heap For printf()ing the message to show. Closes #19651 --- src/tool_msgs.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/tool_msgs.c b/src/tool_msgs.c index 896788745c7c..ae0b6b983586 100644 --- a/src/tool_msgs.c +++ b/src/tool_msgs.c @@ -42,18 +42,15 @@ static void voutf(const char *prefix, const char *fmt, va_list ap) { - size_t width = (get_terminal_columns() - strlen(prefix)); size_t len; char *ptr; - char *print_buffer; + char buffer[1024]; + size_t termw = get_terminal_columns(); + size_t prefw = strlen(prefix); + size_t width = termw > prefw ? termw - prefw : SIZE_MAX; DEBUGASSERT(!strchr(fmt, '\n')); - - print_buffer = curl_mvaprintf(fmt, ap); - if(!print_buffer) - return; - len = strlen(print_buffer); - - ptr = print_buffer; + len = curl_mvsnprintf(buffer, sizeof(buffer), fmt, ap); + ptr = buffer; while(len > 0) { fputs(prefix, tool_stderr); @@ -79,7 +76,6 @@ static void voutf(const char *prefix, len = 0; } } - curl_free(print_buffer); } /* From 74f7505974836f633c955dbce7514f12f78ddc5b Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sun, 23 Nov 2025 14:42:59 +0100 Subject: [PATCH 023/415] asyn-ares: remove hostname free on OOM The freeing of the already allocated hostname is done by Curl_async_shutdown(). This extra free in the RR code path made a double-free. Presumably not detected because the CI torture tests don't run HTTPS-RR enabled? Follow-up to 8d0bfe74fb Closes #19658 --- lib/asyn-ares.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/asyn-ares.c b/lib/asyn-ares.c index ad9147a01c34..e01f7ba3d24e 100644 --- a/lib/asyn-ares.c +++ b/lib/asyn-ares.c @@ -748,10 +748,8 @@ struct Curl_addrinfo *Curl_async_getaddrinfo(struct Curl_easy *data, #ifdef USE_HTTPSRR if(port != 443) { rrname = curl_maprintf("_%d_.https.%s", port, hostname); - if(!rrname) { - free(data->state.async.hostname); + if(!rrname) return NULL; - } } #endif From 29b3b1ae6d7ce561700cfe81aaba3b3ebc8a7a6a Mon Sep 17 00:00:00 2001 From: Stefan Eissing Date: Sun, 23 Nov 2025 16:59:40 +0100 Subject: [PATCH 024/415] wolfssl: fix cipher list, skip 5.8.4 regression - adjust cipher list in infof() statement for min/max TLS version - skip test_17_07 for wolfSSL 5.8.4 when CHACHA20 is negotiated due to regression with homebrew build on ARM systems. Fixes #19644 Reported-by: Viktor Szakats Closes #19662 --- lib/vtls/wolfssl.c | 52 +++++++++++++++++++++-------------- tests/http/test_17_ssl_use.py | 4 +++ 2 files changed, 35 insertions(+), 21 deletions(-) diff --git a/lib/vtls/wolfssl.c b/lib/vtls/wolfssl.c index a8090d1bf1ad..c8fc8c4add1a 100644 --- a/lib/vtls/wolfssl.c +++ b/lib/vtls/wolfssl.c @@ -1043,62 +1043,69 @@ static CURLcode client_certificate(struct Curl_easy *data, static CURLcode ssl_version(struct Curl_easy *data, struct ssl_primary_config *conn_config, - struct wssl_ctx *wctx) + struct wssl_ctx *wctx, + int *min_version, int *max_version) { int res; + *min_version = *max_version = 0; switch(conn_config->version) { case CURL_SSLVERSION_DEFAULT: case CURL_SSLVERSION_TLSv1: case CURL_SSLVERSION_TLSv1_0: - res = wolfSSL_CTX_set_min_proto_version(wctx->ssl_ctx, TLS1_VERSION); + *min_version = TLS1_VERSION; break; case CURL_SSLVERSION_TLSv1_1: - res = wolfSSL_CTX_set_min_proto_version(wctx->ssl_ctx, TLS1_1_VERSION); + *min_version = TLS1_1_VERSION; break; case CURL_SSLVERSION_TLSv1_2: - res = wolfSSL_CTX_set_min_proto_version(wctx->ssl_ctx, TLS1_2_VERSION); + *min_version = TLS1_2_VERSION; break; #ifdef WOLFSSL_TLS13 case CURL_SSLVERSION_TLSv1_3: - res = wolfSSL_CTX_set_min_proto_version(wctx->ssl_ctx, TLS1_3_VERSION); + *min_version = TLS1_3_VERSION; break; #endif default: failf(data, "wolfSSL: unsupported minimum TLS version value"); return CURLE_SSL_CONNECT_ERROR; } - if(res != WOLFSSL_SUCCESS) { - failf(data, "wolfSSL: failed set the minimum TLS version"); - return CURLE_SSL_CONNECT_ERROR; - } switch(conn_config->version_max) { #ifdef WOLFSSL_TLS13 case CURL_SSLVERSION_MAX_TLSv1_3: - res = wolfSSL_CTX_set_max_proto_version(wctx->ssl_ctx, TLS1_3_VERSION); + *max_version = TLS1_3_VERSION; break; #endif case CURL_SSLVERSION_MAX_TLSv1_2: - res = wolfSSL_CTX_set_max_proto_version(wctx->ssl_ctx, TLS1_2_VERSION); + *max_version = TLS1_2_VERSION; break; case CURL_SSLVERSION_MAX_TLSv1_1: - res = wolfSSL_CTX_set_max_proto_version(wctx->ssl_ctx, TLS1_1_VERSION); + *max_version = TLS1_1_VERSION; break; case CURL_SSLVERSION_MAX_TLSv1_0: - res = wolfSSL_CTX_set_max_proto_version(wctx->ssl_ctx, TLS1_VERSION); + *max_version = TLS1_VERSION; break; case CURL_SSLVERSION_MAX_DEFAULT: case CURL_SSLVERSION_MAX_NONE: - res = WOLFSSL_SUCCESS; break; default: failf(data, "wolfSSL: unsupported maximum TLS version value"); return CURLE_SSL_CONNECT_ERROR; } + + res = wolfSSL_CTX_set_min_proto_version(wctx->ssl_ctx, *min_version); if(res != WOLFSSL_SUCCESS) { - failf(data, "wolfSSL: failed set the maximum TLS version"); + failf(data, "wolfSSL: failed set the minimum TLS version"); return CURLE_SSL_CONNECT_ERROR; } + + if(*max_version) { + res = wolfSSL_CTX_set_max_proto_version(wctx->ssl_ctx, *max_version); + if(res != WOLFSSL_SUCCESS) { + failf(data, "wolfSSL: failed set the maximum TLS version"); + return CURLE_SSL_CONNECT_ERROR; + } + } return CURLE_OK; } @@ -1126,6 +1133,7 @@ CURLcode Curl_wssl_ctx_init(struct wssl_ctx *wctx, #endif CURLcode result = CURLE_FAILED_INIT; unsigned char transport; + int tls_min, tls_max; DEBUGASSERT(!wctx->ssl_ctx); DEBUGASSERT(!wctx->ssl); @@ -1159,7 +1167,7 @@ CURLcode Curl_wssl_ctx_init(struct wssl_ctx *wctx, goto out; } - result = ssl_version(data, conn_config, wctx); + result = ssl_version(data, conn_config, wctx, &tls_min, &tls_max); if(result) goto out; @@ -1183,12 +1191,14 @@ CURLcode Curl_wssl_ctx_init(struct wssl_ctx *wctx, struct dynbuf c; curlx_dyn_init(&c, MAX_CIPHER_LEN); - if(ciphers13) - result = curlx_dyn_add(&c, ciphers13); - else - result = wssl_add_default_ciphers(TRUE, &c); + if(!tls_max || (tls_max >= TLS1_3_VERSION)) { + if(ciphers13) + result = curlx_dyn_add(&c, ciphers13); + else + result = wssl_add_default_ciphers(TRUE, &c); + } - if(!result) { + if(!result && (tls_min < TLS1_3_VERSION)) { if(ciphers12) { if(curlx_dyn_len(&c)) result = curlx_dyn_addn(&c, ":", 1); diff --git a/tests/http/test_17_ssl_use.py b/tests/http/test_17_ssl_use.py index 58ad7fdf1576..85c43d568e2c 100644 --- a/tests/http/test_17_ssl_use.py +++ b/tests/http/test_17_ssl_use.py @@ -258,6 +258,10 @@ def test_17_07_ssl_ciphers(self, env: Env, httpd, configures_httpd, curl = CurlClient(env=env) url = f'https://{env.authority_for(env.domain1, proto)}/curltest/sslinfo' # SSL backend specifics + # see wolfSSL/wolfssl#9462 + if env.curl_uses_lib('wolfssl') and env.curl_lib_version('wolfssl') == '5.8.4' \ + and ciphers13 and 'TLS_CHACHA20_POLY1305_SHA256' in ciphers13: + pytest.skip('wolfSSL 5.8.4 is borked on ARM with CHACHA20') if env.curl_uses_lib('gnutls'): pytest.skip('GnuTLS does not support setting ciphers') elif env.curl_uses_lib('boringssl'): From 74cf7725d7c47cb66818063bbb1773b4fc6e1247 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 23 Nov 2025 09:37:41 +0000 Subject: [PATCH 025/415] GHA: update ngtcp2/ngtcp2 to v1.18.0 from v1.17.0 Closes #19655 --- .github/workflows/http3-linux.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/http3-linux.yml b/.github/workflows/http3-linux.yml index 223c6afbf46d..e7406c16eb58 100644 --- a/.github/workflows/http3-linux.yml +++ b/.github/workflows/http3-linux.yml @@ -53,7 +53,7 @@ env: # renovate: datasource=github-tags depName=ngtcp2/nghttp3 versioning=semver registryUrl=https://github.com NGHTTP3_VERSION: 1.12.0 # renovate: datasource=github-tags depName=ngtcp2/ngtcp2 versioning=semver registryUrl=https://github.com - NGTCP2_VERSION: 1.17.0 + NGTCP2_VERSION: 1.18.0 # renovate: datasource=github-tags depName=nghttp2/nghttp2 versioning=semver registryUrl=https://github.com NGHTTP2_VERSION: 1.68.0 # renovate: datasource=github-tags depName=cloudflare/quiche versioning=semver registryUrl=https://github.com From 4d04a0301629d1d37476e312202c0c62b5db309e Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 23 Nov 2025 18:23:32 +0000 Subject: [PATCH 026/415] GHA: update ngtcp2/nghttp3 to v1.13.0 from v1.12.0 Closes #19654 --- .github/workflows/http3-linux.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/http3-linux.yml b/.github/workflows/http3-linux.yml index e7406c16eb58..a6c5972cd948 100644 --- a/.github/workflows/http3-linux.yml +++ b/.github/workflows/http3-linux.yml @@ -51,7 +51,7 @@ env: # renovate: datasource=github-tags depName=wolfSSL/wolfssl versioning=semver extractVersion=^v?(?.+)-stable$ registryUrl=https://github.com WOLFSSL_VERSION: 5.8.4 # renovate: datasource=github-tags depName=ngtcp2/nghttp3 versioning=semver registryUrl=https://github.com - NGHTTP3_VERSION: 1.12.0 + NGHTTP3_VERSION: 1.13.0 # renovate: datasource=github-tags depName=ngtcp2/ngtcp2 versioning=semver registryUrl=https://github.com NGTCP2_VERSION: 1.18.0 # renovate: datasource=github-tags depName=nghttp2/nghttp2 versioning=semver registryUrl=https://github.com From b5265b24b059c1d37512d76b767ff832a68ab817 Mon Sep 17 00:00:00 2001 From: bttrfl on github <33011292+bttrfl@users.noreply.github.com> Date: Sun, 23 Nov 2025 06:55:16 +0300 Subject: [PATCH 027/415] speedcheck: do not trigger low speed cancel on transfers with CURL_READFUNC_PAUSE When a trasfer is paused from a read callback with a CURL_READFUNC_PAUSE code, it should be excluded from the speedcheck. Currently only transfers paused from write callbacks are excluded, because the code only checks for "recv direction" of the transfer. This commit adds a check for "send direction". Issue similar to https://github.com/curl/curl/issues/6358 Closes #19653 --- lib/speedcheck.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/speedcheck.c b/lib/speedcheck.c index aede06001920..b074199c37d6 100644 --- a/lib/speedcheck.c +++ b/lib/speedcheck.c @@ -42,7 +42,7 @@ void Curl_speedinit(struct Curl_easy *data) CURLcode Curl_speedcheck(struct Curl_easy *data, struct curltime now) { - if(Curl_xfer_recv_is_paused(data)) + if(Curl_xfer_recv_is_paused(data) || Curl_xfer_send_is_paused(data)) /* A paused transfer is not qualified for speed checks */ return CURLE_OK; From c77bed81a2e1325ffdebc223c27e3d1355147529 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 18 Nov 2025 14:29:09 +0100 Subject: [PATCH 028/415] memdebug: produce stack trace dump with libbacktrace Enable with "configure --enable-backtrace", inserts a backtrace in the memdump log when a torture test limit is reached. Closes #19657 --- configure.ac | 16 ++++++++++++++++ lib/memdebug.c | 38 ++++++++++++++++++++++++++++++++++++++ tests/memanalyze.pl | 5 ++++- 3 files changed, 58 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index d72b33d5287b..1481a096b2bc 100644 --- a/configure.ac +++ b/configure.ac @@ -1108,6 +1108,22 @@ AS_HELP_STRING([--enable-libgcc],[use libgcc when linking]), AC_MSG_RESULT(no) ) +AC_MSG_CHECKING([whether to use libbacktrace]) +AC_ARG_WITH(backtrace, +AS_HELP_STRING([--enable-backtrace],[use libbacktrace when linking]), +[ case "$enableval" in + yes) + LIBS="-lbacktrace $LIBS" + AC_DEFINE(USE_BACKTRACE, 1, [if libbacktrace is in use]) + AC_MSG_RESULT(yes) + ;; + *) + AC_MSG_RESULT(no) + ;; + esac ], + AC_MSG_RESULT(no) +) + CURL_CHECK_LIB_XNET dnl gethostbyname without lib or in the nsl lib? diff --git a/lib/memdebug.c b/lib/memdebug.c index 758c7b6aa7e2..cbda4a2be144 100644 --- a/lib/memdebug.c +++ b/lib/memdebug.c @@ -31,6 +31,10 @@ #include "urldata.h" #include "curlx/fopen.h" /* for CURLX_FOPEN_LOW(), CURLX_FREOPEN_LOW() */ +#ifdef USE_BACKTRACE +#include "backtrace.h" +#endif + /* The last 2 #include files should be in this order */ #include "curl_memory.h" #include "memdebug.h" @@ -58,6 +62,9 @@ FILE *curl_dbg_logfile = NULL; static bool registered_cleanup = FALSE; /* atexit registered cleanup */ static bool memlimit = FALSE; /* enable memory limit */ static long memsize = 0; /* set number of mallocs allowed */ +#ifdef USE_BACKTRACE +struct backtrace_state *btstate; +#endif /* LeakSantizier (LSAN) calls _exit() instead of exit() when a leak is detected on exit so the logfile must be closed explicitly or data could be lost. @@ -73,6 +80,33 @@ static void curl_dbg_cleanup(void) } curl_dbg_logfile = NULL; } +#ifdef USE_BACKTRACE +static void error_callback(void *data, const char *message, int error_number) +{ + (void)data; + if(error_number == -1) + curl_dbg_log("compile with -g\n\n"); + else + curl_dbg_log("Backtrace error %d: %s\n", error_number, message); +} + +static int full_callback(void *data, uintptr_t pc, const char *pathname, + int line_number, const char *function) +{ + (void)data; + (void)pc; + if(pathname || function || line_number) + curl_dbg_log("BT %s:%d -- %s\n", pathname, line_number, function); + return 0; +} + +static void dump_bt(void) +{ + backtrace_full(btstate, 0, full_callback, error_callback, NULL); +} +#else +#define dump_bt() /* nothing to do */ +#endif /* this sets the log filename */ void curl_dbg_memdebug(const char *logname) @@ -88,6 +122,9 @@ void curl_dbg_memdebug(const char *logname) setbuf(curl_dbg_logfile, (char *)NULL); #endif } +#ifdef USE_BACKTRACE + btstate = backtrace_create_state(NULL, 0, error_callback, NULL); +#endif if(!registered_cleanup) registered_cleanup = !atexit(curl_dbg_cleanup); } @@ -115,6 +152,7 @@ static bool countcheck(const char *func, int line, const char *source) /* log to stderr also */ curl_mfprintf(stderr, "LIMIT %s:%d %s reached memlimit\n", source, line, func); + dump_bt(); fflush(curl_dbg_logfile); /* because it might crash now */ /* !checksrc! disable ERRNOVAR 1 */ errno = ENOMEM; diff --git a/tests/memanalyze.pl b/tests/memanalyze.pl index e35b2e7abadf..2b38e5e8a424 100755 --- a/tests/memanalyze.pl +++ b/tests/memanalyze.pl @@ -130,7 +130,10 @@ sub newtotal { chomp $_; my $line = $_; $lnum++; - if($line =~ /^LIMIT ([^ ]*):(\d*) (.*)/) { + if($line =~ /^BT/) { + # back-trace, ignore + } + elsif($line =~ /^LIMIT ([^ ]*):(\d*) (.*)/) { # new memory limit test prefix my $i = $3; my ($source, $linenum) = ($1, $2); From 039fb84cb4e05cc899bb00b2c8456677516529c1 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 24 Nov 2025 13:08:37 +0100 Subject: [PATCH 029/415] tool_writeout: bail out proper on OOM Closes #19667 --- src/tool_writeout.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/tool_writeout.c b/src/tool_writeout.c index cdfa23a752d9..52b35345f4a9 100644 --- a/src/tool_writeout.c +++ b/src/tool_writeout.c @@ -763,6 +763,8 @@ void ourWriteOut(struct OperationConfig *config, struct per_transfer *per, variables, CURL_ARRAYSIZE(variables), sizeof(variables[0]), matchvar); } + else + break; if(wv) { switch(wv->id) { case VAR_ONERROR: From d03712169b7a02e3a9b3c3a5c060395ed37b626e Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Mon, 24 Nov 2025 12:49:15 +0100 Subject: [PATCH 030/415] cmake: add support for libbacktrace, fix two build issues Also: - memdebug: fix symbol collision in unity builds. - memdebug: fix compiler warning by making a variable static. Follow-up to c77bed81a2e1325ffdebc223c27e3d1355147529 #19657 Closes #19666 --- .github/scripts/pyspelling.words | 1 + CMake/FindLibbacktrace.cmake | 52 ++++++++++++++++++++++++++++++++ CMakeLists.txt | 15 +++++++++ Makefile.am | 1 + docs/INSTALL-CMAKE.md | 3 ++ lib/curl_config.h.cmake | 3 ++ lib/memdebug.c | 9 +++--- 7 files changed, 80 insertions(+), 4 deletions(-) create mode 100644 CMake/FindLibbacktrace.cmake diff --git a/.github/scripts/pyspelling.words b/.github/scripts/pyspelling.words index 5c96701cd09b..984424200b9e 100644 --- a/.github/scripts/pyspelling.words +++ b/.github/scripts/pyspelling.words @@ -434,6 +434,7 @@ LDAPS ldaps LF LGTM +libbacktrace libbrotlidec libc libcurl diff --git a/CMake/FindLibbacktrace.cmake b/CMake/FindLibbacktrace.cmake new file mode 100644 index 000000000000..444c5f90fdcf --- /dev/null +++ b/CMake/FindLibbacktrace.cmake @@ -0,0 +1,52 @@ +#*************************************************************************** +# _ _ ____ _ +# Project ___| | | | _ \| | +# / __| | | | |_) | | +# | (__| |_| | _ <| |___ +# \___|\___/|_| \_\_____| +# +# Copyright (C) Daniel Stenberg, , et al. +# +# This software is licensed as described in the 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. +# +# SPDX-License-Identifier: curl +# +########################################################################### +# Find the libbacktrace library +# +# Input variables: +# +# - `LIBBACKTRACE_INCLUDE_DIR`: Absolute path to libbacktrace include directory. +# - `LIBBACKTRACE_LIBRARY`: Absolute path to `libbacktrace` library. +# +# Result variables: +# +# - `LIBBACKTRACE_FOUND`: System has libbacktrace. +# - `LIBBACKTRACE_INCLUDE_DIRS`: The libbacktrace include directories. +# - `LIBBACKTRACE_LIBRARIES`: The libbacktrace library names. + +find_path(LIBBACKTRACE_INCLUDE_DIR NAMES "backtrace.h") +find_library(LIBBACKTRACE_LIBRARY NAMES "backtrace" "libbacktrace") + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Libbacktrace + REQUIRED_VARS + LIBBACKTRACE_INCLUDE_DIR + LIBBACKTRACE_LIBRARY +) + +if(LIBBACKTRACE_FOUND) + set(LIBBACKTRACE_INCLUDE_DIRS ${LIBBACKTRACE_INCLUDE_DIR}) + set(LIBBACKTRACE_LIBRARIES ${LIBBACKTRACE_LIBRARY}) +endif() + +mark_as_advanced(LIBBACKTRACE_INCLUDE_DIR LIBBACKTRACE_LIBRARY) diff --git a/CMakeLists.txt b/CMakeLists.txt index 20336e097c0e..5d6e7ca3e667 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1421,6 +1421,21 @@ if(CURL_USE_GSSAPI) endif() endif() +# libbacktrace +option(CURL_USE_LIBBACKTRACE "Use libbacktrace. Requires build with TrackMemory and DWARF debug information." OFF) +if(CURL_USE_LIBBACKTRACE) + if(NOT ENABLE_CURLDEBUG) + message(FATAL_ERROR "libbacktrace requires TrackMemory enabled") + endif() + if(NOT CMAKE_BUILD_TYPE MATCHES "(Debug|RelWithDebInfo)") + message(FATAL_ERROR "libbacktrace requires debug information") + endif() + find_package(Libbacktrace REQUIRED) + list(APPEND CURL_LIBS ${LIBBACKTRACE_LIBRARIES}) + include_directories(SYSTEM ${LIBBACKTRACE_INCLUDE_DIRS}) + set(USE_BACKTRACE ON) +endif() + # libuv option(CURL_USE_LIBUV "Use libuv for event-based tests" OFF) if(CURL_USE_LIBUV) diff --git a/Makefile.am b/Makefile.am index 1ed54423e532..d289f33d5756 100644 --- a/Makefile.am +++ b/Makefile.am @@ -37,6 +37,7 @@ CMAKE_DIST = \ CMake/FindGnuTLS.cmake \ CMake/FindGSS.cmake \ CMake/FindLDAP.cmake \ + CMake/FindLibbacktrace.cmake \ CMake/FindLibgsasl.cmake \ CMake/FindLibidn2.cmake \ CMake/FindLibpsl.cmake \ diff --git a/docs/INSTALL-CMAKE.md b/docs/INSTALL-CMAKE.md index bd9555b61461..026db0762892 100644 --- a/docs/INSTALL-CMAKE.md +++ b/docs/INSTALL-CMAKE.md @@ -355,6 +355,7 @@ Details via CMake - `CURL_USE_GNUTLS`: Enable GnuTLS for SSL/TLS. Default: `OFF` - `CURL_USE_GSASL`: Use libgsasl. Default: `OFF` - `CURL_USE_GSSAPI`: Use GSSAPI implementation. Default: `OFF` +- `CURL_USE_LIBBACKTRACE`: Use [libbacktrace](https://github.com/ianlancetaylor/libbacktrace). Requires build with TrackMemory and DWARF debug information. Default: `OFF` - `CURL_USE_LIBPSL`: Use libpsl. Default: `ON` - `CURL_USE_LIBSSH2`: Use libssh2. Default: `ON` - `CURL_USE_LIBSSH`: Use libssh. Default: `OFF` @@ -411,6 +412,8 @@ Details via CMake - `LDAP_INCLUDE_DIR`: Absolute path to LDAP include directory. - `LDAP_LIBRARY`: Absolute path to `ldap` library. - `LDAP_LBER_LIBRARY`: Absolute path to `lber` library. +- `LIBBACKTRACE_INCLUDE_DIR`: Absolute path to libbacktrace include directory (https://github.com/ianlancetaylor/libbacktrace). +- `LIBBACKTRACE_LIBRARY`: Absolute path to `libbacktrace` library. - `LIBGSASL_INCLUDE_DIR`: Absolute path to libgsasl include directory. - `LIBGSASL_LIBRARY`: Absolute path to `libgsasl` library. - `LIBIDN2_INCLUDE_DIR`: Absolute path to libidn2 include directory. diff --git a/lib/curl_config.h.cmake b/lib/curl_config.h.cmake index acbb428575cc..37ec3d9a6551 100644 --- a/lib/curl_config.h.cmake +++ b/lib/curl_config.h.cmake @@ -730,6 +730,9 @@ ${SIZEOF_TIME_T_CODE} /* Define to 1 if you have the header file. */ #cmakedefine HAVE_UV_H 1 +/* if libbacktrace is in use */ +#cmakedefine USE_BACKTRACE 1 + /* Define to 1 if you do not want the OpenSSL configuration to be loaded automatically */ #cmakedefine CURL_DISABLE_OPENSSL_AUTO_LOAD_CONFIG 1 diff --git a/lib/memdebug.c b/lib/memdebug.c index cbda4a2be144..6ec292654f80 100644 --- a/lib/memdebug.c +++ b/lib/memdebug.c @@ -63,7 +63,7 @@ static bool registered_cleanup = FALSE; /* atexit registered cleanup */ static bool memlimit = FALSE; /* enable memory limit */ static long memsize = 0; /* set number of mallocs allowed */ #ifdef USE_BACKTRACE -struct backtrace_state *btstate; +static struct backtrace_state *btstate; #endif /* LeakSantizier (LSAN) calls _exit() instead of exit() when a leak is detected @@ -81,7 +81,8 @@ static void curl_dbg_cleanup(void) curl_dbg_logfile = NULL; } #ifdef USE_BACKTRACE -static void error_callback(void *data, const char *message, int error_number) +static void error_bt_callback(void *data, const char *message, + int error_number) { (void)data; if(error_number == -1) @@ -102,7 +103,7 @@ static int full_callback(void *data, uintptr_t pc, const char *pathname, static void dump_bt(void) { - backtrace_full(btstate, 0, full_callback, error_callback, NULL); + backtrace_full(btstate, 0, full_callback, error_bt_callback, NULL); } #else #define dump_bt() /* nothing to do */ @@ -123,7 +124,7 @@ void curl_dbg_memdebug(const char *logname) #endif } #ifdef USE_BACKTRACE - btstate = backtrace_create_state(NULL, 0, error_callback, NULL); + btstate = backtrace_create_state(NULL, 0, error_bt_callback, NULL); #endif if(!registered_cleanup) registered_cleanup = !atexit(curl_dbg_cleanup); From 537987d8c66aac6ec96cde098ab45525e156b54e Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Sat, 22 Nov 2025 01:20:44 +0100 Subject: [PATCH 031/415] curl_fopen: do not pass invalid mode flags to `open()` on Windows The safe (`_s`) variants of the Windows `open()` reject these flags, while the classic ones silently accepted them. Also: - also drop the now unused `stat()` call on Windows. - replace magic number with their equivalent Windows and Unix-specific `S_*` macros. Refs: https://learn.microsoft.com/cpp/c-runtime-library/reference/open-wopen https://learn.microsoft.com/cpp/c-runtime-library/reference/fstat-fstat32-fstat64-fstati64-fstat32i64-fstat64i32 Cherry-picked from #19643 Closes #19645 --- lib/curl_fopen.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/curl_fopen.c b/lib/curl_fopen.c index fd0c7c65d201..f16b3d6cde0d 100644 --- a/lib/curl_fopen.c +++ b/lib/curl_fopen.c @@ -93,11 +93,14 @@ CURLcode Curl_fopen(struct Curl_easy *data, const char *filename, CURLcode result = CURLE_WRITE_ERROR; unsigned char randbuf[41]; char *tempstore = NULL; +#ifndef _WIN32 struct_stat sb; +#endif int fd = -1; char *dir = NULL; *tempname = NULL; +#ifndef _WIN32 *fh = curlx_fopen(filename, FOPEN_WRITETEXT); if(!*fh) goto fail; @@ -105,6 +108,7 @@ CURLcode Curl_fopen(struct Curl_easy *data, const char *filename, return CURLE_OK; } curlx_fclose(*fh); +#endif *fh = NULL; result = Curl_rand_alnum(data, randbuf, sizeof(randbuf)); @@ -125,13 +129,16 @@ CURLcode Curl_fopen(struct Curl_easy *data, const char *filename, } result = CURLE_WRITE_ERROR; -#if (defined(ANDROID) || defined(__ANDROID__)) && \ +#ifdef _WIN32 + fd = curlx_open(tempstore, O_WRONLY | O_CREAT | O_EXCL, + S_IREAD | S_IWRITE); +#elif (defined(ANDROID) || defined(__ANDROID__)) && \ (defined(__i386__) || defined(__arm__)) fd = curlx_open(tempstore, O_WRONLY | O_CREAT | O_EXCL, - (mode_t)(0600 | sb.st_mode)); + (mode_t)(S_IRUSR | S_IWUSR | sb.st_mode)); #else fd = curlx_open(tempstore, O_WRONLY | O_CREAT | O_EXCL, - 0600 | sb.st_mode); + S_IRUSR | S_IWUSR | sb.st_mode); #endif if(fd == -1) goto fail; From 82013066a6149aa906b1fda3f8f1f27bd272a6c2 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Sat, 22 Nov 2025 01:42:15 +0100 Subject: [PATCH 032/415] file: do not pass invalid mode flags to `open()` on upload (Windows) Ref: https://learn.microsoft.com/cpp/c-runtime-library/reference/open-wopen Ref: #19645 Cherry-picked from #19643 Closes #19647 --- lib/file.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/file.c b/lib/file.c index 826bed6d802c..69370690746e 100644 --- a/lib/file.c +++ b/lib/file.c @@ -343,7 +343,10 @@ static CURLcode file_upload(struct Curl_easy *data, else mode |= O_TRUNC; -#if (defined(ANDROID) || defined(__ANDROID__)) && \ +#ifdef _WIN32 + fd = curlx_open(file->path, mode, + data->set.new_file_perms & (_S_IREAD | _S_IWRITE)); +#elif (defined(ANDROID) || defined(__ANDROID__)) && \ (defined(__i386__) || defined(__arm__)) fd = curlx_open(file->path, mode, (mode_t)data->set.new_file_perms); #else From 1eca08a5417740320501448b64e8584de349126c Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Fri, 21 Nov 2025 15:55:33 +0100 Subject: [PATCH 033/415] curlx/strerr: use `strerror_s()` on Windows To replace deprecated, unsafe `sys_nerr`, `sys_errlist` global variables with the function suggested by the CRT warning silenced via `_CRT_SECURE_NO_WARNINGS`: ``` lib/curlx/strerr.c(291): warning C4996: '__sys_nerr': This function or variable may be unsafe. Consider using strerror instead. lib/curlx/strerr.c(292): warning C4996: '__sys_errlist': This function or variable may be unsafe. Consider using strerror instead. ``` (where `strerror` in turn suggests `strerror_s`...) Upside: returns an error and has a Unicode variant. Downaside: happy to return success when passing unrecognized error codes. Work it around by looking for the string "Unknown error" returned in such cases and falling back to other methods to retrieve a description. Refs: https://learn.microsoft.com/cpp/c-runtime-library/errno-doserrno-sys-errlist-and-sys-nerr https://learn.microsoft.com/cpp/c-runtime-library/reference/strerror-s-strerror-s-wcserror-s-wcserror-s Closes #19646 --- lib/curl_setup.h | 6 +++--- lib/curlx/strerr.c | 13 ++++--------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/lib/curl_setup.h b/lib/curl_setup.h index db438a8b0a47..886a8814936a 100644 --- a/lib/curl_setup.h +++ b/lib/curl_setup.h @@ -95,9 +95,9 @@ unlink(), etc. */ #endif #ifndef _CRT_SECURE_NO_WARNINGS -#define _CRT_SECURE_NO_WARNINGS /* for __sys_errlist, __sys_nerr, _open(), - _wfopen(), _wopen(), fopen(), freopen(), - getenv(), gmtime(), sprintf(), strcpy(), +#define _CRT_SECURE_NO_WARNINGS /* for _open(), _wfopen(), _wopen(), fopen(), + freopen(), getenv(), gmtime(), sprintf(), + strcpy(), in tests: localtime(), open(), sscanf() */ #endif #endif /* _MSC_VER */ diff --git a/lib/curlx/strerr.c b/lib/curlx/strerr.c index 047588ed183a..376f68b0b20d 100644 --- a/lib/curlx/strerr.c +++ b/lib/curlx/strerr.c @@ -287,17 +287,12 @@ const char *curlx_strerror(int err, char *buf, size_t buflen) *buf = '\0'; #ifdef _WIN32 - /* 'sys_nerr' is the maximum errno number, it is not widely portable */ - if(err >= 0 && err < sys_nerr) - SNPRINTF(buf, buflen, "%s", sys_errlist[err]); - else { - if( + if((!strerror_s(buf, buflen, err) || !strcmp(buf, "Unknown error")) && #ifdef USE_WINSOCK - !get_winsock_error(err, buf, buflen) && + !get_winsock_error(err, buf, buflen) && #endif - !curlx_get_winapi_error((DWORD)err, buf, buflen)) - SNPRINTF(buf, buflen, "Unknown error %d (%#x)", err, err); - } + !curlx_get_winapi_error((DWORD)err, buf, buflen)) + SNPRINTF(buf, buflen, "Unknown error %d (%#x)", err, err); #else /* !_WIN32 */ #if defined(HAVE_STRERROR_R) && defined(HAVE_POSIX_STRERROR_R) From 3696ac4e29836dd3e5e3b2101d53294846a6ec1b Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 24 Nov 2025 10:43:14 +0000 Subject: [PATCH 034/415] GHA: update dependency ngtcp2/nghttp3 to v1.13.1 Closes #19664 --- .github/workflows/http3-linux.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/http3-linux.yml b/.github/workflows/http3-linux.yml index a6c5972cd948..3f52c146563e 100644 --- a/.github/workflows/http3-linux.yml +++ b/.github/workflows/http3-linux.yml @@ -51,7 +51,7 @@ env: # renovate: datasource=github-tags depName=wolfSSL/wolfssl versioning=semver extractVersion=^v?(?.+)-stable$ registryUrl=https://github.com WOLFSSL_VERSION: 5.8.4 # renovate: datasource=github-tags depName=ngtcp2/nghttp3 versioning=semver registryUrl=https://github.com - NGHTTP3_VERSION: 1.13.0 + NGHTTP3_VERSION: 1.13.1 # renovate: datasource=github-tags depName=ngtcp2/ngtcp2 versioning=semver registryUrl=https://github.com NGTCP2_VERSION: 1.18.0 # renovate: datasource=github-tags depName=nghttp2/nghttp2 versioning=semver registryUrl=https://github.com From fa1270a0d1c8234929e1d399ff06ef8f31a2b0b9 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Mon, 24 Nov 2025 14:43:49 +0100 Subject: [PATCH 035/415] vquic: do not pass invalid mode flags to `open()` (Windows) Follow-up to 82013066a6149aa906b1fda3f8f1f27bd272a6c2 #19647 Closes #19670 --- lib/vquic/vquic.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/vquic/vquic.c b/lib/vquic/vquic.c index 539d9bfeae36..562a99e4fee0 100644 --- a/lib/vquic/vquic.c +++ b/lib/vquic/vquic.c @@ -665,7 +665,11 @@ CURLcode Curl_qlogdir(struct Curl_easy *data, if(!result) { int qlogfd = curlx_open(curlx_dyn_ptr(&fname), O_WRONLY | O_CREAT | CURL_O_BINARY, - data->set.new_file_perms); + data->set.new_file_perms +#ifdef _WIN32 + & (_S_IREAD | _S_IWRITE) +#endif + ); if(qlogfd != -1) *qlogfdp = qlogfd; } From 2b7515ae8e1d448fd6da2fddb74d36c4867cca80 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Mon, 24 Nov 2025 14:51:18 +0100 Subject: [PATCH 036/415] tftpd: fix/tidy up `open()` mode flags - replace 0777 with `S_I*` macros. - fix to not pass invalid flags on Windows. Follow-up to 537987d8c66aac6ec96cde098ab45525e156b54e #19645 Closes #19671 --- tests/server/tftpd.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/server/tftpd.c b/tests/server/tftpd.c index dd7291c7ceb0..6631e2439b96 100644 --- a/tests/server/tftpd.c +++ b/tests/server/tftpd.c @@ -445,7 +445,15 @@ static ssize_t write_behind(struct testcase *test, int convert) if(!test->ofile) { char outfile[256]; snprintf(outfile, sizeof(outfile), "%s/upload.%ld", logdir, test->testno); - test->ofile = open(outfile, O_CREAT|O_RDWR|CURL_O_BINARY, 0777); + test->ofile = open(outfile, O_CREAT | O_RDWR | CURL_O_BINARY, +#ifdef _WIN32 + S_IREAD | S_IWRITE +#else + S_IRUSR | S_IWUSR | S_IXUSR | + S_IRGRP | S_IWGRP | S_IXGRP | + S_IROTH | S_IWOTH | S_IXOTH +#endif + ); if(test->ofile == -1) { logmsg("Could not create and/or open file %s for upload!", outfile); return -1; /* failure! */ From 2b57d415e5a0d0afceeb90c54b45a1644a4f8a40 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Mon, 24 Nov 2025 19:38:34 +0100 Subject: [PATCH 037/415] content_encoding: drop a guard for brotli 1.0.0+ macro Also add comment with version requirement for the other guard. Refs: https://github.com/google/brotli/commit/19d86fb9a60aa7034d4981b69a5b656f5b90017e https://github.com/google/brotli/commit/03739d2b113afe60638069c4e1604dc2ac27380d Ref: #19672 Follow-up to e639d4ca4d794c222dde4680d9ff35053f501042 Closes #19673 --- lib/content_encoding.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/content_encoding.c b/lib/content_encoding.c index b724b576b41d..f128f7565f77 100644 --- a/lib/content_encoding.c +++ b/lib/content_encoding.c @@ -384,12 +384,10 @@ static CURLcode brotli_map_error(BrotliDecoderErrorCode be) case BROTLI_DECODER_ERROR_FORMAT_WINDOW_BITS: case BROTLI_DECODER_ERROR_FORMAT_PADDING_1: case BROTLI_DECODER_ERROR_FORMAT_PADDING_2: -#ifdef BROTLI_DECODER_ERROR_COMPOUND_DICTIONARY +#ifdef BROTLI_DECODER_ERROR_COMPOUND_DICTIONARY /* brotli v1.1.0+ */ case BROTLI_DECODER_ERROR_COMPOUND_DICTIONARY: #endif -#ifdef BROTLI_DECODER_ERROR_DICTIONARY_NOT_SET case BROTLI_DECODER_ERROR_DICTIONARY_NOT_SET: -#endif case BROTLI_DECODER_ERROR_INVALID_ARGUMENTS: return CURLE_BAD_CONTENT_ENCODING; case BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MODES: From be4462a415a96c203be5be9c59d956b24d43f5c2 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 24 Nov 2025 18:45:53 +0100 Subject: [PATCH 038/415] INTERNALS.md: add brotli and zstd version info And alpha-sort the dependency list Closes #19672 --- docs/INTERNALS.md | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/docs/INTERNALS.md b/docs/INTERNALS.md index e9bb82a33d8e..acc4506e6722 100644 --- a/docs/INTERNALS.md +++ b/docs/INTERNALS.md @@ -24,19 +24,21 @@ versions of libs and build tools. We aim to support these or later versions. - - OpenSSL 3.0.0 (2021-09-07) - - LibreSSL 2.9.1 (2019-04-22) - - GnuTLS 3.6.5 (2018-12-01) - - mbedTLS 3.2.0 (2022-07-11) - - zlib 1.2.5.2 (2011-12-11) - - libssh2 1.9.0 (2019-06-20) + - brotli 1.0.0 (2017-09-21) - c-ares 1.6.0 (2008-12-09) - - libssh 0.9.0 (2019-06-28) + - GnuTLS 3.6.5 (2018-12-01) - libidn2 2.0.0 (2017-03-29) - - wolfSSL 3.4.6 (2017-09-22) - - OpenLDAP 2.0 (2000-08-01) + - LibreSSL 2.9.1 (2019-04-22) + - libssh 0.9.0 (2019-06-28) + - libssh2 1.9.0 (2019-06-20) + - mbedTLS 3.2.0 (2022-07-11) - MIT Kerberos 1.3 (2003-07-31) - nghttp2 1.15.0 (2016-09-25) + - OpenLDAP 2.0 (2000-08-01) + - OpenSSL 3.0.0 (2021-09-07) + - wolfSSL 3.4.6 (2017-09-22) + - zlib 1.2.5.2 (2011-12-11) + - zstd 1.0 (2016-08-31) ## Build tools From bfde7811213d482789683094510f0680ee0291e4 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 24 Nov 2025 23:32:59 +0100 Subject: [PATCH 039/415] RELEASE-NOTES: synced --- RELEASE-NOTES | 56 +++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 50 insertions(+), 6 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 3af5605c8dc6..217f8c750446 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -4,22 +4,27 @@ curl and libcurl 8.18.0 Command line options: 273 curl_easy_setopt() options: 308 Public functions in libcurl: 100 - Contributors: 3546 + Contributors: 3549 This release includes the following changes: o build: drop support for VS2008 (Windows) [62] o build: drop Windows CE / CeGCC support [69] + o gnutls: drop support for GnuTLS < 3.6.5 [167] + o gnutls: implement CURLOPT_CAINFO_BLOB [168] o openssl: bump minimum OpenSSL version to 3.0.0 [60] This release includes the following bugfixes: o _PROGRESS.md: add the E unit, mention kibibyte [24] o AmigaOS: increase minimum stack size for tool_main [137] + o apple-sectrust: always ask when `native_ca_store` is in use [162] + o asyn-ares: remove hostname free on OOM [122] o asyn-thrdd: release rrname if ares_init_options fails [41] o autotools: drop autoconf <2.59 compatibility code (zz60-xc-ovr) [70] o badwords: fix issues found in scripts and other files [142] o badwords: fix issues found in tests [156] + o build: add build-level `CURL_DISABLE_TYPECHECK` options [163] o build: exclude clang prereleases from compiler warning options [154] o build: tidy-up MSVC CRT warning suppression macros [140] o ccsidcurl: make curl_mime_data_ccsid() use the converted size [74] @@ -39,6 +44,7 @@ This release includes the following bugfixes: o cookie: return error on OOM [131] o cshutdn: acknowledge FD_SETSIZE for shutdown descriptors [25] o curl: fix progress meter in parallel mode [15] + o curl_fopen: do not pass invalid mode flags to `open()` on Windows [84] o curl_sasl: make Curl_sasl_decode_mech compare case insensitively [160] o curl_setup.h: document more funcs flagged by `_CRT_SECURE_NO_WARNINGS` [124] o curl_setup.h: drop stray `#undef stat` (Windows) [103] @@ -47,6 +53,8 @@ This release includes the following bugfixes: o CURLINFO_TLS_SSL_PTR.md: remove CURLINFO_TLS_SESSION text [49] o CURLOPT_READFUNCTION.md: clarify the size of the buffer [47] o CURLOPT_SSH_KEYFUNCTION.md: fix minor indent mistake in example + o curlx/strerr: use `strerror_s()` on Windows [75] + o curlx: replace `mbstowcs`/`wcstombs` with `_s` counterparts (Windows) [143] o digest_sspi: fix a memory leak on error path [149] o digest_sspi: properly free sspi identity [12] o DISTROS.md: add OpenBSD [126] @@ -56,6 +64,7 @@ This release includes the following bugfixes: o examples/multithread: fix race condition [101] o examples: make functions/data static where missing [139] o examples: tidy-up headers and includes [138] + o file: do not pass invalid mode flags to `open()` on upload (Windows) [83] o ftp: refactor a piece of code by merging the repeated part [40] o ftp: remove #ifdef for define that is always defined [76] o getinfo: improve perf in debug mode [99] @@ -76,6 +85,7 @@ This release includes the following bugfixes: o lib: error for OOM when extracting URL query [127] o lib: fix gssapi.h include on IBMi [55] o lib: refactor the type of funcs which have useless return and checks [1] + o lib: replace `_tcsncpy`/`wcsncpy`/`wcscpy` with `_s` counterparts (Windows) [164] o libssh2: add paths to error messages for quote commands [114] o libssh2: cleanup ssh_force_knownhost_key_type [64] o libssh2: replace atoi() in ssh_force_knownhost_key_type [63] @@ -87,10 +97,12 @@ This release includes the following bugfixes: o mk-ca-bundle.pl: default to SHA256 fingerprints with `-t` option [73] o mk-ca-bundle.pl: use `open()` with argument list to replace backticks [71] o mqtt: reject overly big messages [39] + o multi: make max_total_* members size_t [158] o noproxy: replace atoi with curlx_str_number [67] o openssl: exit properly on OOM when getting certchain [133] o openssl: fix a potential memory leak of bio_out [150] o openssl: fix a potential memory leak of params.cert [151] + o openssl: no verify failf message unless strict [166] o openssl: release ssl_session if sess_reuse_cb fails [43] o openssl: remove code handling default version [28] o OS400/ccsidcurl: fix curl_easy_setopt_ccsid for non-converted blobs [94] @@ -114,7 +126,9 @@ This release includes the following bugfixes: o setopt: disable CURLOPT_HAPROXY_CLIENT_IP on NULL [30] o setopt: when setting bad protocols, don't store them [9] o sftp: fix range downloads in both SSH backends [82] + o smb: fix a size check to be overflow safe [161] o socks_sspi: use free() not FreeContextBuffer() [93] + o speedcheck: do not trigger low speed cancel on transfers with CURL_READFUNC_PAUSE [113] o telnet: replace atoi for BINARY handling with curlx_str_number [66] o TEST-SUITE.md: correct the man page's path [136] o test07_22: fix flakiness [95] @@ -125,21 +139,27 @@ This release includes the following bugfixes: o tests/server: do not fall back to original data file in `test2fopen()` [32] o tests/server: replace `atoi()` and `atol()` with `curlx_str_number()` [110] o tftp: release filename if conn_get_remote_addr fails [42] + o tftpd: fix/tidy up `open()` mode flags [57] o tidy-up: move `CURL_UNCONST()` out from macro `curl_unicodefree()` [121] o tool: consider (some) curl_easy_setopt errors fatal [7] o tool_cfgable: free ssl-sessions at exit [123] o tool_getparam: verify that a file exists for some options [134] o tool_help: add checks to avoid unsigned wrap around [14] o tool_ipfs: check return codes better [20] + o tool_msgs: make voutf() use stack instead of heap [125] o tool_operate: exit on curl_share_setopt errors [108] + o tool_operate: fix a case of ignoring return code in operate() [128] + o tool_operate: fix case of ignoring return code in single_transfer [129] o tool_operate: remove redundant condition [19] o tool_operate: use curlx_str_number instead of atoi [68] o tool_paramhlp: refuse --proto remove all protocols [10] o tool_urlglob: clean up used memory on errors better [44] + o tool_writeout: bail out proper on OOM [104] o url: if OOM in parse_proxy() return error [132] o urlapi: fix mem-leaks in curl_url_get error paths [22] o verify-release: update to avoid shellcheck warning SC2034 [88] o vquic-tls/gnutls: call Curl_gtls_verifyserver unconditionally [96] + o vquic: do not pass invalid mode flags to `open()` (Windows) [58] o vtls: fix CURLOPT_CAPATH use [51] o vtls: handle possible malicious certs_num from peer [53] o vtls: pinned key check [98] @@ -147,6 +167,7 @@ This release includes the following bugfixes: o wolfSSL: able to differentiate between IP and DNS in alt names [13] o wolfssl: avoid NULL dereference in OOM situation [77] o wolfssl: fix a potential memory leak of session [6] + o wolfssl: fix cipher list, skip 5.8.4 regression [117] o wolfssl: simplify wssl_send_earlydata [111] This release includes the following known bugs: @@ -160,6 +181,7 @@ For all changes ever done in curl: Planned upcoming removals include: o OpenSSL-QUIC + o RTMP support o Support for c-ares versions before 1.16.0 o Support for Windows XP/2003 @@ -168,14 +190,15 @@ Planned upcoming removals include: This release would not have looked like this without help, code, reports and advice from friends like these: - Aleksandr Sergeev, Andrew Kirillov, boingball, Brad King, Christian Schmitz, - Dan Fandrich, Daniel McCarney, Daniel Stenberg, Fd929c2CE5fA on github, - Gisle Vanem, Jiyong Yang, Juliusz Sosinowicz, Leonardo Taccari, - letshack9707 on hackerone, Marcel Raad, nait-furry, Nick Korepanov, + Aleksandr Sergeev, Andrew Kirillov, boingball, Brad King, bttrfl on github, + Christian Schmitz, Dan Fandrich, Daniel McCarney, Daniel Stenberg, + Fd929c2CE5fA on github, ffath-vo on github, Gisle Vanem, Jiyong Yang, + Juliusz Sosinowicz, Leonardo Taccari, letshack9707 on hackerone, + Marc Aldorasi, Marcel Raad, nait-furry, ncaklovic on github, Nick Korepanov, Omdahake on github, Patrick Monnerat, pelioro on hackerone, Ray Satiro, renovate[bot], Samuel Henrique, Stanislav Fort, Stefan Eissing, Thomas Klausner, Viktor Szakats, Wesley Moore, Xiaoke Wang - (29 contributors) + (33 contributors) References to bug reports and discussions on issues: @@ -233,6 +256,8 @@ References to bug reports and discussions on issues: [54] = https://curl.se/bug/?i=19399 [55] = https://curl.se/bug/?i=19336 [56] = https://curl.se/bug/?i=19396 + [57] = https://curl.se/bug/?i=19671 + [58] = https://curl.se/bug/?i=19670 [59] = https://curl.se/bug/?i=19630 [60] = https://curl.se/bug/?i=18330 [61] = https://curl.se/bug/?i=19484 @@ -248,6 +273,7 @@ References to bug reports and discussions on issues: [71] = https://curl.se/bug/?i=19461 [73] = https://curl.se/bug/?i=19359 [74] = https://curl.se/bug/?i=19465 + [75] = https://curl.se/bug/?i=19646 [76] = https://curl.se/bug/?i=19463 [77] = https://curl.se/bug/?i=19459 [78] = https://curl.se/bug/?i=19431 @@ -255,6 +281,8 @@ References to bug reports and discussions on issues: [80] = https://curl.se/bug/?i=19452 [81] = https://curl.se/bug/?i=19425 [82] = https://curl.se/bug/?i=19460 + [83] = https://curl.se/bug/?i=19647 + [84] = https://curl.se/bug/?i=19645 [86] = https://curl.se/bug/?i=19451 [87] = https://curl.se/bug/?i=19450 [88] = https://curl.se/bug/?i=19449 @@ -273,6 +301,7 @@ References to bug reports and discussions on issues: [101] = https://curl.se/bug/?i=19524 [102] = https://curl.se/bug/?i=19518 [103] = https://curl.se/bug/?i=19519 + [104] = https://curl.se/bug/?i=19667 [105] = https://curl.se/bug/?i=19517 [106] = https://curl.se/bug/?i=19144 [107] = https://curl.se/bug/?i=19512 @@ -280,15 +309,21 @@ References to bug reports and discussions on issues: [110] = https://curl.se/bug/?i=19510 [111] = https://curl.se/bug/?i=19509 [112] = https://curl.se/bug/?i=19495 + [113] = https://curl.se/bug/?i=19653 [114] = https://curl.se/bug/?i=19605 + [117] = https://curl.se/bug/?i=19644 [118] = https://curl.se/bug/?i=19493 [119] = https://curl.se/bug/?i=19483 [120] = https://curl.se/bug/?i=19506 [121] = https://curl.se/bug/?i=19606 + [122] = https://curl.se/bug/?i=19658 [123] = https://curl.se/bug/?i=19602 [124] = https://curl.se/bug/?i=19597 + [125] = https://curl.se/bug/?i=19651 [126] = https://curl.se/bug/?i=19596 [127] = https://curl.se/bug/?i=19594 + [128] = https://curl.se/bug/?i=19650 + [129] = https://curl.se/bug/?i=19649 [130] = https://curl.se/bug/?i=19593 [131] = https://curl.se/bug/?i=19591 [132] = https://curl.se/bug/?i=19590 @@ -300,6 +335,7 @@ References to bug reports and discussions on issues: [139] = https://curl.se/bug/?i=19579 [140] = https://curl.se/bug/?i=19175 [142] = https://curl.se/bug/?i=19572 + [143] = https://curl.se/bug/?i=19581 [144] = https://curl.se/bug/?i=19571 [146] = https://curl.se/bug/?i=19543 [147] = https://curl.se/bug/?i=19568 @@ -312,5 +348,13 @@ References to bug reports and discussions on issues: [154] = https://curl.se/bug/?i=19566 [156] = https://curl.se/bug/?i=19541 [157] = https://curl.se/bug/?i=19520 + [158] = https://curl.se/bug/?i=19618 [159] = https://curl.se/bug/?i=19540 [160] = https://curl.se/bug/?i=19535 + [161] = https://curl.se/bug/?i=19640 + [162] = https://curl.se/bug/?i=19636 + [163] = https://curl.se/bug/?i=19637 + [164] = https://curl.se/bug/?i=19589 + [166] = https://curl.se/bug/?i=19615 + [167] = https://curl.se/bug/?i=19609 + [168] = https://curl.se/bug/?i=19612 From 24b36fdd1585ea22e5e1f00791f1c20423433cde Mon Sep 17 00:00:00 2001 From: Stefan Eissing Date: Tue, 11 Nov 2025 14:26:48 +0100 Subject: [PATCH 040/415] ratelimit: redesign Description of how this works in `docs/internal/RATELIMITS.ms`. Notable implementation changes: - KEEP_SEND_PAUSE/KEEP_SEND_HOLD and KEEP_RECV_PAUSE/KEEP_RECV_HOLD no longer exist. Pausing is down via blocked the new rlimits. - KEEP_SEND_TIMED no longer exists. Pausing "100-continue" transfers is done in the new `Curl_http_perform_pollset()` method. - HTTP/2 rate limiting implemented via window updates. When transfer initiaiting connection has a ratelimit, adjust the initial window size - HTTP/3 ngtcp2 rate limitin implemnented via ack updates - HTTP/3 quiche does not seem to support this via its API - the default progress-meter has been improved for accuracy in "current speed" results. pytest speed tests have been improved. Closes #19384 --- docs/Makefile.am | 1 + docs/internals/RATELIMITS.md | 100 +++++++++++ lib/Makefile.inc | 4 +- lib/cf-h1-proxy.c | 13 +- lib/file.c | 19 +- lib/ftp.c | 9 +- lib/http.c | 36 ++-- lib/http.h | 6 +- lib/http2.c | 113 ++++++++---- lib/imap.c | 5 +- lib/ldap.c | 2 +- lib/multi.c | 278 +++++++++++++++-------------- lib/multi_ev.c | 2 +- lib/multiif.h | 3 +- lib/pingpong.c | 7 +- lib/pop3.c | 5 +- lib/progress.c | 317 +++++++++++++++++---------------- lib/progress.h | 24 ++- lib/ratelimit.c | 200 +++++++++++++++++++++ lib/ratelimit.h | 92 ++++++++++ lib/request.c | 13 +- lib/request.h | 1 + lib/rtsp.c | 5 +- lib/select.c | 15 +- lib/select.h | 14 +- lib/sendf.c | 23 +++ lib/setopt.c | 2 + lib/smtp.c | 5 +- lib/speedcheck.c | 80 --------- lib/speedcheck.h | 35 ---- lib/telnet.c | 7 +- lib/tftp.c | 11 +- lib/transfer.c | 87 ++++----- lib/transfer.h | 3 - lib/url.c | 6 +- lib/urldata.h | 43 ++--- lib/vquic/curl_ngtcp2.c | 53 ++++-- lib/vssh/libssh.c | 12 +- lib/vssh/libssh2.c | 11 +- lib/vtls/schannel.c | 5 +- lib/ws.c | 8 +- tests/data/Makefile.am | 2 +- tests/data/test3216 | 19 ++ tests/http/test_02_download.py | 14 +- tests/http/test_07_upload.py | 4 +- tests/unit/Makefile.inc | 2 +- tests/unit/unit1606.c | 6 +- tests/unit/unit3216.c | 103 +++++++++++ 48 files changed, 1148 insertions(+), 677 deletions(-) create mode 100644 docs/internals/RATELIMITS.md create mode 100644 lib/ratelimit.c create mode 100644 lib/ratelimit.h delete mode 100644 lib/speedcheck.c delete mode 100644 lib/speedcheck.h create mode 100644 tests/data/test3216 create mode 100644 tests/unit/unit3216.c diff --git a/docs/Makefile.am b/docs/Makefile.am index 5349c63cc22d..da5812a0eb76 100644 --- a/docs/Makefile.am +++ b/docs/Makefile.am @@ -63,6 +63,7 @@ INTERNALDOCS = \ internals/MULTI-EV.md \ internals/NEW-PROTOCOL.md \ internals/PORTING.md \ + internals/RATELIMITS.md \ internals/README.md \ internals/SCORECARD.md \ internals/SPLAY.md \ diff --git a/docs/internals/RATELIMITS.md b/docs/internals/RATELIMITS.md new file mode 100644 index 000000000000..af72211b7874 --- /dev/null +++ b/docs/internals/RATELIMITS.md @@ -0,0 +1,100 @@ + + +# Rate Limiting Transfers + +Rate limiting a transfer means that no more than "n bytes per second" +shall be sent or received. It can be set individually for both directions +via `CURLOPT_MAX_RECV_SPEED_LARGE` and `CURLOPT_MAX_SEND_SPEED_LARGE`. These +options may be adjusted for an ongoing transfer. + +### Implementation Base + +`ratelimit.[ch]` implements `struct Curl_rlimit` and functions to manage +such limits. It has the following properties: + +* `rate_per_sec`: how many "tokens" can be used per second, 0 for infinite. +* `tokens`: the currently available tokens to consume +* `burst_per_sec`: an upper limit on tokens available +* `ts`: the microsecond timestamp of the last tokens update +* `spare_us`: elapsed microseconds that have not counted yet for a token update +* `blocked`: if the limit is blocked + +Tokens can be *drained* from an `rlimit`. This reduces `tokens`, even to +negative values. To enforce the limits, tokens should not be drained +further when they reach 0, but such things may happen. + +An `rlimit`can be asked how long to wait until `tokens` are positive again. +This is given in milliseconds. When token are available, this wait +time is 0. + +Ideally a user of `rlimit` would consume the available tokens to 0, then +get a wait times of 1000ms, after which the set rate of tokens has +regenerated. Rinse and repeat. + +Should a user drain twice the amount of the rate, tokens are negative +and the wait time is 2 seconds. The `spare_us` account for the +time that has passed for the consumption. When a user takes 250ms to +consume the rate, the wait time is then 750ms. + +When a user drains nothing for two seconds, the available tokens would +grow to twice the rate, unless a burst rate is set. + +Finally, an `rlimit` may be set to `blocked` and later unblocked again. +A blocked `rlimit` has no tokens available. This works also when the rate +is unlimited (`rate_per_sec` set to 0). + +### Downloads + +`rlimit` is in `data->progress.dl.rlimit`. `setopt.c` initializes it whenever +the application sets `CURLOPT_MAX_RECV_SPEED_LARGE`. This may be done +in the middle of a transfer. + +`rlimit` tokens are drained in the "protocol" client writer. Checks for +capacity depend on the protocol: + +* HTTP and other plain protocols: `transfer.c:sendrecv_dl()` reads only +up to capacity. +* HTTP/2: capacity is used to adjust a stream's window size. Since all +streams start with `64kb`, `rlimit` takes a few seconds to take effect. +* HTTP/3: ngtcp2 acknowledges stream data according to capacity. It +keeps track of bytes not acknowledged yet. This has the same effect as HTTP/2 +window sizes. + +(The quiche API does not offer control of `ACK`s and `rlimits` for download +do not work in that backend.) + +### Uploads + +`rlimit` is in `data->progress.ul.rlimit`. `setopt.c` initializes it whenever +the application sets `CURLOPT_MAX_SEND_SPEED_LARGE`. This may be done +in the middle of a transfer. + +The upload capacity is checked in `Curl_client_read()` and readers are +only asked to read bytes up to the `rlimit` capacity. This limits upload +of data for all protocols in the same way. + +### Pause/Unpause + +Pausing of up-/downloads sets the corresponding `rlimit` to blocked. Unpausing +removes that block. + +### Suspending transfers + +While obeying the `rlimit` for up-/download leads to the desired transfer +rates, the other issue that needs care is CPU consumption. + +`rlimits` are inspected when computing the "pollset" of a transfer. When +a transfer wants to send, but not send tokens are available, the `POLLOUT` +is removed from the pollset. Same for receiving. + +For a transfer that is, due to `rlimit`, not able to progress, the pollset +is then empty. No socket events are monitored, no CPU activity +happens. For paused transfers, this is sufficient. + +Draining `rlimit` happens when a transfer is in `PERFORM` state and +exhausted limits cause the timer `TOOFAST` to be set. When the fires, +the transfer runs again and `rlimit`s are re-evaluated. diff --git a/lib/Makefile.inc b/lib/Makefile.inc index 4bdf293f8976..9c9d5c918691 100644 --- a/lib/Makefile.inc +++ b/lib/Makefile.inc @@ -234,6 +234,7 @@ LIB_CFILES = \ progress.c \ psl.c \ rand.c \ + ratelimit.c \ rename.c \ request.c \ rtsp.c \ @@ -249,7 +250,6 @@ LIB_CFILES = \ socks.c \ socks_gssapi.c \ socks_sspi.c \ - speedcheck.c \ splay.c \ strcase.c \ strdup.c \ @@ -366,6 +366,7 @@ LIB_HFILES = \ progress.h \ psl.h \ rand.h \ + ratelimit.h \ rename.h \ request.h \ rtsp.h \ @@ -383,7 +384,6 @@ LIB_HFILES = \ sockaddr.h \ socketpair.h \ socks.h \ - speedcheck.h \ splay.h \ strcase.h \ strdup.h \ diff --git a/lib/cf-h1-proxy.c b/lib/cf-h1-proxy.c index 91d690e31a9e..985500f23e06 100644 --- a/lib/cf-h1-proxy.c +++ b/lib/cf-h1-proxy.c @@ -384,8 +384,8 @@ static CURLcode recv_CONNECT_resp(struct Curl_cfilter *cf, /* socket buffer drained, return */ return CURLE_OK; - if(Curl_pgrsUpdate(data)) - return CURLE_ABORTED_BY_CALLBACK; + if(!result) + result = Curl_pgrsUpdate(data); if(result) { ts->keepon = KEEPON_DONE; @@ -565,10 +565,8 @@ static CURLcode H1_CONNECT(struct Curl_cfilter *cf, /* read what is there */ CURL_TRC_CF(data, cf, "CONNECT receive"); result = recv_CONNECT_resp(cf, data, ts, &done); - if(Curl_pgrsUpdate(data)) { - result = CURLE_ABORTED_BY_CALLBACK; - goto out; - } + if(!result) + result = Curl_pgrsUpdate(data); /* error or not complete yet. return for more multi-multi */ if(result || !done) goto out; @@ -671,8 +669,7 @@ static CURLcode cf_h1_proxy_connect(struct Curl_cfilter *cf, /* The real request will follow the CONNECT, reset request partially */ Curl_req_soft_reset(&data->req, data); Curl_client_reset(data); - Curl_pgrsSetUploadCounter(data, 0); - Curl_pgrsSetDownloadCounter(data, 0); + Curl_pgrsReset(data); tunnel_free(cf, data); } diff --git a/lib/file.c b/lib/file.c index 69370690746e..3de92408c490 100644 --- a/lib/file.c +++ b/lib/file.c @@ -60,7 +60,6 @@ #include "sendf.h" #include "escape.h" #include "file.h" -#include "speedcheck.h" #include "multiif.h" #include "transfer.h" #include "url.h" @@ -415,13 +414,10 @@ static CURLcode file_upload(struct Curl_easy *data, Curl_pgrsSetUploadCounter(data, bytecount); - if(Curl_pgrsUpdate(data)) - result = CURLE_ABORTED_BY_CALLBACK; - else - result = Curl_speedcheck(data, curlx_now()); + result = Curl_pgrsCheck(data); } - if(!result && Curl_pgrsUpdate(data)) - result = CURLE_ABORTED_BY_CALLBACK; + if(!result) + result = Curl_pgrsUpdate(data); out: close(fd); @@ -620,10 +616,7 @@ static CURLcode file_do(struct Curl_easy *data, bool *done) if(result) goto out; - if(Curl_pgrsUpdate(data)) - result = CURLE_ABORTED_BY_CALLBACK; - else - result = Curl_speedcheck(data, curlx_now()); + result = Curl_pgrsCheck(data); if(result) goto out; } @@ -657,8 +650,8 @@ static CURLcode file_do(struct Curl_easy *data, bool *done) #endif } - if(Curl_pgrsUpdate(data)) - result = CURLE_ABORTED_BY_CALLBACK; + if(!result) + result = Curl_pgrsUpdate(data); out: Curl_multi_xfer_buf_release(data, xfer_buf); diff --git a/lib/ftp.c b/lib/ftp.c index ac4fdc25c96a..c289581fd5a4 100644 --- a/lib/ftp.c +++ b/lib/ftp.c @@ -65,7 +65,6 @@ #include "sockaddr.h" /* required for Curl_sockaddr_storage */ #include "multiif.h" #include "url.h" -#include "speedcheck.h" #include "curlx/warnless.h" #include "http_proxy.h" #include "socks.h" @@ -675,8 +674,7 @@ static CURLcode getftpresponse(struct Curl_easy *data, return CURLE_RECV_ERROR; } else if(ev == 0) { - if(Curl_pgrsUpdate(data)) - return CURLE_ABORTED_BY_CALLBACK; + result = Curl_pgrsUpdate(data); continue; /* just continue in our loop for the timeout duration */ } } @@ -4344,10 +4342,7 @@ CURLcode ftp_regular_transfer(struct Curl_easy *data, bool connected = FALSE; data->req.size = -1; /* make sure this is unknown at this point */ - Curl_pgrsSetUploadCounter(data, 0); - Curl_pgrsSetDownloadCounter(data, 0); - Curl_pgrsSetUploadSize(data, -1); - Curl_pgrsSetDownloadSize(data, -1); + Curl_pgrsReset(data); ftpc->ctl_valid = TRUE; /* starts good */ diff --git a/lib/http.c b/lib/http.c index 095a9127a4ee..a1e449d35441 100644 --- a/lib/http.c +++ b/lib/http.c @@ -129,9 +129,9 @@ const struct Curl_handler Curl_handler_http = { ZERO_NULL, /* connecting */ ZERO_NULL, /* doing */ ZERO_NULL, /* proto_pollset */ - Curl_http_do_pollset, /* doing_pollset */ + Curl_http_doing_pollset, /* doing_pollset */ ZERO_NULL, /* domore_pollset */ - ZERO_NULL, /* perform_pollset */ + Curl_http_perform_pollset, /* perform_pollset */ ZERO_NULL, /* disconnect */ Curl_http_write_resp, /* write_resp */ Curl_http_write_resp_hd, /* write_resp_hd */ @@ -159,9 +159,9 @@ const struct Curl_handler Curl_handler_https = { NULL, /* connecting */ ZERO_NULL, /* doing */ NULL, /* proto_pollset */ - Curl_http_do_pollset, /* doing_pollset */ + Curl_http_doing_pollset, /* doing_pollset */ ZERO_NULL, /* domore_pollset */ - ZERO_NULL, /* perform_pollset */ + Curl_http_perform_pollset, /* perform_pollset */ ZERO_NULL, /* disconnect */ Curl_http_write_resp, /* write_resp */ Curl_http_write_resp_hd, /* write_resp_hd */ @@ -1560,13 +1560,30 @@ CURLcode Curl_http_connect(struct Curl_easy *data, bool *done) /* this returns the socket to wait for in the DO and DOING state for the multi interface and then we are always _sending_ a request and thus we wait for the single socket to become writable only */ -CURLcode Curl_http_do_pollset(struct Curl_easy *data, - struct easy_pollset *ps) +CURLcode Curl_http_doing_pollset(struct Curl_easy *data, + struct easy_pollset *ps) { /* write mode */ return Curl_pollset_add_out(data, ps, data->conn->sock[FIRSTSOCKET]); } +CURLcode Curl_http_perform_pollset(struct Curl_easy *data, + struct easy_pollset *ps) +{ + struct connectdata *conn = data->conn; + CURLcode result = CURLE_OK; + + if(CURL_WANT_RECV(data)) { + result = Curl_pollset_add_in(data, ps, conn->sock[FIRSTSOCKET]); + } + + /* on a "Expect: 100-continue" timed wait, do not poll for outgoing */ + if(!result && Curl_req_want_send(data) && !http_exp100_is_waiting(data)) { + result = Curl_pollset_add_out(data, ps, conn->sock[FIRSTSOCKET]); + } + return result; +} + /* * Curl_http_done() gets called after a single HTTP request has been * performed. @@ -4872,8 +4889,6 @@ static void http_exp100_continue(struct Curl_easy *data, struct cr_exp100_ctx *ctx = reader->ctx; if(ctx->state > EXP100_SEND_DATA) { ctx->state = EXP100_SEND_DATA; - data->req.keepon |= KEEP_SEND; - data->req.keepon &= ~KEEP_SEND_TIMED; Curl_expire_done(data, EXPIRE_100_TIMEOUT); } } @@ -4903,8 +4918,6 @@ static CURLcode cr_exp100_read(struct Curl_easy *data, ctx->state = EXP100_AWAITING_CONTINUE; ctx->start = curlx_now(); Curl_expire(data, data->set.expect_100_timeout, EXPIRE_100_TIMEOUT); - data->req.keepon &= ~KEEP_SEND; - data->req.keepon |= KEEP_SEND_TIMED; *nread = 0; *eos = FALSE; return CURLE_OK; @@ -4917,8 +4930,6 @@ static CURLcode cr_exp100_read(struct Curl_easy *data, ms = curlx_timediff_ms(curlx_now(), ctx->start); if(ms < data->set.expect_100_timeout) { DEBUGF(infof(data, "cr_exp100_read, AWAITING_CONTINUE, not expired")); - data->req.keepon &= ~KEEP_SEND; - data->req.keepon |= KEEP_SEND_TIMED; *nread = 0; *eos = FALSE; return CURLE_OK; @@ -4938,7 +4949,6 @@ static void cr_exp100_done(struct Curl_easy *data, { struct cr_exp100_ctx *ctx = reader->ctx; ctx->state = premature ? EXP100_FAILED : EXP100_SEND_DATA; - data->req.keepon &= ~KEEP_SEND_TIMED; Curl_expire_done(data, EXPIRE_100_TIMEOUT); } diff --git a/lib/http.h b/lib/http.h index 67ef17f5b953..ef41d7bb2249 100644 --- a/lib/http.h +++ b/lib/http.h @@ -115,8 +115,10 @@ CURLcode Curl_http_setup_conn(struct Curl_easy *data, CURLcode Curl_http(struct Curl_easy *data, bool *done); CURLcode Curl_http_done(struct Curl_easy *data, CURLcode, bool premature); CURLcode Curl_http_connect(struct Curl_easy *data, bool *done); -CURLcode Curl_http_do_pollset(struct Curl_easy *data, - struct easy_pollset *ps); +CURLcode Curl_http_doing_pollset(struct Curl_easy *data, + struct easy_pollset *ps); +CURLcode Curl_http_perform_pollset(struct Curl_easy *data, + struct easy_pollset *ps); CURLcode Curl_http_write_resp(struct Curl_easy *data, const char *buf, size_t blen, bool is_eos); diff --git a/lib/http2.c b/lib/http2.c index a1caa2020f7c..5d1a502810fb 100644 --- a/lib/http2.c +++ b/lib/http2.c @@ -98,33 +98,6 @@ #define H2_SETTINGS_IV_LEN 3 #define H2_BINSETTINGS_LEN 80 -static size_t populate_settings(nghttp2_settings_entry *iv, - struct Curl_easy *data) -{ - iv[0].settings_id = NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS; - iv[0].value = Curl_multi_max_concurrent_streams(data->multi); - - iv[1].settings_id = NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE; - iv[1].value = H2_STREAM_WINDOW_SIZE_INITIAL; - - iv[2].settings_id = NGHTTP2_SETTINGS_ENABLE_PUSH; - iv[2].value = data->multi->push_cb != NULL; - - return 3; -} - -static ssize_t populate_binsettings(uint8_t *binsettings, - struct Curl_easy *data) -{ - nghttp2_settings_entry iv[H2_SETTINGS_IV_LEN]; - size_t ivlen; - - ivlen = populate_settings(iv, data); - /* this returns number of bytes it wrote or a negative number on error. */ - return nghttp2_pack_settings_payload(binsettings, H2_BINSETTINGS_LEN, - iv, ivlen); -} - struct cf_h2_ctx { nghttp2_session *h2; /* The easy handle used in the current filter call, cleared at return */ @@ -137,6 +110,7 @@ struct cf_h2_ctx { struct uint_hash streams; /* hash of `data->mid` to `h2_stream_ctx` */ size_t drain_total; /* sum of all stream's UrlState drain */ + uint32_t initial_win_size; /* current initial window size (settings) */ uint32_t max_concurrent_streams; uint32_t goaway_error; /* goaway error code from server */ int32_t remote_max_sid; /* max id processed by server */ @@ -204,6 +178,60 @@ static void cf_h2_ctx_close(struct cf_h2_ctx *ctx) } } +static uint32_t cf_h2_initial_win_size(struct Curl_easy *data) +{ +#if NGHTTP2_HAS_SET_LOCAL_WINDOW_SIZE + /* If the transfer has a rate-limit lower than the default initial + * stream window size, use that. It needs to be at least 8k or servers + * may be unhappy. */ + if(data->progress.dl.rlimit.rate_per_step && + (data->progress.dl.rlimit.rate_per_step < H2_STREAM_WINDOW_SIZE_INITIAL)) + return CURLMAX((uint32_t)data->progress.dl.rlimit.rate_per_step, 8192); +#endif + return H2_STREAM_WINDOW_SIZE_INITIAL; +} + +static size_t populate_settings(nghttp2_settings_entry *iv, + struct Curl_easy *data, + struct cf_h2_ctx *ctx) +{ + iv[0].settings_id = NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS; + iv[0].value = Curl_multi_max_concurrent_streams(data->multi); + + iv[1].settings_id = NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE; + iv[1].value = cf_h2_initial_win_size(data); + if(ctx) + ctx->initial_win_size = iv[1].value; + iv[2].settings_id = NGHTTP2_SETTINGS_ENABLE_PUSH; + iv[2].value = data->multi->push_cb != NULL; + + return 3; +} + +static ssize_t populate_binsettings(uint8_t *binsettings, + struct Curl_easy *data) +{ + nghttp2_settings_entry iv[H2_SETTINGS_IV_LEN]; + size_t ivlen; + + ivlen = populate_settings(iv, data, NULL); + /* this returns number of bytes it wrote or a negative number on error. */ + return nghttp2_pack_settings_payload(binsettings, H2_BINSETTINGS_LEN, + iv, ivlen); +} + +static CURLcode cf_h2_update_settings(struct cf_h2_ctx *ctx, + uint32_t initial_win_size) +{ + nghttp2_settings_entry entry; + entry.settings_id = NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE; + entry.value = initial_win_size; + if(nghttp2_submit_settings(ctx->h2, NGHTTP2_FLAG_NONE, &entry, 1)) + return CURLE_SEND_ERROR; + ctx->initial_win_size = initial_win_size; + return CURLE_OK; +} + static CURLcode nw_out_flush(struct Curl_cfilter *cf, struct Curl_easy *data); @@ -296,16 +324,18 @@ static void h2_stream_hash_free(unsigned int id, void *stream) static int32_t cf_h2_get_desired_local_win(struct Curl_cfilter *cf, struct Curl_easy *data) { + curl_off_t avail = Curl_rlimit_avail(&data->progress.dl.rlimit, + curlx_now()); + (void)cf; - if(data->set.max_recv_speed && data->set.max_recv_speed < INT32_MAX) { - /* The transfer should only receive `max_recv_speed` bytes per second. - * We restrict the stream's local window size, so that the server cannot - * send us "too much" at a time. - * This gets less precise the higher the latency. */ - return (int32_t)data->set.max_recv_speed; + if(avail < CURL_OFF_T_MAX) { /* limit in place */ + if(avail <= 0) + return 0; + else if(avail < INT32_MAX) + return (int32_t)avail; } #ifdef DEBUGBUILD - else { + { struct cf_h2_ctx *ctx = cf->ctx; CURL_TRC_CF(data, cf, "stream_win_max=%d", ctx->stream_win_max); return ctx->stream_win_max; @@ -580,7 +610,7 @@ static CURLcode cf_h2_ctx_open(struct Curl_cfilter *cf, nghttp2_settings_entry iv[H2_SETTINGS_IV_LEN]; size_t ivlen; - ivlen = populate_settings(iv, data); + ivlen = populate_settings(iv, data, ctx); rc = nghttp2_submit_settings(ctx->h2, NGHTTP2_FLAG_NONE, iv, ivlen); if(rc) { @@ -2007,6 +2037,9 @@ static CURLcode stream_recv(struct Curl_cfilter *cf, struct Curl_easy *data, (void)len; *pnread = 0; + if(!stream->xfer_result) + stream->xfer_result = cf_h2_update_local_win(cf, data, stream); + if(stream->xfer_result) { CURL_TRC_CF(data, cf, "[%d] xfer write failed", stream->id); result = stream->xfer_result; @@ -2239,6 +2272,7 @@ static CURLcode h2_submit(struct h2_stream_ctx **pstream, nghttp2_priority_spec pri_spec; size_t nwritten; CURLcode result = CURLE_OK; + uint32_t initial_win_size; *pnwritten = 0; Curl_dynhds_init(&h2_headers, 0, DYN_HTTP_REQUEST); @@ -2276,6 +2310,15 @@ static CURLcode h2_submit(struct h2_stream_ctx **pstream, if(!nghttp2_session_check_request_allowed(ctx->h2)) CURL_TRC_CF(data, cf, "send request NOT allowed (via nghttp2)"); + /* Check the initial windows size of the transfer (rate-limits?) and + * send an updated settings on changes from previous value. */ + initial_win_size = cf_h2_initial_win_size(data); + if(initial_win_size != ctx->initial_win_size) { + result = cf_h2_update_settings(ctx, initial_win_size); + if(result) + goto out; + } + switch(data->state.httpreq) { case HTTPREQ_POST: case HTTPREQ_POST_FORM: diff --git a/lib/imap.c b/lib/imap.c index faa595561dfa..181b0d7009d6 100644 --- a/lib/imap.c +++ b/lib/imap.c @@ -1938,10 +1938,7 @@ static CURLcode imap_regular_transfer(struct Curl_easy *data, data->req.size = -1; /* Set the progress data */ - Curl_pgrsSetUploadCounter(data, 0); - Curl_pgrsSetDownloadCounter(data, 0); - Curl_pgrsSetUploadSize(data, -1); - Curl_pgrsSetDownloadSize(data, -1); + Curl_pgrsReset(data); /* Carry out the perform */ result = imap_perform(data, &connected, dophase_done); diff --git a/lib/ldap.c b/lib/ldap.c index f0bc2f2a3790..fa1a4a4d25c5 100644 --- a/lib/ldap.c +++ b/lib/ldap.c @@ -509,7 +509,7 @@ static CURLcode ldap_do(struct Curl_easy *data, bool *done) goto quit; } - Curl_pgrsSetDownloadCounter(data, 0); + Curl_pgrsReset(data); rc = ldap_search_s(server, ludp->lud_dn, (curl_ldap_num_t)ludp->lud_scope, ludp->lud_filter, ludp->lud_attrs, 0, &ldapmsg); diff --git a/lib/multi.c b/lib/multi.c index 3fc1c948f507..5ea93348e4e5 100644 --- a/lib/multi.c +++ b/lib/multi.c @@ -43,7 +43,6 @@ #include "select.h" #include "curlx/warnless.h" #include "curlx/wait.h" -#include "speedcheck.h" #include "conncache.h" #include "multihandle.h" #include "sigpipe.h" @@ -923,79 +922,145 @@ void Curl_attach_connection(struct Curl_easy *data, conn->handler->attach(data, conn); } +/* adjust pollset for rate limits/pauses */ +static CURLcode multi_adjust_pollset(struct Curl_easy *data, + struct easy_pollset *ps) +{ + CURLcode result = CURLE_OK; + + if(ps->n) { + struct curltime now = curlx_now(); + bool send_blocked, recv_blocked; + + recv_blocked = (Curl_rlimit_avail(&data->progress.dl.rlimit, now) <= 0); + send_blocked = (Curl_rlimit_avail(&data->progress.ul.rlimit, now) <= 0); + if(send_blocked || recv_blocked) { + int i; + for(i = 0; i <= SECONDARYSOCKET; ++i) { + curl_socket_t sock = data->conn->sock[i]; + if(sock == CURL_SOCKET_BAD) + continue; + if(recv_blocked && Curl_pollset_want_recv(data, ps, sock)) { + result = Curl_pollset_remove_in(data, ps, sock); + if(result) + break; + } + if(send_blocked && Curl_pollset_want_send(data, ps, sock)) { + result = Curl_pollset_remove_out(data, ps, sock); + if(result) + break; + } + } + } + + /* Not blocked and wanting to receive. If there is data pending + * in the connection filters, make transfer run again. */ + if(!recv_blocked && + ((Curl_pollset_want_recv(data, ps, data->conn->sock[FIRSTSOCKET]) && + Curl_conn_data_pending(data, FIRSTSOCKET)) || + (Curl_pollset_want_recv(data, ps, data->conn->sock[SECONDARYSOCKET]) && + Curl_conn_data_pending(data, SECONDARYSOCKET)))) { + CURL_TRC_M(data, "pollset[] has POLLIN, but there is still " + "buffered input -> mark as dirty"); + Curl_multi_mark_dirty(data); + } + } + return result; +} + static CURLcode mstate_connecting_pollset(struct Curl_easy *data, struct easy_pollset *ps) { - if(data->conn) { - curl_socket_t sockfd = Curl_conn_get_first_socket(data); - if(sockfd != CURL_SOCKET_BAD) { - /* Default is to wait to something from the server */ - return Curl_pollset_change(data, ps, sockfd, CURL_POLL_IN, 0); - } + struct connectdata *conn = data->conn; + curl_socket_t sockfd; + CURLcode result = CURLE_OK; + + if(Curl_xfer_recv_is_paused(data)) + return CURLE_OK; + /* If a socket is set, receiving is default. If the socket + * has not been determined yet (eyeballing), always ask the + * connection filters for what to monitor. */ + sockfd = Curl_conn_get_first_socket(data); + if(sockfd != CURL_SOCKET_BAD) { + result = Curl_pollset_change(data, ps, sockfd, CURL_POLL_IN, 0); + if(!result) + result = multi_adjust_pollset(data, ps); } - return CURLE_OK; + if(!result) + result = Curl_conn_adjust_pollset(data, conn, ps); + return result; } static CURLcode mstate_protocol_pollset(struct Curl_easy *data, struct easy_pollset *ps) { struct connectdata *conn = data->conn; - if(conn) { - curl_socket_t sockfd; - if(conn->handler->proto_pollset) - return conn->handler->proto_pollset(data, ps); - sockfd = conn->sock[FIRSTSOCKET]; + CURLcode result = CURLE_OK; + + if(conn->handler->proto_pollset) + result = conn->handler->proto_pollset(data, ps); + else { + curl_socket_t sockfd = conn->sock[FIRSTSOCKET]; if(sockfd != CURL_SOCKET_BAD) { /* Default is to wait to something from the server */ - return Curl_pollset_change(data, ps, sockfd, CURL_POLL_IN, 0); + result = Curl_pollset_change(data, ps, sockfd, CURL_POLL_IN, 0); } } - return CURLE_OK; + if(!result) + result = multi_adjust_pollset(data, ps); + if(!result) + result = Curl_conn_adjust_pollset(data, conn, ps); + return result; } static CURLcode mstate_do_pollset(struct Curl_easy *data, struct easy_pollset *ps) { struct connectdata *conn = data->conn; - if(conn) { - if(conn->handler->doing_pollset) - return conn->handler->doing_pollset(data, ps); - else if(CONN_SOCK_IDX_VALID(conn->send_idx)) { - /* Default is that we want to send something to the server */ - return Curl_pollset_add_out( - data, ps, conn->sock[conn->send_idx]); - } + CURLcode result = CURLE_OK; + + if(conn->handler->doing_pollset) + result = conn->handler->doing_pollset(data, ps); + else if(CONN_SOCK_IDX_VALID(conn->send_idx)) { + /* Default is that we want to send something to the server */ + result = Curl_pollset_add_out(data, ps, conn->sock[conn->send_idx]); } - return CURLE_OK; + if(!result) + result = multi_adjust_pollset(data, ps); + if(!result) + result = Curl_conn_adjust_pollset(data, conn, ps); + return result; } static CURLcode mstate_domore_pollset(struct Curl_easy *data, struct easy_pollset *ps) { struct connectdata *conn = data->conn; - if(conn) { - if(conn->handler->domore_pollset) - return conn->handler->domore_pollset(data, ps); - else if(CONN_SOCK_IDX_VALID(conn->send_idx)) { - /* Default is that we want to send something to the server */ - return Curl_pollset_add_out( - data, ps, conn->sock[conn->send_idx]); - } + CURLcode result = CURLE_OK; + + if(conn->handler->domore_pollset) + result = conn->handler->domore_pollset(data, ps); + else if(CONN_SOCK_IDX_VALID(conn->send_idx)) { + /* Default is that we want to send something to the server */ + result = Curl_pollset_add_out(data, ps, conn->sock[conn->send_idx]); } - return CURLE_OK; + if(!result) + result = multi_adjust_pollset(data, ps); + if(!result) + result = Curl_conn_adjust_pollset(data, conn, ps); + return result; } static CURLcode mstate_perform_pollset(struct Curl_easy *data, struct easy_pollset *ps) { struct connectdata *conn = data->conn; - if(!conn) - return CURLE_OK; - else if(conn->handler->perform_pollset) - return conn->handler->perform_pollset(data, ps); + CURLcode result = CURLE_OK; + + if(conn->handler->perform_pollset) + result = conn->handler->perform_pollset(data, ps); else { /* Default is to obey the data->req.keepon flags for send/recv */ - CURLcode result = CURLE_OK; if(CURL_WANT_RECV(data) && CONN_SOCK_IDX_VALID(conn->recv_idx)) { result = Curl_pollset_add_in( data, ps, conn->sock[conn->recv_idx]); @@ -1006,19 +1071,21 @@ static CURLcode mstate_perform_pollset(struct Curl_easy *data, result = Curl_pollset_add_out( data, ps, conn->sock[conn->send_idx]); } - return result; } + if(!result) + result = multi_adjust_pollset(data, ps); + if(!result) + result = Curl_conn_adjust_pollset(data, conn, ps); + return result; } /* Initializes `poll_set` with the current socket poll actions needed * for transfer `data`. */ CURLMcode Curl_multi_pollset(struct Curl_easy *data, - struct easy_pollset *ps, - const char *caller) + struct easy_pollset *ps) { CURLMcode mresult = CURLM_OK; CURLcode result = CURLE_OK; - bool expect_sockets = TRUE; /* If the transfer has no connection, this is fine. Happens when called via curl_multi_remove_handle() => Curl_multi_ev_assess() => @@ -1033,70 +1100,49 @@ CURLMcode Curl_multi_pollset(struct Curl_easy *data, case MSTATE_SETUP: case MSTATE_CONNECT: /* nothing to poll for yet */ - expect_sockets = FALSE; break; case MSTATE_RESOLVING: result = Curl_resolv_pollset(data, ps); - /* connection filters are not involved in this phase. It is OK if we get no - * sockets to wait for. Resolving can wake up from other sources. */ - expect_sockets = FALSE; break; case MSTATE_CONNECTING: case MSTATE_TUNNELING: - if(!Curl_xfer_recv_is_paused(data)) { - result = mstate_connecting_pollset(data, ps); - if(!result) - result = Curl_conn_adjust_pollset(data, data->conn, ps); - } - else - expect_sockets = FALSE; + result = mstate_connecting_pollset(data, ps); break; case MSTATE_PROTOCONNECT: case MSTATE_PROTOCONNECTING: result = mstate_protocol_pollset(data, ps); - if(!result) - result = Curl_conn_adjust_pollset(data, data->conn, ps); break; case MSTATE_DO: case MSTATE_DOING: result = mstate_do_pollset(data, ps); - if(!result) - result = Curl_conn_adjust_pollset(data, data->conn, ps); break; case MSTATE_DOING_MORE: result = mstate_domore_pollset(data, ps); - if(!result) - result = Curl_conn_adjust_pollset(data, data->conn, ps); break; case MSTATE_DID: /* same as PERFORMING in regard to polling */ case MSTATE_PERFORMING: result = mstate_perform_pollset(data, ps); - if(!result) - result = Curl_conn_adjust_pollset(data, data->conn, ps); break; case MSTATE_RATELIMITING: /* we need to let time pass, ignore socket(s) */ - expect_sockets = FALSE; break; case MSTATE_DONE: case MSTATE_COMPLETED: case MSTATE_MSGSENT: /* nothing more to poll for */ - expect_sockets = FALSE; break; default: failf(data, "multi_getsock: unexpected multi state %d", data->mstate); DEBUGASSERT(0); - expect_sockets = FALSE; break; } @@ -1110,39 +1156,27 @@ CURLMcode Curl_multi_pollset(struct Curl_easy *data, goto out; } - /* Unblocked and waiting to receive with buffered input. - * Make transfer run again at next opportunity. */ - if(!Curl_xfer_is_blocked(data) && !Curl_xfer_is_too_fast(data) && - ((Curl_pollset_want_read(data, ps, data->conn->sock[FIRSTSOCKET]) && - Curl_conn_data_pending(data, FIRSTSOCKET)) || - (Curl_pollset_want_read(data, ps, data->conn->sock[SECONDARYSOCKET]) && - Curl_conn_data_pending(data, SECONDARYSOCKET)))) { - CURL_TRC_M(data, "%s pollset[] has POLLIN, but there is still " - "buffered input to consume -> mark as dirty", caller); - Curl_multi_mark_dirty(data); - } - #ifndef CURL_DISABLE_VERBOSE_STRINGS if(CURL_TRC_M_is_verbose(data)) { size_t timeout_count = Curl_llist_count(&data->state.timeoutlist); switch(ps->n) { case 0: - CURL_TRC_M(data, "%s pollset[], timeouts=%zu, paused %d/%d (r/w)", - caller, timeout_count, + CURL_TRC_M(data, "pollset[], timeouts=%zu, paused %d/%d (r/w)", + timeout_count, Curl_xfer_send_is_paused(data), Curl_xfer_recv_is_paused(data)); break; case 1: - CURL_TRC_M(data, "%s pollset[fd=%" FMT_SOCKET_T " %s%s], timeouts=%zu", - caller, ps->sockets[0], + CURL_TRC_M(data, "pollset[fd=%" FMT_SOCKET_T " %s%s], timeouts=%zu", + ps->sockets[0], (ps->actions[0] & CURL_POLL_IN) ? "IN" : "", (ps->actions[0] & CURL_POLL_OUT) ? "OUT" : "", timeout_count); break; case 2: - CURL_TRC_M(data, "%s pollset[fd=%" FMT_SOCKET_T " %s%s, " + CURL_TRC_M(data, "pollset[fd=%" FMT_SOCKET_T " %s%s, " "fd=%" FMT_SOCKET_T " %s%s], timeouts=%zu", - caller, ps->sockets[0], + ps->sockets[0], (ps->actions[0] & CURL_POLL_IN) ? "IN" : "", (ps->actions[0] & CURL_POLL_OUT) ? "OUT" : "", ps->sockets[1], @@ -1151,27 +1185,14 @@ CURLMcode Curl_multi_pollset(struct Curl_easy *data, timeout_count); break; default: - CURL_TRC_M(data, "%s pollset[fds=%u], timeouts=%zu", - caller, ps->n, timeout_count); + CURL_TRC_M(data, "pollset[fds=%u], timeouts=%zu", + ps->n, timeout_count); break; } CURL_TRC_EASY_TIMERS(data); } #endif - if(expect_sockets && !ps->n && data->multi && - !Curl_uint_bset_contains(&data->multi->dirty, data->mid) && - !Curl_llist_count(&data->state.timeoutlist) && - !Curl_cwriter_is_paused(data) && !Curl_creader_is_paused(data) && - Curl_conn_is_ip_connected(data, FIRSTSOCKET)) { - /* We expected sockets for POLL monitoring, but none are set. - * We are not dirty (and run anyway). - * We are not waiting on any timer. - * None of the READ/WRITE directions are paused. - * We are connected to the server on IP level, at least. */ - infof(data, "WARNING: no socket in pollset or timer, transfer may stall!"); - DEBUGASSERT(0); - } out: return mresult; } @@ -1205,7 +1226,7 @@ CURLMcode curl_multi_fdset(CURLM *m, continue; } - Curl_multi_pollset(data, &ps, "curl_multi_fdset"); + Curl_multi_pollset(data, &ps); for(i = 0; i < ps.n; i++) { if(!FDSET_SOCK(ps.sockets[i])) /* pretend it does not exist */ @@ -1268,7 +1289,7 @@ CURLMcode curl_multi_waitfds(CURLM *m, Curl_uint_bset_remove(&multi->dirty, mid); continue; } - Curl_multi_pollset(data, &ps, "curl_multi_waitfds"); + Curl_multi_pollset(data, &ps); need += Curl_waitfds_add_ps(&cwfds, &ps); } while(Curl_uint_bset_next(&multi->process, mid, &mid)); @@ -1354,7 +1375,7 @@ static CURLMcode multi_wait(struct Curl_multi *multi, Curl_uint_bset_remove(&multi->dirty, mid); continue; } - Curl_multi_pollset(data, &ps, "multi_wait"); + Curl_multi_pollset(data, &ps); if(Curl_pollfds_add_ps(&cpfds, &ps)) { result = CURLM_OUT_OF_MEMORY; goto out; @@ -1907,35 +1928,28 @@ static CURLcode multi_follow(struct Curl_easy *data, } static CURLcode mspeed_check(struct Curl_easy *data, - struct curltime *nowp) + struct curltime now) { timediff_t recv_wait_ms = 0; timediff_t send_wait_ms = 0; - /* check if over send speed */ - if(data->set.max_send_speed) - send_wait_ms = Curl_pgrsLimitWaitTime(&data->progress.ul, - data->set.max_send_speed, - *nowp); - - /* check if over recv speed */ - if(data->set.max_recv_speed) - recv_wait_ms = Curl_pgrsLimitWaitTime(&data->progress.dl, - data->set.max_recv_speed, - *nowp); + /* check if our send/recv limits require idle waits */ + send_wait_ms = Curl_rlimit_wait_ms(&data->progress.ul.rlimit, now); + recv_wait_ms = Curl_rlimit_wait_ms(&data->progress.dl.rlimit, now); if(send_wait_ms || recv_wait_ms) { if(data->mstate != MSTATE_RATELIMITING) { - Curl_ratelimit(data, *nowp); multistate(data, MSTATE_RATELIMITING); } Curl_expire(data, CURLMAX(send_wait_ms, recv_wait_ms), EXPIRE_TOOFAST); Curl_multi_clear_dirty(data); + CURL_TRC_M(data, "[RLIMIT] waiting %" FMT_TIMEDIFF_T "ms", + CURLMAX(send_wait_ms, recv_wait_ms)); return CURLE_AGAIN; } else if(data->mstate != MSTATE_PERFORMING) { + CURL_TRC_M(data, "[RLIMIT] wait over, continue"); multistate(data, MSTATE_PERFORMING); - Curl_ratelimit(data, *nowp); } return CURLE_OK; } @@ -1951,7 +1965,7 @@ static CURLMcode state_performing(struct Curl_easy *data, CURLcode result = *resultp = CURLE_OK; *stream_errorp = FALSE; - if(mspeed_check(data, nowp) == CURLE_AGAIN) + if(mspeed_check(data, *nowp) == CURLE_AGAIN) return CURLM_OK; /* read/write data if it is ready to do so */ @@ -2073,7 +2087,8 @@ static CURLMcode state_performing(struct Curl_easy *data, } } else { /* not errored, not done */ - mspeed_check(data, nowp); + *nowp = curlx_now(); + mspeed_check(data, *nowp); } free(newurl); *resultp = result; @@ -2228,10 +2243,7 @@ static CURLMcode state_ratelimiting(struct Curl_easy *data, CURLMcode rc = CURLM_OK; DEBUGASSERT(data->conn); /* if both rates are within spec, resume transfer */ - if(Curl_pgrsUpdate(data)) - result = CURLE_ABORTED_BY_CALLBACK; - else - result = Curl_speedcheck(data, *nowp); + result = Curl_pgrsCheck(data); if(result) { if(!(data->conn->handler->flags & PROTOPT_DUAL) && @@ -2242,7 +2254,7 @@ static CURLMcode state_ratelimiting(struct Curl_easy *data, multi_done(data, result, TRUE); } else { - if(!mspeed_check(data, nowp)) + if(!mspeed_check(data, *nowp)) rc = CURLM_CALL_MULTI_PERFORM; } *resultp = result; @@ -2387,6 +2399,8 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi, (HTTP/2), or the full connection for older protocols */ bool stream_error = FALSE; rc = CURLM_OK; + /* update at start for continuous increase when looping */ + *nowp = curlx_now(); if(multi_ischanged(multi, TRUE)) { CURL_TRC_M(data, "multi changed, check CONNECT_PEND queue"); @@ -2704,16 +2718,18 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi, rc = CURLM_CALL_MULTI_PERFORM; } /* if there is still a connection to use, call the progress function */ - else if(data->conn && Curl_pgrsUpdate(data)) { - /* aborted due to progress callback return code must close the - connection */ - result = CURLE_ABORTED_BY_CALLBACK; - streamclose(data->conn, "Aborted by callback"); - - /* if not yet in DONE state, go there, otherwise COMPLETED */ - multistate(data, (data->mstate < MSTATE_DONE) ? - MSTATE_DONE : MSTATE_COMPLETED); - rc = CURLM_CALL_MULTI_PERFORM; + else if(data->conn) { + result = Curl_pgrsUpdate(data); + if(result) { + /* aborted due to progress callback return code must close the + connection */ + streamclose(data->conn, "Aborted by callback"); + + /* if not yet in DONE state, go there, otherwise COMPLETED */ + multistate(data, (data->mstate < MSTATE_DONE) ? + MSTATE_DONE : MSTATE_COMPLETED); + rc = CURLM_CALL_MULTI_PERFORM; + } } } diff --git a/lib/multi_ev.c b/lib/multi_ev.c index f5000a456245..098f8da643af 100644 --- a/lib/multi_ev.c +++ b/lib/multi_ev.c @@ -508,7 +508,7 @@ static CURLMcode mev_assess(struct Curl_multi *multi, } } else - Curl_multi_pollset(data, &ps, "ev assess"); + Curl_multi_pollset(data, &ps); last_ps = mev_get_last_pollset(data, conn); if(!last_ps && ps.n) { diff --git a/lib/multiif.h b/lib/multiif.h index 1423d5a03d0c..81cf665bd3d8 100644 --- a/lib/multiif.h +++ b/lib/multiif.h @@ -73,8 +73,7 @@ CURLMcode Curl_multi_add_perform(struct Curl_multi *multi, unsigned int Curl_multi_max_concurrent_streams(struct Curl_multi *multi); CURLMcode Curl_multi_pollset(struct Curl_easy *data, - struct easy_pollset *ps, - const char *caller); + struct easy_pollset *ps); /** * Borrow the transfer buffer from the multi, suitable diff --git a/lib/pingpong.c b/lib/pingpong.c index 670d37c38e62..297389043f0e 100644 --- a/lib/pingpong.c +++ b/lib/pingpong.c @@ -33,7 +33,6 @@ #include "sendf.h" #include "select.h" #include "progress.h" -#include "speedcheck.h" #include "pingpong.h" #include "multiif.h" #include "vtls/vtls.h" @@ -122,11 +121,7 @@ CURLcode Curl_pp_statemach(struct Curl_easy *data, if(block) { /* if we did not wait, we do not have to spend time on this now */ - if(Curl_pgrsUpdate(data)) - result = CURLE_ABORTED_BY_CALLBACK; - else - result = Curl_speedcheck(data, curlx_now()); - + result = Curl_pgrsCheck(data); if(result) return result; } diff --git a/lib/pop3.c b/lib/pop3.c index d469dc07660d..05203c1a074e 100644 --- a/lib/pop3.c +++ b/lib/pop3.c @@ -1503,10 +1503,7 @@ static CURLcode pop3_regular_transfer(struct Curl_easy *data, data->req.size = -1; /* Set the progress data */ - Curl_pgrsSetUploadCounter(data, 0); - Curl_pgrsSetDownloadCounter(data, 0); - Curl_pgrsSetUploadSize(data, -1); - Curl_pgrsSetDownloadSize(data, -1); + Curl_pgrsReset(data); /* Carry out the perform */ result = pop3_perform(data, &connected, dophase_done); diff --git a/lib/progress.c b/lib/progress.c index 228f5dc19737..3985e1c1bfbd 100644 --- a/lib/progress.c +++ b/lib/progress.c @@ -28,6 +28,7 @@ #include "sendf.h" #include "multiif.h" #include "progress.h" +#include "transfer.h" #include "curlx/timeval.h" /* check rate limits within this many recent milliseconds, at minimum. */ @@ -92,6 +93,55 @@ static char *max6data(curl_off_t bytes, char *max6) } #endif +static void pgrs_speedinit(struct Curl_easy *data) +{ + memset(&data->state.keeps_speed, 0, sizeof(struct curltime)); +} + +/* + * @unittest: 1606 + */ +UNITTEST CURLcode pgrs_speedcheck(struct Curl_easy *data, + struct curltime *pnow) +{ + if(!data->set.low_speed_time || !data->set.low_speed_limit || + Curl_xfer_recv_is_paused(data) || Curl_xfer_send_is_paused(data)) + /* A paused transfer is not qualified for speed checks */ + return CURLE_OK; + + if((data->progress.current_speed >= 0) && data->set.low_speed_time) { + if(data->progress.current_speed < data->set.low_speed_limit) { + if(!data->state.keeps_speed.tv_sec) + /* under the limit at this moment */ + data->state.keeps_speed = *pnow; + else { + /* how long has it been under the limit */ + timediff_t howlong = curlx_timediff_ms(*pnow, data->state.keeps_speed); + + if(howlong >= data->set.low_speed_time * 1000) { + /* too long */ + failf(data, + "Operation too slow. " + "Less than %ld bytes/sec transferred the last %ld seconds", + data->set.low_speed_limit, + data->set.low_speed_time); + return CURLE_OPERATION_TIMEDOUT; + } + } + } + else + /* faster right now */ + data->state.keeps_speed.tv_sec = 0; + } + + if(data->set.low_speed_limit) + /* if low speed limit is enabled, set the expire timer to make this + connection's speed get checked again in a second */ + Curl_expire(data, 1000, EXPIRE_SPEEDCHECK); + + return CURLE_OK; +} + /* New proposed interface, 9th of February 2000: @@ -119,10 +169,19 @@ int Curl_pgrsDone(struct Curl_easy *data) * hidden */ curl_mfprintf(data->set.err, "\n"); - data->progress.speeder_c = 0; /* reset the progress meter display */ return 0; } +void Curl_pgrsReset(struct Curl_easy *data) +{ + Curl_pgrsSetUploadCounter(data, 0); + Curl_pgrsSetDownloadCounter(data, 0); + Curl_pgrsSetUploadSize(data, -1); + Curl_pgrsSetDownloadSize(data, -1); + data->progress.speeder_c = 0; /* reset speed records */ + pgrs_speedinit(data); +} + /* reset the known transfer sizes */ void Curl_pgrsResetTransferSizes(struct Curl_easy *data) { @@ -130,6 +189,14 @@ void Curl_pgrsResetTransferSizes(struct Curl_easy *data) Curl_pgrsSetUploadSize(data, -1); } +void Curl_pgrsRecvPause(struct Curl_easy *data, bool enable) +{ + if(!enable) { + data->progress.speeder_c = 0; /* reset speed records */ + pgrs_speedinit(data); /* reset low speed measurements */ + } +} + /* * * Curl_pgrsTimeWas(). Store the timestamp time at the given label. @@ -228,72 +295,11 @@ void Curl_pgrsStartNow(struct Curl_easy *data) p->speeder_c = 0; /* reset the progress meter display */ p->start = curlx_now(); p->is_t_startransfer_set = FALSE; - p->ul.limit.start = p->start; - p->dl.limit.start = p->start; - p->ul.limit.start_size = 0; - p->dl.limit.start_size = 0; p->dl.cur_size = 0; p->ul.cur_size = 0; /* the sizes are unknown at start */ p->dl_size_known = FALSE; p->ul_size_known = FALSE; - Curl_ratelimit(data, p->start); -} - -/* - * This is used to handle speed limits, calculating how many milliseconds to - * wait until we are back under the speed limit, if needed. - * - * The way it works is by having a "starting point" (time & amount of data - * transferred by then) used in the speed computation, to be used instead of - * the start of the transfer. This starting point is regularly moved as - * transfer goes on, to keep getting accurate values (instead of average over - * the entire transfer). - * - * This function takes the current amount of data transferred, the amount at - * the starting point, the limit (in bytes/s), the time of the starting point - * and the current time. - * - * Returns 0 if no waiting is needed or when no waiting is needed but the - * starting point should be reset (to current); or the number of milliseconds - * to wait to get back under the speed limit. - */ -timediff_t Curl_pgrsLimitWaitTime(struct pgrs_dir *d, - curl_off_t bytes_per_sec, - struct curltime now) -{ - curl_off_t bytes = d->cur_size - d->limit.start_size; - timediff_t should_ms; - timediff_t took_ms; - - /* no limit or we did not get to any bytes yet */ - if(!bytes_per_sec || !bytes) - return 0; - - /* The time it took us to have `bytes` */ - took_ms = curlx_timediff_ceil_ms(now, d->limit.start); - - /* The time it *should* have taken us to have `bytes` - * when obeying the bytes_per_sec speed_limit. */ - if(bytes < CURL_OFF_T_MAX/1000) { - /* (1000 * bytes / (bytes / sec)) = 1000 * sec = ms */ - should_ms = (timediff_t) (1000 * bytes / bytes_per_sec); - } - else { - /* large `bytes`, first calc the seconds it should have taken. - * if that is small enough, convert to milliseconds. */ - should_ms = (timediff_t) (bytes / bytes_per_sec); - if(should_ms < TIMEDIFF_T_MAX/1000) - should_ms *= 1000; - else - should_ms = TIMEDIFF_T_MAX; - } - - if(took_ms < should_ms) { - /* when gotten to `bytes` too fast, wait the difference */ - return should_ms - took_ms; - } - return 0; } /* @@ -304,28 +310,6 @@ void Curl_pgrsSetDownloadCounter(struct Curl_easy *data, curl_off_t size) data->progress.dl.cur_size = size; } -/* - * Update the timestamp and sizestamp to use for rate limit calculations. - */ -void Curl_ratelimit(struct Curl_easy *data, struct curltime now) -{ - /* do not set a new stamp unless the time since last update is long enough */ - if(data->set.max_recv_speed) { - if(curlx_timediff_ms(now, data->progress.dl.limit.start) >= - MIN_RATE_LIMIT_PERIOD) { - data->progress.dl.limit.start = now; - data->progress.dl.limit.start_size = data->progress.dl.cur_size; - } - } - if(data->set.max_send_speed) { - if(curlx_timediff_ms(now, data->progress.ul.limit.start) >= - MIN_RATE_LIMIT_PERIOD) { - data->progress.ul.limit.start = now; - data->progress.ul.limit.start_size = data->progress.ul.cur_size; - } - } -} - /* * Set the number of uploaded bytes so far. */ @@ -378,75 +362,82 @@ static curl_off_t trspeed(curl_off_t size, /* number of bytes */ } /* returns TRUE if it is time to show the progress meter */ -static bool progress_calc(struct Curl_easy *data, struct curltime now) +static bool progress_calc(struct Curl_easy *data, struct curltime *pnow) { - bool timetoshow = FALSE; struct Progress * const p = &data->progress; + int i_next, i_oldest, i_latest; + timediff_t duration_ms; + curl_off_t amount; /* The time spent so far (from the start) in microseconds */ - p->timespent = curlx_timediff_us(now, p->start); + p->timespent = curlx_timediff_us(*pnow, p->start); p->dl.speed = trspeed(p->dl.cur_size, p->timespent); p->ul.speed = trspeed(p->ul.cur_size, p->timespent); - /* Calculations done at most once a second, unless end is reached */ - if(p->lastshow != now.tv_sec) { - int countindex; /* amount of seconds stored in the speeder array */ - int nowindex = p->speeder_c% CURR_TIME; - p->lastshow = now.tv_sec; - timetoshow = TRUE; - - /* Let's do the "current speed" thing, with the dl + ul speeds - combined. Store the speed at entry 'nowindex'. */ - p->speeder[ nowindex ] = p->dl.cur_size + p->ul.cur_size; - - /* remember the exact time for this moment */ - p->speeder_time [ nowindex ] = now; - - /* advance our speeder_c counter, which is increased every time we get - here and we expect it to never wrap as 2^32 is a lot of seconds! */ + if(!p->speeder_c) { /* no previous record exists */ + p->speed_amount[0] = p->dl.cur_size + p->ul.cur_size; + p->speed_time[0] = *pnow; p->speeder_c++; - - /* figure out how many index entries of data we have stored in our speeder - array. With N_ENTRIES filled in, we have about N_ENTRIES-1 seconds of - transfer. Imagine, after one second we have filled in two entries, - after two seconds we have filled in three entries etc. */ - countindex = ((p->speeder_c >= CURR_TIME) ? CURR_TIME : p->speeder_c) - 1; - - /* first of all, we do not do this if there is no counted seconds yet */ - if(countindex) { - int checkindex; - timediff_t span_ms; - curl_off_t amount; - - /* Get the index position to compare with the 'nowindex' position. - Get the oldest entry possible. While we have less than CURR_TIME - entries, the first entry will remain the oldest. */ - checkindex = (p->speeder_c >= CURR_TIME) ? p->speeder_c%CURR_TIME : 0; - - /* Figure out the exact time for the time span */ - span_ms = curlx_timediff_ms(now, p->speeder_time[checkindex]); - if(span_ms == 0) - span_ms = 1; /* at least one millisecond MUST have passed */ - - /* Calculate the average speed the last 'span_ms' milliseconds */ - amount = p->speeder[nowindex]- p->speeder[checkindex]; - - if(amount > (0xffffffff/1000)) - /* the 'amount' value is bigger than would fit in 32 bits if - multiplied with 1000, so we use the double math for this */ - p->current_speed = (curl_off_t) - ((double)amount/((double)span_ms/1000.0)); - else - /* the 'amount' value is small enough to fit within 32 bits even - when multiplied with 1000 */ - p->current_speed = amount * 1000/span_ms; + /* use the overall average at the start */ + p->current_speed = p->ul.speed + p->dl.speed; + p->lastshow = pnow->tv_sec; + return TRUE; + } + /* We have at least one record now. Where to put the next and + * where is the latest one? */ + i_next = p->speeder_c % CURL_SPEED_RECORDS; + i_latest = (i_next > 0) ? (i_next - 1) : (CURL_SPEED_RECORDS - 1); + + /* Make a new record only when some time has passed. + * Too frequent calls otherwise ruin the history. */ + if(curlx_timediff_ms(*pnow, p->speed_time[i_latest]) >= 1000) { + p->speeder_c++; + i_latest = i_next; + p->speed_amount[i_latest] = p->dl.cur_size + p->ul.cur_size; + p->speed_time[i_latest] = *pnow; + } + else if(data->req.done) { + /* When a transfer is done, and we did not have a current speed + * already, update the last record. Otherwise, stay at the speed + * we have. The last chunk of data, when rate limiting, would increase + * reported speed since it no longer measures a full second. */ + if(!p->current_speed) { + p->speed_amount[i_latest] = p->dl.cur_size + p->ul.cur_size; + p->speed_time[i_latest] = *pnow; } - else - /* the first second we use the average */ - p->current_speed = p->ul.speed + p->dl.speed; + } + else { + /* transfer ongoing, wait for more time to pass. */ + return FALSE; + } - } /* Calculations end */ - return timetoshow; + i_oldest = (p->speeder_c < CURL_SPEED_RECORDS) ? 0 : + ((i_latest + 1) % CURL_SPEED_RECORDS); + + /* How much we transferred between oldest and current records */ + amount = p->speed_amount[i_latest]- p->speed_amount[i_oldest]; + /* How long this took */ + duration_ms = curlx_timediff_ms(p->speed_time[i_latest], + p->speed_time[i_oldest]); + if(duration_ms <= 0) + duration_ms = 1; + + if(amount > (CURL_OFF_T_MAX/1000)) { + /* the 'amount' value is bigger than would fit in 64 bits if + multiplied with 1000, so we use the double math for this */ + p->current_speed = (curl_off_t) + (((double)amount * 1000.0)/(double)duration_ms); + } + else { + /* the 'amount' value is small enough to fit within 32 bits even + when multiplied with 1000 */ + p->current_speed = amount * 1000 / duration_ms; + } + + if((p->lastshow == pnow->tv_sec) && !data->req.done) + return FALSE; + p->lastshow = pnow->tv_sec; + return TRUE; } #ifndef CURL_DISABLE_PROGRESS_METER @@ -568,7 +559,7 @@ static void progress_meter(struct Curl_easy *data) * Curl_pgrsUpdate() returns 0 for success or the value returned by the * progress callback! */ -static int pgrsupdate(struct Curl_easy *data, bool showprogress) +static CURLcode pgrsupdate(struct Curl_easy *data, bool showprogress) { if(!data->progress.hide) { if(data->set.fxferinfo) { @@ -582,9 +573,11 @@ static int pgrsupdate(struct Curl_easy *data, bool showprogress) data->progress.ul.cur_size); Curl_set_in_callback(data, FALSE); if(result != CURL_PROGRESSFUNC_CONTINUE) { - if(result) + if(result) { failf(data, "Callback aborted"); - return result; + return CURLE_ABORTED_BY_CALLBACK; + } + return CURLE_OK; } } else if(data->set.fprogress) { @@ -598,9 +591,11 @@ static int pgrsupdate(struct Curl_easy *data, bool showprogress) (double)data->progress.ul.cur_size); Curl_set_in_callback(data, FALSE); if(result != CURL_PROGRESSFUNC_CONTINUE) { - if(result) + if(result) { failf(data, "Callback aborted"); - return result; + return CURLE_ABORTED_BY_CALLBACK; + } + return CURLE_OK; } } @@ -608,21 +603,37 @@ static int pgrsupdate(struct Curl_easy *data, bool showprogress) progress_meter(data); } - return 0; + return CURLE_OK; } -int Curl_pgrsUpdate(struct Curl_easy *data) +static CURLcode pgrs_update(struct Curl_easy *data, struct curltime *pnow) { - struct curltime now = curlx_now(); /* what time is it */ - bool showprogress = progress_calc(data, now); + bool showprogress = progress_calc(data, pnow); return pgrsupdate(data, showprogress); } +CURLcode Curl_pgrsUpdate(struct Curl_easy *data) +{ + struct curltime now = curlx_now(); /* what time is it */ + return pgrs_update(data, &now); +} + +CURLcode Curl_pgrsCheck(struct Curl_easy *data) +{ + struct curltime now = curlx_now(); + CURLcode result; + + result = pgrs_update(data, &now); + if(!result && !data->req.done) + result = pgrs_speedcheck(data, &now); + return result; +} + /* * Update all progress, do not do progress meter/callbacks. */ void Curl_pgrsUpdate_nometer(struct Curl_easy *data) { struct curltime now = curlx_now(); /* what time is it */ - (void)progress_calc(data, now); + (void)progress_calc(data, &now); } diff --git a/lib/progress.h b/lib/progress.h index 7a176b7554ac..96a26fe1a4d9 100644 --- a/lib/progress.h +++ b/lib/progress.h @@ -26,6 +26,7 @@ #include "curlx/timeval.h" +struct Curl_easy; typedef enum { TIMER_NONE, @@ -50,15 +51,23 @@ void Curl_pgrsSetUploadSize(struct Curl_easy *data, curl_off_t size); void Curl_pgrsSetDownloadCounter(struct Curl_easy *data, curl_off_t size); 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 Curl_easy *data); + +/* perform progress update, invoking callbacks at intervals */ +CURLcode Curl_pgrsUpdate(struct Curl_easy *data); +/* perform progress update, no callbacks invoked */ void Curl_pgrsUpdate_nometer(struct Curl_easy *data); +/* perform progress update with callbacks and speed checks */ +CURLcode Curl_pgrsCheck(struct Curl_easy *data); + +/* Inform progress/speedcheck about receive pausing */ +void Curl_pgrsRecvPause(struct Curl_easy *data, bool enable); +/* Reset sizes and couners for up- and download. */ +void Curl_pgrsReset(struct Curl_easy *data); +/* Reset sizes for up- and download. */ void Curl_pgrsResetTransferSizes(struct Curl_easy *data); + struct curltime Curl_pgrsTime(struct Curl_easy *data, timerid timer); -timediff_t Curl_pgrsLimitWaitTime(struct pgrs_dir *d, - curl_off_t speed_limit, - struct curltime now); /** * Update progress timer with the elapsed time from its start to `timestamp`. * This allows updating timers later and is used by happy eyeballing, where @@ -69,4 +78,9 @@ void Curl_pgrsTimeWas(struct Curl_easy *data, timerid timer, void Curl_pgrsEarlyData(struct Curl_easy *data, curl_off_t sent); +#ifdef UNITTESTS +UNITTEST CURLcode pgrs_speedcheck(struct Curl_easy *data, + struct curltime *pnow); +#endif + #endif /* HEADER_CURL_PROGRESS_H */ diff --git a/lib/ratelimit.c b/lib/ratelimit.c new file mode 100644 index 000000000000..8b34d77e1313 --- /dev/null +++ b/lib/ratelimit.c @@ -0,0 +1,200 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) Daniel Stenberg, , et al. + * + * This software is licensed as described in the 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. + * + * SPDX-License-Identifier: curl + * + ***************************************************************************/ + +#include "curl_setup.h" + +#include "curlx/timeval.h" +#include "ratelimit.h" + + +#define CURL_US_PER_SEC 1000000 +#define CURL_RLIMIT_MIN_CHUNK (16 * 1024) +#define CURL_RLIMIT_MAX_STEPS 2 /* 500ms interval */ + +void Curl_rlimit_init(struct Curl_rlimit *r, + curl_off_t rate_per_s, + curl_off_t burst_per_s, + struct curltime ts) +{ + curl_off_t rate_steps; + + DEBUGASSERT(rate_per_s >= 0); + DEBUGASSERT(burst_per_s >= rate_per_s || !burst_per_s); + r->step_us = CURL_US_PER_SEC; + r->rate_per_step = rate_per_s; + r->burst_per_step = burst_per_s; + /* On rates that are multiples of CURL_RLIMIT_MIN_CHUNK, we reduce + * the interval `step_us` from 1 second to smaller steps with at + * most CURL_RLIMIT_MAX_STEPS. + * Smaller means more CPU, but also more precision. */ + rate_steps = rate_per_s / CURL_RLIMIT_MIN_CHUNK; + rate_steps = CURLMIN(rate_steps, CURL_RLIMIT_MAX_STEPS); + if(rate_steps >= 2) { + r->step_us /= rate_steps; + r->rate_per_step /= rate_steps; + r->burst_per_step /= rate_steps; + } + r->tokens = r->rate_per_step; + r->spare_us = 0; + r->ts = ts; + r->blocked = FALSE; +} + +void Curl_rlimit_start(struct Curl_rlimit *r, struct curltime ts) +{ + r->tokens = r->rate_per_step; + r->spare_us = 0; + r->ts = ts; +} + +bool Curl_rlimit_active(struct Curl_rlimit *r) +{ + return (r->rate_per_step > 0) || r->blocked; +} + +bool Curl_rlimit_is_blocked(struct Curl_rlimit *r) +{ + return r->blocked; +} + +static void ratelimit_update(struct Curl_rlimit *r, + struct curltime ts) +{ + timediff_t elapsed_us, elapsed_steps; + curl_off_t token_gain; + + DEBUGASSERT(r->rate_per_step); + if((r->ts.tv_sec == ts.tv_sec) && (r->ts.tv_usec == ts.tv_usec)) + return; + + elapsed_us = curlx_timediff_us(ts, r->ts); + if(elapsed_us < 0) { /* not going back in time */ + curl_mfprintf(stderr, "rlimit: neg elapsed time %" FMT_TIMEDIFF_T "us\n", + elapsed_us); + DEBUGASSERT(0); + return; + } + + elapsed_us += r->spare_us; + if(elapsed_us < r->step_us) + return; + + /* we do the update */ + r->ts = ts; + elapsed_steps = elapsed_us / r->step_us; + r->spare_us = elapsed_us % r->step_us; + + /* How many tokens did we gain since the last update? */ + if(r->rate_per_step > (CURL_OFF_T_MAX / elapsed_steps)) + token_gain = CURL_OFF_T_MAX; + else { + token_gain = r->rate_per_step * elapsed_steps; + } + + /* Limit the token again by the burst rate per second (if set), so we + * do not suddenly have a huge number of tokens after inactivity. */ + r->tokens += token_gain; + if(r->burst_per_step && (r->tokens > r->burst_per_step)) { + r->tokens = r->burst_per_step; + } +} + +curl_off_t Curl_rlimit_avail(struct Curl_rlimit *r, + struct curltime ts) +{ + if(r->blocked) + return 0; + else if(r->rate_per_step) { + ratelimit_update(r, ts); + return r->tokens; + } + else + return CURL_OFF_T_MAX; +} + +void Curl_rlimit_drain(struct Curl_rlimit *r, + size_t tokens, + struct curltime ts) +{ + if(r->blocked || !r->rate_per_step) + return; + + ratelimit_update(r, ts); +#if SIZEOF_CURL_OFF_T <= SIZEOF_SIZE_T + if(tokens > CURL_OFF_T_MAX) { + r->tokens = CURL_OFF_T_MIN; + return; + } + else +#endif + { + curl_off_t val = (curl_off_t)tokens; + if((CURL_OFF_T_MIN + val) < r->tokens) + r->tokens -= val; + else + r->tokens = CURL_OFF_T_MIN; + } +} + +timediff_t Curl_rlimit_wait_ms(struct Curl_rlimit *r, + struct curltime ts) +{ + timediff_t wait_us, elapsed_us; + + if(r->blocked || !r->rate_per_step) + return 0; + ratelimit_update(r, ts); + if(r->tokens > 0) + return 0; + + /* How much time will it take tokens to become positive again? + * Deduct `spare_us` and check against already elapsed time */ + wait_us = (1 + (-r->tokens / r->rate_per_step)) * r->step_us; + wait_us -= r->spare_us; + + elapsed_us = curlx_timediff_us(ts, r->ts); + if(elapsed_us >= wait_us) + return 0; + wait_us -= elapsed_us; + return (wait_us + 999) / 1000; /* in milliseconds */ +} + +void Curl_rlimit_block(struct Curl_rlimit *r, + bool activate, + struct curltime ts) +{ + if(!activate == !r->blocked) + return; + + r->ts = ts; + r->blocked = activate; + if(!r->blocked) { + /* Start rate limiting fresh. The amount of time this was blocked + * does not generate extra tokens. */ + Curl_rlimit_start(r, ts); + } + else { + r->tokens = 0; + } +} diff --git a/lib/ratelimit.h b/lib/ratelimit.h new file mode 100644 index 000000000000..53f803039145 --- /dev/null +++ b/lib/ratelimit.h @@ -0,0 +1,92 @@ +#ifndef HEADER_Curl_rlimit_H +#define HEADER_Curl_rlimit_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) Daniel Stenberg, , et al. + * + * This software is licensed as described in the 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. + * + * SPDX-License-Identifier: curl + * + ***************************************************************************/ + +#include "curlx/timeval.h" + +/* This is a rate limiter that provides "tokens" to be consumed + * per second with a "burst" rate limitation. Example: + * A rate limit of 1 megabyte per second with a burst rate of 1.5MB. + * - initially 1 million tokens are available. + * - these are drained in the first second. + * - checking available tokens before the 2nd second will return 0. + * - at/after the 2nd second, 1 million tokens are available again. + * - nothing happens for a second, the 1 million tokens would grow + * to 2 million, however the burst limit caps those at 1.5 million. + * Thus: + * - setting "burst" to CURL_OFF_T_MAX would average tokens over the + * complete lifetime. E.g. for a download, at the *end* of it, the + * average rate from start to finish would be the rate limit. + * - setting "burst" to the same value as "rate" would make a + * download always try to stay *at/below* the rate and slow times will + * not generate extra tokens. + * A rate limit can be blocked, causing the available tokens to become + * always 0 until unblocked. After unblocking, the rate limiting starts + * again with no history of the past. + * Finally, a rate limiter with rate 0 will always have CURL_OFF_T_MAX + * tokens available, unless blocked. + */ + +struct Curl_rlimit { + curl_off_t rate_per_step; /* rate tokens are generated per step us */ + curl_off_t burst_per_step; /* burst rate of tokens per step us */ + timediff_t step_us; /* microseconds between token increases */ + curl_off_t tokens; /* tokens available in the next second */ + timediff_t spare_us; /* microseconds unaffecting tokens */ + struct curltime ts; /* time of the last update */ + BIT(blocked); /* blocking sets available tokens to 0 */ +}; + +void Curl_rlimit_init(struct Curl_rlimit *r, + curl_off_t rate_per_s, + curl_off_t burst_per_s, + struct curltime ts); + +/* Start ratelimiting with the given timestamp. Resets available tokens. */ +void Curl_rlimit_start(struct Curl_rlimit *r, struct curltime ts); + +/* How many milliseconds to wait until token are available again. */ +timediff_t Curl_rlimit_wait_ms(struct Curl_rlimit *r, + struct curltime ts); + +/* Return if rate limiting of tokens is active */ +bool Curl_rlimit_active(struct Curl_rlimit *r); +bool Curl_rlimit_is_blocked(struct Curl_rlimit *r); + +/* Return how many tokens are available to spend, may be negative */ +curl_off_t Curl_rlimit_avail(struct Curl_rlimit *r, + struct curltime ts); + +/* Drain tokens from the ratelimit, return how many are now available. */ +void Curl_rlimit_drain(struct Curl_rlimit *r, + size_t tokens, + struct curltime ts); + +/* Block/unblock ratelimiting. A blocked ratelimit has 0 tokens available. */ +void Curl_rlimit_block(struct Curl_rlimit *r, + bool activate, + struct curltime ts); + +#endif /* HEADER_Curl_rlimit_H */ diff --git a/lib/request.c b/lib/request.c index 9778a0c95372..5bfcdfbfb8c7 100644 --- a/lib/request.c +++ b/lib/request.c @@ -258,7 +258,7 @@ static CURLcode req_set_upload_done(struct Curl_easy *data) { DEBUGASSERT(!data->req.upload_done); data->req.upload_done = TRUE; - data->req.keepon &= ~(KEEP_SEND|KEEP_SEND_TIMED); /* we are done sending */ + data->req.keepon &= ~KEEP_SEND; /* we are done sending */ Curl_pgrsTime(data, TIMER_POSTRANSFER); Curl_creader_done(data, data->req.upload_aborted); @@ -420,9 +420,9 @@ bool Curl_req_want_send(struct Curl_easy *data) * - or request has buffered data to send * - or transfer connection has pending data to send */ return !data->req.done && - (((data->req.keepon & KEEP_SENDBITS) == KEEP_SEND) || - !Curl_req_sendbuf_empty(data) || - Curl_xfer_needs_flush(data)); + ((data->req.keepon & KEEP_SEND) || + !Curl_req_sendbuf_empty(data) || + Curl_xfer_needs_flush(data)); } bool Curl_req_done_sending(struct Curl_easy *data) @@ -458,8 +458,7 @@ CURLcode Curl_req_abort_sending(struct Curl_easy *data) if(!data->req.upload_done) { Curl_bufq_reset(&data->req.sendbuf); data->req.upload_aborted = TRUE; - /* no longer KEEP_SEND and KEEP_SEND_PAUSE */ - data->req.keepon &= ~KEEP_SENDBITS; + data->req.keepon &= ~KEEP_SEND; return req_set_upload_done(data); } return CURLE_OK; @@ -470,6 +469,6 @@ CURLcode Curl_req_stop_send_recv(struct Curl_easy *data) /* stop receiving and ALL sending as well, including PAUSE and HOLD. * We might still be paused on receive client writes though, so * keep those bits around. */ - data->req.keepon &= ~(KEEP_RECV|KEEP_SENDBITS); + data->req.keepon &= ~(KEEP_RECV|KEEP_SEND); return Curl_req_abort_sending(data); } diff --git a/lib/request.h b/lib/request.h index e12d5efdcb23..0f9e0a6ff4fc 100644 --- a/lib/request.h +++ b/lib/request.h @@ -130,6 +130,7 @@ struct SingleRequest { BIT(sendbuf_init); /* sendbuf is initialized */ BIT(shutdown); /* request end will shutdown connection */ BIT(shutdown_err_ignore); /* errors in shutdown will not fail request */ + BIT(reader_started); /* client reads have started */ }; /** diff --git a/lib/rtsp.c b/lib/rtsp.c index 95215b8d4bfa..b4b3d6dd556d 100644 --- a/lib/rtsp.c +++ b/lib/rtsp.c @@ -142,7 +142,7 @@ const struct Curl_handler Curl_handler_rtsp = { ZERO_NULL, /* proto_pollset */ rtsp_do_pollset, /* doing_pollset */ ZERO_NULL, /* domore_pollset */ - ZERO_NULL, /* perform_pollset */ + Curl_http_perform_pollset, /* perform_pollset */ ZERO_NULL, /* disconnect */ rtsp_rtp_write_resp, /* write_resp */ rtsp_rtp_write_resp_hd, /* write_resp_hd */ @@ -668,8 +668,7 @@ static CURLcode rtsp_do(struct Curl_easy *data, bool *done) /* if a request-body has been sent off, we make sure this progress is noted properly */ Curl_pgrsSetUploadCounter(data, data->req.writebytecount); - if(Curl_pgrsUpdate(data)) - result = CURLE_ABORTED_BY_CALLBACK; + result = Curl_pgrsUpdate(data); } out: curlx_dyn_free(&req_buffer); diff --git a/lib/select.c b/lib/select.c index 7818082e7543..041733973e9e 100644 --- a/lib/select.c +++ b/lib/select.c @@ -711,7 +711,7 @@ void Curl_pollset_check(struct Curl_easy *data, *pwant_read = *pwant_write = FALSE; } -bool Curl_pollset_want_read(struct Curl_easy *data, +bool Curl_pollset_want_recv(struct Curl_easy *data, struct easy_pollset *ps, curl_socket_t sock) { @@ -723,3 +723,16 @@ bool Curl_pollset_want_read(struct Curl_easy *data, } return FALSE; } + +bool Curl_pollset_want_send(struct Curl_easy *data, + struct easy_pollset *ps, + curl_socket_t sock) +{ + unsigned int i; + (void)data; + for(i = 0; i < ps->n; ++i) { + if((ps->sockets[i] == sock) && (ps->actions[i] & CURL_POLL_OUT)) + return TRUE; + } + return FALSE; +} diff --git a/lib/select.h b/lib/select.h index c1f975e9d79c..fb54686af3e2 100644 --- a/lib/select.h +++ b/lib/select.h @@ -163,8 +163,12 @@ CURLcode Curl_pollset_set(struct Curl_easy *data, #define Curl_pollset_add_in(data, ps, sock) \ Curl_pollset_change((data), (ps), (sock), CURL_POLL_IN, 0) +#define Curl_pollset_remove_in(data, ps, sock) \ + Curl_pollset_change((data), (ps), (sock), 0, CURL_POLL_IN) #define Curl_pollset_add_out(data, ps, sock) \ Curl_pollset_change((data), (ps), (sock), CURL_POLL_OUT, 0) +#define Curl_pollset_remove_out(data, ps, sock) \ + Curl_pollset_change((data), (ps), (sock), 0, CURL_POLL_OUT) #define Curl_pollset_add_inout(data, ps, sock) \ Curl_pollset_change((data), (ps), (sock), \ CURL_POLL_IN|CURL_POLL_OUT, 0) @@ -188,10 +192,12 @@ void Curl_pollset_check(struct Curl_easy *data, struct easy_pollset *ps, curl_socket_t sock, bool *pwant_read, bool *pwant_write); -/** - * Return TRUE if the pollset contains socket with CURL_POLL_IN. - */ -bool Curl_pollset_want_read(struct Curl_easy *data, +/* TRUE if the pollset contains socket with CURL_POLL_IN. */ +bool Curl_pollset_want_recv(struct Curl_easy *data, + struct easy_pollset *ps, + curl_socket_t sock); +/* TRUE if the pollset contains socket with CURL_POLL_OUT. */ +bool Curl_pollset_want_send(struct Curl_easy *data, struct easy_pollset *ps, curl_socket_t sock); diff --git a/lib/sendf.c b/lib/sendf.c index 655444a29504..f70abb5797bc 100644 --- a/lib/sendf.c +++ b/lib/sendf.c @@ -108,6 +108,7 @@ static void cl_reset_writer(struct Curl_easy *data) static void cl_reset_reader(struct Curl_easy *data) { struct Curl_creader *reader = data->req.reader_stack; + data->req.reader_started = FALSE; while(reader) { data->req.reader_stack = reader->next; reader->crt->do_close(data, reader); @@ -231,6 +232,7 @@ static CURLcode cw_download_write(struct Curl_easy *data, if(!is_connect && !ctx->started_response) { Curl_pgrsTime(data, TIMER_STARTTRANSFER); + Curl_rlimit_start(&data->progress.dl.rlimit, curlx_now()); ctx->started_response = TRUE; } @@ -301,7 +303,9 @@ static CURLcode cw_download_write(struct Curl_easy *data, if(result) return result; } + /* Update stats, write and report progress */ + Curl_rlimit_drain(&data->progress.dl.rlimit, nwrite, curlx_now()); data->req.bytecount += nwrite; Curl_pgrsSetDownloadCounter(data, data->req.bytecount); @@ -1198,9 +1202,28 @@ CURLcode Curl_client_read(struct Curl_easy *data, char *buf, size_t blen, return result; DEBUGASSERT(data->req.reader_stack); } + if(!data->req.reader_started) { + Curl_rlimit_start(&data->progress.ul.rlimit, curlx_now()); + data->req.reader_started = TRUE; + } + if(Curl_rlimit_active(&data->progress.ul.rlimit)) { + curl_off_t ul_avail = + Curl_rlimit_avail(&data->progress.ul.rlimit, curlx_now()); + if(ul_avail <= 0) { + result = CURLE_OK; + *eos = FALSE; + goto out; + } + if(ul_avail < (curl_off_t)blen) + blen = (size_t)ul_avail; + } result = Curl_creader_read(data, data->req.reader_stack, buf, blen, nread, eos); + if(!result) + Curl_rlimit_drain(&data->progress.ul.rlimit, *nread, curlx_now()); + +out: CURL_TRC_READ(data, "client_read(len=%zu) -> %d, nread=%zu, eos=%d", blen, result, *nread, *eos); return result; diff --git a/lib/setopt.c b/lib/setopt.c index 338e94d1bbf4..1147deb1162f 100644 --- a/lib/setopt.c +++ b/lib/setopt.c @@ -2842,6 +2842,7 @@ static CURLcode setopt_offt(struct Curl_easy *data, CURLoption option, if(offt < 0) return CURLE_BAD_FUNCTION_ARGUMENT; s->max_send_speed = offt; + Curl_rlimit_init(&data->progress.ul.rlimit, offt, offt, curlx_now()); break; case CURLOPT_MAX_RECV_SPEED_LARGE: /* @@ -2851,6 +2852,7 @@ static CURLcode setopt_offt(struct Curl_easy *data, CURLoption option, if(offt < 0) return CURLE_BAD_FUNCTION_ARGUMENT; s->max_recv_speed = offt; + Curl_rlimit_init(&data->progress.dl.rlimit, offt, offt, curlx_now()); break; case CURLOPT_RESUME_FROM_LARGE: /* diff --git a/lib/smtp.c b/lib/smtp.c index f36459634ebb..af4676dc182d 100644 --- a/lib/smtp.c +++ b/lib/smtp.c @@ -1697,10 +1697,7 @@ static CURLcode smtp_regular_transfer(struct Curl_easy *data, data->req.size = -1; /* Set the progress data */ - Curl_pgrsSetUploadCounter(data, 0); - Curl_pgrsSetDownloadCounter(data, 0); - Curl_pgrsSetUploadSize(data, -1); - Curl_pgrsSetDownloadSize(data, -1); + Curl_pgrsReset(data); /* Carry out the perform */ result = smtp_perform(data, smtpc, smtp, &connected, dophase_done); diff --git a/lib/speedcheck.c b/lib/speedcheck.c deleted file mode 100644 index b074199c37d6..000000000000 --- a/lib/speedcheck.c +++ /dev/null @@ -1,80 +0,0 @@ -/*************************************************************************** - * _ _ ____ _ - * Project ___| | | | _ \| | - * / __| | | | |_) | | - * | (__| |_| | _ <| |___ - * \___|\___/|_| \_\_____| - * - * Copyright (C) Daniel Stenberg, , et al. - * - * This software is licensed as described in the 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. - * - * SPDX-License-Identifier: curl - * - ***************************************************************************/ - -#include "curl_setup.h" - -#include -#include "urldata.h" -#include "sendf.h" -#include "transfer.h" -#include "multiif.h" -#include "speedcheck.h" - -void Curl_speedinit(struct Curl_easy *data) -{ - memset(&data->state.keeps_speed, 0, sizeof(struct curltime)); -} - -/* - * @unittest: 1606 - */ -CURLcode Curl_speedcheck(struct Curl_easy *data, - struct curltime now) -{ - if(Curl_xfer_recv_is_paused(data) || Curl_xfer_send_is_paused(data)) - /* A paused transfer is not qualified for speed checks */ - return CURLE_OK; - - if((data->progress.current_speed >= 0) && data->set.low_speed_time) { - if(data->progress.current_speed < data->set.low_speed_limit) { - if(!data->state.keeps_speed.tv_sec) - /* under the limit at this moment */ - data->state.keeps_speed = now; - else { - /* how long has it been under the limit */ - timediff_t howlong = curlx_timediff_ms(now, data->state.keeps_speed); - - if(howlong >= data->set.low_speed_time * 1000) { - /* too long */ - failf(data, - "Operation too slow. " - "Less than %ld bytes/sec transferred the last %ld seconds", - data->set.low_speed_limit, - data->set.low_speed_time); - return CURLE_OPERATION_TIMEDOUT; - } - } - } - else - /* faster right now */ - data->state.keeps_speed.tv_sec = 0; - } - - if(data->set.low_speed_limit) - /* if low speed limit is enabled, set the expire timer to make this - connection's speed get checked again in a second */ - Curl_expire(data, 1000, EXPIRE_SPEEDCHECK); - - return CURLE_OK; -} diff --git a/lib/speedcheck.h b/lib/speedcheck.h deleted file mode 100644 index f54365cadfac..000000000000 --- a/lib/speedcheck.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef HEADER_CURL_SPEEDCHECK_H -#define HEADER_CURL_SPEEDCHECK_H -/*************************************************************************** - * _ _ ____ _ - * Project ___| | | | _ \| | - * / __| | | | |_) | | - * | (__| |_| | _ <| |___ - * \___|\___/|_| \_\_____| - * - * Copyright (C) Daniel Stenberg, , et al. - * - * This software is licensed as described in the 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. - * - * SPDX-License-Identifier: curl - * - ***************************************************************************/ - -#include "curl_setup.h" - -#include "curlx/timeval.h" -struct Curl_easy; -void Curl_speedinit(struct Curl_easy *data); -CURLcode Curl_speedcheck(struct Curl_easy *data, - struct curltime now); - -#endif /* HEADER_CURL_SPEEDCHECK_H */ diff --git a/lib/telnet.c b/lib/telnet.c index 45a70808ea6b..d0ca5a66ce11 100644 --- a/lib/telnet.c +++ b/lib/telnet.c @@ -1659,9 +1659,10 @@ static CURLcode telnet_do(struct Curl_easy *data, bool *done) } } - if(Curl_pgrsUpdate(data)) { - result = CURLE_ABORTED_BY_CALLBACK; - break; + if(!result) { + result = Curl_pgrsUpdate(data); + if(result) + keepon = FALSE; } } #endif diff --git a/lib/tftp.c b/lib/tftp.c index c730f8499ec4..ce9d200f05e3 100644 --- a/lib/tftp.c +++ b/lib/tftp.c @@ -59,7 +59,6 @@ #include "multiif.h" #include "url.h" #include "strcase.h" -#include "speedcheck.h" #include "select.h" #include "escape.h" #include "curlx/strerr.h" @@ -1175,9 +1174,10 @@ static CURLcode tftp_receive_packet(struct Curl_easy *data, } /* Update the progress meter */ - if(Curl_pgrsUpdate(data)) { + result = Curl_pgrsUpdate(data); + if(result) { tftp_state_machine(state, TFTP_EVENT_ERROR); - return CURLE_ABORTED_BY_CALLBACK; + return result; } } return result; @@ -1297,10 +1297,7 @@ static CURLcode tftp_doing(struct Curl_easy *data, bool *dophase_done) /* The multi code does not have this logic for the DOING state so we provide it for TFTP since it may do the entire transfer in this state. */ - if(Curl_pgrsUpdate(data)) - result = CURLE_ABORTED_BY_CALLBACK; - else - result = Curl_speedcheck(data, curlx_now()); + result = Curl_pgrsCheck(data); } return result; } diff --git a/lib/transfer.c b/lib/transfer.c index b576e6b88dbe..fbacdf429061 100644 --- a/lib/transfer.c +++ b/lib/transfer.c @@ -65,7 +65,6 @@ #include "cw-out.h" #include "transfer.h" #include "sendf.h" -#include "speedcheck.h" #include "progress.h" #include "http.h" #include "url.h" @@ -241,10 +240,9 @@ static CURLcode sendrecv_dl(struct Curl_easy *data, char *buf, *xfer_buf; size_t blen, xfer_blen; int maxloops = 10; - curl_off_t total_received = 0; bool is_multiplex = FALSE; bool rcvd_eagain = FALSE; - bool is_eos = FALSE; + bool is_eos = FALSE, rate_limited = FALSE; result = Curl_multi_xfer_buf_borrow(data, &xfer_buf, &xfer_blen); if(result) @@ -265,15 +263,21 @@ static CURLcode sendrecv_dl(struct Curl_easy *data, buf = xfer_buf; bytestoread = xfer_blen; - if(bytestoread && data->set.max_recv_speed > 0) { - /* In case of speed limit on receiving: if this loop already got - * a quarter of the quota, break out. We want to stutter a bit - * to keep in the limit, but too small receives will just cost - * cpu unnecessarily. */ - if(total_received && (total_received >= (data->set.max_recv_speed / 4))) + if(bytestoread && Curl_rlimit_active(&data->progress.dl.rlimit)) { + curl_off_t dl_avail = Curl_rlimit_avail(&data->progress.dl.rlimit, + curlx_now()); + /* DEBUGF(infof(data, "dl_rlimit, available=%" FMT_OFF_T, dl_avail)); + */ + /* In case of rate limited downloads: if this loop already got + * data and less than 16k is left in the limit, break out. + * We want to stutter a bit to keep in the limit, but too small + * receives will just cost cpu unnecessarily. */ + if(dl_avail <= 0) { + rate_limited = TRUE; break; - if(data->set.max_recv_speed < (curl_off_t)bytestoread) - bytestoread = (size_t)data->set.max_recv_speed; + } + if(dl_avail < (curl_off_t)bytestoread) + bytestoread = (size_t)dl_avail; } rcvd_eagain = FALSE; @@ -315,7 +319,6 @@ static CURLcode sendrecv_dl(struct Curl_easy *data, if(k->eos_written) /* already did write this to client, leave */ break; } - total_received += blen; result = Curl_xfer_write_resp(data, buf, blen, is_eos); if(result || data->req.done) @@ -327,13 +330,13 @@ static CURLcode sendrecv_dl(struct Curl_easy *data, if((!is_multiplex && data->req.download_done) || is_eos) { data->req.keepon &= ~KEEP_RECV; } - /* if we are PAUSEd or stopped receiving, leave the loop */ - if((k->keepon & KEEP_RECV_PAUSE) || !(k->keepon & KEEP_RECV)) + /* if we stopped receiving, leave the loop */ + if(!(k->keepon & KEEP_RECV)) break; } while(maxloops--); - if(!is_eos && !Curl_xfer_is_blocked(data) && + if(!is_eos && !rate_limited && CURL_WANT_RECV(data) && (!rcvd_eagain || data_pending(data, rcvd_eagain))) { /* Did not read until EAGAIN/EOS or there is still data pending * in buffers. Mark as read-again via simulated SELECT results. */ @@ -396,16 +399,13 @@ CURLcode Curl_sendrecv(struct Curl_easy *data, struct curltime *nowp) } /* If we still have writing to do, we check if we have a writable socket. */ - if(Curl_req_want_send(data) || (data->req.keepon & KEEP_SEND_TIMED)) { + if(Curl_req_want_send(data)) { result = sendrecv_ul(data); if(result) goto out; } - if(Curl_pgrsUpdate(data)) - result = CURLE_ABORTED_BY_CALLBACK; - else - result = Curl_speedcheck(data, *nowp); + result = Curl_pgrsCheck(data); if(result) goto out; @@ -440,16 +440,14 @@ CURLcode Curl_sendrecv(struct Curl_easy *data, struct curltime *nowp) result = CURLE_PARTIAL_FILE; goto out; } - if(Curl_pgrsUpdate(data)) { - result = CURLE_ABORTED_BY_CALLBACK; - goto out; - } } /* If there is nothing more to send/recv, the request is done */ - if((k->keepon & (KEEP_RECVBITS|KEEP_SENDBITS)) == 0) + if((k->keepon & (KEEP_RECV|KEEP_SEND)) == 0) data->req.done = TRUE; + result = Curl_pgrsUpdate(data); + out: if(result) DEBUGF(infof(data, "Curl_sendrecv() -> %d", result)); @@ -913,51 +911,30 @@ bool Curl_xfer_is_blocked(struct Curl_easy *data) bool Curl_xfer_send_is_paused(struct Curl_easy *data) { - return (data->req.keepon & KEEP_SEND_PAUSE); + return Curl_rlimit_is_blocked(&data->progress.ul.rlimit); } bool Curl_xfer_recv_is_paused(struct Curl_easy *data) { - return (data->req.keepon & KEEP_RECV_PAUSE); + return Curl_rlimit_is_blocked(&data->progress.dl.rlimit); } CURLcode Curl_xfer_pause_send(struct Curl_easy *data, bool enable) { CURLcode result = CURLE_OK; - if(enable) { - data->req.keepon |= KEEP_SEND_PAUSE; - } - else { - data->req.keepon &= ~KEEP_SEND_PAUSE; - if(Curl_creader_is_paused(data)) - result = Curl_creader_unpause(data); - } + Curl_rlimit_block(&data->progress.ul.rlimit, enable, curlx_now()); + if(!enable && Curl_creader_is_paused(data)) + result = Curl_creader_unpause(data); return result; } CURLcode Curl_xfer_pause_recv(struct Curl_easy *data, bool enable) { CURLcode result = CURLE_OK; - if(enable) { - data->req.keepon |= KEEP_RECV_PAUSE; - } - else { - data->req.keepon &= ~KEEP_RECV_PAUSE; - if(Curl_cwriter_is_paused(data)) - result = Curl_cwriter_unpause(data); - } + Curl_rlimit_block(&data->progress.dl.rlimit, enable, curlx_now()); + if(!enable && Curl_cwriter_is_paused(data)) + result = Curl_cwriter_unpause(data); Curl_conn_ev_data_pause(data, enable); + Curl_pgrsRecvPause(data, enable); return result; } - -bool Curl_xfer_is_too_fast(struct Curl_easy *data) -{ - struct Curl_llist_node *e = Curl_llist_head(&data->state.timeoutlist); - while(e) { - struct time_node *n = Curl_node_elem(e); - e = Curl_node_next(e); - if(n->eid == EXPIRE_TOOFAST) - return TRUE; - } - return FALSE; -} diff --git a/lib/transfer.h b/lib/transfer.h index 6145efb4a5fd..b96629d97968 100644 --- a/lib/transfer.h +++ b/lib/transfer.h @@ -143,7 +143,4 @@ bool Curl_xfer_recv_is_paused(struct Curl_easy *data); CURLcode Curl_xfer_pause_send(struct Curl_easy *data, bool enable); CURLcode Curl_xfer_pause_recv(struct Curl_easy *data, bool enable); -/* Query if transfer has expire timeout TOOFAST set. */ -bool Curl_xfer_is_too_fast(struct Curl_easy *data); - #endif /* HEADER_CURL_TRANSFER_H */ diff --git a/lib/url.c b/lib/url.c index 7e4d455a8cd8..f9b1ed0808e7 100644 --- a/lib/url.c +++ b/lib/url.c @@ -88,7 +88,6 @@ #include "select.h" #include "multiif.h" #include "easyif.h" -#include "speedcheck.h" #include "curlx/warnless.h" #include "getinfo.h" #include "pop3.h" @@ -3884,7 +3883,6 @@ CURLcode Curl_connect(struct Curl_easy *data, CURLcode Curl_init_do(struct Curl_easy *data, struct connectdata *conn) { - /* if this is a pushed stream, we need this: */ CURLcode result; if(conn) { @@ -3904,9 +3902,7 @@ CURLcode Curl_init_do(struct Curl_easy *data, struct connectdata *conn) result = Curl_req_start(&data->req, data); if(!result) { - Curl_speedinit(data); - Curl_pgrsSetUploadCounter(data, 0); - Curl_pgrsSetDownloadCounter(data, 0); + Curl_pgrsReset(data); } return result; } diff --git a/lib/urldata.h b/lib/urldata.h index 4b112e7072dd..e4fc49753fd4 100644 --- a/lib/urldata.h +++ b/lib/urldata.h @@ -156,6 +156,7 @@ typedef unsigned int curl_prot_t; #include "curlx/dynbuf.h" #include "dynhds.h" #include "request.h" +#include "ratelimit.h" #include "netrc.h" /* On error return, the value of `pnwritten` has no meaning */ @@ -426,30 +427,11 @@ struct hostname { #define KEEP_NONE 0 #define KEEP_RECV (1<<0) /* there is or may be data to read */ #define KEEP_SEND (1<<1) /* there is or may be data to write */ -#define KEEP_RECV_HOLD (1<<2) /* when set, no reading should be done but there - might still be data to read */ -#define KEEP_SEND_HOLD (1<<3) /* when set, no writing should be done but there - might still be data to write */ -#define KEEP_RECV_PAUSE (1<<4) /* reading is paused */ -#define KEEP_SEND_PAUSE (1<<5) /* writing is paused */ - -/* KEEP_SEND_TIMED is set when the transfer should attempt sending - * at timer (or other) events. A transfer waiting on a timer will - * remove KEEP_SEND to suppress POLLOUTs of the connection. - * Adding KEEP_SEND_TIMED will then attempt to send whenever the transfer - * enters the "readwrite" loop, e.g. when a timer fires. - * This is used in HTTP for 'Expect: 100-continue' waiting. */ -#define KEEP_SEND_TIMED (1<<6) - -#define KEEP_RECVBITS (KEEP_RECV | KEEP_RECV_HOLD | KEEP_RECV_PAUSE) -#define KEEP_SENDBITS (KEEP_SEND | KEEP_SEND_HOLD | KEEP_SEND_PAUSE) - -/* transfer wants to send is not PAUSE or HOLD */ -#define CURL_WANT_SEND(data) \ - (((data)->req.keepon & KEEP_SENDBITS) == KEEP_SEND) -/* transfer receive is not on PAUSE or HOLD */ -#define CURL_WANT_RECV(data) \ - (((data)->req.keepon & KEEP_RECVBITS) == KEEP_RECV) + +/* transfer wants to send */ +#define CURL_WANT_SEND(data) ((data)->req.keepon & KEEP_SEND) +/* transfer wants to receive */ +#define CURL_WANT_RECV(data) ((data)->req.keepon & KEEP_RECV) #define FIRSTSOCKET 0 #define SECONDARYSOCKET 1 @@ -805,16 +787,11 @@ struct PureInfo { BIT(used_proxy); /* the transfer used a proxy */ }; -struct pgrs_measure { - struct curltime start; /* when measure started */ - curl_off_t start_size; /* the 'cur_size' the measure started at */ -}; - struct pgrs_dir { curl_off_t total_size; /* total expected bytes */ curl_off_t cur_size; /* transferred bytes so far */ curl_off_t speed; /* bytes per second transferred */ - struct pgrs_measure limit; + struct Curl_rlimit rlimit; /* speed limiting / pausing */ }; struct Progress { @@ -843,10 +820,10 @@ struct Progress { struct curltime t_startqueue; struct curltime t_acceptdata; -#define CURR_TIME (5 + 1) /* 6 entries for 5 seconds */ +#define CURL_SPEED_RECORDS (5 + 1) /* 6 entries for 5 seconds */ - curl_off_t speeder[ CURR_TIME ]; - struct curltime speeder_time[ CURR_TIME ]; + curl_off_t speed_amount[ CURL_SPEED_RECORDS ]; + struct curltime speed_time[ CURL_SPEED_RECORDS ]; unsigned char speeder_c; BIT(hide); BIT(ul_size_known); diff --git a/lib/vquic/curl_ngtcp2.c b/lib/vquic/curl_ngtcp2.c index ecfa895a2eaf..f63162b34417 100644 --- a/lib/vquic/curl_ngtcp2.c +++ b/lib/vquic/curl_ngtcp2.c @@ -80,10 +80,9 @@ #define QUIC_HANDSHAKE_TIMEOUT (10*NGTCP2_SECONDS) /* A stream window is the maximum amount we need to buffer for - * each active transfer. We use HTTP/3 flow control and only ACK - * when we take things out of the buffer. + * each active transfer. * Chunk size is large enough to take a full DATA frame */ -#define H3_STREAM_WINDOW_SIZE (128 * 1024) +#define H3_STREAM_WINDOW_SIZE (64 * 1024) #define H3_STREAM_CHUNK_SIZE (16 * 1024) #if H3_STREAM_CHUNK_SIZE < NGTCP2_MAX_UDP_PAYLOAD_SIZE #error H3_STREAM_CHUNK_SIZE smaller than NGTCP2_MAX_UDP_PAYLOAD_SIZE @@ -242,6 +241,7 @@ struct h3_stream_ctx { size_t sendbuf_len_in_flight; /* sendbuf amount "in flight" */ curl_uint64_t error3; /* HTTP/3 stream error code */ curl_off_t upload_left; /* number of request bytes left to upload */ + uint64_t download_unacked; /* bytes not acknowledged yet */ int status_code; /* HTTP status code */ CURLcode xfer_result; /* result from xfer_resp_write(_hd) */ BIT(resp_hds_complete); /* we have a complete, final response */ @@ -472,7 +472,7 @@ static void quic_settings(struct cf_ngtcp2_ctx *ctx, s->handshake_timeout = (data->set.connecttimeout > 0) ? data->set.connecttimeout * NGTCP2_MILLISECONDS : QUIC_HANDSHAKE_TIMEOUT; s->max_window = 100 * ctx->max_stream_window; - s->max_stream_window = 10 * ctx->max_stream_window; + s->max_stream_window = ctx->max_stream_window; s->no_pmtud = FALSE; #ifdef NGTCP2_SETTINGS_V3 /* try ten times the ngtcp2 defaults here for problems with Caddy */ @@ -1057,6 +1057,35 @@ static void h3_xfer_write_resp(struct Curl_cfilter *cf, } } +static void cf_ngtcp2_ack_stream(struct Curl_cfilter *cf, + struct Curl_easy *data, + struct h3_stream_ctx *stream) +{ + struct cf_ngtcp2_ctx *ctx = cf->ctx; + struct curltime now = curlx_now(); + curl_off_t avail; + uint64_t ack_len = 0; + + /* How many byte to ack on the stream? */ + + /* how much does rate limiting allow us to acknowledge? */ + avail = Curl_rlimit_avail(&data->progress.dl.rlimit, now); + if(avail == CURL_OFF_T_MAX) { /* no rate limit, ack all */ + ack_len = stream->download_unacked; + } + else if(avail > 0) { + ack_len = CURLMIN(stream->download_unacked, (uint64_t)avail); + } + + if(ack_len) { + CURL_TRC_CF(data, cf, "[%" FMT_PRId64 "] ACK %" PRIu64 + "/%" PRIu64 " bytes of DATA", stream->id, + ack_len, stream->download_unacked); + ngtcp2_conn_extend_max_stream_offset(ctx->qconn, stream->id, ack_len); + stream->download_unacked -= ack_len; + } +} + static int cb_h3_recv_data(nghttp3_conn *conn, int64_t stream3_id, const uint8_t *buf, size_t blen, void *user_data, void *stream_user_data) @@ -1073,13 +1102,15 @@ static int cb_h3_recv_data(nghttp3_conn *conn, int64_t stream3_id, return NGHTTP3_ERR_CALLBACK_FAILURE; h3_xfer_write_resp(cf, data, stream, (const char *)buf, blen, FALSE); - if(blen) { - CURL_TRC_CF(data, cf, "[%" FMT_PRId64 "] ACK %zu bytes of DATA", - stream->id, blen); - ngtcp2_conn_extend_max_stream_offset(ctx->qconn, stream->id, blen); - ngtcp2_conn_extend_max_offset(ctx->qconn, blen); - } CURL_TRC_CF(data, cf, "[%" FMT_PRId64 "] DATA len=%zu", stream->id, blen); + + ngtcp2_conn_extend_max_offset(ctx->qconn, blen); + if(UINT64_MAX - blen < stream->download_unacked) + stream->download_unacked = UINT64_MAX; /* unlikely */ + else + stream->download_unacked += blen; + + cf_ngtcp2_ack_stream(cf, data, stream); return 0; } @@ -1374,6 +1405,8 @@ static CURLcode cf_ngtcp2_recv(struct Curl_cfilter *cf, struct Curl_easy *data, goto out; } + cf_ngtcp2_ack_stream(cf, data, stream); + if(cf_progress_ingress(cf, data, &pktx)) { result = CURLE_RECV_ERROR; goto out; diff --git a/lib/vssh/libssh.c b/lib/vssh/libssh.c index 9428a20a5f39..77a915884aaf 100644 --- a/lib/vssh/libssh.c +++ b/lib/vssh/libssh.c @@ -54,7 +54,6 @@ #include "../http.h" /* for HTTP proxy tunnel stuff */ #include "ssh.h" #include "../url.h" -#include "../speedcheck.h" #include "../vtls/vtls.h" #include "../cfilters.h" #include "../connect.h" @@ -2481,17 +2480,13 @@ static CURLcode myssh_block_statemach(struct Curl_easy *data, while((sshc->state != SSH_STOP) && !result) { bool block; timediff_t left_ms = 1000; - struct curltime now = curlx_now(); result = myssh_statemach_act(data, sshc, sshp, &block); if(result) break; if(!disconnect) { - if(Curl_pgrsUpdate(data)) - return CURLE_ABORTED_BY_CALLBACK; - - result = Curl_speedcheck(data, now); + result = Curl_pgrsCheck(data); if(result) break; @@ -2746,10 +2741,7 @@ static CURLcode myssh_do_it(struct Curl_easy *data, bool *done) sshc->secondCreateDirs = 0; /* reset the create directory attempt state variable */ - Curl_pgrsSetUploadCounter(data, 0); - Curl_pgrsSetDownloadCounter(data, 0); - Curl_pgrsSetUploadSize(data, -1); - Curl_pgrsSetDownloadSize(data, -1); + Curl_pgrsReset(data); if(conn->handler->protocol & CURLPROTO_SCP) result = scp_perform(data, &connected, done); diff --git a/lib/vssh/libssh2.c b/lib/vssh/libssh2.c index 3a7e14053fb9..714e3953730a 100644 --- a/lib/vssh/libssh2.c +++ b/lib/vssh/libssh2.c @@ -53,7 +53,6 @@ #include "../http.h" /* for HTTP proxy tunnel stuff */ #include "ssh.h" #include "../url.h" -#include "../speedcheck.h" #include "../vtls/vtls.h" #include "../cfilters.h" #include "../connect.h" @@ -3135,10 +3134,7 @@ static CURLcode ssh_block_statemach(struct Curl_easy *data, break; if(!disconnect) { - if(Curl_pgrsUpdate(data)) - return CURLE_ABORTED_BY_CALLBACK; - - result = Curl_speedcheck(data, now); + result = Curl_pgrsCheck(data); if(result) break; @@ -3534,10 +3530,7 @@ static CURLcode ssh_do(struct Curl_easy *data, bool *done) sshc->secondCreateDirs = 0; /* reset the create directory attempt state variable */ - Curl_pgrsSetUploadCounter(data, 0); - Curl_pgrsSetDownloadCounter(data, 0); - Curl_pgrsSetUploadSize(data, -1); - Curl_pgrsSetDownloadSize(data, -1); + Curl_pgrsReset(data); if(conn->handler->protocol & CURLPROTO_SCP) result = scp_perform(data, &connected, done); diff --git a/lib/vtls/schannel.c b/lib/vtls/schannel.c index a40c440234ae..f7e831f002e5 100644 --- a/lib/vtls/schannel.c +++ b/lib/vtls/schannel.c @@ -1811,10 +1811,9 @@ schannel_recv_renegotiate(struct Curl_cfilter *cf, struct Curl_easy *data, int what; timediff_t timeout_ms, remaining; - if(Curl_pgrsUpdate(data)) { - result = CURLE_ABORTED_BY_CALLBACK; + result = Curl_pgrsUpdate(data); + if(result) break; - } elapsed = curlx_timediff_ms(curlx_now(), rs->start_time); if(elapsed >= MAX_RENEG_BLOCK_TIME) { diff --git a/lib/ws.c b/lib/ws.c index 140bdece47d8..b5c02bda9555 100644 --- a/lib/ws.c +++ b/lib/ws.c @@ -1927,9 +1927,9 @@ const struct Curl_handler Curl_handler_ws = { ZERO_NULL, /* connecting */ ZERO_NULL, /* doing */ ZERO_NULL, /* proto_pollset */ - Curl_http_do_pollset, /* doing_pollset */ + Curl_http_doing_pollset, /* doing_pollset */ ZERO_NULL, /* domore_pollset */ - ZERO_NULL, /* perform_pollset */ + Curl_http_perform_pollset, /* perform_pollset */ ZERO_NULL, /* disconnect */ Curl_http_write_resp, /* write_resp */ Curl_http_write_resp_hd, /* write_resp_hd */ @@ -1954,9 +1954,9 @@ const struct Curl_handler Curl_handler_wss = { NULL, /* connecting */ ZERO_NULL, /* doing */ NULL, /* proto_pollset */ - Curl_http_do_pollset, /* doing_pollset */ + Curl_http_doing_pollset, /* doing_pollset */ ZERO_NULL, /* domore_pollset */ - ZERO_NULL, /* perform_pollset */ + Curl_http_perform_pollset, /* perform_pollset */ ZERO_NULL, /* disconnect */ Curl_http_write_resp, /* write_resp */ Curl_http_write_resp_hd, /* write_resp_hd */ diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am index fc10723814e1..bc3abbc7d80c 100644 --- a/tests/data/Makefile.am +++ b/tests/data/Makefile.am @@ -280,7 +280,7 @@ test3032 test3033 test3034 test3035 \ test3100 test3101 test3102 test3103 test3104 test3105 \ \ test3200 test3201 test3202 test3203 test3204 test3205 test3206 test3207 test3208 \ -test3209 test3210 test3211 test3212 test3213 test3214 test3215 \ +test3209 test3210 test3211 test3212 test3213 test3214 test3215 test3216 \ test4000 test4001 EXTRA_DIST = $(TESTCASES) DISABLED data-xml1 diff --git a/tests/data/test3216 b/tests/data/test3216 new file mode 100644 index 000000000000..923090c70ac1 --- /dev/null +++ b/tests/data/test3216 @@ -0,0 +1,19 @@ + + + +unittest +ratelimit + + + +# +# Client-side + + +unittest + + +ratelimit unit tests + + + diff --git a/tests/http/test_02_download.py b/tests/http/test_02_download.py index 9abe497539d2..8cfd68b20463 100644 --- a/tests/http/test_02_download.py +++ b/tests/http/test_02_download.py @@ -27,11 +27,9 @@ import difflib import filecmp import logging -import math import os import re import sys -from datetime import timedelta import pytest from testenv import Env, CurlClient, LocalClient @@ -424,15 +422,17 @@ def test_02_24_speed_limit(self, env: Env, httpd, nghttpx, proto): count = 1 url = f'https://{env.authority_for(env.domain1, proto)}/data-1m' curl = CurlClient(env=env) - speed_limit = 384 * 1024 - min_duration = math.floor((1024 * 1024)/speed_limit) + speed_limit = 256 * 1024 r = curl.http_download(urls=[url], alpn_proto=proto, extra_args=[ '--limit-rate', f'{speed_limit}' ]) r.check_response(count=count, http_status=200) - assert r.duration > timedelta(seconds=min_duration), \ - f'rate limited transfer should take more than {min_duration}s, '\ - f'not {r.duration}' + dl_speed = r.stats[0]['speed_download'] + # speed limit is only exact on long durations. Ideally this transfer + # would take 4 seconds, but it may end just after 3 because then + # we have downloaded the rest and will not wait for the rate + # limit to increase again. + assert dl_speed <= ((1024*1024)/3), f'{r.stats[0]}' # make extreme parallel h2 upgrades, check invalid conn reuse # before protocol switch has happened diff --git a/tests/http/test_07_upload.py b/tests/http/test_07_upload.py index 8d6901884146..9e49ad7f4737 100644 --- a/tests/http/test_07_upload.py +++ b/tests/http/test_07_upload.py @@ -557,7 +557,7 @@ def test_07_50_put_speed_limit(self, env: Env, httpd, nghttpx, proto): r.check_response(count=count, http_status=200) assert r.responses[0]['header']['received-length'] == f'{up_len}', f'{r.responses[0]}' up_speed = r.stats[0]['speed_upload'] - assert (speed_limit * 0.5) <= up_speed <= (speed_limit * 1.5), f'{r.stats[0]}' + assert up_speed <= (speed_limit * 1.1), f'{r.stats[0]}' # speed limited on echo handler @pytest.mark.parametrize("proto", Env.http_protos()) @@ -573,7 +573,7 @@ def test_07_51_echo_speed_limit(self, env: Env, httpd, nghttpx, proto): ]) r.check_response(count=count, http_status=200) up_speed = r.stats[0]['speed_upload'] - assert (speed_limit * 0.5) <= up_speed <= (speed_limit * 1.5), f'{r.stats[0]}' + assert up_speed <= (speed_limit * 1.1), f'{r.stats[0]}' # upload larger data, triggering "Expect: 100-continue" code paths @pytest.mark.parametrize("proto", ['http/1.1']) diff --git a/tests/unit/Makefile.inc b/tests/unit/Makefile.inc index 7027973d2f93..af5e2ebc7594 100644 --- a/tests/unit/Makefile.inc +++ b/tests/unit/Makefile.inc @@ -42,4 +42,4 @@ TESTS_C = \ unit1979.c unit1980.c \ unit2600.c unit2601.c unit2602.c unit2603.c unit2604.c unit2605.c \ unit3200.c unit3205.c \ - unit3211.c unit3212.c unit3213.c unit3214.c + unit3211.c unit3212.c unit3213.c unit3214.c unit3216.c diff --git a/tests/unit/unit1606.c b/tests/unit/unit1606.c index d323b5ce020b..4e290db72a76 100644 --- a/tests/unit/unit1606.c +++ b/tests/unit/unit1606.c @@ -23,7 +23,7 @@ ***************************************************************************/ #include "unitcheck.h" -#include "speedcheck.h" +#include "progress.h" #include "urldata.h" static CURLcode t1606_setup(struct Curl_easy **easy) @@ -58,12 +58,12 @@ static int runawhile(struct Curl_easy *easy, curl_easy_setopt(easy, CURLOPT_LOW_SPEED_LIMIT, speed_limit); curl_easy_setopt(easy, CURLOPT_LOW_SPEED_TIME, time_limit); - Curl_speedinit(easy); + Curl_pgrsReset(easy); do { /* fake the current transfer speed */ easy->progress.current_speed = speed; - res = Curl_speedcheck(easy, now); + res = pgrs_speedcheck(easy, &now); if(res) break; /* step the time */ diff --git a/tests/unit/unit3216.c b/tests/unit/unit3216.c new file mode 100644 index 000000000000..cbe9a5f0bf51 --- /dev/null +++ b/tests/unit/unit3216.c @@ -0,0 +1,103 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) Daniel Stenberg, , et al. + * + * This software is licensed as described in the 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. + * + * SPDX-License-Identifier: curl + * + ***************************************************************************/ +#include "unitcheck.h" + +#include "ratelimit.h" + +static CURLcode test_unit3216(const char *arg) +{ + UNITTEST_BEGIN_SIMPLE + struct Curl_rlimit r; + struct curltime ts; + + /* A ratelimit that is unlimited */ + ts = curlx_now(); + Curl_rlimit_init(&r, 0, 0, ts); + fail_unless(Curl_rlimit_avail(&r, ts) == CURL_OFF_T_MAX, "inf"); + Curl_rlimit_drain(&r, 1000000, ts); + fail_unless(Curl_rlimit_avail(&r, ts) == CURL_OFF_T_MAX, "drain keep inf"); + fail_unless(Curl_rlimit_wait_ms(&r, ts) == 0, "inf never waits"); + + Curl_rlimit_block(&r, TRUE, ts); + fail_unless(Curl_rlimit_avail(&r, ts) == 0, "inf blocked to 0"); + Curl_rlimit_drain(&r, 1000000, ts); + fail_unless(Curl_rlimit_avail(&r, ts) == 0, "blocked inf"); + Curl_rlimit_block(&r, FALSE, ts); + fail_unless(Curl_rlimit_avail(&r, ts) == CURL_OFF_T_MAX, + "unblocked unlimited"); + + /* A ratelimit that give 10 tokens per second */ + ts = curlx_now(); + Curl_rlimit_init(&r, 10, 0, ts); + fail_unless(Curl_rlimit_avail(&r, ts) == 10, "initial 10"); + Curl_rlimit_drain(&r, 5, ts); + fail_unless(Curl_rlimit_avail(&r, ts) == 5, "drain to 5"); + Curl_rlimit_drain(&r, 3, ts); + fail_unless(Curl_rlimit_avail(&r, ts) == 2, "drain to 2"); + ts.tv_usec += 1000; /* 1ms */ + Curl_rlimit_drain(&r, 3, ts); + fail_unless(Curl_rlimit_avail(&r, ts) == -1, "drain to -1"); + fail_unless(Curl_rlimit_wait_ms(&r, ts) == 999, "wait 999ms"); + ts.tv_usec += 1000; /* 1ms */ + fail_unless(Curl_rlimit_wait_ms(&r, ts) == 998, "wait 998ms"); + ts.tv_sec += 1; + fail_unless(Curl_rlimit_avail(&r, ts) == 9, "10 inc per sec"); + ts.tv_sec += 1; + fail_unless(Curl_rlimit_avail(&r, ts) == 19, "10 inc per sec(2)"); + + Curl_rlimit_block(&r, TRUE, curlx_now()); + fail_unless(Curl_rlimit_avail(&r, curlx_now()) == 0, "10 blocked to 0"); + Curl_rlimit_block(&r, FALSE, curlx_now()); + fail_unless(Curl_rlimit_avail(&r, curlx_now()) == 10, "unblocked 10"); + + /* A ratelimit that give 10 tokens per second, max burst 15/s */ + ts = curlx_now(); + Curl_rlimit_init(&r, 10, 15, ts); + fail_unless(Curl_rlimit_avail(&r, ts) == 10, "initial 10"); + Curl_rlimit_drain(&r, 5, ts); + fail_unless(Curl_rlimit_avail(&r, ts) == 5, "drain to 5"); + Curl_rlimit_drain(&r, 3, ts); + fail_unless(Curl_rlimit_avail(&r, ts) == 2, "drain to 2"); + Curl_rlimit_drain(&r, 3, ts); + fail_unless(Curl_rlimit_avail(&r, ts) == -1, "drain to -1"); + ts.tv_sec += 1; + fail_unless(Curl_rlimit_avail(&r, ts) == 9, "10 inc per sec"); + ts.tv_sec += 1; + fail_unless(Curl_rlimit_avail(&r, ts) == 15, "10/15 burst limit"); + ts.tv_sec += 1; + fail_unless(Curl_rlimit_avail(&r, ts) == 15, "10/15 burst limit(2)"); + Curl_rlimit_drain(&r, 15, ts); + fail_unless(Curl_rlimit_avail(&r, ts) == 0, "drain to 0"); + fail_unless(Curl_rlimit_wait_ms(&r, ts) == 1000, "wait 1 sec"); + ts.tv_usec += 500000; /* half a sec, cheating on second carry */ + fail_unless(Curl_rlimit_avail(&r, ts) == 0, "0 after 0.5 sec"); + fail_unless(Curl_rlimit_wait_ms(&r, ts) == 500, "wait 0.5 sec"); + ts.tv_sec += 1; + fail_unless(Curl_rlimit_avail(&r, ts) == 10, "10 after 1.5 sec"); + fail_unless(Curl_rlimit_wait_ms(&r, ts) == 0, "wait 0"); + ts.tv_usec += 500000; /* half a sec, cheating on second carry */ + fail_unless(Curl_rlimit_avail(&r, ts) == 15, "10 after 2 sec"); + + UNITTEST_END_SIMPLE +} From 56f2479c1433bd4f886295fcdce2459d1333eecf Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 24 Nov 2025 12:46:01 +0100 Subject: [PATCH 041/415] manage: expand the 'libcurl support required' message Example of old text: --dns-ipv4-addr requires that libcurl is built to support c-ares. New version: For --dns-ipv4-addr to work, it requires that the underlying libcurl is built to support c-ares. Closes #19665 --- scripts/managen | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/managen b/scripts/managen index 61dae8cc1f0f..d8ff9bae5124 100755 --- a/scripts/managen +++ b/scripts/managen @@ -854,7 +854,7 @@ sub single { if($requires) { my $l = manpageify($long, $manpage); - push @foot, "$l requires that libcurl". + push @foot, "For $l to work, it requires that the underlying libcurl". " is built to support $requires.\n"; } if($mutexed) { From 3887069c661b40e76b053a4867eb565d4761ab3e Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Fri, 21 Nov 2025 20:36:26 +0100 Subject: [PATCH 042/415] lib: rename internal header `share.h` to `curl_share.h` to avoid collision Windows CRTs have a `share.h`. Before this patch when trying to `#include ` it, the compiler picked up curl's internal `lib/share.h` instead. Rename it to avoid this issue. CRT `share.h` has constants necessary for using safe open CRT functions. Also rename `lib/share.c` to keep matching the header. Ref: https://learn.microsoft.com/cpp/c-runtime-library/sharing-constants Ref: 625f2c1644da58b9617479775badea21f125ce6d #16949 #16991 Cherry-picked from #19643 Closes #19676 --- lib/Makefile.inc | 4 ++-- lib/asyn-ares.c | 2 +- lib/asyn-base.c | 2 +- lib/asyn-thrdd.c | 2 +- lib/cf-socket.c | 2 +- lib/conncache.c | 2 +- lib/connect.c | 2 +- lib/cookie.c | 2 +- lib/{share.c => curl_share.c} | 2 +- lib/{share.h => curl_share.h} | 0 lib/doh.c | 2 +- lib/easy.c | 2 +- lib/hostip.c | 2 +- lib/hostip4.c | 2 +- lib/hostip6.c | 2 +- lib/hsts.c | 2 +- lib/http.c | 2 +- lib/multi.c | 2 +- lib/psl.c | 2 +- lib/setopt.c | 2 +- lib/url.c | 2 +- lib/vtls/vtls.c | 2 +- lib/vtls/vtls_scache.c | 2 +- tests/unit/unit1607.c | 2 +- tests/unit/unit1609.c | 2 +- 25 files changed, 25 insertions(+), 25 deletions(-) rename lib/{share.c => curl_share.c} (99%) rename lib/{share.h => curl_share.h} (100%) diff --git a/lib/Makefile.inc b/lib/Makefile.inc index 9c9d5c918691..cad02c823786 100644 --- a/lib/Makefile.inc +++ b/lib/Makefile.inc @@ -172,6 +172,7 @@ LIB_CFILES = \ curl_rtmp.c \ curl_sasl.c \ curl_sha512_256.c \ + curl_share.c \ curl_sspi.c \ curl_threads.c \ curl_trc.c \ @@ -242,7 +243,6 @@ LIB_CFILES = \ sendf.c \ setopt.c \ sha256.c \ - share.c \ slist.c \ smb.c \ smtp.c \ @@ -311,6 +311,7 @@ LIB_HFILES = \ curl_setup_once.h \ curl_sha256.h \ curl_sha512_256.h \ + curl_share.h \ curl_sspi.h \ curl_threads.h \ curl_trc.h \ @@ -376,7 +377,6 @@ LIB_HFILES = \ setup-os400.h \ setup-vms.h \ setup-win32.h \ - share.h \ sigpipe.h \ slist.h \ smb.h \ diff --git a/lib/asyn-ares.c b/lib/asyn-ares.c index e01f7ba3d24e..ab57d5e00b41 100644 --- a/lib/asyn-ares.c +++ b/lib/asyn-ares.c @@ -52,7 +52,7 @@ #include "sendf.h" #include "hostip.h" #include "hash.h" -#include "share.h" +#include "curl_share.h" #include "url.h" #include "multiif.h" #include "curlx/inet_pton.h" diff --git a/lib/asyn-base.c b/lib/asyn-base.c index a49e1752a57a..d7e8e7d15b86 100644 --- a/lib/asyn-base.c +++ b/lib/asyn-base.c @@ -51,7 +51,7 @@ #include "hash.h" #include "multiif.h" #include "select.h" -#include "share.h" +#include "curl_share.h" #include "url.h" #include "curl_memory.h" /* The last #include file should be: */ diff --git a/lib/asyn-thrdd.c b/lib/asyn-thrdd.c index 07b666304910..f4f57b547a01 100644 --- a/lib/asyn-thrdd.c +++ b/lib/asyn-thrdd.c @@ -59,7 +59,7 @@ #include "sendf.h" #include "hostip.h" #include "hash.h" -#include "share.h" +#include "curl_share.h" #include "url.h" #include "multiif.h" #include "curl_threads.h" diff --git a/lib/cf-socket.c b/lib/cf-socket.c index 0055f2d48c92..2930f95fe24c 100644 --- a/lib/cf-socket.c +++ b/lib/cf-socket.c @@ -75,7 +75,7 @@ #include "conncache.h" #include "multihandle.h" #include "rand.h" -#include "share.h" +#include "curl_share.h" #include "strdup.h" #include "system_win32.h" #include "curlx/version_win32.h" diff --git a/lib/conncache.c b/lib/conncache.c index 86dcce7138e6..275e490f23e8 100644 --- a/lib/conncache.c +++ b/lib/conncache.c @@ -38,7 +38,7 @@ #include "conncache.h" #include "http_negotiate.h" #include "http_ntlm.h" -#include "share.h" +#include "curl_share.h" #include "sigpipe.h" #include "connect.h" #include "select.h" diff --git a/lib/connect.c b/lib/connect.c index 4f9453907b0c..fbb5dcabff26 100644 --- a/lib/connect.c +++ b/lib/connect.c @@ -72,7 +72,7 @@ #include "curlx/warnless.h" #include "conncache.h" #include "multihandle.h" -#include "share.h" +#include "curl_share.h" #include "http_proxy.h" #include "socks.h" diff --git a/lib/cookie.c b/lib/cookie.c index 85356d563bb1..6099c6ea560d 100644 --- a/lib/cookie.c +++ b/lib/cookie.c @@ -31,7 +31,7 @@ #include "psl.h" #include "sendf.h" #include "slist.h" -#include "share.h" +#include "curl_share.h" #include "strcase.h" #include "curl_fopen.h" #include "curl_get_line.h" diff --git a/lib/share.c b/lib/curl_share.c similarity index 99% rename from lib/share.c rename to lib/curl_share.c index fdb80f5f64ab..b65d16c6281f 100644 --- a/lib/share.c +++ b/lib/curl_share.c @@ -27,7 +27,7 @@ #include #include "urldata.h" #include "connect.h" -#include "share.h" +#include "curl_share.h" #include "psl.h" #include "vtls/vtls.h" #include "vtls/vtls_scache.h" diff --git a/lib/share.h b/lib/curl_share.h similarity index 100% rename from lib/share.h rename to lib/curl_share.h diff --git a/lib/doh.c b/lib/doh.c index 636f0f41cf24..45524edf4c0b 100644 --- a/lib/doh.c +++ b/lib/doh.c @@ -33,7 +33,7 @@ #include "sendf.h" #include "multiif.h" #include "url.h" -#include "share.h" +#include "curl_share.h" #include "curlx/base64.h" #include "connect.h" #include "strdup.h" diff --git a/lib/easy.c b/lib/easy.c index 54896a8d55b4..8c7b9c23da68 100644 --- a/lib/easy.c +++ b/lib/easy.c @@ -53,7 +53,7 @@ #include "url.h" #include "getinfo.h" #include "hostip.h" -#include "share.h" +#include "curl_share.h" #include "strdup.h" #include "progress.h" #include "easyif.h" diff --git a/lib/hostip.c b/lib/hostip.c index 48889dcb43bc..d5f753f4b4a7 100644 --- a/lib/hostip.c +++ b/lib/hostip.c @@ -50,7 +50,7 @@ #include "hostip.h" #include "hash.h" #include "rand.h" -#include "share.h" +#include "curl_share.h" #include "url.h" #include "curlx/inet_ntop.h" #include "curlx/inet_pton.h" diff --git a/lib/hostip4.c b/lib/hostip4.c index e1ed007aafa3..d543c1e14b19 100644 --- a/lib/hostip4.c +++ b/lib/hostip4.c @@ -47,7 +47,7 @@ #include "sendf.h" #include "hostip.h" #include "hash.h" -#include "share.h" +#include "curl_share.h" #include "url.h" /* The last 2 #include files should be in this order */ diff --git a/lib/hostip6.c b/lib/hostip6.c index 9419b9e4d5fe..0f628b3fb5ca 100644 --- a/lib/hostip6.c +++ b/lib/hostip6.c @@ -48,7 +48,7 @@ #include "sendf.h" #include "hostip.h" #include "hash.h" -#include "share.h" +#include "curl_share.h" #include "url.h" #include "curlx/inet_pton.h" #include "connect.h" diff --git a/lib/hsts.c b/lib/hsts.c index ec332392c429..836481cd4c36 100644 --- a/lib/hsts.c +++ b/lib/hsts.c @@ -37,7 +37,7 @@ #include "sendf.h" #include "parsedate.h" #include "rename.h" -#include "share.h" +#include "curl_share.h" #include "strdup.h" #include "curlx/strparse.h" diff --git a/lib/http.c b/lib/http.c index a1e449d35441..ae932cd7c93a 100644 --- a/lib/http.c +++ b/lib/http.c @@ -65,7 +65,7 @@ #include "http_aws_sigv4.h" #include "url.h" #include "urlapi-int.h" -#include "share.h" +#include "curl_share.h" #include "hostip.h" #include "dynhds.h" #include "http.h" diff --git a/lib/multi.c b/lib/multi.c index 5ea93348e4e5..00af3ca2bddf 100644 --- a/lib/multi.c +++ b/lib/multi.c @@ -33,7 +33,7 @@ #include "connect.h" #include "progress.h" #include "easyif.h" -#include "share.h" +#include "curl_share.h" #include "psl.h" #include "multiif.h" #include "multi_ev.h" diff --git a/lib/psl.c b/lib/psl.c index 832d6d21b94a..f645763d063b 100644 --- a/lib/psl.c +++ b/lib/psl.c @@ -29,7 +29,7 @@ #ifdef USE_LIBPSL #include "psl.h" -#include "share.h" +#include "curl_share.h" /* The last 2 #include files should be in this order */ #include "curl_memory.h" diff --git a/lib/setopt.c b/lib/setopt.c index 1147deb1162f..fc95389312ad 100644 --- a/lib/setopt.c +++ b/lib/setopt.c @@ -41,7 +41,7 @@ #include "progress.h" #include "content_encoding.h" #include "strcase.h" -#include "share.h" +#include "curl_share.h" #include "vtls/vtls.h" #include "curlx/warnless.h" #include "sendf.h" diff --git a/lib/url.c b/lib/url.c index f9b1ed0808e7..1d4c6b1fc419 100644 --- a/lib/url.c +++ b/lib/url.c @@ -81,7 +81,7 @@ #include "cookie.h" #include "strcase.h" #include "escape.h" -#include "share.h" +#include "curl_share.h" #include "content_encoding.h" #include "http_digest.h" #include "http_negotiate.h" diff --git a/lib/vtls/vtls.c b/lib/vtls/vtls.c index ed0af3d53b91..d116ec91edb3 100644 --- a/lib/vtls/vtls.c +++ b/lib/vtls/vtls.c @@ -63,7 +63,7 @@ #include "../strcase.h" #include "../url.h" #include "../progress.h" -#include "../share.h" +#include "../curl_share.h" #include "../multiif.h" #include "../curlx/fopen.h" #include "../curlx/timeval.h" diff --git a/lib/vtls/vtls_scache.c b/lib/vtls/vtls_scache.c index 328b12403e9b..3524a25a4417 100644 --- a/lib/vtls/vtls_scache.c +++ b/lib/vtls/vtls_scache.c @@ -41,7 +41,7 @@ #include "../strcase.h" #include "../url.h" #include "../llist.h" -#include "../share.h" +#include "../curl_share.h" #include "../curl_trc.h" #include "../curl_sha256.h" #include "../rand.h" diff --git a/tests/unit/unit1607.c b/tests/unit/unit1607.c index 089caa1c45b8..3e4d53d0be5e 100644 --- a/tests/unit/unit1607.c +++ b/tests/unit/unit1607.c @@ -25,7 +25,7 @@ #include "urldata.h" #include "connect.h" -#include "share.h" +#include "curl_share.h" #include "memdebug.h" /* LAST include file */ diff --git a/tests/unit/unit1609.c b/tests/unit/unit1609.c index 00164617f522..f3f318f2cf97 100644 --- a/tests/unit/unit1609.c +++ b/tests/unit/unit1609.c @@ -25,7 +25,7 @@ #include "urldata.h" #include "connect.h" -#include "share.h" +#include "curl_share.h" #include "memdebug.h" /* LAST include file */ From 56bfde6554716f302998a29a192c82bf681a62ee Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Mon, 24 Nov 2025 23:55:57 +0100 Subject: [PATCH 043/415] INTERNALS.md: add release dates to build dependencies Also: - delete `roffit`, that's not used anymore. Follow-up to ea0b575dab86a3c44dd1d547dc500276266aa382 #12753 Follow-up to 92d9dbe4c008646dd467d23dea963fa32e16cf85 #19611 Closes #19677 --- docs/INTERNALS.md | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/docs/INTERNALS.md b/docs/INTERNALS.md index acc4506e6722..75393a5d1c72 100644 --- a/docs/INTERNALS.md +++ b/docs/INTERNALS.md @@ -46,13 +46,12 @@ versions of libs and build tools. we use a few "build tools" and we make sure that we remain functional with these versions: - - GNU Libtool 1.4.2 - - GNU Autoconf 2.59 - - GNU Automake 1.7 - - GNU M4 1.4 - - perl 5.8 (5.22 on Windows) - - roffit 0.5 - - cmake 3.7 + - GNU libtool 1.4.2 (2001-09-11) + - GNU autoconf 2.59 (2003-11-06) + - GNU automake 1.7 (2002-09-25) + - GNU m4 1.4 (2007-09-21) + - perl 5.8 (2002-07-19), on Windows: 5.22 (2015-06-01) + - cmake 3.7 (2016-11-11) Library Symbols =============== From ee97c2a96a07bad19504973df1384b18419a8eac Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Mon, 24 Nov 2025 15:55:17 +0100 Subject: [PATCH 044/415] tests/server: use curlx file open/close functions Replace: - `open()` with `curlx_open()` (1 call). - `fopen()` with `curlx_fopen()`. - `fclose()` with `curlx_fclose()`. To centralize interacting with the CRT in preparation for using "safe" alternatives on Windows. This also adds long-filename and Unicode support for these operations on Windows. Keep using `open()` in the signal handler to avoid any issues with calling code not allowed in signal handlers. Cherry-picked from #19643 Closes #19679 --- tests/server/.checksrc | 2 -- tests/server/dnsd.c | 10 +++++----- tests/server/mqttd.c | 10 +++++----- tests/server/rtspd.c | 14 +++++++------- tests/server/socksd.c | 8 ++++---- tests/server/sws.c | 18 +++++++++--------- tests/server/tftpd.c | 20 ++++++++++---------- tests/server/util.c | 18 +++++++++--------- 8 files changed, 49 insertions(+), 51 deletions(-) diff --git a/tests/server/.checksrc b/tests/server/.checksrc index a4e094e1c913..0386c677e6c3 100644 --- a/tests/server/.checksrc +++ b/tests/server/.checksrc @@ -3,8 +3,6 @@ # SPDX-License-Identifier: curl allowfunc accept -allowfunc fclose -allowfunc fopen allowfunc fprintf allowfunc freeaddrinfo allowfunc getaddrinfo diff --git a/tests/server/dnsd.c b/tests/server/dnsd.c index c541b05295b2..9b3a42e1590c 100644 --- a/tests/server/dnsd.c +++ b/tests/server/dnsd.c @@ -102,7 +102,7 @@ static int store_incoming(const unsigned char *data, size_t size, snprintf(dumpfile, sizeof(dumpfile), "%s/dnsd.input", logdir); /* Open request dump file. */ - server = fopen(dumpfile, "ab"); + server = curlx_fopen(dumpfile, "ab"); if(!server) { char errbuf[STRERROR_LEN]; int error = errno; @@ -162,7 +162,7 @@ static int store_incoming(const unsigned char *data, size_t size, if(*qlen > qbuflen) { logmsg("dnsd: query too large: %lu > %lu", (unsigned long)*qlen, (unsigned long)qbuflen); - fclose(server); + curlx_fclose(server); return -1; } memcpy(qbuf, qptr, *qlen); @@ -176,7 +176,7 @@ static int store_incoming(const unsigned char *data, size_t size, fprintf(server, "\n"); #endif - fclose(server); + curlx_fclose(server); return 0; } @@ -325,7 +325,7 @@ static void read_instructions(void) char file[256]; FILE *f; snprintf(file, sizeof(file), "%s/" INSTRUCTIONS, logdir); - f = fopen(file, FOPEN_READTEXT); + f = curlx_fopen(file, FOPEN_READTEXT); if(f) { char buf[256]; ancount_aaaa = ancount_a = 0; @@ -375,7 +375,7 @@ static void read_instructions(void) } } } - fclose(f); + curlx_fclose(f); } else logmsg("Error opening file '%s'", file); diff --git a/tests/server/mqttd.c b/tests/server/mqttd.c index 2701d61260e0..59c7540dcfc3 100644 --- a/tests/server/mqttd.c +++ b/tests/server/mqttd.c @@ -73,7 +73,7 @@ static void mqttd_resetdefaults(void) static void mqttd_getconfig(void) { - FILE *fp = fopen(configfile, FOPEN_READTEXT); + FILE *fp = curlx_fopen(configfile, FOPEN_READTEXT); mqttd_resetdefaults(); if(fp) { char buffer[512]; @@ -119,7 +119,7 @@ static void mqttd_getconfig(void) } } } - fclose(fp); + curlx_fclose(fp); } else { logmsg("No config file '%s' to read", configfile); @@ -430,7 +430,7 @@ static curl_socket_t mqttit(curl_socket_t fd) 0x04 /* protocol level */ }; snprintf(dumpfile, sizeof(dumpfile), "%s/%s", logdir, REQUEST_DUMP); - dump = fopen(dumpfile, "ab"); + dump = curlx_fopen(dumpfile, "ab"); if(!dump) goto end; @@ -636,9 +636,9 @@ static curl_socket_t mqttit(curl_socket_t fd) if(buffer) free(buffer); if(dump) - fclose(dump); + curlx_fclose(dump); if(stream) - fclose(stream); + curlx_fclose(stream); return CURL_SOCKET_BAD; } diff --git a/tests/server/rtspd.c b/tests/server/rtspd.c index 5ffd0f28e5ee..335bbaaa69de 100644 --- a/tests/server/rtspd.c +++ b/tests/server/rtspd.c @@ -255,7 +255,7 @@ static int rtspd_ProcessRequest(struct rtspd_httprequest *req) /* get the custom server control "commands" */ int error = getpart(&cmd, &cmdsize, "reply", "servercmd", stream); - fclose(stream); + curlx_fclose(stream); if(error) { logmsg("getpart() failed with error (%d)", error); req->open = FALSE; /* closes connection */ @@ -557,7 +557,7 @@ static void rtspd_storerequest(char *reqbuf, size_t totalsize) return; do { - dump = fopen(dumpfile, "ab"); + dump = curlx_fopen(dumpfile, "ab"); /* !checksrc! disable ERRNOVAR 1 */ } while(!dump && ((error = errno) == EINTR)); if(!dump) { @@ -589,7 +589,7 @@ static void rtspd_storerequest(char *reqbuf, size_t totalsize) storerequest_cleanup: - res = fclose(dump); + res = curlx_fclose(dump); if(res) logmsg("Error closing file %s error (%d) %s", dumpfile, errno, curlx_strerror(errno, errbuf, sizeof(errbuf))); @@ -815,7 +815,7 @@ static int rtspd_send_doc(curl_socket_t sock, struct rtspd_httprequest *req) } else { error = getpart(&ptr, &count, "reply", partbuf, stream); - fclose(stream); + curlx_fclose(stream); if(error) { logmsg("getpart() failed with error (%d)", error); return 0; @@ -841,7 +841,7 @@ static int rtspd_send_doc(curl_socket_t sock, struct rtspd_httprequest *req) else { /* get the custom server control "commands" */ error = getpart(&cmd, &cmdsize, "reply", "postcmd", stream); - fclose(stream); + curlx_fclose(stream); if(error) { logmsg("getpart() failed with error (%d)", error); free(ptr); @@ -870,7 +870,7 @@ static int rtspd_send_doc(curl_socket_t sock, struct rtspd_httprequest *req) else rtspd_prevbounce = FALSE; - dump = fopen(responsedump, "ab"); + dump = curlx_fopen(responsedump, "ab"); if(!dump) { error = errno; logmsg("fopen() failed with error (%d) %s", @@ -928,7 +928,7 @@ static int rtspd_send_doc(curl_socket_t sock, struct rtspd_httprequest *req) req->rtp_buffersize = 0; } - res = fclose(dump); + res = curlx_fclose(dump); if(res) logmsg("Error closing file %s error (%d) %s", responsedump, errno, curlx_strerror(errno, errbuf, sizeof(errbuf))); diff --git a/tests/server/socksd.c b/tests/server/socksd.c index 1a1d40113bf8..4205d26880bd 100644 --- a/tests/server/socksd.c +++ b/tests/server/socksd.c @@ -108,7 +108,7 @@ static void socksd_resetdefaults(void) static void socksd_getconfig(void) { - FILE *fp = fopen(configfile, FOPEN_READTEXT); + FILE *fp = curlx_fopen(configfile, FOPEN_READTEXT); socksd_resetdefaults(); if(fp) { char buffer[512]; @@ -180,7 +180,7 @@ static void socksd_getconfig(void) } } } - fclose(fp); + curlx_fclose(fp); } } @@ -470,7 +470,7 @@ static curl_socket_t sockit(curl_socket_t fd) { FILE *dump; - dump = fopen(reqlogfile, "ab"); + dump = curlx_fopen(reqlogfile, "ab"); if(dump) { int i; fprintf(dump, "atyp %u =>", type); @@ -493,7 +493,7 @@ static curl_socket_t sockit(curl_socket_t fd) fprintf(dump, "\n"); break; } - fclose(dump); + curlx_fclose(dump); } } diff --git a/tests/server/sws.c b/tests/server/sws.c index d590cd6fef69..b070614f525e 100644 --- a/tests/server/sws.c +++ b/tests/server/sws.c @@ -178,7 +178,7 @@ static bool socket_domain_is_ip(void) /* parse the file on disk that might have a test number for us */ static int parse_cmdfile(struct sws_httprequest *req) { - FILE *f = fopen(cmdfile, FOPEN_READTEXT); + FILE *f = curlx_fopen(cmdfile, FOPEN_READTEXT); if(f) { int testnum = DOCNUMBER_NOTHING; char buf[256]; @@ -188,7 +188,7 @@ static int parse_cmdfile(struct sws_httprequest *req) req->testno = testnum; } } - fclose(f); + curlx_fclose(f); } return 0; } @@ -220,7 +220,7 @@ static int sws_parse_servercmd(struct sws_httprequest *req) /* get the custom server control "commands" */ error = getpart(&orgcmd, &cmdsize, "reply", "servercmd", stream); - fclose(stream); + curlx_fclose(stream); if(error) { logmsg("getpart() failed with error (%d)", error); req->open = FALSE; /* closes connection */ @@ -734,7 +734,7 @@ static void sws_storerequest(const char *reqbuf, size_t totalsize) return; do { - dump = fopen(dumpfile, "ab"); + dump = curlx_fopen(dumpfile, "ab"); /* !checksrc! disable ERRNOVAR 1 */ } while(!dump && ((error = errno) == EINTR)); if(!dump) { @@ -766,7 +766,7 @@ static void sws_storerequest(const char *reqbuf, size_t totalsize) storerequest_cleanup: - res = fclose(dump); + res = curlx_fclose(dump); if(res) logmsg("Error closing file %s error (%d) %s", dumpfile, errno, curlx_strerror(errno, errbuf, sizeof(errbuf))); @@ -1050,7 +1050,7 @@ static int sws_send_doc(curl_socket_t sock, struct sws_httprequest *req) } else { error = getpart(&ptr, &count, "reply", partbuf, stream); - fclose(stream); + curlx_fclose(stream); if(error) { logmsg("getpart() failed with error (%d)", error); return 0; @@ -1075,7 +1075,7 @@ static int sws_send_doc(curl_socket_t sock, struct sws_httprequest *req) else { /* get the custom server control "commands" */ error = getpart(&cmd, &cmdsize, "reply", "postcmd", stream); - fclose(stream); + curlx_fclose(stream); if(error) { logmsg("getpart() failed with error (%d)", error); free(ptr); @@ -1104,7 +1104,7 @@ static int sws_send_doc(curl_socket_t sock, struct sws_httprequest *req) else sws_prevbounce = FALSE; - dump = fopen(responsedump, "ab"); + dump = curlx_fopen(responsedump, "ab"); if(!dump) { error = errno; logmsg("fopen() failed with error (%d) %s", @@ -1158,7 +1158,7 @@ static int sws_send_doc(curl_socket_t sock, struct sws_httprequest *req) } } while((count > 0) && !got_exit_signal); - res = fclose(dump); + res = curlx_fclose(dump); if(res) logmsg("Error closing file %s error (%d) %s", responsedump, errno, curlx_strerror(errno, errbuf, sizeof(errbuf))); diff --git a/tests/server/tftpd.c b/tests/server/tftpd.c index 6631e2439b96..2eb31ff5ece8 100644 --- a/tests/server/tftpd.c +++ b/tests/server/tftpd.c @@ -445,13 +445,13 @@ static ssize_t write_behind(struct testcase *test, int convert) if(!test->ofile) { char outfile[256]; snprintf(outfile, sizeof(outfile), "%s/upload.%ld", logdir, test->testno); - test->ofile = open(outfile, O_CREAT | O_RDWR | CURL_O_BINARY, + test->ofile = curlx_open(outfile, O_CREAT | O_RDWR | CURL_O_BINARY, #ifdef _WIN32 - S_IREAD | S_IWRITE + S_IREAD | S_IWRITE #else - S_IRUSR | S_IWUSR | S_IXUSR | - S_IRGRP | S_IWGRP | S_IXGRP | - S_IROTH | S_IWOTH | S_IXOTH + S_IRUSR | S_IWUSR | S_IXUSR | + S_IRGRP | S_IWGRP | S_IXGRP | + S_IROTH | S_IWOTH | S_IXOTH #endif ); if(test->ofile == -1) { @@ -910,7 +910,7 @@ static int do_tftp(struct testcase *test, struct tftphdr *tp, ssize_t size) snprintf(dumpfile, sizeof(dumpfile), "%s/%s", logdir, REQUEST_DUMP); /* Open request dump file. */ - server = fopen(dumpfile, "ab"); + server = curlx_fopen(dumpfile, "ab"); if(!server) { char errbuf[STRERROR_LEN]; int error = errno; @@ -963,7 +963,7 @@ static int do_tftp(struct testcase *test, struct tftphdr *tp, ssize_t size) if(*cp || !mode) { nak(TFTP_EBADOP); - fclose(server); + curlx_fclose(server); return 3; } @@ -975,7 +975,7 @@ static int do_tftp(struct testcase *test, struct tftphdr *tp, ssize_t size) *cp = (char)tolower((int)*cp); /* store input protocol */ - fclose(server); + curlx_fclose(server); for(pf = formata; pf->f_mode; pf++) if(strcmp(pf->f_mode, mode) == 0) @@ -1036,7 +1036,7 @@ static int tftpd_parse_servercmd(struct testcase *req) /* get the custom server control "commands" */ error = getpart(&orgcmd, &cmdsize, "reply", "servercmd", stream); - fclose(stream); + curlx_fclose(stream); if(error) { logmsg("getpart() failed with error (%d)", error); return 1; /* done */ @@ -1155,7 +1155,7 @@ static int validate_access(struct testcase *test, else { size_t count; int error = getpart(&test->buffer, &count, "reply", partbuf, stream); - fclose(stream); + curlx_fclose(stream); if(error) { logmsg("getpart() failed with error (%d)", error); return TFTP_EACCESS; diff --git a/tests/server/util.c b/tests/server/util.c index 6551e4742635..8d8bf12c99dd 100644 --- a/tests/server/util.c +++ b/tests/server/util.c @@ -115,12 +115,12 @@ void logmsg(const char *msg, ...) va_end(ap); do { - logfp = fopen(serverlogfile, "ab"); + logfp = curlx_fopen(serverlogfile, "ab"); /* !checksrc! disable ERRNOVAR 1 */ } while(!logfp && (errno == EINTR)); if(logfp) { fprintf(logfp, "%s %s\n", timebuf, buffer); - fclose(logfp); + curlx_fclose(logfp); } else { char errbuf[STRERROR_LEN]; @@ -193,7 +193,7 @@ FILE *test2fopen(long testno, const char *logdir2) char filename[256]; /* first try the alternative, preprocessed, file */ snprintf(filename, sizeof(filename), "%s/test%ld", logdir2, testno); - stream = fopen(filename, "rb"); + stream = curlx_fopen(filename, "rb"); return stream; } @@ -224,7 +224,7 @@ int write_pidfile(const char *filename) curl_off_t pid; pid = our_getpid(); - pidfile = fopen(filename, "wb"); + pidfile = curlx_fopen(filename, "wb"); if(!pidfile) { char errbuf[STRERROR_LEN]; logmsg("Could not write pid file: %s (%d) %s", filename, @@ -232,7 +232,7 @@ int write_pidfile(const char *filename) return 0; /* fail */ } fprintf(pidfile, "%ld\n", (long)pid); - fclose(pidfile); + curlx_fclose(pidfile); logmsg("Wrote pid %ld to %s", (long)pid, filename); return 1; /* success */ } @@ -240,7 +240,7 @@ int write_pidfile(const char *filename) /* store the used port number in a file */ int write_portfile(const char *filename, int port) { - FILE *portfile = fopen(filename, "wb"); + FILE *portfile = curlx_fopen(filename, "wb"); if(!portfile) { char errbuf[STRERROR_LEN]; logmsg("Could not write port file: %s (%d) %s", filename, @@ -248,7 +248,7 @@ int write_portfile(const char *filename, int port) return 0; /* fail */ } fprintf(portfile, "%d\n", port); - fclose(portfile); + curlx_fclose(portfile); logmsg("Wrote port %d to %s", port, filename); return 1; /* success */ } @@ -261,7 +261,7 @@ void set_advisor_read_lock(const char *filename) int res; do { - lockfile = fopen(filename, "wb"); + lockfile = curlx_fopen(filename, "wb"); /* !checksrc! disable ERRNOVAR 1 */ } while(!lockfile && ((error = errno) == EINTR)); if(!lockfile) { @@ -270,7 +270,7 @@ void set_advisor_read_lock(const char *filename) return; } - res = fclose(lockfile); + res = curlx_fclose(lockfile); if(res) logmsg("Error closing lock file %s error (%d) %s", filename, errno, curlx_strerror(errno, errbuf, sizeof(errbuf))); From 1e7d0bafc6d25d98ec72ff419df65fda3cf147a7 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Tue, 18 Nov 2025 01:32:43 +0100 Subject: [PATCH 045/415] curlx/fopen: replace open CRT functions their with `_s` counterparts (Windows) - `_wopen` -> `_wsopen_s` - `_open`, `open` -> `_sopen_s` - `_wfopen` -> `_wfopen_s` - `fopen` -> `fopen_s` - `_wfreopen` -> `_wfreopen_s` - `freopen` -> `freopen_s` For better error handling and for using the CRT functions recommended via warnings suppressed by `_CRT_SECURE_NO_WARNINGS`. Also: - add missing `freopen_s()` prototype when building with mingw-w64 <5. https://sourceforge.net/p/mingw-w64/mingw-w64/ci/a5d824654cdc57f6eac1bb581b078986f3eb6856/ - tests/server: replace `open()` in the signal handler with `_sopen_s()` on Windows. - tests/server: reduce scope of a checksrc exception to a single line. - checksrc: ban replaced functions. Refs: https://learn.microsoft.com/cpp/c-runtime-library/reference/open-wopen https://learn.microsoft.com/cpp/c-runtime-library/reference/sopen-s-wsopen-s https://learn.microsoft.com/cpp/c-runtime-library/reference/freopen-wfreopen https://learn.microsoft.com/cpp/c-runtime-library/reference/fopen-wfopen https://learn.microsoft.com/cpp/c-runtime-library/reference/fopen-s-wfopen-s https://learn.microsoft.com/cpp/c-runtime-library/reference/freopen-s-wfreopen-s Closes #19643 --- lib/curl_setup.h | 5 ++--- lib/curlx/fopen.c | 21 +++++++++++++-------- scripts/checksrc.pl | 4 ++++ tests/server/.checksrc | 1 - tests/server/util.c | 16 ++++++++++++---- 5 files changed, 31 insertions(+), 16 deletions(-) diff --git a/lib/curl_setup.h b/lib/curl_setup.h index 886a8814936a..0e5ebb60c9ef 100644 --- a/lib/curl_setup.h +++ b/lib/curl_setup.h @@ -95,10 +95,9 @@ unlink(), etc. */ #endif #ifndef _CRT_SECURE_NO_WARNINGS -#define _CRT_SECURE_NO_WARNINGS /* for _open(), _wfopen(), _wopen(), fopen(), - freopen(), getenv(), gmtime(), sprintf(), +#define _CRT_SECURE_NO_WARNINGS /* for getenv(), gmtime(), sprintf(), strcpy(), - in tests: localtime(), open(), sscanf() */ + in tests: localtime(), sscanf() */ #endif #endif /* _MSC_VER */ diff --git a/lib/curlx/fopen.c b/lib/curlx/fopen.c index dc1c2bb4e67d..0dc9699206cd 100644 --- a/lib/curlx/fopen.c +++ b/lib/curlx/fopen.c @@ -51,6 +51,8 @@ int curlx_fseek(void *stream, curl_off_t offset, int whence) #include "multibyte.h" +#include /* for _SH_DENYNO */ + /* declare GetFullPathNameW for mingw-w64 UWP builds targeting old windows */ #if defined(CURL_WINDOWS_UWP) && defined(__MINGW32__) && \ (_WIN32_WINNT < _WIN32_WINNT_WIN10) @@ -244,7 +246,7 @@ int curlx_win32_open(const char *filename, int oflag, ...) target = fixed; else target = filename_w; - result = _wopen(target, oflag, pmode); + errno = _wsopen_s(&result, target, oflag, _SH_DENYNO, pmode); curlx_unicodefree(filename_w); } else @@ -255,7 +257,7 @@ int curlx_win32_open(const char *filename, int oflag, ...) target = fixed; else target = filename; - result = _open(target, oflag, pmode); + errno = _sopen_s(&result, target, oflag, _SH_DENYNO, pmode); #endif (free)(fixed); @@ -276,7 +278,7 @@ FILE *curlx_win32_fopen(const char *filename, const char *mode) target = fixed; else target = filename_w; - result = _wfopen(target, mode_w); + errno = _wfopen_s(&result, target, mode_w); } else /* !checksrc! disable ERRNOVAR 1 */ @@ -288,14 +290,18 @@ FILE *curlx_win32_fopen(const char *filename, const char *mode) target = fixed; else target = filename; - /* !checksrc! disable BANNEDFUNC 1 */ - result = fopen(target, mode); + errno = fopen_s(&result, target, mode); #endif (free)(fixed); return result; } +#if defined(__MINGW32__) && (__MINGW64_VERSION_MAJOR < 5) +_CRTIMP errno_t __cdecl freopen_s(FILE **file, const char *filename, + const char *mode, FILE *stream); +#endif + FILE *curlx_win32_freopen(const char *filename, const char *mode, FILE *fp) { FILE *result = NULL; @@ -310,7 +316,7 @@ FILE *curlx_win32_freopen(const char *filename, const char *mode, FILE *fp) target = fixed; else target = filename_w; - result = _wfreopen(target, mode_w, fp); + errno = _wfreopen_s(&result, target, mode_w, fp); } else /* !checksrc! disable ERRNOVAR 1 */ @@ -322,8 +328,7 @@ FILE *curlx_win32_freopen(const char *filename, const char *mode, FILE *fp) target = fixed; else target = filename; - /* !checksrc! disable BANNEDFUNC 1 */ - result = freopen(target, mode, fp); + errno = freopen_s(&result, target, mode, fp); #endif (free)(fixed); diff --git a/scripts/checksrc.pl b/scripts/checksrc.pl index a2f458b6c1ac..d38ffecdb9b1 100755 --- a/scripts/checksrc.pl +++ b/scripts/checksrc.pl @@ -113,6 +113,10 @@ "fopen" => 1, "freopen" => 1, "open" => 1, + "_open" => 1, + "_wfopen" => 1, + "_wfreopen" => 1, + "_wopen" => 1, "stat" => 1, ); diff --git a/tests/server/.checksrc b/tests/server/.checksrc index 0386c677e6c3..163a217ee4be 100644 --- a/tests/server/.checksrc +++ b/tests/server/.checksrc @@ -6,7 +6,6 @@ allowfunc accept allowfunc fprintf allowfunc freeaddrinfo allowfunc getaddrinfo -allowfunc open allowfunc printf allowfunc recv allowfunc send diff --git a/tests/server/util.c b/tests/server/util.c index 8d8bf12c99dd..ae21ff8b1af8 100644 --- a/tests/server/util.c +++ b/tests/server/util.c @@ -27,6 +27,10 @@ #include #endif +#ifdef _WIN32 +#include +#endif + /* This function returns a pointer to STATIC memory. It converts the given * binary lump to a hex formatted string usable for output in logs or * whatever. @@ -359,13 +363,17 @@ static void exit_signal_handler(int signum) (void)!write(STDERR_FILENO, msg, sizeof(msg) - 1); } else { + int fd = -1; #ifdef _WIN32 -#define OPENMODE S_IREAD | S_IWRITE + if(!_sopen_s(&fd, serverlogfile, O_WRONLY | O_CREAT | O_APPEND, + _SH_DENYNO, S_IREAD | S_IWRITE) && + fd != -1) { #else -#define OPENMODE S_IRUSR | S_IWUSR -#endif - int fd = open(serverlogfile, O_WRONLY | O_CREAT | O_APPEND, OPENMODE); + /* !checksrc! disable BANNEDFUNC 1 */ + fd = open(serverlogfile, + O_WRONLY | O_CREAT | O_APPEND, S_IRUSR | S_IWUSR); if(fd != -1) { +#endif static const char msg[] = "exit_signal_handler: called\n"; (void)!write(fd, msg, sizeof(msg) - 1); close(fd); From a075d1c0d8684c0151cebf50b5cb64be6505c59d Mon Sep 17 00:00:00 2001 From: Sunny Date: Tue, 25 Nov 2025 08:29:32 +0100 Subject: [PATCH 046/415] examples: fix minor typo Closes #19683 --- docs/examples/https.c | 2 +- docs/examples/imap-ssl.c | 2 +- docs/examples/pop3-ssl.c | 2 +- docs/examples/smtp-ssl.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/examples/https.c b/docs/examples/https.c index 905cdb07f23b..02fd8b87bd16 100644 --- a/docs/examples/https.c +++ b/docs/examples/https.c @@ -57,7 +57,7 @@ int main(void) #ifdef SKIP_HOSTNAME_VERIFICATION /* - * If the site you are connecting to uses a different hostname that what + * If the site you are connecting to uses a different hostname than what * they have mentioned in their server certificate's commonName (or * subjectAltName) fields, libcurl refuses to connect. You can skip this * check, but it makes the connection insecure. diff --git a/docs/examples/imap-ssl.c b/docs/examples/imap-ssl.c index d56d89331ac4..259eddc26f6a 100644 --- a/docs/examples/imap-ssl.c +++ b/docs/examples/imap-ssl.c @@ -67,7 +67,7 @@ int main(void) curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L); #endif - /* If the site you are connecting to uses a different hostname that what + /* If the site you are connecting to uses a different hostname than what * they have mentioned in their server certificate's commonName (or * subjectAltName) fields, libcurl refuses to connect. You can skip this * check, but it makes the connection insecure. */ diff --git a/docs/examples/pop3-ssl.c b/docs/examples/pop3-ssl.c index 0f5ac3692d83..4dd808c3f114 100644 --- a/docs/examples/pop3-ssl.c +++ b/docs/examples/pop3-ssl.c @@ -66,7 +66,7 @@ int main(void) curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L); #endif - /* If the site you are connecting to uses a different hostname that what + /* If the site you are connecting to uses a different hostname than what * they have mentioned in their server certificate's commonName (or * subjectAltName) fields, libcurl refuses to connect. You can skip this * check, but it makes the connection insecure. */ diff --git a/docs/examples/smtp-ssl.c b/docs/examples/smtp-ssl.c index a87a033fc4aa..4ebc58f1b5dd 100644 --- a/docs/examples/smtp-ssl.c +++ b/docs/examples/smtp-ssl.c @@ -115,7 +115,7 @@ int main(void) curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L); #endif - /* If the site you are connecting to uses a different hostname that what + /* If the site you are connecting to uses a different hostname than what * they have mentioned in their server certificate's commonName (or * subjectAltName) fields, libcurl refuses to connect. You can skip this * check, but it makes the connection insecure. */ From ce06fe7771052549ff430c86173b2eaca91f8a9c Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 24 Nov 2025 14:00:09 +0100 Subject: [PATCH 047/415] hostip: make more functions return CURLcode - Curl_async_getaddrinfo() always returned NULL so it was pointless. Return proper curlcode instead to distinguish between errors. Same for Curl_doh(). - simplify the IP address handling - make Curl_str2addr() function return CURLcode Closes #19669 --- lib/asyn-ares.c | 22 +++---- lib/asyn-thrdd.c | 17 ++---- lib/asyn.h | 7 +-- lib/curl_addrinfo.c | 41 +++++++++---- lib/curl_addrinfo.h | 6 +- lib/doh.c | 22 ++++--- lib/doh.h | 11 ++-- lib/hostip.c | 132 +++++++++++++++++------------------------ tests/libtest/lib655.c | 4 +- 9 files changed, 117 insertions(+), 145 deletions(-) diff --git a/lib/asyn-ares.c b/lib/asyn-ares.c index ab57d5e00b41..d459fd4a75cd 100644 --- a/lib/asyn-ares.c +++ b/lib/asyn-ares.c @@ -718,25 +718,18 @@ static void async_ares_rr_done(void *user_data, ares_status_t status, /* * Curl_async_getaddrinfo() - when using ares * - * Returns name information about the given hostname and port number. If - * successful, the 'hostent' is returned and the fourth argument will point to - * memory we need to free after use. That memory *MUST* be freed with - * Curl_freeaddrinfo(), nothing else. + * Starts a name resolve for the given hostname and port number. */ -struct Curl_addrinfo *Curl_async_getaddrinfo(struct Curl_easy *data, - const char *hostname, - int port, - int ip_version, - int *waitp) +CURLcode Curl_async_getaddrinfo(struct Curl_easy *data, const char *hostname, + int port, int ip_version) { struct async_ares_ctx *ares = &data->state.async.ares; #ifdef USE_HTTPSRR char *rrname = NULL; #endif - *waitp = 0; /* default to synchronous response */ if(async_ares_init_lazy(data)) - return NULL; + return CURLE_FAILED_INIT; data->state.async.done = FALSE; /* not done */ data->state.async.dns = NULL; /* clear */ @@ -744,12 +737,12 @@ struct Curl_addrinfo *Curl_async_getaddrinfo(struct Curl_easy *data, data->state.async.ip_version = ip_version; data->state.async.hostname = strdup(hostname); if(!data->state.async.hostname) - return NULL; + return CURLE_OUT_OF_MEMORY; #ifdef USE_HTTPSRR if(port != 443) { rrname = curl_maprintf("_%d_.https.%s", port, hostname); if(!rrname) - return NULL; + return CURLE_OUT_OF_MEMORY; } #endif @@ -836,9 +829,8 @@ struct Curl_addrinfo *Curl_async_getaddrinfo(struct Curl_easy *data, async_ares_rr_done, data, NULL); } #endif - *waitp = 1; /* expect asynchronous response */ - return NULL; /* no struct yet */ + return CURLE_OK; } /* Set what DNS server are is to use. This is called in 2 situations: diff --git a/lib/asyn-thrdd.c b/lib/asyn-thrdd.c index f4f57b547a01..71e31e6d0d16 100644 --- a/lib/asyn-thrdd.c +++ b/lib/asyn-thrdd.c @@ -755,15 +755,11 @@ struct Curl_addrinfo *Curl_async_getaddrinfo(struct Curl_easy *data, /* * Curl_async_getaddrinfo() - for getaddrinfo */ -struct Curl_addrinfo *Curl_async_getaddrinfo(struct Curl_easy *data, - const char *hostname, - int port, - int ip_version, - int *waitp) +CURLcode Curl_async_getaddrinfo(struct Curl_easy *data, const char *hostname, + int port, int ip_version) { struct addrinfo hints; int pf = PF_INET; - *waitp = 0; /* default to synchronous response */ CURL_TRC_DNS(data, "init threaded resolve of %s:%d", hostname, port); #ifdef CURLRES_IPV6 @@ -785,14 +781,11 @@ struct Curl_addrinfo *Curl_async_getaddrinfo(struct Curl_easy *data, SOCK_STREAM : SOCK_DGRAM; /* fire up a new resolver thread! */ - if(async_thrdd_init(data, hostname, port, ip_version, &hints)) { - *waitp = 1; /* expect asynchronous response */ - return NULL; - } + if(async_thrdd_init(data, hostname, port, ip_version, &hints)) + return CURLE_OK; failf(data, "getaddrinfo() thread failed to start"); - return NULL; - + return CURLE_FAILED_INIT; } #endif /* !HAVE_GETADDRINFO */ diff --git a/lib/asyn.h b/lib/asyn.h index 7863042bbe37..8da7dd9720cc 100644 --- a/lib/asyn.h +++ b/lib/asyn.h @@ -118,11 +118,8 @@ CURLcode Curl_async_await(struct Curl_easy *data, * Each resolver backend must of course make sure to return data in the * correct format to comply with this. */ -struct Curl_addrinfo *Curl_async_getaddrinfo(struct Curl_easy *data, - const char *hostname, - int port, - int ip_version, - int *waitp); +CURLcode Curl_async_getaddrinfo(struct Curl_easy *data, const char *hostname, + int port, int ip_version); #ifdef USE_ARES /* common functions for c-ares and threaded resolver with HTTPSRR */ diff --git a/lib/curl_addrinfo.c b/lib/curl_addrinfo.c index fc26bef8333d..cd9b52febaa7 100644 --- a/lib/curl_addrinfo.c +++ b/lib/curl_addrinfo.c @@ -347,7 +347,7 @@ Curl_he2ai(const struct hostent *he, int port) #endif /* - * Curl_ip2addr() + * ip2addr() * * This function takes an Internet address, in binary form, as input parameter * along with its address family and the string version of the address, and it @@ -355,8 +355,9 @@ Curl_he2ai(const struct hostent *he, int port) * given address/host */ -struct Curl_addrinfo * -Curl_ip2addr(int af, const void *inaddr, const char *hostname, int port) +static CURLcode +ip2addr(struct Curl_addrinfo **addrp, + int af, const void *inaddr, const char *hostname, int port) { struct Curl_addrinfo *ai; size_t addrsize; @@ -369,6 +370,7 @@ Curl_ip2addr(int af, const void *inaddr, const char *hostname, int port) DEBUGASSERT(inaddr && hostname); namelen = strlen(hostname) + 1; + *addrp = NULL; if(af == AF_INET) addrsize = sizeof(struct sockaddr_in); @@ -377,12 +379,12 @@ Curl_ip2addr(int af, const void *inaddr, const char *hostname, int port) addrsize = sizeof(struct sockaddr_in6); #endif else - return NULL; + return CURLE_BAD_FUNCTION_ARGUMENT; /* allocate memory to hold the struct, the address and the name */ ai = calloc(1, sizeof(struct Curl_addrinfo) + addrsize + namelen); if(!ai) - return NULL; + return CURLE_OUT_OF_MEMORY; /* put the address after the struct */ ai->ai_addr = (void *)((char *)ai + sizeof(struct Curl_addrinfo)); /* then put the name after the address */ @@ -412,29 +414,46 @@ Curl_ip2addr(int af, const void *inaddr, const char *hostname, int port) break; #endif } - - return ai; + *addrp = ai; + return CURLE_OK; } /* * 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) +CURLcode Curl_str2addr(const char *address, int port, + struct Curl_addrinfo **addrp) { struct in_addr in; if(curlx_inet_pton(AF_INET, address, &in) > 0) /* This is a dotted IP address 123.123.123.123-style */ - return Curl_ip2addr(AF_INET, &in, address, port); + return ip2addr(addrp, AF_INET, &in, address, port); +#ifdef USE_IPV6 + { + struct in6_addr in6; + if(curlx_inet_pton(AF_INET6, address, &in6) > 0) + /* This is a dotted IPv6 address ::1-style */ + return ip2addr(addrp, AF_INET6, &in6, address, port); + } +#endif + return CURLE_BAD_FUNCTION_ARGUMENT; /* bad input format */ +} + +bool Curl_is_ipaddr(const char *address) +{ + struct in_addr in; + if(curlx_inet_pton(AF_INET, address, &in) > 0) + return TRUE; #ifdef USE_IPV6 { struct in6_addr in6; if(curlx_inet_pton(AF_INET6, address, &in6) > 0) /* This is a dotted IPv6 address ::1-style */ - return Curl_ip2addr(AF_INET6, &in6, address, port); + return TRUE; } #endif - return NULL; /* bad input format */ + return FALSE; } #ifdef USE_UNIX_SOCKETS diff --git a/lib/curl_addrinfo.h b/lib/curl_addrinfo.h index 2303e95e314e..9a26c6784912 100644 --- a/lib/curl_addrinfo.h +++ b/lib/curl_addrinfo.h @@ -76,10 +76,8 @@ struct Curl_addrinfo * Curl_he2ai(const struct hostent *he, int port); #endif -struct Curl_addrinfo * -Curl_ip2addr(int af, const void *inaddr, const char *hostname, int port); - -struct Curl_addrinfo *Curl_str2addr(char *dotted, int port); +bool Curl_is_ipaddr(const char *address); +CURLcode Curl_str2addr(const char *dotted, int port, struct Curl_addrinfo **); #ifdef USE_UNIX_SOCKETS struct Curl_addrinfo *Curl_unix2addr(const char *path, bool *longpath, diff --git a/lib/doh.c b/lib/doh.c index 45524edf4c0b..83a83f534672 100644 --- a/lib/doh.c +++ b/lib/doh.c @@ -441,15 +441,12 @@ static CURLcode doh_probe_run(struct Curl_easy *data, } /* - * Curl_doh() resolves a name using DoH. It resolves a name and returns a - * 'Curl_addrinfo *' with the address information. + * Curl_doh() starts a name resolve using DoH. It resolves a name and returns + * a 'Curl_addrinfo *' with the address information. */ -struct Curl_addrinfo *Curl_doh(struct Curl_easy *data, - const char *hostname, - int port, - int ip_version, - int *waitp) +CURLcode Curl_doh(struct Curl_easy *data, const char *hostname, + int port, int ip_version) { CURLcode result = CURLE_OK; struct doh_probes *dohp = NULL; @@ -467,12 +464,12 @@ struct Curl_addrinfo *Curl_doh(struct Curl_easy *data, data->state.async.ip_version = ip_version; data->state.async.hostname = strdup(hostname); if(!data->state.async.hostname) - return NULL; + return CURLE_OUT_OF_MEMORY; /* start clean, consider allocating this struct on demand */ data->state.async.doh = dohp = calloc(1, sizeof(struct doh_probes)); if(!dohp) - return NULL; + return CURLE_OUT_OF_MEMORY; for(i = 0; i < DOH_SLOT_COUNT; ++i) { dohp->probe_resp[i].probe_mid = UINT_MAX; @@ -527,12 +524,11 @@ struct Curl_addrinfo *Curl_doh(struct Curl_easy *data, dohp->pending++; } #endif - *waitp = TRUE; /* this never returns synchronously */ - return NULL; + return CURLE_OK; error: Curl_doh_cleanup(data); - return NULL; + return result; } static DOHcode doh_skipqname(const unsigned char *doh, size_t dohlen, @@ -1300,6 +1296,8 @@ CURLcode Curl_doh_is_resolved(struct Curl_easy *data, result = Curl_dnscache_add(data, dns); *dnsp = data->state.async.dns; } + else + Curl_freeaddrinfo(ai); } /* address processing done */ /* All done */ diff --git a/lib/doh.h b/lib/doh.h index 3fd7de2c1c57..726fb9f73557 100644 --- a/lib/doh.h +++ b/lib/doh.h @@ -112,15 +112,12 @@ struct doh_probes { }; /* - * Curl_doh() resolve a name using DoH (DNS-over-HTTPS). It resolves a name - * and returns a 'Curl_addrinfo *' with the address information. + * Curl_doh() starts a name resolve using DoH (DNS-over-HTTPS). It resolves a + * name and returns a 'Curl_addrinfo *' with the address information. */ -struct Curl_addrinfo *Curl_doh(struct Curl_easy *data, - const char *hostname, - int port, - int ip_version, - int *waitp); +CURLcode Curl_doh(struct Curl_easy *data, const char *hostname, + int port, int ip_version); CURLcode Curl_doh_is_resolved(struct Curl_easy *data, struct Curl_dns_entry **dns); diff --git a/lib/hostip.c b/lib/hostip.c index d5f753f4b4a7..4c1bb9236776 100644 --- a/lib/hostip.c +++ b/lib/hostip.c @@ -509,10 +509,8 @@ Curl_dnscache_mk_entry(struct Curl_easy *data, /* shuffle addresses if requested */ if(data->set.dns_shuffle_addresses) { CURLcode result = Curl_shuffle_addr(data, &addr); - if(result) { - Curl_freeaddrinfo(addr); + if(result) return NULL; - } } #else (void)data; @@ -522,10 +520,8 @@ Curl_dnscache_mk_entry(struct Curl_easy *data, /* Create a new cache entry */ dns = calloc(1, sizeof(struct Curl_dns_entry) + hostlen); - if(!dns) { - Curl_freeaddrinfo(addr); + if(!dns) return NULL; - } dns->refcount = 1; /* the cache has the first reference */ dns->addr = addr; /* this is the address(es) */ @@ -569,6 +565,7 @@ dnscache_add_addr(struct Curl_easy *data, dns2 = Curl_hash_add(&dnscache->entries, entry_id, entry_len + 1, (void *)dns); if(!dns2) { + dns->addr = NULL; dnscache_entry_free(dns); return NULL; } @@ -744,40 +741,6 @@ static bool tailmatch(const char *full, size_t flen, return curl_strnequal(part, &full[flen - plen], plen); } -static struct Curl_addrinfo * -convert_ipaddr_direct(const char *hostname, int port, bool *is_ipaddr) -{ - struct in_addr in; - *is_ipaddr = FALSE; - /* First check if this is an IPv4 address string */ - if(curlx_inet_pton(AF_INET, hostname, &in) > 0) { - /* This is a dotted IP address 123.123.123.123-style */ - *is_ipaddr = TRUE; -#ifdef USE_RESOLVE_ON_IPS - (void)port; - return NULL; -#else - return Curl_ip2addr(AF_INET, &in, hostname, port); -#endif - } -#ifdef USE_IPV6 - else { - struct in6_addr in6; - /* check if this is an IPv6 address string */ - if(curlx_inet_pton(AF_INET6, hostname, &in6) > 0) { - /* This is an IPv6 address literal */ - *is_ipaddr = TRUE; -#ifdef USE_RESOLVE_ON_IPS - return NULL; -#else - return Curl_ip2addr(AF_INET6, &in6, hostname, port); -#endif - } - } -#endif /* USE_IPV6 */ - return NULL; -} - static bool can_resolve_ip_version(struct Curl_easy *data, int ip_version) { #ifdef CURLRES_IPV6 @@ -841,10 +804,10 @@ CURLcode Curl_resolv(struct Curl_easy *data, struct Curl_dnscache *dnscache = dnscache_get(data); struct Curl_dns_entry *dns = NULL; struct Curl_addrinfo *addr = NULL; - int respwait = 0; - bool is_ipaddr; + bool respwait = FALSE; size_t hostname_len; bool keep_negative = TRUE; /* cache a negative result */ + CURLcode result = CURLE_COULDNT_RESOLVE_HOST; *entry = NULL; @@ -853,8 +816,11 @@ CURLcode Curl_resolv(struct Curl_easy *data, #else (void)allowDOH; #endif - if(!dnscache) + DEBUGASSERT(dnscache); + if(!dnscache) { + result = CURLE_BAD_FUNCTION_ARGUMENT; goto error; + } /* We should intentionally error and not resolve .onion TLDs */ hostname_len = strlen(hostname); @@ -874,6 +840,7 @@ CURLcode Curl_resolv(struct Curl_easy *data, dnscache_unlock(data, dnscache); if(dns) { infof(data, "Hostname %s was found in DNS cache", hostname); + result = CURLE_OK; goto out; } @@ -882,7 +849,8 @@ CURLcode Curl_resolv(struct Curl_easy *data, void *resolver = NULL; int st; #ifdef CURLRES_ASYNCH - if(Curl_async_get_impl(data, &resolver)) + result = Curl_async_get_impl(data, &resolver); + if(result) goto error; #endif Curl_set_in_callback(data, TRUE); @@ -891,57 +859,58 @@ CURLcode Curl_resolv(struct Curl_easy *data, Curl_set_in_callback(data, FALSE); if(st) { keep_negative = FALSE; + result = CURLE_ABORTED_BY_CALLBACK; goto error; } } - /* shortcut literal IP addresses, if we are not told to resolve them. */ - addr = convert_ipaddr_direct(hostname, port, &is_ipaddr); - if(addr) - goto out; - + if(Curl_is_ipaddr(hostname)) { #ifndef USE_RESOLVE_ON_IPS - /* allowed to convert, hostname is IP address, then NULL means error */ - if(is_ipaddr) { - keep_negative = FALSE; - goto error; - } + /* shortcut literal IP addresses, if we are not told to resolve them. */ + result = Curl_str2addr(hostname, port, &addr); + if(result) + goto error; + goto out; #endif + } - /* Really need a resolver for hostname. */ - if(ip_version == CURL_IPRESOLVE_V6 && !Curl_ipv6works(data)) - goto error; - - if(!is_ipaddr && - (curl_strequal(hostname, "localhost") || - curl_strequal(hostname, "localhost.") || - tailmatch(hostname, hostname_len, STRCONST(".localhost")) || - tailmatch(hostname, hostname_len, STRCONST(".localhost.")))) { + if(curl_strequal(hostname, "localhost") || + curl_strequal(hostname, "localhost.") || + tailmatch(hostname, hostname_len, STRCONST(".localhost")) || + tailmatch(hostname, hostname_len, STRCONST(".localhost."))) { addr = get_localhost(port, hostname); + result = addr ? CURLE_OK : CURLE_OUT_OF_MEMORY; } #ifndef CURL_DISABLE_DOH - else if(!is_ipaddr && allowDOH && data->set.doh) { - addr = Curl_doh(data, hostname, port, ip_version, &respwait); + else if(!Curl_is_ipaddr(hostname) && allowDOH && data->set.doh) { + result = Curl_doh(data, hostname, port, ip_version); + respwait = TRUE; } #endif else { /* Can we provide the requested IP specifics in resolving? */ - if(!can_resolve_ip_version(data, ip_version)) + if(!can_resolve_ip_version(data, ip_version)) { + result = CURLE_COULDNT_RESOLVE_HOST; goto error; + } #ifdef CURLRES_ASYNCH - addr = Curl_async_getaddrinfo(data, hostname, port, ip_version, &respwait); + result = Curl_async_getaddrinfo(data, hostname, port, ip_version); + respwait = TRUE; #else - respwait = 0; /* no async waiting here */ + respwait = FALSE; /* no async waiting here */ addr = Curl_sync_getaddrinfo(data, hostname, port, ip_version); + if(addr) + result = CURLE_OK; #endif } out: - /* We either have found a `dns` or looked up the `addr` - * or `respwait` is set for an async operation. - * Everything else is a failure to resolve. */ - if(dns) { + /* We either have found a `dns` or looked up the `addr` or `respwait` is set + * for an async operation. Everything else is a failure to resolve. */ + if(result) + ; + else if(dns) { if(!dns->addr) { infof(data, "Negative DNS entry"); dns->refcount--; @@ -955,7 +924,12 @@ CURLcode Curl_resolv(struct Curl_easy *data, dns = Curl_dnscache_mk_entry(data, addr, hostname, 0, port, FALSE); if(!dns || Curl_dnscache_add(data, dns)) { /* this is OOM or similar, do not store such negative resolves */ + Curl_freeaddrinfo(addr); + if(dns) + /* avoid a dangling pointer to addr in the dying dns entry */ + dns->addr = NULL; keep_negative = FALSE; + result = CURLE_OUT_OF_MEMORY; goto error; } show_resolve_info(data, dns); @@ -967,6 +941,7 @@ CURLcode Curl_resolv(struct Curl_easy *data, *entry = dns; return dns ? CURLE_OK : CURLE_AGAIN; } + result = CURLE_COULDNT_RESOLVE_HOST; } error: if(dns) @@ -974,7 +949,8 @@ CURLcode Curl_resolv(struct Curl_easy *data, Curl_async_shutdown(data); if(keep_negative) store_negative_resolve(data, hostname, port); - return CURLE_COULDNT_RESOLVE_HOST; + DEBUGASSERT(result); + return result; } CURLcode Curl_resolv_blocking(struct Curl_easy *data, @@ -1338,6 +1314,7 @@ CURLcode Curl_loadhostpairs(struct Curl_easy *data) while(*host) { struct Curl_str target; struct Curl_addrinfo *ai; + CURLcode result; if(!curlx_str_single(&host, '[')) { if(curlx_str_until(&host, &target, MAX_IPADR_LEN, ']') || @@ -1368,8 +1345,8 @@ CURLcode Curl_loadhostpairs(struct Curl_easy *data) memcpy(address, curlx_str(&target), curlx_strlen(&target)); address[curlx_strlen(&target)] = '\0'; - ai = Curl_str2addr(address, (int)port); - if(!ai) { + result = Curl_str2addr(address, (int)port, &ai); + if(result) { infof(data, "Resolve address '%s' found illegal", address); goto err; } @@ -1428,11 +1405,12 @@ CURLcode Curl_loadhostpairs(struct Curl_easy *data) /* put this new host in the cache */ dns = dnscache_add_addr(data, dnscache, head, curlx_str(&source), curlx_strlen(&source), (int)port, permanent); - if(dns) { + if(dns) /* release the returned reference; the cache itself will keep the * entry alive: */ dns->refcount--; - } + else + Curl_freeaddrinfo(head); dnscache_unlock(data, dnscache); diff --git a/tests/libtest/lib655.c b/tests/libtest/lib655.c index 07392cbd86b7..a213a1c493b3 100644 --- a/tests/libtest/lib655.c +++ b/tests/libtest/lib655.c @@ -82,9 +82,9 @@ static CURLcode test_lib655(const char *URL) /* this should fail */ res = curl_easy_perform(curl); - if(res != CURLE_COULDNT_RESOLVE_HOST) { + if(res != CURLE_ABORTED_BY_CALLBACK) { curl_mfprintf(stderr, "curl_easy_perform should have returned " - "CURLE_COULDNT_RESOLVE_HOST but instead returned error %d\n", + "CURLE_ABORTED_BY_CALLBACK but instead returned error %d\n", res); if(res == CURLE_OK) res = TEST_ERR_FAILURE; From 729f36e90fa8927ce85c4f1f7b67724988c35f00 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 25 Nov 2025 08:53:59 +0100 Subject: [PATCH 048/415] sendf: fix uninitialized variable in trace output Initialize *nread early on. Pointed out by CodeSonar Closes #19684 --- lib/sendf.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/sendf.c b/lib/sendf.c index f70abb5797bc..4eabc14402da 100644 --- a/lib/sendf.c +++ b/lib/sendf.c @@ -1195,6 +1195,7 @@ CURLcode Curl_client_read(struct Curl_easy *data, char *buf, size_t blen, DEBUGASSERT(blen); DEBUGASSERT(nread); DEBUGASSERT(eos); + *nread = 0; if(!data->req.reader_stack) { result = Curl_creader_set_fread(data, data->state.infilesize); From d0ad652552564cbcf5c2f14869db0add4ff4ac50 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 25 Nov 2025 09:09:50 +0100 Subject: [PATCH 049/415] progress: remove two redundant variable checks The entry condition in the function already exits early if either low_speed_time or low_speed_limit is not set. Pointed out by CodeSonar Closes #19686 --- lib/progress.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/progress.c b/lib/progress.c index 3985e1c1bfbd..59c5b9a00f28 100644 --- a/lib/progress.c +++ b/lib/progress.c @@ -109,7 +109,7 @@ UNITTEST CURLcode pgrs_speedcheck(struct Curl_easy *data, /* A paused transfer is not qualified for speed checks */ return CURLE_OK; - if((data->progress.current_speed >= 0) && data->set.low_speed_time) { + if(data->progress.current_speed >= 0) { if(data->progress.current_speed < data->set.low_speed_limit) { if(!data->state.keeps_speed.tv_sec) /* under the limit at this moment */ @@ -134,10 +134,9 @@ UNITTEST CURLcode pgrs_speedcheck(struct Curl_easy *data, data->state.keeps_speed.tv_sec = 0; } - if(data->set.low_speed_limit) - /* if low speed limit is enabled, set the expire timer to make this - connection's speed get checked again in a second */ - Curl_expire(data, 1000, EXPIRE_SPEEDCHECK); + /* since low speed limit is enabled, set the expire timer to make this + connection's speed get checked again in a second */ + Curl_expire(data, 1000, EXPIRE_SPEEDCHECK); return CURLE_OK; } From b8f83738c3ab01c214a314981626c86c9ffaca72 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 25 Nov 2025 10:07:30 +0100 Subject: [PATCH 050/415] asyn-ares: handle Curl_dnscache_mk_entry() OOM error To avoid leaking memory. Follow-up to ce06fe7771052549ff430 Closes #19688 --- lib/asyn-ares.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/asyn-ares.c b/lib/asyn-ares.c index d459fd4a75cd..1bc0f3247b78 100644 --- a/lib/asyn-ares.c +++ b/lib/asyn-ares.c @@ -343,7 +343,8 @@ CURLcode Curl_async_is_resolved(struct Curl_easy *data, Curl_dnscache_mk_entry(data, ares->temp_ai, data->state.async.hostname, 0, data->state.async.port, FALSE); - ares->temp_ai = NULL; /* temp_ai now owned by entry */ + if(data->state.async.dns) + ares->temp_ai = NULL; /* temp_ai now owned by entry */ #ifdef HTTPSRR_WORKS if(data->state.async.dns) { struct Curl_https_rrinfo *lhrr = Curl_httpsrr_dup_move(&ares->hinfo); From 6069c340b42a2a4d05f5dc76c49cd3e20e09ccb7 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 25 Nov 2025 10:14:28 +0100 Subject: [PATCH 051/415] tool_doswin: clear pointer when thread takes ownership Attempt to address #19675 Closes #19689 --- src/tool_doswin.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/tool_doswin.c b/src/tool_doswin.c index 6204296a8b51..cd0ec3b9c1b1 100644 --- a/src/tool_doswin.c +++ b/src/tool_doswin.c @@ -801,10 +801,7 @@ static DWORD WINAPI win_stdin_thread_func(void *thread_data) if(socket_w != CURL_SOCKET_BAD) sclose(socket_w); - if(tdata) { - free(tdata); - } - + free(tdata); return 0; } @@ -884,6 +881,7 @@ curl_socket_t win32_stdin_read_thread(void) errorf("CreateThread error: 0x%08lx", GetLastError()); break; } + tdata = NULL; /* win_stdin_thread_func owns it now */ /* Connect to the thread and rearrange our own STDIN handles */ socket_r = CURL_SOCKET(AF_INET, SOCK_STREAM, IPPROTO_TCP); From ba65073037152555aae279a5ef8eae808e3e675e Mon Sep 17 00:00:00 2001 From: Stefan Eissing Date: Tue, 25 Nov 2025 09:30:34 +0100 Subject: [PATCH 052/415] speedlimit: also reset on send unpausing The low speedlimit currently counts both up- and download speed accumulated. So, when unpausing upload, also reset the counter. Closes #19687 --- lib/progress.c | 8 ++++++++ lib/progress.h | 3 ++- lib/transfer.c | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/progress.c b/lib/progress.c index 59c5b9a00f28..7124a307d1f5 100644 --- a/lib/progress.c +++ b/lib/progress.c @@ -196,6 +196,14 @@ void Curl_pgrsRecvPause(struct Curl_easy *data, bool enable) } } +void Curl_pgrsSendPause(struct Curl_easy *data, bool enable) +{ + if(!enable) { + data->progress.speeder_c = 0; /* reset speed records */ + pgrs_speedinit(data); /* reset low speed measurements */ + } +} + /* * * Curl_pgrsTimeWas(). Store the timestamp time at the given label. diff --git a/lib/progress.h b/lib/progress.h index 96a26fe1a4d9..5535c69cbff5 100644 --- a/lib/progress.h +++ b/lib/progress.h @@ -59,8 +59,9 @@ void Curl_pgrsUpdate_nometer(struct Curl_easy *data); /* perform progress update with callbacks and speed checks */ CURLcode Curl_pgrsCheck(struct Curl_easy *data); -/* Inform progress/speedcheck about receive pausing */ +/* Inform progress/speedcheck about receive/send pausing */ void Curl_pgrsRecvPause(struct Curl_easy *data, bool enable); +void Curl_pgrsSendPause(struct Curl_easy *data, bool enable); /* Reset sizes and couners for up- and download. */ void Curl_pgrsReset(struct Curl_easy *data); diff --git a/lib/transfer.c b/lib/transfer.c index fbacdf429061..04a013361ebd 100644 --- a/lib/transfer.c +++ b/lib/transfer.c @@ -925,6 +925,7 @@ CURLcode Curl_xfer_pause_send(struct Curl_easy *data, bool enable) Curl_rlimit_block(&data->progress.ul.rlimit, enable, curlx_now()); if(!enable && Curl_creader_is_paused(data)) result = Curl_creader_unpause(data); + Curl_pgrsSendPause(data, enable); return result; } From 92e6782d1f0dbf0f011fe01ecc4c17b4109561b2 Mon Sep 17 00:00:00 2001 From: Patrick Monnerat Date: Mon, 24 Nov 2025 19:50:26 +0100 Subject: [PATCH 053/415] doc: some returned in-memory data may not be altered Some public prototypes do not declare return values or out parameters as const where they should be. Avoid changing the public interface, but document those values as read-only. Closes #19692 --- docs/libcurl/curl_easy_escape.md | 3 ++- docs/libcurl/curl_easy_unescape.md | 3 ++- docs/libcurl/curl_escape.md | 3 ++- docs/libcurl/curl_getenv.md | 3 ++- docs/libcurl/curl_mprintf.md | 2 +- docs/libcurl/curl_multi_get_handles.md | 3 ++- docs/libcurl/curl_pushheader_byname.md | 3 ++- docs/libcurl/curl_pushheader_bynum.md | 3 ++- docs/libcurl/curl_slist_append.md | 4 ++-- docs/libcurl/curl_unescape.md | 3 ++- docs/libcurl/curl_url.md | 3 +++ docs/libcurl/curl_url_get.md | 1 + 12 files changed, 23 insertions(+), 11 deletions(-) diff --git a/docs/libcurl/curl_easy_escape.md b/docs/libcurl/curl_easy_escape.md index b10500ac2619..1480a75c591a 100644 --- a/docs/libcurl/curl_easy_escape.md +++ b/docs/libcurl/curl_easy_escape.md @@ -30,7 +30,8 @@ char *curl_easy_escape(CURL *curl, const char *string, int length); This function converts the given input *string* to a URL encoded string and returns that as a new allocated string. All input characters that are not a-z, A-Z, 0-9, '-', '.', '_' or '~' are converted to their "URL escaped" version -(**%NN** where **NN** is a two-digit hexadecimal number). +(**%NN** where **NN** is a two-digit hexadecimal number). Although not +constrained by its type, the returned string may not be altered. If *length* is set to 0 (zero), curl_easy_escape(3) uses strlen() on the input *string* to find out the size. This function does not accept input strings diff --git a/docs/libcurl/curl_easy_unescape.md b/docs/libcurl/curl_easy_unescape.md index 2e78ad5d9f07..49e4c6bf269a 100644 --- a/docs/libcurl/curl_easy_unescape.md +++ b/docs/libcurl/curl_easy_unescape.md @@ -30,7 +30,8 @@ char *curl_easy_unescape(CURL *curl, const char *input, This function converts the URL encoded string **input** to a "plain string" and returns that in an allocated memory area. All input characters that are URL encoded (%XX where XX is a two-digit hexadecimal number) are converted to their -binary versions. +binary versions. Although not constrained by its type, the returned data may +not be altered. If the **length** argument is set to 0 (zero), curl_easy_unescape(3) uses strlen() on **input** to find out the size. diff --git a/docs/libcurl/curl_escape.md b/docs/libcurl/curl_escape.md index c24d1890d493..967d375a9758 100644 --- a/docs/libcurl/curl_escape.md +++ b/docs/libcurl/curl_escape.md @@ -31,7 +31,8 @@ Obsolete function. Use curl_easy_escape(3) instead. This function converts the given input **string** to a URL encoded string and return that as a new allocated string. All input characters that are not a-z, A-Z or 0-9 are converted to their "URL escaped" version (**%NN** where -**NN** is a two-digit hexadecimal number). +**NN** is a two-digit hexadecimal number). Although not constrained by its +type, the returned string may not be altered. If the **length** argument is set to 0, curl_escape(3) uses strlen() on **string** to find out the size. diff --git a/docs/libcurl/curl_getenv.md b/docs/libcurl/curl_getenv.md index 2cfb58148ce7..047c913f2530 100644 --- a/docs/libcurl/curl_getenv.md +++ b/docs/libcurl/curl_getenv.md @@ -29,7 +29,8 @@ curl_getenv() is a portable wrapper for the getenv() function, meant to emulate its behavior and provide an identical interface for all operating systems libcurl builds on (including Windows). -You must curl_free(3) the returned string when you are done with it. +You must curl_free(3) the returned string when you are done with it and, +although not constrained by its type, it may not be altered. # %PROTOCOLS% diff --git a/docs/libcurl/curl_mprintf.md b/docs/libcurl/curl_mprintf.md index 4f5c090579ba..a592cfb3e661 100644 --- a/docs/libcurl/curl_mprintf.md +++ b/docs/libcurl/curl_mprintf.md @@ -67,7 +67,7 @@ the value of *ap* is undefined after the call. The functions **curl_maprintf()** and **curl_mvaprintf()** return the output string as pointer to a newly allocated memory area. The returned string -must be curl_free(3)ed by the receiver. +may not be overwritten and must be curl_free(3)ed by the receiver. All of these functions write the output under the control of a format string that specifies how subsequent arguments are converted for output. diff --git a/docs/libcurl/curl_multi_get_handles.md b/docs/libcurl/curl_multi_get_handles.md index f94436a889ba..56da272b8abf 100644 --- a/docs/libcurl/curl_multi_get_handles.md +++ b/docs/libcurl/curl_multi_get_handles.md @@ -41,7 +41,8 @@ are out of sync. The order of the easy handles within the array is not guaranteed. -The returned array must be freed with a call to curl_free(3) after use. +The returned array may not be overwritten and must be freed with a call to +curl_free(3) after use. # %PROTOCOLS% diff --git a/docs/libcurl/curl_pushheader_byname.md b/docs/libcurl/curl_pushheader_byname.md index d066ea7b85b5..e2968fcd4621 100644 --- a/docs/libcurl/curl_pushheader_byname.md +++ b/docs/libcurl/curl_pushheader_byname.md @@ -33,7 +33,8 @@ elsewhere and it has no function then. It returns the value for the given header field name (or NULL) for the incoming server push request. This is a shortcut so that the application does not have to loop through all headers to find the one it is interested in. The -data this function points to is freed when this callback returns. If more than +data this function points to is freed when this callback returns and, +although not constrained by its type, may not be altered. If more than one header field use the same name, this returns only the first one. # %PROTOCOLS% diff --git a/docs/libcurl/curl_pushheader_bynum.md b/docs/libcurl/curl_pushheader_bynum.md index 12555c57f0c1..2431ff446bb1 100644 --- a/docs/libcurl/curl_pushheader_bynum.md +++ b/docs/libcurl/curl_pushheader_bynum.md @@ -33,7 +33,8 @@ elsewhere and it has no function then. It returns the value for the header field at the given index **num**, for the incoming server push request or NULL. The data pointed to is freed by libcurl when this callback returns. The returned pointer points to a -"name:value" string that gets freed when this callback returns. +"name:value" string that gets freed when this callback returns; although +not constrained by its type, this string may not be altered. # %PROTOCOLS% diff --git a/docs/libcurl/curl_slist_append.md b/docs/libcurl/curl_slist_append.md index b2766f728db0..3ebc19e35418 100644 --- a/docs/libcurl/curl_slist_append.md +++ b/docs/libcurl/curl_slist_append.md @@ -33,8 +33,8 @@ new list. The specified **string** has been appended when this function returns. curl_slist_append(3) copies the string. The **string** argument must be a valid string pointer and cannot be NULL. -The list should be freed again (after usage) with -curl_slist_free_all(3). +The list should be freed (after usage) with curl_slist_free_all(3). +Its nodes and pointed content may not be altered outside this function. # %PROTOCOLS% diff --git a/docs/libcurl/curl_unescape.md b/docs/libcurl/curl_unescape.md index 2600f1436110..453fd53145b9 100644 --- a/docs/libcurl/curl_unescape.md +++ b/docs/libcurl/curl_unescape.md @@ -33,7 +33,8 @@ Deprecated. Use curl_easy_unescape(3) instead. This function converts the URL encoded string **input** to a "plain string" and return that as a new allocated string. All input characters that are URL encoded (%XX where XX is a two-digit hexadecimal number) are converted to -their plain text versions. +their plain text versions. Although not constrained by its type, the returned +data may not be altered. If the **length** argument is set to 0, curl_unescape(3) calls strlen() on **input** to find out the size. diff --git a/docs/libcurl/curl_url.md b/docs/libcurl/curl_url.md index 5872134e139a..8053e630b8af 100644 --- a/docs/libcurl/curl_url.md +++ b/docs/libcurl/curl_url.md @@ -38,6 +38,9 @@ single URL. When the object is first created, there is of course no components stored. They are then set in the object with the curl_url_set(3) function. +The object must be destroyed with a call to curl_url_cleanup(3) when no +longer needed. + # %PROTOCOLS% # EXAMPLE diff --git a/docs/libcurl/curl_url_get.md b/docs/libcurl/curl_url_get.md index a9bb0bdc23fb..bed1c02f1747 100644 --- a/docs/libcurl/curl_url_get.md +++ b/docs/libcurl/curl_url_get.md @@ -43,6 +43,7 @@ allocated string with the contents. The *flags* argument is a bitmask with individual features. The returned content pointer must be freed with curl_free(3) after use. +Although not constrained by its type, the pointed string may not be altered. # FLAGS From 74bd3e2f98b26b283dbdb5af543e0c43e61a6155 Mon Sep 17 00:00:00 2001 From: Patrick Monnerat Date: Mon, 24 Nov 2025 14:57:38 +0100 Subject: [PATCH 054/415] slist: constify Curl_slist_append_nodup() string argument Although finally stored as a non-const pointer, the string is intended to be left unchanged. This change allows using the function without the need of a cast for const pointers. Closes #19692 --- lib/slist.c | 5 +++-- lib/slist.h | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/slist.c b/lib/slist.c index 366b24760959..88fdd8a2bae2 100644 --- a/lib/slist.c +++ b/lib/slist.c @@ -58,7 +58,8 @@ static struct curl_slist *slist_get_last(struct curl_slist *list) * If an error occurs, NULL is returned and the string argument is NOT * released. */ -struct curl_slist *Curl_slist_append_nodup(struct curl_slist *list, char *data) +struct curl_slist *Curl_slist_append_nodup(struct curl_slist *list, + const char *data) { struct curl_slist *last; struct curl_slist *new_item; @@ -70,7 +71,7 @@ struct curl_slist *Curl_slist_append_nodup(struct curl_slist *list, char *data) return NULL; new_item->next = NULL; - new_item->data = data; + new_item->data = CURL_UNCONST(data); /* if this is the first item, then new_item *is* the list */ if(!list) diff --git a/lib/slist.h b/lib/slist.h index 9561fd022686..47a30824db01 100644 --- a/lib/slist.h +++ b/lib/slist.h @@ -36,6 +36,6 @@ struct curl_slist *Curl_slist_duplicate(struct curl_slist *inlist); * it to the list. */ struct curl_slist *Curl_slist_append_nodup(struct curl_slist *list, - char *data); + const char *data); #endif /* HEADER_CURL_SLIST_H */ From 62683ad3f49aeb60ab311cf52aacc5630116418a Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Tue, 25 Nov 2025 03:35:40 +0100 Subject: [PATCH 055/415] curlx: replace `sprintf` with `snprintf` To avoid using a deprecated function on Windows. Also: de-dupe `SNPRINTF` definition in curlx. Closes #19681 --- lib/Makefile.inc | 1 + lib/curl_setup.h | 3 +-- lib/curlx/inet_ntop.c | 14 +++++++------- lib/curlx/snprintf.h | 36 ++++++++++++++++++++++++++++++++++++ lib/curlx/strerr.c | 15 +-------------- lib/curlx/winapi.c | 15 +-------------- src/Makefile.inc | 1 + 7 files changed, 48 insertions(+), 37 deletions(-) create mode 100644 lib/curlx/snprintf.h diff --git a/lib/Makefile.inc b/lib/Makefile.inc index cad02c823786..85faa875e072 100644 --- a/lib/Makefile.inc +++ b/lib/Makefile.inc @@ -50,6 +50,7 @@ LIB_CURLX_HFILES = \ curlx/inet_pton.h \ curlx/multibyte.h \ curlx/nonblock.h \ + curlx/snprintf.h \ curlx/strerr.h \ curlx/strparse.h \ curlx/timediff.h \ diff --git a/lib/curl_setup.h b/lib/curl_setup.h index 0e5ebb60c9ef..664aa1432532 100644 --- a/lib/curl_setup.h +++ b/lib/curl_setup.h @@ -95,8 +95,7 @@ unlink(), etc. */ #endif #ifndef _CRT_SECURE_NO_WARNINGS -#define _CRT_SECURE_NO_WARNINGS /* for getenv(), gmtime(), sprintf(), - strcpy(), +#define _CRT_SECURE_NO_WARNINGS /* for getenv(), gmtime(), strcpy(), in tests: localtime(), sscanf() */ #endif #endif /* _MSC_VER */ diff --git a/lib/curlx/inet_ntop.c b/lib/curlx/inet_ntop.c index d4053f1a60f2..771af81474e7 100644 --- a/lib/curlx/inet_ntop.c +++ b/lib/curlx/inet_ntop.c @@ -32,6 +32,7 @@ #endif #include "inet_ntop.h" +#include "snprintf.h" #define IN6ADDRSZ 16 /* #define INADDRSZ 4 */ @@ -61,13 +62,12 @@ static char *inet_ntop4(const unsigned char *src, char *dst, size_t size) DEBUGASSERT(size >= 16); - /* this sprintf() does not overflow the buffer. Avoids snprintf to work more - widely. Avoids the msnprintf family to work as a curlx function. */ - (void)(sprintf)(tmp, "%d.%d.%d.%d", - ((int)((unsigned char)src[0])) & 0xff, - ((int)((unsigned char)src[1])) & 0xff, - ((int)((unsigned char)src[2])) & 0xff, - ((int)((unsigned char)src[3])) & 0xff); + /* this snprintf() does not overflow the buffer. */ + SNPRINTF(tmp, sizeof(tmp), "%d.%d.%d.%d", + ((int)((unsigned char)src[0])) & 0xff, + ((int)((unsigned char)src[1])) & 0xff, + ((int)((unsigned char)src[2])) & 0xff, + ((int)((unsigned char)src[3])) & 0xff); len = strlen(tmp); if(len == 0 || len >= size) { diff --git a/lib/curlx/snprintf.h b/lib/curlx/snprintf.h new file mode 100644 index 000000000000..266ea137fae6 --- /dev/null +++ b/lib/curlx/snprintf.h @@ -0,0 +1,36 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) Daniel Stenberg, , et al. + * + * This software is licensed as described in the 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. + * + * SPDX-License-Identifier: curl + * + ***************************************************************************/ + +/* Raw snprintf() for curlx */ + +#ifdef WITHOUT_LIBCURL /* when built for the test servers */ +#if defined(_MSC_VER) && (_MSC_VER < 1900) /* adjust for old MSVC */ +#define SNPRINTF _snprintf +#else +#define SNPRINTF snprintf +#endif +#else /* !WITHOUT_LIBCURL */ +#include +#define SNPRINTF curl_msnprintf +#endif /* WITHOUT_LIBCURL */ diff --git a/lib/curlx/strerr.c b/lib/curlx/strerr.c index 376f68b0b20d..c33d10701125 100644 --- a/lib/curlx/strerr.c +++ b/lib/curlx/strerr.c @@ -34,21 +34,8 @@ #include -#ifndef WITHOUT_LIBCURL -#include -#define SNPRINTF curl_msnprintf -#else -/* when built for the test servers */ - -/* adjust for old MSVC */ -#if defined(_MSC_VER) && (_MSC_VER < 1900) -#define SNPRINTF _snprintf -#else -#define SNPRINTF snprintf -#endif -#endif /* !WITHOUT_LIBCURL */ - #include "winapi.h" +#include "snprintf.h" #include "strerr.h" /* The last 2 #include files should be in this order */ #include "../curl_memory.h" diff --git a/lib/curlx/winapi.c b/lib/curlx/winapi.c index 7b3d6b60369c..4cacbcb618ea 100644 --- a/lib/curlx/winapi.c +++ b/lib/curlx/winapi.c @@ -29,20 +29,7 @@ */ #ifdef _WIN32 #include "winapi.h" - -#ifndef WITHOUT_LIBCURL -#include -#define SNPRINTF curl_msnprintf -#else -/* when built for the test servers */ - -/* adjust for old MSVC */ -#if defined(_MSC_VER) && (_MSC_VER < 1900) -#define SNPRINTF _snprintf -#else -#define SNPRINTF snprintf -#endif -#endif /* !WITHOUT_LIBCURL */ +#include "snprintf.h" /* This is a helper function for curlx_strerror that converts Windows API error * codes (GetLastError) to error messages. diff --git a/src/Makefile.inc b/src/Makefile.inc index fa5583755203..6e5e31f806e9 100644 --- a/src/Makefile.inc +++ b/src/Makefile.inc @@ -54,6 +54,7 @@ CURLX_HFILES = \ ../lib/curlx/fopen.h \ ../lib/curlx/multibyte.h \ ../lib/curlx/nonblock.h \ + ../lib/curlx/snprintf.h \ ../lib/curlx/strerr.h \ ../lib/curlx/strparse.h \ ../lib/curlx/timediff.h \ From 4f807db155815800fde49c3ef8291a3f7c345429 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Tue, 25 Nov 2025 10:42:07 +0100 Subject: [PATCH 056/415] INTERNALS.md: add more dependency versions and dates Closes #19691 --- docs/INTERNALS.md | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/docs/INTERNALS.md b/docs/INTERNALS.md index 75393a5d1c72..222d9ab5ed69 100644 --- a/docs/INTERNALS.md +++ b/docs/INTERNALS.md @@ -36,6 +36,7 @@ versions of libs and build tools. - nghttp2 1.15.0 (2016-09-25) - OpenLDAP 2.0 (2000-08-01) - OpenSSL 3.0.0 (2021-09-07) + - Windows XP 5.1 (2001-08-24 - 2009-04-14) - wolfSSL 3.4.6 (2017-09-22) - zlib 1.2.5.2 (2011-12-11) - zstd 1.0 (2016-08-31) @@ -46,12 +47,14 @@ versions of libs and build tools. we use a few "build tools" and we make sure that we remain functional with these versions: - - GNU libtool 1.4.2 (2001-09-11) - - GNU autoconf 2.59 (2003-11-06) - - GNU automake 1.7 (2002-09-25) - - GNU m4 1.4 (2007-09-21) - - perl 5.8 (2002-07-19), on Windows: 5.22 (2015-06-01) - - cmake 3.7 (2016-11-11) + - cmake 3.7 (2016-11-11) + - GNU autoconf 2.59 (2003-11-06) + - GNU automake 1.7 (2002-09-25) + - GNU libtool 1.4.2 (2001-09-11) + - GNU m4 1.4 (2007-09-21) + - mingw-w64 3.0 (2013-09-20) + - perl 5.8 (2002-07-19), on Windows: 5.22 (2015-06-01) + - Visual Studio 2010 10.0 (2010-04-12 - 2020-07-14) Library Symbols =============== From 2b0ca15c49e2f437741603d6de29aaa7a7928d18 Mon Sep 17 00:00:00 2001 From: Stefan Eissing Date: Tue, 25 Nov 2025 11:39:04 +0100 Subject: [PATCH 057/415] ratelimit: remove a debug mprintf Follow-up to 24b36fdd1585ea22e5e Closes #19694 --- lib/ratelimit.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/ratelimit.c b/lib/ratelimit.c index 8b34d77e1313..c3593d593756 100644 --- a/lib/ratelimit.c +++ b/lib/ratelimit.c @@ -90,8 +90,6 @@ static void ratelimit_update(struct Curl_rlimit *r, elapsed_us = curlx_timediff_us(ts, r->ts); if(elapsed_us < 0) { /* not going back in time */ - curl_mfprintf(stderr, "rlimit: neg elapsed time %" FMT_TIMEDIFF_T "us\n", - elapsed_us); DEBUGASSERT(0); return; } From fc09a2da4ad0595292ecabda6f50f5d415b70527 Mon Sep 17 00:00:00 2001 From: Yedaya Katsman Date: Sun, 23 Nov 2025 21:29:46 +0200 Subject: [PATCH 058/415] tool: log when loading .curlrc in verbose mode Inspired by @vszakats in https://github.com/curl/curl/pull/19631#issuecomment-3560803674 Closes #19663 --- src/tool_getparam.c | 2 +- src/tool_operate.c | 10 +++++++++- src/tool_parsecfg.c | 8 +++++++- src/tool_parsecfg.h | 3 ++- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/tool_getparam.c b/src/tool_getparam.c index 0bb1329b5495..76113e45bd0d 100644 --- a/src/tool_getparam.c +++ b/src/tool_getparam.c @@ -2225,7 +2225,7 @@ static ParameterError opt_file(struct OperationConfig *config, err = PARAM_BAD_USE; } else { - err = parseconfig(nextarg, max_recursive); + err = parseconfig(nextarg, max_recursive, NULL); } break; case C_CRLFILE: /* --crlfile */ diff --git a/src/tool_operate.c b/src/tool_operate.c index 69cfef96d786..eb591935db4f 100644 --- a/src/tool_operate.c +++ b/src/tool_operate.c @@ -2227,6 +2227,8 @@ CURLcode operate(int argc, argv_item_t argv[]) { CURLcode result = CURLE_OK; const char *first_arg; + char *curlrc_path = NULL; + bool found_curlrc = FALSE; first_arg = argc > 1 ? convert_tchar_to_UTF8(argv[1]) : NULL; @@ -2240,7 +2242,8 @@ CURLcode operate(int argc, argv_item_t argv[]) if((argc == 1) || (first_arg && strncmp(first_arg, "-q", 2) && strcmp(first_arg, "--disable"))) { - parseconfig(NULL, CONFIG_MAX_LEVELS); /* ignore possible failure */ + if(!parseconfig(NULL, CONFIG_MAX_LEVELS, &curlrc_path)) + found_curlrc = TRUE; /* If we had no arguments then make sure a URL was specified in .curlrc */ if((argc < 2) && (!global->first->url_list)) { @@ -2254,6 +2257,11 @@ CURLcode operate(int argc, argv_item_t argv[]) if(!result) { /* Parse the command line arguments */ ParameterError res = parse_args(argc, argv); + if(found_curlrc) { + /* After parse_args so notef knows the verbosity */ + notef("Read config file from '%s'", curlrc_path); + free(curlrc_path); + } if(res) { result = CURLE_OK; diff --git a/src/tool_parsecfg.c b/src/tool_parsecfg.c index 53b63746b5ac..e7a00cf70883 100644 --- a/src/tool_parsecfg.c +++ b/src/tool_parsecfg.c @@ -81,7 +81,8 @@ static int unslashquote(const char *line, struct dynbuf *param) #define MAX_CONFIG_LINE_LENGTH (10*1024*1024) /* return 0 on everything-is-fine, and non-zero otherwise */ -ParameterError parseconfig(const char *filename, int max_recursive) +ParameterError parseconfig(const char *filename, int max_recursive, + char **resolved) { FILE *file = NULL; bool usedarg = FALSE; @@ -264,6 +265,11 @@ ParameterError parseconfig(const char *filename, int max_recursive) if((err == PARAM_READ_ERROR) && filename) errorf("cannot read config from '%s'", filename); + if(!err && resolved) { + *resolved = strdup(filename); + if(!*resolved) + err = PARAM_NO_MEM; + } free(pathalloc); return err; } diff --git a/src/tool_parsecfg.h b/src/tool_parsecfg.h index 3aad9bdd9cbd..860b9df38eda 100644 --- a/src/tool_parsecfg.h +++ b/src/tool_parsecfg.h @@ -27,7 +27,8 @@ /* only allow this many levels of recursive --config use */ #define CONFIG_MAX_LEVELS 5 -ParameterError parseconfig(const char *filename, int max_recursive); +ParameterError parseconfig(const char *filename, int max_recursive, + char **resolved); bool my_get_line(FILE *fp, struct dynbuf *db, bool *error); #endif /* HEADER_CURL_TOOL_PARSECFG_H */ From 208a6aebf223200293a5f0c1bdc3cced36d5af1f Mon Sep 17 00:00:00 2001 From: Stefan Eissing Date: Tue, 25 Nov 2025 10:00:23 +0100 Subject: [PATCH 059/415] lib: timer stats improvements * move the TIMER_POSTQUEUE to the time a connection is chosen, so that TIMER_NAMELOOKUP always happens afterwards * client writer: do not trigger TIMER_STARTTRANSFER on CLIENTWRITE_INFO as ftp and other pingpong protocols write that before starting anything that is the tranfer itself * Elimnating debug trancing of "closed stream/connection - bailing" as confusing, as connection is not really closed on most cases. * Setting 'data->req.upload_done` correctly, so that no "abort upload" is happening at the end of a perfectly fine download. * Adding test cases with up-/download of 0-length files. * pytest: add a "timeline" of timer value checks to Resulst in curl.py, so that this can be used in several test cases, replacing the local stuff in test_16 * add timeline checks to ftp test cases Closes #19269 --- lib/cfilters.c | 13 +++--- lib/multi.c | 2 +- lib/request.c | 10 ++++- lib/sendf.c | 3 +- lib/transfer.c | 13 +----- lib/url.c | 1 + lib/vquic/curl_osslq.c | 8 ++++ tests/http/test_02_download.py | 6 ++- tests/http/test_16_info.py | 56 ++--------------------- tests/http/test_30_vsftpd.py | 21 ++++++--- tests/http/test_31_vsftpds.py | 5 +++ tests/http/test_32_ftps_vsftpd.py | 6 +++ tests/http/testenv/curl.py | 74 +++++++++++++++++++++++++++++++ tests/libtest/lib500.c | 5 ++- 14 files changed, 141 insertions(+), 82 deletions(-) diff --git a/lib/cfilters.c b/lib/cfilters.c index 507512f8aa46..f0da4778a685 100644 --- a/lib/cfilters.c +++ b/lib/cfilters.c @@ -63,8 +63,8 @@ CURLcode Curl_cf_def_shutdown(struct Curl_cfilter *cf, return CURLE_OK; } -static void conn_report_connect_stats(struct Curl_easy *data, - struct connectdata *conn); +static void conn_report_connect_stats(struct Curl_cfilter *cf, + struct Curl_easy *data); CURLcode Curl_cf_def_adjust_pollset(struct Curl_cfilter *cf, struct Curl_easy *data, @@ -508,7 +508,7 @@ CURLcode Curl_conn_connect(struct Curl_easy *data, * persist information at the connection. E.g. cf-socket sets the * socket and ip related information. */ cf_cntrl_update_info(data, data->conn); - conn_report_connect_stats(data, data->conn); + conn_report_connect_stats(cf, data); data->conn->keepalive = curlx_now(); #ifndef CURL_DISABLE_VERBOSE_STRINGS result = cf_verboseconnect(data, cf); @@ -518,7 +518,7 @@ CURLcode Curl_conn_connect(struct Curl_easy *data, else if(result) { CURL_TRC_CF(data, cf, "Curl_conn_connect(), filter returned %d", result); - conn_report_connect_stats(data, data->conn); + conn_report_connect_stats(cf, data); goto out; } @@ -1008,10 +1008,9 @@ static void cf_cntrl_update_info(struct Curl_easy *data, /** * Update connection statistics */ -static void conn_report_connect_stats(struct Curl_easy *data, - struct connectdata *conn) +static void conn_report_connect_stats(struct Curl_cfilter *cf, + struct Curl_easy *data) { - struct Curl_cfilter *cf = conn->cfilter[FIRSTSOCKET]; if(cf) { struct curltime connected; struct curltime appconnected; diff --git a/lib/multi.c b/lib/multi.c index 00af3ca2bddf..db04d64c231b 100644 --- a/lib/multi.c +++ b/lib/multi.c @@ -2337,7 +2337,7 @@ static CURLMcode state_connect(struct Curl_multi *multi, process_pending_handles(data->multi); if(!result) { - *nowp = Curl_pgrsTime(data, TIMER_POSTQUEUE); + *nowp = curlx_now(); if(async) /* We are now waiting for an asynchronous name lookup */ multistate(data, MSTATE_RESOLVING); diff --git a/lib/request.c b/lib/request.c index 5bfcdfbfb8c7..324c4c48f96d 100644 --- a/lib/request.c +++ b/lib/request.c @@ -393,6 +393,11 @@ CURLcode Curl_req_send(struct Curl_easy *data, struct dynbuf *req, return result; buf += nwritten; blen -= nwritten; + if(!blen) { + result = req_set_upload_done(data); + if(result) + return result; + } } if(blen) { @@ -469,6 +474,9 @@ CURLcode Curl_req_stop_send_recv(struct Curl_easy *data) /* stop receiving and ALL sending as well, including PAUSE and HOLD. * We might still be paused on receive client writes though, so * keep those bits around. */ + CURLcode result = CURLE_OK; + if(data->req.keepon & KEEP_SEND) + result = Curl_req_abort_sending(data); data->req.keepon &= ~(KEEP_RECV|KEEP_SEND); - return Curl_req_abort_sending(data); + return result; } diff --git a/lib/sendf.c b/lib/sendf.c index 4eabc14402da..6731cd874b6b 100644 --- a/lib/sendf.c +++ b/lib/sendf.c @@ -230,7 +230,8 @@ static CURLcode cw_download_write(struct Curl_easy *data, size_t nwrite, excess_len = 0; bool is_connect = !!(type & CLIENTWRITE_CONNECT); - if(!is_connect && !ctx->started_response) { + if(!ctx->started_response && + !(type & (CLIENTWRITE_INFO|CLIENTWRITE_CONNECT))) { Curl_pgrsTime(data, TIMER_STARTTRANSFER); Curl_rlimit_start(&data->progress.dl.rlimit, curlx_now()); ctx->started_response = TRUE; diff --git a/lib/transfer.c b/lib/transfer.c index 04a013361ebd..f2df2cef8cba 100644 --- a/lib/transfer.c +++ b/lib/transfer.c @@ -301,18 +301,7 @@ static CURLcode sendrecv_dl(struct Curl_easy *data, /* We only get a 0-length receive at the end of the response */ is_eos = (blen == 0); - if(!blen && (conn->recv[FIRSTSOCKET] == Curl_cf_recv)) { - /* if we receive 0 or less here and the protocol handler did not - replace the connection's `recv` callback, either the data transfer - is done or the server closed the connection and - we bail out from this! - With a `recv` replacement, we assume the protocol handler knows - what it is doing and a 0-length receive is fine. For example, - SFTP downloads of an empty file would show this. See #19165. */ - if(is_multiplex) - DEBUGF(infof(data, "nread == 0, stream closed, bailing")); - else - DEBUGF(infof(data, "nread <= 0, server closed connection, bailing")); + if(!blen) { result = Curl_req_stop_send_recv(data); if(result) goto out; diff --git a/lib/url.c b/lib/url.c index 1d4c6b1fc419..d953734dce9b 100644 --- a/lib/url.c +++ b/lib/url.c @@ -3834,6 +3834,7 @@ CURLcode Curl_connect(struct Curl_easy *data, if(!result) { DEBUGASSERT(conn); + Curl_pgrsTime(data, TIMER_POSTQUEUE); if(reused) { if(CONN_ATTACHED(conn) > 1) /* multiplexed */ diff --git a/lib/vquic/curl_osslq.c b/lib/vquic/curl_osslq.c index f447e8dddf0f..b890a8d9516d 100644 --- a/lib/vquic/curl_osslq.c +++ b/lib/vquic/curl_osslq.c @@ -1803,6 +1803,14 @@ static CURLcode cf_osslq_connect(struct Curl_cfilter *cf, if(err == 1) { /* connected */ + if(!ctx->got_first_byte) { + /* if not recorded yet, take the timestamp before we called + * SSL_do_handshake() as the time we received the first packet. */ + ctx->got_first_byte = TRUE; + ctx->first_byte_at = now; + } + /* Record the handshake complete with a new time stamp. */ + now = curlx_now(); ctx->handshake_at = now; ctx->q.last_io = now; CURL_TRC_CF(data, cf, "handshake complete after %" FMT_TIMEDIFF_T "ms", diff --git a/tests/http/test_02_download.py b/tests/http/test_02_download.py index 8cfd68b20463..dcfe9690bcb4 100644 --- a/tests/http/test_02_download.py +++ b/tests/http/test_02_download.py @@ -43,6 +43,7 @@ class TestDownload: @pytest.fixture(autouse=True, scope='class') def _class_scope(self, env, httpd): indir = httpd.docs_dir + env.make_data_file(indir=indir, fname="data-0k", fsize=0) env.make_data_file(indir=indir, fname="data-10k", fsize=10*1024) env.make_data_file(indir=indir, fname="data-100k", fsize=100*1024) env.make_data_file(indir=indir, fname="data-1m", fsize=1024*1024) @@ -52,9 +53,10 @@ def _class_scope(self, env, httpd): # download 1 file @pytest.mark.parametrize("proto", Env.http_protos()) - def test_02_01_download_1(self, env: Env, httpd, nghttpx, proto): + @pytest.mark.parametrize("docname", ['data.json', 'data-0k', 'data-10k', 'data-100k']) + def test_02_01_download_1(self, env: Env, httpd, nghttpx, proto, docname): curl = CurlClient(env=env) - url = f'https://{env.authority_for(env.domain1, proto)}/data.json' + url = f'https://{env.authority_for(env.domain1, proto)}/{docname}' r = curl.http_download(urls=[url], alpn_proto=proto) r.check_response(http_status=200) diff --git a/tests/http/test_16_info.py b/tests/http/test_16_info.py index 4e0d1ed5b1a9..80984a284ee1 100644 --- a/tests/http/test_16_info.py +++ b/tests/http/test_16_info.py @@ -56,6 +56,7 @@ def test_16_01_info_download(self, env: Env, httpd, nghttpx, proto): remote_ip='127.0.0.1') for idx, s in enumerate(r.stats): self.check_stat(idx, s, r, dl_size=30, ul_size=0) + r.check_stats_timeline(idx) # download plain file with a 302 redirect @pytest.mark.parametrize("proto", Env.http_protos()) @@ -71,6 +72,7 @@ def test_16_02_info_302_download(self, env: Env, httpd, nghttpx, proto): remote_ip='127.0.0.1') for idx, s in enumerate(r.stats): self.check_stat(idx, s, r, dl_size=30, ul_size=0) + r.check_stats_timeline(idx) @pytest.mark.parametrize("proto", Env.http_protos()) def test_16_03_info_upload(self, env: Env, httpd, nghttpx, proto): @@ -89,6 +91,7 @@ def test_16_03_info_upload(self, env: Env, httpd, nghttpx, proto): remote_ip='127.0.0.1') for idx, s in enumerate(r.stats): self.check_stat(idx, s, r, dl_size=fsize, ul_size=fsize) + r.check_stats_timeline(idx) # download plain file via http: ('time_appconnect' is 0) @pytest.mark.parametrize("proto", ['http/1.1']) @@ -101,9 +104,9 @@ def test_16_04_info_http_download(self, env: Env, httpd, nghttpx, proto): remote_port=env.http_port, remote_ip='127.0.0.1') for idx, s in enumerate(r.stats): self.check_stat(idx, s, r, dl_size=30, ul_size=0) + r.check_stats_timeline(idx) def check_stat(self, idx, s, r, dl_size=None, ul_size=None): - self.check_stat_times(s, idx) # we always send something self.check_stat_positive(s, idx, 'size_request') # we always receive response headers @@ -118,54 +121,3 @@ def check_stat(self, idx, s, r, dl_size=None, ul_size=None): def check_stat_positive(self, s, idx, key): assert key in s, f'stat #{idx} "{key}" missing: {s}' assert s[key] > 0, f'stat #{idx} "{key}" not positive: {s}' - - def check_stat_positive_or_0(self, s, idx, key): - assert key in s, f'stat #{idx} "{key}" missing: {s}' - assert s[key] >= 0, f'stat #{idx} "{key}" not positive: {s}' - - def check_stat_zero(self, s, key): - assert key in s, f'stat "{key}" missing: {s}' - assert s[key] == 0, f'stat "{key}" not zero: {s}' - - def check_stat_times(self, s, idx): - # check timings reported on a transfer for consistency - url = s['url_effective'] - # connect time is sometimes reported as 0 by openssl-quic (sigh) - self.check_stat_positive_or_0(s, idx, 'time_connect') - # all stat keys which reporting timings - all_keys = { - 'time_appconnect', 'time_redirect', - 'time_pretransfer', 'time_starttransfer', 'time_total' - } - # stat keys where we expect a positive value - pos_keys = {'time_pretransfer', 'time_starttransfer', 'time_total', 'time_queue'} - if s['num_connects'] > 0: - if url.startswith('https:'): - pos_keys.add('time_appconnect') - if s['num_redirects'] > 0: - pos_keys.add('time_redirect') - zero_keys = all_keys - pos_keys - # assert all zeros are zeros and the others are positive - for key in zero_keys: - self.check_stat_zero(s, key) - for key in pos_keys: - self.check_stat_positive(s, idx, key) - # assert that all timers before "time_pretransfer" are less or equal - for key in ['time_appconnect', 'time_connect', 'time_namelookup']: - assert s[key] < s['time_pretransfer'], f'time "{key}" larger than' \ - f'"time_pretransfer": {s}' - # assert transfer total is after pretransfer. - # (in MOST situations, pretransfer is before starttransfer, BUT - # in protocols like HTTP we might get a server response already before - # we transition to multi state DID.) - assert s['time_pretransfer'] <= s['time_total'], f'"time_pretransfer" '\ - f'greater than "time_total", {s}' - # assert that transfer start is before total - assert s['time_starttransfer'] <= s['time_total'], f'"time_starttransfer" '\ - f'greater than "time_total", {s}' - if s['num_redirects'] > 0: - assert s['time_queue'] < s['time_starttransfer'], f'"time_queue" '\ - f'greater/equal than "time_starttransfer", {s}' - else: - assert s['time_queue'] <= s['time_starttransfer'], f'"time_queue" '\ - f'greater than "time_starttransfer", {s}' diff --git a/tests/http/test_30_vsftpd.py b/tests/http/test_30_vsftpd.py index bffeae35cf7b..7d113d5363fe 100644 --- a/tests/http/test_30_vsftpd.py +++ b/tests/http/test_30_vsftpd.py @@ -63,10 +63,12 @@ def _class_scope(self, env, vsftpd): shutil.rmtree(vsftpd.docs_dir) if not os.path.exists(vsftpd.docs_dir): os.makedirs(vsftpd.docs_dir) + self._make_docs_file(docs_dir=vsftpd.docs_dir, fname='data-0k', fsize=0) self._make_docs_file(docs_dir=vsftpd.docs_dir, fname='data-1k', fsize=1024) self._make_docs_file(docs_dir=vsftpd.docs_dir, fname='data-10k', fsize=10*1024) self._make_docs_file(docs_dir=vsftpd.docs_dir, fname='data-1m', fsize=1024*1024) self._make_docs_file(docs_dir=vsftpd.docs_dir, fname='data-10m', fsize=10*1024*1024) + env.make_data_file(indir=env.gen_dir, fname="upload-0k", fsize=0) env.make_data_file(indir=env.gen_dir, fname="upload-1k", fsize=1024) env.make_data_file(indir=env.gen_dir, fname="upload-100k", fsize=100*1024) env.make_data_file(indir=env.gen_dir, fname="upload-1m", fsize=1024*1024) @@ -77,11 +79,12 @@ def test_30_01_list_dir(self, env: Env, vsftpd: VsFTPD): r = curl.ftp_get(urls=[url], with_stats=True) r.check_stats(count=1, http_status=226) lines = open(os.path.join(curl.run_dir, 'download_#1.data')).readlines() - assert len(lines) == 4, f'list: {lines}' + assert len(lines) == 5, f'list: {lines}' + r.check_stats_timelines() # download 1 file, no SSL @pytest.mark.parametrize("docname", [ - 'data-1k', 'data-1m', 'data-10m' + 'data-0k', 'data-1k', 'data-1m', 'data-10m' ]) def test_30_02_download_1(self, env: Env, vsftpd: VsFTPD, docname): curl = CurlClient(env=env) @@ -91,9 +94,10 @@ def test_30_02_download_1(self, env: Env, vsftpd: VsFTPD, docname): r = curl.ftp_get(urls=[url], with_stats=True) r.check_stats(count=count, http_status=226) self.check_downloads(curl, srcfile, count) + r.check_stats_timelines() @pytest.mark.parametrize("docname", [ - 'data-1k', 'data-1m', 'data-10m' + 'data-0k', 'data-1k', 'data-1m', 'data-10m' ]) def test_30_03_download_10_serial(self, env: Env, vsftpd: VsFTPD, docname): curl = CurlClient(env=env) @@ -104,9 +108,10 @@ def test_30_03_download_10_serial(self, env: Env, vsftpd: VsFTPD, docname): r.check_stats(count=count, http_status=226) self.check_downloads(curl, srcfile, count) assert r.total_connects == count + 1, 'should reuse the control conn' + r.check_stats_timelines() @pytest.mark.parametrize("docname", [ - 'data-1k', 'data-1m', 'data-10m' + 'data-0k', 'data-1k', 'data-1m', 'data-10m' ]) def test_30_04_download_10_parallel(self, env: Env, vsftpd: VsFTPD, docname): curl = CurlClient(env=env) @@ -119,9 +124,10 @@ def test_30_04_download_10_parallel(self, env: Env, vsftpd: VsFTPD, docname): r.check_stats(count=count, http_status=226) self.check_downloads(curl, srcfile, count) assert r.total_connects > count + 1, 'should have used several control conns' + r.check_stats_timelines() @pytest.mark.parametrize("docname", [ - 'upload-1k', 'upload-100k', 'upload-1m' + 'upload-0k', 'upload-1k', 'upload-100k', 'upload-1m' ]) def test_30_05_upload_1(self, env: Env, vsftpd: VsFTPD, docname): curl = CurlClient(env=env) @@ -133,6 +139,7 @@ def test_30_05_upload_1(self, env: Env, vsftpd: VsFTPD, docname): r = curl.ftp_upload(urls=[url], fupload=f'{srcfile}', with_stats=True) r.check_stats(count=count, http_status=226) self.check_upload(env, vsftpd, docname=docname) + r.check_stats_timelines() def _rmf(self, path): if os.path.exists(path): @@ -188,6 +195,7 @@ def test_30_08_active_download(self, env: Env, vsftpd: VsFTPD): ]) r.check_stats(count=count, http_status=226) self.check_downloads(curl, srcfile, count) + r.check_stats_timelines() def test_30_09_active_up_file(self, env: Env, vsftpd: VsFTPD): docname = 'upload-1k' @@ -202,6 +210,7 @@ def test_30_09_active_up_file(self, env: Env, vsftpd: VsFTPD): ]) r.check_stats(count=count, http_status=226) self.check_upload(env, vsftpd, docname=docname) + r.check_stats_timelines() def test_30_10_active_up_ascii(self, env: Env, vsftpd: VsFTPD): docname = 'upload-1k' @@ -216,6 +225,7 @@ def test_30_10_active_up_ascii(self, env: Env, vsftpd: VsFTPD): ]) r.check_stats(count=count, http_status=226) self.check_upload(env, vsftpd, docname=docname, binary=False) + r.check_stats_timelines() def test_30_11_download_non_existing(self, env: Env, vsftpd: VsFTPD): curl = CurlClient(env=env) @@ -223,6 +233,7 @@ def test_30_11_download_non_existing(self, env: Env, vsftpd: VsFTPD): r = curl.ftp_get(urls=[url], with_stats=True) r.check_exit_code(78) r.check_stats(count=1, exitcode=78) + r.check_stats_timelines() def check_downloads(self, client, srcfile: str, count: int, complete: bool = True): diff --git a/tests/http/test_31_vsftpds.py b/tests/http/test_31_vsftpds.py index f7e32cb77b77..93fef708ccdd 100644 --- a/tests/http/test_31_vsftpds.py +++ b/tests/http/test_31_vsftpds.py @@ -85,6 +85,7 @@ def test_31_01_list_dir(self, env: Env, vsftpds: VsFTPD): r.check_stats(count=1, http_status=226) lines = open(os.path.join(curl.run_dir, 'download_#1.data')).readlines() assert len(lines) == 4, f'list: {lines}' + r.check_stats_timelines() # download 1 file, no SSL @pytest.mark.parametrize("docname", [ @@ -98,6 +99,7 @@ def test_31_02_download_1(self, env: Env, vsftpds: VsFTPD, docname): r = curl.ftp_ssl_get(urls=[url], with_stats=True) r.check_stats(count=count, http_status=226) self.check_downloads(curl, srcfile, count) + r.check_stats_timelines() @pytest.mark.parametrize("docname", [ 'data-1k', 'data-1m', 'data-10m' @@ -111,6 +113,7 @@ def test_31_03_download_10_serial(self, env: Env, vsftpds: VsFTPD, docname): r.check_stats(count=count, http_status=226) self.check_downloads(curl, srcfile, count) assert r.total_connects == count + 1, 'should reuse the control conn' + r.check_stats_timelines() @pytest.mark.parametrize("docname", [ 'data-1k', 'data-1m', 'data-10m' @@ -126,6 +129,7 @@ def test_31_04_download_10_parallel(self, env: Env, vsftpds: VsFTPD, docname): r.check_stats(count=count, http_status=226) self.check_downloads(curl, srcfile, count) assert r.total_connects > count + 1, 'should have used several control conns' + r.check_stats_timelines() @pytest.mark.parametrize("docname", [ 'upload-1k', 'upload-100k', 'upload-1m' @@ -140,6 +144,7 @@ def test_31_05_upload_1(self, env: Env, vsftpds: VsFTPD, docname): r = curl.ftp_ssl_upload(urls=[url], fupload=f'{srcfile}', with_stats=True) r.check_stats(count=count, http_status=226) self.check_upload(env, vsftpds, docname=docname) + r.check_stats_timelines() def _rmf(self, path): if os.path.exists(path): diff --git a/tests/http/test_32_ftps_vsftpd.py b/tests/http/test_32_ftps_vsftpd.py index 46690a84355e..7a849d374044 100644 --- a/tests/http/test_32_ftps_vsftpd.py +++ b/tests/http/test_32_ftps_vsftpd.py @@ -85,6 +85,7 @@ def test_32_01_list_dir(self, env: Env, vsftpds: VsFTPD): r.check_stats(count=1, http_status=226) lines = open(os.path.join(curl.run_dir, 'download_#1.data')).readlines() assert len(lines) == 4, f'list: {lines}' + r.check_stats_timelines() # download 1 file, no SSL @pytest.mark.parametrize("docname", [ @@ -98,6 +99,7 @@ def test_32_02_download_1(self, env: Env, vsftpds: VsFTPD, docname): r = curl.ftp_get(urls=[url], with_stats=True) r.check_stats(count=count, http_status=226) self.check_downloads(curl, srcfile, count) + r.check_stats_timelines() @pytest.mark.parametrize("docname", [ 'data-1k', 'data-1m', 'data-10m' @@ -111,6 +113,7 @@ def test_32_03_download_10_serial(self, env: Env, vsftpds: VsFTPD, docname): r.check_stats(count=count, http_status=226) self.check_downloads(curl, srcfile, count) assert r.total_connects == count + 1, 'should reuse the control conn' + r.check_stats_timelines() # 2 serial transfers, first with 'ftps://' and second with 'ftp://' # we want connection reuse in this case @@ -123,6 +126,7 @@ def test_32_03b_ftp_compat_ftps(self, env: Env, vsftpds: VsFTPD): r = curl.ftp_get(urls=[url1, url2], with_stats=True) r.check_stats(count=count, http_status=226) assert r.total_connects == count + 1, 'should reuse the control conn' + r.check_stats_timelines() @pytest.mark.parametrize("docname", [ 'data-1k', 'data-1m', 'data-10m' @@ -138,6 +142,7 @@ def test_32_04_download_10_parallel(self, env: Env, vsftpds: VsFTPD, docname): r.check_stats(count=count, http_status=226) self.check_downloads(curl, srcfile, count) assert r.total_connects > count + 1, 'should have used several control conns' + r.check_stats_timelines() @pytest.mark.parametrize("docname", [ 'upload-1k', 'upload-100k', 'upload-1m' @@ -152,6 +157,7 @@ def test_32_05_upload_1(self, env: Env, vsftpds: VsFTPD, docname): r = curl.ftp_upload(urls=[url], fupload=f'{srcfile}', with_stats=True) r.check_stats(count=count, http_status=226) self.check_upload(env, vsftpds, docname=docname) + r.check_stats_timelines() def _rmf(self, path): if os.path.exists(path): diff --git a/tests/http/testenv/curl.py b/tests/http/testenv/curl.py index a92e4f681f34..e486715fa79b 100644 --- a/tests/http/testenv/curl.py +++ b/tests/http/testenv/curl.py @@ -493,6 +493,80 @@ def check_stats(self, count: int, http_status: Optional[int] = None, f'status #{idx} remote_ip: expected {remote_ip}, '\ f'got {x["remote_ip"]}\n{self.dump_stat(x)}' + def check_stat_positive(self, s, idx, key): + assert key in s, f'stat #{idx} "{key}" missing: {s}' + assert s[key] > 0, f'stat #{idx} "{key}" not positive: {s}' + + def check_stat_positive_or_0(self, s, idx, key): + assert key in s, f'stat #{idx} "{key}" missing: {s}' + assert s[key] >= 0, f'stat #{idx} "{key}" not positive: {s}' + + def check_stat_zero(self, s, key): + assert key in s, f'stat "{key}" missing: {s}' + assert s[key] == 0, f'stat "{key}" not zero: {s}' + + def check_stats_timelines(self): + for i in range(len(self._stats)): + self.check_stats_timeline(i) + + def check_stats_timeline(self, idx): + # check timings reported on a transfer for consistency + s = self._stats[idx] + + url = s['url_effective'] + # connect time is sometimes reported as 0 by openssl-quic (sigh) + self.check_stat_positive_or_0(s, idx, 'time_connect') + # all stat keys which reporting timings + all_keys = { + 'time_queue', 'time_namelookup', + 'time_connect', 'time_appconnect', + 'time_pretransfer', 'time_posttransfer', + 'time_starttransfer', 'time_total', + } + # stat keys where we expect a positive value + ref_tl = [] + exact_match = True + # redirects mess up the queue time, only count without + if s['time_redirect'] == 0: + ref_tl += ['time_queue'] + else: + exact_match = False + # connect events? + if url.startswith('ftp'): + # ftp is messy with connect events for its DATA connection + exact_match = False + elif s['num_connects'] > 0: + ref_tl += ['time_namelookup', 'time_connect'] + if url.startswith('https:'): + ref_tl += ['time_appconnect'] + # what kind of transfer was it? + if s['size_upload'] == 0 and s['size_download'] > 0: + # this is a download + dl_tl = ['time_pretransfer', 'time_starttransfer'] + if s['size_request'] > 0: + dl_tl = ['time_posttransfer'] + dl_tl + ref_tl += dl_tl + elif s['size_upload'] > 0 and s['size_download'] == 0: + # this is an upload + ul_tl = ['time_pretransfer', 'time_posttransfer'] + ref_tl += ul_tl + else: + # could be a 0-length upload or 0-length download, not sure + exact_match = False + # always there at the end + ref_tl += ['time_total'] + + # assert all events in reference timeline are > 0 + for key in ref_tl: + self.check_stat_positive(s, idx, key) + if exact_match: + # assert all events not in reference timeline are 0 + for key in [key for key in all_keys if key not in ref_tl]: + self.check_stat_zero(s, key) + # calculate the timeline that did happen + seen_tl = sorted(ref_tl, key=lambda ts: s[ts]) + assert seen_tl == ref_tl, f'{[f"{ts}: {s[ts]}" for ts in seen_tl]}' + def dump_logs(self): lines = ['>>--stdout ----------------------------------------------\n'] lines.extend(self._stdout) diff --git a/tests/libtest/lib500.c b/tests/libtest/lib500.c index ffb974f4f0cb..ff886a05ca60 100644 --- a/tests/libtest/lib500.c +++ b/tests/libtest/lib500.c @@ -128,7 +128,10 @@ static CURLcode test_lib500(const char *URL) (time_pretransfer / 1000000), (long)(time_pretransfer % 1000000)); } - if(time_pretransfer > time_posttransfer) { + if(time_posttransfer > time_pretransfer) { + /* counter-intuitive: on a GET request, all bytes are sent *before* + * PRETRANSFER happens. Thus POSTTRANSFER has to be smaller. + * The reverse would be true for a POST/PUT. */ curl_mfprintf(moo, "pretransfer vs posttransfer: %" CURL_FORMAT_CURL_OFF_T ".%06ld %" CURL_FORMAT_CURL_OFF_T ".%06ld\n", From 16b44f6a3ad13386a25dfc005794696a69f949b0 Mon Sep 17 00:00:00 2001 From: Stefan Eissing Date: Wed, 19 Nov 2025 11:54:36 +0100 Subject: [PATCH 060/415] multi: simplify admin handle processing Fold the special connection pool shutdown handling in multi the things the admin handle cares about. Add the admin handle to the 'process' bitset, deduce it from the 'running' count. The admin handle is the processed like any other transfer, but has a special case in `multi_runsingle()`. Simplifies all other multi processing parts. Closes #19604 --- lib/multi.c | 82 ++++++++++++++++++++++---------------------------- lib/multi_ev.c | 5 ++- lib/multi_ev.h | 3 +- 3 files changed, 39 insertions(+), 51 deletions(-) diff --git a/lib/multi.c b/lib/multi.c index db04d64c231b..5789861026af 100644 --- a/lib/multi.c +++ b/lib/multi.c @@ -101,9 +101,9 @@ static void move_pending_to_connect(struct Curl_multi *multi, static CURLMcode add_next_timeout(struct curltime now, struct Curl_multi *multi, struct Curl_easy *d); -static CURLMcode multi_timeout(struct Curl_multi *multi, - struct curltime *expire_time, - long *timeout_ms); +static void multi_timeout(struct Curl_multi *multi, + struct curltime *expire_time, + long *timeout_ms); static void process_pending_handles(struct Curl_multi *multi); static void multi_xfer_bufs_free(struct Curl_multi *multi); #ifdef DEBUGBUILD @@ -273,11 +273,13 @@ struct Curl_multi *Curl_multi_handle(unsigned int xfer_table_size, multi->admin->multi = multi; multi->admin->state.internal = TRUE; Curl_llist_init(&multi->admin->state.timeoutlist, NULL); + #ifdef DEBUGBUILD if(getenv("CURL_DEBUG")) multi->admin->set.verbose = TRUE; #endif Curl_uint_tbl_add(&multi->xfers, multi->admin, &multi->admin->mid); + Curl_uint_bset_add(&multi->process, multi->admin->mid); if(Curl_cshutdn_init(&multi->cshutdn, multi)) goto error; @@ -413,7 +415,6 @@ static CURLMcode multi_xfers_add(struct Curl_multi *multi, return CURLM_OK; } - CURLMcode curl_multi_add_handle(CURLM *m, CURL *d) { CURLMcode rc; @@ -500,6 +501,7 @@ CURLMcode curl_multi_add_handle(CURLM *m, CURL *d) /* Make sure the new handle will run */ Curl_multi_mark_dirty(data); + /* Necessary in event based processing, where dirty handles trigger * a timeout callback invocation. */ rc = Curl_update_timer(multi); @@ -1441,7 +1443,7 @@ static CURLMcode multi_wait(struct Curl_multi *multi, * poll. Collecting the sockets may install new timers by protocols * and connection filters. * Use the shorter one of the internal and the caller requested timeout. */ - (void)multi_timeout(multi, &expire_time, &timeout_internal); + multi_timeout(multi, &expire_time, &timeout_internal); if((timeout_internal >= 0) && (timeout_internal < (long)timeout_ms)) timeout_ms = (int)timeout_internal; @@ -1562,7 +1564,8 @@ static CURLMcode multi_wait(struct Curl_multi *multi, long sleep_ms = 0; /* Avoid busy-looping when there is nothing particular to wait for */ - if(!curl_multi_timeout(multi, &sleep_ms) && sleep_ms) { + multi_timeout(multi, &expire_time, &sleep_ms); + if(sleep_ms) { if(sleep_ms > timeout_ms) sleep_ms = timeout_ms; /* when there are no easy handles in the multi, this holds a -1 @@ -2394,6 +2397,11 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi, * again during processing, triggering a re-run later. */ Curl_uint_bset_remove(&multi->dirty, data->mid); + if(data == multi->admin) { + Curl_cshutdn_perform(&multi->cshutdn, multi->admin, CURL_SOCKET_TIMEOUT); + return CURLM_OK; + } + do { /* A "stream" here is a logical stream if the protocol can handle that (HTTP/2), or the full connection for older protocols */ @@ -2810,19 +2818,13 @@ CURLMcode curl_multi_perform(CURLM *m, int *running_handles) Curl_uint_bset_remove(&multi->dirty, mid); continue; } - if(data != multi->admin) { - /* admin handle is processed below */ - sigpipe_apply(data, &pipe_st); - result = multi_runsingle(multi, &now, data); - if(result) - returncode = result; - } + sigpipe_apply(data, &pipe_st); + result = multi_runsingle(multi, &now, data); + if(result) + returncode = result; } while(Curl_uint_bset_next(&multi->process, mid, &mid)); } - - sigpipe_apply(multi->admin, &pipe_st); - Curl_cshutdn_perform(&multi->cshutdn, multi->admin, CURL_SOCKET_TIMEOUT); sigpipe_restore(&pipe_st); if(multi_ischanged(m, TRUE)) @@ -3077,7 +3079,6 @@ struct multi_run_ctx { struct curltime now; size_t run_xfers; SIGPIPE_MEMBER(pipe_st); - bool run_cpool; }; static void multi_mark_expired_as_dirty(struct multi_run_ctx *mrc) @@ -3127,12 +3128,7 @@ static CURLMcode multi_run_dirty(struct multi_run_ctx *mrc) if(data) { CURL_TRC_M(data, "multi_run_dirty"); - if(data == multi->admin) { - Curl_uint_bset_remove(&multi->dirty, mid); - mrc->run_cpool = TRUE; - continue; - } - else if(!Curl_uint_bset_contains(&multi->process, mid)) { + if(!Curl_uint_bset_contains(&multi->process, mid)) { /* We are no longer processing this transfer */ Curl_uint_bset_remove(&multi->dirty, mid); continue; @@ -3185,13 +3181,12 @@ static CURLMcode multi_socket(struct Curl_multi *multi, /* Reassess event status of all active transfers */ result = Curl_multi_ev_assess_xfer_bset(multi, &multi->process); } - mrc.run_cpool = TRUE; goto out; } if(s != CURL_SOCKET_TIMEOUT) { /* Mark all transfers of that socket as dirty */ - Curl_multi_ev_dirty_xfers(multi, s, &mrc.run_cpool); + Curl_multi_ev_dirty_xfers(multi, s); } else { /* Asked to run due to time-out. Clear the 'last_expire_ts' variable to @@ -3200,7 +3195,6 @@ static CURLMcode multi_socket(struct Curl_multi *multi, handles the case when the application asks libcurl to run the timeout prematurely. */ memset(&multi->last_expire_ts, 0, sizeof(multi->last_expire_ts)); - mrc.run_cpool = TRUE; } multi_mark_expired_as_dirty(&mrc); @@ -3220,10 +3214,6 @@ static CURLMcode multi_socket(struct Curl_multi *multi, } out: - if(mrc.run_cpool) { - sigpipe_apply(multi->admin, &mrc.pipe_st); - Curl_cshutdn_perform(&multi->cshutdn, multi->admin, s); - } sigpipe_restore(&mrc.pipe_st); if(multi_ischanged(multi, TRUE)) @@ -3394,9 +3384,9 @@ static bool multi_has_dirties(struct Curl_multi *multi) return FALSE; } -static CURLMcode multi_timeout(struct Curl_multi *multi, - struct curltime *expire_time, - long *timeout_ms) +static void multi_timeout(struct Curl_multi *multi, + struct curltime *expire_time, + long *timeout_ms) { static const struct curltime tv_zero = {0, 0}; #ifndef CURL_DISABLE_VERBOSE_STRINGS @@ -3405,13 +3395,13 @@ static CURLMcode multi_timeout(struct Curl_multi *multi, if(multi->dead) { *timeout_ms = 0; - return CURLM_OK; + return; } if(multi_has_dirties(multi)) { *expire_time = curlx_now(); *timeout_ms = 0; - return CURLM_OK; + return; } else if(multi->timetree) { /* we have a tree of expire times */ @@ -3462,8 +3452,6 @@ static CURLMcode multi_timeout(struct Curl_multi *multi, } } #endif - - return CURLM_OK; } CURLMcode curl_multi_timeout(CURLM *m, @@ -3479,7 +3467,8 @@ CURLMcode curl_multi_timeout(CURLM *m, if(multi->in_callback) return CURLM_RECURSIVE_API_CALL; - return multi_timeout(multi, &expire_time, timeout_ms); + multi_timeout(multi, &expire_time, timeout_ms); + return CURLM_OK; } /* @@ -3495,9 +3484,7 @@ CURLMcode Curl_update_timer(struct Curl_multi *multi) if(!multi->timer_cb || multi->dead) return CURLM_OK; - if(multi_timeout(multi, &expire_ts, &timeout_ms)) { - return CURLM_OK; - } + multi_timeout(multi, &expire_ts, &timeout_ms); if(timeout_ms < 0 && multi->last_timeout_ms < 0) { /* nothing to do */ @@ -3836,6 +3823,7 @@ CURLMcode curl_multi_get_offt(CURLM *m, curl_off_t *pvalue) { struct Curl_multi *multi = m; + unsigned int n; if(!GOOD_MULTI_HANDLE(multi)) return CURLM_BAD_HANDLE; @@ -3843,15 +3831,17 @@ CURLMcode curl_multi_get_offt(CURLM *m, return CURLM_BAD_FUNCTION_ARGUMENT; switch(info) { - case CURLMINFO_XFERS_CURRENT: { - unsigned int n = Curl_uint_tbl_count(&multi->xfers); + case CURLMINFO_XFERS_CURRENT: + n = Curl_uint_tbl_count(&multi->xfers); if(n && multi->admin) --n; *pvalue = (curl_off_t)n; return CURLM_OK; - } case CURLMINFO_XFERS_RUNNING: - *pvalue = (curl_off_t)Curl_uint_bset_count(&multi->process); + n = Curl_uint_bset_count(&multi->process); + if(n && Curl_uint_bset_contains(&multi->process, multi->admin->mid)) + --n; + *pvalue = (curl_off_t)n; return CURLM_OK; case CURLMINFO_XFERS_PENDING: *pvalue = (curl_off_t)Curl_uint_bset_count(&multi->pending); @@ -4037,7 +4027,7 @@ static void multi_xfer_bufs_free(struct Curl_multi *multi) struct Curl_easy *Curl_multi_get_easy(struct Curl_multi *multi, unsigned int mid) { - struct Curl_easy *data = mid ? Curl_uint_tbl_get(&multi->xfers, mid) : NULL; + struct Curl_easy *data = Curl_uint_tbl_get(&multi->xfers, mid); if(data && GOOD_EASY_HANDLE(data)) return data; CURL_TRC_M(multi->admin, "invalid easy handle in xfer table for mid=%u", diff --git a/lib/multi_ev.c b/lib/multi_ev.c index 098f8da643af..086b037527a4 100644 --- a/lib/multi_ev.c +++ b/lib/multi_ev.c @@ -574,8 +574,7 @@ CURLMcode Curl_multi_ev_assign(struct Curl_multi *multi, } void Curl_multi_ev_dirty_xfers(struct Curl_multi *multi, - curl_socket_t s, - bool *run_cpool) + curl_socket_t s) { struct mev_sh_entry *entry; @@ -606,7 +605,7 @@ void Curl_multi_ev_dirty_xfers(struct Curl_multi *multi, } if(entry->conn) - *run_cpool = TRUE; + Curl_multi_mark_dirty(multi->admin); } } diff --git a/lib/multi_ev.h b/lib/multi_ev.h index 20c1aeac81a6..34548c323232 100644 --- a/lib/multi_ev.h +++ b/lib/multi_ev.h @@ -63,8 +63,7 @@ CURLMcode Curl_multi_ev_assess_conn(struct Curl_multi *multi, /* Mark all transfers tied to the given socket as dirty */ void Curl_multi_ev_dirty_xfers(struct Curl_multi *multi, - curl_socket_t s, - bool *run_cpool); + curl_socket_t s); /* Socket will be closed, forget anything we know about it. */ void Curl_multi_ev_socket_done(struct Curl_multi *multi, From 7e5f379d71b60f35f2a6b24e4bd5cf1935400c13 Mon Sep 17 00:00:00 2001 From: Stefan Eissing Date: Tue, 25 Nov 2025 10:24:14 +0100 Subject: [PATCH 061/415] bufq: use uint8_t instead of unsigned char Closes #19690 --- lib/bufq.c | 30 +++++++++++++++--------------- lib/bufq.h | 16 ++++++++-------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/lib/bufq.c b/lib/bufq.c index e429ccf8e375..d38b78c6d5b2 100644 --- a/lib/bufq.c +++ b/lib/bufq.c @@ -51,9 +51,9 @@ static void chunk_reset(struct buf_chunk *chunk) } static size_t chunk_append(struct buf_chunk *chunk, - const unsigned char *buf, size_t len) + const uint8_t *buf, size_t len) { - unsigned char *p = &chunk->x.data[chunk->w_offset]; + uint8_t *p = &chunk->x.data[chunk->w_offset]; size_t n = chunk->dlen - chunk->w_offset; DEBUGASSERT(chunk->dlen >= chunk->w_offset); if(n) { @@ -65,9 +65,9 @@ static size_t chunk_append(struct buf_chunk *chunk, } static size_t chunk_read(struct buf_chunk *chunk, - unsigned char *buf, size_t len) + uint8_t *buf, size_t len) { - unsigned char *p = &chunk->x.data[chunk->r_offset]; + uint8_t *p = &chunk->x.data[chunk->r_offset]; size_t n = chunk->w_offset - chunk->r_offset; DEBUGASSERT(chunk->w_offset >= chunk->r_offset); if(!n) { @@ -89,7 +89,7 @@ static CURLcode chunk_slurpn(struct buf_chunk *chunk, size_t max_len, Curl_bufq_reader *reader, void *reader_ctx, size_t *pnread) { - unsigned char *p = &chunk->x.data[chunk->w_offset]; + uint8_t *p = &chunk->x.data[chunk->w_offset]; size_t n = chunk->dlen - chunk->w_offset; /* free amount */ CURLcode result; @@ -108,7 +108,7 @@ static CURLcode chunk_slurpn(struct buf_chunk *chunk, size_t max_len, } static void chunk_peek(const struct buf_chunk *chunk, - const unsigned char **pbuf, size_t *plen) + const uint8_t **pbuf, size_t *plen) { DEBUGASSERT(chunk->w_offset >= chunk->r_offset); *pbuf = &chunk->x.data[chunk->r_offset]; @@ -116,7 +116,7 @@ static void chunk_peek(const struct buf_chunk *chunk, } static void chunk_peek_at(const struct buf_chunk *chunk, size_t offset, - const unsigned char **pbuf, size_t *plen) + const uint8_t **pbuf, size_t *plen) { offset += chunk->r_offset; DEBUGASSERT(chunk->w_offset >= offset); @@ -370,7 +370,7 @@ static struct buf_chunk *get_non_full_tail(struct bufq *q) } CURLcode Curl_bufq_write(struct bufq *q, - const unsigned char *buf, size_t len, + const uint8_t *buf, size_t len, size_t *pnwritten) { struct buf_chunk *tail; @@ -400,10 +400,10 @@ CURLcode Curl_bufq_cwrite(struct bufq *q, const char *buf, size_t len, size_t *pnwritten) { - return Curl_bufq_write(q, (const unsigned char *)buf, len, pnwritten); + return Curl_bufq_write(q, (const uint8_t *)buf, len, pnwritten); } -CURLcode Curl_bufq_read(struct bufq *q, unsigned char *buf, size_t len, +CURLcode Curl_bufq_read(struct bufq *q, uint8_t *buf, size_t len, size_t *pnread) { *pnread = 0; @@ -422,11 +422,11 @@ CURLcode Curl_bufq_read(struct bufq *q, unsigned char *buf, size_t len, CURLcode Curl_bufq_cread(struct bufq *q, char *buf, size_t len, size_t *pnread) { - return Curl_bufq_read(q, (unsigned char *)buf, len, pnread); + return Curl_bufq_read(q, (uint8_t *)buf, len, pnread); } bool Curl_bufq_peek(struct bufq *q, - const unsigned char **pbuf, size_t *plen) + const uint8_t **pbuf, size_t *plen) { if(q->head && chunk_is_empty(q->head)) { prune_head(q); @@ -441,7 +441,7 @@ bool Curl_bufq_peek(struct bufq *q, } bool Curl_bufq_peek_at(struct bufq *q, size_t offset, - const unsigned char **pbuf, size_t *plen) + const uint8_t **pbuf, size_t *plen) { struct buf_chunk *c = q->head; size_t clen; @@ -477,7 +477,7 @@ void Curl_bufq_skip(struct bufq *q, size_t amount) CURLcode Curl_bufq_pass(struct bufq *q, Curl_bufq_writer *writer, void *writer_ctx, size_t *pwritten) { - const unsigned char *buf; + const uint8_t *buf; size_t blen; CURLcode result = CURLE_OK; @@ -507,7 +507,7 @@ CURLcode Curl_bufq_pass(struct bufq *q, Curl_bufq_writer *writer, } CURLcode Curl_bufq_write_pass(struct bufq *q, - const unsigned char *buf, size_t len, + const uint8_t *buf, size_t len, Curl_bufq_writer *writer, void *writer_ctx, size_t *pwritten) { diff --git a/lib/bufq.h b/lib/bufq.h index ad8e6435fae1..9557e5d33bba 100644 --- a/lib/bufq.h +++ b/lib/bufq.h @@ -38,7 +38,7 @@ struct buf_chunk { size_t r_offset; /* first unread bytes */ size_t w_offset; /* one after last written byte */ union { - unsigned char data[1]; /* the buffer for `dlen` bytes */ + uint8_t data[1]; /* the buffer for `dlen` bytes */ void *dummy; /* alignment */ } x; }; @@ -166,7 +166,7 @@ bool Curl_bufq_is_full(const struct bufq *q); * CURLE_AGAIN is returned if the buffer queue is full. */ CURLcode Curl_bufq_write(struct bufq *q, - const unsigned char *buf, size_t len, + const uint8_t *buf, size_t len, size_t *pnwritten); CURLcode Curl_bufq_cwrite(struct bufq *q, @@ -177,7 +177,7 @@ CURLcode Curl_bufq_cwrite(struct bufq *q, * Read buf from the start of the buffer queue. The buf is copied * and the amount of copied bytes is returned. */ -CURLcode Curl_bufq_read(struct bufq *q, unsigned char *buf, size_t len, +CURLcode Curl_bufq_read(struct bufq *q, uint8_t *buf, size_t len, size_t *pnread); CURLcode Curl_bufq_cread(struct bufq *q, char *buf, size_t len, @@ -193,10 +193,10 @@ CURLcode Curl_bufq_cread(struct bufq *q, char *buf, size_t len, * is modified, see `Curl_bufq_skip()`` */ bool Curl_bufq_peek(struct bufq *q, - const unsigned char **pbuf, size_t *plen); + const uint8_t **pbuf, size_t *plen); bool Curl_bufq_peek_at(struct bufq *q, size_t offset, - const unsigned char **pbuf, size_t *plen); + const uint8_t **pbuf, size_t *plen); /** * Tell the buffer queue to discard `amount` buf bytes at the head @@ -206,7 +206,7 @@ bool Curl_bufq_peek_at(struct bufq *q, size_t offset, void Curl_bufq_skip(struct bufq *q, size_t amount); typedef CURLcode Curl_bufq_writer(void *writer_ctx, - const unsigned char *buf, size_t len, + const uint8_t *buf, size_t len, size_t *pwritten); /** * Passes the chunks in the buffer queue to the writer and returns @@ -221,7 +221,7 @@ CURLcode Curl_bufq_pass(struct bufq *q, Curl_bufq_writer *writer, void *writer_ctx, size_t *pwritten); typedef CURLcode Curl_bufq_reader(void *reader_ctx, - unsigned char *buf, size_t len, + uint8_t *buf, size_t len, size_t *pnread); /** @@ -253,7 +253,7 @@ CURLcode Curl_bufq_sipn(struct bufq *q, size_t max_len, * amount buffered, chunk size, etc. */ CURLcode Curl_bufq_write_pass(struct bufq *q, - const unsigned char *buf, size_t len, + const uint8_t *buf, size_t len, Curl_bufq_writer *writer, void *writer_ctx, size_t *pwritten); From 0f6ad5ab7d040bf1b9dcc16d12430209079378a6 Mon Sep 17 00:00:00 2001 From: Stefan Eissing Date: Tue, 25 Nov 2025 13:03:04 +0100 Subject: [PATCH 062/415] ngtcp2: use stdint types Use int64_t and uint64_t directly without needing to cast to curl_int64_t and curl_uint64_t. Closes #19696 --- lib/vquic/curl_ngtcp2.c | 138 ++++++++++++++++++---------------------- 1 file changed, 63 insertions(+), 75 deletions(-) diff --git a/lib/vquic/curl_ngtcp2.c b/lib/vquic/curl_ngtcp2.c index f63162b34417..d6439287846e 100644 --- a/lib/vquic/curl_ngtcp2.c +++ b/lib/vquic/curl_ngtcp2.c @@ -215,10 +215,10 @@ static void cf_ngtcp2_setup_keep_alive(struct Curl_cfilter *cf, ngtcp2_duration keep_ns; keep_ns = (rp->max_idle_timeout > 1) ? (rp->max_idle_timeout / 2) : 1; ngtcp2_conn_set_keep_alive_timeout(ctx->qconn, keep_ns); - CURL_TRC_CF(data, cf, "peer idle timeout is %" FMT_PRIu64 "ms, " - "set keep-alive to %" FMT_PRIu64 " ms.", - (curl_uint64_t)(rp->max_idle_timeout / NGTCP2_MILLISECONDS), - (curl_uint64_t)(keep_ns / NGTCP2_MILLISECONDS)); + CURL_TRC_CF(data, cf, "peer idle timeout is %" PRIu64 "ms, " + "set keep-alive to %" PRIu64 " ms.", + (rp->max_idle_timeout / NGTCP2_MILLISECONDS), + (keep_ns / NGTCP2_MILLISECONDS)); } } @@ -235,11 +235,11 @@ static CURLcode cf_progress_egress(struct Curl_cfilter *cf, * All about the H3 internals of a stream */ struct h3_stream_ctx { - curl_int64_t id; /* HTTP/3 protocol identifier */ + int64_t id; /* HTTP/3 protocol identifier */ struct bufq sendbuf; /* h3 request body */ struct h1_req_parser h1; /* h1 request parsing */ size_t sendbuf_len_in_flight; /* sendbuf amount "in flight" */ - curl_uint64_t error3; /* HTTP/3 stream error code */ + uint64_t error3; /* HTTP/3 stream error code */ curl_off_t upload_left; /* number of request bytes left to upload */ uint64_t download_unacked; /* bytes not acknowledged yet */ int status_code; /* HTTP status code */ @@ -301,7 +301,7 @@ static CURLcode h3_data_setup(struct Curl_cfilter *cf, #if NGTCP2_VERSION_NUM < 0x011100 struct cf_ngtcp2_sfind_ctx { - curl_int64_t stream_id; + int64_t stream_id; struct h3_stream_ctx *stream; unsigned int mid; }; @@ -320,7 +320,7 @@ static bool cf_ngtcp2_sfind(unsigned int mid, void *value, void *user_data) } static struct h3_stream_ctx * -cf_ngtcp2_get_stream(struct cf_ngtcp2_ctx *ctx, curl_int64_t stream_id) +cf_ngtcp2_get_stream(struct cf_ngtcp2_ctx *ctx, int64_t stream_id) { struct cf_ngtcp2_sfind_ctx fctx; fctx.stream_id = stream_id; @@ -330,7 +330,7 @@ cf_ngtcp2_get_stream(struct cf_ngtcp2_ctx *ctx, curl_int64_t stream_id) } #else static struct h3_stream_ctx *cf_ngtcp2_get_stream(struct cf_ngtcp2_ctx *ctx, - curl_int64_t stream_id) + int64_t stream_id) { struct Curl_easy *data = ngtcp2_conn_get_stream_user_data(ctx->qconn, stream_id); @@ -360,7 +360,7 @@ static void cf_ngtcp2_stream_close(struct Curl_cfilter *cf, NGHTTP3_H3_REQUEST_CANCELLED); result = cf_progress_egress(cf, data, NULL); if(result) - CURL_TRC_CF(data, cf, "[%" FMT_PRId64 "] cancel stream -> %d", + CURL_TRC_CF(data, cf, "[%" PRId64 "] cancel stream -> %d", stream->id, result); } } @@ -371,7 +371,7 @@ static void h3_data_done(struct Curl_cfilter *cf, struct Curl_easy *data) struct h3_stream_ctx *stream = H3_STREAM_CTX(ctx, data); (void)cf; if(stream) { - CURL_TRC_CF(data, cf, "[%" FMT_PRId64 "] easy handle is done", + CURL_TRC_CF(data, cf, "[%" PRId64 "] easy handle is done", stream->id); cf_ngtcp2_stream_close(cf, data, stream); Curl_uint_hash_remove(&ctx->streams, data->mid); @@ -518,12 +518,11 @@ static int cf_ngtcp2_handshake_completed(ngtcp2_conn *tconn, void *user_data) const ngtcp2_transport_params *rp; rp = ngtcp2_conn_get_remote_transport_params(ctx->qconn); CURL_TRC_CF(data, cf, "handshake complete after %" FMT_TIMEDIFF_T - "ms, remote transport[max_udp_payload=%" FMT_PRIu64 - ", initial_max_data=%" FMT_PRIu64 + "ms, remote transport[max_udp_payload=%" PRIu64 + ", initial_max_data=%" PRIu64 "]", curlx_timediff_ms(ctx->handshake_at, ctx->started_at), - (curl_uint64_t)rp->max_udp_payload_size, - (curl_uint64_t)rp->initial_max_data); + rp->max_udp_payload_size, rp->initial_max_data); } #endif @@ -607,13 +606,12 @@ static void cf_ngtcp2_h3_err_set(struct Curl_cfilter *cf, } static int cb_recv_stream_data(ngtcp2_conn *tconn, uint32_t flags, - int64_t sid, uint64_t offset, + int64_t stream_id, uint64_t offset, const uint8_t *buf, size_t buflen, void *user_data, void *stream_user_data) { struct Curl_cfilter *cf = user_data; struct cf_ngtcp2_ctx *ctx = cf->ctx; - curl_int64_t stream_id = (curl_int64_t)sid; nghttp3_ssize nconsumed; int fin = (flags & NGTCP2_STREAM_DATA_FLAG_FIN) ? 1 : 0; struct Curl_easy *data = stream_user_data; @@ -625,12 +623,12 @@ static int cb_recv_stream_data(ngtcp2_conn *tconn, uint32_t flags, if(!data) data = CF_DATA_CURRENT(cf); if(data) - CURL_TRC_CF(data, cf, "[%" FMT_PRId64 "] read_stream(len=%zu) -> %zd", + CURL_TRC_CF(data, cf, "[%" PRId64 "] read_stream(len=%zu) -> %zd", stream_id, buflen, nconsumed); if(nconsumed < 0) { struct h3_stream_ctx *stream = H3_STREAM_CTX(ctx, data); if(data && stream) { - CURL_TRC_CF(data, cf, "[%" FMT_PRId64 "] error on known stream, " + CURL_TRC_CF(data, cf, "[%" PRId64 "] error on known stream, " "reset=%d, closed=%d", stream_id, stream->reset, stream->closed); } @@ -669,13 +667,12 @@ cb_acked_stream_data_offset(ngtcp2_conn *tconn, int64_t stream_id, } static int cb_stream_close(ngtcp2_conn *tconn, uint32_t flags, - int64_t sid, uint64_t app_error_code, + int64_t stream_id, uint64_t app_error_code, void *user_data, void *stream_user_data) { struct Curl_cfilter *cf = user_data; struct cf_ngtcp2_ctx *ctx = cf->ctx; struct Curl_easy *data = stream_user_data; - curl_int64_t stream_id = (curl_int64_t)sid; int rv; (void)tconn; @@ -690,9 +687,8 @@ static int cb_stream_close(ngtcp2_conn *tconn, uint32_t flags, } rv = nghttp3_conn_close_stream(ctx->h3conn, stream_id, app_error_code); - CURL_TRC_CF(data, cf, "[%" FMT_PRId64 "] quic close(app_error=%" - FMT_PRIu64 ") -> %d", stream_id, (curl_uint64_t)app_error_code, - rv); + CURL_TRC_CF(data, cf, "[%" PRId64 "] quic close(app_error=%" + PRIu64 ") -> %d", stream_id, app_error_code, rv); if(rv && rv != NGHTTP3_ERR_STREAM_NOT_FOUND) { cf_ngtcp2_h3_err_set(cf, data, rv); return NGTCP2_ERR_CALLBACK_FAILURE; @@ -701,13 +697,12 @@ static int cb_stream_close(ngtcp2_conn *tconn, uint32_t flags, return 0; } -static int cb_stream_reset(ngtcp2_conn *tconn, int64_t sid, +static int cb_stream_reset(ngtcp2_conn *tconn, int64_t stream_id, uint64_t final_size, uint64_t app_error_code, void *user_data, void *stream_user_data) { struct Curl_cfilter *cf = user_data; struct cf_ngtcp2_ctx *ctx = cf->ctx; - curl_int64_t stream_id = (curl_int64_t)sid; struct Curl_easy *data = stream_user_data; int rv; (void)tconn; @@ -716,7 +711,7 @@ static int cb_stream_reset(ngtcp2_conn *tconn, int64_t sid, (void)data; rv = nghttp3_conn_shutdown_stream_read(ctx->h3conn, stream_id); - CURL_TRC_CF(data, cf, "[%" FMT_PRId64 "] reset -> %d", stream_id, rv); + CURL_TRC_CF(data, cf, "[%" PRId64 "] reset -> %d", stream_id, rv); if(rv && rv != NGHTTP3_ERR_STREAM_NOT_FOUND) { return NGTCP2_ERR_CALLBACK_FAILURE; } @@ -754,9 +749,8 @@ static int cb_extend_max_local_streams_bidi(ngtcp2_conn *tconn, (void)tconn; ctx->max_bidi_streams = max_streams; if(data) - CURL_TRC_CF(data, cf, "max bidi streams now %" FMT_PRIu64 - ", used %" FMT_PRIu64, (curl_uint64_t)ctx->max_bidi_streams, - (curl_uint64_t)ctx->used_bidi_streams); + CURL_TRC_CF(data, cf, "max bidi streams now %" PRIu64 ", used %" PRIu64, + ctx->max_bidi_streams, ctx->used_bidi_streams); return 0; } @@ -778,8 +772,7 @@ static int cb_extend_max_stream_data(ngtcp2_conn *tconn, int64_t stream_id, } stream = H3_STREAM_CTX(ctx, s_data); if(stream && stream->quic_flow_blocked) { - CURL_TRC_CF(s_data, cf, "[%" FMT_PRId64 "] unblock quic flow", - (curl_int64_t)stream_id); + CURL_TRC_CF(s_data, cf, "[%" PRId64 "] unblock quic flow", stream_id); stream->quic_flow_blocked = FALSE; Curl_multi_mark_dirty(s_data); } @@ -986,14 +979,13 @@ static CURLcode cf_ngtcp2_adjust_pollset(struct Curl_cfilter *cf, return result; } -static int cb_h3_stream_close(nghttp3_conn *conn, int64_t sid, +static int cb_h3_stream_close(nghttp3_conn *conn, int64_t stream_id, uint64_t app_error_code, void *user_data, void *stream_user_data) { struct Curl_cfilter *cf = user_data; struct cf_ngtcp2_ctx *ctx = cf->ctx; struct Curl_easy *data = stream_user_data; - curl_int64_t stream_id = (curl_int64_t)sid; struct h3_stream_ctx *stream = H3_STREAM_CTX(ctx, data); (void)conn; (void)stream_id; @@ -1003,15 +995,15 @@ static int cb_h3_stream_close(nghttp3_conn *conn, int64_t sid, return 0; stream->closed = TRUE; - stream->error3 = (curl_uint64_t)app_error_code; + stream->error3 = app_error_code; if(stream->error3 != NGHTTP3_H3_NO_ERROR) { stream->reset = TRUE; stream->send_closed = TRUE; - CURL_TRC_CF(data, cf, "[%" FMT_PRId64 "] RESET: error %" FMT_PRIu64, + CURL_TRC_CF(data, cf, "[%" PRId64 "] RESET: error %" PRIu64, stream->id, stream->error3); } else { - CURL_TRC_CF(data, cf, "[%" FMT_PRId64 "] CLOSED", stream->id); + CURL_TRC_CF(data, cf, "[%" PRId64 "] CLOSED", stream->id); } Curl_multi_mark_dirty(data); return 0; @@ -1031,7 +1023,7 @@ static void h3_xfer_write_resp_hd(struct Curl_cfilter *cf, if(!stream->xfer_result) { stream->xfer_result = Curl_xfer_write_resp_hd(data, buf, blen, eos); if(stream->xfer_result) - CURL_TRC_CF(data, cf, "[%"FMT_PRId64"] error %d writing %zu " + CURL_TRC_CF(data, cf, "[%" PRId64 "] error %d writing %zu " "bytes of headers", stream->id, stream->xfer_result, blen); } } @@ -1051,8 +1043,8 @@ static void h3_xfer_write_resp(struct Curl_cfilter *cf, stream->xfer_result = Curl_xfer_write_resp(data, buf, blen, eos); /* If the transfer write is errored, we do not want any more data */ if(stream->xfer_result) { - CURL_TRC_CF(data, cf, "[%"FMT_PRId64"] error %d writing %zu bytes " - "of data", stream->id, stream->xfer_result, blen); + CURL_TRC_CF(data, cf, "[%" PRId64 "] error %d writing %zu bytes of data", + stream->id, stream->xfer_result, blen); } } } @@ -1078,7 +1070,7 @@ static void cf_ngtcp2_ack_stream(struct Curl_cfilter *cf, } if(ack_len) { - CURL_TRC_CF(data, cf, "[%" FMT_PRId64 "] ACK %" PRIu64 + CURL_TRC_CF(data, cf, "[%" PRId64 "] ACK %" PRIu64 "/%" PRIu64 " bytes of DATA", stream->id, ack_len, stream->download_unacked); ngtcp2_conn_extend_max_stream_offset(ctx->qconn, stream->id, ack_len); @@ -1102,7 +1094,7 @@ static int cb_h3_recv_data(nghttp3_conn *conn, int64_t stream3_id, return NGHTTP3_ERR_CALLBACK_FAILURE; h3_xfer_write_resp(cf, data, stream, (const char *)buf, blen, FALSE); - CURL_TRC_CF(data, cf, "[%" FMT_PRId64 "] DATA len=%zu", stream->id, blen); + CURL_TRC_CF(data, cf, "[%" PRId64 "] DATA len=%zu", stream->id, blen); ngtcp2_conn_extend_max_offset(ctx->qconn, blen); if(UINT64_MAX - blen < stream->download_unacked) @@ -1130,13 +1122,12 @@ static int cb_h3_deferred_consume(nghttp3_conn *conn, int64_t stream3_id, return 0; } -static int cb_h3_end_headers(nghttp3_conn *conn, int64_t sid, +static int cb_h3_end_headers(nghttp3_conn *conn, int64_t stream_id, int fin, void *user_data, void *stream_user_data) { struct Curl_cfilter *cf = user_data; struct cf_ngtcp2_ctx *ctx = cf->ctx; struct Curl_easy *data = stream_user_data; - curl_int64_t stream_id = (curl_int64_t)sid; struct h3_stream_ctx *stream = H3_STREAM_CTX(ctx, data); (void)conn; (void)stream_id; @@ -1148,7 +1139,7 @@ static int cb_h3_end_headers(nghttp3_conn *conn, int64_t sid, /* add a CRLF only if we have received some headers */ h3_xfer_write_resp_hd(cf, data, stream, STRCONST("\r\n"), stream->closed); - CURL_TRC_CF(data, cf, "[%" FMT_PRId64 "] end_headers, status=%d", + CURL_TRC_CF(data, cf, "[%" PRId64 "] end_headers, status=%d", stream_id, stream->status_code); if(stream->status_code / 100 != 1) { stream->resp_hds_complete = TRUE; @@ -1157,14 +1148,13 @@ static int cb_h3_end_headers(nghttp3_conn *conn, int64_t sid, return 0; } -static int cb_h3_recv_header(nghttp3_conn *conn, int64_t sid, +static int cb_h3_recv_header(nghttp3_conn *conn, int64_t stream_id, int32_t token, nghttp3_rcbuf *name, nghttp3_rcbuf *value, uint8_t flags, void *user_data, void *stream_user_data) { struct Curl_cfilter *cf = user_data; struct cf_ngtcp2_ctx *ctx = cf->ctx; - curl_int64_t stream_id = (curl_int64_t)sid; nghttp3_vec h3name = nghttp3_rcbuf_get_buf(name); nghttp3_vec h3val = nghttp3_rcbuf_get_buf(value); struct Curl_easy *data = stream_user_data; @@ -1196,7 +1186,7 @@ static int cb_h3_recv_header(nghttp3_conn *conn, int64_t sid, if(!result) h3_xfer_write_resp_hd(cf, data, stream, curlx_dyn_ptr(&ctx->scratch), curlx_dyn_len(&ctx->scratch), FALSE); - CURL_TRC_CF(data, cf, "[%" FMT_PRId64 "] status: %s", + CURL_TRC_CF(data, cf, "[%" PRId64 "] status: %s", stream_id, curlx_dyn_ptr(&ctx->scratch)); if(result) { return NGHTTP3_ERR_CALLBACK_FAILURE; @@ -1204,7 +1194,7 @@ static int cb_h3_recv_header(nghttp3_conn *conn, int64_t sid, } else { /* store as an HTTP1-style header */ - CURL_TRC_CF(data, cf, "[%" FMT_PRId64 "] header: %.*s: %.*s", + CURL_TRC_CF(data, cf, "[%" PRId64 "] header: %.*s: %.*s", stream_id, (int)h3name.len, h3name.base, (int)h3val.len, h3val.base); curlx_dyn_reset(&ctx->scratch); @@ -1243,13 +1233,12 @@ static int cb_h3_stop_sending(nghttp3_conn *conn, int64_t stream_id, return 0; } -static int cb_h3_reset_stream(nghttp3_conn *conn, int64_t sid, +static int cb_h3_reset_stream(nghttp3_conn *conn, int64_t stream_id, uint64_t app_error_code, void *user_data, void *stream_user_data) { struct Curl_cfilter *cf = user_data; struct cf_ngtcp2_ctx *ctx = cf->ctx; - curl_int64_t stream_id = (curl_int64_t)sid; struct Curl_easy *data = stream_user_data; int rv; (void)conn; @@ -1257,7 +1246,7 @@ static int cb_h3_reset_stream(nghttp3_conn *conn, int64_t sid, rv = ngtcp2_conn_shutdown_stream_write(ctx->qconn, 0, stream_id, app_error_code); - CURL_TRC_CF(data, cf, "[%" FMT_PRId64 "] reset -> %d", stream_id, rv); + CURL_TRC_CF(data, cf, "[%" PRId64 "] reset -> %d", stream_id, rv); if(rv && rv != NGTCP2_ERR_STREAM_NOT_FOUND) { return NGHTTP3_ERR_CALLBACK_FAILURE; } @@ -1359,12 +1348,12 @@ static CURLcode recv_closed_stream(struct Curl_cfilter *cf, (void)cf; *pnread = 0; if(stream->reset) { - failf(data, "HTTP/3 stream %" FMT_PRId64 " reset by server", stream->id); + failf(data, "HTTP/3 stream %" PRId64 " reset by server", stream->id); return data->req.bytecount ? CURLE_PARTIAL_FILE : CURLE_HTTP3; } else if(!stream->resp_hds_complete) { failf(data, - "HTTP/3 stream %" FMT_PRId64 " was closed cleanly, but before " + "HTTP/3 stream %" PRId64 " was closed cleanly, but before " "getting all response header fields, treated as error", stream->id); return CURLE_HTTP3; @@ -1413,7 +1402,7 @@ static CURLcode cf_ngtcp2_recv(struct Curl_cfilter *cf, struct Curl_easy *data, } if(stream->xfer_result) { - CURL_TRC_CF(data, cf, "[%" FMT_PRId64 "] xfer write failed", stream->id); + CURL_TRC_CF(data, cf, "[%" PRId64 "] xfer write failed", stream->id); cf_ngtcp2_stream_close(cf, data, stream); result = stream->xfer_result; goto out; @@ -1428,7 +1417,7 @@ static CURLcode cf_ngtcp2_recv(struct Curl_cfilter *cf, struct Curl_easy *data, result = Curl_1st_err(result, cf_progress_egress(cf, data, &pktx)); result = Curl_1st_err(result, check_and_set_expiry(cf, data, &pktx)); denied: - CURL_TRC_CF(data, cf, "[%" FMT_PRId64 "] cf_recv(blen=%zu) -> %d, %zu", + CURL_TRC_CF(data, cf, "[%" PRId64 "] cf_recv(blen=%zu) -> %d, %zu", stream ? stream->id : -1, blen, result, *pnread); CF_DATA_RESTORE(cf, save); return result; @@ -1519,12 +1508,12 @@ cb_h3_read_req_body(nghttp3_conn *conn, int64_t stream_id, } else if(!nwritten) { /* Not EOF, and nothing to give, we signal WOULDBLOCK. */ - CURL_TRC_CF(data, cf, "[%" FMT_PRId64 "] read req body -> AGAIN", + CURL_TRC_CF(data, cf, "[%" PRId64 "] read req body -> AGAIN", stream->id); return NGHTTP3_ERR_WOULDBLOCK; } - CURL_TRC_CF(data, cf, "[%" FMT_PRId64 "] read req body -> " + CURL_TRC_CF(data, cf, "[%" PRId64 "] read req body -> " "%d vecs%s with %zu (buffered=%zu, left=%" FMT_OFF_T ")", stream->id, (int)nvecs, *pflags == NGHTTP3_DATA_FLAG_EOF ? " EOF" : "", @@ -1605,7 +1594,7 @@ static CURLcode h3_stream_open(struct Curl_cfilter *cf, result = CURLE_SEND_ERROR; goto out; } - stream->id = (curl_int64_t)sid; + stream->id = sid; ++ctx->used_bidi_streams; switch(data->state.httpreq) { @@ -1637,11 +1626,11 @@ static CURLcode h3_stream_open(struct Curl_cfilter *cf, if(rc) { switch(rc) { case NGHTTP3_ERR_CONN_CLOSING: - CURL_TRC_CF(data, cf, "h3sid[%" FMT_PRId64 "] failed to send, " + CURL_TRC_CF(data, cf, "h3sid[%" PRId64 "] failed to send, " "connection is closing", stream->id); break; default: - CURL_TRC_CF(data, cf, "h3sid[%" FMT_PRId64 "] failed to send -> " + CURL_TRC_CF(data, cf, "h3sid[%" PRId64 "] failed to send -> " "%d (%s)", stream->id, rc, nghttp3_strerror(rc)); break; } @@ -1651,10 +1640,10 @@ static CURLcode h3_stream_open(struct Curl_cfilter *cf, } if(Curl_trc_is_verbose(data)) { - infof(data, "[HTTP/3] [%" FMT_PRId64 "] OPENED stream for %s", + infof(data, "[HTTP/3] [%" PRId64 "] OPENED stream for %s", stream->id, data->state.url); for(i = 0; i < nheader; ++i) { - infof(data, "[HTTP/3] [%" FMT_PRId64 "] [%.*s: %.*s]", stream->id, + infof(data, "[HTTP/3] [%" PRId64 "] [%.*s: %.*s]", stream->id, (int)nva[i].namelen, nva[i].name, (int)nva[i].valuelen, nva[i].value); } @@ -1708,7 +1697,7 @@ static CURLcode cf_ngtcp2_send(struct Curl_cfilter *cf, struct Curl_easy *data, stream = H3_STREAM_CTX(ctx, data); } else if(stream->xfer_result) { - CURL_TRC_CF(data, cf, "[%" FMT_PRId64 "] xfer write failed", stream->id); + CURL_TRC_CF(data, cf, "[%" PRId64 "] xfer write failed", stream->id); cf_ngtcp2_stream_close(cf, data, stream); result = stream->xfer_result; goto out; @@ -1720,13 +1709,13 @@ static CURLcode cf_ngtcp2_send(struct Curl_cfilter *cf, struct Curl_easy *data, * body. This happens on 30x or 40x responses. * We silently discard the data sent, since this is not a transport * error situation. */ - CURL_TRC_CF(data, cf, "[%" FMT_PRId64 "] discarding data" + CURL_TRC_CF(data, cf, "[%" PRId64 "] discarding data" "on closed stream with response", stream->id); result = CURLE_OK; *pnwritten = len; goto out; } - CURL_TRC_CF(data, cf, "[%" FMT_PRId64 "] send_body(len=%zu) " + CURL_TRC_CF(data, cf, "[%" PRId64 "] send_body(len=%zu) " "-> stream closed", stream->id, len); result = CURLE_HTTP3; goto out; @@ -1738,7 +1727,7 @@ static CURLcode cf_ngtcp2_send(struct Curl_cfilter *cf, struct Curl_easy *data, } else { result = Curl_bufq_write(&stream->sendbuf, buf, len, pnwritten); - CURL_TRC_CF(data, cf, "[%" FMT_PRId64 "] cf_send, add to " + CURL_TRC_CF(data, cf, "[%" PRId64 "] cf_send, add to " "sendbuf(len=%zu) -> %d, %zu", stream->id, len, result, *pnwritten); if(result) @@ -1755,7 +1744,7 @@ static CURLcode cf_ngtcp2_send(struct Curl_cfilter *cf, struct Curl_easy *data, out: result = Curl_1st_err(result, check_and_set_expiry(cf, data, &pktx)); denied: - CURL_TRC_CF(data, cf, "[%" FMT_PRId64 "] cf_send(len=%zu) -> %d, %zu", + CURL_TRC_CF(data, cf, "[%" PRId64 "] cf_send(len=%zu) -> %d, %zu", stream ? stream->id : -1, len, result, *pnwritten); CF_DATA_RESTORE(cf, save); return result; @@ -1886,8 +1875,8 @@ static CURLcode read_pkt_to_send(void *userp, struct h3_stream_ctx *stream; DEBUGASSERT(ndatalen == -1); nghttp3_conn_block_stream(ctx->h3conn, stream_id); - CURL_TRC_CF(x->data, x->cf, "[%" FMT_PRId64 "] block quic flow", - (curl_int64_t)stream_id); + CURL_TRC_CF(x->data, x->cf, "[%" PRId64 "] block quic flow", + stream_id); stream = cf_ngtcp2_get_stream(ctx, stream_id); if(stream) /* it might be not one of our h3 streams? */ stream->quic_flow_blocked = TRUE; @@ -2171,8 +2160,8 @@ static CURLcode cf_ngtcp2_shutdown(struct Curl_cfilter *cf, (uint8_t *)buffer, sizeof(buffer), &ctx->last_error, pktx.ts); CURL_TRC_CF(data, cf, "start shutdown(err_type=%d, err_code=%" - FMT_PRIu64 ") -> %d", ctx->last_error.type, - (curl_uint64_t)ctx->last_error.error_code, (int)nwritten); + PRIu64 ") -> %d", ctx->last_error.type, + ctx->last_error.error_code, (int)nwritten); /* there are cases listed in ngtcp2 documentation where this call * may fail. Since we are doing a connection shutdown as graceful * as we can, such an error is ignored here. */ @@ -2670,9 +2659,8 @@ static CURLcode cf_ngtcp2_connect(struct Curl_cfilter *cf, result = CURLE_COULDNT_CONNECT; if(cerr) { - CURL_TRC_CF(data, cf, "connect error, type=%d, code=%" - FMT_PRIu64, - cerr->type, (curl_uint64_t)cerr->error_code); + CURL_TRC_CF(data, cf, "connect error, type=%d, code=%" PRIu64, + cerr->type, cerr->error_code); switch(cerr->type) { case NGTCP2_CCERR_TYPE_VERSION_NEGOTIATION: CURL_TRC_CF(data, cf, "error in version negotiation"); From ef4f791337cd13da7dd39e1867e7b038ee98f3a5 Mon Sep 17 00:00:00 2001 From: Stefan Eissing Date: Tue, 25 Nov 2025 13:21:25 +0100 Subject: [PATCH 063/415] quiche: use stdint types Use int64_t and uint64_t directly without needing to cast to curl_int64_t and curl_uint64_t. Closes #19697 --- lib/vquic/curl_quiche.c | 120 +++++++++++++++++++--------------------- 1 file changed, 58 insertions(+), 62 deletions(-) diff --git a/lib/vquic/curl_quiche.c b/lib/vquic/curl_quiche.c index 4fc25acad038..51cadd2e6ead 100644 --- a/lib/vquic/curl_quiche.c +++ b/lib/vquic/curl_quiche.c @@ -171,10 +171,10 @@ static CURLcode cf_flush_egress(struct Curl_cfilter *cf, * All about the H3 internals of a stream */ struct h3_stream_ctx { - curl_uint64_t id; /* HTTP/3 protocol stream identifier */ + uint64_t id; /* HTTP/3 protocol stream identifier */ struct bufq recvbuf; /* h3 response */ struct h1_req_parser h1; /* h1 request parsing */ - curl_uint64_t error3; /* HTTP/3 stream error code */ + uint64_t error3; /* HTTP/3 stream error code */ BIT(opened); /* TRUE after stream has been opened */ BIT(closed); /* TRUE on stream close */ BIT(reset); /* TRUE on stream reset */ @@ -243,7 +243,7 @@ static bool cf_quiche_do_resume(struct Curl_cfilter *cf, if(stream->quic_flow_blocked) { stream->quic_flow_blocked = FALSE; Curl_multi_mark_dirty(sdata); - CURL_TRC_CF(sdata, cf, "[%"FMT_PRIu64"] unblock", stream->id); + CURL_TRC_CF(sdata, cf, "[%" PRIu64 "] unblock", stream->id); } return TRUE; } @@ -294,7 +294,7 @@ static void h3_data_done(struct Curl_cfilter *cf, struct Curl_easy *data) (void)cf; if(stream) { - CURL_TRC_CF(data, cf, "[%"FMT_PRIu64"] easy handle is done", stream->id); + CURL_TRC_CF(data, cf, "[%" PRIu64 "] easy handle is done", stream->id); if(ctx->qconn && !stream->closed) { quiche_conn_stream_shutdown(ctx->qconn, stream->id, QUICHE_SHUTDOWN_READ, CURL_H3_NO_ERROR); @@ -368,7 +368,7 @@ static int cb_each_header(uint8_t *name, size_t name_len, return CURLE_OK; if((name_len == 7) && !strncmp(HTTP_PSEUDO_STATUS, (char *)name, 7)) { - CURL_TRC_CF(x->data, x->cf, "[%" FMT_PRIu64 "] status: %.*s", + CURL_TRC_CF(x->data, x->cf, "[%" PRIu64 "] status: %.*s", stream->id, (int)value_len, value); result = write_resp_raw(x->cf, x->data, "HTTP/3 ", sizeof("HTTP/3 ") - 1); if(!result) @@ -377,7 +377,7 @@ static int cb_each_header(uint8_t *name, size_t name_len, result = write_resp_raw(x->cf, x->data, " \r\n", 3); } else { - CURL_TRC_CF(x->data, x->cf, "[%" FMT_PRIu64 "] header: %.*s: %.*s", + CURL_TRC_CF(x->data, x->cf, "[%" PRIu64 "] header: %.*s: %.*s", stream->id, (int)name_len, name, (int)value_len, value); result = write_resp_raw(x->cf, x->data, name, name_len); @@ -389,7 +389,7 @@ static int cb_each_header(uint8_t *name, size_t name_len, result = write_resp_raw(x->cf, x->data, "\r\n", 2); } if(result) { - CURL_TRC_CF(x->data, x->cf, "[%"FMT_PRIu64"] on header error %d", + CURL_TRC_CF(x->data, x->cf, "[%" PRIu64 "] on header error %d", stream->id, result); } return result; @@ -439,9 +439,9 @@ static CURLcode cf_recv_body(struct Curl_cfilter *cf, stream_resp_read, &cb_ctx, &nread); if(result && result != CURLE_AGAIN) { - CURL_TRC_CF(data, cf, "[%"FMT_PRIu64"] recv_body error %zu", + CURL_TRC_CF(data, cf, "[%" PRIu64 "] recv_body error %zu", stream->id, nread); - failf(data, "Error %d in HTTP/3 response body for stream[%"FMT_PRIu64"]", + failf(data, "Error %d in HTTP/3 response body for stream[%" PRIu64 "]", result, stream->id); stream->closed = TRUE; stream->reset = TRUE; @@ -492,11 +492,11 @@ static CURLcode h3_process_event(struct Curl_cfilter *cf, cb_ctx.data = data; rc = quiche_h3_event_for_each_header(ev, cb_each_header, &cb_ctx); if(rc) { - failf(data, "Error %d in HTTP/3 response header for stream[%" - FMT_PRIu64"]", rc, stream->id); + failf(data, "Error %d in HTTP/3 response header for stream[%" PRIu64 "]", + rc, stream->id); return CURLE_RECV_ERROR; } - CURL_TRC_CF(data, cf, "[%"FMT_PRIu64"] <- [HEADERS]", stream->id); + CURL_TRC_CF(data, cf, "[%" PRIu64 "] <- [HEADERS]", stream->id); break; case QUICHE_H3_EVENT_DATA: @@ -506,7 +506,7 @@ static CURLcode h3_process_event(struct Curl_cfilter *cf, break; case QUICHE_H3_EVENT_RESET: - CURL_TRC_CF(data, cf, "[%"FMT_PRIu64"] RESET", stream->id); + CURL_TRC_CF(data, cf, "[%" PRIu64 "] RESET", stream->id); stream->closed = TRUE; stream->reset = TRUE; stream->send_closed = TRUE; @@ -514,7 +514,7 @@ static CURLcode h3_process_event(struct Curl_cfilter *cf, break; case QUICHE_H3_EVENT_FINISHED: - CURL_TRC_CF(data, cf, "[%"FMT_PRIu64"] CLOSED", stream->id); + CURL_TRC_CF(data, cf, "[%" PRIu64 "] CLOSED", stream->id); if(!stream->resp_hds_complete) { result = write_resp_raw(cf, data, "\r\n", 2); if(result) @@ -526,11 +526,11 @@ static CURLcode h3_process_event(struct Curl_cfilter *cf, break; case QUICHE_H3_EVENT_GOAWAY: - CURL_TRC_CF(data, cf, "[%"FMT_PRIu64"] <- [GOAWAY]", stream->id); + CURL_TRC_CF(data, cf, "[%" PRIu64 "] <- [GOAWAY]", stream->id); break; default: - CURL_TRC_CF(data, cf, "[%"FMT_PRIu64"] recv, unhandled event %d", + CURL_TRC_CF(data, cf, "[%" PRIu64 "] recv, unhandled event %d", stream->id, quiche_h3_event_type(ev)); break; } @@ -545,14 +545,13 @@ static CURLcode cf_quiche_ev_process(struct Curl_cfilter *cf, CURLcode result = h3_process_event(cf, data, stream, ev); Curl_multi_mark_dirty(data); if(result) - CURL_TRC_CF(data, cf, "error processing event %s " - "for [%"FMT_PRIu64"] -> %d", cf_ev_name(ev), - stream->id, result); + CURL_TRC_CF(data, cf, "error processing event %s for [%" PRIu64 "] -> %d", + cf_ev_name(ev), stream->id, result); return result; } struct cf_quich_disp_ctx { - curl_uint64_t stream_id; + uint64_t stream_id; struct Curl_cfilter *cf; struct Curl_multi *multi; quiche_h3_event *ev; @@ -582,17 +581,17 @@ static CURLcode cf_poll_events(struct Curl_cfilter *cf, /* Take in the events and distribute them to the transfers. */ while(ctx->h3c) { - curl_int64_t stream3_id = quiche_h3_conn_poll(ctx->h3c, ctx->qconn, &ev); - if(stream3_id == QUICHE_H3_ERR_DONE) { + int64_t rv = quiche_h3_conn_poll(ctx->h3c, ctx->qconn, &ev); + if(rv == QUICHE_H3_ERR_DONE) { break; } - else if(stream3_id < 0) { - CURL_TRC_CF(data, cf, "error poll: %"FMT_PRId64, stream3_id); + else if(rv < 0) { + CURL_TRC_CF(data, cf, "error poll: %" PRId64, rv); return CURLE_HTTP3; } else { struct cf_quich_disp_ctx dctx; - dctx.stream_id = (curl_uint64_t)stream3_id; + dctx.stream_id = (uint64_t)rv; dctx.cf = cf; dctx.multi = data->multi; dctx.ev = ev; @@ -750,8 +749,8 @@ static CURLcode cf_flush_egress(struct Curl_cfilter *cf, struct cf_quiche_ctx *ctx = cf->ctx; size_t nread; CURLcode result; - curl_int64_t expiry_ns; - curl_int64_t timeout_ns; + int64_t expiry_ns; + int64_t timeout_ns; struct read_ctx readx; size_t pkt_count, gsolen; @@ -837,15 +836,13 @@ static CURLcode recv_closed_stream(struct Curl_cfilter *cf, DEBUGASSERT(stream); *pnread = 0; if(stream->reset) { - failf(data, - "HTTP/3 stream %" FMT_PRIu64 " reset by server", stream->id); + failf(data, "HTTP/3 stream %" PRIu64 " reset by server", stream->id); result = data->req.bytecount ? CURLE_PARTIAL_FILE : CURLE_HTTP3; - CURL_TRC_CF(data, cf, "[%" FMT_PRIu64 "] cf_recv, was reset -> %d", + CURL_TRC_CF(data, cf, "[%" PRIu64 "] cf_recv, was reset -> %d", stream->id, result); } else if(!stream->resp_got_header) { - failf(data, - "HTTP/3 stream %" FMT_PRIu64 " was closed cleanly, but before " + failf(data, "HTTP/3 stream %" PRIu64 " was closed cleanly, but before " "getting all response header fields, treated as error", stream->id); result = CURLE_HTTP3; @@ -868,7 +865,7 @@ static CURLcode cf_quiche_recv(struct Curl_cfilter *cf, struct Curl_easy *data, if(!Curl_bufq_is_empty(&stream->recvbuf)) { result = Curl_bufq_cread(&stream->recvbuf, buf, len, pnread); - CURL_TRC_CF(data, cf, "[%" FMT_PRIu64 "] read recvbuf(len=%zu) " + CURL_TRC_CF(data, cf, "[%" PRIu64 "] read recvbuf(len=%zu) " "-> %d, %zu", stream->id, len, result, *pnread); if(result) goto out; @@ -883,7 +880,7 @@ static CURLcode cf_quiche_recv(struct Curl_cfilter *cf, struct Curl_easy *data, /* recvbuf had nothing before, maybe after progressing ingress? */ if(!*pnread && !Curl_bufq_is_empty(&stream->recvbuf)) { result = Curl_bufq_cread(&stream->recvbuf, buf, len, pnread); - CURL_TRC_CF(data, cf, "[%" FMT_PRIu64 "] read recvbuf(len=%zu) " + CURL_TRC_CF(data, cf, "[%" PRIu64 "] read recvbuf(len=%zu) " "-> %d, %zu", stream->id, len, result, *pnread); if(result) goto out; @@ -908,7 +905,7 @@ static CURLcode cf_quiche_recv(struct Curl_cfilter *cf, struct Curl_easy *data, result = Curl_1st_err(result, cf_flush_egress(cf, data)); if(*pnread > 0) ctx->data_recvd += *pnread; - CURL_TRC_CF(data, cf, "[%"FMT_PRIu64"] cf_recv(total=%" + CURL_TRC_CF(data, cf, "[%" PRIu64 "] cf_recv(total=%" FMT_OFF_T ") -> %d, %zu", stream->id, ctx->data_recvd, result, *pnread); return result; @@ -930,32 +927,31 @@ static CURLcode cf_quiche_send_body(struct Curl_cfilter *cf, /* Blocked on flow control and should HOLD sending. But when do we open * again? */ if(!quiche_conn_stream_writable(ctx->qconn, stream->id, len)) { - CURL_TRC_CF(data, cf, "[%" FMT_PRIu64 "] send_body(len=%zu) " + CURL_TRC_CF(data, cf, "[%" PRIu64 "] send_body(len=%zu) " "-> window exhausted", stream->id, len); stream->quic_flow_blocked = TRUE; } return CURLE_AGAIN; } else if(rv == QUICHE_H3_TRANSPORT_ERR_INVALID_STREAM_STATE) { - CURL_TRC_CF(data, cf, "[%" FMT_PRIu64 "] send_body(len=%zu) " + CURL_TRC_CF(data, cf, "[%" PRIu64 "] send_body(len=%zu) " "-> invalid stream state", stream->id, len); return CURLE_HTTP3; } else if(rv == QUICHE_H3_TRANSPORT_ERR_FINAL_SIZE) { - CURL_TRC_CF(data, cf, "[%" FMT_PRIu64 "] send_body(len=%zu) " - "-> exceeds size", stream->id, len); + CURL_TRC_CF(data, cf, "[%" PRIu64 "] send_body(len=%zu) -> exceeds size", + stream->id, len); return CURLE_SEND_ERROR; } else if(!curlx_sztouz(rv, pnwritten)) { - CURL_TRC_CF(data, cf, "[%" FMT_PRIu64 "] send_body(len=%zu) " - "-> quiche err %zd", stream->id, len, rv); + CURL_TRC_CF(data, cf, "[%" PRIu64 "] send_body(len=%zu) -> quiche err %zd", + stream->id, len, rv); return CURLE_SEND_ERROR; } else { if(eos && (len == *pnwritten)) stream->send_closed = TRUE; - CURL_TRC_CF(data, cf, "[%" FMT_PRIu64 "] send body(len=%zu, " - "eos=%d) -> %zu", + CURL_TRC_CF(data, cf, "[%" PRIu64 "] send body(len=%zu, eos=%d) -> %zu", stream->id, len, stream->send_closed, *pnwritten); return CURLE_OK; } @@ -969,7 +965,7 @@ static CURLcode h3_open_stream(struct Curl_cfilter *cf, struct cf_quiche_ctx *ctx = cf->ctx; struct h3_stream_ctx *stream = H3_STREAM_CTX(ctx, data); size_t nheader, i; - curl_int64_t stream3_id; + int64_t rv; struct dynhds h2_headers; quiche_h3_header *nva = NULL; CURLcode result = CURLE_OK; @@ -1027,37 +1023,37 @@ static CURLcode h3_open_stream(struct Curl_cfilter *cf, if(eos && !blen) stream->send_closed = TRUE; - stream3_id = quiche_h3_send_request(ctx->h3c, ctx->qconn, nva, nheader, - stream->send_closed); - CURL_TRC_CF(data, cf, "quiche_send_request() -> %" FMT_PRIu64, stream3_id); - if(stream3_id < 0) { - if(QUICHE_H3_ERR_STREAM_BLOCKED == stream3_id) { + rv = quiche_h3_send_request(ctx->h3c, ctx->qconn, nva, nheader, + stream->send_closed); + CURL_TRC_CF(data, cf, "quiche_send_request() -> %" PRId64, rv); + if(rv < 0) { + if(QUICHE_H3_ERR_STREAM_BLOCKED == rv) { /* quiche seems to report this error if the connection window is * exhausted. Which happens frequently and intermittent. */ - CURL_TRC_CF(data, cf, "[%"FMT_PRIu64"] blocked", stream->id); + CURL_TRC_CF(data, cf, "[%" PRIu64 "] blocked", stream->id); stream->quic_flow_blocked = TRUE; result = CURLE_AGAIN; goto out; } else { - CURL_TRC_CF(data, cf, "send_request(%s) -> %" FMT_PRIu64, - data->state.url, stream3_id); + CURL_TRC_CF(data, cf, "send_request(%s) -> %" PRId64, + data->state.url, rv); } result = CURLE_SEND_ERROR; goto out; } DEBUGASSERT(!stream->opened); - stream->id = stream3_id; + stream->id = (uint64_t)rv; stream->opened = TRUE; stream->closed = FALSE; stream->reset = FALSE; if(Curl_trc_is_verbose(data)) { - infof(data, "[HTTP/3] [%" FMT_PRIu64 "] OPENED stream for %s", + infof(data, "[HTTP/3] [%" PRIu64 "] OPENED stream for %s", stream->id, data->state.url); for(i = 0; i < nheader; ++i) { - infof(data, "[HTTP/3] [%" FMT_PRIu64 "] [%.*s: %.*s]", stream->id, + infof(data, "[HTTP/3] [%" PRIu64 "] [%.*s: %.*s]", stream->id, (int)nva[i].name_len, nva[i].name, (int)nva[i].value_len, nva[i].value); } @@ -1113,13 +1109,13 @@ static CURLcode cf_quiche_send(struct Curl_cfilter *cf, struct Curl_easy *data, * sending the 30x response. * This is sort of a race: had the transfer loop called recv first, * it would see the response and stop/discard sending on its own- */ - CURL_TRC_CF(data, cf, "[%" FMT_PRIu64 "] discarding data" + CURL_TRC_CF(data, cf, "[%" PRIu64 "] discarding data" "on closed stream with response", stream->id); result = CURLE_OK; *pnwritten = len; goto out; } - CURL_TRC_CF(data, cf, "[%" FMT_PRIu64 "] send_body(len=%zu) " + CURL_TRC_CF(data, cf, "[%" PRIu64 "] send_body(len=%zu) " "-> stream closed", stream->id, len); result = CURLE_HTTP3; goto out; @@ -1131,8 +1127,8 @@ static CURLcode cf_quiche_send(struct Curl_cfilter *cf, struct Curl_easy *data, out: result = Curl_1st_err(result, cf_flush_egress(cf, data)); - CURL_TRC_CF(data, cf, "[%" FMT_PRIu64 "] cf_send(len=%zu) -> %d, %zu", - stream ? stream->id : (curl_uint64_t)~0, len, + CURL_TRC_CF(data, cf, "[%" PRIu64 "] cf_send(len=%zu) -> %d, %zu", + stream ? stream->id : (uint64_t)~0, len, result, *pnwritten); return result; } @@ -1144,7 +1140,7 @@ static bool stream_is_writeable(struct Curl_cfilter *cf, struct h3_stream_ctx *stream = H3_STREAM_CTX(ctx, data); return stream && (quiche_conn_stream_writable( - ctx->qconn, (curl_uint64_t)stream->id, 1) > 0); + ctx->qconn, stream->id, 1) > 0); } static CURLcode cf_quiche_adjust_pollset(struct Curl_cfilter *cf, @@ -1229,7 +1225,7 @@ static CURLcode cf_quiche_cntrl(struct Curl_cfilter *cf, stream->send_closed = TRUE; body[0] = 'X'; result = cf_quiche_send(cf, data, body, 0, TRUE, &sent); - CURL_TRC_CF(data, cf, "[%"FMT_PRIu64"] DONE_SEND -> %d, %zu", + CURL_TRC_CF(data, cf, "[%" PRIu64 "] DONE_SEND -> %d, %zu", stream->id, result, sent); } break; @@ -1520,7 +1516,7 @@ static CURLcode cf_quiche_query(struct Curl_cfilter *cf, switch(query) { case CF_QUERY_MAX_CONCURRENT: { - curl_uint64_t max_streams = CONN_ATTACHED(cf->conn); + uint64_t max_streams = CONN_ATTACHED(cf->conn); if(!ctx->goaway && ctx->qconn) { max_streams += quiche_conn_peer_streams_left_bidi(ctx->qconn); } From bb63518ba71c3d7bb58e6eb605bb0a5962d7835e Mon Sep 17 00:00:00 2001 From: Stefan Eissing Date: Tue, 25 Nov 2025 13:39:35 +0100 Subject: [PATCH 064/415] openssl-quic: use stdint types Use int64_t and uint64_t directly without needing to cast to curl_int64_t and curl_uint64_t. Closes #19698 --- lib/vquic/curl_osslq.c | 106 ++++++++++++++++++++--------------------- 1 file changed, 51 insertions(+), 55 deletions(-) diff --git a/lib/vquic/curl_osslq.c b/lib/vquic/curl_osslq.c index b890a8d9516d..9d0193d55440 100644 --- a/lib/vquic/curl_osslq.c +++ b/lib/vquic/curl_osslq.c @@ -207,7 +207,7 @@ static CURLcode make_bio_addr(BIO_ADDR **pbio_addr, /* QUIC stream (not necessarily H3) */ struct cf_osslq_stream { - curl_int64_t id; + int64_t id; SSL *ssl; struct bufq recvbuf; /* QUIC war data recv buffer */ BIT(recvd_eos); @@ -228,7 +228,7 @@ static CURLcode cf_osslq_stream_open(struct cf_osslq_stream *s, if(!s->ssl) { return CURLE_FAILED_INIT; } - s->id = (curl_int64_t)SSL_get_stream_id(s->ssl); + s->id = SSL_get_stream_id(s->ssl); SSL_set_app_data(s->ssl, user_data); return CURLE_OK; } @@ -450,7 +450,7 @@ static CURLcode cf_osslq_h3conn_add_stream(struct cf_osslq_h3conn *h3, struct Curl_easy *data) { struct cf_osslq_ctx *ctx = cf->ctx; - curl_int64_t stream_id = (curl_int64_t)SSL_get_stream_id(stream_ssl); + int64_t stream_id = (int64_t)SSL_get_stream_id(stream_ssl); int stype = SSL_get_stream_type(stream_ssl); /* This could be a GREASE stream, e.g. HTTP/3 rfc9114 ch 6.2.3 * reserved stream type that is supposed to be discarded silently. @@ -461,7 +461,7 @@ static CURLcode cf_osslq_h3conn_add_stream(struct cf_osslq_h3conn *h3, struct cf_osslq_stream *nstream; if(h3->remote_ctrl_n >= CURL_ARRAYSIZE(h3->remote_ctrl)) { /* rejected, we are full */ - CURL_TRC_CF(data, cf, "[%" FMT_PRId64 "] reject remote uni stream", + CURL_TRC_CF(data, cf, "[%" PRId64 "] reject remote uni stream", stream_id); SSL_free(stream_ssl); return CURLE_OK; @@ -470,12 +470,12 @@ static CURLcode cf_osslq_h3conn_add_stream(struct cf_osslq_h3conn *h3, nstream->id = stream_id; nstream->ssl = stream_ssl; Curl_bufq_initp(&nstream->recvbuf, &ctx->stream_bufcp, 1, BUFQ_OPT_NONE); - CURL_TRC_CF(data, cf, "[%" FMT_PRId64 "] accepted remote uni stream", + CURL_TRC_CF(data, cf, "[%" PRId64 "] accepted remote uni stream", stream_id); return CURLE_OK; } default: - CURL_TRC_CF(data, cf, "[%" FMT_PRId64 "] reject remote %s" + CURL_TRC_CF(data, cf, "[%" PRId64 "] reject remote %s" " stream, type=%x", stream_id, (stype == SSL_STREAM_TYPE_BIDI) ? "bidi" : "write", stype); SSL_free(stream_ssl); @@ -579,7 +579,7 @@ struct h3_stream_ctx { struct h1_req_parser h1; /* h1 request parsing */ size_t sendbuf_len_in_flight; /* sendbuf amount "in flight" */ size_t recv_buf_nonflow; /* buffered bytes, not counting for flow control */ - curl_uint64_t error3; /* HTTP/3 stream error code */ + uint64_t error3; /* HTTP/3 stream error code */ curl_off_t upload_left; /* number of request bytes left to upload */ curl_off_t download_recvd; /* number of response DATA bytes received */ int status_code; /* HTTP status code */ @@ -649,7 +649,7 @@ static void h3_data_done(struct Curl_cfilter *cf, struct Curl_easy *data) (void)cf; if(stream) { - CURL_TRC_CF(data, cf, "[%"FMT_PRId64"] easy handle is done", + CURL_TRC_CF(data, cf, "[%" PRIu64 "] easy handle is done", stream->s.id); if(ctx->h3.conn && (stream->s.id >= 0) && !stream->closed) { nghttp3_conn_shutdown_stream_read(ctx->h3.conn, stream->s.id); @@ -664,7 +664,7 @@ static void h3_data_done(struct Curl_cfilter *cf, struct Curl_easy *data) } struct cf_ossq_find_ctx { - curl_int64_t stream_id; + int64_t stream_id; struct h3_stream_ctx *stream; }; @@ -743,11 +743,11 @@ static int cb_h3_stream_close(nghttp3_conn *conn, int64_t stream_id, if(stream->error3 != NGHTTP3_H3_NO_ERROR) { stream->reset = TRUE; stream->send_closed = TRUE; - CURL_TRC_CF(data, cf, "[%" FMT_PRId64 "] RESET: error %" FMT_PRIu64, + CURL_TRC_CF(data, cf, "[%" PRId64 "] RESET: error %" PRIu64, stream->s.id, stream->error3); } else { - CURL_TRC_CF(data, cf, "[%" FMT_PRId64 "] CLOSED", stream->s.id); + CURL_TRC_CF(data, cf, "[%" PRId64 "] CLOSED", stream->s.id); } Curl_multi_mark_dirty(data); return 0; @@ -806,12 +806,12 @@ static int cb_h3_recv_data(nghttp3_conn *conn, int64_t stream3_id, result = write_resp_raw(cf, data, buf, buflen, TRUE); if(result) { - CURL_TRC_CF(data, cf, "[%" FMT_PRId64 "] DATA len=%zu, ERROR %d", + CURL_TRC_CF(data, cf, "[%" PRId64 "] DATA len=%zu, ERROR %d", stream->s.id, buflen, result); return NGHTTP3_ERR_CALLBACK_FAILURE; } stream->download_recvd += (curl_off_t)buflen; - CURL_TRC_CF(data, cf, "[%" FMT_PRId64 "] DATA len=%zu, total=%" FMT_OFF_T, + CURL_TRC_CF(data, cf, "[%" PRId64 "] DATA len=%zu, total=%" FMT_OFF_T, stream->s.id, buflen, stream->download_recvd); Curl_multi_mark_dirty(data); return 0; @@ -829,18 +829,17 @@ static int cb_h3_deferred_consume(nghttp3_conn *conn, int64_t stream_id, (void)conn; (void)stream_id; if(stream) - CURL_TRC_CF(data, cf, "[%" FMT_PRId64 "] deferred consume %zu bytes", + CURL_TRC_CF(data, cf, "[%" PRId64 "] deferred consume %zu bytes", stream->s.id, consumed); return 0; } -static int cb_h3_recv_header(nghttp3_conn *conn, int64_t sid, +static int cb_h3_recv_header(nghttp3_conn *conn, int64_t stream_id, int32_t token, nghttp3_rcbuf *name, nghttp3_rcbuf *value, uint8_t flags, void *user_data, void *stream_user_data) { struct Curl_cfilter *cf = user_data; - curl_int64_t stream_id = sid; struct cf_osslq_ctx *ctx = cf->ctx; nghttp3_vec h3name = nghttp3_rcbuf_get_buf(name); nghttp3_vec h3val = nghttp3_rcbuf_get_buf(value); @@ -867,7 +866,7 @@ static int cb_h3_recv_header(nghttp3_conn *conn, int64_t sid, return -1; ncopy = curl_msnprintf(line, sizeof(line), "HTTP/3 %03d \r\n", stream->status_code); - CURL_TRC_CF(data, cf, "[%" FMT_PRId64 "] status: %s", stream_id, line); + CURL_TRC_CF(data, cf, "[%" PRId64 "] status: %s", stream_id, line); result = write_resp_raw(cf, data, line, ncopy, FALSE); if(result) { return -1; @@ -875,7 +874,7 @@ static int cb_h3_recv_header(nghttp3_conn *conn, int64_t sid, } else { /* store as an HTTP1-style header */ - CURL_TRC_CF(data, cf, "[%" FMT_PRId64 "] header: %.*s: %.*s", + CURL_TRC_CF(data, cf, "[%" PRId64 "] header: %.*s: %.*s", stream_id, (int)h3name.len, h3name.base, (int)h3val.len, h3val.base); result = write_resp_raw(cf, data, h3name.base, h3name.len, FALSE); @@ -898,13 +897,12 @@ static int cb_h3_recv_header(nghttp3_conn *conn, int64_t sid, return 0; } -static int cb_h3_end_headers(nghttp3_conn *conn, int64_t sid, +static int cb_h3_end_headers(nghttp3_conn *conn, int64_t stream_id, int fin, void *user_data, void *stream_user_data) { struct Curl_cfilter *cf = user_data; struct cf_osslq_ctx *ctx = cf->ctx; struct Curl_easy *data = stream_user_data; - curl_int64_t stream_id = sid; struct h3_stream_ctx *stream = H3_STREAM_CTX(ctx, data); CURLcode result = CURLE_OK; (void)conn; @@ -920,7 +918,7 @@ static int cb_h3_end_headers(nghttp3_conn *conn, int64_t sid, return -1; } - CURL_TRC_CF(data, cf, "[%" FMT_PRId64 "] end_headers, status=%d", + CURL_TRC_CF(data, cf, "[%" PRId64 "] end_headers, status=%d", stream_id, stream->status_code); if(stream->status_code / 100 != 1) { stream->resp_hds_complete = TRUE; @@ -929,14 +927,13 @@ static int cb_h3_end_headers(nghttp3_conn *conn, int64_t sid, return 0; } -static int cb_h3_stop_sending(nghttp3_conn *conn, int64_t sid, +static int cb_h3_stop_sending(nghttp3_conn *conn, int64_t stream_id, uint64_t app_error_code, void *user_data, void *stream_user_data) { struct Curl_cfilter *cf = user_data; struct cf_osslq_ctx *ctx = cf->ctx; struct Curl_easy *data = stream_user_data; - curl_int64_t stream_id = sid; struct h3_stream_ctx *stream = H3_STREAM_CTX(ctx, data); (void)conn; (void)app_error_code; @@ -944,19 +941,18 @@ static int cb_h3_stop_sending(nghttp3_conn *conn, int64_t sid, if(!stream || !stream->s.ssl) return 0; - CURL_TRC_CF(data, cf, "[%" FMT_PRId64 "] stop_sending", stream_id); + CURL_TRC_CF(data, cf, "[%" PRId64 "] stop_sending", stream_id); cf_osslq_stream_close(&stream->s); return 0; } -static int cb_h3_reset_stream(nghttp3_conn *conn, int64_t sid, +static int cb_h3_reset_stream(nghttp3_conn *conn, int64_t stream_id, uint64_t app_error_code, void *user_data, void *stream_user_data) { struct Curl_cfilter *cf = user_data; struct cf_osslq_ctx *ctx = cf->ctx; struct Curl_easy *data = stream_user_data; - curl_int64_t stream_id = sid; struct h3_stream_ctx *stream = H3_STREAM_CTX(ctx, data); int rv; (void)conn; @@ -965,7 +961,7 @@ static int cb_h3_reset_stream(nghttp3_conn *conn, int64_t sid, SSL_STREAM_RESET_ARGS args = {0}; args.quic_error_code = app_error_code; rv = !SSL_stream_reset(stream->s.ssl, &args, sizeof(args)); - CURL_TRC_CF(data, cf, "[%" FMT_PRId64 "] reset -> %d", stream_id, rv); + CURL_TRC_CF(data, cf, "[%" PRId64 "] reset -> %d", stream_id, rv); if(!rv) { return NGHTTP3_ERR_CALLBACK_FAILURE; } @@ -1025,12 +1021,12 @@ cb_h3_read_req_body(nghttp3_conn *conn, int64_t stream_id, } else if(!nwritten) { /* Not EOF, and nothing to give, we signal WOULDBLOCK. */ - CURL_TRC_CF(data, cf, "[%" FMT_PRId64 "] read req body -> AGAIN", + CURL_TRC_CF(data, cf, "[%" PRId64 "] read req body -> AGAIN", stream->s.id); return NGHTTP3_ERR_WOULDBLOCK; } - CURL_TRC_CF(data, cf, "[%" FMT_PRId64 "] read req body -> " + CURL_TRC_CF(data, cf, "[%" PRId64 "] read req body -> " "%d vecs%s with %zu (buffered=%zu, left=%" FMT_OFF_T ")", stream->s.id, (int)nvecs, *pflags == NGHTTP3_DATA_FLAG_EOF ? " EOF" : "", @@ -1262,7 +1258,7 @@ static CURLcode h3_quic_recv(void *reader_ctx, return CURLE_AGAIN; } else if(detail == SSL_ERROR_ZERO_RETURN) { - CURL_TRC_CF(x->data, x->cf, "[%" FMT_PRId64 "] h3_quic_recv -> EOS", + CURL_TRC_CF(x->data, x->cf, "[%" PRId64 "] h3_quic_recv -> EOS", x->s->id); x->s->recvd_eos = TRUE; return CURLE_OK; @@ -1275,7 +1271,7 @@ static CURLcode h3_quic_recv(void *reader_ctx, return CURLE_RECV_ERROR; } else { - CURL_TRC_CF(x->data, x->cf, "[%" FMT_PRId64 "] h3_quic_recv -> RESET, " + CURL_TRC_CF(x->data, x->cf, "[%" PRId64 "] h3_quic_recv -> RESET, " "rv=%d, app_err=%" FMT_PRIu64, x->s->id, rv, (curl_uint64_t)app_error_code); if(app_error_code != NGHTTP3_H3_NO_ERROR) @@ -1332,7 +1328,7 @@ static CURLcode cf_osslq_stream_recv(struct cf_osslq_stream *s, while(Curl_bufq_peek(&s->recvbuf, &buf, &blen)) { nread = nghttp3_conn_read_stream(ctx->h3.conn, s->id, buf, blen, 0); - CURL_TRC_CF(data, cf, "[%" FMT_PRId64 "] forward %zu bytes " + CURL_TRC_CF(data, cf, "[%" PRId64 "] forward %zu bytes " "to nghttp3 -> %zd", s->id, blen, nread); if(nread < 0) { failf(data, "nghttp3_conn_read_stream(len=%zu) error: %s", @@ -1372,7 +1368,7 @@ static CURLcode cf_osslq_stream_recv(struct cf_osslq_stream *s, rv = nghttp3_conn_close_stream(ctx->h3.conn, s->id, NGHTTP3_H3_NO_ERROR); s->closed = TRUE; - CURL_TRC_CF(data, cf, "[%" FMT_PRId64 "] close nghttp3 stream -> %d", + CURL_TRC_CF(data, cf, "[%" PRId64 "] close nghttp3 stream -> %d", s->id, rv); if(rv < 0 && rv != NGHTTP3_ERR_STREAM_NOT_FOUND) { failf(data, "nghttp3_conn_close_stream returned error: %s", @@ -1385,7 +1381,7 @@ static CURLcode cf_osslq_stream_recv(struct cf_osslq_stream *s, } out: if(result) - CURL_TRC_CF(data, cf, "[%" FMT_PRId64 "] cf_osslq_stream_recv -> %d", + CURL_TRC_CF(data, cf, "[%" PRId64 "] cf_osslq_stream_recv -> %d", s->id, result); return result; } @@ -1609,7 +1605,7 @@ static CURLcode h3_send_streams(struct Curl_cfilter *cf, s = cf_osslq_get_qstream(cf, data, stream_id); if(!s) { failf(data, "nghttp3_conn_writev_stream gave unknown stream %" - FMT_PRId64, (curl_int64_t)stream_id); + PRId64, stream_id); result = CURLE_SEND_ERROR; goto out; } @@ -1630,7 +1626,7 @@ static CURLcode h3_send_streams(struct Curl_cfilter *cf, if(ok) { /* As OpenSSL buffers the data, we count this as acknowledged * from nghttp3's point of view */ - CURL_TRC_CF(data, cf, "[%" FMT_PRId64 "] send %zu bytes to QUIC ok", + CURL_TRC_CF(data, cf, "[%" PRId64 "] send %zu bytes to QUIC ok", s->id, vec[i].len); acked_len += vec[i].len; } @@ -1640,14 +1636,14 @@ static CURLcode h3_send_streams(struct Curl_cfilter *cf, case SSL_ERROR_WANT_WRITE: case SSL_ERROR_WANT_READ: /* QUIC blocked us from writing more */ - CURL_TRC_CF(data, cf, "[%"FMT_PRId64 "] send %zu bytes to " + CURL_TRC_CF(data, cf, "[%" PRId64 "] send %zu bytes to " "QUIC blocked", s->id, vec[i].len); written = 0; nghttp3_conn_block_stream(ctx->h3.conn, s->id); s->send_blocked = blocked = TRUE; break; default: - failf(data, "[%"FMT_PRId64 "] send %zu bytes to QUIC, SSL error %d", + failf(data, "[%" PRId64 "] send %zu bytes to QUIC, SSL error %d", s->id, vec[i].len, detail); result = cf_osslq_ssl_err(cf, data, detail, CURLE_HTTP3); goto out; @@ -1673,13 +1669,13 @@ static CURLcode h3_send_streams(struct Curl_cfilter *cf, result = CURLE_SEND_ERROR; goto out; } - CURL_TRC_CF(data, cf, "[%" FMT_PRId64 "] forwarded %zu/%zu h3 bytes " + CURL_TRC_CF(data, cf, "[%" PRId64 "] forwarded %zu/%zu h3 bytes " "to QUIC, eos=%d", s->id, acked_len, total_len, eos); } if(eos && !s->send_blocked && !eos_written) { /* wrote everything and H3 indicates end of stream */ - CURL_TRC_CF(data, cf, "[%" FMT_PRId64 "] closing QUIC stream", s->id); + CURL_TRC_CF(data, cf, "[%" PRId64 "] closing QUIC stream", s->id); SSL_stream_conclude(s->ssl, 0); } } @@ -1980,11 +1976,11 @@ static CURLcode h3_stream_open(struct Curl_cfilter *cf, if(rc) { switch(rc) { case NGHTTP3_ERR_CONN_CLOSING: - CURL_TRC_CF(data, cf, "h3sid[%"FMT_PRId64"] failed to send, " + CURL_TRC_CF(data, cf, "h3sid[%" PRId64 "] failed to send, " "connection is closing", stream->s.id); break; default: - CURL_TRC_CF(data, cf, "h3sid[%"FMT_PRId64 "] failed to send -> %d (%s)", + CURL_TRC_CF(data, cf, "h3sid[%" PRId64 "] failed to send -> %d (%s)", stream->s.id, rc, nghttp3_strerror(rc)); break; } @@ -1993,10 +1989,10 @@ static CURLcode h3_stream_open(struct Curl_cfilter *cf, } if(Curl_trc_is_verbose(data)) { - infof(data, "[HTTP/3] [%" FMT_PRId64 "] OPENED stream for %s", + infof(data, "[HTTP/3] [%" PRId64 "] OPENED stream for %s", stream->s.id, data->state.url); for(i = 0; i < nheader; ++i) { - infof(data, "[HTTP/3] [%" FMT_PRId64 "] [%.*s: %.*s]", + infof(data, "[HTTP/3] [%" PRId64 "] [%.*s: %.*s]", stream->s.id, (int)nva[i].namelen, nva[i].name, (int)nva[i].valuelen, nva[i].value); @@ -2049,20 +2045,20 @@ static CURLcode cf_osslq_send(struct Curl_cfilter *cf, struct Curl_easy *data, * body. This happens on 30x or 40x responses. * We silently discard the data sent, since this is not a transport * error situation. */ - CURL_TRC_CF(data, cf, "[%" FMT_PRId64 "] discarding data" + CURL_TRC_CF(data, cf, "[%" PRId64 "] discarding data" "on closed stream with response", stream->s.id); result = CURLE_OK; *pnwritten = len; goto out; } - CURL_TRC_CF(data, cf, "[%" FMT_PRId64 "] send_body(len=%zu) " + CURL_TRC_CF(data, cf, "[%" PRId64 "] send_body(len=%zu) " "-> stream closed", stream->s.id, len); result = CURLE_HTTP3; goto out; } else { result = Curl_bufq_write(&stream->sendbuf, buf, len, pnwritten); - CURL_TRC_CF(data, cf, "[%" FMT_PRId64 "] cf_send, add to " + CURL_TRC_CF(data, cf, "[%" PRId64 "] cf_send, add to " "sendbuf(len=%zu) -> %d, %zu", stream->s.id, len, result, *pnwritten); if(result) @@ -2075,7 +2071,7 @@ static CURLcode cf_osslq_send(struct Curl_cfilter *cf, struct Curl_easy *data, out: result = Curl_1st_err(result, check_and_set_expiry(cf, data)); - CURL_TRC_CF(data, cf, "[%" FMT_PRId64 "] cf_send(len=%zu) -> %d, %zu", + CURL_TRC_CF(data, cf, "[%" PRId64 "] cf_send(len=%zu) -> %d, %zu", stream ? stream->s.id : -1, len, result, *pnwritten); CF_DATA_RESTORE(cf, save); return result; @@ -2090,13 +2086,13 @@ static CURLcode recv_closed_stream(struct Curl_cfilter *cf, *pnread = 0; if(stream->reset) { failf(data, - "HTTP/3 stream %" FMT_PRId64 " reset by server", + "HTTP/3 stream %" PRId64 " reset by server", stream->s.id); return data->req.bytecount ? CURLE_PARTIAL_FILE : CURLE_HTTP3; } else if(!stream->resp_hds_complete) { failf(data, - "HTTP/3 stream %" FMT_PRId64 + "HTTP/3 stream %" PRId64 " was closed cleanly, but before getting" " all response header fields, treated as error", stream->s.id); @@ -2128,8 +2124,8 @@ static CURLcode cf_osslq_recv(struct Curl_cfilter *cf, struct Curl_easy *data, if(!Curl_bufq_is_empty(&stream->recvbuf)) { result = Curl_bufq_cread(&stream->recvbuf, buf, len, pnread); if(result) { - CURL_TRC_CF(data, cf, "[%" FMT_PRId64 "] read recvbuf(len=%zu) " - "-> %d, %zu", stream->s.id, len, result, *pnread); + CURL_TRC_CF(data, cf, "[%" PRId64 "] read recvbuf(len=%zu) -> %d, %zu", + stream->s.id, len, result, *pnread); goto out; } } @@ -2142,8 +2138,8 @@ static CURLcode cf_osslq_recv(struct Curl_cfilter *cf, struct Curl_easy *data, if(!*pnread && !Curl_bufq_is_empty(&stream->recvbuf)) { result = Curl_bufq_cread(&stream->recvbuf, buf, len, pnread); if(result) { - CURL_TRC_CF(data, cf, "[%" FMT_PRId64 "] read recvbuf(len=%zu) " - "-> %d, %zu", stream->s.id, len, result, *pnread); + CURL_TRC_CF(data, cf, "[%" PRId64 "] read recvbuf(len=%zu) -> %d, %zu", + stream->s.id, len, result, *pnread); goto out; } } @@ -2163,7 +2159,7 @@ static CURLcode cf_osslq_recv(struct Curl_cfilter *cf, struct Curl_easy *data, result = Curl_1st_err(result, cf_progress_egress(cf, data)); result = Curl_1st_err(result, check_and_set_expiry(cf, data)); - CURL_TRC_CF(data, cf, "[%" FMT_PRId64 "] cf_recv(len=%zu) -> %d, %zu", + CURL_TRC_CF(data, cf, "[%" PRId64 "] cf_recv(len=%zu) -> %d, %zu", stream ? stream->s.id : -1, len, result, *pnread); CF_DATA_RESTORE(cf, save); return result; From 4701a6d2ae9f0b66a0feac4061868e944353449b Mon Sep 17 00:00:00 2001 From: Stefan Eissing Date: Tue, 25 Nov 2025 11:33:38 +0100 Subject: [PATCH 065/415] lib: change uint sets to operate on uint32_t - clarify names and change types - make multi's `mid` a uint32_t - update documentation Closes #19695 --- docs/internals/UINT_SETS.md | 40 ++--- lib/doh.c | 16 +- lib/doh.h | 2 +- lib/easy.c | 6 +- lib/http2.c | 10 +- lib/multi.c | 282 ++++++++++++++++++------------------ lib/multi_ev.c | 36 ++--- lib/multi_ev.h | 4 +- lib/multi_ntfy.c | 22 +-- lib/multi_ntfy.h | 2 +- lib/multihandle.h | 10 +- lib/multiif.h | 2 +- lib/uint-bset.c | 102 ++++++------- lib/uint-bset.h | 38 ++--- lib/uint-hash.c | 94 ++++++------ lib/uint-hash.h | 40 ++--- lib/uint-spbset.c | 128 ++++++++-------- lib/uint-spbset.h | 42 +++--- lib/uint-table.c | 82 +++++------ lib/uint-table.h | 40 ++--- lib/url.c | 10 +- lib/urldata.h | 10 +- lib/vquic/curl_ngtcp2.c | 20 +-- lib/vquic/curl_osslq.c | 24 +-- lib/vquic/curl_quiche.c | 16 +- lib/vquic/vquic_int.h | 2 +- tests/unit/unit1616.c | 18 +-- tests/unit/unit3211.c | 65 +++++---- tests/unit/unit3212.c | 82 ++++++----- tests/unit/unit3213.c | 38 ++--- 30 files changed, 645 insertions(+), 638 deletions(-) diff --git a/docs/internals/UINT_SETS.md b/docs/internals/UINT_SETS.md index de00b9b47a30..85952c9803fe 100644 --- a/docs/internals/UINT_SETS.md +++ b/docs/internals/UINT_SETS.md @@ -4,23 +4,23 @@ Copyright (C) Daniel Stenberg, , et al. SPDX-License-Identifier: curl --> -# Unsigned Int Sets +# `uint32_t` Sets -The multi handle tracks added easy handles via an unsigned int -it calls an `mid`. There are four data structures for unsigned int +The multi handle tracks added easy handles via an `uint32_t` +it calls an `mid`. There are four data structures for `uint32_t` optimized for the multi use case. -## `uint_tbl` +## `uint32_tbl` -`uint_table`, implemented in `uint-table.[ch]` manages an array -of `void *`. The unsigned int are the index into this array. It is +`uint32_table`, implemented in `uint-table.[ch]` manages an array +of `void *`. The `uint32_t` is the index into this array. It is created with a *capacity* which can be *resized*. The table assigns the index when a `void *` is *added*. It keeps track of the last assigned index and uses the next available larger index for a subsequent add. Reaching *capacity* it wraps around. The table *can not* store `NULL` values. The largest possible index -is `UINT_MAX - 1`. +is `UINT32_MAX - 1`. The table is iterated over by asking for the *first* existing index, meaning the smallest number that has an entry, if the table is not @@ -29,10 +29,10 @@ iteration step. It does not matter if the previous index is still in the table. Sample code for a table iteration would look like this: ```c -unsigned int mid; +uint32_t int mid; void *entry; -if(Curl_uint_tbl_first(tbl, &mid, &entry)) { +if(Curl_uint32_tbl_first(tbl, &mid, &entry)) { do { /* operate on entry with index mid */ } @@ -51,7 +51,7 @@ This iteration has the following properties: ### Memory For storing 1000 entries, the table would allocate one block of 8KB on a 64-bit system, -plus the 2 pointers and 3 unsigned int in its base `struct uint_tbl`. A resize +plus the 2 pointers and 3 `uint32_t` in its base `struct uint32_tbl`. A resize allocates a completely new pointer array, copy the existing entries and free the previous one. ### Performance @@ -77,17 +77,17 @@ For these reasons, the simple implementation was preferred. Should this become a concern, there are options like "free index lists" or, alternatively, an internal bitset that scans better. -## `uint_bset` +## `uint32_bset` -A bitset for unsigned integers, allowing fast add/remove operations. It is initialized +A bitset for `uint32_t` values, allowing fast add/remove operations. It is initialized with a *capacity*, meaning it can store only the numbers in the range `[0, capacity-1]`. -It can be *resized* and safely *iterated*. `uint_bset` is designed to operate in combination with `uint_tbl`. +It can be *resized* and safely *iterated*. `uint32_bset` is designed to operate in combination with `uint_tbl`. -The bitset keeps an array of `curl_uint64_t`. The first array entry keeps the numbers 0 to 63, the +The bitset keeps an array of `uint64_t`. The first array entry keeps the numbers 0 to 63, the second 64 to 127 and so on. A bitset with capacity 1024 would therefore allocate an array of 16 64-bit values (128 bytes). Operations for an unsigned int divide it by 64 for the array index and then check/set/clear the bit of the remainder. -Iterator works the same as with `uint_tbl`: ask the bitset for the *first* number present and +Iterator works the same as with `uint32_tbl`: ask the bitset for the *first* number present and then use that to get the *next* higher number present. Like the table, this safe for adds/removes and growing the set while iterating. @@ -102,14 +102,14 @@ Operations for add/remove/check are O(1). Iteration needs to scan for the next b number of scans is small (see memory footprint) and, for checking bits, many compilers offer primitives for special CPU instructions. -## `uint_spbset` +## `uint32_spbset` -While the memory footprint of `uint_bset` is good, it still needs 5KB to store the single number 40000. This +While the memory footprint of `uint32_bset` is good, it still needs 5KB to store the single number 40000. This is not optimal when many are needed. For example, in event based processing, each socket needs to keep track of the transfers involved. There are many sockets potentially, but each one mostly tracks a single transfer or few (on HTTP/2 connection borderline up to 100). -For such uses cases, the `uint_spbset` is intended: track a small number of unsigned int, potentially +For such uses cases, the `uint32_spbset` is intended: track a small number of unsigned int, potentially rather "close" together. It keeps "chunks" with an offset and has no capacity limit. Example: adding the number 40000 to an empty sparse bitset would have one chunk with offset 39936, keeping @@ -121,8 +121,8 @@ would need to be allocated and linked, resulting in overall 4 KB of memory used. Iterating a sparse bitset works the same as for bitset and table. -## `uint_hash` +## `uint32_hash` At last, there are places in libcurl such as the HTTP/2 and HTTP/3 protocol implementations that need -to store their own data related to a transfer. `uint_hash` allows then to associate an unsigned int, +to store their own data related to a transfer. `uint32_hash` allows then to associate an unsigned int, e.g. the transfer's `mid`, to their own data. diff --git a/lib/doh.c b/lib/doh.c index 83a83f534672..0712981a97ec 100644 --- a/lib/doh.c +++ b/lib/doh.c @@ -286,7 +286,7 @@ static CURLcode doh_probe_run(struct Curl_easy *data, DNStype dnstype, const char *host, const char *url, CURLM *multi, - unsigned int *pmid) + uint32_t *pmid) { struct Curl_easy *doh = NULL; CURLcode result = CURLE_OK; @@ -294,7 +294,7 @@ static CURLcode doh_probe_run(struct Curl_easy *data, struct doh_request *doh_req; DOHcode d; - *pmid = UINT_MAX; + *pmid = UINT32_MAX; doh_req = calloc(1, sizeof(*doh_req)); if(!doh_req) @@ -472,7 +472,7 @@ CURLcode Curl_doh(struct Curl_easy *data, const char *hostname, return CURLE_OUT_OF_MEMORY; for(i = 0; i < DOH_SLOT_COUNT; ++i) { - dohp->probe_resp[i].probe_mid = UINT_MAX; + dohp->probe_resp[i].probe_mid = UINT32_MAX; curlx_dyn_init(&dohp->probe_resp[i].body, DYN_DOH_RESPONSE); } @@ -1222,8 +1222,8 @@ CURLcode Curl_doh_is_resolved(struct Curl_easy *data, if(!dohp) return CURLE_OUT_OF_MEMORY; - if(dohp->probe_resp[DOH_SLOT_IPV4].probe_mid == UINT_MAX && - dohp->probe_resp[DOH_SLOT_IPV6].probe_mid == UINT_MAX) { + if(dohp->probe_resp[DOH_SLOT_IPV4].probe_mid == UINT32_MAX && + dohp->probe_resp[DOH_SLOT_IPV6].probe_mid == UINT32_MAX) { failf(data, "Could not DoH-resolve: %s", dohp->host); return CONN_IS_PROXIED(data->conn) ? CURLE_COULDNT_RESOLVE_PROXY : CURLE_COULDNT_RESOLVE_HOST; @@ -1318,13 +1318,13 @@ void Curl_doh_close(struct Curl_easy *data) struct doh_probes *doh = data->state.async.doh; if(doh && data->multi) { struct Curl_easy *probe_data; - unsigned int mid; + uint32_t mid; size_t slot; for(slot = 0; slot < DOH_SLOT_COUNT; slot++) { mid = doh->probe_resp[slot].probe_mid; - if(mid == UINT_MAX) + if(mid == UINT32_MAX) continue; - doh->probe_resp[slot].probe_mid = UINT_MAX; + doh->probe_resp[slot].probe_mid = UINT32_MAX; /* should have been called before data is removed from multi handle */ DEBUGASSERT(data->multi); probe_data = data->multi ? Curl_multi_get_easy(data->multi, mid) : diff --git a/lib/doh.h b/lib/doh.h index 726fb9f73557..ffd0cb087913 100644 --- a/lib/doh.h +++ b/lib/doh.h @@ -96,7 +96,7 @@ struct doh_request { }; struct doh_response { - unsigned int probe_mid; + uint32_t probe_mid; struct dynbuf body; DNStype dnstype; CURLcode result; diff --git a/lib/easy.c b/lib/easy.c index 8c7b9c23da68..db6c419c5771 100644 --- a/lib/easy.c +++ b/lib/easy.c @@ -988,8 +988,8 @@ CURL *curl_easy_duphandle(CURL *d) outcurl->state.lastconnect_id = -1; outcurl->state.recent_conn_id = -1; outcurl->id = -1; - outcurl->mid = UINT_MAX; - outcurl->master_mid = UINT_MAX; + outcurl->mid = UINT32_MAX; + outcurl->master_mid = UINT32_MAX; #ifndef CURL_DISABLE_HTTP Curl_llist_init(&outcurl->state.httphdrs, NULL); @@ -1126,7 +1126,7 @@ void curl_easy_reset(CURL *d) #if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_DIGEST_AUTH) Curl_http_auth_cleanup_digest(data); #endif - data->master_mid = UINT_MAX; + data->master_mid = UINT32_MAX; } /* diff --git a/lib/http2.c b/lib/http2.c index 5d1a502810fb..7b94930a21a7 100644 --- a/lib/http2.c +++ b/lib/http2.c @@ -140,7 +140,7 @@ static void cf_h2_ctx_init(struct cf_h2_ctx *ctx, bool via_h1_upgrade) Curl_bufq_initp(&ctx->inbufq, &ctx->stream_bufcp, H2_NW_RECV_CHUNKS, 0); Curl_bufq_initp(&ctx->outbufq, &ctx->stream_bufcp, H2_NW_SEND_CHUNKS, 0); curlx_dyn_init(&ctx->scratch, CURL_MAX_HTTP_HEADER); - Curl_uint_hash_init(&ctx->streams, 63, h2_stream_hash_free); + Curl_uint32_hash_init(&ctx->streams, 63, h2_stream_hash_free); ctx->remote_max_sid = 2147483647; ctx->via_h1_upgrade = via_h1_upgrade; #ifdef DEBUGBUILD @@ -165,7 +165,7 @@ static void cf_h2_ctx_free(struct cf_h2_ctx *ctx) Curl_bufq_free(&ctx->outbufq); Curl_bufcp_free(&ctx->stream_bufcp); curlx_dyn_free(&ctx->scratch); - Curl_uint_hash_destroy(&ctx->streams); + Curl_uint32_hash_destroy(&ctx->streams); memset(ctx, 0, sizeof(*ctx)); } free(ctx); @@ -269,7 +269,7 @@ struct h2_stream_ctx { #define H2_STREAM_CTX(ctx,data) \ ((struct h2_stream_ctx *)( \ - data? Curl_uint_hash_get(&(ctx)->streams, (data)->mid) : NULL)) + data? Curl_uint32_hash_get(&(ctx)->streams, (data)->mid) : NULL)) static struct h2_stream_ctx *h2_stream_ctx_create(struct cf_h2_ctx *ctx) { @@ -426,7 +426,7 @@ static CURLcode http2_data_setup(struct Curl_cfilter *cf, if(!stream) return CURLE_OUT_OF_MEMORY; - if(!Curl_uint_hash_set(&ctx->streams, data->mid, stream)) { + if(!Curl_uint32_hash_set(&ctx->streams, data->mid, stream)) { h2_stream_ctx_free(stream); return CURLE_OUT_OF_MEMORY; } @@ -466,7 +466,7 @@ static void http2_data_done(struct Curl_cfilter *cf, struct Curl_easy *data) } } - Curl_uint_hash_remove(&ctx->streams, data->mid); + Curl_uint32_hash_remove(&ctx->streams, data->mid); } static int h2_client_new(struct Curl_cfilter *cf, diff --git a/lib/multi.c b/lib/multi.c index 5789861026af..57c574a68176 100644 --- a/lib/multi.c +++ b/lib/multi.c @@ -180,11 +180,11 @@ static void mstate(struct Curl_easy *data, CURLMstate state if(oldstate < MSTATE_DONE) CURLM_NTFY(data, CURLMNOTIFY_EASY_DONE); /* changing to COMPLETED means it is in process and needs to go */ - DEBUGASSERT(Curl_uint_bset_contains(&data->multi->process, data->mid)); - Curl_uint_bset_remove(&data->multi->process, data->mid); - Curl_uint_bset_remove(&data->multi->pending, data->mid); /* to be sure */ + DEBUGASSERT(Curl_uint32_bset_contains(&data->multi->process, data->mid)); + Curl_uint32_bset_remove(&data->multi->process, data->mid); + Curl_uint32_bset_remove(&data->multi->pending, data->mid); /* to be sure */ - if(Curl_uint_bset_empty(&data->multi->process)) { + if(Curl_uint32_bset_empty(&data->multi->process)) { /* free the transfer buffer when we have no more active transfers */ multi_xfer_bufs_free(data->multi); } @@ -229,7 +229,7 @@ static void multi_addmsg(struct Curl_multi *multi, struct Curl_message *msg) Curl_llist_append(&multi->msglist, msg, &msg->list); } -struct Curl_multi *Curl_multi_handle(unsigned int xfer_table_size, +struct Curl_multi *Curl_multi_handle(uint32_t xfer_table_size, size_t ev_hashsize, /* event hash */ size_t chashsize, /* connection hash */ size_t dnssize, /* dns hash */ @@ -245,11 +245,11 @@ struct Curl_multi *Curl_multi_handle(unsigned int xfer_table_size, Curl_dnscache_init(&multi->dnscache, dnssize); Curl_mntfy_init(multi); Curl_multi_ev_init(multi, ev_hashsize); - Curl_uint_tbl_init(&multi->xfers, NULL); - Curl_uint_bset_init(&multi->process); - Curl_uint_bset_init(&multi->dirty); - Curl_uint_bset_init(&multi->pending); - Curl_uint_bset_init(&multi->msgsent); + Curl_uint32_tbl_init(&multi->xfers, NULL); + Curl_uint32_bset_init(&multi->process); + Curl_uint32_bset_init(&multi->dirty); + Curl_uint32_bset_init(&multi->pending); + Curl_uint32_bset_init(&multi->msgsent); Curl_hash_init(&multi->proto_hash, 23, Curl_hash_str, curlx_str_key_compare, ph_freeentry); Curl_llist_init(&multi->msglist, NULL); @@ -259,11 +259,11 @@ struct Curl_multi *Curl_multi_handle(unsigned int xfer_table_size, multi->last_timeout_ms = -1; if(Curl_mntfy_resize(multi) || - Curl_uint_bset_resize(&multi->process, xfer_table_size) || - Curl_uint_bset_resize(&multi->pending, xfer_table_size) || - Curl_uint_bset_resize(&multi->dirty, xfer_table_size) || - Curl_uint_bset_resize(&multi->msgsent, xfer_table_size) || - Curl_uint_tbl_resize(&multi->xfers, xfer_table_size)) + Curl_uint32_bset_resize(&multi->process, xfer_table_size) || + Curl_uint32_bset_resize(&multi->pending, xfer_table_size) || + Curl_uint32_bset_resize(&multi->dirty, xfer_table_size) || + Curl_uint32_bset_resize(&multi->msgsent, xfer_table_size) || + Curl_uint32_tbl_resize(&multi->xfers, xfer_table_size)) goto error; multi->admin = curl_easy_init(); @@ -278,8 +278,8 @@ struct Curl_multi *Curl_multi_handle(unsigned int xfer_table_size, if(getenv("CURL_DEBUG")) multi->admin->set.verbose = TRUE; #endif - Curl_uint_tbl_add(&multi->xfers, multi->admin, &multi->admin->mid); - Curl_uint_bset_add(&multi->process, multi->admin->mid); + Curl_uint32_tbl_add(&multi->xfers, multi->admin, &multi->admin->mid); + Curl_uint32_bset_add(&multi->process, multi->admin->mid); if(Curl_cshutdn_init(&multi->cshutdn, multi)) goto error; @@ -322,11 +322,11 @@ struct Curl_multi *Curl_multi_handle(unsigned int xfer_table_size, } Curl_mntfy_cleanup(multi); - Curl_uint_bset_destroy(&multi->process); - Curl_uint_bset_destroy(&multi->dirty); - Curl_uint_bset_destroy(&multi->pending); - Curl_uint_bset_destroy(&multi->msgsent); - Curl_uint_tbl_destroy(&multi->xfers); + Curl_uint32_bset_destroy(&multi->process); + Curl_uint32_bset_destroy(&multi->dirty); + Curl_uint32_bset_destroy(&multi->pending); + Curl_uint32_bset_destroy(&multi->msgsent); + Curl_uint32_tbl_destroy(&multi->xfers); free(multi); return NULL; @@ -359,12 +359,12 @@ static void multi_warn_debug(struct Curl_multi *multi, struct Curl_easy *data) static CURLMcode multi_xfers_add(struct Curl_multi *multi, struct Curl_easy *data) { - unsigned int capacity = Curl_uint_tbl_capacity(&multi->xfers); - unsigned int new_size = 0; + uint32_t capacity = Curl_uint32_tbl_capacity(&multi->xfers); + uint32_t new_size = 0; /* Prepare to make this into a CURLMOPT_MAX_TRANSFERS, because some * applications may want to prevent a run-away of their memory use. */ /* UINT_MAX is our "invalid" id, do not let the table grow up to that. */ - const unsigned int max_capacity = UINT_MAX - 1; + const uint32_t max_capacity = UINT_MAX - 1; if(capacity < max_capacity) { /* We want `multi->xfers` to have "sufficient" free rows, so that we do @@ -372,9 +372,9 @@ static CURLMcode multi_xfers_add(struct Curl_multi *multi, * Since uint_tbl and uint_bset are quite memory efficient, * regard less than 25% free as insufficient. * (for low capacities, e.g. multi_easy, 4 or less). */ - unsigned int used = Curl_uint_tbl_count(&multi->xfers); - unsigned int unused = capacity - used; - unsigned int min_unused = CURLMAX(capacity >> 2, 4); + uint32_t used = Curl_uint32_tbl_count(&multi->xfers); + uint32_t unused = capacity - used; + uint32_t min_unused = CURLMAX(capacity >> 2, 4); if(unused <= min_unused) { /* Make sure the uint arithmetic here works on the corner * cases where we are close to max_capacity or UINT_MAX */ @@ -397,19 +397,19 @@ static CURLMcode multi_xfers_add(struct Curl_multi *multi, * to work properly when larger than the table, but not * the other way around. */ CURL_TRC_M(data, "increasing xfer table size to %u", new_size); - if(Curl_uint_bset_resize(&multi->process, new_size) || - Curl_uint_bset_resize(&multi->dirty, new_size) || - Curl_uint_bset_resize(&multi->pending, new_size) || - Curl_uint_bset_resize(&multi->msgsent, new_size) || - Curl_uint_tbl_resize(&multi->xfers, new_size)) + if(Curl_uint32_bset_resize(&multi->process, new_size) || + Curl_uint32_bset_resize(&multi->dirty, new_size) || + Curl_uint32_bset_resize(&multi->pending, new_size) || + Curl_uint32_bset_resize(&multi->msgsent, new_size) || + Curl_uint32_tbl_resize(&multi->xfers, new_size)) return CURLM_OUT_OF_MEMORY; } /* Insert the easy into the table now */ - if(!Curl_uint_tbl_add(&multi->xfers, data, &data->mid)) { + if(!Curl_uint32_tbl_add(&multi->xfers, data, &data->mid)) { /* MUST only happen when table is full */ - DEBUGASSERT(Curl_uint_tbl_capacity(&multi->xfers) <= - Curl_uint_tbl_count(&multi->xfers)); + DEBUGASSERT(Curl_uint32_tbl_capacity(&multi->xfers) <= + Curl_uint32_tbl_count(&multi->xfers)); return CURLM_OUT_OF_MEMORY; } return CURLM_OK; @@ -441,14 +441,14 @@ CURLMcode curl_multi_add_handle(CURLM *m, CURL *d) handles are still alive - but if there are none alive anymore, it is fine to start over and unmark the "deadness" of this handle. This means only the admin handle MUST be present. */ - if((Curl_uint_tbl_count(&multi->xfers) != 1) || - !Curl_uint_tbl_contains(&multi->xfers, 0)) + if((Curl_uint32_tbl_count(&multi->xfers) != 1) || + !Curl_uint32_tbl_contains(&multi->xfers, 0)) return CURLM_ABORTED_BY_CALLBACK; multi->dead = FALSE; - Curl_uint_bset_clear(&multi->process); - Curl_uint_bset_clear(&multi->dirty); - Curl_uint_bset_clear(&multi->pending); - Curl_uint_bset_clear(&multi->msgsent); + Curl_uint32_bset_clear(&multi->process); + Curl_uint32_bset_clear(&multi->dirty); + Curl_uint32_bset_clear(&multi->pending); + Curl_uint32_bset_clear(&multi->msgsent); } if(data->multi_easy) { @@ -492,7 +492,7 @@ CURLMcode curl_multi_add_handle(CURLM *m, CURL *d) #endif /* add the easy handle to the process set */ - Curl_uint_bset_add(&multi->process, data->mid); + Curl_uint32_bset_add(&multi->process, data->mid); ++multi->xfers_alive; ++multi->xfers_total_ever; @@ -507,8 +507,8 @@ CURLMcode curl_multi_add_handle(CURLM *m, CURL *d) rc = Curl_update_timer(multi); if(rc) { data->multi = NULL; /* not anymore */ - Curl_uint_tbl_remove(&multi->xfers, data->mid); - data->mid = UINT_MAX; + Curl_uint32_tbl_remove(&multi->xfers, data->mid); + data->mid = UINT32_MAX; return rc; } @@ -523,7 +523,7 @@ CURLMcode curl_multi_add_handle(CURLM *m, CURL *d) CURL_TRC_M(data, "added to multi, mid=%u, running=%u, total=%u", data->mid, Curl_multi_xfers_running(multi), - Curl_uint_tbl_count(&multi->xfers)); + Curl_uint32_tbl_count(&multi->xfers)); return CURLM_OK; } @@ -572,11 +572,11 @@ static void multi_done_locked(struct connectdata *conn, Curl_detach_connection(data); CURL_TRC_M(data, "multi_done_locked, in use=%u", - Curl_uint_spbset_count(&conn->xfers_attached)); + Curl_uint32_spbset_count(&conn->xfers_attached)); if(CONN_INUSE(conn)) { /* Stop if still used. */ CURL_TRC_M(data, "Connection still in use %u, no more multi_done now!", - Curl_uint_spbset_count(&conn->xfers_attached)); + Curl_uint32_spbset_count(&conn->xfers_attached)); return; } @@ -740,7 +740,7 @@ CURLMcode curl_multi_remove_handle(CURLM *m, CURL *d) struct Curl_llist_node *e; CURLMcode rc; bool removed_timer = FALSE; - unsigned int mid; + uint32_t mid; /* First, make some basic checks that the CURLM handle is a good handle */ if(!GOOD_MULTI_HANDLE(multi)) @@ -758,11 +758,11 @@ CURLMcode curl_multi_remove_handle(CURLM *m, CURL *d) if(data->multi != multi) return CURLM_BAD_EASY_HANDLE; - if(data->mid == UINT_MAX) { + if(data->mid == UINT32_MAX) { DEBUGASSERT(0); return CURLM_INTERNAL_ERROR; } - if(Curl_uint_tbl_get(&multi->xfers, data->mid) != data) { + if(Curl_uint32_tbl_get(&multi->xfers, data->mid) != data) { DEBUGASSERT(0); return CURLM_INTERNAL_ERROR; } @@ -797,7 +797,7 @@ CURLMcode curl_multi_remove_handle(CURLM *m, CURL *d) removed_timer = Curl_expire_clear(data); /* If in `msgsent`, it was deducted from `multi->xfers_alive` already. */ - if(!Curl_uint_bset_contains(&multi->msgsent, data->mid)) + if(!Curl_uint32_bset_contains(&multi->msgsent, data->mid)) --multi->xfers_alive; Curl_wildcard_dtor(&data->wildcard); @@ -853,15 +853,15 @@ CURLMcode curl_multi_remove_handle(CURLM *m, CURL *d) /* clear the association to this multi handle */ mid = data->mid; - DEBUGASSERT(Curl_uint_tbl_contains(&multi->xfers, mid)); - Curl_uint_tbl_remove(&multi->xfers, mid); - Curl_uint_bset_remove(&multi->process, mid); - Curl_uint_bset_remove(&multi->dirty, mid); - Curl_uint_bset_remove(&multi->pending, mid); - Curl_uint_bset_remove(&multi->msgsent, mid); + DEBUGASSERT(Curl_uint32_tbl_contains(&multi->xfers, mid)); + Curl_uint32_tbl_remove(&multi->xfers, mid); + Curl_uint32_bset_remove(&multi->process, mid); + Curl_uint32_bset_remove(&multi->dirty, mid); + Curl_uint32_bset_remove(&multi->pending, mid); + Curl_uint32_bset_remove(&multi->msgsent, mid); data->multi = NULL; - data->mid = UINT_MAX; - data->master_mid = UINT_MAX; + data->mid = UINT32_MAX; + data->master_mid = UINT32_MAX; /* NOTE NOTE NOTE We do not touch the easy handle here! */ @@ -875,7 +875,7 @@ CURLMcode curl_multi_remove_handle(CURLM *m, CURL *d) CURL_TRC_M(data, "removed from multi, mid=%u, running=%u, total=%u", mid, Curl_multi_xfers_running(multi), - Curl_uint_tbl_count(&multi->xfers)); + Curl_uint32_tbl_count(&multi->xfers)); return CURLM_OK; } @@ -895,8 +895,8 @@ void Curl_detach_connection(struct Curl_easy *data) { struct connectdata *conn = data->conn; if(conn) { - Curl_uint_spbset_remove(&conn->xfers_attached, data->mid); - if(Curl_uint_spbset_empty(&conn->xfers_attached)) + Curl_uint32_spbset_remove(&conn->xfers_attached, data->mid); + if(Curl_uint32_spbset_empty(&conn->xfers_attached)) conn->attached_multi = NULL; } data->conn = NULL; @@ -914,7 +914,7 @@ void Curl_attach_connection(struct Curl_easy *data, DEBUGASSERT(!data->conn); DEBUGASSERT(conn); data->conn = conn; - Curl_uint_spbset_add(&conn->xfers_attached, data->mid); + Curl_uint32_spbset_add(&conn->xfers_attached, data->mid); /* all attached transfers must be from the same multi */ if(!conn->attached_multi) conn->attached_multi = data->multi; @@ -1219,7 +1219,7 @@ CURLMcode curl_multi_fdset(CURLM *m, return CURLM_RECURSIVE_API_CALL; Curl_pollset_init(&ps); - if(Curl_uint_bset_first(&multi->process, &mid)) { + if(Curl_uint32_bset_first(&multi->process, &mid)) { do { struct Curl_easy *data = Curl_multi_get_easy(multi, mid); @@ -1248,7 +1248,7 @@ CURLMcode curl_multi_fdset(CURLM *m, this_max_fd = (int)ps.sockets[i]; } } - while(Curl_uint_bset_next(&multi->process, mid, &mid)); + while(Curl_uint32_bset_next(&multi->process, mid, &mid)); } Curl_cshutdn_setfds(&multi->cshutdn, multi->admin, @@ -1282,19 +1282,19 @@ CURLMcode curl_multi_waitfds(CURLM *m, Curl_pollset_init(&ps); Curl_waitfds_init(&cwfds, ufds, size); - if(Curl_uint_bset_first(&multi->process, &mid)) { + if(Curl_uint32_bset_first(&multi->process, &mid)) { do { struct Curl_easy *data = Curl_multi_get_easy(multi, mid); if(!data) { DEBUGASSERT(0); - Curl_uint_bset_remove(&multi->process, mid); - Curl_uint_bset_remove(&multi->dirty, mid); + Curl_uint32_bset_remove(&multi->process, mid); + Curl_uint32_bset_remove(&multi->dirty, mid); continue; } Curl_multi_pollset(data, &ps); need += Curl_waitfds_add_ps(&cwfds, &ps); } - while(Curl_uint_bset_next(&multi->process, mid, &mid)); + while(Curl_uint32_bset_next(&multi->process, mid, &mid)); } need += Curl_cshutdn_add_waitfds(&multi->cshutdn, multi->admin, &cwfds); @@ -1345,7 +1345,7 @@ static CURLMcode multi_wait(struct Curl_multi *multi, unsigned int curl_nfds = 0; /* how many pfds are for curl transfers */ struct Curl_easy *data = NULL; CURLMcode result = CURLM_OK; - unsigned int mid; + uint32_t mid; #ifdef USE_WINSOCK WSANETWORKEVENTS wsa_events; @@ -1368,13 +1368,13 @@ static CURLMcode multi_wait(struct Curl_multi *multi, Curl_pollfds_init(&cpfds, a_few_on_stack, NUM_POLLS_ON_STACK); /* Add the curl handles to our pollfds first */ - if(Curl_uint_bset_first(&multi->process, &mid)) { + if(Curl_uint32_bset_first(&multi->process, &mid)) { do { data = Curl_multi_get_easy(multi, mid); if(!data) { DEBUGASSERT(0); - Curl_uint_bset_remove(&multi->process, mid); - Curl_uint_bset_remove(&multi->dirty, mid); + Curl_uint32_bset_remove(&multi->process, mid); + Curl_uint32_bset_remove(&multi->dirty, mid); continue; } Curl_multi_pollset(data, &ps); @@ -1383,7 +1383,7 @@ static CURLMcode multi_wait(struct Curl_multi *multi, goto out; } } - while(Curl_uint_bset_next(&multi->process, mid, &mid)); + while(Curl_uint32_bset_next(&multi->process, mid, &mid)); } if(Curl_cshutdn_add_pollfds(&multi->cshutdn, multi->admin, &cpfds)) { @@ -2330,9 +2330,9 @@ static CURLMcode state_connect(struct Curl_multi *multi, wait for an available connection. */ multistate(data, MSTATE_PENDING); /* move from process to pending set */ - Curl_uint_bset_remove(&multi->process, data->mid); - Curl_uint_bset_remove(&multi->dirty, data->mid); - Curl_uint_bset_add(&multi->pending, data->mid); + Curl_uint32_bset_remove(&multi->process, data->mid); + Curl_uint32_bset_remove(&multi->dirty, data->mid); + Curl_uint32_bset_add(&multi->pending, data->mid); *resultp = CURLE_OK; return rc; } @@ -2395,7 +2395,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi, /* transfer runs now, clear the dirty bit. This may be set * again during processing, triggering a re-run later. */ - Curl_uint_bset_remove(&multi->dirty, data->mid); + Curl_uint32_bset_remove(&multi->dirty, data->mid); if(data == multi->admin) { Curl_cshutdn_perform(&multi->cshutdn, multi->admin, CURL_SOCKET_TIMEOUT); @@ -2742,7 +2742,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi, } if(MSTATE_COMPLETED == data->mstate) { - if(data->master_mid != UINT_MAX) { + if(data->master_mid != UINT32_MAX) { /* A sub transfer, not for msgsent to application */ struct Curl_easy *mdata; @@ -2773,10 +2773,10 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi, multistate(data, MSTATE_MSGSENT); /* remove from the other sets, add to msgsent */ - Curl_uint_bset_remove(&multi->process, data->mid); - Curl_uint_bset_remove(&multi->dirty, data->mid); - Curl_uint_bset_remove(&multi->pending, data->mid); - Curl_uint_bset_add(&multi->msgsent, data->mid); + Curl_uint32_bset_remove(&multi->process, data->mid); + Curl_uint32_bset_remove(&multi->dirty, data->mid); + Curl_uint32_bset_remove(&multi->pending, data->mid); + Curl_uint32_bset_add(&multi->msgsent, data->mid); --multi->xfers_alive; return CURLM_OK; } @@ -2793,7 +2793,7 @@ CURLMcode curl_multi_perform(CURLM *m, int *running_handles) struct Curl_tree *t = NULL; struct curltime now = curlx_now(); struct Curl_multi *multi = m; - unsigned int mid; + uint32_t mid; SIGPIPE_VARIABLE(pipe_st); if(!GOOD_MULTI_HANDLE(multi)) @@ -2806,7 +2806,7 @@ CURLMcode curl_multi_perform(CURLM *m, int *running_handles) return CURLM_RECURSIVE_API_CALL; sigpipe_init(&pipe_st); - if(Curl_uint_bset_first(&multi->process, &mid)) { + if(Curl_uint32_bset_first(&multi->process, &mid)) { CURL_TRC_M(multi->admin, "multi_perform(running=%u)", Curl_multi_xfers_running(multi)); do { @@ -2814,8 +2814,8 @@ CURLMcode curl_multi_perform(CURLM *m, int *running_handles) CURLMcode result; if(!data) { DEBUGASSERT(0); - Curl_uint_bset_remove(&multi->process, mid); - Curl_uint_bset_remove(&multi->dirty, mid); + Curl_uint32_bset_remove(&multi->process, mid); + Curl_uint32_bset_remove(&multi->dirty, mid); continue; } sigpipe_apply(data, &pipe_st); @@ -2823,7 +2823,7 @@ CURLMcode curl_multi_perform(CURLM *m, int *running_handles) if(result) returncode = result; } - while(Curl_uint_bset_next(&multi->process, mid, &mid)); + while(Curl_uint32_bset_next(&multi->process, mid, &mid)); } sigpipe_restore(&pipe_st); @@ -2876,7 +2876,7 @@ CURLMcode curl_multi_cleanup(CURLM *m) struct Curl_multi *multi = m; if(GOOD_MULTI_HANDLE(multi)) { void *entry; - unsigned int mid; + uint32_t mid; if(multi->in_callback) return CURLM_RECURSIVE_API_CALL; if(multi->in_ntfy_callback) @@ -2884,7 +2884,7 @@ CURLMcode curl_multi_cleanup(CURLM *m) /* First remove all remaining easy handles, * close internal ones. admin handle is special */ - if(Curl_uint_tbl_first(&multi->xfers, &mid, &entry)) { + if(Curl_uint32_tbl_first(&multi->xfers, &mid, &entry)) { do { struct Curl_easy *data = entry; if(!GOOD_EASY_HANDLE(data)) @@ -2906,8 +2906,8 @@ CURLMcode curl_multi_cleanup(CURLM *m) (void)multi_done(data, CURLE_OK, TRUE); data->multi = NULL; /* clear the association */ - Curl_uint_tbl_remove(&multi->xfers, mid); - data->mid = UINT_MAX; + Curl_uint32_tbl_remove(&multi->xfers, mid); + data->mid = UINT32_MAX; #ifdef USE_LIBPSL if(data->psl == &multi->psl) @@ -2916,7 +2916,7 @@ CURLMcode curl_multi_cleanup(CURLM *m) if(data->state.internal) Curl_close(&data); } - while(Curl_uint_tbl_next(&multi->xfers, mid, &mid, &entry)); + while(Curl_uint32_tbl_next(&multi->xfers, mid, &mid, &entry)); } Curl_cpool_destroy(&multi->cpool); @@ -2924,7 +2924,7 @@ CURLMcode curl_multi_cleanup(CURLM *m) if(multi->admin) { CURL_TRC_M(multi->admin, "multi_cleanup, closing admin handle, done"); multi->admin->multi = NULL; - Curl_uint_tbl_remove(&multi->xfers, multi->admin->mid); + Curl_uint32_tbl_remove(&multi->xfers, multi->admin->mid); Curl_close(&multi->admin); } @@ -2952,16 +2952,16 @@ CURLMcode curl_multi_cleanup(CURLM *m) multi_xfer_bufs_free(multi); Curl_mntfy_cleanup(multi); #ifdef DEBUGBUILD - if(Curl_uint_tbl_count(&multi->xfers)) { + if(Curl_uint32_tbl_count(&multi->xfers)) { multi_xfer_tbl_dump(multi); DEBUGASSERT(0); } #endif - Curl_uint_bset_destroy(&multi->process); - Curl_uint_bset_destroy(&multi->dirty); - Curl_uint_bset_destroy(&multi->pending); - Curl_uint_bset_destroy(&multi->msgsent); - Curl_uint_tbl_destroy(&multi->xfers); + Curl_uint32_bset_destroy(&multi->process); + Curl_uint32_bset_destroy(&multi->dirty); + Curl_uint32_bset_destroy(&multi->pending); + Curl_uint32_bset_destroy(&multi->msgsent); + Curl_uint32_tbl_destroy(&multi->xfers); free(multi); return CURLM_OK; @@ -3120,17 +3120,17 @@ static CURLMcode multi_run_dirty(struct multi_run_ctx *mrc) { struct Curl_multi *multi = mrc->multi; CURLMcode result = CURLM_OK; - unsigned int mid; + uint32_t mid; - if(Curl_uint_bset_first(&multi->dirty, &mid)) { + if(Curl_uint32_bset_first(&multi->dirty, &mid)) { do { struct Curl_easy *data = Curl_multi_get_easy(multi, mid); if(data) { CURL_TRC_M(data, "multi_run_dirty"); - if(!Curl_uint_bset_contains(&multi->process, mid)) { + if(!Curl_uint32_bset_contains(&multi->process, mid)) { /* We are no longer processing this transfer */ - Curl_uint_bset_remove(&multi->dirty, mid); + Curl_uint32_bset_remove(&multi->dirty, mid); continue; } @@ -3148,10 +3148,10 @@ static CURLMcode multi_run_dirty(struct multi_run_ctx *mrc) } else { CURL_TRC_M(multi->admin, "multi_run_dirty, %u no longer found", mid); - Curl_uint_bset_remove(&multi->dirty, mid); + Curl_uint32_bset_remove(&multi->dirty, mid); } } - while(Curl_uint_bset_next(&multi->dirty, mid, &mid)); + while(Curl_uint32_bset_next(&multi->dirty, mid, &mid)); } out: @@ -3364,22 +3364,22 @@ CURLMcode curl_multi_socket_all(CURLM *m, int *running_handles) static bool multi_has_dirties(struct Curl_multi *multi) { - unsigned int mid; - if(Curl_uint_bset_first(&multi->dirty, &mid)) { + uint32_t mid; + if(Curl_uint32_bset_first(&multi->dirty, &mid)) { do { struct Curl_easy *data = Curl_multi_get_easy(multi, mid); if(data) { - if(Curl_uint_bset_contains(&multi->process, mid)) + if(Curl_uint32_bset_contains(&multi->process, mid)) return TRUE; /* We are no longer processing this transfer */ - Curl_uint_bset_remove(&multi->dirty, mid); + Curl_uint32_bset_remove(&multi->dirty, mid); } else { CURL_TRC_M(multi->admin, "dirty transfer %u no longer found", mid); - Curl_uint_bset_remove(&multi->dirty, mid); + Curl_uint32_bset_remove(&multi->dirty, mid); } } - while(Curl_uint_bset_next(&multi->dirty, mid, &mid)); + while(Curl_uint32_bset_next(&multi->dirty, mid, &mid)); } return FALSE; } @@ -3739,8 +3739,8 @@ static void move_pending_to_connect(struct Curl_multi *multi, DEBUGASSERT(data->mstate == MSTATE_PENDING); /* Remove this node from the pending set, add into process set */ - Curl_uint_bset_remove(&multi->pending, data->mid); - Curl_uint_bset_add(&multi->process, data->mid); + Curl_uint32_bset_remove(&multi->pending, data->mid); + Curl_uint32_bset_add(&multi->process, data->mid); multistate(data, MSTATE_CONNECT); Curl_multi_mark_dirty(data); /* make it run */ @@ -3762,8 +3762,8 @@ static void move_pending_to_connect(struct Curl_multi *multi, */ static void process_pending_handles(struct Curl_multi *multi) { - unsigned int mid; - if(Curl_uint_bset_first(&multi->pending, &mid)) { + uint32_t mid; + if(Curl_uint32_bset_first(&multi->pending, &mid)) { do { struct Curl_easy *data = Curl_multi_get_easy(multi, mid); if(data) { @@ -3771,10 +3771,10 @@ static void process_pending_handles(struct Curl_multi *multi) break; } /* transfer no longer known, should not happen */ - Curl_uint_bset_remove(&multi->pending, mid); + Curl_uint32_bset_remove(&multi->pending, mid); DEBUGASSERT(0); } - while(Curl_uint_bset_next(&multi->pending, mid, &mid)); + while(Curl_uint32_bset_next(&multi->pending, mid, &mid)); } } @@ -3799,19 +3799,19 @@ CURL **curl_multi_get_handles(CURLM *m) { struct Curl_multi *multi = m; void *entry; - unsigned int count = Curl_uint_tbl_count(&multi->xfers); + unsigned int count = Curl_uint32_tbl_count(&multi->xfers); CURL **a = malloc(sizeof(struct Curl_easy *) * (count + 1)); if(a) { unsigned int i = 0, mid; - if(Curl_uint_tbl_first(&multi->xfers, &mid, &entry)) { + if(Curl_uint32_tbl_first(&multi->xfers, &mid, &entry)) { do { struct Curl_easy *data = entry; DEBUGASSERT(i < count); if(!data->state.internal) a[i++] = data; } - while(Curl_uint_tbl_next(&multi->xfers, mid, &mid, &entry)); + while(Curl_uint32_tbl_next(&multi->xfers, mid, &mid, &entry)); } a[i] = NULL; /* last entry is a NULL */ } @@ -3823,7 +3823,7 @@ CURLMcode curl_multi_get_offt(CURLM *m, curl_off_t *pvalue) { struct Curl_multi *multi = m; - unsigned int n; + uint32_t n; if(!GOOD_MULTI_HANDLE(multi)) return CURLM_BAD_HANDLE; @@ -3832,22 +3832,22 @@ CURLMcode curl_multi_get_offt(CURLM *m, switch(info) { case CURLMINFO_XFERS_CURRENT: - n = Curl_uint_tbl_count(&multi->xfers); + n = Curl_uint32_tbl_count(&multi->xfers); if(n && multi->admin) --n; *pvalue = (curl_off_t)n; return CURLM_OK; case CURLMINFO_XFERS_RUNNING: - n = Curl_uint_bset_count(&multi->process); - if(n && Curl_uint_bset_contains(&multi->process, multi->admin->mid)) + n = Curl_uint32_bset_count(&multi->process); + if(n && Curl_uint32_bset_contains(&multi->process, multi->admin->mid)) --n; *pvalue = (curl_off_t)n; return CURLM_OK; case CURLMINFO_XFERS_PENDING: - *pvalue = (curl_off_t)Curl_uint_bset_count(&multi->pending); + *pvalue = (curl_off_t)Curl_uint32_bset_count(&multi->pending); return CURLM_OK; case CURLMINFO_XFERS_DONE: - *pvalue = (curl_off_t)Curl_uint_bset_count(&multi->msgsent); + *pvalue = (curl_off_t)Curl_uint32_bset_count(&multi->msgsent); return CURLM_OK; case CURLMINFO_XFERS_ADDED: *pvalue = multi->xfers_total_ever; @@ -4025,14 +4025,14 @@ static void multi_xfer_bufs_free(struct Curl_multi *multi) } struct Curl_easy *Curl_multi_get_easy(struct Curl_multi *multi, - unsigned int mid) + uint32_t mid) { - struct Curl_easy *data = Curl_uint_tbl_get(&multi->xfers, mid); + struct Curl_easy *data = Curl_uint32_tbl_get(&multi->xfers, mid); if(data && GOOD_EASY_HANDLE(data)) return data; CURL_TRC_M(multi->admin, "invalid easy handle in xfer table for mid=%u", mid); - Curl_uint_tbl_remove(&multi->xfers, mid); + Curl_uint32_tbl_remove(&multi->xfers, mid); return NULL; } @@ -4043,14 +4043,14 @@ unsigned int Curl_multi_xfers_running(struct Curl_multi *multi) void Curl_multi_mark_dirty(struct Curl_easy *data) { - if(data->multi && data->mid != UINT_MAX) - Curl_uint_bset_add(&data->multi->dirty, data->mid); + if(data->multi && data->mid != UINT32_MAX) + Curl_uint32_bset_add(&data->multi->dirty, data->mid); } void Curl_multi_clear_dirty(struct Curl_easy *data) { - if(data->multi && data->mid != UINT_MAX) - Curl_uint_bset_remove(&data->multi->dirty, data->mid); + if(data->multi && data->mid != UINT32_MAX) + Curl_uint32_bset_remove(&data->multi->dirty, data->mid); } CURLMcode curl_multi_notify_enable(CURLM *m, unsigned int notification) @@ -4072,7 +4072,7 @@ CURLMcode curl_multi_notify_disable(CURLM *m, unsigned int notification) } #ifdef DEBUGBUILD -static void multi_xfer_dump(struct Curl_multi *multi, unsigned int mid, +static void multi_xfer_dump(struct Curl_multi *multi, uint32_t mid, void *entry) { struct Curl_easy *data = entry; @@ -4092,14 +4092,14 @@ static void multi_xfer_dump(struct Curl_multi *multi, unsigned int mid, static void multi_xfer_tbl_dump(struct Curl_multi *multi) { - unsigned int mid; + uint32_t mid; void *entry; curl_mfprintf(stderr, "=== multi xfer table (count=%u, capacity=%u\n", - Curl_uint_tbl_count(&multi->xfers), - Curl_uint_tbl_capacity(&multi->xfers)); - if(Curl_uint_tbl_first(&multi->xfers, &mid, &entry)) { + Curl_uint32_tbl_count(&multi->xfers), + Curl_uint32_tbl_capacity(&multi->xfers)); + if(Curl_uint32_tbl_first(&multi->xfers, &mid, &entry)) { multi_xfer_dump(multi, mid, entry); - while(Curl_uint_tbl_next(&multi->xfers, mid, &mid, &entry)) + while(Curl_uint32_tbl_next(&multi->xfers, mid, &mid, &entry)) multi_xfer_dump(multi, mid, entry); } curl_mfprintf(stderr, "===\n"); diff --git a/lib/multi_ev.c b/lib/multi_ev.c index 086b037527a4..d5db331cf1f1 100644 --- a/lib/multi_ev.c +++ b/lib/multi_ev.c @@ -55,7 +55,7 @@ static void mev_in_callback(struct Curl_multi *multi, bool value) * what to supervise (CURL_POLL_IN/CURL_POLL_OUT/CURL_POLL_REMOVE) */ struct mev_sh_entry { - struct uint_spbset xfers; /* bitset of transfers `mid`s on this socket */ + struct uint32_spbset xfers; /* bitset of transfers `mid`s on this socket */ struct connectdata *conn; /* connection using this socket or NULL */ void *user_data; /* libcurl app data via curl_multi_assign() */ unsigned int action; /* CURL_POLL_IN/CURL_POLL_OUT we last told the @@ -84,7 +84,7 @@ static size_t mev_sh_entry_compare(void *k1, size_t k1_len, static void mev_sh_entry_dtor(void *freethis) { struct mev_sh_entry *entry = (struct mev_sh_entry *)freethis; - Curl_uint_spbset_destroy(&entry->xfers); + Curl_uint32_spbset_destroy(&entry->xfers); free(entry); } @@ -116,7 +116,7 @@ mev_sh_entry_add(struct Curl_hash *sh, curl_socket_t s) if(!check) return NULL; /* major failure */ - Curl_uint_spbset_init(&check->xfers); + Curl_uint32_spbset_init(&check->xfers); /* make/add new hash entry */ if(!Curl_hash_add(sh, (char *)&s, sizeof(curl_socket_t), check)) { @@ -135,13 +135,13 @@ static void mev_sh_entry_kill(struct Curl_multi *multi, curl_socket_t s) static size_t mev_sh_entry_user_count(struct mev_sh_entry *e) { - return Curl_uint_spbset_count(&e->xfers) + (e->conn ? 1 : 0); + return Curl_uint32_spbset_count(&e->xfers) + (e->conn ? 1 : 0); } static bool mev_sh_entry_xfer_known(struct mev_sh_entry *e, struct Curl_easy *data) { - return Curl_uint_spbset_contains(&e->xfers, data->mid); + return Curl_uint32_spbset_contains(&e->xfers, data->mid); } static bool mev_sh_entry_conn_known(struct mev_sh_entry *e, @@ -155,7 +155,7 @@ static bool mev_sh_entry_xfer_add(struct mev_sh_entry *e, { /* detect weird values */ DEBUGASSERT(mev_sh_entry_user_count(e) < 100000); - return Curl_uint_spbset_add(&e->xfers, data->mid); + return Curl_uint32_spbset_add(&e->xfers, data->mid); } static bool mev_sh_entry_conn_add(struct mev_sh_entry *e, @@ -174,9 +174,9 @@ static bool mev_sh_entry_conn_add(struct mev_sh_entry *e, static bool mev_sh_entry_xfer_remove(struct mev_sh_entry *e, struct Curl_easy *data) { - bool present = Curl_uint_spbset_contains(&e->xfers, data->mid); + bool present = Curl_uint32_spbset_contains(&e->xfers, data->mid); if(present) - Curl_uint_spbset_remove(&e->xfers, data->mid); + Curl_uint32_spbset_remove(&e->xfers, data->mid); return present; } @@ -356,7 +356,7 @@ static CURLMcode mev_pollset_diff(struct Curl_multi *multi, ", total=%u/%d (xfer/conn)", s, conn ? "connection" : "transfer", conn ? conn->connection_id : data->mid, - Curl_uint_spbset_count(&entry->xfers), + Curl_uint32_spbset_count(&entry->xfers), entry->conn ? 1 : 0); } else { @@ -424,7 +424,7 @@ static CURLMcode mev_pollset_diff(struct Curl_multi *multi, return mresult; CURL_TRC_M(data, "ev entry fd=%" FMT_SOCKET_T ", removed transfer, " "total=%u/%d (xfer/conn)", s, - Curl_uint_spbset_count(&entry->xfers), + Curl_uint32_spbset_count(&entry->xfers), entry->conn ? 1 : 0); } else { @@ -545,18 +545,18 @@ CURLMcode Curl_multi_ev_assess_conn(struct Curl_multi *multi, } CURLMcode Curl_multi_ev_assess_xfer_bset(struct Curl_multi *multi, - struct uint_bset *set) + struct uint32_bset *set) { - unsigned int mid; + uint32_t mid; CURLMcode result = CURLM_OK; - if(multi && multi->socket_cb && Curl_uint_bset_first(set, &mid)) { + if(multi && multi->socket_cb && Curl_uint32_bset_first(set, &mid)) { do { struct Curl_easy *data = Curl_multi_get_easy(multi, mid); if(data) result = Curl_multi_ev_assess_xfer(multi, data); } - while(!result && Curl_uint_bset_next(set, mid, &mid)); + while(!result && Curl_uint32_bset_next(set, mid, &mid)); } return result; } @@ -588,9 +588,9 @@ void Curl_multi_ev_dirty_xfers(struct Curl_multi *multi, and just move on. */ if(entry) { struct Curl_easy *data; - unsigned int mid; + uint32_t mid; - if(Curl_uint_spbset_first(&entry->xfers, &mid)) { + if(Curl_uint32_spbset_first(&entry->xfers, &mid)) { do { data = Curl_multi_get_easy(multi, mid); if(data) { @@ -598,10 +598,10 @@ void Curl_multi_ev_dirty_xfers(struct Curl_multi *multi, } else { CURL_TRC_M(multi->admin, "socket transfer %u no longer found", mid); - Curl_uint_spbset_remove(&entry->xfers, mid); + Curl_uint32_spbset_remove(&entry->xfers, mid); } } - while(Curl_uint_spbset_next(&entry->xfers, mid, &mid)); + while(Curl_uint32_spbset_next(&entry->xfers, mid, &mid)); } if(entry->conn) diff --git a/lib/multi_ev.h b/lib/multi_ev.h index 34548c323232..4e5b2a454d26 100644 --- a/lib/multi_ev.h +++ b/lib/multi_ev.h @@ -29,7 +29,7 @@ struct Curl_easy; struct Curl_multi; struct easy_pollset; -struct uint_bset; +struct uint32_bset; /* meta key for event pollset at easy handle or connection */ #define CURL_META_MEV_POLLSET "meta:mev:ps" @@ -55,7 +55,7 @@ CURLMcode Curl_multi_ev_assess_xfer(struct Curl_multi *multi, struct Curl_easy *data); /* Assess all easy handles on the list */ CURLMcode Curl_multi_ev_assess_xfer_bset(struct Curl_multi *multi, - struct uint_bset *set); + struct uint32_bset *set); /* Assess the connection by getting its current pollset */ CURLMcode Curl_multi_ev_assess_conn(struct Curl_multi *multi, struct Curl_easy *data, diff --git a/lib/multi_ntfy.c b/lib/multi_ntfy.c index fe7cc0503a76..d7913bbbfc97 100644 --- a/lib/multi_ntfy.c +++ b/lib/multi_ntfy.c @@ -39,8 +39,8 @@ struct mntfy_entry { - unsigned int mid; - unsigned int type; + uint32_t mid; + uint32_t type; }; #define CURL_MNTFY_CHUNK_SIZE 128 @@ -69,7 +69,7 @@ static void mnfty_chunk_reset(struct mntfy_chunk *chunk) static bool mntfy_chunk_append(struct mntfy_chunk *chunk, struct Curl_easy *data, - unsigned int type) + uint32_t type) { struct mntfy_entry *e; @@ -116,7 +116,7 @@ static void mntfy_chunk_dispatch_all(struct Curl_multi *multi, e = &chunk->entries[chunk->r_offset]; data = e->mid ? Curl_multi_get_easy(multi, e->mid) : multi->admin; /* only when notification has not been disabled in the meantime */ - if(data && Curl_uint_bset_contains(&multi->ntfy.enabled, e->type)) { + if(data && Curl_uint32_bset_contains(&multi->ntfy.enabled, e->type)) { /* this may cause new notifications to be added! */ CURL_TRC_M(multi->admin, "[NTFY] dispatch %d to xfer %u", e->type, e->mid); @@ -132,12 +132,12 @@ static void mntfy_chunk_dispatch_all(struct Curl_multi *multi, void Curl_mntfy_init(struct Curl_multi *multi) { memset(&multi->ntfy, 0, sizeof(multi->ntfy)); - Curl_uint_bset_init(&multi->ntfy.enabled); + Curl_uint32_bset_init(&multi->ntfy.enabled); } CURLMcode Curl_mntfy_resize(struct Curl_multi *multi) { - if(Curl_uint_bset_resize(&multi->ntfy.enabled, CURLMNOTIFY_EASY_DONE + 1)) + if(Curl_uint32_bset_resize(&multi->ntfy.enabled, CURLMNOTIFY_EASY_DONE + 1)) return CURLM_OUT_OF_MEMORY; return CURLM_OK; } @@ -150,14 +150,14 @@ void Curl_mntfy_cleanup(struct Curl_multi *multi) mnfty_chunk_destroy(chunk); } multi->ntfy.tail = NULL; - Curl_uint_bset_destroy(&multi->ntfy.enabled); + Curl_uint32_bset_destroy(&multi->ntfy.enabled); } CURLMcode Curl_mntfy_enable(struct Curl_multi *multi, unsigned int type) { if(type > CURLMNOTIFY_EASY_DONE) return CURLM_UNKNOWN_OPTION; - Curl_uint_bset_add(&multi->ntfy.enabled, type); + Curl_uint32_bset_add(&multi->ntfy.enabled, type); return CURLM_OK; } @@ -165,7 +165,7 @@ CURLMcode Curl_mntfy_disable(struct Curl_multi *multi, unsigned int type) { if(type > CURLMNOTIFY_EASY_DONE) return CURLM_UNKNOWN_OPTION; - Curl_uint_bset_remove(&multi->ntfy.enabled, type); + Curl_uint32_bset_remove(&multi->ntfy.enabled, (uint32_t)type); return CURLM_OK; } @@ -173,12 +173,12 @@ void Curl_mntfy_add(struct Curl_easy *data, unsigned int type) { struct Curl_multi *multi = data ? data->multi : NULL; if(multi && multi->ntfy.ntfy_cb && !multi->ntfy.failure && - Curl_uint_bset_contains(&multi->ntfy.enabled, type)) { + Curl_uint32_bset_contains(&multi->ntfy.enabled, (uint32_t)type)) { /* append to list of outstanding notifications */ struct mntfy_chunk *tail = mntfy_non_full_tail(&multi->ntfy); CURL_TRC_M(data, "[NTFY] add %d for xfer %u", type, data->mid); if(tail) - mntfy_chunk_append(tail, data, type); + mntfy_chunk_append(tail, data, (uint32_t)type); else multi->ntfy.failure = CURLM_OUT_OF_MEMORY; } diff --git a/lib/multi_ntfy.h b/lib/multi_ntfy.h index d920b3295d4b..c3094a9ebe71 100644 --- a/lib/multi_ntfy.h +++ b/lib/multi_ntfy.h @@ -32,7 +32,7 @@ struct Curl_multi; struct curl_multi_ntfy { curl_notify_callback ntfy_cb; void *ntfy_cb_data; - struct uint_bset enabled; + struct uint32_bset enabled; CURLMcode failure; struct mntfy_chunk *head; struct mntfy_chunk *tail; diff --git a/lib/multihandle.h b/lib/multihandle.h index fbb8bdfeeb59..a267a209ee56 100644 --- a/lib/multihandle.h +++ b/lib/multihandle.h @@ -91,12 +91,12 @@ struct Curl_multi { unsigned int xfers_alive; /* amount of added transfers that have not yet reached COMPLETE state */ curl_off_t xfers_total_ever; /* total of added transfers, ever. */ - struct uint_tbl xfers; /* transfers added to this multi */ + struct uint32_tbl xfers; /* transfers added to this multi */ /* Each transfer's mid may be present in at most one of these */ - struct uint_bset process; /* transfer being processed */ - struct uint_bset dirty; /* transfer to be run NOW, e.g. ASAP. */ - struct uint_bset pending; /* transfers in waiting (conn limit etc.) */ - struct uint_bset msgsent; /* transfers done with message for application */ + struct uint32_bset process; /* transfer being processed */ + struct uint32_bset dirty; /* transfer to be run NOW, e.g. ASAP. */ + struct uint32_bset pending; /* transfers in waiting (conn limit etc.) */ + struct uint32_bset msgsent; /* transfers done with message for application */ struct Curl_llist msglist; /* a list of messages from completed transfers */ diff --git a/lib/multiif.h b/lib/multiif.h index 81cf665bd3d8..62c68c9cedf3 100644 --- a/lib/multiif.h +++ b/lib/multiif.h @@ -153,7 +153,7 @@ void Curl_multi_xfer_sockbuf_release(struct Curl_easy *data, char *buf); * Returns NULL if not found. */ struct Curl_easy *Curl_multi_get_easy(struct Curl_multi *multi, - unsigned int mid); + uint32_t mid); /* Get the # of transfers current in process/pending. */ unsigned int Curl_multi_xfers_running(struct Curl_multi *multi); diff --git a/lib/uint-bset.c b/lib/uint-bset.c index 7b822344c1f6..82440c56378a 100644 --- a/lib/uint-bset.c +++ b/lib/uint-bset.c @@ -30,32 +30,32 @@ #include "memdebug.h" #ifdef DEBUGBUILD -#define CURL_UINT_BSET_MAGIC 0x62757473 +#define CURL_UINT32_BSET_MAGIC 0x62757473 #endif -void Curl_uint_bset_init(struct uint_bset *bset) +void Curl_uint32_bset_init(struct uint32_bset *bset) { memset(bset, 0, sizeof(*bset)); #ifdef DEBUGBUILD - bset->init = CURL_UINT_BSET_MAGIC; + bset->init = CURL_UINT32_BSET_MAGIC; #endif } -CURLcode Curl_uint_bset_resize(struct uint_bset *bset, unsigned int nmax) +CURLcode Curl_uint32_bset_resize(struct uint32_bset *bset, uint32_t nmax) { - unsigned int nslots = (nmax < (UINT_MAX-63)) ? - ((nmax + 63) / 64) : (UINT_MAX / 64); + uint32_t nslots = (nmax < (UINT32_MAX-63)) ? + ((nmax + 63) / 64) : (UINT32_MAX / 64); - DEBUGASSERT(bset->init == CURL_UINT_BSET_MAGIC); + DEBUGASSERT(bset->init == CURL_UINT32_BSET_MAGIC); if(nslots != bset->nslots) { - curl_uint64_t *slots = calloc(nslots, sizeof(curl_uint64_t)); + uint64_t *slots = calloc(nslots, sizeof(uint64_t)); if(!slots) return CURLE_OUT_OF_MEMORY; if(bset->slots) { memcpy(slots, bset->slots, - (CURLMIN(nslots, bset->nslots) * sizeof(curl_uint64_t))); + (CURLMIN(nslots, bset->nslots) * sizeof(uint64_t))); free(bset->slots); } bset->slots = slots; @@ -66,24 +66,24 @@ CURLcode Curl_uint_bset_resize(struct uint_bset *bset, unsigned int nmax) } -void Curl_uint_bset_destroy(struct uint_bset *bset) +void Curl_uint32_bset_destroy(struct uint32_bset *bset) { - DEBUGASSERT(bset->init == CURL_UINT_BSET_MAGIC); + DEBUGASSERT(bset->init == CURL_UINT32_BSET_MAGIC); free(bset->slots); memset(bset, 0, sizeof(*bset)); } #ifdef UNITTESTS -UNITTEST unsigned int Curl_uint_bset_capacity(struct uint_bset *bset) +UNITTEST uint32_t Curl_uint32_bset_capacity(struct uint32_bset *bset) { return bset->nslots * 64; } #endif -unsigned int Curl_uint_bset_count(struct uint_bset *bset) +uint32_t Curl_uint32_bset_count(struct uint32_bset *bset) { - unsigned int i; - unsigned int n = 0; + uint32_t i; + uint32_t n = 0; for(i = 0; i < bset->nslots; ++i) { if(bset->slots[i]) n += CURL_POPCOUNT64(bset->slots[i]); @@ -91,9 +91,9 @@ unsigned int Curl_uint_bset_count(struct uint_bset *bset) return n; } -bool Curl_uint_bset_empty(struct uint_bset *bset) +bool Curl_uint32_bset_empty(struct uint32_bset *bset) { - unsigned int i; + uint32_t i; for(i = bset->first_slot_used; i < bset->nslots; ++i) { if(bset->slots[i]) return FALSE; @@ -102,47 +102,47 @@ bool Curl_uint_bset_empty(struct uint_bset *bset) } -void Curl_uint_bset_clear(struct uint_bset *bset) +void Curl_uint32_bset_clear(struct uint32_bset *bset) { if(bset->nslots) { - memset(bset->slots, 0, bset->nslots * sizeof(curl_uint64_t)); - bset->first_slot_used = UINT_MAX; + memset(bset->slots, 0, bset->nslots * sizeof(uint64_t)); + bset->first_slot_used = UINT32_MAX; } } -bool Curl_uint_bset_add(struct uint_bset *bset, unsigned int i) +bool Curl_uint32_bset_add(struct uint32_bset *bset, uint32_t i) { - unsigned int islot = i / 64; + uint32_t islot = i / 64; if(islot >= bset->nslots) return FALSE; - bset->slots[islot] |= ((curl_uint64_t)1 << (i % 64)); + bset->slots[islot] |= ((uint64_t)1 << (i % 64)); if(islot < bset->first_slot_used) bset->first_slot_used = islot; return TRUE; } -void Curl_uint_bset_remove(struct uint_bset *bset, unsigned int i) +void Curl_uint32_bset_remove(struct uint32_bset *bset, uint32_t i) { size_t islot = i / 64; if(islot < bset->nslots) - bset->slots[islot] &= ~((curl_uint64_t)1 << (i % 64)); + bset->slots[islot] &= ~((uint64_t)1 << (i % 64)); } -bool Curl_uint_bset_contains(struct uint_bset *bset, unsigned int i) +bool Curl_uint32_bset_contains(struct uint32_bset *bset, uint32_t i) { - unsigned int islot = i / 64; + uint32_t islot = i / 64; if(islot >= bset->nslots) return FALSE; - return (bset->slots[islot] & ((curl_uint64_t)1 << (i % 64))) != 0; + return (bset->slots[islot] & ((uint64_t)1 << (i % 64))) != 0; } -bool Curl_uint_bset_first(struct uint_bset *bset, unsigned int *pfirst) +bool Curl_uint32_bset_first(struct uint32_bset *bset, uint32_t *pfirst) { - unsigned int i; + uint32_t i; for(i = bset->first_slot_used; i < bset->nslots; ++i) { if(bset->slots[i]) { *pfirst = (i * 64) + CURL_CTZ64(bset->slots[i]); @@ -150,15 +150,15 @@ bool Curl_uint_bset_first(struct uint_bset *bset, unsigned int *pfirst) return TRUE; } } - bset->first_slot_used = *pfirst = UINT_MAX; + bset->first_slot_used = *pfirst = UINT32_MAX; return FALSE; } -bool Curl_uint_bset_next(struct uint_bset *bset, unsigned int last, - unsigned int *pnext) +bool Curl_uint32_bset_next(struct uint32_bset *bset, uint32_t last, + uint32_t *pnext) { - unsigned int islot; - curl_uint64_t x; + uint32_t islot; + uint64_t x; ++last; /* look for number one higher than last */ islot = last / 64; /* the slot this would be in */ @@ -178,42 +178,42 @@ bool Curl_uint_bset_next(struct uint_bset *bset, unsigned int last, } } } - *pnext = UINT_MAX; /* a value we cannot store */ + *pnext = UINT32_MAX; /* a value we cannot store */ return FALSE; } #ifdef CURL_POPCOUNT64_IMPLEMENT -unsigned int Curl_popcount64(curl_uint64_t x) +uint32_t Curl_popcount64(uint64_t x) { /* Compute the "Hamming Distance" between 'x' and 0, * which is the number of set bits in 'x'. * See: https://en.wikipedia.org/wiki/Hamming_weight */ - const curl_uint64_t m1 = 0x5555555555555555LL; /* 0101+ */ - const curl_uint64_t m2 = 0x3333333333333333LL; /* 00110011+ */ - const curl_uint64_t m4 = 0x0f0f0f0f0f0f0f0fLL; /* 00001111+ */ + const uint64_t m1 = 0x5555555555555555LL; /* 0101+ */ + const uint64_t m2 = 0x3333333333333333LL; /* 00110011+ */ + const uint64_t m4 = 0x0f0f0f0f0f0f0f0fLL; /* 00001111+ */ /* 1 + 256^1 + 256^2 + 256^3 + ... + 256^7 */ - const curl_uint64_t h01 = 0x0101010101010101LL; + const uint64_t h01 = 0x0101010101010101LL; x -= (x >> 1) & m1; /* replace every 2 bits with bits present */ x = (x & m2) + ((x >> 2) & m2); /* replace every nibble with bits present */ x = (x + (x >> 4)) & m4; /* replace every byte with bits present */ /* top 8 bits of x + (x<<8) + (x<<16) + (x<<24) + ... which makes the * top byte the sum of all individual 8 bytes, throw away the rest */ - return (unsigned int)((x * h01) >> 56); + return (uint32_t)((x * h01) >> 56); } #endif /* CURL_POPCOUNT64_IMPLEMENT */ #ifdef CURL_CTZ64_IMPLEMENT -unsigned int Curl_ctz64(curl_uint64_t x) +uint32_t Curl_ctz64(uint64_t x) { - /* count trailing zeros in a curl_uint64_t. + /* count trailing zeros in a uint64_t. * divide and conquer to find the number of lower 0 bits */ - const curl_uint64_t ml32 = 0xFFFFFFFF; /* lower 32 bits */ - const curl_uint64_t ml16 = 0x0000FFFF; /* lower 16 bits */ - const curl_uint64_t ml8 = 0x000000FF; /* lower 8 bits */ - const curl_uint64_t ml4 = 0x0000000F; /* lower 4 bits */ - const curl_uint64_t ml2 = 0x00000003; /* lower 2 bits */ - unsigned int n; + const uint64_t ml32 = 0xFFFFFFFF; /* lower 32 bits */ + const uint64_t ml16 = 0x0000FFFF; /* lower 16 bits */ + const uint64_t ml8 = 0x000000FF; /* lower 8 bits */ + const uint64_t ml4 = 0x0000000F; /* lower 4 bits */ + const uint64_t ml2 = 0x00000003; /* lower 2 bits */ + uint32_t n; if(!x) return 64; @@ -238,6 +238,6 @@ unsigned int Curl_ctz64(curl_uint64_t x) n = n + 2; x = x >> 2; } - return n - (unsigned int)(x & 1); + return n - (uint32_t)(x & 1); } #endif /* CURL_CTZ64_IMPLEMENT */ diff --git a/lib/uint-bset.h b/lib/uint-bset.h index cc405cc656e3..5e5bbdb8fc0b 100644 --- a/lib/uint-bset.h +++ b/lib/uint-bset.h @@ -39,51 +39,51 @@ * the price of slightly slower operations. */ -struct uint_bset { - curl_uint64_t *slots; - unsigned int nslots; - unsigned int first_slot_used; +struct uint32_bset { + uint64_t *slots; + uint32_t nslots; + uint32_t first_slot_used; #ifdef DEBUGBUILD int init; #endif }; /* Initialize the bitset with capacity 0. */ -void Curl_uint_bset_init(struct uint_bset *bset); +void Curl_uint32_bset_init(struct uint32_bset *bset); /* Resize the bitset capacity to hold numbers from 0 to `nmax`, * which rounds up `nmax` to the next multiple of 64. */ -CURLcode Curl_uint_bset_resize(struct uint_bset *bset, unsigned int nmax); +CURLcode Curl_uint32_bset_resize(struct uint32_bset *bset, uint32_t nmax); /* Destroy the bitset, freeing all resources. */ -void Curl_uint_bset_destroy(struct uint_bset *bset); +void Curl_uint32_bset_destroy(struct uint32_bset *bset); /* Get the bitset capacity, e.g. can hold numbers from 0 to capacity - 1. */ -unsigned int Curl_uint_bset_capacity(struct uint_bset *bset); +uint32_t Curl_uint32_bset_capacity(struct uint32_bset *bset); /* Get the cardinality of the bitset, e.g. numbers present in the set. */ -unsigned int Curl_uint_bset_count(struct uint_bset *bset); +uint32_t Curl_uint32_bset_count(struct uint32_bset *bset); /* TRUE of bitset is empty */ -bool Curl_uint_bset_empty(struct uint_bset *bset); +bool Curl_uint32_bset_empty(struct uint32_bset *bset); /* Clear the bitset, making it empty. */ -void Curl_uint_bset_clear(struct uint_bset *bset); +void Curl_uint32_bset_clear(struct uint32_bset *bset); /* Add the number `i` to the bitset. Return FALSE if the number is * outside the set's capacity. * Numbers can be added more than once, without making a difference. */ -bool Curl_uint_bset_add(struct uint_bset *bset, unsigned int i); +bool Curl_uint32_bset_add(struct uint32_bset *bset, uint32_t i); /* Remove the number `i` from the bitset. */ -void Curl_uint_bset_remove(struct uint_bset *bset, unsigned int i); +void Curl_uint32_bset_remove(struct uint32_bset *bset, uint32_t i); /* Return TRUE if the bitset contains number `i`. */ -bool Curl_uint_bset_contains(struct uint_bset *bset, unsigned int i); +bool Curl_uint32_bset_contains(struct uint32_bset *bset, uint32_t i); /* Get the first number in the bitset, e.g. the smallest. * Returns FALSE when the bitset is empty. */ -bool Curl_uint_bset_first(struct uint_bset *bset, unsigned int *pfirst); +bool Curl_uint32_bset_first(struct uint32_bset *bset, uint32_t *pfirst); /* Get the next number in the bitset, following `last` in natural order. * Put another way, this is the smallest number greater than `last` in @@ -96,20 +96,20 @@ bool Curl_uint_bset_first(struct uint_bset *bset, unsigned int *pfirst); * - added numbers lower than 'last' will not show up. * - removed numbers lower or equal to 'last' will not show up. * - removed numbers higher than 'last' will not be visited. */ -bool Curl_uint_bset_next(struct uint_bset *bset, unsigned int last, - unsigned int *pnext); +bool Curl_uint32_bset_next(struct uint32_bset *bset, uint32_t last, + uint32_t *pnext); #ifndef CURL_POPCOUNT64 #define CURL_POPCOUNT64(x) Curl_popcount64(x) #define CURL_POPCOUNT64_IMPLEMENT -unsigned int Curl_popcount64(curl_uint64_t x); +uint32_t Curl_popcount64(uint64_t x); #endif /* !CURL_POPCOUNT64 */ #ifndef CURL_CTZ64 #define CURL_CTZ64(x) Curl_ctz64(x) #define CURL_CTZ64_IMPLEMENT -unsigned int Curl_ctz64(curl_uint64_t x); +uint32_t Curl_ctz64(uint64_t x); #endif /* !CURL_CTZ64 */ #endif /* HEADER_CURL_UINT_BSET_H */ diff --git a/lib/uint-hash.c b/lib/uint-hash.c index 6c665078876c..4677c6ac9128 100644 --- a/lib/uint-hash.c +++ b/lib/uint-hash.c @@ -34,10 +34,10 @@ /* random patterns for API verification */ #ifdef DEBUGBUILD -#define CURL_UINTHASHINIT 0x7117e779 +#define CURL_UINT32_HASHINIT 0x7117e779 #endif -static unsigned int uint_hash_hash(unsigned int id, unsigned int slots) +static uint32_t uint32_hash_hash(uint32_t id, uint32_t slots) { return (id % slots); } @@ -46,12 +46,12 @@ static unsigned int uint_hash_hash(unsigned int id, unsigned int slots) struct uint_hash_entry { struct uint_hash_entry *next; void *value; - unsigned int id; + uint32_t id; }; -void Curl_uint_hash_init(struct uint_hash *h, - unsigned int slots, - Curl_uint_hash_dtor *dtor) +void Curl_uint32_hash_init(struct uint_hash *h, + uint32_t slots, + Curl_uint32_hash_dtor *dtor) { DEBUGASSERT(h); DEBUGASSERT(slots); @@ -61,11 +61,11 @@ void Curl_uint_hash_init(struct uint_hash *h, h->size = 0; h->slots = slots; #ifdef DEBUGBUILD - h->init = CURL_UINTHASHINIT; + h->init = CURL_UINT32_HASHINIT; #endif } -static struct uint_hash_entry *uint_hash_mk_entry(unsigned int id, void *value) +static struct uint_hash_entry *uint32_hash_mk_entry(uint32_t id, void *value) { struct uint_hash_entry *e; @@ -79,8 +79,8 @@ static struct uint_hash_entry *uint_hash_mk_entry(unsigned int id, void *value) return e; } -static void uint_hash_entry_clear(struct uint_hash *h, - struct uint_hash_entry *e) +static void uint32_hash_entry_clear(struct uint_hash *h, + struct uint_hash_entry *e) { DEBUGASSERT(h); DEBUGASSERT(e); @@ -91,78 +91,78 @@ static void uint_hash_entry_clear(struct uint_hash *h, } } -static void uint_hash_entry_destroy(struct uint_hash *h, - struct uint_hash_entry *e) +static void uint32_hash_entry_destroy(struct uint_hash *h, + struct uint_hash_entry *e) { - uint_hash_entry_clear(h, e); + uint32_hash_entry_clear(h, e); free(e); } -static void uint_hash_entry_unlink(struct uint_hash *h, - struct uint_hash_entry **he_anchor, - struct uint_hash_entry *he) +static void uint32_hash_entry_unlink(struct uint_hash *h, + struct uint_hash_entry **he_anchor, + struct uint_hash_entry *he) { *he_anchor = he->next; --h->size; } -static void uint_hash_elem_link(struct uint_hash *h, - struct uint_hash_entry **he_anchor, - struct uint_hash_entry *he) +static void uint32_hash_elem_link(struct uint_hash *h, + struct uint_hash_entry **he_anchor, + struct uint_hash_entry *he) { he->next = *he_anchor; *he_anchor = he; ++h->size; } -#define CURL_UINT_HASH_SLOT(h,id) h->table[uint_hash_hash(id, h->slots)] -#define CURL_UINT_HASH_SLOT_ADDR(h,id) &CURL_UINT_HASH_SLOT(h,id) +#define CURL_UINT32_HASH_SLOT(h,id) h->table[uint32_hash_hash(id, h->slots)] +#define CURL_UINT32_HASH_SLOT_ADDR(h,id) &CURL_UINT32_HASH_SLOT(h,id) -bool Curl_uint_hash_set(struct uint_hash *h, unsigned int id, void *value) +bool Curl_uint32_hash_set(struct uint_hash *h, uint32_t id, void *value) { struct uint_hash_entry *he, **slot; DEBUGASSERT(h); DEBUGASSERT(h->slots); - DEBUGASSERT(h->init == CURL_UINTHASHINIT); + DEBUGASSERT(h->init == CURL_UINT32_HASHINIT); if(!h->table) { h->table = calloc(h->slots, sizeof(*he)); if(!h->table) return FALSE; /* OOM */ } - slot = CURL_UINT_HASH_SLOT_ADDR(h, id); + slot = CURL_UINT32_HASH_SLOT_ADDR(h, id); for(he = *slot; he; he = he->next) { if(he->id == id) { /* existing key entry, overwrite by clearing old pointer */ - uint_hash_entry_clear(h, he); + uint32_hash_entry_clear(h, he); he->value = value; return TRUE; } } - he = uint_hash_mk_entry(id, value); + he = uint32_hash_mk_entry(id, value); if(!he) return FALSE; /* OOM */ - uint_hash_elem_link(h, slot, he); + uint32_hash_elem_link(h, slot, he); return TRUE; } -bool Curl_uint_hash_remove(struct uint_hash *h, unsigned int id) +bool Curl_uint32_hash_remove(struct uint_hash *h, uint32_t id) { DEBUGASSERT(h); DEBUGASSERT(h->slots); - DEBUGASSERT(h->init == CURL_UINTHASHINIT); + DEBUGASSERT(h->init == CURL_UINT32_HASHINIT); if(h->table) { struct uint_hash_entry *he, **he_anchor; - he_anchor = CURL_UINT_HASH_SLOT_ADDR(h, id); + he_anchor = CURL_UINT32_HASH_SLOT_ADDR(h, id); while(*he_anchor) { he = *he_anchor; if(id == he->id) { - uint_hash_entry_unlink(h, he_anchor, he); - uint_hash_entry_destroy(h, he); + uint32_hash_entry_unlink(h, he_anchor, he); + uint32_hash_entry_destroy(h, he); return TRUE; } he_anchor = &he->next; @@ -171,14 +171,14 @@ bool Curl_uint_hash_remove(struct uint_hash *h, unsigned int id) return FALSE; } -void *Curl_uint_hash_get(struct uint_hash *h, unsigned int id) +void *Curl_uint32_hash_get(struct uint_hash *h, uint32_t id) { DEBUGASSERT(h); - DEBUGASSERT(h->init == CURL_UINTHASHINIT); + DEBUGASSERT(h->init == CURL_UINT32_HASHINIT); if(h->table) { struct uint_hash_entry *he; DEBUGASSERT(h->slots); - he = CURL_UINT_HASH_SLOT(h, id); + he = CURL_UINT32_HASH_SLOT(h, id); while(he) { if(id == he->id) { return he->value; @@ -194,28 +194,28 @@ static void uint_hash_clear(struct uint_hash *h) if(h && h->table) { struct uint_hash_entry *he, **he_anchor; size_t i; - DEBUGASSERT(h->init == CURL_UINTHASHINIT); + DEBUGASSERT(h->init == CURL_UINT32_HASHINIT); for(i = 0; i < h->slots; ++i) { he_anchor = &h->table[i]; while(*he_anchor) { he = *he_anchor; - uint_hash_entry_unlink(h, he_anchor, he); - uint_hash_entry_destroy(h, he); + uint32_hash_entry_unlink(h, he_anchor, he); + uint32_hash_entry_destroy(h, he); } } } } #ifdef UNITTESTS -UNITTEST void Curl_uint_hash_clear(struct uint_hash *h) +UNITTEST void Curl_uint32_hash_clear(struct uint_hash *h) { uint_hash_clear(h); } #endif -void Curl_uint_hash_destroy(struct uint_hash *h) +void Curl_uint32_hash_destroy(struct uint_hash *h) { - DEBUGASSERT(h->init == CURL_UINTHASHINIT); + DEBUGASSERT(h->init == CURL_UINT32_HASHINIT); if(h->table) { uint_hash_clear(h); Curl_safefree(h->table); @@ -224,20 +224,20 @@ void Curl_uint_hash_destroy(struct uint_hash *h) h->slots = 0; } -unsigned int Curl_uint_hash_count(struct uint_hash *h) +uint32_t Curl_uint32_hash_count(struct uint_hash *h) { - DEBUGASSERT(h->init == CURL_UINTHASHINIT); + DEBUGASSERT(h->init == CURL_UINT32_HASHINIT); return h->size; } -void Curl_uint_hash_visit(struct uint_hash *h, - Curl_uint_hash_visit_cb *cb, - void *user_data) +void Curl_uint32_hash_visit(struct uint_hash *h, + Curl_uint32_hash_visit_cb *cb, + void *user_data) { if(h && h->table && cb) { struct uint_hash_entry *he; size_t i; - DEBUGASSERT(h->init == CURL_UINTHASHINIT); + DEBUGASSERT(h->init == CURL_UINT32_HASHINIT); for(i = 0; i < h->slots; ++i) { for(he = h->table[i]; he; he = he->next) { if(!cb(he->id, he->value, user_data)) diff --git a/lib/uint-hash.h b/lib/uint-hash.h index 1b52dba4c470..330f61208bfa 100644 --- a/lib/uint-hash.h +++ b/lib/uint-hash.h @@ -30,39 +30,39 @@ #include "llist.h" -/* A version with unsigned int as key */ -typedef void Curl_uint_hash_dtor(unsigned int id, void *value); +/* A version with uint32_t as key */ +typedef void Curl_uint32_hash_dtor(uint32_t id, void *value); struct uint_hash_entry; -/* Hash for `unsigned int` as key */ +/* Hash for `uint32_t` as key */ struct uint_hash { struct uint_hash_entry **table; - Curl_uint_hash_dtor *dtor; - unsigned int slots; - unsigned int size; + Curl_uint32_hash_dtor *dtor; + uint32_t slots; + uint32_t size; #ifdef DEBUGBUILD int init; #endif }; -void Curl_uint_hash_init(struct uint_hash *h, - unsigned int slots, - Curl_uint_hash_dtor *dtor); -void Curl_uint_hash_destroy(struct uint_hash *h); -void Curl_uint_hash_clear(struct uint_hash *h); +void Curl_uint32_hash_init(struct uint_hash *h, + uint32_t slots, + Curl_uint32_hash_dtor *dtor); +void Curl_uint32_hash_destroy(struct uint_hash *h); +void Curl_uint32_hash_clear(struct uint_hash *h); -bool Curl_uint_hash_set(struct uint_hash *h, unsigned int id, void *value); -bool Curl_uint_hash_remove(struct uint_hash *h, unsigned int id); -void *Curl_uint_hash_get(struct uint_hash *h, unsigned int id); -unsigned int Curl_uint_hash_count(struct uint_hash *h); +bool Curl_uint32_hash_set(struct uint_hash *h, uint32_t id, void *value); +bool Curl_uint32_hash_remove(struct uint_hash *h, uint32_t id); +void *Curl_uint32_hash_get(struct uint_hash *h, uint32_t id); +uint32_t Curl_uint32_hash_count(struct uint_hash *h); -typedef bool Curl_uint_hash_visit_cb(unsigned int id, void *value, - void *user_data); +typedef bool Curl_uint32_hash_visit_cb(uint32_t id, void *value, + void *user_data); -void Curl_uint_hash_visit(struct uint_hash *h, - Curl_uint_hash_visit_cb *cb, - void *user_data); +void Curl_uint32_hash_visit(struct uint_hash *h, + Curl_uint32_hash_visit_cb *cb, + void *user_data); #endif /* HEADER_CURL_UINT_HASH_H */ diff --git a/lib/uint-spbset.c b/lib/uint-spbset.c index 2e8e2a139e74..f250bcb1b43f 100644 --- a/lib/uint-spbset.c +++ b/lib/uint-spbset.c @@ -31,33 +31,33 @@ #include "memdebug.h" #ifdef DEBUGBUILD -#define CURL_UINT_SPBSET_MAGIC 0x70737362 +#define CURL_UINT32_SPBSET_MAGIC 0x70737362 #endif /* Clear the bitset, making it empty. */ -UNITTEST void Curl_uint_spbset_clear(struct uint_spbset *bset); +UNITTEST void Curl_uint32_spbset_clear(struct uint32_spbset *bset); -void Curl_uint_spbset_init(struct uint_spbset *bset) +void Curl_uint32_spbset_init(struct uint32_spbset *bset) { memset(bset, 0, sizeof(*bset)); #ifdef DEBUGBUILD - bset->init = CURL_UINT_SPBSET_MAGIC; + bset->init = CURL_UINT32_SPBSET_MAGIC; #endif } -void Curl_uint_spbset_destroy(struct uint_spbset *bset) +void Curl_uint32_spbset_destroy(struct uint32_spbset *bset) { - DEBUGASSERT(bset->init == CURL_UINT_SPBSET_MAGIC); - Curl_uint_spbset_clear(bset); + DEBUGASSERT(bset->init == CURL_UINT32_SPBSET_MAGIC); + Curl_uint32_spbset_clear(bset); } -unsigned int Curl_uint_spbset_count(struct uint_spbset *bset) +uint32_t Curl_uint32_spbset_count(struct uint32_spbset *bset) { - struct uint_spbset_chunk *chunk; - unsigned int i, n = 0; + struct uint32_spbset_chunk *chunk; + uint32_t i, n = 0; for(chunk = &bset->head; chunk; chunk = chunk->next) { - for(i = 0; i < CURL_UINT_SPBSET_CH_SLOTS; ++i) { + for(i = 0; i < CURL_UINT32_SPBSET_CH_SLOTS; ++i) { if(chunk->slots[i]) n += CURL_POPCOUNT64(chunk->slots[i]); } @@ -65,13 +65,13 @@ unsigned int Curl_uint_spbset_count(struct uint_spbset *bset) return n; } -bool Curl_uint_spbset_empty(struct uint_spbset *bset) +bool Curl_uint32_spbset_empty(struct uint32_spbset *bset) { - struct uint_spbset_chunk *chunk; - unsigned int i; + struct uint32_spbset_chunk *chunk; + uint32_t i; for(chunk = &bset->head; chunk; chunk = chunk->next) { - for(i = 0; i < CURL_UINT_SPBSET_CH_SLOTS; ++i) { + for(i = 0; i < CURL_UINT32_SPBSET_CH_SLOTS; ++i) { if(chunk->slots[i]) return FALSE; } @@ -79,9 +79,9 @@ bool Curl_uint_spbset_empty(struct uint_spbset *bset) return TRUE; } -UNITTEST void Curl_uint_spbset_clear(struct uint_spbset *bset) +UNITTEST void Curl_uint32_spbset_clear(struct uint32_spbset *bset) { - struct uint_spbset_chunk *next, *chunk; + struct uint32_spbset_chunk *next, *chunk; for(chunk = bset->head.next; chunk; chunk = next) { next = chunk->next; @@ -91,11 +91,11 @@ UNITTEST void Curl_uint_spbset_clear(struct uint_spbset *bset) } -static struct uint_spbset_chunk * -uint_spbset_get_chunk(struct uint_spbset *bset, unsigned int i, bool grow) +static struct uint32_spbset_chunk * +uint32_spbset_get_chunk(struct uint32_spbset *bset, uint32_t i, bool grow) { - struct uint_spbset_chunk *chunk, **panchor = NULL; - unsigned int i_offset = (i & ~CURL_UINT_SPBSET_CH_MASK); + struct uint32_spbset_chunk *chunk, **panchor = NULL; + uint32_t i_offset = (i & ~CURL_UINT32_SPBSET_CH_MASK); if(!bset) return NULL; @@ -134,61 +134,61 @@ uint_spbset_get_chunk(struct uint_spbset *bset, unsigned int i, bool grow) } -bool Curl_uint_spbset_add(struct uint_spbset *bset, unsigned int i) +bool Curl_uint32_spbset_add(struct uint32_spbset *bset, uint32_t i) { - struct uint_spbset_chunk *chunk; - unsigned int i_chunk; + struct uint32_spbset_chunk *chunk; + uint32_t i_chunk; - chunk = uint_spbset_get_chunk(bset, i, TRUE); + chunk = uint32_spbset_get_chunk(bset, i, TRUE); if(!chunk) return FALSE; DEBUGASSERT(i >= chunk->offset); i_chunk = (i - chunk->offset); - DEBUGASSERT((i_chunk / 64) < CURL_UINT_SPBSET_CH_SLOTS); - chunk->slots[(i_chunk / 64)] |= ((curl_uint64_t)1 << (i_chunk % 64)); + DEBUGASSERT((i_chunk / 64) < CURL_UINT32_SPBSET_CH_SLOTS); + chunk->slots[(i_chunk / 64)] |= ((uint64_t)1 << (i_chunk % 64)); return TRUE; } -void Curl_uint_spbset_remove(struct uint_spbset *bset, unsigned int i) +void Curl_uint32_spbset_remove(struct uint32_spbset *bset, uint32_t i) { - struct uint_spbset_chunk *chunk; - unsigned int i_chunk; + struct uint32_spbset_chunk *chunk; + uint32_t i_chunk; - chunk = uint_spbset_get_chunk(bset, i, FALSE); + chunk = uint32_spbset_get_chunk(bset, i, FALSE); if(chunk) { DEBUGASSERT(i >= chunk->offset); i_chunk = (i - chunk->offset); - DEBUGASSERT((i_chunk / 64) < CURL_UINT_SPBSET_CH_SLOTS); - chunk->slots[(i_chunk / 64)] &= ~((curl_uint64_t)1 << (i_chunk % 64)); + DEBUGASSERT((i_chunk / 64) < CURL_UINT32_SPBSET_CH_SLOTS); + chunk->slots[(i_chunk / 64)] &= ~((uint64_t)1 << (i_chunk % 64)); } } -bool Curl_uint_spbset_contains(struct uint_spbset *bset, unsigned int i) +bool Curl_uint32_spbset_contains(struct uint32_spbset *bset, uint32_t i) { - struct uint_spbset_chunk *chunk; - unsigned int i_chunk; + struct uint32_spbset_chunk *chunk; + uint32_t i_chunk; - chunk = uint_spbset_get_chunk(bset, i, FALSE); + chunk = uint32_spbset_get_chunk(bset, i, FALSE); if(chunk) { DEBUGASSERT(i >= chunk->offset); i_chunk = (i - chunk->offset); - DEBUGASSERT((i_chunk / 64) < CURL_UINT_SPBSET_CH_SLOTS); + DEBUGASSERT((i_chunk / 64) < CURL_UINT32_SPBSET_CH_SLOTS); return (chunk->slots[i_chunk / 64] & - ((curl_uint64_t)1 << (i_chunk % 64))) != 0; + ((uint64_t)1 << (i_chunk % 64))) != 0; } return FALSE; } -bool Curl_uint_spbset_first(struct uint_spbset *bset, unsigned int *pfirst) +bool Curl_uint32_spbset_first(struct uint32_spbset *bset, uint32_t *pfirst) { - struct uint_spbset_chunk *chunk; - unsigned int i; + struct uint32_spbset_chunk *chunk; + uint32_t i; for(chunk = &bset->head; chunk; chunk = chunk->next) { - for(i = 0; i < CURL_UINT_SPBSET_CH_SLOTS; ++i) { + for(i = 0; i < CURL_UINT32_SPBSET_CH_SLOTS; ++i) { if(chunk->slots[i]) { *pfirst = chunk->offset + ((i * 64) + CURL_CTZ64(chunk->slots[i])); return TRUE; @@ -200,29 +200,29 @@ bool Curl_uint_spbset_first(struct uint_spbset *bset, unsigned int *pfirst) } -static bool uint_spbset_chunk_first(struct uint_spbset_chunk *chunk, - unsigned int *pfirst) +static bool uint32_spbset_chunk_first(struct uint32_spbset_chunk *chunk, + uint32_t *pfirst) { - unsigned int i; - for(i = 0; i < CURL_UINT_SPBSET_CH_SLOTS; ++i) { + uint32_t i; + for(i = 0; i < CURL_UINT32_SPBSET_CH_SLOTS; ++i) { if(chunk->slots[i]) { *pfirst = chunk->offset + ((i * 64) + CURL_CTZ64(chunk->slots[i])); return TRUE; } } - *pfirst = UINT_MAX; /* a value we cannot store */ + *pfirst = UINT32_MAX; /* a value we cannot store */ return FALSE; } -static bool uint_spbset_chunk_next(struct uint_spbset_chunk *chunk, - unsigned int last, - unsigned int *pnext) +static bool uint32_spbset_chunk_next(struct uint32_spbset_chunk *chunk, + uint32_t last, + uint32_t *pnext) { if(chunk->offset <= last) { - curl_uint64_t x; - unsigned int i = ((last - chunk->offset) / 64); - if(i < CURL_UINT_SPBSET_CH_SLOTS) { + uint64_t x; + uint32_t i = ((last - chunk->offset) / 64); + if(i < CURL_UINT32_SPBSET_CH_SLOTS) { x = (chunk->slots[i] >> (last % 64)); if(x) { /* more bits set, next is `last` + trailing0s of the shifted slot */ @@ -230,7 +230,7 @@ static bool uint_spbset_chunk_next(struct uint_spbset_chunk *chunk, return TRUE; } /* no more bits set in the last slot, scan forward */ - for(i = i + 1; i < CURL_UINT_SPBSET_CH_SLOTS; ++i) { + for(i = i + 1; i < CURL_UINT32_SPBSET_CH_SLOTS; ++i) { if(chunk->slots[i]) { *pnext = chunk->offset + ((i * 64) + CURL_CTZ64(chunk->slots[i])); return TRUE; @@ -238,18 +238,18 @@ static bool uint_spbset_chunk_next(struct uint_spbset_chunk *chunk, } } } - *pnext = UINT_MAX; + *pnext = UINT32_MAX; return FALSE; } -bool Curl_uint_spbset_next(struct uint_spbset *bset, unsigned int last, - unsigned int *pnext) +bool Curl_uint32_spbset_next(struct uint32_spbset *bset, uint32_t last, + uint32_t *pnext) { - struct uint_spbset_chunk *chunk; - unsigned int last_offset; + struct uint32_spbset_chunk *chunk; + uint32_t last_offset; ++last; /* look for the next higher number */ - last_offset = (last & ~CURL_UINT_SPBSET_CH_MASK); + last_offset = (last & ~CURL_UINT32_SPBSET_CH_MASK); for(chunk = &bset->head; chunk; chunk = chunk->next) { if(chunk->offset >= last_offset) { @@ -259,17 +259,17 @@ bool Curl_uint_spbset_next(struct uint_spbset *bset, unsigned int last, if(chunk && (chunk->offset == last_offset)) { /* is there a number higher than last in this chunk? */ - if(uint_spbset_chunk_next(chunk, last, pnext)) + if(uint32_spbset_chunk_next(chunk, last, pnext)) return TRUE; /* not in this chunk */ chunk = chunk->next; } /* look for the first in the "higher" chunks, if there are any. */ while(chunk) { - if(uint_spbset_chunk_first(chunk, pnext)) + if(uint32_spbset_chunk_first(chunk, pnext)) return TRUE; chunk = chunk->next; } - *pnext = UINT_MAX; + *pnext = UINT32_MAX; return FALSE; } diff --git a/lib/uint-spbset.h b/lib/uint-spbset.h index bd2347902c3b..8c46ce4aa8ea 100644 --- a/lib/uint-spbset.h +++ b/lib/uint-spbset.h @@ -27,8 +27,8 @@ #include -/* A "sparse" bitset for unsigned int values. - * It can hold any unsigned int value. +/* A "sparse" bitset for uint32_t values. + * It can hold any uint32_t value. * * Optimized for the case where only a small set of numbers need * to be kept, especially when "close" together. Then storage space @@ -36,48 +36,48 @@ */ /* 4 slots = 256 bits, keep this a 2^n value. */ -#define CURL_UINT_SPBSET_CH_SLOTS 4 -#define CURL_UINT_SPBSET_CH_MASK ((CURL_UINT_SPBSET_CH_SLOTS * 64) - 1) +#define CURL_UINT32_SPBSET_CH_SLOTS 4 +#define CURL_UINT32_SPBSET_CH_MASK ((CURL_UINT32_SPBSET_CH_SLOTS * 64) - 1) /* store the uint value from offset to - * (offset + (CURL_UINT_SPBSET_CHUNK_SLOTS * 64) - 1 */ -struct uint_spbset_chunk { - struct uint_spbset_chunk *next; - curl_uint64_t slots[CURL_UINT_SPBSET_CH_SLOTS]; - unsigned int offset; + * (offset + (CURL_UINT32_SPBSET_CHUNK_SLOTS * 64) - 1 */ +struct uint32_spbset_chunk { + struct uint32_spbset_chunk *next; + uint64_t slots[CURL_UINT32_SPBSET_CH_SLOTS]; + uint32_t offset; }; -struct uint_spbset { - struct uint_spbset_chunk head; +struct uint32_spbset { + struct uint32_spbset_chunk head; #ifdef DEBUGBUILD int init; #endif }; -void Curl_uint_spbset_init(struct uint_spbset *bset); +void Curl_uint32_spbset_init(struct uint32_spbset *bset); -void Curl_uint_spbset_destroy(struct uint_spbset *bset); +void Curl_uint32_spbset_destroy(struct uint32_spbset *bset); /* Get the cardinality of the bitset, e.g. numbers present in the set. */ -unsigned int Curl_uint_spbset_count(struct uint_spbset *bset); +uint32_t Curl_uint32_spbset_count(struct uint32_spbset *bset); /* TRUE of bitset is empty */ -bool Curl_uint_spbset_empty(struct uint_spbset *bset); +bool Curl_uint32_spbset_empty(struct uint32_spbset *bset); /* Add the number `i` to the bitset. * Numbers can be added more than once, without making a difference. * Returns FALSE if allocations failed. */ -bool Curl_uint_spbset_add(struct uint_spbset *bset, unsigned int i); +bool Curl_uint32_spbset_add(struct uint32_spbset *bset, uint32_t i); /* Remove the number `i` from the bitset. */ -void Curl_uint_spbset_remove(struct uint_spbset *bset, unsigned int i); +void Curl_uint32_spbset_remove(struct uint32_spbset *bset, uint32_t i); /* Return TRUE if the bitset contains number `i`. */ -bool Curl_uint_spbset_contains(struct uint_spbset *bset, unsigned int i); +bool Curl_uint32_spbset_contains(struct uint32_spbset *bset, uint32_t i); /* Get the first number in the bitset, e.g. the smallest. * Returns FALSE when the bitset is empty. */ -bool Curl_uint_spbset_first(struct uint_spbset *bset, unsigned int *pfirst); +bool Curl_uint32_spbset_first(struct uint32_spbset *bset, uint32_t *pfirst); /* Get the next number in the bitset, following `last` in natural order. * Put another way, this is the smallest number greater than `last` in @@ -90,7 +90,7 @@ bool Curl_uint_spbset_first(struct uint_spbset *bset, unsigned int *pfirst); * - added numbers lower than 'last' will not show up. * - removed numbers lower or equal to 'last' will not show up. * - removed numbers higher than 'last' will not be visited. */ -bool Curl_uint_spbset_next(struct uint_spbset *bset, unsigned int last, - unsigned int *pnext); +bool Curl_uint32_spbset_next(struct uint32_spbset *bset, uint32_t last, + uint32_t *pnext); #endif /* HEADER_CURL_UINT_SPBSET_H */ diff --git a/lib/uint-table.c b/lib/uint-table.c index 5077363ab0f3..5516ab634bf1 100644 --- a/lib/uint-table.c +++ b/lib/uint-table.c @@ -30,29 +30,29 @@ #include "memdebug.h" #ifdef DEBUGBUILD -#define CURL_UINT_TBL_MAGIC 0x62757473 +#define CURL_UINT32_TBL_MAGIC 0x62757473 #endif /* Clear the table, making it empty. */ -UNITTEST void Curl_uint_tbl_clear(struct uint_tbl *tbl); +UNITTEST void Curl_uint32_tbl_clear(struct uint32_tbl *tbl); -void Curl_uint_tbl_init(struct uint_tbl *tbl, - Curl_uint_tbl_entry_dtor *entry_dtor) +void Curl_uint32_tbl_init(struct uint32_tbl *tbl, + Curl_uint32_tbl_entry_dtor *entry_dtor) { memset(tbl, 0, sizeof(*tbl)); tbl->entry_dtor = entry_dtor; - tbl->last_key_added = UINT_MAX; + tbl->last_key_added = UINT32_MAX; #ifdef DEBUGBUILD - tbl->init = CURL_UINT_TBL_MAGIC; + tbl->init = CURL_UINT32_TBL_MAGIC; #endif } -static void uint_tbl_clear_rows(struct uint_tbl *tbl, - unsigned int from, - unsigned int upto_excluding) +static void uint32_tbl_clear_rows(struct uint32_tbl *tbl, + uint32_t from, + uint32_t upto_excluding) { - unsigned int i, end; + uint32_t i, end; end = CURLMIN(upto_excluding, tbl->nrows); for(i = from; i < end; ++i) { @@ -66,10 +66,10 @@ static void uint_tbl_clear_rows(struct uint_tbl *tbl, } -CURLcode Curl_uint_tbl_resize(struct uint_tbl *tbl, unsigned int nrows) +CURLcode Curl_uint32_tbl_resize(struct uint32_tbl *tbl, uint32_t nrows) { /* we use `tbl->nrows + 1` during iteration, want that to work */ - DEBUGASSERT(tbl->init == CURL_UINT_TBL_MAGIC); + DEBUGASSERT(tbl->init == CURL_UINT32_TBL_MAGIC); if(!nrows) return CURLE_BAD_FUNCTION_ARGUMENT; if(nrows != tbl->nrows) { @@ -79,7 +79,7 @@ CURLcode Curl_uint_tbl_resize(struct uint_tbl *tbl, unsigned int nrows) if(tbl->rows) { memcpy(rows, tbl->rows, (CURLMIN(nrows, tbl->nrows) * sizeof(void *))); if(nrows < tbl->nrows) - uint_tbl_clear_rows(tbl, nrows, tbl->nrows); + uint32_tbl_clear_rows(tbl, nrows, tbl->nrows); free(tbl->rows); } tbl->rows = rows; @@ -89,49 +89,49 @@ CURLcode Curl_uint_tbl_resize(struct uint_tbl *tbl, unsigned int nrows) } -void Curl_uint_tbl_destroy(struct uint_tbl *tbl) +void Curl_uint32_tbl_destroy(struct uint32_tbl *tbl) { - DEBUGASSERT(tbl->init == CURL_UINT_TBL_MAGIC); - Curl_uint_tbl_clear(tbl); + DEBUGASSERT(tbl->init == CURL_UINT32_TBL_MAGIC); + Curl_uint32_tbl_clear(tbl); free(tbl->rows); memset(tbl, 0, sizeof(*tbl)); } -UNITTEST void Curl_uint_tbl_clear(struct uint_tbl *tbl) +UNITTEST void Curl_uint32_tbl_clear(struct uint32_tbl *tbl) { - DEBUGASSERT(tbl->init == CURL_UINT_TBL_MAGIC); - uint_tbl_clear_rows(tbl, 0, tbl->nrows); + DEBUGASSERT(tbl->init == CURL_UINT32_TBL_MAGIC); + uint32_tbl_clear_rows(tbl, 0, tbl->nrows); DEBUGASSERT(!tbl->nentries); - tbl->last_key_added = UINT_MAX; + tbl->last_key_added = UINT32_MAX; } -unsigned int Curl_uint_tbl_capacity(struct uint_tbl *tbl) +uint32_t Curl_uint32_tbl_capacity(struct uint32_tbl *tbl) { return tbl->nrows; } -unsigned int Curl_uint_tbl_count(struct uint_tbl *tbl) +uint32_t Curl_uint32_tbl_count(struct uint32_tbl *tbl) { return tbl->nentries; } -void *Curl_uint_tbl_get(struct uint_tbl *tbl, unsigned int key) +void *Curl_uint32_tbl_get(struct uint32_tbl *tbl, uint32_t key) { return (key < tbl->nrows) ? tbl->rows[key] : NULL; } -bool Curl_uint_tbl_add(struct uint_tbl *tbl, void *entry, unsigned int *pkey) +bool Curl_uint32_tbl_add(struct uint32_tbl *tbl, void *entry, uint32_t *pkey) { - unsigned int key, start_pos; + uint32_t key, start_pos; - DEBUGASSERT(tbl->init == CURL_UINT_TBL_MAGIC); + DEBUGASSERT(tbl->init == CURL_UINT32_TBL_MAGIC); if(!entry || !pkey) return FALSE; - *pkey = UINT_MAX; + *pkey = UINT32_MAX; if(tbl->nentries == tbl->nrows) /* full */ return FALSE; @@ -161,20 +161,20 @@ bool Curl_uint_tbl_add(struct uint_tbl *tbl, void *entry, unsigned int *pkey) } -void Curl_uint_tbl_remove(struct uint_tbl *tbl, unsigned int key) +void Curl_uint32_tbl_remove(struct uint32_tbl *tbl, uint32_t key) { - uint_tbl_clear_rows(tbl, key, key + 1); + uint32_tbl_clear_rows(tbl, key, key + 1); } -bool Curl_uint_tbl_contains(struct uint_tbl *tbl, unsigned int key) +bool Curl_uint32_tbl_contains(struct uint32_tbl *tbl, uint32_t key) { return (key < tbl->nrows) ? !!tbl->rows[key] : FALSE; } -static bool uint_tbl_next_at(struct uint_tbl *tbl, unsigned int key, - unsigned int *pkey, void **pentry) +static bool uint32_tbl_next_at(struct uint32_tbl *tbl, uint32_t key, + uint32_t *pkey, void **pentry) { for(; key < tbl->nrows; ++key) { if(tbl->rows[key]) { @@ -183,33 +183,33 @@ static bool uint_tbl_next_at(struct uint_tbl *tbl, unsigned int key, return TRUE; } } - *pkey = UINT_MAX; /* always invalid */ + *pkey = UINT32_MAX; /* always invalid */ *pentry = NULL; return FALSE; } -bool Curl_uint_tbl_first(struct uint_tbl *tbl, - unsigned int *pkey, void **pentry) +bool Curl_uint32_tbl_first(struct uint32_tbl *tbl, + uint32_t *pkey, void **pentry) { if(!pkey || !pentry) return FALSE; - if(tbl->nentries && uint_tbl_next_at(tbl, 0, pkey, pentry)) + if(tbl->nentries && uint32_tbl_next_at(tbl, 0, pkey, pentry)) return TRUE; DEBUGASSERT(!tbl->nentries); - *pkey = UINT_MAX; /* always invalid */ + *pkey = UINT32_MAX; /* always invalid */ *pentry = NULL; return FALSE; } -bool Curl_uint_tbl_next(struct uint_tbl *tbl, unsigned int last_key, - unsigned int *pkey, void **pentry) +bool Curl_uint32_tbl_next(struct uint32_tbl *tbl, uint32_t last_key, + uint32_t *pkey, void **pentry) { if(!pkey || !pentry) return FALSE; - if(uint_tbl_next_at(tbl, last_key + 1, pkey, pentry)) + if(uint32_tbl_next_at(tbl, last_key + 1, pkey, pentry)) return TRUE; - *pkey = UINT_MAX; /* always invalid */ + *pkey = UINT32_MAX; /* always invalid */ *pentry = NULL; return FALSE; } diff --git a/lib/uint-table.h b/lib/uint-table.h index c74ec7ad634d..f3169fbc8fa2 100644 --- a/lib/uint-table.h +++ b/lib/uint-table.h @@ -28,14 +28,14 @@ #include /* Destructor for a single table entry */ -typedef void Curl_uint_tbl_entry_dtor(unsigned int key, void *entry); +typedef void Curl_uint32_tbl_entry_dtor(uint32_t key, void *entry); -struct uint_tbl { +struct uint32_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; /* entries in table */ - unsigned int last_key_added; /* UINT_MAX or last key added */ + Curl_uint32_tbl_entry_dtor *entry_dtor; + uint32_t nrows; /* length of `rows` array */ + uint32_t nentries; /* entries in table */ + uint32_t last_key_added; /* UINT_MAX or last key added */ #ifdef DEBUGBUILD int init; #endif @@ -44,42 +44,42 @@ struct uint_tbl { /* Initialize the table with 0 capacity. * The optional `entry_dtor` is called when a table entry is removed, * Passing NULL means no action is taken on removal. */ -void Curl_uint_tbl_init(struct uint_tbl *tbl, - Curl_uint_tbl_entry_dtor *entry_dtor); +void Curl_uint32_tbl_init(struct uint32_tbl *tbl, + Curl_uint32_tbl_entry_dtor *entry_dtor); /* Resize the table to change capacity `nmax`. When `nmax` is reduced, * all present entries with key equal or larger to `nmax` are removed. */ -CURLcode Curl_uint_tbl_resize(struct uint_tbl *tbl, unsigned int nmax); +CURLcode Curl_uint32_tbl_resize(struct uint32_tbl *tbl, uint32_t nmax); /* Destroy the table, freeing all entries. */ -void Curl_uint_tbl_destroy(struct uint_tbl *tbl); +void Curl_uint32_tbl_destroy(struct uint32_tbl *tbl); /* Get the table capacity. */ -unsigned int Curl_uint_tbl_capacity(struct uint_tbl *tbl); +uint32_t Curl_uint32_tbl_capacity(struct uint32_tbl *tbl); /* Get the number of entries in the table. */ -unsigned int Curl_uint_tbl_count(struct uint_tbl *tbl); +uint32_t Curl_uint32_tbl_count(struct uint32_tbl *tbl); /* Get the entry for key or NULL if not present */ -void *Curl_uint_tbl_get(struct uint_tbl *tbl, unsigned int key); +void *Curl_uint32_tbl_get(struct uint32_tbl *tbl, uint32_t key); /* Add a new entry to the table and assign it a free key. * Returns FALSE if the table is full. * * Keys are assigned in a round-robin manner. * No matter the capacity, UINT_MAX is never assigned. */ -bool Curl_uint_tbl_add(struct uint_tbl *tbl, void *entry, unsigned int *pkey); +bool Curl_uint32_tbl_add(struct uint32_tbl *tbl, void *entry, uint32_t *pkey); /* Remove the entry with `key`. */ -void Curl_uint_tbl_remove(struct uint_tbl *tbl, unsigned int key); +void Curl_uint32_tbl_remove(struct uint32_tbl *tbl, uint32_t key); /* Return TRUE if the table contains an tryn with that keys. */ -bool Curl_uint_tbl_contains(struct uint_tbl *tbl, unsigned int key); +bool Curl_uint32_tbl_contains(struct uint32_tbl *tbl, uint32_t key); /* Get the first entry in the table (with the smallest `key`). * Returns FALSE if the table is empty. */ -bool Curl_uint_tbl_first(struct uint_tbl *tbl, - unsigned int *pkey, void **pentry); +bool Curl_uint32_tbl_first(struct uint32_tbl *tbl, + uint32_t *pkey, void **pentry); /* Get the next key in the table, following `last_key` in natural order. * Put another way, this is the smallest key greater than `last_key` in @@ -92,7 +92,7 @@ bool Curl_uint_tbl_first(struct uint_tbl *tbl, * - added keys lower than 'last_key' will not show up. * - removed keys lower or equal to 'last_key' will not show up. * - removed keys higher than 'last_key' will not be visited. */ -bool Curl_uint_tbl_next(struct uint_tbl *tbl, unsigned int last_key, - unsigned int *pkey, void **pentry); +bool Curl_uint32_tbl_next(struct uint32_tbl *tbl, uint32_t last_key, + uint32_t *pkey, void **pentry); #endif /* HEADER_CURL_UINT_TABLE_H */ diff --git a/lib/url.c b/lib/url.c index d953734dce9b..8b3f7f5ab738 100644 --- a/lib/url.c +++ b/lib/url.c @@ -513,8 +513,8 @@ CURLcode Curl_open(struct Curl_easy **curl) data->state.recent_conn_id = -1; /* and not assigned an id yet */ data->id = -1; - data->mid = UINT_MAX; - data->master_mid = UINT_MAX; + data->mid = UINT32_MAX; + data->master_mid = UINT32_MAX; data->progress.hide = TRUE; data->state.current_speed = -1; /* init to negative == impossible */ @@ -575,7 +575,7 @@ void Curl_conn_free(struct Curl_easy *data, struct connectdata *conn) Curl_safefree(conn->unix_domain_socket); #endif Curl_safefree(conn->destination); - Curl_uint_spbset_destroy(&conn->xfers_attached); + Curl_uint32_spbset_destroy(&conn->xfers_attached); Curl_hash_destroy(&conn->meta_hash); free(conn); /* free all the connection oriented data */ @@ -1407,7 +1407,7 @@ static struct connectdata *allocate_conn(struct Curl_easy *data) conn->transport_wanted = TRNSPRT_TCP; /* most of them are TCP streams */ /* Initialize the attached xfers bitset */ - Curl_uint_spbset_init(&conn->xfers_attached); + Curl_uint32_spbset_init(&conn->xfers_attached); /* Store the local bind parameters that will be used for this connection */ if(data->set.str[STRING_DEVICE]) { @@ -3685,7 +3685,7 @@ static CURLcode create_conn(struct Curl_easy *data, connections_available = FALSE; break; case CPOOL_LIMIT_TOTAL: - if(data->master_mid != UINT_MAX) + if(data->master_mid != UINT32_MAX) CURL_TRC_M(data, "Allowing sub-requests (like DoH) to override " "max connection limit"); else { diff --git a/lib/urldata.h b/lib/urldata.h index e4fc49753fd4..c71607ea7d2b 100644 --- a/lib/urldata.h +++ b/lib/urldata.h @@ -610,8 +610,8 @@ struct connectdata { handle is still used by one or more easy handles and can only used by any other easy handle without careful consideration (== only for multiplexing) and it cannot be used by another multi handle! */ -#define CONN_INUSE(c) (!Curl_uint_spbset_empty(&(c)->xfers_attached)) -#define CONN_ATTACHED(c) Curl_uint_spbset_count(&(c)->xfers_attached) +#define CONN_INUSE(c) (!Curl_uint32_spbset_empty(&(c)->xfers_attached)) +#define CONN_ATTACHED(c) Curl_uint32_spbset_count(&(c)->xfers_attached) /**** Fields set when inited and not modified again */ curl_off_t connection_id; /* Contains a unique number to make it easier to @@ -671,7 +671,7 @@ struct connectdata { was used on this connection. */ struct curltime keepalive; - struct uint_spbset xfers_attached; /* mids of attached transfers */ + struct uint32_spbset xfers_attached; /* mids of attached transfers */ /* A connection cache from a SHARE might be used in several multi handles. * We MUST not reuse connections that are running in another multi, * for concurrency reasons. That multi might run in another thread. @@ -1631,8 +1631,8 @@ struct Curl_easy { /* once an easy handle is added to a multi, either explicitly by the * libcurl application or implicitly during `curl_easy_perform()`, * a unique identifier inside this one multi instance. */ - unsigned int mid; - unsigned int master_mid; /* if set, this transfer belongs to a master */ + uint32_t mid; + uint32_t master_mid; /* if set, this transfer belongs to a master */ multi_sub_xfer_done_cb *sub_xfer_done; struct connectdata *conn; diff --git a/lib/vquic/curl_ngtcp2.c b/lib/vquic/curl_ngtcp2.c index d6439287846e..ad1f2b2b25c8 100644 --- a/lib/vquic/curl_ngtcp2.c +++ b/lib/vquic/curl_ngtcp2.c @@ -168,7 +168,7 @@ static void cf_ngtcp2_ctx_init(struct cf_ngtcp2_ctx *ctx) Curl_bufcp_init(&ctx->stream_bufcp, H3_STREAM_CHUNK_SIZE, H3_STREAM_POOL_SPARES); curlx_dyn_init(&ctx->scratch, CURL_MAX_HTTP_HEADER); - Curl_uint_hash_init(&ctx->streams, 63, h3_stream_hash_free); + Curl_uint32_hash_init(&ctx->streams, 63, h3_stream_hash_free); ctx->initialized = TRUE; } @@ -179,7 +179,7 @@ static void cf_ngtcp2_ctx_free(struct cf_ngtcp2_ctx *ctx) vquic_ctx_free(&ctx->q); Curl_bufcp_free(&ctx->stream_bufcp); curlx_dyn_free(&ctx->scratch); - Curl_uint_hash_destroy(&ctx->streams); + Curl_uint32_hash_destroy(&ctx->streams); Curl_ssl_peer_cleanup(&ctx->peer); } free(ctx); @@ -207,7 +207,7 @@ static void cf_ngtcp2_setup_keep_alive(struct Curl_cfilter *cf, ngtcp2_conn_set_keep_alive_timeout(ctx->qconn, UINT64_MAX); CURL_TRC_CF(data, cf, "no peer idle timeout, unset keep-alive"); } - else if(!Curl_uint_hash_count(&ctx->streams)) { + else if(!Curl_uint32_hash_count(&ctx->streams)) { ngtcp2_conn_set_keep_alive_timeout(ctx->qconn, UINT64_MAX); CURL_TRC_CF(data, cf, "no active streams, unset keep-alive"); } @@ -288,12 +288,12 @@ static CURLcode h3_data_setup(struct Curl_cfilter *cf, stream->sendbuf_len_in_flight = 0; Curl_h1_req_parse_init(&stream->h1, H1_PARSE_DEFAULT_MAX_LINE_LEN); - if(!Curl_uint_hash_set(&ctx->streams, data->mid, stream)) { + if(!Curl_uint32_hash_set(&ctx->streams, data->mid, stream)) { h3_stream_ctx_free(stream); return CURLE_OUT_OF_MEMORY; } - if(Curl_uint_hash_count(&ctx->streams) == 1) + if(Curl_uint32_hash_count(&ctx->streams) == 1) cf_ngtcp2_setup_keep_alive(cf, data); return CURLE_OK; @@ -303,10 +303,10 @@ static CURLcode h3_data_setup(struct Curl_cfilter *cf, struct cf_ngtcp2_sfind_ctx { int64_t stream_id; struct h3_stream_ctx *stream; - unsigned int mid; + uint32_t mid; }; -static bool cf_ngtcp2_sfind(unsigned int mid, void *value, void *user_data) +static bool cf_ngtcp2_sfind(uint32_t mid, void *value, void *user_data) { struct cf_ngtcp2_sfind_ctx *fctx = user_data; struct h3_stream_ctx *stream = value; @@ -325,7 +325,7 @@ cf_ngtcp2_get_stream(struct cf_ngtcp2_ctx *ctx, int64_t stream_id) struct cf_ngtcp2_sfind_ctx fctx; fctx.stream_id = stream_id; fctx.stream = NULL; - Curl_uint_hash_visit(&ctx->streams, cf_ngtcp2_sfind, &fctx); + Curl_uint32_hash_visit(&ctx->streams, cf_ngtcp2_sfind, &fctx); return fctx.stream; } #else @@ -374,8 +374,8 @@ static void h3_data_done(struct Curl_cfilter *cf, struct Curl_easy *data) CURL_TRC_CF(data, cf, "[%" PRId64 "] easy handle is done", stream->id); cf_ngtcp2_stream_close(cf, data, stream); - Curl_uint_hash_remove(&ctx->streams, data->mid); - if(!Curl_uint_hash_count(&ctx->streams)) + Curl_uint32_hash_remove(&ctx->streams, data->mid); + if(!Curl_uint32_hash_count(&ctx->streams)) cf_ngtcp2_setup_keep_alive(cf, data); } } diff --git a/lib/vquic/curl_osslq.c b/lib/vquic/curl_osslq.c index 9d0193d55440..ade94bf40aa7 100644 --- a/lib/vquic/curl_osslq.c +++ b/lib/vquic/curl_osslq.c @@ -305,7 +305,7 @@ static void cf_osslq_ctx_init(struct cf_osslq_ctx *ctx) DEBUGASSERT(!ctx->initialized); Curl_bufcp_init(&ctx->stream_bufcp, H3_STREAM_CHUNK_SIZE, H3_STREAM_POOL_SPARES); - Curl_uint_hash_init(&ctx->streams, 63, h3_stream_hash_free); + Curl_uint32_hash_init(&ctx->streams, 63, h3_stream_hash_free); ctx->poll_items = NULL; ctx->curl_items = NULL; ctx->items_max = 0; @@ -316,7 +316,7 @@ static void cf_osslq_ctx_free(struct cf_osslq_ctx *ctx) { if(ctx && ctx->initialized) { Curl_bufcp_free(&ctx->stream_bufcp); - Curl_uint_hash_destroy(&ctx->streams); + Curl_uint32_hash_destroy(&ctx->streams); Curl_ssl_peer_cleanup(&ctx->peer); free(ctx->poll_items); free(ctx->curl_items); @@ -634,7 +634,7 @@ static CURLcode h3_data_setup(struct Curl_cfilter *cf, stream->recv_buf_nonflow = 0; Curl_h1_req_parse_init(&stream->h1, H1_PARSE_DEFAULT_MAX_LINE_LEN); - if(!Curl_uint_hash_set(&ctx->streams, data->mid, stream)) { + if(!Curl_uint32_hash_set(&ctx->streams, data->mid, stream)) { h3_stream_ctx_free(stream); return CURLE_OUT_OF_MEMORY; } @@ -659,7 +659,7 @@ static void h3_data_done(struct Curl_cfilter *cf, struct Curl_easy *data) stream->closed = TRUE; } - Curl_uint_hash_remove(&ctx->streams, data->mid); + Curl_uint32_hash_remove(&ctx->streams, data->mid); } } @@ -668,7 +668,7 @@ struct cf_ossq_find_ctx { struct h3_stream_ctx *stream; }; -static bool cf_osslq_find_stream(unsigned int mid, void *val, void *user_data) +static bool cf_osslq_find_stream(uint32_t mid, void *val, void *user_data) { struct h3_stream_ctx *stream = val; struct cf_ossq_find_ctx *fctx = user_data; @@ -704,7 +704,7 @@ static struct cf_osslq_stream *cf_osslq_get_qstream(struct Curl_cfilter *cf, struct cf_ossq_find_ctx fctx; fctx.stream_id = stream_id; fctx.stream = NULL; - Curl_uint_hash_visit(&ctx->streams, cf_osslq_find_stream, &fctx); + Curl_uint32_hash_visit(&ctx->streams, cf_osslq_find_stream, &fctx); if(fctx.stream) return &fctx.stream->s; } @@ -1392,7 +1392,7 @@ struct cf_ossq_recv_ctx { CURLcode result; }; -static bool cf_osslq_iter_recv(unsigned int mid, void *val, void *user_data) +static bool cf_osslq_iter_recv(uint32_t mid, void *val, void *user_data) { struct h3_stream_ctx *stream = val; struct cf_ossq_recv_ctx *rctx = user_data; @@ -1455,7 +1455,7 @@ static CURLcode cf_progress_ingress(struct Curl_cfilter *cf, rctx.cf = cf; rctx.multi = data->multi; rctx.result = CURLE_OK; - Curl_uint_hash_visit(&ctx->streams, cf_osslq_iter_recv, &rctx); + Curl_uint32_hash_visit(&ctx->streams, cf_osslq_iter_recv, &rctx); result = rctx.result; } @@ -1470,7 +1470,7 @@ struct cf_ossq_fill_ctx { size_t n; }; -static bool cf_osslq_collect_block_send(unsigned int mid, void *val, +static bool cf_osslq_collect_block_send(uint32_t mid, void *val, void *user_data) { struct h3_stream_ctx *stream = val; @@ -1508,8 +1508,8 @@ static CURLcode cf_osslq_check_and_unblock(struct Curl_cfilter *cf, if(ctx->h3.conn) { struct cf_ossq_fill_ctx fill_ctx; - if(ctx->items_max < Curl_uint_hash_count(&ctx->streams)) { - size_t nmax = Curl_uint_hash_count(&ctx->streams); + if(ctx->items_max < Curl_uint32_hash_count(&ctx->streams)) { + size_t nmax = Curl_uint32_hash_count(&ctx->streams); ctx->items_max = 0; tmpptr = realloc(ctx->poll_items, nmax * sizeof(SSL_POLL_ITEM)); if(!tmpptr) { @@ -1534,7 +1534,7 @@ static CURLcode cf_osslq_check_and_unblock(struct Curl_cfilter *cf, fill_ctx.ctx = ctx; fill_ctx.multi = data->multi; fill_ctx.n = 0; - Curl_uint_hash_visit(&ctx->streams, cf_osslq_collect_block_send, + Curl_uint32_hash_visit(&ctx->streams, cf_osslq_collect_block_send, &fill_ctx); poll_count = fill_ctx.n; if(poll_count) { diff --git a/lib/vquic/curl_quiche.c b/lib/vquic/curl_quiche.c index 51cadd2e6ead..5082dc750bb5 100644 --- a/lib/vquic/curl_quiche.c +++ b/lib/vquic/curl_quiche.c @@ -125,7 +125,7 @@ static void cf_quiche_ctx_init(struct cf_quiche_ctx *ctx) #endif Curl_bufcp_init(&ctx->stream_bufcp, H3_STREAM_CHUNK_SIZE, H3_STREAM_POOL_SPARES); - Curl_uint_hash_init(&ctx->streams, 63, h3_stream_hash_free); + Curl_uint32_hash_init(&ctx->streams, 63, h3_stream_hash_free); ctx->data_recvd = 0; ctx->initialized = TRUE; } @@ -139,7 +139,7 @@ static void cf_quiche_ctx_free(struct cf_quiche_ctx *ctx) Curl_ssl_peer_cleanup(&ctx->peer); vquic_ctx_free(&ctx->q); Curl_bufcp_free(&ctx->stream_bufcp); - Curl_uint_hash_destroy(&ctx->streams); + Curl_uint32_hash_destroy(&ctx->streams); } free(ctx); } @@ -210,7 +210,7 @@ struct cf_quiche_visit_ctx { void *user_data; }; -static bool cf_quiche_stream_do(unsigned int mid, void *val, void *user_data) +static bool cf_quiche_stream_do(uint32_t mid, void *val, void *user_data) { struct cf_quiche_visit_ctx *vctx = user_data; struct h3_stream_ctx *stream = val; @@ -231,7 +231,7 @@ static void cf_quiche_for_all_streams(struct Curl_cfilter *cf, vctx.multi = multi; vctx.cb = do_cb; vctx.user_data = user_data; - Curl_uint_hash_visit(&ctx->streams, cf_quiche_stream_do, &vctx); + Curl_uint32_hash_visit(&ctx->streams, cf_quiche_stream_do, &vctx); } static bool cf_quiche_do_resume(struct Curl_cfilter *cf, @@ -278,7 +278,7 @@ static CURLcode h3_data_setup(struct Curl_cfilter *cf, H3_STREAM_RECV_CHUNKS, BUFQ_OPT_SOFT_LIMIT); Curl_h1_req_parse_init(&stream->h1, H1_PARSE_DEFAULT_MAX_LINE_LEN); - if(!Curl_uint_hash_set(&ctx->streams, data->mid, stream)) { + if(!Curl_uint32_hash_set(&ctx->streams, data->mid, stream)) { h3_stream_ctx_free(stream); return CURLE_OUT_OF_MEMORY; } @@ -308,7 +308,7 @@ static void h3_data_done(struct Curl_cfilter *cf, struct Curl_easy *data) if(result) CURL_TRC_CF(data, cf, "data_done, flush egress -> %d", result); } - Curl_uint_hash_remove(&ctx->streams, data->mid); + Curl_uint32_hash_remove(&ctx->streams, data->mid); } } @@ -558,7 +558,7 @@ struct cf_quich_disp_ctx { CURLcode result; }; -static bool cf_quiche_disp_event(unsigned int mid, void *val, void *user_data) +static bool cf_quiche_disp_event(uint32_t mid, void *val, void *user_data) { struct cf_quich_disp_ctx *dctx = user_data; struct h3_stream_ctx *stream = val; @@ -607,7 +607,7 @@ static CURLcode cf_poll_events(struct Curl_cfilter *cf, else { /* another transfer, do not return errors, as they are not for * the calling transfer */ - Curl_uint_hash_visit(&ctx->streams, cf_quiche_disp_event, &dctx); + Curl_uint32_hash_visit(&ctx->streams, cf_quiche_disp_event, &dctx); quiche_h3_event_free(ev); } } diff --git a/lib/vquic/vquic_int.h b/lib/vquic/vquic_int.h index 4e5959a4f803..ef92ab21b730 100644 --- a/lib/vquic/vquic_int.h +++ b/lib/vquic/vquic_int.h @@ -52,7 +52,7 @@ struct cf_quic_ctx { }; #define H3_STREAM_CTX(ctx,data) \ - (data ? Curl_uint_hash_get(&(ctx)->streams, (data)->mid) : NULL) + (data ? Curl_uint32_hash_get(&(ctx)->streams, (data)->mid) : NULL) CURLcode vquic_ctx_init(struct cf_quic_ctx *qctx); void vquic_ctx_free(struct cf_quic_ctx *qctx); diff --git a/tests/unit/unit1616.c b/tests/unit/unit1616.c index 7641cbeace94..5d1e6f247e76 100644 --- a/tests/unit/unit1616.c +++ b/tests/unit/unit1616.c @@ -36,13 +36,13 @@ static void t1616_mydtor(unsigned int id, void *elem) static CURLcode t1616_setup(struct uint_hash *hash) { - Curl_uint_hash_init(hash, 15, t1616_mydtor); + Curl_uint32_hash_init(hash, 15, t1616_mydtor); return CURLE_OK; } static void t1616_stop(struct uint_hash *hash) { - Curl_uint_hash_destroy(hash); + Curl_uint32_hash_destroy(hash); } static CURLcode test_unit1616(const char *arg) @@ -61,27 +61,27 @@ static CURLcode test_unit1616(const char *arg) value = malloc(sizeof(int)); abort_unless(value != NULL, "Out of memory"); *value = 199; - ok = Curl_uint_hash_set(&hash, key, value); + ok = Curl_uint32_hash_set(&hash, key, value); if(!ok) free(value); abort_unless(ok, "insertion into hash failed"); - v = Curl_uint_hash_get(&hash, key); + v = Curl_uint32_hash_get(&hash, key); abort_unless(v == value, "lookup present entry failed"); - v = Curl_uint_hash_get(&hash, key2); + v = Curl_uint32_hash_get(&hash, key2); abort_unless(!v, "lookup missing entry failed"); - Curl_uint_hash_clear(&hash); + Curl_uint32_hash_clear(&hash); /* Attempt to add another key/value pair */ value2 = malloc(sizeof(int)); abort_unless(value2 != NULL, "Out of memory"); *value2 = 204; - ok = Curl_uint_hash_set(&hash, key2, value2); + ok = Curl_uint32_hash_set(&hash, key2, value2); if(!ok) free(value2); abort_unless(ok, "insertion into hash failed"); - v = Curl_uint_hash_get(&hash, key2); + v = Curl_uint32_hash_get(&hash, key2); abort_unless(v == value2, "lookup present entry failed"); - v = Curl_uint_hash_get(&hash, key); + v = Curl_uint32_hash_get(&hash, key); abort_unless(!v, "lookup missing entry failed"); UNITTEST_END(t1616_stop(&hash)) diff --git a/tests/unit/unit3211.c b/tests/unit/unit3211.c index c2fac4bbc52c..1ec30ac9a2af 100644 --- a/tests/unit/unit3211.c +++ b/tests/unit/unit3211.c @@ -30,36 +30,38 @@ static void check_set(const char *name, unsigned int capacity, const unsigned int *s, size_t slen) { - struct uint_bset bset; + struct uint32_bset bset; size_t i, j; unsigned int n, c; curl_mfprintf(stderr, "test %s, capacity=%u, %zu numbers\n", name, capacity, slen); - Curl_uint_bset_init(&bset); - fail_unless(!Curl_uint_bset_resize(&bset, capacity), "bset resize failed"); - c = Curl_uint_bset_capacity(&bset); + Curl_uint32_bset_init(&bset); + fail_unless(!Curl_uint32_bset_resize(&bset, capacity), "bset resize failed"); + c = Curl_uint32_bset_capacity(&bset); fail_unless(c == (((capacity + 63) / 64) * 64), "wrong capacity"); - Curl_uint_bset_clear(&bset); - c = Curl_uint_bset_count(&bset); + Curl_uint32_bset_clear(&bset); + c = Curl_uint32_bset_count(&bset); fail_unless(c == 0, "set count is not 0"); for(i = 0; i < slen; ++i) { /* add all */ - fail_unless(Curl_uint_bset_add(&bset, s[i]), "failed to add"); + fail_unless(Curl_uint32_bset_add(&bset, s[i]), "failed to add"); for(j = i + 1; j < slen; ++j) - fail_unless(!Curl_uint_bset_contains(&bset, s[j]), "unexpectedly found"); + fail_unless(!Curl_uint32_bset_contains(&bset, s[j]), + "unexpectedly found"); } for(i = 0; i < slen; ++i) { /* all present */ - fail_unless(Curl_uint_bset_contains(&bset, s[i]), "failed presence check"); + fail_unless(Curl_uint32_bset_contains(&bset, s[i]), + "failed presence check"); } /* iterator over all numbers */ - fail_unless(Curl_uint_bset_first(&bset, &n), "first failed"); + fail_unless(Curl_uint32_bset_first(&bset, &n), "first failed"); fail_unless(n == s[0], "first not correct number"); for(i = 1; i < slen; ++i) { - fail_unless(Curl_uint_bset_next(&bset, n, &n), "next failed"); + fail_unless(Curl_uint32_bset_next(&bset, n, &n), "next failed"); if(n != s[i]) { curl_mfprintf(stderr, "expected next to be %u, not %u\n", s[i], n); fail_unless(n == s[i], "next not correct number"); @@ -67,57 +69,58 @@ static void check_set(const char *name, unsigned int capacity, } /* Adding capacity number does not work (0 - capacity-1) */ - c = Curl_uint_bset_capacity(&bset); - fail_unless(!Curl_uint_bset_add(&bset, c), "add out of range worked"); + c = Curl_uint32_bset_capacity(&bset); + fail_unless(!Curl_uint32_bset_add(&bset, c), "add out of range worked"); /* The count it correct */ - c = Curl_uint_bset_count(&bset); + c = Curl_uint32_bset_count(&bset); fail_unless(c == slen, "set count is wrong"); for(i = 0; i < slen; i += 2) { /* remove every 2nd */ - Curl_uint_bset_remove(&bset, s[i]); - fail_unless(!Curl_uint_bset_contains(&bset, s[i]), "unexpectedly found"); + Curl_uint32_bset_remove(&bset, s[i]); + fail_unless(!Curl_uint32_bset_contains(&bset, s[i]), "unexpectedly found"); } for(i = 1; i < slen; i += 2) { /* others still there */ - fail_unless(Curl_uint_bset_contains(&bset, s[i]), "unexpectedly gone"); + fail_unless(Curl_uint32_bset_contains(&bset, s[i]), "unexpectedly gone"); } /* The count is half */ - c = Curl_uint_bset_count(&bset); + c = Curl_uint32_bset_count(&bset); fail_unless(c == slen/2, "set count is wrong"); - Curl_uint_bset_clear(&bset); - c = Curl_uint_bset_count(&bset); + Curl_uint32_bset_clear(&bset); + c = Curl_uint32_bset_count(&bset); fail_unless(c == 0, "set count is not 0"); for(i = 0; i < slen; i++) { /* none present any longer */ - fail_unless(!Curl_uint_bset_contains(&bset, s[i]), "unexpectedly there"); + fail_unless(!Curl_uint32_bset_contains(&bset, s[i]), "unexpectedly there"); } for(i = 0; i < slen; ++i) { /* add all again */ - fail_unless(Curl_uint_bset_add(&bset, s[i]), "failed to add"); + fail_unless(Curl_uint32_bset_add(&bset, s[i]), "failed to add"); } - fail_unless(!Curl_uint_bset_resize(&bset, capacity * 2), + fail_unless(!Curl_uint32_bset_resize(&bset, capacity * 2), "resize double failed"); for(i = 0; i < slen; i++) { /* all still present after resize */ - fail_unless(Curl_uint_bset_contains(&bset, s[i]), "unexpectedly lost"); + fail_unless(Curl_uint32_bset_contains(&bset, s[i]), "unexpectedly lost"); } - fail_unless(!Curl_uint_bset_resize(&bset, capacity), "resize back failed"); + fail_unless(!Curl_uint32_bset_resize(&bset, capacity), "resize back failed"); for(i = 0; i < slen; i++) /* all still present after resize back */ - fail_unless(Curl_uint_bset_contains(&bset, s[i]), "unexpectedly lost"); + fail_unless(Curl_uint32_bset_contains(&bset, s[i]), "unexpectedly lost"); - fail_unless(!Curl_uint_bset_resize(&bset, capacity/2), "resize half failed"); + fail_unless(!Curl_uint32_bset_resize(&bset, capacity/2), + "resize half failed"); /* halved the size, what numbers remain in set? */ - c = Curl_uint_bset_capacity(&bset); + c = Curl_uint32_bset_capacity(&bset); n = 0; for(i = 0; i < slen; ++i) { if(s[i] < c) ++n; } - fail_unless(n == Curl_uint_bset_count(&bset), "set count(halved) wrong"); + fail_unless(n == Curl_uint32_bset_count(&bset), "set count(halved) wrong"); for(i = 0; i < n; i++) /* still present after resize half */ - fail_unless(Curl_uint_bset_contains(&bset, s[i]), "unexpectedly lost"); + fail_unless(Curl_uint32_bset_contains(&bset, s[i]), "unexpectedly lost"); - Curl_uint_bset_destroy(&bset); + Curl_uint32_bset_destroy(&bset); } static CURLcode test_unit3211(const char *arg) diff --git a/tests/unit/unit3212.c b/tests/unit/unit3212.c index 261d294528fe..0bffd1f79ce3 100644 --- a/tests/unit/unit3212.c +++ b/tests/unit/unit3212.c @@ -30,20 +30,20 @@ #define TBL_SIZE 100 -static CURLcode t3212_setup(struct uint_tbl *tbl) +static CURLcode t3212_setup(struct uint32_tbl *tbl) { - Curl_uint_tbl_init(tbl, NULL); - return Curl_uint_tbl_resize(tbl, TBL_SIZE); + Curl_uint32_tbl_init(tbl, NULL); + return Curl_uint32_tbl_resize(tbl, TBL_SIZE); } -static void t3212_stop(struct uint_tbl *tbl) +static void t3212_stop(struct uint32_tbl *tbl) { - Curl_uint_tbl_destroy(tbl); + Curl_uint32_tbl_destroy(tbl); } static CURLcode test_unit3212(const char *arg) { - struct uint_tbl tbl; + struct uint32_tbl tbl; int dummy; UNITTEST_BEGIN(t3212_setup(&tbl)) @@ -51,83 +51,85 @@ static CURLcode test_unit3212(const char *arg) unsigned int i, key, n; void *entry; - fail_unless(Curl_uint_tbl_capacity(&tbl) == TBL_SIZE, "wrong capacity"); + fail_unless(Curl_uint32_tbl_capacity(&tbl) == TBL_SIZE, "wrong capacity"); for(i = 0; i < TBL_SIZE; ++i) { - fail_unless(Curl_uint_tbl_add(&tbl, &dummy, &key), "failed to add"); + fail_unless(Curl_uint32_tbl_add(&tbl, &dummy, &key), "failed to add"); fail_unless(key == i, "unexpected key assigned"); } /* table should be full now */ - fail_unless(Curl_uint_tbl_count(&tbl) == TBL_SIZE, "wrong count"); - fail_unless(!Curl_uint_tbl_add(&tbl, &dummy, &key), "could add more"); + fail_unless(Curl_uint32_tbl_count(&tbl) == TBL_SIZE, "wrong count"); + fail_unless(!Curl_uint32_tbl_add(&tbl, &dummy, &key), "could add more"); /* remove every 2nd entry, from full table */ n = TBL_SIZE; for(i = 0; i < TBL_SIZE; i += 2) { - Curl_uint_tbl_remove(&tbl, i); + Curl_uint32_tbl_remove(&tbl, i); --n; - fail_unless(Curl_uint_tbl_count(&tbl) == n, "wrong count after remove"); + fail_unless(Curl_uint32_tbl_count(&tbl) == n, "wrong count after remove"); } /* remove same again, should not change count */ for(i = 0; i < TBL_SIZE; i += 2) { - Curl_uint_tbl_remove(&tbl, i); - fail_unless(Curl_uint_tbl_count(&tbl) == n, "wrong count after remove"); + Curl_uint32_tbl_remove(&tbl, i); + fail_unless(Curl_uint32_tbl_count(&tbl) == n, "wrong count after remove"); } /* still contains all odd entries */ for(i = 1; i < TBL_SIZE; i += 2) { - fail_unless(Curl_uint_tbl_contains(&tbl, i), "does not contain"); - fail_unless(Curl_uint_tbl_get(&tbl, i) == &dummy, + fail_unless(Curl_uint32_tbl_contains(&tbl, i), "does not contain"); + fail_unless(Curl_uint32_tbl_get(&tbl, i) == &dummy, "does not contain dummy"); } /* get the first key */ - fail_unless(Curl_uint_tbl_first(&tbl, &key, &entry), "first failed"); + fail_unless(Curl_uint32_tbl_first(&tbl, &key, &entry), "first failed"); fail_unless(key == 1, "unexpected first key"); fail_unless(entry == &dummy, "unexpected first entry"); /* get the second key */ - fail_unless(Curl_uint_tbl_next(&tbl, 1, &key, &entry), "next1 failed"); + fail_unless(Curl_uint32_tbl_next(&tbl, 1, &key, &entry), "next1 failed"); fail_unless(key == 3, "unexpected second key"); fail_unless(entry == &dummy, "unexpected second entry"); /* get the key after 42 */ - fail_unless(Curl_uint_tbl_next(&tbl, 42, &key, &entry), "next42 failed"); + fail_unless(Curl_uint32_tbl_next(&tbl, 42, &key, &entry), "next42 failed"); fail_unless(key == 43, "unexpected next42 key"); fail_unless(entry == &dummy, "unexpected next42 entry"); /* double capacity */ - n = Curl_uint_tbl_count(&tbl); - fail_unless(!Curl_uint_tbl_resize(&tbl, TBL_SIZE * 2), + n = Curl_uint32_tbl_count(&tbl); + fail_unless(!Curl_uint32_tbl_resize(&tbl, TBL_SIZE * 2), "error doubling size"); - fail_unless(Curl_uint_tbl_count(&tbl) == n, "wrong resize count"); + fail_unless(Curl_uint32_tbl_count(&tbl) == n, "wrong resize count"); /* resize to half of original */ - fail_unless(!Curl_uint_tbl_resize(&tbl, TBL_SIZE / 2), "error halving size"); - fail_unless(Curl_uint_tbl_count(&tbl) == n / 2, "wrong half size count"); + fail_unless(!Curl_uint32_tbl_resize(&tbl, TBL_SIZE / 2), + "error halving size"); + fail_unless(Curl_uint32_tbl_count(&tbl) == n / 2, "wrong half size count"); for(i = 1; i < TBL_SIZE / 2; i += 2) { - fail_unless(Curl_uint_tbl_contains(&tbl, i), "does not contain"); - fail_unless(Curl_uint_tbl_get(&tbl, i) == &dummy, + fail_unless(Curl_uint32_tbl_contains(&tbl, i), "does not contain"); + fail_unless(Curl_uint32_tbl_get(&tbl, i) == &dummy, "does not contain dummy"); } /* clear */ - Curl_uint_tbl_clear(&tbl); - fail_unless(!Curl_uint_tbl_count(&tbl), "count not 0 after clear"); + Curl_uint32_tbl_clear(&tbl); + fail_unless(!Curl_uint32_tbl_count(&tbl), "count not 0 after clear"); for(i = 0; i < TBL_SIZE / 2; ++i) { - fail_unless(!Curl_uint_tbl_contains(&tbl, i), "does contain, should not"); + fail_unless(!Curl_uint32_tbl_contains(&tbl, i), + "does contain, should not"); } /* add after clear gets key 0 again */ - fail_unless(Curl_uint_tbl_add(&tbl, &dummy, &key), "failed to add"); + fail_unless(Curl_uint32_tbl_add(&tbl, &dummy, &key), "failed to add"); fail_unless(key == 0, "unexpected key assigned"); /* remove it again and add, should get key 1 */ - Curl_uint_tbl_remove(&tbl, key); - fail_unless(Curl_uint_tbl_add(&tbl, &dummy, &key), "failed to add"); + Curl_uint32_tbl_remove(&tbl, key); + fail_unless(Curl_uint32_tbl_add(&tbl, &dummy, &key), "failed to add"); fail_unless(key == 1, "unexpected key assigned"); /* clear, fill, remove one, add, should get the removed key again */ - Curl_uint_tbl_clear(&tbl); - for(i = 0; i < Curl_uint_tbl_capacity(&tbl); ++i) - fail_unless(Curl_uint_tbl_add(&tbl, &dummy, &key), "failed to add"); - fail_unless(!Curl_uint_tbl_add(&tbl, &dummy, &key), "add on full"); - Curl_uint_tbl_remove(&tbl, 17); - fail_unless(Curl_uint_tbl_add(&tbl, &dummy, &key), "failed to add again"); + Curl_uint32_tbl_clear(&tbl); + for(i = 0; i < Curl_uint32_tbl_capacity(&tbl); ++i) + fail_unless(Curl_uint32_tbl_add(&tbl, &dummy, &key), "failed to add"); + fail_unless(!Curl_uint32_tbl_add(&tbl, &dummy, &key), "add on full"); + Curl_uint32_tbl_remove(&tbl, 17); + fail_unless(Curl_uint32_tbl_add(&tbl, &dummy, &key), "failed to add again"); fail_unless(key == 17, "unexpected key assigned"); /* and again, triggering key search wrap around */ - Curl_uint_tbl_remove(&tbl, 17); - fail_unless(Curl_uint_tbl_add(&tbl, &dummy, &key), "failed to add again"); + Curl_uint32_tbl_remove(&tbl, 17); + fail_unless(Curl_uint32_tbl_add(&tbl, &dummy, &key), "failed to add again"); fail_unless(key == 17, "unexpected key assigned"); UNITTEST_END(t3212_stop(&tbl)) diff --git a/tests/unit/unit3213.c b/tests/unit/unit3213.c index 850b275c86cf..b0d4d2ced557 100644 --- a/tests/unit/unit3213.c +++ b/tests/unit/unit3213.c @@ -30,35 +30,35 @@ static void check_spbset(const char *name, const unsigned int *s, size_t slen) { - struct uint_spbset bset; + struct uint32_spbset bset; size_t i, j; unsigned int n, c; curl_mfprintf(stderr, "test %s, %zu numbers\n", name, slen); - Curl_uint_spbset_init(&bset); + Curl_uint32_spbset_init(&bset); - Curl_uint_spbset_clear(&bset); - c = Curl_uint_spbset_count(&bset); + Curl_uint32_spbset_clear(&bset); + c = Curl_uint32_spbset_count(&bset); fail_unless(c == 0, "set count is not 0"); for(i = 0; i < slen; ++i) { /* add all */ - fail_unless(Curl_uint_spbset_add(&bset, s[i]), "failed to add"); + fail_unless(Curl_uint32_spbset_add(&bset, s[i]), "failed to add"); for(j = i + 1; j < slen; ++j) - fail_unless(!Curl_uint_spbset_contains(&bset, s[j]), + fail_unless(!Curl_uint32_spbset_contains(&bset, s[j]), "unexpectedly found"); } for(i = 0; i < slen; ++i) { /* all present */ - fail_unless(Curl_uint_spbset_contains(&bset, s[i]), + fail_unless(Curl_uint32_spbset_contains(&bset, s[i]), "failed presence check"); } /* iterator over all numbers */ - fail_unless(Curl_uint_spbset_first(&bset, &n), "first failed"); + fail_unless(Curl_uint32_spbset_first(&bset, &n), "first failed"); fail_unless(n == s[0], "first not correct number"); for(i = 1; i < slen; ++i) { - fail_unless(Curl_uint_spbset_next(&bset, n, &n), "next failed"); + fail_unless(Curl_uint32_spbset_next(&bset, n, &n), "next failed"); if(n != s[i]) { curl_mfprintf(stderr, "expected next to be %u, not %u\n", s[i], n); fail_unless(n == s[i], "next not correct number"); @@ -66,28 +66,30 @@ static void check_spbset(const char *name, const unsigned int *s, size_t slen) } for(i = 0; i < slen; i += 2) { /* remove every 2nd */ - Curl_uint_spbset_remove(&bset, s[i]); - fail_unless(!Curl_uint_spbset_contains(&bset, s[i]), "unexpectedly found"); + Curl_uint32_spbset_remove(&bset, s[i]); + fail_unless(!Curl_uint32_spbset_contains(&bset, s[i]), + "unexpectedly found"); } for(i = 1; i < slen; i += 2) { /* others still there */ - fail_unless(Curl_uint_spbset_contains(&bset, s[i]), "unexpectedly gone"); + fail_unless(Curl_uint32_spbset_contains(&bset, s[i]), "unexpectedly gone"); } /* The count is half */ - c = Curl_uint_spbset_count(&bset); + c = Curl_uint32_spbset_count(&bset); fail_unless(c == slen/2, "set count is wrong"); - Curl_uint_spbset_clear(&bset); - c = Curl_uint_spbset_count(&bset); + Curl_uint32_spbset_clear(&bset); + c = Curl_uint32_spbset_count(&bset); fail_unless(c == 0, "set count is not 0"); for(i = 0; i < slen; i++) { /* none present any longer */ - fail_unless(!Curl_uint_spbset_contains(&bset, s[i]), "unexpectedly there"); + fail_unless(!Curl_uint32_spbset_contains(&bset, s[i]), + "unexpectedly there"); } for(i = 0; i < slen; ++i) { /* add all again */ - fail_unless(Curl_uint_spbset_add(&bset, s[i]), "failed to add"); + fail_unless(Curl_uint32_spbset_add(&bset, s[i]), "failed to add"); } - Curl_uint_spbset_destroy(&bset); + Curl_uint32_spbset_destroy(&bset); } static CURLcode test_unit3213(const char *arg) From 31b1527c1d78d7d91c60abdd132f0d788ec95cfd Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 25 Nov 2025 23:03:33 +0100 Subject: [PATCH 066/415] hostip: only store negative response for CURLE_COULDNT_RESOLVE_HOST Follow-up from ce06fe77710525 This allows us to drop the 'keep_negative' variable completely. Closes #19701 --- lib/hostip.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/hostip.c b/lib/hostip.c index 4c1bb9236776..58a7712cf485 100644 --- a/lib/hostip.c +++ b/lib/hostip.c @@ -806,7 +806,6 @@ CURLcode Curl_resolv(struct Curl_easy *data, struct Curl_addrinfo *addr = NULL; bool respwait = FALSE; size_t hostname_len; - bool keep_negative = TRUE; /* cache a negative result */ CURLcode result = CURLE_COULDNT_RESOLVE_HOST; *entry = NULL; @@ -858,7 +857,6 @@ CURLcode Curl_resolv(struct Curl_easy *data, data->set.resolver_start_client); Curl_set_in_callback(data, FALSE); if(st) { - keep_negative = FALSE; result = CURLE_ABORTED_BY_CALLBACK; goto error; } @@ -928,7 +926,6 @@ CURLcode Curl_resolv(struct Curl_easy *data, if(dns) /* avoid a dangling pointer to addr in the dying dns entry */ dns->addr = NULL; - keep_negative = FALSE; result = CURLE_OUT_OF_MEMORY; goto error; } @@ -947,7 +944,7 @@ CURLcode Curl_resolv(struct Curl_easy *data, if(dns) Curl_resolv_unlink(data, &dns); Curl_async_shutdown(data); - if(keep_negative) + if(result == CURLE_COULDNT_RESOLVE_HOST) store_negative_resolve(data, hostname, port); DEBUGASSERT(result); return result; From 4041eea61edd8cf66c6f85c47a430bb5774f017c Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Tue, 25 Nov 2025 02:34:26 +0100 Subject: [PATCH 067/415] GHA/http3-linux: build nettle manually for GnuTLS 3.8.11+ GnuTLS 3.8.11 started requiring a nettle version new enough to be missing from Ubuntu LTS released a year ago. To keep up testing it, build nettle from source. Besides the necessary one time effort this has the downside that nettle updates now need to be done manually a couple of times per year when renovate detects one. (if I got the renovate formula correct to catch the tag format). Also: - switch the local GnuTLS build to use the release tarball instead of the Git repo and calling the script `bootstrap`. The script could potentially download source code using the cleartext `git:` protocol. It's also downloading lots of content, including a full OpenSSL repo. Ref: https://github.com/gnutls/gnutls/blob/955f7a7fc223642d1ede6d55f094961cb97bfa68/NEWS#L41-L44 Follow-up to 905b718de3fb9287c7c0037b2737aa395f01ad3c #19642 Follow-up to a439fc0e372c3de7df3b8ae3ca7752bc3cbca826 #19613 Closes #19680 --- .github/workflows/http3-linux.yml | 78 +++++++++++++++++++++++-------- 1 file changed, 58 insertions(+), 20 deletions(-) diff --git a/.github/workflows/http3-linux.yml b/.github/workflows/http3-linux.yml index 3f52c146563e..06e8e2e97507 100644 --- a/.github/workflows/http3-linux.yml +++ b/.github/workflows/http3-linux.yml @@ -46,8 +46,10 @@ env: AWSLC_VERSION: 1.63.0 # renovate: datasource=github-tags depName=google/boringssl versioning=semver registryUrl=https://github.com BORINGSSL_VERSION: 0.20251110.0 - # renovate: datasource=github-tags depName=gnutls/gnutls versioning=semver registryUrl=https://github.com - GNUTLS_VERSION: 3.8.10 + # renovate: datasource=github-tags depName=gnutls/nettle versioning=semver registryUrl=https://github.com + NETTLE_VERSION: 3.10.2 + # renovate: datasource=github-tags depName=gnutls/gnutls versioning=semver extractVersion=^nettle_?(?.+)_release_.+$ registryUrl=https://github.com + GNUTLS_VERSION: 3.8.11 # renovate: datasource=github-tags depName=wolfSSL/wolfssl versioning=semver extractVersion=^v?(?.+)-stable$ registryUrl=https://github.com WOLFSSL_VERSION: 5.8.4 # renovate: datasource=github-tags depName=ngtcp2/nghttp3 versioning=semver registryUrl=https://github.com @@ -101,6 +103,15 @@ jobs: path: ~/boringssl/build key: ${{ runner.os }}-http3-build-${{ env.cache-name }}-${{ env.BORINGSSL_VERSION }} + - name: 'cache nettle' + uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + id: cache-nettle + env: + cache-name: cache-nettle + with: + path: ~/nettle/build + key: ${{ runner.os }}-http3-build-${{ env.cache-name }}-${{ env.NETTLE_VERSION }} + - name: 'cache gnutls' uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 id: cache-gnutls @@ -108,7 +119,7 @@ jobs: cache-name: cache-gnutls with: path: ~/gnutls/build - key: ${{ runner.os }}-http3-build-${{ env.cache-name }}-${{ env.GNUTLS_VERSION }} + key: ${{ runner.os }}-http3-build-${{ env.cache-name }}-${{ env.GNUTLS_VERSION }}-${{ env.NETTLE_VERSION }} - name: 'cache wolfssl' uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 @@ -135,7 +146,7 @@ jobs: cache-name: cache-ngtcp2 with: path: ~/ngtcp2/build - key: ${{ runner.os }}-http3-build-${{ env.cache-name }}-${{ env.NGTCP2_VERSION }}-${{ env.OPENSSL_VERSION }}-${{ env.LIBRESSL_VERSION }}-${{ env.AWSLC_VERSION }}-${{ env.GNUTLS_VERSION }}-${{ env.WOLFSSL_VERSION }} + key: ${{ runner.os }}-http3-build-${{ env.cache-name }}-${{ env.NGTCP2_VERSION }}-${{ env.OPENSSL_VERSION }}-${{ env.LIBRESSL_VERSION }}-${{ env.AWSLC_VERSION }}-${{ env.NETTLE_VERSION }}-${{ env.GNUTLS_VERSION }}-${{ env.WOLFSSL_VERSION }} - name: 'cache ngtcp2 boringssl' uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 @@ -161,6 +172,7 @@ jobs: steps.cache-libressl.outputs.cache-hit != 'true' || steps.cache-awslc.outputs.cache-hit != 'true' || steps.cache-boringssl.outputs.cache-hit != 'true' || + steps.cache-nettle.outputs.cache-hit != 'true' || steps.cache-gnutls.outputs.cache-hit != 'true' || steps.cache-wolfssl.outputs.cache-hit != 'true' || steps.cache-nghttp3.outputs.cache-hit != 'true' || @@ -181,7 +193,7 @@ jobs: libbrotli-dev libzstd-dev zlib1g-dev \ libev-dev \ libc-ares-dev \ - nettle-dev libp11-kit-dev autopoint bison gperf gtk-doc-tools libtasn1-bin # for GnuTLS + libp11-kit-dev autopoint bison gperf gtk-doc-tools libtasn1-bin # for GnuTLS echo 'CC=gcc-12' >> "$GITHUB_ENV" echo 'CXX=g++-12' >> "$GITHUB_ENV" @@ -228,19 +240,30 @@ jobs: cmake --build . cmake --install . + - name: 'build nettle' + if: ${{ steps.cache-nettle.outputs.cache-hit != 'true' }} + run: | + cd ~ + curl --disable --fail --silent --show-error --connect-timeout 15 --max-time 120 --retry 6 --retry-connrefused \ + --location "https://ftpmirror.gnu.org/nettle/nettle-${NETTLE_VERSION}.tar.gz" | tar -xz + cd "nettle-${NETTLE_VERSION}" + ./configure --disable-dependency-tracking --prefix=/home/runner/nettle/build \ + --disable-silent-rules --disable-static --disable-openssl --disable-documentation + make install + - name: 'build gnutls' if: ${{ steps.cache-gnutls.outputs.cache-hit != 'true' }} run: | cd ~ - git clone --quiet --depth 1 -b "${GNUTLS_VERSION}" https://github.com/gnutls/gnutls - cd gnutls - # required: nettle-dev libp11-kit-dev libev-dev autopoint bison gperf gtk-doc-tools libtasn1-bin - ./bootstrap - ./configure --disable-dependency-tracking --prefix="$PWD"/build \ - LDFLAGS="-Wl,-rpath,$PWD/build/lib -L$PWD/build/lib" \ + curl --disable --fail --silent --show-error --connect-timeout 15 --max-time 120 --retry 6 --retry-connrefused \ + "https://www.gnupg.org/ftp/gcrypt/gnutls/v${GNUTLS_VERSION%.*}/gnutls-${GNUTLS_VERSION}.tar.xz" | tar -xJ + cd "gnutls-${GNUTLS_VERSION}" + # required: libp11-kit-dev libev-dev autopoint bison gperf gtk-doc-tools libtasn1-bin + ./configure --disable-dependency-tracking --prefix=/home/runner/gnutls/build \ + PKG_CONFIG_PATH=/home/runner/nettle/build/lib64/pkgconfig \ + LDFLAGS=-Wl,-rpath,/home/runner/nettle/build/lib64 \ --with-included-libtasn1 --with-included-unistring \ --disable-guile --disable-doc --disable-tests --disable-tools - make make install - name: 'build wolfssl' @@ -280,7 +303,7 @@ jobs: make install make clean ./configure --disable-dependency-tracking --prefix="$PWD"/build \ - PKG_CONFIG_PATH=/home/runner/openssl/build/lib/pkgconfig:/home/runner/gnutls/build/lib/pkgconfig:/home/runner/wolfssl/build/lib/pkgconfig \ + PKG_CONFIG_PATH=/home/runner/openssl/build/lib/pkgconfig:/home/runner/nettle/build/lib64/pkgconfig:/home/runner/gnutls/build/lib/pkgconfig:/home/runner/wolfssl/build/lib/pkgconfig \ --enable-lib-only --with-openssl --with-gnutls --with-wolfssl --with-boringssl \ BORINGSSL_LIBS='-L/home/runner/awslc/build/lib -lssl -lcrypto' \ BORINGSSL_CFLAGS='-I/home/runner/awslc/build/include' @@ -383,16 +406,18 @@ jobs: -DCMAKE_UNITY_BUILD=ON - name: 'gnutls' - install_packages: nettle-dev libp11-kit-dev + install_packages: libp11-kit-dev install_steps: skipall - PKG_CONFIG_PATH: /home/runner/gnutls/build/lib/pkgconfig:/home/runner/nghttp3/build/lib/pkgconfig:/home/runner/ngtcp2/build/lib/pkgconfig:/home/runner/nghttp2/build/lib/pkgconfig + PKG_CONFIG_PATH: /home/runner/nettle/build/lib64/pkgconfig:/home/runner/gnutls/build/lib/pkgconfig:/home/runner/nghttp3/build/lib/pkgconfig:/home/runner/ngtcp2/build/lib/pkgconfig:/home/runner/nghttp2/build/lib/pkgconfig + LDFLAGS: -Wl,-rpath,/home/runner/gnutls/build/lib -Wl,-rpath,/home/runner/nettle/build/lib64 -L/home/runner/nettle/build/lib64 -Wl,-rpath,/home/runner/ngtcp2/build/lib + CPPFLAGS: -I/home/runner/nettle/build/include configure: >- - LDFLAGS=-Wl,-rpath,/home/runner/gnutls/build/lib --with-gnutls=/home/runner/gnutls/build --with-ngtcp2 --enable-ssls-export - name: 'gnutls' - install_packages: nettle-dev libp11-kit-dev - PKG_CONFIG_PATH: /home/runner/gnutls/build/lib/pkgconfig:/home/runner/nghttp3/build/lib/pkgconfig:/home/runner/ngtcp2/build/lib/pkgconfig:/home/runner/nghttp2/build/lib/pkgconfig + install_packages: libp11-kit-dev + PKG_CONFIG_PATH: /home/runner/nettle/build/lib64/pkgconfig:/home/runner/gnutls/build/lib/pkgconfig:/home/runner/nghttp3/build/lib/pkgconfig:/home/runner/ngtcp2/build/lib/pkgconfig:/home/runner/nghttp2/build/lib/pkgconfig + LDFLAGS: -Wl,-rpath,/home/runner/gnutls/build/lib generate: >- -DCURL_USE_GNUTLS=ON -DUSE_NGTCP2=ON -DCMAKE_UNITY_BUILD=ON @@ -502,6 +527,17 @@ jobs: key: ${{ runner.os }}-http3-build-${{ env.cache-name }}-${{ env.BORINGSSL_VERSION }} fail-on-cache-miss: true + - name: 'cache nettle' + if: ${{ matrix.build.name == 'gnutls' }} + uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + id: cache-nettle + env: + cache-name: cache-nettle + with: + path: ~/nettle/build + key: ${{ runner.os }}-http3-build-${{ env.cache-name }}-${{ env.NETTLE_VERSION }} + fail-on-cache-miss: true + - name: 'cache gnutls' if: ${{ matrix.build.name == 'gnutls' }} uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 @@ -510,7 +546,7 @@ jobs: cache-name: cache-gnutls with: path: ~/gnutls/build - key: ${{ runner.os }}-http3-build-${{ env.cache-name }}-${{ env.GNUTLS_VERSION }} + key: ${{ runner.os }}-http3-build-${{ env.cache-name }}-${{ env.GNUTLS_VERSION }}-${{ env.NETTLE_VERSION }} fail-on-cache-miss: true - name: 'cache wolfssl' @@ -541,7 +577,7 @@ jobs: cache-name: cache-ngtcp2 with: path: ~/ngtcp2/build - key: ${{ runner.os }}-http3-build-${{ env.cache-name }}-${{ env.NGTCP2_VERSION }}-${{ env.OPENSSL_VERSION }}-${{ env.LIBRESSL_VERSION }}-${{ env.AWSLC_VERSION }}-${{ env.GNUTLS_VERSION }}-${{ env.WOLFSSL_VERSION }} + key: ${{ runner.os }}-http3-build-${{ env.cache-name }}-${{ env.NGTCP2_VERSION }}-${{ env.OPENSSL_VERSION }}-${{ env.LIBRESSL_VERSION }}-${{ env.AWSLC_VERSION }}-${{ env.NETTLE_VERSION }}-${{ env.GNUTLS_VERSION }}-${{ env.WOLFSSL_VERSION }} fail-on-cache-miss: true - name: 'cache ngtcp2 boringssl' @@ -604,6 +640,8 @@ jobs: - name: 'configure' env: + CPPFLAGS: '${{ matrix.build.CPPFLAGS }}' + LDFLAGS: '${{ matrix.build.LDFLAGS }}' MATRIX_CONFIGURE: '${{ matrix.build.configure }}' MATRIX_GENERATE: '${{ matrix.build.generate }}' MATRIX_PKG_CONFIG_PATH: '${{ matrix.build.PKG_CONFIG_PATH }}' From ea7df8d07671240536f6ab03eaee5ffb49ddc5f7 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 26 Nov 2025 00:47:04 +0100 Subject: [PATCH 068/415] docs: spell it Rustls with a capital R I believe this is how the project itself uses it. Closes #19702 --- docs/INSTALL.md | 2 +- docs/cmdline-opts/ca-native.md | 4 ++-- docs/cmdline-opts/tls-earlydata.md | 2 +- docs/libcurl/opts/CURLINFO_CERTINFO.md | 2 +- docs/libcurl/opts/CURLOPT_CAINFO_BLOB.md | 2 +- docs/libcurl/opts/CURLOPT_CERTINFO.md | 2 +- docs/libcurl/opts/CURLOPT_CRLFILE.md | 2 +- docs/libcurl/opts/CURLOPT_ECH.md | 4 ++-- docs/libcurl/opts/CURLOPT_PROXY_CAINFO_BLOB.md | 2 +- docs/libcurl/opts/CURLOPT_PROXY_SSL_CIPHER_LIST.md | 2 +- docs/libcurl/opts/CURLOPT_PROXY_TLS13_CIPHERS.md | 2 +- docs/libcurl/opts/CURLOPT_SSL_CIPHER_LIST.md | 2 +- docs/libcurl/opts/CURLOPT_SSL_OPTIONS.md | 4 ++-- docs/libcurl/opts/CURLOPT_TLS13_CIPHERS.md | 2 +- scripts/cd2nroff | 2 +- 15 files changed, 18 insertions(+), 18 deletions(-) diff --git a/docs/INSTALL.md b/docs/INSTALL.md index f3db34da280a..1859dc21ae7f 100644 --- a/docs/INSTALL.md +++ b/docs/INSTALL.md @@ -141,7 +141,7 @@ These options are provided to select the TLS backend to use. - GnuTLS: `--with-gnutls`. - mbedTLS: `--with-mbedtls` - OpenSSL: `--with-openssl` (also for BoringSSL, AWS-LC, LibreSSL, and quictls) - - rustls: `--with-rustls` + - Rustls: `--with-rustls` - Schannel: `--with-schannel` - wolfSSL: `--with-wolfssl` diff --git a/docs/cmdline-opts/ca-native.md b/docs/cmdline-opts/ca-native.md index a8e8c5e9a8ae..4a887df558a6 100644 --- a/docs/cmdline-opts/ca-native.md +++ b/docs/cmdline-opts/ca-native.md @@ -34,8 +34,8 @@ Fedora, RHEL), macOS, Android and iOS. (Added in 8.3.0) This option works with GnuTLS (Added in 8.5.0) and also uses Apple SecTrust when libcurl is built with it. (Added in 8.17.0) -This option works with rustls on Windows, macOS, Android and iOS. On Linux it -is equivalent to using the Mozilla CA certificate bundle. When used with rustls +This option works with Rustls on Windows, macOS, Android and iOS. On Linux it +is equivalent to using the Mozilla CA certificate bundle. When used with Rustls _only_ the native CA store is consulted, not other locations set at run time or build time. (Added in 8.13.0) diff --git a/docs/cmdline-opts/tls-earlydata.md b/docs/cmdline-opts/tls-earlydata.md index 642897798304..8e344758be5e 100644 --- a/docs/cmdline-opts/tls-earlydata.md +++ b/docs/cmdline-opts/tls-earlydata.md @@ -21,7 +21,7 @@ Enable the use of TLSv1.3 early data, also known as '0RTT' where possible. This has security implications for the requests sent that way. This option can be used when curl is built to use GnuTLS, wolfSSL, quictls and -OpenSSL as a TLS provider (but not BoringSSL, AWS-LC, or rustls). +OpenSSL as a TLS provider (but not BoringSSL, AWS-LC, or Rustls). If a server supports this TLSv1.3 feature, and to what extent, is announced as part of the TLS "session" sent back to curl. Until curl has seen such diff --git a/docs/libcurl/opts/CURLINFO_CERTINFO.md b/docs/libcurl/opts/CURLINFO_CERTINFO.md index f9fd0ad51c6d..d97c311cc8cd 100644 --- a/docs/libcurl/opts/CURLINFO_CERTINFO.md +++ b/docs/libcurl/opts/CURLINFO_CERTINFO.md @@ -14,7 +14,7 @@ TLS-backend: - OpenSSL - GnuTLS - Schannel - - rustls + - Rustls Added-in: 7.19.1 --- diff --git a/docs/libcurl/opts/CURLOPT_CAINFO_BLOB.md b/docs/libcurl/opts/CURLOPT_CAINFO_BLOB.md index 99bfaf11e673..eb0e24f36aff 100644 --- a/docs/libcurl/opts/CURLOPT_CAINFO_BLOB.md +++ b/docs/libcurl/opts/CURLOPT_CAINFO_BLOB.md @@ -15,7 +15,7 @@ TLS-backend: - OpenSSL - GnuTLS - mbedTLS - - rustls + - Rustls - wolfSSL - Schannel Added-in: 7.77.0 diff --git a/docs/libcurl/opts/CURLOPT_CERTINFO.md b/docs/libcurl/opts/CURLOPT_CERTINFO.md index 7c6641a9fd3e..baddc3079702 100644 --- a/docs/libcurl/opts/CURLOPT_CERTINFO.md +++ b/docs/libcurl/opts/CURLOPT_CERTINFO.md @@ -16,7 +16,7 @@ TLS-backend: - OpenSSL - GnuTLS - Schannel - - rustls + - Rustls Added-in: 7.19.1 --- diff --git a/docs/libcurl/opts/CURLOPT_CRLFILE.md b/docs/libcurl/opts/CURLOPT_CRLFILE.md index d5452db19bdc..0c4eca6c784f 100644 --- a/docs/libcurl/opts/CURLOPT_CRLFILE.md +++ b/docs/libcurl/opts/CURLOPT_CRLFILE.md @@ -14,7 +14,7 @@ TLS-backend: - GnuTLS - mbedTLS - OpenSSL - - rustls + - Rustls Added-in: 7.19.0 --- diff --git a/docs/libcurl/opts/CURLOPT_ECH.md b/docs/libcurl/opts/CURLOPT_ECH.md index 9ac65a73a05d..0cb2d7e4fd75 100644 --- a/docs/libcurl/opts/CURLOPT_ECH.md +++ b/docs/libcurl/opts/CURLOPT_ECH.md @@ -11,7 +11,7 @@ Protocol: TLS-backend: - OpenSSL - wolfSSL - - rustls + - Rustls Added-in: 8.8.0 --- @@ -33,7 +33,7 @@ ECH is only compatible with TLSv1.3. This experimental feature requires a special build of OpenSSL, as ECH is not yet supported in OpenSSL releases. In contrast ECH is supported by the latest -BoringSSL, wolfSSL and rustls-ffi releases. +BoringSSL, wolfSSL and Rustls-ffi releases. There is also a known issue with using wolfSSL which does not support ECH when the HelloRetryRequest mechanism is used. diff --git a/docs/libcurl/opts/CURLOPT_PROXY_CAINFO_BLOB.md b/docs/libcurl/opts/CURLOPT_PROXY_CAINFO_BLOB.md index a352886e061f..16af56e5cda6 100644 --- a/docs/libcurl/opts/CURLOPT_PROXY_CAINFO_BLOB.md +++ b/docs/libcurl/opts/CURLOPT_PROXY_CAINFO_BLOB.md @@ -18,7 +18,7 @@ Protocol: - TLS TLS-backend: - OpenSSL - - rustls + - Rustls - Schannel Added-in: 7.77.0 --- diff --git a/docs/libcurl/opts/CURLOPT_PROXY_SSL_CIPHER_LIST.md b/docs/libcurl/opts/CURLOPT_PROXY_SSL_CIPHER_LIST.md index 239ce03c73dd..718b2617491c 100644 --- a/docs/libcurl/opts/CURLOPT_PROXY_SSL_CIPHER_LIST.md +++ b/docs/libcurl/opts/CURLOPT_PROXY_SSL_CIPHER_LIST.md @@ -17,7 +17,7 @@ TLS-backend: - Schannel - wolfSSL - mbedTLS - - rustls + - Rustls Added-in: 7.52.0 --- diff --git a/docs/libcurl/opts/CURLOPT_PROXY_TLS13_CIPHERS.md b/docs/libcurl/opts/CURLOPT_PROXY_TLS13_CIPHERS.md index ee17d27e99c1..18b5516c5e65 100644 --- a/docs/libcurl/opts/CURLOPT_PROXY_TLS13_CIPHERS.md +++ b/docs/libcurl/opts/CURLOPT_PROXY_TLS13_CIPHERS.md @@ -16,7 +16,7 @@ TLS-backend: - OpenSSL - wolfSSL - mbedTLS - - rustls + - Rustls Added-in: 7.61.0 --- diff --git a/docs/libcurl/opts/CURLOPT_SSL_CIPHER_LIST.md b/docs/libcurl/opts/CURLOPT_SSL_CIPHER_LIST.md index c71a58d6850d..a177d5231722 100644 --- a/docs/libcurl/opts/CURLOPT_SSL_CIPHER_LIST.md +++ b/docs/libcurl/opts/CURLOPT_SSL_CIPHER_LIST.md @@ -17,7 +17,7 @@ TLS-backend: - Schannel - wolfSSL - mbedTLS - - rustls + - Rustls - GnuTLS Added-in: 7.9 --- diff --git a/docs/libcurl/opts/CURLOPT_SSL_OPTIONS.md b/docs/libcurl/opts/CURLOPT_SSL_OPTIONS.md index 79ced71ea76d..ddd7965ee2ef 100644 --- a/docs/libcurl/opts/CURLOPT_SSL_OPTIONS.md +++ b/docs/libcurl/opts/CURLOPT_SSL_OPTIONS.md @@ -79,8 +79,8 @@ Works with wolfSSL on Windows, Linux (Debian, Ubuntu, Gentoo, Fedora, RHEL), macOS, Android and iOS (added in 8.3.0); with GnuTLS (added in 8.5.0) and with OpenSSL and its forks (LibreSSL, BoringSSL, etc) on Windows (Added in 7.71.0). -This works with rustls on Windows, macOS, Android and iOS. On Linux it is -equivalent to using the Mozilla CA certificate bundle. When used with rustls +This works with Rustls on Windows, macOS, Android and iOS. On Linux it is +equivalent to using the Mozilla CA certificate bundle. When used with Rustls _only_ the native CA store is consulted, not other locations set at run time or build time. (Added in 8.13.0) diff --git a/docs/libcurl/opts/CURLOPT_TLS13_CIPHERS.md b/docs/libcurl/opts/CURLOPT_TLS13_CIPHERS.md index 62f734f9633b..41cdec07bc51 100644 --- a/docs/libcurl/opts/CURLOPT_TLS13_CIPHERS.md +++ b/docs/libcurl/opts/CURLOPT_TLS13_CIPHERS.md @@ -17,7 +17,7 @@ TLS-backend: - OpenSSL - wolfSSL - mbedTLS - - rustls + - Rustls Added-in: 7.61.0 --- diff --git a/scripts/cd2nroff b/scripts/cd2nroff index 3f1162a7396c..e97d1299ddbd 100755 --- a/scripts/cd2nroff +++ b/scripts/cd2nroff @@ -189,7 +189,7 @@ my %knowntls = ( 'GnuTLS' => 1, 'mbedTLS' => 1, 'OpenSSL' => 1, - 'rustls' => 1, + 'Rustls' => 1, 'Schannel' => 1, 'wolfSSL' => 1, 'All' => 1, From cb722b32ad163ecdf12b408f2ea86346fe83e199 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 26 Nov 2025 08:23:04 +0100 Subject: [PATCH 069/415] urlapi: handle OOM properly when setting URL Closes #19704 --- lib/urlapi.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/lib/urlapi.c b/lib/urlapi.c index a3d9efdb919f..9d3eb0f8cf0f 100644 --- a/lib/urlapi.c +++ b/lib/urlapi.c @@ -1687,22 +1687,31 @@ static CURLUcode set_url(CURLU *u, const char *url, size_t part_size, if(!part_size) { /* a blank URL is not a valid URL unless we already have a complete one and this is a redirect */ - if(!curl_url_get(u, CURLUPART_URL, &oldurl, flags)) { + uc = curl_url_get(u, CURLUPART_URL, &oldurl, flags); + if(!uc) { /* success, meaning the "" is a fine relative URL, but nothing changes */ free(oldurl); return CURLUE_OK; } + if(uc == CURLUE_OUT_OF_MEMORY) + return uc; return CURLUE_MALFORMED_INPUT; } - /* if the new thing is absolute or the old one is not (we could not get an - * absolute URL in 'oldurl'), then replace the existing with the new. */ + /* if the new URL is absolute replace the existing with the new. */ if(Curl_is_absolute_url(url, NULL, 0, - flags & (CURLU_GUESS_SCHEME|CURLU_DEFAULT_SCHEME)) - || curl_url_get(u, CURLUPART_URL, &oldurl, flags)) { + flags & (CURLU_GUESS_SCHEME|CURLU_DEFAULT_SCHEME))) return parseurl_and_replace(url, u, flags); - } + + /* if the old URL is incomplete (we cannot get an absolute URL in + 'oldurl'), replace the existing with the new */ + uc = curl_url_get(u, CURLUPART_URL, &oldurl, flags); + if(uc == CURLUE_OUT_OF_MEMORY) + return uc; + else if(uc) + return parseurl_and_replace(url, u, flags); + DEBUGASSERT(oldurl); /* it is set here */ /* apply the relative part to create a new URL */ uc = redirect_url(oldurl, url, u, flags); From 0d2bb9c7c6d6ccdc48bb0414b80204acbd29f923 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 26 Nov 2025 11:01:09 +0100 Subject: [PATCH 070/415] http: fix OOM exit in Curl_http_follow Spotted by "strict torture" tests. Closes #19705 --- lib/http.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/http.c b/lib/http.c index ae932cd7c93a..144a898ea0eb 100644 --- a/lib/http.c +++ b/lib/http.c @@ -1282,7 +1282,7 @@ CURLcode Curl_http_follow(struct Curl_easy *data, const char *newurl, CURLU_ALLOW_SPACE | (data->set.path_as_is ? CURLU_PATH_AS_IS : 0))); if(uc) { - if(type != FOLLOW_FAKE) { + if((uc == CURLUE_OUT_OF_MEMORY) || (type != FOLLOW_FAKE)) { failf(data, "The redirect target URL could not be parsed: %s", curl_url_strerror(uc)); return Curl_uc_to_curlcode(uc); From 2acdc4f549ac4aee691ed5782b32a1c5c9f86dbe Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Wed, 26 Nov 2025 02:03:29 +0100 Subject: [PATCH 071/415] autotools: add nettle library detection via pkg-config (for GnuTLS) Also: - fix to restore full state when gnutls canary function is not found. - fix indentation. Closes #19703 --- .github/workflows/http3-linux.yml | 4 +- m4/curl-gnutls.m4 | 73 ++++++++++++++++++++++++++----- 2 files changed, 62 insertions(+), 15 deletions(-) diff --git a/.github/workflows/http3-linux.yml b/.github/workflows/http3-linux.yml index 06e8e2e97507..87738dd79138 100644 --- a/.github/workflows/http3-linux.yml +++ b/.github/workflows/http3-linux.yml @@ -409,8 +409,7 @@ jobs: install_packages: libp11-kit-dev install_steps: skipall PKG_CONFIG_PATH: /home/runner/nettle/build/lib64/pkgconfig:/home/runner/gnutls/build/lib/pkgconfig:/home/runner/nghttp3/build/lib/pkgconfig:/home/runner/ngtcp2/build/lib/pkgconfig:/home/runner/nghttp2/build/lib/pkgconfig - LDFLAGS: -Wl,-rpath,/home/runner/gnutls/build/lib -Wl,-rpath,/home/runner/nettle/build/lib64 -L/home/runner/nettle/build/lib64 -Wl,-rpath,/home/runner/ngtcp2/build/lib - CPPFLAGS: -I/home/runner/nettle/build/include + LDFLAGS: -Wl,-rpath,/home/runner/gnutls/build/lib -Wl,-rpath,/home/runner/nettle/build/lib64 -Wl,-rpath,/home/runner/ngtcp2/build/lib configure: >- --with-gnutls=/home/runner/gnutls/build --with-ngtcp2 --enable-ssls-export @@ -640,7 +639,6 @@ jobs: - name: 'configure' env: - CPPFLAGS: '${{ matrix.build.CPPFLAGS }}' LDFLAGS: '${{ matrix.build.LDFLAGS }}' MATRIX_CONFIGURE: '${{ matrix.build.configure }}' MATRIX_GENERATE: '${{ matrix.build.generate }}' diff --git a/m4/curl-gnutls.m4 b/m4/curl-gnutls.m4 index 9fa7e2451570..f1aa04d3faf6 100644 --- a/m4/curl-gnutls.m4 +++ b/m4/curl-gnutls.m4 @@ -100,18 +100,20 @@ if test "x$OPT_GNUTLS" != xno; then dnl this function is selected since it was introduced in 3.1.10 AC_CHECK_LIB(gnutls, gnutls_x509_crt_get_dn2, - [ + [ AC_DEFINE(USE_GNUTLS, 1, [if GnuTLS is enabled]) GNUTLS_ENABLED=1 USE_GNUTLS="yes" ssl_msg="GnuTLS" QUIC_ENABLED=yes test gnutls != "$DEFAULT_SSL_BACKEND" || VALID_DEFAULT_SSL_BACKEND=yes - ], - [ - LIBS="$CLEANLIBS" - CPPFLAGS="$CLEANCPPFLAGS" - ]) + ], + [ + LIBS="$CLEANLIBS" + CPPFLAGS="$CLEANCPPFLAGS" + LDFLAGS="$CLEANLDFLAGS" + LDFLAGSPC="$CLEANLDFLAGSPC" + ]) if test "x$USE_GNUTLS" = "xyes"; then AC_MSG_NOTICE([detected GnuTLS version $version]) @@ -127,9 +129,8 @@ if test "x$OPT_GNUTLS" != xno; then AC_MSG_NOTICE([Added $gtlslib to CURL_LIBRARY_PATH]) fi fi - LIBCURL_PC_REQUIRES_PRIVATE="$LIBCURL_PC_REQUIRES_PRIVATE gnutls nettle" + LIBCURL_PC_REQUIRES_PRIVATE="$LIBCURL_PC_REQUIRES_PRIVATE gnutls" fi - fi fi dnl GNUTLS not disabled @@ -147,12 +148,60 @@ if test "$GNUTLS_ENABLED" = "1"; then # If not, try linking directly to both of them to see if they are available if test "$USE_GNUTLS_NETTLE" = ""; then - AC_CHECK_LIB(nettle, nettle_MD5Init, [ USE_GNUTLS_NETTLE=1 ]) + + dnl this is with no particular path given + CURL_CHECK_PKGCONFIG(nettle) + + if test "$PKGCONFIG" != "no" ; then + addlib=`$PKGCONFIG --libs-only-l nettle` + addld=`$PKGCONFIG --libs-only-L nettle` + addcflags=`$PKGCONFIG --cflags-only-I nettle` + version=`$PKGCONFIG --modversion nettle` + gtlslib=`echo $addld | $SED -e 's/^-L//'` + + if test -n "$addlib"; then + + CLEANLIBS="$LIBS" + CLEANCPPFLAGS="$CPPFLAGS" + CLEANLDFLAGS="$LDFLAGS" + CLEANLDFLAGSPC="$LDFLAGSPC" + + LIBS="$addlib $LIBS" + LDFLAGS="$LDFLAGS $addld" + LDFLAGSPC="$LDFLAGSPC $addld" + if test "$addcflags" != "-I/usr/include"; then + CPPFLAGS="$CPPFLAGS $addcflags" + fi + + AC_CHECK_LIB(nettle, nettle_MD5Init, + [ + USE_GNUTLS_NETTLE=1 + ], + [ + LIBS="$CLEANLIBS" + CPPFLAGS="$CLEANCPPFLAGS" + LDFLAGS="$CLEANLDFLAGS" + LDFLAGSPC="$CLEANLDFLAGSPC" + ]) + + if test "$USE_GNUTLS_NETTLE" = "1"; then + if test -z "$version"; then + version="unknown" + fi + AC_MSG_NOTICE([detected nettle version $version]) + fi + fi + fi + if test "$USE_GNUTLS_NETTLE" = ""; then + AC_MSG_ERROR([GnuTLS found, but nettle was not found]) + fi + else + LIBS="-lnettle $LIBS" fi - if test "$USE_GNUTLS_NETTLE" = ""; then - AC_MSG_ERROR([GnuTLS found, but nettle was not found]) + + if test "$USE_GNUTLS_NETTLE" = "1"; then + LIBCURL_PC_REQUIRES_PRIVATE="$LIBCURL_PC_REQUIRES_PRIVATE nettle" fi - LIBS="-lnettle $LIBS" dnl --- dnl We require GnuTLS with SRP support. From c722346518365c401b572f8dbe5fa6792ba923cd Mon Sep 17 00:00:00 2001 From: BANADDA Date: Sat, 15 Nov 2025 02:08:10 +0000 Subject: [PATCH 072/415] examples/multi-uv: fix invalid req->data access The on_uv_timeout callback was trying to access req->data as a curl_context pointer, but uv.timeout.data was never initialized, making it always NULL. This rendered the code inside the if(context) block unreachable. Fixes #19462 Closes #19538 --- docs/examples/multi-uv.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/docs/examples/multi-uv.c b/docs/examples/multi-uv.c index 190bed3ef475..75fec20199b3 100644 --- a/docs/examples/multi-uv.c +++ b/docs/examples/multi-uv.c @@ -160,12 +160,19 @@ static void on_uv_socket(uv_poll_t *req, int status, int events) /* callback from libuv when timeout expires */ static void on_uv_timeout(uv_timer_t *req) { - struct curl_context *context = (struct curl_context *) req->data; - if(context) { - int running_handles; - curl_multi_socket_action(context->uv->multi, CURL_SOCKET_TIMEOUT, 0, - &running_handles); - check_multi_info(context); + /* get the datauv struct from the timer handle */ + struct datauv *uv = (struct datauv *)req; + int running_handles; + + curl_multi_socket_action(uv->multi, CURL_SOCKET_TIMEOUT, 0, + &running_handles); + + /* We do not have a curl_context here, so we need to check messages + differently. Create a temporary context just for the check. */ + if(running_handles) { + struct curl_context temp_context; + temp_context.uv = uv; + check_multi_info(&temp_context); } } From 0b09ad8ecbb1e80bc5f621fc012080ab2abf61c4 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Wed, 26 Nov 2025 12:56:44 +0100 Subject: [PATCH 073/415] examples/multi-uv: simplify passing `uv` struct Reported-by: st751228051 on github Follow-up to c722346518365c401b572f8dbe5fa6792ba923cd #19538 #19462 Closes #19707 --- docs/examples/multi-uv.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/docs/examples/multi-uv.c b/docs/examples/multi-uv.c index 75fec20199b3..1dac32048927 100644 --- a/docs/examples/multi-uv.c +++ b/docs/examples/multi-uv.c @@ -104,7 +104,7 @@ static void add_download(const char *url, int num, CURLM *multi) fprintf(stderr, "Added download %s -> %s\n", url, filename); } -static void check_multi_info(struct curl_context *context) +static void check_multi_info(struct datauv *uv) { char *done_url; CURLMsg *message; @@ -112,7 +112,7 @@ static void check_multi_info(struct curl_context *context) CURL *curl; FILE *file; - while((message = curl_multi_info_read(context->uv->multi, &pending))) { + while((message = curl_multi_info_read(uv->multi, &pending))) { switch(message->msg) { case CURLMSG_DONE: /* Do not use message data after calling curl_multi_remove_handle() and @@ -126,7 +126,7 @@ static void check_multi_info(struct curl_context *context) curl_easy_getinfo(curl, CURLINFO_PRIVATE, &file); printf("%s DONE\n", done_url); - curl_multi_remove_handle(context->uv->multi, curl); + curl_multi_remove_handle(uv->multi, curl); curl_easy_cleanup(curl); if(file) { fclose(file); @@ -154,7 +154,7 @@ static void on_uv_socket(uv_poll_t *req, int status, int events) curl_multi_socket_action(context->uv->multi, context->sockfd, flags, &running_handles); - check_multi_info(context); + check_multi_info(context->uv); } /* callback from libuv when timeout expires */ @@ -167,13 +167,8 @@ static void on_uv_timeout(uv_timer_t *req) curl_multi_socket_action(uv->multi, CURL_SOCKET_TIMEOUT, 0, &running_handles); - /* We do not have a curl_context here, so we need to check messages - differently. Create a temporary context just for the check. */ - if(running_handles) { - struct curl_context temp_context; - temp_context.uv = uv; - check_multi_info(&temp_context); - } + if(running_handles) + check_multi_info(uv); } /* callback from libcurl to update the timeout expiry */ From 94ce87c39124d9845aa1e3ce170b9b227ddece89 Mon Sep 17 00:00:00 2001 From: Stefan Eissing Date: Wed, 26 Nov 2025 12:02:02 +0100 Subject: [PATCH 074/415] types: remove curl_int64_t/curl_uint64_t These types and the definitions surrounding them are no longer needed. Closes #19706 --- lib/curl_setup.h | 14 ---- lib/curl_sha512_256.c | 180 ++++++++++++++++++++--------------------- lib/vquic/curl_osslq.c | 7 +- src/tool_util.c | 8 +- 4 files changed, 97 insertions(+), 112 deletions(-) diff --git a/lib/curl_setup.h b/lib/curl_setup.h index 664aa1432532..48b9ea9ea9f9 100644 --- a/lib/curl_setup.h +++ b/lib/curl_setup.h @@ -571,20 +571,6 @@ #endif #define CURL_OFF_T_MIN (-CURL_OFF_T_MAX - 1) -#if (SIZEOF_CURL_OFF_T != 8) -# error "curl_off_t must be exactly 64 bits" -#else - typedef unsigned CURL_TYPEOF_CURL_OFF_T curl_uint64_t; - typedef CURL_TYPEOF_CURL_OFF_T curl_int64_t; -# ifndef CURL_SUFFIX_CURL_OFF_TU -# error "CURL_SUFFIX_CURL_OFF_TU must be defined" -# endif -# define CURL_UINT64_SUFFIX CURL_SUFFIX_CURL_OFF_TU -# define CURL_UINT64_C(val) CURL_CONC_MACROS(val,CURL_UINT64_SUFFIX) -# define FMT_PRId64 CURL_FORMAT_CURL_OFF_T -# define FMT_PRIu64 CURL_FORMAT_CURL_OFF_TU -#endif - #define FMT_OFF_T CURL_FORMAT_CURL_OFF_T #define FMT_OFF_TU CURL_FORMAT_CURL_OFF_TU diff --git a/lib/curl_sha512_256.c b/lib/curl_sha512_256.c index 070d1722cbce..af768fd2aa5f 100644 --- a/lib/curl_sha512_256.c +++ b/lib/curl_sha512_256.c @@ -287,30 +287,30 @@ static CURLcode Curl_sha512_256_finish(unsigned char *digest, Can be moved to other headers to reuse. */ #define CURL_GET_64BIT_BE(ptr) \ - ( ((curl_uint64_t)(((const unsigned char*)(ptr))[0]) << 56) | \ - ((curl_uint64_t)(((const unsigned char*)(ptr))[1]) << 48) | \ - ((curl_uint64_t)(((const unsigned char*)(ptr))[2]) << 40) | \ - ((curl_uint64_t)(((const unsigned char*)(ptr))[3]) << 32) | \ - ((curl_uint64_t)(((const unsigned char*)(ptr))[4]) << 24) | \ - ((curl_uint64_t)(((const unsigned char*)(ptr))[5]) << 16) | \ - ((curl_uint64_t)(((const unsigned char*)(ptr))[6]) << 8) | \ - (curl_uint64_t)(((const unsigned char*)(ptr))[7]) ) + ( ((uint64_t)(((const uint8_t*)(ptr))[0]) << 56) | \ + ((uint64_t)(((const uint8_t*)(ptr))[1]) << 48) | \ + ((uint64_t)(((const uint8_t*)(ptr))[2]) << 40) | \ + ((uint64_t)(((const uint8_t*)(ptr))[3]) << 32) | \ + ((uint64_t)(((const uint8_t*)(ptr))[4]) << 24) | \ + ((uint64_t)(((const uint8_t*)(ptr))[5]) << 16) | \ + ((uint64_t)(((const uint8_t*)(ptr))[6]) << 8) | \ + (uint64_t)(((const uint8_t*)(ptr))[7]) ) #define CURL_PUT_64BIT_BE(ptr,val) do { \ - ((unsigned char*)(ptr))[7]=(unsigned char)((curl_uint64_t)(val)); \ - ((unsigned char*)(ptr))[6]=(unsigned char)(((curl_uint64_t)(val)) >> 8); \ - ((unsigned char*)(ptr))[5]=(unsigned char)(((curl_uint64_t)(val)) >> 16); \ - ((unsigned char*)(ptr))[4]=(unsigned char)(((curl_uint64_t)(val)) >> 24); \ - ((unsigned char*)(ptr))[3]=(unsigned char)(((curl_uint64_t)(val)) >> 32); \ - ((unsigned char*)(ptr))[2]=(unsigned char)(((curl_uint64_t)(val)) >> 40); \ - ((unsigned char*)(ptr))[1]=(unsigned char)(((curl_uint64_t)(val)) >> 48); \ - ((unsigned char*)(ptr))[0]=(unsigned char)(((curl_uint64_t)(val)) >> 56); \ + ((uint8_t*)(ptr))[7]=(uint8_t)((uint64_t)(val)); \ + ((uint8_t*)(ptr))[6]=(uint8_t)(((uint64_t)(val)) >> 8); \ + ((uint8_t*)(ptr))[5]=(uint8_t)(((uint64_t)(val)) >> 16); \ + ((uint8_t*)(ptr))[4]=(uint8_t)(((uint64_t)(val)) >> 24); \ + ((uint8_t*)(ptr))[3]=(uint8_t)(((uint64_t)(val)) >> 32); \ + ((uint8_t*)(ptr))[2]=(uint8_t)(((uint64_t)(val)) >> 40); \ + ((uint8_t*)(ptr))[1]=(uint8_t)(((uint64_t)(val)) >> 48); \ + ((uint8_t*)(ptr))[0]=(uint8_t)(((uint64_t)(val)) >> 56); \ } while(0) /* Defined as a function. The macro version may duplicate the binary code * size as each argument is used twice, so if any calculation is used * as an argument, the calculation could be done twice. */ -static CURL_FORCEINLINE curl_uint64_t Curl_rotr64(curl_uint64_t value, +static CURL_FORCEINLINE uint64_t Curl_rotr64(uint64_t value, unsigned int bits) { bits %= 64; @@ -376,22 +376,22 @@ struct Curl_sha512_256ctx { * compilers may automatically use fast load/store instruction for big * endian data on little endian machine. */ - curl_uint64_t H[SHA512_256_HASH_SIZE_WORDS]; + uint64_t H[SHA512_256_HASH_SIZE_WORDS]; /** * SHA-512/256 input data buffer. The buffer is properly aligned. Smart * compilers may automatically use fast load/store instruction for big * endian data on little endian machine. */ - curl_uint64_t buffer[SHA512_256_BLOCK_SIZE_WORDS]; + uint64_t buffer[SHA512_256_BLOCK_SIZE_WORDS]; /** * The number of bytes, lower part */ - curl_uint64_t count; + uint64_t count; /** * The number of bits, high part. Unlike lower part, this counts the number * of bits, not bytes. */ - curl_uint64_t count_bits_hi; + uint64_t count_bits_hi; }; /** @@ -413,23 +413,23 @@ static CURLcode Curl_sha512_256_init(void *context) /* Check whether the header and this file use the same numbers */ DEBUGASSERT(CURL_SHA512_256_DIGEST_LENGTH == CURL_SHA512_256_DIGEST_SIZE); - DEBUGASSERT(sizeof(curl_uint64_t) == 8); + DEBUGASSERT(sizeof(uint64_t) == 8); /* Initial hash values, see FIPS PUB 180-4 section 5.3.6.2 */ /* Values generated by "IV Generation Function" as described in * section 5.3.6 */ - ctx->H[0] = CURL_UINT64_C(0x22312194FC2BF72C); - ctx->H[1] = CURL_UINT64_C(0x9F555FA3C84C64C2); - ctx->H[2] = CURL_UINT64_C(0x2393B86B6F53B151); - ctx->H[3] = CURL_UINT64_C(0x963877195940EABD); - ctx->H[4] = CURL_UINT64_C(0x96283EE2A88EFFE3); - ctx->H[5] = CURL_UINT64_C(0xBE5E1E2553863992); - ctx->H[6] = CURL_UINT64_C(0x2B0199FC2C85B8AA); - ctx->H[7] = CURL_UINT64_C(0x0EB72DDC81C52CA2); + ctx->H[0] = UINT64_C(0x22312194FC2BF72C); + ctx->H[1] = UINT64_C(0x9F555FA3C84C64C2); + ctx->H[2] = UINT64_C(0x2393B86B6F53B151); + ctx->H[3] = UINT64_C(0x963877195940EABD); + ctx->H[4] = UINT64_C(0x96283EE2A88EFFE3); + ctx->H[5] = UINT64_C(0xBE5E1E2553863992); + ctx->H[6] = UINT64_C(0x2B0199FC2C85B8AA); + ctx->H[7] = UINT64_C(0x0EB72DDC81C52CA2); /* Initialise number of bytes and high part of number of bits. */ - ctx->count = CURL_UINT64_C(0); - ctx->count_bits_hi = CURL_UINT64_C(0); + ctx->count = UINT64_C(0); + ctx->count_bits_hi = UINT64_C(0); return CURLE_OK; } @@ -442,23 +442,23 @@ static CURLcode Curl_sha512_256_init(void *context) * @param data the data buffer with #CURL_SHA512_256_BLOCK_SIZE bytes block */ static -void Curl_sha512_256_transform(curl_uint64_t H[SHA512_256_HASH_SIZE_WORDS], +void Curl_sha512_256_transform(uint64_t H[SHA512_256_HASH_SIZE_WORDS], const void *data) { /* Working variables, see FIPS PUB 180-4 section 6.7, 6.4. */ - curl_uint64_t a = H[0]; - curl_uint64_t b = H[1]; - curl_uint64_t c = H[2]; - curl_uint64_t d = H[3]; - curl_uint64_t e = H[4]; - curl_uint64_t f = H[5]; - curl_uint64_t g = H[6]; - curl_uint64_t h = H[7]; + uint64_t a = H[0]; + uint64_t b = H[1]; + uint64_t c = H[2]; + uint64_t d = H[3]; + uint64_t e = H[4]; + uint64_t f = H[5]; + uint64_t g = H[6]; + uint64_t h = H[7]; /* Data buffer, used as a cyclic buffer. See FIPS PUB 180-4 section 5.2.2, 6.7, 6.4. */ - curl_uint64_t W[16]; + uint64_t W[16]; /* 'Ch' and 'Maj' macro functions are defined with widely-used optimization. See FIPS PUB 180-4 formulae 4.8, 4.9. */ @@ -480,47 +480,47 @@ void Curl_sha512_256_transform(curl_uint64_t H[SHA512_256_HASH_SIZE_WORDS], unsigned int t; /* K constants array. See FIPS PUB 180-4 section 4.2.3 for K values. */ - static const curl_uint64_t K[80] = { - CURL_UINT64_C(0x428a2f98d728ae22), CURL_UINT64_C(0x7137449123ef65cd), - CURL_UINT64_C(0xb5c0fbcfec4d3b2f), CURL_UINT64_C(0xe9b5dba58189dbbc), - CURL_UINT64_C(0x3956c25bf348b538), CURL_UINT64_C(0x59f111f1b605d019), - CURL_UINT64_C(0x923f82a4af194f9b), CURL_UINT64_C(0xab1c5ed5da6d8118), - CURL_UINT64_C(0xd807aa98a3030242), CURL_UINT64_C(0x12835b0145706fbe), - CURL_UINT64_C(0x243185be4ee4b28c), CURL_UINT64_C(0x550c7dc3d5ffb4e2), - CURL_UINT64_C(0x72be5d74f27b896f), CURL_UINT64_C(0x80deb1fe3b1696b1), - CURL_UINT64_C(0x9bdc06a725c71235), CURL_UINT64_C(0xc19bf174cf692694), - CURL_UINT64_C(0xe49b69c19ef14ad2), CURL_UINT64_C(0xefbe4786384f25e3), - CURL_UINT64_C(0x0fc19dc68b8cd5b5), CURL_UINT64_C(0x240ca1cc77ac9c65), - CURL_UINT64_C(0x2de92c6f592b0275), CURL_UINT64_C(0x4a7484aa6ea6e483), - CURL_UINT64_C(0x5cb0a9dcbd41fbd4), CURL_UINT64_C(0x76f988da831153b5), - CURL_UINT64_C(0x983e5152ee66dfab), CURL_UINT64_C(0xa831c66d2db43210), - CURL_UINT64_C(0xb00327c898fb213f), CURL_UINT64_C(0xbf597fc7beef0ee4), - CURL_UINT64_C(0xc6e00bf33da88fc2), CURL_UINT64_C(0xd5a79147930aa725), - CURL_UINT64_C(0x06ca6351e003826f), CURL_UINT64_C(0x142929670a0e6e70), - CURL_UINT64_C(0x27b70a8546d22ffc), CURL_UINT64_C(0x2e1b21385c26c926), - CURL_UINT64_C(0x4d2c6dfc5ac42aed), CURL_UINT64_C(0x53380d139d95b3df), - CURL_UINT64_C(0x650a73548baf63de), CURL_UINT64_C(0x766a0abb3c77b2a8), - CURL_UINT64_C(0x81c2c92e47edaee6), CURL_UINT64_C(0x92722c851482353b), - CURL_UINT64_C(0xa2bfe8a14cf10364), CURL_UINT64_C(0xa81a664bbc423001), - CURL_UINT64_C(0xc24b8b70d0f89791), CURL_UINT64_C(0xc76c51a30654be30), - CURL_UINT64_C(0xd192e819d6ef5218), CURL_UINT64_C(0xd69906245565a910), - CURL_UINT64_C(0xf40e35855771202a), CURL_UINT64_C(0x106aa07032bbd1b8), - CURL_UINT64_C(0x19a4c116b8d2d0c8), CURL_UINT64_C(0x1e376c085141ab53), - CURL_UINT64_C(0x2748774cdf8eeb99), CURL_UINT64_C(0x34b0bcb5e19b48a8), - CURL_UINT64_C(0x391c0cb3c5c95a63), CURL_UINT64_C(0x4ed8aa4ae3418acb), - CURL_UINT64_C(0x5b9cca4f7763e373), CURL_UINT64_C(0x682e6ff3d6b2b8a3), - CURL_UINT64_C(0x748f82ee5defb2fc), CURL_UINT64_C(0x78a5636f43172f60), - CURL_UINT64_C(0x84c87814a1f0ab72), CURL_UINT64_C(0x8cc702081a6439ec), - CURL_UINT64_C(0x90befffa23631e28), CURL_UINT64_C(0xa4506cebde82bde9), - CURL_UINT64_C(0xbef9a3f7b2c67915), CURL_UINT64_C(0xc67178f2e372532b), - CURL_UINT64_C(0xca273eceea26619c), CURL_UINT64_C(0xd186b8c721c0c207), - CURL_UINT64_C(0xeada7dd6cde0eb1e), CURL_UINT64_C(0xf57d4f7fee6ed178), - CURL_UINT64_C(0x06f067aa72176fba), CURL_UINT64_C(0x0a637dc5a2c898a6), - CURL_UINT64_C(0x113f9804bef90dae), CURL_UINT64_C(0x1b710b35131c471b), - CURL_UINT64_C(0x28db77f523047d84), CURL_UINT64_C(0x32caab7b40c72493), - CURL_UINT64_C(0x3c9ebe0a15c9bebc), CURL_UINT64_C(0x431d67c49c100d4c), - CURL_UINT64_C(0x4cc5d4becb3e42b6), CURL_UINT64_C(0x597f299cfc657e2a), - CURL_UINT64_C(0x5fcb6fab3ad6faec), CURL_UINT64_C(0x6c44198c4a475817) + static const uint64_t K[80] = { + UINT64_C(0x428a2f98d728ae22), UINT64_C(0x7137449123ef65cd), + UINT64_C(0xb5c0fbcfec4d3b2f), UINT64_C(0xe9b5dba58189dbbc), + UINT64_C(0x3956c25bf348b538), UINT64_C(0x59f111f1b605d019), + UINT64_C(0x923f82a4af194f9b), UINT64_C(0xab1c5ed5da6d8118), + UINT64_C(0xd807aa98a3030242), UINT64_C(0x12835b0145706fbe), + UINT64_C(0x243185be4ee4b28c), UINT64_C(0x550c7dc3d5ffb4e2), + UINT64_C(0x72be5d74f27b896f), UINT64_C(0x80deb1fe3b1696b1), + UINT64_C(0x9bdc06a725c71235), UINT64_C(0xc19bf174cf692694), + UINT64_C(0xe49b69c19ef14ad2), UINT64_C(0xefbe4786384f25e3), + UINT64_C(0x0fc19dc68b8cd5b5), UINT64_C(0x240ca1cc77ac9c65), + UINT64_C(0x2de92c6f592b0275), UINT64_C(0x4a7484aa6ea6e483), + UINT64_C(0x5cb0a9dcbd41fbd4), UINT64_C(0x76f988da831153b5), + UINT64_C(0x983e5152ee66dfab), UINT64_C(0xa831c66d2db43210), + UINT64_C(0xb00327c898fb213f), UINT64_C(0xbf597fc7beef0ee4), + UINT64_C(0xc6e00bf33da88fc2), UINT64_C(0xd5a79147930aa725), + UINT64_C(0x06ca6351e003826f), UINT64_C(0x142929670a0e6e70), + UINT64_C(0x27b70a8546d22ffc), UINT64_C(0x2e1b21385c26c926), + UINT64_C(0x4d2c6dfc5ac42aed), UINT64_C(0x53380d139d95b3df), + UINT64_C(0x650a73548baf63de), UINT64_C(0x766a0abb3c77b2a8), + UINT64_C(0x81c2c92e47edaee6), UINT64_C(0x92722c851482353b), + UINT64_C(0xa2bfe8a14cf10364), UINT64_C(0xa81a664bbc423001), + UINT64_C(0xc24b8b70d0f89791), UINT64_C(0xc76c51a30654be30), + UINT64_C(0xd192e819d6ef5218), UINT64_C(0xd69906245565a910), + UINT64_C(0xf40e35855771202a), UINT64_C(0x106aa07032bbd1b8), + UINT64_C(0x19a4c116b8d2d0c8), UINT64_C(0x1e376c085141ab53), + UINT64_C(0x2748774cdf8eeb99), UINT64_C(0x34b0bcb5e19b48a8), + UINT64_C(0x391c0cb3c5c95a63), UINT64_C(0x4ed8aa4ae3418acb), + UINT64_C(0x5b9cca4f7763e373), UINT64_C(0x682e6ff3d6b2b8a3), + UINT64_C(0x748f82ee5defb2fc), UINT64_C(0x78a5636f43172f60), + UINT64_C(0x84c87814a1f0ab72), UINT64_C(0x8cc702081a6439ec), + UINT64_C(0x90befffa23631e28), UINT64_C(0xa4506cebde82bde9), + UINT64_C(0xbef9a3f7b2c67915), UINT64_C(0xc67178f2e372532b), + UINT64_C(0xca273eceea26619c), UINT64_C(0xd186b8c721c0c207), + UINT64_C(0xeada7dd6cde0eb1e), UINT64_C(0xf57d4f7fee6ed178), + UINT64_C(0x06f067aa72176fba), UINT64_C(0x0a637dc5a2c898a6), + UINT64_C(0x113f9804bef90dae), UINT64_C(0x1b710b35131c471b), + UINT64_C(0x28db77f523047d84), UINT64_C(0x32caab7b40c72493), + UINT64_C(0x3c9ebe0a15c9bebc), UINT64_C(0x431d67c49c100d4c), + UINT64_C(0x4cc5d4becb3e42b6), UINT64_C(0x597f299cfc657e2a), + UINT64_C(0x5fcb6fab3ad6faec), UINT64_C(0x6c44198c4a475817) }; /* One step of SHA-512/256 computation, @@ -541,7 +541,7 @@ void Curl_sha512_256_transform(curl_uint64_t H[SHA512_256_HASH_SIZE_WORDS], see FIPS PUB 180-4 section 6.4.2 step 3. This macro version reassigns all working variables on each step. */ #define SHA2STEP64RV(vA,vB,vC,vD,vE,vF,vG,vH,kt,wt) do { \ - curl_uint64_t tmp_h_ = (vH); \ + uint64_t tmp_h_ = (vH); \ SHA2STEP64((vA),(vB),(vC),(vD),(vE),(vF),(vG),tmp_h_,(kt),(wt)); \ (vH) = (vG); \ (vG) = (vF); \ @@ -558,7 +558,7 @@ void Curl_sha512_256_transform(curl_uint64_t H[SHA512_256_HASH_SIZE_WORDS], see FIPS PUB 180-4 section 3.1.2. */ #define SHA512_GET_W_FROM_DATA(buf,t) \ CURL_GET_64BIT_BE( \ - ((const unsigned char*) (buf)) + (t) * SHA512_256_BYTES_IN_WORD) + ((const uint8_t*) (buf)) + (t) * SHA512_256_BYTES_IN_WORD) /* During first 16 steps, before making any calculation on each step, the W element is read from the input data buffer as a big-endian value and @@ -573,9 +573,9 @@ void Curl_sha512_256_transform(curl_uint64_t H[SHA512_256_HASH_SIZE_WORDS], As only the last 16 'W' are used in calculations, it is possible to use 16 elements array of W as a cyclic buffer. Note: ((t-16) & 15) have same value as (t & 15) */ -#define Wgen(w,t) \ - (curl_uint64_t)( (w)[(t - 16) & 15] + sig1((w)[((t) - 2) & 15]) \ - + (w)[((t) - 7) & 15] + sig0((w)[((t) - 15) & 15]) ) +#define Wgen(w,t) \ + (uint64_t)( (w)[(t - 16) & 15] + sig1((w)[((t) - 2) & 15]) \ + + (w)[((t) - 7) & 15] + sig0((w)[((t) - 15) & 15]) ) /* During the last 64 steps, before making any calculation on each step, current W element is generated from other W elements of the cyclic @@ -628,7 +628,7 @@ static CURLcode Curl_sha512_256_update(void *context, if(length > ctx->count) ctx->count_bits_hi += 1U << 3; /* Value wrap */ ctx->count_bits_hi += ctx->count >> 61; - ctx->count &= CURL_UINT64_C(0x1FFFFFFFFFFFFFFF); + ctx->count &= UINT64_C(0x1FFFFFFFFFFFFFFF); if(bytes_have) { unsigned int bytes_left = CURL_SHA512_256_BLOCK_SIZE - bytes_have; @@ -685,7 +685,7 @@ static CURLcode Curl_sha512_256_update(void *context, static CURLcode Curl_sha512_256_finish(unsigned char *digest, void *context) { struct Curl_sha512_256ctx *const ctx = (struct Curl_sha512_256ctx *)context; - curl_uint64_t num_bits; /**< Number of processed bits */ + uint64_t num_bits; /**< Number of processed bits */ unsigned int bytes_have; /**< Number of bytes in the context buffer */ /* the void pointer here is required to mute Intel compiler warning */ void *const ctx_buf = ctx->buffer; diff --git a/lib/vquic/curl_osslq.c b/lib/vquic/curl_osslq.c index ade94bf40aa7..0f7cc7a91a2a 100644 --- a/lib/vquic/curl_osslq.c +++ b/lib/vquic/curl_osslq.c @@ -1272,8 +1272,8 @@ static CURLcode h3_quic_recv(void *reader_ctx, } else { CURL_TRC_CF(x->data, x->cf, "[%" PRId64 "] h3_quic_recv -> RESET, " - "rv=%d, app_err=%" FMT_PRIu64, - x->s->id, rv, (curl_uint64_t)app_error_code); + "rv=%d, app_err=%" PRIu64, + x->s->id, rv, app_error_code); if(app_error_code != NGHTTP3_H3_NO_ERROR) x->s->reset = TRUE; } @@ -2246,8 +2246,7 @@ static bool cf_osslq_conn_is_alive(struct Curl_cfilter *cf, "assume connection is dead."); goto out; } - CURL_TRC_CF(data, cf, "negotiated idle timeout: %" FMT_PRIu64 "ms", - (curl_uint64_t)idle_ms); + CURL_TRC_CF(data, cf, "negotiated idle timeout: %" PRIu64 "ms", idle_ms); idletime = curlx_timediff_ms(curlx_now(), ctx->q.last_io); if(idle_ms && idletime > 0 && (uint64_t)idletime > idle_ms) goto out; diff --git a/src/tool_util.c b/src/tool_util.c index a2798876ea06..cb64f9a0b921 100644 --- a/src/tool_util.c +++ b/src/tool_util.c @@ -31,16 +31,16 @@ struct timeval tvrealnow(void) { /* UNIX EPOCH (1970-01-01) in FILETIME (1601-01-01) as 64-bit value */ - static const curl_uint64_t EPOCH = (curl_uint64_t)116444736000000000ULL; + static const uint64_t EPOCH = UINT64_C(116444736000000000); SYSTEMTIME systime; FILETIME ftime; /* 100ns since 1601-01-01, as double 32-bit value */ - curl_uint64_t time; /* 100ns since 1601-01-01, as 64-bit value */ + uint64_t time; /* 100ns since 1601-01-01, as 64-bit value */ struct timeval now; GetSystemTime(&systime); SystemTimeToFileTime(&systime, &ftime); - time = ((curl_uint64_t)ftime.dwLowDateTime); - time += ((curl_uint64_t)ftime.dwHighDateTime) << 32; + time = ((uint64_t)ftime.dwLowDateTime); + time += ((uint64_t)ftime.dwHighDateTime) << 32; now.tv_sec = (long)((time - EPOCH) / 10000000L); /* unit is 100ns */ now.tv_usec = (long)(systime.wMilliseconds * 1000); From 9ea6f2bc6979addeaaab94f8012ad96ae5abfc83 Mon Sep 17 00:00:00 2001 From: Yedaya Katsman Date: Wed, 26 Nov 2025 15:58:40 +0200 Subject: [PATCH 075/415] docs: add rustls to supported backends for CERT and KEY Followup to 1c8c93ae15c692c547e3238c4f067f76616a53e8 Closes #19709 --- docs/libcurl/opts/CURLOPT_SSLCERT.md | 6 +----- docs/libcurl/opts/CURLOPT_SSLKEY.md | 1 + 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/docs/libcurl/opts/CURLOPT_SSLCERT.md b/docs/libcurl/opts/CURLOPT_SSLCERT.md index 20e7d1a17649..40c3a21c25af 100644 --- a/docs/libcurl/opts/CURLOPT_SSLCERT.md +++ b/docs/libcurl/opts/CURLOPT_SSLCERT.md @@ -11,11 +11,7 @@ See-also: Protocol: - TLS TLS-backend: - - OpenSSL - - GnuTLS - - mbedTLS - - Schannel - - wolfSSL + - All Added-in: 7.1 --- diff --git a/docs/libcurl/opts/CURLOPT_SSLKEY.md b/docs/libcurl/opts/CURLOPT_SSLKEY.md index 7d311aeec89d..bbc486d21fb3 100644 --- a/docs/libcurl/opts/CURLOPT_SSLKEY.md +++ b/docs/libcurl/opts/CURLOPT_SSLKEY.md @@ -15,6 +15,7 @@ TLS-backend: - mbedTLS - Schannel - wolfSSL + - Rustls Added-in: 7.9.3 --- From c273de193e6072c4123c4aa95cae316cd728a69f Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 25 Nov 2025 16:14:43 +0100 Subject: [PATCH 076/415] test433: verify "Note: Read config file from..." Which was added in fc09a2da4ad0595292 Closes #19699 --- tests/data/test2080 | 1 + tests/data/test433 | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/tests/data/test2080 b/tests/data/test2080 index 44d16b6ee331..52860addb053 100644 --- a/tests/data/test2080 +++ b/tests/data/test2080 @@ -3,6 +3,7 @@ FILE config +--config diff --git a/tests/data/test433 b/tests/data/test433 index 63c884fdbe48..034f84e0b6db 100644 --- a/tests/data/test433 +++ b/tests/data/test433 @@ -36,8 +36,12 @@ CURL_HOME Verify XDG_CONFIG_HOME use to find curlrc +# set the terminal wide to avoid word wrap in the message + +COLUMNS=300 + -%HOSTIP:%HTTPPORT/%TESTNUMBER +%HOSTIP:%HTTPPORT/%TESTNUMBER --no-progress-meter @@ -55,5 +59,13 @@ Content-Type: application/x-www-form-urlencoded curlrc read + +# On Windows curl may use a backslash, convert that for the comparison + +s:\\:/:g + + +Note: Read config file from '%PWD/%LOGDIR/curlrc' + From 9bb5c0578b39e5b086b6a9db5c6eb299a0fe1c5c Mon Sep 17 00:00:00 2001 From: Stefan Eissing Date: Thu, 27 Nov 2025 12:11:39 +0100 Subject: [PATCH 077/415] ngtcp2+openssl: fix leak of session Fix return value indicating to OpenSSL if reference to session is kept (it is not), so OpenSSL frees it. Reported-by: Aleksei Bavshin Fixes #19717 Closes #19718 --- lib/vquic/curl_ngtcp2.c | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/vquic/curl_ngtcp2.c b/lib/vquic/curl_ngtcp2.c index ad1f2b2b25c8..61b233e4ffc0 100644 --- a/lib/vquic/curl_ngtcp2.c +++ b/lib/vquic/curl_ngtcp2.c @@ -2277,7 +2277,6 @@ static int quic_ossl_new_session_cb(SSL *ssl, SSL_SESSION *ssl_sessionid) #endif Curl_ossl_add_session(cf, data, ctx->peer.scache_key, ssl_sessionid, SSL_version(ssl), "h3", quic_tp, quic_tp_len); - return 1; } return 0; } From a9e7a027ed866b791c12a3c701dc40304f4e00cb Mon Sep 17 00:00:00 2001 From: Stefan Eissing Date: Thu, 27 Nov 2025 10:23:43 +0100 Subject: [PATCH 078/415] vquic: do_sendmsg full init When passing a `msg_ctrl` to sendmsg() as part of GSO handling, zero the complete array. This fixes any false positives by valgrind that complain about uninitialised memory, even though the kernel only ever accesses the first two bytes. Reported-by: Aleksei Bavshin Fixes #19714 Closes #19715 --- lib/vquic/vquic.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/vquic/vquic.c b/lib/vquic/vquic.c index 562a99e4fee0..aa0011c577c4 100644 --- a/lib/vquic/vquic.c +++ b/lib/vquic/vquic.c @@ -145,6 +145,7 @@ static CURLcode do_sendmsg(struct Curl_cfilter *cf, if(pktlen > gsolen) { /* Only set this, when we need it. macOS, for example, * does not seem to like a msg_control of length 0. */ + memset(msg_ctrl, 0, sizeof(msg_ctrl)); msg.msg_control = msg_ctrl; assert(sizeof(msg_ctrl) >= CMSG_SPACE(sizeof(int))); msg.msg_controllen = CMSG_SPACE(sizeof(int)); From feea96851230c7a5a11feaffa0a5e4a4d30e5e63 Mon Sep 17 00:00:00 2001 From: Stefan Eissing Date: Mon, 3 Nov 2025 13:12:50 +0100 Subject: [PATCH 079/415] conncontrol: reuse handling Add protocol handler flag `PROTOPT_CONN_REUSE` to indicate that the protocol allows reusing connections for other tranfers. Add that to all handlers that support it. Create connections with `conn->bits.close = FALSE` and remove all the `connkeep()` calls in protocol handlers setup/connect implementations. `PROTOPT_CONN_REUSE` assures that the default behaviour applies at the end of a transfer without need to juggle the close bit. `conn->bits.close` now serves as an additional indication that a connection cannot be reused. Only protocol handles that allow reuse need to set it to override the default behaviour. Remove all `connclose()` and `connkeep()` calls from connection filters. Filters should not modify connection flags. They are supposed to run in eyeballing situations where a filter is just one of many determining the outcome. Fix http response header handling to only honour `Connection: close` for HTTP/1.x versions. Closes #19333 --- lib/cf-h1-proxy.c | 4 --- lib/cf-h2-proxy.c | 6 +--- lib/conncache.c | 1 - lib/ftp.c | 9 +++--- lib/http.c | 17 ++++------ lib/http2.c | 9 +++--- lib/imap.c | 11 +++---- lib/multi.c | 70 ++++++++++++++++++++++++----------------- lib/openldap.c | 7 +++-- lib/pop3.c | 11 +++---- lib/rtsp.c | 2 +- lib/smb.c | 7 ++--- lib/smtp.c | 11 +++---- lib/url.c | 9 +++--- lib/urldata.h | 1 + lib/vquic/curl_ngtcp2.c | 1 - lib/vquic/curl_osslq.c | 1 - lib/vquic/curl_quiche.c | 4 --- lib/vssh/libssh.c | 11 +++---- lib/vssh/libssh2.c | 12 +++---- lib/vtls/openssl.c | 3 +- 21 files changed, 93 insertions(+), 114 deletions(-) diff --git a/lib/cf-h1-proxy.c b/lib/cf-h1-proxy.c index 985500f23e06..e496d7634dce 100644 --- a/lib/cf-h1-proxy.c +++ b/lib/cf-h1-proxy.c @@ -127,7 +127,6 @@ static CURLcode tunnel_init(struct Curl_cfilter *cf, Curl_httpchunk_init(data, &ts->ch, TRUE); *pts = ts; - connkeep(cf->conn, "HTTP proxy CONNECT"); return tunnel_reinit(cf, data, ts); } @@ -591,7 +590,6 @@ static CURLcode H1_CONNECT(struct Curl_cfilter *cf, CURL_TRC_CF(data, cf, "CONNECT need to close+open"); infof(data, "Connect me again please"); Curl_conn_cf_close(cf, data); - connkeep(conn, "HTTP proxy CONNECT"); result = Curl_conn_cf_connect(cf->next, data, &done); goto out; } @@ -612,8 +610,6 @@ static CURLcode H1_CONNECT(struct Curl_cfilter *cf, if(data->info.httpproxycode/100 != 2) { /* a non-2xx response and we have no next URL to try. */ Curl_safefree(data->req.newurl); - /* failure, close this connection to avoid reuse */ - streamclose(conn, "proxy CONNECT failure"); h1_tunnel_go_state(cf, ts, H1_TUNNEL_FAILED, data); failf(data, "CONNECT tunnel failed, response %d", data->req.httpcode); return CURLE_RECV_ERROR; diff --git a/lib/cf-h2-proxy.c b/lib/cf-h2-proxy.c index b963bb718ce9..89bc7cc23f48 100644 --- a/lib/cf-h2-proxy.c +++ b/lib/cf-h2-proxy.c @@ -488,10 +488,6 @@ static CURLcode proxy_h2_progress_ingress(struct Curl_cfilter *cf, return result; } - if(ctx->conn_closed && Curl_bufq_is_empty(&ctx->inbufq)) { - connclose(cf->conn, "GOAWAY received"); - } - return CURLE_OK; } @@ -1265,7 +1261,7 @@ static CURLcode h2_handle_tunnel_close(struct Curl_cfilter *cf, if(ctx->tunnel.error == NGHTTP2_REFUSED_STREAM) { CURL_TRC_CF(data, cf, "[%d] REFUSED_STREAM, try again on a new " "connection", ctx->tunnel.stream_id); - connclose(cf->conn, "REFUSED_STREAM"); /* do not use this anymore */ + failf(data, "proxy server refused HTTP/2 stream"); return CURLE_RECV_ERROR; /* trigger Curl_retry_request() later */ } else if(ctx->tunnel.error != NGHTTP2_NO_ERROR) { diff --git a/lib/conncache.c b/lib/conncache.c index 275e490f23e8..9d3b69bec356 100644 --- a/lib/conncache.c +++ b/lib/conncache.c @@ -220,7 +220,6 @@ void Curl_cpool_destroy(struct cpool *cpool) while(conn) { cpool_remove_conn(cpool, conn); sigpipe_apply(cpool->idata, &pipe_st); - connclose(conn, "kill all"); cpool_discard_conn(cpool, cpool->idata, conn, FALSE); conn = cpool_get_first(cpool); } diff --git a/lib/ftp.c b/lib/ftp.c index c289581fd5a4..ce4001226823 100644 --- a/lib/ftp.c +++ b/lib/ftp.c @@ -270,7 +270,8 @@ const struct Curl_handler Curl_handler_ftp = { CURLPROTO_FTP, /* family */ PROTOPT_DUAL | PROTOPT_CLOSEACTION | PROTOPT_NEEDSPWD | PROTOPT_NOURLQUERY | PROTOPT_PROXY_AS_HTTP | - PROTOPT_WILDCARD | PROTOPT_SSL_REUSE /* flags */ + PROTOPT_WILDCARD | PROTOPT_SSL_REUSE | + PROTOPT_CONN_REUSE /* flags */ }; @@ -302,7 +303,8 @@ const struct Curl_handler Curl_handler_ftps = { CURLPROTO_FTPS, /* protocol */ CURLPROTO_FTP, /* family */ PROTOPT_SSL | PROTOPT_DUAL | PROTOPT_CLOSEACTION | - PROTOPT_NEEDSPWD | PROTOPT_NOURLQUERY | PROTOPT_WILDCARD /* flags */ + PROTOPT_NEEDSPWD | PROTOPT_NOURLQUERY | PROTOPT_WILDCARD | + PROTOPT_CONN_REUSE /* flags */ }; #endif @@ -3183,9 +3185,6 @@ static CURLcode ftp_connect(struct Curl_easy *data, if(!ftpc) return CURLE_FAILED_INIT; pp = &ftpc->pp; - /* We always support persistent connections on ftp */ - connkeep(conn, "FTP default"); - PINGPONG_SETUP(pp, ftp_pp_statemachine, ftp_endofresp); if(Curl_conn_is_ssl(conn, FIRSTSOCKET)) { diff --git a/lib/http.c b/lib/http.c index 144a898ea0eb..0319be3b657b 100644 --- a/lib/http.c +++ b/lib/http.c @@ -142,7 +142,8 @@ const struct Curl_handler Curl_handler_http = { CURLPROTO_HTTP, /* protocol */ CURLPROTO_HTTP, /* family */ PROTOPT_CREDSPERREQUEST | /* flags */ - PROTOPT_USERPWDCTRL + PROTOPT_USERPWDCTRL | PROTOPT_CONN_REUSE + }; #ifdef USE_SSL @@ -172,7 +173,7 @@ const struct Curl_handler Curl_handler_https = { CURLPROTO_HTTPS, /* protocol */ CURLPROTO_HTTP, /* family */ PROTOPT_SSL | PROTOPT_CREDSPERREQUEST | PROTOPT_ALPN | /* flags */ - PROTOPT_USERPWDCTRL + PROTOPT_USERPWDCTRL | PROTOPT_CONN_REUSE }; #endif @@ -220,7 +221,6 @@ CURLcode Curl_http_setup_conn(struct Curl_easy *data, { /* allocate the HTTP-specific struct for the Curl_easy, only to survive during this request */ - connkeep(conn, "HTTP default"); if(data->state.http_neg.wanted == CURL_HTTP_V3x) { /* only HTTP/3, needs to work */ CURLcode result = Curl_conn_may_http3(data, conn, conn->transport_wanted); @@ -1548,12 +1548,6 @@ Curl_compareheader(const char *headerline, /* line to check */ */ CURLcode Curl_http_connect(struct Curl_easy *data, bool *done) { - struct connectdata *conn = data->conn; - - /* We default to persistent connections. We set this already in this connect - function to make the reuse checks properly be able to check this bit. */ - connkeep(conn, "HTTP default"); - return Curl_conn_connect(data, FIRSTSOCKET, FALSE, done); } @@ -3257,14 +3251,15 @@ static CURLcode http_header_c(struct Curl_easy *data, } return CURLE_OK; } - if(HD_IS_AND_SAYS(hd, hdlen, "Connection:", "close")) { + if((k->httpversion < 20) && + HD_IS_AND_SAYS(hd, hdlen, "Connection:", "close")) { /* * [RFC 2616, section 8.1.2.1] * "Connection: close" is HTTP/1.1 language and means that * the connection will close when this request has been * served. */ - streamclose(conn, "Connection: close used"); + connclose(conn, "Connection: close used"); return CURLE_OK; } if((k->httpversion == 10) && diff --git a/lib/http2.c b/lib/http2.c index 7b94930a21a7..4f5f5ea52dd3 100644 --- a/lib/http2.c +++ b/lib/http2.c @@ -2071,7 +2071,7 @@ static CURLcode h2_progress_ingress(struct Curl_cfilter *cf, size_t nread; if(should_close_session(ctx)) { - CURL_TRC_CF(data, cf, "progress ingress, session is closed"); + CURL_TRC_CF(data, cf, "[0] ingress: session is closed"); return CURLE_HTTP2; } @@ -2128,15 +2128,16 @@ static CURLcode h2_progress_ingress(struct Curl_cfilter *cf, result = h2_process_pending_input(cf, data); if(result) return result; - CURL_TRC_CF(data, cf, "[0] progress ingress: inbufg=%zu", + CURL_TRC_CF(data, cf, "[0] ingress: nw-in buffered %zu", Curl_bufq_len(&ctx->inbufq)); } if(ctx->conn_closed && Curl_bufq_is_empty(&ctx->inbufq)) { - connclose(cf->conn, "GOAWAY received"); + connclose(cf->conn, ctx->rcvd_goaway ? "server closed with GOAWAY" : + "server closed abruptly"); } - CURL_TRC_CF(data, cf, "[0] progress ingress: done"); + CURL_TRC_CF(data, cf, "[0] ingress: done"); return CURLE_OK; } diff --git a/lib/imap.c b/lib/imap.c index 181b0d7009d6..af9b124d1e72 100644 --- a/lib/imap.c +++ b/lib/imap.c @@ -210,9 +210,9 @@ const struct Curl_handler Curl_handler_imap = { PORT_IMAP, /* defport */ CURLPROTO_IMAP, /* protocol */ CURLPROTO_IMAP, /* family */ - PROTOPT_CLOSEACTION| /* flags */ - PROTOPT_URLOPTIONS| - PROTOPT_SSL_REUSE + PROTOPT_CLOSEACTION | /* flags */ + PROTOPT_URLOPTIONS | PROTOPT_SSL_REUSE | + PROTOPT_CONN_REUSE }; #ifdef USE_SSL @@ -243,7 +243,7 @@ const struct Curl_handler Curl_handler_imaps = { CURLPROTO_IMAPS, /* protocol */ CURLPROTO_IMAP, /* family */ PROTOPT_CLOSEACTION | PROTOPT_SSL | /* flags */ - PROTOPT_URLOPTIONS + PROTOPT_URLOPTIONS | PROTOPT_CONN_REUSE }; #endif @@ -1680,9 +1680,6 @@ static CURLcode imap_connect(struct Curl_easy *data, bool *done) if(!imapc) return CURLE_FAILED_INIT; - /* We always support persistent connections in IMAP */ - connkeep(data->conn, "IMAP default"); - /* Parse the URL options */ result = imap_parse_url_options(data->conn, imapc); if(result) diff --git a/lib/multi.c b/lib/multi.c index 57c574a68176..f7265a94a9ec 100644 --- a/lib/multi.c +++ b/lib/multi.c @@ -547,6 +547,47 @@ struct multi_done_ctx { BIT(premature); }; +static bool multi_conn_should_close(struct connectdata *conn, + struct Curl_easy *data, + bool premature) +{ + /* if conn->bits.close is TRUE, it means that the connection should be + closed in spite of everything else. */ + if(conn->bits.close) + return TRUE; + + /* if data->set.reuse_forbid is TRUE, it means the libcurl client has + forced us to close this connection. This is ignored for requests taking + place in a NTLM/NEGOTIATE authentication handshake. */ + if(data->set.reuse_forbid +#ifdef USE_NTLM + && !(conn->http_ntlm_state == NTLMSTATE_TYPE2 || + conn->proxy_ntlm_state == NTLMSTATE_TYPE2) +#endif +#ifdef USE_SPNEGO + && !(conn->http_negotiate_state == GSS_AUTHRECV || + conn->proxy_negotiate_state == GSS_AUTHRECV) +#endif + ) + return TRUE; + + /* Unless this connection is for a "connect-only" transfer, it + * needs to be closed if the protocol handler does not support reuse. */ + if(!data->set.connect_only && conn->handler && + !(conn->handler->flags & PROTOPT_CONN_REUSE)) + return TRUE; + + /* if premature is TRUE, it means this connection was said to be DONE before + the entire request operation is complete and thus we cannot know in what + state it is for reusing, so we are forced to close it. In a perfect world + we can add code that keep track of if we really must close it here or not, + but currently we have no such detail knowledge. */ + if(premature && !Curl_conn_is_multiplex(conn, FIRSTSOCKET)) + return TRUE; + + return FALSE; +} + static void multi_done_locked(struct connectdata *conn, struct Curl_easy *data, void *userdata) @@ -587,32 +628,7 @@ static void multi_done_locked(struct connectdata *conn, Curl_resolv_unlink(data, &data->state.dns[1]); Curl_dnscache_prune(data); - /* if data->set.reuse_forbid is TRUE, it means the libcurl client has - forced us to close this connection. This is ignored for requests taking - place in a NTLM/NEGOTIATE authentication handshake - - if conn->bits.close is TRUE, it means that the connection should be - closed in spite of all our efforts to be nice, due to protocol - restrictions in our or the server's end - - if premature is TRUE, it means this connection was said to be DONE before - the entire request operation is complete and thus we cannot know in what - state it is for reusing, so we are forced to close it. In a perfect world - we can add code that keep track of if we really must close it here or not, - but currently we have no such detail knowledge. - */ - - if((data->set.reuse_forbid -#ifdef USE_NTLM - && !(conn->http_ntlm_state == NTLMSTATE_TYPE2 || - conn->proxy_ntlm_state == NTLMSTATE_TYPE2) -#endif -#ifdef USE_SPNEGO - && !(conn->http_negotiate_state == GSS_AUTHRECV || - conn->proxy_negotiate_state == GSS_AUTHRECV) -#endif - ) || conn->bits.close - || (mdctx->premature && !Curl_conn_is_multiplex(conn, FIRSTSOCKET))) { + if(multi_conn_should_close(conn, data, mdctx->premature)) { #ifndef CURL_DISABLE_VERBOSE_STRINGS CURL_TRC_M(data, "multi_done, terminating conn #%" FMT_OFF_T " to %s:%d, " "forbid=%d, close=%d, premature=%d, conn_multiplex=%d", @@ -2127,8 +2143,6 @@ static CURLMcode state_do(struct Curl_easy *data, } if(data->set.connect_only && !data->set.connect_only_ws) { - /* keep connection open for application to use the socket */ - connkeep(data->conn, "CONNECT_ONLY"); multistate(data, MSTATE_DONE); rc = CURLM_CALL_MULTI_PERFORM; } diff --git a/lib/openldap.c b/lib/openldap.c index 9d6174defe37..41419df21b20 100644 --- a/lib/openldap.c +++ b/lib/openldap.c @@ -139,7 +139,8 @@ const struct Curl_handler Curl_handler_ldap = { PORT_LDAP, /* defport */ CURLPROTO_LDAP, /* protocol */ CURLPROTO_LDAP, /* family */ - PROTOPT_SSL_REUSE /* flags */ + PROTOPT_SSL_REUSE | /* flags */ + PROTOPT_CONN_REUSE }; #ifdef USE_SSL @@ -169,7 +170,8 @@ const struct Curl_handler Curl_handler_ldaps = { PORT_LDAPS, /* defport */ CURLPROTO_LDAPS, /* protocol */ CURLPROTO_LDAP, /* family */ - PROTOPT_SSL /* flags */ + PROTOPT_SSL | /* flags */ + PROTOPT_CONN_REUSE }; #endif @@ -992,7 +994,6 @@ static CURLcode oldap_do(struct Curl_easy *data, bool *done) if(!li) return CURLE_FAILED_INIT; - connkeep(conn, "OpenLDAP do"); infof(data, "LDAP local: %s", data->state.url); diff --git a/lib/pop3.c b/lib/pop3.c index 05203c1a074e..503f4ecb2bd5 100644 --- a/lib/pop3.c +++ b/lib/pop3.c @@ -200,7 +200,8 @@ const struct Curl_handler Curl_handler_pop3 = { CURLPROTO_POP3, /* protocol */ CURLPROTO_POP3, /* family */ PROTOPT_CLOSEACTION | PROTOPT_NOURLQUERY | /* flags */ - PROTOPT_URLOPTIONS | PROTOPT_SSL_REUSE + PROTOPT_URLOPTIONS | PROTOPT_SSL_REUSE | + PROTOPT_CONN_REUSE }; #ifdef USE_SSL @@ -230,8 +231,9 @@ const struct Curl_handler Curl_handler_pop3s = { PORT_POP3S, /* defport */ CURLPROTO_POP3S, /* protocol */ CURLPROTO_POP3, /* family */ - PROTOPT_CLOSEACTION | PROTOPT_SSL - | PROTOPT_NOURLQUERY | PROTOPT_URLOPTIONS /* flags */ + PROTOPT_CLOSEACTION | PROTOPT_SSL | /* flags */ + PROTOPT_NOURLQUERY | PROTOPT_URLOPTIONS | + PROTOPT_CONN_REUSE }; #endif @@ -1295,9 +1297,6 @@ static CURLcode pop3_connect(struct Curl_easy *data, bool *done) if(!pop3c) return CURLE_FAILED_INIT; - /* We always support persistent connections in POP3 */ - connkeep(conn, "POP3 default"); - PINGPONG_SETUP(pp, pop3_statemachine, pop3_endofresp); /* Set the default preferred authentication type and mechanism */ diff --git a/lib/rtsp.c b/lib/rtsp.c index b4b3d6dd556d..dd49ebc42b4d 100644 --- a/lib/rtsp.c +++ b/lib/rtsp.c @@ -152,7 +152,7 @@ const struct Curl_handler Curl_handler_rtsp = { PORT_RTSP, /* defport */ CURLPROTO_RTSP, /* protocol */ CURLPROTO_RTSP, /* family */ - PROTOPT_NONE /* flags */ + PROTOPT_CONN_REUSE /* flags */ }; #define MAX_RTP_BUFFERSIZE 1000000 /* arbitrary */ diff --git a/lib/smb.c b/lib/smb.c index 4ef35c295d15..e5fca3ec0bef 100644 --- a/lib/smb.c +++ b/lib/smb.c @@ -329,7 +329,7 @@ const struct Curl_handler Curl_handler_smb = { PORT_SMB, /* defport */ CURLPROTO_SMB, /* protocol */ CURLPROTO_SMB, /* family */ - PROTOPT_NONE /* flags */ + PROTOPT_CONN_REUSE /* flags */ }; #ifdef USE_SSL @@ -358,7 +358,7 @@ const struct Curl_handler Curl_handler_smbs = { PORT_SMBS, /* defport */ CURLPROTO_SMBS, /* protocol */ CURLPROTO_SMB, /* family */ - PROTOPT_SSL /* flags */ + PROTOPT_SSL | PROTOPT_CONN_REUSE /* flags */ }; #endif @@ -513,9 +513,6 @@ static CURLcode smb_connect(struct Curl_easy *data, bool *done) if(!smbc->send_buf) return CURLE_OUT_OF_MEMORY; - /* Multiple requests are allowed with this connection */ - connkeep(conn, "SMB default"); - /* Parse the username, domain, and password */ slash = strchr(conn->user, '/'); if(!slash) diff --git a/lib/smtp.c b/lib/smtp.c index af4676dc182d..eca27f146525 100644 --- a/lib/smtp.c +++ b/lib/smtp.c @@ -205,7 +205,8 @@ const struct Curl_handler Curl_handler_smtp = { CURLPROTO_SMTP, /* protocol */ CURLPROTO_SMTP, /* family */ PROTOPT_CLOSEACTION | PROTOPT_NOURLQUERY | /* flags */ - PROTOPT_URLOPTIONS | PROTOPT_SSL_REUSE + PROTOPT_URLOPTIONS | PROTOPT_SSL_REUSE | + PROTOPT_CONN_REUSE }; #ifdef USE_SSL @@ -235,8 +236,9 @@ const struct Curl_handler Curl_handler_smtps = { PORT_SMTPS, /* defport */ CURLPROTO_SMTPS, /* protocol */ CURLPROTO_SMTP, /* family */ - PROTOPT_CLOSEACTION | PROTOPT_SSL - | PROTOPT_NOURLQUERY | PROTOPT_URLOPTIONS /* flags */ + PROTOPT_CLOSEACTION | PROTOPT_SSL | /* flags */ + PROTOPT_NOURLQUERY | PROTOPT_URLOPTIONS | + PROTOPT_CONN_REUSE }; #endif @@ -1440,9 +1442,6 @@ static CURLcode smtp_connect(struct Curl_easy *data, bool *done) if(!smtpc) return CURLE_FAILED_INIT; - /* We always support persistent connections in SMTP */ - connkeep(data->conn, "SMTP default"); - PINGPONG_SETUP(&smtpc->pp, smtp_pp_statemachine, smtp_endofresp); /* Initialize the SASL storage */ diff --git a/lib/url.c b/lib/url.c index 8b3f7f5ab738..b6a60feb38b2 100644 --- a/lib/url.c +++ b/lib/url.c @@ -1364,11 +1364,6 @@ static struct connectdata *allocate_conn(struct Curl_easy *data) conn->connection_id = -1; /* no ID */ conn->remote_port = -1; /* unknown at this point */ - /* Default protocol-independent behavior does not support persistent - connections, so we set this to force-close. Protocols that support - this need to set this to FALSE in their "curl_do" functions. */ - connclose(conn, "Default to force-close"); - /* Store creation time to help future close decision making */ conn->created = curlx_now(); @@ -1428,6 +1423,7 @@ static struct connectdata *allocate_conn(struct Curl_easy *data) #ifdef HAVE_GSSAPI conn->gssapi_delegation = data->set.gssapi_delegation; #endif + DEBUGF(infof(data, "alloc connection, bits.close=%d", conn->bits.close)); return conn; error: @@ -2035,11 +2031,13 @@ static CURLcode setup_connection_internals(struct Curl_easy *data, int port; CURLcode result; + DEBUGF(infof(data, "setup connection, bits.close=%d", conn->bits.close)); if(conn->handler->setup_connection) { result = conn->handler->setup_connection(data, conn); if(result) return result; } + DEBUGF(infof(data, "setup connection, bits.close=%d", conn->bits.close)); /* Now create the destination name */ #ifndef CURL_DISABLE_PROXY @@ -3664,6 +3662,7 @@ static CURLcode create_conn(struct Curl_easy *data, /* We have decided that we want a new connection. However, we may not be able to do that if we have reached the limit of how many connections we are allowed to open. */ + DEBUGF(infof(data, "new connection, bits.close=%d", conn->bits.close)); if(conn->handler->flags & PROTOPT_ALPN) { /* The protocol wants it, so set the bits if enabled in the easy handle diff --git a/lib/urldata.h b/lib/urldata.h index c71607ea7d2b..37ecd1ff9db7 100644 --- a/lib/urldata.h +++ b/lib/urldata.h @@ -567,6 +567,7 @@ struct Curl_handler { #define PROTOPT_SSL_REUSE (1<<15) /* this protocol may reuse an existing SSL connection in the same family without having PROTOPT_SSL. */ +#define PROTOPT_CONN_REUSE (1<<16) /* this protocol can reuse connections */ #define CONNCHECK_NONE 0 /* No checks */ #define CONNCHECK_ISDEAD (1<<0) /* Check if the connection is dead. */ diff --git a/lib/vquic/curl_ngtcp2.c b/lib/vquic/curl_ngtcp2.c index 61b233e4ffc0..de767f28dc04 100644 --- a/lib/vquic/curl_ngtcp2.c +++ b/lib/vquic/curl_ngtcp2.c @@ -2647,7 +2647,6 @@ static CURLcode cf_ngtcp2_connect(struct Curl_cfilter *cf, CURL_TRC_CF(data, cf, "peer verified"); cf->connected = TRUE; *done = TRUE; - connkeep(cf->conn, "HTTP/3 default"); } } diff --git a/lib/vquic/curl_osslq.c b/lib/vquic/curl_osslq.c index 0f7cc7a91a2a..376705e51667 100644 --- a/lib/vquic/curl_osslq.c +++ b/lib/vquic/curl_osslq.c @@ -1816,7 +1816,6 @@ static CURLcode cf_osslq_connect(struct Curl_cfilter *cf, CURL_TRC_CF(data, cf, "peer verified"); cf->connected = TRUE; *done = TRUE; - connkeep(cf->conn, "HTTP/3 default"); } } else { diff --git a/lib/vquic/curl_quiche.c b/lib/vquic/curl_quiche.c index 5082dc750bb5..927492979013 100644 --- a/lib/vquic/curl_quiche.c +++ b/lib/vquic/curl_quiche.c @@ -446,7 +446,6 @@ static CURLcode cf_recv_body(struct Curl_cfilter *cf, stream->closed = TRUE; stream->reset = TRUE; stream->send_closed = TRUE; - streamclose(cf->conn, "Reset of stream"); return result; } return CURLE_OK; @@ -510,7 +509,6 @@ static CURLcode h3_process_event(struct Curl_cfilter *cf, stream->closed = TRUE; stream->reset = TRUE; stream->send_closed = TRUE; - streamclose(cf->conn, "Reset of stream"); break; case QUICHE_H3_EVENT_FINISHED: @@ -522,7 +520,6 @@ static CURLcode h3_process_event(struct Curl_cfilter *cf, stream->resp_hds_complete = TRUE; } stream->closed = TRUE; - streamclose(cf->conn, "End of stream"); break; case QUICHE_H3_EVENT_GOAWAY: @@ -1415,7 +1412,6 @@ static CURLcode cf_quiche_connect(struct Curl_cfilter *cf, } cf->connected = TRUE; *done = TRUE; - connkeep(cf->conn, "HTTP/3 default"); } } else if(quiche_conn_is_draining(ctx->qconn)) { diff --git a/lib/vssh/libssh.c b/lib/vssh/libssh.c index 77a915884aaf..c76478bc2a57 100644 --- a/lib/vssh/libssh.c +++ b/lib/vssh/libssh.c @@ -156,7 +156,8 @@ const struct Curl_handler Curl_handler_scp = { PORT_SSH, /* defport */ CURLPROTO_SCP, /* protocol */ CURLPROTO_SCP, /* family */ - PROTOPT_DIRLOCK | PROTOPT_CLOSEACTION | PROTOPT_NOURLQUERY /* flags */ + PROTOPT_DIRLOCK | PROTOPT_CLOSEACTION | /* flags */ + PROTOPT_NOURLQUERY | PROTOPT_CONN_REUSE }; /* @@ -185,8 +186,8 @@ const struct Curl_handler Curl_handler_sftp = { PORT_SSH, /* defport */ CURLPROTO_SFTP, /* protocol */ CURLPROTO_SFTP, /* family */ - PROTOPT_DIRLOCK | PROTOPT_CLOSEACTION - | PROTOPT_NOURLQUERY /* flags */ + PROTOPT_DIRLOCK | PROTOPT_CLOSEACTION | /* flags */ + PROTOPT_NOURLQUERY | PROTOPT_CONN_REUSE }; static CURLcode sftp_error_to_CURLE(int err) @@ -2572,10 +2573,6 @@ static CURLcode myssh_connect(struct Curl_easy *data, bool *done) if(!sshc || !ssh) return CURLE_FAILED_INIT; - /* We default to persistent connections. We set this already in this connect - function to make the reuse checks properly be able to check this bit. */ - connkeep(conn, "SSH default"); - if(conn->handler->protocol & CURLPROTO_SCP) { conn->recv[FIRSTSOCKET] = scp_recv; conn->send[FIRSTSOCKET] = scp_send; diff --git a/lib/vssh/libssh2.c b/lib/vssh/libssh2.c index 714e3953730a..1c9fe5ac0154 100644 --- a/lib/vssh/libssh2.c +++ b/lib/vssh/libssh2.c @@ -123,8 +123,8 @@ const struct Curl_handler Curl_handler_scp = { PORT_SSH, /* defport */ CURLPROTO_SCP, /* protocol */ CURLPROTO_SCP, /* family */ - PROTOPT_DIRLOCK | PROTOPT_CLOSEACTION - | PROTOPT_NOURLQUERY /* flags */ + PROTOPT_DIRLOCK | PROTOPT_CLOSEACTION | /* flags */ + PROTOPT_NOURLQUERY | PROTOPT_CONN_REUSE }; @@ -154,8 +154,8 @@ const struct Curl_handler Curl_handler_sftp = { PORT_SSH, /* defport */ CURLPROTO_SFTP, /* protocol */ CURLPROTO_SFTP, /* family */ - PROTOPT_DIRLOCK | PROTOPT_CLOSEACTION - | PROTOPT_NOURLQUERY /* flags */ + PROTOPT_DIRLOCK | PROTOPT_CLOSEACTION | /* flags */ + PROTOPT_NOURLQUERY | PROTOPT_CONN_REUSE }; static void @@ -3323,10 +3323,6 @@ static CURLcode ssh_connect(struct Curl_easy *data, bool *done) if(!sshc) return CURLE_FAILED_INIT; - /* We default to persistent connections. We set this already in this connect - function to make the reuse checks properly be able to check this bit. */ - connkeep(conn, "SSH default"); - infof(data, "User: '%s'", conn->user); #ifdef CURL_LIBSSH2_DEBUG infof(data, "Password: %s", conn->passwd); diff --git a/lib/vtls/openssl.c b/lib/vtls/openssl.c index 8991d965d9be..2f526479c5f4 100644 --- a/lib/vtls/openssl.c +++ b/lib/vtls/openssl.c @@ -5175,7 +5175,6 @@ static CURLcode ossl_recv(struct Curl_cfilter *cf, char error_buffer[256]; unsigned long sslerror; int buffsize; - struct connectdata *conn = cf->conn; struct ssl_connect_data *connssl = cf->ctx; struct ossl_ctx *octx = (struct ossl_ctx *)connssl->backend; CURLcode result = CURLE_OK; @@ -5205,7 +5204,7 @@ static CURLcode ossl_recv(struct Curl_cfilter *cf, if(cf->sockindex == FIRSTSOCKET) /* mark the connection for close if it is indeed the control connection */ - connclose(conn, "TLS close_notify"); + CURL_TRC_CF(data, cf, "TLS close_notify"); break; case SSL_ERROR_WANT_READ: connssl->io_need = CURL_SSL_IO_NEED_RECV; From c4f29cc5081b4b70ba435c64bd8ee81f02b3ceeb Mon Sep 17 00:00:00 2001 From: Stefan Eissing Date: Wed, 26 Nov 2025 14:05:46 +0100 Subject: [PATCH 080/415] ip_quadruple/proxy: make port uint16_t Make `port` member in these struct of type `uint16_t`. add `uint8_t transport` to `struct ip_quadruple Define TRNSPRT_NONE as 0. By assigning a valid transport only on a successful connection, it is clear when the ip_quadruple members are valid. Also, for transports not involving ports, the getinfos for `CURLINFO_PRIMARY_PORT` and `CURLINFO_LOCAL_PORT` will now always return -1. Make all `transport` members and parameters of type `uint8_t`. Document the return value of `CURLINFO_LOCAL_PORT` and `CURLINFO_PRIMARY_PORT` in this regard. Add tests that writeout stats report ports correctly. Closes #19708 --- docs/libcurl/opts/CURLINFO_LOCAL_PORT.md | 3 +++ docs/libcurl/opts/CURLINFO_PRIMARY_PORT.md | 5 +++++ lib/cf-https-connect.c | 10 ++++----- lib/cf-ip-happy.c | 24 ++++++++++---------- lib/cf-ip-happy.h | 6 ++--- lib/cf-socket.c | 17 +++++++------- lib/cf-socket.h | 8 +++---- lib/connect.c | 16 ++++++------- lib/connect.h | 4 ++-- lib/getinfo.c | 12 ++++++---- lib/setopt.c | 4 ++-- lib/url.c | 14 +++++------- lib/urldata.h | 26 +++++++++++++--------- lib/vquic/vquic.c | 2 +- lib/vquic/vquic.h | 2 +- tests/http/test_01_basic.py | 3 +++ tests/http/test_11_unix.py | 6 +++++ tests/unit/unit1607.c | 2 +- tests/unit/unit1609.c | 2 +- tests/unit/unit2600.c | 4 ++-- 20 files changed, 97 insertions(+), 73 deletions(-) diff --git a/docs/libcurl/opts/CURLINFO_LOCAL_PORT.md b/docs/libcurl/opts/CURLINFO_LOCAL_PORT.md index 67d73b71650e..40d1f5fb6a87 100644 --- a/docs/libcurl/opts/CURLINFO_LOCAL_PORT.md +++ b/docs/libcurl/opts/CURLINFO_LOCAL_PORT.md @@ -35,6 +35,9 @@ connection done with this **curl** handle. If the connection was done using QUIC, the port number is a UDP port number, otherwise it is a TCP port number. +If no connection was established or if the protocol does not use ports, -1 +is returned. + # %PROTOCOLS% # EXAMPLE diff --git a/docs/libcurl/opts/CURLINFO_PRIMARY_PORT.md b/docs/libcurl/opts/CURLINFO_PRIMARY_PORT.md index b98f246042da..85f5767423a4 100644 --- a/docs/libcurl/opts/CURLINFO_PRIMARY_PORT.md +++ b/docs/libcurl/opts/CURLINFO_PRIMARY_PORT.md @@ -36,6 +36,11 @@ If a proxy was used for the most recent transfer, this is the port number of the proxy, if no proxy was used it is the port number of the most recently accessed URL. +If the connection was done using QUIC, the port number is a UDP port number. + +If no connection was established or if the protocol does not use ports, -1 +is returned. + # %PROTOCOLS% # EXAMPLE diff --git a/lib/cf-https-connect.c b/lib/cf-https-connect.c index dfd82bd9a117..5491d7968d7e 100644 --- a/lib/cf-https-connect.c +++ b/lib/cf-https-connect.c @@ -55,7 +55,7 @@ struct cf_hc_baller { CURLcode result; struct curltime started; int reply_ms; - unsigned char transport; + uint8_t transport; enum alpnid alpn_id; BIT(shutdown); }; @@ -124,7 +124,7 @@ struct cf_hc_ctx { static void cf_hc_baller_assign(struct cf_hc_baller *b, enum alpnid alpn_id, - unsigned char def_transport) + uint8_t def_transport) { b->alpn_id = alpn_id; b->transport = def_transport; @@ -148,7 +148,7 @@ static void cf_hc_baller_assign(struct cf_hc_baller *b, static void cf_hc_baller_init(struct cf_hc_baller *b, struct Curl_cfilter *cf, struct Curl_easy *data, - int transport) + uint8_t transport) { struct Curl_cfilter *save = cf->next; @@ -581,7 +581,7 @@ struct Curl_cftype Curl_cft_http_connect = { static CURLcode cf_hc_create(struct Curl_cfilter **pcf, struct Curl_easy *data, enum alpnid *alpnids, size_t alpn_count, - unsigned char def_transport) + uint8_t def_transport) { struct Curl_cfilter *cf = NULL; struct cf_hc_ctx *ctx; @@ -626,7 +626,7 @@ static CURLcode cf_http_connect_add(struct Curl_easy *data, struct connectdata *conn, int sockindex, enum alpnid *alpn_ids, size_t alpn_count, - unsigned char def_transport) + uint8_t def_transport) { struct Curl_cfilter *cf; CURLcode result = CURLE_OK; diff --git a/lib/cf-ip-happy.c b/lib/cf-ip-happy.c index 2e522322c384..eb62cd4c73d3 100644 --- a/lib/cf-ip-happy.c +++ b/lib/cf-ip-happy.c @@ -66,7 +66,7 @@ struct transport_provider { - int transport; + uint8_t transport; cf_ip_connect_create *cf_create; }; @@ -87,7 +87,7 @@ struct transport_provider transport_providers[] = { #endif }; -static cf_ip_connect_create *get_cf_create(int transport) +static cf_ip_connect_create *get_cf_create(uint8_t transport) { size_t i; for(i = 0; i < CURL_ARRAYSIZE(transport_providers); ++i) { @@ -99,7 +99,7 @@ static cf_ip_connect_create *get_cf_create(int transport) #ifdef UNITTESTS /* used by unit2600.c */ -void Curl_debug_set_transport_provider(int transport, +void Curl_debug_set_transport_provider(uint8_t transport, cf_ip_connect_create *cf_create) { size_t i; @@ -172,7 +172,7 @@ struct cf_ip_attempt { struct curltime started; /* start of current attempt */ CURLcode result; int ai_family; - int transport; + uint8_t transport; int error; BIT(connected); /* cf has connected */ BIT(shutdown); /* cf has shutdown */ @@ -195,7 +195,7 @@ static CURLcode cf_ip_attempt_new(struct cf_ip_attempt **pa, struct Curl_easy *data, const struct Curl_addrinfo *addr, int ai_family, - int transport, + uint8_t transport, cf_ip_connect_create *cf_create) { struct Curl_cfilter *wcf; @@ -264,7 +264,7 @@ struct cf_ip_ballers { struct curltime last_attempt_started; timediff_t attempt_delay_ms; int last_attempt_ai_family; - int transport; + uint8_t transport; }; static CURLcode cf_ip_attempt_restart(struct cf_ip_attempt *a, @@ -315,7 +315,7 @@ static void cf_ip_ballers_clear(struct Curl_cfilter *cf, static CURLcode cf_ip_ballers_init(struct cf_ip_ballers *bs, int ip_version, const struct Curl_addrinfo *addr_list, cf_ip_connect_create *cf_create, - int transport, + uint8_t transport, timediff_t attempt_delay_ms) { memset(bs, 0, sizeof(*bs)); @@ -626,7 +626,7 @@ typedef enum { } cf_connect_state; struct cf_ip_happy_ctx { - int transport; + uint8_t transport; cf_ip_connect_create *cf_create; cf_connect_state state; struct cf_ip_ballers ballers; @@ -713,7 +713,7 @@ static CURLcode start_connect(struct Curl_cfilter *cf, return CURLE_OPERATION_TIMEDOUT; } - CURL_TRC_CF(data, cf, "init ip ballers for transport %d", ctx->transport); + CURL_TRC_CF(data, cf, "init ip ballers for transport %u", ctx->transport); ctx->started = curlx_now(); return cf_ip_ballers_init(&ctx->ballers, cf->conn->ip_version, dns->addr, ctx->cf_create, ctx->transport, @@ -933,7 +933,7 @@ static CURLcode cf_ip_happy_create(struct Curl_cfilter **pcf, struct Curl_easy *data, struct connectdata *conn, cf_ip_connect_create *cf_create, - int transport) + uint8_t transport) { struct cf_ip_happy_ctx *ctx = NULL; CURLcode result; @@ -961,7 +961,7 @@ static CURLcode cf_ip_happy_create(struct Curl_cfilter **pcf, CURLcode cf_ip_happy_insert_after(struct Curl_cfilter *cf_at, struct Curl_easy *data, - int transport) + uint8_t transport) { cf_ip_connect_create *cf_create; struct Curl_cfilter *cf; @@ -971,7 +971,7 @@ CURLcode cf_ip_happy_insert_after(struct Curl_cfilter *cf_at, DEBUGASSERT(cf_at); cf_create = get_cf_create(transport); if(!cf_create) { - CURL_TRC_CF(data, cf_at, "unsupported transport type %d", transport); + CURL_TRC_CF(data, cf_at, "unsupported transport type %u", transport); return CURLE_UNSUPPORTED_PROTOCOL; } result = cf_ip_happy_create(&cf, data, cf_at->conn, cf_create, transport); diff --git a/lib/cf-ip-happy.h b/lib/cf-ip-happy.h index 96e619ae4303..2930f21418bf 100644 --- a/lib/cf-ip-happy.h +++ b/lib/cf-ip-happy.h @@ -43,16 +43,16 @@ typedef CURLcode cf_ip_connect_create(struct Curl_cfilter **pcf, struct Curl_easy *data, struct connectdata *conn, const struct Curl_addrinfo *ai, - int transport); + uint8_t transport); CURLcode cf_ip_happy_insert_after(struct Curl_cfilter *cf_at, struct Curl_easy *data, - int transport); + uint8_t transport); extern struct Curl_cftype Curl_cft_ip_happy; #ifdef UNITTESTS -void Curl_debug_set_transport_provider(int transport, +void Curl_debug_set_transport_provider(uint8_t transport, cf_ip_connect_create *cf_create); #endif diff --git a/lib/cf-socket.c b/lib/cf-socket.c index 2930f95fe24c..c657330ec6ed 100644 --- a/lib/cf-socket.c +++ b/lib/cf-socket.c @@ -303,7 +303,7 @@ tcpkeepalive(struct Curl_cfilter *cf, */ static CURLcode sock_assign_addr(struct Curl_sockaddr_ex *dest, const struct Curl_addrinfo *ai, - int transport) + uint8_t transport) { /* * The Curl_sockaddr_ex structure is basically libcurl's external API @@ -404,7 +404,7 @@ static CURLcode socket_open(struct Curl_easy *data, CURLcode Curl_socket_open(struct Curl_easy *data, const struct Curl_addrinfo *ai, struct Curl_sockaddr_ex *addr, - int transport, + uint8_t transport, curl_socket_t *sockfd) { struct Curl_sockaddr_ex dummy; @@ -909,7 +909,7 @@ static CURLcode socket_connect_result(struct Curl_easy *data, } struct cf_socket_ctx { - int transport; + uint8_t transport; struct Curl_sockaddr_ex addr; /* address to connect to */ curl_socket_t sock; /* current attempt socket */ struct ip_quadruple ip; /* The IP quadruple 2x(addr+port) */ @@ -936,7 +936,7 @@ struct cf_socket_ctx { static CURLcode cf_socket_ctx_init(struct cf_socket_ctx *ctx, const struct Curl_addrinfo *ai, - int transport) + uint8_t transport) { CURLcode result; @@ -1035,7 +1035,7 @@ static void set_local_ip(struct Curl_cfilter *cf, { struct cf_socket_ctx *ctx = cf->ctx; ctx->ip.local_ip[0] = 0; - ctx->ip.local_port = -1; + ctx->ip.local_port = 0; #ifdef HAVE_GETSOCKNAME if((ctx->sock != CURL_SOCKET_BAD) && @@ -1069,6 +1069,7 @@ static CURLcode set_remote_ip(struct Curl_cfilter *cf, struct cf_socket_ctx *ctx = cf->ctx; /* store remote address and port used in this connection attempt */ + ctx->ip.transport = ctx->transport; if(!Curl_addr2string(&ctx->addr.curl_sa_addr, (curl_socklen_t)ctx->addr.addrlen, ctx->ip.remote_ip, &ctx->ip.remote_port)) { @@ -1743,7 +1744,7 @@ CURLcode Curl_cf_tcp_create(struct Curl_cfilter **pcf, struct Curl_easy *data, struct connectdata *conn, const struct Curl_addrinfo *ai, - int transport) + uint8_t transport) { struct cf_socket_ctx *ctx = NULL; struct Curl_cfilter *cf = NULL; @@ -1910,7 +1911,7 @@ CURLcode Curl_cf_udp_create(struct Curl_cfilter **pcf, struct Curl_easy *data, struct connectdata *conn, const struct Curl_addrinfo *ai, - int transport) + uint8_t transport) { struct cf_socket_ctx *ctx = NULL; struct Curl_cfilter *cf = NULL; @@ -1964,7 +1965,7 @@ CURLcode Curl_cf_unix_create(struct Curl_cfilter **pcf, struct Curl_easy *data, struct connectdata *conn, const struct Curl_addrinfo *ai, - int transport) + uint8_t transport) { struct cf_socket_ctx *ctx = NULL; struct Curl_cfilter *cf = NULL; diff --git a/lib/cf-socket.h b/lib/cf-socket.h index e5fc176ee19c..432b0870451d 100644 --- a/lib/cf-socket.h +++ b/lib/cf-socket.h @@ -71,7 +71,7 @@ CURLcode Curl_parse_interface(const char *input, CURLcode Curl_socket_open(struct Curl_easy *data, const struct Curl_addrinfo *ai, struct Curl_sockaddr_ex *addr, - int transport, + uint8_t transport, curl_socket_t *sockfd); int Curl_socket_close(struct Curl_easy *data, struct connectdata *conn, @@ -103,7 +103,7 @@ CURLcode Curl_cf_tcp_create(struct Curl_cfilter **pcf, struct Curl_easy *data, struct connectdata *conn, const struct Curl_addrinfo *ai, - int transport); + uint8_t transport); /** * Creates a cfilter that opens a UDP socket to the given address @@ -116,7 +116,7 @@ CURLcode Curl_cf_udp_create(struct Curl_cfilter **pcf, struct Curl_easy *data, struct connectdata *conn, const struct Curl_addrinfo *ai, - int transport); + uint8_t transport); /** * Creates a cfilter that opens a UNIX socket to the given address @@ -129,7 +129,7 @@ CURLcode Curl_cf_unix_create(struct Curl_cfilter **pcf, struct Curl_easy *data, struct connectdata *conn, const struct Curl_addrinfo *ai, - int transport); + uint8_t transport); /** * Creates a cfilter that keeps a listening socket. diff --git a/lib/connect.c b/lib/connect.c index fbb5dcabff26..e29c2f51bcf8 100644 --- a/lib/connect.c +++ b/lib/connect.c @@ -238,7 +238,7 @@ bool Curl_shutdown_started(struct Curl_easy *data, int sockindex) /* retrieves ip address and port from a sockaddr structure. note it calls curlx_inet_ntop which sets errno on fail, not SOCKERRNO. */ bool Curl_addr2string(struct sockaddr *sa, curl_socklen_t salen, - char *addr, int *port) + char *addr, uint16_t *port) { struct sockaddr_in *si = NULL; #ifdef USE_IPV6 @@ -254,8 +254,7 @@ bool Curl_addr2string(struct sockaddr *sa, curl_socklen_t salen, case AF_INET: si = (struct sockaddr_in *)(void *) sa; if(curlx_inet_ntop(sa->sa_family, &si->sin_addr, addr, MAX_IPADR_LEN)) { - unsigned short us_port = ntohs(si->sin_port); - *port = us_port; + *port = ntohs(si->sin_port); return TRUE; } break; @@ -264,8 +263,7 @@ bool Curl_addr2string(struct sockaddr *sa, curl_socklen_t salen, si6 = (struct sockaddr_in6 *)(void *) sa; if(curlx_inet_ntop(sa->sa_family, &si6->sin6_addr, addr, MAX_IPADR_LEN)) { - unsigned short us_port = ntohs(si6->sin6_port); - *port = us_port; + *port = ntohs(si6->sin6_port); return TRUE; } break; @@ -366,7 +364,7 @@ typedef enum { struct cf_setup_ctx { cf_setup_state state; int ssl_mode; - int transport; + uint8_t transport; }; static CURLcode cf_setup_connect(struct Curl_cfilter *cf, @@ -521,7 +519,7 @@ struct Curl_cftype Curl_cft_setup = { static CURLcode cf_setup_create(struct Curl_cfilter **pcf, struct Curl_easy *data, - int transport, + uint8_t transport, int ssl_mode) { struct Curl_cfilter *cf = NULL; @@ -554,7 +552,7 @@ static CURLcode cf_setup_create(struct Curl_cfilter **pcf, static CURLcode cf_setup_add(struct Curl_easy *data, struct connectdata *conn, int sockindex, - int transport, + uint8_t transport, int ssl_mode) { struct Curl_cfilter *cf; @@ -571,7 +569,7 @@ static CURLcode cf_setup_add(struct Curl_easy *data, CURLcode Curl_cf_setup_insert_after(struct Curl_cfilter *cf_at, struct Curl_easy *data, - int transport, + uint8_t transport, int ssl_mode) { struct Curl_cfilter *cf; diff --git a/lib/connect.h b/lib/connect.h index b6d9b8e83698..9060591dcec6 100644 --- a/lib/connect.h +++ b/lib/connect.h @@ -74,7 +74,7 @@ curl_socket_t Curl_getconnectinfo(struct Curl_easy *data, struct connectdata **connp); bool Curl_addr2string(struct sockaddr *sa, curl_socklen_t salen, - char *addr, int *port); + char *addr, uint16_t *port); /* * Curl_conncontrol() marks the end of a connection/stream. The 'closeit' @@ -111,7 +111,7 @@ void Curl_conncontrol(struct connectdata *conn, CURLcode Curl_cf_setup_insert_after(struct Curl_cfilter *cf_at, struct Curl_easy *data, - int transport, + uint8_t transport, int ssl_mode); /** diff --git a/lib/getinfo.c b/lib/getinfo.c index 6a16258b13e1..01c727935620 100644 --- a/lib/getinfo.c +++ b/lib/getinfo.c @@ -81,8 +81,6 @@ void Curl_initinfo(struct Curl_easy *data) info->wouldredirect = NULL; memset(&info->primary, 0, sizeof(info->primary)); - info->primary.remote_port = -1; - info->primary.local_port = -1; info->retry_after = 0; info->conn_scheme = 0; @@ -304,11 +302,17 @@ static CURLcode getinfo_long(struct Curl_easy *data, CURLINFO info, break; case CURLINFO_PRIMARY_PORT: /* Return the (remote) port of the most recent (primary) connection */ - *param_longp = data->info.primary.remote_port; + if(CUR_IP_QUAD_HAS_PORTS(&data->info.primary)) + *param_longp = data->info.primary.remote_port; + else + *param_longp = -1; break; case CURLINFO_LOCAL_PORT: /* Return the local port of the most recent (primary) connection */ - *param_longp = data->info.primary.local_port; + if(CUR_IP_QUAD_HAS_PORTS(&data->info.primary)) + *param_longp = data->info.primary.local_port; + else + *param_longp = -1; break; case CURLINFO_PROXY_ERROR: *param_longp = (long)data->info.pxcode; diff --git a/lib/setopt.c b/lib/setopt.c index fc95389312ad..36f447cdc5bb 100644 --- a/lib/setopt.c +++ b/lib/setopt.c @@ -1001,9 +1001,9 @@ static CURLcode setopt_long(struct Curl_easy *data, CURLoption option, #endif #ifndef CURL_DISABLE_PROXY case CURLOPT_PROXYPORT: - if((arg < 0) || (arg > 65535)) + if((arg < 0) || (arg > UINT16_MAX)) return CURLE_BAD_FUNCTION_ARGUMENT; - s->proxyport = (unsigned short)arg; + s->proxyport = (uint16_t)arg; break; case CURLOPT_PROXYAUTH: diff --git a/lib/url.c b/lib/url.c index b6a60feb38b2..e7f39d5471d1 100644 --- a/lib/url.c +++ b/lib/url.c @@ -2171,7 +2171,6 @@ static CURLcode parse_proxy(struct Curl_easy *data, long proxytype) { char *portptr = NULL; - int port = -1; char *proxyuser = NULL; char *proxypasswd = NULL; char *host = NULL; @@ -2293,24 +2292,23 @@ static CURLcode parse_proxy(struct Curl_easy *data, if(portptr) { curl_off_t num; const char *p = portptr; - if(!curlx_str_number(&p, &num, 0xffff)) - port = (int)num; + if(!curlx_str_number(&p, &num, UINT16_MAX)) + proxyinfo->port = (uint16_t)num; + /* Should we not error out when the port number is invalid? */ free(portptr); } else { if(data->set.proxyport) /* None given in the proxy string, then get the default one if it is given */ - port = (int)data->set.proxyport; + proxyinfo->port = data->set.proxyport; else { if(IS_HTTPS_PROXY(proxytype)) - port = CURL_DEFAULT_HTTPS_PROXY_PORT; + proxyinfo->port = CURL_DEFAULT_HTTPS_PROXY_PORT; else - port = CURL_DEFAULT_PROXY_PORT; + proxyinfo->port = CURL_DEFAULT_PROXY_PORT; } } - if(port >= 0) - proxyinfo->port = port; /* now, clone the proxy hostname */ uc = curl_url_get(uhp, CURLUPART_HOST, &host, CURLU_URLDECODE); diff --git a/lib/urldata.h b/lib/urldata.h index 37ecd1ff9db7..debc2a3e0aa0 100644 --- a/lib/urldata.h +++ b/lib/urldata.h @@ -528,7 +528,7 @@ struct Curl_handler { CURLcode (*follow)(struct Curl_easy *data, const char *newurl, followtype type); - int defport; /* Default port. */ + uint16_t defport; /* Default port. */ curl_prot_t protocol; /* See CURLPROTO_* - this needs to be the single specific protocol bit */ curl_prot_t family; /* single bit for protocol family; basically the @@ -576,26 +576,32 @@ struct Curl_handler { #define CONNRESULT_NONE 0 /* No extra information. */ #define CONNRESULT_DEAD (1<<0) /* The connection is dead. */ +#define TRNSPRT_NONE 0 +#define TRNSPRT_TCP 3 +#define TRNSPRT_UDP 4 +#define TRNSPRT_QUIC 5 +#define TRNSPRT_UNIX 6 + struct ip_quadruple { char remote_ip[MAX_IPADR_LEN]; char local_ip[MAX_IPADR_LEN]; - int remote_port; - int local_port; + uint16_t remote_port; + uint16_t local_port; + uint8_t transport; }; +#define CUR_IP_QUAD_HAS_PORTS(x) (((x)->transport == TRNSPRT_TCP) || \ + ((x)->transport == TRNSPRT_UDP) || \ + ((x)->transport == TRNSPRT_QUIC)) + struct proxy_info { struct hostname host; - int port; + uint16_t port; unsigned char proxytype; /* what kind of proxy that is in use */ char *user; /* proxy username string, allocated */ char *passwd; /* proxy password string, allocated */ }; -#define TRNSPRT_TCP 3 -#define TRNSPRT_UDP 4 -#define TRNSPRT_QUIC 5 -#define TRNSPRT_UNIX 6 - /* * The connectdata struct contains all fields and variables that should be * unique for an entire connection. @@ -1364,7 +1370,7 @@ struct UserDefined { #ifndef CURL_DISABLE_PROXY struct ssl_config_data proxy_ssl; /* user defined SSL stuff for proxy */ struct curl_slist *proxyheaders; /* linked list of extra CONNECT headers */ - unsigned short proxyport; /* If non-zero, use this port number by + uint16_t proxyport; /* If non-zero, use this port number by default. If the proxy string features a ":[port]" that one will override this. */ unsigned char proxytype; /* what kind of proxy */ diff --git a/lib/vquic/vquic.c b/lib/vquic/vquic.c index aa0011c577c4..8b4d678d8118 100644 --- a/lib/vquic/vquic.c +++ b/lib/vquic/vquic.c @@ -687,7 +687,7 @@ CURLcode Curl_cf_quic_create(struct Curl_cfilter **pcf, struct Curl_easy *data, struct connectdata *conn, const struct Curl_addrinfo *ai, - int transport) + uint8_t transport) { (void)transport; DEBUGASSERT(transport == TRNSPRT_QUIC); diff --git a/lib/vquic/vquic.h b/lib/vquic/vquic.h index 0f81334f2937..fd2dac7c22eb 100644 --- a/lib/vquic/vquic.h +++ b/lib/vquic/vquic.h @@ -45,7 +45,7 @@ CURLcode Curl_cf_quic_create(struct Curl_cfilter **pcf, struct Curl_easy *data, struct connectdata *conn, const struct Curl_addrinfo *ai, - int transport); + uint8_t transport); extern struct Curl_cftype Curl_cft_http3; diff --git a/tests/http/test_01_basic.py b/tests/http/test_01_basic.py index aa94238c3f01..14a8dec957fc 100644 --- a/tests/http/test_01_basic.py +++ b/tests/http/test_01_basic.py @@ -96,6 +96,9 @@ def test_01_06_timings(self, env: Env, httpd, nghttpx, proto): # there are cases where time_connect is reported as 0 assert r.stats[0]['time_connect'] >= 0, f'{r.stats[0]}' assert r.stats[0]['time_appconnect'] > 0, f'{r.stats[0]}' + # ports are reported correctly + assert r.stats[0]['remote_port'] == env.port_for(proto), f'{r.dump_logs()}' + assert r.stats[0]['local_port'] > 0, f'{r.dump_logs()}' # simple https: HEAD @pytest.mark.parametrize("proto", Env.http_protos()) diff --git a/tests/http/test_11_unix.py b/tests/http/test_11_unix.py index 2f2db483f404..1432797da26c 100644 --- a/tests/http/test_11_unix.py +++ b/tests/http/test_11_unix.py @@ -109,6 +109,8 @@ def test_11_01_unix_connect_http(self, env: Env, httpd, uds_faker): '--unix-socket', uds_faker.path, ]) r.check_response(count=1, http_status=200) + assert r.stats[0]['remote_port'] == -1, f'{r.dump_logs()}' + assert r.stats[0]['local_port'] == -1, f'{r.dump_logs()}' # download https: via Unix socket @pytest.mark.skipif(condition=not Env.have_ssl_curl(), reason="curl without SSL") @@ -120,6 +122,8 @@ def test_11_02_unix_connect_http(self, env: Env, httpd, uds_faker): '--unix-socket', uds_faker.path, ]) r.check_response(exitcode=35, http_status=None) + assert r.stats[0]['remote_port'] == -1, f'{r.dump_logs()}' + assert r.stats[0]['local_port'] == -1, f'{r.dump_logs()}' # download HTTP/3 via Unix socket @pytest.mark.skipif(condition=not Env.have_h3(), reason='h3 not supported') @@ -132,3 +136,5 @@ def test_11_03_unix_connect_quic(self, env: Env, httpd, uds_faker): '--unix-socket', uds_faker.path, ]) r.check_response(exitcode=96, http_status=None) + assert r.stats[0]['remote_port'] == -1, f'{r.dump_logs()}' + assert r.stats[0]['local_port'] == -1, f'{r.dump_logs()}' diff --git a/tests/unit/unit1607.c b/tests/unit/unit1607.c index 3e4d53d0be5e..f60b5b58a1e4 100644 --- a/tests/unit/unit1607.c +++ b/tests/unit/unit1607.c @@ -141,7 +141,7 @@ static CURLcode test_unit1607(const char *arg) addr = dns ? dns->addr : NULL; for(j = 0; j < addressnum; ++j) { - int port = 0; + uint16_t port = 0; char ipaddress[MAX_IPADR_LEN] = {0}; if(!addr && !tests[i].address[j]) diff --git a/tests/unit/unit1609.c b/tests/unit/unit1609.c index f3f318f2cf97..2a3098c6ef2e 100644 --- a/tests/unit/unit1609.c +++ b/tests/unit/unit1609.c @@ -143,7 +143,7 @@ static CURLcode test_unit1609(const char *arg) addr = dns ? dns->addr : NULL; for(j = 0; j < addressnum; ++j) { - int port = 0; + uint16_t port = 0; char ipaddress[MAX_IPADR_LEN] = {0}; if(!addr && !tests[i].address[j]) diff --git a/tests/unit/unit2600.c b/tests/unit/unit2600.c index 6a03c438dcd9..f2adc50eddd4 100644 --- a/tests/unit/unit2600.c +++ b/tests/unit/unit2600.c @@ -110,7 +110,7 @@ static int test_idx; struct cf_test_ctx { int idx; int ai_family; - int transport; + uint8_t transport; char id[16]; struct curltime started; timediff_t fail_delay_ms; @@ -166,7 +166,7 @@ static CURLcode cf_test_create(struct Curl_cfilter **pcf, struct Curl_easy *data, struct connectdata *conn, const struct Curl_addrinfo *ai, - int transport) + uint8_t transport) { static const struct Curl_cftype cft_test = { "TEST", From fd5a117a6715326749b0e0d18362c50d767e8268 Mon Sep 17 00:00:00 2001 From: Stefan Eissing Date: Thu, 27 Nov 2025 12:50:04 +0100 Subject: [PATCH 081/415] ws: use uint8_t Convert `unsigned char` use to `uint8_t`. Closes #19721 --- lib/ws.c | 82 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/lib/ws.c b/lib/ws.c index b5c02bda9555..36191b2fac0d 100644 --- a/lib/ws.c +++ b/lib/ws.c @@ -91,7 +91,7 @@ struct ws_decoder { int frame_flags; /* See the CURLWS_* defines */ curl_off_t payload_offset; /* the offset parsing is at */ curl_off_t payload_len; - unsigned char head[10]; + uint8_t head[10]; int head_len, head_total; enum ws_dec_state state; int cont_flags; @@ -103,8 +103,8 @@ struct ws_encoder { curl_off_t payload_len; /* payload length of current frame */ curl_off_t payload_remain; /* remaining payload of current */ unsigned int xori; /* xor index */ - unsigned char mask[4]; /* 32-bit mask for this connection */ - unsigned char firstbyte; /* first byte of frame we encode */ + uint8_t mask[4]; /* 32-bit mask for this connection */ + uint8_t firstbyte; /* first byte of frame we encode */ BIT(contfragment); /* set TRUE if the previous fragment sent was not final */ }; @@ -114,7 +114,7 @@ struct ws_encoder { struct ws_cntrl_frame { unsigned int type; size_t payload_len; - unsigned char payload[WS_MAX_CNTRL_LEN]; + uint8_t payload[WS_MAX_CNTRL_LEN]; }; /* A websocket connection with en- and decoder that treat frames @@ -131,7 +131,7 @@ struct websocket { }; -static const char *ws_frame_name_of_op(unsigned char firstbyte) +static const char *ws_frame_name_of_op(uint8_t firstbyte) { switch(firstbyte & WSBIT_OPCODE_MASK) { case WSBIT_OPCODE_CONT: @@ -152,7 +152,7 @@ static const char *ws_frame_name_of_op(unsigned char firstbyte) } static int ws_frame_firstbyte2flags(struct Curl_easy *data, - unsigned char firstbyte, int cont_flags) + uint8_t firstbyte, int cont_flags) { switch(firstbyte) { /* 0x00 - intermediate TEXT/BINARY fragment */ @@ -233,7 +233,7 @@ static int ws_frame_firstbyte2flags(struct Curl_easy *data, static CURLcode ws_frame_flags2firstbyte(struct Curl_easy *data, unsigned int flags, bool contfragment, - unsigned char *pfirstbyte) + uint8_t *pfirstbyte) { *pfirstbyte = 0; switch(flags & ~CURLWS_OFFSET) { @@ -326,7 +326,7 @@ static CURLcode ws_send_raw_blocking(struct Curl_easy *data, struct websocket *ws, const char *buffer, size_t buflen); -typedef CURLcode ws_write_payload(const unsigned char *buf, size_t buflen, +typedef CURLcode ws_write_payload(const uint8_t *buf, size_t buflen, int frame_age, int frame_flags, curl_off_t payload_offset, curl_off_t payload_len, @@ -364,7 +364,7 @@ static CURLcode ws_dec_read_head(struct ws_decoder *dec, struct Curl_easy *data, struct bufq *inraw) { - const unsigned char *inbuf; + const uint8_t *inbuf; size_t inlen; while(Curl_bufq_peek(inraw, &inbuf, &inlen)) { @@ -486,7 +486,7 @@ static CURLcode ws_dec_pass_payload(struct ws_decoder *dec, ws_write_payload *write_cb, void *write_ctx) { - const unsigned char *inbuf; + const uint8_t *inbuf; size_t inlen; size_t nwritten; CURLcode result; @@ -544,7 +544,7 @@ static CURLcode ws_dec_pass(struct ws_decoder *dec, dec->state = WS_DEC_PAYLOAD; if(dec->payload_len == 0) { size_t nwritten; - const unsigned char tmp = '\0'; + const uint8_t tmp = '\0'; /* special case of a 0 length frame, need to write once */ result = write_cb(&tmp, 0, dec->frame_age, dec->frame_flags, 0, 0, write_ctx, &nwritten); @@ -617,7 +617,7 @@ static CURLcode ws_flush(struct Curl_easy *data, struct websocket *ws, bool blocking); static CURLcode ws_enc_send(struct Curl_easy *data, struct websocket *ws, - const unsigned char *buffer, + const uint8_t *buffer, size_t buflen, curl_off_t fragsize, unsigned int flags, @@ -627,7 +627,7 @@ static CURLcode ws_enc_add_pending(struct Curl_easy *data, static CURLcode ws_enc_add_cntrl(struct Curl_easy *data, struct websocket *ws, - const unsigned char *payload, + const uint8_t *payload, size_t plen, unsigned int frame_type) { @@ -663,7 +663,7 @@ static curl_off_t ws_payload_remain(curl_off_t payload_total, return remain - buffered; } -static CURLcode ws_cw_dec_next(const unsigned char *buf, size_t buflen, +static CURLcode ws_cw_dec_next(const uint8_t *buf, size_t buflen, int frame_age, int frame_flags, curl_off_t payload_offset, curl_off_t payload_len, @@ -729,7 +729,7 @@ static CURLcode ws_cw_write(struct Curl_easy *data, if(nbytes) { size_t nwritten; - result = Curl_bufq_write(&ctx->buf, (const unsigned char *)buf, + result = Curl_bufq_write(&ctx->buf, (const uint8_t *)buf, nbytes, &nwritten); if(result) { infof(data, "[WS] error adding data to buffer %d", result); @@ -827,8 +827,8 @@ static CURLcode ws_enc_add_frame(struct Curl_easy *data, curl_off_t payload_len, struct bufq *out) { - unsigned char firstb = 0; - unsigned char head[14]; + uint8_t firstb = 0; + uint8_t head[14]; CURLcode result; size_t hlen, nwritten; @@ -871,24 +871,24 @@ static CURLcode ws_enc_add_frame(struct Curl_easy *data, head[0] = enc->firstbyte = firstb; if(payload_len > 65535) { head[1] = 127 | WSBIT_MASK; - head[2] = (unsigned char)((payload_len >> 56) & 0xff); - head[3] = (unsigned char)((payload_len >> 48) & 0xff); - head[4] = (unsigned char)((payload_len >> 40) & 0xff); - head[5] = (unsigned char)((payload_len >> 32) & 0xff); - head[6] = (unsigned char)((payload_len >> 24) & 0xff); - head[7] = (unsigned char)((payload_len >> 16) & 0xff); - head[8] = (unsigned char)((payload_len >> 8) & 0xff); - head[9] = (unsigned char)(payload_len & 0xff); + head[2] = (uint8_t)((payload_len >> 56) & 0xff); + head[3] = (uint8_t)((payload_len >> 48) & 0xff); + head[4] = (uint8_t)((payload_len >> 40) & 0xff); + head[5] = (uint8_t)((payload_len >> 32) & 0xff); + head[6] = (uint8_t)((payload_len >> 24) & 0xff); + head[7] = (uint8_t)((payload_len >> 16) & 0xff); + head[8] = (uint8_t)((payload_len >> 8) & 0xff); + head[9] = (uint8_t)(payload_len & 0xff); hlen = 10; } else if(payload_len >= 126) { head[1] = 126 | WSBIT_MASK; - head[2] = (unsigned char)((payload_len >> 8) & 0xff); - head[3] = (unsigned char)(payload_len & 0xff); + head[2] = (uint8_t)((payload_len >> 8) & 0xff); + head[3] = (uint8_t)(payload_len & 0xff); hlen = 4; } else { - head[1] = (unsigned char)payload_len | WSBIT_MASK; + head[1] = (uint8_t)payload_len | WSBIT_MASK; hlen = 2; } @@ -897,7 +897,7 @@ static CURLcode ws_enc_add_frame(struct Curl_easy *data, /* 4 bytes random */ - result = Curl_rand(data, (unsigned char *)&enc->mask, sizeof(enc->mask)); + result = Curl_rand(data, (uint8_t *)&enc->mask, sizeof(enc->mask)); if(result) return result; @@ -943,7 +943,7 @@ static CURLcode ws_enc_write_head(struct Curl_easy *data, static CURLcode ws_enc_write_payload(struct ws_encoder *enc, struct Curl_easy *data, - const unsigned char *buf, size_t buflen, + const uint8_t *buf, size_t buflen, struct bufq *out, size_t *pnwritten) { CURLcode result; @@ -960,7 +960,7 @@ static CURLcode ws_enc_write_payload(struct ws_encoder *enc, len = remain; for(i = 0; i < len; ++i) { - unsigned char c = buf[i] ^ enc->mask[enc->xori]; + uint8_t c = buf[i] ^ enc->mask[enc->xori]; result = Curl_bufq_write(out, &c, 1, &n); if(result) { if((result != CURLE_AGAIN) || !i) @@ -1020,7 +1020,7 @@ static CURLcode ws_enc_add_pending(struct Curl_easy *data, static CURLcode ws_enc_send(struct Curl_easy *data, struct websocket *ws, - const unsigned char *buffer, + const uint8_t *buffer, size_t buflen, curl_off_t fragsize, unsigned int flags, @@ -1198,7 +1198,7 @@ static CURLcode cr_ws_read(struct Curl_easy *data, goto out; } - result = ws_enc_write_payload(&ws->enc, data, (unsigned char *)buf, + result = ws_enc_write_payload(&ws->enc, data, (uint8_t *)buf, nread, &ws->sendbuf, &n); if(result) goto out; @@ -1244,7 +1244,7 @@ CURLcode Curl_ws_request(struct Curl_easy *data, struct dynbuf *req) { unsigned int i; CURLcode result = CURLE_OK; - unsigned char rand[16]; + uint8_t rand[16]; char *randstr; size_t randlen; char keyval[40]; @@ -1273,7 +1273,7 @@ CURLcode Curl_ws_request(struct Curl_easy *data, struct dynbuf *req) heads[2].val = &keyval[0]; /* 16 bytes random */ - result = Curl_rand(data, (unsigned char *)rand, sizeof(rand)); + result = Curl_rand(data, rand, sizeof(rand)); if(result) return result; result = curlx_base64_encode((char *)rand, sizeof(rand), &randstr, &randlen); @@ -1393,7 +1393,7 @@ CURLcode Curl_ws_accept(struct Curl_easy *data, /* In CONNECT_ONLY setup, the payloads from `mem` need to be received * when using `curl_ws_recv` later on after this transfer is already * marked as DONE. */ - result = Curl_bufq_write(&ws->recvbuf, (const unsigned char *)mem, + result = Curl_bufq_write(&ws->recvbuf, (const uint8_t *)mem, nread, &nwritten); if(result) goto out; @@ -1452,7 +1452,7 @@ CURLcode Curl_ws_accept(struct Curl_easy *data, struct ws_collect { struct Curl_easy *data; struct websocket *ws; - unsigned char *buffer; + uint8_t *buffer; size_t buflen; size_t bufidx; int frame_age; @@ -1462,7 +1462,7 @@ struct ws_collect { bool written; }; -static CURLcode ws_client_collect(const unsigned char *buf, size_t buflen, +static CURLcode ws_client_collect(const uint8_t *buf, size_t buflen, int frame_age, int frame_flags, curl_off_t payload_offset, curl_off_t payload_len, @@ -1519,7 +1519,7 @@ static CURLcode ws_client_collect(const unsigned char *buf, size_t buflen, } static CURLcode nw_in_recv(void *reader_ctx, - unsigned char *buf, size_t buflen, + uint8_t *buf, size_t buflen, size_t *pnread) { struct Curl_easy *data = reader_ctx; @@ -1628,7 +1628,7 @@ static CURLcode ws_flush(struct Curl_easy *data, struct websocket *ws, { if(!Curl_bufq_is_empty(&ws->sendbuf)) { CURLcode result; - const unsigned char *out; + const uint8_t *out; size_t outlen, n; #ifdef DEBUGBUILD /* Simulate a blocking send after this chunk has been sent */ @@ -1766,7 +1766,7 @@ CURLcode curl_ws_send(CURL *d, const void *buffer_arg, unsigned int flags) { struct websocket *ws; - const unsigned char *buffer = buffer_arg; + const uint8_t *buffer = buffer_arg; CURLcode result = CURLE_OK; struct Curl_easy *data = d; size_t ndummy; From bbb929112b13643842eb9dbfa060bd83a5b5cf03 Mon Sep 17 00:00:00 2001 From: Stefan Eissing Date: Thu, 27 Nov 2025 13:18:09 +0100 Subject: [PATCH 082/415] curlx_base64_encode: use uint8_t* for input Change `inputbuff` parameter from `const char *` to `const uint8_t *` to reflect the binary nature of the input bytes. Half the code was casting unsigned char to signed already in calling. Closes #19722 --- lib/curl_sasl.c | 2 +- lib/curlx/base64.c | 10 +++++----- lib/curlx/base64.h | 6 +++--- lib/http.c | 3 ++- lib/http2.c | 3 +-- lib/http_ntlm.c | 4 ++-- lib/ldap.c | 3 ++- lib/openldap.c | 3 ++- lib/vauth/digest.c | 2 +- lib/vauth/spnego_sspi.c | 2 +- lib/vssh/libssh2.c | 2 +- lib/vtls/openssl.c | 4 ++-- lib/vtls/vtls.c | 2 +- lib/vtls/wolfssl.c | 2 +- lib/vtls/x509asn1.c | 2 +- lib/ws.c | 2 +- src/tool_ssls.c | 4 ++-- src/var.c | 2 +- tests/unit/unit1302.c | 5 +++-- 19 files changed, 33 insertions(+), 30 deletions(-) diff --git a/lib/curl_sasl.c b/lib/curl_sasl.c index 1c9f259de471..f6ec668bfd45 100644 --- a/lib/curl_sasl.c +++ b/lib/curl_sasl.c @@ -267,7 +267,7 @@ static CURLcode build_message(struct SASL *sasl, struct bufref *msg) char *base64; size_t base64len; - result = curlx_base64_encode((const char *) Curl_bufref_ptr(msg), + result = curlx_base64_encode(Curl_bufref_ptr(msg), Curl_bufref_len(msg), &base64, &base64len); if(!result) Curl_bufref_set(msg, base64, base64len, curl_free); diff --git a/lib/curlx/base64.c b/lib/curlx/base64.c index ef07243dd3c5..3fcd709d1ce8 100644 --- a/lib/curlx/base64.c +++ b/lib/curlx/base64.c @@ -66,7 +66,7 @@ static const unsigned char decodetable[] = * @unittest: 1302 */ CURLcode curlx_base64_decode(const char *src, - unsigned char **outptr, size_t *outlen) + uint8_t **outptr, size_t *outlen) { size_t srclen = 0; size_t padding = 0; @@ -170,8 +170,8 @@ CURLcode curlx_base64_decode(const char *src, } static CURLcode base64_encode(const char *table64, - unsigned char padbyte, - const char *inputbuff, size_t insize, + uint8_t padbyte, + const uint8_t *inputbuff, size_t insize, char **outptr, size_t *outlen) { char *output; @@ -245,7 +245,7 @@ static CURLcode base64_encode(const char *table64, * * @unittest: 1302 */ -CURLcode curlx_base64_encode(const char *inputbuff, size_t insize, +CURLcode curlx_base64_encode(const uint8_t *inputbuff, size_t insize, char **outptr, size_t *outlen) { return base64_encode(Curl_base64encdec, '=', @@ -267,7 +267,7 @@ CURLcode curlx_base64_encode(const char *inputbuff, size_t insize, * * @unittest: 1302 */ -CURLcode curlx_base64url_encode(const char *inputbuff, size_t insize, +CURLcode curlx_base64url_encode(const uint8_t *inputbuff, size_t insize, char **outptr, size_t *outlen) { return base64_encode(base64url, 0, inputbuff, insize, outptr, outlen); diff --git a/lib/curlx/base64.h b/lib/curlx/base64.h index 31cfcb36e767..3c97ecc9fec1 100644 --- a/lib/curlx/base64.h +++ b/lib/curlx/base64.h @@ -24,12 +24,12 @@ * ***************************************************************************/ -CURLcode curlx_base64_encode(const char *inputbuff, size_t insize, +CURLcode curlx_base64_encode(const uint8_t *inputbuff, size_t insize, char **outptr, size_t *outlen); -CURLcode curlx_base64url_encode(const char *inputbuff, size_t insize, +CURLcode curlx_base64url_encode(const uint8_t *inputbuff, size_t insize, char **outptr, size_t *outlen); CURLcode curlx_base64_decode(const char *src, - unsigned char **outptr, size_t *outlen); + uint8_t **outptr, size_t *outlen); extern const char Curl_base64encdec[]; diff --git a/lib/http.c b/lib/http.c index 0319be3b657b..672183db0ef2 100644 --- a/lib/http.c +++ b/lib/http.c @@ -367,7 +367,8 @@ static CURLcode http_output_basic(struct Curl_easy *data, bool proxy) if(!out) return CURLE_OUT_OF_MEMORY; - result = curlx_base64_encode(out, strlen(out), &authorization, &size); + result = curlx_base64_encode((uint8_t *)out, strlen(out), + &authorization, &size); if(result) goto fail; diff --git a/lib/http2.c b/lib/http2.c index 4f5f5ea52dd3..4f49efe768b4 100644 --- a/lib/http2.c +++ b/lib/http2.c @@ -1847,8 +1847,7 @@ CURLcode Curl_http2_request_upgrade(struct dynbuf *req, return CURLE_FAILED_INIT; } - result = curlx_base64url_encode((const char *)binsettings, binlen, - &base64, &blen); + result = curlx_base64url_encode(binsettings, binlen, &base64, &blen); if(result) { curlx_dyn_free(req); return result; diff --git a/lib/http_ntlm.c b/lib/http_ntlm.c index fa375b49bfc6..8cb6403fdb8b 100644 --- a/lib/http_ntlm.c +++ b/lib/http_ntlm.c @@ -205,7 +205,7 @@ CURLcode Curl_output_ntlm(struct Curl_easy *data, bool proxy) hostname, ntlm, &ntlmmsg); if(!result) { DEBUGASSERT(Curl_bufref_len(&ntlmmsg) != 0); - result = curlx_base64_encode((const char *) Curl_bufref_ptr(&ntlmmsg), + result = curlx_base64_encode(Curl_bufref_ptr(&ntlmmsg), Curl_bufref_len(&ntlmmsg), &base64, &len); if(!result) { free(*allocuserpwd); @@ -224,7 +224,7 @@ CURLcode Curl_output_ntlm(struct Curl_easy *data, bool proxy) result = Curl_auth_create_ntlm_type3_message(data, userp, passwdp, ntlm, &ntlmmsg); if(!result && Curl_bufref_len(&ntlmmsg)) { - result = curlx_base64_encode((const char *) Curl_bufref_ptr(&ntlmmsg), + result = curlx_base64_encode(Curl_bufref_ptr(&ntlmmsg), Curl_bufref_len(&ntlmmsg), &base64, &len); if(!result) { free(*allocuserpwd); diff --git a/lib/ldap.c b/lib/ldap.c index fa1a4a4d25c5..7f2af3664325 100644 --- a/lib/ldap.c +++ b/lib/ldap.c @@ -626,7 +626,8 @@ static CURLcode ldap_do(struct Curl_easy *data, bool *done) curl_strequal(";binary", attr + (attr_len - 7)) ) { /* Binary attribute, encode to base64. */ if(vals[i]->bv_len) { - result = curlx_base64_encode(vals[i]->bv_val, vals[i]->bv_len, + result = curlx_base64_encode((uint8_t *)vals[i]->bv_val, + vals[i]->bv_len, &val_b64, &val_b64_sz); if(result) { ldap_value_free_len(vals); diff --git a/lib/openldap.c b/lib/openldap.c index 41419df21b20..806ccb33ccd1 100644 --- a/lib/openldap.c +++ b/lib/openldap.c @@ -1213,7 +1213,8 @@ static CURLcode oldap_recv(struct Curl_easy *data, int sockindex, char *buf, /* Binary value, encode to base64. */ if(bvals[i].bv_len) - result = curlx_base64_encode(bvals[i].bv_val, bvals[i].bv_len, + result = curlx_base64_encode((uint8_t *)bvals[i].bv_val, + bvals[i].bv_len, &val_b64, &val_b64_sz); if(!result) result = client_write(data, STRCONST(": "), val_b64, val_b64_sz, diff --git a/lib/vauth/digest.c b/lib/vauth/digest.c index c1c0ab2ab219..16045707fd1e 100644 --- a/lib/vauth/digest.c +++ b/lib/vauth/digest.c @@ -710,7 +710,7 @@ static CURLcode auth_create_digest_http_message( if(result) return result; - result = curlx_base64_encode(cnoncebuf, sizeof(cnoncebuf), + result = curlx_base64_encode((uint8_t *)cnoncebuf, sizeof(cnoncebuf), &cnonce, &cnonce_sz); if(result) return result; diff --git a/lib/vauth/spnego_sspi.c b/lib/vauth/spnego_sspi.c index 9cf554d3b061..b36535557bd9 100644 --- a/lib/vauth/spnego_sspi.c +++ b/lib/vauth/spnego_sspi.c @@ -301,7 +301,7 @@ CURLcode Curl_auth_create_spnego_message(struct negotiatedata *nego, char **outptr, size_t *outlen) { /* Base64 encode the already generated response */ - CURLcode result = curlx_base64_encode((const char *)nego->output_token, + CURLcode result = curlx_base64_encode(nego->output_token, nego->output_token_length, outptr, outlen); if(!result && (!*outptr || !*outlen)) { diff --git a/lib/vssh/libssh2.c b/lib/vssh/libssh2.c index 1c9fe5ac0154..e4ceda8c3494 100644 --- a/lib/vssh/libssh2.c +++ b/lib/vssh/libssh2.c @@ -602,7 +602,7 @@ static CURLcode ssh_check_fingerprint(struct Curl_easy *data, /* The length of fingerprint is 32 bytes for SHA256. * See libssh2_hostkey_hash documentation. */ - if(curlx_base64_encode(fingerprint, 32, &fingerprint_b64, + if(curlx_base64_encode((const uint8_t *)fingerprint, 32, &fingerprint_b64, &fingerprint_b64_len) != CURLE_OK) { myssh_state(data, sshc, SSH_SESSION_FREE); return CURLE_PEER_FAILED_VERIFICATION; diff --git a/lib/vtls/openssl.c b/lib/vtls/openssl.c index 2f526479c5f4..7ff5698e7c30 100644 --- a/lib/vtls/openssl.c +++ b/lib/vtls/openssl.c @@ -4132,7 +4132,7 @@ static void ossl_trace_ech_retry_configs(struct Curl_easy *data, SSL* ssl, int rv = 1; # ifndef HAVE_BORINGSSL_LIKE char *inner = NULL; - unsigned char *rcs = NULL; + uint8_t *rcs = NULL; char *outer = NULL; # else const char *inner = NULL; @@ -4156,7 +4156,7 @@ static void ossl_trace_ech_retry_configs(struct Curl_easy *data, SSL* ssl, char *b64str = NULL; size_t blen = 0; - result = curlx_base64_encode((const char *)rcs, rcl, &b64str, &blen); + result = curlx_base64_encode(rcs, rcl, &b64str, &blen); if(!result && b64str) { infof(data, "ECH: retry_configs %s", b64str); free(b64str); diff --git a/lib/vtls/vtls.c b/lib/vtls/vtls.c index d116ec91edb3..9c76ca7ed32c 100644 --- a/lib/vtls/vtls.c +++ b/lib/vtls/vtls.c @@ -790,7 +790,7 @@ CURLcode Curl_pin_peer_pubkey(struct Curl_easy *data, sha256sumdigest, CURL_SHA256_DIGEST_LENGTH); if(!encode) - encode = curlx_base64_encode((char *)sha256sumdigest, + encode = curlx_base64_encode(sha256sumdigest, CURL_SHA256_DIGEST_LENGTH, &cert_hash, &cert_hash_len); Curl_safefree(sha256sumdigest); diff --git a/lib/vtls/wolfssl.c b/lib/vtls/wolfssl.c index c8fc8c4add1a..e622f909e50b 100644 --- a/lib/vtls/wolfssl.c +++ b/lib/vtls/wolfssl.c @@ -1816,7 +1816,7 @@ static CURLcode wssl_handshake(struct Curl_cfilter *cf, char *b64str = NULL; size_t blen = 0; - result = curlx_base64_encode((const char *)echConfigs, echConfigsLen, + result = curlx_base64_encode(echConfigs, echConfigsLen, &b64str, &blen); if(!result && b64str) infof(data, "ECH: (not yet) retry_configs %s", b64str); diff --git a/lib/vtls/x509asn1.c b/lib/vtls/x509asn1.c index 96eb512b9038..417a5382d873 100644 --- a/lib/vtls/x509asn1.c +++ b/lib/vtls/x509asn1.c @@ -1228,7 +1228,7 @@ CURLcode Curl_extract_certinfo(struct Curl_easy *data, curlx_dyn_reset(&out); /* Generate PEM certificate. */ - result = curlx_base64_encode(cert.certificate.beg, + result = curlx_base64_encode((const uint8_t *)cert.certificate.beg, cert.certificate.end - cert.certificate.beg, &certptr, &clen); if(result) diff --git a/lib/ws.c b/lib/ws.c index 36191b2fac0d..15dc2e9aea7e 100644 --- a/lib/ws.c +++ b/lib/ws.c @@ -1276,7 +1276,7 @@ CURLcode Curl_ws_request(struct Curl_easy *data, struct dynbuf *req) result = Curl_rand(data, rand, sizeof(rand)); if(result) return result; - result = curlx_base64_encode((char *)rand, sizeof(rand), &randstr, &randlen); + result = curlx_base64_encode(rand, sizeof(rand), &randstr, &randlen); if(result) return result; DEBUGASSERT(randlen < sizeof(keyval)); diff --git a/src/tool_ssls.c b/src/tool_ssls.c index 40e67a8044c9..2b67be9baaf8 100644 --- a/src/tool_ssls.c +++ b/src/tool_ssls.c @@ -159,7 +159,7 @@ static CURLcode tool_ssls_exp(CURL *easy, void *userptr, "# This file was generated by libcurl! Edit at your own risk.\n", ctx->fp); - r = curlx_base64_encode((const char *)shmac, shmac_len, &enc, &enc_len); + r = curlx_base64_encode(shmac, shmac_len, &enc, &enc_len); if(r) goto out; r = CURLE_WRITE_ERROR; @@ -168,7 +168,7 @@ static CURLcode tool_ssls_exp(CURL *easy, void *userptr, if(EOF == fputc(':', ctx->fp)) goto out; tool_safefree(enc); - r = curlx_base64_encode((const char *)sdata, sdata_len, &enc, &enc_len); + r = curlx_base64_encode(sdata, sdata_len, &enc, &enc_len); if(r) goto out; r = CURLE_WRITE_ERROR; diff --git a/src/var.c b/src/var.c index 94d79695acc9..5cedf1d24a2c 100644 --- a/src/var.c +++ b/src/var.c @@ -150,7 +150,7 @@ static ParameterError varfunc(char *c, /* content */ if(clen) { char *enc; size_t elen; - CURLcode result = curlx_base64_encode(c, clen, &enc, &elen); + CURLcode result = curlx_base64_encode((uint8_t *)c, clen, &enc, &elen); if(result) { err = PARAM_NO_MEM; break; diff --git a/tests/unit/unit1302.c b/tests/unit/unit1302.c index 2c4404d72702..911432a8c833 100644 --- a/tests/unit/unit1302.c +++ b/tests/unit/unit1302.c @@ -133,7 +133,7 @@ static CURLcode test_unit1302(const char *arg) size_t dlen; /* first encode */ - rc = curlx_base64_encode(e->input, e->ilen, &out, &olen); + rc = curlx_base64_encode((const uint8_t *)e->input, e->ilen, &out, &olen); abort_unless(rc == CURLE_OK, "return code should be CURLE_OK"); abort_unless(olen == e->olen, "wrong output size"); if(memcmp(out, e->output, e->olen)) { @@ -166,7 +166,8 @@ static CURLcode test_unit1302(const char *arg) struct etest *e = &url[i]; char *out; size_t olen; - rc = curlx_base64url_encode(e->input, e->ilen, &out, &olen); + rc = curlx_base64url_encode((const uint8_t *)e->input, e->ilen, + &out, &olen); abort_unless(rc == CURLE_OK, "return code should be CURLE_OK"); if(olen != e->olen) { curl_mfprintf(stderr, "Test %u URL encoded output length %zu " From 71e9920fcd2683bc63ba1f227307560010ce7deb Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Thu, 27 Nov 2025 14:19:48 +0100 Subject: [PATCH 083/415] GHA: add timeouts to mitigate hung brew install step Ref: https://github.com/curl/curl/actions/runs/19736703410/job/56550251534?pr=19723 Closes #19726 --- .github/workflows/checksrc.yml | 2 ++ .github/workflows/configure-vs-cmake.yml | 1 + .github/workflows/distcheck.yml | 1 + .github/workflows/macos.yml | 2 ++ 4 files changed, 6 insertions(+) diff --git a/.github/workflows/checksrc.yml b/.github/workflows/checksrc.yml index 2f7b0b0e941c..d3ef758b4872 100644 --- a/.github/workflows/checksrc.yml +++ b/.github/workflows/checksrc.yml @@ -73,6 +73,7 @@ jobs: .github/scripts/codespell.sh - name: 'typos' + timeout-minutes: 2 run: | HOMEBREW_NO_AUTO_UPDATE=1 /home/linuxbrew/.linuxbrew/bin/brew install typos-cli eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" @@ -148,6 +149,7 @@ jobs: timeout-minutes: 5 steps: - name: 'install prereqs' + timeout-minutes: 2 run: HOMEBREW_NO_AUTO_UPDATE=1 /home/linuxbrew/.linuxbrew/bin/brew install actionlint shellcheck zizmor - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 diff --git a/.github/workflows/configure-vs-cmake.yml b/.github/workflows/configure-vs-cmake.yml index 53775a44fd83..778b306b65ca 100644 --- a/.github/workflows/configure-vs-cmake.yml +++ b/.github/workflows/configure-vs-cmake.yml @@ -81,6 +81,7 @@ jobs: runs-on: macos-latest steps: - name: 'install packages' + timeout-minutes: 2 run: | # shellcheck disable=SC2181,SC2034 while [[ $? == 0 ]]; do for i in 1 2 3; do if brew update && brew install automake libtool; then break 2; else echo Error: wait to try again; sleep 10; fi; done; false Too many retries; done diff --git a/.github/workflows/distcheck.yml b/.github/workflows/distcheck.yml index 442a7f18a10c..86c05fd0f0cc 100644 --- a/.github/workflows/distcheck.yml +++ b/.github/workflows/distcheck.yml @@ -279,6 +279,7 @@ jobs: mingw-w64-x86_64-zlib mingw-w64-x86_64-zstd mingw-w64-x86_64-libpsl mingw-w64-x86_64-libssh2 mingw-w64-x86_64-nghttp2 mingw-w64-x86_64-openssl - name: 'install prereqs' + timeout-minutes: 3 run: | if [[ "${MATRIX_IMAGE}" = *'windows'* ]]; then cd ~ diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index cd72073155c3..25ac41c61ee1 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -94,6 +94,7 @@ jobs: steps: - name: 'brew install' if: ${{ matrix.build.configure }} + timeout-minutes: 5 run: | # shellcheck disable=SC2181,SC2034 while [[ $? == 0 ]]; do for i in 1 2 3; do if brew update && brew install automake libtool; then break 2; else echo Error: wait to try again; sleep 10; fi; done; false Too many retries; done @@ -350,6 +351,7 @@ jobs: steps: - name: 'brew install' + timeout-minutes: 5 # Run this command with retries because of spurious failures seen # while running the tests, for example # https://github.com/curl/curl/runs/4095721123?check_suite_focus=true From eae2df837e8927bc43ab5b8994252f8b0b0f097a Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Thu, 27 Nov 2025 13:02:49 +0100 Subject: [PATCH 084/415] runtests: fix showing `nghttpx-h3` in the `Env:` log when detected Ref: #19723 Closes #19728 --- tests/runtests.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/runtests.pl b/tests/runtests.pl index 54ac77e2e963..3d557d1435ed 100755 --- a/tests/runtests.pl +++ b/tests/runtests.pl @@ -891,7 +891,7 @@ sub checksystemfeatures { $valgrind?"Valgrind ":"", $run_duphandle?"test-duphandle ":"", $run_event_based?"event-based ":"", - $nghttpx_h3, + $nghttpx_h3?"nghttpx-h3 " :"", $libtool?"Libtool ":""); if($env) { logmsg "* Env: $env\n"; From 7a10f493222cad24a1625bfb283523e73647a6f0 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Fri, 21 Nov 2025 13:46:53 +0100 Subject: [PATCH 085/415] badwords: make some words match case-insensitively Also: - wcurl.md: sync with upstream to pass the badwords check. Ref: https://github.com/curl/wcurl/commit/11f840cddd840e03b4281cb7408b246c0d09da0f Ref: https://github.com/curl/wcurl/pull/79 Closes #19713 --- .github/scripts/badwords.txt | 10 +++++----- docs/wcurl.md | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/scripts/badwords.txt b/.github/scripts/badwords.txt index d8f4461d2675..9e43c03fa827 100644 --- a/.github/scripts/badwords.txt +++ b/.github/scripts/badwords.txt @@ -17,7 +17,7 @@ could've:could have couldn't:could not didn't:did not doesn't:does not -don't=do not +don't:do not haven't:have not i'd:I would i'll:I will @@ -74,10 +74,10 @@ file names\b:filenames \buser names\b:usernames \bpass phrase:passphrase \bwill\b:rewrite to present tense -\b32bit=32-bit -\b64bit=64-bit -32 bit\b=32-bit -64 bit\b=64-bit +\b32bit:32-bit +\b64bit:64-bit +32 bit\b:32-bit +64 bit\b:64-bit 64-bits:64 bits or 64-bit 32-bits:32 bits or 32-bit \bvery\b:rephrase using an alternative word diff --git a/docs/wcurl.md b/docs/wcurl.md index 7d1200b2ea70..ab5c3aaa9722 100644 --- a/docs/wcurl.md +++ b/docs/wcurl.md @@ -87,7 +87,7 @@ last value is considered. ## --no-decode-filename -Don't percent-decode the output filename, even if the percent-encoding in the +Do not percent-decode the output filename, even if the percent-encoding in the URL was done by **wcurl**, e.g.: The URL contained whitespace. ## --dry-run From 0081c5b12627ddfb5d6e71198475dc9f95c0a53e Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Thu, 27 Nov 2025 15:37:19 +0100 Subject: [PATCH 086/415] pytest: disable two H3 earlydata tests for all platforms (was: macOS) Follow-up to 692c7f133e6f9a5053a87b1fffbf3c41697a7742 #19252 Follow-up to eefd03c572996e5de4dec4fe295ad6f103e0eefc #18703 Ref: #19719 Ref: #19723 Fixes #19724 Closes #19730 --- tests/http/test_02_download.py | 8 ++++---- tests/http/test_07_upload.py | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/http/test_02_download.py b/tests/http/test_02_download.py index dcfe9690bcb4..9fbc116caf0a 100644 --- a/tests/http/test_02_download.py +++ b/tests/http/test_02_download.py @@ -566,10 +566,10 @@ def test_02_32_earlydata(self, env: Env, httpd, nghttpx, proto): pytest.skip("h3 early data not supported") if proto != 'h3' and sys.platform.startswith('darwin') and env.ci_run: pytest.skip('failing on macOS CI runners') - if proto == 'h3' and sys.platform.startswith('darwin') and env.curl_uses_lib('wolfssl'): - pytest.skip('h3 wolfssl early data failing on macOS') - if proto == 'h3' and sys.platform.startswith('darwin') and env.curl_uses_lib('gnutls'): - pytest.skip('h3 gnutls early data failing on macOS') + if proto == 'h3' and env.curl_uses_lib('wolfssl'): + pytest.skip('h3 wolfssl early data failing') + if proto == 'h3' and env.curl_uses_lib('gnutls'): + pytest.skip('h3 gnutls early data failing') count = 2 docname = 'data-10k' # we want this test to always connect to nghttpx, since it is diff --git a/tests/http/test_07_upload.py b/tests/http/test_07_upload.py index 9e49ad7f4737..495ec7a98955 100644 --- a/tests/http/test_07_upload.py +++ b/tests/http/test_07_upload.py @@ -663,10 +663,10 @@ def test_07_70_put_earlydata(self, env: Env, httpd, nghttpx, proto, upload_size, pytest.skip("h3 not supported") if proto != 'h3' and sys.platform.startswith('darwin') and env.ci_run: pytest.skip('failing on macOS CI runners') - if proto == 'h3' and sys.platform.startswith('darwin') and env.curl_uses_lib('wolfssl'): - pytest.skip('h3 wolfssl early data failing on macOS') - if proto == 'h3' and sys.platform.startswith('darwin') and env.curl_uses_lib('gnutls'): - pytest.skip('h3 gnutls early data failing on macOS') + if proto == 'h3' and env.curl_uses_lib('wolfssl'): + pytest.skip('h3 wolfssl early data failing') + if proto == 'h3' and env.curl_uses_lib('gnutls'): + pytest.skip('h3 gnutls early data failing') count = 2 # we want this test to always connect to nghttpx, since it is # the only server we have that supports TLS earlydata From c8b76ff42f5228b0c8e3a9d51755ec7f318af6ba Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Thu, 27 Nov 2025 13:44:27 +0100 Subject: [PATCH 087/415] GHA/http3-linux: fix broken h3 server in non-openssl jobs, for more pytests It also revealed 3 failing earlydata tests with two backends on Linux, seen earlier on macOS: ``` LibreSSL before: 571 passed, 141 skipped in 45.34s LibreSSL after: 736 passed, 95 skipped in 68.08s aws-lc before: 571 passed, 141 skipped in 78.87s aws-lc after: 736 passed, 95 skipped in 66.71s BoringSSL before: 511 passed, 201 skipped in 46.47s BoringSSL after: 676 passed, 155 skipped in 63.96s GnuTLS before: 515 passed, 197 skipped in 48.31s GnuTLS after: 688 passed, 140 skipped in 67.79s (3 failed) wolfSSL before: 541 passed, 171 skipped in 52.49s wolfSSL after: 714 passed, 114 skipped in 83.84s (3 failed) OpenSSL before: 757 passed, 74 skipped in 65.43s OpenSSL after: 757 passed, 74 skipped in 65.06s OpenSSL-quic before: 741 passed, 90 skipped in 62.85s OpenSSL-quic after: 741 passed, 90 skipped in 57.20s quiche before: 511 passed, 201 skipped in 45.94s quiche after: 664 passed, 167 skipped in 59.57s ``` Before: https://github.com/curl/curl/actions/runs/19734972379 After: https://github.com/curl/curl/actions/runs/19736703398?pr=19723 Failures address via: 0081c5b12627ddfb5d6e71198475dc9f95c0a53e #19730 Ref: #19724 Closes #19723 --- .github/workflows/http3-linux.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/http3-linux.yml b/.github/workflows/http3-linux.yml index 87738dd79138..353c36814219 100644 --- a/.github/workflows/http3-linux.yml +++ b/.github/workflows/http3-linux.yml @@ -486,7 +486,6 @@ jobs: echo 'CXX=g++-12' >> "$GITHUB_ENV" - name: 'cache openssl' - if: ${{ matrix.build.name == 'openssl' || matrix.build.name == 'openssl-quic' }} uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 id: cache-openssl-http3-no-deprecated env: From a59a3cc7f1593784e496172b9fb4d82ed6fae487 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 27 Nov 2025 14:25:43 +0100 Subject: [PATCH 088/415] cfilters: make conn_forget_socket a private libssh function It is only used for (old) libssh builds. Closes #19727 --- lib/cfilters.c | 13 ------------- lib/vssh/libssh.c | 15 ++++++++++++++- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/cfilters.c b/lib/cfilters.c index f0da4778a685..31c7b07747c1 100644 --- a/lib/cfilters.c +++ b/lib/cfilters.c @@ -931,19 +931,6 @@ Curl_conn_get_remote_addr(struct Curl_easy *data, int sockindex) return cf ? cf_get_remote_addr(cf, data) : NULL; } -void Curl_conn_forget_socket(struct Curl_easy *data, int sockindex) -{ - struct connectdata *conn = data->conn; - if(conn && CONN_SOCK_IDX_VALID(sockindex)) { - struct Curl_cfilter *cf = conn->cfilter[sockindex]; - if(cf) - (void)Curl_conn_cf_cntrl(cf, data, TRUE, - CF_CTRL_FORGET_SOCKET, 0, NULL); - fake_sclose(conn->sock[sockindex]); - conn->sock[sockindex] = CURL_SOCKET_BAD; - } -} - static CURLcode cf_cntrl_all(struct connectdata *conn, struct Curl_easy *data, bool ignore_result, diff --git a/lib/vssh/libssh.c b/lib/vssh/libssh.c index c76478bc2a57..4b003bd71ca9 100644 --- a/lib/vssh/libssh.c +++ b/lib/vssh/libssh.c @@ -1874,6 +1874,19 @@ static int myssh_in_SFTP_QUOTE_STAT(struct Curl_easy *data, return SSH_NO_ERROR; } +static void conn_forget_socket(struct Curl_easy *data, int sockindex) +{ + struct connectdata *conn = data->conn; + if(conn && CONN_SOCK_IDX_VALID(sockindex)) { + struct Curl_cfilter *cf = conn->cfilter[sockindex]; + if(cf) + (void)Curl_conn_cf_cntrl(cf, data, TRUE, + CF_CTRL_FORGET_SOCKET, 0, NULL); + fake_sclose(conn->sock[sockindex]); + conn->sock[sockindex] = CURL_SOCKET_BAD; + } +} + /* * 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 @@ -2376,7 +2389,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, /* conn->sock[FIRSTSOCKET] is closed by ssh_disconnect behind our back, tell the connection to forget about it. This libssh bug is fixed in 0.10.0. */ - Curl_conn_forget_socket(data, FIRSTSOCKET); + conn_forget_socket(data, FIRSTSOCKET); } SSH_STRING_FREE_CHAR(sshc->homedir); From 1e048e932acfe8e46a1e33fb5d7d51406b12e23b Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 27 Nov 2025 14:19:34 +0100 Subject: [PATCH 089/415] ngtcp2: remove the unused Curl_conn_is_ngtcp2 function Closes #19725 --- lib/vquic/curl_ngtcp2.c | 16 ---------------- lib/vquic/curl_ngtcp2.h | 4 ---- 2 files changed, 20 deletions(-) diff --git a/lib/vquic/curl_ngtcp2.c b/lib/vquic/curl_ngtcp2.c index de767f28dc04..22ea0e3ef493 100644 --- a/lib/vquic/curl_ngtcp2.c +++ b/lib/vquic/curl_ngtcp2.c @@ -2880,20 +2880,4 @@ CURLcode Curl_cf_ngtcp2_create(struct Curl_cfilter **pcf, return result; } -bool Curl_conn_is_ngtcp2(const struct Curl_easy *data, - const struct connectdata *conn, - int sockindex) -{ - struct Curl_cfilter *cf = conn ? conn->cfilter[sockindex] : NULL; - - (void)data; - for(; cf; cf = cf->next) { - if(cf->cft == &Curl_cft_http3) - return TRUE; - if(cf->cft->flags & CF_TYPE_IP_CONNECT) - return FALSE; - } - return FALSE; -} - #endif diff --git a/lib/vquic/curl_ngtcp2.h b/lib/vquic/curl_ngtcp2.h index 86753a3a6ba8..7933e924e1c7 100644 --- a/lib/vquic/curl_ngtcp2.h +++ b/lib/vquic/curl_ngtcp2.h @@ -55,10 +55,6 @@ CURLcode Curl_cf_ngtcp2_create(struct Curl_cfilter **pcf, struct Curl_easy *data, struct connectdata *conn, const struct Curl_addrinfo *ai); - -bool Curl_conn_is_ngtcp2(const struct Curl_easy *data, - const struct connectdata *conn, - int sockindex); #endif #endif /* HEADER_CURL_VQUIC_CURL_NGTCP2_H */ From 56e88e7c14dd1a529f9a4f23db5f791302bba6e7 Mon Sep 17 00:00:00 2001 From: Stefan Eissing Date: Thu, 27 Nov 2025 15:13:11 +0100 Subject: [PATCH 090/415] cfilter: send uint8_t bytes Change the send parameter from `const void *` to `const uint8_t *` and adapt calling code. Several had already unsigned chars and were casting. Closes #19729 --- lib/cf-h1-proxy.c | 4 ++-- lib/cf-h2-proxy.c | 6 +++--- lib/cf-haproxy.c | 2 +- lib/cf-socket.c | 2 +- lib/cfilters.c | 9 ++++----- lib/cfilters.h | 6 +++--- lib/http2.c | 6 +++--- lib/socks_gssapi.c | 12 +++++------- lib/socks_sspi.c | 13 +++++-------- lib/vquic/curl_ngtcp2.c | 6 +++--- lib/vquic/curl_osslq.c | 6 +++--- lib/vquic/curl_quiche.c | 8 ++++---- lib/vtls/mbedtls.c | 3 +-- lib/vtls/openssl.c | 3 ++- lib/vtls/rustls.c | 2 +- lib/vtls/schannel.c | 12 ++++++++---- lib/vtls/vtls.c | 4 ++-- lib/vtls/wolfssl.c | 3 ++- 18 files changed, 53 insertions(+), 54 deletions(-) diff --git a/lib/cf-h1-proxy.c b/lib/cf-h1-proxy.c index e496d7634dce..417b4df67e29 100644 --- a/lib/cf-h1-proxy.c +++ b/lib/cf-h1-proxy.c @@ -246,7 +246,7 @@ static CURLcode send_CONNECT(struct Curl_cfilter *cf, struct h1_tunnel_state *ts, bool *done) { - char *buf = curlx_dyn_ptr(&ts->request_data); + uint8_t *buf = curlx_dyn_uptr(&ts->request_data); size_t request_len = curlx_dyn_len(&ts->request_data); size_t blen = request_len; CURLcode result = CURLE_OK; @@ -267,7 +267,7 @@ static CURLcode send_CONNECT(struct Curl_cfilter *cf, DEBUGASSERT(blen >= nwritten); ts->nsent += nwritten; - Curl_debug(data, CURLINFO_HEADER_OUT, buf, nwritten); + Curl_debug(data, CURLINFO_HEADER_OUT, (char *)buf, nwritten); out: if(result) diff --git a/lib/cf-h2-proxy.c b/lib/cf-h2-proxy.c index 89bc7cc23f48..fca916a2c24f 100644 --- a/lib/cf-h2-proxy.c +++ b/lib/cf-h2-proxy.c @@ -225,7 +225,7 @@ static void drain_tunnel(struct Curl_cfilter *cf, } static CURLcode proxy_h2_nw_out_writer(void *writer_ctx, - const unsigned char *buf, size_t buflen, + const uint8_t *buf, size_t buflen, size_t *pnwritten) { struct Curl_cfilter *cf = writer_ctx; @@ -233,7 +233,7 @@ static CURLcode proxy_h2_nw_out_writer(void *writer_ctx, if(cf) { struct Curl_easy *data = CF_DATA_CURRENT(cf); CURLcode result; - result = Curl_conn_cf_send(cf->next, data, (const char *)buf, buflen, + result = Curl_conn_cf_send(cf->next, data, buf, buflen, FALSE, pnwritten); CURL_TRC_CF(data, cf, "[0] nw_out_writer(len=%zu) -> %d, %zu", buflen, result, *pnwritten); @@ -1356,7 +1356,7 @@ static CURLcode cf_h2_proxy_recv(struct Curl_cfilter *cf, static CURLcode cf_h2_proxy_send(struct Curl_cfilter *cf, struct Curl_easy *data, - const void *buf, size_t len, bool eos, + const uint8_t *buf, size_t len, bool eos, size_t *pnwritten) { struct cf_h2_proxy_ctx *ctx = cf->ctx; diff --git a/lib/cf-haproxy.c b/lib/cf-haproxy.c index 3231791097ed..8912604504d8 100644 --- a/lib/cf-haproxy.c +++ b/lib/cf-haproxy.c @@ -133,7 +133,7 @@ static CURLcode cf_haproxy_connect(struct Curl_cfilter *cf, if(len > 0) { size_t nwritten; result = Curl_conn_cf_send(cf->next, data, - curlx_dyn_ptr(&ctx->data_out), len, FALSE, + curlx_dyn_uptr(&ctx->data_out), len, FALSE, &nwritten); if(result) { if(result != CURLE_AGAIN) diff --git a/lib/cf-socket.c b/lib/cf-socket.c index c657330ec6ed..6e5333602c34 100644 --- a/lib/cf-socket.c +++ b/lib/cf-socket.c @@ -1428,7 +1428,7 @@ static void win_update_sndbuf_size(struct cf_socket_ctx *ctx) #endif /* USE_WINSOCK */ static CURLcode cf_socket_send(struct Curl_cfilter *cf, struct Curl_easy *data, - const void *buf, size_t len, bool eos, + const uint8_t *buf, size_t len, bool eos, size_t *pnwritten) { struct cf_socket_ctx *ctx = cf->ctx; diff --git a/lib/cfilters.c b/lib/cfilters.c index 31c7b07747c1..7cb10f39282f 100644 --- a/lib/cfilters.c +++ b/lib/cfilters.c @@ -85,7 +85,7 @@ bool Curl_cf_def_data_pending(struct Curl_cfilter *cf, } CURLcode Curl_cf_def_send(struct Curl_cfilter *cf, struct Curl_easy *data, - const void *buf, size_t len, bool eos, + const uint8_t *buf, size_t len, bool eos, size_t *pnwritten) { if(cf->next) @@ -296,12 +296,11 @@ CURLcode Curl_cf_recv_bufq(struct Curl_cfilter *cf, } static CURLcode cf_bufq_writer(void *writer_ctx, - const unsigned char *buf, size_t buflen, + const uint8_t *buf, size_t buflen, size_t *pnwritten) { struct cf_io_ctx *io = writer_ctx; - return Curl_conn_cf_send(io->cf, io->data, (const char *)buf, - buflen, FALSE, pnwritten); + return Curl_conn_cf_send(io->cf, io->data, buf, buflen, FALSE, pnwritten); } CURLcode Curl_cf_send_bufq(struct Curl_cfilter *cf, @@ -422,7 +421,7 @@ void Curl_conn_cf_close(struct Curl_cfilter *cf, struct Curl_easy *data) } CURLcode Curl_conn_cf_send(struct Curl_cfilter *cf, struct Curl_easy *data, - const void *buf, size_t len, bool eos, + const uint8_t *buf, size_t len, bool eos, size_t *pnwritten) { if(cf) diff --git a/lib/cfilters.h b/lib/cfilters.h index 6cb4a6909c36..5d39725088ed 100644 --- a/lib/cfilters.h +++ b/lib/cfilters.h @@ -89,7 +89,7 @@ typedef bool Curl_cft_data_pending(struct Curl_cfilter *cf, typedef CURLcode Curl_cft_send(struct Curl_cfilter *cf, struct Curl_easy *data, /* transfer */ - const void *buf, /* data to write */ + const uint8_t *buf, /* data to write */ size_t len, /* amount to write */ bool eos, /* last chunk */ size_t *pnwritten); /* how much sent */ @@ -250,7 +250,7 @@ CURLcode Curl_cf_def_adjust_pollset(struct Curl_cfilter *cf, bool Curl_cf_def_data_pending(struct Curl_cfilter *cf, const struct Curl_easy *data); CURLcode Curl_cf_def_send(struct Curl_cfilter *cf, struct Curl_easy *data, - const void *buf, size_t len, bool eos, + const uint8_t *buf, size_t len, bool eos, size_t *pnwritten); CURLcode Curl_cf_def_recv(struct Curl_cfilter *cf, struct Curl_easy *data, char *buf, size_t len, size_t *pnread); @@ -323,7 +323,7 @@ CURLcode Curl_conn_cf_connect(struct Curl_cfilter *cf, bool *done); void Curl_conn_cf_close(struct Curl_cfilter *cf, struct Curl_easy *data); CURLcode Curl_conn_cf_send(struct Curl_cfilter *cf, struct Curl_easy *data, - const void *buf, size_t len, bool eos, + const uint8_t *buf, size_t len, bool eos, size_t *pnwritten); CURLcode Curl_conn_cf_recv(struct Curl_cfilter *cf, struct Curl_easy *data, char *buf, size_t len, size_t *pnread); diff --git a/lib/http2.c b/lib/http2.c index 4f49efe768b4..2e8649c10502 100644 --- a/lib/http2.c +++ b/lib/http2.c @@ -2258,7 +2258,7 @@ static CURLcode cf_h2_body_send(struct Curl_cfilter *cf, static CURLcode h2_submit(struct h2_stream_ctx **pstream, struct Curl_cfilter *cf, struct Curl_easy *data, - const void *buf, size_t len, + const uint8_t *buf, size_t len, bool eos, size_t *pnwritten) { struct cf_h2_ctx *ctx = cf->ctx; @@ -2281,7 +2281,7 @@ static CURLcode h2_submit(struct h2_stream_ctx **pstream, if(result) goto out; - result = Curl_h1_req_parse_read(&stream->h1, buf, len, NULL, + result = Curl_h1_req_parse_read(&stream->h1, (const char *)buf, len, NULL, !data->state.http_ignorecustom ? data->set.str[STRING_CUSTOMREQUEST] : NULL, 0, &nwritten); @@ -2391,7 +2391,7 @@ static CURLcode h2_submit(struct h2_stream_ctx **pstream, } static CURLcode cf_h2_send(struct Curl_cfilter *cf, struct Curl_easy *data, - const void *buf, size_t len, bool eos, + const uint8_t *buf, size_t len, bool eos, size_t *pnwritten) { struct cf_h2_ctx *ctx = cf->ctx; diff --git a/lib/socks_gssapi.c b/lib/socks_gssapi.c index 30fefa5a6d3c..61c88be60528 100644 --- a/lib/socks_gssapi.c +++ b/lib/socks_gssapi.c @@ -211,7 +211,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(struct Curl_cfilter *cf, us_length = htons((unsigned short)gss_send_token.length); memcpy(socksreq + 2, &us_length, sizeof(short)); - code = Curl_conn_cf_send(cf->next, data, (char *)socksreq, 4, + code = Curl_conn_cf_send(cf->next, data, socksreq, 4, FALSE, &nwritten); if(code || (nwritten != 4)) { failf(data, "Failed to send GSS-API authentication request."); @@ -222,7 +222,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(struct Curl_cfilter *cf, } code = Curl_conn_cf_send(cf->next, data, - (char *)gss_send_token.value, + gss_send_token.value, gss_send_token.length, FALSE, &nwritten); if(code || (gss_send_token.length != nwritten)) { failf(data, "Failed to send GSS-API authentication token."); @@ -409,8 +409,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(struct Curl_cfilter *cf, memcpy(socksreq + 2, &us_length, sizeof(short)); } - code = Curl_conn_cf_send(cf->next, data, (char *)socksreq, 4, FALSE, - &nwritten); + code = Curl_conn_cf_send(cf->next, data, socksreq, 4, FALSE, &nwritten); if(code || (nwritten != 4)) { failf(data, "Failed to send GSS-API encryption request."); gss_release_buffer(&gss_status, &gss_w_token); @@ -420,8 +419,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(struct Curl_cfilter *cf, if(data->set.socks5_gssapi_nec) { memcpy(socksreq, &gss_enc, 1); - code = Curl_conn_cf_send(cf->next, data, (char *)socksreq, 1, FALSE, - &nwritten); + code = Curl_conn_cf_send(cf->next, data, socksreq, 1, FALSE, &nwritten); if(code || (nwritten != 1)) { failf(data, "Failed to send GSS-API encryption type."); Curl_gss_delete_sec_context(&gss_status, &gss_context, NULL); @@ -429,7 +427,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(struct Curl_cfilter *cf, } } else { - code = Curl_conn_cf_send(cf->next, data, (char *)gss_w_token.value, + code = Curl_conn_cf_send(cf->next, data, gss_w_token.value, gss_w_token.length, FALSE, &nwritten); if(code || (gss_w_token.length != nwritten)) { failf(data, "Failed to send GSS-API encryption type."); diff --git a/lib/socks_sspi.c b/lib/socks_sspi.c index 975172576c35..14025371ce37 100644 --- a/lib/socks_sspi.c +++ b/lib/socks_sspi.c @@ -88,7 +88,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(struct Curl_cfilter *cf, unsigned char socksreq[4]; /* room for GSS-API exchange header only */ const char *service = data->set.str[STRING_PROXY_SERVICE_NAME] ? data->set.str[STRING_PROXY_SERVICE_NAME] : "rcmd"; - char *etbuf; + uint8_t *etbuf; size_t etbuf_size; /* GSS-API request looks like @@ -201,8 +201,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(struct Curl_cfilter *cf, us_length = htons((unsigned short)sspi_send_token.cbBuffer); memcpy(socksreq + 2, &us_length, sizeof(short)); - code = Curl_conn_cf_send(cf->next, data, (char *)socksreq, 4, FALSE, - &written); + code = Curl_conn_cf_send(cf->next, data, socksreq, 4, FALSE, &written); if(code || (written != 4)) { failf(data, "Failed to send SSPI authentication request."); result = CURLE_COULDNT_CONNECT; @@ -210,7 +209,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(struct Curl_cfilter *cf, } code = Curl_conn_cf_send(cf->next, data, - (char *)sspi_send_token.pvBuffer, + sspi_send_token.pvBuffer, sspi_send_token.cbBuffer, FALSE, &written); if(code || (sspi_send_token.cbBuffer != written)) { failf(data, "Failed to send SSPI authentication token."); @@ -433,8 +432,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(struct Curl_cfilter *cf, memcpy(socksreq + 2, &us_length, sizeof(short)); } - code = Curl_conn_cf_send(cf->next, data, (char *)socksreq, 4, FALSE, - &written); + code = Curl_conn_cf_send(cf->next, data, socksreq, 4, FALSE, &written); if(code || (written != 4)) { failf(data, "Failed to send SSPI encryption request."); result = CURLE_COULDNT_CONNECT; @@ -443,8 +441,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(struct Curl_cfilter *cf, if(data->set.socks5_gssapi_nec) { memcpy(socksreq, &gss_enc, 1); - code = Curl_conn_cf_send(cf->next, data, (char *)socksreq, 1, FALSE, - &written); + code = Curl_conn_cf_send(cf->next, data, socksreq, 1, FALSE, &written); if(code || (written != 1)) { failf(data, "Failed to send SSPI encryption type."); result = CURLE_COULDNT_CONNECT; diff --git a/lib/vquic/curl_ngtcp2.c b/lib/vquic/curl_ngtcp2.c index 22ea0e3ef493..86f7428048e1 100644 --- a/lib/vquic/curl_ngtcp2.c +++ b/lib/vquic/curl_ngtcp2.c @@ -1524,7 +1524,7 @@ cb_h3_read_req_body(nghttp3_conn *conn, int64_t stream_id, static CURLcode h3_stream_open(struct Curl_cfilter *cf, struct Curl_easy *data, - const void *buf, size_t len, + const uint8_t *buf, size_t len, size_t *pnwritten) { struct cf_ngtcp2_ctx *ctx = cf->ctx; @@ -1552,7 +1552,7 @@ static CURLcode h3_stream_open(struct Curl_cfilter *cf, goto out; } - result = Curl_h1_req_parse_read(&stream->h1, buf, len, NULL, + result = Curl_h1_req_parse_read(&stream->h1, (const char *)buf, len, NULL, !data->state.http_ignorecustom ? data->set.str[STRING_CUSTOMREQUEST] : NULL, 0, pnwritten); @@ -1656,7 +1656,7 @@ static CURLcode h3_stream_open(struct Curl_cfilter *cf, } static CURLcode cf_ngtcp2_send(struct Curl_cfilter *cf, struct Curl_easy *data, - const void *buf, size_t len, bool eos, + const uint8_t *buf, size_t len, bool eos, size_t *pnwritten) { struct cf_ngtcp2_ctx *ctx = cf->ctx; diff --git a/lib/vquic/curl_osslq.c b/lib/vquic/curl_osslq.c index 376705e51667..d6672ce13252 100644 --- a/lib/vquic/curl_osslq.c +++ b/lib/vquic/curl_osslq.c @@ -1877,7 +1877,7 @@ static CURLcode cf_osslq_connect(struct Curl_cfilter *cf, static CURLcode h3_stream_open(struct Curl_cfilter *cf, struct Curl_easy *data, - const void *buf, size_t len, + const uint8_t *buf, size_t len, size_t *pnwritten) { struct cf_osslq_ctx *ctx = cf->ctx; @@ -1903,7 +1903,7 @@ static CURLcode h3_stream_open(struct Curl_cfilter *cf, goto out; } - result = Curl_h1_req_parse_read(&stream->h1, buf, len, NULL, + result = Curl_h1_req_parse_read(&stream->h1, (const char *)buf, len, NULL, !data->state.http_ignorecustom ? data->set.str[STRING_CUSTOMREQUEST] : NULL, 0, pnwritten); @@ -2005,7 +2005,7 @@ static CURLcode h3_stream_open(struct Curl_cfilter *cf, } static CURLcode cf_osslq_send(struct Curl_cfilter *cf, struct Curl_easy *data, - const void *buf, size_t len, bool eos, + const uint8_t *buf, size_t len, bool eos, size_t *pnwritten) { struct cf_osslq_ctx *ctx = cf->ctx; diff --git a/lib/vquic/curl_quiche.c b/lib/vquic/curl_quiche.c index 927492979013..f8fbadeebb1f 100644 --- a/lib/vquic/curl_quiche.c +++ b/lib/vquic/curl_quiche.c @@ -911,7 +911,7 @@ static CURLcode cf_quiche_recv(struct Curl_cfilter *cf, struct Curl_easy *data, static CURLcode cf_quiche_send_body(struct Curl_cfilter *cf, struct Curl_easy *data, struct h3_stream_ctx *stream, - const void *buf, size_t len, bool eos, + const uint8_t *buf, size_t len, bool eos, size_t *pnwritten) { struct cf_quiche_ctx *ctx = cf->ctx; @@ -956,7 +956,7 @@ static CURLcode cf_quiche_send_body(struct Curl_cfilter *cf, static CURLcode h3_open_stream(struct Curl_cfilter *cf, struct Curl_easy *data, - const char *buf, size_t blen, bool eos, + const uint8_t *buf, size_t blen, bool eos, size_t *pnwritten) { struct cf_quiche_ctx *ctx = cf->ctx; @@ -980,7 +980,7 @@ static CURLcode h3_open_stream(struct Curl_cfilter *cf, DEBUGASSERT(stream); - result = Curl_h1_req_parse_read(&stream->h1, buf, blen, NULL, + result = Curl_h1_req_parse_read(&stream->h1, (const char *)buf, blen, NULL, !data->state.http_ignorecustom ? data->set.str[STRING_CUSTOMREQUEST] : NULL, 0, pnwritten); @@ -1076,7 +1076,7 @@ static CURLcode h3_open_stream(struct Curl_cfilter *cf, } static CURLcode cf_quiche_send(struct Curl_cfilter *cf, struct Curl_easy *data, - const void *buf, size_t len, bool eos, + const uint8_t *buf, size_t len, bool eos, size_t *pnwritten) { struct cf_quiche_ctx *ctx = cf->ctx; diff --git a/lib/vtls/mbedtls.c b/lib/vtls/mbedtls.c index 9a307499595a..2ea3670c1bf2 100644 --- a/lib/vtls/mbedtls.c +++ b/lib/vtls/mbedtls.c @@ -187,8 +187,7 @@ static int mbedtls_bio_cf_write(void *bio, if(!data) return 0; - result = Curl_conn_cf_send(cf->next, data, (const char *)buf, blen, FALSE, - &nwritten); + result = Curl_conn_cf_send(cf->next, data, buf, blen, FALSE, &nwritten); CURL_TRC_CF(data, cf, "mbedtls_bio_cf_out_write(len=%zu) -> %d, %zu", blen, result, nwritten); if(CURLE_AGAIN == result) diff --git a/lib/vtls/openssl.c b/lib/vtls/openssl.c index 7ff5698e7c30..d8f99b21c371 100644 --- a/lib/vtls/openssl.c +++ b/lib/vtls/openssl.c @@ -597,7 +597,8 @@ static int ossl_bio_cf_out_write(BIO *bio, const char *buf, int blen) if(blen < 0) return 0; - result = Curl_conn_cf_send(cf->next, data, buf, (size_t)blen, FALSE, + result = Curl_conn_cf_send(cf->next, data, + (const uint8_t *)buf, (size_t)blen, FALSE, &nwritten); CURL_TRC_CF(data, cf, "ossl_bio_cf_out_write(len=%d) -> %d, %zu", blen, result, nwritten); diff --git a/lib/vtls/rustls.c b/lib/vtls/rustls.c index 3b5bea2c6fe7..cc19a328eda1 100644 --- a/lib/vtls/rustls.c +++ b/lib/vtls/rustls.c @@ -133,7 +133,7 @@ write_cb(void *userdata, const uint8_t *buf, uintptr_t len, uintptr_t *out_n) size_t nwritten; result = Curl_conn_cf_send(io_ctx->cf->next, io_ctx->data, - (const char *)buf, len, FALSE, &nwritten); + buf, len, FALSE, &nwritten); if(result) { nwritten = 0; if(CURLE_AGAIN == result) diff --git a/lib/vtls/schannel.c b/lib/vtls/schannel.c index f7e831f002e5..e5fbe40a8c1a 100644 --- a/lib/vtls/schannel.c +++ b/lib/vtls/schannel.c @@ -1074,7 +1074,8 @@ schannel_connect_step1(struct Curl_cfilter *cf, struct Curl_easy *data) /* send initial handshake data which is now stored in output buffer */ result = Curl_conn_cf_send(cf->next, data, - outbuf.pvBuffer, outbuf.cbBuffer, FALSE, + (const uint8_t *)outbuf.pvBuffer, + outbuf.cbBuffer, FALSE, &written); Curl_pSecFn->FreeContextBuffer(outbuf.pvBuffer); if(result || (outbuf.cbBuffer != written)) { @@ -1307,7 +1308,8 @@ schannel_connect_step2(struct Curl_cfilter *cf, struct Curl_easy *data) /* send handshake token to server */ result = Curl_conn_cf_send(cf->next, data, - outbuf[i].pvBuffer, outbuf[i].cbBuffer, + (const uint8_t *)outbuf[i].pvBuffer, + outbuf[i].cbBuffer, FALSE, &written); if(result || (outbuf[i].cbBuffer != written)) { failf(data, "schannel: failed to send next handshake data: " @@ -2004,7 +2006,8 @@ schannel_send(struct Curl_cfilter *cf, struct Curl_easy *data, /* socket is writable */ result = Curl_conn_cf_send(cf->next, data, - ptr + *pnwritten, len - *pnwritten, + (const uint8_t *)ptr + *pnwritten, + len - *pnwritten, FALSE, &this_write); if(result == CURLE_AGAIN) continue; @@ -2450,7 +2453,8 @@ static CURLcode schannel_shutdown(struct Curl_cfilter *cf, size_t written; result = Curl_conn_cf_send(cf->next, data, - outbuf.pvBuffer, outbuf.cbBuffer, + (const uint8_t *)outbuf.pvBuffer, + outbuf.cbBuffer, FALSE, &written); Curl_pSecFn->FreeContextBuffer(outbuf.pvBuffer); if(!result) { diff --git a/lib/vtls/vtls.c b/lib/vtls/vtls.c index 9c76ca7ed32c..3b242fd485d2 100644 --- a/lib/vtls/vtls.c +++ b/lib/vtls/vtls.c @@ -1477,7 +1477,7 @@ static bool ssl_cf_data_pending(struct Curl_cfilter *cf, static CURLcode ssl_cf_send(struct Curl_cfilter *cf, struct Curl_easy *data, - const void *buf, size_t blen, + const uint8_t *buf, size_t blen, bool eos, size_t *pnwritten) { struct ssl_connect_data *connssl = cf->ctx; @@ -1509,7 +1509,7 @@ static CURLcode ssl_cf_send(struct Curl_cfilter *cf, } else { *pnwritten = connssl->earlydata_skip; - buf = ((const char *)buf) + connssl->earlydata_skip; + buf = buf + connssl->earlydata_skip; blen -= connssl->earlydata_skip; connssl->earlydata_skip = 0; } diff --git a/lib/vtls/wolfssl.c b/lib/vtls/wolfssl.c index e622f909e50b..2ad033f98899 100644 --- a/lib/vtls/wolfssl.c +++ b/lib/vtls/wolfssl.c @@ -334,7 +334,8 @@ static int wssl_bio_cf_out_write(WOLFSSL_BIO *bio, skiplen = (ssize_t)(blen - wssl->io_send_blocked_len); blen = wssl->io_send_blocked_len; } - result = Curl_conn_cf_send(cf->next, data, buf, blen, FALSE, &nwritten); + result = Curl_conn_cf_send(cf->next, data, + (const uint8_t *)buf, blen, FALSE, &nwritten); wssl->io_result = result; CURL_TRC_CF(data, cf, "bio_write(len=%d) -> %d, %zu", blen, result, nwritten); From c1deea4c58f385b172e31a75157931acf278dd74 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Thu, 27 Nov 2025 12:17:27 +0100 Subject: [PATCH 091/415] GHA/http3-linux: add H3 valgrind tests Ref: #19714 Ref: #19717 Closes #19719 --- .github/workflows/http3-linux.yml | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/.github/workflows/http3-linux.yml b/.github/workflows/http3-linux.yml index 353c36814219..a9117e146ef9 100644 --- a/.github/workflows/http3-linux.yml +++ b/.github/workflows/http3-linux.yml @@ -479,7 +479,7 @@ jobs: sudo rm -f /var/lib/man-db/auto-update sudo apt-get -o Dpkg::Use-Pty=0 install \ libtool autoconf automake pkgconf \ - libpsl-dev libbrotli-dev libzstd-dev zlib1g-dev libidn2-0-dev libldap-dev libuv1-dev \ + libpsl-dev libbrotli-dev libzstd-dev zlib1g-dev libidn2-0-dev libldap-dev libuv1-dev valgrind \ ${INSTALL_PACKAGES} \ ${MATRIX_INSTALL_PACKAGES} echo 'CC=gcc-12' >> "$GITHUB_ENV" @@ -701,6 +701,18 @@ jobs: - name: 'run tests' if: ${{ !contains(matrix.build.install_steps, 'skipall') && !contains(matrix.build.install_steps, 'skiprun') }} run: | + export TFLAGS='-n' + source ~/venv/bin/activate + if [ "${MATRIX_BUILD}" = 'cmake' ]; then + cmake --build bld --verbose --target test-ci + else + make -C bld V=1 test-ci + fi + + - name: 'run tests (valgrind)' + if: ${{ !contains(matrix.build.install_steps, 'skipall') && !contains(matrix.build.install_steps, 'skiprun') }} + run: | + export TFLAGS='-j6 HTTP/3' source ~/venv/bin/activate if [ "${MATRIX_BUILD}" = 'cmake' ]; then cmake --build bld --verbose --target test-ci @@ -714,7 +726,7 @@ jobs: [ -d ~/venv ] || python3 -m venv ~/venv ~/venv/bin/pip --disable-pip-version-check --no-input --no-cache-dir install --progress-bar off --prefer-binary -r tests/http/requirements.txt - - name: 'run pytest event based' + - name: 'run pytest (event based)' if: ${{ !contains(matrix.build.install_steps, 'skipall') && !contains(matrix.build.install_steps, 'skiprun') }} env: CURL_TEST_EVENT: 1 From 53775baa1d6ba0301a6c041a60350d0914065b7f Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 27 Nov 2025 15:55:47 +0100 Subject: [PATCH 092/415] tests: allow 2500-2503 to use ~2MB malloc On Linux using UDP_GRO, curl might allocate a (single) 1.5MB buffer for maximum performance. Fixes #19716 Closes #19731 --- tests/data/test2500 | 4 ++++ tests/data/test2501 | 3 +++ tests/data/test2502 | 3 +++ tests/data/test2503 | 3 +++ 4 files changed, 13 insertions(+) diff --git a/tests/data/test2500 b/tests/data/test2500 index f92cabfd32b6..bc6790c2c1f1 100644 --- a/tests/data/test2500 +++ b/tests/data/test2500 @@ -73,5 +73,9 @@ via: 1.1 nghttpx s/^server: nghttpx.*\r?\n// + +Allocations: 150 +Maximum allocated: 1800000 + diff --git a/tests/data/test2501 b/tests/data/test2501 index 99167ec48e86..01505f4ce27f 100644 --- a/tests/data/test2501 +++ b/tests/data/test2501 @@ -65,5 +65,8 @@ Via: 3 nghttpx moo + +Maximum allocated: 1900000 + diff --git a/tests/data/test2502 b/tests/data/test2502 index 627cfdccad8e..ac6cd3cf588c 100644 --- a/tests/data/test2502 +++ b/tests/data/test2502 @@ -101,5 +101,8 @@ Via: 3 nghttpx $_ = '' if(($_ !~ /left intact/) && ($_ !~ /Closing connection/)) + +Maximum allocated: 1800000 + diff --git a/tests/data/test2503 b/tests/data/test2503 index 722d0ceb7adf..9e8d4c3d490c 100644 --- a/tests/data/test2503 +++ b/tests/data/test2503 @@ -65,5 +65,8 @@ via: 1.1 nghttpx "via":["1.1 nghttpx"] } + +Maximum allocated: 1800000 + From aa9342058fbf0ce1d387b7c590e674e6acabbda8 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 27 Nov 2025 16:14:37 +0100 Subject: [PATCH 093/415] RELEASE-NOTES: synced --- RELEASE-NOTES | 75 ++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 65 insertions(+), 10 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 217f8c750446..2dbac34d0f65 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -4,7 +4,7 @@ curl and libcurl 8.18.0 Command line options: 273 curl_easy_setopt() options: 308 Public functions in libcurl: 100 - Contributors: 3549 + Contributors: 3553 This release includes the following changes: @@ -19,8 +19,10 @@ This release includes the following bugfixes: o _PROGRESS.md: add the E unit, mention kibibyte [24] o AmigaOS: increase minimum stack size for tool_main [137] o apple-sectrust: always ask when `native_ca_store` is in use [162] + o asyn-ares: handle Curl_dnscache_mk_entry() OOM error [199] o asyn-ares: remove hostname free on OOM [122] o asyn-thrdd: release rrname if ares_init_options fails [41] + o autotools: add nettle library detection via pkg-config (for GnuTLS) [178] o autotools: drop autoconf <2.59 compatibility code (zz60-xc-ovr) [70] o badwords: fix issues found in scripts and other files [142] o badwords: fix issues found in tests [156] @@ -31,6 +33,7 @@ This release includes the following bugfixes: o cf-https-connect: allocate ctx at first in cf_hc_create() [79] o cf-socket: limit use of `TCP_KEEP*` to Windows 10.0.16299+ at runtime [157] o cf-socket: trace ignored errors [97] + o cfilters: make conn_forget_socket a private libssh function [109] o checksrc.pl: detect assign followed by more than one space [26] o cmake: adjust defaults for target platforms not supporting shared libs [35] o cmake: disable `CURL_CA_PATH` auto-detection if `USE_APPLE_SECTRUST=ON` [16] @@ -39,6 +42,7 @@ This release includes the following bugfixes: o config2setopts: bail out if curl_url_get() returns OOM [102] o config2setopts: exit if curl_url_set() fails on OOM [105] o conncache: silence `-Wnull-dereference` on gcc 14 RISC-V 64 [17] + o conncontrol: reuse handling [170] o connect: reshuffle Curl_timeleft_ms to avoid 'redundant condition' [100] o cookie: propagate errors better, cleanup the internal API [118] o cookie: return error on OOM [131] @@ -53,15 +57,21 @@ This release includes the following bugfixes: o CURLINFO_TLS_SSL_PTR.md: remove CURLINFO_TLS_SESSION text [49] o CURLOPT_READFUNCTION.md: clarify the size of the buffer [47] o CURLOPT_SSH_KEYFUNCTION.md: fix minor indent mistake in example + o curlx/fopen: replace open CRT functions their with `_s` counterparts (Windows) [204] o curlx/strerr: use `strerror_s()` on Windows [75] o curlx: replace `mbstowcs`/`wcstombs` with `_s` counterparts (Windows) [143] + o curlx: replace `sprintf` with `snprintf` [194] o digest_sspi: fix a memory leak on error path [149] o digest_sspi: properly free sspi identity [12] o DISTROS.md: add OpenBSD [126] + o doc: some returned in-memory data may not be altered [196] o docs: fix checksrc `EQUALSPACE` warnings [21] o docs: mention umask need when curl creates files [56] + o docs: spell it Rustls with a capital R [181] o examples/crawler: fix variable [92] + o examples/multi-uv: fix invalid req->data access [177] o examples/multithread: fix race condition [101] + o examples: fix minor typo [203] o examples: make functions/data static where missing [139] o examples: tidy-up headers and includes [138] o file: do not pass invalid mode flags to `open()` on upload (Windows) [83] @@ -73,9 +83,12 @@ This release includes the following bugfixes: o gtls: skip session resumption when verifystatus is set o h2/h3: handle methods with spaces [146] o hostip: don't store negative lookup on OOM [61] + o hostip: make more functions return CURLcode [202] + o hostip: only store negative response for CURLE_COULDNT_RESOLVE_HOST [183] o hsts: propagate and error out correctly on OOM [130] o http: avoid two strdup()s and do minor simplifications [144] o http: error on OOM when creating range header [59] + o http: fix OOM exit in Curl_http_follow [179] o http: replace atoi use in Curl_http_follow with curlx_str_number [65] o http: the :authority header should never contain user+password [147] o INSTALL-CMAKE.md: document static option defaults more [37] @@ -86,6 +99,7 @@ This release includes the following bugfixes: o lib: fix gssapi.h include on IBMi [55] o lib: refactor the type of funcs which have useless return and checks [1] o lib: replace `_tcsncpy`/`wcsncpy`/`wcscpy` with `_s` counterparts (Windows) [164] + o lib: timer stats improvements [190] o libssh2: add paths to error messages for quote commands [114] o libssh2: cleanup ssh_force_knownhost_key_type [64] o libssh2: replace atoi() in ssh_force_knownhost_key_type [63] @@ -93,11 +107,15 @@ This release includes the following bugfixes: o libtests: replace `atoi()` with `curlx_str_number()` [120] o limit-rate: add example using --limit-rate and --max-time together [89] o m4/sectrust: fix test(1) operator [4] + o manage: expand the 'libcurl support required' message [208] o mbedtls: fix potential use of uninitialized `nread` [8] o mk-ca-bundle.pl: default to SHA256 fingerprints with `-t` option [73] o mk-ca-bundle.pl: use `open()` with argument list to replace backticks [71] o mqtt: reject overly big messages [39] o multi: make max_total_* members size_t [158] + o multi: simplify admin handle processing [189] + o ngtcp2+openssl: fix leak of session [172] + o ngtcp2: remove the unused Curl_conn_is_ngtcp2 function [85] o noproxy: replace atoi with curlx_str_number [67] o openssl: exit properly on OOM when getting certchain [133] o openssl: fix a potential memory leak of bio_out [150] @@ -111,7 +129,9 @@ This release includes the following bugfixes: o progress: show fewer digits [78] o projects/README.md: Markdown fixes [148] o pytest fixes and improvements [159] + o pytest: disable two H3 earlydata tests for all platforms (was: macOS) [116] o pytest: skip H2 tests if feature missing from curl [46] + o ratelimit: redesign [209] o rtmp: fix double-free on URL parse errors [27] o rtmp: precaution for a potential integer truncation [54] o runtests: detect bad libssh differently for test 1459 [11] @@ -126,9 +146,11 @@ This release includes the following bugfixes: o setopt: disable CURLOPT_HAPROXY_CLIENT_IP on NULL [30] o setopt: when setting bad protocols, don't store them [9] o sftp: fix range downloads in both SSH backends [82] + o slist: constify Curl_slist_append_nodup() string argument [195] o smb: fix a size check to be overflow safe [161] o socks_sspi: use free() not FreeContextBuffer() [93] o speedcheck: do not trigger low speed cancel on transfers with CURL_READFUNC_PAUSE [113] + o speedlimit: also reset on send unpausing [197] o telnet: replace atoi for BINARY handling with curlx_str_number [66] o TEST-SUITE.md: correct the man page's path [136] o test07_22: fix flakiness [95] @@ -138,11 +160,14 @@ This release includes the following bugfixes: o tests/data: support using native newlines on disk, drop `.gitattributes` [91] o tests/server: do not fall back to original data file in `test2fopen()` [32] o tests/server: replace `atoi()` and `atol()` with `curlx_str_number()` [110] + o tests: allow 2500-2503 to use ~2MB malloc [31] o tftp: release filename if conn_get_remote_addr fails [42] o tftpd: fix/tidy up `open()` mode flags [57] o tidy-up: move `CURL_UNCONST()` out from macro `curl_unicodefree()` [121] o tool: consider (some) curl_easy_setopt errors fatal [7] + o tool: log when loading .curlrc in verbose mode [191] o tool_cfgable: free ssl-sessions at exit [123] + o tool_doswin: clear pointer when thread takes ownership [198] o tool_getparam: verify that a file exists for some options [134] o tool_help: add checks to avoid unsigned wrap around [14] o tool_ipfs: check return codes better [20] @@ -157,9 +182,11 @@ This release includes the following bugfixes: o tool_writeout: bail out proper on OOM [104] o url: if OOM in parse_proxy() return error [132] o urlapi: fix mem-leaks in curl_url_get error paths [22] + o urlapi: handle OOM properly when setting URL [180] o verify-release: update to avoid shellcheck warning SC2034 [88] o vquic-tls/gnutls: call Curl_gtls_verifyserver unconditionally [96] o vquic: do not pass invalid mode flags to `open()` (Windows) [58] + o vquic: do_sendmsg full init [171] o vtls: fix CURLOPT_CAPATH use [51] o vtls: handle possible malicious certs_num from peer [53] o vtls: pinned key check [98] @@ -190,15 +217,16 @@ Planned upcoming removals include: This release would not have looked like this without help, code, reports and advice from friends like these: - Aleksandr Sergeev, Andrew Kirillov, boingball, Brad King, bttrfl on github, - Christian Schmitz, Dan Fandrich, Daniel McCarney, Daniel Stenberg, - Fd929c2CE5fA on github, ffath-vo on github, Gisle Vanem, Jiyong Yang, - Juliusz Sosinowicz, Leonardo Taccari, letshack9707 on hackerone, - Marc Aldorasi, Marcel Raad, nait-furry, ncaklovic on github, Nick Korepanov, - Omdahake on github, Patrick Monnerat, pelioro on hackerone, Ray Satiro, - renovate[bot], Samuel Henrique, Stanislav Fort, Stefan Eissing, - Thomas Klausner, Viktor Szakats, Wesley Moore, Xiaoke Wang - (33 contributors) + Aleksandr Sergeev, Aleksei Bavshin, Andrew Kirillov, BANADDA, boingball, + Brad King, bttrfl on github, Christian Schmitz, Dan Fandrich, + Daniel McCarney, Daniel Stenberg, Fd929c2CE5fA on github, ffath-vo on github, + Gisle Vanem, Jiyong Yang, Juliusz Sosinowicz, Leonardo Taccari, + letshack9707 on hackerone, Marc Aldorasi, Marcel Raad, nait-furry, + ncaklovic on github, Nick Korepanov, Omdahake on github, Patrick Monnerat, + pelioro on hackerone, Ray Satiro, renovate[bot], Samuel Henrique, + st751228051 on github, Stanislav Fort, Stefan Eissing, Sunny, + Thomas Klausner, Viktor Szakats, Wesley Moore, Xiaoke Wang, Yedaya Katsman + (38 contributors) References to bug reports and discussions on issues: @@ -232,6 +260,7 @@ References to bug reports and discussions on issues: [28] = https://curl.se/bug/?i=19354 [29] = https://curl.se/bug/?i=19430 [30] = https://curl.se/bug/?i=19434 + [31] = https://curl.se/bug/?i=19716 [32] = https://curl.se/bug/?i=19429 [33] = https://curl.se/bug/?i=19427 [35] = https://curl.se/bug/?i=19420 @@ -283,6 +312,7 @@ References to bug reports and discussions on issues: [82] = https://curl.se/bug/?i=19460 [83] = https://curl.se/bug/?i=19647 [84] = https://curl.se/bug/?i=19645 + [85] = https://curl.se/bug/?i=19725 [86] = https://curl.se/bug/?i=19451 [87] = https://curl.se/bug/?i=19450 [88] = https://curl.se/bug/?i=19449 @@ -306,11 +336,13 @@ References to bug reports and discussions on issues: [106] = https://curl.se/bug/?i=19144 [107] = https://curl.se/bug/?i=19512 [108] = https://curl.se/bug/?i=19513 + [109] = https://curl.se/bug/?i=19727 [110] = https://curl.se/bug/?i=19510 [111] = https://curl.se/bug/?i=19509 [112] = https://curl.se/bug/?i=19495 [113] = https://curl.se/bug/?i=19653 [114] = https://curl.se/bug/?i=19605 + [116] = https://curl.se/bug/?i=19724 [117] = https://curl.se/bug/?i=19644 [118] = https://curl.se/bug/?i=19493 [119] = https://curl.se/bug/?i=19483 @@ -358,3 +390,26 @@ References to bug reports and discussions on issues: [166] = https://curl.se/bug/?i=19615 [167] = https://curl.se/bug/?i=19609 [168] = https://curl.se/bug/?i=19612 + [170] = https://curl.se/bug/?i=19333 + [171] = https://curl.se/bug/?i=19714 + [172] = https://curl.se/bug/?i=19717 + [177] = https://curl.se/bug/?i=19462 + [178] = https://curl.se/bug/?i=19703 + [179] = https://curl.se/bug/?i=19705 + [180] = https://curl.se/bug/?i=19704 + [181] = https://curl.se/bug/?i=19702 + [183] = https://curl.se/bug/?i=19701 + [189] = https://curl.se/bug/?i=19604 + [190] = https://curl.se/bug/?i=19269 + [191] = https://curl.se/bug/?i=19663 + [194] = https://curl.se/bug/?i=19681 + [195] = https://curl.se/bug/?i=19692 + [196] = https://curl.se/bug/?i=19692 + [197] = https://curl.se/bug/?i=19687 + [198] = https://curl.se/bug/?i=19689 + [199] = https://curl.se/bug/?i=19688 + [202] = https://curl.se/bug/?i=19669 + [203] = https://curl.se/bug/?i=19683 + [204] = https://curl.se/bug/?i=19643 + [208] = https://curl.se/bug/?i=19665 + [209] = https://curl.se/bug/?i=19384 From 5c22bd5384e732755fa00d2fc7fef2ce19e3418b Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 27 Nov 2025 17:42:55 +0100 Subject: [PATCH 094/415] mbedtls_threadlock: avoid calloc, use array Closes #19732 --- lib/vtls/mbedtls_threadlock.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/lib/vtls/mbedtls_threadlock.c b/lib/vtls/mbedtls_threadlock.c index ed70308b739d..82590929cd78 100644 --- a/lib/vtls/mbedtls_threadlock.c +++ b/lib/vtls/mbedtls_threadlock.c @@ -44,17 +44,13 @@ /* 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; +/* This array stores the mutexes available to Mbedtls */ +static MBEDTLS_MUTEX_T mutex_buf[NUMT]; int Curl_mbedtlsthreadlock_thread_setup(void) { int i; - mutex_buf = calloc(1, NUMT * sizeof(MBEDTLS_MUTEX_T)); - if(!mutex_buf) - return 0; /* error, no number of threads defined */ - for(i = 0; i < NUMT; i++) { #if defined(USE_THREADS_POSIX) && defined(HAVE_PTHREAD_H) if(pthread_mutex_init(&mutex_buf[i], NULL)) @@ -73,9 +69,6 @@ int Curl_mbedtlsthreadlock_thread_cleanup(void) { int i; - if(!mutex_buf) - return 0; /* error, no threads locks defined */ - for(i = 0; i < NUMT; i++) { #if defined(USE_THREADS_POSIX) && defined(HAVE_PTHREAD_H) if(pthread_mutex_destroy(&mutex_buf[i])) @@ -85,8 +78,6 @@ int Curl_mbedtlsthreadlock_thread_cleanup(void) return 0; /* CloseHandle failed */ #endif /* USE_THREADS_POSIX && HAVE_PTHREAD_H */ } - free(mutex_buf); - mutex_buf = NULL; return 1; /* OK */ } From 986e6d4eae316f408f188b3079b1af62dce35850 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Thu, 27 Nov 2025 18:32:35 +0100 Subject: [PATCH 095/415] CODE_STYLE.md: sync banned function list with checksrc.pl Also alpha sort the list in checksrc.pl. Closes #19733 --- docs/internals/CODE_STYLE.md | 36 +++++++++++++ scripts/checksrc.pl | 102 +++++++++++++++++------------------ 2 files changed, 87 insertions(+), 51 deletions(-) diff --git a/docs/internals/CODE_STYLE.md b/docs/internals/CODE_STYLE.md index 0d072c04c306..7d37df4805ec 100644 --- a/docs/internals/CODE_STYLE.md +++ b/docs/internals/CODE_STYLE.md @@ -334,14 +334,31 @@ This is the full list of functions generally banned. _access _mbscat _mbsncat + _open _tcscat _tcsdup _tcsncat + _tcsncpy _waccess _wcscat _wcsdup _wcsncat + _wfopen + _wfreopen + _wopen + accept + accept4 access + aprintf + atoi + atol + fclose + fdopen + fopen + fprintf + freeaddrinfo + freopen + getaddrinfo gets gmtime LoadLibrary @@ -351,9 +368,19 @@ This is the full list of functions generally banned. LoadLibraryExW LoadLibraryW localtime + mbstowcs + msnprintf + mvsnprintf + open + printf + recv + send snprintf + socket + socketpair sprintf sscanf + stat strcat strerror strncat @@ -362,6 +389,15 @@ This is the full list of functions generally banned. strtok_r strtol strtoul + vaprintf + vfprintf + vprintf vsnprintf vsprintf + wcscpy wcsdup + wcsncpy + wcstombs + WSASocket + WSASocketA + WSASocketW diff --git a/scripts/checksrc.pl b/scripts/checksrc.pl index d38ffecdb9b1..49290ff137a5 100755 --- a/scripts/checksrc.pl +++ b/scripts/checksrc.pl @@ -48,76 +48,76 @@ my @ignore_line; my %banfunc = ( - "gmtime" => 1, - "localtime" => 1, - "gets" => 1, - "strtok" => 1, - "sprintf" => 1, - "snprintf" => 1, - "vsprintf" => 1, - "vsnprintf" => 1, + "_access" => 1, + "_mbscat" => 1, + "_mbsncat" => 1, + "_open" => 1, + "_tcscat" => 1, + "_tcsdup" => 1, + "_tcsncat" => 1, + "_tcsncpy" => 1, + "_waccess" => 1, + "_wcscat" => 1, + "_wcsdup" => 1, + "_wcsncat" => 1, + "_wfopen" => 1, + "_wfreopen" => 1, + "_wopen" => 1, + "accept" => 1, + "accept4" => 1, + "access" => 1, "aprintf" => 1, + "atoi" => 1, + "atol" => 1, + "fclose" => 1, + "fdopen" => 1, + "fopen" => 1, "fprintf" => 1, + "freeaddrinfo" => 1, + "freopen" => 1, + "getaddrinfo" => 1, + "gets" => 1, + "gmtime" => 1, + "LoadLibrary" => 1, + "LoadLibraryA" => 1, + "LoadLibraryEx" => 1, + "LoadLibraryExA" => 1, + "LoadLibraryExW" => 1, + "LoadLibraryW" => 1, + "localtime" => 1, + "mbstowcs" => 1, "msnprintf" => 1, "mvsnprintf" => 1, + "open" => 1, "printf" => 1, - "vaprintf" => 1, - "vfprintf" => 1, - "vprintf" => 1, + "recv" => 1, + "send" => 1, + "snprintf" => 1, + "socket" => 1, + "socketpair" => 1, + "sprintf" => 1, "sscanf" => 1, + "stat" => 1, "strcat" => 1, "strerror" => 1, "strncat" => 1, "strncpy" => 1, "strtok_r" => 1, + "strtok" => 1, "strtol" => 1, "strtoul" => 1, - "atoi" => 1, - "atol" => 1, - "_mbscat" => 1, - "_mbsncat" => 1, - "_tcscat" => 1, - "_tcsdup" => 1, - "_tcsncpy" => 1, - "_tcsncat" => 1, - "_wcscat" => 1, - "_wcsncat" => 1, - "_wcsdup" => 1, - "wcsdup" => 1, + "vaprintf" => 1, + "vfprintf" => 1, + "vprintf" => 1, + "vsnprintf" => 1, + "vsprintf" => 1, "wcscpy" => 1, + "wcsdup" => 1, "wcsncpy" => 1, - "mbstowcs" => 1, "wcstombs" => 1, - "LoadLibrary" => 1, - "LoadLibraryA" => 1, - "LoadLibraryW" => 1, - "LoadLibraryEx" => 1, - "LoadLibraryExA" => 1, - "LoadLibraryExW" => 1, "WSASocket" => 1, "WSASocketA" => 1, "WSASocketW" => 1, - "_waccess" => 1, - "_access" => 1, - "access" => 1, - "accept" => 1, - "accept4" => 1, - "freeaddrinfo" => 1, - "getaddrinfo" => 1, - "recv" => 1, - "send" => 1, - "socket" => 1, - "socketpair" => 1, - "fclose" => 1, - "fdopen" => 1, - "fopen" => 1, - "freopen" => 1, - "open" => 1, - "_open" => 1, - "_wfopen" => 1, - "_wfreopen" => 1, - "_wopen" => 1, - "stat" => 1, ); my %warnings_extended = ( From 63eb0627b1c6cb2fa267585b4c21f839867e19d2 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Thu, 27 Nov 2025 20:08:43 +0100 Subject: [PATCH 096/415] curl_setup.h: drop superfluous parenthesis from `Curl_safefree` macro Cherry-picked from #19626 Closes #19734 --- lib/curl_setup.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/curl_setup.h b/lib/curl_setup.h index 48b9ea9ea9f9..6236a7153923 100644 --- a/lib/curl_setup.h +++ b/lib/curl_setup.h @@ -941,7 +941,7 @@ extern curl_calloc_callback Curl_ccalloc; * This macro also assigns NULL to given pointer when free'd. */ #define Curl_safefree(ptr) \ - do { free((ptr)); (ptr) = NULL;} while(0) + do { free(ptr); (ptr) = NULL;} while(0) #include /* for CURL_EXTERN, mprintf.h */ From 6dc82c80468941a3f08646454bceccd839e46e00 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Thu, 20 Nov 2025 03:57:45 +0100 Subject: [PATCH 097/415] memdebug: replace `(fwrite)` with `fwrite` Cherry-picked from #19626 Closes #19735 --- lib/memdebug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/memdebug.c b/lib/memdebug.c index 6ec292654f80..1121dc26f550 100644 --- a/lib/memdebug.c +++ b/lib/memdebug.c @@ -526,7 +526,7 @@ void curl_dbg_log(const char *format, ...) nchars = (int)sizeof(buf) - 1; if(nchars > 0) - (fwrite)(buf, 1, (size_t)nchars, curl_dbg_logfile); + fwrite(buf, 1, (size_t)nchars, curl_dbg_logfile); } #endif /* CURLDEBUG */ From 376c7bddc48974d30c9bcc82aa183fe92478d67f Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Thu, 27 Nov 2025 20:48:43 +0100 Subject: [PATCH 098/415] unit1653: replace local macro with `Curl_safefree()` Cherry-picked from #19626 Closes #19736 --- tests/unit/unit1653.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/tests/unit/unit1653.c b/tests/unit/unit1653.c index 714b52a8e60f..8f6a5a51cc55 100644 --- a/tests/unit/unit1653.c +++ b/tests/unit/unit1653.c @@ -27,8 +27,6 @@ #include "curl/urlapi.h" #include "urlapi-int.h" -#define free_and_clear(x) free(x); x = NULL - static CURLUcode parse_port(CURLU *url, char *h, bool has_scheme) { struct dynbuf host; @@ -62,7 +60,7 @@ static CURLcode test_unit1653(const char *arg) fail_unless(ret == CURLUE_OK, "parse_port returned error"); ret = curl_url_get(u, CURLUPART_PORT, &portnum, CURLU_NO_DEFAULT_PORT); fail_unless(ret != CURLUE_OK, "curl_url_get portnum returned something"); - free_and_clear(ipv6port); + Curl_safefree(ipv6port); curl_url_cleanup(u); /* Invalid IPv6 */ @@ -74,7 +72,7 @@ static CURLcode test_unit1653(const char *arg) goto fail; ret = parse_port(u, ipv6port, FALSE); fail_unless(ret != CURLUE_OK, "parse_port true on error"); - free_and_clear(ipv6port); + Curl_safefree(ipv6port); curl_url_cleanup(u); u = curl_url(); @@ -90,7 +88,7 @@ static CURLcode test_unit1653(const char *arg) fail_unless(portnum && !strcmp(portnum, "808"), "Check portnumber"); curl_free(portnum); - free_and_clear(ipv6port); + Curl_safefree(ipv6port); curl_url_cleanup(u); /* Valid IPv6 with zone index and port number */ @@ -106,7 +104,7 @@ static CURLcode test_unit1653(const char *arg) fail_unless(ret == CURLUE_OK, "curl_url_get portnum returned error"); fail_unless(portnum && !strcmp(portnum, "80"), "Check portnumber"); curl_free(portnum); - free_and_clear(ipv6port); + Curl_safefree(ipv6port); curl_url_cleanup(u); /* Valid IPv6 with zone index without port number */ @@ -118,7 +116,7 @@ static CURLcode test_unit1653(const char *arg) goto fail; ret = parse_port(u, ipv6port, FALSE); fail_unless(ret == CURLUE_OK, "parse_port returned error"); - free_and_clear(ipv6port); + Curl_safefree(ipv6port); curl_url_cleanup(u); /* Valid IPv6 with port number */ @@ -134,7 +132,7 @@ static CURLcode test_unit1653(const char *arg) fail_unless(ret == CURLUE_OK, "curl_url_get portnum returned error"); fail_unless(portnum && !strcmp(portnum, "81"), "Check portnumber"); curl_free(portnum); - free_and_clear(ipv6port); + Curl_safefree(ipv6port); curl_url_cleanup(u); /* Valid IPv6 with syntax error in the port number */ @@ -146,7 +144,7 @@ static CURLcode test_unit1653(const char *arg) goto fail; ret = parse_port(u, ipv6port, FALSE); fail_unless(ret != CURLUE_OK, "parse_port true on error"); - free_and_clear(ipv6port); + Curl_safefree(ipv6port); curl_url_cleanup(u); u = curl_url(); @@ -157,7 +155,7 @@ static CURLcode test_unit1653(const char *arg) goto fail; ret = parse_port(u, ipv6port, FALSE); fail_unless(ret != CURLUE_OK, "parse_port true on error"); - free_and_clear(ipv6port); + Curl_safefree(ipv6port); curl_url_cleanup(u); /* Valid IPv6 with no port after the colon, should use default if a scheme @@ -170,7 +168,7 @@ static CURLcode test_unit1653(const char *arg) goto fail; ret = parse_port(u, ipv6port, TRUE); fail_unless(ret == CURLUE_OK, "parse_port returned error"); - free_and_clear(ipv6port); + Curl_safefree(ipv6port); curl_url_cleanup(u); /* Incorrect zone index syntax, but the port extractor does not care */ @@ -186,7 +184,7 @@ static CURLcode test_unit1653(const char *arg) fail_unless(ret == CURLUE_OK, "curl_url_get portnum returned error"); fail_unless(portnum && !strcmp(portnum, "180"), "Check portnumber"); curl_free(portnum); - free_and_clear(ipv6port); + Curl_safefree(ipv6port); curl_url_cleanup(u); /* Non percent-encoded zone index */ @@ -198,7 +196,7 @@ static CURLcode test_unit1653(const char *arg) goto fail; ret = parse_port(u, ipv6port, FALSE); fail_unless(ret == CURLUE_OK, "parse_port returned error"); - free_and_clear(ipv6port); + Curl_safefree(ipv6port); curl_url_cleanup(u); /* No scheme and no digits following the colon - not accepted. Because that From c9e50e9e393508c6a28c695abcf62980b3c1b023 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Thu, 27 Nov 2025 23:23:18 +0100 Subject: [PATCH 099/415] appveyor: add support for using custom CMake versions To allow more flexibility and not be limited by defaults offered by the runner machines: - Visual Studio 2013: CMake 3.12.2 - Visual Studio 2015, 2017: CMake 3.16.2 Ref: https://www.appveyor.com/docs/windows-images-software/ Start using 3.18.4, 3.19.8, 3.20.6 in older VS jobs to add variations. Time cost is a couple of seconds per job. Ref: #18704 (Discussion) Ref: #16973 Closes #19737 --- appveyor.sh | 17 +++++++++++++++++ appveyor.yml | 3 +++ 2 files changed, 20 insertions(+) diff --git a/appveyor.sh b/appveyor.sh index b20838da427b..56f8cc35277a 100644 --- a/appveyor.sh +++ b/appveyor.sh @@ -42,6 +42,23 @@ elif [ "${APPVEYOR_BUILD_WORKER_IMAGE}" = 'Visual Studio 2019' ]; then fi if [ "${BUILD_SYSTEM}" = 'CMake' ]; then + # Install custom cmake version + if [ -n "${CMAKE_VERSION:-}" ]; then + cmake_ver=$(printf '%02d%02d' \ + "$(echo "$CMAKE_VERSION" | cut -f1 -d.)" \ + "$(echo "$CMAKE_VERSION" | cut -f2 -d.)") + if [ "${cmake_ver}" -ge '0320' ]; then + fn="cmake-${CMAKE_VERSION}-windows-x86_64" + else + fn="cmake-${CMAKE_VERSION}-win64-x64" + fi + curl --disable --fail --silent --show-error --connect-timeout 15 --max-time 60 --retry 3 --retry-connrefused \ + --location "https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/${fn}.zip" --output bin.zip + 7z x -y bin.zip >/dev/null + rm -f bin.zip + PATH="$PWD/${fn}/bin:$PATH" + fi + # Set env CHKPREFILL to the value '_chkprefill' to compare feature detection # results with and without the pre-fill feature. They have to match. for _chkprefill in '' ${CHKPREFILL:-}; do diff --git a/appveyor.yml b/appveyor.yml index d10f8d39612f..91a425c7faca 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -79,6 +79,7 @@ environment: SHARED: 'ON' - job_name: 'CM VS2013, Debug, x64, Schannel, Shared, Build-only' APPVEYOR_BUILD_WORKER_IMAGE: 'Visual Studio 2015' + CMAKE_VERSION: '3.18.4' PRJ_GEN: 'Visual Studio 12 2013' TARGET: '-A x64' PRJ_CFG: Debug @@ -87,6 +88,7 @@ environment: TFLAGS: 'skipall' - job_name: 'CM VS2015, Debug, x64, Schannel, Static, Build-only' APPVEYOR_BUILD_WORKER_IMAGE: 'Visual Studio 2015' + CMAKE_VERSION: '3.19.8' PRJ_GEN: 'Visual Studio 14 2015' TARGET: '-A x64' PRJ_CFG: Debug @@ -94,6 +96,7 @@ environment: TFLAGS: 'skipall' - job_name: 'CM VS2017, Debug, x64, Schannel, Shared, Build-only' APPVEYOR_BUILD_WORKER_IMAGE: 'Visual Studio 2017' + CMAKE_VERSION: '3.20.6' PRJ_GEN: 'Visual Studio 15 2017' TARGET: '-A x64' PRJ_CFG: Debug From 5c275f7fef5337c8e743febc238735298315f902 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Fri, 28 Nov 2025 02:40:19 +0100 Subject: [PATCH 100/415] GHA/linux-old: stop installing `groff`, it is unused --- .github/workflows/linux-old.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/linux-old.yml b/.github/workflows/linux-old.yml index 64958f4bd61c..59da60987c96 100644 --- a/.github/workflows/linux-old.yml +++ b/.github/workflows/linux-old.yml @@ -72,7 +72,7 @@ jobs: dpkg -i freexian-archive-keyring_2022.06.08_all.deb echo 'deb http://deb.freexian.com/extended-lts stretch-lts main contrib non-free' | tee /etc/apt/sources.list.d/extended-lts.list apt-get -o Dpkg::Use-Pty=0 update - apt-get -o Dpkg::Use-Pty=0 install -y --no-install-suggests --no-install-recommends cmake make automake autoconf libtool gcc pkg-config libpsl-dev libzstd-dev zlib1g-dev libc-ares-dev libkrb5-dev libldap2-dev librtmp-dev stunnel4 groff + apt-get -o Dpkg::Use-Pty=0 install -y --no-install-suggests --no-install-recommends cmake make automake autoconf libtool gcc pkg-config libpsl-dev libzstd-dev zlib1g-dev libc-ares-dev libkrb5-dev libldap2-dev librtmp-dev stunnel4 # GitHub's actions/checkout needs newer glibc and libstdc++. The latter also depends on # gcc-8-base, but it does not actually seem used in our situation and is not available in # the main repo, so force the install. From e7c2f5bf53838871be4ebd7a9b2521da2a7f9226 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 26 Nov 2025 01:19:06 +0000 Subject: [PATCH 101/415] GHA: update dependency google/boringssl to v0.20251124.0 Closes #19685 --- .github/workflows/http3-linux.yml | 2 +- .github/workflows/linux.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/http3-linux.yml b/.github/workflows/http3-linux.yml index a9117e146ef9..77fd1edc09aa 100644 --- a/.github/workflows/http3-linux.yml +++ b/.github/workflows/http3-linux.yml @@ -45,7 +45,7 @@ env: # renovate: datasource=github-tags depName=awslabs/aws-lc versioning=semver registryUrl=https://github.com AWSLC_VERSION: 1.63.0 # renovate: datasource=github-tags depName=google/boringssl versioning=semver registryUrl=https://github.com - BORINGSSL_VERSION: 0.20251110.0 + BORINGSSL_VERSION: 0.20251124.0 # renovate: datasource=github-tags depName=gnutls/nettle versioning=semver registryUrl=https://github.com NETTLE_VERSION: 3.10.2 # renovate: datasource=github-tags depName=gnutls/gnutls versioning=semver extractVersion=^nettle_?(?.+)_release_.+$ registryUrl=https://github.com diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 0db8ca33b4ec..390cab72923f 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -48,7 +48,7 @@ env: # renovate: datasource=github-tags depName=awslabs/aws-lc versioning=semver registryUrl=https://github.com AWSLC_VERSION: 1.63.0 # renovate: datasource=github-tags depName=google/boringssl versioning=semver registryUrl=https://github.com - BORINGSSL_VERSION: 0.20251110.0 + BORINGSSL_VERSION: 0.20251124.0 # handled in renovate.json OPENSSL_VERSION: 3.6.0 # renovate: datasource=github-tags depName=rustls/rustls-ffi versioning=semver registryUrl=https://github.com From 9d059e27d1dd7d7baa863a6f7673488c965b3756 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 27 Nov 2025 01:01:01 +0000 Subject: [PATCH 102/415] GHA: update dependency pyspelling to v2.12.1 Closes #19712 --- .github/scripts/requirements-docs.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/scripts/requirements-docs.txt b/.github/scripts/requirements-docs.txt index fa26c105d095..6850461de7bc 100644 --- a/.github/scripts/requirements-docs.txt +++ b/.github/scripts/requirements-docs.txt @@ -2,4 +2,4 @@ # # SPDX-License-Identifier: curl -pyspelling==2.12 +pyspelling==2.12.1 From 48939a4575d5db6e875add0ccae93242f56fe581 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Fri, 28 Nov 2025 01:23:57 +0100 Subject: [PATCH 103/415] GHA/linux-old: add support for using custom CMake versions Install CMake from the Kitware GitHub release archive. To allow choosing its version independently from the OS. Switch to 3.7.0 (from 3.7.2) to test the earliest supported version. Also tested OK with 3.18.4 and 3.7.2. The download and install step takes 1-2 seconds. Follow-up to c9e50e9e393508c6a28c695abcf62980b3c1b023 #19737 Closes #19738 --- .github/workflows/linux-old.yml | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/.github/workflows/linux-old.yml b/.github/workflows/linux-old.yml index 59da60987c96..e282b1c47196 100644 --- a/.github/workflows/linux-old.yml +++ b/.github/workflows/linux-old.yml @@ -60,6 +60,8 @@ jobs: runs-on: 'ubuntu-latest' container: 'debian:stretch' + env: + CMAKE_VERSION: '3.7.0' # Earliest version supported by curl steps: - name: 'install prereqs' # Remember, this shell is dash, not bash @@ -72,7 +74,7 @@ jobs: dpkg -i freexian-archive-keyring_2022.06.08_all.deb echo 'deb http://deb.freexian.com/extended-lts stretch-lts main contrib non-free' | tee /etc/apt/sources.list.d/extended-lts.list apt-get -o Dpkg::Use-Pty=0 update - apt-get -o Dpkg::Use-Pty=0 install -y --no-install-suggests --no-install-recommends cmake make automake autoconf libtool gcc pkg-config libpsl-dev libzstd-dev zlib1g-dev libc-ares-dev libkrb5-dev libldap2-dev librtmp-dev stunnel4 + apt-get -o Dpkg::Use-Pty=0 install -y --no-install-suggests --no-install-recommends make automake autoconf libtool gcc pkg-config libpsl-dev libzstd-dev zlib1g-dev libc-ares-dev libkrb5-dev libldap2-dev librtmp-dev stunnel4 # GitHub's actions/checkout needs newer glibc and libstdc++. The latter also depends on # gcc-8-base, but it does not actually seem used in our situation and is not available in # the main repo, so force the install. @@ -80,6 +82,15 @@ jobs: httrack --get https://deb.freexian.com/extended-lts/pool/main/g/gcc-8/libstdc++6_8.3.0-6_amd64.deb dpkg -i --force-depends libc6_*_amd64.deb libstdc++6_*_amd64.deb + - name: 'install prereqs (cmake)' + run: | + cd ~ + fn="cmake-${CMAKE_VERSION}-linux-x86_64" + httrack --get "https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/${fn}.tar.gz" + tar -xf "${fn}".tar*.gz + rm -f "${fn}".tar*.gz + mv "cmake-${CMAKE_VERSION}-Linux-x86_64" cmake + - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 with: persist-credentials: false @@ -88,7 +99,7 @@ jobs: run: | mkdir bld-1 cd bld-1 - cmake .. -DCMAKE_UNITY_BUILD=ON -DCURL_WERROR=ON -DBUILD_SHARED_LIBS=ON \ + "$HOME"/cmake/bin/cmake .. -DCMAKE_UNITY_BUILD=ON -DCURL_WERROR=ON -DBUILD_SHARED_LIBS=ON \ -DCURL_ENABLE_SSL=OFF -DENABLE_ARES=OFF -DCURL_ZSTD=OFF -DCURL_USE_GSSAPI=OFF -DCURL_USE_LIBSSH2=OFF -DCURL_USE_LIBSSH=OFF -DUSE_LIBRTMP=ON - name: 'CM build-only build' @@ -112,7 +123,7 @@ jobs: run: | mkdir bld-cares cd bld-cares - cmake .. -DCMAKE_UNITY_BUILD=ON -DCURL_WERROR=ON -DBUILD_SHARED_LIBS=ON \ + "$HOME"/cmake/bin/cmake .. -DCMAKE_UNITY_BUILD=ON -DCURL_WERROR=ON -DBUILD_SHARED_LIBS=ON \ -DCURL_ENABLE_SSL=OFF -DENABLE_ARES=ON -DCURL_USE_GSSAPI=ON -DCURL_USE_LIBSSH2=OFF -DCURL_USE_LIBSSH=OFF -DUSE_LIBRTMP=ON \ -DCURL_LIBCURL_VERSIONED_SYMBOLS=ON From bfc3d131b6b5be7b7219dc016ff600f58e279c6c Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 28 Nov 2025 09:43:27 +0100 Subject: [PATCH 104/415] http: add asserts for null terminator for input strings http_rw_hd() assumes the null terminator is present. These asserts make sure this remains true. Closes #19741 --- lib/http.c | 2 ++ lib/transfer.c | 1 + 2 files changed, 3 insertions(+) diff --git a/lib/http.c b/lib/http.c index 672183db0ef2..8223c6f0e213 100644 --- a/lib/http.c +++ b/lib/http.c @@ -4142,6 +4142,7 @@ static CURLcode http_rw_hd(struct Curl_easy *data, CURLcode result = CURLE_OK; struct SingleRequest *k = &data->req; int writetype; + DEBUGASSERT(!hd[hdlen]); /* null terminated */ *pconsumed = 0; if((0x0a == *hd) || (0x0d == *hd)) { @@ -4426,6 +4427,7 @@ CURLcode Curl_http_write_resp_hd(struct Curl_easy *data, CURLcode result; size_t consumed; char tmp = 0; + DEBUGASSERT(!hd[hdlen]); /* null terminated */ result = http_rw_hd(data, hd, hdlen, &tmp, 0, &consumed); if(!result && is_eos) { diff --git a/lib/transfer.c b/lib/transfer.c index f2df2cef8cba..f0ce3c501271 100644 --- a/lib/transfer.c +++ b/lib/transfer.c @@ -820,6 +820,7 @@ CURLcode Curl_xfer_write_resp_hd(struct Curl_easy *data, const char *hd0, size_t hdlen, bool is_eos) { if(data->conn->handler->write_resp_hd) { + DEBUGASSERT(!hd0[hdlen]); /* null terminated */ /* protocol handlers offering this function take full responsibility * for writing all received download data to the client. */ return data->conn->handler->write_resp_hd(data, hd0, hdlen, is_eos); From 193cb00ce9b47e75d42157c650cc3de3fd96d35d Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Wed, 8 Oct 2025 02:33:19 +0200 Subject: [PATCH 105/415] build: stop overriding standard memory allocation functions Before this patch curl used the C preprocessor to override standard memory allocation symbols: malloc, calloc, strdup, realloc, free. The goal of these is to replace them with curl's debug wrappers in `CURLDEBUG` builds, another was to replace them with the wrappers calling user-defined allocators in libcurl. This solution needed a bunch of workarounds to avoid breaking external headers: it relied on include order to do the overriding last. For "unity" builds it needed to reset overrides before external includes. Also in test apps, which are always built as single source files. It also needed the `(symbol)` trick to avoid overrides in some places. This would still not fix cases where the standard symbols were macros. It was also fragile and difficult to figure out which was the actual function behind an alloc or free call in a specific piece of code. This in turn caused bugs where the wrong allocator was accidentally called. To avoid these problems, this patch replaces this solution with `curlx_`-prefixed allocator macros, and mapping them _once_ to either the libcurl wrappers, the debug wrappers or the standard ones, matching the rest of the code in libtests. This concludes the long journey to avoid redefining standard functions in the curl codebase. Note: I did not update `packages/OS400/*.c` sources. They did not `#include` `curl_setup.h`, `curl_memory.h` or `memdebug.h`, meaning the overrides were never applied to them. This may or may not have been correct. For now I suppressed the direct use of standard allocators via a local `.checksrc`. Probably they (except for `curlcl.c`) should be updated to include `curl_setup.h` and use the `curlx_` macros. This patch changes mappings in two places: - `lib/curl_threads.c` in libtests: Before this patch it mapped to libcurl allocators. After, it maps to standard allocators, like the rest of libtests code. - `units`: before this patch it mapped to standard allocators. After, it maps to libcurl allocators. Also: - drop all position-dependent `curl_memory.h` and `memdebug.h` includes, and delete the now unnecessary headers. - rename `Curl_tcsdup` macro to `curlx_tcsdup` and define like the other allocators. - map `curlx_strdup()` to `_strdup()` on Windows (was: `strdup()`). To fix warnings silenced via `_CRT_NONSTDC_NO_DEPRECATE`. - multibyte: map `curlx_convert_*()` to `_strdup()` on Windows (was: `strdup()`). - src: do not reuse the `strdup` name for the local replacement. - lib509: call `_strdup()` on Windows (was: `strdup()`). - test1132: delete test obsoleted by this patch. - CHECKSRC.md: update text for `SNPRINTF`. - checksrc: ban standard allocator symbols. Follow-up to b12da22db1f11da51082977dc21a7edee7858911 #18866 Follow-up to db98daab05aec251bcb6615d2d38dfebec291736 #18844 Follow-up to 4deea9396bc7dd25c6362fa746a57bf309c74ada #18814 Follow-up to 9678ff5b1bfea1c847aee4f9edf023e8f01c9293 #18776 Follow-up to 10bac43b873fe45869e15b36aac1c1e5bc89b6e0 #18774 Follow-up to 20142f5d06f7120ba94cbcc25c998e8d81aec85b #18634 Follow-up to bf7375ecc50e857760b0d0a668c436e208a400bd #18503 Follow-up to 9863599d69b79d290928a89bf9160f4e4e023d4e #18502 Follow-up to 3bb5e58c105d7be450b667858d1b8e7ae3ded555 #17827 Closes #19626 --- docs/examples/.checksrc | 5 + docs/internals/CHECKSRC.md | 2 +- docs/internals/CODE_STYLE.md | 5 + lib/Makefile.inc | 3 - lib/altsvc.c | 24 ++-- lib/amigaos.c | 8 +- lib/asyn-ares.c | 8 +- lib/asyn-base.c | 3 - lib/asyn-thrdd.c | 20 ++-- lib/bufq.c | 14 +-- lib/bufref.c | 3 - lib/cf-h1-proxy.c | 12 +- lib/cf-h2-proxy.c | 10 +- lib/cf-haproxy.c | 8 +- lib/cf-https-connect.c | 8 +- lib/cf-ip-happy.c | 12 +- lib/cf-socket.c | 16 +-- lib/cfilters.c | 8 +- lib/conncache.c | 8 +- lib/connect.c | 8 +- lib/content_encoding.c | 10 +- lib/cookie.c | 54 +++++---- lib/cshutdn.c | 4 - lib/curl_addrinfo.c | 17 ++- lib/curl_fnmatch.c | 4 - lib/curl_fopen.c | 8 +- lib/curl_get_line.c | 3 - lib/curl_gssapi.c | 24 ++-- lib/curl_mem_undef.h | 37 ------- lib/curl_memory.h | 89 --------------- lib/curl_memrchr.c | 4 - lib/curl_ntlm_core.c | 16 +-- lib/curl_rtmp.c | 4 - lib/curl_sasl.c | 4 - lib/curl_setup.h | 54 ++++++++- lib/curl_share.c | 10 +- lib/curl_sspi.c | 10 +- lib/curl_threads.c | 17 ++- lib/curl_trc.c | 4 - lib/curlx/base64.c | 12 +- lib/curlx/dynbuf.c | 8 +- lib/curlx/fopen.c | 59 ++++++---- lib/curlx/multibyte.c | 19 ++-- lib/curlx/multibyte.h | 18 +-- lib/curlx/strerr.c | 3 - lib/curlx/version_win32.c | 4 - lib/cw-out.c | 8 +- lib/cw-pause.c | 8 +- lib/dict.c | 11 +- lib/dllmain.c | 4 - lib/doh.c | 18 ++- lib/dynhds.c | 14 +-- lib/easy.c | 24 ++-- lib/escape.c | 10 +- lib/fake_addrinfo.c | 8 +- lib/file.c | 10 +- lib/fileinfo.c | 7 +- lib/formdata.c | 44 ++++---- lib/ftp.c | 68 ++++++------ lib/ftplistparser.c | 14 +-- lib/getenv.c | 11 +- lib/getinfo.c | 10 +- lib/gopher.c | 12 +- lib/hash.c | 10 +- lib/headers.c | 10 +- lib/hmac.c | 10 +- lib/hostip.c | 22 ++-- lib/hostip4.c | 14 +-- lib/hostip6.c | 4 - lib/hsts.c | 24 ++-- lib/http.c | 106 +++++++++--------- lib/http1.c | 4 - lib/http2.c | 30 +++-- lib/http_aws_sigv4.c | 30 +++-- lib/http_chunks.c | 4 - lib/http_digest.c | 10 +- lib/http_negotiate.c | 10 +- lib/http_ntlm.c | 12 +- lib/http_proxy.c | 12 +- lib/httpsrr.c | 14 +-- lib/idn.c | 18 ++- lib/if2ip.c | 4 - lib/imap.c | 42 ++++--- lib/ldap.c | 38 +++---- lib/llist.c | 4 - lib/md4.c | 4 - lib/md5.c | 18 ++- lib/memdebug.c | 4 - lib/memdebug.h | 56 ---------- lib/mime.c | 34 +++--- lib/mprintf.c | 6 +- lib/mqtt.c | 28 ++--- lib/multi.c | 34 +++--- lib/multi_ev.c | 10 +- lib/multi_ntfy.c | 9 +- lib/netrc.c | 28 ++--- lib/openldap.c | 16 +-- lib/pingpong.c | 4 - lib/pop3.c | 12 +- lib/psl.c | 4 - lib/rand.c | 4 - lib/rename.c | 4 - lib/request.c | 4 - lib/rtsp.c | 20 ++-- lib/select.c | 30 +++-- lib/sendf.c | 20 ++-- lib/setopt.c | 26 ++--- lib/sha256.c | 4 - lib/slist.c | 12 +- lib/smb.c | 25 ++--- lib/smtp.c | 32 +++--- lib/socketpair.c | 4 - lib/socks.c | 8 +- lib/socks_gssapi.c | 12 +- lib/socks_sspi.c | 32 +++--- lib/strdup.c | 16 +-- lib/strerror.c | 4 - lib/system_win32.c | 9 +- lib/telnet.c | 8 +- lib/tftp.c | 16 +-- lib/transfer.c | 14 +-- lib/uint-bset.c | 10 +- lib/uint-hash.c | 10 +- lib/uint-spbset.c | 8 +- lib/uint-table.c | 10 +- lib/url.c | 146 ++++++++++++------------- lib/urlapi.c | 86 +++++++-------- lib/vauth/cleartext.c | 4 - lib/vauth/cram.c | 4 - lib/vauth/digest.c | 74 ++++++------- lib/vauth/digest_sspi.c | 52 ++++----- lib/vauth/gsasl.c | 4 - lib/vauth/krb5_gssapi.c | 14 +-- lib/vauth/krb5_sspi.c | 28 ++--- lib/vauth/ntlm.c | 8 +- lib/vauth/ntlm_sspi.c | 14 +-- lib/vauth/oauth2.c | 4 - lib/vauth/spnego_gssapi.c | 8 +- lib/vauth/spnego_sspi.c | 18 ++- lib/vauth/vauth.c | 24 ++-- lib/vquic/curl_ngtcp2.c | 16 +-- lib/vquic/curl_osslq.c | 29 +++-- lib/vquic/curl_quiche.c | 16 +-- lib/vquic/vquic-tls.c | 4 - lib/vquic/vquic.c | 6 +- lib/vssh/libssh.c | 28 +++-- lib/vssh/libssh2.c | 48 ++++---- lib/vssh/vssh.c | 12 +- lib/vtls/apple.c | 10 +- lib/vtls/gtls.c | 25 ++--- lib/vtls/hostcheck.c | 4 - lib/vtls/keylog.c | 4 - lib/vtls/mbedtls.c | 28 ++--- lib/vtls/mbedtls_threadlock.c | 4 - lib/vtls/openssl.c | 36 +++--- lib/vtls/rustls.c | 10 +- lib/vtls/schannel.c | 63 +++++------ lib/vtls/schannel_verify.c | 8 +- lib/vtls/vtls.c | 38 +++---- lib/vtls/vtls_scache.c | 45 ++++---- lib/vtls/vtls_spack.c | 6 +- lib/vtls/wolfssl.c | 24 ++-- lib/vtls/x509asn1.c | 6 +- lib/ws.c | 12 +- packages/Makefile.am | 1 + packages/OS400/.checksrc | 9 ++ scripts/checksrc.pl | 5 + src/mkhelp.pl | 15 ++- src/slist_wc.c | 7 +- src/terminal.c | 1 - src/tool_bname.c | 2 - src/tool_cb_dbg.c | 2 - src/tool_cb_hdr.c | 10 +- src/tool_cb_prg.c | 2 - src/tool_cb_rea.c | 2 - src/tool_cb_see.c | 2 - src/tool_cb_wrt.c | 6 +- src/tool_cfgable.c | 11 +- src/tool_cfgable.h | 2 +- src/tool_dirhie.c | 2 - src/tool_doswin.c | 29 +++-- src/tool_easysrc.c | 2 - src/tool_findfile.c | 4 +- src/tool_formparse.c | 20 ++-- src/tool_getparam.c | 42 ++++--- src/tool_getpass.c | 2 - src/tool_help.c | 6 +- src/tool_helpers.c | 1 - src/tool_ipfs.c | 11 +- src/tool_libinfo.c | 1 - src/tool_libinfo.h | 1 - src/tool_main.c | 9 +- src/tool_msgs.c | 2 - src/tool_operate.c | 46 ++++---- src/tool_operhlp.c | 9 +- src/tool_paramhlp.c | 12 +- src/tool_parsecfg.c | 7 +- src/tool_setopt.c | 17 ++- src/tool_setup.h | 2 + src/tool_ssls.c | 8 +- src/tool_ssls.h | 1 - src/tool_stderr.c | 2 - src/tool_strdup.c | 7 +- src/tool_strdup.h | 2 +- src/tool_urlglob.c | 20 ++-- src/tool_util.c | 1 - src/tool_vms.c | 1 - src/tool_writeout.c | 1 - src/tool_xattr.c | 2 - src/var.c | 15 ++- tests/Makefile.am | 1 - tests/data/Makefile.am | 2 +- tests/data/test1132 | 21 ---- tests/libtest/cli_h2_pausing.c | 1 - tests/libtest/cli_h2_serverpush.c | 1 - tests/libtest/cli_h2_upgrade_extreme.c | 1 - tests/libtest/cli_hx_download.c | 14 +-- tests/libtest/cli_hx_upload.c | 5 +- tests/libtest/cli_tls_session_reuse.c | 1 - tests/libtest/cli_upload_pausing.c | 1 - tests/libtest/cli_ws_data.c | 17 ++- tests/libtest/cli_ws_pingpong.c | 1 - tests/libtest/first.c | 2 - tests/libtest/lib1156.c | 2 - tests/libtest/lib1485.c | 2 - tests/libtest/lib1500.c | 2 - tests/libtest/lib1501.c | 2 - tests/libtest/lib1502.c | 2 - tests/libtest/lib1506.c | 2 - tests/libtest/lib1507.c | 2 - tests/libtest/lib1508.c | 2 - tests/libtest/lib1509.c | 2 - tests/libtest/lib1510.c | 2 - tests/libtest/lib1511.c | 2 - tests/libtest/lib1512.c | 2 - tests/libtest/lib1513.c | 2 - tests/libtest/lib1514.c | 2 - tests/libtest/lib1515.c | 1 - tests/libtest/lib1517.c | 2 - tests/libtest/lib1518.c | 2 - tests/libtest/lib1520.c | 2 - tests/libtest/lib1522.c | 1 - tests/libtest/lib1523.c | 2 - tests/libtest/lib1525.c | 2 - tests/libtest/lib1526.c | 2 - tests/libtest/lib1527.c | 2 - tests/libtest/lib1528.c | 2 - tests/libtest/lib1529.c | 2 - tests/libtest/lib1530.c | 2 - tests/libtest/lib1531.c | 2 - tests/libtest/lib1532.c | 2 - tests/libtest/lib1533.c | 2 - tests/libtest/lib1534.c | 2 - tests/libtest/lib1535.c | 2 - tests/libtest/lib1536.c | 2 - tests/libtest/lib1537.c | 2 - tests/libtest/lib1538.c | 2 - tests/libtest/lib1540.c | 1 - tests/libtest/lib1541.c | 2 - tests/libtest/lib1542.c | 1 - tests/libtest/lib1549.c | 1 - tests/libtest/lib1550.c | 2 - tests/libtest/lib1551.c | 2 - tests/libtest/lib1552.c | 2 - tests/libtest/lib1553.c | 1 - tests/libtest/lib1554.c | 2 - tests/libtest/lib1555.c | 2 - tests/libtest/lib1556.c | 2 - tests/libtest/lib1557.c | 2 - tests/libtest/lib1558.c | 2 - tests/libtest/lib1559.c | 6 +- tests/libtest/lib1560.c | 2 - tests/libtest/lib1564.c | 2 - tests/libtest/lib1565.c | 2 - tests/libtest/lib1567.c | 2 - tests/libtest/lib1568.c | 2 - tests/libtest/lib1569.c | 2 - tests/libtest/lib1571.c | 2 - tests/libtest/lib1576.c | 2 - tests/libtest/lib1582.c | 2 - tests/libtest/lib1591.c | 2 - tests/libtest/lib1593.c | 2 - tests/libtest/lib1594.c | 2 - tests/libtest/lib1597.c | 2 - tests/libtest/lib1598.c | 2 - tests/libtest/lib1900.c | 2 - tests/libtest/lib1901.c | 2 - tests/libtest/lib1902.c | 2 - tests/libtest/lib1903.c | 2 - tests/libtest/lib1905.c | 2 - tests/libtest/lib1906.c | 2 - tests/libtest/lib1907.c | 2 - tests/libtest/lib1908.c | 2 - tests/libtest/lib1910.c | 2 - tests/libtest/lib1911.c | 2 - tests/libtest/lib1912.c | 2 - tests/libtest/lib1913.c | 2 - tests/libtest/lib1915.c | 1 - tests/libtest/lib1916.c | 2 - tests/libtest/lib1918.c | 2 - tests/libtest/lib1919.c | 2 - tests/libtest/lib1933.c | 2 - tests/libtest/lib1934.c | 2 - tests/libtest/lib1935.c | 2 - tests/libtest/lib1936.c | 2 - tests/libtest/lib1937.c | 2 - tests/libtest/lib1938.c | 2 - tests/libtest/lib1939.c | 2 - tests/libtest/lib1940.c | 2 - tests/libtest/lib1945.c | 2 - tests/libtest/lib1947.c | 2 - tests/libtest/lib1955.c | 2 - tests/libtest/lib1956.c | 2 - tests/libtest/lib1957.c | 2 - tests/libtest/lib1958.c | 2 - tests/libtest/lib1959.c | 2 - tests/libtest/lib1960.c | 2 - tests/libtest/lib1964.c | 2 - tests/libtest/lib1970.c | 2 - tests/libtest/lib1971.c | 2 - tests/libtest/lib1972.c | 2 - tests/libtest/lib1973.c | 2 - tests/libtest/lib1974.c | 2 - tests/libtest/lib1975.c | 2 - tests/libtest/lib1977.c | 2 - tests/libtest/lib1978.c | 2 - tests/libtest/lib2023.c | 6 +- tests/libtest/lib2032.c | 8 +- tests/libtest/lib2302.c | 4 +- tests/libtest/lib2402.c | 2 - tests/libtest/lib2404.c | 2 - tests/libtest/lib2405.c | 2 - tests/libtest/lib2502.c | 1 - tests/libtest/lib2700.c | 1 - tests/libtest/lib3010.c | 2 - tests/libtest/lib3025.c | 2 - tests/libtest/lib3027.c | 2 - tests/libtest/lib3033.c | 2 - tests/libtest/lib3100.c | 2 - tests/libtest/lib3101.c | 2 - tests/libtest/lib3102.c | 2 - tests/libtest/lib3103.c | 2 - tests/libtest/lib3104.c | 2 - tests/libtest/lib3105.c | 2 - tests/libtest/lib3207.c | 6 +- tests/libtest/lib3208.c | 2 - tests/libtest/lib500.c | 1 - tests/libtest/lib501.c | 2 - tests/libtest/lib502.c | 2 - tests/libtest/lib503.c | 2 - tests/libtest/lib504.c | 2 - tests/libtest/lib505.c | 2 - tests/libtest/lib506.c | 1 - tests/libtest/lib507.c | 2 - tests/libtest/lib508.c | 2 - tests/libtest/lib509.c | 29 +++-- tests/libtest/lib510.c | 2 - tests/libtest/lib511.c | 2 - tests/libtest/lib512.c | 2 - tests/libtest/lib513.c | 2 - tests/libtest/lib514.c | 2 - tests/libtest/lib515.c | 2 - tests/libtest/lib516.c | 2 - tests/libtest/lib517.c | 2 - tests/libtest/lib518.c | 35 +++--- tests/libtest/lib519.c | 2 - tests/libtest/lib520.c | 2 - tests/libtest/lib521.c | 2 - tests/libtest/lib523.c | 2 - tests/libtest/lib524.c | 2 - tests/libtest/lib525.c | 2 - tests/libtest/lib526.c | 2 - tests/libtest/lib530.c | 14 +-- tests/libtest/lib533.c | 2 - tests/libtest/lib536.c | 2 - tests/libtest/lib537.c | 36 +++--- tests/libtest/lib539.c | 2 - tests/libtest/lib540.c | 2 - tests/libtest/lib541.c | 2 - tests/libtest/lib542.c | 2 - tests/libtest/lib543.c | 2 - tests/libtest/lib544.c | 2 - tests/libtest/lib547.c | 2 - tests/libtest/lib549.c | 2 - tests/libtest/lib552.c | 1 - tests/libtest/lib553.c | 2 - tests/libtest/lib554.c | 2 - tests/libtest/lib555.c | 2 - tests/libtest/lib556.c | 2 - tests/libtest/lib557.c | 2 - tests/libtest/lib558.c | 4 +- tests/libtest/lib559.c | 2 - tests/libtest/lib560.c | 2 - tests/libtest/lib562.c | 2 - tests/libtest/lib564.c | 1 - tests/libtest/lib566.c | 2 - tests/libtest/lib567.c | 2 - tests/libtest/lib568.c | 1 - tests/libtest/lib569.c | 1 - tests/libtest/lib570.c | 1 - tests/libtest/lib571.c | 1 - tests/libtest/lib572.c | 1 - tests/libtest/lib573.c | 1 - tests/libtest/lib574.c | 2 - tests/libtest/lib575.c | 2 - tests/libtest/lib576.c | 2 - tests/libtest/lib578.c | 2 - tests/libtest/lib579.c | 2 - tests/libtest/lib582.c | 8 +- tests/libtest/lib583.c | 2 - tests/libtest/lib586.c | 2 - tests/libtest/lib589.c | 2 - tests/libtest/lib590.c | 2 - tests/libtest/lib591.c | 2 - tests/libtest/lib597.c | 2 - tests/libtest/lib598.c | 2 - tests/libtest/lib599.c | 2 - tests/libtest/lib643.c | 2 - tests/libtest/lib650.c | 2 - tests/libtest/lib651.c | 2 - tests/libtest/lib652.c | 2 - tests/libtest/lib653.c | 2 - tests/libtest/lib654.c | 2 - tests/libtest/lib655.c | 2 - tests/libtest/lib658.c | 2 - tests/libtest/lib659.c | 2 - tests/libtest/lib661.c | 2 - tests/libtest/lib666.c | 2 - tests/libtest/lib667.c | 2 - tests/libtest/lib668.c | 2 - tests/libtest/lib670.c | 2 - tests/libtest/lib674.c | 2 - tests/libtest/lib676.c | 2 - tests/libtest/lib677.c | 2 - tests/libtest/lib678.c | 8 +- tests/libtest/lib694.c | 2 - tests/libtest/lib695.c | 2 - tests/libtest/lib751.c | 2 - tests/libtest/lib753.c | 1 - tests/libtest/lib757.c | 2 - tests/libtest/lib758.c | 12 +- tests/libtest/lib766.c | 2 - tests/libtest/memptr.c | 2 - tests/libtest/mk-lib1521.pl | 1 - tests/libtest/testtrace.c | 2 - tests/libtest/testutil.c | 2 - tests/server/.checksrc | 5 + tests/test1132.pl | 98 ----------------- tests/tunit/tool1394.c | 6 +- tests/tunit/tool1604.c | 16 ++- tests/tunit/tool1621.c | 2 - tests/unit/unit1302.c | 1 - tests/unit/unit1303.c | 1 - tests/unit/unit1304.c | 13 +-- tests/unit/unit1305.c | 13 +-- tests/unit/unit1330.c | 4 +- tests/unit/unit1395.c | 3 +- tests/unit/unit1602.c | 12 +- tests/unit/unit1603.c | 2 - tests/unit/unit1607.c | 4 +- tests/unit/unit1609.c | 4 +- tests/unit/unit1616.c | 12 +- tests/unit/unit1620.c | 8 +- tests/unit/unit1653.c | 28 ++--- tests/unit/unit1661.c | 5 +- tests/unit/unit1663.c | 8 +- tests/unit/unit1664.c | 2 - tests/unit/unit2600.c | 9 +- tests/unit/unit2604.c | 5 +- tests/unit/unit2605.c | 1 - tests/unit/unit3200.c | 1 - 471 files changed, 1456 insertions(+), 2785 deletions(-) delete mode 100644 lib/curl_mem_undef.h delete mode 100644 lib/curl_memory.h delete mode 100644 lib/memdebug.h create mode 100644 packages/OS400/.checksrc delete mode 100644 tests/data/test1132 delete mode 100755 tests/test1132.pl diff --git a/docs/examples/.checksrc b/docs/examples/.checksrc index c47627467ff3..8c7b0c901e80 100644 --- a/docs/examples/.checksrc +++ b/docs/examples/.checksrc @@ -4,17 +4,22 @@ allowfunc atoi allowfunc atol +allowfunc calloc allowfunc fclose allowfunc fdopen allowfunc fopen allowfunc fprintf +allowfunc free allowfunc gmtime allowfunc localtime +allowfunc malloc allowfunc open allowfunc printf +allowfunc realloc allowfunc snprintf allowfunc socket allowfunc sscanf +allowfunc strdup allowfunc strerror allowfunc vsnprintf diff --git a/docs/internals/CHECKSRC.md b/docs/internals/CHECKSRC.md index 1740b2bef591..091a4d3107e6 100644 --- a/docs/internals/CHECKSRC.md +++ b/docs/internals/CHECKSRC.md @@ -107,7 +107,7 @@ warnings are: `sizeof(int)` style. - `SNPRINTF` - Found use of `snprintf()`. Since we use an internal replacement - with a different return code etc, we prefer `msnprintf()`. + with a different return code etc, we prefer `curl_msnprintf()`. - `SPACEAFTERPAREN`: there was a space after open parenthesis, `( text`. diff --git a/docs/internals/CODE_STYLE.md b/docs/internals/CODE_STYLE.md index 7d37df4805ec..43b873be9b37 100644 --- a/docs/internals/CODE_STYLE.md +++ b/docs/internals/CODE_STYLE.md @@ -352,10 +352,12 @@ This is the full list of functions generally banned. aprintf atoi atol + calloc fclose fdopen fopen fprintf + free freeaddrinfo freopen getaddrinfo @@ -368,11 +370,13 @@ This is the full list of functions generally banned. LoadLibraryExW LoadLibraryW localtime + malloc mbstowcs msnprintf mvsnprintf open printf + realloc recv send snprintf @@ -382,6 +386,7 @@ This is the full list of functions generally banned. sscanf stat strcat + strdup strerror strncat strncpy diff --git a/lib/Makefile.inc b/lib/Makefile.inc index 85faa875e072..cdd5587ec80b 100644 --- a/lib/Makefile.inc +++ b/lib/Makefile.inc @@ -300,8 +300,6 @@ LIB_HFILES = \ curl_ldap.h \ curl_md4.h \ curl_md5.h \ - curl_mem_undef.h \ - curl_memory.h \ curl_memrchr.h \ curl_ntlm_core.h \ curl_printf.h \ @@ -353,7 +351,6 @@ LIB_HFILES = \ imap.h \ llist.h \ macos.h \ - memdebug.h \ mime.h \ mqtt.h \ multihandle.h \ diff --git a/lib/altsvc.c b/lib/altsvc.c index c05dff04e2c1..84f6c1b44547 100644 --- a/lib/altsvc.c +++ b/lib/altsvc.c @@ -42,10 +42,6 @@ #include "curlx/strparse.h" #include "connect.h" -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - #define MAX_ALTSVC_LINE 4095 #define MAX_ALTSVC_DATELEN 256 #define MAX_ALTSVC_HOSTLEN 2048 @@ -71,9 +67,9 @@ const char *Curl_alpnid2str(enum alpnid id) static void altsvc_free(struct altsvc *as) { - free(as->src.host); - free(as->dst.host); - free(as); + curlx_free(as->src.host); + curlx_free(as->dst.host); + curlx_free(as); } static struct altsvc *altsvc_createid(const char *srchost, @@ -85,7 +81,7 @@ static struct altsvc *altsvc_createid(const char *srchost, size_t srcport, size_t dstport) { - struct altsvc *as = calloc(1, sizeof(struct altsvc)); + struct altsvc *as = curlx_calloc(1, sizeof(struct altsvc)); if(!as) return NULL; DEBUGASSERT(hlen); @@ -219,8 +215,8 @@ static CURLcode altsvc_load(struct altsvcinfo *asi, const char *file) /* we need a private copy of the filename so that the altsvc cache file name survives an easy handle reset */ - free(asi->filename); - asi->filename = strdup(file); + curlx_free(asi->filename); + asi->filename = curlx_strdup(file); if(!asi->filename) return CURLE_OUT_OF_MEMORY; @@ -299,7 +295,7 @@ static CURLcode altsvc_out(struct altsvc *as, FILE *fp) */ struct altsvcinfo *Curl_altsvc_init(void) { - struct altsvcinfo *asi = calloc(1, sizeof(struct altsvcinfo)); + struct altsvcinfo *asi = curlx_calloc(1, sizeof(struct altsvcinfo)); if(!asi) return NULL; Curl_llist_init(&asi->list, NULL); @@ -350,8 +346,8 @@ void Curl_altsvc_cleanup(struct altsvcinfo **altsvcp) n = Curl_node_next(e); altsvc_free(as); } - free(altsvc->filename); - free(altsvc); + curlx_free(altsvc->filename); + curlx_free(altsvc); *altsvcp = NULL; /* clear the pointer */ } } @@ -399,7 +395,7 @@ CURLcode Curl_altsvc_save(struct Curl_easy *data, if(result && tempstore) unlink(tempstore); } - free(tempstore); + curlx_free(tempstore); return result; } diff --git a/lib/amigaos.c b/lib/amigaos.c index e51236d1260a..e4b678d54185 100644 --- a/lib/amigaos.c +++ b/lib/amigaos.c @@ -42,10 +42,6 @@ # endif #endif -/* The last #include files should be: */ -#include "curl_memory.h" -#include "memdebug.h" - #ifdef HAVE_PROTO_BSDSOCKET_H #ifdef __amigaos4__ @@ -135,7 +131,7 @@ struct Curl_addrinfo *Curl_ipv4_resolve_r(const char *hostname, LONG h_errnop = 0; struct hostent *buf; - buf = calloc(1, CURL_HOSTENT_SIZE); + buf = curlx_calloc(1, CURL_HOSTENT_SIZE); if(buf) { h = gethostbyname_r((STRPTR)hostname, buf, (char *)buf + sizeof(struct hostent), @@ -144,7 +140,7 @@ struct Curl_addrinfo *Curl_ipv4_resolve_r(const char *hostname, if(h) { ai = Curl_he2ai(h, port); } - free(buf); + curlx_free(buf); } } else { diff --git a/lib/asyn-ares.c b/lib/asyn-ares.c index 1bc0f3247b78..e3ba512b77ff 100644 --- a/lib/asyn-ares.c +++ b/lib/asyn-ares.c @@ -104,10 +104,6 @@ #define HTTPSRR_WORKS #endif -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - #define CARES_TIMEOUT_PER_ATTEMPT 2000 static int ares_ver = 0; @@ -633,7 +629,7 @@ async_ares_node2addr(struct ares_addrinfo_node *node) if((size_t)ai->ai_addrlen < ss_size) continue; - ca = malloc(sizeof(struct Curl_addrinfo) + ss_size); + ca = curlx_malloc(sizeof(struct Curl_addrinfo) + ss_size); if(!ca) { error = EAI_MEMORY; break; @@ -736,7 +732,7 @@ CURLcode Curl_async_getaddrinfo(struct Curl_easy *data, const char *hostname, data->state.async.dns = NULL; /* clear */ data->state.async.port = port; data->state.async.ip_version = ip_version; - data->state.async.hostname = strdup(hostname); + data->state.async.hostname = curlx_strdup(hostname); if(!data->state.async.hostname) return CURLE_OUT_OF_MEMORY; #ifdef USE_HTTPSRR diff --git a/lib/asyn-base.c b/lib/asyn-base.c index d7e8e7d15b86..6338a3fc6e25 100644 --- a/lib/asyn-base.c +++ b/lib/asyn-base.c @@ -53,9 +53,6 @@ #include "select.h" #include "curl_share.h" #include "url.h" -#include "curl_memory.h" -/* The last #include file should be: */ -#include "memdebug.h" /*********************************************************************** * Only for builds using asynchronous name resolves diff --git a/lib/asyn-thrdd.c b/lib/asyn-thrdd.c index 71e31e6d0d16..6c2e02fd1871 100644 --- a/lib/asyn-thrdd.c +++ b/lib/asyn-thrdd.c @@ -72,10 +72,6 @@ #endif #endif -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - /* * Curl_async_global_init() @@ -136,7 +132,7 @@ static void addr_ctx_unlink(struct async_thrdd_addr_ctx **paddr_ctx, if(destroy) { Curl_mutex_destroy(&addr_ctx->mutx); - free(addr_ctx->hostname); + curlx_free(addr_ctx->hostname); if(addr_ctx->res) Curl_freeaddrinfo(addr_ctx->res); #ifndef CURL_DISABLE_SOCKETPAIR @@ -145,7 +141,7 @@ static void addr_ctx_unlink(struct async_thrdd_addr_ctx **paddr_ctx, #endif wakeup_close(addr_ctx->sock_pair[0]); #endif - free(addr_ctx); + curlx_free(addr_ctx); } *paddr_ctx = NULL; } @@ -156,7 +152,7 @@ addr_ctx_create(struct Curl_easy *data, const char *hostname, int port, const struct addrinfo *hints) { - struct async_thrdd_addr_ctx *addr_ctx = calloc(1, sizeof(*addr_ctx)); + struct async_thrdd_addr_ctx *addr_ctx = curlx_calloc(1, sizeof(*addr_ctx)); if(!addr_ctx) return NULL; @@ -186,7 +182,7 @@ addr_ctx_create(struct Curl_easy *data, /* Copying hostname string because original can be destroyed by parent * thread during gethostbyname execution. */ - addr_ctx->hostname = strdup(hostname); + addr_ctx->hostname = curlx_strdup(hostname); if(!addr_ctx->hostname) goto err_exit; @@ -376,7 +372,7 @@ static CURLcode async_rr_start(struct Curl_easy *data, int port) status = ares_init_options(&thrdd->rr.channel, NULL, 0); if(status != ARES_SUCCESS) { thrdd->rr.channel = NULL; - free(rrname); + curlx_free(rrname); return CURLE_FAILED_INIT; } #ifdef CURLDEBUG @@ -384,7 +380,7 @@ static CURLcode async_rr_start(struct Curl_easy *data, int port) const char *servers = getenv("CURL_DNS_SERVER"); status = ares_set_servers_ports_csv(thrdd->rr.channel, servers); if(status) { - free(rrname); + curlx_free(rrname); return CURLE_FAILED_INIT; } } @@ -435,8 +431,8 @@ static bool async_thrdd_init(struct Curl_easy *data, data->state.async.done = FALSE; data->state.async.port = port; data->state.async.ip_version = ip_version; - free(data->state.async.hostname); - data->state.async.hostname = strdup(hostname); + curlx_free(data->state.async.hostname); + data->state.async.hostname = curlx_strdup(hostname); if(!data->state.async.hostname) goto err_exit; diff --git a/lib/bufq.c b/lib/bufq.c index d38b78c6d5b2..5a77fc52d4b3 100644 --- a/lib/bufq.c +++ b/lib/bufq.c @@ -25,10 +25,6 @@ #include "curl_setup.h" #include "bufq.h" -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - static bool chunk_is_empty(const struct buf_chunk *chunk) { return chunk->r_offset >= chunk->w_offset; @@ -143,7 +139,7 @@ static void chunk_list_free(struct buf_chunk **anchor) while(*anchor) { chunk = *anchor; *anchor = chunk->next; - free(chunk); + curlx_free(chunk); } } @@ -178,7 +174,7 @@ static CURLcode bufcp_take(struct bufc_pool *pool, return CURLE_OUT_OF_MEMORY; } - chunk = calloc(1, sizeof(*chunk) + pool->chunk_size); + chunk = curlx_calloc(1, sizeof(*chunk) + pool->chunk_size); if(!chunk) { *pchunk = NULL; return CURLE_OUT_OF_MEMORY; @@ -192,7 +188,7 @@ static void bufcp_put(struct bufc_pool *pool, struct buf_chunk *chunk) { if(pool->spare_count >= pool->spare_max) { - free(chunk); + curlx_free(chunk); } else { chunk_reset(chunk); @@ -311,7 +307,7 @@ static struct buf_chunk *get_spare(struct bufq *q) return NULL; } - chunk = calloc(1, sizeof(*chunk) + q->chunk_size); + chunk = curlx_calloc(1, sizeof(*chunk) + q->chunk_size); if(!chunk) return NULL; chunk->dlen = q->chunk_size; @@ -338,7 +334,7 @@ static void prune_head(struct bufq *q) /* SOFT_LIMIT allowed us more than max. free spares until * we are at max again. Or free them if we are configured * to not use spares. */ - free(chunk); + curlx_free(chunk); --q->chunk_count; } else { diff --git a/lib/bufref.c b/lib/bufref.c index ac0612071d6c..d5181a5da662 100644 --- a/lib/bufref.c +++ b/lib/bufref.c @@ -27,9 +27,6 @@ #include "bufref.h" #include "strdup.h" -#include "curl_memory.h" -#include "memdebug.h" - #ifdef DEBUGBUILD #define SIGNATURE 0x5c48e9b2 /* Random pattern. */ #endif diff --git a/lib/cf-h1-proxy.c b/lib/cf-h1-proxy.c index 417b4df67e29..84ba3d6193fa 100644 --- a/lib/cf-h1-proxy.c +++ b/lib/cf-h1-proxy.c @@ -46,10 +46,6 @@ #include "multiif.h" #include "curlx/strparse.h" -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - typedef enum { H1_TUNNEL_INIT, /* init/default/no tunnel state */ @@ -116,7 +112,7 @@ static CURLcode tunnel_init(struct Curl_cfilter *cf, return CURLE_UNSUPPORTED_PROTOCOL; } - ts = calloc(1, sizeof(*ts)); + ts = curlx_calloc(1, sizeof(*ts)); if(!ts) return CURLE_OUT_OF_MEMORY; @@ -194,7 +190,7 @@ static void tunnel_free(struct Curl_cfilter *cf, curlx_dyn_free(&ts->rcvbuf); curlx_dyn_free(&ts->request_data); Curl_httpchunk_free(data, &ts->ch); - free(ts); + curlx_free(ts); cf->ctx = NULL; } } @@ -215,7 +211,7 @@ static CURLcode start_CONNECT(struct Curl_cfilter *cf, /* This only happens if we have looped here due to authentication reasons, and we do not really use the newly cloned URL here - then. Just free() it. */ + then. Just free it. */ Curl_safefree(data->req.newurl); result = Curl_http_proxy_create_CONNECT(&req, cf, data, 1); @@ -298,7 +294,7 @@ static CURLcode on_resp_header(struct Curl_cfilter *cf, CURL_TRC_CF(data, cf, "CONNECT: fwd auth header '%s'", header); result = Curl_http_input_auth(data, proxy, auth); - free(auth); + curlx_free(auth); if(result) return result; diff --git a/lib/cf-h2-proxy.c b/lib/cf-h2-proxy.c index fca916a2c24f..7066db3b4c4a 100644 --- a/lib/cf-h2-proxy.c +++ b/lib/cf-h2-proxy.c @@ -45,10 +45,6 @@ #include "curlx/warnless.h" #include "cf-h2-proxy.h" -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - #define PROXY_H2_CHUNK_SIZE (16*1024) #define PROXY_HTTP2_HUGE_WINDOW_SIZE (100 * 1024 * 1024) @@ -209,7 +205,7 @@ static void cf_h2_proxy_ctx_free(struct cf_h2_proxy_ctx *ctx) { if(ctx) { cf_h2_proxy_ctx_clear(ctx); - free(ctx); + curlx_free(ctx); } } @@ -919,7 +915,7 @@ static CURLcode proxy_h2_submit(int32_t *pstream_id, result = CURLE_OK; out: - free(nva); + curlx_free(nva); Curl_dynhds_free(&h2_headers); *pstream_id = stream_id; return result; @@ -1594,7 +1590,7 @@ CURLcode Curl_cf_h2_proxy_insert_after(struct Curl_cfilter *cf, CURLcode result = CURLE_OUT_OF_MEMORY; (void)data; - ctx = calloc(1, sizeof(*ctx)); + ctx = curlx_calloc(1, sizeof(*ctx)); if(!ctx) goto out; diff --git a/lib/cf-haproxy.c b/lib/cf-haproxy.c index 8912604504d8..a1793c0071ec 100644 --- a/lib/cf-haproxy.c +++ b/lib/cf-haproxy.c @@ -34,10 +34,6 @@ #include "multiif.h" #include "select.h" -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - typedef enum { HAPROXY_INIT, /* init/default/no tunnel state */ @@ -61,7 +57,7 @@ static void cf_haproxy_ctx_free(struct cf_haproxy_ctx *ctx) { if(ctx) { curlx_dyn_free(&ctx->data_out); - free(ctx); + curlx_free(ctx); } } @@ -217,7 +213,7 @@ static CURLcode cf_haproxy_create(struct Curl_cfilter **pcf, CURLcode result; (void)data; - ctx = calloc(1, sizeof(*ctx)); + ctx = curlx_calloc(1, sizeof(*ctx)); if(!ctx) { result = CURLE_OUT_OF_MEMORY; goto out; diff --git a/lib/cf-https-connect.c b/lib/cf-https-connect.c index 5491d7968d7e..ad815a0fe734 100644 --- a/lib/cf-https-connect.c +++ b/lib/cf-https-connect.c @@ -38,10 +38,6 @@ #include "select.h" #include "vquic/vquic.h" -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - typedef enum { CF_HC_INIT, CF_HC_CONNECT, @@ -588,7 +584,7 @@ static CURLcode cf_hc_create(struct Curl_cfilter **pcf, CURLcode result = CURLE_OK; size_t i; - ctx = calloc(1, sizeof(*ctx)); + ctx = curlx_calloc(1, sizeof(*ctx)); if(!ctx) { result = CURLE_OUT_OF_MEMORY; goto out; @@ -618,7 +614,7 @@ static CURLcode cf_hc_create(struct Curl_cfilter **pcf, out: *pcf = result ? NULL : cf; - free(ctx); + curlx_free(ctx); return result; } diff --git a/lib/cf-ip-happy.c b/lib/cf-ip-happy.c index eb62cd4c73d3..8901db02c283 100644 --- a/lib/cf-ip-happy.c +++ b/lib/cf-ip-happy.c @@ -60,10 +60,6 @@ #include "select.h" #include "vquic/vquic.h" /* for quic cfilters */ -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - struct transport_provider { uint8_t transport; @@ -186,7 +182,7 @@ static void cf_ip_attempt_free(struct cf_ip_attempt *a, if(a) { if(a->cf) Curl_conn_cf_discard_chain(&a->cf, data); - free(a); + curlx_free(a); } } @@ -203,7 +199,7 @@ static CURLcode cf_ip_attempt_new(struct cf_ip_attempt **pa, CURLcode result = CURLE_OK; *pa = NULL; - a = calloc(1, sizeof(*a)); + a = curlx_calloc(1, sizeof(*a)); if(!a) return CURLE_OUT_OF_MEMORY; @@ -941,7 +937,7 @@ static CURLcode cf_ip_happy_create(struct Curl_cfilter **pcf, (void)data; (void)conn; *pcf = NULL; - ctx = calloc(1, sizeof(*ctx)); + ctx = curlx_calloc(1, sizeof(*ctx)); if(!ctx) { result = CURLE_OUT_OF_MEMORY; goto out; @@ -954,7 +950,7 @@ static CURLcode cf_ip_happy_create(struct Curl_cfilter **pcf, out: if(result) { Curl_safefree(*pcf); - free(ctx); + curlx_free(ctx); } return result; } diff --git a/lib/cf-socket.c b/lib/cf-socket.c index 6e5333602c34..3172aee5b9c9 100644 --- a/lib/cf-socket.c +++ b/lib/cf-socket.c @@ -82,10 +82,6 @@ #include "curlx/strerr.h" #include "curlx/strparse.h" -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - #if defined(USE_IPV6) && defined(IPV6_V6ONLY) && defined(_WIN32) /* It makes support for IPv4-mapped IPv6 addresses. @@ -555,7 +551,7 @@ CURLcode Curl_parse_interface(const char *input, ++host_part; *host = Curl_memdup0(host_part, len - (host_part - input)); if(!*host) { - free(*iface); + curlx_free(*iface); *iface = NULL; return CURLE_OUT_OF_MEMORY; } @@ -1026,7 +1022,7 @@ static void cf_socket_destroy(struct Curl_cfilter *cf, struct Curl_easy *data) cf_socket_close(cf, data); CURL_TRC_CF(data, cf, "destroy"); - free(ctx); + curlx_free(ctx); cf->ctx = NULL; } @@ -1758,7 +1754,7 @@ CURLcode Curl_cf_tcp_create(struct Curl_cfilter **pcf, goto out; } - ctx = calloc(1, sizeof(*ctx)); + ctx = curlx_calloc(1, sizeof(*ctx)); if(!ctx) { result = CURLE_OUT_OF_MEMORY; goto out; @@ -1920,7 +1916,7 @@ CURLcode Curl_cf_udp_create(struct Curl_cfilter **pcf, (void)data; (void)conn; DEBUGASSERT(transport == TRNSPRT_UDP || transport == TRNSPRT_QUIC); - ctx = calloc(1, sizeof(*ctx)); + ctx = curlx_calloc(1, sizeof(*ctx)); if(!ctx) { result = CURLE_OUT_OF_MEMORY; goto out; @@ -1974,7 +1970,7 @@ CURLcode Curl_cf_unix_create(struct Curl_cfilter **pcf, (void)data; (void)conn; DEBUGASSERT(transport == TRNSPRT_UNIX); - ctx = calloc(1, sizeof(*ctx)); + ctx = curlx_calloc(1, sizeof(*ctx)); if(!ctx) { result = CURLE_OUT_OF_MEMORY; goto out; @@ -2199,7 +2195,7 @@ CURLcode Curl_conn_tcp_listen_set(struct Curl_easy *data, Curl_conn_cf_discard_all(data, conn, sockindex); DEBUGASSERT(conn->sock[sockindex] == CURL_SOCKET_BAD); - ctx = calloc(1, sizeof(*ctx)); + ctx = curlx_calloc(1, sizeof(*ctx)); if(!ctx) { result = CURLE_OUT_OF_MEMORY; goto out; diff --git a/lib/cfilters.c b/lib/cfilters.c index 7cb10f39282f..7d1f0c3d9e4f 100644 --- a/lib/cfilters.c +++ b/lib/cfilters.c @@ -37,10 +37,6 @@ #include "curlx/warnless.h" #include "curlx/strparse.h" -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - static void cf_cntrl_update_info(struct Curl_easy *data, struct connectdata *conn); @@ -143,7 +139,7 @@ void Curl_conn_cf_discard_chain(struct Curl_cfilter **pcf, */ cf->next = NULL; cf->cft->destroy(cf, data); - free(cf); + curlx_free(cf); cf = cfn; } } @@ -332,7 +328,7 @@ CURLcode Curl_cf_create(struct Curl_cfilter **pcf, CURLcode result = CURLE_OUT_OF_MEMORY; DEBUGASSERT(cft); - cf = calloc(1, sizeof(*cf)); + cf = curlx_calloc(1, sizeof(*cf)); if(!cf) goto out; diff --git a/lib/conncache.c b/lib/conncache.c index 9d3b69bec356..7f38a1875790 100644 --- a/lib/conncache.c +++ b/lib/conncache.c @@ -45,10 +45,6 @@ #include "curlx/strparse.h" #include "uint-table.h" -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - #define CPOOL_IS_LOCKED(c) ((c) && (c)->locked) @@ -92,7 +88,7 @@ static struct cpool_bundle *cpool_bundle_create(const char *dest) struct cpool_bundle *bundle; size_t dest_len = strlen(dest) + 1; - bundle = calloc(1, sizeof(*bundle) + dest_len - 1); + bundle = curlx_calloc(1, sizeof(*bundle) + dest_len - 1); if(!bundle) return NULL; Curl_llist_init(&bundle->conns, NULL); @@ -104,7 +100,7 @@ static struct cpool_bundle *cpool_bundle_create(const char *dest) static void cpool_bundle_destroy(struct cpool_bundle *bundle) { DEBUGASSERT(!Curl_llist_count(&bundle->conns)); - free(bundle); + curlx_free(bundle); } /* Add a connection to a bundle */ diff --git a/lib/connect.c b/lib/connect.c index e29c2f51bcf8..72a27fae1cd9 100644 --- a/lib/connect.c +++ b/lib/connect.c @@ -76,10 +76,6 @@ #include "http_proxy.h" #include "socks.h" -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - #if !defined(CURL_DISABLE_ALTSVC) || defined(USE_HTTPSRR) enum alpnid Curl_alpn2alpnid(const unsigned char *name, size_t len) @@ -527,7 +523,7 @@ static CURLcode cf_setup_create(struct Curl_cfilter **pcf, CURLcode result = CURLE_OK; (void)data; - ctx = calloc(1, sizeof(*ctx)); + ctx = curlx_calloc(1, sizeof(*ctx)); if(!ctx) { result = CURLE_OUT_OF_MEMORY; goto out; @@ -544,7 +540,7 @@ static CURLcode cf_setup_create(struct Curl_cfilter **pcf, out: *pcf = result ? NULL : cf; if(ctx) { - free(ctx); + curlx_free(ctx); } return result; } diff --git a/lib/content_encoding.c b/lib/content_encoding.c index f128f7565f77..84ed86c1df3d 100644 --- a/lib/content_encoding.c +++ b/lib/content_encoding.c @@ -52,10 +52,6 @@ #include "http.h" #include "content_encoding.h" -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - #define CONTENT_ENCODING_DEFAULT "identity" #ifndef CURL_DISABLE_HTTP @@ -95,15 +91,15 @@ static voidpf zalloc_cb(voidpf opaque, unsigned int items, unsigned int size) { (void)opaque; - /* not a typo, keep it calloc() */ - return (voidpf) calloc(items, size); + /* not a typo, keep it curlx_calloc() */ + return (voidpf)curlx_calloc(items, size); } static void zfree_cb(voidpf opaque, voidpf ptr) { (void)opaque; - free(ptr); + curlx_free(ptr); } static CURLcode diff --git a/lib/cookie.c b/lib/cookie.c index 6099c6ea560d..250c7390ce12 100644 --- a/lib/cookie.c +++ b/lib/cookie.c @@ -42,10 +42,6 @@ #include "llist.h" #include "curlx/strparse.h" -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - static void strstore(char **str, const char *newstr, size_t len); /* number of seconds in 400 days */ @@ -70,12 +66,12 @@ static void cap_expires(time_t now, struct Cookie *co) static void freecookie(struct Cookie *co) { - free(co->domain); - free(co->path); - free(co->spath); - free(co->name); - free(co->value); - free(co); + curlx_free(co->domain); + curlx_free(co->path); + curlx_free(co->spath); + curlx_free(co->name); + curlx_free(co->value); + curlx_free(co); } static bool cookie_tailmatch(const char *cookie_domain, @@ -246,7 +242,7 @@ static char *sanitize_cookie_path(const char *cookie_path) /* RFC6265 5.2.4 The Path Attribute */ if(cookie_path[0] != '/') /* Let cookie-path be the default-path. */ - return strdup("/"); + return curlx_strdup("/"); /* remove trailing slash when path is non-empty */ /* convert /hoge/ to /hoge */ @@ -268,7 +264,7 @@ static char *sanitize_cookie_path(const char *cookie_path) static void strstore(char **str, const char *newstr, size_t len) { DEBUGASSERT(str); - free(*str); + curlx_free(*str); if(!len) { len++; newstr = ""; @@ -506,7 +502,7 @@ parse_cookie_header(struct Curl_easy *data, strstore(&co->path, curlx_str(&val), curlx_strlen(&val)); if(!co->path) return CURLE_OUT_OF_MEMORY; - free(co->spath); /* if this is set again */ + curlx_free(co->spath); /* if this is set again */ co->spath = sanitize_cookie_path(co->path); if(!co->spath) return CURLE_OUT_OF_MEMORY; @@ -631,7 +627,7 @@ parse_cookie_header(struct Curl_easy *data, if(!co->domain && domain) { /* no domain was given in the header line, set the default */ - co->domain = strdup(domain); + co->domain = curlx_strdup(domain); if(!co->domain) return CURLE_OUT_OF_MEMORY; } @@ -739,10 +735,10 @@ parse_netscape(struct Cookie *co, break; } /* this does not look like a path, make one up! */ - co->path = strdup("/"); + co->path = curlx_strdup("/"); if(!co->path) return CURLE_OUT_OF_MEMORY; - co->spath = strdup("/"); + co->spath = curlx_strdup("/"); if(!co->spath) return CURLE_OUT_OF_MEMORY; fields++; /* add a field and fall down to secure */ @@ -781,7 +777,7 @@ parse_netscape(struct Cookie *co, } if(fields == 6) { /* we got a cookie with blank contents, fix it */ - co->value = strdup(""); + co->value = curlx_strdup(""); if(!co->value) return CURLE_OUT_OF_MEMORY; else @@ -981,7 +977,7 @@ Curl_cookie_add(struct Curl_easy *data, return CURLE_OK; /* silently ignore */ /* First, alloc and init a new struct for it */ - co = calloc(1, sizeof(struct Cookie)); + co = curlx_calloc(1, sizeof(struct Cookie)); if(!co) return CURLE_OUT_OF_MEMORY; /* bail out if we are this low on memory */ @@ -1081,7 +1077,7 @@ Curl_cookie_add(struct Curl_easy *data, struct CookieInfo *Curl_cookie_init(void) { int i; - struct CookieInfo *ci = calloc(1, sizeof(struct CookieInfo)); + struct CookieInfo *ci = curlx_calloc(1, sizeof(struct CookieInfo)); if(!ci) return NULL; @@ -1343,7 +1339,7 @@ CURLcode Curl_cookie_getlist(struct Curl_easy *data, size_t i; /* alloc an array and store all cookie pointers */ - array = malloc(sizeof(struct Cookie *) * matches); + array = curlx_malloc(sizeof(struct Cookie *) * matches); if(!array) { result = CURLE_OUT_OF_MEMORY; goto fail; @@ -1363,7 +1359,7 @@ CURLcode Curl_cookie_getlist(struct Curl_easy *data, for(i = 0; i < matches; i++) Curl_llist_append(list, array[i], &array[i]->getnode); - free(array); /* remove the temporary data again */ + curlx_free(array); /* remove the temporary data again */ } *okay = TRUE; @@ -1435,7 +1431,7 @@ void Curl_cookie_cleanup(struct CookieInfo *ci) { if(ci) { Curl_cookie_clearall(ci); - free(ci); /* free the base struct as well */ + curlx_free(ci); /* free the base struct as well */ } } @@ -1518,7 +1514,7 @@ static CURLcode cookie_output(struct Curl_easy *data, struct Cookie **array; struct Curl_llist_node *n; - array = calloc(1, sizeof(struct Cookie *) * ci->numcookies); + array = curlx_calloc(1, sizeof(struct Cookie *) * ci->numcookies); if(!array) { error = CURLE_OUT_OF_MEMORY; goto error; @@ -1540,15 +1536,15 @@ static CURLcode cookie_output(struct Curl_easy *data, for(i = 0; i < nvalid; i++) { char *format_ptr = get_netscape_format(array[i]); if(!format_ptr) { - free(array); + curlx_free(array); error = CURLE_OUT_OF_MEMORY; goto error; } curl_mfprintf(out, "%s\n", format_ptr); - free(format_ptr); + curlx_free(format_ptr); } - free(array); + curlx_free(array); } if(!use_stdout) { @@ -1565,7 +1561,7 @@ static CURLcode cookie_output(struct Curl_easy *data, * no need to inspect the error, any error case should have jumped into the * error block below. */ - free(tempstore); + curlx_free(tempstore); return CURLE_OK; error: @@ -1573,7 +1569,7 @@ static CURLcode cookie_output(struct Curl_easy *data, curlx_fclose(out); if(tempstore) { unlink(tempstore); - free(tempstore); + curlx_free(tempstore); } return error; } @@ -1605,7 +1601,7 @@ static struct curl_slist *cookie_list(struct Curl_easy *data) } beg = Curl_slist_append_nodup(list, line); if(!beg) { - free(line); + curlx_free(line); curl_slist_free_all(list); return NULL; } diff --git a/lib/cshutdn.c b/lib/cshutdn.c index e039d027625b..0a4ab416473f 100644 --- a/lib/cshutdn.c +++ b/lib/cshutdn.c @@ -42,10 +42,6 @@ #include "select.h" #include "curlx/strparse.h" -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - static void cshutdn_run_conn_handler(struct Curl_easy *data, struct connectdata *conn) diff --git a/lib/curl_addrinfo.c b/lib/curl_addrinfo.c index cd9b52febaa7..67c2f4177d5f 100644 --- a/lib/curl_addrinfo.c +++ b/lib/curl_addrinfo.c @@ -54,10 +54,6 @@ #include "curlx/inet_pton.h" #include "curlx/warnless.h" -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - /* * Curl_freeaddrinfo() * @@ -83,7 +79,7 @@ Curl_freeaddrinfo(struct Curl_addrinfo *cahead) for(ca = cahead; ca; ca = canext) { canext = ca->ai_next; - free(ca); + curlx_free(ca); } } @@ -146,7 +142,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 = curlx_malloc(sizeof(struct Curl_addrinfo) + ss_size + namelen); if(!ca) { error = EAI_MEMORY; break; @@ -285,7 +281,7 @@ Curl_he2ai(const struct hostent *he, int port) ss_size = sizeof(struct sockaddr_in); /* allocate memory to hold the struct, the address and the name */ - ai = calloc(1, sizeof(struct Curl_addrinfo) + ss_size + namelen); + ai = curlx_calloc(1, sizeof(struct Curl_addrinfo) + ss_size + namelen); if(!ai) { result = CURLE_OUT_OF_MEMORY; break; @@ -382,7 +378,7 @@ ip2addr(struct Curl_addrinfo **addrp, return CURLE_BAD_FUNCTION_ARGUMENT; /* allocate memory to hold the struct, the address and the name */ - ai = calloc(1, sizeof(struct Curl_addrinfo) + addrsize + namelen); + ai = curlx_calloc(1, sizeof(struct Curl_addrinfo) + addrsize + namelen); if(!ai) return CURLE_OUT_OF_MEMORY; /* put the address after the struct */ @@ -471,7 +467,8 @@ struct Curl_addrinfo *Curl_unix2addr(const char *path, bool *longpath, *longpath = FALSE; - ai = calloc(1, sizeof(struct Curl_addrinfo) + sizeof(struct sockaddr_un)); + ai = curlx_calloc(1, + sizeof(struct Curl_addrinfo) + sizeof(struct sockaddr_un)); if(!ai) return NULL; ai->ai_addr = (void *)((char *)ai + sizeof(struct Curl_addrinfo)); @@ -482,7 +479,7 @@ struct Curl_addrinfo *Curl_unix2addr(const char *path, bool *longpath, /* 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); + curlx_free(ai); *longpath = TRUE; return NULL; } diff --git a/lib/curl_fnmatch.c b/lib/curl_fnmatch.c index 3148c472e299..918be89d4bf1 100644 --- a/lib/curl_fnmatch.c +++ b/lib/curl_fnmatch.c @@ -27,10 +27,6 @@ #include #include "curl_fnmatch.h" -#include "curl_memory.h" - -/* The last #include file should be: */ -#include "memdebug.h" #ifndef HAVE_FNMATCH diff --git a/lib/curl_fopen.c b/lib/curl_fopen.c index f16b3d6cde0d..cccf849acb7d 100644 --- a/lib/curl_fopen.c +++ b/lib/curl_fopen.c @@ -31,10 +31,6 @@ #include "rand.h" #include "curl_fopen.h" -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - /* The dirslash() function breaks a null-terminated pathname string into directory and filename components then returns the directory component up @@ -120,7 +116,7 @@ CURLcode Curl_fopen(struct Curl_easy *data, const char *filename, /* The temp filename should not end up too long for the target file system */ tempstore = curl_maprintf("%s%s.tmp", dir, randbuf); - free(dir); + curlx_free(dir); } if(!tempstore) { @@ -156,7 +152,7 @@ CURLcode Curl_fopen(struct Curl_easy *data, const char *filename, unlink(tempstore); } - free(tempstore); + curlx_free(tempstore); return result; } diff --git a/lib/curl_get_line.c b/lib/curl_get_line.c index d5ab7b842720..ea31eb182fa3 100644 --- a/lib/curl_get_line.c +++ b/lib/curl_get_line.c @@ -28,9 +28,6 @@ !defined(CURL_DISABLE_HSTS) || !defined(CURL_DISABLE_NETRC) #include "curl_get_line.h" -#include "curl_memory.h" -/* The last #include file should be: */ -#include "memdebug.h" #define appendnl(b) \ curlx_dyn_addn(buf, "\n", 1) diff --git a/lib/curl_gssapi.c b/lib/curl_gssapi.c index 947bb9c00631..edd555db7923 100644 --- a/lib/curl_gssapi.c +++ b/lib/curl_gssapi.c @@ -31,10 +31,8 @@ #ifdef DEBUGBUILD #if defined(HAVE_GSSGNU) || !defined(_WIN32) -/* To avoid memdebug macro replacement, wrap the name in parentheses to call - the original version. It is freed via the GSS API gss_release_buffer(). */ -#define Curl_gss_alloc (malloc) -#define Curl_gss_free (free) +#define Curl_gss_alloc malloc /* freed via the GSS API gss_release_buffer() */ +#define Curl_gss_free free /* pair of the above */ #define CURL_GSS_STUB /* For correctness this would be required for all platforms, not only Windows, but, as of v1.22.1, MIT Kerberos uses a special allocator only for Windows, @@ -51,10 +49,6 @@ #endif #endif /* DEBUGBUILD */ -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - #ifdef __GNUC__ #define CURL_ALIGN8 __attribute__((aligned(8))) #else @@ -208,7 +202,7 @@ stub_gss_init_sec_context(OM_uint32 *min, return GSS_S_FAILURE; } - ctx = calloc(1, sizeof(*ctx)); + ctx = curlx_calloc(1, sizeof(*ctx)); if(!ctx) { *min = STUB_GSS_NO_MEMORY; return GSS_S_FAILURE; @@ -225,7 +219,7 @@ stub_gss_init_sec_context(OM_uint32 *min, else if(ctx->have_ntlm) ctx->sent = STUB_GSS_NTLM1; else { - free(ctx); + curlx_free(ctx); *min = STUB_GSS_NO_MECH; return GSS_S_FAILURE; } @@ -236,7 +230,7 @@ stub_gss_init_sec_context(OM_uint32 *min, token = Curl_gss_alloc(length); if(!token) { - free(ctx); + curlx_free(ctx); *min = STUB_GSS_NO_MEMORY; return GSS_S_FAILURE; } @@ -250,14 +244,14 @@ stub_gss_init_sec_context(OM_uint32 *min, &target_desc, &name_type); if(GSS_ERROR(major_status)) { Curl_gss_free(token); - free(ctx); + curlx_free(ctx); *min = STUB_GSS_NO_MEMORY; return GSS_S_FAILURE; } if(strlen(creds) + target_desc.length + 5 >= sizeof(ctx->creds)) { Curl_gss_free(token); - free(ctx); + curlx_free(ctx); *min = STUB_GSS_NO_MEMORY; return GSS_S_FAILURE; } @@ -273,7 +267,7 @@ stub_gss_init_sec_context(OM_uint32 *min, if(used >= length) { Curl_gss_free(token); - free(ctx); + curlx_free(ctx); *min = STUB_GSS_NO_MEMORY; return GSS_S_FAILURE; } @@ -308,7 +302,7 @@ stub_gss_delete_sec_context(OM_uint32 *min, return GSS_S_FAILURE; } - free(*context); + curlx_free(*context); *context = NULL; *min = 0; diff --git a/lib/curl_mem_undef.h b/lib/curl_mem_undef.h deleted file mode 100644 index 2be114cbd5e6..000000000000 --- a/lib/curl_mem_undef.h +++ /dev/null @@ -1,37 +0,0 @@ -/*************************************************************************** - * _ _ ____ _ - * Project ___| | | | _ \| | - * / __| | | | |_) | | - * | (__| |_| | _ <| |___ - * \___|\___/|_| \_\_____| - * - * Copyright (C) Daniel Stenberg, , et al. - * - * This software is licensed as described in the 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. - * - * SPDX-License-Identifier: curl - * - ***************************************************************************/ - -/* Unset redefined system symbols. */ - -#undef strdup -#undef malloc -#undef calloc -#undef realloc -#undef free -#ifdef _WIN32 -#undef Curl_tcsdup -#endif - -#undef HEADER_CURL_MEMORY_H -#undef HEADER_CURL_MEMDEBUG_H diff --git a/lib/curl_memory.h b/lib/curl_memory.h deleted file mode 100644 index 7793bb63a389..000000000000 --- a/lib/curl_memory.h +++ /dev/null @@ -1,89 +0,0 @@ -#ifndef HEADER_CURL_MEMORY_H -#define HEADER_CURL_MEMORY_H -/*************************************************************************** - * _ _ ____ _ - * Project ___| | | | _ \| | - * / __| | | | |_) | | - * | (__| |_| | _ <| |___ - * \___|\___/|_| \_\_____| - * - * Copyright (C) Daniel Stenberg, , et al. - * - * This software is licensed as described in the 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. - * - * SPDX-License-Identifier: curl - * - ***************************************************************************/ - -/* - * Nasty internal details ahead... - * - * File curl_memory.h must be included by _all_ *.c source files - * that use memory related functions strdup, malloc, calloc, realloc - * or free, and given source file is used to build libcurl library. - * It should be included immediately before memdebug.h as the last files - * included to avoid undesired interaction with other memory function - * headers in dependent libraries. - * - * There is nearly no exception to above rule. All libcurl source - * files in 'lib' subdirectory as well as those living deep inside - * 'packages' subdirectories and linked together in order to build - * libcurl library shall follow it. - * - * File lib/strdup.c is an exception, given that it provides a strdup - * clone implementation while using malloc. Extra care needed inside - * this one. - * - * The need for curl_memory.h inclusion is due to libcurl's feature - * of allowing library user to provide memory replacement functions, - * memory callbacks, at runtime with curl_global_init_mem() - * - * Any *.c source file used to build libcurl library that does not - * include curl_memory.h and uses any memory function of the five - * mentioned above will compile without any indication, but it will - * trigger weird memory related issues at runtime. - * - */ - -#ifndef CURLDEBUG - -/* - * libcurl's 'memory tracking' system defines strdup, malloc, calloc, - * realloc and free, along with others, in memdebug.h in a different - * way although still using memory callbacks forward declared above. - * When using the 'memory tracking' system (CURLDEBUG defined) we do - * not define here the five memory functions given that definitions - * from memdebug.h are the ones that shall be used. - */ - -#undef strdup -#define strdup(ptr) Curl_cstrdup(ptr) -#undef malloc -#define malloc(size) Curl_cmalloc(size) -#undef calloc -#define calloc(nbelem,size) Curl_ccalloc(nbelem, size) -#undef realloc -#define realloc(ptr,size) Curl_crealloc(ptr, size) -#undef free -#define free(ptr) Curl_cfree(ptr) - -#ifdef _WIN32 -#undef Curl_tcsdup -#ifdef UNICODE -#define Curl_tcsdup(ptr) Curl_wcsdup(ptr) -#else -#define Curl_tcsdup(ptr) Curl_cstrdup(ptr) -#endif -#endif /* _WIN32 */ - -#endif /* CURLDEBUG */ -#endif /* HEADER_CURL_MEMORY_H */ diff --git a/lib/curl_memrchr.c b/lib/curl_memrchr.c index 5b6a39c022cc..81464584070c 100644 --- a/lib/curl_memrchr.c +++ b/lib/curl_memrchr.c @@ -27,10 +27,6 @@ #include #include "curl_memrchr.h" -#include "curl_memory.h" - -/* The last #include file should be: */ -#include "memdebug.h" #ifndef HAVE_MEMRCHR /* diff --git a/lib/curl_ntlm_core.c b/lib/curl_ntlm_core.c index d013929d4da6..f2c8c2d2a659 100644 --- a/lib/curl_ntlm_core.c +++ b/lib/curl_ntlm_core.c @@ -122,10 +122,6 @@ #include "curl_endian.h" #include "curl_md4.h" -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - #ifdef USE_CURL_DES_SET_ODD_PARITY /* * curl_des_set_odd_parity() @@ -437,7 +433,7 @@ CURLcode Curl_ntlm_core_mk_nt_hash(const char *password, CURLcode result; if(len > SIZE_MAX/2) /* avoid integer overflow */ return CURLE_OUT_OF_MEMORY; - pw = len ? malloc(len * 2) : (unsigned char *)strdup(""); + pw = len ? curlx_malloc(len * 2) : (unsigned char *)curlx_strdup(""); if(!pw) return CURLE_OUT_OF_MEMORY; @@ -448,7 +444,7 @@ CURLcode Curl_ntlm_core_mk_nt_hash(const char *password, if(!result) memset(ntbuffer + 16, 0, 21 - 16); - free(pw); + curlx_free(pw); return result; } @@ -525,7 +521,7 @@ CURLcode Curl_ntlm_core_mk_ntlmv2_hash(const char *user, size_t userlen, return CURLE_OUT_OF_MEMORY; identity_len = (userlen + domlen) * 2; - identity = malloc(identity_len + 1); + identity = curlx_malloc(identity_len + 1); if(!identity) return CURLE_OUT_OF_MEMORY; @@ -535,7 +531,7 @@ CURLcode Curl_ntlm_core_mk_ntlmv2_hash(const char *user, size_t userlen, result = Curl_hmacit(&Curl_HMAC_MD5, ntlmhash, 16, identity, identity_len, ntlmv2hash); - free(identity); + curlx_free(identity); return result; } @@ -598,7 +594,7 @@ CURLcode Curl_ntlm_core_mk_ntlmv2_resp(unsigned char *ntlmv2hash, len = HMAC_MD5_LENGTH + NTLMv2_BLOB_LEN; /* Allocate the response */ - ptr = calloc(1, len); + ptr = curlx_calloc(1, len); if(!ptr) return CURLE_OUT_OF_MEMORY; @@ -622,7 +618,7 @@ CURLcode Curl_ntlm_core_mk_ntlmv2_resp(unsigned char *ntlmv2hash, result = Curl_hmacit(&Curl_HMAC_MD5, ntlmv2hash, HMAC_MD5_LENGTH, ptr + 8, NTLMv2_BLOB_LEN + 8, hmac_output); if(result) { - free(ptr); + curlx_free(ptr); return result; } diff --git a/lib/curl_rtmp.c b/lib/curl_rtmp.c index 2d2daf414897..351c9f494c3f 100644 --- a/lib/curl_rtmp.c +++ b/lib/curl_rtmp.c @@ -37,10 +37,6 @@ #include #include -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - #if defined(_WIN32) && !defined(USE_LWIPSOCK) #define setsockopt(a,b,c,d,e) (setsockopt)(a,b,c,(const char *)d,(int)e) #define SET_RCVTIMEO(tv,s) int tv = s*1000 diff --git a/lib/curl_sasl.c b/lib/curl_sasl.c index f6ec668bfd45..aef47dc0162e 100644 --- a/lib/curl_sasl.c +++ b/lib/curl_sasl.c @@ -51,10 +51,6 @@ #include "curlx/warnless.h" #include "sendf.h" -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - /* Supported mechanisms */ static const struct { const char *name; /* Name */ diff --git a/lib/curl_setup.h b/lib/curl_setup.h index 6236a7153923..6acac0d17ad0 100644 --- a/lib/curl_setup.h +++ b/lib/curl_setup.h @@ -941,7 +941,7 @@ extern curl_calloc_callback Curl_ccalloc; * This macro also assigns NULL to given pointer when free'd. */ #define Curl_safefree(ptr) \ - do { free(ptr); (ptr) = NULL;} while(0) + do { curlx_free(ptr); (ptr) = NULL;} while(0) #include /* for CURL_EXTERN, mprintf.h */ @@ -1077,6 +1077,56 @@ CURL_EXTERN ALLOC_FUNC #endif /* CURLDEBUG */ +/* Allocator macros */ + +#ifdef CURLDEBUG + +#define curlx_strdup(ptr) curl_dbg_strdup(ptr, __LINE__, __FILE__) +#define curlx_malloc(size) curl_dbg_malloc(size, __LINE__, __FILE__) +#define curlx_calloc(nbelem,size) \ + curl_dbg_calloc(nbelem, size, __LINE__, __FILE__) +#define curlx_realloc(ptr,size) \ + curl_dbg_realloc(ptr, size, __LINE__, __FILE__) +#define curlx_free(ptr) curl_dbg_free(ptr, __LINE__, __FILE__) + +#ifdef _WIN32 +#ifdef UNICODE +#define curlx_tcsdup(ptr) curl_dbg_wcsdup(ptr, __LINE__, __FILE__) +#else +#define curlx_tcsdup(ptr) curlx_strdup(ptr) +#endif +#endif /* _WIN32 */ + +#else /* !CURLDEBUG */ + +#ifdef BUILDING_LIBCURL +#define curlx_strdup(ptr) Curl_cstrdup(ptr) +#define curlx_malloc(size) Curl_cmalloc(size) +#define curlx_calloc(nbelem,size) Curl_ccalloc(nbelem, size) +#define curlx_realloc(ptr,size) Curl_crealloc(ptr, size) +#define curlx_free(ptr) Curl_cfree(ptr) +#else /* !BUILDING_LIBCURL */ +#ifdef _WIN32 +#define curlx_strdup(ptr) _strdup(ptr) +#else +#define curlx_strdup(ptr) strdup(ptr) +#endif +#define curlx_malloc(size) malloc(size) +#define curlx_calloc(nbelem,size) calloc(nbelem, size) +#define curlx_realloc(ptr,size) realloc(ptr, size) +#define curlx_free(ptr) free(ptr) +#endif /* BUILDING_LIBCURL */ + +#ifdef _WIN32 +#ifdef UNICODE +#define curlx_tcsdup(ptr) Curl_wcsdup(ptr) +#else +#define curlx_tcsdup(ptr) curlx_strdup(ptr) +#endif +#endif /* _WIN32 */ + +#endif /* CURLDEBUG */ + /* Some versions of the Android NDK is missing the declaration */ #if defined(HAVE_GETPWUID_R) && \ defined(__ANDROID_API__) && (__ANDROID_API__ < 21) @@ -1167,5 +1217,3 @@ int getpwuid_r(uid_t uid, struct passwd *pwd, char *buf, #endif #endif /* HEADER_CURL_SETUP_H */ - -#include "curl_mem_undef.h" diff --git a/lib/curl_share.c b/lib/curl_share.c index b65d16c6281f..c6b51267046f 100644 --- a/lib/curl_share.c +++ b/lib/curl_share.c @@ -34,21 +34,17 @@ #include "hsts.h" #include "url.h" -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - CURLSH * curl_share_init(void) { - struct Curl_share *share = calloc(1, sizeof(struct Curl_share)); + struct Curl_share *share = curlx_calloc(1, sizeof(struct Curl_share)); if(share) { share->magic = CURL_GOOD_SHARE; share->specifier |= (1 << CURL_LOCK_DATA_SHARE); Curl_dnscache_init(&share->dnscache, 23); share->admin = curl_easy_init(); if(!share->admin) { - free(share); + curlx_free(share); return NULL; } /* admin handles have mid 0 */ @@ -272,7 +268,7 @@ curl_share_cleanup(CURLSH *sh) if(share->unlockfunc) share->unlockfunc(NULL, CURL_LOCK_DATA_SHARE, share->clientdata); share->magic = 0; - free(share); + curlx_free(share); return CURLSHE_OK; } diff --git a/lib/curl_sspi.c b/lib/curl_sspi.c index 369cf18967a3..264703d8cd70 100644 --- a/lib/curl_sspi.c +++ b/lib/curl_sspi.c @@ -33,10 +33,6 @@ #include "system_win32.h" #include "curlx/warnless.h" -/* The last #include files should be: */ -#include "curl_memory.h" -#include "memdebug.h" - /* Pointer to SSPI dispatch table */ PSecurityFunctionTable Curl_pSecFn = NULL; @@ -134,7 +130,7 @@ CURLcode Curl_create_sspi_identity(const char *userp, const char *passwdp, } /* Setup the identity's user and length */ - dup_user.tchar_ptr = Curl_tcsdup(user.tchar_ptr); + dup_user.tchar_ptr = curlx_tcsdup(user.tchar_ptr); if(!dup_user.tchar_ptr) { curlx_unicodefree(useranddomain.tchar_ptr); return CURLE_OUT_OF_MEMORY; @@ -144,7 +140,7 @@ CURLcode Curl_create_sspi_identity(const char *userp, const char *passwdp, dup_user.tchar_ptr = NULL; /* Setup the identity's domain and length */ - dup_domain.tchar_ptr = malloc(sizeof(TCHAR) * (domlen + 1)); + dup_domain.tchar_ptr = curlx_malloc(sizeof(TCHAR) * (domlen + 1)); if(!dup_domain.tchar_ptr) { curlx_unicodefree(useranddomain.tchar_ptr); return CURLE_OUT_OF_MEMORY; @@ -164,7 +160,7 @@ CURLcode Curl_create_sspi_identity(const char *userp, const char *passwdp, passwd.tchar_ptr = curlx_convert_UTF8_to_tchar(passwdp); if(!passwd.tchar_ptr) return CURLE_OUT_OF_MEMORY; - dup_passwd.tchar_ptr = Curl_tcsdup(passwd.tchar_ptr); + dup_passwd.tchar_ptr = curlx_tcsdup(passwd.tchar_ptr); if(!dup_passwd.tchar_ptr) { curlx_unicodefree(passwd.tchar_ptr); return CURLE_OUT_OF_MEMORY; diff --git a/lib/curl_threads.c b/lib/curl_threads.c index a0308f06b2dc..e4536078be39 100644 --- a/lib/curl_threads.c +++ b/lib/curl_threads.c @@ -31,9 +31,6 @@ #endif #include "curl_threads.h" -#include "curl_memory.h" -/* The last #include FILE should be: */ -#include "memdebug.h" #ifdef USE_THREADS_POSIX @@ -48,7 +45,7 @@ static void *curl_thread_create_thunk(void *arg) unsigned int (*func)(void *) = ac->func; void *real_arg = ac->arg; - free(ac); + curlx_free(ac); (*func)(real_arg); @@ -58,8 +55,8 @@ static void *curl_thread_create_thunk(void *arg) curl_thread_t Curl_thread_create(CURL_THREAD_RETURN_T (CURL_STDCALL *func) (void *), void *arg) { - curl_thread_t t = malloc(sizeof(pthread_t)); - struct Curl_actual_call *ac = malloc(sizeof(struct Curl_actual_call)); + curl_thread_t t = curlx_malloc(sizeof(pthread_t)); + struct Curl_actual_call *ac = curlx_malloc(sizeof(struct Curl_actual_call)); int rc; if(!(ac && t)) goto err; @@ -76,8 +73,8 @@ curl_thread_t Curl_thread_create(CURL_THREAD_RETURN_T return t; err: - free(t); - free(ac); + curlx_free(t); + curlx_free(ac); return curl_thread_t_null; } @@ -85,7 +82,7 @@ void Curl_thread_destroy(curl_thread_t *hnd) { if(*hnd != curl_thread_t_null) { pthread_detach(**hnd); - free(*hnd); + curlx_free(*hnd); *hnd = curl_thread_t_null; } } @@ -94,7 +91,7 @@ int Curl_thread_join(curl_thread_t *hnd) { int ret = (pthread_join(**hnd, NULL) == 0); - free(*hnd); + curlx_free(*hnd); *hnd = curl_thread_t_null; return ret; diff --git a/lib/curl_trc.c b/lib/curl_trc.c index 0b91315e3668..cc06c77e9d9a 100644 --- a/lib/curl_trc.c +++ b/lib/curl_trc.c @@ -47,10 +47,6 @@ #include "vtls/vtls.h" #include "vquic/vquic.h" -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - static void trc_write(struct Curl_easy *data, curl_infotype type, const char *ptr, size_t size) { diff --git a/lib/curlx/base64.c b/lib/curlx/base64.c index 3fcd709d1ce8..6a24c20ebdfb 100644 --- a/lib/curlx/base64.c +++ b/lib/curlx/base64.c @@ -30,12 +30,6 @@ #include "warnless.h" #include "base64.h" -/* The last 2 #include files should be in this order */ -#ifdef BUILDING_LIBCURL -#include "../curl_memory.h" -#endif -#include "../memdebug.h" - /* ---- Base64 Encoding/Decoding Table --- */ const char Curl_base64encdec[]= "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; @@ -103,7 +97,7 @@ CURLcode curlx_base64_decode(const char *src, rawlen = (numQuantums * 3) - padding; /* Allocate our buffer including room for a null-terminator */ - newstr = malloc(rawlen + 1); + newstr = curlx_malloc(rawlen + 1); if(!newstr) return CURLE_OUT_OF_MEMORY; @@ -165,7 +159,7 @@ CURLcode curlx_base64_decode(const char *src, return CURLE_OK; bad: - free(newstr); + curlx_free(newstr); return CURLE_BAD_CONTENT_ENCODING; } @@ -189,7 +183,7 @@ static CURLcode base64_encode(const char *table64, if(insize > CURL_MAX_BASE64_INPUT) return CURLE_TOO_LARGE; - base64data = output = malloc((insize + 2) / 3 * 4 + 1); + base64data = output = curlx_malloc((insize + 2) / 3 * 4 + 1); if(!output) return CURLE_OUT_OF_MEMORY; diff --git a/lib/curlx/dynbuf.c b/lib/curlx/dynbuf.c index 447203e42a8a..e54865f933c7 100644 --- a/lib/curlx/dynbuf.c +++ b/lib/curlx/dynbuf.c @@ -25,10 +25,6 @@ #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 @@ -108,7 +104,7 @@ static CURLcode dyn_nappend(struct dynbuf *s, 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); + void *p = curlx_realloc(s->bufr, a); if(!p) { curlx_dyn_free(s); return CURLE_OUT_OF_MEMORY; @@ -212,7 +208,7 @@ CURLcode curlx_dyn_vaddf(struct dynbuf *s, const char *fmt, va_list ap) if(str) { CURLcode result = dyn_nappend(s, (const unsigned char *)str, strlen(str)); - free(str); + curlx_free(str); return result; } /* If we failed, we cleanup the whole buffer and return error */ diff --git a/lib/curlx/fopen.c b/lib/curlx/fopen.c index 0dc9699206cd..c8dff428fc94 100644 --- a/lib/curlx/fopen.c +++ b/lib/curlx/fopen.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) Daniel Stenberg, , et al. + * Copyright (C) Danieal Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -23,11 +23,8 @@ ***************************************************************************/ /* - * This file is 'mem-include-scan' clean, which means its memory allocations - * are not tracked by the curl memory tracker memdebug, so they must not use - * `CURLDEBUG` macro replacements in memdebug.h for free, malloc, etc. To avoid - * these macro replacements, wrap the names in parentheses to call the original - * versions: `ptr = (malloc)(123)`, `(free)(ptr)`, etc. + * Use system allocators to avoid infinite recursion when called by curl's + * memory tracker memdebug functions. */ #include "../curl_setup.h" @@ -103,7 +100,8 @@ static bool fix_excessive_path(const TCHAR *in, TCHAR **out) goto cleanup; if(!needed || needed >= max_path_len) goto cleanup; - ibuf = (malloc)(needed * sizeof(wchar_t)); + /* !checksrc! disable BANNEDFUNC 1 */ + ibuf = malloc(needed * sizeof(wchar_t)); if(!ibuf) goto cleanup; if(mbstowcs_s(&count, ibuf, needed, in, needed - 1)) @@ -124,7 +122,8 @@ static bool fix_excessive_path(const TCHAR *in, TCHAR **out) /* skip paths that are not excessive and do not need modification */ if(needed <= MAX_PATH) goto cleanup; - fbuf = (malloc)(needed * sizeof(wchar_t)); + /* !checksrc! disable BANNEDFUNC 1 */ + fbuf = malloc(needed * sizeof(wchar_t)); if(!fbuf) goto cleanup; count = (size_t)GetFullPathNameW(in_w, (DWORD)needed, fbuf, NULL); @@ -157,16 +156,19 @@ static bool fix_excessive_path(const TCHAR *in, TCHAR **out) if(needed > max_path_len) goto cleanup; - temp = (malloc)(needed * sizeof(wchar_t)); + /* !checksrc! disable BANNEDFUNC 1 */ + temp = malloc(needed * sizeof(wchar_t)); if(!temp) goto cleanup; if(wcsncpy_s(temp, needed, L"\\\\?\\UNC\\", 8)) { - (free)(temp); + /* !checksrc! disable BANNEDFUNC 1 */ + free(temp); goto cleanup; } if(wcscpy_s(temp + 8, needed, fbuf + 2)) { - (free)(temp); + /* !checksrc! disable BANNEDFUNC 1 */ + free(temp); goto cleanup; } } @@ -176,21 +178,25 @@ static bool fix_excessive_path(const TCHAR *in, TCHAR **out) if(needed > max_path_len) goto cleanup; - temp = (malloc)(needed * sizeof(wchar_t)); + /* !checksrc! disable BANNEDFUNC 1 */ + temp = malloc(needed * sizeof(wchar_t)); if(!temp) goto cleanup; if(wcsncpy_s(temp, needed, L"\\\\?\\", 4)) { - (free)(temp); + /* !checksrc! disable BANNEDFUNC 1 */ + free(temp); goto cleanup; } if(wcscpy_s(temp + 4, needed, fbuf)) { - (free)(temp); + /* !checksrc! disable BANNEDFUNC 1 */ + free(temp); goto cleanup; } } - (free)(fbuf); + /* !checksrc! disable BANNEDFUNC 1 */ + free(fbuf); fbuf = temp; } @@ -200,7 +206,8 @@ static bool fix_excessive_path(const TCHAR *in, TCHAR **out) goto cleanup; if(!needed || needed >= max_path_len) goto cleanup; - obuf = (malloc)(needed); + /* !checksrc! disable BANNEDFUNC 1 */ + obuf = malloc(needed); if(!obuf) goto cleanup; if(wcstombs_s(&count, obuf, needed, fbuf, needed - 1)) @@ -215,10 +222,12 @@ static bool fix_excessive_path(const TCHAR *in, TCHAR **out) #endif cleanup: - (free)(fbuf); + /* !checksrc! disable BANNEDFUNC 1 */ + free(fbuf); #ifndef _UNICODE - (free)(ibuf); - (free)(obuf); + /* !checksrc! disable BANNEDFUNC 2 */ + free(ibuf); + free(obuf); #endif return *out ? true : false; } @@ -260,7 +269,8 @@ int curlx_win32_open(const char *filename, int oflag, ...) errno = _sopen_s(&result, target, oflag, _SH_DENYNO, pmode); #endif - (free)(fixed); + /* !checksrc! disable BANNEDFUNC 1 */ + free(fixed); return result; } @@ -293,7 +303,8 @@ FILE *curlx_win32_fopen(const char *filename, const char *mode) errno = fopen_s(&result, target, mode); #endif - (free)(fixed); + /* !checksrc! disable BANNEDFUNC 1 */ + free(fixed); return result; } @@ -331,7 +342,8 @@ FILE *curlx_win32_freopen(const char *filename, const char *mode, FILE *fp) errno = freopen_s(&result, target, mode, fp); #endif - (free)(fixed); + /* !checksrc! disable BANNEDFUNC 1 */ + free(fixed); return result; } @@ -370,7 +382,8 @@ int curlx_win32_stat(const char *path, struct_stat *buffer) #endif #endif - (free)(fixed); + /* !checksrc! disable BANNEDFUNC 1 */ + free(fixed); return result; } diff --git a/lib/curlx/multibyte.c b/lib/curlx/multibyte.c index 9e60edf7e3e2..2583f3087031 100644 --- a/lib/curlx/multibyte.c +++ b/lib/curlx/multibyte.c @@ -23,11 +23,8 @@ ***************************************************************************/ /* - * This file is 'mem-include-scan' clean, which means its memory allocations - * are not tracked by the curl memory tracker memdebug, so they must not use - * `CURLDEBUG` macro replacements in memdebug.h for free, malloc, etc. To avoid - * these macro replacements, wrap the names in parentheses to call the original - * versions: `ptr = (malloc)(123)`, `(free)(ptr)`, etc. + * Use system allocators to avoid infinite recursion when called by curl's + * memory tracker memdebug functions. */ #include "../curl_setup.h" @@ -48,11 +45,13 @@ wchar_t *curlx_convert_UTF8_to_wchar(const char *str_utf8) int str_w_len = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, str_utf8, -1, NULL, 0); if(str_w_len > 0) { - str_w = (malloc)(str_w_len * sizeof(wchar_t)); + /* !checksrc! disable BANNEDFUNC 1 */ + str_w = malloc(str_w_len * sizeof(wchar_t)); if(str_w) { if(MultiByteToWideChar(CP_UTF8, 0, str_utf8, -1, str_w, str_w_len) == 0) { - (free)(str_w); + /* !checksrc! disable BANNEDFUNC 1 */ + free(str_w); return NULL; } } @@ -70,11 +69,13 @@ char *curlx_convert_wchar_to_UTF8(const wchar_t *str_w) int bytes = WideCharToMultiByte(CP_UTF8, 0, str_w, -1, NULL, 0, NULL, NULL); if(bytes > 0) { - str_utf8 = (malloc)(bytes); + /* !checksrc! disable BANNEDFUNC 1 */ + str_utf8 = malloc(bytes); if(str_utf8) { if(WideCharToMultiByte(CP_UTF8, 0, str_w, -1, str_utf8, bytes, NULL, NULL) == 0) { - (free)(str_utf8); + /* !checksrc! disable BANNEDFUNC 1 */ + free(str_utf8); return NULL; } } diff --git a/lib/curlx/multibyte.h b/lib/curlx/multibyte.h index 8b698c1b7357..c992214a9575 100644 --- a/lib/curlx/multibyte.h +++ b/lib/curlx/multibyte.h @@ -44,11 +44,8 @@ char *curlx_convert_wchar_to_UTF8(const wchar_t *str_w); * * Allocated memory should be free'd with curlx_unicodefree(). * - * Note: Because these are curlx functions their memory usage is not tracked - * by the curl memory tracker memdebug. you will notice that curlx - * function-like macros call free and strdup in parentheses, eg (strdup)(ptr), - * and that is to ensure that the curl memdebug override macros do not replace - * them. + * Use system allocators to avoid infinite recursion when called by curl's + * memory tracker memdebug functions. */ #if defined(UNICODE) && defined(_WIN32) @@ -65,8 +62,13 @@ typedef union { #else -#define curlx_convert_UTF8_to_tchar(ptr) (strdup)(ptr) -#define curlx_convert_tchar_to_UTF8(ptr) (strdup)(ptr) +#ifdef _WIN32 +#define curlx_convert_UTF8_to_tchar(ptr) _strdup(ptr) +#define curlx_convert_tchar_to_UTF8(ptr) _strdup(ptr) +#else +#define curlx_convert_UTF8_to_tchar(ptr) strdup(ptr) +#define curlx_convert_tchar_to_UTF8(ptr) strdup(ptr) +#endif typedef union { char *tchar_ptr; @@ -78,6 +80,6 @@ typedef union { #endif /* UNICODE && _WIN32 */ /* the purpose of this macro is to free() without being traced by memdebug */ -#define curlx_unicodefree(ptr) (free)(ptr) +#define curlx_unicodefree(ptr) free(ptr) #endif /* HEADER_CURL_MULTIBYTE_H */ diff --git a/lib/curlx/strerr.c b/lib/curlx/strerr.c index c33d10701125..3dbeab82ee57 100644 --- a/lib/curlx/strerr.c +++ b/lib/curlx/strerr.c @@ -37,9 +37,6 @@ #include "winapi.h" #include "snprintf.h" #include "strerr.h" -/* The last 2 #include files should be in this order */ -#include "../curl_memory.h" -#include "../memdebug.h" #ifdef USE_WINSOCK /* This is a helper function for curlx_strerror that converts Winsock error diff --git a/lib/curlx/version_win32.c b/lib/curlx/version_win32.c index cc86b71d3e3d..9ab72c2fd5b9 100644 --- a/lib/curlx/version_win32.c +++ b/lib/curlx/version_win32.c @@ -30,10 +30,6 @@ #include "version_win32.h" #include "warnless.h" -/* The last 2 #include files should be in this order */ -#include "../curl_memory.h" -#include "../memdebug.h" - /* This Unicode version struct works for VerifyVersionInfoW (OSVERSIONINFOEXW) and RtlVerifyVersionInfo (RTLOSVERSIONINFOEXW) */ struct OUR_OSVERSIONINFOEXW { diff --git a/lib/cw-out.c b/lib/cw-out.c index 36cfc36aca04..4561546d197d 100644 --- a/lib/cw-out.c +++ b/lib/cw-out.c @@ -35,10 +35,6 @@ #include "cw-out.h" #include "cw-pause.h" -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - /** * OVERALL DESIGN of this client writer @@ -85,7 +81,7 @@ struct cw_out_buf { static struct cw_out_buf *cw_out_buf_create(cw_out_type otype) { - struct cw_out_buf *cwbuf = calloc(1, sizeof(*cwbuf)); + struct cw_out_buf *cwbuf = curlx_calloc(1, sizeof(*cwbuf)); if(cwbuf) { cwbuf->type = otype; curlx_dyn_init(&cwbuf->b, DYN_PAUSE_BUFFER); @@ -97,7 +93,7 @@ static void cw_out_buf_free(struct cw_out_buf *cwbuf) { if(cwbuf) { curlx_dyn_free(&cwbuf->b); - free(cwbuf); + curlx_free(cwbuf); } } diff --git a/lib/cw-pause.c b/lib/cw-pause.c index 1af4e8fa4192..2a98667ae4ff 100644 --- a/lib/cw-pause.c +++ b/lib/cw-pause.c @@ -34,10 +34,6 @@ #include "sendf.h" #include "cw-pause.h" -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - /* body dynbuf sizes */ #define CW_PAUSE_BUF_CHUNK (16 * 1024) @@ -52,7 +48,7 @@ struct cw_pause_buf { static struct cw_pause_buf *cw_pause_buf_create(int type, size_t buflen) { - struct cw_pause_buf *cwbuf = calloc(1, sizeof(*cwbuf)); + struct cw_pause_buf *cwbuf = curlx_calloc(1, sizeof(*cwbuf)); if(cwbuf) { cwbuf->type = type; if(type & CLIENTWRITE_BODY) @@ -68,7 +64,7 @@ static void cw_pause_buf_free(struct cw_pause_buf *cwbuf) { if(cwbuf) { Curl_bufq_free(&cwbuf->b); - free(cwbuf); + curlx_free(cwbuf); } } diff --git a/lib/dict.c b/lib/dict.c index 5c7ba7f6229f..f208892f7302 100644 --- a/lib/dict.c +++ b/lib/dict.c @@ -60,11 +60,6 @@ #include "progress.h" #include "dict.h" -/* The last 2 #include files should be: */ -#include "curl_memory.h" -#include "memdebug.h" - - #define DICT_MATCH "/MATCH:" #define DICT_MATCH2 "/M:" #define DICT_MATCH3 "/FIND:" @@ -172,7 +167,7 @@ static CURLcode sendf(struct Curl_easy *data, const char *fmt, ...) break; } - free(s); /* free the output string */ + curlx_free(s); /* free the output string */ return result; } @@ -310,8 +305,8 @@ static CURLcode dict_do(struct Curl_easy *data, bool *done) } error: - free(eword); - free(path); + curlx_free(eword); + curlx_free(path); return result; } #endif /* CURL_DISABLE_DICT */ diff --git a/lib/dllmain.c b/lib/dllmain.c index 011090589bb0..7b7d3c7e2e10 100644 --- a/lib/dllmain.c +++ b/lib/dllmain.c @@ -28,10 +28,6 @@ #include #endif -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - /* DllMain() must only be defined for Windows DLL builds. */ #if defined(_WIN32) && !defined(CURL_STATICLIB) diff --git a/lib/doh.c b/lib/doh.c index 0712981a97ec..d7b1d54c25e8 100644 --- a/lib/doh.c +++ b/lib/doh.c @@ -41,10 +41,6 @@ #include "escape.h" #include "urlapi-int.h" -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - #define DNS_CLASS_IN 0x01 #ifndef CURL_DISABLE_VERBOSE_STRINGS @@ -269,7 +265,7 @@ static void doh_probe_dtor(void *key, size_t klen, void *e) struct doh_request *doh_req = e; curl_slist_free_all(doh_req->req_hds); curlx_dyn_free(&doh_req->resp_body); - free(e); + curlx_free(e); } } @@ -296,7 +292,7 @@ static CURLcode doh_probe_run(struct Curl_easy *data, *pmid = UINT32_MAX; - doh_req = calloc(1, sizeof(*doh_req)); + doh_req = curlx_calloc(1, sizeof(*doh_req)); if(!doh_req) return CURLE_OUT_OF_MEMORY; doh_req->dnstype = dnstype; @@ -462,12 +458,12 @@ CURLcode Curl_doh(struct Curl_easy *data, const char *hostname, data->state.async.done = FALSE; data->state.async.port = port; data->state.async.ip_version = ip_version; - data->state.async.hostname = strdup(hostname); + data->state.async.hostname = curlx_strdup(hostname); if(!data->state.async.hostname) return CURLE_OUT_OF_MEMORY; /* start clean, consider allocating this struct on demand */ - data->state.async.doh = dohp = calloc(1, sizeof(struct doh_probes)); + data->state.async.doh = dohp = curlx_calloc(1, sizeof(struct doh_probes)); if(!dohp) return CURLE_OUT_OF_MEMORY; @@ -518,7 +514,7 @@ CURLcode Curl_doh(struct Curl_easy *data, const char *hostname, qname ? qname : hostname, data->set.str[STRING_DOH], data->multi, &dohp->probe_resp[DOH_SLOT_HTTPS_RR].probe_mid); - free(qname); + curlx_free(qname); if(result) goto error; dohp->pending++; @@ -963,7 +959,7 @@ static CURLcode doh2ai(const struct dohentry *de, const char *hostname, addrtype = AF_INET; } - ai = calloc(1, sizeof(struct Curl_addrinfo) + ss_size + hostlen); + ai = curlx_calloc(1, sizeof(struct Curl_addrinfo) + ss_size + hostlen); if(!ai) { result = CURLE_OUT_OF_MEMORY; break; @@ -1130,7 +1126,7 @@ UNITTEST CURLcode doh_resp_decode_httpsrr(struct Curl_easy *data, *hrr = NULL; if(len <= 2) return CURLE_BAD_FUNCTION_ARGUMENT; - lhrr = calloc(1, sizeof(struct Curl_https_rrinfo)); + lhrr = curlx_calloc(1, sizeof(struct Curl_https_rrinfo)); if(!lhrr) return CURLE_OUT_OF_MEMORY; lhrr->priority = doh_get16bit(cp, 0); diff --git a/lib/dynhds.c b/lib/dynhds.c index 95d415bf0b49..ebe1beae5856 100644 --- a/lib/dynhds.c +++ b/lib/dynhds.c @@ -31,10 +31,6 @@ #include #endif /* USE_NGHTTP2 */ -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - static struct dynhds_entry * entry_new(const char *name, size_t namelen, @@ -45,7 +41,7 @@ entry_new(const char *name, size_t namelen, DEBUGASSERT(name); DEBUGASSERT(value); - e = calloc(1, sizeof(*e) + namelen + valuelen + 2); + e = curlx_calloc(1, sizeof(*e) + namelen + valuelen + 2); if(!e) return NULL; e->name = p = ((char *)e) + sizeof(*e); @@ -68,7 +64,7 @@ entry_append(struct dynhds_entry *e, char *p; DEBUGASSERT(value); - e2 = calloc(1, sizeof(*e) + e->namelen + valuelen2 + 2); + e2 = curlx_calloc(1, sizeof(*e) + e->namelen + valuelen2 + 2); if(!e2) return NULL; e2->name = p = ((char *)e2) + sizeof(*e2); @@ -85,7 +81,7 @@ entry_append(struct dynhds_entry *e, static void entry_free(struct dynhds_entry *e) { - free(e); + curlx_free(e); } void Curl_dynhds_init(struct dynhds *dynhds, size_t max_entries, @@ -186,7 +182,7 @@ entry = entry_new(name, namelen, value, valuelen, dynhds->opts); if(dynhds->max_entries && nallc > dynhds->max_entries) nallc = dynhds->max_entries; - nhds = calloc(nallc, sizeof(struct dynhds_entry *)); + nhds = curlx_calloc(nallc, sizeof(struct dynhds_entry *)); if(!nhds) goto out; if(dynhds->hds) { @@ -374,7 +370,7 @@ CURLcode Curl_dynhds_h1_dprint(struct dynhds *dynhds, struct dynbuf *dbuf) nghttp2_nv *Curl_dynhds_to_nva(struct dynhds *dynhds, size_t *pcount) { - nghttp2_nv *nva = calloc(1, sizeof(nghttp2_nv) * dynhds->hds_len); + nghttp2_nv *nva = curlx_calloc(1, sizeof(nghttp2_nv) * dynhds->hds_len); size_t i; *pcount = 0; diff --git a/lib/easy.c b/lib/easy.c index db6c419c5771..476f63c74dff 100644 --- a/lib/easy.c +++ b/lib/easy.c @@ -80,10 +80,6 @@ #include "easy_lock.h" -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - /* true globals -- for curl_global_init() and curl_global_cleanup() */ static unsigned int initialized; static long easy_init_flags; @@ -198,7 +194,7 @@ static CURLcode global_init(long flags, bool memoryfuncs) #ifdef DEBUGBUILD if(getenv("CURL_GLOBAL_INIT")) /* alloc data that will leak if *cleanup() is not called! */ - leakpointer = malloc(1); + leakpointer = curlx_malloc(1); #endif return CURLE_OK; @@ -297,7 +293,7 @@ void curl_global_cleanup(void) Curl_ssh_cleanup(); #ifdef DEBUGBUILD - free(leakpointer); + curlx_free(leakpointer); #endif easy_init_flags = 0; @@ -478,7 +474,7 @@ static int events_socket(CURL *easy, /* easy handle */ prev->next = nxt; else ev->list = nxt; - free(m); + curlx_free(m); infof(data, "socket cb: socket %" FMT_SOCKET_T " REMOVED", s); } else { @@ -504,7 +500,7 @@ static int events_socket(CURL *easy, /* easy handle */ DEBUGASSERT(0); } else { - m = malloc(sizeof(struct socketmonitor)); + m = curlx_malloc(sizeof(struct socketmonitor)); if(m) { m->next = ev->list; m->socket.fd = s; @@ -927,7 +923,7 @@ static CURLcode dupset(struct Curl_easy *dst, struct Curl_easy *src) i = STRING_COPYPOSTFIELDS; if(src->set.str[i]) { if(src->set.postfieldsize == -1) - dst->set.str[i] = strdup(src->set.str[i]); + dst->set.str[i] = curlx_strdup(src->set.str[i]); else /* postfieldsize is curl_off_t, Curl_memdup() takes a size_t ... */ dst->set.str[i] = Curl_memdup(src->set.str[i], @@ -968,7 +964,7 @@ CURL *curl_easy_duphandle(CURL *d) if(!GOOD_EASY_HANDLE(data)) goto fail; - outcurl = calloc(1, sizeof(struct Curl_easy)); + outcurl = curlx_calloc(1, sizeof(struct Curl_easy)); if(!outcurl) goto fail; @@ -1022,14 +1018,14 @@ CURL *curl_easy_duphandle(CURL *d) #endif if(data->state.url) { - outcurl->state.url = strdup(data->state.url); + outcurl->state.url = curlx_strdup(data->state.url); if(!outcurl->state.url) goto fail; outcurl->state.url_alloc = TRUE; } if(data->state.referer) { - outcurl->state.referer = strdup(data->state.referer); + outcurl->state.referer = curlx_strdup(data->state.referer); if(!outcurl->state.referer) goto fail; outcurl->state.referer_alloc = TRUE; @@ -1073,13 +1069,13 @@ CURL *curl_easy_duphandle(CURL *d) if(outcurl) { #ifndef CURL_DISABLE_COOKIES - free(outcurl->cookies); + curlx_free(outcurl->cookies); #endif curlx_dyn_free(&outcurl->state.headerb); Curl_altsvc_cleanup(&outcurl->asi); Curl_hsts_cleanup(&outcurl->hsts); Curl_freeset(outcurl); - free(outcurl); + curlx_free(outcurl); } return NULL; diff --git a/lib/escape.c b/lib/escape.c index fdc6e438ab3e..04b46f7a9e26 100644 --- a/lib/escape.c +++ b/lib/escape.c @@ -37,10 +37,6 @@ struct Curl_easy; #include "curlx/strparse.h" #include "curl_printf.h" -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - /* for ABI-compatibility with previous versions */ char *curl_escape(const char *string, int inlength) { @@ -68,7 +64,7 @@ char *curl_easy_escape(CURL *data, const char *string, length = (inlength ? (size_t)inlength : strlen(string)); if(!length) - return strdup(""); + return curlx_strdup(""); curlx_dyn_init(&d, length * 3 + 1); @@ -120,7 +116,7 @@ CURLcode Curl_urldecode(const char *string, size_t length, DEBUGASSERT(ctrl >= REJECT_NADA); /* crash on TRUE/FALSE */ alloc = (length ? length : strlen(string)); - ns = malloc(alloc + 1); + ns = curlx_malloc(alloc + 1); if(!ns) return CURLE_OUT_OF_MEMORY; @@ -196,7 +192,7 @@ char *curl_easy_unescape(CURL *data, const char *string, the library's memory system */ void curl_free(void *p) { - free(p); + curlx_free(p); } /* diff --git a/lib/fake_addrinfo.c b/lib/fake_addrinfo.c index 9789d1ef62bd..7d5da09ead53 100644 --- a/lib/fake_addrinfo.c +++ b/lib/fake_addrinfo.c @@ -31,10 +31,6 @@ #include #include -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - void r_freeaddrinfo(struct addrinfo *cahead) { struct addrinfo *canext; @@ -42,7 +38,7 @@ void r_freeaddrinfo(struct addrinfo *cahead) for(ca = cahead; ca; ca = canext) { canext = ca->ai_next; - free(ca); + curlx_free(ca); } } @@ -90,7 +86,7 @@ static struct addrinfo *mk_getaddrinfo(const struct ares_addrinfo *aihead) if((size_t)ai->ai_addrlen < ss_size) continue; - ca = malloc(sizeof(struct addrinfo) + ss_size + namelen); + ca = curlx_malloc(sizeof(struct addrinfo) + ss_size + namelen); if(!ca) { r_freeaddrinfo(cafirst); return NULL; diff --git a/lib/file.c b/lib/file.c index 3de92408c490..2f30a0297ca6 100644 --- a/lib/file.c +++ b/lib/file.c @@ -68,10 +68,6 @@ #include "curlx/warnless.h" #include "curl_range.h" -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - #if defined(_WIN32) || defined(MSDOS) #define DOS_FILESYSTEM 1 #elif defined(__amigaos4__) @@ -148,7 +144,7 @@ static void file_easy_dtor(void *key, size_t klen, void *entry) (void)key; (void)klen; file_cleanup(file); - free(file); + curlx_free(file); } static CURLcode file_setup_connection(struct Curl_easy *data, @@ -157,7 +153,7 @@ static CURLcode file_setup_connection(struct Curl_easy *data, struct FILEPROTO *filep; (void)conn; /* allocate the FILE specific struct */ - filep = calloc(1, sizeof(*filep)); + filep = curlx_calloc(1, sizeof(*filep)); if(!filep || Curl_meta_set(data, CURL_META_FILE_EASY, filep, file_easy_dtor)) return CURLE_OUT_OF_MEMORY; @@ -269,7 +265,7 @@ static CURLcode file_connect(struct Curl_easy *data, bool *done) file->path = real_path; #endif #endif - free(file->freepath); + curlx_free(file->freepath); file->freepath = real_path; /* free this when done */ file->fd = fd; diff --git a/lib/fileinfo.c b/lib/fileinfo.c index bddd3fe6fbb1..83d2ef0d005f 100644 --- a/lib/fileinfo.c +++ b/lib/fileinfo.c @@ -27,13 +27,10 @@ #ifndef CURL_DISABLE_FTP #include "fileinfo.h" -#include "curl_memory.h" -/* The last #include file should be: */ -#include "memdebug.h" struct fileinfo *Curl_fileinfo_alloc(void) { - return calloc(1, sizeof(struct fileinfo)); + return curlx_calloc(1, sizeof(struct fileinfo)); } void Curl_fileinfo_cleanup(struct fileinfo *finfo) @@ -42,7 +39,7 @@ void Curl_fileinfo_cleanup(struct fileinfo *finfo) return; curlx_dyn_free(&finfo->buf); - free(finfo); + curlx_free(finfo); } #endif diff --git a/lib/formdata.c b/lib/formdata.c index 416bcad4f57d..d4bfed89beaa 100644 --- a/lib/formdata.c +++ b/lib/formdata.c @@ -40,10 +40,6 @@ struct Curl_easy; #include "curlx/fopen.h" #include "curlx/warnless.h" -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - #define HTTPPOST_PTRNAME CURL_HTTPPOST_PTRNAME #define HTTPPOST_FILENAME CURL_HTTPPOST_FILENAME @@ -76,7 +72,7 @@ AddHttpPost(struct FormInfo *src, if((src->bufferlength > LONG_MAX) || (namelength > LONG_MAX)) /* avoid overflow in typecasts below */ return NULL; - post = calloc(1, sizeof(struct curl_httppost)); + post = curlx_calloc(1, sizeof(struct curl_httppost)); if(post) { post->name = src->name; post->namelength = (long)namelength; @@ -127,7 +123,7 @@ static struct FormInfo *AddFormInfo(char *value, struct FormInfo *parent_form_info) { struct FormInfo *form_info; - form_info = calloc(1, sizeof(struct FormInfo)); + form_info = curlx_calloc(1, sizeof(struct FormInfo)); if(!form_info) return NULL; if(value) @@ -262,7 +258,7 @@ static CURLFORMcode FormAddCheck(struct FormInfo *first_form, type = FILE_CONTENTTYPE_DEFAULT; /* our contenttype is missing */ - form->contenttype = strdup(type); + form->contenttype = curlx_strdup(type); if(!form->contenttype) return CURL_FORMADD_MEMORY; @@ -320,7 +316,7 @@ static void free_chain(struct curl_httppost *c) struct curl_httppost *next = c->next; if(c->more) free_chain(c->more); - free(c); + curlx_free(c); c = next; } } @@ -346,7 +342,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost, /* * We need to allocate the first struct to fill in. */ - first_form = calloc(1, sizeof(struct FormInfo)); + first_form = curlx_calloc(1, sizeof(struct FormInfo)); if(!first_form) return CURL_FORMADD_MEMORY; @@ -458,7 +454,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost, if(!array_state) avalue = va_arg(params, char *); if(avalue) { - curr->value = strdup(avalue); + curr->value = curlx_strdup(avalue); if(!curr->value) retval = CURL_FORMADD_MEMORY; else { @@ -479,13 +475,13 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost, if(curr->value) { if(curr->flags & HTTPPOST_FILENAME) { if(avalue) { - char *fname = strdup(avalue); + char *fname = curlx_strdup(avalue); if(!fname) retval = CURL_FORMADD_MEMORY; else { form = AddFormInfo(fname, NULL, curr); if(!form) { - free(fname); + curlx_free(fname); retval = CURL_FORMADD_MEMORY; } else { @@ -503,7 +499,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost, } else { if(avalue) { - curr->value = strdup(avalue); + curr->value = curlx_strdup(avalue); if(!curr->value) retval = CURL_FORMADD_MEMORY; else { @@ -566,13 +562,13 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost, if(curr->contenttype) { if(curr->flags & HTTPPOST_FILENAME) { if(avalue) { - char *type = strdup(avalue); + char *type = curlx_strdup(avalue); if(!type) retval = CURL_FORMADD_MEMORY; else { form = AddFormInfo(NULL, type, curr); if(!form) { - free(type); + curlx_free(type); retval = CURL_FORMADD_MEMORY; } else { @@ -590,7 +586,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost, } else { if(avalue) { - curr->contenttype = strdup(avalue); + curr->contenttype = curlx_strdup(avalue); if(!curr->contenttype) retval = CURL_FORMADD_MEMORY; else @@ -623,7 +619,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost, if(curr->showfilename) retval = CURL_FORMADD_OPTION_TWICE; else { - curr->showfilename = strdup(avalue); + curr->showfilename = curlx_strdup(avalue); if(!curr->showfilename) retval = CURL_FORMADD_MEMORY; else @@ -650,7 +646,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost, now by the httppost linked list */ while(first_form) { struct FormInfo *ptr = first_form->more; - free(first_form); + curlx_free(first_form); first_form = ptr; } @@ -743,14 +739,14 @@ void curl_formfree(struct curl_httppost *form) curl_formfree(form->more); if(!(form->flags & HTTPPOST_PTRNAME)) - free(form->name); /* free the name */ + curlx_free(form->name); /* free the name */ if(!(form->flags & (HTTPPOST_PTRCONTENTS|HTTPPOST_BUFFER|HTTPPOST_CALLBACK)) ) - free(form->contents); /* free the contents */ - free(form->contenttype); /* free the content type */ - free(form->showfilename); /* free the faked filename */ - free(form); /* free the struct */ + curlx_free(form->contents); /* free the contents */ + curlx_free(form->contenttype); /* free the content type */ + curlx_free(form->showfilename); /* free the faked filename */ + curlx_free(form); /* free the struct */ form = next; } while(form); /* continue */ } @@ -768,7 +764,7 @@ static CURLcode setname(curl_mimepart *part, const char *name, size_t len) if(!zname) return CURLE_OUT_OF_MEMORY; res = curl_mime_name(part, zname); - free(zname); + curlx_free(zname); return res; } diff --git a/lib/ftp.c b/lib/ftp.c index ce4001226823..b2b15a89dcd3 100644 --- a/lib/ftp.c +++ b/lib/ftp.c @@ -72,10 +72,6 @@ #include "curlx/strerr.h" #include "curlx/strparse.h" -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - #ifndef NI_MAXHOST #define NI_MAXHOST 1025 #endif @@ -1419,7 +1415,7 @@ static CURLcode ftp_state_list(struct Curl_easy *data, return CURLE_OUT_OF_MEMORY; result = Curl_pp_sendf(data, &ftpc->pp, "%s", cmd); - free(cmd); + curlx_free(cmd); if(!result) ftp_state(data, ftpc, FTP_LIST); @@ -1770,12 +1766,12 @@ static CURLcode ftp_control_addr_dup(struct Curl_easy *data, not the ftp host. */ #ifndef CURL_DISABLE_PROXY if(conn->bits.tunnel_proxy || conn->bits.socksproxy) - *newhostp = strdup(conn->host.name); + *newhostp = curlx_strdup(conn->host.name); else #endif if(!Curl_conn_get_ip_info(data, conn, FIRSTSOCKET, &is_ipv6, &ipquad) && *ipquad.remote_ip) - *newhostp = strdup(ipquad.remote_ip); + *newhostp = curlx_strdup(ipquad.remote_ip); else { /* failed to get the remote_ip of the DATA connection */ failf(data, "unable to get peername of DATA connection"); @@ -1934,7 +1930,7 @@ static CURLcode ftp_state_pasv_resp(struct Curl_easy *data, /* postponed address resolution in case of tcp fastopen */ if(conn->bits.tcp_fastopen && !conn->bits.reuse && !newhost[0]) { - free(newhost); + curlx_free(newhost); result = ftp_control_addr_dup(data, &newhost); if(result) goto error; @@ -1956,7 +1952,7 @@ static CURLcode ftp_state_pasv_resp(struct Curl_easy *data, if(result) { if(ftpc->count1 == 0 && ftpcode == 229) { - free(newhost); + curlx_free(newhost); return ftp_epsv_disable(data, ftpc, conn); } @@ -1973,9 +1969,9 @@ static CURLcode ftp_state_pasv_resp(struct Curl_easy *data, /* this just dumps information about this second connection */ ftp_pasv_verbose(data, dns->addr, newhost, connectport); - free(conn->secondaryhostname); + curlx_free(conn->secondaryhostname); conn->secondary_port = newport; - conn->secondaryhostname = strdup(newhost); + conn->secondaryhostname = curlx_strdup(newhost); if(!conn->secondaryhostname) { result = CURLE_OUT_OF_MEMORY; goto error; @@ -1985,7 +1981,7 @@ static CURLcode ftp_state_pasv_resp(struct Curl_easy *data, ftp_state(data, ftpc, FTP_STOP); /* this phase is completed */ error: - free(newhost); + curlx_free(newhost); return result; } @@ -2723,17 +2719,17 @@ static CURLcode ftp_pwd_resp(struct Curl_easy *data, if(!ftpc->server_os && dir[0] != '/') { result = Curl_pp_sendf(data, &ftpc->pp, "%s", "SYST"); if(result) { - free(dir); + curlx_free(dir); return result; } } - free(ftpc->entrypath); + curlx_free(ftpc->entrypath); ftpc->entrypath = dir; /* remember this */ infof(data, "Entry path is '%s'", ftpc->entrypath); /* also save it where getinfo can access it: */ - free(data->state.most_recent_ftp_entrypath); - data->state.most_recent_ftp_entrypath = strdup(ftpc->entrypath); + curlx_free(data->state.most_recent_ftp_entrypath); + data->state.most_recent_ftp_entrypath = curlx_strdup(ftpc->entrypath); if(!data->state.most_recent_ftp_entrypath) return CURLE_OUT_OF_MEMORY; @@ -2961,18 +2957,18 @@ static CURLcode ftp_pp_statemachine(struct Curl_easy *data, /* Force OS400 name format 1. */ result = Curl_pp_sendf(data, &ftpc->pp, "%s", "SITE NAMEFMT 1"); if(result) { - free(os); + curlx_free(os); return result; } /* remember target server OS */ - free(ftpc->server_os); + curlx_free(ftpc->server_os); ftpc->server_os = os; ftp_state(data, ftpc, FTP_NAMEFMT); break; } /* Nothing special for the target server. */ /* remember target server OS */ - free(ftpc->server_os); + curlx_free(ftpc->server_os); ftpc->server_os = os; } else { @@ -3277,7 +3273,7 @@ static CURLcode ftp_done(struct Curl_easy *data, CURLcode status, * 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); + curlx_free(ftpc->prevpath); ftpc->prevpath = NULL; /* no path remembering */ } else { /* remember working directory for connection reuse */ @@ -3288,7 +3284,7 @@ static CURLcode ftp_done(struct Curl_easy *data, CURLcode status, else { size_t pathLen = strlen(ftpc->rawpath); - free(ftpc->prevpath); + curlx_free(ftpc->prevpath); if(!ftpc->cwdfail) { if(data->set.ftp_filemethod == FTPFILE_NOCWD) @@ -3757,7 +3753,7 @@ static void wc_data_dtor(void *ptr) struct ftp_wc *ftpwc = ptr; if(ftpwc && ftpwc->parser) Curl_ftp_parselist_data_free(&ftpwc->parser); - free(ftpwc); + curlx_free(ftpwc); } static CURLcode init_wc_data(struct Curl_easy *data, @@ -3777,14 +3773,14 @@ static CURLcode init_wc_data(struct Curl_easy *data, wildcard->state = CURLWC_CLEAN; return ftp_parse_url_path(data, ftpc, ftp); } - wildcard->pattern = strdup(last_slash); + wildcard->pattern = curlx_strdup(last_slash); if(!wildcard->pattern) return CURLE_OUT_OF_MEMORY; last_slash[0] = '\0'; /* cut file from path */ } else { /* there is only 'wildcard pattern' or nothing */ if(path[0]) { - wildcard->pattern = strdup(path); + wildcard->pattern = curlx_strdup(path); if(!wildcard->pattern) return CURLE_OUT_OF_MEMORY; path[0] = '\0'; @@ -3799,7 +3795,7 @@ static CURLcode init_wc_data(struct Curl_easy *data, resources for wildcard transfer */ /* allocate ftp protocol specific wildcard data */ - ftpwc = calloc(1, sizeof(struct ftp_wc)); + ftpwc = curlx_calloc(1, sizeof(struct ftp_wc)); if(!ftpwc) { result = CURLE_OUT_OF_MEMORY; goto fail; @@ -3825,7 +3821,7 @@ static CURLcode init_wc_data(struct Curl_easy *data, goto fail; } - wildcard->path = strdup(ftp->path); + wildcard->path = curlx_strdup(ftp->path); if(!wildcard->path) { result = CURLE_OUT_OF_MEMORY; goto fail; @@ -3846,7 +3842,7 @@ static CURLcode init_wc_data(struct Curl_easy *data, fail: if(ftpwc) { Curl_ftp_parselist_data_free(&ftpwc->parser); - free(ftpwc); + curlx_free(ftpwc); } Curl_safefree(wildcard->pattern); wildcard->dtor = ZERO_NULL; @@ -3904,7 +3900,7 @@ static CURLcode wc_statemach(struct Curl_easy *data, return CURLE_OUT_OF_MEMORY; /* switch default ftp->path and tmp_path */ - free(ftp->pathalloc); + curlx_free(ftp->pathalloc); ftp->pathalloc = ftp->path = tmp_path; infof(data, "Wildcard - START of \"%s\"", finfo->filename); @@ -4179,7 +4175,7 @@ CURLcode ftp_parse_url_path(struct Curl_easy *data, if(dirlen == 0) dirlen = 1; - ftpc->dirs = calloc(1, sizeof(ftpc->dirs[0])); + ftpc->dirs = curlx_calloc(1, sizeof(ftpc->dirs[0])); if(!ftpc->dirs) return CURLE_OUT_OF_MEMORY; @@ -4205,7 +4201,7 @@ CURLcode ftp_parse_url_path(struct Curl_easy *data, return CURLE_URL_MALFORMAT; if(dirAlloc) { - ftpc->dirs = calloc(dirAlloc, sizeof(ftpc->dirs[0])); + ftpc->dirs = curlx_calloc(dirAlloc, sizeof(ftpc->dirs[0])); if(!ftpc->dirs) return CURLE_OUT_OF_MEMORY; @@ -4372,7 +4368,7 @@ static void ftp_easy_dtor(void *key, size_t klen, void *entry) (void)key; (void)klen; Curl_safefree(ftp->pathalloc); - free(ftp); + curlx_free(ftp); } static void ftp_conn_dtor(void *key, size_t klen, void *entry) @@ -4387,7 +4383,7 @@ static void ftp_conn_dtor(void *key, size_t klen, void *entry) Curl_safefree(ftpc->prevpath); Curl_safefree(ftpc->server_os); Curl_pp_disconnect(&ftpc->pp); - free(ftpc); + curlx_free(ftpc); } static void type_url_check(struct Curl_easy *data, struct FTP *ftp) @@ -4426,19 +4422,19 @@ static CURLcode ftp_setup_connection(struct Curl_easy *data, CURLcode result = CURLE_OK; struct ftp_conn *ftpc; - ftp = calloc(1, sizeof(*ftp)); + ftp = curlx_calloc(1, sizeof(*ftp)); if(!ftp || Curl_meta_set(data, CURL_META_FTP_EASY, ftp, ftp_easy_dtor)) return CURLE_OUT_OF_MEMORY; - ftpc = calloc(1, sizeof(*ftpc)); + ftpc = curlx_calloc(1, sizeof(*ftpc)); if(!ftpc || Curl_conn_meta_set(conn, CURL_META_FTP_CONN, ftpc, ftp_conn_dtor)) return CURLE_OUT_OF_MEMORY; /* clone connection related data that is FTP specific */ if(data->set.str[STRING_FTP_ACCOUNT]) { - ftpc->account = strdup(data->set.str[STRING_FTP_ACCOUNT]); + ftpc->account = curlx_strdup(data->set.str[STRING_FTP_ACCOUNT]); if(!ftpc->account) { Curl_conn_meta_remove(conn, CURL_META_FTP_CONN); return CURLE_OUT_OF_MEMORY; @@ -4446,7 +4442,7 @@ static CURLcode ftp_setup_connection(struct Curl_easy *data, } if(data->set.str[STRING_FTP_ALTERNATIVE_TO_USER]) { ftpc->alternative_to_user = - strdup(data->set.str[STRING_FTP_ALTERNATIVE_TO_USER]); + curlx_strdup(data->set.str[STRING_FTP_ALTERNATIVE_TO_USER]); if(!ftpc->alternative_to_user) { Curl_safefree(ftpc->account); Curl_conn_meta_remove(conn, CURL_META_FTP_CONN); diff --git a/lib/ftplistparser.c b/lib/ftplistparser.c index d8d155d5c2eb..b62fa47f6542 100644 --- a/lib/ftplistparser.c +++ b/lib/ftplistparser.c @@ -52,10 +52,6 @@ #include "multiif.h" #include "curlx/strparse.h" -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - typedef enum { PL_UNIX_TOTALSIZE = 0, PL_UNIX_FILETYPE, @@ -205,18 +201,18 @@ void Curl_wildcard_dtor(struct WildcardData **wcp) DEBUGASSERT(wc->ftpwc == NULL); Curl_llist_destroy(&wc->filelist, NULL); - free(wc->path); + curlx_free(wc->path); wc->path = NULL; - free(wc->pattern); + curlx_free(wc->pattern); wc->pattern = NULL; wc->state = CURLWC_INIT; - free(wc); + curlx_free(wc); *wcp = NULL; } struct ftp_parselist_data *Curl_ftp_parselist_data_alloc(void) { - return calloc(1, sizeof(struct ftp_parselist_data)); + return curlx_calloc(1, sizeof(struct ftp_parselist_data)); } @@ -225,7 +221,7 @@ void Curl_ftp_parselist_data_free(struct ftp_parselist_data **parserp) struct ftp_parselist_data *parser = *parserp; if(parser) Curl_fileinfo_cleanup(parser->file_data); - free(parser); + curlx_free(parser); *parserp = NULL; } diff --git a/lib/getenv.c b/lib/getenv.c index a2d8056fcc72..73c62d99cd23 100644 --- a/lib/getenv.c +++ b/lib/getenv.c @@ -25,9 +25,6 @@ #include "curl_setup.h" #include -#include "curl_memory.h" - -#include "memdebug.h" static char *GetEnv(const char *variable) { @@ -45,9 +42,9 @@ static char *GetEnv(const char *variable) const DWORD max = 32768; /* max env var size from MSCRT source */ for(;;) { - tmp = realloc(buf, rc); + tmp = curlx_realloc(buf, rc); if(!tmp) { - free(buf); + curlx_free(buf); return NULL; } @@ -58,7 +55,7 @@ static char *GetEnv(const char *variable) Since getenv does not make that distinction we ignore it as well. */ rc = GetEnvironmentVariableA(variable, buf, bufsize); if(!rc || rc == bufsize || rc > max) { - free(buf); + curlx_free(buf); return NULL; } @@ -70,7 +67,7 @@ static char *GetEnv(const char *variable) } #else char *env = getenv(variable); - return (env && env[0]) ? strdup(env) : NULL; + return (env && env[0]) ? curlx_strdup(env) : NULL; #endif } diff --git a/lib/getinfo.c b/lib/getinfo.c index 01c727935620..14244d087b06 100644 --- a/lib/getinfo.c +++ b/lib/getinfo.c @@ -34,10 +34,6 @@ #include "progress.h" #include "curlx/strparse.h" -/* The last #include files should be: */ -#include "curl_memory.h" -#include "memdebug.h" - /* * Initialize statistical and informational data. * @@ -74,10 +70,10 @@ void Curl_initinfo(struct Curl_easy *data) info->httpauthpicked = 0; info->numconnects = 0; - free(info->contenttype); + curlx_free(info->contenttype); info->contenttype = NULL; - free(info->wouldredirect); + curlx_free(info->wouldredirect); info->wouldredirect = NULL; memset(&info->primary, 0, sizeof(info->primary)); @@ -137,7 +133,7 @@ static CURLcode getinfo_char(struct Curl_easy *data, CURLINFO info, case CURLINFO_FTP_ENTRY_PATH: /* Return the entrypath string from the most recent connection. This pointer was copied from the connectdata structure by FTP. - The actual string may be free()ed by subsequent libcurl calls so + The actual string may be freed by subsequent libcurl calls so it must be copied to a safer area before the next libcurl call. Callers must never free it themselves. */ *param_charp = data->state.most_recent_ftp_entrypath; diff --git a/lib/gopher.c b/lib/gopher.c index 45d43f6ebdb1..93e9287c99b9 100644 --- a/lib/gopher.c +++ b/lib/gopher.c @@ -40,10 +40,6 @@ #include "escape.h" #include "curlx/warnless.h" -/* The last 2 #include files should be: */ -#include "curl_memory.h" -#include "memdebug.h" - /* * Forward declarations. */ @@ -153,7 +149,7 @@ static CURLcode gopher_do(struct Curl_easy *data, bool *done) if(query) gopherpath = curl_maprintf("%s?%s", path, query); else - gopherpath = strdup(path); + gopherpath = curlx_strdup(path); if(!gopherpath) return CURLE_OUT_OF_MEMORY; @@ -162,7 +158,7 @@ static CURLcode gopher_do(struct Curl_easy *data, bool *done) if(strlen(gopherpath) <= 2) { buf = ""; buf_len = 0; - free(gopherpath); + curlx_free(gopherpath); } else { char *newp; @@ -173,7 +169,7 @@ static CURLcode gopher_do(struct Curl_easy *data, bool *done) /* ... and finally unescape */ result = Curl_urldecode(newp, 0, &buf_alloc, &buf_len, REJECT_ZERO); - free(gopherpath); + curlx_free(gopherpath); if(result) return result; buf = buf_alloc; @@ -224,7 +220,7 @@ static CURLcode gopher_do(struct Curl_easy *data, bool *done) } } - free(buf_alloc); + curlx_free(buf_alloc); if(!result) result = Curl_xfer_send(data, "\r\n", 2, FALSE, &nwritten); diff --git a/lib/hash.c b/lib/hash.c index 8312fbf050fd..2d91c855e614 100644 --- a/lib/hash.c +++ b/lib/hash.c @@ -28,10 +28,6 @@ #include "hash.h" #include "llist.h" -#include "curl_memory.h" - -/* The last #include file should be: */ -#include "memdebug.h" /* random patterns for API verification */ #ifdef DEBUGBUILD @@ -115,7 +111,7 @@ hash_elem_create(const void *key, size_t key_len, const void *p, struct Curl_hash_element *he; /* allocate the struct plus memory after it to store the key */ - he = malloc(sizeof(struct Curl_hash_element) + key_len); + he = curlx_malloc(sizeof(struct Curl_hash_element) + key_len); if(he) { he->next = NULL; /* copy the key */ @@ -145,7 +141,7 @@ static void hash_elem_destroy(struct Curl_hash *h, struct Curl_hash_element *he) { hash_elem_clear_ptr(h, he); - free(he); + curlx_free(he); } static void hash_elem_unlink(struct Curl_hash *h, @@ -177,7 +173,7 @@ void *Curl_hash_add2(struct Curl_hash *h, void *key, size_t key_len, void *p, DEBUGASSERT(h->slots); DEBUGASSERT(h->init == HASHINIT); if(!h->table) { - h->table = calloc(h->slots, sizeof(struct Curl_hash_element *)); + h->table = curlx_calloc(h->slots, sizeof(struct Curl_hash_element *)); if(!h->table) return NULL; /* OOM */ } diff --git a/lib/headers.c b/lib/headers.c index feb52e087de8..91715fd51d3a 100644 --- a/lib/headers.c +++ b/lib/headers.c @@ -30,10 +30,6 @@ #include "headers.h" #include "curlx/strparse.h" -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - #if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_HEADERS_API) /* Generate the curl_header struct for the user. This function MUST assign all @@ -317,7 +313,7 @@ CURLcode Curl_headers_push(struct Curl_easy *data, const char *header, return CURLE_TOO_LARGE; } - hs = calloc(1, sizeof(*hs) + hlen); + hs = curlx_calloc(1, sizeof(*hs) + hlen); if(!hs) return CURLE_OUT_OF_MEMORY; memcpy(hs->buffer, header, hlen); @@ -336,7 +332,7 @@ CURLcode Curl_headers_push(struct Curl_easy *data, const char *header, } else { failf(data, "Invalid response header"); - free(hs); + curlx_free(hs); } return result; } @@ -417,7 +413,7 @@ CURLcode Curl_headers_cleanup(struct Curl_easy *data) for(e = Curl_llist_head(&data->state.httphdrs); e; e = n) { struct Curl_header_store *hs = Curl_node_elem(e); n = Curl_node_next(e); - free(hs); + curlx_free(hs); } headers_reset(data); return CURLE_OK; diff --git a/lib/hmac.c b/lib/hmac.c index 7842f0601b06..4f226e6434f8 100644 --- a/lib/hmac.c +++ b/lib/hmac.c @@ -33,12 +33,8 @@ #include #include "curl_hmac.h" -#include "curl_memory.h" #include "curlx/warnless.h" -/* The last #include file should be: */ -#include "memdebug.h" - /* * Generic HMAC algorithm. * @@ -62,7 +58,7 @@ Curl_HMAC_init(const struct HMAC_params *hashparams, /* Create HMAC context. */ i = sizeof(*ctxt) + 2 * hashparams->ctxtsize + hashparams->resultlen; - ctxt = malloc(i); + ctxt = curlx_malloc(i); if(!ctxt) return ctxt; @@ -103,7 +99,7 @@ Curl_HMAC_init(const struct HMAC_params *hashparams, return ctxt; fail: - free(ctxt); + curlx_free(ctxt); return NULL; } @@ -130,7 +126,7 @@ int Curl_HMAC_final(struct HMAC_context *ctxt, unsigned char *output) hashparams->hfinal(output, ctxt->hashctxt1); hashparams->hupdate(ctxt->hashctxt2, output, hashparams->resultlen); hashparams->hfinal(output, ctxt->hashctxt2); - free(ctxt); + curlx_free(ctxt); return 0; } diff --git a/lib/hostip.c b/lib/hostip.c index 58a7712cf485..e81886995eda 100644 --- a/lib/hostip.c +++ b/lib/hostip.c @@ -62,10 +62,6 @@ #include "easy_lock.h" #include "curlx/strparse.h" -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - #if defined(CURLRES_SYNCH) && \ defined(HAVE_ALARM) && \ defined(SIGALRM) && \ @@ -451,7 +447,7 @@ UNITTEST CURLcode Curl_shuffle_addr(struct Curl_easy *data, struct Curl_addrinfo **nodes; infof(data, "Shuffling %i addresses", num_addrs); - nodes = malloc(num_addrs*sizeof(*nodes)); + nodes = curlx_malloc(num_addrs*sizeof(*nodes)); if(nodes) { int i; unsigned int *rnd; @@ -463,7 +459,7 @@ UNITTEST CURLcode Curl_shuffle_addr(struct Curl_easy *data, nodes[i] = nodes[i-1]->ai_next; } - rnd = malloc(rnd_size); + rnd = curlx_malloc(rnd_size); if(rnd) { /* Fisher-Yates shuffle */ if(Curl_rand(data, (unsigned char *)rnd, rnd_size) == CURLE_OK) { @@ -482,11 +478,11 @@ UNITTEST CURLcode Curl_shuffle_addr(struct Curl_easy *data, nodes[num_addrs-1]->ai_next = NULL; *addr = nodes[0]; } - free(rnd); + curlx_free(rnd); } else result = CURLE_OUT_OF_MEMORY; - free(nodes); + curlx_free(nodes); } else result = CURLE_OUT_OF_MEMORY; @@ -519,7 +515,7 @@ Curl_dnscache_mk_entry(struct Curl_easy *data, hostlen = strlen(hostname); /* Create a new cache entry */ - dns = calloc(1, sizeof(struct Curl_dns_entry) + hostlen); + dns = curlx_calloc(1, sizeof(struct Curl_dns_entry) + hostlen); if(!dns) return NULL; @@ -609,7 +605,7 @@ static struct Curl_addrinfo *get_localhost6(int port, const char *name) struct sockaddr_in6 sa6; unsigned char ipv6[16]; unsigned short port16 = (unsigned short)(port & 0xffff); - ca = calloc(1, sizeof(struct Curl_addrinfo) + ss_size + hostlen + 1); + ca = curlx_calloc(1, sizeof(struct Curl_addrinfo) + ss_size + hostlen + 1); if(!ca) return NULL; @@ -658,7 +654,7 @@ static struct Curl_addrinfo *get_localhost(int port, const char *name) return NULL; memcpy(&sa.sin_addr, &ipv4, sizeof(ipv4)); - ca = calloc(1, sizeof(struct Curl_addrinfo) + ss_size + hostlen + 1); + ca = curlx_calloc(1, sizeof(struct Curl_addrinfo) + ss_size + hostlen + 1); if(!ca) return NULL; ca->ai_flags = 0; @@ -1178,10 +1174,10 @@ static void dnscache_entry_free(struct Curl_dns_entry *dns) #ifdef USE_HTTPSRR if(dns->hinfo) { Curl_httpsrr_cleanup(dns->hinfo); - free(dns->hinfo); + curlx_free(dns->hinfo); } #endif - free(dns); + curlx_free(dns); } /* diff --git a/lib/hostip4.c b/lib/hostip4.c index d543c1e14b19..f01e902fd684 100644 --- a/lib/hostip4.c +++ b/lib/hostip4.c @@ -50,10 +50,6 @@ #include "curl_share.h" #include "url.h" -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - #ifdef CURLRES_SYNCH @@ -139,7 +135,7 @@ struct Curl_addrinfo *Curl_ipv4_resolve_r(const char *hostname, */ int h_errnop; - buf = calloc(1, CURL_HOSTENT_SIZE); + buf = curlx_calloc(1, CURL_HOSTENT_SIZE); if(!buf) return NULL; /* major failure */ /* @@ -253,8 +249,8 @@ struct Curl_addrinfo *Curl_ipv4_resolve_r(const char *hostname, * Since we do not know how big buffer this particular lookup required, * we cannot 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 + * name lookup. Fixing this would require an extra allocation and then + * calling Curl_addrinfo_copy() that subsequent reallocation down the new * memory area to the actually used amount. */ } @@ -262,7 +258,7 @@ struct Curl_addrinfo *Curl_ipv4_resolve_r(const char *hostname, #endif /* HAVE_...BYNAME_R_5 || HAVE_...BYNAME_R_6 || HAVE_...BYNAME_R_3 */ { h = NULL; /* set return code to NULL */ - free(buf); + curlx_free(buf); } #else /* (HAVE_GETADDRINFO && HAVE_GETADDRINFO_THREADSAFE) || HAVE_GETHOSTBYNAME_R */ @@ -280,7 +276,7 @@ struct Curl_addrinfo *Curl_ipv4_resolve_r(const char *hostname, ai = Curl_he2ai(h, port); if(buf) /* used a *_r() function */ - free(buf); + curlx_free(buf); } #endif diff --git a/lib/hostip6.c b/lib/hostip6.c index 0f628b3fb5ca..cfba2a5cbf27 100644 --- a/lib/hostip6.c +++ b/lib/hostip6.c @@ -53,10 +53,6 @@ #include "curlx/inet_pton.h" #include "connect.h" -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - #ifdef CURLRES_SYNCH #ifdef DEBUG_ADDRINFO diff --git a/lib/hsts.c b/lib/hsts.c index 836481cd4c36..22add0395732 100644 --- a/lib/hsts.c +++ b/lib/hsts.c @@ -41,10 +41,6 @@ #include "strdup.h" #include "curlx/strparse.h" -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - #define MAX_HSTS_LINE 4095 #define MAX_HSTS_HOSTLEN 2048 #define MAX_HSTS_DATELEN 256 @@ -72,7 +68,7 @@ static time_t hsts_debugtime(void *unused) struct hsts *Curl_hsts_init(void) { - struct hsts *h = calloc(1, sizeof(struct hsts)); + struct hsts *h = curlx_calloc(1, sizeof(struct hsts)); if(h) { Curl_llist_init(&h->list, NULL); } @@ -81,8 +77,8 @@ struct hsts *Curl_hsts_init(void) static void hsts_free(struct stsentry *e) { - free(CURL_UNCONST(e->host)); - free(e); + curlx_free(CURL_UNCONST(e->host)); + curlx_free(e); } void Curl_hsts_cleanup(struct hsts **hp) @@ -96,8 +92,8 @@ void Curl_hsts_cleanup(struct hsts **hp) n = Curl_node_next(e); hsts_free(sts); } - free(h->filename); - free(h); + curlx_free(h->filename); + curlx_free(h); *hp = NULL; } } @@ -116,13 +112,13 @@ static CURLcode hsts_create(struct hsts *h, --hlen; if(hlen) { char *duphost; - struct stsentry *sts = calloc(1, sizeof(struct stsentry)); + struct stsentry *sts = curlx_calloc(1, sizeof(struct stsentry)); if(!sts) return CURLE_OUT_OF_MEMORY; duphost = Curl_memdup0(hostname, hlen); if(!duphost) { - free(sts); + curlx_free(sts); return CURLE_OUT_OF_MEMORY; } @@ -385,7 +381,7 @@ CURLcode Curl_hsts_save(struct Curl_easy *data, struct hsts *h, if(result && tempstore) unlink(tempstore); } - free(tempstore); + curlx_free(tempstore); skipsave: if(data->set.hsts_write) { /* if there is a write callback */ @@ -518,8 +514,8 @@ static CURLcode hsts_load(struct hsts *h, const char *file) /* we need a private copy of the filename so that the hsts cache file name survives an easy handle reset */ - free(h->filename); - h->filename = strdup(file); + curlx_free(h->filename); + h->filename = curlx_strdup(file); if(!h->filename) return CURLE_OUT_OF_MEMORY; diff --git a/lib/http.c b/lib/http.c index 8223c6f0e213..f09d96ee0607 100644 --- a/lib/http.c +++ b/lib/http.c @@ -87,10 +87,6 @@ #include "curl_ctype.h" #include "curlx/strparse.h" -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - /* * Forward declarations. */ @@ -277,7 +273,7 @@ static bool http_header_is_empty(const char *header) /* * Strip off leading and trailing whitespace from the value in the given HTTP - * header line and return a strdup()ed copy in 'valp' - returns an empty + * header line and return a strdup-ed copy in 'valp' - returns an empty * string if the header value consists entirely of whitespace. * * If the header is provided as "name;", ending with a semicolon, it returns a @@ -305,7 +301,7 @@ static CURLcode copy_custom_value(const char *header, char **valp) /* * Strip off leading and trailing whitespace from the value in the given HTTP - * header line and return a strdup()ed copy in 'valp' - returns an empty + * header line and return a strdup-ed copy in 'valp' - returns an empty * string if the header value consists entirely of whitespace. * * This function MUST be used after the header has already been confirmed to @@ -377,18 +373,18 @@ static CURLcode http_output_basic(struct Curl_easy *data, bool proxy) goto fail; } - free(*userp); + curlx_free(*userp); *userp = curl_maprintf("%sAuthorization: Basic %s\r\n", proxy ? "Proxy-" : "", authorization); - free(authorization); + curlx_free(authorization); if(!*userp) { result = CURLE_OUT_OF_MEMORY; goto fail; } fail: - free(out); + curlx_free(out); return result; } @@ -407,7 +403,7 @@ static CURLcode http_output_bearer(struct Curl_easy *data) CURLcode result = CURLE_OK; userp = &data->state.aptr.userpwd; - free(*userp); + curlx_free(*userp); *userp = curl_maprintf("Authorization: Bearer %s\r\n", data->set.str[STRING_BEARER]); @@ -615,8 +611,8 @@ CURLcode Curl_http_auth_act(struct Curl_easy *data) /* In case this is GSS auth, the newurl field is already allocated so we must make sure to free it before allocating a new one. As figured out in bug #2284386 */ - free(data->req.newurl); - data->req.newurl = strdup(data->state.url); /* clone URL */ + curlx_free(data->req.newurl); + data->req.newurl = curlx_strdup(data->state.url); /* clone URL */ if(!data->req.newurl) return CURLE_OUT_OF_MEMORY; } @@ -629,7 +625,7 @@ CURLcode Curl_http_auth_act(struct Curl_easy *data) we did not try HEAD or GET */ if((data->state.httpreq != HTTPREQ_GET) && (data->state.httpreq != HTTPREQ_HEAD)) { - data->req.newurl = strdup(data->state.url); /* clone URL */ + data->req.newurl = curlx_strdup(data->state.url); /* clone URL */ if(!data->req.newurl) return CURLE_OUT_OF_MEMORY; data->state.authhost.done = TRUE; @@ -916,8 +912,8 @@ static CURLcode auth_spnego(struct Curl_easy *data, curlnegotiate *negstate = proxy ? &conn->proxy_negotiate_state : &conn->http_negotiate_state; if(!result) { - free(data->req.newurl); - data->req.newurl = strdup(data->state.url); + curlx_free(data->req.newurl); + data->req.newurl = curlx_strdup(data->state.url); if(!data->req.newurl) return CURLE_OUT_OF_MEMORY; data->state.authproblem = FALSE; @@ -1291,7 +1287,7 @@ CURLcode Curl_http_follow(struct Curl_easy *data, const char *newurl, /* the URL could not be parsed for some reason, but since this is FAKE mode, just duplicate the field as-is */ - follow_url = strdup(newurl); + follow_url = curlx_strdup(newurl); if(!follow_url) return CURLE_OUT_OF_MEMORY; } @@ -1316,13 +1312,13 @@ CURLcode Curl_http_follow(struct Curl_easy *data, const char *newurl, uc = curl_url_get(data->state.uh, CURLUPART_PORT, &portnum, CURLU_DEFAULT_PORT); if(uc) { - free(follow_url); + curlx_free(follow_url); return Curl_uc_to_curlcode(uc); } p = portnum; curlx_str_number(&p, &value, 0xffff); port = (int)value; - free(portnum); + curlx_free(portnum); } if(port != data->info.conn_remote_port) { infof(data, "Clear auth, redirects to port from %u to %u", @@ -1334,7 +1330,7 @@ CURLcode Curl_http_follow(struct Curl_easy *data, const char *newurl, const struct Curl_handler *p; uc = curl_url_get(data->state.uh, CURLUPART_SCHEME, &scheme, 0); if(uc) { - free(follow_url); + curlx_free(follow_url); return Curl_uc_to_curlcode(uc); } @@ -1344,7 +1340,7 @@ CURLcode Curl_http_follow(struct Curl_easy *data, const char *newurl, data->info.conn_scheme, scheme); clear = TRUE; } - free(scheme); + curlx_free(scheme); } if(clear) { Curl_safefree(data->state.aptr.user); @@ -1917,7 +1913,7 @@ static CURLcode http_useragent(struct Curl_easy *data) with the user-agent string specified, we erase the previously made string here. */ if(Curl_checkheaders(data, STRCONST("User-Agent"))) { - free(data->state.aptr.uagent); + curlx_free(data->state.aptr.uagent); data->state.aptr.uagent = NULL; } return CURLE_OK; @@ -1932,9 +1928,9 @@ static CURLcode http_set_aptr_host(struct Curl_easy *data) if(!data->state.this_is_a_follow) { /* Free to avoid leaking memory on multiple requests */ - free(data->state.first_host); + curlx_free(data->state.first_host); - data->state.first_host = strdup(conn->host.name); + data->state.first_host = curlx_strdup(conn->host.name); if(!data->state.first_host) return CURLE_OUT_OF_MEMORY; @@ -1958,7 +1954,7 @@ static CURLcode http_set_aptr_host(struct Curl_easy *data) return result; if(!*cookiehost) /* ignore empty data */ - free(cookiehost); + curlx_free(cookiehost); else { /* If the host begins with '[', we start searching for the port after the bracket has been closed */ @@ -1977,7 +1973,7 @@ static CURLcode http_set_aptr_host(struct Curl_easy *data) if(colon) *colon = 0; /* The host must not include an embedded port number */ } - free(aptr->cookiehost); + curlx_free(aptr->cookiehost); aptr->cookiehost = cookiehost; } #endif @@ -2086,7 +2082,7 @@ static CURLcode http_target(struct Curl_easy *data, /* target or URL */ result = curlx_dyn_add(r, data->set.str[STRING_TARGET] ? data->set.str[STRING_TARGET] : url); - free(url); + curlx_free(url); if(result) return result; @@ -2142,7 +2138,7 @@ static CURLcode set_post_reader(struct Curl_easy *data, Curl_HttpReq httpreq) /* Convert the form structure into a mime structure, then keep the conversion */ if(!data->state.formp) { - data->state.formp = calloc(1, sizeof(curl_mimepart)); + data->state.formp = curlx_calloc(1, sizeof(curl_mimepart)); if(!data->state.formp) return CURLE_OUT_OF_MEMORY; Curl_mime_cleanpart(data->state.formp); @@ -2547,7 +2543,7 @@ static CURLcode http_range(struct Curl_easy *data, if(((httpreq == HTTPREQ_GET) || (httpreq == HTTPREQ_HEAD)) && !Curl_checkheaders(data, STRCONST("Range"))) { /* if a line like this was already allocated, free the previous one */ - free(data->state.aptr.rangeline); + curlx_free(data->state.aptr.rangeline); data->state.aptr.rangeline = curl_maprintf("Range: bytes=%s\r\n", data->state.range); if(!data->state.aptr.rangeline) @@ -2557,7 +2553,7 @@ static CURLcode http_range(struct Curl_easy *data, !Curl_checkheaders(data, STRCONST("Content-Range"))) { curl_off_t req_clen = Curl_creader_total_length(data); /* if a line like this was already allocated, free the previous one */ - free(data->state.aptr.rangeline); + curlx_free(data->state.aptr.rangeline); if(data->set.set_resume_from < 0) { /* Upload resume was asked for, but we do not know the size of the @@ -2723,7 +2719,7 @@ static CURLcode http_add_connection_hd(struct Curl_easy *data, return result; result = curlx_dyn_addf(req, "%s%s", sep, value); sep = ", "; - free(value); + curlx_free(value); break; /* leave, having added 1st one */ } } @@ -3000,7 +2996,7 @@ CURLcode Curl_http(struct Curl_easy *data, bool *done) } result = Curl_http_output_auth(data, data->conn, method, httpreq, (pq ? pq : data->state.up.path), FALSE); - free(pq); + curlx_free(pq); } if(result) goto out; @@ -3245,9 +3241,9 @@ static CURLcode http_header_c(struct Curl_easy *data, return CURLE_OUT_OF_MEMORY; if(!*contenttype) /* ignore empty data */ - free(contenttype); + curlx_free(contenttype); else { - free(data->info.contenttype); + curlx_free(data->info.contenttype); data->info.contenttype = contenttype; } return CURLE_OK; @@ -3333,14 +3329,14 @@ static CURLcode http_header_l(struct Curl_easy *data, if(!*location || (data->req.location && !strcmp(data->req.location, location))) { /* ignore empty header, or exact repeat of a previous one */ - free(location); + curlx_free(location); return CURLE_OK; } else { /* has value and is not an exact repeat */ if(data->req.location) { failf(data, "Multiple Location headers"); - free(location); + curlx_free(location); return CURLE_WEIRD_SERVER_REPLY; } data->req.location = location; @@ -3349,7 +3345,7 @@ static CURLcode http_header_l(struct Curl_easy *data, data->set.http_follow_mode) { CURLcode result; DEBUGASSERT(!data->req.newurl); - data->req.newurl = strdup(data->req.location); /* clone */ + data->req.newurl = curlx_strdup(data->req.location); /* clone */ if(!data->req.newurl) return CURLE_OUT_OF_MEMORY; @@ -3407,7 +3403,7 @@ static CURLcode http_header_p(struct Curl_easy *data, CURLcode result = auth ? CURLE_OK : CURLE_OUT_OF_MEMORY; if(!result) { result = Curl_http_input_auth(data, TRUE, auth); - free(auth); + curlx_free(auth); } return result; } @@ -3426,7 +3422,7 @@ static CURLcode http_header_p(struct Curl_easy *data, negdata->havenoauthpersist = TRUE; infof(data, "Negotiate: noauthpersist -> %d, header part: %s", negdata->noauthpersist, persistentauth); - free(persistentauth); + curlx_free(persistentauth); } } #endif @@ -3587,7 +3583,7 @@ static CURLcode http_header_w(struct Curl_easy *data, result = CURLE_OUT_OF_MEMORY; else { result = Curl_http_input_auth(data, FALSE, auth); - free(auth); + curlx_free(auth); } } return result; @@ -4065,7 +4061,7 @@ static CURLcode http_on_response(struct Curl_easy *data, data->state.disableexpect = TRUE; Curl_req_abort_sending(data); DEBUGASSERT(!data->req.newurl); - data->req.newurl = strdup(data->state.url); + data->req.newurl = curlx_strdup(data->state.url); if(!data->req.newurl) { result = CURLE_OUT_OF_MEMORY; goto out; @@ -4533,7 +4529,7 @@ CURLcode Curl_http_req_make(struct httpreq **preq, DEBUGASSERT(method && m_len); - req = calloc(1, sizeof(*req) + m_len); + req = curlx_calloc(1, sizeof(*req) + m_len); if(!req) goto out; #if defined(__GNUC__) && __GNUC__ >= 13 @@ -4606,8 +4602,8 @@ static CURLcode req_assign_url_authority(struct httpreq *req, CURLU *url) } req->authority = curlx_dyn_ptr(&buf); out: - free(host); - free(port); + curlx_free(host); + curlx_free(port); if(result) curlx_dyn_free(&buf); return result; @@ -4645,8 +4641,8 @@ static CURLcode req_assign_url_path(struct httpreq *req, CURLU *url) result = CURLE_OK; out: - free(path); - free(query); + curlx_free(path); + curlx_free(query); if(result) curlx_dyn_free(&buf); return result; @@ -4662,7 +4658,7 @@ CURLcode Curl_http_req_make2(struct httpreq **preq, DEBUGASSERT(method && m_len); - req = calloc(1, sizeof(*req) + m_len); + req = curlx_calloc(1, sizeof(*req) + m_len); if(!req) goto out; memcpy(req->method, method, m_len); @@ -4671,7 +4667,7 @@ CURLcode Curl_http_req_make2(struct httpreq **preq, if(uc && uc != CURLUE_NO_SCHEME) goto out; if(!req->scheme && scheme_default) { - req->scheme = strdup(scheme_default); + req->scheme = curlx_strdup(scheme_default); if(!req->scheme) goto out; } @@ -4697,12 +4693,12 @@ CURLcode Curl_http_req_make2(struct httpreq **preq, void Curl_http_req_free(struct httpreq *req) { if(req) { - free(req->scheme); - free(req->authority); - free(req->path); + curlx_free(req->scheme); + curlx_free(req->authority); + curlx_free(req->path); Curl_dynhds_free(&req->headers); Curl_dynhds_free(&req->trailers); - free(req); + curlx_free(req); } } @@ -4840,13 +4836,13 @@ CURLcode Curl_http_resp_make(struct http_resp **presp, struct http_resp *resp; CURLcode result = CURLE_OUT_OF_MEMORY; - resp = calloc(1, sizeof(*resp)); + resp = curlx_calloc(1, sizeof(*resp)); if(!resp) goto out; resp->status = status; if(description) { - resp->description = strdup(description); + resp->description = curlx_strdup(description); if(!resp->description) goto out; } @@ -4864,12 +4860,12 @@ CURLcode Curl_http_resp_make(struct http_resp **presp, void Curl_http_resp_free(struct http_resp *resp) { if(resp) { - free(resp->description); + curlx_free(resp->description); Curl_dynhds_free(&resp->headers); Curl_dynhds_free(&resp->trailers); if(resp->prev) Curl_http_resp_free(resp->prev); - free(resp); + curlx_free(resp); } } diff --git a/lib/http1.c b/lib/http1.c index b1d80976360a..0a80fedfc722 100644 --- a/lib/http1.c +++ b/lib/http1.c @@ -32,10 +32,6 @@ #include "http1.h" #include "urlapi-int.h" -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - #define H1_MAX_URL_LEN (8*1024) diff --git a/lib/http2.c b/lib/http2.c index 2e8649c10502..baaefd439d4f 100644 --- a/lib/http2.c +++ b/lib/http2.c @@ -48,10 +48,6 @@ #include "curlx/warnless.h" #include "headers.h" -/* The last 3 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - #if (NGHTTP2_VERSION_NUM < 0x010c00) #error too old nghttp2 version, upgrade! #endif @@ -168,7 +164,7 @@ static void cf_h2_ctx_free(struct cf_h2_ctx *ctx) Curl_uint32_hash_destroy(&ctx->streams); memset(ctx, 0, sizeof(*ctx)); } - free(ctx); + curlx_free(ctx); } static void cf_h2_ctx_close(struct cf_h2_ctx *ctx) @@ -276,7 +272,7 @@ static struct h2_stream_ctx *h2_stream_ctx_create(struct cf_h2_ctx *ctx) struct h2_stream_ctx *stream; (void)ctx; - stream = calloc(1, sizeof(*stream)); + stream = curlx_calloc(1, sizeof(*stream)); if(!stream) return NULL; @@ -299,7 +295,7 @@ static void free_push_headers(struct h2_stream_ctx *stream) { size_t i; for(i = 0; i < stream->push_headers_used; i++) - free(stream->push_headers[i]); + curlx_free(stream->push_headers[i]); Curl_safefree(stream->push_headers); stream->push_headers_used = 0; } @@ -310,7 +306,7 @@ static void h2_stream_ctx_free(struct h2_stream_ctx *stream) Curl_h1_req_parse_free(&stream->h1); Curl_dynhds_free(&stream->resp_trailers); free_push_headers(stream); - free(stream); + curlx_free(stream); } static void h2_stream_hash_free(unsigned int id, void *stream) @@ -952,7 +948,7 @@ static int set_transfer_url(struct Curl_easy *data, return rc; if(data->state.url_alloc) - free(data->state.url); + curlx_free(data->state.url); data->state.url_alloc = TRUE; data->state.url = url; return 0; @@ -1642,15 +1638,15 @@ static int on_header(nghttp2_session *session, const nghttp2_frame *frame, stream_id, NGHTTP2_PROTOCOL_ERROR); rc = NGHTTP2_ERR_CALLBACK_FAILURE; } - free(check); + curlx_free(check); if(rc) return rc; } if(!stream->push_headers) { stream->push_headers_alloc = 10; - stream->push_headers = malloc(stream->push_headers_alloc * - sizeof(char *)); + stream->push_headers = curlx_malloc(stream->push_headers_alloc * + sizeof(char *)); if(!stream->push_headers) return NGHTTP2_ERR_CALLBACK_FAILURE; stream->push_headers_used = 0; @@ -1665,8 +1661,8 @@ static int on_header(nghttp2_session *session, const nghttp2_frame *frame, return NGHTTP2_ERR_CALLBACK_FAILURE; } stream->push_headers_alloc *= 2; - headp = realloc(stream->push_headers, - stream->push_headers_alloc * sizeof(char *)); + headp = curlx_realloc(stream->push_headers, + stream->push_headers_alloc * sizeof(char *)); if(!headp) { free_push_headers(stream); return NGHTTP2_ERR_CALLBACK_FAILURE; @@ -1859,7 +1855,7 @@ CURLcode Curl_http2_request_upgrade(struct dynbuf *req, "Upgrade: %s\r\n" "HTTP2-Settings: %s\r\n", NGHTTP2_CLEARTEXT_PROTO_VERSION_ID, base64); - free(base64); + curlx_free(base64); k->upgr101 = UPGR101_H2; data->conn->bits.upgrade_in_progress = TRUE; @@ -2881,7 +2877,7 @@ static CURLcode http2_cfilter_add(struct Curl_cfilter **pcf, CURLcode result = CURLE_OUT_OF_MEMORY; DEBUGASSERT(data->conn); - ctx = calloc(1, sizeof(*ctx)); + ctx = curlx_calloc(1, sizeof(*ctx)); if(!ctx) goto out; cf_h2_ctx_init(ctx, via_h1_upgrade); @@ -2909,7 +2905,7 @@ static CURLcode http2_cfilter_insert_after(struct Curl_cfilter *cf, CURLcode result = CURLE_OUT_OF_MEMORY; (void)data; - ctx = calloc(1, sizeof(*ctx)); + ctx = curlx_calloc(1, sizeof(*ctx)); if(!ctx) goto out; cf_h2_ctx_init(ctx, via_h1_upgrade); diff --git a/lib/http_aws_sigv4.c b/lib/http_aws_sigv4.c index d3d4760be780..0ef18b6feabe 100644 --- a/lib/http_aws_sigv4.c +++ b/lib/http_aws_sigv4.c @@ -39,10 +39,6 @@ #include -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - #include "slist.h" #define HMAC_SHA256(k, kl, d, dl, o) \ @@ -210,12 +206,12 @@ static CURLcode merge_duplicate_headers(struct curl_slist *head) if(result) return result; - free(curr->data); + curlx_free(curr->data); curr->data = curlx_dyn_ptr(&buf); curr->next = next->next; - free(next->data); - free(next); + curlx_free(next->data); + curlx_free(next); } else { curr = curr->next; @@ -269,7 +265,7 @@ static CURLcode make_headers(struct Curl_easy *data, if(fullhost) head = Curl_slist_append_nodup(NULL, fullhost); if(!head) { - free(fullhost); + curlx_free(fullhost); goto fail; } } @@ -307,13 +303,13 @@ static CURLcode make_headers(struct Curl_easy *data, ; if(!*ptr && ptr != sep + 1) /* a value of whitespace only */ continue; - dupdata = strdup(l->data); + dupdata = curlx_strdup(l->data); if(!dupdata) goto fail; dupdata[sep - l->data] = ':'; tmp_head = Curl_slist_append_nodup(head, dupdata); if(!tmp_head) { - free(dupdata); + curlx_free(dupdata); goto fail; } head = tmp_head; @@ -964,7 +960,7 @@ CURLcode Curl_output_aws_sigv4(struct Curl_easy *data) Curl_strntoupper(&auth_headers[sizeof("Authorization: ") - 1], curlx_str(&provider0), curlx_strlen(&provider0)); - free(data->state.aptr.userpwd); + curlx_free(data->state.aptr.userpwd); data->state.aptr.userpwd = auth_headers; data->state.authhost.done = TRUE; result = CURLE_OK; @@ -974,12 +970,12 @@ CURLcode Curl_output_aws_sigv4(struct Curl_easy *data) curlx_dyn_free(&canonical_path); curlx_dyn_free(&canonical_headers); curlx_dyn_free(&signed_headers); - free(canonical_request); - free(request_type); - free(credential_scope); - free(str_to_sign); - free(secret); - free(date_header); + curlx_free(canonical_request); + curlx_free(request_type); + curlx_free(credential_scope); + curlx_free(str_to_sign); + curlx_free(secret); + curlx_free(date_header); return result; } diff --git a/lib/http_chunks.c b/lib/http_chunks.c index 005d34e7b905..9d0a0b324cdd 100644 --- a/lib/http_chunks.c +++ b/lib/http_chunks.c @@ -36,10 +36,6 @@ #include "curlx/strparse.h" #include "curlx/warnless.h" -/* The last #include files should be: */ -#include "curl_memory.h" -#include "memdebug.h" - /* * Chunk format (simplified): * diff --git a/lib/http_digest.c b/lib/http_digest.c index 097c81fd716a..2ca1a12d5daf 100644 --- a/lib/http_digest.c +++ b/lib/http_digest.c @@ -32,10 +32,6 @@ #include "http_digest.h" #include "curlx/strparse.h" -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - /* Test example headers: WWW-Authenticate: Digest realm="testrealm", nonce="1053604598" @@ -152,20 +148,20 @@ CURLcode Curl_output_digest(struct Curl_easy *data, } } if(!tmp) - path = (unsigned char *)strdup((const char *) uripath); + path = (unsigned char *)curlx_strdup((const char *) uripath); if(!path) return CURLE_OUT_OF_MEMORY; result = Curl_auth_create_digest_http_message(data, userp, passwdp, request, path, digest, &response, &len); - free(path); + curlx_free(path); if(result) return result; *allocuserpwd = curl_maprintf("%sAuthorization: Digest %s\r\n", proxy ? "Proxy-" : "", response); - free(response); + curlx_free(response); if(!*allocuserpwd) return CURLE_OUT_OF_MEMORY; diff --git a/lib/http_negotiate.c b/lib/http_negotiate.c index 136cb07641c4..fc80f80fa350 100644 --- a/lib/http_negotiate.c +++ b/lib/http_negotiate.c @@ -34,10 +34,6 @@ #include "vtls/vtls.h" #include "curlx/strparse.h" -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - static void http_auth_nego_reset(struct connectdata *conn, struct negotiatedata *neg_ctx, @@ -223,16 +219,16 @@ CURLcode Curl_output_negotiate(struct Curl_easy *data, if(proxy) { #ifndef CURL_DISABLE_PROXY - free(data->state.aptr.proxyuserpwd); + curlx_free(data->state.aptr.proxyuserpwd); data->state.aptr.proxyuserpwd = userp; #endif } else { - free(data->state.aptr.userpwd); + curlx_free(data->state.aptr.userpwd); data->state.aptr.userpwd = userp; } - free(base64); + curlx_free(base64); if(!userp) { return CURLE_OUT_OF_MEMORY; diff --git a/lib/http_ntlm.c b/lib/http_ntlm.c index 8cb6403fdb8b..2856745c34c4 100644 --- a/lib/http_ntlm.c +++ b/lib/http_ntlm.c @@ -49,10 +49,6 @@ #include "curl_sspi.h" #endif -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - CURLcode Curl_input_ntlm(struct Curl_easy *data, bool proxy, /* if proxy or not */ const char *header) /* rest of the www-authenticate: @@ -208,11 +204,11 @@ CURLcode Curl_output_ntlm(struct Curl_easy *data, bool proxy) result = curlx_base64_encode(Curl_bufref_ptr(&ntlmmsg), Curl_bufref_len(&ntlmmsg), &base64, &len); if(!result) { - free(*allocuserpwd); + curlx_free(*allocuserpwd); *allocuserpwd = curl_maprintf("%sAuthorization: NTLM %s\r\n", proxy ? "Proxy-" : "", base64); - free(base64); + curlx_free(base64); if(!*allocuserpwd) result = CURLE_OUT_OF_MEMORY; } @@ -227,11 +223,11 @@ CURLcode Curl_output_ntlm(struct Curl_easy *data, bool proxy) result = curlx_base64_encode(Curl_bufref_ptr(&ntlmmsg), Curl_bufref_len(&ntlmmsg), &base64, &len); if(!result) { - free(*allocuserpwd); + curlx_free(*allocuserpwd); *allocuserpwd = curl_maprintf("%sAuthorization: NTLM %s\r\n", proxy ? "Proxy-" : "", base64); - free(base64); + curlx_free(base64); if(!*allocuserpwd) result = CURLE_OUT_OF_MEMORY; else { diff --git a/lib/http_proxy.c b/lib/http_proxy.c index 9bde118baff2..21f0cc6211c1 100644 --- a/lib/http_proxy.c +++ b/lib/http_proxy.c @@ -44,10 +44,6 @@ #include "vauth/vauth.h" #include "curlx/strparse.h" -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - static CURLcode dynhds_add_custom(struct Curl_easy *data, bool is_connect, int httpversion, struct dynhds *hds) @@ -270,7 +266,7 @@ CURLcode Curl_http_proxy_create_CONNECT(struct httpreq **preq, Curl_http_req_free(req); req = NULL; } - free(authority); + curlx_free(authority); *preq = req; return result; } @@ -386,7 +382,7 @@ static void http_proxy_cf_destroy(struct Curl_cfilter *cf, (void)data; CURL_TRC_CF(data, cf, "destroy"); - free(ctx); + curlx_free(ctx); } static void http_proxy_cf_close(struct Curl_cfilter *cf, @@ -425,7 +421,7 @@ CURLcode Curl_cf_http_proxy_insert_after(struct Curl_cfilter *cf_at, CURLcode result; (void)data; - ctx = calloc(1, sizeof(*ctx)); + ctx = curlx_calloc(1, sizeof(*ctx)); if(!ctx) { result = CURLE_OUT_OF_MEMORY; goto out; @@ -437,7 +433,7 @@ CURLcode Curl_cf_http_proxy_insert_after(struct Curl_cfilter *cf_at, Curl_conn_cf_insert_after(cf_at, cf); out: - free(ctx); + curlx_free(ctx); return result; } diff --git a/lib/httpsrr.c b/lib/httpsrr.c index 0cf5b131bd31..34d081b50264 100644 --- a/lib/httpsrr.c +++ b/lib/httpsrr.c @@ -33,10 +33,6 @@ #include "sendf.h" #include "strdup.h" -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - static CURLcode httpsrr_decode_alpn(const uint8_t *cp, size_t len, unsigned char *alpns) { @@ -97,7 +93,7 @@ CURLcode Curl_httpsrr_set(struct Curl_easy *data, case HTTPS_RR_CODE_IPV4: /* addr4 list */ if(!vlen || (vlen & 3)) /* the size must be 4-byte aligned */ return CURLE_BAD_FUNCTION_ARGUMENT; - free(hi->ipv4hints); + curlx_free(hi->ipv4hints); hi->ipv4hints = Curl_memdup(val, vlen); if(!hi->ipv4hints) return CURLE_OUT_OF_MEMORY; @@ -107,7 +103,7 @@ CURLcode Curl_httpsrr_set(struct Curl_easy *data, case HTTPS_RR_CODE_ECH: if(!vlen) return CURLE_BAD_FUNCTION_ARGUMENT; - free(hi->echconfiglist); + curlx_free(hi->echconfiglist); hi->echconfiglist = Curl_memdup(val, vlen); if(!hi->echconfiglist) return CURLE_OUT_OF_MEMORY; @@ -117,7 +113,7 @@ CURLcode Curl_httpsrr_set(struct Curl_easy *data, case HTTPS_RR_CODE_IPV6: /* addr6 list */ if(!vlen || (vlen & 15)) /* the size must be 16-byte aligned */ return CURLE_BAD_FUNCTION_ARGUMENT; - free(hi->ipv6hints); + curlx_free(hi->ipv6hints); hi->ipv6hints = Curl_memdup(val, vlen); if(!hi->ipv6hints) return CURLE_OUT_OF_MEMORY; @@ -189,8 +185,8 @@ CURLcode Curl_httpsrr_from_ares(struct Curl_easy *data, is in ServiceMode */ target = ares_dns_rr_get_str(rr, ARES_RR_HTTPS_TARGET); if(target && target[0]) { - free(hinfo->target); - hinfo->target = strdup(target); + curlx_free(hinfo->target); + hinfo->target = curlx_strdup(target); if(!hinfo->target) { result = CURLE_OUT_OF_MEMORY; goto out; diff --git a/lib/idn.c b/lib/idn.c index 7e324db6c4b0..1c404f6543f3 100644 --- a/lib/idn.c +++ b/lib/idn.c @@ -45,10 +45,6 @@ #endif #endif /* USE_LIBIDN2 */ -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - /* for macOS and iOS targets */ #ifdef USE_APPLE_IDN #include @@ -108,7 +104,7 @@ static CURLcode mac_idn_to_ascii(const char *in, char **out) buffer, sizeof(buffer) - 1, &info, &err); uidna_close(idna); if(!U_FAILURE(err) && !info.errors) { - *out = strdup(buffer); + *out = curlx_strdup(buffer); if(*out) return CURLE_OK; else @@ -136,7 +132,7 @@ static CURLcode mac_ascii_to_idn(const char *in, char **out) sizeof(buffer) - 1, &info, &err); uidna_close(idna); if(!U_FAILURE(err)) { - *out = strdup(buffer); + *out = curlx_strdup(buffer); if(*out) return CURLE_OK; else @@ -179,7 +175,7 @@ static CURLcode win32_idn_to_ascii(const char *in, char **out) if(chars) { char *mstr = curlx_convert_wchar_to_UTF8(punycode); if(mstr) { - *out = strdup(mstr); + *out = curlx_strdup(mstr); curlx_unicodefree(mstr); if(!*out) return CURLE_OUT_OF_MEMORY; @@ -209,7 +205,7 @@ static CURLcode win32_ascii_to_idn(const char *in, char **output) /* 'chars' is "the number of characters retrieved" */ char *mstr = curlx_convert_wchar_to_UTF8(idn); if(mstr) { - out = strdup(mstr); + out = curlx_strdup(mstr); curlx_unicodefree(mstr); if(!out) return CURLE_OUT_OF_MEMORY; @@ -314,7 +310,7 @@ CURLcode Curl_idn_decode(const char *input, char **output) CURLcode result = idn_decode(input, &d); #ifdef USE_LIBIDN2 if(!result) { - char *c = strdup(d); + char *c = curlx_strdup(d); idn2_free(d); if(c) d = c; @@ -325,7 +321,7 @@ CURLcode Curl_idn_decode(const char *input, char **output) if(!result) { if(!d[0]) { /* ended up zero length, not acceptable */ result = CURLE_URL_MALFORMAT; - free(d); + curlx_free(d); } else *output = d; @@ -339,7 +335,7 @@ CURLcode Curl_idn_encode(const char *puny, char **output) CURLcode result = idn_encode(puny, &d); #ifdef USE_LIBIDN2 if(!result) { - char *c = strdup(d); + char *c = curlx_strdup(d); idn2_free(d); if(c) d = c; diff --git a/lib/if2ip.c b/lib/if2ip.c index 79b0599106de..c2b8aafc4d7e 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -55,10 +55,6 @@ #include "curlx/inet_ntop.h" #include "if2ip.h" -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - /* ------------------------------------------------------------------ */ #ifdef USE_IPV6 diff --git a/lib/imap.c b/lib/imap.c index af9b124d1e72..d093e46d33ab 100644 --- a/lib/imap.c +++ b/lib/imap.c @@ -78,10 +78,6 @@ #include "curlx/warnless.h" #include "curl_ctype.h" -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - /* meta key for storing protocol meta at easy handle */ #define CURL_META_IMAP_EASY "meta:proto:imap:easy" @@ -617,8 +613,8 @@ static CURLcode imap_perform_login(struct Curl_easy *data, result = imap_sendf(data, imapc, "LOGIN %s %s", user ? user : "", passwd ? passwd : ""); - free(user); - free(passwd); + curlx_free(user); + curlx_free(passwd); if(!result) imap_state(data, imapc, IMAP_LOGIN); @@ -751,14 +747,14 @@ static CURLcode imap_perform_list(struct Curl_easy *data, else { /* Make sure the mailbox is in the correct atom format if necessary */ char *mailbox = imap->mailbox ? imap_atom(imap->mailbox, TRUE) - : strdup(""); + : curlx_strdup(""); if(!mailbox) return CURLE_OUT_OF_MEMORY; /* Send the LIST command */ result = imap_sendf(data, imapc, "LIST \"%s\" *", mailbox); - free(mailbox); + curlx_free(mailbox); } if(!result) @@ -797,7 +793,7 @@ static CURLcode imap_perform_select(struct Curl_easy *data, /* Send the SELECT command */ result = imap_sendf(data, imapc, "SELECT %s", mailbox); - free(mailbox); + curlx_free(mailbox); if(!result) imap_state(data, imapc, IMAP_SELECT); @@ -947,7 +943,7 @@ static CURLcode imap_perform_append(struct Curl_easy *data, cleanup: curlx_dyn_free(&flags); - free(mailbox); + curlx_free(mailbox); if(!result) imap_state(data, imapc, IMAP_APPEND); @@ -1338,7 +1334,7 @@ static CURLcode imap_state_select_resp(struct Curl_easy *data, else { /* Note the currently opened mailbox on this connection */ DEBUGASSERT(!imapc->mailbox); - imapc->mailbox = strdup(imap->mailbox); + imapc->mailbox = curlx_strdup(imap->mailbox); if(!imapc->mailbox) return CURLE_OUT_OF_MEMORY; @@ -1967,7 +1963,7 @@ static void imap_easy_dtor(void *key, size_t klen, void *entry) (void)key; (void)klen; imap_easy_reset(imap); - free(imap); + curlx_free(imap); } static void imap_conn_dtor(void *key, size_t klen, void *entry) @@ -1978,7 +1974,7 @@ static void imap_conn_dtor(void *key, size_t klen, void *entry) Curl_pp_disconnect(&imapc->pp); curlx_dyn_free(&imapc->dyn); Curl_safefree(imapc->mailbox); - free(imapc); + curlx_free(imapc); } static CURLcode imap_setup_connection(struct Curl_easy *data, @@ -1988,7 +1984,7 @@ static CURLcode imap_setup_connection(struct Curl_easy *data, struct pingpong *pp; struct IMAP *imap; - imapc = calloc(1, sizeof(*imapc)); + imapc = curlx_calloc(1, sizeof(*imapc)); if(!imapc) return CURLE_OUT_OF_MEMORY; @@ -2005,7 +2001,7 @@ static CURLcode imap_setup_connection(struct Curl_easy *data, if(Curl_conn_meta_set(conn, CURL_META_IMAP_CONN, imapc, imap_conn_dtor)) return CURLE_OUT_OF_MEMORY; - imap = calloc(1, sizeof(struct IMAP)); + imap = curlx_calloc(1, sizeof(struct IMAP)); if(!imap || Curl_meta_set(data, CURL_META_IMAP_EASY, imap, imap_easy_dtor)) return CURLE_OUT_OF_MEMORY; @@ -2078,7 +2074,7 @@ static char *imap_atom(const char *str, bool escape_only) nclean = strcspn(str, "() {%*]\\\""); if(len == nclean) /* nothing to escape, return a strdup */ - return strdup(str); + return curlx_strdup(str); curlx_dyn_init(&line, 2000); @@ -2258,7 +2254,7 @@ static CURLcode imap_parse_url_path(struct Curl_easy *data, result = Curl_urldecode(begin, ptr - begin, &value, &valuelen, REJECT_CTRL); if(result) { - free(name); + curlx_free(name); return result; } @@ -2279,7 +2275,7 @@ static CURLcode imap_parse_url_path(struct Curl_easy *data, imap->uidvalidity = (unsigned int)num; imap->uidvalidity_set = TRUE; } - free(value); + curlx_free(value); } else if(curl_strequal(name, "UID") && !imap->uid) { imap->uid = value; @@ -2294,15 +2290,15 @@ static CURLcode imap_parse_url_path(struct Curl_easy *data, imap->partial = value; } else { - free(name); - free(value); + curlx_free(name); + curlx_free(value); return CURLE_URL_MALFORMAT; } } else /* blank? */ - free(value); - free(name); + curlx_free(value); + curlx_free(name); } /* Does the URL contain a query parameter? Only valid when we have a mailbox @@ -2346,7 +2342,7 @@ static CURLcode imap_parse_custom_request(struct Curl_easy *data, params++; if(*params) { - imap->custom_params = strdup(params); + imap->custom_params = curlx_strdup(params); imap->custom[params - imap->custom] = '\0'; if(!imap->custom_params) diff --git a/lib/ldap.c b/lib/ldap.c index 7f2af3664325..6c6207038571 100644 --- a/lib/ldap.c +++ b/lib/ldap.c @@ -94,10 +94,6 @@ #include "curlx/base64.h" #include "connect.h" -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - #ifdef USE_WIN32_LDAP #define FREE_ON_WINLDAP(x) curlx_unicodefree(x) #define curl_ldap_num_t ULONG @@ -642,7 +638,7 @@ static CURLcode ldap_do(struct Curl_easy *data, bool *done) if(val_b64_sz > 0) { result = Curl_client_write(data, CLIENTWRITE_BODY, val_b64, val_b64_sz); - free(val_b64); + curlx_free(val_b64); if(result) { ldap_value_free_len(vals); FREE_ON_WINLDAP(attr); @@ -809,15 +805,15 @@ static curl_ldap_num_t ldap_url_parse2_low(struct Curl_easy *data, ludp->lud_host = conn->host.name; /* Duplicate the path */ - p = path = strdup(data->state.up.path + 1); + p = path = curlx_strdup(data->state.up.path + 1); if(!path) return LDAP_NO_MEMORY; /* Duplicate the query if present */ if(data->state.up.query) { - q = query = strdup(data->state.up.query); + q = query = curlx_strdup(data->state.up.query); if(!query) { - free(path); + curlx_free(path); return LDAP_NO_MEMORY; } } @@ -843,7 +839,7 @@ static curl_ldap_num_t ldap_url_parse2_low(struct Curl_easy *data, ludp->lud_dn = curlx_convert_UTF8_to_tchar(unescaped); /* Free the unescaped string as we are done with it */ - free(unescaped); + curlx_free(unescaped); if(!ludp->lud_dn) { rc = LDAP_NO_MEMORY; @@ -870,9 +866,9 @@ static curl_ldap_num_t ldap_url_parse2_low(struct Curl_easy *data, /* Allocate our array (+1 for the NULL entry) */ #ifdef USE_WIN32_LDAP - ludp->lud_attrs = calloc(count + 1, sizeof(TCHAR *)); + ludp->lud_attrs = curlx_calloc(count + 1, sizeof(TCHAR *)); #else - ludp->lud_attrs = calloc(count + 1, sizeof(char *)); + ludp->lud_attrs = curlx_calloc(count + 1, sizeof(char *)); #endif if(!ludp->lud_attrs) { rc = LDAP_NO_MEMORY; @@ -902,7 +898,7 @@ static curl_ldap_num_t ldap_url_parse2_low(struct Curl_easy *data, ludp->lud_attrs[i] = curlx_convert_UTF8_to_tchar(unescaped); /* Free the unescaped string as we are done with it */ - free(unescaped); + curlx_free(unescaped); if(!ludp->lud_attrs[i]) { rc = LDAP_NO_MEMORY; @@ -966,7 +962,7 @@ static curl_ldap_num_t ldap_url_parse2_low(struct Curl_easy *data, ludp->lud_filter = curlx_convert_UTF8_to_tchar(unescaped); /* Free the unescaped string as we are done with it */ - free(unescaped); + curlx_free(unescaped); if(!ludp->lud_filter) { rc = LDAP_NO_MEMORY; @@ -986,8 +982,8 @@ static curl_ldap_num_t ldap_url_parse2_low(struct Curl_easy *data, } quit: - free(path); - free(query); + curlx_free(path); + curlx_free(query); return rc; } @@ -996,7 +992,7 @@ static curl_ldap_num_t ldap_url_parse_low(struct Curl_easy *data, const struct connectdata *conn, LDAPURLDesc **ludpp) { - LDAPURLDesc *ludp = calloc(1, sizeof(*ludp)); + LDAPURLDesc *ludp = curlx_calloc(1, sizeof(*ludp)); curl_ldap_num_t rc; *ludpp = NULL; @@ -1021,8 +1017,8 @@ static void ldap_free_urldesc_low(LDAPURLDesc *ludp) curlx_unicodefree(ludp->lud_dn); curlx_unicodefree(ludp->lud_filter); #else - free(ludp->lud_dn); - free(ludp->lud_filter); + curlx_free(ludp->lud_dn); + curlx_free(ludp->lud_filter); #endif if(ludp->lud_attrs) { @@ -1031,13 +1027,13 @@ static void ldap_free_urldesc_low(LDAPURLDesc *ludp) #ifdef USE_WIN32_LDAP curlx_unicodefree(ludp->lud_attrs[i]); #else - free(ludp->lud_attrs[i]); + curlx_free(ludp->lud_attrs[i]); #endif } - free(ludp->lud_attrs); + curlx_free(ludp->lud_attrs); } - free(ludp); + curlx_free(ludp); } #endif /* !HAVE_LDAP_URL_PARSE */ diff --git a/lib/llist.c b/lib/llist.c index c9a7d4a8a789..ebcda82a04ed 100644 --- a/lib/llist.c +++ b/lib/llist.c @@ -27,10 +27,6 @@ #include #include "llist.h" -#include "curl_memory.h" - -/* this must be the last include file */ -#include "memdebug.h" #ifdef DEBUGBUILD #define LLISTINIT 0x100cc001 /* random pattern */ diff --git a/lib/md4.c b/lib/md4.c index 0cc62f815233..7929e57f65c0 100644 --- a/lib/md4.c +++ b/lib/md4.c @@ -71,10 +71,6 @@ #include #endif -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - #if defined(USE_WOLFSSL) && !defined(WOLFSSL_NO_MD4) diff --git a/lib/md5.c b/lib/md5.c index 4b38bb070b32..a579b02c63ae 100644 --- a/lib/md5.c +++ b/lib/md5.c @@ -81,10 +81,6 @@ #include #endif -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - #ifdef USE_GNUTLS typedef struct md5_ctx my_md5_ctx; @@ -604,23 +600,23 @@ struct MD5_context *Curl_MD5_init(const struct MD5_params *md5params) struct MD5_context *ctxt; /* Create MD5 context */ - ctxt = malloc(sizeof(*ctxt)); + ctxt = curlx_malloc(sizeof(*ctxt)); if(!ctxt) return ctxt; - ctxt->md5_hashctx = malloc(md5params->md5_ctxtsize); + ctxt->md5_hashctx = curlx_malloc(md5params->md5_ctxtsize); if(!ctxt->md5_hashctx) { - free(ctxt); + curlx_free(ctxt); return NULL; } ctxt->md5_hash = md5params; if((*md5params->md5_init_func)(ctxt->md5_hashctx)) { - free(ctxt->md5_hashctx); - free(ctxt); + curlx_free(ctxt->md5_hashctx); + curlx_free(ctxt); return NULL; } @@ -640,8 +636,8 @@ CURLcode Curl_MD5_final(struct MD5_context *context, unsigned char *result) { (*context->md5_hash->md5_final_func)(result, context->md5_hashctx); - free(context->md5_hashctx); - free(context); + curlx_free(context->md5_hashctx); + curlx_free(context); return CURLE_OK; } diff --git a/lib/memdebug.c b/lib/memdebug.c index 1121dc26f550..f5b88731ee35 100644 --- a/lib/memdebug.c +++ b/lib/memdebug.c @@ -35,10 +35,6 @@ #include "backtrace.h" #endif -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - struct memdebug { size_t size; union { diff --git a/lib/memdebug.h b/lib/memdebug.h deleted file mode 100644 index c2b7fad9528b..000000000000 --- a/lib/memdebug.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef HEADER_CURL_MEMDEBUG_H -#define HEADER_CURL_MEMDEBUG_H -/*************************************************************************** - * _ _ ____ _ - * Project ___| | | | _ \| | - * / __| | | | |_) | | - * | (__| |_| | _ <| |___ - * \___|\___/|_| \_\_____| - * - * Copyright (C) Daniel Stenberg, , et al. - * - * This software is licensed as described in the 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. - * - * SPDX-License-Identifier: curl - * - ***************************************************************************/ - -/* - * CAUTION: this header is designed to work when included by the app-side - * as well as the library. Do not mix with library internals! - */ - -#ifdef CURLDEBUG - -/* Set this symbol on the command-line, recompile all lib-sources */ -#undef strdup -#define strdup(ptr) curl_dbg_strdup(ptr, __LINE__, __FILE__) -#undef malloc -#define malloc(size) curl_dbg_malloc(size, __LINE__, __FILE__) -#undef calloc -#define calloc(nbelem,size) curl_dbg_calloc(nbelem, size, __LINE__, __FILE__) -#undef realloc -#define realloc(ptr,size) curl_dbg_realloc(ptr, size, __LINE__, __FILE__) -#undef free -#define free(ptr) curl_dbg_free(ptr, __LINE__, __FILE__) - -#ifdef _WIN32 -#undef Curl_tcsdup -#ifdef UNICODE -#define Curl_tcsdup(ptr) curl_dbg_wcsdup(ptr, __LINE__, __FILE__) -#else -#define Curl_tcsdup(ptr) curl_dbg_strdup(ptr, __LINE__, __FILE__) -#endif -#endif /* _WIN32 */ - -#endif /* CURLDEBUG */ -#endif /* HEADER_CURL_MEMDEBUG_H */ diff --git a/lib/mime.c b/lib/mime.c index b1f432c0b044..7ebe47315de9 100644 --- a/lib/mime.c +++ b/lib/mime.c @@ -50,10 +50,6 @@ struct Curl_easy; #include "slist.h" #include "curlx/dynbuf.h" -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - #ifdef _WIN32 # ifndef R_OK # define R_OK 4 @@ -357,13 +353,13 @@ static char *strippath(const char *fullfile) { char *filename; char *base; - filename = strdup(fullfile); /* duplicate since basename() may ruin the - buffer it works on */ + filename = curlx_strdup(fullfile); /* duplicate since basename() may ruin + the buffer it works on */ if(!filename) return NULL; - base = strdup(basename(filename)); + base = curlx_strdup(basename(filename)); - free(filename); /* free temporary buffer */ + curlx_free(filename); /* free temporary buffer */ return base; /* returns an allocated string or NULL ! */ } @@ -1190,9 +1186,9 @@ void curl_mime_free(curl_mime *mime) part = mime->firstpart; mime->firstpart = part->nextpart; Curl_mime_cleanpart(part); - free(part); + curlx_free(part); } - free(mime); + curlx_free(mime); } } @@ -1282,7 +1278,7 @@ curl_mime *curl_mime_init(void *easy) { curl_mime *mime; - mime = (curl_mime *) malloc(sizeof(*mime)); + mime = (curl_mime *)curlx_malloc(sizeof(*mime)); if(mime) { mime->parent = NULL; @@ -1294,7 +1290,7 @@ curl_mime *curl_mime_init(void *easy) (unsigned char *) &mime->boundary[MIME_BOUNDARY_DASHES], MIME_RAND_BOUNDARY_CHARS + 1)) { /* failed to get random separator, bail out */ - free(mime); + curlx_free(mime); return NULL; } mimesetstate(&mime->state, MIMESTATE_BEGIN, NULL); @@ -1319,7 +1315,7 @@ curl_mimepart *curl_mime_addpart(curl_mime *mime) if(!mime) return NULL; - part = (curl_mimepart *) malloc(sizeof(*part)); + part = (curl_mimepart *)curlx_malloc(sizeof(*part)); if(part) { Curl_mime_initpart(part); @@ -1345,7 +1341,7 @@ CURLcode curl_mime_name(curl_mimepart *part, const char *name) Curl_safefree(part->name); if(name) { - part->name = strdup(name); + part->name = curlx_strdup(name); if(!part->name) return CURLE_OUT_OF_MEMORY; } @@ -1362,7 +1358,7 @@ CURLcode curl_mime_filename(curl_mimepart *part, const char *filename) Curl_safefree(part->filename); if(filename) { - part->filename = strdup(filename); + part->filename = curlx_strdup(filename); if(!part->filename) return CURLE_OUT_OF_MEMORY; } @@ -1415,7 +1411,7 @@ CURLcode curl_mime_filedata(curl_mimepart *part, const char *filename) if(curlx_stat(filename, &sbuf)) result = CURLE_READ_ERROR; else { - part->data = strdup(filename); + part->data = curlx_strdup(filename); if(!part->data) result = CURLE_OUT_OF_MEMORY; else { @@ -1438,7 +1434,7 @@ CURLcode curl_mime_filedata(curl_mimepart *part, const char *filename) result = CURLE_OUT_OF_MEMORY; else { result = curl_mime_filename(part, base); - free(base); + curlx_free(base); } } } @@ -1455,7 +1451,7 @@ CURLcode curl_mime_type(curl_mimepart *part, const char *mimetype) Curl_safefree(part->mimetype); if(mimetype) { - part->mimetype = strdup(mimetype); + part->mimetype = curlx_strdup(mimetype); if(!part->mimetype) return CURLE_OUT_OF_MEMORY; } @@ -1696,7 +1692,7 @@ CURLcode Curl_mime_add_header(struct curl_slist **slp, const char *fmt, ...) if(hdr) *slp = hdr; else - free(s); + curlx_free(s); } return hdr ? CURLE_OK : CURLE_OUT_OF_MEMORY; diff --git a/lib/mprintf.c b/lib/mprintf.c index 176f8a3e4b78..046917aeb5f0 100644 --- a/lib/mprintf.c +++ b/lib/mprintf.c @@ -27,10 +27,6 @@ #include "curl_printf.h" #include "curlx/strparse.h" -#include "curl_memory.h" -/* The last #include file should be: */ -#include "memdebug.h" - #ifdef HAVE_LONGLONG # define LONG_LONG_TYPE long long # define HAVE_LONG_LONG_TYPE @@ -1177,7 +1173,7 @@ char *curl_mvaprintf(const char *format, va_list ap_save) } if(curlx_dyn_len(info.b)) return curlx_dyn_ptr(info.b); - return strdup(""); + return curlx_strdup(""); } char *curl_maprintf(const char *format, ...) diff --git a/lib/mqtt.c b/lib/mqtt.c index 9cbe800ded8e..a8975d53919b 100644 --- a/lib/mqtt.c +++ b/lib/mqtt.c @@ -40,10 +40,6 @@ #include "multiif.h" #include "rand.h" -/* The last 2 #includes file should be: */ -#include "curl_memory.h" -#include "memdebug.h" - /* first byte is command. second byte is for flags. */ #define MQTT_MSG_CONNECT 0x10 @@ -146,14 +142,14 @@ static void mqtt_easy_dtor(void *key, size_t klen, void *entry) (void)klen; curlx_dyn_free(&mq->sendbuf); curlx_dyn_free(&mq->recvbuf); - free(mq); + curlx_free(mq); } static void mqtt_conn_dtor(void *key, size_t klen, void *entry) { (void)key; (void)klen; - free(entry); + curlx_free(entry); } static CURLcode mqtt_setup_conn(struct Curl_easy *data, @@ -163,12 +159,12 @@ static CURLcode mqtt_setup_conn(struct Curl_easy *data, struct mqtt_conn *mqtt; struct MQTT *mq; - mqtt = calloc(1, sizeof(*mqtt)); + mqtt = curlx_calloc(1, sizeof(*mqtt)); if(!mqtt || Curl_conn_meta_set(conn, CURL_META_MQTT_CONN, mqtt, mqtt_conn_dtor)) return CURLE_OUT_OF_MEMORY; - mq = calloc(1, sizeof(struct MQTT)); + mq = curlx_calloc(1, sizeof(struct MQTT)); if(!mq) return CURLE_OUT_OF_MEMORY; curlx_dyn_init(&mq->recvbuf, DYN_MQTT_RECV); @@ -350,7 +346,7 @@ static CURLcode mqtt_connect(struct Curl_easy *data) /* allocating packet */ if(packetlen > 0xFFFFFFF) return CURLE_WEIRD_SERVER_REPLY; - packet = calloc(1, packetlen); + packet = curlx_calloc(1, packetlen); if(!packet) return CURLE_OUT_OF_MEMORY; @@ -400,7 +396,7 @@ static CURLcode mqtt_connect(struct Curl_easy *data) end: if(packet) - free(packet); + curlx_free(packet); Curl_safefree(data->state.aptr.user); Curl_safefree(data->state.aptr.passwd); return result; @@ -524,7 +520,7 @@ static CURLcode mqtt_subscribe(struct Curl_easy *data) n = mqtt_encode_len((char *)encodedsize, packetlen); packetlen += n + 1; /* add one for the control packet type byte */ - packet = malloc(packetlen); + packet = curlx_malloc(packetlen); if(!packet) { result = CURLE_OUT_OF_MEMORY; goto fail; @@ -542,8 +538,8 @@ static CURLcode mqtt_subscribe(struct Curl_easy *data) result = mqtt_send(data, (const char *)packet, packetlen); fail: - free(topic); - free(packet); + curlx_free(topic); + curlx_free(packet); return result; } @@ -620,7 +616,7 @@ static CURLcode mqtt_publish(struct Curl_easy *data) } /* add the control byte and the encoded remaining length */ - pkt = malloc(remaininglength + 1 + encodelen); + pkt = curlx_malloc(remaininglength + 1 + encodelen); if(!pkt) { result = CURLE_OUT_OF_MEMORY; goto fail; @@ -639,8 +635,8 @@ static CURLcode mqtt_publish(struct Curl_easy *data) result = mqtt_send(data, (const char *)pkt, i); fail: - free(pkt); - free(topic); + curlx_free(pkt); + curlx_free(topic); return result; } diff --git a/lib/multi.c b/lib/multi.c index f7265a94a9ec..c5b78f53e446 100644 --- a/lib/multi.c +++ b/lib/multi.c @@ -54,10 +54,6 @@ #include "socks.h" #include "urlapi-int.h" -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - /* initial multi->xfers table size for a full multi */ #define CURL_XFER_TABLE_SIZE 512 @@ -235,7 +231,7 @@ struct Curl_multi *Curl_multi_handle(uint32_t xfer_table_size, size_t dnssize, /* dns hash */ size_t sesssize) /* TLS session cache */ { - struct Curl_multi *multi = calloc(1, sizeof(struct Curl_multi)); + struct Curl_multi *multi = curlx_calloc(1, sizeof(struct Curl_multi)); if(!multi) return NULL; @@ -328,7 +324,7 @@ struct Curl_multi *Curl_multi_handle(uint32_t xfer_table_size, Curl_uint32_bset_destroy(&multi->msgsent); Curl_uint32_tbl_destroy(&multi->xfers); - free(multi); + curlx_free(multi); return NULL; } @@ -2022,7 +2018,7 @@ static CURLMcode state_performing(struct Curl_easy *data, data->state.errorbuf = FALSE; if(!newurl) /* typically for HTTP_1_1_REQUIRED error on first flight */ - newurl = strdup(data->state.url); + newurl = curlx_strdup(data->state.url); if(!newurl) { result = CURLE_OUT_OF_MEMORY; } @@ -2068,7 +2064,7 @@ static CURLMcode state_performing(struct Curl_easy *data, if(!retry) { /* if the URL is a follow-location and not just a retried request then figure out the URL here */ - free(newurl); + curlx_free(newurl); newurl = data->req.newurl; data->req.newurl = NULL; follow = FOLLOW_REDIR; @@ -2089,7 +2085,7 @@ static CURLMcode state_performing(struct Curl_easy *data, /* but first check to see if we got a location info even though we are not following redirects */ if(data->req.location) { - free(newurl); + curlx_free(newurl); newurl = data->req.location; data->req.location = NULL; result = multi_follow(data, handler, newurl, FOLLOW_FAKE); @@ -2109,7 +2105,7 @@ static CURLMcode state_performing(struct Curl_easy *data, *nowp = curlx_now(); mspeed_check(data, *nowp); } - free(newurl); + curlx_free(newurl); *resultp = result; return rc; } @@ -2237,7 +2233,7 @@ static CURLMcode state_do(struct Curl_easy *data, /* Have error handler disconnect conn if we cannot retry */ *stream_errorp = TRUE; } - free(newurl); + curlx_free(newurl); } else { /* failure detected */ @@ -2976,7 +2972,7 @@ CURLMcode curl_multi_cleanup(CURLM *m) Curl_uint32_bset_destroy(&multi->pending); Curl_uint32_bset_destroy(&multi->msgsent); Curl_uint32_tbl_destroy(&multi->xfers); - free(multi); + curlx_free(multi); return CURLM_OK; } @@ -3814,7 +3810,7 @@ CURL **curl_multi_get_handles(CURLM *m) struct Curl_multi *multi = m; void *entry; unsigned int count = Curl_uint32_tbl_count(&multi->xfers); - CURL **a = malloc(sizeof(struct Curl_easy *) * (count + 1)); + CURL **a = curlx_malloc(sizeof(struct Curl_easy *) * (count + 1)); if(a) { unsigned int i = 0, mid; @@ -3895,13 +3891,13 @@ CURLcode Curl_multi_xfer_buf_borrow(struct Curl_easy *data, if(data->multi->xfer_buf && data->set.buffer_size > data->multi->xfer_buf_len) { /* not large enough, get a new one */ - free(data->multi->xfer_buf); + curlx_free(data->multi->xfer_buf); data->multi->xfer_buf = NULL; data->multi->xfer_buf_len = 0; } if(!data->multi->xfer_buf) { - data->multi->xfer_buf = malloc(curlx_uitouz(data->set.buffer_size)); + data->multi->xfer_buf = curlx_malloc(curlx_uitouz(data->set.buffer_size)); if(!data->multi->xfer_buf) { failf(data, "could not allocate xfer_buf of %u bytes", data->set.buffer_size); @@ -3948,14 +3944,14 @@ CURLcode Curl_multi_xfer_ulbuf_borrow(struct Curl_easy *data, if(data->multi->xfer_ulbuf && data->set.upload_buffer_size > data->multi->xfer_ulbuf_len) { /* not large enough, get a new one */ - free(data->multi->xfer_ulbuf); + curlx_free(data->multi->xfer_ulbuf); data->multi->xfer_ulbuf = NULL; data->multi->xfer_ulbuf_len = 0; } if(!data->multi->xfer_ulbuf) { data->multi->xfer_ulbuf = - malloc(curlx_uitouz(data->set.upload_buffer_size)); + curlx_malloc(curlx_uitouz(data->set.upload_buffer_size)); if(!data->multi->xfer_ulbuf) { failf(data, "could not allocate xfer_ulbuf of %u bytes", data->set.upload_buffer_size); @@ -3996,13 +3992,13 @@ CURLcode Curl_multi_xfer_sockbuf_borrow(struct Curl_easy *data, if(data->multi->xfer_sockbuf && blen > data->multi->xfer_sockbuf_len) { /* not large enough, get a new one */ - free(data->multi->xfer_sockbuf); + curlx_free(data->multi->xfer_sockbuf); data->multi->xfer_sockbuf = NULL; data->multi->xfer_sockbuf_len = 0; } if(!data->multi->xfer_sockbuf) { - data->multi->xfer_sockbuf = malloc(blen); + data->multi->xfer_sockbuf = curlx_malloc(blen); if(!data->multi->xfer_sockbuf) { failf(data, "could not allocate xfer_sockbuf of %zu bytes", blen); return CURLE_OUT_OF_MEMORY; diff --git a/lib/multi_ev.c b/lib/multi_ev.c index d5db331cf1f1..026cbd29968e 100644 --- a/lib/multi_ev.c +++ b/lib/multi_ev.c @@ -41,10 +41,6 @@ #include "multihandle.h" #include "socks.h" -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - static void mev_in_callback(struct Curl_multi *multi, bool value) { @@ -85,7 +81,7 @@ static void mev_sh_entry_dtor(void *freethis) { struct mev_sh_entry *entry = (struct mev_sh_entry *)freethis; Curl_uint32_spbset_destroy(&entry->xfers); - free(entry); + curlx_free(entry); } /* look up a given socket in the socket hash, skip invalid sockets */ @@ -112,7 +108,7 @@ mev_sh_entry_add(struct Curl_hash *sh, curl_socket_t s) } /* not present, add it */ - check = calloc(1, sizeof(struct mev_sh_entry)); + check = curlx_calloc(1, sizeof(struct mev_sh_entry)); if(!check) return NULL; /* major failure */ @@ -446,7 +442,7 @@ static void mev_pollset_dtor(void *key, size_t klen, void *entry) (void)klen; if(ps) { Curl_pollset_cleanup(ps); - free(ps); + curlx_free(ps); } } diff --git a/lib/multi_ntfy.c b/lib/multi_ntfy.c index d7913bbbfc97..43e4db9e8270 100644 --- a/lib/multi_ntfy.c +++ b/lib/multi_ntfy.c @@ -32,11 +32,6 @@ #include "multiif.h" #include "multi_ntfy.h" -/* The last 3 #include files should be in this order */ -#include "curl_printf.h" -#include "curl_memory.h" -#include "memdebug.h" - struct mntfy_entry { uint32_t mid; @@ -54,12 +49,12 @@ struct mntfy_chunk { static struct mntfy_chunk *mnfty_chunk_create(void) { - return calloc(1, sizeof(struct mntfy_chunk)); + return curlx_calloc(1, sizeof(struct mntfy_chunk)); } static void mnfty_chunk_destroy(struct mntfy_chunk *chunk) { - free(chunk); + curlx_free(chunk); } static void mnfty_chunk_reset(struct mntfy_chunk *chunk) diff --git a/lib/netrc.c b/lib/netrc.c index 9c5c6c7f20c8..f8de4082972c 100644 --- a/lib/netrc.c +++ b/lib/netrc.c @@ -42,10 +42,6 @@ #include "curlx/fopen.h" #include "curlx/strparse.h" -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - /* Get user and password from .netrc when given a machine name */ enum host_lookup_state { @@ -277,8 +273,8 @@ static NETRCcode parsenetrc(struct store_netrc *store, our_login = !Curl_timestrcmp(login, tok); else { our_login = TRUE; - free(login); - login = strdup(tok); + curlx_free(login); + login = curlx_strdup(tok); if(!login) { retcode = NETRC_OUT_OF_MEMORY; /* allocation failed */ goto out; @@ -288,8 +284,8 @@ static NETRCcode parsenetrc(struct store_netrc *store, keyword = NONE; } else if(keyword == PASSWORD) { - free(password); - password = strdup(tok); + curlx_free(password); + password = curlx_strdup(tok); if(!password) { retcode = NETRC_OUT_OF_MEMORY; /* allocation failed */ goto out; @@ -346,7 +342,7 @@ static NETRCcode parsenetrc(struct store_netrc *store, if(!retcode) { if(!password && our_login) { /* success without a password, set a blank one */ - password = strdup(""); + password = curlx_strdup(""); if(!password) retcode = NETRC_OUT_OF_MEMORY; /* out of memory */ } @@ -364,8 +360,8 @@ static NETRCcode parsenetrc(struct store_netrc *store, curlx_dyn_free(filebuf); store->loaded = FALSE; if(!specific_login) - free(login); - free(password); + curlx_free(login); + curlx_free(password); } return retcode; @@ -444,25 +440,25 @@ NETRCcode Curl_parsenetrc(struct store_netrc *store, const char *host, filealloc = curl_maprintf("%s%s.netrc", home, DIR_CHAR); if(!filealloc) { - free(homea); + curlx_free(homea); return NETRC_OUT_OF_MEMORY; } } retcode = parsenetrc(store, host, loginp, passwordp, filealloc); - free(filealloc); + curlx_free(filealloc); #ifdef _WIN32 if(retcode == NETRC_FILE_MISSING) { /* fallback to the old-style "_netrc" file */ filealloc = curl_maprintf("%s%s_netrc", home, DIR_CHAR); if(!filealloc) { - free(homea); + curlx_free(homea); return NETRC_OUT_OF_MEMORY; } retcode = parsenetrc(store, host, loginp, passwordp, filealloc); - free(filealloc); + curlx_free(filealloc); } #endif - free(homea); + curlx_free(homea); } else retcode = parsenetrc(store, host, loginp, passwordp, netrcfile); diff --git a/lib/openldap.c b/lib/openldap.c index 806ccb33ccd1..107f6da832a5 100644 --- a/lib/openldap.c +++ b/lib/openldap.c @@ -53,10 +53,6 @@ #include "curl_sasl.h" #include "strcase.h" -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - /* * Uncommenting this will enable the built-in debug logging of the openldap * library. The debug log level can be set using the CURL_OPENLDAP_TRACE @@ -577,7 +573,7 @@ static void oldap_easy_dtor(void *key, size_t klen, void *entry) struct ldapreqinfo *lr = entry; (void)key; (void)klen; - free(lr); + curlx_free(lr); } static void oldap_conn_dtor(void *key, size_t klen, void *entry) @@ -589,7 +585,7 @@ static void oldap_conn_dtor(void *key, size_t klen, void *entry) ldap_unbind_ext(li->ld, NULL, NULL); li->ld = NULL; } - free(li); + curlx_free(li); } static CURLcode oldap_connect(struct Curl_easy *data, bool *done) @@ -606,7 +602,7 @@ static CURLcode oldap_connect(struct Curl_easy *data, bool *done) (void)done; - li = calloc(1, sizeof(struct ldapconninfo)); + li = curlx_calloc(1, sizeof(struct ldapconninfo)); if(!li) { result = CURLE_OUT_OF_MEMORY; goto out; @@ -697,7 +693,7 @@ static CURLcode oldap_connect(struct Curl_easy *data, bool *done) result = oldap_perform_bind(data, OLDAP_BIND); out: - free(hosturl); + curlx_free(hosturl); return result; } @@ -1023,7 +1019,7 @@ static CURLcode oldap_do(struct Curl_easy *data, bool *done) goto out; } - lr = calloc(1, sizeof(struct ldapreqinfo)); + lr = curlx_calloc(1, sizeof(struct ldapreqinfo)); if(!lr || Curl_meta_set(data, CURL_META_LDAP_EASY, lr, oldap_easy_dtor)) { ldap_abandon_ext(li->ld, msgid, NULL, NULL); @@ -1219,7 +1215,7 @@ static CURLcode oldap_recv(struct Curl_easy *data, int sockindex, char *buf, if(!result) result = client_write(data, STRCONST(": "), val_b64, val_b64_sz, STRCONST("\n")); - free(val_b64); + curlx_free(val_b64); } else result = client_write(data, STRCONST(" "), diff --git a/lib/pingpong.c b/lib/pingpong.c index 297389043f0e..7ac321af7244 100644 --- a/lib/pingpong.c +++ b/lib/pingpong.c @@ -37,10 +37,6 @@ #include "multiif.h" #include "vtls/vtls.h" -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - #ifdef USE_PINGPONG /* Returns timeout in ms. 0 or negative number means the timeout has already diff --git a/lib/pop3.c b/lib/pop3.c index 503f4ecb2bd5..f10108229b6a 100644 --- a/lib/pop3.c +++ b/lib/pop3.c @@ -78,10 +78,6 @@ #include "curlx/warnless.h" #include "strdup.h" -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - /* Authentication type flags */ #define POP3_TYPE_CLEARTEXT (1 << 0) #define POP3_TYPE_APOP (1 << 1) @@ -1523,7 +1519,7 @@ static void pop3_easy_dtor(void *key, size_t klen, void *entry) /* Cleanup our per-request based variables */ Curl_safefree(pop3->id); Curl_safefree(pop3->custom); - free(pop3); + curlx_free(pop3); } static void pop3_conn_dtor(void *key, size_t klen, void *entry) @@ -1534,19 +1530,19 @@ static void pop3_conn_dtor(void *key, size_t klen, void *entry) DEBUGASSERT(pop3c); Curl_pp_disconnect(&pop3c->pp); Curl_safefree(pop3c->apoptimestamp); - free(pop3c); + curlx_free(pop3c); } static CURLcode pop3_setup_connection(struct Curl_easy *data, struct connectdata *conn) { struct pop3_conn *pop3c; - struct POP3 *pop3 = calloc(1, sizeof(*pop3)); + struct POP3 *pop3 = curlx_calloc(1, sizeof(*pop3)); if(!pop3 || Curl_meta_set(data, CURL_META_POP3_EASY, pop3, pop3_easy_dtor)) return CURLE_OUT_OF_MEMORY; - pop3c = calloc(1, sizeof(*pop3c)); + pop3c = curlx_calloc(1, sizeof(*pop3c)); if(!pop3c || Curl_conn_meta_set(conn, CURL_META_POP3_CONN, pop3c, pop3_conn_dtor)) return CURLE_OUT_OF_MEMORY; diff --git a/lib/psl.c b/lib/psl.c index f645763d063b..5bf96d09bd88 100644 --- a/lib/psl.c +++ b/lib/psl.c @@ -31,10 +31,6 @@ #include "psl.h" #include "curl_share.h" -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - void Curl_psl_destroy(struct PslCache *pslcache) { if(pslcache->psl) { diff --git a/lib/rand.c b/lib/rand.c index 5eace0283349..8c5a2cf71e44 100644 --- a/lib/rand.c +++ b/lib/rand.c @@ -38,10 +38,6 @@ #include "rand.h" #include "escape.h" -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - #ifdef _WIN32 #if defined(_WIN32_WINNT) && _WIN32_WINNT >= _WIN32_WINNT_VISTA && \ diff --git a/lib/rename.c b/lib/rename.c index 911afca57563..d3f80422e641 100644 --- a/lib/rename.c +++ b/lib/rename.c @@ -32,10 +32,6 @@ #include "curlx/multibyte.h" #include "curlx/timeval.h" -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - /* return 0 on success, 1 on error */ int Curl_rename(const char *oldpath, const char *newpath) { diff --git a/lib/request.c b/lib/request.c index 324c4c48f96d..581d7d14537a 100644 --- a/lib/request.c +++ b/lib/request.c @@ -36,10 +36,6 @@ #include "url.h" #include "curlx/strparse.h" -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - void Curl_req_init(struct SingleRequest *req) { memset(req, 0, sizeof(*req)); diff --git a/lib/rtsp.c b/lib/rtsp.c index dd49ebc42b4d..5a46dc62c407 100644 --- a/lib/rtsp.c +++ b/lib/rtsp.c @@ -42,10 +42,6 @@ #include "strdup.h" #include "curlx/strparse.h" -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - /* meta key for storing protocol meta at easy handle */ #define CURL_META_RTSP_EASY "meta:proto:rtsp:easy" @@ -162,7 +158,7 @@ static void rtsp_easy_dtor(void *key, size_t klen, void *entry) struct RTSP *rtsp = entry; (void)key; (void)klen; - free(rtsp); + curlx_free(rtsp); } static void rtsp_conn_dtor(void *key, size_t klen, void *entry) @@ -171,7 +167,7 @@ static void rtsp_conn_dtor(void *key, size_t klen, void *entry) (void)key; (void)klen; curlx_dyn_free(&rtspc->buf); - free(rtspc); + curlx_free(rtspc); } static CURLcode rtsp_setup_connection(struct Curl_easy *data, @@ -180,14 +176,14 @@ static CURLcode rtsp_setup_connection(struct Curl_easy *data, struct rtsp_conn *rtspc; struct RTSP *rtsp; - rtspc = calloc(1, sizeof(*rtspc)); + rtspc = curlx_calloc(1, sizeof(*rtspc)); if(!rtspc) return CURLE_OUT_OF_MEMORY; curlx_dyn_init(&rtspc->buf, MAX_RTP_BUFFERSIZE); if(Curl_conn_meta_set(conn, CURL_META_RTSP_CONN, rtspc, rtsp_conn_dtor)) return CURLE_OUT_OF_MEMORY; - rtsp = calloc(1, sizeof(struct RTSP)); + rtsp = curlx_calloc(1, sizeof(struct RTSP)); if(!rtsp || Curl_meta_set(data, CURL_META_RTSP_EASY, rtsp, rtsp_easy_dtor)) return CURLE_OUT_OF_MEMORY; @@ -392,7 +388,7 @@ static CURLcode rtsp_do(struct Curl_easy *data, bool *done) to this origin */ if(!data->state.first_host) { - data->state.first_host = strdup(conn->host.name); + data->state.first_host = curlx_strdup(conn->host.name); if(!data->state.first_host) return CURLE_OUT_OF_MEMORY; @@ -481,7 +477,7 @@ static CURLcode rtsp_do(struct Curl_easy *data, bool *done) if(rtspreq == RTSPREQ_SETUP && !p_transport) { /* New Transport: setting? */ if(data->set.str[STRING_RTSP_TRANSPORT]) { - free(data->state.aptr.rtsp_transport); + curlx_free(data->state.aptr.rtsp_transport); data->state.aptr.rtsp_transport = curl_maprintf("Transport: %s\r\n", data->set.str[STRING_RTSP_TRANSPORT]); @@ -507,7 +503,7 @@ static CURLcode rtsp_do(struct Curl_easy *data, bool *done) /* Accept-Encoding header */ if(!Curl_checkheaders(data, STRCONST("Accept-Encoding")) && data->set.str[STRING_ENCODING]) { - free(data->state.aptr.accept_encoding); + curlx_free(data->state.aptr.accept_encoding); data->state.aptr.accept_encoding = curl_maprintf("Accept-Encoding: %s\r\n", data->set.str[STRING_ENCODING]); @@ -563,7 +559,7 @@ static CURLcode rtsp_do(struct Curl_easy *data, bool *done) /* Check to see if there is a range set in the custom headers */ if(!Curl_checkheaders(data, STRCONST("Range")) && data->state.range) { - free(data->state.aptr.rangeline); + curlx_free(data->state.aptr.rangeline); data->state.aptr.rangeline = curl_maprintf("Range: %s\r\n", data->state.range); p_range = data->state.aptr.rangeline; diff --git a/lib/select.c b/lib/select.c index 041733973e9e..5692fc020d1f 100644 --- a/lib/select.c +++ b/lib/select.c @@ -46,10 +46,6 @@ #include "curlx/wait.h" #include "curlx/warnless.h" -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - #ifndef HAVE_POLL /* * This is a wrapper around select() to aid in Windows compatibility. A @@ -364,7 +360,7 @@ void Curl_pollfds_cleanup(struct curl_pollfds *cpfds) { DEBUGASSERT(cpfds); if(cpfds->allocated_pfds) { - free(cpfds->pfds); + curlx_free(cpfds->pfds); } memset(cpfds, 0, sizeof(*cpfds)); } @@ -374,13 +370,13 @@ static CURLcode cpfds_increase(struct curl_pollfds *cpfds, unsigned int inc) struct pollfd *new_fds; unsigned int new_count = cpfds->count + inc; - new_fds = calloc(new_count, sizeof(struct pollfd)); + new_fds = curlx_calloc(new_count, sizeof(struct pollfd)); if(!new_fds) return CURLE_OUT_OF_MEMORY; memcpy(new_fds, cpfds->pfds, cpfds->count * sizeof(struct pollfd)); if(cpfds->allocated_pfds) - free(cpfds->pfds); + curlx_free(cpfds->pfds); cpfds->pfds = new_fds; cpfds->count = new_count; cpfds->allocated_pfds = TRUE; @@ -521,7 +517,7 @@ void Curl_pollset_init(struct easy_pollset *ps) struct easy_pollset *Curl_pollset_create(void) { - struct easy_pollset *ps = calloc(1, sizeof(*ps)); + struct easy_pollset *ps = curlx_calloc(1, sizeof(*ps)); if(ps) Curl_pollset_init(ps); return ps; @@ -533,11 +529,11 @@ void Curl_pollset_cleanup(struct easy_pollset *ps) DEBUGASSERT(ps->init == CURL_EASY_POLLSET_MAGIC); #endif if(ps->sockets != ps->def_sockets) { - free(ps->sockets); + curlx_free(ps->sockets); ps->sockets = ps->def_sockets; } if(ps->actions != ps->def_actions) { - free(ps->actions); + curlx_free(ps->actions); ps->actions = ps->def_actions; } ps->count = CURL_ARRAYSIZE(ps->def_sockets); @@ -614,21 +610,21 @@ CURLcode Curl_pollset_change(struct Curl_easy *data, ps->count, new_count); if(new_count <= ps->count) return CURLE_OUT_OF_MEMORY; - nsockets = calloc(new_count, sizeof(nsockets[0])); + nsockets = curlx_calloc(new_count, sizeof(nsockets[0])); if(!nsockets) return CURLE_OUT_OF_MEMORY; - nactions = calloc(new_count, sizeof(nactions[0])); + nactions = curlx_calloc(new_count, sizeof(nactions[0])); if(!nactions) { - free(nsockets); + curlx_free(nsockets); return CURLE_OUT_OF_MEMORY; } memcpy(nsockets, ps->sockets, ps->count * sizeof(ps->sockets[0])); memcpy(nactions, ps->actions, ps->count * sizeof(ps->actions[0])); if(ps->sockets != ps->def_sockets) - free(ps->sockets); + curlx_free(ps->sockets); ps->sockets = nsockets; if(ps->actions != ps->def_actions) - free(ps->actions); + curlx_free(ps->actions); ps->actions = nactions; ps->count = new_count; } @@ -668,7 +664,7 @@ int Curl_pollset_poll(struct Curl_easy *data, if(!ps->n) return curlx_wait_ms(timeout_ms); - pfds = calloc(ps->n, sizeof(*pfds)); + pfds = curlx_calloc(ps->n, sizeof(*pfds)); if(!pfds) return -1; @@ -689,7 +685,7 @@ int Curl_pollset_poll(struct Curl_easy *data, } result = Curl_poll(pfds, npfds, timeout_ms); - free(pfds); + curlx_free(pfds); return result; } diff --git a/lib/sendf.c b/lib/sendf.c index 6731cd874b6b..1d73291c92d2 100644 --- a/lib/sendf.c +++ b/lib/sendf.c @@ -55,10 +55,6 @@ #include "curlx/warnless.h" #include "ws.h" -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - static CURLcode do_init_writer_stack(struct Curl_easy *data); @@ -100,7 +96,7 @@ static void cl_reset_writer(struct Curl_easy *data) while(writer) { data->req.writer_stack = writer->next; writer->cwt->do_close(data, writer); - free(writer); + curlx_free(writer); writer = data->req.writer_stack; } } @@ -112,7 +108,7 @@ static void cl_reset_reader(struct Curl_easy *data) while(reader) { data->req.reader_stack = reader->next; reader->crt->do_close(data, reader); - free(reader); + curlx_free(reader); reader = data->req.reader_stack; } } @@ -374,7 +370,7 @@ CURLcode Curl_cwriter_create(struct Curl_cwriter **pwriter, void *p; DEBUGASSERT(cwt->cwriter_size >= sizeof(struct Curl_cwriter)); - p = calloc(1, cwt->cwriter_size); + p = curlx_calloc(1, cwt->cwriter_size); if(!p) goto out; @@ -387,7 +383,7 @@ CURLcode Curl_cwriter_create(struct Curl_cwriter **pwriter, out: *pwriter = result ? NULL : writer; if(result) - free(writer); + curlx_free(writer); return result; } @@ -396,7 +392,7 @@ void Curl_cwriter_free(struct Curl_easy *data, { if(writer) { writer->cwt->do_close(data, writer); - free(writer); + curlx_free(writer); } } @@ -938,7 +934,7 @@ CURLcode Curl_creader_create(struct Curl_creader **preader, void *p; DEBUGASSERT(crt->creader_size >= sizeof(struct Curl_creader)); - p = calloc(1, crt->creader_size); + p = curlx_calloc(1, crt->creader_size); if(!p) goto out; @@ -951,7 +947,7 @@ CURLcode Curl_creader_create(struct Curl_creader **preader, out: *preader = result ? NULL : reader; if(result) - free(reader); + curlx_free(reader); return result; } @@ -959,7 +955,7 @@ void Curl_creader_free(struct Curl_easy *data, struct Curl_creader *reader) { if(reader) { reader->crt->do_close(data, reader); - free(reader); + curlx_free(reader); } } diff --git a/lib/setopt.c b/lib/setopt.c index 36f447cdc5bb..b4ca361ce35f 100644 --- a/lib/setopt.c +++ b/lib/setopt.c @@ -55,10 +55,6 @@ #include "strdup.h" #include "escape.h" -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - static CURLcode setopt_set_timeout_sec(timediff_t *ptimeout_ms, long secs) { if(secs < 0) @@ -98,7 +94,7 @@ CURLcode Curl_setstropt(char **charp, const char *s) if(strlen(s) > CURL_MAX_INPUT_LENGTH) return CURLE_BAD_FUNCTION_ARGUMENT; - *charp = strdup(s); + *charp = curlx_strdup(s); if(!*charp) return CURLE_OUT_OF_MEMORY; } @@ -119,8 +115,8 @@ CURLcode Curl_setblobopt(struct curl_blob **blobp, 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)); + curlx_malloc(sizeof(struct curl_blob) + + ((blob->flags & CURL_BLOB_COPY) ? blob->len : 0)); if(!nblob) return CURLE_OUT_OF_MEMORY; *nblob = *blob; @@ -158,10 +154,10 @@ static CURLcode setstropt_userpwd(char *option, char **userp, char **passwdp) return result; } - free(*userp); + curlx_free(*userp); *userp = user; - free(*passwdp); + curlx_free(*passwdp); *passwdp = passwd; return CURLE_OK; @@ -185,13 +181,13 @@ static CURLcode setstropt_interface(char *option, char **devp, if(result) return result; } - free(*devp); + curlx_free(*devp); *devp = dev; - free(*ifacep); + curlx_free(*ifacep); *ifacep = iface; - free(*hostp); + curlx_free(*hostp); *hostp = host; return CURLE_OK; @@ -1706,7 +1702,7 @@ static CURLcode setopt_cptr(struct Curl_easy *data, CURLoption option, if(!p) return CURLE_OUT_OF_MEMORY; else { - free(s->str[STRING_COPYPOSTFIELDS]); + curlx_free(s->str[STRING_COPYPOSTFIELDS]); s->str[STRING_COPYPOSTFIELDS] = p; } } @@ -2040,8 +2036,8 @@ static CURLcode setopt_cptr(struct Curl_easy *data, CURLoption option, result = Curl_urldecode(p, 0, &s->str[STRING_PROXYPASSWORD], NULL, REJECT_ZERO); } - free(u); - free(p); + curlx_free(u); + curlx_free(p); } break; case CURLOPT_PROXYUSERNAME: diff --git a/lib/sha256.c b/lib/sha256.c index 3e3205e36bf3..977ad3edc402 100644 --- a/lib/sha256.c +++ b/lib/sha256.c @@ -59,10 +59,6 @@ #include #endif -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - /* Please keep the SSL backend-specific #if branches in this order: * * 1. USE_OPENSSL diff --git a/lib/slist.c b/lib/slist.c index 88fdd8a2bae2..469ee0ef3b5b 100644 --- a/lib/slist.c +++ b/lib/slist.c @@ -28,10 +28,6 @@ #include "slist.h" -/* The last #include files should be: */ -#include "curl_memory.h" -#include "memdebug.h" - /* returns last node in linked list */ static struct curl_slist *slist_get_last(struct curl_slist *list) { @@ -66,7 +62,7 @@ struct curl_slist *Curl_slist_append_nodup(struct curl_slist *list, DEBUGASSERT(data); - new_item = malloc(sizeof(struct curl_slist)); + new_item = curlx_malloc(sizeof(struct curl_slist)); if(!new_item) return NULL; @@ -92,14 +88,14 @@ struct curl_slist *Curl_slist_append_nodup(struct curl_slist *list, struct curl_slist *curl_slist_append(struct curl_slist *list, const char *data) { - char *dupdata = strdup(data); + char *dupdata = curlx_strdup(data); if(!dupdata) return NULL; list = Curl_slist_append_nodup(list, dupdata); if(!list) - free(dupdata); + curlx_free(dupdata); return list; } @@ -141,7 +137,7 @@ void curl_slist_free_all(struct curl_slist *list) do { next = item->next; Curl_safefree(item->data); - free(item); + curlx_free(item); item = next; } while(next); } diff --git a/lib/smb.c b/lib/smb.c index e5fca3ec0bef..338464961b21 100644 --- a/lib/smb.c +++ b/lib/smb.c @@ -42,10 +42,6 @@ #include "escape.h" #include "curl_endian.h" -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - /* meta key for storing protocol meta at easy handle */ #define CURL_META_SMB_EASY "meta:proto:smb:easy" @@ -451,7 +447,7 @@ static void smb_easy_dtor(void *key, size_t klen, void *entry) /* `req->path` points to somewhere in `struct smb_conn` which is * kept at the connection meta. If the connection is destroyed first, * req->path points to free'd memory. */ - free(req); + curlx_free(req); } static void smb_conn_dtor(void *key, size_t klen, void *entry) @@ -463,7 +459,7 @@ static void smb_conn_dtor(void *key, size_t klen, void *entry) Curl_safefree(smbc->domain); Curl_safefree(smbc->recv_buf); Curl_safefree(smbc->send_buf); - free(smbc); + curlx_free(smbc); } /* this should setup things in the connection, not in the easy @@ -475,13 +471,13 @@ static CURLcode smb_setup_connection(struct Curl_easy *data, struct smb_request *req; /* Initialize the connection state */ - smbc = calloc(1, sizeof(*smbc)); + smbc = curlx_calloc(1, sizeof(*smbc)); if(!smbc || Curl_conn_meta_set(conn, CURL_META_SMB_CONN, smbc, smb_conn_dtor)) return CURLE_OUT_OF_MEMORY; /* Initialize the request state */ - req = calloc(1, sizeof(*req)); + req = curlx_calloc(1, sizeof(*req)); if(!req || Curl_meta_set(data, CURL_META_SMB_EASY, req, smb_easy_dtor)) return CURLE_OUT_OF_MEMORY; @@ -506,10 +502,10 @@ static CURLcode smb_connect(struct Curl_easy *data, bool *done) /* Initialize the connection state */ smbc->state = SMB_CONNECTING; - smbc->recv_buf = malloc(MAX_MESSAGE_SIZE); + smbc->recv_buf = curlx_malloc(MAX_MESSAGE_SIZE); if(!smbc->recv_buf) return CURLE_OUT_OF_MEMORY; - smbc->send_buf = malloc(MAX_MESSAGE_SIZE); + smbc->send_buf = curlx_malloc(MAX_MESSAGE_SIZE); if(!smbc->send_buf) return CURLE_OUT_OF_MEMORY; @@ -520,14 +516,14 @@ static CURLcode smb_connect(struct Curl_easy *data, bool *done) if(slash) { smbc->user = slash + 1; - smbc->domain = strdup(conn->user); + smbc->domain = curlx_strdup(conn->user); if(!smbc->domain) return CURLE_OUT_OF_MEMORY; smbc->domain[slash - conn->user] = 0; } else { smbc->user = conn->user; - smbc->domain = strdup(conn->host.name); + smbc->domain = curlx_strdup(conn->host.name); if(!smbc->domain) return CURLE_OUT_OF_MEMORY; } @@ -1246,8 +1242,9 @@ static CURLcode smb_parse_url_path(struct Curl_easy *data, return result; /* Parse the path for the share */ - smbc->share = strdup((*path == '/' || *path == '\\') ? path + 1 : path); - free(path); + smbc->share = curlx_strdup((*path == '/' || *path == '\\') + ? path + 1 : path); + curlx_free(path); if(!smbc->share) return CURLE_OUT_OF_MEMORY; diff --git a/lib/smtp.c b/lib/smtp.c index eca27f146525..55a15b36c08d 100644 --- a/lib/smtp.c +++ b/lib/smtp.c @@ -81,10 +81,6 @@ #include "idn.h" #include "curlx/strparse.h" -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - /* meta key for storing protocol meta at easy handle */ #define CURL_META_SMTP_EASY "meta:proto:smtp:easy" /* meta key for storing protocol meta at connection */ @@ -646,7 +642,7 @@ static CURLcode smtp_perform_command(struct Curl_easy *data, utf8 ? " SMTPUTF8" : ""); Curl_free_idnconverted_hostname(&host); - free(address); + curlx_free(address); } else { /* Establish whether we should report that we support SMTPUTF8 for EXPN @@ -722,11 +718,11 @@ static CURLcode smtp_perform_mail(struct Curl_easy *data, worry about that and reply with a 501 error */ from = curl_maprintf("<%s>%s", address, suffix); - free(address); + curlx_free(address); } else /* Null reverse-path, RFC-5321, sect. 3.6.3 */ - from = strdup("<>"); + from = curlx_strdup("<>"); if(!from) { result = CURLE_OUT_OF_MEMORY; @@ -763,11 +759,11 @@ static CURLcode smtp_perform_mail(struct Curl_easy *data, /* An invalid mailbox was provided but we will simply let the server worry about it */ auth = curl_maprintf("<%s>%s", address, suffix); - free(address); + curlx_free(address); } else /* Empty AUTH, RFC-2554, sect. 5 */ - auth = strdup("<>"); + auth = curlx_strdup("<>"); if(!auth) { result = CURLE_OUT_OF_MEMORY; @@ -848,9 +844,9 @@ static CURLcode smtp_perform_mail(struct Curl_easy *data, : ""); /* included in our envelope */ out: - free(from); - free(auth); - free(size); + curlx_free(from); + curlx_free(auth); + curlx_free(size); if(!result) smtp_state(data, smtpc, SMTP_MAIL); @@ -892,7 +888,7 @@ static CURLcode smtp_perform_rcpt_to(struct Curl_easy *data, address, suffix); Curl_free_idnconverted_hostname(&host); - free(address); + curlx_free(address); if(!result) smtp_state(data, smtpc, SMTP_RCPT); @@ -1716,7 +1712,7 @@ static void smtp_easy_dtor(void *key, size_t klen, void *entry) struct SMTP *smtp = entry; (void)key; (void)klen; - free(smtp); + curlx_free(smtp); } static void smtp_conn_dtor(void *key, size_t klen, void *entry) @@ -1726,7 +1722,7 @@ static void smtp_conn_dtor(void *key, size_t klen, void *entry) (void)klen; Curl_pp_disconnect(&smtpc->pp); Curl_safefree(smtpc->domain); - free(smtpc); + curlx_free(smtpc); } static CURLcode smtp_setup_connection(struct Curl_easy *data, @@ -1736,14 +1732,14 @@ static CURLcode smtp_setup_connection(struct Curl_easy *data, struct SMTP *smtp; CURLcode result = CURLE_OK; - smtpc = calloc(1, sizeof(*smtpc)); + smtpc = curlx_calloc(1, sizeof(*smtpc)); if(!smtpc || Curl_conn_meta_set(conn, CURL_META_SMTP_CONN, smtpc, smtp_conn_dtor)) { result = CURLE_OUT_OF_MEMORY; goto out; } - smtp = calloc(1, sizeof(*smtp)); + smtp = curlx_calloc(1, sizeof(*smtp)); if(!smtp || Curl_meta_set(data, CURL_META_SMTP_EASY, smtp, smtp_easy_dtor)) result = CURLE_OUT_OF_MEMORY; @@ -1877,7 +1873,7 @@ static CURLcode smtp_parse_address(const char *fqma, char **address, /* Duplicate the fully qualified email address so we can manipulate it, ensuring it does not contain the delimiters if specified */ - char *dup = strdup(fqma[0] == '<' ? fqma + 1 : fqma); + char *dup = curlx_strdup(fqma[0] == '<' ? fqma + 1 : fqma); if(!dup) return CURLE_OUT_OF_MEMORY; diff --git a/lib/socketpair.c b/lib/socketpair.c index 08753c8a8c21..0b6111204446 100644 --- a/lib/socketpair.c +++ b/lib/socketpair.c @@ -134,10 +134,6 @@ int Curl_socketpair(int domain, int type, int protocol, #include "curlx/timeval.h" /* needed before select.h */ #include "select.h" /* for Curl_poll */ -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - int Curl_socketpair(int domain, int type, int protocol, curl_socket_t socks[2], bool nonblocking) { diff --git a/lib/socks.c b/lib/socks.c index 3434030c839f..7160dd150698 100644 --- a/lib/socks.c +++ b/lib/socks.c @@ -45,10 +45,6 @@ #include "curlx/inet_pton.h" #include "url.h" -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - #if defined(DEBUGBUILD) && !defined(CURL_DISABLE_VERBOSE_STRINGS) #define DEBUG_AND_VERBOSE #endif @@ -1215,7 +1211,7 @@ static void socks_proxy_cf_free(struct Curl_cfilter *cf) struct socks_state *sxstate = cf->ctx; if(sxstate) { Curl_bufq_free(&sxstate->iobuf); - free(sxstate); + curlx_free(sxstate); cf->ctx = NULL; } } @@ -1247,7 +1243,7 @@ static CURLcode socks_proxy_cf_connect(struct Curl_cfilter *cf, return result; if(!sx) { - cf->ctx = sx = calloc(1, sizeof(*sx)); + cf->ctx = sx = curlx_calloc(1, sizeof(*sx)); if(!sx) { result = CURLE_OUT_OF_MEMORY; goto out; diff --git a/lib/socks_gssapi.c b/lib/socks_gssapi.c index 61c88be60528..6f8a90139ded 100644 --- a/lib/socks_gssapi.c +++ b/lib/socks_gssapi.c @@ -37,10 +37,6 @@ #include "curlx/warnless.h" #include "strdup.h" -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - #if defined(__GNUC__) && defined(__APPLE__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wdeprecated-declarations" @@ -151,8 +147,8 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(struct Curl_cfilter *cf, (gss_OID) GSS_C_NULL_OID, &server); } else { - service.value = malloc(serviceptr_length + - strlen(conn->socks_proxy.host.name) + 2); + service.value = curlx_malloc(serviceptr_length + + strlen(conn->socks_proxy.host.name) + 2); if(!service.value) return CURLE_OUT_OF_MEMORY; service.length = serviceptr_length + @@ -277,7 +273,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(struct Curl_cfilter *cf, us_length = ntohs(us_length); gss_recv_token.length = us_length; - gss_recv_token.value = malloc(gss_recv_token.length); + gss_recv_token.value = curlx_malloc(gss_recv_token.length); if(!gss_recv_token.value) { failf(data, "Could not allocate memory for GSS-API authentication " @@ -464,7 +460,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(struct Curl_cfilter *cf, us_length = ntohs(us_length); gss_recv_token.length = us_length; - gss_recv_token.value = malloc(gss_recv_token.length); + gss_recv_token.value = curlx_malloc(gss_recv_token.length); if(!gss_recv_token.value) { Curl_gss_delete_sec_context(&gss_status, &gss_context, NULL); return CURLE_OUT_OF_MEMORY; diff --git a/lib/socks_sspi.c b/lib/socks_sspi.c index 14025371ce37..92592c5ce007 100644 --- a/lib/socks_sspi.c +++ b/lib/socks_sspi.c @@ -38,10 +38,6 @@ #include "curlx/multibyte.h" #include "curlx/warnless.h" -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - /* * Helper sspi error functions. */ @@ -101,7 +97,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(struct Curl_cfilter *cf, /* prepare service name */ if(strchr(service, '/')) - service_name = strdup(service); + service_name = curlx_strdup(service); else service_name = curl_maprintf("%s/%s", service, conn->socks_proxy.host.name); @@ -267,7 +263,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(struct Curl_cfilter *cf, us_length = ntohs(us_length); sspi_recv_token.cbBuffer = us_length; - sspi_recv_token.pvBuffer = malloc(us_length); + sspi_recv_token.pvBuffer = curlx_malloc(us_length); if(!sspi_recv_token.pvBuffer) { result = CURLE_OUT_OF_MEMORY; @@ -371,7 +367,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(struct Curl_cfilter *cf, sspi_w_token[0].cbBuffer = sspi_sizes.cbSecurityTrailer; sspi_w_token[0].BufferType = SECBUFFER_TOKEN; - sspi_w_token[0].pvBuffer = malloc(sspi_sizes.cbSecurityTrailer); + sspi_w_token[0].pvBuffer = curlx_malloc(sspi_sizes.cbSecurityTrailer); if(!sspi_w_token[0].pvBuffer) { result = CURLE_OUT_OF_MEMORY; @@ -379,7 +375,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(struct Curl_cfilter *cf, } sspi_w_token[1].cbBuffer = 1; - sspi_w_token[1].pvBuffer = malloc(1); + sspi_w_token[1].pvBuffer = curlx_malloc(1); if(!sspi_w_token[1].pvBuffer) { result = CURLE_OUT_OF_MEMORY; goto error; @@ -388,7 +384,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(struct Curl_cfilter *cf, memcpy(sspi_w_token[1].pvBuffer, &gss_enc, 1); sspi_w_token[2].BufferType = SECBUFFER_PADDING; sspi_w_token[2].cbBuffer = sspi_sizes.cbBlockSize; - sspi_w_token[2].pvBuffer = malloc(sspi_sizes.cbBlockSize); + sspi_w_token[2].pvBuffer = curlx_malloc(sspi_sizes.cbBlockSize); if(!sspi_w_token[2].pvBuffer) { result = CURLE_OUT_OF_MEMORY; goto error; @@ -409,7 +405,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(struct Curl_cfilter *cf, result = CURLE_COULDNT_CONNECT; goto error; } - etbuf = malloc(etbuf_size); + etbuf = curlx_malloc(etbuf_size); if(!etbuf) { result = CURLE_OUT_OF_MEMORY; goto error; @@ -486,7 +482,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(struct Curl_cfilter *cf, us_length = ntohs(us_length); sspi_w_token[0].cbBuffer = us_length; - sspi_w_token[0].pvBuffer = malloc(us_length); + sspi_w_token[0].pvBuffer = curlx_malloc(us_length); if(!sspi_w_token[0].pvBuffer) { result = CURLE_OUT_OF_MEMORY; goto error; @@ -514,7 +510,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(struct Curl_cfilter *cf, /* since sspi_w_token[1].pvBuffer is allocated by the SSPI in this case, it must be freed in this block using FreeContextBuffer() instead of - potentially in error cleanup using free(). */ + potentially in error cleanup using curlx_free(). */ if(check_sspi_err(data, status, "DecryptMessage")) { failf(data, "Failed to query security context attributes."); @@ -577,18 +573,18 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(struct Curl_cfilter *cf, return CURLE_OK; error: (void)curlx_nonblock(sock, TRUE); - free(service_name); + curlx_free(service_name); Curl_pSecFn->DeleteSecurityContext(&sspi_context); Curl_pSecFn->FreeCredentialsHandle(&cred_handle); - free(sspi_recv_token.pvBuffer); + curlx_free(sspi_recv_token.pvBuffer); if(sspi_send_token.pvBuffer) Curl_pSecFn->FreeContextBuffer(sspi_send_token.pvBuffer); if(names.sUserName) Curl_pSecFn->FreeContextBuffer(names.sUserName); - free(sspi_w_token[0].pvBuffer); - free(sspi_w_token[1].pvBuffer); - free(sspi_w_token[2].pvBuffer); - free(etbuf); + curlx_free(sspi_w_token[0].pvBuffer); + curlx_free(sspi_w_token[1].pvBuffer); + curlx_free(sspi_w_token[2].pvBuffer); + curlx_free(etbuf); return result; } #endif diff --git a/lib/strdup.c b/lib/strdup.c index 3339e909ee79..375f0f50442a 100644 --- a/lib/strdup.c +++ b/lib/strdup.c @@ -31,10 +31,6 @@ #endif #include "strdup.h" -#include "curl_memory.h" - -/* The last #include file should be: */ -#include "memdebug.h" #ifndef HAVE_STRDUP char *Curl_strdup(const char *str) @@ -47,7 +43,7 @@ char *Curl_strdup(const char *str) len = strlen(str) + 1; - newstr = malloc(len); + newstr = curlx_malloc(len); if(!newstr) return (char *)NULL; @@ -90,7 +86,7 @@ wchar_t *Curl_wcsdup(const wchar_t *src) ***************************************************************************/ void *Curl_memdup(const void *src, size_t length) { - void *buffer = malloc(length); + void *buffer = curlx_malloc(length); if(!buffer) return NULL; /* fail */ @@ -111,7 +107,7 @@ void *Curl_memdup(const void *src, size_t length) ***************************************************************************/ void *Curl_memdup0(const char *src, size_t length) { - char *buf = (length < SIZE_MAX) ? malloc(length + 1) : NULL; + char *buf = (length < SIZE_MAX) ? curlx_malloc(length + 1) : NULL; if(!buf) return NULL; if(length) { @@ -126,7 +122,7 @@ void *Curl_memdup0(const char *src, size_t length) * * Curl_saferealloc(ptr, size) * - * Does a normal realloc(), but will free the data pointer if the realloc + * Does a normal curlx_realloc(), but will free the data pointer if the realloc * fails. If 'size' is non-zero, it will free the data and return a failure. * * This convenience function is provided and used to help us avoid a common @@ -138,9 +134,9 @@ void *Curl_memdup0(const char *src, size_t length) ***************************************************************************/ void *Curl_saferealloc(void *ptr, size_t size) { - void *datap = realloc(ptr, size); + void *datap = curlx_realloc(ptr, size); if(size && !datap) /* only free 'ptr' if size was non-zero */ - free(ptr); + curlx_free(ptr); return datap; } diff --git a/lib/strerror.c b/lib/strerror.c index afe69756bcbc..4b957bef2312 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -34,10 +34,6 @@ #include "curlx/winapi.h" #include "strerror.h" -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - const char * curl_easy_strerror(CURLcode error) { diff --git a/lib/system_win32.c b/lib/system_win32.c index bdbed66162eb..f8a6cbfcccd6 100644 --- a/lib/system_win32.c +++ b/lib/system_win32.c @@ -32,10 +32,6 @@ #include "curl_sspi.h" #include "curlx/warnless.h" -/* The last #include files should be: */ -#include "curl_memory.h" -#include "memdebug.h" - #ifndef HAVE_IF_NAMETOINDEX /* Handle of iphlpapp.dll */ static HMODULE s_hIpHlpApiDll = NULL; @@ -218,7 +214,8 @@ static HMODULE curl_load_library(LPCTSTR filename) /* 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)); + TCHAR *path = curlx_malloc(sizeof(TCHAR) * + (systemdirlen + 1 + filenamelen)); if(path && GetSystemDirectory(path, systemdirlen)) { /* Calculate the full DLL path */ _tcscpy(path + _tcslen(path), TEXT("\\")); @@ -230,7 +227,7 @@ static HMODULE curl_load_library(LPCTSTR filename) pLoadLibraryEx(path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH) : LoadLibrary(path); } - free(path); + curlx_free(path); } } return hModule; diff --git a/lib/telnet.c b/lib/telnet.c index d0ca5a66ce11..5319130b90f3 100644 --- a/lib/telnet.c +++ b/lib/telnet.c @@ -60,10 +60,6 @@ #include "curlx/warnless.h" #include "curlx/strparse.h" -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - #define SUBBUFSIZE 512 #define CURL_SB_CLEAR(x) x->subpointer = x->subbuffer @@ -211,7 +207,7 @@ static void telnet_easy_dtor(void *key, size_t klen, void *entry) (void)klen; curl_slist_free_all(tn->telnet_vars); curlx_dyn_free(&tn->out); - free(tn); + curlx_free(tn); } static @@ -219,7 +215,7 @@ CURLcode init_telnet(struct Curl_easy *data) { struct TELNET *tn; - tn = calloc(1, sizeof(struct TELNET)); + tn = curlx_calloc(1, sizeof(struct TELNET)); if(!tn) return CURLE_OUT_OF_MEMORY; diff --git a/lib/tftp.c b/lib/tftp.c index ce9d200f05e3..5311a4c683a2 100644 --- a/lib/tftp.c +++ b/lib/tftp.c @@ -64,10 +64,6 @@ #include "curlx/strerr.h" #include "curlx/strparse.h" -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - /* RFC2348 allows the block size to be negotiated */ #define TFTP_BLKSIZE_DEFAULT 512 #define TFTP_OPTION_BLKSIZE "blksize" @@ -470,7 +466,7 @@ static CURLcode tftp_send_first(struct tftp_conn *state, if(strlen(filename) > (state->blksize - strlen(mode) - 4)) { failf(data, "TFTP filename too long"); - free(filename); + curlx_free(filename); return CURLE_TFTP_ILLEGAL; /* too long filename field */ } @@ -478,7 +474,7 @@ static CURLcode tftp_send_first(struct tftp_conn *state, state->blksize, "%s%c%s%c", filename, '\0', mode, '\0'); sbytes = 4 + strlen(filename) + strlen(mode); - free(filename); + curlx_free(filename); /* optional addition of TFTP options */ if(!data->set.tftp_no_options) { @@ -946,7 +942,7 @@ static void tftp_conn_dtor(void *key, size_t klen, void *entry) (void)klen; Curl_safefree(state->rpacket.data); Curl_safefree(state->spacket.data); - free(state); + curlx_free(state); } /********************************************************** @@ -967,7 +963,7 @@ static CURLcode tftp_connect(struct Curl_easy *data, bool *done) blksize = TFTP_BLKSIZE_DEFAULT; - state = calloc(1, sizeof(*state)); + state = curlx_calloc(1, sizeof(*state)); if(!state || Curl_conn_meta_set(conn, CURL_META_TFTP_CONN, state, tftp_conn_dtor)) return CURLE_OUT_OF_MEMORY; @@ -983,14 +979,14 @@ static CURLcode tftp_connect(struct Curl_easy *data, bool *done) need_blksize = TFTP_BLKSIZE_DEFAULT; if(!state->rpacket.data) { - state->rpacket.data = calloc(1, need_blksize + 2 + 2); + state->rpacket.data = curlx_calloc(1, need_blksize + 2 + 2); if(!state->rpacket.data) return CURLE_OUT_OF_MEMORY; } if(!state->spacket.data) { - state->spacket.data = calloc(1, need_blksize + 2 + 2); + state->spacket.data = curlx_calloc(1, need_blksize + 2 + 2); if(!state->spacket.data) return CURLE_OUT_OF_MEMORY; diff --git a/lib/transfer.c b/lib/transfer.c index f0ce3c501271..d8a0d6c0ba2e 100644 --- a/lib/transfer.c +++ b/lib/transfer.c @@ -81,10 +81,6 @@ #include "headers.h" #include "curlx/warnless.h" -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - #if !defined(CURL_DISABLE_HTTP) || !defined(CURL_DISABLE_SMTP) || \ !defined(CURL_DISABLE_IMAP) /* @@ -479,7 +475,7 @@ CURLcode Curl_pretransfer(struct Curl_easy *data) is allowed to be changed by the user between transfers */ if(data->set.uh) { CURLUcode uc; - free(data->set.str[STRING_SET_URL]); + curlx_free(data->set.str[STRING_SET_URL]); uc = curl_url_get(data->set.uh, CURLUPART_URL, &data->set.str[STRING_SET_URL], 0); if(uc) { @@ -574,7 +570,7 @@ CURLcode Curl_pretransfer(struct Curl_easy *data) if(data->state.wildcardmatch) { struct WildcardData *wc; if(!data->wildcard) { - data->wildcard = calloc(1, sizeof(struct WildcardData)); + data->wildcard = curlx_calloc(1, sizeof(struct WildcardData)); if(!data->wildcard) return CURLE_OUT_OF_MEMORY; } @@ -597,7 +593,7 @@ CURLcode Curl_pretransfer(struct Curl_easy *data) * protocol. */ if(!result && data->set.str[STRING_USERAGENT]) { - free(data->state.aptr.uagent); + curlx_free(data->state.aptr.uagent); data->state.aptr.uagent = curl_maprintf("User-Agent: %s\r\n", data->set.str[STRING_USERAGENT]); if(!data->state.aptr.uagent) @@ -629,7 +625,7 @@ CURLcode Curl_pretransfer(struct Curl_easy *data) /* Returns CURLE_OK *and* sets '*url' if a request retry is wanted. - NOTE: that the *url is malloc()ed. */ + NOTE: that the *url is curlx_malloc()ed. */ CURLcode Curl_retry_request(struct Curl_easy *data, char **url) { struct connectdata *conn = data->conn; @@ -680,7 +676,7 @@ CURLcode Curl_retry_request(struct Curl_easy *data, char **url) } infof(data, "Connection died, retrying a fresh connect (retry count: %d)", data->state.retrycount); - *url = strdup(data->state.url); + *url = curlx_strdup(data->state.url); if(!*url) return CURLE_OUT_OF_MEMORY; diff --git a/lib/uint-bset.c b/lib/uint-bset.c index 82440c56378a..dcad94e42a6e 100644 --- a/lib/uint-bset.c +++ b/lib/uint-bset.c @@ -25,10 +25,6 @@ #include "curl_setup.h" #include "uint-bset.h" -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - #ifdef DEBUGBUILD #define CURL_UINT32_BSET_MAGIC 0x62757473 #endif @@ -49,14 +45,14 @@ CURLcode Curl_uint32_bset_resize(struct uint32_bset *bset, uint32_t nmax) DEBUGASSERT(bset->init == CURL_UINT32_BSET_MAGIC); if(nslots != bset->nslots) { - uint64_t *slots = calloc(nslots, sizeof(uint64_t)); + uint64_t *slots = curlx_calloc(nslots, sizeof(uint64_t)); if(!slots) return CURLE_OUT_OF_MEMORY; if(bset->slots) { memcpy(slots, bset->slots, (CURLMIN(nslots, bset->nslots) * sizeof(uint64_t))); - free(bset->slots); + curlx_free(bset->slots); } bset->slots = slots; bset->nslots = nslots; @@ -69,7 +65,7 @@ CURLcode Curl_uint32_bset_resize(struct uint32_bset *bset, uint32_t nmax) void Curl_uint32_bset_destroy(struct uint32_bset *bset) { DEBUGASSERT(bset->init == CURL_UINT32_BSET_MAGIC); - free(bset->slots); + curlx_free(bset->slots); memset(bset, 0, sizeof(*bset)); } diff --git a/lib/uint-hash.c b/lib/uint-hash.c index 4677c6ac9128..166a9ab99ba5 100644 --- a/lib/uint-hash.c +++ b/lib/uint-hash.c @@ -27,10 +27,6 @@ #include #include "uint-hash.h" -#include "curl_memory.h" - -/* The last #include file should be: */ -#include "memdebug.h" /* random patterns for API verification */ #ifdef DEBUGBUILD @@ -70,7 +66,7 @@ static struct uint_hash_entry *uint32_hash_mk_entry(uint32_t id, void *value) struct uint_hash_entry *e; /* allocate the struct for the hash entry */ - e = malloc(sizeof(*e)); + e = curlx_malloc(sizeof(*e)); if(e) { e->id = id; e->next = NULL; @@ -95,7 +91,7 @@ static void uint32_hash_entry_destroy(struct uint_hash *h, struct uint_hash_entry *e) { uint32_hash_entry_clear(h, e); - free(e); + curlx_free(e); } static void uint32_hash_entry_unlink(struct uint_hash *h, @@ -126,7 +122,7 @@ bool Curl_uint32_hash_set(struct uint_hash *h, uint32_t id, void *value) DEBUGASSERT(h->slots); DEBUGASSERT(h->init == CURL_UINT32_HASHINIT); if(!h->table) { - h->table = calloc(h->slots, sizeof(*he)); + h->table = curlx_calloc(h->slots, sizeof(*he)); if(!h->table) return FALSE; /* OOM */ } diff --git a/lib/uint-spbset.c b/lib/uint-spbset.c index f250bcb1b43f..c726bfb900c1 100644 --- a/lib/uint-spbset.c +++ b/lib/uint-spbset.c @@ -26,10 +26,6 @@ #include "uint-bset.h" #include "uint-spbset.h" -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - #ifdef DEBUGBUILD #define CURL_UINT32_SPBSET_MAGIC 0x70737362 #endif @@ -85,7 +81,7 @@ UNITTEST void Curl_uint32_spbset_clear(struct uint32_spbset *bset) for(chunk = bset->head.next; chunk; chunk = next) { next = chunk->next; - free(chunk); + curlx_free(chunk); } memset(&bset->head, 0, sizeof(bset->head)); } @@ -116,7 +112,7 @@ uint32_spbset_get_chunk(struct uint32_spbset *bset, uint32_t i, bool grow) return NULL; /* need a new one */ - chunk = calloc(1, sizeof(*chunk)); + chunk = curlx_calloc(1, sizeof(*chunk)); if(!chunk) return NULL; diff --git a/lib/uint-table.c b/lib/uint-table.c index 5516ab634bf1..05b53766f30a 100644 --- a/lib/uint-table.c +++ b/lib/uint-table.c @@ -25,10 +25,6 @@ #include "curl_setup.h" #include "uint-table.h" -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - #ifdef DEBUGBUILD #define CURL_UINT32_TBL_MAGIC 0x62757473 #endif @@ -73,14 +69,14 @@ CURLcode Curl_uint32_tbl_resize(struct uint32_tbl *tbl, uint32_t nrows) if(!nrows) return CURLE_BAD_FUNCTION_ARGUMENT; if(nrows != tbl->nrows) { - void **rows = calloc(nrows, sizeof(void *)); + void **rows = curlx_calloc(nrows, sizeof(void *)); if(!rows) return CURLE_OUT_OF_MEMORY; if(tbl->rows) { memcpy(rows, tbl->rows, (CURLMIN(nrows, tbl->nrows) * sizeof(void *))); if(nrows < tbl->nrows) uint32_tbl_clear_rows(tbl, nrows, tbl->nrows); - free(tbl->rows); + curlx_free(tbl->rows); } tbl->rows = rows; tbl->nrows = nrows; @@ -93,7 +89,7 @@ void Curl_uint32_tbl_destroy(struct uint32_tbl *tbl) { DEBUGASSERT(tbl->init == CURL_UINT32_TBL_MAGIC); Curl_uint32_tbl_clear(tbl); - free(tbl->rows); + curlx_free(tbl->rows); memset(tbl, 0, sizeof(*tbl)); } diff --git a/lib/url.c b/lib/url.c index e7f39d5471d1..b4c33236cd67 100644 --- a/lib/url.c +++ b/lib/url.c @@ -126,10 +126,6 @@ #include "curlx/strerr.h" #include "curlx/strparse.h" -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - #ifdef USE_NGHTTP2 static void data_priority_cleanup(struct Curl_easy *data); #else @@ -257,7 +253,7 @@ CURLcode Curl_close(struct Curl_easy **datap) Curl_expire_clear(data); /* shut off any timers left */ if(data->state.rangestringalloc) - free(data->state.range); + curlx_free(data->state.range); /* release any resolve information this transfer kept */ Curl_async_destroy(data); @@ -346,7 +342,7 @@ CURLcode Curl_close(struct Curl_easy **datap) Curl_freeset(data); Curl_headers_cleanup(data); Curl_netrc_cleanup(&data->state.netrc); - free(data); + curlx_free(data); return CURLE_OK; } @@ -500,7 +496,7 @@ CURLcode Curl_open(struct Curl_easy **curl) struct Curl_easy *data; /* simple start-up: alloc the struct, init it with zeroes and return */ - data = calloc(1, sizeof(struct Curl_easy)); + data = curlx_calloc(1, sizeof(struct Curl_easy)); if(!data) { /* this is a serious error */ DEBUGF(curl_mfprintf(stderr, "Error: calloc of Curl_easy failed\n")); @@ -578,7 +574,7 @@ void Curl_conn_free(struct Curl_easy *data, struct connectdata *conn) Curl_uint32_spbset_destroy(&conn->xfers_attached); Curl_hash_destroy(&conn->meta_hash); - free(conn); /* free all the connection oriented data */ + curlx_free(conn); /* free all the connection oriented data */ } /* @@ -1351,7 +1347,7 @@ ConnectionExists(struct Curl_easy *data, */ static struct connectdata *allocate_conn(struct Curl_easy *data) { - struct connectdata *conn = calloc(1, sizeof(struct connectdata)); + struct connectdata *conn = curlx_calloc(1, sizeof(struct connectdata)); if(!conn) return NULL; @@ -1406,7 +1402,7 @@ static struct connectdata *allocate_conn(struct Curl_easy *data) /* Store the local bind parameters that will be used for this connection */ if(data->set.str[STRING_DEVICE]) { - conn->localdev = strdup(data->set.str[STRING_DEVICE]); + conn->localdev = curlx_strdup(data->set.str[STRING_DEVICE]); if(!conn->localdev) goto error; } @@ -1427,8 +1423,8 @@ static struct connectdata *allocate_conn(struct Curl_easy *data) return conn; error: - free(conn->localdev); - free(conn); + curlx_free(conn->localdev); + curlx_free(conn); return NULL; } @@ -1747,7 +1743,7 @@ static void zonefrom_url(CURLU *uh, struct Curl_easy *data, } #endif /* HAVE_IF_NAMETOINDEX || _WIN32 */ - free(zoneid); + curlx_free(zoneid); } } #else @@ -1787,7 +1783,7 @@ static CURLcode parseurlandfillconn(struct Curl_easy *data, if(!url) return CURLE_OUT_OF_MEMORY; if(data->state.url_alloc) - free(data->state.url); + curlx_free(data->state.url); data->state.url = url; data->state.url_alloc = TRUE; } @@ -1810,7 +1806,7 @@ static CURLcode parseurlandfillconn(struct Curl_easy *data, if(uc) return Curl_uc_to_curlcode(uc); if(data->state.url_alloc) - free(data->state.url); + curlx_free(data->state.url); data->state.url = newurl; data->state.url_alloc = TRUE; } @@ -1844,7 +1840,7 @@ static CURLcode parseurlandfillconn(struct Curl_easy *data, } /* make sure the connect struct gets its own copy of the hostname */ - conn->host.rawalloc = strdup(hostname ? hostname : ""); + conn->host.rawalloc = curlx_strdup(hostname ? hostname : ""); if(!conn->host.rawalloc) return CURLE_OUT_OF_MEMORY; conn->host.name = conn->host.rawalloc; @@ -1874,7 +1870,7 @@ static CURLcode parseurlandfillconn(struct Curl_easy *data, return Curl_uc_to_curlcode(uc); uc = curl_url_get(uh, CURLUPART_SCHEME, &data->state.up.scheme, 0); if(uc) { - free(url); + curlx_free(url); return Curl_uc_to_curlcode(uc); } data->state.url = url; @@ -1937,7 +1933,7 @@ static CURLcode parseurlandfillconn(struct Curl_easy *data, uc = curl_url_get(uh, CURLUPART_OPTIONS, &data->state.up.options, CURLU_URLDECODE); if(!uc) { - conn->options = strdup(data->state.up.options); + conn->options = curlx_strdup(data->state.up.options); if(!conn->options) return CURLE_OUT_OF_MEMORY; } @@ -1993,12 +1989,12 @@ static CURLcode setup_range(struct Curl_easy *data) s->resume_from = data->set.set_resume_from; if(s->resume_from || data->set.str[STRING_SET_RANGE]) { if(s->rangestringalloc) - free(s->range); + curlx_free(s->range); if(s->resume_from) s->range = curl_maprintf("%" FMT_OFF_T "-", s->resume_from); else - s->range = strdup(data->set.str[STRING_SET_RANGE]); + s->range = curlx_strdup(data->set.str[STRING_SET_RANGE]); if(!s->range) return CURLE_OUT_OF_MEMORY; @@ -2261,7 +2257,7 @@ static CURLcode parse_proxy(struct Curl_easy *data, goto error; if(proxyuser || proxypasswd) { - free(proxyinfo->user); + curlx_free(proxyinfo->user); proxyinfo->user = proxyuser; result = Curl_setstropt(&data->state.aptr.proxyuser, proxyuser); proxyuser = NULL; @@ -2269,7 +2265,7 @@ static CURLcode parse_proxy(struct Curl_easy *data, goto error; Curl_safefree(proxyinfo->passwd); if(!proxypasswd) { - proxypasswd = strdup(""); + proxypasswd = curlx_strdup(""); if(!proxypasswd) { result = CURLE_OUT_OF_MEMORY; goto error; @@ -2295,7 +2291,7 @@ static CURLcode parse_proxy(struct Curl_easy *data, if(!curlx_str_number(&p, &num, UINT16_MAX)) proxyinfo->port = (uint16_t)num; /* Should we not error out when the port number is invalid? */ - free(portptr); + curlx_free(portptr); } else { if(data->set.proxyport) @@ -2326,13 +2322,13 @@ static CURLcode parse_proxy(struct Curl_easy *data, /* path will be "/", if no path was found */ if(strcmp("/", path)) { is_unix_proxy = TRUE; - free(host); + curlx_free(host); host = curl_maprintf(UNIX_SOCKET_PREFIX"%s", path); if(!host) { result = CURLE_OUT_OF_MEMORY; goto error; } - free(proxyinfo->host.rawalloc); + curlx_free(proxyinfo->host.rawalloc); proxyinfo->host.rawalloc = host; proxyinfo->host.name = host; host = NULL; @@ -2341,7 +2337,7 @@ static CURLcode parse_proxy(struct Curl_easy *data, if(!is_unix_proxy) { #endif - free(proxyinfo->host.rawalloc); + curlx_free(proxyinfo->host.rawalloc); proxyinfo->host.rawalloc = host; if(host[0] == '[') { /* this is a numerical IPv6, strip off the brackets */ @@ -2357,12 +2353,12 @@ static CURLcode parse_proxy(struct Curl_easy *data, #endif error: - free(proxyuser); - free(proxypasswd); - free(host); - free(scheme); + curlx_free(proxyuser); + curlx_free(proxypasswd); + curlx_free(host); + curlx_free(scheme); #ifdef USE_UNIX_SOCKETS - free(path); + curlx_free(path); #endif curl_url_cleanup(uhp); return result; @@ -2380,9 +2376,9 @@ static CURLcode parse_proxy_auth(struct Curl_easy *data, data->state.aptr.proxypasswd : ""; CURLcode result = CURLE_OUT_OF_MEMORY; - conn->http_proxy.user = strdup(proxyuser); + conn->http_proxy.user = curlx_strdup(proxyuser); if(conn->http_proxy.user) { - conn->http_proxy.passwd = strdup(proxypasswd); + conn->http_proxy.passwd = curlx_strdup(proxypasswd); if(conn->http_proxy.passwd) result = CURLE_OK; else @@ -2414,7 +2410,7 @@ static CURLcode create_conn_helper_init_proxy(struct Curl_easy *data, * Detect what (if any) proxy to use *************************************************************/ if(data->set.str[STRING_PROXY]) { - proxy = strdup(data->set.str[STRING_PROXY]); + proxy = curlx_strdup(data->set.str[STRING_PROXY]); /* if global proxy is set, this is it */ if(!proxy) { failf(data, "memory shortage"); @@ -2424,7 +2420,7 @@ static CURLcode create_conn_helper_init_proxy(struct Curl_easy *data, } if(data->set.str[STRING_PRE_PROXY]) { - socksproxy = strdup(data->set.str[STRING_PRE_PROXY]); + socksproxy = curlx_strdup(data->set.str[STRING_PRE_PROXY]); /* if global socks proxy is set, this is it */ if(!socksproxy) { failf(data, "memory shortage"); @@ -2460,20 +2456,21 @@ static CURLcode create_conn_helper_init_proxy(struct Curl_easy *data, #ifdef USE_UNIX_SOCKETS /* For the time being do not mix proxy and Unix domain sockets. See #1274 */ if(proxy && conn->unix_domain_socket) { - free(proxy); + curlx_free(proxy); proxy = NULL; } #endif if(proxy && (!*proxy || (conn->handler->flags & PROTOPT_NONETWORK))) { - free(proxy); /* Do not bother with an empty proxy string or if the - protocol does not work with network */ + curlx_free(proxy); /* Do not bother with an empty proxy string + or if the protocol does not work with network */ proxy = NULL; } if(socksproxy && (!*socksproxy || (conn->handler->flags & PROTOPT_NONETWORK))) { - free(socksproxy); /* Do not bother with an empty socks proxy string or if - the protocol does not work with network */ + curlx_free(socksproxy); /* Do not bother with an empty socks proxy string + or if the protocol does not work with + network */ socksproxy = NULL; } @@ -2528,7 +2525,7 @@ static CURLcode create_conn_helper_init_proxy(struct Curl_easy *data, if(!conn->socks_proxy.user) { conn->socks_proxy.user = conn->http_proxy.user; conn->http_proxy.user = NULL; - free(conn->socks_proxy.passwd); + curlx_free(conn->socks_proxy.passwd); conn->socks_proxy.passwd = conn->http_proxy.passwd; conn->http_proxy.passwd = NULL; } @@ -2558,8 +2555,8 @@ static CURLcode create_conn_helper_init_proxy(struct Curl_easy *data, out: - free(socksproxy); - free(proxy); + curlx_free(socksproxy); + curlx_free(proxy); return result; } #endif /* CURL_DISABLE_PROXY */ @@ -2653,8 +2650,8 @@ CURLcode Curl_parse_login_details(const char *login, const size_t len, *passwdp = pbuf; return CURLE_OK; error: - free(ubuf); - free(pbuf); + curlx_free(ubuf); + curlx_free(pbuf); return CURLE_OUT_OF_MEMORY; } @@ -2712,8 +2709,8 @@ static CURLcode override_login(struct Curl_easy *data, char **optionsp = &conn->options; if(data->set.str[STRING_OPTIONS]) { - free(*optionsp); - *optionsp = strdup(data->set.str[STRING_OPTIONS]); + curlx_free(*optionsp); + *optionsp = curlx_strdup(data->set.str[STRING_OPTIONS]); if(!*optionsp) return CURLE_OUT_OF_MEMORY; } @@ -2767,14 +2764,14 @@ static CURLcode override_login(struct Curl_easy *data, } } if(url_provided) { - free(conn->user); - conn->user = strdup(*userp); + curlx_free(conn->user); + conn->user = curlx_strdup(*userp); if(!conn->user) return CURLE_OUT_OF_MEMORY; } /* no user was set but a password, set a blank user */ if(!*userp && *passwdp) { - *userp = strdup(""); + *userp = curlx_strdup(""); if(!*userp) return CURLE_OUT_OF_MEMORY; } @@ -2798,7 +2795,7 @@ static CURLcode override_login(struct Curl_easy *data, if(uc) return Curl_uc_to_curlcode(uc); if(!*userp) { - *userp = strdup(data->state.aptr.user); + *userp = curlx_strdup(data->state.aptr.user); if(!*userp) return CURLE_OUT_OF_MEMORY; } @@ -2815,7 +2812,7 @@ static CURLcode override_login(struct Curl_easy *data, if(uc) return Curl_uc_to_curlcode(uc); if(!*passwdp) { - *passwdp = strdup(data->state.aptr.passwd); + *passwdp = curlx_strdup(data->state.aptr.passwd); if(!*passwdp) return CURLE_OUT_OF_MEMORY; } @@ -2843,14 +2840,14 @@ static CURLcode set_login(struct Curl_easy *data, } /* Store the default user */ if(!conn->user) { - conn->user = strdup(setuser); + conn->user = curlx_strdup(setuser); if(!conn->user) return CURLE_OUT_OF_MEMORY; } /* Store the default password */ if(!conn->passwd) { - conn->passwd = strdup(setpasswd); + conn->passwd = curlx_strdup(setpasswd); if(!conn->passwd) result = CURLE_OUT_OF_MEMORY; } @@ -2885,7 +2882,7 @@ static CURLcode parse_connect_to_host_port(struct Curl_easy *data, if(!host || !*host) return CURLE_OK; - host_dup = strdup(host); + host_dup = curlx_strdup(host); if(!host_dup) return CURLE_OUT_OF_MEMORY; @@ -2947,7 +2944,7 @@ static CURLcode parse_connect_to_host_port(struct Curl_easy *data, /* now, clone the cleaned hostname */ DEBUGASSERT(hostptr); - *hostname_result = strdup(hostptr); + *hostname_result = curlx_strdup(hostptr); if(!*hostname_result) { result = CURLE_OUT_OF_MEMORY; goto error; @@ -2956,7 +2953,7 @@ static CURLcode parse_connect_to_host_port(struct Curl_easy *data, *port_result = port; error: - free(host_dup); + curlx_free(host_dup); return result; } @@ -2995,7 +2992,7 @@ static CURLcode parse_connect_to_string(struct Curl_easy *data, hostname_to_match_len = strlen(hostname_to_match); host_match = curl_strnequal(ptr, hostname_to_match, hostname_to_match_len); - free(hostname_to_match); + curlx_free(hostname_to_match); ptr += hostname_to_match_len; host_match = host_match && *ptr == ':'; @@ -3136,7 +3133,7 @@ static CURLcode parse_connect_to_slist(struct Curl_easy *data, } if(hit) { - char *hostd = strdup((char *)as->dst.host); + char *hostd = curlx_strdup((char *)as->dst.host); if(!hostd) return CURLE_OUT_OF_MEMORY; conn->conn_to_host.rawalloc = hostd; @@ -3188,7 +3185,7 @@ static CURLcode resolve_unix(struct Curl_easy *data, /* Unix domain sockets are local. The host gets ignored, just use the * specified domain socket address. Do not cache "DNS entries". There is * no DNS involved and we already have the file system path available. */ - hostaddr = calloc(1, sizeof(struct Curl_dns_entry)); + hostaddr = curlx_calloc(1, sizeof(struct Curl_dns_entry)); if(!hostaddr) return CURLE_OUT_OF_MEMORY; @@ -3198,7 +3195,7 @@ static CURLcode resolve_unix(struct Curl_easy *data, if(longpath) /* Long paths are not supported for now */ failf(data, "Unix socket path too long: '%s'", unix_path); - free(hostaddr); + curlx_free(hostaddr); return longpath ? CURLE_COULDNT_RESOLVE_HOST : CURLE_OUT_OF_MEMORY; } @@ -3261,7 +3258,7 @@ static CURLcode resolve_server(struct Curl_easy *data, } /* Resolve target host right on */ - conn->hostname_resolve = strdup(ehost->name); + conn->hostname_resolve = curlx_strdup(ehost->name); if(!conn->hostname_resolve) return CURLE_OUT_OF_MEMORY; @@ -3308,8 +3305,8 @@ static void reuse_conn(struct Curl_easy *data, * be new for this request even when we reuse an existing connection */ if(temp->user) { /* use the new username and password though */ - free(existing->user); - free(existing->passwd); + curlx_free(existing->user); + curlx_free(existing->passwd); existing->user = temp->user; existing->passwd = temp->passwd; temp->user = NULL; @@ -3320,10 +3317,10 @@ static void reuse_conn(struct Curl_easy *data, existing->bits.proxy_user_passwd = temp->bits.proxy_user_passwd; if(existing->bits.proxy_user_passwd) { /* use the new proxy username and proxy password though */ - free(existing->http_proxy.user); - free(existing->socks_proxy.user); - free(existing->http_proxy.passwd); - free(existing->socks_proxy.passwd); + curlx_free(existing->http_proxy.user); + curlx_free(existing->socks_proxy.user); + curlx_free(existing->http_proxy.passwd); + curlx_free(existing->socks_proxy.passwd); existing->http_proxy.user = temp->http_proxy.user; existing->socks_proxy.user = temp->socks_proxy.user; existing->http_proxy.passwd = temp->http_proxy.passwd; @@ -3354,7 +3351,7 @@ static void reuse_conn(struct Curl_easy *data, existing->conn_to_port = temp->conn_to_port; existing->remote_port = temp->remote_port; - free(existing->hostname_resolve); + curlx_free(existing->hostname_resolve); existing->hostname_resolve = temp->hostname_resolve; temp->hostname_resolve = NULL; @@ -3436,7 +3433,7 @@ static CURLcode create_conn(struct Curl_easy *data, goto out; if(data->set.str[STRING_SASL_AUTHZID]) { - conn->sasl_authzid = strdup(data->set.str[STRING_SASL_AUTHZID]); + conn->sasl_authzid = curlx_strdup(data->set.str[STRING_SASL_AUTHZID]); if(!conn->sasl_authzid) { result = CURLE_OUT_OF_MEMORY; goto out; @@ -3444,7 +3441,7 @@ static CURLcode create_conn(struct Curl_easy *data, } if(data->set.str[STRING_BEARER]) { - conn->oauth_bearer = strdup(data->set.str[STRING_BEARER]); + conn->oauth_bearer = curlx_strdup(data->set.str[STRING_BEARER]); if(!conn->oauth_bearer) { result = CURLE_OUT_OF_MEMORY; goto out; @@ -3453,7 +3450,8 @@ static CURLcode create_conn(struct Curl_easy *data, #ifdef USE_UNIX_SOCKETS if(data->set.str[STRING_UNIX_SOCKET_PATH]) { - conn->unix_domain_socket = strdup(data->set.str[STRING_UNIX_SOCKET_PATH]); + conn->unix_domain_socket = + curlx_strdup(data->set.str[STRING_UNIX_SOCKET_PATH]); if(!conn->unix_domain_socket) { result = CURLE_OUT_OF_MEMORY; goto out; @@ -3924,7 +3922,7 @@ static void priority_remove_child(struct Curl_easy *parent, DEBUGASSERT(pnode); if(pnode) { *pnext = pnode->next; - free(pnode); + curlx_free(pnode); } child->set.priority.parent = 0; @@ -3943,7 +3941,7 @@ CURLcode Curl_data_priority_add_child(struct Curl_easy *parent, struct Curl_data_prio_node **tail; struct Curl_data_prio_node *pnode; - pnode = calloc(1, sizeof(*pnode)); + pnode = curlx_calloc(1, sizeof(*pnode)); if(!pnode) return CURLE_OUT_OF_MEMORY; pnode->data = child; diff --git a/lib/urlapi.c b/lib/urlapi.c index 9d3eb0f8cf0f..ad4d367dc34c 100644 --- a/lib/urlapi.c +++ b/lib/urlapi.c @@ -37,10 +37,6 @@ #include "curlx/strparse.h" #include "curl_memrchr.h" -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - #ifdef _WIN32 /* MS-DOS/Windows style drive prefix, eg c: in c:foo */ #define STARTS_WITH_DRIVE_PREFIX(str) \ @@ -94,16 +90,16 @@ static CURLUcode parseurl_and_replace(const char *url, CURLU *u, static void free_urlhandle(struct Curl_URL *u) { - free(u->scheme); - free(u->user); - free(u->password); - free(u->options); - free(u->host); - free(u->zoneid); - free(u->port); - free(u->path); - free(u->query); - free(u->fragment); + curlx_free(u->scheme); + curlx_free(u->user); + curlx_free(u->password); + curlx_free(u->options); + curlx_free(u->host); + curlx_free(u->zoneid); + curlx_free(u->port); + curlx_free(u->path); + curlx_free(u->query); + curlx_free(u->fragment); } /* @@ -384,17 +380,17 @@ static CURLUcode parse_hostname_login(struct Curl_URL *u, result = CURLUE_USER_NOT_ALLOWED; goto out; } - free(u->user); + curlx_free(u->user); u->user = userp; } if(passwdp) { - free(u->password); + curlx_free(u->password); u->password = passwdp; } if(optionsp) { - free(u->options); + curlx_free(u->options); u->options = optionsp; } @@ -404,9 +400,9 @@ static CURLUcode parse_hostname_login(struct Curl_URL *u, out: - free(userp); - free(passwdp); - free(optionsp); + curlx_free(userp); + curlx_free(passwdp); + curlx_free(optionsp); u->user = NULL; u->password = NULL; u->options = NULL; @@ -459,7 +455,7 @@ UNITTEST CURLUcode Curl_parse_port(struct Curl_URL *u, struct dynbuf *host, u->portnum = (unsigned short) port; /* generate a new port number string to get rid of leading zeroes etc */ - free(u->port); + curlx_free(u->port); u->port = curl_maprintf("%" CURL_FORMAT_CURL_OFF_T, port); if(!u->port) return CURLUE_OUT_OF_MEMORY; @@ -497,7 +493,7 @@ static CURLUcode ipv6_parse(struct Curl_URL *u, char *hostname, if(!i || (']' != *h)) return CURLUE_BAD_IPV6; zoneid[i] = 0; - u->zoneid = strdup(zoneid); + u->zoneid = curlx_strdup(zoneid); if(!u->zoneid) return CURLUE_OUT_OF_MEMORY; hostname[len] = ']'; /* insert end bracket */ @@ -675,7 +671,7 @@ static CURLUcode urldecode_host(struct dynbuf *host) return CURLUE_BAD_HOSTNAME; curlx_dyn_reset(host); result = curlx_dyn_addn(host, decoded, dlen); - free(decoded); + curlx_free(decoded); if(result) return cc2cu(result); } @@ -750,7 +746,7 @@ CURLUcode Curl_url_set_authority(CURLU *u, const char *authority) if(result) curlx_dyn_free(&host); else { - free(u->host); + curlx_free(u->host); u->host = curlx_dyn_ptr(&host); } return result; @@ -894,7 +890,7 @@ UNITTEST int dedotdotify(const char *input, size_t clen, char **outp) if(curlx_dyn_len(&out)) *outp = curlx_dyn_ptr(&out); else { - *outp = strdup(""); + *outp = curlx_strdup(""); if(!*outp) return 1; } @@ -940,7 +936,7 @@ static CURLUcode parseurl(const char *url, CURLU *u, unsigned int flags) path = &url[5]; pathlen = urllen - 5; - u->scheme = strdup("file"); + u->scheme = curlx_strdup("file"); if(!u->scheme) { result = CURLUE_OUT_OF_MEMORY; goto fail; @@ -1087,7 +1083,7 @@ static CURLUcode parseurl(const char *url, CURLU *u, unsigned int flags) } if(schemep) { - u->scheme = strdup(schemep); + u->scheme = curlx_strdup(schemep); if(!u->scheme) { result = CURLUE_OUT_OF_MEMORY; goto fail; @@ -1124,7 +1120,7 @@ static CURLUcode parseurl(const char *url, CURLU *u, unsigned int flags) else schemep = "http"; - u->scheme = strdup(schemep); + u->scheme = curlx_strdup(schemep); if(!u->scheme) { result = CURLUE_OUT_OF_MEMORY; goto fail; @@ -1197,7 +1193,7 @@ static CURLUcode parseurl(const char *url, CURLU *u, unsigned int flags) } else { /* single byte query */ - u->query = strdup(""); + u->query = curlx_strdup(""); if(!u->query) { result = CURLUE_OUT_OF_MEMORY; goto fail; @@ -1241,7 +1237,7 @@ static CURLUcode parseurl(const char *url, CURLU *u, unsigned int flags) goto fail; } if(dedot) { - free(u->path); + curlx_free(u->path); u->path = dedot; } } @@ -1277,21 +1273,21 @@ static CURLUcode parseurl_and_replace(const char *url, CURLU *u, */ CURLU *curl_url(void) { - return calloc(1, sizeof(struct Curl_URL)); + return curlx_calloc(1, sizeof(struct Curl_URL)); } void curl_url_cleanup(CURLU *u) { if(u) { free_urlhandle(u); - free(u); + curlx_free(u); } } #define DUP(dest, src, name) \ do { \ if(src->name) { \ - dest->name = strdup(src->name); \ + dest->name = curlx_strdup(src->name); \ if(!dest->name) \ goto fail; \ } \ @@ -1299,7 +1295,7 @@ void curl_url_cleanup(CURLU *u) CURLU *curl_url_dup(const CURLU *in) { - struct Curl_URL *u = calloc(1, sizeof(struct Curl_URL)); + struct Curl_URL *u = curlx_calloc(1, sizeof(struct Curl_URL)); if(u) { DUP(u, in, scheme); DUP(u, in, user); @@ -1373,7 +1369,7 @@ static CURLUcode urlget_format(const CURLU *u, CURLUPart what, /* this unconditional rejection of control bytes is documented API behavior */ CURLcode res = Curl_urldecode(part, partlen, &decoded, &dlen, REJECT_CTRL); - free(part); + curlx_free(part); if(res) return CURLUE_URLDECODE; part = decoded; @@ -1383,7 +1379,7 @@ static CURLUcode urlget_format(const CURLU *u, CURLUPart what, struct dynbuf enc; curlx_dyn_init(&enc, CURL_MAX_INPUT_LENGTH); uc = urlencode_str(&enc, part, partlen, TRUE, what == CURLUPART_QUERY); - free(part); + curlx_free(part); if(uc) return uc; part = curlx_dyn_ptr(&enc); @@ -1392,7 +1388,7 @@ static CURLUcode urlget_format(const CURLU *u, CURLUPart what, if(!Curl_is_ASCII_name(u->host)) { char *punyversion = NULL; uc = host_decode(part, &punyversion); - free(part); + curlx_free(part); if(uc) return uc; part = punyversion; @@ -1402,7 +1398,7 @@ static CURLUcode urlget_format(const CURLU *u, CURLUPart what, if(Curl_is_ASCII_name(u->host)) { char *unpunified = NULL; uc = host_encode(part, &unpunified); - free(part); + curlx_free(part); if(uc) return uc; part = unpunified; @@ -1520,7 +1516,7 @@ static CURLUcode urlget_url(const CURLU *u, char **part, unsigned int flags) u->query ? u->query : "", show_fragment ? "#": "", u->fragment ? u->fragment : ""); - free(allochost); + curlx_free(allochost); } if(!url) return CURLUE_OUT_OF_MEMORY; @@ -1666,7 +1662,7 @@ static CURLUcode set_url_port(CURLU *u, const char *provided_port) tmp = curl_maprintf("%" CURL_FORMAT_CURL_OFF_T, port); if(!tmp) return CURLUE_OUT_OF_MEMORY; - free(u->port); + curlx_free(u->port); u->port = tmp; u->portnum = (unsigned short)port; return CURLUE_OK; @@ -1691,7 +1687,7 @@ static CURLUcode set_url(CURLU *u, const char *url, size_t part_size, if(!uc) { /* success, meaning the "" is a fine relative URL, but nothing changes */ - free(oldurl); + curlx_free(oldurl); return CURLUE_OK; } if(uc == CURLUE_OUT_OF_MEMORY) @@ -1715,7 +1711,7 @@ static CURLUcode set_url(CURLU *u, const char *url, size_t part_size, DEBUGASSERT(oldurl); /* it is set here */ /* apply the relative part to create a new URL */ uc = redirect_url(oldurl, url, u, flags); - free(oldurl); + curlx_free(oldurl); return uc; } @@ -1930,7 +1926,7 @@ CURLUcode curl_url_set(CURLU *u, CURLUPart what, if(curlx_dyn_add(&qbuf, newp)) goto nomem; curlx_dyn_free(&enc); - free(*storep); + curlx_free(*storep); *storep = curlx_dyn_ptr(&qbuf); return CURLUE_OK; nomem: @@ -1957,7 +1953,7 @@ CURLUcode curl_url_set(CURLU *u, CURLUPart what, Curl_urldecode(newp, n, &decoded, &dlen, REJECT_CTRL); if(result || hostname_check(u, decoded, dlen)) bad = TRUE; - free(decoded); + curlx_free(decoded); } else if(hostname_check(u, (char *)CURL_UNCONST(newp), n)) bad = TRUE; @@ -1968,7 +1964,7 @@ CURLUcode curl_url_set(CURLU *u, CURLUPart what, } } - free(*storep); + curlx_free(*storep); *storep = (char *)CURL_UNCONST(newp); } return CURLUE_OK; diff --git a/lib/vauth/cleartext.c b/lib/vauth/cleartext.c index 884ebce0f268..d259bc42b5b2 100644 --- a/lib/vauth/cleartext.c +++ b/lib/vauth/cleartext.c @@ -38,10 +38,6 @@ #include "../curlx/warnless.h" #include "../sendf.h" -/* The last #include files should be: */ -#include "../curl_memory.h" -#include "../memdebug.h" - /* * Curl_auth_create_plain_message() * diff --git a/lib/vauth/cram.c b/lib/vauth/cram.c index 2754ddc4a29f..3b02e5751fcc 100644 --- a/lib/vauth/cram.c +++ b/lib/vauth/cram.c @@ -36,10 +36,6 @@ #include "../curl_md5.h" #include "../curlx/warnless.h" -/* The last #include files should be: */ -#include "../curl_memory.h" -#include "../memdebug.h" - /* * Curl_auth_create_cram_md5_message() diff --git a/lib/vauth/digest.c b/lib/vauth/digest.c index 16045707fd1e..850891f17535 100644 --- a/lib/vauth/digest.c +++ b/lib/vauth/digest.c @@ -44,10 +44,6 @@ #include "../curlx/strparse.h" #include "../rand.h" -/* The last #include files should be: */ -#include "../curl_memory.h" -#include "../memdebug.h" - #ifndef USE_WINDOWS_SSPI #define SESSION_ALGO 1 /* for algos with this bit set */ @@ -174,7 +170,7 @@ static char *auth_digest_string_quoted(const char *source) ++s; } - dest = malloc(n); + dest = curlx_malloc(n); if(dest) { char *d = dest; s = source; @@ -426,7 +422,7 @@ CURLcode Curl_auth_create_digest_md5_message(struct Curl_easy *data, /* Calculate H(A2) */ ctxt = Curl_MD5_init(&Curl_DIGEST_MD5); if(!ctxt) { - free(spn); + curlx_free(spn); return CURLE_OUT_OF_MEMORY; } @@ -444,7 +440,7 @@ CURLcode Curl_auth_create_digest_md5_message(struct Curl_easy *data, /* Now calculate the response hash */ ctxt = Curl_MD5_init(&Curl_DIGEST_MD5); if(!ctxt) { - free(spn); + curlx_free(spn); return CURLE_OUT_OF_MEMORY; } @@ -477,7 +473,7 @@ CURLcode Curl_auth_create_digest_md5_message(struct Curl_easy *data, "response=%s,qop=%s", userp, realm, nonce, cnonce, nonceCount, spn, resp_hash_hex, qop); - free(spn); + curlx_free(spn); if(!response) return CURLE_OUT_OF_MEMORY; @@ -522,8 +518,8 @@ CURLcode Curl_auth_decode_digest_http_message(const char *chlg, /* Extract a value=content pair */ if(Curl_auth_digest_get_pair(chlg, value, content, &chlg)) { if(curl_strequal(value, "nonce")) { - free(digest->nonce); - digest->nonce = strdup(content); + curlx_free(digest->nonce); + digest->nonce = curlx_strdup(content); if(!digest->nonce) return CURLE_OUT_OF_MEMORY; } @@ -534,14 +530,14 @@ CURLcode Curl_auth_decode_digest_http_message(const char *chlg, } } else if(curl_strequal(value, "realm")) { - free(digest->realm); - digest->realm = strdup(content); + curlx_free(digest->realm); + digest->realm = curlx_strdup(content); if(!digest->realm) return CURLE_OUT_OF_MEMORY; } else if(curl_strequal(value, "opaque")) { - free(digest->opaque); - digest->opaque = strdup(content); + curlx_free(digest->opaque); + digest->opaque = curlx_strdup(content); if(!digest->opaque) return CURLE_OUT_OF_MEMORY; } @@ -567,21 +563,21 @@ CURLcode Curl_auth_decode_digest_http_message(const char *chlg, /* Select only auth or auth-int. Otherwise, ignore */ if(foundAuth) { - free(digest->qop); - digest->qop = strdup(DIGEST_QOP_VALUE_STRING_AUTH); + curlx_free(digest->qop); + digest->qop = curlx_strdup(DIGEST_QOP_VALUE_STRING_AUTH); if(!digest->qop) return CURLE_OUT_OF_MEMORY; } else if(foundAuthInt) { - free(digest->qop); - digest->qop = strdup(DIGEST_QOP_VALUE_STRING_AUTH_INT); + curlx_free(digest->qop); + digest->qop = curlx_strdup(DIGEST_QOP_VALUE_STRING_AUTH_INT); if(!digest->qop) return CURLE_OUT_OF_MEMORY; } } else if(curl_strequal(value, "algorithm")) { - free(digest->algorithm); - digest->algorithm = strdup(content); + curlx_free(digest->algorithm); + digest->algorithm = curlx_strdup(content); if(!digest->algorithm) return CURLE_OUT_OF_MEMORY; @@ -725,7 +721,7 @@ static CURLcode auth_create_digest_http_message( return CURLE_OUT_OF_MEMORY; result = hash(hashbuf, (unsigned char *) hashthis, strlen(hashthis)); - free(hashthis); + curlx_free(hashthis); if(result) return result; convert_to_ascii(hashbuf, (unsigned char *)userh); @@ -748,7 +744,7 @@ static CURLcode auth_create_digest_http_message( return CURLE_OUT_OF_MEMORY; result = hash(hashbuf, (unsigned char *) hashthis, strlen(hashthis)); - free(hashthis); + curlx_free(hashthis); if(result) return result; convert_to_ascii(hashbuf, ha1); @@ -760,7 +756,7 @@ static CURLcode auth_create_digest_http_message( return CURLE_OUT_OF_MEMORY; result = hash(hashbuf, (unsigned char *) tmp, strlen(tmp)); - free(tmp); + curlx_free(tmp); if(result) return result; convert_to_ascii(hashbuf, ha1); @@ -790,13 +786,13 @@ static CURLcode auth_create_digest_http_message( result = hash(hashbuf, (const unsigned char *)"", 0); if(result) { - free(hashthis); + curlx_free(hashthis); return result; } convert_to_ascii(hashbuf, (unsigned char *)hashed); hashthis2 = curl_maprintf("%s:%s", hashthis, hashed); - free(hashthis); + curlx_free(hashthis); hashthis = hashthis2; } @@ -804,7 +800,7 @@ static CURLcode auth_create_digest_http_message( return CURLE_OUT_OF_MEMORY; result = hash(hashbuf, (unsigned char *) hashthis, strlen(hashthis)); - free(hashthis); + curlx_free(hashthis); if(result) return result; convert_to_ascii(hashbuf, ha2); @@ -821,7 +817,7 @@ static CURLcode auth_create_digest_http_message( return CURLE_OUT_OF_MEMORY; result = hash(hashbuf, (unsigned char *) hashthis, strlen(hashthis)); - free(hashthis); + curlx_free(hashthis); if(result) return result; convert_to_ascii(hashbuf, request_digest); @@ -845,18 +841,18 @@ static CURLcode auth_create_digest_http_message( if(digest->realm) realm_quoted = auth_digest_string_quoted(digest->realm); else { - realm_quoted = malloc(1); + realm_quoted = curlx_malloc(1); if(realm_quoted) realm_quoted[0] = 0; } if(!realm_quoted) { - free(userp_quoted); + curlx_free(userp_quoted); return CURLE_OUT_OF_MEMORY; } nonce_quoted = auth_digest_string_quoted(digest->nonce); if(!nonce_quoted) { - free(realm_quoted); - free(userp_quoted); + curlx_free(realm_quoted); + curlx_free(userp_quoted); return CURLE_OUT_OF_MEMORY; } @@ -893,9 +889,9 @@ static CURLcode auth_create_digest_http_message( uripath, request_digest); } - free(nonce_quoted); - free(realm_quoted); - free(userp_quoted); + curlx_free(nonce_quoted); + curlx_free(realm_quoted); + curlx_free(userp_quoted); if(!response) return CURLE_OUT_OF_MEMORY; @@ -905,12 +901,12 @@ static CURLcode auth_create_digest_http_message( /* Append the opaque */ opaque_quoted = auth_digest_string_quoted(digest->opaque); if(!opaque_quoted) { - free(response); + curlx_free(response); return CURLE_OUT_OF_MEMORY; } tmp = curl_maprintf("%s, opaque=\"%s\"", response, opaque_quoted); - free(response); - free(opaque_quoted); + curlx_free(response); + curlx_free(opaque_quoted); if(!tmp) return CURLE_OUT_OF_MEMORY; @@ -920,7 +916,7 @@ static CURLcode auth_create_digest_http_message( if(digest->algorithm) { /* Append the algorithm */ tmp = curl_maprintf("%s, algorithm=%s", response, digest->algorithm); - free(response); + curlx_free(response); if(!tmp) return CURLE_OUT_OF_MEMORY; @@ -930,7 +926,7 @@ static CURLcode auth_create_digest_http_message( if(digest->userhash) { /* Append the userhash */ tmp = curl_maprintf("%s, userhash=true", response); - free(response); + curlx_free(response); if(!tmp) return CURLE_OUT_OF_MEMORY; diff --git a/lib/vauth/digest_sspi.c b/lib/vauth/digest_sspi.c index f730c52987a3..ea6a66af9fac 100644 --- a/lib/vauth/digest_sspi.c +++ b/lib/vauth/digest_sspi.c @@ -41,10 +41,6 @@ #include "../strcase.h" #include "../strerror.h" -/* The last #include files should be: */ -#include "../curl_memory.h" -#include "../memdebug.h" - /* * Curl_auth_is_digest_supported() * @@ -135,14 +131,14 @@ CURLcode Curl_auth_create_digest_md5_message(struct Curl_easy *data, Curl_pSecFn->FreeContextBuffer(SecurityPackage); /* Allocate our response buffer */ - output_token = malloc(token_max); + output_token = curlx_malloc(token_max); if(!output_token) return CURLE_OUT_OF_MEMORY; /* Generate our SPN */ spn = Curl_auth_build_spn(service, data->conn->host.name, NULL); if(!spn) { - free(output_token); + curlx_free(output_token); return CURLE_OUT_OF_MEMORY; } @@ -150,8 +146,8 @@ CURLcode Curl_auth_create_digest_md5_message(struct Curl_easy *data, /* Populate our identity structure */ result = Curl_create_sspi_identity(userp, passwdp, &identity); if(result) { - free(spn); - free(output_token); + curlx_free(spn); + curlx_free(output_token); return result; } @@ -171,8 +167,8 @@ CURLcode Curl_auth_create_digest_md5_message(struct Curl_easy *data, if(status != SEC_E_OK) { Curl_sspi_free_identity(p_identity); - free(spn); - free(output_token); + curlx_free(spn); + curlx_free(output_token); return CURLE_LOGIN_DENIED; } @@ -208,8 +204,8 @@ CURLcode Curl_auth_create_digest_md5_message(struct Curl_easy *data, Curl_pSecFn->FreeCredentialsHandle(&credentials); Curl_sspi_free_identity(p_identity); - free(spn); - free(output_token); + curlx_free(spn); + curlx_free(output_token); if(status == SEC_E_INSUFFICIENT_MEMORY) return CURLE_OUT_OF_MEMORY; @@ -233,7 +229,7 @@ CURLcode Curl_auth_create_digest_md5_message(struct Curl_easy *data, Curl_sspi_free_identity(p_identity); /* Free the SPN */ - free(spn); + curlx_free(spn); return result; } @@ -276,13 +272,13 @@ CURLcode Curl_override_sspi_http_realm(const char *chlg, if(!domain.tchar_ptr) return CURLE_OUT_OF_MEMORY; - dup_domain.tchar_ptr = Curl_tcsdup(domain.tchar_ptr); + dup_domain.tchar_ptr = curlx_tcsdup(domain.tchar_ptr); if(!dup_domain.tchar_ptr) { curlx_unicodefree(domain.tchar_ptr); return CURLE_OUT_OF_MEMORY; } - free(identity->Domain); + curlx_free(identity->Domain); identity->Domain = dup_domain.tbyte_ptr; identity->DomainLength = curlx_uztoul(_tcslen(dup_domain.tchar_ptr)); dup_domain.tchar_ptr = NULL; @@ -429,7 +425,7 @@ CURLcode Curl_auth_create_digest_http_message(struct Curl_easy *data, /* Allocate the output buffer according to the max token size as indicated by the security package */ - output_token = malloc(token_max); + output_token = curlx_malloc(token_max); if(!output_token) { return CURLE_OUT_OF_MEMORY; } @@ -495,7 +491,7 @@ CURLcode Curl_auth_create_digest_http_message(struct Curl_easy *data, if(userp && *userp) { /* Populate our identity structure */ if(Curl_create_sspi_identity(userp, passwdp, &identity)) { - free(output_token); + curlx_free(output_token); return CURLE_OUT_OF_MEMORY; } @@ -503,7 +499,7 @@ CURLcode Curl_auth_create_digest_http_message(struct Curl_easy *data, if(Curl_override_sspi_http_realm((const char *) digest->input_token, &identity)) { Curl_sspi_free_identity(&identity); - free(output_token); + curlx_free(output_token); return CURLE_OUT_OF_MEMORY; } @@ -515,20 +511,20 @@ CURLcode Curl_auth_create_digest_http_message(struct Curl_easy *data, p_identity = NULL; if(userp) { - digest->user = strdup(userp); + digest->user = curlx_strdup(userp); if(!digest->user) { - free(output_token); + curlx_free(output_token); Curl_sspi_free_identity(p_identity); return CURLE_OUT_OF_MEMORY; } } if(passwdp) { - digest->passwd = strdup(passwdp); + digest->passwd = curlx_strdup(passwdp); if(!digest->passwd) { - free(output_token); + curlx_free(output_token); Curl_sspi_free_identity(p_identity); Curl_safefree(digest->user); return CURLE_OUT_OF_MEMORY; @@ -543,7 +539,7 @@ CURLcode Curl_auth_create_digest_http_message(struct Curl_easy *data, &credentials, NULL); if(status != SEC_E_OK) { Curl_sspi_free_identity(p_identity); - free(output_token); + curlx_free(output_token); return CURLE_LOGIN_DENIED; } @@ -575,18 +571,18 @@ CURLcode Curl_auth_create_digest_http_message(struct Curl_easy *data, Curl_pSecFn->FreeCredentialsHandle(&credentials); Curl_sspi_free_identity(p_identity); - free(output_token); + curlx_free(output_token); return CURLE_OUT_OF_MEMORY; } /* Allocate our new context handle */ - digest->http_context = calloc(1, sizeof(CtxtHandle)); + digest->http_context = curlx_calloc(1, sizeof(CtxtHandle)); if(!digest->http_context) { Curl_pSecFn->FreeCredentialsHandle(&credentials); curlx_unicodefree(spn); Curl_sspi_free_identity(p_identity); - free(output_token); + curlx_free(output_token); return CURLE_OUT_OF_MEMORY; } @@ -610,7 +606,7 @@ CURLcode Curl_auth_create_digest_http_message(struct Curl_easy *data, Curl_pSecFn->FreeCredentialsHandle(&credentials); Curl_sspi_free_identity(p_identity); - free(output_token); + curlx_free(output_token); Curl_safefree(digest->http_context); @@ -632,7 +628,7 @@ CURLcode Curl_auth_create_digest_http_message(struct Curl_easy *data, } resp = Curl_memdup0((const char *)output_token, output_token_len); - free(output_token); + curlx_free(output_token); if(!resp) { return CURLE_OUT_OF_MEMORY; } diff --git a/lib/vauth/gsasl.c b/lib/vauth/gsasl.c index 119c392cda13..debeda0604e2 100644 --- a/lib/vauth/gsasl.c +++ b/lib/vauth/gsasl.c @@ -36,10 +36,6 @@ #include -/* The last 2 #include files should be in this order */ -#include "../curl_memory.h" -#include "../memdebug.h" - bool Curl_auth_gsasl_is_supported(struct Curl_easy *data, const char *mech, struct gsasldata *gsasl) diff --git a/lib/vauth/krb5_gssapi.c b/lib/vauth/krb5_gssapi.c index a414d0a35961..9ea36171faec 100644 --- a/lib/vauth/krb5_gssapi.c +++ b/lib/vauth/krb5_gssapi.c @@ -37,10 +37,6 @@ #include "../curl_gssapi.h" #include "../sendf.h" -/* The last #include files should be: */ -#include "../curl_memory.h" -#include "../memdebug.h" - #if defined(__GNUC__) && defined(__APPLE__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wdeprecated-declarations" @@ -120,12 +116,12 @@ CURLcode Curl_auth_create_gssapi_user_message(struct Curl_easy *data, Curl_gss_log_error(data, "gss_import_name() failed: ", major_status, minor_status); - free(spn); + curlx_free(spn); return CURLE_AUTH_ERROR; } - free(spn); + curlx_free(spn); } if(chlg) { @@ -258,7 +254,7 @@ CURLcode Curl_auth_create_gssapi_security_message(struct Curl_easy *data, messagelen = 4; if(authzid) messagelen += strlen(authzid); - message = malloc(messagelen); + message = curlx_malloc(messagelen); if(!message) return CURLE_OUT_OF_MEMORY; @@ -285,7 +281,7 @@ CURLcode Curl_auth_create_gssapi_security_message(struct Curl_easy *data, if(GSS_ERROR(major_status)) { Curl_gss_log_error(data, "gss_wrap() failed: ", major_status, minor_status); - free(message); + curlx_free(message); return CURLE_AUTH_ERROR; } @@ -295,7 +291,7 @@ CURLcode Curl_auth_create_gssapi_security_message(struct Curl_easy *data, gss_release_buffer(&unused_status, &output_token); /* Free the message buffer */ - free(message); + curlx_free(message); return result; } diff --git a/lib/vauth/krb5_sspi.c b/lib/vauth/krb5_sspi.c index cad2412d1794..10fbac7644db 100644 --- a/lib/vauth/krb5_sspi.c +++ b/lib/vauth/krb5_sspi.c @@ -36,10 +36,6 @@ #include "../curlx/multibyte.h" #include "../sendf.h" -/* The last #include files should be: */ -#include "../curl_memory.h" -#include "../memdebug.h" - /* * Curl_auth_is_gssapi_supported() * @@ -131,7 +127,7 @@ CURLcode Curl_auth_create_gssapi_user_message(struct Curl_easy *data, Curl_pSecFn->FreeContextBuffer(SecurityPackage); /* Allocate our response buffer */ - krb5->output_token = malloc(krb5->token_max); + krb5->output_token = curlx_malloc(krb5->token_max); if(!krb5->output_token) return CURLE_OUT_OF_MEMORY; } @@ -152,7 +148,7 @@ CURLcode Curl_auth_create_gssapi_user_message(struct Curl_easy *data, krb5->p_identity = NULL; /* Allocate our credentials handle */ - krb5->credentials = calloc(1, sizeof(CredHandle)); + krb5->credentials = curlx_calloc(1, sizeof(CredHandle)); if(!krb5->credentials) return CURLE_OUT_OF_MEMORY; @@ -166,7 +162,7 @@ CURLcode Curl_auth_create_gssapi_user_message(struct Curl_easy *data, return CURLE_LOGIN_DENIED; /* Allocate our new context handle */ - krb5->context = calloc(1, sizeof(CtxtHandle)); + krb5->context = curlx_calloc(1, sizeof(CtxtHandle)); if(!krb5->context) return CURLE_OUT_OF_MEMORY; } @@ -340,7 +336,7 @@ CURLcode Curl_auth_create_gssapi_security_message(struct Curl_easy *data, } /* Allocate the trailer */ - trailer = malloc(sizes.cbSecurityTrailer); + trailer = curlx_malloc(sizes.cbSecurityTrailer); if(!trailer) return CURLE_OUT_OF_MEMORY; @@ -348,7 +344,7 @@ CURLcode Curl_auth_create_gssapi_security_message(struct Curl_easy *data, messagelen = 4; if(authzid) messagelen += strlen(authzid); - message = malloc(messagelen); + message = curlx_malloc(messagelen); if(!message) { result = CURLE_OUT_OF_MEMORY; goto out; @@ -367,7 +363,7 @@ CURLcode Curl_auth_create_gssapi_security_message(struct Curl_easy *data, memcpy(message + 4, authzid, messagelen - 4); /* Allocate the padding */ - padding = malloc(sizes.cbBlockSize); + padding = curlx_malloc(sizes.cbBlockSize); if(!padding) { result = CURLE_OUT_OF_MEMORY; goto out; @@ -401,7 +397,7 @@ CURLcode Curl_auth_create_gssapi_security_message(struct Curl_easy *data, /* Allocate the encryption (wrap) buffer */ appdatalen = wrap_buf[0].cbBuffer + wrap_buf[1].cbBuffer + wrap_buf[2].cbBuffer; - appdata = malloc(appdatalen); + appdata = curlx_malloc(appdatalen); if(!appdata) { result = CURLE_OUT_OF_MEMORY; goto out; @@ -416,9 +412,9 @@ CURLcode Curl_auth_create_gssapi_security_message(struct Curl_easy *data, out: /* Free all of our local buffers */ - free(padding); - free(message); - free(trailer); + curlx_free(padding); + curlx_free(message); + curlx_free(trailer); if(result) return result; @@ -443,14 +439,14 @@ void Curl_auth_cleanup_gssapi(struct kerberos5data *krb5) /* Free our security context */ if(krb5->context) { Curl_pSecFn->DeleteSecurityContext(krb5->context); - free(krb5->context); + curlx_free(krb5->context); krb5->context = NULL; } /* Free our credentials handle */ if(krb5->credentials) { Curl_pSecFn->FreeCredentialsHandle(krb5->credentials); - free(krb5->credentials); + curlx_free(krb5->credentials); krb5->credentials = NULL; } diff --git a/lib/vauth/ntlm.c b/lib/vauth/ntlm.c index 1e9b629d8f49..a757d1c8f9fd 100644 --- a/lib/vauth/ntlm.c +++ b/lib/vauth/ntlm.c @@ -48,10 +48,6 @@ #include "vauth.h" #include "../curl_endian.h" -/* The last #include files should be: */ -#include "../curl_memory.h" -#include "../memdebug.h" - /* NTLM buffer fixed size, large enough for long user + host + domain */ #define NTLM_BUFSIZE 1024 @@ -282,7 +278,7 @@ static CURLcode ntlm_decode_type2_target(struct Curl_easy *data, return CURLE_BAD_CONTENT_ENCODING; } - free(ntlm->target_info); /* replace any previous data */ + curlx_free(ntlm->target_info); /* replace any previous data */ ntlm->target_info = Curl_memdup(&type2[target_info_offset], target_info_len); if(!ntlm->target_info) @@ -842,7 +838,7 @@ CURLcode Curl_auth_create_ntlm_type3_message(struct Curl_easy *data, result = Curl_bufref_memdup(out, ntlmbuf, size); error: - free(ntlmv2resp); /* Free the dynamic buffer allocated for NTLMv2 */ + curlx_free(ntlmv2resp); /* Free the dynamic buffer allocated for NTLMv2 */ Curl_auth_cleanup_ntlm(ntlm); diff --git a/lib/vauth/ntlm_sspi.c b/lib/vauth/ntlm_sspi.c index 071617182e7e..d976bc5d2131 100644 --- a/lib/vauth/ntlm_sspi.c +++ b/lib/vauth/ntlm_sspi.c @@ -36,10 +36,6 @@ #include "../sendf.h" #include "../strdup.h" -/* The last #include files should be: */ -#include "../curl_memory.h" -#include "../memdebug.h" - /* * Curl_auth_is_ntlm_supported() * @@ -117,7 +113,7 @@ CURLcode Curl_auth_create_ntlm_type1_message(struct Curl_easy *data, Curl_pSecFn->FreeContextBuffer(SecurityPackage); /* Allocate our output buffer */ - ntlm->output_token = malloc(ntlm->token_max); + ntlm->output_token = curlx_malloc(ntlm->token_max); if(!ntlm->output_token) return CURLE_OUT_OF_MEMORY; @@ -137,7 +133,7 @@ CURLcode Curl_auth_create_ntlm_type1_message(struct Curl_easy *data, ntlm->p_identity = NULL; /* Allocate our credentials handle */ - ntlm->credentials = calloc(1, sizeof(CredHandle)); + ntlm->credentials = curlx_calloc(1, sizeof(CredHandle)); if(!ntlm->credentials) return CURLE_OUT_OF_MEMORY; @@ -151,7 +147,7 @@ CURLcode Curl_auth_create_ntlm_type1_message(struct Curl_easy *data, return CURLE_LOGIN_DENIED; /* Allocate our new context handle */ - ntlm->context = calloc(1, sizeof(CtxtHandle)); + ntlm->context = curlx_calloc(1, sizeof(CtxtHandle)); if(!ntlm->context) return CURLE_OUT_OF_MEMORY; @@ -343,14 +339,14 @@ void Curl_auth_cleanup_ntlm(struct ntlmdata *ntlm) /* Free our security context */ if(ntlm->context) { Curl_pSecFn->DeleteSecurityContext(ntlm->context); - free(ntlm->context); + curlx_free(ntlm->context); ntlm->context = NULL; } /* Free our credentials handle */ if(ntlm->credentials) { Curl_pSecFn->FreeCredentialsHandle(ntlm->credentials); - free(ntlm->credentials); + curlx_free(ntlm->credentials); ntlm->credentials = NULL; } diff --git a/lib/vauth/oauth2.c b/lib/vauth/oauth2.c index cf7addf53597..0bb7a9d6bdab 100644 --- a/lib/vauth/oauth2.c +++ b/lib/vauth/oauth2.c @@ -36,10 +36,6 @@ #include "vauth.h" #include "../curlx/warnless.h" -/* The last #include files should be: */ -#include "../curl_memory.h" -#include "../memdebug.h" - /* * Curl_auth_create_oauth_bearer_message() * diff --git a/lib/vauth/spnego_gssapi.c b/lib/vauth/spnego_gssapi.c index 4e9125ba4400..f956f2c03e81 100644 --- a/lib/vauth/spnego_gssapi.c +++ b/lib/vauth/spnego_gssapi.c @@ -38,10 +38,6 @@ #include "../curlx/multibyte.h" #include "../sendf.h" -/* The last #include files should be: */ -#include "../curl_memory.h" -#include "../memdebug.h" - #if defined(__GNUC__) && defined(__APPLE__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wdeprecated-declarations" @@ -131,12 +127,12 @@ CURLcode Curl_auth_decode_spnego_message(struct Curl_easy *data, Curl_gss_log_error(data, "gss_import_name() failed: ", major_status, minor_status); - free(spn); + curlx_free(spn); return CURLE_AUTH_ERROR; } - free(spn); + curlx_free(spn); } if(chlg64 && *chlg64) { diff --git a/lib/vauth/spnego_sspi.c b/lib/vauth/spnego_sspi.c index b36535557bd9..90e622da3d4e 100644 --- a/lib/vauth/spnego_sspi.c +++ b/lib/vauth/spnego_sspi.c @@ -38,10 +38,6 @@ #include "../sendf.h" #include "../strerror.h" -/* The last #include files should be: */ -#include "../curl_memory.h" -#include "../memdebug.h" - /* * Curl_auth_is_spnego_supported() * @@ -140,7 +136,7 @@ CURLcode Curl_auth_decode_spnego_message(struct Curl_easy *data, Curl_pSecFn->FreeContextBuffer(SecurityPackage); /* Allocate our output buffer */ - nego->output_token = malloc(nego->token_max); + nego->output_token = curlx_malloc(nego->token_max); if(!nego->output_token) return CURLE_OUT_OF_MEMORY; } @@ -161,7 +157,7 @@ CURLcode Curl_auth_decode_spnego_message(struct Curl_easy *data, nego->p_identity = NULL; /* Allocate our credentials handle */ - nego->credentials = calloc(1, sizeof(CredHandle)); + nego->credentials = curlx_calloc(1, sizeof(CredHandle)); if(!nego->credentials) return CURLE_OUT_OF_MEMORY; @@ -175,7 +171,7 @@ CURLcode Curl_auth_decode_spnego_message(struct Curl_easy *data, return CURLE_AUTH_ERROR; /* Allocate our new context handle */ - nego->context = calloc(1, sizeof(CtxtHandle)); + nego->context = curlx_calloc(1, sizeof(CtxtHandle)); if(!nego->context) return CURLE_OUT_OF_MEMORY; } @@ -248,7 +244,7 @@ CURLcode Curl_auth_decode_spnego_message(struct Curl_easy *data, &resp_desc, &attrs, NULL); /* Free the decoded challenge as it is not required anymore */ - free(chlg); + curlx_free(chlg); if(GSS_ERROR(nego->status)) { char buffer[STRERROR_LEN]; @@ -305,7 +301,7 @@ CURLcode Curl_auth_create_spnego_message(struct negotiatedata *nego, nego->output_token_length, outptr, outlen); if(!result && (!*outptr || !*outlen)) { - free(*outptr); + curlx_free(*outptr); result = CURLE_REMOTE_ACCESS_DENIED; } @@ -327,14 +323,14 @@ void Curl_auth_cleanup_spnego(struct negotiatedata *nego) /* Free our security context */ if(nego->context) { Curl_pSecFn->DeleteSecurityContext(nego->context); - free(nego->context); + curlx_free(nego->context); nego->context = NULL; } /* Free our credentials handle */ if(nego->credentials) { Curl_pSecFn->FreeCredentialsHandle(nego->credentials); - free(nego->credentials); + curlx_free(nego->credentials); nego->credentials = NULL; } diff --git a/lib/vauth/vauth.c b/lib/vauth/vauth.c index 6ee687dcab22..6626ace8bc6a 100644 --- a/lib/vauth/vauth.c +++ b/lib/vauth/vauth.c @@ -32,10 +32,6 @@ #include "../curlx/multibyte.h" #include "../url.h" -/* The last #include files should be: */ -#include "../curl_memory.h" -#include "../memdebug.h" - /* * Curl_auth_build_spn() * @@ -96,10 +92,10 @@ TCHAR *Curl_auth_build_spn(const char *service, const char *host, must be freed by curlx_unicodefree we will dupe the result so that the pointer this function returns can be normally free'd. */ tchar_spn = curlx_convert_UTF8_to_tchar(utf8_spn); - free(utf8_spn); + curlx_free(utf8_spn); if(!tchar_spn) return NULL; - dupe_tchar_spn = Curl_tcsdup(tchar_spn); + dupe_tchar_spn = curlx_tcsdup(tchar_spn); curlx_unicodefree(tchar_spn); return dupe_tchar_spn; } @@ -170,7 +166,7 @@ static void ntlm_conn_dtor(void *key, size_t klen, void *entry) (void)klen; DEBUGASSERT(ntlm); Curl_auth_cleanup_ntlm(ntlm); - free(ntlm); + curlx_free(ntlm); } struct ntlmdata *Curl_auth_ntlm_get(struct connectdata *conn, bool proxy) @@ -179,7 +175,7 @@ struct ntlmdata *Curl_auth_ntlm_get(struct connectdata *conn, bool proxy) CURL_META_NTLM_CONN; struct ntlmdata *ntlm = Curl_conn_meta_get(conn, key); if(!ntlm) { - ntlm = calloc(1, sizeof(*ntlm)); + ntlm = curlx_calloc(1, sizeof(*ntlm)); if(!ntlm || Curl_conn_meta_set(conn, key, ntlm, ntlm_conn_dtor)) return NULL; @@ -204,14 +200,14 @@ static void krb5_conn_dtor(void *key, size_t klen, void *entry) (void)klen; DEBUGASSERT(krb5); Curl_auth_cleanup_gssapi(krb5); - free(krb5); + curlx_free(krb5); } struct kerberos5data *Curl_auth_krb5_get(struct connectdata *conn) { struct kerberos5data *krb5 = Curl_conn_meta_get(conn, CURL_META_KRB5_CONN); if(!krb5) { - krb5 = calloc(1, sizeof(*krb5)); + krb5 = curlx_calloc(1, sizeof(*krb5)); if(!krb5 || Curl_conn_meta_set(conn, CURL_META_KRB5_CONN, krb5, krb5_conn_dtor)) return NULL; @@ -230,14 +226,14 @@ static void gsasl_conn_dtor(void *key, size_t klen, void *entry) (void)klen; DEBUGASSERT(gsasl); Curl_auth_gsasl_cleanup(gsasl); - free(gsasl); + curlx_free(gsasl); } struct gsasldata *Curl_auth_gsasl_get(struct connectdata *conn) { struct gsasldata *gsasl = Curl_conn_meta_get(conn, CURL_META_GSASL_CONN); if(!gsasl) { - gsasl = calloc(1, sizeof(*gsasl)); + gsasl = curlx_calloc(1, sizeof(*gsasl)); if(!gsasl || Curl_conn_meta_set(conn, CURL_META_GSASL_CONN, gsasl, gsasl_conn_dtor)) return NULL; @@ -256,7 +252,7 @@ static void nego_conn_dtor(void *key, size_t klen, void *entry) (void)klen; DEBUGASSERT(nego); Curl_auth_cleanup_spnego(nego); - free(nego); + curlx_free(nego); } struct negotiatedata *Curl_auth_nego_get(struct connectdata *conn, bool proxy) @@ -265,7 +261,7 @@ struct negotiatedata *Curl_auth_nego_get(struct connectdata *conn, bool proxy) CURL_META_NEGO_CONN; struct negotiatedata *nego = Curl_conn_meta_get(conn, key); if(!nego) { - nego = calloc(1, sizeof(*nego)); + nego = curlx_calloc(1, sizeof(*nego)); if(!nego || Curl_conn_meta_set(conn, key, nego, nego_conn_dtor)) return NULL; diff --git a/lib/vquic/curl_ngtcp2.c b/lib/vquic/curl_ngtcp2.c index 86f7428048e1..4767780a922d 100644 --- a/lib/vquic/curl_ngtcp2.c +++ b/lib/vquic/curl_ngtcp2.c @@ -71,10 +71,6 @@ #include "../curlx/warnless.h" -/* The last 2 #include files should be in this order */ -#include "../curl_memory.h" -#include "../memdebug.h" - #define QUIC_MAX_STREAMS (256*1024) #define QUIC_HANDSHAKE_TIMEOUT (10*NGTCP2_SECONDS) @@ -182,7 +178,7 @@ static void cf_ngtcp2_ctx_free(struct cf_ngtcp2_ctx *ctx) Curl_uint32_hash_destroy(&ctx->streams); Curl_ssl_peer_cleanup(&ctx->peer); } - free(ctx); + curlx_free(ctx); } static void cf_ngtcp2_setup_keep_alive(struct Curl_cfilter *cf, @@ -255,7 +251,7 @@ static void h3_stream_ctx_free(struct h3_stream_ctx *stream) { Curl_bufq_free(&stream->sendbuf); Curl_h1_req_parse_free(&stream->h1); - free(stream); + curlx_free(stream); } static void h3_stream_hash_free(unsigned int id, void *stream) @@ -277,7 +273,7 @@ static CURLcode h3_data_setup(struct Curl_cfilter *cf, if(stream) return CURLE_OK; - stream = calloc(1, sizeof(*stream)); + stream = curlx_calloc(1, sizeof(*stream)); if(!stream) return CURLE_OUT_OF_MEMORY; @@ -1573,7 +1569,7 @@ static CURLcode h3_stream_open(struct Curl_cfilter *cf, Curl_h1_req_parse_free(&stream->h1); nheader = Curl_dynhds_count(&h2_headers); - nva = malloc(sizeof(nghttp3_nv) * nheader); + nva = curlx_malloc(sizeof(nghttp3_nv) * nheader); if(!nva) { result = CURLE_OUT_OF_MEMORY; goto out; @@ -1650,7 +1646,7 @@ static CURLcode h3_stream_open(struct Curl_cfilter *cf, } out: - free(nva); + curlx_free(nva); Curl_dynhds_free(&h2_headers); return result; } @@ -2851,7 +2847,7 @@ CURLcode Curl_cf_ngtcp2_create(struct Curl_cfilter **pcf, CURLcode result; (void)data; - ctx = calloc(1, sizeof(*ctx)); + ctx = curlx_calloc(1, sizeof(*ctx)); if(!ctx) { result = CURLE_OUT_OF_MEMORY; goto out; diff --git a/lib/vquic/curl_osslq.c b/lib/vquic/curl_osslq.c index d6672ce13252..1c3f0c55b66e 100644 --- a/lib/vquic/curl_osslq.c +++ b/lib/vquic/curl_osslq.c @@ -57,10 +57,6 @@ #include "../curlx/warnless.h" #include "../curlx/strerr.h" -/* The last 2 #include files should be in this order */ -#include "../curl_memory.h" -#include "../memdebug.h" - /* A stream window is the maximum amount we need to buffer for * each active transfer. We use HTTP/3 flow control and only ACK * when we take things out of the buffer. @@ -318,10 +314,10 @@ static void cf_osslq_ctx_free(struct cf_osslq_ctx *ctx) Curl_bufcp_free(&ctx->stream_bufcp); Curl_uint32_hash_destroy(&ctx->streams); Curl_ssl_peer_cleanup(&ctx->peer); - free(ctx->poll_items); - free(ctx->curl_items); + curlx_free(ctx->poll_items); + curlx_free(ctx->curl_items); } - free(ctx); + curlx_free(ctx); } static void cf_osslq_ctx_close(struct cf_osslq_ctx *ctx) @@ -596,7 +592,7 @@ static void h3_stream_ctx_free(struct h3_stream_ctx *stream) Curl_bufq_free(&stream->sendbuf); Curl_bufq_free(&stream->recvbuf); Curl_h1_req_parse_free(&stream->h1); - free(stream); + curlx_free(stream); } static void h3_stream_hash_free(unsigned int id, void *stream) @@ -618,7 +614,7 @@ static CURLcode h3_data_setup(struct Curl_cfilter *cf, if(stream) return CURLE_OK; - stream = calloc(1, sizeof(*stream)); + stream = curlx_calloc(1, sizeof(*stream)); if(!stream) return CURLE_OUT_OF_MEMORY; @@ -1511,18 +1507,19 @@ static CURLcode cf_osslq_check_and_unblock(struct Curl_cfilter *cf, if(ctx->items_max < Curl_uint32_hash_count(&ctx->streams)) { size_t nmax = Curl_uint32_hash_count(&ctx->streams); ctx->items_max = 0; - tmpptr = realloc(ctx->poll_items, nmax * sizeof(SSL_POLL_ITEM)); + tmpptr = curlx_realloc(ctx->poll_items, nmax * sizeof(SSL_POLL_ITEM)); if(!tmpptr) { - free(ctx->poll_items); + curlx_free(ctx->poll_items); ctx->poll_items = NULL; res = CURLE_OUT_OF_MEMORY; goto out; } ctx->poll_items = tmpptr; - tmpptr = realloc(ctx->curl_items, nmax * sizeof(struct Curl_easy *)); + tmpptr = curlx_realloc(ctx->curl_items, + nmax * sizeof(struct Curl_easy *)); if(!tmpptr) { - free(ctx->curl_items); + curlx_free(ctx->curl_items); ctx->curl_items = NULL; res = CURLE_OUT_OF_MEMORY; goto out; @@ -1922,7 +1919,7 @@ static CURLcode h3_stream_open(struct Curl_cfilter *cf, Curl_h1_req_parse_free(&stream->h1); nheader = Curl_dynhds_count(&h2_headers); - nva = malloc(sizeof(nghttp3_nv) * nheader); + nva = curlx_malloc(sizeof(nghttp3_nv) * nheader); if(!nva) { result = CURLE_OUT_OF_MEMORY; goto out; @@ -1999,7 +1996,7 @@ static CURLcode h3_stream_open(struct Curl_cfilter *cf, } out: - free(nva); + curlx_free(nva); Curl_dynhds_free(&h2_headers); return result; } @@ -2407,7 +2404,7 @@ CURLcode Curl_cf_osslq_create(struct Curl_cfilter **pcf, CURLcode result; (void)data; - ctx = calloc(1, sizeof(*ctx)); + ctx = curlx_calloc(1, sizeof(*ctx)); if(!ctx) { result = CURLE_OUT_OF_MEMORY; goto out; diff --git a/lib/vquic/curl_quiche.c b/lib/vquic/curl_quiche.c index f8fbadeebb1f..c182e1490d23 100644 --- a/lib/vquic/curl_quiche.c +++ b/lib/vquic/curl_quiche.c @@ -52,10 +52,6 @@ #include "../vtls/keylog.h" #include "../vtls/vtls.h" -/* The last 2 #include files should be in this order */ -#include "../curl_memory.h" -#include "../memdebug.h" - /* HTTP/3 error values defined in RFC 9114, ch. 8.1 */ #define CURL_H3_NO_ERROR (0x0100) @@ -141,7 +137,7 @@ static void cf_quiche_ctx_free(struct cf_quiche_ctx *ctx) Curl_bufcp_free(&ctx->stream_bufcp); Curl_uint32_hash_destroy(&ctx->streams); } - free(ctx); + curlx_free(ctx); } static void cf_quiche_ctx_close(struct cf_quiche_ctx *ctx) @@ -188,7 +184,7 @@ static void h3_stream_ctx_free(struct h3_stream_ctx *stream) { Curl_bufq_free(&stream->recvbuf); Curl_h1_req_parse_free(&stream->h1); - free(stream); + curlx_free(stream); } static void h3_stream_hash_free(unsigned int id, void *stream) @@ -269,7 +265,7 @@ static CURLcode h3_data_setup(struct Curl_cfilter *cf, if(stream) return CURLE_OK; - stream = calloc(1, sizeof(*stream)); + stream = curlx_calloc(1, sizeof(*stream)); if(!stream) return CURLE_OUT_OF_MEMORY; @@ -1000,7 +996,7 @@ static CURLcode h3_open_stream(struct Curl_cfilter *cf, Curl_h1_req_parse_free(&stream->h1); nheader = Curl_dynhds_count(&h2_headers); - nva = malloc(sizeof(quiche_h3_header) * nheader); + nva = curlx_malloc(sizeof(quiche_h3_header) * nheader); if(!nva) { result = CURLE_OUT_OF_MEMORY; goto out; @@ -1070,7 +1066,7 @@ static CURLcode h3_open_stream(struct Curl_cfilter *cf, } out: - free(nva); + curlx_free(nva); Curl_dynhds_free(&h2_headers); return result; } @@ -1633,7 +1629,7 @@ CURLcode Curl_cf_quiche_create(struct Curl_cfilter **pcf, (void)data; (void)conn; - ctx = calloc(1, sizeof(*ctx)); + ctx = curlx_calloc(1, sizeof(*ctx)); if(!ctx) { result = CURLE_OUT_OF_MEMORY; goto out; diff --git a/lib/vquic/vquic-tls.c b/lib/vquic/vquic-tls.c index 46bb4c7d4c25..7a3c99b58441 100644 --- a/lib/vquic/vquic-tls.c +++ b/lib/vquic/vquic-tls.c @@ -53,10 +53,6 @@ #include "../vtls/vtls_scache.h" #include "vquic-tls.h" -/* The last 2 #include files should be in this order */ -#include "../curl_memory.h" -#include "../memdebug.h" - CURLcode Curl_vquic_tls_init(struct curl_tls_ctx *ctx, struct Curl_cfilter *cf, struct Curl_easy *data, diff --git a/lib/vquic/vquic.c b/lib/vquic/vquic.c index 8b4d678d8118..c1267cef9ed0 100644 --- a/lib/vquic/vquic.c +++ b/lib/vquic/vquic.c @@ -47,10 +47,6 @@ #include "../curlx/strerr.h" #include "../curlx/strparse.h" -/* The last 2 #include files should be in this order */ -#include "../curl_memory.h" -#include "../memdebug.h" - #if !defined(CURL_DISABLE_HTTP) && defined(USE_HTTP3) @@ -675,7 +671,7 @@ CURLcode Curl_qlogdir(struct Curl_easy *data, *qlogfdp = qlogfd; } curlx_dyn_free(&fname); - free(qlog_dir); + curlx_free(qlog_dir); if(result) return result; } diff --git a/lib/vssh/libssh.c b/lib/vssh/libssh.c index 4b003bd71ca9..a5997a6f6cf9 100644 --- a/lib/vssh/libssh.c +++ b/lib/vssh/libssh.c @@ -72,10 +72,6 @@ #include #endif -/* The last 2 #include files should be in this order */ -#include "../curl_memory.h" -#include "../memdebug.h" - /* A recent macro provided by libssh. Or make our own. */ #ifndef SSH_STRING_FREE_CHAR #define SSH_STRING_FREE_CHAR(x) \ @@ -491,10 +487,12 @@ static int myssh_is_known(struct Curl_easy *data, struct ssh_conn *sshc) cleanup: if(found_base64) { - (free)(found_base64); + /* !checksrc! disable BANNEDFUNC 1 */ + free(found_base64); /* allocated by libssh, deallocate with system free */ } if(known_base64) { - (free)(known_base64); + /* !checksrc! disable BANNEDFUNC 1 */ + free(known_base64); /* allocated by libssh, deallocate with system free */ } if(hash) ssh_clean_pubkey_hash(&hash); @@ -605,7 +603,7 @@ static int myssh_in_SFTP_READDIR(struct Curl_easy *data, } result = Curl_client_write(data, CLIENTWRITE_BODY, tmpLine, sshc->readdir_len + 1); - free(tmpLine); + curlx_free(tmpLine); if(result) { myssh_to(data, sshc, SSH_STOP); @@ -787,7 +785,7 @@ static int myssh_in_SFTP_QUOTE_STATVFS(struct Curl_easy *data, if(!result) { result = Curl_client_write(data, CLIENTWRITE_HEADER, tmp, strlen(tmp)); - free(tmp); + curlx_free(tmp); } if(result) { myssh_to(data, sshc, SSH_SFTP_CLOSE); @@ -1478,8 +1476,8 @@ static int myssh_in_SFTP_REALPATH(struct Curl_easy *data, if(!sshc->homedir) return myssh_to_ERROR(data, sshc, CURLE_COULDNT_CONNECT); - free(data->state.most_recent_ftp_entrypath); - data->state.most_recent_ftp_entrypath = strdup(sshc->homedir); + curlx_free(data->state.most_recent_ftp_entrypath); + data->state.most_recent_ftp_entrypath = curlx_strdup(sshc->homedir); if(!data->state.most_recent_ftp_entrypath) return myssh_to_ERROR(data, sshc, CURLE_OUT_OF_MEMORY); @@ -1577,7 +1575,7 @@ static int myssh_in_SFTP_QUOTE(struct Curl_easy *data, the current directory can be read similar to how it is read when using ordinary FTP. */ result = Curl_client_write(data, CLIENTWRITE_HEADER, tmp, strlen(tmp)); - free(tmp); + curlx_free(tmp); if(result) { myssh_to(data, sshc, SSH_SFTP_CLOSE); sshc->nextstate = SSH_NO_STATE; @@ -2529,7 +2527,7 @@ static void myssh_easy_dtor(void *key, size_t klen, void *entry) (void)key; (void)klen; Curl_safefree(sshp->path); - free(sshp); + curlx_free(sshp); } static void myssh_conn_dtor(void *key, size_t klen, void *entry) @@ -2538,7 +2536,7 @@ static void myssh_conn_dtor(void *key, size_t klen, void *entry) (void)key; (void)klen; sshc_cleanup(sshc); - free(sshc); + curlx_free(sshc); } /* @@ -2550,7 +2548,7 @@ static CURLcode myssh_setup_connection(struct Curl_easy *data, struct SSHPROTO *sshp; struct ssh_conn *sshc; - sshc = calloc(1, sizeof(*sshc)); + sshc = curlx_calloc(1, sizeof(*sshc)); if(!sshc) return CURLE_OUT_OF_MEMORY; @@ -2559,7 +2557,7 @@ static CURLcode myssh_setup_connection(struct Curl_easy *data, if(Curl_conn_meta_set(conn, CURL_META_SSH_CONN, sshc, myssh_conn_dtor)) return CURLE_OUT_OF_MEMORY; - sshp = calloc(1, sizeof(*sshp)); + sshp = curlx_calloc(1, sizeof(*sshp)); if(!sshp || Curl_meta_set(data, CURL_META_SSH_EASY, sshp, myssh_easy_dtor)) return CURLE_OUT_OF_MEMORY; diff --git a/lib/vssh/libssh2.c b/lib/vssh/libssh2.c index e4ceda8c3494..4ac9d89f1ad5 100644 --- a/lib/vssh/libssh2.c +++ b/lib/vssh/libssh2.c @@ -66,10 +66,6 @@ #include "../curlx/strparse.h" #include "../curlx/base64.h" /* for base64 encoding/decoding */ -/* The last 2 #include files should be in this order */ -#include "../curl_memory.h" -#include "../memdebug.h" - /* Local functions: */ static const char *sftp_libssh2_strerror(unsigned long err); static LIBSSH2_ALLOC_FUNC(my_libssh2_malloc); @@ -181,7 +177,7 @@ kbd_callback(const char *name, int name_len, const char *instruction, #endif /* CURL_LIBSSH2_DEBUG */ if(num_prompts == 1) { struct connectdata *conn = data->conn; - responses[0].text = strdup(conn->passwd); + responses[0].text = curlx_strdup(conn->passwd); responses[0].length = responses[0].text == NULL ? 0 : curlx_uztoui(strlen(conn->passwd)); } @@ -635,12 +631,12 @@ static CURLcode ssh_check_fingerprint(struct Curl_easy *data, failf(data, "Denied establishing ssh session: mismatch sha256 fingerprint. " "Remote %s is not equal to %s", fingerprint_b64, pubkey_sha256); - free(fingerprint_b64); + curlx_free(fingerprint_b64); myssh_state(data, sshc, SSH_SESSION_FREE); return CURLE_PEER_FAILED_VERIFICATION; } - free(fingerprint_b64); + curlx_free(fingerprint_b64); infof(data, "SHA256 checksum match"); } @@ -881,7 +877,7 @@ static CURLcode sftp_quote(struct Curl_easy *data, the current directory can be read similar to how it is read when using ordinary FTP. */ result = Curl_client_write(data, CLIENTWRITE_HEADER, tmp, strlen(tmp)); - free(tmp); + curlx_free(tmp); if(!result) myssh_state(data, sshc, SSH_SFTP_NEXT_QUOTE); return result; @@ -1204,7 +1200,7 @@ static CURLcode ssh_state_pkey_init(struct Curl_easy *data, sshc->rsa_pub = sshc->rsa = NULL; if(data->set.str[STRING_SSH_PRIVATE_KEY]) - sshc->rsa = strdup(data->set.str[STRING_SSH_PRIVATE_KEY]); + sshc->rsa = curlx_strdup(data->set.str[STRING_SSH_PRIVATE_KEY]); else { /* To ponder about: should really the lib be messing about with the HOME environment variable etc? */ @@ -1218,7 +1214,7 @@ static CURLcode ssh_state_pkey_init(struct Curl_easy *data, if(!sshc->rsa) out_of_memory = TRUE; else if(curlx_stat(sshc->rsa, &sbuf)) { - free(sshc->rsa); + curlx_free(sshc->rsa); sshc->rsa = curl_maprintf("%s/.ssh/id_dsa", home); if(!sshc->rsa) out_of_memory = TRUE; @@ -1226,19 +1222,19 @@ static CURLcode ssh_state_pkey_init(struct Curl_easy *data, Curl_safefree(sshc->rsa); } } - free(home); + curlx_free(home); } if(!out_of_memory && !sshc->rsa) { /* Nothing found; try the current dir. */ - sshc->rsa = strdup("id_rsa"); + sshc->rsa = curlx_strdup("id_rsa"); if(sshc->rsa && curlx_stat(sshc->rsa, &sbuf)) { - free(sshc->rsa); - sshc->rsa = strdup("id_dsa"); + curlx_free(sshc->rsa); + sshc->rsa = curlx_strdup("id_dsa"); if(sshc->rsa && curlx_stat(sshc->rsa, &sbuf)) { - free(sshc->rsa); + curlx_free(sshc->rsa); /* Out of guesses. Set to the empty string to avoid * surprising info messages. */ - sshc->rsa = strdup(""); + sshc->rsa = curlx_strdup(""); } } } @@ -1252,7 +1248,7 @@ static CURLcode ssh_state_pkey_init(struct Curl_easy *data, if(data->set.str[STRING_SSH_PUBLIC_KEY] /* treat empty string the same way as NULL */ && data->set.str[STRING_SSH_PUBLIC_KEY][0]) { - sshc->rsa_pub = strdup(data->set.str[STRING_SSH_PUBLIC_KEY]); + sshc->rsa_pub = curlx_strdup(data->set.str[STRING_SSH_PUBLIC_KEY]); if(!sshc->rsa_pub) out_of_memory = TRUE; } @@ -1936,12 +1932,12 @@ static CURLcode ssh_state_sftp_realpath(struct Curl_easy *data, myssh_state(data, sshc, SSH_STOP); if(rc > 0) { - free(sshc->homedir); - sshc->homedir = strdup(sshp->readdir_filename); + curlx_free(sshc->homedir); + sshc->homedir = curlx_strdup(sshp->readdir_filename); if(!sshc->homedir) return CURLE_OUT_OF_MEMORY; - free(data->state.most_recent_ftp_entrypath); - data->state.most_recent_ftp_entrypath = strdup(sshc->homedir); + curlx_free(data->state.most_recent_ftp_entrypath); + data->state.most_recent_ftp_entrypath = curlx_strdup(sshc->homedir); if(!data->state.most_recent_ftp_entrypath) return CURLE_OUT_OF_MEMORY; } @@ -2251,7 +2247,7 @@ static CURLcode ssh_state_sftp_quote_statvfs(struct Curl_easy *data, } result = Curl_client_write(data, CLIENTWRITE_HEADER, tmp, strlen(tmp)); - free(tmp); + curlx_free(tmp); if(result) { myssh_state(data, sshc, SSH_SFTP_CLOSE); sshc->nextstate = SSH_NO_STATE; @@ -3177,7 +3173,7 @@ static void myssh_easy_dtor(void *key, size_t klen, void *entry) Curl_safefree(sshp->path); curlx_dyn_free(&sshp->readdir); curlx_dyn_free(&sshp->readdir_link); - free(sshp); + curlx_free(sshp); } static void myssh_conn_dtor(void *key, size_t klen, void *entry) @@ -3186,7 +3182,7 @@ static void myssh_conn_dtor(void *key, size_t klen, void *entry) (void)key; (void)klen; sshc_cleanup(sshc, NULL, TRUE); - free(sshc); + curlx_free(sshc); } /* @@ -3199,14 +3195,14 @@ static CURLcode ssh_setup_connection(struct Curl_easy *data, struct SSHPROTO *sshp; (void)conn; - sshc = calloc(1, sizeof(*sshc)); + sshc = curlx_calloc(1, sizeof(*sshc)); if(!sshc) return CURLE_OUT_OF_MEMORY; if(Curl_conn_meta_set(conn, CURL_META_SSH_CONN, sshc, myssh_conn_dtor)) return CURLE_OUT_OF_MEMORY; - sshp = calloc(1, sizeof(*sshp)); + sshp = curlx_calloc(1, sizeof(*sshp)); if(!sshp) return CURLE_OUT_OF_MEMORY; diff --git a/lib/vssh/vssh.c b/lib/vssh/vssh.c index e33386a16aa5..a23f9e8e981f 100644 --- a/lib/vssh/vssh.c +++ b/lib/vssh/vssh.c @@ -30,9 +30,7 @@ #include #include "../curlx/strparse.h" #include "../curl_trc.h" -#include "../curl_memory.h" #include "../escape.h" -#include "../memdebug.h" #define MAX_SSHPATH_LEN 100000 /* arbitrary */ @@ -59,7 +57,7 @@ CURLcode Curl_getworkingpath(struct Curl_easy *data, (working_path_len > 3) && (!memcmp(working_path, "/~/", 3))) { /* It is referenced to the home directory, so strip the leading '/~/' */ if(curlx_dyn_addn(&npath, &working_path[3], working_path_len - 3)) { - free(working_path); + curlx_free(working_path); return CURLE_OUT_OF_MEMORY; } } @@ -67,7 +65,7 @@ CURLcode Curl_getworkingpath(struct Curl_easy *data, (!strcmp("/~", working_path) || ((working_path_len > 2) && !memcmp(working_path, "/~/", 3)))) { if(curlx_dyn_add(&npath, homedir)) { - free(working_path); + curlx_free(working_path); return CURLE_OUT_OF_MEMORY; } if(working_path_len > 2) { @@ -82,20 +80,20 @@ CURLcode Curl_getworkingpath(struct Curl_easy *data, if(curlx_dyn_addn(&npath, &working_path[copyfrom], working_path_len - copyfrom)) { - free(working_path); + curlx_free(working_path); return CURLE_OUT_OF_MEMORY; } } else { if(curlx_dyn_add(&npath, "/")) { - free(working_path); + curlx_free(working_path); return CURLE_OUT_OF_MEMORY; } } } if(curlx_dyn_len(&npath)) { - free(working_path); + curlx_free(working_path); /* store the pointer for the caller to receive */ *path = curlx_dyn_ptr(&npath); diff --git a/lib/vtls/apple.c b/lib/vtls/apple.c index 297ebc39f393..62bb9e3bd194 100644 --- a/lib/vtls/apple.c +++ b/lib/vtls/apple.c @@ -50,10 +50,6 @@ #include #endif -/* The last #include files should be: */ -#include "../curl_memory.h" -#include "../memdebug.h" - #ifdef USE_APPLE_SECTRUST #define SSL_SYSTEM_VERIFIER @@ -244,11 +240,11 @@ CURLcode Curl_vtls_apple_verify(struct Curl_cfilter *cf, if(error_ref) { CFIndex size = CFStringGetMaximumSizeForEncoding( CFStringGetLength(error_ref), kCFStringEncodingUTF8); - err_desc = malloc(size + 1); + err_desc = curlx_malloc(size + 1); if(err_desc) { if(!CFStringGetCString(error_ref, err_desc, size, kCFStringEncodingUTF8)) { - free(err_desc); + curlx_free(err_desc); err_desc = NULL; } } @@ -276,7 +272,7 @@ CURLcode Curl_vtls_apple_verify(struct Curl_cfilter *cf, } out: - free(err_desc); + curlx_free(err_desc); if(error_ref) CFRelease(error_ref); if(error) diff --git a/lib/vtls/gtls.c b/lib/vtls/gtls.c index 55a75fa72150..c05ab8427b89 100644 --- a/lib/vtls/gtls.c +++ b/lib/vtls/gtls.c @@ -59,9 +59,6 @@ #include "../curlx/warnless.h" #include "x509asn1.h" #include "../multiif.h" -#include "../curl_memory.h" -/* The last #include file should be: */ -#include "../memdebug.h" /* Enable GnuTLS debugging by defining GTLSDEBUG */ /*#define GTLSDEBUG */ @@ -215,10 +212,10 @@ static gnutls_datum_t load_file(const char *file) if(fseek(f, 0, SEEK_END) != 0 || (filelen = ftell(f)) < 0 || fseek(f, 0, SEEK_SET) != 0 - || !(ptr = malloc((size_t)filelen))) + || !(ptr = curlx_malloc((size_t)filelen))) goto out; if(fread(ptr, 1, (size_t)filelen, f) < (size_t)filelen) { - free(ptr); + curlx_free(ptr); goto out; } @@ -231,7 +228,7 @@ static gnutls_datum_t load_file(const char *file) static void unload_file(gnutls_datum_t data) { - free(data.data); + curlx_free(data.data); } @@ -404,14 +401,14 @@ CURLcode Curl_gtls_shared_creds_create(struct Curl_easy *data, int rc; *pcreds = NULL; - shared = calloc(1, sizeof(*shared)); + shared = curlx_calloc(1, sizeof(*shared)); if(!shared) return CURLE_OUT_OF_MEMORY; rc = gnutls_certificate_allocate_credentials(&shared->creds); if(rc != GNUTLS_E_SUCCESS) { failf(data, "gnutls_cert_all_cred() failed: %s", gnutls_strerror(rc)); - free(shared); + curlx_free(shared); return CURLE_SSL_CONNECT_ERROR; } @@ -439,8 +436,8 @@ void Curl_gtls_shared_creds_free(struct gtls_shared_creds **pcreds) --shared->refcount; if(!shared->refcount) { gnutls_certificate_free_credentials(shared->creds); - free(shared->CAfile); - free(shared); + curlx_free(shared->CAfile); + curlx_free(shared); } } } @@ -629,7 +626,7 @@ static void gtls_set_cached_creds(struct Curl_cfilter *cf, return; if(conn_config->CAfile) { - sc->CAfile = strdup(conn_config->CAfile); + sc->CAfile = curlx_strdup(conn_config->CAfile); if(!sc->CAfile) return; } @@ -723,7 +720,7 @@ CURLcode Curl_gtls_cache_session(struct Curl_cfilter *cf, if(!sdata_len) /* gnutls does this for some version combinations */ return CURLE_OK; - sdata = malloc(sdata_len); /* get a buffer for it */ + sdata = curlx_malloc(sdata_len); /* get a buffer for it */ if(!sdata) return CURLE_OUT_OF_MEMORY; @@ -737,7 +734,7 @@ CURLcode Curl_gtls_cache_session(struct Curl_cfilter *cf, if(quic_tp && quic_tp_len) { qtp_clone = Curl_memdup0((char *)quic_tp, quic_tp_len); if(!qtp_clone) { - free(sdata); + curlx_free(sdata); return CURLE_OUT_OF_MEMORY; } } @@ -1312,7 +1309,7 @@ static CURLcode pkp_pin_peer_pubkey(struct Curl_easy *data, if(ret != GNUTLS_E_SHORT_MEMORY_BUFFER || len1 == 0) break; /* failed */ - buff1 = malloc(len1); + buff1 = curlx_malloc(len1); if(!buff1) break; /* failed */ diff --git a/lib/vtls/hostcheck.c b/lib/vtls/hostcheck.c index 23ba33951f17..672f473db42a 100644 --- a/lib/vtls/hostcheck.c +++ b/lib/vtls/hostcheck.c @@ -37,10 +37,6 @@ #include "hostcheck.h" #include "../hostip.h" -#include "../curl_memory.h" -/* The last #include file should be: */ -#include "../memdebug.h" - /* check the two input strings with given length, but do not assume they end in nul-bytes */ static bool pmatch(const char *hostname, size_t hostlen, diff --git a/lib/vtls/keylog.c b/lib/vtls/keylog.c index 9179d38fe76f..397bac1a366a 100644 --- a/lib/vtls/keylog.c +++ b/lib/vtls/keylog.c @@ -35,10 +35,6 @@ #include "../escape.h" #include "../curlx/fopen.h" -/* The last #include files should be: */ -#include "../curl_memory.h" -#include "../memdebug.h" - /* The fp for the open SSLKEYLOGFILE, or NULL if not open */ static FILE *keylog_file_fp; diff --git a/lib/vtls/mbedtls.c b/lib/vtls/mbedtls.c index 2ea3670c1bf2..9e13ed4641d9 100644 --- a/lib/vtls/mbedtls.c +++ b/lib/vtls/mbedtls.c @@ -75,10 +75,6 @@ #include "../strdup.h" #include "../curl_sha256.h" -/* The last 2 #include files should be in this order */ -#include "../curl_memory.h" -#include "../memdebug.h" - /* ALPN for http2 */ #if defined(USE_HTTP2) && defined(MBEDTLS_SSL_ALPN) # define HAS_ALPN_MBEDTLS @@ -355,7 +351,7 @@ mbed_set_selected_ciphers(struct Curl_easy *data, for(i = 0; supported[i] != 0; i++); supported_len = i; - selected = malloc(sizeof(int) * (supported_len + 1)); + selected = curlx_malloc(sizeof(int) * (supported_len + 1)); if(!selected) return CURLE_OUT_OF_MEMORY; @@ -433,7 +429,7 @@ mbed_set_selected_ciphers(struct Curl_easy *data, selected[count] = 0; if(count == 0) { - free(selected); + curlx_free(selected); failf(data, "mbedTLS: no supported cipher in list"); return CURLE_SSL_CIPHER; } @@ -452,7 +448,7 @@ mbed_dump_cert_info(struct Curl_easy *data, const mbedtls_x509_crt *crt) (void)data, (void)crt; #else const size_t bufsize = 16384; - char *p, *buffer = malloc(bufsize); + char *p, *buffer = curlx_malloc(bufsize); if(buffer && mbedtls_x509_crt_info(buffer, bufsize, " ", crt) > 0) { infof(data, "Server certificate:"); @@ -465,7 +461,7 @@ mbed_dump_cert_info(struct Curl_easy *data, const mbedtls_x509_crt *crt) else infof(data, "Unable to dump certificate information"); - free(buffer); + curlx_free(buffer); #endif } @@ -597,7 +593,7 @@ mbed_connect_step1(struct Curl_cfilter *cf, struct Curl_easy *data) return CURLE_OUT_OF_MEMORY; ret = mbedtls_x509_crt_parse(&backend->cacert, newblob, ca_info_blob->len + 1); - free(newblob); + curlx_free(newblob); if(ret < 0) { mbedtls_strerror(ret, errorbuf, sizeof(errorbuf)); failf(data, "Error importing ca cert blob - mbedTLS: (-0x%04X) %s", @@ -670,7 +666,7 @@ mbed_connect_step1(struct Curl_cfilter *cf, struct Curl_easy *data) return CURLE_OUT_OF_MEMORY; ret = mbedtls_x509_crt_parse(&backend->clicert, newblob, ssl_cert_blob->len + 1); - free(newblob); + curlx_free(newblob); if(ret) { mbedtls_strerror(ret, errorbuf, sizeof(errorbuf)); @@ -1027,12 +1023,12 @@ mbed_connect_step2(struct Curl_cfilter *cf, struct Curl_easy *data) return CURLE_SSL_PINNEDPUBKEYNOTMATCH; } - p = calloc(1, sizeof(*p)); + p = curlx_calloc(1, sizeof(*p)); if(!p) return CURLE_OUT_OF_MEMORY; - pubkey = malloc(PUB_DER_MAX_BYTES); + pubkey = curlx_malloc(PUB_DER_MAX_BYTES); if(!pubkey) { result = CURLE_OUT_OF_MEMORY; @@ -1064,8 +1060,8 @@ mbed_connect_step2(struct Curl_cfilter *cf, struct Curl_easy *data) &pubkey[PUB_DER_MAX_BYTES - size], size); pinnedpubkey_error: mbedtls_x509_crt_free(p); - free(p); - free(pubkey); + curlx_free(p); + curlx_free(pubkey); if(result) return result; } @@ -1122,7 +1118,7 @@ mbed_new_session(struct Curl_cfilter *cf, struct Curl_easy *data) goto out; } - sdata = malloc(slen); + sdata = curlx_malloc(slen); if(!sdata) { result = CURLE_OUT_OF_MEMORY; goto out; @@ -1147,7 +1143,7 @@ mbed_new_session(struct Curl_cfilter *cf, struct Curl_easy *data) out: if(msession_alloced) mbedtls_ssl_session_free(&session); - free(sdata); + curlx_free(sdata); return result; } diff --git a/lib/vtls/mbedtls_threadlock.c b/lib/vtls/mbedtls_threadlock.c index 82590929cd78..91de9eceb59b 100644 --- a/lib/vtls/mbedtls_threadlock.c +++ b/lib/vtls/mbedtls_threadlock.c @@ -37,10 +37,6 @@ #include "mbedtls_threadlock.h" -/* The last 2 #include files should be: */ -#include "../curl_memory.h" -#include "../memdebug.h" - /* number of thread locks */ #define NUMT 2 diff --git a/lib/vtls/openssl.c b/lib/vtls/openssl.c index d8f99b21c371..bdfe527acd83 100644 --- a/lib/vtls/openssl.c +++ b/lib/vtls/openssl.c @@ -132,10 +132,6 @@ static void ossl_provider_cleanup(struct Curl_easy *data); #include "../curlx/warnless.h" -/* The last #include files should be: */ -#include "../curl_memory.h" -#include "../memdebug.h" - #if defined(USE_OPENSSL_ENGINE) || defined(OPENSSL_HAS_PROVIDERS) #include #endif @@ -1831,7 +1827,7 @@ static CURLcode ossl_set_provider(struct Curl_easy *data, const char *iname) if(!libctx) return CURLE_OUT_OF_MEMORY; if(propq) { - data->state.propq = strdup(propq); + data->state.propq = curlx_strdup(propq); if(!data->state.propq) { OSSL_LIB_CTX_free(libctx); return CURLE_OUT_OF_MEMORY; @@ -2738,7 +2734,7 @@ CURLcode Curl_ossl_add_session(struct Curl_cfilter *cf, goto out; } - der_session_buf = der_session_ptr = malloc(der_session_size); + der_session_buf = der_session_ptr = curlx_malloc(der_session_size); if(!der_session_buf) { result = CURLE_OUT_OF_MEMORY; goto out; @@ -2775,7 +2771,7 @@ CURLcode Curl_ossl_add_session(struct Curl_cfilter *cf, } out: - free(der_session_buf); + curlx_free(der_session_buf); return result; } @@ -2932,7 +2928,7 @@ static CURLcode ossl_win_load_store(struct Curl_easy *data, */ if(CertGetEnhancedKeyUsage(pContext, 0, NULL, &req_size)) { if(req_size && req_size > enhkey_usage_size) { - void *tmp = realloc(enhkey_usage, req_size); + void *tmp = curlx_realloc(enhkey_usage, req_size); if(!tmp) { failf(data, "SSL: Out of memory allocating for OID list"); @@ -2990,7 +2986,7 @@ static CURLcode ossl_win_load_store(struct Curl_easy *data, X509_free(x509); } - free(enhkey_usage); + curlx_free(enhkey_usage); CertFreeCertificateContext(pContext); CertCloseStore(hStore, 0); @@ -3233,8 +3229,8 @@ static void oss_x509_share_free(void *key, size_t key_len, void *p) if(share->store) { X509_STORE_free(share->store); } - free(share->CAfile); - free(share); + curlx_free(share->CAfile); + curlx_free(share); } static bool @@ -3304,14 +3300,14 @@ static void ossl_set_cached_x509_store(struct Curl_cfilter *cf, sizeof(MPROTO_OSSL_X509_KEY)-1); if(!share) { - share = calloc(1, sizeof(*share)); + share = curlx_calloc(1, sizeof(*share)); if(!share) return; if(!Curl_hash_add2(&multi->proto_hash, CURL_UNCONST(MPROTO_OSSL_X509_KEY), sizeof(MPROTO_OSSL_X509_KEY)-1, share, oss_x509_share_free)) { - free(share); + curlx_free(share); return; } } @@ -3320,7 +3316,7 @@ static void ossl_set_cached_x509_store(struct Curl_cfilter *cf, char *CAfile = NULL; if(conn_config->CAfile) { - CAfile = strdup(conn_config->CAfile); + CAfile = curlx_strdup(conn_config->CAfile); if(!CAfile) { X509_STORE_free(store); return; @@ -3329,7 +3325,7 @@ static void ossl_set_cached_x509_store(struct Curl_cfilter *cf, if(share->store) { X509_STORE_free(share->store); - free(share->CAfile); + curlx_free(share->CAfile); } share->time = curlx_now(); @@ -3516,11 +3512,11 @@ static CURLcode ossl_init_ech(struct ossl_ctx *octx, ech_config_len) != 1) { infof(data, "ECH: SSL_ECH_set1_ech_config_list failed"); if(data->set.tls_ech & CURLECH_HARD) { - free(ech_config); + curlx_free(ech_config); return CURLE_SSL_CONNECT_ERROR; } } - free(ech_config); + curlx_free(ech_config); trying_ech_now = 1; # else ech_config = (unsigned char *) data->set.str[STRING_ECH_CONFIG]; @@ -4160,7 +4156,7 @@ static void ossl_trace_ech_retry_configs(struct Curl_easy *data, SSL* ssl, result = curlx_base64_encode(rcs, rcl, &b64str, &blen); if(!result && b64str) { infof(data, "ECH: retry_configs %s", b64str); - free(b64str); + curlx_free(b64str); #ifndef HAVE_BORINGSSL_LIKE rv = SSL_ech_get1_status(ssl, &inner, &outer); infof(data, "ECH: retry_configs for %s from %s, %d %d", @@ -4446,7 +4442,7 @@ static CURLcode ossl_pkp_pin_peer_pubkey(struct Curl_easy *data, X509* cert, if(len1 < 1) break; /* failed */ - buff1 = temp = malloc(len1); + buff1 = temp = curlx_malloc(len1); if(!buff1) break; /* failed */ @@ -4468,7 +4464,7 @@ static CURLcode ossl_pkp_pin_peer_pubkey(struct Curl_easy *data, X509* cert, } while(0); if(buff1) - free(buff1); + curlx_free(buff1); return result; } diff --git a/lib/vtls/rustls.c b/lib/vtls/rustls.c index cc19a328eda1..e4251a915198 100644 --- a/lib/vtls/rustls.c +++ b/lib/vtls/rustls.c @@ -42,10 +42,6 @@ #include "cipher_suite.h" #include "x509asn1.h" -/* The last #include files should be: */ -#include "../curl_memory.h" -#include "../memdebug.h" - struct rustls_ssl_backend_data { const struct rustls_client_config *config; @@ -586,7 +582,7 @@ init_config_builder(struct Curl_easy *data, } #endif /* USE_ECH */ - cipher_suites = malloc(sizeof(*cipher_suites) * (cipher_suites_len)); + cipher_suites = curlx_malloc(sizeof(*cipher_suites) * (cipher_suites_len)); if(!cipher_suites) { result = CURLE_OUT_OF_MEMORY; goto cleanup; @@ -643,7 +639,7 @@ init_config_builder(struct Curl_easy *data, cleanup: if(cipher_suites) { - free(cipher_suites); + curlx_free(cipher_suites); } if(custom_provider_builder) { rustls_crypto_provider_builder_free(custom_provider_builder); @@ -1004,7 +1000,7 @@ init_config_builder_ech(struct Curl_easy *data, cleanup: /* if we base64 decoded, we can free now */ if(data->set.tls_ech & CURLECH_CLA_CFG && data->set.str[STRING_ECH_CONFIG]) { - free(ech_config); + curlx_free(ech_config); } if(dns) { Curl_resolv_unlink(data, &dns); diff --git a/lib/vtls/schannel.c b/lib/vtls/schannel.c index e5fbe40a8c1a..49a4516cdfc8 100644 --- a/lib/vtls/schannel.c +++ b/lib/vtls/schannel.c @@ -60,10 +60,6 @@ #include "../progress.h" #include "../curl_sha256.h" -/* The last #include file should be: */ -#include "../curl_memory.h" -#include "../memdebug.h" - /* Some verbose debug messages are wrapped by SCH_DEV() instead of DEBUGF() * and only shown if CURL_SCHANNEL_DEV_DEBUG was defined at build time. These * messages are extra verbose and intended for curl developers debugging @@ -427,7 +423,7 @@ get_cert_location(TCHAR *path, DWORD *store_name, TCHAR **store_path, return CURLE_SSL_CERTPROBLEM; *sep = TEXT('\0'); - *store_path = Curl_tcsdup(store_path_start); + *store_path = curlx_tcsdup(store_path_start); *sep = TEXT('\\'); if(!*store_path) return CURLE_OUT_OF_MEMORY; @@ -571,7 +567,7 @@ schannel_acquire_credential_handle(struct Curl_cfilter *cf, failf(data, "schannel: certificate format compatibility error " " for %s", blob ? "(memory blob)" : data->set.ssl.primary.clientcert); - free(cert_store_path); + curlx_free(cert_store_path); curlx_unicodefree(cert_path); if(fInCert) curlx_fclose(fInCert); @@ -589,7 +585,7 @@ schannel_acquire_credential_handle(struct Curl_cfilter *cf, int cert_find_flags; const char *cert_showfilename_error = blob ? "(memory blob)" : data->set.ssl.primary.clientcert; - free(cert_store_path); + curlx_free(cert_store_path); curlx_unicodefree(cert_path); if(fInCert) { long cert_tell = 0; @@ -603,7 +599,7 @@ schannel_acquire_credential_handle(struct Curl_cfilter *cf, if(continue_reading) continue_reading = fseek(fInCert, 0, SEEK_SET) == 0; if(continue_reading) - certdata = malloc(certsize + 1); + certdata = curlx_malloc(certsize + 1); if((!certdata) || ((int) fread(certdata, certsize, 1, fInCert) != 1)) continue_reading = FALSE; @@ -611,7 +607,7 @@ schannel_acquire_credential_handle(struct Curl_cfilter *cf, if(!continue_reading) { failf(data, "schannel: Failed to read cert file %s", data->set.ssl.primary.clientcert); - free(certdata); + curlx_free(certdata); return CURLE_SSL_CERTPROBLEM; } } @@ -622,7 +618,7 @@ schannel_acquire_credential_handle(struct Curl_cfilter *cf, if(data->set.ssl.key_passwd) pwd_len = strlen(data->set.ssl.key_passwd); - pszPassword = (WCHAR*)malloc(sizeof(WCHAR)*(pwd_len + 1)); + pszPassword = (WCHAR*)curlx_malloc(sizeof(WCHAR)*(pwd_len + 1)); if(pszPassword) { if(pwd_len > 0) str_w_len = MultiByteToWideChar(CP_UTF8, @@ -642,10 +638,10 @@ schannel_acquire_credential_handle(struct Curl_cfilter *cf, else cert_store = PFXImportCertStore(&datablob, pszPassword, 0); - free(pszPassword); + curlx_free(pszPassword); } if(!blob) - free(certdata); + curlx_free(certdata); if(!cert_store) { DWORD errorcode = GetLastError(); if(errorcode == ERROR_INVALID_PASSWORD) @@ -699,12 +695,12 @@ schannel_acquire_credential_handle(struct Curl_cfilter *cf, cert_store_name, (path_utf8 ? path_utf8 : "(unknown)"), GetLastError()); - free(cert_store_path); + curlx_free(cert_store_path); curlx_unicodefree(path_utf8); curlx_unicodefree(cert_path); return CURLE_SSL_CERTPROBLEM; } - free(cert_store_path); + curlx_free(cert_store_path); cert_thumbprint.pbData = cert_thumbprint_data; cert_thumbprint.cbData = CERT_THUMBPRINT_DATA_LEN; @@ -738,7 +734,7 @@ schannel_acquire_credential_handle(struct Curl_cfilter *cf, /* allocate memory for the reusable credential handle */ backend->cred = (struct Curl_schannel_cred *) - calloc(1, sizeof(struct Curl_schannel_cred)); + curlx_calloc(1, sizeof(struct Curl_schannel_cred)); if(!backend->cred) { failf(data, "schannel: unable to allocate memory"); @@ -1019,7 +1015,7 @@ schannel_connect_step1(struct Curl_cfilter *cf, struct Curl_easy *data) /* allocate memory for the security context handle */ backend->ctxt = (struct Curl_schannel_ctxt *) - calloc(1, sizeof(struct Curl_schannel_ctxt)); + curlx_calloc(1, sizeof(struct Curl_schannel_ctxt)); if(!backend->ctxt) { failf(data, "schannel: unable to allocate memory"); return CURLE_OUT_OF_MEMORY; @@ -1170,7 +1166,7 @@ schannel_connect_step2(struct Curl_cfilter *cf, struct Curl_easy *data) if(!backend->decdata_buffer) { backend->decdata_offset = 0; backend->decdata_length = CURL_SCHANNEL_BUFFER_INIT_SIZE; - backend->decdata_buffer = malloc(backend->decdata_length); + backend->decdata_buffer = curlx_malloc(backend->decdata_length); if(!backend->decdata_buffer) { failf(data, "schannel: unable to allocate memory"); return CURLE_OUT_OF_MEMORY; @@ -1182,7 +1178,7 @@ schannel_connect_step2(struct Curl_cfilter *cf, struct Curl_easy *data) backend->encdata_is_incomplete = FALSE; backend->encdata_offset = 0; backend->encdata_length = CURL_SCHANNEL_BUFFER_INIT_SIZE; - backend->encdata_buffer = malloc(backend->encdata_length); + backend->encdata_buffer = curlx_malloc(backend->encdata_length); if(!backend->encdata_buffer) { failf(data, "schannel: unable to allocate memory"); return CURLE_OUT_OF_MEMORY; @@ -1195,8 +1191,8 @@ schannel_connect_step2(struct Curl_cfilter *cf, struct Curl_easy *data) /* increase internal encrypted data buffer */ size_t reallocated_length = backend->encdata_offset + CURL_SCHANNEL_BUFFER_FREE_SIZE; - reallocated_buffer = realloc(backend->encdata_buffer, - reallocated_length); + reallocated_buffer = curlx_realloc(backend->encdata_buffer, + reallocated_length); if(!reallocated_buffer) { failf(data, "schannel: unable to re-allocate memory"); @@ -1247,7 +1243,8 @@ schannel_connect_step2(struct Curl_cfilter *cf, struct Curl_easy *data) backend->encdata_offset, backend->encdata_length)); /* setup input buffers */ - InitSecBuffer(&inbuf[0], SECBUFFER_TOKEN, malloc(backend->encdata_offset), + InitSecBuffer(&inbuf[0], SECBUFFER_TOKEN, + curlx_malloc(backend->encdata_offset), curlx_uztoul(backend->encdata_offset)); InitSecBuffer(&inbuf[1], SECBUFFER_EMPTY, NULL, 0); InitSecBufferDesc(&inbuf_desc, inbuf, 2); @@ -1274,7 +1271,7 @@ schannel_connect_step2(struct Curl_cfilter *cf, struct Curl_easy *data) if(!SOCKET_WRITABLE(Curl_conn_cf_get_socket(cf, data), 0)) { SCH_DEV(infof(data, "schannel: handshake waiting for writeable socket")); connssl->io_need = CURL_SSL_IO_NEED_SEND; - free(inbuf[0].pvBuffer); + curlx_free(inbuf[0].pvBuffer); return CURLE_OK; } @@ -1931,7 +1928,7 @@ schannel_send(struct Curl_cfilter *cf, struct Curl_easy *data, /* calculate the complete message length and allocate a buffer for it */ data_len = backend->stream_sizes.cbHeader + len + backend->stream_sizes.cbTrailer; - ptr = (unsigned char *)malloc(data_len); + ptr = (unsigned char *)curlx_malloc(data_len); if(!ptr) { return CURLE_OUT_OF_MEMORY; } @@ -2110,8 +2107,8 @@ schannel_recv(struct Curl_cfilter *cf, struct Curl_easy *data, if(reallocated_length < min_encdata_length) { reallocated_length = min_encdata_length; } - reallocated_buffer = realloc(backend->encdata_buffer, - reallocated_length); + reallocated_buffer = curlx_realloc(backend->encdata_buffer, + reallocated_length); if(!reallocated_buffer) { result = CURLE_OUT_OF_MEMORY; failf(data, "schannel: unable to re-allocate memory"); @@ -2196,8 +2193,8 @@ schannel_recv(struct Curl_cfilter *cf, struct Curl_easy *data, if(reallocated_length < len) { reallocated_length = len; } - reallocated_buffer = realloc(backend->decdata_buffer, - reallocated_length); + reallocated_buffer = curlx_realloc(backend->decdata_buffer, + reallocated_length); if(!reallocated_buffer) { result = CURLE_OUT_OF_MEMORY; failf(data, "schannel: unable to re-allocate memory"); @@ -2819,8 +2816,8 @@ static void schannel_cert_share_free(void *key, size_t key_len, void *p) if(share->cert_store) { CertCloseStore(share->cert_store, 0); } - free(share->CAfile); - free(share); + curlx_free(share->CAfile); + curlx_free(share); } bool Curl_schannel_set_cached_cert_store(struct Curl_cfilter *cf, @@ -2844,7 +2841,7 @@ bool Curl_schannel_set_cached_cert_store(struct Curl_cfilter *cf, CURL_UNCONST(MPROTO_SCHANNEL_CERT_SHARE_KEY), sizeof(MPROTO_SCHANNEL_CERT_SHARE_KEY)-1); if(!share) { - share = calloc(1, sizeof(*share)); + share = curlx_calloc(1, sizeof(*share)); if(!share) { return FALSE; } @@ -2852,7 +2849,7 @@ bool Curl_schannel_set_cached_cert_store(struct Curl_cfilter *cf, CURL_UNCONST(MPROTO_SCHANNEL_CERT_SHARE_KEY), sizeof(MPROTO_SCHANNEL_CERT_SHARE_KEY)-1, share, schannel_cert_share_free)) { - free(share); + curlx_free(share); return FALSE; } } @@ -2866,7 +2863,7 @@ bool Curl_schannel_set_cached_cert_store(struct Curl_cfilter *cf, } else { if(conn_config->CAfile) { - CAfile = strdup(conn_config->CAfile); + CAfile = curlx_strdup(conn_config->CAfile); if(!CAfile) { return FALSE; } @@ -2877,7 +2874,7 @@ bool Curl_schannel_set_cached_cert_store(struct Curl_cfilter *cf, if(share->cert_store) { CertCloseStore(share->cert_store, 0); } - free(share->CAfile); + curlx_free(share->CAfile); share->time = curlx_now(); share->cert_store = cert_store; diff --git a/lib/vtls/schannel_verify.c b/lib/vtls/schannel_verify.c index 72c42ed35341..4ff7b5d536a1 100644 --- a/lib/vtls/schannel_verify.c +++ b/lib/vtls/schannel_verify.c @@ -49,10 +49,6 @@ #include "hostcheck.h" #include "../curlx/version_win32.h" -/* The last #include file should be: */ -#include "../curl_memory.h" -#include "../memdebug.h" - #define BACKEND ((struct schannel_ssl_backend_data *)connssl->backend) #define MAX_CAFILE_SIZE 1048576 /* 1 MiB */ @@ -319,7 +315,7 @@ static CURLcode add_certs_file_to_store(HCERTSTORE trust_store, } ca_file_bufsize = (size_t)file_size.QuadPart; - ca_file_buffer = (char *)malloc(ca_file_bufsize + 1); + ca_file_buffer = (char *)curlx_malloc(ca_file_bufsize + 1); if(!ca_file_buffer) { result = CURLE_OUT_OF_MEMORY; goto cleanup; @@ -606,7 +602,7 @@ CURLcode Curl_verify_host(struct Curl_cfilter *cf, /* CertGetNameString guarantees that the returned name will not contain * embedded null bytes. This appears to be undocumented behavior. */ - cert_hostname_buff = (LPTSTR)malloc(len * sizeof(TCHAR)); + cert_hostname_buff = (LPTSTR)curlx_malloc(len * sizeof(TCHAR)); if(!cert_hostname_buff) { result = CURLE_OUT_OF_MEMORY; goto cleanup; diff --git a/lib/vtls/vtls.c b/lib/vtls/vtls.c index 3b242fd485d2..6eb60e41cf99 100644 --- a/lib/vtls/vtls.c +++ b/lib/vtls/vtls.c @@ -81,15 +81,11 @@ #include #endif -/* The last #include files should be: */ -#include "../curl_memory.h" -#include "../memdebug.h" - #define CLONE_STRING(var) \ do { \ if(source->var) { \ - dest->var = strdup(source->var); \ + dest->var = curlx_strdup(source->var); \ if(!dest->var) \ return FALSE; \ } \ @@ -111,7 +107,7 @@ static CURLcode blobdup(struct curl_blob **dest, if(src) { /* only if there is data to dupe! */ struct curl_blob *d; - d = malloc(sizeof(struct curl_blob) + src->len); + d = curlx_malloc(sizeof(struct curl_blob) + src->len); if(!d) return CURLE_OUT_OF_MEMORY; d->len = src->len; @@ -503,16 +499,16 @@ static struct ssl_connect_data *cf_ctx_new(struct Curl_easy *data, struct ssl_connect_data *ctx; (void)data; - ctx = calloc(1, sizeof(*ctx)); + ctx = curlx_calloc(1, sizeof(*ctx)); if(!ctx) return NULL; ctx->ssl_impl = Curl_ssl; ctx->alpn = alpn; Curl_bufq_init2(&ctx->earlydata, CURL_SSL_EARLY_MAX, 1, BUFQ_OPT_NO_SPARES); - ctx->backend = calloc(1, ctx->ssl_impl->sizeof_ssl_backend_data); + ctx->backend = curlx_calloc(1, ctx->ssl_impl->sizeof_ssl_backend_data); if(!ctx->backend) { - free(ctx); + curlx_free(ctx); return NULL; } return ctx; @@ -523,8 +519,8 @@ static void cf_ctx_free(struct ssl_connect_data *ctx) if(ctx) { Curl_safefree(ctx->negotiated.alpn); Curl_bufq_free(&ctx->earlydata); - free(ctx->backend); - free(ctx); + curlx_free(ctx->backend); + curlx_free(ctx); } } @@ -617,7 +613,7 @@ void Curl_ssl_free_certinfo(struct Curl_easy *data) ci->certinfo[i] = NULL; } - free(ci->certinfo); /* free the actual array too */ + curlx_free(ci->certinfo); /* free the actual array too */ ci->certinfo = NULL; ci->num_of_certs = 0; } @@ -632,7 +628,7 @@ CURLcode Curl_ssl_init_certinfo(struct Curl_easy *data, int num) Curl_ssl_free_certinfo(data); /* Allocate the required certificate information structures */ - table = calloc((size_t) num, sizeof(struct curl_slist *)); + table = curlx_calloc((size_t) num, sizeof(struct curl_slist *)); if(!table) return CURLE_OUT_OF_MEMORY; @@ -783,7 +779,7 @@ CURLcode Curl_pin_peer_pubkey(struct Curl_easy *data, } /* compute sha256sum of public key */ - sha256sumdigest = malloc(CURL_SHA256_DIGEST_LENGTH); + sha256sumdigest = curlx_malloc(CURL_SHA256_DIGEST_LENGTH); if(!sha256sumdigest) return CURLE_OUT_OF_MEMORY; encode = Curl_ssl->sha256sum(pubkey, pubkeylen, @@ -1118,7 +1114,7 @@ static int multissl_setup(const struct Curl_ssl *backend) for(i = 0; available_backends[i]; i++) { if(curl_strequal(env, available_backends[i]->info.name)) { Curl_ssl = available_backends[i]; - free(env); + curlx_free(env); return 0; } } @@ -1129,7 +1125,7 @@ static int multissl_setup(const struct Curl_ssl *backend) if(curl_strequal(CURL_DEFAULT_SSL_BACKEND, available_backends[i]->info.name)) { Curl_ssl = available_backends[i]; - free(env); + curlx_free(env); return 0; } } @@ -1137,7 +1133,7 @@ static int multissl_setup(const struct Curl_ssl *backend) /* Fall back to first available backend */ Curl_ssl = available_backends[0]; - free(env); + curlx_free(env); return 0; } @@ -1190,7 +1186,7 @@ void Curl_ssl_peer_cleanup(struct ssl_peer *peer) { Curl_safefree(peer->sni); if(peer->dispname != peer->hostname) - free(peer->dispname); + curlx_free(peer->dispname); peer->dispname = NULL; Curl_safefree(peer->hostname); Curl_safefree(peer->scache_key); @@ -1266,13 +1262,13 @@ CURLcode Curl_ssl_peer_init(struct ssl_peer *peer, goto out; } - peer->hostname = strdup(ehostname); + peer->hostname = curlx_strdup(ehostname); if(!peer->hostname) goto out; if(!edispname || !strcmp(ehostname, edispname)) peer->dispname = peer->hostname; else { - peer->dispname = strdup(edispname); + peer->dispname = curlx_strdup(edispname); if(!peer->dispname) goto out; } @@ -1284,7 +1280,7 @@ CURLcode Curl_ssl_peer_init(struct ssl_peer *peer, if(len && (peer->hostname[len-1] == '.')) len--; if(len < USHRT_MAX) { - peer->sni = calloc(1, len + 1); + peer->sni = curlx_calloc(1, len + 1); if(!peer->sni) goto out; Curl_strntolower(peer->sni, peer->hostname, len); diff --git a/lib/vtls/vtls_scache.c b/lib/vtls/vtls_scache.c index 3524a25a4417..21dfe2eaa032 100644 --- a/lib/vtls/vtls_scache.c +++ b/lib/vtls/vtls_scache.c @@ -47,10 +47,6 @@ #include "../rand.h" #include "../curlx/warnless.h" -/* The last #include files should be: */ -#include "../curl_memory.h" -#include "../memdebug.h" - static bool cf_ssl_peer_key_is_global(const char *peer_key); @@ -104,10 +100,10 @@ static void cf_ssl_scache_session_ldestroy(void *udata, void *obj) { struct Curl_ssl_session *s = obj; (void)udata; - free(CURL_UNCONST(s->sdata)); - free(CURL_UNCONST(s->quic_tp)); - free((void *)s->alpn); - free(s); + curlx_free(CURL_UNCONST(s->sdata)); + curlx_free(CURL_UNCONST(s->quic_tp)); + curlx_free((void *)s->alpn); + curlx_free(s); } CURLcode @@ -131,15 +127,15 @@ Curl_ssl_session_create2(void *sdata, size_t sdata_len, struct Curl_ssl_session *s; if(!sdata || !sdata_len) { - free(sdata); + curlx_free(sdata); return CURLE_BAD_FUNCTION_ARGUMENT; } *psession = NULL; - s = calloc(1, sizeof(*s)); + s = curlx_calloc(1, sizeof(*s)); if(!s) { - free(sdata); - free(quic_tp); + curlx_free(sdata); + curlx_free(quic_tp); return CURLE_OUT_OF_MEMORY; } @@ -151,7 +147,7 @@ Curl_ssl_session_create2(void *sdata, size_t sdata_len, s->quic_tp = quic_tp; s->quic_tp_len = quic_tp_len; if(alpn) { - s->alpn = strdup(alpn); + s->alpn = curlx_strdup(alpn); if(!s->alpn) { cf_ssl_scache_session_ldestroy(NULL, s); return CURLE_OUT_OF_MEMORY; @@ -231,7 +227,7 @@ cf_ssl_scache_peer_init(struct Curl_ssl_scache_peer *peer, DEBUGASSERT(!peer->ssl_peer_key); if(ssl_peer_key) { - peer->ssl_peer_key = strdup(ssl_peer_key); + peer->ssl_peer_key = curlx_strdup(ssl_peer_key); if(!peer->ssl_peer_key) goto out; peer->hmac_set = FALSE; @@ -246,17 +242,17 @@ cf_ssl_scache_peer_init(struct Curl_ssl_scache_peer *peer, goto out; } if(clientcert) { - peer->clientcert = strdup(clientcert); + peer->clientcert = curlx_strdup(clientcert); if(!peer->clientcert) goto out; } if(srp_username) { - peer->srp_username = strdup(srp_username); + peer->srp_username = curlx_strdup(srp_username); if(!peer->srp_username) goto out; } if(srp_password) { - peer->srp_password = strdup(srp_password); + peer->srp_password = curlx_strdup(srp_password); if(!peer->srp_password) goto out; } @@ -315,13 +311,13 @@ CURLcode Curl_ssl_scache_create(size_t max_peers, size_t i; *pscache = NULL; - peers = calloc(max_peers, sizeof(*peers)); + peers = curlx_calloc(max_peers, sizeof(*peers)); if(!peers) return CURLE_OUT_OF_MEMORY; - scache = calloc(1, sizeof(*scache)); + scache = curlx_calloc(1, sizeof(*scache)); if(!scache) { - free(peers); + curlx_free(peers); return CURLE_OUT_OF_MEMORY; } @@ -348,8 +344,8 @@ void Curl_ssl_scache_destroy(struct Curl_ssl_scache *scache) for(i = 0; i < scache->peer_count; ++i) { cf_ssl_scache_clear_peer(&scache->peers[i]); } - free(scache->peers); - free(scache); + curlx_free(scache->peers); + curlx_free(scache); } } @@ -396,7 +392,8 @@ static CURLcode cf_ssl_peer_key_add_path(struct dynbuf *buf, char *abspath = realpath(path, NULL); if(abspath) { CURLcode r = curlx_dyn_addf(buf, ":%s-%s", name, abspath); - (free)(abspath); /* allocated by libc, free without memdebug */ + /* !checksrc! disable BANNEDFUNC 1 */ + free(abspath); /* allocated by libc, free without memdebug */ return r; } *is_local = TRUE; @@ -675,7 +672,7 @@ cf_ssl_find_peer_by_key(struct Curl_easy *data, /* remember peer_key for future lookups */ CURL_TRC_SSLS(data, "peer entry %zu key recovered: %s", i, ssl_peer_key); - scache->peers[i].ssl_peer_key = strdup(ssl_peer_key); + scache->peers[i].ssl_peer_key = curlx_strdup(ssl_peer_key); if(!scache->peers[i].ssl_peer_key) { result = CURLE_OUT_OF_MEMORY; goto out; diff --git a/lib/vtls/vtls_spack.c b/lib/vtls/vtls_spack.c index d86f31d72721..070bb485a350 100644 --- a/lib/vtls/vtls_spack.c +++ b/lib/vtls/vtls_spack.c @@ -32,10 +32,6 @@ #include "vtls_spack.h" #include "../strdup.h" -/* The last #include files should be: */ -#include "../curl_memory.h" -#include "../memdebug.h" - #ifndef UINT16_MAX #define UINT16_MAX 0xffff #endif @@ -267,7 +263,7 @@ CURLcode Curl_ssl_session_unpack(struct Curl_easy *data, goto out; } - s = calloc(1, sizeof(*s)); + s = curlx_calloc(1, sizeof(*s)); if(!s) { r = CURLE_OUT_OF_MEMORY; goto out; diff --git a/lib/vtls/wolfssl.c b/lib/vtls/wolfssl.c index 2ad033f98899..eae17078fd35 100644 --- a/lib/vtls/wolfssl.c +++ b/lib/vtls/wolfssl.c @@ -75,10 +75,6 @@ #include #include "wolfssl.h" -/* The last #include files should be: */ -#include "../curl_memory.h" -#include "../memdebug.h" - #ifdef HAVE_WOLFSSL_CTX_GENERATEECHCONFIG #define USE_ECH_WOLFSSL #endif @@ -447,7 +443,7 @@ CURLcode Curl_wssl_cache_session(struct Curl_cfilter *cf, result = CURLE_FAILED_INIT; goto out; } - sdata = calloc(1, sdata_len); + sdata = curlx_calloc(1, sdata_len); if(!sdata) { failf(data, "unable to allocate session buffer of %u bytes", sdata_len); result = CURLE_OUT_OF_MEMORY; @@ -462,7 +458,7 @@ CURLcode Curl_wssl_cache_session(struct Curl_cfilter *cf, if(quic_tp && quic_tp_len) { qtp_clone = Curl_memdup0((char *)quic_tp, quic_tp_len); if(!qtp_clone) { - free(sdata); + curlx_free(sdata); return CURLE_OUT_OF_MEMORY; } } @@ -483,7 +479,7 @@ CURLcode Curl_wssl_cache_session(struct Curl_cfilter *cf, } out: - free(sdata); + curlx_free(sdata); return result; } @@ -726,8 +722,8 @@ static void wssl_x509_share_free(void *key, size_t key_len, void *p) if(share->store) { wolfSSL_X509_STORE_free(share->store); } - free(share->CAfile); - free(share); + curlx_free(share->CAfile); + curlx_free(share); } static bool @@ -792,14 +788,14 @@ static void wssl_set_cached_x509_store(struct Curl_cfilter *cf, sizeof(MPROTO_WSSL_X509_KEY)-1); if(!share) { - share = calloc(1, sizeof(*share)); + share = curlx_calloc(1, sizeof(*share)); if(!share) return; if(!Curl_hash_add2(&multi->proto_hash, CURL_UNCONST(MPROTO_WSSL_X509_KEY), sizeof(MPROTO_WSSL_X509_KEY)-1, share, wssl_x509_share_free)) { - free(share); + curlx_free(share); return; } } @@ -808,7 +804,7 @@ static void wssl_set_cached_x509_store(struct Curl_cfilter *cf, char *CAfile = NULL; if(conn_config->CAfile) { - CAfile = strdup(conn_config->CAfile); + CAfile = curlx_strdup(conn_config->CAfile); if(!CAfile) { wolfSSL_X509_STORE_free(store); return; @@ -817,7 +813,7 @@ static void wssl_set_cached_x509_store(struct Curl_cfilter *cf, if(share->store) { wolfSSL_X509_STORE_free(share->store); - free(share->CAfile); + curlx_free(share->CAfile); } share->time = curlx_now(); @@ -1821,7 +1817,7 @@ static CURLcode wssl_handshake(struct Curl_cfilter *cf, &b64str, &blen); if(!result && b64str) infof(data, "ECH: (not yet) retry_configs %s", b64str); - free(b64str); + curlx_free(b64str); } return CURLE_SSL_CONNECT_ERROR; } diff --git a/lib/vtls/x509asn1.c b/lib/vtls/x509asn1.c index 417a5382d873..fcc0d0e1daf2 100644 --- a/lib/vtls/x509asn1.c +++ b/lib/vtls/x509asn1.c @@ -49,10 +49,6 @@ #include "x509asn1.h" #include "../curlx/dynbuf.h" -/* The last 2 #include files should be in this order */ -#include "../curl_memory.h" -#include "../memdebug.h" - /* * Constants. */ @@ -1260,7 +1256,7 @@ CURLcode Curl_extract_certinfo(struct Curl_easy *data, if(!result) result = curlx_dyn_add(&out, "-----END CERTIFICATE-----\n"); } - free(certptr); + curlx_free(certptr); if(!result) if(data->set.ssl.certinfo) result = ssl_push_certinfo_dyn(data, certnum, "Cert", &out); diff --git a/lib/ws.c b/lib/ws.c index 15dc2e9aea7e..93e13e1ac184 100644 --- a/lib/ws.c +++ b/lib/ws.c @@ -43,10 +43,6 @@ #include "curlx/strparse.h" #include "curlx/warnless.h" -/* The last 2 #include files should be in this order */ -#include "curl_memory.h" -#include "memdebug.h" - /*** RFC 6455 Section 5.2 @@ -1281,11 +1277,11 @@ CURLcode Curl_ws_request(struct Curl_easy *data, struct dynbuf *req) return result; DEBUGASSERT(randlen < sizeof(keyval)); if(randlen >= sizeof(keyval)) { - free(randstr); + curlx_free(randstr); return CURLE_FAILED_INIT; } strcpy(keyval, randstr); - free(randstr); + curlx_free(randstr); for(i = 0; !result && (i < CURL_ARRAYSIZE(heads)); i++) { if(!Curl_checkheaders(data, heads[i].name, strlen(heads[i].name))) { result = curlx_dyn_addf(req, "%s: %s\r\n", heads[i].name, @@ -1305,7 +1301,7 @@ static void ws_conn_dtor(void *key, size_t klen, void *entry) (void)klen; Curl_bufq_free(&ws->recvbuf); Curl_bufq_free(&ws->sendbuf); - free(ws); + curlx_free(ws); } /* @@ -1325,7 +1321,7 @@ CURLcode Curl_ws_accept(struct Curl_easy *data, ws = Curl_conn_meta_get(data->conn, CURL_META_PROTO_WS_CONN); if(!ws) { size_t chunk_size = WS_CHUNK_SIZE; - ws = calloc(1, sizeof(*ws)); + ws = curlx_calloc(1, sizeof(*ws)); if(!ws) return CURLE_OUT_OF_MEMORY; #ifdef DEBUGBUILD diff --git a/packages/Makefile.am b/packages/Makefile.am index 43e544a0195c..8b6d4dc4b242 100644 --- a/packages/Makefile.am +++ b/packages/Makefile.am @@ -24,6 +24,7 @@ SUBDIRS = vms EXTRA_DIST = README.md \ + OS400/.checksrc \ OS400/README.OS400 \ OS400/rpg-examples \ OS400/ccsidcurl.c \ diff --git a/packages/OS400/.checksrc b/packages/OS400/.checksrc new file mode 100644 index 000000000000..aae405506b9e --- /dev/null +++ b/packages/OS400/.checksrc @@ -0,0 +1,9 @@ +# Copyright (C) Daniel Stenberg, , et al. +# +# SPDX-License-Identifier: curl + +# Possible not what we want, but cannot test, just silence the warnings +allowfunc calloc +allowfunc free +allowfunc malloc +allowfunc realloc diff --git a/scripts/checksrc.pl b/scripts/checksrc.pl index 49290ff137a5..87b72af96326 100755 --- a/scripts/checksrc.pl +++ b/scripts/checksrc.pl @@ -69,10 +69,12 @@ "aprintf" => 1, "atoi" => 1, "atol" => 1, + "calloc" => 1, "fclose" => 1, "fdopen" => 1, "fopen" => 1, "fprintf" => 1, + "free" => 1, "freeaddrinfo" => 1, "freopen" => 1, "getaddrinfo" => 1, @@ -85,11 +87,13 @@ "LoadLibraryExW" => 1, "LoadLibraryW" => 1, "localtime" => 1, + "malloc" => 1, "mbstowcs" => 1, "msnprintf" => 1, "mvsnprintf" => 1, "open" => 1, "printf" => 1, + "realloc" => 1, "recv" => 1, "send" => 1, "snprintf" => 1, @@ -99,6 +103,7 @@ "sscanf" => 1, "stat" => 1, "strcat" => 1, + "strdup" => 1, "strerror" => 1, "strncat" => 1, "strncpy" => 1, diff --git a/src/mkhelp.pl b/src/mkhelp.pl index d1a040c0cc63..b3a6c5abdce7 100755 --- a/src/mkhelp.pl +++ b/src/mkhelp.pl @@ -78,7 +78,6 @@ print < -#include /* keep this as LAST include */ static const unsigned char hugehelpgz[] = { /* This mumbo-jumbo is the huge help text compressed with gzip. Thanks to this operation, the size of this data shrank from $gzip @@ -105,13 +104,13 @@ static voidpf zalloc_func(voidpf opaque, unsigned int items, unsigned int size) { (void)opaque; - /* not a typo, keep it calloc() */ - return (voidpf) calloc(items, size); + /* not a typo, keep it curlx_calloc() */ + return (voidpf)curlx_calloc(items, size); } static void zfree_func(voidpf opaque, voidpf ptr) { (void)opaque; - free(ptr); + curlx_free(ptr); } #define HEADERLEN 10 @@ -136,7 +135,7 @@ if(inflateInit2(&z, -MAX_WBITS) != Z_OK) return; - buf = malloc(BUF_SIZE); + buf = curlx_malloc(BUF_SIZE); if(buf) { while(1) { z.avail_out = BUF_SIZE; @@ -150,7 +149,7 @@ else break; /* error */ } - free(buf); + curlx_free(buf); } inflateEnd(&z); } @@ -176,7 +175,7 @@ if(inflateInit2(&z, -MAX_WBITS) != Z_OK) return; - buf = malloc(BUF_SIZE); + buf = curlx_malloc(BUF_SIZE); if(buf) { while(1) { z.avail_out = BUF_SIZE; @@ -192,7 +191,7 @@ else break; /* error */ } - free(buf); + curlx_free(buf); } inflateEnd(&z); } diff --git a/src/slist_wc.c b/src/slist_wc.c index 7f1e8f19be8d..26a91362b8e3 100644 --- a/src/slist_wc.c +++ b/src/slist_wc.c @@ -28,9 +28,6 @@ #include "slist_wc.h" -/* The last #include files should be: */ -#include "memdebug.h" - /* * slist_wc_append() appends a string to the linked list. This function can be * used as an initialization function as well as an append function. @@ -44,7 +41,7 @@ struct slist_wc *slist_wc_append(struct slist_wc *list, return NULL; if(!list) { - list = malloc(sizeof(struct slist_wc)); + list = curlx_malloc(sizeof(struct slist_wc)); if(!list) { curl_slist_free_all(new_item); @@ -68,7 +65,7 @@ void slist_wc_free_all(struct slist_wc *list) return; curl_slist_free_all(list->first); - free(list); + curlx_free(list); } #endif /* CURL_DISABLE_LIBCURL_OPTION */ diff --git a/src/terminal.c b/src/terminal.c index 867ca6edcf88..bb3e2ac61184 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -28,7 +28,6 @@ #endif #include "terminal.h" -#include "memdebug.h" /* keep this as LAST include */ #ifdef HAVE_TERMIOS_H # include diff --git a/src/tool_bname.c b/src/tool_bname.c index 4ba1a3b8eeac..50d77abb9644 100644 --- a/src/tool_bname.c +++ b/src/tool_bname.c @@ -25,8 +25,6 @@ #include "tool_bname.h" -#include "memdebug.h" /* keep this as LAST include */ - #ifndef HAVE_BASENAME char *tool_basename(char *path) diff --git a/src/tool_cb_dbg.c b/src/tool_cb_dbg.c index 043daef26dd0..b858b6688e6e 100644 --- a/src/tool_cb_dbg.c +++ b/src/tool_cb_dbg.c @@ -28,8 +28,6 @@ #include "tool_cb_dbg.h" #include "tool_util.h" -#include "memdebug.h" /* keep this as LAST include */ - static void dump(const char *timebuf, const char *idsbuf, const char *text, FILE *stream, const unsigned char *ptr, size_t size, trace tracetype, curl_infotype infotype); diff --git a/src/tool_cb_hdr.c b/src/tool_cb_hdr.c index d4431a74b951..7a5a475981d5 100644 --- a/src/tool_cb_hdr.c +++ b/src/tool_cb_hdr.c @@ -36,8 +36,6 @@ #include "tool_libinfo.h" #include "tool_strdup.h" -#include "memdebug.h" /* keep this as LAST include */ - static char *parse_filename(const char *ptr, size_t len); #ifdef _WIN32 @@ -212,14 +210,14 @@ size_t tool_header_cb(char *ptr, size_t size, size_t nmemb, void *userdata) if(filename) { if(outs->stream) { /* indication of problem, get out! */ - free(filename); + curlx_free(filename); return CURL_WRITEFUNC_ERROR; } if(per->config->output_dir) { outs->filename = curl_maprintf("%s/%s", per->config->output_dir, filename); - free(filename); + curlx_free(filename); if(!outs->filename) return CURL_WRITEFUNC_ERROR; } @@ -252,7 +250,7 @@ size_t tool_header_cb(char *ptr, size_t size, size_t nmemb, void *userdata) if(clone) { struct curl_slist *old = hdrcbdata->headlist; hdrcbdata->headlist = curl_slist_append(old, clone); - free(clone); + curlx_free(clone); if(!hdrcbdata->headlist) { curl_slist_free_all(old); return CURL_WRITEFUNC_ERROR; @@ -479,7 +477,7 @@ static void write_linked_location(CURL *curl, const char *location, curl_free(finalurl); curl_free(scheme); curl_url_cleanup(u); - free(copyloc); + curlx_free(copyloc); } } #endif diff --git a/src/tool_cb_prg.c b/src/tool_cb_prg.c index 5f33c7c29c05..6ae53b3ba227 100644 --- a/src/tool_cb_prg.c +++ b/src/tool_cb_prg.c @@ -29,8 +29,6 @@ #include "tool_operate.h" #include "terminal.h" -#include "memdebug.h" /* keep this as LAST include */ - #define MAX_BARLENGTH 400 #define MIN_BARLENGTH 20 diff --git a/src/tool_cb_rea.c b/src/tool_cb_rea.c index cc7ef5a55079..0f2bf8177198 100644 --- a/src/tool_cb_rea.c +++ b/src/tool_cb_rea.c @@ -38,8 +38,6 @@ #include "tool_util.h" #include "tool_msgs.h" -#include "memdebug.h" /* keep this as LAST include */ - #ifndef _WIN32 /* Wait up to a number of milliseconds for socket activity. This function waits on read activity on a file descriptor that is not a socket which diff --git a/src/tool_cb_see.c b/src/tool_cb_see.c index fd1b4c563c80..ea5c8e313b40 100644 --- a/src/tool_cb_see.c +++ b/src/tool_cb_see.c @@ -27,8 +27,6 @@ #include "tool_operate.h" #include "tool_cb_see.h" -#include "memdebug.h" /* keep this as LAST include */ - /* ** callback for CURLOPT_SEEKFUNCTION ** diff --git a/src/tool_cb_wrt.c b/src/tool_cb_wrt.c index 48f5fea3c9b9..5696df2a5935 100644 --- a/src/tool_cb_wrt.c +++ b/src/tool_cb_wrt.c @@ -28,8 +28,6 @@ #include "tool_cb_wrt.h" #include "tool_operate.h" -#include "memdebug.h" /* keep this as LAST include */ - #ifdef _WIN32 #define OPENMODE S_IREAD | S_IWRITE #else @@ -211,8 +209,8 @@ static size_t win_console(intptr_t fhnd, struct OutStruct *outs, /* grow the buffer if needed */ if(len > global->term.len) { - wchar_t *buf = (wchar_t *) realloc(global->term.buf, - len * sizeof(wchar_t)); + wchar_t *buf = (wchar_t *)curlx_realloc(global->term.buf, + len * sizeof(wchar_t)); if(!buf) return CURL_WRITEFUNC_ERROR; global->term.len = len; diff --git a/src/tool_cfgable.c b/src/tool_cfgable.c index 086e4ac21659..ab4892b06578 100644 --- a/src/tool_cfgable.c +++ b/src/tool_cfgable.c @@ -28,7 +28,6 @@ #include "tool_paramhlp.h" #include "tool_main.h" #include "tool_msgs.h" -#include "memdebug.h" /* keep this as LAST include */ static struct GlobalConfig globalconf; struct GlobalConfig *global; @@ -36,7 +35,7 @@ struct GlobalConfig *global; struct OperationConfig *config_alloc(void) { struct OperationConfig *config = - calloc(1, sizeof(struct OperationConfig)); + curlx_calloc(1, sizeof(struct OperationConfig)); if(!config) return NULL; @@ -199,7 +198,7 @@ void config_free(struct OperationConfig *config) struct OperationConfig *prev = last->prev; free_config_fields(last); - free(last); + curlx_free(last); last = prev; } @@ -236,12 +235,12 @@ CURLcode globalconf_init(void) if(result) { errorf("error retrieving curl library information"); - free(global->first); + curlx_free(global->first); } } else { errorf("error initializing curl library"); - free(global->first); + curlx_free(global->first); } } else { @@ -263,7 +262,7 @@ static void free_globalconfig(void) tool_safefree(global->ssl_sessions); tool_safefree(global->libcurl); #ifdef _WIN32 - free(global->term.buf); + curlx_free(global->term.buf); #endif } diff --git a/src/tool_cfgable.h b/src/tool_cfgable.h index dc78f2db44f6..0eac0185f280 100644 --- a/src/tool_cfgable.h +++ b/src/tool_cfgable.h @@ -42,7 +42,7 @@ #define checkprefix(a,b) curl_strnequal(b, STRCONST(a)) #define tool_safefree(ptr) \ - do { free((ptr)); (ptr) = NULL;} while(0) + do { curlx_free((ptr)); (ptr) = NULL;} while(0) extern struct GlobalConfig *global; diff --git a/src/tool_dirhie.c b/src/tool_dirhie.c index 17b2d01e9bc6..31962bd1c546 100644 --- a/src/tool_dirhie.c +++ b/src/tool_dirhie.c @@ -30,8 +30,6 @@ #include "tool_dirhie.h" #include "tool_msgs.h" -#include "memdebug.h" /* keep this as LAST include */ - #if defined(_WIN32) || (defined(MSDOS) && !defined(__DJGPP__)) # define mkdir(x,y) (mkdir)((x)) # ifndef F_OK diff --git a/src/tool_doswin.c b/src/tool_doswin.c index cd0ec3b9c1b1..ee236178c276 100644 --- a/src/tool_doswin.c +++ b/src/tool_doswin.c @@ -40,8 +40,6 @@ #include "tool_doswin.h" #include "tool_msgs.h" -#include "memdebug.h" /* keep this as LAST include */ - #ifdef _WIN32 # undef PATH_MAX # define PATH_MAX MAX_PATH @@ -133,7 +131,7 @@ SANITIZEcode sanitize_file_name(char **const sanitized, const char *file_name, if(len > max_sanitized_len) return SANITIZE_ERR_INVALID_PATH; - target = strdup(file_name); + target = curlx_strdup(file_name); if(!target) return SANITIZE_ERR_OUT_OF_MEMORY; @@ -183,28 +181,28 @@ SANITIZEcode sanitize_file_name(char **const sanitized, const char *file_name, #ifdef MSDOS sc = msdosify(&p, target, flags); - free(target); + curlx_free(target); if(sc) return sc; target = p; len = strlen(target); if(len > max_sanitized_len) { - free(target); + curlx_free(target); return SANITIZE_ERR_INVALID_PATH; } #endif if(!(flags & SANITIZE_ALLOW_RESERVED)) { sc = rename_if_reserved_dos(&p, target, flags); - free(target); + curlx_free(target); if(sc) return sc; target = p; len = strlen(target); if(len > max_sanitized_len) { - free(target); + curlx_free(target); return SANITIZE_ERR_INVALID_PATH; } } @@ -415,7 +413,7 @@ static SANITIZEcode msdosify(char **const sanitized, const char *file_name, return SANITIZE_ERR_INVALID_PATH; } - *sanitized = strdup(dos_name); + *sanitized = curlx_strdup(dos_name); return *sanitized ? SANITIZE_ERR_OK : SANITIZE_ERR_OUT_OF_MEMORY; } #endif /* MSDOS */ @@ -457,7 +455,7 @@ static SANITIZEcode rename_if_reserved_dos(char **const sanitized, #ifndef MSDOS if((flags & SANITIZE_ALLOW_PATH) && file_name[0] == '\\' && file_name[1] == '\\') { - *sanitized = strdup(file_name); + *sanitized = curlx_strdup(file_name); if(!*sanitized) return SANITIZE_ERR_OUT_OF_MEMORY; return SANITIZE_ERR_OK; @@ -544,7 +542,7 @@ static SANITIZEcode rename_if_reserved_dos(char **const sanitized, } #endif - *sanitized = strdup(fname); + *sanitized = curlx_strdup(fname); return *sanitized ? SANITIZE_ERR_OK : SANITIZE_ERR_OUT_OF_MEMORY; } @@ -597,7 +595,7 @@ CURLcode FindWin32CACert(struct OperationConfig *config, char *mstr = curlx_convert_tchar_to_UTF8(buf); tool_safefree(config->cacert); if(mstr) - config->cacert = strdup(mstr); + config->cacert = curlx_strdup(mstr); curlx_unicodefree(mstr); if(!config->cacert) result = CURLE_OUT_OF_MEMORY; @@ -801,7 +799,7 @@ static DWORD WINAPI win_stdin_thread_func(void *thread_data) if(socket_w != CURL_SOCKET_BAD) sclose(socket_w); - free(tdata); + curlx_free(tdata); return 0; } @@ -824,9 +822,10 @@ curl_socket_t win32_stdin_read_thread(void) do { /* Prepare handles for thread */ - tdata = (struct win_thread_data*)calloc(1, sizeof(struct win_thread_data)); + tdata = (struct win_thread_data*) + curlx_calloc(1, sizeof(struct win_thread_data)); if(!tdata) { - errorf("calloc() error"); + errorf("curlx_calloc() error"); break; } /* Create the listening socket for the thread. When it starts, it will @@ -937,7 +936,7 @@ curl_socket_t win32_stdin_read_thread(void) if(tdata->socket_l != CURL_SOCKET_BAD) sclose(tdata->socket_l); - free(tdata); + curlx_free(tdata); } return CURL_SOCKET_BAD; diff --git a/src/tool_easysrc.c b/src/tool_easysrc.c index 65d01d5f85a6..4747f6dfe6bb 100644 --- a/src/tool_easysrc.c +++ b/src/tool_easysrc.c @@ -31,8 +31,6 @@ #include "tool_easysrc.h" #include "tool_msgs.h" -#include "memdebug.h" /* keep this as LAST include */ - /* global variable definitions, for easy-interface source code generation */ struct slist_wc *easysrc_decl; /* Variable declarations */ diff --git a/src/tool_findfile.c b/src/tool_findfile.c index 6e9fbdfd6003..4dbd7bccb470 100644 --- a/src/tool_findfile.c +++ b/src/tool_findfile.c @@ -36,8 +36,6 @@ #include "tool_findfile.h" #include "tool_cfgable.h" -#include "memdebug.h" /* keep this as LAST include */ - struct finder { const char *env; const char *append; @@ -75,7 +73,7 @@ static char *checkhome(const char *home, const char *fname, bool dotscore) if(c) { int fd = curlx_open(c, O_RDONLY); if(fd >= 0) { - char *path = strdup(c); + char *path = curlx_strdup(c); close(fd); curl_free(c); return path; diff --git a/src/tool_formparse.c b/src/tool_formparse.c index c1e9abe9d0b8..181abf7b8627 100644 --- a/src/tool_formparse.c +++ b/src/tool_formparse.c @@ -30,13 +30,11 @@ #include "tool_formparse.h" #include "tool_parsecfg.h" -#include "memdebug.h" /* keep this as LAST include */ - /* tool_mime functions. */ static struct tool_mime *tool_mime_new(struct tool_mime *parent, toolmimekind kind) { - struct tool_mime *m = (struct tool_mime *) calloc(1, sizeof(*m)); + struct tool_mime *m = (struct tool_mime *)curlx_calloc(1, sizeof(*m)); if(m) { m->kind = kind; @@ -60,11 +58,11 @@ static struct tool_mime *tool_mime_new_data(struct tool_mime *parent, char *mime_data_copy; struct tool_mime *m = NULL; - mime_data_copy = strdup(mime_data); + mime_data_copy = curlx_strdup(mime_data); if(mime_data_copy) { m = tool_mime_new(parent, TOOLMIME_DATA); if(!m) - free(mime_data_copy); + curlx_free(mime_data_copy); else m->data = mime_data_copy; } @@ -107,11 +105,11 @@ static struct tool_mime *tool_mime_new_filedata(struct tool_mime *parent, *errcode = CURLE_OUT_OF_MEMORY; if(strcmp(filename, "-")) { /* This is a normal file. */ - char *filedup = strdup(filename); + char *filedup = curlx_strdup(filename); if(filedup) { m = tool_mime_new(parent, TOOLMIME_FILE); if(!m) - free(filedup); + curlx_free(filedup); else { m->data = filedup; if(!isremotefile) @@ -152,7 +150,7 @@ static struct tool_mime *tool_mime_new_filedata(struct tool_mime *parent, default: if(!stdinsize) { /* Zero-length data has been freed. Re-create it. */ - data = strdup(""); + data = curlx_strdup(""); if(!data) return m; } @@ -190,7 +188,7 @@ void tool_mime_free(struct tool_mime *mime) tool_safefree(mime->encoder); tool_safefree(mime->data); curl_slist_free_all(mime->headers); - free(mime); + curlx_free(mime); } } @@ -711,7 +709,7 @@ static int get_param_part(char endchar, #define SET_TOOL_MIME_PTR(m, field) \ do { \ if(field) { \ - (m)->field = strdup(field); \ + (m)->field = curlx_strdup(field); \ if(!(m)->field) \ goto fail; \ } \ @@ -745,7 +743,7 @@ int formparse(const char *input, } /* Make a copy we can overwrite. */ - contents = strdup(input); + contents = curlx_strdup(input); if(!contents) goto fail; diff --git a/src/tool_getparam.c b/src/tool_getparam.c index 76113e45bd0d..7afb0c5fc051 100644 --- a/src/tool_getparam.c +++ b/src/tool_getparam.c @@ -38,22 +38,20 @@ #include "tool_help.h" #include "var.h" -#include "memdebug.h" /* keep this as LAST include */ - #define ALLOW_BLANK TRUE #define DENY_BLANK FALSE static ParameterError getstr(char **str, const char *val, bool allowblank) { if(*str) { - free(*str); + curlx_free(*str); *str = NULL; } DEBUGASSERT(val); if(!allowblank && !val[0]) return PARAM_BLANK_STRING; - *str = strdup(val); + *str = curlx_strdup(val); if(!*str) return PARAM_NO_MEM; @@ -64,14 +62,14 @@ static ParameterError getstrn(char **str, const char *val, size_t len, bool allowblank) { if(*str) { - free(*str); + curlx_free(*str); *str = NULL; } DEBUGASSERT(val); if(!allowblank && !val[0]) return PARAM_BLANK_STRING; - *str = malloc(len + 1); + *str = curlx_malloc(len + 1); if(!*str) return PARAM_NO_MEM; @@ -407,13 +405,13 @@ ParameterError parse_cert_parameter(const char *cert_parameter, * means no passphrase was given and no characters escaped */ if(curl_strnequal(cert_parameter, "pkcs11:", 7) || !strpbrk(cert_parameter, ":\\")) { - *certname = strdup(cert_parameter); + *certname = curlx_strdup(cert_parameter); if(!*certname) return PARAM_NO_MEM; return PARAM_OK; } /* deal with escaped chars; find unescaped colon if it exists */ - certname_place = malloc(param_length + 1); + certname_place = curlx_malloc(param_length + 1); if(!certname_place) { err = PARAM_NO_MEM; goto done; @@ -475,7 +473,7 @@ ParameterError parse_cert_parameter(const char *cert_parameter, * above; if we are still here, this is a separating colon */ param_place++; if(*param_place) { - *passphrase = strdup(param_place); + *passphrase = curlx_strdup(param_place); if(!*passphrase) err = PARAM_NO_MEM; } @@ -527,10 +525,10 @@ GetFileAndPassword(const char *nextarg, char **file, char **password) /* nextarg is never NULL here */ err = parse_cert_parameter(nextarg, &certname, &passphrase); if(!err) { - free(*file); + curlx_free(*file); *file = certname; if(passphrase) { - free(*password); + curlx_free(*password); *password = passphrase; } } @@ -668,7 +666,7 @@ static ParameterError data_urlencode(const char *nextarg, if(!postdata) { /* no data from the file, point to a zero byte string to make this get sent as a POST anyway */ - postdata = strdup(""); + postdata = curlx_strdup(""); if(!postdata) return PARAM_NO_MEM; size = 0; @@ -870,7 +868,7 @@ static ParameterError url_query(const char *nextarg, if(*nextarg == '+') { /* use without encoding */ - query = strdup(&nextarg[1]); + query = curlx_strdup(&nextarg[1]); if(!query) err = PARAM_NO_MEM; } @@ -880,11 +878,11 @@ static ParameterError url_query(const char *nextarg, if(!err) { if(config->query) { CURLcode result = curlx_dyn_addf(&dyn, "%s&%s", config->query, query); - free(query); + curlx_free(query); if(result) err = PARAM_NO_MEM; else { - free(config->query); + curlx_free(config->query); config->query = curlx_dyn_ptr(&dyn); } } @@ -944,7 +942,7 @@ static ParameterError set_data(cmdline_t cmd, if(!postdata) { /* no data from the file, point to a zero byte string to make this get sent as a POST anyway */ - postdata = strdup(""); + postdata = curlx_strdup(""); if(!postdata) return PARAM_NO_MEM; } @@ -1240,7 +1238,7 @@ static ParameterError parse_ech(struct OperationConfig *config, if(err) return err; config->ech_config = curl_maprintf("ecl:%s",tmpcfg); - free(tmpcfg); + curlx_free(tmpcfg); if(!config->ech_config) return PARAM_NO_MEM; } /* file done */ @@ -1424,8 +1422,8 @@ static ParameterError parse_range(struct OperationConfig *config, "Appending one for you"); curl_msnprintf(buffer, sizeof(buffer), "%" CURL_FORMAT_CURL_OFF_T "-", value); - free(config->range); - config->range = strdup(buffer); + curlx_free(config->range); + config->range = curlx_strdup(buffer); if(!config->range) err = PARAM_NO_MEM; } @@ -1509,8 +1507,8 @@ static ParameterError parse_verbose(bool toggle) switch(global->verbosity) { case 0: global->verbosity = 1; - free(global->trace_dump); - global->trace_dump = strdup("%"); + curlx_free(global->trace_dump); + global->trace_dump = curlx_strdup("%"); if(!global->trace_dump) err = PARAM_NO_MEM; else { @@ -3021,7 +3019,7 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */ error: if(nextalloc) - free(CURL_UNCONST(nextarg)); + curlx_free(CURL_UNCONST(nextarg)); return err; } diff --git a/src/tool_getpass.c b/src/tool_getpass.c index 014c22813acf..b0316510bc23 100644 --- a/src/tool_getpass.c +++ b/src/tool_getpass.c @@ -51,8 +51,6 @@ #endif #include "tool_getpass.h" -#include "memdebug.h" /* keep this as LAST include */ - #ifdef __VMS /* VMS implementation */ char *getpass_r(const char *prompt, char *buffer, size_t buflen) diff --git a/src/tool_help.c b/src/tool_help.c index 4509fa2b949d..bbe8dc68a4c3 100644 --- a/src/tool_help.c +++ b/src/tool_help.c @@ -33,8 +33,6 @@ #include "tool_cfgable.h" #include "terminal.h" -#include "memdebug.h" /* keep this as LAST include */ - struct category_descriptors { const char *opt; const char *desc; @@ -364,7 +362,7 @@ void tool_version_info(void) #ifdef CURL_CA_EMBED ++feat_ext_count; #endif - feat_ext = malloc(sizeof(*feature_names) * (feat_ext_count + 1)); + feat_ext = curlx_malloc(sizeof(*feature_names) * (feat_ext_count + 1)); if(feat_ext) { memcpy((void *)feat_ext, feature_names, sizeof(*feature_names) * feature_count); @@ -379,7 +377,7 @@ void tool_version_info(void) for(builtin = feat_ext; *builtin; ++builtin) curl_mprintf(" %s", *builtin); puts(""); /* newline */ - free((void *)feat_ext); + curlx_free((void *)feat_ext); } } if(strcmp(CURL_VERSION, curlinfo->version)) { diff --git a/src/tool_helpers.c b/src/tool_helpers.c index b36bd4af1d87..2e308a248f13 100644 --- a/src/tool_helpers.c +++ b/src/tool_helpers.c @@ -27,7 +27,6 @@ #include "tool_msgs.h" #include "tool_getparam.h" #include "tool_helpers.h" -#include "memdebug.h" /* keep this as LAST include */ /* ** Helper functions that are used from more than one source file. diff --git a/src/tool_ipfs.c b/src/tool_ipfs.c index 0214a2004f1e..c1d27fc99b09 100644 --- a/src/tool_ipfs.c +++ b/src/tool_ipfs.c @@ -28,7 +28,6 @@ #include "tool_cfgable.h" #include "tool_msgs.h" #include "tool_ipfs.h" -#include "memdebug.h" /* keep this as LAST include */ /* input string ends in slash? */ static bool has_trailing_slash(const char *input) @@ -45,7 +44,7 @@ static char *ipfs_gateway(void) char *gateway_env = getenv("IPFS_GATEWAY"); if(gateway_env) - return strdup(gateway_env); + return curlx_strdup(gateway_env); /* Try to find the gateway in the IPFS data folder. */ ipfs_path_c = curl_getenv("IPFS_PATH"); @@ -133,7 +132,7 @@ CURLcode ipfs_url_rewrite(CURLU *uh, const char *protocol, char **url, if(config->ipfs_gateway) { if(!curl_url_set(gatewayurl, CURLUPART_URL, config->ipfs_gateway, CURLU_GUESS_SCHEME)) { - gateway = strdup(config->ipfs_gateway); + gateway = curlx_strdup(config->ipfs_gateway); if(!gateway) { result = CURLE_URL_MALFORMAT; goto clean; @@ -200,8 +199,8 @@ CURLcode ipfs_url_rewrite(CURLU *uh, const char *protocol, char **url, if(curl_url_get(uh, CURLUPART_URL, &cloneurl, CURLU_URLENCODE)) { goto clean; } - /* we need to strdup the URL so that we can call free() on it later */ - *url = strdup(cloneurl); + /* we need to strdup the URL so that we can call curlx_free() on it later */ + *url = curlx_strdup(cloneurl); curl_free(cloneurl); if(!*url) goto clean; @@ -209,7 +208,7 @@ CURLcode ipfs_url_rewrite(CURLU *uh, const char *protocol, char **url, result = CURLE_OK; clean: - free(gateway); + curlx_free(gateway); curl_free(gwhost); curl_free(gwpath); curl_free(gwquery); diff --git a/src/tool_libinfo.c b/src/tool_libinfo.c index d755532652c8..1687005481a9 100644 --- a/src/tool_libinfo.c +++ b/src/tool_libinfo.c @@ -24,7 +24,6 @@ #include "tool_setup.h" #include "tool_libinfo.h" -#include "memdebug.h" /* keep this as LAST include */ /* global variable definitions, for libcurl runtime info */ diff --git a/src/tool_libinfo.h b/src/tool_libinfo.h index 5e6e1de24c43..ddc41a133867 100644 --- a/src/tool_libinfo.h +++ b/src/tool_libinfo.h @@ -27,7 +27,6 @@ /* global variable declarations, for libcurl runtime info */ - extern curl_version_info_data *curlinfo; extern const char * const *built_in_protos; diff --git a/src/tool_main.c b/src/tool_main.c index 8047e663c8f7..eb15ae740dd1 100644 --- a/src/tool_main.c +++ b/src/tool_main.c @@ -42,13 +42,6 @@ #include "tool_libinfo.h" #include "tool_stderr.h" -/* - * This is low-level hard-hacking memory leak tracking and similar. Using - * the library level code from this client-side is ugly, but we do this - * anyway for convenience. - */ -#include "memdebug.h" /* keep this as LAST include */ - #ifdef __VMS /* * vms_show is a global variable, used in main() as parameter for @@ -121,7 +114,7 @@ static void memory_tracking_init(void) curl_free(env); curl_dbg_memdebug(fname); /* this weird stuff here is to make curl_free() get called before - curl_dbg_memdebug() as otherwise memory tracking will log a free() + curl_dbg_memdebug() as otherwise memory tracking will log a curlx_free() without an alloc! */ } /* if CURL_MEMLIMIT is set, this enables fail-on-alloc-number-N feature */ diff --git a/src/tool_msgs.c b/src/tool_msgs.c index ae0b6b983586..b385f75cf8b8 100644 --- a/src/tool_msgs.c +++ b/src/tool_msgs.c @@ -28,8 +28,6 @@ #include "tool_cb_prg.h" #include "terminal.h" -#include "memdebug.h" /* keep this as LAST include */ - #define WARN_PREFIX "Warning: " #define NOTE_PREFIX "Note: " #define ERROR_PREFIX "curl: " diff --git a/src/tool_operate.c b/src/tool_operate.c index eb591935db4f..968dc864f9f6 100644 --- a/src/tool_operate.c +++ b/src/tool_operate.c @@ -90,8 +90,6 @@ CURL_EXTERN CURLcode curl_easy_perform_ev(CURL *easy); #endif -#include "memdebug.h" /* keep this as LAST include */ - #ifdef CURL_CA_EMBED #ifndef CURL_DECLARED_CURL_CA_EMBED #define CURL_DECLARED_CURL_CA_EMBED @@ -204,7 +202,7 @@ static struct per_transfer *transfersl; /* last node */ static CURLcode add_per_transfer(struct per_transfer **per) { struct per_transfer *p; - p = calloc(1, sizeof(struct per_transfer)); + p = curlx_calloc(1, sizeof(struct per_transfer)); if(!p) return CURLE_OUT_OF_MEMORY; if(!transfers) @@ -246,7 +244,7 @@ static struct per_transfer *del_per_transfer(struct per_transfer *per) else transfersl = p; - free(per); + curlx_free(per); return n; } @@ -770,10 +768,10 @@ static CURLcode post_per_transfer(struct per_transfer *per, curl_easy_cleanup(per->curl); if(outs->alloc_filename) - free(outs->filename); - free(per->url); - free(per->outfile); - free(per->uploadfile); + curlx_free(outs->filename); + curlx_free(per->url); + curlx_free(per->outfile); + curlx_free(per->uploadfile); curl_slist_free_all(per->hdrcbdata.headlist); per->hdrcbdata.headlist = NULL; return result; @@ -785,7 +783,7 @@ static CURLcode set_cert_types(struct OperationConfig *config) /* Check if config->cert is a PKCS#11 URI and set the config->cert_type if * necessary */ if(config->cert && !config->cert_type && is_pkcs11_uri(config->cert)) { - config->cert_type = strdup("ENG"); + config->cert_type = curlx_strdup("ENG"); if(!config->cert_type) return CURLE_OUT_OF_MEMORY; } @@ -793,7 +791,7 @@ static CURLcode set_cert_types(struct OperationConfig *config) /* Check if config->key is a PKCS#11 URI and set the config->key_type if * necessary */ if(config->key && !config->key_type && is_pkcs11_uri(config->key)) { - config->key_type = strdup("ENG"); + config->key_type = curlx_strdup("ENG"); if(!config->key_type) return CURLE_OUT_OF_MEMORY; } @@ -802,7 +800,7 @@ static CURLcode set_cert_types(struct OperationConfig *config) * config->proxy_type if necessary */ if(config->proxy_cert && !config->proxy_cert_type && is_pkcs11_uri(config->proxy_cert)) { - config->proxy_cert_type = strdup("ENG"); + config->proxy_cert_type = curlx_strdup("ENG"); if(!config->proxy_cert_type) return CURLE_OUT_OF_MEMORY; } @@ -811,7 +809,7 @@ static CURLcode set_cert_types(struct OperationConfig *config) * config->proxy_key_type if necessary */ if(config->proxy_key && !config->proxy_key_type && is_pkcs11_uri(config->proxy_key)) { - config->proxy_key_type = strdup("ENG"); + config->proxy_key_type = curlx_strdup("ENG"); if(!config->proxy_key_type) return CURLE_OUT_OF_MEMORY; } @@ -844,7 +842,7 @@ static CURLcode append2query(struct OperationConfig *config, if(uerr) result = urlerr_cvt(uerr); else { - free(per->url); /* free previous URL */ + curlx_free(per->url); /* free previous URL */ per->url = updated; /* use our new URL instead! */ } } @@ -1022,7 +1020,7 @@ static CURLcode setup_outfile(struct OperationConfig *config, char *d = curl_maprintf("%s/%s", config->output_dir, per->outfile); if(!d) return CURLE_WRITE_ERROR; - free(per->outfile); + curlx_free(per->outfile); per->outfile = d; } /* Create the directory hierarchy, if not pre-existent to a multiple @@ -1264,7 +1262,7 @@ static CURLcode single_transfer(struct OperationConfig *config, } per->etag_save = etag_first; /* copy the whole struct */ if(state->uploadfile) { - per->uploadfile = strdup(state->uploadfile); + per->uploadfile = curlx_strdup(state->uploadfile); if(!per->uploadfile || SetHTTPrequest(TOOL_HTTPREQ_PUT, &config->httpreq)) { tool_safefree(per->uploadfile); @@ -1300,7 +1298,7 @@ static CURLcode single_transfer(struct OperationConfig *config, if(glob_inuse(&state->urlglob)) result = glob_next_url(&per->url, &state->urlglob); else if(!state->urlidx) { - per->url = strdup(u->url); + per->url = curlx_strdup(u->url); if(!per->url) result = CURLE_OUT_OF_MEMORY; } @@ -1312,7 +1310,7 @@ static CURLcode single_transfer(struct OperationConfig *config, return result; if(u->outfile) { - per->outfile = strdup(u->outfile); + per->outfile = curlx_strdup(u->outfile); if(!per->outfile) return CURLE_OUT_OF_MEMORY; } @@ -1586,7 +1584,7 @@ static struct contextuv *create_context(curl_socket_t sockfd, { struct contextuv *c; - c = (struct contextuv *) malloc(sizeof(*c)); + c = (struct contextuv *)curlx_malloc(sizeof(*c)); c->sockfd = sockfd; c->uv = uv; @@ -1600,7 +1598,7 @@ static struct contextuv *create_context(curl_socket_t sockfd, static void close_cb(uv_handle_t *handle) { struct contextuv *c = (struct contextuv *) handle->data; - free(c); + curlx_free(c); } static void destroy_context(struct contextuv *c) @@ -2053,7 +2051,7 @@ static CURLcode cacertpaths(struct OperationConfig *config) env = curl_getenv("CURL_CA_BUNDLE"); if(env) { - config->cacert = strdup(env); + config->cacert = curlx_strdup(env); curl_free(env); if(!config->cacert) { result = CURLE_OUT_OF_MEMORY; @@ -2063,7 +2061,7 @@ static CURLcode cacertpaths(struct OperationConfig *config) else { env = curl_getenv("SSL_CERT_DIR"); if(env) { - config->capath = strdup(env); + config->capath = curlx_strdup(env); curl_free(env); if(!config->capath) { result = CURLE_OUT_OF_MEMORY; @@ -2072,7 +2070,7 @@ static CURLcode cacertpaths(struct OperationConfig *config) } env = curl_getenv("SSL_CERT_FILE"); if(env) { - config->cacert = strdup(env); + config->cacert = curlx_strdup(env); curl_free(env); if(!config->cacert) { result = CURLE_OUT_OF_MEMORY; @@ -2088,7 +2086,7 @@ static CURLcode cacertpaths(struct OperationConfig *config) FILE *cafile = tool_execpath("curl-ca-bundle.crt", &cacert); if(cafile) { curlx_fclose(cafile); - config->cacert = strdup(cacert); + config->cacert = curlx_strdup(cacert); if(!config->cacert) { result = CURLE_OUT_OF_MEMORY; goto fail; @@ -2260,7 +2258,7 @@ CURLcode operate(int argc, argv_item_t argv[]) if(found_curlrc) { /* After parse_args so notef knows the verbosity */ notef("Read config file from '%s'", curlrc_path); - free(curlrc_path); + curlx_free(curlrc_path); } if(res) { result = CURLE_OK; diff --git a/src/tool_operhlp.c b/src/tool_operhlp.c index 0d6c2cb6e0e5..a8b5e9497570 100644 --- a/src/tool_operhlp.c +++ b/src/tool_operhlp.c @@ -28,7 +28,6 @@ #include "tool_doswin.h" #include "tool_operhlp.h" #include "tool_msgs.h" -#include "memdebug.h" /* keep this as LAST include */ void clean_getout(struct OperationConfig *config) { @@ -144,7 +143,7 @@ CURLcode add_file_name_to_url(CURL *curl, char **inurlp, const char *filename) if(!newpath) goto fail; uerr = curl_url_set(uh, CURLUPART_PATH, newpath, 0); - free(newpath); + curlx_free(newpath); if(uerr) { result = urlerr_cvt(uerr); goto fail; @@ -154,7 +153,7 @@ CURLcode add_file_name_to_url(CURL *curl, char **inurlp, const char *filename) result = urlerr_cvt(uerr); goto fail; } - free(*inurlp); + curlx_free(*inurlp); *inurlp = newurl; result = CURLE_OK; } @@ -206,11 +205,11 @@ CURLcode get_url_file_name(char **filename, const char *url) if(pc) { /* duplicate the string beyond the slash */ - *filename = strdup(pc + 1); + *filename = curlx_strdup(pc + 1); } else { /* no slash => empty string, use default */ - *filename = strdup("curl_response"); + *filename = curlx_strdup("curl_response"); warnf("No remote filename, uses \"%s\"", *filename); } diff --git a/src/tool_paramhlp.c b/src/tool_paramhlp.c index 15293c0cc6ce..b16fc42906d8 100644 --- a/src/tool_paramhlp.c +++ b/src/tool_paramhlp.c @@ -32,11 +32,9 @@ #include "tool_util.h" #include "tool_version.h" -#include "memdebug.h" /* keep this as LAST include */ - struct getout *new_getout(struct OperationConfig *config) { - struct getout *node = calloc(1, sizeof(struct getout)); + struct getout *node = curlx_calloc(1, sizeof(struct getout)); struct getout *last = config->url_last; if(node) { static int outnum = 0; @@ -401,7 +399,7 @@ ParameterError proto2num(const char * const *val, char **ostr, const char *str) curlx_dyn_init(&obuf, MAX_PROTOSTRING); - protoset = malloc((proto_count + 1) * sizeof(*protoset)); + protoset = curlx_malloc((proto_count + 1) * sizeof(*protoset)); if(!protoset) return PARAM_NO_MEM; @@ -499,14 +497,14 @@ ParameterError proto2num(const char * const *val, char **ostr, const char *str) for(proto = 0; protoset[proto] && !result; proto++) result = curlx_dyn_addf(&obuf, "%s%s", curlx_dyn_len(&obuf) ? "," : "", protoset[proto]); - free((char *) protoset); + curlx_free((char *)protoset); if(result) return PARAM_NO_MEM; if(!curlx_dyn_len(&obuf)) { curlx_dyn_free(&obuf); return PARAM_BAD_USE; } - free(*ostr); + curlx_free(*ostr); *ostr = curlx_dyn_ptr(&obuf); return PARAM_OK; } @@ -592,7 +590,7 @@ static CURLcode checkpasswd(const char *kind, /* for what purpose */ return CURLE_OUT_OF_MEMORY; /* return the new string */ - free(*userpwd); + curlx_free(*userpwd); *userpwd = curlx_dyn_ptr(&dyn); } diff --git a/src/tool_parsecfg.c b/src/tool_parsecfg.c index e7a00cf70883..f901e69e7849 100644 --- a/src/tool_parsecfg.c +++ b/src/tool_parsecfg.c @@ -30,7 +30,6 @@ #include "tool_msgs.h" #include "tool_parsecfg.h" #include "tool_util.h" -#include "memdebug.h" /* keep this as LAST include */ /* only acknowledge colon or equals as separators if the option was not specified with an initial dash! */ @@ -96,7 +95,7 @@ ParameterError parseconfig(const char *filename, int max_recursive, if(curlrc) { file = curlx_fopen(curlrc, FOPEN_READTEXT); if(!file) { - free(curlrc); + curlx_free(curlrc); return PARAM_READ_ERROR; } filename = pathalloc = curlrc; @@ -266,11 +265,11 @@ ParameterError parseconfig(const char *filename, int max_recursive, errorf("cannot read config from '%s'", filename); if(!err && resolved) { - *resolved = strdup(filename); + *resolved = curlx_strdup(filename); if(!*resolved) err = PARAM_NO_MEM; } - free(pathalloc); + curlx_free(pathalloc); return err; } diff --git a/src/tool_setopt.c b/src/tool_setopt.c index b7039fbb4881..97d469d76daa 100644 --- a/src/tool_setopt.c +++ b/src/tool_setopt.c @@ -30,7 +30,6 @@ #ifndef CURL_DISABLE_LIBCURL_OPTION #include "tool_msgs.h" -#include "memdebug.h" /* keep this as LAST include */ /* Lookup tables for converting setopt values back to symbols */ /* For enums, values may be in any order. */ @@ -385,7 +384,7 @@ static CURLcode libcurl_generate_slist(struct curl_slist *slist, int *slistno) ret = easysrc_addf(&easysrc_data, "slist%d = curl_slist_append(slist%d, \"%s\");", *slistno, *slistno, escaped); - free(escaped); + curlx_free(escaped); } return ret; @@ -439,7 +438,7 @@ static CURLcode libcurl_generate_mime_part(CURL *curl, easysrc_addf(&easysrc_code, "curl_mime_data(part%d, \"%s\", CURL_ZERO_TERMINATED);", mimeno, escaped); - free(escaped); + curlx_free(escaped); } break; @@ -452,7 +451,7 @@ static CURLcode libcurl_generate_mime_part(CURL *curl, ret = easysrc_addf(&easysrc_code, "curl_mime_filename(part%d, NULL);", mimeno); } - free(escaped); + curlx_free(escaped); break; } @@ -477,28 +476,28 @@ static CURLcode libcurl_generate_mime_part(CURL *curl, char *escaped = c_escape(part->encoder, ZERO_TERMINATED); ret = easysrc_addf(&easysrc_code, "curl_mime_encoder(part%d, \"%s\");", mimeno, escaped); - free(escaped); + curlx_free(escaped); } if(!ret && filename) { char *escaped = c_escape(filename, ZERO_TERMINATED); ret = easysrc_addf(&easysrc_code, "curl_mime_filename(part%d, \"%s\");", mimeno, escaped); - free(escaped); + curlx_free(escaped); } if(!ret && part->name) { char *escaped = c_escape(part->name, ZERO_TERMINATED); ret = easysrc_addf(&easysrc_code, "curl_mime_name(part%d, \"%s\");", mimeno, escaped); - free(escaped); + curlx_free(escaped); } if(!ret && part->type) { char *escaped = c_escape(part->type, ZERO_TERMINATED); ret = easysrc_addf(&easysrc_code, "curl_mime_type(part%d, \"%s\");", mimeno, escaped); - free(escaped); + curlx_free(escaped); } if(!ret && part->headers) { @@ -687,7 +686,7 @@ CURLcode tool_setopt_str(CURL *curl, struct OperationConfig *config, result = easysrc_addf(&easysrc_code, "curl_easy_setopt(hnd, %s, \"%s\");", name, escaped); - free(escaped); + curlx_free(escaped); } else result = CURLE_OUT_OF_MEMORY; diff --git a/src/tool_setup.h b/src/tool_setup.h index 17c2f420b582..f693fc1dae70 100644 --- a/src/tool_setup.h +++ b/src/tool_setup.h @@ -68,6 +68,8 @@ extern FILE *tool_stderr; #ifndef HAVE_STRDUP #include "tool_strdup.h" +#undef Curl_strdup +#define Curl_strdup tool_strdup #endif #ifndef tool_nop_stmt diff --git a/src/tool_ssls.c b/src/tool_ssls.c index 2b67be9baaf8..7ffd6f707420 100644 --- a/src/tool_ssls.c +++ b/src/tool_ssls.c @@ -30,8 +30,6 @@ #include "tool_ssls.h" #include "tool_parsecfg.h" -#include "memdebug.h" /* keep this as LAST include */ - /* The maximum line length for an ecoded session ticket */ #define MAX_SSLS_LINE (64 * 1024) @@ -127,8 +125,8 @@ CURLcode tool_ssls_load(struct OperationConfig *config, if(fp) curlx_fclose(fp); curlx_dyn_free(&buf); - free(shmac); - free(sdata); + curlx_free(shmac); + curlx_free(sdata); return r; } @@ -181,7 +179,7 @@ static CURLcode tool_ssls_exp(CURL *easy, void *userptr, out: if(r) warnf("Warning: error saving SSL session for '%s': %d", session_key, r); - free(enc); + curlx_free(enc); return r; } diff --git a/src/tool_ssls.h b/src/tool_ssls.h index 7a1b95194d35..c06e9427cf4a 100644 --- a/src/tool_ssls.h +++ b/src/tool_ssls.h @@ -26,7 +26,6 @@ #include "tool_setup.h" #include "tool_operate.h" - CURLcode tool_ssls_load(struct OperationConfig *config, CURLSH *share, const char *filename); CURLcode tool_ssls_save(struct OperationConfig *config, diff --git a/src/tool_stderr.c b/src/tool_stderr.c index 8812f8bf8e52..7871ebc0ccb5 100644 --- a/src/tool_stderr.c +++ b/src/tool_stderr.c @@ -26,8 +26,6 @@ #include "tool_stderr.h" #include "tool_msgs.h" -#include "memdebug.h" /* keep this as LAST include */ - FILE *tool_stderr; void tool_init_stderr(void) diff --git a/src/tool_strdup.c b/src/tool_strdup.c index ff80b56b9263..c799d1acdfde 100644 --- a/src/tool_strdup.c +++ b/src/tool_strdup.c @@ -22,10 +22,9 @@ * ***************************************************************************/ #include "tool_strdup.h" -#include "memdebug.h" /* keep this as LAST include */ #ifndef HAVE_STRDUP -char *strdup(const char *str) +char *tool_strdup(const char *str) { size_t len; char *newstr; @@ -35,7 +34,7 @@ char *strdup(const char *str) len = strlen(str) + 1; - newstr = malloc(len); + newstr = curlx_malloc(len); if(!newstr) return (char *)NULL; @@ -46,7 +45,7 @@ char *strdup(const char *str) char *memdup0(const char *data, size_t len) { - char *p = malloc(len + 1); + char *p = curlx_malloc(len + 1); if(!p) return NULL; if(len) diff --git a/src/tool_strdup.h b/src/tool_strdup.h index 275be7c5d907..0f121e20fdff 100644 --- a/src/tool_strdup.h +++ b/src/tool_strdup.h @@ -26,7 +26,7 @@ #include "tool_setup.h" #ifndef HAVE_STRDUP -extern char *strdup(const char *str); +extern char *tool_strdup(const char *str); #endif char *memdup0(const char *data, size_t len); diff --git a/src/tool_urlglob.c b/src/tool_urlglob.c index 7185e80f66b1..9ea8a274fa0d 100644 --- a/src/tool_urlglob.c +++ b/src/tool_urlglob.c @@ -28,7 +28,6 @@ #include "tool_urlglob.h" #include "tool_vms.h" #include "tool_strdup.h" -#include "memdebug.h" /* keep this as LAST include */ static CURLcode globerror(struct URLGlob *glob, const char *err, size_t pos, CURLcode error) @@ -45,7 +44,7 @@ static CURLcode glob_fixed(struct URLGlob *glob, char *fixed, size_t len) pat->globindex = -1; pat->c.set.size = 0; pat->c.set.idx = 0; - pat->c.set.elem = malloc(sizeof(char *)); + pat->c.set.elem = curlx_malloc(sizeof(char *)); if(!pat->c.set.elem) return globerror(glob, NULL, 0, CURLE_OUT_OF_MEMORY); @@ -137,10 +136,10 @@ static CURLcode glob_set(struct URLGlob *glob, const char **patternp, if(!palloc) { palloc = 5; /* a reasonable default */ - elem = malloc(palloc * sizeof(char *)); + elem = curlx_malloc(palloc * sizeof(char *)); } else if(size >= palloc) { - char **arr = realloc(elem, palloc * 2 * sizeof(char *)); + char **arr = curlx_realloc(elem, palloc * 2 * sizeof(char *)); if(!arr) { result = globerror(glob, NULL, 0, CURLE_OUT_OF_MEMORY); goto error; @@ -154,8 +153,8 @@ static CURLcode glob_set(struct URLGlob *glob, const char **patternp, goto error; } - elem[size] = - strdup(curlx_dyn_ptr(&glob->buf) ? curlx_dyn_ptr(&glob->buf) : ""); + elem[size] = curlx_strdup(curlx_dyn_ptr(&glob->buf) ? + curlx_dyn_ptr(&glob->buf) : ""); if(!elem[size]) { result = globerror(glob, NULL, 0, CURLE_OUT_OF_MEMORY); goto error; @@ -206,7 +205,7 @@ static CURLcode glob_set(struct URLGlob *glob, const char **patternp, for(i = 0; i < size; i++) tool_safefree(elem[i]); } - free(elem); + curlx_free(elem); return result; } @@ -387,7 +386,8 @@ static CURLcode add_glob(struct URLGlob *glob, size_t pos) struct URLPattern *np = NULL; glob->palloc *= 2; if(glob->pnum < 255) { /* avoid ridiculous amounts */ - np = realloc(glob->pattern, glob->palloc * sizeof(struct URLPattern)); + np = curlx_realloc(glob->pattern, + glob->palloc * sizeof(struct URLPattern)); if(!np) return globerror(glob, NULL, pos, CURLE_OUT_OF_MEMORY); } @@ -491,7 +491,7 @@ CURLcode glob_url(struct URLGlob *glob, char *url, curl_off_t *urlnum, memset(glob, 0, sizeof(struct URLGlob)); curlx_dyn_init(&glob->buf, 1024*1024); - glob->pattern = malloc(2 * sizeof(struct URLPattern)); + glob->pattern = curlx_malloc(2 * sizeof(struct URLPattern)); if(!glob->pattern) return CURLE_OUT_OF_MEMORY; glob->palloc = 2; @@ -617,7 +617,7 @@ CURLcode glob_next_url(char **globbed, struct URLGlob *glob) } *globbed = - strdup(curlx_dyn_ptr(&glob->buf) ? curlx_dyn_ptr(&glob->buf) : ""); + curlx_strdup(curlx_dyn_ptr(&glob->buf) ? curlx_dyn_ptr(&glob->buf) : ""); if(!*globbed) return CURLE_OUT_OF_MEMORY; diff --git a/src/tool_util.c b/src/tool_util.c index cb64f9a0b921..43dd096783cc 100644 --- a/src/tool_util.c +++ b/src/tool_util.c @@ -24,7 +24,6 @@ #include "tool_setup.h" #include "tool_util.h" -#include "memdebug.h" /* keep this as LAST include */ #ifdef _WIN32 diff --git a/src/tool_vms.c b/src/tool_vms.c index fac0cfc4dd72..75aa7d5370ee 100644 --- a/src/tool_vms.c +++ b/src/tool_vms.c @@ -32,7 +32,6 @@ #include "curlmsg_vms.h" #include "tool_vms.h" -#include "memdebug.h" /* keep this as LAST include */ void decc$__posix_exit(int __status); void decc$exit(int __status); diff --git a/src/tool_writeout.c b/src/tool_writeout.c index 52b35345f4a9..f846add4e311 100644 --- a/src/tool_writeout.c +++ b/src/tool_writeout.c @@ -26,7 +26,6 @@ #include "tool_cfgable.h" #include "tool_writeout.h" #include "tool_writeout_json.h" -#include "memdebug.h" /* keep this as LAST include */ static int writeTime(FILE *stream, const struct writeoutvar *wovar, struct per_transfer *per, CURLcode per_result, diff --git a/src/tool_xattr.c b/src/tool_xattr.c index fb0669106e4b..b111c7b843e4 100644 --- a/src/tool_xattr.c +++ b/src/tool_xattr.c @@ -24,8 +24,6 @@ #include "tool_setup.h" #include "tool_xattr.h" -#include "memdebug.h" /* keep this as LAST include */ - #ifdef USE_XATTR /* mapping table of curl metadata to extended attribute names */ diff --git a/src/var.c b/src/var.c index 5cedf1d24a2c..08269e1db704 100644 --- a/src/var.c +++ b/src/var.c @@ -33,7 +33,6 @@ #include "tool_writeout_json.h" #include "tool_strdup.h" #include "var.h" -#include "memdebug.h" /* keep this as LAST include */ #define MAX_EXPAND_CONTENT 10000000 #define MAX_VAR_LEN 128 /* max length of a name */ @@ -45,8 +44,8 @@ void varcleanup(void) while(list) { struct tool_var *t = list; list = list->next; - free(CURL_UNCONST(t->content)); - free(t); + curlx_free(CURL_UNCONST(t->content)); + curlx_free(t); } } @@ -192,7 +191,7 @@ static ParameterError varfunc(char *c, /* content */ break; } if(alloc) - free(c); + curlx_free(c); clen = curlx_dyn_len(out); c = memdup0(curlx_dyn_ptr(out), clen); @@ -203,7 +202,7 @@ static ParameterError varfunc(char *c, /* content */ alloc = TRUE; } if(alloc) - free(c); + curlx_free(c); if(err) curlx_dyn_free(out); return err; @@ -359,7 +358,7 @@ static ParameterError addvariable(const char *name, if(check) notef("Overwriting variable '%s'", check->name); - p = calloc(1, sizeof(struct tool_var) + nlen); + p = curlx_calloc(1, sizeof(struct tool_var) + nlen); if(p) { memcpy(p->name, name, nlen); /* the null termination byte is already present from above */ @@ -372,7 +371,7 @@ static ParameterError addvariable(const char *name, global->variables = p; return PARAM_OK; } - free(p); + curlx_free(p); } return PARAM_NO_MEM; } @@ -496,7 +495,7 @@ ParameterError setvariable(const char *input) err = addvariable(name, nlen, content, clen, contalloc); if(err) { if(contalloc) - free(content); + curlx_free(content); } return err; } diff --git a/tests/Makefile.am b/tests/Makefile.am index 677a17cd99fe..0371159d68d8 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -25,7 +25,6 @@ # scripts used in test cases TESTSCRIPTS = \ test1119.pl \ - test1132.pl \ test1135.pl \ test1139.pl \ test1140.pl \ diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am index bc3abbc7d80c..18c6969391be 100644 --- a/tests/data/Makefile.am +++ b/tests/data/Makefile.am @@ -152,7 +152,7 @@ test1093 test1094 test1095 test1096 test1097 test1098 test1099 test1100 \ test1101 test1102 test1103 test1104 test1105 test1106 test1107 test1108 \ test1109 test1110 test1111 test1112 test1113 test1114 test1115 test1116 \ test1117 test1118 test1119 test1120 test1121 test1122 test1123 test1124 \ -test1125 test1126 test1127 test1128 test1129 test1130 test1131 test1132 \ +test1125 test1126 test1127 test1128 test1129 test1130 test1131 \ test1133 test1134 test1135 test1136 test1137 test1138 test1139 test1140 \ test1141 test1142 test1143 test1144 test1145 test1146 test1147 test1148 \ test1149 test1150 test1151 test1152 test1153 test1154 test1155 test1156 \ diff --git a/tests/data/test1132 b/tests/data/test1132 deleted file mode 100644 index d0ef42a24e6f..000000000000 --- a/tests/data/test1132 +++ /dev/null @@ -1,21 +0,0 @@ - - - -source analysis -memory-includes - - - -# -# Client-side - - -Verify memory #include files in libcurl's C source files - - - -%SRCDIR/test1132.pl %SRCDIR/../lib - - - - diff --git a/tests/libtest/cli_h2_pausing.c b/tests/libtest/cli_h2_pausing.c index 0f06dadd5204..25b798af4b2b 100644 --- a/tests/libtest/cli_h2_pausing.c +++ b/tests/libtest/cli_h2_pausing.c @@ -26,7 +26,6 @@ #include "first.h" #include "testtrace.h" -#include "memdebug.h" static void usage_h2_pausing(const char *msg) { diff --git a/tests/libtest/cli_h2_serverpush.c b/tests/libtest/cli_h2_serverpush.c index ad3ae4f91406..80d8c031367f 100644 --- a/tests/libtest/cli_h2_serverpush.c +++ b/tests/libtest/cli_h2_serverpush.c @@ -24,7 +24,6 @@ #include "first.h" #include "testtrace.h" -#include "memdebug.h" static FILE *out_download = NULL; diff --git a/tests/libtest/cli_h2_upgrade_extreme.c b/tests/libtest/cli_h2_upgrade_extreme.c index b5c6c31b1b59..bc28a6f4d05e 100644 --- a/tests/libtest/cli_h2_upgrade_extreme.c +++ b/tests/libtest/cli_h2_upgrade_extreme.c @@ -24,7 +24,6 @@ #include "first.h" #include "testtrace.h" -#include "memdebug.h" static size_t write_h2_upg_extreme_cb(char *ptr, size_t size, size_t nmemb, void *opaque) diff --git a/tests/libtest/cli_hx_download.c b/tests/libtest/cli_hx_download.c index 82e8c1b70da7..a7f5d200903c 100644 --- a/tests/libtest/cli_hx_download.c +++ b/tests/libtest/cli_hx_download.c @@ -25,8 +25,6 @@ #include "testtrace.h" -#include "curl_mem_undef.h" - #if defined(USE_QUICHE) || defined(USE_OPENSSL) #include #endif @@ -45,8 +43,6 @@ #include #endif -#include "memdebug.h" - static int verbose_d = 1; struct transfer_d { @@ -346,8 +342,8 @@ static CURLcode test_cli_hx_download(const char *URL) pause_offset = (size_t)num; break; case 'r': - free(resolve); - resolve = strdup(coptarg); + curlx_free(resolve); + resolve = curlx_strdup(coptarg); break; case 'T': if(!curlx_str_number(&opt, &num, LONG_MAX)) @@ -407,7 +403,7 @@ static CURLcode test_cli_hx_download(const char *URL) curl_share_setopt(share, CURLSHOPT_SHARE, CURL_LOCK_DATA_PSL); curl_share_setopt(share, CURLSHOPT_SHARE, CURL_LOCK_DATA_HSTS); - transfer_d = calloc(transfer_count_d, sizeof(*transfer_d)); + transfer_d = curlx_calloc(transfer_count_d, sizeof(*transfer_d)); if(!transfer_d) { curl_mfprintf(stderr, "error allocating transfer structs\n"); res = (CURLcode)1; @@ -559,7 +555,7 @@ static CURLcode test_cli_hx_download(const char *URL) else /* on success we expect ssl to have been checked */ assert(t->checked_ssl); } - free(transfer_d); + curlx_free(transfer_d); } curl_share_cleanup(share); @@ -569,7 +565,7 @@ static CURLcode test_cli_hx_download(const char *URL) optcleanup: - free(resolve); + curlx_free(resolve); return res; } diff --git a/tests/libtest/cli_hx_upload.c b/tests/libtest/cli_hx_upload.c index f0183f6df2bf..f7036509fea2 100644 --- a/tests/libtest/cli_hx_upload.c +++ b/tests/libtest/cli_hx_upload.c @@ -24,7 +24,6 @@ #include "first.h" #include "testtrace.h" -#include "memdebug.h" static int verbose_u = 1; @@ -358,7 +357,7 @@ static CURLcode test_cli_hx_upload(const char *URL) curl_share_setopt(share, CURLSHOPT_SHARE, CURL_LOCK_DATA_PSL); curl_share_setopt(share, CURLSHOPT_SHARE, CURL_LOCK_DATA_HSTS); - transfer_u = calloc(transfer_count_u, sizeof(*transfer_u)); + transfer_u = curlx_calloc(transfer_count_u, sizeof(*transfer_u)); if(!transfer_u) { curl_mfprintf(stderr, "error allocating transfer structs\n"); res = (CURLcode)1; @@ -539,7 +538,7 @@ static CURLcode test_cli_hx_upload(const char *URL) curl_mime_free(t->mime); } } - free(transfer_u); + curlx_free(transfer_u); } curl_share_cleanup(share); diff --git a/tests/libtest/cli_tls_session_reuse.c b/tests/libtest/cli_tls_session_reuse.c index 2f6bde43e384..aa56a0e28c66 100644 --- a/tests/libtest/cli_tls_session_reuse.c +++ b/tests/libtest/cli_tls_session_reuse.c @@ -24,7 +24,6 @@ #include "first.h" #include "testtrace.h" -#include "memdebug.h" static int tse_found_tls_session = FALSE; diff --git a/tests/libtest/cli_upload_pausing.c b/tests/libtest/cli_upload_pausing.c index 441ce899a09e..042eddd7d7dc 100644 --- a/tests/libtest/cli_upload_pausing.c +++ b/tests/libtest/cli_upload_pausing.c @@ -26,7 +26,6 @@ #include "first.h" #include "testtrace.h" -#include "memdebug.h" static size_t total_read = 0; diff --git a/tests/libtest/cli_ws_data.c b/tests/libtest/cli_ws_data.c index aa43bc6058ca..2276f0c92ce1 100644 --- a/tests/libtest/cli_ws_data.c +++ b/tests/libtest/cli_ws_data.c @@ -24,7 +24,6 @@ #include "first.h" #include "testtrace.h" -#include "memdebug.h" #ifndef CURL_DISABLE_WEBSOCKETS @@ -83,8 +82,8 @@ static CURLcode test_ws_data_m2_echo(const char *url, size_t i, scount = count, rcount = count; int rblock, sblock; - send_buf = calloc(1, plen_max + 1); - recv_buf = calloc(1, plen_max + 1); + send_buf = curlx_calloc(1, plen_max + 1); + recv_buf = curlx_calloc(1, plen_max + 1); if(!send_buf || !recv_buf) { r = CURLE_OUT_OF_MEMORY; goto out; @@ -184,8 +183,8 @@ static CURLcode test_ws_data_m2_echo(const char *url, ws_close(curl); curl_easy_cleanup(curl); } - free(send_buf); - free(recv_buf); + curlx_free(send_buf); + curlx_free(recv_buf); return r; } @@ -294,8 +293,8 @@ static CURLcode test_ws_data_m1_echo(const char *url, curl_mfprintf(stderr, "test_ws_data_m1_echo(min=%zu, max=%zu)\n", plen_min, plen_max); memset(&m1_ctx, 0, sizeof(m1_ctx)); - m1_ctx.send_buf = calloc(1, plen_max + 1); - m1_ctx.recv_buf = calloc(1, plen_max + 1); + m1_ctx.send_buf = curlx_calloc(1, plen_max + 1); + m1_ctx.recv_buf = curlx_calloc(1, plen_max + 1); if(!m1_ctx.send_buf || !m1_ctx.recv_buf) { r = CURLE_OUT_OF_MEMORY; goto out; @@ -389,8 +388,8 @@ static CURLcode test_ws_data_m1_echo(const char *url, if(m1_ctx.curl) { curl_easy_cleanup(m1_ctx.curl); } - free(m1_ctx.send_buf); - free(m1_ctx.recv_buf); + curlx_free(m1_ctx.send_buf); + curlx_free(m1_ctx.recv_buf); return r; } diff --git a/tests/libtest/cli_ws_pingpong.c b/tests/libtest/cli_ws_pingpong.c index 0a8e957aa411..8449b9d1278f 100644 --- a/tests/libtest/cli_ws_pingpong.c +++ b/tests/libtest/cli_ws_pingpong.c @@ -24,7 +24,6 @@ #include "first.h" #include "testtrace.h" -#include "memdebug.h" #ifndef CURL_DISABLE_WEBSOCKETS diff --git a/tests/libtest/first.c b/tests/libtest/first.c index a8e2e91cf0cc..2f6553088211 100644 --- a/tests/libtest/first.c +++ b/tests/libtest/first.c @@ -27,8 +27,6 @@ #include /* for setlocale() */ #endif -#include "memdebug.h" - int select_wrapper(int nfds, fd_set *rd, fd_set *wr, fd_set *exc, struct timeval *tv) { diff --git a/tests/libtest/lib1156.c b/tests/libtest/lib1156.c index 6ceb6894e785..758f6e3f1ae9 100644 --- a/tests/libtest/lib1156.c +++ b/tests/libtest/lib1156.c @@ -34,8 +34,6 @@ */ -#include "memdebug.h" - #define F_RESUME (1 << 0) /* resume/range. */ #define F_HTTP416 (1 << 1) /* Server returns http code 416. */ #define F_FAIL (1 << 2) /* Fail on error. */ diff --git a/tests/libtest/lib1485.c b/tests/libtest/lib1485.c index 7fea83317c06..828e1ede74df 100644 --- a/tests/libtest/lib1485.c +++ b/tests/libtest/lib1485.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - struct t1485_transfer_status { CURL *curl; curl_off_t out_len; diff --git a/tests/libtest/lib1500.c b/tests/libtest/lib1500.c index 5fe8e7ab4faf..921d1ce8b182 100644 --- a/tests/libtest/lib1500.c +++ b/tests/libtest/lib1500.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib1500(const char *URL) { CURL *curl = NULL; diff --git a/tests/libtest/lib1501.c b/tests/libtest/lib1501.c index 5b5e64c48cca..cd1cd874f777 100644 --- a/tests/libtest/lib1501.c +++ b/tests/libtest/lib1501.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib1501(const char *URL) { static const long HANG_TIMEOUT = 30 * 1000; diff --git a/tests/libtest/lib1502.c b/tests/libtest/lib1502.c index 527f969b116f..1546acfaa8ad 100644 --- a/tests/libtest/lib1502.c +++ b/tests/libtest/lib1502.c @@ -31,8 +31,6 @@ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib1502(const char *URL) { CURL *curl = NULL; diff --git a/tests/libtest/lib1506.c b/tests/libtest/lib1506.c index 5790f3baebad..8b986c59a029 100644 --- a/tests/libtest/lib1506.c +++ b/tests/libtest/lib1506.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib1506(const char *URL) { CURLcode res = CURLE_OK; diff --git a/tests/libtest/lib1507.c b/tests/libtest/lib1507.c index d9f85a3318aa..ffdaa50df6d3 100644 --- a/tests/libtest/lib1507.c +++ b/tests/libtest/lib1507.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static size_t t1507_read_cb(char *ptr, size_t size, size_t nmemb, void *userp) { (void)ptr; diff --git a/tests/libtest/lib1508.c b/tests/libtest/lib1508.c index b7b47daa3f9e..446e8231a528 100644 --- a/tests/libtest/lib1508.c +++ b/tests/libtest/lib1508.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib1508(const char *URL) { CURLcode res = CURLE_OK; diff --git a/tests/libtest/lib1509.c b/tests/libtest/lib1509.c index 3ab4feea8b8e..16935de7a757 100644 --- a/tests/libtest/lib1509.c +++ b/tests/libtest/lib1509.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static size_t realHeaderSize = 0; static size_t WriteOutput(char *ptr, size_t size, size_t nmemb, void *stream) diff --git a/tests/libtest/lib1510.c b/tests/libtest/lib1510.c index e914d48eb78c..7a70763813d8 100644 --- a/tests/libtest/lib1510.c +++ b/tests/libtest/lib1510.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib1510(const char *URL) { static const int NUM_URLS = 4; diff --git a/tests/libtest/lib1511.c b/tests/libtest/lib1511.c index de09d2a6fa93..fb65dcae988f 100644 --- a/tests/libtest/lib1511.c +++ b/tests/libtest/lib1511.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib1511(const char *URL) { long unmet; diff --git a/tests/libtest/lib1512.c b/tests/libtest/lib1512.c index dd80163d43d4..16648d7e56f4 100644 --- a/tests/libtest/lib1512.c +++ b/tests/libtest/lib1512.c @@ -30,8 +30,6 @@ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib1512(const char *URL) { CURLcode res = CURLE_OK; diff --git a/tests/libtest/lib1513.c b/tests/libtest/lib1513.c index c86c5185e23e..8bf1613fa17b 100644 --- a/tests/libtest/lib1513.c +++ b/tests/libtest/lib1513.c @@ -30,8 +30,6 @@ #include "first.h" -#include "memdebug.h" - static int progressKiller(void *arg, double dltotal, double dlnow, diff --git a/tests/libtest/lib1514.c b/tests/libtest/lib1514.c index fc7e33e3d3b3..fa0aa0742439 100644 --- a/tests/libtest/lib1514.c +++ b/tests/libtest/lib1514.c @@ -28,8 +28,6 @@ #include "first.h" -#include "memdebug.h" - struct t1514_WriteThis { char *readptr; size_t sizeleft; diff --git a/tests/libtest/lib1515.c b/tests/libtest/lib1515.c index 679a413c69a3..7833f06a10f6 100644 --- a/tests/libtest/lib1515.c +++ b/tests/libtest/lib1515.c @@ -31,7 +31,6 @@ #include "first.h" #include "testtrace.h" -#include "memdebug.h" #define DNS_TIMEOUT 1L diff --git a/tests/libtest/lib1517.c b/tests/libtest/lib1517.c index d8ad3b753bb2..cebdeab0a1b4 100644 --- a/tests/libtest/lib1517.c +++ b/tests/libtest/lib1517.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - struct t1517_WriteThis { const char *readptr; size_t sizeleft; diff --git a/tests/libtest/lib1518.c b/tests/libtest/lib1518.c index 63e861910dd1..1ebe957af3f7 100644 --- a/tests/libtest/lib1518.c +++ b/tests/libtest/lib1518.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - /* Test inspired by github issue 3340 */ static size_t t1518_write_cb(char *buffer, size_t size, size_t nitems, diff --git a/tests/libtest/lib1520.c b/tests/libtest/lib1520.c index e61727eadc22..4cf54388eb1a 100644 --- a/tests/libtest/lib1520.c +++ b/tests/libtest/lib1520.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - struct upload_status { int lines_read; }; diff --git a/tests/libtest/lib1522.c b/tests/libtest/lib1522.c index 3423f4777c95..1ac2332e8121 100644 --- a/tests/libtest/lib1522.c +++ b/tests/libtest/lib1522.c @@ -26,7 +26,6 @@ /* test case and code based on https://github.com/curl/curl/issues/2847 */ #include "testtrace.h" -#include "memdebug.h" static int sockopt_callback(void *clientp, curl_socket_t curlfd, curlsocktype purpose) diff --git a/tests/libtest/lib1523.c b/tests/libtest/lib1523.c index 5c9a01a5eb1b..711aa3f7140f 100644 --- a/tests/libtest/lib1523.c +++ b/tests/libtest/lib1523.c @@ -25,8 +25,6 @@ /* test case and code based on https://github.com/curl/curl/issues/3927 */ -#include "memdebug.h" - static int dload_progress_cb(void *a, curl_off_t b, curl_off_t c, curl_off_t d, curl_off_t e) { diff --git a/tests/libtest/lib1525.c b/tests/libtest/lib1525.c index 7e7d98ef7997..c9a1e1514f80 100644 --- a/tests/libtest/lib1525.c +++ b/tests/libtest/lib1525.c @@ -30,8 +30,6 @@ #include "first.h" -#include "memdebug.h" - static const char t1525_testdata[] = "Hello Cloud!\n"; static size_t t1525_read_cb(char *ptr, size_t size, size_t nmemb, void *stream) diff --git a/tests/libtest/lib1526.c b/tests/libtest/lib1526.c index bf2a07ee9dfe..031f8bfd2746 100644 --- a/tests/libtest/lib1526.c +++ b/tests/libtest/lib1526.c @@ -29,8 +29,6 @@ #include "first.h" -#include "memdebug.h" - static const char t1526_testdata[] = "Hello Cloud!\n"; static size_t t1526_read_cb(char *ptr, size_t size, size_t nmemb, void *stream) diff --git a/tests/libtest/lib1527.c b/tests/libtest/lib1527.c index 362472868799..1d9a5821324b 100644 --- a/tests/libtest/lib1527.c +++ b/tests/libtest/lib1527.c @@ -29,8 +29,6 @@ #include "first.h" -#include "memdebug.h" - static const char t1527_testdata[] = "Hello Cloud!\n"; static size_t t1527_read_cb(char *ptr, size_t size, size_t nmemb, void *stream) diff --git a/tests/libtest/lib1528.c b/tests/libtest/lib1528.c index 98bd2bdaf18a..e1dd3657fe42 100644 --- a/tests/libtest/lib1528.c +++ b/tests/libtest/lib1528.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib1528(const char *URL) { CURL *curl = NULL; diff --git a/tests/libtest/lib1529.c b/tests/libtest/lib1529.c index ae86b61a5e67..24cdd78b0315 100644 --- a/tests/libtest/lib1529.c +++ b/tests/libtest/lib1529.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib1529(const char *URL) { CURL *curl = NULL; diff --git a/tests/libtest/lib1530.c b/tests/libtest/lib1530.c index 19b0d9cbde38..6cb6d59e874f 100644 --- a/tests/libtest/lib1530.c +++ b/tests/libtest/lib1530.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static curl_socket_t opensocket(void *clientp, curlsocktype purpose, struct curl_sockaddr *address) diff --git a/tests/libtest/lib1531.c b/tests/libtest/lib1531.c index 65b20c2993b4..a3554434e643 100644 --- a/tests/libtest/lib1531.c +++ b/tests/libtest/lib1531.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib1531(const char *URL) { static char const testData[] = ".abc\0xyz"; diff --git a/tests/libtest/lib1532.c b/tests/libtest/lib1532.c index 83a826de32d2..e1c5c0470278 100644 --- a/tests/libtest/lib1532.c +++ b/tests/libtest/lib1532.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - /* Test CURLINFO_RESPONSE_CODE */ static CURLcode test_lib1532(const char *URL) diff --git a/tests/libtest/lib1533.c b/tests/libtest/lib1533.c index 1c6017273410..a2d541c4124f 100644 --- a/tests/libtest/lib1533.c +++ b/tests/libtest/lib1533.c @@ -31,8 +31,6 @@ #include "first.h" -#include "memdebug.h" - struct cb_data { CURL *curl; int response_received; diff --git a/tests/libtest/lib1534.c b/tests/libtest/lib1534.c index af1c0bd52020..377df3b2fe19 100644 --- a/tests/libtest/lib1534.c +++ b/tests/libtest/lib1534.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - /* Test CURLINFO_FILETIME */ static CURLcode test_lib1534(const char *URL) diff --git a/tests/libtest/lib1535.c b/tests/libtest/lib1535.c index c0e0689d98ba..c49c3076dfee 100644 --- a/tests/libtest/lib1535.c +++ b/tests/libtest/lib1535.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - /* Test CURLINFO_PROTOCOL */ static CURLcode test_lib1535(const char *URL) diff --git a/tests/libtest/lib1536.c b/tests/libtest/lib1536.c index 3219724b9aef..f89b50a19583 100644 --- a/tests/libtest/lib1536.c +++ b/tests/libtest/lib1536.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - /* Test CURLINFO_SCHEME */ static CURLcode test_lib1536(const char *URL) diff --git a/tests/libtest/lib1537.c b/tests/libtest/lib1537.c index cb35fb19087c..f521986ebc54 100644 --- a/tests/libtest/lib1537.c +++ b/tests/libtest/lib1537.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib1537(const char *URL) { const unsigned char a[] = {0x2f, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, diff --git a/tests/libtest/lib1538.c b/tests/libtest/lib1538.c index 9aaec8171a18..2a8830c5cce9 100644 --- a/tests/libtest/lib1538.c +++ b/tests/libtest/lib1538.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib1538(const char *URL) { CURLcode res = CURLE_OK; diff --git a/tests/libtest/lib1540.c b/tests/libtest/lib1540.c index 7f9123435632..849431e79633 100644 --- a/tests/libtest/lib1540.c +++ b/tests/libtest/lib1540.c @@ -24,7 +24,6 @@ #include "first.h" #include "testtrace.h" -#include "memdebug.h" struct t1540_transfer_status { CURL *curl; diff --git a/tests/libtest/lib1541.c b/tests/libtest/lib1541.c index 150fd2e30bc9..c39bee989cd7 100644 --- a/tests/libtest/lib1541.c +++ b/tests/libtest/lib1541.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - struct t1541_transfer_status { CURL *curl; int hd_count; diff --git a/tests/libtest/lib1542.c b/tests/libtest/lib1542.c index 9fc9f17efb46..9a6ba0b36e0a 100644 --- a/tests/libtest/lib1542.c +++ b/tests/libtest/lib1542.c @@ -33,7 +33,6 @@ #include "first.h" #include "testtrace.h" -#include "memdebug.h" static CURLcode test_lib1542(const char *URL) { diff --git a/tests/libtest/lib1549.c b/tests/libtest/lib1549.c index 10d318381027..fa9515e4f6cb 100644 --- a/tests/libtest/lib1549.c +++ b/tests/libtest/lib1549.c @@ -24,7 +24,6 @@ #include "first.h" #include "testtrace.h" -#include "memdebug.h" static CURLcode test_lib1549(const char *URL) { diff --git a/tests/libtest/lib1550.c b/tests/libtest/lib1550.c index 566cbfa1928a..b328dd27bc2a 100644 --- a/tests/libtest/lib1550.c +++ b/tests/libtest/lib1550.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - #include static CURLcode test_lib1550(const char *URL) diff --git a/tests/libtest/lib1551.c b/tests/libtest/lib1551.c index 80020f55566d..ce4989a6163d 100644 --- a/tests/libtest/lib1551.c +++ b/tests/libtest/lib1551.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - #include static CURLcode test_lib1551(const char *URL) diff --git a/tests/libtest/lib1552.c b/tests/libtest/lib1552.c index d0c3469d4cea..bceacd354cdf 100644 --- a/tests/libtest/lib1552.c +++ b/tests/libtest/lib1552.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib1552(const char *URL) { CURL *curl = NULL; diff --git a/tests/libtest/lib1553.c b/tests/libtest/lib1553.c index fa753ac23102..d1eaefee4a4e 100644 --- a/tests/libtest/lib1553.c +++ b/tests/libtest/lib1553.c @@ -24,7 +24,6 @@ #include "first.h" #include "testtrace.h" -#include "memdebug.h" static int t1553_xferinfo(void *p, curl_off_t dltotal, curl_off_t dlnow, diff --git a/tests/libtest/lib1554.c b/tests/libtest/lib1554.c index a23d713e63d7..f330b2df7d90 100644 --- a/tests/libtest/lib1554.c +++ b/tests/libtest/lib1554.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static const char *ldata_names[] = { "NONE", "SHARE", diff --git a/tests/libtest/lib1555.c b/tests/libtest/lib1555.c index 4ebde5c74c6d..001a8f5bae7e 100644 --- a/tests/libtest/lib1555.c +++ b/tests/libtest/lib1555.c @@ -27,8 +27,6 @@ #include "first.h" -#include "memdebug.h" - static CURL *t1555_curl; static int progressCallback(void *arg, diff --git a/tests/libtest/lib1556.c b/tests/libtest/lib1556.c index 4987fc9f0969..e852bb322471 100644 --- a/tests/libtest/lib1556.c +++ b/tests/libtest/lib1556.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - struct headerinfo { size_t largest; }; diff --git a/tests/libtest/lib1557.c b/tests/libtest/lib1557.c index 1c2785dbe33e..28162a1b0342 100644 --- a/tests/libtest/lib1557.c +++ b/tests/libtest/lib1557.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib1557(const char *URL) { CURLM *multi = NULL; diff --git a/tests/libtest/lib1558.c b/tests/libtest/lib1558.c index 1bbc0f77b75f..d299405fe214 100644 --- a/tests/libtest/lib1558.c +++ b/tests/libtest/lib1558.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib1558(const char *URL) { CURLcode res = CURLE_OK; diff --git a/tests/libtest/lib1559.c b/tests/libtest/lib1559.c index 1aa0f830c75d..c6851918a685 100644 --- a/tests/libtest/lib1559.c +++ b/tests/libtest/lib1559.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib1559(const char *URL) { static const int EXCESSIVE = 10*1000*1000; @@ -38,7 +36,7 @@ static CURLcode test_lib1559(const char *URL) global_init(CURL_GLOBAL_ALL); easy_init(curl); - longurl = malloc(EXCESSIVE); + longurl = curlx_malloc(EXCESSIVE); if(!longurl) { res = TEST_ERR_MAJOR_BAD; goto test_cleanup; @@ -70,7 +68,7 @@ static CURLcode test_lib1559(const char *URL) } test_cleanup: - free(longurl); + curlx_free(longurl); curl_easy_cleanup(curl); curl_global_cleanup(); diff --git a/tests/libtest/lib1560.c b/tests/libtest/lib1560.c index db85fe738239..2f6608108cca 100644 --- a/tests/libtest/lib1560.c +++ b/tests/libtest/lib1560.c @@ -35,8 +35,6 @@ #define USE_IDN #endif -#include "memdebug.h" /* LAST include file */ - static int checkparts(CURLU *u, const char *in, const char *wanted, unsigned int getflags) { diff --git a/tests/libtest/lib1564.c b/tests/libtest/lib1564.c index 42b3a07d1a91..23d0c2cd6f43 100644 --- a/tests/libtest/lib1564.c +++ b/tests/libtest/lib1564.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - #define WAKEUP_NUM 10 static CURLcode test_lib1564(const char *URL) diff --git a/tests/libtest/lib1565.c b/tests/libtest/lib1565.c index 7e983978e7bf..506959dd9083 100644 --- a/tests/libtest/lib1565.c +++ b/tests/libtest/lib1565.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - #ifdef HAVE_PTHREAD_H #include diff --git a/tests/libtest/lib1567.c b/tests/libtest/lib1567.c index e0016157256e..539da3c34f86 100644 --- a/tests/libtest/lib1567.c +++ b/tests/libtest/lib1567.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - #include static CURLcode test_lib1567(const char *URL) diff --git a/tests/libtest/lib1568.c b/tests/libtest/lib1568.c index 89dd83480dad..0db1e49e2f7a 100644 --- a/tests/libtest/lib1568.c +++ b/tests/libtest/lib1568.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib1568(const char *URL) { CURLcode res = TEST_ERR_MAJOR_BAD; diff --git a/tests/libtest/lib1569.c b/tests/libtest/lib1569.c index c2fd27bfe195..44d77a5d455b 100644 --- a/tests/libtest/lib1569.c +++ b/tests/libtest/lib1569.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib1569(const char *URL) { CURLcode res = CURLE_OK; diff --git a/tests/libtest/lib1571.c b/tests/libtest/lib1571.c index 622be2f643d0..8b29a9a1bf17 100644 --- a/tests/libtest/lib1571.c +++ b/tests/libtest/lib1571.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib1571(const char *URL) { CURLcode res; diff --git a/tests/libtest/lib1576.c b/tests/libtest/lib1576.c index 203ef2b9891e..9a5d415193e3 100644 --- a/tests/libtest/lib1576.c +++ b/tests/libtest/lib1576.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static char t1576_testdata[] = "request indicates that the client, which made"; static size_t t1576_read_cb(char *ptr, size_t size, size_t nmemb, void *stream) diff --git a/tests/libtest/lib1582.c b/tests/libtest/lib1582.c index 0e209beee450..e1877a99ac5a 100644 --- a/tests/libtest/lib1582.c +++ b/tests/libtest/lib1582.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib1582(const char *URL) { CURLcode res; diff --git a/tests/libtest/lib1591.c b/tests/libtest/lib1591.c index 3031ba1bb71c..42761c3065d2 100644 --- a/tests/libtest/lib1591.c +++ b/tests/libtest/lib1591.c @@ -29,8 +29,6 @@ #include "first.h" -#include "memdebug.h" - static size_t consumed = 0; static size_t t1591_read_cb(char *ptr, size_t size, size_t nmemb, void *stream) diff --git a/tests/libtest/lib1593.c b/tests/libtest/lib1593.c index 5b6e57d4f752..f8d7be9d7273 100644 --- a/tests/libtest/lib1593.c +++ b/tests/libtest/lib1593.c @@ -26,8 +26,6 @@ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib1593(const char *URL) { struct curl_slist *header = NULL; diff --git a/tests/libtest/lib1594.c b/tests/libtest/lib1594.c index 5c8db3ae92ae..6cf5cace5335 100644 --- a/tests/libtest/lib1594.c +++ b/tests/libtest/lib1594.c @@ -26,8 +26,6 @@ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib1594(const char *URL) { struct curl_slist *header = NULL; diff --git a/tests/libtest/lib1597.c b/tests/libtest/lib1597.c index 251016641e7a..a338a53944fb 100644 --- a/tests/libtest/lib1597.c +++ b/tests/libtest/lib1597.c @@ -26,8 +26,6 @@ #include "first.h" -#include "memdebug.h" - struct pair { const char *in; CURLcode *exp; diff --git a/tests/libtest/lib1598.c b/tests/libtest/lib1598.c index 4120916ff0ab..8d9ec7eb8e6b 100644 --- a/tests/libtest/lib1598.c +++ b/tests/libtest/lib1598.c @@ -29,8 +29,6 @@ #include "first.h" -#include "memdebug.h" - /* * carefully not leak memory on OOM */ diff --git a/tests/libtest/lib1900.c b/tests/libtest/lib1900.c index 2f0954bb6c52..04ce5aa9f197 100644 --- a/tests/libtest/lib1900.c +++ b/tests/libtest/lib1900.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib1900(const char *URL) { CURLcode res = CURLE_OK; diff --git a/tests/libtest/lib1901.c b/tests/libtest/lib1901.c index cb66001f9bb2..4494633b94f3 100644 --- a/tests/libtest/lib1901.c +++ b/tests/libtest/lib1901.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static size_t t1901_read_cb(char *ptr, size_t size, size_t nmemb, void *stream) { static const char *chunks[] = { diff --git a/tests/libtest/lib1902.c b/tests/libtest/lib1902.c index 8e5929e33827..e114554ec526 100644 --- a/tests/libtest/lib1902.c +++ b/tests/libtest/lib1902.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib1902(const char *URL) { CURLcode res = CURLE_OK; diff --git a/tests/libtest/lib1903.c b/tests/libtest/lib1903.c index fc2858d5eecb..19c2f50e197a 100644 --- a/tests/libtest/lib1903.c +++ b/tests/libtest/lib1903.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib1903(const char *URL) { CURLcode res = CURLE_OK; diff --git a/tests/libtest/lib1905.c b/tests/libtest/lib1905.c index 600e6962383e..d1fdba4d2ea5 100644 --- a/tests/libtest/lib1905.c +++ b/tests/libtest/lib1905.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib1905(const char *URL) { CURLSH *share = NULL; diff --git a/tests/libtest/lib1906.c b/tests/libtest/lib1906.c index da0f9f56b900..07404f8b9054 100644 --- a/tests/libtest/lib1906.c +++ b/tests/libtest/lib1906.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib1906(const char *URL) { CURLcode res = CURLE_OK; diff --git a/tests/libtest/lib1907.c b/tests/libtest/lib1907.c index 0a3556719b61..ebf106d3b1e4 100644 --- a/tests/libtest/lib1907.c +++ b/tests/libtest/lib1907.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib1907(const char *URL) { char *url_after; diff --git a/tests/libtest/lib1908.c b/tests/libtest/lib1908.c index ac841ca1a18b..2ceb04d5a243 100644 --- a/tests/libtest/lib1908.c +++ b/tests/libtest/lib1908.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib1908(const char *URL) { CURLcode res = TEST_ERR_MAJOR_BAD; diff --git a/tests/libtest/lib1910.c b/tests/libtest/lib1910.c index ebe86c12453c..4f2277752692 100644 --- a/tests/libtest/lib1910.c +++ b/tests/libtest/lib1910.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib1910(const char *URL) { CURLcode res = TEST_ERR_MAJOR_BAD; diff --git a/tests/libtest/lib1911.c b/tests/libtest/lib1911.c index 46c73ffb361d..0f88752b6fbd 100644 --- a/tests/libtest/lib1911.c +++ b/tests/libtest/lib1911.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - /* The maximum string length limit (CURL_MAX_INPUT_LENGTH) is an internal define not publicly exposed so we set our own */ #define MAX_INPUT_LENGTH 8000000 diff --git a/tests/libtest/lib1912.c b/tests/libtest/lib1912.c index 0dd246e4612b..76ba51c4479f 100644 --- a/tests/libtest/lib1912.c +++ b/tests/libtest/lib1912.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - #define print_err(name, exp) \ curl_mfprintf(stderr, "Type mismatch for CURLOPT_%s (expected %s)\n", \ name, exp) diff --git a/tests/libtest/lib1913.c b/tests/libtest/lib1913.c index cea7a6c6ec81..b4b4ab720f83 100644 --- a/tests/libtest/lib1913.c +++ b/tests/libtest/lib1913.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib1913(const char *URL) { CURLcode res = TEST_ERR_MAJOR_BAD; diff --git a/tests/libtest/lib1915.c b/tests/libtest/lib1915.c index e47ae9ee8028..367533aef64f 100644 --- a/tests/libtest/lib1915.c +++ b/tests/libtest/lib1915.c @@ -24,7 +24,6 @@ #include "first.h" #include "testtrace.h" -#include "memdebug.h" struct state { int index; diff --git a/tests/libtest/lib1916.c b/tests/libtest/lib1916.c index 24583ab8a189..4c66b1b97ead 100644 --- a/tests/libtest/lib1916.c +++ b/tests/libtest/lib1916.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib1916(const char *URL) { CURL *curl; diff --git a/tests/libtest/lib1918.c b/tests/libtest/lib1918.c index de9252107bfb..d99563916416 100644 --- a/tests/libtest/lib1918.c +++ b/tests/libtest/lib1918.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib1918(const char *URL) { const struct curl_easyoption *o; diff --git a/tests/libtest/lib1919.c b/tests/libtest/lib1919.c index a619850dc718..79d31810a466 100644 --- a/tests/libtest/lib1919.c +++ b/tests/libtest/lib1919.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib1919(const char *URL) { CURLcode res = CURLE_OK; diff --git a/tests/libtest/lib1933.c b/tests/libtest/lib1933.c index bdd914a641ef..8b02f16aa7f8 100644 --- a/tests/libtest/lib1933.c +++ b/tests/libtest/lib1933.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib1933(const char *URL) { CURL *curl; diff --git a/tests/libtest/lib1934.c b/tests/libtest/lib1934.c index 2cffaa9bc790..465dfeb5dec6 100644 --- a/tests/libtest/lib1934.c +++ b/tests/libtest/lib1934.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib1934(const char *URL) { CURL *curl; diff --git a/tests/libtest/lib1935.c b/tests/libtest/lib1935.c index 4f6a1ebb731c..61382399a32f 100644 --- a/tests/libtest/lib1935.c +++ b/tests/libtest/lib1935.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib1935(const char *URL) { CURL *curl; diff --git a/tests/libtest/lib1936.c b/tests/libtest/lib1936.c index 438cf92c58e0..20b170397e3c 100644 --- a/tests/libtest/lib1936.c +++ b/tests/libtest/lib1936.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib1936(const char *URL) { CURL *curl; diff --git a/tests/libtest/lib1937.c b/tests/libtest/lib1937.c index 4903f7409a5c..c6fb120b6ad6 100644 --- a/tests/libtest/lib1937.c +++ b/tests/libtest/lib1937.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib1937(const char *URL) { CURL *curl; diff --git a/tests/libtest/lib1938.c b/tests/libtest/lib1938.c index c0bfb6b8ced9..b585c53c0114 100644 --- a/tests/libtest/lib1938.c +++ b/tests/libtest/lib1938.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib1938(const char *URL) { CURL *curl; diff --git a/tests/libtest/lib1939.c b/tests/libtest/lib1939.c index 9985af5adc28..b3d79fc68dd1 100644 --- a/tests/libtest/lib1939.c +++ b/tests/libtest/lib1939.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib1939(const char *URL) { CURLM *multi; diff --git a/tests/libtest/lib1940.c b/tests/libtest/lib1940.c index 283128dc31d6..75b8f7818c02 100644 --- a/tests/libtest/lib1940.c +++ b/tests/libtest/lib1940.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static size_t t1940_write_cb(char *data, size_t n, size_t l, void *userp) { /* take care of the data here, ignored in this example */ diff --git a/tests/libtest/lib1945.c b/tests/libtest/lib1945.c index ee8e69f10016..99044880cfe8 100644 --- a/tests/libtest/lib1945.c +++ b/tests/libtest/lib1945.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static void t1945_showem(CURL *curl, unsigned int type) { struct curl_header *header = NULL; diff --git a/tests/libtest/lib1947.c b/tests/libtest/lib1947.c index 19fbcb7af417..acbc260aa1d5 100644 --- a/tests/libtest/lib1947.c +++ b/tests/libtest/lib1947.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static size_t t1947_write_cb(char *data, size_t n, size_t l, void *userp) { /* ignore the data */ diff --git a/tests/libtest/lib1955.c b/tests/libtest/lib1955.c index e47a52275e74..3fe118269e82 100644 --- a/tests/libtest/lib1955.c +++ b/tests/libtest/lib1955.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib1955(const char *URL) { CURL *curl; diff --git a/tests/libtest/lib1956.c b/tests/libtest/lib1956.c index 0f1c72e3d2e2..a86a4c9e4ca3 100644 --- a/tests/libtest/lib1956.c +++ b/tests/libtest/lib1956.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib1956(const char *URL) { CURL *curl; diff --git a/tests/libtest/lib1957.c b/tests/libtest/lib1957.c index 8eeed09b7c34..c7864a150c47 100644 --- a/tests/libtest/lib1957.c +++ b/tests/libtest/lib1957.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib1957(const char *URL) { CURL *curl; diff --git a/tests/libtest/lib1958.c b/tests/libtest/lib1958.c index 7a94c76709a3..9a7f12f286ab 100644 --- a/tests/libtest/lib1958.c +++ b/tests/libtest/lib1958.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib1958(const char *URL) { CURL *curl; diff --git a/tests/libtest/lib1959.c b/tests/libtest/lib1959.c index d718149772e3..6739cfe3ab9e 100644 --- a/tests/libtest/lib1959.c +++ b/tests/libtest/lib1959.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib1959(const char *URL) { CURL *curl; diff --git a/tests/libtest/lib1960.c b/tests/libtest/lib1960.c index 152b1053f133..2dbdf5995fd3 100644 --- a/tests/libtest/lib1960.c +++ b/tests/libtest/lib1960.c @@ -32,8 +32,6 @@ #include #endif -#include "memdebug.h" - /* to prevent libcurl from closing our socket */ static int closesocket_cb(void *clientp, curl_socket_t item) { diff --git a/tests/libtest/lib1964.c b/tests/libtest/lib1964.c index cbad31dcc00f..9536575ba82d 100644 --- a/tests/libtest/lib1964.c +++ b/tests/libtest/lib1964.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib1964(const char *URL) { CURL *curl; diff --git a/tests/libtest/lib1970.c b/tests/libtest/lib1970.c index 5ba51f6a58f2..fa110462c2c6 100644 --- a/tests/libtest/lib1970.c +++ b/tests/libtest/lib1970.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib1970(const char *URL) { CURL *curl; diff --git a/tests/libtest/lib1971.c b/tests/libtest/lib1971.c index bc25226bded6..982f06b28629 100644 --- a/tests/libtest/lib1971.c +++ b/tests/libtest/lib1971.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static size_t t1971_read_cb(char *ptr, size_t size, size_t nitems, void *userp) { (void)ptr; diff --git a/tests/libtest/lib1972.c b/tests/libtest/lib1972.c index ec9c9b06988f..7931e866bf70 100644 --- a/tests/libtest/lib1972.c +++ b/tests/libtest/lib1972.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib1972(const char *URL) { CURL *curl; diff --git a/tests/libtest/lib1973.c b/tests/libtest/lib1973.c index e887e80c2e0b..2cc1c8ebfe0c 100644 --- a/tests/libtest/lib1973.c +++ b/tests/libtest/lib1973.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib1973(const char *URL) { CURL *curl; diff --git a/tests/libtest/lib1974.c b/tests/libtest/lib1974.c index b2d0b59450ea..1534cfadeeba 100644 --- a/tests/libtest/lib1974.c +++ b/tests/libtest/lib1974.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib1974(const char *URL) { CURL *curl; diff --git a/tests/libtest/lib1975.c b/tests/libtest/lib1975.c index d6c05a1251f2..c5b6568a07b1 100644 --- a/tests/libtest/lib1975.c +++ b/tests/libtest/lib1975.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static size_t t1975_read_cb(char *ptr, size_t size, size_t nitems, void *userp) { (void)ptr; diff --git a/tests/libtest/lib1977.c b/tests/libtest/lib1977.c index dae8bcbae70b..10412f66c0c4 100644 --- a/tests/libtest/lib1977.c +++ b/tests/libtest/lib1977.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib1977(const char *URL) { CURLcode res = CURLE_OK; diff --git a/tests/libtest/lib1978.c b/tests/libtest/lib1978.c index 113f06da8f3b..6c06e727dcb1 100644 --- a/tests/libtest/lib1978.c +++ b/tests/libtest/lib1978.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib1978(const char *URL) { CURL *curl; diff --git a/tests/libtest/lib2023.c b/tests/libtest/lib2023.c index 8c181fa09338..1475deb2d3f8 100644 --- a/tests/libtest/lib2023.c +++ b/tests/libtest/lib2023.c @@ -28,14 +28,12 @@ #include "first.h" -#include "memdebug.h" - static CURLcode send_request(CURL *curl, const char *url, int seq, long auth_scheme, const char *userpwd) { CURLcode res; size_t len = strlen(url) + 4 + 1; - char *full_url = malloc(len); + char *full_url = curlx_malloc(len); if(!full_url) { curl_mfprintf(stderr, "Not enough memory for full url\n"); return CURLE_OUT_OF_MEMORY; @@ -54,7 +52,7 @@ static CURLcode send_request(CURL *curl, const char *url, int seq, res = curl_easy_perform(curl); test_cleanup: - free(full_url); + curlx_free(full_url); return res; } diff --git a/tests/libtest/lib2032.c b/tests/libtest/lib2032.c index e0f9990f59f4..a733f34e6fc0 100644 --- a/tests/libtest/lib2032.c +++ b/tests/libtest/lib2032.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - #define MAX_EASY_HANDLES 3 static int ntlm_counter[MAX_EASY_HANDLES]; @@ -92,7 +90,7 @@ static CURLcode test_lib2032(const char *URL) /* libntlmconnect */ int num_handles = 0; enum HandleState state = ReadyForNewHandle; size_t urllen = strlen(URL) + 4 + 1; - char *full_url = malloc(urllen); + char *full_url = curlx_malloc(urllen); start_test_timing(); @@ -108,7 +106,7 @@ static CURLcode test_lib2032(const char *URL) /* libntlmconnect */ res_global_init(CURL_GLOBAL_ALL); if(res) { - free(full_url); + curlx_free(full_url); return res; } @@ -230,7 +228,7 @@ static CURLcode test_lib2032(const char *URL) /* libntlmconnect */ curl_multi_cleanup(multi); curl_global_cleanup(); - free(full_url); + curlx_free(full_url); return res; } diff --git a/tests/libtest/lib2302.c b/tests/libtest/lib2302.c index 47276197bb08..aa0be3d5140d 100644 --- a/tests/libtest/lib2302.c +++ b/tests/libtest/lib2302.c @@ -102,7 +102,7 @@ static CURLcode test_lib2302(const char *URL) global_init(CURL_GLOBAL_ALL); memset(&ws_data, 0, sizeof(ws_data)); - ws_data.buf = (char *)calloc(LIB2302_BUFSIZE, 1); + ws_data.buf = (char *)curlx_calloc(LIB2302_BUFSIZE, 1); if(ws_data.buf) { curl = curl_easy_init(); if(curl) { @@ -120,7 +120,7 @@ static CURLcode test_lib2302(const char *URL) curl_easy_cleanup(curl); flush_data(&ws_data); } - free(ws_data.buf); + curlx_free(ws_data.buf); } curl_global_cleanup(); return res; diff --git a/tests/libtest/lib2402.c b/tests/libtest/lib2402.c index 1695208716b1..58c1b6c431fe 100644 --- a/tests/libtest/lib2402.c +++ b/tests/libtest/lib2402.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib2402(const char *URL) { CURLcode res = CURLE_OK; diff --git a/tests/libtest/lib2404.c b/tests/libtest/lib2404.c index 42d81d8d4ae6..93a3ef926f40 100644 --- a/tests/libtest/lib2404.c +++ b/tests/libtest/lib2404.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib2404(const char *URL) { CURLcode res = CURLE_OK; diff --git a/tests/libtest/lib2405.c b/tests/libtest/lib2405.c index 4f3c8015c64e..97d0d5d231e5 100644 --- a/tests/libtest/lib2405.c +++ b/tests/libtest/lib2405.c @@ -39,8 +39,6 @@ #include "first.h" -#include "memdebug.h" - /* ---------------------------------------------------------------- */ #define test_check(expected_fds) \ diff --git a/tests/libtest/lib2502.c b/tests/libtest/lib2502.c index b9a2cabd798c..4b5e0ef6833e 100644 --- a/tests/libtest/lib2502.c +++ b/tests/libtest/lib2502.c @@ -24,7 +24,6 @@ #include "first.h" #include "testtrace.h" -#include "memdebug.h" static CURLcode test_lib2502(const char *URL) { diff --git a/tests/libtest/lib2700.c b/tests/libtest/lib2700.c index f50908964543..1760d243ea1a 100644 --- a/tests/libtest/lib2700.c +++ b/tests/libtest/lib2700.c @@ -24,7 +24,6 @@ #include "first.h" #include "testtrace.h" -#include "memdebug.h" #ifndef CURL_DISABLE_WEBSOCKETS diff --git a/tests/libtest/lib3010.c b/tests/libtest/lib3010.c index 4595f4de3577..0f805c2d6f7f 100644 --- a/tests/libtest/lib3010.c +++ b/tests/libtest/lib3010.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib3010(const char *URL) { CURLcode res = TEST_ERR_MAJOR_BAD; diff --git a/tests/libtest/lib3025.c b/tests/libtest/lib3025.c index b0056193b772..7d94c4062684 100644 --- a/tests/libtest/lib3025.c +++ b/tests/libtest/lib3025.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib3025(const char *URL) { CURLcode res; diff --git a/tests/libtest/lib3027.c b/tests/libtest/lib3027.c index 5cd2bd757d86..7a25c214bb9b 100644 --- a/tests/libtest/lib3027.c +++ b/tests/libtest/lib3027.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib3027(const char *URL) { CURLcode ret = CURLE_OK; diff --git a/tests/libtest/lib3033.c b/tests/libtest/lib3033.c index b00bba9e7466..428de8afc31d 100644 --- a/tests/libtest/lib3033.c +++ b/tests/libtest/lib3033.c @@ -25,8 +25,6 @@ #include "testtrace.h" -#include "memdebug.h" - static CURLcode t3033_req_test(CURLM *multi, CURL *curl, const char *URL, int index) { diff --git a/tests/libtest/lib3100.c b/tests/libtest/lib3100.c index b661aa76ceb1..e9a2b4111c77 100644 --- a/tests/libtest/lib3100.c +++ b/tests/libtest/lib3100.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib3100(const char *URL) { CURLcode res; diff --git a/tests/libtest/lib3101.c b/tests/libtest/lib3101.c index 3f5cbce17cbf..d95167f0ce6d 100644 --- a/tests/libtest/lib3101.c +++ b/tests/libtest/lib3101.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib3101(const char *URL) { CURLcode res; diff --git a/tests/libtest/lib3102.c b/tests/libtest/lib3102.c index 9cc87543dc87..72da47551e40 100644 --- a/tests/libtest/lib3102.c +++ b/tests/libtest/lib3102.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - /* * Verify correct order of certificates in the chain by comparing the * subject and issuer attributes of each certificate. diff --git a/tests/libtest/lib3103.c b/tests/libtest/lib3103.c index 5b25e1cd4175..4e3a0d79fd4d 100644 --- a/tests/libtest/lib3103.c +++ b/tests/libtest/lib3103.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib3103(const char *URL) { CURLcode res = CURLE_OK; diff --git a/tests/libtest/lib3104.c b/tests/libtest/lib3104.c index dd1500ede55c..278aa515b1de 100644 --- a/tests/libtest/lib3104.c +++ b/tests/libtest/lib3104.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib3104(const char *URL) { CURLcode res = CURLE_OK; diff --git a/tests/libtest/lib3105.c b/tests/libtest/lib3105.c index 808fd98ca4de..a3cbf28bb8b5 100644 --- a/tests/libtest/lib3105.c +++ b/tests/libtest/lib3105.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib3105(const char *URL) { CURL *curl = NULL; diff --git a/tests/libtest/lib3207.c b/tests/libtest/lib3207.c index 8ba88e4a66b6..7757643a269b 100644 --- a/tests/libtest/lib3207.c +++ b/tests/libtest/lib3207.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - #ifdef USE_THREADS_POSIX #include #endif @@ -48,7 +46,7 @@ static size_t write_memory_callback(char *contents, size_t size, /* append the data to contents */ size_t realsize = size * nmemb; struct Ctx *mem = (struct Ctx *)userp; - char *data = (char *)malloc(realsize + 1); + char *data = (char *)curlx_malloc(realsize + 1); struct curl_slist *item_append = NULL; if(!data) { curl_mprintf("not enough memory (malloc returned NULL)\n"); @@ -57,7 +55,7 @@ static size_t write_memory_callback(char *contents, size_t size, memcpy(data, contents, realsize); data[realsize] = '\0'; item_append = curl_slist_append(mem->contents, data); - free(data); + curlx_free(data); if(item_append) { mem->contents = item_append; } diff --git a/tests/libtest/lib3208.c b/tests/libtest/lib3208.c index 39585c159775..befa92e6d0ca 100644 --- a/tests/libtest/lib3208.c +++ b/tests/libtest/lib3208.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib3208(const char *URL) { CURL *curl = NULL; diff --git a/tests/libtest/lib500.c b/tests/libtest/lib500.c index ff886a05ca60..0d01b0102649 100644 --- a/tests/libtest/lib500.c +++ b/tests/libtest/lib500.c @@ -24,7 +24,6 @@ #include "first.h" #include "testtrace.h" -#include "memdebug.h" static int testcounter; diff --git a/tests/libtest/lib501.c b/tests/libtest/lib501.c index d761c8a63604..3dbed1cd4ff5 100644 --- a/tests/libtest/lib501.c +++ b/tests/libtest/lib501.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib501(const char *URL) { CURLcode res; diff --git a/tests/libtest/lib502.c b/tests/libtest/lib502.c index c33783ea687a..4e1fc14a97a7 100644 --- a/tests/libtest/lib502.c +++ b/tests/libtest/lib502.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - /* * Get a single URL without select(). */ diff --git a/tests/libtest/lib503.c b/tests/libtest/lib503.c index 34a6105bf7ae..48f0b671b91a 100644 --- a/tests/libtest/lib503.c +++ b/tests/libtest/lib503.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - /* * Source code in here hugely as reported in bug report 651460 by * Christopher R. Palmer. diff --git a/tests/libtest/lib504.c b/tests/libtest/lib504.c index fa9338f262ec..996130c246d4 100644 --- a/tests/libtest/lib504.c +++ b/tests/libtest/lib504.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - /* * Source code in here hugely as reported in bug report 651464 by * Christopher R. Palmer. diff --git a/tests/libtest/lib505.c b/tests/libtest/lib505.c index 37cc1e0b3f8c..b28a01a9ce05 100644 --- a/tests/libtest/lib505.c +++ b/tests/libtest/lib505.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - /* * This example shows an FTP upload, with a rename of the file just after * a successful upload. diff --git a/tests/libtest/lib506.c b/tests/libtest/lib506.c index 928c33b13cc3..3d2a3556fdb0 100644 --- a/tests/libtest/lib506.c +++ b/tests/libtest/lib506.c @@ -24,7 +24,6 @@ #include "first.h" #include "testutil.h" -#include "memdebug.h" #define THREADS 2 diff --git a/tests/libtest/lib507.c b/tests/libtest/lib507.c index 9a306d39a656..0496099ce204 100644 --- a/tests/libtest/lib507.c +++ b/tests/libtest/lib507.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib507(const char *URL) { CURL *curl = NULL; diff --git a/tests/libtest/lib508.c b/tests/libtest/lib508.c index a4c25b7918f6..697505150056 100644 --- a/tests/libtest/lib508.c +++ b/tests/libtest/lib508.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - struct t508_WriteThis { const char *readptr; size_t sizeleft; diff --git a/tests/libtest/lib509.c b/tests/libtest/lib509.c index a8be3eae5221..b5a0c583e072 100644 --- a/tests/libtest/lib509.c +++ b/tests/libtest/lib509.c @@ -29,9 +29,8 @@ * libcurl and that it works unconditionally no matter how libcurl is built, * nothing more. * - * Do not include memdebug.h in this source file, and do not use directly - * memory related functions in this file except those used inside custom - * memory callbacks which should be calling 'the real thing'. + * Do not use directly memory related functions in this file except those used + * inside custom memory callbacks which should be calling 'the real thing'. */ static int seen; @@ -39,31 +38,40 @@ static int seen; static void *custom_calloc(size_t nmemb, size_t size) { seen++; - return (calloc)(nmemb, size); + /* !checksrc! disable BANNEDFUNC 1 */ + return calloc(nmemb, size); } static void *custom_malloc(size_t size) { seen++; - return (malloc)(size); + /* !checksrc! disable BANNEDFUNC 1 */ + return malloc(size); } static char *custom_strdup(const char *ptr) { seen++; - return (strdup)(ptr); +#ifdef _WIN32 + return _strdup(ptr); +#else + /* !checksrc! disable BANNEDFUNC 1 */ + return strdup(ptr); +#endif } static void *custom_realloc(void *ptr, size_t size) { seen++; - return (realloc)(ptr, size); + /* !checksrc! disable BANNEDFUNC 1 */ + return realloc(ptr, size); } static void custom_free(void *ptr) { seen++; - (free)(ptr); + /* !checksrc! disable BANNEDFUNC 1 */ + free(ptr); } @@ -95,10 +103,11 @@ static CURLcode test_lib509(const char *URL) return TEST_ERR_MAJOR_BAD; } - test_setopt(curl, CURLOPT_USERAGENT, "test509"); /* uses strdup() */ + test_setopt(curl, CURLOPT_USERAGENT, "test509"); /* uses curlx_strdup() */ asize = (int)sizeof(a); - str = curl_easy_escape(curl, (const char *)a, asize); /* uses realloc() */ + /* uses curlx_realloc() */ + str = curl_easy_escape(curl, (const char *)a, asize); if(seen) curl_mprintf("Callbacks were invoked!\n"); diff --git a/tests/libtest/lib510.c b/tests/libtest/lib510.c index da270c1c9213..d2df0eaf203b 100644 --- a/tests/libtest/lib510.c +++ b/tests/libtest/lib510.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - struct t510_WriteThis { int counter; }; diff --git a/tests/libtest/lib511.c b/tests/libtest/lib511.c index 1db409378098..c4e78a1117ec 100644 --- a/tests/libtest/lib511.c +++ b/tests/libtest/lib511.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib511(const char *URL) { CURLcode res; diff --git a/tests/libtest/lib512.c b/tests/libtest/lib512.c index 59a1cd7595d5..be7187542a14 100644 --- a/tests/libtest/lib512.c +++ b/tests/libtest/lib512.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - /* Test case code based on source in a bug report filed by James Bursa on 28 Apr 2004 */ diff --git a/tests/libtest/lib513.c b/tests/libtest/lib513.c index 3d0afb1191b9..1458971007ec 100644 --- a/tests/libtest/lib513.c +++ b/tests/libtest/lib513.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static size_t t513_read_cb(char *ptr, size_t size, size_t nmemb, void *userp) { (void)ptr; diff --git a/tests/libtest/lib514.c b/tests/libtest/lib514.c index f47cdb321d58..0ce96f5be81f 100644 --- a/tests/libtest/lib514.c +++ b/tests/libtest/lib514.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib514(const char *URL) { CURL *curl; diff --git a/tests/libtest/lib515.c b/tests/libtest/lib515.c index d9814525df55..b0d3a65d5073 100644 --- a/tests/libtest/lib515.c +++ b/tests/libtest/lib515.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib515(const char *URL) { CURL *curl; diff --git a/tests/libtest/lib516.c b/tests/libtest/lib516.c index b7778a6a76c8..42b63c9d87d0 100644 --- a/tests/libtest/lib516.c +++ b/tests/libtest/lib516.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib516(const char *URL) { CURL *curl; diff --git a/tests/libtest/lib517.c b/tests/libtest/lib517.c index 01d3ac4bad1a..843c5c03f0ef 100644 --- a/tests/libtest/lib517.c +++ b/tests/libtest/lib517.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib517(const char *URL) { struct dcheck { diff --git a/tests/libtest/lib518.c b/tests/libtest/lib518.c index b8a9ec4a6a84..d785857bb1c0 100644 --- a/tests/libtest/lib518.c +++ b/tests/libtest/lib518.c @@ -24,7 +24,6 @@ #include "first.h" #include "testutil.h" -#include "memdebug.h" #ifndef FD_SETSIZE #error "this test requires FD_SETSIZE" @@ -65,7 +64,7 @@ static void t518_close_file_descriptors(void) t518_num_open.rlim_cur++) if(t518_testfd[t518_num_open.rlim_cur] > 0) close(t518_testfd[t518_num_open.rlim_cur]); - free(t518_testfd); + curlx_free(t518_testfd); t518_testfd = NULL; } @@ -213,8 +212,8 @@ static int t518_test_rlimit(int keep_open) * avoid a low memory condition once the file descriptors are * open. System conditions that could make the test fail should * be addressed in the precheck phase. This chunk of memory shall - * be always free()ed before exiting the t518_test_rlimit() function so - * that it becomes available to the test. + * be always curlx_free()ed before exiting the t518_test_rlimit() + * function so that it becomes available to the test. */ for(nitems = i = 1; nitems <= i; i *= 2) @@ -225,7 +224,7 @@ static int t518_test_rlimit(int keep_open) t518_num_open.rlim_max = sizeof(*memchunk) * nitems; tutil_rlim2str(strbuff, sizeof(strbuff), t518_num_open.rlim_max); curl_mfprintf(stderr, "allocating memchunk %s byte array\n", strbuff); - memchunk = malloc(sizeof(*memchunk) * (size_t)nitems); + memchunk = curlx_malloc(sizeof(*memchunk) * (size_t)nitems); if(!memchunk) { curl_mfprintf(stderr, "memchunk, malloc() failed\n"); nitems /= 2; @@ -248,7 +247,7 @@ static int t518_test_rlimit(int keep_open) t518_num_open.rlim_max = NUM_OPEN; - /* verify that we do not overflow size_t in malloc() */ + /* verify that we do not overflow size_t in curlx_malloc() */ if((size_t)(t518_num_open.rlim_max) > ((size_t)-1) / sizeof(*t518_testfd)) { tutil_rlim2str(strbuff1, sizeof(strbuff1), t518_num_open.rlim_max); @@ -257,7 +256,7 @@ static int t518_test_rlimit(int keep_open) "file descriptors, would overflow size_t", strbuff1); t518_store_errmsg(strbuff, 0); curl_mfprintf(stderr, "%s\n", t518_msgbuff); - free(memchunk); + curlx_free(memchunk); return -6; } @@ -266,12 +265,12 @@ static int t518_test_rlimit(int keep_open) tutil_rlim2str(strbuff, sizeof(strbuff), t518_num_open.rlim_max); curl_mfprintf(stderr, "allocating array for %s file descriptors\n", strbuff); - t518_testfd = malloc(sizeof(*t518_testfd) * - (size_t)(t518_num_open.rlim_max)); + t518_testfd = curlx_malloc(sizeof(*t518_testfd) * + (size_t)(t518_num_open.rlim_max)); if(!t518_testfd) { t518_store_errmsg("testfd, malloc() failed", errno); curl_mfprintf(stderr, "%s\n", t518_msgbuff); - free(memchunk); + curlx_free(memchunk); return -7; } @@ -294,9 +293,9 @@ static int t518_test_rlimit(int keep_open) curl_msnprintf(strbuff, sizeof(strbuff), "opening of %s failed", DEV_NULL); t518_store_errmsg(strbuff, errno); curl_mfprintf(stderr, "%s\n", t518_msgbuff); - free(t518_testfd); + curlx_free(t518_testfd); t518_testfd = NULL; - free(memchunk); + curlx_free(memchunk); return -8; } @@ -335,9 +334,9 @@ static int t518_test_rlimit(int keep_open) t518_testfd[t518_num_open.rlim_cur] >= 0; t518_num_open.rlim_cur++) close(t518_testfd[t518_num_open.rlim_cur]); - free(t518_testfd); + curlx_free(t518_testfd); t518_testfd = NULL; - free(memchunk); + curlx_free(memchunk); return -9; } } @@ -365,7 +364,7 @@ static int t518_test_rlimit(int keep_open) t518_store_errmsg(strbuff, 0); curl_mfprintf(stderr, "%s\n", t518_msgbuff); t518_close_file_descriptors(); - free(memchunk); + curlx_free(memchunk); return -10; } @@ -380,7 +379,7 @@ static int t518_test_rlimit(int keep_open) t518_store_errmsg(strbuff, 0); curl_mfprintf(stderr, "%s\n", t518_msgbuff); t518_close_file_descriptors(); - free(memchunk); + curlx_free(memchunk); return -11; } } @@ -405,14 +404,14 @@ static int t518_test_rlimit(int keep_open) "fopen fails with lots of fds open"); t518_store_errmsg(strbuff, 0); t518_close_file_descriptors(); - free(memchunk); + curlx_free(memchunk); return -12; } /* free the chunk of memory we were reserving so that it becomes available to the test */ - free(memchunk); + curlx_free(memchunk); /* close file descriptors unless instructed to keep them */ diff --git a/tests/libtest/lib519.c b/tests/libtest/lib519.c index 615e8aac8a52..0d2f23e0d355 100644 --- a/tests/libtest/lib519.c +++ b/tests/libtest/lib519.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib519(const char *URL) { CURLcode res; diff --git a/tests/libtest/lib520.c b/tests/libtest/lib520.c index 34f7c541e222..b3e67864e21e 100644 --- a/tests/libtest/lib520.c +++ b/tests/libtest/lib520.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib520(const char *URL) { CURLcode res; diff --git a/tests/libtest/lib521.c b/tests/libtest/lib521.c index acfec703811f..0d2bacd16de1 100644 --- a/tests/libtest/lib521.c +++ b/tests/libtest/lib521.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib521(const char *URL) { CURLcode res = TEST_ERR_MAJOR_BAD; diff --git a/tests/libtest/lib523.c b/tests/libtest/lib523.c index 3b56ada894e8..60648a7da1fc 100644 --- a/tests/libtest/lib523.c +++ b/tests/libtest/lib523.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib523(const char *URL) { CURLcode res; diff --git a/tests/libtest/lib524.c b/tests/libtest/lib524.c index e015e58637eb..5b7e01c087b5 100644 --- a/tests/libtest/lib524.c +++ b/tests/libtest/lib524.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib524(const char *URL) { CURLcode res; diff --git a/tests/libtest/lib525.c b/tests/libtest/lib525.c index 4ca7ab7d6545..abc75644ce5b 100644 --- a/tests/libtest/lib525.c +++ b/tests/libtest/lib525.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib525(const char *URL) { CURLcode res = CURLE_OK; diff --git a/tests/libtest/lib526.c b/tests/libtest/lib526.c index 6f586c5a3e54..a4d5ab6b1a1e 100644 --- a/tests/libtest/lib526.c +++ b/tests/libtest/lib526.c @@ -42,8 +42,6 @@ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib526(const char *URL) { CURLcode res = CURLE_OK; diff --git a/tests/libtest/lib530.c b/tests/libtest/lib530.c index e7e86a32ccbb..429a4869f5c9 100644 --- a/tests/libtest/lib530.c +++ b/tests/libtest/lib530.c @@ -30,9 +30,6 @@ #include "first.h" -#include "memdebug.h" - - static struct t530_ctx { int socket_calls; int max_socket_calls; @@ -106,14 +103,15 @@ static int t530_addFd(struct t530_Sockets *sockets, curl_socket_t fd, * Allocate array storage when required. */ if(!sockets->sockets) { - sockets->sockets = malloc(sizeof(curl_socket_t) * 20U); + sockets->sockets = curlx_malloc(sizeof(curl_socket_t) * 20U); if(!sockets->sockets) return 1; sockets->max_count = 20; } else if(sockets->count + 1 > sockets->max_count) { - curl_socket_t *ptr = realloc(sockets->sockets, sizeof(curl_socket_t) * - (sockets->max_count + 20)); + curl_socket_t *ptr = curlx_realloc(sockets->sockets, + sizeof(curl_socket_t) * + (sockets->max_count + 20)); if(!ptr) /* cleanup in test_cleanup */ return 1; @@ -390,8 +388,8 @@ static CURLcode testone(const char *URL, int timer_fail_at, int socket_fail_at) curl_global_cleanup(); /* free local memory */ - free(sockets.read.sockets); - free(sockets.write.sockets); + curlx_free(sockets.read.sockets); + curlx_free(sockets.write.sockets); t530_msg("done"); return res; diff --git a/tests/libtest/lib533.c b/tests/libtest/lib533.c index 8f3b0f1474c0..b730960695a6 100644 --- a/tests/libtest/lib533.c +++ b/tests/libtest/lib533.c @@ -25,8 +25,6 @@ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib533(const char *URL) { CURLcode res = CURLE_OK; diff --git a/tests/libtest/lib536.c b/tests/libtest/lib536.c index c0107ed9cbdc..4810aba83fc3 100644 --- a/tests/libtest/lib536.c +++ b/tests/libtest/lib536.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static void proxystat(CURL *curl) { long wasproxy; diff --git a/tests/libtest/lib537.c b/tests/libtest/lib537.c index 02d4a89b26a6..8027a09c0286 100644 --- a/tests/libtest/lib537.c +++ b/tests/libtest/lib537.c @@ -24,7 +24,6 @@ #include "first.h" #include "testutil.h" -#include "memdebug.h" #if !defined(HAVE_POLL) && !defined(USE_WINSOCK) && !defined(FD_SETSIZE) #error "this test requires FD_SETSIZE" @@ -62,7 +61,7 @@ static void t537_close_file_descriptors(void) t537_num_open.rlim_cur++) if(t537_testfd[t537_num_open.rlim_cur] > 0) close(t537_testfd[t537_num_open.rlim_cur]); - free(t537_testfd); + curlx_free(t537_testfd); t537_testfd = NULL; } @@ -193,8 +192,8 @@ static int t537_test_rlimit(int keep_open) * avoid a low memory condition once the file descriptors are * open. System conditions that could make the test fail should * be addressed in the precheck phase. This chunk of memory shall - * be always free()ed before exiting the t537_test_rlimit() function so - * that it becomes available to the test. + * be always curlx_free()ed before exiting the t537_test_rlimit() + * function so that it becomes available to the test. */ for(nitems = i = 1; nitems <= i; i *= 2) @@ -205,7 +204,7 @@ static int t537_test_rlimit(int keep_open) t537_num_open.rlim_max = sizeof(*memchunk) * nitems; tutil_rlim2str(strbuff, sizeof(strbuff), t537_num_open.rlim_max); curl_mfprintf(stderr, "allocating memchunk %s byte array\n", strbuff); - memchunk = malloc(sizeof(*memchunk) * (size_t)nitems); + memchunk = curlx_malloc(sizeof(*memchunk) * (size_t)nitems); if(!memchunk) { curl_mfprintf(stderr, "memchunk, malloc() failed\n"); nitems /= 2; @@ -243,7 +242,7 @@ static int t537_test_rlimit(int keep_open) t537_num_open.rlim_max = nitems; } - /* verify that we do not overflow size_t in malloc() */ + /* verify that we do not overflow size_t in curlx_malloc() */ if((size_t)(t537_num_open.rlim_max) > ((size_t)-1) / sizeof(*t537_testfd)) { tutil_rlim2str(strbuff1, sizeof(strbuff1), t537_num_open.rlim_max); @@ -252,7 +251,7 @@ static int t537_test_rlimit(int keep_open) "file descriptors, would overflow size_t", strbuff1); t537_store_errmsg(strbuff, 0); curl_mfprintf(stderr, "%s\n", t537_msgbuff); - free(memchunk); + curlx_free(memchunk); return -5; } @@ -263,8 +262,8 @@ static int t537_test_rlimit(int keep_open) curl_mfprintf(stderr, "allocating array for %s file descriptors\n", strbuff); - t537_testfd = malloc(sizeof(*t537_testfd) * - (size_t)(t537_num_open.rlim_max)); + t537_testfd = curlx_malloc(sizeof(*t537_testfd) * + (size_t)(t537_num_open.rlim_max)); if(!t537_testfd) { curl_mfprintf(stderr, "testfd, malloc() failed\n"); t537_num_open.rlim_max /= 2; @@ -273,7 +272,7 @@ static int t537_test_rlimit(int keep_open) if(!t537_testfd) { t537_store_errmsg("testfd, malloc() failed", errno); curl_mfprintf(stderr, "%s\n", t537_msgbuff); - free(memchunk); + curlx_free(memchunk); return -6; } @@ -296,9 +295,9 @@ static int t537_test_rlimit(int keep_open) curl_msnprintf(strbuff, sizeof(strbuff), "opening of %s failed", DEV_NULL); t537_store_errmsg(strbuff, errno); curl_mfprintf(stderr, "%s\n", t537_msgbuff); - free(t537_testfd); + curlx_free(t537_testfd); t537_testfd = NULL; - free(memchunk); + curlx_free(memchunk); return -7; } @@ -345,8 +344,9 @@ static int t537_test_rlimit(int keep_open) /* we do not care if we cannot shrink it */ - tmpfd = realloc(t537_testfd, - sizeof(*t537_testfd) * (size_t)(t537_num_open.rlim_max)); + tmpfd = curlx_realloc(t537_testfd, + sizeof(*t537_testfd) * + (size_t)(t537_num_open.rlim_max)); if(tmpfd) { t537_testfd = tmpfd; tmpfd = NULL; @@ -379,7 +379,7 @@ static int t537_test_rlimit(int keep_open) t537_store_errmsg(strbuff, 0); curl_mfprintf(stderr, "%s\n", t537_msgbuff); t537_close_file_descriptors(); - free(memchunk); + curlx_free(memchunk); return -8; } @@ -394,7 +394,7 @@ static int t537_test_rlimit(int keep_open) t537_store_errmsg(strbuff, 0); curl_mfprintf(stderr, "%s\n", t537_msgbuff); t537_close_file_descriptors(); - free(memchunk); + curlx_free(memchunk); return -9; } } @@ -419,14 +419,14 @@ static int t537_test_rlimit(int keep_open) "fopen fails with lots of fds open"); t537_store_errmsg(strbuff, 0); t537_close_file_descriptors(); - free(memchunk); + curlx_free(memchunk); return -10; } /* free the chunk of memory we were reserving so that it becomes available to the test */ - free(memchunk); + curlx_free(memchunk); /* close file descriptors unless instructed to keep them */ diff --git a/tests/libtest/lib539.c b/tests/libtest/lib539.c index e4e26c204a13..1e6c0fb0ef2f 100644 --- a/tests/libtest/lib539.c +++ b/tests/libtest/lib539.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib539(const char *URL) { CURLcode res; diff --git a/tests/libtest/lib540.c b/tests/libtest/lib540.c index 55d5adad0742..5e8890d98421 100644 --- a/tests/libtest/lib540.c +++ b/tests/libtest/lib540.c @@ -32,8 +32,6 @@ #include "first.h" -#include "memdebug.h" - static CURL *t540_curl[2]; static CURLcode init(int num, CURLM *multi, const char *url, diff --git a/tests/libtest/lib541.c b/tests/libtest/lib541.c index ebab472456b5..891c2de52585 100644 --- a/tests/libtest/lib541.c +++ b/tests/libtest/lib541.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - /* * Two FTP uploads, the second with no content sent. */ diff --git a/tests/libtest/lib542.c b/tests/libtest/lib542.c index b29a2733fffd..d6689517c7d2 100644 --- a/tests/libtest/lib542.c +++ b/tests/libtest/lib542.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - /* * FTP get with NOBODY but no HEADER */ diff --git a/tests/libtest/lib543.c b/tests/libtest/lib543.c index 579a71a6117c..9938d269addc 100644 --- a/tests/libtest/lib543.c +++ b/tests/libtest/lib543.c @@ -25,8 +25,6 @@ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib543(const char *URL) { static const unsigned char a[] = { diff --git a/tests/libtest/lib544.c b/tests/libtest/lib544.c index d0ed914051ed..0d72af3042d5 100644 --- a/tests/libtest/lib544.c +++ b/tests/libtest/lib544.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib544(const char *URL) { CURL *curl; diff --git a/tests/libtest/lib547.c b/tests/libtest/lib547.c index 9184d933a882..8f51fef088d8 100644 --- a/tests/libtest/lib547.c +++ b/tests/libtest/lib547.c @@ -28,8 +28,6 @@ #include "first.h" -#include "memdebug.h" - static const char t547_uploadthis[] = "this is the blurb we want to upload\n"; #define T547_DATALEN (sizeof(t547_uploadthis)-1) diff --git a/tests/libtest/lib549.c b/tests/libtest/lib549.c index 4eaacf5868a4..2793f92bcb51 100644 --- a/tests/libtest/lib549.c +++ b/tests/libtest/lib549.c @@ -28,8 +28,6 @@ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib549(const char *URL) { CURLcode res; diff --git a/tests/libtest/lib552.c b/tests/libtest/lib552.c index 3d5b09c1ec3f..403ad6fec196 100644 --- a/tests/libtest/lib552.c +++ b/tests/libtest/lib552.c @@ -28,7 +28,6 @@ #include "first.h" #include "testtrace.h" -#include "memdebug.h" static size_t current_offset = 0; static char databuf[70000]; /* MUST be more than 64k OR diff --git a/tests/libtest/lib553.c b/tests/libtest/lib553.c index 0d44573131ec..4bc2568a46fd 100644 --- a/tests/libtest/lib553.c +++ b/tests/libtest/lib553.c @@ -28,8 +28,6 @@ #include "first.h" -#include "memdebug.h" - #define POSTLEN 40960 static size_t myreadfunc(char *ptr, size_t size, size_t nmemb, void *stream) diff --git a/tests/libtest/lib554.c b/tests/libtest/lib554.c index 230da065a1b4..dd8c690ddbc3 100644 --- a/tests/libtest/lib554.c +++ b/tests/libtest/lib554.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - struct t554_WriteThis { const char *readptr; size_t sizeleft; diff --git a/tests/libtest/lib555.c b/tests/libtest/lib555.c index 19e0480e2a51..005fefe72ff8 100644 --- a/tests/libtest/lib555.c +++ b/tests/libtest/lib555.c @@ -32,8 +32,6 @@ #include "first.h" -#include "memdebug.h" - static const char t555_uploadthis[] = "this is the blurb we want to upload\n"; #define T555_DATALEN (sizeof(t555_uploadthis)-1) diff --git a/tests/libtest/lib556.c b/tests/libtest/lib556.c index daf92fe1e600..cdf9ebe94194 100644 --- a/tests/libtest/lib556.c +++ b/tests/libtest/lib556.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib556(const char *URL) { CURLcode res; diff --git a/tests/libtest/lib557.c b/tests/libtest/lib557.c index 38d93a687e81..fa1ee2fa2fbc 100644 --- a/tests/libtest/lib557.c +++ b/tests/libtest/lib557.c @@ -33,8 +33,6 @@ # include /* for setlocale() */ #endif -#include "memdebug.h" - #if defined(CURL_GNUC_DIAG) || defined(__clang__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wformat" diff --git a/tests/libtest/lib558.c b/tests/libtest/lib558.c index c82b6ee969de..94dd7f57b80f 100644 --- a/tests/libtest/lib558.c +++ b/tests/libtest/lib558.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib558(const char *URL) { unsigned char a[] = {0x2f, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, @@ -40,7 +38,7 @@ static CURLcode test_lib558(const char *URL) return TEST_ERR_MAJOR_BAD; } - ptr = malloc(558); + ptr = curlx_malloc(558); Curl_safefree(ptr); asize = (int)sizeof(a); diff --git a/tests/libtest/lib559.c b/tests/libtest/lib559.c index 36a557512652..bf9cd86e639e 100644 --- a/tests/libtest/lib559.c +++ b/tests/libtest/lib559.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib559(const char *URL) { CURLcode res; diff --git a/tests/libtest/lib560.c b/tests/libtest/lib560.c index 45f137aabeb7..fc156f43d795 100644 --- a/tests/libtest/lib560.c +++ b/tests/libtest/lib560.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - /* * Simply download an HTTPS file! * diff --git a/tests/libtest/lib562.c b/tests/libtest/lib562.c index 3f2c912c9173..fbe2560147df 100644 --- a/tests/libtest/lib562.c +++ b/tests/libtest/lib562.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - /* * From "KNOWN_BUGS" April 2009: diff --git a/tests/libtest/lib564.c b/tests/libtest/lib564.c index b105fc710e6b..56acfe40f72a 100644 --- a/tests/libtest/lib564.c +++ b/tests/libtest/lib564.c @@ -24,7 +24,6 @@ #include "first.h" #include "testtrace.h" -#include "memdebug.h" static CURLcode test_lib564(const char *URL) { diff --git a/tests/libtest/lib566.c b/tests/libtest/lib566.c index 79f48f235b2c..89adbdbd9c75 100644 --- a/tests/libtest/lib566.c +++ b/tests/libtest/lib566.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib566(const char *URL) { CURLcode res; diff --git a/tests/libtest/lib567.c b/tests/libtest/lib567.c index a11a6c31f010..95b66f102c25 100644 --- a/tests/libtest/lib567.c +++ b/tests/libtest/lib567.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - /* * Test a simple OPTIONS request with a custom header */ diff --git a/tests/libtest/lib568.c b/tests/libtest/lib568.c index 5465ca0c8be8..260061f5191f 100644 --- a/tests/libtest/lib568.c +++ b/tests/libtest/lib568.c @@ -24,7 +24,6 @@ #include "first.h" #include "testutil.h" -#include "memdebug.h" /* * Test the Client->Server ANNOUNCE functionality (PUT style) diff --git a/tests/libtest/lib569.c b/tests/libtest/lib569.c index 1c44153d009f..77e0471e5f4e 100644 --- a/tests/libtest/lib569.c +++ b/tests/libtest/lib569.c @@ -24,7 +24,6 @@ #include "first.h" #include "testutil.h" -#include "memdebug.h" /* * Test Session ID capture diff --git a/tests/libtest/lib570.c b/tests/libtest/lib570.c index 300881efa7b7..f5ada6770b2e 100644 --- a/tests/libtest/lib570.c +++ b/tests/libtest/lib570.c @@ -24,7 +24,6 @@ #include "first.h" #include "testutil.h" -#include "memdebug.h" static CURLcode test_lib570(const char *URL) { diff --git a/tests/libtest/lib571.c b/tests/libtest/lib571.c index 509557f0f50b..678141b1c545 100644 --- a/tests/libtest/lib571.c +++ b/tests/libtest/lib571.c @@ -34,7 +34,6 @@ #endif #include "testutil.h" -#include "memdebug.h" #define RTP_PKT_CHANNEL(p) ((int)((unsigned char)((p)[1]))) diff --git a/tests/libtest/lib572.c b/tests/libtest/lib572.c index 2865372f5fef..4e20cb3da5b8 100644 --- a/tests/libtest/lib572.c +++ b/tests/libtest/lib572.c @@ -24,7 +24,6 @@ #include "first.h" #include "testutil.h" -#include "memdebug.h" /* * Test GET_PARAMETER: PUT, HEARTBEAT, and POST diff --git a/tests/libtest/lib573.c b/tests/libtest/lib573.c index 38612df7b58c..ed00bbb04243 100644 --- a/tests/libtest/lib573.c +++ b/tests/libtest/lib573.c @@ -24,7 +24,6 @@ #include "first.h" #include "testtrace.h" -#include "memdebug.h" /* * Get a single URL without select(). diff --git a/tests/libtest/lib574.c b/tests/libtest/lib574.c index e82be6c0d663..f74371e97383 100644 --- a/tests/libtest/lib574.c +++ b/tests/libtest/lib574.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static int new_fnmatch(void *ptr, const char *pattern, const char *string) { diff --git a/tests/libtest/lib575.c b/tests/libtest/lib575.c index 36efe6ef5a66..4709708a52bd 100644 --- a/tests/libtest/lib575.c +++ b/tests/libtest/lib575.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - /* 3x download! * 1. normal * 2. dup handle diff --git a/tests/libtest/lib576.c b/tests/libtest/lib576.c index 11c0f76d1390..7ee7bc9525d4 100644 --- a/tests/libtest/lib576.c +++ b/tests/libtest/lib576.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - struct chunk_data { int remains; int print_content; diff --git a/tests/libtest/lib578.c b/tests/libtest/lib578.c index b6be1600f4c9..799821123df2 100644 --- a/tests/libtest/lib578.c +++ b/tests/libtest/lib578.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - /* The size of data should be kept below MAX_INITIAL_POST_SIZE! */ static char t578_testdata[] = "this is a short string.\n"; diff --git a/tests/libtest/lib579.c b/tests/libtest/lib579.c index 9e626c130002..aaa81baedeb1 100644 --- a/tests/libtest/lib579.c +++ b/tests/libtest/lib579.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - struct t579_WriteThis { int counter; }; diff --git a/tests/libtest/lib582.c b/tests/libtest/lib582.c index 4318096e1f79..e99d5febdfab 100644 --- a/tests/libtest/lib582.c +++ b/tests/libtest/lib582.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - struct t582_Sockets { curl_socket_t *sockets; int count; /* number of sockets actually stored in array */ @@ -72,7 +70,7 @@ static void t582_addFd(struct t582_Sockets *sockets, curl_socket_t fd, * Allocate array storage when required. */ if(!sockets->sockets) { - sockets->sockets = malloc(sizeof(curl_socket_t) * 20U); + sockets->sockets = curlx_malloc(sizeof(curl_socket_t) * 20U); if(!sockets->sockets) return; sockets->max_count = 20; @@ -359,8 +357,8 @@ static CURLcode test_lib582(const char *URL) curlx_fclose(hd_src); /* free local memory */ - free(sockets.read.sockets); - free(sockets.write.sockets); + curlx_free(sockets.read.sockets); + curlx_free(sockets.write.sockets); return res; } diff --git a/tests/libtest/lib583.c b/tests/libtest/lib583.c index 510c5a3bdcf6..8f29e310c7ed 100644 --- a/tests/libtest/lib583.c +++ b/tests/libtest/lib583.c @@ -28,8 +28,6 @@ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib583(const char *URL) { int stillRunning; diff --git a/tests/libtest/lib586.c b/tests/libtest/lib586.c index dac6751b3587..d0671b18fec3 100644 --- a/tests/libtest/lib586.c +++ b/tests/libtest/lib586.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - #define THREADS 2 /* struct containing data of a thread */ diff --git a/tests/libtest/lib589.c b/tests/libtest/lib589.c index 9b912ab037d8..46b2a22a05f2 100644 --- a/tests/libtest/lib589.c +++ b/tests/libtest/lib589.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib589(const char *URL) { CURL *curl; diff --git a/tests/libtest/lib590.c b/tests/libtest/lib590.c index c804f995dee9..bba31e9da4e2 100644 --- a/tests/libtest/lib590.c +++ b/tests/libtest/lib590.c @@ -37,8 +37,6 @@ - Start the request */ -#include "memdebug.h" - static CURLcode test_lib590(const char *URL) { CURLcode res; diff --git a/tests/libtest/lib591.c b/tests/libtest/lib591.c index c30bde5e8be4..521cbb7503ab 100644 --- a/tests/libtest/lib591.c +++ b/tests/libtest/lib591.c @@ -25,8 +25,6 @@ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib591(const char *URL) { CURL *curl = NULL; diff --git a/tests/libtest/lib597.c b/tests/libtest/lib597.c index e82d061a222e..38e60c084486 100644 --- a/tests/libtest/lib597.c +++ b/tests/libtest/lib597.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - /* * Test case for below scenario: * - Connect to an FTP server using CONNECT_ONLY option diff --git a/tests/libtest/lib598.c b/tests/libtest/lib598.c index 56330c4a2448..b42743845d62 100644 --- a/tests/libtest/lib598.c +++ b/tests/libtest/lib598.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib598(const char *URL) { CURLcode res; diff --git a/tests/libtest/lib599.c b/tests/libtest/lib599.c index 199ef90dbf8c..a216aa13a38e 100644 --- a/tests/libtest/lib599.c +++ b/tests/libtest/lib599.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static int t599_progress_callback(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow) { diff --git a/tests/libtest/lib643.c b/tests/libtest/lib643.c index d74d7ea9ee03..52ea1eb664cc 100644 --- a/tests/libtest/lib643.c +++ b/tests/libtest/lib643.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - struct t643_WriteThis { const char *readptr; curl_off_t sizeleft; diff --git a/tests/libtest/lib650.c b/tests/libtest/lib650.c index 069e94f8e5ce..4aa6ea9d8bb4 100644 --- a/tests/libtest/lib650.c +++ b/tests/libtest/lib650.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - /* This test attempts to use all form API features that are not * used elsewhere. */ diff --git a/tests/libtest/lib651.c b/tests/libtest/lib651.c index 05e9e381da9c..7d1d28563f15 100644 --- a/tests/libtest/lib651.c +++ b/tests/libtest/lib651.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib651(const char *URL) { static char testbuf[17000]; /* more than 16K */ diff --git a/tests/libtest/lib652.c b/tests/libtest/lib652.c index dcbc5a3ab3f8..4fae340042b0 100644 --- a/tests/libtest/lib652.c +++ b/tests/libtest/lib652.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib652(const char *URL) { static char testbuf[17000]; /* more than 16K */ diff --git a/tests/libtest/lib653.c b/tests/libtest/lib653.c index 21948a5720e6..8447706958e0 100644 --- a/tests/libtest/lib653.c +++ b/tests/libtest/lib653.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib653(const char *URL) { CURL *curl = NULL; diff --git a/tests/libtest/lib654.c b/tests/libtest/lib654.c index 5b2236ebb044..1d93798d7c10 100644 --- a/tests/libtest/lib654.c +++ b/tests/libtest/lib654.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - struct t654_WriteThis { const char *readptr; curl_off_t sizeleft; diff --git a/tests/libtest/lib655.c b/tests/libtest/lib655.c index a213a1c493b3..3a8e0df43473 100644 --- a/tests/libtest/lib655.c +++ b/tests/libtest/lib655.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static const char *TEST_DATA_STRING = "Test data"; static int cb_count = 0; diff --git a/tests/libtest/lib658.c b/tests/libtest/lib658.c index 4f0f867d65de..edcb26333822 100644 --- a/tests/libtest/lib658.c +++ b/tests/libtest/lib658.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - /* * Get a single URL without select(). */ diff --git a/tests/libtest/lib659.c b/tests/libtest/lib659.c index 84c3ecc8cd46..5071e7fa267d 100644 --- a/tests/libtest/lib659.c +++ b/tests/libtest/lib659.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - /* * Get a single URL without select(). */ diff --git a/tests/libtest/lib661.c b/tests/libtest/lib661.c index 10a4ab99cee7..7cf6d091339b 100644 --- a/tests/libtest/lib661.c +++ b/tests/libtest/lib661.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib661(const char *URL) { CURLcode res; diff --git a/tests/libtest/lib666.c b/tests/libtest/lib666.c index cff244dafb1c..f47bacb9a807 100644 --- a/tests/libtest/lib666.c +++ b/tests/libtest/lib666.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib666(const char *URL) { static char testbuf[17000]; /* more than 16K */ diff --git a/tests/libtest/lib667.c b/tests/libtest/lib667.c index 2827d0051194..1bd612f37797 100644 --- a/tests/libtest/lib667.c +++ b/tests/libtest/lib667.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - struct t667_WriteThis { const char *readptr; curl_off_t sizeleft; diff --git a/tests/libtest/lib668.c b/tests/libtest/lib668.c index 488f86215247..5011391736b1 100644 --- a/tests/libtest/lib668.c +++ b/tests/libtest/lib668.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - struct t668_WriteThis { const char *readptr; curl_off_t sizeleft; diff --git a/tests/libtest/lib670.c b/tests/libtest/lib670.c index b30d097f68ff..e97b04319e3c 100644 --- a/tests/libtest/lib670.c +++ b/tests/libtest/lib670.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - #define PAUSE_TIME 5 struct t670_ReadThis { diff --git a/tests/libtest/lib674.c b/tests/libtest/lib674.c index 668ecdf32d14..c84d1af05db8 100644 --- a/tests/libtest/lib674.c +++ b/tests/libtest/lib674.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - /* * Get a single URL without select(). */ diff --git a/tests/libtest/lib676.c b/tests/libtest/lib676.c index 63437523df88..17494b73e7de 100644 --- a/tests/libtest/lib676.c +++ b/tests/libtest/lib676.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib676(const char *URL) { CURLcode res; diff --git a/tests/libtest/lib677.c b/tests/libtest/lib677.c index 526e1706c376..089202b5c591 100644 --- a/tests/libtest/lib677.c +++ b/tests/libtest/lib677.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib677(const char *URL) { static const char testcmd[] = "A1 IDLE\r\n"; diff --git a/tests/libtest/lib678.c b/tests/libtest/lib678.c index 2a2e21321f79..ed8731d20d5b 100644 --- a/tests/libtest/lib678.c +++ b/tests/libtest/lib678.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static int loadfile(const char *filename, void **filedata, size_t *filesize) { size_t datasize = 0; @@ -44,13 +42,13 @@ static int loadfile(const char *filename, void **filedata, size_t *filesize) if(continue_reading) continue_reading = fseek(fInCert, 0, SEEK_SET) == 0; if(continue_reading) - data = malloc(datasize + 1); + data = curlx_malloc(datasize + 1); if((!data) || ((int)fread(data, datasize, 1, fInCert) != 1)) continue_reading = FALSE; curlx_fclose(fInCert); if(!continue_reading) { - free(data); + curlx_free(data); datasize = 0; data = NULL; } @@ -86,7 +84,7 @@ static CURLcode test_cert_blob(const char *url, const char *cafile) blob.len = certsize; blob.flags = CURL_BLOB_COPY; curl_easy_setopt(curl, CURLOPT_CAINFO_BLOB, &blob); - free(certdata); + curlx_free(certdata); code = curl_easy_perform(curl); } curl_easy_cleanup(curl); diff --git a/tests/libtest/lib694.c b/tests/libtest/lib694.c index 5b477ecebd44..25db2694c6d7 100644 --- a/tests/libtest/lib694.c +++ b/tests/libtest/lib694.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - static CURLcode test_lib694(const char *URL) { CURLcode res; diff --git a/tests/libtest/lib695.c b/tests/libtest/lib695.c index 325897c357c9..1177a529fd64 100644 --- a/tests/libtest/lib695.c +++ b/tests/libtest/lib695.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - /* write callback that does nothing */ static size_t write_it(char *ptr, size_t size, size_t nmemb, void *userdata) { diff --git a/tests/libtest/lib751.c b/tests/libtest/lib751.c index 42c1aeb1176e..898ba8d7efcb 100644 --- a/tests/libtest/lib751.c +++ b/tests/libtest/lib751.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - /* * Get a single URL without select(). */ diff --git a/tests/libtest/lib753.c b/tests/libtest/lib753.c index 19194c4646a5..f01fa3f5c806 100644 --- a/tests/libtest/lib753.c +++ b/tests/libtest/lib753.c @@ -24,7 +24,6 @@ #include "first.h" #include "testtrace.h" -#include "memdebug.h" struct t753_transfer_status { CURL *curl; diff --git a/tests/libtest/lib757.c b/tests/libtest/lib757.c index 632818f94605..f3a1e0fdb408 100644 --- a/tests/libtest/lib757.c +++ b/tests/libtest/lib757.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "memdebug.h" - /* write callback that does nothing */ static size_t write_757(char *ptr, size_t size, size_t nmemb, void *userdata) { diff --git a/tests/libtest/lib758.c b/tests/libtest/lib758.c index ab6ce481b779..bc6a490d3d39 100644 --- a/tests/libtest/lib758.c +++ b/tests/libtest/lib758.c @@ -31,7 +31,6 @@ #include "first.h" #include "testtrace.h" -#include "memdebug.h" #ifdef USE_OPENSSL @@ -121,14 +120,15 @@ static int t758_addFd(struct t758_Sockets *sockets, curl_socket_t fd, * Allocate array storage when required. */ if(!sockets->sockets) { - sockets->sockets = malloc(sizeof(curl_socket_t) * 20U); + sockets->sockets = curlx_malloc(sizeof(curl_socket_t) * 20U); if(!sockets->sockets) return 1; sockets->max_count = 20; } else if(sockets->count + 1 > sockets->max_count) { - curl_socket_t *ptr = realloc(sockets->sockets, sizeof(curl_socket_t) * - (sockets->max_count + 20)); + curl_socket_t *ptr = curlx_realloc(sockets->sockets, + sizeof(curl_socket_t) * + (sockets->max_count + 20)); if(!ptr) /* cleanup in test_cleanup */ return 1; @@ -487,8 +487,8 @@ static CURLcode t758_one(const char *URL, int timer_fail_at, curl_global_cleanup(); /* free local memory */ - free(sockets.read.sockets); - free(sockets.write.sockets); + curlx_free(sockets.read.sockets); + curlx_free(sockets.write.sockets); t758_msg("done"); return res; diff --git a/tests/libtest/lib766.c b/tests/libtest/lib766.c index 53f1dd97b551..bba08e263b84 100644 --- a/tests/libtest/lib766.c +++ b/tests/libtest/lib766.c @@ -24,8 +24,6 @@ #include "first.h" -#include "memdebug.h" - static int sockopt_766(void *clientp, curl_socket_t curlfd, curlsocktype purpose) diff --git a/tests/libtest/memptr.c b/tests/libtest/memptr.c index 64e9fd7f8a1a..400e72c41ab9 100644 --- a/tests/libtest/memptr.c +++ b/tests/libtest/memptr.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "first.h" -#include "curl_memory.h" - #ifndef CURL_STATICLIB #if defined(_MSC_VER) && defined(_DLL) diff --git a/tests/libtest/mk-lib1521.pl b/tests/libtest/mk-lib1521.pl index 156422eccc42..bfb0e590e78f 100755 --- a/tests/libtest/mk-lib1521.pl +++ b/tests/libtest/mk-lib1521.pl @@ -206,7 +206,6 @@ * ***************************************************************************/ #include "first.h" -#include "memdebug.h" /* This source code is generated by mk-lib1521.pl ! */ diff --git a/tests/libtest/testtrace.c b/tests/libtest/testtrace.c index 7c4517378751..a541d4e55c18 100644 --- a/tests/libtest/testtrace.c +++ b/tests/libtest/testtrace.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "testtrace.h" -#include "memdebug.h" - struct libtest_trace_cfg debug_config; static time_t epoch_offset; /* for test time tracing */ diff --git a/tests/libtest/testutil.c b/tests/libtest/testutil.c index b5cfa70369b7..02c041c4b132 100644 --- a/tests/libtest/testutil.c +++ b/tests/libtest/testutil.c @@ -23,8 +23,6 @@ ***************************************************************************/ #include "testutil.h" -#include "memdebug.h" - /* build request URL */ char *tutil_suburl(const char *base, int i) { diff --git a/tests/server/.checksrc b/tests/server/.checksrc index 163a217ee4be..2fb655e159fa 100644 --- a/tests/server/.checksrc +++ b/tests/server/.checksrc @@ -3,13 +3,18 @@ # SPDX-License-Identifier: curl allowfunc accept +allowfunc calloc allowfunc fprintf +allowfunc free allowfunc freeaddrinfo allowfunc getaddrinfo +allowfunc malloc allowfunc printf +allowfunc realloc allowfunc recv allowfunc send allowfunc snprintf allowfunc socket allowfunc sscanf +allowfunc strdup allowfunc vsnprintf diff --git a/tests/test1132.pl b/tests/test1132.pl deleted file mode 100755 index 966bd09a489a..000000000000 --- a/tests/test1132.pl +++ /dev/null @@ -1,98 +0,0 @@ -#!/usr/bin/env perl -#*************************************************************************** -# _ _ ____ _ -# Project ___| | | | _ \| | -# / __| | | | |_) | | -# | (__| |_| | _ <| |___ -# \___|\___/|_| \_\_____| -# -# Copyright (C) Daniel Stenberg, , et al. -# -# This software is licensed as described in the 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. -# -# SPDX-License-Identifier: curl -# -########################################################################### -# -# This script scans C source files. If they seem to use memory functions, -# it also makes sure that it #includes the correct two header files! -# -# You can also mark a C source as fine by using 'mem-include-scan' anywhere in -# it. -# - -use strict; -use warnings; - -my $dir = $ARGV[0] || die "specify directory!"; - -sub scanfile { - my ($file) = @_; - my $memfunc; - my $memdebug; - my $curlmem; - - print STDERR "checking $file...\n"; - - open(my $f, "<", "$file"); - while(<$f>) { - if($_ =~ /\W(free|alloc|strdup)\(/) { - $memfunc++; - } - elsif($_ =~ /^ *# *include \"memdebug.h\"/) { - $memdebug++; - } - elsif($_ =~ /^ *# *include \"curl_memory.h\"/) { - $curlmem++; - } - elsif($_ =~ /mem-include-scan/) { - # free pass - close($f); - return 0; - } - if($memfunc && $memdebug && $curlmem) { - last; - } - } - close($f); - - - if($memfunc) { - if($memdebug && $curlmem) { - return 0; - } - else { - if(!$memdebug) { - print STDERR "$file does not include \"memdebug.h\"!\n"; - } - if(!$curlmem) { - print STDERR "$file does not include \"curl_memory.h\"!\n"; - } - return 1; - } - } - return 0; -} - -opendir(my $dh, $dir) || die "cannot opendir $dir: $!"; -my @cfiles = grep { /\.c\z/ && -f "$dir/$_" } readdir($dh); -closedir $dh; - -my $errs; -for(@cfiles) { - $errs += scanfile("$dir/$_"); -} - -if($errs) { - print STDERR "----\n$errs errors detected!\n"; - exit 2; -} diff --git a/tests/tunit/tool1394.c b/tests/tunit/tool1394.c index 71be2c87c478..9d97dbb0de8f 100644 --- a/tests/tunit/tool1394.c +++ b/tests/tunit/tool1394.c @@ -25,8 +25,6 @@ #include "tool_getparam.h" -#include "memdebug.h" /* LAST include file */ - static CURLcode test_tool1394(const char *arg) { UNITTEST_BEGIN_SIMPLE @@ -120,9 +118,9 @@ static CURLcode test_tool1394(const char *arg) } } if(certname) - free(certname); + curlx_free(certname); if(passphrase) - free(passphrase); + curlx_free(passphrase); } UNITTEST_END_SIMPLE diff --git a/tests/tunit/tool1604.c b/tests/tunit/tool1604.c index 3b6f006e7cfd..dcfee4cbac62 100644 --- a/tests/tunit/tool1604.c +++ b/tests/tunit/tool1604.c @@ -26,12 +26,10 @@ #include "tool_cfgable.h" #include "tool_doswin.h" -#include "memdebug.h" /* LAST include file */ - #if defined(_WIN32) || defined(MSDOS) static char *getflagstr(int flags) { - char *buf = malloc(256); + char *buf = curlx_malloc(256); if(buf) { curl_msnprintf(buf, 256, "%s,%s", ((flags & SANITIZE_ALLOW_PATH) ? @@ -44,7 +42,7 @@ static char *getflagstr(int flags) static char *getcurlcodestr(int cc) { - char *buf = malloc(256); + char *buf = curlx_malloc(256); if(buf) { curl_msnprintf(buf, 256, "%s (%d)", (cc == SANITIZE_ERR_OK ? "SANITIZE_ERR_OK" : @@ -212,7 +210,7 @@ static CURLcode test_tool1604(const char *arg) ((!output && !data[i].expected_output) || (output && data[i].expected_output && !strcmp(output, data[i].expected_output)))) { /* OK */ - free(output); + curlx_free(output); continue; } @@ -240,10 +238,10 @@ static CURLcode test_tool1604(const char *arg) data[i].expected_output ? data[i].expected_output : "(null)", expected_ccstr); - free(output); - free(flagstr); - free(received_ccstr); - free(expected_ccstr); + curlx_free(output); + curlx_free(flagstr); + curlx_free(received_ccstr); + curlx_free(expected_ccstr); } /* END sanitize_file_name */ #else diff --git a/tests/tunit/tool1621.c b/tests/tunit/tool1621.c index bb709cf39d21..ba9e28029446 100644 --- a/tests/tunit/tool1621.c +++ b/tests/tunit/tool1621.c @@ -25,8 +25,6 @@ #include "tool_xattr.h" -#include "memdebug.h" /* LAST include file */ - static CURLcode test_tool1621(const char *arg) { UNITTEST_BEGIN_SIMPLE diff --git a/tests/unit/unit1302.c b/tests/unit/unit1302.c index 911432a8c833..d56f7b09f779 100644 --- a/tests/unit/unit1302.c +++ b/tests/unit/unit1302.c @@ -25,7 +25,6 @@ #include "urldata.h" #include "url.h" /* for Curl_safefree */ -#include "memdebug.h" /* LAST include file */ struct etest { const char *input; diff --git a/tests/unit/unit1303.c b/tests/unit/unit1303.c index 03673c544e29..9bed1ebff6f4 100644 --- a/tests/unit/unit1303.c +++ b/tests/unit/unit1303.c @@ -25,7 +25,6 @@ #include "urldata.h" #include "connect.h" -#include "memdebug.h" /* LAST include file */ static CURLcode t1303_setup(struct Curl_easy **easy) { diff --git a/tests/unit/unit1304.c b/tests/unit/unit1304.c index 041ce42691dd..100f3f58287e 100644 --- a/tests/unit/unit1304.c +++ b/tests/unit/unit1304.c @@ -23,7 +23,6 @@ ***************************************************************************/ #include "unitcheck.h" #include "netrc.h" -#include "memdebug.h" /* LAST include file */ #ifndef CURL_DISABLE_NETRC @@ -120,8 +119,8 @@ static CURLcode test_unit1304(const char *arg) * Test for the first existing host in our netrc file * with login[0] != 0. */ - free(password); - free(login); + curlx_free(password); + curlx_free(login); password = NULL; login = NULL; Curl_netrc_init(&store); @@ -139,9 +138,9 @@ static CURLcode test_unit1304(const char *arg) * Test for the second existing host in our netrc file * with login[0] = 0. */ - free(password); + curlx_free(password); password = NULL; - free(login); + curlx_free(login); login = NULL; Curl_netrc_init(&store); result = Curl_parsenetrc(&store, @@ -158,9 +157,9 @@ static CURLcode test_unit1304(const char *arg) * Test for the second existing host in our netrc file * with login[0] != 0. */ - free(password); + curlx_free(password); password = NULL; - free(login); + curlx_free(login); login = NULL; Curl_netrc_init(&store); result = Curl_parsenetrc(&store, diff --git a/tests/unit/unit1305.c b/tests/unit/unit1305.c index e95e2994535d..404d90bec9a9 100644 --- a/tests/unit/unit1305.c +++ b/tests/unit/unit1305.c @@ -36,8 +36,6 @@ #include "hash.h" #include "hostip.h" -#include "memdebug.h" /* LAST include file */ - static struct Curl_dnscache hp; static char *data_key; static struct Curl_dns_entry *data_node; @@ -52,9 +50,9 @@ static void t1305_stop(void) { if(data_node) { Curl_freeaddrinfo(data_node->addr); - free(data_node); + curlx_free(data_node); } - free(data_key); + curlx_free(data_key); Curl_dnscache_destroy(&hp); } @@ -64,8 +62,9 @@ static struct Curl_addrinfo *fake_ai(void) static const char dummy[] = "dummy"; size_t namelen = sizeof(dummy); /* including the null-terminator */ - ai = calloc(1, sizeof(struct Curl_addrinfo) + sizeof(struct sockaddr_in) + - namelen); + ai = curlx_calloc(1, + sizeof(struct Curl_addrinfo) + sizeof(struct sockaddr_in) + + namelen); if(!ai) return NULL; @@ -86,7 +85,7 @@ static CURLcode create_node(void) if(!data_key) return CURLE_OUT_OF_MEMORY; - data_node = calloc(1, sizeof(struct Curl_dns_entry)); + data_node = curlx_calloc(1, sizeof(struct Curl_dns_entry)); if(!data_node) return CURLE_OUT_OF_MEMORY; diff --git a/tests/unit/unit1330.c b/tests/unit/unit1330.c index bd7fc6e2592b..a98393b5325c 100644 --- a/tests/unit/unit1330.c +++ b/tests/unit/unit1330.c @@ -23,13 +23,11 @@ ***************************************************************************/ #include "unitcheck.h" -#include "memdebug.h" - static CURLcode test_unit1330(const char *arg) { UNITTEST_BEGIN_SIMPLE - char *ptr = malloc(1330); + char *ptr = curlx_malloc(1330); Curl_safefree(ptr); UNITTEST_END_SIMPLE diff --git a/tests/unit/unit1395.c b/tests/unit/unit1395.c index e6ac18f08107..395f3e7707d7 100644 --- a/tests/unit/unit1395.c +++ b/tests/unit/unit1395.c @@ -22,7 +22,6 @@ * ***************************************************************************/ #include "unitcheck.h" -#include "memdebug.h" #include "unitprotos.h" static CURLcode test_unit1395(const char *arg) @@ -133,7 +132,7 @@ static CURLcode test_unit1395(const char *arg) } else curl_mfprintf(stderr, "Test %u: OK\n", i); - free(out); + curlx_free(out); } fail_if(fails, "output mismatched"); diff --git a/tests/unit/unit1602.c b/tests/unit/unit1602.c index e397bdb5ca5f..5841717691e0 100644 --- a/tests/unit/unit1602.c +++ b/tests/unit/unit1602.c @@ -25,12 +25,10 @@ #include "hash.h" -#include "memdebug.h" /* LAST include file */ - static void t1602_mydtor(void *p) { int *ptr = (int *)p; - free(ptr); + curlx_free(ptr); } static CURLcode t1602_setup(struct Curl_hash *hash) @@ -59,22 +57,22 @@ static CURLcode test_unit1602(const char *arg) int key = 20; int key2 = 25; - value = malloc(sizeof(int)); + value = curlx_malloc(sizeof(int)); abort_unless(value != NULL, "Out of memory"); *value = 199; nodep = Curl_hash_add(&hash, &key, klen, value); if(!nodep) - free(value); + curlx_free(value); abort_unless(nodep, "insertion into hash failed"); Curl_hash_clean(&hash); /* Attempt to add another key/value pair */ - value2 = malloc(sizeof(int)); + value2 = curlx_malloc(sizeof(int)); abort_unless(value2 != NULL, "Out of memory"); *value2 = 204; nodep = Curl_hash_add(&hash, &key2, klen, value2); if(!nodep) - free(value2); + curlx_free(value2); abort_unless(nodep, "insertion into hash failed"); UNITTEST_END(t1602_stop(&hash)) diff --git a/tests/unit/unit1603.c b/tests/unit/unit1603.c index b4ec152936ee..81db398cb19e 100644 --- a/tests/unit/unit1603.c +++ b/tests/unit/unit1603.c @@ -25,8 +25,6 @@ #include "hash.h" -#include "memdebug.h" /* LAST include file */ - static const size_t slots = 3; static void t1603_mydtor(void *p) diff --git a/tests/unit/unit1607.c b/tests/unit/unit1607.c index f60b5b58a1e4..233866da18b6 100644 --- a/tests/unit/unit1607.c +++ b/tests/unit/unit1607.c @@ -27,8 +27,6 @@ #include "connect.h" #include "curl_share.h" -#include "memdebug.h" /* LAST include file */ - static CURLcode t1607_setup(void) { CURLcode res = CURLE_OK; @@ -135,7 +133,7 @@ static CURLcode test_unit1607(const char *arg) goto error; dns = Curl_hash_pick(&multi->dnscache.entries, entry_id, strlen(entry_id) + 1); - free(entry_id); + curlx_free(entry_id); entry_id = NULL; addr = dns ? dns->addr : NULL; diff --git a/tests/unit/unit1609.c b/tests/unit/unit1609.c index 2a3098c6ef2e..bf912b99cd1a 100644 --- a/tests/unit/unit1609.c +++ b/tests/unit/unit1609.c @@ -27,8 +27,6 @@ #include "connect.h" #include "curl_share.h" -#include "memdebug.h" /* LAST include file */ - static CURLcode t1609_setup(void) { CURLcode res = CURLE_OK; @@ -137,7 +135,7 @@ static CURLcode test_unit1609(const char *arg) dns = Curl_hash_pick(&multi->dnscache.entries, entry_id, strlen(entry_id) + 1); - free(entry_id); + curlx_free(entry_id); entry_id = NULL; addr = dns ? dns->addr : NULL; diff --git a/tests/unit/unit1616.c b/tests/unit/unit1616.c index 5d1e6f247e76..d898444613ce 100644 --- a/tests/unit/unit1616.c +++ b/tests/unit/unit1616.c @@ -25,13 +25,11 @@ #include "uint-hash.h" -#include "memdebug.h" /* LAST include file */ - static void t1616_mydtor(unsigned int id, void *elem) { int *ptr = (int *)elem; (void)id; - free(ptr); + curlx_free(ptr); } static CURLcode t1616_setup(struct uint_hash *hash) @@ -58,12 +56,12 @@ static CURLcode test_unit1616(const char *arg) unsigned int key = 20; unsigned int key2 = 25; - value = malloc(sizeof(int)); + value = curlx_malloc(sizeof(int)); abort_unless(value != NULL, "Out of memory"); *value = 199; ok = Curl_uint32_hash_set(&hash, key, value); if(!ok) - free(value); + curlx_free(value); abort_unless(ok, "insertion into hash failed"); v = Curl_uint32_hash_get(&hash, key); abort_unless(v == value, "lookup present entry failed"); @@ -72,12 +70,12 @@ static CURLcode test_unit1616(const char *arg) Curl_uint32_hash_clear(&hash); /* Attempt to add another key/value pair */ - value2 = malloc(sizeof(int)); + value2 = curlx_malloc(sizeof(int)); abort_unless(value2 != NULL, "Out of memory"); *value2 = 204; ok = Curl_uint32_hash_set(&hash, key2, value2); if(!ok) - free(value2); + curlx_free(value2); abort_unless(ok, "insertion into hash failed"); v = Curl_uint32_hash_get(&hash, key2); abort_unless(v == value2, "lookup present entry failed"); diff --git a/tests/unit/unit1620.c b/tests/unit/unit1620.c index 4851602eaa71..4c1674f5bd54 100644 --- a/tests/unit/unit1620.c +++ b/tests/unit/unit1620.c @@ -26,8 +26,6 @@ #include "urldata.h" #include "url.h" -#include "memdebug.h" /* LAST include file */ - static CURLcode t1620_setup(void) { CURLcode res = CURLE_OK; @@ -64,9 +62,9 @@ static void t1620_parse( "options should be equal to exp_options"); } - free(userstr); - free(passwdstr); - free(options); + curlx_free(userstr); + curlx_free(passwdstr); + curlx_free(options); } static CURLcode test_unit1620(const char *arg) diff --git a/tests/unit/unit1653.c b/tests/unit/unit1653.c index 8f6a5a51cc55..7ea7e380a80b 100644 --- a/tests/unit/unit1653.c +++ b/tests/unit/unit1653.c @@ -53,7 +53,7 @@ static CURLcode test_unit1653(const char *arg) u = curl_url(); if(!u) goto fail; - ipv6port = strdup("[fe80::250:56ff:fea7:da15]"); + ipv6port = curlx_strdup("[fe80::250:56ff:fea7:da15]"); if(!ipv6port) goto fail; ret = parse_port(u, ipv6port, FALSE); @@ -67,7 +67,7 @@ static CURLcode test_unit1653(const char *arg) u = curl_url(); if(!u) goto fail; - ipv6port = strdup("[fe80::250:56ff:fea7:da15|"); + ipv6port = curlx_strdup("[fe80::250:56ff:fea7:da15|"); if(!ipv6port) goto fail; ret = parse_port(u, ipv6port, FALSE); @@ -78,7 +78,7 @@ static CURLcode test_unit1653(const char *arg) u = curl_url(); if(!u) goto fail; - ipv6port = strdup("[fe80::250:56ff;fea7:da15]:808"); + ipv6port = curlx_strdup("[fe80::250:56ff;fea7:da15]:808"); if(!ipv6port) goto fail; ret = parse_port(u, ipv6port, FALSE); @@ -95,7 +95,7 @@ static CURLcode test_unit1653(const char *arg) u = curl_url(); if(!u) goto fail; - ipv6port = strdup("[fe80::250:56ff:fea7:da15%25eth3]:80"); + ipv6port = curlx_strdup("[fe80::250:56ff:fea7:da15%25eth3]:80"); if(!ipv6port) goto fail; ret = parse_port(u, ipv6port, FALSE); @@ -111,7 +111,7 @@ static CURLcode test_unit1653(const char *arg) u = curl_url(); if(!u) goto fail; - ipv6port = strdup("[fe80::250:56ff:fea7:da15%25eth3]"); + ipv6port = curlx_strdup("[fe80::250:56ff:fea7:da15%25eth3]"); if(!ipv6port) goto fail; ret = parse_port(u, ipv6port, FALSE); @@ -123,7 +123,7 @@ static CURLcode test_unit1653(const char *arg) u = curl_url(); if(!u) goto fail; - ipv6port = strdup("[fe80::250:56ff:fea7:da15]:81"); + ipv6port = curlx_strdup("[fe80::250:56ff:fea7:da15]:81"); if(!ipv6port) goto fail; ret = parse_port(u, ipv6port, FALSE); @@ -139,7 +139,7 @@ static CURLcode test_unit1653(const char *arg) u = curl_url(); if(!u) goto fail; - ipv6port = strdup("[fe80::250:56ff:fea7:da15];81"); + ipv6port = curlx_strdup("[fe80::250:56ff:fea7:da15];81"); if(!ipv6port) goto fail; ret = parse_port(u, ipv6port, FALSE); @@ -150,7 +150,7 @@ static CURLcode test_unit1653(const char *arg) u = curl_url(); if(!u) goto fail; - ipv6port = strdup("[fe80::250:56ff:fea7:da15]80"); + ipv6port = curlx_strdup("[fe80::250:56ff:fea7:da15]80"); if(!ipv6port) goto fail; ret = parse_port(u, ipv6port, FALSE); @@ -163,7 +163,7 @@ static CURLcode test_unit1653(const char *arg) u = curl_url(); if(!u) goto fail; - ipv6port = strdup("[fe80::250:56ff:fea7:da15]:"); + ipv6port = curlx_strdup("[fe80::250:56ff:fea7:da15]:"); if(!ipv6port) goto fail; ret = parse_port(u, ipv6port, TRUE); @@ -175,7 +175,7 @@ static CURLcode test_unit1653(const char *arg) u = curl_url(); if(!u) goto fail; - ipv6port = strdup("[fe80::250:56ff:fea7:da15!25eth3]:180"); + ipv6port = curlx_strdup("[fe80::250:56ff:fea7:da15!25eth3]:180"); if(!ipv6port) goto fail; ret = parse_port(u, ipv6port, FALSE); @@ -191,7 +191,7 @@ static CURLcode test_unit1653(const char *arg) u = curl_url(); if(!u) goto fail; - ipv6port = strdup("[fe80::250:56ff:fea7:da15%eth3]:80"); + ipv6port = curlx_strdup("[fe80::250:56ff:fea7:da15%eth3]:80"); if(!ipv6port) goto fail; ret = parse_port(u, ipv6port, FALSE); @@ -204,14 +204,14 @@ static CURLcode test_unit1653(const char *arg) u = curl_url(); if(!u) goto fail; - ipv6port = strdup("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" - "aaaaaaaaaaaaaaaaaaaaaa:"); + ipv6port = curlx_strdup("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaa:"); if(!ipv6port) goto fail; ret = parse_port(u, ipv6port, FALSE); fail_unless(ret == CURLUE_BAD_PORT_NUMBER, "parse_port did wrong"); fail: - free(ipv6port); + curlx_free(ipv6port); curl_url_cleanup(u); UNITTEST_END_SIMPLE diff --git a/tests/unit/unit1661.c b/tests/unit/unit1661.c index 6cc448554401..d9aa2a61f14e 100644 --- a/tests/unit/unit1661.c +++ b/tests/unit/unit1661.c @@ -23,7 +23,6 @@ ***************************************************************************/ #include "unitcheck.h" #include "bufref.h" -#include "memdebug.h" static int freecount = 0; @@ -31,7 +30,7 @@ static void test_free(void *p) { fail_unless(p, "pointer to free may not be NULL"); freecount++; - free(p); + curlx_free(p); } static CURLcode t1661_setup(struct bufref *bufref) @@ -68,7 +67,7 @@ static CURLcode test_unit1661(const char *arg) /** * testing Curl_bufref_set */ - buffer = malloc(13); + buffer = curlx_malloc(13); abort_unless(buffer, "Out of memory"); Curl_bufref_set(&bufref, buffer, 13, test_free); diff --git a/tests/unit/unit1663.c b/tests/unit/unit1663.c index 0d6fb4bbbe50..e4431930a410 100644 --- a/tests/unit/unit1663.c +++ b/tests/unit/unit1663.c @@ -32,8 +32,6 @@ #include "cf-socket.h" -#include "memdebug.h" /* LAST include file */ - static CURLcode t1663_setup(void) { CURLcode res = CURLE_OK; @@ -67,9 +65,9 @@ static void t1663_parse( "host should be equal to exp_host"); } - free(dev); - free(iface); - free(host); + curlx_free(dev); + curlx_free(iface); + curlx_free(host); } static CURLcode test_unit1663(const char *arg) diff --git a/tests/unit/unit1664.c b/tests/unit/unit1664.c index 6903c70e9298..a24a859e5272 100644 --- a/tests/unit/unit1664.c +++ b/tests/unit/unit1664.c @@ -30,8 +30,6 @@ #include #endif -#include "memdebug.h" /* LAST include file */ - static CURLcode t1664_setup(void) { CURLcode res = CURLE_OK; diff --git a/tests/unit/unit2600.c b/tests/unit/unit2600.c index f2adc50eddd4..b69b675b3b1a 100644 --- a/tests/unit/unit2600.c +++ b/tests/unit/unit2600.c @@ -47,7 +47,6 @@ #include "multiif.h" #include "select.h" #include "curl_trc.h" -#include "memdebug.h" static CURLcode t2600_setup(CURL **easy) { @@ -126,7 +125,7 @@ static void cf_test_destroy(struct Curl_cfilter *cf, struct Curl_easy *data) #else (void)data; #endif - free(ctx); + curlx_free(ctx); cf->ctx = NULL; } @@ -193,7 +192,7 @@ static CURLcode cf_test_create(struct Curl_cfilter **pcf, (void)data; (void)conn; - ctx = calloc(1, sizeof(*ctx)); + ctx = curlx_calloc(1, sizeof(*ctx)); if(!ctx) { res = CURLE_OUT_OF_MEMORY; goto out; @@ -233,8 +232,8 @@ static CURLcode cf_test_create(struct Curl_cfilter **pcf, out: *pcf = (!res) ? cf : NULL; if(res) { - free(cf); - free(ctx); + curlx_free(cf); + curlx_free(ctx); } return res; } diff --git a/tests/unit/unit2604.c b/tests/unit/unit2604.c index 695b1210071e..fb05189714c3 100644 --- a/tests/unit/unit2604.c +++ b/tests/unit/unit2604.c @@ -23,7 +23,6 @@ ***************************************************************************/ #include "unitcheck.h" #include "vssh/vssh.h" -#include "memdebug.h" static CURLcode test_unit2604(const char *arg) { @@ -79,7 +78,7 @@ static CURLcode test_unit2604(const char *arg) #pragma GCC diagnostic pop #endif - char *cp0 = calloc(1, too_long + 1); + char *cp0 = curlx_calloc(1, too_long + 1); fail_unless(cp0, "could not alloc too long value"); memset(cp0, 'a', too_long); @@ -108,7 +107,7 @@ static CURLcode test_unit2604(const char *arg) } } - free(cp0); + curlx_free(cp0); #endif diff --git a/tests/unit/unit2605.c b/tests/unit/unit2605.c index 71c37f32cfcb..49d0b0b000e9 100644 --- a/tests/unit/unit2605.c +++ b/tests/unit/unit2605.c @@ -23,7 +23,6 @@ ***************************************************************************/ #include "unitcheck.h" #include "vssh/vssh.h" -#include "memdebug.h" static CURLcode test_unit2605(const char *arg) { diff --git a/tests/unit/unit3200.c b/tests/unit/unit3200.c index 0b3c87691157..fe00da939d57 100644 --- a/tests/unit/unit3200.c +++ b/tests/unit/unit3200.c @@ -23,7 +23,6 @@ ***************************************************************************/ #include "unitcheck.h" #include "curl_get_line.h" -#include "memdebug.h" static CURLcode test_unit3200(const char *arg) { From c10dda9ebb6ccaaff7b71000c7c54b86dbd80cc7 Mon Sep 17 00:00:00 2001 From: Yedaya Katsman Date: Fri, 28 Nov 2025 15:48:03 +0200 Subject: [PATCH 106/415] curlx/fopen: fix typo in copyright Follow-up to 193cb00ce9b47e75d42157c650cc3de3fd96d35d #19626 Closes #19747 --- lib/curlx/fopen.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/curlx/fopen.c b/lib/curlx/fopen.c index c8dff428fc94..caf4978af163 100644 --- a/lib/curlx/fopen.c +++ b/lib/curlx/fopen.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) Danieal Stenberg, , et al. + * Copyright (C) Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms From aad3c2e8e14317c99838e3766df6cd2ce8f3f279 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Fri, 28 Nov 2025 14:19:18 +0100 Subject: [PATCH 107/415] example: fix formatting nits Also: - drop non-portable `__STRING()` macro use where still used. Closes #19746 --- docs/examples/10-at-a-time.c | 2 +- docs/examples/anyauthput.c | 8 +-- docs/examples/block_ip.c | 6 +- docs/examples/certinfo.c | 4 +- docs/examples/cookie_interface.c | 3 +- docs/examples/crawler.c | 15 +++-- docs/examples/ephiperfifo.c | 65 +++++++++++---------- docs/examples/evhiperfifo.c | 35 ++++++------ docs/examples/externalsocket.c | 5 +- docs/examples/ftp-wildcard.c | 5 +- docs/examples/ftpget.c | 1 - docs/examples/ftpgetresp.c | 2 +- docs/examples/ftpuploadfrommem.c | 4 +- docs/examples/getinmemory.c | 7 +-- docs/examples/getredirect.c | 3 +- docs/examples/ghiper.c | 31 +++++----- docs/examples/headerapi.c | 1 - docs/examples/hiperfifo.c | 75 ++++++++++++++----------- docs/examples/hsts-preload.c | 3 +- docs/examples/htmltidy.c | 4 +- docs/examples/htmltitle.cpp | 7 +-- docs/examples/http2-pushinmemory.c | 1 - docs/examples/httpput-postfields.c | 2 +- docs/examples/httpput.c | 2 +- docs/examples/imap-append.c | 4 +- docs/examples/imap-ssl.c | 2 +- docs/examples/log_failed_transfers.c | 2 +- docs/examples/multi-app.c | 2 +- docs/examples/multi-event.c | 18 +++--- docs/examples/multi-legacy.c | 6 +- docs/examples/multi-uv.c | 18 +++--- docs/examples/multithread.c | 2 - docs/examples/netrc.c | 3 +- docs/examples/post-callback.c | 2 +- docs/examples/postinmemory.c | 5 +- docs/examples/sftpget.c | 4 +- docs/examples/sftpuploadresume.c | 1 - docs/examples/shared-connection-cache.c | 4 +- docs/examples/simplessl.c | 8 +-- docs/examples/smooth-gtk-thread.c | 9 ++- docs/examples/smtp-authzid.c | 4 +- docs/examples/smtp-mail.c | 4 +- docs/examples/smtp-multi.c | 4 +- docs/examples/smtp-ssl.c | 4 +- docs/examples/smtp-tls.c | 4 +- docs/examples/sslbackend.c | 2 +- docs/examples/synctime.c | 33 ++++++----- docs/examples/threaded-ssl.c | 2 +- docs/examples/usercertinmem.c | 4 +- docs/examples/xmlstream.c | 10 ++-- 50 files changed, 225 insertions(+), 227 deletions(-) diff --git a/docs/examples/10-at-a-time.c b/docs/examples/10-at-a-time.c index bddcd1563740..22db7c5fc461 100644 --- a/docs/examples/10-at-a-time.c +++ b/docs/examples/10-at-a-time.c @@ -81,7 +81,7 @@ static const char *urls[] = { }; #define MAX_PARALLEL 10 /* number of simultaneous transfers */ -#define NUM_URLS sizeof(urls)/sizeof(char *) +#define NUM_URLS (sizeof(urls) / sizeof(char *)) static size_t write_cb(char *data, size_t n, size_t l, void *userp) { diff --git a/docs/examples/anyauthput.c b/docs/examples/anyauthput.c index eb5959ca2263..247d4d0d3b3a 100644 --- a/docs/examples/anyauthput.c +++ b/docs/examples/anyauthput.c @@ -65,9 +65,9 @@ /* seek callback function */ static int my_seek(void *userp, curl_off_t offset, int origin) { - FILE *fp = (FILE *) userp; + FILE *fp = (FILE *)userp; - if(fseek(fp, (long) offset, origin) == -1) + if(fseek(fp, (long)offset, origin) == -1) /* could not seek */ return CURL_SEEKFUNC_CANTSEEK; @@ -128,13 +128,13 @@ int main(int argc, char **argv) curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_cb); /* which file to upload */ - curl_easy_setopt(curl, CURLOPT_READDATA, (void *) fp); + curl_easy_setopt(curl, CURLOPT_READDATA, (void *)fp); /* set the seek function */ curl_easy_setopt(curl, CURLOPT_SEEKFUNCTION, my_seek); /* pass the file descriptor to the seek callback as well */ - curl_easy_setopt(curl, CURLOPT_SEEKDATA, (void *) fp); + curl_easy_setopt(curl, CURLOPT_SEEKDATA, (void *)fp); /* enable "uploading" (which means PUT when doing HTTP) */ curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L); diff --git a/docs/examples/block_ip.c b/docs/examples/block_ip.c index ef7056dc4340..bf2193a26359 100644 --- a/docs/examples/block_ip.c +++ b/docs/examples/block_ip.c @@ -31,7 +31,11 @@ #ifdef __AMIGA__ #include -int main(void) { printf("Platform not supported.\n"); return 1; } +int main(void) +{ + printf("Platform not supported.\n"); + return 1; +} #else #ifdef _MSC_VER diff --git a/docs/examples/certinfo.c b/docs/examples/certinfo.c index 3176d0a1fcfc..e799cfc92879 100644 --- a/docs/examples/certinfo.c +++ b/docs/examples/certinfo.c @@ -29,7 +29,7 @@ #include -static size_t write_cb(void *ptr, size_t size, size_t nmemb, void *stream) +static size_t write_cb(void *ptr, size_t size, size_t nmemb, void *stream) { (void)stream; (void)ptr; @@ -74,10 +74,8 @@ int main(void) for(slist = certinfo->certinfo[i]; slist; slist = slist->next) printf("%s\n", slist->data); - } } - } curl_easy_cleanup(curl); diff --git a/docs/examples/cookie_interface.c b/docs/examples/cookie_interface.c index a031380f1207..0398cdf164ff 100644 --- a/docs/examples/cookie_interface.c +++ b/docs/examples/cookie_interface.c @@ -71,8 +71,7 @@ static int print_cookies(CURL *curl) return 0; } -int -main(void) +int main(void) { CURL *curl; CURLcode res; diff --git a/docs/examples/crawler.c b/docs/examples/crawler.c index 419ceab26d06..9207199cdfc9 100644 --- a/docs/examples/crawler.c +++ b/docs/examples/crawler.c @@ -65,7 +65,7 @@ struct memory { static size_t write_cb(void *contents, size_t sz, size_t nmemb, void *ctx) { size_t realsize = sz * nmemb; - struct memory *mem = (struct memory*) ctx; + struct memory *mem = (struct memory *)ctx; char *ptr = realloc(mem->buf, mem->size + realsize); if(!ptr) { /* out of memory */ @@ -109,7 +109,7 @@ static CURL *make_handle(const char *url) curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT_MS, 2000L); /* skip files larger than a gigabyte */ curl_easy_setopt(curl, CURLOPT_MAXFILESIZE_LARGE, - (curl_off_t)1024*1024*1024); + (curl_off_t)1024 * 1024 * 1024); curl_easy_setopt(curl, CURLOPT_COOKIEFILE, ""); curl_easy_setopt(curl, CURLOPT_FILETIME, 1L); curl_easy_setopt(curl, CURLOPT_USERAGENT, "mini crawler"); @@ -121,8 +121,7 @@ static CURL *make_handle(const char *url) } /* HREF finder implemented in libxml2 but could be any HTML parser */ -static size_t follow_links(CURLM *multi, struct memory *mem, - const char *url) +static size_t follow_links(CURLM *multi, struct memory *mem, const char *url) { int opts = HTML_PARSE_NOBLANKS | HTML_PARSE_NOERROR | \ HTML_PARSE_NOWARNING | HTML_PARSE_NONET; @@ -135,7 +134,7 @@ static size_t follow_links(CURLM *multi, struct memory *mem, xmlXPathObjectPtr result; if(!doc) return 0; - xpath = (xmlChar*) "//a/@href"; + xpath = (xmlChar *)"//a/@href"; context = xmlXPathNewContext(doc); result = xmlXPathEvalExpression(xpath, context); xmlXPathFreeContext(context); @@ -155,10 +154,10 @@ static size_t follow_links(CURLM *multi, struct memory *mem, char *link; if(follow_relative_links) { xmlChar *orig = href; - href = xmlBuildURI(href, (xmlChar *) url); + href = xmlBuildURI(href, (xmlChar *)url); xmlFree(orig); } - link = (char *) href; + link = (char *)href; if(!link || strlen(link) < 20) continue; if(!strncmp(link, "http://", 7) || !strncmp(link, "https://", 8)) { @@ -240,7 +239,7 @@ int main(void) } } else { - printf("[%d] HTTP %d: %s\n", complete, (int) res_status, url); + printf("[%d] HTTP %d: %s\n", complete, (int)res_status, url); } } else { diff --git a/docs/examples/ephiperfifo.c b/docs/examples/ephiperfifo.c index b47cbbedbfb1..e572fffad887 100644 --- a/docs/examples/ephiperfifo.c +++ b/docs/examples/ephiperfifo.c @@ -58,7 +58,6 @@ This is purely a demo app, all retrieved data is simply discarded by the write callback. */ - #include #include #include @@ -77,7 +76,6 @@ callback. #define MSG_OUT stdout /* Send info to stdout, change to stderr if you want */ - /* Global information, common to all connections */ struct GlobalInfo { int epfd; /* epoll filedescriptor */ @@ -105,23 +103,35 @@ struct SockInfo { struct GlobalInfo *global; }; -#define mycase(code) \ - case code: s = __STRING(code) - /* Die if we get a bad CURLMcode somewhere */ static void mcode_or_die(const char *where, CURLMcode code) { if(CURLM_OK != code) { const char *s; switch(code) { - mycase(CURLM_BAD_HANDLE); break; - mycase(CURLM_BAD_EASY_HANDLE); break; - mycase(CURLM_OUT_OF_MEMORY); break; - mycase(CURLM_INTERNAL_ERROR); break; - mycase(CURLM_UNKNOWN_OPTION); break; - mycase(CURLM_LAST); break; - default: s = "CURLM_unknown"; break; - mycase(CURLM_BAD_SOCKET); + case CURLM_BAD_HANDLE: + s = "CURLM_BAD_HANDLE"; + break; + case CURLM_BAD_EASY_HANDLE: + s = "CURLM_BAD_EASY_HANDLE"; + break; + case CURLM_OUT_OF_MEMORY: + s = "CURLM_OUT_OF_MEMORY"; + break; + case CURLM_INTERNAL_ERROR: + s = "CURLM_INTERNAL_ERROR"; + break; + case CURLM_UNKNOWN_OPTION: + s = "CURLM_UNKNOWN_OPTION"; + break; + case CURLM_LAST: + s = "CURLM_LAST"; + break; + default: + s = "CURLM_unknown"; + break; + case CURLM_BAD_SOCKET: + s = "CURLM_BAD_SOCKET"; fprintf(MSG_OUT, "ERROR: %s returns %s\n", where, s); /* ignore this error */ return; @@ -161,7 +171,7 @@ static int multi_timer_cb(CURLM *multi, long timeout_ms, struct GlobalInfo *g) memset(&its, 0, sizeof(its)); } - timerfd_settime(g->tfd, /* flags= */0, &its, NULL); + timerfd_settime(g->tfd, /* flags= */ 0, &its, NULL); return 0; } @@ -281,7 +291,7 @@ static void setsock(struct SockInfo *f, curl_socket_t s, CURL *e, int act, static void addsock(curl_socket_t s, CURL *curl, int action, struct GlobalInfo *g) { - struct SockInfo *fdp = (struct SockInfo*)calloc(1, sizeof(struct SockInfo)); + struct SockInfo *fdp = (struct SockInfo *)calloc(1, sizeof(struct SockInfo)); fdp->global = g; setsock(fdp, s, curl, action, g); @@ -291,12 +301,11 @@ static void addsock(curl_socket_t s, CURL *curl, int action, /* CURLMOPT_SOCKETFUNCTION */ static int sock_cb(CURL *e, curl_socket_t s, int what, void *cbp, void *sockp) { - struct GlobalInfo *g = (struct GlobalInfo*) cbp; - struct SockInfo *fdp = (struct SockInfo*) sockp; - const char *whatstr[]={ "none", "IN", "OUT", "INOUT", "REMOVE" }; + struct GlobalInfo *g = (struct GlobalInfo *)cbp; + struct SockInfo *fdp = (struct SockInfo *)sockp; + const char *whatstr[] = {"none", "IN", "OUT", "INOUT", "REMOVE"}; - fprintf(MSG_OUT, - "socket callback: s=%d e=%p what=%s ", s, e, whatstr[what]); + fprintf(MSG_OUT, "socket callback: s=%d e=%p what=%s ", s, e, whatstr[what]); if(what == CURL_POLL_REMOVE) { fprintf(MSG_OUT, "\n"); remsock(fdp, g); @@ -307,8 +316,7 @@ static int sock_cb(CURL *e, curl_socket_t s, int what, void *cbp, void *sockp) addsock(s, e, what, g); } else { - fprintf(MSG_OUT, - "Changing action from %s to %s\n", + fprintf(MSG_OUT, "Changing action from %s to %s\n", whatstr[fdp->action], whatstr[what]); setsock(fdp, s, e, what, g); } @@ -342,7 +350,7 @@ static void new_conn(const char *url, struct GlobalInfo *g) struct ConnInfo *conn; CURLMcode rc; - conn = (struct ConnInfo*)calloc(1, sizeof(*conn)); + conn = (struct ConnInfo *)calloc(1, sizeof(*conn)); conn->error[0] = '\0'; conn->curl = curl_easy_init(); @@ -364,8 +372,8 @@ static void new_conn(const char *url, struct GlobalInfo *g) curl_easy_setopt(conn->curl, CURLOPT_FOLLOWLOCATION, 1L); curl_easy_setopt(conn->curl, CURLOPT_LOW_SPEED_TIME, 3L); curl_easy_setopt(conn->curl, CURLOPT_LOW_SPEED_LIMIT, 10L); - fprintf(MSG_OUT, - "Adding easy %p to multi %p (%s)\n", conn->curl, g->multi, url); + fprintf(MSG_OUT, "Adding easy %p to multi %p (%s)\n", + conn->curl, g->multi, url); rc = curl_multi_add_handle(g->multi, conn->curl); mcode_or_die("new_conn: curl_multi_add_handle", rc); @@ -381,9 +389,9 @@ static void fifo_cb(struct GlobalInfo *g, int revents) int n = 0; do { - s[0]='\0'; + s[0] = '\0'; rv = fscanf(g->input, "%1023s%n", s, &n); - s[n]='\0'; + s[n] = '\0'; if(n && s[0]) { new_conn(s, g); /* if we read a URL, go get it! */ } @@ -437,7 +445,6 @@ static void clean_fifo(struct GlobalInfo *g) unlink(fifo); } - int g_should_exit_ = 0; void sigint_handler(int signo) @@ -506,7 +513,7 @@ int main(int argc, char **argv) while(!g_should_exit_) { int idx; int err = epoll_wait(g.epfd, events, - sizeof(events)/sizeof(struct epoll_event), 10000); + sizeof(events) / sizeof(struct epoll_event), 10000); if(err == -1) { /* !checksrc! disable ERRNOVAR 1 */ if(errno == EINTR) { diff --git a/docs/examples/evhiperfifo.c b/docs/examples/evhiperfifo.c index b6b957d54eb6..178be018a3a6 100644 --- a/docs/examples/evhiperfifo.c +++ b/docs/examples/evhiperfifo.c @@ -61,7 +61,6 @@ This is purely a demo app, all retrieved data is simply discarded by the write callback. */ - #include #include #include @@ -79,7 +78,6 @@ callback. #define MSG_OUT stdout /* Send info to stdout, change to stderr if you want */ - /* Global information, common to all connections */ struct GlobalInfo { struct ev_loop *loop; @@ -119,7 +117,7 @@ static int multi_timer_cb(CURLM *multi, long timeout_ms, struct GlobalInfo *g) ev_timer_stop(g->loop, &g->timer_event); if(timeout_ms >= 0) { /* -1 means delete, other values are timeout times in milliseconds */ - double t = timeout_ms / 1000; + double t = timeout_ms / 1000; ev_timer_init(&g->timer_event, timer_cb, t, 0.); ev_timer_start(g->loop, &g->timer_event); } @@ -196,7 +194,7 @@ static void event_cb(EV_P_ struct ev_io *w, int revents) int action; printf("%s w %p revents %i\n", __PRETTY_FUNCTION__, (void *)w, revents); - g = (struct GlobalInfo*) w->data; + g = (struct GlobalInfo *)w->data; action = ((revents & EV_READ) ? CURL_POLL_IN : 0) | ((revents & EV_WRITE) ? CURL_POLL_OUT : 0); @@ -270,15 +268,14 @@ static void addsock(curl_socket_t s, CURL *curl, int action, /* CURLMOPT_SOCKETFUNCTION */ static int sock_cb(CURL *e, curl_socket_t s, int what, void *cbp, void *sockp) { - struct GlobalInfo *g = (struct GlobalInfo*) cbp; - struct SockInfo *fdp = (struct SockInfo*) sockp; - const char *whatstr[]={ "none", "IN", "OUT", "INOUT", "REMOVE"}; + struct GlobalInfo *g = (struct GlobalInfo *)cbp; + struct SockInfo *fdp = (struct SockInfo *)sockp; + const char *whatstr[] = {"none", "IN", "OUT", "INOUT", "REMOVE"}; printf("%s e %p s %i what %i cbp %p sockp %p\n", __PRETTY_FUNCTION__, e, s, what, cbp, sockp); - fprintf(MSG_OUT, - "socket callback: s=%d e=%p what=%s ", s, e, whatstr[what]); + fprintf(MSG_OUT, "socket callback: s=%d e=%p what=%s ", s, e, whatstr[what]); if(what == CURL_POLL_REMOVE) { fprintf(MSG_OUT, "\n"); remsock(fdp, g); @@ -289,8 +286,7 @@ static int sock_cb(CURL *e, curl_socket_t s, int what, void *cbp, void *sockp) addsock(s, e, what, g); } else { - fprintf(MSG_OUT, - "Changing action from %s to %s\n", + fprintf(MSG_OUT, "Changing action from %s to %s\n", whatstr[fdp->action], whatstr[what]); setsock(fdp, s, e, what, g); } @@ -302,7 +298,7 @@ static int sock_cb(CURL *e, curl_socket_t s, int what, void *cbp, void *sockp) static size_t write_cb(void *ptr, size_t size, size_t nmemb, void *data) { size_t realsize = size * nmemb; - struct ConnInfo *conn = (struct ConnInfo*) data; + struct ConnInfo *conn = (struct ConnInfo *)data; (void)ptr; (void)conn; return realsize; @@ -316,8 +312,9 @@ static int xferinfo_cb(void *p, curl_off_t dltotal, curl_off_t dlnow, (void)ult; (void)uln; - fprintf(MSG_OUT, "Progress: %s (%" CURL_FORMAT_CURL_OFF_T - "/%" CURL_FORMAT_CURL_OFF_T ")\n", conn->url, dlnow, dltotal); + fprintf(MSG_OUT, "Progress: %s (%" CURL_FORMAT_CURL_OFF_T "/" + "%" CURL_FORMAT_CURL_OFF_T ")\n", + conn->url, dlnow, dltotal); return 0; } @@ -328,7 +325,7 @@ static void new_conn(const char *url, struct GlobalInfo *g) CURLMcode rc; conn = calloc(1, sizeof(*conn)); - conn->error[0]='\0'; + conn->error[0] = '\0'; conn->curl = curl_easy_init(); if(!conn->curl) { @@ -349,8 +346,8 @@ static void new_conn(const char *url, struct GlobalInfo *g) curl_easy_setopt(conn->curl, CURLOPT_LOW_SPEED_TIME, 3L); curl_easy_setopt(conn->curl, CURLOPT_LOW_SPEED_LIMIT, 10L); - fprintf(MSG_OUT, - "Adding easy %p to multi %p (%s)\n", conn->curl, g->multi, url); + fprintf(MSG_OUT, "Adding easy %p to multi %p (%s)\n", + conn->curl, g->multi, url); rc = curl_multi_add_handle(g->multi, conn->curl); mcode_or_die("new_conn: curl_multi_add_handle", rc); @@ -369,9 +366,9 @@ static void fifo_cb(EV_P_ struct ev_io *w, int revents) (void)revents; do { - s[0]='\0'; + s[0] = '\0'; rv = fscanf(g->input, "%1023s%n", s, &n); - s[n]='\0'; + s[n] = '\0'; if(n && s[0]) { new_conn(s, g); /* if we read a URL, go get it! */ } diff --git a/docs/examples/externalsocket.c b/docs/examples/externalsocket.c index 610a835272a6..632d5f298168 100644 --- a/docs/examples/externalsocket.c +++ b/docs/examples/externalsocket.c @@ -124,7 +124,7 @@ int main(void) memset(&servaddr, 0, sizeof(servaddr)); servaddr.sin_family = AF_INET; - servaddr.sin_port = htons(PORTNUM); + servaddr.sin_port = htons(PORTNUM); servaddr.sin_addr.s_addr = inet_addr(IPADDR); if(INADDR_NONE == servaddr.sin_addr.s_addr) { @@ -132,8 +132,7 @@ int main(void) return 2; } - if(connect(sockfd, (struct sockaddr *) &servaddr, sizeof(servaddr)) == - -1) { + if(connect(sockfd, (struct sockaddr *)&servaddr, sizeof(servaddr)) == -1) { close(sockfd); printf("client error: connect: %s\n", strerror(errno)); return 1; diff --git a/docs/examples/ftp-wildcard.c b/docs/examples/ftp-wildcard.c index 3bd2f690832b..fa66628f1655 100644 --- a/docs/examples/ftp-wildcard.c +++ b/docs/examples/ftp-wildcard.c @@ -85,8 +85,7 @@ static long file_is_downloaded(void *input) return CURL_CHUNK_END_FUNC_OK; } -static size_t write_cb(char *buff, size_t size, size_t nmemb, - void *cb_data) +static size_t write_cb(char *buff, size_t size, size_t nmemb, void *cb_data) { struct callback_data *data = cb_data; size_t written = 0; @@ -104,7 +103,7 @@ int main(int argc, char **argv) CURL *curl; /* help data */ - struct callback_data data = { 0 }; + struct callback_data data = {0}; /* global initialization */ CURLcode res = curl_global_init(CURL_GLOBAL_ALL); diff --git a/docs/examples/ftpget.c b/docs/examples/ftpget.c index f57974de1fb1..400102207474 100644 --- a/docs/examples/ftpget.c +++ b/docs/examples/ftpget.c @@ -52,7 +52,6 @@ static size_t write_cb(void *buffer, size_t size, size_t nmemb, void *stream) return fwrite(buffer, size, nmemb, out->stream); } - int main(void) { CURL *curl; diff --git a/docs/examples/ftpgetresp.c b/docs/examples/ftpgetresp.c index eec727bf943b..53ada7ccaee6 100644 --- a/docs/examples/ftpgetresp.c +++ b/docs/examples/ftpgetresp.c @@ -90,7 +90,7 @@ int main(void) curl_easy_cleanup(curl); } - fclose(ftpfile); /* close the local file */ + fclose(ftpfile); /* close the local file */ fclose(respfile); /* close the response file */ curl_global_cleanup(); diff --git a/docs/examples/ftpuploadfrommem.c b/docs/examples/ftpuploadfrommem.c index af88f52f1a7b..7c75f2b8d759 100644 --- a/docs/examples/ftpuploadfrommem.c +++ b/docs/examples/ftpuploadfrommem.c @@ -30,7 +30,7 @@ #include -static const char data[]= +static const char data[] = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. " "___ rhoncus odio id venenatis volutpat. Vestibulum dapibus " "bibendum ullamcorper. Maecenas finibus elit augue, vel " @@ -64,7 +64,7 @@ static size_t read_cb(char *ptr, size_t size, size_t nmemb, void *userp) return copylen; } - return 0; /* no more data left to deliver */ + return 0; /* no more data left to deliver */ } int main(void) diff --git a/docs/examples/getinmemory.c b/docs/examples/getinmemory.c index 1deeeda26667..d4d8960487a1 100644 --- a/docs/examples/getinmemory.c +++ b/docs/examples/getinmemory.c @@ -37,8 +37,7 @@ struct MemoryStruct { size_t size; }; -static size_t write_cb(void *contents, size_t size, size_t nmemb, - void *userp) +static size_t write_cb(void *contents, size_t size, size_t nmemb, void *userp) { size_t realsize = size * nmemb; struct MemoryStruct *mem = (struct MemoryStruct *)userp; @@ -69,8 +68,8 @@ int main(void) if(res) return (int)res; - chunk.memory = malloc(1); /* grown as needed by the realloc above */ - chunk.size = 0; /* no data at this point */ + chunk.memory = malloc(1); /* grown as needed by the realloc above */ + chunk.size = 0; /* no data at this point */ /* init the curl session */ curl = curl_easy_init(); diff --git a/docs/examples/getredirect.c b/docs/examples/getredirect.c index b1f42dc9fdf4..6ad9b9c1aa5c 100644 --- a/docs/examples/getredirect.c +++ b/docs/examples/getredirect.c @@ -54,8 +54,7 @@ int main(void) curl_easy_strerror(res)); else { res = curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response_code); - if((res == CURLE_OK) && - ((response_code / 100) != 3)) { + if((res == CURLE_OK) && ((response_code / 100) != 3)) { /* a redirect implies a 3xx response code */ fprintf(stderr, "Not a redirect.\n"); } diff --git a/docs/examples/ghiper.c b/docs/examples/ghiper.c index f27521971cd5..d7b19abb9be3 100644 --- a/docs/examples/ghiper.c +++ b/docs/examples/ghiper.c @@ -171,8 +171,8 @@ static int update_timeout_cb(CURLM *multi, long timeout_ms, void *userp) { struct timeval timeout; struct GlobalInfo *g = (struct GlobalInfo *)userp; - timeout.tv_sec = timeout_ms/1000; - timeout.tv_usec = (timeout_ms%1000)*1000; + timeout.tv_sec = timeout_ms / 1000; + timeout.tv_usec = (timeout_ms % 1000) * 1000; MSG_OUT("*** update_timeout_cb %ld => %ld:%ld ***\n", timeout_ms, timeout.tv_sec, timeout.tv_usec); @@ -191,7 +191,7 @@ static int update_timeout_cb(CURLM *multi, long timeout_ms, void *userp) /* Called by glib when we get action on a multi socket */ static gboolean event_cb(GIOChannel *ch, GIOCondition condition, gpointer data) { - struct GlobalInfo *g = (struct GlobalInfo*) data; + struct GlobalInfo *g = (struct GlobalInfo *)data; CURLMcode rc; int fd = g_io_channel_unix_get_fd(ch); @@ -259,9 +259,9 @@ static void addsock(curl_socket_t s, CURL *curl, int action, /* CURLMOPT_SOCKETFUNCTION */ static int sock_cb(CURL *e, curl_socket_t s, int what, void *cbp, void *sockp) { - struct GlobalInfo *g = (struct GlobalInfo*) cbp; - struct SockInfo *fdp = (struct SockInfo*) sockp; - static const char *whatstr[]={ "none", "IN", "OUT", "INOUT", "REMOVE" }; + struct GlobalInfo *g = (struct GlobalInfo *)cbp; + struct SockInfo *fdp = (struct SockInfo *)sockp; + static const char *whatstr[] = {"none", "IN", "OUT", "INOUT", "REMOVE"}; MSG_OUT("socket callback: s=%d e=%p what=%s ", s, e, whatstr[what]); if(what == CURL_POLL_REMOVE) { @@ -276,8 +276,7 @@ static int sock_cb(CURL *e, curl_socket_t s, int what, void *cbp, void *sockp) addsock(s, e, what, g); } else { - MSG_OUT( - "Changing action from %d to %d\n", fdp->action, what); + MSG_OUT("Changing action from %d to %d\n", fdp->action, what); setsock(fdp, s, e, what, g); } } @@ -288,7 +287,7 @@ static int sock_cb(CURL *e, curl_socket_t s, int what, void *cbp, void *sockp) static size_t write_cb(void *ptr, size_t size, size_t nmemb, void *data) { size_t realsize = size * nmemb; - struct ConnInfo *conn = (struct ConnInfo*) data; + struct ConnInfo *conn = (struct ConnInfo *)data; (void)ptr; (void)conn; return realsize; @@ -302,8 +301,8 @@ static int xferinfo_cb(void *p, curl_off_t dltotal, curl_off_t dlnow, (void)ult; (void)uln; - fprintf(MSG_OUT, "Progress: %s (%" CURL_FORMAT_CURL_OFF_T - "/%" CURL_FORMAT_CURL_OFF_T ")\n", conn->url, dlnow, dltotal); + fprintf(MSG_OUT, "Progress: %s (%" CURL_FORMAT_CURL_OFF_T "/" + "%" CURL_FORMAT_CURL_OFF_T ")\n", conn->url, dlnow, dltotal); return 0; } @@ -357,18 +356,18 @@ static gboolean fifo_cb(GIOChannel *ch, GIOCondition condition, gpointer data) rv = g_io_channel_read_line(ch, &buf, &len, &tp, &err); if(buf) { if(tp) { - buf[tp]='\0'; + buf[tp] = '\0'; } - new_conn(buf, (struct GlobalInfo*)data); + new_conn(buf, (struct GlobalInfo *)data); g_free(buf); } else { buf = g_malloc(BUF_SIZE + 1); while(TRUE) { - buf[BUF_SIZE]='\0'; + buf[BUF_SIZE] = '\0'; g_io_channel_read_chars(ch, buf, BUF_SIZE, &len, &err); if(len) { - buf[len]='\0'; + buf[len] = '\0'; if(all) { tmp = all; all = g_strdup_printf("%s%s", tmp, buf); @@ -383,7 +382,7 @@ static gboolean fifo_cb(GIOChannel *ch, GIOCondition condition, gpointer data) } } if(all) { - new_conn(all, (struct GlobalInfo*)data); + new_conn(all, (struct GlobalInfo *)data); g_free(all); } g_free(buf); diff --git a/docs/examples/headerapi.c b/docs/examples/headerapi.c index 089a23a07013..e1fa33b8f62d 100644 --- a/docs/examples/headerapi.c +++ b/docs/examples/headerapi.c @@ -76,7 +76,6 @@ int main(void) printf(" %s: %s (%u)\n", h->name, h->value, (unsigned int)h->amount); prev = h; } while(h); - } /* always cleanup */ curl_easy_cleanup(curl); diff --git a/docs/examples/hiperfifo.c b/docs/examples/hiperfifo.c index 60288b4bd263..576bbb8d2c2f 100644 --- a/docs/examples/hiperfifo.c +++ b/docs/examples/hiperfifo.c @@ -77,7 +77,6 @@ callback. #define MSG_OUT stdout /* Send info to stdout, change to stderr if you want */ - /* Global information, common to all connections */ struct GlobalInfo { struct event_base *evbase; @@ -107,23 +106,35 @@ struct SockInfo { struct GlobalInfo *global; }; -#define mycase(code) \ - case code: s = __STRING(code) - /* Die if we get a bad CURLMcode somewhere */ static void mcode_or_die(const char *where, CURLMcode code) { if(CURLM_OK != code) { const char *s; switch(code) { - mycase(CURLM_BAD_HANDLE); break; - mycase(CURLM_BAD_EASY_HANDLE); break; - mycase(CURLM_OUT_OF_MEMORY); break; - mycase(CURLM_INTERNAL_ERROR); break; - mycase(CURLM_UNKNOWN_OPTION); break; - mycase(CURLM_LAST); break; - default: s = "CURLM_unknown"; break; - mycase(CURLM_BAD_SOCKET); + case CURLM_BAD_HANDLE: + s = "CURLM_BAD_HANDLE"; + break; + case CURLM_BAD_EASY_HANDLE: + s = "CURLM_BAD_EASY_HANDLE"; + break; + case CURLM_OUT_OF_MEMORY: + s = "CURLM_OUT_OF_MEMORY"; + break; + case CURLM_INTERNAL_ERROR: + s = "CURLM_INTERNAL_ERROR"; + break; + case CURLM_UNKNOWN_OPTION: + s = "CURLM_UNKNOWN_OPTION"; + break; + case CURLM_LAST: + s = "CURLM_LAST"; + break; + default: + s = "CURLM_unknown"; + break; + case CURLM_BAD_SOCKET: + s = "CURLM_BAD_SOCKET"; fprintf(MSG_OUT, "ERROR: %s returns %s\n", where, s); /* ignore this error */ return; @@ -139,8 +150,8 @@ static int multi_timer_cb(CURLM *multi, long timeout_ms, struct GlobalInfo *g) struct timeval timeout; (void)multi; - timeout.tv_sec = timeout_ms/1000; - timeout.tv_usec = (timeout_ms%1000)*1000; + timeout.tv_sec = timeout_ms / 1000; + timeout.tv_usec = (timeout_ms % 1000) * 1000; fprintf(MSG_OUT, "multi_timer_cb: Setting timeout to %ld ms\n", timeout_ms); /* @@ -185,7 +196,7 @@ static void check_multi_info(struct GlobalInfo *g) /* Called by libevent when we get action on a multi socket */ static void event_cb(int fd, short kind, void *userp) { - struct GlobalInfo *g = (struct GlobalInfo*) userp; + struct GlobalInfo *g = (struct GlobalInfo *)userp; CURLMcode rc; int action = @@ -261,12 +272,11 @@ static void addsock(curl_socket_t s, CURL *curl, int action, /* CURLMOPT_SOCKETFUNCTION */ static int sock_cb(CURL *e, curl_socket_t s, int what, void *cbp, void *sockp) { - struct GlobalInfo *g = (struct GlobalInfo*) cbp; - struct SockInfo *fdp = (struct SockInfo*) sockp; - const char *whatstr[]={ "none", "IN", "OUT", "INOUT", "REMOVE" }; + struct GlobalInfo *g = (struct GlobalInfo *)cbp; + struct SockInfo *fdp = (struct SockInfo *)sockp; + const char *whatstr[] = {"none", "IN", "OUT", "INOUT", "REMOVE"}; - fprintf(MSG_OUT, - "socket callback: s=%d e=%p what=%s ", s, e, whatstr[what]); + fprintf(MSG_OUT, "socket callback: s=%d e=%p what=%s ", s, e, whatstr[what]); if(what == CURL_POLL_REMOVE) { fprintf(MSG_OUT, "\n"); remsock(fdp); @@ -277,8 +287,7 @@ static int sock_cb(CURL *e, curl_socket_t s, int what, void *cbp, void *sockp) addsock(s, e, what, g); } else { - fprintf(MSG_OUT, - "Changing action from %s to %s\n", + fprintf(MSG_OUT, "Changing action from %s to %s\n", whatstr[fdp->action], whatstr[what]); setsock(fdp, s, e, what, g); } @@ -302,8 +311,8 @@ static int xferinfo_cb(void *p, curl_off_t dltotal, curl_off_t dlnow, (void)ult; (void)uln; - fprintf(MSG_OUT, "Progress: %s (%" CURL_FORMAT_CURL_OFF_T - "/%" CURL_FORMAT_CURL_OFF_T ")\n", conn->url, dlnow, dltotal); + fprintf(MSG_OUT, "Progress: %s (%" CURL_FORMAT_CURL_OFF_T "/" + "%" CURL_FORMAT_CURL_OFF_T ")\n", conn->url, dlnow, dltotal); return 0; } @@ -333,8 +342,8 @@ static void new_conn(const char *url, struct GlobalInfo *g) curl_easy_setopt(conn->curl, CURLOPT_XFERINFOFUNCTION, xferinfo_cb); curl_easy_setopt(conn->curl, CURLOPT_PROGRESSDATA, conn); curl_easy_setopt(conn->curl, CURLOPT_FOLLOWLOCATION, 1L); - fprintf(MSG_OUT, - "Adding easy %p to multi %p (%s)\n", conn->curl, g->multi, url); + fprintf(MSG_OUT, "Adding easy %p to multi %p (%s)\n", + conn->curl, g->multi, url); rc = curl_multi_add_handle(g->multi, conn->curl); mcode_or_die("new_conn: curl_multi_add_handle", rc); @@ -353,9 +362,9 @@ static void fifo_cb(int fd, short event, void *arg) (void)event; do { - s[0]='\0'; + s[0] = '\0'; rv = fscanf(g->input, "%1023s%n", s, &n); - s[n]='\0'; + s[n] = '\0'; if(n && s[0]) { if(!strcmp(s, "stop")) { g->stopped = 1; @@ -386,7 +395,7 @@ static int init_fifo(struct GlobalInfo *g) } } unlink(fifo); - if(mkfifo (fifo, 0600) == -1) { + if(mkfifo(fifo, 0600) == -1) { perror("mkfifo"); return 1; } @@ -398,7 +407,7 @@ static int init_fifo(struct GlobalInfo *g) g->input = fdopen(sockfd, "r"); fprintf(MSG_OUT, "Now, pipe some URL's into > %s\n", fifo); - event_assign(&g->fifo_event, g->evbase, sockfd, EV_READ|EV_PERSIST, + event_assign(&g->fifo_event, g->evbase, sockfd, EV_READ | EV_PERSIST, fifo_cb, g); event_add(&g->fifo_event, NULL); return 0; @@ -406,9 +415,9 @@ static int init_fifo(struct GlobalInfo *g) static void clean_fifo(struct GlobalInfo *g) { - event_del(&g->fifo_event); - fclose(g->input); - unlink(fifo); + event_del(&g->fifo_event); + fclose(g->input); + unlink(fifo); } int main(int argc, char **argv) diff --git a/docs/examples/hsts-preload.c b/docs/examples/hsts-preload.c index ad71c62cad96..b029df2a0a30 100644 --- a/docs/examples/hsts-preload.c +++ b/docs/examples/hsts-preload.c @@ -53,8 +53,7 @@ struct state { /* "read" is from the point of the library, it wants data from us. One domain entry per invoke. */ -static CURLSTScode hstsread(CURL *curl, struct curl_hstsentry *e, - void *userp) +static CURLSTScode hstsread(CURL *curl, struct curl_hstsentry *e, void *userp) { const char *host; const char *expire; diff --git a/docs/examples/htmltidy.c b/docs/examples/htmltidy.c index 04b4809317a9..9865a633efcd 100644 --- a/docs/examples/htmltidy.c +++ b/docs/examples/htmltidy.c @@ -48,14 +48,14 @@ static uint write_cb(char *in, uint size, uint nmemb, TidyBuffer *out) static void dumpNode(TidyDoc doc, TidyNode tnod, int indent) { TidyNode child; - for(child = tidyGetChild(tnod); child; child = tidyGetNext(child) ) { + for(child = tidyGetChild(tnod); child; child = tidyGetNext(child)) { ctmbstr name = tidyNodeGetName(child); if(name) { /* if it has a name, then it is an HTML tag ... */ TidyAttr attr; printf("%*.*s%s ", indent, indent, "<", name); /* walk the attribute list */ - for(attr = tidyAttrFirst(child); attr; attr = tidyAttrNext(attr) ) { + for(attr = tidyAttrFirst(child); attr; attr = tidyAttrNext(attr)) { printf("%s", tidyAttrName(attr)); tidyAttrValue(attr) ? printf("=\"%s\" ", tidyAttrValue(attr)) : printf(" "); diff --git a/docs/examples/htmltitle.cpp b/docs/examples/htmltitle.cpp index 97b924b1802d..a6f944ff0eb9 100644 --- a/docs/examples/htmltitle.cpp +++ b/docs/examples/htmltitle.cpp @@ -55,9 +55,8 @@ // libxml callback context structure // -struct Context -{ - Context(): addTitle(false) { } +struct Context { + Context() : addTitle(false) {} bool addTitle; std::string title; @@ -79,7 +78,7 @@ static size_t writer(char *data, size_t size, size_t nmemb, if(writerData == NULL) return 0; - writerData->append(data, size*nmemb); + writerData->append(data, size * nmemb); return size * nmemb; } diff --git a/docs/examples/http2-pushinmemory.c b/docs/examples/http2-pushinmemory.c index 14f37dbbbcd3..df896e1af5d1 100644 --- a/docs/examples/http2-pushinmemory.c +++ b/docs/examples/http2-pushinmemory.c @@ -115,7 +115,6 @@ static int server_push_callback(CURL *parent, return CURL_PUSH_OK; } - /* * Download a file over HTTP/2, take care of server push. */ diff --git a/docs/examples/httpput-postfields.c b/docs/examples/httpput-postfields.c index 29fd6273d7eb..4fd92aaffbef 100644 --- a/docs/examples/httpput-postfields.c +++ b/docs/examples/httpput-postfields.c @@ -30,7 +30,7 @@ #include -static const char olivertwist[]= +static const char olivertwist[] = "Among other public buildings in a certain town, which for many reasons " "it will be prudent to refrain from mentioning, and to which I will assign " "no fictitious name, there is one anciently common to most towns, great or " diff --git a/docs/examples/httpput.c b/docs/examples/httpput.c index 5c3fc314b801..026fde1210ea 100644 --- a/docs/examples/httpput.c +++ b/docs/examples/httpput.c @@ -77,7 +77,7 @@ int main(int argc, char **argv) { CURL *curl; CURLcode res; - FILE * hd_src; + FILE *hd_src; struct stat file_info; char *file; diff --git a/docs/examples/imap-append.c b/docs/examples/imap-append.c index 81ca682ffd26..91cbac69151a 100644 --- a/docs/examples/imap-append.c +++ b/docs/examples/imap-append.c @@ -64,7 +64,7 @@ static size_t read_cb(char *ptr, size_t size, size_t nmemb, void *userp) const char *data; size_t room = size * nmemb; - if((size == 0) || (nmemb == 0) || ((size*nmemb) < 1)) { + if((size == 0) || (nmemb == 0) || ((size * nmemb) < 1)) { return 0; } @@ -95,7 +95,7 @@ int main(void) if(curl) { size_t filesize; long infilesize = LONG_MAX; - struct upload_status upload_ctx = { 0 }; + struct upload_status upload_ctx = {0}; /* Set username and password */ curl_easy_setopt(curl, CURLOPT_USERNAME, "user"); diff --git a/docs/examples/imap-ssl.c b/docs/examples/imap-ssl.c index 259eddc26f6a..52448f492d16 100644 --- a/docs/examples/imap-ssl.c +++ b/docs/examples/imap-ssl.c @@ -51,7 +51,7 @@ int main(void) curl_easy_setopt(curl, CURLOPT_PASSWORD, "secret"); /* This fetches message 1 from the user's inbox. Note the use of - * imaps:// rather than imap:// to request an SSL based connection. */ + * imaps:// rather than imap:// to request an SSL based connection. */ curl_easy_setopt(curl, CURLOPT_URL, "imaps://imap.example.com/INBOX/;UID=1"); diff --git a/docs/examples/log_failed_transfers.c b/docs/examples/log_failed_transfers.c index a0d209ffc395..0c5c1a3b5494 100644 --- a/docs/examples/log_failed_transfers.c +++ b/docs/examples/log_failed_transfers.c @@ -236,7 +236,7 @@ int main(void) curl_global_trace("all"); #endif - for(i = 0; i < sizeof(transfer)/sizeof(transfer[0]); ++i) { + for(i = 0; i < sizeof(transfer) / sizeof(transfer[0]); ++i) { int failed = 0; struct transfer *t = &transfer[i]; diff --git a/docs/examples/multi-app.c b/docs/examples/multi-app.c index 460c93057ad5..d58181e027f4 100644 --- a/docs/examples/multi-app.c +++ b/docs/examples/multi-app.c @@ -66,7 +66,7 @@ int main(void) int still_running = 1; /* keep number of running handles */ - CURLMsg *msg; /* for picking up messages with the transfer status */ + CURLMsg *msg; /* for picking up messages with the transfer status */ int msgs_left; /* how many messages are left */ /* add the individual transfers */ diff --git a/docs/examples/multi-event.c b/docs/examples/multi-event.c index 2698e24678f9..901d7dd6e765 100644 --- a/docs/examples/multi-event.c +++ b/docs/examples/multi-event.c @@ -47,7 +47,7 @@ static struct curl_context *create_curl_context(curl_socket_t sockfd) { struct curl_context *context; - context = (struct curl_context *) malloc(sizeof(*context)); + context = (struct curl_context *)malloc(sizeof(*context)); context->sockfd = sockfd; @@ -134,10 +134,9 @@ static void curl_perform(int fd, short event, void *arg) if(event & EV_WRITE) flags |= CURL_CSELECT_OUT; - context = (struct curl_context *) arg; + context = (struct curl_context *)arg; - curl_multi_socket_action(multi, context->sockfd, flags, - &running_handles); + curl_multi_socket_action(multi, context->sockfd, flags, &running_handles); check_multi_info(); } @@ -148,8 +147,7 @@ static void on_timeout(evutil_socket_t fd, short events, void *arg) (void)fd; (void)events; (void)arg; - curl_multi_socket_action(multi, CURL_SOCKET_TIMEOUT, 0, - &running_handles); + curl_multi_socket_action(multi, CURL_SOCKET_TIMEOUT, 0, &running_handles); check_multi_info(); } @@ -186,9 +184,9 @@ static int handle_socket(CURL *curl, curl_socket_t s, int action, void *userp, case CURL_POLL_OUT: case CURL_POLL_INOUT: curl_context = socketp ? - (struct curl_context *) socketp : create_curl_context(s); + (struct curl_context *)socketp : create_curl_context(s); - curl_multi_assign(multi, s, (void *) curl_context); + curl_multi_assign(multi, s, (void *)curl_context); if(action != CURL_POLL_IN) events |= EV_WRITE; @@ -205,8 +203,8 @@ static int handle_socket(CURL *curl, curl_socket_t s, int action, void *userp, break; case CURL_POLL_REMOVE: if(socketp) { - event_del(((struct curl_context*) socketp)->event); - destroy_curl_context((struct curl_context*) socketp); + event_del(((struct curl_context *)socketp)->event); + destroy_curl_context((struct curl_context *)socketp); curl_multi_assign(multi, s, NULL); } break; diff --git a/docs/examples/multi-legacy.c b/docs/examples/multi-legacy.c index ca2c0a4c7afb..e34d1cd710a2 100644 --- a/docs/examples/multi-legacy.c +++ b/docs/examples/multi-legacy.c @@ -72,7 +72,7 @@ int main(void) int still_running = 0; /* keep number of running handles */ - CURLMsg *msg; /* for picking up messages with the transfer status */ + CURLMsg *msg; /* for picking up messages with the transfer status */ int msgs_left; /* how many messages are left */ /* add the individual transfers */ @@ -85,7 +85,7 @@ int main(void) while(still_running) { struct timeval timeout; - int rc; /* select() return code */ + int rc; /* select() return code */ CURLMcode mc; /* curl_multi_fdset() return code */ fd_set fdread; @@ -155,7 +155,7 @@ int main(void) case -1: /* select error */ break; - case 0: /* timeout */ + case 0: /* timeout */ default: /* action */ curl_multi_perform(multi, &still_running); break; diff --git a/docs/examples/multi-uv.c b/docs/examples/multi-uv.c index 1dac32048927..4053cb906112 100644 --- a/docs/examples/multi-uv.c +++ b/docs/examples/multi-uv.c @@ -60,7 +60,7 @@ static struct curl_context *create_curl_context(curl_socket_t sockfd, { struct curl_context *context; - context = (struct curl_context *) malloc(sizeof(*context)); + context = (struct curl_context *)malloc(sizeof(*context)); context->sockfd = sockfd; context->uv = uv; @@ -73,13 +73,13 @@ static struct curl_context *create_curl_context(curl_socket_t sockfd, static void curl_close_cb(uv_handle_t *handle) { - struct curl_context *context = (struct curl_context *) handle->data; + struct curl_context *context = (struct curl_context *)handle->data; free(context); } static void destroy_curl_context(struct curl_context *context) { - uv_close((uv_handle_t *) &context->poll_handle, curl_close_cb); + uv_close((uv_handle_t *)&context->poll_handle, curl_close_cb); } static void add_download(const char *url, int num, CURLM *multi) @@ -145,7 +145,7 @@ static void on_uv_socket(uv_poll_t *req, int status, int events) { int running_handles; int flags = 0; - struct curl_context *context = (struct curl_context *) req->data; + struct curl_context *context = (struct curl_context *)req->data; (void)status; if(events & UV_READABLE) flags |= CURL_CSELECT_IN; @@ -202,9 +202,9 @@ static int cb_socket(CURL *curl, curl_socket_t s, int action, case CURL_POLL_OUT: case CURL_POLL_INOUT: curl_context = socketp ? - (struct curl_context *) socketp : create_curl_context(s, uv); + (struct curl_context *)socketp : create_curl_context(s, uv); - curl_multi_assign(uv->multi, s, (void *) curl_context); + curl_multi_assign(uv->multi, s, (void *)curl_context); if(action != CURL_POLL_IN) events |= UV_WRITABLE; @@ -215,8 +215,8 @@ static int cb_socket(CURL *curl, curl_socket_t s, int action, break; case CURL_POLL_REMOVE: if(socketp) { - uv_poll_stop(&((struct curl_context*)socketp)->poll_handle); - destroy_curl_context((struct curl_context*) socketp); + uv_poll_stop(&((struct curl_context *)socketp)->poll_handle); + destroy_curl_context((struct curl_context *)socketp); curl_multi_assign(uv->multi, s, NULL); } break; @@ -230,7 +230,7 @@ static int cb_socket(CURL *curl, curl_socket_t s, int action, int main(int argc, char **argv) { CURLcode res; - struct datauv uv = { 0 }; + struct datauv uv = {0}; int running_handles; if(argc <= 1) diff --git a/docs/examples/multithread.c b/docs/examples/multithread.c index 7de1baea9085..308c1168e284 100644 --- a/docs/examples/multithread.c +++ b/docs/examples/multithread.c @@ -56,7 +56,6 @@ struct targ { const char *url; }; - static void *pull_one_url(void *p) { CURL *curl; @@ -72,7 +71,6 @@ static void *pull_one_url(void *p) return NULL; } - /* int pthread_create(pthread_t *new_thread_ID, const pthread_attr_t *attr, diff --git a/docs/examples/netrc.c b/docs/examples/netrc.c index 91f8df96dc31..a9eaebff88ee 100644 --- a/docs/examples/netrc.c +++ b/docs/examples/netrc.c @@ -40,8 +40,7 @@ int main(void) curl = curl_easy_init(); if(curl) { curl_easy_setopt(curl, CURLOPT_NETRC, CURL_NETRC_OPTIONAL); - curl_easy_setopt(curl, CURLOPT_NETRC_FILE, - "/home/daniel/s3cr3ts.txt"); + curl_easy_setopt(curl, CURLOPT_NETRC_FILE, "/home/daniel/s3cr3ts.txt"); curl_easy_setopt(curl, CURLOPT_URL, "https://curl.se/"); res = curl_easy_perform(curl); diff --git a/docs/examples/post-callback.c b/docs/examples/post-callback.c index bbab00279091..c463e3785ceb 100644 --- a/docs/examples/post-callback.c +++ b/docs/examples/post-callback.c @@ -47,7 +47,7 @@ struct WriteThis { static size_t read_cb(char *dest, size_t size, size_t nmemb, void *userp) { struct WriteThis *wt = (struct WriteThis *)userp; - size_t buffer_size = size*nmemb; + size_t buffer_size = size * nmemb; if(wt->sizeleft) { /* copy as much as possible from the source to the destination */ diff --git a/docs/examples/postinmemory.c b/docs/examples/postinmemory.c index fc42251ddd12..089d9a9c743c 100644 --- a/docs/examples/postinmemory.c +++ b/docs/examples/postinmemory.c @@ -36,8 +36,7 @@ struct MemoryStruct { size_t size; }; -static size_t write_cb(void *contents, size_t size, size_t nmemb, - void *userp) +static size_t write_cb(void *contents, size_t size, size_t nmemb, void *userp) { size_t realsize = size * nmemb; struct MemoryStruct *mem = (struct MemoryStruct *)userp; @@ -104,7 +103,7 @@ int main(void) * * Do something nice with it! */ - printf("%s\n",chunk.memory); + printf("%s\n", chunk.memory); } /* always cleanup */ diff --git a/docs/examples/sftpget.c b/docs/examples/sftpget.c index 287d5b253efb..470474cafd6c 100644 --- a/docs/examples/sftpget.c +++ b/docs/examples/sftpget.c @@ -50,8 +50,7 @@ struct FtpFile { FILE *stream; }; -static size_t write_cb(void *buffer, size_t size, size_t nmemb, - void *stream) +static size_t write_cb(void *buffer, size_t size, size_t nmemb, void *stream) { struct FtpFile *out = (struct FtpFile *)stream; if(!out->stream) { @@ -63,7 +62,6 @@ static size_t write_cb(void *buffer, size_t size, size_t nmemb, return fwrite(buffer, size, nmemb, out->stream); } - int main(void) { CURL *curl; diff --git a/docs/examples/sftpuploadresume.c b/docs/examples/sftpuploadresume.c index 84bb42554939..9b78f96ee4ab 100644 --- a/docs/examples/sftpuploadresume.c +++ b/docs/examples/sftpuploadresume.c @@ -83,7 +83,6 @@ static curl_off_t sftpGetRemoteFileSize(const char *i_remoteFile) return remoteFileSizeByte; } - static int sftpResumeUpload(CURL *curl, const char *remotepath, const char *localpath) { diff --git a/docs/examples/shared-connection-cache.c b/docs/examples/shared-connection-cache.c index bc1239428ba4..acaa610dec11 100644 --- a/docs/examples/shared-connection-cache.c +++ b/docs/examples/shared-connection-cache.c @@ -29,8 +29,8 @@ #include -static void my_lock(CURL *curl, curl_lock_data data, - curl_lock_access laccess, void *useptr) +static void my_lock(CURL *curl, curl_lock_data data, curl_lock_access laccess, + void *useptr) { (void)curl; (void)data; diff --git a/docs/examples/simplessl.c b/docs/examples/simplessl.c index a41a9ac29e6a..3cf4b462bd50 100644 --- a/docs/examples/simplessl.c +++ b/docs/examples/simplessl.c @@ -68,11 +68,11 @@ int main(void) const char *pKeyType; #ifdef USE_ENGINE - pKeyName = "rsa_test"; - pKeyType = "ENG"; + pKeyName = "rsa_test"; + pKeyType = "ENG"; #else - pKeyName = "testkey.pem"; - pKeyType = "PEM"; + pKeyName = "testkey.pem"; + pKeyType = "PEM"; #endif res = curl_global_init(CURL_GLOBAL_ALL); diff --git a/docs/examples/smooth-gtk-thread.c b/docs/examples/smooth-gtk-thread.c index 2a3cdbc0ef3c..6bf8946721aa 100644 --- a/docs/examples/smooth-gtk-thread.c +++ b/docs/examples/smooth-gtk-thread.c @@ -108,11 +108,10 @@ static void *pull_one_url(void *NaN) return NULL; } - static gboolean pulse_bar(gpointer data) { gdk_threads_enter(); - gtk_progress_bar_pulse(GTK_PROGRESS_BAR (data)); + gtk_progress_bar_pulse(GTK_PROGRESS_BAR(data)); gdk_threads_leave(); /* Return true so the function is called again; returning false removes this @@ -127,7 +126,7 @@ static void *create_thread(void *progress_bar) int i; /* Make sure I do not create more threads than urls. */ - for(i = 0; i < NUMT && i < num_urls ; i++) { + for(i = 0; i < NUMT && i < num_urls; i++) { int error = pthread_create(&tid[i], NULL, /* default attributes please */ pull_one_url, @@ -196,7 +195,7 @@ int main(int argc, char **argv) /* Progress bar */ progress_bar = gtk_progress_bar_new(); - gtk_progress_bar_pulse(GTK_PROGRESS_BAR (progress_bar)); + gtk_progress_bar_pulse(GTK_PROGRESS_BAR(progress_bar)); /* Make uniform pulsing */ gint pulse_ref = g_timeout_add(300, pulse_bar, progress_bar); g_object_set_data(G_OBJECT(progress_bar), "pulse_id", @@ -206,7 +205,7 @@ int main(int argc, char **argv) gtk_widget_show_all(top_window); printf("gtk_widget_show_all\n"); - g_signal_connect(G_OBJECT (top_window), "delete-event", + g_signal_connect(G_OBJECT(top_window), "delete-event", G_CALLBACK(cb_delete), NULL); if(!g_thread_create(&create_thread, progress_bar, FALSE, NULL) != 0) diff --git a/docs/examples/smtp-authzid.c b/docs/examples/smtp-authzid.c index a375d839b131..e7dd20f59093 100644 --- a/docs/examples/smtp-authzid.c +++ b/docs/examples/smtp-authzid.c @@ -73,7 +73,7 @@ static size_t read_cb(char *ptr, size_t size, size_t nmemb, void *userp) size_t room = size * nmemb; size_t len; - if((size == 0) || (nmemb == 0) || ((size*nmemb) < 1)) { + if((size == 0) || (nmemb == 0) || ((size * nmemb) < 1)) { return 0; } @@ -99,7 +99,7 @@ int main(void) curl = curl_easy_init(); if(curl) { struct curl_slist *recipients = NULL; - struct upload_status upload_ctx = { 0 }; + struct upload_status upload_ctx = {0}; /* This is the URL for your mailserver. In this example we connect to the smtp-submission port as we require an authenticated connection. */ diff --git a/docs/examples/smtp-mail.c b/docs/examples/smtp-mail.c index e6e77b97a39d..d5074abbf2f5 100644 --- a/docs/examples/smtp-mail.c +++ b/docs/examples/smtp-mail.c @@ -70,7 +70,7 @@ static size_t read_cb(char *ptr, size_t size, size_t nmemb, void *userp) size_t room = size * nmemb; size_t len; - if((size == 0) || (nmemb == 0) || ((size*nmemb) < 1)) { + if((size == 0) || (nmemb == 0) || ((size * nmemb) < 1)) { return 0; } @@ -96,7 +96,7 @@ int main(void) curl = curl_easy_init(); if(curl) { struct curl_slist *recipients = NULL; - struct upload_status upload_ctx = { 0 }; + struct upload_status upload_ctx = {0}; /* This is the URL for your mailserver */ curl_easy_setopt(curl, CURLOPT_URL, "smtp://mail.example.com"); diff --git a/docs/examples/smtp-multi.c b/docs/examples/smtp-multi.c index ab7165cd5277..8cb5e65a26b9 100644 --- a/docs/examples/smtp-multi.c +++ b/docs/examples/smtp-multi.c @@ -63,7 +63,7 @@ static size_t read_cb(char *ptr, size_t size, size_t nmemb, void *userp) size_t room = size * nmemb; size_t len; - if((size == 0) || (nmemb == 0) || ((size*nmemb) < 1)) { + if((size == 0) || (nmemb == 0) || ((size * nmemb) < 1)) { return 0; } @@ -94,7 +94,7 @@ int main(void) if(multi) { int still_running = 1; struct curl_slist *recipients = NULL; - struct upload_status upload_ctx = { 0 }; + struct upload_status upload_ctx = {0}; /* This is the URL for your mailserver */ curl_easy_setopt(curl, CURLOPT_URL, "smtp://mail.example.com"); diff --git a/docs/examples/smtp-ssl.c b/docs/examples/smtp-ssl.c index 4ebc58f1b5dd..3b140c904c5c 100644 --- a/docs/examples/smtp-ssl.c +++ b/docs/examples/smtp-ssl.c @@ -67,7 +67,7 @@ static size_t read_cb(char *ptr, size_t size, size_t nmemb, void *userp) size_t room = size * nmemb; size_t len; - if((size == 0) || (nmemb == 0) || ((size*nmemb) < 1)) { + if((size == 0) || (nmemb == 0) || ((size * nmemb) < 1)) { return 0; } @@ -93,7 +93,7 @@ int main(void) curl = curl_easy_init(); if(curl) { struct curl_slist *recipients = NULL; - struct upload_status upload_ctx = { 0 }; + struct upload_status upload_ctx = {0}; /* Set username and password */ curl_easy_setopt(curl, CURLOPT_USERNAME, "user"); diff --git a/docs/examples/smtp-tls.c b/docs/examples/smtp-tls.c index f6b3bb6053c4..3bf3b0cddf11 100644 --- a/docs/examples/smtp-tls.c +++ b/docs/examples/smtp-tls.c @@ -67,7 +67,7 @@ static size_t read_cb(char *ptr, size_t size, size_t nmemb, void *userp) size_t room = size * nmemb; size_t len; - if((size == 0) || (nmemb == 0) || ((size*nmemb) < 1)) { + if((size == 0) || (nmemb == 0) || ((size * nmemb) < 1)) { return 0; } @@ -93,7 +93,7 @@ int main(void) curl = curl_easy_init(); if(curl) { struct curl_slist *recipients = NULL; - struct upload_status upload_ctx = { 0 }; + struct upload_status upload_ctx = {0}; /* Set username and password */ curl_easy_setopt(curl, CURLOPT_USERNAME, "user"); diff --git a/docs/examples/sslbackend.c b/docs/examples/sslbackend.c index fd2b57534e65..5615bec72dc6 100644 --- a/docs/examples/sslbackend.c +++ b/docs/examples/sslbackend.c @@ -38,7 +38,7 @@ * SSL backend has to be configured). * * **** This example only works with libcurl 7.56.0 and later! **** -*/ + */ int main(int argc, char **argv) { diff --git a/docs/examples/synctime.c b/docs/examples/synctime.c index a9a746c30a20..b2a3b926072d 100644 --- a/docs/examples/synctime.c +++ b/docs/examples/synctime.c @@ -66,7 +66,11 @@ #include #ifndef _WIN32 -int main(void) { printf("Platform not supported.\n"); return 1; } +int main(void) +{ + printf("Platform not supported.\n"); + return 1; +} #else #if (defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0602)) || \ @@ -79,7 +83,11 @@ int main(void) { printf("Platform not supported.\n"); return 1; } #endif #ifdef CURL_WINDOWS_UWP -int main(void) { printf("Platform not supported.\n"); return 1; } +int main(void) +{ + printf("Platform not supported.\n"); + return 1; +} #else #include @@ -123,8 +131,7 @@ static SYSTEMTIME LOCALTime; #define HTTP_COMMAND_HEAD 0 #define HTTP_COMMAND_GET 1 -static size_t write_cb(void *ptr, size_t size, size_t nmemb, - void *stream) +static size_t write_cb(void *ptr, size_t size, size_t nmemb, void *stream) { fwrite(ptr, size, nmemb, stream); return nmemb * size; @@ -280,7 +287,7 @@ int main(int argc, char *argv[]) snprintf(conf->http_proxy, MAX_STRING, "%s", &argv[OptionIndex][8]); if((strcmp(argv[OptionIndex], "--help") == 0) || - (strcmp(argv[OptionIndex], "/?") == 0)) { + (strcmp(argv[OptionIndex], "/?") == 0)) { showUsage(); return 0; } @@ -317,9 +324,9 @@ int main(int argc, char *argv[]) gmt = gmtime(&tt); tt_gmt = mktime(gmt); tzonediffFloat = difftime(tt_local, tt_gmt); - tzonediffWord = (int)(tzonediffFloat/3600.0); + tzonediffWord = (int)(tzonediffFloat / 3600.0); - if(tzonediffWord == (int)(tzonediffFloat/3600.0)) + if(tzonediffWord == (int)(tzonediffFloat / 3600.0)) snprintf(tzoneBuf, sizeof(tzoneBuf), "%+03d'00'", tzonediffWord); else snprintf(tzoneBuf, sizeof(tzoneBuf), "%+03d'30'", tzonediffWord); @@ -329,9 +336,8 @@ int main(int argc, char *argv[]) GetLocalTime(&LOCALTime); snprintf(timeBuf, 60, "%s, %02d %s %04d %02d:%02d:%02d.%03d, ", DayStr[LOCALTime.wDayOfWeek], LOCALTime.wDay, - MthStr[LOCALTime.wMonth-1], LOCALTime.wYear, - LOCALTime.wHour, LOCALTime.wMinute, LOCALTime.wSecond, - LOCALTime.wMilliseconds); + MthStr[LOCALTime.wMonth - 1], LOCALTime.wYear, LOCALTime.wHour, + LOCALTime.wMinute, LOCALTime.wSecond, LOCALTime.wMilliseconds); fprintf(stderr, "Fetch: %s\n\n", conf->timeserver); fprintf(stderr, "Before HTTP. Date: %s%s\n\n", timeBuf, tzoneBuf); @@ -343,9 +349,8 @@ int main(int argc, char *argv[]) GetLocalTime(&LOCALTime); snprintf(timeBuf, 60, "%s, %02d %s %04d %02d:%02d:%02d.%03d, ", DayStr[LOCALTime.wDayOfWeek], LOCALTime.wDay, - MthStr[LOCALTime.wMonth-1], LOCALTime.wYear, - LOCALTime.wHour, LOCALTime.wMinute, LOCALTime.wSecond, - LOCALTime.wMilliseconds); + MthStr[LOCALTime.wMonth - 1], LOCALTime.wYear, LOCALTime.wHour, + LOCALTime.wMinute, LOCALTime.wSecond, LOCALTime.wMilliseconds); fprintf(stderr, "\nAfter HTTP. Date: %s%s\n", timeBuf, tzoneBuf); if(AutoSyncTime == 3) { @@ -359,7 +364,7 @@ int main(int argc, char *argv[]) GetLocalTime(&LOCALTime); snprintf(timeBuf, 60, "%s, %02d %s %04d %02d:%02d:%02d.%03d, ", DayStr[LOCALTime.wDayOfWeek], LOCALTime.wDay, - MthStr[LOCALTime.wMonth-1], LOCALTime.wYear, + MthStr[LOCALTime.wMonth - 1], LOCALTime.wYear, LOCALTime.wHour, LOCALTime.wMinute, LOCALTime.wSecond, LOCALTime.wMilliseconds); fprintf(stderr, "\nNew System's Date: %s%s\n", timeBuf, tzoneBuf); diff --git a/docs/examples/threaded-ssl.c b/docs/examples/threaded-ssl.c index 8119113695ea..8d5d1234fcb2 100644 --- a/docs/examples/threaded-ssl.c +++ b/docs/examples/threaded-ssl.c @@ -46,7 +46,7 @@ #define NUMT 4 /* List of URLs to fetch.*/ -static const char * const urls[]= { +static const char * const urls[] = { "https://www.example.com/", "https://www2.example.com/", "https://www3.example.com/", diff --git a/docs/examples/usercertinmem.c b/docs/examples/usercertinmem.c index 175dae11514f..44a0a15bc7b1 100644 --- a/docs/examples/usercertinmem.c +++ b/docs/examples/usercertinmem.c @@ -114,7 +114,7 @@ static CURLcode sslctx_function(CURL *curl, void *sslctx, void *pointer) } /* tell SSL to use the X509 certificate */ - ret = SSL_CTX_use_certificate((SSL_CTX*)sslctx, cert); + ret = SSL_CTX_use_certificate((SSL_CTX *)sslctx, cert); if(ret != 1) { printf("Use certificate failed\n"); } @@ -132,7 +132,7 @@ static CURLcode sslctx_function(CURL *curl, void *sslctx, void *pointer) } /* tell SSL to use the RSA key from memory */ - ret = SSL_CTX_use_RSAPrivateKey((SSL_CTX*)sslctx, rsa); + ret = SSL_CTX_use_RSAPrivateKey((SSL_CTX *)sslctx, rsa); if(ret != 1) { printf("Use Key failed\n"); } diff --git a/docs/examples/xmlstream.c b/docs/examples/xmlstream.c index 0aec24cc67a7..5b35d048619a 100644 --- a/docs/examples/xmlstream.c +++ b/docs/examples/xmlstream.c @@ -55,7 +55,7 @@ struct ParserStruct { static void startElement(void *userData, const XML_Char *name, const XML_Char **atts) { - struct ParserStruct *state = (struct ParserStruct *) userData; + struct ParserStruct *state = (struct ParserStruct *)userData; state->tags++; state->depth++; @@ -70,7 +70,7 @@ static void startElement(void *userData, const XML_Char *name, static void characterDataHandler(void *userData, const XML_Char *s, int len) { - struct ParserStruct *state = (struct ParserStruct *) userData; + struct ParserStruct *state = (struct ParserStruct *)userData; struct MemoryStruct *mem = &state->characters; char *ptr = realloc(mem->memory, mem->size + (unsigned long)len + 1); @@ -89,7 +89,7 @@ static void characterDataHandler(void *userData, const XML_Char *s, int len) static void endElement(void *userData, const XML_Char *name) { - struct ParserStruct *state = (struct ParserStruct *) userData; + struct ParserStruct *state = (struct ParserStruct *)userData; state->depth--; printf("%5lu %10lu %s\n", state->depth, state->characters.size, name); @@ -98,9 +98,9 @@ static void endElement(void *userData, const XML_Char *name) static size_t write_cb(void *contents, size_t length, size_t nmemb, void *userp) { - XML_Parser parser = (XML_Parser) userp; + XML_Parser parser = (XML_Parser)userp; size_t real_size = length * nmemb; - struct ParserStruct *state = (struct ParserStruct *) XML_GetUserData(parser); + struct ParserStruct *state = (struct ParserStruct *)XML_GetUserData(parser); /* Only parse if we are not already in a failure state. */ if(state->ok && XML_Parse(parser, contents, (int)real_size, 0) == 0) { From e25a3c6734458328412c55d236d3a2370593585c Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Fri, 28 Nov 2025 15:16:08 +0100 Subject: [PATCH 108/415] GHA/curl-for-win: drop WINE install, do not run curl after build To reduce to amount of Debian packages to install, which hopefully removes some flakiness due to sometimes very slow Azure package distro servers. Possible also making these jobs finish 20s faster. Windows from Debian | llvm | gcc :------------------ | :----------------: | :----------------: build time | 2m41s -> 2m20s | 3m19s -> 2m57s installed packages | 288 -> 142 | 247 -> 99 downloads | 403 MB -> 240 MB | 297 MB -> 134 MB disk space | 2132 MB -> 1289 MB | 1582 MB -> 739 MB Before: https://github.com/curl/curl/actions/runs/19765983026 After: https://github.com/curl/curl/actions/runs/19766373960?pr=19749 Ref: https://github.com/curl/curl-for-win/commit/02149b7e364a1830d8fa2c947cfc713d925c186d Closes #19749 --- .github/workflows/curl-for-win.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/curl-for-win.yml b/.github/workflows/curl-for-win.yml index f0214b2874cb..f352529f723e 100644 --- a/.github/workflows/curl-for-win.yml +++ b/.github/workflows/curl-for-win.yml @@ -159,7 +159,7 @@ jobs: run: | git clone --depth 1 https://github.com/curl/curl-for-win mv curl-for-win/* . - export CW_CONFIG='-main-werror-unitybatch-win-x64' + export CW_CONFIG='-main-werror-unitybatch-win-x64-noWINE' export CW_REVISION="${GITHUB_SHA}" . ./_versions.sh sudo podman image trust set --type reject default @@ -186,7 +186,7 @@ jobs: run: | git clone --depth 1 https://github.com/curl/curl-for-win mv curl-for-win/* . - export CW_CONFIG='-main-werror-unitybatch-win-x64-gcc-zlibold' + export CW_CONFIG='-main-werror-unitybatch-win-x64-gcc-zlibold-noWINE' export CW_REVISION="${GITHUB_SHA}" . ./_versions.sh sudo podman image trust set --type reject default From 12a3182fc39cb948792e9cc189887cd85b587bb0 Mon Sep 17 00:00:00 2001 From: Stefan Eissing Date: Fri, 28 Nov 2025 12:49:16 +0100 Subject: [PATCH 109/415] ssh: tracing and better pollset handling Remove connection member `waitfor` and keep it in the SSH connection meta. Add `ssh` to supported tracing features, convert many DEBUGF printgs to traces. Closes #19745 --- docs/libcurl/curl_global_trace.md | 4 + lib/curl_trc.c | 28 +++++++ lib/curl_trc.h | 13 ++++ lib/urldata.h | 1 - lib/vssh/libssh.c | 124 ++++++++++++++++-------------- lib/vssh/libssh2.c | 112 +++++++++++++++------------ lib/vssh/ssh.h | 3 +- 7 files changed, 178 insertions(+), 107 deletions(-) diff --git a/docs/libcurl/curl_global_trace.md b/docs/libcurl/curl_global_trace.md index 0459eab6747d..10ec21b4bd43 100644 --- a/docs/libcurl/curl_global_trace.md +++ b/docs/libcurl/curl_global_trace.md @@ -130,6 +130,10 @@ states. Traces reading of upload data from the application in order to send it to the server. +## `ssh` + +Tracing of SSH related protocols SCP and SFTP. + ## `ssls` Tracing of SSL Session handling, e.g. caching/import/export. diff --git a/lib/curl_trc.c b/lib/curl_trc.c index cc06c77e9d9a..42711ed01c05 100644 --- a/lib/curl_trc.c +++ b/lib/curl_trc.c @@ -453,6 +453,24 @@ void Curl_trc_ssls(struct Curl_easy *data, const char *fmt, ...) } #endif /* USE_SSL */ +#ifdef USE_SSH +struct curl_trc_feat Curl_trc_feat_ssh = { + "SSH", + CURL_LOG_LVL_NONE, +}; + +void Curl_trc_ssh(struct Curl_easy *data, const char *fmt, ...) +{ + DEBUGASSERT(!strchr(fmt, '\n')); + if(Curl_trc_ft_is_verbose(data, &Curl_trc_feat_ssh)) { + va_list ap; + va_start(ap, fmt); + trc_infof(data, &Curl_trc_feat_ssh, NULL, 0, fmt, ap); + va_end(ap); + } +} +#endif /* USE_SSH */ + #if !defined(CURL_DISABLE_WEBSOCKETS) && !defined(CURL_DISABLE_HTTP) struct curl_trc_feat Curl_trc_feat_ws = { "WS", @@ -500,6 +518,9 @@ static struct trc_feat_def trc_feats[] = { #ifdef USE_SSL { &Curl_trc_feat_ssls, TRC_CT_NETWORK }, #endif +#ifdef USE_SSH + { &Curl_trc_feat_ssh, TRC_CT_PROTOCOL }, +#endif #if !defined(CURL_DISABLE_WEBSOCKETS) && !defined(CURL_DISABLE_HTTP) { &Curl_trc_feat_ws, TRC_CT_PROTOCOL }, #endif @@ -696,6 +717,13 @@ void Curl_trc_ws(struct Curl_easy *data, const char *fmt, ...) (void)data; (void)fmt; } #endif +#ifdef USE_SSH +void Curl_trc_ssh(struct Curl_easy *data, const char *fmt, ...) +{ + (void)data; + (void)fmt; +} +#endif #ifdef USE_SSL void Curl_trc_ssls(struct Curl_easy *data, const char *fmt, ...) { diff --git a/lib/curl_trc.h b/lib/curl_trc.h index 1a3f8f374e2d..0ce76ed7effa 100644 --- a/lib/curl_trc.h +++ b/lib/curl_trc.h @@ -117,6 +117,11 @@ extern struct curl_trc_feat Curl_trc_feat_ssls; void Curl_trc_ssls(struct Curl_easy *data, const char *fmt, ...) CURL_PRINTF(2, 3); #endif +#ifdef USE_SSH +extern struct curl_trc_feat Curl_trc_feat_ssh; +void Curl_trc_ssh(struct Curl_easy *data, + const char *fmt, ...) CURL_PRINTF(2, 3); +#endif #if !defined(CURL_DISABLE_WEBSOCKETS) && !defined(CURL_DISABLE_HTTP) extern struct curl_trc_feat Curl_trc_feat_ws; void Curl_trc_ws(struct Curl_easy *data, @@ -168,6 +173,11 @@ void Curl_trc_ws(struct Curl_easy *data, do { if(Curl_trc_ft_is_verbose(data, &Curl_trc_feat_ssls)) \ Curl_trc_ssls(data, __VA_ARGS__); } while(0) #endif /* USE_SSL */ +#ifdef USE_SSH +#define CURL_TRC_SSH(data, ...) \ + do { if(Curl_trc_ft_is_verbose(data, &Curl_trc_feat_ssh)) \ + Curl_trc_ssh(data, __VA_ARGS__); } while(0) +#endif /* USE_SSH */ #if !defined(CURL_DISABLE_WEBSOCKETS) && !defined(CURL_DISABLE_HTTP) #define CURL_TRC_WS(data, ...) \ do { if(Curl_trc_ft_is_verbose(data, &Curl_trc_feat_ws)) \ @@ -193,6 +203,9 @@ void Curl_trc_ws(struct Curl_easy *data, #ifdef USE_SSL #define CURL_TRC_SSLS Curl_trc_ssls #endif +#ifdef USE_SSH +#define CURL_TRC_SSH Curl_trc_ssh +#endif #if !defined(CURL_DISABLE_WEBSOCKETS) && !defined(CURL_DISABLE_HTTP) #define CURL_TRC_WS Curl_trc_ws #endif diff --git a/lib/urldata.h b/lib/urldata.h index debc2a3e0aa0..2d28718181a9 100644 --- a/lib/urldata.h +++ b/lib/urldata.h @@ -713,7 +713,6 @@ struct connectdata { wrong connections. */ char *localdev; unsigned short localportrange; - int waitfor; /* current READ/WRITE bits to wait for */ #if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI) int socks5_gssapi_enctype; #endif diff --git a/lib/vssh/libssh.c b/lib/vssh/libssh.c index a5997a6f6cf9..2b605e4a6184 100644 --- a/lib/vssh/libssh.c +++ b/lib/vssh/libssh.c @@ -210,26 +210,9 @@ static CURLcode sftp_error_to_CURLE(int err) return CURLE_SSH; } -#if defined(DEBUGBUILD) && !defined(CURL_DISABLE_VERBOSE_STRINGS) -#define myssh_to(x,y,z) myssh_set_state(x,y,z, __LINE__) -#else -#define myssh_to(x,y,z) myssh_set_state(x,y,z) -#endif - -/* - * SSH State machine related code - */ -/* This is the ONLY way to change SSH state! */ -static void myssh_set_state(struct Curl_easy *data, - struct ssh_conn *sshc, - sshstate nowstate -#if defined(DEBUGBUILD) && !defined(CURL_DISABLE_VERBOSE_STRINGS) - , int lineno -#endif - ) +#if !defined(CURL_DISABLE_VERBOSE_STRINGS) +static const char *myssh_statename(sshstate state) { -#if defined(DEBUGBUILD) && !defined(CURL_DISABLE_VERBOSE_STRINGS) - /* for debug purposes */ static const char *const names[] = { "SSH_STOP", "SSH_INIT", @@ -292,14 +275,34 @@ static void myssh_set_state(struct Curl_easy *data, "SSH_SESSION_FREE", "QUIT" }; + /* a precaution to make sure the lists are in sync */ + DEBUGASSERT(CURL_ARRAYSIZE(names) == SSH_LAST); + return ((size_t)state < CURL_ARRAYSIZE(names)) ? names[state] : ""; +} +#else +#define myssh_statename(x) "" +#endif /* !CURL_DISABLE_VERBOSE_STRINGS */ + +#define myssh_to(x,y,z) myssh_set_state(x,y,z) + +/* + * SSH State machine related code + */ +/* This is the ONLY way to change SSH state! */ +static void myssh_set_state(struct Curl_easy *data, + struct ssh_conn *sshc, + sshstate nowstate) +{ +#if !defined(CURL_DISABLE_VERBOSE_STRINGS) if(sshc->state != nowstate) { - infof(data, "SSH %p state change from %s to %s (line %d)", - (void *) sshc, names[sshc->state], names[nowstate], - lineno); + CURL_TRC_SSH(data, "[%s] -> [%s]", + myssh_statename(sshc->state), + myssh_statename(nowstate)); } -#endif +#else (void)data; +#endif sshc->state = nowstate; } @@ -887,7 +890,7 @@ static int myssh_in_S_STARTUP(struct Curl_easy *data, myssh_block2waitfor(conn, sshc, (rc == SSH_AGAIN)); if(rc == SSH_AGAIN) { - DEBUGF(infof(data, "ssh_connect -> EAGAIN")); + CURL_TRC_SSH(data, "connect -> EAGAIN"); } else if(rc != SSH_OK) { failf(data, "Failure establishing ssh session"); @@ -1259,10 +1262,6 @@ static int myssh_in_UPLOAD_INIT(struct Curl_easy *data, /* not set by Curl_xfer_setup to preserve keepon bits */ data->conn->recv_idx = FIRSTSOCKET; - /* store this original bitmask setup to use later on if we cannot - figure out a "real" bitmask */ - sshc->orig_waitfor = data->req.keepon; - /* since we do not really wait for anything at this point, we want the state machine to move on as soon as possible so we mark this as dirty */ Curl_multi_mark_dirty(data); @@ -1401,7 +1400,7 @@ static int myssh_in_SFTP_CLOSE(struct Curl_easy *data, } Curl_safefree(sshp->path); - DEBUGF(infof(data, "SFTP DONE done")); + CURL_TRC_SSH(data, "SFTP DONE done"); /* Check if nextstate is set and move .nextstate could be POSTQUOTE_INIT After nextstate is executed, the control should come back to @@ -1485,7 +1484,7 @@ static int myssh_in_SFTP_REALPATH(struct Curl_easy *data, we get the homedir here, we get the "workingpath" in the DO action since the homedir will remain the same between request but the working path will not. */ - DEBUGF(infof(data, "SSH CONNECT phase done")); + CURL_TRC_SSH(data, "CONNECT phase done"); myssh_to(data, sshc, SSH_STOP); return SSH_NO_ERROR; } @@ -2285,10 +2284,6 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, /* not set by Curl_xfer_setup to preserve keepon bits */ data->conn->recv_idx = FIRSTSOCKET; - /* store this original bitmask setup to use later on if we cannot - figure out a "real" bitmask */ - sshc->orig_waitfor = data->req.keepon; - myssh_to(data, sshc, SSH_STOP); break; @@ -2357,7 +2352,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, ssh_scp_free(sshc->scp_session); sshc->scp_session = NULL; } - DEBUGF(infof(data, "SCP DONE phase complete")); + CURL_TRC_SSH(data, "SCP DONE phase complete"); ssh_set_blocking(sshc->ssh_session, 0); @@ -2422,7 +2417,8 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, } if(!result && (sshc->state == SSH_STOP)) result = sshc->actualcode; - DEBUGF(infof(data, "SSH: myssh_statemach_act -> %d", result)); + CURL_TRC_SSH(data, "[%s] statemachine() -> %d, block=%d", + myssh_statename(sshc->state), result, *block); return result; } @@ -2432,33 +2428,45 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, static CURLcode myssh_pollset(struct Curl_easy *data, struct easy_pollset *ps) { - int flags = 0; struct connectdata *conn = data->conn; - if(conn->waitfor & KEEP_RECV) - flags |= CURL_POLL_IN; - if(conn->waitfor & KEEP_SEND) - flags |= CURL_POLL_OUT; - if(!conn->waitfor) - flags |= CURL_POLL_OUT; - return flags ? - Curl_pollset_change(data, ps, conn->sock[FIRSTSOCKET], flags, 0) : - CURLE_OK; + struct ssh_conn *sshc = Curl_conn_meta_get(conn, CURL_META_SSH_CONN); + curl_socket_t sock = conn->sock[FIRSTSOCKET]; + int waitfor; + + if(!sshc || (sock == CURL_SOCKET_BAD)) + return CURLE_FAILED_INIT; + + waitfor = sshc->waitfor ? sshc->waitfor : data->req.keepon; + if(waitfor) { + int flags = 0; + if(waitfor & KEEP_RECV) + flags |= CURL_POLL_IN; + if(waitfor & KEEP_SEND) + flags |= CURL_POLL_OUT; + DEBUGASSERT(flags); + CURL_TRC_SSH(data, "pollset, flags=%x", flags); + return Curl_pollset_change(data, ps, sock, flags, 0); + } + /* While we still have a session, we listen incoming data. */ + if(sshc->ssh_session) + return Curl_pollset_change(data, ps, sock, CURL_POLL_IN, 0); + return CURLE_OK; } static void myssh_block2waitfor(struct connectdata *conn, struct ssh_conn *sshc, bool block) { + (void)conn; if(block) { int dir = ssh_get_poll_flags(sshc->ssh_session); /* translate the libssh define bits into our own bit defines */ - conn->waitfor = + sshc->waitfor = ((dir & SSH_READ_PENDING) ? KEEP_RECV : 0) | ((dir & SSH_WRITE_PENDING) ? KEEP_SEND : 0); } else - /* if it did not block, use the original set */ - conn->waitfor = sshc->orig_waitfor; + sshc->waitfor = 0; } /* called repeatedly until done from multi.c */ @@ -2584,6 +2592,7 @@ static CURLcode myssh_connect(struct Curl_easy *data, bool *done) if(!sshc || !ssh) return CURLE_FAILED_INIT; + CURL_TRC_SSH(data, "myssh_connect"); if(conn->handler->protocol & CURLPROTO_SCP) { conn->recv[FIRSTSOCKET] = scp_recv; conn->send[FIRSTSOCKET] = scp_send; @@ -2618,6 +2627,7 @@ static CURLcode myssh_connect(struct Curl_easy *data, bool *done) /* ignore */ } + CURL_TRC_SSH(data, "myssh_connect, set socket=%" FMT_SOCKET_T, sock); rc = ssh_options_set(sshc->ssh_session, SSH_OPTIONS_FD, &sock); if(rc != SSH_OK) { failf(data, "Could not set socket"); @@ -2691,7 +2701,7 @@ static CURLcode scp_doing(struct Curl_easy *data, bool *dophase_done) result = myssh_multi_statemach(data, dophase_done); if(*dophase_done) { - DEBUGF(infof(data, "DO phase is complete")); + CURL_TRC_SSH(data, "DO phase is complete"); } return result; } @@ -2712,7 +2722,7 @@ CURLcode scp_perform(struct Curl_easy *data, CURLcode result = CURLE_OK; struct ssh_conn *sshc = Curl_conn_meta_get(data->conn, CURL_META_SSH_CONN); - DEBUGF(infof(data, "DO phase starts")); + CURL_TRC_SSH(data, "DO phase starts"); *dophase_done = FALSE; /* not done yet */ if(!sshc) @@ -2726,7 +2736,7 @@ CURLcode scp_perform(struct Curl_easy *data, *connected = Curl_conn_is_connected(data->conn, FIRSTSOCKET); if(*dophase_done) { - DEBUGF(infof(data, "DO phase is complete")); + CURL_TRC_SSH(data, "DO phase is complete"); } return result; @@ -2959,7 +2969,7 @@ CURLcode sftp_perform(struct Curl_easy *data, struct ssh_conn *sshc = Curl_conn_meta_get(data->conn, CURL_META_SSH_CONN); CURLcode result = CURLE_OK; - DEBUGF(infof(data, "DO phase starts")); + CURL_TRC_SSH(data, "DO phase starts"); *dophase_done = FALSE; /* not done yet */ if(!sshc) @@ -2974,7 +2984,7 @@ CURLcode sftp_perform(struct Curl_easy *data, *connected = Curl_conn_is_connected(data->conn, FIRSTSOCKET); if(*dophase_done) { - DEBUGF(infof(data, "DO phase is complete")); + CURL_TRC_SSH(data, "DO phase is complete"); } return result; @@ -2986,7 +2996,7 @@ static CURLcode sftp_doing(struct Curl_easy *data, { CURLcode result = myssh_multi_statemach(data, dophase_done); if(*dophase_done) { - DEBUGF(infof(data, "DO phase is complete")); + CURL_TRC_SSH(data, "DO phase is complete"); } return result; } @@ -3003,7 +3013,7 @@ static CURLcode sftp_disconnect(struct Curl_easy *data, CURLcode result = CURLE_OK; (void)dead_connection; - DEBUGF(infof(data, "SSH DISCONNECT starts now")); + CURL_TRC_SSH(data, "DISCONNECT starts now"); if(sshc && sshc->ssh_session) { /* only if there is a session still around to use! */ @@ -3011,7 +3021,7 @@ static CURLcode sftp_disconnect(struct Curl_easy *data, result = myssh_block_statemach(data, sshc, sshp, TRUE); } - DEBUGF(infof(data, "SSH DISCONNECT is done")); + CURL_TRC_SSH(data, "DISCONNECT is done"); return result; } diff --git a/lib/vssh/libssh2.c b/lib/vssh/libssh2.c index 4ac9d89f1ad5..31ef5092d3da 100644 --- a/lib/vssh/libssh2.c +++ b/lib/vssh/libssh2.c @@ -280,17 +280,10 @@ static LIBSSH2_FREE_FUNC(my_libssh2_free) Curl_cfree(ptr); } -/* - * SSH State machine related code - */ -/* This is the ONLY way to change SSH state! */ -static void myssh_state(struct Curl_easy *data, - struct ssh_conn *sshc, - sshstate nowstate) +#if !defined(CURL_DISABLE_VERBOSE_STRINGS) +static const char *myssh_statename(sshstate state) { -#if defined(DEBUGBUILD) && !defined(CURL_DISABLE_VERBOSE_STRINGS) - /* for debug purposes */ - static const char * const names[] = { + static const char *const names[] = { "SSH_STOP", "SSH_INIT", "SSH_S_STARTUP", @@ -352,16 +345,34 @@ static void myssh_state(struct Curl_easy *data, "SSH_SESSION_FREE", "QUIT" }; - /* a precaution to make sure the lists are in sync */ DEBUGASSERT(CURL_ARRAYSIZE(names) == SSH_LAST); + return ((size_t)state < CURL_ARRAYSIZE(names)) ? names[state] : ""; +} +#else +#define myssh_statename(x) "" +#endif /* !CURL_DISABLE_VERBOSE_STRINGS */ + +#define myssh_state(x,y,z) myssh_set_state(x,y,z) + +/* + * SSH State machine related code + */ +/* This is the ONLY way to change SSH state! */ +static void myssh_set_state(struct Curl_easy *data, + struct ssh_conn *sshc, + sshstate nowstate) +{ +#if !defined(CURL_DISABLE_VERBOSE_STRINGS) if(sshc->state != nowstate) { - infof(data, "SFTP %p state change from %s to %s", - (void *)sshc, names[sshc->state], names[nowstate]); + CURL_TRC_SSH(data, "[%s] -> [%s]", + myssh_statename(sshc->state), + myssh_statename(nowstate)); } -#endif +#else (void)data; +#endif sshc->state = nowstate; } @@ -1172,10 +1183,6 @@ sftp_upload_init(struct Curl_easy *data, /* not set by Curl_xfer_setup to preserve keepon bits */ data->conn->recv_idx = FIRSTSOCKET; - /* store this original bitmask setup to use later on if we cannot - figure out a "real" bitmask */ - sshc->orig_waitfor = data->req.keepon; - /* since we do not really wait for anything at this point, we want the state machine to move on as soon as possible so mark this as dirty */ Curl_multi_mark_dirty(data); @@ -1951,8 +1958,7 @@ static CURLcode ssh_state_sftp_realpath(struct Curl_easy *data, /* in this case, the error was not in the SFTP level but for example a time-out or similar */ result = CURLE_SSH; - DEBUGF(infof(data, "error = %lu makes libcurl = %d", - sftperr, (int)result)); + CURL_TRC_SSH(data, "error = %lu makes libcurl = %d", sftperr, (int)result); return result; } @@ -1960,7 +1966,7 @@ static CURLcode ssh_state_sftp_realpath(struct Curl_easy *data, get the homedir here, we get the "workingpath" in the DO action since the homedir will remain the same between request but the working path will not. */ - DEBUGF(infof(data, "SSH CONNECT phase done")); + CURL_TRC_SSH(data, "CONNECT phase done"); return CURLE_OK; } @@ -2418,7 +2424,7 @@ static CURLcode ssh_state_sftp_close(struct Curl_easy *data, Curl_safefree(sshp->path); - DEBUGF(infof(data, "SFTP DONE done")); + CURL_TRC_SSH(data, "SFTP DONE done"); /* Check if nextstate is set and move .nextstate could be POSTQUOTE_INIT After nextstate is executed, the control should come back to @@ -2542,10 +2548,6 @@ static CURLcode ssh_state_scp_upload_init(struct Curl_easy *data, /* not set by Curl_xfer_setup to preserve keepon bits */ data->conn->recv_idx = FIRSTSOCKET; - /* store this original bitmask setup to use later on if we cannot - figure out a "real" bitmask */ - sshc->orig_waitfor = data->req.keepon; - myssh_state(data, sshc, SSH_STOP); return CURLE_OK; @@ -3008,7 +3010,7 @@ static CURLcode ssh_statemachine(struct Curl_easy *data, } sshc->ssh_channel = NULL; } - DEBUGF(infof(data, "SCP DONE phase complete")); + CURL_TRC_SSH(data, "SCP DONE phase complete"); myssh_state(data, sshc, SSH_STOP); break; @@ -3042,6 +3044,8 @@ static CURLcode ssh_statemachine(struct Curl_easy *data, *block = TRUE; result = CURLE_OK; } + CURL_TRC_SSH(data, "[%s] statemachine() -> %d, block=%d", + myssh_statename(sshc->state), result, *block); return result; } @@ -3051,15 +3055,29 @@ static CURLcode ssh_statemachine(struct Curl_easy *data, static CURLcode ssh_pollset(struct Curl_easy *data, struct easy_pollset *ps) { - int flags = 0; struct connectdata *conn = data->conn; - if(conn->waitfor & KEEP_RECV) - flags |= CURL_POLL_IN; - if(conn->waitfor & KEEP_SEND) - flags |= CURL_POLL_OUT; - return flags ? - Curl_pollset_change(data, ps, conn->sock[FIRSTSOCKET], flags, 0) : - CURLE_OK; + struct ssh_conn *sshc = Curl_conn_meta_get(conn, CURL_META_SSH_CONN); + curl_socket_t sock = conn->sock[FIRSTSOCKET]; + int waitfor; + + if(!sshc || (sock == CURL_SOCKET_BAD)) + return CURLE_FAILED_INIT; + + waitfor = sshc->waitfor ? sshc->waitfor : data->req.keepon; + if(waitfor) { + int flags = 0; + if(waitfor & KEEP_RECV) + flags |= CURL_POLL_IN; + if(waitfor & KEEP_SEND) + flags |= CURL_POLL_OUT; + DEBUGASSERT(flags); + CURL_TRC_SSH(data, "pollset, flags=%x", flags); + return Curl_pollset_change(data, ps, sock, flags, 0); + } + /* While we still have a session, we listen incoming data. */ + if(sshc->ssh_session) + return Curl_pollset_change(data, ps, sock, CURL_POLL_IN, 0); + return CURLE_OK; } /* @@ -3073,20 +3091,18 @@ static void ssh_block2waitfor(struct Curl_easy *data, struct ssh_conn *sshc, bool block) { - struct connectdata *conn = data->conn; int dir = 0; + (void)data; if(block) { dir = libssh2_session_block_directions(sshc->ssh_session); if(dir) { /* translate the libssh2 define bits into our own bit defines */ - conn->waitfor = ((dir&LIBSSH2_SESSION_BLOCK_INBOUND) ? KEEP_RECV : 0) | + sshc->waitfor = ((dir&LIBSSH2_SESSION_BLOCK_INBOUND) ? KEEP_RECV : 0) | ((dir&LIBSSH2_SESSION_BLOCK_OUTBOUND) ? KEEP_SEND : 0); } } if(!dir) - /* It did not block or libssh2 did not reveal in which direction, put back - the original set */ - conn->waitfor = sshc->orig_waitfor; + sshc->waitfor = 0; } /* called repeatedly until done from multi.c */ @@ -3468,7 +3484,7 @@ CURLcode scp_perform(struct Curl_easy *data, struct ssh_conn *sshc = Curl_conn_meta_get(data->conn, CURL_META_SSH_CONN); CURLcode result = CURLE_OK; - DEBUGF(infof(data, "DO phase starts")); + CURL_TRC_SSH(data, "DO phase starts"); *dophase_done = FALSE; /* not done yet */ if(!sshc) @@ -3483,7 +3499,7 @@ CURLcode scp_perform(struct Curl_easy *data, *connected = Curl_conn_is_connected(data->conn, FIRSTSOCKET); if(*dophase_done) { - DEBUGF(infof(data, "DO phase is complete")); + CURL_TRC_SSH(data, "DO phase is complete"); } return result; @@ -3497,7 +3513,7 @@ static CURLcode scp_doing(struct Curl_easy *data, result = ssh_multi_statemach(data, dophase_done); if(*dophase_done) { - DEBUGF(infof(data, "DO phase is complete")); + CURL_TRC_SSH(data, "DO phase is complete"); } return result; } @@ -3778,7 +3794,7 @@ CURLcode sftp_perform(struct Curl_easy *data, struct ssh_conn *sshc = Curl_conn_meta_get(data->conn, CURL_META_SSH_CONN); CURLcode result = CURLE_OK; - DEBUGF(infof(data, "DO phase starts")); + CURL_TRC_SSH(data, "DO phase starts"); *dophase_done = FALSE; /* not done yet */ if(!sshc) @@ -3793,7 +3809,7 @@ CURLcode sftp_perform(struct Curl_easy *data, *connected = Curl_conn_is_connected(data->conn, FIRSTSOCKET); if(*dophase_done) { - DEBUGF(infof(data, "DO phase is complete")); + CURL_TRC_SSH(data, "DO phase is complete"); } return result; @@ -3806,7 +3822,7 @@ static CURLcode sftp_doing(struct Curl_easy *data, CURLcode result = ssh_multi_statemach(data, dophase_done); if(*dophase_done) { - DEBUGF(infof(data, "DO phase is complete")); + CURL_TRC_SSH(data, "DO phase is complete"); } return result; } @@ -3825,10 +3841,10 @@ static CURLcode sftp_disconnect(struct Curl_easy *data, if(sshc) { if(sshc->ssh_session) { /* only if there is a session still around to use! */ - DEBUGF(infof(data, "SSH DISCONNECT starts now")); + CURL_TRC_SSH(data, "DISCONNECT starts now"); myssh_state(data, sshc, SSH_SFTP_SHUTDOWN); result = ssh_block_statemach(data, sshc, sshp, TRUE); - DEBUGF(infof(data, "SSH DISCONNECT is done -> %d", result)); + CURL_TRC_SSH(data, "DISCONNECT is done -> %d", result); } sshc_cleanup(sshc, data, TRUE); } diff --git a/lib/vssh/ssh.h b/lib/vssh/ssh.h index 5317351478fc..92ae72a6a761 100644 --- a/lib/vssh/ssh.h +++ b/lib/vssh/ssh.h @@ -156,7 +156,8 @@ struct ssh_conn { int secondCreateDirs; /* counter use by the code to see if the second attempt has been made to change to/create a directory */ - int orig_waitfor; /* default READ/WRITE bits wait for */ + int waitfor; /* KEEP_RECV/KEEP_SEND bits overriding + pollset given flags */ char *slash_pos; /* used by the SFTP_CREATE_DIRS state */ #ifdef USE_LIBSSH From b06cd929bd9bdda2fe4dfced73a60bd503be6155 Mon Sep 17 00:00:00 2001 From: Stefan Eissing Date: Fri, 28 Nov 2025 14:05:34 +0100 Subject: [PATCH 110/415] libssh: fix state machine loop to progress as it should --- lib/vssh/libssh.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/vssh/libssh.c b/lib/vssh/libssh.c index 2b605e4a6184..d0f3d3de5cca 100644 --- a/lib/vssh/libssh.c +++ b/lib/vssh/libssh.c @@ -2408,7 +2408,9 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, break; } - } while(!rc && (sshc->state != SSH_STOP)); + /* break the loop only on STOP or SSH_AGAIN. If `rc` is some + * other error code, we will have progressed the state accordingly. */ + } while((rc != SSH_AGAIN) && (sshc->state != SSH_STOP)); if(rc == SSH_AGAIN) { /* we would block, we need to wait for the socket to be ready (in the From 8c68887d2d145b00a912824cc6962d0d64cb8419 Mon Sep 17 00:00:00 2001 From: Stefan Eissing Date: Fri, 28 Nov 2025 10:25:59 +0100 Subject: [PATCH 111/415] http1: parse header from uint8_t buffer To save casting the passed buffer when parsing HTTP/1 request headers from an uint8_t buffer. Closes #19742 --- lib/http1.c | 10 +++++----- lib/http1.h | 2 +- lib/http2.c | 2 +- lib/vquic/curl_ngtcp2.c | 2 +- lib/vquic/curl_osslq.c | 2 +- lib/vquic/curl_quiche.c | 2 +- tests/unit/unit2603.c | 6 +++--- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/http1.c b/lib/http1.c index 0a80fedfc722..657a674105fa 100644 --- a/lib/http1.c +++ b/lib/http1.c @@ -77,7 +77,7 @@ static CURLcode trim_line(struct h1_req_parser *parser, int options) } static CURLcode detect_line(struct h1_req_parser *parser, - const char *buf, const size_t buflen, + const uint8_t *buf, const size_t buflen, size_t *pnread) { const char *line_end; @@ -87,14 +87,14 @@ static CURLcode detect_line(struct h1_req_parser *parser, line_end = memchr(buf, '\n', buflen); if(!line_end) return CURLE_AGAIN; - parser->line = buf; - parser->line_len = line_end - buf + 1; + parser->line = (const char *)buf; + parser->line_len = line_end - parser->line + 1; *pnread = parser->line_len; return CURLE_OK; } static CURLcode next_line(struct h1_req_parser *parser, - const char *buf, const size_t buflen, int options, + const uint8_t *buf, const size_t buflen, int options, size_t *pnread) { CURLcode result; @@ -262,7 +262,7 @@ static CURLcode start_req(struct h1_req_parser *parser, } CURLcode Curl_h1_req_parse_read(struct h1_req_parser *parser, - const char *buf, size_t buflen, + const uint8_t *buf, size_t buflen, const char *scheme_default, const char *custom_method, int options, size_t *pnread) diff --git a/lib/http1.h b/lib/http1.h index 944e9038dd98..88bd99798e05 100644 --- a/lib/http1.h +++ b/lib/http1.h @@ -49,7 +49,7 @@ void Curl_h1_req_parse_init(struct h1_req_parser *parser, size_t max_line_len); void Curl_h1_req_parse_free(struct h1_req_parser *parser); CURLcode Curl_h1_req_parse_read(struct h1_req_parser *parser, - const char *buf, size_t buflen, + const uint8_t *buf, size_t buflen, const char *scheme_default, const char *custom_method, int options, size_t *pnread); diff --git a/lib/http2.c b/lib/http2.c index baaefd439d4f..e75d7431e72c 100644 --- a/lib/http2.c +++ b/lib/http2.c @@ -2277,7 +2277,7 @@ static CURLcode h2_submit(struct h2_stream_ctx **pstream, if(result) goto out; - result = Curl_h1_req_parse_read(&stream->h1, (const char *)buf, len, NULL, + result = Curl_h1_req_parse_read(&stream->h1, buf, len, NULL, !data->state.http_ignorecustom ? data->set.str[STRING_CUSTOMREQUEST] : NULL, 0, &nwritten); diff --git a/lib/vquic/curl_ngtcp2.c b/lib/vquic/curl_ngtcp2.c index 4767780a922d..62255285b6a0 100644 --- a/lib/vquic/curl_ngtcp2.c +++ b/lib/vquic/curl_ngtcp2.c @@ -1548,7 +1548,7 @@ static CURLcode h3_stream_open(struct Curl_cfilter *cf, goto out; } - result = Curl_h1_req_parse_read(&stream->h1, (const char *)buf, len, NULL, + result = Curl_h1_req_parse_read(&stream->h1, buf, len, NULL, !data->state.http_ignorecustom ? data->set.str[STRING_CUSTOMREQUEST] : NULL, 0, pnwritten); diff --git a/lib/vquic/curl_osslq.c b/lib/vquic/curl_osslq.c index 1c3f0c55b66e..7bca97b4086d 100644 --- a/lib/vquic/curl_osslq.c +++ b/lib/vquic/curl_osslq.c @@ -1900,7 +1900,7 @@ static CURLcode h3_stream_open(struct Curl_cfilter *cf, goto out; } - result = Curl_h1_req_parse_read(&stream->h1, (const char *)buf, len, NULL, + result = Curl_h1_req_parse_read(&stream->h1, buf, len, NULL, !data->state.http_ignorecustom ? data->set.str[STRING_CUSTOMREQUEST] : NULL, 0, pnwritten); diff --git a/lib/vquic/curl_quiche.c b/lib/vquic/curl_quiche.c index c182e1490d23..5aca750c2cb9 100644 --- a/lib/vquic/curl_quiche.c +++ b/lib/vquic/curl_quiche.c @@ -976,7 +976,7 @@ static CURLcode h3_open_stream(struct Curl_cfilter *cf, DEBUGASSERT(stream); - result = Curl_h1_req_parse_read(&stream->h1, (const char *)buf, blen, NULL, + result = Curl_h1_req_parse_read(&stream->h1, buf, blen, NULL, !data->state.http_ignorecustom ? data->set.str[STRING_CUSTOMREQUEST] : NULL, 0, pnwritten); diff --git a/tests/unit/unit2603.c b/tests/unit/unit2603.c index 61295de37e1d..1de774d26f8b 100644 --- a/tests/unit/unit2603.c +++ b/tests/unit/unit2603.c @@ -63,7 +63,7 @@ struct tcase { static void parse_success(const struct tcase *t) { struct h1_req_parser p; - const char *buf; + const uint8_t *buf; size_t buflen, i, in_len, in_consumed; CURLcode err; size_t nread; @@ -71,8 +71,8 @@ static void parse_success(const struct tcase *t) Curl_h1_req_parse_init(&p, 1024); in_len = in_consumed = 0; for(i = 0; t->input[i]; ++i) { - buf = t->input[i]; - buflen = strlen(buf); + buf = (const uint8_t *)t->input[i]; + buflen = strlen(t->input[i]); in_len += buflen; err = Curl_h1_req_parse_read(&p, buf, buflen, t->default_scheme, t->custom_method, 0, &nread); From 38961528434e6efdd4c1fba19e67ae0f0585007c Mon Sep 17 00:00:00 2001 From: Stefan Eissing Date: Fri, 28 Nov 2025 10:44:05 +0100 Subject: [PATCH 112/415] connection: give send methods/prototypes an uint8_t buffer To conclude changing the send buffer type from `const void *` to `const uint8_t *`, change the top level send function and its implementations. Closes #19743 --- lib/cfilters.c | 2 +- lib/cfilters.h | 2 +- lib/curl_rtmp.c | 2 +- lib/urldata.h | 2 +- lib/vssh/libssh.c | 4 ++-- lib/vssh/libssh2.c | 9 +++++---- 6 files changed, 11 insertions(+), 10 deletions(-) diff --git a/lib/cfilters.c b/lib/cfilters.c index 7d1f0c3d9e4f..dd4cb5210acc 100644 --- a/lib/cfilters.c +++ b/lib/cfilters.c @@ -242,7 +242,7 @@ CURLcode Curl_cf_recv(struct Curl_easy *data, int num, char *buf, } CURLcode Curl_cf_send(struct Curl_easy *data, int num, - const void *mem, size_t len, bool eos, + const uint8_t *mem, size_t len, bool eos, size_t *pnwritten) { struct Curl_cfilter *cf; diff --git a/lib/cfilters.h b/lib/cfilters.h index 5d39725088ed..a3bd97a9f166 100644 --- a/lib/cfilters.h +++ b/lib/cfilters.h @@ -508,7 +508,7 @@ CURLcode Curl_cf_recv(struct Curl_easy *data, int sockindex, char *buf, * in `*pnwritten` or on error. */ CURLcode Curl_cf_send(struct Curl_easy *data, int sockindex, - const void *buf, size_t len, bool eos, + const uint8_t *buf, size_t len, bool eos, size_t *pnwritten); /** diff --git a/lib/curl_rtmp.c b/lib/curl_rtmp.c index 351c9f494c3f..b2dd937008a5 100644 --- a/lib/curl_rtmp.c +++ b/lib/curl_rtmp.c @@ -352,7 +352,7 @@ static CURLcode rtmp_recv(struct Curl_easy *data, int sockindex, char *buf, } static CURLcode rtmp_send(struct Curl_easy *data, int sockindex, - const void *buf, size_t len, bool eos, + const uint8_t *buf, size_t len, bool eos, size_t *pnwritten) { struct connectdata *conn = data->conn; diff --git a/lib/urldata.h b/lib/urldata.h index 2d28718181a9..561db56ecd8a 100644 --- a/lib/urldata.h +++ b/lib/urldata.h @@ -162,7 +162,7 @@ typedef unsigned int curl_prot_t; /* On error return, the value of `pnwritten` has no meaning */ typedef CURLcode (Curl_send)(struct Curl_easy *data, /* transfer */ int sockindex, /* socketindex */ - const void *buf, /* data to write */ + const uint8_t *buf, /* data to write */ size_t len, /* amount to send */ bool eos, /* last chunk */ size_t *pnwritten); /* how much sent */ diff --git a/lib/vssh/libssh.c b/lib/vssh/libssh.c index d0f3d3de5cca..db80bcbf8c96 100644 --- a/lib/vssh/libssh.c +++ b/lib/vssh/libssh.c @@ -2887,7 +2887,7 @@ static CURLcode scp_done(struct Curl_easy *data, CURLcode status, } static CURLcode scp_send(struct Curl_easy *data, int sockindex, - const void *mem, size_t len, bool eos, + const uint8_t *mem, size_t len, bool eos, size_t *pnwritten) { int rc; @@ -3048,7 +3048,7 @@ static CURLcode sftp_done(struct Curl_easy *data, CURLcode status, /* return number of sent bytes */ static CURLcode sftp_send(struct Curl_easy *data, int sockindex, - const void *mem, size_t len, bool eos, + const uint8_t *mem, size_t len, bool eos, size_t *pnwritten) { struct connectdata *conn = data->conn; diff --git a/lib/vssh/libssh2.c b/lib/vssh/libssh2.c index 31ef5092d3da..ce593d54874a 100644 --- a/lib/vssh/libssh2.c +++ b/lib/vssh/libssh2.c @@ -3715,7 +3715,7 @@ static CURLcode scp_done(struct Curl_easy *data, CURLcode status, } static CURLcode scp_send(struct Curl_easy *data, int sockindex, - const void *mem, size_t len, bool eos, + const uint8_t *mem, size_t len, bool eos, size_t *pnwritten) { struct connectdata *conn = data->conn; @@ -3731,7 +3731,8 @@ static CURLcode scp_send(struct Curl_easy *data, int sockindex, return CURLE_FAILED_INIT; /* libssh2_channel_write() returns int! */ - nwritten = (ssize_t) libssh2_channel_write(sshc->ssh_channel, mem, len); + nwritten = (ssize_t) libssh2_channel_write(sshc->ssh_channel, + (const char *)mem, len); ssh_block2waitfor(data, sshc, (nwritten == LIBSSH2_ERROR_EAGAIN)); @@ -3874,7 +3875,7 @@ static CURLcode sftp_done(struct Curl_easy *data, CURLcode status, /* return number of sent bytes */ static CURLcode sftp_send(struct Curl_easy *data, int sockindex, - const void *mem, size_t len, bool eos, + const uint8_t *mem, size_t len, bool eos, size_t *pnwritten) { struct connectdata *conn = data->conn; @@ -3888,7 +3889,7 @@ static CURLcode sftp_send(struct Curl_easy *data, int sockindex, if(!sshc) return CURLE_FAILED_INIT; - nwrite = libssh2_sftp_write(sshc->sftp_handle, mem, len); + nwrite = libssh2_sftp_write(sshc->sftp_handle, (const char *)mem, len); ssh_block2waitfor(data, sshc, (nwrite == LIBSSH2_ERROR_EAGAIN)); From 02aa75a8c240af1a8912145497806e8925859a87 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 28 Nov 2025 17:41:59 +0100 Subject: [PATCH 113/415] runtests: allow a test to switch off memdebug Test 3207 now uses this as its multi-threading is not fully memdebug compliant. Closes #19752 --- docs/tests/FILEFORMAT.md | 5 ++++- lib/memdebug.c | 2 -- tests/data/test3207 | 2 +- tests/runner.pm | 11 +++++++++++ tests/runtests.pl | 6 ++++-- 5 files changed, 20 insertions(+), 6 deletions(-) diff --git a/docs/tests/FILEFORMAT.md b/docs/tests/FILEFORMAT.md index 7851e08e2597..1f3aa78991b8 100644 --- a/docs/tests/FILEFORMAT.md +++ b/docs/tests/FILEFORMAT.md @@ -586,7 +586,7 @@ command has been run. If the variable name has no assignment, no `=`, then that variable is just deleted. -### `` +### `` Command line to run. If the command spans multiple lines, they are concatenated with a space added @@ -608,6 +608,9 @@ otherwise written to verify stdout. Set `option="no-include"` to prevent the test script to slap on the `--include` argument. +Set `option="no-memdebug"` to make the test run without the memdebug tracking +system. For tests that are incompatible - multi-threaded for example. + Set `option="no-q"` avoid using `-q` as the first argument in the curl command line. diff --git a/lib/memdebug.c b/lib/memdebug.c index f5b88731ee35..9fd54d026b69 100644 --- a/lib/memdebug.c +++ b/lib/memdebug.c @@ -111,8 +111,6 @@ void curl_dbg_memdebug(const char *logname) if(!curl_dbg_logfile) { if(logname && *logname) curl_dbg_logfile = CURLX_FOPEN_LOW(logname, FOPEN_WRITETEXT); - else - curl_dbg_logfile = stderr; #ifdef MEMDEBUG_LOG_SYNC /* Flush the log file after every line so the log is not lost in a crash */ if(curl_dbg_logfile) diff --git a/tests/data/test3207 b/tests/data/test3207 index 4806ef5474d6..9aa3ee5a365f 100644 --- a/tests/data/test3207 +++ b/tests/data/test3207 @@ -37,7 +37,7 @@ concurrent HTTPS GET using shared ssl session cache lib%TESTNUMBER # provide URL and ca-cert - + https://localhost:%HTTPSPORT/%TESTNUMBER %CERTDIR/certs/test-ca.crt diff --git a/tests/runner.pm b/tests/runner.pm index a73f9d599934..b69bbf2420aa 100644 --- a/tests/runner.pm +++ b/tests/runner.pm @@ -840,6 +840,7 @@ sub singletest_run { $tool = $tool_name . exe_ext('TOOL'); } + my $oldmemdebug; my $disablevalgrind; my $CMDLINE=""; my $cmdargs; @@ -1025,6 +1026,11 @@ sub singletest_run { # timestamp starting of test command $$testtimings{"timetoolini"} = Time::HiRes::time(); + if($cmdhash{'option'} && ($cmdhash{'option'} =~ /no-memdebug/)) { + $oldmemdebug = $ENV{'CURL_MEMDEBUG'}; + delete $ENV{'CURL_MEMDEBUG'}; + } + # run the command line we built if($torture) { $cmdres = torture($CMDLINE, @@ -1048,6 +1054,11 @@ sub singletest_run { ($cmdres, $dumped_core) = normalize_cmdres(runclient("$CMDLINE")); } + # restore contents + if($oldmemdebug) { + $ENV{'CURL_MEMDEBUG'} = $oldmemdebug; + } + # timestamp finishing of test command $$testtimings{"timetoolend"} = Time::HiRes::time(); diff --git a/tests/runtests.pl b/tests/runtests.pl index 3d557d1435ed..648666fd301e 100755 --- a/tests/runtests.pl +++ b/tests/runtests.pl @@ -1763,8 +1763,10 @@ sub singletest_check { if(! -f "$logdir/$MEMDUMP") { my %cmdhash = getpartattr("client", "command"); my $cmdtype = $cmdhash{'type'} || "default"; - logmsg "\n** ALERT! memory tracking with no output file?\n" - if($cmdtype ne "perl"); + if($cmdhash{'option'} !~ /no-memdebug/) { + logmsg "\n** ALERT! memory tracking with no output file?\n" + if($cmdtype ne "perl"); + } $ok .= "-"; # problem with memory checking } else { From 4be6707910192681c5cb52e7d9eb6c0947b28600 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Fri, 28 Nov 2025 17:39:04 +0100 Subject: [PATCH 114/415] curlx/multibyte: stop setting macros for non-Windows These macros are not used for non-Windows. Drop them with the unused mappings to standard allocators. Closes #19751 --- lib/curlx/multibyte.h | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/lib/curlx/multibyte.h b/lib/curlx/multibyte.h index c992214a9575..fac07c2eeb24 100644 --- a/lib/curlx/multibyte.h +++ b/lib/curlx/multibyte.h @@ -26,10 +26,6 @@ #include "../curl_setup.h" #ifdef _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); -#endif /* * Macros curlx_convert_UTF8_to_tchar(), curlx_convert_tchar_to_UTF8() @@ -48,7 +44,14 @@ char *curlx_convert_wchar_to_UTF8(const wchar_t *str_w); * memory tracker memdebug functions. */ -#if defined(UNICODE) && 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); + +/* the purpose of this macro is to free() without being traced by memdebug */ +#define curlx_unicodefree(ptr) free(ptr) + +#ifdef UNICODE #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)) @@ -60,15 +63,10 @@ typedef union { const unsigned short *const_tbyte_ptr; } xcharp_u; -#else +#else /* !UNICODE */ -#ifdef _WIN32 #define curlx_convert_UTF8_to_tchar(ptr) _strdup(ptr) #define curlx_convert_tchar_to_UTF8(ptr) _strdup(ptr) -#else -#define curlx_convert_UTF8_to_tchar(ptr) strdup(ptr) -#define curlx_convert_tchar_to_UTF8(ptr) strdup(ptr) -#endif typedef union { char *tchar_ptr; @@ -77,9 +75,7 @@ typedef union { const unsigned char *const_tbyte_ptr; } xcharp_u; -#endif /* UNICODE && _WIN32 */ - -/* the purpose of this macro is to free() without being traced by memdebug */ -#define curlx_unicodefree(ptr) free(ptr) +#endif /* UNICODE */ +#endif /* _WIN32 */ #endif /* HEADER_CURL_MULTIBYTE_H */ From d73efc62c15f2d2a3da4b27b90825975298e5c88 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Fri, 28 Nov 2025 21:17:58 +0100 Subject: [PATCH 115/415] tests: fix formatting nits Also: - lib1948: fix checksrc error TYPEDEFSTRUCT. (detected after formatting) Closes #19754 --- .../http/testenv/mod_curltest/mod_curltest.c | 29 +- tests/libtest/cli_h2_pausing.c | 7 +- tests/libtest/cli_h2_upgrade_extreme.c | 2 +- tests/libtest/cli_hx_download.c | 6 +- tests/libtest/cli_hx_upload.c | 3 +- tests/libtest/cli_tls_session_reuse.c | 6 +- tests/libtest/cli_upload_pausing.c | 2 +- tests/libtest/cli_ws_data.c | 9 +- tests/libtest/first.c | 3 +- tests/libtest/first.h | 2 +- tests/libtest/lib1156.c | 18 +- tests/libtest/lib1308.c | 2 +- tests/libtest/lib1514.c | 2 +- tests/libtest/lib1517.c | 1 - tests/libtest/lib1520.c | 2 +- tests/libtest/lib1522.c | 2 +- tests/libtest/lib1523.c | 2 +- tests/libtest/lib1525.c | 2 +- tests/libtest/lib1526.c | 2 +- tests/libtest/lib1527.c | 2 +- tests/libtest/lib1533.c | 1 - tests/libtest/lib1534.c | 8 +- tests/libtest/lib1535.c | 8 +- tests/libtest/lib1536.c | 8 +- tests/libtest/lib1559.c | 4 +- tests/libtest/lib1560.c | 4 +- tests/libtest/lib1597.c | 2 +- tests/libtest/lib1662.c | 2 +- tests/libtest/lib1915.c | 3 +- tests/libtest/lib1919.c | 4 +- tests/libtest/lib1940.c | 2 +- tests/libtest/lib1945.c | 4 +- tests/libtest/lib1947.c | 6 +- tests/libtest/lib1948.c | 9 +- tests/libtest/lib1960.c | 8 +- tests/libtest/lib1977.c | 3 - tests/libtest/lib2023.c | 2 +- tests/libtest/lib2032.c | 6 +- tests/libtest/lib2402.c | 6 +- tests/libtest/lib2404.c | 6 +- tests/libtest/lib2405.c | 7 +- tests/libtest/lib2502.c | 6 +- tests/libtest/lib2700.c | 3 +- tests/libtest/lib3033.c | 3 +- tests/libtest/lib3102.c | 10 +- tests/libtest/lib3207.c | 6 +- tests/libtest/lib505.c | 3 +- tests/libtest/lib506.c | 92 +++--- tests/libtest/lib508.c | 2 +- tests/libtest/lib509.c | 1 - tests/libtest/lib510.c | 4 +- tests/libtest/lib526.c | 1 - tests/libtest/lib530.c | 2 +- tests/libtest/lib536.c | 3 +- tests/libtest/lib537.c | 2 +- tests/libtest/lib540.c | 4 +- tests/libtest/lib547.c | 2 +- tests/libtest/lib552.c | 8 +- tests/libtest/lib554.c | 2 +- tests/libtest/lib555.c | 2 +- tests/libtest/lib557.c | 43 +-- tests/libtest/lib568.c | 2 +- tests/libtest/lib570.c | 2 +- tests/libtest/lib572.c | 2 +- tests/libtest/lib573.c | 2 +- tests/libtest/lib574.c | 3 +- tests/libtest/lib579.c | 2 +- tests/libtest/lib582.c | 2 +- tests/libtest/lib586.c | 75 +++-- tests/libtest/lib591.c | 4 +- tests/libtest/lib597.c | 6 +- tests/libtest/lib643.c | 17 +- tests/libtest/lib650.c | 7 +- tests/libtest/lib651.c | 6 +- tests/libtest/lib652.c | 2 +- tests/libtest/lib654.c | 6 +- tests/libtest/lib666.c | 2 +- tests/libtest/lib667.c | 7 +- tests/libtest/lib668.c | 8 +- tests/libtest/lib670.c | 8 +- tests/libtest/lib678.c | 5 +- tests/libtest/lib758.c | 8 +- tests/server/dnsd.c | 17 +- tests/server/getpart.c | 17 +- tests/server/mqttd.c | 17 +- tests/server/resolve.c | 4 +- tests/server/rtspd.c | 46 ++- tests/server/sockfilt.c | 294 +++++++++--------- tests/server/socksd.c | 15 +- tests/server/sws.c | 67 ++-- tests/server/tftpd.c | 20 +- tests/server/util.c | 55 ++-- tests/unit/unit1300.c | 2 +- tests/unit/unit1302.c | 4 +- tests/unit/unit1304.c | 33 +- tests/unit/unit1307.c | 2 +- tests/unit/unit1309.c | 12 +- tests/unit/unit1397.c | 2 +- tests/unit/unit1398.c | 20 +- tests/unit/unit1601.c | 2 +- tests/unit/unit1606.c | 18 +- tests/unit/unit1610.c | 4 +- tests/unit/unit1611.c | 4 +- tests/unit/unit1612.c | 8 +- tests/unit/unit1614.c | 14 +- tests/unit/unit1615.c | 14 +- tests/unit/unit1620.c | 3 +- tests/unit/unit1650.c | 16 +- tests/unit/unit1651.c | 4 +- tests/unit/unit1655.c | 2 +- tests/unit/unit1656.c | 2 +- tests/unit/unit1657.c | 2 +- tests/unit/unit1660.c | 2 +- tests/unit/unit1661.c | 2 +- tests/unit/unit1663.c | 11 +- tests/unit/unit2600.c | 6 +- tests/unit/unit2601.c | 10 +- tests/unit/unit2602.c | 12 +- tests/unit/unit3200.c | 124 ++++---- tests/unit/unit3205.c | 4 +- tests/unit/unit3211.c | 4 +- tests/unit/unit3213.c | 2 +- tests/unit/unit3216.c | 2 +- 123 files changed, 680 insertions(+), 801 deletions(-) diff --git a/tests/http/testenv/mod_curltest/mod_curltest.c b/tests/http/testenv/mod_curltest/mod_curltest.c index cb236557e0a5..b45fd95286b2 100644 --- a/tests/http/testenv/mod_curltest/mod_curltest.c +++ b/tests/http/testenv/mod_curltest/mod_curltest.c @@ -62,7 +62,8 @@ static int curltest_post_config(apr_pool_t *p, apr_pool_t *plog, void *data = NULL; const char *key = "mod_curltest_init_counter"; - (void)plog;(void)ptemp; + (void)plog; + (void)ptemp; apr_pool_userdata_get(&data, key, s->process->pool); if(!data) { @@ -93,8 +94,8 @@ static void curltest_hooks(apr_pool_t *pool) ap_hook_handler(curltest_sslinfo_handler, NULL, NULL, APR_HOOK_MIDDLE); } -#define SECS_PER_HOUR (60*60) -#define SECS_PER_DAY (24*SECS_PER_HOUR) +#define SECS_PER_HOUR (60 * 60) +#define SECS_PER_DAY (24 * SECS_PER_HOUR) static apr_status_t duration_parse(apr_interval_time_t *ptimeout, const char *value, const char *def_unit) @@ -124,12 +125,12 @@ static apr_status_t duration_parse(apr_interval_time_t *ptimeout, break; case 's': case 'S': - *ptimeout = (apr_interval_time_t) apr_time_from_sec(n); + *ptimeout = (apr_interval_time_t)apr_time_from_sec(n); break; case 'h': case 'H': /* Time is in hours */ - *ptimeout = (apr_interval_time_t) apr_time_from_sec(n * SECS_PER_HOUR); + *ptimeout = (apr_interval_time_t)apr_time_from_sec(n * SECS_PER_HOUR); break; case 'm': case 'M': @@ -137,12 +138,12 @@ static apr_status_t duration_parse(apr_interval_time_t *ptimeout, /* Time is in milliseconds */ case 's': case 'S': - *ptimeout = (apr_interval_time_t) n * 1000; + *ptimeout = (apr_interval_time_t)n * 1000; break; /* Time is in minutes */ case 'i': case 'I': - *ptimeout = (apr_interval_time_t) apr_time_from_sec(n * 60); + *ptimeout = (apr_interval_time_t)apr_time_from_sec(n * 60); break; default: return APR_EGENERAL; @@ -154,7 +155,7 @@ static apr_status_t duration_parse(apr_interval_time_t *ptimeout, /* Time is in microseconds */ case 's': case 'S': - *ptimeout = (apr_interval_time_t) n; + *ptimeout = (apr_interval_time_t)n; break; default: return APR_EGENERAL; @@ -266,8 +267,7 @@ static int curltest_echo_handler(request_rec *r) apr_table_get(r->headers_in, "TE")); if(read_delay) { - ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, - "put_handler: read_delay"); + ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, "put_handler: read_delay"); apr_sleep(read_delay); } @@ -343,7 +343,7 @@ static int curltest_tweak_handler(request_rec *r) apr_bucket_brigade *bb; apr_bucket *b; apr_status_t rv; - char buffer[16*1024]; + char buffer[16 * 1024]; int i, chunks = 3, error_bucket = 1; size_t chunk_size = sizeof(buffer); const char *request_id = "none"; @@ -579,7 +579,7 @@ static int curltest_put_handler(request_rec *r) apr_bucket_brigade *bb; apr_bucket *b; apr_status_t rv; - char buffer[128*1024]; + char buffer[128 * 1024]; const char *ct; apr_off_t rbody_len = 0; apr_off_t rbody_max_len = -1; @@ -650,8 +650,7 @@ static int curltest_put_handler(request_rec *r) ap_set_content_type(r, ct ? ct : "text/plain"); if(read_delay) { - ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, - "put_handler: read_delay"); + ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, "put_handler: read_delay"); apr_sleep(read_delay); } bb = apr_brigade_create(r->pool, c->bucket_alloc); @@ -674,7 +673,7 @@ static int curltest_put_handler(request_rec *r) } } /* we are done */ - s_rbody_len = apr_psprintf(r->pool, "%"APR_OFF_T_FMT, rbody_len); + s_rbody_len = apr_psprintf(r->pool, "%" APR_OFF_T_FMT, rbody_len); apr_table_setn(r->headers_out, "Received-Length", s_rbody_len); rv = apr_brigade_puts(bb, NULL, NULL, s_rbody_len); if(APR_SUCCESS != rv) diff --git a/tests/libtest/cli_h2_pausing.c b/tests/libtest/cli_h2_pausing.c index 25b798af4b2b..30bcfcf043a6 100644 --- a/tests/libtest/cli_h2_pausing.c +++ b/tests/libtest/cli_h2_pausing.c @@ -38,8 +38,7 @@ static void usage_h2_pausing(const char *msg) ); } -struct handle -{ +struct handle { size_t idx; int paused; int resumed; @@ -51,7 +50,7 @@ struct handle static size_t cb(char *data, size_t size, size_t nmemb, void *clientp) { size_t realsize = size * nmemb; - struct handle *handle = (struct handle *) clientp; + struct handle *handle = (struct handle *)clientp; curl_off_t totalsize; (void)data; @@ -163,7 +162,7 @@ static CURLcode test_cli_h2_pausing(const char *URL) goto cleanup; } memset(&resolve, 0, sizeof(resolve)); - curl_msnprintf(resolve_buf, sizeof(resolve_buf)-1, "%s:%s:127.0.0.1", + curl_msnprintf(resolve_buf, sizeof(resolve_buf) - 1, "%s:%s:127.0.0.1", host, port); resolve = curl_slist_append(resolve, resolve_buf); diff --git a/tests/libtest/cli_h2_upgrade_extreme.c b/tests/libtest/cli_h2_upgrade_extreme.c index bc28a6f4d05e..8d5bf8d82ca6 100644 --- a/tests/libtest/cli_h2_upgrade_extreme.c +++ b/tests/libtest/cli_h2_upgrade_extreme.c @@ -120,7 +120,7 @@ static CURLcode test_cli_h2_upgrade_extreme(const char *URL) curl_easy_getinfo(msg->easy_handle, CURLINFO_XFER_ID, &xfer_id); curl_easy_getinfo(msg->easy_handle, CURLINFO_RESPONSE_CODE, &status); if(msg->data.result == CURLE_SEND_ERROR || - msg->data.result == CURLE_RECV_ERROR) { + msg->data.result == CURLE_RECV_ERROR) { /* We get these if the server had a GOAWAY in transit on * reusing a connection */ } diff --git a/tests/libtest/cli_hx_download.c b/tests/libtest/cli_hx_download.c index a7f5d200903c..2a3614412369 100644 --- a/tests/libtest/cli_hx_download.c +++ b/tests/libtest/cli_hx_download.c @@ -88,7 +88,7 @@ static size_t my_write_d_cb(char *buf, size_t nitems, size_t buflen, "pause_at=%" CURL_FORMAT_CURL_OFF_T "\n", t->idx, blen, t->recv_size, t->pause_at); if(!t->out) { - curl_msnprintf(t->filename, sizeof(t->filename)-1, "download_%zu.data", + curl_msnprintf(t->filename, sizeof(t->filename) - 1, "download_%zu.data", t->idx); t->out = curlx_fopen(t->filename, "wb"); if(!t->out) @@ -149,7 +149,7 @@ static int my_progress_d_cb(void *userdata, switch(tls->backend) { #if defined(USE_QUICHE) || defined(USE_OPENSSL) case CURLSSLBACKEND_OPENSSL: { - const char *version = SSL_get_version((SSL*)tls->internals); + const char *version = SSL_get_version((SSL *)tls->internals); assert(version); assert(strcmp(version, "unknown")); curl_mfprintf(stderr, "[t-%zu] info OpenSSL using %s\n", @@ -159,7 +159,7 @@ static int my_progress_d_cb(void *userdata, #endif #ifdef USE_WOLFSSL case CURLSSLBACKEND_WOLFSSL: { - const char *version = wolfSSL_get_version((WOLFSSL*)tls->internals); + const char *version = wolfSSL_get_version((WOLFSSL *)tls->internals); assert(version); assert(strcmp(version, "unknown")); curl_mfprintf(stderr, "[t-%zu] info wolfSSL using %s\n", diff --git a/tests/libtest/cli_hx_upload.c b/tests/libtest/cli_hx_upload.c index f7036509fea2..1ffb7c243f94 100644 --- a/tests/libtest/cli_hx_upload.c +++ b/tests/libtest/cli_hx_upload.c @@ -72,7 +72,7 @@ static size_t my_write_u_cb(char *buf, size_t nitems, size_t buflen, "pause_at=%" CURL_FORMAT_CURL_OFF_T "\n", t->idx, blen, t->recv_size, t->pause_at); if(!t->out) { - curl_msnprintf(t->filename, sizeof(t->filename)-1, "download_%zu.data", + curl_msnprintf(t->filename, sizeof(t->filename) - 1, "download_%zu.data", t->idx); t->out = curlx_fopen(t->filename, "wb"); if(!t->out) @@ -462,7 +462,6 @@ static CURLcode test_cli_hx_upload(const char *URL) } } - /* nothing happening, maintenance */ if(abort_paused) { /* abort paused transfers */ diff --git a/tests/libtest/cli_tls_session_reuse.c b/tests/libtest/cli_tls_session_reuse.c index aa56a0e28c66..a0e5901e5539 100644 --- a/tests/libtest/cli_tls_session_reuse.c +++ b/tests/libtest/cli_tls_session_reuse.c @@ -83,7 +83,6 @@ static CURL *tse_add_transfer(CURLM *multi, CURLSH *share, if(resolve) curl_easy_setopt(curl, CURLOPT_RESOLVE, resolve); - mc = curl_multi_add_handle(multi, curl); if(mc != CURLM_OK) { curl_mfprintf(stderr, "curl_multi_add_handle: %s\n", @@ -144,7 +143,7 @@ static CURLcode test_cli_tls_session_reuse(const char *URL) goto cleanup; } - curl_msnprintf(resolve_buf, sizeof(resolve_buf)-1, "%s:%s:127.0.0.1", + curl_msnprintf(resolve_buf, sizeof(resolve_buf) - 1, "%s:%s:127.0.0.1", host, port); resolve = curl_slist_append(resolve, resolve_buf); @@ -161,7 +160,6 @@ static CURLcode test_cli_tls_session_reuse(const char *URL) } curl_share_setopt(share, CURLSHOPT_SHARE, CURL_LOCK_DATA_SSL_SESSION); - if(!tse_add_transfer(multi, share, resolve, URL, http_version)) goto cleanup; ++ongoing; @@ -205,7 +203,7 @@ static CURLcode test_cli_tls_session_reuse(const char *URL) curl_easy_getinfo(msg->easy_handle, CURLINFO_XFER_ID, &xfer_id); curl_easy_getinfo(msg->easy_handle, CURLINFO_RESPONSE_CODE, &status); if(msg->data.result == CURLE_SEND_ERROR || - msg->data.result == CURLE_RECV_ERROR) { + msg->data.result == CURLE_RECV_ERROR) { /* We get these if the server had a GOAWAY in transit on * reusing a connection */ } diff --git a/tests/libtest/cli_upload_pausing.c b/tests/libtest/cli_upload_pausing.c index 042eddd7d7dc..cb94bcf0a83f 100644 --- a/tests/libtest/cli_upload_pausing.c +++ b/tests/libtest/cli_upload_pausing.c @@ -154,7 +154,7 @@ static CURLcode test_cli_upload_pausing(const char *URL) goto cleanup; } memset(&resolve, 0, sizeof(resolve)); - curl_msnprintf(resolve_buf, sizeof(resolve_buf)-1, "%s:%s:127.0.0.1", + curl_msnprintf(resolve_buf, sizeof(resolve_buf) - 1, "%s:%s:127.0.0.1", host, port); resolve = curl_slist_append(resolve, resolve_buf); diff --git a/tests/libtest/cli_ws_data.c b/tests/libtest/cli_ws_data.c index 2276f0c92ce1..35da27788683 100644 --- a/tests/libtest/cli_ws_data.c +++ b/tests/libtest/cli_ws_data.c @@ -27,10 +27,9 @@ #ifndef CURL_DISABLE_WEBSOCKETS -static CURLcode -test_ws_data_m2_check_recv(const struct curl_ws_frame *frame, - size_t r_offset, size_t nread, - size_t exp_len) +static CURLcode test_ws_data_m2_check_recv(const struct curl_ws_frame *frame, + size_t r_offset, size_t nread, + size_t exp_len) { if(!frame) return CURLE_OK; @@ -362,7 +361,6 @@ static CURLcode test_ws_data_m1_echo(const char *url, r = CURLE_RECV_ERROR; goto out; } - } curl_multi_remove_handle(multi, m1_ctx.curl); @@ -393,7 +391,6 @@ static CURLcode test_ws_data_m1_echo(const char *url, return r; } - static void test_ws_data_usage(const char *msg) { if(msg) diff --git a/tests/libtest/first.c b/tests/libtest/first.c index 2f6553088211..e384971c7efc 100644 --- a/tests/libtest/first.c +++ b/tests/libtest/first.c @@ -62,7 +62,7 @@ int unitfail; /* for unittests */ int coptind; const char *coptarg; -int cgetopt(int argc, const char * const argv[], const char *optstring) +int cgetopt(int argc, const char *const argv[], const char *optstring) { static int optpos = 1; int coptopt; @@ -204,7 +204,6 @@ void ws_close(CURL *curl) } #endif /* CURL_DISABLE_WEBSOCKETS */ - int main(int argc, const char **argv) { const char *URL = ""; diff --git a/tests/libtest/first.h b/tests/libtest/first.h index f5cbc6023783..5fa587686b56 100644 --- a/tests/libtest/first.h +++ b/tests/libtest/first.h @@ -79,7 +79,7 @@ extern struct curltime tv_test_start; /* for test timing */ extern int coptind; extern const char *coptarg; -int cgetopt(int argc, const char * const argv[], const char *optstring); +int cgetopt(int argc, const char *const argv[], const char *optstring); extern int select_wrapper(int nfds, fd_set *rd, fd_set *wr, fd_set *exc, struct timeval *tv); diff --git a/tests/libtest/lib1156.c b/tests/libtest/lib1156.c index 758f6e3f1ae9..1468b35e1cc7 100644 --- a/tests/libtest/lib1156.c +++ b/tests/libtest/lib1156.c @@ -96,27 +96,27 @@ static int onetest(CURL *curl, const char *url, const struct testparams *p, test_setopt(curl, CURLOPT_VERBOSE, 1L); test_setopt(curl, CURLOPT_RESUME_FROM, (p->flags & F_RESUME) ? 3L : 0L); test_setopt(curl, CURLOPT_RANGE, !(p->flags & F_RESUME) ? - "3-1000000": (char *)NULL); + "3-1000000" : (char *)NULL); test_setopt(curl, CURLOPT_FAILONERROR, (p->flags & F_FAIL) ? 1L : 0L); hasbody = 0; res = curl_easy_perform(curl); if(res != p->res) { curl_mprintf("%zu: bad error code (%d): resume=%s, fail=%s, http416=%s, " "content-range=%s, expected=%d\n", num, res, - (p->flags & F_RESUME) ? "yes": "no", - (p->flags & F_FAIL) ? "yes": "no", - (p->flags & F_HTTP416) ? "yes": "no", - (p->flags & F_CONTENTRANGE) ? "yes": "no", + (p->flags & F_RESUME) ? "yes" : "no", + (p->flags & F_FAIL) ? "yes" : "no", + (p->flags & F_HTTP416) ? "yes" : "no", + (p->flags & F_CONTENTRANGE) ? "yes" : "no", p->res); return 1; } if(hasbody && (p->flags & F_IGNOREBODY)) { curl_mprintf("body should be ignored and is not: resume=%s, fail=%s, " "http416=%s, content-range=%s\n", - (p->flags & F_RESUME) ? "yes": "no", - (p->flags & F_FAIL) ? "yes": "no", - (p->flags & F_HTTP416) ? "yes": "no", - (p->flags & F_CONTENTRANGE) ? "yes": "no"); + (p->flags & F_RESUME) ? "yes" : "no", + (p->flags & F_FAIL) ? "yes" : "no", + (p->flags & F_HTTP416) ? "yes" : "no", + (p->flags & F_CONTENTRANGE) ? "yes" : "no"); return 1; } return 0; diff --git a/tests/libtest/lib1308.c b/tests/libtest/lib1308.c index 6f7b9c264eef..6a7e71d7923d 100644 --- a/tests/libtest/lib1308.c +++ b/tests/libtest/lib1308.c @@ -26,7 +26,7 @@ static size_t print_httppost_callback(void *arg, const char *buf, size_t len) { fwrite(buf, len, 1, stdout); - (*(size_t *) arg) += len; + (*(size_t *)arg) += len; return len; } diff --git a/tests/libtest/lib1514.c b/tests/libtest/lib1514.c index fa0aa0742439..0ae61d41e88e 100644 --- a/tests/libtest/lib1514.c +++ b/tests/libtest/lib1514.c @@ -37,7 +37,7 @@ static size_t t1514_read_cb(char *ptr, size_t size, size_t nmemb, void *userp) { struct t1514_WriteThis *pooh = (struct t1514_WriteThis *)userp; - if(size*nmemb < 1) + if(size * nmemb < 1) return 0; if(pooh->sizeleft) { diff --git a/tests/libtest/lib1517.c b/tests/libtest/lib1517.c index cebdeab0a1b4..ab18efe11314 100644 --- a/tests/libtest/lib1517.c +++ b/tests/libtest/lib1517.c @@ -98,7 +98,6 @@ static CURLcode test_lib1517(const char *URL) /* detect HTTP error codes >= 400 */ /* test_setopt(curl, CURLOPT_FAILONERROR, 1L); */ - /* Perform the request, res will get the return code */ res = curl_easy_perform(curl); diff --git a/tests/libtest/lib1520.c b/tests/libtest/lib1520.c index 4cf54388eb1a..076ab564d016 100644 --- a/tests/libtest/lib1520.c +++ b/tests/libtest/lib1520.c @@ -46,7 +46,7 @@ static size_t t1520_read_cb(char *ptr, size_t size, size_t nmemb, void *userp) struct upload_status *upload_ctx = (struct upload_status *)userp; const char *data; - if((size == 0) || (nmemb == 0) || ((size*nmemb) < 1)) { + if((size == 0) || (nmemb == 0) || ((size * nmemb) < 1)) { return 0; } diff --git a/tests/libtest/lib1522.c b/tests/libtest/lib1522.c index 1ac2332e8121..e90b39bc5676 100644 --- a/tests/libtest/lib1522.c +++ b/tests/libtest/lib1522.c @@ -78,7 +78,7 @@ static CURLcode test_lib1522(const char *URL) curl_mprintf("uploadSize = %" CURL_FORMAT_CURL_OFF_T "\n", uploadSize); - if((size_t) uploadSize == sizeof(g_Data)) { + if((size_t)uploadSize == sizeof(g_Data)) { curl_mprintf("!!!!!!!!!! PASS\n"); } else { diff --git a/tests/libtest/lib1523.c b/tests/libtest/lib1523.c index 711aa3f7140f..23ec23d82305 100644 --- a/tests/libtest/lib1523.c +++ b/tests/libtest/lib1523.c @@ -41,7 +41,7 @@ static size_t t1523_write_cb(char *d, size_t n, size_t l, void *p) /* take care of the data here, ignored in this example */ (void)d; (void)p; - return n*l; + return n * l; } static CURLcode run(CURL *curl, long limit, long time) diff --git a/tests/libtest/lib1525.c b/tests/libtest/lib1525.c index c9a1e1514f80..66c18df21e40 100644 --- a/tests/libtest/lib1525.c +++ b/tests/libtest/lib1525.c @@ -34,7 +34,7 @@ static const char t1525_testdata[] = "Hello Cloud!\n"; static size_t t1525_read_cb(char *ptr, size_t size, size_t nmemb, void *stream) { - size_t amount = nmemb * size; /* Total bytes curl wants */ + size_t amount = nmemb * size; /* Total bytes curl wants */ if(amount < strlen(t1525_testdata)) { return strlen(t1525_testdata); } diff --git a/tests/libtest/lib1526.c b/tests/libtest/lib1526.c index 031f8bfd2746..400544b8e038 100644 --- a/tests/libtest/lib1526.c +++ b/tests/libtest/lib1526.c @@ -33,7 +33,7 @@ static const char t1526_testdata[] = "Hello Cloud!\n"; static size_t t1526_read_cb(char *ptr, size_t size, size_t nmemb, void *stream) { - size_t amount = nmemb * size; /* Total bytes curl wants */ + size_t amount = nmemb * size; /* Total bytes curl wants */ if(amount < strlen(t1526_testdata)) { return strlen(t1526_testdata); } diff --git a/tests/libtest/lib1527.c b/tests/libtest/lib1527.c index 1d9a5821324b..e55672a3c0cc 100644 --- a/tests/libtest/lib1527.c +++ b/tests/libtest/lib1527.c @@ -33,7 +33,7 @@ static const char t1527_testdata[] = "Hello Cloud!\n"; static size_t t1527_read_cb(char *ptr, size_t size, size_t nmemb, void *stream) { - size_t amount = nmemb * size; /* Total bytes curl wants */ + size_t amount = nmemb * size; /* Total bytes curl wants */ if(amount < strlen(t1527_testdata)) { return strlen(t1527_testdata); } diff --git a/tests/libtest/lib1533.c b/tests/libtest/lib1533.c index a2d541c4124f..b859ee36649c 100644 --- a/tests/libtest/lib1533.c +++ b/tests/libtest/lib1533.c @@ -119,7 +119,6 @@ static CURLcode perform_and_check_connections(CURL *curl, return TEST_ERR_SUCCESS; } - static CURLcode test_lib1533(const char *URL) { struct cb_data data; diff --git a/tests/libtest/lib1534.c b/tests/libtest/lib1534.c index 377df3b2fe19..94a02c2986b1 100644 --- a/tests/libtest/lib1534.c +++ b/tests/libtest/lib1534.c @@ -36,7 +36,7 @@ static CURLcode test_lib1534(const char *URL) easy_init(curl); /* Test that a filetime is properly initialized on curl_easy_init. - */ + */ res = curl_easy_getinfo(curl, CURLINFO_FILETIME, &filetime); if(res) { @@ -65,7 +65,7 @@ static CURLcode test_lib1534(const char *URL) } /* Test that a filetime is properly set after receiving an HTTP resource. - */ + */ res = curl_easy_getinfo(curl, CURLINFO_FILETIME, &filetime); if(res) { @@ -83,7 +83,7 @@ static CURLcode test_lib1534(const char *URL) } /* Test that a filetime is properly initialized on curl_easy_duphandle. - */ + */ dupe = curl_easy_duphandle(curl); if(!dupe) { @@ -109,7 +109,7 @@ static CURLcode test_lib1534(const char *URL) } /* Test that a filetime is properly initialized on curl_easy_reset. - */ + */ curl_easy_reset(curl); diff --git a/tests/libtest/lib1535.c b/tests/libtest/lib1535.c index c49c3076dfee..a9480429faaf 100644 --- a/tests/libtest/lib1535.c +++ b/tests/libtest/lib1535.c @@ -36,7 +36,7 @@ static CURLcode test_lib1535(const char *URL) easy_init(curl); /* Test that protocol is properly initialized on curl_easy_init. - */ + */ res = curl_easy_getinfo(curl, CURLINFO_PROTOCOL, &protocol); @@ -65,7 +65,7 @@ static CURLcode test_lib1535(const char *URL) } /* Test that a protocol is properly set after receiving an HTTP resource. - */ + */ res = curl_easy_getinfo(curl, CURLINFO_PROTOCOL, &protocol); @@ -85,7 +85,7 @@ static CURLcode test_lib1535(const char *URL) } /* Test that a protocol is properly initialized on curl_easy_duphandle. - */ + */ dupe = curl_easy_duphandle(curl); if(!dupe) { @@ -112,7 +112,7 @@ static CURLcode test_lib1535(const char *URL) } /* Test that a protocol is properly initialized on curl_easy_reset. - */ + */ curl_easy_reset(curl); diff --git a/tests/libtest/lib1536.c b/tests/libtest/lib1536.c index f89b50a19583..f03e9d98ed8e 100644 --- a/tests/libtest/lib1536.c +++ b/tests/libtest/lib1536.c @@ -36,7 +36,7 @@ static CURLcode test_lib1536(const char *URL) easy_init(curl); /* Test that scheme is properly initialized on curl_easy_init. - */ + */ res = curl_easy_getinfo(curl, CURLINFO_SCHEME, &scheme); if(res) { @@ -64,7 +64,7 @@ static CURLcode test_lib1536(const char *URL) } /* Test that a scheme is properly set after receiving an HTTP resource. - */ + */ res = curl_easy_getinfo(curl, CURLINFO_SCHEME, &scheme); if(res) { @@ -83,7 +83,7 @@ static CURLcode test_lib1536(const char *URL) } /* Test that a scheme is properly initialized on curl_easy_duphandle. - */ + */ dupe = curl_easy_duphandle(curl); if(!dupe) { @@ -108,7 +108,7 @@ static CURLcode test_lib1536(const char *URL) } /* Test that a scheme is properly initialized on curl_easy_reset. - */ + */ curl_easy_reset(curl); diff --git a/tests/libtest/lib1559.c b/tests/libtest/lib1559.c index c6851918a685..30773add7356 100644 --- a/tests/libtest/lib1559.c +++ b/tests/libtest/lib1559.c @@ -25,7 +25,7 @@ static CURLcode test_lib1559(const char *URL) { - static const int EXCESSIVE = 10*1000*1000; + static const int EXCESSIVE = 10 * 1000 * 1000; CURLcode res = CURLE_OK; CURL *curl = NULL; @@ -43,7 +43,7 @@ static CURLcode test_lib1559(const char *URL) } memset(longurl, 'a', EXCESSIVE); - longurl[EXCESSIVE-1] = 0; + longurl[EXCESSIVE - 1] = 0; res = curl_easy_setopt(curl, CURLOPT_URL, longurl); curl_mprintf("CURLOPT_URL %d bytes URL == %d\n", diff --git a/tests/libtest/lib1560.c b/tests/libtest/lib1560.c index 2f6608108cca..d080d38aa87e 100644 --- a/tests/libtest/lib1560.c +++ b/tests/libtest/lib1560.c @@ -68,10 +68,10 @@ static int checkparts(CURLU *u, const char *in, const char *wanted, size_t n; rc = curl_url_get(u, parts[i].part, &p, getflags); if(!rc && p) { - curl_msnprintf(bufp, len, "%s%s", buf[0]?" | ":"", p); + curl_msnprintf(bufp, len, "%s%s", buf[0] ? " | " : "", p); } else - curl_msnprintf(bufp, len, "%s[%d]", buf[0]?" | ":"", rc); + curl_msnprintf(bufp, len, "%s[%d]", buf[0] ? " | " : "", rc); n = strlen(bufp); bufp += n; diff --git a/tests/libtest/lib1597.c b/tests/libtest/lib1597.c index a338a53944fb..0e86517eadb1 100644 --- a/tests/libtest/lib1597.c +++ b/tests/libtest/lib1597.c @@ -80,7 +80,7 @@ static CURLcode test_lib1597(const char *URL) n = 0; for(proto = curlinfo->protocols; *proto; proto++) { - if((size_t) n >= sizeof(protolist)) { + if((size_t)n >= sizeof(protolist)) { puts("protolist buffer too small\n"); res = TEST_ERR_FAILURE; goto test_cleanup; diff --git a/tests/libtest/lib1662.c b/tests/libtest/lib1662.c index 41a1bc0bd4bb..f1e7b55df414 100644 --- a/tests/libtest/lib1662.c +++ b/tests/libtest/lib1662.c @@ -34,7 +34,7 @@ static size_t t1662_read_cb(char *ptr, size_t size, size_t nmemb, void *userp) struct t1662_WriteThis *pooh = (struct t1662_WriteThis *)userp; size_t len = strlen(testdata); - if(size*nmemb < len) + if(size * nmemb < len) return 0; if(pooh->sizeleft) { diff --git a/tests/libtest/lib1915.c b/tests/libtest/lib1915.c index 367533aef64f..adb589a8c0fb 100644 --- a/tests/libtest/lib1915.c +++ b/tests/libtest/lib1915.c @@ -30,8 +30,7 @@ struct state { }; /* "read" is from the point of the library, it wants data from us */ -static CURLSTScode hstsread(CURL *curl, struct curl_hstsentry *e, - void *userp) +static CURLSTScode hstsread(CURL *curl, struct curl_hstsentry *e, void *userp) { struct entry { const char *name; diff --git a/tests/libtest/lib1919.c b/tests/libtest/lib1919.c index 79d31810a466..1a436b00cea3 100644 --- a/tests/libtest/lib1919.c +++ b/tests/libtest/lib1919.c @@ -33,9 +33,9 @@ static CURLcode test_lib1919(const char *URL) easy_init(curl); easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_BEARER); easy_setopt(curl, CURLOPT_XOAUTH2_BEARER, - "c4e448d652a961fda0ab64f882c8c161d5985f805d45d80c9ddca1"); + "c4e448d652a961fda0ab64f882c8c161d5985f805d45d80c9ddca1"); easy_setopt(curl, CURLOPT_SASL_AUTHZID, - "c4e448d652a961fda0ab64f882c8c161d5985f805d45d80c9ddca2"); + "c4e448d652a961fda0ab64f882c8c161d5985f805d45d80c9ddca2"); easy_setopt(curl, CURLOPT_URL, URL); for(i = 0; i < 2; i++) { diff --git a/tests/libtest/lib1940.c b/tests/libtest/lib1940.c index 75b8f7818c02..1d9975534ad9 100644 --- a/tests/libtest/lib1940.c +++ b/tests/libtest/lib1940.c @@ -28,7 +28,7 @@ static size_t t1940_write_cb(char *data, size_t n, size_t l, void *userp) /* take care of the data here, ignored in this example */ (void)data; (void)userp; - return n*l; + return n * l; } static void t1940_showem(CURL *curl, int header_request, unsigned int type) diff --git a/tests/libtest/lib1945.c b/tests/libtest/lib1945.c index 99044880cfe8..07a010951415 100644 --- a/tests/libtest/lib1945.c +++ b/tests/libtest/lib1945.c @@ -41,7 +41,7 @@ static size_t t1945_write_cb(char *data, size_t n, size_t l, void *userp) /* take care of the data here, ignored in this example */ (void)data; (void)userp; - return n*l; + return n * l; } static CURLcode test_lib1945(const char *URL) @@ -67,7 +67,7 @@ static CURLcode test_lib1945(const char *URL) if(res) { curl_mprintf("badness: %d\n", res); } - t1945_showem(curl, CURLH_CONNECT|CURLH_HEADER|CURLH_TRAILER|CURLH_1XX); + t1945_showem(curl, CURLH_CONNECT | CURLH_HEADER | CURLH_TRAILER | CURLH_1XX); test_cleanup: curl_easy_cleanup(curl); diff --git a/tests/libtest/lib1947.c b/tests/libtest/lib1947.c index acbc260aa1d5..43e4c274b825 100644 --- a/tests/libtest/lib1947.c +++ b/tests/libtest/lib1947.c @@ -28,7 +28,7 @@ static size_t t1947_write_cb(char *data, size_t n, size_t l, void *userp) /* ignore the data */ (void)data; (void)userp; - return n*l; + return n * l; } static CURLcode test_lib1947(const char *URL) @@ -56,8 +56,8 @@ static CURLcode test_lib1947(const char *URL) /* count the number of requests by reading the first header of each request. */ - origins = (CURLH_HEADER|CURLH_TRAILER|CURLH_CONNECT| - CURLH_1XX|CURLH_PSEUDO); + origins = CURLH_HEADER | CURLH_TRAILER | CURLH_CONNECT | CURLH_1XX | + CURLH_PSEUDO; do { h = curl_easy_nextheader(curl, origins, count, NULL); if(h) diff --git a/tests/libtest/lib1948.c b/tests/libtest/lib1948.c index 2a138ac69554..024080e3e491 100644 --- a/tests/libtest/lib1948.c +++ b/tests/libtest/lib1948.c @@ -23,15 +23,14 @@ ***************************************************************************/ #include "first.h" -typedef struct -{ +struct put_buffer { const char *buf; size_t len; -} put_buffer; +}; static size_t put_callback(char *ptr, size_t size, size_t nmemb, void *stream) { - put_buffer *putdata = (put_buffer *)stream; + struct put_buffer *putdata = (struct put_buffer *)stream; size_t totalsize = size * nmemb; size_t tocopy = (putdata->len < totalsize) ? putdata->len : totalsize; memcpy(ptr, putdata->buf, tocopy); @@ -45,7 +44,7 @@ static CURLcode test_lib1948(const char *URL) CURL *curl; CURLcode res = CURLE_OK; static const char *testput = "This is test PUT data\n"; - put_buffer pbuf; + struct put_buffer pbuf; curl_global_init(CURL_GLOBAL_DEFAULT); diff --git a/tests/libtest/lib1960.c b/tests/libtest/lib1960.c index 2dbdf5995fd3..ff8ad76bc12b 100644 --- a/tests/libtest/lib1960.c +++ b/tests/libtest/lib1960.c @@ -63,12 +63,11 @@ static int sockopt_cb(void *clientp, } #ifdef __AMIGA__ -#define my_inet_pton(x,y,z) inet_pton(x,(unsigned char *)y,z) +#define my_inet_pton(x, y, z) inet_pton(x, (unsigned char *)y, z) #else -#define my_inet_pton(x,y,z) inet_pton(x,y,z) +#define my_inet_pton(x, y, z) inet_pton(x, y, z) #endif - /* Expected args: URL IP PORT */ static CURLcode test_lib1960(const char *URL) { @@ -109,7 +108,8 @@ static CURLcode test_lib1960(const char *URL) goto test_cleanup; } - status = connect(client_fd, (struct sockaddr*)&serv_addr, sizeof(serv_addr)); + status = connect(client_fd, (struct sockaddr *)&serv_addr, + sizeof(serv_addr)); if(status < 0) { curl_mfprintf(stderr, "connection failed\n"); goto test_cleanup; diff --git a/tests/libtest/lib1977.c b/tests/libtest/lib1977.c index 10412f66c0c4..06ab698c365e 100644 --- a/tests/libtest/lib1977.c +++ b/tests/libtest/lib1977.c @@ -48,7 +48,6 @@ static CURLcode test_lib1977(const char *URL) goto test_cleanup; curl_mprintf("effective URL: %s\n", effective); - /* second transfer: set URL + query in the second CURLU handle */ curl_url_set(curlu_2, CURLUPART_URL, URL, CURLU_DEFAULT_SCHEME); curl_url_set(curlu_2, CURLUPART_QUERY, "foo", 0); @@ -64,7 +63,6 @@ static CURLcode test_lib1977(const char *URL) goto test_cleanup; curl_mprintf("effective URL: %s\n", effective); - /* third transfer: append extra query in the second CURLU handle, but do not set CURLOPT_CURLU again. this is to test that the contents of the handle is allowed to change between transfers and is used without having to set @@ -81,7 +79,6 @@ static CURLcode test_lib1977(const char *URL) goto test_cleanup; curl_mprintf("effective URL: %s\n", effective); - test_cleanup: curl_easy_cleanup(curl); curl_url_cleanup(curlu); diff --git a/tests/libtest/lib2023.c b/tests/libtest/lib2023.c index 1475deb2d3f8..660d528b2a37 100644 --- a/tests/libtest/lib2023.c +++ b/tests/libtest/lib2023.c @@ -90,7 +90,7 @@ static CURLcode test_lib2023(const char *URL) /* libauthretry */ long fallback_auth_scheme = parse_auth_name(libtest_arg3); if(main_auth_scheme == CURLAUTH_NONE || - fallback_auth_scheme == CURLAUTH_NONE) { + fallback_auth_scheme == CURLAUTH_NONE) { curl_mfprintf(stderr, "auth schemes not found on commandline\n"); return TEST_ERR_MAJOR_BAD; } diff --git a/tests/libtest/lib2032.c b/tests/libtest/lib2032.c index a733f34e6fc0..a9cb29857130 100644 --- a/tests/libtest/lib2032.c +++ b/tests/libtest/lib2032.c @@ -32,7 +32,7 @@ static CURLcode ntlmcb_res = CURLE_OK; static size_t callback(char *ptr, size_t size, size_t nmemb, void *data) { - ssize_t idx = ((CURL **) data) - ntlm_curls; + ssize_t idx = ((CURL **)data) - ntlm_curls; curl_socket_t sock; long longdata; CURLcode code; @@ -195,8 +195,8 @@ static CURLcode test_lib2032(const char *URL) /* libntlmconnect */ #else itimeout = (int)timeout; #endif - interval.tv_sec = itimeout/1000; - interval.tv_usec = (itimeout%1000)*1000; + interval.tv_sec = itimeout / 1000; + interval.tv_usec = (itimeout % 1000) * 1000; } else { interval.tv_sec = 0; diff --git a/tests/libtest/lib2402.c b/tests/libtest/lib2402.c index 58c1b6c431fe..49d87d1cd4f1 100644 --- a/tests/libtest/lib2402.c +++ b/tests/libtest/lib2402.c @@ -38,8 +38,7 @@ static CURLcode test_lib2402(const char *URL) (void)URL; - curl_msnprintf(dnsentry, sizeof(dnsentry), "localhost:%s:%s", - port, address); + curl_msnprintf(dnsentry, sizeof(dnsentry), "localhost:%s:%s", port, address); curl_mprintf("%s\n", dnsentry); slist = curl_slist_append(slist, dnsentry); if(!slist) { @@ -61,8 +60,7 @@ static CURLcode test_lib2402(const char *URL) easy_init(curl[i]); /* specify target */ curl_msnprintf(target_url, sizeof(target_url), - "https://localhost:%s/path/2402%04zu", - port, i + 1); + "https://localhost:%s/path/2402%04zu", port, i + 1); target_url[sizeof(target_url) - 1] = '\0'; easy_setopt(curl[i], CURLOPT_URL, target_url); /* go http2 */ diff --git a/tests/libtest/lib2404.c b/tests/libtest/lib2404.c index 93a3ef926f40..c20259744771 100644 --- a/tests/libtest/lib2404.c +++ b/tests/libtest/lib2404.c @@ -38,8 +38,7 @@ static CURLcode test_lib2404(const char *URL) (void)URL; - curl_msnprintf(dnsentry, sizeof(dnsentry), "localhost:%s:%s", - port, address); + curl_msnprintf(dnsentry, sizeof(dnsentry), "localhost:%s:%s", port, address); curl_mprintf("%s\n", dnsentry); slist = curl_slist_append(slist, dnsentry); if(!slist) { @@ -61,8 +60,7 @@ static CURLcode test_lib2404(const char *URL) easy_init(curl[i]); /* specify target */ curl_msnprintf(target_url, sizeof(target_url), - "https://localhost:%s/path/2404%04zu", - port, i + 1); + "https://localhost:%s/path/2404%04zu", port, i + 1); target_url[sizeof(target_url) - 1] = '\0'; easy_setopt(curl[i], CURLOPT_URL, target_url); /* go http2 */ diff --git a/tests/libtest/lib2405.c b/tests/libtest/lib2405.c index 97d0d5d231e5..89ab659bdd4e 100644 --- a/tests/libtest/lib2405.c +++ b/tests/libtest/lib2405.c @@ -66,9 +66,10 @@ enum { TEST_USE_HTTP2_MPLEX }; -static size_t emptyWriteFunc(char *ptr, size_t size, size_t nmemb, - void *data) { - (void)ptr; (void)data; +static size_t emptyWriteFunc(char *ptr, size_t size, size_t nmemb, void *data) +{ + (void)ptr; + (void)data; return size * nmemb; } diff --git a/tests/libtest/lib2502.c b/tests/libtest/lib2502.c index 4b5e0ef6833e..48a8a93f0f8e 100644 --- a/tests/libtest/lib2502.c +++ b/tests/libtest/lib2502.c @@ -40,8 +40,7 @@ static CURLcode test_lib2502(const char *URL) (void)URL; - curl_msnprintf(dnsentry, sizeof(dnsentry), "localhost:%s:%s", - port, address); + curl_msnprintf(dnsentry, sizeof(dnsentry), "localhost:%s:%s", port, address); curl_mprintf("%s\n", dnsentry); slist = curl_slist_append(slist, dnsentry); if(!slist) { @@ -63,8 +62,7 @@ static CURLcode test_lib2502(const char *URL) easy_init(curl[i]); /* specify target */ curl_msnprintf(target_url, sizeof(target_url), - "https://localhost:%s/path/2502%04zu", - port, i + 1); + "https://localhost:%s/path/2502%04zu", port, i + 1); target_url[sizeof(target_url) - 1] = '\0'; easy_setopt(curl[i], CURLOPT_URL, target_url); /* go http2 */ diff --git a/tests/libtest/lib2700.c b/tests/libtest/lib2700.c index 1760d243ea1a..1c38f073d58c 100644 --- a/tests/libtest/lib2700.c +++ b/tests/libtest/lib2700.c @@ -120,8 +120,7 @@ static CURLcode send_chunk(CURL *curl, int flags, const char *buffer, size_t nsent; retry: - res = curl_ws_send(curl, buffer + *offset, size - *offset, &nsent, 0, - flags); + res = curl_ws_send(curl, buffer + *offset, size - *offset, &nsent, 0, flags); if(res == CURLE_AGAIN) { assert(nsent == 0); goto retry; diff --git a/tests/libtest/lib3033.c b/tests/libtest/lib3033.c index 428de8afc31d..e2f0099615f5 100644 --- a/tests/libtest/lib3033.c +++ b/tests/libtest/lib3033.c @@ -33,8 +33,7 @@ static CURLcode t3033_req_test(CURLM *multi, CURL *curl, int still_running = 0; if(index == 1) { - curl_multi_setopt(multi, CURLMOPT_NETWORK_CHANGED, - CURLMNWC_CLEAR_CONNS); + curl_multi_setopt(multi, CURLMOPT_NETWORK_CHANGED, CURLMNWC_CLEAR_CONNS); curl_mprintf("[1] signal network change\n"); } else { diff --git a/tests/libtest/lib3102.c b/tests/libtest/lib3102.c index 72da47551e40..094b32c1fc56 100644 --- a/tests/libtest/lib3102.c +++ b/tests/libtest/lib3102.c @@ -47,11 +47,11 @@ static bool is_chain_in_order(struct curl_certinfo *cert_info) static const char issuer_prefix[] = "Issuer:"; static const char subject_prefix[] = "Subject:"; - if(!strncmp(slist->data, issuer_prefix, sizeof(issuer_prefix)-1)) { - issuer = slist->data + sizeof(issuer_prefix)-1; + if(!strncmp(slist->data, issuer_prefix, sizeof(issuer_prefix) - 1)) { + issuer = slist->data + sizeof(issuer_prefix) - 1; } - if(!strncmp(slist->data, subject_prefix, sizeof(subject_prefix)-1)) { - subject = slist->data + sizeof(subject_prefix)-1; + if(!strncmp(slist->data, subject_prefix, sizeof(subject_prefix) - 1)) { + subject = slist->data + sizeof(subject_prefix) - 1; } } @@ -80,7 +80,7 @@ static bool is_chain_in_order(struct curl_certinfo *cert_info) return true; } -static size_t wrfu(void *ptr, size_t size, size_t nmemb, void *stream) +static size_t wrfu(void *ptr, size_t size, size_t nmemb, void *stream) { (void)stream; (void)ptr; diff --git a/tests/libtest/lib3207.c b/tests/libtest/lib3207.c index 7757643a269b..8b20b311ebbf 100644 --- a/tests/libtest/lib3207.c +++ b/tests/libtest/lib3207.c @@ -116,7 +116,7 @@ static unsigned int test_thread(void *ptr) static void t3207_test_lock(CURL *curl, curl_lock_data data, curl_lock_access laccess, void *useptr) { - curl_mutex_t *mutexes = (curl_mutex_t*) useptr; + curl_mutex_t *mutexes = (curl_mutex_t *)useptr; (void)curl; (void)laccess; Curl_mutex_acquire(&mutexes[data]); @@ -124,7 +124,7 @@ static void t3207_test_lock(CURL *curl, curl_lock_data data, static void t3207_test_unlock(CURL *curl, curl_lock_data data, void *useptr) { - curl_mutex_t *mutexes = (curl_mutex_t*) useptr; + curl_mutex_t *mutexes = (curl_mutex_t *)useptr; (void)curl; Curl_mutex_release(&mutexes[data]); } @@ -175,7 +175,7 @@ static CURLcode test_lib3207(const char *URL) { CURLcode res = CURLE_OK; size_t i; - CURLSH* share; + CURLSH *share; struct Ctx ctx[THREAD_SIZE]; curl_global_init(CURL_GLOBAL_ALL); diff --git a/tests/libtest/lib505.c b/tests/libtest/lib505.c index b28a01a9ce05..e33614fc58a8 100644 --- a/tests/libtest/lib505.c +++ b/tests/libtest/lib505.c @@ -127,8 +127,7 @@ static CURLcode test_lib505(const char *URL) test_setopt(curl, CURLOPT_READDATA, hd_src); /* and give the size of the upload (optional) */ - test_setopt(curl, CURLOPT_INFILESIZE_LARGE, - (curl_off_t)file_info.st_size); + test_setopt(curl, CURLOPT_INFILESIZE_LARGE, (curl_off_t)file_info.st_size); /* Now run off and do what you have been told! */ res = curl_easy_perform(curl); diff --git a/tests/libtest/lib506.c b/tests/libtest/lib506.c index 3d2a3556fdb0..f5c44c3e4726 100644 --- a/tests/libtest/lib506.c +++ b/tests/libtest/lib506.c @@ -52,21 +52,21 @@ static void t506_test_lock(CURL *curl, curl_lock_data data, (void)laccess; switch(data) { - case CURL_LOCK_DATA_SHARE: - what = "share"; - locknum = 0; - break; - case CURL_LOCK_DATA_DNS: - what = "dns"; - locknum = 1; - break; - case CURL_LOCK_DATA_COOKIE: - what = "cookie"; - locknum = 2; - break; - default: - curl_mfprintf(stderr, "lock: no such data: %d\n", data); - return; + case CURL_LOCK_DATA_SHARE: + what = "share"; + locknum = 0; + break; + case CURL_LOCK_DATA_DNS: + what = "dns"; + locknum = 1; + break; + case CURL_LOCK_DATA_COOKIE: + what = "cookie"; + locknum = 2; + break; + default: + curl_mfprintf(stderr, "lock: no such data: %d\n", data); + return; } /* detect locking of locked locks */ @@ -88,21 +88,21 @@ static void t506_test_unlock(CURL *curl, curl_lock_data data, void *useptr) int locknum; (void)curl; switch(data) { - case CURL_LOCK_DATA_SHARE: - what = "share"; - locknum = 0; - break; - case CURL_LOCK_DATA_DNS: - what = "dns"; - locknum = 1; - break; - case CURL_LOCK_DATA_COOKIE: - what = "cookie"; - locknum = 2; - break; - default: - curl_mfprintf(stderr, "unlock: no such data: %d\n", data); - return; + case CURL_LOCK_DATA_SHARE: + what = "share"; + locknum = 0; + break; + case CURL_LOCK_DATA_DNS: + what = "dns"; + locknum = 1; + break; + case CURL_LOCK_DATA_COOKIE: + what = "cookie"; + locknum = 2; + break; + default: + curl_mfprintf(stderr, "unlock: no such data: %d\n", data); + return; } /* detect unlocking of unlocked locks */ @@ -128,7 +128,7 @@ static void *t506_test_fire(void *ptr) { CURLcode code; struct curl_slist *headers; - struct t506_Tdata *tdata = (struct t506_Tdata*)ptr; + struct t506_Tdata *tdata = (struct t506_Tdata *)ptr; CURL *curl; curl = curl_easy_init(); @@ -138,9 +138,9 @@ static void *t506_test_fire(void *ptr) } headers = sethost(NULL); - curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers); - curl_easy_setopt(curl, CURLOPT_URL, tdata->url); + curl_easy_setopt(curl, CURLOPT_URL, tdata->url); curl_easy_setopt(curl, CURLOPT_COOKIEFILE, ""); curl_mprintf("CURLOPT_SHARE\n"); curl_easy_setopt(curl, CURLOPT_SHARE, tdata->share); @@ -233,40 +233,38 @@ static CURLcode test_lib506(const char *URL) return TEST_ERR_MAJOR_BAD; } curl_mprintf("CURLOPT_SHARE\n"); - test_setopt(curl, CURLOPT_SHARE, share); + test_setopt(curl, CURLOPT_SHARE, share); curl_mprintf("CURLOPT_COOKIELIST injected_and_clobbered\n"); test_setopt(curl, CURLOPT_COOKIELIST, - "Set-Cookie: injected_and_clobbered=yes; " - "domain=host.foo.com; expires=Sat Feb 2 11:56:27 GMT 2030"); + "Set-Cookie: injected_and_clobbered=yes; " + "domain=host.foo.com; expires=Sat Feb 2 11:56:27 GMT 2030"); curl_mprintf("CURLOPT_COOKIELIST ALL\n"); test_setopt(curl, CURLOPT_COOKIELIST, "ALL"); curl_mprintf("CURLOPT_COOKIELIST session\n"); test_setopt(curl, CURLOPT_COOKIELIST, "Set-Cookie: session=elephants"); curl_mprintf("CURLOPT_COOKIELIST injected\n"); test_setopt(curl, CURLOPT_COOKIELIST, - "Set-Cookie: injected=yes; domain=host.foo.com; " - "expires=Sat Feb 2 11:56:27 GMT 2030"); + "Set-Cookie: injected=yes; domain=host.foo.com; " + "expires=Sat Feb 2 11:56:27 GMT 2030"); curl_mprintf("CURLOPT_COOKIELIST SESS\n"); test_setopt(curl, CURLOPT_COOKIELIST, "SESS"); curl_mprintf("CLEANUP\n"); curl_easy_cleanup(curl); - /* start treads */ for(i = 1; i <= THREADS; i++) { /* set thread data */ - tdata.url = tutil_suburl(URL, i); /* must be curl_free()d */ + tdata.url = tutil_suburl(URL, i); /* must be curl_free()d */ tdata.share = share; /* simulate thread, direct call of "thread" function */ - curl_mprintf("*** run %d\n",i); + curl_mprintf("*** run %d\n", i); t506_test_fire(&tdata); curl_free(tdata.url); } - /* fetch another one and save cookies */ curl_mprintf("*** run %d\n", i); curl = curl_easy_init(); @@ -280,11 +278,11 @@ static CURLcode test_lib506(const char *URL) url = tutil_suburl(URL, i); headers = sethost(NULL); test_setopt(curl, CURLOPT_HTTPHEADER, headers); - test_setopt(curl, CURLOPT_URL, url); + test_setopt(curl, CURLOPT_URL, url); curl_mprintf("CURLOPT_SHARE\n"); - test_setopt(curl, CURLOPT_SHARE, share); + test_setopt(curl, CURLOPT_SHARE, share); curl_mprintf("CURLOPT_COOKIEJAR\n"); - test_setopt(curl, CURLOPT_COOKIEJAR, jar); + test_setopt(curl, CURLOPT_COOKIEJAR, jar); curl_mprintf("CURLOPT_COOKIELIST FLUSH\n"); test_setopt(curl, CURLOPT_COOKIELIST, "FLUSH"); @@ -307,9 +305,9 @@ static CURLcode test_lib506(const char *URL) url = tutil_suburl(URL, i); headers = sethost(NULL); test_setopt(curl, CURLOPT_HTTPHEADER, headers); - test_setopt(curl, CURLOPT_URL, url); + test_setopt(curl, CURLOPT_URL, url); curl_mprintf("CURLOPT_SHARE\n"); - test_setopt(curl, CURLOPT_SHARE, share); + test_setopt(curl, CURLOPT_SHARE, share); curl_mprintf("CURLOPT_COOKIELIST ALL\n"); test_setopt(curl, CURLOPT_COOKIELIST, "ALL"); curl_mprintf("CURLOPT_COOKIEJAR\n"); diff --git a/tests/libtest/lib508.c b/tests/libtest/lib508.c index 697505150056..144f967f4a84 100644 --- a/tests/libtest/lib508.c +++ b/tests/libtest/lib508.c @@ -32,7 +32,7 @@ static size_t t508_read_cb(char *ptr, size_t size, size_t nmemb, void *userp) { struct t508_WriteThis *pooh = (struct t508_WriteThis *)userp; - if(size*nmemb < 1) + if(size * nmemb < 1) return 0; if(pooh->sizeleft) { diff --git a/tests/libtest/lib509.c b/tests/libtest/lib509.c index b5a0c583e072..c065eb87c891 100644 --- a/tests/libtest/lib509.c +++ b/tests/libtest/lib509.c @@ -74,7 +74,6 @@ static void custom_free(void *ptr) free(ptr); } - static CURLcode test_lib509(const char *URL) { static const unsigned char a[] = {0x2f, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, diff --git a/tests/libtest/lib510.c b/tests/libtest/lib510.c index d2df0eaf203b..8d4b6ce15512 100644 --- a/tests/libtest/lib510.c +++ b/tests/libtest/lib510.c @@ -40,14 +40,14 @@ static size_t t510_read_cb(char *ptr, size_t size, size_t nmemb, void *userp) struct t510_WriteThis *pooh = (struct t510_WriteThis *)userp; const char *data; - if(size*nmemb < 1) + if(size * nmemb < 1) return 0; data = testpost[pooh->counter]; if(data) { size_t len = strlen(data); - if(size*nmemb < len) { + if(size * nmemb < len) { curl_mfprintf(stderr, "read buffer is too small to run test\n"); return 0; } diff --git a/tests/libtest/lib526.c b/tests/libtest/lib526.c index a4d5ab6b1a1e..04e8759c1a71 100644 --- a/tests/libtest/lib526.c +++ b/tests/libtest/lib526.c @@ -155,7 +155,6 @@ static CURLcode test_lib526(const char *URL) curl_multi_cleanup(multi); curl_global_cleanup(); - } else if(testnum == 532) { /* undocumented cleanup sequence - type UB */ diff --git a/tests/libtest/lib530.c b/tests/libtest/lib530.c index 429a4869f5c9..f32d64b3033f 100644 --- a/tests/libtest/lib530.c +++ b/tests/libtest/lib530.c @@ -229,7 +229,7 @@ static ssize_t t530_getMicroSecondTimeout(struct curltime *timeout) /** * Update a fd_set with all of the sockets in use. */ -static void t530_updateFdSet(struct t530_Sockets *sockets, fd_set* fdset, +static void t530_updateFdSet(struct t530_Sockets *sockets, fd_set *fdset, curl_socket_t *maxFd) { int i; diff --git a/tests/libtest/lib536.c b/tests/libtest/lib536.c index 4810aba83fc3..82d839d772ea 100644 --- a/tests/libtest/lib536.c +++ b/tests/libtest/lib536.c @@ -27,8 +27,7 @@ static void proxystat(CURL *curl) { long wasproxy; if(!curl_easy_getinfo(curl, CURLINFO_USED_PROXY, &wasproxy)) { - curl_mprintf("This %sthe proxy\n", wasproxy ? "used ": - "DID NOT use "); + curl_mprintf("This %sthe proxy\n", wasproxy ? "used " : "DID NOT use "); } } diff --git a/tests/libtest/lib537.c b/tests/libtest/lib537.c index 8027a09c0286..31c5e306125a 100644 --- a/tests/libtest/lib537.c +++ b/tests/libtest/lib537.c @@ -118,7 +118,7 @@ static int t537_test_rlimit(int keep_open) /* If the OS allows a HUGE number of open files, we do not run. * Modern debian sid reports a limit of 134217724 and this tests * takes minutes. */ -#define LIMIT_CAP (256*1024) +#define LIMIT_CAP (256 * 1024) if(rl.rlim_cur > LIMIT_CAP) { curl_mfprintf(stderr, "soft limit above %ld, not running\n", (long)LIMIT_CAP); diff --git a/tests/libtest/lib540.c b/tests/libtest/lib540.c index 5e8890d98421..21886cfc74c5 100644 --- a/tests/libtest/lib540.c +++ b/tests/libtest/lib540.c @@ -138,8 +138,8 @@ static CURLcode loop(int num, CURLM *multi, const char *url, #else itimeout = (int)L; #endif - T.tv_sec = itimeout/1000; - T.tv_usec = (itimeout%1000)*1000; + T.tv_sec = itimeout / 1000; + T.tv_usec = (itimeout % 1000) * 1000; } else { T.tv_sec = 5; diff --git a/tests/libtest/lib547.c b/tests/libtest/lib547.c index 8f51fef088d8..797e6f1fc6b6 100644 --- a/tests/libtest/lib547.c +++ b/tests/libtest/lib547.c @@ -29,7 +29,7 @@ #include "first.h" static const char t547_uploadthis[] = "this is the blurb we want to upload\n"; -#define T547_DATALEN (sizeof(t547_uploadthis)-1) +#define T547_DATALEN (sizeof(t547_uploadthis) - 1) static size_t t547_read_cb(char *ptr, size_t size, size_t nmemb, void *clientp) { diff --git a/tests/libtest/lib552.c b/tests/libtest/lib552.c index 403ad6fec196..79cd877b1baa 100644 --- a/tests/libtest/lib552.c +++ b/tests/libtest/lib552.c @@ -35,10 +35,10 @@ static char databuf[70000]; /* MUST be more than 64k OR static size_t t552_read_cb(char *ptr, size_t size, size_t nmemb, void *stream) { - size_t amount = nmemb * size; /* Total bytes curl wants */ - size_t available = sizeof(databuf) - current_offset; /* What we have to - give */ - size_t given = amount < available ? amount : available; /* What is given */ + size_t amount = nmemb * size; /* Total bytes curl wants */ + size_t available = sizeof(databuf) - current_offset; /* What we have to + give */ + size_t given = amount < available ? amount : available; /* What is given */ (void)stream; memcpy(ptr, databuf + current_offset, given); current_offset += given; diff --git a/tests/libtest/lib554.c b/tests/libtest/lib554.c index dd8c690ddbc3..0c8349159e55 100644 --- a/tests/libtest/lib554.c +++ b/tests/libtest/lib554.c @@ -32,7 +32,7 @@ static size_t t554_read_cb(char *ptr, size_t size, size_t nmemb, void *userp) { struct t554_WriteThis *pooh = (struct t554_WriteThis *)userp; - if(size*nmemb < 1) + if(size * nmemb < 1) return 0; if(pooh->sizeleft) { diff --git a/tests/libtest/lib555.c b/tests/libtest/lib555.c index 005fefe72ff8..c9522f5eaeb5 100644 --- a/tests/libtest/lib555.c +++ b/tests/libtest/lib555.c @@ -33,7 +33,7 @@ #include "first.h" static const char t555_uploadthis[] = "this is the blurb we want to upload\n"; -#define T555_DATALEN (sizeof(t555_uploadthis)-1) +#define T555_DATALEN (sizeof(t555_uploadthis) - 1) static size_t t555_read_cb(char *ptr, size_t size, size_t nmemb, void *clientp) { diff --git a/tests/libtest/lib557.c b/tests/libtest/lib557.c index fa1ee2fa2fbc..9c4f7f9b9f3b 100644 --- a/tests/libtest/lib557.c +++ b/tests/libtest/lib557.c @@ -48,56 +48,48 @@ #define BUFSZ 256 - struct unsshort_st { unsigned short num; /* unsigned short */ const char *expected; /* expected string */ char result[BUFSZ]; /* result string */ }; - struct sigshort_st { short num; /* signed short */ const char *expected; /* expected string */ char result[BUFSZ]; /* result string */ }; - struct unsint_st { unsigned int num; /* unsigned int */ const char *expected; /* expected string */ char result[BUFSZ]; /* result string */ }; - struct sigint_st { int num; /* signed int */ const char *expected; /* expected string */ char result[BUFSZ]; /* result string */ }; - struct unslong_st { unsigned long num; /* unsigned long */ const char *expected; /* expected string */ char result[BUFSZ]; /* result string */ }; - struct siglong_st { long num; /* signed long */ const char *expected; /* expected string */ char result[BUFSZ]; /* result string */ }; - struct curloff_st { curl_off_t num; /* curl_off_t */ const char *expected; /* expected string */ char result[BUFSZ]; /* result string */ }; - static struct unsshort_st us_test[1 + 100]; static struct sigshort_st ss_test[1 + 100]; static struct unsint_st ui_test[1 + 100]; @@ -106,7 +98,6 @@ static struct unslong_st ul_test[1 + 100]; static struct siglong_st sl_test[1 + 100]; static struct curloff_st co_test[1 + 100]; - static int test_unsigned_short_formatting(void) { int i, j; @@ -136,7 +127,7 @@ static int test_unsigned_short_formatting(void) for(j = 0; j < BUFSZ; j++) us_test[i].result[j] = 'X'; - us_test[i].result[BUFSZ-1] = '\0'; + us_test[i].result[BUFSZ - 1] = '\0'; (void)curl_msprintf(us_test[i].result, "%hu", us_test[i].num); @@ -148,7 +139,6 @@ static int test_unsigned_short_formatting(void) i, us_test[i].expected, us_test[i].result); failed++; } - } if(!failed) @@ -159,7 +149,6 @@ static int test_unsigned_short_formatting(void) return failed; } - static int test_signed_short_formatting(void) { int i, j; @@ -211,7 +200,7 @@ static int test_signed_short_formatting(void) for(j = 0; j < BUFSZ; j++) ss_test[i].result[j] = 'X'; - ss_test[i].result[BUFSZ-1] = '\0'; + ss_test[i].result[BUFSZ - 1] = '\0'; (void)curl_msprintf(ss_test[i].result, "%hd", ss_test[i].num); @@ -222,7 +211,6 @@ static int test_signed_short_formatting(void) i, ss_test[i].expected, ss_test[i].result); failed++; } - } if(!failed) @@ -233,7 +221,6 @@ static int test_signed_short_formatting(void) return failed; } - static int test_unsigned_int_formatting(void) { int i, j; @@ -361,7 +348,7 @@ static int test_unsigned_int_formatting(void) for(j = 0; j < BUFSZ; j++) ui_test[i].result[j] = 'X'; - ui_test[i].result[BUFSZ-1] = '\0'; + ui_test[i].result[BUFSZ - 1] = '\0'; (void)curl_msprintf(ui_test[i].result, "%u", ui_test[i].num); @@ -372,7 +359,6 @@ static int test_unsigned_int_formatting(void) i, ui_test[i].expected, ui_test[i].result); failed++; } - } if(!failed) @@ -383,7 +369,6 @@ static int test_unsigned_int_formatting(void) return failed; } - static int test_signed_int_formatting(void) { int i, j; @@ -589,7 +574,7 @@ static int test_signed_int_formatting(void) for(j = 0; j < BUFSZ; j++) si_test[i].result[j] = 'X'; - si_test[i].result[BUFSZ-1] = '\0'; + si_test[i].result[BUFSZ - 1] = '\0'; (void)curl_msprintf(si_test[i].result, "%d", si_test[i].num); @@ -600,7 +585,6 @@ static int test_signed_int_formatting(void) i, si_test[i].expected, si_test[i].result); failed++; } - } if(!failed) @@ -611,7 +595,6 @@ static int test_signed_int_formatting(void) return failed; } - static int test_unsigned_long_formatting(void) { int i, j; @@ -738,7 +721,7 @@ static int test_unsigned_long_formatting(void) for(j = 0; j < BUFSZ; j++) ul_test[i].result[j] = 'X'; - ul_test[i].result[BUFSZ-1] = '\0'; + ul_test[i].result[BUFSZ - 1] = '\0'; (void)curl_msprintf(ul_test[i].result, "%lu", ul_test[i].num); @@ -749,7 +732,6 @@ static int test_unsigned_long_formatting(void) i, ul_test[i].expected, ul_test[i].result); failed++; } - } if(!failed) @@ -760,7 +742,6 @@ static int test_unsigned_long_formatting(void) return failed; } - static int test_signed_long_formatting(void) { int i, j; @@ -966,7 +947,7 @@ static int test_signed_long_formatting(void) for(j = 0; j < BUFSZ; j++) sl_test[i].result[j] = 'X'; - sl_test[i].result[BUFSZ-1] = '\0'; + sl_test[i].result[BUFSZ - 1] = '\0'; (void)curl_msprintf(sl_test[i].result, "%ld", sl_test[i].num); @@ -977,7 +958,6 @@ static int test_signed_long_formatting(void) i, sl_test[i].expected, sl_test[i].result); failed++; } - } if(!failed) @@ -988,7 +968,6 @@ static int test_signed_long_formatting(void) return failed; } - static int test_curl_off_t_formatting(void) { int i, j; @@ -1080,7 +1059,7 @@ static int test_curl_off_t_formatting(void) for(j = 0; j < BUFSZ; j++) co_test[i].result[j] = 'X'; - co_test[i].result[BUFSZ-1] = '\0'; + co_test[i].result[BUFSZ - 1] = '\0'; (void)curl_msprintf(co_test[i].result, "%" CURL_FORMAT_CURL_OFF_T, co_test[i].num); @@ -1092,7 +1071,6 @@ static int test_curl_off_t_formatting(void) i, co_test[i].expected, co_test[i].result); failed++; } - } if(!failed) @@ -1113,7 +1091,7 @@ static int string_check_low(int linenumber, char *buf, const char *buf2) } return 0; } -#define string_check(x,y) string_check_low(__LINE__, x, y) +#define string_check(x, y) string_check_low(__LINE__, x, y) static int strlen_check_low(int linenumber, char *buf, size_t len) { @@ -1126,7 +1104,7 @@ static int strlen_check_low(int linenumber, char *buf, size_t len) } return 0; } -#define strlen_check(x,y) strlen_check_low(__LINE__, x, y) +#define strlen_check(x, y) strlen_check_low(__LINE__, x, y) /* * The output strings in this test need to have been verified with a system @@ -1222,7 +1200,6 @@ static int test_width_precision(void) return errors; } - static int test_weird_arguments(void) { int errors = 0; @@ -1275,7 +1252,7 @@ static int test_weird_arguments(void) 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, /* 10 9 */ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, /* 10 10 */ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, /* 10 11 */ - 0, 1, 2, 3, 4, 5, 6, 7); /* 8 */ + 0, 1, 2, 3, 4, 5, 6, 7); /* 8 */ if(rc != 128) { curl_mprintf("curl_mprintf() returned %d and not 128!\n", rc); diff --git a/tests/libtest/lib568.c b/tests/libtest/lib568.c index 260061f5191f..46e94afb5390 100644 --- a/tests/libtest/lib568.c +++ b/tests/libtest/lib568.c @@ -84,7 +84,7 @@ static CURLcode test_lib568(const char *URL) test_setopt(curl, CURLOPT_READDATA, sdpf); test_setopt(curl, CURLOPT_UPLOAD, 1L); - test_setopt(curl, CURLOPT_INFILESIZE_LARGE, (curl_off_t) file_info.st_size); + test_setopt(curl, CURLOPT_INFILESIZE_LARGE, (curl_off_t)file_info.st_size); test_setopt(curl, CURLOPT_VERBOSE, 1L); /* Do the ANNOUNCE */ diff --git a/tests/libtest/lib570.c b/tests/libtest/lib570.c index f5ada6770b2e..1a1656d798f5 100644 --- a/tests/libtest/lib570.c +++ b/tests/libtest/lib570.c @@ -70,7 +70,7 @@ static CURLcode test_lib570(const char *URL) test_setopt(curl, CURLOPT_RTSP_CLIENT_CSEQ, 999L); test_setopt(curl, CURLOPT_RTSP_TRANSPORT, - "RAW/RAW/UDP;unicast;client_port=3056-3057"); + "RAW/RAW/UDP;unicast;client_port=3056-3057"); test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP); stream_uri = tutil_suburl(URL, request++); diff --git a/tests/libtest/lib572.c b/tests/libtest/lib572.c index 4e20cb3da5b8..5e54f3549b92 100644 --- a/tests/libtest/lib572.c +++ b/tests/libtest/lib572.c @@ -102,7 +102,7 @@ static CURLcode test_lib572(const char *URL) test_setopt(curl, CURLOPT_READDATA, paramsf); test_setopt(curl, CURLOPT_UPLOAD, 1L); - test_setopt(curl, CURLOPT_INFILESIZE_LARGE, (curl_off_t) file_info.st_size); + test_setopt(curl, CURLOPT_INFILESIZE_LARGE, (curl_off_t)file_info.st_size); res = curl_easy_perform(curl); if(res) diff --git a/tests/libtest/lib573.c b/tests/libtest/lib573.c index ed00bbb04243..b19782ce0d6f 100644 --- a/tests/libtest/lib573.c +++ b/tests/libtest/lib573.c @@ -41,7 +41,7 @@ static CURLcode test_lib573(const char *URL) dbl_epsilon = 1.0; do { dbl_epsilon /= 2.0; - } while((double)(1.0 + (dbl_epsilon/2.0)) > (double)1.0); + } while((double)(1.0 + (dbl_epsilon / 2.0)) > (double)1.0); start_test_timing(); diff --git a/tests/libtest/lib574.c b/tests/libtest/lib574.c index f74371e97383..52527c7f419c 100644 --- a/tests/libtest/lib574.c +++ b/tests/libtest/lib574.c @@ -23,8 +23,7 @@ ***************************************************************************/ #include "first.h" -static int new_fnmatch(void *ptr, - const char *pattern, const char *string) +static int new_fnmatch(void *ptr, const char *pattern, const char *string) { (void)ptr; curl_mfprintf(stderr, "lib574: match string '%s' against pattern '%s'\n", diff --git a/tests/libtest/lib579.c b/tests/libtest/lib579.c index aaa81baedeb1..05d4a8432e63 100644 --- a/tests/libtest/lib579.c +++ b/tests/libtest/lib579.c @@ -84,7 +84,7 @@ static size_t t579_read_cb(char *ptr, size_t size, size_t nmemb, void *userp) struct t579_WriteThis *pooh = (struct t579_WriteThis *)userp; const char *data; - if(size*nmemb < 1) + if(size * nmemb < 1) return 0; data = testpost[pooh->counter]; diff --git a/tests/libtest/lib582.c b/tests/libtest/lib582.c index e99d5febdfab..dabebed6ce8f 100644 --- a/tests/libtest/lib582.c +++ b/tests/libtest/lib582.c @@ -175,7 +175,7 @@ static ssize_t t582_getMicroSecondTimeout(struct curltime *timeout) /** * Update a fd_set with all of the sockets in use. */ -static void t582_updateFdSet(struct t582_Sockets *sockets, fd_set* fdset, +static void t582_updateFdSet(struct t582_Sockets *sockets, fd_set *fdset, curl_socket_t *maxFd) { int i; diff --git a/tests/libtest/lib586.c b/tests/libtest/lib586.c index d0671b18fec3..310ad77f39f4 100644 --- a/tests/libtest/lib586.c +++ b/tests/libtest/lib586.c @@ -47,21 +47,21 @@ static void t586_test_lock(CURL *curl, curl_lock_data data, (void)laccess; switch(data) { - case CURL_LOCK_DATA_SHARE: - what = "share"; - break; - case CURL_LOCK_DATA_DNS: - what = "dns"; - break; - case CURL_LOCK_DATA_COOKIE: - what = "cookie"; - break; - case CURL_LOCK_DATA_SSL_SESSION: - what = "ssl_session"; - break; - default: - curl_mfprintf(stderr, "lock: no such data: %d\n", data); - return; + case CURL_LOCK_DATA_SHARE: + what = "share"; + break; + case CURL_LOCK_DATA_DNS: + what = "dns"; + break; + case CURL_LOCK_DATA_COOKIE: + what = "cookie"; + break; + case CURL_LOCK_DATA_SSL_SESSION: + what = "ssl_session"; + break; + default: + curl_mfprintf(stderr, "lock: no such data: %d\n", data); + return; } curl_mprintf("lock: %-6s [%s]: %d\n", what, user->text, user->counter); user->counter++; @@ -74,21 +74,21 @@ static void t586_test_unlock(CURL *curl, curl_lock_data data, void *useptr) struct t586_userdata *user = (struct t586_userdata *)useptr; (void)curl; switch(data) { - case CURL_LOCK_DATA_SHARE: - what = "share"; - break; - case CURL_LOCK_DATA_DNS: - what = "dns"; - break; - case CURL_LOCK_DATA_COOKIE: - what = "cookie"; - break; - case CURL_LOCK_DATA_SSL_SESSION: - what = "ssl_session"; - break; - default: - curl_mfprintf(stderr, "unlock: no such data: %d\n", data); - return; + case CURL_LOCK_DATA_SHARE: + what = "share"; + break; + case CURL_LOCK_DATA_DNS: + what = "dns"; + break; + case CURL_LOCK_DATA_COOKIE: + what = "cookie"; + break; + case CURL_LOCK_DATA_SSL_SESSION: + what = "ssl_session"; + break; + default: + curl_mfprintf(stderr, "unlock: no such data: %d\n", data); + return; } curl_mprintf("unlock: %-6s [%s]: %d\n", what, user->text, user->counter); user->counter++; @@ -98,7 +98,7 @@ static void t586_test_unlock(CURL *curl, curl_lock_data data, void *useptr) static void *t586_test_fire(void *ptr) { CURLcode code; - struct t586_Tdata *tdata = (struct t586_Tdata*)ptr; + struct t586_Tdata *tdata = (struct t586_Tdata *)ptr; CURL *curl; curl = curl_easy_init(); @@ -108,8 +108,8 @@ static void *t586_test_fire(void *ptr) } curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L); - curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); - curl_easy_setopt(curl, CURLOPT_URL, tdata->url); + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); + curl_easy_setopt(curl, CURLOPT_URL, tdata->url); curl_mprintf("CURLOPT_SHARE\n"); curl_easy_setopt(curl, CURLOPT_SHARE, tdata->share); @@ -181,20 +181,18 @@ static CURLcode test_lib586(const char *URL) return TEST_ERR_MAJOR_BAD; } - /* start treads */ for(i = 1; i <= THREADS; i++) { /* set thread data */ - tdata.url = URL; + tdata.url = URL; tdata.share = share; /* simulate thread, direct call of "thread" function */ - curl_mprintf("*** run %d\n",i); + curl_mprintf("*** run %d\n", i); t586_test_fire(&tdata); } - /* fetch another one */ curl_mprintf("*** run %d\n", i); curl = curl_easy_init(); @@ -233,8 +231,7 @@ static CURLcode test_lib586(const char *URL) curl_mprintf("SHARE_CLEANUP\n"); scode = curl_share_cleanup(share); if(scode != CURLSHE_OK) - curl_mfprintf(stderr, "curl_share_cleanup failed, code errno %d\n", - scode); + curl_mfprintf(stderr, "curl_share_cleanup failed, code errno %d\n", scode); curl_mprintf("GLOBAL_CLEANUP\n"); curl_global_cleanup(); diff --git a/tests/libtest/lib591.c b/tests/libtest/lib591.c index 521cbb7503ab..b58a408a028d 100644 --- a/tests/libtest/lib591.c +++ b/tests/libtest/lib591.c @@ -114,8 +114,8 @@ static CURLcode test_lib591(const char *URL) #else itimeout = (int)timeout; #endif - interval.tv_sec = itimeout/1000; - interval.tv_usec = (itimeout%1000)*1000; + interval.tv_sec = itimeout / 1000; + interval.tv_usec = (itimeout % 1000) * 1000; } else { interval.tv_sec = 0; diff --git a/tests/libtest/lib597.c b/tests/libtest/lib597.c index 38e60c084486..e02acadab39f 100644 --- a/tests/libtest/lib597.c +++ b/tests/libtest/lib597.c @@ -94,11 +94,11 @@ static CURLcode test_lib597(const char *URL) #else itimeout = (int)timeout; #endif - interval.tv_sec = itimeout/1000; - interval.tv_usec = (itimeout%1000)*1000; + interval.tv_sec = itimeout / 1000; + interval.tv_usec = (itimeout % 1000) * 1000; } else { - interval.tv_sec = TEST_HANG_TIMEOUT/1000 - 1; + interval.tv_sec = TEST_HANG_TIMEOUT / 1000 - 1; interval.tv_usec = 0; } diff --git a/tests/libtest/lib643.c b/tests/libtest/lib643.c index 52ea1eb664cc..d096082143ac 100644 --- a/tests/libtest/lib643.c +++ b/tests/libtest/lib643.c @@ -33,7 +33,7 @@ static size_t t643_read_cb(char *ptr, size_t size, size_t nmemb, void *userp) struct t643_WriteThis *pooh = (struct t643_WriteThis *)userp; int eof; - if(size*nmemb < 1) + if(size * nmemb < 1) return 0; if(testnum == 643) { @@ -100,8 +100,7 @@ static CURLcode t643_test_once(const char *URL, bool oldstyle) if(oldstyle) { res = curl_mime_name(part, "sendfile"); if(!res) - res = curl_mime_data_cb(part, datasize, t643_read_cb, - NULL, NULL, &pooh); + res = curl_mime_data_cb(part, datasize, t643_read_cb, NULL, NULL, &pooh); if(!res) res = curl_mime_filename(part, "postit2.c"); } @@ -109,8 +108,7 @@ static CURLcode t643_test_once(const char *URL, bool oldstyle) /* new style */ res = curl_mime_name(part, "sendfile alternative"); if(!res) - res = curl_mime_data_cb(part, datasize, t643_read_cb, - NULL, NULL, &pooh); + res = curl_mime_data_cb(part, datasize, t643_read_cb, NULL, NULL, &pooh); if(!res) res = curl_mime_filename(part, "filename 2 "); } @@ -137,8 +135,7 @@ static CURLcode t643_test_once(const char *URL, bool oldstyle) /* Fill in the file upload part */ res = curl_mime_name(part, "callbackdata"); if(!res) - res = curl_mime_data_cb(part, datasize, t643_read_cb, - NULL, NULL, &pooh2); + res = curl_mime_data_cb(part, datasize, t643_read_cb, NULL, NULL, &pooh2); if(res) curl_mprintf("curl_mime_xxx(2) = %s\n", curl_easy_strerror(res)); @@ -155,8 +152,7 @@ static CURLcode t643_test_once(const char *URL, bool oldstyle) /* Fill in the filename field */ res = curl_mime_name(part, "filename"); if(!res) - res = curl_mime_data(part, "postit2.c", - CURL_ZERO_TERMINATED); + res = curl_mime_data(part, "postit2.c", CURL_ZERO_TERMINATED); if(res) curl_mprintf("curl_mime_xxx(3) = %s\n", curl_easy_strerror(res)); @@ -172,8 +168,7 @@ static CURLcode t643_test_once(const char *URL, bool oldstyle) } res = curl_mime_name(part, "submit"); if(!res) - res = curl_mime_data(part, "send", - CURL_ZERO_TERMINATED); + res = curl_mime_data(part, "send", CURL_ZERO_TERMINATED); if(res) curl_mprintf("curl_mime_xxx(4) = %s\n", curl_easy_strerror(res)); diff --git a/tests/libtest/lib650.c b/tests/libtest/lib650.c index 4aa6ea9d8bb4..d749e67d27c7 100644 --- a/tests/libtest/lib650.c +++ b/tests/libtest/lib650.c @@ -30,7 +30,7 @@ /* curl_formget callback to count characters. */ static size_t count_chars(void *userp, const char *buf, size_t len) { - size_t *pcounter = (size_t *) userp; + size_t *pcounter = (size_t *)userp; (void)buf; *pcounter += len; @@ -51,8 +51,7 @@ static CURLcode test_lib650(const char *URL) long contentlength = 0; static const char testname[] = "fieldname"; - static char testdata[] = - "this is what we post to the silly web server"; + static char testdata[] = "this is what we post to the silly web server"; if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { curl_mfprintf(stderr, "curl_global_init() failed\n"); @@ -141,7 +140,7 @@ static CURLcode test_lib650(const char *URL) * This is done before including stdin data because we want to reuse it * and stdin cannot be rewound. */ - curl_formget(formpost, (void *) &formlength, count_chars); + curl_formget(formpost, (void *)&formlength, count_chars); /* Include length in data for external check. */ curl_msnprintf(flbuf, sizeof(flbuf), "%zu", formlength); diff --git a/tests/libtest/lib651.c b/tests/libtest/lib651.c index 7d1d28563f15..1e38d18895cc 100644 --- a/tests/libtest/lib651.c +++ b/tests/libtest/lib651.c @@ -35,12 +35,12 @@ static CURLcode test_lib651(const char *URL) /* create a buffer with AAAA...BBBBB...CCCC...etc */ int i; - int size = (int)sizeof(testbuf)/1000; + int size = (int)sizeof(testbuf) / 1000; - for(i = 0; i < size ; i++) + for(i = 0; i < size; i++) memset(&testbuf[i * 1000], 65 + i, 1000); - testbuf[sizeof(testbuf)-1] = 0; /* null-terminate */ + testbuf[sizeof(testbuf) - 1] = 0; /* null-terminate */ if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { curl_mfprintf(stderr, "curl_global_init() failed\n"); diff --git a/tests/libtest/lib652.c b/tests/libtest/lib652.c index 4fae340042b0..eea153742f03 100644 --- a/tests/libtest/lib652.c +++ b/tests/libtest/lib652.c @@ -37,7 +37,7 @@ static CURLcode test_lib652(const char *URL) int i; int size = (int)sizeof(testbuf) / 10; - for(i = 0; i < size ; i++) + for(i = 0; i < size; i++) memset(&testbuf[i * 10], 65 + (i % 26), 10); if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { diff --git a/tests/libtest/lib654.c b/tests/libtest/lib654.c index 1d93798d7c10..7d519d645331 100644 --- a/tests/libtest/lib654.c +++ b/tests/libtest/lib654.c @@ -31,7 +31,7 @@ struct t654_WriteThis { static void free_callback(void *userp) { - struct t654_WriteThis *pooh = (struct t654_WriteThis *) userp; + struct t654_WriteThis *pooh = (struct t654_WriteThis *)userp; pooh->freecount++; } @@ -41,7 +41,7 @@ static size_t t654_read_cb(char *ptr, size_t size, size_t nmemb, void *userp) struct t654_WriteThis *pooh = (struct t654_WriteThis *)userp; int eof; - if(size*nmemb < 1) + if(size * nmemb < 1) return 0; eof = pooh->sizeleft <= 0; @@ -92,7 +92,7 @@ static CURLcode test_lib654(const char *URL) /* Prepare the callback structure. */ pooh.readptr = testdata; - pooh.sizeleft = (curl_off_t) strlen(testdata); + pooh.sizeleft = (curl_off_t)strlen(testdata); pooh.freecount = 0; /* Build the mime tree. */ diff --git a/tests/libtest/lib666.c b/tests/libtest/lib666.c index f47bacb9a807..e0a36412b012 100644 --- a/tests/libtest/lib666.c +++ b/tests/libtest/lib666.c @@ -40,7 +40,7 @@ static CURLcode test_lib666(const char *URL) if(i % 77 == 76) testbuf[i] = '\n'; else - testbuf[i] = (char) (0x41 + i % 26); /* A...Z */ + testbuf[i] = (char)(0x41 + i % 26); /* A...Z */ if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { curl_mfprintf(stderr, "curl_global_init() failed\n"); diff --git a/tests/libtest/lib667.c b/tests/libtest/lib667.c index 1bd612f37797..3d835d500f86 100644 --- a/tests/libtest/lib667.c +++ b/tests/libtest/lib667.c @@ -33,7 +33,7 @@ static size_t t667_read_cb(char *ptr, size_t size, size_t nmemb, void *userp) struct t667_WriteThis *pooh = (struct t667_WriteThis *)userp; int eof; - if(size*nmemb < 1) + if(size * nmemb < 1) return 0; eof = pooh->sizeleft <= 0; @@ -82,7 +82,7 @@ static CURLcode test_lib667(const char *URL) /* Prepare the callback structure. */ pooh.readptr = testdata; - pooh.sizeleft = (curl_off_t) strlen(testdata); + pooh.sizeleft = (curl_off_t)strlen(testdata); /* Build the mime tree. */ mime = curl_mime_init(curl); @@ -90,8 +90,7 @@ static CURLcode test_lib667(const char *URL) curl_mime_name(part, "field"); curl_mime_encoder(part, "base64"); /* Using an undefined length forces chunked transfer. */ - curl_mime_data_cb(part, (curl_off_t) -1, t667_read_cb, - NULL, NULL, &pooh); + curl_mime_data_cb(part, (curl_off_t)-1, t667_read_cb, NULL, NULL, &pooh); /* Bind mime data to its easy handle. */ test_setopt(curl, CURLOPT_MIMEPOST, mime); diff --git a/tests/libtest/lib668.c b/tests/libtest/lib668.c index 5011391736b1..e0f291d809e2 100644 --- a/tests/libtest/lib668.c +++ b/tests/libtest/lib668.c @@ -76,7 +76,7 @@ static CURLcode test_lib668(const char *URL) /* Prepare the callback structures. */ pooh1.readptr = testdata; - pooh1.sizeleft = (curl_off_t) strlen(testdata); + pooh1.sizeleft = (curl_off_t)strlen(testdata); pooh2 = pooh1; /* Build the mime tree. */ @@ -84,14 +84,14 @@ static CURLcode test_lib668(const char *URL) part = curl_mime_addpart(mime); curl_mime_name(part, "field1"); /* Early end of data detection can be done because the data size is known. */ - curl_mime_data_cb(part, (curl_off_t) strlen(testdata), + curl_mime_data_cb(part, (curl_off_t)strlen(testdata), t668_read_cb, NULL, NULL, &pooh1); part = curl_mime_addpart(mime); curl_mime_name(part, "field2"); /* Using an undefined length forces chunked transfer and disables early end of data detection for this part. */ - curl_mime_data_cb(part, (curl_off_t) -1, t668_read_cb, - NULL, NULL, &pooh2); + curl_mime_data_cb(part, (curl_off_t)-1, + t668_read_cb, NULL, NULL, &pooh2); part = curl_mime_addpart(mime); curl_mime_name(part, "field3"); /* Regular file part sources early end of data can be detected because diff --git a/tests/libtest/lib670.c b/tests/libtest/lib670.c index e97b04319e3c..886bf39a72bc 100644 --- a/tests/libtest/lib670.c +++ b/tests/libtest/lib670.c @@ -33,7 +33,7 @@ struct t670_ReadThis { static size_t t670_read_cb(char *ptr, size_t size, size_t nmemb, void *userp) { - struct t670_ReadThis *pooh = (struct t670_ReadThis *) userp; + struct t670_ReadThis *pooh = (struct t670_ReadThis *)userp; time_t delta; if(size * nmemb < 1) @@ -61,7 +61,7 @@ static int t670_xferinfo(void *clientp, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow) { - struct t670_ReadThis *pooh = (struct t670_ReadThis *) clientp; + struct t670_ReadThis *pooh = (struct t670_ReadThis *)clientp; (void)dltotal; (void)dlnow; @@ -102,7 +102,7 @@ static CURLcode test_lib670(const char *URL) return TEST_ERR_MAJOR_BAD; } - pooh.origin = (time_t) 0; + pooh.origin = (time_t)0; pooh.count = 0; pooh.curl = curl_easy_init(); @@ -128,7 +128,7 @@ static CURLcode test_lib670(const char *URL) goto test_cleanup; } - res = curl_mime_data_cb(part, (curl_off_t) 2, t670_read_cb, + res = curl_mime_data_cb(part, (curl_off_t)2, t670_read_cb, NULL, NULL, &pooh); /* Bind mime data to its easy handle. */ diff --git a/tests/libtest/lib678.c b/tests/libtest/lib678.c index ed8731d20d5b..525407fddc37 100644 --- a/tests/libtest/lib678.c +++ b/tests/libtest/lib678.c @@ -43,8 +43,7 @@ static int loadfile(const char *filename, void **filedata, size_t *filesize) continue_reading = fseek(fInCert, 0, SEEK_SET) == 0; if(continue_reading) data = curlx_malloc(datasize + 1); - if((!data) || - ((int)fread(data, datasize, 1, fInCert) != 1)) + if((!data) || ((int)fread(data, datasize, 1, fInCert) != 1)) continue_reading = FALSE; curlx_fclose(fInCert); if(!continue_reading) { @@ -52,7 +51,7 @@ static int loadfile(const char *filename, void **filedata, size_t *filesize) datasize = 0; data = NULL; } - } + } } *filesize = datasize; *filedata = data; diff --git a/tests/libtest/lib758.c b/tests/libtest/lib758.c index bc6a490d3d39..fadb1db6fdd7 100644 --- a/tests/libtest/lib758.c +++ b/tests/libtest/lib758.c @@ -69,7 +69,6 @@ static void t758_msg(const char *msg) curl_mfprintf(stderr, "%s %s\n", t758_tag(), msg); } - struct t758_Sockets { curl_socket_t *sockets; int count; /* number of sockets actually stored in array */ @@ -203,7 +202,7 @@ static int t758_curlTimerCallback(CURLM *multi, long timeout_ms, void *userp) static int t758_cert_verify_callback(X509_STORE_CTX *ctx, void *arg) { - SSL * ssl; + SSL *ssl; (void)arg; ssl = (SSL *)X509_STORE_CTX_get_ex_data(ctx, SSL_get_ex_data_X509_STORE_CTX_idx()); @@ -226,7 +225,7 @@ static int t758_cert_verify_callback(X509_STORE_CTX *ctx, void *arg) static CURLcode t758_set_ssl_ctx_callback(CURL *curl, void *ssl_ctx, void *clientp) { - SSL_CTX *ctx = (SSL_CTX *) ssl_ctx; + SSL_CTX *ctx = (SSL_CTX *)ssl_ctx; (void)curl; SSL_CTX_set_cert_verify_callback(ctx, t758_cert_verify_callback, clientp); return CURLE_OK; @@ -277,7 +276,7 @@ static ssize_t t758_getMicroSecondTimeout(struct curltime *timeout) /** * Update a fd_set with all of the sockets in use. */ -static void t758_updateFdSet(struct t758_Sockets *sockets, fd_set* fdset, +static void t758_updateFdSet(struct t758_Sockets *sockets, fd_set *fdset, curl_socket_t *maxFd) { int i; @@ -359,7 +358,6 @@ static CURLcode t758_one(const char *URL, int timer_fail_at, curl_global_trace("all"); - easy_init(curl); debug_config.nohex = TRUE; debug_config.tracetime = TRUE; diff --git a/tests/server/dnsd.c b/tests/server/dnsd.c index 9b3a42e1590c..58bbd2f3f88c 100644 --- a/tests/server/dnsd.c +++ b/tests/server/dnsd.c @@ -26,8 +26,7 @@ static int dnsd_wrotepidfile = 0; static int dnsd_wroteportfile = 0; -static unsigned short get16bit(const unsigned char **pkt, - size_t *size) +static unsigned short get16bit(const unsigned char **pkt, size_t *size) { const unsigned char *p = *pkt; (*pkt) += 2; @@ -140,7 +139,7 @@ static int store_incoming(const unsigned char *data, size_t size, fprintf(server, "Z: %x\n", (id & 0x70) >> 4); fprintf(server, "RCODE: %x\n", (id & 0x0f)); #endif - (void) get16bit(&data, &size); + (void)get16bit(&data, &size); data += 6; /* skip ANCOUNT, NSCOUNT and ARCOUNT */ size -= 6; @@ -153,10 +152,9 @@ static int store_incoming(const unsigned char *data, size_t size, qd = get16bit(&data, &size); fprintf(server, "QNAME %s QTYPE %s\n", name, type2string(qd)); *qtype = qd; - logmsg("Question for '%s' type %x / %s", name, qd, - type2string(qd)); + logmsg("Question for '%s' type %x / %s", name, qd, type2string(qd)); - (void) get16bit(&data, &size); + (void)get16bit(&data, &size); *qlen = qsize - size; /* total size of the query */ if(*qlen > qbuflen) { @@ -311,7 +309,7 @@ static int send_response(curl_socket_t sock, fprintf(stderr, "Not working\n"); return -1; #else - rc = sendto(sock, (const void *)bytes, (SENDTO3) i, 0, addr, addrlen); + rc = sendto(sock, (const void *)bytes, (SENDTO3)i, 0, addr, addrlen); if(rc != (ssize_t)i) { fprintf(stderr, "failed sending %d bytes\n", (int)i); } @@ -319,7 +317,6 @@ static int send_response(curl_socket_t sock, return 0; } - static void read_instructions(void) { char file[256]; @@ -412,7 +409,7 @@ static int test_dnsd(int argc, char **argv) #else "" #endif - ); + ); return 0; } else if(!strcmp("--pidfile", argv[arg])) { @@ -475,7 +472,7 @@ static int test_dnsd(int argc, char **argv) } snprintf(loglockfile, sizeof(loglockfile), "%s/%s/dnsd-%s.lock", - logdir, SERVERLOGS_LOCKDIR, ipv_inuse); + logdir, SERVERLOGS_LOCKDIR, ipv_inuse); #ifdef _WIN32 if(win32_init()) diff --git a/tests/server/getpart.c b/tests/server/getpart.c index efec3de634b6..becde4a9bb06 100644 --- a/tests/server/getpart.c +++ b/tests/server/getpart.c @@ -182,8 +182,8 @@ static int appenddata(char **dst_buf, /* dest buffer */ return GPE_OK; } -static int decodedata(char **buf, /* dest buffer */ - size_t *len) /* dest buffer data length */ +static int decodedata(char **buf, /* dest buffer */ + size_t *len) /* dest buffer data length */ { CURLcode error = CURLE_OK; unsigned char *buf64 = NULL; @@ -254,7 +254,7 @@ int getpart(char **outbuf, size_t *outlen, char *end; union { ssize_t sig; - size_t uns; + size_t uns; } len; size_t bufsize = 0; size_t outalloc = 256; @@ -288,8 +288,7 @@ int getpart(char **outbuf, size_t *outlen, if('<' != *ptr) { if(in_wanted_part) { show(("=> %s", buffer)); - error = appenddata(outbuf, outlen, &outalloc, buffer, datalen, - base64); + error = appenddata(outbuf, outlen, &outalloc, buffer, datalen, base64); if(error) break; } @@ -353,7 +352,6 @@ int getpart(char **outbuf, size_t *outlen, if(in_wanted_part) break; } - } else if(!in_wanted_part) { /* @@ -411,9 +409,9 @@ int getpart(char **outbuf, size_t *outlen, /* start of wanted part */ in_wanted_part = 1; if(strstr(patt, "base64=")) - /* bit rough test, but "mostly" functional, */ - /* treat wanted part data as base64 encoded */ - base64 = 1; + /* bit rough test, but "mostly" functional, */ + /* treat wanted part data as base64 encoded */ + base64 = 1; if(strstr(patt, "nonewline=")) { show(("* setting nonewline\n")); nonewline = 1; @@ -421,7 +419,6 @@ int getpart(char **outbuf, size_t *outlen, } continue; } - } if(in_wanted_part) { diff --git a/tests/server/mqttd.c b/tests/server/mqttd.c index 59c7540dcfc3..081b038d075b 100644 --- a/tests/server/mqttd.c +++ b/tests/server/mqttd.c @@ -156,7 +156,7 @@ static void logprotocol(mqttdir dir, /* return 0 on success */ static int connack(FILE *dump, curl_socket_t fd) { - unsigned char packet[]={ + unsigned char packet[] = { MQTT_MSG_CONNACK, 0x02, 0x00, 0x00 }; @@ -283,7 +283,6 @@ static size_t encode_length(size_t packetlen, return bytes; } - static size_t decode_length(unsigned char *buffer, size_t buflen, size_t *lenbytes) { @@ -304,7 +303,6 @@ static size_t decode_length(unsigned char *buffer, return len; } - /* return 0 on success */ static int publish(FILE *dump, curl_socket_t fd, unsigned short packetid, @@ -408,7 +406,7 @@ static int fixedheader(curl_socket_t fd, static curl_socket_t mqttit(curl_socket_t fd) { - size_t buff_size = 10*1024; + size_t buff_size = 10 * 1024; unsigned char *buffer = NULL; ssize_t rc; unsigned char byte; @@ -482,8 +480,7 @@ static curl_socket_t mqttit(curl_socket_t fd) } if(byte == MQTT_MSG_CONNECT) { - logprotocol(FROM_CLIENT, "CONNECT", remaining_length, - dump, buffer, rc); + logprotocol(FROM_CLIENT, "CONNECT", remaining_length, dump, buffer, rc); if(memcmp(protocol, buffer, sizeof(protocol))) { logmsg("Protocol preamble mismatch"); @@ -607,8 +604,7 @@ static curl_socket_t mqttit(curl_socket_t fd) size_t topiclen; logmsg("Incoming PUBLISH"); - logprotocol(FROM_CLIENT, "PUBLISH", remaining_length, - dump, buffer, rc); + logprotocol(FROM_CLIENT, "PUBLISH", remaining_length, dump, buffer, rc); topiclen = (size_t)(buffer[1 + bytes] << 8) | buffer[2 + bytes]; logmsg("Got %zu bytes topic", topiclen); @@ -754,7 +750,7 @@ static int test_mqttd(int argc, char *argv[]) #else "" #endif - ); + ); return 0; } else if(!strcmp("--pidfile", argv[arg])) { @@ -802,8 +798,7 @@ static int test_mqttd(int argc, char *argv[]) if(argc > arg) { opt = argv[arg]; if(curlx_str_number(&opt, &num, 0xffff)) { - fprintf(stderr, "mqttd: invalid --port argument (%s)\n", - argv[arg]); + fprintf(stderr, "mqttd: invalid --port argument (%s)\n", argv[arg]); return 0; } server_port = (unsigned short)num; diff --git a/tests/server/resolve.c b/tests/server/resolve.c index c41c2fc68ad2..ed54eef5f36b 100644 --- a/tests/server/resolve.c +++ b/tests/server/resolve.c @@ -47,7 +47,7 @@ static int test_resolve(int argc, char *argv[]) #else "" #endif - ); + ); return 0; } else if(!strcmp("--ipv6", argv[arg])) { @@ -79,7 +79,7 @@ static int test_resolve(int argc, char *argv[]) #ifdef CURLRES_IPV6 "\n --ipv6" #endif - ); + ); return 1; } diff --git a/tests/server/rtspd.c b/tests/server/rtspd.c index 335bbaaa69de..842562394058 100644 --- a/tests/server/rtspd.c +++ b/tests/server/rtspd.c @@ -50,10 +50,10 @@ typedef enum { RPROT_HTTP = 2 } reqprot_t; -#define SET_RTP_PKT_CHN(p,c) ((p)[1] = (char)((c) & 0xFF)) +#define SET_RTP_PKT_CHN(p, c) ((p)[1] = (char)((c) & 0xFF)) -#define SET_RTP_PKT_LEN(p,l) (((p)[2] = (char)(((l) >> 8) & 0xFF)), \ - ((p)[3] = (char)((l) & 0xFF))) +#define SET_RTP_PKT_LEN(p, l) (((p)[2] = (char)(((l) >> 8) & 0xFF)), \ + ((p)[3] = (char)((l) & 0xFF))) struct rtspd_httprequest { char reqbuf[150000]; /* buffer area for the incoming request */ @@ -105,10 +105,8 @@ struct rtspd_httprequest { #define END_OF_HEADERS "\r\n\r\n" - /* sent as reply to a QUIT */ -static const char *docquit_rtsp = -"HTTP/1.1 200 Goodbye" END_OF_HEADERS; +static const char *docquit_rtsp = "HTTP/1.1 200 Goodbye" END_OF_HEADERS; /* sent as reply to a CONNECT */ static const char *docconnect = @@ -180,7 +178,7 @@ static int rtspd_ProcessRequest(struct rtspd_httprequest *req) return 1; } - req->prot_version = prot_major*10 + prot_minor; + req->prot_version = prot_major * 10 + prot_minor; /* find the last slash */ ptr = strrchr(doc, '/'); @@ -285,8 +283,8 @@ static int rtspd_ProcessRequest(struct rtspd_httprequest *req) if(num < 0) logmsg("negative pipe size ignored"); else if(num > 0) - req->pipe = num-1; /* decrease by one since we do not count the - first request in this number */ + req->pipe = num - 1; /* decrease by one since we do not count + the first request in this number */ } else if(sscanf(ptr, "skip: %d", &num) == 1) { logmsg("instructed to skip this number of bytes %d", num); @@ -569,7 +567,7 @@ static void rtspd_storerequest(char *reqbuf, size_t totalsize) writeleft = totalsize; do { - written = fwrite(&reqbuf[totalsize-writeleft], 1, writeleft, dump); + written = fwrite(&reqbuf[totalsize - writeleft], 1, writeleft, dump); if(got_exit_signal) goto storerequest_cleanup; if(written > 0) @@ -584,7 +582,7 @@ static void rtspd_storerequest(char *reqbuf, size_t totalsize) logmsg("Error writing file %s error (%d) %s", dumpfile, error, curlx_strerror(error, errbuf, sizeof(errbuf))); logmsg("Wrote only (%zu bytes) of (%zu bytes) request input to %s", - totalsize-writeleft, totalsize, dumpfile); + totalsize - writeleft, totalsize, dumpfile); } storerequest_cleanup: @@ -636,7 +634,7 @@ static int rtspd_get_request(curl_socket_t sock, struct rtspd_httprequest *req) /*** end of httprequest init ***/ - while(!done_processing && (req->offset < sizeof(req->reqbuf)-1)) { + while(!done_processing && (req->offset < sizeof(req->reqbuf) - 1)) { if(pipereq_length && pipereq) { memmove(reqbuf, pipereq, pipereq_length); got = curlx_uztosz(pipereq_length); @@ -650,7 +648,7 @@ static int rtspd_get_request(curl_socket_t sock, struct rtspd_httprequest *req) got = sread(sock, reqbuf + req->offset, req->cl); else got = sread(sock, reqbuf + req->offset, - sizeof(req->reqbuf)-1 - req->offset); + sizeof(req->reqbuf) - 1 - req->offset); } if(got_exit_signal) return 1; @@ -686,16 +684,16 @@ static int rtspd_get_request(curl_socket_t sock, struct rtspd_httprequest *req) } } - if((req->offset == sizeof(req->reqbuf)-1) && (got > 0)) { + if((req->offset == sizeof(req->reqbuf) - 1) && (got > 0)) { logmsg("Request would overflow buffer, closing connection"); /* dump request received so far to external file anyway */ - reqbuf[sizeof(req->reqbuf)-1] = '\0'; + reqbuf[sizeof(req->reqbuf) - 1] = '\0'; fail = 1; } - else if(req->offset > sizeof(req->reqbuf)-1) { + else if(req->offset > sizeof(req->reqbuf) - 1) { logmsg("Request buffer overflow, closing connection"); /* dump request received so far to external file anyway */ - reqbuf[sizeof(req->reqbuf)-1] = '\0'; + reqbuf[sizeof(req->reqbuf) - 1] = '\0'; fail = 1; } else @@ -739,10 +737,10 @@ static int rtspd_send_doc(curl_socket_t sock, struct rtspd_httprequest *req) case RCMD_STREAM: { static const char streamthis[] = "a string to stream 01234567890\n"; for(;;) { - written = swrite(sock, streamthis, sizeof(streamthis)-1); + written = swrite(sock, streamthis, sizeof(streamthis) - 1); if(got_exit_signal) return -1; - if(written != (ssize_t)(sizeof(streamthis)-1)) { + if(written != (ssize_t)(sizeof(streamthis) - 1)) { logmsg("Stopped streaming"); break; } @@ -803,7 +801,7 @@ static int rtspd_send_doc(curl_socket_t sock, struct rtspd_httprequest *req) } else { FILE *stream = test2fopen(req->testno, logdir); - char partbuf[80]="data"; + char partbuf[80] = "data"; if(req->partno) snprintf(partbuf, sizeof(partbuf), "data%ld", req->partno); if(!stream) { @@ -942,7 +940,7 @@ static int rtspd_send_doc(curl_socket_t sock, struct rtspd_httprequest *req) if(sendfailure) { logmsg("Sending response failed. Only (%zu bytes) of " "(%zu bytes) were sent", - responsesize-count, responsesize); + responsesize - count, responsesize); free(ptr); free(cmd); return -1; @@ -997,7 +995,6 @@ static int rtspd_send_doc(curl_socket_t sock, struct rtspd_httprequest *req) return 0; } - static int test_rtspd(int argc, char *argv[]) { srvr_sockaddr_union_t me; @@ -1031,7 +1028,7 @@ static int test_rtspd(int argc, char *argv[]) #else "" #endif - ); + ); return 0; } else if(!strcmp("--pidfile", argv[arg])) { @@ -1126,8 +1123,7 @@ static int test_rtspd(int argc, char *argv[]) } flag = 1; - if(setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, - (void *)&flag, sizeof(flag))) { + if(setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void *)&flag, sizeof(flag))) { error = SOCKERRNO; logmsg("setsockopt(SO_REUSEADDR) failed with error (%d) %s", error, curlx_strerror(error, errbuf, sizeof(errbuf))); diff --git a/tests/server/sockfilt.c b/tests/server/sockfilt.c index 08ece51ea141..9560a3967646 100644 --- a/tests/server/sockfilt.c +++ b/tests/server/sockfilt.c @@ -420,7 +420,7 @@ static DWORD WINAPI select_ws_wait_thread(void *lpParameter) DWORD type, length, ret; /* retrieve handles from internal structure */ - data = (struct select_ws_wait_data *) lpParameter; + data = (struct select_ws_wait_data *)lpParameter; if(data) { handle = data->handle; handles[0] = data->abort; @@ -434,120 +434,120 @@ static DWORD WINAPI select_ws_wait_thread(void *lpParameter) /* retrieve the type of file to wait on */ type = GetFileType(handle); switch(type) { - case FILE_TYPE_DISK: - /* The handle represents a file on disk, this means: - * - WaitForMultipleObjectsEx will always be signalled for it. - * - comparison of current position in file and total size of - * the file can be used to check if we reached the end yet. - * - * Approach: Loop till either the internal event is signalled - * or if the end of the file has already been reached. - */ - while(WaitForMultipleObjectsEx(1, handles, FALSE, 0, FALSE) - == WAIT_TIMEOUT) { - /* get total size of file */ - length = 0; - size.QuadPart = 0; - size.LowPart = GetFileSize(handle, &length); - if((size.LowPart != INVALID_FILE_SIZE) || + case FILE_TYPE_DISK: + /* The handle represents a file on disk, this means: + * - WaitForMultipleObjectsEx will always be signalled for it. + * - comparison of current position in file and total size of + * the file can be used to check if we reached the end yet. + * + * Approach: Loop till either the internal event is signalled + * or if the end of the file has already been reached. + */ + while(WaitForMultipleObjectsEx(1, handles, FALSE, 0, FALSE) + == WAIT_TIMEOUT) { + /* get total size of file */ + length = 0; + size.QuadPart = 0; + size.LowPart = GetFileSize(handle, &length); + if((size.LowPart != INVALID_FILE_SIZE) || + (GetLastError() == NO_ERROR)) { + size.HighPart = (LONG)length; + /* get the current position within the file */ + pos.QuadPart = 0; + pos.LowPart = SetFilePointer(handle, 0, &pos.HighPart, FILE_CURRENT); + if((pos.LowPart != INVALID_SET_FILE_POINTER) || (GetLastError() == NO_ERROR)) { - size.HighPart = (LONG)length; - /* get the current position within the file */ - pos.QuadPart = 0; - pos.LowPart = SetFilePointer(handle, 0, &pos.HighPart, FILE_CURRENT); - if((pos.LowPart != INVALID_SET_FILE_POINTER) || - (GetLastError() == NO_ERROR)) { - /* compare position with size, abort if not equal */ - if(size.QuadPart == pos.QuadPart) { - /* sleep and continue waiting */ - SleepEx(0, FALSE); - continue; - } + /* compare position with size, abort if not equal */ + if(size.QuadPart == pos.QuadPart) { + /* sleep and continue waiting */ + SleepEx(0, FALSE); + continue; } } - /* there is some data available, stop waiting */ - logmsg("[select_ws_wait_thread] data available, DISK: %p", handle); - SetEvent(signal); } - break; + /* there is some data available, stop waiting */ + logmsg("[select_ws_wait_thread] data available, DISK: %p", handle); + SetEvent(signal); + } + break; - case FILE_TYPE_CHAR: - /* The handle represents a character input, this means: - * - WaitForMultipleObjectsEx will be signalled on any kind of input, - * including mouse and window size events we do not care about. - * - * Approach: Loop till either the internal event is signalled - * or we get signalled for an actual key-event. - */ - while(WaitForMultipleObjectsEx(2, handles, FALSE, INFINITE, FALSE) - == WAIT_OBJECT_0 + 1) { - /* check if this is an actual console handle */ - if(GetConsoleMode(handle, &ret)) { - /* retrieve an event from the console buffer */ - length = 0; - if(PeekConsoleInput(handle, &inputrecord, 1, &length)) { - /* check if the event is not an actual key-event */ - if(length == 1 && inputrecord.EventType != KEY_EVENT) { - /* purge the non-key-event and continue waiting */ - ReadConsoleInput(handle, &inputrecord, 1, &length); - continue; - } + case FILE_TYPE_CHAR: + /* The handle represents a character input, this means: + * - WaitForMultipleObjectsEx will be signalled on any kind of input, + * including mouse and window size events we do not care about. + * + * Approach: Loop till either the internal event is signalled + * or we get signalled for an actual key-event. + */ + while(WaitForMultipleObjectsEx(2, handles, FALSE, INFINITE, FALSE) + == WAIT_OBJECT_0 + 1) { + /* check if this is an actual console handle */ + if(GetConsoleMode(handle, &ret)) { + /* retrieve an event from the console buffer */ + length = 0; + if(PeekConsoleInput(handle, &inputrecord, 1, &length)) { + /* check if the event is not an actual key-event */ + if(length == 1 && inputrecord.EventType != KEY_EVENT) { + /* purge the non-key-event and continue waiting */ + ReadConsoleInput(handle, &inputrecord, 1, &length); + continue; } } - /* there is some data available, stop waiting */ - logmsg("[select_ws_wait_thread] data available, CHAR: %p", handle); - SetEvent(signal); } - break; + /* there is some data available, stop waiting */ + logmsg("[select_ws_wait_thread] data available, CHAR: %p", handle); + SetEvent(signal); + } + break; - case FILE_TYPE_PIPE: - /* The handle represents an anonymous or named pipe, this means: - * - WaitForMultipleObjectsEx will always be signalled for it. - * - peek into the pipe and retrieve the amount of data available. - * - * Approach: Loop till either the internal event is signalled - * or there is data in the pipe available for reading. - */ - while(WaitForMultipleObjectsEx(1, handles, FALSE, 0, FALSE) - == WAIT_TIMEOUT) { - /* peek into the pipe and retrieve the amount of data available */ - length = 0; - if(PeekNamedPipe(handle, NULL, 0, NULL, &length, NULL)) { - /* if there is no data available, sleep and continue waiting */ - if(length == 0) { - SleepEx(0, FALSE); - continue; - } - else { - logmsg("[select_ws_wait_thread] PeekNamedPipe len: %lu", length); - } + case FILE_TYPE_PIPE: + /* The handle represents an anonymous or named pipe, this means: + * - WaitForMultipleObjectsEx will always be signalled for it. + * - peek into the pipe and retrieve the amount of data available. + * + * Approach: Loop till either the internal event is signalled + * or there is data in the pipe available for reading. + */ + while(WaitForMultipleObjectsEx(1, handles, FALSE, 0, FALSE) + == WAIT_TIMEOUT) { + /* peek into the pipe and retrieve the amount of data available */ + length = 0; + if(PeekNamedPipe(handle, NULL, 0, NULL, &length, NULL)) { + /* if there is no data available, sleep and continue waiting */ + if(length == 0) { + SleepEx(0, FALSE); + continue; } else { - /* if the pipe has NOT been closed, sleep and continue waiting */ - ret = GetLastError(); - if(ret != ERROR_BROKEN_PIPE) { - logmsg("[select_ws_wait_thread] PeekNamedPipe error (%lu)", ret); - SleepEx(0, FALSE); - continue; - } - else { - logmsg("[select_ws_wait_thread] pipe closed, PIPE: %p", handle); - } + logmsg("[select_ws_wait_thread] PeekNamedPipe len: %lu", length); } - /* there is some data available, stop waiting */ - logmsg("[select_ws_wait_thread] data available, PIPE: %p", handle); - SetEvent(signal); } - break; - - default: - /* The handle has an unknown type, try to wait on it */ - if(WaitForMultipleObjectsEx(2, handles, FALSE, INFINITE, FALSE) - == WAIT_OBJECT_0 + 1) { - logmsg("[select_ws_wait_thread] data available, HANDLE: %p", handle); - SetEvent(signal); + else { + /* if the pipe has NOT been closed, sleep and continue waiting */ + ret = GetLastError(); + if(ret != ERROR_BROKEN_PIPE) { + logmsg("[select_ws_wait_thread] PeekNamedPipe error (%lu)", ret); + SleepEx(0, FALSE); + continue; + } + else { + logmsg("[select_ws_wait_thread] pipe closed, PIPE: %p", handle); + } } - break; + /* there is some data available, stop waiting */ + logmsg("[select_ws_wait_thread] data available, PIPE: %p", handle); + SetEvent(signal); + } + break; + + default: + /* The handle has an unknown type, try to wait on it */ + if(WaitForMultipleObjectsEx(2, handles, FALSE, INFINITE, FALSE) + == WAIT_OBJECT_0 + 1) { + logmsg("[select_ws_wait_thread] data available, HANDLE: %p", handle); + SetEvent(signal); + } + break; } return 0; @@ -658,12 +658,12 @@ static int select_ws(int nfds, fd_set *readfds, fd_set *writefds, if(FD_ISSET(wsasock, readfds)) { FD_SET(wsasock, &readsock); - wsaevents.lNetworkEvents |= FD_READ|FD_ACCEPT|FD_CLOSE; + wsaevents.lNetworkEvents |= FD_READ | FD_ACCEPT | FD_CLOSE; } if(FD_ISSET(wsasock, writefds)) { FD_SET(wsasock, &writesock); - wsaevents.lNetworkEvents |= FD_WRITE|FD_CONNECT|FD_CLOSE; + wsaevents.lNetworkEvents |= FD_WRITE | FD_CONNECT | FD_CLOSE; } if(FD_ISSET(wsasock, exceptfds)) { @@ -800,11 +800,11 @@ static int select_ws(int nfds, fd_set *readfds, fd_set *writefds, wsaevents.lNetworkEvents |= data[i].wsastate; /* remove from descriptor set if not ready for read/accept/close */ - if(!(wsaevents.lNetworkEvents & (FD_READ|FD_ACCEPT|FD_CLOSE))) + if(!(wsaevents.lNetworkEvents & (FD_READ | FD_ACCEPT | FD_CLOSE))) FD_CLR(wsasock, readfds); /* remove from descriptor set if not ready for write/connect */ - if(!(wsaevents.lNetworkEvents & (FD_WRITE|FD_CONNECT|FD_CLOSE))) + if(!(wsaevents.lNetworkEvents & (FD_WRITE | FD_CONNECT | FD_CLOSE))) FD_CLR(wsasock, writefds); /* remove from descriptor set if not exceptional */ @@ -851,10 +851,10 @@ static int select_ws(int nfds, fd_set *readfds, fd_set *writefds, return ret; } -#define SOCKFILT_select(a,b,c,d,e) select_ws(a,b,c,d,e) +#define SOCKFILT_select(a, b, c, d, e) select_ws(a, b, c, d, e) #else -#define SOCKFILT_select(a,b,c,d,e) select(a,b,c,d,e) -#endif /* USE_WINSOCK */ +#define SOCKFILT_select(a, b, c, d, e) select(a, b, c, d, e) +#endif /* USE_WINSOCK */ /* Perform the disconnect handshake with sockfilt * This involves waiting for the disconnect acknowledgment after the DISC @@ -867,46 +867,45 @@ static bool disc_handshake(void) return FALSE; do { - unsigned char buffer[BUFFER_SIZE]; - ssize_t buffer_len; - if(!read_stdin(buffer, 5)) - return FALSE; - logmsg("Received %c%c%c%c (on stdin)", - buffer[0], buffer[1], buffer[2], buffer[3]); - - if(!memcmp("ACKD", buffer, 4)) { - /* got the ack we were waiting for */ - break; - } - else if(!memcmp("DISC", buffer, 4)) { - logmsg("Crikey! Client also wants to disconnect"); - if(!write_stdout("ACKD\n", 5)) - return FALSE; - } - else if(!memcmp("DATA", buffer, 4)) { - /* We must read more data to stay in sync */ - logmsg("Throwing away data bytes"); - if(!read_data_block(buffer, sizeof(buffer), &buffer_len)) - return FALSE; + unsigned char buffer[BUFFER_SIZE]; + ssize_t buffer_len; + if(!read_stdin(buffer, 5)) + return FALSE; + logmsg("Received %c%c%c%c (on stdin)", + buffer[0], buffer[1], buffer[2], buffer[3]); - } - else if(!memcmp("QUIT", buffer, 4)) { - /* just die */ - logmsg("quits"); + if(!memcmp("ACKD", buffer, 4)) { + /* got the ack we were waiting for */ + break; + } + else if(!memcmp("DISC", buffer, 4)) { + logmsg("Crikey! Client also wants to disconnect"); + if(!write_stdout("ACKD\n", 5)) return FALSE; - } - else { - logmsg("Unexpected message error; aborting"); - /* - * The only other messages that could occur here are PING and PORT, - * and both of them occur at the start of a test when nothing should be - * trying to DISC. Therefore, we should not ever get here, but if we - * do, it is probably due to some kind of unclean shutdown situation so - * us shutting down is what we probably ought to be doing, anyway. - */ + } + else if(!memcmp("DATA", buffer, 4)) { + /* We must read more data to stay in sync */ + logmsg("Throwing away data bytes"); + if(!read_data_block(buffer, sizeof(buffer), &buffer_len)) return FALSE; - } + } + else if(!memcmp("QUIT", buffer, 4)) { + /* just die */ + logmsg("quits"); + return FALSE; + } + else { + logmsg("Unexpected message error; aborting"); + /* + * The only other messages that could occur here are PING and PORT, + * and both of them occur at the start of a test when nothing should be + * trying to DISC. Therefore, we should not ever get here, but if we + * do, it is probably due to some kind of unclean shutdown situation so + * us shutting down is what we probably ought to be doing, anyway. + */ + return FALSE; + } } while(TRUE); return TRUE; } @@ -1034,7 +1033,6 @@ static bool juggle(curl_socket_t *sockfdp, } /* switch(*mode) */ - do { /* select() blocking behavior call on blocking descriptors please */ @@ -1058,7 +1056,6 @@ static bool juggle(curl_socket_t *sockfdp, /* timeout */ return TRUE; - if(FD_ISSET(fileno(stdin), &fds_read)) { ssize_t buffer_len; /* read from stdin, commands/data to be dealt with and possibly passed on @@ -1146,8 +1143,7 @@ static bool juggle(curl_socket_t *sockfdp, } } - - if((sockfd != CURL_SOCKET_BAD) && (FD_ISSET(sockfd, &fds_read)) ) { + if((sockfd != CURL_SOCKET_BAD) && (FD_ISSET(sockfd, &fds_read))) { ssize_t nread_socket; if(*mode == PASSIVE_LISTEN) { /* there is no stream set up yet, this is an indication that there is a @@ -1228,7 +1224,7 @@ static int test_sockfilt(int argc, char *argv[]) #else "" #endif - ); + ); return 0; } else if(!strcmp("--verbose", argv[arg])) { diff --git a/tests/server/socksd.c b/tests/server/socksd.c index 4205d26880bd..f9fadd211328 100644 --- a/tests/server/socksd.c +++ b/tests/server/socksd.c @@ -289,8 +289,8 @@ static curl_socket_t socks4(curl_socket_t fd, static curl_socket_t sockit(curl_socket_t fd) { - unsigned char buffer[2*256 + 16]; - unsigned char response[2*256 + 16]; + unsigned char buffer[2 * 256 + 16]; + unsigned char response[2 * 256 + 16]; ssize_t rc; unsigned char len; unsigned char type; @@ -483,7 +483,7 @@ static curl_socket_t sockit(curl_socket_t fd) case 3: /* The first octet of the address field contains the number of octets of name that follow */ - fprintf(dump, " %.*s\n", len-1, &address[1]); + fprintf(dump, " %.*s\n", len - 1, &address[1]); break; case 4: /* 16 bytes IPv6 address */ @@ -579,8 +579,7 @@ static int tunnel(struct perclient *cp, fd_set *fds) /* read from client, send to remote */ nread = recv(cp->clientfd, buffer, sizeof(buffer), 0); if(nread > 0) { - nwrite = send(cp->remotefd, (char *)buffer, - (SEND_TYPE_ARG3)nread, 0); + nwrite = send(cp->remotefd, (char *)buffer, (SEND_TYPE_ARG3)nread, 0); if(nwrite != nread) return 1; cp->fromclient += nwrite; @@ -592,8 +591,7 @@ static int tunnel(struct perclient *cp, fd_set *fds) /* read from remote, send to client */ nread = recv(cp->remotefd, buffer, sizeof(buffer), 0); if(nread > 0) { - nwrite = send(cp->clientfd, (char *)buffer, - (SEND_TYPE_ARG3)nread, 0); + nwrite = send(cp->clientfd, (char *)buffer, (SEND_TYPE_ARG3)nread, 0); if(nwrite != nread) return 1; cp->fromremote += nwrite; @@ -725,7 +723,6 @@ static bool socksd_incoming(curl_socket_t listenfd) cp->used = TRUE; clients++; } - } } for(i = 0; i < 2; i++) { @@ -777,7 +774,7 @@ static int test_socksd(int argc, char *argv[]) #else "" #endif - ); + ); return 0; } else if(!strcmp("--pidfile", argv[arg])) { diff --git a/tests/server/sws.c b/tests/server/sws.c index b070614f525e..13f745546983 100644 --- a/tests/server/sws.c +++ b/tests/server/sws.c @@ -51,7 +51,7 @@ static bool sws_prevbounce = FALSE; /* instructs the server to override the #define RCMD_STREAM 2 /* told to stream */ struct sws_httprequest { - char reqbuf[2*1024*1024]; /* buffer area for the incoming request */ + char reqbuf[2 * 1024 * 1024]; /* buffer area for the incoming request */ bool connect_request; /* if a CONNECT */ unsigned short connect_port; /* the port number CONNECT used */ size_t checkindex; /* where to start checking of the request */ @@ -138,8 +138,7 @@ static const char *cmdfile = "log/server.cmd"; static const char *end_of_headers = END_OF_HEADERS; /* sent as reply to a QUIT */ -static const char *docquit_sws = -"HTTP/1.1 200 Goodbye" END_OF_HEADERS; +static const char *docquit_sws = "HTTP/1.1 200 Goodbye" END_OF_HEADERS; /* send back this on 404 file not found */ static const char *doc404 = "HTTP/1.1 404 Not Found\r\n" @@ -169,7 +168,7 @@ static bool socket_domain_is_ip(void) #endif return true; default: - /* case AF_UNIX: */ + /* case AF_UNIX: */ return false; } } @@ -334,12 +333,10 @@ static int sws_ProcessRequest(struct sws_httprequest *req) size_t npath = 0; /* httppath length */ if(sscanf(line, - "%" REQUEST_KEYWORD_SIZE_TXT"s ", request) == 1) { + "%" REQUEST_KEYWORD_SIZE_TXT "s ", request) == 1) { http = strstr(line + strlen(request), "HTTP/"); - if(http && sscanf(http, "HTTP/%d.%d", - &prot_major, - &prot_minor) == 2) { + if(http && sscanf(http, "HTTP/%d.%d", &prot_major, &prot_minor) == 2) { /* between the request keyword and HTTP/ there is a path */ httppath = line + strlen(request); npath = http - httppath; @@ -361,7 +358,7 @@ static int sws_ProcessRequest(struct sws_httprequest *req) if(fine) { char *ptr; - req->prot_version = prot_major*10 + prot_minor; + req->prot_version = prot_major * 10 + prot_minor; /* find the last slash */ ptr = &httppath[npath]; @@ -746,7 +743,7 @@ static void sws_storerequest(const char *reqbuf, size_t totalsize) writeleft = totalsize; do { - written = fwrite(&reqbuf[totalsize-writeleft], 1, writeleft, dump); + written = fwrite(&reqbuf[totalsize - writeleft], 1, writeleft, dump); if(got_exit_signal) goto storerequest_cleanup; if(written > 0) @@ -761,7 +758,7 @@ static void sws_storerequest(const char *reqbuf, size_t totalsize) logmsg("Error writing file %s error (%d) %s", dumpfile, error, curlx_strerror(error, errbuf, sizeof(errbuf))); logmsg("Wrote only (%zu bytes) of (%zu bytes) request input to %s", - totalsize-writeleft, totalsize, dumpfile); + totalsize - writeleft, totalsize, dumpfile); } storerequest_cleanup: @@ -876,7 +873,7 @@ static int sws_get_request(curl_socket_t sock, struct sws_httprequest *req) return -1; } - if(req->offset >= sizeof(req->reqbuf)-1) { + if(req->offset >= sizeof(req->reqbuf) - 1) { /* buffer is already full; do nothing */ overflow = 1; } @@ -888,7 +885,7 @@ static int sws_get_request(curl_socket_t sock, struct sws_httprequest *req) got = sread(sock, reqbuf + req->offset, req->cl); else got = sread(sock, reqbuf + req->offset, - sizeof(req->reqbuf)-1 - req->offset); + sizeof(req->reqbuf) - 1 - req->offset); if(got_exit_signal) return -1; @@ -924,16 +921,16 @@ static int sws_get_request(curl_socket_t sock, struct sws_httprequest *req) return -1; } - if(overflow || (req->offset == sizeof(req->reqbuf)-1 && got > 0)) { + if(overflow || (req->offset == sizeof(req->reqbuf) - 1 && got > 0)) { logmsg("Request would overflow buffer, closing connection"); /* dump request received so far to external file anyway */ - reqbuf[sizeof(req->reqbuf)-1] = '\0'; + reqbuf[sizeof(req->reqbuf) - 1] = '\0'; fail = 1; } - else if(req->offset > sizeof(req->reqbuf)-1) { + else if(req->offset > sizeof(req->reqbuf) - 1) { logmsg("Request buffer overflow, closing connection"); /* dump request received so far to external file anyway */ - reqbuf[sizeof(req->reqbuf)-1] = '\0'; + reqbuf[sizeof(req->reqbuf) - 1] = '\0'; fail = 1; } else @@ -978,10 +975,10 @@ static int sws_send_doc(curl_socket_t sock, struct sws_httprequest *req) case RCMD_STREAM: { static const char streamthis[] = "a string to stream 01234567890\n"; for(;;) { - written = swrite(sock, streamthis, sizeof(streamthis)-1); + written = swrite(sock, streamthis, sizeof(streamthis) - 1); if(got_exit_signal) return -1; - if(written != (ssize_t)(sizeof(streamthis)-1)) { + if(written != (ssize_t)(sizeof(streamthis) - 1)) { logmsg("Stopped streaming"); break; } @@ -1144,7 +1141,7 @@ static int sws_send_doc(curl_socket_t sock, struct sws_httprequest *req) if(req->writedelay) { int msecs_left = req->writedelay; int intervals = msecs_left / MAX_SLEEP_TIME_MS; - if(msecs_left%MAX_SLEEP_TIME_MS) + if(msecs_left % MAX_SLEEP_TIME_MS) intervals++; logmsg("Pausing %d milliseconds after writing %zd bytes", msecs_left, written); @@ -1172,7 +1169,7 @@ static int sws_send_doc(curl_socket_t sock, struct sws_httprequest *req) if(sendfailure) { logmsg("Sending response failed. Only (%zu bytes) of (%zu bytes) " "were sent", - responsesize-count, responsesize); + responsesize - count, responsesize); sws_prevtestno = req->testno; sws_prevpartno = req->partno; free(ptr); @@ -1247,9 +1244,7 @@ static curl_socket_t connect_to(const char *ipaddr, unsigned short port) if(!ipaddr) return CURL_SOCKET_BAD; - logmsg("about to connect to %s%s%s:%hu", - op_br, ipaddr, cl_br, port); - + logmsg("about to connect to %s%s%s:%hu", op_br, ipaddr, cl_br, port); serverfd = socket(socket_domain, SOCK_STREAM, 0); if(CURL_SOCKET_BAD == serverfd) { @@ -1389,7 +1384,7 @@ static curl_socket_t connect_to(const char *ipaddr, unsigned short port) * must accept a new connection and deal with it appropriately. */ -#define data_or_ctrl(x) ((x)?"DATA":"CTRL") +#define data_or_ctrl(x) ((x) ? "DATA" : "CTRL") #define SWS_CTRL 0 #define SWS_DATA 1 @@ -1644,7 +1639,7 @@ static void http_connect(curl_socket_t *infdp, } } if(serverfd[i] != CURL_SOCKET_BAD) { - len = sizeof(readserver[i])-toc[i]; + len = sizeof(readserver[i]) - toc[i]; if(len && FD_ISSET(serverfd[i], &input)) { /* read from server */ rc = sread(serverfd[i], &readserver[i][toc[i]], len); @@ -1676,7 +1671,7 @@ static void http_connect(curl_socket_t *infdp, logmsg("[%s] SENT \"%s\"", data_or_ctrl(i), data_to_hex(readserver[i], rc)); if(toc[i] - rc) - memmove(&readserver[i][0], &readserver[i][rc], toc[i]-rc); + memmove(&readserver[i][0], &readserver[i][rc], toc[i] - rc); toc[i] -= rc; } } @@ -1696,7 +1691,7 @@ static void http_connect(curl_socket_t *infdp, logmsg("[%s] SENT \"%s\"", data_or_ctrl(i), data_to_hex(readclient[i], rc)); if(tos[i] - rc) - memmove(&readclient[i][0], &readclient[i][rc], tos[i]-rc); + memmove(&readclient[i][0], &readclient[i][rc], tos[i] - rc); tos[i] -= rc; } } @@ -1826,7 +1821,6 @@ static void http_upgrade(struct sws_httprequest *req) /* left to implement */ } - /* returns a socket handle, or 0 if there are no more waiting sockets, or < 0 if there was an error */ static curl_socket_t accept_connection(curl_socket_t sock) @@ -2021,12 +2015,12 @@ static int test_sws(int argc, char *argv[]) if(!strcmp("--version", argv[arg])) { puts("sws IPv4" #ifdef USE_IPV6 - "/IPv6" + "/IPv6" #endif #ifdef USE_UNIX_SOCKETS - "/unix" + "/unix" #endif - ); + ); return 0; } else if(!strcmp("--pidfile", argv[arg])) { @@ -2097,8 +2091,7 @@ static int test_sws(int argc, char *argv[]) if(argc > arg) { opt = argv[arg]; if(curlx_str_number(&opt, &num, 0xffff)) { - fprintf(stderr, "sws: invalid --port argument (%s)\n", - argv[arg]); + fprintf(stderr, "sws: invalid --port argument (%s)\n", argv[arg]); return 0; } port = (unsigned short)num; @@ -2327,9 +2320,9 @@ static int test_sws(int argc, char *argv[]) /* Clear out closed sockets */ for(socket_idx = num_sockets - 1; socket_idx >= 1; --socket_idx) { if(CURL_SOCKET_BAD == all_sockets[socket_idx]) { - char *dst = (char *) (all_sockets + socket_idx); - char *src = (char *) (all_sockets + socket_idx + 1); - char *end = (char *) (all_sockets + num_sockets); + char *dst = (char *)(all_sockets + socket_idx); + char *src = (char *)(all_sockets + socket_idx + 1); + char *end = (char *)(all_sockets + num_sockets); memmove(dst, src, end - src); num_sockets -= 1; } diff --git a/tests/server/tftpd.c b/tests/server/tftpd.c index 2eb31ff5ece8..99c008031eab 100644 --- a/tests/server/tftpd.c +++ b/tests/server/tftpd.c @@ -380,7 +380,7 @@ static void read_ahead(struct testcase *test, } p = dp->th_data; - for(i = 0 ; i < SEGSIZE; i++) { + for(i = 0; i < SEGSIZE; i++) { if(newline) { if(prevchar == '\n') c = '\n'; /* lf to cr,lf */ @@ -536,8 +536,7 @@ static int synchnet(curl_socket_t f /* socket to flush */) else fromaddrlen = sizeof(fromaddr.sa6); #endif - (void)recvfrom(f, rbuf, sizeof(rbuf), 0, - &fromaddr.sa, &fromaddrlen); + (void)recvfrom(f, rbuf, sizeof(rbuf), 0, &fromaddr.sa, &fromaddrlen); } else break; @@ -578,7 +577,7 @@ static int test_tftpd(int argc, char **argv) #else "" #endif - ); + ); return 0; } else if(!strcmp("--pidfile", argv[arg])) { @@ -674,8 +673,7 @@ static int test_tftpd(int argc, char **argv) } flag = 1; - if(setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, - (void *)&flag, sizeof(flag))) { + if(setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void *)&flag, sizeof(flag))) { error = SOCKERRNO; logmsg("setsockopt(SO_REUSEADDR) failed with error (%d) %s", error, curlx_strerror(error, errbuf, sizeof(errbuf))); @@ -825,7 +823,7 @@ static int test_tftpd(int argc, char **argv) } #endif - maxtimeout = 5*TIMEOUT; + maxtimeout = 5 * TIMEOUT; tp = &trsbuf.hdr; tp->th_opcode = ntohs(tp->th_opcode); @@ -1076,7 +1074,6 @@ static int tftpd_parse_servercmd(struct testcase *req) return 0; /* OK! */ } - /* * Validate file access. */ @@ -1104,7 +1101,7 @@ static int validate_access(struct testcase *test, ptr = strrchr(filename, '/'); if(ptr) { - char partbuf[80]="data"; + char partbuf[80] = "data"; long partno; long testno; const char *pval; @@ -1209,7 +1206,7 @@ static void sendtftp(struct testcase *test, const struct formats *pf) if(test->writedelay) { logmsg("Pausing %d seconds before %d bytes", test->writedelay, size); - curlx_wait_ms(1000*test->writedelay); + curlx_wait_ms(1000 * test->writedelay); } send_data: @@ -1249,11 +1246,10 @@ static void sendtftp(struct testcase *test, const struct formats *pf) } /* Re-synchronize with the other side */ (void)synchnet(peer); - if(sap->th_block == (sendblock-1)) { + if(sap->th_block == (sendblock - 1)) { goto send_data; } } - } sendblock++; } while(size == SEGSIZE); diff --git a/tests/server/util.c b/tests/server/util.c index ae21ff8b1af8..624826571a9f 100644 --- a/tests/server/util.c +++ b/tests/server/util.c @@ -37,7 +37,7 @@ */ char *data_to_hex(char *data, size_t len) { - static char buf[256*3]; + static char buf[256 * 3]; size_t i; char *optr = buf; char *iptr = data; @@ -177,18 +177,18 @@ int win32_init(void) } if(LOBYTE(wsaData.wVersion) != LOBYTE(wVersionRequested) || - HIBYTE(wsaData.wVersion) != HIBYTE(wVersionRequested) ) { + HIBYTE(wsaData.wVersion) != HIBYTE(wVersionRequested)) { WSACleanup(); win32_perror("Winsock init failed"); logmsg("No suitable winsock.dll found -- aborting"); return 1; } } -#endif /* USE_WINSOCK */ +#endif /* USE_WINSOCK */ atexit(win32_cleanup); return 0; } -#endif /* _WIN32 */ +#endif /* _WIN32 */ /* fopens the test case file */ FILE *test2fopen(long testno, const char *logdir2) @@ -370,8 +370,7 @@ static void exit_signal_handler(int signum) fd != -1) { #else /* !checksrc! disable BANNEDFUNC 1 */ - fd = open(serverlogfile, - O_WRONLY | O_CREAT | O_APPEND, S_IRUSR | S_IWUSR); + fd = open(serverlogfile, O_WRONLY | O_CREAT | O_APPEND, S_IRUSR | S_IWUSR); if(fd != -1) { #endif static const char msg[] = "exit_signal_handler: called\n"; @@ -546,7 +545,7 @@ static SIGHANDLER_T set_signal(int signum, SIGHANDLER_T handler, #ifdef HAVE_SIGINTERRUPT if(oldhdlr != SIG_ERR) - siginterrupt(signum, (int) restartable); + siginterrupt(signum, (int)restartable); #else (void)restartable; #endif @@ -693,7 +692,7 @@ int bind_unix_socket(curl_socket_t sock, const char *unix_socket, return -1; } strcpy(sau->sun_path, unix_socket); - rc = bind(sock, (struct sockaddr*)sau, sizeof(struct sockaddr_un)); + rc = bind(sock, (struct sockaddr *)sau, sizeof(struct sockaddr_un)); if(rc && SOCKERRNO == SOCKEADDRINUSE) { struct_stat statbuf; /* socket already exists. Perhaps it is stale? */ @@ -738,7 +737,7 @@ int bind_unix_socket(curl_socket_t sock, const char *unix_socket, return rc; } /* stale socket is gone, retry bind */ - rc = bind(sock, (struct sockaddr*)sau, sizeof(struct sockaddr_un)); + rc = bind(sock, (struct sockaddr *)sau, sizeof(struct sockaddr_un)); } return rc; } @@ -805,29 +804,29 @@ curl_socket_t sockdaemon(curl_socket_t sock, request to let the system choose a non-zero available port. */ switch(socket_domain) { - case AF_INET: - memset(&listener.sa4, 0, sizeof(listener.sa4)); - listener.sa4.sin_family = AF_INET; - listener.sa4.sin_addr.s_addr = INADDR_ANY; - listener.sa4.sin_port = htons(*listenport); - rc = bind(sock, &listener.sa, sizeof(listener.sa4)); - break; + case AF_INET: + memset(&listener.sa4, 0, sizeof(listener.sa4)); + listener.sa4.sin_family = AF_INET; + listener.sa4.sin_addr.s_addr = INADDR_ANY; + listener.sa4.sin_port = htons(*listenport); + rc = bind(sock, &listener.sa, sizeof(listener.sa4)); + break; #ifdef USE_IPV6 - case AF_INET6: - memset(&listener.sa6, 0, sizeof(listener.sa6)); - listener.sa6.sin6_family = AF_INET6; - listener.sa6.sin6_addr = in6addr_any; - listener.sa6.sin6_port = htons(*listenport); - rc = bind(sock, &listener.sa, sizeof(listener.sa6)); - break; + case AF_INET6: + memset(&listener.sa6, 0, sizeof(listener.sa6)); + listener.sa6.sin6_family = AF_INET6; + listener.sa6.sin6_addr = in6addr_any; + listener.sa6.sin6_port = htons(*listenport); + rc = bind(sock, &listener.sa, sizeof(listener.sa6)); + break; #endif /* USE_IPV6 */ #ifdef USE_UNIX_SOCKETS - case AF_UNIX: - rc = bind_unix_socket(sock, unix_socket, &listener.sau); - break; + case AF_UNIX: + rc = bind_unix_socket(sock, unix_socket, &listener.sau); + break; #endif - default: - rc = 1; + default: + rc = 1; } if(rc) { diff --git a/tests/unit/unit1300.c b/tests/unit/unit1300.c index 77fb1fb38639..53da9dd4f661 100644 --- a/tests/unit/unit1300.c +++ b/tests/unit/unit1300.c @@ -65,7 +65,7 @@ static CURLcode test_unit1300(const char *arg) * 2: list head will be NULL * 3: list tail will be NULL * 4: list dtor will be NULL - */ + */ fail_unless(Curl_llist_count(&llist) == 0, "list initial size should be zero"); diff --git a/tests/unit/unit1302.c b/tests/unit/unit1302.c index d56f7b09f779..157f1f61ed9c 100644 --- a/tests/unit/unit1302.c +++ b/tests/unit/unit1302.c @@ -124,7 +124,7 @@ static CURLcode test_unit1302(const char *arg) {"", 0, "aWlpaWlpaQ=", 15} /* unaligned size, missing a padding char */ }; - for(i = 0 ; i < CURL_ARRAYSIZE(encode); i++) { + for(i = 0; i < CURL_ARRAYSIZE(encode); i++) { struct etest *e = &encode[i]; char *out; unsigned char *decoded; @@ -180,7 +180,7 @@ static CURLcode test_unit1302(const char *arg) Curl_safefree(out); } - for(i = 0 ; i < CURL_ARRAYSIZE(badecode); i++) { + for(i = 0; i < CURL_ARRAYSIZE(badecode); i++) { struct etest *e = &badecode[i]; unsigned char *decoded; size_t dlen; diff --git a/tests/unit/unit1304.c b/tests/unit/unit1304.c index 100f3f58287e..3e09a0c27761 100644 --- a/tests/unit/unit1304.c +++ b/tests/unit/unit1304.c @@ -46,8 +46,7 @@ static CURLcode test_unit1304(const char *arg) * Test a non existent host in our netrc file. */ Curl_netrc_init(&store); - result = Curl_parsenetrc(&store, - "test.example.com", &login, &password, arg); + result = Curl_parsenetrc(&store, "test.example.com", &login, &password, arg); fail_unless(result == 1, "Host not found should return 1"); abort_unless(password == NULL, "password did not return NULL!"); abort_unless(login == NULL, "user did not return NULL!"); @@ -58,8 +57,7 @@ static CURLcode test_unit1304(const char *arg) */ login = (char *)CURL_UNCONST("me"); Curl_netrc_init(&store); - result = Curl_parsenetrc(&store, - "example.com", &login, &password, arg); + result = Curl_parsenetrc(&store, "example.com", &login, &password, arg); fail_unless(result == 0, "Host should have been found"); abort_unless(password == NULL, "password is not NULL!"); Curl_netrc_cleanup(&store); @@ -69,8 +67,7 @@ static CURLcode test_unit1304(const char *arg) */ login = (char *)CURL_UNCONST("me"); Curl_netrc_init(&store); - result = Curl_parsenetrc(&store, - "test.example.com", &login, &password, arg); + result = Curl_parsenetrc(&store, "test.example.com", &login, &password, arg); fail_unless(result == 1, "Host not found should return 1"); abort_unless(password == NULL, "password is not NULL!"); Curl_netrc_cleanup(&store); @@ -81,8 +78,7 @@ static CURLcode test_unit1304(const char *arg) */ login = (char *)CURL_UNCONST("admi"); /* spellchecker:disable-line */ Curl_netrc_init(&store); - result = Curl_parsenetrc(&store, - "example.com", &login, &password, arg); + result = Curl_parsenetrc(&store, "example.com", &login, &password, arg); fail_unless(result == 0, "Host should have been found"); abort_unless(password == NULL, "password is not NULL!"); Curl_netrc_cleanup(&store); @@ -93,8 +89,7 @@ static CURLcode test_unit1304(const char *arg) */ login = (char *)CURL_UNCONST("adminn"); Curl_netrc_init(&store); - result = Curl_parsenetrc(&store, - "example.com", &login, &password, arg); + result = Curl_parsenetrc(&store, "example.com", &login, &password, arg); fail_unless(result == 0, "Host should have been found"); abort_unless(password == NULL, "password is not NULL!"); Curl_netrc_cleanup(&store); @@ -105,8 +100,7 @@ static CURLcode test_unit1304(const char *arg) */ login = NULL; Curl_netrc_init(&store); - result = Curl_parsenetrc(&store, - "example.com", &login, &password, arg); + result = Curl_parsenetrc(&store, "example.com", &login, &password, arg); fail_unless(result == 0, "Host should have been found"); abort_unless(password != NULL, "returned NULL!"); fail_unless(strncmp(password, "passwd", 6) == 0, @@ -124,8 +118,7 @@ static CURLcode test_unit1304(const char *arg) password = NULL; login = NULL; Curl_netrc_init(&store); - result = Curl_parsenetrc(&store, - "example.com", &login, &password, arg); + result = Curl_parsenetrc(&store, "example.com", &login, &password, arg); fail_unless(result == 0, "Host should have been found"); abort_unless(password != NULL, "returned NULL!"); fail_unless(strncmp(password, "passwd", 6) == 0, @@ -143,12 +136,10 @@ static CURLcode test_unit1304(const char *arg) curlx_free(login); login = NULL; Curl_netrc_init(&store); - result = Curl_parsenetrc(&store, - "curl.example.com", &login, &password, arg); + result = Curl_parsenetrc(&store, "curl.example.com", &login, &password, arg); fail_unless(result == 0, "Host should have been found"); abort_unless(password != NULL, "returned NULL!"); - fail_unless(strncmp(password, "none", 4) == 0, - "password should be 'none'"); + fail_unless(strncmp(password, "none", 4) == 0, "password should be 'none'"); abort_unless(login != NULL, "returned NULL!"); fail_unless(strncmp(login, "none", 4) == 0, "login should be 'none'"); Curl_netrc_cleanup(&store); @@ -162,12 +153,10 @@ static CURLcode test_unit1304(const char *arg) curlx_free(login); login = NULL; Curl_netrc_init(&store); - result = Curl_parsenetrc(&store, - "curl.example.com", &login, &password, arg); + result = Curl_parsenetrc(&store, "curl.example.com", &login, &password, arg); fail_unless(result == 0, "Host should have been found"); abort_unless(password != NULL, "returned NULL!"); - fail_unless(strncmp(password, "none", 4) == 0, - "password should be 'none'"); + fail_unless(strncmp(password, "none", 4) == 0, "password should be 'none'"); abort_unless(login != NULL, "returned NULL!"); fail_unless(strncmp(login, "none", 4) == 0, "login should be 'none'"); Curl_netrc_cleanup(&store); diff --git a/tests/unit/unit1307.c b/tests/unit/unit1307.c index d5fcf5c6b1ed..3651b341ed39 100644 --- a/tests/unit/unit1307.c +++ b/tests/unit/unit1307.c @@ -290,7 +290,7 @@ static CURLcode test_unit1307(const char *arg) for(i = 0; i < CURL_ARRAYSIZE(tests); i++) { int result = tests[i].result; int rc = Curl_fnmatch(NULL, tests[i].pattern, tests[i].string); - if(result & (LINUX_DIFFER|MAC_DIFFER)) { + if(result & (LINUX_DIFFER | MAC_DIFFER)) { if((result & LINUX_DIFFER) && (machine == SYSTEM_LINUX)) result >>= LINUX_SHIFT; else if((result & MAC_DIFFER) && (machine == SYSTEM_MACOS)) diff --git a/tests/unit/unit1309.c b/tests/unit/unit1309.c index 2e2af21f2c75..af9a29e11085 100644 --- a/tests/unit/unit1309.c +++ b/tests/unit/unit1309.c @@ -63,8 +63,8 @@ static CURLcode test_unit1309(const char *arg) #define NUM_NODES 50 struct Curl_tree *root, *removed; - struct Curl_tree nodes[NUM_NODES*3]; - size_t storage[NUM_NODES*3]; + struct Curl_tree nodes[NUM_NODES * 3]; + size_t storage[NUM_NODES * 3]; int rc; int i, j; struct curltime tv_now = {0, 0}; @@ -75,7 +75,7 @@ static CURLcode test_unit1309(const char *arg) struct curltime key; key.tv_sec = 0; - key.tv_usec = (541*i)%1023; + key.tv_usec = (541 * i) % 1023; storage[i] = key.tv_usec; Curl_splayset(&nodes[i], &storage[i]); root = Curl_splayinsert(key, root, &nodes[i]); @@ -85,7 +85,7 @@ static CURLcode test_unit1309(const char *arg) splayprint(root, 0, 1); for(i = 0; i < NUM_NODES; i++) { - int rem = (i + 7)%NUM_NODES; + int rem = (i + 7) % NUM_NODES; curl_mprintf("Tree look:\n"); splayprint(root, 0, 1); curl_mprintf("remove pointer %d, payload %zu\n", rem, @@ -105,11 +105,11 @@ static CURLcode test_unit1309(const char *arg) struct curltime key; key.tv_sec = 0; - key.tv_usec = (541*i)%1023; + key.tv_usec = (541 * i) % 1023; /* add some nodes with the same key */ for(j = 0; j <= i % 3; j++) { - storage[i * 3 + j] = key.tv_usec*10 + j; + storage[i * 3 + j] = key.tv_usec * 10 + j; Curl_splayset(&nodes[i * 3 + j], &storage[i * 3 + j]); root = Curl_splayinsert(key, root, &nodes[i * 3 + j]); } diff --git a/tests/unit/unit1397.c b/tests/unit/unit1397.c index 7d3d4fd7f798..e56b894e36b3 100644 --- a/tests/unit/unit1397.c +++ b/tests/unit/unit1397.c @@ -103,7 +103,7 @@ static CURLcode test_unit1397(const char *arg) "did %sMATCH\n", tests[i].host, tests[i].pattern, - tests[i].match ? "NOT ": ""); + tests[i].match ? "NOT " : ""); unitfail++; } } diff --git a/tests/unit/unit1398.c b/tests/unit/unit1398.c index 1b72bf1163b1..abd4447ca464 100644 --- a/tests/unit/unit1398.c +++ b/tests/unit/unit1398.c @@ -118,7 +118,7 @@ static CURLcode test_unit1398(const char *arg) "%s%s%s%s%s%s%s%s%s%s" /* 100 */ "%s%s%s%s%s%s%s%s%s%s" /* 110 */ "%s%s%s%s%s%s%s%s%s%s" /* 120 */ - "%s%s%s%s%s%s%s%s%s", /* 129 */ + "%s%s%s%s%s%s%s%s%s", /* 129 */ "a", "", "", "", "", "", "", "", "", "", /* 10 */ "b", "", "", "", "", "", "", "", "", "", /* 20 */ @@ -132,8 +132,8 @@ static CURLcode test_unit1398(const char *arg) "j", "", "", "", "", "", "", "", "", "", /* 100 */ "k", "", "", "", "", "", "", "", "", "", /* 110 */ "l", "", "", "", "", "", "", "", "", "", /* 120 */ - "m", "", "", "", "", "", "", "", "" /* 129 */ - ); + "m", "", "", "", "", "", "", "", "" /* 129 */ + ); fail_unless(rc == 0, "return code should be 0"); /* 128 input % flags */ @@ -150,7 +150,7 @@ static CURLcode test_unit1398(const char *arg) "%s%s%s%s%s%s%s%s%s%s" /* 100 */ "%s%s%s%s%s%s%s%s%s%s" /* 110 */ "%s%s%s%s%s%s%s%s%s%s" /* 120 */ - "%s%s%s%s%s%s%s%s", /* 128 */ + "%s%s%s%s%s%s%s%s", /* 128 */ "a", "", "", "", "", "", "", "", "", "", /* 10 */ "b", "", "", "", "", "", "", "", "", "", /* 20 */ @@ -164,8 +164,8 @@ static CURLcode test_unit1398(const char *arg) "j", "", "", "", "", "", "", "", "", "", /* 100 */ "k", "", "", "", "", "", "", "", "", "", /* 110 */ "l", "", "", "", "", "", "", "", "", "", /* 120 */ - "m", "", "", "", "", "", "", "" /* 128 */ - ); + "m", "", "", "", "", "", "", "" /* 128 */ + ); fail_unless(rc == 13, "return code should be 13"); /* 129 output segments */ @@ -176,8 +176,8 @@ static CURLcode test_unit1398(const char *arg) "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" /* 80 */ "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" /* 100 */ "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" /* 120 */ - "%%%%%%%%%%%%%%%%%%" /* 129 */ - ); + "%%%%%%%%%%%%%%%%%%" /* 129 */ + ); fail_unless(rc == 0, "return code should be 0"); /* 128 output segments */ @@ -188,8 +188,8 @@ static CURLcode test_unit1398(const char *arg) "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" /* 80 */ "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" /* 100 */ "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" /* 120 */ - "%%%%%%%%%%%%%%%%" /* 128 */ - ); + "%%%%%%%%%%%%%%%%" /* 128 */ + ); fail_unless(rc == 128, "return code should be 128"); UNITTEST_END_SIMPLE diff --git a/tests/unit/unit1601.c b/tests/unit/unit1601.c index d31866bb741a..fa7743785dcf 100644 --- a/tests/unit/unit1601.c +++ b/tests/unit/unit1601.c @@ -37,7 +37,7 @@ static CURLcode test_unit1601(const char *arg) unsigned char output[MD5_DIGEST_LEN]; unsigned char *testp = output; - Curl_md5it(output, (const unsigned char *) string1, strlen(string1)); + Curl_md5it(output, (const unsigned char *)string1, strlen(string1)); verify_memory(testp, "\xc4\xca\x42\x38\xa0\xb9\x23\x82\x0d\xcc\x50\x9a\x6f" "\x75\x84\x9b", MD5_DIGEST_LEN); diff --git a/tests/unit/unit1606.c b/tests/unit/unit1606.c index 4e290db72a76..c7f3d718c7d4 100644 --- a/tests/unit/unit1606.c +++ b/tests/unit/unit1606.c @@ -82,18 +82,12 @@ static CURLcode test_unit1606(const char *arg) UNITTEST_BEGIN(t1606_setup(&easy)) - fail_unless(runawhile(easy, 41, 41, 40, 0) == 41, - "wrong low speed timeout"); - fail_unless(runawhile(easy, 21, 21, 20, 0) == 21, - "wrong low speed timeout"); - fail_unless(runawhile(easy, 60, 60, 40, 0) == 60, - "wrong log speed timeout"); - fail_unless(runawhile(easy, 50, 50, 40, 0) == 50, - "wrong log speed timeout"); - fail_unless(runawhile(easy, 40, 40, 40, 0) == 99, - "should not time out"); - fail_unless(runawhile(easy, 10, 50, 100, 2) == 36, - "bad timeout"); + fail_unless(runawhile(easy, 41, 41, 40, 0) == 41, "wrong low speed timeout"); + fail_unless(runawhile(easy, 21, 21, 20, 0) == 21, "wrong low speed timeout"); + fail_unless(runawhile(easy, 60, 60, 40, 0) == 60, "wrong log speed timeout"); + fail_unless(runawhile(easy, 50, 50, 40, 0) == 50, "wrong log speed timeout"); + fail_unless(runawhile(easy, 40, 40, 40, 0) == 99, "should not time out"); + fail_unless(runawhile(easy, 10, 50, 100, 2) == 36, "bad timeout"); UNITTEST_END(t1606_stop(easy)) } diff --git a/tests/unit/unit1610.c b/tests/unit/unit1610.c index 73a546a85eaf..5c47fe28e2c6 100644 --- a/tests/unit/unit1610.c +++ b/tests/unit/unit1610.c @@ -44,14 +44,14 @@ static CURLcode test_unit1610(const char *arg) unsigned char output[CURL_SHA256_DIGEST_LENGTH]; unsigned char *testp = output; - Curl_sha256it(output, (const unsigned char *) string1, strlen(string1)); + Curl_sha256it(output, (const unsigned char *)string1, strlen(string1)); verify_memory(testp, "\x6b\x86\xb2\x73\xff\x34\xfc\xe1\x9d\x6b\x80\x4e\xff\x5a\x3f" "\x57\x47\xad\xa4\xea\xa2\x2f\x1d\x49\xc0\x1e\x52\xdd\xb7\x87" "\x5b\x4b", CURL_SHA256_DIGEST_LENGTH); - Curl_sha256it(output, (const unsigned char *) string2, strlen(string2)); + Curl_sha256it(output, (const unsigned char *)string2, strlen(string2)); verify_memory(testp, "\xcb\xb1\x6a\x8a\xb9\xcb\xb9\x35\xa8\xcb\xa0\x2e\x28\xc0\x26" diff --git a/tests/unit/unit1611.c b/tests/unit/unit1611.c index 5337aa33a319..88c79eb3d9af 100644 --- a/tests/unit/unit1611.c +++ b/tests/unit/unit1611.c @@ -35,13 +35,13 @@ static CURLcode test_unit1611(const char *arg) unsigned char output[MD4_DIGEST_LENGTH]; unsigned char *testp = output; - Curl_md4it(output, (const unsigned char *) string1, strlen(string1)); + Curl_md4it(output, (const unsigned char *)string1, strlen(string1)); verify_memory(testp, "\x8b\xe1\xec\x69\x7b\x14\xad\x3a\x53\xb3\x71\x43\x61\x20\x64" "\x1d", MD4_DIGEST_LENGTH); - Curl_md4it(output, (const unsigned char *) string2, strlen(string2)); + Curl_md4it(output, (const unsigned char *)string2, strlen(string2)); verify_memory(testp, "\xa7\x16\x1c\xad\x7e\xbe\xdb\xbc\xf8\xc7\x23\x10\x2d\x2c\xe2" diff --git a/tests/unit/unit1612.c b/tests/unit/unit1612.c index 0cc0c0254667..7d8c9acf96b6 100644 --- a/tests/unit/unit1612.c +++ b/tests/unit/unit1612.c @@ -40,8 +40,8 @@ static CURLcode test_unit1612(const char *arg) unsigned char *testp = output; Curl_hmacit(&Curl_HMAC_MD5, - (const unsigned char *) password, strlen(password), - (const unsigned char *) string1, strlen(string1), + (const unsigned char *)password, strlen(password), + (const unsigned char *)string1, strlen(string1), output); verify_memory(testp, @@ -49,8 +49,8 @@ static CURLcode test_unit1612(const char *arg) "\x37", HMAC_MD5_LENGTH); Curl_hmacit(&Curl_HMAC_MD5, - (const unsigned char *) password, strlen(password), - (const unsigned char *) string2, strlen(string2), + (const unsigned char *)password, strlen(password), + (const unsigned char *)string2, strlen(string2), output); verify_memory(testp, diff --git a/tests/unit/unit1614.c b/tests/unit/unit1614.c index 10140ee60282..675133e5adf6 100644 --- a/tests/unit/unit1614.c +++ b/tests/unit/unit1614.c @@ -34,12 +34,12 @@ static CURLcode test_unit1614(const char *arg) int err = 0; struct check { - const char *a; + const char *a; const char *n; unsigned int bits; bool match; }; - struct check list4[]= { + struct check list4[] = { { "192.160.0.1", "192.160.0.1", 33, FALSE}, { "192.160.0.1", "192.160.0.1", 32, TRUE}, { "192.160.0.1", "192.160.0.1", 0, TRUE}, @@ -55,7 +55,7 @@ static CURLcode test_unit1614(const char *arg) { NULL, NULL, 0, FALSE} /* end marker */ }; #ifdef USE_IPV6 - struct check list6[]= { + struct check list6[] = { { "::1", "::1", 0, TRUE}, { "::1", "::1", 128, TRUE}, { "::1", "0:0::1", 128, TRUE}, @@ -69,7 +69,7 @@ static CURLcode test_unit1614(const char *arg) const char *n; bool match; }; - struct noproxy list[]= { + struct noproxy list[] = { { "www.example.com", "localhost .example.com .example.de", FALSE}, { "www.example.com", "localhost,.example.com,.example.de", TRUE}, { "www.example.com.", "localhost,.example.com,.example.de", TRUE}, @@ -161,7 +161,7 @@ static CURLcode test_unit1614(const char *arg) if(match != list4[i].match) { curl_mfprintf(stderr, "%s in %s/%u should %smatch\n", list4[i].a, list4[i].n, list4[i].bits, - list4[i].match ? "": "not "); + list4[i].match ? "" : "not "); err++; } } @@ -171,7 +171,7 @@ static CURLcode test_unit1614(const char *arg) if(match != list6[i].match) { curl_mfprintf(stderr, "%s in %s/%u should %smatch\n", list6[i].a, list6[i].n, list6[i].bits, - list6[i].match ? "": "not "); + list6[i].match ? "" : "not "); err++; } } @@ -181,7 +181,7 @@ static CURLcode test_unit1614(const char *arg) if(match != list[i].match) { curl_mfprintf(stderr, "%s in %s should %smatch\n", list[i].a, list[i].n, - list[i].match ? "": "not "); + list[i].match ? "" : "not "); err++; } } diff --git a/tests/unit/unit1615.c b/tests/unit/unit1615.c index 44dc1ae04545..fadb1aaa59b4 100644 --- a/tests/unit/unit1615.c +++ b/tests/unit/unit1615.c @@ -113,31 +113,31 @@ static CURLcode test_unit1615(const char *arg) /* Mute compiler warnings in 'verify_memory' macros below */ computed_hash = output_buf; - Curl_sha512_256it(output_buf, (const unsigned char *) test_str1, + Curl_sha512_256it(output_buf, (const unsigned char *)test_str1, CURL_ARRAYSIZE(test_str1) - 1); verify_memory(computed_hash, precomp_hash1, CURL_SHA512_256_DIGEST_LENGTH); - Curl_sha512_256it(output_buf, (const unsigned char *) test_str2, + Curl_sha512_256it(output_buf, (const unsigned char *)test_str2, CURL_ARRAYSIZE(test_str2) - 1); verify_memory(computed_hash, precomp_hash2, CURL_SHA512_256_DIGEST_LENGTH); - Curl_sha512_256it(output_buf, (const unsigned char *) test_str3, + Curl_sha512_256it(output_buf, (const unsigned char *)test_str3, CURL_ARRAYSIZE(test_str3) - 1); verify_memory(computed_hash, precomp_hash3, CURL_SHA512_256_DIGEST_LENGTH); - Curl_sha512_256it(output_buf, (const unsigned char *) test_str4, + Curl_sha512_256it(output_buf, (const unsigned char *)test_str4, CURL_ARRAYSIZE(test_str4) - 1); verify_memory(computed_hash, precomp_hash4, CURL_SHA512_256_DIGEST_LENGTH); - Curl_sha512_256it(output_buf, (const unsigned char *) test_str5, + Curl_sha512_256it(output_buf, (const unsigned char *)test_str5, CURL_ARRAYSIZE(test_str5) - 1); verify_memory(computed_hash, precomp_hash5, CURL_SHA512_256_DIGEST_LENGTH); - Curl_sha512_256it(output_buf, (const unsigned char *) test_str6, + Curl_sha512_256it(output_buf, (const unsigned char *)test_str6, CURL_ARRAYSIZE(test_str6) - 1); verify_memory(computed_hash, precomp_hash6, CURL_SHA512_256_DIGEST_LENGTH); - Curl_sha512_256it(output_buf, (const unsigned char *) test_str7, + Curl_sha512_256it(output_buf, (const unsigned char *)test_str7, CURL_ARRAYSIZE(test_str7) - 1); verify_memory(computed_hash, precomp_hash7, CURL_SHA512_256_DIGEST_LENGTH); diff --git a/tests/unit/unit1620.c b/tests/unit/unit1620.c index 4c1674f5bd54..b04424ae3bd3 100644 --- a/tests/unit/unit1620.c +++ b/tests/unit/unit1620.c @@ -116,8 +116,7 @@ static CURLcode test_unit1620(const char *arg) Curl_freeset(empty); for(i = (enum dupstring)0; i < STRING_LAST; i++) { - fail_unless(empty->set.str[i] == NULL, - "Curl_free() did not set to NULL"); + fail_unless(empty->set.str[i] == NULL, "Curl_free() did not set to NULL"); } rc = Curl_close(&empty); diff --git a/tests/unit/unit1650.c b/tests/unit/unit1650.c index 89e72262d384..309515d9b125 100644 --- a/tests/unit/unit1650.c +++ b/tests/unit/unit1650.c @@ -205,7 +205,7 @@ static CURLcode test_unit1650(const char *arg) int j; for(j = 0; j < 16; j += 2) { size_t l; - curl_msnprintf(ptr, len, "%s%02x%02x", j?":":"", a->ip.v6[j], + curl_msnprintf(ptr, len, "%s%02x%02x", j ? ":" : "", a->ip.v6[j], a->ip.v6[j + 1]); l = strlen(ptr); len -= l; @@ -232,12 +232,12 @@ static CURLcode test_unit1650(const char *arg) } /* pass all sizes into the decoder until full */ - for(i = 0; i < sizeof(full49)-1; i++) { + for(i = 0; i < sizeof(full49) - 1; i++) { struct dohentry d; DOHcode rc; memset(&d, 0, sizeof(d)); - rc = doh_resp_decode((const unsigned char *)full49, i, CURL_DNS_TYPE_A, - &d); + rc = doh_resp_decode((const unsigned char *)full49, + i, CURL_DNS_TYPE_A, &d); if(!rc) { /* none of them should work */ curl_mfprintf(stderr, "%zu: %d\n", i, rc); @@ -250,8 +250,8 @@ static CURLcode test_unit1650(const char *arg) struct dohentry d; DOHcode rc; memset(&d, 0, sizeof(d)); - rc = doh_resp_decode((const unsigned char *)&full49[i], sizeof(full49)-i-1, - CURL_DNS_TYPE_A, &d); + rc = doh_resp_decode((const unsigned char *)&full49[i], + sizeof(full49) - i - 1, CURL_DNS_TYPE_A, &d); if(!rc) { /* none of them should work */ curl_mfprintf(stderr, "2 %zu: %d\n", i, rc); @@ -264,8 +264,8 @@ static CURLcode test_unit1650(const char *arg) struct dohentry d; struct dohaddr *a; memset(&d, 0, sizeof(d)); - rc = doh_resp_decode((const unsigned char *)full49, sizeof(full49)-1, - CURL_DNS_TYPE_A, &d); + rc = doh_resp_decode((const unsigned char *)full49, + sizeof(full49) - 1, CURL_DNS_TYPE_A, &d); fail_if(d.numaddr != 1, "missing address"); a = &d.addr[0]; p = &a->ip.v4[0]; diff --git a/tests/unit/unit1651.c b/tests/unit/unit1651.c index d3620d99f299..ffaea47b20ea 100644 --- a/tests/unit/unit1651.c +++ b/tests/unit/unit1651.c @@ -360,10 +360,10 @@ static CURLcode test_unit1651(const char *arg) /* a poor man's fuzzing of some initial data to make sure nothing bad happens */ - for(byte = 1 ; byte < 255; byte += 17) { + for(byte = 1; byte < 255; byte += 17) { for(i = 0; i < 45; i++) { unsigned char backup = cert[i]; - cert[i] = (unsigned char) (byte & 0xff); + cert[i] = (unsigned char)(byte & 0xff); (void)Curl_extract_certinfo(data, 0, beg, end); cert[i] = backup; } diff --git a/tests/unit/unit1655.c b/tests/unit/unit1655.c index ab42b971ef51..91aca3f1a4a3 100644 --- a/tests/unit/unit1655.c +++ b/tests/unit/unit1655.c @@ -121,7 +121,7 @@ static CURLcode test_unit1655(const char *arg) else { if(d == DOH_OK) { fail_unless(olen <= sizeof(victim.dohbuffer), - "wrote outside bounds"); + "wrote outside bounds"); fail_unless(olen > strlen(name), "unrealistic low size"); } } diff --git a/tests/unit/unit1656.c b/tests/unit/unit1656.c index 322aa2dbe329..7cdca884b808 100644 --- a/tests/unit/unit1656.c +++ b/tests/unit/unit1656.c @@ -95,7 +95,7 @@ static CURLcode test_unit1656(const char *arg) struct dynbuf dbuf; bool all_ok = TRUE; - curlx_dyn_init(&dbuf, 32*1024); + curlx_dyn_init(&dbuf, 32 * 1024); if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { curl_mfprintf(stderr, "curl_global_init() failed\n"); diff --git a/tests/unit/unit1657.c b/tests/unit/unit1657.c index c03cd51f55a8..850b3ef73086 100644 --- a/tests/unit/unit1657.c +++ b/tests/unit/unit1657.c @@ -93,7 +93,7 @@ static CURLcode test_unit1657(const char *arg) bool all_ok = TRUE; struct dynbuf dbuf; - curlx_dyn_init(&dbuf, 32*1024); + curlx_dyn_init(&dbuf, 32 * 1024); if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { curl_mfprintf(stderr, "curl_global_init() failed\n"); diff --git a/tests/unit/unit1660.c b/tests/unit/unit1660.c index 376f6bdcfa45..6b1dcce9fc4d 100644 --- a/tests/unit/unit1660.c +++ b/tests/unit/unit1660.c @@ -130,7 +130,7 @@ static CURLcode test_unit1660(const char *arg) Curl_hsts_loadfile(easy, h, arg); - for(i = 0; headers[i].host ; i++) { + for(i = 0; headers[i].host; i++) { if(headers[i].hdr) { res = Curl_hsts_parse(h, headers[i].host, headers[i].hdr); diff --git a/tests/unit/unit1661.c b/tests/unit/unit1661.c index d9aa2a61f14e..569b06760b2b 100644 --- a/tests/unit/unit1661.c +++ b/tests/unit/unit1661.c @@ -78,7 +78,7 @@ static CURLcode test_unit1661(const char *arg) /** * testing Curl_bufref_ptr */ - fail_unless((const char *) Curl_bufref_ptr(&bufref) == buffer, + fail_unless((const char *)Curl_bufref_ptr(&bufref) == buffer, "Wrong pointer value returned"); /** diff --git a/tests/unit/unit1663.c b/tests/unit/unit1663.c index e4431930a410..e0c77c9d7849 100644 --- a/tests/unit/unit1663.c +++ b/tests/unit/unit1663.c @@ -39,12 +39,11 @@ static CURLcode t1663_setup(void) return res; } -static void t1663_parse( - const char *input_data, - const char *exp_dev, - const char *exp_iface, - const char *exp_host, - CURLcode exp_rc) +static void t1663_parse(const char *input_data, + const char *exp_dev, + const char *exp_iface, + const char *exp_host, + CURLcode exp_rc) { char *dev = NULL; char *iface = NULL; diff --git a/tests/unit/unit2600.c b/tests/unit/unit2600.c index b69b675b3b1a..9af844ca6387 100644 --- a/tests/unit/unit2600.c +++ b/tests/unit/unit2600.c @@ -238,8 +238,7 @@ static CURLcode cf_test_create(struct Curl_cfilter **pcf, return res; } -static void check_result(const struct test_case *tc, - struct test_result *tr) +static void check_result(const struct test_case *tc, struct test_result *tr) { char msg[256]; timediff_t duration_ms; @@ -247,8 +246,7 @@ static void check_result(const struct test_case *tc, duration_ms = curlx_timediff_ms(tr->ended, tr->started); curl_mfprintf(stderr, "%d: test case took %dms\n", tc->id, (int)duration_ms); - if(tr->res != tc->exp_res - && CURLE_OPERATION_TIMEDOUT != tr->res) { + if(tr->res != tc->exp_res && CURLE_OPERATION_TIMEDOUT != tr->res) { /* on CI we encounter the TIMEOUT result, since images get less CPU * and events are not as sharply timed. */ curl_msprintf(msg, "%d: expected result %d but got %d", diff --git a/tests/unit/unit2601.c b/tests/unit/unit2601.c index 8411c19e9878..6a1ca2f1bd36 100644 --- a/tests/unit/unit2601.c +++ b/tests/unit/unit2601.c @@ -80,7 +80,7 @@ static void check_bufq(size_t pool_spares, size_t chunk_size, size_t max_chunks, size_t wsize, size_t rsize, int opts) { - static unsigned char test_data[32*1024]; + static unsigned char test_data[32 * 1024]; struct bufq q; struct bufc_pool pool; @@ -167,7 +167,7 @@ static void check_bufq(size_t pool_spares, /* Test SOFT_LIMIT option */ Curl_bufq_free(&q); - Curl_bufq_init2(&q, chunk_size, max_chunks, (opts|BUFQ_OPT_SOFT_LIMIT)); + Curl_bufq_init2(&q, chunk_size, max_chunks, (opts | BUFQ_OPT_SOFT_LIMIT)); nwritten = 0; while(!Curl_bufq_is_full(&q)) { res = Curl_bufq_write(&q, test_data, wsize, &n2); @@ -212,9 +212,9 @@ static CURLcode test_unit2601(const char *arg) struct bufq q; size_t n; CURLcode res; - unsigned char buf[16*1024]; + unsigned char buf[16 * 1024]; - Curl_bufq_init(&q, 8*1024, 12); + Curl_bufq_init(&q, 8 * 1024, 12); res = Curl_bufq_read(&q, buf, 128, &n); fail_unless(res && res == CURLE_AGAIN, "read empty fail"); Curl_bufq_free(&q); @@ -225,7 +225,7 @@ static CURLcode test_unit2601(const char *arg) check_bufq(0, 1024, 4, 16000, 3000, BUFQ_OPT_NONE); check_bufq(0, 8000, 10, 1234, 1234, BUFQ_OPT_NONE); - check_bufq(0, 8000, 10, 8*1024, 4*1024, BUFQ_OPT_NONE); + check_bufq(0, 8000, 10, 8 * 1024, 4 * 1024, BUFQ_OPT_NONE); check_bufq(0, 1024, 4, 128, 128, BUFQ_OPT_NO_SPARES); check_bufq(0, 1024, 4, 129, 127, BUFQ_OPT_NO_SPARES); diff --git a/tests/unit/unit2602.c b/tests/unit/unit2602.c index da2b7dba5496..684fa3db8332 100644 --- a/tests/unit/unit2602.c +++ b/tests/unit/unit2602.c @@ -85,7 +85,7 @@ static CURLcode test_unit2602(const char *arg) Curl_dynhds_reset(&hds); Curl_dynhds_free(&hds); - Curl_dynhds_init(&hds, 128, 4*1024); + Curl_dynhds_init(&hds, 128, 4 * 1024); fail_if(Curl_dynhds_add(&hds, "test1", 5, "123", 3), "add failed"); fail_if(Curl_dynhds_add(&hds, "test1", 5, "123", 3), "add failed"); fail_if(Curl_dynhds_cadd(&hds, "blablabla", "thingies"), "add failed"); @@ -100,18 +100,18 @@ static CURLcode test_unit2602(const char *arg) fail_unless(Curl_dynhds_ccount_name(&hds, "bLABlaBlA") == 0, "should"); fail_if(Curl_dynhds_cadd(&hds, "Bla-Bla", "thingies"), "add failed"); - curlx_dyn_init(&dbuf, 32*1024); + curlx_dyn_init(&dbuf, 32 * 1024); fail_if(Curl_dynhds_h1_dprint(&hds, &dbuf), "h1 print failed"); if(curlx_dyn_ptr(&dbuf)) { fail_if(strcmp(curlx_dyn_ptr(&dbuf), "test1: 123\r\ntest1: 123\r\nBla-Bla: thingies\r\n"), - "h1 format differs"); + "h1 format differs"); } curlx_dyn_free(&dbuf); } Curl_dynhds_free(&hds); - Curl_dynhds_init(&hds, 128, 4*1024); + Curl_dynhds_init(&hds, 128, 4 * 1024); /* continuation without previous header fails */ res = Curl_dynhds_h1_cadd_line(&hds, " indented value"); fail_unless(res, "add should have failed"); @@ -124,13 +124,13 @@ static CURLcode test_unit2602(const char *arg) fail_if(Curl_dynhds_h1_cadd_line(&hds, "ti3: val1"), "add"); fail_if(Curl_dynhds_h1_cadd_line(&hds, " val2"), "add indent"); - curlx_dyn_init(&dbuf, 32*1024); + curlx_dyn_init(&dbuf, 32 * 1024); fail_if(Curl_dynhds_h1_dprint(&hds, &dbuf), "h1 print failed"); if(curlx_dyn_ptr(&dbuf)) { curl_mfprintf(stderr, "indent concat: %s\n", curlx_dyn_ptr(&dbuf)); fail_if(strcmp(curlx_dyn_ptr(&dbuf), "ti1: val1 val2\r\nti2: val1 val2\r\nti3: val1 val2\r\n"), - "wrong format"); + "wrong format"); } curlx_dyn_free(&dbuf); diff --git a/tests/unit/unit3200.c b/tests/unit/unit3200.c index fe00da939d57..bfd4d1181b84 100644 --- a/tests/unit/unit3200.c +++ b/tests/unit/unit3200.c @@ -94,68 +94,68 @@ static CURLcode test_unit3200(const char *arg) curl_mfprintf(stderr, "Test %zd...", i); switch(i) { - case 0: - res = Curl_get_line(&buf, fp, &eof); - line = curlx_dyn_ptr(&buf); - fail_unless(!res && line && !strcmp("LINE1\n", line), - "First line failed (1)"); - res = Curl_get_line(&buf, fp, &eof); - line = curlx_dyn_ptr(&buf); - fail_unless(!res && line && !strcmp("LINE2 NEWLINE\n", line), - "Second line failed (1)"); - res = Curl_get_line(&buf, fp, &eof); - abort_unless(eof, "Missed EOF (1)"); - break; - case 1: - res = Curl_get_line(&buf, fp, &eof); - line = curlx_dyn_ptr(&buf); - fail_unless(!res && line && !strcmp("LINE1\n", line), - "First line failed (2)"); - res = Curl_get_line(&buf, fp, &eof); - line = curlx_dyn_ptr(&buf); - fail_unless(!res && line && !strcmp("LINE2 NONEWLINE\n", line), - "Second line failed (2)"); - res = Curl_get_line(&buf, fp, &eof); - abort_unless(eof, "Missed EOF (2)"); - break; - case 2: - res = Curl_get_line(&buf, fp, &eof); - line = curlx_dyn_ptr(&buf); - fail_unless(!res && line && !strcmp("LINE1\n", line), - "First line failed (3)"); - res = Curl_get_line(&buf, fp, &eof); - fail_unless(!curlx_dyn_len(&buf), - "Did not detect max read on EOF (3)"); - break; - case 3: - res = Curl_get_line(&buf, fp, &eof); - line = curlx_dyn_ptr(&buf); - fail_unless(!res && line && !strcmp("LINE1\n", line), - "First line failed (4)"); - res = Curl_get_line(&buf, fp, &eof); - fail_unless(!curlx_dyn_len(&buf), - "Did not ignore partial on EOF (4)"); - break; - case 4: - res = Curl_get_line(&buf, fp, &eof); - line = curlx_dyn_ptr(&buf); - fail_unless(!res && line && !strcmp("LINE1\n", line), - "First line failed (5)"); - res = Curl_get_line(&buf, fp, &eof); - fail_unless(!curlx_dyn_len(&buf), - "Did not bail out on too long line"); - break; - case 5: - res = Curl_get_line(&buf, fp, &eof); - line = curlx_dyn_ptr(&buf); - fail_unless(!res && line && !strcmp("LINE1\x1aTEST\n", line), - "Missed/Misinterpreted ^Z (6)"); - res = Curl_get_line(&buf, fp, &eof); - abort_unless(eof, "Missed EOF (6)"); - break; - default: - abort_unless(1, "Unknown case"); - break; + case 0: + res = Curl_get_line(&buf, fp, &eof); + line = curlx_dyn_ptr(&buf); + fail_unless(!res && line && !strcmp("LINE1\n", line), + "First line failed (1)"); + res = Curl_get_line(&buf, fp, &eof); + line = curlx_dyn_ptr(&buf); + fail_unless(!res && line && !strcmp("LINE2 NEWLINE\n", line), + "Second line failed (1)"); + res = Curl_get_line(&buf, fp, &eof); + abort_unless(eof, "Missed EOF (1)"); + break; + case 1: + res = Curl_get_line(&buf, fp, &eof); + line = curlx_dyn_ptr(&buf); + fail_unless(!res && line && !strcmp("LINE1\n", line), + "First line failed (2)"); + res = Curl_get_line(&buf, fp, &eof); + line = curlx_dyn_ptr(&buf); + fail_unless(!res && line && !strcmp("LINE2 NONEWLINE\n", line), + "Second line failed (2)"); + res = Curl_get_line(&buf, fp, &eof); + abort_unless(eof, "Missed EOF (2)"); + break; + case 2: + res = Curl_get_line(&buf, fp, &eof); + line = curlx_dyn_ptr(&buf); + fail_unless(!res && line && !strcmp("LINE1\n", line), + "First line failed (3)"); + res = Curl_get_line(&buf, fp, &eof); + fail_unless(!curlx_dyn_len(&buf), + "Did not detect max read on EOF (3)"); + break; + case 3: + res = Curl_get_line(&buf, fp, &eof); + line = curlx_dyn_ptr(&buf); + fail_unless(!res && line && !strcmp("LINE1\n", line), + "First line failed (4)"); + res = Curl_get_line(&buf, fp, &eof); + fail_unless(!curlx_dyn_len(&buf), + "Did not ignore partial on EOF (4)"); + break; + case 4: + res = Curl_get_line(&buf, fp, &eof); + line = curlx_dyn_ptr(&buf); + fail_unless(!res && line && !strcmp("LINE1\n", line), + "First line failed (5)"); + res = Curl_get_line(&buf, fp, &eof); + fail_unless(!curlx_dyn_len(&buf), + "Did not bail out on too long line"); + break; + case 5: + res = Curl_get_line(&buf, fp, &eof); + line = curlx_dyn_ptr(&buf); + fail_unless(!res && line && !strcmp("LINE1\x1aTEST\n", line), + "Missed/Misinterpreted ^Z (6)"); + res = Curl_get_line(&buf, fp, &eof); + abort_unless(eof, "Missed EOF (6)"); + break; + default: + abort_unless(1, "Unknown case"); + break; } curlx_dyn_free(&buf); curlx_fclose(fp); diff --git a/tests/unit/unit3205.c b/tests/unit/unit3205.c index bb42e9e0c629..bb35fb2f8eae 100644 --- a/tests/unit/unit3205.c +++ b/tests/unit/unit3205.c @@ -561,9 +561,9 @@ static CURLcode test_unit3205(const char *arg) /* suites matched by EDH alias will return the DHE name */ if(test->id >= 0x0011 && test->id < 0x0017) { if(expect && memcmp(expect, "EDH-", 4) == 0) - expect = (char *) memcpy(strcpy(alt, expect), "DHE-", 4); + expect = (char *)memcpy(strcpy(alt, expect), "DHE-", 4); if(expect && memcmp(expect + 4, "EDH-", 4) == 0) - expect = (char *) memcpy(strcpy(alt, expect) + 4, "DHE-", 4) - 4; + expect = (char *)memcpy(strcpy(alt, expect) + 4, "DHE-", 4) - 4; } if(expect && strcmp(buf, expect) != 0) { diff --git a/tests/unit/unit3211.c b/tests/unit/unit3211.c index 1ec30ac9a2af..7f6c616909c0 100644 --- a/tests/unit/unit3211.c +++ b/tests/unit/unit3211.c @@ -84,7 +84,7 @@ static void check_set(const char *name, unsigned int capacity, } /* The count is half */ c = Curl_uint32_bset_count(&bset); - fail_unless(c == slen/2, "set count is wrong"); + fail_unless(c == slen / 2, "set count is wrong"); Curl_uint32_bset_clear(&bset); c = Curl_uint32_bset_count(&bset); @@ -107,7 +107,7 @@ static void check_set(const char *name, unsigned int capacity, for(i = 0; i < slen; i++) /* all still present after resize back */ fail_unless(Curl_uint32_bset_contains(&bset, s[i]), "unexpectedly lost"); - fail_unless(!Curl_uint32_bset_resize(&bset, capacity/2), + fail_unless(!Curl_uint32_bset_resize(&bset, capacity / 2), "resize half failed"); /* halved the size, what numbers remain in set? */ c = Curl_uint32_bset_capacity(&bset); diff --git a/tests/unit/unit3213.c b/tests/unit/unit3213.c index b0d4d2ced557..dbd26f4aa49c 100644 --- a/tests/unit/unit3213.c +++ b/tests/unit/unit3213.c @@ -75,7 +75,7 @@ static void check_spbset(const char *name, const unsigned int *s, size_t slen) } /* The count is half */ c = Curl_uint32_spbset_count(&bset); - fail_unless(c == slen/2, "set count is wrong"); + fail_unless(c == slen / 2, "set count is wrong"); Curl_uint32_spbset_clear(&bset); c = Curl_uint32_spbset_count(&bset); diff --git a/tests/unit/unit3216.c b/tests/unit/unit3216.c index cbe9a5f0bf51..0f9d27492c03 100644 --- a/tests/unit/unit3216.c +++ b/tests/unit/unit3216.c @@ -45,7 +45,7 @@ static CURLcode test_unit3216(const char *arg) fail_unless(Curl_rlimit_avail(&r, ts) == 0, "blocked inf"); Curl_rlimit_block(&r, FALSE, ts); fail_unless(Curl_rlimit_avail(&r, ts) == CURL_OFF_T_MAX, - "unblocked unlimited"); + "unblocked unlimited"); /* A ratelimit that give 10 tokens per second */ ts = curlx_now(); From 06e16167d62984976b7a3ea2fcfa61813fd6d81c Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 28 Nov 2025 17:16:31 +0100 Subject: [PATCH 116/415] memdebug: buffer output data Instead of writing each line to file immediately, this now stores them in an in-memory buffer until that gets full or curl exits. To make it run faster and write to file less often. Closes #19750 --- lib/memdebug.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/lib/memdebug.c b/lib/memdebug.c index 9fd54d026b69..329b11ea793b 100644 --- a/lib/memdebug.c +++ b/lib/memdebug.c @@ -62,6 +62,10 @@ static long memsize = 0; /* set number of mallocs allowed */ static struct backtrace_state *btstate; #endif +#define KEEPSIZE 10000 +static char membuf[KEEPSIZE]; +static size_t memwidx = 0; /* write index */ + /* LeakSantizier (LSAN) calls _exit() instead of exit() when a leak is detected on exit so the logfile must be closed explicitly or data could be lost. Though _exit() does not call atexit handlers such as this, LSAN's call to @@ -71,6 +75,8 @@ static void curl_dbg_cleanup(void) if(curl_dbg_logfile && curl_dbg_logfile != stderr && curl_dbg_logfile != stdout) { + if(memwidx) + fwrite(membuf, 1, memwidx, curl_dbg_logfile); /* !checksrc! disable BANNEDFUNC 1 */ fclose(curl_dbg_logfile); } @@ -506,7 +512,7 @@ int curl_dbg_fclose(FILE *file, int line, const char *source) void curl_dbg_log(const char *format, ...) { char buf[1024]; - int nchars; + size_t nchars; va_list ap; if(!curl_dbg_logfile) @@ -519,8 +525,20 @@ void curl_dbg_log(const char *format, ...) if(nchars > (int)sizeof(buf) - 1) nchars = (int)sizeof(buf) - 1; - if(nchars > 0) - fwrite(buf, 1, (size_t)nchars, curl_dbg_logfile); + if(nchars > 0) { + if(KEEPSIZE - nchars < memwidx) { + /* flush */ + fwrite(membuf, 1, memwidx, curl_dbg_logfile); + fflush(curl_dbg_logfile); + memwidx = 0; + } + if(memwidx) { + /* the previous line ends with a newline */ + DEBUGASSERT(membuf[memwidx - 1] == '\n'); + } + memcpy(&membuf[memwidx], buf, nchars); + memwidx += nchars; + } } #endif /* CURLDEBUG */ From 16f073ef49f94412000218c9f6ad04e3fd7e4d01 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Thu, 27 Mar 2025 01:15:16 +0100 Subject: [PATCH 117/415] cmake: define dependencies as `IMPORTED` interface targets Rework the way curl's custom Find modules advertise their properties. Before this patch, Find modules returned detected dependency properties (header dirs, libs, libdirs, C flags, etc.) via global variables. curl's main `CMakeLists.txt` copied their values into global lists, which it later applied to targets. This solution worked internally, but it was unsuited for the public, distributed `CURLConfig.cmake` and publishing curl's Find modules with it, due to polluting the namespace of consumer projects. It's also impractical to apply the many individual variables to every targets depending on libcurl. To allow using Find modules in consumer projects, this patch makes them define as imported interface targets, named `CURL::`. Then store dependency information as target properties. It avoids namespace pollution and makes the dependency information apply automatically to all targets using `CURL::libcurl_static`. Find modules continue to return `*_FOUND` and `*_VERSION` variables. For dependencies detected via `pkg-config`, CMake 3.16+ is recommended. Older CMake versions have a varying degree of support for propagating/handling library directories. This may cause issues in envs where dependencies reside in non-system locations and detected via `pkg-config` (e.g. macOS + Homebrew). Use `CURL_USE_PKGCONFIG=OFF` to fix these issues. Or upgrade to newer CMake, or link libcurl dynamically. Also: - re-enable `pkg-config` for old cmake `find_library()` integration tests. - make `curlinfo` build after these changes. - distribute local Find modules. - export the raw list of lib dependencies via `CURL_LIBRARIES_PRIVATE`. - `CURLconfig.cmake`: use curl's Find modules to detect dependencies in the consumer env. - add custom property to target property debug function. - the curl build process no longer modifies `CMAKE_C_FLAGS`. Follow-up to e86542038dda88dadf8959584e803895f979310c #17047 Ref: #14930 Ref: https://github.com/libssh2/libssh2/pull/1535 Ref: https://github.com/libssh2/libssh2/pull/1571 Ref: https://github.com/libssh2/libssh2/pull/1581 Ref: https://github.com/libssh2/libssh2/pull/1623 Closes #16973 --- CMake/FindBrotli.cmake | 40 ++-- CMake/FindCares.cmake | 51 +++-- CMake/FindGSS.cmake | 73 +++--- CMake/FindGnuTLS.cmake | 47 ++-- CMake/FindLDAP.cmake | 42 ++-- CMake/FindLibbacktrace.cmake | 29 ++- CMake/FindLibgsasl.cmake | 46 ++-- CMake/FindLibidn2.cmake | 47 ++-- CMake/FindLibpsl.cmake | 47 ++-- CMake/FindLibrtmp.cmake | 53 +++-- CMake/FindLibssh.cmake | 51 +++-- CMake/FindLibssh2.cmake | 47 ++-- CMake/FindLibuv.cmake | 47 ++-- CMake/FindMbedTLS.cmake | 54 +++-- CMake/FindNGHTTP2.cmake | 47 ++-- CMake/FindNGHTTP3.cmake | 47 ++-- CMake/FindNGTCP2.cmake | 42 ++-- CMake/FindNettle.cmake | 47 ++-- CMake/FindQuiche.cmake | 47 ++-- CMake/FindRustls.cmake | 59 +++-- CMake/FindWolfSSL.cmake | 55 +++-- CMake/FindZstd.cmake | 47 ++-- CMake/Utilities.cmake | 1 + CMake/curl-config.cmake.in | 118 ++++++++++ CMakeLists.txt | 433 +++++++++++++++-------------------- lib/CMakeLists.txt | 26 ++- src/CMakeLists.txt | 3 +- tests/cmake/test.sh | 2 +- 28 files changed, 999 insertions(+), 649 deletions(-) diff --git a/CMake/FindBrotli.cmake b/CMake/FindBrotli.cmake index d2b50d962124..981b30cafd57 100644 --- a/CMake/FindBrotli.cmake +++ b/CMake/FindBrotli.cmake @@ -29,31 +29,27 @@ # - `BROTLICOMMON_LIBRARY`: Absolute path to `brotlicommon` library. # - `BROTLIDEC_LIBRARY`: Absolute path to `brotlidec` library. # -# Result variables: +# Defines: # # - `BROTLI_FOUND`: System has brotli. -# - `BROTLI_INCLUDE_DIRS`: The brotli include directories. -# - `BROTLI_LIBRARIES`: The brotli library names. -# - `BROTLI_LIBRARY_DIRS`: The brotli library directories. -# - `BROTLI_PC_REQUIRES`: The brotli pkg-config packages. -# - `BROTLI_CFLAGS`: Required compiler flags. # - `BROTLI_VERSION`: Version of brotli. +# - `CURL::brotli`: brotli library target. -set(BROTLI_PC_REQUIRES "libbrotlidec" "libbrotlicommon") # order is significant: brotlidec then brotlicommon +set(_brotli_pc_requires "libbrotlidec" "libbrotlicommon") # order is significant: brotlidec then brotlicommon if(CURL_USE_PKGCONFIG AND NOT DEFINED BROTLI_INCLUDE_DIR AND NOT DEFINED BROTLICOMMON_LIBRARY AND NOT DEFINED BROTLIDEC_LIBRARY) find_package(PkgConfig QUIET) - pkg_check_modules(BROTLI ${BROTLI_PC_REQUIRES}) + pkg_check_modules(_brotli ${_brotli_pc_requires}) endif() -if(BROTLI_FOUND) +if(_brotli_FOUND) set(Brotli_FOUND TRUE) - set(BROTLI_VERSION ${BROTLI_libbrotlicommon_VERSION}) - string(REPLACE ";" " " BROTLI_CFLAGS "${BROTLI_CFLAGS}") - message(STATUS "Found Brotli (via pkg-config): ${BROTLI_INCLUDE_DIRS} (found version \"${BROTLI_VERSION}\")") + set(BROTLI_FOUND TRUE) + set(BROTLI_VERSION ${_brotli_libbrotlicommon_VERSION}) + message(STATUS "Found Brotli (via pkg-config): ${_brotli_INCLUDE_DIRS} (found version \"${BROTLI_VERSION}\")") else() find_path(BROTLI_INCLUDE_DIR "brotli/decode.h") find_library(BROTLICOMMON_LIBRARY NAMES "brotlicommon") @@ -68,9 +64,25 @@ else() ) if(BROTLI_FOUND) - set(BROTLI_INCLUDE_DIRS ${BROTLI_INCLUDE_DIR}) - set(BROTLI_LIBRARIES ${BROTLIDEC_LIBRARY} ${BROTLICOMMON_LIBRARY}) + set(_brotli_INCLUDE_DIRS ${BROTLI_INCLUDE_DIR}) + set(_brotli_LIBRARIES ${BROTLIDEC_LIBRARY} ${BROTLICOMMON_LIBRARY}) endif() mark_as_advanced(BROTLI_INCLUDE_DIR BROTLIDEC_LIBRARY BROTLICOMMON_LIBRARY) endif() + +if(BROTLI_FOUND) + if(CMAKE_VERSION VERSION_LESS 3.13) + link_directories(${_brotli_LIBRARY_DIRS}) + endif() + + if(NOT TARGET CURL::brotli) + add_library(CURL::brotli INTERFACE IMPORTED) + set_target_properties(CURL::brotli PROPERTIES + INTERFACE_LIBCURL_PC_MODULES "${_brotli_pc_requires}" + INTERFACE_COMPILE_OPTIONS "${_brotli_CFLAGS}" + INTERFACE_INCLUDE_DIRECTORIES "${_brotli_INCLUDE_DIRS}" + INTERFACE_LINK_DIRECTORIES "${_brotli_LIBRARY_DIRS}" + INTERFACE_LINK_LIBRARIES "${_brotli_LIBRARIES}") + endif() +endif() diff --git a/CMake/FindCares.cmake b/CMake/FindCares.cmake index ae2db52d85aa..4a20bc0af471 100644 --- a/CMake/FindCares.cmake +++ b/CMake/FindCares.cmake @@ -25,32 +25,29 @@ # # Input variables: # -# - `CARES_INCLUDE_DIR`: Absolute path to c-ares include directory. -# - `CARES_LIBRARY`: Absolute path to `cares` library. +# - `CARES_INCLUDE_DIR`: Absolute path to c-ares include directory. +# - `CARES_LIBRARY`: Absolute path to `cares` library. # -# Result variables: +# Defines: # -# - `CARES_FOUND`: System has c-ares. -# - `CARES_INCLUDE_DIRS`: The c-ares include directories. -# - `CARES_LIBRARIES`: The c-ares library names. -# - `CARES_LIBRARY_DIRS`: The c-ares library directories. -# - `CARES_PC_REQUIRES`: The c-ares pkg-config packages. -# - `CARES_CFLAGS`: Required compiler flags. -# - `CARES_VERSION`: Version of c-ares. +# - `CARES_FOUND`: System has c-ares. +# - `CARES_VERSION`: Version of c-ares. +# - `CURL::cares`: c-ares library target. -set(CARES_PC_REQUIRES "libcares") +set(_cares_pc_requires "libcares") if(CURL_USE_PKGCONFIG AND NOT DEFINED CARES_INCLUDE_DIR AND NOT DEFINED CARES_LIBRARY) find_package(PkgConfig QUIET) - pkg_check_modules(CARES ${CARES_PC_REQUIRES}) + pkg_check_modules(_cares ${_cares_pc_requires}) endif() -if(CARES_FOUND) +if(_cares_FOUND) set(Cares_FOUND TRUE) - string(REPLACE ";" " " CARES_CFLAGS "${CARES_CFLAGS}") - message(STATUS "Found Cares (via pkg-config): ${CARES_INCLUDE_DIRS} (found version \"${CARES_VERSION}\")") + set(CARES_FOUND TRUE) + set(CARES_VERSION ${_cares_VERSION}) + message(STATUS "Found Cares (via pkg-config): ${_cares_INCLUDE_DIRS} (found version \"${CARES_VERSION}\")") else() find_path(CARES_INCLUDE_DIR NAMES "ares.h") find_library(CARES_LIBRARY NAMES ${CARES_NAMES} "cares") @@ -85,13 +82,29 @@ else() ) if(CARES_FOUND) - set(CARES_INCLUDE_DIRS ${CARES_INCLUDE_DIR}) - set(CARES_LIBRARIES ${CARES_LIBRARY}) + set(_cares_INCLUDE_DIRS ${CARES_INCLUDE_DIR}) + set(_cares_LIBRARIES ${CARES_LIBRARY}) endif() mark_as_advanced(CARES_INCLUDE_DIR CARES_LIBRARY) endif() -if(CARES_FOUND AND WIN32) - list(APPEND CARES_LIBRARIES "iphlpapi") # for if_indextoname and others +if(CARES_FOUND) + if(WIN32) + list(APPEND _cares_LIBRARIES "iphlpapi") # for if_indextoname and others + endif() + + if(CMAKE_VERSION VERSION_LESS 3.13) + link_directories(${_cares_LIBRARY_DIRS}) + endif() + + if(NOT TARGET CURL::cares) + add_library(CURL::cares INTERFACE IMPORTED) + set_target_properties(CURL::cares PROPERTIES + INTERFACE_LIBCURL_PC_MODULES "${_cares_pc_requires}" + INTERFACE_COMPILE_OPTIONS "${_cares_CFLAGS}" + INTERFACE_INCLUDE_DIRECTORIES "${_cares_INCLUDE_DIRS}" + INTERFACE_LINK_DIRECTORIES "${_cares_LIBRARY_DIRS}" + INTERFACE_LINK_LIBRARIES "${_cares_LIBRARIES}") + endif() endif() diff --git a/CMake/FindGSS.cmake b/CMake/FindGSS.cmake index 89545aa74134..106c4c4edd71 100644 --- a/CMake/FindGSS.cmake +++ b/CMake/FindGSS.cmake @@ -25,19 +25,15 @@ # # Input variables: # -# - `GSS_ROOT_DIR`: Absolute path to the root installation of GSS. (also supported as environment) +# - `GSS_ROOT_DIR`: Absolute path to the root installation of GSS. (also supported as environment) # -# Result variables: +# Defines: # -# - `GSS_FOUND`: System has a GSS library. -# - `GSS_FLAVOUR`: "GNU" or "MIT" if anything found. -# - `GSS_INCLUDE_DIRS`: The GSS include directories. -# - `GSS_LIBRARIES`: The GSS library names. -# - `GSS_LIBRARY_DIRS`: The GSS library directories. -# - `GSS_PC_REQUIRES`: The GSS pkg-config packages. -# - `GSS_CFLAGS`: Required compiler flags. -# - `GSS_VERSION`: This is set to version advertised by pkg-config or read from manifest. -# In case the library is found but no version info available it is set to "unknown" +# - `GSS_FOUND`: System has a GSS library. +# - `GSS_VERSION`: This is set to version advertised by pkg-config or read from manifest. +# In case the library is found but no version info available it is set to "unknown" +# - `CURL::gss`: GSS library target. +# - CURL_GSS_FLAVOUR`: Custom property. "GNU" or "MIT" if detected. set(_gnu_modname "gss") set(_mit_modname "mit-krb5-gssapi") @@ -140,7 +136,7 @@ if(NOT _gss_FOUND) # Not found by pkg-config. Let us take more traditional appr # Older versions may not have the "--vendor" parameter. In this case we just do not care. if(NOT _gss_configure_failed AND NOT _gss_vendor MATCHES "Heimdal|heimdal") - set(GSS_FLAVOUR "MIT") # assume a default, should not really matter + set(_gss_flavour "MIT") # assume a default, should not really matter endif() else() # Either there is no config script or we are on a platform that does not provide one (Windows?) @@ -156,7 +152,7 @@ if(NOT _gss_FOUND) # Not found by pkg-config. Let us take more traditional appr cmake_pop_check_state() if(_gss_have_mit_headers) - set(GSS_FLAVOUR "MIT") + set(_gss_flavour "MIT") if(WIN32) if(CMAKE_SIZEOF_VOID_P EQUAL 8) list(APPEND _gss_libdir_suffixes "lib/AMD64") @@ -174,14 +170,14 @@ if(NOT _gss_FOUND) # Not found by pkg-config. Let us take more traditional appr find_path(_gss_INCLUDE_DIRS NAMES "gss.h" HINTS ${_gss_root_hints} PATH_SUFFIXES "include") if(_gss_INCLUDE_DIRS) - set(GSS_FLAVOUR "GNU") - set(GSS_PC_REQUIRES ${_gnu_modname}) + set(_gss_flavour "GNU") + set(_gss_pc_requires ${_gnu_modname}) set(_gss_libname "gss") endif() endif() # If we have headers, look up libraries - if(GSS_FLAVOUR) + if(_gss_flavour) set(_gss_libdir_hints ${_gss_root_hints}) if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.20) cmake_path(GET _gss_INCLUDE_DIRS PARENT_PATH _gss_calculated_potential_root) @@ -193,34 +189,28 @@ if(NOT _gss_FOUND) # Not found by pkg-config. Let us take more traditional appr find_library(_gss_LIBRARIES NAMES ${_gss_libname} HINTS ${_gss_libdir_hints} PATH_SUFFIXES ${_gss_libdir_suffixes}) endif() endif() - if(NOT GSS_FLAVOUR) + if(NOT _gss_flavour) message(FATAL_ERROR "GNU or MIT GSS is required") endif() else() # _gss_MODULE_NAME set since CMake 3.16. # _pkg_check_modules_pkg_name is undocumented and used as a fallback for CMake <3.16 versions. if(_gss_MODULE_NAME STREQUAL _gnu_modname OR _pkg_check_modules_pkg_name STREQUAL _gnu_modname) - set(GSS_FLAVOUR "GNU") - set(GSS_PC_REQUIRES ${_gnu_modname}) + set(_gss_flavour "GNU") + set(_gss_pc_requires ${_gnu_modname}) elseif(_gss_MODULE_NAME STREQUAL _mit_modname OR _pkg_check_modules_pkg_name STREQUAL _mit_modname) - set(GSS_FLAVOUR "MIT") - set(GSS_PC_REQUIRES ${_mit_modname}) + set(_gss_flavour "MIT") + set(_gss_pc_requires ${_mit_modname}) else() message(FATAL_ERROR "GNU or MIT GSS is required") endif() - message(STATUS "Found GSS/${GSS_FLAVOUR} (via pkg-config): ${_gss_INCLUDE_DIRS} (found version \"${_gss_version}\")") + message(STATUS "Found GSS/${_gss_flavour} (via pkg-config): ${_gss_INCLUDE_DIRS} (found version \"${_gss_version}\")") endif() -string(REPLACE ";" " " _gss_CFLAGS "${_gss_CFLAGS}") - -set(GSS_INCLUDE_DIRS ${_gss_INCLUDE_DIRS}) -set(GSS_LIBRARIES ${_gss_LIBRARIES}) -set(GSS_LIBRARY_DIRS ${_gss_LIBRARY_DIRS}) -set(GSS_CFLAGS ${_gss_CFLAGS}) set(GSS_VERSION ${_gss_version}) if(NOT GSS_VERSION) - if(GSS_FLAVOUR STREQUAL "MIT") + if(_gss_flavour STREQUAL "MIT") if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.24) cmake_host_system_information(RESULT _mit_version QUERY WINDOWS_REGISTRY "HKLM/SOFTWARE/MIT/Kerberos/SDK/CurrentVersion" VALUE "VersionString") @@ -234,9 +224,9 @@ if(NOT GSS_VERSION) set(GSS_VERSION "MIT Unknown") endif() else() # GNU - if(GSS_INCLUDE_DIRS AND EXISTS "${GSS_INCLUDE_DIRS}/gss.h") + if(_gss_INCLUDE_DIRS AND EXISTS "${_gss_INCLUDE_DIRS}/gss.h") set(_version_regex "#[\t ]*define[\t ]+GSS_VERSION[\t ]+\"([^\"]*)\"") - file(STRINGS "${GSS_INCLUDE_DIRS}/gss.h" _version_str REGEX "${_version_regex}") + file(STRINGS "${_gss_INCLUDE_DIRS}/gss.h" _version_str REGEX "${_version_regex}") string(REGEX REPLACE "${_version_regex}" "\\1" _version_str "${_version_str}") set(GSS_VERSION "${_version_str}") unset(_version_regex) @@ -248,8 +238,8 @@ endif() include(FindPackageHandleStandardArgs) find_package_handle_standard_args(GSS REQUIRED_VARS - GSS_FLAVOUR - GSS_LIBRARIES + _gss_flavour + _gss_LIBRARIES VERSION_VAR GSS_VERSION FAIL_MESSAGE @@ -266,3 +256,20 @@ mark_as_advanced( _gss_PREFIX _gss_version ) + +if(GSS_FOUND) + if(CMAKE_VERSION VERSION_LESS 3.13) + link_directories(${_gss_LIBRARY_DIRS}) + endif() + + if(NOT TARGET CURL::gss) + add_library(CURL::gss INTERFACE IMPORTED) + set_target_properties(CURL::gss PROPERTIES + INTERFACE_CURL_GSS_FLAVOUR "${_gss_flavour}" + INTERFACE_LIBCURL_PC_MODULES "${_gss_pc_requires}" + INTERFACE_COMPILE_OPTIONS "${_gss_CFLAGS}" + INTERFACE_INCLUDE_DIRECTORIES "${_gss_INCLUDE_DIRS}" + INTERFACE_LINK_DIRECTORIES "${_gss_LIBRARY_DIRS}" + INTERFACE_LINK_LIBRARIES "${_gss_LIBRARIES}") + endif() +endif() diff --git a/CMake/FindGnuTLS.cmake b/CMake/FindGnuTLS.cmake index 4de4f82eee38..fff57b2c293a 100644 --- a/CMake/FindGnuTLS.cmake +++ b/CMake/FindGnuTLS.cmake @@ -25,32 +25,29 @@ # # Input variables: # -# - `GNUTLS_INCLUDE_DIR`: Absolute path to GnuTLS include directory. -# - `GNUTLS_LIBRARY`: Absolute path to `gnutls` library. +# - `GNUTLS_INCLUDE_DIR`: Absolute path to GnuTLS include directory. +# - `GNUTLS_LIBRARY`: Absolute path to `gnutls` library. # -# Result variables: +# Defines: # -# - `GNUTLS_FOUND`: System has GnuTLS. -# - `GNUTLS_INCLUDE_DIRS`: The GnuTLS include directories. -# - `GNUTLS_LIBRARIES`: The GnuTLS library names. -# - `GNUTLS_LIBRARY_DIRS`: The GnuTLS library directories. -# - `GNUTLS_PC_REQUIRES`: The GnuTLS pkg-config packages. -# - `GNUTLS_CFLAGS`: Required compiler flags. -# - `GNUTLS_VERSION`: Version of GnuTLS. +# - `GNUTLS_FOUND`: System has GnuTLS. +# - `GNUTLS_VERSION`: Version of GnuTLS. +# - `CURL::gnutls`: GnuTLS library target. -set(GNUTLS_PC_REQUIRES "gnutls") +set(_gnutls_pc_requires "gnutls") if(CURL_USE_PKGCONFIG AND NOT DEFINED GNUTLS_INCLUDE_DIR AND NOT DEFINED GNUTLS_LIBRARY) find_package(PkgConfig QUIET) - pkg_check_modules(GNUTLS ${GNUTLS_PC_REQUIRES}) + pkg_check_modules(_gnutls ${_gnutls_pc_requires}) endif() -if(GNUTLS_FOUND) +if(_gnutls_FOUND) set(GnuTLS_FOUND TRUE) - string(REPLACE ";" " " GNUTLS_CFLAGS "${GNUTLS_CFLAGS}") - message(STATUS "Found GnuTLS (via pkg-config): ${GNUTLS_INCLUDE_DIRS} (found version \"${GNUTLS_VERSION}\")") + set(GNUTLS_FOUND TRUE) + set(GNUTLS_VERSION ${_gnutls_VERSION}) + message(STATUS "Found GnuTLS (via pkg-config): ${_gnutls_INCLUDE_DIRS} (found version \"${GNUTLS_VERSION}\")") else() find_path(GNUTLS_INCLUDE_DIR NAMES "gnutls/gnutls.h") find_library(GNUTLS_LIBRARY NAMES "gnutls" "libgnutls") @@ -75,9 +72,25 @@ else() ) if(GNUTLS_FOUND) - set(GNUTLS_INCLUDE_DIRS ${GNUTLS_INCLUDE_DIR}) - set(GNUTLS_LIBRARIES ${GNUTLS_LIBRARY}) + set(_gnutls_INCLUDE_DIRS ${GNUTLS_INCLUDE_DIR}) + set(_gnutls_LIBRARIES ${GNUTLS_LIBRARY}) endif() mark_as_advanced(GNUTLS_INCLUDE_DIR GNUTLS_LIBRARY) endif() + +if(GNUTLS_FOUND) + if(CMAKE_VERSION VERSION_LESS 3.13) + link_directories(${_gnutls_LIBRARY_DIRS}) + endif() + + if(NOT TARGET CURL::gnutls) + add_library(CURL::gnutls INTERFACE IMPORTED) + set_target_properties(CURL::gnutls PROPERTIES + INTERFACE_LIBCURL_PC_MODULES "${_gnutls_pc_requires}" + INTERFACE_COMPILE_OPTIONS "${_gnutls_CFLAGS}" + INTERFACE_INCLUDE_DIRECTORIES "${_gnutls_INCLUDE_DIRS}" + INTERFACE_LINK_DIRECTORIES "${_gnutls_LIBRARY_DIRS}" + INTERFACE_LINK_LIBRARIES "${_gnutls_LIBRARIES}") + endif() +endif() diff --git a/CMake/FindLDAP.cmake b/CMake/FindLDAP.cmake index 0a897aa13f88..2f5cc713c72d 100644 --- a/CMake/FindLDAP.cmake +++ b/CMake/FindLDAP.cmake @@ -29,32 +29,28 @@ # - `LDAP_LIBRARY`: Absolute path to `ldap` library. # - `LDAP_LBER_LIBRARY`: Absolute path to `lber` library. # -# Result variables: +# Defines: # # - `LDAP_FOUND`: System has ldap. -# - `LDAP_INCLUDE_DIRS`: The ldap include directories. -# - `LDAP_LIBRARIES`: The ldap library names. -# - `LDAP_LIBRARY_DIRS`: The ldap library directories. -# - `LDAP_PC_REQUIRES`: The ldap pkg-config packages. -# - `LDAP_CFLAGS`: Required compiler flags. # - `LDAP_VERSION`: Version of ldap. +# - `CURL::ldap`: ldap library target. -set(LDAP_PC_REQUIRES "ldap" "lber") +set(_ldap_pc_requires "ldap" "lber") if(CURL_USE_PKGCONFIG AND NOT DEFINED LDAP_INCLUDE_DIR AND NOT DEFINED LDAP_LIBRARY AND NOT DEFINED LDAP_LBER_LIBRARY) find_package(PkgConfig QUIET) - pkg_check_modules(LDAP ${LDAP_PC_REQUIRES}) + pkg_check_modules(_ldap ${_ldap_pc_requires}) endif() -if(LDAP_FOUND) - set(LDAP_VERSION ${LDAP_ldap_VERSION}) - string(REPLACE ";" " " LDAP_CFLAGS "${LDAP_CFLAGS}") - message(STATUS "Found LDAP (via pkg-config): ${LDAP_INCLUDE_DIRS} (found version \"${LDAP_VERSION}\")") +if(_ldap_FOUND) + set(LDAP_FOUND TRUE) + set(LDAP_VERSION ${_ldap_ldap_VERSION}) + message(STATUS "Found LDAP (via pkg-config): ${_ldap_INCLUDE_DIRS} (found version \"${LDAP_VERSION}\")") else() - set(LDAP_PC_REQUIRES "") # Depend on pkg-config only when found via pkg-config + set(_ldap_pc_requires "") # Depend on pkg-config only when found via pkg-config # On Apple the SDK LDAP gets picked up from # 'MacOSX.sdk/System/Library/Frameworks/LDAP.framework/Headers', which contains @@ -99,9 +95,25 @@ else() ) if(LDAP_FOUND) - set(LDAP_INCLUDE_DIRS ${LDAP_INCLUDE_DIR}) - set(LDAP_LIBRARIES ${LDAP_LIBRARY} ${LDAP_LBER_LIBRARY}) + set(_ldap_INCLUDE_DIRS ${LDAP_INCLUDE_DIR}) + set(_ldap_LIBRARIES ${LDAP_LIBRARY} ${LDAP_LBER_LIBRARY}) endif() mark_as_advanced(LDAP_INCLUDE_DIR LDAP_LIBRARY LDAP_LBER_LIBRARY) endif() + +if(LDAP_FOUND) + if(CMAKE_VERSION VERSION_LESS 3.13) + link_directories(${_ldap_LIBRARY_DIRS}) + endif() + + if(NOT TARGET CURL::ldap) + add_library(CURL::ldap INTERFACE IMPORTED) + set_target_properties(CURL::ldap PROPERTIES + INTERFACE_LIBCURL_PC_MODULES "${_ldap_pc_requires}" + INTERFACE_COMPILE_OPTIONS "${_ldap_CFLAGS}" + INTERFACE_INCLUDE_DIRECTORIES "${_ldap_INCLUDE_DIRS}" + INTERFACE_LINK_DIRECTORIES "${_ldap_LIBRARY_DIRS}" + INTERFACE_LINK_LIBRARIES "${_ldap_LIBRARIES}") + endif() +endif() diff --git a/CMake/FindLibbacktrace.cmake b/CMake/FindLibbacktrace.cmake index 444c5f90fdcf..c6f7b700c43c 100644 --- a/CMake/FindLibbacktrace.cmake +++ b/CMake/FindLibbacktrace.cmake @@ -25,14 +25,13 @@ # # Input variables: # -# - `LIBBACKTRACE_INCLUDE_DIR`: Absolute path to libbacktrace include directory. -# - `LIBBACKTRACE_LIBRARY`: Absolute path to `libbacktrace` library. +# - `LIBBACKTRACE_INCLUDE_DIR`: Absolute path to libbacktrace include directory. +# - `LIBBACKTRACE_LIBRARY`: Absolute path to `libbacktrace` library. # -# Result variables: +# Defines: # -# - `LIBBACKTRACE_FOUND`: System has libbacktrace. -# - `LIBBACKTRACE_INCLUDE_DIRS`: The libbacktrace include directories. -# - `LIBBACKTRACE_LIBRARIES`: The libbacktrace library names. +# - `LIBBACKTRACE_FOUND`: System has libbacktrace. +# - `CURL::libbacktrace`: libbacktrace library target. find_path(LIBBACKTRACE_INCLUDE_DIR NAMES "backtrace.h") find_library(LIBBACKTRACE_LIBRARY NAMES "backtrace" "libbacktrace") @@ -45,8 +44,22 @@ find_package_handle_standard_args(Libbacktrace ) if(LIBBACKTRACE_FOUND) - set(LIBBACKTRACE_INCLUDE_DIRS ${LIBBACKTRACE_INCLUDE_DIR}) - set(LIBBACKTRACE_LIBRARIES ${LIBBACKTRACE_LIBRARY}) + set(_libbacktrace_INCLUDE_DIRS ${LIBBACKTRACE_INCLUDE_DIR}) + set(_libbacktrace_LIBRARIES ${LIBBACKTRACE_LIBRARY}) + + if(CMAKE_VERSION VERSION_LESS 3.13) + link_directories(${_libbacktrace_LIBRARY_DIRS}) + endif() + + if(NOT TARGET CURL::libbacktrace) + add_library(CURL::libbacktrace INTERFACE IMPORTED) + set_target_properties(CURL::libbacktrace PROPERTIES + INTERFACE_LIBCURL_PC_MODULES "${_libbacktrace_pc_requires}" + INTERFACE_COMPILE_OPTIONS "${_libbacktrace_CFLAGS}" + INTERFACE_INCLUDE_DIRECTORIES "${_libbacktrace_INCLUDE_DIRS}" + INTERFACE_LINK_DIRECTORIES "${_libbacktrace_LIBRARY_DIRS}" + INTERFACE_LINK_LIBRARIES "${_libbacktrace_LIBRARIES}") + endif() endif() mark_as_advanced(LIBBACKTRACE_INCLUDE_DIR LIBBACKTRACE_LIBRARY) diff --git a/CMake/FindLibgsasl.cmake b/CMake/FindLibgsasl.cmake index e584f75371c0..5ddf957d72d8 100644 --- a/CMake/FindLibgsasl.cmake +++ b/CMake/FindLibgsasl.cmake @@ -25,32 +25,28 @@ # # Input variables: # -# - `LIBGSASL_INCLUDE_DIR`: Absolute path to libgsasl include directory. -# - `LIBGSASL_LIBRARY`: Absolute path to `libgsasl` library. +# - `LIBGSASL_INCLUDE_DIR`: Absolute path to libgsasl include directory. +# - `LIBGSASL_LIBRARY`: Absolute path to `libgsasl` library. # -# Result variables: +# Defines: # -# - `LIBGSASL_FOUND`: System has libgsasl. -# - `LIBGSASL_INCLUDE_DIRS`: The libgsasl include directories. -# - `LIBGSASL_LIBRARIES`: The libgsasl library names. -# - `LIBGSASL_LIBRARY_DIRS`: The libgsasl library directories. -# - `LIBGSASL_PC_REQUIRES`: The libgsasl pkg-config packages. -# - `LIBGSASL_CFLAGS`: Required compiler flags. -# - `LIBGSASL_VERSION`: Version of libgsasl. +# - `LIBGSASL_FOUND`: System has libgsasl. +# - `LIBGSASL_VERSION`: Version of libgsasl. +# - `CURL::libgsasl`: libgsasl library target. -set(LIBGSASL_PC_REQUIRES "libgsasl") +set(_libgsasl_pc_requires "libgsasl") if(CURL_USE_PKGCONFIG AND NOT DEFINED LIBGSASL_INCLUDE_DIR AND NOT DEFINED LIBGSASL_LIBRARY) find_package(PkgConfig QUIET) - pkg_check_modules(LIBGSASL ${LIBGSASL_PC_REQUIRES}) + pkg_check_modules(_libgsasl ${_libgsasl_pc_requires}) endif() -if(LIBGSASL_FOUND) +if(_libgsasl_FOUND) set(Libgsasl_FOUND TRUE) - string(REPLACE ";" " " LIBGSASL_CFLAGS "${LIBGSASL_CFLAGS}") - message(STATUS "Found Libgsasl (via pkg-config): ${LIBGSASL_INCLUDE_DIRS} (found version \"${LIBGSASL_VERSION}\")") + set(LIBGSASL_FOUND TRUE) + message(STATUS "Found Libgsasl (via pkg-config): ${_libgsasl_INCLUDE_DIRS} (found version \"${LIBGSASL_VERSION}\")") else() find_path(LIBGSASL_INCLUDE_DIR NAMES "gsasl.h") find_library(LIBGSASL_LIBRARY NAMES "gsasl" "libgsasl") @@ -75,9 +71,25 @@ else() ) if(LIBGSASL_FOUND) - set(LIBGSASL_INCLUDE_DIRS ${LIBGSASL_INCLUDE_DIR}) - set(LIBGSASL_LIBRARIES ${LIBGSASL_LIBRARY}) + set(_libgsasl_INCLUDE_DIRS ${LIBGSASL_INCLUDE_DIR}) + set(_libgsasl_LIBRARIES ${LIBGSASL_LIBRARY}) endif() mark_as_advanced(LIBGSASL_INCLUDE_DIR LIBGSASL_LIBRARY) endif() + +if(LIBGSASL_FOUND) + if(CMAKE_VERSION VERSION_LESS 3.13) + link_directories(${_libgsasl_LIBRARY_DIRS}) + endif() + + if(NOT TARGET CURL::libgsasl) + add_library(CURL::libgsasl INTERFACE IMPORTED) + set_target_properties(CURL::libgsasl PROPERTIES + INTERFACE_LIBCURL_PC_MODULES "${_libgsasl_pc_requires}" + INTERFACE_COMPILE_OPTIONS "${_libgsasl_CFLAGS}" + INTERFACE_INCLUDE_DIRECTORIES "${_libgsasl_INCLUDE_DIRS}" + INTERFACE_LINK_DIRECTORIES "${_libgsasl_LIBRARY_DIRS}" + INTERFACE_LINK_LIBRARIES "${_libgsasl_LIBRARIES}") + endif() +endif() diff --git a/CMake/FindLibidn2.cmake b/CMake/FindLibidn2.cmake index 9112428f37dc..336a7f7b404e 100644 --- a/CMake/FindLibidn2.cmake +++ b/CMake/FindLibidn2.cmake @@ -25,32 +25,29 @@ # # Input variables: # -# - `LIBIDN2_INCLUDE_DIR`: Absolute path to libidn2 include directory. -# - `LIBIDN2_LIBRARY`: Absolute path to `libidn2` library. +# - `LIBIDN2_INCLUDE_DIR`: Absolute path to libidn2 include directory. +# - `LIBIDN2_LIBRARY`: Absolute path to `libidn2` library. # -# Result variables: +# Defines: # -# - `LIBIDN2_FOUND`: System has libidn2. -# - `LIBIDN2_INCLUDE_DIRS`: The libidn2 include directories. -# - `LIBIDN2_LIBRARIES`: The libidn2 library names. -# - `LIBIDN2_LIBRARY_DIRS`: The libidn2 library directories. -# - `LIBIDN2_PC_REQUIRES`: The libidn2 pkg-config packages. -# - `LIBIDN2_CFLAGS`: Required compiler flags. -# - `LIBIDN2_VERSION`: Version of libidn2. +# - `LIBIDN2_FOUND`: System has libidn2. +# - `LIBIDN2_VERSION`: Version of libidn2. +# - `CURL::libidn2`: libidn2 library target. -set(LIBIDN2_PC_REQUIRES "libidn2") +set(_libidn2_pc_requires "libidn2") if(CURL_USE_PKGCONFIG AND NOT DEFINED LIBIDN2_INCLUDE_DIR AND NOT DEFINED LIBIDN2_LIBRARY) find_package(PkgConfig QUIET) - pkg_check_modules(LIBIDN2 ${LIBIDN2_PC_REQUIRES}) + pkg_check_modules(_libidn2 ${_libidn2_pc_requires}) endif() -if(LIBIDN2_FOUND) +if(_libidn2_FOUND) set(Libidn2_FOUND TRUE) - string(REPLACE ";" " " LIBIDN2_CFLAGS "${LIBIDN2_CFLAGS}") - message(STATUS "Found Libidn2 (via pkg-config): ${LIBIDN2_INCLUDE_DIRS} (found version \"${LIBIDN2_VERSION}\")") + set(LIBIDN2_FOUND TRUE) + set(LIBIDN2_VERSION ${_libidn2_VERSION}) + message(STATUS "Found Libidn2 (via pkg-config): ${_libidn2_INCLUDE_DIRS} (found version \"${LIBIDN2_VERSION}\")") else() find_path(LIBIDN2_INCLUDE_DIR NAMES "idn2.h") find_library(LIBIDN2_LIBRARY NAMES "idn2" "libidn2") @@ -75,9 +72,25 @@ else() ) if(LIBIDN2_FOUND) - set(LIBIDN2_INCLUDE_DIRS ${LIBIDN2_INCLUDE_DIR}) - set(LIBIDN2_LIBRARIES ${LIBIDN2_LIBRARY}) + set(_libidn2_INCLUDE_DIRS ${LIBIDN2_INCLUDE_DIR}) + set(_libidn2_LIBRARIES ${LIBIDN2_LIBRARY}) endif() mark_as_advanced(LIBIDN2_INCLUDE_DIR LIBIDN2_LIBRARY) endif() + +if(LIBIDN2_FOUND) + if(CMAKE_VERSION VERSION_LESS 3.13) + link_directories(${_libidn2_LIBRARY_DIRS}) + endif() + + if(NOT TARGET CURL::libidn2) + add_library(CURL::libidn2 INTERFACE IMPORTED) + set_target_properties(CURL::libidn2 PROPERTIES + INTERFACE_LIBCURL_PC_MODULES "${_libidn2_pc_requires}" + INTERFACE_COMPILE_OPTIONS "${_libidn2_CFLAGS}" + INTERFACE_INCLUDE_DIRECTORIES "${_libidn2_INCLUDE_DIRS}" + INTERFACE_LINK_DIRECTORIES "${_libidn2_LIBRARY_DIRS}" + INTERFACE_LINK_LIBRARIES "${_libidn2_LIBRARIES}") + endif() +endif() diff --git a/CMake/FindLibpsl.cmake b/CMake/FindLibpsl.cmake index 13740fa9b3fa..9b1a0cdd97b4 100644 --- a/CMake/FindLibpsl.cmake +++ b/CMake/FindLibpsl.cmake @@ -25,32 +25,29 @@ # # Input variables: # -# - `LIBPSL_INCLUDE_DIR`: Absolute path to libpsl include directory. -# - `LIBPSL_LIBRARY`: Absolute path to `libpsl` library. +# - `LIBPSL_INCLUDE_DIR`: Absolute path to libpsl include directory. +# - `LIBPSL_LIBRARY`: Absolute path to `libpsl` library. # -# Result variables: +# Defines: # -# - `LIBPSL_FOUND`: System has libpsl. -# - `LIBPSL_INCLUDE_DIRS`: The libpsl include directories. -# - `LIBPSL_LIBRARIES`: The libpsl library names. -# - `LIBPSL_LIBRARY_DIRS`: The libpsl library directories. -# - `LIBPSL_PC_REQUIRES`: The libpsl pkg-config packages. -# - `LIBPSL_CFLAGS`: Required compiler flags. -# - `LIBPSL_VERSION`: Version of libpsl. +# - `LIBPSL_FOUND`: System has libpsl. +# - `LIBPSL_VERSION`: Version of libpsl. +# - `CURL::libpsl`: libpsl library target. -set(LIBPSL_PC_REQUIRES "libpsl") +set(_libpsl_pc_requires "libpsl") if(CURL_USE_PKGCONFIG AND NOT DEFINED LIBPSL_INCLUDE_DIR AND NOT DEFINED LIBPSL_LIBRARY) find_package(PkgConfig QUIET) - pkg_check_modules(LIBPSL ${LIBPSL_PC_REQUIRES}) + pkg_check_modules(_libpsl ${_libpsl_pc_requires}) endif() -if(LIBPSL_FOUND AND LIBPSL_INCLUDE_DIRS) +if(_libpsl_FOUND AND _libpsl_INCLUDE_DIRS) set(Libpsl_FOUND TRUE) - string(REPLACE ";" " " LIBPSL_CFLAGS "${LIBPSL_CFLAGS}") - message(STATUS "Found Libpsl (via pkg-config): ${LIBPSL_INCLUDE_DIRS} (found version \"${LIBPSL_VERSION}\")") + set(LIBPSL_FOUND TRUE) + set(LIBPSL_VERSION ${_libpsl_VERSION}) + message(STATUS "Found Libpsl (via pkg-config): ${_libpsl_INCLUDE_DIRS} (found version \"${LIBPSL_VERSION}\")") else() find_path(LIBPSL_INCLUDE_DIR NAMES "libpsl.h") find_library(LIBPSL_LIBRARY NAMES "psl" "libpsl") @@ -75,9 +72,25 @@ else() ) if(LIBPSL_FOUND) - set(LIBPSL_INCLUDE_DIRS ${LIBPSL_INCLUDE_DIR}) - set(LIBPSL_LIBRARIES ${LIBPSL_LIBRARY}) + set(_libpsl_INCLUDE_DIRS ${LIBPSL_INCLUDE_DIR}) + set(_libpsl_LIBRARIES ${LIBPSL_LIBRARY}) endif() mark_as_advanced(LIBPSL_INCLUDE_DIR LIBPSL_LIBRARY) endif() + +if(LIBPSL_FOUND) + if(CMAKE_VERSION VERSION_LESS 3.13) + link_directories(${_libpsl_LIBRARY_DIRS}) + endif() + + if(NOT TARGET CURL::libpsl) + add_library(CURL::libpsl INTERFACE IMPORTED) + set_target_properties(CURL::libpsl PROPERTIES + INTERFACE_LIBCURL_PC_MODULES "${_libpsl_pc_requires}" + INTERFACE_COMPILE_OPTIONS "${_libpsl_CFLAGS}" + INTERFACE_INCLUDE_DIRECTORIES "${_libpsl_INCLUDE_DIRS}" + INTERFACE_LINK_DIRECTORIES "${_libpsl_LIBRARY_DIRS}" + INTERFACE_LINK_LIBRARIES "${_libpsl_LIBRARIES}") + endif() +endif() diff --git a/CMake/FindLibrtmp.cmake b/CMake/FindLibrtmp.cmake index be975794b773..070538578e4a 100644 --- a/CMake/FindLibrtmp.cmake +++ b/CMake/FindLibrtmp.cmake @@ -25,32 +25,29 @@ # # Input variables: # -# - `LIBRTMP_INCLUDE_DIR`: Absolute path to librtmp include directory. -# - `LIBRTMP_LIBRARY`: Absolute path to `librtmp` library. +# - `LIBRTMP_INCLUDE_DIR`: Absolute path to librtmp include directory. +# - `LIBRTMP_LIBRARY`: Absolute path to `librtmp` library. # -# Result variables: +# Defines: # -# - `LIBRTMP_FOUND`: System has librtmp. -# - `LIBRTMP_INCLUDE_DIRS`: The librtmp include directories. -# - `LIBRTMP_LIBRARIES`: The librtmp library names. -# - `LIBRTMP_LIBRARY_DIRS`: The librtmp library directories. -# - `LIBRTMP_PC_REQUIRES`: The librtmp pkg-config packages. -# - `LIBRTMP_CFLAGS`: Required compiler flags. -# - `LIBRTMP_VERSION`: Version of librtmp. +# - `LIBRTMP_FOUND`: System has librtmp. +# - `LIBRTMP_VERSION`: Version of librtmp. +# - `CURL::librtmp`: librtmp library target. -set(LIBRTMP_PC_REQUIRES "librtmp") +set(_librtmp_pc_requires "librtmp") if(CURL_USE_PKGCONFIG AND NOT DEFINED LIBRTMP_INCLUDE_DIR AND NOT DEFINED LIBRTMP_LIBRARY) find_package(PkgConfig QUIET) - pkg_check_modules(LIBRTMP ${LIBRTMP_PC_REQUIRES}) + pkg_check_modules(_librtmp ${_librtmp_pc_requires}) endif() -if(LIBRTMP_FOUND AND LIBRTMP_INCLUDE_DIRS) +if(_librtmp_FOUND AND _librtmp_INCLUDE_DIRS) set(Librtmp_FOUND TRUE) - string(REPLACE ";" " " LIBRTMP_CFLAGS "${LIBRTMP_CFLAGS}") - message(STATUS "Found Librtmp (via pkg-config): ${LIBRTMP_INCLUDE_DIRS} (found version \"${LIBRTMP_VERSION}\")") + set(LIBRTMP_FOUND TRUE) + set(LIBRTMP_VERSION ${_librtmp_VERSION}) + message(STATUS "Found Librtmp (via pkg-config): ${_librtmp_INCLUDE_DIRS} (found version \"${LIBRTMP_VERSION}\")") else() find_path(LIBRTMP_INCLUDE_DIR NAMES "librtmp/rtmp.h") find_library(LIBRTMP_LIBRARY NAMES "rtmp") @@ -85,8 +82,8 @@ else() ) if(LIBRTMP_FOUND) - set(LIBRTMP_INCLUDE_DIRS ${LIBRTMP_INCLUDE_DIR}) - set(LIBRTMP_LIBRARIES ${LIBRTMP_LIBRARY}) + set(_librtmp_INCLUDE_DIRS ${LIBRTMP_INCLUDE_DIR}) + set(_librtmp_LIBRARIES ${LIBRTMP_LIBRARY}) endif() mark_as_advanced(LIBRTMP_INCLUDE_DIR LIBRTMP_LIBRARY) @@ -94,10 +91,26 @@ else() # Necessary when linking a static librtmp find_package(OpenSSL) if(OPENSSL_FOUND) - list(APPEND LIBRTMP_LIBRARIES OpenSSL::SSL OpenSSL::Crypto) + list(APPEND _librtmp_LIBRARIES OpenSSL::SSL OpenSSL::Crypto) endif() endif() -if(LIBRTMP_FOUND AND WIN32) - list(APPEND LIBRTMP_LIBRARIES "winmm") +if(LIBRTMP_FOUND) + if(WIN32) + list(APPEND _librtmp_LIBRARIES "winmm") + endif() + + if(CMAKE_VERSION VERSION_LESS 3.13) + link_directories(${_librtmp_LIBRARY_DIRS}) + endif() + + if(NOT TARGET CURL::librtmp) + add_library(CURL::librtmp INTERFACE IMPORTED) + set_target_properties(CURL::librtmp PROPERTIES + INTERFACE_LIBCURL_PC_MODULES "${_librtmp_pc_requires}" + INTERFACE_COMPILE_OPTIONS "${_librtmp_CFLAGS}" + INTERFACE_INCLUDE_DIRECTORIES "${_librtmp_INCLUDE_DIRS}" + INTERFACE_LINK_DIRECTORIES "${_librtmp_LIBRARY_DIRS}" + INTERFACE_LINK_LIBRARIES "${_librtmp_LIBRARIES}") + endif() endif() diff --git a/CMake/FindLibssh.cmake b/CMake/FindLibssh.cmake index cb895aa8d74b..ad1248fe00af 100644 --- a/CMake/FindLibssh.cmake +++ b/CMake/FindLibssh.cmake @@ -25,32 +25,29 @@ # # Input variables: # -# - `LIBSSH_INCLUDE_DIR`: Absolute path to libssh include directory. -# - `LIBSSH_LIBRARY`: Absolute path to `libssh` library. +# - `LIBSSH_INCLUDE_DIR`: Absolute path to libssh include directory. +# - `LIBSSH_LIBRARY`: Absolute path to `libssh` library. # -# Result variables: +# Defines: # -# - `LIBSSH_FOUND`: System has libssh. -# - `LIBSSH_INCLUDE_DIRS`: The libssh include directories. -# - `LIBSSH_LIBRARIES`: The libssh library names. -# - `LIBSSH_LIBRARY_DIRS`: The libssh library directories. -# - `LIBSSH_PC_REQUIRES`: The libssh pkg-config packages. -# - `LIBSSH_CFLAGS`: Required compiler flags. -# - `LIBSSH_VERSION`: Version of libssh. +# - `LIBSSH_FOUND`: System has libssh. +# - `LIBSSH_VERSION`: Version of libssh. +# - `CURL::libssh`: libssh library target. -set(LIBSSH_PC_REQUIRES "libssh") +set(_libssh_pc_requires "libssh") if(CURL_USE_PKGCONFIG AND NOT DEFINED LIBSSH_INCLUDE_DIR AND NOT DEFINED LIBSSH_LIBRARY) find_package(PkgConfig QUIET) - pkg_check_modules(LIBSSH ${LIBSSH_PC_REQUIRES}) + pkg_check_modules(_libssh ${_libssh_pc_requires}) endif() -if(LIBSSH_FOUND) +if(_libssh_FOUND) set(Libssh_FOUND TRUE) - string(REPLACE ";" " " LIBSSH_CFLAGS "${LIBSSH_CFLAGS}") - message(STATUS "Found Libssh (via pkg-config): ${LIBSSH_INCLUDE_DIRS} (found version \"${LIBSSH_VERSION}\")") + set(LIBSSH_FOUND TRUE) + set(LIBSSH_VERSION ${_libssh_VERSION}) + message(STATUS "Found Libssh (via pkg-config): ${_libssh_INCLUDE_DIRS} (found version \"${LIBSSH_VERSION}\")") else() find_path(LIBSSH_INCLUDE_DIR NAMES "libssh/libssh.h") find_library(LIBSSH_LIBRARY NAMES "ssh" "libssh") @@ -85,13 +82,29 @@ else() ) if(LIBSSH_FOUND) - set(LIBSSH_INCLUDE_DIRS ${LIBSSH_INCLUDE_DIR}) - set(LIBSSH_LIBRARIES ${LIBSSH_LIBRARY}) + set(_libssh_INCLUDE_DIRS ${LIBSSH_INCLUDE_DIR}) + set(_libssh_LIBRARIES ${LIBSSH_LIBRARY}) endif() mark_as_advanced(LIBSSH_INCLUDE_DIR LIBSSH_LIBRARY) endif() -if(LIBSSH_FOUND AND WIN32) - list(APPEND LIBSSH_LIBRARIES "iphlpapi") # for if_nametoindex +if(LIBSSH_FOUND) + if(WIN32) + list(APPEND _libssh_LIBRARIES "iphlpapi") # for if_nametoindex + endif() + + if(CMAKE_VERSION VERSION_LESS 3.13) + link_directories(${_libssh_LIBRARY_DIRS}) + endif() + + if(NOT TARGET CURL::libssh) + add_library(CURL::libssh INTERFACE IMPORTED) + set_target_properties(CURL::libssh PROPERTIES + INTERFACE_LIBCURL_PC_MODULES "${_libssh_pc_requires}" + INTERFACE_COMPILE_OPTIONS "${_libssh_CFLAGS}" + INTERFACE_INCLUDE_DIRECTORIES "${_libssh_INCLUDE_DIRS}" + INTERFACE_LINK_DIRECTORIES "${_libssh_LIBRARY_DIRS}" + INTERFACE_LINK_LIBRARIES "${_libssh_LIBRARIES}") + endif() endif() diff --git a/CMake/FindLibssh2.cmake b/CMake/FindLibssh2.cmake index 08415533e0db..330611bfe55c 100644 --- a/CMake/FindLibssh2.cmake +++ b/CMake/FindLibssh2.cmake @@ -25,32 +25,29 @@ # # Input variables: # -# - `LIBSSH2_INCLUDE_DIR`: Absolute path to libssh2 include directory. -# - `LIBSSH2_LIBRARY`: Absolute path to `libssh2` library. +# - `LIBSSH2_INCLUDE_DIR`: Absolute path to libssh2 include directory. +# - `LIBSSH2_LIBRARY`: Absolute path to `libssh2` library. # -# Result variables: +# Defines: # -# - `LIBSSH2_FOUND`: System has libssh2. -# - `LIBSSH2_INCLUDE_DIRS`: The libssh2 include directories. -# - `LIBSSH2_LIBRARIES`: The libssh2 library names. -# - `LIBSSH2_LIBRARY_DIRS`: The libssh2 library directories. -# - `LIBSSH2_PC_REQUIRES`: The libssh2 pkg-config packages. -# - `LIBSSH2_CFLAGS`: Required compiler flags. -# - `LIBSSH2_VERSION`: Version of libssh2. +# - `LIBSSH2_FOUND`: System has libssh2. +# - `LIBSSH2_VERSION`: Version of libssh2. +# - `CURL::libssh2`: libssh2 library target. -set(LIBSSH2_PC_REQUIRES "libssh2") +set(_libssh2_pc_requires "libssh2") if(CURL_USE_PKGCONFIG AND NOT DEFINED LIBSSH2_INCLUDE_DIR AND NOT DEFINED LIBSSH2_LIBRARY) find_package(PkgConfig QUIET) - pkg_check_modules(LIBSSH2 ${LIBSSH2_PC_REQUIRES}) + pkg_check_modules(_libssh2 ${_libssh2_pc_requires}) endif() -if(LIBSSH2_FOUND AND LIBSSH2_INCLUDE_DIRS) +if(_libssh2_FOUND AND _libssh2_INCLUDE_DIRS) set(Libssh2_FOUND TRUE) - string(REPLACE ";" " " LIBSSH2_CFLAGS "${LIBSSH2_CFLAGS}") - message(STATUS "Found Libssh2 (via pkg-config): ${LIBSSH2_INCLUDE_DIRS} (found version \"${LIBSSH2_VERSION}\")") + set(LIBSSH2_FOUND TRUE) + set(LIBSSH2_VERSION ${_libssh2_VERSION}) + message(STATUS "Found Libssh2 (via pkg-config): ${_libssh2_INCLUDE_DIRS} (found version \"${LIBSSH2_VERSION}\")") else() find_path(LIBSSH2_INCLUDE_DIR NAMES "libssh2.h") find_library(LIBSSH2_LIBRARY NAMES "ssh2" "libssh2") @@ -75,9 +72,25 @@ else() ) if(LIBSSH2_FOUND) - set(LIBSSH2_INCLUDE_DIRS ${LIBSSH2_INCLUDE_DIR}) - set(LIBSSH2_LIBRARIES ${LIBSSH2_LIBRARY}) + set(_libssh2_INCLUDE_DIRS ${LIBSSH2_INCLUDE_DIR}) + set(_libssh2_LIBRARIES ${LIBSSH2_LIBRARY}) endif() mark_as_advanced(LIBSSH2_INCLUDE_DIR LIBSSH2_LIBRARY) endif() + +if(LIBSSH2_FOUND) + if(CMAKE_VERSION VERSION_LESS 3.13) + link_directories(${_libssh2_LIBRARY_DIRS}) + endif() + + if(NOT TARGET CURL::libssh2) + add_library(CURL::libssh2 INTERFACE IMPORTED) + set_target_properties(CURL::libssh2 PROPERTIES + INTERFACE_LIBCURL_PC_MODULES "${_libssh2_pc_requires}" + INTERFACE_COMPILE_OPTIONS "${_libssh2_CFLAGS}" + INTERFACE_INCLUDE_DIRECTORIES "${_libssh2_INCLUDE_DIRS}" + INTERFACE_LINK_DIRECTORIES "${_libssh2_LIBRARY_DIRS}" + INTERFACE_LINK_LIBRARIES "${_libssh2_LIBRARIES}") + endif() +endif() diff --git a/CMake/FindLibuv.cmake b/CMake/FindLibuv.cmake index 2565ba3a386a..f9d614bc067c 100644 --- a/CMake/FindLibuv.cmake +++ b/CMake/FindLibuv.cmake @@ -25,32 +25,29 @@ # # Input variables: # -# - `LIBUV_INCLUDE_DIR`: Absolute path to libuv include directory. -# - `LIBUV_LIBRARY`: Absolute path to `libuv` library. +# - `LIBUV_INCLUDE_DIR`: Absolute path to libuv include directory. +# - `LIBUV_LIBRARY`: Absolute path to `libuv` library. # -# Result variables: +# Defines: # -# - `LIBUV_FOUND`: System has libuv. -# - `LIBUV_INCLUDE_DIRS`: The libuv include directories. -# - `LIBUV_LIBRARIES`: The libuv library names. -# - `LIBUV_LIBRARY_DIRS`: The libuv library directories. -# - `LIBUV_PC_REQUIRES`: The libuv pkg-config packages. -# - `LIBUV_CFLAGS`: Required compiler flags. -# - `LIBUV_VERSION`: Version of libuv. +# - `LIBUV_FOUND`: System has libuv. +# - `LIBUV_VERSION`: Version of libuv. +# - `CURL::libuv`: libuv library target. -set(LIBUV_PC_REQUIRES "libuv") +set(_libuv_pc_requires "libuv") if(CURL_USE_PKGCONFIG AND NOT DEFINED LIBUV_INCLUDE_DIR AND NOT DEFINED LIBUV_LIBRARY) find_package(PkgConfig QUIET) - pkg_check_modules(LIBUV ${LIBUV_PC_REQUIRES}) + pkg_check_modules(_libuv ${_libuv_pc_requires}) endif() -if(LIBUV_FOUND) +if(_libuv_FOUND) set(Libuv_FOUND TRUE) - string(REPLACE ";" " " LIBUV_CFLAGS "${LIBUV_CFLAGS}") - message(STATUS "Found Libuv (via pkg-config): ${LIBUV_INCLUDE_DIRS} (found version \"${LIBUV_VERSION}\")") + set(LIBUV_FOUND TRUE) + set(LIBUV_VERSION ${_libuv_VERSION}) + message(STATUS "Found Libuv (via pkg-config): ${_libuv_INCLUDE_DIRS} (found version \"${LIBUV_VERSION}\")") else() find_path(LIBUV_INCLUDE_DIR NAMES "uv.h") find_library(LIBUV_LIBRARY NAMES "uv" "libuv") @@ -85,9 +82,25 @@ else() ) if(LIBUV_FOUND) - set(LIBUV_INCLUDE_DIRS ${LIBUV_INCLUDE_DIR}) - set(LIBUV_LIBRARIES ${LIBUV_LIBRARY}) + set(_libuv_INCLUDE_DIRS ${LIBUV_INCLUDE_DIR}) + set(_libuv_LIBRARIES ${LIBUV_LIBRARY}) endif() mark_as_advanced(LIBUV_INCLUDE_DIR LIBUV_LIBRARY) endif() + +if(LIBUV_FOUND) + if(CMAKE_VERSION VERSION_LESS 3.13) + link_directories(${_libuv_LIBRARY_DIRS}) + endif() + + if(NOT TARGET CURL::libuv) + add_library(CURL::libuv INTERFACE IMPORTED) + set_target_properties(CURL::libuv PROPERTIES + INTERFACE_LIBCURL_PC_MODULES "${_libuv_pc_requires}" + INTERFACE_COMPILE_OPTIONS "${_libuv_CFLAGS}" + INTERFACE_INCLUDE_DIRECTORIES "${_libuv_INCLUDE_DIRS}" + INTERFACE_LINK_DIRECTORIES "${_libuv_LIBRARY_DIRS}" + INTERFACE_LINK_LIBRARIES "${_libuv_LIBRARIES}") + endif() +endif() diff --git a/CMake/FindMbedTLS.cmake b/CMake/FindMbedTLS.cmake index 11b4f076f4dc..97201ab2b343 100644 --- a/CMake/FindMbedTLS.cmake +++ b/CMake/FindMbedTLS.cmake @@ -25,20 +25,16 @@ # # Input variables: # -# - `MBEDTLS_INCLUDE_DIR`: Absolute path to mbedTLS include directory. -# - `MBEDTLS_LIBRARY`: Absolute path to `mbedtls` library. -# - `MBEDX509_LIBRARY`: Absolute path to `mbedx509` library. -# - `MBEDCRYPTO_LIBRARY`: Absolute path to `mbedcrypto` library. +# - `MBEDTLS_INCLUDE_DIR`: Absolute path to mbedTLS include directory. +# - `MBEDTLS_LIBRARY`: Absolute path to `mbedtls` library. +# - `MBEDX509_LIBRARY`: Absolute path to `mbedx509` library. +# - `MBEDCRYPTO_LIBRARY`: Absolute path to `mbedcrypto` library. # -# Result variables: +# Defines: # -# - `MBEDTLS_FOUND`: System has mbedTLS. -# - `MBEDTLS_INCLUDE_DIRS`: The mbedTLS include directories. -# - `MBEDTLS_LIBRARIES`: The mbedTLS library names. -# - `MBEDTLS_LIBRARY_DIRS`: The mbedTLS library directories. -# - `MBEDTLS_PC_REQUIRES`: The mbedTLS pkg-config packages. -# - `MBEDTLS_CFLAGS`: Required compiler flags. -# - `MBEDTLS_VERSION`: Version of mbedTLS. +# - `MBEDTLS_FOUND`: System has mbedTLS. +# - `MBEDTLS_VERSION`: Version of mbedTLS. +# - `CURL::mbedtls`: mbedTLS library target. if(DEFINED MBEDTLS_INCLUDE_DIRS AND NOT DEFINED MBEDTLS_INCLUDE_DIR) message(WARNING "MBEDTLS_INCLUDE_DIRS is deprecated, use MBEDTLS_INCLUDE_DIR instead.") @@ -46,7 +42,7 @@ if(DEFINED MBEDTLS_INCLUDE_DIRS AND NOT DEFINED MBEDTLS_INCLUDE_DIR) unset(MBEDTLS_INCLUDE_DIRS) endif() -set(MBEDTLS_PC_REQUIRES "mbedtls" "mbedx509" "mbedcrypto") +set(_mbedtls_pc_requires "mbedtls" "mbedx509" "mbedcrypto") if(CURL_USE_PKGCONFIG AND NOT DEFINED MBEDTLS_INCLUDE_DIR AND @@ -54,16 +50,16 @@ if(CURL_USE_PKGCONFIG AND NOT DEFINED MBEDX509_LIBRARY AND NOT DEFINED MBEDCRYPTO_LIBRARY) find_package(PkgConfig QUIET) - pkg_check_modules(MBEDTLS ${MBEDTLS_PC_REQUIRES}) + pkg_check_modules(_mbedtls ${_mbedtls_pc_requires}) endif() -if(MBEDTLS_FOUND) +if(_mbedtls_FOUND) set(MbedTLS_FOUND TRUE) - set(MBEDTLS_VERSION ${MBEDTLS_mbedtls_VERSION}) - string(REPLACE ";" " " MBEDTLS_CFLAGS "${MBEDTLS_CFLAGS}") - message(STATUS "Found MbedTLS (via pkg-config): ${MBEDTLS_INCLUDE_DIRS} (found version \"${MBEDTLS_VERSION}\")") + set(MBEDTLS_FOUND TRUE) + set(MBEDTLS_VERSION ${_mbedtls_mbedtls_VERSION}) + message(STATUS "Found MbedTLS (via pkg-config): ${_mbedtls_INCLUDE_DIRS} (found version \"${MBEDTLS_VERSION}\")") else() - set(MBEDTLS_PC_REQUIRES "") # Depend on pkg-config only when found via pkg-config + set(_mbedtls_pc_requires "") # Depend on pkg-config only when found via pkg-config find_path(MBEDTLS_INCLUDE_DIR NAMES "mbedtls/ssl.h") find_library(MBEDTLS_LIBRARY NAMES "mbedtls" "libmbedtls") @@ -92,9 +88,25 @@ else() ) if(MBEDTLS_FOUND) - set(MBEDTLS_INCLUDE_DIRS ${MBEDTLS_INCLUDE_DIR}) - set(MBEDTLS_LIBRARIES ${MBEDTLS_LIBRARY} ${MBEDX509_LIBRARY} ${MBEDCRYPTO_LIBRARY}) + set(_mbedtls_INCLUDE_DIRS ${MBEDTLS_INCLUDE_DIR}) + set(_mbedtls_LIBRARIES ${MBEDTLS_LIBRARY} ${MBEDX509_LIBRARY} ${MBEDCRYPTO_LIBRARY}) endif() mark_as_advanced(MBEDTLS_INCLUDE_DIR MBEDTLS_LIBRARY MBEDX509_LIBRARY MBEDCRYPTO_LIBRARY) endif() + +if(MBEDTLS_FOUND) + if(CMAKE_VERSION VERSION_LESS 3.13) + link_directories(${_mbedtls_LIBRARY_DIRS}) + endif() + + if(NOT TARGET CURL::mbedtls) + add_library(CURL::mbedtls INTERFACE IMPORTED) + set_target_properties(CURL::mbedtls PROPERTIES + INTERFACE_LIBCURL_PC_MODULES "${_mbedtls_pc_requires}" + INTERFACE_COMPILE_OPTIONS "${_mbedtls_CFLAGS}" + INTERFACE_INCLUDE_DIRECTORIES "${_mbedtls_INCLUDE_DIRS}" + INTERFACE_LINK_DIRECTORIES "${_mbedtls_LIBRARY_DIRS}" + INTERFACE_LINK_LIBRARIES "${_mbedtls_LIBRARIES}") + endif() +endif() diff --git a/CMake/FindNGHTTP2.cmake b/CMake/FindNGHTTP2.cmake index 1ccf64158915..8304345a384b 100644 --- a/CMake/FindNGHTTP2.cmake +++ b/CMake/FindNGHTTP2.cmake @@ -25,31 +25,28 @@ # # Input variables: # -# - `NGHTTP2_INCLUDE_DIR`: Absolute path to nghttp2 include directory. -# - `NGHTTP2_LIBRARY`: Absolute path to `nghttp2` library. +# - `NGHTTP2_INCLUDE_DIR`: Absolute path to nghttp2 include directory. +# - `NGHTTP2_LIBRARY`: Absolute path to `nghttp2` library. # -# Result variables: +# Defines: # -# - `NGHTTP2_FOUND`: System has nghttp2. -# - `NGHTTP2_INCLUDE_DIRS`: The nghttp2 include directories. -# - `NGHTTP2_LIBRARIES`: The nghttp2 library names. -# - `NGHTTP2_LIBRARY_DIRS`: The nghttp2 library directories. -# - `NGHTTP2_PC_REQUIRES`: The nghttp2 pkg-config packages. -# - `NGHTTP2_CFLAGS`: Required compiler flags. -# - `NGHTTP2_VERSION`: Version of nghttp2. +# - `NGHTTP2_FOUND`: System has nghttp2. +# - `NGHTTP2_VERSION`: Version of nghttp2. +# - `CURL::nghttp2`: nghttp2 library target. -set(NGHTTP2_PC_REQUIRES "libnghttp2") +set(_nghttp2_pc_requires "libnghttp2") if(CURL_USE_PKGCONFIG AND NOT DEFINED NGHTTP2_INCLUDE_DIR AND NOT DEFINED NGHTTP2_LIBRARY) find_package(PkgConfig QUIET) - pkg_check_modules(NGHTTP2 ${NGHTTP2_PC_REQUIRES}) + pkg_check_modules(_nghttp2 ${_nghttp2_pc_requires}) endif() -if(NGHTTP2_FOUND) - string(REPLACE ";" " " NGHTTP2_CFLAGS "${NGHTTP2_CFLAGS}") - message(STATUS "Found NGHTTP2 (via pkg-config): ${NGHTTP2_INCLUDE_DIRS} (found version \"${NGHTTP2_VERSION}\")") +if(_nghttp2_FOUND) + set(NGHTTP2_FOUND TRUE) + set(NGHTTP2_VERSION ${_nghttp2_VERSION}) + message(STATUS "Found NGHTTP2 (via pkg-config): ${_nghttp2_INCLUDE_DIRS} (found version \"${NGHTTP2_VERSION}\")") else() find_path(NGHTTP2_INCLUDE_DIR NAMES "nghttp2/nghttp2.h") find_library(NGHTTP2_LIBRARY NAMES "nghttp2" "nghttp2_static") @@ -74,9 +71,25 @@ else() ) if(NGHTTP2_FOUND) - set(NGHTTP2_INCLUDE_DIRS ${NGHTTP2_INCLUDE_DIR}) - set(NGHTTP2_LIBRARIES ${NGHTTP2_LIBRARY}) + set(_nghttp2_INCLUDE_DIRS ${NGHTTP2_INCLUDE_DIR}) + set(_nghttp2_LIBRARIES ${NGHTTP2_LIBRARY}) endif() mark_as_advanced(NGHTTP2_INCLUDE_DIR NGHTTP2_LIBRARY) endif() + +if(NGHTTP2_FOUND) + if(CMAKE_VERSION VERSION_LESS 3.13) + link_directories(${_nghttp2_LIBRARY_DIRS}) + endif() + + if(NOT TARGET CURL::nghttp2) + add_library(CURL::nghttp2 INTERFACE IMPORTED) + set_target_properties(CURL::nghttp2 PROPERTIES + INTERFACE_LIBCURL_PC_MODULES "${_nghttp2_pc_requires}" + INTERFACE_COMPILE_OPTIONS "${_nghttp2_CFLAGS}" + INTERFACE_INCLUDE_DIRECTORIES "${_nghttp2_INCLUDE_DIRS}" + INTERFACE_LINK_DIRECTORIES "${_nghttp2_LIBRARY_DIRS}" + INTERFACE_LINK_LIBRARIES "${_nghttp2_LIBRARIES}") + endif() +endif() diff --git a/CMake/FindNGHTTP3.cmake b/CMake/FindNGHTTP3.cmake index fba2c5779b36..37ebfe1114fa 100644 --- a/CMake/FindNGHTTP3.cmake +++ b/CMake/FindNGHTTP3.cmake @@ -25,31 +25,28 @@ # # Input variables: # -# - `NGHTTP3_INCLUDE_DIR`: Absolute path to nghttp3 include directory. -# - `NGHTTP3_LIBRARY`: Absolute path to `nghttp3` library. +# - `NGHTTP3_INCLUDE_DIR`: Absolute path to nghttp3 include directory. +# - `NGHTTP3_LIBRARY`: Absolute path to `nghttp3` library. # -# Result variables: +# Defines: # -# - `NGHTTP3_FOUND`: System has nghttp3. -# - `NGHTTP3_INCLUDE_DIRS`: The nghttp3 include directories. -# - `NGHTTP3_LIBRARIES`: The nghttp3 library names. -# - `NGHTTP3_LIBRARY_DIRS`: The nghttp3 library directories. -# - `NGHTTP3_PC_REQUIRES`: The nghttp3 pkg-config packages. -# - `NGHTTP3_CFLAGS`: Required compiler flags. -# - `NGHTTP3_VERSION`: Version of nghttp3. +# - `NGHTTP3_FOUND`: System has nghttp3. +# - `NGHTTP3_VERSION`: Version of nghttp3. +# - `CURL::nghttp3`: nghttp3 library target. -set(NGHTTP3_PC_REQUIRES "libnghttp3") +set(_nghttp3_pc_requires "libnghttp3") if(CURL_USE_PKGCONFIG AND NOT DEFINED NGHTTP3_INCLUDE_DIR AND NOT DEFINED NGHTTP3_LIBRARY) find_package(PkgConfig QUIET) - pkg_check_modules(NGHTTP3 ${NGHTTP3_PC_REQUIRES}) + pkg_check_modules(_nghttp3 ${_nghttp3_pc_requires}) endif() -if(NGHTTP3_FOUND) - string(REPLACE ";" " " NGHTTP3_CFLAGS "${NGHTTP3_CFLAGS}") - message(STATUS "Found NGHTTP3 (via pkg-config): ${NGHTTP3_INCLUDE_DIRS} (found version \"${NGHTTP3_VERSION}\")") +if(_nghttp3_FOUND) + set(NGHTTP3_FOUND TRUE) + set(NGHTTP3_VERSION ${_nghttp3_VERSION}) + message(STATUS "Found NGHTTP3 (via pkg-config): ${_nghttp3_INCLUDE_DIRS} (found version \"${NGHTTP3_VERSION}\")") else() find_path(NGHTTP3_INCLUDE_DIR NAMES "nghttp3/nghttp3.h") find_library(NGHTTP3_LIBRARY NAMES "nghttp3") @@ -74,9 +71,25 @@ else() ) if(NGHTTP3_FOUND) - set(NGHTTP3_INCLUDE_DIRS ${NGHTTP3_INCLUDE_DIR}) - set(NGHTTP3_LIBRARIES ${NGHTTP3_LIBRARY}) + set(_nghttp3_INCLUDE_DIRS ${NGHTTP3_INCLUDE_DIR}) + set(_nghttp3_LIBRARIES ${NGHTTP3_LIBRARY}) endif() mark_as_advanced(NGHTTP3_INCLUDE_DIR NGHTTP3_LIBRARY) endif() + +if(NGHTTP3_FOUND) + if(CMAKE_VERSION VERSION_LESS 3.13) + link_directories(${_nghttp3_LIBRARY_DIRS}) + endif() + + if(NOT TARGET CURL::nghttp3) + add_library(CURL::nghttp3 INTERFACE IMPORTED) + set_target_properties(CURL::nghttp3 PROPERTIES + INTERFACE_LIBCURL_PC_MODULES "${_nghttp3_pc_requires}" + INTERFACE_COMPILE_OPTIONS "${_nghttp3_CFLAGS}" + INTERFACE_INCLUDE_DIRECTORIES "${_nghttp3_INCLUDE_DIRS}" + INTERFACE_LINK_DIRECTORIES "${_nghttp3_LIBRARY_DIRS}" + INTERFACE_LINK_LIBRARIES "${_nghttp3_LIBRARIES}") + endif() +endif() diff --git a/CMake/FindNGTCP2.cmake b/CMake/FindNGTCP2.cmake index cda3b0e08cb2..416ea459f6b1 100644 --- a/CMake/FindNGTCP2.cmake +++ b/CMake/FindNGTCP2.cmake @@ -44,15 +44,11 @@ # - `NGTCP2_CRYPTO_QUICTLS_LIBRARY`: Absolute path to `ngtcp2_crypto_quictls` library. # - `NGTCP2_CRYPTO_WOLFSSL_LIBRARY`: Absolute path to `ngtcp2_crypto_wolfssl` library. # -# Result variables: +# Defines: # # - `NGTCP2_FOUND`: System has ngtcp2. -# - `NGTCP2_INCLUDE_DIRS`: The ngtcp2 include directories. -# - `NGTCP2_LIBRARIES`: The ngtcp2 library names. -# - `NGTCP2_LIBRARY_DIRS`: The ngtcp2 library directories. -# - `NGTCP2_PC_REQUIRES`: The ngtcp2 pkg-config packages. -# - `NGTCP2_CFLAGS`: Required compiler flags. # - `NGTCP2_VERSION`: Version of ngtcp2. +# - `CURL::ngtcp2`: ngtcp2 library target. if(NGTCP2_FIND_COMPONENTS) set(_ngtcp2_crypto_backend "") @@ -71,9 +67,9 @@ if(NGTCP2_FIND_COMPONENTS) endif() endif() -set(NGTCP2_PC_REQUIRES "libngtcp2") +set(_ngtcp2_pc_requires "libngtcp2") if(_ngtcp2_crypto_backend) - list(APPEND NGTCP2_PC_REQUIRES "lib${_crypto_library_lower}") + list(APPEND _ngtcp2_pc_requires "lib${_crypto_library_lower}") endif() set(_tried_pkgconfig FALSE) @@ -81,14 +77,14 @@ if(CURL_USE_PKGCONFIG AND NOT DEFINED NGTCP2_INCLUDE_DIR AND NOT DEFINED NGTCP2_LIBRARY) find_package(PkgConfig QUIET) - pkg_check_modules(NGTCP2 ${NGTCP2_PC_REQUIRES}) + pkg_check_modules(_ngtcp2 ${_ngtcp2_pc_requires}) set(_tried_pkgconfig TRUE) endif() -if(NGTCP2_FOUND) - set(NGTCP2_VERSION ${NGTCP2_libngtcp2_VERSION}) - string(REPLACE ";" " " NGTCP2_CFLAGS "${NGTCP2_CFLAGS}") - message(STATUS "Found NGTCP2 (via pkg-config): ${NGTCP2_INCLUDE_DIRS} (found version \"${NGTCP2_VERSION}\")") +if(_ngtcp2_FOUND) + set(NGTCP2_FOUND TRUE) + set(NGTCP2_VERSION ${_ngtcp2_libngtcp2_VERSION}) + message(STATUS "Found NGTCP2 (via pkg-config): ${_ngtcp2_INCLUDE_DIRS} (found version \"${NGTCP2_VERSION}\")") else() find_path(NGTCP2_INCLUDE_DIR NAMES "ngtcp2/ngtcp2.h") find_library(NGTCP2_LIBRARY NAMES "ngtcp2") @@ -128,8 +124,8 @@ else() ) if(NGTCP2_FOUND) - set(NGTCP2_INCLUDE_DIRS ${NGTCP2_INCLUDE_DIR}) - set(NGTCP2_LIBRARIES ${NGTCP2_LIBRARY} ${NGTCP2_CRYPTO_LIBRARY}) + set(_ngtcp2_INCLUDE_DIRS ${NGTCP2_INCLUDE_DIR}) + set(_ngtcp2_LIBRARIES ${NGTCP2_LIBRARY} ${NGTCP2_CRYPTO_LIBRARY}) endif() mark_as_advanced(NGTCP2_INCLUDE_DIR NGTCP2_LIBRARY NGTCP2_CRYPTO_LIBRARY) @@ -139,3 +135,19 @@ else() unset(NGTCP2_LIBRARY CACHE) endif() endif() + +if(NGTCP2_FOUND) + if(CMAKE_VERSION VERSION_LESS 3.13) + link_directories(${_ngtcp2_LIBRARY_DIRS}) + endif() + + if(NOT TARGET CURL::ngtcp2) + add_library(CURL::ngtcp2 INTERFACE IMPORTED) + set_target_properties(CURL::ngtcp2 PROPERTIES + INTERFACE_LIBCURL_PC_MODULES "${_ngtcp2_pc_requires}" + INTERFACE_COMPILE_OPTIONS "${_ngtcp2_CFLAGS}" + INTERFACE_INCLUDE_DIRECTORIES "${_ngtcp2_INCLUDE_DIRS}" + INTERFACE_LINK_DIRECTORIES "${_ngtcp2_LIBRARY_DIRS}" + INTERFACE_LINK_LIBRARIES "${_ngtcp2_LIBRARIES}") + endif() +endif() diff --git a/CMake/FindNettle.cmake b/CMake/FindNettle.cmake index 7f2f69c1ca3e..d22865ffad69 100644 --- a/CMake/FindNettle.cmake +++ b/CMake/FindNettle.cmake @@ -25,32 +25,29 @@ # # Input variables: # -# - `NETTLE_INCLUDE_DIR`: Absolute path to nettle include directory. -# - `NETTLE_LIBRARY`: Absolute path to `nettle` library. +# - `NETTLE_INCLUDE_DIR`: Absolute path to nettle include directory. +# - `NETTLE_LIBRARY`: Absolute path to `nettle` library. # -# Result variables: +# Defines: # -# - `NETTLE_FOUND`: System has nettle. -# - `NETTLE_INCLUDE_DIRS`: The nettle include directories. -# - `NETTLE_LIBRARIES`: The nettle library names. -# - `NETTLE_LIBRARY_DIRS`: The nettle library directories. -# - `NETTLE_PC_REQUIRES`: The nettle pkg-config packages. -# - `NETTLE_CFLAGS`: Required compiler flags. -# - `NETTLE_VERSION`: Version of nettle. +# - `NETTLE_FOUND`: System has nettle. +# - `NETTLE_VERSION`: Version of nettle. +# - `CURL::nettle`: nettle library target. -set(NETTLE_PC_REQUIRES "nettle") +set(_nettle_pc_requires "nettle") if(CURL_USE_PKGCONFIG AND NOT DEFINED NETTLE_INCLUDE_DIR AND NOT DEFINED NETTLE_LIBRARY) find_package(PkgConfig QUIET) - pkg_check_modules(NETTLE ${NETTLE_PC_REQUIRES}) + pkg_check_modules(_nettle ${_nettle_pc_requires}) endif() -if(NETTLE_FOUND) +if(_nettle_FOUND) set(Nettle_FOUND TRUE) - string(REPLACE ";" " " NETTLE_CFLAGS "${NETTLE_CFLAGS}") - message(STATUS "Found Nettle (via pkg-config): ${NETTLE_INCLUDE_DIRS} (found version \"${NETTLE_VERSION}\")") + set(NETTLE_FOUND TRUE) + set(NETTLE_VERSION ${_nettle_VERSION}) + message(STATUS "Found Nettle (via pkg-config): ${_nettle_INCLUDE_DIRS} (found version \"${NETTLE_VERSION}\")") else() find_path(NETTLE_INCLUDE_DIR NAMES "nettle/sha2.h") find_library(NETTLE_LIBRARY NAMES "nettle") @@ -80,9 +77,25 @@ else() ) if(NETTLE_FOUND) - set(NETTLE_INCLUDE_DIRS ${NETTLE_INCLUDE_DIR}) - set(NETTLE_LIBRARIES ${NETTLE_LIBRARY}) + set(_nettle_INCLUDE_DIRS ${NETTLE_INCLUDE_DIR}) + set(_nettle_LIBRARIES ${NETTLE_LIBRARY}) endif() mark_as_advanced(NETTLE_INCLUDE_DIR NETTLE_LIBRARY) endif() + +if(NETTLE_FOUND) + if(CMAKE_VERSION VERSION_LESS 3.13) + link_directories(${_nettle_LIBRARY_DIRS}) + endif() + + if(NOT TARGET CURL::nettle) + add_library(CURL::nettle INTERFACE IMPORTED) + set_target_properties(CURL::nettle PROPERTIES + INTERFACE_LIBCURL_PC_MODULES "${_nettle_pc_requires}" + INTERFACE_COMPILE_OPTIONS "${_nettle_CFLAGS}" + INTERFACE_INCLUDE_DIRECTORIES "${_nettle_INCLUDE_DIRS}" + INTERFACE_LINK_DIRECTORIES "${_nettle_LIBRARY_DIRS}" + INTERFACE_LINK_LIBRARIES "${_nettle_LIBRARIES}") + endif() +endif() diff --git a/CMake/FindQuiche.cmake b/CMake/FindQuiche.cmake index 934cf9f69f15..22482d79fb4f 100644 --- a/CMake/FindQuiche.cmake +++ b/CMake/FindQuiche.cmake @@ -25,32 +25,29 @@ # # Input variables: # -# - `QUICHE_INCLUDE_DIR`: Absolute path to quiche include directory. -# - `QUICHE_LIBRARY`: Absolute path to `quiche` library. +# - `QUICHE_INCLUDE_DIR`: Absolute path to quiche include directory. +# - `QUICHE_LIBRARY`: Absolute path to `quiche` library. # -# Result variables: +# Defines: # -# - `QUICHE_FOUND`: System has quiche. -# - `QUICHE_INCLUDE_DIRS`: The quiche include directories. -# - `QUICHE_LIBRARIES`: The quiche library names. -# - `QUICHE_LIBRARY_DIRS`: The quiche library directories. -# - `QUICHE_PC_REQUIRES`: The quiche pkg-config packages. -# - `QUICHE_CFLAGS`: Required compiler flags. -# - `QUICHE_VERSION`: Version of quiche. +# - `QUICHE_FOUND`: System has quiche. +# - `QUICHE_VERSION`: Version of quiche. +# - `CURL::quiche`: quiche library target. -set(QUICHE_PC_REQUIRES "quiche") +set(_quiche_pc_requires "quiche") if(CURL_USE_PKGCONFIG AND NOT DEFINED QUICHE_INCLUDE_DIR AND NOT DEFINED QUICHE_LIBRARY) find_package(PkgConfig QUIET) - pkg_check_modules(QUICHE ${QUICHE_PC_REQUIRES}) + pkg_check_modules(_quiche ${_quiche_pc_requires}) endif() -if(QUICHE_FOUND) +if(_quiche_FOUND) set(Quiche_FOUND TRUE) - string(REPLACE ";" " " QUICHE_CFLAGS "${QUICHE_CFLAGS}") - message(STATUS "Found Quiche (via pkg-config): ${QUICHE_INCLUDE_DIRS} (found version \"${QUICHE_VERSION}\")") + set(QUICHE_FOUND TRUE) + set(QUICHE_VERSION ${_quiche_VERSION}) + message(STATUS "Found Quiche (via pkg-config): ${_quiche_INCLUDE_DIRS} (found version \"${QUICHE_VERSION}\")") else() find_path(QUICHE_INCLUDE_DIR NAMES "quiche.h") find_library(QUICHE_LIBRARY NAMES "quiche") @@ -63,9 +60,25 @@ else() ) if(QUICHE_FOUND) - set(QUICHE_INCLUDE_DIRS ${QUICHE_INCLUDE_DIR}) - set(QUICHE_LIBRARIES ${QUICHE_LIBRARY}) + set(_quiche_INCLUDE_DIRS ${QUICHE_INCLUDE_DIR}) + set(_quiche_LIBRARIES ${QUICHE_LIBRARY}) endif() mark_as_advanced(QUICHE_INCLUDE_DIR QUICHE_LIBRARY) endif() + +if(QUICHE_FOUND) + if(CMAKE_VERSION VERSION_LESS 3.13) + link_directories(${_quiche_LIBRARY_DIRS}) + endif() + + if(NOT TARGET CURL::quiche) + add_library(CURL::quiche INTERFACE IMPORTED) + set_target_properties(CURL::quiche PROPERTIES + INTERFACE_LIBCURL_PC_MODULES "${_quiche_pc_requires}" + INTERFACE_COMPILE_OPTIONS "${_quiche_CFLAGS}" + INTERFACE_INCLUDE_DIRECTORIES "${_quiche_INCLUDE_DIRS}" + INTERFACE_LINK_DIRECTORIES "${_quiche_LIBRARY_DIRS}" + INTERFACE_LINK_LIBRARIES "${_quiche_LIBRARIES}") + endif() +endif() diff --git a/CMake/FindRustls.cmake b/CMake/FindRustls.cmake index a29ce5fa098b..37b99be73ea9 100644 --- a/CMake/FindRustls.cmake +++ b/CMake/FindRustls.cmake @@ -25,34 +25,31 @@ # # Input variables: # -# - `RUSTLS_INCLUDE_DIR`: Absolute path to Rustls include directory. -# - `RUSTLS_LIBRARY`: Absolute path to `rustls` library. +# - `RUSTLS_INCLUDE_DIR`: Absolute path to Rustls include directory. +# - `RUSTLS_LIBRARY`: Absolute path to `rustls` library. # -# Result variables: +# Defines: # -# - `RUSTLS_FOUND`: System has Rustls. -# - `RUSTLS_INCLUDE_DIRS`: The Rustls include directories. -# - `RUSTLS_LIBRARIES`: The Rustls library names. -# - `RUSTLS_LIBRARY_DIRS`: The Rustls library directories. -# - `RUSTLS_PC_REQUIRES`: The Rustls pkg-config packages. -# - `RUSTLS_CFLAGS`: Required compiler flags. -# - `RUSTLS_VERSION`: Version of Rustls. +# - `RUSTLS_FOUND`: System has Rustls. +# - `RUSTLS_VERSION`: Version of Rustls. +# - `CURL::rustls`: Rustls library target. -set(RUSTLS_PC_REQUIRES "rustls") +set(_rustls_pc_requires "rustls") if(CURL_USE_PKGCONFIG AND NOT DEFINED RUSTLS_INCLUDE_DIR AND NOT DEFINED RUSTLS_LIBRARY) find_package(PkgConfig QUIET) - pkg_check_modules(RUSTLS ${RUSTLS_PC_REQUIRES}) + pkg_check_modules(_rustls ${_rustls_pc_requires}) endif() -if(RUSTLS_FOUND) +if(_rustls_FOUND) set(Rustls_FOUND TRUE) - string(REPLACE ";" " " RUSTLS_CFLAGS "${RUSTLS_CFLAGS}") - message(STATUS "Found Rustls (via pkg-config): ${RUSTLS_INCLUDE_DIRS} (found version \"${RUSTLS_VERSION}\")") + set(RUSTLS_FOUND TRUE) + set(RUSTLS_VERSION ${_rustls_VERSION}) + message(STATUS "Found Rustls (via pkg-config): ${_rustls_INCLUDE_DIRS} (found version \"${RUSTLS_VERSION}\")") else() - set(RUSTLS_PC_REQUIRES "") # Depend on pkg-config only when found via pkg-config + set(_rustls_pc_requires "") # Depend on pkg-config only when found via pkg-config find_path(RUSTLS_INCLUDE_DIR NAMES "rustls.h") find_library(RUSTLS_LIBRARY NAMES "rustls") @@ -65,8 +62,8 @@ else() ) if(RUSTLS_FOUND) - set(RUSTLS_INCLUDE_DIRS ${RUSTLS_INCLUDE_DIR}) - set(RUSTLS_LIBRARIES ${RUSTLS_LIBRARY}) + set(_rustls_INCLUDE_DIRS ${RUSTLS_INCLUDE_DIR}) + set(_rustls_LIBRARIES ${RUSTLS_LIBRARY}) endif() mark_as_advanced(RUSTLS_INCLUDE_DIR RUSTLS_LIBRARY) @@ -79,31 +76,47 @@ if(RUSTLS_FOUND) if(NOT SECURITY_FRAMEWORK) message(FATAL_ERROR "Security framework not found") endif() - list(APPEND RUSTLS_LIBRARIES "-framework Security") + list(APPEND _rustls_LIBRARIES "-framework Security") find_library(FOUNDATION_FRAMEWORK NAMES "Foundation") mark_as_advanced(FOUNDATION_FRAMEWORK) if(NOT FOUNDATION_FRAMEWORK) message(FATAL_ERROR "Foundation framework not found") endif() - list(APPEND RUSTLS_LIBRARIES "-framework Foundation") + list(APPEND _rustls_LIBRARIES "-framework Foundation") elseif(NOT WIN32) find_library(PTHREAD_LIBRARY NAMES "pthread") if(PTHREAD_LIBRARY) - list(APPEND RUSTLS_LIBRARIES ${PTHREAD_LIBRARY}) + list(APPEND _rustls_LIBRARIES ${PTHREAD_LIBRARY}) endif() mark_as_advanced(PTHREAD_LIBRARY) find_library(DL_LIBRARY NAMES "dl") if(DL_LIBRARY) - list(APPEND RUSTLS_LIBRARIES ${DL_LIBRARY}) + list(APPEND _rustls_LIBRARIES ${DL_LIBRARY}) endif() mark_as_advanced(DL_LIBRARY) find_library(MATH_LIBRARY NAMES "m") if(MATH_LIBRARY) - list(APPEND RUSTLS_LIBRARIES ${MATH_LIBRARY}) + list(APPEND _rustls_LIBRARIES ${MATH_LIBRARY}) endif() mark_as_advanced(MATH_LIBRARY) endif() endif() + +if(RUSTLS_FOUND) + if(CMAKE_VERSION VERSION_LESS 3.13) + link_directories(${_rustls_LIBRARY_DIRS}) + endif() + + if(NOT TARGET CURL::rustls) + add_library(CURL::rustls INTERFACE IMPORTED) + set_target_properties(CURL::rustls PROPERTIES + INTERFACE_LIBCURL_PC_MODULES "${_rustls_pc_requires}" + INTERFACE_COMPILE_OPTIONS "${_rustls_CFLAGS}" + INTERFACE_INCLUDE_DIRECTORIES "${_rustls_INCLUDE_DIRS}" + INTERFACE_LINK_DIRECTORIES "${_rustls_LIBRARY_DIRS}" + INTERFACE_LINK_LIBRARIES "${_rustls_LIBRARIES}") + endif() +endif() diff --git a/CMake/FindWolfSSL.cmake b/CMake/FindWolfSSL.cmake index 4d172c029a39..3a3c05f0fd03 100644 --- a/CMake/FindWolfSSL.cmake +++ b/CMake/FindWolfSSL.cmake @@ -25,18 +25,14 @@ # # Input variables: # -# - `WOLFSSL_INCLUDE_DIR`: Absolute path to wolfSSL include directory. -# - `WOLFSSL_LIBRARY`: Absolute path to `wolfssl` library. +# - `WOLFSSL_INCLUDE_DIR`: Absolute path to wolfSSL include directory. +# - `WOLFSSL_LIBRARY`: Absolute path to `wolfssl` library. # -# Result variables: +# Defines: # -# - `WOLFSSL_FOUND`: System has wolfSSL. -# - `WOLFSSL_INCLUDE_DIRS`: The wolfSSL include directories. -# - `WOLFSSL_LIBRARIES`: The wolfSSL library names. -# - `WOLFSSL_LIBRARY_DIRS`: The wolfSSL library directories. -# - `WOLFSSL_PC_REQUIRES`: The wolfSSL pkg-config packages. -# - `WOLFSSL_CFLAGS`: Required compiler flags. -# - `WOLFSSL_VERSION`: Version of wolfSSL. +# - `WOLFSSL_FOUND`: System has wolfSSL. +# - `WOLFSSL_VERSION`: Version of wolfSSL. +# - `CURL::wolfssl`: wolfSSL library target. if(DEFINED WolfSSL_INCLUDE_DIR AND NOT DEFINED WOLFSSL_INCLUDE_DIR) message(WARNING "WolfSSL_INCLUDE_DIR is deprecated, use WOLFSSL_INCLUDE_DIR instead.") @@ -47,19 +43,20 @@ if(DEFINED WolfSSL_LIBRARY AND NOT DEFINED WOLFSSL_LIBRARY) set(WOLFSSL_LIBRARY "${WolfSSL_LIBRARY}") endif() -set(WOLFSSL_PC_REQUIRES "wolfssl") +set(_wolfssl_pc_requires "wolfssl") if(CURL_USE_PKGCONFIG AND NOT DEFINED WOLFSSL_INCLUDE_DIR AND NOT DEFINED WOLFSSL_LIBRARY) find_package(PkgConfig QUIET) - pkg_check_modules(WOLFSSL ${WOLFSSL_PC_REQUIRES}) + pkg_check_modules(_wolfssl ${_wolfssl_pc_requires}) endif() -if(WOLFSSL_FOUND) +if(_wolfssl_FOUND) set(WolfSSL_FOUND TRUE) - string(REPLACE ";" " " WOLFSSL_CFLAGS "${WOLFSSL_CFLAGS}") - message(STATUS "Found WolfSSL (via pkg-config): ${WOLFSSL_INCLUDE_DIRS} (found version \"${WOLFSSL_VERSION}\")") + set(WOLFSSL_FOUND TRUE) + set(WOLFSSL_VERSION ${_wolfssl_VERSION}) + message(STATUS "Found WolfSSL (via pkg-config): ${_wolfssl_INCLUDE_DIRS} (found version \"${WOLFSSL_VERSION}\")") else() find_path(WOLFSSL_INCLUDE_DIR NAMES "wolfssl/ssl.h") find_library(WOLFSSL_LIBRARY NAMES "wolfssl") @@ -84,8 +81,8 @@ else() ) if(WOLFSSL_FOUND) - set(WOLFSSL_INCLUDE_DIRS ${WOLFSSL_INCLUDE_DIR}) - set(WOLFSSL_LIBRARIES ${WOLFSSL_LIBRARY}) + set(_wolfssl_INCLUDE_DIRS ${WOLFSSL_INCLUDE_DIR}) + set(_wolfssl_LIBRARIES ${WOLFSSL_LIBRARY}) endif() mark_as_advanced(WOLFSSL_INCLUDE_DIR WOLFSSL_LIBRARY) @@ -98,19 +95,35 @@ if(WOLFSSL_FOUND) if(NOT SECURITY_FRAMEWORK) message(FATAL_ERROR "Security framework not found") endif() - list(APPEND WOLFSSL_LIBRARIES "-framework Security") + list(APPEND _wolfssl_LIBRARIES "-framework Security") find_library(COREFOUNDATION_FRAMEWORK NAMES "CoreFoundation") mark_as_advanced(COREFOUNDATION_FRAMEWORK) if(NOT COREFOUNDATION_FRAMEWORK) message(FATAL_ERROR "CoreFoundation framework not found") endif() - list(APPEND WOLFSSL_LIBRARIES "-framework CoreFoundation") - elseif(NOT WIN32) + list(APPEND _wolfssl_LIBRARIES "-framework CoreFoundation") + elseif(WIN32) + list(APPEND _wolfssl_LIBRARIES "crypt32") + else() find_library(MATH_LIBRARY NAMES "m") if(MATH_LIBRARY) - list(APPEND WOLFSSL_LIBRARIES ${MATH_LIBRARY}) # for log and pow + list(APPEND _wolfssl_LIBRARIES ${MATH_LIBRARY}) # for log and pow endif() mark_as_advanced(MATH_LIBRARY) endif() + + if(CMAKE_VERSION VERSION_LESS 3.13) + link_directories(${_wolfssl_LIBRARY_DIRS}) + endif() + + if(NOT TARGET CURL::wolfssl) + add_library(CURL::wolfssl INTERFACE IMPORTED) + set_target_properties(CURL::wolfssl PROPERTIES + INTERFACE_LIBCURL_PC_MODULES "${_wolfssl_pc_requires}" + INTERFACE_COMPILE_OPTIONS "${_wolfssl_CFLAGS}" + INTERFACE_INCLUDE_DIRECTORIES "${_wolfssl_INCLUDE_DIRS}" + INTERFACE_LINK_DIRECTORIES "${_wolfssl_LIBRARY_DIRS}" + INTERFACE_LINK_LIBRARIES "${_wolfssl_LIBRARIES}") + endif() endif() diff --git a/CMake/FindZstd.cmake b/CMake/FindZstd.cmake index 655f0cc700a8..954a827b6fe4 100644 --- a/CMake/FindZstd.cmake +++ b/CMake/FindZstd.cmake @@ -25,18 +25,14 @@ # # Input variables: # -# - `ZSTD_INCLUDE_DIR`: Absolute path to zstd include directory. -# - `ZSTD_LIBRARY`: Absolute path to `zstd` library. +# - `ZSTD_INCLUDE_DIR`: Absolute path to zstd include directory. +# - `ZSTD_LIBRARY`: Absolute path to `zstd` library. # -# Result variables: +# Defines: # -# - `ZSTD_FOUND`: System has zstd. -# - `ZSTD_INCLUDE_DIRS`: The zstd include directories. -# - `ZSTD_LIBRARIES`: The zstd library names. -# - `ZSTD_LIBRARY_DIRS`: The zstd library directories. -# - `ZSTD_PC_REQUIRES`: The zstd pkg-config packages. -# - `ZSTD_CFLAGS`: Required compiler flags. -# - `ZSTD_VERSION`: Version of zstd. +# - `ZSTD_FOUND`: System has zstd. +# - `ZSTD_VERSION`: Version of zstd. +# - `CURL::zstd`: zstd library target. if(DEFINED Zstd_INCLUDE_DIR AND NOT DEFINED ZSTD_INCLUDE_DIR) message(WARNING "Zstd_INCLUDE_DIR is deprecated, use ZSTD_INCLUDE_DIR instead.") @@ -47,19 +43,20 @@ if(DEFINED Zstd_LIBRARY AND NOT DEFINED ZSTD_LIBRARY) set(ZSTD_LIBRARY "${Zstd_LIBRARY}") endif() -set(ZSTD_PC_REQUIRES "libzstd") +set(_zstd_pc_requires "libzstd") if(CURL_USE_PKGCONFIG AND NOT DEFINED ZSTD_INCLUDE_DIR AND NOT DEFINED ZSTD_LIBRARY) find_package(PkgConfig QUIET) - pkg_check_modules(ZSTD ${ZSTD_PC_REQUIRES}) + pkg_check_modules(_zstd ${_zstd_pc_requires}) endif() -if(ZSTD_FOUND) +if(_zstd_FOUND) set(Zstd_FOUND TRUE) - string(REPLACE ";" " " ZSTD_CFLAGS "${ZSTD_CFLAGS}") - message(STATUS "Found Zstd (via pkg-config): ${ZSTD_INCLUDE_DIRS} (found version \"${ZSTD_VERSION}\")") + set(ZSTD_FOUND TRUE) + set(ZSTD_VERSION ${_zstd_VERSION}) + message(STATUS "Found Zstd (via pkg-config): ${_zstd_INCLUDE_DIRS} (found version \"${ZSTD_VERSION}\")") else() find_path(ZSTD_INCLUDE_DIR NAMES "zstd.h") find_library(ZSTD_LIBRARY NAMES "zstd") @@ -94,9 +91,25 @@ else() ) if(ZSTD_FOUND) - set(ZSTD_INCLUDE_DIRS ${ZSTD_INCLUDE_DIR}) - set(ZSTD_LIBRARIES ${ZSTD_LIBRARY}) + set(_zstd_INCLUDE_DIRS ${ZSTD_INCLUDE_DIR}) + set(_zstd_LIBRARIES ${ZSTD_LIBRARY}) endif() mark_as_advanced(ZSTD_INCLUDE_DIR ZSTD_LIBRARY) endif() + +if(ZSTD_FOUND) + if(CMAKE_VERSION VERSION_LESS 3.13) + link_directories(${_zstd_LIBRARY_DIRS}) + endif() + + if(NOT TARGET CURL::zstd) + add_library(CURL::zstd INTERFACE IMPORTED) + set_target_properties(CURL::zstd PROPERTIES + INTERFACE_LIBCURL_PC_MODULES "${_zstd_pc_requires}" + INTERFACE_COMPILE_OPTIONS "${_zstd_CFLAGS}" + INTERFACE_INCLUDE_DIRECTORIES "${_zstd_INCLUDE_DIRS}" + INTERFACE_LINK_DIRECTORIES "${_zstd_LIBRARY_DIRS}" + INTERFACE_LINK_LIBRARIES "${_zstd_LIBRARIES}") + endif() +endif() diff --git a/CMake/Utilities.cmake b/CMake/Utilities.cmake index 335713c84cfe..efa28b75155b 100644 --- a/CMake/Utilities.cmake +++ b/CMake/Utilities.cmake @@ -59,6 +59,7 @@ function(curl_dumptargetprops _target) string(REPLACE "\n" ";" _cmake_property_list "${_cmake_property_list}") list(REMOVE_DUPLICATES _cmake_property_list) list(REMOVE_ITEM _cmake_property_list "") + list(APPEND _cmake_property_list "INTERFACE_LIBCURL_PC_MODULES") foreach(_prop IN LISTS _cmake_property_list) if(_prop MATCHES "") foreach(_config IN ITEMS "DEBUG" "RELEASE" "MINSIZEREL" "RELWITHDEBINFO") diff --git a/CMake/curl-config.cmake.in b/CMake/curl-config.cmake.in index d1582b8d41b9..99949198a305 100644 --- a/CMake/curl-config.cmake.in +++ b/CMake/curl-config.cmake.in @@ -23,7 +23,12 @@ ########################################################################### @PACKAGE_INIT@ +option(CURL_USE_PKGCONFIG "Enable pkg-config to detect @PROJECT_NAME@ dependencies. Default: @CURL_USE_PKGCONFIG@" "@CURL_USE_PKGCONFIG@") + include(CMakeFindDependencyMacro) +set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR} ${CMAKE_MODULE_PATH}) + +set(_libs "") if("@USE_OPENSSL@") if("@OPENSSL_VERSION_MAJOR@") find_dependency(OpenSSL "@OPENSSL_VERSION_MAJOR@") @@ -34,6 +39,97 @@ endif() if("@HAVE_LIBZ@") find_dependency(ZLIB "@ZLIB_VERSION_MAJOR@") endif() +if("@HAVE_BROTLI@") + find_dependency(Brotli) + list(APPEND _libs CURL::brotli) +endif() +if("@USE_ARES@") + find_dependency(Cares) + list(APPEND _libs CURL::cares) +endif() +if("@HAVE_GSSAPI@") + find_dependency(GSS) + list(APPEND _libs CURL::gss) +endif() +if("@USE_BACKTRACE@") + find_dependency(Libbacktrace) + list(APPEND _libs CURL::libbacktrace) +endif() +if("@USE_GSASL@") + find_dependency(Libgsasl) + list(APPEND _libs CURL::libgsasl) +endif() +if(NOT "@USE_WIN32_LDAP@" AND NOT "@CURL_DISABLE_LDAP@") + find_dependency(LDAP) + list(APPEND _libs CURL::ldap) +endif() +if("@HAVE_LIBIDN2@") + find_dependency(Libidn2) + list(APPEND _libs CURL::libidn2) +endif() +if("@USE_LIBPSL@") + find_dependency(Libpsl) + list(APPEND _libs CURL::libpsl) +endif() +if("@USE_LIBRTMP@") + find_dependency(Librtmp) + list(APPEND _libs CURL::librtmp) +endif() +if("@USE_LIBSSH@") + find_dependency(Libssh) + list(APPEND _libs CURL::libssh) +endif() +if("@USE_LIBSSH2@") + find_dependency(Libssh2) + list(APPEND _libs CURL::libssh2) +endif() +if("@USE_LIBUV@") + find_dependency(Libuv) + list(APPEND _libs CURL::libuv) +endif() +if("@USE_MBEDTLS@") + find_dependency(MbedTLS) + list(APPEND _libs CURL::mbedtls) +endif() +if("@USE_NGHTTP2@") + find_dependency(NGHTTP2) + list(APPEND _libs CURL::nghttp2) +endif() +if("@USE_NGHTTP3@") + find_dependency(NGHTTP3) + list(APPEND _libs CURL::nghttp3) +endif() +if("@USE_NGTCP2@") + find_dependency(NGTCP2) + list(APPEND _libs CURL::ngtcp2) +endif() +if("@USE_GNUTLS@") + find_dependency(GnuTLS) + list(APPEND _libs CURL::gnutls) + find_dependency(Nettle) + list(APPEND _libs CURL::nettle) +endif() +if("@USE_QUICHE@") + find_dependency(Quiche) + list(APPEND _libs CURL::quiche) +endif() +if("@USE_RUSTLS@") + find_dependency(Rustls) + list(APPEND _libs CURL::rustls) +endif() +if("@USE_WOLFSSL@") + find_dependency(WolfSSL) + list(APPEND _libs CURL::wolfssl) +endif() +if("@HAVE_ZSTD@") + find_dependency(Zstd) + list(APPEND _libs CURL::zstd) +endif() + +if(CMAKE_C_COMPILER_ID STREQUAL "GNU" AND WIN32 AND NOT TARGET CURL::win32_winsock) + add_library(CURL::win32_winsock INTERFACE IMPORTED) + set_target_properties(CURL::win32_winsock PROPERTIES INTERFACE_LINK_LIBRARIES "@_win32_winsock@") +endif() include("${CMAKE_CURRENT_LIST_DIR}/@TARGETS_EXPORT_NAME@.cmake") @@ -45,9 +141,31 @@ if(NOT TARGET @PROJECT_NAME@::@LIB_NAME@) add_library(@PROJECT_NAME@::@LIB_NAME@ ALIAS @PROJECT_NAME@::@LIB_SELECTED@) endif() +if(TARGET @PROJECT_NAME@::@LIB_STATIC@) + # CMake before CMP0099 (CMake 3.17 2020-03-20) did not propagate libdirs to + # targets. It expected libs to have an absolute filename. As a workaround, + # manually apply dependency libdirs, for CMake consumers without this policy. + if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.17) + cmake_policy(GET CMP0099 _has_CMP0099) # https://cmake.org/cmake/help/latest/policy/CMP0099.html + endif() + if(NOT _has_CMP0099 AND CMAKE_VERSION VERSION_GREATER_EQUAL 3.13 AND _libs) + set(_libdirs "") + foreach(_lib IN LISTS _libs) + get_target_property(_libdir "${_lib}" INTERFACE_LINK_DIRECTORIES) + if(_libdir) + list(APPEND _libdirs "${_libdir}") + endif() + endforeach() + if(_libdirs) + target_link_directories(@PROJECT_NAME@::@LIB_STATIC@ INTERFACE ${_libdirs}) + endif() + endif() +endif() + # For compatibility with CMake's FindCURL.cmake set(CURL_VERSION_STRING "@CURLVERSION@") set(CURL_LIBRARIES @PROJECT_NAME@::@LIB_NAME@) +set(CURL_LIBRARIES_PRIVATE "@LIBCURL_PC_LIBS_PRIVATE_LIST@") set_and_check(CURL_INCLUDE_DIRS "@PACKAGE_CMAKE_INSTALL_INCLUDEDIR@") set(CURL_SUPPORTED_PROTOCOLS "@CURL_SUPPORTED_PROTOCOLS_LIST@") diff --git a/CMakeLists.txt b/CMakeLists.txt index 5d6e7ca3e667..2af1679c993f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -358,23 +358,14 @@ else() endif() option(CURL_USE_PKGCONFIG "Enable pkg-config to detect dependencies" ${_curl_use_pkgconfig_default}) -# Initialize variables collecting dependency libs, paths, pkg-config names. +# Initialize variables collecting system and dependency libs. set(CURL_NETWORK_AND_TIME_LIBS "") set(CURL_LIBS "") -set(CURL_LIBDIRS "") -set(LIBCURL_PC_REQUIRES_PRIVATE "") if(ENABLE_ARES) set(USE_ARES 1) find_package(Cares REQUIRED) - list(APPEND CURL_LIBS ${CARES_LIBRARIES}) - list(APPEND CURL_LIBDIRS ${CARES_LIBRARY_DIRS}) - list(APPEND LIBCURL_PC_REQUIRES_PRIVATE ${CARES_PC_REQUIRES}) - include_directories(SYSTEM ${CARES_INCLUDE_DIRS}) - link_directories(${CARES_LIBRARY_DIRS}) - if(CARES_CFLAGS) - string(APPEND CMAKE_C_FLAGS " ${CARES_CFLAGS}") - endif() + list(APPEND CURL_LIBS CURL::cares) endif() include(CurlSymbolHiding) @@ -762,7 +753,7 @@ if(CURL_USE_OPENSSL) # Depend on OpenSSL via imported targets. This allows our dependents to # get our dependencies transitively. list(APPEND CURL_LIBS OpenSSL::SSL OpenSSL::Crypto) - list(APPEND LIBCURL_PC_REQUIRES_PRIVATE "openssl") + set_target_properties(OpenSSL::SSL PROPERTIES INTERFACE_LIBCURL_PC_MODULES "openssl") if(CURL_DEFAULT_SSL_BACKEND AND CURL_DEFAULT_SSL_BACKEND STREQUAL "openssl") set(_valid_default_ssl_backend TRUE) @@ -809,14 +800,7 @@ if(CURL_USE_MBEDTLS) endif() set(_ssl_enabled ON) set(USE_MBEDTLS ON) - list(APPEND CURL_LIBS ${MBEDTLS_LIBRARIES}) - list(APPEND CURL_LIBDIRS ${MBEDTLS_LIBRARY_DIRS}) - list(APPEND LIBCURL_PC_REQUIRES_PRIVATE ${MBEDTLS_PC_REQUIRES}) - include_directories(SYSTEM ${MBEDTLS_INCLUDE_DIRS}) - link_directories(${MBEDTLS_LIBRARY_DIRS}) - if(MBEDTLS_CFLAGS) - string(APPEND CMAKE_C_FLAGS " ${MBEDTLS_CFLAGS}") - endif() + list(APPEND CURL_LIBS CURL::mbedtls) if(CURL_DEFAULT_SSL_BACKEND AND CURL_DEFAULT_SSL_BACKEND STREQUAL "mbedtls") set(_valid_default_ssl_backend TRUE) @@ -828,9 +812,7 @@ if(CURL_USE_MBEDTLS) endif() if(NOT DEFINED HAVE_MBEDTLS_DES_CRYPT_ECB) cmake_push_check_state() - list(APPEND CMAKE_REQUIRED_INCLUDES "${MBEDTLS_INCLUDE_DIRS}") - list(APPEND CMAKE_REQUIRED_LIBRARIES "${MBEDTLS_LIBRARIES}") - curl_required_libpaths("${MBEDTLS_LIBRARY_DIRS}") + list(APPEND CMAKE_REQUIRED_LIBRARIES CURL::mbedtls) check_function_exists("mbedtls_des_crypt_ecb" HAVE_MBEDTLS_DES_CRYPT_ECB) # in mbedTLS <4 cmake_pop_check_state() endif() @@ -840,14 +822,7 @@ if(CURL_USE_WOLFSSL) find_package(WolfSSL REQUIRED) set(_ssl_enabled ON) set(USE_WOLFSSL ON) - list(APPEND CURL_LIBS ${WOLFSSL_LIBRARIES}) - list(APPEND CURL_LIBDIRS ${WOLFSSL_LIBRARY_DIRS}) - list(APPEND LIBCURL_PC_REQUIRES_PRIVATE ${WOLFSSL_PC_REQUIRES}) - include_directories(SYSTEM ${WOLFSSL_INCLUDE_DIRS}) - link_directories(${WOLFSSL_LIBRARY_DIRS}) - if(WOLFSSL_CFLAGS) - string(APPEND CMAKE_C_FLAGS " ${WOLFSSL_CFLAGS}") - endif() + list(APPEND CURL_LIBS CURL::wolfssl) if(CURL_DEFAULT_SSL_BACKEND AND CURL_DEFAULT_SSL_BACKEND STREQUAL "wolfssl") set(_valid_default_ssl_backend TRUE) @@ -857,26 +832,11 @@ endif() if(CURL_USE_GNUTLS) find_package(GnuTLS REQUIRED) - list(APPEND CURL_LIBS ${GNUTLS_LIBRARIES}) - list(APPEND CURL_LIBDIRS ${GNUTLS_LIBRARY_DIRS}) - list(APPEND LIBCURL_PC_REQUIRES_PRIVATE ${GNUTLS_PC_REQUIRES}) - include_directories(SYSTEM ${GNUTLS_INCLUDE_DIRS}) - link_directories(${GNUTLS_LIBRARY_DIRS}) - if(GNUTLS_CFLAGS) - string(APPEND CMAKE_C_FLAGS " ${GNUTLS_CFLAGS}") - endif() - + list(APPEND CURL_LIBS CURL::gnutls) find_package(Nettle REQUIRED) + list(APPEND CURL_LIBS CURL::nettle) set(_ssl_enabled ON) set(USE_GNUTLS ON) - list(APPEND CURL_LIBS ${NETTLE_LIBRARIES}) - list(APPEND CURL_LIBDIRS ${NETTLE_LIBRARY_DIRS}) - list(APPEND LIBCURL_PC_REQUIRES_PRIVATE ${NETTLE_PC_REQUIRES}) - include_directories(SYSTEM ${NETTLE_INCLUDE_DIRS}) - link_directories(${NETTLE_LIBRARY_DIRS}) - if(NETTLE_CFLAGS) - string(APPEND CMAKE_C_FLAGS " ${NETTLE_CFLAGS}") - endif() if(CURL_DEFAULT_SSL_BACKEND AND CURL_DEFAULT_SSL_BACKEND STREQUAL "gnutls") set(_valid_default_ssl_backend TRUE) @@ -885,9 +845,7 @@ if(CURL_USE_GNUTLS) if(NOT DEFINED HAVE_GNUTLS_SRP AND NOT CURL_DISABLE_SRP) cmake_push_check_state() - list(APPEND CMAKE_REQUIRED_INCLUDES "${GNUTLS_INCLUDE_DIRS}") - list(APPEND CMAKE_REQUIRED_LIBRARIES "${GNUTLS_LIBRARIES}") - curl_required_libpaths("${GNUTLS_LIBRARY_DIRS}") + list(APPEND CMAKE_REQUIRED_LIBRARIES CURL::gnutls) # In GnuTLS 3.8.0 (2023-02-10) and upper, this check always succeeds. # Detecting actual TLS-SRP support needs poking the API at runtime. check_symbol_exists("gnutls_srp_verifier" "gnutls/gnutls.h" HAVE_GNUTLS_SRP) @@ -899,23 +857,14 @@ if(CURL_USE_RUSTLS) find_package(Rustls REQUIRED) set(_ssl_enabled ON) set(USE_RUSTLS ON) - list(APPEND CURL_LIBS ${RUSTLS_LIBRARIES}) - list(APPEND CURL_LIBDIRS ${RUSTLS_LIBRARY_DIRS}) - list(APPEND LIBCURL_PC_REQUIRES_PRIVATE ${RUSTLS_PC_REQUIRES}) - include_directories(SYSTEM ${RUSTLS_INCLUDE_DIRS}) - link_directories(${RUSTLS_LIBRARY_DIRS}) - if(RUSTLS_CFLAGS) - string(APPEND CMAKE_C_FLAGS " ${RUSTLS_CFLAGS}") - endif() + list(APPEND CURL_LIBS CURL::rustls) if(NOT DEFINED HAVE_RUSTLS_SUPPORTED_HPKE) if(RUSTLS_VERSION AND RUSTLS_VERSION VERSION_GREATER_EQUAL 0.15) set(HAVE_RUSTLS_SUPPORTED_HPKE TRUE) elseif(NOT RUSTLS_VERSION) cmake_push_check_state() - list(APPEND CMAKE_REQUIRED_INCLUDES "${RUSTLS_INCLUDE_DIRS}") - list(APPEND CMAKE_REQUIRED_LIBRARIES "${RUSTLS_LIBRARIES}") - curl_required_libpaths("${RUSTLS_LIBRARY_DIRS}") + list(APPEND CMAKE_REQUIRED_LIBRARIES CURL::rustls) check_symbol_exists("rustls_supported_hpke" "rustls.h" HAVE_RUSTLS_SUPPORTED_HPKE) cmake_pop_check_state() endif() @@ -944,21 +893,14 @@ if(ZLIB_FOUND) # Depend on ZLIB via imported targets. This allows our dependents to # get our dependencies transitively. list(APPEND CURL_LIBS ZLIB::ZLIB) - list(APPEND LIBCURL_PC_REQUIRES_PRIVATE "zlib") + set_target_properties(ZLIB::ZLIB PROPERTIES INTERFACE_LIBCURL_PC_MODULES "zlib") endif() set(HAVE_BROTLI OFF) curl_dependency_option(CURL_BROTLI Brotli "brotli") if(BROTLI_FOUND) set(HAVE_BROTLI ON) - list(APPEND CURL_LIBS ${BROTLI_LIBRARIES}) - list(APPEND CURL_LIBDIRS ${BROTLI_LIBRARY_DIRS}) - list(APPEND LIBCURL_PC_REQUIRES_PRIVATE ${BROTLI_PC_REQUIRES}) - include_directories(SYSTEM ${BROTLI_INCLUDE_DIRS}) - link_directories(${BROTLI_LIBRARY_DIRS}) - if(BROTLI_CFLAGS) - string(APPEND CMAKE_C_FLAGS " ${BROTLI_CFLAGS}") - endif() + list(APPEND CURL_LIBS CURL::brotli) endif() set(HAVE_ZSTD OFF) @@ -966,14 +908,7 @@ curl_dependency_option(CURL_ZSTD Zstd "zstd") if(ZSTD_FOUND) if(ZSTD_VERSION VERSION_GREATER_EQUAL 1.0.0) set(HAVE_ZSTD ON) - list(APPEND CURL_LIBS ${ZSTD_LIBRARIES}) - list(APPEND CURL_LIBDIRS ${ZSTD_LIBRARY_DIRS}) - list(APPEND LIBCURL_PC_REQUIRES_PRIVATE ${ZSTD_PC_REQUIRES}) - include_directories(SYSTEM ${ZSTD_INCLUDE_DIRS}) - link_directories(${ZSTD_LIBRARY_DIRS}) - if(ZSTD_CFLAGS) - string(APPEND CMAKE_C_FLAGS " ${ZSTD_CFLAGS}") - endif() + list(APPEND CURL_LIBS CURL::zstd) else() message(WARNING "zstd v1.0.0 or newer is required, disabling zstd support.") endif() @@ -993,9 +928,7 @@ macro(curl_openssl_check_exists) endif() endif() if(USE_WOLFSSL) - list(APPEND CMAKE_REQUIRED_INCLUDES "${WOLFSSL_INCLUDE_DIRS}") - list(APPEND CMAKE_REQUIRED_LIBRARIES "${WOLFSSL_LIBRARIES}") - curl_required_libpaths("${WOLFSSL_LIBRARY_DIRS}") + list(APPEND CMAKE_REQUIRED_LIBRARIES CURL::wolfssl) if(HAVE_LIBZ) list(APPEND CMAKE_REQUIRED_LIBRARIES ZLIB::ZLIB) # Public wolfSSL headers also require zlib headers endif() @@ -1097,14 +1030,7 @@ option(USE_NGHTTP2 "Use nghttp2 library" ON) if(USE_NGHTTP2) find_package(NGHTTP2) if(NGHTTP2_FOUND) - list(APPEND CURL_LIBS ${NGHTTP2_LIBRARIES}) - list(APPEND CURL_LIBDIRS ${NGHTTP2_LIBRARY_DIRS}) - list(APPEND LIBCURL_PC_REQUIRES_PRIVATE ${NGHTTP2_PC_REQUIRES}) - include_directories(SYSTEM ${NGHTTP2_INCLUDE_DIRS}) - link_directories(${NGHTTP2_LIBRARY_DIRS}) - if(NGHTTP2_CFLAGS) - string(APPEND CMAKE_C_FLAGS " ${NGHTTP2_CFLAGS}") - endif() + list(APPEND CURL_LIBS CURL::nghttp2) else() set(USE_NGHTTP2 OFF) endif() @@ -1140,25 +1066,11 @@ if(USE_NGTCP2) else() message(FATAL_ERROR "ngtcp2 requires a supported TLS-backend") endif() - list(APPEND CURL_LIBS ${NGTCP2_LIBRARIES}) - list(APPEND CURL_LIBDIRS ${NGTCP2_LIBRARY_DIRS}) - list(APPEND LIBCURL_PC_REQUIRES_PRIVATE ${NGTCP2_PC_REQUIRES}) - include_directories(SYSTEM ${NGTCP2_INCLUDE_DIRS}) - link_directories(${NGTCP2_LIBRARY_DIRS}) - if(NGTCP2_CFLAGS) - string(APPEND CMAKE_C_FLAGS " ${NGTCP2_CFLAGS}") - endif() + list(APPEND CURL_LIBS CURL::ngtcp2) find_package(NGHTTP3 REQUIRED) set(USE_NGHTTP3 ON) - list(APPEND CURL_LIBS ${NGHTTP3_LIBRARIES}) - list(APPEND CURL_LIBDIRS ${NGHTTP3_LIBRARY_DIRS}) - list(APPEND LIBCURL_PC_REQUIRES_PRIVATE ${NGHTTP3_PC_REQUIRES}) - include_directories(SYSTEM ${NGHTTP3_INCLUDE_DIRS}) - link_directories(${NGHTTP3_LIBRARY_DIRS}) - if(NGHTTP3_CFLAGS) - string(APPEND CMAKE_C_FLAGS " ${NGHTTP3_CFLAGS}") - endif() + list(APPEND CURL_LIBS CURL::nghttp3) endif() option(USE_QUICHE "Use quiche library for HTTP/3 support" OFF) @@ -1173,18 +1085,10 @@ if(USE_QUICHE) message(FATAL_ERROR "quiche requires BoringSSL") endif() curl_openssl_check_quic() - list(APPEND CURL_LIBS ${QUICHE_LIBRARIES}) - list(APPEND CURL_LIBDIRS ${QUICHE_LIBRARY_DIRS}) - list(APPEND LIBCURL_PC_REQUIRES_PRIVATE ${QUICHE_PC_REQUIRES}) - include_directories(SYSTEM ${QUICHE_INCLUDE_DIRS}) - link_directories(${QUICHE_LIBRARY_DIRS}) - if(QUICHE_CFLAGS) - string(APPEND CMAKE_C_FLAGS " ${QUICHE_CFLAGS}") - endif() + list(APPEND CURL_LIBS CURL::quiche) if(NOT DEFINED HAVE_QUICHE_CONN_SET_QLOG_FD) cmake_push_check_state() - list(APPEND CMAKE_REQUIRED_INCLUDES "${QUICHE_INCLUDE_DIRS}") - list(APPEND CMAKE_REQUIRED_LIBRARIES "${QUICHE_LIBRARIES}") + list(APPEND CMAKE_REQUIRED_LIBRARIES CURL::quiche) check_symbol_exists("quiche_conn_set_qlog_fd" "quiche.h" HAVE_QUICHE_CONN_SET_QLOG_FD) cmake_pop_check_state() endif() @@ -1200,14 +1104,7 @@ if(USE_OPENSSL_QUIC) find_package(NGHTTP3 REQUIRED) set(USE_NGHTTP3 ON) - list(APPEND CURL_LIBS ${NGHTTP3_LIBRARIES}) - list(APPEND CURL_LIBDIRS ${NGHTTP3_LIBRARY_DIRS}) - list(APPEND LIBCURL_PC_REQUIRES_PRIVATE ${NGHTTP3_PC_REQUIRES}) - include_directories(SYSTEM ${NGHTTP3_INCLUDE_DIRS}) - link_directories(${NGHTTP3_LIBRARY_DIRS}) - if(NGHTTP3_CFLAGS) - string(APPEND CMAKE_C_FLAGS " ${NGHTTP3_CFLAGS}") - endif() + list(APPEND CURL_LIBS CURL::nghttp3) endif() if(NOT CURL_DISABLE_SRP AND (HAVE_GNUTLS_SRP OR HAVE_OPENSSL_SRP)) @@ -1235,22 +1132,12 @@ if(NOT CURL_DISABLE_LDAP) find_package(LDAP) if(LDAP_FOUND) set(HAVE_LBER_H 1) - set(CURL_LIBS ${LDAP_LIBRARIES} ${CURL_LIBS}) - list(APPEND CURL_LIBDIRS ${LDAP_LIBRARY_DIRS}) - if(LDAP_PC_REQUIRES) - set(LIBCURL_PC_REQUIRES_PRIVATE ${LDAP_PC_REQUIRES} ${LIBCURL_PC_REQUIRES_PRIVATE}) - endif() - include_directories(SYSTEM ${LDAP_INCLUDE_DIRS}) - link_directories(${LDAP_LIBRARY_DIRS}) - if(LDAP_CFLAGS) - string(APPEND CMAKE_C_FLAGS " ${LDAP_CFLAGS}") - endif() + set(CURL_LIBS CURL::ldap ${CURL_LIBS}) # LDAP feature checks list(APPEND CMAKE_REQUIRED_DEFINITIONS "-DLDAP_DEPRECATED=1") - list(APPEND CMAKE_REQUIRED_LIBRARIES "${LDAP_LIBRARIES}") - curl_required_libpaths("${LDAP_LIBRARY_DIRS}") + list(APPEND CMAKE_REQUIRED_LIBRARIES CURL::ldap) check_function_exists("ldap_url_parse" HAVE_LDAP_URL_PARSE) check_function_exists("ldap_init_fd" HAVE_LDAP_INIT_FD) @@ -1312,14 +1199,7 @@ set(HAVE_LIBIDN2 OFF) if(USE_LIBIDN2 AND NOT USE_APPLE_IDN AND NOT USE_WIN32_IDN) find_package(Libidn2) if(LIBIDN2_FOUND) - set(CURL_LIBS ${LIBIDN2_LIBRARIES} ${CURL_LIBS}) - list(APPEND CURL_LIBDIRS ${LIBIDN2_LIBRARY_DIRS}) - set(LIBCURL_PC_REQUIRES_PRIVATE ${LIBIDN2_PC_REQUIRES} ${LIBCURL_PC_REQUIRES_PRIVATE}) - include_directories(SYSTEM ${LIBIDN2_INCLUDE_DIRS}) - link_directories(${LIBIDN2_LIBRARY_DIRS}) - if(LIBIDN2_CFLAGS) - string(APPEND CMAKE_C_FLAGS " ${LIBIDN2_CFLAGS}") - endif() + set(CURL_LIBS CURL::libidn2 ${CURL_LIBS}) set(HAVE_IDN2_H 1) set(HAVE_LIBIDN2 1) endif() @@ -1329,17 +1209,9 @@ endif() option(CURL_USE_LIBPSL "Use libpsl" ON) mark_as_advanced(CURL_USE_LIBPSL) set(USE_LIBPSL OFF) - if(CURL_USE_LIBPSL) find_package(Libpsl REQUIRED) - list(APPEND CURL_LIBS ${LIBPSL_LIBRARIES}) - list(APPEND CURL_LIBDIRS ${LIBPSL_LIBRARY_DIRS}) - list(APPEND LIBCURL_PC_REQUIRES_PRIVATE ${LIBPSL_PC_REQUIRES}) - include_directories(SYSTEM ${LIBPSL_INCLUDE_DIRS}) - link_directories(${LIBPSL_LIBRARY_DIRS}) - if(LIBPSL_CFLAGS) - string(APPEND CMAKE_C_FLAGS " ${LIBPSL_CFLAGS}") - endif() + list(APPEND CURL_LIBS CURL::libpsl) set(USE_LIBPSL ON) endif() @@ -1347,18 +1219,10 @@ endif() option(CURL_USE_LIBSSH2 "Use libssh2" ON) mark_as_advanced(CURL_USE_LIBSSH2) set(USE_LIBSSH2 OFF) - if(CURL_USE_LIBSSH2) find_package(Libssh2) if(LIBSSH2_FOUND) - set(CURL_LIBS ${LIBSSH2_LIBRARIES} ${CURL_LIBS}) # keep it before TLS-crypto, compression - list(APPEND CURL_LIBDIRS ${LIBSSH2_LIBRARY_DIRS}) - set(LIBCURL_PC_REQUIRES_PRIVATE ${LIBSSH2_PC_REQUIRES} ${LIBCURL_PC_REQUIRES_PRIVATE}) - include_directories(SYSTEM ${LIBSSH2_INCLUDE_DIRS}) - link_directories(${LIBSSH2_LIBRARY_DIRS}) - if(LIBSSH2_CFLAGS) - string(APPEND CMAKE_C_FLAGS " ${LIBSSH2_CFLAGS}") - endif() + set(CURL_LIBS CURL::libssh2 ${CURL_LIBS}) # keep it before TLS-crypto, compression set(USE_LIBSSH2 ON) endif() endif() @@ -1368,14 +1232,7 @@ option(CURL_USE_LIBSSH "Use libssh" OFF) mark_as_advanced(CURL_USE_LIBSSH) if(NOT USE_LIBSSH2 AND CURL_USE_LIBSSH) find_package(Libssh REQUIRED) - set(CURL_LIBS ${LIBSSH_LIBRARIES} ${CURL_LIBS}) # keep it before TLS-crypto, compression - list(APPEND CURL_LIBDIRS ${LIBSSH_LIBRARY_DIRS}) - set(LIBCURL_PC_REQUIRES_PRIVATE ${LIBSSH_PC_REQUIRES} ${LIBCURL_PC_REQUIRES_PRIVATE}) - include_directories(SYSTEM ${LIBSSH_INCLUDE_DIRS}) - link_directories(${LIBSSH_LIBRARY_DIRS}) - if(LIBSSH_CFLAGS) - string(APPEND CMAKE_C_FLAGS " ${LIBSSH_CFLAGS}") - endif() + set(CURL_LIBS CURL::libssh ${CURL_LIBS}) # keep it before TLS-crypto, compression set(USE_LIBSSH ON) endif() @@ -1383,14 +1240,7 @@ option(CURL_USE_GSASL "Use libgsasl" OFF) mark_as_advanced(CURL_USE_GSASL) if(CURL_USE_GSASL) find_package(Libgsasl REQUIRED) - list(APPEND CURL_LIBS ${LIBGSASL_LIBRARIES}) - list(APPEND CURL_LIBDIRS ${LIBGSASL_LIBRARY_DIRS}) - list(APPEND LIBCURL_PC_REQUIRES_PRIVATE ${LIBGSASL_PC_REQUIRES}) - include_directories(SYSTEM ${LIBGSASL_INCLUDE_DIRS}) - link_directories(${LIBGSASL_LIBRARY_DIRS}) - if(LIBGSASL_CFLAGS) - string(APPEND CMAKE_C_FLAGS " ${LIBGSASL_CFLAGS}") - endif() + list(APPEND CURL_LIBS CURL::libgsasl) set(USE_GSASL ON) endif() @@ -1402,16 +1252,10 @@ if(CURL_USE_GSSAPI) set(HAVE_GSSAPI ${GSS_FOUND}) if(GSS_FOUND) - list(APPEND CURL_LIBS ${GSS_LIBRARIES}) - list(APPEND CURL_LIBDIRS ${GSS_LIBRARY_DIRS}) - list(APPEND LIBCURL_PC_REQUIRES_PRIVATE ${GSS_PC_REQUIRES}) - include_directories(SYSTEM ${GSS_INCLUDE_DIRS}) - link_directories(${GSS_LIBRARY_DIRS}) - if(GSS_CFLAGS) - string(APPEND CMAKE_C_FLAGS " ${GSS_CFLAGS}") - endif() + list(APPEND CURL_LIBS CURL::gss) - if(GSS_FLAVOUR STREQUAL "GNU") + get_target_property(_gss_flavour CURL::gss INTERFACE_CURL_GSS_FLAVOUR) + if(_gss_flavour STREQUAL "GNU") set(HAVE_GSSGNU 1) elseif(GSS_VERSION) # MIT set(CURL_KRB5_VERSION "\"${GSS_VERSION}\"") @@ -1431,8 +1275,7 @@ if(CURL_USE_LIBBACKTRACE) message(FATAL_ERROR "libbacktrace requires debug information") endif() find_package(Libbacktrace REQUIRED) - list(APPEND CURL_LIBS ${LIBBACKTRACE_LIBRARIES}) - include_directories(SYSTEM ${LIBBACKTRACE_INCLUDE_DIRS}) + list(APPEND CURL_LIBS CURL::libbacktrace) set(USE_BACKTRACE ON) endif() @@ -1443,14 +1286,7 @@ if(CURL_USE_LIBUV) message(FATAL_ERROR "Using libuv without debug support enabled is useless") endif() find_package(Libuv REQUIRED) - list(APPEND CURL_LIBS ${LIBUV_LIBRARIES}) - list(APPEND CURL_LIBDIRS ${LIBUV_LIBRARY_DIRS}) - list(APPEND LIBCURL_PC_REQUIRES_PRIVATE ${LIBUV_PC_REQUIRES}) - include_directories(SYSTEM ${LIBUV_INCLUDE_DIRS}) - link_directories(${LIBUV_LIBRARY_DIRS}) - if(LIBUV_CFLAGS) - string(APPEND CMAKE_C_FLAGS " ${LIBUV_CFLAGS}") - endif() + list(APPEND CURL_LIBS CURL::libuv) set(USE_LIBUV ON) set(HAVE_UV_H ON) endif() @@ -1458,14 +1294,7 @@ endif() option(USE_LIBRTMP "Enable librtmp from rtmpdump" OFF) if(USE_LIBRTMP) find_package(Librtmp REQUIRED) - list(APPEND CURL_LIBS ${LIBRTMP_LIBRARIES}) - list(APPEND CURL_LIBDIRS ${LIBRTMP_LIBRARY_DIRS}) - list(APPEND LIBCURL_PC_REQUIRES_PRIVATE ${LIBRTMP_PC_REQUIRES}) - include_directories(SYSTEM ${LIBRTMP_INCLUDE_DIRS}) - link_directories(${LIBRTMP_LIBRARY_DIRS}) - if(LIBRTMP_CFLAGS) - string(APPEND CMAKE_C_FLAGS " ${LIBRTMP_CFLAGS}") - endif() + list(APPEND CURL_LIBS CURL::librtmp) endif() option(ENABLE_UNIX_SOCKETS "Enable Unix domain sockets support" ON) @@ -1964,6 +1793,28 @@ if(CURL_CODE_COVERAGE) list(APPEND CURL_LIBS ${CURL_COVERAGE_LIBS}) endif() +# Hack to add some libraries to the end of the library list to make binutils ld +# for GCC find symbols when linking statically. Necessary for libs detected via +# CMake's built-in find modules, which CMake adds to the beginning of the lib +# list on the linker command-line for some reason. This makes them appear +# before dependencies detected via curl's custom Find modules, and breaks +# linkers sensitive to lib order. There must be a better solution to this. +if(CMAKE_C_COMPILER_ID STREQUAL "GNU") + foreach(_lib IN ITEMS OpenSSL::Crypto ZLIB::ZLIB) + if(TARGET "${_lib}") + add_library(CURL::${_lib} INTERFACE IMPORTED) + get_target_property(_libname "${_lib}" LOCATION) + set_target_properties(${_lib} PROPERTIES INTERFACE_LINK_LIBRARIES "${_libname}") + list(APPEND CURL_LIBS ${_lib}) + endif() + endforeach() + if(WIN32) + add_library(CURL::win32_winsock INTERFACE IMPORTED) + set_target_properties(CURL::win32_winsock PROPERTIES INTERFACE_LINK_LIBRARIES "ws2_32") + list(APPEND CURL_LIBS CURL::win32_winsock) + endif() +endif() + if(CMAKE_C_COMPILER_ID STREQUAL "MSVC") # MSVC but exclude clang-cl set_property(DIRECTORY APPEND PROPERTY COMPILE_OPTIONS "-MP") # Parallel compilation endif() @@ -2028,8 +1879,6 @@ endif() add_subdirectory(scripts) # for shell completions -list(REMOVE_DUPLICATES CURL_LIBDIRS) - add_subdirectory(lib) if(BUILD_CURL_EXE) @@ -2252,67 +2101,104 @@ if(NOT CURL_DISABLE_INSTALL) endif() endforeach() - foreach(_libdir IN LISTS _custom_libdirs CURL_LIBDIRS) - if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.20) - cmake_path(SET _libdir NORMALIZE "${_libdir}") - endif() - list(FIND _sys_libdirs "${_libdir}" _libdir_index) - if(_libdir_index LESS 0) - list(APPEND _ldflags "-L${_libdir}") - endif() - endforeach() - set(_implicit_libs "") if(NOT MINGW AND NOT UNIX) set(_implicit_libs "${CMAKE_C_IMPLICIT_LINK_LIBRARIES}") endif() - foreach(_lib IN LISTS _implicit_libs _custom_libs CURL_LIBS) + set(_explicit_libdirs "") + set(LIBCURL_PC_REQUIRES_PRIVATE "") + set(LIBCURL_PC_LIBS_PRIVATE_LIST "") + foreach(_lib IN LISTS CURL_LIBS _custom_libs _implicit_libs) if(TARGET "${_lib}") - set(_libname "${_lib}") - get_target_property(_imported "${_libname}" IMPORTED) + set(_explicit_libs "") + get_target_property(_imported "${_lib}" IMPORTED) if(NOT _imported) # Reading the LOCATION property on non-imported target will error out. # Assume the user will not need this information in the .pc file. continue() endif() - get_target_property(_lib "${_libname}" LOCATION) - if(NOT _lib) - message(WARNING "Bad lib in library list: ${_libname}") - continue() - endif() - endif() - if(_lib MATCHES "^-") # '-framework ' - list(APPEND _ldflags "${_lib}") - elseif(_lib MATCHES "/") - # This gets a bit more complex, because we want to specify the - # directory separately, and only once per directory - if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.20) - cmake_path(GET _lib PARENT_PATH _libdir) - cmake_path(GET _lib STEM _libname) + if(_lib MATCHES "CURL::") + # This is empty for 'CURL::*' targets and safe to ignore. + # Explicitly skip this query to avoid CMake v3.18 and older erroring out. + set(_libname "") else() - get_filename_component(_libdir "${_lib}" DIRECTORY) - get_filename_component(_libname "${_lib}" NAME_WE) + get_target_property(_libname "${_lib}" LOCATION) endif() - if(_libname MATCHES "^lib") - if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.20) - cmake_path(SET _libdir NORMALIZE "${_libdir}") + if(_libname) + list(APPEND _explicit_libs "${_libname}") + else() + get_target_property(_libs "${_lib}" INTERFACE_LINK_LIBRARIES) + if(_libs) + list(APPEND _explicit_libs "${_libs}") endif() - list(FIND _sys_libdirs "${_libdir}" _libdir_index) - if(_libdir_index LESS 0) - list(APPEND _ldflags "-L${_libdir}") + get_target_property(_libdirs "${_lib}" INTERFACE_LINK_DIRECTORIES) + if(_libdirs) + list(APPEND _explicit_libdirs "${_libdirs}") endif() - string(REGEX REPLACE "^lib" "" _libname "${_libname}") - list(APPEND LIBCURL_PC_LIBS_PRIVATE "-l${_libname}") - else() - list(APPEND LIBCURL_PC_LIBS_PRIVATE "${_lib}") endif() + if(NOT _libname AND NOT _libs AND NOT _libdirs) + message(WARNING "Bad lib in library list: ${_lib}") + endif() + get_target_property(_modules "${_lib}" INTERFACE_LIBCURL_PC_MODULES) + if(_modules) + list(APPEND LIBCURL_PC_REQUIRES_PRIVATE "${_modules}") + endif() + + foreach(_lib IN LISTS _explicit_libs) + if(_lib MATCHES "/") + # This gets a bit more complex, because we want to specify the + # directory separately, and only once per directory + if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.20) + cmake_path(GET _lib PARENT_PATH _libdir) + cmake_path(GET _lib STEM _libname) + else() + get_filename_component(_libdir "${_lib}" DIRECTORY) + get_filename_component(_libname "${_lib}" NAME_WE) + endif() + if(_libname MATCHES "^lib") + if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.20) + cmake_path(SET _libdir NORMALIZE "${_libdir}") + endif() + list(FIND _sys_libdirs "${_libdir}" _libdir_index) + if(_libdir_index LESS 0) + list(APPEND _ldflags "-L${_libdir}") + endif() + string(REGEX REPLACE "^lib" "" _libname "${_libname}") + list(APPEND LIBCURL_PC_LIBS_PRIVATE "-l${_libname}") + list(APPEND LIBCURL_PC_LIBS_PRIVATE_LIST "${_lib}") + else() + list(APPEND LIBCURL_PC_LIBS_PRIVATE "${_lib}") + list(APPEND LIBCURL_PC_LIBS_PRIVATE_LIST "${_lib}") + endif() + else() + list(APPEND LIBCURL_PC_LIBS_PRIVATE "-l${_lib}") + list(APPEND LIBCURL_PC_LIBS_PRIVATE_LIST "${_lib}") + endif() + endforeach() + elseif(_lib MATCHES "^-") # '-framework ' + list(APPEND _ldflags "${_lib}") + list(APPEND LIBCURL_PC_LIBS_PRIVATE_LIST "${_lib}") else() list(APPEND LIBCURL_PC_LIBS_PRIVATE "-l${_lib}") + list(APPEND LIBCURL_PC_LIBS_PRIVATE_LIST "${_lib}") endif() endforeach() + foreach(_libdir IN LISTS _custom_libdirs _explicit_libdirs) + if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.20) + cmake_path(SET _libdir NORMALIZE "${_libdir}") + endif() + list(FIND _sys_libdirs "${_libdir}" _libdir_index) + if(_libdir_index LESS 0) + list(APPEND _ldflags "-L${_libdir}") + endif() + endforeach() + + list(REMOVE_DUPLICATES _ldflags) + if(LIBCURL_PC_REQUIRES_PRIVATE) + list(REMOVE_DUPLICATES LIBCURL_PC_REQUIRES_PRIVATE) string(REPLACE ";" "," LIBCURL_PC_REQUIRES_PRIVATE "${LIBCURL_PC_REQUIRES_PRIVATE}") endif() if(LIBCURL_PC_LIBS_PRIVATE) @@ -2424,13 +2310,37 @@ if(NOT CURL_DISABLE_INSTALL) # Consumed custom variables: # CURLVERSION + # LIBCURL_PC_LIBS_PRIVATE_LIST # LIB_NAME # LIB_SELECTED + # LIB_STATIC # TARGETS_EXPORT_NAME - # USE_OPENSSL OPENSSL_VERSION_MAJOR - # HAVE_LIBZ ZLIB_VERSION_MAJOR # CURL_SUPPORTED_FEATURES_LIST # CURL_SUPPORTED_PROTOCOLS_LIST + # HAVE_BROTLI + # HAVE_GSSAPI + # HAVE_LIBIDN2 + # HAVE_LIBZ ZLIB_VERSION_MAJOR + # HAVE_ZSTD + # USE_ARES + # USE_BACKTRACE + # USE_GNUTLS + # USE_GSASL + # USE_LIBPSL + # USE_LIBRTMP + # USE_LIBSSH + # USE_LIBSSH2 + # USE_LIBUV + # USE_MBEDTLS + # USE_NGHTTP2 + # USE_NGHTTP3 + # USE_NGTCP2 + # USE_OPENSSL OPENSSL_VERSION_MAJOR + # USE_QUICHE + # USE_RUSTLS + # USE_WIN32_LDAP CURL_DISABLE_LDAP + # USE_WOLFSSL + # _win32_winsock configure_package_config_file("CMake/curl-config.cmake.in" "${_project_config}" INSTALL_DESTINATION ${_install_cmake_dir} @@ -2442,7 +2352,32 @@ if(NOT CURL_DISABLE_INSTALL) DESTINATION ${_install_cmake_dir}) endif() - install(FILES ${_version_config} ${_project_config} + install( + FILES + ${_version_config} + ${_project_config} + "${CMAKE_CURRENT_SOURCE_DIR}/CMake/FindBrotli.cmake" + "${CMAKE_CURRENT_SOURCE_DIR}/CMake/FindCares.cmake" + "${CMAKE_CURRENT_SOURCE_DIR}/CMake/FindGSS.cmake" + "${CMAKE_CURRENT_SOURCE_DIR}/CMake/FindGnuTLS.cmake" + "${CMAKE_CURRENT_SOURCE_DIR}/CMake/FindLDAP.cmake" + "${CMAKE_CURRENT_SOURCE_DIR}/CMake/FindLibbacktrace.cmake" + "${CMAKE_CURRENT_SOURCE_DIR}/CMake/FindLibgsasl.cmake" + "${CMAKE_CURRENT_SOURCE_DIR}/CMake/FindLibidn2.cmake" + "${CMAKE_CURRENT_SOURCE_DIR}/CMake/FindLibpsl.cmake" + "${CMAKE_CURRENT_SOURCE_DIR}/CMake/FindLibrtmp.cmake" + "${CMAKE_CURRENT_SOURCE_DIR}/CMake/FindLibssh.cmake" + "${CMAKE_CURRENT_SOURCE_DIR}/CMake/FindLibssh2.cmake" + "${CMAKE_CURRENT_SOURCE_DIR}/CMake/FindLibuv.cmake" + "${CMAKE_CURRENT_SOURCE_DIR}/CMake/FindMbedTLS.cmake" + "${CMAKE_CURRENT_SOURCE_DIR}/CMake/FindNGHTTP2.cmake" + "${CMAKE_CURRENT_SOURCE_DIR}/CMake/FindNGHTTP3.cmake" + "${CMAKE_CURRENT_SOURCE_DIR}/CMake/FindNGTCP2.cmake" + "${CMAKE_CURRENT_SOURCE_DIR}/CMake/FindNettle.cmake" + "${CMAKE_CURRENT_SOURCE_DIR}/CMake/FindQuiche.cmake" + "${CMAKE_CURRENT_SOURCE_DIR}/CMake/FindRustls.cmake" + "${CMAKE_CURRENT_SOURCE_DIR}/CMake/FindWolfSSL.cmake" + "${CMAKE_CURRENT_SOURCE_DIR}/CMake/FindZstd.cmake" DESTINATION ${_install_cmake_dir}) if(NOT TARGET curl_uninstall) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index b468eec0a2e4..5ce288a0a897 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -44,7 +44,7 @@ if(CURL_BUILD_TESTING) # special libcurlu library just for unittests add_library(curlu STATIC EXCLUDE_FROM_ALL ${HHEADERS} ${CSOURCES}) target_compile_definitions(curlu PUBLIC "CURL_STATICLIB" "UNITTESTS") - target_link_libraries(curlu PRIVATE ${CURL_LIBS}) + target_link_libraries(curlu PUBLIC ${CURL_LIBS}) # There is plenty of parallelism when building the testdeps target. # Override the curlu batch size with the maximum to optimize performance. set_target_properties(curlu PROPERTIES UNITY_BUILD_BATCH_SIZE 0 C_CLANG_TIDY "") @@ -151,8 +151,7 @@ if(BUILD_STATIC_LIBS) set_target_properties(${LIB_STATIC} PROPERTIES PREFIX "" OUTPUT_NAME "${LIBCURL_OUTPUT_NAME}" SUFFIX "${STATIC_LIB_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}" - INTERFACE_COMPILE_DEFINITIONS "CURL_STATICLIB" - INTERFACE_LINK_DIRECTORIES "${CURL_LIBDIRS}") + INTERFACE_COMPILE_DEFINITIONS "CURL_STATICLIB") if(CURL_HIDES_PRIVATE_SYMBOLS) set_property(TARGET ${LIB_STATIC} APPEND PROPERTY COMPILE_OPTIONS "${CURL_CFLAG_SYMBOLS_HIDE}") set_property(TARGET ${LIB_STATIC} APPEND PROPERTY COMPILE_DEFINITIONS "CURL_HIDDEN_SYMBOLS") @@ -174,6 +173,27 @@ if(BUILD_STATIC_LIBS) target_include_directories(${LIB_STATIC} INTERFACE "$" "$") + + # CMake before CMP0099 (CMake 3.17 2020-03-20) did not propagate libdirs to + # targets. It expected libs to have an absolute filename. As a workaround, + # manually apply dependency libdirs, for CMake consumers without this policy. + if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.17) + cmake_policy(GET CMP0099 _has_CMP0099) # https://cmake.org/cmake/help/latest/policy/CMP0099.html + endif() + if(NOT _has_CMP0099 AND CMAKE_VERSION VERSION_GREATER_EQUAL 3.13 AND CURL_LIBS) + set(_libdirs "") + foreach(_lib IN LISTS CURL_LIBS) + if(TARGET "${_lib}") + get_target_property(_libdir "${_lib}" INTERFACE_LINK_DIRECTORIES) + if(_libdir) + list(APPEND _libdirs "${_libdir}") + endif() + endif() + endforeach() + if(_libdirs) + target_link_directories(${LIB_STATIC} INTERFACE ${_libdirs}) + endif() + endif() endif() if(BUILD_SHARED_LIBS) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 33f288b91591..7d28434bd38e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -109,12 +109,13 @@ target_link_libraries(${EXE_NAME} ${LIB_SELECTED_FOR_EXE} ${CURL_LIBS}) add_executable(${PROJECT_NAME}::${EXE_NAME} ALIAS ${EXE_NAME}) add_executable(curlinfo EXCLUDE_FROM_ALL "curlinfo.c") +target_link_libraries(curlinfo PRIVATE ${CURL_LIBS}) set_target_properties(curlinfo PROPERTIES UNITY_BUILD OFF) # special libcurltool library just for unittests add_library(curltool STATIC EXCLUDE_FROM_ALL ${CURL_CFILES} ${CURL_HFILES} ${_curlx_cfiles_lib} ${_curlx_hfiles_lib}) target_compile_definitions(curltool PUBLIC "CURL_STATICLIB" "UNITTESTS") -target_link_libraries(curltool PRIVATE ${CURL_LIBS}) +target_link_libraries(curltool PUBLIC ${CURL_LIBS}) set_target_properties(curltool PROPERTIES C_CLANG_TIDY "") if(CURL_HAS_LTO) diff --git a/tests/cmake/test.sh b/tests/cmake/test.sh index 451235484ef6..a871372ab644 100755 --- a/tests/cmake/test.sh +++ b/tests/cmake/test.sh @@ -114,7 +114,7 @@ if [ "${mode}" = 'all' ] || [ "${mode}" = 'find_package' ]; then "${cmake_provider}" --install "${bldp}" else mkdir "${bldp}"; cd "${bldp}" - "${cmake_provider}" "${src}" -G "${gen}" ${cmake_opts} -DCURL_USE_PKGCONFIG=OFF ${TEST_CMAKE_FLAGS:-} "$@" \ + "${cmake_provider}" "${src}" -G "${gen}" ${cmake_opts} ${TEST_CMAKE_FLAGS:-} "$@" \ -DBUILD_SHARED_LIBS=ON \ -DBUILD_STATIC_LIBS=ON \ -DCMAKE_INSTALL_PREFIX="${prefix}" From ed331cea80c607344a19b400ab9abf25af09dc36 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Sat, 29 Nov 2025 14:17:04 +0100 Subject: [PATCH 118/415] cmake: save and restore `CMAKE_MODULE_PATH` in `curl-config.cmake` Reported-by: Kai Pastor Bug: https://github.com/curl/curl/pull/16973#discussion_r2572957270 Follow-up to 16f073ef49f94412000218c9f6ad04e3fd7e4d01 #16973 Closes #19758 --- CMake/curl-config.cmake.in | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CMake/curl-config.cmake.in b/CMake/curl-config.cmake.in index 99949198a305..c4e9f59e863b 100644 --- a/CMake/curl-config.cmake.in +++ b/CMake/curl-config.cmake.in @@ -26,6 +26,8 @@ option(CURL_USE_PKGCONFIG "Enable pkg-config to detect @PROJECT_NAME@ dependencies. Default: @CURL_USE_PKGCONFIG@" "@CURL_USE_PKGCONFIG@") include(CMakeFindDependencyMacro) + +set(_curl_cmake_module_path_save ${CMAKE_MODULE_PATH}) set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR} ${CMAKE_MODULE_PATH}) set(_libs "") @@ -126,6 +128,8 @@ if("@HAVE_ZSTD@") list(APPEND _libs CURL::zstd) endif() +set(CMAKE_MODULE_PATH ${_curl_cmake_module_path_save}) + if(CMAKE_C_COMPILER_ID STREQUAL "GNU" AND WIN32 AND NOT TARGET CURL::win32_winsock) add_library(CURL::win32_winsock INTERFACE IMPORTED) set_target_properties(CURL::win32_winsock PROPERTIES INTERFACE_LINK_LIBRARIES "@_win32_winsock@") From 545f2f387d41b4a356705a08c1154c807f4dbb7d Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Sat, 29 Nov 2025 16:07:59 +0100 Subject: [PATCH 119/415] lib/sendf.h: forward declare two structs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To fix non-unity builds using certain header orders (seen in ntlm.c with the include order changed): ``` lib/vauth/../sendf.h:117:27: error: ‘struct Curl_cwriter’ declared inside parameter list will not be visible outside of this definition or declaration [-Werror] 117 | struct Curl_cwriter *writer); | ^~~~~~~~~~~~ lib/vauth/../sendf.h:215:54: error: ‘struct Curl_creader’ declared inside parameter list will not be visible outside of this definition or declaration [-Werror] 215 | CURLcode (*do_init)(struct Curl_easy *data, struct Curl_creader *reader); | ^~~~~~~~~~~~ [...] ``` Ref: https://github.com/curl/curl/actions/runs/19785420705/job/56691185397?pr=19760 Ref: #19760 Closes #19761 --- lib/sendf.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/sendf.h b/lib/sendf.h index 686744390102..3a6dccba6a3d 100644 --- a/lib/sendf.h +++ b/lib/sendf.h @@ -52,6 +52,10 @@ #define CLIENTWRITE_EOS (1<<7) /* End Of transfer download Stream */ #define CLIENTWRITE_0LEN (1<<8) /* write even 0-length buffers */ +/* Forward declarations */ +struct Curl_creader; +struct Curl_cwriter; + /** * Write `len` bytes at `prt` to the client. `type` indicates what * kind of data is being written. From db32c0721f9cfbefe6a42b828ef7bfc4b40f71ac Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 28 Nov 2025 23:59:23 +0100 Subject: [PATCH 120/415] rustls: verify that verifier_builder is not NULL Since this function returns allocated resources there is probably at least a theoretical risk this can return NULL. Pointed out by ZeroPath Closes #19756 --- lib/vtls/rustls.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/vtls/rustls.c b/lib/vtls/rustls.c index e4251a915198..0c13cc81eebb 100644 --- a/lib/vtls/rustls.c +++ b/lib/vtls/rustls.c @@ -750,6 +750,10 @@ init_config_builder_verifier(struct Curl_easy *data, } verifier_builder = rustls_web_pki_server_cert_verifier_builder_new(roots); + if(!verifier_builder) { + result = CURLE_OUT_OF_MEMORY; + goto cleanup; + } if(conn_config->CRLfile) { result = init_config_builder_verifier_crl(data, From 985f86f0be42a69bae91e9209016e5f7fe3346da Mon Sep 17 00:00:00 2001 From: Daniel McCarney Date: Sat, 29 Nov 2025 09:30:48 -0500 Subject: [PATCH 121/415] rustls: simplify init err path Closes #19759 --- lib/vtls/rustls.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/vtls/rustls.c b/lib/vtls/rustls.c index 0c13cc81eebb..360a2454ac85 100644 --- a/lib/vtls/rustls.c +++ b/lib/vtls/rustls.c @@ -744,9 +744,7 @@ init_config_builder_verifier(struct Curl_easy *data, if(rr != RUSTLS_RESULT_OK) { rustls_failf(data, rr, "failed to build trusted root certificate store"); result = CURLE_SSL_CACERT_BADFILE; - if(result) { - goto cleanup; - } + goto cleanup; } verifier_builder = rustls_web_pki_server_cert_verifier_builder_new(roots); From c3add7130d7d81add205edbbb75fdfd1f38b3c68 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Sat, 29 Nov 2025 19:51:45 +0100 Subject: [PATCH 122/415] mbedtls: replace macro constant with `CURL_ARRAYSIZE()` Also move from `int` to `size_t` for index variables. Closes #19762 --- lib/vtls/mbedtls_threadlock.c | 23 ++++++++++------------- lib/vtls/mbedtls_threadlock.h | 4 ++-- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/lib/vtls/mbedtls_threadlock.c b/lib/vtls/mbedtls_threadlock.c index 91de9eceb59b..89cc2b7d38df 100644 --- a/lib/vtls/mbedtls_threadlock.c +++ b/lib/vtls/mbedtls_threadlock.c @@ -37,17 +37,14 @@ #include "mbedtls_threadlock.h" -/* number of thread locks */ -#define NUMT 2 - -/* This array stores the mutexes available to Mbedtls */ -static MBEDTLS_MUTEX_T mutex_buf[NUMT]; +/* This array stores the mutexes available to mbedTLS */ +static MBEDTLS_MUTEX_T mutex_buf[2]; int Curl_mbedtlsthreadlock_thread_setup(void) { - int i; + size_t i; - for(i = 0; i < NUMT; i++) { + for(i = 0; i < CURL_ARRAYSIZE(mutex_buf); i++) { #if defined(USE_THREADS_POSIX) && defined(HAVE_PTHREAD_H) if(pthread_mutex_init(&mutex_buf[i], NULL)) return 0; /* pthread_mutex_init failed */ @@ -63,9 +60,9 @@ int Curl_mbedtlsthreadlock_thread_setup(void) int Curl_mbedtlsthreadlock_thread_cleanup(void) { - int i; + size_t i; - for(i = 0; i < NUMT; i++) { + for(i = 0; i < CURL_ARRAYSIZE(mutex_buf); i++) { #if defined(USE_THREADS_POSIX) && defined(HAVE_PTHREAD_H) if(pthread_mutex_destroy(&mutex_buf[i])) return 0; /* pthread_mutex_destroy failed */ @@ -78,9 +75,9 @@ int Curl_mbedtlsthreadlock_thread_cleanup(void) return 1; /* OK */ } -int Curl_mbedtlsthreadlock_lock_function(int n) +int Curl_mbedtlsthreadlock_lock_function(size_t n) { - if(n < NUMT) { + if(n < CURL_ARRAYSIZE(mutex_buf)) { #if defined(USE_THREADS_POSIX) && defined(HAVE_PTHREAD_H) if(pthread_mutex_lock(&mutex_buf[n])) { DEBUGF(curl_mfprintf(stderr, "Error: " @@ -98,9 +95,9 @@ int Curl_mbedtlsthreadlock_lock_function(int n) return 1; /* OK */ } -int Curl_mbedtlsthreadlock_unlock_function(int n) +int Curl_mbedtlsthreadlock_unlock_function(size_t n) { - if(n < NUMT) { + if(n < CURL_ARRAYSIZE(mutex_buf)) { #if defined(USE_THREADS_POSIX) && defined(HAVE_PTHREAD_H) if(pthread_mutex_unlock(&mutex_buf[n])) { DEBUGF(curl_mfprintf(stderr, "Error: " diff --git a/lib/vtls/mbedtls_threadlock.h b/lib/vtls/mbedtls_threadlock.h index 9402af6e415a..1855d4cc0187 100644 --- a/lib/vtls/mbedtls_threadlock.h +++ b/lib/vtls/mbedtls_threadlock.h @@ -33,8 +33,8 @@ int Curl_mbedtlsthreadlock_thread_setup(void); int Curl_mbedtlsthreadlock_thread_cleanup(void); -int Curl_mbedtlsthreadlock_lock_function(int n); -int Curl_mbedtlsthreadlock_unlock_function(int n); +int Curl_mbedtlsthreadlock_lock_function(size_t n); +int Curl_mbedtlsthreadlock_unlock_function(size_t n); #else From 0eed8b73309fbfb113002f4da8a6d92acff4871f Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sat, 29 Nov 2025 23:44:23 +0100 Subject: [PATCH 123/415] tool_operatate: return error for OOM in append2query Closes #19763 --- src/tool_operate.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/tool_operate.c b/src/tool_operate.c index 968dc864f9f6..71d29af8d8b0 100644 --- a/src/tool_operate.c +++ b/src/tool_operate.c @@ -848,6 +848,8 @@ static CURLcode append2query(struct OperationConfig *config, } curl_url_cleanup(uh); } + else + result = CURLE_OUT_OF_MEMORY; return result; } From 2253bc330f56315faaa287c29d7612f5a34d8058 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Sat, 29 Nov 2025 02:16:52 +0100 Subject: [PATCH 124/415] lib/subdirs: fix formatting nits Closes #19757 --- lib/curlx/base64.c | 20 +- lib/curlx/dynbuf.c | 1 - lib/curlx/dynbuf.h | 22 +-- lib/curlx/fopen.h | 11 +- lib/curlx/inet_ntop.c | 11 +- lib/curlx/inet_ntop.h | 4 +- lib/curlx/inet_pton.c | 23 +-- lib/curlx/inet_pton.h | 6 +- lib/curlx/nonblock.c | 2 +- lib/curlx/strerr.c | 3 +- lib/curlx/strparse.c | 8 +- lib/curlx/timediff.c | 2 +- lib/curlx/timeval.c | 34 ++-- lib/curlx/wait.c | 2 +- lib/curlx/warnless.c | 121 ++++++------ lib/curlx/warnless.h | 2 +- lib/curlx/winapi.c | 5 +- lib/vauth/cleartext.c | 7 +- lib/vauth/cram.c | 2 +- lib/vauth/digest.c | 76 ++++---- lib/vauth/digest_sspi.c | 16 +- lib/vauth/gsasl.c | 2 +- lib/vauth/krb5_gssapi.c | 2 +- lib/vauth/krb5_sspi.c | 3 +- lib/vauth/ntlm.c | 5 +- lib/vauth/ntlm_sspi.c | 13 +- lib/vauth/oauth2.c | 2 +- lib/vauth/spnego_sspi.c | 14 +- lib/vauth/vauth.c | 16 +- lib/vquic/curl_ngtcp2.c | 128 +++++++------ lib/vquic/curl_osslq.c | 99 +++++----- lib/vquic/curl_quiche.c | 31 ++- lib/vquic/vquic-tls.c | 7 +- lib/vquic/vquic-tls.h | 16 +- lib/vquic/vquic.c | 9 +- lib/vquic/vquic_int.h | 25 ++- lib/vssh/libssh.c | 333 ++++++++++++++++---------------- lib/vssh/libssh2.c | 347 ++++++++++++++++------------------ lib/vssh/ssh.h | 6 +- lib/vssh/vssh.c | 3 +- lib/vtls/apple.c | 5 +- lib/vtls/cipher_suite.c | 42 ++-- lib/vtls/gtls.c | 84 ++++---- lib/vtls/gtls.h | 3 +- lib/vtls/hostcheck.c | 4 +- lib/vtls/keylog.c | 19 +- lib/vtls/mbedtls.c | 73 ++++--- lib/vtls/mbedtls_threadlock.c | 5 +- lib/vtls/mbedtls_threadlock.h | 3 +- lib/vtls/openssl.c | 148 ++++++--------- lib/vtls/openssl.h | 3 +- lib/vtls/rustls.c | 176 ++++++++--------- lib/vtls/schannel.c | 160 +++++++--------- lib/vtls/schannel.h | 9 +- lib/vtls/schannel_verify.c | 51 ++--- lib/vtls/vtls.c | 53 +++--- lib/vtls/vtls.h | 12 +- lib/vtls/vtls_int.h | 20 +- lib/vtls/vtls_scache.c | 54 +++--- lib/vtls/vtls_scache.h | 26 ++- lib/vtls/vtls_spack.c | 31 ++- lib/vtls/wolfssl.c | 113 +++++------ lib/vtls/wolfssl.h | 9 +- lib/vtls/x509asn1.c | 54 +++--- 64 files changed, 1199 insertions(+), 1397 deletions(-) diff --git a/lib/curlx/base64.c b/lib/curlx/base64.c index 6a24c20ebdfb..4fc525387e5f 100644 --- a/lib/curlx/base64.c +++ b/lib/curlx/base64.c @@ -31,12 +31,12 @@ #include "base64.h" /* ---- Base64 Encoding/Decoding Table --- */ -const char Curl_base64encdec[]= +const char Curl_base64encdec[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; /* The Base 64 encoding with a URL and filename safe alphabet, RFC 4648 section 5 */ -static const char base64url[]= +static const char base64url[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"; static const unsigned char decodetable[] = @@ -188,18 +188,18 @@ static CURLcode base64_encode(const char *table64, return CURLE_OUT_OF_MEMORY; while(insize >= 3) { - *output++ = table64[ in[0] >> 2 ]; - *output++ = table64[ ((in[0] & 0x03) << 4) | (in[1] >> 4) ]; - *output++ = table64[ ((in[1] & 0x0F) << 2) | ((in[2] & 0xC0) >> 6) ]; - *output++ = table64[ in[2] & 0x3F ]; + *output++ = table64[in[0] >> 2]; + *output++ = table64[((in[0] & 0x03) << 4) | (in[1] >> 4)]; + *output++ = table64[((in[1] & 0x0F) << 2) | ((in[2] & 0xC0) >> 6)]; + *output++ = table64[in[2] & 0x3F]; insize -= 3; in += 3; } if(insize) { /* this is only one or two bytes now */ - *output++ = table64[ in[0] >> 2 ]; + *output++ = table64[in[0] >> 2]; if(insize == 1) { - *output++ = table64[ ((in[0] & 0x03) << 4) ]; + *output++ = table64[((in[0] & 0x03) << 4)]; if(padbyte) { *output++ = padbyte; *output++ = padbyte; @@ -207,8 +207,8 @@ static CURLcode base64_encode(const char *table64, } else { /* insize == 2 */ - *output++ = table64[ ((in[0] & 0x03) << 4) | ((in[1] & 0xF0) >> 4) ]; - *output++ = table64[ ((in[1] & 0x0F) << 2) ]; + *output++ = table64[((in[0] & 0x03) << 4) | ((in[1] & 0xF0) >> 4)]; + *output++ = table64[((in[1] & 0x0F) << 2)]; if(padbyte) *output++ = padbyte; } diff --git a/lib/curlx/dynbuf.c b/lib/curlx/dynbuf.c index e54865f933c7..a9ff48367f62 100644 --- a/lib/curlx/dynbuf.c +++ b/lib/curlx/dynbuf.c @@ -156,7 +156,6 @@ CURLcode curlx_dyn_tail(struct dynbuf *s, size_t trail) s->bufr[s->leng] = 0; } return CURLE_OK; - } /* diff --git a/lib/curlx/dynbuf.h b/lib/curlx/dynbuf.h index 00ca04789360..683b484610bb 100644 --- a/lib/curlx/dynbuf.h +++ b/lib/curlx/dynbuf.h @@ -32,7 +32,7 @@ struct dynbuf { size_t allc; /* size of the current allocation */ size_t toobig; /* size limit for the buffer */ #ifdef DEBUGBUILD - int init; /* detect API usage mistakes */ + int init; /* detect API usage mistakes */ #endif }; @@ -62,24 +62,24 @@ int curlx_dyn_vprintf(struct dynbuf *dyn, const char *format, va_list ap_save); char *curlx_dyn_take(struct dynbuf *s, size_t *plen); /* Dynamic buffer max sizes */ -#define MAX_DYNBUF_SIZE (SIZE_MAX/2) +#define MAX_DYNBUF_SIZE (SIZE_MAX / 2) #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 (1024*1024) +#define DYN_HTTP_REQUEST (1024 * 1024) #define DYN_APRINTF 8000000 -#define DYN_RTSP_REQ_HEADER (64*1024) -#define DYN_TRAILERS (64*1024) +#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) -#define DYN_MQTT_RECV (64*1024) +#define DYN_PINGPPONG_CMD (64 * 1024) +#define DYN_IMAP_CMD (64 * 1024) +#define DYN_MQTT_RECV (64 * 1024) #define DYN_MQTT_SEND 0xFFFFFFF -#define DYN_CRLFILE_SIZE (400*1024*1024) /* 400mb */ -#define DYN_CERTFILE_SIZE (100*1024) /* 100KiB */ -#define DYN_KEYFILE_SIZE (100*1024) /* 100KiB */ +#define DYN_CRLFILE_SIZE (400 * 1024 * 1024) /* 400MiB */ +#define DYN_CERTFILE_SIZE (100 * 1024) /* 100KiB */ +#define DYN_KEYFILE_SIZE (100 * 1024) /* 100KiB */ #endif diff --git a/lib/curlx/fopen.h b/lib/curlx/fopen.h index eeb3fda9469c..fb3277a17e7d 100644 --- a/lib/curlx/fopen.h +++ b/lib/curlx/fopen.h @@ -51,11 +51,12 @@ int curlx_win32_open(const char *filename, int oflag, ...); #endif #ifdef CURLDEBUG -#define curlx_fopen(file,mode) curl_dbg_fopen(file,mode,__LINE__,__FILE__) -#define curlx_freopen(file,mode,fh) \ - curl_dbg_freopen(file,mode,fh,__LINE__,__FILE__) -#define curlx_fdopen(file,mode) curl_dbg_fdopen(file,mode,__LINE__,__FILE__) -#define curlx_fclose(file) curl_dbg_fclose(file,__LINE__,__FILE__) +#define curlx_fopen(file, mode) curl_dbg_fopen(file, mode, __LINE__, __FILE__) +#define curlx_freopen(file, mode, fh) \ + curl_dbg_freopen(file, mode, fh, __LINE__, __FILE__) +#define curlx_fdopen(file, mode) \ + curl_dbg_fdopen(file, mode, __LINE__, __FILE__) +#define curlx_fclose(file) curl_dbg_fclose(file, __LINE__, __FILE__) #else #define curlx_fopen CURLX_FOPEN_LOW #define curlx_freopen CURLX_FREOPEN_LOW diff --git a/lib/curlx/inet_ntop.c b/lib/curlx/inet_ntop.c index 771af81474e7..96c58273e2a1 100644 --- a/lib/curlx/inet_ntop.c +++ b/lib/curlx/inet_ntop.c @@ -109,17 +109,18 @@ static char *inet_ntop6(const unsigned char *src, char *dst, size_t size) */ memset(words, '\0', sizeof(words)); for(i = 0; i < IN6ADDRSZ; i++) - words[i/2] |= ((unsigned int)src[i] << ((1 - (i % 2)) << 3)); + words[i / 2] |= ((unsigned int)src[i] << ((1 - (i % 2)) << 3)); best.base = -1; - cur.base = -1; + cur.base = -1; best.len = 0; cur.len = 0; for(i = 0; i < (IN6ADDRSZ / INT16SZ); i++) { if(words[i] == 0) { if(cur.base == -1) { - cur.base = i; cur.len = 1; + cur.base = i; + cur.len = 1; } else cur.len++; @@ -152,7 +153,7 @@ static char *inet_ntop6(const unsigned char *src, char *dst, size_t size) /* Is this address an encapsulated IPv4? */ if(i == 6 && best.base == 0 && - (best.len == 6 || (best.len == 5 && words[5] == 0xffff))) { + (best.len == 6 || (best.len == 5 && words[5] == 0xffff))) { if(!inet_ntop4(src + 12, tp, sizeof(tmp) - (tp - tmp))) { return NULL; } @@ -219,4 +220,4 @@ char *curlx_inet_ntop(int af, const void *src, char *buf, size_t size) return NULL; } } -#endif /* HAVE_INET_NTOP */ +#endif /* HAVE_INET_NTOP */ diff --git a/lib/curlx/inet_ntop.h b/lib/curlx/inet_ntop.h index 490f49e8a195..79cdc9e2afea 100644 --- a/lib/curlx/inet_ntop.h +++ b/lib/curlx/inet_ntop.h @@ -37,11 +37,11 @@ #include #endif #ifdef __AMIGA__ -#define curlx_inet_ntop(af,addr,buf,size) \ +#define curlx_inet_ntop(af, addr, buf, size) \ (char *)inet_ntop(af, CURL_UNCONST(addr), (unsigned char *)buf, \ (curl_socklen_t)(size)) #else -#define curlx_inet_ntop(af,addr,buf,size) \ +#define curlx_inet_ntop(af, addr, buf, size) \ inet_ntop(af, addr, buf, (curl_socklen_t)(size)) #endif #else diff --git a/lib/curlx/inet_pton.c b/lib/curlx/inet_pton.c index b78fa5d746fb..7b4a4043061d 100644 --- a/lib/curlx/inet_pton.c +++ b/lib/curlx/inet_pton.c @@ -54,8 +54,8 @@ * sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX. */ -static int inet_pton4(const char *src, unsigned char *dst); -static int inet_pton6(const char *src, unsigned char *dst); +static int inet_pton4(const char *src, unsigned char *dst); +static int inet_pton6(const char *src, unsigned char *dst); /* int * inet_pton(af, src, dst) @@ -73,8 +73,7 @@ static int inet_pton6(const char *src, unsigned char *dst); * author: * Paul Vixie, 1996. */ -int -curlx_inet_pton(int af, const char *src, void *dst) +int curlx_inet_pton(int af, const char *src, void *dst) { switch(af) { case AF_INET: @@ -98,8 +97,7 @@ curlx_inet_pton(int af, const char *src, void *dst) * author: * Paul Vixie, 1996. */ -static int -inet_pton4(const char *src, unsigned char *dst) +static int inet_pton4(const char *src, unsigned char *dst) { int saw_digit, octets, ch; unsigned char tmp[INADDRSZ], *tp; @@ -151,8 +149,7 @@ inet_pton4(const char *src, unsigned char *dst) * author: * Paul Vixie, 1996. */ -static int -inet_pton6(const char *src, unsigned char *dst) +static int inet_pton6(const char *src, unsigned char *dst) { unsigned char tmp[IN6ADDRSZ], *tp, *endp, *colonp; const char *curtok; @@ -187,14 +184,14 @@ inet_pton6(const char *src, unsigned char *dst) } if(tp + INT16SZ > endp) return 0; - *tp++ = (unsigned char) ((val >> 8) & 0xff); - *tp++ = (unsigned char) (val & 0xff); + *tp++ = (unsigned char)((val >> 8) & 0xff); + *tp++ = (unsigned char)(val & 0xff); saw_xdigit = 0; val = 0; continue; } if(ch == '.' && ((tp + INADDRSZ) <= endp) && - inet_pton4(curtok, tp) > 0) { + inet_pton4(curtok, tp) > 0) { tp += INADDRSZ; saw_xdigit = 0; break; /* '\0' was seen by inet_pton4(). */ @@ -204,8 +201,8 @@ inet_pton6(const char *src, unsigned char *dst) if(saw_xdigit) { if(tp + INT16SZ > endp) return 0; - *tp++ = (unsigned char) ((val >> 8) & 0xff); - *tp++ = (unsigned char) (val & 0xff); + *tp++ = (unsigned char)((val >> 8) & 0xff); + *tp++ = (unsigned char)(val & 0xff); } if(colonp) { /* diff --git a/lib/curlx/inet_pton.h b/lib/curlx/inet_pton.h index a9ad24c9447f..a52ef145dac5 100644 --- a/lib/curlx/inet_pton.h +++ b/lib/curlx/inet_pton.h @@ -37,9 +37,11 @@ #include #endif #ifdef __AMIGA__ -#define curlx_inet_pton(x,y,z) inet_pton(x,(unsigned char *)CURL_UNCONST(y),z) +#define curlx_inet_pton(x, y, z) \ + inet_pton(x, (unsigned char *)CURL_UNCONST(y), z) #else -#define curlx_inet_pton(x,y,z) inet_pton(x,y,z) +#define curlx_inet_pton(x, y, z) \ + inet_pton(x, y, z) #endif #else int curlx_inet_pton(int, const char *, void *); diff --git a/lib/curlx/nonblock.c b/lib/curlx/nonblock.c index b944f9546bb5..23eb8c0e3ab2 100644 --- a/lib/curlx/nonblock.c +++ b/lib/curlx/nonblock.c @@ -88,6 +88,6 @@ int curlx_nonblock(curl_socket_t sockfd, /* operate on this */ return setsockopt(sockfd, SOL_SOCKET, SO_NONBLOCK, &b, sizeof(b)); #else -# error "no non-blocking method was found/used/set" +#error "no non-blocking method was found/used/set" #endif } diff --git a/lib/curlx/strerr.c b/lib/curlx/strerr.c index 3dbeab82ee57..70ad1fb813e4 100644 --- a/lib/curlx/strerr.c +++ b/lib/curlx/strerr.c @@ -43,8 +43,7 @@ * 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) +static const char *get_winsock_error(int err, char *buf, size_t len) { #ifndef CURL_DISABLE_VERBOSE_STRINGS const char *p; diff --git a/lib/curlx/strparse.c b/lib/curlx/strparse.c index a29d8be2fdb7..c5a3ed2102e6 100644 --- a/lib/curlx/strparse.c +++ b/lib/curlx/strparse.c @@ -66,8 +66,7 @@ int curlx_str_until(const char **linep, struct Curl_str *out, /* Get a word until the first space or end of string. At least one byte long. return non-zero on error */ -int curlx_str_word(const char **linep, struct Curl_str *out, - const size_t max) +int curlx_str_word(const char **linep, struct Curl_str *out, const size_t max) { return curlx_str_until(linep, out, max, ' '); } @@ -95,7 +94,6 @@ int curlx_str_untilnl(const char **linep, struct Curl_str *out, return STRE_OK; } - /* Get a "quoted" word. No escaping possible. return non-zero on error */ int curlx_str_quotedword(const char **linep, struct Curl_str *out, @@ -141,8 +139,8 @@ int curlx_str_singlespace(const char **linep) } /* given an ASCII character and max ascii, return TRUE if valid */ -#define valid_digit(x,m) \ - (((x) >= '0') && ((x) <= m) && Curl_hexasciitable[(x)-'0']) +#define valid_digit(x, m) \ + (((x) >= '0') && ((x) <= m) && Curl_hexasciitable[(x) - '0']) /* We use 16 for the zero index (and the necessary bitwise AND in the loop) to be able to have a non-zero value there to make valid_digit() able to diff --git a/lib/curlx/timediff.c b/lib/curlx/timediff.c index a90da961ab83..d8baabe63e60 100644 --- a/lib/curlx/timediff.c +++ b/lib/curlx/timediff.c @@ -84,5 +84,5 @@ struct timeval *curlx_mstotv(struct timeval *tv, timediff_t ms) */ timediff_t curlx_tvtoms(struct timeval *tv) { - return (tv->tv_sec*1000) + (timediff_t)(tv->tv_usec/1000); + return (tv->tv_sec * 1000) + (timediff_t)(tv->tv_usec / 1000); } diff --git a/lib/curlx/timeval.c b/lib/curlx/timeval.c index a27525855b0a..ff49d7d27464 100644 --- a/lib/curlx/timeval.c +++ b/lib/curlx/timeval.c @@ -79,7 +79,7 @@ struct curltime curlx_now(void) return now; } -#elif defined(HAVE_CLOCK_GETTIME_MONOTONIC) || \ +#elif defined(HAVE_CLOCK_GETTIME_MONOTONIC) || \ defined(HAVE_CLOCK_GETTIME_MONOTONIC_RAW) struct curltime curlx_now(void) @@ -103,7 +103,7 @@ struct curltime curlx_now(void) ** called on unsupported OS version. */ #if defined(__APPLE__) && defined(HAVE_BUILTIN_AVAILABLE) && \ - (HAVE_BUILTIN_AVAILABLE == 1) + (HAVE_BUILTIN_AVAILABLE == 1) bool have_clock_gettime = FALSE; if(__builtin_available(macOS 10.12, iOS 10, tvOS 10, watchOS 3, *)) have_clock_gettime = TRUE; @@ -111,8 +111,8 @@ struct curltime curlx_now(void) #ifdef HAVE_CLOCK_GETTIME_MONOTONIC_RAW if( -#if defined(__APPLE__) && defined(HAVE_BUILTIN_AVAILABLE) && \ - (HAVE_BUILTIN_AVAILABLE == 1) +#if defined(__APPLE__) && defined(HAVE_BUILTIN_AVAILABLE) && \ + (HAVE_BUILTIN_AVAILABLE == 1) have_clock_gettime && #endif (clock_gettime(CLOCK_MONOTONIC_RAW, &tsnow) == 0)) { @@ -124,7 +124,7 @@ struct curltime curlx_now(void) if( #if defined(__APPLE__) && defined(HAVE_BUILTIN_AVAILABLE) && \ - (HAVE_BUILTIN_AVAILABLE == 1) + (HAVE_BUILTIN_AVAILABLE == 1) have_clock_gettime && #endif (clock_gettime(CLOCK_MONOTONIC, &tsnow) == 0)) { @@ -222,12 +222,12 @@ struct curltime curlx_now(void) */ timediff_t curlx_timediff_ms(struct curltime newer, struct curltime older) { - timediff_t diff = (timediff_t)newer.tv_sec-older.tv_sec; - if(diff >= (TIMEDIFF_T_MAX/1000)) + timediff_t diff = (timediff_t)newer.tv_sec - older.tv_sec; + if(diff >= (TIMEDIFF_T_MAX / 1000)) return TIMEDIFF_T_MAX; - else if(diff <= (TIMEDIFF_T_MIN/1000)) + else if(diff <= (TIMEDIFF_T_MIN / 1000)) return TIMEDIFF_T_MIN; - return diff * 1000 + (newer.tv_usec-older.tv_usec)/1000; + return diff * 1000 + (newer.tv_usec - older.tv_usec) / 1000; } /* @@ -237,12 +237,12 @@ timediff_t curlx_timediff_ms(struct curltime newer, struct curltime older) timediff_t curlx_timediff_ceil_ms(struct curltime newer, struct curltime older) { - timediff_t diff = (timediff_t)newer.tv_sec-older.tv_sec; - if(diff >= (TIMEDIFF_T_MAX/1000)) + timediff_t diff = (timediff_t)newer.tv_sec - older.tv_sec; + if(diff >= (TIMEDIFF_T_MAX / 1000)) return TIMEDIFF_T_MAX; - else if(diff <= (TIMEDIFF_T_MIN/1000)) + else if(diff <= (TIMEDIFF_T_MIN / 1000)) return TIMEDIFF_T_MIN; - return diff * 1000 + (newer.tv_usec - older.tv_usec + 999)/1000; + return diff * 1000 + (newer.tv_usec - older.tv_usec + 999) / 1000; } /* @@ -251,10 +251,10 @@ timediff_t curlx_timediff_ceil_ms(struct curltime newer, */ timediff_t curlx_timediff_us(struct curltime newer, struct curltime older) { - timediff_t diff = (timediff_t)newer.tv_sec-older.tv_sec; - if(diff >= (TIMEDIFF_T_MAX/1000000)) + timediff_t diff = (timediff_t)newer.tv_sec - older.tv_sec; + if(diff >= (TIMEDIFF_T_MAX / 1000000)) return TIMEDIFF_T_MAX; - else if(diff <= (TIMEDIFF_T_MIN/1000000)) + else if(diff <= (TIMEDIFF_T_MIN / 1000000)) return TIMEDIFF_T_MIN; - return diff * 1000000 + newer.tv_usec-older.tv_usec; + return diff * 1000000 + newer.tv_usec - older.tv_usec; } diff --git a/lib/curlx/wait.c b/lib/curlx/wait.c index 4e10a8297a93..f1dd6e7a7e27 100644 --- a/lib/curlx/wait.c +++ b/lib/curlx/wait.c @@ -74,7 +74,7 @@ int curlx_wait_ms(timediff_t timeout_ms) /* 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; + timeout_ms = ULONG_MAX - 1; /* do not use ULONG_MAX, because that is equal to INFINITE */ #endif Sleep((DWORD)timeout_ms); diff --git a/lib/curlx/warnless.c b/lib/curlx/warnless.c index fafa83c98c97..45442bd46270 100644 --- a/lib/curlx/warnless.c +++ b/lib/curlx/warnless.c @@ -27,10 +27,10 @@ #if defined(__INTEL_COMPILER) && defined(__unix__) #ifdef HAVE_NETINET_IN_H -# include +#include #endif #ifdef HAVE_ARPA_INET_H -# include +#include #endif #endif /* __INTEL_COMPILER && __unix__ */ @@ -56,15 +56,15 @@ unsigned char curlx_ultouc(unsigned long ulnum) { #ifdef __INTEL_COMPILER -# pragma warning(push) -# pragma warning(disable:810) /* conversion may lose significant bits */ +#pragma warning(push) +#pragma warning(disable:810) /* conversion may lose significant bits */ #endif - DEBUGASSERT(ulnum <= (unsigned long) CURL_MASK_UCHAR); - return (unsigned char)(ulnum & (unsigned long) CURL_MASK_UCHAR); + DEBUGASSERT(ulnum <= (unsigned long)CURL_MASK_UCHAR); + return (unsigned char)(ulnum & (unsigned long)CURL_MASK_UCHAR); #ifdef __INTEL_COMPILER -# pragma warning(pop) +#pragma warning(pop) #endif } @@ -75,15 +75,15 @@ unsigned char curlx_ultouc(unsigned long ulnum) int curlx_uztosi(size_t uznum) { #ifdef __INTEL_COMPILER -# pragma warning(push) -# pragma warning(disable:810) /* conversion may lose significant bits */ +#pragma warning(push) +#pragma warning(disable:810) /* conversion may lose significant bits */ #endif - DEBUGASSERT(uznum <= (size_t) CURL_MASK_SINT); - return (int)(uznum & (size_t) CURL_MASK_SINT); + DEBUGASSERT(uznum <= (size_t)CURL_MASK_SINT); + return (int)(uznum & (size_t)CURL_MASK_SINT); #ifdef __INTEL_COMPILER -# pragma warning(pop) +#pragma warning(pop) #endif } @@ -94,17 +94,17 @@ int curlx_uztosi(size_t uznum) unsigned long curlx_uztoul(size_t uznum) { #ifdef __INTEL_COMPILER -# pragma warning(push) -# pragma warning(disable:810) /* conversion may lose significant bits */ +#pragma warning(push) +#pragma warning(disable:810) /* conversion may lose significant bits */ #endif #if ULONG_MAX < SIZE_MAX - DEBUGASSERT(uznum <= (size_t) CURL_MASK_ULONG); + DEBUGASSERT(uznum <= (size_t)CURL_MASK_ULONG); #endif - return (unsigned long)(uznum & (size_t) CURL_MASK_ULONG); + return (unsigned long)(uznum & (size_t)CURL_MASK_ULONG); #ifdef __INTEL_COMPILER -# pragma warning(pop) +#pragma warning(pop) #endif } @@ -115,17 +115,17 @@ unsigned long curlx_uztoul(size_t uznum) unsigned int curlx_uztoui(size_t uznum) { #ifdef __INTEL_COMPILER -# pragma warning(push) -# pragma warning(disable:810) /* conversion may lose significant bits */ +#pragma warning(push) +#pragma warning(disable:810) /* conversion may lose significant bits */ #endif #if UINT_MAX < SIZE_MAX - DEBUGASSERT(uznum <= (size_t) CURL_MASK_UINT); + DEBUGASSERT(uznum <= (size_t)CURL_MASK_UINT); #endif - return (unsigned int)(uznum & (size_t) CURL_MASK_UINT); + return (unsigned int)(uznum & (size_t)CURL_MASK_UINT); #ifdef __INTEL_COMPILER -# pragma warning(pop) +#pragma warning(pop) #endif } @@ -136,18 +136,18 @@ unsigned int curlx_uztoui(size_t uznum) int curlx_sltosi(long slnum) { #ifdef __INTEL_COMPILER -# pragma warning(push) -# pragma warning(disable:810) /* conversion may lose significant bits */ +#pragma warning(push) +#pragma warning(disable:810) /* conversion may lose significant bits */ #endif DEBUGASSERT(slnum >= 0); #if INT_MAX < LONG_MAX - DEBUGASSERT((unsigned long) slnum <= (unsigned long) CURL_MASK_SINT); + DEBUGASSERT((unsigned long)slnum <= (unsigned long)CURL_MASK_SINT); #endif - return (int)(slnum & (long) CURL_MASK_SINT); + return (int)(slnum & (long)CURL_MASK_SINT); #ifdef __INTEL_COMPILER -# pragma warning(pop) +#pragma warning(pop) #endif } @@ -158,18 +158,18 @@ int curlx_sltosi(long slnum) unsigned int curlx_sltoui(long slnum) { #ifdef __INTEL_COMPILER -# pragma warning(push) -# pragma warning(disable:810) /* conversion may lose significant bits */ +#pragma warning(push) +#pragma warning(disable:810) /* conversion may lose significant bits */ #endif DEBUGASSERT(slnum >= 0); #if UINT_MAX < LONG_MAX - DEBUGASSERT((unsigned long) slnum <= (unsigned long) CURL_MASK_UINT); + DEBUGASSERT((unsigned long)slnum <= (unsigned long)CURL_MASK_UINT); #endif - return (unsigned int)(slnum & (long) CURL_MASK_UINT); + return (unsigned int)(slnum & (long)CURL_MASK_UINT); #ifdef __INTEL_COMPILER -# pragma warning(pop) +#pragma warning(pop) #endif } @@ -180,16 +180,16 @@ unsigned int curlx_sltoui(long slnum) unsigned short curlx_sltous(long slnum) { #ifdef __INTEL_COMPILER -# pragma warning(push) -# pragma warning(disable:810) /* conversion may lose significant bits */ +#pragma warning(push) +#pragma warning(disable:810) /* conversion may lose significant bits */ #endif DEBUGASSERT(slnum >= 0); - DEBUGASSERT((unsigned long) slnum <= (unsigned long) CURL_MASK_USHORT); - return (unsigned short)(slnum & (long) CURL_MASK_USHORT); + DEBUGASSERT((unsigned long)slnum <= (unsigned long)CURL_MASK_USHORT); + return (unsigned short)(slnum & (long)CURL_MASK_USHORT); #ifdef __INTEL_COMPILER -# pragma warning(pop) +#pragma warning(pop) #endif } @@ -200,15 +200,15 @@ unsigned short curlx_sltous(long slnum) ssize_t curlx_uztosz(size_t uznum) { #ifdef __INTEL_COMPILER -# pragma warning(push) -# pragma warning(disable:810) /* conversion may lose significant bits */ +#pragma warning(push) +#pragma warning(disable:810) /* conversion may lose significant bits */ #endif - DEBUGASSERT(uznum <= (size_t) CURL_MASK_SSIZE_T); - return (ssize_t)(uznum & (size_t) CURL_MASK_SSIZE_T); + DEBUGASSERT(uznum <= (size_t)CURL_MASK_SSIZE_T); + return (ssize_t)(uznum & (size_t)CURL_MASK_SSIZE_T); #ifdef __INTEL_COMPILER -# pragma warning(pop) +#pragma warning(pop) #endif } @@ -219,15 +219,15 @@ ssize_t curlx_uztosz(size_t uznum) size_t curlx_sotouz(curl_off_t sonum) { #ifdef __INTEL_COMPILER -# pragma warning(push) -# pragma warning(disable:810) /* conversion may lose significant bits */ +#pragma warning(push) +#pragma warning(disable:810) /* conversion may lose significant bits */ #endif DEBUGASSERT(sonum >= 0); - return (size_t)(sonum & (curl_off_t) CURL_MASK_USIZE_T); + return (size_t)(sonum & (curl_off_t)CURL_MASK_USIZE_T); #ifdef __INTEL_COMPILER -# pragma warning(pop) +#pragma warning(pop) #endif } @@ -238,18 +238,18 @@ size_t curlx_sotouz(curl_off_t sonum) int curlx_sztosi(ssize_t sznum) { #ifdef __INTEL_COMPILER -# pragma warning(push) -# pragma warning(disable:810) /* conversion may lose significant bits */ +#pragma warning(push) +#pragma warning(disable:810) /* conversion may lose significant bits */ #endif DEBUGASSERT(sznum >= 0); #if INT_MAX < SSIZE_MAX - DEBUGASSERT((size_t) sznum <= (size_t) CURL_MASK_SINT); + DEBUGASSERT((size_t)sznum <= (size_t)CURL_MASK_SINT); #endif - return (int)(sznum & (ssize_t) CURL_MASK_SINT); + return (int)(sznum & (ssize_t)CURL_MASK_SINT); #ifdef __INTEL_COMPILER -# pragma warning(pop) +#pragma warning(pop) #endif } @@ -260,15 +260,15 @@ int curlx_sztosi(ssize_t sznum) unsigned short curlx_uitous(unsigned int uinum) { #ifdef __INTEL_COMPILER -# pragma warning(push) -# pragma warning(disable:810) /* conversion may lose significant bits */ +#pragma warning(push) +#pragma warning(disable:810) /* conversion may lose significant bits */ #endif - DEBUGASSERT(uinum <= (unsigned int) CURL_MASK_USHORT); - return (unsigned short) (uinum & (unsigned int) CURL_MASK_USHORT); + DEBUGASSERT(uinum <= (unsigned int)CURL_MASK_USHORT); + return (unsigned short)(uinum & (unsigned int)CURL_MASK_USHORT); #ifdef __INTEL_COMPILER -# pragma warning(pop) +#pragma warning(pop) #endif } @@ -279,15 +279,15 @@ unsigned short curlx_uitous(unsigned int uinum) size_t curlx_sitouz(int sinum) { #ifdef __INTEL_COMPILER -# pragma warning(push) -# pragma warning(disable:810) /* conversion may lose significant bits */ +#pragma warning(push) +#pragma warning(disable:810) /* conversion may lose significant bits */ #endif DEBUGASSERT(sinum >= 0); - return (size_t) sinum; + return (size_t)sinum; #ifdef __INTEL_COMPILER -# pragma warning(pop) +#pragma warning(pop) #endif } @@ -333,7 +333,6 @@ bool curlx_sotouz_fits(curl_off_t sonum, size_t *puznum) return TRUE; } - bool curlx_sltouz(long slnum, size_t *puznum) { if(slnum < 0) { diff --git a/lib/curlx/warnless.h b/lib/curlx/warnless.h index 52e7ec2a5c5d..5f324ac37592 100644 --- a/lib/curlx/warnless.h +++ b/lib/curlx/warnless.h @@ -31,7 +31,7 @@ #endif #define CURLX_FUNCTION_CAST(target_type, func) \ - (target_type)(void (*) (void))(func) + (target_type)(void (*)(void))(func) unsigned char curlx_ultouc(unsigned long ulnum); diff --git a/lib/curlx/winapi.c b/lib/curlx/winapi.c index 4cacbcb618ea..3243f7cb4ad3 100644 --- a/lib/curlx/winapi.c +++ b/lib/curlx/winapi.c @@ -57,8 +57,8 @@ const char *curlx_get_winapi_error(DWORD err, char *buf, size_t buflen) /* Truncate multiple lines */ p = strchr(buf, '\n'); if(p) { - if(p > buf && *(p-1) == '\r') - *(p-1) = '\0'; + if(p > buf && *(p - 1) == '\r') + *(p - 1) = '\0'; else *p = '\0'; } @@ -89,7 +89,6 @@ const char *curlx_winapi_strerror(DWORD err, char *buf, size_t buflen) #if defined(__GNUC__) && __GNUC__ >= 7 #pragma GCC diagnostic pop #endif - } #else { diff --git a/lib/vauth/cleartext.c b/lib/vauth/cleartext.c index d259bc42b5b2..862310111e66 100644 --- a/lib/vauth/cleartext.c +++ b/lib/vauth/cleartext.c @@ -27,8 +27,8 @@ #include "../curl_setup.h" -#if !defined(CURL_DISABLE_IMAP) || !defined(CURL_DISABLE_SMTP) || \ - !defined(CURL_DISABLE_POP3) || \ +#if !defined(CURL_DISABLE_IMAP) || !defined(CURL_DISABLE_SMTP) || \ + !defined(CURL_DISABLE_POP3) || \ (!defined(CURL_DISABLE_LDAP) && defined(USE_OPENLDAP)) #include @@ -110,8 +110,7 @@ void Curl_auth_create_login_message(const char *valuep, struct bufref *out) * * Returns void. */ -void Curl_auth_create_external_message(const char *user, - struct bufref *out) +void Curl_auth_create_external_message(const char *user, struct bufref *out) { /* This is the same formatting as the login message */ Curl_auth_create_login_message(user, out); diff --git a/lib/vauth/cram.c b/lib/vauth/cram.c index 3b02e5751fcc..9bc5544a64fa 100644 --- a/lib/vauth/cram.c +++ b/lib/vauth/cram.c @@ -63,7 +63,7 @@ CURLcode Curl_auth_create_cram_md5_message(const struct bufref *chlg, /* Compute the digest using the password as the key */ ctxt = Curl_HMAC_init(&Curl_HMAC_MD5, - (const unsigned char *) passwdp, + (const unsigned char *)passwdp, curlx_uztoui(strlen(passwdp))); if(!ctxt) return CURLE_OUT_OF_MEMORY; diff --git a/lib/vauth/digest.c b/lib/vauth/digest.c index 850891f17535..c5fea6739449 100644 --- a/lib/vauth/digest.c +++ b/lib/vauth/digest.c @@ -138,20 +138,20 @@ bool Curl_auth_digest_get_pair(const char *str, char *value, char *content, #ifndef USE_WINDOWS_SSPI /* Convert MD5 chunk to RFC2617 (section 3.1.3) -suitable ASCII string */ static void auth_digest_md5_to_ascii(unsigned char *source, /* 16 bytes */ - unsigned char *dest) /* 33 bytes */ + unsigned char *dest) /* 33 bytes */ { int i; for(i = 0; i < 16; i++) - curl_msnprintf((char *) &dest[i * 2], 3, "%02x", source[i]); + curl_msnprintf((char *)&dest[i * 2], 3, "%02x", source[i]); } /* Convert sha256 or SHA-512/256 chunk to RFC7616 -suitable ASCII string */ static void auth_digest_sha256_to_ascii(unsigned char *source, /* 32 bytes */ - unsigned char *dest) /* 65 bytes */ + unsigned char *dest) /* 65 bytes */ { int i; for(i = 0; i < 32; i++) - curl_msnprintf((char *) &dest[i * 2], 3, "%02x", source[i]); + curl_msnprintf((char *)&dest[i * 2], 3, "%02x", source[i]); } /* Perform quoted-string escaping as described in RFC2616 and its errata */ @@ -272,7 +272,7 @@ static CURLcode auth_decode_digest_md5_message(const struct bufref *chlgref, char *alg, size_t alen, char *qop, size_t qlen) { - const char *chlg = (const char *) Curl_bufref_ptr(chlgref); + const char *chlg = (const char *)Curl_bufref_ptr(chlgref); /* Ensure we have a valid challenge message */ if(!Curl_bufref_len(chlgref)) @@ -387,13 +387,13 @@ CURLcode Curl_auth_create_digest_md5_message(struct Curl_easy *data, if(!ctxt) return CURLE_OUT_OF_MEMORY; - Curl_MD5_update(ctxt, (const unsigned char *) userp, + Curl_MD5_update(ctxt, (const unsigned char *)userp, curlx_uztoui(strlen(userp))); - Curl_MD5_update(ctxt, (const unsigned char *) ":", 1); - Curl_MD5_update(ctxt, (const unsigned char *) realm, + Curl_MD5_update(ctxt, (const unsigned char *)":", 1); + Curl_MD5_update(ctxt, (const unsigned char *)realm, curlx_uztoui(strlen(realm))); - Curl_MD5_update(ctxt, (const unsigned char *) ":", 1); - Curl_MD5_update(ctxt, (const unsigned char *) passwdp, + Curl_MD5_update(ctxt, (const unsigned char *)":", 1); + Curl_MD5_update(ctxt, (const unsigned char *)passwdp, curlx_uztoui(strlen(passwdp))); Curl_MD5_final(ctxt, digest); @@ -401,12 +401,12 @@ CURLcode Curl_auth_create_digest_md5_message(struct Curl_easy *data, if(!ctxt) return CURLE_OUT_OF_MEMORY; - Curl_MD5_update(ctxt, (const unsigned char *) digest, MD5_DIGEST_LEN); - Curl_MD5_update(ctxt, (const unsigned char *) ":", 1); - Curl_MD5_update(ctxt, (const unsigned char *) nonce, + Curl_MD5_update(ctxt, (const unsigned char *)digest, MD5_DIGEST_LEN); + Curl_MD5_update(ctxt, (const unsigned char *)":", 1); + Curl_MD5_update(ctxt, (const unsigned char *)nonce, curlx_uztoui(strlen(nonce))); - Curl_MD5_update(ctxt, (const unsigned char *) ":", 1); - Curl_MD5_update(ctxt, (const unsigned char *) cnonce, + Curl_MD5_update(ctxt, (const unsigned char *)":", 1); + Curl_MD5_update(ctxt, (const unsigned char *)cnonce, curlx_uztoui(strlen(cnonce))); Curl_MD5_final(ctxt, digest); @@ -427,10 +427,10 @@ CURLcode Curl_auth_create_digest_md5_message(struct Curl_easy *data, return CURLE_OUT_OF_MEMORY; } - Curl_MD5_update(ctxt, (const unsigned char *) method, + Curl_MD5_update(ctxt, (const unsigned char *)method, curlx_uztoui(strlen(method))); - Curl_MD5_update(ctxt, (const unsigned char *) ":", 1); - Curl_MD5_update(ctxt, (const unsigned char *) spn, + Curl_MD5_update(ctxt, (const unsigned char *)":", 1); + Curl_MD5_update(ctxt, (const unsigned char *)spn, curlx_uztoui(strlen(spn))); Curl_MD5_final(ctxt, digest); @@ -445,23 +445,23 @@ CURLcode Curl_auth_create_digest_md5_message(struct Curl_easy *data, return CURLE_OUT_OF_MEMORY; } - Curl_MD5_update(ctxt, (const unsigned char *) HA1_hex, 2 * MD5_DIGEST_LEN); - Curl_MD5_update(ctxt, (const unsigned char *) ":", 1); - Curl_MD5_update(ctxt, (const unsigned char *) nonce, + Curl_MD5_update(ctxt, (const unsigned char *)HA1_hex, 2 * MD5_DIGEST_LEN); + Curl_MD5_update(ctxt, (const unsigned char *)":", 1); + Curl_MD5_update(ctxt, (const unsigned char *)nonce, curlx_uztoui(strlen(nonce))); - Curl_MD5_update(ctxt, (const unsigned char *) ":", 1); + Curl_MD5_update(ctxt, (const unsigned char *)":", 1); - Curl_MD5_update(ctxt, (const unsigned char *) nonceCount, + Curl_MD5_update(ctxt, (const unsigned char *)nonceCount, curlx_uztoui(strlen(nonceCount))); - Curl_MD5_update(ctxt, (const unsigned char *) ":", 1); - Curl_MD5_update(ctxt, (const unsigned char *) cnonce, + Curl_MD5_update(ctxt, (const unsigned char *)":", 1); + Curl_MD5_update(ctxt, (const unsigned char *)cnonce, curlx_uztoui(strlen(cnonce))); - Curl_MD5_update(ctxt, (const unsigned char *) ":", 1); - Curl_MD5_update(ctxt, (const unsigned char *) qop, + Curl_MD5_update(ctxt, (const unsigned char *)":", 1); + Curl_MD5_update(ctxt, (const unsigned char *)qop, curlx_uztoui(strlen(qop))); - Curl_MD5_update(ctxt, (const unsigned char *) ":", 1); + Curl_MD5_update(ctxt, (const unsigned char *)":", 1); - Curl_MD5_update(ctxt, (const unsigned char *) HA2_hex, 2 * MD5_DIGEST_LEN); + Curl_MD5_update(ctxt, (const unsigned char *)HA2_hex, 2 * MD5_DIGEST_LEN); Curl_MD5_final(ctxt, digest); for(i = 0; i < MD5_DIGEST_LEN; i++) @@ -553,7 +553,7 @@ CURLcode Curl_auth_decode_digest_http_message(const char *chlg, if(curlx_str_casecompare(&out, DIGEST_QOP_VALUE_STRING_AUTH)) foundAuth = TRUE; else if(curlx_str_casecompare(&out, - DIGEST_QOP_VALUE_STRING_AUTH_INT)) + DIGEST_QOP_VALUE_STRING_AUTH_INT)) foundAuthInt = TRUE; if(curlx_str_single(&token, ',')) break; @@ -720,7 +720,7 @@ static CURLcode auth_create_digest_http_message( if(!hashthis) return CURLE_OUT_OF_MEMORY; - result = hash(hashbuf, (unsigned char *) hashthis, strlen(hashthis)); + result = hash(hashbuf, (unsigned char *)hashthis, strlen(hashthis)); curlx_free(hashthis); if(result) return result; @@ -743,7 +743,7 @@ static CURLcode auth_create_digest_http_message( if(!hashthis) return CURLE_OUT_OF_MEMORY; - result = hash(hashbuf, (unsigned char *) hashthis, strlen(hashthis)); + result = hash(hashbuf, (unsigned char *)hashthis, strlen(hashthis)); curlx_free(hashthis); if(result) return result; @@ -755,7 +755,7 @@ static CURLcode auth_create_digest_http_message( if(!tmp) return CURLE_OUT_OF_MEMORY; - result = hash(hashbuf, (unsigned char *) tmp, strlen(tmp)); + result = hash(hashbuf, (unsigned char *)tmp, strlen(tmp)); curlx_free(tmp); if(result) return result; @@ -799,7 +799,7 @@ static CURLcode auth_create_digest_http_message( if(!hashthis) return CURLE_OUT_OF_MEMORY; - result = hash(hashbuf, (unsigned char *) hashthis, strlen(hashthis)); + result = hash(hashbuf, (unsigned char *)hashthis, strlen(hashthis)); curlx_free(hashthis); if(result) return result; @@ -816,7 +816,7 @@ static CURLcode auth_create_digest_http_message( if(!hashthis) return CURLE_OUT_OF_MEMORY; - result = hash(hashbuf, (unsigned char *) hashthis, strlen(hashthis)); + result = hash(hashbuf, (unsigned char *)hashthis, strlen(hashthis)); curlx_free(hashthis); if(result) return result; @@ -1015,9 +1015,9 @@ void Curl_auth_digest_cleanup(struct digestdata *digest) digest->nc = 0; digest->algo = ALGO_MD5; /* default algorithm */ - digest->stale = FALSE; /* default means normal, not stale */ + digest->stale = FALSE; /* default means normal, not stale */ digest->userhash = FALSE; } -#endif /* !USE_WINDOWS_SSPI */ +#endif /* !USE_WINDOWS_SSPI */ -#endif /* !CURL_DISABLE_DIGEST_AUTH */ +#endif /* !CURL_DISABLE_DIGEST_AUTH */ diff --git a/lib/vauth/digest_sspi.c b/lib/vauth/digest_sspi.c index ea6a66af9fac..550810acda18 100644 --- a/lib/vauth/digest_sspi.c +++ b/lib/vauth/digest_sspi.c @@ -42,14 +42,14 @@ #include "../strerror.h" /* -* Curl_auth_is_digest_supported() -* -* This is used to evaluate if DIGEST is supported. -* -* Parameters: None -* -* Returns TRUE if DIGEST is supported by Windows SSPI. -*/ + * Curl_auth_is_digest_supported() + * + * This is used to evaluate if DIGEST is supported. + * + * Parameters: None + * + * Returns TRUE if DIGEST is supported by Windows SSPI. + */ bool Curl_auth_is_digest_supported(void) { PSecPkgInfo SecurityPackage; diff --git a/lib/vauth/gsasl.c b/lib/vauth/gsasl.c index debeda0604e2..8330a4bd7155 100644 --- a/lib/vauth/gsasl.c +++ b/lib/vauth/gsasl.c @@ -100,7 +100,7 @@ CURLcode Curl_auth_gsasl_token(struct Curl_easy *data, size_t outlen; res = gsasl_step(gsasl->client, - (const char *) Curl_bufref_ptr(chlg), Curl_bufref_len(chlg), + (const char *)Curl_bufref_ptr(chlg), Curl_bufref_len(chlg), &response, &outlen); if(res != GSASL_OK && res != GSASL_NEEDS_MORE) { failf(data, "GSASL step: %s", gsasl_strerror(res)); diff --git a/lib/vauth/krb5_gssapi.c b/lib/vauth/krb5_gssapi.c index 9ea36171faec..1590949d681a 100644 --- a/lib/vauth/krb5_gssapi.c +++ b/lib/vauth/krb5_gssapi.c @@ -159,7 +159,7 @@ CURLcode Curl_auth_create_gssapi_user_message(struct Curl_easy *data, gss_release_buffer(&unused_status, &output_token); } else - Curl_bufref_set(out, mutual_auth ? "": NULL, 0, NULL); + Curl_bufref_set(out, mutual_auth ? "" : NULL, 0, NULL); return result; } diff --git a/lib/vauth/krb5_sspi.c b/lib/vauth/krb5_sspi.c index 10fbac7644db..2f82345b98c7 100644 --- a/lib/vauth/krb5_sspi.c +++ b/lib/vauth/krb5_sspi.c @@ -278,8 +278,7 @@ CURLcode Curl_auth_create_gssapi_security_message(struct Curl_easy *data, /* Get our response size information */ status = Curl_pSecFn->QueryContextAttributes(krb5->context, - SECPKG_ATTR_SIZES, - &sizes); + SECPKG_ATTR_SIZES, &sizes); if(status == SEC_E_INSUFFICIENT_MEMORY) return CURLE_OUT_OF_MEMORY; diff --git a/lib/vauth/ntlm.c b/lib/vauth/ntlm.c index a757d1c8f9fd..e5eb1de5ef8b 100644 --- a/lib/vauth/ntlm.c +++ b/lib/vauth/ntlm.c @@ -48,7 +48,6 @@ #include "vauth.h" #include "../curl_endian.h" - /* NTLM buffer fixed size, large enough for long user + host + domain */ #define NTLM_BUFSIZE 1024 @@ -158,7 +157,7 @@ #define NTLMSSP_SIGNATURE "\x4e\x54\x4c\x4d\x53\x53\x50" #if DEBUG_ME -# define DEBUG_OUT(x) x +#define DEBUG_OUT(x) x static void ntlm_print_flags(FILE *handle, unsigned long flags) { if(flags & NTLMFLAG_NEGOTIATE_UNICODE) @@ -236,7 +235,7 @@ static void ntlm_print_hex(FILE *handle, const char *buf, size_t len) curl_mfprintf(stderr, "%02.2x", (unsigned int)*p++); } #else -# define DEBUG_OUT(x) Curl_nop_stmt +#define DEBUG_OUT(x) Curl_nop_stmt #endif /* diff --git a/lib/vauth/ntlm_sspi.c b/lib/vauth/ntlm_sspi.c index d976bc5d2131..bab319671c48 100644 --- a/lib/vauth/ntlm_sspi.c +++ b/lib/vauth/ntlm_sspi.c @@ -221,7 +221,6 @@ CURLcode Curl_auth_decode_ntlm_type2_message(struct Curl_easy *data, } /* -* Curl_auth_create_ntlm_type3_message() * Curl_auth_create_ntlm_type3_message() * * This is used to generate an already encoded NTLM type-3 message ready for @@ -267,12 +266,12 @@ CURLcode Curl_auth_create_ntlm_type3_message(struct Curl_easy *data, #ifdef SECPKG_ATTR_ENDPOINT_BINDINGS /* ssl context comes from schannel. - * When extended protection is used in IIS server, - * we have to pass a second SecBuffer to the SecBufferDesc - * otherwise IIS will not pass the authentication (401 response). - * Minimum supported version is Windows 7. - * https://learn.microsoft.com/security-updates/SecurityAdvisories/2009/973811 - */ + * When extended protection is used in IIS server, + * we have to pass a second SecBuffer to the SecBufferDesc + * otherwise IIS will not pass the authentication (401 response). + * Minimum supported version is Windows 7. + * https://learn.microsoft.com/security-updates/SecurityAdvisories/2009/973811 + */ if(ntlm->sslContext) { SEC_CHANNEL_BINDINGS channelBindings; SecPkgContext_Bindings pkgBindings; diff --git a/lib/vauth/oauth2.c b/lib/vauth/oauth2.c index 0bb7a9d6bdab..3b4d4164f094 100644 --- a/lib/vauth/oauth2.c +++ b/lib/vauth/oauth2.c @@ -27,7 +27,7 @@ #include "../curl_setup.h" #if !defined(CURL_DISABLE_IMAP) || !defined(CURL_DISABLE_SMTP) || \ - !defined(CURL_DISABLE_POP3) || \ + !defined(CURL_DISABLE_POP3) || \ (!defined(CURL_DISABLE_LDAP) && defined(USE_OPENLDAP)) #include diff --git a/lib/vauth/spnego_sspi.c b/lib/vauth/spnego_sspi.c index 90e622da3d4e..2b0504f630f8 100644 --- a/lib/vauth/spnego_sspi.c +++ b/lib/vauth/spnego_sspi.c @@ -139,7 +139,7 @@ CURLcode Curl_auth_decode_spnego_message(struct Curl_easy *data, nego->output_token = curlx_malloc(nego->token_max); if(!nego->output_token) return CURLE_OUT_OF_MEMORY; - } + } if(!nego->credentials) { /* Do we have credentials to use or are we using single sign-on? */ @@ -200,12 +200,12 @@ CURLcode Curl_auth_decode_spnego_message(struct Curl_easy *data, #ifdef SECPKG_ATTR_ENDPOINT_BINDINGS /* ssl context comes from Schannel. - * When extended protection is used in IIS server, - * we have to pass a second SecBuffer to the SecBufferDesc - * otherwise IIS will not pass the authentication (401 response). - * Minimum supported version is Windows 7. - * https://learn.microsoft.com/security-updates/SecurityAdvisories/2009/973811 - */ + * When extended protection is used in IIS server, + * we have to pass a second SecBuffer to the SecBufferDesc + * otherwise IIS will not pass the authentication (401 response). + * Minimum supported version is Windows 7. + * https://learn.microsoft.com/security-updates/SecurityAdvisories/2009/973811 + */ if(nego->sslContext) { SEC_CHANNEL_BINDINGS channelBindings; SecPkgContext_Bindings pkgBindings; diff --git a/lib/vauth/vauth.c b/lib/vauth/vauth.c index 6626ace8bc6a..4ca6cef7c8fe 100644 --- a/lib/vauth/vauth.c +++ b/lib/vauth/vauth.c @@ -171,13 +171,11 @@ static void ntlm_conn_dtor(void *key, size_t klen, void *entry) struct ntlmdata *Curl_auth_ntlm_get(struct connectdata *conn, bool proxy) { - const char *key = proxy ? CURL_META_NTLM_PROXY_CONN : - CURL_META_NTLM_CONN; + const char *key = proxy ? CURL_META_NTLM_PROXY_CONN : CURL_META_NTLM_CONN; struct ntlmdata *ntlm = Curl_conn_meta_get(conn, key); if(!ntlm) { ntlm = curlx_calloc(1, sizeof(*ntlm)); - if(!ntlm || - Curl_conn_meta_set(conn, key, ntlm, ntlm_conn_dtor)) + if(!ntlm || Curl_conn_meta_set(conn, key, ntlm, ntlm_conn_dtor)) return NULL; } return ntlm; @@ -185,8 +183,8 @@ struct ntlmdata *Curl_auth_ntlm_get(struct connectdata *conn, bool proxy) void Curl_auth_ntlm_remove(struct connectdata *conn, bool proxy) { - Curl_conn_meta_remove(conn, proxy ? - CURL_META_NTLM_PROXY_CONN : CURL_META_NTLM_CONN); + Curl_conn_meta_remove(conn, proxy ? CURL_META_NTLM_PROXY_CONN + : CURL_META_NTLM_CONN); } #endif /* USE_NTLM */ @@ -257,13 +255,11 @@ static void nego_conn_dtor(void *key, size_t klen, void *entry) struct negotiatedata *Curl_auth_nego_get(struct connectdata *conn, bool proxy) { - const char *key = proxy ? CURL_META_NEGO_PROXY_CONN : - CURL_META_NEGO_CONN; + const char *key = proxy ? CURL_META_NEGO_PROXY_CONN : CURL_META_NEGO_CONN; struct negotiatedata *nego = Curl_conn_meta_get(conn, key); if(!nego) { nego = curlx_calloc(1, sizeof(*nego)); - if(!nego || - Curl_conn_meta_set(conn, key, nego, nego_conn_dtor)) + if(!nego || Curl_conn_meta_set(conn, key, nego, nego_conn_dtor)) return NULL; } return nego; diff --git a/lib/vquic/curl_ngtcp2.c b/lib/vquic/curl_ngtcp2.c index 62255285b6a0..09b30229f08d 100644 --- a/lib/vquic/curl_ngtcp2.c +++ b/lib/vquic/curl_ngtcp2.c @@ -72,14 +72,14 @@ #include "../curlx/warnless.h" -#define QUIC_MAX_STREAMS (256*1024) -#define QUIC_HANDSHAKE_TIMEOUT (10*NGTCP2_SECONDS) +#define QUIC_MAX_STREAMS (256 * 1024) +#define QUIC_HANDSHAKE_TIMEOUT (10 * NGTCP2_SECONDS) /* A stream window is the maximum amount we need to buffer for * each active transfer. * Chunk size is large enough to take a full DATA frame */ #define H3_STREAM_WINDOW_SIZE (64 * 1024) -#define H3_STREAM_CHUNK_SIZE (16 * 1024) +#define H3_STREAM_CHUNK_SIZE (16 * 1024) #if H3_STREAM_CHUNK_SIZE < NGTCP2_MAX_UDP_PAYLOAD_SIZE #error H3_STREAM_CHUNK_SIZE smaller than NGTCP2_MAX_UDP_PAYLOAD_SIZE #endif @@ -150,8 +150,7 @@ struct cf_ngtcp2_ctx { /* How to access `call_data` from a cf_ngtcp2 filter */ #undef CF_CTX_CALL_DATA -#define CF_CTX_CALL_DATA(cf) \ - ((struct cf_ngtcp2_ctx *)(cf)->ctx)->call_data +#define CF_CTX_CALL_DATA(cf) ((struct cf_ngtcp2_ctx *)(cf)->ctx)->call_data static void h3_stream_hash_free(unsigned int id, void *stream); @@ -187,14 +186,14 @@ static void cf_ngtcp2_setup_keep_alive(struct Curl_cfilter *cf, struct cf_ngtcp2_ctx *ctx = cf->ctx; const ngtcp2_transport_params *rp; /* Peer should have sent us its transport parameters. If it - * announces a positive `max_idle_timeout` it will close the - * connection when it does not hear from us for that time. - * - * Some servers use this as a keep-alive timer at a rather low - * value. We are doing HTTP/3 here and waiting for the response - * to a request may take a considerable amount of time. We need - * to prevent the peer's QUIC stack from closing in this case. - */ + * announces a positive `max_idle_timeout` it will close the + * connection when it does not hear from us for that time. + * + * Some servers use this as a keep-alive timer at a rather low + * value. We are doing HTTP/3 here and waiting for the response + * to a request may take a considerable amount of time. We need + * to prevent the peer's QUIC stack from closing in this case. + */ if(!ctx->qconn) return; @@ -218,7 +217,6 @@ static void cf_ngtcp2_setup_keep_alive(struct Curl_cfilter *cf, } } - struct pkt_io_ctx; static CURLcode cf_progress_ingress(struct Curl_cfilter *cf, struct Curl_easy *data, @@ -231,20 +229,20 @@ static CURLcode cf_progress_egress(struct Curl_cfilter *cf, * All about the H3 internals of a stream */ struct h3_stream_ctx { - int64_t id; /* HTTP/3 protocol identifier */ - struct bufq sendbuf; /* h3 request body */ - struct h1_req_parser h1; /* h1 request parsing */ + int64_t id; /* HTTP/3 protocol identifier */ + struct bufq sendbuf; /* h3 request body */ + struct h1_req_parser h1; /* h1 request parsing */ size_t sendbuf_len_in_flight; /* sendbuf amount "in flight" */ - uint64_t error3; /* HTTP/3 stream error code */ - curl_off_t upload_left; /* number of request bytes left to upload */ - uint64_t download_unacked; /* bytes not acknowledged yet */ - int status_code; /* HTTP status code */ - CURLcode xfer_result; /* result from xfer_resp_write(_hd) */ - BIT(resp_hds_complete); /* we have a complete, final response */ - BIT(closed); /* TRUE on stream close */ - BIT(reset); /* TRUE on stream reset */ - BIT(send_closed); /* stream is local closed */ - BIT(quic_flow_blocked); /* stream is blocked by QUIC flow control */ + uint64_t error3; /* HTTP/3 stream error code */ + curl_off_t upload_left; /* number of request bytes left to upload */ + uint64_t download_unacked; /* bytes not acknowledged yet */ + int status_code; /* HTTP status code */ + CURLcode xfer_result; /* result from xfer_resp_write(_hd) */ + BIT(resp_hds_complete); /* we have a complete, final response */ + BIT(closed); /* TRUE on stream close */ + BIT(reset); /* TRUE on stream reset */ + BIT(send_closed); /* stream is local closed */ + BIT(quic_flow_blocked); /* stream is blocked by QUIC flow control */ }; static void h3_stream_ctx_free(struct h3_stream_ctx *stream) @@ -315,8 +313,8 @@ static bool cf_ngtcp2_sfind(uint32_t mid, void *value, void *user_data) return TRUE; /* continue */ } -static struct h3_stream_ctx * -cf_ngtcp2_get_stream(struct cf_ngtcp2_ctx *ctx, int64_t stream_id) +static struct h3_stream_ctx *cf_ngtcp2_get_stream(struct cf_ngtcp2_ctx *ctx, + int64_t stream_id) { struct cf_ngtcp2_sfind_ctx fctx; fctx.stream_id = stream_id; @@ -367,8 +365,7 @@ static void h3_data_done(struct Curl_cfilter *cf, struct Curl_easy *data) struct h3_stream_ctx *stream = H3_STREAM_CTX(ctx, data); (void)cf; if(stream) { - CURL_TRC_CF(data, cf, "[%" PRId64 "] easy handle is done", - stream->id); + CURL_TRC_CF(data, cf, "[%" PRId64 "] easy handle is done", stream->id); cf_ngtcp2_stream_close(cf, data, stream); Curl_uint32_hash_remove(&ctx->streams, data->mid); if(!Curl_uint32_hash_count(&ctx->streams)) @@ -640,10 +637,9 @@ static int cb_recv_stream_data(ngtcp2_conn *tconn, uint32_t flags, return 0; } -static int -cb_acked_stream_data_offset(ngtcp2_conn *tconn, int64_t stream_id, - uint64_t offset, uint64_t datalen, void *user_data, - void *stream_user_data) +static int cb_acked_stream_data_offset(ngtcp2_conn *tconn, int64_t stream_id, + uint64_t offset, uint64_t datalen, + void *user_data, void *stream_user_data) { struct Curl_cfilter *cf = user_data; struct cf_ngtcp2_ctx *ctx = cf->ctx; @@ -830,8 +826,8 @@ static int cb_recv_rx_key(ngtcp2_conn *tconn, ngtcp2_encryption_level level, } #if defined(_MSC_VER) && defined(_DLL) -# pragma warning(push) -# pragma warning(disable:4232) /* MSVC extension, dllimport identity */ +#pragma warning(push) +#pragma warning(disable:4232) /* MSVC extension, dllimport identity */ #endif static ngtcp2_callbacks ng_callbacks = { @@ -881,7 +877,7 @@ static ngtcp2_callbacks ng_callbacks = { }; #if defined(_MSC_VER) && defined(_DLL) -# pragma warning(pop) +#pragma warning(pop) #endif /** @@ -1337,9 +1333,9 @@ static CURLcode init_ngh3_conn(struct Curl_cfilter *cf, } static CURLcode recv_closed_stream(struct Curl_cfilter *cf, - struct Curl_easy *data, - struct h3_stream_ctx *stream, - size_t *pnread) + struct Curl_easy *data, + struct h3_stream_ctx *stream, + size_t *pnread) { (void)cf; *pnread = 0; @@ -1452,11 +1448,10 @@ static int cb_h3_acked_req_body(nghttp3_conn *conn, int64_t stream_id, return 0; } -static nghttp3_ssize -cb_h3_read_req_body(nghttp3_conn *conn, int64_t stream_id, - nghttp3_vec *vec, size_t veccnt, - uint32_t *pflags, void *user_data, - void *stream_user_data) +static nghttp3_ssize cb_h3_read_req_body(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_cfilter *cf = user_data; struct cf_ngtcp2_ctx *ctx = cf->ctx; @@ -1504,8 +1499,7 @@ cb_h3_read_req_body(nghttp3_conn *conn, int64_t stream_id, } else if(!nwritten) { /* Not EOF, and nothing to give, we signal WOULDBLOCK. */ - CURL_TRC_CF(data, cf, "[%" PRId64 "] read req body -> AGAIN", - stream->id); + CURL_TRC_CF(data, cf, "[%" PRId64 "] read req body -> AGAIN", stream->id); return NGHTTP3_ERR_WOULDBLOCK; } @@ -1961,7 +1955,7 @@ static CURLcode cf_progress_egress(struct Curl_cfilter *cf, */ max_payload_size = ngtcp2_conn_get_max_tx_udp_payload_size(ctx->qconn); path_max_payload_size = - ngtcp2_conn_get_path_max_tx_udp_payload_size(ctx->qconn); + ngtcp2_conn_get_path_max_tx_udp_payload_size(ctx->qconn); send_quantum = ngtcp2_conn_get_send_quantum(ctx->qconn); CURL_TRC_CF(data, cf, "egress, collect and send packets, quantum=%zu", send_quantum); @@ -1977,7 +1971,7 @@ static CURLcode cf_progress_egress(struct Curl_cfilter *cf, size_t buflen = Curl_bufq_len(&ctx->q.sendbuf); if((buflen >= send_quantum) || ((buflen + gsolen) >= ctx->q.sendbuf.chunk_size)) - break; + break; DEBUGASSERT(nread > 0); ++pktcnt; if(pktcnt == 1) { @@ -2283,16 +2277,26 @@ static int quic_ossl_new_session_cb(SSL *ssl, SSL_SESSION *ssl_sessionid) static const char *gtls_hs_msg_name(int mtype) { switch(mtype) { - case 1: return "ClientHello"; - case 2: return "ServerHello"; - case 4: return "SessionTicket"; - case 8: return "EncryptedExtensions"; - case 11: return "Certificate"; - case 13: return "CertificateRequest"; - case 15: return "CertificateVerify"; - case 20: return "Finished"; - case 24: return "KeyUpdate"; - case 254: return "MessageHash"; + case 1: + return "ClientHello"; + case 2: + return "ServerHello"; + case 4: + return "SessionTicket"; + case 8: + return "EncryptedExtensions"; + case 11: + return "Certificate"; + case 13: + return "CertificateRequest"; + case 15: + return "CertificateVerify"; + case 20: + return "Finished"; + case 24: + return "KeyUpdate"; + case 254: + return "MessageHash"; } return "Unknown"; } @@ -2458,7 +2462,7 @@ static CURLcode cf_ngtcp2_on_session_reuse(struct Curl_cfilter *cf, #endif /* WOLFSSL_EARLY_DATA */ #endif #if defined(USE_GNUTLS) || defined(USE_WOLFSSL) || \ - (defined(USE_OPENSSL) && defined(HAVE_OPENSSL_EARLYDATA)) + (defined(USE_OPENSSL) && defined(HAVE_OPENSSL_EARLYDATA)) if((!ctx->earlydata_max)) { CURL_TRC_CF(data, cf, "SSL session does not allow earlydata"); } @@ -2668,7 +2672,7 @@ static CURLcode cf_ngtcp2_connect(struct Curl_cfilter *cf, CURL_TRC_CF(data, cf, "connection refused by server"); /* When a QUIC server instance is shutting down, it may send us a * CONNECTION_CLOSE with this code right away. We want - * to keep on trying in this case. */ + * to keep on trying in this case. */ result = CURLE_WEIRD_SERVER_REPLY; } } diff --git a/lib/vquic/curl_osslq.c b/lib/vquic/curl_osslq.c index 7bca97b4086d..ece4ce6ad570 100644 --- a/lib/vquic/curl_osslq.c +++ b/lib/vquic/curl_osslq.c @@ -453,29 +453,29 @@ static CURLcode cf_osslq_h3conn_add_stream(struct cf_osslq_h3conn *h3, * BUT OpenSSL does not offer this information to us. So, we silently * ignore all such streams we do not expect. */ switch(stype) { - case SSL_STREAM_TYPE_READ: { - struct cf_osslq_stream *nstream; - if(h3->remote_ctrl_n >= CURL_ARRAYSIZE(h3->remote_ctrl)) { - /* rejected, we are full */ - CURL_TRC_CF(data, cf, "[%" PRId64 "] reject remote uni stream", - stream_id); - SSL_free(stream_ssl); - return CURLE_OK; - } - nstream = &h3->remote_ctrl[h3->remote_ctrl_n++]; - nstream->id = stream_id; - nstream->ssl = stream_ssl; - Curl_bufq_initp(&nstream->recvbuf, &ctx->stream_bufcp, 1, BUFQ_OPT_NONE); - CURL_TRC_CF(data, cf, "[%" PRId64 "] accepted remote uni stream", + case SSL_STREAM_TYPE_READ: { + struct cf_osslq_stream *nstream; + if(h3->remote_ctrl_n >= CURL_ARRAYSIZE(h3->remote_ctrl)) { + /* rejected, we are full */ + CURL_TRC_CF(data, cf, "[%" PRId64 "] reject remote uni stream", stream_id); - return CURLE_OK; - } - default: - CURL_TRC_CF(data, cf, "[%" PRId64 "] reject remote %s" - " stream, type=%x", stream_id, - (stype == SSL_STREAM_TYPE_BIDI) ? "bidi" : "write", stype); SSL_free(stream_ssl); return CURLE_OK; + } + nstream = &h3->remote_ctrl[h3->remote_ctrl_n++]; + nstream->id = stream_id; + nstream->ssl = stream_ssl; + Curl_bufq_initp(&nstream->recvbuf, &ctx->stream_bufcp, 1, BUFQ_OPT_NONE); + CURL_TRC_CF(data, cf, "[%" PRId64 "] accepted remote uni stream", + stream_id); + return CURLE_OK; + } + default: + CURL_TRC_CF(data, cf, "[%" PRId64 "] reject remote %s" + " stream, type=%x", stream_id, + (stype == SSL_STREAM_TYPE_BIDI) ? "bidi" : "write", stype); + SSL_free(stream_ssl); + return CURLE_OK; } } @@ -505,8 +505,7 @@ static CURLcode cf_osslq_ssl_err(struct Curl_cfilter *cf, lerr = SSL_get_verify_result(ctx->tls.ossl.ssl); if(lerr != X509_V_OK) { ssl_config->certverifyresult = lerr; - curl_msnprintf(ebuf, sizeof(ebuf), - "SSL certificate problem: %s", + curl_msnprintf(ebuf, sizeof(ebuf), "SSL certificate problem: %s", X509_verify_cert_error_string(lerr)); } else @@ -540,7 +539,7 @@ static CURLcode cf_osslq_ssl_err(struct Curl_cfilter *cf, * the SO_ERROR is also lost. */ if(CURLE_SSL_CONNECT_ERROR == result && errdetail == 0) { - char extramsg[80]=""; + char extramsg[80] = ""; int sockerr = SOCKERRNO; struct ip_quadruple ip; @@ -570,20 +569,21 @@ static CURLcode cf_osslq_verify_peer(struct Curl_cfilter *cf, */ struct h3_stream_ctx { struct cf_osslq_stream s; - struct bufq sendbuf; /* h3 request body */ - struct bufq recvbuf; /* h3 response body */ - struct h1_req_parser h1; /* h1 request parsing */ + struct bufq sendbuf; /* h3 request body */ + struct bufq recvbuf; /* h3 response body */ + struct h1_req_parser h1; /* h1 request parsing */ size_t sendbuf_len_in_flight; /* sendbuf amount "in flight" */ - size_t recv_buf_nonflow; /* buffered bytes, not counting for flow control */ - uint64_t error3; /* HTTP/3 stream error code */ - curl_off_t upload_left; /* number of request bytes left to upload */ - curl_off_t download_recvd; /* number of response DATA bytes received */ - int status_code; /* HTTP status code */ - BIT(resp_hds_complete); /* we have a complete, final response */ - BIT(closed); /* TRUE on stream close */ - BIT(reset); /* TRUE on stream reset */ - BIT(send_closed); /* stream is local closed */ - BIT(quic_flow_blocked); /* stream is blocked by QUIC flow control */ + size_t recv_buf_nonflow; /* buffered bytes, + not counting for flow control */ + uint64_t error3; /* HTTP/3 stream error code */ + curl_off_t upload_left; /* number of request bytes left to upload */ + curl_off_t download_recvd; /* number of response DATA bytes received */ + int status_code; /* HTTP status code */ + BIT(resp_hds_complete); /* we have a complete, final response */ + BIT(closed); /* TRUE on stream close */ + BIT(reset); /* TRUE on stream reset */ + BIT(send_closed); /* stream is local closed */ + BIT(quic_flow_blocked); /* stream is blocked by QUIC flow control */ }; static void h3_stream_ctx_free(struct h3_stream_ctx *stream) @@ -645,8 +645,7 @@ static void h3_data_done(struct Curl_cfilter *cf, struct Curl_easy *data) (void)cf; if(stream) { - CURL_TRC_CF(data, cf, "[%" PRIu64 "] easy handle is done", - stream->s.id); + CURL_TRC_CF(data, cf, "[%" PRIu64 "] easy handle is done", stream->s.id); if(ctx->h3.conn && (stream->s.id >= 0) && !stream->closed) { nghttp3_conn_shutdown_stream_read(ctx->h3.conn, stream->s.id); nghttp3_conn_close_stream(ctx->h3.conn, stream->s.id, @@ -965,11 +964,10 @@ static int cb_h3_reset_stream(nghttp3_conn *conn, int64_t stream_id, return 0; } -static nghttp3_ssize -cb_h3_read_req_body(nghttp3_conn *conn, int64_t stream_id, - nghttp3_vec *vec, size_t veccnt, - uint32_t *pflags, void *user_data, - void *stream_user_data) +static nghttp3_ssize cb_h3_read_req_body(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_cfilter *cf = user_data; struct cf_osslq_ctx *ctx = cf->ctx; @@ -1106,21 +1104,21 @@ static CURLcode cf_osslq_h3conn_init(struct cf_osslq_ctx *ctx, SSL *conn, } result = cf_osslq_stream_open(&h3->s_ctrl, conn, - SSL_STREAM_FLAG_ADVANCE|SSL_STREAM_FLAG_UNI, + SSL_STREAM_FLAG_ADVANCE | SSL_STREAM_FLAG_UNI, &ctx->stream_bufcp, NULL); if(result) { result = CURLE_QUIC_CONNECT_ERROR; goto out; } result = cf_osslq_stream_open(&h3->s_qpack_enc, conn, - SSL_STREAM_FLAG_ADVANCE|SSL_STREAM_FLAG_UNI, + SSL_STREAM_FLAG_ADVANCE | SSL_STREAM_FLAG_UNI, &ctx->stream_bufcp, NULL); if(result) { result = CURLE_QUIC_CONNECT_ERROR; goto out; } result = cf_osslq_stream_open(&h3->s_qpack_dec, conn, - SSL_STREAM_FLAG_ADVANCE|SSL_STREAM_FLAG_UNI, + SSL_STREAM_FLAG_ADVANCE | SSL_STREAM_FLAG_UNI, &ctx->stream_bufcp, NULL); if(result) { result = CURLE_QUIC_CONNECT_ERROR; @@ -1221,7 +1219,8 @@ static CURLcode cf_osslq_ctx_start(struct Curl_cfilter *cf, SSL_INCOMING_STREAM_POLICY_ACCEPT, 0); /* from our side, there is no idle timeout */ SSL_set_value_uint(ctx->tls.ossl.ssl, - SSL_VALUE_CLASS_FEATURE_REQUEST, SSL_VALUE_QUIC_IDLE_TIMEOUT, 0); + SSL_VALUE_CLASS_FEATURE_REQUEST, + SSL_VALUE_QUIC_IDLE_TIMEOUT, 0); /* setup the H3 things on top of the QUIC connection */ result = cf_osslq_h3conn_init(ctx, ctx->tls.ossl.ssl, cf); @@ -1532,7 +1531,7 @@ static CURLcode cf_osslq_check_and_unblock(struct Curl_cfilter *cf, fill_ctx.multi = data->multi; fill_ctx.n = 0; Curl_uint32_hash_visit(&ctx->streams, cf_osslq_collect_block_send, - &fill_ctx); + &fill_ctx); poll_count = fill_ctx.n; if(poll_count) { CURL_TRC_CF(data, cf, "polling %zu blocked streams", poll_count); @@ -1541,7 +1540,7 @@ static CURLcode cf_osslq_check_and_unblock(struct Curl_cfilter *cf, res = CURLE_UNRECOVERABLE_POLL; if(!SSL_poll(ctx->poll_items, poll_count, sizeof(SSL_POLL_ITEM), &timeout, 0, &result_count)) - goto out; + goto out; res = CURLE_OK; @@ -1617,7 +1616,7 @@ static CURLcode h3_send_streams(struct Curl_cfilter *cf, uint64_t flags = (eos && ((i + 1) == n)) ? SSL_WRITE_FLAG_CONCLUDE : 0; written = vec[i].len; ok = !s->ssl || SSL_write_ex2(s->ssl, vec[i].base, vec[i].len, flags, - &written); + &written); if(ok && flags & SSL_WRITE_FLAG_CONCLUDE) eos_written = TRUE; if(ok) { diff --git a/lib/vquic/curl_quiche.c b/lib/vquic/curl_quiche.c index 5aca750c2cb9..45f606ec6182 100644 --- a/lib/vquic/curl_quiche.c +++ b/lib/vquic/curl_quiche.c @@ -167,17 +167,17 @@ static CURLcode cf_flush_egress(struct Curl_cfilter *cf, * All about the H3 internals of a stream */ struct h3_stream_ctx { - uint64_t id; /* HTTP/3 protocol stream identifier */ - struct bufq recvbuf; /* h3 response */ + uint64_t id; /* HTTP/3 protocol stream identifier */ + struct bufq recvbuf; /* h3 response */ struct h1_req_parser h1; /* h1 request parsing */ - uint64_t error3; /* HTTP/3 stream error code */ - BIT(opened); /* TRUE after stream has been opened */ - BIT(closed); /* TRUE on stream close */ - BIT(reset); /* TRUE on stream reset */ - BIT(send_closed); /* stream is locally closed */ + uint64_t error3; /* HTTP/3 stream error code */ + BIT(opened); /* TRUE after stream has been opened */ + BIT(closed); /* TRUE on stream close */ + BIT(reset); /* TRUE on stream reset */ + BIT(send_closed); /* stream is locally closed */ BIT(resp_hds_complete); /* final response has been received */ - BIT(resp_got_header); /* TRUE when h3 stream has recvd some HEADER */ - BIT(quic_flow_blocked); /* stream is blocked by QUIC flow control */ + BIT(resp_got_header); /* TRUE when h3 stream has recvd some HEADER */ + BIT(quic_flow_blocked); /* stream is blocked by QUIC flow control */ }; static void h3_stream_ctx_free(struct h3_stream_ctx *stream) @@ -318,7 +318,7 @@ static void cf_quiche_expire_conn_closed(struct Curl_cfilter *cf, /* * write_resp_raw() copies response data in raw format to the `data`'s - * receive buffer. If not enough space is available, it appends to the + * receive buffer. If not enough space is available, it appends to the * `data`'s overflow buffer. */ static CURLcode write_resp_raw(struct Curl_cfilter *cf, @@ -813,7 +813,7 @@ static CURLcode cf_flush_egress(struct Curl_cfilter *cf, timeout_ns = quiche_conn_timeout_as_nanos(ctx->qconn); if(timeout_ns % 1000000) timeout_ns += 1000000; - /* expire resolution is milliseconds */ + /* expire resolution is milliseconds */ Curl_expire(data, (timeout_ns / 1000000), EXPIRE_QUIC); return result; } @@ -977,9 +977,9 @@ static CURLcode h3_open_stream(struct Curl_cfilter *cf, DEBUGASSERT(stream); result = Curl_h1_req_parse_read(&stream->h1, buf, blen, NULL, - !data->state.http_ignorecustom ? - data->set.str[STRING_CUSTOMREQUEST] : NULL, - 0, pnwritten); + !data->state.http_ignorecustom ? + data->set.str[STRING_CUSTOMREQUEST] : NULL, + 0, pnwritten); if(result) goto out; if(!stream->h1.done) { @@ -1313,8 +1313,7 @@ static CURLcode cf_quiche_ctx_open(struct Curl_cfilter *cf, int qfd; (void)Curl_qlogdir(data, ctx->scid, sizeof(ctx->scid), &qfd); if(qfd != -1) - quiche_conn_set_qlog_fd(ctx->qconn, qfd, - "qlog title", "curl qlog"); + quiche_conn_set_qlog_fd(ctx->qconn, qfd, "qlog title", "curl qlog"); } #endif diff --git a/lib/vquic/vquic-tls.c b/lib/vquic/vquic-tls.c index 7a3c99b58441..99b19b369185 100644 --- a/lib/vquic/vquic-tls.c +++ b/lib/vquic/vquic-tls.c @@ -143,7 +143,9 @@ CURLcode Curl_vquic_tls_before_recv(struct curl_tls_ctx *ctx, return result; } #else - (void)ctx; (void)cf; (void)data; + (void)ctx; + (void)cf; + (void)data; #endif return CURLE_OK; } @@ -172,7 +174,7 @@ CURLcode Curl_vquic_tls_verify_peer(struct curl_tls_ctx *ctx, #elif defined(USE_WOLFSSL) (void)data; if(conn_config->verifyhost) { - WOLFSSL_X509* cert = wolfSSL_get_peer_certificate(ctx->wssl.ssl); + WOLFSSL_X509 *cert = wolfSSL_get_peer_certificate(ctx->wssl.ssl); if(!cert) result = CURLE_OUT_OF_MEMORY; else if(peer->sni && @@ -194,7 +196,6 @@ CURLcode Curl_vquic_tls_verify_peer(struct curl_tls_ctx *ctx, return result; } - bool Curl_vquic_tls_get_ssl_info(struct curl_tls_ctx *ctx, bool give_ssl_ctx, struct curl_tlssessioninfo *info) diff --git a/lib/vquic/vquic-tls.h b/lib/vquic/vquic-tls.h index c694e23e4e6d..7bddb42c99f3 100644 --- a/lib/vquic/vquic-tls.h +++ b/lib/vquic/vquic-tls.h @@ -69,14 +69,14 @@ typedef CURLcode Curl_vquic_session_reuse_cb(struct Curl_cfilter *cf, /** * Initialize the QUIC TLS instances based of the SSL configurations * for the connection filter, transfer and peer. - * @param ctx the TLS context to initialize - * @param cf the connection filter involved - * @param data the transfer involved - * @param peer the peer that will be connected to - * @param alpns the ALPN specifications to negotiate, may be NULL - * @param cb_setup optional callback for early TLS config - * @param cb_user_data user_data param for callback - * @param ssl_user_data optional pointer to set in TLS application context + * @param ctx the TLS context to initialize + * @param cf the connection filter involved + * @param data the transfer involved + * @param peer the peer that will be connected to + * @param alpns the ALPN specifications to negotiate, may be NULL + * @param cb_setup optional callback for early TLS config + * @param cb_user_data user_data param for callback + * @param ssl_user_data optional pointer to set in TLS application context * @param session_reuse_cb callback to handle session reuse, signal early data */ CURLcode Curl_vquic_tls_init(struct curl_tls_ctx *ctx, diff --git a/lib/vquic/vquic.c b/lib/vquic/vquic.c index c1267cef9ed0..a4dea8a77c43 100644 --- a/lib/vquic/vquic.c +++ b/lib/vquic/vquic.c @@ -266,7 +266,7 @@ static CURLcode vquic_send_packets(struct Curl_cfilter *cf, unsigned char c; *psent = 0; Curl_rand(data, &c, 1); - if(c >= ((100-qctx->wblock_percent)*256/100)) { + if(c >= ((100 - qctx->wblock_percent) * 256 / 100)) { CURL_TRC_CF(data, cf, "vquic_flush() simulate EWOULDBLOCK"); return CURLE_AGAIN; } @@ -334,8 +334,7 @@ CURLcode vquic_send_tail_split(struct Curl_cfilter *cf, struct Curl_easy *data, qctx->split_gsolen = gsolen; qctx->gsolen = tail_gsolen; CURL_TRC_CF(data, cf, "vquic_send_tail_split: [%zu gso=%zu][%zu gso=%zu]", - qctx->split_len, qctx->split_gsolen, - tail_len, qctx->gsolen); + qctx->split_len, qctx->split_gsolen, tail_len, qctx->gsolen); return vquic_flush(cf, data, qctx); } @@ -476,7 +475,7 @@ static CURLcode recvmsg_packets(struct Curl_cfilter *cf, { struct iovec msg_iov; struct msghdr msg; - uint8_t buf[64*1024]; + uint8_t buf[64 * 1024]; struct sockaddr_storage remote_addr; size_t total_nread, pkts, calls; ssize_t rc; @@ -551,7 +550,7 @@ static CURLcode recvfrom_packets(struct Curl_cfilter *cf, size_t max_pkts, vquic_recv_pkts_cb *recv_cb, void *userp) { - uint8_t buf[64*1024]; + uint8_t buf[64 * 1024]; int bufsize = (int)sizeof(buf); struct sockaddr_storage remote_addr; socklen_t remote_addrlen = sizeof(remote_addr); diff --git a/lib/vquic/vquic_int.h b/lib/vquic/vquic_int.h index ef92ab21b730..b4f2fd811680 100644 --- a/lib/vquic/vquic_int.h +++ b/lib/vquic/vquic_int.h @@ -33,25 +33,25 @@ #define MAX_UDP_PAYLOAD_SIZE 1452 struct cf_quic_ctx { - curl_socket_t sockfd; /* connected UDP socket */ + curl_socket_t sockfd; /* connected UDP socket */ struct sockaddr_storage local_addr; /* address socket is bound to */ - socklen_t local_addrlen; /* length of local address */ - - struct bufq sendbuf; /* buffer for sending one or more packets */ - struct curltime first_byte_at; /* when first byte was recvd */ - struct curltime last_op; /* last (attempted) send/recv operation */ - struct curltime last_io; /* last successful socket IO */ - size_t gsolen; /* length of individual packets in send buf */ - size_t split_len; /* if != 0, buffer length after which GSO differs */ + socklen_t local_addrlen; /* length of local address */ + + struct bufq sendbuf; /* buffer for sending one or more packets */ + struct curltime first_byte_at; /* when first byte was recvd */ + struct curltime last_op; /* last (attempted) send/recv operation */ + struct curltime last_io; /* last successful socket IO */ + size_t gsolen; /* length of individual packets in send buf */ + size_t split_len; /* if != 0, buffer length after which GSO differs */ size_t split_gsolen; /* length of individual packets after split_len */ #ifdef DEBUGBUILD - int wblock_percent; /* percent of writes doing EAGAIN */ + int wblock_percent; /* percent of writes doing EAGAIN */ #endif BIT(got_first_byte); /* if first byte was received */ - BIT(no_gso); /* do not use gso on sending */ + BIT(no_gso); /* do not use gso on sending */ }; -#define H3_STREAM_CTX(ctx,data) \ +#define H3_STREAM_CTX(ctx, data) \ (data ? Curl_uint32_hash_get(&(ctx)->streams, (data)->mid) : NULL) CURLcode vquic_ctx_init(struct cf_quic_ctx *qctx); @@ -77,7 +77,6 @@ CURLcode vquic_send_tail_split(struct Curl_cfilter *cf, struct Curl_easy *data, CURLcode vquic_flush(struct Curl_cfilter *cf, struct Curl_easy *data, struct cf_quic_ctx *qctx); - typedef CURLcode vquic_recv_pkts_cb(const unsigned char *buf, size_t buflen, size_t gso_size, struct sockaddr_storage *remote_addr, diff --git a/lib/vssh/libssh.c b/lib/vssh/libssh.c index db80bcbf8c96..cd3a7d6622e1 100644 --- a/lib/vssh/libssh.c +++ b/lib/vssh/libssh.c @@ -74,12 +74,12 @@ /* 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; \ - } \ +#define SSH_STRING_FREE_CHAR(x) \ + do { \ + if(x) { \ + ssh_string_free_char(x); \ + x = NULL; \ + } \ } while(0) #endif @@ -111,10 +111,9 @@ static CURLcode sftp_doing(struct Curl_easy *data, static CURLcode sftp_disconnect(struct Curl_easy *data, struct connectdata *conn, bool dead); -static -CURLcode sftp_perform(struct Curl_easy *data, - bool *connected, - bool *dophase_done); +static CURLcode sftp_perform(struct Curl_easy *data, + bool *connected, + bool *dophase_done); static CURLcode myssh_pollset(struct Curl_easy *data, struct easy_pollset *ps); @@ -189,22 +188,22 @@ const struct Curl_handler Curl_handler_sftp = { static CURLcode sftp_error_to_CURLE(int err) { switch(err) { - case SSH_FX_OK: - return CURLE_OK; + case SSH_FX_OK: + return CURLE_OK; - case SSH_FX_NO_SUCH_FILE: - case SSH_FX_NO_SUCH_PATH: - return CURLE_REMOTE_FILE_NOT_FOUND; + case SSH_FX_NO_SUCH_FILE: + case SSH_FX_NO_SUCH_PATH: + return CURLE_REMOTE_FILE_NOT_FOUND; - case SSH_FX_PERMISSION_DENIED: - case SSH_FX_WRITE_PROTECT: - return CURLE_REMOTE_ACCESS_DENIED; + case SSH_FX_PERMISSION_DENIED: + case SSH_FX_WRITE_PROTECT: + return CURLE_REMOTE_ACCESS_DENIED; - case SSH_FX_FILE_ALREADY_EXISTS: - return CURLE_REMOTE_FILE_EXISTS; + case SSH_FX_FILE_ALREADY_EXISTS: + return CURLE_REMOTE_FILE_EXISTS; - default: - break; + default: + break; } return CURLE_SSH; @@ -213,7 +212,7 @@ static CURLcode sftp_error_to_CURLE(int err) #if !defined(CURL_DISABLE_VERBOSE_STRINGS) static const char *myssh_statename(sshstate state) { - static const char *const names[] = { + static const char * const names[] = { "SSH_STOP", "SSH_INIT", "SSH_S_STARTUP", @@ -284,7 +283,7 @@ static const char *myssh_statename(sshstate state) #endif /* !CURL_DISABLE_VERBOSE_STRINGS */ -#define myssh_to(x,y,z) myssh_set_state(x,y,z) +#define myssh_to(x, y, z) myssh_set_state(x, y, z) /* * SSH State machine related code @@ -328,8 +327,7 @@ static int myssh_is_known(struct Curl_easy *data, struct ssh_conn *sshc) enum curl_khmatch keymatch; struct curl_khkey foundkey; struct curl_khkey *knownkeyp = NULL; - curl_sshkeycallback func = - data->set.ssh_keyfunc; + curl_sshkeycallback func = data->set.ssh_keyfunc; struct ssh_knownhosts_entry *knownhostsentry = NULL; struct curl_khkey knownkey; @@ -343,8 +341,7 @@ static int myssh_is_known(struct Curl_easy *data, struct ssh_conn *sshc) 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); + 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"); @@ -352,7 +349,7 @@ static int myssh_is_known(struct Curl_easy *data, struct ssh_conn *sshc) } for(i = 0; i < 16; i++) - curl_msnprintf(&md5buffer[i*2], 3, "%02x", (unsigned char)hash[i]); + curl_msnprintf(&md5buffer[i * 2], 3, "%02x", (unsigned char)hash[i]); infof(data, "SSH MD5 fingerprint: %s", md5buffer); @@ -461,7 +458,7 @@ static int myssh_is_known(struct Curl_easy *data, struct ssh_conn *sshc) Curl_set_in_callback(data, TRUE); rc = func(data, knownkeyp, /* from the knownhosts file */ - &foundkey, /* from the remote host */ + &foundkey, /* from the remote host */ keymatch, data->set.ssh_keyfunc_userp); Curl_set_in_callback(data, FALSE); @@ -519,8 +516,7 @@ static int myssh_to_SFTP_CLOSE(struct Curl_easy *data, struct ssh_conn *sshc) { myssh_to(data, sshc, SSH_SFTP_CLOSE); - sshc->actualcode = - sftp_error_to_CURLE(sftp_get_error(sshc->sftp_session)); + sshc->actualcode = sftp_error_to_CURLE(sftp_get_error(sshc->sftp_session)); return SSH_ERROR; } @@ -613,7 +609,6 @@ static int myssh_in_SFTP_READDIR(struct Curl_easy *data, sshc->actualcode = result; return SSH_NO_ERROR; } - } else { if(curlx_dyn_add(&sshc->readdir_buf, sshc->readdir_longentry)) { @@ -684,8 +679,7 @@ static int myssh_in_SFTP_READDIR_LINK(struct Curl_easy *data, Curl_safefree(sshc->readdir_linkPath); - if(curlx_dyn_addf(&sshc->readdir_buf, " -> %s", - sshc->readdir_filename)) { + if(curlx_dyn_addf(&sshc->readdir_buf, " -> %s", sshc->readdir_filename)) { /* Not using: * return myssh_to_SFTP_CLOSE(data, sshc); * @@ -808,56 +802,56 @@ static int myssh_auth_interactive(struct connectdata *conn, restart: switch(sshc->kbd_state) { - case 0: - rc = ssh_userauth_kbdint(sshc->ssh_session, NULL, NULL); - if(rc == SSH_AUTH_AGAIN) - return SSH_AGAIN; + case 0: + rc = ssh_userauth_kbdint(sshc->ssh_session, NULL, NULL); + if(rc == SSH_AUTH_AGAIN) + return SSH_AGAIN; - if(rc != SSH_AUTH_INFO) - return SSH_ERROR; + if(rc != SSH_AUTH_INFO) + return SSH_ERROR; - nprompts = ssh_userauth_kbdint_getnprompts(sshc->ssh_session); - if(nprompts != 1) - return SSH_ERROR; + nprompts = ssh_userauth_kbdint_getnprompts(sshc->ssh_session); + if(nprompts != 1) + return SSH_ERROR; - rc = ssh_userauth_kbdint_setanswer(sshc->ssh_session, 0, conn->passwd); - if(rc < 0) - return SSH_ERROR; + rc = ssh_userauth_kbdint_setanswer(sshc->ssh_session, 0, conn->passwd); + if(rc < 0) + return SSH_ERROR; - FALLTHROUGH(); - case 1: - sshc->kbd_state = 1; + FALLTHROUGH(); + case 1: + sshc->kbd_state = 1; - rc = ssh_userauth_kbdint(sshc->ssh_session, NULL, NULL); - if(rc == SSH_AUTH_AGAIN) - return SSH_AGAIN; - else if(rc == SSH_AUTH_SUCCESS) - rc = SSH_OK; - else if(rc == SSH_AUTH_INFO) { - nprompts = ssh_userauth_kbdint_getnprompts(sshc->ssh_session); - if(nprompts) - return SSH_ERROR; + rc = ssh_userauth_kbdint(sshc->ssh_session, NULL, NULL); + if(rc == SSH_AUTH_AGAIN) + return SSH_AGAIN; + else if(rc == SSH_AUTH_SUCCESS) + rc = SSH_OK; + else if(rc == SSH_AUTH_INFO) { + nprompts = ssh_userauth_kbdint_getnprompts(sshc->ssh_session); + if(nprompts) + return SSH_ERROR; - sshc->kbd_state = 2; - goto restart; - } - else - rc = SSH_ERROR; - break; - case 2: sshc->kbd_state = 2; + goto restart; + } + else + rc = SSH_ERROR; + break; + case 2: + sshc->kbd_state = 2; - rc = ssh_userauth_kbdint(sshc->ssh_session, NULL, NULL); - if(rc == SSH_AUTH_AGAIN) - return SSH_AGAIN; - else if(rc == SSH_AUTH_SUCCESS) - rc = SSH_OK; - else - rc = SSH_ERROR; + rc = ssh_userauth_kbdint(sshc->ssh_session, NULL, NULL); + if(rc == SSH_AUTH_AGAIN) + return SSH_AGAIN; + else if(rc == SSH_AUTH_SUCCESS) + rc = SSH_OK; + else + rc = SSH_ERROR; - break; - default: - return SSH_ERROR; + break; + default: + return SSH_ERROR; } sshc->kbd_state = 0; @@ -967,8 +961,7 @@ static int myssh_in_AUTH_PKEY_INIT(struct Curl_easy *data, * (2) use the "default" keys. */ if(data->set.str[STRING_SSH_PRIVATE_KEY]) { if(sshc->pubkey && !data->set.ssl.key_passwd) { - rc = ssh_userauth_try_publickey(sshc->ssh_session, NULL, - sshc->pubkey); + rc = ssh_userauth_try_publickey(sshc->ssh_session, NULL, sshc->pubkey); if(rc == SSH_AUTH_AGAIN) return SSH_AGAIN; @@ -993,7 +986,7 @@ static int myssh_in_AUTH_PKEY_INIT(struct Curl_easy *data, } else { rc = ssh_userauth_publickey_auto(sshc->ssh_session, NULL, - data->set.ssl.key_passwd); + data->set.ssl.key_passwd); if(rc == SSH_AUTH_AGAIN) return SSH_AGAIN; @@ -1166,7 +1159,7 @@ static int myssh_in_UPLOAD_INIT(struct Curl_easy *data, } else /* Clear file before writing (normal behavior) */ - flags = O_WRONLY|O_CREAT|O_TRUNC; + flags = O_WRONLY | O_CREAT | O_TRUNC; if(sshc->sftp_file) sftp_close(sshc->sftp_file); @@ -1214,7 +1207,7 @@ static int myssh_in_UPLOAD_INIT(struct Curl_easy *data, } /* seekerr == CURL_SEEKFUNC_CANTSEEK (cannot seek to offset) */ do { - char scratch[4*1024]; + char scratch[4 * 1024]; size_t readthisamountnow = (data->state.resume_from - passed > (curl_off_t)sizeof(scratch)) ? @@ -1363,8 +1356,7 @@ static int myssh_in_SFTP_DOWNLOAD_STAT(struct Curl_easy *data, /* Now store the number of bytes we are expected to download */ data->req.size = size - data->state.resume_from; data->req.maxdownload = size - data->state.resume_from; - Curl_pgrsSetDownloadSize(data, - size - data->state.resume_from); + Curl_pgrsSetDownloadSize(data, size - data->state.resume_from); rc = sftp_seek64(sshc->sftp_file, data->state.resume_from); if(rc) @@ -1877,8 +1869,7 @@ static void conn_forget_socket(struct Curl_easy *data, int sockindex) if(conn && CONN_SOCK_IDX_VALID(sockindex)) { struct Curl_cfilter *cf = conn->cfilter[sockindex]; if(cf) - (void)Curl_conn_cf_cntrl(cf, data, TRUE, - CF_CTRL_FORGET_SOCKET, 0, NULL); + (void)Curl_conn_cf_cntrl(cf, data, TRUE, CF_CTRL_FORGET_SOCKET, 0, NULL); fake_sclose(conn->sock[sockindex]); conn->sock[sockindex] = CURL_SOCKET_BAD; } @@ -2067,8 +2058,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, break; if(rc && !sshc->acceptfail) { Curl_safefree(sshc->quote_path1); - failf(data, "rm command failed: %s", - ssh_get_error(sshc->ssh_session)); + failf(data, "rm command failed: %s", ssh_get_error(sshc->ssh_session)); myssh_to(data, sshc, SSH_SFTP_CLOSE); sshc->nextstate = SSH_NO_STATE; sshc->actualcode = CURLE_QUOTE_ERROR; @@ -2110,7 +2100,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, if(data->state.upload) myssh_to(data, sshc, SSH_SFTP_UPLOAD_INIT); else if(sshp) { - if(sshp->path[strlen(sshp->path)-1] == '/') + if(sshp->path[strlen(sshp->path) - 1] == '/') myssh_to(data, sshc, SSH_SFTP_READDIR_INIT); else myssh_to(data, sshc, SSH_SFTP_DOWNLOAD_INIT); @@ -2301,26 +2291,26 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, FALLTHROUGH(); case SSH_SCP_DOWNLOAD: { - curl_off_t bytecount; + curl_off_t bytecount; - rc = ssh_scp_pull_request(sshc->scp_session); - if(rc != SSH_SCP_REQUEST_NEWFILE) { - err_msg = ssh_get_error(sshc->ssh_session); - failf(data, "%s", err_msg); - rc = myssh_to_ERROR(data, sshc, CURLE_REMOTE_FILE_NOT_FOUND); - break; - } + rc = ssh_scp_pull_request(sshc->scp_session); + if(rc != SSH_SCP_REQUEST_NEWFILE) { + err_msg = ssh_get_error(sshc->ssh_session); + failf(data, "%s", err_msg); + rc = myssh_to_ERROR(data, sshc, CURLE_REMOTE_FILE_NOT_FOUND); + break; + } - /* download data */ - bytecount = ssh_scp_request_get_size(sshc->scp_session); - data->req.maxdownload = (curl_off_t) bytecount; - Curl_xfer_setup_recv(data, FIRSTSOCKET, bytecount); + /* download data */ + bytecount = ssh_scp_request_get_size(sshc->scp_session); + data->req.maxdownload = (curl_off_t)bytecount; + Curl_xfer_setup_recv(data, FIRSTSOCKET, bytecount); - /* not set by Curl_xfer_setup to preserve keepon bits */ - conn->send_idx = 0; + /* not set by Curl_xfer_setup to preserve keepon bits */ + conn->send_idx = 0; - myssh_to(data, sshc, SSH_STOP); - break; + myssh_to(data, sshc, SSH_STOP); + break; } case SSH_SCP_DONE: if(data->state.upload) @@ -2406,7 +2396,6 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, sshc->nextstate = SSH_NO_STATE; myssh_to(data, sshc, SSH_STOP); break; - } /* break the loop only on STOP or SSH_AGAIN. If `rc` is some * other error code, we will have progressed the state accordingly. */ @@ -2424,7 +2413,6 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, return result; } - /* called by the multi interface to figure out what socket(s) to wait for and for what actions in the DO_DONE, PERFORM and WAITPERFORM states */ static CURLcode myssh_pollset(struct Curl_easy *data, @@ -2525,7 +2513,6 @@ static CURLcode myssh_block_statemach(struct Curl_easy *data, (void)Curl_socket_check(fd_read, CURL_SOCKET_BAD, CURL_SOCKET_BAD, left_ms > 1000 ? 1000 : left_ms); } - } return result; @@ -2717,9 +2704,8 @@ static CURLcode scp_doing(struct Curl_easy *data, bool *dophase_done) * the options previously setup. */ -static -CURLcode scp_perform(struct Curl_easy *data, - bool *connected, bool *dophase_done) +static CURLcode scp_perform(struct Curl_easy *data, + bool *connected, bool *dophase_done) { CURLcode result = CURLE_OK; struct ssh_conn *sshc = Curl_conn_meta_get(data->conn, CURL_META_SSH_CONN); @@ -2871,7 +2857,6 @@ static CURLcode myssh_done(struct Curl_easy *data, return result; } - static CURLcode scp_done(struct Curl_easy *data, CURLcode status, bool premature) { @@ -2963,10 +2948,9 @@ static CURLcode scp_recv(struct Curl_easy *data, int sockindex, * the options previously setup. */ -static -CURLcode sftp_perform(struct Curl_easy *data, - bool *connected, - bool *dophase_done) +static CURLcode sftp_perform(struct Curl_easy *data, + bool *connected, + bool *dophase_done) { struct ssh_conn *sshc = Curl_conn_meta_get(data->conn, CURL_META_SSH_CONN); CURLcode result = CURLE_OK; @@ -3064,34 +3048,34 @@ static CURLcode sftp_send(struct Curl_easy *data, int sockindex, #if LIBSSH_VERSION_INT > SSH_VERSION_INT(0, 11, 0) switch(sshc->sftp_send_state) { - case 0: - sftp_file_set_nonblocking(sshc->sftp_file); - if(sftp_aio_begin_write(sshc->sftp_file, mem, len, - &sshc->sftp_send_aio) == SSH_ERROR) { - return CURLE_SEND_ERROR; - } - sshc->sftp_send_state = 1; - FALLTHROUGH(); - case 1: - nwrite = sftp_aio_wait_write(&sshc->sftp_send_aio); - myssh_block2waitfor(conn, sshc, (nwrite == SSH_AGAIN) ? TRUE : FALSE); - if(nwrite == SSH_AGAIN) - return CURLE_AGAIN; - else if(nwrite < 0) - return CURLE_SEND_ERROR; - - /* - * sftp_aio_wait_write() would free sftp_send_aio and - * assign it NULL in all cases except when it returns - * SSH_AGAIN. - */ - - sshc->sftp_send_state = 0; - *pnwritten = (size_t)nwrite; - return CURLE_OK; - default: - /* we never reach here */ + case 0: + sftp_file_set_nonblocking(sshc->sftp_file); + if(sftp_aio_begin_write(sshc->sftp_file, mem, len, + &sshc->sftp_send_aio) == SSH_ERROR) { return CURLE_SEND_ERROR; + } + sshc->sftp_send_state = 1; + FALLTHROUGH(); + case 1: + nwrite = sftp_aio_wait_write(&sshc->sftp_send_aio); + myssh_block2waitfor(conn, sshc, (nwrite == SSH_AGAIN) ? TRUE : FALSE); + if(nwrite == SSH_AGAIN) + return CURLE_AGAIN; + else if(nwrite < 0) + return CURLE_SEND_ERROR; + + /* + * sftp_aio_wait_write() would free sftp_send_aio and + * assign it NULL in all cases except when it returns + * SSH_AGAIN. + */ + + sshc->sftp_send_state = 0; + *pnwritten = (size_t)nwrite; + return CURLE_OK; + default: + /* we never reach here */ + return CURLE_SEND_ERROR; } #else /* @@ -3143,54 +3127,53 @@ static CURLcode sftp_recv(struct Curl_easy *data, int sockindex, return CURLE_FAILED_INIT; switch(sshc->sftp_recv_state) { - case 0: + case 0: #if LIBSSH_VERSION_INT > SSH_VERSION_INT(0, 11, 0) - if(sftp_aio_begin_read(sshc->sftp_file, len, - &sshc->sftp_recv_aio) == SSH_ERROR) { - return CURLE_RECV_ERROR; - } + if(sftp_aio_begin_read(sshc->sftp_file, len, + &sshc->sftp_recv_aio) == SSH_ERROR) { + return CURLE_RECV_ERROR; + } #else - sshc->sftp_file_index = - sftp_async_read_begin(sshc->sftp_file, (uint32_t)len); - if(sshc->sftp_file_index < 0) - return CURLE_RECV_ERROR; + sshc->sftp_file_index = + sftp_async_read_begin(sshc->sftp_file, (uint32_t)len); + if(sshc->sftp_file_index < 0) + return CURLE_RECV_ERROR; #endif - FALLTHROUGH(); - case 1: - sshc->sftp_recv_state = 1; + FALLTHROUGH(); + case 1: + sshc->sftp_recv_state = 1; #if LIBSSH_VERSION_INT > SSH_VERSION_INT(0, 11, 0) - nread = sftp_aio_wait_read(&sshc->sftp_recv_aio, mem, len); + nread = sftp_aio_wait_read(&sshc->sftp_recv_aio, mem, len); #else - nread = sftp_async_read(sshc->sftp_file, mem, (uint32_t)len, - (uint32_t)sshc->sftp_file_index); + nread = sftp_async_read(sshc->sftp_file, mem, (uint32_t)len, + (uint32_t)sshc->sftp_file_index); #endif - myssh_block2waitfor(conn, sshc, (nread == SSH_AGAIN)); + myssh_block2waitfor(conn, sshc, (nread == SSH_AGAIN)); - if(nread == SSH_AGAIN) - return CURLE_AGAIN; - else if(nread < 0) - return CURLE_RECV_ERROR; + if(nread == SSH_AGAIN) + return CURLE_AGAIN; + else if(nread < 0) + return CURLE_RECV_ERROR; - /* - * sftp_aio_wait_read() would free sftp_recv_aio and - * assign it NULL in all cases except when it returns - * SSH_AGAIN. - */ + /* + * sftp_aio_wait_read() would free sftp_recv_aio and + * assign it NULL in all cases except when it returns + * SSH_AGAIN. + */ - sshc->sftp_recv_state = 0; - *pnread = (size_t)nread; - return CURLE_OK; + sshc->sftp_recv_state = 0; + *pnread = (size_t)nread; + return CURLE_OK; - default: - /* we never reach here */ - return CURLE_RECV_ERROR; + default: + /* we never reach here */ + return CURLE_RECV_ERROR; } } - CURLcode Curl_ssh_init(void) { if(ssh_init()) { @@ -3210,4 +3193,4 @@ void Curl_ssh_version(char *buffer, size_t buflen) (void)curl_msnprintf(buffer, buflen, "libssh/%s", ssh_version(0)); } -#endif /* USE_LIBSSH */ +#endif /* USE_LIBSSH */ diff --git a/lib/vssh/libssh2.c b/lib/vssh/libssh2.c index ce593d54874a..8701775d7d94 100644 --- a/lib/vssh/libssh2.c +++ b/lib/vssh/libssh2.c @@ -154,12 +154,12 @@ const struct Curl_handler Curl_handler_sftp = { PROTOPT_NOURLQUERY | PROTOPT_CONN_REUSE }; -static void -kbd_callback(const char *name, int name_len, const char *instruction, - int instruction_len, int num_prompts, - const LIBSSH2_USERAUTH_KBDINT_PROMPT *prompts, - LIBSSH2_USERAUTH_KBDINT_RESPONSE *responses, - void **abstract) +static void kbd_callback(const char *name, int name_len, + const char *instruction, int instruction_len, + int num_prompts, + const LIBSSH2_USERAUTH_KBDINT_PROMPT *prompts, + LIBSSH2_USERAUTH_KBDINT_RESPONSE *responses, + void **abstract) { struct Curl_easy *data = (struct Curl_easy *)*abstract; @@ -187,30 +187,30 @@ kbd_callback(const char *name, int name_len, const char *instruction, static CURLcode sftp_libssh2_error_to_CURLE(unsigned long err) { switch(err) { - case LIBSSH2_FX_OK: - return CURLE_OK; + case LIBSSH2_FX_OK: + return CURLE_OK; - case LIBSSH2_FX_NO_SUCH_FILE: - case LIBSSH2_FX_NO_SUCH_PATH: - return CURLE_REMOTE_FILE_NOT_FOUND; + case LIBSSH2_FX_NO_SUCH_FILE: + case LIBSSH2_FX_NO_SUCH_PATH: + return CURLE_REMOTE_FILE_NOT_FOUND; - case LIBSSH2_FX_PERMISSION_DENIED: - case LIBSSH2_FX_WRITE_PROTECT: - case LIBSSH2_FX_LOCK_CONFlICT: - return CURLE_REMOTE_ACCESS_DENIED; + case LIBSSH2_FX_PERMISSION_DENIED: + case LIBSSH2_FX_WRITE_PROTECT: + case LIBSSH2_FX_LOCK_CONFlICT: + return CURLE_REMOTE_ACCESS_DENIED; - case LIBSSH2_FX_NO_SPACE_ON_FILESYSTEM: - case LIBSSH2_FX_QUOTA_EXCEEDED: - return CURLE_REMOTE_DISK_FULL; + case LIBSSH2_FX_NO_SPACE_ON_FILESYSTEM: + case LIBSSH2_FX_QUOTA_EXCEEDED: + return CURLE_REMOTE_DISK_FULL; - case LIBSSH2_FX_FILE_ALREADY_EXISTS: - return CURLE_REMOTE_FILE_EXISTS; + case LIBSSH2_FX_FILE_ALREADY_EXISTS: + return CURLE_REMOTE_FILE_EXISTS; - case LIBSSH2_FX_DIR_NOT_EMPTY: - return CURLE_QUOTE_ERROR; + case LIBSSH2_FX_DIR_NOT_EMPTY: + return CURLE_QUOTE_ERROR; - default: - break; + default: + break; } return CURLE_SSH; @@ -219,39 +219,39 @@ static CURLcode sftp_libssh2_error_to_CURLE(unsigned long err) static CURLcode libssh2_session_error_to_CURLE(int err) { switch(err) { - /* Ordered by order of appearance in libssh2.h */ - case LIBSSH2_ERROR_NONE: - return CURLE_OK; + /* Ordered by order of appearance in libssh2.h */ + case LIBSSH2_ERROR_NONE: + return CURLE_OK; - /* This is the error returned by libssh2_scp_recv2 - * on unknown file */ - case LIBSSH2_ERROR_SCP_PROTOCOL: - return CURLE_REMOTE_FILE_NOT_FOUND; + /* This is the error returned by libssh2_scp_recv2 + * on unknown file */ + case LIBSSH2_ERROR_SCP_PROTOCOL: + return CURLE_REMOTE_FILE_NOT_FOUND; - case LIBSSH2_ERROR_SOCKET_NONE: - return CURLE_COULDNT_CONNECT; + case LIBSSH2_ERROR_SOCKET_NONE: + return CURLE_COULDNT_CONNECT; - case LIBSSH2_ERROR_ALLOC: - return CURLE_OUT_OF_MEMORY; + case LIBSSH2_ERROR_ALLOC: + return CURLE_OUT_OF_MEMORY; - case LIBSSH2_ERROR_SOCKET_SEND: - return CURLE_SEND_ERROR; + case LIBSSH2_ERROR_SOCKET_SEND: + return CURLE_SEND_ERROR; - case LIBSSH2_ERROR_HOSTKEY_INIT: - case LIBSSH2_ERROR_HOSTKEY_SIGN: - case LIBSSH2_ERROR_PUBLICKEY_UNRECOGNIZED: - case LIBSSH2_ERROR_PUBLICKEY_UNVERIFIED: - return CURLE_PEER_FAILED_VERIFICATION; + case LIBSSH2_ERROR_HOSTKEY_INIT: + case LIBSSH2_ERROR_HOSTKEY_SIGN: + case LIBSSH2_ERROR_PUBLICKEY_UNRECOGNIZED: + case LIBSSH2_ERROR_PUBLICKEY_UNVERIFIED: + return CURLE_PEER_FAILED_VERIFICATION; - case LIBSSH2_ERROR_PASSWORD_EXPIRED: - return CURLE_LOGIN_DENIED; + case LIBSSH2_ERROR_PASSWORD_EXPIRED: + return CURLE_LOGIN_DENIED; - case LIBSSH2_ERROR_SOCKET_TIMEOUT: - case LIBSSH2_ERROR_TIMEOUT: - return CURLE_OPERATION_TIMEDOUT; + case LIBSSH2_ERROR_SOCKET_TIMEOUT: + case LIBSSH2_ERROR_TIMEOUT: + return CURLE_OPERATION_TIMEDOUT; - case LIBSSH2_ERROR_EAGAIN: - return CURLE_AGAIN; + case LIBSSH2_ERROR_EAGAIN: + return CURLE_AGAIN; } return CURLE_SSH; @@ -283,7 +283,7 @@ static LIBSSH2_FREE_FUNC(my_libssh2_free) #if !defined(CURL_DISABLE_VERBOSE_STRINGS) static const char *myssh_statename(sshstate state) { - static const char *const names[] = { + static const char * const names[] = { "SSH_STOP", "SSH_INIT", "SSH_S_STARTUP", @@ -354,7 +354,7 @@ static const char *myssh_statename(sshstate state) #endif /* !CURL_DISABLE_VERBOSE_STRINGS */ -#define myssh_state(x,y,z) myssh_set_state(x,y,z) +#define myssh_state(x, y, z) myssh_set_state(x, y, z) /* * SSH State machine related code @@ -663,7 +663,7 @@ static CURLcode ssh_check_fingerprint(struct Curl_easy *data, /* The fingerprint points to static storage (!), do not free() it. */ int i; for(i = 0; i < 16; i++) { - curl_msnprintf(&md5buffer[i*2], 3, "%02x", + curl_msnprintf(&md5buffer[i * 2], 3, "%02x", (unsigned char)fingerprint[i]); } @@ -703,7 +703,7 @@ static CURLcode ssh_check_fingerprint(struct Curl_easy *data, rc = data->set.ssh_hostkeyfunc(data->set.ssh_hostkeyfunc_userp, (int)keytype, remotekey, keylen); Curl_set_in_callback(data, FALSE); - if(rc!= CURLKHMATCH_OK) { + if(rc != CURLKHMATCH_OK) { myssh_state(data, sshc, SSH_SESSION_FREE); return CURLE_PEER_FAILED_VERIFICATION; } @@ -1009,11 +1009,10 @@ static CURLcode sftp_quote(struct Curl_easy *data, return CURLE_QUOTE_ERROR; } -static CURLcode -sftp_upload_init(struct Curl_easy *data, - struct ssh_conn *sshc, - struct SSHPROTO *sshp, - bool *blockp) +static CURLcode sftp_upload_init(struct Curl_easy *data, + struct ssh_conn *sshc, + struct SSHPROTO *sshp, + bool *blockp) { unsigned long flags; @@ -1140,7 +1139,7 @@ sftp_upload_init(struct Curl_easy *data, } /* seekerr == CURL_SEEKFUNC_CANTSEEK (cannot seek to offset) */ do { - char scratch[4*1024]; + char scratch[4 * 1024]; size_t readthisamountnow = (data->state.resume_from - passed > (curl_off_t)sizeof(scratch)) ? @@ -1283,11 +1282,10 @@ static CURLcode ssh_state_pkey_init(struct Curl_easy *data, return 0; } -static CURLcode -sftp_quote_stat(struct Curl_easy *data, - struct ssh_conn *sshc, - struct SSHPROTO *sshp, - bool *blockp) +static CURLcode sftp_quote_stat(struct Curl_easy *data, + struct ssh_conn *sshc, + struct SSHPROTO *sshp, + bool *blockp) { char *cmd = sshc->quote_item->data; sshc->acceptfail = FALSE; @@ -1395,11 +1393,10 @@ sftp_quote_stat(struct Curl_easy *data, return CURLE_QUOTE_ERROR; } -static CURLcode -sftp_download_stat(struct Curl_easy *data, - struct ssh_conn *sshc, - struct SSHPROTO *sshp, - bool *blockp) +static CURLcode sftp_download_stat(struct Curl_easy *data, + struct ssh_conn *sshc, + struct SSHPROTO *sshp, + bool *blockp) { LIBSSH2_SFTP_ATTRIBUTES attrs; int rc = libssh2_sftp_stat_ex(sshc->sftp_session, sshp->path, @@ -1468,8 +1465,7 @@ sftp_download_stat(struct Curl_easy *data, /* Now store the number of bytes we are expected to download */ data->req.size = attrs.filesize - data->state.resume_from; data->req.maxdownload = attrs.filesize - data->state.resume_from; - Curl_pgrsSetDownloadSize(data, - attrs.filesize - data->state.resume_from); + Curl_pgrsSetDownloadSize(data, attrs.filesize - data->state.resume_from); libssh2_sftp_seek64(sshc->sftp_handle, (libssh2_uint64_t)data->state.resume_from); } @@ -1507,7 +1503,7 @@ static CURLcode sftp_readdir(struct Curl_easy *data, return result; } if(rc > 0) { - size_t readdir_len = (size_t) rc; + size_t readdir_len = (size_t)rc; sshp->readdir_filename[readdir_len] = '\0'; if(data->set.list_only) { @@ -1639,8 +1635,7 @@ static CURLcode ssh_state_authlist(struct Curl_easy *data, myssh_state(data, sshc, SSH_SESSION_FREE); return libssh2_session_error_to_CURLE(rc); } - infof(data, "SSH authentication methods available: %s", - sshc->authlist); + infof(data, "SSH authentication methods available: %s", sshc->authlist); myssh_state(data, sshc, SSH_AUTH_PKEY_INIT); return CURLE_OK; @@ -1679,8 +1674,7 @@ static CURLcode ssh_state_auth_pkey(struct Curl_easy *data, err_msg = unknown; } else { - (void)libssh2_session_last_error(sshc->ssh_session, - &err_msg, NULL, 0); + (void)libssh2_session_last_error(sshc->ssh_session, &err_msg, NULL, 0); } infof(data, "SSH public key authentication failed: %s", err_msg); myssh_state(data, sshc, SSH_AUTH_PASS_INIT); @@ -1742,8 +1736,8 @@ static CURLcode ssh_state_auth_agent_init(struct Curl_easy *data, struct ssh_conn *sshc) { int rc = 0; - if((data->set.ssh_auth_types & CURLSSH_AUTH_AGENT) - && (strstr(sshc->authlist, "publickey") != NULL)) { + if((data->set.ssh_auth_types & CURLSSH_AUTH_AGENT) && + (strstr(sshc->authlist, "publickey") != NULL)) { /* Connect to the ssh-agent */ /* The agent could be shared by a curl thread i believe @@ -1838,8 +1832,8 @@ static CURLcode ssh_state_auth_agent(struct Curl_easy *data, static CURLcode ssh_state_auth_key_init(struct Curl_easy *data, struct ssh_conn *sshc) { - if((data->set.ssh_auth_types & CURLSSH_AUTH_KEYBOARD) - && (strstr(sshc->authlist, "keyboard-interactive") != NULL)) { + if((data->set.ssh_auth_types & CURLSSH_AUTH_KEYBOARD) && + (strstr(sshc->authlist, "keyboard-interactive") != NULL)) { myssh_state(data, sshc, SSH_AUTH_KEY); } else { @@ -1913,8 +1907,7 @@ static CURLcode ssh_state_sftp_init(struct Curl_easy *data, LIBSSH2_ERROR_EAGAIN) return CURLE_AGAIN; - (void)libssh2_session_last_error(sshc->ssh_session, - &err_msg, NULL, 0); + (void)libssh2_session_last_error(sshc->ssh_session, &err_msg, NULL, 0); failf(data, "Failure initializing sftp session: %s", err_msg); myssh_state(data, sshc, SSH_SESSION_FREE); return CURLE_FAILED_INIT; @@ -2384,8 +2377,7 @@ static CURLcode ssh_state_scp_download_init(struct Curl_easy *data, LIBSSH2_ERROR_EAGAIN) return CURLE_AGAIN; - ssh_err = (int)(libssh2_session_last_error(sshc->ssh_session, - &err_msg, NULL, 0)); + ssh_err = libssh2_session_last_error(sshc->ssh_session, &err_msg, NULL, 0); failf(data, "%s", err_msg); myssh_state(data, sshc, SSH_SCP_CHANNEL_FREE); return libssh2_session_error_to_CURLE(ssh_err); @@ -2415,8 +2407,7 @@ static CURLcode ssh_state_sftp_close(struct Curl_easy *data, if(rc < 0) { char *err_msg = NULL; - (void)libssh2_session_last_error(sshc->ssh_session, - &err_msg, NULL, 0); + (void)libssh2_session_last_error(sshc->ssh_session, &err_msg, NULL, 0); infof(data, "Failed to close libssh2 file: %d %s", rc, err_msg); } sshc->sftp_handle = NULL; @@ -2454,8 +2445,7 @@ static CURLcode ssh_state_sftp_shutdown(struct Curl_easy *data, if(rc < 0) { char *err_msg = NULL; - (void)libssh2_session_last_error(sshc->ssh_session, &err_msg, - NULL, 0); + (void)libssh2_session_last_error(sshc->ssh_session, &err_msg, NULL, 0); infof(data, "Failed to close libssh2 file: %d %s", rc, err_msg); } sshc->sftp_handle = NULL; @@ -2527,8 +2517,7 @@ static CURLcode ssh_state_scp_upload_init(struct Curl_easy *data, LIBSSH2_ERROR_EAGAIN) return CURLE_AGAIN; - ssh_err = (int)(libssh2_session_last_error(sshc->ssh_session, - &err_msg, NULL, 0)); + ssh_err = libssh2_session_last_error(sshc->ssh_session, &err_msg, NULL, 0); failf(data, "%s", err_msg); myssh_state(data, sshc, SSH_SCP_CHANNEL_FREE); result = libssh2_session_error_to_CURLE(ssh_err); @@ -2567,10 +2556,8 @@ static CURLcode ssh_state_session_disconnect(struct Curl_easy *data, if(rc < 0) { char *err_msg = NULL; - (void)libssh2_session_last_error(sshc->ssh_session, - &err_msg, NULL, 0); - infof(data, "Failed to free libssh2 scp subsystem: %d %s", - rc, err_msg); + (void)libssh2_session_last_error(sshc->ssh_session, &err_msg, NULL, 0); + infof(data, "Failed to free libssh2 scp subsystem: %d %s", rc, err_msg); } sshc->ssh_channel = NULL; } @@ -2582,10 +2569,8 @@ static CURLcode ssh_state_session_disconnect(struct Curl_easy *data, if(rc < 0) { char *err_msg = NULL; - (void)libssh2_session_last_error(sshc->ssh_session, - &err_msg, NULL, 0); - infof(data, "Failed to disconnect libssh2 session: %d %s", - rc, err_msg); + (void)libssh2_session_last_error(sshc->ssh_session, &err_msg, NULL, 0); + infof(data, "Failed to disconnect libssh2 session: %d %s", rc, err_msg); } } @@ -2750,8 +2735,7 @@ static CURLcode ssh_statemachine(struct Curl_easy *data, } break; - case SSH_SFTP_FILETIME: - { + case SSH_SFTP_FILETIME: { LIBSSH2_SFTP_ATTRIBUTES attrs; int rc; @@ -2778,7 +2762,7 @@ static CURLcode ssh_statemachine(struct Curl_easy *data, if(data->state.upload) myssh_state(data, sshc, SSH_SFTP_UPLOAD_INIT); else if(sshp) { - if(sshp->path[strlen(sshp->path)-1] == '/') + if(sshp->path[strlen(sshp->path) - 1] == '/') myssh_state(data, sshc, SSH_SFTP_READDIR_INIT); else myssh_state(data, sshc, SSH_SFTP_DOWNLOAD_INIT); @@ -3097,8 +3081,8 @@ static void ssh_block2waitfor(struct Curl_easy *data, dir = libssh2_session_block_directions(sshc->ssh_session); if(dir) { /* translate the libssh2 define bits into our own bit defines */ - sshc->waitfor = ((dir&LIBSSH2_SESSION_BLOCK_INBOUND) ? KEEP_RECV : 0) | - ((dir&LIBSSH2_SESSION_BLOCK_OUTBOUND) ? KEEP_SEND : 0); + sshc->waitfor = ((dir & LIBSSH2_SESSION_BLOCK_INBOUND) ? KEEP_RECV : 0) | + ((dir & LIBSSH2_SESSION_BLOCK_OUTBOUND) ? KEEP_SEND : 0); } } if(!dir) @@ -3308,24 +3292,24 @@ static CURLcode ssh_connect(struct Curl_easy *data, bool *done) { const char *crypto_str; switch(libssh2_crypto_engine()) { - case libssh2_gcrypt: - crypto_str = "libgcrypt"; - break; - case libssh2_mbedtls: - crypto_str = "mbedTLS"; - break; - case libssh2_openssl: - crypto_str = "openssl compatible"; - break; - case libssh2_os400qc3: - crypto_str = "OS400QC3"; - break; - case libssh2_wincng: - crypto_str = "WinCNG"; - break; - default: - crypto_str = NULL; - break; + case libssh2_gcrypt: + crypto_str = "libgcrypt"; + break; + case libssh2_mbedtls: + crypto_str = "mbedTLS"; + break; + case libssh2_openssl: + crypto_str = "openssl compatible"; + break; + case libssh2_os400qc3: + crypto_str = "OS400QC3"; + break; + case libssh2_wincng: + crypto_str = "WinCNG"; + break; + default: + crypto_str = NULL; + break; } if(crypto_str) infof(data, "libssh2 cryptography backend: %s", crypto_str); @@ -3476,10 +3460,9 @@ static CURLcode ssh_connect(struct Curl_easy *data, bool *done) * the options previously setup. */ -static -CURLcode scp_perform(struct Curl_easy *data, - bool *connected, - bool *dophase_done) +static CURLcode scp_perform(struct Curl_easy *data, + bool *connected, + bool *dophase_done) { struct ssh_conn *sshc = Curl_conn_meta_get(data->conn, CURL_META_SSH_CONN); CURLcode result = CURLE_OK; @@ -3562,8 +3545,7 @@ static CURLcode sshc_cleanup(struct ssh_conn *sshc, struct Curl_easy *data, rc = libssh2_agent_disconnect(sshc->ssh_agent); if((rc < 0) && data) { char *err_msg = NULL; - (void)libssh2_session_last_error(sshc->ssh_session, - &err_msg, NULL, 0); + (void)libssh2_session_last_error(sshc->ssh_session, &err_msg, NULL, 0); infof(data, "Failed to disconnect from libssh2 agent: %d %s", rc, err_msg); } @@ -3583,8 +3565,7 @@ static CURLcode sshc_cleanup(struct ssh_conn *sshc, struct Curl_easy *data, rc = libssh2_sftp_close(sshc->sftp_handle); if((rc < 0) && data) { char *err_msg = NULL; - (void)libssh2_session_last_error(sshc->ssh_session, &err_msg, - NULL, 0); + (void)libssh2_session_last_error(sshc->ssh_session, &err_msg, NULL, 0); infof(data, "Failed to close libssh2 file: %d %s", rc, err_msg); } if(!block && (rc == LIBSSH2_ERROR_EAGAIN)) @@ -3597,10 +3578,8 @@ static CURLcode sshc_cleanup(struct ssh_conn *sshc, struct Curl_easy *data, rc = libssh2_channel_free(sshc->ssh_channel); if((rc < 0) && data) { char *err_msg = NULL; - (void)libssh2_session_last_error(sshc->ssh_session, - &err_msg, NULL, 0); - infof(data, "Failed to free libssh2 scp subsystem: %d %s", - rc, err_msg); + (void)libssh2_session_last_error(sshc->ssh_session, &err_msg, NULL, 0); + infof(data, "Failed to free libssh2 scp subsystem: %d %s", rc, err_msg); } if(!block && (rc == LIBSSH2_ERROR_EAGAIN)) return CURLE_AGAIN; @@ -3612,8 +3591,7 @@ static CURLcode sshc_cleanup(struct ssh_conn *sshc, struct Curl_easy *data, rc = libssh2_sftp_shutdown(sshc->sftp_session); if((rc < 0) && data) { char *err_msg = NULL; - (void)libssh2_session_last_error(sshc->ssh_session, - &err_msg, NULL, 0); + (void)libssh2_session_last_error(sshc->ssh_session, &err_msg, NULL, 0); infof(data, "Failed to stop libssh2 sftp subsystem: %d %s", rc, err_msg); } if(!block && (rc == LIBSSH2_ERROR_EAGAIN)) @@ -3626,8 +3604,7 @@ static CURLcode sshc_cleanup(struct ssh_conn *sshc, struct Curl_easy *data, rc = libssh2_session_free(sshc->ssh_session); if((rc < 0) && data) { char *err_msg = NULL; - (void)libssh2_session_last_error(sshc->ssh_session, - &err_msg, NULL, 0); + (void)libssh2_session_last_error(sshc->ssh_session, &err_msg, NULL, 0); infof(data, "Failed to free libssh2 session: %d %s", rc, err_msg); } if(!block && (rc == LIBSSH2_ERROR_EAGAIN)) @@ -3653,7 +3630,6 @@ static CURLcode sshc_cleanup(struct ssh_conn *sshc, struct Curl_easy *data, return CURLE_OK; } - /* BLOCKING, but the function is using the state machine so the only reason this is still blocking is that the multi interface code has no support for disconnecting operations that takes a while */ @@ -3701,7 +3677,6 @@ static CURLcode ssh_done(struct Curl_easy *data, CURLcode status) return result; } - static CURLcode scp_done(struct Curl_easy *data, CURLcode status, bool premature) { @@ -3731,8 +3706,8 @@ static CURLcode scp_send(struct Curl_easy *data, int sockindex, return CURLE_FAILED_INIT; /* libssh2_channel_write() returns int! */ - nwritten = (ssize_t) libssh2_channel_write(sshc->ssh_channel, - (const char *)mem, len); + nwritten = (ssize_t)libssh2_channel_write(sshc->ssh_channel, + (const char *)mem, len); ssh_block2waitfor(data, sshc, (nwritten == LIBSSH2_ERROR_EAGAIN)); @@ -3761,7 +3736,7 @@ static CURLcode scp_recv(struct Curl_easy *data, int sockindex, return CURLE_FAILED_INIT; /* libssh2_channel_read() returns int */ - nread = (ssize_t) libssh2_channel_read(sshc->ssh_channel, mem, len); + nread = (ssize_t)libssh2_channel_read(sshc->ssh_channel, mem, len); ssh_block2waitfor(data, sshc, (nread == LIBSSH2_ERROR_EAGAIN)); if(nread == LIBSSH2_ERROR_EAGAIN) @@ -3787,10 +3762,9 @@ static CURLcode scp_recv(struct Curl_easy *data, int sockindex, * the options previously setup. */ -static -CURLcode sftp_perform(struct Curl_easy *data, - bool *connected, - bool *dophase_done) +static CURLcode sftp_perform(struct Curl_easy *data, + bool *connected, + bool *dophase_done) { struct ssh_conn *sshc = Curl_conn_meta_get(data->conn, CURL_META_SSH_CONN); CURLcode result = CURLE_OK; @@ -3850,7 +3824,6 @@ static CURLcode sftp_disconnect(struct Curl_easy *data, sshc_cleanup(sshc, data, TRUE); } return result; - } static CURLcode sftp_done(struct Curl_easy *data, CURLcode status, @@ -3934,65 +3907,65 @@ static CURLcode sftp_recv(struct Curl_easy *data, int sockindex, static const char *sftp_libssh2_strerror(unsigned long err) { switch(err) { - case LIBSSH2_FX_NO_SUCH_FILE: - return "No such file or directory"; + case LIBSSH2_FX_NO_SUCH_FILE: + return "No such file or directory"; - case LIBSSH2_FX_PERMISSION_DENIED: - return "Permission denied"; + case LIBSSH2_FX_PERMISSION_DENIED: + return "Permission denied"; - case LIBSSH2_FX_FAILURE: - return "Operation failed"; + case LIBSSH2_FX_FAILURE: + return "Operation failed"; - case LIBSSH2_FX_BAD_MESSAGE: - return "Bad message from SFTP server"; + case LIBSSH2_FX_BAD_MESSAGE: + return "Bad message from SFTP server"; - case LIBSSH2_FX_NO_CONNECTION: - return "Not connected to SFTP server"; + case LIBSSH2_FX_NO_CONNECTION: + return "Not connected to SFTP server"; - case LIBSSH2_FX_CONNECTION_LOST: - return "Connection to SFTP server lost"; + case LIBSSH2_FX_CONNECTION_LOST: + return "Connection to SFTP server lost"; - case LIBSSH2_FX_OP_UNSUPPORTED: - return "Operation not supported by SFTP server"; + case LIBSSH2_FX_OP_UNSUPPORTED: + return "Operation not supported by SFTP server"; - case LIBSSH2_FX_INVALID_HANDLE: - return "Invalid handle"; + case LIBSSH2_FX_INVALID_HANDLE: + return "Invalid handle"; - case LIBSSH2_FX_NO_SUCH_PATH: - return "No such file or directory"; + case LIBSSH2_FX_NO_SUCH_PATH: + return "No such file or directory"; - case LIBSSH2_FX_FILE_ALREADY_EXISTS: - return "File already exists"; + case LIBSSH2_FX_FILE_ALREADY_EXISTS: + return "File already exists"; - case LIBSSH2_FX_WRITE_PROTECT: - return "File is write protected"; + case LIBSSH2_FX_WRITE_PROTECT: + return "File is write protected"; - case LIBSSH2_FX_NO_MEDIA: - return "No media"; + case LIBSSH2_FX_NO_MEDIA: + return "No media"; - case LIBSSH2_FX_NO_SPACE_ON_FILESYSTEM: - return "Disk full"; + case LIBSSH2_FX_NO_SPACE_ON_FILESYSTEM: + return "Disk full"; - case LIBSSH2_FX_QUOTA_EXCEEDED: - return "User quota exceeded"; + case LIBSSH2_FX_QUOTA_EXCEEDED: + return "User quota exceeded"; - case LIBSSH2_FX_UNKNOWN_PRINCIPLE: - return "Unknown principle"; + case LIBSSH2_FX_UNKNOWN_PRINCIPLE: + return "Unknown principle"; - case LIBSSH2_FX_LOCK_CONFlICT: - return "File lock conflict"; + case LIBSSH2_FX_LOCK_CONFlICT: + return "File lock conflict"; - case LIBSSH2_FX_DIR_NOT_EMPTY: - return "Directory not empty"; + case LIBSSH2_FX_DIR_NOT_EMPTY: + return "Directory not empty"; - case LIBSSH2_FX_NOT_A_DIRECTORY: - return "Not a directory"; + case LIBSSH2_FX_NOT_A_DIRECTORY: + return "Not a directory"; - case LIBSSH2_FX_INVALID_FILENAME: - return "Invalid filename"; + case LIBSSH2_FX_INVALID_FILENAME: + return "Invalid filename"; - case LIBSSH2_FX_LINK_LOOP: - return "Link points to itself"; + case LIBSSH2_FX_LINK_LOOP: + return "Link points to itself"; } return "Unknown error in libssh2"; } diff --git a/lib/vssh/ssh.h b/lib/vssh/ssh.h index 92ae72a6a761..ad0875f19143 100644 --- a/lib/vssh/ssh.h +++ b/lib/vssh/ssh.h @@ -217,7 +217,7 @@ struct ssh_conn { #ifdef USE_LIBSSH #if LIBSSH_VERSION_INT < SSH_VERSION_INT(0, 9, 0) -# error "SCP/SFTP protocols require libssh 0.9.0 or later" +#error "SCP/SFTP protocols require libssh 0.9.0 or later" #endif #endif @@ -227,7 +227,7 @@ struct ssh_conn { non-configure platforms */ #if !defined(LIBSSH2_VERSION_NUM) || (LIBSSH2_VERSION_NUM < 0x010208) -# error "SCP/SFTP protocols require libssh2 1.2.8 or later" +#error "SCP/SFTP protocols require libssh2 1.2.8 or later" /* 1.2.8 was released on April 5 2011 */ #endif @@ -247,7 +247,7 @@ void Curl_ssh_attach(struct Curl_easy *data, #else /* for non-SSH builds */ #define Curl_ssh_cleanup() -#define Curl_ssh_attach(x,y) +#define Curl_ssh_attach(x, y) #define Curl_ssh_init() 0 #endif diff --git a/lib/vssh/vssh.c b/lib/vssh/vssh.c index a23f9e8e981f..bfc0a1eb3ab6 100644 --- a/lib/vssh/vssh.c +++ b/lib/vssh/vssh.c @@ -75,7 +75,7 @@ CURLcode Curl_getworkingpath(struct Curl_easy *data, /* Copy a separating '/' if homedir does not end with one */ len = curlx_dyn_len(&npath); p = curlx_dyn_ptr(&npath); - if(len && (p[len-1] != '/')) + if(len && (p[len - 1] != '/')) copyfrom = 2; if(curlx_dyn_addn(&npath, &working_path[copyfrom], @@ -147,7 +147,6 @@ CURLcode Curl_get_pathname(const char **cpp, char **path, const char *homedir) if(!curlx_dyn_len(&out)) goto fail; - } else { struct Curl_str word; diff --git a/lib/vtls/apple.c b/lib/vtls/apple.c index 62bb9e3bd194..31108763a02a 100644 --- a/lib/vtls/apple.c +++ b/lib/vtls/apple.c @@ -207,8 +207,7 @@ CURLcode Curl_vtls_apple_verify(struct Curl_cfilter *cf, #if defined(HAVE_BUILTIN_AVAILABLE) && defined(SUPPORTS_SecOCSP) if(ocsp_len > 0) { if(__builtin_available(macOS 10.9, iOS 7, tvOS 9, watchOS 2, *)) { - CFDataRef ocspdata = - CFDataCreate(NULL, ocsp_buf, (CFIndex)ocsp_len); + CFDataRef ocspdata = CFDataCreate(NULL, ocsp_buf, (CFIndex)ocsp_len); status = SecTrustSetOCSPResponse(trust, ocspdata); CFRelease(ocspdata); @@ -243,7 +242,7 @@ CURLcode Curl_vtls_apple_verify(struct Curl_cfilter *cf, err_desc = curlx_malloc(size + 1); if(err_desc) { if(!CFStringGetCString(error_ref, err_desc, size, - kCFStringEncodingUTF8)) { + kCFStringEncodingUTF8)) { curlx_free(err_desc); err_desc = NULL; } diff --git a/lib/vtls/cipher_suite.c b/lib/vtls/cipher_suite.c index 23fb3a3c5d16..3726187d7fcc 100644 --- a/lib/vtls/cipher_suite.c +++ b/lib/vtls/cipher_suite.c @@ -547,8 +547,7 @@ static const struct cs_entry cs_list [] = { }; #define CS_LIST_LEN CURL_ARRAYSIZE(cs_list) -static int cs_str_to_zip(const char *cs_str, size_t cs_len, - uint8_t zip[6]) +static int cs_str_to_zip(const char *cs_str, size_t cs_len, uint8_t zip[6]) { uint8_t indexes[8] = {0}; const char *entry, *cur; @@ -568,7 +567,8 @@ static int cs_str_to_zip(const char *cs_str, size_t cs_len, /* determine the length of the part */ cur = nxt; - for(; nxt < end && *nxt != '\0' && *nxt != separator; nxt++); + for(; nxt < end && *nxt != '\0' && *nxt != separator; nxt++) + ; len = nxt - cur; /* lookup index for the part (skip empty string at 0) */ @@ -581,22 +581,21 @@ static int cs_str_to_zip(const char *cs_str, size_t cs_len, if(idx == CS_TXT_LEN) return -1; - indexes[i++] = (uint8_t) idx; + indexes[i++] = (uint8_t)idx; } while(nxt < end && *(nxt++) != '\0'); /* zip the 8 indexes into 48 bits */ - zip[0] = (uint8_t) (indexes[0] << 2 | (indexes[1] & 0x3F) >> 4); - zip[1] = (uint8_t) (indexes[1] << 4 | (indexes[2] & 0x3F) >> 2); - zip[2] = (uint8_t) (indexes[2] << 6 | (indexes[3] & 0x3F)); - zip[3] = (uint8_t) (indexes[4] << 2 | (indexes[5] & 0x3F) >> 4); - zip[4] = (uint8_t) (indexes[5] << 4 | (indexes[6] & 0x3F) >> 2); - zip[5] = (uint8_t) (indexes[6] << 6 | (indexes[7] & 0x3F)); + zip[0] = (uint8_t)(indexes[0] << 2 | (indexes[1] & 0x3F) >> 4); + zip[1] = (uint8_t)(indexes[1] << 4 | (indexes[2] & 0x3F) >> 2); + zip[2] = (uint8_t)(indexes[2] << 6 | (indexes[3] & 0x3F)); + zip[3] = (uint8_t)(indexes[4] << 2 | (indexes[5] & 0x3F) >> 4); + zip[4] = (uint8_t)(indexes[5] << 4 | (indexes[6] & 0x3F) >> 2); + zip[5] = (uint8_t)(indexes[6] << 6 | (indexes[7] & 0x3F)); return 0; } -static int cs_zip_to_str(const uint8_t zip[6], - char *buf, size_t buf_size) +static int cs_zip_to_str(const uint8_t zip[6], char *buf, size_t buf_size) { uint8_t indexes[8] = {0}; const char *entry; @@ -659,13 +658,12 @@ uint16_t Curl_cipher_suite_lookup_id(const char *cs_str, size_t cs_len) static bool cs_is_separator(char c) { switch(c) { - case ' ': - case '\t': - case ':': - case ',': - case ';': - return TRUE; - default:; + case ' ': + case '\t': + case ':': + case ',': + case ';': + return TRUE; } return FALSE; } @@ -673,10 +671,12 @@ static bool cs_is_separator(char c) uint16_t Curl_cipher_suite_walk_str(const char **str, const char **end) { /* move string pointer to first non-separator or end of string */ - for(; cs_is_separator(*str[0]); (*str)++); + for(; cs_is_separator(*str[0]); (*str)++) + ; /* move end pointer to next separator or end of string */ - for(*end = *str; *end[0] != '\0' && !cs_is_separator(*end[0]); (*end)++); + for(*end = *str; *end[0] != '\0' && !cs_is_separator(*end[0]); (*end)++) + ; return Curl_cipher_suite_lookup_id(*str, *end - *str); } diff --git a/lib/vtls/gtls.c b/lib/vtls/gtls.c index c05ab8427b89..e0ba48422b22 100644 --- a/lib/vtls/gtls.c +++ b/lib/vtls/gtls.c @@ -66,7 +66,7 @@ #ifdef GTLSDEBUG static void tls_log_func(int level, const char *str) { - curl_mfprintf(stderr, "|<%d>| %s", level, str); + curl_mfprintf(stderr, "|<%d>| %s", level, str); } #endif @@ -131,8 +131,7 @@ static ssize_t gtls_pull(void *s, void *buf, size_t blen) } result = Curl_conn_cf_recv(cf->next, data, buf, blen, &nread); - CURL_TRC_CF(data, cf, "glts_pull(len=%zu) -> %d, %zd", - blen, result, nread); + CURL_TRC_CF(data, cf, "glts_pull(len=%zu) -> %d, %zd", blen, result, nread); backend->gtls.io_result = result; if(result) { /* !checksrc! disable ERRNOVAR 1 */ @@ -173,9 +172,7 @@ static void gtls_cleanup(void) } #ifndef CURL_DISABLE_VERBOSE_STRINGS -static void showtime(struct Curl_easy *data, - const char *text, - time_t stamp) +static void showtime(struct Curl_easy *data, const char *text, time_t stamp) { struct tm buffer; const struct tm *tm = &buffer; @@ -209,10 +206,10 @@ static gnutls_datum_t load_file(const char *file) f = curlx_fopen(file, "rb"); if(!f) return loaded_file; - if(fseek(f, 0, SEEK_END) != 0 - || (filelen = ftell(f)) < 0 - || fseek(f, 0, SEEK_SET) != 0 - || !(ptr = curlx_malloc((size_t)filelen))) + if(fseek(f, 0, SEEK_END) != 0 || + (filelen = ftell(f)) < 0 || + fseek(f, 0, SEEK_SET) != 0 || + !(ptr = curlx_malloc((size_t)filelen))) goto out; if(fread(ptr, 1, (size_t)filelen, f) < (size_t)filelen) { curlx_free(ptr); @@ -231,7 +228,6 @@ static void unload_file(gnutls_datum_t data) curlx_free(data.data); } - /* this function does an SSL/TLS (re-)handshake */ static CURLcode cf_gtls_handshake(struct Curl_cfilter *cf, struct Curl_easy *data) @@ -584,20 +580,20 @@ static bool gtls_shared_creds_different(struct Curl_cfilter *cf, return strcmp(sc->CAfile, conn_config->CAfile); } -static struct gtls_shared_creds* -gtls_get_cached_creds(struct Curl_cfilter *cf, struct Curl_easy *data) +static struct gtls_shared_creds *gtls_get_cached_creds(struct Curl_cfilter *cf, + struct Curl_easy *data) { struct gtls_shared_creds *shared_creds; if(data->multi) { shared_creds = Curl_hash_pick(&data->multi->proto_hash, CURL_UNCONST(MPROTO_GTLS_X509_KEY), - sizeof(MPROTO_GTLS_X509_KEY)-1); - if(shared_creds && shared_creds->creds && - !gtls_shared_creds_expired(data, shared_creds) && - !gtls_shared_creds_different(cf, shared_creds)) { - return shared_creds; - } + sizeof(MPROTO_GTLS_X509_KEY) - 1); + if(shared_creds && shared_creds->creds && + !gtls_shared_creds_expired(data, shared_creds) && + !gtls_shared_creds_different(cf, shared_creds)) { + return shared_creds; + } } return NULL; } @@ -605,7 +601,7 @@ gtls_get_cached_creds(struct Curl_cfilter *cf, struct Curl_easy *data) static void gtls_shared_creds_hash_free(void *key, size_t key_len, void *p) { struct gtls_shared_creds *sc = p; - DEBUGASSERT(key_len == (sizeof(MPROTO_GTLS_X509_KEY)-1)); + DEBUGASSERT(key_len == (sizeof(MPROTO_GTLS_X509_KEY) - 1)); DEBUGASSERT(!memcmp(MPROTO_GTLS_X509_KEY, key, key_len)); (void)key; (void)key_len; @@ -635,9 +631,9 @@ static void gtls_set_cached_creds(struct Curl_cfilter *cf, return; if(!Curl_hash_add2(&data->multi->proto_hash, - CURL_UNCONST(MPROTO_GTLS_X509_KEY), - sizeof(MPROTO_GTLS_X509_KEY)-1, - sc, gtls_shared_creds_hash_free)) { + CURL_UNCONST(MPROTO_GTLS_X509_KEY), + sizeof(MPROTO_GTLS_X509_KEY) - 1, + sc, gtls_shared_creds_hash_free)) { Curl_gtls_shared_creds_free(&sc); /* down reference again */ return; } @@ -839,7 +835,7 @@ static CURLcode gtls_set_priority(struct Curl_cfilter *cf, if((conn_config->cipher_list[0] == '+') || (conn_config->cipher_list[0] == '-') || (conn_config->cipher_list[0] == '!')) { - /* add it to out own */ + /* add it to out own */ if(!curlx_dyn_len(&buf)) { /* not added yet */ result = curlx_dyn_add(&buf, priority); if(result) @@ -1106,8 +1102,8 @@ static CURLcode gtls_on_session_reuse(struct Curl_cfilter *cf, connssl->earlydata_state = ssl_earlydata_await; connssl->state = ssl_connection_deferred; result = Curl_alpn_set_negotiated(cf, data, connssl, - (const unsigned char *)scs->alpn, - scs->alpn ? strlen(scs->alpn) : 0); + (const unsigned char *)scs->alpn, + scs->alpn ? strlen(scs->alpn) : 0); *do_early_data = !result; } return result; @@ -1225,8 +1221,8 @@ CURLcode Curl_gtls_ctx_init(struct gtls_ctx *gctx, return result; } -static CURLcode -gtls_connect_step1(struct Curl_cfilter *cf, struct Curl_easy *data) +static CURLcode gtls_connect_step1(struct Curl_cfilter *cf, + struct Curl_easy *data) { struct ssl_connect_data *connssl = cf->ctx; struct gtls_ssl_backend_data *backend = @@ -1333,8 +1329,7 @@ static CURLcode pkp_pin_peer_pubkey(struct Curl_easy *data, return result; } -void Curl_gtls_report_handshake(struct Curl_easy *data, - struct gtls_ctx *gctx) +void Curl_gtls_report_handshake(struct Curl_easy *data, struct gtls_ctx *gctx) { #ifndef CURL_DISABLE_VERBOSE_STRINGS if(Curl_trc_is_verbose(data)) { @@ -1580,8 +1575,7 @@ static CURLcode glts_apple_verify(struct Curl_cfilter *cf, CURLcode result; result = Curl_vtls_apple_verify(cf, data, peer, chain->num_certs, - gtls_chain_get_der, chain, - NULL, 0); + gtls_chain_get_der, chain, NULL, 0); *pverified = !result; if(*pverified) infof(data, " SSL certificate verified by Apple SecTrust."); @@ -1589,14 +1583,13 @@ static CURLcode glts_apple_verify(struct Curl_cfilter *cf, } #endif /* USE_APPLE_SECTRUST */ -CURLcode -Curl_gtls_verifyserver(struct Curl_cfilter *cf, - struct Curl_easy *data, - gnutls_session_t session, - struct ssl_primary_config *config, - struct ssl_config_data *ssl_config, - struct ssl_peer *peer, - const char *pinned_key) +CURLcode Curl_gtls_verifyserver(struct Curl_cfilter *cf, + struct Curl_easy *data, + gnutls_session_t session, + struct ssl_primary_config *config, + struct ssl_config_data *ssl_config, + struct ssl_peer *peer, + const char *pinned_key) { struct gtls_cert_chain chain; gnutls_x509_crt_t x509_cert = NULL, x509_issuer = NULL; @@ -1651,7 +1644,7 @@ Curl_gtls_verifyserver(struct Curl_cfilter *cf, goto out; for(i = 0; i < chain.num_certs; i++) { - const char *beg = (const char *) chain.certs[i].data; + const char *beg = (const char *)chain.certs[i].data; const char *end = beg + chain.certs[i].size; result = Curl_extract_certinfo(data, (int)i, beg, end); @@ -1897,7 +1890,7 @@ static CURLcode gtls_send_earlydata(struct Curl_cfilter *cf, { struct ssl_connect_data *connssl = cf->ctx; struct gtls_ssl_backend_data *backend = - (struct gtls_ssl_backend_data *)connssl->backend; + (struct gtls_ssl_backend_data *)connssl->backend; CURLcode result = CURLE_OK; const unsigned char *buf; size_t blen; @@ -1907,8 +1900,7 @@ static CURLcode gtls_send_earlydata(struct Curl_cfilter *cf, backend->gtls.io_result = CURLE_OK; while(Curl_bufq_peek(&connssl->earlydata, &buf, &blen)) { n = gnutls_record_send_early_data(backend->gtls.session, buf, blen); - CURL_TRC_CF(data, cf, "gtls_send_earlydata(len=%zu) -> %zd", - blen, n); + CURL_TRC_CF(data, cf, "gtls_send_earlydata(len=%zu) -> %zd", blen, n); if(n < 0) { if(n == GNUTLS_E_AGAIN) result = CURLE_AGAIN; @@ -1947,7 +1939,7 @@ static CURLcode gtls_connect_common(struct Curl_cfilter *cf, { struct ssl_connect_data *connssl = cf->ctx; struct gtls_ssl_backend_data *backend = - (struct gtls_ssl_backend_data *)connssl->backend; + (struct gtls_ssl_backend_data *)connssl->backend; CURLcode result = CURLE_OK; DEBUGASSERT(backend); @@ -2131,7 +2123,7 @@ static CURLcode gtls_shutdown(struct Curl_cfilter *cf, size_t i; DEBUGASSERT(backend); - /* If we have no handshaked connection or already shut down */ + /* If we have no handshaked connection or already shut down */ if(!backend->gtls.session || cf->shutdown || connssl->state != ssl_connection_complete) { *done = TRUE; diff --git a/lib/vtls/gtls.h b/lib/vtls/gtls.h index afbe51eb9cb8..4949eee2d211 100644 --- a/lib/vtls/gtls.h +++ b/lib/vtls/gtls.h @@ -119,8 +119,7 @@ CURLcode Curl_gtls_cache_session(struct Curl_cfilter *cf, size_t quic_tp_len); /* Report properties of a successful handshake */ -void Curl_gtls_report_handshake(struct Curl_easy *data, - struct gtls_ctx *gctx); +void Curl_gtls_report_handshake(struct Curl_easy *data, struct gtls_ctx *gctx); extern const struct Curl_ssl Curl_ssl_gnutls; diff --git a/lib/vtls/hostcheck.c b/lib/vtls/hostcheck.c index 672f473db42a..fbd460bc15b1 100644 --- a/lib/vtls/hostcheck.c +++ b/lib/vtls/hostcheck.c @@ -84,9 +84,9 @@ static bool hostmatch(const char *hostname, DEBUGASSERT(hostlen); /* normalize pattern and hostname by stripping off trailing dots */ - if(hostname[hostlen-1]=='.') + if(hostname[hostlen - 1] == '.') hostlen--; - if(pattern[patternlen-1]=='.') + if(pattern[patternlen - 1] == '.') patternlen--; if(strncmp(pattern, "*.", 2)) diff --git a/lib/vtls/keylog.c b/lib/vtls/keylog.c index 397bac1a366a..03dda01f8dec 100644 --- a/lib/vtls/keylog.c +++ b/lib/vtls/keylog.c @@ -38,8 +38,7 @@ /* The fp for the open SSLKEYLOGFILE, or NULL if not open */ static FILE *keylog_file_fp; -void -Curl_tls_keylog_open(void) +void Curl_tls_keylog_open(void) { char *keylog_file_name; @@ -63,8 +62,7 @@ Curl_tls_keylog_open(void) } } -void -Curl_tls_keylog_close(void) +void Curl_tls_keylog_close(void) { if(keylog_file_fp) { curlx_fclose(keylog_file_fp); @@ -72,14 +70,12 @@ Curl_tls_keylog_close(void) } } -bool -Curl_tls_keylog_enabled(void) +bool Curl_tls_keylog_enabled(void) { return keylog_file_fp != NULL; } -bool -Curl_tls_keylog_write_line(const char *line) +bool Curl_tls_keylog_write_line(const char *line) { /* The current maximum valid keylog line length LF and NUL is 195. */ size_t linelen; @@ -107,10 +103,9 @@ Curl_tls_keylog_write_line(const char *line) 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) +bool Curl_tls_keylog_write(const char *label, + const unsigned char client_random[CLIENT_RANDOM_SIZE], + const unsigned char *secret, size_t secretlen) { size_t pos, i; unsigned char line[KEYLOG_LABEL_MAXLEN + 1 + 2 * CLIENT_RANDOM_SIZE + 1 + diff --git a/lib/vtls/mbedtls.c b/lib/vtls/mbedtls.c index 9e13ed4641d9..d33167037162 100644 --- a/lib/vtls/mbedtls.c +++ b/lib/vtls/mbedtls.c @@ -38,7 +38,7 @@ #include #if MBEDTLS_VERSION_NUMBER < 0x03020000 - #error "mbedTLS 3.2.0 or later required" +#error "mbedTLS 3.2.0 or later required" #endif #include #include @@ -77,7 +77,7 @@ /* ALPN for http2 */ #if defined(USE_HTTP2) && defined(MBEDTLS_SSL_ALPN) -# define HAS_ALPN_MBEDTLS +#define HAS_ALPN_MBEDTLS #endif struct mbed_ssl_backend_data { @@ -109,7 +109,7 @@ struct mbed_ssl_backend_data { #endif #ifndef MBEDTLS_ERROR_C -#define mbedtls_strerror(a,b,c) b[0] = 0 +#define mbedtls_strerror(a, b, c) b[0] = 0 #endif #if defined(CURL_MBEDTLS_DRBG) && defined(HAS_THREADING_SUPPORT) @@ -217,8 +217,7 @@ static int mbedtls_bio_cf_read(void *bio, unsigned char *buf, size_t blen) /* * profile */ -static const mbedtls_x509_crt_profile mbedtls_x509_crt_profile_fr = -{ +static const mbedtls_x509_crt_profile mbedtls_x509_crt_profile_fr = { /* Hashes from SHA-1 and above */ MBEDTLS_X509_ID_FLAG(MBEDTLS_MD_SHA1) | MBEDTLS_X509_ID_FLAG(MBEDTLS_MD_RIPEMD160) | @@ -307,9 +306,8 @@ mbed_set_ssl_version_min_max(struct Curl_easy *data, cipher suite present in other SSL implementations. Provide provisional support for specifying the cipher suite here. */ #ifdef MBEDTLS_TLS_ECJPAKE_WITH_AES_128_CCM_8 -static int -mbed_cipher_suite_get_str(uint16_t id, char *buf, size_t buf_size, - bool prefer_rfc) +static int mbed_cipher_suite_get_str(uint16_t id, char *buf, size_t buf_size, + bool prefer_rfc) { if(id == MBEDTLS_TLS_ECJPAKE_WITH_AES_128_CCM_8) curl_msnprintf(buf, buf_size, "%s", "TLS_ECJPAKE_WITH_AES_128_CCM_8"); @@ -318,8 +316,7 @@ mbed_cipher_suite_get_str(uint16_t id, char *buf, size_t buf_size, return 0; } -static uint16_t -mbed_cipher_suite_walk_str(const char **str, const char **end) +static uint16_t mbed_cipher_suite_walk_str(const char **str, const char **end) { uint16_t id = Curl_cipher_suite_walk_str(str, end); size_t len = *end - *str; @@ -348,7 +345,8 @@ mbed_set_selected_ciphers(struct Curl_easy *data, const char *ptr, *end; supported = mbedtls_ssl_list_ciphersuites(); - for(i = 0; supported[i] != 0; i++); + for(i = 0; supported[i] != 0; i++) + ; supported_len = i; selected = curlx_malloc(sizeof(int) * (supported_len + 1)); @@ -361,7 +359,7 @@ mbed_set_selected_ciphers(struct Curl_easy *data, if(!ciphers13) { /* Add default TLSv1.3 ciphers to selection */ for(j = 0; j < supported_len; j++) { - uint16_t id = (uint16_t) supported[j]; + uint16_t id = (uint16_t)supported[j]; if(strncmp(mbedtls_ssl_get_ciphersuite_name(id), "TLS1-3", 6) != 0) continue; @@ -380,23 +378,25 @@ mbed_set_selected_ciphers(struct Curl_easy *data, /* Check if cipher is supported */ if(id) { - for(i = 0; i < supported_len && supported[i] != id; i++); + for(i = 0; i < supported_len && supported[i] != id; i++) + ; if(i == supported_len) id = 0; } if(!id) { if(ptr[0] != '\0') infof(data, "mbedTLS: unknown cipher in list: \"%.*s\"", - (int) (end - ptr), ptr); + (int)(end - ptr), ptr); continue; } /* No duplicates allowed (so selected cannot overflow) */ - for(i = 0; i < count && selected[i] != id; i++); + for(i = 0; i < count && selected[i] != id; i++) + ; if(i < count) { if(i >= default13_count) infof(data, "mbedTLS: duplicate cipher in list: \"%.*s\"", - (int) (end - ptr), ptr); + (int)(end - ptr), ptr); continue; } @@ -412,12 +412,13 @@ mbed_set_selected_ciphers(struct Curl_easy *data, if(!ciphers12) { /* Add default TLSv1.2 ciphers to selection */ for(j = 0; j < supported_len; j++) { - uint16_t id = (uint16_t) supported[j]; + uint16_t id = (uint16_t)supported[j]; if(strncmp(mbedtls_ssl_get_ciphersuite_name(id), "TLS1-3", 6) == 0) continue; /* No duplicates allowed (so selected cannot overflow) */ - for(i = 0; i < count && selected[i] != id; i++); + for(i = 0; i < count && selected[i] != id; i++) + ; if(i < count) continue; @@ -441,8 +442,8 @@ mbed_set_selected_ciphers(struct Curl_easy *data, return CURLE_OK; } -static void -mbed_dump_cert_info(struct Curl_easy *data, const mbedtls_x509_crt *crt) +static void mbed_dump_cert_info(struct Curl_easy *data, + const mbedtls_x509_crt *crt) { #if defined(CURL_DISABLE_VERBOSE_STRINGS) || defined(MBEDTLS_X509_REMOVE_INFO) (void)data, (void)crt; @@ -454,7 +455,7 @@ mbed_dump_cert_info(struct Curl_easy *data, const mbedtls_x509_crt *crt) infof(data, "Server certificate:"); for(p = buffer; *p; p += *p != '\0') { size_t s = strcspn(p, "\n"); - infof(data, "%.*s", (int) s, p); + infof(data, "%.*s", (int)s, p); p += s; } } @@ -465,8 +466,8 @@ mbed_dump_cert_info(struct Curl_easy *data, const mbedtls_x509_crt *crt) #endif } -static void -mbed_extract_certinfo(struct Curl_easy *data, const mbedtls_x509_crt *crt) +static void mbed_extract_certinfo(struct Curl_easy *data, + const mbedtls_x509_crt *crt) { CURLcode result; const mbedtls_x509_crt *cur; @@ -485,7 +486,7 @@ mbed_extract_certinfo(struct Curl_easy *data, const mbedtls_x509_crt *crt) result = Curl_ssl_init_certinfo(data, cert_count); for(i = 0, cur = crt; result == CURLE_OK && cur; ++i, cur = cur->next) { - const char *beg = (const char *) cur->raw.p; + const char *beg = (const char *)cur->raw.p; const char *end = beg + cur->raw.len; result = Curl_extract_certinfo(data, i, beg, end); } @@ -494,7 +495,7 @@ mbed_extract_certinfo(struct Curl_easy *data, const mbedtls_x509_crt *crt) static int mbed_verify_cb(void *ptr, mbedtls_x509_crt *crt, int depth, uint32_t *flags) { - struct Curl_cfilter *cf = (struct Curl_cfilter *) ptr; + struct Curl_cfilter *cf = (struct Curl_cfilter *)ptr; struct ssl_primary_config *conn_config = Curl_ssl_cf_get_primary_config(cf); struct Curl_easy *data = CF_DATA_CURRENT(cf); @@ -523,8 +524,8 @@ static int mbed_verify_cb(void *ptr, mbedtls_x509_crt *crt, return 0; } -static CURLcode -mbed_connect_step1(struct Curl_cfilter *cf, struct Curl_easy *data) +static CURLcode mbed_connect_step1(struct Curl_cfilter *cf, + struct Curl_easy *data) { struct ssl_connect_data *connssl = cf->ctx; struct mbed_ssl_backend_data *backend = @@ -959,8 +960,8 @@ mbed_connect_step1(struct Curl_cfilter *cf, struct Curl_easy *data) return CURLE_OK; } -static CURLcode -mbed_connect_step2(struct Curl_cfilter *cf, struct Curl_easy *data) +static CURLcode mbed_connect_step2(struct Curl_cfilter *cf, + struct Curl_easy *data) { CURLcode result; int ret; @@ -1004,8 +1005,8 @@ mbed_connect_step2(struct Curl_cfilter *cf, struct Curl_easy *data) { char cipher_str[64]; uint16_t cipher_id; - cipher_id = (uint16_t) - mbedtls_ssl_get_ciphersuite_id_from_ssl(&backend->ssl); + cipher_id = + (uint16_t)mbedtls_ssl_get_ciphersuite_id_from_ssl(&backend->ssl); mbed_cipher_suite_get_str(cipher_id, cipher_str, sizeof(cipher_str), TRUE); infof(data, "mbedTLS: %s Handshake complete, cipher is %s", mbedtls_ssl_get_version(&backend->ssl), cipher_str); @@ -1084,8 +1085,8 @@ mbed_connect_step2(struct Curl_cfilter *cf, struct Curl_easy *data) return CURLE_OK; } -static CURLcode -mbed_new_session(struct Curl_cfilter *cf, struct Curl_easy *data) +static CURLcode mbed_new_session(struct Curl_cfilter *cf, + struct Curl_easy *data) { struct ssl_connect_data *connssl = cf->ctx; struct mbed_ssl_backend_data *backend = @@ -1148,8 +1149,7 @@ mbed_new_session(struct Curl_cfilter *cf, struct Curl_easy *data) } static CURLcode mbed_send(struct Curl_cfilter *cf, struct Curl_easy *data, - const void *mem, size_t len, - size_t *pnwritten) + const void *mem, size_t len, size_t *pnwritten) { struct ssl_connect_data *connssl = cf->ctx; struct mbed_ssl_backend_data *backend = @@ -1327,8 +1327,7 @@ static void mbedtls_close(struct Curl_cfilter *cf, struct Curl_easy *data) } static CURLcode mbed_recv(struct Curl_cfilter *cf, struct Curl_easy *data, - char *buf, size_t buffersize, - size_t *pnread) + char *buf, size_t buffersize, size_t *pnread) { struct ssl_connect_data *connssl = cf->ctx; struct mbed_ssl_backend_data *backend = diff --git a/lib/vtls/mbedtls_threadlock.c b/lib/vtls/mbedtls_threadlock.c index 89cc2b7d38df..0a74d60d37ae 100644 --- a/lib/vtls/mbedtls_threadlock.c +++ b/lib/vtls/mbedtls_threadlock.c @@ -24,9 +24,8 @@ ***************************************************************************/ #include "../curl_setup.h" -#if defined(USE_MBEDTLS) && \ - ((defined(USE_THREADS_POSIX) && defined(HAVE_PTHREAD_H)) || \ - defined(_WIN32)) +#if defined(USE_MBEDTLS) && \ + ((defined(USE_THREADS_POSIX) && defined(HAVE_PTHREAD_H)) || defined(_WIN32)) #if defined(USE_THREADS_POSIX) && defined(HAVE_PTHREAD_H) # include diff --git a/lib/vtls/mbedtls_threadlock.h b/lib/vtls/mbedtls_threadlock.h index 1855d4cc0187..55607e62504c 100644 --- a/lib/vtls/mbedtls_threadlock.h +++ b/lib/vtls/mbedtls_threadlock.h @@ -28,8 +28,7 @@ #ifdef USE_MBEDTLS -#if (defined(USE_THREADS_POSIX) && defined(HAVE_PTHREAD_H)) || \ - defined(_WIN32) +#if (defined(USE_THREADS_POSIX) && defined(HAVE_PTHREAD_H)) || defined(_WIN32) int Curl_mbedtlsthreadlock_thread_setup(void); int Curl_mbedtlsthreadlock_thread_cleanup(void); diff --git a/lib/vtls/openssl.c b/lib/vtls/openssl.c index bdfe527acd83..a958698b5836 100644 --- a/lib/vtls/openssl.c +++ b/lib/vtls/openssl.c @@ -179,7 +179,7 @@ static void ossl_provider_cleanup(struct Curl_easy *data); #define OSSL_PACKAGE "BoringSSL" #elif defined(OPENSSL_IS_AWSLC) #define OSSL_PACKAGE "AWS-LC" -#elif defined(USE_NGTCP2) && defined(USE_NGHTTP3) && \ +#elif defined(USE_NGTCP2) && defined(USE_NGHTTP3) && \ !defined(OPENSSL_QUIC_API2) #define OSSL_PACKAGE "quictls" #else @@ -234,7 +234,7 @@ static CURLcode pubkey_show(struct Curl_easy *data, return push_certinfo(data, mem, namebuf, num); } -#define print_pubkey_BN(_type, _name, _num) \ +#define print_pubkey_BN(_type, _name, _num) \ pubkey_show(data, mem, _num, #_type, #_name, _name) static int asn1_object_dump(const ASN1_OBJECT *a, char *buf, size_t len) @@ -685,8 +685,7 @@ static void ossl_keylog_callback(const SSL *ssl, const char *line) * ossl_log_tls12_secret is called by libcurl to make the CLIENT_RANDOMs if the * OpenSSL being used does not 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; unsigned char client_random[SSL3_RANDOM_SIZE]; @@ -791,8 +790,7 @@ static char *ossl_strerror(unsigned long error, char *buf, size_t size) return buf; } -static int passwd_callback(char *buf, int num, int encrypting, - void *password) +static int passwd_callback(char *buf, int num, int encrypting, void *password) { DEBUGASSERT(encrypting == 0); @@ -932,8 +930,7 @@ static int use_certificate_blob(SSL_CTX *ctx, const struct curl_blob *blob, } else if(type == SSL_FILETYPE_PEM) { /* ERR_R_PEM_LIB; */ - x = PEM_read_bio_X509(in, NULL, - passwd_callback, CURL_UNCONST(key_passwd)); + x = PEM_read_bio_X509(in, NULL, passwd_callback, CURL_UNCONST(key_passwd)); } else { ret = 0; @@ -979,9 +976,9 @@ static int use_privatekey_blob(SSL_CTX *ctx, const struct curl_blob *blob, return ret; } -static int -use_certificate_chain_blob(SSL_CTX *ctx, const struct curl_blob *blob, - const char *key_passwd) +static int use_certificate_chain_blob(SSL_CTX *ctx, + const struct curl_blob *blob, + const char *key_passwd) { int ret = 0; X509 *x = NULL; @@ -1011,8 +1008,7 @@ use_certificate_chain_blob(SSL_CTX *ctx, const struct curl_blob *blob, } while((ca = PEM_read_bio_X509(in, NULL, passwd_callback, - CURL_UNCONST(key_passwd))) - != NULL) { + CURL_UNCONST(key_passwd))) != NULL) { if(!SSL_CTX_add0_chain_cert(ctx, ca)) { X509_free(ca); @@ -1054,8 +1050,7 @@ static int enginecheck(struct Curl_easy *data, } if(data->state.engine) { - UI_METHOD *ui_method = - UI_create_method("curl user interface"); + UI_METHOD *ui_method = UI_create_method("curl user interface"); if(!ui_method) { failf(data, "unable to create " OSSL_PACKAGE " user-interface method"); return 0; @@ -1116,8 +1111,7 @@ static int providercheck(struct Curl_easy *data, EVP_PKEY *priv_key = NULL; OSSL_STORE_CTX *store = NULL; OSSL_STORE_INFO *info = NULL; - UI_METHOD *ui_method = - UI_create_method("curl user interface"); + UI_METHOD *ui_method = UI_create_method("curl user interface"); if(!ui_method) { failf(data, "unable to create " OSSL_PACKAGE " user-interface method"); return 0; @@ -1221,16 +1215,15 @@ static int engineload(struct Curl_easy *data, /* Load the certificate from the engine */ if(!ENGINE_ctrl_cmd(data->state.engine, cmd_name, 0, ¶ms, NULL, 1)) { - failf(data, "ssl engine cannot load client cert with id" - " '%s' [%s]", cert_file, + failf(data, "ssl engine cannot load client cert with id '%s' [%s]", + cert_file, ossl_strerror(ERR_get_error(), error_buffer, sizeof(error_buffer))); return 0; } if(!params.cert) { - failf(data, "ssl engine did not initialized the certificate " - "properly."); + failf(data, "ssl engine did not initialized the certificate properly."); return 0; } @@ -1352,8 +1345,7 @@ static int pkcs12load(struct Curl_easy *data, if(cert_blob) { cert_bio = BIO_new_mem_buf(cert_blob->data, (int)(cert_blob->len)); if(!cert_bio) { - failf(data, - "BIO_new_mem_buf NULL, " OSSL_PACKAGE " error %s", + failf(data, "BIO_new_mem_buf NULL, " OSSL_PACKAGE " error %s", ossl_strerror(ERR_get_error(), error_buffer, sizeof(error_buffer)) ); return 0; @@ -1362,8 +1354,7 @@ static int pkcs12load(struct Curl_easy *data, else { cert_bio = BIO_new(BIO_s_file()); if(!cert_bio) { - failf(data, - "BIO_new return NULL, " OSSL_PACKAGE " error %s", + failf(data, "BIO_new return NULL, " OSSL_PACKAGE " error %s", ossl_strerror(ERR_get_error(), error_buffer, sizeof(error_buffer)) ); return 0; @@ -1386,11 +1377,9 @@ static int pkcs12load(struct Curl_easy *data, } if(!PKCS12_parse(p12, key_passwd, &pri, &x509, &ca)) { - failf(data, - "could not parse PKCS12 file, check password, " OSSL_PACKAGE + failf(data, "could not parse PKCS12 file, check password, " OSSL_PACKAGE " error %s", - ossl_strerror(ERR_get_error(), error_buffer, - sizeof(error_buffer)) ); + ossl_strerror(ERR_get_error(), error_buffer, sizeof(error_buffer))); PKCS12_free(p12); return 0; } @@ -1398,17 +1387,14 @@ static int pkcs12load(struct Curl_easy *data, PKCS12_free(p12); if(SSL_CTX_use_certificate(ctx, x509) != 1) { - failf(data, - "could not load PKCS12 client certificate, " OSSL_PACKAGE + failf(data, "could not load PKCS12 client certificate, " OSSL_PACKAGE " error %s", - ossl_strerror(ERR_get_error(), error_buffer, - sizeof(error_buffer)) ); + ossl_strerror(ERR_get_error(), error_buffer, sizeof(error_buffer))); goto fail; } if(SSL_CTX_use_PrivateKey(ctx, pri) != 1) { - failf(data, "unable to use private key from PKCS12 file '%s'", - cert_file); + failf(data, "unable to use private key from PKCS12 file '%s'", cert_file); goto fail; } @@ -1500,7 +1486,7 @@ static CURLcode client_cert(struct Curl_easy *data, "(no key found, wrong passphrase, or wrong file format?)", (cert_blob ? "CURLOPT_SSLCERT_BLOB" : cert_file), ossl_strerror(ERR_get_error(), error_buffer, - sizeof(error_buffer)) ); + sizeof(error_buffer))); return CURLE_SSL_CERTPROBLEM; } break; @@ -1520,7 +1506,7 @@ static CURLcode client_cert(struct Curl_easy *data, "(no key found, wrong passphrase, or wrong file format?)", (cert_blob ? "CURLOPT_SSLCERT_BLOB" : cert_file), ossl_strerror(ERR_get_error(), error_buffer, - sizeof(error_buffer)) ); + sizeof(error_buffer))); return CURLE_SSL_CERTPROBLEM; } break; @@ -1850,20 +1836,17 @@ static CURLcode ossl_set_provider(struct Curl_easy *data, const char *iname) return CURLE_OK; } - data->state.provider = - OSSL_PROVIDER_try_load(data->state.libctx, name, 1); + data->state.provider = OSSL_PROVIDER_try_load(data->state.libctx, name, 1); if(!data->state.provider) { char error_buffer[256]; failf(data, "Failed to initialize provider: %s", - ossl_strerror(ERR_get_error(), error_buffer, - sizeof(error_buffer))); + ossl_strerror(ERR_get_error(), error_buffer, sizeof(error_buffer))); ossl_provider_cleanup(data); return CURLE_SSL_ENGINE_NOTFOUND; } /* load the base provider as well */ - data->state.baseprov = - OSSL_PROVIDER_try_load(data->state.libctx, "base", 1); + data->state.baseprov = OSSL_PROVIDER_try_load(data->state.libctx, "base", 1); if(!data->state.baseprov) { ossl_provider_cleanup(data); failf(data, "Failed to load base"); @@ -1875,7 +1858,6 @@ static CURLcode ossl_set_provider(struct Curl_easy *data, const char *iname) } #endif - static CURLcode ossl_shutdown(struct Curl_cfilter *cf, struct Curl_easy *data, bool send_shutdown, bool *done) @@ -2138,7 +2120,7 @@ static CURLcode ossl_verifyhost(struct Curl_easy *data, if(check->type == target) { /* get data and length */ const char *altptr = (const char *)ASN1_STRING_get0_data(check->d.ia5); - size_t altlen = (size_t) ASN1_STRING_length(check->d.ia5); + size_t altlen = (size_t)ASN1_STRING_length(check->d.ia5); switch(target) { case GEN_DNS: /* name/pattern comparison */ @@ -2166,8 +2148,7 @@ static CURLcode ossl_verifyhost(struct Curl_easy *data, our server IP address is */ if((altlen == addrlen) && !memcmp(altptr, &addr, altlen)) { matched = TRUE; - infof(data, - " subjectAltName: \"%s\" matches cert's IP address!", + infof(data, " subjectAltName: \"%s\" matches cert's IP address!", peer->dispname); } break; @@ -2242,8 +2223,7 @@ static CURLcode ossl_verifyhost(struct Curl_easy *data, /* error already detected, pass through */ ; else if(!cn) { - failf(data, - "SSL: unable to obtain common name from peer certificate"); + failf(data, "SSL: unable to obtain common name from peer certificate"); result = CURLE_PEER_FAILED_VERIFICATION; } else if(!Curl_cert_hostcheck((const char *)cn, cnlen, @@ -2780,7 +2760,7 @@ CURLcode Curl_ossl_add_session(struct Curl_cfilter *cf, */ static int ossl_new_session_cb(SSL *ssl, SSL_SESSION *ssl_sessionid) { - struct Curl_cfilter *cf = (struct Curl_cfilter*) SSL_get_app_data(ssl); + struct Curl_cfilter *cf = (struct Curl_cfilter *)SSL_get_app_data(ssl); if(cf) { struct Curl_easy *data = CF_DATA_CURRENT(cf); struct ssl_connect_data *connssl = cf->ctx; @@ -3181,7 +3161,7 @@ static CURLcode ossl_populate_x509_store(struct Curl_cfilter *cf, failf(data, "error loading CRL file: %s", ssl_crlfile); return CURLE_SSL_CRL_BADFILE; } - x509flags = X509_V_FLAG_CRL_CHECK|X509_V_FLAG_CRL_CHECK_ALL; + x509flags = X509_V_FLAG_CRL_CHECK | X509_V_FLAG_CRL_CHECK_ALL; infof(data, " CRLfile: %s", ssl_crlfile); } @@ -3210,7 +3190,7 @@ static CURLcode ossl_populate_x509_store(struct Curl_cfilter *cf, } /* key to use at `multi->proto_hash` */ -#define MPROTO_OSSL_X509_KEY "tls:ossl:x509:share" +#define MPROTO_OSSL_X509_KEY "tls:ossl:x509:share" struct ossl_x509_share { char *CAfile; /* CAfile path used to generate X509 store */ @@ -3222,7 +3202,7 @@ struct ossl_x509_share { static void oss_x509_share_free(void *key, size_t key_len, void *p) { struct ossl_x509_share *share = p; - DEBUGASSERT(key_len == (sizeof(MPROTO_OSSL_X509_KEY)-1)); + DEBUGASSERT(key_len == (sizeof(MPROTO_OSSL_X509_KEY) - 1)); DEBUGASSERT(!memcmp(MPROTO_OSSL_X509_KEY, key, key_len)); (void)key; (void)key_len; @@ -3233,9 +3213,8 @@ static void oss_x509_share_free(void *key, size_t key_len, void *p) curlx_free(share); } -static bool -ossl_cached_x509_store_expired(const struct Curl_easy *data, - const struct ossl_x509_share *mb) +static bool ossl_cached_x509_store_expired(const struct Curl_easy *data, + const struct ossl_x509_share *mb) { const struct ssl_general_config *cfg = &data->set.general_ssl; if(cfg->ca_cache_timeout < 0) @@ -3249,9 +3228,8 @@ ossl_cached_x509_store_expired(const struct Curl_easy *data, } } -static bool -ossl_cached_x509_store_different(struct Curl_cfilter *cf, - const struct ossl_x509_share *mb) +static bool ossl_cached_x509_store_different(struct Curl_cfilter *cf, + const struct ossl_x509_share *mb) { struct ssl_primary_config *conn_config = Curl_ssl_cf_get_primary_config(cf); if(!mb->CAfile || !conn_config->CAfile) @@ -3272,7 +3250,7 @@ static X509_STORE *ossl_get_cached_x509_store(struct Curl_cfilter *cf, *pempty = TRUE; share = multi ? Curl_hash_pick(&multi->proto_hash, CURL_UNCONST(MPROTO_OSSL_X509_KEY), - sizeof(MPROTO_OSSL_X509_KEY)-1) : NULL; + sizeof(MPROTO_OSSL_X509_KEY) - 1) : NULL; if(share && share->store && !ossl_cached_x509_store_expired(data, share) && !ossl_cached_x509_store_different(cf, share)) { @@ -3297,7 +3275,7 @@ static void ossl_set_cached_x509_store(struct Curl_cfilter *cf, return; share = Curl_hash_pick(&multi->proto_hash, CURL_UNCONST(MPROTO_OSSL_X509_KEY), - sizeof(MPROTO_OSSL_X509_KEY)-1); + sizeof(MPROTO_OSSL_X509_KEY) - 1); if(!share) { share = curlx_calloc(1, sizeof(*share)); @@ -3305,7 +3283,7 @@ static void ossl_set_cached_x509_store(struct Curl_cfilter *cf, return; if(!Curl_hash_add2(&multi->proto_hash, CURL_UNCONST(MPROTO_OSSL_X509_KEY), - sizeof(MPROTO_OSSL_X509_KEY)-1, + sizeof(MPROTO_OSSL_X509_KEY) - 1, share, oss_x509_share_free)) { curlx_free(share); return; @@ -3508,8 +3486,7 @@ static CURLcode ossl_init_ech(struct ossl_ctx *octx, if(data->set.tls_ech & CURLECH_HARD) return result; } - if(SSL_set1_ech_config_list(octx->ssl, ech_config, - ech_config_len) != 1) { + if(SSL_set1_ech_config_list(octx->ssl, ech_config, ech_config_len) != 1) { infof(data, "ECH: SSL_ECH_set1_ech_config_list failed"); if(data->set.tls_ech & CURLECH_HARD) { curlx_free(ech_config); @@ -3519,14 +3496,13 @@ static CURLcode ossl_init_ech(struct ossl_ctx *octx, curlx_free(ech_config); trying_ech_now = 1; # else - ech_config = (unsigned char *) data->set.str[STRING_ECH_CONFIG]; + ech_config = (unsigned char *)data->set.str[STRING_ECH_CONFIG]; if(!ech_config) { infof(data, "ECH: ECHConfig from command line empty"); return CURLE_SSL_CONNECT_ERROR; } ech_config_len = strlen(data->set.str[STRING_ECH_CONFIG]); - if(SSL_set1_ech_config_list(octx->ssl, ech_config, - ech_config_len) != 1) { + if(SSL_set1_ech_config_list(octx->ssl, ech_config, ech_config_len) != 1) { infof(data, "ECH: SSL_ECH_set1_ech_config_list failed"); if(data->set.tls_ech & CURLECH_HARD) return CURLE_SSL_CONNECT_ERROR; @@ -3584,16 +3560,16 @@ static CURLcode ossl_init_ech(struct ossl_ctx *octx, infof(data, "ECH: inner: '%s', outer: '%s'", peer->hostname ? peer->hostname : "NULL", outername); result = SSL_ech_set1_server_names(octx->ssl, - peer->hostname, outername, - 0 /* do send outer */); + peer->hostname, outername, + 0 /* do send outer */); if(result != 1) { infof(data, "ECH: rv failed to set server name(s) %d [ERROR]", result); return CURLE_SSL_CONNECT_ERROR; } } # endif /* HAVE_BORINGSSL_LIKE */ - if(trying_ech_now - && SSL_set_min_proto_version(octx->ssl, TLS1_3_VERSION) != 1) { + if(trying_ech_now && + SSL_set_min_proto_version(octx->ssl, TLS1_3_VERSION) != 1) { infof(data, "ECH: cannot force TLSv1.3 [ERROR]"); return CURLE_SSL_CONNECT_ERROR; } @@ -3602,7 +3578,6 @@ static CURLcode ossl_init_ech(struct ossl_ctx *octx, } #endif /* USE_ECH_OPENSSL */ - static CURLcode ossl_init_ssl(struct ossl_ctx *octx, struct Curl_cfilter *cf, struct Curl_easy *data, @@ -3706,7 +3681,6 @@ static CURLcode ossl_init_method(struct Curl_cfilter *cf, return *pmethod ? CURLE_OK : CURLE_SSL_CONNECT_ERROR; } - CURLcode Curl_ossl_ctx_init(struct ossl_ctx *octx, struct Curl_cfilter *cf, struct Curl_easy *data, @@ -3821,7 +3795,7 @@ CURLcode Curl_ossl_ctx_init(struct ossl_ctx *octx, /* "--tlsv" options mean TLS >= version */ case CURL_SSLVERSION_DEFAULT: - case CURL_SSLVERSION_TLSv1: /* TLS >= version 1.0 */ + case CURL_SSLVERSION_TLSv1: /* TLS >= version 1.0 */ case CURL_SSLVERSION_TLSv1_0: /* TLS >= version 1.0 */ case CURL_SSLVERSION_TLSv1_1: /* TLS >= version 1.1 */ case CURL_SSLVERSION_TLSv1_2: /* TLS >= version 1.2 */ @@ -4036,8 +4010,7 @@ static CURLcode ossl_on_session_reuse(struct Curl_cfilter *cf, return result; } -void Curl_ossl_report_handshake(struct Curl_easy *data, - struct ossl_ctx *octx) +void Curl_ossl_report_handshake(struct Curl_easy *data, struct ossl_ctx *octx) { #ifndef CURL_DISABLE_VERBOSE_STRINGS if(Curl_trc_is_verbose(data)) { @@ -4065,7 +4038,6 @@ void Curl_ossl_report_handshake(struct Curl_easy *data, (void)data; (void)octx; #endif /* CURL_DISABLE_VERBOSE_STRINGS */ - } static CURLcode ossl_connect_step1(struct Curl_cfilter *cf, @@ -4121,7 +4093,7 @@ static CURLcode ossl_connect_step1(struct Curl_cfilter *cf, #ifdef USE_ECH_OPENSSL /* If we have retry configs, then trace those out */ -static void ossl_trace_ech_retry_configs(struct Curl_easy *data, SSL* ssl, +static void ossl_trace_ech_retry_configs(struct Curl_easy *data, SSL *ssl, int reason) { CURLcode result = CURLE_OK; @@ -4247,7 +4219,7 @@ static CURLcode ossl_connect_step2(struct Curl_cfilter *cf, else { /* untreated error */ sslerr_t errdetail; - char error_buffer[256]=""; + char error_buffer[256] = ""; CURLcode result; long lerr; int lib; @@ -4319,7 +4291,7 @@ static CURLcode ossl_connect_step2(struct Curl_cfilter *cf, * the SO_ERROR is also lost. */ if(CURLE_SSL_CONNECT_ERROR == result && errdetail == 0) { - char extramsg[80]=""; + char extramsg[80] = ""; int sockerr = SOCKERRNO; if(sockerr && detail == SSL_ERROR_SYSCALL) @@ -4374,7 +4346,7 @@ static CURLcode ossl_connect_step2(struct Curl_cfilter *cf, break; default: status = "unexpected status"; - infof(data, "ECH: unexpected status %d",rv); + infof(data, "ECH: unexpected status %d", rv); } infof(data, "ECH: result: status is %s, inner is %s, outer is %s", (status ? status : "NULL"), @@ -4418,7 +4390,7 @@ static CURLcode ossl_connect_step2(struct Curl_cfilter *cf, * Heavily modified from: * https://www.owasp.org/index.php/Certificate_and_Public_Key_Pinning#OpenSSL */ -static CURLcode ossl_pkp_pin_peer_pubkey(struct Curl_easy *data, X509* cert, +static CURLcode ossl_pkp_pin_peer_pubkey(struct Curl_easy *data, X509 *cert, const char *pinnedpubkey) { /* Scratch */ @@ -4534,8 +4506,7 @@ static void infof_certstack(struct Curl_easy *data, const SSL *ssl) type_name = NULL; #endif - infof(data, - " Certificate level %d: " + infof(data, " Certificate level %d: " "Public key type %s%s (%d/%d Bits/secBits), signed using %s", cert_level, type_name ? type_name : "?", get_group_name == 0 ? "" : group_name_final, @@ -4553,7 +4524,7 @@ static CURLcode ossl_check_issuer(struct Curl_cfilter *cf, struct ssl_primary_config *conn_config = Curl_ssl_cf_get_primary_config(cf); X509 *issuer = NULL; BIO *fp = NULL; - char err_buf[256]=""; + char err_buf[256] = ""; bool verify_enabled = (conn_config->verifypeer || conn_config->verifyhost); CURLcode result = CURLE_OK; @@ -4671,12 +4642,12 @@ static CURLcode ossl_infof_cert(struct Curl_cfilter *cf, infof(data, " subject: %s", result ? "[NONE]" : curlx_dyn_ptr(&dname)); ASN1_TIME_print(mem, X509_get0_notBefore(server_cert)); - len = BIO_get_mem_data(mem, (char **) &buf); + len = BIO_get_mem_data(mem, (char **)&buf); infof(data, " start date: %.*s", (int)len, buf); (void)BIO_reset(mem); ASN1_TIME_print(mem, X509_get0_notAfter(server_cert)); - len = BIO_get_mem_data(mem, (char **) &buf); + len = BIO_get_mem_data(mem, (char **)&buf); infof(data, " expire date: %.*s", (int)len, buf); (void)BIO_reset(mem); @@ -5118,8 +5089,7 @@ static CURLcode ossl_send(struct Curl_cfilter *cf, result = CURLE_AGAIN; octx->blocked_ssl_write_len = memlen; goto out; - case SSL_ERROR_SYSCALL: - { + case SSL_ERROR_SYSCALL: { int sockerr = SOCKERRNO; if(octx->io_result == CURLE_AGAIN) { diff --git a/lib/vtls/openssl.h b/lib/vtls/openssl.h index 5b6f35396d91..ff8246b4fae3 100644 --- a/lib/vtls/openssl.h +++ b/lib/vtls/openssl.h @@ -150,8 +150,7 @@ CURLcode Curl_ossl_check_peer_cert(struct Curl_cfilter *cf, struct ssl_peer *peer); /* Report properties of a successful handshake */ -void Curl_ossl_report_handshake(struct Curl_easy *data, - struct ossl_ctx *octx); +void Curl_ossl_report_handshake(struct Curl_easy *data, struct ossl_ctx *octx); #endif /* USE_OPENSSL */ #endif /* HEADER_CURL_SSLUSE_H */ diff --git a/lib/vtls/rustls.c b/lib/vtls/rustls.c index 360a2454ac85..951b339b4346 100644 --- a/lib/vtls/rustls.c +++ b/lib/vtls/rustls.c @@ -42,8 +42,7 @@ #include "cipher_suite.h" #include "x509asn1.h" -struct rustls_ssl_backend_data -{ +struct rustls_ssl_backend_data { const struct rustls_client_config *config; struct rustls_connection *conn; size_t plain_out_buffered; @@ -58,17 +57,17 @@ static CURLcode map_error(const rustls_result r) return CURLE_PEER_FAILED_VERIFICATION; } switch(r) { - case RUSTLS_RESULT_OK: - return CURLE_OK; - case RUSTLS_RESULT_NULL_PARAMETER: - return CURLE_BAD_FUNCTION_ARGUMENT; - default: - return CURLE_RECV_ERROR; + case RUSTLS_RESULT_OK: + return CURLE_OK; + case RUSTLS_RESULT_NULL_PARAMETER: + return CURLE_BAD_FUNCTION_ARGUMENT; + default: + return CURLE_RECV_ERROR; } } -static void -rustls_failf(struct Curl_easy *data, const rustls_result rr, const char *msg) +static void rustls_failf(struct Curl_easy *data, const rustls_result rr, + const char *msg) { char errorbuf[STRERROR_LEN]; size_t errorlen; @@ -76,8 +75,8 @@ rustls_failf(struct Curl_easy *data, const rustls_result rr, const char *msg) failf(data, "%s: %.*s", msg, (int)errorlen, errorbuf); } -static bool -cr_data_pending(struct Curl_cfilter *cf, const struct Curl_easy *data) +static bool cr_data_pending(struct Curl_cfilter *cf, + const struct Curl_easy *data) { const struct ssl_connect_data *ctx = cf->ctx; struct rustls_ssl_backend_data *backend; @@ -93,11 +92,11 @@ struct io_ctx { struct Curl_easy *data; }; -static int -read_cb(void *userdata, uint8_t *buf, uintptr_t len, uintptr_t *out_n) +static int read_cb(void *userdata, uint8_t *buf, uintptr_t len, + uintptr_t *out_n) { const struct io_ctx *io_ctx = userdata; - struct ssl_connect_data *const connssl = io_ctx->cf->ctx; + struct ssl_connect_data * const connssl = io_ctx->cf->ctx; CURLcode result; int ret = 0; size_t nread; @@ -120,8 +119,8 @@ read_cb(void *userdata, uint8_t *buf, uintptr_t len, uintptr_t *out_n) return ret; } -static int -write_cb(void *userdata, const uint8_t *buf, uintptr_t len, uintptr_t *out_n) +static int write_cb(void *userdata, const uint8_t *buf, uintptr_t len, + uintptr_t *out_n) { const struct io_ctx *io_ctx = userdata; CURLcode result; @@ -146,8 +145,8 @@ write_cb(void *userdata, const uint8_t *buf, uintptr_t len, uintptr_t *out_n) static ssize_t tls_recv_more(struct Curl_cfilter *cf, struct Curl_easy *data, CURLcode *err) { - const struct ssl_connect_data *const connssl = cf->ctx; - struct rustls_ssl_backend_data *const backend = + const struct ssl_connect_data * const connssl = cf->ctx; + struct rustls_ssl_backend_data * const backend = (struct rustls_ssl_backend_data *)connssl->backend; struct io_ctx io_ctx; size_t tls_bytes_read = 0; @@ -186,12 +185,11 @@ static ssize_t tls_recv_more(struct Curl_cfilter *cf, * Filter receive method implementation. `plainbuf` and `plainlen` * are always not NULL/0. */ -static CURLcode -cr_recv(struct Curl_cfilter *cf, struct Curl_easy *data, - char *plainbuf, size_t plainlen, size_t *pnread) +static CURLcode cr_recv(struct Curl_cfilter *cf, struct Curl_easy *data, + char *plainbuf, size_t plainlen, size_t *pnread) { - const struct ssl_connect_data *const connssl = cf->ctx; - struct rustls_ssl_backend_data *const backend = + const struct ssl_connect_data * const connssl = cf->ctx; + struct rustls_ssl_backend_data * const backend = (struct rustls_ssl_backend_data *)connssl->backend; struct rustls_connection *rconn = NULL; CURLcode result = CURLE_OK; @@ -300,12 +298,12 @@ static CURLcode cr_flush_out(struct Curl_cfilter *cf, struct Curl_easy *data, * In that case, it will not read anything into Rustls' plaintext input buffer. * It will only drain Rustls' plaintext output buffer into the socket. */ -static CURLcode -cr_send(struct Curl_cfilter *cf, struct Curl_easy *data, - const void *plainbuf, size_t plainlen, size_t *pnwritten) +static CURLcode cr_send(struct Curl_cfilter *cf, struct Curl_easy *data, + const void *plainbuf, size_t plainlen, + size_t *pnwritten) { - const struct ssl_connect_data *const connssl = cf->ctx; - struct rustls_ssl_backend_data *const backend = + const struct ssl_connect_data * const connssl = cf->ctx; + struct rustls_ssl_backend_data * const backend = (struct rustls_ssl_backend_data *)connssl->backend; struct rustls_connection *rconn = NULL; size_t plainwritten = 0; @@ -379,18 +377,15 @@ cr_send(struct Curl_cfilter *cf, struct Curl_easy *data, /* A server certificate verify callback for Rustls that always returns RUSTLS_RESULT_OK, or in other words disable certificate verification. */ -static uint32_t -cr_verify_none(void *userdata, - const rustls_verify_server_cert_params *params) +static uint32_t cr_verify_none(void *userdata, + const rustls_verify_server_cert_params *params) { (void)userdata; (void)params; return RUSTLS_RESULT_OK; } -static int -read_file_into(const char *filename, - struct dynbuf *out) +static int read_file_into(const char *filename, struct dynbuf *out) { FILE *f = curlx_fopen(filename, FOPEN_READTEXT); if(!f) { @@ -464,16 +459,17 @@ cr_get_selected_ciphers(struct Curl_easy *data, if(!id) { if(ptr[0] != '\0') infof(data, "rustls: unknown cipher in list: \"%.*s\"", - (int) (end - ptr), ptr); + (int)(end - ptr), ptr); continue; } /* No duplicates allowed (so selected cannot overflow) */ - for(i = 0; i < count && selected[i] != entry; i++); + for(i = 0; i < count && selected[i] != entry; i++) + ; if(i < count) { if(i >= default13_count) infof(data, "rustls: duplicate cipher in list: \"%.*s\"", - (int) (end - ptr), ptr); + (int)(end - ptr), ptr); continue; } @@ -494,7 +490,8 @@ cr_get_selected_ciphers(struct Curl_easy *data, continue; /* No duplicates allowed (so selected cannot overflow) */ - for(i = 0; i < count && selected[i] != entry; i++); + for(i = 0; i < count && selected[i] != entry; i++) + ; if(i < count) continue; @@ -505,10 +502,10 @@ cr_get_selected_ciphers(struct Curl_easy *data, *selected_size = count; } -static void -cr_keylog_log_cb(struct rustls_str label, - const uint8_t *client_random, size_t client_random_len, - const uint8_t *secret, size_t secret_len) +static void cr_keylog_log_cb(struct rustls_str label, + const uint8_t *client_random, + size_t client_random_len, const uint8_t *secret, + size_t secret_len) { char clabel[KEYLOG_LABEL_MAXLEN]; (void)client_random_len; @@ -528,12 +525,11 @@ init_config_builder(struct Curl_easy *data, const struct rustls_crypto_provider *custom_provider = NULL; uint16_t tls_versions[2] = { - RUSTLS_TLS_VERSION_TLSV1_2, - RUSTLS_TLS_VERSION_TLSV1_3, + RUSTLS_TLS_VERSION_TLSV1_2, + RUSTLS_TLS_VERSION_TLSV1_3, }; size_t tls_versions_len = 2; - size_t cipher_suites_len = - rustls_default_crypto_provider_ciphersuites_len(); + size_t cipher_suites_len = rustls_default_crypto_provider_ciphersuites_len(); CURLcode result = CURLE_OK; rustls_result rr; @@ -602,7 +598,7 @@ init_config_builder(struct Curl_easy *data, &custom_provider_builder); if(rr != RUSTLS_RESULT_OK) { rustls_failf(data, rr, - "failed to create crypto provider builder from default"); + "failed to create crypto provider builder from default"); result = CURLE_SSL_CIPHER; goto cleanup; } @@ -614,13 +610,13 @@ init_config_builder(struct Curl_easy *data, cipher_suites_len); if(rr != RUSTLS_RESULT_OK) { rustls_failf(data, rr, - "failed to set ciphersuites for crypto provider builder"); + "failed to set ciphersuites for crypto provider builder"); result = CURLE_SSL_CIPHER; goto cleanup; } - rr = rustls_crypto_provider_builder_build( - custom_provider_builder, &custom_provider); + rr = rustls_crypto_provider_builder_build(custom_provider_builder, + &custom_provider); if(rr != RUSTLS_RESULT_OK) { rustls_failf(data, rr, "failed to build custom crypto provider"); result = CURLE_SSL_CIPHER; @@ -628,9 +624,9 @@ init_config_builder(struct Curl_easy *data, } rr = rustls_client_config_builder_new_custom(custom_provider, - tls_versions, - tls_versions_len, - config_builder); + tls_versions, + tls_versions_len, + config_builder); if(rr != RUSTLS_RESULT_OK) { rustls_failf(data, rr, "failed to create client config builder"); result = CURLE_SSL_CIPHER; @@ -669,8 +665,7 @@ init_config_builder_alpn(struct Curl_easy *data, infof(data, VTLS_INFOF_ALPN_OFFER_1STR, proto.data); } -static CURLcode -init_config_builder_verifier_crl( +static CURLcode init_config_builder_verifier_crl( struct Curl_easy *data, const struct ssl_primary_config *conn_config, struct rustls_web_pki_server_cert_verifier_builder *builder) @@ -723,7 +718,6 @@ init_config_builder_verifier(struct Curl_easy *data, 1); if(rr != RUSTLS_RESULT_OK) { rustls_failf(data, rr, "failed to parse trusted certificates from blob"); - result = CURLE_SSL_CACERT_BADFILE; goto cleanup; } @@ -734,7 +728,6 @@ init_config_builder_verifier(struct Curl_easy *data, 1); if(rr != RUSTLS_RESULT_OK) { rustls_failf(data, rr, "failed to load trusted certificates"); - result = CURLE_SSL_CACERT_BADFILE; goto cleanup; } @@ -755,8 +748,8 @@ init_config_builder_verifier(struct Curl_easy *data, if(conn_config->CRLfile) { result = init_config_builder_verifier_crl(data, - conn_config, - verifier_builder); + conn_config, + verifier_builder); if(result) { goto cleanup; } @@ -789,8 +782,7 @@ init_config_builder_verifier(struct Curl_easy *data, return result; } -static CURLcode -init_config_builder_platform_verifier( +static CURLcode init_config_builder_platform_verifier( struct Curl_easy *data, struct rustls_client_config_builder *builder) { @@ -890,10 +882,8 @@ init_config_builder_client_auth(struct Curl_easy *data, rr = rustls_certified_key_keys_match(certified_key); if(rr != RUSTLS_RESULT_OK) { - rustls_failf(data, - rr, + rustls_failf(data, rr, "rustls: client certificate and keypair files do not match:"); - result = CURLE_SSL_CERTPROBLEM; goto cleanup; } @@ -1011,9 +1001,9 @@ init_config_builder_ech(struct Curl_easy *data, } #endif /* USE_ECH */ -static CURLcode -cr_init_backend(struct Curl_cfilter *cf, struct Curl_easy *data, - struct rustls_ssl_backend_data *const backend) +static CURLcode cr_init_backend(struct Curl_cfilter *cf, + struct Curl_easy *data, + struct rustls_ssl_backend_data * const backend) { const struct ssl_connect_data *connssl = cf->ctx; const struct ssl_primary_config *conn_config = @@ -1091,9 +1081,7 @@ cr_init_backend(struct Curl_cfilter *cf, struct Curl_easy *data, return result; } - rr = rustls_client_config_builder_build( - config_builder, - &backend->config); + rr = rustls_client_config_builder_build(config_builder, &backend->config); if(rr != RUSTLS_RESULT_OK) { rustls_failf(data, rr, "failed to build client config"); return CURLE_SSL_CONNECT_ERROR; @@ -1116,11 +1104,11 @@ cr_init_backend(struct Curl_cfilter *cf, struct Curl_easy *data, return result; } -static void -cr_set_negotiated_alpn(struct Curl_cfilter *cf, struct Curl_easy *data, - const struct rustls_connection *rconn) +static void cr_set_negotiated_alpn(struct Curl_cfilter *cf, + struct Curl_easy *data, + const struct rustls_connection *rconn) { - struct ssl_connect_data *const connssl = cf->ctx; + struct ssl_connect_data * const connssl = cf->ctx; const uint8_t *protocol = NULL; size_t len = 0; @@ -1133,12 +1121,11 @@ cr_set_negotiated_alpn(struct Curl_cfilter *cf, struct Curl_easy *data, * This function will set `*done` to true once the handshake is complete. * This function never reads the value of `*done*`. */ -static CURLcode -cr_connect(struct Curl_cfilter *cf, - struct Curl_easy *data, bool *done) +static CURLcode cr_connect(struct Curl_cfilter *cf, struct Curl_easy *data, + bool *done) { - struct ssl_connect_data *const connssl = cf->ctx; - const struct rustls_ssl_backend_data *const backend = + struct ssl_connect_data * const connssl = cf->ctx; + const struct rustls_ssl_backend_data * const backend = (struct rustls_ssl_backend_data *)connssl->backend; const struct rustls_connection *rconn = NULL; CURLcode tmperr = CURLE_OK; @@ -1165,9 +1152,9 @@ cr_connect(struct Curl_cfilter *cf, /* Read/write data until the handshake is done or the socket would block. */ for(;;) { /* - * Connection has been established according to Rustls. Set send/recv - * handlers, and update the state machine. - */ + * Connection has been established according to Rustls. Set send/recv + * handlers, and update the state machine. + */ connssl->io_need = CURL_SSL_IO_NEED_NONE; if(!rustls_connection_is_handshaking(rconn)) { /* Rustls claims it is no longer handshaking *before* it has @@ -1186,8 +1173,7 @@ cr_connect(struct Curl_cfilter *cf, } /* REALLY Done with the handshake. */ { - const uint16_t proto = - rustls_connection_get_protocol_version(rconn); + const uint16_t proto = rustls_connection_get_protocol_version(rconn); const rustls_str ciphersuite_name = rustls_connection_get_negotiated_ciphersuite_name(rconn); const rustls_str kex_group_name = @@ -1297,9 +1283,7 @@ cr_connect(struct Curl_cfilter *cf, DEBUGASSERT(FALSE); } -static void * -cr_get_internals(struct ssl_connect_data *connssl, - CURLINFO info) +static void *cr_get_internals(struct ssl_connect_data *connssl, CURLINFO info) { struct rustls_ssl_backend_data *backend = (struct rustls_ssl_backend_data *)connssl->backend; @@ -1308,10 +1292,8 @@ cr_get_internals(struct ssl_connect_data *connssl, return backend->conn; } -static CURLcode -cr_shutdown(struct Curl_cfilter *cf, - struct Curl_easy *data, - const bool send_shutdown, bool *done) +static CURLcode cr_shutdown(struct Curl_cfilter *cf, struct Curl_easy *data, + const bool send_shutdown, bool *done) { struct ssl_connect_data *connssl = cf->ctx; struct rustls_ssl_backend_data *backend = @@ -1373,8 +1355,7 @@ cr_shutdown(struct Curl_cfilter *cf, return result; } -static void -cr_close(struct Curl_cfilter *cf, struct Curl_easy *data) +static void cr_close(struct Curl_cfilter *cf, struct Curl_easy *data) { const struct ssl_connect_data *connssl = cf->ctx; struct rustls_ssl_backend_data *backend = @@ -1398,13 +1379,12 @@ static size_t cr_version(char *buffer, size_t size) return curl_msnprintf(buffer, size, "%.*s", (int)ver.len, ver.data); } -static CURLcode -cr_random(struct Curl_easy *data, unsigned char *entropy, size_t length) +static CURLcode cr_random(struct Curl_easy *data, unsigned char *entropy, + size_t length) { rustls_result rresult = 0; (void)data; - rresult = - rustls_default_crypto_provider_random(entropy, length); + rresult = rustls_default_crypto_provider_random(entropy, length); return map_error(rresult); } diff --git a/lib/vtls/schannel.c b/lib/vtls/schannel.c index 49a4516cdfc8..21314d16ecb3 100644 --- a/lib/vtls/schannel.c +++ b/lib/vtls/schannel.c @@ -34,7 +34,7 @@ #ifdef USE_SCHANNEL #ifndef USE_WINDOWS_SSPI -# error "cannot compile SCHANNEL support without SSPI." +#error "cannot compile SCHANNEL support without SSPI." #endif #include "schannel.h" @@ -67,7 +67,7 @@ */ #ifdef CURL_SCHANNEL_DEV_DEBUG #define SCH_DEV(x) x -#define SCH_DEV_SHOWBOOL(x) \ +#define SCH_DEV_SHOWBOOL(x) \ infof(data, "schannel: " #x " %s", (x) ? "TRUE" : "FALSE"); #else #define SCH_DEV(x) do { } while(0) @@ -159,10 +159,9 @@ static void InitSecBufferDesc(SecBufferDesc *desc, SecBuffer *BufArr, desc->cBuffers = NumArrElem; } -static CURLcode -schannel_set_ssl_version_min_max(DWORD *enabled_protocols, - struct Curl_cfilter *cf, - struct Curl_easy *data) +static CURLcode schannel_set_ssl_version_min_max(DWORD *enabled_protocols, + struct Curl_cfilter *cf, + struct Curl_easy *data) { struct ssl_primary_config *conn_config = Curl_ssl_cf_get_primary_config(cf); long ssl_version = conn_config->version; @@ -222,7 +221,7 @@ struct algo { int id; }; -static const struct algo algs[]= { +static const struct algo algs[] = { CIPHEROPTION(CALG_MD2), CIPHEROPTION(CALG_MD4), CIPHEROPTION(CALG_MD5), @@ -330,8 +329,7 @@ static const struct algo algs[]= { {NULL, 0}, }; -static int -get_alg_id_by_name(const char *name) +static int get_alg_id_by_name(const char *name) { const char *nameEnd = strchr(name, ':'); size_t n = nameEnd ? (size_t)(nameEnd - name) : strlen(name); @@ -346,9 +344,8 @@ get_alg_id_by_name(const char *name) #define NUM_CIPHERS 47 /* There are 47 options listed above */ -static CURLcode -set_ssl_ciphers(SCHANNEL_CRED *schannel_cred, char *ciphers, - ALG_ID *algIds) +static CURLcode set_ssl_ciphers(SCHANNEL_CRED *schannel_cred, char *ciphers, + ALG_ID *algIds) { const char *startCur = ciphers; int algCount = 0; @@ -376,9 +373,8 @@ set_ssl_ciphers(SCHANNEL_CRED *schannel_cred, char *ciphers, } /* 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) +static CURLcode get_cert_location(TCHAR *path, DWORD *store_name, + TCHAR **store_path, TCHAR **thumbprint) { TCHAR *sep; TCHAR *store_path_start; @@ -400,14 +396,11 @@ get_cert_location(TCHAR *path, DWORD *store_name, TCHAR **store_path, *store_name = CERT_SYSTEM_STORE_SERVICES; else if(_tcsncmp(path, TEXT("Users"), store_name_len) == 0) *store_name = CERT_SYSTEM_STORE_USERS; - else if(_tcsncmp(path, TEXT("CurrentUserGroupPolicy"), - store_name_len) == 0) + else if(_tcsncmp(path, TEXT("CurrentUserGroupPolicy"), store_name_len) == 0) *store_name = CERT_SYSTEM_STORE_CURRENT_USER_GROUP_POLICY; - else if(_tcsncmp(path, TEXT("LocalMachineGroupPolicy"), - store_name_len) == 0) + else if(_tcsncmp(path, TEXT("LocalMachineGroupPolicy"), store_name_len) == 0) *store_name = CERT_SYSTEM_STORE_LOCAL_MACHINE_GROUP_POLICY; - else if(_tcsncmp(path, TEXT("LocalMachineEnterprise"), - store_name_len) == 0) + else if(_tcsncmp(path, TEXT("LocalMachineEnterprise"), store_name_len) == 0) *store_name = CERT_SYSTEM_STORE_LOCAL_MACHINE_ENTERPRISE; else return CURLE_SSL_CERTPROBLEM; @@ -431,9 +424,8 @@ get_cert_location(TCHAR *path, DWORD *store_name, TCHAR **store_path, return CURLE_OK; } -static CURLcode -schannel_acquire_credential_handle(struct Curl_cfilter *cf, - struct Curl_easy *data) +static CURLcode schannel_acquire_credential_handle(struct Curl_cfilter *cf, + struct Curl_easy *data) { struct ssl_connect_data *connssl = cf->ctx; struct ssl_primary_config *conn_config = Curl_ssl_cf_get_primary_config(cf); @@ -461,37 +453,36 @@ schannel_acquire_credential_handle(struct Curl_cfilter *cf, if(ssl_config->no_revoke) { flags |= SCH_CRED_IGNORE_NO_REVOCATION_CHECK | - SCH_CRED_IGNORE_REVOCATION_OFFLINE; + SCH_CRED_IGNORE_REVOCATION_OFFLINE; DEBUGF(infof(data, "schannel: disabled server certificate revocation " - "checks")); + "checks")); } else if(ssl_config->revoke_best_effort) { flags |= SCH_CRED_IGNORE_NO_REVOCATION_CHECK | - SCH_CRED_IGNORE_REVOCATION_OFFLINE | SCH_CRED_REVOCATION_CHECK_CHAIN; + SCH_CRED_IGNORE_REVOCATION_OFFLINE | + SCH_CRED_REVOCATION_CHECK_CHAIN; DEBUGF(infof(data, "schannel: ignore revocation offline errors")); } else { flags |= SCH_CRED_REVOCATION_CHECK_CHAIN; - DEBUGF(infof(data, - "schannel: checking server certificate revocation")); + DEBUGF(infof(data, "schannel: checking server certificate revocation")); } } else { flags = SCH_CRED_MANUAL_CRED_VALIDATION | - SCH_CRED_IGNORE_NO_REVOCATION_CHECK | - SCH_CRED_IGNORE_REVOCATION_OFFLINE; - DEBUGF(infof(data, - "schannel: disabled server cert revocation checks")); + SCH_CRED_IGNORE_NO_REVOCATION_CHECK | + SCH_CRED_IGNORE_REVOCATION_OFFLINE; + DEBUGF(infof(data, "schannel: disabled server cert revocation checks")); } if(!conn_config->verifyhost) { flags |= SCH_CRED_NO_SERVERNAME_CHECK; DEBUGF(infof(data, "schannel: verifyhost setting prevents Schannel from " - "comparing the supplied target name with the subject " - "names in server certificates.")); + "comparing the supplied target name with the subject " + "names in server certificates.")); } if(!ssl_config->auto_client_cert) { @@ -508,8 +499,7 @@ schannel_acquire_credential_handle(struct Curl_cfilter *cf, case CURL_SSLVERSION_TLSv1_0: case CURL_SSLVERSION_TLSv1_1: case CURL_SSLVERSION_TLSv1_2: - case CURL_SSLVERSION_TLSv1_3: - { + case CURL_SSLVERSION_TLSv1_3: { result = schannel_set_ssl_version_min_max(&enabled_protocols, cf, data); if(result) return result; @@ -550,7 +540,7 @@ schannel_acquire_credential_handle(struct Curl_cfilter *cf, result = get_cert_location(cert_path, &cert_store_name, &cert_store_path, &cert_thumbprint_str); - if(result && (data->set.ssl.primary.clientcert[0]!='\0')) + if(result && (data->set.ssl.primary.clientcert[0] != '\0')) fInCert = curlx_fopen(data->set.ssl.primary.clientcert, "rb"); if(result && !fInCert) { @@ -579,7 +569,7 @@ schannel_acquire_credential_handle(struct Curl_cfilter *cf, https://learn.microsoft.com/archive/msdn-technet-forums/3e7bc95f-b21a-4bcd-bd2c-7f996718cae5 */ CRYPT_DATA_BLOB datablob; - WCHAR* pszPassword; + WCHAR *pszPassword; size_t pwd_len = 0; int str_w_len = 0; int cert_find_flags; @@ -613,12 +603,12 @@ schannel_acquire_credential_handle(struct Curl_cfilter *cf, } /* Convert key-pair data to the in-memory certificate store */ - datablob.pbData = (BYTE*)certdata; + datablob.pbData = (BYTE *)certdata; datablob.cbData = (DWORD)certsize; if(data->set.ssl.key_passwd) pwd_len = strlen(data->set.ssl.key_passwd); - pszPassword = (WCHAR*)curlx_malloc(sizeof(WCHAR)*(pwd_len + 1)); + pszPassword = (WCHAR *)curlx_malloc(sizeof(WCHAR) * (pwd_len + 1)); if(pszPassword) { if(pwd_len > 0) str_w_len = MultiByteToWideChar(CP_UTF8, @@ -854,8 +844,8 @@ schannel_acquire_credential_handle(struct Curl_cfilter *cf, return CURLE_OK; } -static CURLcode -schannel_connect_step1(struct Curl_cfilter *cf, struct Curl_easy *data) +static CURLcode schannel_connect_step1(struct Curl_cfilter *cf, + struct Curl_easy *data) { size_t written = 0; struct ssl_connect_data *connssl = cf->ctx; @@ -874,8 +864,7 @@ schannel_connect_step1(struct Curl_cfilter *cf, struct Curl_easy *data) CURLcode result; DEBUGASSERT(backend); - DEBUGF(infof(data, - "schannel: SSL/TLS connection with %s port %d (step 1/3)", + DEBUGF(infof(data, "schannel: SSL/TLS connection with %s port %d (step 1/3)", connssl->peer.hostname, connssl->peer.port)); if(curlx_verify_windows_version(5, 1, 0, PLATFORM_WINNT, @@ -899,7 +888,7 @@ schannel_connect_step1(struct Curl_cfilter *cf, struct Curl_easy *data) } else { failf(data, "schannel: this version of Windows is too old to support " - "certificate verification via CA bundle file."); + "certificate verification via CA bundle file."); return CURLE_SSL_CACERT_BADFILE; } } @@ -952,7 +941,7 @@ schannel_connect_step1(struct Curl_cfilter *cf, struct Curl_easy *data) int cur = 0; int list_start_index = 0; unsigned int *extension_len = NULL; - unsigned short* list_len = NULL; + unsigned short *list_len = NULL; struct alpn_proto_buf proto; /* The first four bytes will be an unsigned int indicating number @@ -968,7 +957,7 @@ schannel_connect_step1(struct Curl_cfilter *cf, struct Curl_easy *data) /* The next two bytes will be an unsigned short indicating the number of bytes used to list the preferred protocols. */ - list_len = (unsigned short*)(void *)(&alpn_buffer[cur]); + list_len = (unsigned short *)(void *)(&alpn_buffer[cur]); cur += (int)sizeof(unsigned short); list_start_index = cur; @@ -1006,8 +995,8 @@ schannel_connect_step1(struct Curl_cfilter *cf, struct Curl_easy *data) /* security request flags */ backend->req_flags = ISC_REQ_SEQUENCE_DETECT | ISC_REQ_REPLAY_DETECT | - ISC_REQ_CONFIDENTIALITY | ISC_REQ_ALLOCATE_MEMORY | - ISC_REQ_STREAM; + ISC_REQ_CONFIDENTIALITY | ISC_REQ_ALLOCATE_MEMORY | + ISC_REQ_STREAM; if(!ssl_config->auto_client_cert) { backend->req_flags |= ISC_REQ_USE_SUPPLIED_CREDS; @@ -1131,8 +1120,8 @@ static CURLcode schannel_error(struct Curl_easy *data, } } -static CURLcode -schannel_connect_step2(struct Curl_cfilter *cf, struct Curl_easy *data) +static CURLcode schannel_connect_step2(struct Curl_cfilter *cf, + struct Curl_easy *data) { struct ssl_connect_data *connssl = cf->ctx; struct schannel_ssl_backend_data *backend = @@ -1155,8 +1144,7 @@ schannel_connect_step2(struct Curl_cfilter *cf, struct Curl_easy *data) doread = (connssl->io_need & CURL_SSL_IO_NEED_SEND) ? FALSE : TRUE; connssl->io_need = CURL_SSL_IO_NEED_NONE; - DEBUGF(infof(data, - "schannel: SSL/TLS connection with %s port %d (step 2/3)", + DEBUGF(infof(data, "schannel: SSL/TLS connection with %s port %d (step 2/3)", connssl->peer.hostname, connssl->peer.port)); if(!backend->cred || !backend->ctxt) @@ -1361,7 +1349,8 @@ schannel_connect_step2(struct Curl_cfilter *cf, struct Curl_easy *data) if(backend->encdata_offset > inbuf[1].cbBuffer) { memmove(backend->encdata_buffer, (backend->encdata_buffer + backend->encdata_offset) - - inbuf[1].cbBuffer, inbuf[1].cbBuffer); + inbuf[1].cbBuffer, + inbuf[1].cbBuffer); backend->encdata_offset = inbuf[1].cbBuffer; if(sspi_status == SEC_I_CONTINUE_NEEDED) { doread = FALSE; @@ -1415,8 +1404,7 @@ schannel_connect_step2(struct Curl_cfilter *cf, struct Curl_easy *data) return CURLE_OK; } -static bool -valid_cert_encoding(const CERT_CONTEXT *cert_context) +static bool valid_cert_encoding(const CERT_CONTEXT *cert_context) { return (cert_context != NULL) && ((cert_context->dwCertEncodingType & X509_ASN_ENCODING) != 0) && @@ -1424,12 +1412,11 @@ valid_cert_encoding(const CERT_CONTEXT *cert_context) (cert_context->cbCertEncoded > 0); } -typedef bool(*Read_crt_func)(const CERT_CONTEXT *ccert_context, - bool reverse_order, void *arg); +typedef bool (*Read_crt_func)(const CERT_CONTEXT *ccert_context, + bool reverse_order, void *arg); -static void -traverse_cert_store(const CERT_CONTEXT *context, Read_crt_func func, - void *arg) +static void traverse_cert_store(const CERT_CONTEXT *context, + Read_crt_func func, void *arg) { const CERT_CONTEXT *current_context = NULL; bool should_continue = TRUE; @@ -1454,9 +1441,8 @@ traverse_cert_store(const CERT_CONTEXT *context, Read_crt_func func, CertFreeCertificateContext(current_context); } -static bool -cert_counter_callback(const CERT_CONTEXT *ccert_context, bool reverse_order, - void *certs_count) +static bool cert_counter_callback(const CERT_CONTEXT *ccert_context, + bool reverse_order, void *certs_count) { (void)reverse_order; if(valid_cert_encoding(ccert_context)) @@ -1466,22 +1452,20 @@ cert_counter_callback(const CERT_CONTEXT *ccert_context, bool reverse_order, return TRUE; } -struct Adder_args -{ +struct Adder_args { struct Curl_easy *data; CURLcode result; int idx; int certs_count; }; -static bool -add_cert_to_certinfo(const CERT_CONTEXT *ccert_context, bool reverse_order, - void *raw_arg) +static bool add_cert_to_certinfo(const CERT_CONTEXT *ccert_context, + bool reverse_order, void *raw_arg) { - struct Adder_args *args = (struct Adder_args*)raw_arg; + struct Adder_args *args = (struct Adder_args *)raw_arg; args->result = CURLE_OK; if(valid_cert_encoding(ccert_context)) { - const char *beg = (const char *) ccert_context->pbCertEncoded; + const char *beg = (const char *)ccert_context->pbCertEncoded; const char *end = beg + ccert_context->cbCertEncoded; int insert_index = reverse_order ? (args->certs_count - 1) - args->idx : args->idx; @@ -1511,8 +1495,8 @@ static void schannel_session_free(void *sessionid) } } -static CURLcode -schannel_connect_step3(struct Curl_cfilter *cf, struct Curl_easy *data) +static CURLcode schannel_connect_step3(struct Curl_cfilter *cf, + struct Curl_easy *data) { struct ssl_connect_data *connssl = cf->ctx; struct schannel_ssl_backend_data *backend = @@ -1527,8 +1511,7 @@ schannel_connect_step3(struct Curl_cfilter *cf, struct Curl_easy *data) DEBUGASSERT(ssl_connect_3 == connssl->connecting_state); DEBUGASSERT(backend); - DEBUGF(infof(data, - "schannel: SSL/TLS connection with %s port %d (step 3/3)", + DEBUGF(infof(data, "schannel: SSL/TLS connection with %s port %d (step 3/3)", connssl->peer.hostname, connssl->peer.port)); if(!backend->cred) @@ -1886,9 +1869,8 @@ schannel_recv_renegotiate(struct Curl_cfilter *cf, struct Curl_easy *data, return result; } -static CURLcode -schannel_send(struct Curl_cfilter *cf, struct Curl_easy *data, - const void *buf, size_t len, size_t *pnwritten) +static CURLcode schannel_send(struct Curl_cfilter *cf, struct Curl_easy *data, + const void *buf, size_t len, size_t *pnwritten) { size_t data_len = 0; unsigned char *ptr = NULL; @@ -2018,7 +2000,7 @@ schannel_send(struct Curl_cfilter *cf, struct Curl_easy *data, else if(sspi_status == SEC_E_INSUFFICIENT_MEMORY) { result = CURLE_OUT_OF_MEMORY; } - else{ + else { result = CURLE_SEND_ERROR; } @@ -2032,9 +2014,8 @@ schannel_send(struct Curl_cfilter *cf, struct Curl_easy *data, return result; } -static CURLcode -schannel_recv(struct Curl_cfilter *cf, struct Curl_easy *data, - char *buf, size_t len, size_t *pnread) +static CURLcode schannel_recv(struct Curl_cfilter *cf, struct Curl_easy *data, + char *buf, size_t len, size_t *pnread) { size_t size = 0; size_t nread = 0; @@ -2170,7 +2151,7 @@ schannel_recv(struct Curl_cfilter *cf, struct Curl_easy *data, /* https://learn.microsoft.com/windows/win32/api/sspi/nf-sspi-decryptmessage */ sspi_status = Curl_pSecFn->DecryptMessage(&backend->ctxt->ctxt_handle, - &inbuf_desc, 0, NULL); + &inbuf_desc, 0, NULL); /* check if everything went fine (server may want to renegotiate or shutdown the connection context) */ @@ -2231,7 +2212,8 @@ schannel_recv(struct Curl_cfilter *cf, struct Curl_easy *data, buffer */ memmove(backend->encdata_buffer, (backend->encdata_buffer + backend->encdata_offset) - - inbuf[3].cbBuffer, inbuf[3].cbBuffer); + inbuf[3].cbBuffer, + inbuf[3].cbBuffer); backend->encdata_offset = inbuf[3].cbBuffer; } @@ -2761,7 +2743,7 @@ HCERTSTORE Curl_schannel_get_cached_cert_store(struct Curl_cfilter *cf, share = Curl_hash_pick(&multi->proto_hash, CURL_UNCONST(MPROTO_SCHANNEL_CERT_SHARE_KEY), - sizeof(MPROTO_SCHANNEL_CERT_SHARE_KEY)-1); + sizeof(MPROTO_SCHANNEL_CERT_SHARE_KEY) - 1); if(!share || !share->cert_store) { return NULL; } @@ -2809,7 +2791,7 @@ HCERTSTORE Curl_schannel_get_cached_cert_store(struct Curl_cfilter *cf, static void schannel_cert_share_free(void *key, size_t key_len, void *p) { struct schannel_cert_share *share = p; - DEBUGASSERT(key_len == (sizeof(MPROTO_SCHANNEL_CERT_SHARE_KEY)-1)); + DEBUGASSERT(key_len == (sizeof(MPROTO_SCHANNEL_CERT_SHARE_KEY) - 1)); DEBUGASSERT(!memcmp(MPROTO_SCHANNEL_CERT_SHARE_KEY, key, key_len)); (void)key; (void)key_len; @@ -2839,7 +2821,7 @@ bool Curl_schannel_set_cached_cert_store(struct Curl_cfilter *cf, share = Curl_hash_pick(&multi->proto_hash, CURL_UNCONST(MPROTO_SCHANNEL_CERT_SHARE_KEY), - sizeof(MPROTO_SCHANNEL_CERT_SHARE_KEY)-1); + sizeof(MPROTO_SCHANNEL_CERT_SHARE_KEY) - 1); if(!share) { share = curlx_calloc(1, sizeof(*share)); if(!share) { @@ -2847,7 +2829,7 @@ bool Curl_schannel_set_cached_cert_store(struct Curl_cfilter *cf, } if(!Curl_hash_add2(&multi->proto_hash, CURL_UNCONST(MPROTO_SCHANNEL_CERT_SHARE_KEY), - sizeof(MPROTO_SCHANNEL_CERT_SHARE_KEY)-1, + sizeof(MPROTO_SCHANNEL_CERT_SHARE_KEY) - 1, share, schannel_cert_share_free)) { curlx_free(share); return FALSE; diff --git a/lib/vtls/schannel.h b/lib/vtls/schannel.h index 9d0bea221a9b..47017c5f5686 100644 --- a/lib/vtls/schannel.h +++ b/lib/vtls/schannel.h @@ -69,15 +69,14 @@ * (and only here). */ #if defined(OPENSSL_IS_BORINGSSL) || defined(OPENSSL_IS_AWSLC) -# undef X509_NAME -# undef X509_CERT_PAIR -# undef X509_EXTENSIONS +#undef X509_NAME +#undef X509_CERT_PAIR +#undef X509_EXTENSIONS #endif extern const struct Curl_ssl Curl_ssl_schannel; -CURLcode Curl_verify_host(struct Curl_cfilter *cf, - struct Curl_easy *data); +CURLcode Curl_verify_host(struct Curl_cfilter *cf, struct Curl_easy *data); CURLcode Curl_verify_certificate(struct Curl_cfilter *cf, struct Curl_easy *data); diff --git a/lib/vtls/schannel_verify.c b/lib/vtls/schannel_verify.c index 4ff7b5d536a1..e1a3731457b8 100644 --- a/lib/vtls/schannel_verify.c +++ b/lib/vtls/schannel_verify.c @@ -33,7 +33,7 @@ #ifdef USE_SCHANNEL #ifndef USE_WINDOWS_SSPI -# error "cannot compile SCHANNEL support without SSPI." +#error "cannot compile SCHANNEL support without SSPI." #endif #include "schannel.h" @@ -157,8 +157,8 @@ static CURLcode add_certs_data_to_store(HCERTSTORE trust_store, const CERT_CONTEXT *cert_context = NULL; BOOL add_cert_result = FALSE; DWORD actual_content_type = 0; - DWORD cert_size = (DWORD) - ((end_cert_ptr + end_cert_len) - begin_cert_ptr); + DWORD cert_size = + (DWORD)((end_cert_ptr + end_cert_len) - begin_cert_ptr); cert_blob.pbData = (BYTE *)CURL_UNCONST(begin_cert_ptr); cert_blob.cbData = cert_size; @@ -238,13 +238,11 @@ static CURLcode add_certs_data_to_store(HCERTSTORE trust_store, if(result == CURLE_OK) { if(!num_certs) { - infof(data, - "schannel: did not add any certificates from CA file '%s'", + infof(data, "schannel: did not add any certificates from CA file '%s'", ca_file_text); } else { - infof(data, - "schannel: added %d certificate(s) from CA file '%s'", + infof(data, "schannel: added %d certificate(s) from CA file '%s'", num_certs, ca_file_text); } } @@ -266,9 +264,7 @@ static CURLcode add_certs_file_to_store(HCERTSTORE trust_store, ca_file_tstr = curlx_convert_UTF8_to_tchar(ca_file); if(!ca_file_tstr) { char buffer[WINAPI_ERROR_LEN]; - failf(data, - "schannel: invalid path name for CA file '%s': %s", - ca_file, + failf(data, "schannel: invalid path name for CA file '%s': %s", ca_file, curlx_winapi_strerror(GetLastError(), buffer, sizeof(buffer))); result = CURLE_SSL_CACERT_BADFILE; goto cleanup; @@ -288,9 +284,7 @@ static CURLcode add_certs_file_to_store(HCERTSTORE trust_store, NULL); if(ca_file_handle == INVALID_HANDLE_VALUE) { char buffer[WINAPI_ERROR_LEN]; - failf(data, - "schannel: failed to open CA file '%s': %s", - ca_file, + failf(data, "schannel: failed to open CA file '%s': %s", ca_file, curlx_winapi_strerror(GetLastError(), buffer, sizeof(buffer))); result = CURLE_SSL_CACERT_BADFILE; goto cleanup; @@ -298,8 +292,7 @@ static CURLcode add_certs_file_to_store(HCERTSTORE trust_store, if(!GetFileSizeEx(ca_file_handle, &file_size)) { char buffer[WINAPI_ERROR_LEN]; - failf(data, - "schannel: failed to determine size of CA file '%s': %s", + failf(data, "schannel: failed to determine size of CA file '%s': %s", ca_file, curlx_winapi_strerror(GetLastError(), buffer, sizeof(buffer))); result = CURLE_SSL_CACERT_BADFILE; @@ -307,8 +300,7 @@ static CURLcode add_certs_file_to_store(HCERTSTORE trust_store, } if(file_size.QuadPart > MAX_CAFILE_SIZE) { - failf(data, - "schannel: CA file exceeds max size of %u bytes", + failf(data, "schannel: CA file exceeds max size of %u bytes", MAX_CAFILE_SIZE); result = CURLE_SSL_CACERT_BADFILE; goto cleanup; @@ -328,9 +320,7 @@ static CURLcode add_certs_file_to_store(HCERTSTORE trust_store, if(!ReadFile(ca_file_handle, ca_file_buffer + total_bytes_read, bytes_to_read, &bytes_read, NULL)) { char buffer[WINAPI_ERROR_LEN]; - failf(data, - "schannel: failed to read from CA file '%s': %s", - ca_file, + failf(data, "schannel: failed to read from CA file '%s': %s", ca_file, curlx_winapi_strerror(GetLastError(), buffer, sizeof(buffer))); result = CURLE_SSL_CACERT_BADFILE; goto cleanup; @@ -455,12 +445,11 @@ static DWORD cert_get_name_string(struct Curl_easy *data, } /* -* Returns TRUE if the hostname is a numeric IPv4/IPv6 Address, -* and populates the buffer with IPv4/IPv6 info. -*/ + * Returns TRUE if the hostname is a numeric IPv4/IPv6 Address, + * and populates the buffer with IPv4/IPv6 info. + */ -static bool get_num_host_info(struct num_ip_data *ip_blob, - LPCSTR hostname) +static bool get_num_host_info(struct num_ip_data *ip_blob, LPCSTR hostname) { struct in_addr ia; struct in6_addr ia6; @@ -520,9 +509,8 @@ static bool get_alt_name_info(struct Curl_easy *data, &decode_para, alt_name_info, alt_name_info_size)) { - failf(data, - "schannel: CryptDecodeObjectEx() returned no alternate name " - "information."); + failf(data, "schannel: CryptDecodeObjectEx() returned no alternate name " + "information."); return result; } result = TRUE; @@ -530,8 +518,7 @@ static bool get_alt_name_info(struct Curl_easy *data, } /* Verify the server's hostname */ -CURLcode Curl_verify_host(struct Curl_cfilter *cf, - struct Curl_easy *data) +CURLcode Curl_verify_host(struct Curl_cfilter *cf, struct Curl_easy *data) { CURLcode result = CURLE_PEER_FAILED_VERIFICATION; struct ssl_connect_data *connssl = cf->ctx; @@ -545,7 +532,7 @@ CURLcode Curl_verify_host(struct Curl_cfilter *cf, DWORD actual_len = 0; PCERT_ALT_NAME_INFO alt_name_info = NULL; DWORD alt_name_info_size = 0; - struct num_ip_data ip_blob = { 0 }; + struct num_ip_data ip_blob = {0}; bool Win8_compat; struct num_ip_data *p = &ip_blob; DWORD i; @@ -840,7 +827,7 @@ CURLcode Curl_verify_certificate(struct Curl_cfilter *cf, * 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); + CERT_TRUST_IS_OFFLINE_REVOCATION); } if(dwTrustErrorMask) { diff --git a/lib/vtls/vtls.c b/lib/vtls/vtls.c index 6eb60e41cf99..e342953778b0 100644 --- a/lib/vtls/vtls.c +++ b/lib/vtls/vtls.c @@ -93,14 +93,13 @@ dest->var = NULL; \ } while(0) -#define CLONE_BLOB(var) \ - do { \ - if(blobdup(&dest->var, source->var)) \ - return FALSE; \ +#define CLONE_BLOB(var) \ + do { \ + if(blobdup(&dest->var, source->var)) \ + return FALSE; \ } while(0) -static CURLcode blobdup(struct curl_blob **dest, - struct curl_blob *src) +static CURLcode blobdup(struct curl_blob **dest, struct curl_blob *src) { DEBUGASSERT(dest); DEBUGASSERT(!*dest); @@ -149,8 +148,8 @@ static const struct alpn_spec ALPN_SPEC_H2_H11 = { #endif #if !defined(CURL_DISABLE_HTTP) || !defined(CURL_DISABLE_PROXY) -static const struct alpn_spec * -alpn_get_spec(http_majors allowed, bool use_alpn) +static const struct alpn_spec *alpn_get_spec(http_majors allowed, + bool use_alpn) { if(!use_alpn) return NULL; @@ -170,7 +169,6 @@ alpn_get_spec(http_majors allowed, bool use_alpn) #endif /* !CURL_DISABLE_HTTP || !CURL_DISABLE_PROXY */ #endif /* USE_SSL */ - void Curl_ssl_easy_config_init(struct Curl_easy *data) { /* @@ -185,10 +183,9 @@ void Curl_ssl_easy_config_init(struct Curl_easy *data) #endif } -static bool -match_ssl_primary_config(struct Curl_easy *data, - struct ssl_primary_config *c1, - struct ssl_primary_config *c2) +static bool match_ssl_primary_config(struct Curl_easy *data, + struct ssl_primary_config *c1, + struct ssl_primary_config *c2) { (void)data; if((c1->version == c2->version) && @@ -324,8 +321,7 @@ CURLcode Curl_ssl_easy_config_complete(struct Curl_easy *data) sslc->primary.cipher_list13 = data->set.str[STRING_SSL_CIPHER13_LIST]; sslc->primary.signature_algorithms = data->set.str[STRING_SSL_SIGNATURE_ALGORITHMS]; - sslc->primary.pinned_key = - data->set.str[STRING_SSL_PINNEDPUBLICKEY]; + sslc->primary.pinned_key = data->set.str[STRING_SSL_PINNEDPUBLICKEY]; sslc->primary.cert_blob = data->set.blobs[BLOB_CERT]; sslc->primary.ca_info_blob = data->set.blobs[BLOB_CAINFO]; sslc->primary.curves = data->set.str[STRING_SSL_EC_CURVES]; @@ -538,9 +534,9 @@ void Curl_ssl_close_all(struct Curl_easy *data) Curl_ssl->close_all(data); } -CURLcode Curl_ssl_adjust_pollset(struct Curl_cfilter *cf, - struct Curl_easy *data, - struct easy_pollset *ps) +CURLcode Curl_ssl_adjust_pollset(struct Curl_cfilter *cf, + struct Curl_easy *data, + struct easy_pollset *ps) { struct ssl_connect_data *connssl = cf->ctx; @@ -628,7 +624,7 @@ CURLcode Curl_ssl_init_certinfo(struct Curl_easy *data, int num) Curl_ssl_free_certinfo(data); /* Allocate the required certificate information structures */ - table = curlx_calloc((size_t) num, sizeof(struct curl_slist *)); + table = curlx_calloc((size_t)num, sizeof(struct curl_slist *)); if(!table) return CURLE_OUT_OF_MEMORY; @@ -661,8 +657,7 @@ CURLcode Curl_ssl_push_certinfo_len(struct Curl_easy *data, curlx_dyn_addn(&build, value, valuelen)) return CURLE_OUT_OF_MEMORY; - nl = Curl_slist_append_nodup(ci->certinfo[certnum], - curlx_dyn_ptr(&build)); + nl = Curl_slist_append_nodup(ci->certinfo[certnum], curlx_dyn_ptr(&build)); if(!nl) { curlx_dyn_free(&build); curl_slist_free_all(ci->certinfo[certnum]); @@ -798,8 +793,8 @@ CURLcode Curl_pin_peer_pubkey(struct Curl_easy *data, pinned_hash = pinnedpubkey; while(pinned_hash && - !strncmp(pinned_hash, "sha256//", (sizeof("sha256//")-1))) { - pinned_hash = pinned_hash + (sizeof("sha256//")-1); + !strncmp(pinned_hash, "sha256//", (sizeof("sha256//") - 1))) { + pinned_hash = pinned_hash + (sizeof("sha256//") - 1); end_pos = strchr(pinned_hash, ';'); pinned_hash_len = end_pos ? (size_t)(end_pos - pinned_hash) : strlen(pinned_hash); @@ -845,7 +840,7 @@ CURLcode Curl_pin_peer_pubkey(struct Curl_easy *data, * if the size of our certificate is bigger than the file * size then it cannot match */ - size = curlx_sotouz((curl_off_t) filesize); + size = curlx_sotouz((curl_off_t)filesize); if(pubkeylen > size) goto end; @@ -1277,7 +1272,7 @@ CURLcode Curl_ssl_peer_init(struct ssl_peer *peer, /* not an IP address, normalize according to RCC 6066 ch. 3, * max len of SNI is 2^16-1, no trailing dot */ size_t len = strlen(peer->hostname); - if(len && (peer->hostname[len-1] == '.')) + if(len && (peer->hostname[len - 1] == '.')) len--; if(len < USHRT_MAX) { peer->sni = curlx_calloc(1, len + 1); @@ -1563,7 +1558,7 @@ static CURLcode ssl_cf_shutdown(struct Curl_cfilter *cf, *done = TRUE; /* If we have done the SSL handshake, shut down the connection cleanly */ if(cf->connected && (connssl->state == ssl_connection_complete) && - !cf->shutdown && Curl_ssl->shut_down) { + !cf->shutdown && Curl_ssl->shut_down) { struct cf_call_data save; CF_DATA_SAVE(save, cf, data); @@ -1781,7 +1776,7 @@ static CURLcode cf_ssl_proxy_create(struct Curl_cfilter **pcf, #ifdef USE_HTTP2 if(conn->http_proxy.proxytype == CURLPROXY_HTTPS2) { use_alpn = TRUE; - allowed = (CURL_HTTP_V1x|CURL_HTTP_V2x); + allowed = (CURL_HTTP_V1x | CURL_HTTP_V2x); } #endif @@ -1847,7 +1842,7 @@ static CURLcode vtls_shutdown_blocking(struct Curl_cfilter *cf, } result = connssl->ssl_impl->shut_down(cf, data, send_shutdown, done); - if(result ||*done) + if(result || *done) goto out; if(connssl->io_need) { @@ -2042,7 +2037,7 @@ CURLcode Curl_alpn_set_negotiated(struct Curl_cfilter *cf, if(proto && proto_len) { if(memchr(proto, '\0', proto_len)) { failf(data, "ALPN: server selected protocol contains NUL. " - "Refusing to continue."); + "Refusing to continue."); result = CURLE_SSL_CONNECT_ERROR; goto out; } diff --git a/lib/vtls/vtls.h b/lib/vtls/vtls.h index dbe13c59030b..b5b517f0b6fa 100644 --- a/lib/vtls/vtls.h +++ b/lib/vtls/vtls.h @@ -253,16 +253,16 @@ extern struct Curl_cftype Curl_cft_ssl_proxy; #define Curl_ssl_init() 1 #define Curl_ssl_cleanup() Curl_nop_stmt #define Curl_ssl_close_all(x) Curl_nop_stmt -#define Curl_ssl_set_engine(x,y) CURLE_NOT_BUILT_IN +#define Curl_ssl_set_engine(x, y) CURLE_NOT_BUILT_IN #define Curl_ssl_set_engine_default(x) CURLE_NOT_BUILT_IN #define Curl_ssl_engines_list(x) NULL #define Curl_ssl_free_certinfo(x) Curl_nop_stmt -#define Curl_ssl_random(x,y,z) ((void)x, CURLE_NOT_BUILT_IN) +#define Curl_ssl_random(x, y, z) ((void)x, CURLE_NOT_BUILT_IN) #define Curl_ssl_cert_status_request() FALSE -#define Curl_ssl_supports(a,b) FALSE -#define Curl_ssl_cfilter_add(a,b,c) CURLE_NOT_BUILT_IN -#define Curl_ssl_cfilter_remove(a,b,c) CURLE_OK -#define Curl_ssl_cf_get_config(a,b) NULL +#define Curl_ssl_supports(a, b) FALSE +#define Curl_ssl_cfilter_add(a, b, c) CURLE_NOT_BUILT_IN +#define Curl_ssl_cfilter_remove(a, b, c) CURLE_OK +#define Curl_ssl_cf_get_config(a, b) NULL #define Curl_ssl_cf_get_primary_config(a) NULL #endif diff --git a/lib/vtls/vtls_int.h b/lib/vtls/vtls_int.h index 8bf6c6c64be9..0a184f88c127 100644 --- a/lib/vtls/vtls_int.h +++ b/lib/vtls/vtls_int.h @@ -71,8 +71,7 @@ CURLcode Curl_alpn_set_negotiated(struct Curl_cfilter *cf, const unsigned char *proto, size_t proto_len); -bool Curl_alpn_contains_proto(const struct alpn_spec *spec, - const char *proto); +bool Curl_alpn_contains_proto(const struct alpn_spec *spec, const char *proto); /* enum for the nonblocking SSL connection state machine */ typedef enum { @@ -99,11 +98,11 @@ typedef enum { } ssl_earlydata_state; #define CURL_SSL_IO_NEED_NONE (0) -#define CURL_SSL_IO_NEED_RECV (1<<0) -#define CURL_SSL_IO_NEED_SEND (1<<1) +#define CURL_SSL_IO_NEED_RECV (1 << 0) +#define CURL_SSL_IO_NEED_SEND (1 << 1) /* Max earlydata payload we want to send */ -#define CURL_SSL_EARLY_MAX (64*1024) +#define CURL_SSL_EARLY_MAX (64 * 1024) /* Information in each SSL cfilter context: cf->ctx */ struct ssl_connect_data { @@ -130,11 +129,8 @@ struct ssl_connect_data { BIT(input_pending); /* data for SSL_read() may be available */ }; - #undef CF_CTX_CALL_DATA -#define CF_CTX_CALL_DATA(cf) \ - ((struct ssl_connect_data *)(cf)->ctx)->call_data - +#define CF_CTX_CALL_DATA(cf) ((struct ssl_connect_data *)(cf)->ctx)->call_data /* Definitions for SSL Implementations */ @@ -157,8 +153,7 @@ struct Curl_ssl { /* data_pending() shall return TRUE when it wants to get called again to drain internal buffers and deliver data instead of waiting for the socket to get readable */ - bool (*data_pending)(struct Curl_cfilter *cf, - const struct Curl_easy *data); + bool (*data_pending)(struct Curl_cfilter *cf, const struct Curl_easy *data); /* return 0 if a find random is filled in */ CURLcode (*random)(struct Curl_easy *data, unsigned char *entropy, @@ -181,7 +176,7 @@ struct Curl_ssl { struct curl_slist *(*engines_list)(struct Curl_easy *data); CURLcode (*sha256sum)(const unsigned char *input, size_t inputlen, - unsigned char *sha256sum, size_t sha256sumlen); + unsigned char *sha256sum, size_t sha256sumlen); CURLcode (*recv_plain)(struct Curl_cfilter *cf, struct Curl_easy *data, char *buf, size_t len, size_t *pnread); CURLcode (*send_plain)(struct Curl_cfilter *cf, struct Curl_easy *data, @@ -189,7 +184,6 @@ struct Curl_ssl { CURLcode (*get_channel_binding)(struct Curl_easy *data, int sockindex, struct dynbuf *binding); - }; extern const struct Curl_ssl *Curl_ssl; diff --git a/lib/vtls/vtls_scache.c b/lib/vtls/vtls_scache.c index 21dfe2eaa032..b968d8b8f36a 100644 --- a/lib/vtls/vtls_scache.c +++ b/lib/vtls/vtls_scache.c @@ -106,23 +106,21 @@ static void cf_ssl_scache_session_ldestroy(void *udata, void *obj) curlx_free(s); } -CURLcode -Curl_ssl_session_create(void *sdata, size_t sdata_len, - int ietf_tls_id, const char *alpn, - curl_off_t valid_until, size_t earlydata_max, - struct Curl_ssl_session **psession) +CURLcode Curl_ssl_session_create(void *sdata, size_t sdata_len, + int ietf_tls_id, const char *alpn, + curl_off_t valid_until, size_t earlydata_max, + struct Curl_ssl_session **psession) { return Curl_ssl_session_create2(sdata, sdata_len, ietf_tls_id, alpn, valid_until, earlydata_max, NULL, 0, psession); } -CURLcode -Curl_ssl_session_create2(void *sdata, size_t sdata_len, - int ietf_tls_id, const char *alpn, - curl_off_t valid_until, size_t earlydata_max, - unsigned char *quic_tp, size_t quic_tp_len, - struct Curl_ssl_session **psession) +CURLcode Curl_ssl_session_create2(void *sdata, size_t sdata_len, + int ietf_tls_id, const char *alpn, + curl_off_t valid_until, size_t earlydata_max, + unsigned char *quic_tp, size_t quic_tp_len, + struct Curl_ssl_session **psession) { struct Curl_ssl_session *s; @@ -322,7 +320,7 @@ CURLcode Curl_ssl_scache_create(size_t max_peers, } scache->magic = CURL_SCACHE_MAGIC; - scache->default_lifetime_secs = (24*60*60); /* 1 day */ + scache->default_lifetime_secs = (24 * 60 * 60); /* 1 day */ scache->peer_count = max_peers; scache->peers = peers; scache->age = 1; @@ -507,7 +505,7 @@ CURLcode Curl_ssl_peer_key_make(struct Curl_cfilter *cf, if(ssl->version || ssl->version_max) { r = curlx_dyn_addf(&buf, ":TLSVER-%d-%d", ssl->version, - (ssl->version_max >> 16)); + (ssl->version_max >> 16)); if(r) goto out; } @@ -616,19 +614,18 @@ static bool cf_ssl_scache_match_auth(struct Curl_ssl_scache_peer *peer, else if(!Curl_safecmp(peer->clientcert, conn_config->clientcert)) return FALSE; #ifdef USE_TLS_SRP - if(Curl_timestrcmp(peer->srp_username, conn_config->username) || - Curl_timestrcmp(peer->srp_password, conn_config->password)) - return FALSE; + if(Curl_timestrcmp(peer->srp_username, conn_config->username) || + Curl_timestrcmp(peer->srp_password, conn_config->password)) + return FALSE; #endif return TRUE; } -static CURLcode -cf_ssl_find_peer_by_key(struct Curl_easy *data, - struct Curl_ssl_scache *scache, - const char *ssl_peer_key, - struct ssl_primary_config *conn_config, - struct Curl_ssl_scache_peer **ppeer) +static CURLcode cf_ssl_find_peer_by_key(struct Curl_easy *data, + struct Curl_ssl_scache *scache, + const char *ssl_peer_key, + struct ssl_primary_config *conn_config, + struct Curl_ssl_scache_peer **ppeer) { size_t i, peer_key_len = 0; CURLcode result = CURLE_OK; @@ -718,12 +715,11 @@ cf_ssl_get_free_peer(struct Curl_ssl_scache *scache) return peer; } -static CURLcode -cf_ssl_add_peer(struct Curl_easy *data, - struct Curl_ssl_scache *scache, - const char *ssl_peer_key, - struct ssl_primary_config *conn_config, - struct Curl_ssl_scache_peer **ppeer) +static CURLcode cf_ssl_add_peer(struct Curl_easy *data, + struct Curl_ssl_scache *scache, + const char *ssl_peer_key, + struct ssl_primary_config *conn_config, + struct Curl_ssl_scache_peer **ppeer) { struct Curl_ssl_scache_peer *peer = NULL; CURLcode result = CURLE_OK; @@ -1000,7 +996,7 @@ void Curl_ssl_scache_remove_all(struct Curl_cfilter *cf, #ifdef USE_SSLS_EXPORT -#define CURL_SSL_TICKET_MAX (16*1024) +#define CURL_SSL_TICKET_MAX (16 * 1024) static CURLcode cf_ssl_scache_peer_set_hmac(struct Curl_ssl_scache_peer *peer) { diff --git a/lib/vtls/vtls_scache.h b/lib/vtls/vtls_scache.h index 445f21054937..67049462a859 100644 --- a/lib/vtls/vtls_scache.h +++ b/lib/vtls/vtls_scache.h @@ -37,8 +37,8 @@ struct ssl_peer; /* RFC 8446 (TLSv1.3) restrict lifetime to one week max, for * other, less secure versions, we restrict it to a day */ -#define CURL_SCACHE_MAX_13_LIFETIME_SEC (60*60*24*7) -#define CURL_SCACHE_MAX_12_LIFETIME_SEC (60*60*24) +#define CURL_SCACHE_MAX_13_LIFETIME_SEC (60 * 60 * 24 * 7) +#define CURL_SCACHE_MAX_12_LIFETIME_SEC (60 * 60 * 24) /* Create a session cache for up to max_peers endpoints with a total * of up to max_sessions SSL sessions per peer */ @@ -142,22 +142,18 @@ struct Curl_ssl_session { * in case this is not known. * @param psession on return the scached session instance created */ -CURLcode -Curl_ssl_session_create(void *sdata, size_t sdata_len, - int ietf_tls_id, const char *alpn, - curl_off_t valid_until, - size_t earlydata_max, - struct Curl_ssl_session **psession); +CURLcode Curl_ssl_session_create(void *sdata, size_t sdata_len, + int ietf_tls_id, const char *alpn, + curl_off_t valid_until, size_t earlydata_max, + struct Curl_ssl_session **psession); /* Variation of session creation with quic transport parameter bytes, * Takes ownership of `quic_tp` regardless of return code. */ -CURLcode -Curl_ssl_session_create2(void *sdata, size_t sdata_len, - int ietf_tls_id, const char *alpn, - curl_off_t valid_until, - size_t earlydata_max, - unsigned char *quic_tp, size_t quic_tp_len, - struct Curl_ssl_session **psession); +CURLcode Curl_ssl_session_create2(void *sdata, size_t sdata_len, + int ietf_tls_id, const char *alpn, + curl_off_t valid_until, size_t earlydata_max, + unsigned char *quic_tp, size_t quic_tp_len, + struct Curl_ssl_session **psession); /* Destroy a `session` instance. Can be called with NULL. * Does NOT need locking. */ diff --git a/lib/vtls/vtls_spack.c b/lib/vtls/vtls_spack.c index 070bb485a350..ac289f1b2f69 100644 --- a/lib/vtls/vtls_spack.c +++ b/lib/vtls/vtls_spack.c @@ -52,8 +52,8 @@ static CURLcode spack_enc8(struct dynbuf *buf, uint8_t b) return curlx_dyn_addn(buf, &b, 1); } -static CURLcode -spack_dec8(uint8_t *val, const uint8_t **src, const uint8_t *end) +static CURLcode spack_dec8(uint8_t *val, const uint8_t **src, + const uint8_t *end) { if(end - *src < 1) return CURLE_READ_ERROR; @@ -70,8 +70,8 @@ static CURLcode spack_enc16(struct dynbuf *buf, uint16_t val) return curlx_dyn_addn(buf, nval, sizeof(nval)); } -static CURLcode -spack_dec16(uint16_t *val, const uint8_t **src, const uint8_t *end) +static CURLcode spack_dec16(uint16_t *val, const uint8_t **src, + const uint8_t *end) { if(end - *src < 2) return CURLE_READ_ERROR; @@ -90,8 +90,8 @@ static CURLcode spack_enc32(struct dynbuf *buf, uint32_t val) return curlx_dyn_addn(buf, nval, sizeof(nval)); } -static CURLcode -spack_dec32(uint32_t *val, const uint8_t **src, const uint8_t *end) +static CURLcode spack_dec32(uint32_t *val, const uint8_t **src, + const uint8_t *end) { if(end - *src < 4) return CURLE_READ_ERROR; @@ -107,7 +107,7 @@ static CURLcode spack_enc64(struct dynbuf *buf, uint64_t val) nval[0] = (uint8_t)(val >> 56); nval[1] = (uint8_t)(val >> 48); nval[2] = (uint8_t)(val >> 40); - nval[3] = (uint8_t)(val >> 32); \ + nval[3] = (uint8_t)(val >> 32); nval[4] = (uint8_t)(val >> 24); nval[5] = (uint8_t)(val >> 16); nval[6] = (uint8_t)(val >> 8); @@ -115,8 +115,8 @@ static CURLcode spack_enc64(struct dynbuf *buf, uint64_t val) return curlx_dyn_addn(buf, nval, sizeof(nval)); } -static CURLcode -spack_dec64(uint64_t *val, const uint8_t **src, const uint8_t *end) +static CURLcode spack_dec64(uint64_t *val, const uint8_t **src, + const uint8_t *end) { if(end - *src < 8) return CURLE_READ_ERROR; @@ -141,8 +141,8 @@ static CURLcode spack_encstr16(struct dynbuf *buf, const char *s) return r; } -static CURLcode -spack_decstr16(char **val, const uint8_t **src, const uint8_t *end) +static CURLcode spack_decstr16(char **val, const uint8_t **src, + const uint8_t *end) { uint16_t slen; CURLcode r; @@ -158,8 +158,8 @@ spack_decstr16(char **val, const uint8_t **src, const uint8_t *end) return *val ? CURLE_OK : CURLE_OUT_OF_MEMORY; } -static CURLcode spack_encdata16(struct dynbuf *buf, - const uint8_t *data, size_t data_len) +static CURLcode spack_encdata16(struct dynbuf *buf, const uint8_t *data, + size_t data_len) { CURLcode r; if(data_len > UINT16_MAX) @@ -171,9 +171,8 @@ static CURLcode spack_encdata16(struct dynbuf *buf, return r; } -static CURLcode -spack_decdata16(uint8_t **val, size_t *val_len, - const uint8_t **src, const uint8_t *end) +static CURLcode spack_decdata16(uint8_t **val, size_t *val_len, + const uint8_t **src, const uint8_t *end) { uint16_t data_len; CURLcode r; diff --git a/lib/vtls/wolfssl.c b/lib/vtls/wolfssl.c index eae17078fd35..62bf723efd33 100644 --- a/lib/vtls/wolfssl.c +++ b/lib/vtls/wolfssl.c @@ -127,9 +127,9 @@ static CURLcode wssl_connect(struct Curl_cfilter *cf, * (--enable-opensslextra or --enable-all). */ #if defined(HAVE_SECRET_CALLBACK) && defined(WOLFSSL_TLS13) -static int -wssl_tls13_secret_callback(SSL *ssl, int id, const unsigned char *secret, - int secretSz, void *ctx) +static int wssl_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]; @@ -309,8 +309,7 @@ static long wssl_bio_cf_ctrl(WOLFSSL_BIO *bio, int cmd, long num, void *ptr) return ret; } -static int wssl_bio_cf_out_write(WOLFSSL_BIO *bio, - const char *buf, int blen) +static int wssl_bio_cf_out_write(WOLFSSL_BIO *bio, const char *buf, int blen) { struct Curl_cfilter *cf = wolfSSL_BIO_get_data(bio); struct ssl_connect_data *connssl = cf->ctx; @@ -487,7 +486,7 @@ static int wssl_vtls_new_session_cb(WOLFSSL *ssl, WOLFSSL_SESSION *session) { struct Curl_cfilter *cf; - cf = (struct Curl_cfilter*)wolfSSL_get_app_data(ssl); + cf = (struct Curl_cfilter *)wolfSSL_get_app_data(ssl); DEBUGASSERT(cf != NULL); if(cf && session) { struct ssl_connect_data *connssl = cf->ctx; @@ -535,8 +534,8 @@ static CURLcode wssl_on_session_reuse(struct Curl_cfilter *cf, connssl->earlydata_state = ssl_earlydata_await; connssl->state = ssl_connection_deferred; result = Curl_alpn_set_negotiated(cf, data, connssl, - (const unsigned char *)scs->alpn, - scs->alpn ? strlen(scs->alpn) : 0); + (const unsigned char *)scs->alpn, + scs->alpn ? strlen(scs->alpn) : 0); *do_early_data = !result; } return result; @@ -640,7 +639,7 @@ static CURLcode wssl_populate_x509_store(struct Curl_cfilter *cf, } #else infof(data, "ignoring native CA option because wolfSSL was built without " - "native CA support"); + "native CA support"); #endif } #endif /* !NO_FILESYSTEM */ @@ -688,7 +687,7 @@ static CURLcode wssl_populate_x509_store(struct Curl_cfilter *cf, /* Just continue with a warning if no strict certificate verification is required. */ infof(data, "error setting certificate verify locations," - " continuing anyway:"); + " continuing anyway:"); } } else { @@ -707,15 +706,15 @@ static CURLcode wssl_populate_x509_store(struct Curl_cfilter *cf, #define MPROTO_WSSL_X509_KEY "tls:wssl:x509:share" struct wssl_x509_share { - char *CAfile; /* CAfile path used to generate X509 store */ + char *CAfile; /* CAfile path used to generate X509 store */ WOLFSSL_X509_STORE *store; /* cached X509 store or NULL if none */ - struct curltime time; /* when the cached store was created */ + struct curltime time; /* when the cached store was created */ }; static void wssl_x509_share_free(void *key, size_t key_len, void *p) { struct wssl_x509_share *share = p; - DEBUGASSERT(key_len == (sizeof(MPROTO_WSSL_X509_KEY)-1)); + DEBUGASSERT(key_len == (sizeof(MPROTO_WSSL_X509_KEY) - 1)); DEBUGASSERT(!memcmp(MPROTO_WSSL_X509_KEY, key, key_len)); (void)key; (void)key_len; @@ -726,9 +725,8 @@ static void wssl_x509_share_free(void *key, size_t key_len, void *p) curlx_free(share); } -static bool -wssl_cached_x509_store_expired(const struct Curl_easy *data, - const struct wssl_x509_share *mb) +static bool wssl_cached_x509_store_expired(const struct Curl_easy *data, + const struct wssl_x509_share *mb) { const struct ssl_general_config *cfg = &data->set.general_ssl; struct curltime now = curlx_now(); @@ -741,9 +739,8 @@ wssl_cached_x509_store_expired(const struct Curl_easy *data, return elapsed_ms >= timeout_ms; } -static bool -wssl_cached_x509_store_different(struct Curl_cfilter *cf, - const struct wssl_x509_share *mb) +static bool wssl_cached_x509_store_different(struct Curl_cfilter *cf, + const struct wssl_x509_share *mb) { struct ssl_primary_config *conn_config = Curl_ssl_cf_get_primary_config(cf); if(!mb->CAfile || !conn_config->CAfile) @@ -762,7 +759,7 @@ static WOLFSSL_X509_STORE *wssl_get_cached_x509_store(struct Curl_cfilter *cf, DEBUGASSERT(multi); share = multi ? Curl_hash_pick(&multi->proto_hash, CURL_UNCONST(MPROTO_WSSL_X509_KEY), - sizeof(MPROTO_WSSL_X509_KEY)-1) : NULL; + sizeof(MPROTO_WSSL_X509_KEY) - 1) : NULL; if(share && share->store && !wssl_cached_x509_store_expired(data, share) && !wssl_cached_x509_store_different(cf, share)) { @@ -785,7 +782,7 @@ static void wssl_set_cached_x509_store(struct Curl_cfilter *cf, return; share = Curl_hash_pick(&multi->proto_hash, CURL_UNCONST(MPROTO_WSSL_X509_KEY), - sizeof(MPROTO_WSSL_X509_KEY)-1); + sizeof(MPROTO_WSSL_X509_KEY) - 1); if(!share) { share = curlx_calloc(1, sizeof(*share)); @@ -793,7 +790,7 @@ static void wssl_set_cached_x509_store(struct Curl_cfilter *cf, return; if(!Curl_hash_add2(&multi->proto_hash, CURL_UNCONST(MPROTO_WSSL_X509_KEY), - sizeof(MPROTO_WSSL_X509_KEY)-1, + sizeof(MPROTO_WSSL_X509_KEY) - 1, share, wssl_x509_share_free)) { curlx_free(share); return; @@ -876,8 +873,7 @@ CURLcode Curl_wssl_setup_x509_store(struct Curl_cfilter *cf, } #ifdef WOLFSSL_TLS13 -static CURLcode -wssl_add_default_ciphers(bool tls13, struct dynbuf *buf) +static CURLcode wssl_add_default_ciphers(bool tls13, struct dynbuf *buf) { int i; char *str; @@ -905,8 +901,7 @@ wssl_add_default_ciphers(bool tls13, struct dynbuf *buf) /* 4.2.0 (2019) */ #if LIBWOLFSSL_VERSION_HEX < 0x04002000 || !defined(OPENSSL_EXTRA) -static int -wssl_legacy_CTX_set_min_proto_version(WOLFSSL_CTX* ctx, int version) +static int wssl_legacy_CTX_set_min_proto_version(WOLFSSL_CTX *ctx, int version) { int res; switch(version) { @@ -933,8 +928,8 @@ wssl_legacy_CTX_set_min_proto_version(WOLFSSL_CTX* ctx, int version) } return res; } -static int -wssl_legacy_CTX_set_max_proto_version(WOLFSSL_CTX* ctx, int version) + +static int wssl_legacy_CTX_set_max_proto_version(WOLFSSL_CTX *ctx, int version) { (void)ctx, (void)version; return WOLFSSL_NOT_IMPLEMENTED; @@ -1106,7 +1101,6 @@ static CURLcode ssl_version(struct Curl_easy *data, return CURLE_OK; } - #define QUIC_GROUPS "P-256:P-384:P-521" CURLcode Curl_wssl_ctx_init(struct wssl_ctx *wctx, @@ -1121,7 +1115,7 @@ CURLcode Curl_wssl_ctx_init(struct wssl_ctx *wctx, { struct ssl_config_data *ssl_config = Curl_ssl_cf_get_config(cf, data); struct ssl_primary_config *conn_config; - WOLFSSL_METHOD* req_method = NULL; + WOLFSSL_METHOD *req_method = NULL; struct alpn_spec alpns; char *curves; #ifdef WOLFSSL_HAVE_KYBER @@ -1357,8 +1351,7 @@ CURLcode Curl_wssl_ctx_init(struct wssl_ctx *wctx, /* Ensure the Client Random is preserved. */ wolfSSL_KeepArrays(wctx->ssl); #if defined(HAVE_SECRET_CALLBACK) && defined(WOLFSSL_TLS13) - wolfSSL_set_tls13_secret_cb(wctx->ssl, - wssl_tls13_secret_callback, NULL); + wolfSSL_set_tls13_secret_cb(wctx->ssl, wssl_tls13_secret_callback, NULL); #endif } #endif /* OPENSSL_EXTRA */ @@ -1383,15 +1376,15 @@ CURLcode Curl_wssl_ctx_init(struct wssl_ctx *wctx, if(data->set.tls_ech == CURLECH_GREASE) { infof(data, "ECH: GREASE is done by default by wolfSSL: no need to ask"); } - if(data->set.tls_ech & CURLECH_CLA_CFG - && data->set.str[STRING_ECH_CONFIG]) { + if(data->set.tls_ech & CURLECH_CLA_CFG && + data->set.str[STRING_ECH_CONFIG]) { char *b64val = data->set.str[STRING_ECH_CONFIG]; word32 b64len = 0; - b64len = (word32) strlen(b64val); - if(b64len - && wolfSSL_SetEchConfigsBase64(wctx->ssl, b64val, b64len) - != WOLFSSL_SUCCESS) { + b64len = (word32)strlen(b64val); + if(b64len && + wolfSSL_SetEchConfigsBase64(wctx->ssl, + b64val, b64len) != WOLFSSL_SUCCESS) { if(data->set.tls_ech & CURLECH_HARD) { result = CURLE_SSL_CONNECT_ERROR; goto out; @@ -1424,8 +1417,8 @@ CURLcode Curl_wssl_ctx_init(struct wssl_ctx *wctx, size_t elen = rinfo->echconfiglist_len; infof(data, "ECH: ECHConfig from DoH HTTPS RR"); - if(wolfSSL_SetEchConfigs(wctx->ssl, ecl, (word32) elen) != - WOLFSSL_SUCCESS) { + if(wolfSSL_SetEchConfigs(wctx->ssl, ecl, (word32)elen) != + WOLFSSL_SUCCESS) { infof(data, "ECH: wolfSSL_SetEchConfigs failed"); if(data->set.tls_ech & CURLECH_HARD) { result = CURLE_SSL_CONNECT_ERROR; @@ -1476,8 +1469,8 @@ CURLcode Curl_wssl_ctx_init(struct wssl_ctx *wctx, * This function loads all the client/CA certificates and CRLs. Setup the TLS * layer and do all necessary magic. */ -static CURLcode -wssl_connect_step1(struct Curl_cfilter *cf, struct Curl_easy *data) +static CURLcode wssl_connect_step1(struct Curl_cfilter *cf, + struct Curl_easy *data) { struct ssl_connect_data *connssl = cf->ctx; struct wssl_ctx *wssl = (struct wssl_ctx *)connssl->backend; @@ -1542,9 +1535,7 @@ wssl_connect_step1(struct Curl_cfilter *cf, struct Curl_easy *data) return CURLE_OK; } - -static char *wssl_strerror(unsigned long error, char *buf, - unsigned long size) +static char *wssl_strerror(unsigned long error, char *buf, unsigned long size) { DEBUGASSERT(size > 40); *buf = '\0'; @@ -1665,8 +1656,7 @@ static CURLcode wssl_send_earlydata(struct Curl_cfilter *cf, } #endif /* WOLFSSL_EARLY_DATA */ -static CURLcode wssl_handshake(struct Curl_cfilter *cf, - struct Curl_easy *data) +static CURLcode wssl_handshake(struct Curl_cfilter *cf, struct Curl_easy *data) { struct ssl_connect_data *connssl = cf->ctx; struct wssl_ctx *wssl = (struct wssl_ctx *)connssl->backend; @@ -1735,7 +1725,7 @@ static CURLcode wssl_handshake(struct Curl_cfilter *cf, conn_config->verifyhost && !connssl->peer.sni) { /* we have an IP address as hostname. */ - WOLFSSL_X509* cert = wolfSSL_get_peer_certificate(wssl->ssl); + WOLFSSL_X509 *cert = wolfSSL_get_peer_certificate(wssl->ssl); if(!cert) { failf(data, "unable to get peer certificate"); return CURLE_PEER_FAILED_VERIFICATION; @@ -1789,11 +1779,11 @@ static CURLcode wssl_handshake(struct Curl_cfilter *cf, } else if(wssl->io_result) { switch(wssl->io_result) { - case CURLE_SEND_ERROR: - case CURLE_RECV_ERROR: - return CURLE_SSL_CONNECT_ERROR; - default: - return wssl->io_result; + case CURLE_SEND_ERROR: + case CURLE_RECV_ERROR: + return CURLE_SSL_CONNECT_ERROR; + default: + return wssl->io_result; } } #ifdef USE_ECH_WOLFSSL @@ -1804,8 +1794,7 @@ static CURLcode wssl_handshake(struct Curl_cfilter *cf, int rv = 0; /* this currently does not produce the retry_configs */ - rv = wolfSSL_GetEchConfigs(wssl->ssl, echConfigs, - &echConfigsLen); + rv = wolfSSL_GetEchConfigs(wssl->ssl, echConfigs, &echConfigsLen); if(rv != WOLFSSL_SUCCESS) { infof(data, "Failed to get ECHConfigs"); } @@ -2087,7 +2076,6 @@ size_t Curl_wssl_version(char *buffer, size_t size) #endif } - static int wssl_init(void) { int ret; @@ -2101,7 +2089,6 @@ static int wssl_init(void) return ret; } - static void wssl_cleanup(void) { wssl_bio_cf_free_methods(); @@ -2111,7 +2098,6 @@ static void wssl_cleanup(void) #endif } - static bool wssl_data_pending(struct Curl_cfilter *cf, const struct Curl_easy *data) { @@ -2128,15 +2114,14 @@ static bool wssl_data_pending(struct Curl_cfilter *cf, return FALSE; } -void Curl_wssl_report_handshake(struct Curl_easy *data, - struct wssl_ctx *wssl) +void Curl_wssl_report_handshake(struct Curl_easy *data, struct wssl_ctx *wssl) { #if (LIBWOLFSSL_VERSION_HEX >= 0x03009010) - infof(data, "SSL connection using %s / %s", - wolfSSL_get_version(wssl->ssl), - wolfSSL_get_cipher_name(wssl->ssl)); + infof(data, "SSL connection using %s / %s", + wolfSSL_get_version(wssl->ssl), + wolfSSL_get_cipher_name(wssl->ssl)); #else - infof(data, "SSL connected"); + infof(data, "SSL connected"); #endif } diff --git a/lib/vtls/wolfssl.h b/lib/vtls/wolfssl.h index 7ff4cfb88178..5e3c9e2c5dd6 100644 --- a/lib/vtls/wolfssl.h +++ b/lib/vtls/wolfssl.h @@ -41,9 +41,9 @@ extern const struct Curl_ssl Curl_ssl_wolfssl; struct wssl_ctx { struct WOLFSSL_CTX *ssl_ctx; - struct WOLFSSL *ssl; - CURLcode io_result; /* result of last BIO cfilter operation */ - CURLcode hs_result; /* result of handshake */ + struct WOLFSSL *ssl; + CURLcode io_result; /* result of last BIO cfilter operation */ + CURLcode hs_result; /* result of handshake */ int io_send_blocked_len; /* length of last BIO write that EAGAIN-ed */ BIT(x509_store_setup); /* x509 store has been set up */ BIT(shutting_down); /* TLS is being shut down */ @@ -88,8 +88,7 @@ CURLcode Curl_wssl_verify_pinned(struct Curl_cfilter *cf, struct Curl_easy *data, struct wssl_ctx *wssl); -void Curl_wssl_report_handshake(struct Curl_easy *data, - struct wssl_ctx *wssl); +void Curl_wssl_report_handshake(struct Curl_easy *data, struct wssl_ctx *wssl); #endif /* USE_WOLFSSL */ #endif /* HEADER_CURL_WOLFSSL_H */ diff --git a/lib/vtls/x509asn1.c b/lib/vtls/x509asn1.c index fcc0d0e1daf2..f63a9fcb9928 100644 --- a/lib/vtls/x509asn1.c +++ b/lib/vtls/x509asn1.c @@ -192,7 +192,7 @@ static const char *getASN1Element_(struct Curl_asn1Element *elem, /* Process header byte. */ elem->header = beg; - b = (unsigned char) *beg++; + b = (unsigned char)*beg++; elem->constructed = (b & 0x20) != 0; elem->eclass = (b >> 6) & 3; b &= 0x1F; @@ -203,7 +203,7 @@ static const char *getASN1Element_(struct Curl_asn1Element *elem, /* Process length. */ if(beg >= end) return NULL; - b = (unsigned char) *beg++; + b = (unsigned char)*beg++; if(!(b & 0x80)) len = b; else if(!(b &= 0x7F)) { @@ -284,7 +284,7 @@ static CURLcode bool2str(struct dynbuf *store, { if(end - beg != 1) return CURLE_BAD_FUNCTION_ARGUMENT; - return curlx_dyn_add(store, *beg ? "TRUE": "FALSE"); + return curlx_dyn_add(store, *beg ? "TRUE" : "FALSE"); } /* @@ -298,13 +298,12 @@ static CURLcode octet2str(struct dynbuf *store, CURLcode result = CURLE_OK; while(!result && beg < end) - result = curlx_dyn_addf(store, "%02x:", (unsigned char) *beg++); + result = curlx_dyn_addf(store, "%02x:", (unsigned char)*beg++); return result; } -static CURLcode bit2str(struct dynbuf *store, - const char *beg, const char *end) +static CURLcode bit2str(struct dynbuf *store, const char *beg, const char *end) { /* Convert an ASN.1 bit string to a printable string. */ @@ -318,8 +317,7 @@ static CURLcode bit2str(struct dynbuf *store, * * Returns error. */ -static CURLcode int2str(struct dynbuf *store, - const char *beg, const char *end) +static CURLcode int2str(struct dynbuf *store, const char *beg, const char *end) { unsigned int val = 0; size_t n = end - beg; @@ -335,7 +333,7 @@ static CURLcode int2str(struct dynbuf *store, val = ~val; do - val = (val << 8) | *(const unsigned char *) beg++; + val = (val << 8) | *(const unsigned char *)beg++; while(beg < end); return curlx_dyn_addf(store, "%s%x", val >= 10 ? "0x" : "", val); } @@ -348,8 +346,8 @@ static CURLcode int2str(struct dynbuf *store, * * Returns error. */ -static CURLcode -utf8asn1str(struct dynbuf *to, int type, const char *from, const char *end) +static CURLcode utf8asn1str(struct dynbuf *to, int type, const char *from, + const char *end) { size_t inlength = end - from; int size = 1; @@ -390,14 +388,14 @@ utf8asn1str(struct dynbuf *to, int type, const char *from, const char *end) switch(size) { case 4: - wc = (wc << 8) | *(const unsigned char *) from++; - wc = (wc << 8) | *(const unsigned char *) from++; + wc = (wc << 8) | *(const unsigned char *)from++; + wc = (wc << 8) | *(const unsigned char *)from++; FALLTHROUGH(); case 2: - wc = (wc << 8) | *(const unsigned char *) from++; + wc = (wc << 8) | *(const unsigned char *)from++; FALLTHROUGH(); default: /* case 1: */ - wc = (wc << 8) | *(const unsigned char *) from++; + wc = (wc << 8) | *(const unsigned char *)from++; } if(wc >= 0x00000080) { if(wc >= 0x00000800) { @@ -406,19 +404,19 @@ utf8asn1str(struct dynbuf *to, int type, const char *from, const char *end) /* Invalid char. size for target encoding. */ return CURLE_WEIRD_SERVER_REPLY; } - buf[3] = (char) (0x80 | (wc & 0x3F)); + buf[3] = (char)(0x80 | (wc & 0x3F)); wc = (wc >> 6) | 0x00010000; charsize++; } - buf[2] = (char) (0x80 | (wc & 0x3F)); + buf[2] = (char)(0x80 | (wc & 0x3F)); wc = (wc >> 6) | 0x00000800; charsize++; } - buf[1] = (char) (0x80 | (wc & 0x3F)); + buf[1] = (char)(0x80 | (wc & 0x3F)); wc = (wc >> 6) | 0x000000C0; charsize++; } - buf[0] = (char) wc; + buf[0] = (char)wc; result = curlx_dyn_addn(to, buf, charsize); } } @@ -438,7 +436,7 @@ static CURLcode encodeOID(struct dynbuf *store, CURLcode result = CURLE_OK; /* Process the first two numbers. */ - y = *(const unsigned char *) beg++; + y = *(const unsigned char *)beg++; x = y / 40; y -= x * 40; @@ -452,7 +450,7 @@ static CURLcode encodeOID(struct dynbuf *store, do { if(x & 0xFF000000) return CURLE_OK; - y = *(const unsigned char *) beg++; + y = *(const unsigned char *)beg++; x = (x << 7) | (y & 0x7F); } while(y & 0x80); result = curlx_dyn_addf(store, ".%u", x); @@ -973,8 +971,8 @@ static CURLcode do_pubkey_field(struct Curl_easy *data, int certnum, } /* return 0 on success, 1 on error */ -static int do_pubkey(struct Curl_easy *data, int certnum, - const char *algo, struct Curl_asn1Element *param, +static int do_pubkey(struct Curl_easy *data, int certnum, const char *algo, + struct Curl_asn1Element *param, struct Curl_asn1Element *pubkey) { struct Curl_asn1Element elem; @@ -1019,7 +1017,7 @@ static int do_pubkey(struct Curl_easy *data, int certnum, len = ((elem.end - q) * 8); if(len) { unsigned int i; - for(i = *(const unsigned char *) q; !(i & 0x80); i <<= 1) + for(i = *(const unsigned char *)q; !(i & 0x80); i <<= 1) len--; } if(len > 32) @@ -1078,8 +1076,7 @@ static int do_pubkey(struct Curl_easy *data, int certnum, * Convert an ASN.1 distinguished name into a printable string. * Return error. */ -static CURLcode DNtostr(struct dynbuf *store, - struct Curl_asn1Element *dn) +static CURLcode DNtostr(struct dynbuf *store, struct Curl_asn1Element *dn) { return encodeDN(store, dn); } @@ -1135,7 +1132,7 @@ CURLcode Curl_extract_certinfo(struct Curl_easy *data, /* Version (always fits in less than 32 bits). */ version = 0; for(ptr = cert.version.beg; ptr < cert.version.end; ptr++) - version = (version << 8) | *(const unsigned char *) ptr; + version = (version << 8) | *(const unsigned char *)ptr; if(data->set.ssl.certinfo) { result = curlx_dyn_addf(&out, "%x", version); if(result) @@ -1163,8 +1160,7 @@ CURLcode Curl_extract_certinfo(struct Curl_easy *data, if(result) goto done; if(data->set.ssl.certinfo) { - result = ssl_push_certinfo_dyn(data, certnum, "Signature Algorithm", - &out); + result = ssl_push_certinfo_dyn(data, certnum, "Signature Algorithm", &out); if(result) goto done; } From 47a1ab2ebecb21485c0e955316d90511e80a3c43 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Sat, 29 Nov 2025 22:37:26 +0100 Subject: [PATCH 125/415] lib: fix formatting nits (part 1) From `lib/a*` to `lib/cs*`. Closes #19764 --- lib/altsvc.c | 1 - lib/altsvc.h | 2 +- lib/amigaos.c | 12 ++-- lib/arpa_telnet.h | 12 ++-- lib/asyn-ares.c | 22 +++---- lib/asyn-base.c | 8 +-- lib/asyn-thrdd.c | 15 ++--- lib/asyn.h | 20 +++--- lib/bufq.c | 3 +- lib/bufq.h | 2 +- lib/bufref.c | 2 +- lib/bufref.h | 1 - lib/cf-h1-proxy.c | 40 ++++++------ lib/cf-h1-proxy.h | 1 - lib/cf-h2-proxy.c | 159 +++++++++++++++++++++++----------------------- lib/cf-haproxy.c | 8 +-- lib/cf-ip-happy.c | 90 +++++++++++++------------- lib/cf-socket.c | 117 +++++++++++++++++----------------- lib/cf-socket.h | 2 +- lib/cfilters.c | 19 +++--- lib/cfilters.h | 55 ++++++++-------- lib/conncache.c | 18 ++---- lib/conncache.h | 3 +- lib/connect.c | 64 +++++++++---------- lib/connect.h | 12 ++-- lib/cookie.c | 61 ++++++++---------- lib/cookie.h | 40 ++++++------ lib/cshutdn.c | 20 ++---- 28 files changed, 377 insertions(+), 432 deletions(-) diff --git a/lib/altsvc.c b/lib/altsvc.c index 84f6c1b44547..cbaf4b4d85f9 100644 --- a/lib/altsvc.c +++ b/lib/altsvc.c @@ -64,7 +64,6 @@ const char *Curl_alpnid2str(enum alpnid id) } } - static void altsvc_free(struct altsvc *as) { curlx_free(as->src.host); diff --git a/lib/altsvc.h b/lib/altsvc.h index 831cd097436a..d370b4e4b195 100644 --- a/lib/altsvc.h +++ b/lib/altsvc.h @@ -68,7 +68,7 @@ bool Curl_altsvc_lookup(struct altsvcinfo *asi, const int versions); /* CURLALTSVC_H* bits */ #else /* disabled */ -#define Curl_altsvc_save(a,b,c) +#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/lib/amigaos.c b/lib/amigaos.c index e4b678d54185..d32ee5e7902f 100644 --- a/lib/amigaos.c +++ b/lib/amigaos.c @@ -120,8 +120,7 @@ void Curl_amiga_cleanup(void) * allocates memory also. */ -struct Curl_addrinfo *Curl_ipv4_resolve_r(const char *hostname, - int port) +struct Curl_addrinfo *Curl_ipv4_resolve_r(const char *hostname, int port) { struct Curl_addrinfo *ai = NULL; struct hostent *h; @@ -144,7 +143,7 @@ struct Curl_addrinfo *Curl_ipv4_resolve_r(const char *hostname, } } else { - #ifdef CURLRES_THREADED +#ifdef CURLRES_THREADED /* gethostbyname() is not thread safe, so we need to reopen bsdsocket * on the thread's context */ @@ -160,13 +159,13 @@ struct Curl_addrinfo *Curl_ipv4_resolve_r(const char *hostname, } CloseLibrary(base); } - #else +#else /* not using threaded resolver - safe to use this as-is */ h = gethostbyname(hostname); if(h) { ai = Curl_he2ai(h, port); } - #endif +#endif } return ai; @@ -219,8 +218,7 @@ CURLcode Curl_amiga_init(void) } if(SocketBaseTags(SBTM_SETVAL(SBTC_ERRNOPTR(sizeof(errno))), (ULONG)&errno, - SBTM_SETVAL(SBTC_LOGTAGPTR), (ULONG)"curl", - TAG_DONE)) { + SBTM_SETVAL(SBTC_LOGTAGPTR), (ULONG)"curl", TAG_DONE)) { CURL_AMIGA_REQUEST("SocketBaseTags ERROR"); return CURLE_FAILED_INIT; } diff --git a/lib/arpa_telnet.h b/lib/arpa_telnet.h index 055aa98b1096..daf2487fc616 100644 --- a/lib/arpa_telnet.h +++ b/lib/arpa_telnet.h @@ -43,8 +43,7 @@ /* * The telnet options represented as strings */ -static const char * const telnetoptions[]= -{ +static const char * const telnetoptions[] = { "BINARY", "ECHO", "RCP", "SUPPRESS GO AHEAD", "NAME", "STATUS", "TIMING MARK", "RCTE", "NAOL", "NAOP", "NAOCRD", "NAOHTS", @@ -86,8 +85,7 @@ static const char * const telnetoptions[]= /* * Then those numbers represented as strings: */ -static const char * const telnetcmds[]= -{ +static const char * const telnetcmds[] = { "EOF", "SUSP", "ABORT", "EOR", "SE", "NOP", "DMARK", "BRK", "IP", "AO", "AYT", "EC", "EL", "GA", "SB", @@ -103,11 +101,11 @@ static const char * const telnetcmds[]= #define CURL_TELQUAL_INFO 2 #define CURL_TELQUAL_NAME 3 -#define CURL_TELCMD_OK(x) ( ((unsigned int)(x) >= CURL_TELCMD_MINIMUM) && \ - ((unsigned int)(x) <= CURL_TELCMD_MAXIMUM) ) +#define CURL_TELCMD_OK(x) (((unsigned int)(x) >= CURL_TELCMD_MINIMUM) && \ + ((unsigned int)(x) <= CURL_TELCMD_MAXIMUM)) #ifndef CURL_DISABLE_VERBOSE_STRINGS -#define CURL_TELCMD(x) telnetcmds[(x)-CURL_TELCMD_MINIMUM] +#define CURL_TELCMD(x) telnetcmds[(x) - CURL_TELCMD_MINIMUM] #else #define CURL_TELCMD(x) "" #endif diff --git a/lib/asyn-ares.c b/lib/asyn-ares.c index e3ba512b77ff..ce4f866be6d2 100644 --- a/lib/asyn-ares.c +++ b/lib/asyn-ares.c @@ -140,7 +140,6 @@ void Curl_async_global_cleanup(void) #endif } - static void sock_state_cb(void *data, ares_socket_t socket_fd, int readable, int writable) { @@ -309,12 +308,12 @@ CURLcode Curl_async_is_resolved(struct Curl_easy *data, /* Now that we have checked for any last minute results above, see if there are any responses still pending when the EXPIRE_HAPPY_EYEBALLS_DNS timer expires. */ - if(ares->num_pending + if(ares->num_pending && /* This is only set to non-zero if the timer was started. */ - && (ares->happy_eyeballs_dns_time.tv_sec - || ares->happy_eyeballs_dns_time.tv_usec) - && (curlx_timediff_ms(curlx_now(), ares->happy_eyeballs_dns_time) - >= HAPPY_EYEBALLS_DNS_TIMEOUT)) { + (ares->happy_eyeballs_dns_time.tv_sec || + ares->happy_eyeballs_dns_time.tv_usec) && + (curlx_timediff_ms(curlx_now(), ares->happy_eyeballs_dns_time) >= + HAPPY_EYEBALLS_DNS_TIMEOUT)) { /* Remember that the EXPIRE_HAPPY_EYEBALLS_DNS timer is no longer running. */ memset(&ares->happy_eyeballs_dns_time, 0, @@ -418,8 +417,8 @@ CURLcode Curl_async_await(struct Curl_easy *data, itimeout_ms = (int)timeout_ms; #endif - max_timeout.tv_sec = itimeout_ms/1000; - max_timeout.tv_usec = (itimeout_ms%1000)*1000; + max_timeout.tv_sec = itimeout_ms / 1000; + max_timeout.tv_usec = (itimeout_ms % 1000) * 1000; real_timeout = ares_timeout(ares->channel, &max_timeout, &time_buf); @@ -427,7 +426,7 @@ CURLcode Curl_async_await(struct Curl_easy *data, second is left, otherwise just use 1000ms to make sure the progress callback gets called frequent enough */ if(!real_timeout->tv_sec) - call_timeout_ms = (timediff_t)(real_timeout->tv_usec/1000); + call_timeout_ms = (timediff_t)(real_timeout->tv_usec / 1000); else call_timeout_ms = 1000; @@ -518,7 +517,7 @@ static void async_ares_hostbyname_cb(void *user_data, if(ARES_SUCCESS == status) { ares->ares_status = status; /* one success overrules any error */ async_addr_concat(&ares->temp_ai, - Curl_he2ai(hostent, data->state.async.port)); + Curl_he2ai(hostent, data->state.async.port)); } else if(ares->ares_status != ARES_SUCCESS) { /* no success so far, remember last error */ @@ -586,8 +585,7 @@ static void async_ares_hostbyname_cb(void *user_data, c-ares retry cycle each request is. */ ares->happy_eyeballs_dns_time = curlx_now(); - Curl_expire(data, HAPPY_EYEBALLS_DNS_TIMEOUT, - EXPIRE_HAPPY_EYEBALLS_DNS); + Curl_expire(data, HAPPY_EYEBALLS_DNS_TIMEOUT, EXPIRE_HAPPY_EYEBALLS_DNS); } } diff --git a/lib/asyn-base.c b/lib/asyn-base.c index 6338a3fc6e25..5358fcb8fa54 100644 --- a/lib/asyn-base.c +++ b/lib/asyn-base.c @@ -59,7 +59,6 @@ **********************************************************************/ #ifdef CURLRES_ASYNCH - #ifdef USE_ARES #if ARES_VERSION < 0x010600 @@ -122,8 +121,7 @@ CURLcode Curl_ares_pollset(struct Curl_easy *data, * * return number of sockets it worked on, or -1 on error */ -int Curl_ares_perform(ares_channel channel, - timediff_t timeout_ms) +int Curl_ares_perform(ares_channel channel, timediff_t timeout_ms) { int nfds; int bitmask; @@ -142,11 +140,11 @@ int Curl_ares_perform(ares_channel channel, pfd[i].revents = 0; if(ARES_GETSOCK_READABLE(bitmask, i)) { pfd[i].fd = socks[i]; - pfd[i].events |= POLLRDNORM|POLLIN; + pfd[i].events |= POLLRDNORM | POLLIN; } if(ARES_GETSOCK_WRITABLE(bitmask, i)) { pfd[i].fd = socks[i]; - pfd[i].events |= POLLWRNORM|POLLOUT; + pfd[i].events |= POLLWRNORM | POLLOUT; } if(pfd[i].events) num++; diff --git a/lib/asyn-thrdd.c b/lib/asyn-thrdd.c index 6c2e02fd1871..e5bf0629d38f 100644 --- a/lib/asyn-thrdd.c +++ b/lib/asyn-thrdd.c @@ -45,13 +45,13 @@ #endif #if defined(USE_THREADS_POSIX) && defined(HAVE_PTHREAD_H) -# include +#include #endif #ifdef HAVE_GETADDRINFO -# define RESOLVER_ENOMEM EAI_MEMORY /* = WSA_NOT_ENOUGH_MEMORY on Windows */ +#define RESOLVER_ENOMEM EAI_MEMORY /* = WSA_NOT_ENOUGH_MEMORY on Windows */ #else -# define RESOLVER_ENOMEM SOCKENOMEM +#define RESOLVER_ENOMEM SOCKENOMEM #endif #include "urldata.h" @@ -245,7 +245,6 @@ static CURL_THREAD_RETURN_T CURL_STDCALL getaddrinfo_thread(void *arg) } } #endif - } addr_ctx_unlink(&addr_ctx, NULL); @@ -486,8 +485,8 @@ static void async_thrdd_shutdown(struct Curl_easy *data) Curl_mutex_acquire(&addr_ctx->mutx); #ifndef CURL_DISABLE_SOCKETPAIR - if(!addr_ctx->do_abort) - Curl_multi_will_close(data, addr_ctx->sock_pair[0]); + if(!addr_ctx->do_abort) + Curl_multi_will_close(data, addr_ctx->sock_pair[0]); #endif addr_ctx->do_abort = TRUE; done = addr_ctx->thrd_done; @@ -703,7 +702,7 @@ CURLcode Curl_async_pollset(struct Curl_easy *data, struct easy_pollset *ps) if(!thrd_done) { #ifndef CURL_DISABLE_SOCKETPAIR - /* return read fd to client for polling the DNS resolution status */ + /* return read fd to client for polling the DNS resolution status */ result = Curl_pollset_add_in(data, ps, thrdd->addr->sock_pair[0]); #else timediff_t milli; @@ -711,7 +710,7 @@ CURLcode Curl_async_pollset(struct Curl_easy *data, struct easy_pollset *ps) if(ms < 3) milli = 0; else if(ms <= 50) - milli = ms/3; + milli = ms / 3; else if(ms <= 250) milli = 50; else diff --git a/lib/asyn.h b/lib/asyn.h index 8da7dd9720cc..e5e472e247db 100644 --- a/lib/asyn.h +++ b/lib/asyn.h @@ -129,19 +129,18 @@ CURLcode Curl_ares_pollset(struct Curl_easy *data, ares_channel channel, struct easy_pollset *ps); -int Curl_ares_perform(ares_channel channel, - timediff_t timeout_ms); +int Curl_ares_perform(ares_channel channel, timediff_t timeout_ms); #endif #ifdef CURLRES_ARES /* async resolving implementation using c-ares alone */ struct async_ares_ctx { ares_channel channel; - int num_pending; /* number of outstanding c-ares requests */ + int num_pending; /* number of outstanding c-ares requests */ struct Curl_addrinfo *temp_ai; /* intermediary result while fetching c-ares parts */ - int ares_status; /* ARES_SUCCESS, ARES_ENOTFOUND, etc. */ - CURLcode result; /* CURLE_OK or error handling response */ + int ares_status; /* ARES_SUCCESS, ARES_ENOTFOUND, etc. */ + CURLcode result; /* CURLE_OK or error handling response */ #ifndef HAVE_CARES_GETADDRINFO struct curltime happy_eyeballs_dns_time; /* when this timer started, or 0 */ #endif @@ -223,11 +222,11 @@ struct doh_probes; #else /* CURLRES_ASYNCH */ /* convert these functions if an asynch resolver is not used */ -#define Curl_async_get_impl(x,y) (*(y) = NULL, CURLE_OK) -#define Curl_async_is_resolved(x,y) CURLE_COULDNT_RESOLVE_HOST -#define Curl_async_await(x,y) CURLE_COULDNT_RESOLVE_HOST -#define Curl_async_global_init() CURLE_OK -#define Curl_async_global_cleanup() Curl_nop_stmt +#define Curl_async_get_impl(x, y) (*(y) = NULL, CURLE_OK) +#define Curl_async_is_resolved(x,y) CURLE_COULDNT_RESOLVE_HOST +#define Curl_async_await(x, y) CURLE_COULDNT_RESOLVE_HOST +#define Curl_async_global_init() CURLE_OK +#define Curl_async_global_cleanup() Curl_nop_stmt #endif /* !CURLRES_ASYNCH */ @@ -270,6 +269,5 @@ void Curl_async_destroy(struct Curl_easy *data); #define Curl_async_destroy(x) Curl_nop_stmt #endif /* USE_CURL_ASYNC */ - /********** end of generic resolver interface functions *****************/ #endif /* HEADER_CURL_ASYN_H */ diff --git a/lib/bufq.c b/lib/bufq.c index 5a77fc52d4b3..6eeeeb35d432 100644 --- a/lib/bufq.c +++ b/lib/bufq.c @@ -143,7 +143,6 @@ static void chunk_list_free(struct buf_chunk **anchor) } } - void Curl_bufcp_init(struct bufc_pool *pool, size_t chunk_size, size_t spare_max) { @@ -330,7 +329,7 @@ static void prune_head(struct bufq *q) --q->chunk_count; } else if((q->chunk_count > q->max_chunks) || - (q->opts & BUFQ_OPT_NO_SPARES)) { + (q->opts & BUFQ_OPT_NO_SPARES)) { /* SOFT_LIMIT allowed us more than max. free spares until * we are at max again. Or free them if we are configured * to not use spares. */ diff --git a/lib/bufq.h b/lib/bufq.h index 9557e5d33bba..112388a6bf47 100644 --- a/lib/bufq.h +++ b/lib/bufq.h @@ -38,7 +38,7 @@ struct buf_chunk { size_t r_offset; /* first unread bytes */ size_t w_offset; /* one after last written byte */ union { - uint8_t data[1]; /* the buffer for `dlen` bytes */ + uint8_t data[1]; /* the buffer for `dlen` bytes */ void *dummy; /* alignment */ } x; }; diff --git a/lib/bufref.c b/lib/bufref.c index d5181a5da662..643fe5d2e08c 100644 --- a/lib/bufref.c +++ b/lib/bufref.c @@ -76,7 +76,7 @@ void Curl_bufref_set(struct bufref *br, const void *ptr, size_t len, DEBUGASSERT(len <= CURL_MAX_INPUT_LENGTH); Curl_bufref_free(br); - br->ptr = (const unsigned char *) ptr; + br->ptr = (const unsigned char *)ptr; br->len = len; br->dtor = dtor; } diff --git a/lib/bufref.h b/lib/bufref.h index dd424f18f556..f80011fde5ec 100644 --- a/lib/bufref.h +++ b/lib/bufref.h @@ -36,7 +36,6 @@ struct bufref { #endif }; - void Curl_bufref_init(struct bufref *br); void Curl_bufref_set(struct bufref *br, const void *ptr, size_t len, void (*dtor)(void *)); diff --git a/lib/cf-h1-proxy.c b/lib/cf-h1-proxy.c index 84ba3d6193fa..19c63a12b049 100644 --- a/lib/cf-h1-proxy.c +++ b/lib/cf-h1-proxy.c @@ -48,12 +48,12 @@ typedef enum { - H1_TUNNEL_INIT, /* init/default/no tunnel state */ - H1_TUNNEL_CONNECT, /* CONNECT request is being send */ - H1_TUNNEL_RECEIVE, /* CONNECT answer is being received */ - H1_TUNNEL_RESPONSE, /* CONNECT response received completely */ - H1_TUNNEL_ESTABLISHED, - H1_TUNNEL_FAILED + H1_TUNNEL_INIT, /* init/default/no tunnel state */ + H1_TUNNEL_CONNECT, /* CONNECT request is being send */ + H1_TUNNEL_RECEIVE, /* CONNECT answer is being received */ + H1_TUNNEL_RESPONSE, /* CONNECT response received completely */ + H1_TUNNEL_ESTABLISHED, + H1_TUNNEL_FAILED } h1_tunnel_state; /* struct for HTTP CONNECT tunneling */ @@ -74,7 +74,6 @@ struct h1_tunnel_state { BIT(close_connection); }; - static bool tunnel_is_established(struct h1_tunnel_state *ts) { return ts && (ts->tunnel_state == H1_TUNNEL_ESTABLISHED); @@ -209,9 +208,9 @@ static CURLcode start_CONNECT(struct Curl_cfilter *cf, int http_minor; CURLcode result; - /* This only happens if we have looped here due to authentication - reasons, and we do not really use the newly cloned URL here - then. Just free it. */ + /* This only happens if we have looped here due to authentication + reasons, and we do not really use the newly cloned URL here + then. Just free it. */ Curl_safefree(data->req.newurl); result = Curl_http_proxy_create_CONNECT(&req, cf, data, 1); @@ -281,10 +280,8 @@ static CURLcode on_resp_header(struct Curl_cfilter *cf, struct SingleRequest *k = &data->req; (void)cf; - if((checkprefix("WWW-Authenticate:", header) && - (401 == k->httpcode)) || - (checkprefix("Proxy-authenticate:", header) && - (407 == k->httpcode))) { + if((checkprefix("WWW-Authenticate:", header) && (401 == k->httpcode)) || + (checkprefix("Proxy-authenticate:", header) && (407 == k->httpcode))) { bool proxy = (k->httpcode == 407); char *auth = Curl_copy_header_value(header); @@ -300,7 +297,7 @@ static CURLcode on_resp_header(struct Curl_cfilter *cf, return result; } else if(checkprefix("Content-Length:", header)) { - if(k->httpcode/100 == 2) { + if(k->httpcode / 100 == 2) { /* A client MUST ignore any Content-Length or Transfer-Encoding header fields received in a successful response to CONNECT. "Successful" described as: 2xx (Successful). RFC 7231 4.3.6 */ @@ -319,7 +316,7 @@ static CURLcode on_resp_header(struct Curl_cfilter *cf, STRCONST("Connection:"), STRCONST("close"))) ts->close_connection = TRUE; else if(checkprefix("Transfer-Encoding:", header)) { - if(k->httpcode/100 == 2) { + if(k->httpcode / 100 == 2) { /* A client MUST ignore any Content-Length or Transfer-Encoding header fields received in a successful response to CONNECT. "Successful" described as: 2xx (Successful). RFC 7231 4.3.6 */ @@ -493,8 +490,8 @@ static CURLcode recv_CONNECT_resp(struct Curl_cfilter *cf, ts->keepon = KEEPON_DONE; } - DEBUGASSERT(ts->keepon == KEEPON_IGNORE - || ts->keepon == KEEPON_DONE); + DEBUGASSERT(ts->keepon == KEEPON_IGNORE || + ts->keepon == KEEPON_DONE); continue; } @@ -508,7 +505,7 @@ static CURLcode recv_CONNECT_resp(struct Curl_cfilter *cf, if(error) result = CURLE_RECV_ERROR; *done = (ts->keepon == KEEPON_DONE); - if(!result && *done && data->info.httpproxycode/100 != 2) { + if(!result && *done && data->info.httpproxycode / 100 != 2) { /* Deal with the possibly already received authenticate headers. 'newurl' is set to a new URL if we must loop. */ result = Curl_http_auth_act(data); @@ -603,7 +600,7 @@ static CURLcode H1_CONNECT(struct Curl_cfilter *cf, } while(data->req.newurl); DEBUGASSERT(ts->tunnel_state == H1_TUNNEL_RESPONSE); - if(data->info.httpproxycode/100 != 2) { + if(data->info.httpproxycode / 100 != 2) { /* a non-2xx response and we have no next URL to try. */ Curl_safefree(data->req.newurl); h1_tunnel_go_state(cf, ts, H1_TUNNEL_FAILED, data); @@ -716,10 +713,9 @@ static void cf_h1_proxy_close(struct Curl_cfilter *cf, } } - struct Curl_cftype Curl_cft_h1_proxy = { "H1-PROXY", - CF_TYPE_IP_CONNECT|CF_TYPE_PROXY, + CF_TYPE_IP_CONNECT | CF_TYPE_PROXY, 0, cf_h1_proxy_destroy, cf_h1_proxy_connect, diff --git a/lib/cf-h1-proxy.h b/lib/cf-h1-proxy.h index ac5bed0b2bc7..ded55db9df31 100644 --- a/lib/cf-h1-proxy.h +++ b/lib/cf-h1-proxy.h @@ -33,7 +33,6 @@ CURLcode Curl_cf_h1_proxy_insert_after(struct Curl_cfilter *cf, extern struct Curl_cftype Curl_cft_h1_proxy; - #endif /* !CURL_DISABLE_PROXY && !CURL_DISABLE_HTTP */ #endif /* HEADER_CURL_H1_PROXY_H */ diff --git a/lib/cf-h2-proxy.c b/lib/cf-h2-proxy.c index 7066db3b4c4a..fb2586d1d0e5 100644 --- a/lib/cf-h2-proxy.c +++ b/lib/cf-h2-proxy.c @@ -45,12 +45,12 @@ #include "curlx/warnless.h" #include "cf-h2-proxy.h" -#define PROXY_H2_CHUNK_SIZE (16*1024) +#define PROXY_H2_CHUNK_SIZE (16 * 1024) #define PROXY_HTTP2_HUGE_WINDOW_SIZE (100 * 1024 * 1024) #define H2_TUNNEL_WINDOW_SIZE (10 * 1024 * 1024) -#define PROXY_H2_NW_RECV_CHUNKS (H2_TUNNEL_WINDOW_SIZE / PROXY_H2_CHUNK_SIZE) +#define PROXY_H2_NW_RECV_CHUNKS (H2_TUNNEL_WINDOW_SIZE / PROXY_H2_CHUNK_SIZE) #define PROXY_H2_NW_SEND_CHUNKS 1 #define H2_TUNNEL_RECV_CHUNKS (H2_TUNNEL_WINDOW_SIZE / PROXY_H2_CHUNK_SIZE) @@ -58,11 +58,11 @@ typedef enum { - H2_TUNNEL_INIT, /* init/default/no tunnel state */ - H2_TUNNEL_CONNECT, /* CONNECT request is being send */ - H2_TUNNEL_RESPONSE, /* CONNECT response received completely */ - H2_TUNNEL_ESTABLISHED, - H2_TUNNEL_FAILED + H2_TUNNEL_INIT, /* init/default/no tunnel state */ + H2_TUNNEL_CONNECT, /* CONNECT request is being send */ + H2_TUNNEL_RESPONSE, /* CONNECT response received completely */ + H2_TUNNEL_ESTABLISHED, + H2_TUNNEL_FAILED } h2_tunnel_state; struct tunnel_stream { @@ -94,7 +94,7 @@ static CURLcode tunnel_stream_init(struct Curl_cfilter *cf, Curl_http_proxy_get_destination(cf, &hostname, &port, &ipv6_ip); /* host:port with IPv6 support */ - ts->authority = curl_maprintf("%s%s%s:%d", ipv6_ip ? "[":"", hostname, + ts->authority = curl_maprintf("%s%s%s:%d", ipv6_ip ? "[" : "", hostname, ipv6_ip ? "]" : "", port); if(!ts->authority) return CURLE_OUT_OF_MEMORY; @@ -184,8 +184,7 @@ struct cf_h2_proxy_ctx { /* How to access `call_data` from a cf_h2 filter */ #undef CF_CTX_CALL_DATA -#define CF_CTX_CALL_DATA(cf) \ - ((struct cf_h2_proxy_ctx *)(cf)->ctx)->call_data +#define CF_CTX_CALL_DATA(cf) ((struct cf_h2_proxy_ctx *)(cf)->ctx)->call_data static void cf_h2_proxy_ctx_clear(struct cf_h2_proxy_ctx *ctx) { @@ -542,70 +541,70 @@ static int proxy_h2_fr_print(const nghttp2_frame *frame, char *buffer, size_t blen) { switch(frame->hd.type) { - case NGHTTP2_DATA: { - return curl_msnprintf(buffer, blen, - "FRAME[DATA, len=%d, eos=%d, padlen=%d]", - (int)frame->hd.length, - !!(frame->hd.flags & NGHTTP2_FLAG_END_STREAM), - (int)frame->data.padlen); + case NGHTTP2_DATA: { + return curl_msnprintf(buffer, blen, + "FRAME[DATA, len=%d, eos=%d, padlen=%d]", + (int)frame->hd.length, + !!(frame->hd.flags & NGHTTP2_FLAG_END_STREAM), + (int)frame->data.padlen); + } + case NGHTTP2_HEADERS: { + return curl_msnprintf(buffer, blen, + "FRAME[HEADERS, len=%d, hend=%d, eos=%d]", + (int)frame->hd.length, + !!(frame->hd.flags & NGHTTP2_FLAG_END_HEADERS), + !!(frame->hd.flags & NGHTTP2_FLAG_END_STREAM)); + } + case NGHTTP2_PRIORITY: { + return curl_msnprintf(buffer, blen, + "FRAME[PRIORITY, len=%d, flags=%d]", + (int)frame->hd.length, frame->hd.flags); + } + case NGHTTP2_RST_STREAM: { + return curl_msnprintf(buffer, blen, + "FRAME[RST_STREAM, len=%d, flags=%d, error=%u]", + (int)frame->hd.length, frame->hd.flags, + frame->rst_stream.error_code); + } + case NGHTTP2_SETTINGS: { + if(frame->hd.flags & NGHTTP2_FLAG_ACK) { + return curl_msnprintf(buffer, blen, "FRAME[SETTINGS, ack=1]"); } - case NGHTTP2_HEADERS: { - return curl_msnprintf(buffer, blen, - "FRAME[HEADERS, len=%d, hend=%d, eos=%d]", - (int)frame->hd.length, - !!(frame->hd.flags & NGHTTP2_FLAG_END_HEADERS), - !!(frame->hd.flags & NGHTTP2_FLAG_END_STREAM)); - } - case NGHTTP2_PRIORITY: { - return curl_msnprintf(buffer, blen, - "FRAME[PRIORITY, len=%d, flags=%d]", - (int)frame->hd.length, frame->hd.flags); - } - case NGHTTP2_RST_STREAM: { - return curl_msnprintf(buffer, blen, - "FRAME[RST_STREAM, len=%d, flags=%d, error=%u]", - (int)frame->hd.length, frame->hd.flags, - frame->rst_stream.error_code); - } - case NGHTTP2_SETTINGS: { - if(frame->hd.flags & NGHTTP2_FLAG_ACK) { - return curl_msnprintf(buffer, blen, "FRAME[SETTINGS, ack=1]"); - } - return curl_msnprintf(buffer, blen, - "FRAME[SETTINGS, len=%d]", (int)frame->hd.length); - } - case NGHTTP2_PUSH_PROMISE: - return curl_msnprintf(buffer, blen, - "FRAME[PUSH_PROMISE, len=%d, hend=%d]", - (int)frame->hd.length, - !!(frame->hd.flags & NGHTTP2_FLAG_END_HEADERS)); - case NGHTTP2_PING: - return curl_msnprintf(buffer, blen, - "FRAME[PING, len=%d, ack=%d]", - (int)frame->hd.length, - frame->hd.flags & NGHTTP2_FLAG_ACK); - case NGHTTP2_GOAWAY: { - char scratch[128]; - size_t s_len = CURL_ARRAYSIZE(scratch); - size_t len = (frame->goaway.opaque_data_len < s_len) ? - frame->goaway.opaque_data_len : s_len-1; - if(len) - memcpy(scratch, frame->goaway.opaque_data, len); - scratch[len] = '\0'; - return curl_msnprintf(buffer, blen, - "FRAME[GOAWAY, error=%d, reason='%s', " - "last_stream=%d]", frame->goaway.error_code, - scratch, frame->goaway.last_stream_id); - } - case NGHTTP2_WINDOW_UPDATE: { - return curl_msnprintf(buffer, blen, - "FRAME[WINDOW_UPDATE, incr=%d]", - frame->window_update.window_size_increment); - } - default: - return curl_msnprintf(buffer, blen, "FRAME[%d, len=%d, flags=%d]", - frame->hd.type, (int)frame->hd.length, - frame->hd.flags); + return curl_msnprintf(buffer, blen, + "FRAME[SETTINGS, len=%d]", (int)frame->hd.length); + } + case NGHTTP2_PUSH_PROMISE: + return curl_msnprintf(buffer, blen, + "FRAME[PUSH_PROMISE, len=%d, hend=%d]", + (int)frame->hd.length, + !!(frame->hd.flags & NGHTTP2_FLAG_END_HEADERS)); + case NGHTTP2_PING: + return curl_msnprintf(buffer, blen, + "FRAME[PING, len=%d, ack=%d]", + (int)frame->hd.length, + frame->hd.flags & NGHTTP2_FLAG_ACK); + case NGHTTP2_GOAWAY: { + char scratch[128]; + size_t s_len = CURL_ARRAYSIZE(scratch); + size_t len = (frame->goaway.opaque_data_len < s_len) ? + frame->goaway.opaque_data_len : s_len-1; + if(len) + memcpy(scratch, frame->goaway.opaque_data, len); + scratch[len] = '\0'; + return curl_msnprintf(buffer, blen, + "FRAME[GOAWAY, error=%d, reason='%s', " + "last_stream=%d]", frame->goaway.error_code, + scratch, frame->goaway.last_stream_id); + } + case NGHTTP2_WINDOW_UPDATE: { + return curl_msnprintf(buffer, blen, + "FRAME[WINDOW_UPDATE, incr=%d]", + frame->window_update.window_size_increment); + } + default: + return curl_msnprintf(buffer, blen, "FRAME[%d, len=%d, flags=%d]", + frame->hd.type, (int)frame->hd.length, + frame->hd.flags); } } @@ -621,7 +620,7 @@ static int proxy_h2_on_frame_send(nghttp2_session *session, if(data && Curl_trc_cf_is_verbose(cf, data)) { char buffer[256]; int len; - len = proxy_h2_fr_print(frame, buffer, sizeof(buffer)-1); + len = proxy_h2_fr_print(frame, buffer, sizeof(buffer) - 1); buffer[len] = 0; CURL_TRC_CF(data, cf, "[%d] -> %s", frame->hd.stream_id, buffer); } @@ -644,9 +643,9 @@ static int proxy_h2_on_frame_recv(nghttp2_session *session, if(Curl_trc_cf_is_verbose(cf, data)) { char buffer[256]; int len; - len = proxy_h2_fr_print(frame, buffer, sizeof(buffer)-1); + len = proxy_h2_fr_print(frame, buffer, sizeof(buffer) - 1); buffer[len] = 0; - CURL_TRC_CF(data, cf, "[%d] <- %s",frame->hd.stream_id, buffer); + CURL_TRC_CF(data, cf, "[%d] <- %s", frame->hd.stream_id, buffer); } #endif /* !CURL_DISABLE_VERBOSE_STRINGS */ @@ -962,7 +961,7 @@ static CURLcode inspect_response(struct Curl_cfilter *cf, (void)cf; DEBUGASSERT(ts->resp); - if(ts->resp->status/100 == 2) { + if(ts->resp->status / 100 == 2) { infof(data, "CONNECT tunnel established, response %d", ts->resp->status); h2_tunnel_go_state(cf, ts, H2_TUNNEL_ESTABLISHED, data); return CURLE_OK; @@ -1220,7 +1219,7 @@ static CURLcode cf_h2_proxy_adjust_pollset(struct Curl_cfilter *cf, c_exhaust = !nghttp2_session_get_remote_window_size(ctx->h2); s_exhaust = ctx->tunnel.stream_id >= 0 && !nghttp2_session_get_stream_remote_window_size( - ctx->h2, ctx->tunnel.stream_id); + ctx->h2, ctx->tunnel.stream_id); want_recv = (want_recv || c_exhaust || s_exhaust); want_send = (!s_exhaust && want_send) || (!c_exhaust && nghttp2_session_want_write(ctx->h2)) || @@ -1414,7 +1413,7 @@ static CURLcode cf_h2_proxy_send(struct Curl_cfilter *cf, "h2 windows %d-%d (stream-conn), buffers %zu-%zu (stream-conn)", ctx->tunnel.stream_id, len, result, *pnwritten, nghttp2_session_get_stream_remote_window_size( - ctx->h2, ctx->tunnel.stream_id), + ctx->h2, ctx->tunnel.stream_id), nghttp2_session_get_remote_window_size(ctx->h2), Curl_bufq_len(&ctx->tunnel.sendbuf), Curl_bufq_len(&ctx->outbufq)); @@ -1566,7 +1565,7 @@ static CURLcode cf_h2_proxy_cntrl(struct Curl_cfilter *cf, struct Curl_cftype Curl_cft_h2_proxy = { "H2-PROXY", - CF_TYPE_IP_CONNECT|CF_TYPE_PROXY, + CF_TYPE_IP_CONNECT | CF_TYPE_PROXY, CURL_LOG_LVL_NONE, cf_h2_proxy_destroy, cf_h2_proxy_connect, diff --git a/lib/cf-haproxy.c b/lib/cf-haproxy.c index a1793c0071ec..5ceef5190a37 100644 --- a/lib/cf-haproxy.c +++ b/lib/cf-haproxy.c @@ -36,9 +36,9 @@ typedef enum { - HAPROXY_INIT, /* init/default/no tunnel state */ - HAPROXY_SEND, /* data_out being sent */ - HAPROXY_DONE /* all work done */ + HAPROXY_INIT, /* init/default/no tunnel state */ + HAPROXY_SEND, /* data_out being sent */ + HAPROXY_DONE /* all work done */ } haproxy_state; struct cf_haproxy_ctx { @@ -61,7 +61,7 @@ static void cf_haproxy_ctx_free(struct cf_haproxy_ctx *ctx) } } -static CURLcode cf_haproxy_date_out_set(struct Curl_cfilter*cf, +static CURLcode cf_haproxy_date_out_set(struct Curl_cfilter *cf, struct Curl_easy *data) { struct cf_haproxy_ctx *ctx = cf->ctx; diff --git a/lib/cf-ip-happy.c b/lib/cf-ip-happy.c index 8901db02c283..72ac59b7d90b 100644 --- a/lib/cf-ip-happy.c +++ b/lib/cf-ip-happy.c @@ -108,7 +108,6 @@ void Curl_debug_set_transport_provider(uint8_t transport, } #endif /* UNITTESTS */ - struct cf_ai_iter { const struct Curl_addrinfo *head; const struct Curl_addrinfo *last; @@ -423,9 +422,9 @@ static CURLcode cf_ip_ballers_run(struct cf_ip_ballers *bs, int ai_family = 0; #ifdef USE_IPV6 if((bs->last_attempt_ai_family == AF_INET) || - !cf_ai_iter_has_more(&bs->addr_iter)) { - addr = cf_ai_iter_next(&bs->ipv6_iter); - ai_family = bs->ipv6_iter.ai_family; + !cf_ai_iter_has_more(&bs->addr_iter)) { + addr = cf_ai_iter_next(&bs->ipv6_iter); + ai_family = bs->ipv6_iter.ai_family; } #endif if(!addr) { @@ -629,7 +628,6 @@ struct cf_ip_happy_ctx { struct curltime started; }; - static CURLcode is_connected(struct Curl_cfilter *cf, struct Curl_easy *data, bool *connected) @@ -774,50 +772,50 @@ static CURLcode cf_ip_happy_connect(struct Curl_cfilter *cf, *done = FALSE; switch(ctx->state) { - case SCFST_INIT: - DEBUGASSERT(CURL_SOCKET_BAD == Curl_conn_cf_get_socket(cf, data)); - DEBUGASSERT(!cf->connected); - result = start_connect(cf, data); - if(result) - return result; - ctx->state = SCFST_WAITING; - FALLTHROUGH(); - case SCFST_WAITING: - result = is_connected(cf, data, done); - if(!result && *done) { - DEBUGASSERT(ctx->ballers.winner); - DEBUGASSERT(ctx->ballers.winner->cf); - DEBUGASSERT(ctx->ballers.winner->cf->connected); - /* we have a winner. Install and activate it. - * close/free all others. */ - ctx->state = SCFST_DONE; - cf->connected = TRUE; - cf->next = ctx->ballers.winner->cf; - ctx->ballers.winner->cf = NULL; - cf_ip_happy_ctx_clear(cf, data); - Curl_expire_done(data, EXPIRE_HAPPY_EYEBALLS); - - if(cf->conn->handler->protocol & PROTO_FAMILY_SSH) - Curl_pgrsTime(data, TIMER_APPCONNECT); /* we are connected already */ + case SCFST_INIT: + DEBUGASSERT(CURL_SOCKET_BAD == Curl_conn_cf_get_socket(cf, data)); + DEBUGASSERT(!cf->connected); + result = start_connect(cf, data); + if(result) + return result; + ctx->state = SCFST_WAITING; + FALLTHROUGH(); + case SCFST_WAITING: + result = is_connected(cf, data, done); + if(!result && *done) { + DEBUGASSERT(ctx->ballers.winner); + DEBUGASSERT(ctx->ballers.winner->cf); + DEBUGASSERT(ctx->ballers.winner->cf->connected); + /* we have a winner. Install and activate it. + * close/free all others. */ + ctx->state = SCFST_DONE; + cf->connected = TRUE; + cf->next = ctx->ballers.winner->cf; + ctx->ballers.winner->cf = NULL; + cf_ip_happy_ctx_clear(cf, data); + Curl_expire_done(data, EXPIRE_HAPPY_EYEBALLS); + + if(cf->conn->handler->protocol & PROTO_FAMILY_SSH) + Curl_pgrsTime(data, TIMER_APPCONNECT); /* we are connected already */ #ifndef CURL_DISABLE_VERBOSE_STRINGS - if(Curl_trc_cf_is_verbose(cf, data)) { - struct ip_quadruple ipquad; - bool is_ipv6; - if(!Curl_conn_cf_get_ip_info(cf->next, data, &is_ipv6, &ipquad)) { - const char *host; - int port; - Curl_conn_get_current_host(data, cf->sockindex, &host, &port); - CURL_TRC_CF(data, cf, "Connected to %s (%s) port %u", - host, ipquad.remote_ip, ipquad.remote_port); - } + if(Curl_trc_cf_is_verbose(cf, data)) { + struct ip_quadruple ipquad; + bool is_ipv6; + if(!Curl_conn_cf_get_ip_info(cf->next, data, &is_ipv6, &ipquad)) { + const char *host; + int port; + Curl_conn_get_current_host(data, cf->sockindex, &host, &port); + CURL_TRC_CF(data, cf, "Connected to %s (%s) port %u", + host, ipquad.remote_ip, ipquad.remote_port); } -#endif - data->info.numconnects++; /* to track the # of connections made */ } - break; - case SCFST_DONE: - *done = TRUE; - break; +#endif + data->info.numconnects++; /* to track the # of connections made */ + } + break; + case SCFST_DONE: + *done = TRUE; + break; } return result; } diff --git a/lib/cf-socket.c b/lib/cf-socket.c index 3172aee5b9c9..a12995941610 100644 --- a/lib/cf-socket.c +++ b/lib/cf-socket.c @@ -96,7 +96,7 @@ static void set_ipv6_v6only(curl_socket_t sockfd, int on) (void)setsockopt(sockfd, IPPROTO_IPV6, IPV6_V6ONLY, (void *)&on, sizeof(on)); } #else -#define set_ipv6_v6only(x,y) +#define set_ipv6_v6only(x, y) #endif static void tcpnodelay(struct Curl_cfilter *cf, @@ -104,7 +104,7 @@ static void tcpnodelay(struct Curl_cfilter *cf, curl_socket_t sockfd) { #if defined(TCP_NODELAY) && defined(CURL_TCP_NODELAY_SUPPORTED) - curl_socklen_t onoff = (curl_socklen_t) 1; + curl_socklen_t onoff = (curl_socklen_t)1; int level = IPPROTO_TCP; char buffer[STRERROR_LEN]; @@ -142,7 +142,7 @@ static void nosigpipe(struct Curl_cfilter *cf, } } #else -#define nosigpipe(x,y,z) Curl_nop_stmt +#define nosigpipe(x, y, z) Curl_nop_stmt #endif #if defined(USE_WINSOCK) || \ @@ -156,10 +156,9 @@ static void nosigpipe(struct Curl_cfilter *cf, #define KEEPALIVE_FACTOR(x) #endif -static void -tcpkeepalive(struct Curl_cfilter *cf, - struct Curl_easy *data, - curl_socket_t sockfd) +static void tcpkeepalive(struct Curl_cfilter *cf, + struct Curl_easy *data, + curl_socket_t sockfd) { int optval = data->set.tcp_keepalive ? 1 : 0; @@ -202,7 +201,7 @@ tcpkeepalive(struct Curl_cfilter *cf, { /* Offered by mingw-w64 and MS SDK. Latter only when targeting Win7+. */ #ifndef SIO_KEEPALIVE_VALS -#define SIO_KEEPALIVE_VALS _WSAIOW(IOC_VENDOR,4) +#define SIO_KEEPALIVE_VALS _WSAIOW(IOC_VENDOR, 4) struct tcp_keepalive { u_long onoff; u_long keepalivetime; @@ -342,15 +341,15 @@ static CURLcode socket_open(struct Curl_easy *data, DEBUGASSERT(data); DEBUGASSERT(data->conn); if(data->set.fopensocket) { - /* - * If the opensocket callback is set, all the destination address - * information is passed to the callback. Depending on this information the - * callback may opt to abort the connection, this is indicated returning - * CURL_SOCKET_BAD; otherwise it will return a not-connected socket. When - * the callback returns a valid socket the destination address information - * might have been changed and this 'new' address will actually be used - * here to connect. - */ + /* + * If the opensocket callback is set, all the destination address + * information is passed to the callback. Depending on this information the + * callback may opt to abort the connection, this is indicated returning + * CURL_SOCKET_BAD; otherwise it will return a not-connected socket. When + * the callback returns a valid socket the destination address information + * might have been changed and this 'new' address will actually be used + * here to connect. + */ Curl_set_in_callback(data, TRUE); *sockfd = data->set.fopensocket(data->set.opensocket_client, CURLSOCKTYPE_IPCXN, @@ -600,7 +599,7 @@ static CURLcode bindlocal(struct Curl_easy *data, struct connectdata *conn, if(!iface && !host && !port) /* no local kind of binding was requested */ return CURLE_OK; - else if(iface && (strlen(iface) >= 255) ) + else if(iface && (strlen(iface) >= 255)) return CURLE_BAD_FUNCTION_ARGUMENT; memset(&sa, 0, sizeof(struct Curl_sockaddr_storage)); @@ -640,33 +639,33 @@ static CURLcode bindlocal(struct Curl_easy *data, struct connectdata *conn, /* Discover IP from input device, then bind to it */ if2ip_result = Curl_if2ip(af, #ifdef USE_IPV6 - scope, conn->scope_id, + scope, conn->scope_id, #endif - iface, myhost, sizeof(myhost)); + iface, myhost, sizeof(myhost)); } switch(if2ip_result) { - case IF2IP_NOT_FOUND: - if(iface_input && !host_input) { - /* Do not fall back to treating it as a hostname */ - char buffer[STRERROR_LEN]; - data->state.os_errno = error = SOCKERRNO; - failf(data, "Could not bind to interface '%s' with errno %d: %s", - iface, error, curlx_strerror(error, buffer, sizeof(buffer))); - return CURLE_INTERFACE_FAILED; - } - break; - case IF2IP_AF_NOT_SUPPORTED: - /* Signal the caller to try another address family if available */ - return CURLE_UNSUPPORTED_PROTOCOL; - case IF2IP_FOUND: - /* - * We now have the numerical IP address in the 'myhost' buffer - */ - host = myhost; - infof(data, "Local Interface %s is ip %s using address family %i", - iface, host, af); - done = 1; - break; + case IF2IP_NOT_FOUND: + if(iface_input && !host_input) { + /* Do not fall back to treating it as a hostname */ + char buffer[STRERROR_LEN]; + data->state.os_errno = error = SOCKERRNO; + failf(data, "Could not bind to interface '%s' with errno %d: %s", + iface, error, curlx_strerror(error, buffer, sizeof(buffer))); + return CURLE_INTERFACE_FAILED; + } + break; + case IF2IP_AF_NOT_SUPPORTED: + /* Signal the caller to try another address family if available */ + return CURLE_UNSUPPORTED_PROTOCOL; + case IF2IP_FOUND: + /* + * We now have the numerical IP address in the 'myhost' buffer + */ + host = myhost; + infof(data, "Local Interface %s is ip %s using address family %i", + iface, host, af); + done = 1; + break; } if(!iface_input || host_input) { /* @@ -728,7 +727,7 @@ static CURLcode bindlocal(struct Curl_easy *data, struct connectdata *conn, present, is known to be numeric */ curl_off_t scope_id; if(curlx_str_number((const char **)CURL_UNCONST(&scope_ptr), - &scope_id, UINT_MAX)) + &scope_id, UINT_MAX)) return CURLE_UNSUPPORTED_PROTOCOL; si6->sin6_scope_id = (unsigned int)scope_id; } @@ -921,7 +920,7 @@ struct cf_socket_ctx { int wblock_percent; /* percent of writes doing EAGAIN */ int wpartial_percent; /* percent of bytes written in send */ int rblock_percent; /* percent of reads doing EAGAIN */ - size_t recv_max; /* max enforced read size */ + size_t recv_max; /* max enforced read size */ #endif BIT(got_first_byte); /* if first byte was received */ BIT(listening); /* socket is listening */ @@ -1043,12 +1042,12 @@ static void set_local_ip(struct Curl_cfilter *cf, curl_socklen_t slen = sizeof(struct Curl_sockaddr_storage); memset(&ssloc, 0, sizeof(ssloc)); - if(getsockname(ctx->sock, (struct sockaddr*) &ssloc, &slen)) { + if(getsockname(ctx->sock, (struct sockaddr *)&ssloc, &slen)) { int error = SOCKERRNO; infof(data, "getsockname() failed with errno %d: %s", error, curlx_strerror(error, buffer, sizeof(buffer))); } - else if(!Curl_addr2string((struct sockaddr*)&ssloc, slen, + else if(!Curl_addr2string((struct sockaddr *)&ssloc, slen, ctx->ip.local_ip, &ctx->ip.local_port)) { infof(data, "ssloc inet_ntop() failed with errno %d: %s", errno, curlx_strerror(errno, buffer, sizeof(buffer))); @@ -1123,8 +1122,8 @@ static CURLcode cf_socket_open(struct Curl_cfilter *cf, infof(data, " Trying %s:%d...", ctx->ip.remote_ip, ctx->ip.remote_port); #ifdef USE_IPV6 - is_tcp = (ctx->addr.family == AF_INET - || ctx->addr.family == AF_INET6) && + is_tcp = (ctx->addr.family == AF_INET || + ctx->addr.family == AF_INET6) && ctx->addr.socktype == SOCK_STREAM; #else is_tcp = (ctx->addr.family == AF_INET) && @@ -1320,8 +1319,7 @@ static CURLcode cf_tcp_connect(struct Curl_cfilter *cf, rc = SOCKET_WRITABLE(ctx->sock, 0); if(rc == 0) { /* no connection yet */ - CURL_TRC_CF(data, cf, "not connected yet on fd=%" FMT_SOCKET_T, - ctx->sock); + CURL_TRC_CF(data, cf, "not connected yet on fd=%" FMT_SOCKET_T, ctx->sock); return CURLE_OK; } else if(rc == CURL_CSELECT_OUT || cf->conn->bits.tcp_fastopen) { @@ -1411,7 +1409,7 @@ static void win_update_sndbuf_size(struct cf_socket_ctx *ctx) if(curlx_timediff_ms(n, ctx->last_sndbuf_query_at) > 1000) { if(!WSAIoctl(ctx->sock, SIO_IDEAL_SEND_BACKLOG_QUERY, 0, 0, - &ideal, sizeof(ideal), &ideallen, 0, 0) && + &ideal, sizeof(ideal), &ideallen, 0, 0) && ideal != ctx->sndbuf_size && !setsockopt(ctx->sock, SOL_SOCKET, SO_SNDBUF, (const char *)&ideal, sizeof(ideal))) { @@ -1443,7 +1441,7 @@ static CURLcode cf_socket_send(struct Curl_cfilter *cf, struct Curl_easy *data, if(ctx->wblock_percent > 0) { unsigned char c = 0; Curl_rand_bytes(data, FALSE, &c, 1); - if(c >= ((100-ctx->wblock_percent)*256/100)) { + if(c >= ((100 - ctx->wblock_percent) * 256 / 100)) { CURL_TRC_CF(data, cf, "send(len=%zu) SIMULATE EWOULDBLOCK", orig_len); cf->conn->sock[cf->sockindex] = fdsave; return CURLE_AGAIN; @@ -1520,7 +1518,7 @@ static CURLcode cf_socket_recv(struct Curl_cfilter *cf, struct Curl_easy *data, if(cf->cft != &Curl_cft_udp && ctx->rblock_percent > 0) { unsigned char c = 0; Curl_rand(data, &c, 1); - if(c >= ((100-ctx->rblock_percent)*256/100)) { + if(c >= ((100 - ctx->rblock_percent) * 256 / 100)) { CURL_TRC_CF(data, cf, "recv(len=%zu) SIMULATE EWOULDBLOCK", len); return CURLE_AGAIN; } @@ -1634,7 +1632,7 @@ static bool cf_socket_conn_is_alive(struct Curl_cfilter *cf, /* Check with 0 timeout if there are any events pending on the socket */ pfd[0].fd = ctx->sock; - pfd[0].events = POLLRDNORM|POLLIN|POLLRDBAND|POLLPRI; + pfd[0].events = POLLRDNORM | POLLIN | POLLRDBAND | POLLPRI; pfd[0].revents = 0; r = Curl_poll(pfd, 1, 0); @@ -1646,7 +1644,7 @@ static bool cf_socket_conn_is_alive(struct Curl_cfilter *cf, CURL_TRC_CF(data, cf, "is_alive: poll timeout, assume alive"); return TRUE; } - else if(pfd[0].revents & (POLLERR|POLLHUP|POLLPRI|POLLNVAL)) { + else if(pfd[0].revents & (POLLERR | POLLHUP | POLLPRI | POLLNVAL)) { CURL_TRC_CF(data, cf, "is_alive: err/hup/etc events, assume dead"); return FALSE; } @@ -1814,7 +1812,6 @@ static void linux_quic_gro(struct cf_socket_ctx *ctx) #define linux_quic_gro(x) #endif - static CURLcode cf_udp_setup_quic(struct Curl_cfilter *cf, struct Curl_easy *data) { @@ -2035,13 +2032,13 @@ static void cf_tcp_set_accepted_remote_ip(struct Curl_cfilter *cf, ctx->ip.remote_port = 0; plen = sizeof(ssrem); memset(&ssrem, 0, plen); - if(getpeername(ctx->sock, (struct sockaddr*) &ssrem, &plen)) { + if(getpeername(ctx->sock, (struct sockaddr *)&ssrem, &plen)) { int error = SOCKERRNO; failf(data, "getpeername() failed with errno %d: %s", error, curlx_strerror(error, buffer, sizeof(buffer))); return; } - if(!Curl_addr2string((struct sockaddr*)&ssrem, plen, + if(!Curl_addr2string((struct sockaddr *)&ssrem, plen, ctx->ip.remote_ip, &ctx->ip.remote_port)) { failf(data, "ssrem inet_ntop() failed with errno %d: %s", errno, curlx_strerror(errno, buffer, sizeof(buffer))); @@ -2111,10 +2108,10 @@ static CURLcode cf_tcp_accept_connect(struct Curl_cfilter *cf, size = sizeof(add); #ifdef HAVE_ACCEPT4 - s_accepted = CURL_ACCEPT4(ctx->sock, (struct sockaddr *) &add, &size, + s_accepted = CURL_ACCEPT4(ctx->sock, (struct sockaddr *)&add, &size, SOCK_NONBLOCK | SOCK_CLOEXEC); #else - s_accepted = CURL_ACCEPT(ctx->sock, (struct sockaddr *) &add, &size); + s_accepted = CURL_ACCEPT(ctx->sock, (struct sockaddr *)&add, &size); #endif if(CURL_SOCKET_BAD == s_accepted) { diff --git a/lib/cf-socket.h b/lib/cf-socket.h index 432b0870451d..e5f69c60f46f 100644 --- a/lib/cf-socket.h +++ b/lib/cf-socket.h @@ -57,7 +57,7 @@ struct Curl_sockaddr_ex { /* * Parse interface option, and return the interface name and the host part. -*/ + */ CURLcode Curl_parse_interface(const char *input, char **dev, char **iface, char **host); diff --git a/lib/cfilters.c b/lib/cfilters.c index dd4cb5210acc..f51da8521aff 100644 --- a/lib/cfilters.c +++ b/lib/cfilters.c @@ -511,8 +511,7 @@ CURLcode Curl_conn_connect(struct Curl_easy *data, goto out; } else if(result) { - CURL_TRC_CF(data, cf, "Curl_conn_connect(), filter returned %d", - result); + CURL_TRC_CF(data, cf, "Curl_conn_connect(), filter returned %d", result); conn_report_connect_stats(cf, data); goto out; } @@ -653,7 +652,7 @@ bool Curl_conn_is_multiplex(struct connectdata *conn, int sockindex) for(; cf; cf = cf->next) { if(cf->cft->flags & CF_TYPE_MULTIPLEX) return TRUE; - if(cf->cft->flags & (CF_TYPE_IP_CONNECT|CF_TYPE_SSL)) + if(cf->cft->flags & (CF_TYPE_IP_CONNECT | CF_TYPE_SSL)) return FALSE; } return FALSE; @@ -691,7 +690,7 @@ unsigned char Curl_conn_http_version(struct Curl_easy *data, v = (unsigned char)value; break; } - if(cf->cft->flags & (CF_TYPE_IP_CONNECT|CF_TYPE_SSL)) + if(cf->cft->flags & (CF_TYPE_IP_CONNECT | CF_TYPE_SSL)) break; } return (unsigned char)(result ? 0 : v); @@ -803,9 +802,9 @@ void Curl_conn_get_current_host(struct Curl_easy *data, int sockindex, cf = CONN_SOCK_IDX_VALID(sockindex) ? data->conn->cfilter[sockindex] : NULL; /* Find the "lowest" tunneling proxy filter that has not connected yet. */ while(cf && !cf->connected) { - if((cf->cft->flags & (CF_TYPE_IP_CONNECT|CF_TYPE_PROXY)) == - (CF_TYPE_IP_CONNECT|CF_TYPE_PROXY)) - cf_proxy = cf; + if((cf->cft->flags & (CF_TYPE_IP_CONNECT | CF_TYPE_PROXY)) == + (CF_TYPE_IP_CONNECT | CF_TYPE_PROXY)) + cf_proxy = cf; cf = cf->next; } /* cf_proxy (!= NULL) is not connected yet. It is talking @@ -945,8 +944,7 @@ static CURLcode cf_cntrl_all(struct connectdata *conn, CURLcode Curl_conn_ev_data_setup(struct Curl_easy *data) { - return cf_cntrl_all(data->conn, data, FALSE, - CF_CTRL_DATA_SETUP, 0, NULL); + return cf_cntrl_all(data->conn, data, FALSE, CF_CTRL_DATA_SETUP, 0, NULL); } CURLcode Curl_conn_flush(struct Curl_easy *data, int sockindex) @@ -1100,8 +1098,7 @@ CURLcode Curl_conn_send(struct Curl_easy *data, int sockindex, return CURLE_BAD_FUNCTION_ARGUMENT; #ifdef DEBUGBUILD if(write_len) { - /* Allow debug builds to override this logic to force short sends - */ + /* Allow debug builds to override this logic to force short sends */ const char *p = getenv("CURL_SMALLSENDS"); if(p) { curl_off_t altsize; diff --git a/lib/cfilters.h b/lib/cfilters.h index a3bd97a9f166..73b9cb03e034 100644 --- a/lib/cfilters.h +++ b/lib/cfilters.h @@ -116,16 +116,16 @@ typedef CURLcode Curl_cft_conn_keep_alive(struct Curl_cfilter *cf, * "ignored" meaning return values are ignored and the event is distributed * to all filters in the chain. Overall result is always CURLE_OK. */ -/* data event arg1 arg2 return */ -#define CF_CTRL_DATA_SETUP 4 /* 0 NULL first fail */ -/* unused now 5 */ -#define CF_CTRL_DATA_PAUSE 6 /* on/off NULL first fail */ -#define CF_CTRL_DATA_DONE 7 /* premature NULL ignored */ -#define CF_CTRL_DATA_DONE_SEND 8 /* 0 NULL ignored */ +/* data event arg1 arg2 return */ +#define CF_CTRL_DATA_SETUP 4 /* 0 NULL first fail */ +/* unused now 5 */ +#define CF_CTRL_DATA_PAUSE 6 /* on/off NULL first fail */ +#define CF_CTRL_DATA_DONE 7 /* premature NULL ignored */ +#define CF_CTRL_DATA_DONE_SEND 8 /* 0 NULL ignored */ /* update conn info at connection and data */ -#define CF_CTRL_CONN_INFO_UPDATE (256+0) /* 0 NULL ignored */ -#define CF_CTRL_FORGET_SOCKET (256+1) /* 0 NULL ignored */ -#define CF_CTRL_FLUSH (256+2) /* 0 NULL first fail */ +#define CF_CTRL_CONN_INFO_UPDATE (256 + 0) /* 0 NULL ignored */ +#define CF_CTRL_FORGET_SOCKET (256 + 1) /* 0 NULL ignored */ +#define CF_CTRL_FLUSH (256 + 2) /* 0 NULL first fail */ /** * Handle event/control for the filter. @@ -135,7 +135,6 @@ typedef CURLcode Curl_cft_cntrl(struct Curl_cfilter *cf, struct Curl_easy *data, int event, int arg1, void *arg2); - /** * Queries to ask via a `Curl_cft_query *query` method on a cfilter chain. * - MAX_CONCURRENT: the maximum number of parallel transfers the filter @@ -210,21 +209,21 @@ typedef CURLcode Curl_cft_query(struct Curl_cfilter *cf, /* A connection filter type, e.g. specific implementation. */ struct Curl_cftype { - const char *name; /* name of the filter type */ - int flags; /* flags of filter type */ - int log_level; /* log level for such filters */ - Curl_cft_destroy_this *destroy; /* destroy resources of this cf */ - Curl_cft_connect *do_connect; /* establish connection */ - Curl_cft_close *do_close; /* close conn */ - Curl_cft_shutdown *do_shutdown; /* shutdown conn */ + const char *name; /* name of the filter type */ + int flags; /* flags of filter type */ + int log_level; /* log level for such filters */ + Curl_cft_destroy_this *destroy; /* destroy resources of this cf */ + Curl_cft_connect *do_connect; /* establish connection */ + Curl_cft_close *do_close; /* close conn */ + Curl_cft_shutdown *do_shutdown; /* shutdown conn */ Curl_cft_adjust_pollset *adjust_pollset; /* adjust transfer poll set */ - Curl_cft_data_pending *has_data_pending;/* conn has data pending */ - Curl_cft_send *do_send; /* send data */ - Curl_cft_recv *do_recv; /* receive data */ - Curl_cft_cntrl *cntrl; /* events/control */ - Curl_cft_conn_is_alive *is_alive; /* FALSE if conn is dead, Jim! */ - Curl_cft_conn_keep_alive *keep_alive; /* try to keep it alive */ - Curl_cft_query *query; /* query filter chain */ + Curl_cft_data_pending *has_data_pending; /* conn has data pending */ + Curl_cft_send *do_send; /* send data */ + Curl_cft_recv *do_recv; /* receive data */ + Curl_cft_cntrl *cntrl; /* events/control */ + Curl_cft_conn_is_alive *is_alive; /* FALSE if conn is dead, Jim! */ + Curl_cft_conn_keep_alive *keep_alive; /* try to keep it alive */ + Curl_cft_query *query; /* query filter chain */ }; /* A connection filter instance, e.g. registered at a connection */ @@ -426,7 +425,7 @@ const char *Curl_conn_get_alpn_negotiated(struct Curl_easy *data, /** * Close the filter chain at `sockindex` for connection `data->conn`. - * Filters remain in place and may be connected again afterwards. + * Filters remain in place and may be connected again afterwards. */ void Curl_conn_close(struct Curl_easy *data, int sockindex); @@ -622,7 +621,6 @@ CURLcode Curl_conn_send(struct Curl_easy *data, int sockindex, const void *buf, size_t blen, bool eos, size_t *pnwritten); - /** * Types and macros used to keep the current easy handle in filter calls, * allowing for nested invocations. See #10336. @@ -654,7 +652,7 @@ struct cf_call_data { * a member in the cfilter's `ctx`. * * #define CF_CTX_CALL_DATA(cf) -> struct cf_call_data instance -*/ + */ #ifdef DEBUGBUILD @@ -688,7 +686,6 @@ struct cf_call_data { #endif /* !DEBUGBUILD */ -#define CF_DATA_CURRENT(cf) \ - ((cf)? (CF_CTX_CALL_DATA(cf).data) : NULL) +#define CF_DATA_CURRENT(cf) ((cf) ? (CF_CTX_CALL_DATA(cf).data) : NULL) #endif /* HEADER_CURL_CFILTERS_H */ diff --git a/lib/conncache.c b/lib/conncache.c index 7f38a1875790..c7a52b69f69a 100644 --- a/lib/conncache.c +++ b/lib/conncache.c @@ -59,7 +59,7 @@ } \ } while(0) -#define CPOOL_UNLOCK(c,d) \ +#define CPOOL_UNLOCK(c,d) \ do { \ if((c)) { \ DEBUGASSERT((c)->locked); \ @@ -161,7 +161,6 @@ static struct connectdata *cpool_get_first(struct cpool *cpool) return NULL; } - static struct cpool_bundle *cpool_find_bundle(struct cpool *cpool, struct connectdata *conn) { @@ -178,7 +177,6 @@ static void cpool_remove_bundle(struct cpool *cpool, Curl_hash_delete(&cpool->dest2bundle, bundle->dest, bundle->dest_len); } - static void cpool_remove_conn(struct cpool *cpool, struct connectdata *conn) { @@ -260,8 +258,8 @@ void Curl_cpool_xfer_init(struct Curl_easy *data) } } -static struct cpool_bundle * -cpool_add_bundle(struct cpool *cpool, struct connectdata *conn) +static struct cpool_bundle *cpool_add_bundle(struct cpool *cpool, + struct connectdata *conn) { struct cpool_bundle *bundle; @@ -341,7 +339,6 @@ static struct connectdata *cpool_get_oldest_idle(struct cpool *cpool) return oldest_idle; } - int Curl_cpool_check_limits(struct Curl_easy *data, struct connectdata *conn) { @@ -386,10 +383,10 @@ int Curl_cpool_check_limits(struct Curl_easy *data, if(!oldest_idle) break; /* disconnect the old conn and continue */ - CURL_TRC_M(data, "Discarding connection #%" - FMT_OFF_T " from %zu to reach destination " - "limit of %zu", oldest_idle->connection_id, - Curl_llist_count(&bundle->conns), dest_limit); + CURL_TRC_M(data, "Discarding connection #%" FMT_OFF_T + " from %zu to reach destination limit of %zu", + oldest_idle->connection_id, + Curl_llist_count(&bundle->conns), dest_limit); Curl_conn_terminate(cpool->idata, oldest_idle, FALSE); /* in case the bundle was destroyed in disconnect, look it up again */ @@ -704,7 +701,6 @@ void Curl_conn_terminate(struct Curl_easy *data, CPOOL_UNLOCK(cpool, data); } - struct cpool_reaper_ctx { struct curltime now; }; diff --git a/lib/conncache.h b/lib/conncache.h index a5f133344fd4..5761ee9b4464 100644 --- a/lib/conncache.h +++ b/lib/conncache.h @@ -49,7 +49,7 @@ void Curl_conn_terminate(struct Curl_easy *data, bool aborted); struct cpool { - /* the pooled connections, bundled per destination */ + /* the pooled connections, bundled per destination */ struct Curl_hash dest2bundle; size_t num_conn; curl_off_t next_connection_id; @@ -166,5 +166,4 @@ void Curl_cpool_do_locked(struct Curl_easy *data, /* Close all unused connections, prevent reuse of existing ones. */ void Curl_cpool_nw_changed(struct Curl_easy *data); - #endif /* HEADER_CURL_CONNCACHE_H */ diff --git a/lib/connect.c b/lib/connect.c index 72a27fae1cd9..748cf53a29ae 100644 --- a/lib/connect.c +++ b/lib/connect.c @@ -247,36 +247,35 @@ bool Curl_addr2string(struct sockaddr *sa, curl_socklen_t salen, #endif switch(sa->sa_family) { - case AF_INET: - si = (struct sockaddr_in *)(void *) sa; - if(curlx_inet_ntop(sa->sa_family, &si->sin_addr, addr, MAX_IPADR_LEN)) { - *port = ntohs(si->sin_port); - return TRUE; - } - break; + case AF_INET: + si = (struct sockaddr_in *)(void *)sa; + if(curlx_inet_ntop(sa->sa_family, &si->sin_addr, addr, MAX_IPADR_LEN)) { + *port = ntohs(si->sin_port); + return TRUE; + } + break; #ifdef USE_IPV6 - case AF_INET6: - si6 = (struct sockaddr_in6 *)(void *) sa; - if(curlx_inet_ntop(sa->sa_family, &si6->sin6_addr, addr, - MAX_IPADR_LEN)) { - *port = ntohs(si6->sin6_port); - return TRUE; - } - break; + case AF_INET6: + si6 = (struct sockaddr_in6 *)(void *)sa; + if(curlx_inet_ntop(sa->sa_family, &si6->sin6_addr, addr, MAX_IPADR_LEN)) { + *port = ntohs(si6->sin6_port); + return TRUE; + } + break; #endif #if (defined(HAVE_SYS_UN_H) || defined(WIN32_SOCKADDR_UN)) && defined(AF_UNIX) - case AF_UNIX: - if(salen > (curl_socklen_t)sizeof(CURL_SA_FAMILY_T)) { - su = (struct sockaddr_un*)sa; - curl_msnprintf(addr, MAX_IPADR_LEN, "%s", su->sun_path); - } - else - addr[0] = 0; /* socket with no name */ - *port = 0; - return TRUE; + case AF_UNIX: + if(salen > (curl_socklen_t)sizeof(CURL_SA_FAMILY_T)) { + su = (struct sockaddr_un *)sa; + curl_msnprintf(addr, MAX_IPADR_LEN, "%s", su->sun_path); + } + else + addr[0] = 0; /* socket with no name */ + *port = 0; + return TRUE; #endif - default: - break; + default: + break; } addr[0] = '\0'; @@ -338,7 +337,7 @@ void Curl_conncontrol(struct connectdata *conn, #endif is_multiplex = Curl_conn_is_multiplex(conn, FIRSTSOCKET); closeit = (ctrl == CONNCTRL_CONNECTION) || - ((ctrl == CONNCTRL_STREAM) && !is_multiplex); + ((ctrl == CONNCTRL_STREAM) && !is_multiplex); if((ctrl == CONNCTRL_STREAM) && is_multiplex) ; /* stream signal on multiplex conn never affects close state */ else if((bit)closeit != conn->bits.close) { @@ -409,8 +408,8 @@ static CURLcode cf_setup_connect(struct Curl_cfilter *cf, if(ctx->state < CF_SETUP_CNNCT_HTTP_PROXY && cf->conn->bits.httpproxy) { #ifdef USE_SSL - if(IS_HTTPS_PROXY(cf->conn->http_proxy.proxytype) - && !Curl_conn_is_ssl(cf->conn, cf->sockindex)) { + if(IS_HTTPS_PROXY(cf->conn->http_proxy.proxytype) && + !Curl_conn_is_ssl(cf->conn, cf->sockindex)) { result = Curl_cf_ssl_proxy_insert_after(cf, data); if(result) return result; @@ -450,9 +449,9 @@ static CURLcode cf_setup_connect(struct Curl_cfilter *cf, if(ctx->state < CF_SETUP_CNNCT_SSL) { #ifdef USE_SSL - if((ctx->ssl_mode == CURL_CF_SSL_ENABLE - || (ctx->ssl_mode != CURL_CF_SSL_DISABLE - && cf->conn->handler->flags & PROTOPT_SSL)) /* we want SSL */ + if((ctx->ssl_mode == CURL_CF_SSL_ENABLE || + (ctx->ssl_mode != CURL_CF_SSL_DISABLE && + cf->conn->handler->flags & PROTOPT_SSL)) /* we want SSL */ && !Curl_conn_is_ssl(cf->conn, cf->sockindex)) { /* it is missing */ result = Curl_cf_ssl_insert_after(cf, data); if(result) @@ -494,7 +493,6 @@ static void cf_setup_destroy(struct Curl_cfilter *cf, struct Curl_easy *data) Curl_safefree(ctx); } - struct Curl_cftype Curl_cft_setup = { "SETUP", 0, diff --git a/lib/connect.h b/lib/connect.h index 9060591dcec6..7d1c9c908991 100644 --- a/lib/connect.h +++ b/lib/connect.h @@ -100,13 +100,13 @@ void Curl_conncontrol(struct connectdata *conn, ); #if defined(DEBUGBUILD) && !defined(CURL_DISABLE_VERBOSE_STRINGS) -#define streamclose(x,y) Curl_conncontrol(x, CONNCTRL_STREAM, y) -#define connclose(x,y) Curl_conncontrol(x, CONNCTRL_CONNECTION, y) -#define connkeep(x,y) Curl_conncontrol(x, CONNCTRL_KEEP, y) +#define streamclose(x, y) Curl_conncontrol(x, CONNCTRL_STREAM, y) +#define connclose(x, y) Curl_conncontrol(x, CONNCTRL_CONNECTION, y) +#define connkeep(x, y) Curl_conncontrol(x, CONNCTRL_KEEP, y) #else /* if !DEBUGBUILD || CURL_DISABLE_VERBOSE_STRINGS */ -#define streamclose(x,y) Curl_conncontrol(x, CONNCTRL_STREAM) -#define connclose(x,y) Curl_conncontrol(x, CONNCTRL_CONNECTION) -#define connkeep(x,y) Curl_conncontrol(x, CONNCTRL_KEEP) +#define streamclose(x, y) Curl_conncontrol(x, CONNCTRL_STREAM) +#define connclose(x, y) Curl_conncontrol(x, CONNCTRL_CONNECTION) +#define connkeep(x, y) Curl_conncontrol(x, CONNCTRL_KEEP) #endif CURLcode Curl_cf_setup_insert_after(struct Curl_cfilter *cf_at, diff --git a/lib/cookie.c b/lib/cookie.c index 250c7390ce12..81a57942b245 100644 --- a/lib/cookie.c +++ b/lib/cookie.c @@ -45,7 +45,7 @@ static void strstore(char **str, const char *newstr, size_t len); /* number of seconds in 400 days */ -#define COOKIES_MAXAGE (400*24*3600) +#define COOKIES_MAXAGE (400 * 24 * 3600) /* Make sure cookies never expire further away in time than 400 days into the future. (from RFC6265bis draft-19) @@ -59,7 +59,7 @@ static void cap_expires(time_t now, struct Cookie *co) timediff_t cap = now + COOKIES_MAXAGE; if(co->expires > cap) { cap += 30; - co->expires = (cap/60)*60; + co->expires = (cap / 60) * 60; } } } @@ -84,7 +84,7 @@ static bool cookie_tailmatch(const char *cookie_domain, return FALSE; if(!curl_strnequal(cookie_domain, - hostname + hostname_len-cookie_domain_len, + hostname + hostname_len - cookie_domain_len, cookie_domain_len)) return FALSE; @@ -428,8 +428,8 @@ parse_cookie_header(struct Curl_easy *data, * combination of name + contents. Chrome and Firefox support 4095 or * 4096 bytes combo */ - if(curlx_strlen(&name) >= (MAX_NAME-1) || - curlx_strlen(&val) >= (MAX_NAME-1) || + if(curlx_strlen(&name) >= (MAX_NAME - 1) || + curlx_strlen(&val) >= (MAX_NAME - 1) || ((curlx_strlen(&name) + curlx_strlen(&val)) > MAX_NAME)) { infof(data, "oversized cookie dropped, name/val %zu + %zu bytes", curlx_strlen(&name), curlx_strlen(&val)); @@ -530,11 +530,11 @@ parse_cookie_header(struct Curl_easy *data, is_ip = Curl_host_is_ipnum(domain ? domain : curlx_str(&val)); - if(!domain - || (is_ip && !strncmp(curlx_str(&val), domain, - curlx_strlen(&val)) && - (curlx_strlen(&val) == strlen(domain))) - || (!is_ip && cookie_tailmatch(curlx_str(&val), + if(!domain || + (is_ip && + !strncmp(curlx_str(&val), domain, curlx_strlen(&val)) && + (curlx_strlen(&val) == strlen(domain))) || + (!is_ip && cookie_tailmatch(curlx_str(&val), curlx_strlen(&val), domain))) { strstore(&co->domain, curlx_str(&val), curlx_strlen(&val)); if(!co->domain) @@ -689,7 +689,7 @@ parse_netscape(struct Cookie *co, co->httponly = TRUE; } - if(lineptr[0]=='#') + if(lineptr[0] == '#') /* do not even try the comments */ return CURLE_OK; @@ -704,7 +704,7 @@ parse_netscape(struct Cookie *co, next = (ptr[len] == '\t' ? &ptr[len + 1] : NULL); switch(fields) { case 0: - if(ptr[0]=='.') { /* skip preceding dots */ + if(ptr[0] == '.') { /* skip preceding dots */ ptr++; len--; } @@ -792,10 +792,9 @@ parse_netscape(struct Cookie *co, return CURLE_OK; } -static bool -is_public_suffix(struct Curl_easy *data, - struct Cookie *co, - const char *domain) +static bool is_public_suffix(struct Curl_easy *data, + struct Cookie *co, + const char *domain) { #ifdef USE_LIBPSL /* @@ -899,7 +898,7 @@ static bool replace_existing(struct Curl_easy *data, if(clist->domain && co->domain) { if(curl_strequal(clist->domain, co->domain) && - (clist->tailmatch == co->tailmatch)) + (clist->tailmatch == co->tailmatch)) /* The domains are identical */ replace_old = TRUE; } @@ -1059,7 +1058,6 @@ Curl_cookie_add(struct Curl_easy *data, return result; } - /* * Curl_cookie_init() * @@ -1195,7 +1193,6 @@ CURLcode Curl_cookie_loadfiles(struct Curl_easy *data) return result; } - /* * cookie_sort * @@ -1291,8 +1288,7 @@ CURLcode Curl_cookie_getlist(struct Curl_easy *data, /* at first, remove expired cookies */ remove_expired(ci); - for(n = Curl_llist_head(&ci->cookielist[myhash]); - n; n = Curl_node_next(n)) { + for(n = Curl_llist_head(&ci->cookielist[myhash]); n; n = Curl_node_next(n)) { struct Cookie *co = Curl_node_elem(n); /* if the cookie requires we are secure we must only continue if we are! */ @@ -1302,7 +1298,7 @@ CURLcode Curl_cookie_getlist(struct Curl_easy *data, if(!co->domain || (co->tailmatch && !is_ip && cookie_tailmatch(co->domain, strlen(co->domain), host)) || - ((!co->tailmatch || is_ip) && curl_strequal(host, co->domain)) ) { + ((!co->tailmatch || is_ip) && curl_strequal(host, co->domain))) { /* * the right part of the host matches the domain stuff in the * cookie data @@ -1312,7 +1308,7 @@ CURLcode Curl_cookie_getlist(struct Curl_easy *data, * now check the left part of the path with the cookies path * requirement */ - if(!co->spath || pathmatch(co->spath, path) ) { + if(!co->spath || pathmatch(co->spath, path)) { /* * This is a match and we add it to the return-linked-list @@ -1445,14 +1441,14 @@ void Curl_cookie_cleanup(struct CookieInfo *ci) static char *get_netscape_format(const struct Cookie *co) { return curl_maprintf( - "%s" /* httponly preamble */ - "%s%s\t" /* domain */ - "%s\t" /* tailmatch */ - "%s\t" /* path */ - "%s\t" /* secure */ - "%" FMT_OFF_T "\t" /* expires */ - "%s\t" /* name */ - "%s", /* value */ + "%s" /* httponly preamble */ + "%s%s\t" /* domain */ + "%s\t" /* tailmatch */ + "%s\t" /* path */ + "%s\t" /* secure */ + "%" FMT_OFF_T "\t" /* expires */ + "%s\t" /* name */ + "%s", /* value */ co->httponly ? "#HttpOnly_" : "", /* * Make sure all domains are prefixed with a dot if they allow @@ -1522,8 +1518,7 @@ static CURLcode cookie_output(struct Curl_easy *data, /* only sort the cookies with a domain property */ for(i = 0; i < COOKIE_HASH_SIZE; i++) { - for(n = Curl_llist_head(&ci->cookielist[i]); n; - n = Curl_node_next(n)) { + for(n = Curl_llist_head(&ci->cookielist[i]); n; n = Curl_node_next(n)) { struct Cookie *co = Curl_node_elem(n); if(!co->domain) continue; diff --git a/lib/cookie.h b/lib/cookie.h index e1be698cf49a..5e9f5f7823ce 100644 --- a/lib/cookie.h +++ b/lib/cookie.h @@ -30,29 +30,29 @@ #include "llist.h" struct Cookie { - struct Curl_llist_node node; /* for the main cookie list */ + struct Curl_llist_node node; /* for the main cookie list */ struct Curl_llist_node getnode; /* for getlist */ - char *name; /* = value */ - char *value; /* name = */ - char *path; /* path = which is in Set-Cookie: */ - char *spath; /* sanitized cookie path */ - char *domain; /* domain = */ - curl_off_t expires; /* expires = */ - unsigned int creationtime; /* time when the cookie was written */ - BIT(tailmatch); /* tail-match the domain name */ - BIT(secure); /* the 'secure' keyword was used */ - BIT(livecookie); /* updated from a server, not a stored file */ - BIT(httponly); /* the httponly directive is present */ - BIT(prefix_secure); /* secure prefix is set */ - BIT(prefix_host); /* host prefix is set */ + char *name; /* = value */ + char *value; /* name = */ + char *path; /* path = which is in Set-Cookie: */ + char *spath; /* sanitized cookie path */ + char *domain; /* domain = */ + curl_off_t expires; /* expires = */ + unsigned int creationtime; /* time when the cookie was written */ + BIT(tailmatch); /* tail-match the domain name */ + BIT(secure); /* the 'secure' keyword was used */ + BIT(livecookie); /* updated from server, not a stored file */ + BIT(httponly); /* the httponly directive is present */ + BIT(prefix_secure); /* secure prefix is set */ + BIT(prefix_host); /* host prefix is set */ }; /* * Available cookie prefixes, as defined in * draft-ietf-httpbis-rfc6265bis-02 */ -#define COOKIE_PREFIX__SECURE (1<<0) -#define COOKIE_PREFIX__HOST (1<<1) +#define COOKIE_PREFIX__SECURE (1 << 0) +#define COOKIE_PREFIX__HOST (1 << 1) #define COOKIE_HASH_SIZE 63 @@ -60,9 +60,9 @@ struct CookieInfo { /* linked lists of cookies we know of */ struct Curl_llist cookielist[COOKIE_HASH_SIZE]; curl_off_t next_expiration; /* the next time at which expiration happens */ - unsigned int numcookies; /* number of cookies in the "jar" */ - unsigned int lastct; /* last creation-time used in the jar */ - BIT(running); /* state info, for cookie adding information */ + unsigned int numcookies; /* number of cookies in the "jar" */ + unsigned int lastct; /* last creation-time used in the jar */ + BIT(running); /* state info, for cookie adding information */ BIT(newsession); /* new session, discard session cookies on load */ }; @@ -130,7 +130,7 @@ void Curl_cookie_clearsess(struct CookieInfo *cookies); #define Curl_cookie_init() NULL #define Curl_cookie_run(x) Curl_nop_stmt #define Curl_cookie_cleanup(x) Curl_nop_stmt -#define Curl_flush_cookies(x,y) 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_cookie_cleanup(struct CookieInfo *c); diff --git a/lib/cshutdn.c b/lib/cshutdn.c index 0a4ab416473f..26c8f9c0dd41 100644 --- a/lib/cshutdn.c +++ b/lib/cshutdn.c @@ -119,7 +119,6 @@ void Curl_cshutdn_run_once(struct Curl_easy *data, Curl_detach_connection(data); } - void Curl_cshutdn_terminate(struct Curl_easy *data, struct connectdata *conn, bool do_shutdown) @@ -227,7 +226,6 @@ static CURLcode cshutdn_wait(struct cshutdn *cshutdn, return result; } - static void cshutdn_perform(struct cshutdn *cshutdn, struct Curl_easy *data) { @@ -270,7 +268,6 @@ static void cshutdn_perform(struct cshutdn *cshutdn, Curl_expire_ex(data, nowp, next_expire_ms, EXPIRE_SHUTDOWN); } - static void cshutdn_terminate_all(struct cshutdn *cshutdn, struct Curl_easy *data, int timeout_ms) @@ -301,7 +298,7 @@ static void cshutdn_terminate_all(struct cshutdn *cshutdn, spent_ms = curlx_timediff_ms(curlx_now(), started); if(spent_ms >= (timediff_t)timeout_ms) { CURL_TRC_M(data, "[SHUTDOWN] shutdown finished, %s", - (timeout_ms > 0) ? "timeout" : "best effort done"); + (timeout_ms > 0) ? "timeout" : "best effort done"); break; } @@ -325,7 +322,6 @@ static void cshutdn_terminate_all(struct cshutdn *cshutdn, sigpipe_restore(&pipe_st); } - int Curl_cshutdn_init(struct cshutdn *cshutdn, struct Curl_multi *multi) { @@ -336,7 +332,6 @@ int Curl_cshutdn_init(struct cshutdn *cshutdn, return 0; /* good */ } - void Curl_cshutdn_destroy(struct cshutdn *cshutdn, struct Curl_easy *data) { @@ -388,7 +383,6 @@ size_t Curl_cshutdn_dest_count(struct Curl_easy *data, return 0; } - static CURLMcode cshutdn_update_ev(struct cshutdn *cshutdn, struct Curl_easy *data, struct connectdata *conn) @@ -404,7 +398,6 @@ static CURLMcode cshutdn_update_ev(struct cshutdn *cshutdn, return mresult; } - void Curl_cshutdn_add(struct cshutdn *cshutdn, struct connectdata *conn, size_t conns_in_pool) @@ -436,7 +429,6 @@ void Curl_cshutdn_add(struct cshutdn *cshutdn, conn->connection_id, Curl_llist_count(&cshutdn->list)); } - static void cshutdn_multi_socket(struct cshutdn *cshutdn, struct Curl_easy *data, curl_socket_t s) @@ -461,7 +453,6 @@ static void cshutdn_multi_socket(struct cshutdn *cshutdn, } } - void Curl_cshutdn_perform(struct cshutdn *cshutdn, struct Curl_easy *data, curl_socket_t s) @@ -483,8 +474,7 @@ void Curl_cshutdn_setfds(struct cshutdn *cshutdn, struct easy_pollset ps; Curl_pollset_init(&ps); - for(e = Curl_llist_head(&cshutdn->list); e; - e = Curl_node_next(e)) { + for(e = Curl_llist_head(&cshutdn->list); e; e = Curl_node_next(e)) { unsigned int i; struct connectdata *conn = Curl_node_elem(e); CURLcode result; @@ -535,8 +525,7 @@ unsigned int Curl_cshutdn_add_waitfds(struct cshutdn *cshutdn, CURLcode result; Curl_pollset_init(&ps); - for(e = Curl_llist_head(&cshutdn->list); e; - e = Curl_node_next(e)) { + for(e = Curl_llist_head(&cshutdn->list); e; e = Curl_node_next(e)) { conn = Curl_node_elem(e); Curl_pollset_reset(&ps); Curl_attach_connection(data, conn); @@ -563,8 +552,7 @@ CURLcode Curl_cshutdn_add_pollfds(struct cshutdn *cshutdn, struct connectdata *conn; Curl_pollset_init(&ps); - for(e = Curl_llist_head(&cshutdn->list); e; - e = Curl_node_next(e)) { + for(e = Curl_llist_head(&cshutdn->list); e; e = Curl_node_next(e)) { conn = Curl_node_elem(e); Curl_pollset_reset(&ps); Curl_attach_connection(data, conn); From 6d156bc05f6d96a84a5c6a464dee638870e92094 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Sun, 30 Nov 2025 01:26:56 +0100 Subject: [PATCH 126/415] tests/data: replace Perl `&&` with `and` for XML-compliance Bringing down non-XML-compliant files to 50 (from 58). Follow-up to 7f3731ce142c1d74023abad183cc8ce0fd527fab #19595 Closes #19765 --- tests/data/test1506 | 3 +-- tests/data/test1510 | 3 +-- tests/data/test1512 | 3 +-- tests/data/test1542 | 3 +-- tests/data/test2402 | 3 +-- tests/data/test2404 | 3 +-- tests/data/test2502 | 3 +-- tests/data/test96 | 3 +-- 8 files changed, 8 insertions(+), 16 deletions(-) diff --git a/tests/data/test1506 b/tests/data/test1506 index cd7654a0d8bc..677d16773c22 100644 --- a/tests/data/test1506 +++ b/tests/data/test1506 @@ -4,7 +4,6 @@ HTTP multi verbose logs -notxml @@ -93,7 +92,7 @@ Accept: */* * Connection #3 to host server4.example.com:%HTTPPORT left intact -$_ = '' if(($_ !~ /left intact/) && ($_ !~ /Closing connection/)) +$_ = '' if(($_ !~ /left intact/) and ($_ !~ /Closing connection/)) diff --git a/tests/data/test1510 b/tests/data/test1510 index febe7d76ea30..7a688c81a23a 100644 --- a/tests/data/test1510 +++ b/tests/data/test1510 @@ -4,7 +4,6 @@ HTTP verbose logs flaky -notxml @@ -90,7 +89,7 @@ Accept: */* * Connection #3 to host server4.example.com:%HTTPPORT left intact -$_ = '' if(($_ !~ /left intact/) && ($_ !~ /Closing connection/)) +$_ = '' if(($_ !~ /left intact/) and ($_ !~ /Closing connection/)) diff --git a/tests/data/test1512 b/tests/data/test1512 index 3798d7325b4c..74547cdd2867 100644 --- a/tests/data/test1512 +++ b/tests/data/test1512 @@ -3,7 +3,6 @@ HTTP GLOBAL DNS CACHE -notxml @@ -75,7 +74,7 @@ Accept: */* ^Host:.* -$_ = '' if(($_ !~ /left intact/) && ($_ !~ /Closing connection/)) +$_ = '' if(($_ !~ /left intact/) and ($_ !~ /Closing connection/)) diff --git a/tests/data/test1542 b/tests/data/test1542 index 044fe518a467..41cf01432475 100644 --- a/tests/data/test1542 +++ b/tests/data/test1542 @@ -6,7 +6,6 @@ connection reuse persistent connection CURLOPT_MAXLIFETIME_CONN verbose logs -notxml @@ -66,7 +65,7 @@ Accept: */* == Info: Connection #1 to host %HOSTIP:%HTTPPORT left intact -$_ = '' if(($_ !~ /left intact/) && ($_ !~ /(closing|shutting down) connection #\d+/)) +$_ = '' if(($_ !~ /left intact/) and ($_ !~ /(closing|shutting down) connection #\d+/)) diff --git a/tests/data/test2402 b/tests/data/test2402 index ba3fcc85b451..5dc357f58fcd 100644 --- a/tests/data/test2402 +++ b/tests/data/test2402 @@ -5,7 +5,6 @@ HTTP HTTP/2 multi verbose logs -notxml @@ -104,7 +103,7 @@ Via: 2 nghttpx * Connection #0 to host localhost:%HTTP2TLSPORT left intact -$_ = '' if(($_ !~ /left intact/) && ($_ !~ /Closing connection/)) +$_ = '' if(($_ !~ /left intact/) and ($_ !~ /Closing connection/)) diff --git a/tests/data/test2404 b/tests/data/test2404 index 5034a15c3ca6..3dbb726be9a3 100644 --- a/tests/data/test2404 +++ b/tests/data/test2404 @@ -5,7 +5,6 @@ HTTP HTTP/2 multi verbose logs -notxml @@ -104,7 +103,7 @@ Via: 2 nghttpx * Connection #0 to host localhost:%HTTP2TLSPORT left intact -$_ = '' if(($_ !~ /left intact/) && ($_ !~ /Closing connection/)) +$_ = '' if(($_ !~ /left intact/) and ($_ !~ /Closing connection/)) diff --git a/tests/data/test2502 b/tests/data/test2502 index ac6cd3cf588c..c76b0418744d 100644 --- a/tests/data/test2502 +++ b/tests/data/test2502 @@ -5,7 +5,6 @@ HTTP HTTP/3 multi verbose logs -notxml @@ -99,7 +98,7 @@ Via: 3 nghttpx == Info: Connection #0 to host localhost:%HTTP3PORT left intact -$_ = '' if(($_ !~ /left intact/) && ($_ !~ /Closing connection/)) +$_ = '' if(($_ !~ /left intact/) and ($_ !~ /Closing connection/)) Maximum allocated: 1800000 diff --git a/tests/data/test96 b/tests/data/test96 index de4b7c18ad3f..a99114a3b3fb 100644 --- a/tests/data/test96 +++ b/tests/data/test96 @@ -2,7 +2,6 @@ TrackMemory -notxml @@ -37,7 +36,7 @@ MEM tool_cfgable.c MEM tool_cfgable.c -$_ = '' if((($_ !~ /tool_paramhlp/) && ($_ !~ /tool_cfgable/)) || ($_ =~ /free\(\(nil\)\)/)) +$_ = '' if((($_ !~ /tool_paramhlp/) and ($_ !~ /tool_cfgable/)) || ($_ =~ /free\(\(nil\)\)/)) s/:\d+.*// s:^(MEM )(.*/)(.*):$1$3: From 2d2d70b6e568f229d140264361a219851de1fd56 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Sun, 30 Nov 2025 01:45:57 +0100 Subject: [PATCH 127/415] test613.pl: integrate mtime check for test 1445, 1446 Move check logic from postchecks to `test613.pl`. To make these test data files XML-compliant. Also to avoid POSIX/bash-shellisms in postcheck. Closes #19766 --- tests/data/test1445 | 4 +--- tests/data/test1446 | 7 +------ tests/libtest/test613.pl | 9 ++++++++- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/data/test1445 b/tests/data/test1445 index 705162be2d37..08c12c9647a8 100644 --- a/tests/data/test1445 +++ b/tests/data/test1445 @@ -3,7 +3,6 @@ FILE --remote-time -notxml @@ -29,8 +28,7 @@ file://localhost%FILE_PWD/%LOGDIR/test%TESTNUMBER.dir/plainfile.txt --remote-tim # Verify data after the test has been "shot" -%PERL %SRCDIR/libtest/test613.pl postprocess %PWD/%LOGDIR/test%TESTNUMBER.dir && \ -%PERL -e 'exit((stat("%LOGDIR/curl%TESTNUMBER.out"))[9] != 946728000)' +%PERL %SRCDIR/libtest/test613.pl postprocess %PWD/%LOGDIR/test%TESTNUMBER.dir %LOGDIR/curl%TESTNUMBER.out 946728000 diff --git a/tests/data/test1446 b/tests/data/test1446 index 448eefbc1f5a..aa87ce11e193 100644 --- a/tests/data/test1446 +++ b/tests/data/test1446 @@ -3,16 +3,13 @@ SFTP --remote-time -notxml -# # Server-side -# # Client-side @@ -29,12 +26,10 @@ SFTP with --remote-time -# # Verify data after the test has been "shot" -%PERL %SRCDIR/libtest/test613.pl postprocess %PWD/%LOGDIR/test%TESTNUMBER.dir && \ -%PERL -e 'exit((stat("%LOGDIR/curl%TESTNUMBER.out"))[9] != 978264000)' +%PERL %SRCDIR/libtest/test613.pl postprocess %PWD/%LOGDIR/test%TESTNUMBER.dir %LOGDIR/curl%TESTNUMBER.out 978264000 diff --git a/tests/libtest/test613.pl b/tests/libtest/test613.pl index 88c0e4968256..3cccb6ed7f71 100755 --- a/tests/libtest/test613.pl +++ b/tests/libtest/test613.pl @@ -83,7 +83,6 @@ sub errout { } elsif($ARGV[0] eq "postprocess") { my $dirname = $ARGV[1]; - my $logfile = $ARGV[2]; # Clean up the test directory if($^O eq 'cygwin') { @@ -97,6 +96,14 @@ sub errout { rmdir $dirname || die "$!"; + if($#ARGV >= 3) { # Verify mtime if requested + my $checkfile = $ARGV[2]; + my $expected_mtime = int($ARGV[3]); + my $mtime = (stat($checkfile))[9]; + exit ($mtime != $expected_mtime); + } + + my $logfile = $ARGV[2]; if($logfile && -s $logfile) { # Process the directory file to remove all information that # could be inconsistent from one test run to the next (e.g. From 0180af248119d373b74b6906c5adac71d4b6cdfe Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Sun, 30 Nov 2025 02:57:39 +0100 Subject: [PATCH 128/415] tests/data: add `%PERL` to postcheck commands where missing To avoid potentially executing a different Perl than used by the rest of the build and tests. Also to be more portable by not relying on shebang support, though these particular tests require POSIX shell anyway. Closes #19767 --- tests/data/test1013 | 2 +- tests/data/test1014 | 2 +- tests/data/test1022 | 2 +- tests/data/test1023 | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/data/test1013 b/tests/data/test1013 index aee2bfbefb3a..ef7cd958aa7e 100644 --- a/tests/data/test1013 +++ b/tests/data/test1013 @@ -25,7 +25,7 @@ Compare curl --version with curl-config --protocols # Verify data after the test has been "shot" -%SRCDIR/libtest/test%TESTNUMBER.pl ../curl-config %LOGDIR/stdout%TESTNUMBER protocols +%PERL %SRCDIR/libtest/test%TESTNUMBER.pl ../curl-config %LOGDIR/stdout%TESTNUMBER protocols 0 diff --git a/tests/data/test1014 b/tests/data/test1014 index 7dce0d8e1542..72289bc4ad32 100644 --- a/tests/data/test1014 +++ b/tests/data/test1014 @@ -25,7 +25,7 @@ Compare curl --version with curl-config --features # Verify data after the test has been "shot" -%SRCDIR/libtest/test1013.pl ../curl-config %LOGDIR/stdout%TESTNUMBER features > %LOGDIR/result%TESTNUMBER +%PERL %SRCDIR/libtest/test1013.pl ../curl-config %LOGDIR/stdout%TESTNUMBER features > %LOGDIR/result%TESTNUMBER 0 diff --git a/tests/data/test1022 b/tests/data/test1022 index 888c9ea1024c..b3b6bc04a2d6 100644 --- a/tests/data/test1022 +++ b/tests/data/test1022 @@ -25,7 +25,7 @@ Compare curl --version with curl-config --version # Verify data after the test has been "shot" -%SRCDIR/libtest/test%TESTNUMBER.pl ../curl-config %LOGDIR/stdout%TESTNUMBER version +%PERL %SRCDIR/libtest/test%TESTNUMBER.pl ../curl-config %LOGDIR/stdout%TESTNUMBER version 0 diff --git a/tests/data/test1023 b/tests/data/test1023 index 40fb11f81ed2..6e55d235e82d 100644 --- a/tests/data/test1023 +++ b/tests/data/test1023 @@ -25,7 +25,7 @@ Compare curl --version with curl-config --vernum # Verify data after the test has been "shot" -%SRCDIR/libtest/test1022.pl ../curl-config %LOGDIR/stdout%TESTNUMBER vernum +%PERL %SRCDIR/libtest/test1022.pl ../curl-config %LOGDIR/stdout%TESTNUMBER vernum 0 From fdf9937cef62755f67e7d622d6fdd296eb542009 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Sun, 30 Nov 2025 12:34:02 +0100 Subject: [PATCH 129/415] rtmp: stop redefining `setsockopt` system symbol on Windows Before this patch it added Windows-specific casts. In unity builds this also affected other source files. `setsockopt()` is called without special casts in other places in the code, and passing a non-const char ptr to a const char ptr arg also should work. Basic compile test with mingw-w64 confirms. In case of issues, a cast to `curl_socklen_t` can be used, or do the special case in an `#if` branch. Also: merge Windows-specific guards for `SET_RCVTIMEO()`. Follow-up to 639d052e4499c663a578d940713e40cd466268fa #3155 Follow-up to 04cb15ae9dc0e863487ee55de2226cf5033311c0 Closes #19768 --- lib/curl_rtmp.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/curl_rtmp.c b/lib/curl_rtmp.c index b2dd937008a5..6f9e7c37b4b8 100644 --- a/lib/curl_rtmp.c +++ b/lib/curl_rtmp.c @@ -37,10 +37,7 @@ #include #include -#if defined(_WIN32) && !defined(USE_LWIPSOCK) -#define setsockopt(a,b,c,d,e) (setsockopt)(a,b,c,(const char *)d,(int)e) -#define SET_RCVTIMEO(tv,s) int tv = s*1000 -#elif defined(LWIP_SO_SNDRCVTIMEO_NONSTANDARD) +#if defined(USE_WINSOCK) || defined(LWIP_SO_SNDRCVTIMEO_NONSTANDARD) #define SET_RCVTIMEO(tv,s) int tv = s*1000 #else #define SET_RCVTIMEO(tv,s) struct timeval tv = {s,0} From 003689c3d37510f7073d203ed94c882c19653fac Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Sun, 30 Nov 2025 12:52:46 +0100 Subject: [PATCH 130/415] cf-socket: drop feature check for `IPV6_V6ONLY` on Windows The macro is present in all supported Windows toolchains. It's present in mingw-w64 v3+, and in MS SDK 6.0A+ (maybe earlier). Also: - restrict this logic to `USE_WINSOCK` (was: `_WIN32`), to exclude alternate socket libraries (i.e. lwIP). lwIP supports `IPV6_V6ONLY` since its 2.0.0 (2016-11-10) release and it's disabled by default, unlike in Winsock. Ref: https://github.com/lwip-tcpip/lwip/commit/e65202f8257e55b09e6309b1aa405b5e6a017f0d - delete interim setter function/dummy macro `set_ipv6_v6only()`. Follow-up to a28f5f68b965119d9dd1ab6c2a2ccc66c6ed5d1f #18010 Follow-up to ca3f6decb927a4c3eb4c10fba09848b626a526d6 #10975 Closes #19769 --- lib/cf-socket.c | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/lib/cf-socket.c b/lib/cf-socket.c index a12995941610..0e431976c915 100644 --- a/lib/cf-socket.c +++ b/lib/cf-socket.c @@ -83,22 +83,6 @@ #include "curlx/strparse.h" -#if defined(USE_IPV6) && defined(IPV6_V6ONLY) && defined(_WIN32) -/* It makes support for IPv4-mapped IPv6 addresses. - * Linux kernel, NetBSD, FreeBSD and Darwin: default is off; - * Windows Vista and later: default is on; - * DragonFly BSD: acts like off, and dummy setting; - * OpenBSD and earlier Windows: unsupported. - * Linux: controlled by /proc/sys/net/ipv6/bindv6only. - */ -static void set_ipv6_v6only(curl_socket_t sockfd, int on) -{ - (void)setsockopt(sockfd, IPPROTO_IPV6, IPV6_V6ONLY, (void *)&on, sizeof(on)); -} -#else -#define set_ipv6_v6only(x, y) -#endif - static void tcpnodelay(struct Curl_cfilter *cf, struct Curl_easy *data, curl_socket_t sockfd) @@ -1114,7 +1098,18 @@ static CURLcode cf_socket_open(struct Curl_cfilter *cf, #ifdef USE_IPV6 if(ctx->addr.family == AF_INET6) { - set_ipv6_v6only(ctx->sock, 0); +#ifdef USE_WINSOCK + /* Turn on support for IPv4-mapped IPv6 addresses. + * Linux kernel, NetBSD, FreeBSD, Darwin, lwIP: default is off; + * Windows Vista and later: default is on; + * DragonFly BSD: acts like off, and dummy setting; + * OpenBSD and earlier Windows: unsupported. + * Linux: controlled by /proc/sys/net/ipv6/bindv6only. + */ + int on = 0; + (void)setsockopt(ctx->sock, IPPROTO_IPV6, IPV6_V6ONLY, + (void *)&on, sizeof(on)); +#endif infof(data, " Trying [%s]:%d...", ctx->ip.remote_ip, ctx->ip.remote_port); } else From 815bf7664999cb733438c9dd54bbbd8f1737679e Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Sun, 30 Nov 2025 17:16:03 +0100 Subject: [PATCH 131/415] autotools: delete idle `AM_CFLAGS`, `AM_LDFLAGS` variables Closes #19771 --- lib/Makefile.am | 9 +++------ src/Makefile.am | 3 +-- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/Makefile.am b/lib/Makefile.am index 784b7f35d61e..2645872ebf77 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -63,8 +63,6 @@ AM_CPPFLAGS = -I$(top_srcdir)/include \ # Prevent LIBS from being used for all link targets LIBS = $(BLANK_AT_MAKETIME) -AM_LDFLAGS = -AM_CFLAGS = if DEBUGBUILD AM_CPPFLAGS += -DDEBUGBUILD endif @@ -136,12 +134,11 @@ libcurl_la_CFLAGS_EXTRA += $(CFLAG_CURL_SYMBOL_HIDING) endif 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) +libcurl_la_LDFLAGS = $(libcurl_la_LDFLAGS_EXTRA) $(CURL_LDFLAGS_LIB) $(LIBCURL_PC_LIBS_PRIVATE) +libcurl_la_CFLAGS = $(libcurl_la_CFLAGS_EXTRA) libcurlu_la_CPPFLAGS = $(AM_CPPFLAGS) -DCURL_STATICLIB -DUNITTESTS -libcurlu_la_LDFLAGS = $(AM_LDFLAGS) -static $(LIBCURL_PC_LIBS_PRIVATE) -libcurlu_la_CFLAGS = $(AM_CFLAGS) +libcurlu_la_LDFLAGS = -static $(LIBCURL_PC_LIBS_PRIVATE) CHECKSRC = $(CS_$(V)) CS_0 = @echo " RUN " $@; diff --git a/src/Makefile.am b/src/Makefile.am index c1bcf273597e..169a64f71391 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -61,7 +61,6 @@ if CURLDEBUG AM_CPPFLAGS += -DCURLDEBUG endif -AM_LDFLAGS = if USE_UNICODE UNICODEFLAG = -municode endif @@ -94,7 +93,7 @@ curl_SOURCES += $(CURL_RCFILES) $(CURL_RCFILES): tool_version.h endif -curl_LDFLAGS = $(AM_LDFLAGS) $(CURL_LDFLAGS_BIN) $(UNICODEFLAG) +curl_LDFLAGS = $(CURL_LDFLAGS_BIN) $(UNICODEFLAG) # This might hold -Werror CFLAGS += @CURL_CFLAG_EXTRAS@ From 4e8d5da7eeaa83c9d2e5cc62fb92231cf75d3c94 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Sun, 30 Nov 2025 17:31:24 +0100 Subject: [PATCH 132/415] vtls: drop interim ECH feature macros (OpenSSL, wolfSSL) Use the macros set by autotools and cmake, to simplify. Closes #19772 --- lib/vtls/openssl.c | 24 ++++++++++-------------- lib/vtls/wolfssl.c | 12 ++++-------- 2 files changed, 14 insertions(+), 22 deletions(-) diff --git a/lib/vtls/openssl.c b/lib/vtls/openssl.c index a958698b5836..67466e6e41d5 100644 --- a/lib/vtls/openssl.c +++ b/lib/vtls/openssl.c @@ -86,11 +86,7 @@ #include #include -#ifdef HAVE_SSL_SET1_ECH_CONFIG_LIST -#define USE_ECH_OPENSSL -#endif - -#if defined(USE_ECH_OPENSSL) && !defined(HAVE_BORINGSSL_LIKE) +#if defined(HAVE_SSL_SET1_ECH_CONFIG_LIST) && !defined(HAVE_BORINGSSL_LIKE) #include #endif @@ -3447,7 +3443,7 @@ ossl_init_session_and_alpns(struct ossl_ctx *octx, return CURLE_OK; } -#ifdef USE_ECH_OPENSSL +#ifdef HAVE_SSL_SET1_ECH_CONFIG_LIST static CURLcode ossl_init_ech(struct ossl_ctx *octx, struct Curl_cfilter *cf, struct Curl_easy *data, @@ -3576,7 +3572,7 @@ static CURLcode ossl_init_ech(struct ossl_ctx *octx, return CURLE_OK; } -#endif /* USE_ECH_OPENSSL */ +#endif /* HAVE_SSL_SET1_ECH_CONFIG_LIST */ static CURLcode ossl_init_ssl(struct ossl_ctx *octx, struct Curl_cfilter *cf, @@ -3611,13 +3607,13 @@ static CURLcode ossl_init_ssl(struct ossl_ctx *octx, } } -#ifdef USE_ECH_OPENSSL +#ifdef HAVE_SSL_SET1_ECH_CONFIG_LIST { CURLcode result = ossl_init_ech(octx, cf, data, peer); if(result) return result; } -#endif /* USE_ECH_OPENSSL */ +#endif /* HAVE_SSL_SET1_ECH_CONFIG_LIST */ return ossl_init_session_and_alpns(octx, cf, data, peer, alpns_requested, sess_reuse_cb); @@ -4091,7 +4087,7 @@ static CURLcode ossl_connect_step1(struct Curl_cfilter *cf, return CURLE_OK; } -#ifdef USE_ECH_OPENSSL +#ifdef HAVE_SSL_SET1_ECH_CONFIG_LIST /* If we have retry configs, then trace those out */ static void ossl_trace_ech_retry_configs(struct Curl_easy *data, SSL *ssl, int reason) @@ -4262,7 +4258,7 @@ static CURLcode ossl_connect_step2(struct Curl_cfilter *cf, ossl_strerror(errdetail, error_buffer, sizeof(error_buffer))); } #endif -#ifdef USE_ECH_OPENSSL +#ifdef HAVE_SSL_SET1_ECH_CONFIG_LIST else if((lib == ERR_LIB_SSL) && # ifndef HAVE_BORINGSSL_LIKE (reason == SSL_R_ECH_REQUIRED)) { @@ -4309,7 +4305,7 @@ static CURLcode ossl_connect_step2(struct Curl_cfilter *cf, connssl->connecting_state = ssl_connect_3; Curl_ossl_report_handshake(data, octx); -#if defined(USE_ECH_OPENSSL) && !defined(HAVE_BORINGSSL_LIKE) +#if defined(HAVE_SSL_SET1_ECH_CONFIG_LIST) && !defined(HAVE_BORINGSSL_LIKE) if(ECH_ENABLED(data)) { char *inner = NULL, *outer = NULL; const char *status = NULL; @@ -4367,7 +4363,7 @@ static CURLcode ossl_connect_step2(struct Curl_cfilter *cf, else { infof(data, "ECH: result: status is not attempted"); } -#endif /* USE_ECH_OPENSSL && !HAVE_BORINGSSL_LIKE */ +#endif /* HAVE_SSL_SET1_ECH_CONFIG_LIST && !HAVE_BORINGSSL_LIKE */ #ifdef HAS_ALPN_OPENSSL /* Sets data and len to negotiated protocol, len is 0 if no protocol was @@ -5435,7 +5431,7 @@ const struct Curl_ssl Curl_ssl_openssl = { #ifdef HAVE_SSL_CTX_SET1_SIGALGS SSLSUPP_SIGNATURE_ALGORITHMS | #endif -#ifdef USE_ECH_OPENSSL +#ifdef HAVE_SSL_SET1_ECH_CONFIG_LIST SSLSUPP_ECH | #endif SSLSUPP_CA_CACHE | diff --git a/lib/vtls/wolfssl.c b/lib/vtls/wolfssl.c index 62bf723efd33..cfefeb9320c7 100644 --- a/lib/vtls/wolfssl.c +++ b/lib/vtls/wolfssl.c @@ -75,10 +75,6 @@ #include #include "wolfssl.h" -#ifdef HAVE_WOLFSSL_CTX_GENERATEECHCONFIG -#define USE_ECH_WOLFSSL -#endif - /* KEEP_PEER_CERT is a product of the presence of build time symbol OPENSSL_EXTRA without NO_CERTS, depending on the version. KEEP_PEER_CERT is in wolfSSL's settings.h, and the latter two are build time symbols in @@ -1364,7 +1360,7 @@ CURLcode Curl_wssl_ctx_init(struct wssl_ctx *wctx, } #endif /* HAVE_SECURE_RENEGOTIATION */ -#ifdef USE_ECH_WOLFSSL +#ifdef HAVE_WOLFSSL_CTX_GENERATEECHCONFIG if(ECH_ENABLED(data)) { int trying_ech_now = 0; @@ -1449,7 +1445,7 @@ CURLcode Curl_wssl_ctx_init(struct wssl_ctx *wctx, } } -#endif /* USE_ECH_WOLFSSL */ +#endif /* HAVE_WOLFSSL_CTX_GENERATEECHCONFIG */ result = CURLE_OK; @@ -1786,7 +1782,7 @@ static CURLcode wssl_handshake(struct Curl_cfilter *cf, struct Curl_easy *data) return wssl->io_result; } } -#ifdef USE_ECH_WOLFSSL +#ifdef HAVE_WOLFSSL_CTX_GENERATEECHCONFIG else if(detail == -1) { /* try access a retry_config ECHConfigList for tracing */ byte echConfigs[1000]; @@ -2282,7 +2278,7 @@ const struct Curl_ssl Curl_ssl_wolfssl = { #endif SSLSUPP_CA_PATH | SSLSUPP_CAINFO_BLOB | -#ifdef USE_ECH_WOLFSSL +#ifdef HAVE_WOLFSSL_CTX_GENERATEECHCONFIG SSLSUPP_ECH | #endif SSLSUPP_SSL_CTX | From f553bff6ee719cf04402b28305e911458b5b6d36 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Sun, 30 Nov 2025 23:27:06 +0100 Subject: [PATCH 133/415] cmakelint: also lint CMake `.in` files, fix a long line ``` CMakeConfigurableFile.in cmake_uninstall.cmake.in curl-config.cmake.in ``` Follow-up to 16f073ef49f94412000218c9f6ad04e3fd7e4d01 #16973 Closes #19773 --- CMake/curl-config.cmake.in | 3 ++- scripts/cmakelint.sh | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CMake/curl-config.cmake.in b/CMake/curl-config.cmake.in index c4e9f59e863b..33d540da27c8 100644 --- a/CMake/curl-config.cmake.in +++ b/CMake/curl-config.cmake.in @@ -23,7 +23,8 @@ ########################################################################### @PACKAGE_INIT@ -option(CURL_USE_PKGCONFIG "Enable pkg-config to detect @PROJECT_NAME@ dependencies. Default: @CURL_USE_PKGCONFIG@" "@CURL_USE_PKGCONFIG@") +option(CURL_USE_PKGCONFIG "Enable pkg-config to detect @PROJECT_NAME@ dependencies. Default: @CURL_USE_PKGCONFIG@" + "@CURL_USE_PKGCONFIG@") include(CMakeFindDependencyMacro) diff --git a/scripts/cmakelint.sh b/scripts/cmakelint.sh index 325a07b5e6cb..1e1cc592ed3f 100755 --- a/scripts/cmakelint.sh +++ b/scripts/cmakelint.sh @@ -52,7 +52,7 @@ cd "$(dirname "$0")"/.. # strip off the leading ./ to make the grep regexes work properly find . -type f | sed 's@^\./@@' fi -} | grep -E '(^CMake|/CMake|\.cmake$)' | grep -v -E '(\.h\.cmake|\.in|\.c)$' \ +} | grep -E '(^CMake|/CMake|\.cmake$)' | grep -v -E '(\.h\.cmake|\.c)$' \ | xargs \ cmake-lint \ --suppress-decorations \ From 7799d15eef302cdc3fdbbe1dec5c43df2048ec9e Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Mon, 1 Dec 2025 00:34:33 +0100 Subject: [PATCH 134/415] cmake: fix `ws2_32` reference in `curl-config.cmake` Follow-up to 16f073ef49f94412000218c9f6ad04e3fd7e4d01 #16973 Follow-up to 554dfa556886c3d7425f6690f3fc408128bf4744 #17927 Closes #19775 --- CMake/curl-config.cmake.in | 2 +- CMakeLists.txt | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/CMake/curl-config.cmake.in b/CMake/curl-config.cmake.in index 33d540da27c8..525f2d3dbeb3 100644 --- a/CMake/curl-config.cmake.in +++ b/CMake/curl-config.cmake.in @@ -133,7 +133,7 @@ set(CMAKE_MODULE_PATH ${_curl_cmake_module_path_save}) if(CMAKE_C_COMPILER_ID STREQUAL "GNU" AND WIN32 AND NOT TARGET CURL::win32_winsock) add_library(CURL::win32_winsock INTERFACE IMPORTED) - set_target_properties(CURL::win32_winsock PROPERTIES INTERFACE_LINK_LIBRARIES "@_win32_winsock@") + set_target_properties(CURL::win32_winsock PROPERTIES INTERFACE_LINK_LIBRARIES "ws2_32") endif() include("${CMAKE_CURRENT_LIST_DIR}/@TARGETS_EXPORT_NAME@.cmake") diff --git a/CMakeLists.txt b/CMakeLists.txt index 2af1679c993f..5bcf0b6a631a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2340,7 +2340,6 @@ if(NOT CURL_DISABLE_INSTALL) # USE_RUSTLS # USE_WIN32_LDAP CURL_DISABLE_LDAP # USE_WOLFSSL - # _win32_winsock configure_package_config_file("CMake/curl-config.cmake.in" "${_project_config}" INSTALL_DESTINATION ${_install_cmake_dir} From bf58ca6e8f5f518c1f4b4acab03acb1b60e25c00 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Mon, 1 Dec 2025 01:17:41 +0100 Subject: [PATCH 135/415] cmake: narrow scope of custom `CMAKE_MODULE_PATH` in `curl-config.cmake` Set it only while using local Find modules, leave it as-is while using system ones. Follow-up to 16f073ef49f94412000218c9f6ad04e3fd7e4d01 #16973 Cherry-picked from #19776 --- CMake/curl-config.cmake.in | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/CMake/curl-config.cmake.in b/CMake/curl-config.cmake.in index 525f2d3dbeb3..97c60d3a8d4d 100644 --- a/CMake/curl-config.cmake.in +++ b/CMake/curl-config.cmake.in @@ -28,10 +28,6 @@ option(CURL_USE_PKGCONFIG "Enable pkg-config to detect @PROJECT_NAME@ dependenci include(CMakeFindDependencyMacro) -set(_curl_cmake_module_path_save ${CMAKE_MODULE_PATH}) -set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR} ${CMAKE_MODULE_PATH}) - -set(_libs "") if("@USE_OPENSSL@") if("@OPENSSL_VERSION_MAJOR@") find_dependency(OpenSSL "@OPENSSL_VERSION_MAJOR@") @@ -42,6 +38,12 @@ endif() if("@HAVE_LIBZ@") find_dependency(ZLIB "@ZLIB_VERSION_MAJOR@") endif() + +set(_curl_cmake_module_path_save ${CMAKE_MODULE_PATH}) +set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR} ${CMAKE_MODULE_PATH}) + +set(_libs "") + if("@HAVE_BROTLI@") find_dependency(Brotli) list(APPEND _libs CURL::brotli) From 41931f1659f485ba60cfb4da0b4479bfb0fd8a8e Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sun, 30 Nov 2025 23:35:25 +0100 Subject: [PATCH 136/415] imap: make sure Curl_pgrsSetDownloadSize() does not overflow Follow-up to c1e3a760b. The previous update missed an addition that also can wrap and cause confusion. Fixing this by calling Curl_pgrsSetDownloadSize() after the overflow check. Reported-by: Deniz Parlak Closes #19774 --- lib/imap.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/imap.c b/lib/imap.c index d093e46d33ab..9d58bec4ec81 100644 --- a/lib/imap.c +++ b/lib/imap.c @@ -1214,8 +1214,6 @@ static CURLcode imap_state_listsearch_resp(struct Curl_easy *data, /* This is a literal response, setup to receive the body data */ infof(data, "Found %" FMT_OFF_T " bytes to download", size); - /* Progress size includes both header line and literal body */ - Curl_pgrsSetDownloadSize(data, size + len); /* First write the header line */ result = Curl_client_write(data, CLIENTWRITE_BODY, line, len); @@ -1268,6 +1266,9 @@ static CURLcode imap_state_listsearch_resp(struct Curl_easy *data, else size += len; + /* Progress size includes both header line and literal body */ + Curl_pgrsSetDownloadSize(data, size); + if(data->req.bytecount == size) /* All data already transferred (header + literal body) */ Curl_xfer_setup_nop(data); From cffc91284475e78a7d9b0538b9db329fe3249f63 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 1 Dec 2025 09:26:28 +0100 Subject: [PATCH 137/415] url: fix return code for OOM in parse_proxy() Closes #19779 --- lib/url.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/url.c b/lib/url.c index b4c33236cd67..84909f037238 100644 --- a/lib/url.c +++ b/lib/url.c @@ -2250,11 +2250,15 @@ static CURLcode parse_proxy(struct Curl_easy *data, /* Is there a username and password given in this proxy url? */ uc = curl_url_get(uhp, CURLUPART_USER, &proxyuser, CURLU_URLDECODE); - if(uc && (uc != CURLUE_NO_USER)) + if(uc && (uc != CURLUE_NO_USER)) { + result = Curl_uc_to_curlcode(uc); goto error; + } uc = curl_url_get(uhp, CURLUPART_PASSWORD, &proxypasswd, CURLU_URLDECODE); - if(uc && (uc != CURLUE_NO_PASSWORD)) + if(uc && (uc != CURLUE_NO_PASSWORD)) { + result = Curl_uc_to_curlcode(uc); goto error; + } if(proxyuser || proxypasswd) { curlx_free(proxyinfo->user); From 729316a9e4aed66c3ca90435e2c7f4052dac32f9 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 1 Dec 2025 10:24:32 +0100 Subject: [PATCH 138/415] http: handle oom error from Curl_input_digest() Closes #19780 --- lib/http.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/http.c b/lib/http.c index f09d96ee0607..5e2b8f9ac013 100644 --- a/lib/http.c +++ b/lib/http.c @@ -976,6 +976,8 @@ static CURLcode auth_digest(struct Curl_easy *data, * Digest */ result = Curl_input_digest(data, proxy, auth); if(result) { + if(result == CURLE_OUT_OF_MEMORY) + return result; infof(data, "Digest authentication problem, ignoring."); data->state.authproblem = TRUE; } From dabfae84f0f2626974c109c979a21bcaad357450 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Mon, 1 Dec 2025 01:53:25 +0100 Subject: [PATCH 139/415] cmake: namespace all local variables in `curl-config.cmake` Also: - apply it to the local copy of this code in `lib/CMakeLists.txt`. - replace 'CURL' with `@PROJECT_NAME@` in a message. Closes #19777 --- CMake/curl-config.cmake.in | 86 +++++++++++++++++++------------------- lib/CMakeLists.txt | 16 +++---- 2 files changed, 51 insertions(+), 51 deletions(-) diff --git a/CMake/curl-config.cmake.in b/CMake/curl-config.cmake.in index 97c60d3a8d4d..7ae026d8f8c6 100644 --- a/CMake/curl-config.cmake.in +++ b/CMake/curl-config.cmake.in @@ -42,93 +42,93 @@ endif() set(_curl_cmake_module_path_save ${CMAKE_MODULE_PATH}) set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR} ${CMAKE_MODULE_PATH}) -set(_libs "") +set(_curl_libs "") if("@HAVE_BROTLI@") find_dependency(Brotli) - list(APPEND _libs CURL::brotli) + list(APPEND _curl_libs CURL::brotli) endif() if("@USE_ARES@") find_dependency(Cares) - list(APPEND _libs CURL::cares) + list(APPEND _curl_libs CURL::cares) endif() if("@HAVE_GSSAPI@") find_dependency(GSS) - list(APPEND _libs CURL::gss) + list(APPEND _curl_libs CURL::gss) endif() if("@USE_BACKTRACE@") find_dependency(Libbacktrace) - list(APPEND _libs CURL::libbacktrace) + list(APPEND _curl_libs CURL::libbacktrace) endif() if("@USE_GSASL@") find_dependency(Libgsasl) - list(APPEND _libs CURL::libgsasl) + list(APPEND _curl_libs CURL::libgsasl) endif() if(NOT "@USE_WIN32_LDAP@" AND NOT "@CURL_DISABLE_LDAP@") find_dependency(LDAP) - list(APPEND _libs CURL::ldap) + list(APPEND _curl_libs CURL::ldap) endif() if("@HAVE_LIBIDN2@") find_dependency(Libidn2) - list(APPEND _libs CURL::libidn2) + list(APPEND _curl_libs CURL::libidn2) endif() if("@USE_LIBPSL@") find_dependency(Libpsl) - list(APPEND _libs CURL::libpsl) + list(APPEND _curl_libs CURL::libpsl) endif() if("@USE_LIBRTMP@") find_dependency(Librtmp) - list(APPEND _libs CURL::librtmp) + list(APPEND _curl_libs CURL::librtmp) endif() if("@USE_LIBSSH@") find_dependency(Libssh) - list(APPEND _libs CURL::libssh) + list(APPEND _curl_libs CURL::libssh) endif() if("@USE_LIBSSH2@") find_dependency(Libssh2) - list(APPEND _libs CURL::libssh2) + list(APPEND _curl_libs CURL::libssh2) endif() if("@USE_LIBUV@") find_dependency(Libuv) - list(APPEND _libs CURL::libuv) + list(APPEND _curl_libs CURL::libuv) endif() if("@USE_MBEDTLS@") find_dependency(MbedTLS) - list(APPEND _libs CURL::mbedtls) + list(APPEND _curl_libs CURL::mbedtls) endif() if("@USE_NGHTTP2@") find_dependency(NGHTTP2) - list(APPEND _libs CURL::nghttp2) + list(APPEND _curl_libs CURL::nghttp2) endif() if("@USE_NGHTTP3@") find_dependency(NGHTTP3) - list(APPEND _libs CURL::nghttp3) + list(APPEND _curl_libs CURL::nghttp3) endif() if("@USE_NGTCP2@") find_dependency(NGTCP2) - list(APPEND _libs CURL::ngtcp2) + list(APPEND _curl_libs CURL::ngtcp2) endif() if("@USE_GNUTLS@") find_dependency(GnuTLS) - list(APPEND _libs CURL::gnutls) + list(APPEND _curl_libs CURL::gnutls) find_dependency(Nettle) - list(APPEND _libs CURL::nettle) + list(APPEND _curl_libs CURL::nettle) endif() if("@USE_QUICHE@") find_dependency(Quiche) - list(APPEND _libs CURL::quiche) + list(APPEND _curl_libs CURL::quiche) endif() if("@USE_RUSTLS@") find_dependency(Rustls) - list(APPEND _libs CURL::rustls) + list(APPEND _curl_libs CURL::rustls) endif() if("@USE_WOLFSSL@") find_dependency(WolfSSL) - list(APPEND _libs CURL::wolfssl) + list(APPEND _curl_libs CURL::wolfssl) endif() if("@HAVE_ZSTD@") find_dependency(Zstd) - list(APPEND _libs CURL::zstd) + list(APPEND _curl_libs CURL::zstd) endif() set(CMAKE_MODULE_PATH ${_curl_cmake_module_path_save}) @@ -155,16 +155,16 @@ if(TARGET @PROJECT_NAME@::@LIB_STATIC@) if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.17) cmake_policy(GET CMP0099 _has_CMP0099) # https://cmake.org/cmake/help/latest/policy/CMP0099.html endif() - if(NOT _has_CMP0099 AND CMAKE_VERSION VERSION_GREATER_EQUAL 3.13 AND _libs) - set(_libdirs "") - foreach(_lib IN LISTS _libs) - get_target_property(_libdir "${_lib}" INTERFACE_LINK_DIRECTORIES) - if(_libdir) - list(APPEND _libdirs "${_libdir}") + if(NOT _has_CMP0099 AND CMAKE_VERSION VERSION_GREATER_EQUAL 3.13 AND _curl_libs) + set(_curl_libdirs "") + foreach(_curl_lib IN LISTS _curl_libs) + get_target_property(_curl_libdir "${_curl_lib}" INTERFACE_LINK_DIRECTORIES) + if(_curl_libdir) + list(APPEND _curl_libdirs "${_curl_libdir}") endif() endforeach() - if(_libdirs) - target_link_directories(@PROJECT_NAME@::@LIB_STATIC@ INTERFACE ${_libdirs}) + if(_curl_libdirs) + target_link_directories(@PROJECT_NAME@::@LIB_STATIC@ INTERFACE ${_curl_libdirs}) endif() endif() endif() @@ -178,25 +178,25 @@ set_and_check(CURL_INCLUDE_DIRS "@PACKAGE_CMAKE_INSTALL_INCLUDEDIR@") set(CURL_SUPPORTED_PROTOCOLS "@CURL_SUPPORTED_PROTOCOLS_LIST@") set(CURL_SUPPORTED_FEATURES "@CURL_SUPPORTED_FEATURES_LIST@") -foreach(_item IN LISTS CURL_SUPPORTED_PROTOCOLS CURL_SUPPORTED_FEATURES) - set(CURL_SUPPORTS_${_item} TRUE) +foreach(_curl_item IN LISTS CURL_SUPPORTED_PROTOCOLS CURL_SUPPORTED_FEATURES) + set(CURL_SUPPORTS_${_curl_item} TRUE) endforeach() -set(_missing_req "") -foreach(_item IN LISTS CURL_FIND_COMPONENTS) - if(CURL_SUPPORTS_${_item}) - set(CURL_${_item}_FOUND TRUE) - elseif(CURL_FIND_REQUIRED_${_item}) - list(APPEND _missing_req ${_item}) +set(_curl_missing_req "") +foreach(_curl_item IN LISTS CURL_FIND_COMPONENTS) + if(CURL_SUPPORTS_${_curl_item}) + set(CURL_${_curl_item}_FOUND TRUE) + elseif(CURL_FIND_REQUIRED_${_curl_item}) + list(APPEND _curl_missing_req ${_curl_item}) endif() endforeach() -if(_missing_req) - string(REPLACE ";" " " _missing_req "${_missing_req}") +if(_curl_missing_req) + string(REPLACE ";" " " _curl_missing_req "${_curl_missing_req}") if(CURL_FIND_REQUIRED) - message(FATAL_ERROR "CURL: missing required components: ${_missing_req}") + message(FATAL_ERROR "@PROJECT_NAME@: missing required components: ${_curl_missing_req}") endif() - unset(_missing_req) + unset(_curl_missing_req) endif() check_required_components("@PROJECT_NAME@") diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 5ce288a0a897..b9b175a24d06 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -181,17 +181,17 @@ if(BUILD_STATIC_LIBS) cmake_policy(GET CMP0099 _has_CMP0099) # https://cmake.org/cmake/help/latest/policy/CMP0099.html endif() if(NOT _has_CMP0099 AND CMAKE_VERSION VERSION_GREATER_EQUAL 3.13 AND CURL_LIBS) - set(_libdirs "") - foreach(_lib IN LISTS CURL_LIBS) - if(TARGET "${_lib}") - get_target_property(_libdir "${_lib}" INTERFACE_LINK_DIRECTORIES) - if(_libdir) - list(APPEND _libdirs "${_libdir}") + set(_curl_libdirs "") + foreach(_curl_lib IN LISTS CURL_LIBS) + if(TARGET "${_curl_lib}") + get_target_property(_curl_libdir "${_curl_lib}" INTERFACE_LINK_DIRECTORIES) + if(_curl_libdir) + list(APPEND _curl_libdirs "${_curl_libdir}") endif() endif() endforeach() - if(_libdirs) - target_link_directories(${LIB_STATIC} INTERFACE ${_libdirs}) + if(_curl_libdirs) + target_link_directories(${LIB_STATIC} INTERFACE ${_curl_libdirs}) endif() endif() endif() From 4aed2dcc897b383b8bb9ae3bf2d7a2246ebccfcd Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Sat, 29 Nov 2025 15:23:58 +0100 Subject: [PATCH 140/415] krb5: fix detecting channel binding feature MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use the already detected `gssapi/gssapi_krb5.h` MIT Kerberos header to pull in `gssapi_ext.h`, which in turn sets `GSS_C_CHANNEL_BOUND_FLAG` if supported. Channel binding is present in MIT Kerberos 1.19+. Also: - lib: de-duplicate GSS-API header includes. - vauth: de-duplicate `urldata.h` includes. - drop interim feature macro in favor of the native GSS one. Assisted-by: Max Faxälv Reported-by: Max Faxälv Bug: https://github.com/curl/curl/pull/19164#issuecomment-3551687025 Follow-up to 8616e5aada9c78fb611c60d913c999c8e78c14ba #19164 Closes #19603 Closes #19760 --- lib/curl_gssapi.h | 5 ----- lib/http_negotiate.c | 6 +++--- lib/urldata.h | 11 +++++------ lib/vauth/cleartext.c | 1 - lib/vauth/cram.c | 1 - lib/vauth/digest.c | 1 - lib/vauth/digest_sspi.c | 1 - lib/vauth/gsasl.c | 1 - lib/vauth/krb5_gssapi.c | 1 - lib/vauth/krb5_sspi.c | 1 - lib/vauth/ntlm.c | 4 +--- lib/vauth/ntlm_sspi.c | 1 - lib/vauth/oauth2.c | 1 - lib/vauth/spnego_gssapi.c | 5 ++--- lib/vauth/spnego_sspi.c | 1 - lib/vauth/vauth.c | 1 - lib/vauth/vauth.h | 15 ++------------- lib/version.c | 12 ------------ 18 files changed, 13 insertions(+), 56 deletions(-) diff --git a/lib/curl_gssapi.h b/lib/curl_gssapi.h index 1a2bbabdf516..6df7e059d325 100644 --- a/lib/curl_gssapi.h +++ b/lib/curl_gssapi.h @@ -28,11 +28,6 @@ #include "urldata.h" #ifdef HAVE_GSSAPI - -#ifdef GSS_C_CHANNEL_BOUND_FLAG /* MIT Kerberos 1.19+, missing from GNU GSS */ -#define CURL_GSSAPI_HAS_CHANNEL_BINDING -#endif - extern gss_OID_desc Curl_spnego_mech_oid; extern gss_OID_desc Curl_krb5_mech_oid; diff --git a/lib/http_negotiate.c b/lib/http_negotiate.c index fc80f80fa350..f31e59c2ca6d 100644 --- a/lib/http_negotiate.c +++ b/lib/http_negotiate.c @@ -120,7 +120,7 @@ CURLcode Curl_input_negotiate(struct Curl_easy *data, struct connectdata *conn, neg_ctx->sslContext = conn->sslContext; #endif /* Check if the connection is using SSL and get the channel binding data */ -#ifdef CURL_GSSAPI_HAS_CHANNEL_BINDING +#ifdef GSS_C_CHANNEL_BOUND_FLAG #ifdef USE_SSL curlx_dyn_init(&neg_ctx->channel_binding_data, SSL_CB_MAX_SIZE + 1); if(Curl_conn_is_ssl(conn, FIRSTSOCKET)) { @@ -134,13 +134,13 @@ CURLcode Curl_input_negotiate(struct Curl_easy *data, struct connectdata *conn, #else curlx_dyn_init(&neg_ctx->channel_binding_data, 1); #endif /* USE_SSL */ -#endif /* CURL_GSSAPI_HAS_CHANNEL_BINDING */ +#endif /* GSS_C_CHANNEL_BOUND_FLAG */ /* Initialize the security context and decode our challenge */ result = Curl_auth_decode_spnego_message(data, userp, passwdp, service, host, header, neg_ctx); -#ifdef CURL_GSSAPI_HAS_CHANNEL_BINDING +#ifdef GSS_C_CHANNEL_BOUND_FLAG curlx_dyn_free(&neg_ctx->channel_binding_data); #endif diff --git a/lib/urldata.h b/lib/urldata.h index 561db56ecd8a..1c91099d153d 100644 --- a/lib/urldata.h +++ b/lib/urldata.h @@ -191,12 +191,11 @@ typedef CURLcode (Curl_recv)(struct Curl_easy *data, /* transfer */ #ifdef HAVE_GSSAPI # ifdef HAVE_GSSGNU # include -# else -# ifdef HAVE_GSSAPI_H -# include -# else -# include -# endif +# elif defined(HAVE_GSSAPI_H) +# include +# else /* MIT Kerberos */ +# include +# include /* for GSS_C_CHANNEL_BOUND_FLAG, in 1.19+ */ # endif #endif diff --git a/lib/vauth/cleartext.c b/lib/vauth/cleartext.c index 862310111e66..c0e59fd273b9 100644 --- a/lib/vauth/cleartext.c +++ b/lib/vauth/cleartext.c @@ -32,7 +32,6 @@ (!defined(CURL_DISABLE_LDAP) && defined(USE_OPENLDAP)) #include -#include "../urldata.h" #include "vauth.h" #include "../curlx/warnless.h" diff --git a/lib/vauth/cram.c b/lib/vauth/cram.c index 9bc5544a64fa..6a39a400ee3c 100644 --- a/lib/vauth/cram.c +++ b/lib/vauth/cram.c @@ -29,7 +29,6 @@ #ifndef CURL_DISABLE_DIGEST_AUTH #include -#include "../urldata.h" #include "vauth.h" #include "../curl_hmac.h" diff --git a/lib/vauth/digest.c b/lib/vauth/digest.c index c5fea6739449..8bcfc7ed6c9c 100644 --- a/lib/vauth/digest.c +++ b/lib/vauth/digest.c @@ -33,7 +33,6 @@ #include "vauth.h" #include "digest.h" -#include "../urldata.h" #include "../curlx/base64.h" #include "../curl_hmac.h" #include "../curl_md5.h" diff --git a/lib/vauth/digest_sspi.c b/lib/vauth/digest_sspi.c index 550810acda18..fc2c1393750f 100644 --- a/lib/vauth/digest_sspi.c +++ b/lib/vauth/digest_sspi.c @@ -33,7 +33,6 @@ #include "vauth.h" #include "digest.h" -#include "../urldata.h" #include "../curlx/warnless.h" #include "../curlx/multibyte.h" #include "../sendf.h" diff --git a/lib/vauth/gsasl.c b/lib/vauth/gsasl.c index 8330a4bd7155..3888622dbffa 100644 --- a/lib/vauth/gsasl.c +++ b/lib/vauth/gsasl.c @@ -31,7 +31,6 @@ #include #include "vauth.h" -#include "../urldata.h" #include "../sendf.h" #include diff --git a/lib/vauth/krb5_gssapi.c b/lib/vauth/krb5_gssapi.c index 1590949d681a..7ba21a394184 100644 --- a/lib/vauth/krb5_gssapi.c +++ b/lib/vauth/krb5_gssapi.c @@ -33,7 +33,6 @@ #include "vauth.h" #include "../curl_sasl.h" -#include "../urldata.h" #include "../curl_gssapi.h" #include "../sendf.h" diff --git a/lib/vauth/krb5_sspi.c b/lib/vauth/krb5_sspi.c index 2f82345b98c7..7317af809ad5 100644 --- a/lib/vauth/krb5_sspi.c +++ b/lib/vauth/krb5_sspi.c @@ -31,7 +31,6 @@ #include #include "vauth.h" -#include "../urldata.h" #include "../curlx/warnless.h" #include "../curlx/multibyte.h" #include "../sendf.h" diff --git a/lib/vauth/ntlm.c b/lib/vauth/ntlm.c index e5eb1de5ef8b..e47135337acd 100644 --- a/lib/vauth/ntlm.c +++ b/lib/vauth/ntlm.c @@ -35,7 +35,7 @@ #define DEBUG_ME 0 -#include "../urldata.h" +#include "vauth.h" #include "../sendf.h" #include "../curl_ntlm_core.h" #include "../curl_gethostname.h" @@ -44,8 +44,6 @@ #include "../rand.h" #include "../vtls/vtls.h" #include "../strdup.h" - -#include "vauth.h" #include "../curl_endian.h" /* NTLM buffer fixed size, large enough for long user + host + domain */ diff --git a/lib/vauth/ntlm_sspi.c b/lib/vauth/ntlm_sspi.c index bab319671c48..561de27dc36c 100644 --- a/lib/vauth/ntlm_sspi.c +++ b/lib/vauth/ntlm_sspi.c @@ -29,7 +29,6 @@ #include #include "vauth.h" -#include "../urldata.h" #include "../curl_ntlm_core.h" #include "../curlx/warnless.h" #include "../curlx/multibyte.h" diff --git a/lib/vauth/oauth2.c b/lib/vauth/oauth2.c index 3b4d4164f094..c9122debffa9 100644 --- a/lib/vauth/oauth2.c +++ b/lib/vauth/oauth2.c @@ -31,7 +31,6 @@ (!defined(CURL_DISABLE_LDAP) && defined(USE_OPENLDAP)) #include -#include "../urldata.h" #include "vauth.h" #include "../curlx/warnless.h" diff --git a/lib/vauth/spnego_gssapi.c b/lib/vauth/spnego_gssapi.c index f956f2c03e81..3a24e8860a80 100644 --- a/lib/vauth/spnego_gssapi.c +++ b/lib/vauth/spnego_gssapi.c @@ -31,7 +31,6 @@ #include #include "vauth.h" -#include "../urldata.h" #include "../curlx/base64.h" #include "../curl_gssapi.h" #include "../curlx/warnless.h" @@ -92,7 +91,7 @@ CURLcode Curl_auth_decode_spnego_message(struct Curl_easy *data, gss_buffer_desc input_token = GSS_C_EMPTY_BUFFER; gss_buffer_desc output_token = GSS_C_EMPTY_BUFFER; gss_channel_bindings_t chan_bindings = GSS_C_NO_CHANNEL_BINDINGS; -#ifdef CURL_GSSAPI_HAS_CHANNEL_BINDING +#ifdef GSS_C_CHANNEL_BOUND_FLAG struct gss_channel_bindings_struct chan; #endif @@ -155,7 +154,7 @@ CURLcode Curl_auth_decode_spnego_message(struct Curl_easy *data, } /* Set channel binding data if available */ -#ifdef CURL_GSSAPI_HAS_CHANNEL_BINDING +#ifdef GSS_C_CHANNEL_BOUND_FLAG if(curlx_dyn_len(&nego->channel_binding_data)) { memset(&chan, 0, sizeof(struct gss_channel_bindings_struct)); chan.application_data.length = curlx_dyn_len(&nego->channel_binding_data); diff --git a/lib/vauth/spnego_sspi.c b/lib/vauth/spnego_sspi.c index 2b0504f630f8..2a6548b6d4d9 100644 --- a/lib/vauth/spnego_sspi.c +++ b/lib/vauth/spnego_sspi.c @@ -31,7 +31,6 @@ #include #include "vauth.h" -#include "../urldata.h" #include "../curlx/base64.h" #include "../curlx/warnless.h" #include "../curlx/multibyte.h" diff --git a/lib/vauth/vauth.c b/lib/vauth/vauth.c index 4ca6cef7c8fe..9b87bd2c6757 100644 --- a/lib/vauth/vauth.c +++ b/lib/vauth/vauth.c @@ -28,7 +28,6 @@ #include "vauth.h" #include "../strdup.h" -#include "../urldata.h" #include "../curlx/multibyte.h" #include "../url.h" diff --git a/lib/vauth/vauth.h b/lib/vauth/vauth.h index 51b9f41c1b04..4c98d9b1c11c 100644 --- a/lib/vauth/vauth.h +++ b/lib/vauth/vauth.h @@ -28,6 +28,7 @@ #include "../bufref.h" #include "../curlx/dynbuf.h" +#include "../urldata.h" struct Curl_easy; struct connectdata; @@ -233,18 +234,6 @@ CURLcode Curl_auth_create_xoauth_bearer_message(const char *user, #ifdef USE_KERBEROS5 -#ifdef HAVE_GSSAPI -# ifdef HAVE_GSSGNU -# include -# else -# ifdef HAVE_GSSAPI_H -# include -# else -# include -# endif -# endif -#endif - /* meta key for storing KRB5 meta at connection */ #define CURL_META_KRB5_CONN "meta:auth:krb5:conn" @@ -310,7 +299,7 @@ struct negotiatedata { gss_ctx_id_t context; gss_name_t spn; gss_buffer_desc output_token; -#ifdef CURL_GSSAPI_HAS_CHANNEL_BINDING +#ifdef GSS_C_CHANNEL_BOUND_FLAG struct dynbuf channel_binding_data; #endif #else diff --git a/lib/version.c b/lib/version.c index f02b92fedfc7..49c15ffcdec9 100644 --- a/lib/version.c +++ b/lib/version.c @@ -77,18 +77,6 @@ #include #endif -#ifdef HAVE_GSSAPI -# ifdef HAVE_GSSGNU -# include -# else -# ifdef HAVE_GSSAPI_H -# include -# else -# include -# endif -# endif -#endif - #ifdef USE_OPENLDAP #include #endif From 012fa2b91b6c1129695600bfdafc5f01f7fce76f Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 1 Dec 2025 11:04:36 +0100 Subject: [PATCH 141/415] auth: always treat Curl_auth_ntlm_get() returning NULL as OOM Closes #19782 --- lib/curl_sasl.c | 2 +- lib/http_ntlm.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/curl_sasl.c b/lib/curl_sasl.c index aef47dc0162e..f0b6e9471e5f 100644 --- a/lib/curl_sasl.c +++ b/lib/curl_sasl.c @@ -705,7 +705,7 @@ CURLcode Curl_sasl_continue(struct SASL *sasl, struct Curl_easy *data, case SASL_NTLM_TYPE2MSG: { /* Decode the type-2 message */ struct ntlmdata *ntlm = Curl_auth_ntlm_get(conn, FALSE); - result = !ntlm ? CURLE_FAILED_INIT : + result = !ntlm ? CURLE_OUT_OF_MEMORY : get_server_message(sasl, data, &serverdata); if(!result) result = Curl_auth_decode_ntlm_type2_message(data, &serverdata, ntlm); diff --git a/lib/http_ntlm.c b/lib/http_ntlm.c index 2856745c34c4..6c79bcac1b97 100644 --- a/lib/http_ntlm.c +++ b/lib/http_ntlm.c @@ -64,7 +64,7 @@ CURLcode Curl_input_ntlm(struct Curl_easy *data, if(checkprefix("NTLM", header)) { struct ntlmdata *ntlm = Curl_auth_ntlm_get(conn, proxy); if(!ntlm) - return CURLE_FAILED_INIT; + return CURLE_OUT_OF_MEMORY; header += strlen("NTLM"); curlx_str_passblanks(&header); From c6c4a99300bebdd3fd5a6af9ebca0053e3cbc8f7 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 1 Dec 2025 11:00:47 +0100 Subject: [PATCH 142/415] http: acknowledge OOM errors from Curl_input_ntlm Closes #19781 --- lib/http.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/http.c b/lib/http.c index 5e2b8f9ac013..fcae0a57c25c 100644 --- a/lib/http.c +++ b/lib/http.c @@ -946,6 +946,8 @@ static CURLcode auth_ntlm(struct Curl_easy *data, if(!result) data->state.authproblem = FALSE; else { + if(result == CURLE_OUT_OF_MEMORY) + return result; infof(data, "NTLM authentication problem, ignoring."); data->state.authproblem = TRUE; } From a7bebd8502914f1652f423eddfd7005f8413a781 Mon Sep 17 00:00:00 2001 From: Stefan Eissing Date: Mon, 1 Dec 2025 13:22:25 +0100 Subject: [PATCH 143/415] memdebug: add mutex for thread safety Protect modification to the `membuf` by different threads via a mutex. This ensure that index updates are correct and that data gets written in order. Closes #19785 --- lib/memdebug.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/lib/memdebug.c b/lib/memdebug.c index 329b11ea793b..1dda6d785cca 100644 --- a/lib/memdebug.c +++ b/lib/memdebug.c @@ -29,6 +29,7 @@ #include #include "urldata.h" +#include "curl_threads.h" #include "curlx/fopen.h" /* for CURLX_FOPEN_LOW(), CURLX_FREOPEN_LOW() */ #ifdef USE_BACKTRACE @@ -66,6 +67,11 @@ static struct backtrace_state *btstate; static char membuf[KEEPSIZE]; static size_t memwidx = 0; /* write index */ +#if defined(USE_THREADS_POSIX) || defined(USE_THREADS_WIN32) +static bool dbg_mutex_init = 0; +static curl_mutex_t dbg_mutex; +#endif + /* LeakSantizier (LSAN) calls _exit() instead of exit() when a leak is detected on exit so the logfile must be closed explicitly or data could be lost. Though _exit() does not call atexit handlers such as this, LSAN's call to @@ -81,6 +87,12 @@ static void curl_dbg_cleanup(void) fclose(curl_dbg_logfile); } curl_dbg_logfile = NULL; +#if defined(USE_THREADS_POSIX) || defined(USE_THREADS_WIN32) + if(dbg_mutex_init) { + Curl_mutex_destroy(&dbg_mutex); + dbg_mutex_init = FALSE; + } +#endif } #ifdef USE_BACKTRACE static void error_bt_callback(void *data, const char *message, @@ -123,6 +135,12 @@ void curl_dbg_memdebug(const char *logname) setbuf(curl_dbg_logfile, (char *)NULL); #endif } +#if defined(USE_THREADS_POSIX) || defined(USE_THREADS_WIN32) + if(!dbg_mutex_init) { + dbg_mutex_init = TRUE; + Curl_mutex_init(&dbg_mutex); + } +#endif #ifdef USE_BACKTRACE btstate = backtrace_create_state(NULL, 0, error_bt_callback, NULL); #endif @@ -526,6 +544,11 @@ void curl_dbg_log(const char *format, ...) nchars = (int)sizeof(buf) - 1; if(nchars > 0) { +#if defined(USE_THREADS_POSIX) || defined(USE_THREADS_WIN32) + bool lock_mutex = dbg_mutex_init; + if(lock_mutex) + Curl_mutex_acquire(&dbg_mutex); +#endif if(KEEPSIZE - nchars < memwidx) { /* flush */ fwrite(membuf, 1, memwidx, curl_dbg_logfile); @@ -538,6 +561,10 @@ void curl_dbg_log(const char *format, ...) } memcpy(&membuf[memwidx], buf, nchars); memwidx += nchars; +#if defined(USE_THREADS_POSIX) || defined(USE_THREADS_WIN32) + if(lock_mutex) + Curl_mutex_release(&dbg_mutex); +#endif } } From d1b85bc49c5dd0e2c2eaf06027b5520152317f62 Mon Sep 17 00:00:00 2001 From: Stefan Eissing Date: Mon, 1 Dec 2025 14:05:39 +0100 Subject: [PATCH 144/415] memdebug: log before free add the debug log before freeing the memory, otherwise another thread might allocate and log it before the free is logged. Follow-up to a7bebd8502914f1652f423 Closes #19787 --- lib/memdebug.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/memdebug.c b/lib/memdebug.c index 1dda6d785cca..b6c2d854c33e 100644 --- a/lib/memdebug.c +++ b/lib/memdebug.c @@ -337,6 +337,9 @@ void curl_dbg_free(void *ptr, int line, const char *source) if(ptr) { struct memdebug *mem; + if(source) + curl_dbg_log("MEM %s:%d free(%p)\n", source, line, (void *)ptr); + #ifdef __INTEL_COMPILER # pragma warning(push) # pragma warning(disable:1684) @@ -352,9 +355,6 @@ void curl_dbg_free(void *ptr, int line, const char *source) /* free for real */ (Curl_cfree)(mem); } - - if(source && ptr) - curl_dbg_log("MEM %s:%d free(%p)\n", source, line, (void *)ptr); } curl_socket_t curl_dbg_socket(int domain, int type, int protocol, From fb7033d7600dfb59de06e7af8a0d6ab2a4163578 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 1 Dec 2025 13:48:12 +0100 Subject: [PATCH 145/415] runtests: enable torture testing with threaded resolver Since a7bebd850291 made it possible. Closes #19786 --- tests/runtests.pl | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/tests/runtests.pl b/tests/runtests.pl index 648666fd301e..1bde3f3afc64 100755 --- a/tests/runtests.pl +++ b/tests/runtests.pl @@ -846,15 +846,9 @@ sub checksystemfeatures { } # 'socks' was once here but is now removed - if($torture) { - if(!$feature{"TrackMemory"}) { - die "cannot run torture tests since curl was built without ". - "TrackMemory feature (--enable-curldebug)"; - } - if($feature{"threaded-resolver"} && !$valgrind) { - die "cannot run torture tests since curl was built with the ". - "threaded resolver, and we are not running with valgrind"; - } + if($torture && !$feature{"TrackMemory"}) { + die "cannot run torture tests since curl was built without ". + "TrackMemory feature (--enable-curldebug)"; } my $hostname=join(' ', runclientoutput("hostname")); @@ -879,13 +873,6 @@ sub checksystemfeatures { # Only show if not the default for now logmsg "* Jobs: $jobs\n"; } - # Disable memory tracking when using threaded resolver - if($feature{"TrackMemory"} && $feature{"threaded-resolver"}) { - logmsg("*\n", - "*** DISABLES TrackMemory (memory tracking) when using threaded resolver\n", - "*\n"); - $feature{"TrackMemory"} = 0; - } my $env = sprintf("%s%s%s%s%s", $valgrind?"Valgrind ":"", From a2ebae61ca365a358c6d11b2ab1f0b062efa49c6 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 1 Dec 2025 13:14:17 +0100 Subject: [PATCH 146/415] tool_urlglob: acknowledge OOM in peek_ipv6 Previously, an OOM error would just imply not an IPv6 address. Closes #19784 --- src/tool_urlglob.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/tool_urlglob.c b/src/tool_urlglob.c index 9ea8a274fa0d..bfa54ab8275b 100644 --- a/src/tool_urlglob.c +++ b/src/tool_urlglob.c @@ -343,7 +343,7 @@ static CURLcode glob_range(struct URLGlob *glob, const char **patternp, #define MAX_IP6LEN 128 -static bool peek_ipv6(const char *str, size_t *skip) +static CURLcode peek_ipv6(const char *str, size_t *skip, bool *ipv6p) { /* * Scan for a potential IPv6 literal. @@ -355,27 +355,33 @@ static bool peek_ipv6(const char *str, size_t *skip) char *endbr = strchr(str, ']'); size_t hlen; CURLUcode rc; + CURLcode result = CURLE_OK; + *ipv6p = FALSE; /* default to nope */ + *skip = 0; if(!endbr) - return FALSE; + return CURLE_OK; hlen = endbr - str + 1; if(hlen >= MAX_IP6LEN) - return FALSE; + return CURLE_OK; u = curl_url(); if(!u) - return FALSE; + return CURLE_OUT_OF_MEMORY; memcpy(hostname, str, hlen); hostname[hlen] = 0; /* ask to "guess scheme" as then it works without an https:// prefix */ rc = curl_url_set(u, CURLUPART_URL, hostname, CURLU_GUESS_SCHEME); - curl_url_cleanup(u); - if(!rc) + if(rc == CURLUE_OUT_OF_MEMORY) + return CURLE_OUT_OF_MEMORY; + if(!rc) { *skip = hlen; - return rc ? FALSE : TRUE; + *ipv6p = TRUE; + } + return result; } static CURLcode add_glob(struct URLGlob *glob, size_t pos) @@ -414,7 +420,11 @@ static CURLcode glob_parse(struct URLGlob *glob, const char *pattern, if(*pattern == '[') { /* skip over IPv6 literals and [] */ size_t skip = 0; - if(!peek_ipv6(pattern, &skip) && (pattern[1] == ']')) + bool ipv6; + res = peek_ipv6(pattern, &skip, &ipv6); + if(res) + return res; + if(!ipv6 && (pattern[1] == ']')) skip = 2; if(skip) { if(curlx_dyn_addn(&glob->buf, pattern, skip)) From c421c3e3251b33e78b1c98030d92e6ad23a82d03 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Sun, 30 Nov 2025 23:22:59 +0100 Subject: [PATCH 147/415] cmake: verify minimum CMake version in `curl-config.cmake` Show a message if the CMake version is lower than that when consuming libcurl via the CMake config. The minimum CMake version on consumption is for now the same as the minimum required (v3.7) to build curl itself. Ref: https://cmake.org/cmake/help/v3.7/variable/CMAKE_MINIMUM_REQUIRED_VERSION.html Ref: #18704 (discussion) Follow-up to 16f073ef49f94412000218c9f6ad04e3fd7e4d01 #16973 Closes #19776 --- CMake/curl-config.cmake.in | 5 +++++ CMakeLists.txt | 1 + 2 files changed, 6 insertions(+) diff --git a/CMake/curl-config.cmake.in b/CMake/curl-config.cmake.in index 7ae026d8f8c6..7f346c832ca5 100644 --- a/CMake/curl-config.cmake.in +++ b/CMake/curl-config.cmake.in @@ -26,6 +26,11 @@ option(CURL_USE_PKGCONFIG "Enable pkg-config to detect @PROJECT_NAME@ dependencies. Default: @CURL_USE_PKGCONFIG@" "@CURL_USE_PKGCONFIG@") +if(CMAKE_VERSION VERSION_LESS @CMAKE_MINIMUM_REQUIRED_VERSION@) + message(STATUS "@PROJECT_NAME@: @PROJECT_NAME@-specific Find modules require " + "CMake @CMAKE_MINIMUM_REQUIRED_VERSION@ or upper, found: ${CMAKE_VERSION}.") +endif() + include(CMakeFindDependencyMacro) if("@USE_OPENSSL@") diff --git a/CMakeLists.txt b/CMakeLists.txt index 5bcf0b6a631a..b45e7859e090 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2309,6 +2309,7 @@ if(NOT CURL_DISABLE_INSTALL) ${_generated_version_config}") # Consumed custom variables: + # CMAKE_MINIMUM_REQUIRED_VERSION # CURLVERSION # LIBCURL_PC_LIBS_PRIVATE_LIST # LIB_NAME From ca1919caee6a82e400acdc491179b748f38c5ede Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Mon, 1 Dec 2025 15:52:10 +0100 Subject: [PATCH 148/415] idn: fix memory leak in `win32_ascii_to_idn()` Closes #19789 --- lib/idn.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/idn.c b/lib/idn.c index 1c404f6543f3..38f2845f260e 100644 --- a/lib/idn.c +++ b/lib/idn.c @@ -201,6 +201,7 @@ static CURLcode win32_ascii_to_idn(const char *in, char **output) WCHAR idn[IDN_MAX_LENGTH]; /* stores a UTF-16 string */ int chars = IdnToUnicode(0, in_w, (int)(wcslen(in_w) + 1), idn, IDN_MAX_LENGTH); + curlx_unicodefree(in_w); if(chars) { /* 'chars' is "the number of characters retrieved" */ char *mstr = curlx_convert_wchar_to_UTF8(idn); From 338713345046e164ddd3b2dca75d862124d34a3a Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Mon, 1 Dec 2025 16:36:25 +0100 Subject: [PATCH 149/415] lib: delete unused `curlx/multibyte.h` includes Closes #19792 --- lib/vauth/krb5_sspi.c | 1 - lib/vauth/ntlm.c | 1 - lib/vauth/ntlm_sspi.c | 1 - lib/vauth/spnego_gssapi.c | 1 - lib/vauth/spnego_sspi.c | 1 - 5 files changed, 5 deletions(-) diff --git a/lib/vauth/krb5_sspi.c b/lib/vauth/krb5_sspi.c index 7317af809ad5..21636d59ee3d 100644 --- a/lib/vauth/krb5_sspi.c +++ b/lib/vauth/krb5_sspi.c @@ -32,7 +32,6 @@ #include "vauth.h" #include "../curlx/warnless.h" -#include "../curlx/multibyte.h" #include "../sendf.h" /* diff --git a/lib/vauth/ntlm.c b/lib/vauth/ntlm.c index e47135337acd..22d028e8c2fa 100644 --- a/lib/vauth/ntlm.c +++ b/lib/vauth/ntlm.c @@ -39,7 +39,6 @@ #include "../sendf.h" #include "../curl_ntlm_core.h" #include "../curl_gethostname.h" -#include "../curlx/multibyte.h" #include "../curlx/warnless.h" #include "../rand.h" #include "../vtls/vtls.h" diff --git a/lib/vauth/ntlm_sspi.c b/lib/vauth/ntlm_sspi.c index 561de27dc36c..d724907db649 100644 --- a/lib/vauth/ntlm_sspi.c +++ b/lib/vauth/ntlm_sspi.c @@ -31,7 +31,6 @@ #include "vauth.h" #include "../curl_ntlm_core.h" #include "../curlx/warnless.h" -#include "../curlx/multibyte.h" #include "../sendf.h" #include "../strdup.h" diff --git a/lib/vauth/spnego_gssapi.c b/lib/vauth/spnego_gssapi.c index 3a24e8860a80..2feafdda4b24 100644 --- a/lib/vauth/spnego_gssapi.c +++ b/lib/vauth/spnego_gssapi.c @@ -34,7 +34,6 @@ #include "../curlx/base64.h" #include "../curl_gssapi.h" #include "../curlx/warnless.h" -#include "../curlx/multibyte.h" #include "../sendf.h" #if defined(__GNUC__) && defined(__APPLE__) diff --git a/lib/vauth/spnego_sspi.c b/lib/vauth/spnego_sspi.c index 2a6548b6d4d9..31747c0a0e72 100644 --- a/lib/vauth/spnego_sspi.c +++ b/lib/vauth/spnego_sspi.c @@ -33,7 +33,6 @@ #include "vauth.h" #include "../curlx/base64.h" #include "../curlx/warnless.h" -#include "../curlx/multibyte.h" #include "../sendf.h" #include "../strerror.h" From ccb68d2e3b602b24a8cb52f473b96938ac998db6 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Mon, 1 Dec 2025 15:49:01 +0100 Subject: [PATCH 150/415] idn: use curlx allocators on Windows Replace `curlx_convert*()` functions with local copies that always use the curlx allocator. Closes #19790 --- lib/idn.c | 81 +++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 55 insertions(+), 26 deletions(-) diff --git a/lib/idn.c b/lib/idn.c index 38f2845f260e..0b1a4a36ccc0 100644 --- a/lib/idn.c +++ b/lib/idn.c @@ -30,7 +30,6 @@ #include "urldata.h" #include "idn.h" #include "sendf.h" -#include "curlx/multibyte.h" #include "curlx/warnless.h" #ifdef USE_LIBIDN2 @@ -163,24 +162,60 @@ WINBASEAPI int WINAPI IdnToUnicode(DWORD dwFlags, #define IDN_MAX_LENGTH 255 +static wchar_t *idn_curlx_convert_UTF8_to_wchar(const char *str_utf8) +{ + wchar_t *str_w = NULL; + + if(str_utf8) { + int str_w_len = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, + str_utf8, -1, NULL, 0); + if(str_w_len > 0) { + str_w = curlx_malloc(str_w_len * sizeof(wchar_t)); + if(str_w) { + if(MultiByteToWideChar(CP_UTF8, 0, str_utf8, -1, str_w, + str_w_len) == 0) { + curlx_free(str_w); + return NULL; + } + } + } + } + return str_w; +} + +static char *idn_curlx_convert_wchar_to_UTF8(const wchar_t *str_w) +{ + char *str_utf8 = NULL; + + if(str_w) { + int bytes = WideCharToMultiByte(CP_UTF8, 0, str_w, -1, + NULL, 0, NULL, NULL); + if(bytes > 0) { + str_utf8 = curlx_malloc(bytes); + if(str_utf8) { + if(WideCharToMultiByte(CP_UTF8, 0, str_w, -1, str_utf8, bytes, + NULL, NULL) == 0) { + curlx_free(str_utf8); + return NULL; + } + } + } + } + return str_utf8; +} + static CURLcode win32_idn_to_ascii(const char *in, char **out) { - wchar_t *in_w = curlx_convert_UTF8_to_wchar(in); + wchar_t *in_w = idn_curlx_convert_UTF8_to_wchar(in); *out = NULL; if(in_w) { wchar_t punycode[IDN_MAX_LENGTH]; int chars = IdnToAscii(0, in_w, (int)(wcslen(in_w) + 1), punycode, IDN_MAX_LENGTH); - curlx_unicodefree(in_w); + curlx_free(in_w); if(chars) { - char *mstr = curlx_convert_wchar_to_UTF8(punycode); - if(mstr) { - *out = curlx_strdup(mstr); - curlx_unicodefree(mstr); - if(!*out) - return CURLE_OUT_OF_MEMORY; - } - else + *out = idn_curlx_convert_wchar_to_UTF8(punycode); + if(!*out) return CURLE_OUT_OF_MEMORY; } else @@ -192,32 +227,26 @@ static CURLcode win32_idn_to_ascii(const char *in, char **out) return CURLE_OK; } -static CURLcode win32_ascii_to_idn(const char *in, char **output) +static CURLcode win32_ascii_to_idn(const char *in, char **out) { - char *out = NULL; - - wchar_t *in_w = curlx_convert_UTF8_to_wchar(in); + wchar_t *in_w = idn_curlx_convert_UTF8_to_wchar(in); + *out = NULL; if(in_w) { WCHAR idn[IDN_MAX_LENGTH]; /* stores a UTF-16 string */ int chars = IdnToUnicode(0, in_w, (int)(wcslen(in_w) + 1), idn, IDN_MAX_LENGTH); - curlx_unicodefree(in_w); - if(chars) { - /* 'chars' is "the number of characters retrieved" */ - char *mstr = curlx_convert_wchar_to_UTF8(idn); - if(mstr) { - out = curlx_strdup(mstr); - curlx_unicodefree(mstr); - if(!out) - return CURLE_OUT_OF_MEMORY; - } + curlx_free(in_w); + if(chars) { /* 'chars' is "the number of characters retrieved" */ + *out = idn_curlx_convert_wchar_to_UTF8(idn); + if(!*out) + return CURLE_OUT_OF_MEMORY; } else return CURLE_URL_MALFORMAT; } else return CURLE_URL_MALFORMAT; - *output = out; + return CURLE_OK; } From a3fcd80de4b1fe00c8832713afadfc6ad8f391b3 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Mon, 1 Dec 2025 15:25:26 +0100 Subject: [PATCH 151/415] curlx: use curlx allocators in non-memdebug builds (Windows) To limit raw allocators to `CURLDEBUG` (memdebug/TrackMemory) Windows UNICODE builds. Closes #19788 --- lib/curlx/fopen.c | 50 +++++++++++++++---------------------------- lib/curlx/multibyte.c | 12 ++++------- lib/curlx/multibyte.h | 15 ++++++++++++- 3 files changed, 35 insertions(+), 42 deletions(-) diff --git a/lib/curlx/fopen.c b/lib/curlx/fopen.c index caf4978af163..1838b7de8b8c 100644 --- a/lib/curlx/fopen.c +++ b/lib/curlx/fopen.c @@ -100,8 +100,7 @@ static bool fix_excessive_path(const TCHAR *in, TCHAR **out) goto cleanup; if(!needed || needed >= max_path_len) goto cleanup; - /* !checksrc! disable BANNEDFUNC 1 */ - ibuf = malloc(needed * sizeof(wchar_t)); + ibuf = CURLX_MALLOC(needed * sizeof(wchar_t)); if(!ibuf) goto cleanup; if(mbstowcs_s(&count, ibuf, needed, in, needed - 1)) @@ -122,8 +121,7 @@ static bool fix_excessive_path(const TCHAR *in, TCHAR **out) /* skip paths that are not excessive and do not need modification */ if(needed <= MAX_PATH) goto cleanup; - /* !checksrc! disable BANNEDFUNC 1 */ - fbuf = malloc(needed * sizeof(wchar_t)); + fbuf = CURLX_MALLOC(needed * sizeof(wchar_t)); if(!fbuf) goto cleanup; count = (size_t)GetFullPathNameW(in_w, (DWORD)needed, fbuf, NULL); @@ -156,19 +154,16 @@ static bool fix_excessive_path(const TCHAR *in, TCHAR **out) if(needed > max_path_len) goto cleanup; - /* !checksrc! disable BANNEDFUNC 1 */ - temp = malloc(needed * sizeof(wchar_t)); + temp = CURLX_MALLOC(needed * sizeof(wchar_t)); if(!temp) goto cleanup; if(wcsncpy_s(temp, needed, L"\\\\?\\UNC\\", 8)) { - /* !checksrc! disable BANNEDFUNC 1 */ - free(temp); + CURLX_FREE(temp); goto cleanup; } if(wcscpy_s(temp + 8, needed, fbuf + 2)) { - /* !checksrc! disable BANNEDFUNC 1 */ - free(temp); + CURLX_FREE(temp); goto cleanup; } } @@ -178,25 +173,21 @@ static bool fix_excessive_path(const TCHAR *in, TCHAR **out) if(needed > max_path_len) goto cleanup; - /* !checksrc! disable BANNEDFUNC 1 */ - temp = malloc(needed * sizeof(wchar_t)); + temp = CURLX_MALLOC(needed * sizeof(wchar_t)); if(!temp) goto cleanup; if(wcsncpy_s(temp, needed, L"\\\\?\\", 4)) { - /* !checksrc! disable BANNEDFUNC 1 */ - free(temp); + CURLX_FREE(temp); goto cleanup; } if(wcscpy_s(temp + 4, needed, fbuf)) { - /* !checksrc! disable BANNEDFUNC 1 */ - free(temp); + CURLX_FREE(temp); goto cleanup; } } - /* !checksrc! disable BANNEDFUNC 1 */ - free(fbuf); + CURLX_FREE(fbuf); fbuf = temp; } @@ -206,8 +197,7 @@ static bool fix_excessive_path(const TCHAR *in, TCHAR **out) goto cleanup; if(!needed || needed >= max_path_len) goto cleanup; - /* !checksrc! disable BANNEDFUNC 1 */ - obuf = malloc(needed); + obuf = CURLX_MALLOC(needed); if(!obuf) goto cleanup; if(wcstombs_s(&count, obuf, needed, fbuf, needed - 1)) @@ -222,12 +212,10 @@ static bool fix_excessive_path(const TCHAR *in, TCHAR **out) #endif cleanup: - /* !checksrc! disable BANNEDFUNC 1 */ - free(fbuf); + CURLX_FREE(fbuf); #ifndef _UNICODE - /* !checksrc! disable BANNEDFUNC 2 */ - free(ibuf); - free(obuf); + CURLX_FREE(ibuf); + CURLX_FREE(obuf); #endif return *out ? true : false; } @@ -269,8 +257,7 @@ int curlx_win32_open(const char *filename, int oflag, ...) errno = _sopen_s(&result, target, oflag, _SH_DENYNO, pmode); #endif - /* !checksrc! disable BANNEDFUNC 1 */ - free(fixed); + CURLX_FREE(fixed); return result; } @@ -303,8 +290,7 @@ FILE *curlx_win32_fopen(const char *filename, const char *mode) errno = fopen_s(&result, target, mode); #endif - /* !checksrc! disable BANNEDFUNC 1 */ - free(fixed); + CURLX_FREE(fixed); return result; } @@ -342,8 +328,7 @@ FILE *curlx_win32_freopen(const char *filename, const char *mode, FILE *fp) errno = freopen_s(&result, target, mode, fp); #endif - /* !checksrc! disable BANNEDFUNC 1 */ - free(fixed); + CURLX_FREE(fixed); return result; } @@ -382,8 +367,7 @@ int curlx_win32_stat(const char *path, struct_stat *buffer) #endif #endif - /* !checksrc! disable BANNEDFUNC 1 */ - free(fixed); + CURLX_FREE(fixed); return result; } diff --git a/lib/curlx/multibyte.c b/lib/curlx/multibyte.c index 2583f3087031..fb3b7be3e120 100644 --- a/lib/curlx/multibyte.c +++ b/lib/curlx/multibyte.c @@ -45,13 +45,11 @@ wchar_t *curlx_convert_UTF8_to_wchar(const char *str_utf8) int str_w_len = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, str_utf8, -1, NULL, 0); if(str_w_len > 0) { - /* !checksrc! disable BANNEDFUNC 1 */ - str_w = malloc(str_w_len * sizeof(wchar_t)); + str_w = CURLX_MALLOC(str_w_len * sizeof(wchar_t)); if(str_w) { if(MultiByteToWideChar(CP_UTF8, 0, str_utf8, -1, str_w, str_w_len) == 0) { - /* !checksrc! disable BANNEDFUNC 1 */ - free(str_w); + CURLX_FREE(str_w); return NULL; } } @@ -69,13 +67,11 @@ char *curlx_convert_wchar_to_UTF8(const wchar_t *str_w) int bytes = WideCharToMultiByte(CP_UTF8, 0, str_w, -1, NULL, 0, NULL, NULL); if(bytes > 0) { - /* !checksrc! disable BANNEDFUNC 1 */ - str_utf8 = malloc(bytes); + str_utf8 = CURLX_MALLOC(bytes); if(str_utf8) { if(WideCharToMultiByte(CP_UTF8, 0, str_w, -1, str_utf8, bytes, NULL, NULL) == 0) { - /* !checksrc! disable BANNEDFUNC 1 */ - free(str_utf8); + CURLX_FREE(str_utf8); return NULL; } } diff --git a/lib/curlx/multibyte.h b/lib/curlx/multibyte.h index fac07c2eeb24..3eae4e75bd1f 100644 --- a/lib/curlx/multibyte.h +++ b/lib/curlx/multibyte.h @@ -44,12 +44,20 @@ * memory tracker memdebug functions. */ +#ifdef CURLDEBUG +#define CURLX_MALLOC(x) malloc(x) +#define CURLX_FREE(x) free(x) +#else +#define CURLX_MALLOC(x) curlx_malloc(x) +#define CURLX_FREE(x) curlx_free(x) +#endif + /* 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); /* the purpose of this macro is to free() without being traced by memdebug */ -#define curlx_unicodefree(ptr) free(ptr) +#define curlx_unicodefree(ptr) CURLX_FREE(ptr) #ifdef UNICODE @@ -65,8 +73,13 @@ typedef union { #else /* !UNICODE */ +#ifdef CURLDEBUG #define curlx_convert_UTF8_to_tchar(ptr) _strdup(ptr) #define curlx_convert_tchar_to_UTF8(ptr) _strdup(ptr) +#else +#define curlx_convert_UTF8_to_tchar(ptr) curlx_strdup(ptr) +#define curlx_convert_tchar_to_UTF8(ptr) curlx_strdup(ptr) +#endif typedef union { char *tchar_ptr; From 5356bce6abab7e8e28a3d412b2fa2c55bfa62416 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Mon, 1 Dec 2025 19:49:50 +0100 Subject: [PATCH 152/415] windows: use `_strdup()` instead of `strdup()` where missing To replace deprecated `strdup()` CRT calls with the recommended `_strdup()`. Refs: https://learn.microsoft.com/cpp/c-runtime-library/reference/strdup-wcsdup https://learn.microsoft.com/cpp/c-runtime-library/reference/strdup-wcsdup-mbsdup Closes #19794 --- docs/examples/block_ip.c | 7 +------ lib/curl_setup.h | 3 +-- lib/easy.c | 4 ++++ tests/libtest/memptr.c | 4 ++++ tests/server/first.h | 4 ++++ 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/docs/examples/block_ip.c b/docs/examples/block_ip.c index bf2193a26359..5cd77cad0e80 100644 --- a/docs/examples/block_ip.c +++ b/docs/examples/block_ip.c @@ -38,12 +38,6 @@ int main(void) } #else -#ifdef _MSC_VER -#ifndef _CRT_NONSTDC_NO_DEPRECATE -#define _CRT_NONSTDC_NO_DEPRECATE /* for strdup() */ -#endif -#endif - #ifdef _WIN32 #if !defined(_WIN32_WINNT) || _WIN32_WINNT < 0x0600 #undef _WIN32_WINNT @@ -52,6 +46,7 @@ int main(void) #include #include #include +#define strdup _strdup #else #include #include diff --git a/lib/curl_setup.h b/lib/curl_setup.h index 6acac0d17ad0..2cc18cf41488 100644 --- a/lib/curl_setup.h +++ b/lib/curl_setup.h @@ -91,8 +91,7 @@ #pragma warning(disable:4127) /* Avoid VS2005 and upper complaining about portable C functions. */ #ifndef _CRT_NONSTDC_NO_DEPRECATE /* mingw-w64 v2+. MS SDK ~10+/~VS2017+. */ -#define _CRT_NONSTDC_NO_DEPRECATE /* for close(), fileno(), strdup(), - unlink(), etc. */ +#define _CRT_NONSTDC_NO_DEPRECATE /* for close(), fileno(), unlink(), etc. */ #endif #ifndef _CRT_SECURE_NO_WARNINGS #define _CRT_SECURE_NO_WARNINGS /* for getenv(), gmtime(), strcpy(), diff --git a/lib/easy.c b/lib/easy.c index 476f63c74dff..c60819fcdc6e 100644 --- a/lib/easy.c +++ b/lib/easy.c @@ -103,7 +103,11 @@ static curl_simple_lock s_lock = CURL_SIMPLE_LOCK_INIT; * so the callback pointer is initialized correctly. */ #ifdef HAVE_STRDUP +#ifdef _WIN32 +#define system_strdup _strdup +#else #define system_strdup strdup +#endif #else #define system_strdup Curl_strdup #endif diff --git a/tests/libtest/memptr.c b/tests/libtest/memptr.c index 400e72c41ab9..fe90b01a6cb1 100644 --- a/tests/libtest/memptr.c +++ b/tests/libtest/memptr.c @@ -36,7 +36,11 @@ curl_malloc_callback Curl_cmalloc = (curl_malloc_callback)malloc; curl_free_callback Curl_cfree = (curl_free_callback)free; curl_realloc_callback Curl_crealloc = (curl_realloc_callback)realloc; +#ifdef _WIN32 +curl_strdup_callback Curl_cstrdup = (curl_strdup_callback)_strdup; +#else curl_strdup_callback Curl_cstrdup = (curl_strdup_callback)strdup; +#endif curl_calloc_callback Curl_ccalloc = (curl_calloc_callback)calloc; #if defined(_MSC_VER) && defined(_DLL) diff --git a/tests/server/first.h b/tests/server/first.h index 2979239ad366..316a7a622e8d 100644 --- a/tests/server/first.h +++ b/tests/server/first.h @@ -69,6 +69,10 @@ extern const struct entry_s s_entries[]; # define snprintf _snprintf #endif +#ifdef _WIN32 +# define strdup _strdup +#endif + #ifdef _WIN32 # define CURL_STRNICMP(p1, p2, n) _strnicmp(p1, p2, n) #elif defined(HAVE_STRCASECMP) From 189fda00260b75bb2776a8ae36e3d7d36f01173e Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Sat, 29 Nov 2025 23:12:47 +0100 Subject: [PATCH 153/415] memdebug: replace macro constant with `sizeof()` Closes #19795 --- lib/memdebug.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/memdebug.c b/lib/memdebug.c index b6c2d854c33e..bbd7407c3c90 100644 --- a/lib/memdebug.c +++ b/lib/memdebug.c @@ -63,8 +63,7 @@ static long memsize = 0; /* set number of mallocs allowed */ static struct backtrace_state *btstate; #endif -#define KEEPSIZE 10000 -static char membuf[KEEPSIZE]; +static char membuf[10000]; static size_t memwidx = 0; /* write index */ #if defined(USE_THREADS_POSIX) || defined(USE_THREADS_WIN32) @@ -549,7 +548,7 @@ void curl_dbg_log(const char *format, ...) if(lock_mutex) Curl_mutex_acquire(&dbg_mutex); #endif - if(KEEPSIZE - nchars < memwidx) { + if(sizeof(membuf) - nchars < memwidx) { /* flush */ fwrite(membuf, 1, memwidx, curl_dbg_logfile); fflush(curl_dbg_logfile); From 9517b41b509f1098ed0b3b7ff20b53a566fa3f5e Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Mon, 1 Dec 2025 20:08:09 +0100 Subject: [PATCH 154/415] multibyte: limit `curlx_convert_*wchar*()` functions to Unicode builds Follow-up to ccb68d2e3b602b24a8cb52f473b96938ac998db6 #19790 Closes #19796 --- lib/curlx/multibyte.c | 4 ++-- lib/curlx/multibyte.h | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/curlx/multibyte.c b/lib/curlx/multibyte.c index fb3b7be3e120..3a33fcedfc65 100644 --- a/lib/curlx/multibyte.c +++ b/lib/curlx/multibyte.c @@ -29,7 +29,7 @@ #include "../curl_setup.h" -#ifdef _WIN32 +#if defined(_WIN32) && defined(UNICODE) #include "multibyte.h" @@ -81,4 +81,4 @@ char *curlx_convert_wchar_to_UTF8(const wchar_t *str_w) return str_utf8; } -#endif /* _WIN32 */ +#endif /* _WIN32 && UNICODE */ diff --git a/lib/curlx/multibyte.h b/lib/curlx/multibyte.h index 3eae4e75bd1f..fd264e180efa 100644 --- a/lib/curlx/multibyte.h +++ b/lib/curlx/multibyte.h @@ -52,15 +52,15 @@ #define CURLX_FREE(x) curlx_free(x) #endif -/* 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); - /* the purpose of this macro is to free() without being traced by memdebug */ #define curlx_unicodefree(ptr) CURLX_FREE(ptr) #ifdef UNICODE +/* 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); + #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)) From 58673ac8373c0d3baa0e5a3530e36a1095321a2b Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Mon, 1 Dec 2025 21:07:56 +0100 Subject: [PATCH 155/415] runtests: fix Perl warning ``` Use of uninitialized value $cmdhash{"option"} in pattern match (m//) at tests/runtests.pl line 1753. ``` Ref: https://github.com/curl/curl/actions/runs/19833947198/job/56831923295?pr=19794#step:13:3694 Follow-up to 02aa75a8c240af1a8912145497806e8925859a87 #19752 Closes #19797 --- tests/runtests.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/runtests.pl b/tests/runtests.pl index 1bde3f3afc64..d0455d224380 100755 --- a/tests/runtests.pl +++ b/tests/runtests.pl @@ -1750,7 +1750,7 @@ sub singletest_check { if(! -f "$logdir/$MEMDUMP") { my %cmdhash = getpartattr("client", "command"); my $cmdtype = $cmdhash{'type'} || "default"; - if($cmdhash{'option'} !~ /no-memdebug/) { + if($cmdhash{'option'} && $cmdhash{'option'} !~ /no-memdebug/) { logmsg "\n** ALERT! memory tracking with no output file?\n" if($cmdtype ne "perl"); } From 85a6936d7669748983ec340519df325eea9c9333 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 1 Dec 2025 16:32:39 +0100 Subject: [PATCH 156/415] libssh2: consider strdup() failures OOM and return correctly In the ssh_state_pkey_init function. Closes #19791 --- lib/vssh/libssh2.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/vssh/libssh2.c b/lib/vssh/libssh2.c index 8701775d7d94..4437724fcf42 100644 --- a/lib/vssh/libssh2.c +++ b/lib/vssh/libssh2.c @@ -1205,8 +1205,11 @@ static CURLcode ssh_state_pkey_init(struct Curl_easy *data, sshc->rsa_pub = sshc->rsa = NULL; - if(data->set.str[STRING_SSH_PRIVATE_KEY]) + if(data->set.str[STRING_SSH_PRIVATE_KEY]) { sshc->rsa = curlx_strdup(data->set.str[STRING_SSH_PRIVATE_KEY]); + if(!sshc->rsa) + out_of_memory = TRUE; + } else { /* To ponder about: should really the lib be messing about with the HOME environment variable etc? */ @@ -1251,7 +1254,7 @@ static CURLcode ssh_state_pkey_init(struct Curl_easy *data, * libssh2 extract the public key from the private key file. * This is done by simply passing sshc->rsa_pub = NULL. */ - if(data->set.str[STRING_SSH_PUBLIC_KEY] + if(!out_of_memory && data->set.str[STRING_SSH_PUBLIC_KEY] /* treat empty string the same way as NULL */ && data->set.str[STRING_SSH_PUBLIC_KEY][0]) { sshc->rsa_pub = curlx_strdup(data->set.str[STRING_SSH_PUBLIC_KEY]); From dc29590d6061931d054132cb701512a8b7305e7c Mon Sep 17 00:00:00 2001 From: Stefan Eissing Date: Mon, 1 Dec 2025 18:08:25 +0100 Subject: [PATCH 157/415] memdebug: log socket close before closing To not get a mixup in the memdebug log order. Closes #19793 --- lib/memdebug.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/memdebug.c b/lib/memdebug.c index bbd7407c3c90..7eae1708b7de 100644 --- a/lib/memdebug.c +++ b/lib/memdebug.c @@ -468,9 +468,8 @@ void curl_dbg_mark_sclose(curl_socket_t sockfd, int line, const char *source) /* this is our own defined way to close sockets on *ALL* platforms */ int curl_dbg_sclose(curl_socket_t sockfd, int line, const char *source) { - int res = CURL_SCLOSE(sockfd); curl_dbg_mark_sclose(sockfd, line, source); - return res; + return CURL_SCLOSE(sockfd); } ALLOC_FUNC From 055f1a3d02f656feb31a1246392473f6ac0e186f Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 2 Dec 2025 09:16:20 +0100 Subject: [PATCH 158/415] RELEASE-NOTES: synced --- RELEASE-NOTES | 84 +++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 75 insertions(+), 9 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 2dbac34d0f65..136176ce799d 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -4,7 +4,7 @@ curl and libcurl 8.18.0 Command line options: 273 curl_easy_setopt() options: 308 Public functions in libcurl: 100 - Contributors: 3553 + Contributors: 3554 This release includes the following changes: @@ -22,6 +22,7 @@ This release includes the following bugfixes: o asyn-ares: handle Curl_dnscache_mk_entry() OOM error [199] o asyn-ares: remove hostname free on OOM [122] o asyn-thrdd: release rrname if ares_init_options fails [41] + o auth: always treat Curl_auth_ntlm_get() returning NULL as OOM [186] o autotools: add nettle library detection via pkg-config (for GnuTLS) [178] o autotools: drop autoconf <2.59 compatibility code (zz60-xc-ovr) [70] o badwords: fix issues found in scripts and other files [142] @@ -31,14 +32,19 @@ This release includes the following bugfixes: o build: tidy-up MSVC CRT warning suppression macros [140] o ccsidcurl: make curl_mime_data_ccsid() use the converted size [74] o cf-https-connect: allocate ctx at first in cf_hc_create() [79] + o cf-socket: drop feature check for `IPV6_V6ONLY` on Windows [210] o cf-socket: limit use of `TCP_KEEP*` to Windows 10.0.16299+ at runtime [157] o cf-socket: trace ignored errors [97] o cfilters: make conn_forget_socket a private libssh function [109] o checksrc.pl: detect assign followed by more than one space [26] o cmake: adjust defaults for target platforms not supporting shared libs [35] + o cmake: define dependencies as `IMPORTED` interface targets [223] o cmake: disable `CURL_CA_PATH` auto-detection if `USE_APPLE_SECTRUST=ON` [16] + o cmake: fix `ws2_32` reference in `curl-config.cmake` [201] o cmake: honor `CURL_DISABLE_INSTALL` and `CURL_ENABLE_EXPORT_TARGET` [106] + o cmake: save and restore `CMAKE_MODULE_PATH` in `curl-config.cmake` [222] o code: minor indent fixes before closing braces [107] + o CODE_STYLE.md: sync banned function list with checksrc.pl [243] o config2setopts: bail out if curl_url_get() returns OOM [102] o config2setopts: exit if curl_url_set() fails on OOM [105] o conncache: silence `-Wnull-dereference` on gcc 14 RISC-V 64 [17] @@ -52,15 +58,18 @@ This release includes the following bugfixes: o curl_sasl: make Curl_sasl_decode_mech compare case insensitively [160] o curl_setup.h: document more funcs flagged by `_CRT_SECURE_NO_WARNINGS` [124] o curl_setup.h: drop stray `#undef stat` (Windows) [103] + o curl_setup.h: drop superfluous parenthesis from `Curl_safefree` macro [242] o CURLINFO: remove 'get' and 'get the' from each short desc [50] o CURLINFO_SCHEME/PROTOCOL: they return the "scheme" for a "transfer" [48] o CURLINFO_TLS_SSL_PTR.md: remove CURLINFO_TLS_SESSION text [49] o CURLOPT_READFUNCTION.md: clarify the size of the buffer [47] o CURLOPT_SSH_KEYFUNCTION.md: fix minor indent mistake in example o curlx/fopen: replace open CRT functions their with `_s` counterparts (Windows) [204] + o curlx/multibyte: stop setting macros for non-Windows [226] o curlx/strerr: use `strerror_s()` on Windows [75] o curlx: replace `mbstowcs`/`wcstombs` with `_s` counterparts (Windows) [143] o curlx: replace `sprintf` with `snprintf` [194] + o curlx: use curlx allocators in non-memdebug builds (Windows) [155] o digest_sspi: fix a memory leak on error path [149] o digest_sspi: properly free sspi identity [12] o DISTROS.md: add OpenBSD [126] @@ -68,6 +77,7 @@ This release includes the following bugfixes: o docs: fix checksrc `EQUALSPACE` warnings [21] o docs: mention umask need when curl creates files [56] o docs: spell it Rustls with a capital R [181] + o example: fix formatting nits [232] o examples/crawler: fix variable [92] o examples/multi-uv: fix invalid req->data access [177] o examples/multithread: fix race condition [101] @@ -86,34 +96,47 @@ This release includes the following bugfixes: o hostip: make more functions return CURLcode [202] o hostip: only store negative response for CURLE_COULDNT_RESOLVE_HOST [183] o hsts: propagate and error out correctly on OOM [130] + o http: acknowledge OOM errors from Curl_input_ntlm [185] o http: avoid two strdup()s and do minor simplifications [144] o http: error on OOM when creating range header [59] o http: fix OOM exit in Curl_http_follow [179] + o http: handle oom error from Curl_input_digest() [192] o http: replace atoi use in Curl_http_follow with curlx_str_number [65] o http: the :authority header should never contain user+password [147] + o idn: fix memory leak in `win32_ascii_to_idn()` [173] + o idn: use curlx allocators on Windows [165] + o imap: make sure Curl_pgrsSetDownloadSize() does not overflow [200] o INSTALL-CMAKE.md: document static option defaults more [37] + o krb5: fix detecting channel binding feature [187] o krb5_sspi: unify a part of error handling [80] + o lib/sendf.h: forward declare two structs [221] o lib: cleanup for some typos about spaces and code style [3] o lib: eliminate size_t casts [112] o lib: error for OOM when extracting URL query [127] + o lib: fix formatting nits [215] o lib: fix gssapi.h include on IBMi [55] o lib: refactor the type of funcs which have useless return and checks [1] o lib: replace `_tcsncpy`/`wcsncpy`/`wcscpy` with `_s` counterparts (Windows) [164] o lib: timer stats improvements [190] o libssh2: add paths to error messages for quote commands [114] o libssh2: cleanup ssh_force_knownhost_key_type [64] + o libssh2: consider strdup() failures OOM and return correctly [72] o libssh2: replace atoi() in ssh_force_knownhost_key_type [63] + o libssh: fix state machine loop to progress as it should o libssh: properly free sftp_attributes [153] o libtests: replace `atoi()` with `curlx_str_number()` [120] o limit-rate: add example using --limit-rate and --max-time together [89] o m4/sectrust: fix test(1) operator [4] o manage: expand the 'libcurl support required' message [208] o mbedtls: fix potential use of uninitialized `nread` [8] + o mbedtls_threadlock: avoid calloc, use array [244] + o memdebug: add mutex for thread safety [184] o mk-ca-bundle.pl: default to SHA256 fingerprints with `-t` option [73] o mk-ca-bundle.pl: use `open()` with argument list to replace backticks [71] o mqtt: reject overly big messages [39] o multi: make max_total_* members size_t [158] o multi: simplify admin handle processing [189] + o multibyte: limit `curlx_convert_*wchar*()` functions to Unicode builds [135] o ngtcp2+openssl: fix leak of session [172] o ngtcp2: remove the unused Curl_conn_is_ngtcp2 function [85] o noproxy: replace atoi with curlx_str_number [67] @@ -134,10 +157,14 @@ This release includes the following bugfixes: o ratelimit: redesign [209] o rtmp: fix double-free on URL parse errors [27] o rtmp: precaution for a potential integer truncation [54] + o rtmp: stop redefining `setsockopt` system symbol on Windows [211] o runtests: detect bad libssh differently for test 1459 [11] o runtests: drop Python 2 support remains [45] + o runtests: enable torture testing with threaded resolver [176] o rustls: fix a potential memory issue [81] o rustls: minor adjustment of sizeof() [38] + o rustls: simplify init err path [219] + o rustls: verify that verifier_builder is not NULL [220] o schannel: fix memory leak of cert_store_path on four error paths [23] o schannel: replace atoi() with curlx_str_number() [119] o schannel_verify: fix a memory leak of cert_context [152] @@ -151,6 +178,7 @@ This release includes the following bugfixes: o socks_sspi: use free() not FreeContextBuffer() [93] o speedcheck: do not trigger low speed cancel on transfers with CURL_READFUNC_PAUSE [113] o speedlimit: also reset on send unpausing [197] + o ssh: tracing and better pollset handling [230] o telnet: replace atoi for BINARY handling with curlx_str_number [66] o TEST-SUITE.md: correct the man page's path [136] o test07_22: fix flakiness [95] @@ -161,6 +189,7 @@ This release includes the following bugfixes: o tests/server: do not fall back to original data file in `test2fopen()` [32] o tests/server: replace `atoi()` and `atol()` with `curlx_str_number()` [110] o tests: allow 2500-2503 to use ~2MB malloc [31] + o tests: fix formatting nits [225] o tftp: release filename if conn_get_remote_addr fails [42] o tftpd: fix/tidy up `open()` mode flags [57] o tidy-up: move `CURL_UNCONST()` out from macro `curl_unicodefree()` [121] @@ -172,14 +201,17 @@ This release includes the following bugfixes: o tool_help: add checks to avoid unsigned wrap around [14] o tool_ipfs: check return codes better [20] o tool_msgs: make voutf() use stack instead of heap [125] + o tool_operatate: return error for OOM in append2query [217] o tool_operate: exit on curl_share_setopt errors [108] o tool_operate: fix a case of ignoring return code in operate() [128] o tool_operate: fix case of ignoring return code in single_transfer [129] o tool_operate: remove redundant condition [19] o tool_operate: use curlx_str_number instead of atoi [68] o tool_paramhlp: refuse --proto remove all protocols [10] + o tool_urlglob: acknowledge OOM in peek_ipv6 [175] o tool_urlglob: clean up used memory on errors better [44] o tool_writeout: bail out proper on OOM [104] + o url: fix return code for OOM in parse_proxy() [193] o url: if OOM in parse_proxy() return error [132] o urlapi: fix mem-leaks in curl_url_get error paths [22] o urlapi: handle OOM properly when setting URL [180] @@ -191,6 +223,7 @@ This release includes the following bugfixes: o vtls: handle possible malicious certs_num from peer [53] o vtls: pinned key check [98] o wcurl: import v2025.11.09 [29] + o windows: use `_strdup()` instead of `strdup()` where missing [145] o wolfSSL: able to differentiate between IP and DNS in alt names [13] o wolfssl: avoid NULL dereference in OOM situation [77] o wolfssl: fix a potential memory leak of session [6] @@ -219,14 +252,15 @@ advice from friends like these: Aleksandr Sergeev, Aleksei Bavshin, Andrew Kirillov, BANADDA, boingball, Brad King, bttrfl on github, Christian Schmitz, Dan Fandrich, - Daniel McCarney, Daniel Stenberg, Fd929c2CE5fA on github, ffath-vo on github, - Gisle Vanem, Jiyong Yang, Juliusz Sosinowicz, Leonardo Taccari, - letshack9707 on hackerone, Marc Aldorasi, Marcel Raad, nait-furry, - ncaklovic on github, Nick Korepanov, Omdahake on github, Patrick Monnerat, - pelioro on hackerone, Ray Satiro, renovate[bot], Samuel Henrique, - st751228051 on github, Stanislav Fort, Stefan Eissing, Sunny, - Thomas Klausner, Viktor Szakats, Wesley Moore, Xiaoke Wang, Yedaya Katsman - (38 contributors) + Daniel McCarney, Daniel Stenberg, Deniz Parlak, Fd929c2CE5fA on github, + ffath-vo on github, Gisle Vanem, Jiyong Yang, Juliusz Sosinowicz, Kai Pastor, + Leonardo Taccari, letshack9707 on hackerone, Marc Aldorasi, Marcel Raad, + Max Faxälv, nait-furry, ncaklovic on github, Nick Korepanov, + Omdahake on github, Patrick Monnerat, pelioro on hackerone, Ray Satiro, + renovate[bot], Samuel Henrique, st751228051 on github, Stanislav Fort, + Stefan Eissing, Sunny, Thomas Klausner, Viktor Szakats, Wesley Moore, + Xiaoke Wang, Yedaya Katsman + (41 contributors) References to bug reports and discussions on issues: @@ -300,6 +334,7 @@ References to bug reports and discussions on issues: [69] = https://curl.se/bug/?i=17927 [70] = https://curl.se/bug/?i=19464 [71] = https://curl.se/bug/?i=19461 + [72] = https://curl.se/bug/?i=19791 [73] = https://curl.se/bug/?i=19359 [74] = https://curl.se/bug/?i=19465 [75] = https://curl.se/bug/?i=19646 @@ -361,6 +396,7 @@ References to bug reports and discussions on issues: [132] = https://curl.se/bug/?i=19590 [133] = https://curl.se/bug/?i=19471 [134] = https://curl.se/bug/?i=19583 + [135] = https://curl.se/bug/?i=19796 [136] = https://curl.se/bug/?i=19586 [137] = https://curl.se/bug/?i=19578 [138] = https://curl.se/bug/?i=19580 @@ -369,6 +405,7 @@ References to bug reports and discussions on issues: [142] = https://curl.se/bug/?i=19572 [143] = https://curl.se/bug/?i=19581 [144] = https://curl.se/bug/?i=19571 + [145] = https://curl.se/bug/?i=19794 [146] = https://curl.se/bug/?i=19543 [147] = https://curl.se/bug/?i=19568 [148] = https://curl.se/bug/?i=19569 @@ -378,6 +415,7 @@ References to bug reports and discussions on issues: [152] = https://curl.se/bug/?i=19556 [153] = https://curl.se/bug/?i=19564 [154] = https://curl.se/bug/?i=19566 + [155] = https://curl.se/bug/?i=19788 [156] = https://curl.se/bug/?i=19541 [157] = https://curl.se/bug/?i=19520 [158] = https://curl.se/bug/?i=19618 @@ -387,29 +425,57 @@ References to bug reports and discussions on issues: [162] = https://curl.se/bug/?i=19636 [163] = https://curl.se/bug/?i=19637 [164] = https://curl.se/bug/?i=19589 + [165] = https://curl.se/bug/?i=19790 [166] = https://curl.se/bug/?i=19615 [167] = https://curl.se/bug/?i=19609 [168] = https://curl.se/bug/?i=19612 [170] = https://curl.se/bug/?i=19333 [171] = https://curl.se/bug/?i=19714 [172] = https://curl.se/bug/?i=19717 + [173] = https://curl.se/bug/?i=19789 + [175] = https://curl.se/bug/?i=19784 + [176] = https://curl.se/bug/?i=19786 [177] = https://curl.se/bug/?i=19462 [178] = https://curl.se/bug/?i=19703 [179] = https://curl.se/bug/?i=19705 [180] = https://curl.se/bug/?i=19704 [181] = https://curl.se/bug/?i=19702 [183] = https://curl.se/bug/?i=19701 + [184] = https://curl.se/bug/?i=19785 + [185] = https://curl.se/bug/?i=19781 + [186] = https://curl.se/bug/?i=19782 + [187] = https://curl.se/bug/?i=19164 [189] = https://curl.se/bug/?i=19604 [190] = https://curl.se/bug/?i=19269 [191] = https://curl.se/bug/?i=19663 + [192] = https://curl.se/bug/?i=19780 + [193] = https://curl.se/bug/?i=19779 [194] = https://curl.se/bug/?i=19681 [195] = https://curl.se/bug/?i=19692 [196] = https://curl.se/bug/?i=19692 [197] = https://curl.se/bug/?i=19687 [198] = https://curl.se/bug/?i=19689 [199] = https://curl.se/bug/?i=19688 + [200] = https://curl.se/bug/?i=19774 + [201] = https://curl.se/bug/?i=19775 [202] = https://curl.se/bug/?i=19669 [203] = https://curl.se/bug/?i=19683 [204] = https://curl.se/bug/?i=19643 [208] = https://curl.se/bug/?i=19665 [209] = https://curl.se/bug/?i=19384 + [210] = https://curl.se/bug/?i=19769 + [211] = https://curl.se/bug/?i=19768 + [215] = https://curl.se/bug/?i=19764 + [217] = https://curl.se/bug/?i=19763 + [219] = https://curl.se/bug/?i=19759 + [220] = https://curl.se/bug/?i=19756 + [221] = https://curl.se/bug/?i=19761 + [222] = https://curl.se/bug/?i=16973 + [223] = https://curl.se/bug/?i=16973 + [225] = https://curl.se/bug/?i=19754 + [226] = https://curl.se/bug/?i=19751 + [230] = https://curl.se/bug/?i=19745 + [232] = https://curl.se/bug/?i=19746 + [242] = https://curl.se/bug/?i=19734 + [243] = https://curl.se/bug/?i=19733 + [244] = https://curl.se/bug/?i=19732 From 8dedcce7a3b8f32633ba7b546ae55bb7f5017fd1 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 2 Dec 2025 10:13:32 +0100 Subject: [PATCH 159/415] RELEASE-NOTES: fix typo --- RELEASE-NOTES | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 136176ce799d..512bc5425d57 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -201,11 +201,11 @@ This release includes the following bugfixes: o tool_help: add checks to avoid unsigned wrap around [14] o tool_ipfs: check return codes better [20] o tool_msgs: make voutf() use stack instead of heap [125] - o tool_operatate: return error for OOM in append2query [217] o tool_operate: exit on curl_share_setopt errors [108] o tool_operate: fix a case of ignoring return code in operate() [128] o tool_operate: fix case of ignoring return code in single_transfer [129] o tool_operate: remove redundant condition [19] + o tool_operate: return error for OOM in append2query [217] o tool_operate: use curlx_str_number instead of atoi [68] o tool_paramhlp: refuse --proto remove all protocols [10] o tool_urlglob: acknowledge OOM in peek_ipv6 [175] From c1c3487d7902799412823cb71df7af6af0df36a1 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 2 Dec 2025 09:53:00 +0100 Subject: [PATCH 160/415] curl_gssapi: make sure Curl_gss_log_error() has an initialized buffer Reported-by: Stanislav Fort (Aisle Research) Closes #19802 --- lib/curl_gssapi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/curl_gssapi.c b/lib/curl_gssapi.c index edd555db7923..7f5bd72954aa 100644 --- a/lib/curl_gssapi.c +++ b/lib/curl_gssapi.c @@ -428,7 +428,7 @@ static size_t display_gss_error(OM_uint32 status, int type, void Curl_gss_log_error(struct Curl_easy *data, const char *prefix, OM_uint32 major, OM_uint32 minor) { - char buf[GSS_LOG_BUFFER_LEN]; + char buf[GSS_LOG_BUFFER_LEN] = ""; size_t len = 0; if(major != GSS_S_FAILURE) From 4f2374810ab50802c94400dad26c60771b3fa0ff Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 2 Dec 2025 11:13:49 +0100 Subject: [PATCH 161/415] DEPRECATE.md: remove OpenSSL-QUIC in January 2026 instead Move it up two months. It was only ever experimental so this cannot interfere with any production code so shorten the "quarantine". Closes #19805 --- docs/DEPRECATE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/DEPRECATE.md b/docs/DEPRECATE.md index 1629af1fffd0..2a3cbfc78d88 100644 --- a/docs/DEPRECATE.md +++ b/docs/DEPRECATE.md @@ -36,7 +36,7 @@ stack. - curl users building with vanilla OpenSSL can still use QUIC through the means of ngtcp2 -We remove the OpenSSL-QUIC backend in March 2026. +We remove the OpenSSL-QUIC backend in January 2026. ## RTMP From b30c1b97b97cdbe7cc6f638c90f8b60e2036ad27 Mon Sep 17 00:00:00 2001 From: Stefan Eissing Date: Tue, 2 Dec 2025 13:42:29 +0100 Subject: [PATCH 162/415] quiche: use client writer Instead of buffering response body data until it is received by the transfer loop, write the response data directly to the client. Use a connection wide scratch buffer to get the response body from quiche. Eliminates need for maintaining individual buffers for each stream. Fixes #19803 Reported-by: Stanislav Fort Closes #19806 --- lib/vquic/curl_quiche.c | 385 +++++++++++++++++++--------------------- 1 file changed, 185 insertions(+), 200 deletions(-) diff --git a/lib/vquic/curl_quiche.c b/lib/vquic/curl_quiche.c index 45f606ec6182..913311085270 100644 --- a/lib/vquic/curl_quiche.c +++ b/lib/vquic/curl_quiche.c @@ -89,8 +89,9 @@ struct cf_quiche_ctx { uint8_t scid[QUICHE_MAX_CONN_ID_LEN]; struct curltime started_at; /* time the current attempt started */ struct curltime handshake_at; /* time connect handshake finished */ - struct bufc_pool stream_bufcp; /* chunk pool for streams */ struct uint_hash streams; /* hash `data->mid` to `stream_ctx` */ + struct dynbuf scratch; /* temp buffer for header construction */ + struct bufq writebuf; /* temp buffer for writing bodies */ curl_off_t data_recvd; BIT(initialized); BIT(goaway); /* got GOAWAY from server */ @@ -119,9 +120,10 @@ static void cf_quiche_ctx_init(struct cf_quiche_ctx *ctx) debug_log_init = 1; } #endif - Curl_bufcp_init(&ctx->stream_bufcp, H3_STREAM_CHUNK_SIZE, - H3_STREAM_POOL_SPARES); + curlx_dyn_init(&ctx->scratch, CURL_MAX_HTTP_HEADER); Curl_uint32_hash_init(&ctx->streams, 63, h3_stream_hash_free); + Curl_bufq_init2(&ctx->writebuf, H3_STREAM_CHUNK_SIZE, H3_STREAM_RECV_CHUNKS, + BUFQ_OPT_SOFT_LIMIT); ctx->data_recvd = 0; ctx->initialized = TRUE; } @@ -134,8 +136,9 @@ static void cf_quiche_ctx_free(struct cf_quiche_ctx *ctx) Curl_vquic_tls_cleanup(&ctx->tls); Curl_ssl_peer_cleanup(&ctx->peer); vquic_ctx_free(&ctx->q); - Curl_bufcp_free(&ctx->stream_bufcp); Curl_uint32_hash_destroy(&ctx->streams); + curlx_dyn_free(&ctx->scratch); + Curl_bufq_free(&ctx->writebuf); } curlx_free(ctx); } @@ -168,9 +171,10 @@ static CURLcode cf_flush_egress(struct Curl_cfilter *cf, */ struct h3_stream_ctx { uint64_t id; /* HTTP/3 protocol stream identifier */ - struct bufq recvbuf; /* h3 response */ struct h1_req_parser h1; /* h1 request parsing */ uint64_t error3; /* HTTP/3 stream error code */ + int status_code; /* HTTP status code */ + CURLcode xfer_result; /* result from cf_quiche_write_(hd/body) */ BIT(opened); /* TRUE after stream has been opened */ BIT(closed); /* TRUE on stream close */ BIT(reset); /* TRUE on stream reset */ @@ -182,7 +186,6 @@ struct h3_stream_ctx { static void h3_stream_ctx_free(struct h3_stream_ctx *stream) { - Curl_bufq_free(&stream->recvbuf); Curl_h1_req_parse_free(&stream->h1); curlx_free(stream); } @@ -252,6 +255,7 @@ static bool cf_quiche_do_expire(struct Curl_cfilter *cf, (void)stream; (void)user_data; CURL_TRC_CF(sdata, cf, "conn closed, mark as dirty"); + stream->xfer_result = CURLE_SEND_ERROR; Curl_multi_mark_dirty(sdata); return TRUE; } @@ -270,8 +274,6 @@ static CURLcode h3_data_setup(struct Curl_cfilter *cf, return CURLE_OUT_OF_MEMORY; stream->id = -1; - Curl_bufq_initp(&stream->recvbuf, &ctx->stream_bufcp, - H3_STREAM_RECV_CHUNKS, BUFQ_OPT_SOFT_LIMIT); Curl_h1_req_parse_init(&stream->h1, H1_PARSE_DEFAULT_MAX_LINE_LEN); if(!Curl_uint32_hash_set(&ctx->streams, data->mid, stream)) { @@ -282,28 +284,38 @@ static CURLcode h3_data_setup(struct Curl_cfilter *cf, return CURLE_OK; } +static void cf_quiche_stream_close(struct Curl_cfilter *cf, + struct Curl_easy *data, + struct h3_stream_ctx *stream) +{ + struct cf_quiche_ctx *ctx = cf->ctx; + CURLcode result; + + if(ctx->qconn && !stream->closed) { + quiche_conn_stream_shutdown(ctx->qconn, stream->id, + QUICHE_SHUTDOWN_READ, CURL_H3_NO_ERROR); + if(!stream->send_closed) { + quiche_conn_stream_shutdown(ctx->qconn, stream->id, + QUICHE_SHUTDOWN_WRITE, CURL_H3_NO_ERROR); + stream->send_closed = TRUE; + } + stream->closed = TRUE; + result = cf_flush_egress(cf, data); + if(result) + CURL_TRC_CF(data, cf, "[%" PRIu64 "] stream close, flush egress -> %d", + stream->id, result); + } +} + static void h3_data_done(struct Curl_cfilter *cf, struct Curl_easy *data) { struct cf_quiche_ctx *ctx = cf->ctx; struct h3_stream_ctx *stream = H3_STREAM_CTX(ctx, data); - CURLcode result; (void)cf; if(stream) { CURL_TRC_CF(data, cf, "[%" PRIu64 "] easy handle is done", stream->id); - if(ctx->qconn && !stream->closed) { - quiche_conn_stream_shutdown(ctx->qconn, stream->id, - QUICHE_SHUTDOWN_READ, CURL_H3_NO_ERROR); - if(!stream->send_closed) { - quiche_conn_stream_shutdown(ctx->qconn, stream->id, - QUICHE_SHUTDOWN_WRITE, CURL_H3_NO_ERROR); - stream->send_closed = TRUE; - } - stream->closed = TRUE; - result = cf_flush_egress(cf, data); - if(result) - CURL_TRC_CF(data, cf, "data_done, flush egress -> %d", result); - } + cf_quiche_stream_close(cf, data, stream); Curl_uint32_hash_remove(&ctx->streams, data->mid); } } @@ -316,39 +328,29 @@ static void cf_quiche_expire_conn_closed(struct Curl_cfilter *cf, cf_quiche_for_all_streams(cf, data->multi, cf_quiche_do_expire, NULL); } -/* - * write_resp_raw() copies response data in raw format to the `data`'s - * receive buffer. If not enough space is available, it appends to the - * `data`'s overflow buffer. - */ -static CURLcode write_resp_raw(struct Curl_cfilter *cf, +static void cf_quiche_write_hd(struct Curl_cfilter *cf, struct Curl_easy *data, - const void *mem, size_t memlen) + struct h3_stream_ctx *stream, + const char *buf, size_t blen, bool eos) { - struct cf_quiche_ctx *ctx = cf->ctx; - struct h3_stream_ctx *stream = H3_STREAM_CTX(ctx, data); - CURLcode result = CURLE_OK; - size_t nwritten; - - (void)cf; - if(!stream) - return CURLE_RECV_ERROR; - result = Curl_bufq_write(&stream->recvbuf, mem, memlen, &nwritten); - if(result) - return result; - - if(nwritten < memlen) { - /* This MUST not happen. Our recbuf is dimensioned to hold the - * full max_stream_window and then some for this reason. */ - DEBUGASSERT(0); - return CURLE_RECV_ERROR; + /* This function returns no error intentionally, but records + * the result at the stream, skipping further writes once the + * `result` of the transfer is known. + * The stream is subsequently cancelled "higher up" in the filter's + * send/recv callbacks. Closing the stream here leads to SEND/RECV + * errors in other places that then overwrite the transfer's result. */ + if(!stream->xfer_result) { + stream->xfer_result = Curl_xfer_write_resp_hd(data, buf, blen, eos); + if(stream->xfer_result) + CURL_TRC_CF(data, cf, "[%" PRId64 "] error %d writing %zu " + "bytes of headers", stream->id, stream->xfer_result, blen); } - return result; } struct cb_ctx { struct Curl_cfilter *cf; struct Curl_easy *data; + struct h3_stream_ctx *stream; }; static int cb_each_header(uint8_t *name, size_t name_len, @@ -356,39 +358,59 @@ static int cb_each_header(uint8_t *name, size_t name_len, void *argp) { struct cb_ctx *x = argp; - struct cf_quiche_ctx *ctx = x->cf->ctx; - struct h3_stream_ctx *stream = H3_STREAM_CTX(ctx, x->data); + struct Curl_cfilter *cf = x->cf; + struct Curl_easy *data = x->data; + struct h3_stream_ctx *stream = x->stream; + struct cf_quiche_ctx *ctx = cf->ctx; CURLcode result; - if(!stream) - return CURLE_OK; + if(!stream || stream->xfer_result) + return 1; /* abort iteration */ if((name_len == 7) && !strncmp(HTTP_PSEUDO_STATUS, (char *)name, 7)) { - CURL_TRC_CF(x->data, x->cf, "[%" PRIu64 "] status: %.*s", - stream->id, (int)value_len, value); - result = write_resp_raw(x->cf, x->data, "HTTP/3 ", sizeof("HTTP/3 ") - 1); + curlx_dyn_reset(&ctx->scratch); + result = Curl_http_decode_status(&stream->status_code, + (const char *)value, value_len); + if(!result) + result = curlx_dyn_addn(&ctx->scratch, STRCONST("HTTP/3 ")); + if(!result) + result = curlx_dyn_addn(&ctx->scratch, + (const char *)value, value_len); if(!result) - result = write_resp_raw(x->cf, x->data, value, value_len); + result = curlx_dyn_addn(&ctx->scratch, STRCONST(" \r\n")); if(!result) - result = write_resp_raw(x->cf, x->data, " \r\n", 3); + cf_quiche_write_hd(cf, data, stream, curlx_dyn_ptr(&ctx->scratch), + curlx_dyn_len(&ctx->scratch), FALSE); + CURL_TRC_CF(data, cf, "[%" PRId64 "] status: %s", + stream->id, curlx_dyn_ptr(&ctx->scratch)); } else { - CURL_TRC_CF(x->data, x->cf, "[%" PRIu64 "] header: %.*s: %.*s", + /* store as an HTTP1-style header */ + CURL_TRC_CF(data, cf, "[%" PRId64 "] header: %.*s: %.*s", stream->id, (int)name_len, name, (int)value_len, value); - result = write_resp_raw(x->cf, x->data, name, name_len); + curlx_dyn_reset(&ctx->scratch); + result = curlx_dyn_addn(&ctx->scratch, + (const char *)name, name_len); if(!result) - result = write_resp_raw(x->cf, x->data, ": ", 2); + result = curlx_dyn_addn(&ctx->scratch, STRCONST(": ")); if(!result) - result = write_resp_raw(x->cf, x->data, value, value_len); + result = curlx_dyn_addn(&ctx->scratch, + (const char *)value, value_len); if(!result) - result = write_resp_raw(x->cf, x->data, "\r\n", 2); + result = curlx_dyn_addn(&ctx->scratch, STRCONST("\r\n")); + if(!result) + cf_quiche_write_hd(cf, data, stream, curlx_dyn_ptr(&ctx->scratch), + curlx_dyn_len(&ctx->scratch), FALSE); } + if(result) { CURL_TRC_CF(x->data, x->cf, "[%" PRIu64 "] on header error %d", stream->id, result); + if(!stream->xfer_result) + stream->xfer_result = result; } - return result; + return stream->xfer_result ? 1 : 0; } static CURLcode stream_resp_read(void *reader_ctx, @@ -410,94 +432,99 @@ static CURLcode stream_resp_read(void *reader_ctx, return CURLE_OK; } -static CURLcode cf_recv_body(struct Curl_cfilter *cf, - struct Curl_easy *data) +static void cf_quiche_flush_body(struct Curl_cfilter *cf, + struct Curl_easy *data, + struct h3_stream_ctx *stream) +{ + struct cf_quiche_ctx *ctx = cf->ctx; + const uint8_t *buf; + size_t blen; + + while(stream && !stream->xfer_result) { + if(Curl_bufq_peek(&ctx->writebuf, &buf, &blen)) { + stream->xfer_result = Curl_xfer_write_resp( + data, (const char *)buf, blen, FALSE); + Curl_bufq_skip(&ctx->writebuf, blen); + if(stream->xfer_result) { + CURL_TRC_CF(data, cf, "[%" PRId64 "] error %d writing %zu bytes" + " of data", stream->id, stream->xfer_result, blen); + } + } + else + break; + } + Curl_bufq_reset(&ctx->writebuf); +} + +static void cf_quiche_recv_body(struct Curl_cfilter *cf, + struct Curl_easy *data, + struct h3_stream_ctx *stream) { struct cf_quiche_ctx *ctx = cf->ctx; - struct h3_stream_ctx *stream = H3_STREAM_CTX(ctx, data); size_t nread; struct cb_ctx cb_ctx; CURLcode result = CURLE_OK; if(!stream) - return CURLE_RECV_ERROR; - - if(!stream->resp_hds_complete) { - result = write_resp_raw(cf, data, "\r\n", 2); - if(result) - return result; - stream->resp_hds_complete = TRUE; - } + return; + /* Even when the transfer has already errored, we need to receive + * the data from quiche, as quiche will otherwise get stuck and + * raise events to receive over and over again. */ cb_ctx.cf = cf; cb_ctx.data = data; - result = Curl_bufq_slurp(&stream->recvbuf, - stream_resp_read, &cb_ctx, &nread); - - if(result && result != CURLE_AGAIN) { - CURL_TRC_CF(data, cf, "[%" PRIu64 "] recv_body error %zu", - stream->id, nread); - failf(data, "Error %d in HTTP/3 response body for stream[%" PRIu64 "]", - result, stream->id); - stream->closed = TRUE; - stream->reset = TRUE; - stream->send_closed = TRUE; - return result; - } - return CURLE_OK; -} - -#ifdef DEBUGBUILD -static const char *cf_ev_name(quiche_h3_event *ev) -{ - switch(quiche_h3_event_type(ev)) { - case QUICHE_H3_EVENT_HEADERS: - return "HEADERS"; - case QUICHE_H3_EVENT_DATA: - return "DATA"; - case QUICHE_H3_EVENT_RESET: - return "RESET"; - case QUICHE_H3_EVENT_FINISHED: - return "FINISHED"; - case QUICHE_H3_EVENT_GOAWAY: - return "GOAWAY"; - default: - return "Unknown"; + cb_ctx.stream = stream; + Curl_bufq_reset(&ctx->writebuf); + while(!result) { + result = Curl_bufq_slurp(&ctx->writebuf, + stream_resp_read, &cb_ctx, &nread); + if(!result) + cf_quiche_flush_body(cf, data, stream); + else if(result == CURLE_AGAIN) + break; + else if(result) { + CURL_TRC_CF(data, cf, "[%" PRIu64 "] recv_body error %d", + stream->id, result); + failf(data, "[%" PRIu64 "] Error %d in HTTP/3 response body for stream", + stream->id, result); + stream->closed = TRUE; + stream->reset = TRUE; + stream->send_closed = TRUE; + if(!stream->xfer_result) + stream->xfer_result = result; + } } + cf_quiche_flush_body(cf, data, stream); } -#else -#define cf_ev_name(x) "" -#endif -static CURLcode h3_process_event(struct Curl_cfilter *cf, +static void cf_quiche_process_ev(struct Curl_cfilter *cf, struct Curl_easy *data, struct h3_stream_ctx *stream, quiche_h3_event *ev) { - struct cb_ctx cb_ctx; - CURLcode result = CURLE_OK; - int rc; - if(!stream) - return CURLE_OK; + return; + switch(quiche_h3_event_type(ev)) { - case QUICHE_H3_EVENT_HEADERS: + case QUICHE_H3_EVENT_HEADERS: { + struct cb_ctx cb_ctx; stream->resp_got_header = TRUE; cb_ctx.cf = cf; cb_ctx.data = data; - rc = quiche_h3_event_for_each_header(ev, cb_each_header, &cb_ctx); - if(rc) { - failf(data, "Error %d in HTTP/3 response header for stream[%" PRIu64 "]", - rc, stream->id); - return CURLE_RECV_ERROR; - } + cb_ctx.stream = stream; + quiche_h3_event_for_each_header(ev, cb_each_header, &cb_ctx); CURL_TRC_CF(data, cf, "[%" PRIu64 "] <- [HEADERS]", stream->id); + Curl_multi_mark_dirty(data); break; - + } case QUICHE_H3_EVENT_DATA: - if(!stream->closed) { - result = cf_recv_body(cf, data); + if(!stream->resp_hds_complete) { + stream->resp_hds_complete = TRUE; + cf_quiche_write_hd(cf, data, stream, "\r\n", 2, FALSE); } + cf_quiche_recv_body(cf, data, stream); + CURL_TRC_CF(data, cf, "[%" PRIu64 "] <- [DATA]", stream->id); + Curl_multi_mark_dirty(data); break; case QUICHE_H3_EVENT_RESET: @@ -505,17 +532,17 @@ static CURLcode h3_process_event(struct Curl_cfilter *cf, stream->closed = TRUE; stream->reset = TRUE; stream->send_closed = TRUE; + Curl_multi_mark_dirty(data); break; case QUICHE_H3_EVENT_FINISHED: CURL_TRC_CF(data, cf, "[%" PRIu64 "] CLOSED", stream->id); if(!stream->resp_hds_complete) { - result = write_resp_raw(cf, data, "\r\n", 2); - if(result) - return result; stream->resp_hds_complete = TRUE; + cf_quiche_write_hd(cf, data, stream, "\r\n", 2, TRUE); } stream->closed = TRUE; + Curl_multi_mark_dirty(data); break; case QUICHE_H3_EVENT_GOAWAY: @@ -527,20 +554,6 @@ static CURLcode h3_process_event(struct Curl_cfilter *cf, stream->id, quiche_h3_event_type(ev)); break; } - return result; -} - -static CURLcode cf_quiche_ev_process(struct Curl_cfilter *cf, - struct Curl_easy *data, - struct h3_stream_ctx *stream, - quiche_h3_event *ev) -{ - CURLcode result = h3_process_event(cf, data, stream, ev); - Curl_multi_mark_dirty(data); - if(result) - CURL_TRC_CF(data, cf, "error processing event %s for [%" PRIu64 "] -> %d", - cf_ev_name(ev), stream->id, result); - return result; } struct cf_quich_disp_ctx { @@ -548,7 +561,6 @@ struct cf_quich_disp_ctx { struct Curl_cfilter *cf; struct Curl_multi *multi; quiche_h3_event *ev; - CURLcode result; }; static bool cf_quiche_disp_event(uint32_t mid, void *val, void *user_data) @@ -559,7 +571,7 @@ static bool cf_quiche_disp_event(uint32_t mid, void *val, void *user_data) if(stream->id == dctx->stream_id) { struct Curl_easy *sdata = Curl_multi_get_easy(dctx->multi, mid); if(sdata) - dctx->result = cf_quiche_ev_process(dctx->cf, sdata, stream, dctx->ev); + cf_quiche_process_ev(dctx->cf, sdata, stream, dctx->ev); return FALSE; /* stop iterating */ } return TRUE; @@ -583,23 +595,22 @@ static CURLcode cf_poll_events(struct Curl_cfilter *cf, return CURLE_HTTP3; } else { - struct cf_quich_disp_ctx dctx; - dctx.stream_id = (uint64_t)rv; - dctx.cf = cf; - dctx.multi = data->multi; - dctx.ev = ev; - dctx.result = CURLE_OK; stream = H3_STREAM_CTX(ctx, data); - if(stream && stream->id == dctx.stream_id) { + if(stream && stream->id == (uint64_t)rv) { /* event for calling transfer */ - CURLcode result = cf_quiche_ev_process(cf, data, stream, ev); + cf_quiche_process_ev(cf, data, stream, ev); quiche_h3_event_free(ev); - if(result) - return result; + if(stream->xfer_result) + return stream->xfer_result; } else { /* another transfer, do not return errors, as they are not for * the calling transfer */ + struct cf_quich_disp_ctx dctx; + dctx.stream_id = (uint64_t)rv; + dctx.cf = cf; + dctx.multi = data->multi; + dctx.ev = ev; Curl_uint32_hash_visit(&ctx->streams, cf_quiche_disp_event, &dctx); quiche_h3_event_free(ev); } @@ -844,63 +855,46 @@ static CURLcode recv_closed_stream(struct Curl_cfilter *cf, } static CURLcode cf_quiche_recv(struct Curl_cfilter *cf, struct Curl_easy *data, - char *buf, size_t len, size_t *pnread) + char *buf, size_t blen, size_t *pnread) { struct cf_quiche_ctx *ctx = cf->ctx; struct h3_stream_ctx *stream = H3_STREAM_CTX(ctx, data); CURLcode result = CURLE_OK; *pnread = 0; + (void)buf; + (void)blen; vquic_ctx_update_time(&ctx->q); if(!stream) return CURLE_RECV_ERROR; - if(!Curl_bufq_is_empty(&stream->recvbuf)) { - result = Curl_bufq_cread(&stream->recvbuf, buf, len, pnread); - CURL_TRC_CF(data, cf, "[%" PRIu64 "] read recvbuf(len=%zu) " - "-> %d, %zu", stream->id, len, result, *pnread); - if(result) - goto out; - } - result = cf_process_ingress(cf, data); if(result) { CURL_TRC_CF(data, cf, "cf_recv, error on ingress"); goto out; } - /* recvbuf had nothing before, maybe after progressing ingress? */ - if(!*pnread && !Curl_bufq_is_empty(&stream->recvbuf)) { - result = Curl_bufq_cread(&stream->recvbuf, buf, len, pnread); - CURL_TRC_CF(data, cf, "[%" PRIu64 "] read recvbuf(len=%zu) " - "-> %d, %zu", stream->id, len, result, *pnread); - if(result) - goto out; - } - - if(*pnread) { - if(stream->closed) - Curl_multi_mark_dirty(data); + if(stream->xfer_result) { + cf_quiche_stream_close(cf, data, stream); + result = stream->xfer_result; + goto out; } - else { - if(stream->closed) - result = recv_closed_stream(cf, data, pnread); - else if(quiche_conn_is_draining(ctx->qconn)) { - failf(data, "QUIC connection is draining"); - result = CURLE_HTTP3; - } - else - result = CURLE_AGAIN; + else if(stream->closed) + result = recv_closed_stream(cf, data, pnread); + else if(quiche_conn_is_draining(ctx->qconn)) { + failf(data, "QUIC connection is draining"); + result = CURLE_HTTP3; } + else + result = CURLE_AGAIN; out: result = Curl_1st_err(result, cf_flush_egress(cf, data)); if(*pnread > 0) ctx->data_recvd += *pnread; - CURL_TRC_CF(data, cf, "[%" PRIu64 "] cf_recv(total=%" - FMT_OFF_T ") -> %d, %zu", - stream->id, ctx->data_recvd, result, *pnread); + CURL_TRC_CF(data, cf, "[%" PRIu64 "] cf_recv(len=%zu) -> %d, %zu, total=%" + FMT_OFF_T, stream->id, blen, result, *pnread, ctx->data_recvd); return result; } @@ -1092,6 +1086,10 @@ static CURLcode cf_quiche_send(struct Curl_cfilter *cf, struct Curl_easy *data, goto out; stream = H3_STREAM_CTX(ctx, data); } + else if(stream->xfer_result) { + cf_quiche_stream_close(cf, data, stream); + result = stream->xfer_result; + } else if(stream->closed) { if(stream->resp_hds_complete) { /* sending request body on a stream that has been closed by the @@ -1165,19 +1163,6 @@ static CURLcode cf_quiche_adjust_pollset(struct Curl_cfilter *cf, return result; } -/* - * Called from transfer.c:data_pending to know if we should keep looping - * to receive more data from the connection. - */ -static bool cf_quiche_data_pending(struct Curl_cfilter *cf, - const struct Curl_easy *data) -{ - struct cf_quiche_ctx *ctx = cf->ctx; - const struct h3_stream_ctx *stream = H3_STREAM_CTX(ctx, data); - (void)cf; - return stream && !Curl_bufq_is_empty(&stream->recvbuf); -} - static CURLcode h3_data_pause(struct Curl_cfilter *cf, struct Curl_easy *data, bool pause) @@ -1608,7 +1593,7 @@ struct Curl_cftype Curl_cft_http3 = { cf_quiche_close, cf_quiche_shutdown, cf_quiche_adjust_pollset, - cf_quiche_data_pending, + Curl_cf_def_data_pending, cf_quiche_send, cf_quiche_recv, cf_quiche_cntrl, From 3e2a946926853608d67805bd9f4a58345fff364a Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 2 Dec 2025 14:13:55 +0100 Subject: [PATCH 163/415] ldap: provide version for "legacy" ldap as well It displays in version output as WinLDAP and LDAP/1, compared to OpenLDAP/[version] for the OpenLDAP backend code. Closes #19808 --- lib/curl_ldap.h | 1 + lib/ldap.c | 9 +++++++++ lib/openldap.c | 20 ++++++++++++++++++++ lib/version.c | 32 +++++--------------------------- 4 files changed, 35 insertions(+), 27 deletions(-) diff --git a/lib/curl_ldap.h b/lib/curl_ldap.h index 8a1d807ed92b..9da9b717d529 100644 --- a/lib/curl_ldap.h +++ b/lib/curl_ldap.h @@ -32,5 +32,6 @@ extern const struct Curl_handler Curl_handler_ldap; extern const struct Curl_handler Curl_handler_ldaps; #endif +void Curl_ldap_version(char *buf, size_t bufsz); #endif #endif /* HEADER_CURL_LDAP_H */ diff --git a/lib/ldap.c b/lib/ldap.c index 6c6207038571..522bf3ad5860 100644 --- a/lib/ldap.c +++ b/lib/ldap.c @@ -1037,6 +1037,15 @@ static void ldap_free_urldesc_low(LDAPURLDesc *ludp) } #endif /* !HAVE_LDAP_URL_PARSE */ +void Curl_ldap_version(char *buf, size_t bufsz) +{ +#ifdef USE_WIN32_LDAP + curl_msnprintf(buf, bufsz, "WinLDAP"); +#else + curl_msnprintf(buf, bufsz, "LDAP/1"); +#endif +} + #if defined(__GNUC__) && defined(__APPLE__) #pragma GCC diagnostic pop #endif diff --git a/lib/openldap.c b/lib/openldap.c index 107f6da832a5..bb48edd32f2c 100644 --- a/lib/openldap.c +++ b/lib/openldap.c @@ -1331,4 +1331,24 @@ ldapsb_tls_write(Sockbuf_IO_Desc *sbiod, void *buf, ber_len_t len) } #endif /* USE_SSL */ +void Curl_ldap_version(char *buf, size_t bufsz) +{ + LDAPAPIInfo api; + api.ldapai_info_version = LDAP_API_INFO_VERSION; + + if(ldap_get_option(NULL, LDAP_OPT_API_INFO, &api) == LDAP_OPT_SUCCESS) { + unsigned int patch = (unsigned int)(api.ldapai_vendor_version % 100); + unsigned int major = (unsigned int)(api.ldapai_vendor_version / 10000); + unsigned int minor = + (((unsigned int)api.ldapai_vendor_version - major * 10000) + - patch) / 100; + curl_msnprintf(buf, bufsz, "%s/%u.%u.%u", + api.ldapai_vendor_name, major, minor, patch); + ldap_memfree(api.ldapai_vendor_name); + ber_memvfree((void **)api.ldapai_extensions); + } + else + curl_msnprintf(buf, bufsz, "OpenLDAP"); +} + #endif /* !CURL_DISABLE_LDAP && USE_OPENLDAP */ diff --git a/lib/version.c b/lib/version.c index 49c15ffcdec9..487dc74ffa15 100644 --- a/lib/version.c +++ b/lib/version.c @@ -77,8 +77,8 @@ #include #endif -#ifdef USE_OPENLDAP -#include +#ifndef CURL_DISABLE_LDAP +#include "curl_ldap.h" #endif #ifdef HAVE_BROTLI @@ -103,28 +103,6 @@ static void zstd_version(char *buf, size_t bufsz) } #endif -#ifdef USE_OPENLDAP -static void oldap_version(char *buf, size_t bufsz) -{ - LDAPAPIInfo api; - api.ldapai_info_version = LDAP_API_INFO_VERSION; - - if(ldap_get_option(NULL, LDAP_OPT_API_INFO, &api) == LDAP_OPT_SUCCESS) { - unsigned int patch = (unsigned int)(api.ldapai_vendor_version % 100); - unsigned int major = (unsigned int)(api.ldapai_vendor_version / 10000); - unsigned int minor = - (((unsigned int)api.ldapai_vendor_version - major * 10000) - - patch) / 100; - curl_msnprintf(buf, bufsz, "%s/%u.%u.%u", - api.ldapai_vendor_name, major, minor, patch); - ldap_memfree(api.ldapai_vendor_name); - ber_memvfree((void **)api.ldapai_extensions); - } - else - curl_msnprintf(buf, bufsz, "OpenLDAP"); -} -#endif - #ifdef USE_LIBPSL static void psl_version(char *buf, size_t bufsz) { @@ -211,7 +189,7 @@ char *curl_version(void) #ifdef HAVE_GSSAPI char gss_buf[40]; #endif -#ifdef USE_OPENLDAP +#ifndef CURL_DISABLE_LDAP char ldap_buf[30]; #endif int i = 0; @@ -289,8 +267,8 @@ char *curl_version(void) #endif src[i++] = gss_buf; #endif /* HAVE_GSSAPI */ -#ifdef USE_OPENLDAP - oldap_version(ldap_buf, sizeof(ldap_buf)); +#ifndef CURL_DISABLE_LDAP + Curl_ldap_version(ldap_buf, sizeof(ldap_buf)); src[i++] = ldap_buf; #endif From 86b346443b68cde7ef33e1ab770e6c8ab641d2b1 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Thu, 27 Nov 2025 04:27:26 +0100 Subject: [PATCH 164/415] lib: fix formatting nits (part 2) From `lib/curl*` to `lib/g*`. With fixes to part 1. part 1: 47a1ab2ebecb21485c0e955316d90511e80a3c43 #19764 Closes #19800 --- lib/altsvc.c | 2 +- lib/amigaos.h | 2 +- lib/asyn-ares.c | 3 +- lib/asyn-base.c | 4 +- lib/asyn.h | 4 +- lib/cf-h2-proxy.c | 4 +- lib/cf-https-connect.c | 1 - lib/cf-ip-happy.c | 1 - lib/cf-socket.c | 6 +- lib/cf-socket.h | 2 +- lib/conncache.c | 1 - lib/content_encoding.c | 61 ++-- lib/cookie.c | 15 +- lib/cookie.h | 2 +- lib/curl_addrinfo.c | 54 ++-- lib/curl_addrinfo.h | 31 +- lib/curl_ctype.h | 8 +- lib/curl_fopen.c | 4 +- lib/curl_get_line.c | 5 +- lib/curl_gethostname.c | 1 - lib/curl_gssapi.c | 4 +- lib/curl_hmac.h | 1 - lib/curl_ldap.h | 6 +- lib/curl_memrchr.c | 4 +- lib/curl_memrchr.h | 2 +- lib/curl_ntlm_core.c | 99 +++--- lib/curl_ntlm_core.h | 20 +- lib/curl_range.c | 8 +- lib/curl_rtmp.c | 6 +- lib/curl_sasl.c | 16 +- lib/curl_setup.h | 46 +-- lib/curl_setup_once.h | 48 +-- lib/curl_sha512_256.c | 160 +++++----- lib/curl_sha512_256.h | 5 +- lib/curl_share.c | 20 +- lib/curl_share.h | 6 +- lib/curl_trc.c | 44 ++- lib/curl_trc.h | 12 +- lib/cw-out.c | 2 +- lib/cw-pause.c | 2 +- lib/dict.c | 20 +- lib/doh.c | 62 ++-- lib/doh.h | 6 +- lib/dynhds.c | 11 +- lib/easy.c | 22 +- lib/easy_lock.h | 14 +- lib/easyoptions.c | 688 +++++++++++++++++++++-------------------- lib/escape.c | 10 +- lib/fake_addrinfo.c | 3 +- lib/file.c | 17 +- lib/formdata.c | 99 +++--- lib/formdata.h | 1 - lib/ftp.c | 336 ++++++++++---------- lib/ftplistparser.c | 20 +- lib/getinfo.c | 29 +- lib/optiontable.pl | 8 +- 56 files changed, 978 insertions(+), 1090 deletions(-) diff --git a/lib/altsvc.c b/lib/altsvc.c index cbaf4b4d85f9..f2906ad4e379 100644 --- a/lib/altsvc.c +++ b/lib/altsvc.c @@ -42,7 +42,7 @@ #include "curlx/strparse.h" #include "connect.h" -#define MAX_ALTSVC_LINE 4095 +#define MAX_ALTSVC_LINE 4095 #define MAX_ALTSVC_DATELEN 256 #define MAX_ALTSVC_HOSTLEN 2048 #define MAX_ALTSVC_ALPNLEN 10 diff --git a/lib/amigaos.h b/lib/amigaos.h index c99d963ececc..58278f093561 100644 --- a/lib/amigaos.h +++ b/lib/amigaos.h @@ -33,7 +33,7 @@ void Curl_amiga_cleanup(void); #else -#define Curl_amiga_init() CURLE_OK +#define Curl_amiga_init() CURLE_OK #define Curl_amiga_cleanup() Curl_nop_stmt #endif diff --git a/lib/asyn-ares.c b/lib/asyn-ares.c index ce4f866be6d2..40ce00db2229 100644 --- a/lib/asyn-ares.c +++ b/lib/asyn-ares.c @@ -180,8 +180,7 @@ static CURLcode async_ares_init(struct Curl_easy *data) status = ares_init_options(&ares->channel, &options, optmask); if(status != ARES_SUCCESS) { ares->channel = NULL; - rc = (status == ARES_ENOMEM) ? - CURLE_OUT_OF_MEMORY : CURLE_FAILED_INIT; + rc = (status == ARES_ENOMEM) ? CURLE_OUT_OF_MEMORY : CURLE_FAILED_INIT; goto out; } diff --git a/lib/asyn-base.c b/lib/asyn-base.c index 5358fcb8fa54..1db132c1e41d 100644 --- a/lib/asyn-base.c +++ b/lib/asyn-base.c @@ -168,9 +168,9 @@ int Curl_ares_perform(ares_channel channel, timediff_t timeout_ms) /* move through the descriptors and ask for processing on them */ for(i = 0; i < num; i++) ares_process_fd(channel, - (pfd[i].revents & (POLLRDNORM|POLLIN)) ? + (pfd[i].revents & (POLLRDNORM | POLLIN)) ? pfd[i].fd : ARES_SOCKET_BAD, - (pfd[i].revents & (POLLWRNORM|POLLOUT)) ? + (pfd[i].revents & (POLLWRNORM | POLLOUT)) ? pfd[i].fd : ARES_SOCKET_BAD); } return nfds; diff --git a/lib/asyn.h b/lib/asyn.h index e5e472e247db..87c6532a3d9d 100644 --- a/lib/asyn.h +++ b/lib/asyn.h @@ -223,7 +223,7 @@ struct doh_probes; /* convert these functions if an asynch resolver is not used */ #define Curl_async_get_impl(x, y) (*(y) = NULL, CURLE_OK) -#define Curl_async_is_resolved(x,y) CURLE_COULDNT_RESOLVE_HOST +#define Curl_async_is_resolved(x, y) CURLE_COULDNT_RESOLVE_HOST #define Curl_async_await(x, y) CURLE_COULDNT_RESOLVE_HOST #define Curl_async_global_init() CURLE_OK #define Curl_async_global_cleanup() Curl_nop_stmt @@ -266,7 +266,7 @@ void Curl_async_shutdown(struct Curl_easy *data); void Curl_async_destroy(struct Curl_easy *data); #else /* !USE_CURL_ASYNC */ #define Curl_async_shutdown(x) Curl_nop_stmt -#define Curl_async_destroy(x) Curl_nop_stmt +#define Curl_async_destroy(x) Curl_nop_stmt #endif /* USE_CURL_ASYNC */ /********** end of generic resolver interface functions *****************/ diff --git a/lib/cf-h2-proxy.c b/lib/cf-h2-proxy.c index fb2586d1d0e5..5a58c280e9f4 100644 --- a/lib/cf-h2-proxy.c +++ b/lib/cf-h2-proxy.c @@ -242,8 +242,8 @@ static int proxy_h2_client_new(struct Curl_cfilter *cf, { struct cf_h2_proxy_ctx *ctx = cf->ctx; nghttp2_option *o; - nghttp2_mem mem = {NULL, Curl_nghttp2_malloc, Curl_nghttp2_free, - Curl_nghttp2_calloc, Curl_nghttp2_realloc}; + nghttp2_mem mem = { NULL, Curl_nghttp2_malloc, Curl_nghttp2_free, + Curl_nghttp2_calloc, Curl_nghttp2_realloc }; int rc = nghttp2_option_new(&o); if(rc) diff --git a/lib/cf-https-connect.c b/lib/cf-https-connect.c index ad815a0fe734..acb3bcdd3a7a 100644 --- a/lib/cf-https-connect.c +++ b/lib/cf-https-connect.c @@ -244,7 +244,6 @@ static CURLcode baller_connected(struct Curl_cfilter *cf, return result; } - static bool time_to_start_next(struct Curl_cfilter *cf, struct Curl_easy *data, size_t idx, struct curltime now) diff --git a/lib/cf-ip-happy.c b/lib/cf-ip-happy.c index 72ac59b7d90b..d31c6b6caaa6 100644 --- a/lib/cf-ip-happy.c +++ b/lib/cf-ip-happy.c @@ -613,7 +613,6 @@ static int cf_ip_ballers_min_reply_ms(struct cf_ip_ballers *bs, return reply_ms; } - typedef enum { SCFST_INIT, SCFST_WAITING, diff --git a/lib/cf-socket.c b/lib/cf-socket.c index 0e431976c915..1881683cc8ed 100644 --- a/lib/cf-socket.c +++ b/lib/cf-socket.c @@ -643,8 +643,8 @@ static CURLcode bindlocal(struct Curl_easy *data, struct connectdata *conn, return CURLE_UNSUPPORTED_PROTOCOL; case IF2IP_FOUND: /* - * We now have the numerical IP address in the 'myhost' buffer - */ + * We now have the numerical IP address in the 'myhost' buffer + */ host = myhost; infof(data, "Local Interface %s is ip %s using address family %i", iface, host, af); @@ -2057,7 +2057,7 @@ static CURLcode cf_tcp_accept_connect(struct Curl_cfilter *cf, #else struct sockaddr_in add; #endif - curl_socklen_t size = (curl_socklen_t) sizeof(add); + curl_socklen_t size = (curl_socklen_t)sizeof(add); curl_socket_t s_accepted = CURL_SOCKET_BAD; timediff_t timeout_ms; int socketstate = 0; diff --git a/lib/cf-socket.h b/lib/cf-socket.h index e5f69c60f46f..fe5ff2fa47de 100644 --- a/lib/cf-socket.h +++ b/lib/cf-socket.h @@ -52,7 +52,7 @@ struct Curl_sockaddr_ex { struct Curl_sockaddr_storage buf; } addr; }; -#define curl_sa_addr addr.sa +#define curl_sa_addr addr.sa #define curl_sa_addrbuf addr.buf /* diff --git a/lib/conncache.c b/lib/conncache.c index c7a52b69f69a..c50697f177b6 100644 --- a/lib/conncache.c +++ b/lib/conncache.c @@ -77,7 +77,6 @@ struct cpool_bundle { char dest[1]; /* destination of bundle, allocated to keep dest_len bytes */ }; - static void cpool_discard_conn(struct cpool *cpool, struct Curl_easy *data, struct connectdata *conn, diff --git a/lib/content_encoding.c b/lib/content_encoding.c index 84ed86c1df3d..47adac0f4302 100644 --- a/lib/content_encoding.c +++ b/lib/content_encoding.c @@ -86,24 +86,20 @@ struct zlib_writer { z_stream z; /* State structure for zlib. */ }; - -static voidpf -zalloc_cb(voidpf opaque, unsigned int items, unsigned int size) +static voidpf zalloc_cb(voidpf opaque, unsigned int items, unsigned int size) { (void)opaque; /* not a typo, keep it curlx_calloc() */ return (voidpf)curlx_calloc(items, size); } -static void -zfree_cb(voidpf opaque, voidpf ptr) +static void zfree_cb(voidpf opaque, voidpf ptr) { (void)opaque; curlx_free(ptr); } -static CURLcode -process_zlib_error(struct Curl_easy *data, z_stream *z) +static CURLcode process_zlib_error(struct Curl_easy *data, z_stream *z) { if(z->msg) failf(data, "Error while processing content unencoding: %s", @@ -115,9 +111,8 @@ process_zlib_error(struct Curl_easy *data, z_stream *z) return CURLE_BAD_CONTENT_ENCODING; } -static CURLcode -exit_zlib(struct Curl_easy *data, - z_stream *z, zlibInitState *zlib_init, CURLcode result) +static CURLcode exit_zlib(struct Curl_easy *data, z_stream *z, + zlibInitState *zlib_init, CURLcode result) { if(*zlib_init != ZLIB_UNINIT) { if(inflateEnd(z) != Z_OK && result == CURLE_OK) @@ -128,8 +123,7 @@ exit_zlib(struct Curl_easy *data, return result; } -static CURLcode process_trailer(struct Curl_easy *data, - struct zlib_writer *zp) +static CURLcode process_trailer(struct Curl_easy *data, struct zlib_writer *zp) { z_stream *z = &zp->z; CURLcode result = CURLE_OK; @@ -156,7 +150,7 @@ static CURLcode inflate_stream(struct Curl_easy *data, struct Curl_cwriter *writer, int type, zlibInitState started) { - struct zlib_writer *zp = (struct zlib_writer *) writer; + struct zlib_writer *zp = (struct zlib_writer *)writer; z_stream *z = &zp->z; /* zlib state structure */ uInt nread = z->avail_in; z_const Bytef *orig_in = z->next_in; @@ -176,7 +170,7 @@ static CURLcode inflate_stream(struct Curl_easy *data, done = TRUE; /* (re)set buffer for decompressed output for every iteration */ - z->next_out = (Bytef *) zp->buffer; + z->next_out = (Bytef *)zp->buffer; z->avail_out = DECOMPRESS_BUFFER_SIZE; status = inflate(z, Z_BLOCK); @@ -237,17 +231,16 @@ static CURLcode inflate_stream(struct Curl_easy *data, return result; } - /* Deflate handler. */ static CURLcode deflate_do_init(struct Curl_easy *data, struct Curl_cwriter *writer) { - struct zlib_writer *zp = (struct zlib_writer *) writer; + struct zlib_writer *zp = (struct zlib_writer *)writer; z_stream *z = &zp->z; /* zlib state structure */ /* Initialize zlib */ - z->zalloc = (alloc_func) zalloc_cb; - z->zfree = (free_func) zfree_cb; + z->zalloc = (alloc_func)zalloc_cb; + z->zfree = (free_func)zfree_cb; if(inflateInit(z) != Z_OK) return process_zlib_error(data, z); @@ -259,7 +252,7 @@ static CURLcode deflate_do_write(struct Curl_easy *data, struct Curl_cwriter *writer, int type, const char *buf, size_t nbytes) { - struct zlib_writer *zp = (struct zlib_writer *) writer; + struct zlib_writer *zp = (struct zlib_writer *)writer; z_stream *z = &zp->z; /* zlib state structure */ if(!(type & CLIENTWRITE_BODY) || !nbytes) @@ -279,7 +272,7 @@ static CURLcode deflate_do_write(struct Curl_easy *data, static void deflate_do_close(struct Curl_easy *data, struct Curl_cwriter *writer) { - struct zlib_writer *zp = (struct zlib_writer *) writer; + struct zlib_writer *zp = (struct zlib_writer *)writer; z_stream *z = &zp->z; /* zlib state structure */ exit_zlib(data, z, &zp->zlib_init, CURLE_OK); @@ -299,12 +292,12 @@ static const struct Curl_cwtype deflate_encoding = { static CURLcode gzip_do_init(struct Curl_easy *data, struct Curl_cwriter *writer) { - struct zlib_writer *zp = (struct zlib_writer *) writer; + struct zlib_writer *zp = (struct zlib_writer *)writer; z_stream *z = &zp->z; /* zlib state structure */ /* Initialize zlib */ - z->zalloc = (alloc_func) zalloc_cb; - z->zfree = (free_func) zfree_cb; + z->zalloc = (alloc_func)zalloc_cb; + z->zfree = (free_func)zfree_cb; if(inflateInit2(z, MAX_WBITS + 32) != Z_OK) return process_zlib_error(data, z); @@ -317,7 +310,7 @@ static CURLcode gzip_do_write(struct Curl_easy *data, struct Curl_cwriter *writer, int type, const char *buf, size_t nbytes) { - struct zlib_writer *zp = (struct zlib_writer *) writer; + struct zlib_writer *zp = (struct zlib_writer *)writer; z_stream *z = &zp->z; /* zlib state structure */ if(!(type & CLIENTWRITE_BODY) || !nbytes) @@ -338,7 +331,7 @@ static CURLcode gzip_do_write(struct Curl_easy *data, static void gzip_do_close(struct Curl_easy *data, struct Curl_cwriter *writer) { - struct zlib_writer *zp = (struct zlib_writer *) writer; + struct zlib_writer *zp = (struct zlib_writer *)writer; z_stream *z = &zp->z; /* zlib state structure */ exit_zlib(data, z, &zp->zlib_init, CURLE_OK); @@ -402,7 +395,7 @@ static CURLcode brotli_map_error(BrotliDecoderErrorCode be) static CURLcode brotli_do_init(struct Curl_easy *data, struct Curl_cwriter *writer) { - struct brotli_writer *bp = (struct brotli_writer *) writer; + struct brotli_writer *bp = (struct brotli_writer *)writer; (void)data; bp->br = BrotliDecoderCreateInstance(NULL, NULL, NULL); @@ -413,8 +406,8 @@ static CURLcode brotli_do_write(struct Curl_easy *data, struct Curl_cwriter *writer, int type, const char *buf, size_t nbytes) { - struct brotli_writer *bp = (struct brotli_writer *) writer; - const uint8_t *src = (const uint8_t *) buf; + struct brotli_writer *bp = (struct brotli_writer *)writer; + const uint8_t *src = (const uint8_t *)buf; uint8_t *dst; size_t dstleft; CURLcode result = CURLE_OK; @@ -428,7 +421,7 @@ static CURLcode brotli_do_write(struct Curl_easy *data, while((nbytes || r == BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT) && result == CURLE_OK) { - dst = (uint8_t *) bp->buffer; + dst = (uint8_t *)bp->buffer; dstleft = DECOMPRESS_BUFFER_SIZE; r = BrotliDecoderDecompressStream(bp->br, &nbytes, &src, &dstleft, &dst, NULL); @@ -457,7 +450,7 @@ static CURLcode brotli_do_write(struct Curl_easy *data, static void brotli_do_close(struct Curl_easy *data, struct Curl_cwriter *writer) { - struct brotli_writer *bp = (struct brotli_writer *) writer; + struct brotli_writer *bp = (struct brotli_writer *)writer; (void)data; if(bp->br) { @@ -501,7 +494,7 @@ static void Curl_zstd_free(void *opaque, void *address) static CURLcode zstd_do_init(struct Curl_easy *data, struct Curl_cwriter *writer) { - struct zstd_writer *zp = (struct zstd_writer *) writer; + struct zstd_writer *zp = (struct zstd_writer *)writer; (void)data; @@ -523,7 +516,7 @@ static CURLcode zstd_do_write(struct Curl_easy *data, const char *buf, size_t nbytes) { CURLcode result = CURLE_OK; - struct zstd_writer *zp = (struct zstd_writer *) writer; + struct zstd_writer *zp = (struct zstd_writer *)writer; ZSTD_inBuffer in; ZSTD_outBuffer out; size_t errorCode; @@ -560,7 +553,7 @@ static CURLcode zstd_do_write(struct Curl_easy *data, static void zstd_do_close(struct Curl_easy *data, struct Curl_cwriter *writer) { - struct zstd_writer *zp = (struct zstd_writer *) writer; + struct zstd_writer *zp = (struct zstd_writer *)writer; (void)data; if(zp->zds) { @@ -614,7 +607,7 @@ static const struct Curl_cwtype * const transfer_unencoders[] = { }; /* Provide a list of comma-separated names of supported encodings. -*/ + */ void Curl_all_content_encodings(char *buf, size_t blen) { size_t len = 0; diff --git a/lib/cookie.c b/lib/cookie.c index 81a57942b245..e3cf8e4e0cf1 100644 --- a/lib/cookie.c +++ b/lib/cookie.c @@ -661,13 +661,12 @@ parse_cookie_header(struct Curl_easy *data, return CURLE_OK; } -static CURLcode -parse_netscape(struct Cookie *co, - struct CookieInfo *ci, - bool *okay, - const char *lineptr, - bool secure) /* TRUE if connection is over secure - origin */ +static CURLcode parse_netscape(struct Cookie *co, + struct CookieInfo *ci, + bool *okay, + const char *lineptr, + bool secure) /* TRUE if connection is over + secure origin */ { /* * This line is NOT an HTTP header style line, we do offer support for @@ -1247,7 +1246,7 @@ static int cookie_sort_ct(const void *p1, const void *p2) bool Curl_secure_context(struct connectdata *conn, const char *host) { - return conn->handler->protocol&(CURLPROTO_HTTPS|CURLPROTO_WSS) || + return conn->handler->protocol & (CURLPROTO_HTTPS | CURLPROTO_WSS) || curl_strequal("localhost", host) || !strcmp(host, "127.0.0.1") || !strcmp(host, "::1"); diff --git a/lib/cookie.h b/lib/cookie.h index 5e9f5f7823ce..c1fb23ee4c23 100644 --- a/lib/cookie.h +++ b/lib/cookie.h @@ -52,7 +52,7 @@ struct Cookie { * draft-ietf-httpbis-rfc6265bis-02 */ #define COOKIE_PREFIX__SECURE (1 << 0) -#define COOKIE_PREFIX__HOST (1 << 1) +#define COOKIE_PREFIX__HOST (1 << 1) #define COOKIE_HASH_SIZE 63 diff --git a/lib/curl_addrinfo.c b/lib/curl_addrinfo.c index 67c2f4177d5f..7993631bf1f8 100644 --- a/lib/curl_addrinfo.c +++ b/lib/curl_addrinfo.c @@ -71,8 +71,7 @@ # define vqualifier #endif -void -Curl_freeaddrinfo(struct Curl_addrinfo *cahead) +void Curl_freeaddrinfo(struct Curl_addrinfo *cahead) { struct Curl_addrinfo *vqualifier canext; struct Curl_addrinfo *ca; @@ -83,7 +82,6 @@ Curl_freeaddrinfo(struct Curl_addrinfo *cahead) } } - #ifdef HAVE_GETADDRINFO /* * Curl_getaddrinfo_ex() @@ -98,12 +96,10 @@ Curl_freeaddrinfo(struct Curl_addrinfo *cahead) * There should be no single call to system's getaddrinfo() in the * whole library, any such call should be 'routed' through this one. */ - -int -Curl_getaddrinfo_ex(const char *nodename, - const char *servname, - const struct addrinfo *hints, - struct Curl_addrinfo **result) +int Curl_getaddrinfo_ex(const char *nodename, + const char *servname, + const struct addrinfo *hints, + struct Curl_addrinfo **result) { const struct addrinfo *ai; struct addrinfo *aihead; @@ -176,7 +172,6 @@ Curl_getaddrinfo_ex(const char *nodename, if(calast) calast->ai_next = ca; calast = ca; - } /* destroy the addrinfo list */ @@ -208,7 +203,6 @@ Curl_getaddrinfo_ex(const char *nodename, } #endif /* HAVE_GETADDRINFO */ - /* * Curl_he2ai() * @@ -248,10 +242,8 @@ Curl_getaddrinfo_ex(const char *nodename, * * #define h_addr h_addr_list[0] */ - #if !(defined(HAVE_GETADDRINFO) && defined(HAVE_GETADDRINFO_THREADSAFE)) -struct Curl_addrinfo * -Curl_he2ai(const struct hostent *he, int port) +struct Curl_addrinfo *Curl_he2ai(const struct hostent *he, int port) { struct Curl_addrinfo *ai; struct Curl_addrinfo *prevai = NULL; @@ -350,10 +342,8 @@ Curl_he2ai(const struct hostent *he, int port) * returns a Curl_addrinfo chain filled in correctly with information for the * given address/host */ - -static CURLcode -ip2addr(struct Curl_addrinfo **addrp, - int af, const void *inaddr, const char *hostname, int port) +static CURLcode ip2addr(struct Curl_addrinfo **addrp, int af, + const void *inaddr, const char *hostname, int port) { struct Curl_addrinfo *ai; size_t addrsize; @@ -473,7 +463,7 @@ struct Curl_addrinfo *Curl_unix2addr(const char *path, bool *longpath, return NULL; ai->ai_addr = (void *)((char *)ai + sizeof(struct Curl_addrinfo)); - sa_un = (void *) ai->ai_addr; + sa_un = (void *)ai->ai_addr; sa_un->sun_family = AF_UNIX; /* sun_path must be able to store the null-terminated path */ @@ -508,10 +498,8 @@ struct Curl_addrinfo *Curl_unix2addr(const char *path, bool *longpath, * family otherwise present in memdebug.c. I put these ones here since they * require a bunch of structs I did not want to include in memdebug.c */ - -void -curl_dbg_freeaddrinfo(struct addrinfo *freethis, - int line, const char *source) +void curl_dbg_freeaddrinfo(struct addrinfo *freethis, + int line, const char *source) { curl_dbg_log("ADDR %s:%d freeaddrinfo(%p)\n", source, line, (void *)freethis); @@ -533,7 +521,6 @@ curl_dbg_freeaddrinfo(struct addrinfo *freethis, } #endif /* CURLDEBUG && HAVE_FREEADDRINFO */ - #if defined(CURLDEBUG) && defined(HAVE_GETADDRINFO) /* * curl_dbg_getaddrinfo() @@ -542,13 +529,11 @@ curl_dbg_freeaddrinfo(struct addrinfo *freethis, * family otherwise present in memdebug.c. I put these ones here since they * require a bunch of structs I did not want to include in memdebug.c */ - -int -curl_dbg_getaddrinfo(const char *hostname, - const char *service, - const struct addrinfo *hints, - struct addrinfo **result, - int line, const char *source) +int curl_dbg_getaddrinfo(const char *hostname, + const char *service, + const struct addrinfo *hints, + struct addrinfo **result, + int line, const char *source) { #ifdef USE_LWIPSOCK int res = lwip_getaddrinfo(hostname, service, hints, result); @@ -566,11 +551,10 @@ curl_dbg_getaddrinfo(const char *hostname, #endif if(res == 0) /* success */ - curl_dbg_log("ADDR %s:%d getaddrinfo() = %p\n", - source, line, (void *)*result); + curl_dbg_log("ADDR %s:%d getaddrinfo() = %p\n", source, line, + (void *)*result); else - curl_dbg_log("ADDR %s:%d getaddrinfo() failed\n", - source, line); + curl_dbg_log("ADDR %s:%d getaddrinfo() failed\n", source, line); return res; } #endif /* CURLDEBUG && HAVE_GETADDRINFO */ diff --git a/lib/curl_addrinfo.h b/lib/curl_addrinfo.h index 9a26c6784912..378b31ed05da 100644 --- a/lib/curl_addrinfo.h +++ b/lib/curl_addrinfo.h @@ -60,20 +60,17 @@ struct Curl_addrinfo { struct Curl_addrinfo *ai_next; }; -void -Curl_freeaddrinfo(struct Curl_addrinfo *cahead); +void 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); +int Curl_getaddrinfo_ex(const char *nodename, + const char *servname, + const struct addrinfo *hints, + struct Curl_addrinfo **result); #endif #if !(defined(HAVE_GETADDRINFO) && defined(HAVE_GETADDRINFO_THREADSAFE)) -struct Curl_addrinfo * -Curl_he2ai(const struct hostent *he, int port); +struct Curl_addrinfo *Curl_he2ai(const struct hostent *he, int port); #endif bool Curl_is_ipaddr(const char *address); @@ -85,23 +82,23 @@ struct Curl_addrinfo *Curl_unix2addr(const char *path, bool *longpath, #endif #if defined(CURLDEBUG) && defined(HAVE_GETADDRINFO) && \ - defined(HAVE_FREEADDRINFO) -void -curl_dbg_freeaddrinfo(struct addrinfo *freethis, int line, const char *source); + defined(HAVE_FREEADDRINFO) +void curl_dbg_freeaddrinfo(struct addrinfo *freethis, int line, + const char *source); #endif #if defined(CURLDEBUG) && defined(HAVE_GETADDRINFO) -int -curl_dbg_getaddrinfo(const char *hostname, const char *service, - const struct addrinfo *hints, struct addrinfo **result, - int line, const char *source); +int curl_dbg_getaddrinfo(const char *hostname, const char *service, + const struct addrinfo *hints, + struct addrinfo **result, int line, + const char *source); #endif #ifdef HAVE_GETADDRINFO #ifdef USE_RESOLVE_ON_IPS void Curl_addrinfo_set_port(struct Curl_addrinfo *addrinfo, int port); #else -#define Curl_addrinfo_set_port(x,y) +#define Curl_addrinfo_set_port(x, y) #endif #endif diff --git a/lib/curl_ctype.h b/lib/curl_ctype.h index 48c3c37c359c..153a8f9c6cdc 100644 --- a/lib/curl_ctype.h +++ b/lib/curl_ctype.h @@ -25,17 +25,17 @@ ***************************************************************************/ #define ISLOWHEXALHA(x) (((x) >= 'a') && ((x) <= 'f')) -#define ISUPHEXALHA(x) (((x) >= 'A') && ((x) <= 'F')) +#define ISUPHEXALHA(x) (((x) >= 'A') && ((x) <= 'F')) #define ISLOWCNTRL(x) ((unsigned char)(x) <= 0x1f) -#define IS7F(x) ((x) == 0x7f) +#define IS7F(x) ((x) == 0x7f) #define ISLOWPRINT(x) (((x) >= 9) && ((x) <= 0x0d)) #define ISPRINT(x) (ISLOWPRINT(x) || (((x) >= ' ') && ((x) <= 0x7e))) #define ISGRAPH(x) (ISLOWPRINT(x) || (((x) > ' ') && ((x) <= 0x7e))) -#define ISCNTRL(x) (ISLOWCNTRL(x) || IS7F(x)) -#define ISALPHA(x) (ISLOWER(x) || ISUPPER(x)) +#define ISCNTRL(x) (ISLOWCNTRL(x) || IS7F(x)) +#define ISALPHA(x) (ISLOWER(x) || ISUPPER(x)) #define ISXDIGIT(x) (ISDIGIT(x) || ISLOWHEXALHA(x) || ISUPHEXALHA(x)) #define ISODIGIT(x) (((x) >= '0') && ((x) <= '7')) #define ISALNUM(x) (ISDIGIT(x) || ISLOWER(x) || ISUPPER(x)) diff --git a/lib/curl_fopen.c b/lib/curl_fopen.c index cccf849acb7d..383b307e2120 100644 --- a/lib/curl_fopen.c +++ b/lib/curl_fopen.c @@ -62,10 +62,10 @@ static char *dirslash(const char *path) n = strlen(path); if(n) { /* find the rightmost path separator, if any */ - while(n && !IS_SEP(path[n-1])) + while(n && !IS_SEP(path[n - 1])) --n; /* skip over all the path separators, if any */ - while(n && IS_SEP(path[n-1])) + while(n && IS_SEP(path[n - 1])) --n; } if(curlx_dyn_addn(&out, path, n)) diff --git a/lib/curl_get_line.c b/lib/curl_get_line.c index ea31eb182fa3..5e553f4d31de 100644 --- a/lib/curl_get_line.c +++ b/lib/curl_get_line.c @@ -29,8 +29,7 @@ #include "curl_get_line.h" -#define appendnl(b) \ - curlx_dyn_addn(buf, "\n", 1) +#define appendnl(b) curlx_dyn_addn(buf, "\n", 1) /* * Curl_get_line() returns only complete whole lines that end with newline. @@ -57,7 +56,7 @@ CURLcode Curl_get_line(struct dynbuf *buf, FILE *input, bool *eof) /* now check the full line */ rlen = curlx_dyn_len(buf); b = curlx_dyn_ptr(buf); - if(rlen && (b[rlen-1] == '\n')) + if(rlen && (b[rlen - 1] == '\n')) /* LF at end of the line */ return CURLE_OK; /* all good */ if(*eof) diff --git a/lib/curl_gethostname.c b/lib/curl_gethostname.c index 9f2624ff051d..e339e6079882 100644 --- a/lib/curl_gethostname.c +++ b/lib/curl_gethostname.c @@ -93,5 +93,4 @@ int Curl_gethostname(char * const name, GETHOSTNAME_TYPE_ARG2 namelen) return 0; #endif - } diff --git a/lib/curl_gssapi.c b/lib/curl_gssapi.c index 7f5bd72954aa..31addb8fbc7f 100644 --- a/lib/curl_gssapi.c +++ b/lib/curl_gssapi.c @@ -154,7 +154,7 @@ stub_gss_init_sec_context(OM_uint32 *min, } /* Server response, either D (RA==) or C (Qw==) */ - if(((char *) input_token->value)[0] == 'D') { + if(((char *)input_token->value)[0] == 'D') { /* Done */ switch(ctx->sent) { case STUB_GSS_KRB5: @@ -170,7 +170,7 @@ stub_gss_init_sec_context(OM_uint32 *min, } } - if(((char *) input_token->value)[0] != 'C') { + if(((char *)input_token->value)[0] != 'C') { /* We only support Done or Continue */ *min = STUB_GSS_SERVER_ERR; return GSS_S_FAILURE; diff --git a/lib/curl_hmac.h b/lib/curl_hmac.h index 9675c6c54259..285846afe705 100644 --- a/lib/curl_hmac.h +++ b/lib/curl_hmac.h @@ -56,7 +56,6 @@ struct HMAC_context { void *hashctxt2; /* Hash function context 2. */ }; - /* Prototypes. */ struct HMAC_context *Curl_HMAC_init(const struct HMAC_params *hashparams, const unsigned char *key, diff --git a/lib/curl_ldap.h b/lib/curl_ldap.h index 9da9b717d529..5ef32a5a30ae 100644 --- a/lib/curl_ldap.h +++ b/lib/curl_ldap.h @@ -26,9 +26,9 @@ #ifndef CURL_DISABLE_LDAP extern const struct Curl_handler Curl_handler_ldap; -#if !defined(CURL_DISABLE_LDAPS) && \ - ((defined(USE_OPENLDAP) && defined(USE_SSL)) || \ - (!defined(USE_OPENLDAP) && defined(HAVE_LDAP_SSL))) +#if !defined(CURL_DISABLE_LDAPS) && \ + ((defined(USE_OPENLDAP) && defined(USE_SSL)) || \ + (!defined(USE_OPENLDAP) && defined(HAVE_LDAP_SSL))) extern const struct Curl_handler Curl_handler_ldaps; #endif diff --git a/lib/curl_memrchr.c b/lib/curl_memrchr.c index 81464584070c..d8b4eef9f40b 100644 --- a/lib/curl_memrchr.c +++ b/lib/curl_memrchr.c @@ -37,9 +37,7 @@ * backwards from the end of the n bytes pointed to by s instead of forward * from the beginning. */ - -void * -Curl_memrchr(const void *s, int c, size_t n) +void *Curl_memrchr(const void *s, int c, size_t n) { if(n > 0) { const unsigned char *p = s; diff --git a/lib/curl_memrchr.h b/lib/curl_memrchr.h index 3c7dda96ac98..73bd346cdee6 100644 --- a/lib/curl_memrchr.h +++ b/lib/curl_memrchr.h @@ -35,7 +35,7 @@ #else /* HAVE_MEMRCHR */ void *Curl_memrchr(const void *s, int c, size_t n); -#define memrchr(x,y,z) Curl_memrchr((x),(y),(z)) +#define memrchr(x, y, z) Curl_memrchr((x), (y), (z)) #endif /* HAVE_MEMRCHR */ diff --git a/lib/curl_ntlm_core.c b/lib/curl_ntlm_core.c index f2c8c2d2a659..8bb273693d30 100644 --- a/lib/curl_ntlm_core.c +++ b/lib/curl_ntlm_core.c @@ -53,7 +53,7 @@ #ifdef USE_MBEDTLS #include #if MBEDTLS_VERSION_NUMBER < 0x03020000 - #error "mbedTLS 3.2.0 or later required" +#error "mbedTLS 3.2.0 or later required" #endif #endif @@ -81,13 +81,13 @@ # include # include # ifdef OPENSSL_COEXIST -# define DES_key_schedule WOLFSSL_DES_key_schedule -# define DES_cblock WOLFSSL_DES_cblock -# define DES_set_odd_parity wolfSSL_DES_set_odd_parity -# define DES_set_key wolfSSL_DES_set_key +# define DES_key_schedule WOLFSSL_DES_key_schedule +# define DES_cblock WOLFSSL_DES_cblock +# define DES_set_odd_parity wolfSSL_DES_set_odd_parity +# define DES_set_key wolfSSL_DES_set_key # define DES_set_key_unchecked wolfSSL_DES_set_key_unchecked -# define DES_ecb_encrypt wolfSSL_DES_ecb_encrypt -# define DESKEY(x) ((WOLFSSL_DES_key_schedule *)(x)) +# define DES_ecb_encrypt wolfSSL_DES_ecb_encrypt +# define DESKEY(x) ((WOLFSSL_DES_key_schedule *)(x)) # else # define DESKEY(x) &x # endif @@ -161,8 +161,8 @@ static void curl_des_set_odd_parity(unsigned char *bytes, size_t len) #endif /* USE_CURL_DES_SET_ODD_PARITY */ /* -* Turns a 56-bit key into being 64-bit wide. -*/ + * Turns a 56-bit key into being 64-bit wide. + */ static void extend_key_56_to_64(const unsigned char *key_56, char *key) { key[0] = (char)key_56[0]; @@ -186,7 +186,7 @@ static void setup_des_key(const unsigned char *key_56, DES_cblock key; /* Expand the 56-bit key to 64 bits */ - extend_key_56_to_64(key_56, (char *) &key); + extend_key_56_to_64(key_56, (char *)&key); /* Set the key parity to odd */ DES_set_odd_parity(&key); @@ -197,8 +197,7 @@ static void setup_des_key(const unsigned char *key_56, #elif defined(USE_GNUTLS) -static void setup_des_key(const unsigned char *key_56, - struct des_ctx *des) +static void setup_des_key(const unsigned char *key_56, struct des_ctx *des) { char key[8]; @@ -206,10 +205,10 @@ static void setup_des_key(const unsigned char *key_56, extend_key_56_to_64(key_56, key); /* Set the key parity to odd */ - curl_des_set_odd_parity((unsigned char *) key, sizeof(key)); + curl_des_set_odd_parity((unsigned char *)key, sizeof(key)); /* Set the key */ - des_set_key(des, (const uint8_t *) key); + des_set_key(des, (const uint8_t *)key); } #elif defined(USE_MBEDTLS_DES) @@ -224,11 +223,11 @@ static bool encrypt_des(const unsigned char *in, unsigned char *out, extend_key_56_to_64(key_56, key); /* Set the key parity to odd */ - mbedtls_des_key_set_parity((unsigned char *) key); + mbedtls_des_key_set_parity((unsigned char *)key); /* Perform the encryption */ mbedtls_des_init(&ctx); - mbedtls_des_setkey_enc(&ctx, (unsigned char *) key); + mbedtls_des_setkey_enc(&ctx, (unsigned char *)key); return mbedtls_des_crypt_ecb(&ctx, in, out) == 0; } @@ -248,10 +247,10 @@ static bool encrypt_des(const unsigned char *in, unsigned char *out, extend_key_56_to_64(key_56, ctl.Crypto_Key); /* Set the key parity to odd */ - curl_des_set_odd_parity((unsigned char *) ctl.Crypto_Key, ctl.Data_Len); + curl_des_set_odd_parity((unsigned char *)ctl.Crypto_Key, ctl.Data_Len); /* Perform the encryption */ - _CIPHER((_SPCPTR *) &out, &ctl, (_SPCPTR *) &in); + _CIPHER((_SPCPTR *)&out, &ctl, (_SPCPTR *)&in); return TRUE; } @@ -286,10 +285,10 @@ static bool encrypt_des(const unsigned char *in, unsigned char *out, extend_key_56_to_64(key_56, blob.key); /* Set the key parity to odd */ - curl_des_set_odd_parity((unsigned char *) blob.key, sizeof(blob.key)); + curl_des_set_odd_parity((unsigned char *)blob.key, sizeof(blob.key)); /* Import the key */ - if(!CryptImportKey(hprov, (BYTE *) &blob, sizeof(blob), 0, 0, &hkey)) { + if(!CryptImportKey(hprov, (BYTE *)&blob, sizeof(blob), 0, 0, &hkey)) { CryptReleaseContext(hprov, 0); return FALSE; @@ -308,11 +307,11 @@ static bool encrypt_des(const unsigned char *in, unsigned char *out, #endif /* USE_WIN32_CRYPTO */ - /* - * takes a 21 byte array and treats it as 3 56-bit DES keys. The - * 8 byte plaintext is encrypted with each key and the resulting 24 - * bytes are stored in the results array. - */ +/* + * takes a 21 byte array and treats it as 3 56-bit DES keys. The + * 8 byte plaintext is encrypted with each key and the resulting 24 + * bytes are stored in the results array. + */ void Curl_ntlm_core_lm_resp(const unsigned char *keys, const unsigned char *plaintext, unsigned char *results) @@ -321,16 +320,16 @@ void Curl_ntlm_core_lm_resp(const unsigned char *keys, DES_key_schedule ks; setup_des_key(keys, DESKEY(ks)); - DES_ecb_encrypt((DES_cblock*)CURL_UNCONST(plaintext), - (DES_cblock*)results, DESKEY(ks), DES_ENCRYPT); + DES_ecb_encrypt((DES_cblock *)CURL_UNCONST(plaintext), + (DES_cblock *)results, DESKEY(ks), DES_ENCRYPT); setup_des_key(keys + 7, DESKEY(ks)); - DES_ecb_encrypt((DES_cblock*)CURL_UNCONST(plaintext), - (DES_cblock*)(results + 8), DESKEY(ks), DES_ENCRYPT); + DES_ecb_encrypt((DES_cblock *)CURL_UNCONST(plaintext), + (DES_cblock *)(results + 8), DESKEY(ks), DES_ENCRYPT); setup_des_key(keys + 14, DESKEY(ks)); - DES_ecb_encrypt((DES_cblock*)CURL_UNCONST(plaintext), - (DES_cblock*)(results + 16), DESKEY(ks), DES_ENCRYPT); + DES_ecb_encrypt((DES_cblock *)CURL_UNCONST(plaintext), + (DES_cblock *)(results + 16), DESKEY(ks), DES_ENCRYPT); #elif defined(USE_GNUTLS) struct des_ctx des; setup_des_key(keys, &des); @@ -431,7 +430,7 @@ CURLcode Curl_ntlm_core_mk_nt_hash(const char *password, size_t len = strlen(password); unsigned char *pw; CURLcode result; - if(len > SIZE_MAX/2) /* avoid integer overflow */ + if(len > SIZE_MAX / 2) /* avoid integer overflow */ return CURLE_OUT_OF_MEMORY; pw = len ? curlx_malloc(len * 2) : (unsigned char *)curlx_strdup(""); if(!pw) @@ -452,7 +451,7 @@ CURLcode Curl_ntlm_core_mk_nt_hash(const char *password, #ifndef USE_WINDOWS_SSPI #define NTLMv2_BLOB_SIGNATURE "\x01\x01\x00\x00" -#define NTLMv2_BLOB_LEN (44 -16 + ntlm->target_info_len + 4) +#define NTLMv2_BLOB_LEN (44 - 16 + ntlm->target_info_len + 4) /* Timestamp in tenths of a microsecond since January 1, 1601 00:00:00 UTC. */ struct ms_filetime { @@ -474,11 +473,11 @@ static void time2filetime(struct ms_filetime *ft, time_t t) ft->dwLowDateTime = (unsigned int)(t & 0xFFFFFFFF); ft->dwHighDateTime = 0; -# ifndef HAVE_TIME_T_UNSIGNED +#ifndef HAVE_TIME_T_UNSIGNED /* Extend sign if needed. */ if(ft->dwLowDateTime & 0x80000000) ft->dwHighDateTime = ~(unsigned int)0; -# endif +#endif /* Bias seconds to Jan 1, 1601. 134774 days = 11644473600 seconds = 0x2B6109100 */ @@ -559,20 +558,20 @@ CURLcode Curl_ntlm_core_mk_ntlmv2_resp(unsigned char *ntlmv2hash, unsigned char **ntresp, unsigned int *ntresp_len) { -/* NTLMv2 response structure : ------------------------------------------------------------------------------- -0 HMAC MD5 16 bytes -------BLOB-------------------------------------------------------------------- -16 Signature 0x01010000 -20 Reserved long (0x00000000) -24 Timestamp LE, 64-bit signed value representing the number of - tenths of a microsecond since January 1, 1601. -32 Client Nonce 8 bytes -40 Unknown 4 bytes -44 Target Info N bytes (from the type-2 message) -44+N Unknown 4 bytes ------------------------------------------------------------------------------- -*/ + /* NTLMv2 response structure : + ----------------------------------------------------------------------------- + 0 HMAC MD5 16 bytes + ------BLOB------------------------------------------------------------------- + 16 Signature 0x01010000 + 20 Reserved long (0x00000000) + 24 Timestamp LE, 64-bit signed value representing the number of + tenths of a microsecond since January 1, 1601. + 32 Client Nonce 8 bytes + 40 Unknown 4 bytes + 44 Target Info N bytes (from the type-2 message) + 44+N Unknown 4 bytes + ----------------------------------------------------------------------------- + */ unsigned int len = 0; unsigned char *ptr = NULL; @@ -585,7 +584,7 @@ CURLcode Curl_ntlm_core_mk_ntlmv2_resp(unsigned char *ntlmv2hash, #ifdef DEBUGBUILD char *force_timestamp = getenv("CURL_FORCETIME"); if(force_timestamp) - time2filetime(&tw, (time_t) 0); + time2filetime(&tw, (time_t)0); else #endif time2filetime(&tw, time(NULL)); diff --git a/lib/curl_ntlm_core.h b/lib/curl_ntlm_core.h index 584f4a17d508..2e23d44bf580 100644 --- a/lib/curl_ntlm_core.h +++ b/lib/curl_ntlm_core.h @@ -58,16 +58,16 @@ CURLcode Curl_ntlm_core_mk_ntlmv2_hash(const char *user, size_t userlen, unsigned char *ntlmhash, unsigned char *ntlmv2hash); -CURLcode Curl_ntlm_core_mk_ntlmv2_resp(unsigned char *ntlmv2hash, - unsigned char *challenge_client, - struct ntlmdata *ntlm, - unsigned char **ntresp, - unsigned int *ntresp_len); - -CURLcode Curl_ntlm_core_mk_lmv2_resp(unsigned char *ntlmv2hash, - unsigned char *challenge_client, - unsigned char *challenge_server, - unsigned char *lmresp); +CURLcode Curl_ntlm_core_mk_ntlmv2_resp(unsigned char *ntlmv2hash, + unsigned char *challenge_client, + struct ntlmdata *ntlm, + unsigned char **ntresp, + unsigned int *ntresp_len); + +CURLcode Curl_ntlm_core_mk_lmv2_resp(unsigned char *ntlmv2hash, + unsigned char *challenge_client, + unsigned char *challenge_server, + unsigned char *lmresp); #endif /* !USE_WINDOWS_SSPI */ diff --git a/lib/curl_range.c b/lib/curl_range.c index e9620a29b535..4f788688133b 100644 --- a/lib/curl_range.c +++ b/lib/curl_range.c @@ -31,10 +31,10 @@ /* Only include this function if one or more of FTP, FILE are enabled. */ #if !defined(CURL_DISABLE_FTP) || !defined(CURL_DISABLE_FILE) - /* - Check if this is a range download, and if so, set the internal variables - properly. - */ +/* + Check if this is a range download, and if so, set the internal variables + properly. +*/ CURLcode Curl_range(struct Curl_easy *data) { if(data->state.use_range && data->state.range) { diff --git a/lib/curl_rtmp.c b/lib/curl_rtmp.c index 6f9e7c37b4b8..1eebbb5b3f24 100644 --- a/lib/curl_rtmp.c +++ b/lib/curl_rtmp.c @@ -38,12 +38,12 @@ #include #if defined(USE_WINSOCK) || defined(LWIP_SO_SNDRCVTIMEO_NONSTANDARD) -#define SET_RCVTIMEO(tv,s) int tv = s*1000 +#define SET_RCVTIMEO(tv, s) int tv = s * 1000 #else -#define SET_RCVTIMEO(tv,s) struct timeval tv = {s,0} +#define SET_RCVTIMEO(tv, s) struct timeval tv = { s, 0 } #endif -#define DEF_BUFTIME (2*60*60*1000) /* 2 hours */ +#define DEF_BUFTIME (2 * 60 * 60 * 1000) /* 2 hours */ /* meta key for storing RTMP* at connection */ #define CURL_META_RTMP_CONN "meta:proto:rtmp:conn" diff --git a/lib/curl_sasl.c b/lib/curl_sasl.c index f0b6e9471e5f..a4cd5a207b68 100644 --- a/lib/curl_sasl.c +++ b/lib/curl_sasl.c @@ -235,7 +235,7 @@ static CURLcode get_server_message(struct SASL *sasl, struct Curl_easy *data, if(!result && (sasl->params->flags & SASL_FLAG_BASE64)) { unsigned char *msg; size_t msglen; - const char *serverdata = (const char *) Curl_bufref_ptr(out); + const char *serverdata = (const char *)Curl_bufref_ptr(out); if(!*serverdata || *serverdata == '=') Curl_bufref_set(out, NULL, 0, NULL); @@ -355,8 +355,8 @@ static bool sasl_choose_gsasl(struct Curl_easy *data, struct sasl_ctx *sctx) struct gsasldata *gsasl; struct bufref nullmsg; - if(sctx->user && - (sctx->enabledmechs & (SASL_MECH_SCRAM_SHA_256|SASL_MECH_SCRAM_SHA_1))) { + if(sctx->user && (sctx->enabledmechs & + (SASL_MECH_SCRAM_SHA_256 | SASL_MECH_SCRAM_SHA_1))) { gsasl = Curl_auth_gsasl_get(sctx->conn); if(!gsasl) { sctx->result = CURLE_OUT_OF_MEMORY; @@ -364,14 +364,14 @@ static bool sasl_choose_gsasl(struct Curl_easy *data, struct sasl_ctx *sctx) } if((sctx->enabledmechs & SASL_MECH_SCRAM_SHA_256) && - Curl_auth_gsasl_is_supported(data, SASL_MECH_STRING_SCRAM_SHA_256, - gsasl)) { + Curl_auth_gsasl_is_supported(data, SASL_MECH_STRING_SCRAM_SHA_256, + gsasl)) { sctx->mech = SASL_MECH_STRING_SCRAM_SHA_256; sctx->sasl->authused = SASL_MECH_SCRAM_SHA_256; } else if((sctx->enabledmechs & SASL_MECH_SCRAM_SHA_1) && - Curl_auth_gsasl_is_supported(data, SASL_MECH_STRING_SCRAM_SHA_1, - gsasl)) { + Curl_auth_gsasl_is_supported(data, SASL_MECH_STRING_SCRAM_SHA_1, + gsasl)) { sctx->mech = SASL_MECH_STRING_SCRAM_SHA_1; sctx->sasl->authused = SASL_MECH_SCRAM_SHA_1; } @@ -399,7 +399,7 @@ static bool sasl_choose_digest(struct Curl_easy *data, struct sasl_ctx *sctx) if(!sctx->user) return FALSE; else if((sctx->enabledmechs & SASL_MECH_DIGEST_MD5) && - Curl_auth_is_digest_supported()) { + Curl_auth_is_digest_supported()) { sctx->mech = SASL_MECH_STRING_DIGEST_MD5; sctx->state1 = SASL_DIGESTMD5; sctx->sasl->authused = SASL_MECH_DIGEST_MD5; diff --git a/lib/curl_setup.h b/lib/curl_setup.h index 2cc18cf41488..ca275df0ada0 100644 --- a/lib/curl_setup.h +++ b/lib/curl_setup.h @@ -325,8 +325,8 @@ * Direct macros concatenation does not work because macros * are not expanded before direct concatenation. */ -#define CURL_CONC_MACROS_(A,B) A ## B -#define CURL_CONC_MACROS(A,B) CURL_CONC_MACROS_(A,B) +#define CURL_CONC_MACROS_(A, B) A ## B +#define CURL_CONC_MACROS(A, B) CURL_CONC_MACROS_(A, B) /* curl uses its own printf() function internally. It understands the GNU * format. Use this format, so that it matches the GNU format attribute we @@ -431,9 +431,9 @@ # ifdef __amigaos4__ int Curl_amiga_select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *errorfds, struct timeval *timeout); -# define select(a,b,c,d,e) Curl_amiga_select(a,b,c,d,e) +# define select(a, b, c, d, e) Curl_amiga_select(a, b, c, d, e) # else -# define select(a,b,c,d,e) WaitSelect(a,b,c,d,e,0) +# define select(a, b, c, d, e) WaitSelect(a, b, c, d, e, 0) # endif /* must not use libc's fcntl() on bsdsocket.library sockfds! */ # undef HAVE_FCNTL @@ -485,7 +485,7 @@ # undef lseek # define lseek(fdes, offset, whence) _lseeki64(fdes, offset, whence) # undef fstat -# define fstat(fdes,stp) _fstati64(fdes, stp) +# define fstat(fdes, stp) _fstati64(fdes, stp) # define struct_stat struct _stati64 # define LSEEK_ERROR (__int64)-1 # else @@ -500,8 +500,8 @@ /* Requires DJGPP 2.04 */ # include # undef lseek -# define lseek(fdes,offset,whence) llseek(fdes, offset, whence) -# define LSEEK_ERROR (offset_t)-1 +# define lseek(fdes, offset, whence) llseek(fdes, offset, whence) +# define LSEEK_ERROR (offset_t)-1 #endif #ifndef struct_stat @@ -570,7 +570,7 @@ #endif #define CURL_OFF_T_MIN (-CURL_OFF_T_MAX - 1) -#define FMT_OFF_T CURL_FORMAT_CURL_OFF_T +#define FMT_OFF_T CURL_FORMAT_CURL_OFF_T #define FMT_OFF_TU CURL_FORMAT_CURL_OFF_TU #if (SIZEOF_TIME_T == 4) @@ -639,8 +639,8 @@ # ifdef MSDOS /* Watt-32 */ # include -# define select(n,r,w,x,t) select_s(n,r,w,x,t) -# define ioctl(x,y,z) ioctlsocket(x,y,(char *)(z)) +# define select(n, r, w, x, t) select_s(n, r, w, x, t) +# define ioctl(x, y, z) ioctlsocket(x, y, (char *)(z)) # include # undef word # undef byte @@ -899,15 +899,15 @@ endings either CRLF or LF so 't' is appropriate. /* Some convenience macros to get the larger/smaller value out of two given. We prefix with CURL to prevent name collisions. */ -#define CURLMAX(x,y) ((x)>(y)?(x):(y)) -#define CURLMIN(x,y) ((x)<(y)?(x):(y)) +#define CURLMAX(x, y) ((x) > (y) ? (x) : (y)) +#define CURLMIN(x, y) ((x) < (y) ? (x) : (y)) /* A convenience macro to provide both the string literal and the length of the string literal in one go, useful for functions that take "string,len" as their argument */ -#define STRCONST(x) x,sizeof(x)-1 +#define STRCONST(x) x, sizeof(x) - 1 -#define CURL_ARRAYSIZE(A) (sizeof(A)/sizeof((A)[0])) +#define CURL_ARRAYSIZE(A) (sizeof(A) / sizeof((A)[0])) /* Buffer size for error messages retrieved via curlx_strerror() and Curl_sspi_strerror() */ @@ -1033,28 +1033,28 @@ CURL_EXTERN ALLOC_FUNC FILE *curl_dbg_fdopen(int filedes, const char *mode, int line, const char *source); -#define sclose(sockfd) curl_dbg_sclose(sockfd,__LINE__,__FILE__) -#define fake_sclose(sockfd) curl_dbg_mark_sclose(sockfd,__LINE__,__FILE__) +#define sclose(sockfd) curl_dbg_sclose(sockfd, __LINE__, __FILE__) +#define fake_sclose(sockfd) curl_dbg_mark_sclose(sockfd, __LINE__, __FILE__) -#define CURL_GETADDRINFO(host,serv,hint,res) \ +#define CURL_GETADDRINFO(host, serv, hint, res) \ curl_dbg_getaddrinfo(host, serv, hint, res, __LINE__, __FILE__) #define CURL_FREEADDRINFO(data) \ curl_dbg_freeaddrinfo(data, __LINE__, __FILE__) -#define CURL_SOCKET(domain,type,protocol) \ +#define CURL_SOCKET(domain, type, protocol) \ curl_dbg_socket((int)domain, type, protocol, __LINE__, __FILE__) #ifdef HAVE_SOCKETPAIR -#define CURL_SOCKETPAIR(domain,type,protocol,socket_vector) \ +#define CURL_SOCKETPAIR(domain, type, protocol, socket_vector) \ curl_dbg_socketpair((int)domain, type, protocol, socket_vector, \ __LINE__, __FILE__) #endif -#define CURL_ACCEPT(sock,addr,len) \ +#define CURL_ACCEPT(sock, addr, len) \ curl_dbg_accept(sock, addr, len, __LINE__, __FILE__) #ifdef HAVE_ACCEPT4 -#define CURL_ACCEPT4(sock,addr,len,flags) \ +#define CURL_ACCEPT4(sock, addr, len, flags) \ curl_dbg_accept4(sock, addr, len, flags, __LINE__, __FILE__) #endif -#define CURL_SEND(a,b,c,d) curl_dbg_send(a,b,c,d, __LINE__, __FILE__) -#define CURL_RECV(a,b,c,d) curl_dbg_recv(a,b,c,d, __LINE__, __FILE__) +#define CURL_SEND(a, b, c, d) curl_dbg_send(a, b, c, d, __LINE__, __FILE__) +#define CURL_RECV(a, b, c, d) curl_dbg_recv(a, b, c, d, __LINE__, __FILE__) #else /* !CURLDEBUG */ diff --git a/lib/curl_setup_once.h b/lib/curl_setup_once.h index 7caf6c9bc5eb..cf494b2ba8b0 100644 --- a/lib/curl_setup_once.h +++ b/lib/curl_setup_once.h @@ -104,7 +104,6 @@ /* * Definition of timeval struct for platforms that do not have it. */ - #ifndef HAVE_STRUCT_TIMEVAL struct timeval { long tv_sec; @@ -112,24 +111,21 @@ struct timeval { }; #endif - /* * If we have the MSG_NOSIGNAL define, make sure we use * it as the fourth argument of function send() */ - #ifdef HAVE_MSG_NOSIGNAL #define SEND_4TH_ARG MSG_NOSIGNAL #else #define SEND_4TH_ARG 0 #endif - #ifdef __minix /* Minix does not support recv on TCP sockets */ -#define sread(x,y,z) (ssize_t)read((RECV_TYPE_ARG1)(x), \ - (RECV_TYPE_ARG2)(y), \ - (RECV_TYPE_ARG3)(z)) +#define sread(x, y, z) (ssize_t)read((RECV_TYPE_ARG1)(x), \ + (RECV_TYPE_ARG2)(y), \ + (RECV_TYPE_ARG3)(z)) #elif defined(HAVE_RECV) /* @@ -154,10 +150,10 @@ struct timeval { * SEND_TYPE_RETV must also be defined. */ -#define sread(x,y,z) (ssize_t)recv((RECV_TYPE_ARG1)(x), \ - (RECV_TYPE_ARG2)(y), \ - (RECV_TYPE_ARG3)(z), \ - (RECV_TYPE_ARG4)(0)) +#define sread(x, y, z) (ssize_t)recv((RECV_TYPE_ARG1)(x), \ + (RECV_TYPE_ARG2)(y), \ + (RECV_TYPE_ARG3)(z), \ + (RECV_TYPE_ARG4)(0)) #else /* HAVE_RECV */ #ifndef sread #error "Missing definition of macro sread!" @@ -167,25 +163,23 @@ struct timeval { #ifdef __minix /* Minix does not support send on TCP sockets */ -#define swrite(x,y,z) (ssize_t)write((SEND_TYPE_ARG1)(x), \ - (SEND_TYPE_ARG2)CURL_UNCONST(y), \ - (SEND_TYPE_ARG3)(z)) +#define swrite(x, y, z) (ssize_t)write((SEND_TYPE_ARG1)(x), \ + (SEND_TYPE_ARG2)CURL_UNCONST(y), \ + (SEND_TYPE_ARG3)(z)) #elif defined(HAVE_SEND) -#define swrite(x,y,z) (ssize_t)send((SEND_TYPE_ARG1)(x), \ +#define swrite(x, y, z) (ssize_t)send((SEND_TYPE_ARG1)(x), \ (SEND_QUAL_ARG2 SEND_TYPE_ARG2)CURL_UNCONST(y), \ - (SEND_TYPE_ARG3)(z), \ - (SEND_TYPE_ARG4)(SEND_4TH_ARG)) + (SEND_TYPE_ARG3)(z), \ + (SEND_TYPE_ARG4)(SEND_4TH_ARG)) #else /* HAVE_SEND */ #ifndef swrite #error "Missing definition of macro swrite!" #endif #endif /* HAVE_SEND */ - /* * Function-like macro definition used to close a socket. */ - #ifdef HAVE_CLOSESOCKET # define CURL_SCLOSE(x) closesocket((x)) #elif defined(HAVE_CLOSESOCKET_CAMEL) @@ -210,7 +204,6 @@ struct timeval { /* * 'bool' stuff compatible with HP-UX headers. */ - #if defined(__hpux) && !defined(HAVE_BOOL_T) typedef int bool; # define false 0 @@ -218,14 +211,12 @@ struct timeval { # define HAVE_BOOL_T #endif - /* * 'bool' exists on platforms with , i.e. C99 platforms. * On non-C99 platforms there is no bool, so define an enum for that. * On C99 platforms 'false' and 'true' also exist. Enum uses a * global namespace though, so use bool_false and bool_true. */ - #ifndef HAVE_BOOL_T typedef enum { bool_false = 0, @@ -258,7 +249,6 @@ typedef unsigned int bit; * 'bool found = TRUE' will not. Change tested on IRIX/MIPSPro, * AIX 5.1/Xlc, Tru64 5.1/cc, w/make test too. */ - #ifndef TRUE #define TRUE true #endif @@ -268,22 +258,18 @@ typedef unsigned int bit; #include "curl_ctype.h" - /* * Macro used to include code only in debug builds. */ - #ifdef DEBUGBUILD #define DEBUGF(x) x #else #define DEBUGF(x) do { } while(0) #endif - /* * Macro used to include assertion code only in debug builds. */ - #undef DEBUGASSERT #ifdef DEBUGBUILD #define DEBUGASSERT(x) assert(x) @@ -291,12 +277,10 @@ typedef unsigned int bit; #define DEBUGASSERT(x) do { } while(0) #endif - /* * Macro SOCKERRNO / SET_SOCKERRNO() returns / sets the *socket-related* errno * (or equivalent) on this platform to hide platform details to code using it. */ - #ifdef USE_WINSOCK #define SOCKERRNO ((int)WSAGetLastError()) #define SET_SOCKERRNO(x) (WSASetLastError((int)(x))) @@ -305,11 +289,9 @@ typedef unsigned int bit; #define SET_SOCKERRNO(x) (errno = (x)) #endif - /* * Portable error number symbolic names defined to Winsock error codes. */ - #ifdef USE_WINSOCK #define SOCKEACCES WSAEACCES #define SOCKEADDRINUSE WSAEADDRINUSE @@ -349,7 +331,6 @@ typedef unsigned int bit; /* * Macro argv_item_t hides platform details to code using it. */ - #ifdef __VMS #define argv_item_t __char_ptr32 #elif defined(_UNICODE) @@ -358,13 +339,10 @@ typedef unsigned int bit; #define argv_item_t char * #endif - /* * We use this ZERO_NULL to avoid picky compiler warnings, * when assigning a NULL pointer to a function pointer var. */ - #define ZERO_NULL 0 - #endif /* HEADER_CURL_SETUP_ONCE_H */ diff --git a/lib/curl_sha512_256.c b/lib/curl_sha512_256.c index af768fd2aa5f..cc49aa4c7750 100644 --- a/lib/curl_sha512_256.c +++ b/lib/curl_sha512_256.c @@ -30,12 +30,12 @@ #include "curlx/warnless.h" /* The recommended order of the TLS backends: - * * OpenSSL - * * GnuTLS - * * wolfSSL - * * Schannel SSPI - * * mbedTLS - * * Rustls + * 1. OpenSSL + * 2. GnuTLS + * 3. wolfSSL + * 4. Schannel SSPI + * 5. mbedTLS + * 6. Rustls * Skip the backend if it does not support the required algorithm */ #ifdef USE_OPENSSL @@ -72,7 +72,6 @@ # endif #endif /* USE_OPENSSL */ - #if !defined(HAS_SHA512_256_IMPLEMENTATION) && defined(USE_GNUTLS) # include # ifdef SHA512_256_DIGEST_SIZE @@ -109,7 +108,7 @@ typedef EVP_MD_CTX *Curl_sha512_256_ctx; */ static CURLcode Curl_sha512_256_init(void *context) { - Curl_sha512_256_ctx *const ctx = (Curl_sha512_256_ctx *)context; + Curl_sha512_256_ctx * const ctx = (Curl_sha512_256_ctx *)context; *ctx = EVP_MD_CTX_create(); if(!*ctx) @@ -129,7 +128,6 @@ static CURLcode Curl_sha512_256_init(void *context) return CURLE_FAILED_INIT; } - /** * Process portion of bytes. * @@ -142,7 +140,7 @@ static CURLcode Curl_sha512_256_update(void *context, const unsigned char *data, size_t length) { - Curl_sha512_256_ctx *const ctx = (Curl_sha512_256_ctx *)context; + Curl_sha512_256_ctx * const ctx = (Curl_sha512_256_ctx *)context; if(!EVP_DigestUpdate(*ctx, data, length)) return CURLE_SSL_CIPHER; @@ -150,7 +148,6 @@ static CURLcode Curl_sha512_256_update(void *context, return CURLE_OK; } - /** * Finalise SHA-512/256 calculation, return digest. * @@ -163,7 +160,7 @@ static CURLcode Curl_sha512_256_update(void *context, static CURLcode Curl_sha512_256_finish(unsigned char *digest, void *context) { CURLcode ret; - Curl_sha512_256_ctx *const ctx = (Curl_sha512_256_ctx *)context; + Curl_sha512_256_ctx * const ctx = (Curl_sha512_256_ctx *)context; #ifdef NEED_NETBSD_SHA512_256_WORKAROUND /* Use a larger buffer to work around a bug in NetBSD: @@ -202,7 +199,7 @@ typedef struct sha512_256_ctx Curl_sha512_256_ctx; */ static CURLcode Curl_sha512_256_init(void *context) { - Curl_sha512_256_ctx *const ctx = (Curl_sha512_256_ctx *)context; + Curl_sha512_256_ctx * const ctx = (Curl_sha512_256_ctx *)context; /* Check whether the header and this file use the same numbers */ DEBUGASSERT(CURL_SHA512_256_DIGEST_LENGTH == CURL_SHA512_256_DIGEST_SIZE); @@ -212,7 +209,6 @@ static CURLcode Curl_sha512_256_init(void *context) return CURLE_OK; } - /** * Process portion of bytes. * @@ -225,7 +221,7 @@ static CURLcode Curl_sha512_256_update(void *context, const unsigned char *data, size_t length) { - Curl_sha512_256_ctx *const ctx = (Curl_sha512_256_ctx *)context; + Curl_sha512_256_ctx * const ctx = (Curl_sha512_256_ctx *)context; DEBUGASSERT((data != NULL) || (length == 0)); @@ -234,7 +230,6 @@ static CURLcode Curl_sha512_256_update(void *context, return CURLE_OK; } - /** * Finalise SHA-512/256 calculation, return digest. * @@ -246,7 +241,7 @@ static CURLcode Curl_sha512_256_update(void *context, static CURLcode Curl_sha512_256_finish(unsigned char *digest, void *context) { - Curl_sha512_256_ctx *const ctx = (Curl_sha512_256_ctx *)context; + Curl_sha512_256_ctx * const ctx = (Curl_sha512_256_ctx *)context; sha512_256_digest(ctx, (size_t)CURL_SHA512_256_DIGEST_SIZE, (uint8_t *)digest); @@ -286,32 +281,31 @@ static CURLcode Curl_sha512_256_finish(unsigned char *digest, /* Bits manipulation macros and functions. Can be moved to other headers to reuse. */ -#define CURL_GET_64BIT_BE(ptr) \ - ( ((uint64_t)(((const uint8_t*)(ptr))[0]) << 56) | \ - ((uint64_t)(((const uint8_t*)(ptr))[1]) << 48) | \ - ((uint64_t)(((const uint8_t*)(ptr))[2]) << 40) | \ - ((uint64_t)(((const uint8_t*)(ptr))[3]) << 32) | \ - ((uint64_t)(((const uint8_t*)(ptr))[4]) << 24) | \ - ((uint64_t)(((const uint8_t*)(ptr))[5]) << 16) | \ - ((uint64_t)(((const uint8_t*)(ptr))[6]) << 8) | \ - (uint64_t)(((const uint8_t*)(ptr))[7]) ) - -#define CURL_PUT_64BIT_BE(ptr,val) do { \ - ((uint8_t*)(ptr))[7]=(uint8_t)((uint64_t)(val)); \ - ((uint8_t*)(ptr))[6]=(uint8_t)(((uint64_t)(val)) >> 8); \ - ((uint8_t*)(ptr))[5]=(uint8_t)(((uint64_t)(val)) >> 16); \ - ((uint8_t*)(ptr))[4]=(uint8_t)(((uint64_t)(val)) >> 24); \ - ((uint8_t*)(ptr))[3]=(uint8_t)(((uint64_t)(val)) >> 32); \ - ((uint8_t*)(ptr))[2]=(uint8_t)(((uint64_t)(val)) >> 40); \ - ((uint8_t*)(ptr))[1]=(uint8_t)(((uint64_t)(val)) >> 48); \ - ((uint8_t*)(ptr))[0]=(uint8_t)(((uint64_t)(val)) >> 56); \ +#define CURL_GET_64BIT_BE(ptr) \ + (((uint64_t)(((const uint8_t *)(ptr))[0]) << 56) | \ + ((uint64_t)(((const uint8_t *)(ptr))[1]) << 48) | \ + ((uint64_t)(((const uint8_t *)(ptr))[2]) << 40) | \ + ((uint64_t)(((const uint8_t *)(ptr))[3]) << 32) | \ + ((uint64_t)(((const uint8_t *)(ptr))[4]) << 24) | \ + ((uint64_t)(((const uint8_t *)(ptr))[5]) << 16) | \ + ((uint64_t)(((const uint8_t *)(ptr))[6]) << 8) | \ + (uint64_t)(((const uint8_t *)(ptr))[7])) + +#define CURL_PUT_64BIT_BE(ptr,val) do { \ + ((uint8_t*)(ptr))[7] = (uint8_t) ((uint64_t)(val)); \ + ((uint8_t*)(ptr))[6] = (uint8_t)(((uint64_t)(val)) >> 8); \ + ((uint8_t*)(ptr))[5] = (uint8_t)(((uint64_t)(val)) >> 16); \ + ((uint8_t*)(ptr))[4] = (uint8_t)(((uint64_t)(val)) >> 24); \ + ((uint8_t*)(ptr))[3] = (uint8_t)(((uint64_t)(val)) >> 32); \ + ((uint8_t*)(ptr))[2] = (uint8_t)(((uint64_t)(val)) >> 40); \ + ((uint8_t*)(ptr))[1] = (uint8_t)(((uint64_t)(val)) >> 48); \ + ((uint8_t*)(ptr))[0] = (uint8_t)(((uint64_t)(val)) >> 56); \ } while(0) /* Defined as a function. The macro version may duplicate the binary code * size as each argument is used twice, so if any calculation is used * as an argument, the calculation could be done twice. */ -static CURL_FORCEINLINE uint64_t Curl_rotr64(uint64_t value, - unsigned int bits) +static CURL_FORCEINLINE uint64_t Curl_rotr64(uint64_t value, unsigned int bits) { bits %= 64; if(bits == 0) @@ -399,7 +393,6 @@ struct Curl_sha512_256ctx { */ typedef struct Curl_sha512_256ctx Curl_sha512_256_ctx; - /** * Initialise structure for SHA-512/256 calculation. * @@ -408,7 +401,7 @@ typedef struct Curl_sha512_256ctx Curl_sha512_256_ctx; */ static CURLcode Curl_sha512_256_init(void *context) { - struct Curl_sha512_256ctx *const ctx = (struct Curl_sha512_256ctx *)context; + struct Curl_sha512_256ctx * const ctx = (struct Curl_sha512_256ctx *)context; /* Check whether the header and this file use the same numbers */ DEBUGASSERT(CURL_SHA512_256_DIGEST_LENGTH == CURL_SHA512_256_DIGEST_SIZE); @@ -434,16 +427,14 @@ static CURLcode Curl_sha512_256_init(void *context) return CURLE_OK; } - /** * Base of the SHA-512/256 transformation. * Gets a full 128 bytes block of data and updates hash values; * @param H hash values * @param data the data buffer with #CURL_SHA512_256_BLOCK_SIZE bytes block */ -static -void Curl_sha512_256_transform(uint64_t H[SHA512_256_HASH_SIZE_WORDS], - const void *data) +static void Curl_sha512_256_transform(uint64_t H[SHA512_256_HASH_SIZE_WORDS], + const void *data) { /* Working variables, see FIPS PUB 180-4 section 6.7, 6.4. */ @@ -462,8 +453,8 @@ void Curl_sha512_256_transform(uint64_t H[SHA512_256_HASH_SIZE_WORDS], /* 'Ch' and 'Maj' macro functions are defined with widely-used optimization. See FIPS PUB 180-4 formulae 4.8, 4.9. */ -#define Sha512_Ch(x,y,z) ( (z) ^ ((x) & ((y) ^ (z))) ) -#define Sha512_Maj(x,y,z) ( ((x) & (y)) ^ ((z) & ((x) ^ (y))) ) +#define Sha512_Ch(x, y, z) ( (z) ^ ((x) & ((y) ^ (z))) ) +#define Sha512_Maj(x, y, z) ( ((x) & (y)) ^ ((z) & ((x) ^ (y))) ) /* Four 'Sigma' macro functions. See FIPS PUB 180-4 formulae 4.10, 4.11, 4.12, 4.13. */ @@ -533,38 +524,41 @@ void Curl_sha512_256_transform(uint64_t H[SHA512_256_HASH_SIZE_WORDS], * Note: 'wt' must be used exactly one time in this macro as macro for 'wt' calculation may change other data as well every time when used. */ -#define SHA2STEP64(vA,vB,vC,vD,vE,vF,vG,vH,kt,wt) do { \ - (vD) += ((vH) += SIG1((vE)) + Sha512_Ch((vE),(vF),(vG)) + (kt) + (wt)); \ - (vH) += SIG0((vA)) + Sha512_Maj((vA),(vB),(vC)); } while (0) +#define SHA2STEP64(vA, vB, vC, vD, vE, vF, vG, vH, kt, wt) \ + do { \ + (vD) += ((vH) += SIG1((vE)) + Sha512_Ch((vE), (vF), (vG)) + (kt) + (wt)); \ + (vH) += SIG0((vA)) + Sha512_Maj((vA), (vB), (vC)); \ + } while(0) /* One step of SHA-512/256 computation with working variables rotation, see FIPS PUB 180-4 section 6.4.2 step 3. This macro version reassigns all working variables on each step. */ -#define SHA2STEP64RV(vA,vB,vC,vD,vE,vF,vG,vH,kt,wt) do { \ - uint64_t tmp_h_ = (vH); \ - SHA2STEP64((vA),(vB),(vC),(vD),(vE),(vF),(vG),tmp_h_,(kt),(wt)); \ - (vH) = (vG); \ - (vG) = (vF); \ - (vF) = (vE); \ - (vE) = (vD); \ - (vD) = (vC); \ - (vC) = (vB); \ - (vB) = (vA); \ - (vA) = tmp_h_; } while(0) +#define SHA2STEP64RV(vA, vB, vC, vD, vE, vF, vG, vH, kt, wt) \ + do { \ + uint64_t tmp_h_ = (vH); \ + SHA2STEP64((vA), (vB), (vC), (vD), (vE), (vF), (vG), tmp_h_, (kt), (wt)); \ + (vH) = (vG); \ + (vG) = (vF); \ + (vF) = (vE); \ + (vE) = (vD); \ + (vD) = (vC); \ + (vC) = (vB); \ + (vB) = (vA); \ + (vA) = tmp_h_; \ + } while(0) /* Get value of W(t) from input data buffer for 0 <= t <= 15, See FIPS PUB 180-4 section 6.2. Input data must be read in big-endian bytes order, see FIPS PUB 180-4 section 3.1.2. */ -#define SHA512_GET_W_FROM_DATA(buf,t) \ - CURL_GET_64BIT_BE( \ - ((const uint8_t*) (buf)) + (t) * SHA512_256_BYTES_IN_WORD) +#define SHA512_GET_W_FROM_DATA(buf, t) \ + CURL_GET_64BIT_BE(((const uint8_t *)(buf)) + (t) * SHA512_256_BYTES_IN_WORD) /* During first 16 steps, before making any calculation on each step, the W element is read from the input data buffer as a big-endian value and stored in the array of W elements. */ for(t = 0; t < 16; ++t) { - SHA2STEP64RV(a, b, c, d, e, f, g, h, K[t], \ + SHA2STEP64RV(a, b, c, d, e, f, g, h, K[t], W[t] = SHA512_GET_W_FROM_DATA(data, t)); } @@ -573,15 +567,15 @@ void Curl_sha512_256_transform(uint64_t H[SHA512_256_HASH_SIZE_WORDS], As only the last 16 'W' are used in calculations, it is possible to use 16 elements array of W as a cyclic buffer. Note: ((t-16) & 15) have same value as (t & 15) */ -#define Wgen(w,t) \ - (uint64_t)( (w)[(t - 16) & 15] + sig1((w)[((t) - 2) & 15]) \ - + (w)[((t) - 7) & 15] + sig0((w)[((t) - 15) & 15]) ) +#define Wgen(w, t) \ + (uint64_t)((w)[((t) - 16) & 15] + sig1((w)[((t) - 2) & 15]) + \ + (w)[((t) - 7) & 15] + sig0((w)[((t) - 15) & 15])) /* During the last 64 steps, before making any calculation on each step, current W element is generated from other W elements of the cyclic buffer and the generated value is stored back in the cyclic buffer. */ for(t = 16; t < 80; ++t) { - SHA2STEP64RV(a, b, c, d, e, f, g, h, K[t], \ + SHA2STEP64RV(a, b, c, d, e, f, g, h, K[t], W[t & 15] = Wgen(W, t)); } } @@ -598,7 +592,6 @@ void Curl_sha512_256_transform(uint64_t H[SHA512_256_HASH_SIZE_WORDS], H[7] += h; } - /** * Process portion of bytes. * @@ -612,9 +605,9 @@ static CURLcode Curl_sha512_256_update(void *context, size_t length) { unsigned int bytes_have; /**< Number of bytes in the context buffer */ - struct Curl_sha512_256ctx *const ctx = (struct Curl_sha512_256ctx *)context; + struct Curl_sha512_256ctx * const ctx = (struct Curl_sha512_256ctx *)context; /* the void pointer here is required to mute Intel compiler warning */ - void *const ctx_buf = ctx->buffer; + void * const ctx_buf = ctx->buffer; DEBUGASSERT((data != NULL) || (length == 0)); @@ -623,7 +616,7 @@ static CURLcode Curl_sha512_256_update(void *context, /* Note: (count & (CURL_SHA512_256_BLOCK_SIZE-1)) equals (count % CURL_SHA512_256_BLOCK_SIZE) for this block size. */ - bytes_have = (unsigned int) (ctx->count & (CURL_SHA512_256_BLOCK_SIZE - 1)); + bytes_have = (unsigned int)(ctx->count & (CURL_SHA512_256_BLOCK_SIZE - 1)); ctx->count += length; if(length > ctx->count) ctx->count_bits_hi += 1U << 3; /* Value wrap */ @@ -635,7 +628,7 @@ static CURLcode Curl_sha512_256_update(void *context, if(length >= bytes_left) { /* Combine new data with data in the buffer and process the full block. */ - memcpy(((unsigned char *) ctx_buf) + bytes_have, + memcpy(((unsigned char *)ctx_buf) + bytes_have, data, bytes_left); data += bytes_left; @@ -656,13 +649,12 @@ static CURLcode Curl_sha512_256_update(void *context, if(length) { /* Copy incomplete block of new data (if any) to the buffer. */ - memcpy(((unsigned char *) ctx_buf) + bytes_have, data, length); + memcpy(((unsigned char *)ctx_buf) + bytes_have, data, length); } return CURLE_OK; } - /** * Size of "length" insertion in bits. * See FIPS PUB 180-4 section 5.1.2. @@ -684,11 +676,11 @@ static CURLcode Curl_sha512_256_update(void *context, */ static CURLcode Curl_sha512_256_finish(unsigned char *digest, void *context) { - struct Curl_sha512_256ctx *const ctx = (struct Curl_sha512_256ctx *)context; + struct Curl_sha512_256ctx * const ctx = (struct Curl_sha512_256ctx *)context; uint64_t num_bits; /**< Number of processed bits */ unsigned int bytes_have; /**< Number of bytes in the context buffer */ /* the void pointer here is required to mute Intel compiler warning */ - void *const ctx_buf = ctx->buffer; + void * const ctx_buf = ctx->buffer; /* Memorise the number of processed bits. The padding and other data added here during the postprocessing must @@ -697,7 +689,7 @@ static CURLcode Curl_sha512_256_finish(unsigned char *digest, void *context) /* Note: (count & (CURL_SHA512_256_BLOCK_SIZE-1)) equals (count % CURL_SHA512_256_BLOCK_SIZE) for this block size. */ - bytes_have = (unsigned int) (ctx->count & (CURL_SHA512_256_BLOCK_SIZE - 1)); + bytes_have = (unsigned int)(ctx->count & (CURL_SHA512_256_BLOCK_SIZE - 1)); /* Input data must be padded with a single bit "1", then with zeros and the finally the length of data in bits must be added as the final bytes @@ -709,13 +701,13 @@ static CURLcode Curl_sha512_256_finish(unsigned char *digest, void *context) predefined (0x80). */ /* Buffer always have space at least for one byte (as full buffers are processed when formed). */ - ((unsigned char *) ctx_buf)[bytes_have++] = 0x80U; + ((unsigned char *)ctx_buf)[bytes_have++] = 0x80U; if(CURL_SHA512_256_BLOCK_SIZE - bytes_have < SHA512_256_SIZE_OF_LEN_ADD) { /* No space in the current block to put the total length of message. Pad the current block with zeros and process it. */ if(bytes_have < CURL_SHA512_256_BLOCK_SIZE) - memset(((unsigned char *) ctx_buf) + bytes_have, 0, + memset(((unsigned char *)ctx_buf) + bytes_have, 0, CURL_SHA512_256_BLOCK_SIZE - bytes_have); /* Process the full block. */ Curl_sha512_256_transform(ctx->H, ctx->buffer); @@ -724,17 +716,17 @@ static CURLcode Curl_sha512_256_finish(unsigned char *digest, void *context) } /* Pad the rest of the buffer with zeros. */ - memset(((unsigned char *) ctx_buf) + bytes_have, 0, + memset(((unsigned char *)ctx_buf) + bytes_have, 0, CURL_SHA512_256_BLOCK_SIZE - SHA512_256_SIZE_OF_LEN_ADD - bytes_have); /* Put high part of number of bits in processed message and then lower part of number of bits as big-endian values. See FIPS PUB 180-4 section 5.1.2. */ /* Note: the target location is predefined and buffer is always aligned */ - CURL_PUT_64BIT_BE(((unsigned char *) ctx_buf) \ + CURL_PUT_64BIT_BE(((unsigned char *)ctx_buf) \ + CURL_SHA512_256_BLOCK_SIZE \ - SHA512_256_SIZE_OF_LEN_ADD, \ ctx->count_bits_hi); - CURL_PUT_64BIT_BE(((unsigned char *) ctx_buf) \ + CURL_PUT_64BIT_BE(((unsigned char *)ctx_buf) \ + CURL_SHA512_256_BLOCK_SIZE \ - SHA512_256_SIZE_OF_LEN_ADD \ + SHA512_256_BYTES_IN_WORD, \ @@ -775,7 +767,7 @@ CURLcode Curl_sha512_256it(unsigned char *output, const unsigned char *input, if(res != CURLE_OK) return res; - res = Curl_sha512_256_update(&ctx, (const void *) input, input_size); + res = Curl_sha512_256_update(&ctx, (const void *)input, input_size); if(res != CURLE_OK) { (void)Curl_sha512_256_finish(output, &ctx); diff --git a/lib/curl_sha512_256.h b/lib/curl_sha512_256.h index a84e77bc3038..c22491ddc0f5 100644 --- a/lib/curl_sha512_256.h +++ b/lib/curl_sha512_256.h @@ -35,9 +35,8 @@ extern const struct HMAC_params Curl_HMAC_SHA512_256[1]; #define CURL_SHA512_256_DIGEST_LENGTH 32 -CURLcode -Curl_sha512_256it(unsigned char *output, const unsigned char *input, - size_t input_size); +CURLcode Curl_sha512_256it(unsigned char *output, const unsigned char *input, + size_t input_size); #endif /* !CURL_DISABLE_DIGEST_AUTH && !CURL_DISABLE_SHA512_256 */ diff --git a/lib/curl_share.c b/lib/curl_share.c index c6b51267046f..109fe76b6676 100644 --- a/lib/curl_share.c +++ b/lib/curl_share.c @@ -34,8 +34,7 @@ #include "hsts.h" #include "url.h" -CURLSH * -curl_share_init(void) +CURLSH *curl_share_init(void) { struct Curl_share *share = curlx_calloc(1, sizeof(struct Curl_share)); if(share) { @@ -60,8 +59,7 @@ curl_share_init(void) } #undef curl_share_setopt -CURLSHcode -curl_share_setopt(CURLSH *sh, CURLSHoption option, ...) +CURLSHcode curl_share_setopt(CURLSH *sh, CURLSHoption option, ...) { va_list param; int type; @@ -224,8 +222,7 @@ curl_share_setopt(CURLSH *sh, CURLSHoption option, ...) return res; } -CURLSHcode -curl_share_cleanup(CURLSH *sh) +CURLSHcode curl_share_cleanup(CURLSH *sh) { struct Curl_share *share = sh; if(!GOOD_SHARE_HANDLE(share)) @@ -273,10 +270,8 @@ curl_share_cleanup(CURLSH *sh) return CURLSHE_OK; } - -CURLSHcode -Curl_share_lock(struct Curl_easy *data, curl_lock_data type, - curl_lock_access accesstype) +CURLSHcode Curl_share_lock(struct Curl_easy *data, curl_lock_data type, + curl_lock_access accesstype) { struct Curl_share *share = data->share; @@ -292,8 +287,7 @@ Curl_share_lock(struct Curl_easy *data, curl_lock_data type, return CURLSHE_OK; } -CURLSHcode -Curl_share_unlock(struct Curl_easy *data, curl_lock_data type) +CURLSHcode Curl_share_unlock(struct Curl_easy *data, curl_lock_data type) { struct Curl_share *share = data->share; @@ -302,7 +296,7 @@ Curl_share_unlock(struct Curl_easy *data, curl_lock_data type) if(share->specifier & (unsigned int)(1 << type)) { if(share->unlockfunc) /* only call this if set! */ - share->unlockfunc (data, type, share->clientdata); + share->unlockfunc(data, type, share->clientdata); } return CURLSHE_OK; diff --git a/lib/curl_share.h b/lib/curl_share.h index 974c99dc204b..0699356dd443 100644 --- a/lib/curl_share.h +++ b/lib/curl_share.h @@ -38,7 +38,7 @@ struct Curl_ssl_scache; #define GOOD_SHARE_HANDLE(x) ((x) && (x)->magic == CURL_GOOD_SHARE) #define CURL_SHARE_KEEP_CONNECT(s) \ - ((s) && ((s)->specifier & (1<< CURL_LOCK_DATA_CONNECT))) + ((s) && ((s)->specifier & (1 << CURL_LOCK_DATA_CONNECT))) /* this struct is libcurl-private, do not export details */ struct Curl_share { @@ -71,8 +71,8 @@ CURLSHcode Curl_share_lock(struct Curl_easy *, curl_lock_data, CURLSHcode Curl_share_unlock(struct Curl_easy *, curl_lock_data); /* convenience macro to check if this handle is using a shared SSL spool */ -#define CURL_SHARE_ssl_scache(data) (data->share && \ +#define CURL_SHARE_ssl_scache(data) (data->share && \ (data->share->specifier & \ - (1<type = type; if(type & CLIENTWRITE_BODY) Curl_bufq_init2(&cwbuf->b, CW_PAUSE_BUF_CHUNK, 1, - (BUFQ_OPT_SOFT_LIMIT|BUFQ_OPT_NO_SPARES)); + (BUFQ_OPT_SOFT_LIMIT | BUFQ_OPT_NO_SPARES)); else Curl_bufq_init(&cwbuf->b, buflen, 1); } diff --git a/lib/dict.c b/lib/dict.c index f208892f7302..a5facf4310db 100644 --- a/lib/dict.c +++ b/lib/dict.c @@ -60,10 +60,10 @@ #include "progress.h" #include "dict.h" -#define DICT_MATCH "/MATCH:" -#define DICT_MATCH2 "/M:" -#define DICT_MATCH3 "/FIND:" -#define DICT_DEFINE "/DEFINE:" +#define DICT_MATCH "/MATCH:" +#define DICT_MATCH2 "/M:" +#define DICT_MATCH3 "/FIND:" +#define DICT_DEFINE "/DEFINE:" #define DICT_DEFINE2 "/D:" #define DICT_DEFINE3 "/LOOKUP:" @@ -192,9 +192,9 @@ static CURLcode dict_do(struct Curl_easy *data, bool *done) if(result) return result; - if(curl_strnequal(path, DICT_MATCH, sizeof(DICT_MATCH)-1) || - curl_strnequal(path, DICT_MATCH2, sizeof(DICT_MATCH2)-1) || - curl_strnequal(path, DICT_MATCH3, sizeof(DICT_MATCH3)-1)) { + if(curl_strnequal(path, DICT_MATCH, sizeof(DICT_MATCH) - 1) || + curl_strnequal(path, DICT_MATCH2, sizeof(DICT_MATCH2) - 1) || + curl_strnequal(path, DICT_MATCH3, sizeof(DICT_MATCH3) - 1)) { word = strchr(path, ':'); if(word) { @@ -239,9 +239,9 @@ static CURLcode dict_do(struct Curl_easy *data, bool *done) } Curl_xfer_setup_recv(data, FIRSTSOCKET, -1); } - else if(curl_strnequal(path, DICT_DEFINE, sizeof(DICT_DEFINE)-1) || - curl_strnequal(path, DICT_DEFINE2, sizeof(DICT_DEFINE2)-1) || - curl_strnequal(path, DICT_DEFINE3, sizeof(DICT_DEFINE3)-1)) { + else if(curl_strnequal(path, DICT_DEFINE, sizeof(DICT_DEFINE) - 1) || + curl_strnequal(path, DICT_DEFINE2, sizeof(DICT_DEFINE2) - 1) || + curl_strnequal(path, DICT_DEFINE3, sizeof(DICT_DEFINE3) - 1)) { word = strchr(path, ':'); if(word) { diff --git a/lib/doh.c b/lib/doh.c index d7b1d54c25e8..b0f19be73a7e 100644 --- a/lib/doh.c +++ b/lib/doh.c @@ -44,7 +44,7 @@ #define DNS_CLASS_IN 0x01 #ifndef CURL_DISABLE_VERBOSE_STRINGS -static const char * const errors[]={ +static const char * const errors[] = { "", "Bad label", "Out of range", @@ -107,7 +107,7 @@ UNITTEST DOHcode doh_req_encode(const char *host, size_t expected_len; DEBUGASSERT(hostlen); expected_len = 12 + 1 + hostlen + 4; - if(host[hostlen-1]!='.') + if(host[hostlen - 1] != '.') expected_len++; if(expected_len > DOH_MAX_DNSREQ_SIZE) @@ -169,8 +169,8 @@ UNITTEST DOHcode doh_req_encode(const char *host, return DOH_OK; } -static size_t -doh_probe_write_cb(char *contents, size_t size, size_t nmemb, void *userp) +static size_t doh_probe_write_cb(char *contents, size_t size, size_t nmemb, + void *userp) { size_t realsize = size * nmemb; struct Curl_easy *data = userp; @@ -269,7 +269,7 @@ static void doh_probe_dtor(void *key, size_t klen, void *e) } } -#define ERROR_CHECK_SETOPT(x,y) \ +#define ERROR_CHECK_SETOPT(x, y) \ do { \ result = curl_easy_setopt((CURL *)doh, x, y); \ if(result && \ @@ -346,7 +346,7 @@ static CURLcode doh_probe_run(struct Curl_easy *data, ERROR_CHECK_SETOPT(CURLOPT_PROTOCOLS, CURLPROTO_HTTPS); #else /* in debug mode, also allow http */ - ERROR_CHECK_SETOPT(CURLOPT_PROTOCOLS, CURLPROTO_HTTP|CURLPROTO_HTTPS); + ERROR_CHECK_SETOPT(CURLOPT_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS); #endif ERROR_CHECK_SETOPT(CURLOPT_TIMEOUT_MS, (long)timeout_ms); ERROR_CHECK_SETOPT(CURLOPT_SHARE, (CURLSH *)data->share); @@ -358,11 +358,11 @@ static CURLcode doh_probe_run(struct Curl_easy *data, ERROR_CHECK_SETOPT(CURLOPT_NOSIGNAL, 1L); ERROR_CHECK_SETOPT(CURLOPT_SSL_VERIFYHOST, - data->set.doh_verifyhost ? 2L : 0L); + data->set.doh_verifyhost ? 2L : 0L); ERROR_CHECK_SETOPT(CURLOPT_SSL_VERIFYPEER, - data->set.doh_verifypeer ? 1L : 0L); + data->set.doh_verifypeer ? 1L : 0L); ERROR_CHECK_SETOPT(CURLOPT_SSL_VERIFYSTATUS, - data->set.doh_verifystatus ? 1L : 0L); + data->set.doh_verifystatus ? 1L : 0L); /* Inherit *some* SSL options from the user's transfer. This is a best-guess as to which options are needed for compatibility. #3661 @@ -376,20 +376,16 @@ static CURLcode doh_probe_run(struct Curl_easy *data, doh->set.ssl.custom_capath = data->set.ssl.custom_capath; doh->set.ssl.custom_cablob = data->set.ssl.custom_cablob; if(data->set.str[STRING_SSL_CAFILE]) { - ERROR_CHECK_SETOPT(CURLOPT_CAINFO, - data->set.str[STRING_SSL_CAFILE]); + ERROR_CHECK_SETOPT(CURLOPT_CAINFO, data->set.str[STRING_SSL_CAFILE]); } if(data->set.blobs[BLOB_CAINFO]) { - ERROR_CHECK_SETOPT(CURLOPT_CAINFO_BLOB, - data->set.blobs[BLOB_CAINFO]); + ERROR_CHECK_SETOPT(CURLOPT_CAINFO_BLOB, data->set.blobs[BLOB_CAINFO]); } if(data->set.str[STRING_SSL_CAPATH]) { - ERROR_CHECK_SETOPT(CURLOPT_CAPATH, - data->set.str[STRING_SSL_CAPATH]); + ERROR_CHECK_SETOPT(CURLOPT_CAPATH, data->set.str[STRING_SSL_CAPATH]); } if(data->set.str[STRING_SSL_CRLFILE]) { - ERROR_CHECK_SETOPT(CURLOPT_CRLFILE, - data->set.str[STRING_SSL_CRLFILE]); + ERROR_CHECK_SETOPT(CURLOPT_CRLFILE, data->set.str[STRING_SSL_CRLFILE]); } if(data->set.ssl.certinfo) ERROR_CHECK_SETOPT(CURLOPT_CERTINFO, 1L); @@ -717,7 +713,6 @@ UNITTEST void de_init(struct dohentry *de) curlx_dyn_init(&de->cname[i], DYN_DOH_CNAME); } - UNITTEST DOHcode doh_resp_decode(const unsigned char *doh, size_t dohlen, DNStype dnstype, @@ -851,7 +846,7 @@ UNITTEST DOHcode doh_resp_decode(const unsigned char *doh, #ifdef USE_HTTTPS if((type != CURL_DNS_TYPE_NS) && !d->numcname && !d->numaddr && - !d->numhttps_rrs) + !d->numhttps_rrs) #else if((type != CURL_DNS_TYPE_NS) && !d->numcname && !d->numaddr) #endif @@ -895,8 +890,7 @@ static void doh_show(struct Curl_easy *data, #ifdef USE_HTTPSRR for(i = 0; i < d->numhttps_rrs; i++) { # ifdef DEBUGBUILD - doh_print_buf(data, "DoH HTTPS", - d->https_rrs[i].val, d->https_rrs[i].len); + doh_print_buf(data, "DoH HTTPS", d->https_rrs[i].val, d->https_rrs[i].len); # else infof(data, "DoH HTTPS RR: length %d", d->https_rrs[i].len); # endif @@ -907,7 +901,7 @@ static void doh_show(struct Curl_easy *data, } } #else -#define doh_show(x,y) +#define doh_show(x, y) #endif /* @@ -1022,16 +1016,16 @@ static CURLcode doh2ai(const struct dohentry *de, const char *hostname, static const char *doh_type2name(DNStype dnstype) { switch(dnstype) { - case CURL_DNS_TYPE_A: - return "A"; - case CURL_DNS_TYPE_AAAA: - return "AAAA"; + case CURL_DNS_TYPE_A: + return "A"; + case CURL_DNS_TYPE_AAAA: + return "AAAA"; #ifdef USE_HTTPSRR - case CURL_DNS_TYPE_HTTPS: - return "HTTPS"; + case CURL_DNS_TYPE_HTTPS: + return "HTTPS"; #endif - default: - return "unknown"; + default: + return "unknown"; } } #endif @@ -1174,8 +1168,7 @@ UNITTEST void doh_print_httpsrr(struct Curl_easy *data, struct Curl_https_rrinfo *hrr) { DEBUGASSERT(hrr); - infof(data, "HTTPS RR: priority %d, target: %s", - hrr->priority, hrr->target); + infof(data, "HTTPS RR: priority %d, target: %s", hrr->priority, hrr->target); if(hrr->alpns[0] != ALPN_none) infof(data, "HTTPS RR: alpns %u %u %u %u", hrr->alpns[0], hrr->alpns[1], hrr->alpns[2], hrr->alpns[3]); @@ -1285,7 +1278,7 @@ CURLcode Curl_doh_is_resolved(struct Curl_easy *data, doh_print_httpsrr(data, hrr); # endif dns->hinfo = hrr; - } + } #endif /* and add the entry to the cache */ data->state.async.dns = dns; @@ -1323,8 +1316,7 @@ void Curl_doh_close(struct Curl_easy *data) doh->probe_resp[slot].probe_mid = UINT32_MAX; /* should have been called before data is removed from multi handle */ DEBUGASSERT(data->multi); - probe_data = data->multi ? Curl_multi_get_easy(data->multi, mid) : - NULL; + probe_data = data->multi ? Curl_multi_get_easy(data->multi, mid) : NULL; if(!probe_data) { DEBUGF(infof(data, "Curl_doh_close: xfer for mid=%u not found!", doh->probe_resp[slot].probe_mid)); diff --git a/lib/doh.h b/lib/doh.h index ffd0cb087913..16732173ab67 100644 --- a/lib/doh.h +++ b/lib/doh.h @@ -122,7 +122,7 @@ CURLcode Curl_doh(struct Curl_easy *data, const char *hostname, CURLcode Curl_doh_is_resolved(struct Curl_easy *data, struct Curl_dns_entry **dns); -#define DOH_MAX_ADDR 24 +#define DOH_MAX_ADDR 24 #define DOH_MAX_CNAME 4 #define DOH_MAX_HTTPS 4 @@ -180,8 +180,8 @@ UNITTEST void de_cleanup(struct dohentry *d); #endif #else /* if DoH is disabled */ -#define Curl_doh(a,b,c,d,e) NULL -#define Curl_doh_is_resolved(x,y) CURLE_COULDNT_RESOLVE_HOST +#define Curl_doh(a, b, c, d, e) NULL +#define Curl_doh_is_resolved(x, y) CURLE_COULDNT_RESOLVE_HOST #endif #endif /* HEADER_CURL_DOH_H */ diff --git a/lib/dynhds.c b/lib/dynhds.c index ebe1beae5856..b6654114d692 100644 --- a/lib/dynhds.c +++ b/lib/dynhds.c @@ -55,9 +55,8 @@ entry_new(const char *name, size_t namelen, return e; } -static struct dynhds_entry * -entry_append(struct dynhds_entry *e, - const char *value, size_t valuelen) +static struct dynhds_entry *entry_append(struct dynhds_entry *e, + const char *value, size_t valuelen) { struct dynhds_entry *e2; size_t valuelen2 = e->valuelen + 1 + valuelen; @@ -171,7 +170,7 @@ CURLcode Curl_dynhds_add(struct dynhds *dynhds, if(dynhds->strs_len + namelen + valuelen > dynhds->max_strs_size) return CURLE_OUT_OF_MEMORY; -entry = entry_new(name, namelen, value, valuelen, dynhds->opts); + entry = entry_new(name, namelen, value, valuelen, dynhds->opts); if(!entry) goto out; @@ -234,11 +233,11 @@ CURLcode Curl_dynhds_h1_add_line(struct dynhds *dynhds, } if(!line_len) return CURLE_BAD_FUNCTION_ARGUMENT; - e = dynhds->hds[dynhds->hds_len-1]; + e = dynhds->hds[dynhds->hds_len - 1]; e2 = entry_append(e, line, line_len); if(!e2) return CURLE_OUT_OF_MEMORY; - dynhds->hds[dynhds->hds_len-1] = e2; + dynhds->hds[dynhds->hds_len - 1] = e2; entry_free(e); return CURLE_OK; } diff --git a/lib/easy.c b/lib/easy.c index c60819fcdc6e..d2f6c36c0d87 100644 --- a/lib/easy.c +++ b/lib/easy.c @@ -87,7 +87,7 @@ static long easy_init_flags; #ifdef GLOBAL_INIT_IS_THREADSAFE static curl_simple_lock s_lock = CURL_SIMPLE_LOCK_INIT; -#define global_init_lock() curl_simple_lock_lock(&s_lock) +#define global_init_lock() curl_simple_lock_lock(&s_lock) #define global_init_unlock() curl_simple_lock_unlock(&s_lock) #else @@ -208,7 +208,6 @@ static CURLcode global_init(long flags, bool memoryfuncs) return CURLE_FAILED_INIT; } - /** * curl_global_init() globally initializes curl given a bitwise set of the * different features of what to initialize. @@ -411,7 +410,6 @@ static int events_timer(CURLM *multi, /* multi handle */ return 0; } - /* poll2cselect * * convert from poll() bit definitions to libcurl's CURL_CSELECT_* ones @@ -428,7 +426,6 @@ static int poll2cselect(int pollmask) return omask; } - /* socketcb2poll * * convert from libcurl' CURL_POLL_* bit definitions to poll()'s @@ -485,10 +482,9 @@ static int events_socket(CURL *easy, /* easy handle */ /* The socket 's' is already being monitored, update the activity mask. Convert from libcurl bitmask to the poll one. */ m->socket.events = socketcb2poll(what); - infof(data, "socket cb: socket %" FMT_SOCKET_T - " UPDATED as %s%s", s, - (what&CURL_POLL_IN) ? "IN" : "", - (what&CURL_POLL_OUT) ? "OUT" : ""); + infof(data, "socket cb: socket %" FMT_SOCKET_T " UPDATED as %s%s", s, + (what & CURL_POLL_IN) ? "IN" : "", + (what & CURL_POLL_OUT) ? "OUT" : ""); } break; } @@ -512,8 +508,8 @@ static int events_socket(CURL *easy, /* easy handle */ m->socket.revents = 0; ev->list = m; infof(data, "socket cb: socket %" FMT_SOCKET_T " ADDED as %s%s", s, - (what&CURL_POLL_IN) ? "IN" : "", - (what&CURL_POLL_OUT) ? "OUT" : ""); + (what & CURL_POLL_IN) ? "IN" : "", + (what & CURL_POLL_OUT) ? "OUT" : ""); } else return CURLE_OUT_OF_MEMORY; @@ -523,7 +519,6 @@ static int events_socket(CURL *easy, /* easy handle */ return 0; } - /* * events_setup() * @@ -681,7 +676,6 @@ static CURLcode wait_or_timeout(struct Curl_multi *multi, struct events *ev) return result; } - /* easy_events() * * Runs a transfer in a blocking manner using the events-based API @@ -690,7 +684,7 @@ static CURLcode easy_events(struct Curl_multi *multi) { /* this struct is made static to allow it to be used after this function returns and curl_multi_remove_handle() is called */ - static struct events evs = {-1, FALSE, 0, NULL, 0}; + static struct events evs = { -1, FALSE, 0, NULL, 0 }; /* if running event-based, do some further multi inits */ events_setup(multi, &evs); @@ -738,7 +732,6 @@ static CURLcode easy_transfer(struct Curl_multi *multi) return result; } - /* * easy_perform() is the internal interface that performs a blocking * transfer as previously setup. @@ -1201,7 +1194,6 @@ CURLcode curl_easy_pause(CURL *d, int action) return result; } - static CURLcode easy_connection(struct Curl_easy *data, struct connectdata **connp) { diff --git a/lib/easy_lock.h b/lib/easy_lock.h index f8998cc5472c..a10fe3103a8d 100644 --- a/lib/easy_lock.h +++ b/lib/easy_lock.h @@ -30,10 +30,10 @@ #if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x600 -#define curl_simple_lock SRWLOCK +#define curl_simple_lock SRWLOCK #define CURL_SIMPLE_LOCK_INIT SRWLOCK_INIT -#define curl_simple_lock_lock(m) AcquireSRWLockExclusive(m) +#define curl_simple_lock_lock(m) AcquireSRWLockExclusive(m) #define curl_simple_lock_unlock(m) ReleaseSRWLockExclusive(m) #elif defined(HAVE_ATOMIC) && defined(HAVE_STDATOMIC_H) @@ -42,7 +42,7 @@ #include #endif -#define curl_simple_lock atomic_int +#define curl_simple_lock atomic_int #define CURL_SIMPLE_LOCK_INIT 0 #ifndef __INTEL_COMPILER @@ -91,14 +91,14 @@ static CURL_INLINE void curl_simple_lock_unlock(curl_simple_lock *lock) #include -#define curl_simple_lock pthread_mutex_t -#define CURL_SIMPLE_LOCK_INIT PTHREAD_MUTEX_INITIALIZER -#define curl_simple_lock_lock(m) pthread_mutex_lock(m) +#define curl_simple_lock pthread_mutex_t +#define CURL_SIMPLE_LOCK_INIT PTHREAD_MUTEX_INITIALIZER +#define curl_simple_lock_lock(m) pthread_mutex_lock(m) #define curl_simple_lock_unlock(m) pthread_mutex_unlock(m) #else -#undef GLOBAL_INIT_IS_THREADSAFE +#undef GLOBAL_INIT_IS_THREADSAFE #endif diff --git a/lib/easyoptions.c b/lib/easyoptions.c index 03d676df0e73..4bd8457f75dd 100644 --- a/lib/easyoptions.c +++ b/lib/easyoptions.c @@ -29,348 +29,352 @@ /* all easy setopt options listed in alphabetical order */ const 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}, - {"AWS_SIGV4", CURLOPT_AWS_SIGV4, CURLOT_STRING, 0}, - {"BUFFERSIZE", CURLOPT_BUFFERSIZE, CURLOT_LONG, 0}, - {"CAINFO", CURLOPT_CAINFO, CURLOT_STRING, 0}, - {"CAINFO_BLOB", CURLOPT_CAINFO_BLOB, CURLOT_BLOB, 0}, - {"CAPATH", CURLOPT_CAPATH, CURLOT_STRING, 0}, - {"CA_CACHE_TIMEOUT", CURLOPT_CA_CACHE_TIMEOUT, CURLOT_LONG, 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_SSL_VERIFYHOST", CURLOPT_DOH_SSL_VERIFYHOST, CURLOT_LONG, 0}, - {"DOH_SSL_VERIFYPEER", CURLOPT_DOH_SSL_VERIFYPEER, CURLOT_LONG, 0}, - {"DOH_SSL_VERIFYSTATUS", CURLOPT_DOH_SSL_VERIFYSTATUS, CURLOT_LONG, 0}, - {"DOH_URL", CURLOPT_DOH_URL, CURLOT_STRING, 0}, - {"ECH", CURLOPT_ECH, 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_SERVER_RESPONSE_TIMEOUT, - CURLOT_LONG, CURLOT_FLAG_ALIAS}, - {"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}, - {"HAPROXY_CLIENT_IP", CURLOPT_HAPROXY_CLIENT_IP, CURLOT_STRING, 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_ALLOWFAILS, - CURLOT_LONG, CURLOT_FLAG_ALIAS}, - {"MAIL_RCPT_ALLOWFAILS", CURLOPT_MAIL_RCPT_ALLOWFAILS, 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}, - {"MAXLIFETIME_CONN", CURLOPT_MAXLIFETIME_CONN, CURLOT_LONG, 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}, - {"MIME_OPTIONS", CURLOPT_MIME_OPTIONS, CURLOT_LONG, 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}, - {"PREREQDATA", CURLOPT_PREREQDATA, CURLOT_CBPTR, 0}, - {"PREREQFUNCTION", CURLOPT_PREREQFUNCTION, CURLOT_FUNCTION, 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}, - {"PROTOCOLS_STR", CURLOPT_PROTOCOLS_STR, CURLOT_STRING, 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_CAINFO_BLOB", CURLOPT_PROXY_CAINFO_BLOB, CURLOT_BLOB, 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}, - {"QUICK_EXIT", CURLOPT_QUICK_EXIT, 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}, - {"REDIR_PROTOCOLS_STR", CURLOPT_REDIR_PROTOCOLS_STR, CURLOT_STRING, 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_SERVER_RESPONSE_TIMEOUT, - CURLOT_LONG, 0}, - {"SERVER_RESPONSE_TIMEOUT_MS", CURLOPT_SERVER_RESPONSE_TIMEOUT_MS, - CURLOT_LONG, 0}, - {"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_HOSTKEYDATA", CURLOPT_SSH_HOSTKEYDATA, CURLOT_CBPTR, 0}, - {"SSH_HOSTKEYFUNCTION", CURLOPT_SSH_HOSTKEYFUNCTION, CURLOT_FUNCTION, 0}, - {"SSH_HOST_PUBLIC_KEY_MD5", CURLOPT_SSH_HOST_PUBLIC_KEY_MD5, - CURLOT_STRING, 0}, - {"SSH_HOST_PUBLIC_KEY_SHA256", CURLOPT_SSH_HOST_PUBLIC_KEY_SHA256, - 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_SIGNATURE_ALGORITHMS", CURLOPT_SSL_SIGNATURE_ALGORITHMS, - CURLOT_STRING, 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_KEEPCNT", CURLOPT_TCP_KEEPCNT, 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}, - {"UPLOAD_FLAGS", CURLOPT_UPLOAD_FLAGS, 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}, - {"WS_OPTIONS", CURLOPT_WS_OPTIONS, CURLOT_LONG, 0}, - {"XFERINFODATA", CURLOPT_XFERINFODATA, CURLOT_CBPTR, 0}, - {"XFERINFOFUNCTION", CURLOPT_XFERINFOFUNCTION, CURLOT_FUNCTION, 0}, - {"XOAUTH2_BEARER", CURLOPT_XOAUTH2_BEARER, CURLOT_STRING, 0}, - {NULL, CURLOPT_LASTENTRY, CURLOT_LONG, 0} /* end of table */ + { "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 }, + { "AWS_SIGV4", CURLOPT_AWS_SIGV4, CURLOT_STRING, 0 }, + { "BUFFERSIZE", CURLOPT_BUFFERSIZE, CURLOT_LONG, 0 }, + { "CAINFO", CURLOPT_CAINFO, CURLOT_STRING, 0 }, + { "CAINFO_BLOB", CURLOPT_CAINFO_BLOB, CURLOT_BLOB, 0 }, + { "CAPATH", CURLOPT_CAPATH, CURLOT_STRING, 0 }, + { "CA_CACHE_TIMEOUT", CURLOPT_CA_CACHE_TIMEOUT, CURLOT_LONG, 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_SSL_VERIFYHOST", CURLOPT_DOH_SSL_VERIFYHOST, CURLOT_LONG, 0 }, + { "DOH_SSL_VERIFYPEER", CURLOPT_DOH_SSL_VERIFYPEER, CURLOT_LONG, 0 }, + { "DOH_SSL_VERIFYSTATUS", CURLOPT_DOH_SSL_VERIFYSTATUS, CURLOT_LONG, 0 }, + { "DOH_URL", CURLOPT_DOH_URL, CURLOT_STRING, 0 }, + { "ECH", CURLOPT_ECH, 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_SERVER_RESPONSE_TIMEOUT, + CURLOT_LONG, CURLOT_FLAG_ALIAS }, + { "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 }, + { "HAPROXY_CLIENT_IP", CURLOPT_HAPROXY_CLIENT_IP, CURLOT_STRING, 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_ALLOWFAILS, + CURLOT_LONG, CURLOT_FLAG_ALIAS }, + { "MAIL_RCPT_ALLOWFAILS", CURLOPT_MAIL_RCPT_ALLOWFAILS, 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 }, + { "MAXLIFETIME_CONN", CURLOPT_MAXLIFETIME_CONN, CURLOT_LONG, 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 }, + { "MIME_OPTIONS", CURLOPT_MIME_OPTIONS, CURLOT_LONG, 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 }, + { "PREREQDATA", CURLOPT_PREREQDATA, CURLOT_CBPTR, 0 }, + { "PREREQFUNCTION", CURLOPT_PREREQFUNCTION, CURLOT_FUNCTION, 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 }, + { "PROTOCOLS_STR", CURLOPT_PROTOCOLS_STR, CURLOT_STRING, 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_CAINFO_BLOB", CURLOPT_PROXY_CAINFO_BLOB, CURLOT_BLOB, 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 }, + { "QUICK_EXIT", CURLOPT_QUICK_EXIT, 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 }, + { "REDIR_PROTOCOLS_STR", CURLOPT_REDIR_PROTOCOLS_STR, CURLOT_STRING, 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_SERVER_RESPONSE_TIMEOUT, + CURLOT_LONG, 0 }, + { "SERVER_RESPONSE_TIMEOUT_MS", CURLOPT_SERVER_RESPONSE_TIMEOUT_MS, + CURLOT_LONG, 0 }, + { "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_HOSTKEYDATA", CURLOPT_SSH_HOSTKEYDATA, CURLOT_CBPTR, 0 }, + { "SSH_HOSTKEYFUNCTION", CURLOPT_SSH_HOSTKEYFUNCTION, CURLOT_FUNCTION, 0 }, + { "SSH_HOST_PUBLIC_KEY_MD5", CURLOPT_SSH_HOST_PUBLIC_KEY_MD5, + CURLOT_STRING, 0 }, + { "SSH_HOST_PUBLIC_KEY_SHA256", CURLOPT_SSH_HOST_PUBLIC_KEY_SHA256, + 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_SIGNATURE_ALGORITHMS", CURLOPT_SSL_SIGNATURE_ALGORITHMS, + CURLOT_STRING, 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_KEEPCNT", CURLOPT_TCP_KEEPCNT, 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 }, + { "UPLOAD_FLAGS", CURLOPT_UPLOAD_FLAGS, 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 }, + { "WS_OPTIONS", CURLOPT_WS_OPTIONS, CURLOT_LONG, 0 }, + { "XFERINFODATA", CURLOPT_XFERINFODATA, CURLOT_CBPTR, 0 }, + { "XFERINFOFUNCTION", CURLOPT_XFERINFOFUNCTION, CURLOT_FUNCTION, 0 }, + { "XOAUTH2_BEARER", CURLOPT_XOAUTH2_BEARER, CURLOT_STRING, 0 }, + { NULL, CURLOPT_LASTENTRY, CURLOT_LONG, 0 } /* end of table */ }; #ifdef DEBUGBUILD diff --git a/lib/escape.c b/lib/escape.c index 04b46f7a9e26..3e49701bcb62 100644 --- a/lib/escape.c +++ b/lib/escape.c @@ -52,8 +52,7 @@ char *curl_unescape(const char *string, int length) /* Escapes for URL the given unescaped string of given length. * 'data' is ignored since 7.82.0. */ -char *curl_easy_escape(CURL *data, const char *string, - int inlength) +char *curl_easy_escape(CURL *data, const char *string, int inlength) { size_t length; struct dynbuf d; @@ -79,7 +78,7 @@ char *curl_easy_escape(CURL *data, const char *string, } else { /* encode it */ - unsigned char out[3]={'%'}; + unsigned char out[3] = { '%' }; Curl_hexbyte(&out[1], in); if(curlx_dyn_addn(&d, out, 3)) return NULL; @@ -163,8 +162,7 @@ CURLcode Curl_urldecode(const char *string, size_t length, * If olen == NULL, no output length is stored. * 'data' is ignored since 7.82.0. */ -char *curl_easy_unescape(CURL *data, const char *string, - int length, int *olen) +char *curl_easy_unescape(CURL *data, const char *string, int length, int *olen) { char *str = NULL; (void)data; @@ -177,7 +175,7 @@ char *curl_easy_unescape(CURL *data, const char *string, return NULL; if(olen) { - if(outputlen <= (size_t) INT_MAX) + if(outputlen <= (size_t)INT_MAX) *olen = curlx_uztosi(outputlen); else /* too large to return in an int, fail! */ diff --git a/lib/fake_addrinfo.c b/lib/fake_addrinfo.c index 7d5da09ead53..f771c29009a4 100644 --- a/lib/fake_addrinfo.c +++ b/lib/fake_addrinfo.c @@ -181,8 +181,7 @@ int r_getaddrinfo(const char *node, } } - ares_getaddrinfo(channel, node, service, &ahints, - async_addrinfo_cb, &ctx); + ares_getaddrinfo(channel, node, service, &ahints, async_addrinfo_cb, &ctx); /* Wait until no more requests are left to be processed */ ares_queue_wait_empty(channel, -1); diff --git a/lib/file.c b/lib/file.c index 2f30a0297ca6..0f969571265a 100644 --- a/lib/file.c +++ b/lib/file.c @@ -127,7 +127,6 @@ const struct Curl_handler Curl_handler_file = { PROTOPT_NONETWORK | PROTOPT_NOURLQUERY /* flags */ }; - static void file_cleanup(struct FILEPROTO *file) { Curl_safefree(file->freepath); @@ -332,7 +331,7 @@ static CURLcode file_upload(struct Curl_easy *data, if(!dir[1]) return CURLE_FILE_COULDNT_READ_FILE; /* fix: better error code */ - mode = O_WRONLY|O_CREAT|CURL_O_BINARY; + mode = O_WRONLY | O_CREAT | CURL_O_BINARY; if(data->state.resume_from) mode |= O_APPEND; else @@ -478,7 +477,7 @@ static CURLcode file_do(struct Curl_easy *data, bool *done) const struct tm *tm = &buffer; char header[80]; int headerlen; - static const char accept_ranges[]= { "Accept-ranges: bytes\r\n" }; + static const char accept_ranges[] = { "Accept-ranges: bytes\r\n" }; if(expected_size >= 0) { headerlen = curl_msnprintf(header, sizeof(header), @@ -502,7 +501,7 @@ static CURLcode file_do(struct Curl_easy *data, bool *done) headerlen = curl_msnprintf(header, sizeof(header), "Last-Modified: %s, %02d %s %4d %02d:%02d:%02d GMT\r\n", - Curl_wkday[tm->tm_wday ? tm->tm_wday-1 : 6], + Curl_wkday[tm->tm_wday ? tm->tm_wday - 1 : 6], tm->tm_mday, Curl_month[tm->tm_mon], tm->tm_year + 1900, @@ -568,10 +567,10 @@ static CURLcode file_do(struct Curl_easy *data, bool *done) if(!S_ISDIR(statbuf.st_mode)) { #ifdef __AMIGA__ if(data->state.resume_from != - lseek(fd, (off_t)data->state.resume_from, SEEK_SET)) + lseek(fd, (off_t)data->state.resume_from, SEEK_SET)) #else if(data->state.resume_from != - lseek(fd, data->state.resume_from, SEEK_SET)) + lseek(fd, data->state.resume_from, SEEK_SET)) #endif return CURLE_BAD_DOWNLOAD_RESUME; } @@ -591,11 +590,11 @@ static CURLcode file_do(struct Curl_easy *data, bool *done) size_t bytestoread; if(size_known) { - bytestoread = (expected_size < (curl_off_t)(xfer_blen-1)) ? - curlx_sotouz(expected_size) : (xfer_blen-1); + bytestoread = (expected_size < (curl_off_t)(xfer_blen - 1)) ? + curlx_sotouz(expected_size) : (xfer_blen - 1); } else - bytestoread = xfer_blen-1; + bytestoread = xfer_blen - 1; nread = read(fd, xfer_buf, bytestoread); diff --git a/lib/formdata.c b/lib/formdata.c index d4bfed89beaa..e51bf14b6323 100644 --- a/lib/formdata.c +++ b/lib/formdata.c @@ -41,13 +41,13 @@ struct Curl_easy; #include "curlx/warnless.h" -#define HTTPPOST_PTRNAME CURL_HTTPPOST_PTRNAME -#define HTTPPOST_FILENAME CURL_HTTPPOST_FILENAME +#define HTTPPOST_PTRNAME CURL_HTTPPOST_PTRNAME +#define HTTPPOST_FILENAME CURL_HTTPPOST_FILENAME #define HTTPPOST_PTRCONTENTS CURL_HTTPPOST_PTRCONTENTS -#define HTTPPOST_READFILE CURL_HTTPPOST_READFILE -#define HTTPPOST_PTRBUFFER CURL_HTTPPOST_PTRBUFFER -#define HTTPPOST_CALLBACK CURL_HTTPPOST_CALLBACK -#define HTTPPOST_BUFFER CURL_HTTPPOST_BUFFER +#define HTTPPOST_READFILE CURL_HTTPPOST_READFILE +#define HTTPPOST_PTRBUFFER CURL_HTTPPOST_PTRBUFFER +#define HTTPPOST_CALLBACK CURL_HTTPPOST_CALLBACK +#define HTTPPOST_BUFFER CURL_HTTPPOST_BUFFER /*************************************************************************** * @@ -59,11 +59,10 @@ struct Curl_easy; * Returns newly allocated HttpPost on success and NULL if malloc failed. * ***************************************************************************/ -static struct curl_httppost * -AddHttpPost(struct FormInfo *src, - struct curl_httppost *parent_post, - struct curl_httppost **httppost, - struct curl_httppost **last_post) +static struct curl_httppost *AddHttpPost(struct FormInfo *src, + struct curl_httppost *parent_post, + struct curl_httppost **httppost, + struct curl_httppost **last_post) { struct curl_httppost *post; size_t namelength = src->namelength; @@ -227,21 +226,19 @@ static CURLFORMcode FormAddCheck(struct FormInfo *first_form, /* go through the list, check for completeness and if everything is * alright add the HttpPost item otherwise set retval accordingly */ - for(form = first_form; - form != NULL; - form = form->more) { + for(form = first_form; form != NULL; form = form->more) { if(((!form->name || !form->value) && !post) || - ( (form->contentslength) && - (form->flags & HTTPPOST_FILENAME) ) || - ( (form->flags & HTTPPOST_FILENAME) && - (form->flags & HTTPPOST_PTRCONTENTS) ) || + (form->contentslength && + (form->flags & HTTPPOST_FILENAME)) || + ((form->flags & HTTPPOST_FILENAME) && + (form->flags & HTTPPOST_PTRCONTENTS)) || - ( (!form->buffer) && - (form->flags & HTTPPOST_BUFFER) && - (form->flags & HTTPPOST_PTRBUFFER) ) || + (!form->buffer && + (form->flags & HTTPPOST_BUFFER) && + (form->flags & HTTPPOST_PTRBUFFER)) || - ( (form->flags & HTTPPOST_READFILE) && - (form->flags & HTTPPOST_PTRCONTENTS) ) + ((form->flags & HTTPPOST_READFILE) && + (form->flags & HTTPPOST_PTRCONTENTS)) ) { return CURL_FORMADD_INCOMPLETE; } @@ -285,7 +282,7 @@ static CURLFORMcode FormAddCheck(struct FormInfo *first_form, HTTPPOST_PTRCONTENTS | HTTPPOST_PTRBUFFER | HTTPPOST_CALLBACK)) && form->value) { /* copy value (without strdup; possibly contains null characters) */ - size_t clen = (size_t) form->contentslength; + size_t clen = (size_t)form->contentslength; if(!clen) clen = strlen(form->value) + 1; @@ -321,10 +318,8 @@ static void free_chain(struct curl_httppost *c) } } -static -CURLFORMcode FormAdd(struct curl_httppost **httppost, - struct curl_httppost **last_post, - va_list params) +static CURLFORMcode FormAdd(struct curl_httppost **httppost, + struct curl_httppost **last_post, va_list params) { struct FormInfo *first_form, *curr, *form = NULL; CURLFORMcode retval = CURL_FORMADD_OK; @@ -442,13 +437,12 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost, case CURLFORM_CONTENTLEN: curr->flags |= CURL_HTTPPOST_LARGE; curr->contentslength = - array_state ? (curl_off_t)(size_t)avalue : - va_arg(params, curl_off_t); + array_state ? (curl_off_t)(size_t)avalue : va_arg(params, curl_off_t); break; /* Get contents from a given filename */ case CURLFORM_FILECONTENT: - if(curr->flags & (HTTPPOST_PTRCONTENTS|HTTPPOST_READFILE)) + if(curr->flags & (HTTPPOST_PTRCONTENTS | HTTPPOST_READFILE)) retval = CURL_FORMADD_OPTION_TWICE; else { if(!array_state) @@ -513,7 +507,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost, break; case CURLFORM_BUFFERPTR: - curr->flags |= HTTPPOST_PTRBUFFER|HTTPPOST_BUFFER; + curr->flags |= HTTPPOST_PTRBUFFER | HTTPPOST_BUFFER; if(curr->buffer) retval = CURL_FORMADD_OPTION_TWICE; else { @@ -597,21 +591,20 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost, } break; - case CURLFORM_CONTENTHEADER: - { - /* this "cast increases required alignment of target type" but - we consider it OK anyway */ - struct curl_slist *list = array_state ? - (struct curl_slist *)(void *)avalue : - va_arg(params, struct curl_slist *); + case CURLFORM_CONTENTHEADER: { + /* this "cast increases required alignment of target type" but + we consider it OK anyway */ + struct curl_slist *list = array_state ? + (struct curl_slist *)(void *)avalue : + va_arg(params, struct curl_slist *); - if(curr->contentheader) - retval = CURL_FORMADD_OPTION_TWICE; - else - curr->contentheader = list; + if(curr->contentheader) + retval = CURL_FORMADD_OPTION_TWICE; + else + curr->contentheader = list; - break; - } + break; + } case CURLFORM_FILENAME: case CURLFORM_BUFFER: if(!array_state) @@ -672,8 +665,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost, */ CURLFORMcode curl_formadd(struct curl_httppost **httppost, - struct curl_httppost **last_post, - ...) + struct curl_httppost **last_post, ...) { va_list arg; CURLFORMcode result; @@ -717,7 +709,7 @@ int curl_formget(struct curl_httppost *form, void *arg, } Curl_mime_cleanpart(&toppart); - return (int) result; + return (int)result; } /* @@ -741,8 +733,7 @@ void curl_formfree(struct curl_httppost *form) if(!(form->flags & HTTPPOST_PTRNAME)) curlx_free(form->name); /* free the name */ if(!(form->flags & - (HTTPPOST_PTRCONTENTS|HTTPPOST_BUFFER|HTTPPOST_CALLBACK)) - ) + (HTTPPOST_PTRCONTENTS | HTTPPOST_BUFFER | HTTPPOST_CALLBACK))) curlx_free(form->contents); /* free the contents */ curlx_free(form->contenttype); /* free the content type */ curlx_free(form->showfilename); /* free the faked filename */ @@ -751,7 +742,6 @@ void curl_formfree(struct curl_httppost *form) } while(form); /* continue */ } - /* Set mime part name, taking care of non null-terminated name string. */ static CURLcode setname(curl_mimepart *part, const char *name, size_t len) { @@ -893,7 +883,7 @@ CURLcode Curl_getformdata(CURL *data, /* Set fake filename. */ if(!result && post->showfilename) if(post->more || (post->flags & (HTTPPOST_FILENAME | HTTPPOST_BUFFER | - HTTPPOST_CALLBACK))) + HTTPPOST_CALLBACK))) result = curl_mime_filename(part, post->showfilename); } } @@ -907,8 +897,7 @@ CURLcode Curl_getformdata(CURL *data, #else /* if disabled */ CURLFORMcode curl_formadd(struct curl_httppost **httppost, - struct curl_httppost **last_post, - ...) + struct curl_httppost **last_post, ...) { (void)httppost; (void)last_post; @@ -930,4 +919,4 @@ void curl_formfree(struct curl_httppost *form) /* Nothing to do. */ } -#endif /* if disabled */ +#endif /* if disabled */ diff --git a/lib/formdata.h b/lib/formdata.h index 74f00bf4fcbc..e80b83bbf491 100644 --- a/lib/formdata.h +++ b/lib/formdata.h @@ -55,5 +55,4 @@ CURLcode Curl_getformdata(CURL *data, curl_read_callback fread_func); #endif /* CURL_DISABLE_FORM_API */ - #endif /* HEADER_CURL_FORMDATA_H */ diff --git a/lib/ftp.c b/lib/ftp.c index b2b15a89dcd3..49f042c7c4c7 100644 --- a/lib/ftp.c +++ b/lib/ftp.c @@ -88,11 +88,11 @@ #define LASTLINE(line) (STATUSCODE(line) && (' ' == line[3])) #ifdef CURL_DISABLE_VERBOSE_STRINGS -#define ftp_pasv_verbose(a,b,c,d) Curl_nop_stmt -#define FTP_CSTATE(c) ((void)(c), "") +#define ftp_pasv_verbose(a, b, c, d) Curl_nop_stmt +#define FTP_CSTATE(c) ((void)(c), "") #else /* CURL_DISABLE_VERBOSE_STRINGS */ /* for tracing purposes */ -static const char * const ftp_state_names[]={ +static const char * const ftp_state_names[] = { "STOP", "WAIT220", "AUTH", @@ -131,7 +131,7 @@ static const char * const ftp_state_names[]={ "STOR", "QUIT" }; -#define FTP_CSTATE(ftpc) ((ftpc)? ftp_state_names[(ftpc)->state] : "???") +#define FTP_CSTATE(ftpc) ((ftpc) ? ftp_state_names[(ftpc)->state] : "???") #endif /* !CURL_DISABLE_VERBOSE_STRINGS */ @@ -163,12 +163,11 @@ static void ftp_state_low(struct Curl_easy *data, ftpc->state = newstate; } - /* Local API functions */ #ifndef DEBUGBUILD -#define ftp_state(x,y,z) ftp_state_low(x,y,z) +#define ftp_state(x, y, z) ftp_state_low(x, y, z) #else /* !DEBUGBUILD */ -#define ftp_state(x,y,z) ftp_state_low(x,y,z,__LINE__) +#define ftp_state(x, y, z) ftp_state_low(x, y, z, __LINE__) #endif /* DEBUGBUILD */ static CURLcode ftp_sendquote(struct Curl_easy *data, @@ -270,7 +269,6 @@ const struct Curl_handler Curl_handler_ftp = { PROTOPT_CONN_REUSE /* flags */ }; - #ifdef USE_SSL /* * FTPS protocol handler. @@ -490,7 +488,7 @@ static CURLcode ftp_check_ctrl_on_data_wait(struct Curl_easy *data, infof(data, "FTP code: %03d", ftpcode); - if(ftpcode/100 > 3) + if(ftpcode / 100 > 3) return CURLE_FTP_ACCEPT_FAILED; return CURLE_WEIRD_SERVER_REPLY; @@ -762,8 +760,8 @@ static CURLcode ftp_domore_pollset(struct Curl_easy *data, /* if stopped and still in this state, then we are also waiting for a connect on the secondary connection */ DEBUGASSERT(data->conn->sock[SECONDARYSOCKET] != CURL_SOCKET_BAD || - (data->conn->cfilter[SECONDARYSOCKET] && - !Curl_conn_is_connected(data->conn, SECONDARYSOCKET))); + (data->conn->cfilter[SECONDARYSOCKET] && + !Curl_conn_is_connected(data->conn, SECONDARYSOCKET))); /* An unconnected SECONDARY will add its socket by itself * via its adjust_pollset() */ return Curl_pollset_add_in(data, ps, data->conn->sock[FIRSTSOCKET]); @@ -782,7 +780,7 @@ static const char *pathpiece(struct ftp_conn *ftpc, int num) { DEBUGASSERT(ftpc->dirs); DEBUGASSERT(ftpc->dirdepth > num); - return &ftpc->rawpath[ ftpc->dirs[num].start ]; + return &ftpc->rawpath[ftpc->dirs[num].start]; } /* This is called after the FTP_QUOTE state is passed. @@ -953,7 +951,7 @@ static CURLcode ftp_state_use_port(struct Curl_easy *data, if(addrlen) { const struct Curl_sockaddr_ex *remote_addr = - Curl_conn_get_remote_addr(data, FIRSTSOCKET); + Curl_conn_get_remote_addr(data, FIRSTSOCKET); DEBUGASSERT(remote_addr); if(!remote_addr) @@ -971,15 +969,15 @@ static CURLcode ftp_state_use_port(struct Curl_easy *data, conn->scope_id, #endif ipstr, hbuf, sizeof(hbuf))) { - case IF2IP_NOT_FOUND: - /* not an interface, use the given string as hostname instead */ - host = ipstr; - break; - case IF2IP_AF_NOT_SUPPORTED: - goto out; - case IF2IP_FOUND: - host = hbuf; /* use the hbuf for hostname */ - break; + case IF2IP_NOT_FOUND: + /* not an interface, use the given string as hostname instead */ + host = ipstr; + break; + case IF2IP_AF_NOT_SUPPORTED: + goto out; + case IF2IP_FOUND: + host = hbuf; /* use the hbuf for hostname */ + break; } } else @@ -1060,7 +1058,7 @@ static CURLcode ftp_state_use_port(struct Curl_easy *data, sa6->sin6_port = htons(port); #endif /* Try binding the given address. */ - if(bind(portsock, sa, sslen) ) { + if(bind(portsock, sa, sslen)) { /* It failed. */ error = SOCKERRNO; if(possibly_non_local && (error == SOCKEADDRNOTAVAIL)) { @@ -1501,7 +1499,6 @@ static CURLcode ftp_state_mdtm(struct Curl_easy *data, return result; } - /* This is called after the TYPE and possible quote commands have been sent */ static CURLcode ftp_state_ul_setup(struct Curl_easy *data, struct ftp_conn *ftpc, @@ -1554,7 +1551,7 @@ static CURLcode ftp_state_ul_setup(struct Curl_easy *data, } /* seekerr == CURL_SEEKFUNC_CANTSEEK (cannot seek to offset) */ do { - char scratch[4*1024]; + char scratch[4 * 1024]; size_t readthisamountnow = (data->state.resume_from - passed > (curl_off_t)sizeof(scratch)) ? sizeof(scratch) : @@ -1752,7 +1749,6 @@ static CURLcode ftp_epsv_disable(struct Curl_easy *data, return result; } - static CURLcode ftp_control_addr_dup(struct Curl_easy *data, char **newhostp) { @@ -1810,8 +1806,7 @@ static CURLcode ftp_state_pasv_resp(struct Curl_easy *data, struct pingpong *pp = &ftpc->pp; char *newhost = NULL; unsigned short newport = 0; - char *str = - curlx_dyn_ptr(&pp->recvbuf) + 4; /* start on the first letter */ + char *str = curlx_dyn_ptr(&pp->recvbuf) + 4; /* start on the first letter */ if((ftpc->count1 == 0) && (ftpcode == 229)) { @@ -1872,8 +1867,7 @@ static CURLcode ftp_state_pasv_resp(struct Curl_easy *data, /* told to ignore the remotely given IP but instead use the host we used for the control connection */ infof(data, "Skip %u.%u.%u.%u for data connection, reuse %s instead", - ip[0], ip[1], ip[2], ip[3], - conn->host.name); + ip[0], ip[1], ip[2], ip[3], conn->host.name); result = ftp_control_addr_dup(data, &newhost); if(result) return result; @@ -2024,7 +2018,7 @@ static CURLcode ftp_state_port_resp(struct Curl_easy *data, static int twodigit(const char *p) { - return (p[0]-'0') * 10 + (p[1]-'0'); + return (p[0] - '0') * 10 + (p[1] - '0'); } static bool ftp_213_date(const char *p, int *year, int *month, int *day, @@ -2079,27 +2073,26 @@ static CURLcode ftp_state_mdtm_resp(struct Curl_easy *data, CURLcode result = CURLE_OK; switch(ftpcode) { - case 213: - { - /* we got a time. Format should be: "YYYYMMDDHHMMSS[.sss]" where the - last .sss part is optional and means fractions of a second */ - int year, month, day, hour, minute, second; - struct pingpong *pp = &ftpc->pp; - char *resp = curlx_dyn_ptr(&pp->recvbuf) + 4; - bool showtime = FALSE; - if(ftp_213_date(resp, &year, &month, &day, &hour, &minute, &second)) { - /* we have a time, reformat it */ - char timebuf[24]; - curl_msnprintf(timebuf, sizeof(timebuf), - "%04d%02d%02d %02d:%02d:%02d GMT", - year, month, day, hour, minute, second); - /* now, convert this into a time() value: */ - if(!Curl_getdate_capped(timebuf, &data->info.filetime)) - showtime = TRUE; - } + case 213: { + /* we got a time. Format should be: "YYYYMMDDHHMMSS[.sss]" where the + last .sss part is optional and means fractions of a second */ + int year, month, day, hour, minute, second; + struct pingpong *pp = &ftpc->pp; + char *resp = curlx_dyn_ptr(&pp->recvbuf) + 4; + bool showtime = FALSE; + if(ftp_213_date(resp, &year, &month, &day, &hour, &minute, &second)) { + /* we have a time, reformat it */ + char timebuf[24]; + curl_msnprintf(timebuf, sizeof(timebuf), + "%04d%02d%02d %02d:%02d:%02d GMT", + year, month, day, hour, minute, second); + /* now, convert this into a time() value: */ + if(!Curl_getdate_capped(timebuf, &data->info.filetime)) + showtime = TRUE; + } - /* If we asked for a time of the file and we actually got one as well, - we "emulate" an HTTP-style header in our output. */ + /* If we asked for a time of the file and we actually got one as well, + we "emulate" an HTTP-style header in our output. */ #if defined(__GNUC__) && (defined(__DJGPP__) || defined(__AMIGA__)) #pragma GCC diagnostic push @@ -2107,38 +2100,38 @@ static CURLcode ftp_state_mdtm_resp(struct Curl_easy *data, warning: comparison of unsigned expression in '>= 0' is always true */ #pragma GCC diagnostic ignored "-Wtype-limits" #endif - if(data->req.no_body && ftpc->file && - data->set.get_filetime && showtime) { + if(data->req.no_body && ftpc->file && + data->set.get_filetime && showtime) { #if defined(__GNUC__) && (defined(__DJGPP__) || defined(__AMIGA__)) #pragma GCC diagnostic pop #endif - char headerbuf[128]; - int headerbuflen; - time_t filetime = data->info.filetime; - struct tm buffer; - const struct tm *tm = &buffer; + char headerbuf[128]; + int headerbuflen; + time_t filetime = data->info.filetime; + struct tm buffer; + const struct tm *tm = &buffer; - result = Curl_gmtime(filetime, &buffer); - if(result) - return result; + result = Curl_gmtime(filetime, &buffer); + if(result) + return result; - /* format: "Tue, 15 Nov 1994 12:45:26" */ - headerbuflen = - curl_msnprintf(headerbuf, sizeof(headerbuf), - "Last-Modified: %s, %02d %s %4d %02d:%02d:%02d " - "GMT\r\n", - Curl_wkday[tm->tm_wday ? tm->tm_wday-1 : 6], - tm->tm_mday, - Curl_month[tm->tm_mon], - tm->tm_year + 1900, - tm->tm_hour, - tm->tm_min, - tm->tm_sec); - result = client_write_header(data, headerbuf, headerbuflen); - if(result) - return result; - } /* end of a ridiculous amount of conditionals */ - } + /* format: "Tue, 15 Nov 1994 12:45:26" */ + headerbuflen = + curl_msnprintf(headerbuf, sizeof(headerbuf), + "Last-Modified: %s, %02d %s %4d %02d:%02d:%02d " + "GMT\r\n", + Curl_wkday[tm->tm_wday ? tm->tm_wday-1 : 6], + tm->tm_mday, + Curl_month[tm->tm_mon], + tm->tm_year + 1900, + tm->tm_hour, + tm->tm_min, + tm->tm_sec); + result = client_write_header(data, headerbuf, headerbuflen); + if(result) + return result; + } /* end of a ridiculous amount of conditionals */ + } break; default: infof(data, "unsupported MDTM reply format"); @@ -2194,7 +2187,7 @@ static CURLcode ftp_state_type_resp(struct Curl_easy *data, { CURLcode result = CURLE_OK; - if(ftpcode/100 != 2) { + if(ftpcode / 100 != 2) { /* "sasserftpd" and "(u)r(x)bot ftpd" both responds with 226 after a successful 'TYPE I'. While that is not as RFC959 says, it is still a positive response code and we allow that. */ @@ -2267,7 +2260,7 @@ static CURLcode ftp_state_retr(struct Curl_easy *data, return CURLE_BAD_DOWNLOAD_RESUME; } /* Now store the number of bytes we are expected to download */ - ftp->downloadsize = filesize-data->state.resume_from; + ftp->downloadsize = filesize - data->state.resume_from; } } @@ -2378,7 +2371,7 @@ static CURLcode ftp_state_rest_resp(struct Curl_easy *data, case FTP_REST: default: if(ftpcode == 350) { - char buffer[24]= { "Accept-ranges: bytes\r\n" }; + char buffer[24] = { "Accept-ranges: bytes\r\n" }; result = client_write_header(data, buffer, strlen(buffer)); if(result) return result; @@ -2590,12 +2583,11 @@ static CURLcode ftp_state_user_resp(struct Curl_easy *data, 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(data, &ftpc->pp, "PASS %s", - data->conn->passwd); + result = Curl_pp_sendf(data, &ftpc->pp, "PASS %s", data->conn->passwd); if(!result) ftp_state(data, ftpc, FTP_PASS); } - else if(ftpcode/100 == 2) { + else if(ftpcode / 100 == 2) { /* 230 User ... logged in. (the user logged in with or without password) */ result = ftp_state_loggedin(data, ftpc); @@ -2621,9 +2613,8 @@ static CURLcode ftp_state_user_resp(struct Curl_easy *data, if(data->set.str[STRING_FTP_ALTERNATIVE_TO_USER] && !ftpc->ftp_trying_alternative) { /* Ok, USER failed. Let's try the supplied command. */ - result = - Curl_pp_sendf(data, &ftpc->pp, "%s", - data->set.str[STRING_FTP_ALTERNATIVE_TO_USER]); + result = Curl_pp_sendf(data, &ftpc->pp, "%s", + data->set.str[STRING_FTP_ALTERNATIVE_TO_USER]); if(!result) { ftpc->ftp_trying_alternative = TRUE; ftp_state(data, ftpc, FTP_USER); @@ -2789,8 +2780,7 @@ static CURLcode ftp_wait_resp(struct Curl_easy *data, (int)data->set.ftpsslauth); return CURLE_UNKNOWN_OPTION; /* we do not know what to do */ } - result = Curl_pp_sendf(data, &ftpc->pp, "AUTH %s", - ftpauth[ftpc->count1]); + result = Curl_pp_sendf(data, &ftpc->pp, "AUTH %s", ftpauth[ftpc->count1]); if(!result) ftp_state(data, ftpc, FTP_AUTH); } @@ -2890,10 +2880,9 @@ static CURLcode ftp_pp_statemachine(struct Curl_easy *data, break; case FTP_PROT: - if(ftpcode/100 == 2) + if(ftpcode / 100 == 2) /* We have enabled SSL for the data connection! */ - conn->bits.ftp_use_data_ssl = - (data->set.use_ssl != CURLUSESSL_CONTROL); + conn->bits.ftp_use_data_ssl = (data->set.use_ssl != CURLUSESSL_CONTROL); /* FTP servers typically responds with 500 if they decide to reject our 'P' request */ else if(data->set.use_ssl > CURLUSESSL_CONTROL) @@ -3005,7 +2994,7 @@ static CURLcode ftp_pp_statemachine(struct Curl_easy *data, break; case FTP_CWD: - if(ftpcode/100 != 2) { + if(ftpcode / 100 != 2) { /* failure to CWD there */ if(data->set.ftp_create_missing_dirs && ftpc->cwdcount && !ftpc->count2) { @@ -3047,7 +3036,7 @@ static CURLcode ftp_pp_statemachine(struct Curl_easy *data, break; case FTP_MKD: - if((ftpcode/100 != 2) && !ftpc->count3--) { + if((ftpcode / 100 != 2) && !ftpc->count3--) { /* failure to MKD the directory */ failf(data, "Failed to MKD dir: %03d", ftpcode); result = CURLE_REMOTE_ACCESS_DENIED; @@ -3120,7 +3109,6 @@ static CURLcode ftp_pp_statemachine(struct Curl_easy *data, return result; } - /* called repeatedly until done from multi.c */ static CURLcode ftp_statemach(struct Curl_easy *data, struct ftp_conn *ftpc, @@ -3419,10 +3407,9 @@ static CURLcode ftp_done(struct Curl_easy *data, CURLcode status, * * BLOCKING */ -static -CURLcode ftp_sendquote(struct Curl_easy *data, - struct ftp_conn *ftpc, - struct curl_slist *quote) +static CURLcode ftp_sendquote(struct Curl_easy *data, + struct ftp_conn *ftpc, + struct curl_slist *quote) { struct curl_slist *item; struct pingpong *pp = &ftpc->pp; @@ -3913,8 +3900,7 @@ static CURLcode wc_statemach(struct Curl_easy *data, Curl_set_in_callback(data, FALSE); switch(userresponse) { case CURL_CHUNK_BGN_FUNC_SKIP: - infof(data, "Wildcard - \"%s\" skipped by user", - finfo->filename); + infof(data, "Wildcard - \"%s\" skipped by user", finfo->filename); wildcard->state = CURLWC_SKIP; continue; case CURL_CHUNK_BGN_FUNC_FAIL: @@ -4130,10 +4116,9 @@ static size_t numof_slashes(const char *str) * Parse the URL path into separate path components. * */ -static -CURLcode ftp_parse_url_path(struct Curl_easy *data, - struct ftp_conn *ftpc, - struct FTP *ftp) +static CURLcode ftp_parse_url_path(struct Curl_easy *data, + struct ftp_conn *ftpc, + struct FTP *ftp) { const char *slashPos = NULL; const char *fileName = NULL; @@ -4155,78 +4140,78 @@ CURLcode ftp_parse_url_path(struct Curl_easy *data, rawPath = ftpc->rawpath; switch(data->set.ftp_filemethod) { - case FTPFILE_NOCWD: /* fastest, but less standard-compliant */ + 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; + 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 = 1; - - ftpc->dirs = curlx_calloc(1, sizeof(ftpc->dirs[0])); - if(!ftpc->dirs) - return CURLE_OUT_OF_MEMORY; - - ftpc->dirs[0].start = 0; - ftpc->dirs[0].len = (int)dirlen; - ftpc->dirdepth = 1; /* we consider it to be a single directory */ - fileName = slashPos + 1; /* rest is filename */ - } - else - fileName = rawPath; /* filename only (or empty) */ - 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 = 1; - default: /* allow pretty much anything */ - case FTPFILE_MULTICWD: { - /* current position: begin of next path component */ - const char *curPos = rawPath; - - /* number of entries to allocate for the 'dirs' array */ - size_t dirAlloc = numof_slashes(rawPath); - - if(dirAlloc >= FTP_MAX_DIR_DEPTH) - /* suspiciously deep directory hierarchy */ - return CURLE_URL_MALFORMAT; - - if(dirAlloc) { - ftpc->dirs = curlx_calloc(dirAlloc, sizeof(ftpc->dirs[0])); - if(!ftpc->dirs) - return CURLE_OUT_OF_MEMORY; - - /* parse the URL path into separate path components */ - while(dirAlloc--) { - const char *spos = strchr(curPos, '/'); - size_t clen = spos - curPos; - - /* path starts with a slash: add that as a directory */ - if(!clen && (ftpc->dirdepth == 0)) - ++clen; - - /* we skip empty path components, like "x//y" since the FTP command - CWD requires a parameter and a non-existent parameter a) does not - work on many servers and b) has no effect on the others. */ - if(clen) { - ftpc->dirs[ftpc->dirdepth].start = (int)(curPos - rawPath); - ftpc->dirs[ftpc->dirdepth].len = (int)clen; - ftpc->dirdepth++; - } - curPos = spos + 1; + ftpc->dirs = curlx_calloc(1, sizeof(ftpc->dirs[0])); + if(!ftpc->dirs) + return CURLE_OUT_OF_MEMORY; + + ftpc->dirs[0].start = 0; + ftpc->dirs[0].len = (int)dirlen; + ftpc->dirdepth = 1; /* we consider it to be a single directory */ + fileName = slashPos + 1; /* rest is filename */ + } + else + fileName = rawPath; /* filename only (or empty) */ + break; + + default: /* allow pretty much anything */ + case FTPFILE_MULTICWD: { + /* current position: begin of next path component */ + const char *curPos = rawPath; + + /* number of entries to allocate for the 'dirs' array */ + size_t dirAlloc = numof_slashes(rawPath); + + if(dirAlloc >= FTP_MAX_DIR_DEPTH) + /* suspiciously deep directory hierarchy */ + return CURLE_URL_MALFORMAT; + + if(dirAlloc) { + ftpc->dirs = curlx_calloc(dirAlloc, sizeof(ftpc->dirs[0])); + if(!ftpc->dirs) + return CURLE_OUT_OF_MEMORY; + + /* parse the URL path into separate path components */ + while(dirAlloc--) { + const char *spos = strchr(curPos, '/'); + size_t clen = spos - curPos; + + /* path starts with a slash: add that as a directory */ + if(!clen && (ftpc->dirdepth == 0)) + ++clen; + + /* we skip empty path components, like "x//y" since the FTP command + CWD requires a parameter and a non-existent parameter a) does not + work on many servers and b) has no effect on the others. */ + if(clen) { + ftpc->dirs[ftpc->dirdepth].start = (int)(curPos - rawPath); + ftpc->dirs[ftpc->dirdepth].len = (int)clen; + ftpc->dirdepth++; } + curPos = spos + 1; } - fileName = curPos; /* the rest is the filename (or empty) */ } + fileName = curPos; /* the rest is the filename (or empty) */ + } break; } /* switch */ @@ -4327,11 +4312,10 @@ static CURLcode ftp_doing(struct Curl_easy *data, * ftp->ctl_valid starts out as FALSE, and gets set to TRUE if we reach the * ftp_done() function without finding any major problem. */ -static -CURLcode ftp_regular_transfer(struct Curl_easy *data, - struct ftp_conn *ftpc, - struct FTP *ftp, - bool *dophase_done) +static CURLcode ftp_regular_transfer(struct Curl_easy *data, + struct ftp_conn *ftpc, + struct FTP *ftp, + bool *dophase_done) { CURLcode result = CURLE_OK; bool connected = FALSE; diff --git a/lib/ftplistparser.c b/lib/ftplistparser.c index b62fa47f6542..5a1194613753 100644 --- a/lib/ftplistparser.c +++ b/lib/ftplistparser.c @@ -215,7 +215,6 @@ struct ftp_parselist_data *Curl_ftp_parselist_data_alloc(void) return curlx_calloc(1, sizeof(struct ftp_parselist_data)); } - void Curl_ftp_parselist_data_free(struct ftp_parselist_data **parserp) { struct ftp_parselist_data *parser = *parserp; @@ -225,13 +224,11 @@ void Curl_ftp_parselist_data_free(struct ftp_parselist_data **parserp) *parserp = NULL; } - CURLcode Curl_ftp_parselist_geterror(struct ftp_parselist_data *pl_data) { return pl_data->error; } - #define FTP_LP_MALFORMATED_PERM 0x01000000 static unsigned int ftp_pl_get_permission(const char *str) @@ -284,7 +281,7 @@ static unsigned int ftp_pl_get_permission(const char *str) if(str[7] == 'w') permissions |= 1 << 1; else if(str[7] != '-') - permissions |= FTP_LP_MALFORMATED_PERM; + permissions |= FTP_LP_MALFORMATED_PERM; if(str[8] == 'x') permissions |= 1; else if(str[8] == 't') { @@ -430,7 +427,6 @@ static CURLcode parse_unix_totalsize(struct ftp_parselist_data *parser, } else return CURLE_FTP_BAD_FILE_LIST; - } break; } @@ -487,7 +483,7 @@ static CURLcode parse_unix_hlinks(struct ftp_parselist_data *parser, } break; case PL_UNIX_HLINKS_NUMBER: - parser->item_length ++; + parser->item_length++; if(c == ' ') { const char *p = &mem[parser->item_offset]; curl_off_t hlinks; @@ -623,7 +619,7 @@ static CURLcode parse_unix_time(struct ftp_parselist_data *parser, case PL_UNIX_TIME_PREPART1: if(c != ' ') { if(ISALNUM(c) && len) { - parser->item_offset = len -1; + parser->item_offset = len - 1; parser->item_length = 1; parser->state.UNIX.sub.time = PL_UNIX_TIME_PART1; } @@ -668,7 +664,7 @@ static CURLcode parse_unix_time(struct ftp_parselist_data *parser, case PL_UNIX_TIME_PART3: parser->item_length++; if(c == ' ') { - mem[parser->item_offset + parser->item_length -1] = 0; + mem[parser->item_offset + parser->item_length - 1] = 0; parser->offsets.time = parser->item_offset; if(finfo->filetype == CURLFILETYPE_SYMLINK) { parser->state.UNIX.main = PL_UNIX_SYMLINK; @@ -924,7 +920,7 @@ static CURLcode parse_winnt(struct Curl_easy *data, case PL_WINNT_TIME_TIME: if(c == ' ') { parser->offsets.time = parser->item_offset; - mem[parser->item_offset + parser->item_length -1] = 0; + mem[parser->item_offset + parser->item_length - 1] = 0; parser->state.NT.main = PL_WINNT_DIRORSIZE; parser->state.NT.sub.dirorsize = PL_WINNT_DIRORSIZE_PRESPACE; parser->item_length = 0; @@ -944,7 +940,7 @@ static CURLcode parse_winnt(struct Curl_easy *data, } break; case PL_WINNT_DIRORSIZE_CONTENT: - parser->item_length ++; + parser->item_length++; if(c == ' ') { mem[parser->item_offset + parser->item_length - 1] = 0; if(strcmp("", mem + parser->item_offset) == 0) { @@ -972,7 +968,7 @@ static CURLcode parse_winnt(struct Curl_easy *data, switch(parser->state.NT.sub.filename) { case PL_WINNT_FILENAME_PRESPACE: if(c != ' ' && len) { - parser->item_offset = len -1; + parser->item_offset = len - 1; parser->item_length = 1; parser->state.NT.sub.filename = PL_WINNT_FILENAME_CONTENT; } @@ -1020,7 +1016,7 @@ static CURLcode parse_winnt(struct Curl_easy *data, size_t Curl_ftp_parselist(char *buffer, size_t size, size_t nmemb, void *connptr) { - size_t bufflen = size*nmemb; + size_t bufflen = size * nmemb; struct Curl_easy *data = (struct Curl_easy *)connptr; struct ftp_wc *ftpwc = data->wildcard->ftpwc; struct ftp_parselist_data *parser = ftpwc->parser; diff --git a/lib/getinfo.c b/lib/getinfo.c index 14244d087b06..13e9622d3302 100644 --- a/lib/getinfo.c +++ b/lib/getinfo.c @@ -128,7 +128,7 @@ static CURLcode getinfo_char(struct Curl_easy *data, CURLINFO info, *param_charp = data->info.contenttype; break; case CURLINFO_PRIVATE: - *param_charp = (char *) data->set.private_data; + *param_charp = (char *)data->set.private_data; break; case CURLINFO_FTP_ENTRY_PATH: /* Return the entrypath string from the most recent connection. @@ -375,7 +375,7 @@ static CURLcode getinfo_long(struct Curl_easy *data, CURLINFO info, return CURLE_OK; } -#define DOUBLE_SECS(x) (double)(x)/1000000 +#define DOUBLE_SECS(x) (double)(x) / 1000000 static CURLcode getinfo_offt(struct Curl_easy *data, CURLINFO info, curl_off_t *param_offt) @@ -577,20 +577,19 @@ static CURLcode getinfo_slist(struct Curl_easy *data, CURLINFO info, *param_slistp = ptr.to_slist; break; case CURLINFO_TLS_SESSION: - case CURLINFO_TLS_SSL_PTR: - { - struct curl_tlssessioninfo **tsip = (struct curl_tlssessioninfo **) - param_slistp; - struct curl_tlssessioninfo *tsi = &data->tsi; - - /* we are exposing a pointer to internal memory with unknown - * lifetime here. */ - *tsip = tsi; - if(!Curl_conn_get_ssl_info(data, data->conn, FIRSTSOCKET, tsi)) { - tsi->backend = Curl_ssl_backend(); - tsi->internals = NULL; - } + case CURLINFO_TLS_SSL_PTR: { + struct curl_tlssessioninfo **tsip = (struct curl_tlssessioninfo **) + param_slistp; + struct curl_tlssessioninfo *tsi = &data->tsi; + + /* we are exposing a pointer to internal memory with unknown + * lifetime here. */ + *tsip = tsi; + if(!Curl_conn_get_ssl_info(data, data->conn, FIRSTSOCKET, tsi)) { + tsi->backend = Curl_ssl_backend(); + tsi->internals = NULL; } + } break; default: return CURLE_UNKNOWN_OPTION; diff --git a/lib/optiontable.pl b/lib/optiontable.pl index 43fbd39d3bfc..54b86d72e1ed 100755 --- a/lib/optiontable.pl +++ b/lib/optiontable.pl @@ -131,19 +131,19 @@ sub add { $name = $alias{$name}; $flag = "CURLOT_FLAG_ALIAS"; } - my $o = sprintf(" {\"%s\", %s, %s, %s},\n", + my $o = sprintf(" { \"%s\", %s, %s, %s },\n", $oname, $opt{$name}, $type{$name}, $flag); if(length($o) < 80) { print $o; } else { - printf(" {\"%s\", %s,\n %s, %s},\n", - $oname, $opt{$name}, $type{$name}, $flag); + printf(" { \"%s\", %s,\n %s, %s },\n", + $oname, $opt{$name}, $type{$name}, $flag); } } print < Date: Tue, 2 Dec 2025 14:26:31 +0100 Subject: [PATCH 165/415] pytest: improve stragglers A fix for the tests that took the longest: - test_05: make the server close the HTTP/1.1 connection when simulating an error during a download. This eliminates waiting for a keepalive timeout - test_02: pause tests with slightly smaller documents, eliminate special setup for HTTP/2. We test stream window handling now elsewhere already - cli_hx_download: run look in 500ms steps instead of 1sec, resuming paused tranfers earlier. Closes #19809 --- docs/libcurl/libcurl-env-dbg.md | 5 ---- lib/http2.c | 23 -------------- tests/http/test_02_download.py | 30 ++----------------- .../http/testenv/mod_curltest/mod_curltest.c | 4 +++ tests/libtest/cli_hx_download.c | 2 +- 5 files changed, 7 insertions(+), 57 deletions(-) diff --git a/docs/libcurl/libcurl-env-dbg.md b/docs/libcurl/libcurl-env-dbg.md index 3fcc1935d5ee..ce6b480ae305 100644 --- a/docs/libcurl/libcurl-env-dbg.md +++ b/docs/libcurl/libcurl-env-dbg.md @@ -164,8 +164,3 @@ Make a blocking, graceful shutdown of all remaining connections when a multi handle is destroyed. This implicitly triggers for easy handles that are run via easy_perform. The value of the environment variable gives the shutdown timeout in milliseconds. - -## `CURL_H2_STREAM_WIN_MAX` - -Set to a positive 32-bit number to override the HTTP/2 stream window's -default of 10MB. Used in testing to verify correct window update handling. diff --git a/lib/http2.c b/lib/http2.c index e75d7431e72c..38c7d82785fe 100644 --- a/lib/http2.c +++ b/lib/http2.c @@ -111,9 +111,6 @@ struct cf_h2_ctx { uint32_t goaway_error; /* goaway error code from server */ int32_t remote_max_sid; /* max id processed by server */ int32_t local_max_sid; /* max id processed by us */ -#ifdef DEBUGBUILD - int32_t stream_win_max; /* max h2 stream window size */ -#endif BIT(initialized); BIT(via_h1_upgrade); BIT(conn_closed); @@ -139,18 +136,6 @@ static void cf_h2_ctx_init(struct cf_h2_ctx *ctx, bool via_h1_upgrade) Curl_uint32_hash_init(&ctx->streams, 63, h2_stream_hash_free); ctx->remote_max_sid = 2147483647; ctx->via_h1_upgrade = via_h1_upgrade; -#ifdef DEBUGBUILD - { - const char *p = getenv("CURL_H2_STREAM_WIN_MAX"); - - ctx->stream_win_max = H2_STREAM_WINDOW_SIZE_MAX; - if(p) { - curl_off_t l; - if(!curlx_str_number(&p, &l, INT_MAX)) - ctx->stream_win_max = (int32_t)l; - } - } -#endif ctx->initialized = TRUE; } @@ -330,15 +315,7 @@ static int32_t cf_h2_get_desired_local_win(struct Curl_cfilter *cf, else if(avail < INT32_MAX) return (int32_t)avail; } -#ifdef DEBUGBUILD - { - struct cf_h2_ctx *ctx = cf->ctx; - CURL_TRC_CF(data, cf, "stream_win_max=%d", ctx->stream_win_max); - return ctx->stream_win_max; - } -#else return H2_STREAM_WINDOW_SIZE_MAX; -#endif } static CURLcode cf_h2_update_local_win(struct Curl_cfilter *cf, diff --git a/tests/http/test_02_download.py b/tests/http/test_02_download.py index 9fbc116caf0a..269ff6cf2695 100644 --- a/tests/http/test_02_download.py +++ b/tests/http/test_02_download.py @@ -277,12 +277,10 @@ def test_02_20_h2_small_frames(self, env: Env, httpd, configures_httpd): # download serial via lib client, pause/resume at different offsets @pytest.mark.parametrize("pause_offset", [0, 10*1024, 100*1023, 640000]) - @pytest.mark.parametrize("proto", ['http/1.1', 'h3']) + @pytest.mark.parametrize("proto", Env.http_protos()) def test_02_21_lib_serial(self, env: Env, httpd, nghttpx, proto, pause_offset): - if proto == 'h3' and not env.have_h3(): - pytest.skip("h3 not supported") count = 2 - docname = 'data-10m' + docname = 'data-1m' url = f'https://localhost:{env.https_port}/{docname}' client = LocalClient(name='cli_hx_download', env=env) if not client.exists(): @@ -294,30 +292,6 @@ def test_02_21_lib_serial(self, env: Env, httpd, nghttpx, proto, pause_offset): srcfile = os.path.join(httpd.docs_dir, docname) self.check_downloads(client, srcfile, count) - # h2 download parallel via lib client, pause/resume at different offsets - # debug-override stream window size to reproduce #16955 - @pytest.mark.parametrize("pause_offset", [0, 10*1024, 100*1023, 640000]) - @pytest.mark.parametrize("swin_max", [0, 10*1024]) - @pytest.mark.skipif(condition=not Env.have_h2_curl(), reason="curl without h2") - def test_02_21_h2_lib_serial(self, env: Env, httpd, pause_offset, swin_max): - proto = 'h2' - count = 2 - docname = 'data-10m' - url = f'https://localhost:{env.https_port}/{docname}' - run_env = os.environ.copy() - run_env['CURL_DEBUG'] = 'multi,http/2' - if swin_max > 0: - run_env['CURL_H2_STREAM_WIN_MAX'] = f'{swin_max}' - client = LocalClient(name='cli_hx_download', env=env, run_env=run_env) - if not client.exists(): - pytest.skip(f'example client not built: {client.name}') - r = client.run(args=[ - '-n', f'{count}', '-P', f'{pause_offset}', '-V', proto, url - ]) - r.check_exit_code(0) - srcfile = os.path.join(httpd.docs_dir, docname) - self.check_downloads(client, srcfile, count) - # download via lib client, several at a time, pause/resume @pytest.mark.parametrize("pause_offset", [100*1023]) @pytest.mark.parametrize("proto", Env.http_protos()) diff --git a/tests/http/testenv/mod_curltest/mod_curltest.c b/tests/http/testenv/mod_curltest/mod_curltest.c index b45fd95286b2..76ce5f459721 100644 --- a/tests/http/testenv/mod_curltest/mod_curltest.c +++ b/tests/http/testenv/mod_curltest/mod_curltest.c @@ -570,6 +570,10 @@ static int curltest_tweak_handler(request_rec *r) APR_BRIGADE_INSERT_TAIL(bb, b); ap_pass_brigade(r->output_filters, bb); } + if(rv == APR_ECONNRESET) { + r->connection->aborted = 1; + return rv; + } return AP_FILTER_ERROR; } diff --git a/tests/libtest/cli_hx_download.c b/tests/libtest/cli_hx_download.c index 2a3614412369..d139ea28f772 100644 --- a/tests/libtest/cli_hx_download.c +++ b/tests/libtest/cli_hx_download.c @@ -449,7 +449,7 @@ static CURLcode test_cli_hx_download(const char *URL) if(still_running) { /* wait for activity, timeout or "nothing" */ - mc = curl_multi_poll(multi, NULL, 0, 1000, NULL); + mc = curl_multi_poll(multi, NULL, 0, 500, NULL); } if(mc) From aba3c63ae8323e68149417d1a56ea7b43b842814 Mon Sep 17 00:00:00 2001 From: Stefan Eissing Date: Mon, 1 Dec 2025 12:48:55 +0100 Subject: [PATCH 166/415] pytest: fix and improve reliability Address issues listed in #19770: - allow for ngttpx to successfully shut down on last attempt that might extend beyond the finish timestamp - timeline checks: allos `time_starttransfer` to appear anywhere in the timeline as a slow client might seen response data before setting the other counters - dump logs on test_05_02 as it was not reproduced locally Fixes #19970 Closes #19783 --- tests/http/test_01_basic.py | 5 +++-- tests/http/test_05_errors.py | 4 ++-- tests/http/testenv/curl.py | 11 +++++++++-- tests/http/testenv/nghttpx.py | 2 +- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/tests/http/test_01_basic.py b/tests/http/test_01_basic.py index 14a8dec957fc..eb328ea73390 100644 --- a/tests/http/test_01_basic.py +++ b/tests/http/test_01_basic.py @@ -308,13 +308,14 @@ def test_01_20_method_space(self, env: Env, proto, httpd): url = f'https://{env.authority_for(env.domain1, proto)}/curltest/echo' r = curl.http_download(urls=[url], alpn_proto=proto, with_stats=True, extra_args=['-X', method]) - assert len(r.stats) == 1 if proto == 'h2' or proto == 'h3': - r.check_response(http_status=0) + # h2+3 may close the connection for such invalid requests re_m = re.compile(r'.*\[:method: ([^\]]+)\].*') lines = [line for line in r.trace_lines if re_m.match(line)] assert len(lines) == 1, f'{r.dump_logs()}' m = re_m.match(lines[0]) assert m.group(1) == method, f'{r.dump_logs()}' else: + # h1 should give us a real response + assert len(r.stats) == 1 r.check_response(http_status=400) diff --git a/tests/http/test_05_errors.py b/tests/http/test_05_errors.py index 258b7f11d5e5..102b92e20256 100644 --- a/tests/http/test_05_errors.py +++ b/tests/http/test_05_errors.py @@ -73,8 +73,8 @@ def test_05_02_partial_20(self, env: Env, httpd, nghttpx, proto): invalid_stats = [] for idx, s in enumerate(r.stats): if 'exitcode' not in s or s['exitcode'] not in [18, 55, 56, 92, 95]: - invalid_stats.append(f'request {idx} exit with {s["exitcode"]}\n{s}') - assert len(invalid_stats) == 0, f'failed: {invalid_stats}' + invalid_stats.append(f'request {idx} exit with {s["exitcode"]}\n{r.dump_logs()}') + assert len(invalid_stats) == 0, f'failed: {invalid_stats}\n{r.dump_logs()}' # access a resource that, on h2, RST the stream with HTTP_1_1_REQUIRED @pytest.mark.skipif(condition=not Env.have_h2_curl(), reason="curl without h2") diff --git a/tests/http/testenv/curl.py b/tests/http/testenv/curl.py index e486715fa79b..f54170baba58 100644 --- a/tests/http/testenv/curl.py +++ b/tests/http/testenv/curl.py @@ -525,6 +525,7 @@ def check_stats_timeline(self, idx): } # stat keys where we expect a positive value ref_tl = [] + somewhere_keys = [] exact_match = True # redirects mess up the queue time, only count without if s['time_redirect'] == 0: @@ -542,10 +543,13 @@ def check_stats_timeline(self, idx): # what kind of transfer was it? if s['size_upload'] == 0 and s['size_download'] > 0: # this is a download - dl_tl = ['time_pretransfer', 'time_starttransfer'] + dl_tl = ['time_pretransfer'] if s['size_request'] > 0: dl_tl = ['time_posttransfer'] + dl_tl ref_tl += dl_tl + # the first byte of the response may arrive before we + # track the other times when the client is slow (CI). + somewhere_keys = ['time_starttransfer'] elif s['size_upload'] > 0 and s['size_download'] == 0: # this is an upload ul_tl = ['time_pretransfer', 'time_posttransfer'] @@ -561,11 +565,14 @@ def check_stats_timeline(self, idx): self.check_stat_positive(s, idx, key) if exact_match: # assert all events not in reference timeline are 0 - for key in [key for key in all_keys if key not in ref_tl]: + for key in [key for key in all_keys if key not in ref_tl and key not in somewhere_keys]: self.check_stat_zero(s, key) # calculate the timeline that did happen seen_tl = sorted(ref_tl, key=lambda ts: s[ts]) assert seen_tl == ref_tl, f'{[f"{ts}: {s[ts]}" for ts in seen_tl]}' + for key in somewhere_keys: + self.check_stat_positive(s, idx, key) + assert s[key] <= s['time_total'] def dump_logs(self): lines = ['>>--stdout ----------------------------------------------\n'] diff --git a/tests/http/testenv/nghttpx.py b/tests/http/testenv/nghttpx.py index 6db888b901be..106766fc0fe7 100644 --- a/tests/http/testenv/nghttpx.py +++ b/tests/http/testenv/nghttpx.py @@ -138,7 +138,7 @@ def reload(self, timeout: timedelta = timedelta(seconds=Env.SERVER_TIMEOUT)): except subprocess.TimeoutExpired: log.warning(f'nghttpx({running.pid}), not shut down yet.') os.kill(running.pid, signal.SIGQUIT) - if datetime.now() >= end_wait: + if running and datetime.now() >= end_wait: log.error(f'nghttpx({running.pid}), terminate forcefully.') os.kill(running.pid, signal.SIGKILL) running.terminate() From d993d46eb14234e36a15288d25dccc6107a6733f Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Wed, 3 Dec 2025 03:06:39 +0100 Subject: [PATCH 167/415] GHA/windows: install MSYS2 c-ares only when used Closes #19820 --- .github/workflows/windows.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index d4019ed176cb..d2e97851fc69 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -204,8 +204,8 @@ jobs: - { build: 'autotools', sys: 'msys' , env: 'x86_64' , tflags: '' , config: '--with-openssl', install: 'openssl-devel libssh2-devel', name: 'default R' } # MinGW - { build: 'autotools', sys: 'mingw64' , env: 'x86_64' , tflags: 'skiprun', config: '--enable-debug --with-openssl --disable-threaded-resolver --disable-curldebug --enable-static=no --without-zlib CPPFLAGS=-D_WIN32_WINNT=0x0501', install: 'mingw-w64-x86_64-openssl mingw-w64-x86_64-libssh2', name: 'default XP' } - - { build: 'autotools', sys: 'mingw64' , env: 'x86_64' , tflags: '' , config: '--enable-debug --with-openssl --enable-windows-unicode --enable-ares --with-openssl-quic --enable-shared=no', install: 'mingw-w64-x86_64-openssl mingw-w64-x86_64-nghttp3 mingw-w64-x86_64-libssh2', name: 'c-ares U' } - - { build: 'cmake' , sys: 'mingw64' , env: 'x86_64' , tflags: '' , config: '-DENABLE_DEBUG=ON -DBUILD_SHARED_LIBS=OFF -DCURL_USE_SCHANNEL=ON -DENABLE_UNICODE=ON -DENABLE_ARES=ON', install: 'mingw-w64-x86_64-libssh2', type: 'Debug', name: 'schannel c-ares U' } + - { build: 'autotools', sys: 'mingw64' , env: 'x86_64' , tflags: '' , config: '--enable-debug --with-openssl --enable-windows-unicode --enable-ares --with-openssl-quic --enable-shared=no', install: 'mingw-w64-x86_64-c-ares mingw-w64-x86_64-openssl mingw-w64-x86_64-nghttp3 mingw-w64-x86_64-libssh2', name: 'c-ares U' } + - { build: 'cmake' , sys: 'mingw64' , env: 'x86_64' , tflags: '' , config: '-DENABLE_DEBUG=ON -DBUILD_SHARED_LIBS=OFF -DCURL_USE_SCHANNEL=ON -DENABLE_UNICODE=ON -DENABLE_ARES=ON', install: 'mingw-w64-x86_64-c-ares mingw-w64-x86_64-libssh2', type: 'Debug', name: 'schannel c-ares U' } # WARNING: libssh uses hard-coded world-writable paths (/etc/..., ~/.ssh/) to # read its configuration from, making it vulnerable to attacks on # Windows. Do not use this component till there is a fix for these. @@ -244,7 +244,6 @@ jobs: mingw-w64-${{ matrix.env }}-${{ matrix.build }} ${{ matrix.build == 'autotools' && 'make' || '' }} mingw-w64-${{ matrix.env }}-diffutils mingw-w64-${{ matrix.env }}-libpsl - mingw-w64-${{ matrix.env }}-c-ares ${{ matrix.install }} - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 From dc8c0d54a51961bbdea25fafa4c381d10f27cf9c Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 2 Dec 2025 17:46:52 +0100 Subject: [PATCH 168/415] test3207: enable memdebug for this test again Closes #19813 --- tests/data/test3207 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/data/test3207 b/tests/data/test3207 index 9aa3ee5a365f..4806ef5474d6 100644 --- a/tests/data/test3207 +++ b/tests/data/test3207 @@ -37,7 +37,7 @@ concurrent HTTPS GET using shared ssl session cache lib%TESTNUMBER # provide URL and ca-cert - + https://localhost:%HTTPSPORT/%TESTNUMBER %CERTDIR/certs/test-ca.crt From c3b030b860a2c1b2a74e032bb82b981d2f806249 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Tue, 2 Dec 2025 07:25:18 +0100 Subject: [PATCH 169/415] lib: fix formatting nits (part 3) From `lib/h` to `lib/w`. part 1: 47a1ab2ebecb21485c0e955316d90511e80a3c43 #19764 part 2: 86b346443b68cde7ef33e1ab770e6c8ab641d2b1 #19800 Closes #19811 --- lib/hash.c | 41 ++--- lib/hash.h | 23 ++- lib/headers.c | 3 +- lib/headers.h | 6 +- lib/hmac.c | 16 +- lib/hostip.c | 61 +++---- lib/hostip.h | 9 +- lib/hostip4.c | 10 +- lib/hsts.c | 16 +- lib/hsts.h | 4 +- lib/http.c | 148 +++++++--------- lib/http.h | 18 +- lib/http1.c | 6 +- lib/http2.c | 174 +++++++++---------- lib/http2.h | 8 +- lib/http_aws_sigv4.c | 59 +++---- lib/http_aws_sigv4.h | 3 +- lib/http_chunks.c | 4 +- lib/http_digest.c | 2 +- lib/http_negotiate.c | 5 +- lib/http_ntlm.c | 12 +- lib/http_proxy.c | 27 +-- lib/http_proxy.h | 2 +- lib/httpsrr.c | 1 - lib/httpsrr.h | 2 +- lib/idn.c | 20 +-- lib/if2ip.c | 25 ++- lib/if2ip.h | 16 +- lib/imap.c | 145 +++++++++------- lib/imap.h | 3 +- lib/ldap.c | 22 ++- lib/llist.c | 25 ++- lib/llist.h | 4 +- lib/md4.c | 71 ++++---- lib/md5.c | 62 ++++--- lib/memdebug.c | 14 +- lib/mime.c | 138 +++++++-------- lib/mime.h | 11 +- lib/mprintf.c | 62 ++++--- lib/mqtt.c | 22 +-- lib/multi.c | 178 ++++++++----------- lib/multi_ev.c | 40 ++--- lib/multi_ntfy.c | 4 +- lib/multi_ntfy.h | 9 +- lib/multiif.h | 1 - lib/netrc.c | 10 +- lib/netrc.h | 12 +- lib/noproxy.c | 10 +- lib/openldap.c | 39 ++--- lib/parsedate.c | 182 +++++++++---------- lib/pingpong.c | 1 - lib/pingpong.h | 10 +- lib/pop3.c | 20 +-- lib/progress.c | 25 ++- lib/psl.c | 2 +- lib/rand.c | 9 +- lib/rand.h | 7 +- lib/ratelimit.c | 2 +- lib/request.c | 4 +- lib/request.h | 1 - lib/rtsp.c | 33 ++-- lib/rtsp.h | 2 +- lib/select.c | 36 ++-- lib/select.h | 61 ++++--- lib/sendf.c | 15 +- lib/sendf.h | 20 +-- lib/setopt.c | 76 ++++---- lib/setopt.h | 2 +- lib/setup-os400.h | 9 +- lib/setup-vms.h | 385 +++++++++++++++++++++-------------------- lib/sha256.c | 103 +++++------ lib/sigpipe.h | 12 +- lib/slist.c | 13 +- lib/smb.c | 42 ++--- lib/smtp.c | 61 ++++--- lib/socketpair.h | 18 +- lib/socks.c | 51 +++--- lib/socks.h | 6 +- lib/socks_gssapi.c | 12 +- lib/socks_sspi.c | 12 +- lib/splay.c | 6 +- lib/strcase.c | 76 ++++---- lib/strcase.h | 2 +- lib/strdup.h | 2 +- lib/strerror.c | 192 ++++++++++----------- lib/system_win32.c | 2 +- lib/telnet.c | 403 +++++++++++++++++++++---------------------- lib/tftp.c | 22 +-- lib/transfer.c | 18 +- lib/transfer.h | 3 +- lib/uint-bset.c | 10 +- lib/uint-bset.h | 3 +- lib/uint-hash.c | 7 +- lib/uint-hash.h | 2 - lib/uint-spbset.c | 6 - lib/uint-table.c | 11 -- lib/url.c | 112 ++++++------ lib/urlapi.c | 68 +++++--- lib/urldata.h | 130 +++++++------- lib/version.c | 6 +- lib/ws.c | 300 ++++++++++++++++---------------- lib/ws.h | 5 +- 102 files changed, 1998 insertions(+), 2223 deletions(-) diff --git a/lib/hash.c b/lib/hash.c index 2d91c855e614..b9e9d702e3cc 100644 --- a/lib/hash.c +++ b/lib/hash.c @@ -37,8 +37,7 @@ #if 0 /* useful function for debugging hashes and their contents */ -void Curl_hash_print(struct Curl_hash *h, - void (*func)(void *)) +void Curl_hash_print(struct Curl_hash *h, void (*func)(void *)) { struct Curl_hash_iterator iter; struct Curl_hash_element *he; @@ -80,12 +79,11 @@ void Curl_hash_print(struct Curl_hash *h, * @unittest: 1602 * @unittest: 1603 */ -void -Curl_hash_init(struct Curl_hash *h, - size_t slots, - hash_function hfunc, - comp_function comparator, - Curl_hash_dtor dtor) +void Curl_hash_init(struct Curl_hash *h, + size_t slots, + hash_function hfunc, + comp_function comparator, + Curl_hash_dtor dtor) { DEBUGASSERT(h); DEBUGASSERT(slots); @@ -104,9 +102,10 @@ Curl_hash_init(struct Curl_hash *h, #endif } -static struct Curl_hash_element * -hash_elem_create(const void *key, size_t key_len, const void *p, - Curl_hash_elem_dtor dtor) +static struct Curl_hash_element *hash_elem_create(const void *key, + size_t key_len, + const void *p, + Curl_hash_elem_dtor dtor) { struct Curl_hash_element *he; @@ -161,8 +160,8 @@ static void hash_elem_link(struct Curl_hash *h, ++h->size; } -#define CURL_HASH_SLOT(x,y,z) x->table[x->hash_func(y, z, x->slots)] -#define CURL_HASH_SLOT_ADDR(x,y,z) &CURL_HASH_SLOT(x,y,z) +#define CURL_HASH_SLOT(x, y, z) x->table[x->hash_func(y, z, x->slots)] +#define CURL_HASH_SLOT_ADDR(x, y, z) &CURL_HASH_SLOT(x, y, z) void *Curl_hash_add2(struct Curl_hash *h, void *key, size_t key_len, void *p, Curl_hash_elem_dtor dtor) @@ -205,8 +204,7 @@ void *Curl_hash_add2(struct Curl_hash *h, void *key, size_t key_len, void *p, * @unittest: 1602 * @unittest: 1603 */ -void * -Curl_hash_add(struct Curl_hash *h, void *key, size_t key_len, void *p) +void *Curl_hash_add(struct Curl_hash *h, void *key, size_t key_len, void *p) { return Curl_hash_add2(h, key, key_len, p, NULL); } @@ -242,8 +240,7 @@ 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) +void *Curl_hash_pick(struct Curl_hash *h, void *key, size_t key_len) { DEBUGASSERT(h); DEBUGASSERT(h->init == HASHINIT); @@ -268,8 +265,7 @@ Curl_hash_pick(struct Curl_hash *h, void *key, size_t key_len) * @unittest: 1602 * @unittest: 1603 */ -void -Curl_hash_destroy(struct Curl_hash *h) +void Curl_hash_destroy(struct Curl_hash *h) { DEBUGASSERT(h->init == HASHINIT); if(h->table) { @@ -308,9 +304,8 @@ size_t Curl_hash_count(struct Curl_hash *h) } /* Cleans all entries that pass the comp function criteria. */ -void -Curl_hash_clean_with_criterium(struct Curl_hash *h, void *user, - int (*comp)(void *, void *)) +void Curl_hash_clean_with_criterium(struct Curl_hash *h, void *user, + int (*comp)(void *, void *)) { size_t i; @@ -335,7 +330,7 @@ Curl_hash_clean_with_criterium(struct Curl_hash *h, void *user, size_t Curl_hash_str(void *key, size_t key_length, size_t slots_num) { - const char *key_str = (const char *) key; + const char *key_str = (const char *)key; const char *end = key_str + key_length; size_t h = 5381; diff --git a/lib/hash.h b/lib/hash.h index fcd92db6645d..b9974826b03c 100644 --- a/lib/hash.h +++ b/lib/hash.h @@ -31,17 +31,17 @@ #include "llist.h" /* Hash function prototype */ -typedef size_t (*hash_function) (void *key, - size_t key_length, - size_t slots_num); +typedef size_t (*hash_function)(void *key, + size_t key_length, + size_t slots_num); /* Comparator function prototype. Compares two keys. */ -typedef size_t (*comp_function) (void *key1, - size_t key1_len, - void *key2, - size_t key2_len); +typedef size_t (*comp_function)(void *key1, + size_t key1_len, + void *key2, + size_t key2_len); typedef void (*Curl_hash_dtor)(void *); @@ -49,10 +49,10 @@ typedef void (*Curl_hash_elem_dtor)(void *key, size_t key_len, void *p); struct Curl_hash_element { struct Curl_hash_element *next; - void *ptr; + void *ptr; Curl_hash_elem_dtor dtor; size_t key_len; - char key[1]; /* allocated memory following the struct */ + char key[1]; /* allocated memory following the struct */ }; struct Curl_hash { @@ -63,7 +63,7 @@ struct Curl_hash { /* Comparator function to compare keys */ comp_function comp_func; /* General element construct, unless element itself carries one */ - Curl_hash_dtor dtor; + Curl_hash_dtor dtor; size_t slots; size_t size; #ifdef DEBUGBUILD @@ -105,7 +105,6 @@ void Curl_hash_start_iterate(struct Curl_hash *hash, struct Curl_hash_element * Curl_hash_next_element(struct Curl_hash_iterator *iter); -void Curl_hash_print(struct Curl_hash *h, - void (*func)(void *)); +void Curl_hash_print(struct Curl_hash *h, void (*func)(void *)); #endif /* HEADER_CURL_HASH_H */ diff --git a/lib/headers.c b/lib/headers.c index 91715fd51d3a..7cf215c0800e 100644 --- a/lib/headers.c +++ b/lib/headers.c @@ -69,7 +69,7 @@ CURLHcode curl_easy_header(CURL *easy, struct Curl_header_store *hs = NULL; struct Curl_header_store *pick = NULL; if(!name || !hout || !data || - (type > (CURLH_HEADER|CURLH_TRAILER|CURLH_CONNECT|CURLH_1XX| + (type > (CURLH_HEADER | CURLH_TRAILER | CURLH_CONNECT | CURLH_1XX | CURLH_PSEUDO)) || !type || (request < -1)) return CURLHE_BAD_ARGUMENT; if(!Curl_llist_count(&data->state.httphdrs)) @@ -264,7 +264,6 @@ static CURLcode unfold_value(struct Curl_easy *data, const char *value, return CURLE_OK; } - /* * Curl_headers_push() gets passed a full HTTP header to store. It gets called * immediately before the header callback. The header is CRLF terminated. diff --git a/lib/headers.h b/lib/headers.h index e11fe9804e51..7249355f0ccd 100644 --- a/lib/headers.h +++ b/lib/headers.h @@ -54,9 +54,9 @@ CURLcode Curl_headers_push(struct Curl_easy *data, const char *header, CURLcode Curl_headers_cleanup(struct Curl_easy *data); #else -#define Curl_headers_init(x) CURLE_OK -#define Curl_headers_push(x,y,z) CURLE_OK -#define Curl_headers_cleanup(x) Curl_nop_stmt +#define Curl_headers_init(x) CURLE_OK +#define Curl_headers_push(x, y, z) CURLE_OK +#define Curl_headers_cleanup(x) Curl_nop_stmt #endif #endif /* HEADER_CURL_HEADER_H */ diff --git a/lib/hmac.c b/lib/hmac.c index 4f226e6434f8..fdde19717539 100644 --- a/lib/hmac.c +++ b/lib/hmac.c @@ -46,10 +46,9 @@ static const unsigned char hmac_ipad = 0x36; static const unsigned char hmac_opad = 0x5C; -struct HMAC_context * -Curl_HMAC_init(const struct HMAC_params *hashparams, - const unsigned char *key, - unsigned int keylen) +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; @@ -64,15 +63,15 @@ Curl_HMAC_init(const struct HMAC_params *hashparams, return ctxt; ctxt->hash = hashparams; - ctxt->hashctxt1 = (void *) (ctxt + 1); - ctxt->hashctxt2 = (void *) ((char *) ctxt->hashctxt1 + hashparams->ctxtsize); + ctxt->hashctxt1 = (void *)(ctxt + 1); + ctxt->hashctxt2 = (void *)((char *)ctxt->hashctxt1 + hashparams->ctxtsize); /* If the key is too long, replace it by its hash digest. */ if(keylen > hashparams->maxkeylen) { if(hashparams->hinit(ctxt->hashctxt1)) goto fail; hashparams->hupdate(ctxt->hashctxt1, key, keylen); - hkey = (unsigned char *) ctxt->hashctxt2 + hashparams->ctxtsize; + hkey = (unsigned char *)ctxt->hashctxt2 + hashparams->ctxtsize; hashparams->hfinal(hkey, ctxt->hashctxt1); key = hkey; keylen = hashparams->resultlen; @@ -112,7 +111,6 @@ int Curl_HMAC_update(struct HMAC_context *ctxt, return 0; } - int Curl_HMAC_final(struct HMAC_context *ctxt, unsigned char *output) { const struct HMAC_params *hashparams = ctxt->hash; @@ -121,7 +119,7 @@ int Curl_HMAC_final(struct HMAC_context *ctxt, unsigned char *output) storage. */ if(!output) - output = (unsigned char *) ctxt->hashctxt2 + ctxt->hash->ctxtsize; + output = (unsigned char *)ctxt->hashctxt2 + ctxt->hash->ctxtsize; hashparams->hfinal(output, ctxt->hashctxt1); hashparams->hupdate(ctxt->hashctxt2, output, hashparams->resultlen); diff --git a/lib/hostip.c b/lib/hostip.c index e81886995eda..ba9e3ddd7ac9 100644 --- a/lib/hostip.c +++ b/lib/hostip.c @@ -118,7 +118,7 @@ static void dnscache_entry_free(struct Curl_dns_entry *dns); static void show_resolve_info(struct Curl_easy *data, struct Curl_dns_entry *dns); #else -#define show_resolve_info(x,y) Curl_nop_stmt +#define show_resolve_info(x, y) Curl_nop_stmt #endif /* @@ -158,10 +158,9 @@ void Curl_printable_address(const struct Curl_addrinfo *ai, char *buf, * Create a hostcache id string for the provided host + port, to be used by * the DNS caching. Without alloc. Return length of the id string. */ -static size_t -create_dnscache_id(const char *name, - size_t nlen, /* 0 or actual name length */ - int port, char *ptr, size_t buflen) +static size_t create_dnscache_id(const char *name, + size_t nlen, /* 0 or actual name length */ + int port, char *ptr, size_t buflen) { size_t len = nlen ? nlen : strlen(name); DEBUGASSERT(buflen >= MAX_HOSTCACHE_LEN); @@ -185,12 +184,10 @@ struct dnscache_prune_data { * Returning non-zero means remove the entry, return 0 to keep it in the * cache. */ -static int -dnscache_entry_is_stale(void *datap, void *hc) +static int dnscache_entry_is_stale(void *datap, void *hc) { - struct dnscache_prune_data *prune = - (struct dnscache_prune_data *) datap; - struct Curl_dns_entry *dns = (struct Curl_dns_entry *) hc; + struct dnscache_prune_data *prune = (struct dnscache_prune_data *)datap; + struct Curl_dns_entry *dns = (struct Curl_dns_entry *)hc; if(dns->timestamp.tv_sec || dns->timestamp.tv_usec) { /* get age in milliseconds */ @@ -209,9 +206,9 @@ dnscache_entry_is_stale(void *datap, void *hc) * Prune the DNS cache. This assumes that a lock has already been taken. * Returns the 'age' of the oldest still kept entry - in milliseconds. */ -static timediff_t -dnscache_prune(struct Curl_hash *hostcache, timediff_t cache_timeout_ms, - struct curltime now) +static timediff_t dnscache_prune(struct Curl_hash *hostcache, + timediff_t cache_timeout_ms, + struct curltime now) { struct dnscache_prune_data user; @@ -389,11 +386,10 @@ static struct Curl_dns_entry *fetch_addr(struct Curl_easy *data, * The returned data *MUST* be "released" with Curl_resolv_unlink() after * use, or we will leak memory! */ -struct Curl_dns_entry * -Curl_dnscache_get(struct Curl_easy *data, - const char *hostname, - int port, - int ip_version) +struct Curl_dns_entry *Curl_dnscache_get(struct Curl_easy *data, + const char *hostname, + int port, + int ip_version) { struct Curl_dnscache *dnscache = dnscache_get(data); struct Curl_dns_entry *dns = NULL; @@ -447,7 +443,7 @@ UNITTEST CURLcode Curl_shuffle_addr(struct Curl_easy *data, struct Curl_addrinfo **nodes; infof(data, "Shuffling %i addresses", num_addrs); - nodes = curlx_malloc(num_addrs*sizeof(*nodes)); + nodes = curlx_malloc(num_addrs * sizeof(*nodes)); if(nodes) { int i; unsigned int *rnd; @@ -456,7 +452,7 @@ UNITTEST CURLcode Curl_shuffle_addr(struct Curl_easy *data, /* build a plain array of Curl_addrinfo pointers */ nodes[0] = *addr; for(i = 1; i < num_addrs; i++) { - nodes[i] = nodes[i-1]->ai_next; + nodes[i] = nodes[i - 1]->ai_next; } rnd = curlx_malloc(rnd_size); @@ -472,10 +468,10 @@ UNITTEST CURLcode Curl_shuffle_addr(struct Curl_easy *data, /* relink list in the new order */ for(i = 1; i < num_addrs; i++) { - nodes[i-1]->ai_next = nodes[i]; + nodes[i - 1]->ai_next = nodes[i]; } - nodes[num_addrs-1]->ai_next = NULL; + nodes[num_addrs - 1]->ai_next = NULL; *addr = nodes[0]; } curlx_free(rnd); @@ -632,7 +628,7 @@ static struct Curl_addrinfo *get_localhost6(int port, const char *name) return ca; } #else -#define get_localhost6(x,y) NULL +#define get_localhost6(x, y) NULL #endif /* return a static IPv4 127.0.0.1 for the given name */ @@ -727,7 +723,6 @@ bool Curl_host_is_ipnum(const char *hostname) return FALSE; } - /* return TRUE if 'part' is a case insensitive tail of 'full' */ static bool tailmatch(const char *full, size_t flen, const char *part, size_t plen) @@ -980,8 +975,7 @@ CURLcode Curl_resolv_blocking(struct Curl_easy *data, * execution. This effectively causes the remainder of the application to run * within a signal handler which is nonportable and could lead to problems. */ -CURL_NORETURN static -void alarmfunc(int sig) +CURL_NORETURN static void alarmfunc(int sig) { (void)sig; siglongjmp(curl_jmpenv, 1); @@ -1018,7 +1012,7 @@ CURLcode Curl_resolv_timeout(struct Curl_easy *data, { #ifdef USE_ALARM_TIMEOUT #ifdef HAVE_SIGACTION - struct sigaction keep_sigact; /* store the old struct here */ + struct sigaction keep_sigact; /* store the old struct here */ volatile bool keep_copysig = FALSE; /* whether old sigact has been saved */ struct sigaction sigact; #else @@ -1058,8 +1052,8 @@ CURLcode Curl_resolv_timeout(struct Curl_easy *data, /* The alarm() function only provides integer second resolution, so if we want to wait less than one second we must bail out already now. */ failf(data, - "remaining timeout of %ld too small to resolve via SIGALRM method", - timeout); + "remaining timeout of %ld too small to resolve via SIGALRM method", + timeout); return CURLE_OPERATION_TIMEDOUT; } /* This allows us to time-out from the name resolver, as the timeout @@ -1101,7 +1095,7 @@ CURLcode Curl_resolv_timeout(struct Curl_easy *data, /* alarm() makes a signal get sent when the timeout fires off, and that will abort system calls */ - prev_alarm = alarm(curlx_sltoui(timeout/1000L)); + prev_alarm = alarm(curlx_sltoui(timeout / 1000L)); } #else /* !USE_ALARM_TIMEOUT */ @@ -1151,7 +1145,7 @@ CURLcode Curl_resolv_timeout(struct Curl_easy *data, unsigned long alarm_set = (unsigned long)(prev_alarm - elapsed_secs); if(!alarm_set || - ((alarm_set >= 0x80000000) && (prev_alarm < 0x80000000)) ) { + ((alarm_set >= 0x80000000) && (prev_alarm < 0x80000000))) { /* if the alarm time-left reached zero or turned "negative" (counted with unsigned values), we should fire off a SIGALRM here, but we will not, and zero would be to switch it off so we never set it to @@ -1203,7 +1197,7 @@ void Curl_resolv_unlink(struct Curl_easy *data, struct Curl_dns_entry **pdns) static void dnscache_entry_dtor(void *entry) { - struct Curl_dns_entry *dns = (struct Curl_dns_entry *) entry; + struct Curl_dns_entry *dns = (struct Curl_dns_entry *)entry; DEBUGASSERT(dns && (dns->refcount > 0)); dns->refcount--; if(dns->refcount == 0) @@ -1361,8 +1355,7 @@ CURLcode Curl_loadhostpairs(struct Curl_easy *data) error = FALSE; err: if(error) { - failf(data, "Could not parse CURLOPT_RESOLVE entry '%s'", - hostp->data); + failf(data, "Could not parse CURLOPT_RESOLVE entry '%s'", hostp->data); Curl_freeaddrinfo(head); return CURLE_SETOPT_OPTION_SYNTAX; } diff --git a/lib/hostip.h b/lib/hostip.h index 3eb82cd1498a..780d93038f93 100644 --- a/lib/hostip.h +++ b/lib/hostip.h @@ -175,10 +175,9 @@ Curl_dnscache_mk_entry(struct Curl_easy *data, * The returned data *MUST* be "released" with Curl_resolv_unlink() after * use, or we will leak memory! */ -struct Curl_dns_entry * -Curl_dnscache_get(struct Curl_easy *data, - const char *hostname, - int port, int ip_version); +struct Curl_dns_entry *Curl_dnscache_get(struct Curl_easy *data, + const char *hostname, int port, + int ip_version); /* * Curl_dnscache_addr() adds `entry` to the cache, increasing its @@ -196,7 +195,7 @@ CURLcode Curl_loadhostpairs(struct Curl_easy *data); CURLcode Curl_resolv_check(struct Curl_easy *data, struct Curl_dns_entry **dns); #else -#define Curl_resolv_check(x,y) CURLE_NOT_BUILT_IN +#define Curl_resolv_check(x, y) CURLE_NOT_BUILT_IN #endif CURLcode Curl_resolv_pollset(struct Curl_easy *data, struct easy_pollset *ps); diff --git a/lib/hostip4.c b/lib/hostip4.c index f01e902fd684..ada021176983 100644 --- a/lib/hostip4.c +++ b/lib/hostip4.c @@ -166,11 +166,11 @@ struct Curl_addrinfo *Curl_ipv4_resolve_r(const char *hostname, /* Linux */ (void)gethostbyname_r(hostname, - (struct hostent *)buf, - (char *)buf + sizeof(struct hostent), - CURL_HOSTENT_SIZE - sizeof(struct hostent), - &h, /* DIFFERENCE */ - &h_errnop); + (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 diff --git a/lib/hsts.c b/lib/hsts.c index 22add0395732..66f983e493fb 100644 --- a/lib/hsts.c +++ b/lib/hsts.c @@ -41,10 +41,10 @@ #include "strdup.h" #include "curlx/strparse.h" -#define MAX_HSTS_LINE 4095 +#define MAX_HSTS_LINE 4095 #define MAX_HSTS_HOSTLEN 2048 #define MAX_HSTS_DATELEN 256 -#define UNLIMITED "unlimited" +#define UNLIMITED "unlimited" #if defined(DEBUGBUILD) || defined(UNITTESTS) /* to play well with debug builds, we can *set* a fixed time this will @@ -248,7 +248,7 @@ struct stsentry *Curl_hsts(struct hsts *h, const char *hostname, if((hlen > MAX_HSTS_HOSTLEN) || !hlen) return NULL; - if(hostname[hlen-1] == '.') + if(hostname[hlen - 1] == '.') /* remove the trailing dot */ --hlen; @@ -265,7 +265,7 @@ struct stsentry *Curl_hsts(struct hsts *h, const char *hostname, ntail = strlen(sts->host); if((subdomain && sts->includeSubDomains) && (ntail < hlen)) { size_t offs = hlen - ntail; - if((hostname[offs-1] == '.') && + if((hostname[offs - 1] == '.') && curl_strnequal(&hostname[offs], sts->host, ntail) && (ntail > blen)) { /* save the tail match with the longest tail */ @@ -310,8 +310,7 @@ static CURLcode hsts_push(struct Curl_easy *data, else strcpy(e.expire, UNLIMITED); - sc = data->set.hsts_write(data, &e, i, - data->set.hsts_write_userp); + 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; } @@ -327,7 +326,7 @@ static CURLcode hsts_out(struct stsentry *sts, FILE *fp) if(result) return result; curl_mfprintf(fp, "%s%s \"%d%02d%02d %02d:%02d:%02d\"\n", - sts->includeSubDomains ? ".": "", sts->host, + sts->includeSubDomains ? "." : "", sts->host, stamp.tm_year + 1900, stamp.tm_mon + 1, stamp.tm_mday, stamp.tm_hour, stamp.tm_min, stamp.tm_sec); } @@ -337,7 +336,6 @@ static CURLcode hsts_out(struct stsentry *sts, FILE *fp) return CURLE_OK; } - /* * Curl_https_save() writes the HSTS cache to file and callback. */ @@ -469,7 +467,7 @@ static CURLcode hsts_pull(struct Curl_easy *data, struct hsts *h) char buffer[MAX_HSTS_HOSTLEN + 1]; struct curl_hstsentry e; e.name = buffer; - e.namelen = sizeof(buffer)-1; + e.namelen = sizeof(buffer) - 1; e.includeSubDomains = FALSE; /* default */ e.expire[0] = 0; e.name[0] = 0; /* just to make it clean */ diff --git a/lib/hsts.h b/lib/hsts.h index cb83ada79043..91fe778788c7 100644 --- a/lib/hsts.h +++ b/lib/hsts.h @@ -62,8 +62,8 @@ CURLcode Curl_hsts_loadcb(struct Curl_easy *data, CURLcode Curl_hsts_loadfiles(struct Curl_easy *data); #else #define Curl_hsts_cleanup(x) -#define Curl_hsts_loadcb(x,y) CURLE_OK -#define Curl_hsts_save(x,y,z) +#define Curl_hsts_loadcb(x, y) CURLE_OK +#define Curl_hsts_save(x, y, z) #define Curl_hsts_loadfiles(x) CURLE_OK #endif /* CURL_DISABLE_HTTP || CURL_DISABLE_HSTS */ #endif /* HEADER_CURL_HSTS_H */ diff --git a/lib/http.c b/lib/http.c index fcae0a57c25c..3178ca59e993 100644 --- a/lib/http.c +++ b/lib/http.c @@ -111,7 +111,6 @@ static CURLcode http_statusline(struct Curl_easy *data, static CURLcode http_target(struct Curl_easy *data, struct dynbuf *req); static CURLcode http_useragent(struct Curl_easy *data); - /* * HTTP handler interface. */ @@ -138,7 +137,7 @@ const struct Curl_handler Curl_handler_http = { CURLPROTO_HTTP, /* protocol */ CURLPROTO_HTTP, /* family */ PROTOPT_CREDSPERREQUEST | /* flags */ - PROTOPT_USERPWDCTRL | PROTOPT_CONN_REUSE + PROTOPT_USERPWDCTRL | PROTOPT_CONN_REUSE }; @@ -169,7 +168,7 @@ const struct Curl_handler Curl_handler_https = { CURLPROTO_HTTPS, /* protocol */ CURLPROTO_HTTP, /* family */ PROTOPT_SSL | PROTOPT_CREDSPERREQUEST | PROTOPT_ALPN | /* flags */ - PROTOPT_USERPWDCTRL | PROTOPT_CONN_REUSE + PROTOPT_USERPWDCTRL | PROTOPT_CONN_REUSE }; #endif @@ -255,7 +254,7 @@ char *Curl_checkProxyheaders(struct Curl_easy *data, } #else /* disabled */ -#define Curl_checkProxyheaders(x,y,z,a) NULL +#define Curl_checkProxyheaders(x, y, z, a) NULL #endif static bool http_header_is_empty(const char *header) @@ -599,7 +598,6 @@ CURLcode Curl_http_auth_act(struct Curl_easy *data) data->state.authproblem = TRUE; else data->info.proxyauthpicked = data->state.authproxy.picked; - } #endif @@ -617,7 +615,7 @@ CURLcode Curl_http_auth_act(struct Curl_easy *data) return CURLE_OUT_OF_MEMORY; } else if((data->req.httpcode < 300) && - (!data->state.authhost.done) && + !data->state.authhost.done && data->req.authneg) { /* no (known) authentication available, authentication is not "done" yet and @@ -645,13 +643,12 @@ CURLcode Curl_http_auth_act(struct Curl_easy *data) * Output the correct authentication header depending on the auth type * and whether or not it is to a proxy. */ -static CURLcode -output_auth_headers(struct Curl_easy *data, - struct connectdata *conn, - struct auth *authstatus, - const char *request, - const char *path, - bool proxy) +static CURLcode output_auth_headers(struct Curl_easy *data, + struct connectdata *conn, + struct auth *authstatus, + const char *request, + const char *path, + bool proxy) { const char *auth = NULL; CURLcode result = CURLE_OK; @@ -865,13 +862,12 @@ Curl_http_output_auth(struct Curl_easy *data, #else /* when disabled */ -CURLcode -Curl_http_output_auth(struct Curl_easy *data, - struct connectdata *conn, - const char *request, - Curl_HttpReq httpreq, - const char *path, - bool proxytunnel) +CURLcode Curl_http_output_auth(struct Curl_easy *data, + struct connectdata *conn, + const char *request, + Curl_HttpReq httpreq, + const char *path, + bool proxytunnel) { (void)data; (void)conn; @@ -1398,7 +1394,7 @@ CURLcode Curl_http_follow(struct Curl_easy *data, const char *newurl, /* 300 - Multiple Choices */ /* 306 - Not used */ /* 307 - Temporary Redirect */ - default: /* for all above (and the unknown ones) */ + default: /* for all above (and the unknown ones) */ /* Some codes are explicitly mentioned since I have checked RFC2616 and * they seem to be OK to POST to. */ @@ -1420,10 +1416,10 @@ CURLcode Curl_http_follow(struct Curl_easy *data, const char *newurl, * This behavior 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) - && !(data->set.keep_post & CURL_REDIR_POST_301)) { + 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)) { http_switch_to_get(data, 301); switch_to_get = TRUE; } @@ -1445,10 +1441,10 @@ CURLcode Curl_http_follow(struct Curl_easy *data, const char *newurl, * This behavior 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) - && !(data->set.keep_post & CURL_REDIR_POST_302)) { + 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)) { http_switch_to_get(data, 302); switch_to_get = TRUE; } @@ -1502,12 +1498,11 @@ CURLcode Curl_http_follow(struct Curl_easy *data, const char *newurl, * Returns TRUE if 'headerline' contains the 'header' with given 'content'. * Pass headers WITH the colon. */ -bool -Curl_compareheader(const char *headerline, /* line to check */ - const char *header, /* header keyword _with_ colon */ - const size_t hlen, /* len of the keyword in bytes */ - const char *content, /* content string to find */ - const size_t clen) /* len of the content in bytes */ +bool Curl_compareheader(const char *headerline, /* line to check */ + const char *header, /* header keyword _with_ colon */ + const size_t hlen, /* len of the keyword in bytes */ + const char *content, /* content string to find */ + const size_t clen) /* len of the content in bytes */ { /* RFC2616, section 4.2 says: "Each header field consists of a name followed * by a colon (":") and the field value. Field names are case-insensitive. @@ -1651,14 +1646,14 @@ static unsigned char http_request_version(struct Curl_easy *data) static const char *get_http_string(int httpversion) { switch(httpversion) { - case 30: - return "3"; - case 20: - return "2"; - case 11: - return "1.1"; - default: - return "1.0"; + case 30: + return "3"; + case 20: + return "2"; + case 11: + return "1.1"; + default: + return "1.0"; } } @@ -1841,7 +1836,7 @@ CURLcode Curl_add_timecondition(struct Curl_easy *data, curl_msnprintf(datestr, sizeof(datestr), "%s: %s, %02d %s %4d %02d:%02d:%02d GMT\r\n", condp, - Curl_wkday[tm->tm_wday ? tm->tm_wday-1 : 6], + Curl_wkday[tm->tm_wday ? tm->tm_wday - 1 : 6], tm->tm_mday, Curl_month[tm->tm_mon], tm->tm_year + 1900, @@ -1869,11 +1864,11 @@ void Curl_http_method(struct Curl_easy *data, Curl_HttpReq httpreq = (Curl_HttpReq)data->state.httpreq; const char *request; #ifndef CURL_DISABLE_WEBSOCKETS - if(data->conn->handler->protocol&(CURLPROTO_WS|CURLPROTO_WSS)) + if(data->conn->handler->protocol & (CURLPROTO_WS | CURLPROTO_WSS)) httpreq = HTTPREQ_GET; else #endif - if((data->conn->handler->protocol&(PROTO_FAMILY_HTTP|CURLPROTO_FTP)) && + if((data->conn->handler->protocol & (PROTO_FAMILY_HTTP | CURLPROTO_FTP)) && data->state.upload) httpreq = HTTPREQ_PUT; @@ -1923,7 +1918,6 @@ static CURLcode http_useragent(struct Curl_easy *data) return CURLE_OK; } - static CURLcode http_set_aptr_host(struct Curl_easy *data) { struct connectdata *conn = data->conn; @@ -1993,10 +1987,10 @@ static CURLcode http_set_aptr_host(struct Curl_easy *data) [brackets] if the hostname is a plain IPv6-address. RFC2732-style. */ const char *host = conn->host.name; - if(((conn->given->protocol&(CURLPROTO_HTTPS|CURLPROTO_WSS)) && + if(((conn->given->protocol & (CURLPROTO_HTTPS | CURLPROTO_WSS)) && (conn->remote_port == PORT_HTTPS)) || - ((conn->given->protocol&(CURLPROTO_HTTP|CURLPROTO_WS)) && - (conn->remote_port == PORT_HTTP)) ) + ((conn->given->protocol & (CURLPROTO_HTTP | CURLPROTO_WS)) && + (conn->remote_port == PORT_HTTP))) /* if(HTTPS on port 443) OR (HTTP on port 80) then do not include the port number in the host string */ aptr->host = curl_maprintf("Host: %s%s%s\r\n", @@ -2532,7 +2526,7 @@ static CURLcode http_cookies(struct Curl_easy *data, return result; } #else -#define http_cookies(a,b) CURLE_OK +#define http_cookies(a, b) CURLE_OK #endif static CURLcode http_range(struct Curl_easy *data, @@ -2579,7 +2573,7 @@ static CURLcode http_range(struct Curl_easy *data, data->state.aptr.rangeline = curl_maprintf("Content-Range: bytes %s%" FMT_OFF_T "/" "%" FMT_OFF_T "\r\n", - data->state.range, total_len-1, total_len); + data->state.range, total_len - 1, total_len); } else { /* Range was selected and then we just pass the incoming range and @@ -2909,7 +2903,7 @@ static CURLcode http_add_hd(struct Curl_easy *data, result = Curl_http2_request_upgrade(req, data); } #ifndef CURL_DISABLE_WEBSOCKETS - if(!result && conn->handler->protocol&(CURLPROTO_WS|CURLPROTO_WSS)) + if(!result && conn->handler->protocol & (CURLPROTO_WS | CURLPROTO_WSS)) result = Curl_ws_request(data, req); #endif break; @@ -3057,7 +3051,6 @@ typedef enum { STATUS_BAD /* not a status line */ } statusline; - /* Check a string for a prefix. Check no more than 'len' bytes */ static bool checkprefixmax(const char *prefix, const char *buffer, size_t len) { @@ -3070,9 +3063,8 @@ static bool checkprefixmax(const char *prefix, const char *buffer, size_t len) * * Returns TRUE if member of the list matches prefix of string */ -static statusline -checkhttpprefix(struct Curl_easy *data, - const char *s, size_t len) +static statusline checkhttpprefix(struct Curl_easy *data, + const char *s, size_t len) { struct curl_slist *head = data->set.http200aliases; statusline rc = STATUS_BAD; @@ -3093,9 +3085,8 @@ checkhttpprefix(struct Curl_easy *data, } #ifndef CURL_DISABLE_RTSP -static statusline -checkrtspprefix(struct Curl_easy *data, - const char *s, size_t len) +static statusline checkrtspprefix(struct Curl_easy *data, + const char *s, size_t len) { statusline result = STATUS_BAD; statusline onmatch = len >= 5 ? STATUS_DONE : STATUS_UNKNOWN; @@ -3107,9 +3098,9 @@ checkrtspprefix(struct Curl_easy *data, } #endif /* CURL_DISABLE_RTSP */ -static statusline -checkprotoprefix(struct Curl_easy *data, struct connectdata *conn, - const char *s, size_t len) +static statusline checkprotoprefix(struct Curl_easy *data, + struct connectdata *conn, + const char *s, size_t len) { #ifndef CURL_DISABLE_RTSP if(conn->handler->protocol & CURLPROTO_RTSP) @@ -3123,17 +3114,17 @@ checkprotoprefix(struct Curl_easy *data, struct connectdata *conn, /* HTTP header has field name `n` (a string constant) */ #define HD_IS(hd, hdlen, n) \ - (((hdlen) >= (sizeof(n)-1)) && curl_strnequal((n), (hd), (sizeof(n)-1))) + (((hdlen) >= (sizeof(n) - 1)) && curl_strnequal((n), (hd), (sizeof(n) - 1))) #define HD_VAL(hd, hdlen, n) \ - ((((hdlen) >= (sizeof(n)-1)) && \ - curl_strnequal((n), (hd), (sizeof(n)-1)))? (hd + (sizeof(n)-1)) : NULL) + ((((hdlen) >= (sizeof(n) - 1)) && \ + curl_strnequal((n), (hd), (sizeof(n) - 1)))? (hd + (sizeof(n) - 1)) : NULL) /* HTTP header has field name `n` (a string constant) and contains `v` * (a string constant) in its value(s) */ #define HD_IS_AND_SAYS(hd, hdlen, n, v) \ (HD_IS(hd, hdlen, n) && \ - ((hdlen) > ((sizeof(n)-1) + (sizeof(v)-1))) && \ + ((hdlen) > ((sizeof(n) - 1) + (sizeof(v) - 1))) && \ Curl_compareheader(hd, STRCONST(n), STRCONST(v))) /* @@ -3664,15 +3655,15 @@ static CURLcode http_statusline(struct Curl_easy *data, #endif /* no major version switch mid-connection */ if(k->httpversion_sent && - (k->httpversion/10 != k->httpversion_sent/10)) { + (k->httpversion / 10 != k->httpversion_sent / 10)) { failf(data, "Version mismatch (from HTTP/%u to HTTP/%u)", - k->httpversion_sent/10, k->httpversion/10); + k->httpversion_sent / 10, k->httpversion / 10); return CURLE_WEIRD_SERVER_REPLY; } break; default: failf(data, "Unsupported HTTP version (%u.%d) in response", - k->httpversion/10, k->httpversion%10); + k->httpversion / 10, k->httpversion % 10); return CURLE_UNSUPPORTED_PROTOCOL; } @@ -3825,7 +3816,7 @@ static CURLcode http_write_header(struct Curl_easy *data, Curl_debug(data, CURLINFO_HEADER_IN, hd, hdlen); writetype = CLIENTWRITE_HEADER | - ((data->req.httpcode/100 == 1) ? CLIENTWRITE_1XX : 0); + ((data->req.httpcode / 100 == 1) ? CLIENTWRITE_1XX : 0); result = Curl_client_write(data, writetype, hd, hdlen); if(result) @@ -4011,8 +4002,7 @@ static CURLcode http_on_response(struct Curl_easy *data, /* Check if this response means the transfer errored. */ if(http_should_fail(data, data->req.httpcode)) { - failf(data, "The requested URL returned error: %d", - k->httpcode); + failf(data, "The requested URL returned error: %d", k->httpcode); result = CURLE_HTTP_RETURNED_ERROR; goto out; } @@ -4056,8 +4046,7 @@ static CURLcode http_on_response(struct Curl_easy *data, } else { infof(data, "Got HTTP failure 417 while sending data"); - streamclose(conn, - "Stop sending data before everything sent"); + streamclose(conn, "Stop sending data before everything sent"); result = http_perhapsrewind(data, conn); if(result) goto out; @@ -4095,7 +4084,6 @@ static CURLcode http_on_response(struct Curl_easy *data, infof(data, "Keep sending data to get tossed away"); k->keepon |= KEEP_SEND; } - } /* If we requested a "no body", this is a good time to get @@ -4291,7 +4279,7 @@ static CURLcode http_rw_hd(struct Curl_easy *data, */ Curl_debug(data, CURLINFO_HEADER_IN, hd, hdlen); - if(k->httpcode/100 == 1) + if(k->httpcode / 100 == 1) writetype |= CLIENTWRITE_1XX; result = Curl_client_write(data, writetype, hd, hdlen); if(result) @@ -4785,8 +4773,7 @@ CURLcode Curl_http_req_to_h2(struct dynhds *h2_headers, infof(data, "set pseudo header %s to %s", HTTP_PSEUDO_SCHEME, scheme); } else { - scheme = Curl_conn_is_ssl(data->conn, FIRSTSOCKET) ? - "https" : "http"; + scheme = Curl_conn_is_ssl(data->conn, FIRSTSOCKET) ? "https" : "http"; } } @@ -4969,8 +4956,7 @@ static CURLcode http_exp100_add_reader(struct Curl_easy *data) struct Curl_creader *reader = NULL; CURLcode result; - result = Curl_creader_create(&reader, data, &cr_exp100, - CURL_CR_PROTOCOL); + result = Curl_creader_create(&reader, data, &cr_exp100, CURL_CR_PROTOCOL); if(!result) result = Curl_creader_add(data, reader); if(!result) { diff --git a/lib/http.h b/lib/http.h index ef41d7bb2249..1c7ebdf8d7f1 100644 --- a/lib/http.h +++ b/lib/http.h @@ -38,7 +38,6 @@ typedef enum { HTTPREQ_HEAD } Curl_HttpReq; - /* When redirecting transfers. */ typedef enum { FOLLOW_NONE, /* not used within the function, just a placeholder to @@ -55,7 +54,6 @@ typedef enum { /* bitmask of CURL_HTTP_V* values */ typedef unsigned char http_majors; - #ifndef CURL_DISABLE_HTTP #ifdef USE_HTTP3 @@ -140,7 +138,7 @@ CURLcode Curl_http_follow(struct Curl_easy *data, const char *newurl, selected to use no auth at all. Ie, we actively select no auth, as opposed to not having one selected. The other CURLAUTH_* defines are present in the public curl/curl.h header. */ -#define CURLAUTH_PICKNONE (1<<30) /* do not use auth */ +#define CURLAUTH_PICKNONE (1 << 30) /* do not use auth */ /* MAX_INITIAL_POST_SIZE indicates the number of bytes that will make the POST data get included in the initial data chunk sent to the server. If the @@ -155,7 +153,7 @@ CURLcode Curl_http_follow(struct Curl_easy *data, const char *newurl, It must not be greater than 64K to work on VMS. */ #ifndef MAX_INITIAL_POST_SIZE -#define MAX_INITIAL_POST_SIZE (64*1024) +#define MAX_INITIAL_POST_SIZE (64 * 1024) #endif /* EXPECT_100_THRESHOLD is the request body size limit for when libcurl will @@ -164,13 +162,13 @@ CURLcode Curl_http_follow(struct Curl_easy *data, const char *newurl, * */ #ifndef EXPECT_100_THRESHOLD -#define EXPECT_100_THRESHOLD (1024*1024) +#define EXPECT_100_THRESHOLD (1024 * 1024) #endif /* MAX_HTTP_RESP_HEADER_SIZE is the maximum size of all response headers combined that libcurl allows for a single HTTP response, any HTTP version. This count includes CONNECT response headers. */ -#define MAX_HTTP_RESP_HEADER_SIZE (300*1024) +#define MAX_HTTP_RESP_HEADER_SIZE (300 * 1024) /* MAX_HTTP_RESP_HEADER_COUNT is the maximum number of response headers that libcurl allows for a single HTTP response, including CONNECT and @@ -243,11 +241,11 @@ CURLcode Curl_http_req_make2(struct httpreq **preq, void Curl_http_req_free(struct httpreq *req); -#define HTTP_PSEUDO_METHOD ":method" -#define HTTP_PSEUDO_SCHEME ":scheme" +#define HTTP_PSEUDO_METHOD ":method" +#define HTTP_PSEUDO_SCHEME ":scheme" #define HTTP_PSEUDO_AUTHORITY ":authority" -#define HTTP_PSEUDO_PATH ":path" -#define HTTP_PSEUDO_STATUS ":status" +#define HTTP_PSEUDO_PATH ":path" +#define HTTP_PSEUDO_STATUS ":status" /** * Create the list of HTTP/2 headers which represent the request, diff --git a/lib/http1.c b/lib/http1.c index 657a674105fa..693a0dd7ef6d 100644 --- a/lib/http1.c +++ b/lib/http1.c @@ -33,7 +33,7 @@ #include "urlapi-int.h" -#define H1_MAX_URL_LEN (8*1024) +#define H1_MAX_URL_LEN (8 * 1024) void Curl_h1_req_parse_init(struct h1_req_parser *parser, size_t max_line_len) { @@ -227,8 +227,8 @@ static CURLcode start_req(struct h1_req_parser *parser, result = CURLE_OUT_OF_MEMORY; goto out; } - url_options = (CURLU_NON_SUPPORT_SCHEME| - CURLU_PATH_AS_IS| + url_options = (CURLU_NON_SUPPORT_SCHEME | + CURLU_PATH_AS_IS | CURLU_NO_DEFAULT_PORT); if(!(options & H1_PARSE_OPT_STRICT)) url_options |= CURLU_ALLOW_SPACE; diff --git a/lib/http2.c b/lib/http2.c index 38c7d82785fe..a3ff8c85294e 100644 --- a/lib/http2.c +++ b/lib/http2.c @@ -53,7 +53,7 @@ #endif #ifdef CURL_DISABLE_VERBOSE_STRINGS -#define nghttp2_session_callbacks_set_error_callback(x,y) +#define nghttp2_session_callbacks_set_error_callback(x, y) #endif #if (NGHTTP2_VERSION_NUM >= 0x010c00) @@ -91,7 +91,7 @@ * is blocked from sending us any data. See #10988 for an issue with this. */ #define HTTP2_HUGE_WINDOW_SIZE (100 * H2_STREAM_WINDOW_SIZE_MAX) -#define H2_SETTINGS_IV_LEN 3 +#define H2_SETTINGS_IV_LEN 3 #define H2_BINSETTINGS_LEN 80 struct cf_h2_ctx { @@ -122,8 +122,7 @@ struct cf_h2_ctx { /* How to access `call_data` from a cf_h2 filter */ #undef CF_CTX_CALL_DATA -#define CF_CTX_CALL_DATA(cf) \ - ((struct cf_h2_ctx *)(cf)->ctx)->call_data +#define CF_CTX_CALL_DATA(cf) ((struct cf_h2_ctx *)(cf)->ctx)->call_data static void h2_stream_hash_free(unsigned int id, void *stream); @@ -248,7 +247,7 @@ struct h2_stream_ctx { BIT(write_paused); /* stream write is paused */ }; -#define H2_STREAM_CTX(ctx,data) \ +#define H2_STREAM_CTX(ctx, data) \ ((struct h2_stream_ctx *)( \ data? Curl_uint32_hash_get(&(ctx)->streams, (data)->mid) : NULL)) @@ -305,8 +304,7 @@ static void h2_stream_hash_free(unsigned int id, void *stream) static int32_t cf_h2_get_desired_local_win(struct Curl_cfilter *cf, struct Curl_easy *data) { - curl_off_t avail = Curl_rlimit_avail(&data->progress.dl.rlimit, - curlx_now()); + curl_off_t avail = Curl_rlimit_avail(&data->progress.dl.rlimit, curlx_now()); (void)cf; if(avail < CURL_OFF_T_MAX) { /* limit in place */ @@ -379,7 +377,6 @@ static CURLcode cf_h2_update_local_win(struct Curl_cfilter *cf, } #endif /* !NGHTTP2_HAS_SET_LOCAL_WINDOW_SIZE */ - static CURLcode http2_data_setup(struct Curl_cfilter *cf, struct Curl_easy *data, struct h2_stream_ctx **pstream) @@ -447,8 +444,8 @@ static int h2_client_new(struct Curl_cfilter *cf, { struct cf_h2_ctx *ctx = cf->ctx; nghttp2_option *o; - nghttp2_mem mem = {NULL, Curl_nghttp2_malloc, Curl_nghttp2_free, - Curl_nghttp2_calloc, Curl_nghttp2_realloc}; + nghttp2_mem mem = { NULL, Curl_nghttp2_malloc, Curl_nghttp2_free, + Curl_nghttp2_calloc, Curl_nghttp2_realloc }; int rc = nghttp2_option_new(&o); if(rc) @@ -806,7 +803,6 @@ static ssize_t send_callback(nghttp2_session *h2, NGHTTP2_ERR_CALLBACK_FAILURE : (ssize_t)nwritten; } - /* We pass a pointer to this struct in the push callback, but the contents of the struct are hidden from the user. */ struct curl_pushheaders { @@ -1217,72 +1213,72 @@ static CURLcode on_stream_frame(struct Curl_cfilter *cf, static int fr_print(const nghttp2_frame *frame, char *buffer, size_t blen) { switch(frame->hd.type) { - case NGHTTP2_DATA: { - return curl_msnprintf(buffer, blen, - "FRAME[DATA, len=%d, eos=%d, padlen=%d]", - (int)frame->hd.length, - !!(frame->hd.flags & NGHTTP2_FLAG_END_STREAM), - (int)frame->data.padlen); - } - case NGHTTP2_HEADERS: { - return curl_msnprintf(buffer, blen, - "FRAME[HEADERS, len=%d, hend=%d, eos=%d]", - (int)frame->hd.length, - !!(frame->hd.flags & NGHTTP2_FLAG_END_HEADERS), - !!(frame->hd.flags & NGHTTP2_FLAG_END_STREAM)); - } - case NGHTTP2_PRIORITY: { - return curl_msnprintf(buffer, blen, - "FRAME[PRIORITY, len=%d, flags=%d]", - (int)frame->hd.length, frame->hd.flags); - } - case NGHTTP2_RST_STREAM: { - return curl_msnprintf(buffer, blen, - "FRAME[RST_STREAM, len=%d, flags=%d, error=%u]", - (int)frame->hd.length, frame->hd.flags, - frame->rst_stream.error_code); - } - case NGHTTP2_SETTINGS: { - if(frame->hd.flags & NGHTTP2_FLAG_ACK) { - return curl_msnprintf(buffer, blen, "FRAME[SETTINGS, ack=1]"); - } - return curl_msnprintf(buffer, blen, - "FRAME[SETTINGS, len=%d]", (int)frame->hd.length); - } - case NGHTTP2_PUSH_PROMISE: { - return curl_msnprintf(buffer, blen, - "FRAME[PUSH_PROMISE, len=%d, hend=%d]", - (int)frame->hd.length, - !!(frame->hd.flags & NGHTTP2_FLAG_END_HEADERS)); - } - case NGHTTP2_PING: { - return curl_msnprintf(buffer, blen, - "FRAME[PING, len=%d, ack=%d]", - (int)frame->hd.length, - frame->hd.flags&NGHTTP2_FLAG_ACK); - } - case NGHTTP2_GOAWAY: { - char scratch[128]; - size_t s_len = CURL_ARRAYSIZE(scratch); - size_t len = (frame->goaway.opaque_data_len < s_len) ? - frame->goaway.opaque_data_len : s_len-1; - if(len) - memcpy(scratch, frame->goaway.opaque_data, len); - scratch[len] = '\0'; - return curl_msnprintf(buffer, blen, - "FRAME[GOAWAY, error=%d, reason='%s', " - "last_stream=%d]", frame->goaway.error_code, - scratch, frame->goaway.last_stream_id); - } - case NGHTTP2_WINDOW_UPDATE: { - return curl_msnprintf(buffer, blen, - "FRAME[WINDOW_UPDATE, incr=%d]", - frame->window_update.window_size_increment); - } - default: - return curl_msnprintf(buffer, blen, "FRAME[%d, len=%d, flags=%d]", - frame->hd.type, (int)frame->hd.length, - frame->hd.flags); + case NGHTTP2_DATA: { + return curl_msnprintf(buffer, blen, + "FRAME[DATA, len=%d, eos=%d, padlen=%d]", + (int)frame->hd.length, + !!(frame->hd.flags & NGHTTP2_FLAG_END_STREAM), + (int)frame->data.padlen); + } + case NGHTTP2_HEADERS: { + return curl_msnprintf(buffer, blen, + "FRAME[HEADERS, len=%d, hend=%d, eos=%d]", + (int)frame->hd.length, + !!(frame->hd.flags & NGHTTP2_FLAG_END_HEADERS), + !!(frame->hd.flags & NGHTTP2_FLAG_END_STREAM)); + } + case NGHTTP2_PRIORITY: { + return curl_msnprintf(buffer, blen, + "FRAME[PRIORITY, len=%d, flags=%d]", + (int)frame->hd.length, frame->hd.flags); + } + case NGHTTP2_RST_STREAM: { + return curl_msnprintf(buffer, blen, + "FRAME[RST_STREAM, len=%d, flags=%d, error=%u]", + (int)frame->hd.length, frame->hd.flags, + frame->rst_stream.error_code); + } + case NGHTTP2_SETTINGS: { + if(frame->hd.flags & NGHTTP2_FLAG_ACK) { + return curl_msnprintf(buffer, blen, "FRAME[SETTINGS, ack=1]"); + } + return curl_msnprintf(buffer, blen, + "FRAME[SETTINGS, len=%d]", (int)frame->hd.length); + } + case NGHTTP2_PUSH_PROMISE: { + return curl_msnprintf(buffer, blen, + "FRAME[PUSH_PROMISE, len=%d, hend=%d]", + (int)frame->hd.length, + !!(frame->hd.flags & NGHTTP2_FLAG_END_HEADERS)); + } + case NGHTTP2_PING: { + return curl_msnprintf(buffer, blen, + "FRAME[PING, len=%d, ack=%d]", + (int)frame->hd.length, + frame->hd.flags & NGHTTP2_FLAG_ACK); + } + case NGHTTP2_GOAWAY: { + char scratch[128]; + size_t s_len = CURL_ARRAYSIZE(scratch); + size_t len = (frame->goaway.opaque_data_len < s_len) ? + frame->goaway.opaque_data_len : s_len - 1; + if(len) + memcpy(scratch, frame->goaway.opaque_data, len); + scratch[len] = '\0'; + return curl_msnprintf(buffer, blen, + "FRAME[GOAWAY, error=%d, reason='%s', " + "last_stream=%d]", frame->goaway.error_code, + scratch, frame->goaway.last_stream_id); + } + case NGHTTP2_WINDOW_UPDATE: { + return curl_msnprintf(buffer, blen, + "FRAME[WINDOW_UPDATE, incr=%d]", + frame->window_update.window_size_increment); + } + default: + return curl_msnprintf(buffer, blen, "FRAME[%d, len=%d, flags=%d]", + frame->hd.type, (int)frame->hd.length, + frame->hd.flags); } } @@ -1298,7 +1294,7 @@ static int on_frame_send(nghttp2_session *session, const nghttp2_frame *frame, if(data && Curl_trc_cf_is_verbose(cf, data)) { char buffer[256]; int len; - len = fr_print(frame, buffer, sizeof(buffer)-1); + len = fr_print(frame, buffer, sizeof(buffer) - 1); buffer[len] = 0; CURL_TRC_CF(data, cf, "[%d] -> %s", frame->hd.stream_id, buffer); } @@ -1326,9 +1322,9 @@ static int on_frame_recv(nghttp2_session *session, const nghttp2_frame *frame, if(Curl_trc_cf_is_verbose(cf, data)) { char buffer[256]; int len; - len = fr_print(frame, buffer, sizeof(buffer)-1); + len = fr_print(frame, buffer, sizeof(buffer) - 1); buffer[len] = 0; - CURL_TRC_CF(data, cf, "[%d] <- %s",frame->hd.stream_id, buffer); + CURL_TRC_CF(data, cf, "[%d] <- %s", frame->hd.stream_id, buffer); } #endif /* !CURL_DISABLE_VERBOSE_STRINGS */ @@ -1340,9 +1336,9 @@ static int on_frame_recv(nghttp2_session *session, const nghttp2_frame *frame, if(!(frame->hd.flags & NGHTTP2_FLAG_ACK)) { uint32_t max_conn = ctx->max_concurrent_streams; ctx->max_concurrent_streams = nghttp2_session_get_remote_settings( - session, NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS); + session, NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS); ctx->enable_push = nghttp2_session_get_remote_settings( - session, NGHTTP2_SETTINGS_ENABLE_PUSH) != 0; + session, NGHTTP2_SETTINGS_ENABLE_PUSH) != 0; CURL_TRC_CF(data, cf, "[0] MAX_CONCURRENT_STREAMS: %d", ctx->max_concurrent_streams); CURL_TRC_CF(data, cf, "[0] ENABLE_PUSH: %s", @@ -1369,7 +1365,7 @@ static int on_frame_recv(nghttp2_session *session, const nghttp2_frame *frame, ctx->remote_max_sid = frame->goaway.last_stream_id; if(data) { infof(data, "received GOAWAY, error=%u, last_stream=%u", - ctx->goaway_error, ctx->remote_max_sid); + ctx->goaway_error, ctx->remote_max_sid); Curl_multi_connchanged(data->multi); } break; @@ -1403,7 +1399,7 @@ static int cf_h2_on_invalid_frame_recv(nghttp2_session *session, #ifndef CURL_DISABLE_VERBOSE_STRINGS char buffer[256]; int len; - len = fr_print(frame, buffer, sizeof(buffer)-1); + len = fr_print(frame, buffer, sizeof(buffer) - 1); buffer[len] = 0; failf(data, "[HTTP2] [%d] received invalid frame: %s, error %d: %s", stream_id, buffer, ngerr, nghttp2_strerror(ngerr)); @@ -1440,8 +1436,7 @@ static int on_data_chunk_recv(nghttp2_session *session, uint8_t flags, /* Receiving a Stream ID not in the hash should not happen - unless we have aborted a transfer artificially and there were more data in the pipeline. Silently ignore. */ - CURL_TRC_CF(CF_DATA_CURRENT(cf), cf, "[%d] Data for unknown", - stream_id); + CURL_TRC_CF(CF_DATA_CURRENT(cf), cf, "[%d] Data for unknown", stream_id); /* consumed explicitly as no one will read it */ nghttp2_session_consume(session, stream_id, len); return 0; @@ -1594,7 +1589,7 @@ static int on_header(nghttp2_session *session, const nghttp2_frame *frame, if(frame->hd.type == NGHTTP2_PUSH_PROMISE) { char *h; - if((namelen == (sizeof(HTTP_PSEUDO_AUTHORITY)-1)) && + if((namelen == (sizeof(HTTP_PSEUDO_AUTHORITY) - 1)) && !strncmp(HTTP_PSEUDO_AUTHORITY, (const char *)name, namelen)) { /* pseudo headers are lower case */ int rc = 0; @@ -1900,7 +1895,8 @@ static CURLcode http2_handle_stream_close(struct Curl_cfilter *cf, break; Curl_debug(data, CURLINFO_HEADER_IN, curlx_dyn_ptr(&dbuf), curlx_dyn_len(&dbuf)); - result = Curl_client_write(data, CLIENTWRITE_HEADER|CLIENTWRITE_TRAILER, + result = Curl_client_write(data, + CLIENTWRITE_HEADER | CLIENTWRITE_TRAILER, curlx_dyn_ptr(&dbuf), curlx_dyn_len(&dbuf)); if(result) break; @@ -1967,7 +1963,7 @@ static CURLcode h2_progress_egress(struct Curl_cfilter *cf, if(stream && stream->id > 0 && ((sweight_wanted(data) != sweight_in_effect(data)) || (data->set.priority.exclusive != data->state.priority.exclusive) || - (data->set.priority.parent != data->state.priority.parent)) ) { + (data->set.priority.parent != data->state.priority.parent))) { /* send new weight and/or dependency */ nghttp2_priority_spec pri_spec; diff --git a/lib/http2.h b/lib/http2.h index 93cc2d44f259..147d7f76d538 100644 --- a/lib/http2.h +++ b/lib/http2.h @@ -65,10 +65,10 @@ extern struct Curl_cftype Curl_cft_nghttp2; #define Curl_http2_may_switch(a) FALSE -#define Curl_http2_request_upgrade(x,y) CURLE_UNSUPPORTED_PROTOCOL -#define Curl_http2_switch(a) CURLE_UNSUPPORTED_PROTOCOL -#define Curl_http2_upgrade(a,b,c,d,e) CURLE_UNSUPPORTED_PROTOCOL -#define Curl_h2_http_1_1_error(x) 0 +#define Curl_http2_request_upgrade(x, y) CURLE_UNSUPPORTED_PROTOCOL +#define Curl_http2_switch(a) CURLE_UNSUPPORTED_PROTOCOL +#define Curl_http2_upgrade(a, b, c, d, e) CURLE_UNSUPPORTED_PROTOCOL +#define Curl_h2_http_1_1_error(x) 0 #endif #endif /* HEADER_CURL_HTTP2_H */ diff --git a/lib/http_aws_sigv4.c b/lib/http_aws_sigv4.c index 0ef18b6feabe..da80f1965809 100644 --- a/lib/http_aws_sigv4.c +++ b/lib/http_aws_sigv4.c @@ -133,7 +133,7 @@ static void trim_headers(struct curl_slist *head) } /* maximum length for the aws sivg4 parts */ -#define MAX_SIGV4_LEN 64 +#define MAX_SIGV4_LEN 64 #define DATE_HDR_KEY_LEN (MAX_SIGV4_LEN + sizeof("X--Date")) /* string been x-PROVIDER-date:TIMESTAMP, I need +1 for ':' */ @@ -400,8 +400,7 @@ static CURLcode make_headers(struct Curl_easy *data, #define CONTENT_SHA256_KEY_LEN (MAX_SIGV4_LEN + sizeof("X--Content-Sha256")) /* add 2 for ": " between header name and value */ -#define CONTENT_SHA256_HDR_LEN (CONTENT_SHA256_KEY_LEN + 2 + \ - SHA256_HEX_LENGTH) +#define CONTENT_SHA256_HDR_LEN (CONTENT_SHA256_KEY_LEN + 2 + SHA256_HEX_LENGTH) /* try to parse a payload hash from the content-sha256 header */ static const char *parse_content_sha_hdr(struct Curl_easy *data, @@ -429,7 +428,7 @@ static const char *parse_content_sha_hdr(struct Curl_easy *data, curlx_str_passblanks(&value); len = strlen(value); - while(len > 0 && ISBLANK(value[len-1])) + while(len > 0 && ISBLANK(value[len - 1])) --len; *value_len = len; @@ -530,7 +529,6 @@ static int compare_func(const void *a, const void *b) compare = strcmp(curlx_dyn_ptr(&aa->value), curlx_dyn_ptr(&bb->value)); return compare; - } UNITTEST CURLcode canon_path(const char *q, size_t len, @@ -572,14 +570,13 @@ UNITTEST CURLcode canon_query(const char *query, struct dynbuf *dq) if(!query) return result; - result = split_to_dyn_array(query, &query_array[0], - &num_query_components); + result = split_to_dyn_array(query, &query_array[0], &num_query_components); if(result) { goto fail; } /* Create list of pairs, each pair containing an encoded query - * component */ + * component */ for(index = 0; index < num_query_components; index++) { const char *in_key; @@ -599,8 +596,8 @@ UNITTEST CURLcode canon_query(const char *query, struct dynbuf *dq) in_key_len = offset - in_key; } - curlx_dyn_init(&encoded_query_array[index].key, query_part_len*3 + 1); - curlx_dyn_init(&encoded_query_array[index].value, query_part_len*3 + 1); + curlx_dyn_init(&encoded_query_array[index].key, query_part_len * 3 + 1); + curlx_dyn_init(&encoded_query_array[index].value, query_part_len * 3 + 1); counted_query_components++; /* Decode/encode the key */ @@ -672,8 +669,8 @@ CURLcode Curl_output_aws_sigv4(struct Curl_easy *data) const char *line; struct Curl_str provider0; struct Curl_str provider1; - struct Curl_str region = { NULL, 0}; - struct Curl_str service = { NULL, 0}; + struct Curl_str region = { NULL, 0 }; + struct Curl_str service = { NULL, 0 }; const char *hostname = conn->host.name; time_t clock; struct tm tm; @@ -697,8 +694,8 @@ CURLcode Curl_output_aws_sigv4(struct Curl_easy *data) char *str_to_sign = NULL; const char *user = data->state.aptr.user ? data->state.aptr.user : ""; char *secret = NULL; - unsigned char sign0[CURL_SHA256_DIGEST_LENGTH] = {0}; - unsigned char sign1[CURL_SHA256_DIGEST_LENGTH] = {0}; + unsigned char sign0[CURL_SHA256_DIGEST_LENGTH] = { 0 }; + unsigned char sign1[CURL_SHA256_DIGEST_LENGTH] = { 0 }; char *auth_headers = NULL; if(data->set.path_as_is) { @@ -782,7 +779,7 @@ CURLcode Curl_output_aws_sigv4(struct Curl_easy *data) /* AWS S3 requires a x-amz-content-sha256 header, and supports special * values like UNSIGNED-PAYLOAD */ bool sign_as_s3 = curlx_str_casecompare(&provider0, "aws") && - curlx_str_casecompare(&service, "s3"); + curlx_str_casecompare(&service, "s3"); if(sign_as_s3) result = calc_s3_payload_hash(data, httpreq, curlx_str(&provider1), @@ -864,7 +861,7 @@ CURLcode Curl_output_aws_sigv4(struct Curl_easy *data) goto fail; infof(data, "aws_sigv4: Canonical request (enclosed in []) - [%s]", - canonical_request); + canonical_request); request_type = curl_maprintf("%.*s4_request", (int)curlx_strlen(&provider0), @@ -885,7 +882,7 @@ CURLcode Curl_output_aws_sigv4(struct Curl_easy *data) if(!credential_scope) goto fail; - if(Curl_sha256it(sha_hash, (unsigned char *) canonical_request, + if(Curl_sha256it(sha_hash, (unsigned char *)canonical_request, strlen(canonical_request))) goto fail; @@ -912,7 +909,7 @@ CURLcode Curl_output_aws_sigv4(struct Curl_easy *data) curlx_strlen(&provider0)); infof(data, "aws_sigv4: String to sign (enclosed in []) - [%s]", - str_to_sign); + str_to_sign); secret = curl_maprintf("%.*s4%s", (int)curlx_strlen(&provider0), curlx_str(&provider0), data->state.aptr.passwd ? @@ -980,8 +977,8 @@ CURLcode Curl_output_aws_sigv4(struct Curl_easy *data) } /* -* Frees all allocated strings in a dynbuf pair array, and the dynbuf itself -*/ + * Frees all allocated strings in a dynbuf pair array, and the dynbuf itself + */ static void pair_array_free(struct pair *pair_array, size_t num_elements) { @@ -991,12 +988,11 @@ static void pair_array_free(struct pair *pair_array, size_t num_elements) curlx_dyn_free(&pair_array[index].key); curlx_dyn_free(&pair_array[index].value); } - } /* -* Frees all allocated strings in a split dynbuf, and the dynbuf itself -*/ + * Frees all allocated strings in a split dynbuf, and the dynbuf itself + */ static void dyn_array_free(struct dynbuf *db, size_t num_elements) { @@ -1007,10 +1003,10 @@ static void dyn_array_free(struct dynbuf *db, size_t num_elements) } /* -* Splits source string by SPLIT_BY, and creates an array of dynbuf in db. -* db is initialized by this function. -* Caller is responsible for freeing the array elements with dyn_array_free -*/ + * Splits source string by SPLIT_BY, and creates an array of dynbuf in db. + * db is initialized by this function. + * Caller is responsible for freeing the array elements with dyn_array_free + */ #define SPLIT_BY '&' @@ -1032,8 +1028,7 @@ static CURLcode split_to_dyn_array(const char *source, if(source[pos] == SPLIT_BY) { if(segment_length) { curlx_dyn_init(&db[index], segment_length + 1); - result = curlx_dyn_addn(&db[index], &source[start], - segment_length); + result = curlx_dyn_addn(&db[index], &source[start], segment_length); if(result) goto fail; @@ -1064,7 +1059,6 @@ static CURLcode split_to_dyn_array(const char *source, return result; } - static bool is_reserved_char(const char c) { return (ISALNUM(c) || ISURLPUNTCS(c)); @@ -1091,7 +1085,6 @@ static CURLcode uri_encode_path(struct Curl_str *original_path, return CURLE_OK; } - static CURLcode encode_query_component(char *component, size_t len, struct dynbuf *db) { @@ -1116,8 +1109,8 @@ static CURLcode encode_query_component(char *component, size_t len, } /* -* Populates a dynbuf containing url_encode(url_decode(in)) -*/ + * Populates a dynbuf containing url_encode(url_decode(in)) + */ static CURLcode http_aws_decode_encode(const char *in, size_t in_len, struct dynbuf *out) diff --git a/lib/http_aws_sigv4.h b/lib/http_aws_sigv4.h index 9747c948a69d..ea7651896e50 100644 --- a/lib/http_aws_sigv4.h +++ b/lib/http_aws_sigv4.h @@ -33,8 +33,7 @@ CURLcode Curl_output_aws_sigv4(struct Curl_easy *data); #ifdef UNITTESTS UNITTEST CURLcode canon_path(const char *q, size_t len, - struct dynbuf *new_path, - bool normalize); + struct dynbuf *new_path, bool normalize); UNITTEST CURLcode canon_query(const char *query, struct dynbuf *dq); #endif diff --git a/lib/http_chunks.c b/lib/http_chunks.c index 9d0a0b324cdd..76aab85ce233 100644 --- a/lib/http_chunks.c +++ b/lib/http_chunks.c @@ -357,7 +357,6 @@ static CURLcode httpchunk_readwrite(struct Curl_easy *data, case CHUNK_FAILED: return CURLE_RECV_ERROR; } - } return CURLE_OK; } @@ -528,8 +527,7 @@ static CURLcode add_last_chunk(struct Curl_easy *data, continue; } - result = Curl_bufq_cwrite(&ctx->chunkbuf, tr->data, - strlen(tr->data), &n); + result = Curl_bufq_cwrite(&ctx->chunkbuf, tr->data, strlen(tr->data), &n); if(!result) result = Curl_bufq_cwrite(&ctx->chunkbuf, STRCONST("\r\n"), &n); if(result) diff --git a/lib/http_digest.c b/lib/http_digest.c index 2ca1a12d5daf..34aba0e3ba2f 100644 --- a/lib/http_digest.c +++ b/lib/http_digest.c @@ -148,7 +148,7 @@ CURLcode Curl_output_digest(struct Curl_easy *data, } } if(!tmp) - path = (unsigned char *)curlx_strdup((const char *) uripath); + path = (unsigned char *)curlx_strdup((const char *)uripath); if(!path) return CURLE_OUT_OF_MEMORY; diff --git a/lib/http_negotiate.c b/lib/http_negotiate.c index f31e59c2ca6d..2929f7980aff 100644 --- a/lib/http_negotiate.c +++ b/lib/http_negotiate.c @@ -47,7 +47,6 @@ static void http_auth_nego_reset(struct connectdata *conn, Curl_auth_cleanup_spnego(neg_ctx); } - CURLcode Curl_input_negotiate(struct Curl_easy *data, struct connectdata *conn, bool proxy, const char *header) { @@ -124,8 +123,8 @@ CURLcode Curl_input_negotiate(struct Curl_easy *data, struct connectdata *conn, #ifdef USE_SSL curlx_dyn_init(&neg_ctx->channel_binding_data, SSL_CB_MAX_SIZE + 1); if(Curl_conn_is_ssl(conn, FIRSTSOCKET)) { - result = Curl_ssl_get_channel_binding( - data, FIRSTSOCKET, &neg_ctx->channel_binding_data); + result = Curl_ssl_get_channel_binding(data, FIRSTSOCKET, + &neg_ctx->channel_binding_data); if(result) { http_auth_nego_reset(conn, neg_ctx, proxy); return result; diff --git a/lib/http_ntlm.c b/lib/http_ntlm.c index 6c79bcac1b97..e1b48d76759d 100644 --- a/lib/http_ntlm.c +++ b/lib/http_ntlm.c @@ -144,7 +144,7 @@ CURLcode Curl_output_ntlm(struct Curl_easy *data, bool proxy) userp = data->state.aptr.proxyuser; passwdp = data->state.aptr.proxypasswd; service = data->set.str[STRING_PROXY_SERVICE_NAME] ? - data->set.str[STRING_PROXY_SERVICE_NAME] : "HTTP"; + data->set.str[STRING_PROXY_SERVICE_NAME] : "HTTP"; hostname = conn->http_proxy.host.name; state = &conn->proxy_ntlm_state; authp = &data->state.authproxy; @@ -157,7 +157,7 @@ CURLcode Curl_output_ntlm(struct Curl_easy *data, bool proxy) userp = data->state.aptr.user; passwdp = data->state.aptr.passwd; service = data->set.str[STRING_SERVICE_NAME] ? - data->set.str[STRING_SERVICE_NAME] : "HTTP"; + data->set.str[STRING_SERVICE_NAME] : "HTTP"; hostname = conn->host.name; state = &conn->http_ntlm_state; authp = &data->state.authhost; @@ -202,12 +202,11 @@ CURLcode Curl_output_ntlm(struct Curl_easy *data, bool proxy) if(!result) { DEBUGASSERT(Curl_bufref_len(&ntlmmsg) != 0); result = curlx_base64_encode(Curl_bufref_ptr(&ntlmmsg), - Curl_bufref_len(&ntlmmsg), &base64, &len); + Curl_bufref_len(&ntlmmsg), &base64, &len); if(!result) { curlx_free(*allocuserpwd); *allocuserpwd = curl_maprintf("%sAuthorization: NTLM %s\r\n", - proxy ? "Proxy-" : "", - base64); + proxy ? "Proxy-" : "", base64); curlx_free(base64); if(!*allocuserpwd) result = CURLE_OUT_OF_MEMORY; @@ -225,8 +224,7 @@ CURLcode Curl_output_ntlm(struct Curl_easy *data, bool proxy) if(!result) { curlx_free(*allocuserpwd); *allocuserpwd = curl_maprintf("%sAuthorization: NTLM %s\r\n", - proxy ? "Proxy-" : "", - base64); + proxy ? "Proxy-" : "", base64); curlx_free(base64); if(!*allocuserpwd) result = CURLE_OUT_OF_MEMORY; diff --git a/lib/http_proxy.c b/lib/http_proxy.c index 21f0cc6211c1..d1d043bfb245 100644 --- a/lib/http_proxy.c +++ b/lib/http_proxy.c @@ -131,25 +131,31 @@ static CURLcode dynhds_add_custom(struct Curl_easy *data, if(data->state.aptr.host && /* a Host: header was sent already, do not pass on any custom Host: header as that will produce *two* in the same request! */ - curlx_str_casecompare(&name, "Host")); + curlx_str_casecompare(&name, "Host")) + ; else if(data->state.httpreq == HTTPREQ_POST_FORM && /* this header (extended by formdata.c) is sent later */ - curlx_str_casecompare(&name, "Content-Type")); + curlx_str_casecompare(&name, "Content-Type")) + ; else if(data->state.httpreq == HTTPREQ_POST_MIME && /* this header is sent later */ - curlx_str_casecompare(&name, "Content-Type")); + curlx_str_casecompare(&name, "Content-Type")) + ; else if(data->req.authneg && /* while doing auth neg, do not allow the custom length since we will force length zero then */ - curlx_str_casecompare(&name, "Content-Length")); + curlx_str_casecompare(&name, "Content-Length")) + ; else if((httpversion >= 20) && - curlx_str_casecompare(&name, "Transfer-Encoding")); + curlx_str_casecompare(&name, "Transfer-Encoding")) + ; /* HTTP/2 and HTTP/3 do not support chunked requests */ else if((curlx_str_casecompare(&name, "Authorization") || curlx_str_casecompare(&name, "Cookie")) && /* be careful of sending this potentially sensitive header to other hosts */ - !Curl_auth_allowed_to_host(data)); + !Curl_auth_allowed_to_host(data)) + ; else { CURLcode result = Curl_dynhds_add(hds, curlx_str(&name), curlx_strlen(&name), @@ -211,13 +217,13 @@ CURLcode Curl_http_proxy_create_CONNECT(struct httpreq **preq, Curl_http_proxy_get_destination(cf, &hostname, &port, &ipv6_ip); authority = curl_maprintf("%s%s%s:%d", ipv6_ip ? "[" : "", hostname, - ipv6_ip ?"]" : "", port); + ipv6_ip ? "]" : "", port); if(!authority) { result = CURLE_OUT_OF_MEMORY; goto out; } - result = Curl_http_req_make(&req, "CONNECT", sizeof("CONNECT")-1, + result = Curl_http_req_make(&req, "CONNECT", sizeof("CONNECT") - 1, NULL, 0, authority, strlen(authority), NULL, 0); if(result) @@ -253,7 +259,7 @@ CURLcode Curl_http_proxy_create_CONNECT(struct httpreq **preq, } if(http_version_major == 1 && - !Curl_checkProxyheaders(data, cf->conn, STRCONST("Proxy-Connection"))) { + !Curl_checkProxyheaders(data, cf->conn, STRCONST("Proxy-Connection"))) { result = Curl_dynhds_cadd(&req->headers, "Proxy-Connection", "Keep-Alive"); if(result) goto out; @@ -394,10 +400,9 @@ static void http_proxy_cf_close(struct Curl_cfilter *cf, cf->next->cft->do_close(cf->next, data); } - struct Curl_cftype Curl_cft_http_proxy = { "HTTP-PROXY", - CF_TYPE_IP_CONNECT|CF_TYPE_PROXY, + CF_TYPE_IP_CONNECT | CF_TYPE_PROXY, 0, http_proxy_cf_destroy, http_proxy_cf_connect, diff --git a/lib/http_proxy.h b/lib/http_proxy.h index 17f7e10488e1..7af2ebb284c9 100644 --- a/lib/http_proxy.h +++ b/lib/http_proxy.h @@ -46,7 +46,7 @@ CURLcode Curl_http_proxy_create_CONNECT(struct httpreq **preq, int http_version_major); /* Default proxy timeout in milliseconds */ -#define PROXY_TIMEOUT (3600*1000) +#define PROXY_TIMEOUT (3600 * 1000) CURLcode Curl_cf_http_proxy_query(struct Curl_cfilter *cf, struct Curl_easy *data, diff --git a/lib/httpsrr.c b/lib/httpsrr.c index 34d081b50264..3acb16ac3a71 100644 --- a/lib/httpsrr.c +++ b/lib/httpsrr.c @@ -151,7 +151,6 @@ void Curl_httpsrr_cleanup(struct Curl_https_rrinfo *rrinfo) Curl_safefree(rrinfo->rrname); } - #ifdef USE_ARES static CURLcode httpsrr_opt(struct Curl_easy *data, diff --git a/lib/httpsrr.h b/lib/httpsrr.h index 9b7831f75cbc..4259a03262f3 100644 --- a/lib/httpsrr.h +++ b/lib/httpsrr.h @@ -33,7 +33,7 @@ #ifdef USE_HTTPSRR #define CURL_MAXLEN_host_name 253 -#define MAX_HTTPSRR_ALPNS 4 +#define MAX_HTTPSRR_ALPNS 4 struct Curl_easy; diff --git a/lib/idn.c b/lib/idn.c index 0b1a4a36ccc0..8f4c3e03f712 100644 --- a/lib/idn.c +++ b/lib/idn.c @@ -22,9 +22,9 @@ * ***************************************************************************/ - /* - * IDN conversions - */ +/* + * IDN conversions + */ #include "curl_setup.h" #include "urldata.h" @@ -87,18 +87,18 @@ static CURLcode mac_idn_to_ascii(const char *in, char **out) { size_t inlen = strlen(in); if(inlen < MAX_HOST_LENGTH) { - char iconv_buffer[MAX_HOST_LENGTH] = {0}; + char iconv_buffer[MAX_HOST_LENGTH] = { 0 }; char *iconv_outptr = iconv_buffer; size_t iconv_outlen = sizeof(iconv_buffer); CURLcode iconv_result = iconv_to_utf8(in, inlen, &iconv_outptr, &iconv_outlen); if(!iconv_result) { UErrorCode err = U_ZERO_ERROR; - UIDNA* idna = uidna_openUTS46( - UIDNA_CHECK_BIDI|UIDNA_NONTRANSITIONAL_TO_ASCII, &err); + UIDNA *idna = uidna_openUTS46( + UIDNA_CHECK_BIDI | UIDNA_NONTRANSITIONAL_TO_ASCII, &err); if(!U_FAILURE(err)) { UIDNAInfo info = UIDNA_INFO_INITIALIZER; - char buffer[MAX_HOST_LENGTH] = {0}; + char buffer[MAX_HOST_LENGTH] = { 0 }; (void)uidna_nameToASCII_UTF8(idna, iconv_buffer, (int)iconv_outlen, buffer, sizeof(buffer) - 1, &info, &err); uidna_close(idna); @@ -122,11 +122,11 @@ static CURLcode mac_ascii_to_idn(const char *in, char **out) size_t inlen = strlen(in); if(inlen < MAX_HOST_LENGTH) { UErrorCode err = U_ZERO_ERROR; - UIDNA* idna = uidna_openUTS46( - UIDNA_CHECK_BIDI|UIDNA_NONTRANSITIONAL_TO_UNICODE, &err); + UIDNA *idna = uidna_openUTS46( + UIDNA_CHECK_BIDI | UIDNA_NONTRANSITIONAL_TO_UNICODE, &err); if(!U_FAILURE(err)) { UIDNAInfo info = UIDNA_INFO_INITIALIZER; - char buffer[MAX_HOST_LENGTH] = {0}; + char buffer[MAX_HOST_LENGTH] = { 0 }; (void)uidna_nameToUnicodeUTF8(idna, in, -1, buffer, sizeof(buffer) - 1, &info, &err); uidna_close(idna); diff --git a/lib/if2ip.c b/lib/if2ip.c index c2b8aafc4d7e..ef2bfe2b0a48 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -62,10 +62,10 @@ unsigned int Curl_ipv6_scope(const struct sockaddr *sa) { if(sa->sa_family == AF_INET6) { - const struct sockaddr_in6 * sa6 = - (const struct sockaddr_in6 *)(const void *) sa; + const struct sockaddr_in6 *sa6 = + (const struct sockaddr_in6 *)(const void *)sa; const unsigned char *b = sa6->sin6_addr.s6_addr; - unsigned short w = (unsigned short) ((b[0] << 8) | b[1]); + unsigned short w = (unsigned short)((b[0] << 8) | b[1]); if((b[0] & 0xFE) == 0xFC) /* Handle ULAs */ return IPV6_SCOPE_UNIQUELOCAL; @@ -103,8 +103,7 @@ if2ip_result_t Curl_if2ip(int af, struct ifaddrs *iface, *head; if2ip_result_t res = IF2IP_NOT_FOUND; -#if defined(USE_IPV6) && \ - !defined(HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID) +#if defined(USE_IPV6) && !defined(HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID) (void)local_scope_id; #endif @@ -138,7 +137,7 @@ if2ip_result_t Curl_if2ip(int af, #ifdef HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID /* Include the scope of this interface as part of the address */ scopeid = ((struct sockaddr_in6 *)(void *)iface->ifa_addr) - ->sin6_scope_id; + ->sin6_scope_id; /* If given, scope id should match. */ if(local_scope_id && scopeid != local_scope_id) { @@ -248,15 +247,15 @@ if2ip_result_t Curl_if2ip(int af, const char *interf, char *buf, size_t buf_size) { - (void)af; + (void)af; #ifdef USE_IPV6 - (void)remote_scope; - (void)local_scope_id; + (void)remote_scope; + (void)local_scope_id; #endif - (void)interf; - (void)buf; - (void)buf_size; - return IF2IP_NOT_FOUND; + (void)interf; + (void)buf; + (void)buf_size; + return IF2IP_NOT_FOUND; } #endif diff --git a/lib/if2ip.h b/lib/if2ip.h index 42ec7b033a8c..12fdaabd736a 100644 --- a/lib/if2ip.h +++ b/lib/if2ip.h @@ -56,7 +56,7 @@ if2ip_result_t Curl_if2ip(int af, /* Nedelcho Stanev's work-around for SFU 3.0 */ struct ifreq { -#define IFNAMSIZ 16 +#define IFNAMSIZ 16 #define IFHWADDRLEN 6 union { char ifrn_name[IFNAMSIZ]; /* if name, e.g. "en0" */ @@ -75,14 +75,14 @@ struct ifreq { /* This define exists to avoid an extra #ifdef INTERIX in the C code. */ -#define ifr_name ifr_ifrn.ifrn_name /* interface name */ -#define ifr_addr ifr_ifru.ifru_addr /* address */ +#define ifr_name ifr_ifrn.ifrn_name /* interface name */ +#define ifr_addr ifr_ifru.ifru_addr /* address */ #define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */ -#define ifr_netmask ifr_ifru.ifru_netmask /* interface net mask */ -#define ifr_flags ifr_ifru.ifru_flags /* flags */ -#define ifr_hwaddr ifr_ifru.ifru_hwaddr /* MAC address */ -#define ifr_metric ifr_ifru.ifru_metric /* metric */ -#define ifr_mtu ifr_ifru.ifru_mtu /* mtu */ +#define ifr_netmask ifr_ifru.ifru_netmask /* interface net mask */ +#define ifr_flags ifr_ifru.ifru_flags /* flags */ +#define ifr_hwaddr ifr_ifru.ifru_hwaddr /* MAC address */ +#define ifr_metric ifr_ifru.ifru_metric /* metric */ +#define ifr_mtu ifr_ifru.ifru_mtu /* mtu */ #define SIOCGIFADDR _IOW('s', 102, struct ifreq) /* Get if addr */ diff --git a/lib/imap.c b/lib/imap.c index 9d58bec4ec81..ec5e654cfae9 100644 --- a/lib/imap.c +++ b/lib/imap.c @@ -347,46 +347,46 @@ static bool imap_endofresp(struct Curl_easy *data, struct connectdata *conn, /* Do we have an untagged command response? */ if(len >= 2 && !memcmp("* ", line, 2)) { switch(imapc->state) { - /* States which are interested in untagged responses */ - case IMAP_CAPABILITY: - if(!imap_matchresp(line, len, "CAPABILITY")) - return FALSE; - break; - - case IMAP_LIST: - if((!imap->custom && !imap_matchresp(line, len, "LIST")) || - (imap->custom && !imap_matchresp(line, len, imap->custom) && - (!curl_strequal(imap->custom, "STORE") || - !imap_matchresp(line, len, "FETCH")) && - !curl_strequal(imap->custom, "SELECT") && - !curl_strequal(imap->custom, "EXAMINE") && - !curl_strequal(imap->custom, "SEARCH") && - !curl_strequal(imap->custom, "EXPUNGE") && - !curl_strequal(imap->custom, "LSUB") && - !curl_strequal(imap->custom, "UID") && - !curl_strequal(imap->custom, "GETQUOTAROOT") && - !curl_strequal(imap->custom, "NOOP"))) - return FALSE; - break; + /* States which are interested in untagged responses */ + case IMAP_CAPABILITY: + if(!imap_matchresp(line, len, "CAPABILITY")) + return FALSE; + break; - case IMAP_SELECT: - /* SELECT is special in that its untagged responses do not have a - common prefix so accept anything! */ - break; + case IMAP_LIST: + if((!imap->custom && !imap_matchresp(line, len, "LIST")) || + (imap->custom && !imap_matchresp(line, len, imap->custom) && + (!curl_strequal(imap->custom, "STORE") || + !imap_matchresp(line, len, "FETCH")) && + !curl_strequal(imap->custom, "SELECT") && + !curl_strequal(imap->custom, "EXAMINE") && + !curl_strequal(imap->custom, "SEARCH") && + !curl_strequal(imap->custom, "EXPUNGE") && + !curl_strequal(imap->custom, "LSUB") && + !curl_strequal(imap->custom, "UID") && + !curl_strequal(imap->custom, "GETQUOTAROOT") && + !curl_strequal(imap->custom, "NOOP"))) + return FALSE; + break; - case IMAP_FETCH: - if(!imap_matchresp(line, len, "FETCH")) - return FALSE; - break; + case IMAP_SELECT: + /* SELECT is special in that its untagged responses do not have a + common prefix so accept anything! */ + break; - case IMAP_SEARCH: - if(!imap_matchresp(line, len, "SEARCH")) - return FALSE; - break; + case IMAP_FETCH: + if(!imap_matchresp(line, len, "FETCH")) + return FALSE; + break; - /* Ignore other untagged responses */ - default: + case IMAP_SEARCH: + if(!imap_matchresp(line, len, "SEARCH")) return FALSE; + break; + + /* Ignore other untagged responses */ + default: + return FALSE; } *resp = '*'; @@ -400,16 +400,16 @@ static bool imap_endofresp(struct Curl_easy *data, struct connectdata *conn, if(!imap->custom && ((len == 3 && line[0] == '+') || (len >= 2 && !memcmp("+ ", line, 2)))) { switch(imapc->state) { - /* States which are interested in continuation responses */ - case IMAP_AUTHENTICATE: - case IMAP_APPEND: - *resp = '+'; - break; + /* States which are interested in continuation responses */ + case IMAP_AUTHENTICATE: + case IMAP_APPEND: + *resp = '+'; + break; - default: - failf(data, "Unexpected continuation response"); - *resp = -1; - break; + default: + failf(data, "Unexpected continuation response"); + *resp = -1; + break; } return TRUE; @@ -471,7 +471,7 @@ static void imap_state(struct Curl_easy *data, { #if defined(DEBUGBUILD) && !defined(CURL_DISABLE_VERBOSE_STRINGS) /* for debug purposes */ - static const char * const names[]={ + static const char * const names[] = { "STOP", "SERVERGREET", "CAPABILITY", @@ -570,8 +570,8 @@ static CURLcode imap_perform_upgrade_tls(struct Curl_easy *data, result, ssldone)); if(!result && ssldone) { imapc->ssldone = ssldone; - /* perform CAPA now, changes imapc->state out of IMAP_UPGRADETLS */ - result = imap_perform_capability(data, imapc); + /* perform CAPA now, changes imapc->state out of IMAP_UPGRADETLS */ + result = imap_perform_capability(data, imapc); } out: return result; @@ -636,7 +636,7 @@ static CURLcode imap_perform_authenticate(struct Curl_easy *data, struct imap_conn *imapc = Curl_conn_meta_get(data->conn, CURL_META_IMAP_CONN); CURLcode result = CURLE_OK; - const char *ir = (const char *) Curl_bufref_ptr(initresp); + const char *ir = (const char *)Curl_bufref_ptr(initresp); if(!imapc) return CURLE_FAILED_INIT; @@ -669,7 +669,7 @@ static CURLcode imap_continue_authenticate(struct Curl_easy *data, if(!imapc) return CURLE_FAILED_INIT; return Curl_pp_sendf(data, &imapc->pp, - "%s", (const char *) Curl_bufref_ptr(resp)); + "%s", (const char *)Curl_bufref_ptr(resp)); } /*********************************************************************** @@ -1048,8 +1048,8 @@ static CURLcode imap_state_capability_resp(struct Curl_easy *data, /* Extract the word */ for(wordlen = 0; line[wordlen] && line[wordlen] != ' ' && - line[wordlen] != '\t' && line[wordlen] != '\r' && - line[wordlen] != '\n';) + line[wordlen] != '\t' && line[wordlen] != '\r' && + line[wordlen] != '\n';) wordlen++; /* Does the server support the STARTTLS capability? */ @@ -1322,7 +1322,6 @@ static CURLcode imap_state_select_resp(struct Curl_easy *data, imapc->mb_uidvalidity = (unsigned int)value; imapc->mb_uidvalidity_set = TRUE; } - } } else if(imapcode == IMAP_RESP_OK) { @@ -1797,7 +1796,7 @@ static CURLcode imap_perform(struct Curl_easy *data, bool *connected, /* SEARCH the current mailbox */ result = imap_perform_search(data, imapc, imap); else if(imap->mailbox && !selected && - (imap->custom || imap->uid || imap->mindex || imap->query)) + (imap->custom || imap->uid || imap->mindex || imap->query)) /* SELECT the mailbox */ result = imap_perform_select(data, imapc, imap); else @@ -2112,21 +2111,33 @@ static bool imap_is_bchar(char ch) return TRUE; switch(ch) { - /* bchar */ - case ':': case '@': case '/': - /* bchar -> achar */ - case '&': case '=': - /* bchar -> achar -> uchar -> unreserved (without alphanumeric) */ - case '-': case '.': case '_': case '~': - /* bchar -> achar -> uchar -> sub-delims-sh */ - case '!': case '$': case '\'': case '(': case ')': case '*': - case '+': case ',': - /* bchar -> achar -> uchar -> pct-encoded */ - case '%': /* HEXDIG chars are already included above */ - return TRUE; + /* bchar */ + case ':': + case '@': + case '/': + /* bchar -> achar */ + case '&': + case '=': + /* bchar -> achar -> uchar -> unreserved (without alphanumeric) */ + case '-': + case '.': + case '_': + case '~': + /* bchar -> achar -> uchar -> sub-delims-sh */ + case '!': + case '$': + case '\'': + case '(': + case ')': + case '*': + case '+': + case ',': + /* bchar -> achar -> uchar -> pct-encoded */ + case '%': /* HEXDIG chars are already included above */ + return TRUE; - default: - return FALSE; + default: + return FALSE; } } diff --git a/lib/imap.h b/lib/imap.h index f802ed5c0c72..2bab0b4ddea7 100644 --- a/lib/imap.h +++ b/lib/imap.h @@ -27,7 +27,6 @@ #include "pingpong.h" #include "curl_sasl.h" - extern const struct Curl_handler Curl_handler_imap; extern const struct Curl_handler Curl_handler_imaps; @@ -37,6 +36,6 @@ extern const struct Curl_handler Curl_handler_imaps; /* Authentication type values */ #define IMAP_TYPE_NONE 0 -#define IMAP_TYPE_ANY (IMAP_TYPE_CLEARTEXT|IMAP_TYPE_SASL) +#define IMAP_TYPE_ANY (IMAP_TYPE_CLEARTEXT | IMAP_TYPE_SASL) #endif /* HEADER_CURL_IMAP_H */ diff --git a/lib/ldap.c b/lib/ldap.c index 522bf3ad5860..63b2cbc414f6 100644 --- a/lib/ldap.c +++ b/lib/ldap.c @@ -96,7 +96,7 @@ #ifdef USE_WIN32_LDAP #define FREE_ON_WINLDAP(x) curlx_unicodefree(x) -#define curl_ldap_num_t ULONG +#define curl_ldap_num_t ULONG #else #define FREE_ON_WINLDAP(x) #define curl_ldap_num_t int @@ -142,14 +142,15 @@ static void ldap_free_urldesc_low(LDAPURLDesc *ludp); #endif /* !HAVE_LDAP_URL_PARSE */ #ifdef DEBUG_LDAP - #define LDAP_TRACE(x) do { \ - ldap_trace_low("%u: ", __LINE__); \ - ldap_trace_low x; \ - } while(0) +#define LDAP_TRACE(x) \ +do { \ + ldap_trace_low("%u: ", __LINE__); \ + ldap_trace_low x; \ +} while(0) - static void ldap_trace_low(const char *fmt, ...) CURL_PRINTF(1, 2); +static void ldap_trace_low(const char *fmt, ...) CURL_PRINTF(1, 2); #else - #define LDAP_TRACE(x) Curl_nop_stmt +#define LDAP_TRACE(x) Curl_nop_stmt #endif #if defined(USE_WIN32_LDAP) && defined(ldap_err2string) @@ -172,7 +173,6 @@ static CURLcode ldap_do(struct Curl_easy *data, bool *done); /* * LDAP protocol handler. */ - const struct Curl_handler Curl_handler_ldap = { "ldap", /* scheme */ ZERO_NULL, /* setup_connection */ @@ -202,7 +202,6 @@ const struct Curl_handler Curl_handler_ldap = { /* * LDAPS protocol handler. */ - const struct Curl_handler Curl_handler_ldaps = { "ldaps", /* scheme */ ZERO_NULL, /* setup_connection */ @@ -619,7 +618,7 @@ static CURLcode ldap_do(struct Curl_easy *data, bool *done) } if((attr_len > 7) && - curl_strequal(";binary", attr + (attr_len - 7)) ) { + curl_strequal(";binary", attr + (attr_len - 7))) { /* Binary attribute, encode to base64. */ if(vals[i]->bv_len) { result = curlx_base64_encode((uint8_t *)vals[i]->bv_val, @@ -886,8 +885,7 @@ static curl_ldap_num_t ldap_url_parse2_low(struct Curl_easy *data, LDAP_TRACE(("attr[%zu] '%.*s'\n", i, (int)out.len, out.str)); /* Unescape the attribute */ - result = Curl_urldecode(out.str, out.len, &unescaped, NULL, - REJECT_ZERO); + result = Curl_urldecode(out.str, out.len, &unescaped, NULL, REJECT_ZERO); if(result) { rc = LDAP_NO_MEMORY; goto quit; diff --git a/lib/llist.c b/lib/llist.c index ebcda82a04ed..3c70905df250 100644 --- a/lib/llist.c +++ b/lib/llist.c @@ -45,8 +45,7 @@ static struct Curl_llist_node *verifynode(struct Curl_llist_node *n) /* * @unittest: 1300 */ -void -Curl_llist_init(struct Curl_llist *l, Curl_llist_dtor dtor) +void Curl_llist_init(struct Curl_llist *l, Curl_llist_dtor dtor) { l->_size = 0; l->_dtor = dtor; @@ -68,11 +67,10 @@ 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_node *e, /* may be NULL */ - const void *p, - struct Curl_llist_node *ne) +void Curl_llist_insert_next(struct Curl_llist *list, + struct Curl_llist_node *e, /* may be NULL */ + const void *p, + struct Curl_llist_node *ne) { DEBUGASSERT(list); DEBUGASSERT(list->_init == LLISTINIT); @@ -119,9 +117,8 @@ Curl_llist_insert_next(struct Curl_llist *list, * * @unittest: 1300 */ -void -Curl_llist_append(struct Curl_llist *list, const void *p, - struct Curl_llist_node *ne) +void Curl_llist_append(struct Curl_llist *list, const void *p, + struct Curl_llist_node *ne) { DEBUGASSERT(list); DEBUGASSERT(list->_init == LLISTINIT); @@ -177,9 +174,8 @@ void *Curl_node_take_elem(struct Curl_llist_node *e) /* * @unittest: 1300 */ -UNITTEST void Curl_node_uremove(struct Curl_llist_node *, void *); -UNITTEST void -Curl_node_uremove(struct Curl_llist_node *e, void *user) +UNITTEST void Curl_node_uremove(struct Curl_llist_node *e, void *user); +UNITTEST void Curl_node_uremove(struct Curl_llist_node *e, void *user) { struct Curl_llist *list; void *ptr; @@ -200,8 +196,7 @@ void Curl_node_remove(struct Curl_llist_node *e) Curl_node_uremove(e, NULL); } -void -Curl_llist_destroy(struct Curl_llist *list, void *user) +void Curl_llist_destroy(struct Curl_llist *list, void *user) { if(list) { DEBUGASSERT(list->_init == LLISTINIT); diff --git a/lib/llist.h b/lib/llist.h index 0a2bc9a62f47..0a4a68516362 100644 --- a/lib/llist.h +++ b/lib/llist.h @@ -55,8 +55,8 @@ struct Curl_llist_node { void Curl_llist_init(struct Curl_llist *, Curl_llist_dtor); void Curl_llist_insert_next(struct Curl_llist *, struct Curl_llist_node *, const void *, struct Curl_llist_node *node); -void Curl_llist_append(struct Curl_llist *, - const void *, struct Curl_llist_node *node); +void Curl_llist_append(struct Curl_llist *, const void *, + struct Curl_llist_node *node); void Curl_node_remove(struct Curl_llist_node *); void Curl_llist_destroy(struct Curl_llist *, void *); diff --git a/lib/md4.c b/lib/md4.c index 7929e57f65c0..befaeab68bcd 100644 --- a/lib/md4.c +++ b/lib/md4.c @@ -71,14 +71,13 @@ #include #endif - #if defined(USE_WOLFSSL) && !defined(WOLFSSL_NO_MD4) #ifdef OPENSSL_COEXIST - #define MD4_CTX WOLFSSL_MD4_CTX - #define MD4_Init wolfSSL_MD4_Init + #define MD4_CTX WOLFSSL_MD4_CTX + #define MD4_Init wolfSSL_MD4_Init #define MD4_Update wolfSSL_MD4_Update - #define MD4_Final wolfSSL_MD4_Final + #define MD4_Final wolfSSL_MD4_Final #endif #elif defined(USE_OPENSSL) && !defined(OPENSSL_NO_MD4) @@ -129,7 +128,7 @@ static int MD4_Init(MD4_CTX *ctx) static void MD4_Update(MD4_CTX *ctx, const void *data, unsigned long size) { - CryptHashData(ctx->hHash, (const BYTE *)data, (unsigned int) size, 0); + CryptHashData(ctx->hHash, (const BYTE *)data, (unsigned int)size, 0); } static void MD4_Final(unsigned char *result, MD4_CTX *ctx) @@ -224,8 +223,8 @@ static void MD4_Final(unsigned char *result, MD4_CTX *ctx); * The MD4 transformation for all three rounds. */ #define MD4_STEP(f, a, b, c, d, x, s) \ - (a) += f((b), (c), (d)) + (x); \ - (a) = (((a) << (s)) | (((a) & 0xffffffff) >> (32 - (s)))); + (a) += f((b), (c), (d)) + (x); \ + (a) = (((a) << (s)) | (((a) & 0xffffffff) >> (32 - (s)))); /* * SET reads 4 input bytes in little-endian byte order and stores them @@ -236,19 +235,15 @@ static void MD4_Final(unsigned char *result, MD4_CTX *ctx); * does not work. */ #if defined(__i386__) || defined(__x86_64__) || defined(__vax__) -#define MD4_SET(n) \ - (*(const MD4_u32plus *)(const void *)&ptr[(n) * 4]) -#define MD4_GET(n) \ - MD4_SET(n) +#define MD4_SET(n) (*(const MD4_u32plus *)(const void *)&ptr[(n) * 4]) +#define MD4_GET(n) MD4_SET(n) #else -#define MD4_SET(n) \ - (ctx->block[(n)] = \ - (MD4_u32plus)ptr[(n) * 4] | \ - ((MD4_u32plus)ptr[(n) * 4 + 1] << 8) | \ - ((MD4_u32plus)ptr[(n) * 4 + 2] << 16) | \ - ((MD4_u32plus)ptr[(n) * 4 + 3] << 24)) -#define MD4_GET(n) \ - (ctx->block[(n)]) +#define MD4_SET(n) (ctx->block[(n)] = \ + (MD4_u32plus)ptr[(n) * 4] | \ + ((MD4_u32plus)ptr[(n) * 4 + 1] << 8) | \ + ((MD4_u32plus)ptr[(n) * 4 + 2] << 16) | \ + ((MD4_u32plus)ptr[(n) * 4 + 3] << 24)) +#define MD4_GET(n) (ctx->block[(n)]) #endif /* @@ -413,32 +408,32 @@ static void MD4_Final(unsigned char *result, MD4_CTX *ctx) memset(&ctx->buffer[used], 0, available - 8); ctx->lo <<= 3; - ctx->buffer[56] = curlx_ultouc((ctx->lo)&0xff); - ctx->buffer[57] = curlx_ultouc((ctx->lo >> 8)&0xff); - ctx->buffer[58] = curlx_ultouc((ctx->lo >> 16)&0xff); - ctx->buffer[59] = curlx_ultouc((ctx->lo >> 24)&0xff); - ctx->buffer[60] = curlx_ultouc((ctx->hi)&0xff); - ctx->buffer[61] = curlx_ultouc((ctx->hi >> 8)&0xff); - ctx->buffer[62] = curlx_ultouc((ctx->hi >> 16)&0xff); + ctx->buffer[56] = curlx_ultouc((ctx->lo) & 0xff); + ctx->buffer[57] = curlx_ultouc((ctx->lo >> 8) & 0xff); + ctx->buffer[58] = curlx_ultouc((ctx->lo >> 16) & 0xff); + ctx->buffer[59] = curlx_ultouc((ctx->lo >> 24) & 0xff); + ctx->buffer[60] = curlx_ultouc((ctx->hi) & 0xff); + ctx->buffer[61] = curlx_ultouc((ctx->hi >> 8) & 0xff); + ctx->buffer[62] = curlx_ultouc((ctx->hi >> 16) & 0xff); ctx->buffer[63] = curlx_ultouc(ctx->hi >> 24); my_md4_body(ctx, ctx->buffer, 64); - result[0] = curlx_ultouc((ctx->a)&0xff); - result[1] = curlx_ultouc((ctx->a >> 8)&0xff); - result[2] = curlx_ultouc((ctx->a >> 16)&0xff); + result[0] = curlx_ultouc((ctx->a) & 0xff); + result[1] = curlx_ultouc((ctx->a >> 8) & 0xff); + result[2] = curlx_ultouc((ctx->a >> 16) & 0xff); result[3] = curlx_ultouc(ctx->a >> 24); - result[4] = curlx_ultouc((ctx->b)&0xff); - result[5] = curlx_ultouc((ctx->b >> 8)&0xff); - result[6] = curlx_ultouc((ctx->b >> 16)&0xff); + result[4] = curlx_ultouc((ctx->b) & 0xff); + result[5] = curlx_ultouc((ctx->b >> 8) & 0xff); + result[6] = curlx_ultouc((ctx->b >> 16) & 0xff); result[7] = curlx_ultouc(ctx->b >> 24); - result[8] = curlx_ultouc((ctx->c)&0xff); - result[9] = curlx_ultouc((ctx->c >> 8)&0xff); - result[10] = curlx_ultouc((ctx->c >> 16)&0xff); + result[8] = curlx_ultouc((ctx->c) & 0xff); + result[9] = curlx_ultouc((ctx->c >> 8) & 0xff); + result[10] = curlx_ultouc((ctx->c >> 16) & 0xff); result[11] = curlx_ultouc(ctx->c >> 24); - result[12] = curlx_ultouc((ctx->d)&0xff); - result[13] = curlx_ultouc((ctx->d >> 8)&0xff); - result[14] = curlx_ultouc((ctx->d >> 16)&0xff); + result[12] = curlx_ultouc((ctx->d) & 0xff); + result[13] = curlx_ultouc((ctx->d >> 8) & 0xff); + result[14] = curlx_ultouc((ctx->d >> 16) & 0xff); result[15] = curlx_ultouc(ctx->d >> 24); memset(ctx, 0, sizeof(*ctx)); diff --git a/lib/md5.c b/lib/md5.c index a579b02c63ae..e1a443c9236a 100644 --- a/lib/md5.c +++ b/lib/md5.c @@ -314,9 +314,9 @@ static void my_md5_final(unsigned char *result, void *ctx); * The MD5 transformation for all four rounds. */ #define MD5_STEP(f, a, b, c, d, x, t, s) \ - (a) += f((b), (c), (d)) + (x) + (t); \ - (a) = (((a) << (s)) | (((a) & 0xffffffff) >> (32 - (s)))); \ - (a) += (b); + (a) += f((b), (c), (d)) + (x) + (t); \ + (a) = (((a) << (s)) | (((a) & 0xffffffff) >> (32 - (s)))); \ + (a) += (b); /* * SET reads 4 input bytes in little-endian byte order and stores them @@ -327,19 +327,15 @@ static void my_md5_final(unsigned char *result, void *ctx); * does not work. */ #if defined(__i386__) || defined(__x86_64__) || defined(__vax__) -#define MD5_SET(n) \ - (*(const MD5_u32plus *)(const void *)&ptr[(n) * 4]) -#define MD5_GET(n) \ - MD5_SET(n) +#define MD5_SET(n) (*(const MD5_u32plus *)(const void *)&ptr[(n) * 4]) +#define MD5_GET(n) MD5_SET(n) #else -#define MD5_SET(n) \ - (ctx->block[(n)] = \ - (MD5_u32plus)ptr[(n) * 4] | \ - ((MD5_u32plus)ptr[(n) * 4 + 1] << 8) | \ - ((MD5_u32plus)ptr[(n) * 4 + 2] << 16) | \ - ((MD5_u32plus)ptr[(n) * 4 + 3] << 24)) -#define MD5_GET(n) \ - (ctx->block[(n)]) +#define MD5_SET(n) (ctx->block[(n)] = \ + (MD5_u32plus)ptr[(n) * 4] | \ + ((MD5_u32plus)ptr[(n) * 4 + 1] << 8) | \ + ((MD5_u32plus)ptr[(n) * 4 + 2] << 16) | \ + ((MD5_u32plus)ptr[(n) * 4 + 3] << 24)) +#define MD5_GET(n) (ctx->block[(n)]) #endif /* @@ -527,32 +523,32 @@ static void my_md5_final(unsigned char *result, void *in) memset(&ctx->buffer[used], 0, available - 8); ctx->lo <<= 3; - ctx->buffer[56] = curlx_ultouc((ctx->lo)&0xff); - ctx->buffer[57] = curlx_ultouc((ctx->lo >> 8)&0xff); - ctx->buffer[58] = curlx_ultouc((ctx->lo >> 16)&0xff); + ctx->buffer[56] = curlx_ultouc((ctx->lo) & 0xff); + ctx->buffer[57] = curlx_ultouc((ctx->lo >> 8) & 0xff); + ctx->buffer[58] = curlx_ultouc((ctx->lo >> 16) & 0xff); ctx->buffer[59] = curlx_ultouc(ctx->lo >> 24); - ctx->buffer[60] = curlx_ultouc((ctx->hi)&0xff); - ctx->buffer[61] = curlx_ultouc((ctx->hi >> 8)&0xff); - ctx->buffer[62] = curlx_ultouc((ctx->hi >> 16)&0xff); + ctx->buffer[60] = curlx_ultouc((ctx->hi) & 0xff); + ctx->buffer[61] = curlx_ultouc((ctx->hi >> 8) & 0xff); + ctx->buffer[62] = curlx_ultouc((ctx->hi >> 16) & 0xff); ctx->buffer[63] = curlx_ultouc(ctx->hi >> 24); my_md5_body(ctx, ctx->buffer, 64); - result[0] = curlx_ultouc((ctx->a)&0xff); - result[1] = curlx_ultouc((ctx->a >> 8)&0xff); - result[2] = curlx_ultouc((ctx->a >> 16)&0xff); + result[0] = curlx_ultouc((ctx->a) & 0xff); + result[1] = curlx_ultouc((ctx->a >> 8) & 0xff); + result[2] = curlx_ultouc((ctx->a >> 16) & 0xff); result[3] = curlx_ultouc(ctx->a >> 24); - result[4] = curlx_ultouc((ctx->b)&0xff); - result[5] = curlx_ultouc((ctx->b >> 8)&0xff); - result[6] = curlx_ultouc((ctx->b >> 16)&0xff); + result[4] = curlx_ultouc((ctx->b) & 0xff); + result[5] = curlx_ultouc((ctx->b >> 8) & 0xff); + result[6] = curlx_ultouc((ctx->b >> 16) & 0xff); result[7] = curlx_ultouc(ctx->b >> 24); - result[8] = curlx_ultouc((ctx->c)&0xff); - result[9] = curlx_ultouc((ctx->c >> 8)&0xff); - result[10] = curlx_ultouc((ctx->c >> 16)&0xff); + result[8] = curlx_ultouc((ctx->c) & 0xff); + result[9] = curlx_ultouc((ctx->c >> 8) & 0xff); + result[10] = curlx_ultouc((ctx->c >> 16) & 0xff); result[11] = curlx_ultouc(ctx->c >> 24); - result[12] = curlx_ultouc((ctx->d)&0xff); - result[13] = curlx_ultouc((ctx->d >> 8)&0xff); - result[14] = curlx_ultouc((ctx->d >> 16)&0xff); + result[12] = curlx_ultouc((ctx->d) & 0xff); + result[13] = curlx_ultouc((ctx->d >> 8) & 0xff); + result[14] = curlx_ultouc((ctx->d >> 16) & 0xff); result[15] = curlx_ultouc(ctx->d >> 24); memset(ctx, 0, sizeof(*ctx)); diff --git a/lib/memdebug.c b/lib/memdebug.c index 7eae1708b7de..991c9eb921c3 100644 --- a/lib/memdebug.c +++ b/lib/memdebug.c @@ -165,8 +165,7 @@ static bool countcheck(const char *func, int line, const char *source) if(memlimit && source) { if(!memsize) { /* log to file */ - curl_dbg_log("LIMIT %s:%d %s reached memlimit\n", - source, line, func); + curl_dbg_log("LIMIT %s:%d %s reached memlimit\n", source, line, func); /* log to stderr also */ curl_mfprintf(stderr, "LIMIT %s:%d %s reached memlimit\n", source, line, func); @@ -336,8 +335,8 @@ void curl_dbg_free(void *ptr, int line, const char *source) if(ptr) { struct memdebug *mem; - if(source) - curl_dbg_log("MEM %s:%d free(%p)\n", source, line, (void *)ptr); + if(source) + curl_dbg_log("MEM %s:%d free(%p)\n", source, line, (void *)ptr); #ifdef __INTEL_COMPILER # pragma warning(push) @@ -386,7 +385,7 @@ SEND_TYPE_RETV curl_dbg_send(SEND_TYPE_ARG1 sockfd, rc = send(sockfd, buf, len, flags); if(source) curl_dbg_log("SEND %s:%d send(%lu) = %ld\n", - source, line, (unsigned long)len, (long)rc); + source, line, (unsigned long)len, (long)rc); return rc; } @@ -401,7 +400,7 @@ RECV_TYPE_RETV curl_dbg_recv(RECV_TYPE_ARG1 sockfd, RECV_TYPE_ARG2 buf, rc = recv(sockfd, buf, len, flags); if(source) curl_dbg_log("RECV %s:%d recv(%lu) = %ld\n", - source, line, (unsigned long)len, (long)rc); + source, line, (unsigned long)len, (long)rc); return rc; } @@ -515,8 +514,7 @@ int curl_dbg_fclose(FILE *file, int line, const char *source) DEBUGASSERT(file != NULL); if(source) - curl_dbg_log("FILE %s:%d fclose(%p)\n", - source, line, (void *)file); + curl_dbg_log("FILE %s:%d fclose(%p)\n", source, line, (void *)file); /* !checksrc! disable BANNEDFUNC 1 */ res = fclose(file); diff --git a/lib/mime.c b/lib/mime.c index 7ebe47315de9..92edd78878c8 100644 --- a/lib/mime.c +++ b/lib/mime.c @@ -56,8 +56,8 @@ struct Curl_easy; # endif #endif -#define READ_ERROR ((size_t) -1) -#define STOP_FILLING ((size_t) -2) +#define READ_ERROR ((size_t)-1) +#define STOP_FILLING ((size_t)-2) static size_t mime_subparts_read(char *buffer, size_t size, size_t nitems, void *instream, bool *hasread); @@ -77,12 +77,12 @@ static curl_off_t encoder_qp_size(curl_mimepart *part); static curl_off_t mime_size(curl_mimepart *part); 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}, - {"base64", encoder_base64_read, encoder_base64_size}, - {"quoted-printable", encoder_qp_read, encoder_qp_size}, - {ZERO_NULL, ZERO_NULL, ZERO_NULL} + { "binary", encoder_nop_read, encoder_nop_size }, + { "8bit", encoder_nop_read, encoder_nop_size }, + { "7bit", encoder_7bit_read, encoder_nop_size }, + { "base64", encoder_base64_read, encoder_base64_size }, + { "quoted-printable", encoder_qp_read, encoder_qp_size }, + { ZERO_NULL, ZERO_NULL, ZERO_NULL } }; /* Quoted-printable character class table. @@ -120,15 +120,13 @@ static const unsigned char qp_class[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /* F0 - FF */ }; - /* Binary --> hexadecimal ASCII table. */ static const char aschex[] = "\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x41\x42\x43\x44\x45\x46"; - #ifndef __VMS #define filesize(name, stat_data) (stat_data.st_size) -#define fopen_read curlx_fopen +#define fopen_read curlx_fopen #else @@ -143,13 +141,12 @@ static const char aschex[] = * and CD/DVD images should be either a STREAM_LF format or a fixed format. * */ -curl_off_t VmsRealFileSize(const char *name, - const struct_stat *stat_buf) +curl_off_t VmsRealFileSize(const char *name, const struct_stat *stat_buf) { char buffer[8192]; curl_off_t count; int ret_stat; - FILE * file; + FILE *file; file = curlx_fopen(name, FOPEN_READTEXT); /* VMS */ if(!file) @@ -173,8 +170,7 @@ curl_off_t VmsRealFileSize(const char *name, * if not to call a routine to get the correct size. * */ -static curl_off_t VmsSpecialSize(const char *name, - const struct_stat *stat_buf) +static curl_off_t VmsSpecialSize(const char *name, const struct_stat *stat_buf) { switch(stat_buf->st_fab_rfm) { case FAB$C_VAR: @@ -196,7 +192,7 @@ static curl_off_t VmsSpecialSize(const char *name, * record format of the file. * */ -static FILE * vmsfopenread(const char *file, const char *mode) +static FILE *vmsfopenread(const char *file, const char *mode) { struct_stat statbuf; int result; @@ -217,7 +213,6 @@ static FILE * vmsfopenread(const char *file, const char *mode) #define fopen_read vmsfopenread #endif - #ifndef HAVE_BASENAME /* (Quote from The Open Group Base Specifications Issue 6 IEEE Std 1003.1, 2004 @@ -264,7 +259,7 @@ static char *Curl_basename(char *path) return path; } -#define basename(x) Curl_basename((x)) +#define basename(x) Curl_basename(x) #endif @@ -372,7 +367,6 @@ static void cleanup_encoder_state(struct mime_encoder_state *p) p->bufend = 0; } - /* 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) @@ -400,7 +394,6 @@ static curl_off_t encoder_nop_size(curl_mimepart *part) return part->datasize; } - /* 7bit encoder: the encoder is just a data validity check. */ static size_t encoder_7bit_read(char *buffer, size_t size, bool ateof, curl_mimepart *part) @@ -426,7 +419,6 @@ static size_t encoder_7bit_read(char *buffer, size_t size, bool ateof, return cursize; } - /* Base64 content encoder. */ static size_t encoder_base64_read(char *buffer, size_t size, bool ateof, curl_mimepart *part) @@ -521,7 +513,6 @@ static curl_off_t encoder_base64_size(curl_mimepart *part) return size + 2 * ((size - 1) / MAX_ENCODED_LINE_LENGTH); } - /* Quoted-printable lookahead. * * Check if a CRLF or end of data is in input buffer at current position + n. @@ -558,7 +549,7 @@ static size_t encoder_qp_read(char *buffer, size_t size, bool ateof, size_t len = 1; size_t consumed = 1; int i = st->buf[st->bufbeg]; - buf[0] = (char) i; + buf[0] = (char)i; buf[1] = aschex[(i >> 4) & 0xF]; buf[2] = aschex[i & 0xF]; @@ -649,13 +640,12 @@ static curl_off_t encoder_qp_size(curl_mimepart *part) return part->datasize ? -1 : 0; } - /* In-memory data callbacks. */ /* Argument is a pointer to the mime part. */ static size_t mime_mem_read(char *buffer, size_t size, size_t nitems, void *instream) { - curl_mimepart *part = (curl_mimepart *) instream; + curl_mimepart *part = (curl_mimepart *)instream; size_t sz = curlx_sotouz(part->datasize - part->state.offset); (void)size; /* Always 1 */ @@ -673,7 +663,7 @@ static size_t mime_mem_read(char *buffer, size_t size, size_t nitems, static int mime_mem_seek(void *instream, curl_off_t offset, int whence) { - curl_mimepart *part = (curl_mimepart *) instream; + curl_mimepart *part = (curl_mimepart *)instream; switch(whence) { case SEEK_CUR: @@ -693,10 +683,9 @@ static int mime_mem_seek(void *instream, curl_off_t offset, int whence) static void mime_mem_free(void *ptr) { - Curl_safefree(((curl_mimepart *) ptr)->data); + Curl_safefree(((curl_mimepart *)ptr)->data); } - /* Named file callbacks. */ /* Argument is a pointer to the mime part. */ static bool mime_open_file(curl_mimepart *part) @@ -712,7 +701,7 @@ static bool mime_open_file(curl_mimepart *part) static size_t mime_file_read(char *buffer, size_t size, size_t nitems, void *instream) { - curl_mimepart *part = (curl_mimepart *) instream; + curl_mimepart *part = (curl_mimepart *)instream; if(!nitems) return STOP_FILLING; @@ -725,7 +714,7 @@ static size_t mime_file_read(char *buffer, size_t size, size_t nitems, static int mime_file_seek(void *instream, curl_off_t offset, int whence) { - curl_mimepart *part = (curl_mimepart *) instream; + curl_mimepart *part = (curl_mimepart *)instream; if(whence == SEEK_SET && !offset && !part->fp) return CURL_SEEKFUNC_OK; /* Not open: implicitly already at BOF. */ @@ -739,7 +728,7 @@ static int mime_file_seek(void *instream, curl_off_t offset, int whence) static void mime_file_free(void *ptr) { - curl_mimepart *part = (curl_mimepart *) ptr; + curl_mimepart *part = (curl_mimepart *)ptr; if(part->fp) { curlx_fclose(part->fp); @@ -748,7 +737,6 @@ static void mime_file_free(void *ptr) Curl_safefree(part->data); } - /* Subparts callbacks. */ /* Argument is a pointer to the mime structure. */ @@ -798,7 +786,7 @@ static size_t read_part_content(curl_mimepart *part, } /* If we can determine we are at end of part data, spare a read. */ - if(part->datasize != (curl_off_t) -1 && + if(part->datasize != (curl_off_t)-1 && part->state.offset >= part->datasize) { /* sz is already zero. */ } @@ -809,8 +797,8 @@ static size_t read_part_content(curl_mimepart *part, * 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; + sz = mime_subparts_read(buffer, 1, bufsize, part->arg, hasread); + break; case MIMEKIND_FILE: if(part->fp && feof(part->fp)) break; /* At EOF. */ @@ -916,7 +904,7 @@ static size_t readback_part(curl_mimepart *part, while(bufsize) { size_t sz = 0; - struct curl_slist *hdr = (struct curl_slist *) part->state.ptr; + struct curl_slist *hdr = (struct curl_slist *)part->state.ptr; switch(part->state.state) { case MIMESTATE_BEGIN: mimesetstate(&part->state, @@ -994,7 +982,7 @@ static size_t readback_part(curl_mimepart *part, static size_t mime_subparts_read(char *buffer, size_t size, size_t nitems, void *instream, bool *hasread) { - curl_mime *mime = (curl_mime *) instream; + curl_mime *mime = (curl_mime *)instream; size_t cursize = 0; (void)size; /* Always 1 */ @@ -1070,7 +1058,7 @@ static int mime_part_rewind(curl_mimepart *part) if(part->state.state > targetstate) { res = CURL_SEEKFUNC_CANTSEEK; if(part->seekfunc) { - res = part->seekfunc(part->arg, (curl_off_t) 0, SEEK_SET); + res = part->seekfunc(part->arg, (curl_off_t)0, SEEK_SET); switch(res) { case CURL_SEEKFUNC_OK: case CURL_SEEKFUNC_FAIL: @@ -1095,7 +1083,7 @@ static int mime_part_rewind(curl_mimepart *part) static int mime_subparts_seek(void *instream, curl_off_t offset, int whence) { - curl_mime *mime = (curl_mime *) instream; + curl_mime *mime = (curl_mime *)instream; curl_mimepart *part; int result = CURL_SEEKFUNC_OK; @@ -1126,10 +1114,10 @@ static void cleanup_part_content(curl_mimepart *part) part->readfunc = NULL; part->seekfunc = NULL; part->freefunc = NULL; - part->arg = (void *) part; /* Defaults to part itself. */ + part->arg = (void *)part; /* Defaults to part itself. */ part->data = NULL; part->fp = NULL; - part->datasize = (curl_off_t) 0; /* No size yet. */ + part->datasize = (curl_off_t)0; /* No size yet. */ cleanup_encoder_state(&part->encstate); part->kind = MIMEKIND_NONE; part->flags &= ~(unsigned int)MIME_FAST_READ; @@ -1139,7 +1127,7 @@ static void cleanup_part_content(curl_mimepart *part) static void mime_subparts_free(void *ptr) { - curl_mime *mime = (curl_mime *) ptr; + curl_mime *mime = (curl_mime *)ptr; if(mime && mime->parent) { mime->parent->freefunc = NULL; /* Be sure we will not be called again. */ @@ -1151,7 +1139,7 @@ static void mime_subparts_free(void *ptr) /* Do not free subparts: unbind them. This is used for the top level only. */ static void mime_subparts_unbind(void *ptr) { - curl_mime *mime = (curl_mime *) ptr; + curl_mime *mime = (curl_mime *)ptr; if(mime && mime->parent) { mime->parent->freefunc = NULL; /* Be sure we will not be called again. */ @@ -1160,7 +1148,6 @@ static void mime_subparts_unbind(void *ptr) } } - void Curl_mime_cleanpart(curl_mimepart *part) { if(part) { @@ -1207,7 +1194,7 @@ CURLcode Curl_mime_duppart(struct Curl_easy *data, case MIMEKIND_NONE: break; case MIMEKIND_DATA: - res = curl_mime_data(dst, src->data, (size_t) src->datasize); + res = curl_mime_data(dst, src->data, (size_t)src->datasize); break; case MIMEKIND_FILE: res = curl_mime_filedata(dst, src->data); @@ -1226,7 +1213,7 @@ CURLcode Curl_mime_duppart(struct Curl_easy *data, res = mime ? curl_mime_subparts(dst, mime) : CURLE_OUT_OF_MEMORY; /* Duplicate subparts. */ - for(s = ((curl_mime *) src->arg)->firstpart; !res && s; s = s->nextpart) { + for(s = ((curl_mime *)src->arg)->firstpart; !res && s; s = s->nextpart) { d = curl_mime_addpart(mime); res = d ? Curl_mime_duppart(data, d, s) : CURLE_OUT_OF_MEMORY; } @@ -1287,7 +1274,7 @@ curl_mime *curl_mime_init(void *easy) memset(mime->boundary, '-', MIME_BOUNDARY_DASHES); if(Curl_rand_alnum(easy, - (unsigned char *) &mime->boundary[MIME_BOUNDARY_DASHES], + (unsigned char *)&mime->boundary[MIME_BOUNDARY_DASHES], MIME_RAND_BOUNDARY_CHARS + 1)) { /* failed to get random separator, bail out */ curlx_free(mime); @@ -1302,7 +1289,7 @@ curl_mime *curl_mime_init(void *easy) /* Initialize a mime part. */ void Curl_mime_initpart(curl_mimepart *part) { - memset((char *) part, 0, sizeof(*part)); + memset((char *)part, 0, sizeof(*part)); part->lastreadstatus = 1; /* Successful read status. */ mimesetstate(&part->state, MIMESTATE_BEGIN, NULL); } @@ -1367,8 +1354,7 @@ CURLcode curl_mime_filename(curl_mimepart *part, const char *filename) } /* Set mime part content from memory data. */ -CURLcode curl_mime_data(curl_mimepart *part, - const char *ptr, size_t datasize) +CURLcode curl_mime_data(curl_mimepart *part, const char *ptr, size_t datasize) { if(!part) return CURLE_BAD_FUNCTION_ARGUMENT; @@ -1558,7 +1544,7 @@ CURLcode Curl_mime_set_subparts(curl_mimepart *part, they might not be positioned at start. Rewind them now, as a future check while rewinding the parent may cause this content to be skipped. */ - if(mime_subparts_seek(subparts, (curl_off_t) 0, SEEK_SET) != + if(mime_subparts_seek(subparts, (curl_off_t)0, SEEK_SET) != CURL_SEEKFUNC_OK) return CURLE_SEND_FAIL_REWIND; @@ -1580,12 +1566,11 @@ CURLcode curl_mime_subparts(curl_mimepart *part, curl_mime *subparts) return Curl_mime_set_subparts(part, subparts, TRUE); } - /* Readback from top mime. */ /* Argument is the dummy top part. */ size_t Curl_mime_read(char *buffer, size_t size, size_t nitems, void *instream) { - curl_mimepart *part = (curl_mimepart *) instream; + curl_mimepart *part = (curl_mimepart *)instream; size_t ret; bool hasread; @@ -1668,8 +1653,7 @@ static curl_off_t mime_size(curl_mimepart *part) if(size >= 0 && !(part->flags & MIME_BODY_ONLY)) { /* Compute total part size. */ size += slist_size(part->curlheaders, 2, NULL, 0); - size += slist_size(part->userheaders, 2, - STRCONST("Content-Type")); + size += slist_size(part->userheaders, 2, STRCONST("Content-Type")); size += 2; /* CRLF after headers. */ } return size; @@ -1718,16 +1702,16 @@ const char *Curl_mime_contenttype(const char *filename) const char *type; }; static const struct ContentType ctts[] = { - {".gif", "image/gif"}, - {".jpg", "image/jpeg"}, - {".jpeg", "image/jpeg"}, - {".png", "image/png"}, - {".svg", "image/svg+xml"}, - {".txt", "text/plain"}, - {".htm", "text/html"}, - {".html", "text/html"}, - {".pdf", "application/pdf"}, - {".xml", "application/xml"} + { ".gif", "image/gif" }, + { ".jpg", "image/jpeg" }, + { ".jpeg", "image/jpeg" }, + { ".png", "image/png" }, + { ".svg", "image/svg+xml" }, + { ".txt", "text/plain" }, + { ".htm", "text/html" }, + { ".html", "text/html" }, + { ".pdf", "application/pdf" }, + { ".xml", "application/xml" } }; if(filename) { @@ -1808,7 +1792,7 @@ CURLcode Curl_mime_prepare_headers(struct Curl_easy *data, } if(part->kind == MIMEKIND_MULTIPART) { - mime = (curl_mime *) part->arg; + mime = (curl_mime *)part->arg; if(mime) boundary = mime->boundary; } @@ -1821,10 +1805,10 @@ CURLcode Curl_mime_prepare_headers(struct Curl_easy *data, if(!search_header(part->userheaders, STRCONST("Content-Disposition"))) { if(!disposition) if(part->filename || part->name || - (contenttype && !curl_strnequal(contenttype, "multipart/", 10))) - disposition = DISPOSITION_DEFAULT; + (contenttype && !curl_strnequal(contenttype, "multipart/", 10))) + disposition = DISPOSITION_DEFAULT; if(disposition && curl_strequal(disposition, "attachment") && - !part->name && !part->filename) + !part->name && !part->filename) disposition = NULL; if(disposition) { char *name = NULL; @@ -1854,8 +1838,8 @@ CURLcode Curl_mime_prepare_headers(struct Curl_easy *data, Curl_safefree(filename); if(ret) return ret; - } } + } /* Issue Content-Type header. */ if(contenttype) { @@ -1870,7 +1854,7 @@ CURLcode Curl_mime_prepare_headers(struct Curl_easy *data, if(part->encoder) cte = part->encoder->name; else if(contenttype && strategy == MIMESTRATEGY_MAIL && - part->kind != MIMEKIND_MULTIPART) + part->kind != MIMEKIND_MULTIPART) cte = "8bit"; if(cte) { ret = Curl_mime_add_header(&part->curlheaders, @@ -1909,7 +1893,7 @@ static void mime_unpause(curl_mimepart *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; + curl_mime *mime = (curl_mime *)part->arg; if(mime) { curl_mimepart *subpart; @@ -2113,7 +2097,7 @@ static CURLcode cr_mime_resume_from(struct Curl_easy *data, curl_off_t passed = 0; do { - char scratch[4*1024]; + char scratch[4 * 1024]; size_t readthisamountnow = (offset - passed > (curl_off_t)sizeof(scratch)) ? sizeof(scratch) : @@ -2262,8 +2246,7 @@ CURLcode curl_mime_encoder(curl_mimepart *part, const char *encoding) return CURLE_NOT_BUILT_IN; } -CURLcode curl_mime_data(curl_mimepart *part, - const char *data, size_t datasize) +CURLcode curl_mime_data(curl_mimepart *part, const char *data, size_t datasize) { (void)part; (void)data; @@ -2278,8 +2261,7 @@ CURLcode curl_mime_filedata(curl_mimepart *part, const char *filename) return CURLE_NOT_BUILT_IN; } -CURLcode curl_mime_data_cb(curl_mimepart *part, - curl_off_t datasize, +CURLcode curl_mime_data_cb(curl_mimepart *part, curl_off_t datasize, curl_read_callback readfunc, curl_seek_callback seekfunc, curl_free_callback freefunc, diff --git a/lib/mime.h b/lib/mime.h index 5073a38f709a..3ac196180bff 100644 --- a/lib/mime.h +++ b/lib/mime.h @@ -165,12 +165,11 @@ CURLcode Curl_creader_set_mime(struct Curl_easy *data, curl_mimepart *part); /* if disabled */ #define Curl_mime_initpart(x) #define Curl_mime_cleanpart(x) -#define Curl_mime_duppart(x,y,z) CURLE_OK /* Nothing to duplicate. Succeed */ -#define Curl_mime_set_subparts(a,b,c) CURLE_NOT_BUILT_IN -#define Curl_mime_prepare_headers(a,b,c,d,e) CURLE_NOT_BUILT_IN -#define Curl_mime_read NULL -#define Curl_creader_set_mime(x,y) ((void)x, CURLE_NOT_BUILT_IN) +#define Curl_mime_duppart(x, y, z) CURLE_OK /* Nothing to duplicate. Succeed */ +#define Curl_mime_set_subparts(a, b, c) CURLE_NOT_BUILT_IN +#define Curl_mime_prepare_headers(a, b, c, d, e) CURLE_NOT_BUILT_IN +#define Curl_mime_read NULL +#define Curl_creader_set_mime(x, y) ((void)x, CURLE_NOT_BUILT_IN) #endif - #endif /* HEADER_CURL_MIME_H */ diff --git a/lib/mprintf.c b/lib/mprintf.c index 046917aeb5f0..5c58e907b4b5 100644 --- a/lib/mprintf.c +++ b/lib/mprintf.c @@ -171,8 +171,8 @@ static int dollarstring(const char *p, const char **end) return (int)num - 1; } -#define is_arg_used(x,y) ((x)[(y)/8] & (1 << ((y)&7))) -#define mark_arg_used(x,y) ((x)[y/8] |= (unsigned char)(1 << ((y)&7))) +#define is_arg_used(x, y) ((x)[(y) / 8] & (1 << ((y) & 7))) +#define mark_arg_used(x, y) ((x)[y / 8] |= (unsigned char)(1 << ((y) & 7))) /* * Parse the format string. @@ -206,7 +206,7 @@ static int parsefmt(const char *format, int max_param = -1; int i; int ocount = 0; - unsigned char usedinput[MAX_PARAMETERS/8]; + unsigned char usedinput[MAX_PARAMETERS / 8]; size_t outlen = 0; struct outsegment *optr; int use_dollar = DOLLAR_UNKNOWN; @@ -364,8 +364,15 @@ static int parsefmt(const char *format, if(!(flags & FLAGS_LEFT)) flags |= FLAGS_PAD_NIL; FALLTHROUGH(); - case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': { + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': { curl_off_t num; flags |= FLAGS_WIDTH; fmt--; @@ -431,7 +438,7 @@ static int parsefmt(const char *format, type = FORMAT_LONGU; else type = FORMAT_INTU; - flags |= FLAGS_OCTAL|FLAGS_UNSIGNED; + flags |= FLAGS_OCTAL | FLAGS_UNSIGNED; break; case 'x': if(flags & FLAGS_LONGLONG) @@ -440,7 +447,7 @@ static int parsefmt(const char *format, type = FORMAT_LONGU; else type = FORMAT_INTU; - flags |= FLAGS_HEX|FLAGS_UNSIGNED; + flags |= FLAGS_HEX | FLAGS_UNSIGNED; break; case 'X': if(flags & FLAGS_LONGLONG) @@ -449,7 +456,7 @@ static int parsefmt(const char *format, type = FORMAT_LONGU; else type = FORMAT_INTU; - flags |= FLAGS_HEX|FLAGS_UPPER|FLAGS_UNSIGNED; + flags |= FLAGS_HEX | FLAGS_UPPER | FLAGS_UNSIGNED; break; case 'c': type = FORMAT_INT; @@ -464,7 +471,7 @@ static int parsefmt(const char *format, break; case 'E': type = FORMAT_DOUBLE; - flags |= FLAGS_FLOATE|FLAGS_UPPER; + flags |= FLAGS_FLOATE | FLAGS_UPPER; break; case 'g': type = FORMAT_DOUBLE; @@ -472,7 +479,7 @@ static int parsefmt(const char *format, break; case 'G': type = FORMAT_DOUBLE; - flags |= FLAGS_FLOATG|FLAGS_UPPER; + flags |= FLAGS_FLOATG | FLAGS_UPPER; break; default: /* invalid instruction, disregard and continue */ @@ -627,9 +634,9 @@ static bool out_double(void *userp, double dnum, char *work, int *donep) { - char formatbuf[32]="%"; + char formatbuf[32] = "%"; char *fptr = &formatbuf[1]; - size_t left = sizeof(formatbuf)-strlen(formatbuf); + size_t left = sizeof(formatbuf) - strlen(formatbuf); int flags = p->flags; int width = p->width; int prec = p->prec; @@ -745,7 +752,7 @@ static bool out_number(void *userp, if(!(flags & FLAGS_LEFT)) while(--width > 0) OUTCHAR(' '); - OUTCHAR((char) num); + OUTCHAR((char)num); if(flags & FLAGS_LEFT) while(--width > 0) OUTCHAR(' '); @@ -868,7 +875,7 @@ static bool out_string(void *userp, if(!str) { /* Write null string if there is space. */ - if(prec == -1 || prec >= (int) sizeof(nilstr) - 1) { + if(prec == -1 || prec >= (int)sizeof(nilstr) - 1) { str = nilstr; len = sizeof(nilstr) - 1; /* Disable quotes around (nil) */ @@ -916,10 +923,10 @@ static bool out_pointer(void *userp, { /* Generic pointer. */ if(ptr) { - size_t num = (size_t) ptr; + size_t num = (size_t)ptr; /* If the pointer is not NULL, write it as a %#x spec. */ - p->flags |= FLAGS_HEX|FLAGS_ALT; + p->flags |= FLAGS_HEX | FLAGS_ALT; if(out_number(userp, stream, p, num, 0, work, donep)) return TRUE; } @@ -958,13 +965,12 @@ static bool out_pointer(void *userp, * All output is sent to the 'stream()' callback, one byte at a time. */ -static int formatf( - void *userp, /* untouched by format(), just sent to the stream() function in - the second argument */ - /* function pointer called for each output character */ - int (*stream)(unsigned char, void *), - const char *format, /* %-formatted string */ - va_list ap_save) /* list of parameters */ +static int formatf(void *userp, /* untouched by format(), just sent to the + stream() function in the second argument */ + /* function pointer called for each output character */ + int (*stream)(unsigned char, void *), + const char *format, /* %-formatted string */ + va_list ap_save) /* list of parameters */ { int done = 0; /* number of characters written */ int i; @@ -1065,15 +1071,15 @@ static int formatf( /* Answer the count of characters written. */ #ifdef HAVE_LONG_LONG_TYPE if(p.flags & FLAGS_LONGLONG) - *(LONG_LONG_TYPE *) iptr->val.ptr = (LONG_LONG_TYPE)done; + *(LONG_LONG_TYPE *)iptr->val.ptr = (LONG_LONG_TYPE)done; else #endif if(p.flags & FLAGS_LONG) - *(long *) iptr->val.ptr = (long)done; + *(long *)iptr->val.ptr = (long)done; else if(!(p.flags & FLAGS_SHORT)) - *(int *) iptr->val.ptr = (int)done; + *(int *)iptr->val.ptr = (int)done; else - *(short *) iptr->val.ptr = (short)done; + *(short *)iptr->val.ptr = (short)done; break; default: @@ -1138,7 +1144,7 @@ static int alloc_addbyter(unsigned char outc, void *f) CURLcode result = curlx_dyn_addn(infop->b, &outc, 1); if(result) { infop->merr = result == CURLE_TOO_LARGE ? MERR_TOO_LARGE : MERR_MEM; - return 1 ; /* fail */ + return 1; /* fail */ } return 0; } diff --git a/lib/mqtt.c b/lib/mqtt.c index a8975d53919b..df5f37775f4f 100644 --- a/lib/mqtt.c +++ b/lib/mqtt.c @@ -51,8 +51,8 @@ /* #define MQTT_MSG_PINGREQ 0xC0 */ #define MQTT_MSG_PINGRESP 0xD0 -#define MQTT_CONNACK_LEN 2 -#define MQTT_SUBACK_LEN 3 +#define MQTT_CONNACK_LEN 2 +#define MQTT_SUBACK_LEN 3 #define MQTT_CLIENTID_LEN 12 /* "curl0123abcd" */ /* meta key for storing protocol meta at easy handle */ @@ -92,7 +92,6 @@ struct MQTT { BIT(pingsent); /* 1 while we wait for ping response */ }; - /* * Forward declarations. */ @@ -315,7 +314,7 @@ static CURLcode mqtt_connect(struct Curl_easy *data) int rc = 0; /* remain length */ int remain_pos = 0; - char remain[4] = {0}; + char remain[4] = { 0 }; size_t packetlen = 0; size_t start_user = 0; size_t start_pwd = 0; @@ -324,12 +323,10 @@ static CURLcode mqtt_connect(struct Curl_easy *data) char *packet = NULL; /* extracting username from request */ - const char *username = data->state.aptr.user ? - data->state.aptr.user : ""; + const char *username = data->state.aptr.user ? data->state.aptr.user : ""; const size_t ulen = strlen(username); /* extracting password from request */ - const char *passwd = data->state.aptr.passwd ? - data->state.aptr.passwd : ""; + const char *passwd = data->state.aptr.passwd ? data->state.aptr.passwd : ""; const size_t plen = strlen(passwd); const size_t payloadlen = ulen + plen + MQTT_CLIENTID_LEN + 2 + /* The plus 2s below are for the MSB and LSB describing the length of the @@ -531,7 +528,7 @@ static CURLcode mqtt_subscribe(struct Curl_easy *data) packet[1 + n] = (mqtt->packetid >> 8) & 0xff; packet[2 + n] = mqtt->packetid & 0xff; packet[3 + n] = (topiclen >> 8) & 0xff; - packet[4 + n ] = topiclen & 0xff; + packet[4 + n] = topiclen & 0xff; memcpy(&packet[5 + n], topic, topiclen); packet[5 + n + topiclen] = 0; /* QoS zero */ @@ -661,7 +658,7 @@ static size_t mqtt_decode_len(unsigned char *buf, } #ifdef DEBUGBUILD -static const char *statenames[]={ +static const char *statenames[] = { "MQTT_FIRST", "MQTT_REMAINING_LENGTH", "MQTT_CONNACK", @@ -695,7 +692,6 @@ static void mqstate(struct Curl_easy *data, mqtt->nextstate = nextstate; } - static CURLcode mqtt_read_publish(struct Curl_easy *data, bool *done) { CURLcode result = CURLE_OK; @@ -756,7 +752,7 @@ static CURLcode mqtt_read_publish(struct Curl_easy *data, bool *done) FALLTHROUGH(); case MQTT_PUB_REMAIN: { /* read rest of packet, but no more. Cap to buffer size */ - char buffer[4*1024]; + char buffer[4 * 1024]; size_t rest = mq->npacket; if(rest > sizeof(buffer)) rest = sizeof(buffer); @@ -886,7 +882,7 @@ static CURLcode mqtt_doing(struct Curl_easy *data, bool *done) if(result) return result; - infof(data, "mqtt_doing: state [%d]", (int) mqtt->state); + infof(data, "mqtt_doing: state [%d]", (int)mqtt->state); switch(mqtt->state) { case MQTT_FIRST: /* Read the initial byte only */ diff --git a/lib/multi.c b/lib/multi.c index c5b78f53e446..b912f7a212f2 100644 --- a/lib/multi.c +++ b/lib/multi.c @@ -55,7 +55,7 @@ #include "urlapi-int.h" /* initial multi->xfers table size for a full multi */ -#define CURL_XFER_TABLE_SIZE 512 +#define CURL_XFER_TABLE_SIZE 512 /* CURL_SOCKET_HASH_TABLE_SIZE should be a prime number. Increasing it from 97 @@ -195,12 +195,11 @@ static void mstate(struct Curl_easy *data, CURLMstate state } #ifndef DEBUGBUILD -#define multistate(x,y) mstate(x,y) +#define multistate(x, y) mstate(x, y) #else -#define multistate(x,y) mstate(x,y, __LINE__) +#define multistate(x, y) mstate(x, y, __LINE__) #endif - /* multi->proto_hash destructor. Should never be called as elements * MUST be added with their own destructor */ static void ph_freeentry(void *p) @@ -343,15 +342,14 @@ static void multi_warn_debug(struct Curl_multi *multi, struct Curl_easy *data) if(!multi->warned) { infof(data, "!!! WARNING !!!"); infof(data, "This is a debug build of libcurl, " - "do not use in production."); + "do not use in production."); multi->warned = TRUE; } } #else -#define multi_warn_debug(x,y) Curl_nop_stmt +#define multi_warn_debug(x, y) Curl_nop_stmt #endif - static CURLMcode multi_xfers_add(struct Curl_multi *multi, struct Curl_easy *data) { @@ -380,8 +378,8 @@ static CURLMcode multi_xfers_add(struct Curl_multi *multi, new_size = max_capacity; /* can not be larger than this */ } else { - /* make it a 64 multiple, since our bitsets frow by that and - * small (easy_multi) grows to at least 64 on first resize. */ + /* make it a 64 multiple, since our bitsets frow by that and + * small (easy_multi) grows to at least 64 on first resize. */ new_size = (((used + min_unused) + 63) / 64) * 64; } } @@ -564,7 +562,7 @@ static bool multi_conn_should_close(struct connectdata *conn, && !(conn->http_negotiate_state == GSS_AUTHRECV || conn->proxy_negotiate_state == GSS_AUTHRECV) #endif - ) + ) return TRUE; /* Unless this connection is for a "connect-only" transfer, it @@ -842,7 +840,7 @@ CURLMcode curl_multi_remove_handle(CURLM *m, CURL *d) if(data->state.lastconnect_id != -1) { /* Mark any connect-only connection for closure */ Curl_cpool_do_by_id(data, data->state.lastconnect_id, - close_connect_only, NULL); + close_connect_only, NULL); } #ifdef USE_LIBPSL @@ -1076,14 +1074,12 @@ static CURLcode mstate_perform_pollset(struct Curl_easy *data, else { /* Default is to obey the data->req.keepon flags for send/recv */ if(CURL_WANT_RECV(data) && CONN_SOCK_IDX_VALID(conn->recv_idx)) { - result = Curl_pollset_add_in( - data, ps, conn->sock[conn->recv_idx]); + result = Curl_pollset_add_in(data, ps, conn->sock[conn->recv_idx]); } if(!result && Curl_req_want_send(data) && CONN_SOCK_IDX_VALID(conn->send_idx)) { - result = Curl_pollset_add_out( - data, ps, conn->sock[conn->send_idx]); + result = Curl_pollset_add_out(data, ps, conn->sock[conn->send_idx]); } } if(!result) @@ -1174,34 +1170,33 @@ CURLMcode Curl_multi_pollset(struct Curl_easy *data, if(CURL_TRC_M_is_verbose(data)) { size_t timeout_count = Curl_llist_count(&data->state.timeoutlist); switch(ps->n) { - case 0: - CURL_TRC_M(data, "pollset[], timeouts=%zu, paused %d/%d (r/w)", - timeout_count, - Curl_xfer_send_is_paused(data), - Curl_xfer_recv_is_paused(data)); - break; - case 1: - CURL_TRC_M(data, "pollset[fd=%" FMT_SOCKET_T " %s%s], timeouts=%zu", - ps->sockets[0], - (ps->actions[0] & CURL_POLL_IN) ? "IN" : "", - (ps->actions[0] & CURL_POLL_OUT) ? "OUT" : "", - timeout_count); - break; - case 2: - CURL_TRC_M(data, "pollset[fd=%" FMT_SOCKET_T " %s%s, " - "fd=%" FMT_SOCKET_T " %s%s], timeouts=%zu", - ps->sockets[0], - (ps->actions[0] & CURL_POLL_IN) ? "IN" : "", - (ps->actions[0] & CURL_POLL_OUT) ? "OUT" : "", - ps->sockets[1], - (ps->actions[1] & CURL_POLL_IN) ? "IN" : "", - (ps->actions[1] & CURL_POLL_OUT) ? "OUT" : "", - timeout_count); - break; - default: - CURL_TRC_M(data, "pollset[fds=%u], timeouts=%zu", - ps->n, timeout_count); - break; + case 0: + CURL_TRC_M(data, "pollset[], timeouts=%zu, paused %d/%d (r/w)", + timeout_count, + Curl_xfer_send_is_paused(data), + Curl_xfer_recv_is_paused(data)); + break; + case 1: + CURL_TRC_M(data, "pollset[fd=%" FMT_SOCKET_T " %s%s], timeouts=%zu", + ps->sockets[0], + (ps->actions[0] & CURL_POLL_IN) ? "IN" : "", + (ps->actions[0] & CURL_POLL_OUT) ? "OUT" : "", + timeout_count); + break; + case 2: + CURL_TRC_M(data, "pollset[fd=%" FMT_SOCKET_T " %s%s, " + "fd=%" FMT_SOCKET_T " %s%s], timeouts=%zu", + ps->sockets[0], + (ps->actions[0] & CURL_POLL_IN) ? "IN" : "", + (ps->actions[0] & CURL_POLL_OUT) ? "OUT" : "", + ps->sockets[1], + (ps->actions[1] & CURL_POLL_IN) ? "IN" : "", + (ps->actions[1] & CURL_POLL_OUT) ? "OUT" : "", + timeout_count); + break; + default: + CURL_TRC_M(data, "pollset[fds=%u], timeouts=%zu", ps->n, timeout_count); + break; } CURL_TRC_EASY_TIMERS(data); } @@ -1259,8 +1254,7 @@ CURLMcode curl_multi_fdset(CURLM *m, if((int)ps.sockets[i] > this_max_fd) this_max_fd = (int)ps.sockets[i]; } - } - while(Curl_uint32_bset_next(&multi->process, mid, &mid)); + } while(Curl_uint32_bset_next(&multi->process, mid, &mid)); } Curl_cshutdn_setfds(&multi->cshutdn, multi->admin, @@ -1305,8 +1299,7 @@ CURLMcode curl_multi_waitfds(CURLM *m, } Curl_multi_pollset(data, &ps); need += Curl_waitfds_add_ps(&cwfds, &ps); - } - while(Curl_uint32_bset_next(&multi->process, mid, &mid)); + } while(Curl_uint32_bset_next(&multi->process, mid, &mid)); } need += Curl_cshutdn_add_waitfds(&multi->cshutdn, multi->admin, &cwfds); @@ -1394,8 +1387,7 @@ static CURLMcode multi_wait(struct Curl_multi *multi, result = CURLM_OUT_OF_MEMORY; goto out; } - } - while(Curl_uint32_bset_next(&multi->process, mid, &mid)); + } while(Curl_uint32_bset_next(&multi->process, mid, &mid)); } if(Curl_cshutdn_add_pollfds(&multi->cshutdn, multi->admin, &cpfds)) { @@ -1424,11 +1416,11 @@ static CURLMcode multi_wait(struct Curl_multi *multi, for(i = 0; i < cpfds.n; i++) { long mask = 0; if(cpfds.pfds[i].events & POLLIN) - mask |= FD_READ|FD_ACCEPT|FD_CLOSE; + mask |= FD_READ | FD_ACCEPT | FD_CLOSE; if(cpfds.pfds[i].events & POLLPRI) mask |= FD_OOB; if(cpfds.pfds[i].events & POLLOUT) { - mask |= FD_WRITE|FD_CONNECT|FD_CLOSE; + mask |= FD_WRITE | FD_CONNECT | FD_CLOSE; reset_socket_fdwrite(cpfds.pfds[i].fd); } if(mask) { @@ -1503,9 +1495,9 @@ static CURLMcode multi_wait(struct Curl_multi *multi, curl_socket_t s = extra_fds[i].fd; wsa_events.lNetworkEvents = 0; if(WSAEnumNetworkEvents(s, NULL, &wsa_events) == 0) { - if(wsa_events.lNetworkEvents & (FD_READ|FD_ACCEPT|FD_CLOSE)) + if(wsa_events.lNetworkEvents & (FD_READ | FD_ACCEPT | FD_CLOSE)) mask |= CURL_WAIT_POLLIN; - if(wsa_events.lNetworkEvents & (FD_WRITE|FD_CONNECT|FD_CLOSE)) + if(wsa_events.lNetworkEvents & (FD_WRITE | FD_CONNECT | FD_CLOSE)) mask |= CURL_WAIT_POLLOUT; if(wsa_events.lNetworkEvents & FD_OOB) mask |= CURL_WAIT_POLLPRI; @@ -1610,8 +1602,7 @@ CURLMcode curl_multi_poll(CURLM *multi, int timeout_ms, int *ret) { - return multi_wait(multi, extra_fds, extra_nfds, timeout_ms, ret, TRUE, - TRUE); + return multi_wait(multi, extra_fds, extra_nfds, timeout_ms, ret, TRUE, TRUE); } CURLMcode curl_multi_wakeup(CURLM *m) @@ -1864,8 +1855,7 @@ static CURLcode protocol_doing(struct Curl_easy *data, bool *done) * proceed with some action. * */ -static CURLcode protocol_connect(struct Curl_easy *data, - bool *protocol_done) +static CURLcode protocol_connect(struct Curl_easy *data, bool *protocol_done) { CURLcode result = CURLE_OK; struct connectdata *conn = data->conn; @@ -1874,8 +1864,7 @@ static CURLcode protocol_connect(struct Curl_easy *data, *protocol_done = FALSE; - if(Curl_conn_is_connected(conn, FIRSTSOCKET) - && conn->bits.protoconnstart) { + if(Curl_conn_is_connected(conn, FIRSTSOCKET) && conn->bits.protoconnstart) { /* We already are connected, get back. This may happen when the connect worked fine in the first call, like when we connect to a local server or proxy. Note that we do not know if the protocol is actually done. @@ -1942,8 +1931,7 @@ static CURLcode multi_follow(struct Curl_easy *data, return CURLE_TOO_MANY_REDIRECTS; } -static CURLcode mspeed_check(struct Curl_easy *data, - struct curltime now) +static CURLcode mspeed_check(struct Curl_easy *data, struct curltime now) { timediff_t recv_wait_ms = 0; timediff_t send_wait_ms = 0; @@ -2160,8 +2148,7 @@ static CURLMcode state_do(struct Curl_easy *data, multi_done(data, CURLE_OK, FALSE); /* if there is no connection left, skip the DONE state */ - multistate(data, data->conn ? - MSTATE_DONE : MSTATE_COMPLETED); + multistate(data, data->conn ? MSTATE_DONE : MSTATE_COMPLETED); rc = CURLM_CALL_MULTI_PERFORM; goto end; } @@ -2597,8 +2584,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi, if(control) { /* if positive, advance to DO_DONE if negative, go back to DOING */ - multistate(data, control == 1 ? - MSTATE_DID : MSTATE_DOING); + multistate(data, control == 1 ? MSTATE_DID : MSTATE_DOING); rc = CURLM_CALL_MULTI_PERFORM; } /* else @@ -2796,7 +2782,6 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi, return rc; } - CURLMcode curl_multi_perform(CURLM *m, int *running_handles) { CURLMcode returncode = CURLM_OK; @@ -2832,8 +2817,7 @@ CURLMcode curl_multi_perform(CURLM *m, int *running_handles) result = multi_runsingle(multi, &now, data); if(result) returncode = result; - } - while(Curl_uint32_bset_next(&multi->process, mid, &mid)); + } while(Curl_uint32_bset_next(&multi->process, mid, &mid)); } sigpipe_restore(&pipe_st); @@ -2925,8 +2909,7 @@ CURLMcode curl_multi_cleanup(CURLM *m) #endif if(data->state.internal) Curl_close(&data); - } - while(Curl_uint32_tbl_next(&multi->xfers, mid, &mid, &entry)); + } while(Curl_uint32_tbl_next(&multi->xfers, mid, &mid, &entry)); } Curl_cpool_destroy(&multi->cpool); @@ -3017,7 +3000,6 @@ CURLMsg *curl_multi_info_read(CURLM *m, int *msgs_in_queue) return NULL; } - void Curl_multi_will_close(struct Curl_easy *data, curl_socket_t s) { if(data) { @@ -3160,8 +3142,7 @@ static CURLMcode multi_run_dirty(struct multi_run_ctx *mrc) CURL_TRC_M(multi->admin, "multi_run_dirty, %u no longer found", mid); Curl_uint32_bset_remove(&multi->dirty, mid); } - } - while(Curl_uint32_bset_next(&multi->dirty, mid, &mid)); + } while(Curl_uint32_bset_next(&multi->dirty, mid, &mid)); } out: @@ -3243,8 +3224,7 @@ static CURLMcode multi_socket(struct Curl_multi *multi, } #undef curl_multi_setopt -CURLMcode curl_multi_setopt(CURLM *m, - CURLMoption option, ...) +CURLMcode curl_multi_setopt(CURLM *m, CURLMoption option, ...) { CURLMcode res = CURLM_OK; va_list param; @@ -3305,14 +3285,13 @@ CURLMcode curl_multi_setopt(CURLM *m, break; case CURLMOPT_PIPELINING_SERVER_BL: break; - case CURLMOPT_MAX_CONCURRENT_STREAMS: - { - long streams = va_arg(param, long); - if((streams < 1) || (streams > INT_MAX)) - streams = 100; - multi->max_concurrent_streams = (unsigned int)streams; - } + case CURLMOPT_MAX_CONCURRENT_STREAMS: { + long streams = va_arg(param, long); + if((streams < 1) || (streams > INT_MAX)) + streams = 100; + multi->max_concurrent_streams = (unsigned int)streams; break; + } case CURLMOPT_NETWORK_CHANGED: { long val = va_arg(param, long); if(val & CURLMNWC_CLEAR_DNS) { @@ -3371,7 +3350,6 @@ CURLMcode curl_multi_socket_all(CURLM *m, int *running_handles) return multi_socket(multi, TRUE, CURL_SOCKET_BAD, 0, running_handles); } - static bool multi_has_dirties(struct Curl_multi *multi) { uint32_t mid; @@ -3388,8 +3366,7 @@ static bool multi_has_dirties(struct Curl_multi *multi) CURL_TRC_M(multi->admin, "dirty transfer %u no longer found", mid); Curl_uint32_bset_remove(&multi->dirty, mid); } - } - while(Curl_uint32_bset_next(&multi->dirty, mid, &mid)); + } while(Curl_uint32_bset_next(&multi->dirty, mid, &mid)); } return FALSE; } @@ -3398,7 +3375,7 @@ static void multi_timeout(struct Curl_multi *multi, struct curltime *expire_time, long *timeout_ms) { - static const struct curltime tv_zero = {0, 0}; + static const struct curltime tv_zero = { 0, 0 }; #ifndef CURL_DISABLE_VERBOSE_STRINGS struct Curl_easy *data = NULL; #endif @@ -3453,8 +3430,7 @@ static void multi_timeout(struct Curl_multi *multi, #ifndef CURL_DISABLE_VERBOSE_STRINGS if(data && CURL_TRC_TIMER_is_verbose(data)) { - struct Curl_llist_node *e = - Curl_llist_head(&data->state.timeoutlist); + struct Curl_llist_node *e = Curl_llist_head(&data->state.timeoutlist); if(e) { struct time_node *n = Curl_node_elem(e); CURL_TRC_TIMER(data, n->eid, "gives multi timeout in %ldms", @@ -3506,8 +3482,7 @@ CURLMcode Curl_update_timer(struct Curl_multi *multi) set_value = TRUE; } else if(multi->last_timeout_ms < 0) { - CURL_TRC_M(multi->admin, "[TIMER] set %ldms, none before", - timeout_ms); + CURL_TRC_M(multi->admin, "[TIMER] set %ldms, none before", timeout_ms); set_value = TRUE; } else if(curlx_timediff_us(multi->last_expire_ts, expire_ts)) { @@ -3543,8 +3518,7 @@ CURLMcode Curl_update_timer(struct Curl_multi *multi) * * Remove a given timestamp from the list of timeouts. */ -static void -multi_deltimeout(struct Curl_easy *data, expire_id eid) +static void multi_deltimeout(struct Curl_easy *data, expire_id eid) { struct Curl_llist_node *e; struct Curl_llist *timeoutlist = &data->state.timeoutlist; @@ -3565,11 +3539,10 @@ multi_deltimeout(struct Curl_easy *data, expire_id eid) * of list is always the timeout nearest in time. * */ -static CURLMcode -multi_addtimeout(struct Curl_easy *data, - struct curltime *stamp, - expire_id eid, - const struct curltime *nowp) +static CURLMcode multi_addtimeout(struct Curl_easy *data, + struct curltime *stamp, + expire_id eid, + const struct curltime *nowp) { struct Curl_llist_node *e; struct time_node *node; @@ -3594,7 +3567,6 @@ multi_addtimeout(struct Curl_easy *data, break; prev = e; } - } /* else this is the first timeout on the list */ @@ -3621,8 +3593,8 @@ void Curl_expire_ex(struct Curl_easy *data, DEBUGASSERT(id < EXPIRE_LAST); set = *nowp; - set.tv_sec += (time_t)(milli/1000); /* might be a 64 to 32 bits conversion */ - set.tv_usec += (int)(milli%1000)*1000; + set.tv_sec += (time_t)(milli / 1000); /* may be a 64 to 32-bit conversion */ + set.tv_usec += (int)(milli % 1000) * 1000; if(set.tv_usec >= 1000000) { set.tv_sec++; @@ -3783,8 +3755,7 @@ static void process_pending_handles(struct Curl_multi *multi) /* transfer no longer known, should not happen */ Curl_uint32_bset_remove(&multi->pending, mid); DEBUGASSERT(0); - } - while(Curl_uint32_bset_next(&multi->pending, mid, &mid)); + } while(Curl_uint32_bset_next(&multi->pending, mid, &mid)); } } @@ -3820,8 +3791,7 @@ CURL **curl_multi_get_handles(CURLM *m) DEBUGASSERT(i < count); if(!data->state.internal) a[i++] = data; - } - while(Curl_uint32_tbl_next(&multi->xfers, mid, &mid, &entry)); + } while(Curl_uint32_tbl_next(&multi->xfers, mid, &mid, &entry)); } a[i] = NULL; /* last entry is a NULL */ } diff --git a/lib/multi_ev.c b/lib/multi_ev.c index 026cbd29968e..40b49da85d95 100644 --- a/lib/multi_ev.c +++ b/lib/multi_ev.c @@ -64,7 +64,7 @@ struct mev_sh_entry { static size_t mev_sh_entry_hash(void *key, size_t key_length, size_t slots_num) { - curl_socket_t fd = *((curl_socket_t *) key); + curl_socket_t fd = *((curl_socket_t *)key); (void)key_length; return (fd % (curl_socket_t)slots_num); } @@ -72,8 +72,9 @@ static size_t mev_sh_entry_hash(void *key, size_t key_length, size_t slots_num) static size_t mev_sh_entry_compare(void *k1, size_t k1_len, void *k2, size_t k2_len) { - (void)k1_len; (void)k2_len; - return (*((curl_socket_t *) k1)) == (*((curl_socket_t *) k2)); + (void)k1_len; + (void)k2_len; + return (*((curl_socket_t *)k1)) == (*((curl_socket_t *)k2)); } /* sockhash entry destructor callback */ @@ -85,8 +86,8 @@ static void mev_sh_entry_dtor(void *freethis) } /* look up a given socket in the socket hash, skip invalid sockets */ -static struct mev_sh_entry * -mev_sh_entry_get(struct Curl_hash *sh, curl_socket_t s) +static struct mev_sh_entry *mev_sh_entry_get(struct Curl_hash *sh, + curl_socket_t s) { if(s != CURL_SOCKET_BAD) { /* only look for proper sockets */ @@ -96,8 +97,8 @@ mev_sh_entry_get(struct Curl_hash *sh, curl_socket_t s) } /* make sure this socket is present in the hash for this handle */ -static struct mev_sh_entry * -mev_sh_entry_add(struct Curl_hash *sh, curl_socket_t s) +static struct mev_sh_entry *mev_sh_entry_add(struct Curl_hash *sh, + curl_socket_t s) { struct mev_sh_entry *there = mev_sh_entry_get(sh, s); struct mev_sh_entry *check; @@ -166,7 +167,6 @@ static bool mev_sh_entry_conn_add(struct mev_sh_entry *e, return TRUE; } - static bool mev_sh_entry_xfer_remove(struct mev_sh_entry *e, struct Curl_easy *data) { @@ -202,8 +202,7 @@ static CURLMcode mev_forget_socket(struct Curl_multi *multi, /* We managed this socket before, tell the socket callback to forget it. */ if(entry->announced && multi->socket_cb) { - CURL_TRC_M(data, "ev %s, call(fd=%" FMT_SOCKET_T ", ev=REMOVE)", - cause, s); + CURL_TRC_M(data, "ev %s, call(fd=%" FMT_SOCKET_T ", ev=REMOVE)", cause, s); mev_in_callback(multi, TRUE); rc = multi->socket_cb(data, s, CURL_POLL_REMOVE, multi->socket_userp, entry->user_data); @@ -446,8 +445,7 @@ static void mev_pollset_dtor(void *key, size_t klen, void *entry) } } -static struct easy_pollset* -mev_add_new_conn_pollset(struct connectdata *conn) +static struct easy_pollset *mev_add_new_conn_pollset(struct connectdata *conn) { struct easy_pollset *ps; @@ -459,8 +457,7 @@ mev_add_new_conn_pollset(struct connectdata *conn) return ps; } -static struct easy_pollset* -mev_add_new_xfer_pollset(struct Curl_easy *data) +static struct easy_pollset *mev_add_new_xfer_pollset(struct Curl_easy *data) { struct easy_pollset *ps; @@ -472,9 +469,8 @@ mev_add_new_xfer_pollset(struct Curl_easy *data) return ps; } -static struct easy_pollset * -mev_get_last_pollset(struct Curl_easy *data, - struct connectdata *conn) +static struct easy_pollset *mev_get_last_pollset(struct Curl_easy *data, + struct connectdata *conn) { if(data) { if(conn) @@ -484,8 +480,7 @@ mev_get_last_pollset(struct Curl_easy *data, return NULL; } -static CURLMcode mev_assess(struct Curl_multi *multi, - struct Curl_easy *data, +static CURLMcode mev_assess(struct Curl_multi *multi, struct Curl_easy *data, struct connectdata *conn) { struct easy_pollset ps, *last_ps; @@ -551,13 +546,11 @@ CURLMcode Curl_multi_ev_assess_xfer_bset(struct Curl_multi *multi, struct Curl_easy *data = Curl_multi_get_easy(multi, mid); if(data) result = Curl_multi_ev_assess_xfer(multi, data); - } - while(!result && Curl_uint32_bset_next(set, mid, &mid)); + } while(!result && Curl_uint32_bset_next(set, mid, &mid)); } return result; } - CURLMcode Curl_multi_ev_assign(struct Curl_multi *multi, curl_socket_t s, void *user_data) @@ -596,8 +589,7 @@ void Curl_multi_ev_dirty_xfers(struct Curl_multi *multi, CURL_TRC_M(multi->admin, "socket transfer %u no longer found", mid); Curl_uint32_spbset_remove(&entry->xfers, mid); } - } - while(Curl_uint32_spbset_next(&entry->xfers, mid, &mid)); + } while(Curl_uint32_spbset_next(&entry->xfers, mid, &mid)); } if(entry->conn) diff --git a/lib/multi_ntfy.c b/lib/multi_ntfy.c index 43e4db9e8270..4fdbe7400a4a 100644 --- a/lib/multi_ntfy.c +++ b/lib/multi_ntfy.c @@ -38,7 +38,7 @@ struct mntfy_entry { uint32_t type; }; -#define CURL_MNTFY_CHUNK_SIZE 128 +#define CURL_MNTFY_CHUNK_SIZE 128 struct mntfy_chunk { struct mntfy_chunk *next; @@ -171,7 +171,7 @@ void Curl_mntfy_add(struct Curl_easy *data, unsigned int type) Curl_uint32_bset_contains(&multi->ntfy.enabled, (uint32_t)type)) { /* append to list of outstanding notifications */ struct mntfy_chunk *tail = mntfy_non_full_tail(&multi->ntfy); - CURL_TRC_M(data, "[NTFY] add %d for xfer %u", type, data->mid); + CURL_TRC_M(data, "[NTFY] add %d for xfer %u", type, data->mid); if(tail) mntfy_chunk_append(tail, data, (uint32_t)type); else diff --git a/lib/multi_ntfy.h b/lib/multi_ntfy.h index c3094a9ebe71..144d0319d0e6 100644 --- a/lib/multi_ntfy.h +++ b/lib/multi_ntfy.h @@ -47,11 +47,12 @@ CURLMcode Curl_mntfy_disable(struct Curl_multi *multi, unsigned int type); void Curl_mntfy_add(struct Curl_easy *data, unsigned int type); -#define CURLM_NTFY(d,t) \ - do { if((d) && (d)->multi && (d)->multi->ntfy.ntfy_cb) \ - Curl_mntfy_add((d), (t)); } while(0) +#define CURLM_NTFY(d, t) \ + do { \ + if((d) && (d)->multi && (d)->multi->ntfy.ntfy_cb) \ + Curl_mntfy_add((d), (t)); \ + } while(0) CURLMcode Curl_mntfy_dispatch_all(struct Curl_multi *multi); - #endif /* HEADER_CURL_MULTI_NTFY_H */ diff --git a/lib/multiif.h b/lib/multiif.h index 62c68c9cedf3..9db5b0100029 100644 --- a/lib/multiif.h +++ b/lib/multiif.h @@ -68,7 +68,6 @@ 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); diff --git a/lib/netrc.c b/lib/netrc.c index f8de4082972c..d26d194fe2d9 100644 --- a/lib/netrc.c +++ b/lib/netrc.c @@ -60,8 +60,8 @@ enum found_state { #define FOUND_LOGIN 1 #define FOUND_PASSWORD 2 -#define MAX_NETRC_LINE 16384 -#define MAX_NETRC_FILE (128*1024) +#define MAX_NETRC_LINE 16384 +#define MAX_NETRC_FILE (128 * 1024) #define MAX_NETRC_TOKEN 4096 /* convert a dynbuf call CURLcode error to a NETRCcode error */ @@ -318,7 +318,7 @@ static NETRCcode parsenetrc(struct store_netrc *store, if(!specific_login) Curl_safefree(login); } - if((found == (FOUND_PASSWORD|FOUND_LOGIN)) && our_login) { + if((found == (FOUND_PASSWORD | FOUND_LOGIN)) && our_login) { done = TRUE; break; } @@ -412,8 +412,8 @@ NETRCcode Curl_parsenetrc(struct store_netrc *store, const char *host, } else { struct passwd pw, *pw_res; - if(!getpwuid_r(geteuid(), &pw, pwbuf, sizeof(pwbuf), &pw_res) - && pw_res) { + if(!getpwuid_r(geteuid(), &pw, pwbuf, sizeof(pwbuf), &pw_res) && + pw_res) { home = pw.pw_dir; } #elif defined(HAVE_GETPWUID) && defined(HAVE_GETEUID) diff --git a/lib/netrc.h b/lib/netrc.h index 0d6d081bfbb9..81012d0d97e6 100644 --- a/lib/netrc.h +++ b/lib/netrc.h @@ -50,14 +50,14 @@ void Curl_netrc_cleanup(struct store_netrc *s); NETRCcode Curl_parsenetrc(struct store_netrc *s, const char *host, char **loginp, char **passwordp, const char *filename); - /* Assume: (*passwordp)[0]=0, host[0] != 0. - * If (*loginp)[0] = 0, search for login and password within a machine - * section in the netrc. - * If (*loginp)[0] != 0, search for password within machine and login. - */ +/* Assume: (*passwordp)[0]=0, host[0] != 0. + * If (*loginp)[0] = 0, search for login and password within a machine + * section in the netrc. + * If (*loginp)[0] != 0, search for password within machine and login. + */ #else /* disabled */ -#define Curl_parsenetrc(a,b,c,d,e,f) 1 +#define Curl_parsenetrc(a, b, c, d, e, f) 1 #define Curl_netrc_init(x) #define Curl_netrc_cleanup(x) #endif diff --git a/lib/noproxy.c b/lib/noproxy.c index 1e19c369c0d9..569466fb62ec 100644 --- a/lib/noproxy.c +++ b/lib/noproxy.c @@ -141,8 +141,7 @@ static bool match_host(const char *token, size_t tokenlen, else if(tokenlen < namelen) { /* case B, tailmatch domain */ match = (name[namelen - tokenlen - 1] == '.') && - curl_strnequal(token, name + (namelen - tokenlen), - tokenlen); + curl_strnequal(token, name + (namelen - tokenlen), tokenlen); } /* case C passes through, not a match */ return match; @@ -180,11 +179,10 @@ static bool match_ip(int type, const char *token, size_t tokenlen, return Curl_cidr4_match(name, check, bits); } - /**************************************************************** -* Checks if the host is in the noproxy list. returns TRUE if it matches and -* therefore the proxy should NOT be used. -****************************************************************/ + * Checks if the host is in the noproxy list. returns TRUE if it matches and + * therefore the proxy should NOT be used. + ****************************************************************/ bool Curl_check_noproxy(const char *name, const char *no_proxy) { char hostip[128]; diff --git a/lib/openldap.c b/lib/openldap.c index bb48edd32f2c..ba1a39181f38 100644 --- a/lib/openldap.c +++ b/lib/openldap.c @@ -112,7 +112,6 @@ static Curl_recv oldap_recv; /* * LDAP protocol handler. */ - const struct Curl_handler Curl_handler_ldap = { "ldap", /* scheme */ oldap_setup_connection, /* setup_connection */ @@ -136,14 +135,13 @@ const struct Curl_handler Curl_handler_ldap = { CURLPROTO_LDAP, /* protocol */ CURLPROTO_LDAP, /* family */ PROTOPT_SSL_REUSE | /* flags */ - PROTOPT_CONN_REUSE + PROTOPT_CONN_REUSE }; #ifdef USE_SSL /* * LDAPS protocol handler. */ - const struct Curl_handler Curl_handler_ldaps = { "ldaps", /* scheme */ oldap_setup_connection, /* setup_connection */ @@ -167,7 +165,7 @@ const struct Curl_handler Curl_handler_ldaps = { CURLPROTO_LDAPS, /* protocol */ CURLPROTO_LDAP, /* family */ PROTOPT_SSL | /* flags */ - PROTOPT_CONN_REUSE + PROTOPT_CONN_REUSE }; #endif @@ -281,7 +279,7 @@ static CURLcode oldap_url_parse(struct Curl_easy *data, LDAPURLDesc **ludp) result = rc == LDAP_URL_ERR_MEM ? CURLE_OUT_OF_MEMORY : CURLE_URL_MALFORMAT; rc -= LDAP_URL_SUCCESS; - if((size_t) rc < CURL_ARRAYSIZE(url_errs)) + if((size_t)rc < CURL_ARRAYSIZE(url_errs)) msg = url_errs[rc]; failf(data, "LDAP local: %s", msg); } @@ -507,8 +505,7 @@ static ber_slen_t ldapsb_tls_write(Sockbuf_IO_Desc *sbiod, void *buf, ber_len_t len); static int ldapsb_tls_close(Sockbuf_IO_Desc *sbiod); -static Sockbuf_IO ldapsb_tls = -{ +static Sockbuf_IO ldapsb_tls = { ldapsb_tls_setup, ldapsb_tls_remove, ldapsb_tls_ctrl, @@ -658,7 +655,7 @@ static CURLcode oldap_connect(struct Curl_easy *data, bool *done) ldap_set_option(li->ld, LDAP_OPT_REFERRALS, LDAP_OPT_OFF); { - ber_len_t max = 256*1024; + ber_len_t max = 256 * 1024; Sockbuf *sb; if((ldap_get_option(li->ld, LDAP_OPT_SOCKBUF, &sb) != LDAP_OPT_SUCCESS) || /* Set the maximum allowed size of an incoming message, which to @@ -730,7 +727,7 @@ static CURLcode oldap_state_mechs_resp(struct Curl_easy *data, if(bvals) { for(i = 0; bvals[i].bv_val; i++) { size_t llen; - unsigned short mech = Curl_sasl_decode_mech((char *) bvals[i].bv_val, + unsigned short mech = Curl_sasl_decode_mech((char *)bvals[i].bv_val, bvals[i].bv_len, &llen); if(bvals[i].bv_len == llen) li->sasl.authmechs |= mech; @@ -829,7 +826,7 @@ static CURLcode oldap_connecting(struct Curl_easy *data, bool *done) struct connectdata *conn = data->conn; struct ldapconninfo *li = Curl_conn_meta_get(conn, CURL_META_LDAP_CONN); LDAPMessage *msg = NULL; - struct timeval tv = {0, 0}; + struct timeval tv = { 0, 0 }; int code = LDAP_SUCCESS; int rc; @@ -1091,7 +1088,7 @@ static CURLcode oldap_recv(struct Curl_easy *data, int sockindex, char *buf, int rc; LDAPMessage *msg = NULL; BerElement *ber = NULL; - struct timeval tv = {0, 0}; + struct timeval tv = { 0, 0 }; struct berval bv, *bvals; CURLcode result = CURLE_AGAIN; int code; @@ -1246,30 +1243,26 @@ static CURLcode oldap_recv(struct Curl_easy *data, int sockindex, char *buf, } #ifdef USE_SSL -static int -ldapsb_tls_setup(Sockbuf_IO_Desc *sbiod, void *arg) +static int ldapsb_tls_setup(Sockbuf_IO_Desc *sbiod, void *arg) { sbiod->sbiod_pvt = arg; return 0; } -static int -ldapsb_tls_remove(Sockbuf_IO_Desc *sbiod) +static int ldapsb_tls_remove(Sockbuf_IO_Desc *sbiod) { sbiod->sbiod_pvt = NULL; return 0; } /* We do not need to do anything because libcurl does it already */ -static int -ldapsb_tls_close(Sockbuf_IO_Desc *sbiod) +static int ldapsb_tls_close(Sockbuf_IO_Desc *sbiod) { (void)sbiod; return 0; } -static int -ldapsb_tls_ctrl(Sockbuf_IO_Desc *sbiod, int opt, void *arg) +static int ldapsb_tls_ctrl(Sockbuf_IO_Desc *sbiod, int opt, void *arg) { (void)arg; if(opt == LBER_SB_OPT_DATA_READY) { @@ -1279,8 +1272,8 @@ ldapsb_tls_ctrl(Sockbuf_IO_Desc *sbiod, int opt, void *arg) return 0; } -static ber_slen_t -ldapsb_tls_read(Sockbuf_IO_Desc *sbiod, void *buf, ber_len_t len) +static ber_slen_t ldapsb_tls_read(Sockbuf_IO_Desc *sbiod, void *buf, + ber_len_t len) { struct Curl_easy *data = sbiod->sbiod_pvt; ber_slen_t ret = 0; @@ -1304,8 +1297,8 @@ ldapsb_tls_read(Sockbuf_IO_Desc *sbiod, void *buf, ber_len_t len) } return ret; } -static ber_slen_t -ldapsb_tls_write(Sockbuf_IO_Desc *sbiod, void *buf, ber_len_t len) +static ber_slen_t ldapsb_tls_write(Sockbuf_IO_Desc *sbiod, void *buf, + ber_len_t len) { struct Curl_easy *data = sbiod->sbiod_pvt; ber_slen_t ret = 0; diff --git a/lib/parsedate.c b/lib/parsedate.c index 2c3eb67fd2e6..0649de454b4c 100644 --- a/lib/parsedate.c +++ b/lib/parsedate.c @@ -107,17 +107,19 @@ static int parsedate(const char *date, time_t *output); #if !defined(CURL_DISABLE_PARSEDATE) || !defined(CURL_DISABLE_FTP) || \ !defined(CURL_DISABLE_FILE) || defined(USE_GNUTLS) /* 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" }; +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 #ifndef CURL_DISABLE_PARSEDATE -static const char * const weekday[] = -{ "Monday", "Tuesday", "Wednesday", "Thursday", - "Friday", "Saturday", "Sunday" }; +static const char * const weekday[] = { + "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" +}; struct tzinfo { char name[5]; @@ -127,83 +129,83 @@ struct tzinfo { /* Here's a bunch of frequently used time zone names. These were supported by the old getdate parser. */ #define tDAYZONE -60 /* offset for daylight savings time */ -static const struct tzinfo tz[]= { - {"GMT", 0}, /* Greenwich Mean */ - {"UT", 0}, /* Universal Time */ - {"UTC", 0}, /* Universal (Coordinated) */ - {"WET", 0}, /* Western European */ - {"BST", 0 tDAYZONE}, /* British Summer */ - {"WAT", 60}, /* West Africa */ - {"AST", 240}, /* Atlantic Standard */ - {"ADT", 240 tDAYZONE}, /* Atlantic Daylight */ - {"EST", 300}, /* Eastern Standard */ - {"EDT", 300 tDAYZONE}, /* Eastern Daylight */ - {"CST", 360}, /* Central Standard */ - {"CDT", 360 tDAYZONE}, /* Central Daylight */ - {"MST", 420}, /* Mountain Standard */ - {"MDT", 420 tDAYZONE}, /* Mountain Daylight */ - {"PST", 480}, /* Pacific Standard */ - {"PDT", 480 tDAYZONE}, /* Pacific Daylight */ - {"YST", 540}, /* Yukon Standard */ - {"YDT", 540 tDAYZONE}, /* Yukon Daylight */ - {"HST", 600}, /* Hawaii Standard */ - {"HDT", 600 tDAYZONE}, /* Hawaii Daylight */ - {"CAT", 600}, /* Central Alaska */ - {"AHST", 600}, /* Alaska-Hawaii Standard */ - {"NT", 660}, /* Nome */ /* spellchecker:disable-line */ - {"IDLW", 720}, /* International Date Line West */ - {"CET", -60}, /* Central European */ - {"MET", -60}, /* Middle European */ - {"MEWT", -60}, /* Middle European Winter */ - {"MEST", -60 tDAYZONE}, /* Middle European Summer */ - {"CEST", -60 tDAYZONE}, /* Central European Summer */ - {"MESZ", -60 tDAYZONE}, /* Middle European Summer */ - {"FWT", -60}, /* French Winter */ - {"FST", -60 tDAYZONE}, /* French Summer */ - {"EET", -120}, /* Eastern Europe, USSR Zone 1 */ - {"WAST", -420}, /* spellchecker:disable-line */ - /* West Australian Standard */ - {"WADT", -420 tDAYZONE}, /* West Australian Daylight */ - {"CCT", -480}, /* China Coast, USSR Zone 7 */ - {"JST", -540}, /* Japan Standard, USSR Zone 8 */ - {"EAST", -600}, /* Eastern Australian Standard */ - {"EADT", -600 tDAYZONE}, /* Eastern Australian Daylight */ - {"GST", -600}, /* Guam Standard, USSR Zone 9 */ - {"NZT", -720}, /* New Zealand */ - {"NZST", -720}, /* New Zealand Standard */ - {"NZDT", -720 tDAYZONE}, /* New Zealand Daylight */ - {"IDLE", -720}, /* International Date Line East */ +static const struct tzinfo tz[] = { + { "GMT", 0 }, /* Greenwich Mean */ + { "UT", 0 }, /* Universal Time */ + { "UTC", 0 }, /* Universal (Coordinated) */ + { "WET", 0 }, /* Western European */ + { "BST", 0 tDAYZONE }, /* British Summer */ + { "WAT", 60 }, /* West Africa */ + { "AST", 240 }, /* Atlantic Standard */ + { "ADT", 240 tDAYZONE }, /* Atlantic Daylight */ + { "EST", 300 }, /* Eastern Standard */ + { "EDT", 300 tDAYZONE }, /* Eastern Daylight */ + { "CST", 360 }, /* Central Standard */ + { "CDT", 360 tDAYZONE }, /* Central Daylight */ + { "MST", 420 }, /* Mountain Standard */ + { "MDT", 420 tDAYZONE }, /* Mountain Daylight */ + { "PST", 480 }, /* Pacific Standard */ + { "PDT", 480 tDAYZONE }, /* Pacific Daylight */ + { "YST", 540 }, /* Yukon Standard */ + { "YDT", 540 tDAYZONE }, /* Yukon Daylight */ + { "HST", 600 }, /* Hawaii Standard */ + { "HDT", 600 tDAYZONE }, /* Hawaii Daylight */ + { "CAT", 600 }, /* Central Alaska */ + { "AHST", 600 }, /* Alaska-Hawaii Standard */ + { "NT", 660 }, /* Nome */ /* spellchecker:disable-line */ + { "IDLW", 720 }, /* International Date Line West */ + { "CET", -60 }, /* Central European */ + { "MET", -60 }, /* Middle European */ + { "MEWT", -60 }, /* Middle European Winter */ + { "MEST", -60 tDAYZONE }, /* Middle European Summer */ + { "CEST", -60 tDAYZONE }, /* Central European Summer */ + { "MESZ", -60 tDAYZONE }, /* Middle European Summer */ + { "FWT", -60 }, /* French Winter */ + { "FST", -60 tDAYZONE }, /* French Summer */ + { "EET", -120 }, /* Eastern Europe, USSR Zone 1 */ + { "WAST", -420 }, /* spellchecker:disable-line */ + /* West Australian Standard */ + { "WADT", -420 tDAYZONE }, /* West Australian Daylight */ + { "CCT", -480 }, /* China Coast, USSR Zone 7 */ + { "JST", -540 }, /* Japan Standard, USSR Zone 8 */ + { "EAST", -600 }, /* Eastern Australian Standard */ + { "EADT", -600 tDAYZONE }, /* Eastern Australian Daylight */ + { "GST", -600 }, /* Guam Standard, USSR Zone 9 */ + { "NZT", -720 }, /* New Zealand */ + { "NZST", -720 }, /* New Zealand Standard */ + { "NZDT", -720 tDAYZONE }, /* New Zealand Daylight */ + { "IDLE", -720 }, /* International Date Line East */ /* Next up: Military timezone names. RFC822 allowed these, but (as noted in RFC 1123) had their signs wrong. Here we use the correct signs to match actual military usage. */ - {"A", 1 * 60}, /* Alpha */ - {"B", 2 * 60}, /* Bravo */ - {"C", 3 * 60}, /* Charlie */ - {"D", 4 * 60}, /* Delta */ - {"E", 5 * 60}, /* Echo */ - {"F", 6 * 60}, /* Foxtrot */ - {"G", 7 * 60}, /* Golf */ - {"H", 8 * 60}, /* Hotel */ - {"I", 9 * 60}, /* India */ + { "A", 1 * 60 }, /* Alpha */ + { "B", 2 * 60 }, /* Bravo */ + { "C", 3 * 60 }, /* Charlie */ + { "D", 4 * 60 }, /* Delta */ + { "E", 5 * 60 }, /* Echo */ + { "F", 6 * 60 }, /* Foxtrot */ + { "G", 7 * 60 }, /* Golf */ + { "H", 8 * 60 }, /* Hotel */ + { "I", 9 * 60 }, /* India */ /* "J", Juliet is not used as a timezone, to indicate the observer's local time */ - {"K", 10 * 60}, /* Kilo */ - {"L", 11 * 60}, /* Lima */ - {"M", 12 * 60}, /* Mike */ - {"N", -1 * 60}, /* November */ - {"O", -2 * 60}, /* Oscar */ - {"P", -3 * 60}, /* Papa */ - {"Q", -4 * 60}, /* Quebec */ - {"R", -5 * 60}, /* Romeo */ - {"S", -6 * 60}, /* Sierra */ - {"T", -7 * 60}, /* Tango */ - {"U", -8 * 60}, /* Uniform */ - {"V", -9 * 60}, /* Victor */ - {"W", -10 * 60}, /* Whiskey */ - {"X", -11 * 60}, /* X-ray */ - {"Y", -12 * 60}, /* Yankee */ - {"Z", 0}, /* Zulu, zero meridian, a.k.a. UTC */ + { "K", 10 * 60 }, /* Kilo */ + { "L", 11 * 60 }, /* Lima */ + { "M", 12 * 60 }, /* Mike */ + { "N", -1 * 60 }, /* November */ + { "O", -2 * 60 }, /* Oscar */ + { "P", -3 * 60 }, /* Papa */ + { "Q", -4 * 60 }, /* Quebec */ + { "R", -5 * 60 }, /* Romeo */ + { "S", -6 * 60 }, /* Sierra */ + { "T", -7 * 60 }, /* Tango */ + { "U", -8 * 60 }, /* Uniform */ + { "V", -9 * 60 }, /* Victor */ + { "W", -10 * 60 }, /* Whiskey */ + { "X", -11 * 60 }, /* X-ray */ + { "Y", -12 * 60 }, /* Yankee */ + { "Z", 0 }, /* Zulu, zero meridian, a.k.a. UTC */ }; /* returns: @@ -260,7 +262,7 @@ static int checktz(const char *check, size_t len) size_t ilen = strlen(what->name); if((ilen == len) && curl_strnequal(check, what->name, len)) - return what->offset*60; + return what->offset * 60; what++; } return -1; @@ -286,12 +288,13 @@ enum assume { 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 }; + 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); leap_days = ((leap_days / 4) - (leap_days / 100) + (leap_days / 400) - (1969 / 4) + (1969 / 100) - (1969 / 400)); - return ((((time_t) (year - 1970) * 365 + return ((((time_t)(year - 1970) * 365 + leap_days + month_days_cumulative[mon] + mday - 1) * 24 + hour) * 60 + min) * 60 + sec; } @@ -304,13 +307,12 @@ static int oneortwodigit(const char *date, const char **endp) int num = date[0] - '0'; if(ISDIGIT(date[1])) { *endp = &date[2]; - return num*10 + (date[1] - '0'); + return num * 10 + (date[1] - '0'); } *endp = &date[1]; return num; } - /* HH:MM:SS or HH:MM and accept single-digits too */ static bool match_time(const char *date, int *h, int *m, int *s, char **endp) @@ -444,11 +446,11 @@ static int parsedate(const char *date, time_t *output) anyone has a more authoritative source for the exact maximum time zone offsets, please speak up! */ found = TRUE; - tzoff = (val/100 * 60 + val%100)*60; + tzoff = (val / 100 * 60 + val % 100) * 60; /* the + and - prefix indicates the local time compared to GMT, this we need their reversed math to get what we want */ - tzoff = date[-1]=='+' ? -tzoff : tzoff; + tzoff = date[-1] == '+' ? -tzoff : tzoff; } else if((num_digits == 8) && @@ -457,9 +459,9 @@ static int parsedate(const char *date, time_t *output) (mdaynum == -1)) { /* 8 digits, no year, month or day yet. This is YYYYMMDD */ found = TRUE; - yearnum = val/10000; - monnum = (val%10000)/100-1; /* month is 0 - 11 */ - mdaynum = val%100; + yearnum = val / 10000; + monnum = (val % 10000) / 100 - 1; /* month is 0 - 11 */ + mdaynum = val % 100; } if(!found && (dignext == DATE_MDAY) && (mdaynum == -1)) { diff --git a/lib/pingpong.c b/lib/pingpong.c index 7ac321af7244..36acc34a3668 100644 --- a/lib/pingpong.c +++ b/lib/pingpong.c @@ -214,7 +214,6 @@ CURLcode Curl_pp_vsendf(struct Curl_easy *data, return CURLE_OK; } - /*********************************************************************** * * Curl_pp_sendf() diff --git a/lib/pingpong.h b/lib/pingpong.h index bd723b1c9bf4..5492453d8459 100644 --- a/lib/pingpong.h +++ b/lib/pingpong.h @@ -71,10 +71,10 @@ struct pingpong { read */ }; -#define PINGPONG_SETUP(pp,s,e) \ - do { \ - (pp)->statemachine = s; \ - (pp)->endofresp = e; \ +#define PINGPONG_SETUP(pp, s, e) \ + do { \ + (pp)->statemachine = s; \ + (pp)->endofresp = e; \ } while(0) /* @@ -94,7 +94,6 @@ void Curl_pp_init(struct pingpong *pp); timediff_t Curl_pp_state_timeout(struct Curl_easy *data, struct pingpong *pp, bool disconnecting); - /*********************************************************************** * * Curl_pp_sendf() @@ -148,7 +147,6 @@ CURLcode Curl_pp_pollset(struct Curl_easy *data, struct pingpong *pp, struct easy_pollset *ps); - /*********************************************************************** * * Curl_pp_moredata() diff --git a/lib/pop3.c b/lib/pop3.c index f10108229b6a..771069b3d434 100644 --- a/lib/pop3.c +++ b/lib/pop3.c @@ -84,11 +84,11 @@ #define POP3_TYPE_SASL (1 << 2) /* Authentication type values */ -#define POP3_TYPE_NONE 0 -#define POP3_TYPE_ANY (POP3_TYPE_CLEARTEXT|POP3_TYPE_APOP|POP3_TYPE_SASL) +#define POP3_TYPE_NONE 0 +#define POP3_TYPE_ANY (POP3_TYPE_CLEARTEXT | POP3_TYPE_APOP | POP3_TYPE_SASL) /* This is the 5-bytes End-Of-Body marker for POP3 */ -#define POP3_EOB "\x0d\x0a\x2e\x0d\x0a" +#define POP3_EOB "\x0d\x0a\x2e\x0d\x0a" #define POP3_EOB_LEN 5 /* meta key for storing protocol meta at easy handle */ @@ -196,8 +196,7 @@ const struct Curl_handler Curl_handler_pop3 = { CURLPROTO_POP3, /* protocol */ CURLPROTO_POP3, /* family */ PROTOPT_CLOSEACTION | PROTOPT_NOURLQUERY | /* flags */ - PROTOPT_URLOPTIONS | PROTOPT_SSL_REUSE | - PROTOPT_CONN_REUSE + PROTOPT_URLOPTIONS | PROTOPT_SSL_REUSE | PROTOPT_CONN_REUSE }; #ifdef USE_SSL @@ -228,8 +227,7 @@ const struct Curl_handler Curl_handler_pop3s = { CURLPROTO_POP3S, /* protocol */ CURLPROTO_POP3, /* family */ PROTOPT_CLOSEACTION | PROTOPT_SSL | /* flags */ - PROTOPT_NOURLQUERY | PROTOPT_URLOPTIONS | - PROTOPT_CONN_REUSE + PROTOPT_NOURLQUERY | PROTOPT_URLOPTIONS | PROTOPT_CONN_REUSE }; #endif @@ -512,7 +510,7 @@ static CURLcode pop3_perform_upgrade_tls(struct Curl_easy *data, result, ssldone)); if(!result && ssldone) { pop3c->ssldone = ssldone; - /* perform CAPA now, changes pop3c->state out of POP3_UPGRADETLS */ + /* perform CAPA now, changes pop3c->state out of POP3_UPGRADETLS */ result = pop3_perform_capa(data, conn); } out: @@ -589,10 +587,10 @@ static CURLcode pop3_perform_apop(struct Curl_easy *data, if(!ctxt) return CURLE_OUT_OF_MEMORY; - Curl_MD5_update(ctxt, (const unsigned char *) pop3c->apoptimestamp, + Curl_MD5_update(ctxt, (const unsigned char *)pop3c->apoptimestamp, curlx_uztoui(strlen(pop3c->apoptimestamp))); - Curl_MD5_update(ctxt, (const unsigned char *) conn->passwd, + Curl_MD5_update(ctxt, (const unsigned char *)conn->passwd, curlx_uztoui(strlen(conn->passwd))); /* Finalise the digest */ @@ -625,7 +623,7 @@ static CURLcode pop3_perform_auth(struct Curl_easy *data, struct pop3_conn *pop3c = Curl_conn_meta_get(data->conn, CURL_META_POP3_CONN); CURLcode result = CURLE_OK; - const char *ir = (const char *) Curl_bufref_ptr(initresp); + const char *ir = (const char *)Curl_bufref_ptr(initresp); if(!pop3c) return CURLE_FAILED_INIT; diff --git a/lib/progress.c b/lib/progress.c index 7124a307d1f5..1ae8b5801d01 100644 --- a/lib/progress.c +++ b/lib/progress.c @@ -87,7 +87,7 @@ static char *max6data(curl_off_t bytes, char *max6) /* xxx.yU */ curl_msnprintf(max6, 7, "%3" CURL_FORMAT_CURL_OFF_T ".%" CURL_FORMAT_CURL_OFF_T "%c", nbytes, - (bytes%1024) / (1024/10), unit[k]); + (bytes % 1024) / (1024 / 10), unit[k]); } return max6; } @@ -351,7 +351,7 @@ void Curl_pgrsSetUploadSize(struct Curl_easy *data, curl_off_t size) void Curl_pgrsEarlyData(struct Curl_easy *data, curl_off_t sent) { - data->progress.earlydata_sent = sent; + data->progress.earlydata_sent = sent; } /* returns the average speed in bytes / second */ @@ -360,7 +360,7 @@ static curl_off_t trspeed(curl_off_t size, /* number of bytes */ { if(us < 1) return size * 1000000; - else if(size < CURL_OFF_T_MAX/1000000) + else if(size < CURL_OFF_T_MAX / 1000000) return (size * 1000000) / us; else if(us >= 1000000) return size / (us / 1000000); @@ -422,18 +422,18 @@ static bool progress_calc(struct Curl_easy *data, struct curltime *pnow) ((i_latest + 1) % CURL_SPEED_RECORDS); /* How much we transferred between oldest and current records */ - amount = p->speed_amount[i_latest]- p->speed_amount[i_oldest]; + amount = p->speed_amount[i_latest] - p->speed_amount[i_oldest]; /* How long this took */ duration_ms = curlx_timediff_ms(p->speed_time[i_latest], p->speed_time[i_oldest]); if(duration_ms <= 0) duration_ms = 1; - if(amount > (CURL_OFF_T_MAX/1000)) { + if(amount > (CURL_OFF_T_MAX / 1000)) { /* the 'amount' value is bigger than would fit in 64 bits if multiplied with 1000, so we use the double math for this */ - p->current_speed = (curl_off_t) - (((double)amount * 1000.0)/(double)duration_ms); + p->current_speed = + (curl_off_t)(((double)amount * 1000.0) / (double)duration_ms); } else { /* the 'amount' value is small enough to fit within 32 bits even @@ -459,7 +459,7 @@ static curl_off_t pgrs_est_percent(curl_off_t total, curl_off_t cur) if(total > 10000) return cur / (total / 100); else if(total > 0) - return (cur*100) / total; + return (cur * 100) / total; return 0; } @@ -488,7 +488,7 @@ static void progress_meter(struct Curl_easy *data) char time_left[10]; char time_total[10]; char time_spent[10]; - curl_off_t cur_secs = (curl_off_t)p->timespent/1000000; /* seconds */ + curl_off_t cur_secs = (curl_off_t)p->timespent / 1000000; /* seconds */ if(!p->headers_out) { if(data->state.resume_from) { @@ -516,11 +516,9 @@ static void progress_meter(struct Curl_easy *data) time2str(time_spent, cur_secs); /* Get the total amount of data expected to get transferred */ - total_expected_size = - p->ul_size_known ? p->ul.total_size : p->ul.cur_size; + total_expected_size = p->ul_size_known ? p->ul.total_size : p->ul.cur_size; - dl_size = - p->dl_size_known ? p->dl.total_size : p->dl.cur_size; + dl_size = p->dl_size_known ? p->dl.total_size : p->dl.cur_size; /* integer overflow check */ if((CURL_OFF_T_MAX - total_expected_size) < dl_size) @@ -561,7 +559,6 @@ static void progress_meter(struct Curl_easy *data) #define progress_meter(x) Curl_nop_stmt #endif - /* * Curl_pgrsUpdate() returns 0 for success or the value returned by the * progress callback! diff --git a/lib/psl.c b/lib/psl.c index 5bf96d09bd88..0be51e44020a 100644 --- a/lib/psl.c +++ b/lib/psl.c @@ -91,7 +91,7 @@ const psl_ctx_t *Curl_psl_use(struct Curl_easy *easy) pslcache->expires = expires; } } - Curl_share_unlock(easy, CURL_LOCK_DATA_PSL); /* Release exclusive lock. */ + Curl_share_unlock(easy, CURL_LOCK_DATA_PSL); /* Release exclusive lock. */ Curl_share_lock(easy, CURL_LOCK_DATA_PSL, CURL_LOCK_ACCESS_SHARED); } psl = pslcache->psl; diff --git a/lib/rand.c b/lib/rand.c index 8c5a2cf71e44..88324e918ae9 100644 --- a/lib/rand.c +++ b/lib/rand.c @@ -227,8 +227,7 @@ CURLcode Curl_rand_bytes(struct Curl_easy *data, * size. */ -CURLcode Curl_rand_hex(struct Curl_easy *data, unsigned char *rnd, - size_t num) +CURLcode Curl_rand_hex(struct Curl_easy *data, unsigned char *rnd, size_t num) { CURLcode result = CURLE_BAD_FUNCTION_ARGUMENT; unsigned char buffer[128]; @@ -240,7 +239,7 @@ CURLcode Curl_rand_hex(struct Curl_easy *data, unsigned char *rnd, memset(buffer, 0, sizeof(buffer)); #endif - if((num/2 >= sizeof(buffer)) || !(num&1)) { + if((num / 2 >= sizeof(buffer)) || !(num & 1)) { /* make sure it fits in the local buffer and that it is an odd number! */ DEBUGF(infof(data, "invalid buffer size with Curl_rand_hex")); return CURLE_BAD_FUNCTION_ARGUMENT; @@ -248,11 +247,11 @@ CURLcode Curl_rand_hex(struct Curl_easy *data, unsigned char *rnd, num--; /* save one for null-termination */ - result = Curl_rand(data, buffer, num/2); + result = Curl_rand(data, buffer, num / 2); if(result) return result; - Curl_hexencode(buffer, num/2, rnd, num + 1); + Curl_hexencode(buffer, num / 2, rnd, num + 1); return result; } diff --git a/lib/rand.h b/lib/rand.h index 2ba60e72976e..674cb6ee2025 100644 --- a/lib/rand.h +++ b/lib/rand.h @@ -31,9 +31,9 @@ CURLcode Curl_rand_bytes(struct Curl_easy *data, unsigned char *rnd, size_t num); #ifdef DEBUGBUILD -#define Curl_rand(a,b,c) Curl_rand_bytes((a), TRUE, (b), (c)) +#define Curl_rand(a, b, c) Curl_rand_bytes((a), TRUE, (b), (c)) #else -#define Curl_rand(a,b,c) Curl_rand_bytes((a), (b), (c)) +#define Curl_rand(a, b, c) Curl_rand_bytes((a), (b), (c)) #endif /* @@ -41,8 +41,7 @@ CURLcode Curl_rand_bytes(struct Curl_easy *data, * hexadecimal digits PLUS a null-terminating byte. It must be an odd number * size. */ -CURLcode Curl_rand_hex(struct Curl_easy *data, unsigned char *rnd, - size_t num); +CURLcode Curl_rand_hex(struct Curl_easy *data, unsigned char *rnd, size_t num); /* * Curl_rand_alnum() fills the 'rnd' buffer with a given 'num' size with random diff --git a/lib/ratelimit.c b/lib/ratelimit.c index c3593d593756..7e3592506aa8 100644 --- a/lib/ratelimit.c +++ b/lib/ratelimit.c @@ -28,7 +28,7 @@ #include "ratelimit.h" -#define CURL_US_PER_SEC 1000000 +#define CURL_US_PER_SEC 1000000 #define CURL_RLIMIT_MIN_CHUNK (16 * 1024) #define CURL_RLIMIT_MAX_STEPS 2 /* 500ms interval */ diff --git a/lib/request.c b/lib/request.c index 581d7d14537a..fa83380878ad 100644 --- a/lib/request.c +++ b/lib/request.c @@ -111,7 +111,7 @@ CURLcode Curl_req_done(struct SingleRequest *req, void Curl_req_hard_reset(struct SingleRequest *req, struct Curl_easy *data) { - struct curltime t0 = {0, 0}; + struct curltime t0 = { 0, 0 }; Curl_safefree(req->newurl); Curl_client_reset(data); @@ -473,6 +473,6 @@ CURLcode Curl_req_stop_send_recv(struct Curl_easy *data) CURLcode result = CURLE_OK; if(data->req.keepon & KEEP_SEND) result = Curl_req_abort_sending(data); - data->req.keepon &= ~(KEEP_RECV|KEEP_SEND); + data->req.keepon &= ~(KEEP_RECV | KEEP_SEND); return result; } diff --git a/lib/request.h b/lib/request.h index 0f9e0a6ff4fc..5b0d1460283b 100644 --- a/lib/request.h +++ b/lib/request.h @@ -48,7 +48,6 @@ enum upgrade101 { UPGR101_RECEIVED /* 101 response received */ }; - /* * Request specific data in the easy handle (Curl_easy). Previously, * these members were on the connectdata struct but since a conn struct may diff --git a/lib/rtsp.c b/lib/rtsp.c index 5a46dc62c407..ee5d822a5404 100644 --- a/lib/rtsp.c +++ b/lib/rtsp.c @@ -117,11 +117,10 @@ static CURLcode rtsp_do_pollset(struct Curl_easy *data, return Curl_pollset_add_out(data, ps, data->conn->sock[FIRSTSOCKET]); } -static -CURLcode rtp_client_write(struct Curl_easy *data, const char *ptr, size_t len); -static -CURLcode rtsp_parse_transport(struct Curl_easy *data, const char *transport); - +static CURLcode rtp_client_write(struct Curl_easy *data, const char *ptr, + size_t len); +static CURLcode rtsp_parse_transport(struct Curl_easy *data, + const char *transport); /* * RTSP handler interface. @@ -191,7 +190,6 @@ static CURLcode rtsp_setup_connection(struct Curl_easy *data, return CURLE_OK; } - /* * Function to check on various aspects of a connection. */ @@ -211,7 +209,6 @@ static unsigned int rtsp_conncheck(struct Curl_easy *data, return ret_val; } - static CURLcode rtsp_connect(struct Curl_easy *data, bool *done) { struct rtsp_conn *rtspc = @@ -274,7 +271,6 @@ static CURLcode rtsp_done(struct Curl_easy *data, return httpStatus; } - static CURLcode rtsp_setup_body(struct Curl_easy *data, Curl_RtspReq rtspreq, struct dynbuf *reqp) @@ -324,9 +320,8 @@ static CURLcode rtsp_setup_body(struct Curl_easy *data, if(rtspreq == RTSPREQ_SET_PARAMETER || rtspreq == RTSPREQ_GET_PARAMETER) { if(!Curl_checkheaders(data, STRCONST("Content-Type"))) { - result = curlx_dyn_addn(reqp, - STRCONST("Content-Type: " - "text/parameters\r\n")); + result = curlx_dyn_addn(reqp, STRCONST("Content-Type: " + "text/parameters\r\n")); if(result) return result; } @@ -334,9 +329,8 @@ static CURLcode rtsp_setup_body(struct Curl_easy *data, if(rtspreq == RTSPREQ_ANNOUNCE) { if(!Curl_checkheaders(data, STRCONST("Content-Type"))) { - result = curlx_dyn_addn(reqp, - STRCONST("Content-Type: " - "application/sdp\r\n")); + result = curlx_dyn_addn(reqp, STRCONST("Content-Type: " + "application/sdp\r\n")); if(result) return result; } @@ -931,7 +925,7 @@ static CURLcode rtsp_rtp_write_resp(struct Curl_easy *data, blen, rtspc->in_header, data->req.done, rtspc->state, data->req.size)); if(!result && (is_eos || blen)) { - result = Curl_client_write(data, CLIENTWRITE_BODY| + result = Curl_client_write(data, CLIENTWRITE_BODY | (is_eos ? CLIENTWRITE_EOS : 0), buf, blen); } @@ -954,8 +948,8 @@ static CURLcode rtsp_rtp_write_resp_hd(struct Curl_easy *data, return rtsp_rtp_write_resp(data, buf, blen, is_eos); } -static -CURLcode rtp_client_write(struct Curl_easy *data, const char *ptr, size_t len) +static CURLcode rtp_client_write(struct Curl_easy *data, const char *ptr, + size_t len) { size_t wrote; curl_write_callback writeit; @@ -1066,8 +1060,8 @@ CURLcode Curl_rtsp_parseheader(struct Curl_easy *data, const char *header) return CURLE_OK; } -static -CURLcode rtsp_parse_transport(struct Curl_easy *data, const char *transport) +static CURLcode rtsp_parse_transport(struct Curl_easy *data, + const char *transport) { /* If we receive multiple Transport response-headers, the linterleaved channels of each response header is recorded and used together for @@ -1109,5 +1103,4 @@ CURLcode rtsp_parse_transport(struct Curl_easy *data, const char *transport) return CURLE_OK; } - #endif /* CURL_DISABLE_RTSP */ diff --git a/lib/rtsp.h b/lib/rtsp.h index 59f20a9f1672..7b42efde2860 100644 --- a/lib/rtsp.h +++ b/lib/rtsp.h @@ -32,7 +32,7 @@ CURLcode Curl_rtsp_parseheader(struct Curl_easy *data, const char *header); #else /* disabled */ -#define Curl_rtsp_parseheader(x,y) CURLE_NOT_BUILT_IN +#define Curl_rtsp_parseheader(x, y) CURLE_NOT_BUILT_IN #endif /* CURL_DISABLE_RTSP */ diff --git a/lib/select.c b/lib/select.c index 5692fc020d1f..52dfa7376d0a 100644 --- a/lib/select.c +++ b/lib/select.c @@ -146,19 +146,19 @@ int Curl_socket_check(curl_socket_t readfd0, /* two sockets to read from */ num = 0; if(readfd0 != CURL_SOCKET_BAD) { pfd[num].fd = readfd0; - pfd[num].events = POLLRDNORM|POLLIN|POLLRDBAND|POLLPRI; + pfd[num].events = POLLRDNORM | POLLIN | POLLRDBAND | POLLPRI; pfd[num].revents = 0; num++; } if(readfd1 != CURL_SOCKET_BAD) { pfd[num].fd = readfd1; - pfd[num].events = POLLRDNORM|POLLIN|POLLRDBAND|POLLPRI; + pfd[num].events = POLLRDNORM | POLLIN | POLLRDBAND | POLLPRI; pfd[num].revents = 0; num++; } 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++; } @@ -170,23 +170,23 @@ int Curl_socket_check(curl_socket_t readfd0, /* two sockets to read from */ r = 0; num = 0; if(readfd0 != CURL_SOCKET_BAD) { - if(pfd[num].revents & (POLLRDNORM|POLLIN|POLLERR|POLLHUP)) + if(pfd[num].revents & (POLLRDNORM | POLLIN | POLLERR | POLLHUP)) r |= CURL_CSELECT_IN; - if(pfd[num].revents & (POLLPRI|POLLNVAL)) + if(pfd[num].revents & (POLLPRI | POLLNVAL)) r |= CURL_CSELECT_ERR; num++; } if(readfd1 != CURL_SOCKET_BAD) { - if(pfd[num].revents & (POLLRDNORM|POLLIN|POLLERR|POLLHUP)) + if(pfd[num].revents & (POLLRDNORM | POLLIN | POLLERR | POLLHUP)) r |= CURL_CSELECT_IN2; - if(pfd[num].revents & (POLLPRI|POLLNVAL)) + if(pfd[num].revents & (POLLPRI | POLLNVAL)) r |= CURL_CSELECT_ERR; num++; } if(writefd != CURL_SOCKET_BAD) { - if(pfd[num].revents & (POLLWRNORM|POLLOUT)) + if(pfd[num].revents & (POLLWRNORM | POLLOUT)) r |= CURL_CSELECT_OUT; - if(pfd[num].revents & (POLLERR|POLLHUP|POLLPRI|POLLNVAL)) + if(pfd[num].revents & (POLLERR | POLLHUP | POLLPRI | POLLNVAL)) r |= CURL_CSELECT_ERR; } @@ -265,7 +265,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 */ @@ -280,15 +280,15 @@ int Curl_poll(struct pollfd ufds[], unsigned int nfds, timediff_t timeout_ms) if(ufds[i].fd == CURL_SOCKET_BAD) continue; VERIFY_SOCK(ufds[i].fd); - if(ufds[i].events & (POLLIN|POLLOUT|POLLPRI| - POLLRDNORM|POLLWRNORM|POLLRDBAND)) { + if(ufds[i].events & (POLLIN |POLLOUT |POLLPRI | + POLLRDNORM | POLLWRNORM | POLLRDBAND)) { if(ufds[i].fd > maxfd) maxfd = ufds[i].fd; - if(ufds[i].events & (POLLRDNORM|POLLIN)) + if(ufds[i].events & (POLLRDNORM | POLLIN)) FD_SET(ufds[i].fd, &fds_read); - if(ufds[i].events & (POLLWRNORM|POLLOUT)) + if(ufds[i].events & (POLLWRNORM | POLLOUT)) FD_SET(ufds[i].fd, &fds_write); - if(ufds[i].events & (POLLRDBAND|POLLPRI)) + if(ufds[i].events & (POLLRDBAND | POLLPRI)) FD_SET(ufds[i].fd, &fds_err); } } @@ -579,9 +579,9 @@ CURLcode Curl_pollset_change(struct Curl_easy *data, if(!VALID_SOCK(sock)) return CURLE_BAD_FUNCTION_ARGUMENT; - DEBUGASSERT(add_flags <= (CURL_POLL_IN|CURL_POLL_OUT)); - DEBUGASSERT(remove_flags <= (CURL_POLL_IN|CURL_POLL_OUT)); - DEBUGASSERT((add_flags&remove_flags) == 0); /* no overlap */ + DEBUGASSERT(add_flags <= (CURL_POLL_IN | CURL_POLL_OUT)); + DEBUGASSERT(remove_flags <= (CURL_POLL_IN | CURL_POLL_OUT)); + DEBUGASSERT((add_flags & remove_flags) == 0); /* no overlap */ for(i = 0; i < ps->n; ++i) { if(ps->sockets[i] == sock) { ps->actions[i] &= (unsigned char)(~remove_flags); diff --git a/lib/select.h b/lib/select.h index fb54686af3e2..c5f1c59be02f 100644 --- a/lib/select.h +++ b/lib/select.h @@ -47,11 +47,10 @@ #define POLLHUP 0x10 #define POLLNVAL 0x20 -struct pollfd -{ - curl_socket_t fd; - short events; - short revents; +struct pollfd { + curl_socket_t fd; + short events; + short revents; }; #endif @@ -76,9 +75,9 @@ struct pollfd int Curl_socket_check(curl_socket_t readfd, curl_socket_t readfd2, curl_socket_t writefd, timediff_t timeout_ms); -#define SOCKET_READABLE(x,z) \ +#define SOCKET_READABLE(x, z) \ Curl_socket_check(x, CURL_SOCKET_BAD, CURL_SOCKET_BAD, z) -#define SOCKET_WRITABLE(x,z) \ +#define SOCKET_WRITABLE(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); @@ -90,32 +89,33 @@ int Curl_poll(struct pollfd ufds[], unsigned int nfds, timediff_t timeout_ms); #ifdef USE_WINSOCK #define VALID_SOCK(s) ((s) < INVALID_SOCKET) #define FDSET_SOCK(x) 1 -#define VERIFY_SOCK(x) do { \ - if(!VALID_SOCK(x)) { \ - SET_SOCKERRNO(SOCKEINVAL); \ - return -1; \ - } \ -} while(0) +#define VERIFY_SOCK(x) \ + do { \ + if(!VALID_SOCK(x)) { \ + SET_SOCKERRNO(SOCKEINVAL); \ + return -1; \ + } \ + } while(0) #else #define VALID_SOCK(s) ((s) >= 0) /* If the socket is small enough to get set or read from an fdset */ #define FDSET_SOCK(s) ((s) < FD_SETSIZE) -#define VERIFY_SOCK(x) do { \ - if(!VALID_SOCK(x) || !FDSET_SOCK(x)) { \ - SET_SOCKERRNO(SOCKEINVAL); \ - return -1; \ - } \ +#define VERIFY_SOCK(x) \ + do { \ + if(!VALID_SOCK(x) || !FDSET_SOCK(x)) { \ + SET_SOCKERRNO(SOCKEINVAL); \ + return -1; \ + } \ } while(0) #endif - /* Keep the sockets to poll for an easy handle. * `actions` are bitmaps of CURL_POLL_IN and CURL_POLL_OUT. * Starts with small capacity, grows on demand. */ -#define EZ_POLLSET_DEF_COUNT 2 +#define EZ_POLLSET_DEF_COUNT 2 struct easy_pollset { curl_socket_t *sockets; @@ -133,7 +133,6 @@ struct easy_pollset { #define CURL_EASY_POLLSET_MAGIC 0x7a657370 #endif - /* allocate and initialise */ struct easy_pollset *Curl_pollset_create(void); @@ -162,22 +161,22 @@ CURLcode Curl_pollset_set(struct Curl_easy *data, bool do_in, bool do_out) WARN_UNUSED_RESULT; #define Curl_pollset_add_in(data, ps, sock) \ - Curl_pollset_change((data), (ps), (sock), CURL_POLL_IN, 0) + Curl_pollset_change((data), (ps), (sock), CURL_POLL_IN, 0) #define Curl_pollset_remove_in(data, ps, sock) \ - Curl_pollset_change((data), (ps), (sock), 0, CURL_POLL_IN) + Curl_pollset_change((data), (ps), (sock), 0, CURL_POLL_IN) #define Curl_pollset_add_out(data, ps, sock) \ - Curl_pollset_change((data), (ps), (sock), CURL_POLL_OUT, 0) + Curl_pollset_change((data), (ps), (sock), CURL_POLL_OUT, 0) #define Curl_pollset_remove_out(data, ps, sock) \ - Curl_pollset_change((data), (ps), (sock), 0, CURL_POLL_OUT) + Curl_pollset_change((data), (ps), (sock), 0, CURL_POLL_OUT) #define Curl_pollset_add_inout(data, ps, sock) \ - Curl_pollset_change((data), (ps), (sock), \ - CURL_POLL_IN|CURL_POLL_OUT, 0) + Curl_pollset_change((data), (ps), (sock), \ + CURL_POLL_IN | CURL_POLL_OUT, 0) #define Curl_pollset_set_in_only(data, ps, sock) \ - Curl_pollset_change((data), (ps), (sock), \ - CURL_POLL_IN, CURL_POLL_OUT) + Curl_pollset_change((data), (ps), (sock), \ + CURL_POLL_IN, CURL_POLL_OUT) #define Curl_pollset_set_out_only(data, ps, sock) \ - Curl_pollset_change((data), (ps), (sock), \ - CURL_POLL_OUT, CURL_POLL_IN) + Curl_pollset_change((data), (ps), (sock), \ + CURL_POLL_OUT, CURL_POLL_IN) /* return < = on error, 0 on timeout or how many sockets are ready */ int Curl_pollset_poll(struct Curl_easy *data, diff --git a/lib/sendf.c b/lib/sendf.c index 1d73291c92d2..f4a816e23173 100644 --- a/lib/sendf.c +++ b/lib/sendf.c @@ -69,13 +69,14 @@ CURLcode Curl_client_write(struct Curl_easy *data, CURLcode result; /* it is one of those, at least */ - DEBUGASSERT(type & (CLIENTWRITE_BODY|CLIENTWRITE_HEADER|CLIENTWRITE_INFO)); + DEBUGASSERT(type & + (CLIENTWRITE_BODY | CLIENTWRITE_HEADER | CLIENTWRITE_INFO)); /* BODY is only BODY (with optional EOS) */ DEBUGASSERT(!(type & CLIENTWRITE_BODY) || - ((type & ~(CLIENTWRITE_BODY|CLIENTWRITE_EOS)) == 0)); + ((type & ~(CLIENTWRITE_BODY | CLIENTWRITE_EOS)) == 0)); /* INFO is only INFO (with optional EOS) */ DEBUGASSERT(!(type & CLIENTWRITE_INFO) || - ((type & ~(CLIENTWRITE_INFO|CLIENTWRITE_EOS)) == 0)); + ((type & ~(CLIENTWRITE_INFO | CLIENTWRITE_EOS)) == 0)); if(!data->req.writer_stack) { result = do_init_writer_stack(data); @@ -227,7 +228,7 @@ static CURLcode cw_download_write(struct Curl_easy *data, bool is_connect = !!(type & CLIENTWRITE_CONNECT); if(!ctx->started_response && - !(type & (CLIENTWRITE_INFO|CLIENTWRITE_CONNECT))) { + !(type & (CLIENTWRITE_INFO | CLIENTWRITE_CONNECT))) { Curl_pgrsTime(data, TIMER_STARTTRANSFER); Curl_rlimit_start(&data->progress.dl.rlimit, curlx_now()); ctx->started_response = TRUE; @@ -784,7 +785,7 @@ static CURLcode cr_in_resume_from(struct Curl_easy *data, } /* when seekerr == CURL_SEEKFUNC_CANTSEEK (cannot seek to offset) */ do { - char scratch[4*1024]; + char scratch[4 * 1024]; size_t readthisamountnow = (offset - passed > (curl_off_t)sizeof(scratch)) ? sizeof(scratch) : @@ -1089,8 +1090,7 @@ static CURLcode cr_lc_add(struct Curl_easy *data) struct Curl_creader *reader = NULL; CURLcode result; - result = Curl_creader_create(&reader, data, &cr_lc, - CURL_CR_CONTENT_ENCODE); + result = Curl_creader_create(&reader, data, &cr_lc, CURL_CR_CONTENT_ENCODE); if(!result) result = Curl_creader_add(data, reader); @@ -1481,5 +1481,4 @@ struct Curl_creader *Curl_creader_get_by_type(struct Curl_easy *data, return r; } return NULL; - } diff --git a/lib/sendf.h b/lib/sendf.h index 3a6dccba6a3d..7b983c5271b2 100644 --- a/lib/sendf.h +++ b/lib/sendf.h @@ -42,15 +42,15 @@ * BODY, INFO and HEADER should not be mixed, as this would lead to * confusion on how to interpret/format/convert the data. */ -#define CLIENTWRITE_BODY (1<<0) /* non-meta information, BODY */ -#define CLIENTWRITE_INFO (1<<1) /* meta information, not a HEADER */ -#define CLIENTWRITE_HEADER (1<<2) /* meta information, HEADER */ -#define CLIENTWRITE_STATUS (1<<3) /* a special status HEADER */ -#define CLIENTWRITE_CONNECT (1<<4) /* a CONNECT related HEADER */ -#define CLIENTWRITE_1XX (1<<5) /* a 1xx response related HEADER */ -#define CLIENTWRITE_TRAILER (1<<6) /* a trailer HEADER */ -#define CLIENTWRITE_EOS (1<<7) /* End Of transfer download Stream */ -#define CLIENTWRITE_0LEN (1<<8) /* write even 0-length buffers */ +#define CLIENTWRITE_BODY (1 << 0) /* non-meta information, BODY */ +#define CLIENTWRITE_INFO (1 << 1) /* meta information, not a HEADER */ +#define CLIENTWRITE_HEADER (1 << 2) /* meta information, HEADER */ +#define CLIENTWRITE_STATUS (1 << 3) /* a special status HEADER */ +#define CLIENTWRITE_CONNECT (1 << 4) /* a CONNECT related HEADER */ +#define CLIENTWRITE_1XX (1 << 5) /* a 1xx response related HEADER */ +#define CLIENTWRITE_TRAILER (1 << 6) /* a trailer HEADER */ +#define CLIENTWRITE_EOS (1 << 7) /* End Of transfer download Stream */ +#define CLIENTWRITE_0LEN (1 << 8) /* write even 0-length buffers */ /* Forward declarations */ struct Curl_creader; @@ -206,7 +206,6 @@ CURLcode Curl_cwriter_def_write(struct Curl_easy *data, void Curl_cwriter_def_close(struct Curl_easy *data, struct Curl_cwriter *writer); - typedef enum { CURL_CRCNTRL_REWIND, CURL_CRCNTRL_UNPAUSE, @@ -407,7 +406,6 @@ void Curl_creader_done(struct Curl_easy *data, int premature); struct Curl_creader *Curl_creader_get_by_type(struct Curl_easy *data, const struct Curl_crtype *crt); - /** * Set the client reader to provide 0 bytes, immediate EOS. */ diff --git a/lib/setopt.c b/lib/setopt.c index b4ca361ce35f..0a377be1f165 100644 --- a/lib/setopt.c +++ b/lib/setopt.c @@ -59,8 +59,8 @@ static CURLcode setopt_set_timeout_sec(timediff_t *ptimeout_ms, long secs) { if(secs < 0) return CURLE_BAD_FUNCTION_ARGUMENT; -#if LONG_MAX > (TIMEDIFF_T_MAX/1000) - if(secs > (TIMEDIFF_T_MAX/1000)) { +#if LONG_MAX > (TIMEDIFF_T_MAX / 1000) + if(secs > (TIMEDIFF_T_MAX / 1000)) { *ptimeout_ms = TIMEDIFF_T_MAX; return CURLE_OK; } @@ -193,7 +193,7 @@ static CURLcode setstropt_interface(char *option, char **devp, return CURLE_OK; } -#define C_SSLVERSION_VALUE(x) (x & 0xffff) +#define C_SSLVERSION_VALUE(x) (x & 0xffff) #define C_SSLVERSION_MAX_VALUE(x) ((unsigned long)x & 0xffff0000) static CURLcode protocol2num(const char *str, curl_prot_t *val) @@ -208,7 +208,7 @@ static CURLcode protocol2num(const char *str, curl_prot_t *val) return CURLE_BAD_FUNCTION_ARGUMENT; if(curl_strequal(str, "all")) { - *val = ~(curl_prot_t) 0; + *val = ~(curl_prot_t)0; return CURLE_OK; } @@ -217,7 +217,7 @@ static CURLcode protocol2num(const char *str, curl_prot_t *val) size_t tlen; str = strchr(str, ','); - tlen = str ? (size_t) (str - token) : strlen(token); + tlen = str ? (size_t)(str - token) : strlen(token); if(tlen) { const struct Curl_handler *h = Curl_getn_scheme_handler(token, tlen); @@ -256,7 +256,7 @@ static CURLcode httpauth(struct Curl_easy *data, bool proxy, /* switch off bits we cannot support */ #ifndef USE_NTLM - auth &= ~CURLAUTH_NTLM; /* no NTLM support */ + auth &= ~CURLAUTH_NTLM; /* no NTLM support */ #endif #ifndef USE_SPNEGO auth &= ~CURLAUTH_NEGOTIATE; /* no Negotiate (SPNEGO) auth without GSS-API @@ -787,8 +787,7 @@ static CURLcode setopt_bool(struct Curl_easy *data, CURLoption option, case CURLOPT_SSL_SESSIONID_CACHE: s->ssl.primary.cache_session = enabled; #ifndef CURL_DISABLE_PROXY - s->proxy_ssl.primary.cache_session = - s->ssl.primary.cache_session; + s->proxy_ssl.primary.cache_session = s->ssl.primary.cache_session; #endif break; #ifdef USE_SSH @@ -810,7 +809,7 @@ static CURLcode setopt_bool(struct Curl_easy *data, CURLoption option, s->tcp_keepalive = enabled; break; case CURLOPT_TCP_FASTOPEN: -#if defined(CONNECT_DATA_IDEMPOTENT) || defined(MSG_FASTOPEN) || \ +#if defined(CONNECT_DATA_IDEMPOTENT) || defined(MSG_FASTOPEN) || \ defined(TCP_FASTOPEN_CONNECT) s->tcp_fastopen = enabled; break; @@ -1099,7 +1098,7 @@ static CURLcode setopt_long(struct Curl_easy *data, CURLoption option, #ifdef HAVE_GSSAPI case CURLOPT_GSSAPI_DELEGATION: s->gssapi_delegation = (unsigned char)uarg & - (CURLGSSAPI_DELEGATION_POLICY_FLAG|CURLGSSAPI_DELEGATION_FLAG); + (CURLGSSAPI_DELEGATION_POLICY_FLAG | CURLGSSAPI_DELEGATION_FLAG); break; #endif @@ -1145,7 +1144,7 @@ static CURLcode setopt_long(struct Curl_easy *data, CURLoption option, case CURLOPT_IPRESOLVE: if((arg < CURL_IPRESOLVE_WHATEVER) || (arg > CURL_IPRESOLVE_V6)) return CURLE_BAD_FUNCTION_ARGUMENT; - s->ipver = (unsigned char) arg; + s->ipver = (unsigned char)arg; break; case CURLOPT_CONNECT_ONLY: @@ -1413,8 +1412,8 @@ static CURLcode setopt_pointers(struct Curl_easy *data, CURLoption option, break; #endif /* ! CURL_DISABLE_FORM_API */ #endif /* ! CURL_DISABLE_HTTP */ -#if !defined(CURL_DISABLE_HTTP) || !defined(CURL_DISABLE_SMTP) || \ - !defined(CURL_DISABLE_IMAP) +#if !defined(CURL_DISABLE_HTTP) || !defined(CURL_DISABLE_SMTP) || \ + !defined(CURL_DISABLE_IMAP) # ifndef CURL_DISABLE_MIME case CURLOPT_MIMEPOST: /* @@ -1444,8 +1443,7 @@ static CURLcode setopt_pointers(struct Curl_easy *data, CURLoption option, if(!s->err) s->err = stderr; break; - case CURLOPT_SHARE: - { + case CURLOPT_SHARE: { struct Curl_share *set = va_arg(param, struct Curl_share *); /* disconnect from old share, if any */ @@ -1492,7 +1490,7 @@ static CURLcode setopt_pointers(struct Curl_easy *data, CURLoption option, /* enable cookies since we now use a share that uses cookies! */ data->cookies = data->share->cookies; } -#endif /* CURL_DISABLE_HTTP */ +#endif /* CURL_DISABLE_HTTP */ #ifndef CURL_DISABLE_HSTS if(data->share->hsts) { /* first free the private one if any */ @@ -1509,8 +1507,8 @@ static CURLcode setopt_pointers(struct Curl_easy *data, CURLoption option, } /* check for host cache not needed, * it will be done by curl_easy_perform */ + break; } - break; #ifdef USE_HTTP2 case CURLOPT_STREAM_DEPENDS: @@ -1530,8 +1528,7 @@ static CURLcode setopt_pointers(struct Curl_easy *data, CURLoption option, } #ifndef CURL_DISABLE_COOKIES -static CURLcode cookielist(struct Curl_easy *data, - const char *ptr) +static CURLcode cookielist(struct Curl_easy *data, const char *ptr) { CURLcode result = CURLE_OK; if(!ptr) @@ -1584,8 +1581,7 @@ static CURLcode cookielist(struct Curl_easy *data, return result; } -static CURLcode cookiefile(struct Curl_easy *data, - const char *ptr) +static CURLcode cookiefile(struct Curl_easy *data, const char *ptr) { /* * Set cookie file to read and parse. Can be used multiple times. @@ -1639,8 +1635,7 @@ static CURLcode setopt_cptr(struct Curl_easy *data, CURLoption option, case CURLOPT_PROXY_SSL_CIPHER_LIST: if(Curl_ssl_supports(data, SSLSUPP_CIPHER_LIST)) { /* set a list of cipher we want to use in the SSL connection for proxy */ - return Curl_setstropt(&s->str[STRING_SSL_CIPHER_LIST_PROXY], - ptr); + return Curl_setstropt(&s->str[STRING_SSL_CIPHER_LIST_PROXY], ptr); } else return CURLE_NOT_BUILT_IN; @@ -1656,8 +1651,7 @@ static CURLcode setopt_cptr(struct Curl_easy *data, CURLoption option, case CURLOPT_PROXY_TLS13_CIPHERS: if(Curl_ssl_supports(data, SSLSUPP_TLS13_CIPHERSUITES)) /* set preferred list of TLS 1.3 cipher suites for proxy */ - return Curl_setstropt(&s->str[STRING_SSL_CIPHER13_LIST_PROXY], - ptr); + return Curl_setstropt(&s->str[STRING_SSL_CIPHER13_LIST_PROXY], ptr); else return CURLE_NOT_BUILT_IN; #endif @@ -1841,7 +1835,7 @@ static CURLcode setopt_cptr(struct Curl_easy *data, CURLoption option, * to use the socks proxy. */ return Curl_setstropt(&s->str[STRING_PRE_PROXY], ptr); -#endif /* CURL_DISABLE_PROXY */ +#endif /* CURL_DISABLE_PROXY */ #ifndef CURL_DISABLE_PROXY case CURLOPT_SOCKS5_GSSAPI_SERVICE: @@ -2038,8 +2032,8 @@ static CURLcode setopt_cptr(struct Curl_easy *data, CURLoption option, } curlx_free(u); curlx_free(p); - } break; + } case CURLOPT_PROXYUSERNAME: /* * authentication username to use in the operation @@ -2201,8 +2195,7 @@ static CURLcode setopt_cptr(struct Curl_easy *data, CURLoption option, */ #ifdef USE_SSL if(Curl_ssl_supports(data, SSLSUPP_PINNEDPUBKEY)) - return Curl_setstropt(&s->str[STRING_SSL_PINNEDPUBLICKEY_PROXY], - ptr); + return Curl_setstropt(&s->str[STRING_SSL_PINNEDPUBLICKEY_PROXY], ptr); #endif return CURLE_NOT_BUILT_IN; #endif @@ -2304,8 +2297,7 @@ static CURLcode setopt_cptr(struct Curl_easy *data, CURLoption option, * Specify colon-delimited list of signature scheme names. */ if(Curl_ssl_supports(data, SSLSUPP_SIGNATURE_ALGORITHMS)) - return Curl_setstropt(&s->str[STRING_SSL_SIGNATURE_ALGORITHMS], - ptr); + return Curl_setstropt(&s->str[STRING_SSL_SIGNATURE_ALGORITHMS], ptr); return CURLE_NOT_BUILT_IN; #endif #ifdef USE_SSH @@ -2347,8 +2339,7 @@ static CURLcode setopt_cptr(struct Curl_easy *data, CURLoption option, * Option to allow for the SHA256 of the host public key to be checked * for validation purposes. */ - return Curl_setstropt(&s->str[STRING_SSH_HOST_PUBLIC_KEY_SHA256], - ptr); + return Curl_setstropt(&s->str[STRING_SSH_HOST_PUBLIC_KEY_SHA256], ptr); case CURLOPT_SSH_HOSTKEYDATA: /* @@ -2367,7 +2358,7 @@ static CURLcode setopt_cptr(struct Curl_easy *data, CURLoption option, } else /* make a NULL argument reset to default */ - s->allowed_protocols = (curl_prot_t) CURLPROTO_ALL; + s->allowed_protocols = (curl_prot_t)CURLPROTO_ALL; break; case CURLOPT_REDIR_PROTOCOLS_STR: @@ -2379,7 +2370,7 @@ static CURLcode setopt_cptr(struct Curl_easy *data, CURLoption option, } else /* make a NULL argument reset to default */ - s->redir_protocols = (curl_prot_t) CURLPROTO_REDIR; + s->redir_protocols = (curl_prot_t)CURLPROTO_REDIR; break; case CURLOPT_DEFAULT_PROTOCOL: @@ -2571,17 +2562,13 @@ static CURLcode setopt_cptr(struct Curl_easy *data, CURLoption option, } /* set tls_ech flag value, preserving CLA_CFG bit */ if(!strcmp(ptr, "false")) - s->tls_ech = CURLECH_DISABLE | - (s->tls_ech & CURLECH_CLA_CFG); + s->tls_ech = (s->tls_ech & CURLECH_CLA_CFG) | CURLECH_DISABLE; else if(!strcmp(ptr, "grease")) - s->tls_ech = CURLECH_GREASE | - (s->tls_ech & CURLECH_CLA_CFG); + s->tls_ech = (s->tls_ech & CURLECH_CLA_CFG) | CURLECH_GREASE; else if(!strcmp(ptr, "true")) - s->tls_ech = CURLECH_ENABLE | - (s->tls_ech & CURLECH_CLA_CFG); + s->tls_ech = (s->tls_ech & CURLECH_CLA_CFG) | CURLECH_ENABLE; else if(!strcmp(ptr, "hard")) - s->tls_ech = CURLECH_HARD | - (s->tls_ech & CURLECH_CLA_CFG); + s->tls_ech = (s->tls_ech & CURLECH_CLA_CFG) | CURLECH_HARD; else if(plen > 5 && !strncmp(ptr, "ecl:", 4)) { result = Curl_setstropt(&s->str[STRING_ECH_CONFIG], ptr + 4); if(result) @@ -2908,8 +2895,7 @@ static CURLcode setopt_blob(struct Curl_easy *data, CURLoption option, /* * Blob that holds Issuer certificate to check certificates issuer */ - return Curl_setblobopt(&s->blobs[BLOB_SSL_ISSUERCERT_PROXY], - blob); + return Curl_setblobopt(&s->blobs[BLOB_SSL_ISSUERCERT_PROXY], blob); #endif case CURLOPT_SSLKEY_BLOB: /* diff --git a/lib/setopt.h b/lib/setopt.h index c323dd74a379..0dd60c785f93 100644 --- a/lib/setopt.h +++ b/lib/setopt.h @@ -28,7 +28,7 @@ CURLcode Curl_setopt_SSLVERSION(struct Curl_easy *data, CURLoption option, long arg); #else -#define Curl_setopt_SSLVERSION(a,b,c) CURLE_NOT_BUILT_IN +#define Curl_setopt_SSLVERSION(a, b, c) CURLE_NOT_BUILT_IN #endif CURLcode Curl_setstropt(char **charp, const char *s) WARN_UNUSED_RESULT; diff --git a/lib/setup-os400.h b/lib/setup-os400.h index ef7baca67eff..01f939951008 100644 --- a/lib/setup-os400.h +++ b/lib/setup-os400.h @@ -24,7 +24,6 @@ * ***************************************************************************/ - /* OS/400 netdb.h does not define NI_MAXHOST. */ #define NI_MAXHOST 1025 @@ -37,15 +36,13 @@ typedef unsigned long u_int32_t; /* OS/400 has no idea of a tty! */ #define isatty(fd) 0 - /* Workaround bug in IBM QADRT runtime library: * function puts() does not output the implicit trailing newline. */ #include /* Be sure it is loaded. */ #undef puts -#define puts(s) (fputs((s), stdout) == EOF? EOF: putchar('\n')) - +#define puts(s) (fputs((s), stdout) == EOF ? EOF : putchar('\n')) /* System API wrapper prototypes & definitions to support ASCII parameters. */ @@ -105,8 +102,8 @@ extern OM_uint32 Curl_gss_init_sec_context_a(OM_uint32 * minor_status, #define gss_init_sec_context Curl_gss_init_sec_context_a -extern OM_uint32 Curl_gss_delete_sec_context_a(OM_uint32 * minor_status, - gss_ctx_id_t * context_handle, +extern OM_uint32 Curl_gss_delete_sec_context_a(OM_uint32 *minor_status, + gss_ctx_id_t *context_handle, gss_buffer_t output_token); #define gss_delete_sec_context Curl_gss_delete_sec_context_a diff --git a/lib/setup-vms.h b/lib/setup-vms.h index e3777ded6e10..17bf5a07a26d 100644 --- a/lib/setup-vms.h +++ b/lib/setup-vms.h @@ -38,9 +38,9 @@ /* Hide the stuff we are overriding */ #define getenv decc_getenv #ifdef __DECC -# if __INITIAL_POINTER_SIZE != 64 -# define getpwuid decc_getpwuid -# endif +# if __INITIAL_POINTER_SIZE != 64 +# define getpwuid decc_getpwuid +# endif #endif #include char *decc$getenv(const char *__name); @@ -51,34 +51,34 @@ char *decc$getenv(const char *__name); #undef getenv #undef getpwuid -#define getenv vms_getenv +#define getenv vms_getenv #define getpwuid vms_getpwuid /* VAX needs these in upper case when compiling exact case */ #define sys$assign SYS$ASSIGN #define sys$dassgn SYS$DASSGN -#define sys$qiow SYS$QIOW +#define sys$qiow SYS$QIOW #ifdef __DECC -# if __INITIAL_POINTER_SIZE -# pragma __pointer_size __save -# endif +# if __INITIAL_POINTER_SIZE +# pragma __pointer_size __save +# endif #endif #if __USE_LONG_GID_T -# define decc_getpwuid DECC$__LONG_GID_GETPWUID +# define decc_getpwuid DECC$__LONG_GID_GETPWUID #else -# if __INITIAL_POINTER_SIZE -# define decc_getpwuid decc$__32_getpwuid -# else -# define decc_getpwuid decc$getpwuid -# endif +# if __INITIAL_POINTER_SIZE +# define decc_getpwuid decc$__32_getpwuid +# else +# define decc_getpwuid decc$getpwuid +# endif #endif - struct passwd *decc_getpwuid(uid_t uid); +struct passwd *decc_getpwuid(uid_t uid); #ifdef __DECC -# if __INITIAL_POINTER_SIZE == 32 +# if __INITIAL_POINTER_SIZE == 32 /* Translate the path, but only if the path is a VMS file specification */ /* The translation is usually only needed for older versions of VMS */ static char *vms_translate_path(const char *path) @@ -100,18 +100,18 @@ static char *vms_translate_path(const char *path) return (char *)path; } } -# else - /* VMS translate path is actually not needed on the current 64-bit */ - /* VMS platforms, so instead of figuring out the pointer settings */ - /* Change it to a noop */ -# define vms_translate_path(__path) __path -# endif +# else + /* VMS translate path is actually not needed on the current 64-bit */ + /* VMS platforms, so instead of figuring out the pointer settings */ + /* Change it to a noop */ +# define vms_translate_path(__path) __path +# endif #endif #ifdef __DECC -# if __INITIAL_POINTER_SIZE -# pragma __pointer_size __restore -# endif +# if __INITIAL_POINTER_SIZE +# pragma __pointer_size __restore +# endif #endif static char *vms_getenv(const char *envvar) @@ -137,7 +137,6 @@ static char *vms_getenv(const char *envvar) return result; } - static struct passwd vms_passwd_cache; static struct passwd *vms_getpwuid(uid_t uid) @@ -146,11 +145,11 @@ static struct passwd *vms_getpwuid(uid_t uid) /* Hack needed to support 64-bit builds, decc_getpwnam is 32-bit only */ #ifdef __DECC -# if __INITIAL_POINTER_SIZE +# if __INITIAL_POINTER_SIZE __char_ptr32 unix_path; -# else +# else char *unix_path; -# endif +# endif #else char *unix_path; #endif @@ -191,181 +190,181 @@ static struct passwd *vms_getpwuid(uid_t uid) /* Bug - VMS OpenSSL and Kerberos universal symbols are in uppercase only */ /* VMS libraries should have universal symbols in exact and uppercase */ -#define ASN1_INTEGER_get ASN1_INTEGER_GET -#define ASN1_STRING_data ASN1_STRING_DATA -#define ASN1_STRING_length ASN1_STRING_LENGTH -#define ASN1_STRING_print ASN1_STRING_PRINT -#define ASN1_STRING_to_UTF8 ASN1_STRING_TO_UTF8 -#define ASN1_STRING_type ASN1_STRING_TYPE -#define BIO_ctrl BIO_CTRL -#define BIO_free BIO_FREE -#define BIO_new BIO_NEW -#define BIO_s_mem BIO_S_MEM -#define BN_bn2bin BN_BN2BIN -#define BN_num_bits BN_NUM_BITS +#define ASN1_INTEGER_get ASN1_INTEGER_GET +#define ASN1_STRING_data ASN1_STRING_DATA +#define ASN1_STRING_length ASN1_STRING_LENGTH +#define ASN1_STRING_print ASN1_STRING_PRINT +#define ASN1_STRING_to_UTF8 ASN1_STRING_TO_UTF8 +#define ASN1_STRING_type ASN1_STRING_TYPE +#define BIO_ctrl BIO_CTRL +#define BIO_free BIO_FREE +#define BIO_new BIO_NEW +#define BIO_s_mem BIO_S_MEM +#define BN_bn2bin BN_BN2BIN +#define BN_num_bits BN_NUM_BITS #define CRYPTO_cleanup_all_ex_data CRYPTO_CLEANUP_ALL_EX_DATA -#define CRYPTO_free CRYPTO_FREE -#define CRYPTO_malloc CRYPTO_MALLOC -#define CONF_modules_load_file CONF_MODULES_LOAD_FILE +#define CRYPTO_free CRYPTO_FREE +#define CRYPTO_malloc CRYPTO_MALLOC +#define CONF_modules_load_file CONF_MODULES_LOAD_FILE #ifdef __VAX # ifdef VMS_OLD_SSL /* Ancient OpenSSL on VAX/VMS missing this constant */ # define CONF_MFLAGS_IGNORE_MISSING_FILE 0x10 # undef CONF_modules_load_file - static int CONF_modules_load_file(const char *filename, - const char *appname, - unsigned long flags) { - return 1; - } +static int CONF_modules_load_file(const char *filename, + const char *appname, + unsigned long flags) { + return 1; +} # endif #endif -#define DES_ecb_encrypt DES_ECB_ENCRYPT -#define DES_set_key DES_SET_KEY -#define DES_set_odd_parity DES_SET_ODD_PARITY -#define ENGINE_ctrl ENGINE_CTRL -#define ENGINE_ctrl_cmd ENGINE_CTRL_CMD -#define ENGINE_finish ENGINE_FINISH -#define ENGINE_free ENGINE_FREE -#define ENGINE_get_first ENGINE_GET_FIRST -#define ENGINE_get_id ENGINE_GET_ID -#define ENGINE_get_next ENGINE_GET_NEXT -#define ENGINE_init ENGINE_INIT +#define DES_ecb_encrypt DES_ECB_ENCRYPT +#define DES_set_key DES_SET_KEY +#define DES_set_odd_parity DES_SET_ODD_PARITY +#define ENGINE_ctrl ENGINE_CTRL +#define ENGINE_ctrl_cmd ENGINE_CTRL_CMD +#define ENGINE_finish ENGINE_FINISH +#define ENGINE_free ENGINE_FREE +#define ENGINE_get_first ENGINE_GET_FIRST +#define ENGINE_get_id ENGINE_GET_ID +#define ENGINE_get_next ENGINE_GET_NEXT +#define ENGINE_init ENGINE_INIT #define ENGINE_load_builtin_engines ENGINE_LOAD_BUILTIN_ENGINES -#define ENGINE_load_private_key ENGINE_LOAD_PRIVATE_KEY -#define ENGINE_set_default ENGINE_SET_DEFAULT -#define ERR_clear_error ERR_CLEAR_ERROR -#define ERR_error_string ERR_ERROR_STRING -#define ERR_error_string_n ERR_ERROR_STRING_N -#define ERR_free_strings ERR_FREE_STRINGS -#define ERR_get_error ERR_GET_ERROR -#define ERR_peek_error ERR_PEEK_ERROR -#define ERR_remove_state ERR_REMOVE_STATE -#define EVP_PKEY_copy_parameters EVP_PKEY_COPY_PARAMETERS -#define EVP_PKEY_free EVP_PKEY_FREE -#define EVP_cleanup EVP_CLEANUP -#define GENERAL_NAMES_free GENERAL_NAMES_FREE -#define i2d_X509_PUBKEY I2D_X509_PUBKEY -#define MD4_Final MD4_FINAL -#define MD4_Init MD4_INIT -#define MD4_Update MD4_UPDATE -#define MD5_Final MD5_FINAL -#define MD5_Init MD5_INIT -#define MD5_Update MD5_UPDATE +#define ENGINE_load_private_key ENGINE_LOAD_PRIVATE_KEY +#define ENGINE_set_default ENGINE_SET_DEFAULT +#define ERR_clear_error ERR_CLEAR_ERROR +#define ERR_error_string ERR_ERROR_STRING +#define ERR_error_string_n ERR_ERROR_STRING_N +#define ERR_free_strings ERR_FREE_STRINGS +#define ERR_get_error ERR_GET_ERROR +#define ERR_peek_error ERR_PEEK_ERROR +#define ERR_remove_state ERR_REMOVE_STATE +#define EVP_PKEY_copy_parameters EVP_PKEY_COPY_PARAMETERS +#define EVP_PKEY_free EVP_PKEY_FREE +#define EVP_cleanup EVP_CLEANUP +#define GENERAL_NAMES_free GENERAL_NAMES_FREE +#define i2d_X509_PUBKEY I2D_X509_PUBKEY +#define MD4_Final MD4_FINAL +#define MD4_Init MD4_INIT +#define MD4_Update MD4_UPDATE +#define MD5_Final MD5_FINAL +#define MD5_Init MD5_INIT +#define MD5_Update MD5_UPDATE #define OPENSSL_add_all_algo_noconf OPENSSL_ADD_ALL_ALGO_NOCONF #ifndef __VAX #define OPENSSL_load_builtin_modules OPENSSL_LOAD_BUILTIN_MODULES #endif -#define PEM_read_X509 PEM_READ_X509 -#define PEM_write_bio_X509 PEM_WRITE_BIO_X509 -#define PKCS12_free PKCS12_FREE -#define PKCS12_parse PKCS12_PARSE -#define RAND_add RAND_ADD -#define RAND_bytes RAND_BYTES -#define RAND_file_name RAND_FILE_NAME -#define RAND_load_file RAND_LOAD_FILE -#define RAND_status RAND_STATUS -#define SSL_CIPHER_get_name SSL_CIPHER_GET_NAME -#define SSL_CTX_add_client_CA SSL_CTX_ADD_CLIENT_CA -#define SSL_CTX_callback_ctrl SSL_CTX_CALLBACK_CTRL -#define SSL_CTX_check_private_key SSL_CTX_CHECK_PRIVATE_KEY -#define SSL_CTX_ctrl SSL_CTX_CTRL -#define SSL_CTX_free SSL_CTX_FREE -#define SSL_CTX_get_cert_store SSL_CTX_GET_CERT_STORE -#define SSL_CTX_load_verify_locations SSL_CTX_LOAD_VERIFY_LOCATIONS -#define SSL_CTX_new SSL_CTX_NEW -#define SSL_CTX_set_cipher_list SSL_CTX_SET_CIPHER_LIST -#define SSL_CTX_set_def_passwd_cb_ud SSL_CTX_SET_DEF_PASSWD_CB_UD -#define SSL_CTX_set_default_passwd_cb SSL_CTX_SET_DEFAULT_PASSWD_CB -#define SSL_CTX_set_msg_callback SSL_CTX_SET_MSG_CALLBACK -#define SSL_CTX_set_verify SSL_CTX_SET_VERIFY -#define SSL_CTX_use_PrivateKey SSL_CTX_USE_PRIVATEKEY -#define SSL_CTX_use_PrivateKey_file SSL_CTX_USE_PRIVATEKEY_FILE -#define SSL_CTX_use_cert_chain_file SSL_CTX_USE_CERT_CHAIN_FILE -#define SSL_CTX_use_certificate SSL_CTX_USE_CERTIFICATE -#define SSL_CTX_use_certificate_file SSL_CTX_USE_CERTIFICATE_FILE -#define SSL_SESSION_free SSL_SESSION_FREE -#define SSL_connect SSL_CONNECT -#define SSL_free SSL_FREE -#define SSL_get1_session SSL_GET1_SESSION -#define SSL_get_certificate SSL_GET_CERTIFICATE -#define SSL_get_current_cipher SSL_GET_CURRENT_CIPHER -#define SSL_get_error SSL_GET_ERROR -#define SSL_get_peer_cert_chain SSL_GET_PEER_CERT_CHAIN -#define SSL_get_peer_certificate SSL_GET_PEER_CERTIFICATE -#define SSL_get_privatekey SSL_GET_PRIVATEKEY -#define SSL_get_session SSL_GET_SESSION -#define SSL_get_shutdown SSL_GET_SHUTDOWN -#define SSL_get_verify_result SSL_GET_VERIFY_RESULT -#define SSL_library_init SSL_LIBRARY_INIT -#define SSL_load_error_strings SSL_LOAD_ERROR_STRINGS -#define SSL_new SSL_NEW -#define SSL_peek SSL_PEEK -#define SSL_pending SSL_PENDING -#define SSL_read SSL_READ -#define SSL_set_connect_state SSL_SET_CONNECT_STATE -#define SSL_set_fd SSL_SET_FD -#define SSL_set_session SSL_SET_SESSION -#define SSL_shutdown SSL_SHUTDOWN -#define SSL_version SSL_VERSION -#define SSL_write SSL_WRITE -#define SSLeay SSLEAY -#define SSLv23_client_method SSLV23_CLIENT_METHOD -#define SSLv3_client_method SSLV3_CLIENT_METHOD -#define TLSv1_client_method TLSV1_CLIENT_METHOD -#define UI_create_method UI_CREATE_METHOD -#define UI_destroy_method UI_DESTROY_METHOD -#define UI_get0_user_data UI_GET0_USER_DATA -#define UI_get_input_flags UI_GET_INPUT_FLAGS -#define UI_get_string_type UI_GET_STRING_TYPE -#define UI_create_method UI_CREATE_METHOD -#define UI_destroy_method UI_DESTROY_METHOD -#define UI_method_get_closer UI_METHOD_GET_CLOSER -#define UI_method_get_opener UI_METHOD_GET_OPENER -#define UI_method_get_reader UI_METHOD_GET_READER -#define UI_method_get_writer UI_METHOD_GET_WRITER -#define UI_method_set_closer UI_METHOD_SET_CLOSER -#define UI_method_set_opener UI_METHOD_SET_OPENER -#define UI_method_set_reader UI_METHOD_SET_READER -#define UI_method_set_writer UI_METHOD_SET_WRITER -#define UI_OpenSSL UI_OPENSSL -#define UI_set_result UI_SET_RESULT -#define X509V3_EXT_print X509V3_EXT_PRINT -#define X509_EXTENSION_get_critical X509_EXTENSION_GET_CRITICAL -#define X509_EXTENSION_get_data X509_EXTENSION_GET_DATA -#define X509_EXTENSION_get_object X509_EXTENSION_GET_OBJECT -#define X509_LOOKUP_file X509_LOOKUP_FILE -#define X509_NAME_ENTRY_get_data X509_NAME_ENTRY_GET_DATA -#define X509_NAME_get_entry X509_NAME_GET_ENTRY -#define X509_NAME_get_index_by_NID X509_NAME_GET_INDEX_BY_NID -#define X509_NAME_print_ex X509_NAME_PRINT_EX +#define PEM_read_X509 PEM_READ_X509 +#define PEM_write_bio_X509 PEM_WRITE_BIO_X509 +#define PKCS12_free PKCS12_FREE +#define PKCS12_parse PKCS12_PARSE +#define RAND_add RAND_ADD +#define RAND_bytes RAND_BYTES +#define RAND_file_name RAND_FILE_NAME +#define RAND_load_file RAND_LOAD_FILE +#define RAND_status RAND_STATUS +#define SSL_CIPHER_get_name SSL_CIPHER_GET_NAME +#define SSL_CTX_add_client_CA SSL_CTX_ADD_CLIENT_CA +#define SSL_CTX_callback_ctrl SSL_CTX_CALLBACK_CTRL +#define SSL_CTX_check_private_key SSL_CTX_CHECK_PRIVATE_KEY +#define SSL_CTX_ctrl SSL_CTX_CTRL +#define SSL_CTX_free SSL_CTX_FREE +#define SSL_CTX_get_cert_store SSL_CTX_GET_CERT_STORE +#define SSL_CTX_load_verify_locations SSL_CTX_LOAD_VERIFY_LOCATIONS +#define SSL_CTX_new SSL_CTX_NEW +#define SSL_CTX_set_cipher_list SSL_CTX_SET_CIPHER_LIST +#define SSL_CTX_set_def_passwd_cb_ud SSL_CTX_SET_DEF_PASSWD_CB_UD +#define SSL_CTX_set_default_passwd_cb SSL_CTX_SET_DEFAULT_PASSWD_CB +#define SSL_CTX_set_msg_callback SSL_CTX_SET_MSG_CALLBACK +#define SSL_CTX_set_verify SSL_CTX_SET_VERIFY +#define SSL_CTX_use_PrivateKey SSL_CTX_USE_PRIVATEKEY +#define SSL_CTX_use_PrivateKey_file SSL_CTX_USE_PRIVATEKEY_FILE +#define SSL_CTX_use_cert_chain_file SSL_CTX_USE_CERT_CHAIN_FILE +#define SSL_CTX_use_certificate SSL_CTX_USE_CERTIFICATE +#define SSL_CTX_use_certificate_file SSL_CTX_USE_CERTIFICATE_FILE +#define SSL_SESSION_free SSL_SESSION_FREE +#define SSL_connect SSL_CONNECT +#define SSL_free SSL_FREE +#define SSL_get1_session SSL_GET1_SESSION +#define SSL_get_certificate SSL_GET_CERTIFICATE +#define SSL_get_current_cipher SSL_GET_CURRENT_CIPHER +#define SSL_get_error SSL_GET_ERROR +#define SSL_get_peer_cert_chain SSL_GET_PEER_CERT_CHAIN +#define SSL_get_peer_certificate SSL_GET_PEER_CERTIFICATE +#define SSL_get_privatekey SSL_GET_PRIVATEKEY +#define SSL_get_session SSL_GET_SESSION +#define SSL_get_shutdown SSL_GET_SHUTDOWN +#define SSL_get_verify_result SSL_GET_VERIFY_RESULT +#define SSL_library_init SSL_LIBRARY_INIT +#define SSL_load_error_strings SSL_LOAD_ERROR_STRINGS +#define SSL_new SSL_NEW +#define SSL_peek SSL_PEEK +#define SSL_pending SSL_PENDING +#define SSL_read SSL_READ +#define SSL_set_connect_state SSL_SET_CONNECT_STATE +#define SSL_set_fd SSL_SET_FD +#define SSL_set_session SSL_SET_SESSION +#define SSL_shutdown SSL_SHUTDOWN +#define SSL_version SSL_VERSION +#define SSL_write SSL_WRITE +#define SSLeay SSLEAY +#define SSLv23_client_method SSLV23_CLIENT_METHOD +#define SSLv3_client_method SSLV3_CLIENT_METHOD +#define TLSv1_client_method TLSV1_CLIENT_METHOD +#define UI_create_method UI_CREATE_METHOD +#define UI_destroy_method UI_DESTROY_METHOD +#define UI_get0_user_data UI_GET0_USER_DATA +#define UI_get_input_flags UI_GET_INPUT_FLAGS +#define UI_get_string_type UI_GET_STRING_TYPE +#define UI_create_method UI_CREATE_METHOD +#define UI_destroy_method UI_DESTROY_METHOD +#define UI_method_get_closer UI_METHOD_GET_CLOSER +#define UI_method_get_opener UI_METHOD_GET_OPENER +#define UI_method_get_reader UI_METHOD_GET_READER +#define UI_method_get_writer UI_METHOD_GET_WRITER +#define UI_method_set_closer UI_METHOD_SET_CLOSER +#define UI_method_set_opener UI_METHOD_SET_OPENER +#define UI_method_set_reader UI_METHOD_SET_READER +#define UI_method_set_writer UI_METHOD_SET_WRITER +#define UI_OpenSSL UI_OPENSSL +#define UI_set_result UI_SET_RESULT +#define X509V3_EXT_print X509V3_EXT_PRINT +#define X509_EXTENSION_get_critical X509_EXTENSION_GET_CRITICAL +#define X509_EXTENSION_get_data X509_EXTENSION_GET_DATA +#define X509_EXTENSION_get_object X509_EXTENSION_GET_OBJECT +#define X509_LOOKUP_file X509_LOOKUP_FILE +#define X509_NAME_ENTRY_get_data X509_NAME_ENTRY_GET_DATA +#define X509_NAME_get_entry X509_NAME_GET_ENTRY +#define X509_NAME_get_index_by_NID X509_NAME_GET_INDEX_BY_NID +#define X509_NAME_print_ex X509_NAME_PRINT_EX #define X509_STORE_CTX_get_current_cert X509_STORE_CTX_GET_CURRENT_CERT -#define X509_STORE_add_lookup X509_STORE_ADD_LOOKUP -#define X509_STORE_set_flags X509_STORE_SET_FLAGS -#define X509_check_issued X509_CHECK_ISSUED -#define X509_free X509_FREE -#define X509_get_ext_d2i X509_GET_EXT_D2I -#define X509_get_issuer_name X509_GET_ISSUER_NAME -#define X509_get_pubkey X509_GET_PUBKEY -#define X509_get_serialNumber X509_GET_SERIALNUMBER -#define X509_get_subject_name X509_GET_SUBJECT_NAME -#define X509_load_crl_file X509_LOAD_CRL_FILE -#define X509_verify_cert_error_string X509_VERIFY_CERT_ERROR_STRING -#define d2i_PKCS12_fp D2I_PKCS12_FP -#define i2t_ASN1_OBJECT I2T_ASN1_OBJECT -#define sk_num SK_NUM -#define sk_pop SK_POP -#define sk_pop_free SK_POP_FREE -#define sk_value SK_VALUE +#define X509_STORE_add_lookup X509_STORE_ADD_LOOKUP +#define X509_STORE_set_flags X509_STORE_SET_FLAGS +#define X509_check_issued X509_CHECK_ISSUED +#define X509_free X509_FREE +#define X509_get_ext_d2i X509_GET_EXT_D2I +#define X509_get_issuer_name X509_GET_ISSUER_NAME +#define X509_get_pubkey X509_GET_PUBKEY +#define X509_get_serialNumber X509_GET_SERIALNUMBER +#define X509_get_subject_name X509_GET_SUBJECT_NAME +#define X509_load_crl_file X509_LOAD_CRL_FILE +#define X509_verify_cert_error_string X509_VERIFY_CERT_ERROR_STRING +#define d2i_PKCS12_fp D2I_PKCS12_FP +#define i2t_ASN1_OBJECT I2T_ASN1_OBJECT +#define sk_num SK_NUM +#define sk_pop SK_POP +#define sk_pop_free SK_POP_FREE +#define sk_value SK_VALUE #ifdef __VAX #define OPENSSL_NO_SHA256 #endif -#define SHA256_Final SHA256_FINAL -#define SHA256_Init SHA256_INIT +#define SHA256_Final SHA256_FINAL +#define SHA256_Init SHA256_INIT #define SHA256_Update SHA256_UPDATE #define USE_UPPERCASE_GSSAPI 1 -#define gss_seal GSS_SEAL -#define gss_unseal GSS_UNSEAL +#define gss_seal GSS_SEAL +#define gss_unseal GSS_UNSEAL #define USE_UPPERCASE_KRBAPI 1 @@ -379,11 +378,11 @@ static struct passwd *vms_getpwuid(uid_t uid) /* VAX symbols are always in uppercase */ #ifdef __VAX -#define inflate INFLATE -#define inflateEnd INFLATEEND +#define inflate INFLATE +#define inflateEnd INFLATEEND #define inflateInit2_ INFLATEINIT2_ -#define inflateInit_ INFLATEINIT_ -#define zlibVersion ZLIBVERSION +#define inflateInit_ INFLATEINIT_ +#define zlibVersion ZLIBVERSION #endif /* Older VAX OpenSSL port defines these as Macros */ @@ -391,11 +390,11 @@ static struct passwd *vms_getpwuid(uid_t uid) /* that way a newer port will also work if some one has one */ #ifdef __VAX -# include -# ifndef OpenSSL_add_all_algorithms -# define OpenSSL_add_all_algorithms OPENSSL_ADD_ALL_ALGORITHMS - void OPENSSL_ADD_ALL_ALGORITHMS(void); -# endif +# include +# ifndef OpenSSL_add_all_algorithms +# define OpenSSL_add_all_algorithms OPENSSL_ADD_ALL_ALGORITHMS + void OPENSSL_ADD_ALL_ALGORITHMS(void); +# endif #endif #endif /* HEADER_CURL_SETUP_VMS_H */ diff --git a/lib/sha256.c b/lib/sha256.c index 977ad3edc402..9c3b60ec1885 100644 --- a/lib/sha256.c +++ b/lib/sha256.c @@ -193,7 +193,7 @@ static CURLcode my_sha256_init(void *in) { my_sha256_ctx *ctx = (my_sha256_ctx *)in; if(!CryptAcquireContext(&ctx->hCryptProv, NULL, NULL, PROV_RSA_AES, - CRYPT_VERIFYCONTEXT | CRYPT_SILENT)) + CRYPT_VERIFYCONTEXT | CRYPT_SILENT)) return CURLE_OUT_OF_MEMORY; if(!CryptCreateHash(ctx->hCryptProv, CALG_SHA_256, 0, 0, &ctx->hHash)) { @@ -236,42 +236,43 @@ static void my_sha256_final(unsigned char *digest, void *in) /* This is based on the SHA256 implementation in LibTomCrypt that was released * into public domain. */ -#define WPA_GET_BE32(a) ((((unsigned long)(a)[0]) << 24) | \ - (((unsigned long)(a)[1]) << 16) | \ - (((unsigned long)(a)[2]) << 8) | \ - ((unsigned long)(a)[3])) -#define WPA_PUT_BE32(a, val) \ -do { \ - (a)[0] = (unsigned char)((((unsigned long) (val)) >> 24) & 0xff); \ - (a)[1] = (unsigned char)((((unsigned long) (val)) >> 16) & 0xff); \ - (a)[2] = (unsigned char)((((unsigned long) (val)) >> 8) & 0xff); \ - (a)[3] = (unsigned char)(((unsigned long) (val)) & 0xff); \ -} while(0) +#define WPA_GET_BE32(a) \ + ((((unsigned long)(a)[0]) << 24) | \ + (((unsigned long)(a)[1]) << 16) | \ + (((unsigned long)(a)[2]) << 8) | \ + ((unsigned long)(a)[3])) +#define WPA_PUT_BE32(a, val) \ + do { \ + (a)[0] = (unsigned char)((((unsigned long)(val)) >> 24) & 0xff); \ + (a)[1] = (unsigned char)((((unsigned long)(val)) >> 16) & 0xff); \ + (a)[2] = (unsigned char)((((unsigned long)(val)) >> 8) & 0xff); \ + (a)[3] = (unsigned char) (((unsigned long)(val)) & 0xff); \ + } while(0) #ifdef HAVE_LONGLONG -#define WPA_PUT_BE64(a, val) \ -do { \ - (a)[0] = (unsigned char)(((unsigned long long)(val)) >> 56); \ - (a)[1] = (unsigned char)(((unsigned long long)(val)) >> 48); \ - (a)[2] = (unsigned char)(((unsigned long long)(val)) >> 40); \ - (a)[3] = (unsigned char)(((unsigned long long)(val)) >> 32); \ - (a)[4] = (unsigned char)(((unsigned long long)(val)) >> 24); \ - (a)[5] = (unsigned char)(((unsigned long long)(val)) >> 16); \ - (a)[6] = (unsigned char)(((unsigned long long)(val)) >> 8); \ - (a)[7] = (unsigned char)(((unsigned long long)(val)) & 0xff); \ -} while(0) +#define WPA_PUT_BE64(a, val) \ + do { \ + (a)[0] = (unsigned char)(((unsigned long long)(val)) >> 56); \ + (a)[1] = (unsigned char)(((unsigned long long)(val)) >> 48); \ + (a)[2] = (unsigned char)(((unsigned long long)(val)) >> 40); \ + (a)[3] = (unsigned char)(((unsigned long long)(val)) >> 32); \ + (a)[4] = (unsigned char)(((unsigned long long)(val)) >> 24); \ + (a)[5] = (unsigned char)(((unsigned long long)(val)) >> 16); \ + (a)[6] = (unsigned char)(((unsigned long long)(val)) >> 8); \ + (a)[7] = (unsigned char)(((unsigned long long)(val)) & 0xff); \ + } while(0) #else -#define WPA_PUT_BE64(a, val) \ -do { \ - (a)[0] = (unsigned char)(((unsigned __int64)(val)) >> 56); \ - (a)[1] = (unsigned char)(((unsigned __int64)(val)) >> 48); \ - (a)[2] = (unsigned char)(((unsigned __int64)(val)) >> 40); \ - (a)[3] = (unsigned char)(((unsigned __int64)(val)) >> 32); \ - (a)[4] = (unsigned char)(((unsigned __int64)(val)) >> 24); \ - (a)[5] = (unsigned char)(((unsigned __int64)(val)) >> 16); \ - (a)[6] = (unsigned char)(((unsigned __int64)(val)) >> 8); \ - (a)[7] = (unsigned char)(((unsigned __int64)(val)) & 0xff); \ -} while(0) +#define WPA_PUT_BE64(a, val) \ + do { \ + (a)[0] = (unsigned char)(((unsigned __int64)(val)) >> 56); \ + (a)[1] = (unsigned char)(((unsigned __int64)(val)) >> 48); \ + (a)[2] = (unsigned char)(((unsigned __int64)(val)) >> 40); \ + (a)[3] = (unsigned char)(((unsigned __int64)(val)) >> 32); \ + (a)[4] = (unsigned char)(((unsigned __int64)(val)) >> 24); \ + (a)[5] = (unsigned char)(((unsigned __int64)(val)) >> 16); \ + (a)[6] = (unsigned char)(((unsigned __int64)(val)) >> 8); \ + (a)[7] = (unsigned char)(((unsigned __int64)(val)) & 0xff); \ + } while(0) #endif struct sha256_state { @@ -304,20 +305,21 @@ static const unsigned long K[64] = { /* Various logical functions */ #define RORc(x, y) \ -(((((unsigned long)(x) & 0xFFFFFFFFUL) >> (unsigned long)((y) & 31)) | \ - ((unsigned long)(x) << (unsigned long)(32 - ((y) & 31)))) & 0xFFFFFFFFUL) -#define Sha256_Ch(x,y,z) (z ^ (x & (y ^ z))) -#define Sha256_Maj(x,y,z) (((x | y) & z) | (x & y)) -#define Sha256_S(x, n) RORc((x), (n)) -#define Sha256_R(x, n) (((x)&0xFFFFFFFFUL)>>(n)) + (((((unsigned long)(x) & 0xFFFFFFFFUL) >> (unsigned long)((y) & 31)) | \ + ((unsigned long)(x) << (unsigned long)(32 - ((y) & 31)))) & 0xFFFFFFFFUL) + +#define Sha256_Ch(x, y, z) (z ^ (x & (y ^ z))) +#define Sha256_Maj(x, y, z) (((x | y) & z) | (x & y)) +#define Sha256_S(x, n) RORc((x), (n)) +#define Sha256_R(x, n) (((x) & 0xFFFFFFFFUL) >> (n)) + #define Sigma0(x) (Sha256_S(x, 2) ^ Sha256_S(x, 13) ^ Sha256_S(x, 22)) #define Sigma1(x) (Sha256_S(x, 6) ^ Sha256_S(x, 11) ^ Sha256_S(x, 25)) #define Gamma0(x) (Sha256_S(x, 7) ^ Sha256_S(x, 18) ^ Sha256_R(x, 3)) #define Gamma1(x) (Sha256_S(x, 17) ^ Sha256_S(x, 19) ^ Sha256_R(x, 10)) /* Compress 512-bits */ -static int sha256_compress(struct sha256_state *md, - const unsigned char *buf) +static int sha256_compress(struct sha256_state *md, const unsigned char *buf) { unsigned long S[8], W[64]; int i; @@ -331,12 +333,11 @@ static int sha256_compress(struct sha256_state *md, W[i] = WPA_GET_BE32(buf + (4 * i)); /* fill W[16..63] */ for(i = 16; i < 64; i++) { - W[i] = Gamma1(W[i - 2]) + W[i - 7] + Gamma0(W[i - 15]) + - W[i - 16]; + 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) \ +#define RND(a, b, c, d, e, f, g, h, i) \ do { \ unsigned long t0 = h + Sigma1(e) + Sha256_Ch(e, f, g) + K[i] + W[i]; \ unsigned long t1 = Sigma0(a) + Sha256_Maj(a, b, c); \ @@ -347,8 +348,15 @@ static int sha256_compress(struct sha256_state *md, for(i = 0; i < 64; ++i) { unsigned long t; RND(S[0], S[1], S[2], S[3], S[4], S[5], S[6], S[7], i); - 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; + 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 */ @@ -492,7 +500,6 @@ CURLcode Curl_sha256it(unsigned char *output, const unsigned char *input, return result; } - const struct HMAC_params Curl_HMAC_SHA256 = { my_sha256_init, /* Hash initialization function. */ my_sha256_update, /* Hash update function. */ diff --git a/lib/sigpipe.h b/lib/sigpipe.h index 1be3a111e958..5d2c78a2713c 100644 --- a/lib/sigpipe.h +++ b/lib/sigpipe.h @@ -25,7 +25,7 @@ ***************************************************************************/ #include "curl_setup.h" -#if defined(HAVE_SIGACTION) && \ +#if defined(HAVE_SIGACTION) && \ (defined(USE_OPENSSL) || defined(USE_MBEDTLS) || defined(USE_WOLFSSL)) #include @@ -88,12 +88,12 @@ static void sigpipe_apply(struct Curl_easy *data, #else /* for systems without sigaction */ -#define sigpipe_ignore(x,y) Curl_nop_stmt -#define sigpipe_apply(x,y) Curl_nop_stmt -#define sigpipe_init(x) Curl_nop_stmt -#define sigpipe_restore(x) Curl_nop_stmt +#define sigpipe_ignore(x, y) Curl_nop_stmt +#define sigpipe_apply(x, y) Curl_nop_stmt +#define sigpipe_init(x) Curl_nop_stmt +#define sigpipe_restore(x) Curl_nop_stmt #define SIGPIPE_VARIABLE(x) -#define SIGPIPE_MEMBER(x) bool x +#define SIGPIPE_MEMBER(x) bool x #endif #endif /* HEADER_CURL_SIGPIPE_H */ diff --git a/lib/slist.c b/lib/slist.c index 469ee0ef3b5b..9b7f11d42619 100644 --- a/lib/slist.c +++ b/lib/slist.c @@ -31,7 +31,7 @@ /* returns last node in linked list */ static struct curl_slist *slist_get_last(struct curl_slist *list) { - struct curl_slist *item; + struct curl_slist *item; /* if caller passed us a NULL, return now */ if(!list) @@ -57,8 +57,8 @@ static struct curl_slist *slist_get_last(struct curl_slist *list) struct curl_slist *Curl_slist_append_nodup(struct curl_slist *list, const char *data) { - struct curl_slist *last; - struct curl_slist *new_item; + struct curl_slist *last; + struct curl_slist *new_item; DEBUGASSERT(data); @@ -85,8 +85,7 @@ struct curl_slist *Curl_slist_append_nodup(struct curl_slist *list, * bothersome, then simply create a separate _init function and call it * appropriately from within the program. */ -struct curl_slist *curl_slist_append(struct curl_slist *list, - const char *data) +struct curl_slist *curl_slist_append(struct curl_slist *list, const char *data) { char *dupdata = curlx_strdup(data); @@ -127,8 +126,8 @@ struct curl_slist *Curl_slist_duplicate(struct curl_slist *inlist) /* be nice and clean up resources */ void curl_slist_free_all(struct curl_slist *list) { - struct curl_slist *next; - struct curl_slist *item; + struct curl_slist *next; + struct curl_slist *item; if(!list) return; diff --git a/lib/smb.c b/lib/smb.c index 338464961b21..c52d4eca57af 100644 --- a/lib/smb.c +++ b/lib/smb.c @@ -368,7 +368,7 @@ const struct Curl_handler Curl_handler_smbs = { defined(__OS400__) static unsigned short smb_swap16(unsigned short x) { - return (unsigned short) ((x << 8) | ((x >> 8) & 0xff)); + return (unsigned short)((x << 8) | ((x >> 8) & 0xff)); } static unsigned int smb_swap32(unsigned int x) @@ -379,8 +379,8 @@ static unsigned int smb_swap32(unsigned int x) static curl_off_t smb_swap64(curl_off_t x) { - return ((curl_off_t) smb_swap32((unsigned int) x) << 32) | - smb_swap32((unsigned int) (x >> 32)); + return ((curl_off_t)smb_swap32((unsigned int)x) << 32) | + smb_swap32((unsigned int)(x >> 32)); } #else @@ -573,7 +573,7 @@ static CURLcode smb_recv_message(struct Curl_easy *data, if(nbt_size >= msg_size + 1) { /* Add the word count */ - msg_size += 1 + ((unsigned char) buf[msg_size]) * sizeof(unsigned short); + msg_size += 1 + ((unsigned char)buf[msg_size]) * sizeof(unsigned short); if(nbt_size >= msg_size + sizeof(unsigned short)) { /* Add the byte count */ msg_size += sizeof(unsigned short) + @@ -601,8 +601,8 @@ static void smb_format_message(struct smb_conn *smbc, const unsigned int pid = 0xbad71d; /* made up */ memset(h, 0, sizeof(*h)); - h->nbt_length = htons((unsigned short) (sizeof(*h) - sizeof(unsigned int) + - len)); + h->nbt_length = htons((unsigned short)(sizeof(*h) - sizeof(unsigned int) + + len)); memcpy((char *)h->magic, "\xffSMB", 4); h->command = cmd; h->flags = SMB_FLAGS_CANONICAL_PATHNAMES | SMB_FLAGS_CASELESS_PATHNAMES; @@ -610,7 +610,7 @@ static void smb_format_message(struct smb_conn *smbc, h->uid = smb_swap16(smbc->uid); h->tid = smb_swap16(req->tid); h->pid_high = smb_swap16((unsigned short)(pid >> 16)); - h->pid = smb_swap16((unsigned short) pid); + h->pid = smb_swap16((unsigned short)pid); } static CURLcode smb_send(struct Curl_easy *data, struct smb_conn *smbc, @@ -790,7 +790,7 @@ static CURLcode smb_send_open(struct Curl_easy *data, msg.access = smb_swap32(SMB_GENERIC_READ); msg.create_disposition = smb_swap32(SMB_FILE_OPEN); } - msg.byte_count = smb_swap16((unsigned short) byte_count); + msg.byte_count = smb_swap16((unsigned short)byte_count); strcpy(msg.bytes, req->path); return smb_send_message(data, smbc, req, SMB_COM_NT_CREATE_ANDX, &msg, @@ -831,8 +831,8 @@ static CURLcode smb_send_read(struct Curl_easy *data, msg.word_count = SMB_WC_READ_ANDX; msg.andx.command = SMB_COM_NO_ANDX_COMMAND; msg.fid = smb_swap16(req->fid); - msg.offset = smb_swap32((unsigned int) offset); - msg.offset_high = smb_swap32((unsigned int) (offset >> 32)); + msg.offset = smb_swap32((unsigned int)offset); + msg.offset_high = smb_swap32((unsigned int)(offset >> 32)); msg.min_bytes = smb_swap16(MAX_PAYLOAD_SIZE); msg.max_bytes = smb_swap16(MAX_PAYLOAD_SIZE); @@ -856,16 +856,16 @@ static CURLcode smb_send_write(struct Curl_easy *data, msg->word_count = SMB_WC_WRITE_ANDX; msg->andx.command = SMB_COM_NO_ANDX_COMMAND; msg->fid = smb_swap16(req->fid); - msg->offset = smb_swap32((unsigned int) offset); - msg->offset_high = smb_swap32((unsigned int) (offset >> 32)); - msg->data_length = smb_swap16((unsigned short) upload_size); + msg->offset = smb_swap32((unsigned int)offset); + msg->offset_high = smb_swap32((unsigned int)(offset >> 32)); + msg->data_length = smb_swap16((unsigned short)upload_size); msg->data_offset = smb_swap16(sizeof(*msg) - sizeof(unsigned int)); - msg->byte_count = smb_swap16((unsigned short) (upload_size + 1)); + msg->byte_count = smb_swap16((unsigned short)(upload_size + 1)); smb_format_message(smbc, req, &msg->h, SMB_COM_WRITE_ANDX, - sizeof(*msg) - sizeof(msg->h) + (size_t) upload_size); + sizeof(*msg) - sizeof(msg->h) + (size_t)upload_size); - return smb_send(data, smbc, sizeof(*msg), (size_t) upload_size); + return smb_send(data, smbc, sizeof(*msg), (size_t)upload_size); } static CURLcode smb_send_and_recv(struct Curl_easy *data, @@ -1014,7 +1014,7 @@ static void get_posix_time(time_t *out, curl_off_t timestamp) *out = TIME_T_MIN; else #endif - *out = (time_t) timestamp; + *out = (time_t)timestamp; } else *out = 0; @@ -1084,7 +1084,7 @@ static CURLcode smb_request_state(struct Curl_easy *data, bool *done) next_state = SMB_TREE_DISCONNECT; break; } - smb_m = (const struct smb_nt_create_response*) msg; + smb_m = (const struct smb_nt_create_response *)msg; req->fid = smb_swap16(smb_m->fid); data->req.offset = 0; if(data->state.upload) { @@ -1113,9 +1113,9 @@ static CURLcode smb_request_state(struct Curl_easy *data, bool *done) next_state = SMB_CLOSE; break; } - len = Curl_read16_le(((const unsigned char *) msg) + + len = Curl_read16_le(((const unsigned char *)msg) + sizeof(struct smb_header) + 11); - off = Curl_read16_le(((const unsigned char *) msg) + + off = Curl_read16_le(((const unsigned char *)msg) + sizeof(struct smb_header) + 13); if(len > 0) { if(off + sizeof(unsigned int) + len > smbc->got) { @@ -1142,7 +1142,7 @@ static CURLcode smb_request_state(struct Curl_easy *data, bool *done) next_state = SMB_CLOSE; break; } - len = Curl_read16_le(((const unsigned char *) msg) + + len = Curl_read16_le(((const unsigned char *)msg) + sizeof(struct smb_header) + 5); data->req.bytecount += len; data->req.offset += len; diff --git a/lib/smtp.c b/lib/smtp.c index 55a15b36c08d..5aab391e379a 100644 --- a/lib/smtp.c +++ b/lib/smtp.c @@ -201,8 +201,7 @@ const struct Curl_handler Curl_handler_smtp = { CURLPROTO_SMTP, /* protocol */ CURLPROTO_SMTP, /* family */ PROTOPT_CLOSEACTION | PROTOPT_NOURLQUERY | /* flags */ - PROTOPT_URLOPTIONS | PROTOPT_SSL_REUSE | - PROTOPT_CONN_REUSE + PROTOPT_URLOPTIONS | PROTOPT_SSL_REUSE | PROTOPT_CONN_REUSE }; #ifdef USE_SSL @@ -233,8 +232,7 @@ const struct Curl_handler Curl_handler_smtps = { CURLPROTO_SMTPS, /* protocol */ CURLPROTO_SMTP, /* family */ PROTOPT_CLOSEACTION | PROTOPT_SSL | /* flags */ - PROTOPT_NOURLQUERY | PROTOPT_URLOPTIONS | - PROTOPT_CONN_REUSE + PROTOPT_NOURLQUERY | PROTOPT_URLOPTIONS | PROTOPT_CONN_REUSE }; #endif @@ -285,10 +283,10 @@ static bool smtp_endofresp(struct Curl_easy *data, struct connectdata *conn, const char *p = tmpline; result = TRUE; memcpy(tmpline, line, (len == 5 ? 5 : 3)); - tmpline[len == 5 ? 5 : 3 ] = 0; + tmpline[len == 5 ? 5 : 3] = 0; if(curlx_str_number(&p, &code, len == 5 ? 99999 : 999)) return FALSE; - *resp = (int) code; + *resp = (int)code; /* Make sure real server never sends internal value */ if(*resp == 1) @@ -508,7 +506,7 @@ static CURLcode smtp_perform_auth(struct Curl_easy *data, CURLcode result = CURLE_OK; struct smtp_conn *smtpc = Curl_conn_meta_get(data->conn, CURL_META_SMTP_CONN); - const char *ir = (const char *) Curl_bufref_ptr(initresp); + const char *ir = (const char *)Curl_bufref_ptr(initresp); if(!smtpc) return CURLE_FAILED_INIT; @@ -542,7 +540,7 @@ static CURLcode smtp_continue_auth(struct Curl_easy *data, if(!smtpc) return CURLE_FAILED_INIT; return Curl_pp_sendf(data, &smtpc->pp, - "%s", (const char *) Curl_bufref_ptr(resp)); + "%s", (const char *)Curl_bufref_ptr(resp)); } /*********************************************************************** @@ -923,7 +921,7 @@ static CURLcode smtp_state_servergreet_resp(struct Curl_easy *data, CURLcode result = CURLE_OK; (void)instate; - if(smtpcode/100 != 2) { + if(smtpcode / 100 != 2) { failf(data, "Got unexpected smtp-server response: %d", smtpcode); result = CURLE_WEIRD_SERVER_REPLY; } @@ -972,9 +970,9 @@ static CURLcode smtp_state_ehlo_resp(struct Curl_easy *data, (void)instate; - if(smtpcode/100 != 2 && smtpcode != 1) { - if(data->set.use_ssl <= CURLUSESSL_TRY - || Curl_conn_is_ssl(data->conn, FIRSTSOCKET)) + if(smtpcode / 100 != 2 && smtpcode != 1) { + if(data->set.use_ssl <= CURLUSESSL_TRY || + Curl_conn_is_ssl(data->conn, FIRSTSOCKET)) result = smtp_perform_helo(data, smtpc); else { failf(data, "Remote access denied: %d", smtpcode); @@ -1073,7 +1071,7 @@ static CURLcode smtp_state_helo_resp(struct Curl_easy *data, CURLcode result = CURLE_OK; (void)instate; - if(smtpcode/100 != 2) { + if(smtpcode / 100 != 2) { failf(data, "Remote access denied: %d", smtpcode); result = CURLE_REMOTE_ACCESS_DENIED; } @@ -1125,8 +1123,8 @@ static CURLcode smtp_state_command_resp(struct Curl_easy *data, (void)instate; - if((smtp->rcpt && smtpcode/100 != 2 && smtpcode != 553 && smtpcode != 1) || - (!smtp->rcpt && smtpcode/100 != 2 && smtpcode != 1)) { + if((smtp->rcpt && smtpcode / 100 != 2 && smtpcode != 553 && smtpcode != 1) || + (!smtp->rcpt && smtpcode / 100 != 2 && smtpcode != 1)) { failf(data, "Command failed: %d", smtpcode); result = CURLE_WEIRD_SERVER_REPLY; } @@ -1165,7 +1163,7 @@ static CURLcode smtp_state_mail_resp(struct Curl_easy *data, CURLcode result = CURLE_OK; (void)instate; - if(smtpcode/100 != 2) { + if(smtpcode / 100 != 2) { failf(data, "MAIL failed: %d", smtpcode); result = CURLE_SEND_ERROR; } @@ -1189,7 +1187,7 @@ static CURLcode smtp_state_rcpt_resp(struct Curl_easy *data, (void)instate; - is_smtp_err = (smtpcode/100 != 2); + is_smtp_err = (smtpcode / 100 != 2); /* If there is multiple RCPT TO to be issued, it is possible to ignore errors and proceed with only the valid addresses. */ @@ -1735,8 +1733,8 @@ static CURLcode smtp_setup_connection(struct Curl_easy *data, smtpc = curlx_calloc(1, sizeof(*smtpc)); if(!smtpc || Curl_conn_meta_set(conn, CURL_META_SMTP_CONN, smtpc, smtp_conn_dtor)) { - result = CURLE_OUT_OF_MEMORY; - goto out; + result = CURLE_OUT_OF_MEMORY; + goto out; } smtp = curlx_calloc(1, sizeof(*smtp)); @@ -1943,7 +1941,7 @@ static void cr_eob_close(struct Curl_easy *data, struct Curl_creader *reader) } /* this is the 5-bytes End-Of-Body marker for SMTP */ -#define SMTP_EOB "\r\n.\r\n" +#define SMTP_EOB "\r\n.\r\n" #define SMTP_EOB_FIND_LEN 3 /* client reader doing SMTP End-Of-Body escaping. */ @@ -2016,16 +2014,16 @@ static CURLcode cr_eob_read(struct Curl_easy *data, const char *eob = SMTP_EOB; CURL_TRC_SMTP(data, "auto-ending mail body with '\\r\\n.\\r\\n'"); switch(ctx->n_eob) { - case 2: - /* seen a CRLF at the end, just add the remainder */ - eob = &SMTP_EOB[2]; - break; - case 3: - /* ended with '\r\n.', we should escape the last '.' */ - eob = "." SMTP_EOB; - break; - default: - break; + case 2: + /* seen a CRLF at the end, just add the remainder */ + eob = &SMTP_EOB[2]; + break; + case 3: + /* ended with '\r\n.', we should escape the last '.' */ + eob = "." SMTP_EOB; + break; + default: + break; } result = Curl_bufq_cwrite(&ctx->buf, eob, strlen(eob), &n); if(result) @@ -2078,8 +2076,7 @@ static CURLcode cr_eob_add(struct Curl_easy *data) struct Curl_creader *reader = NULL; CURLcode result; - result = Curl_creader_create(&reader, data, &cr_eob, - CURL_CR_CONTENT_ENCODE); + result = Curl_creader_create(&reader, data, &cr_eob, CURL_CR_CONTENT_ENCODE); if(!result) result = Curl_creader_add(data, reader); diff --git a/lib/socketpair.h b/lib/socketpair.h index e601f5f71bee..5387c09340fb 100644 --- a/lib/socketpair.h +++ b/lib/socketpair.h @@ -28,20 +28,20 @@ #ifdef USE_EVENTFD -#define wakeup_write write -#define wakeup_read read -#define wakeup_close close -#define wakeup_create(p,nb) Curl_eventfd(p,nb) +#define wakeup_write write +#define wakeup_read read +#define wakeup_close close +#define wakeup_create(p, nb) Curl_eventfd(p, nb) #include int Curl_eventfd(curl_socket_t socks[2], bool nonblocking); #elif defined(HAVE_PIPE) -#define wakeup_write write -#define wakeup_read read -#define wakeup_close close -#define wakeup_create(p,nb) Curl_pipe(p,nb) +#define wakeup_write write +#define wakeup_read read +#define wakeup_close close +#define wakeup_create(p, nb) Curl_pipe(p, nb) #include int Curl_pipe(curl_socket_t socks[2], bool nonblocking); @@ -67,7 +67,7 @@ int Curl_pipe(curl_socket_t socks[2], bool nonblocking); #endif #define USE_SOCKETPAIR -#define wakeup_create(p,nb) \ +#define wakeup_create(p, nb) \ Curl_socketpair(SOCKETPAIR_FAMILY, SOCKETPAIR_TYPE, 0, p, nb) #endif /* USE_EVENTFD */ diff --git a/lib/socks.c b/lib/socks.c index 7160dd150698..46208506527c 100644 --- a/lib/socks.c +++ b/lib/socks.c @@ -164,9 +164,9 @@ CURLcode Curl_blockread_all(struct Curl_cfilter *cf, #if defined(DEBUGBUILD) && !defined(CURL_DISABLE_VERBOSE_STRINGS) #define DEBUG_AND_VERBOSE -#define sxstate(x,c,d,y) socksstate(x,c,d,y, __LINE__) +#define sxstate(x, c, d, y) socksstate(x, c, d, y, __LINE__) #else -#define sxstate(x,c,d,y) socksstate(x,c,d,y) +#define sxstate(x, c, d, y) socksstate(x, c, d, y) #endif /* always use this function to change state, to make debugging easier */ @@ -206,9 +206,9 @@ static CURLproxycode socks_failed(struct socks_state *sx, } static CURLproxycode socks_flush(struct socks_state *sx, - struct Curl_cfilter *cf, - struct Curl_easy *data, - bool *done) + struct Curl_cfilter *cf, + struct Curl_easy *data, + bool *done) { CURLcode result; size_t nwritten; @@ -332,8 +332,7 @@ static CURLproxycode socks4_resolving(struct socks_state *sx, result = Curl_resolv(data, sx->hostname, sx->remote_port, cf->conn->ip_version, TRUE, &dns); if(result == CURLE_AGAIN) { - CURL_TRC_CF(data, cf, "SOCKS4 non-blocking resolve of %s", - sx->hostname); + CURL_TRC_CF(data, cf, "SOCKS4 non-blocking resolve of %s", sx->hostname); return CURLPX_OK; } else if(result) @@ -347,8 +346,7 @@ static CURLproxycode socks4_resolving(struct socks_state *sx, } if(result || !dns) { - failf(data, "Failed to resolve \"%s\" for SOCKS4 connect.", - sx->hostname); + failf(data, "Failed to resolve \"%s\" for SOCKS4 connect.", sx->hostname); return CURLPX_RESOLVE_HOST; } @@ -465,16 +463,16 @@ static CURLproxycode socks4_check_resp(struct socks_state *sx, } /* -* This function logs in to a SOCKS4 proxy and sends the specifics to the final -* destination server. -* -* Reference : -* https://www.openssh.com/txt/socks4.protocol -* -* Note : -* Set protocol4a=true for "SOCKS 4A (Simple Extension to SOCKS 4 Protocol)" -* Nonsupport "Identification Protocol (RFC1413)" -*/ + * This function logs in to a SOCKS4 proxy and sends the specifics to the final + * destination server. + * + * Reference : + * https://www.openssh.com/txt/socks4.protocol + * + * Note : + * Set protocol4a=true for "SOCKS 4A (Simple Extension to SOCKS 4 Protocol)" + * Nonsupport "Identification Protocol (RFC1413)" + */ static CURLproxycode socks4_connect(struct Curl_cfilter *cf, struct socks_state *sx, struct Curl_easy *data) @@ -733,7 +731,7 @@ static CURLproxycode socks5_auth_init(struct Curl_cfilter *cf, if(result || (nwritten != ulen)) return CURLPX_SEND_REQUEST; } - buf[0] = (unsigned char) plen; + buf[0] = (unsigned char)plen; result = Curl_bufq_write(&sx->iobuf, buf, 1, &nwritten); if(result || (nwritten != 1)) return CURLPX_SEND_REQUEST; @@ -813,7 +811,7 @@ static CURLproxycode socks5_req1_init(struct socks_state *sx, const size_t hostname_len = strlen(sx->hostname); desttype = 3; destination = (const unsigned char *)sx->hostname; - destlen = (unsigned char) hostname_len; /* one byte length */ + destlen = (unsigned char)hostname_len; /* one byte length */ } req[3] = desttype; @@ -860,8 +858,7 @@ static CURLproxycode socks5_resolving(struct socks_state *sx, result = Curl_resolv(data, sx->hostname, sx->remote_port, cf->conn->ip_version, TRUE, &dns); if(result == CURLE_AGAIN) { - CURL_TRC_CF(data, cf, "SOCKS5 non-blocking resolve of %s", - sx->hostname); + CURL_TRC_CF(data, cf, "SOCKS5 non-blocking resolve of %s", sx->hostname); return CURLPX_OK; } else if(result) @@ -875,8 +872,7 @@ static CURLproxycode socks5_resolving(struct socks_state *sx, } if(result || !dns) { - failf(data, "Failed to resolve \"%s\" for SOCKS5 connect.", - sx->hostname); + failf(data, "Failed to resolve \"%s\" for SOCKS5 connect.", sx->hostname); presult = CURLPX_RESOLVE_HOST; goto out; } @@ -893,8 +889,7 @@ static CURLproxycode socks5_resolving(struct socks_state *sx, } #endif if(!hp) { - failf(data, "Failed to resolve \"%s\" for SOCKS5 connect.", - sx->hostname); + failf(data, "Failed to resolve \"%s\" for SOCKS5 connect.", sx->hostname); presult = CURLPX_RESOLVE_HOST; goto out; } @@ -1394,7 +1389,7 @@ static CURLcode socks_cf_query(struct Curl_cfilter *cf, struct Curl_cftype Curl_cft_socks_proxy = { "SOCKS", - CF_TYPE_IP_CONNECT|CF_TYPE_PROXY, + CF_TYPE_IP_CONNECT | CF_TYPE_PROXY, 0, socks_proxy_cf_destroy, socks_proxy_cf_connect, diff --git a/lib/socks.h b/lib/socks.h index f76bddc5f4e1..eb9088f530c7 100644 --- a/lib/socks.h +++ b/lib/socks.h @@ -27,9 +27,9 @@ #include "curl_setup.h" #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_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 #else /* * Helper read-from-socket functions. Does the same as Curl_read() but it diff --git a/lib/socks_gssapi.c b/lib/socks_gssapi.c index 6f8a90139ded..3bee643e4108 100644 --- a/lib/socks_gssapi.c +++ b/lib/socks_gssapi.c @@ -67,8 +67,7 @@ static int check_gss_err(struct Curl_easy *data, GSS_C_NULL_OID, &msg_ctx, &status_string); if(maj_stat == GSS_S_COMPLETE) { - if(curlx_dyn_addn(&dbuf, status_string.value, - status_string.length)) + if(curlx_dyn_addn(&dbuf, status_string.value, status_string.length)) return 1; /* error */ gss_release_buffer(&min_stat, &status_string); break; @@ -85,8 +84,7 @@ static int check_gss_err(struct Curl_easy *data, GSS_C_NULL_OID, &msg_ctx, &status_string); if(maj_stat == GSS_S_COMPLETE) { - if(curlx_dyn_addn(&dbuf, status_string.value, - status_string.length)) + if(curlx_dyn_addn(&dbuf, status_string.value, status_string.length)) return 1; /* error */ gss_release_buffer(&min_stat, &status_string); break; @@ -144,7 +142,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(struct Curl_cfilter *cf, return CURLE_OUT_OF_MEMORY; gss_major_status = gss_import_name(&gss_minor_status, &service, - (gss_OID) GSS_C_NULL_OID, &server); + (gss_OID)GSS_C_NULL_OID, &server); } else { service.value = curlx_malloc(serviceptr_length + @@ -207,8 +205,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(struct Curl_cfilter *cf, us_length = htons((unsigned short)gss_send_token.length); memcpy(socksreq + 2, &us_length, sizeof(short)); - code = Curl_conn_cf_send(cf->next, data, socksreq, 4, - FALSE, &nwritten); + code = Curl_conn_cf_send(cf->next, data, socksreq, 4, FALSE, &nwritten); if(code || (nwritten != 4)) { failf(data, "Failed to send GSS-API authentication request."); gss_release_name(&gss_status, &server); @@ -227,7 +224,6 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(struct Curl_cfilter *cf, Curl_gss_delete_sec_context(&gss_status, &gss_context, NULL); return CURLE_COULDNT_CONNECT; } - } gss_release_buffer(&gss_status, &gss_send_token); diff --git a/lib/socks_sspi.c b/lib/socks_sspi.c index 92592c5ce007..17e875557eea 100644 --- a/lib/socks_sspi.c +++ b/lib/socks_sspi.c @@ -187,8 +187,8 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(struct Curl_cfilter *cf, } if(sspi_send_token.cbBuffer) { - socksreq[0] = 1; /* GSS-API subnegotiation version */ - socksreq[1] = 1; /* authentication message type */ + socksreq[0] = 1; /* GSS-API subnegotiation version */ + socksreq[1] = 1; /* authentication message type */ if(sspi_send_token.cbBuffer > 0xffff) { /* needs to fit in an unsigned 16 bit field */ result = CURLE_COULDNT_CONNECT; @@ -305,8 +305,8 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(struct Curl_cfilter *cf, } /* Do encryption */ - socksreq[0] = 1; /* GSS-API subnegotiation version */ - socksreq[1] = 2; /* encryption message type */ + socksreq[0] = 1; /* GSS-API subnegotiation version */ + socksreq[1] = 2; /* encryption message type */ gss_enc = 0; /* no data protection */ /* do confidentiality protection if supported */ @@ -318,7 +318,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(struct Curl_cfilter *cf, infof(data, "SOCKS5 server supports GSS-API %s data protection.", (gss_enc == 0) ? "no" : - ((gss_enc == 1) ? "integrity":"confidentiality") ); + ((gss_enc == 1) ? "integrity" : "confidentiality") ); /* * Sending the encryption type in clear seems wrong. It should be @@ -399,7 +399,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(struct Curl_cfilter *cf, } etbuf_size = sspi_w_token[0].cbBuffer + sspi_w_token[1].cbBuffer + - sspi_w_token[2].cbBuffer; + sspi_w_token[2].cbBuffer; if(etbuf_size > 0xffff) { /* needs to fit in an unsigned 16 bit field */ result = CURLE_COULDNT_CONNECT; diff --git a/lib/splay.c b/lib/splay.c index 3ca8678b2b2f..d036d27f548e 100644 --- a/lib/splay.c +++ b/lib/splay.c @@ -34,7 +34,7 @@ * zero : when i is equal to j * positive when : when i is larger than j */ -#define compare(i,j) curlx_timediff_us(i,j) +#define compare(i, j) curlx_timediff_us(i, j) /* * Splay using the key i (which may or may not be in the tree.) The starting @@ -134,7 +134,6 @@ struct Curl_tree *Curl_splayinsert(struct curltime i, node->smaller = t->smaller; node->larger = t; t->smaller = NULL; - } else { node->larger = t->larger; @@ -156,7 +155,7 @@ struct Curl_tree *Curl_splaygetbest(struct curltime i, struct Curl_tree *t, struct Curl_tree **removed) { - static const struct curltime tv_zero = {0, 0}; + static const struct curltime tv_zero = { 0, 0 }; struct Curl_tree *x; if(!t) { @@ -197,7 +196,6 @@ struct Curl_tree *Curl_splaygetbest(struct curltime i, return x; } - /* Deletes the node we point out from the tree if it is there. Stores a * pointer to the new resulting tree in 'newroot'. * diff --git a/lib/strcase.c b/lib/strcase.c index 78d4dc5b3d93..e8424fa61732 100644 --- a/lib/strcase.c +++ b/lib/strcase.c @@ -30,58 +30,60 @@ /* Mapping table to go from lowercase to uppercase for plain ASCII.*/ static const unsigned char touppermap[256] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, - 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, - 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, - 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, - 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 65, - 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, - 85, 86, 87, 88, 89, 90, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, - 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, - 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, - 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, - 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, - 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, - 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, - 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, - 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, - 253, 254, 255 + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, + 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, + 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, + 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, + 90, 91, 92, 93, 94, 95, 96, 65, 66, 67, 68, 69, 70, 71, 72, + 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, + 88, 89, 90, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, + 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, + 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, + 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, + 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, + 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, + 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, + 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, + 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, + 255 }; /* Mapping table to go from uppercase to lowercase for plain ASCII.*/ static const unsigned char tolowermap[256] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, - 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, - 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, - 60, 61, 62, 63, 64, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, - 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 91, 92, - 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, - 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, - 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, - 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, - 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, - 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, - 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, - 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, - 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, - 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, - 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255 + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, + 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, + 60, 61, 62, 63, 64, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, + 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, + 122, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, + 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, + 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, + 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, + 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, + 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, + 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, + 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, + 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, + 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, + 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, + 255 }; - /* Portable, consistent toupper. Do not use toupper() because its behavior is altered by the current locale. */ char Curl_raw_toupper(char in) { - return (char)touppermap[(unsigned char) in]; + return (char)touppermap[(unsigned char)in]; } - /* Portable, consistent tolower. Do not use tolower() because its behavior is altered by the current locale. */ char Curl_raw_tolower(char in) { - return (char)tolowermap[(unsigned char) in]; + return (char)tolowermap[(unsigned char)in]; } /* Copy an upper case version of the string from src to dest. The @@ -135,7 +137,7 @@ int Curl_timestrcmp(const char *a, const char *b) if(a && b) { while(1) { - match |= a[i]^b[i]; + match |= a[i] ^ b[i]; if(!a[i] || !b[i]) break; i++; diff --git a/lib/strcase.h b/lib/strcase.h index 915c996926d0..56839c2f3eaa 100644 --- a/lib/strcase.h +++ b/lib/strcase.h @@ -31,7 +31,7 @@ char Curl_raw_tolower(char in); /* checkprefix() is a shorter version of the above, used when the first argument is the string literal */ -#define checkprefix(a,b) curl_strnequal(b, STRCONST(a)) +#define checkprefix(a, b) curl_strnequal(b, STRCONST(a)) void Curl_strntoupper(char *dest, const char *src, size_t n); void Curl_strntolower(char *dest, const char *src, size_t n); diff --git a/lib/strdup.h b/lib/strdup.h index 238a2611f645..22ade4d7ffad 100644 --- a/lib/strdup.h +++ b/lib/strdup.h @@ -29,7 +29,7 @@ char *Curl_strdup(const char *str); #endif #ifdef _WIN32 -wchar_t* Curl_wcsdup(const wchar_t* src); +wchar_t *Curl_wcsdup(const wchar_t *src); #endif void *Curl_memdup(const void *src, size_t buffer_length); void *Curl_saferealloc(void *ptr, size_t size); diff --git a/lib/strerror.c b/lib/strerror.c index 4b957bef2312..899db8c61d77 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -34,8 +34,7 @@ #include "curlx/winapi.h" #include "strerror.h" -const char * -curl_easy_strerror(CURLcode error) +const char *curl_easy_strerror(CURLcode error) { #ifndef CURL_DISABLE_VERBOSE_STRINGS switch(error) { @@ -53,7 +52,7 @@ curl_easy_strerror(CURLcode error) case CURLE_NOT_BUILT_IN: return "A requested feature, protocol or option was not found built-in in" - " this libcurl due to a build-time decision."; + " this libcurl due to a build-time decision."; case CURLE_COULDNT_RESOLVE_PROXY: return "Could not resolve proxy name"; @@ -327,8 +326,7 @@ curl_easy_strerror(CURLcode error) #endif } -const char * -curl_multi_strerror(CURLMcode error) +const char *curl_multi_strerror(CURLMcode error) { #ifndef CURL_DISABLE_VERBOSE_STRINGS switch(error) { @@ -387,8 +385,7 @@ curl_multi_strerror(CURLMcode error) #endif } -const char * -curl_share_strerror(CURLSHcode error) +const char *curl_share_strerror(CURLSHcode error) { #ifndef CURL_DISABLE_VERBOSE_STRINGS switch(error) { @@ -423,8 +420,7 @@ curl_share_strerror(CURLSHcode error) #endif } -const char * -curl_url_strerror(CURLUcode error) +const char *curl_url_strerror(CURLUcode error) { #ifndef CURL_DISABLE_VERBOSE_STRINGS switch(error) { @@ -558,96 +554,96 @@ const char *Curl_sspi_strerror(SECURITY_STATUS err, char *buf, size_t buflen) #ifndef CURL_DISABLE_VERBOSE_STRINGS switch(err) { - case SEC_E_OK: - txt = "No error"; - break; + case SEC_E_OK: + txt = "No error"; + break; #define SEC2TXT(sec) case sec: txt = #sec; break - SEC2TXT(CRYPT_E_REVOKED); - SEC2TXT(CRYPT_E_NO_REVOCATION_DLL); - SEC2TXT(CRYPT_E_NO_REVOCATION_CHECK); - SEC2TXT(CRYPT_E_REVOCATION_OFFLINE); - SEC2TXT(CRYPT_E_NOT_IN_REVOCATION_DATABASE); - 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"; + SEC2TXT(CRYPT_E_REVOKED); + SEC2TXT(CRYPT_E_NO_REVOCATION_DLL); + SEC2TXT(CRYPT_E_NO_REVOCATION_CHECK); + SEC2TXT(CRYPT_E_REVOCATION_OFFLINE); + SEC2TXT(CRYPT_E_NOT_IN_REVOCATION_DATABASE); + 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) { diff --git a/lib/system_win32.c b/lib/system_win32.c index f8a6cbfcccd6..42db33a3edfa 100644 --- a/lib/system_win32.c +++ b/lib/system_win32.c @@ -70,7 +70,7 @@ CURLcode Curl_win32_init(long flags) /* highest supported version. */ if(LOBYTE(wsaData.wVersion) != LOBYTE(wVersionRequested) || - HIBYTE(wsaData.wVersion) != HIBYTE(wVersionRequested) ) { + HIBYTE(wsaData.wVersion) != HIBYTE(wVersionRequested)) { /* Tell the user that we could not find a usable */ /* winsock.dll. */ diff --git a/lib/telnet.c b/lib/telnet.c index 5319130b90f3..3153a392f679 100644 --- a/lib/telnet.c +++ b/lib/telnet.c @@ -62,27 +62,27 @@ #define SUBBUFSIZE 512 -#define CURL_SB_CLEAR(x) x->subpointer = x->subbuffer -#define CURL_SB_TERM(x) \ - do { \ - x->subend = x->subpointer; \ - CURL_SB_CLEAR(x); \ +#define CURL_SB_CLEAR(x) x->subpointer = x->subbuffer +#define CURL_SB_TERM(x) \ + do { \ + x->subend = x->subpointer; \ + CURL_SB_CLEAR(x); \ } while(0) -#define CURL_SB_ACCUM(x,c) \ - do { \ - if(x->subpointer < (x->subbuffer + sizeof(x->subbuffer))) \ - *x->subpointer++ = (c); \ +#define CURL_SB_ACCUM(x, c) \ + do { \ + if(x->subpointer < (x->subbuffer + sizeof(x->subbuffer))) \ + *x->subpointer++ = (c); \ } while(0) -#define CURL_SB_GET(x) ((*x->subpointer++)&0xff) -#define CURL_SB_LEN(x) (x->subend - x->subpointer) +#define CURL_SB_GET(x) ((*x->subpointer++) & 0xff) +#define CURL_SB_LEN(x) (x->subend - x->subpointer) /* For posterity: #define CURL_SB_PEEK(x) ((*x->subpointer)&0xff) #define CURL_SB_EOF(x) (x->subpointer >= x->subend) */ #ifdef CURL_DISABLE_VERBOSE_STRINGS -#define printoption(a,b,c,d) Curl_nop_stmt +#define printoption(a, b, c, d) Curl_nop_stmt #endif /* For negotiation compliant to RFC 1143 */ @@ -101,8 +101,7 @@ /* * Telnet receiver states for fsm */ -typedef enum -{ +typedef enum { CURL_TS_DATA = 0, CURL_TS_IAC, CURL_TS_WILL, @@ -137,12 +136,12 @@ struct TELNET { unsigned char *subpointer, *subend; /* buffer for sub-options */ }; - -static -CURLcode telrcv(struct Curl_easy *data, - struct TELNET *tn, - const unsigned char *inbuf, /* Data received from socket */ - ssize_t count); /* Number of bytes received */ +static CURLcode telrcv(struct Curl_easy *data, + struct TELNET *tn, + const unsigned char *inbuf, /* Data received from + socket */ + ssize_t count); /* Number of bytes + received */ #ifndef CURL_DISABLE_VERBOSE_STRINGS static void printoption(struct Curl_easy *data, @@ -199,7 +198,6 @@ const struct Curl_handler Curl_handler_telnet = { PROTOPT_NONE | PROTOPT_NOURLQUERY /* flags */ }; - static void telnet_easy_dtor(void *key, size_t klen, void *entry) { struct TELNET *tn = entry; @@ -210,8 +208,7 @@ static void telnet_easy_dtor(void *key, size_t klen, void *entry) curlx_free(tn); } -static -CURLcode init_telnet(struct Curl_easy *data) +static CURLcode init_telnet(struct Curl_easy *data) { struct TELNET *tn; @@ -328,15 +325,14 @@ static void send_negotiation(struct Curl_easy *data, int cmd, int option) bytes_written = swrite(conn->sock[FIRSTSOCKET], buf, 3); if(bytes_written < 0) { int err = SOCKERRNO; - failf(data,"Sending data failed (%d)",err); + failf(data, "Sending data failed (%d)", err); } printoption(data, "SENT", cmd, option); } -static -void set_remote_option(struct Curl_easy *data, struct TELNET *tn, - int option, int newstate) +static void set_remote_option(struct Curl_easy *data, struct TELNET *tn, + int option, int newstate) { if(newstate == CURL_YES) { switch(tn->him[option]) { @@ -408,8 +404,7 @@ void set_remote_option(struct Curl_easy *data, struct TELNET *tn, } } -static -void rec_will(struct Curl_easy *data, struct TELNET *tn, int option) +static void rec_will(struct Curl_easy *data, struct TELNET *tn, int option) { switch(tn->him[option]) { case CURL_NO: @@ -455,8 +450,7 @@ void rec_will(struct Curl_easy *data, struct TELNET *tn, int option) } } -static -void rec_wont(struct Curl_easy *data, struct TELNET *tn, int option) +static void rec_wont(struct Curl_easy *data, struct TELNET *tn, int option) { switch(tn->him[option]) { case CURL_NO: @@ -496,9 +490,8 @@ void rec_wont(struct Curl_easy *data, struct TELNET *tn, int option) } } -static void -set_local_option(struct Curl_easy *data, struct TELNET *tn, - int option, int newstate) +static void set_local_option(struct Curl_easy *data, struct TELNET *tn, + int option, int newstate) { if(newstate == CURL_YES) { switch(tn->us[option]) { @@ -570,8 +563,7 @@ set_local_option(struct Curl_easy *data, struct TELNET *tn, } } -static -void rec_do(struct Curl_easy *data, struct TELNET *tn, int option) +static void rec_do(struct Curl_easy *data, struct TELNET *tn, int option) { switch(tn->us[option]) { case CURL_NO: @@ -629,8 +621,7 @@ void rec_do(struct Curl_easy *data, struct TELNET *tn, int option) } } -static -void rec_dont(struct Curl_easy *data, struct TELNET *tn, int option) +static void rec_dont(struct Curl_easy *data, struct TELNET *tn, int option) { switch(tn->us[option]) { case CURL_NO: @@ -670,7 +661,6 @@ void rec_dont(struct Curl_easy *data, struct TELNET *tn, int option) } } - static void printsub(struct Curl_easy *data, int direction, /* '<' or '>' */ unsigned char *pointer, /* where suboption data is */ @@ -683,8 +673,8 @@ static void printsub(struct Curl_easy *data, if(length >= 3) { int j; - i = pointer[length-2]; - j = pointer[length-1]; + i = pointer[length - 2]; + j = pointer[length - 1]; if(i != CURL_IAC || j != CURL_SE) { infof(data, "(terminated by "); @@ -950,77 +940,77 @@ static CURLcode suboption(struct Curl_easy *data, struct TELNET *tn) printsub(data, '<', (unsigned char *)tn->subbuffer, CURL_SB_LEN(tn) + 2); switch(CURL_SB_GET(tn)) { - case CURL_TELOPT_TTYPE: - if(bad_option(tn->subopt_ttype)) - return CURLE_BAD_FUNCTION_ARGUMENT; - if(strlen(tn->subopt_ttype) > 1000) { - failf(data, "Tool long telnet TTYPE"); - return CURLE_SEND_ERROR; - } - len = curl_msnprintf((char *)temp, sizeof(temp), "%c%c%c%c%s%c%c", - CURL_IAC, CURL_SB, CURL_TELOPT_TTYPE, - CURL_TELQUAL_IS, tn->subopt_ttype, CURL_IAC, - CURL_SE); - bytes_written = swrite(conn->sock[FIRSTSOCKET], temp, len); + case CURL_TELOPT_TTYPE: + if(bad_option(tn->subopt_ttype)) + return CURLE_BAD_FUNCTION_ARGUMENT; + if(strlen(tn->subopt_ttype) > 1000) { + failf(data, "Tool long telnet TTYPE"); + return CURLE_SEND_ERROR; + } + len = curl_msnprintf((char *)temp, sizeof(temp), "%c%c%c%c%s%c%c", + CURL_IAC, CURL_SB, CURL_TELOPT_TTYPE, + CURL_TELQUAL_IS, tn->subopt_ttype, CURL_IAC, + CURL_SE); + bytes_written = swrite(conn->sock[FIRSTSOCKET], temp, len); - if(bytes_written < 0) { - err = SOCKERRNO; - failf(data, "Sending data failed (%d)", err); - return CURLE_SEND_ERROR; - } - printsub(data, '>', &temp[2], len-2); - break; - case CURL_TELOPT_XDISPLOC: - if(bad_option(tn->subopt_xdisploc)) + if(bytes_written < 0) { + err = SOCKERRNO; + failf(data, "Sending data failed (%d)", err); + return CURLE_SEND_ERROR; + } + printsub(data, '>', &temp[2], len-2); + break; + case CURL_TELOPT_XDISPLOC: + if(bad_option(tn->subopt_xdisploc)) + return CURLE_BAD_FUNCTION_ARGUMENT; + if(strlen(tn->subopt_xdisploc) > 1000) { + failf(data, "Tool long telnet XDISPLOC"); + return CURLE_SEND_ERROR; + } + len = curl_msnprintf((char *)temp, sizeof(temp), "%c%c%c%c%s%c%c", + CURL_IAC, CURL_SB, CURL_TELOPT_XDISPLOC, + CURL_TELQUAL_IS, tn->subopt_xdisploc, CURL_IAC, + CURL_SE); + bytes_written = swrite(conn->sock[FIRSTSOCKET], temp, len); + if(bytes_written < 0) { + err = SOCKERRNO; + failf(data, "Sending data failed (%d)", err); + return CURLE_SEND_ERROR; + } + printsub(data, '>', &temp[2], len - 2); + break; + case CURL_TELOPT_NEW_ENVIRON: + len = curl_msnprintf((char *)temp, sizeof(temp), "%c%c%c%c", + CURL_IAC, CURL_SB, CURL_TELOPT_NEW_ENVIRON, + CURL_TELQUAL_IS); + for(v = tn->telnet_vars; v; v = v->next) { + size_t tmplen = (strlen(v->data) + 1); + if(bad_option(v->data)) return CURLE_BAD_FUNCTION_ARGUMENT; - if(strlen(tn->subopt_xdisploc) > 1000) { - failf(data, "Tool long telnet XDISPLOC"); - return CURLE_SEND_ERROR; - } - len = curl_msnprintf((char *)temp, sizeof(temp), "%c%c%c%c%s%c%c", - CURL_IAC, CURL_SB, CURL_TELOPT_XDISPLOC, - CURL_TELQUAL_IS, tn->subopt_xdisploc, CURL_IAC, - CURL_SE); - bytes_written = swrite(conn->sock[FIRSTSOCKET], temp, len); - if(bytes_written < 0) { - err = SOCKERRNO; - failf(data,"Sending data failed (%d)",err); - return CURLE_SEND_ERROR; - } - printsub(data, '>', &temp[2], len-2); - break; - case CURL_TELOPT_NEW_ENVIRON: - len = curl_msnprintf((char *)temp, sizeof(temp), "%c%c%c%c", - CURL_IAC, CURL_SB, CURL_TELOPT_NEW_ENVIRON, - CURL_TELQUAL_IS); - for(v = tn->telnet_vars; v; v = v->next) { - size_t tmplen = (strlen(v->data) + 1); - if(bad_option(v->data)) - return CURLE_BAD_FUNCTION_ARGUMENT; - /* Add the variable if it fits */ - if(len + tmplen < (int)sizeof(temp)-6) { - char *s = strchr(v->data, ','); - if(!s) - len += curl_msnprintf((char *)&temp[len], sizeof(temp) - len, - "%c%s", CURL_NEW_ENV_VAR, v->data); - else { - size_t vlen = s - v->data; - len += curl_msnprintf((char *)&temp[len], sizeof(temp) - len, - "%c%.*s%c%s", CURL_NEW_ENV_VAR, - (int)vlen, v->data, CURL_NEW_ENV_VALUE, ++s); - } + /* Add the variable if it fits */ + if(len + tmplen < (int)sizeof(temp) - 6) { + char *s = strchr(v->data, ','); + if(!s) + len += curl_msnprintf((char *)&temp[len], sizeof(temp) - len, + "%c%s", CURL_NEW_ENV_VAR, v->data); + else { + size_t vlen = s - v->data; + len += curl_msnprintf((char *)&temp[len], sizeof(temp) - len, + "%c%.*s%c%s", CURL_NEW_ENV_VAR, + (int)vlen, v->data, CURL_NEW_ENV_VALUE, ++s); } } - curl_msnprintf((char *)&temp[len], sizeof(temp) - len, - "%c%c", CURL_IAC, CURL_SE); - len += 2; - bytes_written = swrite(conn->sock[FIRSTSOCKET], temp, len); - if(bytes_written < 0) { - err = SOCKERRNO; - failf(data,"Sending data failed (%d)",err); - } - printsub(data, '>', &temp[2], len-2); - break; + } + curl_msnprintf((char *)&temp[len], sizeof(temp) - len, + "%c%c", CURL_IAC, CURL_SE); + len += 2; + bytes_written = swrite(conn->sock[FIRSTSOCKET], temp, len); + if(bytes_written < 0) { + err = SOCKERRNO; + failf(data, "Sending data failed (%d)", err); + } + printsub(data, '>', &temp[2], len - 2); + break; } return CURLE_OK; } @@ -1063,7 +1053,7 @@ static void sendsuboption(struct Curl_easy *data, /* data suboption is now ready */ printsub(data, '>', (unsigned char *)tn->subbuffer + 2, - CURL_SB_LEN(tn)-2); + CURL_SB_LEN(tn) - 2); /* we send the header of the suboption... */ bytes_written = swrite(conn->sock[FIRSTSOCKET], tn->subbuffer, 3); @@ -1084,11 +1074,12 @@ static void sendsuboption(struct Curl_easy *data, } } -static -CURLcode telrcv(struct Curl_easy *data, - struct TELNET *tn, - const unsigned char *inbuf, /* Data received from socket */ - ssize_t count) /* Number of bytes received */ +static CURLcode telrcv(struct Curl_easy *data, + struct TELNET *tn, + const unsigned char *inbuf, /* Data received from + socket */ + ssize_t count) /* Number of bytes + received */ { unsigned char c; CURLcode result; @@ -1106,9 +1097,9 @@ CURLcode telrcv(struct Curl_easy *data, } \ startwrite = -1 -#define writebyte() \ - if(startwrite < 0) \ - startwrite = in +#define writebyte() \ + if(startwrite < 0) \ + startwrite = in #define bufferflush() startskipping() @@ -1170,79 +1161,79 @@ CURLcode telrcv(struct Curl_easy *data, } break; - case CURL_TS_WILL: - printoption(data, "RCVD", CURL_WILL, c); - tn->please_negotiate = 1; - rec_will(data, tn, c); - tn->telrcv_state = CURL_TS_DATA; - break; + case CURL_TS_WILL: + printoption(data, "RCVD", CURL_WILL, c); + tn->please_negotiate = 1; + rec_will(data, tn, c); + tn->telrcv_state = CURL_TS_DATA; + break; - case CURL_TS_WONT: - printoption(data, "RCVD", CURL_WONT, c); - tn->please_negotiate = 1; - rec_wont(data, tn, c); - tn->telrcv_state = CURL_TS_DATA; - break; + case CURL_TS_WONT: + printoption(data, "RCVD", CURL_WONT, c); + tn->please_negotiate = 1; + rec_wont(data, tn, c); + tn->telrcv_state = CURL_TS_DATA; + break; - case CURL_TS_DO: - printoption(data, "RCVD", CURL_DO, c); - tn->please_negotiate = 1; - rec_do(data, tn, c); - tn->telrcv_state = CURL_TS_DATA; - break; + case CURL_TS_DO: + printoption(data, "RCVD", CURL_DO, c); + tn->please_negotiate = 1; + rec_do(data, tn, c); + tn->telrcv_state = CURL_TS_DATA; + break; - case CURL_TS_DONT: - printoption(data, "RCVD", CURL_DONT, c); - tn->please_negotiate = 1; - rec_dont(data, tn, c); - tn->telrcv_state = CURL_TS_DATA; - break; + case CURL_TS_DONT: + printoption(data, "RCVD", CURL_DONT, c); + tn->please_negotiate = 1; + rec_dont(data, tn, c); + tn->telrcv_state = CURL_TS_DATA; + break; - case CURL_TS_SB: - if(c == CURL_IAC) - tn->telrcv_state = CURL_TS_SE; - else - CURL_SB_ACCUM(tn, c); - break; + case CURL_TS_SB: + if(c == CURL_IAC) + tn->telrcv_state = CURL_TS_SE; + else + CURL_SB_ACCUM(tn, c); + break; - case CURL_TS_SE: - if(c != CURL_SE) { - if(c != CURL_IAC) { - /* - * This is an error. We only expect to get "IAC IAC" or "IAC SE". - * Several things may have happened. An IAC was not doubled, the - * IAC SE was left off, or another option got inserted into the - * suboption are all possibilities. If we assume that the IAC was - * not doubled, and really the IAC SE was left off, we could get - * into an infinite loop here. So, instead, we terminate the - * suboption, and process the partial suboption if we can. - */ - CURL_SB_ACCUM(tn, CURL_IAC); - CURL_SB_ACCUM(tn, c); - tn->subpointer -= 2; - CURL_SB_TERM(tn); - - printoption(data, "In SUBOPTION processing, RCVD", CURL_IAC, c); - result = suboption(data, tn); /* handle sub-option */ - if(result) - return result; - tn->telrcv_state = CURL_TS_IAC; - goto process_iac; - } - CURL_SB_ACCUM(tn, c); - tn->telrcv_state = CURL_TS_SB; - } - else { + case CURL_TS_SE: + if(c != CURL_SE) { + if(c != CURL_IAC) { + /* + * This is an error. We only expect to get "IAC IAC" or "IAC SE". + * Several things may have happened. An IAC was not doubled, the + * IAC SE was left off, or another option got inserted into the + * suboption are all possibilities. If we assume that the IAC was + * not doubled, and really the IAC SE was left off, we could get + * into an infinite loop here. So, instead, we terminate the + * suboption, and process the partial suboption if we can. + */ CURL_SB_ACCUM(tn, CURL_IAC); - CURL_SB_ACCUM(tn, CURL_SE); + CURL_SB_ACCUM(tn, c); tn->subpointer -= 2; CURL_SB_TERM(tn); + + printoption(data, "In SUBOPTION processing, RCVD", CURL_IAC, c); result = suboption(data, tn); /* handle sub-option */ if(result) return result; - tn->telrcv_state = CURL_TS_DATA; + tn->telrcv_state = CURL_TS_IAC; + goto process_iac; } - break; + CURL_SB_ACCUM(tn, c); + tn->telrcv_state = CURL_TS_SB; + } + else { + CURL_SB_ACCUM(tn, CURL_IAC); + CURL_SB_ACCUM(tn, CURL_SE); + tn->subpointer -= 2; + CURL_SB_TERM(tn); + result = suboption(data, tn); /* handle sub-option */ + if(result) + return result; + tn->telrcv_state = CURL_TS_DATA; + } + break; } ++in; } @@ -1291,16 +1282,16 @@ static CURLcode send_telnet_data(struct Curl_easy *data, pfd[0].fd = conn->sock[FIRSTSOCKET]; pfd[0].events = POLLOUT; switch(Curl_poll(pfd, 1, -1)) { - case -1: /* error, abort writing */ - case 0: /* timeout (will never happen) */ - result = CURLE_SEND_ERROR; - break; - default: /* write! */ - bytes_written = 0; - result = Curl_xfer_send(data, outbuf + total_written, - outlen - total_written, FALSE, &bytes_written); - total_written += bytes_written; - break; + case -1: /* error, abort writing */ + case 0: /* timeout (will never happen) */ + result = CURLE_SEND_ERROR; + break; + default: /* write! */ + bytes_written = 0; + result = Curl_xfer_send(data, outbuf + total_written, + outlen - total_written, FALSE, &bytes_written); + total_written += bytes_written; + break; } } @@ -1326,8 +1317,8 @@ static CURLcode telnet_do(struct Curl_easy *data, bool *done) WSANETWORKEVENTS events; HANDLE stdin_handle; HANDLE objs[2]; - DWORD obj_count; - DWORD wait_timeout; + DWORD obj_count; + DWORD wait_timeout; DWORD readfile_read; int err; #else @@ -1340,7 +1331,7 @@ static CURLcode telnet_do(struct Curl_easy *data, bool *done) #endif struct curltime now; bool keepon = TRUE; - char buffer[4*1024]; + char buffer[4 * 1024]; struct TELNET *tn; *done = TRUE; /* unconditionally */ @@ -1371,7 +1362,8 @@ static CURLcode telnet_do(struct Curl_easy *data, bool *done) } /* Tell Winsock what events we want to listen to */ - if(WSAEventSelect(sockfd, event_handle, FD_READ|FD_CLOSE) == SOCKET_ERROR) { + if(WSAEventSelect(sockfd, event_handle, FD_READ | FD_CLOSE) == + SOCKET_ERROR) { WSACloseEvent(event_handle); return CURLE_RECV_ERROR; } @@ -1385,8 +1377,7 @@ static CURLcode telnet_do(struct Curl_easy *data, bool *done) /* If stdin_handle is a pipe, use PeekNamedPipe() method to check it, else use the old WaitForMultipleObjects() way */ - if(GetFileType(stdin_handle) == FILE_TYPE_PIPE || - data->set.is_fread_set) { + if(GetFileType(stdin_handle) == FILE_TYPE_PIPE || data->set.is_fread_set) { /* Do not wait for stdin_handle, just wait for event_handle */ obj_count = 1; /* Check stdin_handle per 100 milliseconds */ @@ -1404,8 +1395,7 @@ static CURLcode telnet_do(struct Curl_easy *data, bool *done) FALSE, wait_timeout); switch(waitret) { - case WAIT_TIMEOUT: - { + case WAIT_TIMEOUT: { for(;;) { if(data->set.is_fread_set) { size_t n; @@ -1438,8 +1428,7 @@ static CURLcode telnet_do(struct Curl_easy *data, bool *done) if(!readfile_read) break; - if(!ReadFile(stdin_handle, buffer, buf_size, - &readfile_read, NULL)) { + if(!ReadFile(stdin_handle, buffer, buf_size, &readfile_read, NULL)) { keepon = FALSE; result = CURLE_READ_ERROR; break; @@ -1455,10 +1444,8 @@ static CURLcode telnet_do(struct Curl_easy *data, bool *done) } break; - case WAIT_OBJECT_0 + 1: - { - if(!ReadFile(stdin_handle, buffer, buf_size, - &readfile_read, NULL)) { + case WAIT_OBJECT_0 + 1: { + if(!ReadFile(stdin_handle, buffer, buf_size, &readfile_read, NULL)) { keepon = FALSE; result = CURLE_READ_ERROR; break; @@ -1472,8 +1459,7 @@ static CURLcode telnet_do(struct Curl_easy *data, bool *done) } break; - case WAIT_OBJECT_0: - { + case WAIT_OBJECT_0: { events.lNetworkEvents = 0; if(WSAEnumNetworkEvents(sockfd, event_handle, &events) == SOCKET_ERROR) { err = SOCKERRNO; @@ -1503,7 +1489,7 @@ static CURLcode telnet_do(struct Curl_easy *data, bool *done) break; } - result = telrcv(data, tn, (unsigned char *) buffer, nread); + result = telrcv(data, tn, (unsigned char *)buffer, nread); if(result) { keepon = FALSE; break; @@ -1520,10 +1506,9 @@ static CURLcode telnet_do(struct Curl_easy *data, bool *done) if(events.lNetworkEvents & FD_CLOSE) { keepon = FALSE; } + break; } - break; - - } + } /* switch */ if(data->set.timeout) { now = curlx_now(); @@ -1622,7 +1607,7 @@ static CURLcode telnet_do(struct Curl_easy *data, bool *done) else { /* read from user-supplied method */ snread = (int)data->state.fread_func(buffer, 1, sizeof(buffer), - data->state.in); + data->state.in); if(snread == CURL_READFUNC_ABORT) { keepon = FALSE; break; diff --git a/lib/tftp.c b/lib/tftp.c index 5311a4c683a2..58e9696fb2c2 100644 --- a/lib/tftp.c +++ b/lib/tftp.c @@ -66,7 +66,7 @@ /* RFC2348 allows the block size to be negotiated */ #define TFTP_BLKSIZE_DEFAULT 512 -#define TFTP_OPTION_BLKSIZE "blksize" +#define TFTP_OPTION_BLKSIZE "blksize" /* from RFC2349: */ #define TFTP_OPTION_TSIZE "tsize" @@ -159,7 +159,6 @@ static CURLcode tftp_pollset(struct Curl_easy *data, struct easy_pollset *ps); static CURLcode tftp_translate_code(tftp_error_t error); - /* * TFTP protocol handler. */ @@ -221,7 +220,7 @@ static CURLcode tftp_set_timeouts(struct tftp_conn *state) timeout = 15; /* Average reposting an ACK after 5 seconds */ - state->retry_max = (int)timeout/5; + state->retry_max = (int)timeout / 5; /* But bound the total number */ if(state->retry_max < 3) @@ -231,7 +230,7 @@ static CURLcode tftp_set_timeouts(struct tftp_conn *state) state->retry_max = 50; /* Compute the re-ACK interval to suit the timeout */ - state->retry_time = (int)(timeout/state->retry_max); + state->retry_time = (int)(timeout / state->retry_max); if(state->retry_time < 1) state->retry_time = 1; @@ -259,7 +258,6 @@ static void setpacketevent(struct tftp_packet *packet, unsigned short num) packet->data[1] = (unsigned char)(num & 0xff); } - static void setpacketblock(struct tftp_packet *packet, unsigned short num) { packet->data[2] = (unsigned char)(num >> 8); @@ -279,7 +277,7 @@ static unsigned short getrpacketblock(const struct tftp_packet *packet) static size_t tftp_strnlen(const char *string, size_t maxlen) { const char *end = memchr(string, '\0', maxlen); - return end ? (size_t) (end - string) : maxlen; + return end ? (size_t)(end - string) : maxlen; } static const char *tftp_option_get(const char *buf, size_t len, @@ -294,7 +292,7 @@ static const char *tftp_option_get(const char *buf, size_t len, return NULL; *option = buf; - loc += tftp_strnlen(buf + loc, len-loc); + loc += tftp_strnlen(buf + loc, len - loc); loc++; /* NULL term */ if(loc > len) @@ -570,7 +568,7 @@ static CURLcode tftp_send_first(struct tftp_conn *state, /* the next blocknum is x + 1 but it needs to wrap at an unsigned 16bit boundary */ -#define NEXT_BLOCKNUM(x) (((x) + 1)&0xffff) +#define NEXT_BLOCKNUM(x) (((x) + 1) & 0xffff) /********************************************************** * @@ -784,7 +782,7 @@ static CURLcode tftp_tx(struct tftp_conn *state, tftp_event_t event) bufptr += cb; } while(state->sbytes < state->blksize && cb); - sbytes = sendto(state->sockfd, (void *) state->spacket.data, + sbytes = sendto(state->sockfd, (void *)state->spacket.data, 4 + (SEND_TYPE_ARG3)state->sbytes, SEND_4TH_ARG, (struct sockaddr *)&state->remote_addr, state->remote_addrlen); @@ -1136,15 +1134,14 @@ static CURLcode tftp_receive_packet(struct Curl_easy *data, (NEXT_BLOCKNUM(state->block) == getrpacketblock(&state->rpacket))) { result = Curl_client_write(data, CLIENTWRITE_BODY, (char *)state->rpacket.data + 4, - state->rbytes-4); + state->rbytes - 4); if(result) { tftp_state_machine(state, TFTP_EVENT_ERROR); return result; } } break; - case TFTP_EVENT_ERROR: - { + case TFTP_EVENT_ERROR: { unsigned short error = getrpacketblock(&state->rpacket); char *str = (char *)state->rpacket.data + 4; size_t strn = state->rbytes - 4; @@ -1328,7 +1325,6 @@ static CURLcode tftp_perform(struct Curl_easy *data, bool *dophase_done) return result; } - /********************************************************** * * tftp_do diff --git a/lib/transfer.c b/lib/transfer.c index d8a0d6c0ba2e..a8a66f86c7b9 100644 --- a/lib/transfer.c +++ b/lib/transfer.c @@ -82,7 +82,7 @@ #include "curlx/warnless.h" #if !defined(CURL_DISABLE_HTTP) || !defined(CURL_DISABLE_SMTP) || \ - !defined(CURL_DISABLE_IMAP) + !defined(CURL_DISABLE_IMAP) /* * checkheaders() checks the linked list of custom headers for a * particular header (prefix). Provide the prefix without colon! @@ -95,11 +95,11 @@ char *Curl_checkheaders(const struct Curl_easy *data, { struct curl_slist *head; DEBUGASSERT(thislen); - DEBUGASSERT(thisheader[thislen-1] != ':'); + DEBUGASSERT(thisheader[thislen - 1] != ':'); for(head = data->set.headers; head; head = head->next) { if(curl_strnequal(head->data, thisheader, thislen) && - Curl_headersep(head->data[thislen]) ) + Curl_headersep(head->data[thislen])) return head->data; } @@ -111,13 +111,13 @@ static int data_pending(struct Curl_easy *data, bool rcvd_eagain) { struct connectdata *conn = data->conn; - if(conn->handler->protocol&PROTO_FAMILY_FTP) + if(conn->handler->protocol & PROTO_FAMILY_FTP) return Curl_conn_data_pending(data, SECONDARYSOCKET); /* 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 (!rcvd_eagain && - conn->handler->protocol&(CURLPROTO_SCP|CURLPROTO_SFTP)) || + conn->handler->protocol & (CURLPROTO_SCP | CURLPROTO_SFTP)) || Curl_conn_data_pending(data, FIRSTSOCKET); } @@ -329,7 +329,7 @@ static CURLcode sendrecv_dl(struct Curl_easy *data, CURL_TRC_M(data, "sendrecv_dl() no EAGAIN/pending data, mark as dirty"); } - if(((k->keepon & (KEEP_RECV|KEEP_SEND)) == KEEP_SEND) && + if(((k->keepon & (KEEP_RECV | KEEP_SEND)) == KEEP_SEND) && (conn->bits.close || is_multiplex)) { /* When we have read the entire thing and the close bit is set, the server may now close the connection. If there is now any kind of sending going @@ -428,7 +428,7 @@ CURLcode Curl_sendrecv(struct Curl_easy *data, struct curltime *nowp) } /* If there is nothing more to send/recv, the request is done */ - if((k->keepon & (KEEP_RECV|KEEP_SEND)) == 0) + if((k->keepon & (KEEP_RECV | KEEP_SEND)) == 0) data->req.done = TRUE; result = Curl_pgrsUpdate(data); @@ -636,7 +636,7 @@ CURLcode Curl_retry_request(struct Curl_easy *data, char **url) protocol is HTTP as when uploading over HTTP we will still get a response */ if(data->state.upload && - !(conn->handler->protocol&(PROTO_FAMILY_HTTP|CURLPROTO_RTSP))) + !(conn->handler->protocol & (PROTO_FAMILY_HTTP | CURLPROTO_RTSP))) return CURLE_OK; if(conn->bits.reuse && @@ -656,7 +656,7 @@ CURLcode Curl_retry_request(struct Curl_easy *data, char **url) it again. Bad luck. Retry the same request on a fresh connect! */ retry = TRUE; else if(data->state.refused_stream && - (data->req.bytecount + data->req.headerbytecount == 0) ) { + (data->req.bytecount + data->req.headerbytecount == 0)) { /* This was sent on a refused stream, safe to rerun. A refused stream error can typically only happen on HTTP/2 level if the stream is safe to issue again, but the nghttp2 API can deliver the message to other diff --git a/lib/transfer.h b/lib/transfer.h index b96629d97968..3da5e2445139 100644 --- a/lib/transfer.h +++ b/lib/transfer.h @@ -24,7 +24,8 @@ * ***************************************************************************/ -#define Curl_headersep(x) ((((x)==':') || ((x)==';'))) +#define Curl_headersep(x) ((((x) == ':') || ((x) == ';'))) + char *Curl_checkheaders(const struct Curl_easy *data, const char *thisheader, const size_t thislen); diff --git a/lib/uint-bset.c b/lib/uint-bset.c index dcad94e42a6e..d41d982b3a23 100644 --- a/lib/uint-bset.c +++ b/lib/uint-bset.c @@ -37,10 +37,9 @@ void Curl_uint32_bset_init(struct uint32_bset *bset) #endif } - CURLcode Curl_uint32_bset_resize(struct uint32_bset *bset, uint32_t nmax) { - uint32_t nslots = (nmax < (UINT32_MAX-63)) ? + uint32_t nslots = (nmax < (UINT32_MAX - 63)) ? ((nmax + 63) / 64) : (UINT32_MAX / 64); DEBUGASSERT(bset->init == CURL_UINT32_BSET_MAGIC); @@ -61,7 +60,6 @@ CURLcode Curl_uint32_bset_resize(struct uint32_bset *bset, uint32_t nmax) return CURLE_OK; } - void Curl_uint32_bset_destroy(struct uint32_bset *bset) { DEBUGASSERT(bset->init == CURL_UINT32_BSET_MAGIC); @@ -97,7 +95,6 @@ bool Curl_uint32_bset_empty(struct uint32_bset *bset) return TRUE; } - void Curl_uint32_bset_clear(struct uint32_bset *bset) { if(bset->nslots) { @@ -106,7 +103,6 @@ void Curl_uint32_bset_clear(struct uint32_bset *bset) } } - bool Curl_uint32_bset_add(struct uint32_bset *bset, uint32_t i) { uint32_t islot = i / 64; @@ -118,7 +114,6 @@ bool Curl_uint32_bset_add(struct uint32_bset *bset, uint32_t i) return TRUE; } - void Curl_uint32_bset_remove(struct uint32_bset *bset, uint32_t i) { size_t islot = i / 64; @@ -126,7 +121,6 @@ void Curl_uint32_bset_remove(struct uint32_bset *bset, uint32_t i) bset->slots[islot] &= ~((uint64_t)1 << (i % 64)); } - bool Curl_uint32_bset_contains(struct uint32_bset *bset, uint32_t i) { uint32_t islot = i / 64; @@ -135,7 +129,6 @@ bool Curl_uint32_bset_contains(struct uint32_bset *bset, uint32_t i) return (bset->slots[islot] & ((uint64_t)1 << (i % 64))) != 0; } - bool Curl_uint32_bset_first(struct uint32_bset *bset, uint32_t *pfirst) { uint32_t i; @@ -198,7 +191,6 @@ uint32_t Curl_popcount64(uint64_t x) } #endif /* CURL_POPCOUNT64_IMPLEMENT */ - #ifdef CURL_CTZ64_IMPLEMENT uint32_t Curl_ctz64(uint64_t x) { diff --git a/lib/uint-bset.h b/lib/uint-bset.h index 5e5bbdb8fc0b..ff814bb5e6ad 100644 --- a/lib/uint-bset.h +++ b/lib/uint-bset.h @@ -99,9 +99,8 @@ bool Curl_uint32_bset_first(struct uint32_bset *bset, uint32_t *pfirst); bool Curl_uint32_bset_next(struct uint32_bset *bset, uint32_t last, uint32_t *pnext); - #ifndef CURL_POPCOUNT64 -#define CURL_POPCOUNT64(x) Curl_popcount64(x) +#define CURL_POPCOUNT64(x) Curl_popcount64(x) #define CURL_POPCOUNT64_IMPLEMENT uint32_t Curl_popcount64(uint64_t x); #endif /* !CURL_POPCOUNT64 */ diff --git a/lib/uint-hash.c b/lib/uint-hash.c index 166a9ab99ba5..43de42a19c8b 100644 --- a/lib/uint-hash.c +++ b/lib/uint-hash.c @@ -38,10 +38,9 @@ static uint32_t uint32_hash_hash(uint32_t id, uint32_t slots) return (id % slots); } - struct uint_hash_entry { struct uint_hash_entry *next; - void *value; + void *value; uint32_t id; }; @@ -111,8 +110,8 @@ static void uint32_hash_elem_link(struct uint_hash *h, ++h->size; } -#define CURL_UINT32_HASH_SLOT(h,id) h->table[uint32_hash_hash(id, h->slots)] -#define CURL_UINT32_HASH_SLOT_ADDR(h,id) &CURL_UINT32_HASH_SLOT(h,id) +#define CURL_UINT32_HASH_SLOT(h, id) h->table[uint32_hash_hash(id, h->slots)] +#define CURL_UINT32_HASH_SLOT_ADDR(h, id) &CURL_UINT32_HASH_SLOT(h, id) bool Curl_uint32_hash_set(struct uint_hash *h, uint32_t id, void *value) { diff --git a/lib/uint-hash.h b/lib/uint-hash.h index 330f61208bfa..3e09a6234821 100644 --- a/lib/uint-hash.h +++ b/lib/uint-hash.h @@ -45,7 +45,6 @@ struct uint_hash { #endif }; - void Curl_uint32_hash_init(struct uint_hash *h, uint32_t slots, Curl_uint32_hash_dtor *dtor); @@ -57,7 +56,6 @@ bool Curl_uint32_hash_remove(struct uint_hash *h, uint32_t id); void *Curl_uint32_hash_get(struct uint_hash *h, uint32_t id); uint32_t Curl_uint32_hash_count(struct uint_hash *h); - typedef bool Curl_uint32_hash_visit_cb(uint32_t id, void *value, void *user_data); diff --git a/lib/uint-spbset.c b/lib/uint-spbset.c index c726bfb900c1..84a893e85f5a 100644 --- a/lib/uint-spbset.c +++ b/lib/uint-spbset.c @@ -86,7 +86,6 @@ UNITTEST void Curl_uint32_spbset_clear(struct uint32_spbset *bset) memset(&bset->head, 0, sizeof(bset->head)); } - static struct uint32_spbset_chunk * uint32_spbset_get_chunk(struct uint32_spbset *bset, uint32_t i, bool grow) { @@ -129,7 +128,6 @@ uint32_spbset_get_chunk(struct uint32_spbset *bset, uint32_t i, bool grow) return chunk; } - bool Curl_uint32_spbset_add(struct uint32_spbset *bset, uint32_t i) { struct uint32_spbset_chunk *chunk; @@ -146,7 +144,6 @@ bool Curl_uint32_spbset_add(struct uint32_spbset *bset, uint32_t i) return TRUE; } - void Curl_uint32_spbset_remove(struct uint32_spbset *bset, uint32_t i) { struct uint32_spbset_chunk *chunk; @@ -161,7 +158,6 @@ void Curl_uint32_spbset_remove(struct uint32_spbset *bset, uint32_t i) } } - bool Curl_uint32_spbset_contains(struct uint32_spbset *bset, uint32_t i) { struct uint32_spbset_chunk *chunk; @@ -195,7 +191,6 @@ bool Curl_uint32_spbset_first(struct uint32_spbset *bset, uint32_t *pfirst) return FALSE; } - static bool uint32_spbset_chunk_first(struct uint32_spbset_chunk *chunk, uint32_t *pfirst) { @@ -210,7 +205,6 @@ static bool uint32_spbset_chunk_first(struct uint32_spbset_chunk *chunk, return FALSE; } - static bool uint32_spbset_chunk_next(struct uint32_spbset_chunk *chunk, uint32_t last, uint32_t *pnext) diff --git a/lib/uint-table.c b/lib/uint-table.c index 05b53766f30a..b4d5d94a3a36 100644 --- a/lib/uint-table.c +++ b/lib/uint-table.c @@ -43,7 +43,6 @@ void Curl_uint32_tbl_init(struct uint32_tbl *tbl, #endif } - static void uint32_tbl_clear_rows(struct uint32_tbl *tbl, uint32_t from, uint32_t upto_excluding) @@ -61,7 +60,6 @@ static void uint32_tbl_clear_rows(struct uint32_tbl *tbl, } } - CURLcode Curl_uint32_tbl_resize(struct uint32_tbl *tbl, uint32_t nrows) { /* we use `tbl->nrows + 1` during iteration, want that to work */ @@ -84,7 +82,6 @@ CURLcode Curl_uint32_tbl_resize(struct uint32_tbl *tbl, uint32_t nrows) return CURLE_OK; } - void Curl_uint32_tbl_destroy(struct uint32_tbl *tbl) { DEBUGASSERT(tbl->init == CURL_UINT32_TBL_MAGIC); @@ -101,25 +98,21 @@ UNITTEST void Curl_uint32_tbl_clear(struct uint32_tbl *tbl) tbl->last_key_added = UINT32_MAX; } - uint32_t Curl_uint32_tbl_capacity(struct uint32_tbl *tbl) { return tbl->nrows; } - uint32_t Curl_uint32_tbl_count(struct uint32_tbl *tbl) { return tbl->nentries; } - void *Curl_uint32_tbl_get(struct uint32_tbl *tbl, uint32_t key) { return (key < tbl->nrows) ? tbl->rows[key] : NULL; } - bool Curl_uint32_tbl_add(struct uint32_tbl *tbl, void *entry, uint32_t *pkey) { uint32_t key, start_pos; @@ -156,19 +149,16 @@ bool Curl_uint32_tbl_add(struct uint32_tbl *tbl, void *entry, uint32_t *pkey) return FALSE; } - void Curl_uint32_tbl_remove(struct uint32_tbl *tbl, uint32_t key) { uint32_tbl_clear_rows(tbl, key, key + 1); } - bool Curl_uint32_tbl_contains(struct uint32_tbl *tbl, uint32_t key) { return (key < tbl->nrows) ? !!tbl->rows[key] : FALSE; } - static bool uint32_tbl_next_at(struct uint32_tbl *tbl, uint32_t key, uint32_t *pkey, void **pentry) { @@ -197,7 +187,6 @@ bool Curl_uint32_tbl_first(struct uint32_tbl *tbl, return FALSE; } - bool Curl_uint32_tbl_next(struct uint32_tbl *tbl, uint32_t last_key, uint32_t *pkey, void **pentry) { diff --git a/lib/url.c b/lib/url.c index 84909f037238..f646b74ed4a7 100644 --- a/lib/url.c +++ b/lib/url.c @@ -148,16 +148,16 @@ static void data_priority_cleanup(struct Curl_easy *data); #define MAX_URL_LEN 0xffff /* -* 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. -*/ + * 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 curl_prot_t get_protocol_family(const struct Curl_handler *h) { DEBUGASSERT(h); @@ -460,8 +460,7 @@ void Curl_init_userdefined(struct Curl_easy *data) set->conn_max_idle_ms = 118 * 1000; set->conn_max_age_ms = 24 * 3600 * 1000; set->http09_allowed = FALSE; - set->httpwant = CURL_HTTP_VERSION_NONE - ; + set->httpwant = CURL_HTTP_VERSION_NONE; #if defined(USE_HTTP2) || defined(USE_HTTP3) memset(&set->priority, 0, sizeof(set->priority)); #endif @@ -592,7 +591,7 @@ static bool xfer_may_multiplex(const struct Curl_easy *data, (!conn->bits.protoconnstart || !conn->bits.close)) { if(Curl_multiplex_wanted(data->multi) && - (data->state.http_neg.allowed & (CURL_HTTP_V2x|CURL_HTTP_V3x))) + (data->state.http_neg.allowed & (CURL_HTTP_V2x | CURL_HTTP_V3x))) /* allows HTTP/2 or newer */ return TRUE; } @@ -604,9 +603,8 @@ static bool xfer_may_multiplex(const struct Curl_easy *data, } #ifndef CURL_DISABLE_PROXY -static bool -proxy_info_matches(const struct proxy_info *data, - const struct proxy_info *needle) +static bool proxy_info_matches(const struct proxy_info *data, + const struct proxy_info *needle) { if((data->proxytype == needle->proxytype) && (data->port == needle->port) && @@ -616,9 +614,8 @@ 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) +static bool socks_proxy_info_matches(const struct proxy_info *data, + const struct proxy_info *needle) { if(!proxy_info_matches(data, needle)) return FALSE; @@ -636,8 +633,8 @@ socks_proxy_info_matches(const struct proxy_info *data, } #else /* disabled, will not get called */ -#define proxy_info_matches(x,y) FALSE -#define socks_proxy_info_matches(x,y) FALSE +#define proxy_info_matches(x, y) FALSE +#define socks_proxy_info_matches(x, y) FALSE #endif /* A connection has to have been idle for less than 'conn_max_idle_ms' @@ -708,7 +705,6 @@ bool Curl_conn_seems_dead(struct connectdata *conn, dead = (state & CONNRESULT_DEAD); /* detach the connection again */ Curl_detach_connection(data); - } else { bool input_pending = FALSE; @@ -803,8 +799,8 @@ static bool url_match_connect_config(struct connectdata *conn, return FALSE; /* ip_version must match */ - if(m->data->set.ipver != CURL_IPRESOLVE_WHATEVER - && m->data->set.ipver != conn->ip_version) + if(m->data->set.ipver != CURL_IPRESOLVE_WHATEVER && + m->data->set.ipver != conn->ip_version) return FALSE; if(m->needle->localdev || m->needle->localport) { @@ -913,7 +909,7 @@ static bool url_match_multiplex_limits(struct connectdata *conn, return FALSE; } if(CONN_ATTACHED(conn) >= - Curl_conn_get_max_concurrent(m->data, conn, FIRSTSOCKET)) { + Curl_conn_get_max_concurrent(m->data, conn, FIRSTSOCKET)) { infof(m->data, "MAX_CONCURRENT_STREAMS reached, skip (%u)", CONN_ATTACHED(conn)); return FALSE; @@ -951,8 +947,7 @@ static bool url_match_proxy_use(struct connectdata *conn, return FALSE; if(m->needle->bits.socksproxy && - !socks_proxy_info_matches(&m->needle->socks_proxy, - &conn->socks_proxy)) + !socks_proxy_info_matches(&m->needle->socks_proxy, &conn->socks_proxy)) return FALSE; if(m->needle->bits.httpproxy) { @@ -969,9 +964,9 @@ static bool url_match_proxy_use(struct connectdata *conn, /* match SSL config to proxy */ if(!Curl_ssl_conn_config_match(m->data, conn, TRUE)) { DEBUGF(infof(m->data, - "Connection #%" FMT_OFF_T - " has different SSL proxy parameters, cannot reuse", - conn->connection_id)); + "Connection #%" FMT_OFF_T + " has different SSL proxy parameters, cannot reuse", + conn->connection_id)); return FALSE; } /* the SSL config to the server, which may apply here is checked @@ -981,7 +976,7 @@ static bool url_match_proxy_use(struct connectdata *conn, return TRUE; } #else -#define url_match_proxy_use(c,m) ((void)c, (void)m, TRUE) +#define url_match_proxy_use(c, m) ((void)c, (void)m, TRUE) #endif #ifndef CURL_DISABLE_HTTP @@ -989,7 +984,7 @@ static bool url_match_http_multiplex(struct connectdata *conn, struct url_conn_match *m) { if(m->may_multiplex && - (m->data->state.http_neg.allowed & (CURL_HTTP_V2x|CURL_HTTP_V3x)) && + (m->data->state.http_neg.allowed & (CURL_HTTP_V2x | CURL_HTTP_V3x)) && (m->needle->handler->protocol & CURLPROTO_HTTP) && !conn->httpversion_seen) { if(m->data->set.pipewait) { @@ -1037,8 +1032,8 @@ static bool url_match_http_version(struct connectdata *conn, return TRUE; } #else -#define url_match_http_multiplex(c,m) ((void)c, (void)m, TRUE) -#define url_match_http_version(c,m) ((void)c, (void)m, TRUE) +#define url_match_http_multiplex(c, m) ((void)c, (void)m, TRUE) +#define url_match_http_version(c, m) ((void)c, (void)m, TRUE) #endif static bool url_match_proto_config(struct connectdata *conn, @@ -1091,7 +1086,7 @@ static bool url_match_destination(struct connectdata *conn, { /* Additional match requirements if talking TLS OR * not talking to an HTTP proxy OR using a tunnel through a proxy */ - if((m->needle->handler->flags&PROTOPT_SSL) + if((m->needle->handler->flags & PROTOPT_SSL) #ifndef CURL_DISABLE_PROXY || !m->needle->bits.httpproxy || m->needle->bits.tunnel_proxy #endif @@ -1116,7 +1111,7 @@ static bool url_match_destination(struct connectdata *conn, if((m->needle->bits.conn_to_host && !curl_strequal( m->needle->conn_to_host.name, conn->conn_to_host.name)) || (m->needle->bits.conn_to_port && - m->needle->conn_to_port != conn->conn_to_port)) + m->needle->conn_to_port != conn->conn_to_port)) return FALSE; /* hostname and port must match */ @@ -1207,7 +1202,7 @@ static bool url_match_auth_ntlm(struct connectdata *conn, return TRUE; } #else -#define url_match_auth_ntlm(c,m) ((void)c, (void)m, TRUE) +#define url_match_auth_ntlm(c, m) ((void)c, (void)m, TRUE) #endif static bool url_match_conn(struct connectdata *conn, void *userdata) @@ -1303,12 +1298,11 @@ static bool url_match_result(bool result, void *userdata) * * The force_reuse flag is set if the connection must be used. */ -static bool -ConnectionExists(struct Curl_easy *data, - struct connectdata *needle, - struct connectdata **usethis, - bool *force_reuse, - bool *waitpipe) +static bool ConnectionExists(struct Curl_easy *data, + struct connectdata *needle, + struct connectdata **usethis, + bool *force_reuse, + bool *waitpipe) { struct url_conn_match match; bool result; @@ -1676,12 +1670,11 @@ static CURLcode findprotocol(struct Curl_easy *data, create_conn() function when the connectdata struct is allocated. */ failf(data, "Protocol \"%s\" %s%s", protostr, p ? "disabled" : "not supported", - data->state.this_is_a_follow ? " (in redirect)":""); + data->state.this_is_a_follow ? " (in redirect)" : ""); return CURLE_UNSUPPORTED_PROTOCOL; } - CURLcode Curl_uc_to_curlcode(CURLUcode uc) { switch(uc) { @@ -1747,7 +1740,7 @@ static void zonefrom_url(CURLU *uh, struct Curl_easy *data, } } #else -#define zonefrom_url(a,b,c) Curl_nop_stmt +#define zonefrom_url(a, b, c) Curl_nop_stmt #endif /* @@ -1940,8 +1933,7 @@ static CURLcode parseurlandfillconn(struct Curl_easy *data, else if(uc != CURLUE_NO_OPTIONS) return Curl_uc_to_curlcode(uc); - uc = curl_url_get(uh, CURLUPART_PATH, &data->state.up.path, - CURLU_URLENCODE); + uc = curl_url_get(uh, CURLUPART_PATH, &data->state.up.path, CURLU_URLENCODE); if(uc) return Curl_uc_to_curlcode(uc); @@ -1978,7 +1970,6 @@ static CURLcode parseurlandfillconn(struct Curl_easy *data, return CURLE_OK; } - /* * If we are doing a resumed transfer, we need to setup our stuff * properly. @@ -2010,7 +2001,6 @@ static CURLcode setup_range(struct Curl_easy *data) return CURLE_OK; } - /* * setup_connection_internals() - * @@ -2066,15 +2056,14 @@ static CURLcode setup_connection_internals(struct Curl_easy *data, return CURLE_OK; } - #ifndef CURL_DISABLE_PROXY #ifndef CURL_DISABLE_HTTP /**************************************************************** -* Detect what (if any) proxy to use. Remember that this selects a host -* name and is not limited to HTTP proxies only. -* The returned pointer must be freed by the caller (unless NULL) -****************************************************************/ + * Detect what (if any) proxy to use. Remember that this selects a host + * name and is not limited to HTTP proxies only. + * The returned pointer must be freed by the caller (unless NULL) + ****************************************************************/ static char *detect_proxy(struct Curl_easy *data, struct connectdata *conn) { @@ -2189,7 +2178,7 @@ static CURLcode parse_proxy(struct Curl_easy *data, /* When parsing the proxy, allowing non-supported schemes since we have these made up ones for proxies. Guess scheme for URLs without it. */ uc = curl_url_set(uhp, CURLUPART_URL, proxy, - CURLU_NON_SUPPORT_SCHEME|CURLU_GUESS_SCHEME); + CURLU_NON_SUPPORT_SCHEME | CURLU_GUESS_SCHEME); if(!uc) { /* parsed okay as a URL */ uc = curl_url_get(uhp, CURLUPART_SCHEME, &scheme, 0); @@ -2327,7 +2316,7 @@ static CURLcode parse_proxy(struct Curl_easy *data, if(strcmp("/", path)) { is_unix_proxy = TRUE; curlx_free(host); - host = curl_maprintf(UNIX_SOCKET_PREFIX"%s", path); + host = curl_maprintf(UNIX_SOCKET_PREFIX "%s", path); if(!host) { result = CURLE_OUT_OF_MEMORY; goto error; @@ -2346,7 +2335,7 @@ static CURLcode parse_proxy(struct Curl_easy *data, if(host[0] == '[') { /* this is a numerical IPv6, strip off the brackets */ size_t len = strlen(host); - host[len-1] = 0; /* clear the trailing bracket */ + host[len - 1] = 0; /* clear the trailing bracket */ host++; zonefrom_url(uhp, data, conn); } @@ -2753,7 +2742,7 @@ static CURLcode override_login(struct Curl_easy *data, return CURLE_READ_ERROR; } else { - if(!(conn->handler->flags&PROTOPT_USERPWDCTRL)) { + if(!(conn->handler->flags & PROTOPT_USERPWDCTRL)) { /* if the protocol cannot handle control codes in credentials, make sure there are none */ if(str_has_ctrl(*userp) || str_has_ctrl(*passwdp)) { @@ -3475,7 +3464,7 @@ static CURLcode create_conn(struct Curl_easy *data, * If the protocol is using SSL and HTTP proxy is used, we set * the tunnel_proxy bit. *************************************************************/ - if((conn->given->flags&PROTOPT_SSL) && conn->bits.httpproxy) + if((conn->given->flags & PROTOPT_SSL) && conn->bits.httpproxy) conn->bits.tunnel_proxy = TRUE; #endif @@ -3548,7 +3537,7 @@ static CURLcode create_conn(struct Curl_easy *data, * we set the tunnel_proxy bit. *************************************************************/ if((conn->bits.conn_to_host || conn->bits.conn_to_port) && - conn->bits.httpproxy) + conn->bits.httpproxy) conn->bits.tunnel_proxy = TRUE; #endif @@ -4006,7 +3995,6 @@ void Curl_data_priority_clear_state(struct Curl_easy *data) #endif /* USE_HTTP2 || USE_HTTP3 */ - CURLcode Curl_conn_meta_set(struct connectdata *conn, const char *key, void *meta_data, Curl_meta_dtor *meta_dtor) { diff --git a/lib/urlapi.c b/lib/urlapi.c index ad4d367dc34c..b8814cf85284 100644 --- a/lib/urlapi.c +++ b/lib/urlapi.c @@ -38,19 +38,19 @@ #include "curl_memrchr.h" #ifdef _WIN32 - /* MS-DOS/Windows style drive prefix, eg c: in c:foo */ -#define STARTS_WITH_DRIVE_PREFIX(str) \ - ((('a' <= str[0] && str[0] <= 'z') || \ +/* MS-DOS/Windows style drive prefix, eg c: in c:foo */ +#define STARTS_WITH_DRIVE_PREFIX(str) \ + ((('a' <= str[0] && str[0] <= 'z') || \ ('A' <= str[0] && str[0] <= 'Z')) && \ (str[1] == ':')) #endif - /* MS-DOS/Windows style drive prefix, optionally with - * a '|' instead of ':', followed by a slash or NUL */ -#define STARTS_WITH_URL_DRIVE_PREFIX(str) \ - ((('a' <= (str)[0] && (str)[0] <= 'z') || \ - ('A' <= (str)[0] && (str)[0] <= 'Z')) && \ - ((str)[1] == ':' || (str)[1] == '|') && \ +/* MS-DOS/Windows style drive prefix, optionally with + * a '|' instead of ':', followed by a slash or NUL */ +#define STARTS_WITH_URL_DRIVE_PREFIX(str) \ + ((('a' <= (str)[0] && (str)[0] <= 'z') || \ + ('A' <= (str)[0] && (str)[0] <= 'Z')) && \ + ((str)[1] == ':' || (str)[1] == '|') && \ ((str)[2] == '/' || (str)[2] == '\\' || (str)[2] == 0)) /* scheme is not URL encoded, the longest libcurl supported ones are... */ @@ -139,12 +139,12 @@ static CURLUcode urlencode_str(struct dynbuf *o, const char *url, /* we must add this with whitespace-replacing */ bool left = !query; const unsigned char *iptr; - const unsigned char *host_sep = (const unsigned char *) url; + const unsigned char *host_sep = (const unsigned char *)url; CURLcode result = CURLE_OK; if(!relative) { size_t n; - host_sep = (const unsigned char *) find_host_sep(url); + host_sep = (const unsigned char *)find_host_sep(url); /* output the first piece as-is */ n = (const char *)host_sep - url; @@ -160,7 +160,7 @@ static CURLUcode urlencode_str(struct dynbuf *o, const char *url, result = curlx_dyn_addn(o, "+", 1); } else if((*iptr < ' ') || (*iptr >= 0x7f)) { - unsigned char out[3]={'%'}; + unsigned char out[3] = { '%' }; Curl_hexbyte(&out[1], *iptr); result = curlx_dyn_addn(o, out, 3); } @@ -199,7 +199,7 @@ size_t Curl_is_absolute_url(const char *url, char *buf, size_t buflen, if(ISALPHA(url[0])) for(i = 1; i < MAX_SCHEME_LEN; ++i) { char s = url[i]; - if(s && (ISALNUM(s) || (s == '+') || (s == '-') || (s == '.') )) { + if(s && (ISALNUM(s) || (s == '+') || (s == '-') || (s == '.'))) { /* RFC 3986 3.1 explains: scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." ) */ @@ -453,7 +453,7 @@ UNITTEST CURLUcode Curl_parse_port(struct Curl_URL *u, struct dynbuf *host, if(curlx_str_number(&portptr, &port, 0xffff) || *portptr) return CURLUE_BAD_PORT_NUMBER; - u->portnum = (unsigned short) port; + u->portnum = (unsigned short)port; /* generate a new port number string to get rid of leading zeroes etc */ curlx_free(u->port); u->port = curl_maprintf("%" CURL_FORMAT_CURL_OFF_T, port); @@ -563,7 +563,7 @@ static int ipv4_normalize(struct dynbuf *host) bool done = FALSE; int n = 0; const char *c = curlx_dyn_ptr(host); - unsigned int parts[4] = {0, 0, 0, 0}; + unsigned int parts[4] = { 0, 0, 0, 0 }; CURLcode result = CURLE_OK; if(*c == '[') @@ -920,7 +920,7 @@ static CURLUcode parseurl(const char *url, CURLU *u, unsigned int flags) goto fail; schemelen = Curl_is_absolute_url(url, schemebuf, sizeof(schemebuf), - flags & (CURLU_GUESS_SCHEME| + flags & (CURLU_GUESS_SCHEME | CURLU_DEFAULT_SCHEME)); /* handle the file: scheme */ @@ -1036,7 +1036,6 @@ static CURLUcode parseurl(const char *url, CURLU *u, unsigned int flags) pathlen--; } #endif - } else { /* clear path */ @@ -1069,7 +1068,7 @@ static CURLUcode parseurl(const char *url, CURLU *u, unsigned int flags) else { /* no scheme! */ - if(!(flags & (CURLU_DEFAULT_SCHEME|CURLU_GUESS_SCHEME))) { + if(!(flags & (CURLU_DEFAULT_SCHEME | CURLU_GUESS_SCHEME))) { result = CURLUE_BAD_SCHEME; goto fail; } @@ -1318,8 +1317,8 @@ CURLU *curl_url_dup(const CURLU *in) } #ifndef USE_IDN -#define host_decode(x,y) CURLUE_LACKS_IDN -#define host_encode(x,y) CURLUE_LACKS_IDN +#define host_decode(x, y) CURLUE_LACKS_IDN +#define host_encode(x, y) CURLUE_LACKS_IDN #else static CURLUcode host_decode(const char *host, char **allochost) { @@ -1697,7 +1696,7 @@ static CURLUcode set_url(CURLU *u, const char *url, size_t part_size, /* if the new URL is absolute replace the existing with the new. */ if(Curl_is_absolute_url(url, NULL, 0, - flags & (CURLU_GUESS_SCHEME|CURLU_DEFAULT_SCHEME))) + flags & (CURLU_GUESS_SCHEME | CURLU_DEFAULT_SCHEME))) return parseurl_and_replace(url, u, flags); /* if the old URL is incomplete (we cannot get an absolute URL in @@ -1765,11 +1764,24 @@ static CURLUcode urlset_clear(CURLU *u, CURLUPart what) static bool allowed_in_path(unsigned char x) { switch(x) { - case '!': case '$': case '&': case '\'': - case '(': case ')': case '{': case '}': - case '[': case ']': case '*': case '+': - case ',': case ';': case '=': case ':': - case '@': case '/': + case '!': + case '$': + case '&': + case '\'': + case '(': + case ')': + case '{': + case '}': + case '[': + case ']': + case '*': + case '+': + case ',': + case ';': + case '=': + case ':': + case '@': + case '/': return TRUE; } return FALSE; @@ -1878,7 +1890,7 @@ CURLUcode curl_url_set(CURLU *u, CURLUPart what, return cc2cu(result); } else { - unsigned char out[3]={'%'}; + unsigned char out[3] = { '%' }; Curl_hexbyte(&out[1], *i); result = curlx_dyn_addn(&enc, out, 3); if(result) @@ -1911,7 +1923,7 @@ CURLUcode curl_url_set(CURLU *u, CURLUPart what, none is present at the end of the existing query already */ size_t querylen = u->query ? strlen(u->query) : 0; - bool addamperand = querylen && (u->query[querylen -1] != '&'); + bool addamperand = querylen && (u->query[querylen - 1] != '&'); if(querylen) { struct dynbuf qbuf; curlx_dyn_init(&qbuf, CURL_MAX_INPUT_LENGTH); diff --git a/lib/urldata.h b/lib/urldata.h index 1c91099d153d..aa1326d2a645 100644 --- a/lib/urldata.h +++ b/lib/urldata.h @@ -28,40 +28,40 @@ #include "curl_setup.h" -#define PORT_FTP 21 -#define PORT_FTPS 990 +#define PORT_FTP 21 +#define PORT_FTPS 990 #define PORT_TELNET 23 -#define PORT_HTTP 80 -#define PORT_HTTPS 443 -#define PORT_DICT 2628 -#define PORT_LDAP 389 -#define PORT_LDAPS 636 -#define PORT_TFTP 69 -#define PORT_SSH 22 -#define PORT_IMAP 143 -#define PORT_IMAPS 993 -#define PORT_POP3 110 -#define PORT_POP3S 995 -#define PORT_SMB 445 -#define PORT_SMBS 445 -#define PORT_SMTP 25 -#define PORT_SMTPS 465 /* sometimes called SSMTP */ -#define PORT_RTSP 554 -#define PORT_RTMP 1935 -#define PORT_RTMPT PORT_HTTP -#define PORT_RTMPS PORT_HTTPS +#define PORT_HTTP 80 +#define PORT_HTTPS 443 +#define PORT_DICT 2628 +#define PORT_LDAP 389 +#define PORT_LDAPS 636 +#define PORT_TFTP 69 +#define PORT_SSH 22 +#define PORT_IMAP 143 +#define PORT_IMAPS 993 +#define PORT_POP3 110 +#define PORT_POP3S 995 +#define PORT_SMB 445 +#define PORT_SMBS 445 +#define PORT_SMTP 25 +#define PORT_SMTPS 465 /* sometimes called SSMTP */ +#define PORT_RTSP 554 +#define PORT_RTMP 1935 +#define PORT_RTMPT PORT_HTTP +#define PORT_RTMPS PORT_HTTPS #define PORT_GOPHER 70 -#define PORT_MQTT 1883 +#define PORT_MQTT 1883 struct curl_trc_featt; #ifdef USE_ECH /* CURLECH_ bits for the tls_ech option */ -# define CURLECH_DISABLE (1<<0) -# define CURLECH_GREASE (1<<1) -# define CURLECH_ENABLE (1<<2) -# define CURLECH_HARD (1<<3) -# define CURLECH_CLA_CFG (1<<4) +# define CURLECH_DISABLE (1 << 0) +# define CURLECH_GREASE (1 << 1) +# define CURLECH_ENABLE (1 << 2) +# define CURLECH_HARD (1 << 3) +# define CURLECH_CLA_CFG (1 << 4) #endif #ifndef CURL_DISABLE_WEBSOCKETS @@ -70,8 +70,8 @@ struct curl_trc_featt; * platforms that have a >= 64-bit type and then we use such a type for the * protocol fields in the protocol handler. */ -#define CURLPROTO_WS (1L<<30) -#define CURLPROTO_WSS ((curl_prot_t)1<<31) +#define CURLPROTO_WS (1L << 30) +#define CURLPROTO_WSS ((curl_prot_t)1 << 31) #else #define CURLPROTO_WS 0L #define CURLPROTO_WSS 0L @@ -107,15 +107,15 @@ typedef unsigned int curl_prot_t; /* Convenience defines for checking protocols or their SSL based version. Each protocol handler should only ever have a single CURLPROTO_ in its protocol field. */ -#define PROTO_FAMILY_HTTP (CURLPROTO_HTTP|CURLPROTO_HTTPS|CURLPROTO_WS| \ +#define PROTO_FAMILY_HTTP (CURLPROTO_HTTP | CURLPROTO_HTTPS | CURLPROTO_WS | \ CURLPROTO_WSS) -#define PROTO_FAMILY_FTP (CURLPROTO_FTP|CURLPROTO_FTPS) -#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_FTP (CURLPROTO_FTP | CURLPROTO_FTPS) +#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) -#if !defined(CURL_DISABLE_FTP) || defined(USE_SSH) || \ +#if !defined(CURL_DISABLE_FTP) || defined(USE_SSH) || \ !defined(CURL_DISABLE_POP3) /* these protocols support CURLOPT_DIRLISTONLY */ #define CURL_LIST_ONLY_PROTOCOL 1 @@ -127,7 +127,7 @@ typedef unsigned int curl_prot_t; #define MAX_IPADR_LEN sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255") /* Default FTP/IMAP etc response timeout in milliseconds */ -#define RESP_TIMEOUT (60*1000) +#define RESP_TIMEOUT (60 * 1000) /* Max string input length is a precaution against abuse and to detect junk input easier and better. */ @@ -217,8 +217,8 @@ typedef CURLcode (Curl_recv)(struct Curl_easy *data, /* transfer */ larger buffers can help further, but this is deemed a fair memory/speed compromise. */ #define UPLOADBUFFER_DEFAULT 65536 -#define UPLOADBUFFER_MAX (2*1024*1024) -#define UPLOADBUFFER_MIN CURL_MAX_WRITE_SIZE +#define UPLOADBUFFER_MAX (2 * 1024 * 1024) +#define UPLOADBUFFER_MIN CURL_MAX_WRITE_SIZE #define CURLEASY_MAGIC_NUMBER 0xc0dedbadU #ifdef DEBUGBUILD @@ -226,7 +226,7 @@ typedef CURLcode (Curl_recv)(struct Curl_easy *data, /* transfer */ * are not NULL, but no longer have the MAGIC touch. This gives * us early warning on things only discovered by valgrind otherwise. */ #define GOOD_EASY_HANDLE(x) \ - (((x) && ((x)->magic == CURLEASY_MAGIC_NUMBER))? TRUE: \ + (((x) && ((x)->magic == CURLEASY_MAGIC_NUMBER)) ? TRUE : \ (DEBUGASSERT(!(x)), FALSE)) #else #define GOOD_EASY_HANDLE(x) \ @@ -269,7 +269,7 @@ struct ssl_config_data { long certverifyresult; /* result from the certificate verification */ 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 *cert_type; /* format for certificate (default: PEM) */ char *key; /* private key filename */ struct curl_blob *key_blob; char *key_type; /* format for private key (default: PEM) */ @@ -424,8 +424,8 @@ struct hostname { */ #define KEEP_NONE 0 -#define KEEP_RECV (1<<0) /* there is or may be data to read */ -#define KEEP_SEND (1<<1) /* there is or may be data to write */ +#define KEEP_RECV (1 << 0) /* there is or may be data to read */ +#define KEEP_SEND (1 << 1) /* there is or may be data to write */ /* transfer wants to send */ #define CURL_WANT_SEND(data) ((data)->req.keepon & KEEP_SEND) @@ -576,8 +576,8 @@ struct Curl_handler { #define CONNRESULT_DEAD (1<<0) /* The connection is dead. */ #define TRNSPRT_NONE 0 -#define TRNSPRT_TCP 3 -#define TRNSPRT_UDP 4 +#define TRNSPRT_TCP 3 +#define TRNSPRT_UDP 4 #define TRNSPRT_QUIC 5 #define TRNSPRT_UNIX 6 @@ -589,9 +589,10 @@ struct ip_quadruple { uint8_t transport; }; -#define CUR_IP_QUAD_HAS_PORTS(x) (((x)->transport == TRNSPRT_TCP) || \ - ((x)->transport == TRNSPRT_UDP) || \ - ((x)->transport == TRNSPRT_QUIC)) +#define CUR_IP_QUAD_HAS_PORTS(x) \ + (((x)->transport == TRNSPRT_TCP) || \ + ((x)->transport == TRNSPRT_UDP) || \ + ((x)->transport == TRNSPRT_QUIC)) struct proxy_info { struct hostname host; @@ -827,8 +828,8 @@ struct Progress { #define CURL_SPEED_RECORDS (5 + 1) /* 6 entries for 5 seconds */ - curl_off_t speed_amount[ CURL_SPEED_RECORDS ]; - struct curltime speed_time[ CURL_SPEED_RECORDS ]; + curl_off_t speed_amount[CURL_SPEED_RECORDS]; + struct curltime speed_time[CURL_SPEED_RECORDS]; unsigned char speeder_c; BIT(hide); BIT(ul_size_known); @@ -839,19 +840,19 @@ struct Progress { }; typedef enum { - RTSPREQ_NONE, /* first in list */ - RTSPREQ_OPTIONS, - RTSPREQ_DESCRIBE, - RTSPREQ_ANNOUNCE, - RTSPREQ_SETUP, - RTSPREQ_PLAY, - RTSPREQ_PAUSE, - RTSPREQ_TEARDOWN, - RTSPREQ_GET_PARAMETER, - RTSPREQ_SET_PARAMETER, - RTSPREQ_RECORD, - RTSPREQ_RECEIVE, - RTSPREQ_LAST /* last in list */ + RTSPREQ_NONE, /* first in list */ + RTSPREQ_OPTIONS, + RTSPREQ_DESCRIBE, + RTSPREQ_ANNOUNCE, + RTSPREQ_SETUP, + RTSPREQ_PLAY, + RTSPREQ_PAUSE, + RTSPREQ_TEARDOWN, + RTSPREQ_GET_PARAMETER, + RTSPREQ_SET_PARAMETER, + RTSPREQ_RECORD, + RTSPREQ_RECEIVE, + RTSPREQ_LAST /* last in list */ } Curl_RtspReq; struct auth { @@ -911,7 +912,6 @@ typedef enum { EXPIRE_LAST /* not an actual timer, used as a marker only */ } expire_id; - typedef enum { TRAILERS_NONE, TRAILERS_INITIALIZED, @@ -919,7 +919,6 @@ typedef enum { TRAILERS_DONE } trailers_state; - /* * One instance for each timeout an easy handle can set. */ @@ -1296,7 +1295,6 @@ enum dupblob { BLOB_LAST }; - struct UserDefined { FILE *err; /* the stderr user data goes here */ void *debugdata; /* the data that will be passed to fdebug */ diff --git a/lib/version.c b/lib/version.c index 487dc74ffa15..79654fa9755c 100644 --- a/lib/version.c +++ b/lib/version.c @@ -335,8 +335,8 @@ static const char * const supported_protocols[] = { #ifndef CURL_DISABLE_LDAP "ldap", #if !defined(CURL_DISABLE_LDAPS) && \ - ((defined(USE_OPENLDAP) && defined(USE_SSL)) || \ - (!defined(USE_OPENLDAP) && defined(HAVE_LDAP_SSL))) + ((defined(USE_OPENLDAP) && defined(USE_SSL)) || \ + (!defined(USE_OPENLDAP) && defined(HAVE_LDAP_SSL))) "ldaps", #endif #endif @@ -438,7 +438,7 @@ static int ech_present(curl_version_info_data *info) * Use FEATURE() macro to define an entry: this allows documentation check. */ -#define FEATURE(name, present, bitmask) {(name), (present), (bitmask)} +#define FEATURE(name, present, bitmask) { (name), (present), (bitmask) } struct feat { const char *name; diff --git a/lib/ws.c b/lib/ws.c index 93e13e1ac184..eab06f4f118c 100644 --- a/lib/ws.c +++ b/lib/ws.c @@ -54,11 +54,11 @@ |N|V|V|V| | | |1|2|3| | */ -#define WSBIT_FIN (0x80) -#define WSBIT_RSV1 (0x40) -#define WSBIT_RSV2 (0x20) -#define WSBIT_RSV3 (0x10) -#define WSBIT_RSV_MASK (WSBIT_RSV1 | WSBIT_RSV2 | WSBIT_RSV3) +#define WSBIT_FIN (0x80) +#define WSBIT_RSV1 (0x40) +#define WSBIT_RSV2 (0x20) +#define WSBIT_RSV3 (0x10) +#define WSBIT_RSV_MASK (WSBIT_RSV1 | WSBIT_RSV2 | WSBIT_RSV3) #define WSBIT_OPCODE_CONT (0x0) #define WSBIT_OPCODE_TEXT (0x1) #define WSBIT_OPCODE_BIN (0x2) @@ -70,10 +70,9 @@ #define WSBIT_MASK 0x80 /* buffer dimensioning */ -#define WS_CHUNK_SIZE 65535 +#define WS_CHUNK_SIZE 65535 #define WS_CHUNK_COUNT 2 - /* a client-side WS frame decoder, parsing frame headers and * payload, keeping track of current position and stats */ enum ws_dec_state { @@ -126,24 +125,23 @@ struct websocket { size_t sendbuf_payload; /* number of payload bytes in sendbuf */ }; - static const char *ws_frame_name_of_op(uint8_t firstbyte) { switch(firstbyte & WSBIT_OPCODE_MASK) { - case WSBIT_OPCODE_CONT: - return "CONT"; - case WSBIT_OPCODE_TEXT: - return "TEXT"; - case WSBIT_OPCODE_BIN: - return "BIN"; - case WSBIT_OPCODE_CLOSE: - return "CLOSE"; - case WSBIT_OPCODE_PING: - return "PING"; - case WSBIT_OPCODE_PONG: - return "PONG"; - default: - return "???"; + case WSBIT_OPCODE_CONT: + return "CONT"; + case WSBIT_OPCODE_TEXT: + return "TEXT"; + case WSBIT_OPCODE_BIN: + return "BIN"; + case WSBIT_OPCODE_CLOSE: + return "CLOSE"; + case WSBIT_OPCODE_PING: + return "PING"; + case WSBIT_OPCODE_PONG: + return "PONG"; + default: + return "???"; } } @@ -151,78 +149,78 @@ static int ws_frame_firstbyte2flags(struct Curl_easy *data, uint8_t firstbyte, int cont_flags) { switch(firstbyte) { - /* 0x00 - intermediate TEXT/BINARY fragment */ - case WSBIT_OPCODE_CONT: - 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): - 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"); + /* 0x00 - intermediate TEXT/BINARY fragment */ + case WSBIT_OPCODE_CONT: + if(!(cont_flags & CURLWS_CONT)) { + failf(data, "[WS] no ongoing fragmented message to resume"); 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 cont_flags | CURLWS_CONT; + /* 0x80 - final TEXT/BIN fragment */ + case (WSBIT_OPCODE_CONT | WSBIT_FIN): + if(!(cont_flags & CURLWS_CONT)) { + failf(data, "[WS] no ongoing fragmented message to resume"); 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 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; - /* 0x8a - unfragmented PONG */ - case (WSBIT_OPCODE_PONG | WSBIT_FIN): - return CURLWS_PONG; - /* invalid first byte */ - default: - 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 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) + /* 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; } } @@ -233,59 +231,59 @@ static CURLcode ws_frame_flags2firstbyte(struct Curl_easy *data, { *pfirstbyte = 0; switch(flags & ~CURLWS_OFFSET) { - case 0: - if(contfragment) { - CURL_TRC_WS(data, "no flags given; interpreting as continuation " - "fragment for compatibility"); - *pfirstbyte = (WSBIT_OPCODE_CONT | WSBIT_FIN); - return CURLE_OK; - } - failf(data, "[WS] no flags given"); - return CURLE_BAD_FUNCTION_ARGUMENT; - case CURLWS_CONT: - if(contfragment) { - infof(data, "[WS] setting CURLWS_CONT flag without message type is " - "supported for compatibility but highly discouraged"); - *pfirstbyte = WSBIT_OPCODE_CONT; - return CURLE_OK; - } - failf(data, "[WS] No ongoing fragmented message to continue"); - return CURLE_BAD_FUNCTION_ARGUMENT; - case CURLWS_TEXT: - *pfirstbyte = contfragment ? (WSBIT_OPCODE_CONT | WSBIT_FIN) - : (WSBIT_OPCODE_TEXT | WSBIT_FIN); - return CURLE_OK; - case (CURLWS_TEXT | CURLWS_CONT): - *pfirstbyte = contfragment ? WSBIT_OPCODE_CONT : WSBIT_OPCODE_TEXT; - return CURLE_OK; - case CURLWS_BINARY: - *pfirstbyte = contfragment ? (WSBIT_OPCODE_CONT | WSBIT_FIN) - : (WSBIT_OPCODE_BIN | WSBIT_FIN); - return CURLE_OK; - case (CURLWS_BINARY | CURLWS_CONT): - *pfirstbyte = contfragment ? WSBIT_OPCODE_CONT : WSBIT_OPCODE_BIN; - return CURLE_OK; - case CURLWS_CLOSE: - *pfirstbyte = WSBIT_OPCODE_CLOSE | WSBIT_FIN; - return CURLE_OK; - case (CURLWS_CLOSE | CURLWS_CONT): - failf(data, "[WS] CLOSE frame must not be fragmented"); - return CURLE_BAD_FUNCTION_ARGUMENT; - case CURLWS_PING: - *pfirstbyte = WSBIT_OPCODE_PING | WSBIT_FIN; + case 0: + if(contfragment) { + CURL_TRC_WS(data, "no flags given; interpreting as continuation " + "fragment for compatibility"); + *pfirstbyte = (WSBIT_OPCODE_CONT | WSBIT_FIN); return CURLE_OK; - case (CURLWS_PING | CURLWS_CONT): - failf(data, "[WS] PING frame must not be fragmented"); - return CURLE_BAD_FUNCTION_ARGUMENT; - case CURLWS_PONG: - *pfirstbyte = WSBIT_OPCODE_PONG | WSBIT_FIN; + } + failf(data, "[WS] no flags given"); + return CURLE_BAD_FUNCTION_ARGUMENT; + case CURLWS_CONT: + if(contfragment) { + infof(data, "[WS] setting CURLWS_CONT flag without message type is " + "supported for compatibility but highly discouraged"); + *pfirstbyte = WSBIT_OPCODE_CONT; return CURLE_OK; - case (CURLWS_PONG | CURLWS_CONT): - failf(data, "[WS] PONG frame must not be fragmented"); - return CURLE_BAD_FUNCTION_ARGUMENT; - default: - failf(data, "[WS] unknown flags: %x", flags); - return CURLE_BAD_FUNCTION_ARGUMENT; + } + failf(data, "[WS] No ongoing fragmented message to continue"); + return CURLE_BAD_FUNCTION_ARGUMENT; + case CURLWS_TEXT: + *pfirstbyte = contfragment ? (WSBIT_OPCODE_CONT | WSBIT_FIN) + : (WSBIT_OPCODE_TEXT | WSBIT_FIN); + return CURLE_OK; + case (CURLWS_TEXT | CURLWS_CONT): + *pfirstbyte = contfragment ? WSBIT_OPCODE_CONT : WSBIT_OPCODE_TEXT; + return CURLE_OK; + case CURLWS_BINARY: + *pfirstbyte = contfragment ? (WSBIT_OPCODE_CONT | WSBIT_FIN) + : (WSBIT_OPCODE_BIN | WSBIT_FIN); + return CURLE_OK; + case (CURLWS_BINARY | CURLWS_CONT): + *pfirstbyte = contfragment ? WSBIT_OPCODE_CONT : WSBIT_OPCODE_BIN; + return CURLE_OK; + case CURLWS_CLOSE: + *pfirstbyte = WSBIT_OPCODE_CLOSE | WSBIT_FIN; + return CURLE_OK; + case (CURLWS_CLOSE | CURLWS_CONT): + failf(data, "[WS] CLOSE frame must not be fragmented"); + return CURLE_BAD_FUNCTION_ARGUMENT; + case CURLWS_PING: + *pfirstbyte = WSBIT_OPCODE_PING | WSBIT_FIN; + return CURLE_OK; + case (CURLWS_PING | CURLWS_CONT): + failf(data, "[WS] PING frame must not be fragmented"); + return CURLE_BAD_FUNCTION_ARGUMENT; + case CURLWS_PONG: + *pfirstbyte = WSBIT_OPCODE_PONG | WSBIT_FIN; + return CURLE_OK; + case (CURLWS_PONG | CURLWS_CONT): + failf(data, "[WS] PONG frame must not be fragmented"); + return CURLE_BAD_FUNCTION_ARGUMENT; + default: + failf(data, "[WS] unknown flags: %x", flags); + return CURLE_BAD_FUNCTION_ARGUMENT; } } @@ -452,13 +450,14 @@ static CURLcode ws_dec_read_head(struct ws_decoder *dec, failf(data, "[WS] frame length longer than 63 bit not supported"); return CURLE_RECV_ERROR; } - dec->payload_len = ((curl_off_t)dec->head[2] << 56) | + dec->payload_len = + (curl_off_t)dec->head[2] << 56 | (curl_off_t)dec->head[3] << 48 | (curl_off_t)dec->head[4] << 40 | (curl_off_t)dec->head[5] << 32 | (curl_off_t)dec->head[6] << 24 | (curl_off_t)dec->head[7] << 16 | - (curl_off_t)dec->head[8] << 8 | + (curl_off_t)dec->head[8] << 8 | dec->head[9]; break; default: @@ -1230,7 +1229,6 @@ static const struct Curl_crtype ws_cr_encode = { sizeof(struct cr_ws_ctx) }; - struct wsfield { const char *name; const char *val; @@ -1245,7 +1243,7 @@ CURLcode Curl_ws_request(struct Curl_easy *data, struct dynbuf *req) size_t randlen; char keyval[40]; struct SingleRequest *k = &data->req; - struct wsfield heads[]= { + struct wsfield heads[] = { { /* The request MUST contain an |Upgrade| header field whose value MUST include the "websocket" keyword. */ @@ -1284,8 +1282,7 @@ CURLcode Curl_ws_request(struct Curl_easy *data, struct dynbuf *req) curlx_free(randstr); for(i = 0; !result && (i < CURL_ARRAYSIZE(heads)); i++) { if(!Curl_checkheaders(data, heads[i].name, strlen(heads[i].name))) { - result = curlx_dyn_addf(req, "%s: %s\r\n", heads[i].name, - heads[i].val); + result = curlx_dyn_addf(req, "%s: %s\r\n", heads[i].name, heads[i].val); } } data->state.http_hd_upgrade = TRUE; @@ -1329,7 +1326,7 @@ CURLcode Curl_ws_accept(struct Curl_easy *data, const char *p = getenv("CURL_WS_CHUNK_SIZE"); if(p) { curl_off_t l; - if(!curlx_str_number(&p, &l, 1*1024*1024)) + if(!curlx_str_number(&p, &l, 1 * 1024 * 1024)) chunk_size = (size_t)l; } } @@ -1633,7 +1630,7 @@ static CURLcode ws_flush(struct Curl_easy *data, struct websocket *ws, const char *p = getenv("CURL_WS_CHUNK_EAGAIN"); if(p) { curl_off_t l; - if(!curlx_str_number(&p, &l, 1*1024*1024)) + if(!curlx_str_number(&p, &l, 1 * 1024 * 1024)) chunk_egain = (size_t)l; } #endif @@ -1844,7 +1841,6 @@ static CURLcode ws_setup_conn(struct Curl_easy *data, return Curl_http_setup_conn(data, conn); } - const struct curl_ws_frame *curl_ws_meta(CURL *d) { /* we only return something for websocket, called from within the callback @@ -1856,7 +1852,6 @@ const struct curl_ws_frame *curl_ws_meta(CURL *d) ws = Curl_conn_meta_get(data->conn, CURL_META_PROTO_WS_CONN); if(ws) return &ws->recvframe; - } return NULL; } @@ -1963,11 +1958,10 @@ const struct Curl_handler Curl_handler_wss = { CURLPROTO_WSS, /* protocol */ CURLPROTO_HTTP, /* family */ PROTOPT_SSL | PROTOPT_CREDSPERREQUEST | /* flags */ - PROTOPT_USERPWDCTRL + PROTOPT_USERPWDCTRL }; #endif - #else CURLcode curl_ws_recv(CURL *curl, void *buffer, size_t buflen, diff --git a/lib/ws.h b/lib/ws.h index b7655abbce74..a6e770694dee 100644 --- a/lib/ws.h +++ b/lib/ws.h @@ -38,10 +38,9 @@ extern const struct Curl_handler Curl_handler_ws; extern const struct Curl_handler Curl_handler_wss; #endif - #else -#define Curl_ws_request(x,y) CURLE_OK -#define Curl_ws_free(x) Curl_nop_stmt +#define Curl_ws_request(x, y) CURLE_OK +#define Curl_ws_free(x) Curl_nop_stmt #endif #endif /* HEADER_CURL_WS_H */ From 6694a42aa0e820a6fe1e59d85ff8597b6d768d8d Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Mon, 1 Dec 2025 22:18:41 +0100 Subject: [PATCH 170/415] idn: avoid allocations and wcslen on Windows Eliminate a heap buffer in both `win32_idn_to_ascii()` and `win32_ascii_to_idn()`, by replacing it with stack buffer. The maximum size is fixed in these cases, and small enough to fit there. Also reuse length returned by the UTF-8 to wchar conversion, allowing to drop `wcslen()` call in both functions, and allowing to call the wchar to UTF-8 conversion API `WideCharToMultiByte()` with the known length, saving length calculations within that API too. Ref: https://github.com/curl/curl/pull/19748#issuecomment-3592015200 Closes #19798 --- lib/idn.c | 72 +++++++++++++++++++------------------------------------ 1 file changed, 24 insertions(+), 48 deletions(-) diff --git a/lib/idn.c b/lib/idn.c index 8f4c3e03f712..083be1d53f88 100644 --- a/lib/idn.c +++ b/lib/idn.c @@ -162,42 +162,18 @@ WINBASEAPI int WINAPI IdnToUnicode(DWORD dwFlags, #define IDN_MAX_LENGTH 255 -static wchar_t *idn_curlx_convert_UTF8_to_wchar(const char *str_utf8) -{ - wchar_t *str_w = NULL; - - if(str_utf8) { - int str_w_len = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, - str_utf8, -1, NULL, 0); - if(str_w_len > 0) { - str_w = curlx_malloc(str_w_len * sizeof(wchar_t)); - if(str_w) { - if(MultiByteToWideChar(CP_UTF8, 0, str_utf8, -1, str_w, - str_w_len) == 0) { - curlx_free(str_w); - return NULL; - } - } - } - } - return str_w; -} - -static char *idn_curlx_convert_wchar_to_UTF8(const wchar_t *str_w) +static char *idn_curlx_convert_wchar_to_UTF8(const wchar_t *str_w, int chars) { char *str_utf8 = NULL; - - if(str_w) { - int bytes = WideCharToMultiByte(CP_UTF8, 0, str_w, -1, - NULL, 0, NULL, NULL); - if(bytes > 0) { - str_utf8 = curlx_malloc(bytes); - if(str_utf8) { - if(WideCharToMultiByte(CP_UTF8, 0, str_w, -1, str_utf8, bytes, - NULL, NULL) == 0) { - curlx_free(str_utf8); - return NULL; - } + int bytes = WideCharToMultiByte(CP_UTF8, 0, str_w, chars, NULL, 0, + NULL, NULL); + if(bytes > 0) { + str_utf8 = curlx_malloc(bytes); + if(str_utf8) { + if(WideCharToMultiByte(CP_UTF8, 0, str_w, chars, str_utf8, bytes, + NULL, NULL) == 0) { + curlx_free(str_utf8); + return NULL; } } } @@ -206,15 +182,15 @@ static char *idn_curlx_convert_wchar_to_UTF8(const wchar_t *str_w) static CURLcode win32_idn_to_ascii(const char *in, char **out) { - wchar_t *in_w = idn_curlx_convert_UTF8_to_wchar(in); + wchar_t in_w[IDN_MAX_LENGTH]; + int in_w_len; *out = NULL; - if(in_w) { + in_w_len = MultiByteToWideChar(CP_UTF8, 0, in, -1, in_w, IDN_MAX_LENGTH); + if(in_w_len) { wchar_t punycode[IDN_MAX_LENGTH]; - int chars = IdnToAscii(0, in_w, (int)(wcslen(in_w) + 1), punycode, - IDN_MAX_LENGTH); - curlx_free(in_w); - if(chars) { - *out = idn_curlx_convert_wchar_to_UTF8(punycode); + int chars = IdnToAscii(0, in_w, in_w_len, punycode, IDN_MAX_LENGTH); + if(chars > 0) { + *out = idn_curlx_convert_wchar_to_UTF8(punycode, chars); if(!*out) return CURLE_OUT_OF_MEMORY; } @@ -229,15 +205,15 @@ static CURLcode win32_idn_to_ascii(const char *in, char **out) static CURLcode win32_ascii_to_idn(const char *in, char **out) { - wchar_t *in_w = idn_curlx_convert_UTF8_to_wchar(in); + wchar_t in_w[IDN_MAX_LENGTH]; + int in_w_len; *out = NULL; - if(in_w) { + in_w_len = MultiByteToWideChar(CP_UTF8, 0, in, -1, in_w, IDN_MAX_LENGTH); + if(in_w_len) { WCHAR idn[IDN_MAX_LENGTH]; /* stores a UTF-16 string */ - int chars = IdnToUnicode(0, in_w, (int)(wcslen(in_w) + 1), idn, - IDN_MAX_LENGTH); - curlx_free(in_w); - if(chars) { /* 'chars' is "the number of characters retrieved" */ - *out = idn_curlx_convert_wchar_to_UTF8(idn); + int chars = IdnToUnicode(0, in_w, in_w_len, idn, IDN_MAX_LENGTH); + if(chars > 0) { /* 'chars' is "the number of characters retrieved" */ + *out = idn_curlx_convert_wchar_to_UTF8(idn, chars); if(!*out) return CURLE_OUT_OF_MEMORY; } From 1753de9d7a7a4e8d98869f1e01023db2861adf4f Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Wed, 3 Dec 2025 16:32:07 +0100 Subject: [PATCH 171/415] GHA/checksrc: give more time for slow Azure servers [ci skip] Sometimes 1 minutes is too short to install 39.4 kB of archives. Ref: https://github.com/curl/curl/actions/runs/19898949860/job/57036965452 --- .github/workflows/checksrc.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/checksrc.yml b/.github/workflows/checksrc.yml index d3ef758b4872..1b471e50cfe7 100644 --- a/.github/workflows/checksrc.yml +++ b/.github/workflows/checksrc.yml @@ -122,7 +122,7 @@ jobs: xmllint: name: 'xmllint' runs-on: ubuntu-latest - timeout-minutes: 1 + timeout-minutes: 3 steps: - name: 'install prereqs' run: | From 0417d323c96db547e5ed9da733c51aed02be723e Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Wed, 3 Dec 2025 15:53:46 +0100 Subject: [PATCH 172/415] src: fix formatting nits Closes #19823 --- src/config2setopts.c | 21 ++--- src/curlinfo.c | 2 +- src/slist_wc.c | 3 +- src/terminal.c | 3 +- src/tool_cb_dbg.c | 4 +- src/tool_cb_hdr.c | 17 ++-- src/tool_cb_prg.c | 27 +++--- src/tool_cb_prg.h | 10 +-- src/tool_cb_rea.c | 2 +- src/tool_cb_wrt.c | 6 +- src/tool_cfgable.h | 9 +- src/tool_dirhie.c | 4 +- src/tool_doswin.c | 50 ++++++----- src/tool_doswin.h | 6 +- src/tool_easysrc.c | 4 +- src/tool_filetime.c | 4 +- src/tool_filetime.h | 2 +- src/tool_findfile.c | 2 +- src/tool_formparse.c | 43 ++++----- src/tool_getparam.c | 178 ++++++++++++++++++------------------- src/tool_getparam.h | 10 +-- src/tool_getpass.c | 9 +- src/tool_help.c | 57 ++++++------ src/tool_helpers.c | 4 +- src/tool_ipfs.c | 4 +- src/tool_libinfo.c | 2 +- src/tool_main.c | 2 +- src/tool_main.h | 4 +- src/tool_msgs.c | 12 +-- src/tool_msgs.h | 12 +-- src/tool_operate.c | 59 +++++-------- src/tool_operhlp.c | 2 +- src/tool_paramhlp.c | 27 +++--- src/tool_paramhlp.h | 2 +- src/tool_parsecfg.c | 2 +- src/tool_progress.c | 28 +++--- src/tool_sdecls.h | 2 - src/tool_setopt.c | 19 ++-- src/tool_setopt.h | 104 +++++++++------------- src/tool_setup.h | 4 +- src/tool_ssls.c | 4 +- src/tool_urlglob.c | 12 +-- src/tool_util.c | 2 +- src/tool_version.h | 8 +- src/tool_vms.c | 7 +- src/tool_vms.h | 5 +- src/tool_writeout.c | 186 ++++++++++++++++++++------------------- src/tool_writeout_json.c | 3 +- src/tool_xattr.h | 4 +- src/var.c | 37 ++++---- src/var.h | 3 +- tests/test1486.pl | 2 +- 52 files changed, 491 insertions(+), 544 deletions(-) diff --git a/src/config2setopts.c b/src/config2setopts.c index d3bd39c8647c..89a003cc96ac 100644 --- a/src/config2setopts.c +++ b/src/config2setopts.c @@ -142,8 +142,7 @@ static CURLcode url_proto_and_rewrite(char **url, curl_url_set(uh, CURLUPART_URL, *url, CURLU_GUESS_SCHEME | CURLU_NON_SUPPORT_SCHEME); if(!uc) { - uc = curl_url_get(uh, CURLUPART_SCHEME, &schemep, - CURLU_DEFAULT_SCHEME); + uc = curl_url_get(uh, CURLUPART_SCHEME, &schemep, CURLU_DEFAULT_SCHEME); if(!uc) { #ifdef CURL_DISABLE_IPFS (void)config; @@ -339,8 +338,7 @@ static CURLcode ssl_setopts(struct OperationConfig *config, CURL *curl) MY_SETOPT_STR(curl, CURLOPT_PROXY_CRLFILE, config->crlfile); if(config->pinnedpubkey) { - MY_SETOPT_STR(curl, CURLOPT_PINNEDPUBLICKEY, - config->pinnedpubkey); + MY_SETOPT_STR(curl, CURLOPT_PINNEDPUBLICKEY, config->pinnedpubkey); if(result) warnf("ignoring %s, not supported by libcurl with %s", "--pinnedpubkey", ssl_backend()); @@ -417,8 +415,7 @@ static CURLcode ssl_setopts(struct OperationConfig *config, CURL *curl) { long mask = (config->proxy_ssl_allow_beast ? CURLSSLOPT_ALLOW_BEAST : 0) | - (config->proxy_ssl_auto_client_cert ? - CURLSSLOPT_AUTO_CLIENT_CERT : 0) | + (config->proxy_ssl_auto_client_cert ? CURLSSLOPT_AUTO_CLIENT_CERT : 0) | (config->proxy_native_ca_store ? CURLSSLOPT_NATIVE_CA : 0); if(mask) @@ -486,15 +483,13 @@ static CURLcode ssl_setopts(struct OperationConfig *config, CURL *curl) } /* only called for HTTP transfers */ -static CURLcode http_setopts(struct OperationConfig *config, - CURL *curl) +static CURLcode http_setopts(struct OperationConfig *config, CURL *curl) { CURLcode result; long postRedir = 0; my_setopt_long(curl, CURLOPT_FOLLOWLOCATION, config->followlocation); - my_setopt_long(curl, CURLOPT_UNRESTRICTED_AUTH, - config->unrestricted_auth); + my_setopt_long(curl, CURLOPT_UNRESTRICTED_AUTH, config->unrestricted_auth); MY_SETOPT_STR(curl, CURLOPT_AWS_SIGV4, config->aws_sigv4); my_setopt_long(curl, CURLOPT_AUTOREFERER, config->autoreferer); @@ -590,8 +585,7 @@ static void tcp_setopts(struct OperationConfig *config, CURL *curl) my_setopt_long(curl, CURLOPT_TCP_FASTOPEN, 1); if(config->mptcp) - my_setopt_ptr(curl, CURLOPT_OPENSOCKETFUNCTION, - tool_socket_open_mptcp_cb); + my_setopt_ptr(curl, CURLOPT_OPENSOCKETFUNCTION, tool_socket_open_mptcp_cb); /* curl 7.17.1 */ if(!config->nokeepalive) { @@ -946,8 +940,7 @@ CURLcode config2setopts(struct OperationConfig *config, my_setopt_long(curl, CURLOPT_FTP_CREATE_MISSING_DIRS, (config->ftp_create_dirs ? CURLFTP_CREATE_DIR_RETRY : CURLFTP_CREATE_DIR_NONE)); - my_setopt_offt(curl, CURLOPT_MAXFILESIZE_LARGE, - config->max_filesize); + my_setopt_offt(curl, CURLOPT_MAXFILESIZE_LARGE, config->max_filesize); my_setopt_long(curl, CURLOPT_IPRESOLVE, config->ip_version); if(config->socks5_gssapi_nec) my_setopt_long(curl, CURLOPT_SOCKS5_GSSAPI_NEC, 1); diff --git a/src/curlinfo.c b/src/curlinfo.c index 852aee820161..35b8ff56a6e4 100644 --- a/src/curlinfo.c +++ b/src/curlinfo.c @@ -39,7 +39,7 @@ #include "fake_addrinfo.h" /* for USE_FAKE_GETADDRINFO */ #include -static const char *disabled[]={ +static const char *disabled[] = { "bindlocal: " #ifdef CURL_DISABLE_BINDLOCAL "OFF" diff --git a/src/slist_wc.c b/src/slist_wc.c index 26a91362b8e3..8a3ff254ccbc 100644 --- a/src/slist_wc.c +++ b/src/slist_wc.c @@ -32,8 +32,7 @@ * slist_wc_append() appends a string to the linked list. This function can be * used as an initialization function as well as an append function. */ -struct slist_wc *slist_wc_append(struct slist_wc *list, - const char *data) +struct slist_wc *slist_wc_append(struct slist_wc *list, const char *data) { struct curl_slist *new_item = curl_slist_append(NULL, data); diff --git a/src/terminal.c b/src/terminal.c index bb3e2ac61184..fe945cfa9c7b 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -74,8 +74,7 @@ unsigned int get_terminal_columns(void) * Do not use +1 to get the true screen-width since writing a * character at the right edge will cause a line wrap. */ - cols = (int) - (console_info.srWindow.Right - console_info.srWindow.Left); + cols = (int)(console_info.srWindow.Right - console_info.srWindow.Left); } } #endif /* TIOCGSIZE */ diff --git a/src/tool_cb_dbg.c b/src/tool_cb_dbg.c index b858b6688e6e..2301bd67f57c 100644 --- a/src/tool_cb_dbg.c +++ b/src/tool_cb_dbg.c @@ -103,7 +103,7 @@ int tool_debug_cb(CURL *handle, curl_infotype type, if(handle && global->traceids && !curl_easy_getinfo(handle, CURLINFO_XFER_ID, &xfer_id) && xfer_id >= 0) { if(!curl_easy_getinfo(handle, CURLINFO_CONN_ID, &conn_id) && - conn_id >= 0) { + conn_id >= 0) { curl_msnprintf(idsbuf, sizeof(idsbuf), TRC_IDS_FORMAT_IDS_2, xfer_id, conn_id); } @@ -224,7 +224,7 @@ int tool_debug_cb(CURL *handle, curl_infotype type, break; } - dump(timebuf, idsbuf, text, output, (unsigned char *) data, size, + dump(timebuf, idsbuf, text, output, (unsigned char *)data, size, global->tracetype, type); return 0; } diff --git a/src/tool_cb_hdr.c b/src/tool_cb_hdr.c index 7a5a475981d5..8027ea542171 100644 --- a/src/tool_cb_hdr.c +++ b/src/tool_cb_hdr.c @@ -39,17 +39,17 @@ static char *parse_filename(const char *ptr, size_t len); #ifdef _WIN32 -#define BOLD "\x1b[1m" +#define BOLD "\x1b[1m" #define BOLDOFF "\x1b[22m" #else -#define BOLD "\x1b[1m" +#define BOLD "\x1b[1m" /* Switch off bold by setting "all attributes off" since the explicit bold-off code (21) is not supported everywhere - like in the mac Terminal. */ #define BOLDOFF "\x1b[0m" /* OSC 8 hyperlink escape sequence */ -#define LINK "\x1b]8;;" -#define LINKST "\x1b\\" +#define LINK "\x1b]8;;" +#define LINKST "\x1b\\" #define LINKOFF LINK LINKST #endif @@ -76,7 +76,6 @@ int tool_write_headers(struct HdrCbData *hdrcbdata, FILE *stream) return rc; } - /* ** callback for CURLOPT_HEADERFUNCTION * @@ -131,7 +130,7 @@ size_t tool_header_cb(char *ptr, size_t size, size_t nmemb, void *userdata) long response = 0; curl_easy_getinfo(per->curl, CURLINFO_RESPONSE_CODE, &response); - if((response/100 != 2) && (response/100 != 3)) + if((response / 100 != 2) && (response / 100 != 3)) /* only care about etag and content-disposition headers in 2xx and 3xx responses */ ; @@ -299,7 +298,7 @@ size_t tool_header_cb(char *ptr, size_t size, size_t nmemb, void *userdata) #else if(curl_strnequal("Location", ptr, namelen)) { write_linked_location(per->curl, &value[1], cb - namelen - 1, - outs->stream); + outs->stream); } else fwrite(&value[1], cb - namelen - 1, 1, outs->stream); @@ -320,7 +319,7 @@ static char *parse_filename(const char *ptr, size_t len) char *copy; char *p; char *q; - char stop = '\0'; + char stop = '\0'; copy = memdup0(ptr, len); if(!copy) @@ -426,7 +425,7 @@ static void write_linked_location(CURL *curl, const char *location, } /* Strip the trailing end-of-line characters, normally "\r\n" */ - while(llen && (loc[llen-1] == '\n' || loc[llen-1] == '\r')) + while(llen && (loc[llen - 1] == '\n' || loc[llen - 1] == '\r')) --llen; /* CURLU makes it easy to handle the relative URL case */ diff --git a/src/tool_cb_prg.c b/src/tool_cb_prg.c index 6ae53b3ba227..ca437de50107 100644 --- a/src/tool_cb_prg.c +++ b/src/tool_cb_prg.c @@ -54,14 +54,15 @@ static const int sinus[] = { 500046, 484341, 468651, 452993, 437381, 421830, 406357, 390976, 375703, 360552, 345539, 330679, 315985, 301474, 287158, 273052, 259170, 245525, 232132, 219003, 206152, 193590, 181331, 169386, 157768, 146487, 135555, - 124983, 114781, 104959, 95526, 86493, 77868, 69660, 61876, 54525, 47613, - 41147, 35135, 29581, 24491, 19871, 15724, 12056, 8868, 6166, 3951, 2225, - 990, 248, 0, 244, 982, 2212, 3933, 6144, 8842, 12025, 15690, 19832, 24448, - 29534, 35084, 41092, 47554, 54462, 61809, 69589, 77794, 86415, 95445, - 104873, 114692, 124891, 135460, 146389, 157667, 169282, 181224, 193480, - 206039, 218888, 232015, 245406, 259048, 272928, 287032, 301346, 315856, - 330548, 345407, 360419, 375568, 390841, 406221, 421693, 437243, 452854, - 468513, 484202, 499907 + 124983, 114781, 104959, 95526, 86493, 77868, 69660, 61876, 54525, + 47613, 41147, 35135, 29581, 24491, 19871, 15724, 12056, 8868, + 6166, 3951, 2225, 990, 248, 0, 244, 982, 2212, + 3933, 6144, 8842, 12025, 15690, 19832, 24448, 29534, 35084, + 41092, 47554, 54462, 61809, 69589, 77794, 86415, 95445, 104873, + 114692, 124891, 135460, 146389, 157667, 169282, 181224, 193480, 206039, + 218888, 232015, 245406, 259048, 272928, 287032, 301346, 315856, 330548, + 345407, 360419, 375568, 390841, 406221, 421693, 437243, 452854, 468513, + 484202, 499907 }; static void fly(struct ProgressData *bar, bool moved) @@ -78,13 +79,13 @@ static void fly(struct ProgressData *bar, bool moved) memcpy(&buf[bar->bar + 1], "-=O=-", 5); - pos = sinus[bar->tick%200] / (1000000 / check) + 1; + pos = sinus[bar->tick % 200] / (1000000 / check) + 1; buf[pos] = '#'; - pos = sinus[(bar->tick + 5)%200] / (1000000 / check) + 1; + pos = sinus[(bar->tick + 5) % 200] / (1000000 / check) + 1; buf[pos] = '#'; - pos = sinus[(bar->tick + 10)%200] / (1000000 / check) + 1; + pos = sinus[(bar->tick + 10) % 200] / (1000000 / check) + 1; buf[pos] = '#'; - pos = sinus[(bar->tick + 15)%200] / (1000000 / check) + 1; + pos = sinus[(bar->tick + 15) % 200] / (1000000 / check) + 1; buf[pos] = '#'; fputs(buf, bar->out); @@ -201,7 +202,7 @@ int tool_progress_cb(void *clientp, frac = (double)point / (double)total; percent = frac * 100.0; barwidth = bar->width - 7; - num = (size_t) (((double)barwidth) * frac); + num = (size_t)(((double)barwidth) * frac); if(num > MAX_BARLENGTH) num = MAX_BARLENGTH; memset(line, '#', num); diff --git a/src/tool_cb_prg.h b/src/tool_cb_prg.h index 1f005dbfc4e9..a8b8930616f3 100644 --- a/src/tool_cb_prg.h +++ b/src/tool_cb_prg.h @@ -29,12 +29,12 @@ #define CURL_PROGRESS_BAR 1 struct ProgressData { - int calls; - curl_off_t prev; + int calls; + curl_off_t prev; struct curltime prevtime; - int width; - FILE *out; /* where to write everything to */ - curl_off_t initial_size; + int width; + FILE *out; /* where to write everything to */ + curl_off_t initial_size; unsigned int tick; int bar; int barmove; diff --git a/src/tool_cb_rea.c b/src/tool_cb_rea.c index 0f2bf8177198..1de2277cd084 100644 --- a/src/tool_cb_rea.c +++ b/src/tool_cb_rea.c @@ -137,7 +137,7 @@ size_t tool_read_cb(char *buffer, size_t sz, size_t nmemb, void *userdata) #endif } else { - rc = read(per->infd, buffer, sz*nmemb); + rc = read(per->infd, buffer, sz * nmemb); if(rc < 0) { if(errno == EAGAIN) { errno = 0; diff --git a/src/tool_cb_wrt.c b/src/tool_cb_wrt.c index 5696df2a5935..1b76565399cd 100644 --- a/src/tool_cb_wrt.c +++ b/src/tool_cb_wrt.c @@ -66,7 +66,7 @@ bool tool_create_output_file(struct OutStruct *outs, while(fd == -1 && /* have not successfully opened a file */ (errno == EEXIST || errno == EISDIR) && /* because we keep having files that already exist */ - next_num < 100 /* and we have not reached the retry limit */ ) { + next_num < 100 /* and we have not reached the retry limit */) { curlx_dyn_reset(&fbuffer); if(curlx_dyn_addf(&fbuffer, "%s.%d", fname, next_num)) return FALSE; @@ -158,12 +158,12 @@ static size_t win_console(intptr_t fhnd, struct OutStruct *outs, } if(complete) { - WCHAR prefix[3] = {0}; /* UTF-16 (1-2 WCHARs) + NUL */ + WCHAR prefix[3] = { 0 }; /* UTF-16 (1-2 WCHARs) + NUL */ if(MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)outs->utf8seq, -1, prefix, CURL_ARRAYSIZE(prefix))) { DEBUGASSERT(prefix[2] == L'\0'); - if(!WriteConsoleW((HANDLE) fhnd, prefix, prefix[1] ? 2 : 1, + if(!WriteConsoleW((HANDLE)fhnd, prefix, prefix[1] ? 2 : 1, &chars_written, NULL)) { return CURL_WRITEFUNC_ERROR; } diff --git a/src/tool_cfgable.h b/src/tool_cfgable.h index 0eac0185f280..5652229d4b79 100644 --- a/src/tool_cfgable.h +++ b/src/tool_cfgable.h @@ -39,10 +39,13 @@ #endif #endif -#define checkprefix(a,b) curl_strnequal(b, STRCONST(a)) +#define checkprefix(a, b) curl_strnequal(b, STRCONST(a)) -#define tool_safefree(ptr) \ - do { curlx_free((ptr)); (ptr) = NULL;} while(0) +#define tool_safefree(ptr) \ + do { \ + curlx_free(ptr); \ + (ptr) = NULL; \ + } while(0) extern struct GlobalConfig *global; diff --git a/src/tool_dirhie.c b/src/tool_dirhie.c index 31962bd1c546..058403d66688 100644 --- a/src/tool_dirhie.c +++ b/src/tool_dirhie.c @@ -31,7 +31,7 @@ #include "tool_msgs.h" #if defined(_WIN32) || (defined(MSDOS) && !defined(__DJGPP__)) -# define mkdir(x,y) (mkdir)((x)) +# define mkdir(x, y) (mkdir)((x)) # ifndef F_OK # define F_OK 0 # endif @@ -112,7 +112,7 @@ CURLcode create_dir_hierarchy(const char *outfile) exist, since we would be creating it erroneously. eg if outfile is X:\foo\bar\filename then do not mkdir X: This logic takes into account unsupported drives !:, 1:, etc. */ - if(len > 1 && (outfile[1]==':')) + if(len > 1 && (outfile[1] == ':')) skip = TRUE; } #endif diff --git a/src/tool_doswin.c b/src/tool_doswin.c index ee236178c276..040792f465a7 100644 --- a/src/tool_doswin.c +++ b/src/tool_doswin.c @@ -63,14 +63,13 @@ /* only used by msdosify() */ static SANITIZEcode truncate_dryrun(const char *path, const size_t truncate_pos); -static SANITIZEcode msdosify(char **const sanitized, const char *file_name, +static SANITIZEcode msdosify(char ** const sanitized, const char *file_name, int flags); #endif -static SANITIZEcode rename_if_reserved_dos(char **const sanitized, +static SANITIZEcode rename_if_reserved_dos(char ** const sanitized, const char *file_name, int flags); - /* Sanitize a file or path name. @@ -96,7 +95,7 @@ is in a UNC prefixed path. Success: (SANITIZE_ERR_OK) *sanitized points to a sanitized copy of file_name. Failure: (!= SANITIZE_ERR_OK) *sanitized is NULL. */ -SANITIZEcode sanitize_file_name(char **const sanitized, const char *file_name, +SANITIZEcode sanitize_file_name(char ** const sanitized, const char *file_name, int flags) { char *p, *target; @@ -116,16 +115,16 @@ SANITIZEcode sanitize_file_name(char **const sanitized, const char *file_name, #ifndef MSDOS if(file_name[0] == '\\' && file_name[1] == '\\') /* UNC prefixed path \\ (eg \\?\C:\foo) */ - max_sanitized_len = 32767-1; + max_sanitized_len = 32767 - 1; else #endif - max_sanitized_len = PATH_MAX-1; + max_sanitized_len = PATH_MAX - 1; } else /* The maximum length of a filename. FILENAME_MAX is often the same as PATH_MAX, in other words it is 260 and does not discount the path information therefore we should not use it. */ - max_sanitized_len = (PATH_MAX-1 > 255) ? 255 : PATH_MAX-1; + max_sanitized_len = (PATH_MAX - 1 > 255) ? 255 : PATH_MAX - 1; len = strlen(file_name); if(len > max_sanitized_len) @@ -287,17 +286,18 @@ sanitize_file_name. Success: (SANITIZE_ERR_OK) *sanitized points to a sanitized copy of file_name. Failure: (!= SANITIZE_ERR_OK) *sanitized is NULL. */ -static SANITIZEcode msdosify(char **const sanitized, const char *file_name, +static SANITIZEcode msdosify(char ** const sanitized, const char *file_name, int flags) { char dos_name[PATH_MAX]; - static const char illegal_chars_dos[] = ".+, ;=[]" /* illegal in DOS */ + static const char illegal_chars_dos[] = + ".+, ;=[]" /* illegal in DOS */ "|<>/\\\":?*"; /* illegal in DOS & W95 */ static const char *illegal_chars_w95 = &illegal_chars_dos[8]; int idx, dot_idx; const char *s = file_name; char *d = dos_name; - const char *const dlimit = dos_name + sizeof(dos_name) - 1; + const char * const dlimit = dos_name + sizeof(dos_name) - 1; const char *illegal_aliens = illegal_chars_dos; size_t len = sizeof(illegal_chars_dos) - 1; @@ -309,7 +309,7 @@ static SANITIZEcode msdosify(char **const sanitized, const char *file_name, if(!file_name) return SANITIZE_ERR_BAD_ARGUMENT; - if(strlen(file_name) > PATH_MAX-1) + if(strlen(file_name) > PATH_MAX - 1) return SANITIZE_ERR_INVALID_PATH; /* Support for Windows 9X VFAT systems, when available. */ @@ -322,7 +322,8 @@ static SANITIZEcode msdosify(char **const sanitized, const char *file_name, if(s[0] >= 'A' && s[0] <= 'z' && s[1] == ':') { *d++ = *s++; *d = ((flags & SANITIZE_ALLOW_PATH)) ? ':' : '_'; - ++d; ++s; + ++d; + ++s; } for(idx = 0, dot_idx = -1; *s && d < dlimit; s++, d++) { @@ -373,7 +374,7 @@ static SANITIZEcode msdosify(char **const sanitized, const char *file_name, *d++ = 'x'; if(d == dlimit) break; - *d = 'x'; + *d = 'x'; } else { /* libg++ etc. */ @@ -381,7 +382,7 @@ static SANITIZEcode msdosify(char **const sanitized, const char *file_name, *d++ = 'x'; if(d == dlimit) break; - *d = 'x'; + *d = 'x'; } else { memcpy(d, "plus", 4); @@ -431,7 +432,7 @@ sanitize_file_name. Success: (SANITIZE_ERR_OK) *sanitized points to a sanitized copy of file_name. Failure: (!= SANITIZE_ERR_OK) *sanitized is NULL. */ -static SANITIZEcode rename_if_reserved_dos(char **const sanitized, +static SANITIZEcode rename_if_reserved_dos(char ** const sanitized, const char *file_name, int flags) { @@ -462,7 +463,7 @@ static SANITIZEcode rename_if_reserved_dos(char **const sanitized, } #endif - if(len > PATH_MAX-1) + if(len > PATH_MAX - 1) return SANITIZE_ERR_INVALID_PATH; memcpy(fname, file_name, len); @@ -511,7 +512,7 @@ static SANITIZEcode rename_if_reserved_dos(char **const sanitized, p_len = strlen(p); /* Prepend a '_' */ - if(strlen(fname) == PATH_MAX-1) + if(strlen(fname) == PATH_MAX - 1) return SANITIZE_ERR_INVALID_PATH; memmove(p + 1, p, p_len + 1); p[0] = '_'; @@ -534,7 +535,7 @@ static SANITIZEcode rename_if_reserved_dos(char **const sanitized, /* Prepend a '_' */ size_t blen = strlen(base); if(blen) { - if(strlen(fname) >= PATH_MAX-1) + if(strlen(fname) >= PATH_MAX - 1) return SANITIZE_ERR_INVALID_PATH; memmove(base + 1, base, blen + 1); base[0] = '_'; @@ -613,7 +614,7 @@ struct curl_slist *GetLoadedModulePaths(void) struct curl_slist *slist = NULL; #ifndef CURL_WINDOWS_UWP HANDLE hnd = INVALID_HANDLE_VALUE; - MODULEENTRY32 mod = {0}; + MODULEENTRY32 mod = { 0 }; mod.dwSize = sizeof(MODULEENTRY32); @@ -763,7 +764,8 @@ static DWORD WINAPI win_stdin_thread_func(void *thread_data) SOCKADDR_IN clientAddr; int clientAddrLen = sizeof(clientAddr); - curl_socket_t socket_w = CURL_ACCEPT(tdata->socket_l, (SOCKADDR*)&clientAddr, + curl_socket_t socket_w = CURL_ACCEPT(tdata->socket_l, + (SOCKADDR *)&clientAddr, &clientAddrLen); if(socket_w == CURL_SOCKET_BAD) { @@ -822,7 +824,7 @@ curl_socket_t win32_stdin_read_thread(void) do { /* Prepare handles for thread */ - tdata = (struct win_thread_data*) + tdata = (struct win_thread_data *) curlx_calloc(1, sizeof(struct win_thread_data)); if(!tdata) { errorf("curlx_calloc() error"); @@ -841,14 +843,14 @@ curl_socket_t win32_stdin_read_thread(void) selfaddr.sin_family = AF_INET; selfaddr.sin_addr.S_un.S_addr = htonl(INADDR_LOOPBACK); /* Bind to any available loopback port */ - result = bind(tdata->socket_l, (SOCKADDR*)&selfaddr, socksize); + result = bind(tdata->socket_l, (SOCKADDR *)&selfaddr, socksize); if(result == SOCKET_ERROR) { errorf("bind error: %d", SOCKERRNO); break; } /* Bind to any available loopback port */ - result = getsockname(tdata->socket_l, (SOCKADDR*)&selfaddr, &socksize); + result = getsockname(tdata->socket_l, (SOCKADDR *)&selfaddr, &socksize); if(result == SOCKET_ERROR) { errorf("getsockname error: %d", SOCKERRNO); break; @@ -892,7 +894,7 @@ curl_socket_t win32_stdin_read_thread(void) /* Hard close the socket on closesocket() */ setsockopt(socket_r, SOL_SOCKET, SO_DONTLINGER, 0, 0); - if(connect(socket_r, (SOCKADDR*)&selfaddr, socksize) == SOCKET_ERROR) { + if(connect(socket_r, (SOCKADDR *)&selfaddr, socksize) == SOCKET_ERROR) { errorf("connect error: %d", SOCKERRNO); break; } diff --git a/src/tool_doswin.h b/src/tool_doswin.h index 01500bdbf732..75f4bacdb8c2 100644 --- a/src/tool_doswin.h +++ b/src/tool_doswin.h @@ -27,8 +27,8 @@ #if defined(_WIN32) || defined(MSDOS) -#define SANITIZE_ALLOW_PATH (1<<1) /* Allow path separators and colons */ -#define SANITIZE_ALLOW_RESERVED (1<<2) /* Allow reserved device names */ +#define SANITIZE_ALLOW_PATH (1 << 1) /* Allow path separators and colons */ +#define SANITIZE_ALLOW_RESERVED (1 << 2) /* Allow reserved device names */ typedef enum { SANITIZE_ERR_OK = 0, /* 0 - OK */ @@ -38,7 +38,7 @@ typedef enum { SANITIZE_ERR_LAST /* never use! */ } SANITIZEcode; -SANITIZEcode sanitize_file_name(char **const sanitized, const char *file_name, +SANITIZEcode sanitize_file_name(char ** const sanitized, const char *file_name, int flags); #ifdef __DJGPP__ diff --git a/src/tool_easysrc.c b/src/tool_easysrc.c index 4747f6dfe6bb..ba9d345645c0 100644 --- a/src/tool_easysrc.c +++ b/src/tool_easysrc.c @@ -41,7 +41,7 @@ struct slist_wc *easysrc_clean; /* Clean up allocated data */ int easysrc_mime_count; int easysrc_slist_count; -static const char *const srchead[]={ +static const char * const srchead[] = { "/********* Sample code generated by the curl command line tool **********", " * All curl_easy_setopt() options are documented at:", " * https://curl.se/libcurl/c/curl_easy_setopt.html", @@ -57,7 +57,7 @@ static const char *const srchead[]={ /* easysrc_decl declarations come here */ /* easysrc_data initialization come here */ /* easysrc_code statements come here */ -static const char *const srchard[]={ +static const char * const srchard[] = { "/* Here is a list of options the curl code used that cannot get generated", " as source easily. You may choose to either not use them or implement", " them yourself.", diff --git a/src/tool_filetime.c b/src/tool_filetime.c index 041cc4dbd6cb..2d362b4bb7cb 100644 --- a/src/tool_filetime.c +++ b/src/tool_filetime.c @@ -51,8 +51,8 @@ int getfiletime(const char *filename, curl_off_t *stamp) if(hfile != INVALID_HANDLE_VALUE) { FILETIME ft; if(GetFileTime(hfile, NULL, NULL, &ft)) { - curl_off_t converted = (curl_off_t)ft.dwLowDateTime - | ((curl_off_t)ft.dwHighDateTime) << 32; + curl_off_t converted = (curl_off_t)ft.dwLowDateTime | + ((curl_off_t)ft.dwHighDateTime) << 32; if(converted < 116444736000000000) warnf("Failed to get filetime: underflow"); diff --git a/src/tool_filetime.h b/src/tool_filetime.h index c3663617b533..fedb7a195792 100644 --- a/src/tool_filetime.h +++ b/src/tool_filetime.h @@ -31,7 +31,7 @@ int getfiletime(const char *filename, curl_off_t *stamp); (defined(_WIN32) && (SIZEOF_CURL_OFF_T >= 8)) void setfiletime(curl_off_t filetime, const char *filename); #else -#define setfiletime(a,b,c) tool_nop_stmt +#define setfiletime(a, b, c) tool_nop_stmt #endif #endif /* HEADER_CURL_TOOL_FILETIME_H */ diff --git a/src/tool_findfile.c b/src/tool_findfile.c index 4dbd7bccb470..c962eb86b8cb 100644 --- a/src/tool_findfile.c +++ b/src/tool_findfile.c @@ -51,7 +51,7 @@ static const struct finder conf_list[] = { #ifdef _WIN32 { "USERPROFILE", NULL, FALSE }, { "APPDATA", NULL, FALSE }, - { "USERPROFILE", "\\Application Data", FALSE}, + { "USERPROFILE", "\\Application Data", FALSE }, #endif /* these are for .curlrc if XDG_CONFIG_HOME is not defined */ { "CURL_HOME", "/.config", TRUE }, diff --git a/src/tool_formparse.c b/src/tool_formparse.c index 181abf7b8627..543f817cc3e4 100644 --- a/src/tool_formparse.c +++ b/src/tool_formparse.c @@ -86,8 +86,8 @@ static curl_off_t uztoso(size_t uznum) # pragma warning(disable:4310) /* cast truncates constant value */ #endif - DEBUGASSERT(uznum <= (size_t) CURL_MASK_SCOFFT); - return (curl_off_t)(uznum & (size_t) CURL_MASK_SCOFFT); + DEBUGASSERT(uznum <= (size_t)CURL_MASK_SCOFFT); + return (curl_off_t)(uznum & (size_t)CURL_MASK_SCOFFT); #if defined(__INTEL_COMPILER) || defined(_MSC_VER) # pragma warning(pop) @@ -192,12 +192,11 @@ void tool_mime_free(struct tool_mime *mime) } } - /* Mime part callbacks for stdin. */ size_t tool_mime_stdin_read(char *buffer, size_t size, size_t nitems, void *arg) { - struct tool_mime *sip = (struct tool_mime *) arg; + struct tool_mime *sip = (struct tool_mime *)arg; curl_off_t bytesleft; (void)size; /* Always 1: ignored. */ @@ -230,7 +229,7 @@ size_t tool_mime_stdin_read(char *buffer, int tool_mime_stdin_seek(void *instream, curl_off_t offset, int whence) { - struct tool_mime *sip = (struct tool_mime *) instream; + struct tool_mime *sip = (struct tool_mime *)instream; switch(whence) { case SEEK_CUR: @@ -296,8 +295,8 @@ static CURLcode tool2curlparts(CURL *curl, struct tool_mime *m, FALLTHROUGH(); case TOOLMIME_STDINDATA: ret = curl_mime_data_cb(part, m->size, - (curl_read_callback) tool_mime_stdin_read, - (curl_seek_callback) tool_mime_stdin_seek, + (curl_read_callback)tool_mime_stdin_read, + (curl_seek_callback)tool_mime_stdin_seek, NULL, m); break; @@ -372,8 +371,7 @@ static char *get_param_word(char **str, char **end_pos, char endchar) if(*ptr == '\\' && (ptr[1] == '\\' || ptr[1] == '"')) ++ptr; *ptr2++ = *ptr++; - } - while(ptr < *end_pos); + } while(ptr < *end_pos); *end_pos = ptr2; } ++ptr; @@ -428,7 +426,7 @@ static int read_field_headers(FILE *fp, struct curl_slist **pheaders) else if(ptr[0] == ' ') /* a continuation from the line before */ folded = TRUE; /* trim off trailing CRLFs and whitespaces */ - while(len && (ISNEWLINE(ptr[len -1]) || ISBLANK(ptr[len - 1]))) + while(len && (ISNEWLINE(ptr[len - 1]) || ISBLANK(ptr[len - 1]))) len--; if(!len) @@ -658,7 +656,6 @@ static int get_param_part(char endchar, return sep & 0xFF; } - /*************************************************************************** * * formparse() @@ -706,13 +703,13 @@ static int get_param_part(char endchar, * ***************************************************************************/ -#define SET_TOOL_MIME_PTR(m, field) \ - do { \ - if(field) { \ - (m)->field = curlx_strdup(field); \ - if(!(m)->field) \ - goto fail; \ - } \ +#define SET_TOOL_MIME_PTR(m, field) \ + do { \ + if(field) { \ + (m)->field = curlx_strdup(field); \ + if(!(m)->field) \ + goto fail; \ + } \ } while(0) int formparse(const char *input, @@ -811,9 +808,8 @@ int formparse(const char *input, part->headers = headers; headers = NULL; if(res == CURLE_READ_ERROR) { - /* An error occurred while reading stdin: if read has started, - issue the error now. Else, delay it until processed by - libcurl. */ + /* An error occurred while reading stdin: if read has started, + issue the error now. Else, delay it until processed by libcurl. */ if(part->size > 0) { warnf("error while reading standard input"); goto fail; @@ -838,8 +834,7 @@ int formparse(const char *input, if(sep < 0) goto fail; - part = tool_mime_new_filedata(*mimecurrent, data, FALSE, - &res); + part = tool_mime_new_filedata(*mimecurrent, data, FALSE, &res); if(!part) goto fail; part->headers = headers; @@ -879,7 +874,7 @@ int formparse(const char *input, SET_TOOL_MIME_PTR(part, encoder); if(sep) { - *contp = (char) sep; + *contp = (char)sep; warnf("garbage at end of field specification: %s", contp); } } diff --git a/src/tool_getparam.c b/src/tool_getparam.c index 7afb0c5fc051..89385af84436 100644 --- a/src/tool_getparam.c +++ b/src/tool_getparam.c @@ -39,7 +39,7 @@ #include "var.h" #define ALLOW_BLANK TRUE -#define DENY_BLANK FALSE +#define DENY_BLANK FALSE static ParameterError getstr(char **str, const char *val, bool allowblank) { @@ -432,22 +432,22 @@ ParameterError parse_cert_parameter(const char *cert_parameter, case '\\': param_place++; switch(*param_place) { - case '\0': - *certname_place++ = '\\'; - break; - case '\\': - *certname_place++ = '\\'; - param_place++; - break; - case ':': - *certname_place++ = ':'; - param_place++; - break; - default: - *certname_place++ = '\\'; - *certname_place++ = *param_place; - param_place++; - break; + case '\0': + *certname_place++ = '\\'; + break; + case '\\': + *certname_place++ = '\\'; + param_place++; + break; + case ':': + *certname_place++ = ':'; + param_place++; + break; + default: + *certname_place++ = '\\'; + *certname_place++ = *param_place; + param_place++; + break; } break; case ':': @@ -459,7 +459,7 @@ ParameterError parse_cert_parameter(const char *cert_parameter, #ifdef _WIN32 if((param_place == &cert_parameter[1]) && (cert_parameter[2] == '\\' || cert_parameter[2] == '/') && - (ISALPHA(cert_parameter[0])) ) { + (ISALPHA(cert_parameter[0]))) { /* colon in the second column, followed by a backslash, and the first character is an alphabetic letter: @@ -503,7 +503,7 @@ static size_t replace_url_encoded_space_by_plus(char *url) url[new_index] = '+'; orig_index += 3; } - else{ + else { if(new_index != orig_index) { url[new_index] = url[orig_index]; } @@ -517,8 +517,8 @@ static size_t replace_url_encoded_space_by_plus(char *url) return new_index; /* new size */ } -static ParameterError -GetFileAndPassword(const char *nextarg, char **file, char **password) +static ParameterError GetFileAndPassword(const char *nextarg, char **file, + char **password) { char *certname, *passphrase; ParameterError err; @@ -558,15 +558,15 @@ static ParameterError GetSizeParameter(const char *arg, switch(*unit) { case 'G': case 'g': - if(value > (CURL_OFF_T_MAX / (1024*1024*1024))) + if(value > (CURL_OFF_T_MAX / (1024 * 1024 * 1024))) return PARAM_NUMBER_TOO_LARGE; - value *= 1024*1024*1024; + value *= 1024 * 1024 * 1024; break; case 'M': case 'm': - if(value > (CURL_OFF_T_MAX / (1024*1024))) + if(value > (CURL_OFF_T_MAX / (1024 * 1024))) return PARAM_NUMBER_TOO_LARGE; - value *= 1024*1024; + value *= 1024 * 1024; break; case 'K': case 'k': @@ -602,7 +602,7 @@ static void cleanarg(char *str) #endif /* the maximum size we allow the dynbuf generated string */ -#define MAX_DATAURLENCODE (500*1024*1024) +#define MAX_DATAURLENCODE (500 * 1024 * 1024) /* --data-urlencode */ static ParameterError data_urlencode(const char *nextarg, @@ -706,8 +706,7 @@ static ParameterError data_urlencode(const char *nextarg, return err; } -static void sethttpver(struct OperationConfig *config, - long httpversion) +static void sethttpver(struct OperationConfig *config, long httpversion) { if(config->httpversion && (config->httpversion != httpversion)) @@ -732,20 +731,20 @@ static CURLcode set_trace_config(const char *token) len = strlen(token); switch(*token) { - case '-': - toggle = FALSE; - name = token + 1; - len--; - break; - case '+': - toggle = TRUE; - name = token + 1; - len--; - break; - default: - toggle = TRUE; - name = token; - break; + case '-': + toggle = FALSE; + name = token + 1; + len--; + break; + case '+': + toggle = TRUE; + name = token + 1; + len--; + break; + default: + toggle = TRUE; + name = token; + break; } if((len == 3) && curl_strnequal(name, "all", 3)) { @@ -816,37 +815,37 @@ struct TOSEntry { }; static const struct TOSEntry tos_entries[] = { - {"AF11", 0x28}, - {"AF12", 0x30}, - {"AF13", 0x38}, - {"AF21", 0x48}, - {"AF22", 0x50}, - {"AF23", 0x58}, - {"AF31", 0x68}, - {"AF32", 0x70}, - {"AF33", 0x78}, - {"AF41", 0x88}, - {"AF42", 0x90}, - {"AF43", 0x98}, - {"CE", 0x03}, - {"CS0", 0x00}, - {"CS1", 0x20}, - {"CS2", 0x40}, - {"CS3", 0x60}, - {"CS4", 0x80}, - {"CS5", 0xa0}, - {"CS6", 0xc0}, - {"CS7", 0xe0}, - {"ECT0", 0x02}, - {"ECT1", 0x01}, - {"EF", 0xb8}, - {"LE", 0x04}, - {"LOWCOST", 0x02}, - {"LOWDELAY", 0x10}, - {"MINCOST", 0x02}, - {"RELIABILITY", 0x04}, - {"THROUGHPUT", 0x08}, - {"VOICE-ADMIT", 0xb0} + { "AF11", 0x28 }, + { "AF12", 0x30 }, + { "AF13", 0x38 }, + { "AF21", 0x48 }, + { "AF22", 0x50 }, + { "AF23", 0x58 }, + { "AF31", 0x68 }, + { "AF32", 0x70 }, + { "AF33", 0x78 }, + { "AF41", 0x88 }, + { "AF42", 0x90 }, + { "AF43", 0x98 }, + { "CE", 0x03 }, + { "CS0", 0x00 }, + { "CS1", 0x20 }, + { "CS2", 0x40 }, + { "CS3", 0x60 }, + { "CS4", 0x80 }, + { "CS5", 0xa0 }, + { "CS6", 0xc0 }, + { "CS7", 0xe0 }, + { "ECT0", 0x02 }, + { "ECT1", 0x01 }, + { "EF", 0xb8 }, + { "LE", 0x04 }, + { "LOWCOST", 0x02 }, + { "LOWDELAY", 0x10 }, + { "MINCOST", 0x02 }, + { "RELIABILITY", 0x04 }, + { "THROUGHPUT", 0x08 }, + { "VOICE-ADMIT", 0xb0 } }; static int find_tos(const void *a, const void *b) @@ -986,9 +985,9 @@ static ParameterError set_rate(const char *nextarg) const char *div = strchr(nextarg, '/'); char number[26]; long denominator; - long numerator = 60*60*1000; /* default per hour */ + long numerator = 60 * 60 * 1000; /* default per hour */ size_t numlen = div ? (size_t)(div - nextarg) : strlen(nextarg); - if(numlen > sizeof(number) -1) + if(numlen > sizeof(number) - 1) return PARAM_NUMBER_TOO_LARGE; memcpy(number, nextarg, numlen); @@ -1012,12 +1011,12 @@ static ParameterError set_rate(const char *nextarg) numerator = 1000; break; case 'm': /* per minute */ - numerator = 60*1000; + numerator = 60 * 1000; break; case 'h': /* per hour */ break; case 'd': /* per day */ - numerator = 24*60*60*1000; + numerator = 24 * 60 * 60 * 1000; break; default: errorf("unsupported --rate unit"); @@ -1040,7 +1039,7 @@ static ParameterError set_rate(const char *nextarg) else if(denominator > numerator) err = PARAM_NUMBER_TOO_LARGE; else - global->ms_per_transfer = numerator/denominator; + global->ms_per_transfer = numerator / denominator; return err; } @@ -1133,7 +1132,6 @@ static ParameterError parse_url(struct OperationConfig *config, return add_url(config, nextarg, FALSE); } - static ParameterError parse_localport(struct OperationConfig *config, const char *nextarg) { @@ -1163,7 +1161,7 @@ static ParameterError parse_localport(struct OperationConfig *config, else { if(str2unummax(&config->localportrange, pp, 65535)) return PARAM_BAD_USE; - config->localportrange -= (config->localport-1); + config->localportrange -= (config->localport - 1); if(config->localportrange < 1) return PARAM_BAD_USE; } @@ -1237,7 +1235,7 @@ static ParameterError parse_ech(struct OperationConfig *config, curlx_fclose(file); if(err) return err; - config->ech_config = curl_maprintf("ecl:%s",tmpcfg); + config->ech_config = curl_maprintf("ecl:%s", tmpcfg); curlx_free(tmpcfg); if(!config->ech_config) return PARAM_NO_MEM; @@ -1268,7 +1266,7 @@ static ParameterError parse_header(struct OperationConfig *config, else { struct dynbuf line; bool error = FALSE; - curlx_dyn_init(&line, 1024*100); + curlx_dyn_init(&line, 1024 * 100); while(my_get_line(file, &line, &error)) { const char *ptr = curlx_dyn_ptr(&line); err = add2list(cmd == C_PROXY_HEADER ? /* --proxy-header? */ @@ -1287,7 +1285,7 @@ static ParameterError parse_header(struct OperationConfig *config, else { if(!strchr(nextarg, ':') && !strchr(nextarg, ';')) { warnf("The provided %s header '%s' does not look like a header?", - (cmd == C_PROXY_HEADER) ? "proxy": "HTTP", nextarg); + (cmd == C_PROXY_HEADER) ? "proxy" : "HTTP", nextarg); } if(cmd == C_PROXY_HEADER) /* --proxy-header */ err = add2list(&config->proxyheaders, nextarg); @@ -1629,12 +1627,12 @@ struct flagmap { }; static const struct flagmap flag_table[] = { - {"answered", 8, CURLULFLAG_ANSWERED}, - {"deleted", 7, CURLULFLAG_DELETED}, - {"draft", 5, CURLULFLAG_DRAFT}, - {"flagged", 7, CURLULFLAG_FLAGGED}, - {"seen", 4, CURLULFLAG_SEEN}, - {NULL, 0, 0} + { "answered", 8, CURLULFLAG_ANSWERED }, + { "deleted", 7, CURLULFLAG_DELETED }, + { "draft", 5, CURLULFLAG_DRAFT }, + { "flagged", 7, CURLULFLAG_FLAGGED }, + { "seen", 4, CURLULFLAG_SEEN }, + { NULL, 0, 0 } }; static ParameterError parse_upload_flags(struct OperationConfig *config, @@ -2902,7 +2900,7 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */ p = word; /* is there an '=' ? */ if(!curlx_str_until(&p, &out, MAX_OPTION_LEN, '=') && - !curlx_str_single(&p, '=') ) { + !curlx_str_single(&p, '=')) { /* there is an equal sign */ char tempword[MAX_OPTION_LEN + 1]; memcpy(tempword, curlx_str(&out), curlx_strlen(&out)); diff --git a/src/tool_getparam.h b/src/tool_getparam.h index d4812f6cebca..10b235187436 100644 --- a/src/tool_getparam.h +++ b/src/tool_getparam.h @@ -319,12 +319,12 @@ typedef enum { #define ARG_FILE 3 /* requires an argument, usually a filename */ #define ARG_TYPEMASK 0x03 -#define ARGTYPE(x) ((x) & ARG_TYPEMASK) +#define ARGTYPE(x) ((x) & ARG_TYPEMASK) -#define ARG_DEPR 0x10 /* deprecated option */ +#define ARG_DEPR 0x10 /* deprecated option */ #define ARG_CLEAR 0x20 /* clear cmdline argument */ -#define ARG_TLS 0x40 /* requires TLS support */ -#define ARG_NO 0x80 /* set if the option is documented as --no-* */ +#define ARG_TLS 0x40 /* requires TLS support */ +#define ARG_NO 0x80 /* set if the option is documented as --no-* */ struct LongShort { const char *lname; /* long name option */ @@ -383,7 +383,7 @@ ParameterError parse_args(int argc, argv_item_t argv[]); #define convert_UTF8_to_tchar(ptr) curlx_convert_UTF8_to_wchar((ptr)) #define convert_tchar_to_UTF8(ptr) curlx_convert_wchar_to_UTF8((ptr)) -#define unicodefree(ptr) curlx_unicodefree(ptr) +#define unicodefree(ptr) curlx_unicodefree(ptr) #else diff --git a/src/tool_getpass.c b/src/tool_getpass.c index b0316510bc23..f2423790fe2a 100644 --- a/src/tool_getpass.c +++ b/src/tool_getpass.c @@ -98,17 +98,16 @@ char *getpass_r(const char *prompt, char *buffer, size_t buflen) buffer[i] = '\0'; break; } - else - if(buffer[i] == '\b') - /* remove this letter and if this is not the first key, remove the + else if(buffer[i] == '\b') + /* remove this letter and if this is not the first key, remove the previous one as well */ - i = i - (i >= 1 ? 2 : 1); + i = i - (i >= 1 ? 2 : 1); } /* since echo is disabled, print a newline */ fputs("\n", tool_stderr); /* if user did not hit ENTER, terminate buffer */ if(i == buflen) - buffer[buflen-1] = '\0'; + buffer[buflen - 1] = '\0'; return buffer; /* we always return success */ } diff --git a/src/tool_help.c b/src/tool_help.c index bbe8dc68a4c3..7355d2a7822f 100644 --- a/src/tool_help.c +++ b/src/tool_help.c @@ -41,31 +41,31 @@ struct category_descriptors { static const struct category_descriptors categories[] = { /* important is left out because it is the default help page */ - {"auth", "Authentication methods", CURLHELP_AUTH}, - {"connection", "Manage connections", CURLHELP_CONNECTION}, - {"curl", "The command line tool itself", CURLHELP_CURL}, - {"deprecated", "Legacy", CURLHELP_DEPRECATED}, - {"dns", "Names and resolving", CURLHELP_DNS}, - {"file", "FILE protocol", CURLHELP_FILE}, - {"ftp", "FTP protocol", CURLHELP_FTP}, - {"global", "Global options", CURLHELP_GLOBAL}, - {"http", "HTTP and HTTPS protocol", CURLHELP_HTTP}, - {"imap", "IMAP protocol", CURLHELP_IMAP}, - {"ldap", "LDAP protocol", CURLHELP_LDAP}, - {"output", "File system output", CURLHELP_OUTPUT}, - {"pop3", "POP3 protocol", CURLHELP_POP3}, - {"post", "HTTP POST specific", CURLHELP_POST}, - {"proxy", "Options for proxies", CURLHELP_PROXY}, - {"scp", "SCP protocol", CURLHELP_SCP}, - {"sftp", "SFTP protocol", CURLHELP_SFTP}, - {"smtp", "SMTP protocol", CURLHELP_SMTP}, - {"ssh", "SSH protocol", CURLHELP_SSH}, - {"telnet", "TELNET protocol", CURLHELP_TELNET}, - {"tftp", "TFTP protocol", CURLHELP_TFTP}, - {"timeout", "Timeouts and delays", CURLHELP_TIMEOUT}, - {"tls", "TLS/SSL related", CURLHELP_TLS}, - {"upload", "Upload, sending data", CURLHELP_UPLOAD}, - {"verbose", "Tracing, logging etc", CURLHELP_VERBOSE} + { "auth", "Authentication methods", CURLHELP_AUTH }, + { "connection", "Manage connections", CURLHELP_CONNECTION }, + { "curl", "The command line tool itself", CURLHELP_CURL }, + { "deprecated", "Legacy", CURLHELP_DEPRECATED }, + { "dns", "Names and resolving", CURLHELP_DNS }, + { "file", "FILE protocol", CURLHELP_FILE }, + { "ftp", "FTP protocol", CURLHELP_FTP }, + { "global", "Global options", CURLHELP_GLOBAL }, + { "http", "HTTP and HTTPS protocol", CURLHELP_HTTP }, + { "imap", "IMAP protocol", CURLHELP_IMAP }, + { "ldap", "LDAP protocol", CURLHELP_LDAP }, + { "output", "File system output", CURLHELP_OUTPUT }, + { "pop3", "POP3 protocol", CURLHELP_POP3 }, + { "post", "HTTP POST specific", CURLHELP_POST }, + { "proxy", "Options for proxies", CURLHELP_PROXY }, + { "scp", "SCP protocol", CURLHELP_SCP }, + { "sftp", "SFTP protocol", CURLHELP_SFTP }, + { "smtp", "SMTP protocol", CURLHELP_SMTP }, + { "ssh", "SSH protocol", CURLHELP_SSH }, + { "telnet", "TELNET protocol", CURLHELP_TELNET }, + { "tftp", "TFTP protocol", CURLHELP_TFTP }, + { "timeout", "Timeouts and delays", CURLHELP_TIMEOUT }, + { "tls", "TLS/SSL related", CURLHELP_TLS }, + { "upload", "Upload, sending data", CURLHELP_UPLOAD }, + { "verbose", "Tracing, logging etc", CURLHELP_VERBOSE } }; static void print_category(unsigned int category, unsigned int cols) @@ -228,7 +228,8 @@ void tool_help(const char *category) unsigned int cols = get_terminal_columns(); /* If no category was provided */ if(!category) { - const char *category_note = "\nThis is not the full help; this " + const char *category_note = + "\nThis is not the full help; this " "menu is split into categories.\nUse \"--help category\" to get " "an overview of all categories, which are:"; const char *category_note2 = @@ -303,7 +304,7 @@ void tool_help(const char *category) static bool is_debug(void) { - const char *const *builtin; + const char * const *builtin; for(builtin = feature_names; *builtin; ++builtin) if(curl_strequal("debug", *builtin)) return TRUE; @@ -312,7 +313,7 @@ static bool is_debug(void) void tool_version_info(void) { - const char *const *builtin; + const char * const *builtin; if(is_debug()) curl_mfprintf(tool_stderr, "WARNING: this libcurl is Debug-enabled, " "do not use in production\n\n"); diff --git a/src/tool_helpers.c b/src/tool_helpers.c index 2e308a248f13..c32e1bbaabe1 100644 --- a/src/tool_helpers.c +++ b/src/tool_helpers.c @@ -75,7 +75,7 @@ const char *param2text(ParameterError error) int SetHTTPrequest(HttpReq req, HttpReq *store) { /* this mirrors the HttpReq enum in tool_sdecls.h */ - const char *reqname[]= { + const char *reqname[] = { "", /* unspec */ "GET (-G, --get)", "HEAD (-I, --head)", @@ -99,7 +99,7 @@ int SetHTTPrequest(HttpReq req, HttpReq *store) void customrequest_helper(HttpReq req, char *method) { /* this mirrors the HttpReq enum in tool_sdecls.h */ - const char *dflt[]= { + const char *dflt[] = { "GET", "GET", "HEAD", diff --git a/src/tool_ipfs.c b/src/tool_ipfs.c index c1d27fc99b09..25bff3152f7c 100644 --- a/src/tool_ipfs.c +++ b/src/tool_ipfs.c @@ -157,8 +157,8 @@ CURLcode ipfs_url_rewrite(CURLU *uh, const char *protocol, char **url, } /* check for unsupported gateway parts */ - if(curl_url_get(gatewayurl, CURLUPART_QUERY, &gwquery, 0) - != CURLUE_NO_QUERY) { + if(curl_url_get(gatewayurl, CURLUPART_QUERY, &gwquery, 0) != + CURLUE_NO_QUERY) { result = CURLE_URL_MALFORMAT; goto clean; } diff --git a/src/tool_libinfo.c b/src/tool_libinfo.c index 1687005481a9..18e0d6964ee5 100644 --- a/src/tool_libinfo.c +++ b/src/tool_libinfo.c @@ -137,7 +137,7 @@ size_t feature_count; CURLcode get_libcurl_info(void) { CURLcode result = CURLE_OK; - const char *const *builtin; + const char * const *builtin; /* Pointer to libcurl's runtime version information */ curlinfo = curl_version_info(CURLVERSION_NOW); diff --git a/src/tool_main.c b/src/tool_main.c index eb15ae740dd1..3784f280f645 100644 --- a/src/tool_main.c +++ b/src/tool_main.c @@ -109,7 +109,7 @@ static void memory_tracking_init(void) /* use the value as filename */ char fname[512]; if(strlen(env) >= sizeof(fname)) - env[sizeof(fname)-1] = '\0'; + env[sizeof(fname) - 1] = '\0'; strcpy(fname, env); curl_free(env); curl_dbg_memdebug(fname); diff --git a/src/tool_main.h b/src/tool_main.h index 53ee9a3702a7..757861632038 100644 --- a/src/tool_main.h +++ b/src/tool_main.h @@ -30,10 +30,10 @@ #define RETRY_SLEEP_DEFAULT 1000L /* ms */ #define RETRY_SLEEP_MAX 600000L /* ms == 10 minutes */ -#define MAX_PARALLEL 65535 +#define MAX_PARALLEL 65535 #define PARALLEL_DEFAULT 50 -#define MAX_PARALLEL_HOST 65535 +#define MAX_PARALLEL_HOST 65535 #define PARALLEL_HOST_DEFAULT 0 /* means not used */ #endif /* HEADER_CURL_TOOL_MAIN_H */ diff --git a/src/tool_msgs.c b/src/tool_msgs.c index b385f75cf8b8..b4fc1fb6fd5a 100644 --- a/src/tool_msgs.c +++ b/src/tool_msgs.c @@ -28,8 +28,8 @@ #include "tool_cb_prg.h" #include "terminal.h" -#define WARN_PREFIX "Warning: " -#define NOTE_PREFIX "Note: " +#define WARN_PREFIX "Warning: " +#define NOTE_PREFIX "Note: " #define ERROR_PREFIX "curl: " static void voutf(const char *prefix, @@ -53,7 +53,7 @@ static void voutf(const char *prefix, fputs(prefix, tool_stderr); if(len > width) { - size_t cut = width-1; + size_t cut = width - 1; while(!ISBLANK(ptr[cut]) && cut) { cut--; @@ -61,7 +61,7 @@ static void voutf(const char *prefix, if(cut == 0) /* not a single cutting position was found, just cut it at the max text width then! */ - cut = width-1; + cut = width - 1; (void)fwrite(ptr, cut + 1, 1, tool_stderr); fputs("\n", tool_stderr); @@ -121,9 +121,9 @@ void helpf(const char *fmt, ...) } curl_mfprintf(tool_stderr, "curl: try 'curl --help' " #ifdef USE_MANUAL - "or 'curl --manual' " + "or 'curl --manual' " #endif - "for more information\n"); + "for more information\n"); } /* diff --git a/src/tool_msgs.h b/src/tool_msgs.h index 99a980234a23..be75d95593ef 100644 --- a/src/tool_msgs.h +++ b/src/tool_msgs.h @@ -26,13 +26,9 @@ #include "tool_setup.h" #include "tool_cfgable.h" -void warnf(const char *fmt, ...) - CURL_PRINTF(1, 2); -void notef(const char *fmt, ...) - CURL_PRINTF(1, 2); -void helpf(const char *fmt, ...) - CURL_PRINTF(1, 2); -void errorf(const char *fmt, ...) - CURL_PRINTF(1, 2); +void warnf(const char *fmt, ...) CURL_PRINTF(1, 2); +void notef(const char *fmt, ...) CURL_PRINTF(1, 2); +void helpf(const char *fmt, ...) CURL_PRINTF(1, 2); +void errorf(const char *fmt, ...) CURL_PRINTF(1, 2); #endif /* HEADER_CURL_TOOL_MSGS_H */ diff --git a/src/tool_operate.c b/src/tool_operate.c index 71d29af8d8b0..25c1473b9685 100644 --- a/src/tool_operate.c +++ b/src/tool_operate.c @@ -155,7 +155,7 @@ static curl_off_t vms_realfilesize(const char *name, char buffer[8192]; curl_off_t count; int ret_stat; - FILE * file; + FILE *file; /* !checksrc! disable FOPENMODE 1 */ file = curlx_fopen(name, "r"); /* VMS */ @@ -180,8 +180,7 @@ static curl_off_t vms_realfilesize(const char *name, * if not to call a routine to get the correct size. * */ -static curl_off_t VmsSpecialSize(const char *name, - const struct_stat *stat_buf) +static curl_off_t VmsSpecialSize(const char *name, const struct_stat *stat_buf) { switch(stat_buf->st_fab_rfm) { case FAB$C_VAR: @@ -451,7 +450,7 @@ static CURLcode retrycheck(struct OperationConfig *config, if(retry) { long sleeptime = 0; curl_off_t retry_after = 0; - static const char * const m[]={ + static const char * const m[] = { NULL, "(retrying all errors)", ": timeout", @@ -465,7 +464,7 @@ static CURLcode retrycheck(struct OperationConfig *config, curl_easy_getinfo(curl, CURLINFO_RETRY_AFTER, &retry_after); if(retry_after) { /* store in a 'long', make sure it does not overflow */ - if(retry_after > LONG_MAX/1000) + if(retry_after > LONG_MAX / 1000) sleeptime = LONG_MAX; else if((retry_after * 1000) > sleeptime) sleeptime = (long)retry_after * 1000; /* milliseconds */ @@ -500,10 +499,10 @@ static CURLcode retrycheck(struct OperationConfig *config, warnf("Problem %s. " "Will retry in %ld%s%.*ld second%s. " "%ld retr%s left.", - m[retry], sleeptime/1000L, - (sleeptime%1000L ? "." : ""), - (sleeptime%1000L ? 3 : 0), - sleeptime%1000L, + m[retry], sleeptime / 1000L, + (sleeptime % 1000L ? "." : ""), + (sleeptime % 1000L ? 3 : 0), + sleeptime % 1000L, (sleeptime == 1000L ? "" : "s"), per->retry_remaining, (per->retry_remaining > 1 ? "ies" : "y")); @@ -547,8 +546,7 @@ static CURLcode retrycheck(struct OperationConfig *config, outs->init += outs->bytes; outs->bytes = 0; config->resume_from = outs->init; - curl_easy_setopt(curl, CURLOPT_RESUME_FROM_LARGE, - config->resume_from); + curl_easy_setopt(curl, CURLOPT_RESUME_FROM_LARGE, config->resume_from); } } @@ -562,8 +560,7 @@ static CURLcode retrycheck(struct OperationConfig *config, int rc; /* We have written data to an output file, we truncate file */ fflush(outs->stream); - notef("Throwing away %" CURL_FORMAT_CURL_OFF_T " bytes", - outs->bytes); + notef("Throwing away %" CURL_FORMAT_CURL_OFF_T " bytes", outs->bytes); /* truncate file at the position where we started appending */ #if defined(HAVE_FTRUNCATE) && !defined(__DJGPP__) && !defined(__AMIGA__) if(ftruncate(fileno(outs->stream), outs->init)) { @@ -595,7 +592,6 @@ static CURLcode retrycheck(struct OperationConfig *config, return result; } - /* * Call this after a transfer has completed. */ @@ -706,7 +702,7 @@ static CURLcode post_per_transfer(struct per_transfer *per, if(per->retry_remaining && (!config->retry_maxtime_ms || (curlx_timediff_ms(curlx_now(), per->retrystart) < - config->retry_maxtime_ms)) ) { + config->retry_maxtime_ms))) { result = retrycheck(config, per, result, retryp, delay); if(!result && *retryp) return CURLE_OK; /* retry! */ @@ -735,8 +731,7 @@ static CURLcode post_per_transfer(struct per_transfer *per, warnf("Failed removing: %s", outs->filename); } else - warnf("Skipping removal; not a regular file: %s", - outs->filename); + warnf("Skipping removal; not a regular file: %s", outs->filename); } } @@ -825,8 +820,7 @@ static CURLcode append2query(struct OperationConfig *config, CURLU *uh = curl_url(); if(uh) { CURLUcode uerr; - uerr = curl_url_set(uh, CURLUPART_URL, per->url, - CURLU_GUESS_SCHEME); + uerr = curl_url_set(uh, CURLUPART_URL, per->url, CURLU_GUESS_SCHEME); if(uerr) { result = urlerr_cvt(uerr); errorf("(%d) Could not parse the URL, " @@ -837,8 +831,7 @@ static CURLcode append2query(struct OperationConfig *config, char *updated = NULL; uerr = curl_url_set(uh, CURLUPART_QUERY, q, CURLU_APPENDQUERY); if(!uerr) - uerr = curl_url_get(uh, CURLUPART_URL, &updated, - CURLU_GUESS_SCHEME); + uerr = curl_url_get(uh, CURLUPART_URL, &updated, CURLU_GUESS_SCHEME); if(uerr) result = urlerr_cvt(uerr); else { @@ -1333,8 +1326,7 @@ static CURLcode single_transfer(struct OperationConfig *config, /* * We have specified a file to upload and it is not "-". */ - result = add_file_name_to_url(per->curl, &per->url, - per->uploadfile); + result = add_file_name_to_url(per->curl, &per->url, per->uploadfile); if(result) return result; } @@ -1370,8 +1362,7 @@ static CURLcode single_transfer(struct OperationConfig *config, } /* explicitly passed to stdout means okaying binary gunk */ - config->terminal_binary_ok = - (per->outfile && !strcmp(per->outfile, "-")); + config->terminal_binary_ok = (per->outfile && !strcmp(per->outfile, "-")); hdrcbdata->honor_cd_filename = (config->content_disposition && u->useremote); @@ -1428,7 +1419,7 @@ static CURLcode add_parallel_transfers(CURLM *multi, CURLSH *share, return CURLE_UNKNOWN_OPTION; } - if(nxfers < (curl_off_t)(global->parallel_max*2)) { + if(nxfers < (curl_off_t)(global->parallel_max * 2)) { bool skipped = FALSE; do { result = create_transfer(share, addedp, &skipped); @@ -1513,7 +1504,7 @@ struct parastate { #if defined(DEBUGBUILD) && defined(USE_LIBUV) -#define DEBUG_UV 0 +#define DEBUG_UV 0 /* object to pass to the callbacks */ struct datauv { @@ -1535,7 +1526,7 @@ static void mnotify(CURLM *multi, unsigned int notification, static void on_uv_socket(uv_poll_t *req, int status, int events) { int flags = 0; - struct contextuv *c = (struct contextuv *) req->data; + struct contextuv *c = (struct contextuv *)req->data; (void)status; if(events & UV_READABLE) flags |= CURL_CSELECT_IN; @@ -1550,7 +1541,7 @@ static void on_uv_socket(uv_poll_t *req, int status, int events) /* callback from libuv when timeout expires */ static void on_uv_timeout(uv_timer_t *req) { - struct datauv *uv = (struct datauv *) req->data; + struct datauv *uv = (struct datauv *)req->data; #if DEBUG_UV curl_mfprintf(tool_stderr, "parallel_event: on_uv_timeout\n"); #endif @@ -1599,13 +1590,13 @@ static struct contextuv *create_context(curl_socket_t sockfd, static void close_cb(uv_handle_t *handle) { - struct contextuv *c = (struct contextuv *) handle->data; + struct contextuv *c = (struct contextuv *)handle->data; curlx_free(c); } static void destroy_context(struct contextuv *c) { - uv_close((uv_handle_t *) &c->poll_handle, close_cb); + uv_close((uv_handle_t *)&c->poll_handle, close_cb); } /* callback from libcurl to update socket activity to wait for */ @@ -1625,8 +1616,7 @@ static int cb_socket(CURL *easy, curl_socket_t s, int action, case CURL_POLL_IN: case CURL_POLL_OUT: case CURL_POLL_INOUT: - c = socketp ? - (struct contextuv *) socketp : create_context(s, uv); + c = socketp ? (struct contextuv *)socketp : create_context(s, uv); curl_multi_assign(uv->s->multi, s, c); @@ -1753,7 +1743,7 @@ static CURLcode check_finished(struct parastate *s) if(retry) { ended->added = FALSE; /* add it again */ /* we delay retries in full integer seconds only */ - ended->startat = delay ? time(NULL) + delay/1000 : 0; + ended->startat = delay ? time(NULL) + delay / 1000 : 0; } else { /* result receives this transfer's error unless the transfer was @@ -2222,7 +2212,6 @@ static CURLcode share_setup(CURLSH *share) return result; } - CURLcode operate(int argc, argv_item_t argv[]) { CURLcode result = CURLE_OK; diff --git a/src/tool_operhlp.c b/src/tool_operhlp.c index a8b5e9497570..c46f3e3eefd9 100644 --- a/src/tool_operhlp.c +++ b/src/tool_operhlp.c @@ -91,7 +91,7 @@ CURLcode add_file_name_to_url(CURL *curl, char **inurlp, const char *filename) if(uh) { char *ptr; uerr = curl_url_set(uh, CURLUPART_URL, *inurlp, - CURLU_GUESS_SCHEME|CURLU_NON_SUPPORT_SCHEME); + CURLU_GUESS_SCHEME | CURLU_NON_SUPPORT_SCHEME); if(uerr) { result = urlerr_cvt(uerr); goto fail; diff --git a/src/tool_paramhlp.c b/src/tool_paramhlp.c index b16fc42906d8..9faf2e4dde2d 100644 --- a/src/tool_paramhlp.c +++ b/src/tool_paramhlp.c @@ -224,7 +224,7 @@ static ParameterError getnum(long *val, const char *str, int base) *val = (long)num; if(is_neg) *val = -*val; - return PARAM_OK; /* Ok */ + return PARAM_OK; /* Ok */ } } return PARAM_BAD_NUMERIC; /* badness */ @@ -309,7 +309,7 @@ ParameterError secs2ms(long *valp, const char *str) const unsigned int digs[] = { 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000 }; if(!str || - curlx_str_number(&str, &secs, LONG_MAX/1000 - 1)) + curlx_str_number(&str, &secs, LONG_MAX / 1000 - 1)) return PARAM_BAD_NUMERIC; if(!curlx_str_single(&str, '.')) { curl_off_t fracs; @@ -319,7 +319,7 @@ ParameterError secs2ms(long *valp, const char *str) return PARAM_NUMBER_TOO_LARGE; /* how many milliseconds are in fracs ? */ len = (str - s); - while((len > CURL_ARRAYSIZE(digs) || (fracs > LONG_MAX/100))) { + while((len > CURL_ARRAYSIZE(digs) || (fracs > LONG_MAX / 100))) { fracs /= 10; len--; } @@ -340,7 +340,7 @@ static size_t protoset_index(const char * const *protoset, const char *proto) { const char * const *p = protoset; - DEBUGASSERT(proto == proto_token(proto)); /* Ensure it is tokenized. */ + DEBUGASSERT(proto == proto_token(proto)); /* Ensure it is tokenized. */ for(; *p; p++) if(proto == *p) @@ -388,7 +388,7 @@ static void protoset_clear(const char **protoset, const char *proto) * data. */ -#define MAX_PROTOSTRING (64*11) /* Enough room for 64 10-chars proto names. */ +#define MAX_PROTOSTRING (64 * 11) /* Room for 64 10-chars proto names. */ ParameterError proto2num(const char * const *val, char **ostr, const char *str) { @@ -452,8 +452,8 @@ ParameterError proto2num(const char * const *val, char **ostr, const char *str) break; case allow: case set: - memcpy((char *) protoset, - built_in_protos, (proto_count + 1) * sizeof(*protoset)); + memcpy((char *)protoset, built_in_protos, + (proto_count + 1) * sizeof(*protoset)); break; } } @@ -491,7 +491,7 @@ ParameterError proto2num(const char * const *val, char **ostr, const char *str) } /* We need the protocols in alphabetic order for CI tests requirements. */ - qsort((char *) protoset, protoset_index(protoset, NULL), sizeof(*protoset), + qsort((char *)protoset, protoset_index(protoset, NULL), sizeof(*protoset), struplocompare4sort); for(proto = 0; protoset[proto] && !result; proto++) @@ -543,7 +543,7 @@ ParameterError str2offset(curl_off_t *val, const char *str) return PARAM_OK; } -#define MAX_USERPWDLENGTH (100*1024) +#define MAX_USERPWDLENGTH (100 * 1024) static CURLcode checkpasswd(const char *kind, /* for what purpose */ const size_t i, /* operation index */ const bool last, /* TRUE if last operation */ @@ -648,22 +648,21 @@ long delegation(const char *str) return CURLGSSAPI_DELEGATION_NONE; } -#define isheadersep(x) ((((x)==':') || ((x)==';'))) +#define isheadersep(x) ((((x) == ':') || ((x) == ';'))) /* * inlist() returns true if the given 'checkfor' header is present in the * header list. */ -static bool inlist(const struct curl_slist *head, - const char *checkfor) +static bool inlist(const struct curl_slist *head, const char *checkfor) { size_t thislen = strlen(checkfor); DEBUGASSERT(thislen); - DEBUGASSERT(checkfor[thislen-1] != ':'); + DEBUGASSERT(checkfor[thislen - 1] != ':'); for(; head; head = head->next) { if(curl_strnequal(head->data, checkfor, thislen) && - isheadersep(head->data[thislen]) ) + isheadersep(head->data[thislen])) return TRUE; } diff --git a/src/tool_paramhlp.h b/src/tool_paramhlp.h index a9e8539cf57b..f7c743b7e262 100644 --- a/src/tool_paramhlp.h +++ b/src/tool_paramhlp.h @@ -31,7 +31,7 @@ struct getout *new_getout(struct OperationConfig *config); ParameterError file2string(char **bufp, FILE *file); #if SIZEOF_SIZE_T > 4 -#define MAX_FILE2MEMORY (16LL*1024*1024*1024) +#define MAX_FILE2MEMORY (16LL * 1024 * 1024 * 1024) #else #define MAX_FILE2MEMORY (INT_MAX) #endif diff --git a/src/tool_parsecfg.c b/src/tool_parsecfg.c index f901e69e7849..0466c547c3e3 100644 --- a/src/tool_parsecfg.c +++ b/src/tool_parsecfg.c @@ -33,7 +33,7 @@ /* only acknowledge colon or equals as separators if the option was not specified with an initial dash! */ -#define ISSEP(x,dash) (!dash && (((x) == '=') || ((x) == ':'))) +#define ISSEP(x, dash) (!dash && (((x) == '=') || ((x) == ':'))) /* * Copies the string from line to the param dynbuf, unquoting backslash-quoted diff --git a/src/tool_progress.c b/src/tool_progress.c index f9fbd83574ed..53ed9bcb3cec 100644 --- a/src/tool_progress.c +++ b/src/tool_progress.c @@ -44,8 +44,8 @@ static char *max5data(curl_off_t bytes, char *max5) if(nbytes < 100) { /* display with a decimal */ curl_msnprintf(max5, 6, "%2" CURL_FORMAT_CURL_OFF_T ".%0" - CURL_FORMAT_CURL_OFF_T "%c", bytes/1024, - (bytes%1024) / (1024/10), unit[k]); + CURL_FORMAT_CURL_OFF_T "%c", bytes / 1024, + (bytes % 1024) / (1024 / 10), unit[k]); break; } else if(nbytes < 10000) { @@ -143,9 +143,7 @@ static void add_offt(curl_off_t *val, curl_off_t add) |DL% UL% Dled Uled Xfers Live Total Current Left Speed | 6 -- 9.9G 0 2 2 0:00:40 0:00:02 0:00:37 4087M */ -bool progress_meter(CURLM *multi, - struct curltime *start, - bool final) +bool progress_meter(CURLM *multi, struct curltime *start, bool final) { static struct curltime stamp; static bool header = FALSE; @@ -169,9 +167,9 @@ bool progress_meter(CURLM *multi, char time_total[10]; char time_spent[10]; char buffer[3][6]; - curl_off_t spent = curlx_timediff_ms(now, *start)/1000; - char dlpercen[4]="--"; - char ulpercen[4]="--"; + curl_off_t spent = curlx_timediff_ms(now, *start) / 1000; + char dlpercen[4] = "--"; + char ulpercen[4] = "--"; struct per_transfer *per; curl_off_t all_dlnow = 0; curl_off_t all_ulnow = 0; @@ -207,15 +205,15 @@ bool progress_meter(CURLM *multi, } if(dlknown && all_dltotal) curl_msnprintf(dlpercen, sizeof(dlpercen), "%3" CURL_FORMAT_CURL_OFF_T, - all_dlnow < (CURL_OFF_T_MAX/100) ? + all_dlnow < (CURL_OFF_T_MAX / 100) ? (all_dlnow * 100 / all_dltotal) : - (all_dlnow / (all_dltotal/100))); + (all_dlnow / (all_dltotal / 100))); if(ulknown && all_ultotal) curl_msnprintf(ulpercen, sizeof(ulpercen), "%3" CURL_FORMAT_CURL_OFF_T, - all_ulnow < (CURL_OFF_T_MAX/100) ? + all_ulnow < (CURL_OFF_T_MAX / 100) ? (all_ulnow * 100 / all_ultotal) : - (all_ulnow / (all_ultotal/100))); + (all_ulnow / (all_ultotal / 100))); /* get the transfer speed, the higher of the two */ @@ -248,8 +246,8 @@ bool progress_meter(CURLM *multi, } if(!deltams) /* no division by zero please */ deltams++; - dls = (curl_off_t)((double)dl / ((double)deltams/1000.0)); - uls = (curl_off_t)((double)ul / ((double)deltams/1000.0)); + dls = (curl_off_t)((double)dl / ((double)deltams / 1000.0)); + uls = (curl_off_t)((double)ul / ((double)deltams / 1000.0)); speed = dls > uls ? dls : uls; } @@ -291,7 +289,7 @@ bool progress_meter(CURLM *multi, time_spent, time_left, max5data(speed, buffer[2]), /* speed */ - final ? "\n" :""); + final ? "\n" : ""); return TRUE; } return FALSE; diff --git a/src/tool_sdecls.h b/src/tool_sdecls.h index 45b7bd0c2056..9a6f3cc8820f 100644 --- a/src/tool_sdecls.h +++ b/src/tool_sdecls.h @@ -109,7 +109,6 @@ typedef enum { TRACE_PLAIN /* -v/--verbose type */ } trace; - /* * 'HttpReq' enumeration represents HTTP request types. */ @@ -123,7 +122,6 @@ typedef enum { TOOL_HTTPREQ_PUT } HttpReq; - /* * Complete struct declarations which have OperationConfig struct members, * just in case this header is directly included in some source file. diff --git a/src/tool_setopt.c b/src/tool_setopt.c index 97d469d76daa..837f66c9c319 100644 --- a/src/tool_setopt.c +++ b/src/tool_setopt.c @@ -36,9 +36,9 @@ /* For bit masks, put combinations first, then single bits, */ /* and finally any "NONE" value. */ -#define NV(e) {#e, e} -#define NV1(e, v) {#e, (v)} -#define NVEND {NULL, 0} /* sentinel to mark end of list */ +#define NV(e) { #e, e } +#define NV1(e, v) { #e, (v) } +#define NVEND { NULL, 0 } /* sentinel to mark end of list */ const struct NameValue setopt_nv_CURLPROXY[] = { NV(CURLPROXY_HTTP), @@ -101,7 +101,7 @@ const struct NameValue setopt_nv_CURL_SSLVERSION[] = { }; const struct NameValue setopt_nv_CURL_SSLVERSION_MAX[] = { - {"", CURL_SSLVERSION_MAX_NONE}, + { "", CURL_SSLVERSION_MAX_NONE }, NV(CURL_SSLVERSION_MAX_DEFAULT), NV(CURL_SSLVERSION_MAX_TLSv1_0), NV(CURL_SSLVERSION_MAX_TLSv1_1), @@ -174,7 +174,7 @@ static const struct NameValue setopt_nv_CURLNONZERODEFAULTS[] = { /* Escape string to C string syntax. Return NULL if out of memory. */ #define MAX_STRING_LENGTH_OUTPUT 2000 -#define ZERO_TERMINATED -1 +#define ZERO_TERMINATED -1 static char *c_escape(const char *str, curl_off_t len) { @@ -216,7 +216,7 @@ static char *c_escape(const char *str, curl_off_t len) /* Octal escape to avoid >2 digit hex. */ (len > 1 && ISXDIGIT(s[1])) ? "\\%03o" : "\\x%02x", - (unsigned int) *(const unsigned char *) s); + (unsigned int)*(const unsigned char *)s); } } } @@ -337,9 +337,9 @@ CURLcode tool_setopt_bitmask(CURL *curl, const char *name, CURLoption tag, curl_msnprintf(preamble, sizeof(preamble), "curl_easy_setopt(hnd, %s, ", name); for(nv = nvlist; nv->name; nv++) { - if((nv->value & ~ rest) == 0) { + if((nv->value & ~rest) == 0) { /* all value flags contained in rest */ - rest &= ~ nv->value; /* remove bits handled here */ + rest &= ~nv->value; /* remove bits handled here */ ret = easysrc_addf(&easysrc_code, "%s(long)%s%s", preamble, nv->name, rest ? " |" : ");"); if(!rest || ret) @@ -425,8 +425,7 @@ static CURLcode libcurl_generate_mime_part(CURL *curl, mimeno, submimeno); if(!ret) /* Avoid freeing in CLEAN. */ - ret = easysrc_addf(&easysrc_code, - "mime%d = NULL;", submimeno); + ret = easysrc_addf(&easysrc_code, "mime%d = NULL;", submimeno); } break; diff --git a/src/tool_setopt.h b/src/tool_setopt.h index 5ca7188841c4..fcd56382a75f 100644 --- a/src/tool_setopt.h +++ b/src/tool_setopt.h @@ -62,20 +62,20 @@ extern const struct NameValueUnsigned setopt_nv_CURLAUTH[]; extern const struct NameValueUnsigned setopt_nv_CURLHSTS[]; /* Map options to NameValue sets */ -#define setopt_nv_CURLOPT_HSTS_CTRL setopt_nv_CURLHSTS -#define setopt_nv_CURLOPT_HTTP_VERSION setopt_nv_CURL_HTTP_VERSION -#define setopt_nv_CURLOPT_HTTPAUTH setopt_nv_CURLAUTH -#define setopt_nv_CURLOPT_SSLVERSION setopt_nv_CURL_SSLVERSION -#define setopt_nv_CURLOPT_PROXY_SSLVERSION setopt_nv_CURL_SSLVERSION -#define setopt_nv_CURLOPT_TIMECONDITION setopt_nv_CURL_TIMECOND -#define setopt_nv_CURLOPT_FTP_SSL_CCC setopt_nv_CURLFTPSSL_CCC -#define setopt_nv_CURLOPT_USE_SSL setopt_nv_CURLUSESSL -#define setopt_nv_CURLOPT_SSL_OPTIONS setopt_nv_CURLSSLOPT +#define setopt_nv_CURLOPT_HSTS_CTRL setopt_nv_CURLHSTS +#define setopt_nv_CURLOPT_HTTP_VERSION setopt_nv_CURL_HTTP_VERSION +#define setopt_nv_CURLOPT_HTTPAUTH setopt_nv_CURLAUTH +#define setopt_nv_CURLOPT_SSLVERSION setopt_nv_CURL_SSLVERSION +#define setopt_nv_CURLOPT_PROXY_SSLVERSION setopt_nv_CURL_SSLVERSION +#define setopt_nv_CURLOPT_TIMECONDITION setopt_nv_CURL_TIMECOND +#define setopt_nv_CURLOPT_FTP_SSL_CCC setopt_nv_CURLFTPSSL_CCC +#define setopt_nv_CURLOPT_USE_SSL setopt_nv_CURLUSESSL +#define setopt_nv_CURLOPT_SSL_OPTIONS setopt_nv_CURLSSLOPT #define setopt_nv_CURLOPT_PROXY_SSL_OPTIONS setopt_nv_CURLSSLOPT -#define setopt_nv_CURLOPT_NETRC setopt_nv_CURL_NETRC -#define setopt_nv_CURLOPT_PROXYTYPE setopt_nv_CURLPROXY -#define setopt_nv_CURLOPT_PROXYAUTH setopt_nv_CURLAUTH -#define setopt_nv_CURLOPT_SOCKS5_AUTH setopt_nv_CURLAUTH +#define setopt_nv_CURLOPT_NETRC setopt_nv_CURL_NETRC +#define setopt_nv_CURLOPT_PROXYTYPE setopt_nv_CURLPROXY +#define setopt_nv_CURLOPT_PROXYAUTH setopt_nv_CURLAUTH +#define setopt_nv_CURLOPT_SOCKS5_AUTH setopt_nv_CURLAUTH /* Intercept setopt calls for --libcurl */ @@ -103,64 +103,48 @@ CURLcode tool_setopt_str(CURL *curl, struct OperationConfig *config, ...) WARN_UNUSED_RESULT; CURLcode tool_setopt_ptr(CURL *curl, const char *name, CURLoption tag, ...); -#define my_setopt_ptr(x,y,z) \ - tool_setopt_ptr(x, #y, y, z) - -#define my_setopt_long(x,y,z) \ - tool_setopt_long(x, #y, y, z) - -#define my_setopt_offt(x,y,z) \ - tool_setopt_offt(x, #y, y, z) - -#define my_setopt_str(x,y,z) \ - tool_setopt_str(x, config, #y, y, z) +#define my_setopt_long(x, y, z) tool_setopt_long(x, #y, y, z) +#define my_setopt_offt(x, y, z) tool_setopt_offt(x, #y, y, z) +#define my_setopt_ptr(x, y, z) tool_setopt_ptr(x, #y, y, z) +#define my_setopt_str(x, y, z) tool_setopt_str(x, config, #y, y, z) +#define my_setopt_mimepost(x, y, z) tool_setopt_mimepost(x, config, #y, y, z) +#define my_setopt_slist(x, y, z) tool_setopt_slist(x, #y, y, z) +#define my_setopt_SSLVERSION(x, y, z) tool_setopt_SSLVERSION(x, #y, y, z) +#define my_setopt_enum(x, y, z) \ + tool_setopt_enum(x, #y, y, setopt_nv_ ## y, z) +#define my_setopt_bitmask(x, y, z) \ + tool_setopt_bitmask(x, #y, y, setopt_nv_ ## y, z) /* assumes a 'result' variable to use. If the return code is benign it is left in 'result' after this call, otherwise the function returns the error */ -#define MY_SETOPT_STR(x,y,z) \ - do { \ - result = tool_setopt_str(x, config, #y, y, z); \ - if(setopt_bad(result)) \ - return result; \ +#define MY_SETOPT_STR(x, y, z) \ + do { \ + result = tool_setopt_str(x, config, #y, y, z); \ + if(setopt_bad(result)) \ + return result; \ } while(0) -#define my_setopt_enum(x,y,z) \ - tool_setopt_enum(x, #y, y, setopt_nv_ ## y, z) - -#define my_setopt_SSLVERSION(x,y,z) \ - tool_setopt_SSLVERSION(x, #y, y, z) - -#define my_setopt_bitmask(x,y,z) \ - tool_setopt_bitmask(x, #y, y, setopt_nv_ ## y, z) - -#define my_setopt_mimepost(x,y,z) \ - tool_setopt_mimepost(x, config, #y, y, z) - -#define my_setopt_slist(x,y,z) \ - tool_setopt_slist(x, #y, y, z) - #else /* CURL_DISABLE_LIBCURL_OPTION */ /* No --libcurl, so pass options directly to library */ -#define my_setopt_long(x,y,z) curl_easy_setopt(x, y, (long)(z)) -#define my_setopt_offt(x,y,z) curl_easy_setopt(x, y, (curl_off_t)(z)) -#define my_setopt_ptr(x,y,z) curl_easy_setopt(x, y, z) -#define my_setopt_str(x,y,z) curl_easy_setopt(x, y, z) -#define my_setopt_enum(x,y,z) curl_easy_setopt(x, y, z) -#define my_setopt_SSLVERSION(x,y,z) curl_easy_setopt(x, y, z) -#define my_setopt_bitmask(x,y,z) curl_easy_setopt(x, y, (long)z) -#define my_setopt_mimepost(x,y,z) curl_easy_setopt(x, y, z) -#define my_setopt_slist(x,y,z) curl_easy_setopt(x, y, z) - -#define MY_SETOPT_STR(x,y,z) \ - do { \ - result = curl_easy_setopt(x, y, z); \ - if(setopt_bad(result)) \ - return result; \ +#define my_setopt_long(x, y, z) curl_easy_setopt(x, y, (long)(z)) +#define my_setopt_offt(x, y, z) curl_easy_setopt(x, y, (curl_off_t)(z)) +#define my_setopt_ptr(x, y, z) curl_easy_setopt(x, y, z) +#define my_setopt_str(x, y, z) curl_easy_setopt(x, y, z) +#define my_setopt_mimepost(x, y, z) curl_easy_setopt(x, y, z) +#define my_setopt_slist(x, y, z) curl_easy_setopt(x, y, z) +#define my_setopt_SSLVERSION(x, y, z) curl_easy_setopt(x, y, z) +#define my_setopt_enum(x, y, z) curl_easy_setopt(x, y, z) +#define my_setopt_bitmask(x, y, z) curl_easy_setopt(x, y, (long)z) + +#define MY_SETOPT_STR(x, y, z) \ + do { \ + result = curl_easy_setopt(x, y, z); \ + if(setopt_bad(result)) \ + return result; \ } while(0) - #endif /* CURL_DISABLE_LIBCURL_OPTION */ #endif /* HEADER_CURL_TOOL_SETOPT_H */ diff --git a/src/tool_setup.h b/src/tool_setup.h index f693fc1dae70..1524e36103fb 100644 --- a/src/tool_setup.h +++ b/src/tool_setup.h @@ -54,7 +54,7 @@ extern FILE *tool_stderr; */ #ifdef macintosh -# define main(x,y) curl_main(x,y) +# define main(x, y) curl_main(x, y) #endif #ifndef CURL_OS @@ -100,7 +100,7 @@ extern bool tool_term_has_bold; int tool_ftruncate64(int fd, curl_off_t where); #undef ftruncate -#define ftruncate(fd,where) tool_ftruncate64(fd,where) +#define ftruncate(fd, where) tool_ftruncate64(fd, where) #define HAVE_FTRUNCATE 1 #define USE_TOOL_FTRUNCATE 1 diff --git a/src/tool_ssls.c b/src/tool_ssls.c index 7ffd6f707420..6ad5c2475dad 100644 --- a/src/tool_ssls.c +++ b/src/tool_ssls.c @@ -33,7 +33,6 @@ /* The maximum line length for an ecoded session ticket */ #define MAX_SSLS_LINE (64 * 1024) - static CURLcode tool_ssls_easy(struct OperationConfig *config, CURLSH *share, CURL **peasy) { @@ -193,8 +192,7 @@ CURLcode tool_ssls_save(struct OperationConfig *config, ctx.exported = 0; ctx.fp = curlx_fopen(filename, FOPEN_WRITETEXT); if(!ctx.fp) { - warnf("Warning: Failed to create SSL session file %s", - filename); + warnf("Warning: Failed to create SSL session file %s", filename); goto out; } diff --git a/src/tool_urlglob.c b/src/tool_urlglob.c index bfa54ab8275b..ad2e2de9d66b 100644 --- a/src/tool_urlglob.c +++ b/src/tool_urlglob.c @@ -80,7 +80,7 @@ static int multiply(curl_off_t *amount, curl_off_t with) return 1; #else sum = *amount * with; - if(sum/with != *amount) + if(sum / with != *amount) return 1; /* did not fit, bail out */ #endif } @@ -99,7 +99,7 @@ static CURLcode glob_set(struct URLGlob *glob, const char **patternp, bool done = FALSE; const char *pattern = *patternp; const char *opattern = pattern; - size_t opos = *posp-1; + size_t opos = *posp - 1; CURLcode result = CURLE_OK; size_t size = 0; char **elem = NULL; @@ -441,7 +441,7 @@ static CURLcode glob_parse(struct URLGlob *glob, const char *pattern, /* only allow \ to escape known "special letters" */ if(*pattern == '\\' && (pattern[1] == '{' || pattern[1] == '[' || - pattern[1] == '}' || pattern[1] == ']') ) { + pattern[1] == '}' || pattern[1] == ']')) { /* escape character, skip '\' */ ++pattern; @@ -463,7 +463,7 @@ static CURLcode glob_parse(struct URLGlob *glob, const char *pattern, else { if(!*pattern) /* done */ break; - else if(*pattern =='{') { + else if(*pattern == '{') { /* process set pattern */ pattern++; pos++; @@ -500,7 +500,7 @@ CURLcode glob_url(struct URLGlob *glob, char *url, curl_off_t *urlnum, CURLcode res; memset(glob, 0, sizeof(struct URLGlob)); - curlx_dyn_init(&glob->buf, 1024*1024); + curlx_dyn_init(&glob->buf, 1024 * 1024); glob->pattern = curlx_malloc(2 * sizeof(struct URLPattern)); if(!glob->pattern) return CURLE_OUT_OF_MEMORY; @@ -634,7 +634,7 @@ CURLcode glob_next_url(char **globbed, struct URLGlob *glob) return CURLE_OK; } -#define MAX_OUTPUT_GLOB_LENGTH (1024*1024) +#define MAX_OUTPUT_GLOB_LENGTH (1024 * 1024) CURLcode glob_match_url(char **output, const char *filename, struct URLGlob *glob) diff --git a/src/tool_util.c b/src/tool_util.c index 43dd096783cc..96b0715b0af3 100644 --- a/src/tool_util.c +++ b/src/tool_util.c @@ -75,7 +75,7 @@ int struplocompare(const char *p1, const char *p2) /* Indirect version to use as qsort callback. */ int struplocompare4sort(const void *p1, const void *p2) { - return struplocompare(* (char * const *) p1, * (char * const *) p2); + return struplocompare(*(char * const *)p1, *(char * const *)p2); } #ifdef USE_TOOL_FTRUNCATE diff --git a/src/tool_version.h b/src/tool_version.h index 00be7799ea74..5db625c3170f 100644 --- a/src/tool_version.h +++ b/src/tool_version.h @@ -25,12 +25,12 @@ ***************************************************************************/ #include -#define CURL_NAME "curl" -#define CURL_COPYRIGHT LIBCURL_COPYRIGHT -#define CURL_VERSION LIBCURL_VERSION +#define CURL_NAME "curl" +#define CURL_COPYRIGHT LIBCURL_COPYRIGHT +#define CURL_VERSION LIBCURL_VERSION #define CURL_VERSION_MAJOR LIBCURL_VERSION_MAJOR #define CURL_VERSION_MINOR LIBCURL_VERSION_MINOR #define CURL_VERSION_PATCH LIBCURL_VERSION_PATCH -#define CURL_ID CURL_NAME " " CURL_VERSION " (" CURL_OS ") " +#define CURL_ID CURL_NAME " " CURL_VERSION " (" CURL_OS ") " #endif /* HEADER_CURL_TOOL_VERSION_H */ diff --git a/src/tool_vms.c b/src/tool_vms.c index 75aa7d5370ee..71606f3d66c5 100644 --- a/src/tool_vms.c +++ b/src/tool_vms.c @@ -184,7 +184,6 @@ static void decc_init(void) /* Invalid DECC feature name. */ curl_mprintf(" UNKNOWN DECC FEATURE: %s.\n", decc_feat_array[i].name); } - } } @@ -196,16 +195,16 @@ static void decc_init(void) other attributes. Note that "nopic" is significant only on VAX. */ #pragma extern_model save #pragma extern_model strict_refdef "LIB$INITIALIZ" 2, nopic, nowrt -const int spare[8] = {0}; +const int spare[8] = { 0 }; #pragma extern_model strict_refdef "LIB$INITIALIZE" 2, nopic, nowrt -void (*const x_decc_init)() = decc_init; +void (* const x_decc_init)() = decc_init; #pragma extern_model restore /* Fake reference to ensure loading the LIB$INITIALIZE PSECT. */ #pragma extern_model save int LIB$INITIALIZE(void); #pragma extern_model strict_refdef -int dmy_lib$initialize = (int) LIB$INITIALIZE; +int dmy_lib$initialize = (int)LIB$INITIALIZE; #pragma extern_model restore #pragma standard diff --git a/src/tool_vms.h b/src/tool_vms.h index 3da816cf6735..3519628fc121 100644 --- a/src/tool_vms.h +++ b/src/tool_vms.h @@ -40,8 +40,9 @@ void vms_special_exit(int code, int vms_show); #undef exit #define exit(__code) vms_special_exit((__code), (0)) -#define VMS_STS(c,f,e,s) (((c&0xF)<<28)|((f&0xFFF)<<16)|((e&0x1FFF)<3)|(s&7)) -#define VMSSTS_HIDE VMS_STS(1,0,0,0) +#define VMS_STS(c, f, e, s) \ + (((c & 0xF) << 28) | ((f & 0xFFF) << 16) | ((e & 0x1FFF) < 3) | (s & 7)) +#define VMSSTS_HIDE VMS_STS(1, 0, 0, 0) #endif /* __VMS */ diff --git a/src/tool_writeout.c b/src/tool_writeout.c index f846add4e311..358c7b39b3f9 100644 --- a/src/tool_writeout.c +++ b/src/tool_writeout.c @@ -49,12 +49,12 @@ struct httpmap { }; static const struct httpmap http_version[] = { - { "0", CURL_HTTP_VERSION_NONE}, - { "1", CURL_HTTP_VERSION_1_0}, - { "1.1", CURL_HTTP_VERSION_1_1}, - { "2", CURL_HTTP_VERSION_2}, - { "3", CURL_HTTP_VERSION_3}, - { NULL, 0} /* end of list */ + { "0", CURL_HTTP_VERSION_NONE }, + { "1", CURL_HTTP_VERSION_1_0 }, + { "1.1", CURL_HTTP_VERSION_1_1 }, + { "2", CURL_HTTP_VERSION_2 }, + { "3", CURL_HTTP_VERSION_3 }, + { NULL, 0 } /* end of list */ }; /* The designated write function should be the same as the CURLINFO return type @@ -68,87 +68,90 @@ static const struct httpmap http_version[] = { Variable names MUST be in alphabetical order. */ static const struct writeoutvar variables[] = { - {"certs", VAR_CERT, CURLINFO_NONE, writeString}, - {"conn_id", VAR_CONN_ID, CURLINFO_CONN_ID, writeOffset}, - {"content_type", VAR_CONTENT_TYPE, CURLINFO_CONTENT_TYPE, writeString}, - {"errormsg", VAR_ERRORMSG, CURLINFO_NONE, writeString}, - {"exitcode", VAR_EXITCODE, CURLINFO_NONE, writeLong}, - {"filename_effective", VAR_EFFECTIVE_FILENAME, CURLINFO_NONE, writeString}, - {"ftp_entry_path", VAR_FTP_ENTRY_PATH, CURLINFO_FTP_ENTRY_PATH, writeString}, - {"header_json", VAR_HEADER_JSON, CURLINFO_NONE, NULL}, - {"http_code", VAR_HTTP_CODE, CURLINFO_RESPONSE_CODE, writeLong}, - {"http_connect", VAR_HTTP_CODE_PROXY, CURLINFO_HTTP_CONNECTCODE, writeLong}, - {"http_version", VAR_HTTP_VERSION, CURLINFO_HTTP_VERSION, writeString}, - {"json", VAR_JSON, CURLINFO_NONE, NULL}, - {"local_ip", VAR_LOCAL_IP, CURLINFO_LOCAL_IP, writeString}, - {"local_port", VAR_LOCAL_PORT, CURLINFO_LOCAL_PORT, writeLong}, - {"method", VAR_EFFECTIVE_METHOD, CURLINFO_EFFECTIVE_METHOD, writeString}, - {"num_certs", VAR_NUM_CERTS, CURLINFO_NONE, writeLong}, - {"num_connects", VAR_NUM_CONNECTS, CURLINFO_NUM_CONNECTS, writeLong}, - {"num_headers", VAR_NUM_HEADERS, CURLINFO_NONE, writeLong}, - {"num_redirects", VAR_REDIRECT_COUNT, CURLINFO_REDIRECT_COUNT, writeLong}, - {"num_retries", VAR_NUM_RETRY, CURLINFO_NONE, writeLong}, - {"onerror", VAR_ONERROR, CURLINFO_NONE, NULL}, - {"proxy_ssl_verify_result", VAR_PROXY_SSL_VERIFY_RESULT, - CURLINFO_PROXY_SSL_VERIFYRESULT, writeLong}, - {"proxy_used", VAR_PROXY_USED, CURLINFO_USED_PROXY, writeLong}, - {"redirect_url", VAR_REDIRECT_URL, CURLINFO_REDIRECT_URL, writeString}, - {"referer", VAR_REFERER, CURLINFO_REFERER, writeString}, - {"remote_ip", VAR_PRIMARY_IP, CURLINFO_PRIMARY_IP, writeString}, - {"remote_port", VAR_PRIMARY_PORT, CURLINFO_PRIMARY_PORT, writeLong}, - {"response_code", VAR_HTTP_CODE, CURLINFO_RESPONSE_CODE, writeLong}, - {"scheme", VAR_SCHEME, CURLINFO_SCHEME, writeString}, - {"size_download", VAR_SIZE_DOWNLOAD, CURLINFO_SIZE_DOWNLOAD_T, writeOffset}, - {"size_header", VAR_HEADER_SIZE, CURLINFO_HEADER_SIZE, writeLong}, - {"size_request", VAR_REQUEST_SIZE, CURLINFO_REQUEST_SIZE, writeLong}, - {"size_upload", VAR_SIZE_UPLOAD, CURLINFO_SIZE_UPLOAD_T, writeOffset}, - {"speed_download", VAR_SPEED_DOWNLOAD, CURLINFO_SPEED_DOWNLOAD_T, - writeOffset}, - {"speed_upload", VAR_SPEED_UPLOAD, CURLINFO_SPEED_UPLOAD_T, writeOffset}, - {"ssl_verify_result", VAR_SSL_VERIFY_RESULT, CURLINFO_SSL_VERIFYRESULT, - writeLong}, - {"stderr", VAR_STDERR, CURLINFO_NONE, NULL}, - {"stdout", VAR_STDOUT, CURLINFO_NONE, NULL}, - {"time_appconnect", VAR_APPCONNECT_TIME, CURLINFO_APPCONNECT_TIME_T, - writeTime}, - {"time_connect", VAR_CONNECT_TIME, CURLINFO_CONNECT_TIME_T, writeTime}, - {"time_namelookup", VAR_NAMELOOKUP_TIME, CURLINFO_NAMELOOKUP_TIME_T, - writeTime}, - {"time_posttransfer", VAR_POSTTRANSFER_TIME, CURLINFO_POSTTRANSFER_TIME_T, - writeTime}, - {"time_pretransfer", VAR_PRETRANSFER_TIME, CURLINFO_PRETRANSFER_TIME_T, - writeTime}, - {"time_queue", VAR_QUEUE_TIME, CURLINFO_QUEUE_TIME_T, writeTime}, - {"time_redirect", VAR_REDIRECT_TIME, CURLINFO_REDIRECT_TIME_T, writeTime}, - {"time_starttransfer", VAR_STARTTRANSFER_TIME, CURLINFO_STARTTRANSFER_TIME_T, - writeTime}, - {"time_total", VAR_TOTAL_TIME, CURLINFO_TOTAL_TIME_T, writeTime}, - {"tls_earlydata", VAR_TLS_EARLYDATA_SENT, CURLINFO_EARLYDATA_SENT_T, - writeOffset}, - {"url", VAR_INPUT_URL, CURLINFO_NONE, writeString}, - {"url.fragment", VAR_INPUT_URLFRAGMENT, CURLINFO_NONE, writeString}, - {"url.host", VAR_INPUT_URLHOST, CURLINFO_NONE, writeString}, - {"url.options", VAR_INPUT_URLOPTIONS, CURLINFO_NONE, writeString}, - {"url.password", VAR_INPUT_URLPASSWORD, CURLINFO_NONE, writeString}, - {"url.path", VAR_INPUT_URLPATH, CURLINFO_NONE, writeString}, - {"url.port", VAR_INPUT_URLPORT, CURLINFO_NONE, writeString}, - {"url.query", VAR_INPUT_URLQUERY, CURLINFO_NONE, writeString}, - {"url.scheme", VAR_INPUT_URLSCHEME, CURLINFO_NONE, writeString}, - {"url.user", VAR_INPUT_URLUSER, CURLINFO_NONE, writeString}, - {"url.zoneid", VAR_INPUT_URLZONEID, CURLINFO_NONE, writeString}, - {"url_effective", VAR_EFFECTIVE_URL, CURLINFO_EFFECTIVE_URL, writeString}, - {"urle.fragment", VAR_INPUT_URLEFRAGMENT, CURLINFO_NONE, writeString}, - {"urle.host", VAR_INPUT_URLEHOST, CURLINFO_NONE, writeString}, - {"urle.options", VAR_INPUT_URLEOPTIONS, CURLINFO_NONE, writeString}, - {"urle.password", VAR_INPUT_URLEPASSWORD, CURLINFO_NONE, writeString}, - {"urle.path", VAR_INPUT_URLEPATH, CURLINFO_NONE, writeString}, - {"urle.port", VAR_INPUT_URLEPORT, CURLINFO_NONE, writeString}, - {"urle.query", VAR_INPUT_URLEQUERY, CURLINFO_NONE, writeString}, - {"urle.scheme", VAR_INPUT_URLESCHEME, CURLINFO_NONE, writeString}, - {"urle.user", VAR_INPUT_URLEUSER, CURLINFO_NONE, writeString}, - {"urle.zoneid", VAR_INPUT_URLEZONEID, CURLINFO_NONE, writeString}, - {"urlnum", VAR_URLNUM, CURLINFO_NONE, writeOffset}, - {"xfer_id", VAR_EASY_ID, CURLINFO_XFER_ID, writeOffset} + { "certs", VAR_CERT, CURLINFO_NONE, writeString }, + { "conn_id", VAR_CONN_ID, CURLINFO_CONN_ID, writeOffset }, + { "content_type", VAR_CONTENT_TYPE, CURLINFO_CONTENT_TYPE, writeString }, + { "errormsg", VAR_ERRORMSG, CURLINFO_NONE, writeString }, + { "exitcode", VAR_EXITCODE, CURLINFO_NONE, writeLong }, + { "filename_effective", VAR_EFFECTIVE_FILENAME, CURLINFO_NONE, writeString }, + { "ftp_entry_path", VAR_FTP_ENTRY_PATH, CURLINFO_FTP_ENTRY_PATH, + writeString }, + { "header_json", VAR_HEADER_JSON, CURLINFO_NONE, NULL }, + { "http_code", VAR_HTTP_CODE, CURLINFO_RESPONSE_CODE, writeLong }, + { "http_connect", VAR_HTTP_CODE_PROXY, CURLINFO_HTTP_CONNECTCODE, + writeLong }, + { "http_version", VAR_HTTP_VERSION, CURLINFO_HTTP_VERSION, writeString }, + { "json", VAR_JSON, CURLINFO_NONE, NULL }, + { "local_ip", VAR_LOCAL_IP, CURLINFO_LOCAL_IP, writeString }, + { "local_port", VAR_LOCAL_PORT, CURLINFO_LOCAL_PORT, writeLong }, + { "method", VAR_EFFECTIVE_METHOD, CURLINFO_EFFECTIVE_METHOD, writeString }, + { "num_certs", VAR_NUM_CERTS, CURLINFO_NONE, writeLong }, + { "num_connects", VAR_NUM_CONNECTS, CURLINFO_NUM_CONNECTS, writeLong }, + { "num_headers", VAR_NUM_HEADERS, CURLINFO_NONE, writeLong }, + { "num_redirects", VAR_REDIRECT_COUNT, CURLINFO_REDIRECT_COUNT, writeLong }, + { "num_retries", VAR_NUM_RETRY, CURLINFO_NONE, writeLong }, + { "onerror", VAR_ONERROR, CURLINFO_NONE, NULL }, + { "proxy_ssl_verify_result", VAR_PROXY_SSL_VERIFY_RESULT, + CURLINFO_PROXY_SSL_VERIFYRESULT, writeLong }, + { "proxy_used", VAR_PROXY_USED, CURLINFO_USED_PROXY, writeLong }, + { "redirect_url", VAR_REDIRECT_URL, CURLINFO_REDIRECT_URL, writeString }, + { "referer", VAR_REFERER, CURLINFO_REFERER, writeString }, + { "remote_ip", VAR_PRIMARY_IP, CURLINFO_PRIMARY_IP, writeString }, + { "remote_port", VAR_PRIMARY_PORT, CURLINFO_PRIMARY_PORT, writeLong }, + { "response_code", VAR_HTTP_CODE, CURLINFO_RESPONSE_CODE, writeLong }, + { "scheme", VAR_SCHEME, CURLINFO_SCHEME, writeString }, + { "size_download", VAR_SIZE_DOWNLOAD, CURLINFO_SIZE_DOWNLOAD_T, + writeOffset }, + { "size_header", VAR_HEADER_SIZE, CURLINFO_HEADER_SIZE, writeLong }, + { "size_request", VAR_REQUEST_SIZE, CURLINFO_REQUEST_SIZE, writeLong }, + { "size_upload", VAR_SIZE_UPLOAD, CURLINFO_SIZE_UPLOAD_T, writeOffset }, + { "speed_download", VAR_SPEED_DOWNLOAD, CURLINFO_SPEED_DOWNLOAD_T, + writeOffset }, + { "speed_upload", VAR_SPEED_UPLOAD, CURLINFO_SPEED_UPLOAD_T, writeOffset }, + { "ssl_verify_result", VAR_SSL_VERIFY_RESULT, CURLINFO_SSL_VERIFYRESULT, + writeLong }, + { "stderr", VAR_STDERR, CURLINFO_NONE, NULL }, + { "stdout", VAR_STDOUT, CURLINFO_NONE, NULL }, + { "time_appconnect", VAR_APPCONNECT_TIME, CURLINFO_APPCONNECT_TIME_T, + writeTime }, + { "time_connect", VAR_CONNECT_TIME, CURLINFO_CONNECT_TIME_T, writeTime }, + { "time_namelookup", VAR_NAMELOOKUP_TIME, CURLINFO_NAMELOOKUP_TIME_T, + writeTime }, + { "time_posttransfer", VAR_POSTTRANSFER_TIME, CURLINFO_POSTTRANSFER_TIME_T, + writeTime }, + { "time_pretransfer", VAR_PRETRANSFER_TIME, CURLINFO_PRETRANSFER_TIME_T, + writeTime }, + { "time_queue", VAR_QUEUE_TIME, CURLINFO_QUEUE_TIME_T, writeTime }, + { "time_redirect", VAR_REDIRECT_TIME, CURLINFO_REDIRECT_TIME_T, writeTime }, + { "time_starttransfer", VAR_STARTTRANSFER_TIME, + CURLINFO_STARTTRANSFER_TIME_T, writeTime }, + { "time_total", VAR_TOTAL_TIME, CURLINFO_TOTAL_TIME_T, writeTime }, + { "tls_earlydata", VAR_TLS_EARLYDATA_SENT, CURLINFO_EARLYDATA_SENT_T, + writeOffset }, + { "url", VAR_INPUT_URL, CURLINFO_NONE, writeString }, + { "url.fragment", VAR_INPUT_URLFRAGMENT, CURLINFO_NONE, writeString }, + { "url.host", VAR_INPUT_URLHOST, CURLINFO_NONE, writeString }, + { "url.options", VAR_INPUT_URLOPTIONS, CURLINFO_NONE, writeString }, + { "url.password", VAR_INPUT_URLPASSWORD, CURLINFO_NONE, writeString }, + { "url.path", VAR_INPUT_URLPATH, CURLINFO_NONE, writeString }, + { "url.port", VAR_INPUT_URLPORT, CURLINFO_NONE, writeString }, + { "url.query", VAR_INPUT_URLQUERY, CURLINFO_NONE, writeString }, + { "url.scheme", VAR_INPUT_URLSCHEME, CURLINFO_NONE, writeString }, + { "url.user", VAR_INPUT_URLUSER, CURLINFO_NONE, writeString }, + { "url.zoneid", VAR_INPUT_URLZONEID, CURLINFO_NONE, writeString }, + { "url_effective", VAR_EFFECTIVE_URL, CURLINFO_EFFECTIVE_URL, writeString }, + { "urle.fragment", VAR_INPUT_URLEFRAGMENT, CURLINFO_NONE, writeString }, + { "urle.host", VAR_INPUT_URLEHOST, CURLINFO_NONE, writeString }, + { "urle.options", VAR_INPUT_URLEOPTIONS, CURLINFO_NONE, writeString }, + { "urle.password", VAR_INPUT_URLEPASSWORD, CURLINFO_NONE, writeString }, + { "urle.path", VAR_INPUT_URLEPATH, CURLINFO_NONE, writeString }, + { "urle.port", VAR_INPUT_URLEPORT, CURLINFO_NONE, writeString }, + { "urle.query", VAR_INPUT_URLEQUERY, CURLINFO_NONE, writeString }, + { "urle.scheme", VAR_INPUT_URLESCHEME, CURLINFO_NONE, writeString }, + { "urle.user", VAR_INPUT_URLEUSER, CURLINFO_NONE, writeString }, + { "urle.zoneid", VAR_INPUT_URLEZONEID, CURLINFO_NONE, writeString }, + { "urlnum", VAR_URLNUM, CURLINFO_NONE, writeOffset }, + { "xfer_id", VAR_EASY_ID, CURLINFO_XFER_ID, writeOffset } }; static int writeTime(FILE *stream, const struct writeoutvar *wovar, @@ -254,7 +257,7 @@ static int urlpart(struct per_transfer *per, writeoutid vid, } } if(!rc && curl_url_set(uh, CURLUPART_URL, url, - CURLU_GUESS_SCHEME|CURLU_NON_SUPPORT_SCHEME)) + CURLU_GUESS_SCHEME | CURLU_NON_SUPPORT_SCHEME)) rc = 2; if(!rc && curl_url_get(uh, cpart, &part, CURLU_DEFAULT_PORT)) @@ -286,7 +289,7 @@ static int writeString(FILE *stream, const struct writeoutvar *wovar, const char *strinfo = NULL; const char *freestr = NULL; struct dynbuf buf; - curlx_dyn_init(&buf, 256*1024); + curlx_dyn_init(&buf, 256 * 1024); DEBUGASSERT(wovar->writefunc == writeString); @@ -337,7 +340,7 @@ static int writeString(FILE *stream, const struct writeoutvar *wovar, len = curlx_dyn_len(&buf); if(len) { char *ptr = curlx_dyn_ptr(&buf); - if(ptr[len -1] != '\n') { + if(ptr[len - 1] != '\n') { /* add a newline to make things look better */ if(curlx_dyn_addn(&buf, "\n", 1)) { error = TRUE; @@ -527,8 +530,7 @@ static int writeOffset(FILE *stream, const struct writeoutvar *wovar, return 1; /* return 1 if anything was written */ } -static int -matchvar(const void *m1, const void *m2) +static int matchvar(const void *m1, const void *m2) { const struct writeoutvar *v1 = m1; const struct writeoutvar *v2 = m2; diff --git a/src/tool_writeout_json.c b/src/tool_writeout_json.c index f3175edf9502..ee7dda2e9cc9 100644 --- a/src/tool_writeout_json.c +++ b/src/tool_writeout_json.c @@ -143,8 +143,7 @@ void headerJSON(FILE *stream, struct per_transfer *per) if(++i >= a) break; fputc(',', stream); - if(curl_easy_header(per->curl, name, i, CURLH_HEADER, - -1, &header)) + if(curl_easy_header(per->curl, name, i, CURLH_HEADER, -1, &header)) break; } while(1); fputc(']', stream); diff --git a/src/tool_xattr.h b/src/tool_xattr.h index 31301b3b0616..6720ccb2bd9a 100644 --- a/src/tool_xattr.h +++ b/src/tool_xattr.h @@ -29,7 +29,7 @@ # include /* header from libc, not from libattr */ # define USE_XATTR #elif (defined(__FreeBSD_version) && (__FreeBSD_version > 500000)) || \ - defined(__MidnightBSD_version) + defined(__MidnightBSD_version) # include # include # define USE_XATTR @@ -43,7 +43,7 @@ UNITTEST char *stripcredentials(const char *url); #endif #else -#define fwrite_xattr(a,b,c) 0 +#define fwrite_xattr(a, b, c) 0 #endif #endif /* HEADER_CURL_TOOL_XATTR_H */ diff --git a/src/var.c b/src/var.c index 08269e1db704..e224bf01d549 100644 --- a/src/var.c +++ b/src/var.c @@ -35,7 +35,7 @@ #include "var.h" #define MAX_EXPAND_CONTENT 10000000 -#define MAX_VAR_LEN 128 /* max length of a name */ +#define MAX_VAR_LEN 128 /* max length of a name */ /* free everything */ void varcleanup(void) @@ -53,8 +53,7 @@ static const struct tool_var *varcontent(const char *name, size_t nlen) { struct tool_var *list = global->variables; while(list) { - if((strlen(list->name) == nlen) && - !strncmp(name, list->name, nlen)) { + if((strlen(list->name) == nlen) && !strncmp(name, list->name, nlen)) { return list; } list = list->next; @@ -63,18 +62,18 @@ static const struct tool_var *varcontent(const char *name, size_t nlen) } #define ENDOFFUNC(x) (((x) == '}') || ((x) == ':')) -#define FUNCMATCH(ptr,name,len) \ +#define FUNCMATCH(ptr, name, len) \ (!strncmp(ptr, name, len) && ENDOFFUNC(ptr[len])) -#define FUNC_TRIM "trim" -#define FUNC_TRIM_LEN (sizeof(FUNC_TRIM) - 1) -#define FUNC_JSON "json" -#define FUNC_JSON_LEN (sizeof(FUNC_JSON) - 1) -#define FUNC_URL "url" -#define FUNC_URL_LEN (sizeof(FUNC_URL) - 1) -#define FUNC_B64 "b64" -#define FUNC_B64_LEN (sizeof(FUNC_B64) - 1) -#define FUNC_64DEC "64dec" /* base64 decode */ +#define FUNC_TRIM "trim" +#define FUNC_TRIM_LEN (sizeof(FUNC_TRIM) - 1) +#define FUNC_JSON "json" +#define FUNC_JSON_LEN (sizeof(FUNC_JSON) - 1) +#define FUNC_URL "url" +#define FUNC_URL_LEN (sizeof(FUNC_URL) - 1) +#define FUNC_B64 "b64" +#define FUNC_B64_LEN (sizeof(FUNC_B64) - 1) +#define FUNC_64DEC "64dec" /* base64 decode */ #define FUNC_64DEC_LEN (sizeof(FUNC_64DEC) - 1) static ParameterError varfunc(char *c, /* content */ @@ -105,7 +104,7 @@ static ParameterError varfunc(char *c, /* content */ c++; len--; } - while(len && ISSPACE(c[len-1])) + while(len && ISSPACE(c[len - 1])) len--; } /* put it in the output */ @@ -208,8 +207,7 @@ static ParameterError varfunc(char *c, /* content */ return err; } -ParameterError varexpand(const char *line, struct dynbuf *out, - bool *replaced) +ParameterError varexpand(const char *line, struct dynbuf *out, bool *replaced) { CURLcode result; char *envp; @@ -274,13 +272,12 @@ ParameterError varexpand(const char *line, struct dynbuf *out, name[nlen] = 0; /* verify that the name looks sensible */ - for(i = 0; (i < nlen) && - (ISALNUM(name[i]) || (name[i] == '_')); i++); + for(i = 0; (i < nlen) && (ISALNUM(name[i]) || (name[i] == '_')); i++) + ; if(i != nlen) { warnf("bad variable name: %s", name); /* insert the text as-is since this is not an env variable */ - result = curlx_dyn_addn(out, envp - prefix, - clp - envp + prefix + 2); + result = curlx_dyn_addn(out, envp - prefix, clp - envp + prefix + 2); if(result) return PARAM_NO_MEM; } diff --git a/src/var.h b/src/var.h index 4f1361cf1eab..40defea8ace1 100644 --- a/src/var.h +++ b/src/var.h @@ -34,8 +34,7 @@ struct tool_var { }; ParameterError setvariable(const char *input); -ParameterError varexpand(const char *line, struct dynbuf *out, - bool *replaced); +ParameterError varexpand(const char *line, struct dynbuf *out, bool *replaced); /* free everything */ void varcleanup(void); diff --git a/tests/test1486.pl b/tests/test1486.pl index 05006ebc63f5..79f6a856be48 100755 --- a/tests/test1486.pl +++ b/tests/test1486.pl @@ -45,7 +45,7 @@ sub getsrcvars { if($_ =~ /^}/) { last; } - if($_ =~ /^ \{\"([^\"]*)/) { + if($_ =~ /^ \{ \"([^\"]*)/) { my $var = $1; $insrc{$var} = $srccount++; } From 004f41c186becfd0bae1e5e456ba1842f0db7d9e Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Tue, 2 Dec 2025 05:05:36 +0100 Subject: [PATCH 173/415] tests: add `%AMP` macro, use it in two tests To allow replacing `&` characters in `tests/data/test*` files for XML-compliance. Also: - document `%GT`, `%LT` Follow-up to de49cc89abc917cb4f273ebea8c6fb584d097de2 #19470 Closes #19824 --- docs/tests/FILEFORMAT.md | 8 ++++++++ tests/data/test1524 | 7 +++---- tests/data/test45 | 7 +++---- tests/testutil.pm | 1 + 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/docs/tests/FILEFORMAT.md b/docs/tests/FILEFORMAT.md index 1f3aa78991b8..90a249fac2d2 100644 --- a/docs/tests/FILEFORMAT.md +++ b/docs/tests/FILEFORMAT.md @@ -88,6 +88,14 @@ lines: %SP - space %TAB - horizontal tab +## Special characters + +Macros to help keep data files XML-compliant: + + %AMP - Ampersand: `&` + %GT - Greater-than sign: `>` + %LT - Less-than sign: `<` + ## Insert capped epoch days Mostly to test capped cookie expire dates: `%days[NUM]` inserts the number of diff --git a/tests/data/test1524 b/tests/data/test1524 index fcfd9f4c0001..8674e7660b07 100644 --- a/tests/data/test1524 +++ b/tests/data/test1524 @@ -4,7 +4,6 @@ HTTP HTTP PUT followlocation -notxml # @@ -12,7 +11,7 @@ notxml HTTP/1.1 303 OK swsclose -Location: moo.html&testcase=/%TESTNUMBER0002 +Location: moo.html%AMPtestcase=/%TESTNUMBER0002 Connection: close @@ -25,7 +24,7 @@ body HTTP/1.1 303 OK swsclose -Location: moo.html&testcase=/%TESTNUMBER0002 +Location: moo.html%AMPtestcase=/%TESTNUMBER0002 Connection: close HTTP/1.1 200 OK swsclose @@ -64,7 +63,7 @@ Accept: */* Content-Length: 4 moo -GET /blah/moo.html&testcase=/%TESTNUMBER0002 HTTP/1.1 +GET /blah/moo.html%AMPtestcase=/%TESTNUMBER0002 HTTP/1.1 Host: %HOSTIP:%HTTPPORT User-Agent: curl/%VERSION Accept: */* diff --git a/tests/data/test45 b/tests/data/test45 index 3d4df02f1332..f9b6dcc6db92 100644 --- a/tests/data/test45 +++ b/tests/data/test45 @@ -4,7 +4,6 @@ HTTP HTTP GET followlocation -notxml # Server-side @@ -13,7 +12,7 @@ notxml HTTP/1.1 301 This is a weirdo text message swsclose Date: Tue, 09 Nov 2010 14:49:00 GMT Server: test-server/fake -Location: data.cgi?moo=http://&/%TESTNUMBER0002 +Location: data.cgi?moo=http://%AMP/%TESTNUMBER0002 Connection: close This server reply is for testing a simple Location: following @@ -32,7 +31,7 @@ If this is received, the location following worked HTTP/1.1 301 This is a weirdo text message swsclose Date: Tue, 09 Nov 2010 14:49:00 GMT Server: test-server/fake -Location: data.cgi?moo=http://&/%TESTNUMBER0002 +Location: data.cgi?moo=http://%AMP/%TESTNUMBER0002 Connection: close HTTP/1.1 200 Followed here fine swsclose @@ -66,7 +65,7 @@ Host: %HOSTIP:%HTTPPORT User-Agent: curl/%VERSION Accept: */* -GET /want/data.cgi?moo=http://&/%TESTNUMBER0002 HTTP/1.1 +GET /want/data.cgi?moo=http://%AMP/%TESTNUMBER0002 HTTP/1.1 Host: %HOSTIP:%HTTPPORT User-Agent: curl/%VERSION Accept: */* diff --git a/tests/testutil.pm b/tests/testutil.pm index 7e2b279f07a0..4666770f072d 100644 --- a/tests/testutil.pm +++ b/tests/testutil.pm @@ -158,6 +158,7 @@ sub subbase64 { $$thing =~ s/%CR/\r/g; # carriage return aka \r aka 0x0d $$thing =~ s/%LT//g; + $$thing =~ s/%AMP/&/g; # include a file $$thing =~ s/%include ([^%]*)%[\n\r]+/includefile($1, 0)/ge; From 276a4af4741c7ac5f4e24b22458146ebab049dcd Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Wed, 3 Dec 2025 17:22:37 +0100 Subject: [PATCH 174/415] test787: fix possible typo `&` -> `%` in curl option They are close on the keyboard and don't affect test results. To make this test XML-compliant. Ref: #14479 Follow-up to 40c264db617d025ca5053bc0964a185d11101301 #15739 Closes #19826 --- tests/data/test787 | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/data/test787 b/tests/data/test787 index e95a18d17bd8..47b2effbde10 100644 --- a/tests/data/test787 +++ b/tests/data/test787 @@ -3,7 +3,6 @@ HTTP --variable -notxml @@ -22,7 +21,7 @@ http --variable with a file byte range, bad range -http://%HOSTIP:%HTTPPORT/%TESTNUMBER --variable "name[15-14]@&LOGDIR/fooo" --expand-data '{{name}}' +http://%HOSTIP:%HTTPPORT/%TESTNUMBER --variable "name[15-14]@%LOGDIR/fooo" --expand-data '{{name}}' From e8a4068e6868424d83a3394da4810c93a43c070a Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 4 Dec 2025 08:45:55 +0100 Subject: [PATCH 175/415] docs: clarify how to do unix domain sockets with SOCKS proxy Ref: #19825 Closes #19829 --- docs/cmdline-opts/socks4.md | 6 ++++-- docs/cmdline-opts/socks4a.md | 6 ++++-- docs/cmdline-opts/socks5-hostname.md | 6 ++++-- docs/cmdline-opts/socks5.md | 7 +++++-- docs/libcurl/opts/CURLOPT_PROXY.md | 5 +++-- 5 files changed, 20 insertions(+), 10 deletions(-) diff --git a/docs/cmdline-opts/socks4.md b/docs/cmdline-opts/socks4.md index 8e92d5930cb3..59ec172b8d86 100644 --- a/docs/cmdline-opts/socks4.md +++ b/docs/cmdline-opts/socks4.md @@ -7,6 +7,7 @@ Help: SOCKS4 proxy on given host + port Added: 7.15.2 Category: proxy Multi: single +Mutexed: proxy socks4a socks5 socks5-hostname See-also: - socks4a - socks5 @@ -21,8 +22,9 @@ Use the specified SOCKS4 proxy. If the port number is not specified, it is assumed at port 1080. Using this socket type makes curl resolve the hostname and pass the address on to the proxy. -To specify proxy on a Unix domain socket, use localhost for host, e.g. -`socks4://localhost/path/to/socket.sock` +To specify the proxy on a Unix domain socket, use localhost for host and +append the absolute path to the domain socket. For example: +`socks4://localhost/path/to/socket.sock` (the scheme may be omitted). This option overrides any previous use of --proxy, as they are mutually exclusive. diff --git a/docs/cmdline-opts/socks4a.md b/docs/cmdline-opts/socks4a.md index 04d60b81b66d..9e451cf7b063 100644 --- a/docs/cmdline-opts/socks4a.md +++ b/docs/cmdline-opts/socks4a.md @@ -7,6 +7,7 @@ Help: SOCKS4a proxy on given host + port Added: 7.18.0 Category: proxy Multi: single +Mutexed: proxy socks4 socks5 socks5-hostname See-also: - socks4 - socks5 @@ -20,8 +21,9 @@ Example: Use the specified SOCKS4a proxy. If the port number is not specified, it is assumed at port 1080. This asks the proxy to resolve the hostname. -To specify proxy on a Unix domain socket, use localhost for host, e.g. -`socks4a://localhost/path/to/socket.sock` +To specify the proxy on a Unix domain socket, use localhost for host and +append the absolute path to the domain socket. For example: +`socks4a://localhost/path/to/socket.sock` (the scheme may be omitted). This option overrides any previous use of --proxy, as they are mutually exclusive. diff --git a/docs/cmdline-opts/socks5-hostname.md b/docs/cmdline-opts/socks5-hostname.md index 0ea2ed739fb9..b558248a78b9 100644 --- a/docs/cmdline-opts/socks5-hostname.md +++ b/docs/cmdline-opts/socks5-hostname.md @@ -7,6 +7,7 @@ Help: SOCKS5 proxy, pass hostname to proxy Added: 7.18.0 Category: proxy Multi: single +Mutexed: proxy socks4 socks4a socks5 See-also: - socks5 - socks4a @@ -19,8 +20,9 @@ Example: Use the specified SOCKS5 proxy (and let the proxy resolve the hostname). If the port number is not specified, it is assumed at port 1080. -To specify proxy on a Unix domain socket, use localhost for host, e.g. -`socks5h://localhost/path/to/socket.sock` +To specify the proxy on a Unix domain socket, use localhost for host and +append the absolute path to the domain socket. For example: +`socks5h://localhost/path/to/socket.sock` (the scheme may be omitted). This option overrides any previous use of --proxy, as they are mutually exclusive. diff --git a/docs/cmdline-opts/socks5.md b/docs/cmdline-opts/socks5.md index 4ea660d62d47..3aa65b33adda 100644 --- a/docs/cmdline-opts/socks5.md +++ b/docs/cmdline-opts/socks5.md @@ -10,8 +10,10 @@ Multi: single See-also: - socks5-hostname - socks4a +Mutexed: proxy socks4 socks4a socks5-hostname Example: - --socks5 proxy.example:7000 $URL + - --socks5 localhost/path/unix-domain $URL --- # `--socks5` @@ -19,8 +21,9 @@ Example: Use the specified SOCKS5 proxy - but resolve the hostname locally. If the port number is not specified, it is assumed at port 1080. -To specify proxy on a Unix domain socket, use localhost for host, e.g. -`socks5://localhost/path/to/socket.sock` +To specify the proxy on a Unix domain socket, use localhost for host and +append the absolute path to the domain socket. For example: +`socks5://localhost/path/to/socket.sock` (the scheme may be omitted). This option overrides any previous use of --proxy, as they are mutually exclusive. diff --git a/docs/libcurl/opts/CURLOPT_PROXY.md b/docs/libcurl/opts/CURLOPT_PROXY.md index 310e123e3db2..fca07f23f6f9 100644 --- a/docs/libcurl/opts/CURLOPT_PROXY.md +++ b/docs/libcurl/opts/CURLOPT_PROXY.md @@ -89,8 +89,9 @@ proxy. Such tunneling is activated with CURLOPT_HTTPPROXYTUNNEL(3). Setting the proxy string to "" (an empty string) explicitly disables the use of a proxy, even if there is an environment variable set for it. -Unix domain sockets are supported for socks proxies since 7.84.0. Set -localhost for the host part. e.g. socks5h://localhost/path/to/socket.sock +Unix domain sockets are supported for SOCKS proxies. Set `localhost` for the +host part and append the absolute path to the domain socket. For example: +`socks5h://localhost/path/to/socket.sock` When you set a hostname to use, do not assume that there is any particular single port number used widely for proxies. Specify it. From ff2aaed9ba6f186feb57f89fc68546759fdb6dad Mon Sep 17 00:00:00 2001 From: Georg Schulz-Allgaier Date: Wed, 3 Dec 2025 22:49:05 +0100 Subject: [PATCH 176/415] noproxy: fix ipv6 handling Closes #19828 --- lib/noproxy.c | 34 ++++++---------------- tests/unit/unit1614.c | 66 +++++++++++++++++++++---------------------- 2 files changed, 42 insertions(+), 58 deletions(-) diff --git a/lib/noproxy.c b/lib/noproxy.c index 569466fb62ec..e0d0877fdc4f 100644 --- a/lib/noproxy.c +++ b/lib/noproxy.c @@ -185,8 +185,6 @@ static bool match_ip(int type, const char *token, size_t tokenlen, ****************************************************************/ bool Curl_check_noproxy(const char *name, const char *no_proxy) { - char hostip[128]; - /* * If we do not have a hostname at all, like for example with a FILE * transfer, we have nothing to interrogate the noproxy list with. @@ -202,37 +200,23 @@ bool Curl_check_noproxy(const char *name, const char *no_proxy) if(no_proxy && no_proxy[0]) { const char *p = no_proxy; size_t namelen; + char address[16]; enum nametype type = TYPE_HOST; if(!strcmp("*", no_proxy)) return TRUE; /* NO_PROXY was specified and it was not just an asterisk */ - if(name[0] == '[') { - char *endptr; - /* IPv6 numerical address */ - endptr = strchr(name, ']'); - if(!endptr) - return FALSE; - name++; - namelen = endptr - name; - if(namelen >= sizeof(hostip)) - return FALSE; - memcpy(hostip, name, namelen); - hostip[namelen] = 0; - name = hostip; + /* Check if name is an IP address; if not, assume it being a hostname. */ + namelen = strlen(name); + if(curlx_inet_pton(AF_INET, name, &address) == 1) + type = TYPE_IPV4; + else if(curlx_inet_pton(AF_INET6, name, &address) == 1) type = TYPE_IPV6; - } else { - unsigned int address; - namelen = strlen(name); - if(curlx_inet_pton(AF_INET, name, &address) == 1) - type = TYPE_IPV4; - else { - /* ignore trailing dots in the hostname */ - if(name[namelen - 1] == '.') - namelen--; - } + /* ignore trailing dots in the hostname */ + if(name[namelen - 1] == '.') + namelen--; } while(*p) { diff --git a/tests/unit/unit1614.c b/tests/unit/unit1614.c index 675133e5adf6..7b66af843119 100644 --- a/tests/unit/unit1614.c +++ b/tests/unit/unit1614.c @@ -113,39 +113,39 @@ static CURLcode test_unit1614(const char *arg) { "192.168.1.1", "foo, bar, 192.168.0.0/24", FALSE}, { "192.168.1.1", "foo, bar, 192.168.0.0/16", TRUE}, #ifdef USE_IPV6 - { "[::1]", "foo, bar, 192.168.0.0/16", FALSE}, - { "[::1]", "foo, bar, ::1/64", TRUE}, - { "[::1]", "::1/64", TRUE}, - { "[::1]", "::1/96", TRUE}, - { "[::1]", "::1/129", FALSE}, - { "[::1]", "::1/128", TRUE}, - { "[::1]", "::1/127", TRUE}, - { "[::1]", "::1/a127", FALSE}, - { "[::1]", "::1/127a", FALSE}, - { "[::1]", "::1/ 127", FALSE}, - { "[::1]", "::1/127 ", TRUE}, - { "[::1]", "::1/126", TRUE}, - { "[::1]", "::1/125", TRUE}, - { "[::1]", "::1/124", TRUE}, - { "[::1]", "::1/123", TRUE}, - { "[::1]", "::1/122", TRUE}, - { "[2001:db8:8000::1]", "2001:db8::/65", FALSE}, - { "[2001:db8:8000::1]", "2001:db8::/66", FALSE}, - { "[2001:db8:8000::1]", "2001:db8::/67", FALSE}, - { "[2001:db8:8000::1]", "2001:db8::/68", FALSE}, - { "[2001:db8:8000::1]", "2001:db8::/69", FALSE}, - { "[2001:db8:8000::1]", "2001:db8::/70", FALSE}, - { "[2001:db8:8000::1]", "2001:db8::/71", FALSE}, - { "[2001:db8:8000::1]", "2001:db8::/72", FALSE}, - { "[2001:db8::1]", "2001:db8::/65", TRUE}, - { "[2001:db8::1]", "2001:db8::/66", TRUE}, - { "[2001:db8::1]", "2001:db8::/67", TRUE}, - { "[2001:db8::1]", "2001:db8::/68", TRUE}, - { "[2001:db8::1]", "2001:db8::/69", TRUE}, - { "[2001:db8::1]", "2001:db8::/70", TRUE}, - { "[2001:db8::1]", "2001:db8::/71", TRUE}, - { "[2001:db8::1]", "2001:db8::/72", TRUE}, - { "[::1]", "::1/129", FALSE}, + { "::1", "foo, bar, 192.168.0.0/16", FALSE}, + { "::1", "foo, bar, ::1/64", TRUE}, + { "::1", "::1/64", TRUE}, + { "::1", "::1/96", TRUE}, + { "::1", "::1/129", FALSE}, + { "::1", "::1/128", TRUE}, + { "::1", "::1/127", TRUE}, + { "::1", "::1/a127", FALSE}, + { "::1", "::1/127a", FALSE}, + { "::1", "::1/ 127", FALSE}, + { "::1", "::1/127 ", TRUE}, + { "::1", "::1/126", TRUE}, + { "::1", "::1/125", TRUE}, + { "::1", "::1/124", TRUE}, + { "::1", "::1/123", TRUE}, + { "::1", "::1/122", TRUE}, + { "2001:db8:8000::1", "2001:db8::/65", FALSE}, + { "2001:db8:8000::1", "2001:db8::/66", FALSE}, + { "2001:db8:8000::1", "2001:db8::/67", FALSE}, + { "2001:db8:8000::1", "2001:db8::/68", FALSE}, + { "2001:db8:8000::1", "2001:db8::/69", FALSE}, + { "2001:db8:8000::1", "2001:db8::/70", FALSE}, + { "2001:db8:8000::1", "2001:db8::/71", FALSE}, + { "2001:db8:8000::1", "2001:db8::/72", FALSE}, + { "2001:db8::1", "2001:db8::/65", TRUE}, + { "2001:db8::1", "2001:db8::/66", TRUE}, + { "2001:db8::1", "2001:db8::/67", TRUE}, + { "2001:db8::1", "2001:db8::/68", TRUE}, + { "2001:db8::1", "2001:db8::/69", TRUE}, + { "2001:db8::1", "2001:db8::/70", TRUE}, + { "2001:db8::1", "2001:db8::/71", TRUE}, + { "2001:db8::1", "2001:db8::/72", TRUE}, + { "::1", "::1/129", FALSE}, { "bar", "foo, bar, ::1/64", TRUE}, { "BAr", "foo, bar, ::1/64", TRUE}, { "BAr", "foo,,,,, bar, ::1/64", TRUE}, From 472bc9032374f98f48f7a2df6c644cff91fe142c Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Wed, 3 Dec 2025 04:42:02 +0100 Subject: [PATCH 177/415] runtests: make memanalyzer a Perl module (for 1.1-2x speed-up per test run) Patch #19786 removed an exception, which caused many more CI jobs to run `memanalyze.pl`. It resulted in a 10-30% (Linux), 15% (macOS), 100% (2x, on Windows) slowdown of runtest steps. It also made some jobs exceed their time limits and fail (seen with the Windows ARM64 job.) Turns out the overhead was caused by calling `memanalyze.pl` as an external process (twice per test), which in turn had to load a full Perl stack from scratch each time. Fix by converting memanalyze to a Perl modul, loaded as part of `runtests.pl`, which eliminated the overhead completely. It also sped up existing jobs where memanalyze was run for a long time, e.g. two c-ares Windows jobs, saving 4.5m per CI run. Supersedes #19819 Bug: https://github.com/curl/curl/pull/19786#issuecomment-3598679397 Follow-up to fb7033d7600dfb59de06e7af8a0d6ab2a4163578 #19786 Closes #19821 --- tests/Makefile.am | 1 + tests/memanalyze.pl | 429 +--------------------------------------- tests/memanalyzer.pm | 459 +++++++++++++++++++++++++++++++++++++++++++ tests/runtests.pl | 5 +- 4 files changed, 471 insertions(+), 423 deletions(-) create mode 100644 tests/memanalyzer.pm diff --git a/tests/Makefile.am b/tests/Makefile.am index 0371159d68d8..6c48328ae109 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -61,6 +61,7 @@ EXTRA_DIST = \ http2-server.pl \ http3-server.pl \ memanalyze.pl \ + memanalyzer.pm \ negtelnetserver.py \ nghttpx.conf \ pathhelp.pm \ diff --git a/tests/memanalyze.pl b/tests/memanalyze.pl index 2b38e5e8a424..e30b263c4128 100755 --- a/tests/memanalyze.pl +++ b/tests/memanalyze.pl @@ -22,27 +22,15 @@ # SPDX-License-Identifier: curl # ########################################################################### -# -# Example input: -# -# MEM mprintf.c:1094 malloc(32) = e5718 -# MEM mprintf.c:1103 realloc(e5718, 64) = e6118 -# MEM sendf.c:232 free(f6520) use strict; use warnings; -my $mallocs=0; -my $callocs=0; -my $reallocs=0; -my $strdups=0; -my $wcsdups=0; -my $showlimit=0; -my $sends=0; -my $recvs=0; -my $sockets=0; -my $verbose=0; -my $trace=0; +use memanalyzer; + +my $showlimit = 0; +my $verbose = 0; +my $trace = 0; while(@ARGV) { if($ARGV[0] eq "-v") { @@ -63,411 +51,10 @@ } } -my $memsum = 0; # the total number of memory allocated over the lifetime -my $maxmem = 0; # the high water mark - -sub newtotal { - my ($newtot)=@_; - # count a max here - - if($newtot > $maxmem) { - $maxmem = $newtot; - } -} - my $file = $ARGV[0] || ''; -if(! -f $file) { - print "Usage: memanalyze.pl [options] \n", - "Options:\n", - " -l memlimit failure displayed\n", - " -v Verbose\n", - " -t Trace\n"; - exit; -} - -open(my $fileh, "<", "$file"); - -if($showlimit) { - while(<$fileh>) { - if(/^LIMIT.*memlimit$/) { - print $_; - last; - } - } - close($fileh); - exit; -} - -my %sizeataddr; -my %getmem; - -my $totalmem = 0; -my $frees = 0; - -my $dup; -my $size; -my $addr; - -my %filedes; -my %getfile; - -my %fopen; -my %fopenfile; -my $openfile = 0; -my $fopens = 0; - -my %addrinfo; -my %addrinfofile; -my $addrinfos = 0; - -my $source; -my $linenum; -my $function; - -my $lnum = 0; -while(<$fileh>) { - chomp $_; - my $line = $_; - $lnum++; - if($line =~ /^BT/) { - # back-trace, ignore - } - elsif($line =~ /^LIMIT ([^ ]*):(\d*) (.*)/) { - # new memory limit test prefix - my $i = $3; - my ($source, $linenum) = ($1, $2); - if($trace && ($i =~ /([^ ]*) reached memlimit/)) { - print "LIMIT: $1 returned error at $source:$linenum\n"; - } - } - elsif($line =~ /^MEM ([^ ]*):(\d*) (.*)/) { - # generic match for the filename+linenumber - $source = $1; - $linenum = $2; - $function = $3; - - if($function =~ /free\((\(nil\)|0x([0-9a-f]*))/) { - $addr = $2; - if($1 eq "(nil)") { - ; # do nothing when free(NULL) - } - elsif(!exists $sizeataddr{$addr}) { - print "FREE ERROR: No memory allocated: $line\n"; - } - elsif(-1 == $sizeataddr{$addr}) { - print "FREE ERROR: Memory freed twice: $line\n"; - print "FREE ERROR: Previously freed at: ".$getmem{$addr}."\n"; - } - else { - $totalmem -= $sizeataddr{$addr}; - if($trace) { - print "FREE: malloc at ".$getmem{$addr}." is freed again at $source:$linenum\n"; - printf("FREE: %d bytes freed, left allocated: $totalmem bytes\n", $sizeataddr{$addr}); - } - - newtotal($totalmem); - $frees++; - - $sizeataddr{$addr}=-1; # set -1 to mark as freed - $getmem{$addr}="$source:$linenum"; - - } - } - elsif($function =~ /malloc\((\d*)\) = 0x([0-9a-f]*)/) { - $size = $1; - $addr = $2; - - if($sizeataddr{$addr} && $sizeataddr{$addr}>0) { - # this means weeeeeirdo - print "Mixed debug compile ($source:$linenum at line $lnum), rebuild curl now\n"; - print "We think $sizeataddr{$addr} bytes are already allocated at that memory address: $addr!\n"; - } - - $sizeataddr{$addr} = $size; - $totalmem += $size; - $memsum += $size; - - if($trace) { - print "MALLOC: malloc($size) at $source:$linenum", - " makes totally $totalmem bytes\n"; - } - - newtotal($totalmem); - $mallocs++; - - $getmem{$addr}="$source:$linenum"; - } - elsif($function =~ /calloc\((\d*),(\d*)\) = 0x([0-9a-f]*)/) { - $size = $1*$2; - $addr = $3; - - my $arg1 = $1; - my $arg2 = $2; - - if($sizeataddr{$addr} && $sizeataddr{$addr}>0) { - # this means weeeeeirdo - print "Mixed debug compile, rebuild curl now\n"; - } - - $sizeataddr{$addr}=$size; - $totalmem += $size; - $memsum += $size; - - if($trace) { - print "CALLOC: calloc($arg1,$arg2) at $source:$linenum", - " makes totally $totalmem bytes\n"; - } - - newtotal($totalmem); - $callocs++; - - $getmem{$addr}="$source:$linenum"; - } - elsif($function =~ /realloc\((\(nil\)|0x([0-9a-f]*)), (\d*)\) = 0x([0-9a-f]*)/) { - my ($oldaddr, $newsize, $newaddr) = ($2, $3, $4); - - if($oldaddr) { - my $oldsize = $sizeataddr{$oldaddr} ? $sizeataddr{$oldaddr} : 0; - - $totalmem -= $oldsize; - if($trace) { - printf("REALLOC: %d less bytes and ", $oldsize); - } - $sizeataddr{$oldaddr}=0; - - $getmem{$oldaddr}=""; - } - - $totalmem += $newsize; - $memsum += $newsize; - $sizeataddr{$newaddr}=$newsize; - - if($trace) { - printf("%d more bytes ($source:$linenum)\n", $newsize); - } - - newtotal($totalmem); - $reallocs++; - - $getmem{$newaddr}="$source:$linenum"; - } - elsif($function =~ /strdup\(0x([0-9a-f]*)\) \((\d*)\) = 0x([0-9a-f]*)/) { - # strdup(a5b50) (8) = df7c0 - - $dup = $1; - $size = $2; - $addr = $3; - $getmem{$addr}="$source:$linenum"; - $sizeataddr{$addr}=$size; - - $totalmem += $size; - $memsum += $size; - - if($trace) { - printf("STRDUP: $size bytes at %s, makes totally: %d bytes\n", - $getmem{$addr}, $totalmem); - } - - newtotal($totalmem); - $strdups++; - } - elsif($function =~ /wcsdup\(0x([0-9a-f]*)\) \((\d*)\) = 0x([0-9a-f]*)/) { - # wcsdup(a5b50) (8) = df7c0 - - $dup = $1; - $size = $2; - $addr = $3; - $getmem{$addr}="$source:$linenum"; - $sizeataddr{$addr}=$size; - - $totalmem += $size; - $memsum += $size; - - if($trace) { - printf("WCSDUP: $size bytes at %s, makes totally: %d bytes\n", - $getmem{$addr}, $totalmem); - } - - newtotal($totalmem); - $wcsdups++; - } - else { - print "Not recognized input line: $function\n"; - } - } - # FD url.c:1282 socket() = 5 - elsif($_ =~ /^FD ([^ ]*):(\d*) (.*)/) { - # generic match for the filename+linenumber - $source = $1; - $linenum = $2; - $function = $3; - - if($function =~ /socket\(\) = (\d*)/) { - $filedes{$1}=1; - $getfile{$1}="$source:$linenum"; - $openfile++; - $sockets++; # number of socket() calls - } - elsif($function =~ /socketpair\(\) = (\d*) (\d*)/) { - $filedes{$1}=1; - $getfile{$1}="$source:$linenum"; - $openfile++; - $filedes{$2}=1; - $getfile{$2}="$source:$linenum"; - $openfile++; - } - elsif($function =~ /accept\(\) = (\d*)/) { - $filedes{$1}=1; - $getfile{$1}="$source:$linenum"; - $openfile++; - } - elsif($function =~ /sclose\((\d*)\)/) { - if($filedes{$1} != 1) { - print "Close without open: $line\n"; - } - else { - $filedes{$1}=0; # closed now - $openfile--; - } - } - } - # FILE url.c:1282 fopen("blabla") = 0x5ddd - elsif($_ =~ /^FILE ([^ ]*):(\d*) (.*)/) { - # generic match for the filename+linenumber - $source = $1; - $linenum = $2; - $function = $3; - - if($function =~ /f[d]*open\(\"(.*)\",\"([^\"]*)\"\) = (\(nil\)|0x([0-9a-f]*))/) { - if($3 eq "(nil)") { - ; - } - else { - $fopen{$4}=1; - $fopenfile{$4}="$source:$linenum"; - $fopens++; - } - } - # fclose(0x1026c8) - elsif($function =~ /fclose\(0x([0-9a-f]*)\)/) { - if(!$fopen{$1}) { - print "fclose() without fopen(): $line\n"; - } - else { - $fopen{$1}=0; - $fopens--; - } - } - } - # GETNAME url.c:1901 getnameinfo() - elsif($_ =~ /^GETNAME ([^ ]*):(\d*) (.*)/) { - # not much to do - } - # SEND url.c:1901 send(83) = 83 - elsif($_ =~ /^SEND ([^ ]*):(\d*) (.*)/) { - $sends++; - } - # RECV url.c:1901 recv(102400) = 256 - elsif($_ =~ /^RECV ([^ ]*):(\d*) (.*)/) { - $recvs++; - } - - # ADDR url.c:1282 getaddrinfo() = 0x5ddd - elsif($_ =~ /^ADDR ([^ ]*):(\d*) (.*)/) { - # generic match for the filename+linenumber - $source = $1; - $linenum = $2; - $function = $3; - - if($function =~ /getaddrinfo\(\) = (\(nil\)|0x([0-9a-f]*))/) { - my $add = $1; - if($add eq "(nil)") { - ; - } - else { - $addrinfo{$add}=1; - $addrinfofile{$add}="$source:$linenum"; - $addrinfos++; - } - if($trace) { - printf("GETADDRINFO ($source:$linenum)\n"); - } - } - # fclose(0x1026c8) - elsif($function =~ /freeaddrinfo\((0x[0-9a-f]*)\)/) { - my $addr = $1; - if(!$addrinfo{$addr}) { - print "freeaddrinfo() without getaddrinfo(): $line\n"; - } - else { - $addrinfo{$addr}=0; - $addrinfos--; - } - if($trace) { - printf("FREEADDRINFO ($source:$linenum)\n"); - } - } - - } - else { - print "Not recognized prefix line: $line\n"; - } -} -close($fileh); - -if($totalmem) { - print "Leak detected: memory still allocated: $totalmem bytes\n"; - - for(keys %sizeataddr) { - $addr = $_; - $size = $sizeataddr{$addr}; - if($size > 0) { - print "At $addr, there is $size bytes.\n"; - print " allocated by ".$getmem{$addr}."\n"; - } - } -} - -if($openfile) { - for(keys %filedes) { - if($filedes{$_} == 1) { - print "Open file descriptor created at ".$getfile{$_}."\n"; - } - } -} - -if($fopens) { - print "Open FILE handles left at:\n"; - for(keys %fopen) { - if($fopen{$_} == 1) { - print "fopen() called at ".$fopenfile{$_}."\n"; - } - } -} - -if($addrinfos) { - print "IPv6-style name resolve data left at:\n"; - for(keys %addrinfofile) { - if($addrinfo{$_} == 1) { - print "getaddrinfo() called at ".$addrinfofile{$_}."\n"; - } - } -} - -if($verbose) { - print "Mallocs: $mallocs\n", - "Reallocs: $reallocs\n", - "Callocs: $callocs\n", - "Strdups: $strdups\n", - "Wcsdups: $wcsdups\n", - "Frees: $frees\n", - "Sends: $sends\n", - "Recvs: $recvs\n", - "Sockets: $sockets\n", - "Allocations: ".($mallocs + $callocs + $reallocs + $strdups + $wcsdups)."\n", - "Operations: ".($mallocs + $callocs + $reallocs + $strdups + $wcsdups + $sends + $recvs + $sockets)."\n"; +my @res = memanalyze($file, $verbose, $trace, $showlimit); - print "Maximum allocated: $maxmem\n"; - print "Total allocated: $memsum\n"; +for (@res) { + print $_; } diff --git a/tests/memanalyzer.pm b/tests/memanalyzer.pm new file mode 100644 index 000000000000..7dbdf7b94a91 --- /dev/null +++ b/tests/memanalyzer.pm @@ -0,0 +1,459 @@ +#!/usr/bin/env perl +#*************************************************************************** +# _ _ ____ _ +# Project ___| | | | _ \| | +# / __| | | | |_) | | +# | (__| |_| | _ <| |___ +# \___|\___/|_| \_\_____| +# +# Copyright (C) Daniel Stenberg, , et al. +# +# This software is licensed as described in the 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. +# +# SPDX-License-Identifier: curl +# +########################################################################### +# +# Example input: +# +# MEM mprintf.c:1094 malloc(32) = e5718 +# MEM mprintf.c:1103 realloc(e5718, 64) = e6118 +# MEM sendf.c:232 free(f6520) + +package memanalyzer; + +use strict; +use warnings; + +BEGIN { + use base qw(Exporter); + + our @EXPORT = qw( + memanalyze + ); +} + +my $memsum; +my $maxmem; + +sub newtotal { + my ($newtot)=@_; + # count a max here + + if($newtot > $maxmem) { + $maxmem = $newtot; + } +} + +sub memanalyze { + my ($file, $verbose, $trace, $showlimit) = @_; + my @res; + + my $mallocs = 0; + my $callocs = 0; + my $reallocs = 0; + my $strdups = 0; + my $wcsdups = 0; + my $sends = 0; + my $recvs = 0; + my $sockets = 0; + + $memsum = 0; # the total number of memory allocated over the lifetime + $maxmem = 0; # the high water mark + + open(my $fileh, "<", "$file") or return (); + + if($showlimit) { + while(<$fileh>) { + if(/^LIMIT.*memlimit$/) { + push @res, $_; + last; + } + } + close($fileh); + return @res; + } + + my %sizeataddr; + my %getmem; + + my $totalmem = 0; + my $frees = 0; + + my $dup; + my $size; + my $addr; + + my %filedes; + my %getfile; + + my %fopen; + my %fopenfile; + my $openfile = 0; + my $fopens = 0; + + my %addrinfo; + my %addrinfofile; + my $addrinfos = 0; + + my $source; + my $linenum; + my $function; + + my $lnum = 0; + + while(<$fileh>) { + chomp $_; + my $line = $_; + $lnum++; + if($line =~ /^BT/) { + # back-trace, ignore + } + elsif($line =~ /^LIMIT ([^ ]*):(\d*) (.*)/) { + # new memory limit test prefix + my $i = $3; + my ($source, $linenum) = ($1, $2); + if($trace && ($i =~ /([^ ]*) reached memlimit/)) { + push @res, "LIMIT: $1 returned error at $source:$linenum\n"; + } + } + elsif($line =~ /^MEM ([^ ]*):(\d*) (.*)/) { + # generic match for the filename+linenumber + $source = $1; + $linenum = $2; + $function = $3; + + if($function =~ /free\((\(nil\)|0x([0-9a-f]*))/) { + $addr = $2; + if($1 eq "(nil)") { + ; # do nothing when free(NULL) + } + elsif(!exists $sizeataddr{$addr}) { + push @res, "FREE ERROR: No memory allocated: $line\n"; + } + elsif(-1 == $sizeataddr{$addr}) { + push @res, "FREE ERROR: Memory freed twice: $line\n"; + push @res, "FREE ERROR: Previously freed at: $getmem{$addr}\n"; + } + else { + $totalmem -= $sizeataddr{$addr}; + if($trace) { + push @res, "FREE: malloc at $getmem{$addr} is freed again at $source:$linenum\n"; + push @res, "FREE: $sizeataddr{$addr} bytes freed, left allocated: $totalmem bytes\n"; + } + + newtotal($totalmem); + $frees++; + + $sizeataddr{$addr}=-1; # set -1 to mark as freed + $getmem{$addr}="$source:$linenum"; + + } + } + elsif($function =~ /malloc\((\d*)\) = 0x([0-9a-f]*)/) { + $size = $1; + $addr = $2; + + if($sizeataddr{$addr} && $sizeataddr{$addr}>0) { + # this means weeeeeirdo + push @res, "Mixed debug compile ($source:$linenum at line $lnum), rebuild curl now\n"; + push @res, "We think $sizeataddr{$addr} bytes are already allocated at that memory address: $addr!\n"; + } + + $sizeataddr{$addr} = $size; + $totalmem += $size; + $memsum += $size; + + if($trace) { + push @res, "MALLOC: malloc($size) at $source:$linenum makes totally $totalmem bytes\n"; + } + + newtotal($totalmem); + $mallocs++; + + $getmem{$addr}="$source:$linenum"; + } + elsif($function =~ /calloc\((\d*),(\d*)\) = 0x([0-9a-f]*)/) { + $size = $1 * $2; + $addr = $3; + + my $arg1 = $1; + my $arg2 = $2; + + if($sizeataddr{$addr} && $sizeataddr{$addr}>0) { + # this means weeeeeirdo + push @res, "Mixed debug compile, rebuild curl now\n"; + } + + $sizeataddr{$addr} = $size; + $totalmem += $size; + $memsum += $size; + + if($trace) { + push @res, "CALLOC: calloc($arg1,$arg2) at $source:$linenum makes totally $totalmem bytes\n"; + } + + newtotal($totalmem); + $callocs++; + + $getmem{$addr}="$source:$linenum"; + } + elsif($function =~ /realloc\((\(nil\)|0x([0-9a-f]*)), (\d*)\) = 0x([0-9a-f]*)/) { + my ($oldaddr, $newsize, $newaddr) = ($2, $3, $4); + my $oldsize = '-'; + + if($oldaddr) { + $oldsize = $sizeataddr{$oldaddr} ? $sizeataddr{$oldaddr} : 0; + + $totalmem -= $oldsize; + if($trace) { + } + $sizeataddr{$oldaddr} = 0; + + $getmem{$oldaddr} = ""; + } + + $totalmem += $newsize; + $memsum += $newsize; + $sizeataddr{$newaddr} = $newsize; + + if($trace) { + push @res, "REALLOC: $oldsize less bytes and $newsize more bytes ($source:$linenum)\n"; + } + + newtotal($totalmem); + $reallocs++; + + $getmem{$newaddr}="$source:$linenum"; + } + elsif($function =~ /strdup\(0x([0-9a-f]*)\) \((\d*)\) = 0x([0-9a-f]*)/) { + # strdup(a5b50) (8) = df7c0 + + $dup = $1; + $size = $2; + $addr = $3; + $getmem{$addr} = "$source:$linenum"; + $sizeataddr{$addr} = $size; + + $totalmem += $size; + $memsum += $size; + + if($trace) { + push @res, "STRDUP: $size bytes at $getmem{$addr}, makes totally: $totalmem bytes\n"; + } + + newtotal($totalmem); + $strdups++; + } + elsif($function =~ /wcsdup\(0x([0-9a-f]*)\) \((\d*)\) = 0x([0-9a-f]*)/) { + # wcsdup(a5b50) (8) = df7c0 + + $dup = $1; + $size = $2; + $addr = $3; + $getmem{$addr}="$source:$linenum"; + $sizeataddr{$addr}=$size; + + $totalmem += $size; + $memsum += $size; + + if($trace) { + push @res, "WCSDUP: $size bytes at $getmem{$addr}, makes totally: $totalmem bytes\n"; + } + + newtotal($totalmem); + $wcsdups++; + } + else { + push @res, "Not recognized input line: $function\n"; + } + } + # FD url.c:1282 socket() = 5 + elsif($_ =~ /^FD ([^ ]*):(\d*) (.*)/) { + # generic match for the filename+linenumber + $source = $1; + $linenum = $2; + $function = $3; + + if($function =~ /socket\(\) = (\d*)/) { + $filedes{$1} = 1; + $getfile{$1} = "$source:$linenum"; + $openfile++; + $sockets++; # number of socket() calls + } + elsif($function =~ /socketpair\(\) = (\d*) (\d*)/) { + $filedes{$1} = 1; + $getfile{$1} = "$source:$linenum"; + $openfile++; + $filedes{$2} = 1; + $getfile{$2} = "$source:$linenum"; + $openfile++; + } + elsif($function =~ /accept\(\) = (\d*)/) { + $filedes{$1} = 1; + $getfile{$1} = "$source:$linenum"; + $openfile++; + } + elsif($function =~ /sclose\((\d*)\)/) { + if($filedes{$1} != 1) { + push @res, "Close without open: $line\n"; + } + else { + $filedes{$1}=0; # closed now + $openfile--; + } + } + } + # FILE url.c:1282 fopen("blabla") = 0x5ddd + elsif($_ =~ /^FILE ([^ ]*):(\d*) (.*)/) { + # generic match for the filename+linenumber + $source = $1; + $linenum = $2; + $function = $3; + + if($function =~ /f[d]*open\(\"(.*)\",\"([^\"]*)\"\) = (\(nil\)|0x([0-9a-f]*))/) { + if($3 eq "(nil)") { + ; + } + else { + $fopen{$4} = 1; + $fopenfile{$4} = "$source:$linenum"; + $fopens++; + } + } + # fclose(0x1026c8) + elsif($function =~ /fclose\(0x([0-9a-f]*)\)/) { + if(!$fopen{$1}) { + push @res, "fclose() without fopen(): $line\n"; + } + else { + $fopen{$1} = 0; + $fopens--; + } + } + } + # GETNAME url.c:1901 getnameinfo() + elsif($_ =~ /^GETNAME ([^ ]*):(\d*) (.*)/) { + # not much to do + } + # SEND url.c:1901 send(83) = 83 + elsif($_ =~ /^SEND ([^ ]*):(\d*) (.*)/) { + $sends++; + } + # RECV url.c:1901 recv(102400) = 256 + elsif($_ =~ /^RECV ([^ ]*):(\d*) (.*)/) { + $recvs++; + } + + # ADDR url.c:1282 getaddrinfo() = 0x5ddd + elsif($_ =~ /^ADDR ([^ ]*):(\d*) (.*)/) { + # generic match for the filename+linenumber + $source = $1; + $linenum = $2; + $function = $3; + + if($function =~ /getaddrinfo\(\) = (\(nil\)|0x([0-9a-f]*))/) { + my $add = $1; + if($add eq "(nil)") { + ; + } + else { + $addrinfo{$add} = 1; + $addrinfofile{$add} = "$source:$linenum"; + $addrinfos++; + } + if($trace) { + push @res, "GETADDRINFO ($source:$linenum)\n"; + } + } + # fclose(0x1026c8) + elsif($function =~ /freeaddrinfo\((0x[0-9a-f]*)\)/) { + my $addr = $1; + if(!$addrinfo{$addr}) { + push @res, "freeaddrinfo() without getaddrinfo(): $line\n"; + } + else { + $addrinfo{$addr} = 0; + $addrinfos--; + } + if($trace) { + push @res, "FREEADDRINFO ($source:$linenum)\n"; + } + } + + } + else { + push @res, "Not recognized prefix line: $line\n"; + } + } + close($fileh); + + if($totalmem) { + push @res, "Leak detected: memory still allocated: $totalmem bytes\n"; + + for(keys %sizeataddr) { + $addr = $_; + $size = $sizeataddr{$addr}; + if($size > 0) { + push @res, "At $addr, there is $size bytes.\n"; + push @res, " allocated by $getmem{$addr}\n"; + } + } + } + + if($openfile) { + for(keys %filedes) { + if($filedes{$_} == 1) { + push @res, "Open file descriptor created at $getfile{$_}.\n"; + } + } + } + + if($fopens) { + push @res, "Open FILE handles left at:\n"; + for(keys %fopen) { + if($fopen{$_} == 1) { + push @res, "fopen() called at $fopenfile{$_}.\n"; + } + } + } + + if($addrinfos) { + push @res, "IPv6-style name resolve data left at:\n"; + for(keys %addrinfofile) { + if($addrinfo{$_} == 1) { + push @res, "getaddrinfo() called at $addrinfofile{$_}.\n"; + } + } + } + + if($verbose) { + push @res, + "Mallocs: $mallocs\n", + "Reallocs: $reallocs\n", + "Callocs: $callocs\n", + "Strdups: $strdups\n", + "Wcsdups: $wcsdups\n", + "Frees: $frees\n", + "Sends: $sends\n", + "Recvs: $recvs\n", + "Sockets: $sockets\n", + "Allocations: ".($mallocs + $callocs + $reallocs + $strdups + $wcsdups)."\n", + "Operations: ".($mallocs + $callocs + $reallocs + $strdups + $wcsdups + $sends + $recvs + $sockets)."\n", + "Maximum allocated: $maxmem\n", + "Total allocated: $memsum\n"; + } + + return @res; +} + +1; diff --git a/tests/runtests.pl b/tests/runtests.pl index d0455d224380..32a03446d132 100755 --- a/tests/runtests.pl +++ b/tests/runtests.pl @@ -102,6 +102,7 @@ BEGIN use globalconfig; use runner; use testutil; +use memanalyzer; my %custom_skip_reasons; @@ -1757,7 +1758,7 @@ sub singletest_check { $ok .= "-"; # problem with memory checking } else { - my @memdata=`$memanalyze "$logdir/$MEMDUMP"`; + my @memdata = memanalyze("$logdir/$MEMDUMP", 0, 0, 0); my $leak=0; for(@memdata) { if($_ ne "") { @@ -1776,7 +1777,7 @@ sub singletest_check { else { $ok .= "m"; } - my @more=`$memanalyze -v "$logdir/$MEMDUMP"`; + my @more = memanalyze("$logdir/$MEMDUMP", 1, 0, 0); my $allocs = 0; my $max = 0; for(@more) { From 608f5dd4557b449d9ece5aa193a4b89ac3760422 Mon Sep 17 00:00:00 2001 From: Theo Buehler Date: Thu, 4 Dec 2025 14:43:18 +0100 Subject: [PATCH 178/415] vtls: do not reach into ASN1_STRING OpenSSL 4 has plans to make ASN1_STRING opaque, which will break the build, so convert the code to use accessors. ASN1_STRING_length() and ASN1_STRING_type() go way back to SSLeay and ASN1_STRING_get0_data() is OpenSSL 1.1 API present in BoringSSL since foreer and also available since LibreSSL 2.7, so this should not cause compat issues with any libcrypto in a supported version of the fork family. https://github.com/openssl/openssl/issues/29117 Closes #19831 --- lib/vtls/openssl.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/vtls/openssl.c b/lib/vtls/openssl.c index 67466e6e41d5..444fbc4e0453 100644 --- a/lib/vtls/openssl.c +++ b/lib/vtls/openssl.c @@ -412,6 +412,7 @@ static CURLcode ossl_certchain(struct Curl_easy *data, SSL *ssl) for(i = 0; !result && (i < (int)numcerts); i++) { ASN1_INTEGER *num; + const unsigned char *numdata; X509 *x = sk_X509_value(sk, (ossl_valsize_t)i); EVP_PKEY *pubkey = NULL; int j; @@ -433,10 +434,11 @@ static CURLcode ossl_certchain(struct Curl_easy *data, SSL *ssl) break; num = X509_get_serialNumber(x); - if(num->type == V_ASN1_NEG_INTEGER) + if(ASN1_STRING_type(num) == V_ASN1_NEG_INTEGER) BIO_puts(mem, "-"); - for(j = 0; j < num->length; j++) - BIO_printf(mem, "%02x", num->data[j]); + numdata = ASN1_STRING_get0_data(num); + for(j = 0; j < ASN1_STRING_length(num); j++) + BIO_printf(mem, "%02x", numdata[j]); result = push_certinfo(data, mem, "Serial Number", i); if(result) break; @@ -503,8 +505,9 @@ static CURLcode ossl_certchain(struct Curl_easy *data, SSL *ssl) } if(!result && psig) { - for(j = 0; j < psig->length; j++) - BIO_printf(mem, "%02x:", psig->data[j]); + const unsigned char *psigdata = ASN1_STRING_get0_data(psig); + for(j = 0; j < ASN1_STRING_length(psig); j++) + BIO_printf(mem, "%02x:", psigdata[j]); result = push_certinfo(data, mem, "Signature", i); } From 39d1976b7f709a516e3243338ebc0443bdd8d56d Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 4 Dec 2025 00:14:20 +0100 Subject: [PATCH 179/415] ldap: call ldap_init() before setting the options Closes #19830 --- lib/ldap.c | 50 +++++++++++++++++++------------------------------- 1 file changed, 19 insertions(+), 31 deletions(-) diff --git a/lib/ldap.c b/lib/ldap.c index 63b2cbc414f6..0911a9239a2d 100644 --- a/lib/ldap.c +++ b/lib/ldap.c @@ -377,16 +377,29 @@ static CURLcode ldap_do(struct Curl_easy *data, bool *done) passwd = conn->passwd; } +#ifdef USE_WIN32_LDAP + if(ldap_ssl) + server = ldap_sslinit(host, (curl_ldap_num_t)ipquad.remote_port, 1); + else +#else + server = ldap_init(host, (curl_ldap_num_t)ipquad.remote_port); +#endif + if(!server) { + failf(data, "LDAP: cannot setup connect to %s:%u", + conn->host.dispname, ipquad.remote_port); + result = CURLE_COULDNT_CONNECT; + goto quit; + } + #ifdef LDAP_OPT_NETWORK_TIMEOUT - ldap_set_option(NULL, LDAP_OPT_NETWORK_TIMEOUT, &ldap_timeout); + ldap_set_option(server, LDAP_OPT_NETWORK_TIMEOUT, &ldap_timeout); #endif - ldap_set_option(NULL, LDAP_OPT_PROTOCOL_VERSION, &ldap_proto); + ldap_set_option(server, LDAP_OPT_PROTOCOL_VERSION, &ldap_proto); if(ldap_ssl) { #ifdef HAVE_LDAP_SSL #ifdef USE_WIN32_LDAP /* Win32 LDAP SDK does not support insecure mode without CA! */ - server = ldap_sslinit(host, (curl_ldap_num_t)ipquad.remote_port, 1); ldap_set_option(server, LDAP_OPT_SSL, LDAP_OPT_ON); #else /* !USE_WIN32_LDAP */ int ldap_option; @@ -406,7 +419,7 @@ static CURLcode ldap_do(struct Curl_easy *data, bool *done) goto quit; } infof(data, "LDAP local: using PEM CA cert: %s", ldap_ca); - rc = ldap_set_option(NULL, LDAP_OPT_X_TLS_CACERTFILE, ldap_ca); + rc = ldap_set_option(server, LDAP_OPT_X_TLS_CACERTFILE, ldap_ca); if(rc != LDAP_SUCCESS) { failf(data, "LDAP local: ERROR setting PEM CA cert: %s", ldap_err2string(rc)); @@ -418,20 +431,13 @@ static CURLcode ldap_do(struct Curl_easy *data, bool *done) else ldap_option = LDAP_OPT_X_TLS_NEVER; - rc = ldap_set_option(NULL, LDAP_OPT_X_TLS_REQUIRE_CERT, &ldap_option); + rc = ldap_set_option(server, LDAP_OPT_X_TLS_REQUIRE_CERT, &ldap_option); if(rc != LDAP_SUCCESS) { failf(data, "LDAP local: ERROR setting cert verify mode: %s", ldap_err2string(rc)); result = CURLE_SSL_CERTPROBLEM; goto quit; } - server = ldap_init(host, ipquad.remote_port); - if(!server) { - failf(data, "LDAP local: Cannot connect to %s:%u", - conn->host.dispname, ipquad.remote_port); - result = CURLE_COULDNT_CONNECT; - goto quit; - } ldap_option = LDAP_OPT_X_TLS_HARD; rc = ldap_set_option(server, LDAP_OPT_X_TLS, &ldap_option); if(rc != LDAP_SUCCESS) { @@ -440,16 +446,6 @@ static CURLcode ldap_do(struct Curl_easy *data, bool *done) result = CURLE_SSL_CERTPROBLEM; goto quit; } -#if 0 - rc = ldap_start_tls_s(server, NULL, NULL); - if(rc != LDAP_SUCCESS) { - failf(data, "LDAP local: ERROR starting SSL/TLS mode: %s", - ldap_err2string(rc)); - result = CURLE_SSL_CERTPROBLEM; - goto quit; - } -#endif - #else /* !LDAP_OPT_X_TLS */ (void)ldap_option; (void)ldap_ca; @@ -468,15 +464,7 @@ static CURLcode ldap_do(struct Curl_easy *data, bool *done) result = CURLE_NOT_BUILT_IN; goto quit; } - else { - server = ldap_init(host, (curl_ldap_num_t)ipquad.remote_port); - if(!server) { - failf(data, "LDAP local: Cannot connect to %s:%u", - conn->host.dispname, ipquad.remote_port); - result = CURLE_COULDNT_CONNECT; - goto quit; - } - } + #ifdef USE_WIN32_LDAP ldap_set_option(server, LDAP_OPT_PROTOCOL_VERSION, &ldap_proto); rc = ldap_win_bind(data, server, user, passwd); From f39b8a11749dba677848ea1e7d2ed20f23f87f03 Mon Sep 17 00:00:00 2001 From: Patrick Monnerat Date: Wed, 3 Dec 2025 18:36:03 +0100 Subject: [PATCH 180/415] lib: add a Curl_bufref_uptr() function and use it Function Curl_bufref_ptr() now returns a const char *. New function Curl_bufref_uptr() returns a const unsigned char *. Usage and doc updated. Closes #19827 --- docs/internals/BUFREF.md | 10 +++++++++- lib/bufref.c | 14 +++++++++++++- lib/bufref.h | 3 ++- lib/curl_sasl.c | 4 ++-- lib/http_ntlm.c | 4 ++-- lib/imap.c | 5 ++--- lib/pop3.c | 5 ++--- lib/smtp.c | 5 ++--- lib/vauth/cram.c | 2 +- lib/vauth/digest.c | 2 +- lib/vauth/gsasl.c | 3 +-- lib/vauth/ntlm.c | 4 ++-- lib/vauth/ntlm_sspi.c | 2 +- 13 files changed, 40 insertions(+), 23 deletions(-) diff --git a/docs/internals/BUFREF.md b/docs/internals/BUFREF.md index 9a8b506b561a..686a092aecc3 100644 --- a/docs/internals/BUFREF.md +++ b/docs/internals/BUFREF.md @@ -72,7 +72,15 @@ Returns `CURLE_OK` if successful, else `CURLE_OUT_OF_MEMORY`. ## `ptr` ```c -const unsigned char *Curl_bufref_ptr(const struct bufref *br); +const char *Curl_bufref_ptr(const struct bufref *br); +``` + +Returns a `const char *` to the referenced buffer. + +## `uptr` + +```c +const unsigned char *Curl_bufref_uptr(const struct bufref *br); ``` Returns a `const unsigned char *` to the referenced buffer. diff --git a/lib/bufref.c b/lib/bufref.c index 643fe5d2e08c..8dcd3592dbe4 100644 --- a/lib/bufref.c +++ b/lib/bufref.c @@ -84,7 +84,7 @@ void Curl_bufref_set(struct bufref *br, const void *ptr, size_t len, /* * Get a pointer to the referenced buffer. */ -const unsigned char *Curl_bufref_ptr(const struct bufref *br) +const unsigned char *Curl_bufref_uptr(const struct bufref *br) { DEBUGASSERT(br); DEBUGASSERT(br->signature == SIGNATURE); @@ -93,6 +93,18 @@ const unsigned char *Curl_bufref_ptr(const struct bufref *br) return br->ptr; } +/* + * Get a pointer to the referenced string. + */ +const char *Curl_bufref_ptr(const struct bufref *br) +{ + DEBUGASSERT(br); + DEBUGASSERT(br->signature == SIGNATURE); + DEBUGASSERT(br->ptr || !br->len); + + return (const char *) br->ptr; +} + /* * Get the length of the referenced buffer data. */ diff --git a/lib/bufref.h b/lib/bufref.h index f80011fde5ec..b8ffe383478b 100644 --- a/lib/bufref.h +++ b/lib/bufref.h @@ -39,7 +39,8 @@ struct bufref { void Curl_bufref_init(struct bufref *br); void Curl_bufref_set(struct bufref *br, const void *ptr, size_t len, void (*dtor)(void *)); -const unsigned char *Curl_bufref_ptr(const struct bufref *br); +const char *Curl_bufref_ptr(const struct bufref *br); +const unsigned char *Curl_bufref_uptr(const struct bufref *br); size_t Curl_bufref_len(const struct bufref *br); CURLcode Curl_bufref_memdup(struct bufref *br, const void *ptr, size_t len); void Curl_bufref_free(struct bufref *br); diff --git a/lib/curl_sasl.c b/lib/curl_sasl.c index a4cd5a207b68..3e4bafc19ae4 100644 --- a/lib/curl_sasl.c +++ b/lib/curl_sasl.c @@ -235,7 +235,7 @@ static CURLcode get_server_message(struct SASL *sasl, struct Curl_easy *data, if(!result && (sasl->params->flags & SASL_FLAG_BASE64)) { unsigned char *msg; size_t msglen; - const char *serverdata = (const char *)Curl_bufref_ptr(out); + const char *serverdata = Curl_bufref_ptr(out); if(!*serverdata || *serverdata == '=') Curl_bufref_set(out, NULL, 0, NULL); @@ -263,7 +263,7 @@ static CURLcode build_message(struct SASL *sasl, struct bufref *msg) char *base64; size_t base64len; - result = curlx_base64_encode(Curl_bufref_ptr(msg), + result = curlx_base64_encode(Curl_bufref_uptr(msg), Curl_bufref_len(msg), &base64, &base64len); if(!result) Curl_bufref_set(msg, base64, base64len, curl_free); diff --git a/lib/http_ntlm.c b/lib/http_ntlm.c index e1b48d76759d..8d15a8a16227 100644 --- a/lib/http_ntlm.c +++ b/lib/http_ntlm.c @@ -201,7 +201,7 @@ CURLcode Curl_output_ntlm(struct Curl_easy *data, bool proxy) hostname, ntlm, &ntlmmsg); if(!result) { DEBUGASSERT(Curl_bufref_len(&ntlmmsg) != 0); - result = curlx_base64_encode(Curl_bufref_ptr(&ntlmmsg), + result = curlx_base64_encode(Curl_bufref_uptr(&ntlmmsg), Curl_bufref_len(&ntlmmsg), &base64, &len); if(!result) { curlx_free(*allocuserpwd); @@ -219,7 +219,7 @@ CURLcode Curl_output_ntlm(struct Curl_easy *data, bool proxy) result = Curl_auth_create_ntlm_type3_message(data, userp, passwdp, ntlm, &ntlmmsg); if(!result && Curl_bufref_len(&ntlmmsg)) { - result = curlx_base64_encode(Curl_bufref_ptr(&ntlmmsg), + result = curlx_base64_encode(Curl_bufref_uptr(&ntlmmsg), Curl_bufref_len(&ntlmmsg), &base64, &len); if(!result) { curlx_free(*allocuserpwd); diff --git a/lib/imap.c b/lib/imap.c index ec5e654cfae9..cbc4506a9d85 100644 --- a/lib/imap.c +++ b/lib/imap.c @@ -636,7 +636,7 @@ static CURLcode imap_perform_authenticate(struct Curl_easy *data, struct imap_conn *imapc = Curl_conn_meta_get(data->conn, CURL_META_IMAP_CONN); CURLcode result = CURLE_OK; - const char *ir = (const char *)Curl_bufref_ptr(initresp); + const char *ir = Curl_bufref_ptr(initresp); if(!imapc) return CURLE_FAILED_INIT; @@ -668,8 +668,7 @@ static CURLcode imap_continue_authenticate(struct Curl_easy *data, (void)mech; if(!imapc) return CURLE_FAILED_INIT; - return Curl_pp_sendf(data, &imapc->pp, - "%s", (const char *)Curl_bufref_ptr(resp)); + return Curl_pp_sendf(data, &imapc->pp, "%s", Curl_bufref_ptr(resp)); } /*********************************************************************** diff --git a/lib/pop3.c b/lib/pop3.c index 771069b3d434..0ddff3e45ef9 100644 --- a/lib/pop3.c +++ b/lib/pop3.c @@ -623,7 +623,7 @@ static CURLcode pop3_perform_auth(struct Curl_easy *data, struct pop3_conn *pop3c = Curl_conn_meta_get(data->conn, CURL_META_POP3_CONN); CURLcode result = CURLE_OK; - const char *ir = (const char *)Curl_bufref_ptr(initresp); + const char *ir = Curl_bufref_ptr(initresp); if(!pop3c) return CURLE_FAILED_INIT; @@ -657,8 +657,7 @@ static CURLcode pop3_continue_auth(struct Curl_easy *data, if(!pop3c) return CURLE_FAILED_INIT; - return Curl_pp_sendf(data, &pop3c->pp, - "%s", (const char *) Curl_bufref_ptr(resp)); + return Curl_pp_sendf(data, &pop3c->pp, "%s", Curl_bufref_ptr(resp)); } /*********************************************************************** diff --git a/lib/smtp.c b/lib/smtp.c index 5aab391e379a..fa821fe45de3 100644 --- a/lib/smtp.c +++ b/lib/smtp.c @@ -506,7 +506,7 @@ static CURLcode smtp_perform_auth(struct Curl_easy *data, CURLcode result = CURLE_OK; struct smtp_conn *smtpc = Curl_conn_meta_get(data->conn, CURL_META_SMTP_CONN); - const char *ir = (const char *)Curl_bufref_ptr(initresp); + const char *ir = Curl_bufref_ptr(initresp); if(!smtpc) return CURLE_FAILED_INIT; @@ -539,8 +539,7 @@ static CURLcode smtp_continue_auth(struct Curl_easy *data, (void)mech; if(!smtpc) return CURLE_FAILED_INIT; - return Curl_pp_sendf(data, &smtpc->pp, - "%s", (const char *)Curl_bufref_ptr(resp)); + return Curl_pp_sendf(data, &smtpc->pp, "%s", Curl_bufref_ptr(resp)); } /*********************************************************************** diff --git a/lib/vauth/cram.c b/lib/vauth/cram.c index 6a39a400ee3c..7cce86fd62b5 100644 --- a/lib/vauth/cram.c +++ b/lib/vauth/cram.c @@ -69,7 +69,7 @@ CURLcode Curl_auth_create_cram_md5_message(const struct bufref *chlg, /* Update the digest with the given challenge */ if(Curl_bufref_len(chlg)) - Curl_HMAC_update(ctxt, Curl_bufref_ptr(chlg), + Curl_HMAC_update(ctxt, Curl_bufref_uptr(chlg), curlx_uztoui(Curl_bufref_len(chlg))); /* Finalise the digest */ diff --git a/lib/vauth/digest.c b/lib/vauth/digest.c index 8bcfc7ed6c9c..ce3a7b368779 100644 --- a/lib/vauth/digest.c +++ b/lib/vauth/digest.c @@ -271,7 +271,7 @@ static CURLcode auth_decode_digest_md5_message(const struct bufref *chlgref, char *alg, size_t alen, char *qop, size_t qlen) { - const char *chlg = (const char *)Curl_bufref_ptr(chlgref); + const char *chlg = Curl_bufref_ptr(chlgref); /* Ensure we have a valid challenge message */ if(!Curl_bufref_len(chlgref)) diff --git a/lib/vauth/gsasl.c b/lib/vauth/gsasl.c index 3888622dbffa..4c83793d788d 100644 --- a/lib/vauth/gsasl.c +++ b/lib/vauth/gsasl.c @@ -98,8 +98,7 @@ CURLcode Curl_auth_gsasl_token(struct Curl_easy *data, char *response; size_t outlen; - res = gsasl_step(gsasl->client, - (const char *)Curl_bufref_ptr(chlg), Curl_bufref_len(chlg), + res = gsasl_step(gsasl->client, Curl_bufref_ptr(chlg), Curl_bufref_len(chlg), &response, &outlen); if(res != GSASL_OK && res != GSASL_NEEDS_MORE) { failf(data, "GSASL step: %s", gsasl_strerror(res)); diff --git a/lib/vauth/ntlm.c b/lib/vauth/ntlm.c index 22d028e8c2fa..7fd13d8745c1 100644 --- a/lib/vauth/ntlm.c +++ b/lib/vauth/ntlm.c @@ -255,7 +255,7 @@ static CURLcode ntlm_decode_type2_target(struct Curl_easy *data, { unsigned short target_info_len = 0; unsigned int target_info_offset = 0; - const unsigned char *type2 = Curl_bufref_ptr(type2ref); + const unsigned char *type2 = Curl_bufref_uptr(type2ref); size_t type2len = Curl_bufref_len(type2ref); #ifdef CURL_DISABLE_VERBOSE_STRINGS @@ -355,7 +355,7 @@ CURLcode Curl_auth_decode_ntlm_type2_message(struct Curl_easy *data, */ CURLcode result = CURLE_OK; - const unsigned char *type2 = Curl_bufref_ptr(type2ref); + const unsigned char *type2 = Curl_bufref_uptr(type2ref); size_t type2len = Curl_bufref_len(type2ref); #ifdef CURL_DISABLE_VERBOSE_STRINGS diff --git a/lib/vauth/ntlm_sspi.c b/lib/vauth/ntlm_sspi.c index d724907db649..e4aad6e24f8d 100644 --- a/lib/vauth/ntlm_sspi.c +++ b/lib/vauth/ntlm_sspi.c @@ -209,7 +209,7 @@ CURLcode Curl_auth_decode_ntlm_type2_message(struct Curl_easy *data, } /* Store the challenge for later use */ - ntlm->input_token = Curl_memdup0((const char *)Curl_bufref_ptr(type2), + ntlm->input_token = Curl_memdup0(Curl_bufref_ptr(type2), Curl_bufref_len(type2)); if(!ntlm->input_token) return CURLE_OUT_OF_MEMORY; From 36542b734966fce2ce5689d689a0e4922a103e50 Mon Sep 17 00:00:00 2001 From: Patrick Monnerat Date: Wed, 3 Dec 2025 23:15:18 +0100 Subject: [PATCH 181/415] lib: turn state.url into a struct bufref Closes #19827 --- lib/cookie.c | 3 ++- lib/curl_rtmp.c | 3 ++- lib/easy.c | 12 ++++++------ lib/getinfo.c | 7 +++++-- lib/http.c | 22 +++++++++++----------- lib/http2.c | 8 +++----- lib/ldap.c | 5 +++-- lib/multi.c | 5 +++-- lib/openldap.c | 5 +++-- lib/setopt.c | 14 +++----------- lib/transfer.c | 11 +++-------- lib/url.c | 37 +++++++++++++------------------------ lib/urldata.h | 4 ++-- lib/vquic/curl_ngtcp2.c | 3 ++- lib/vquic/curl_osslq.c | 3 ++- lib/vquic/curl_quiche.c | 7 ++++--- 16 files changed, 67 insertions(+), 82 deletions(-) diff --git a/lib/cookie.c b/lib/cookie.c index e3cf8e4e0cf1..dff5198c1162 100644 --- a/lib/cookie.c +++ b/lib/cookie.c @@ -40,6 +40,7 @@ #include "rename.h" #include "strdup.h" #include "llist.h" +#include "bufref.h" #include "curlx/strparse.h" static void strstore(char **str, const char *newstr, size_t len); @@ -1622,7 +1623,7 @@ void Curl_flush_cookies(struct Curl_easy *data, bool cleanup) set), as otherwise the cookies were not completely initialized and there might be cookie files that were not loaded so saving the file is the wrong thing. */ - if(data->set.str[STRING_COOKIEJAR] && data->state.url) { + if(data->set.str[STRING_COOKIEJAR] && Curl_bufref_ptr(&data->state.url)) { /* if we have a destination file for all the cookies to get dumped to */ CURLcode result = cookie_output(data, data->cookies, data->set.str[STRING_COOKIEJAR]); diff --git a/lib/curl_rtmp.c b/lib/curl_rtmp.c index 1eebbb5b3f24..e0597cdcca92 100644 --- a/lib/curl_rtmp.c +++ b/lib/curl_rtmp.c @@ -33,6 +33,7 @@ #include "curlx/nonblock.h" /* for curlx_nonblock */ #include "progress.h" /* for Curl_pgrsSetUploadSize */ #include "transfer.h" +#include "bufref.h" #include "curlx/warnless.h" #include #include @@ -233,7 +234,7 @@ static CURLcode rtmp_setup_connection(struct Curl_easy *data, RTMP_Init(r); RTMP_SetBufferMS(r, DEF_BUFTIME); - if(!RTMP_SetupURL(r, data->state.url)) + if(!RTMP_SetupURL(r, CURL_UNCONST(Curl_bufref_ptr(&data->state.url)))) /* rtmp_conn_dtor() performs the cleanup */ return CURLE_URL_MALFORMAT; return CURLE_OK; diff --git a/lib/easy.c b/lib/easy.c index d2f6c36c0d87..c18fdd09bf86 100644 --- a/lib/easy.c +++ b/lib/easy.c @@ -75,6 +75,7 @@ #include "system_win32.h" #include "http2.h" #include "curlx/dynbuf.h" +#include "bufref.h" #include "altsvc.h" #include "hsts.h" @@ -975,6 +976,7 @@ CURL *curl_easy_duphandle(CURL *d) Curl_hash_init(&outcurl->meta_hash, 23, Curl_hash_str, curlx_str_key_compare, dupeasy_meta_freeentry); curlx_dyn_init(&outcurl->state.headerb, CURL_MAX_HTTP_HEADER); + Curl_bufref_init(&outcurl->state.url); Curl_netrc_init(&outcurl->state.netrc); /* the connection pool is setup on demand */ @@ -1014,12 +1016,10 @@ CURL *curl_easy_duphandle(CURL *d) } #endif - if(data->state.url) { - outcurl->state.url = curlx_strdup(data->state.url); - if(!outcurl->state.url) - goto fail; - outcurl->state.url_alloc = TRUE; - } + if(Curl_bufref_ptr(&data->state.url)) + Curl_bufref_set(&outcurl->state.url, + curlx_strdup(Curl_bufref_ptr(&data->state.url)), 0, + curl_free); if(data->state.referer) { outcurl->state.referer = curlx_strdup(data->state.referer); diff --git a/lib/getinfo.c b/lib/getinfo.c index 13e9622d3302..59dc19877742 100644 --- a/lib/getinfo.c +++ b/lib/getinfo.c @@ -32,6 +32,7 @@ #include "vtls/vtls.h" #include "connect.h" /* Curl_getconnectinfo() */ #include "progress.h" +#include "bufref.h" #include "curlx/strparse.h" /* @@ -91,8 +92,10 @@ static CURLcode getinfo_char(struct Curl_easy *data, CURLINFO info, const char **param_charp) { switch(info) { - case CURLINFO_EFFECTIVE_URL: - *param_charp = data->state.url ? data->state.url : ""; + case CURLINFO_EFFECTIVE_URL: { + const char *s = Curl_bufref_ptr(&data->state.url); + *param_charp = s ? s : ""; + } break; case CURLINFO_EFFECTIVE_METHOD: { const char *m = data->set.str[STRING_CUSTOMREQUEST]; diff --git a/lib/http.c b/lib/http.c index 3178ca59e993..ae7458572b6a 100644 --- a/lib/http.c +++ b/lib/http.c @@ -84,6 +84,7 @@ #include "altsvc.h" #include "hsts.h" #include "ws.h" +#include "bufref.h" #include "curl_ctype.h" #include "curlx/strparse.h" @@ -610,7 +611,8 @@ CURLcode Curl_http_auth_act(struct Curl_easy *data) we must make sure to free it before allocating a new one. As figured out in bug #2284386 */ curlx_free(data->req.newurl); - data->req.newurl = curlx_strdup(data->state.url); /* clone URL */ + /* clone URL */ + data->req.newurl = curlx_strdup(Curl_bufref_ptr(&data->state.url)); if(!data->req.newurl) return CURLE_OUT_OF_MEMORY; } @@ -623,7 +625,8 @@ CURLcode Curl_http_auth_act(struct Curl_easy *data) we did not try HEAD or GET */ if((data->state.httpreq != HTTPREQ_GET) && (data->state.httpreq != HTTPREQ_HEAD)) { - data->req.newurl = curlx_strdup(data->state.url); /* clone URL */ + /* clone URL */ + data->req.newurl = curlx_strdup(Curl_bufref_ptr(&data->state.url)); if(!data->req.newurl) return CURLE_OUT_OF_MEMORY; data->state.authhost.done = TRUE; @@ -909,7 +912,7 @@ static CURLcode auth_spnego(struct Curl_easy *data, &conn->http_negotiate_state; if(!result) { curlx_free(data->req.newurl); - data->req.newurl = curlx_strdup(data->state.url); + data->req.newurl = curlx_strdup(Curl_bufref_ptr(&data->state.url)); if(!data->req.newurl) return CURLE_OUT_OF_MEMORY; data->state.authproblem = FALSE; @@ -1243,7 +1246,8 @@ CURLcode Curl_http_follow(struct Curl_easy *data, const char *newurl, if(!u) return CURLE_OUT_OF_MEMORY; - uc = curl_url_set(u, CURLUPART_URL, data->state.url, 0); + uc = curl_url_set(u, CURLUPART_URL, + Curl_bufref_ptr(&data->state.url), 0); if(!uc) uc = curl_url_set(u, CURLUPART_FRAGMENT, NULL, 0); if(!uc) @@ -1365,13 +1369,9 @@ CURLcode Curl_http_follow(struct Curl_easy *data, const char *newurl, if(disallowport) data->state.allow_port = FALSE; - if(data->state.url_alloc) - Curl_safefree(data->state.url); - - data->state.url = follow_url; - data->state.url_alloc = TRUE; + Curl_bufref_set(&data->state.url, follow_url, 0, curl_free); rewind_result = Curl_req_soft_reset(&data->req, data); - infof(data, "Issue another request to this URL: '%s'", data->state.url); + infof(data, "Issue another request to this URL: '%s'", follow_url); if((data->set.http_follow_mode == CURLFOLLOW_FIRSTONLY) && data->set.str[STRING_CUSTOMREQUEST] && !data->state.http_ignorecustom) { @@ -4054,7 +4054,7 @@ static CURLcode http_on_response(struct Curl_easy *data, data->state.disableexpect = TRUE; Curl_req_abort_sending(data); DEBUGASSERT(!data->req.newurl); - data->req.newurl = curlx_strdup(data->state.url); + data->req.newurl = curlx_strdup(Curl_bufref_ptr(&data->state.url)); if(!data->req.newurl) { result = CURLE_OUT_OF_MEMORY; goto out; diff --git a/lib/http2.c b/lib/http2.c index a3ff8c85294e..df38f82cafa0 100644 --- a/lib/http2.c +++ b/lib/http2.c @@ -44,6 +44,7 @@ #include "rand.h" #include "curlx/strparse.h" #include "transfer.h" +#include "bufref.h" #include "curlx/dynbuf.h" #include "curlx/warnless.h" #include "headers.h" @@ -920,10 +921,7 @@ static int set_transfer_url(struct Curl_easy *data, if(rc) return rc; - if(data->state.url_alloc) - curlx_free(data->state.url); - data->state.url_alloc = TRUE; - data->state.url = url; + Curl_bufref_set(&data->state.url, url, 0, curl_free); return 0; } @@ -2316,7 +2314,7 @@ static CURLcode h2_submit(struct h2_stream_ctx **pstream, size_t acc = 0, i; infof(data, "[HTTP/2] [%d] OPENED stream for %s", - stream_id, data->state.url); + stream_id, Curl_bufref_ptr(&data->state.url)); for(i = 0; i < nheader; ++i) { acc += nva[i].namelen + nva[i].valuelen; diff --git a/lib/ldap.c b/lib/ldap.c index 0911a9239a2d..b6ed43d90415 100644 --- a/lib/ldap.c +++ b/lib/ldap.c @@ -89,6 +89,7 @@ #include "progress.h" #include "transfer.h" #include "curlx/strparse.h" +#include "bufref.h" #include "curl_ldap.h" #include "curlx/multibyte.h" #include "curlx/base64.h" @@ -338,10 +339,10 @@ static CURLcode ldap_do(struct Curl_easy *data, bool *done) *done = TRUE; /* unconditionally */ infof(data, "LDAP local: LDAP Vendor = %s ; LDAP Version = %d", LDAP_VENDOR_NAME, LDAP_VENDOR_VERSION); - infof(data, "LDAP local: %s", data->state.url); + infof(data, "LDAP local: %s", Curl_bufref_ptr(&data->state.url)); #ifdef HAVE_LDAP_URL_PARSE - rc = ldap_url_parse(data->state.url, &ludp); + rc = ldap_url_parse(Curl_bufref_ptr(&data->state.url), &ludp); #else rc = ldap_url_parse_low(data, conn, &ludp); #endif diff --git a/lib/multi.c b/lib/multi.c index b912f7a212f2..3086d61c7489 100644 --- a/lib/multi.c +++ b/lib/multi.c @@ -53,6 +53,7 @@ #include "socketpair.h" #include "socks.h" #include "urlapi-int.h" +#include "bufref.h" /* initial multi->xfers table size for a full multi */ #define CURL_XFER_TABLE_SIZE 512 @@ -2006,7 +2007,7 @@ static CURLMcode state_performing(struct Curl_easy *data, data->state.errorbuf = FALSE; if(!newurl) /* typically for HTTP_1_1_REQUIRED error on first flight */ - newurl = curlx_strdup(data->state.url); + newurl = curlx_strdup(Curl_bufref_ptr(&data->state.url)); if(!newurl) { result = CURLE_OUT_OF_MEMORY; } @@ -4066,7 +4067,7 @@ static void multi_xfer_dump(struct Curl_multi *multi, uint32_t mid, ", url=%s\n", mid, (data->magic == CURLEASY_MAGIC_NUMBER) ? "GOOD" : "BAD!", - (void *)data, data->id, data->state.url); + (void *)data, data->id, Curl_bufref_ptr(&data->state.url)); } } diff --git a/lib/openldap.c b/lib/openldap.c index ba1a39181f38..a1756e427907 100644 --- a/lib/openldap.c +++ b/lib/openldap.c @@ -52,6 +52,7 @@ #include "connect.h" #include "curl_sasl.h" #include "strcase.h" +#include "bufref.h" /* * Uncommenting this will enable the built-in debug logging of the openldap @@ -272,7 +273,7 @@ static CURLcode oldap_url_parse(struct Curl_easy *data, LDAPURLDesc **ludp) *ludp = NULL; if(!data->state.up.user && !data->state.up.password && !data->state.up.options) - rc = ldap_url_parse(data->state.url, ludp); + rc = ldap_url_parse(Curl_bufref_ptr(&data->state.url), ludp); if(rc != LDAP_URL_SUCCESS) { const char *msg = "url parsing problem"; @@ -988,7 +989,7 @@ static CURLcode oldap_do(struct Curl_easy *data, bool *done) if(!li) return CURLE_FAILED_INIT; - infof(data, "LDAP local: %s", data->state.url); + infof(data, "LDAP local: %s", Curl_bufref_ptr(&data->state.url)); result = oldap_url_parse(data, &lud); if(result) diff --git a/lib/setopt.c b/lib/setopt.c index 0a377be1f165..bcaf3fc2ae28 100644 --- a/lib/setopt.c +++ b/lib/setopt.c @@ -54,6 +54,7 @@ #include "tftp.h" #include "strdup.h" #include "escape.h" +#include "bufref.h" static CURLcode setopt_set_timeout_sec(timediff_t *ptimeout_ms, long secs) { @@ -1971,12 +1972,8 @@ static CURLcode setopt_cptr(struct Curl_easy *data, CURLoption option, /* * The URL to fetch. */ - if(data->state.url_alloc) { - Curl_safefree(data->state.url); - data->state.url_alloc = FALSE; - } result = Curl_setstropt(&s->str[STRING_SET_URL], ptr); - data->state.url = s->str[STRING_SET_URL]; + Curl_bufref_set(&data->state.url, s->str[STRING_SET_URL], 0, NULL); break; case CURLOPT_USERPWD: @@ -2063,12 +2060,7 @@ static CURLcode setopt_cptr(struct Curl_easy *data, CURLoption option, /* * pass CURLU to set URL */ - if(data->state.url_alloc) { - Curl_safefree(data->state.url); - data->state.url_alloc = FALSE; - } - else - data->state.url = NULL; + Curl_bufref_free(&data->state.url); Curl_safefree(s->str[STRING_SET_URL]); s->uh = (CURLU *)ptr; break; diff --git a/lib/transfer.c b/lib/transfer.c index a8a66f86c7b9..34f0698ebd75 100644 --- a/lib/transfer.c +++ b/lib/transfer.c @@ -79,6 +79,7 @@ #include "hsts.h" #include "setopt.h" #include "headers.h" +#include "bufref.h" #include "curlx/warnless.h" #if !defined(CURL_DISABLE_HTTP) || !defined(CURL_DISABLE_SMTP) || \ @@ -484,13 +485,7 @@ CURLcode Curl_pretransfer(struct Curl_easy *data) } } - /* since the URL may have been redirected in a previous use of this handle */ - if(data->state.url_alloc) { - Curl_safefree(data->state.url); - data->state.url_alloc = FALSE; - } - - data->state.url = data->set.str[STRING_SET_URL]; + Curl_bufref_set(&data->state.url, data->set.str[STRING_SET_URL], 0, NULL); if(data->set.postfields && data->set.set_resume_from) { /* we cannot */ @@ -676,7 +671,7 @@ CURLcode Curl_retry_request(struct Curl_easy *data, char **url) } infof(data, "Connection died, retrying a fresh connect (retry count: %d)", data->state.retrycount); - *url = curlx_strdup(data->state.url); + *url = curlx_strdup(Curl_bufref_ptr(&data->state.url)); if(!*url) return CURLE_OUT_OF_MEMORY; diff --git a/lib/url.c b/lib/url.c index f646b74ed4a7..65161d7e2488 100644 --- a/lib/url.c +++ b/lib/url.c @@ -73,6 +73,7 @@ #include "netrc.h" #include "formdata.h" #include "mime.h" +#include "bufref.h" #include "vtls/vtls.h" #include "hostip.h" #include "transfer.h" @@ -184,11 +185,7 @@ void Curl_freeset(struct Curl_easy *data) data->state.referer_alloc = FALSE; } data->state.referer = NULL; - if(data->state.url_alloc) { - Curl_safefree(data->state.url); - data->state.url_alloc = FALSE; - } - data->state.url = NULL; + Curl_bufref_free(&data->state.url); Curl_mime_cleanpart(&data->set.mimepost); @@ -516,6 +513,7 @@ CURLcode Curl_open(struct Curl_easy **curl) Curl_hash_init(&data->meta_hash, 23, Curl_hash_str, curlx_str_key_compare, easy_meta_freeentry); curlx_dyn_init(&data->state.headerb, CURL_MAX_HTTP_HEADER); + Curl_bufref_init(&data->state.url); Curl_req_init(&data->req); Curl_initinfo(data); #ifndef CURL_DISABLE_HTTP @@ -1769,22 +1767,19 @@ static CURLcode parseurlandfillconn(struct Curl_easy *data, return CURLE_OUT_OF_MEMORY; if(data->set.str[STRING_DEFAULT_PROTOCOL] && - !Curl_is_absolute_url(data->state.url, NULL, 0, TRUE)) { + !Curl_is_absolute_url(Curl_bufref_ptr(&data->state.url), NULL, 0, TRUE)) { char *url = curl_maprintf("%s://%s", data->set.str[STRING_DEFAULT_PROTOCOL], - data->state.url); + Curl_bufref_ptr(&data->state.url)); if(!url) return CURLE_OUT_OF_MEMORY; - if(data->state.url_alloc) - curlx_free(data->state.url); - data->state.url = url; - data->state.url_alloc = TRUE; + Curl_bufref_set(&data->state.url, url, 0, curl_free); } if(!use_set_uh) { char *newurl; - uc = curl_url_set(uh, CURLUPART_URL, data->state.url, (unsigned int) - (CURLU_GUESS_SCHEME | + uc = curl_url_set(uh, CURLUPART_URL, Curl_bufref_ptr(&data->state.url), + (unsigned int) (CURLU_GUESS_SCHEME | CURLU_NON_SUPPORT_SCHEME | (data->set.disallow_username_in_url ? CURLU_DISALLOW_USER : 0) | @@ -1798,10 +1793,7 @@ static CURLcode parseurlandfillconn(struct Curl_easy *data, uc = curl_url_get(uh, CURLUPART_URL, &newurl, 0); if(uc) return Curl_uc_to_curlcode(uc); - if(data->state.url_alloc) - curlx_free(data->state.url); - data->state.url = newurl; - data->state.url_alloc = TRUE; + Curl_bufref_set(&data->state.url, newurl, 0, curl_free); } uc = curl_url_get(uh, CURLUPART_SCHEME, &data->state.up.scheme, 0); @@ -1855,8 +1847,7 @@ static CURLcode parseurlandfillconn(struct Curl_easy *data, uc = curl_url_set(uh, CURLUPART_SCHEME, "https", 0); if(uc) return Curl_uc_to_curlcode(uc); - if(data->state.url_alloc) - Curl_safefree(data->state.url); + Curl_bufref_free(&data->state.url); /* after update, get the updated version */ uc = curl_url_get(uh, CURLUPART_URL, &url, 0); if(uc) @@ -1866,10 +1857,8 @@ static CURLcode parseurlandfillconn(struct Curl_easy *data, curlx_free(url); return Curl_uc_to_curlcode(uc); } - data->state.url = url; - data->state.url_alloc = TRUE; - infof(data, "Switched from HTTP to HTTPS due to HSTS => %s", - data->state.url); + Curl_bufref_set(&data->state.url, url, 0, curl_free); + infof(data, "Switched from HTTP to HTTPS due to HSTS => %s", url); } } #endif @@ -3396,7 +3385,7 @@ static CURLcode create_conn(struct Curl_easy *data, /************************************************************* * Check input data *************************************************************/ - if(!data->state.url) { + if(!Curl_bufref_ptr(&data->state.url)) { result = CURLE_URL_MALFORMAT; goto out; } diff --git a/lib/urldata.h b/lib/urldata.h index aa1326d2a645..554e002020ad 100644 --- a/lib/urldata.h +++ b/lib/urldata.h @@ -154,6 +154,7 @@ typedef unsigned int curl_prot_t; #include "hash.h" #include "splay.h" #include "curlx/dynbuf.h" +#include "bufref.h" #include "dynhds.h" #include "request.h" #include "ratelimit.h" @@ -1025,7 +1026,7 @@ struct UrlState { void *in; /* CURLOPT_READDATA */ CURLU *uh; /* URL handle for the current parsed URL */ struct urlpieces up; - char *url; /* work URL, copied from UserDefined */ + struct bufref url; /* work URL, initially copied from UserDefined */ char *referer; /* referer string */ struct curl_slist *resolve; /* set to point to the set.resolve list when this should be dealt with in pretransfer */ @@ -1122,7 +1123,6 @@ struct UrlState { #ifdef CURL_LIST_ONLY_PROTOCOL BIT(list_only); /* list directory contents */ #endif - 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 */ BIT(upload); /* upload request */ diff --git a/lib/vquic/curl_ngtcp2.c b/lib/vquic/curl_ngtcp2.c index 09b30229f08d..cf7b95bf6f94 100644 --- a/lib/vquic/curl_ngtcp2.c +++ b/lib/vquic/curl_ngtcp2.c @@ -61,6 +61,7 @@ #include "../select.h" #include "../curlx/inet_pton.h" #include "../transfer.h" +#include "../bufref.h" #include "vquic.h" #include "vquic_int.h" #include "vquic-tls.h" @@ -1631,7 +1632,7 @@ static CURLcode h3_stream_open(struct Curl_cfilter *cf, if(Curl_trc_is_verbose(data)) { infof(data, "[HTTP/3] [%" PRId64 "] OPENED stream for %s", - stream->id, data->state.url); + stream->id, Curl_bufref_ptr(&data->state.url)); for(i = 0; i < nheader; ++i) { infof(data, "[HTTP/3] [%" PRId64 "] [%.*s: %.*s]", stream->id, (int)nva[i].namelen, nva[i].name, diff --git a/lib/vquic/curl_osslq.c b/lib/vquic/curl_osslq.c index ece4ce6ad570..79bd1180dcf6 100644 --- a/lib/vquic/curl_osslq.c +++ b/lib/vquic/curl_osslq.c @@ -54,6 +54,7 @@ #include "../vtls/openssl.h" #include "curl_osslq.h" #include "../url.h" +#include "../bufref.h" #include "../curlx/warnless.h" #include "../curlx/strerr.h" @@ -1985,7 +1986,7 @@ static CURLcode h3_stream_open(struct Curl_cfilter *cf, if(Curl_trc_is_verbose(data)) { infof(data, "[HTTP/3] [%" PRId64 "] OPENED stream for %s", - stream->s.id, data->state.url); + stream->s.id, Curl_bufref_ptr(&data->state.url)); for(i = 0; i < nheader; ++i) { infof(data, "[HTTP/3] [%" PRId64 "] [%.*s: %.*s]", stream->s.id, diff --git a/lib/vquic/curl_quiche.c b/lib/vquic/curl_quiche.c index 913311085270..a35ffbec65e8 100644 --- a/lib/vquic/curl_quiche.c +++ b/lib/vquic/curl_quiche.c @@ -46,6 +46,7 @@ #include "curl_quiche.h" #include "../transfer.h" #include "../url.h" +#include "../bufref.h" #include "../curlx/inet_pton.h" #include "../curlx/warnless.h" #include "../vtls/openssl.h" @@ -1023,8 +1024,8 @@ static CURLcode h3_open_stream(struct Curl_cfilter *cf, goto out; } else { - CURL_TRC_CF(data, cf, "send_request(%s) -> %" PRId64, - data->state.url, rv); + CURL_TRC_CF(data, cf, "send_request(%s) -> %" PRIu64, + Curl_bufref_ptr(&data->state.url), rv); } result = CURLE_SEND_ERROR; goto out; @@ -1038,7 +1039,7 @@ static CURLcode h3_open_stream(struct Curl_cfilter *cf, if(Curl_trc_is_verbose(data)) { infof(data, "[HTTP/3] [%" PRIu64 "] OPENED stream for %s", - stream->id, data->state.url); + stream->id, Curl_bufref_ptr(&data->state.url)); for(i = 0; i < nheader; ++i) { infof(data, "[HTTP/3] [%" PRIu64 "] [%.*s: %.*s]", stream->id, (int)nva[i].name_len, nva[i].name, From 2cb868242dc2ac9cd52ee64987ef51d5964a56f9 Mon Sep 17 00:00:00 2001 From: Patrick Monnerat Date: Wed, 3 Dec 2025 21:13:52 +0100 Subject: [PATCH 182/415] lib: turn state.referer into a struct bufref Closes #19827 --- lib/easy.c | 16 ++++++++++------ lib/getinfo.c | 2 +- lib/http.c | 15 ++++++--------- lib/rtsp.c | 8 +++++--- lib/setopt.c | 6 +----- lib/url.c | 13 +++---------- lib/urldata.h | 3 +-- 7 files changed, 27 insertions(+), 36 deletions(-) diff --git a/lib/easy.c b/lib/easy.c index c18fdd09bf86..68ec3000f856 100644 --- a/lib/easy.c +++ b/lib/easy.c @@ -977,6 +977,7 @@ CURL *curl_easy_duphandle(CURL *d) Curl_hash_str, curlx_str_key_compare, dupeasy_meta_freeentry); curlx_dyn_init(&outcurl->state.headerb, CURL_MAX_HTTP_HEADER); Curl_bufref_init(&outcurl->state.url); + Curl_bufref_init(&outcurl->state.referer); Curl_netrc_init(&outcurl->state.netrc); /* the connection pool is setup on demand */ @@ -1016,16 +1017,19 @@ CURL *curl_easy_duphandle(CURL *d) } #endif - if(Curl_bufref_ptr(&data->state.url)) + if(Curl_bufref_ptr(&data->state.url)) { Curl_bufref_set(&outcurl->state.url, curlx_strdup(Curl_bufref_ptr(&data->state.url)), 0, curl_free); - - if(data->state.referer) { - outcurl->state.referer = curlx_strdup(data->state.referer); - if(!outcurl->state.referer) + if(!Curl_bufref_ptr(&outcurl->state.url)) + goto fail; + } + if(Curl_bufref_ptr(&data->state.referer)) { + Curl_bufref_set(&outcurl->state.referer, + curlx_strdup(Curl_bufref_ptr(&data->state.referer)), 0, + curl_free); + if(!Curl_bufref_ptr(&outcurl->state.referer)) goto fail; - outcurl->state.referer_alloc = TRUE; } /* Reinitialize an SSL engine for the new handle diff --git a/lib/getinfo.c b/lib/getinfo.c index 59dc19877742..82c701e07c67 100644 --- a/lib/getinfo.c +++ b/lib/getinfo.c @@ -148,7 +148,7 @@ static CURLcode getinfo_char(struct Curl_easy *data, CURLINFO info, break; case CURLINFO_REFERER: /* Return the referrer header for this request, or NULL if unset */ - *param_charp = data->state.referer; + *param_charp = Curl_bufref_ptr(&data->state.referer); break; case CURLINFO_PRIMARY_IP: /* Return the ip address of the most recent (primary) connection */ diff --git a/lib/http.c b/lib/http.c index ae7458572b6a..afe37da5b660 100644 --- a/lib/http.c +++ b/lib/http.c @@ -1235,11 +1235,7 @@ CURLcode Curl_http_follow(struct Curl_easy *data, const char *newurl, /* We are asked to automatically set the previous URL as the referer when we get the next URL. We pick the ->url field, which may or may not be 100% correct */ - - if(data->state.referer_alloc) { - Curl_safefree(data->state.referer); - data->state.referer_alloc = FALSE; - } + Curl_bufref_free(&data->state.referer); /* Make a copy of the URL without credentials and fragment */ u = curl_url(); @@ -1262,8 +1258,7 @@ CURLcode Curl_http_follow(struct Curl_easy *data, const char *newurl, if(uc || !referer) return CURLE_OUT_OF_MEMORY; - data->state.referer = referer; - data->state.referer_alloc = TRUE; /* yes, free this later */ + Curl_bufref_set(&data->state.referer, referer, 0, curl_free); } } } @@ -2867,8 +2862,10 @@ static CURLcode http_add_hd(struct Curl_easy *data, case H1_HD_REFERER: Curl_safefree(data->state.aptr.ref); - if(data->state.referer && !Curl_checkheaders(data, STRCONST("Referer"))) - result = curlx_dyn_addf(req, "Referer: %s\r\n", data->state.referer); + if(Curl_bufref_ptr(&data->state.referer) && + !Curl_checkheaders(data, STRCONST("Referer"))) + result = curlx_dyn_addf(req, "Referer: %s\r\n", + Curl_bufref_ptr(&data->state.referer)); break; #ifndef CURL_DISABLE_PROXY diff --git a/lib/rtsp.c b/lib/rtsp.c index ee5d822a5404..0a807899f9a9 100644 --- a/lib/rtsp.c +++ b/lib/rtsp.c @@ -40,6 +40,7 @@ #include "connect.h" #include "cfilters.h" #include "strdup.h" +#include "bufref.h" #include "curlx/strparse.h" @@ -536,9 +537,10 @@ static CURLcode rtsp_do(struct Curl_easy *data, bool *done) /* Referrer */ Curl_safefree(data->state.aptr.ref); - if(data->state.referer && !Curl_checkheaders(data, STRCONST("Referer"))) - data->state.aptr.ref = curl_maprintf("Referer: %s\r\n", - data->state.referer); + if(Curl_bufref_ptr(&data->state.referer) && + !Curl_checkheaders(data, STRCONST("Referer"))) + data->state.aptr.ref = + curl_maprintf("Referer: %s\r\n", Curl_bufref_ptr(&data->state.referer)); p_referrer = data->state.aptr.ref; diff --git a/lib/setopt.c b/lib/setopt.c index bcaf3fc2ae28..476506dad4dc 100644 --- a/lib/setopt.c +++ b/lib/setopt.c @@ -1754,12 +1754,8 @@ static CURLcode setopt_cptr(struct Curl_easy *data, CURLoption option, /* * String to set in the HTTP Referer: field. */ - if(data->state.referer_alloc) { - Curl_safefree(data->state.referer); - data->state.referer_alloc = FALSE; - } result = Curl_setstropt(&s->str[STRING_SET_REFERER], ptr); - data->state.referer = s->str[STRING_SET_REFERER]; + Curl_bufref_set(&data->state.referer, s->str[STRING_SET_REFERER], 0, NULL); break; case CURLOPT_USERAGENT: diff --git a/lib/url.c b/lib/url.c index 65161d7e2488..64ad16a1ae81 100644 --- a/lib/url.c +++ b/lib/url.c @@ -180,11 +180,7 @@ void Curl_freeset(struct Curl_easy *data) Curl_safefree(data->set.blobs[j]); } - if(data->state.referer_alloc) { - Curl_safefree(data->state.referer); - data->state.referer_alloc = FALSE; - } - data->state.referer = NULL; + Curl_bufref_free(&data->state.referer); Curl_bufref_free(&data->state.url); Curl_mime_cleanpart(&data->set.mimepost); @@ -271,11 +267,7 @@ CURLcode Curl_close(struct Curl_easy **datap) Curl_safefree(data->state.first_host); Curl_ssl_free_certinfo(data); - if(data->state.referer_alloc) { - Curl_safefree(data->state.referer); - data->state.referer_alloc = FALSE; - } - data->state.referer = NULL; + Curl_bufref_free(&data->state.referer); up_free(data); curlx_dyn_free(&data->state.headerb); @@ -514,6 +506,7 @@ CURLcode Curl_open(struct Curl_easy **curl) Curl_hash_str, curlx_str_key_compare, easy_meta_freeentry); curlx_dyn_init(&data->state.headerb, CURL_MAX_HTTP_HEADER); Curl_bufref_init(&data->state.url); + Curl_bufref_init(&data->state.referer); Curl_req_init(&data->req); Curl_initinfo(data); #ifndef CURL_DISABLE_HTTP diff --git a/lib/urldata.h b/lib/urldata.h index 554e002020ad..76aefec01ec7 100644 --- a/lib/urldata.h +++ b/lib/urldata.h @@ -1027,7 +1027,7 @@ struct UrlState { CURLU *uh; /* URL handle for the current parsed URL */ struct urlpieces up; struct bufref url; /* work URL, initially copied from UserDefined */ - char *referer; /* referer string */ + struct bufref referer; /* referer string */ struct curl_slist *resolve; /* set to point to the set.resolve list when this should be dealt with in pretransfer */ #ifndef CURL_DISABLE_HTTP @@ -1123,7 +1123,6 @@ struct UrlState { #ifdef CURL_LIST_ONLY_PROTOCOL BIT(list_only); /* list directory contents */ #endif - BIT(referer_alloc); /* referer string is malloc()ed */ BIT(wildcard_resolve); /* Set to true if any resolve change is a wildcard */ BIT(upload); /* upload request */ BIT(internal); /* internal: true if this easy handle was created for From fe7703a0b398458eea2023ae802320eb1c5e401e Mon Sep 17 00:00:00 2001 From: Patrick Monnerat Date: Wed, 3 Dec 2025 21:52:33 +0100 Subject: [PATCH 183/415] formdata: use struct bufref for maybe-dynamic fields. Lengths are not stored in the structures, as they may be given before the data locations. Closes #19827 --- lib/formdata.c | 312 +++++++++++++++++++++---------------------------- lib/formdata.h | 24 ++-- 2 files changed, 141 insertions(+), 195 deletions(-) diff --git a/lib/formdata.c b/lib/formdata.c index e51bf14b6323..880f804dc6c9 100644 --- a/lib/formdata.c +++ b/lib/formdata.c @@ -37,6 +37,7 @@ struct Curl_easy; #include "sendf.h" #include "strdup.h" #include "rand.h" +#include "bufref.h" #include "curlx/fopen.h" #include "curlx/warnless.h" @@ -66,23 +67,23 @@ static struct curl_httppost *AddHttpPost(struct FormInfo *src, { struct curl_httppost *post; size_t namelength = src->namelength; - if(!namelength && src->name) - namelength = strlen(src->name); + if(!namelength && Curl_bufref_ptr(&src->name)) + namelength = strlen(Curl_bufref_ptr(&src->name)); if((src->bufferlength > LONG_MAX) || (namelength > LONG_MAX)) /* avoid overflow in typecasts below */ return NULL; post = curlx_calloc(1, sizeof(struct curl_httppost)); if(post) { - post->name = src->name; + post->name = CURL_UNCONST(Curl_bufref_ptr(&src->name)); post->namelength = (long)namelength; - post->contents = src->value; + post->contents = CURL_UNCONST(Curl_bufref_ptr(&src->value)); post->contentlen = src->contentslength; post->buffer = src->buffer; post->bufferlength = (long)src->bufferlength; - post->contenttype = src->contenttype; + post->contenttype = CURL_UNCONST(Curl_bufref_ptr(&src->contenttype)); post->flags = src->flags | CURL_HTTPPOST_LARGE; post->contentheader = src->contentheader; - post->showfilename = src->showfilename; + post->showfilename = CURL_UNCONST(Curl_bufref_ptr(&src->showfilename)); post->userp = src->userp; } else @@ -107,60 +108,63 @@ static struct curl_httppost *AddHttpPost(struct FormInfo *src, return post; } +/* Allocate and initialize a new FormInfo structure. */ +static struct FormInfo *NewFormInfo(void) +{ + struct FormInfo *form_info = curlx_calloc(1, sizeof(struct FormInfo)); + + if(form_info) { + Curl_bufref_init(&form_info->name); + Curl_bufref_init(&form_info->value); + Curl_bufref_init(&form_info->contenttype); + Curl_bufref_init(&form_info->showfilename); + } + + return form_info; +} + +/* Replace the target field data by a dynamic copy of it. */ +static CURLcode FormInfoCopyField(struct bufref *field, size_t len) +{ + const char *value = Curl_bufref_ptr(field); + CURLcode result = CURLE_OK; + + if(value) { + if(!len) + len = strlen(value); + result = Curl_bufref_memdup(field, value, len); + } + + return result; +} + /*************************************************************************** * * AddFormInfo() * - * Adds a FormInfo structure to the list presented by parent_form_info. - * - * Returns newly allocated FormInfo on success and NULL if malloc failed/ - * parent_form_info is NULL. + * Adds a FormInfo structure to the list presented by parent. * ***************************************************************************/ -static struct FormInfo *AddFormInfo(char *value, - char *contenttype, - struct FormInfo *parent_form_info) +static void AddFormInfo(struct FormInfo *form_info, struct FormInfo *parent) { - struct FormInfo *form_info; - form_info = curlx_calloc(1, sizeof(struct FormInfo)); - if(!form_info) - return NULL; - if(value) - form_info->value = value; - if(contenttype) - form_info->contenttype = contenttype; - form_info->flags = HTTPPOST_FILENAME; + form_info->flags |= HTTPPOST_FILENAME; - if(parent_form_info) { + if(parent) { /* now, point our 'more' to the original 'more' */ - form_info->more = parent_form_info->more; + form_info->more = parent->more; /* then move the original 'more' to point to ourselves */ - parent_form_info->more = form_info; + parent->more = form_info; } - - return form_info; } static void free_formlist(struct FormInfo *ptr) { for(; ptr != NULL; ptr = ptr->more) { - if(ptr->name_alloc) { - Curl_safefree(ptr->name); - ptr->name_alloc = FALSE; - } - if(ptr->value_alloc) { - Curl_safefree(ptr->value); - ptr->value_alloc = FALSE; - } - if(ptr->contenttype_alloc) { - Curl_safefree(ptr->contenttype); - ptr->contenttype_alloc = FALSE; - } - if(ptr->showfilename_alloc) { - Curl_safefree(ptr->showfilename); - ptr->showfilename_alloc = FALSE; - } + Curl_bufref_free(&ptr->name); + Curl_bufref_free(&ptr->value); + Curl_bufref_free(&ptr->contenttype); + Curl_bufref_free(&ptr->showfilename); } } @@ -227,7 +231,9 @@ static CURLFORMcode FormAddCheck(struct FormInfo *first_form, * alright add the HttpPost item otherwise set retval accordingly */ for(form = first_form; form != NULL; form = form->more) { - if(((!form->name || !form->value) && !post) || + const char *name = Curl_bufref_ptr(&form->name); + + if(((!name || !Curl_bufref_ptr(&form->value)) && !post) || (form->contentslength && (form->flags & HTTPPOST_FILENAME)) || ((form->flags & HTTPPOST_FILENAME) && @@ -244,62 +250,42 @@ static CURLFORMcode FormAddCheck(struct FormInfo *first_form, } if(((form->flags & HTTPPOST_FILENAME) || (form->flags & HTTPPOST_BUFFER)) && - !form->contenttype) { - char *f = (form->flags & HTTPPOST_BUFFER) ? - form->showfilename : form->value; - char const *type; - type = Curl_mime_contenttype(f); + !Curl_bufref_ptr(&form->contenttype)) { + const char *f = Curl_bufref_ptr((form->flags & HTTPPOST_BUFFER) ? + &form->showfilename : &form->value); + const char *type = Curl_mime_contenttype(f); if(!type) type = prevtype; if(!type) type = FILE_CONTENTTYPE_DEFAULT; /* our contenttype is missing */ - form->contenttype = curlx_strdup(type); - if(!form->contenttype) + if(Curl_bufref_memdup(&form->contenttype, type, strlen(type))) return CURL_FORMADD_MEMORY; - - form->contenttype_alloc = TRUE; } - if(form->name && form->namelength) { - if(memchr(form->name, 0, form->namelength)) + if(name && form->namelength) { + if(memchr(name, 0, form->namelength)) return CURL_FORMADD_NULL; } - if(!(form->flags & HTTPPOST_PTRNAME) && form->name) { + if(!(form->flags & HTTPPOST_PTRNAME)) { /* Note that there is small risk that form->name is NULL here if the app passed in a bad combo, so we check for that. */ - - /* copy name (without strdup; possibly not null-terminated) */ - char *dupname = Curl_memdup0(form->name, form->namelength ? - form->namelength : strlen(form->name)); - if(!dupname) + if(FormInfoCopyField(&form->name, form->namelength)) return CURL_FORMADD_MEMORY; - - form->name = dupname; - form->name_alloc = TRUE; } if(!(form->flags & (HTTPPOST_FILENAME | HTTPPOST_READFILE | HTTPPOST_PTRCONTENTS | HTTPPOST_PTRBUFFER | - HTTPPOST_CALLBACK)) && form->value) { - /* copy value (without strdup; possibly contains null characters) */ - size_t clen = (size_t)form->contentslength; - if(!clen) - clen = strlen(form->value) + 1; - - form->value = Curl_memdup(form->value, clen); - - if(!form->value) + HTTPPOST_CALLBACK))) { + if(FormInfoCopyField(&form->value, (size_t) form->contentslength)) return CURL_FORMADD_MEMORY; - - form->value_alloc = TRUE; } post = AddHttpPost(form, post, httppost, last_post); if(!post) return CURL_FORMADD_MEMORY; - if(form->contenttype) - prevtype = form->contenttype; + if(Curl_bufref_ptr(&form->contenttype)) + prevtype = Curl_bufref_ptr(&form->contenttype); } return CURL_FORMADD_OK; @@ -329,15 +315,17 @@ static CURLFORMcode FormAdd(struct curl_httppost **httppost, struct curl_httppost *newchain = NULL; struct curl_httppost *lastnode = NULL; - /* This is a state variable, that if TRUE means that we are parsing an - array that we got passed to us. If FALSE we are parsing the input - va_list arguments. */ - bool array_state = FALSE; +#define form_ptr_arg(t) (forms ? (t) (void *) avalue : va_arg(params, t)) +#ifdef HAVE_STDINT_H +#define form_int_arg(t) (forms ? (t) (uintptr_t) avalue : va_arg(params, t)) +#else +#define form_int_arg(t) (forms ? (t) (void *) avalue : va_arg(params, t)) +#endif /* * We need to allocate the first struct to fill in. */ - first_form = curlx_calloc(1, sizeof(struct FormInfo)); + first_form = NewFormInfo(); if(!first_form) return CURL_FORMADD_MEMORY; @@ -349,7 +337,7 @@ static CURLFORMcode FormAdd(struct curl_httppost **httppost, while(retval == CURL_FORMADD_OK) { /* first see if we have more parts of the array param */ - if(array_state && forms) { + if(forms) { /* get the upcoming option from the given array */ option = forms->option; avalue = (char *)CURL_UNCONST(forms->value); @@ -357,7 +345,7 @@ static CURLFORMcode FormAdd(struct curl_httppost **httppost, forms++; /* advance this to next entry */ if(CURLFORM_END == option) { /* end of array state */ - array_state = FALSE; + forms = NULL; continue; } } @@ -372,14 +360,12 @@ static CURLFORMcode FormAdd(struct curl_httppost **httppost, switch(option) { case CURLFORM_ARRAY: - if(array_state) + if(forms) /* we do not support an array from within an array */ retval = CURL_FORMADD_ILLEGAL_ARRAY; else { forms = va_arg(params, struct curl_forms *); - if(forms) - array_state = TRUE; - else + if(!forms) retval = CURL_FORMADD_NULL; } break; @@ -388,17 +374,15 @@ static CURLFORMcode FormAdd(struct curl_httppost **httppost, * Set the Name property. */ case CURLFORM_PTRNAME: - curr->flags |= HTTPPOST_PTRNAME; /* fall through */ - + curr->flags |= HTTPPOST_PTRNAME; FALLTHROUGH(); case CURLFORM_COPYNAME: - if(curr->name) + if(Curl_bufref_ptr(&curr->name)) retval = CURL_FORMADD_OPTION_TWICE; else { - if(!array_state) - avalue = va_arg(params, char *); + avalue = form_ptr_arg(char *); if(avalue) - curr->name = avalue; /* store for the moment */ + Curl_bufref_set(&curr->name, avalue, 0, NULL); /* No copy yet. */ else retval = CURL_FORMADD_NULL; } @@ -407,8 +391,7 @@ static CURLFORMcode FormAdd(struct curl_httppost **httppost, if(curr->namelength) retval = CURL_FORMADD_OPTION_TWICE; else - curr->namelength = - array_state ? (size_t)avalue : (size_t)va_arg(params, long); + curr->namelength = (size_t) form_int_arg(long); break; /* @@ -418,26 +401,23 @@ static CURLFORMcode FormAdd(struct curl_httppost **httppost, curr->flags |= HTTPPOST_PTRCONTENTS; FALLTHROUGH(); case CURLFORM_COPYCONTENTS: - if(curr->value) + if(Curl_bufref_ptr(&curr->value)) retval = CURL_FORMADD_OPTION_TWICE; else { - if(!array_state) - avalue = va_arg(params, char *); + avalue = form_ptr_arg(char *); if(avalue) - curr->value = avalue; /* store for the moment */ + Curl_bufref_set(&curr->value, avalue, 0, NULL); /* No copy yet. */ else retval = CURL_FORMADD_NULL; } break; case CURLFORM_CONTENTSLENGTH: - curr->contentslength = - array_state ? (size_t)avalue : (size_t)va_arg(params, long); + curr->contentslength = (curl_off_t)(size_t) form_int_arg(long); break; case CURLFORM_CONTENTLEN: curr->flags |= CURL_HTTPPOST_LARGE; - curr->contentslength = - array_state ? (curl_off_t)(size_t)avalue : va_arg(params, curl_off_t); + curr->contentslength = form_int_arg(curl_off_t); break; /* Get contents from a given filename */ @@ -445,16 +425,12 @@ static CURLFORMcode FormAdd(struct curl_httppost **httppost, if(curr->flags & (HTTPPOST_PTRCONTENTS | HTTPPOST_READFILE)) retval = CURL_FORMADD_OPTION_TWICE; else { - if(!array_state) - avalue = va_arg(params, char *); + avalue = form_ptr_arg(char *); if(avalue) { - curr->value = curlx_strdup(avalue); - if(!curr->value) + if(Curl_bufref_memdup(&curr->value, avalue, strlen(avalue))) retval = CURL_FORMADD_MEMORY; - else { + else curr->flags |= HTTPPOST_READFILE; - curr->value_alloc = TRUE; - } } else retval = CURL_FORMADD_NULL; @@ -463,26 +439,20 @@ static CURLFORMcode FormAdd(struct curl_httppost **httppost, /* We upload a file */ case CURLFORM_FILE: - if(!array_state) - avalue = va_arg(params, char *); - - if(curr->value) { + avalue = form_ptr_arg(char *); + if(Curl_bufref_ptr(&curr->value)) { if(curr->flags & HTTPPOST_FILENAME) { if(avalue) { - char *fname = curlx_strdup(avalue); - if(!fname) + form = NewFormInfo(); + if(!form || + Curl_bufref_memdup(&form->value, avalue, strlen(avalue))) { + curlx_free(form); retval = CURL_FORMADD_MEMORY; + } else { - form = AddFormInfo(fname, NULL, curr); - if(!form) { - curlx_free(fname); - retval = CURL_FORMADD_MEMORY; - } - else { - form->value_alloc = TRUE; - curr = form; - form = NULL; - } + AddFormInfo(form, curr); + curr = form; + form = NULL; } } else @@ -493,13 +463,10 @@ static CURLFORMcode FormAdd(struct curl_httppost **httppost, } else { if(avalue) { - curr->value = curlx_strdup(avalue); - if(!curr->value) + if(Curl_bufref_memdup(&curr->value, avalue, strlen(avalue))) retval = CURL_FORMADD_MEMORY; - else { + else curr->flags |= HTTPPOST_FILENAME; - curr->value_alloc = TRUE; - } } else retval = CURL_FORMADD_NULL; @@ -511,12 +478,11 @@ static CURLFORMcode FormAdd(struct curl_httppost **httppost, if(curr->buffer) retval = CURL_FORMADD_OPTION_TWICE; else { - if(!array_state) - avalue = va_arg(params, char *); + avalue = form_ptr_arg(char *); if(avalue) { curr->buffer = avalue; /* store for the moment */ - curr->value = avalue; /* make it non-NULL to be accepted - as fine */ + /* Make value non-NULL to be accepted as fine */ + Curl_bufref_set(&curr->value, avalue, 0, NULL); } else retval = CURL_FORMADD_NULL; @@ -527,8 +493,7 @@ static CURLFORMcode FormAdd(struct curl_httppost **httppost, if(curr->bufferlength) retval = CURL_FORMADD_OPTION_TWICE; else - curr->bufferlength = - array_state ? (size_t)avalue : (size_t)va_arg(params, long); + curr->bufferlength = (size_t) form_int_arg(long); break; case CURLFORM_STREAM: @@ -536,14 +501,13 @@ static CURLFORMcode FormAdd(struct curl_httppost **httppost, if(curr->userp) retval = CURL_FORMADD_OPTION_TWICE; else { - if(!array_state) - avalue = va_arg(params, char *); + avalue = form_ptr_arg(char *); if(avalue) { curr->userp = avalue; - curr->value = avalue; /* this is not strictly true but we derive a - value from this later on and we need this - non-NULL to be accepted as a fine form - part */ + /* The following line is not strictly true but we derive a value + from this later on and we need this non-NULL to be accepted as + a fine form part */ + Curl_bufref_set(&curr->value, avalue, 0, NULL); } else retval = CURL_FORMADD_NULL; @@ -551,25 +515,20 @@ static CURLFORMcode FormAdd(struct curl_httppost **httppost, break; case CURLFORM_CONTENTTYPE: - if(!array_state) - avalue = va_arg(params, char *); - if(curr->contenttype) { + avalue = form_ptr_arg(char *); + if(Curl_bufref_ptr(&curr->contenttype)) { if(curr->flags & HTTPPOST_FILENAME) { if(avalue) { - char *type = curlx_strdup(avalue); - if(!type) + form = NewFormInfo(); + if(!form || Curl_bufref_memdup(&form->contenttype, avalue, + strlen(avalue))) { + curlx_free(form); retval = CURL_FORMADD_MEMORY; + } else { - form = AddFormInfo(NULL, type, curr); - if(!form) { - curlx_free(type); - retval = CURL_FORMADD_MEMORY; - } - else { - form->contenttype_alloc = TRUE; - curr = form; - form = NULL; - } + AddFormInfo(form, curr); + curr = form; + form = NULL; } } else @@ -578,25 +537,18 @@ static CURLFORMcode FormAdd(struct curl_httppost **httppost, else retval = CURL_FORMADD_OPTION_TWICE; } - else { - if(avalue) { - curr->contenttype = curlx_strdup(avalue); - if(!curr->contenttype) - retval = CURL_FORMADD_MEMORY; - else - curr->contenttype_alloc = TRUE; - } - else - retval = CURL_FORMADD_NULL; + else if(avalue) { + if(Curl_bufref_memdup(&curr->contenttype, avalue, strlen(avalue))) + retval = CURL_FORMADD_MEMORY; } + else + retval = CURL_FORMADD_NULL; break; case CURLFORM_CONTENTHEADER: { /* this "cast increases required alignment of target type" but we consider it OK anyway */ - struct curl_slist *list = array_state ? - (struct curl_slist *)(void *)avalue : - va_arg(params, struct curl_slist *); + struct curl_slist *list = form_ptr_arg(struct curl_slist *); if(curr->contentheader) retval = CURL_FORMADD_OPTION_TWICE; @@ -607,17 +559,11 @@ static CURLFORMcode FormAdd(struct curl_httppost **httppost, } case CURLFORM_FILENAME: case CURLFORM_BUFFER: - if(!array_state) - avalue = va_arg(params, char *); - if(curr->showfilename) + avalue = form_ptr_arg(char *); + if(Curl_bufref_ptr(&curr->showfilename)) retval = CURL_FORMADD_OPTION_TWICE; - else { - curr->showfilename = curlx_strdup(avalue); - if(!curr->showfilename) - retval = CURL_FORMADD_MEMORY; - else - curr->showfilename_alloc = TRUE; - } + else if(Curl_bufref_memdup(&curr->showfilename, avalue, strlen(avalue))) + retval = CURL_FORMADD_MEMORY; break; default: @@ -656,6 +602,8 @@ static CURLFORMcode FormAdd(struct curl_httppost **httppost, free_chain(newchain); return retval; +#undef form_ptr_arg +#undef form_int_arg } /* diff --git a/lib/formdata.h b/lib/formdata.h index e80b83bbf491..4ece7d06e71e 100644 --- a/lib/formdata.h +++ b/lib/formdata.h @@ -28,25 +28,23 @@ #ifndef CURL_DISABLE_FORM_API +#include "bufref.h" + /* used by FormAdd for temporary storage */ struct FormInfo { - char *name; - size_t namelength; - char *value; - curl_off_t contentslength; - char *contenttype; + struct bufref name; + struct bufref value; + struct bufref contenttype; + struct bufref showfilename; /* The filename to show. If not set, the actual + filename will be used */ char *buffer; /* pointer to existing buffer used for file upload */ - size_t bufferlength; - char *showfilename; /* The filename to show. If not set, the actual - filename will be used */ char *userp; /* pointer for the read callback */ - struct curl_slist *contentheader; struct FormInfo *more; + struct curl_slist *contentheader; + curl_off_t contentslength; + size_t namelength; + size_t bufferlength; unsigned char flags; - BIT(name_alloc); - BIT(value_alloc); - BIT(contenttype_alloc); - BIT(showfilename_alloc); }; CURLcode Curl_getformdata(CURL *data, From 1def38003299bf0fbbaf8b5ed34422205166d085 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 4 Dec 2025 16:20:25 +0100 Subject: [PATCH 184/415] bufref: rename *memdup() to *memdup0() To make it clearer to readers of the code that the resulting dup also has a null terminator. Something a "normal" memdup() does not provide. Closes #19833 --- docs/internals/BUFREF.md | 5 +++-- lib/bufref.c | 2 +- lib/bufref.h | 2 +- lib/formdata.c | 16 ++++++++-------- lib/vauth/krb5_gssapi.c | 4 ++-- lib/vauth/krb5_sspi.c | 2 +- lib/vauth/ntlm.c | 2 +- lib/vauth/ntlm_sspi.c | 2 +- tests/unit/unit1661.c | 4 ++-- 9 files changed, 20 insertions(+), 19 deletions(-) diff --git a/docs/internals/BUFREF.md b/docs/internals/BUFREF.md index 686a092aecc3..cd101f08a9a3 100644 --- a/docs/internals/BUFREF.md +++ b/docs/internals/BUFREF.md @@ -54,10 +54,11 @@ specified as `NULL`: this is the case when the referenced buffer is static. if `buffer` is NULL, `length` must be zero. -## `memdup` +## `memdup0` ```c -CURLcode Curl_bufref_memdup(struct bufref *br, const void *data, size_t length); +CURLcode Curl_bufref_memdup0(struct bufref *br, const void *data, + size_t length); ``` Releases the previously referenced buffer, then duplicates the `length`-byte diff --git a/lib/bufref.c b/lib/bufref.c index 8dcd3592dbe4..8f52d48d20a5 100644 --- a/lib/bufref.c +++ b/lib/bufref.c @@ -117,7 +117,7 @@ size_t Curl_bufref_len(const struct bufref *br) return br->len; } -CURLcode Curl_bufref_memdup(struct bufref *br, const void *ptr, size_t len) +CURLcode Curl_bufref_memdup0(struct bufref *br, const void *ptr, size_t len) { unsigned char *cpy = NULL; diff --git a/lib/bufref.h b/lib/bufref.h index b8ffe383478b..abf1d617df5a 100644 --- a/lib/bufref.h +++ b/lib/bufref.h @@ -42,7 +42,7 @@ void Curl_bufref_set(struct bufref *br, const void *ptr, size_t len, const char *Curl_bufref_ptr(const struct bufref *br); const unsigned char *Curl_bufref_uptr(const struct bufref *br); size_t Curl_bufref_len(const struct bufref *br); -CURLcode Curl_bufref_memdup(struct bufref *br, const void *ptr, size_t len); +CURLcode Curl_bufref_memdup0(struct bufref *br, const void *ptr, size_t len); void Curl_bufref_free(struct bufref *br); #endif diff --git a/lib/formdata.c b/lib/formdata.c index 880f804dc6c9..d5f6776a3d5f 100644 --- a/lib/formdata.c +++ b/lib/formdata.c @@ -132,7 +132,7 @@ static CURLcode FormInfoCopyField(struct bufref *field, size_t len) if(value) { if(!len) len = strlen(value); - result = Curl_bufref_memdup(field, value, len); + result = Curl_bufref_memdup0(field, value, len); } return result; @@ -260,7 +260,7 @@ static CURLFORMcode FormAddCheck(struct FormInfo *first_form, type = FILE_CONTENTTYPE_DEFAULT; /* our contenttype is missing */ - if(Curl_bufref_memdup(&form->contenttype, type, strlen(type))) + if(Curl_bufref_memdup0(&form->contenttype, type, strlen(type))) return CURL_FORMADD_MEMORY; } if(name && form->namelength) { @@ -427,7 +427,7 @@ static CURLFORMcode FormAdd(struct curl_httppost **httppost, else { avalue = form_ptr_arg(char *); if(avalue) { - if(Curl_bufref_memdup(&curr->value, avalue, strlen(avalue))) + if(Curl_bufref_memdup0(&curr->value, avalue, strlen(avalue))) retval = CURL_FORMADD_MEMORY; else curr->flags |= HTTPPOST_READFILE; @@ -445,7 +445,7 @@ static CURLFORMcode FormAdd(struct curl_httppost **httppost, if(avalue) { form = NewFormInfo(); if(!form || - Curl_bufref_memdup(&form->value, avalue, strlen(avalue))) { + Curl_bufref_memdup0(&form->value, avalue, strlen(avalue))) { curlx_free(form); retval = CURL_FORMADD_MEMORY; } @@ -463,7 +463,7 @@ static CURLFORMcode FormAdd(struct curl_httppost **httppost, } else { if(avalue) { - if(Curl_bufref_memdup(&curr->value, avalue, strlen(avalue))) + if(Curl_bufref_memdup0(&curr->value, avalue, strlen(avalue))) retval = CURL_FORMADD_MEMORY; else curr->flags |= HTTPPOST_FILENAME; @@ -520,7 +520,7 @@ static CURLFORMcode FormAdd(struct curl_httppost **httppost, if(curr->flags & HTTPPOST_FILENAME) { if(avalue) { form = NewFormInfo(); - if(!form || Curl_bufref_memdup(&form->contenttype, avalue, + if(!form || Curl_bufref_memdup0(&form->contenttype, avalue, strlen(avalue))) { curlx_free(form); retval = CURL_FORMADD_MEMORY; @@ -538,7 +538,7 @@ static CURLFORMcode FormAdd(struct curl_httppost **httppost, retval = CURL_FORMADD_OPTION_TWICE; } else if(avalue) { - if(Curl_bufref_memdup(&curr->contenttype, avalue, strlen(avalue))) + if(Curl_bufref_memdup0(&curr->contenttype, avalue, strlen(avalue))) retval = CURL_FORMADD_MEMORY; } else @@ -562,7 +562,7 @@ static CURLFORMcode FormAdd(struct curl_httppost **httppost, avalue = form_ptr_arg(char *); if(Curl_bufref_ptr(&curr->showfilename)) retval = CURL_FORMADD_OPTION_TWICE; - else if(Curl_bufref_memdup(&curr->showfilename, avalue, strlen(avalue))) + else if(Curl_bufref_memdup0(&curr->showfilename, avalue, strlen(avalue))) retval = CURL_FORMADD_MEMORY; break; diff --git a/lib/vauth/krb5_gssapi.c b/lib/vauth/krb5_gssapi.c index 7ba21a394184..0c069c70d690 100644 --- a/lib/vauth/krb5_gssapi.c +++ b/lib/vauth/krb5_gssapi.c @@ -154,7 +154,7 @@ CURLcode Curl_auth_create_gssapi_user_message(struct Curl_easy *data, } if(output_token.value && output_token.length) { - result = Curl_bufref_memdup(out, output_token.value, output_token.length); + result = Curl_bufref_memdup0(out, output_token.value, output_token.length); gss_release_buffer(&unused_status, &output_token); } else @@ -285,7 +285,7 @@ CURLcode Curl_auth_create_gssapi_security_message(struct Curl_easy *data, } /* Return the response. */ - result = Curl_bufref_memdup(out, output_token.value, output_token.length); + result = Curl_bufref_memdup0(out, output_token.value, output_token.length); /* Free the output buffer */ gss_release_buffer(&unused_status, &output_token); diff --git a/lib/vauth/krb5_sspi.c b/lib/vauth/krb5_sspi.c index 21636d59ee3d..32fa44cfcbb9 100644 --- a/lib/vauth/krb5_sspi.c +++ b/lib/vauth/krb5_sspi.c @@ -212,7 +212,7 @@ CURLcode Curl_auth_create_gssapi_user_message(struct Curl_easy *data, } if(resp_buf.cbBuffer) { - result = Curl_bufref_memdup(out, resp_buf.pvBuffer, resp_buf.cbBuffer); + result = Curl_bufref_memdup0(out, resp_buf.pvBuffer, resp_buf.cbBuffer); } else if(mutual_auth) Curl_bufref_set(out, "", 0, NULL); diff --git a/lib/vauth/ntlm.c b/lib/vauth/ntlm.c index 7fd13d8745c1..70d080f5a4ac 100644 --- a/lib/vauth/ntlm.c +++ b/lib/vauth/ntlm.c @@ -831,7 +831,7 @@ CURLcode Curl_auth_create_ntlm_type3_message(struct Curl_easy *data, size += hostlen; /* Return the binary blob. */ - result = Curl_bufref_memdup(out, ntlmbuf, size); + result = Curl_bufref_memdup0(out, ntlmbuf, size); error: curlx_free(ntlmv2resp); /* Free the dynamic buffer allocated for NTLMv2 */ diff --git a/lib/vauth/ntlm_sspi.c b/lib/vauth/ntlm_sspi.c index e4aad6e24f8d..dae7248f73fb 100644 --- a/lib/vauth/ntlm_sspi.c +++ b/lib/vauth/ntlm_sspi.c @@ -316,7 +316,7 @@ CURLcode Curl_auth_create_ntlm_type3_message(struct Curl_easy *data, } /* Return the response. */ - result = Curl_bufref_memdup(out, ntlm->output_token, type_3_buf.cbBuffer); + result = Curl_bufref_memdup0(out, ntlm->output_token, type_3_buf.cbBuffer); Curl_auth_cleanup_ntlm(ntlm); return result; } diff --git a/tests/unit/unit1661.c b/tests/unit/unit1661.c index 569b06760b2b..7f8d1aa76a37 100644 --- a/tests/unit/unit1661.c +++ b/tests/unit/unit1661.c @@ -87,9 +87,9 @@ static CURLcode test_unit1661(const char *arg) fail_unless(Curl_bufref_len(&bufref) == 13, "Wrong data size returned"); /** - * testing Curl_bufref_memdup + * testing Curl_bufref_memdup0 */ - res = Curl_bufref_memdup(&bufref, "1661", 3); + res = Curl_bufref_memdup0(&bufref, "1661", 3); abort_unless(res == CURLE_OK, curl_easy_strerror(res)); fail_unless(freecount == 1, "Destructor not called"); fail_unless((const char *)bufref.ptr != buffer, "Returned pointer not set"); From d7928029fc0a31df03473d5ca9e13b732357febc Mon Sep 17 00:00:00 2001 From: Stefan Eissing Date: Thu, 4 Dec 2025 17:15:33 +0100 Subject: [PATCH 185/415] connection: attached transfer count Since we no longer traverse the transfers attached to a connection, change the sparse bitset to just a `uint32_t` counter. This makes multi_ev the single user of sparse bitsets for transfers using a socket and allocation failures are handled there correctly. Refs #19818 Closes #19836 --- lib/conncache.c | 4 ++-- lib/http2.c | 2 +- lib/multi.c | 18 +++++++++++------- lib/uint-spbset.c | 14 -------------- lib/uint-spbset.h | 3 --- lib/url.c | 15 ++++++--------- lib/urldata.h | 7 ++++--- lib/vquic/curl_ngtcp2.c | 4 ++-- lib/vquic/curl_osslq.c | 2 +- lib/vquic/curl_quiche.c | 4 ++-- 10 files changed, 29 insertions(+), 44 deletions(-) diff --git a/lib/conncache.c b/lib/conncache.c index c50697f177b6..18b760afe052 100644 --- a/lib/conncache.c +++ b/lib/conncache.c @@ -620,7 +620,7 @@ static void cpool_discard_conn(struct cpool *cpool, if(CONN_INUSE(conn) && !aborted) { CURL_TRC_M(data, "[CPOOL] not discarding #%" FMT_OFF_T " still in use by %u transfers", conn->connection_id, - CONN_ATTACHED(conn)); + conn->attached_xfers); return; } @@ -664,7 +664,7 @@ void Curl_conn_terminate(struct Curl_easy *data, * are other users of it */ if(CONN_INUSE(conn) && !aborted) { DEBUGASSERT(0); /* does this ever happen? */ - DEBUGF(infof(data, "Curl_disconnect when inuse: %u", CONN_ATTACHED(conn))); + DEBUGF(infof(data, "conn terminate when inuse: %u", conn->attached_xfers)); return; } diff --git a/lib/http2.c b/lib/http2.c index df38f82cafa0..deed6ece7ee1 100644 --- a/lib/http2.c +++ b/lib/http2.c @@ -2786,7 +2786,7 @@ static CURLcode cf_h2_query(struct Curl_cfilter *cf, CF_DATA_SAVE(save, cf, data); if(!ctx->h2 || !nghttp2_session_check_request_allowed(ctx->h2)) { /* the limit is what we have in use right now */ - effective_max = CONN_ATTACHED(cf->conn); + effective_max = cf->conn->attached_xfers; } else { effective_max = ctx->max_concurrent_streams; diff --git a/lib/multi.c b/lib/multi.c index 3086d61c7489..f87ee012d86b 100644 --- a/lib/multi.c +++ b/lib/multi.c @@ -607,12 +607,11 @@ static void multi_done_locked(struct connectdata *conn, Curl_detach_connection(data); - CURL_TRC_M(data, "multi_done_locked, in use=%u", - Curl_uint32_spbset_count(&conn->xfers_attached)); + CURL_TRC_M(data, "multi_done_locked, in use=%u", conn->attached_xfers); if(CONN_INUSE(conn)) { /* Stop if still used. */ CURL_TRC_M(data, "Connection still in use %u, no more multi_done now!", - Curl_uint32_spbset_count(&conn->xfers_attached)); + conn->attached_xfers); return; } @@ -906,9 +905,13 @@ void Curl_detach_connection(struct Curl_easy *data) { struct connectdata *conn = data->conn; if(conn) { - Curl_uint32_spbset_remove(&conn->xfers_attached, data->mid); - if(Curl_uint32_spbset_empty(&conn->xfers_attached)) - conn->attached_multi = NULL; + /* this should never happen, prevent underflow */ + DEBUGASSERT(conn->attached_xfers); + if(conn->attached_xfers) { + conn->attached_xfers--; + if(!conn->attached_xfers) + conn->attached_multi = NULL; + } } data->conn = NULL; } @@ -924,8 +927,9 @@ void Curl_attach_connection(struct Curl_easy *data, DEBUGASSERT(data); DEBUGASSERT(!data->conn); DEBUGASSERT(conn); + DEBUGASSERT(conn->attached_xfers < UINT32_MAX); data->conn = conn; - Curl_uint32_spbset_add(&conn->xfers_attached, data->mid); + conn->attached_xfers++; /* all attached transfers must be from the same multi */ if(!conn->attached_multi) conn->attached_multi = data->multi; diff --git a/lib/uint-spbset.c b/lib/uint-spbset.c index 84a893e85f5a..e27f66fc7b15 100644 --- a/lib/uint-spbset.c +++ b/lib/uint-spbset.c @@ -61,20 +61,6 @@ uint32_t Curl_uint32_spbset_count(struct uint32_spbset *bset) return n; } -bool Curl_uint32_spbset_empty(struct uint32_spbset *bset) -{ - struct uint32_spbset_chunk *chunk; - uint32_t i; - - for(chunk = &bset->head; chunk; chunk = chunk->next) { - for(i = 0; i < CURL_UINT32_SPBSET_CH_SLOTS; ++i) { - if(chunk->slots[i]) - return FALSE; - } - } - return TRUE; -} - UNITTEST void Curl_uint32_spbset_clear(struct uint32_spbset *bset) { struct uint32_spbset_chunk *next, *chunk; diff --git a/lib/uint-spbset.h b/lib/uint-spbset.h index 8c46ce4aa8ea..0220d0544378 100644 --- a/lib/uint-spbset.h +++ b/lib/uint-spbset.h @@ -61,9 +61,6 @@ void Curl_uint32_spbset_destroy(struct uint32_spbset *bset); /* Get the cardinality of the bitset, e.g. numbers present in the set. */ uint32_t Curl_uint32_spbset_count(struct uint32_spbset *bset); -/* TRUE of bitset is empty */ -bool Curl_uint32_spbset_empty(struct uint32_spbset *bset); - /* Add the number `i` to the bitset. * Numbers can be added more than once, without making a difference. * Returns FALSE if allocations failed. */ diff --git a/lib/url.c b/lib/url.c index 64ad16a1ae81..194810553e18 100644 --- a/lib/url.c +++ b/lib/url.c @@ -561,7 +561,6 @@ void Curl_conn_free(struct Curl_easy *data, struct connectdata *conn) Curl_safefree(conn->unix_domain_socket); #endif Curl_safefree(conn->destination); - Curl_uint32_spbset_destroy(&conn->xfers_attached); Curl_hash_destroy(&conn->meta_hash); curlx_free(conn); /* free all the connection oriented data */ @@ -893,16 +892,16 @@ static bool url_match_multiplex_limits(struct connectdata *conn, if(CONN_INUSE(conn) && m->may_multiplex) { DEBUGASSERT(conn->bits.multiplex); /* If multiplexed, make sure we do not go over concurrency limit */ - if(CONN_ATTACHED(conn) >= + if(conn->attached_xfers >= Curl_multi_max_concurrent_streams(m->data->multi)) { infof(m->data, "client side MAX_CONCURRENT_STREAMS reached" - ", skip (%u)", CONN_ATTACHED(conn)); + ", skip (%u)", conn->attached_xfers); return FALSE; } - if(CONN_ATTACHED(conn) >= + if(conn->attached_xfers >= Curl_conn_get_max_concurrent(m->data, conn, FIRSTSOCKET)) { infof(m->data, "MAX_CONCURRENT_STREAMS reached, skip (%u)", - CONN_ATTACHED(conn)); + conn->attached_xfers); return FALSE; } /* When not multiplexed, we have a match here! */ @@ -1343,6 +1342,7 @@ static struct connectdata *allocate_conn(struct Curl_easy *data) conn->recv_idx = 0; /* default for receiving transfer data */ conn->send_idx = 0; /* default for sending transfer data */ conn->connection_id = -1; /* no ID */ + conn->attached_xfers = 0; conn->remote_port = -1; /* unknown at this point */ /* Store creation time to help future close decision making */ @@ -1382,9 +1382,6 @@ static struct connectdata *allocate_conn(struct Curl_easy *data) conn->connect_only = data->set.connect_only; conn->transport_wanted = TRNSPRT_TCP; /* most of them are TCP streams */ - /* Initialize the attached xfers bitset */ - Curl_uint32_spbset_init(&conn->xfers_attached); - /* Store the local bind parameters that will be used for this connection */ if(data->set.str[STRING_DEVICE]) { conn->localdev = curlx_strdup(data->set.str[STRING_DEVICE]); @@ -3806,7 +3803,7 @@ CURLcode Curl_connect(struct Curl_easy *data, DEBUGASSERT(conn); Curl_pgrsTime(data, TIMER_POSTQUEUE); if(reused) { - if(CONN_ATTACHED(conn) > 1) + if(conn->attached_xfers > 1) /* multiplexed */ *protocol_done = TRUE; } diff --git a/lib/urldata.h b/lib/urldata.h index 76aefec01ec7..899dfff0f10b 100644 --- a/lib/urldata.h +++ b/lib/urldata.h @@ -618,8 +618,7 @@ struct connectdata { handle is still used by one or more easy handles and can only used by any other easy handle without careful consideration (== only for multiplexing) and it cannot be used by another multi handle! */ -#define CONN_INUSE(c) (!Curl_uint32_spbset_empty(&(c)->xfers_attached)) -#define CONN_ATTACHED(c) Curl_uint32_spbset_count(&(c)->xfers_attached) +#define CONN_INUSE(c) (!!(c)->attached_xfers) /**** Fields set when inited and not modified again */ curl_off_t connection_id; /* Contains a unique number to make it easier to @@ -679,7 +678,6 @@ struct connectdata { was used on this connection. */ struct curltime keepalive; - struct uint32_spbset xfers_attached; /* mids of attached transfers */ /* A connection cache from a SHARE might be used in several multi handles. * We MUST not reuse connections that are running in another multi, * for concurrency reasons. That multi might run in another thread. @@ -721,6 +719,9 @@ struct connectdata { int remote_port; /* the remote port, not the proxy port! */ int conn_to_port; /* the remote port to connect to. valid only if bits.conn_to_port is set */ + + uint32_t attached_xfers; /* # of attached easy handles */ + #ifdef USE_IPV6 unsigned int scope_id; /* Scope id for IPv6 */ #endif diff --git a/lib/vquic/curl_ngtcp2.c b/lib/vquic/curl_ngtcp2.c index cf7b95bf6f94..690ef252a037 100644 --- a/lib/vquic/curl_ngtcp2.c +++ b/lib/vquic/curl_ngtcp2.c @@ -2718,7 +2718,7 @@ static CURLcode cf_ngtcp2_query(struct Curl_cfilter *cf, } else if(ctx->max_bidi_streams) { uint64_t avail_bidi_streams = 0; - uint64_t max_streams = CONN_ATTACHED(cf->conn); + uint64_t max_streams = cf->conn->attached_xfers; if(ctx->max_bidi_streams > ctx->used_bidi_streams) avail_bidi_streams = ctx->max_bidi_streams - ctx->used_bidi_streams; max_streams += avail_bidi_streams; @@ -2728,7 +2728,7 @@ static CURLcode cf_ngtcp2_query(struct Curl_cfilter *cf, *pres1 = (int)Curl_multi_max_concurrent_streams(data->multi); CURL_TRC_CF(data, cf, "query conn[%" FMT_OFF_T "]: " "MAX_CONCURRENT -> %d (%u in use)", - cf->conn->connection_id, *pres1, CONN_ATTACHED(cf->conn)); + cf->conn->connection_id, *pres1, cf->conn->attached_xfers); CF_DATA_RESTORE(cf, save); return CURLE_OK; } diff --git a/lib/vquic/curl_osslq.c b/lib/vquic/curl_osslq.c index 79bd1180dcf6..73cea21a15dc 100644 --- a/lib/vquic/curl_osslq.c +++ b/lib/vquic/curl_osslq.c @@ -2323,7 +2323,7 @@ static CURLcode cf_osslq_query(struct Curl_cfilter *cf, return CURLE_HTTP3; } /* we report avail + in_use */ - v += CONN_ATTACHED(cf->conn); + v += cf->conn->attached_xfers; *pres1 = (v > INT_MAX) ? INT_MAX : (int)v; #else *pres1 = 100; diff --git a/lib/vquic/curl_quiche.c b/lib/vquic/curl_quiche.c index a35ffbec65e8..7082d55916b8 100644 --- a/lib/vquic/curl_quiche.c +++ b/lib/vquic/curl_quiche.c @@ -1493,14 +1493,14 @@ static CURLcode cf_quiche_query(struct Curl_cfilter *cf, switch(query) { case CF_QUERY_MAX_CONCURRENT: { - uint64_t max_streams = CONN_ATTACHED(cf->conn); + uint64_t max_streams = cf->conn->attached_xfers; if(!ctx->goaway && ctx->qconn) { max_streams += quiche_conn_peer_streams_left_bidi(ctx->qconn); } *pres1 = (max_streams > INT_MAX) ? INT_MAX : (int)max_streams; CURL_TRC_CF(data, cf, "query conn[%" FMT_OFF_T "]: " "MAX_CONCURRENT -> %d (%u in use)", - cf->conn->connection_id, *pres1, CONN_ATTACHED(cf->conn)); + cf->conn->connection_id, *pres1, cf->conn->attached_xfers); return CURLE_OK; } case CF_QUERY_CONNECT_REPLY_MS: From d517efe5bd1dbcc6faafe6b0c123521f96d955b0 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 4 Dec 2025 16:39:22 +0100 Subject: [PATCH 186/415] bufref: add Curl_bufref_dup that returns a strdup()ed version Cleans up a common pattern somewhat. Implemented as a macro. Closes #19834 --- docs/internals/BUFREF.md | 9 +++++++++ lib/bufref.h | 3 +++ lib/easy.c | 4 ++-- lib/http.c | 8 ++++---- lib/multi.c | 2 +- lib/transfer.c | 2 +- 6 files changed, 20 insertions(+), 8 deletions(-) diff --git a/docs/internals/BUFREF.md b/docs/internals/BUFREF.md index cd101f08a9a3..46f7ee6b3e50 100644 --- a/docs/internals/BUFREF.md +++ b/docs/internals/BUFREF.md @@ -93,3 +93,12 @@ size_t Curl_bufref_len(const struct bufref *br); ``` Returns the stored length of the referenced buffer. + +## `dup` + +```c +char *Curl_bufref_dup(const struct bufref *br); +``` + +Returns a strdup() version of the buffer. Note that this assumes that the +bufref is null terminated. diff --git a/lib/bufref.h b/lib/bufref.h index abf1d617df5a..5d331adbdf0f 100644 --- a/lib/bufref.h +++ b/lib/bufref.h @@ -45,4 +45,7 @@ size_t Curl_bufref_len(const struct bufref *br); CURLcode Curl_bufref_memdup0(struct bufref *br, const void *ptr, size_t len); void Curl_bufref_free(struct bufref *br); +/* return a strdup() version of the buffer */ +#define Curl_bufref_dup(x) curlx_strdup(Curl_bufref_ptr(x)) + #endif diff --git a/lib/easy.c b/lib/easy.c index 68ec3000f856..bdda114850ad 100644 --- a/lib/easy.c +++ b/lib/easy.c @@ -1019,14 +1019,14 @@ CURL *curl_easy_duphandle(CURL *d) if(Curl_bufref_ptr(&data->state.url)) { Curl_bufref_set(&outcurl->state.url, - curlx_strdup(Curl_bufref_ptr(&data->state.url)), 0, + Curl_bufref_dup(&data->state.url), 0, curl_free); if(!Curl_bufref_ptr(&outcurl->state.url)) goto fail; } if(Curl_bufref_ptr(&data->state.referer)) { Curl_bufref_set(&outcurl->state.referer, - curlx_strdup(Curl_bufref_ptr(&data->state.referer)), 0, + Curl_bufref_dup(&data->state.referer), 0, curl_free); if(!Curl_bufref_ptr(&outcurl->state.referer)) goto fail; diff --git a/lib/http.c b/lib/http.c index afe37da5b660..ba42f19ff0f9 100644 --- a/lib/http.c +++ b/lib/http.c @@ -612,7 +612,7 @@ CURLcode Curl_http_auth_act(struct Curl_easy *data) out in bug #2284386 */ curlx_free(data->req.newurl); /* clone URL */ - data->req.newurl = curlx_strdup(Curl_bufref_ptr(&data->state.url)); + data->req.newurl = Curl_bufref_dup(&data->state.url); if(!data->req.newurl) return CURLE_OUT_OF_MEMORY; } @@ -626,7 +626,7 @@ CURLcode Curl_http_auth_act(struct Curl_easy *data) if((data->state.httpreq != HTTPREQ_GET) && (data->state.httpreq != HTTPREQ_HEAD)) { /* clone URL */ - data->req.newurl = curlx_strdup(Curl_bufref_ptr(&data->state.url)); + data->req.newurl = Curl_bufref_dup(&data->state.url); if(!data->req.newurl) return CURLE_OUT_OF_MEMORY; data->state.authhost.done = TRUE; @@ -912,7 +912,7 @@ static CURLcode auth_spnego(struct Curl_easy *data, &conn->http_negotiate_state; if(!result) { curlx_free(data->req.newurl); - data->req.newurl = curlx_strdup(Curl_bufref_ptr(&data->state.url)); + data->req.newurl = Curl_bufref_dup(&data->state.url); if(!data->req.newurl) return CURLE_OUT_OF_MEMORY; data->state.authproblem = FALSE; @@ -4051,7 +4051,7 @@ static CURLcode http_on_response(struct Curl_easy *data, data->state.disableexpect = TRUE; Curl_req_abort_sending(data); DEBUGASSERT(!data->req.newurl); - data->req.newurl = curlx_strdup(Curl_bufref_ptr(&data->state.url)); + data->req.newurl = Curl_bufref_dup(&data->state.url); if(!data->req.newurl) { result = CURLE_OUT_OF_MEMORY; goto out; diff --git a/lib/multi.c b/lib/multi.c index f87ee012d86b..531ec6605e46 100644 --- a/lib/multi.c +++ b/lib/multi.c @@ -2011,7 +2011,7 @@ static CURLMcode state_performing(struct Curl_easy *data, data->state.errorbuf = FALSE; if(!newurl) /* typically for HTTP_1_1_REQUIRED error on first flight */ - newurl = curlx_strdup(Curl_bufref_ptr(&data->state.url)); + newurl = Curl_bufref_dup(&data->state.url); if(!newurl) { result = CURLE_OUT_OF_MEMORY; } diff --git a/lib/transfer.c b/lib/transfer.c index 34f0698ebd75..11e7e6e793c3 100644 --- a/lib/transfer.c +++ b/lib/transfer.c @@ -671,7 +671,7 @@ CURLcode Curl_retry_request(struct Curl_easy *data, char **url) } infof(data, "Connection died, retrying a fresh connect (retry count: %d)", data->state.retrycount); - *url = curlx_strdup(Curl_bufref_ptr(&data->state.url)); + *url = Curl_bufref_dup(&data->state.url); if(!*url) return CURLE_OUT_OF_MEMORY; From 7a1e99eefa20b2a5dc694ef6078051703521fd1e Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Thu, 4 Dec 2025 17:44:46 +0100 Subject: [PATCH 187/415] badwords: check FAQ with allowlisted 'will', fix a typo Also: - badwords.pl: add support for filename:word exceptions. - badwords.pl: handle `-w` file open errors. Ref: https://github.com/curl/curl/pull/19817#issuecomment-3612386568 Closes #19837 --- .github/scripts/badwords.ok | 7 +++++++ .github/scripts/badwords.pl | 12 +++++++++--- .github/workflows/checkdocs.yml | 2 +- docs/FAQ | 2 +- 4 files changed, 18 insertions(+), 5 deletions(-) create mode 100644 .github/scripts/badwords.ok diff --git a/.github/scripts/badwords.ok b/.github/scripts/badwords.ok new file mode 100644 index 000000000000..d5401a822870 --- /dev/null +++ b/.github/scripts/badwords.ok @@ -0,0 +1,7 @@ +# Copyright (C) Daniel Stenberg, , et al. +# +# SPDX-License-Identifier: curl +# +# whitelisted uses of bad words +# file:[line]:rule +docs/FAQ::\bwill\b diff --git a/.github/scripts/badwords.pl b/.github/scripts/badwords.pl index 014468c6f99c..1fde5ec4730f 100755 --- a/.github/scripts/badwords.pl +++ b/.github/scripts/badwords.pl @@ -30,13 +30,13 @@ if($ARGV[0] eq "-w") { shift @ARGV; my $file = shift @ARGV; - open(W, "<$file"); + open(W, "<$file") or die "Cannot open '$file': $!"; while() { if(/^#/) { # allow #-comments next; } - if(/^([^:]*):(\d+):(.*)/) { + if(/^([^:]*):(\d*):(.*)/) { $wl{"$1:$2:$3"}=1; #print STDERR "whitelisted $1:$2:$3\n"; } @@ -93,7 +93,13 @@ sub file { my $ch = "$f:$l:$w"; if($wl{$ch}) { - # whitelisted + # whitelisted filename + line + word + print STDERR "$ch found but whitelisted\n"; + next; + } + $ch = $f . "::" . $w; + if($wl{$ch}) { + # whitelisted filename + word print STDERR "$ch found but whitelisted\n"; next; } diff --git a/.github/workflows/checkdocs.yml b/.github/workflows/checkdocs.yml index 6f67b44fca89..60d42301941e 100644 --- a/.github/workflows/checkdocs.yml +++ b/.github/workflows/checkdocs.yml @@ -140,7 +140,7 @@ jobs: persist-credentials: false - name: 'badwords' - run: .github/scripts/badwords.pl '**.md' docs/TODO docs/KNOWN_BUGS packages/OS400/README.OS400 < .github/scripts/badwords.txt + run: .github/scripts/badwords.pl -w .github/scripts/badwords.ok '**.md' docs/FAQ docs/KNOWN_BUGS docs/TODO packages/OS400/README.OS400 < .github/scripts/badwords.txt - name: 'verify synopsis' run: .github/scripts/verify-synopsis.pl docs/libcurl/curl*.md diff --git a/docs/FAQ b/docs/FAQ index 6ba339c7d55c..15cfee848cc6 100644 --- a/docs/FAQ +++ b/docs/FAQ @@ -666,7 +666,7 @@ FAQ does not require this, you do not need a client certificate. A client certificate is always used together with a private key, and the - private key has a pass phrase that protects it. + private key has a passphrase that protects it. SERVER CERTIFICATE From 0476e4fc65a67c5d7e6d0229c4073ce2b8fd9325 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Sat, 29 Nov 2025 23:11:52 +0100 Subject: [PATCH 188/415] tidy-up: one more round of formatting nits Closes #19835 --- .github/scripts/typos.toml | 2 +- docs/examples/10-at-a-time.c | 2 +- docs/examples/block_ip.c | 4 +- docs/examples/cacertinmem.c | 2 +- docs/examples/crawler.c | 4 +- docs/examples/ephiperfifo.c | 4 +- docs/examples/evhiperfifo.c | 2 +- docs/examples/externalsocket.c | 10 +- docs/examples/ftp-wildcard.c | 2 +- docs/examples/ftpgetresp.c | 2 +- docs/examples/ftpsget.c | 4 +- docs/examples/ftpupload.c | 8 +- docs/examples/ftpuploadresume.c | 1 - docs/examples/ghiper.c | 8 +- docs/examples/hiperfifo.c | 2 +- docs/examples/hsts-preload.c | 2 +- docs/examples/htmltidy.c | 4 +- docs/examples/htmltitle.cpp | 13 +- docs/examples/http2-download.c | 4 +- docs/examples/http2-serverpush.c | 2 +- docs/examples/http2-upload.c | 4 +- docs/examples/imap-append.c | 8 +- docs/examples/maxconnects.c | 3 +- docs/examples/multi-app.c | 2 +- docs/examples/multi-event.c | 6 +- docs/examples/multi-legacy.c | 10 +- docs/examples/multi-uv.c | 6 +- docs/examples/multithread.c | 2 +- docs/examples/post-callback.c | 7 +- docs/examples/postinmemory.c | 2 +- docs/examples/progressfunc.c | 4 +- docs/examples/protofeats.c | 4 +- docs/examples/sendrecv.c | 2 +- docs/examples/sessioninfo.c | 4 +- docs/examples/smtp-authzid.c | 14 +- docs/examples/smtp-mail.c | 8 +- docs/examples/smtp-mime.c | 9 +- docs/examples/smtp-multi.c | 8 +- docs/examples/smtp-ssl.c | 8 +- docs/examples/smtp-tls.c | 8 +- docs/examples/synctime.c | 37 +- docs/examples/websocket-cb.c | 4 +- docs/examples/websocket-updown.c | 5 +- docs/examples/websocket.c | 15 +- lib/bufref.c | 2 +- lib/cookie.c | 2 +- lib/curl_sha512_256.c | 19 +- lib/formdata.c | 24 +- lib/ftp.c | 7 +- lib/hostip.c | 2 +- lib/http_aws_sigv4.c | 2 +- lib/ldap.c | 10 +- lib/url.c | 4 +- lib/vauth/digest_sspi.c | 10 +- lib/vquic/curl_ngtcp2.c | 11 +- lib/vquic/curl_osslq.c | 11 +- lib/vquic/curl_quiche.c | 6 +- lib/vquic/vquic-tls.c | 8 +- lib/vquic/vquic.c | 9 +- lib/vquic/vquic_int.h | 2 +- lib/vtls/apple.c | 32 +- lib/vtls/cipher_suite.c | 6 +- lib/vtls/schannel_verify.c | 6 +- lib/vtls/x509asn1.c | 2 +- tests/libtest/cli_h2_pausing.c | 32 +- tests/libtest/cli_hx_download.c | 10 +- tests/libtest/first.c | 4 +- tests/libtest/first.h | 76 ++-- tests/libtest/lib1156.c | 10 +- tests/libtest/lib1506.c | 2 +- tests/libtest/lib1512.c | 2 +- tests/libtest/lib1514.c | 2 +- tests/libtest/lib1520.c | 2 +- tests/libtest/lib1537.c | 4 +- tests/libtest/lib1541.c | 2 +- tests/libtest/lib1550.c | 4 +- tests/libtest/lib1556.c | 2 +- tests/libtest/lib1560.c | 26 +- tests/libtest/lib1565.c | 2 +- tests/libtest/lib1597.c | 34 +- tests/libtest/lib1911.c | 4 +- tests/libtest/lib1912.c | 4 +- tests/libtest/lib1915.c | 2 +- tests/libtest/lib1918.c | 4 +- tests/libtest/lib1938.c | 2 +- tests/libtest/lib2032.c | 9 +- tests/libtest/lib2301.c | 4 +- tests/libtest/lib2402.c | 2 +- tests/libtest/lib2404.c | 2 +- tests/libtest/lib2405.c | 27 +- tests/libtest/lib2502.c | 2 +- tests/libtest/lib3207.c | 2 +- tests/libtest/lib509.c | 6 +- tests/libtest/lib517.c | 232 +++++------ tests/libtest/lib518.c | 4 +- tests/libtest/lib530.c | 7 +- tests/libtest/lib537.c | 2 +- tests/libtest/lib543.c | 7 +- tests/libtest/lib544.c | 3 +- tests/libtest/lib553.c | 2 +- tests/libtest/lib557.c | 6 +- tests/libtest/lib558.c | 4 +- tests/libtest/lib576.c | 2 +- tests/libtest/lib582.c | 6 +- tests/libtest/lib654.c | 2 +- tests/libtest/lib670.c | 2 +- tests/libtest/lib678.c | 2 +- tests/libtest/lib758.c | 17 +- tests/libtest/memptr.c | 6 +- tests/server/dnsd.c | 7 +- tests/server/getpart.c | 2 +- tests/server/mqttd.c | 11 +- tests/server/rtspd.c | 17 +- tests/server/sockfilt.c | 49 ++- tests/server/socksd.c | 30 +- tests/server/sws.c | 38 +- tests/server/tftpd.c | 38 +- tests/unit/unit1300.c | 10 +- tests/unit/unit1302.c | 148 ++++---- tests/unit/unit1307.c | 18 +- tests/unit/unit1309.c | 4 +- tests/unit/unit1323.c | 8 +- tests/unit/unit1395.c | 6 +- tests/unit/unit1396.c | 52 ++- tests/unit/unit1397.c | 100 ++--- tests/unit/unit1398.c | 2 +- tests/unit/unit1600.c | 27 +- tests/unit/unit1601.c | 2 +- tests/unit/unit1606.c | 2 +- tests/unit/unit1607.c | 2 +- tests/unit/unit1609.c | 2 +- tests/unit/unit1610.c | 6 +- tests/unit/unit1611.c | 6 +- tests/unit/unit1612.c | 6 +- tests/unit/unit1614.c | 196 +++++----- tests/unit/unit1615.c | 103 ++--- tests/unit/unit1620.c | 19 +- tests/unit/unit1650.c | 14 +- tests/unit/unit1651.c | 634 ++++++++++++++++--------------- tests/unit/unit1660.c | 17 +- tests/unit/unit1979.c | 2 +- tests/unit/unit1980.c | 2 +- tests/unit/unit2604.c | 42 +- tests/unit/unit2605.c | 59 ++- tests/unit/unit3200.c | 2 +- tests/unit/unit3205.c | 30 +- tests/unit/unit3211.c | 9 +- tests/unit/unit3212.c | 2 +- tests/unit/unit3213.c | 12 +- 149 files changed, 1383 insertions(+), 1378 deletions(-) diff --git a/.github/scripts/typos.toml b/.github/scripts/typos.toml index 3495823c1bdc..ec6b9bb05015 100644 --- a/.github/scripts/typos.toml +++ b/.github/scripts/typos.toml @@ -9,7 +9,7 @@ extend-ignore-identifiers-re = [ "^(ECT0|ECT1|HELO|htpt|PASE)$", "^[A-Za-z0-9_-]*(EDE|GOST)[A-Z0-9_-]*$", # ciphers "^0x[0-9a-fA-F]+FUL$", # unsigned long hex literals ending with 'F' - "^(eyeballers|HELO_smtp|optin|passin|perfec|SMTP_HELO)$", + "^(eyeballers|HELO_smtp|Januar|optin|passin|perfec|SMTP_HELO)$", "^(clen|req_clen|smtp_perform_helo|smtp_state_helo_resp|Tru64|_stati64)$", "secur32", "proxys", # this should be limited to tests/http/*. Short for secure proxy. diff --git a/docs/examples/10-at-a-time.c b/docs/examples/10-at-a-time.c index 22db7c5fc461..08f1f25f7f7f 100644 --- a/docs/examples/10-at-a-time.c +++ b/docs/examples/10-at-a-time.c @@ -81,7 +81,7 @@ static const char *urls[] = { }; #define MAX_PARALLEL 10 /* number of simultaneous transfers */ -#define NUM_URLS (sizeof(urls) / sizeof(char *)) +#define NUM_URLS (sizeof(urls) / sizeof(char *)) static size_t write_cb(char *data, size_t n, size_t l, void *userp) { diff --git a/docs/examples/block_ip.c b/docs/examples/block_ip.c index 5cd77cad0e80..04223ddd0363 100644 --- a/docs/examples/block_ip.c +++ b/docs/examples/block_ip.c @@ -268,7 +268,7 @@ static curl_socket_t opensocket(void *clientp, if(ip && filter->type == CONNECTION_FILTER_BLACKLIST) { if(filter->verbose) { - char buf[128] = {0}; + char buf[128] = { 0 }; inet_ntop(address->family, cinaddr, buf, sizeof(buf)); fprintf(stderr, "* Rejecting IP %s due to blacklist entry %s.\n", buf, ip->str); @@ -277,7 +277,7 @@ static curl_socket_t opensocket(void *clientp, } else if(!ip && filter->type == CONNECTION_FILTER_WHITELIST) { if(filter->verbose) { - char buf[128] = {0}; + char buf[128] = { 0 }; inet_ntop(address->family, cinaddr, buf, sizeof(buf)); fprintf(stderr, "* Rejecting IP %s due to missing whitelist entry.\n", buf); diff --git a/docs/examples/cacertinmem.c b/docs/examples/cacertinmem.c index ed8f40aef454..b37cd6f41485 100644 --- a/docs/examples/cacertinmem.c +++ b/docs/examples/cacertinmem.c @@ -83,7 +83,7 @@ static CURLcode sslctx_function(CURL *curl, void *sslctx, void *pointer) BIO *cbio = BIO_new_mem_buf(mypem, sizeof(mypem)); X509_STORE *cts = SSL_CTX_get_cert_store((SSL_CTX *)sslctx); ossl_valsize_t i; - STACK_OF(X509_INFO) *inf; + STACK_OF(X509_INFO) * inf; (void)curl; (void)pointer; diff --git a/docs/examples/crawler.c b/docs/examples/crawler.c index 9207199cdfc9..09c0c7d6923f 100644 --- a/docs/examples/crawler.c +++ b/docs/examples/crawler.c @@ -123,8 +123,8 @@ static CURL *make_handle(const char *url) /* HREF finder implemented in libxml2 but could be any HTML parser */ static size_t follow_links(CURLM *multi, struct memory *mem, const char *url) { - int opts = HTML_PARSE_NOBLANKS | HTML_PARSE_NOERROR | \ - HTML_PARSE_NOWARNING | HTML_PARSE_NONET; + int opts = HTML_PARSE_NOBLANKS | HTML_PARSE_NOERROR | HTML_PARSE_NOWARNING | + HTML_PARSE_NONET; htmlDocPtr doc = htmlReadMemory(mem->buf, (int)mem->size, url, NULL, opts); size_t count; int i; diff --git a/docs/examples/ephiperfifo.c b/docs/examples/ephiperfifo.c index e572fffad887..cafea9693fe4 100644 --- a/docs/examples/ephiperfifo.c +++ b/docs/examples/ephiperfifo.c @@ -244,7 +244,7 @@ static void timer_cb(struct GlobalInfo *g, int revents) } rc = curl_multi_socket_action(g->multi, - CURL_SOCKET_TIMEOUT, 0, &g->still_running); + CURL_SOCKET_TIMEOUT, 0, &g->still_running); mcode_or_die("timer_cb: curl_multi_socket_action", rc); check_multi_info(g); } @@ -303,7 +303,7 @@ static int sock_cb(CURL *e, curl_socket_t s, int what, void *cbp, void *sockp) { struct GlobalInfo *g = (struct GlobalInfo *)cbp; struct SockInfo *fdp = (struct SockInfo *)sockp; - const char *whatstr[] = {"none", "IN", "OUT", "INOUT", "REMOVE"}; + const char *whatstr[] = { "none", "IN", "OUT", "INOUT", "REMOVE" }; fprintf(MSG_OUT, "socket callback: s=%d e=%p what=%s ", s, e, whatstr[what]); if(what == CURL_POLL_REMOVE) { diff --git a/docs/examples/evhiperfifo.c b/docs/examples/evhiperfifo.c index 178be018a3a6..922197c3cb5a 100644 --- a/docs/examples/evhiperfifo.c +++ b/docs/examples/evhiperfifo.c @@ -270,7 +270,7 @@ static int sock_cb(CURL *e, curl_socket_t s, int what, void *cbp, void *sockp) { struct GlobalInfo *g = (struct GlobalInfo *)cbp; struct SockInfo *fdp = (struct SockInfo *)sockp; - const char *whatstr[] = {"none", "IN", "OUT", "INOUT", "REMOVE"}; + const char *whatstr[] = { "none", "IN", "OUT", "INOUT", "REMOVE" }; printf("%s e %p s %i what %i cbp %p sockp %p\n", __PRETTY_FUNCTION__, e, s, what, cbp, sockp); diff --git a/docs/examples/externalsocket.c b/docs/examples/externalsocket.c index 632d5f298168..4f1b2e9091e3 100644 --- a/docs/examples/externalsocket.c +++ b/docs/examples/externalsocket.c @@ -43,17 +43,17 @@ #ifdef _WIN32 #define close closesocket #else -#include /* socket types */ -#include /* socket definitions */ +#include /* socket types */ +#include /* socket definitions */ #include -#include /* inet (3) functions */ -#include /* misc. Unix functions */ +#include /* inet (3) functions */ +#include /* misc. Unix functions */ #endif #include /* The IP address and port number to connect to */ -#define IPADDR "127.0.0.1" +#define IPADDR "127.0.0.1" #define PORTNUM 80 #ifndef INADDR_NONE diff --git a/docs/examples/ftp-wildcard.c b/docs/examples/ftp-wildcard.c index fa66628f1655..9159d3857f54 100644 --- a/docs/examples/ftp-wildcard.c +++ b/docs/examples/ftp-wildcard.c @@ -103,7 +103,7 @@ int main(int argc, char **argv) CURL *curl; /* help data */ - struct callback_data data = {0}; + struct callback_data data = { 0 }; /* global initialization */ CURLcode res = curl_global_init(CURL_GLOBAL_ALL); diff --git a/docs/examples/ftpgetresp.c b/docs/examples/ftpgetresp.c index 53ada7ccaee6..c46fa057eb80 100644 --- a/docs/examples/ftpgetresp.c +++ b/docs/examples/ftpgetresp.c @@ -42,7 +42,7 @@ static size_t write_response(void *ptr, size_t size, size_t nmemb, void *data) return fwrite(ptr, size, nmemb, writehere); } -#define FTPBODY "ftp-list" +#define FTPBODY "ftp-list" #define FTPHEADERS "ftp-responses" int main(void) diff --git a/docs/examples/ftpsget.c b/docs/examples/ftpsget.c index 22c94b8e9363..38844bb21915 100644 --- a/docs/examples/ftpsget.c +++ b/docs/examples/ftpsget.c @@ -40,8 +40,7 @@ struct FtpFile { FILE *stream; }; -static size_t write_cb(void *buffer, size_t size, size_t nmemb, - void *stream) +static size_t write_cb(void *buffer, size_t size, size_t nmemb, void *stream) { struct FtpFile *out = (struct FtpFile *)stream; if(!out->stream) { @@ -53,7 +52,6 @@ static size_t write_cb(void *buffer, size_t size, size_t nmemb, return fwrite(buffer, size, nmemb, out->stream); } - int main(void) { CURL *curl; diff --git a/docs/examples/ftpupload.c b/docs/examples/ftpupload.c index 0a241db21c93..48c76a4898a7 100644 --- a/docs/examples/ftpupload.c +++ b/docs/examples/ftpupload.c @@ -52,10 +52,10 @@ #include #endif -#define LOCAL_FILE "/tmp/uploadthis.txt" -#define UPLOAD_FILE_AS "while-uploading.txt" -#define REMOTE_URL "ftp://example.com/" UPLOAD_FILE_AS -#define RENAME_FILE_TO "renamed-and-fine.txt" +#define LOCAL_FILE "/tmp/uploadthis.txt" +#define UPLOAD_FILE_AS "while-uploading.txt" +#define REMOTE_URL "ftp://example.com/" UPLOAD_FILE_AS +#define RENAME_FILE_TO "renamed-and-fine.txt" /* NOTE: if you want this example to work on Windows with libcurl as a DLL, you MUST also provide a read callback with CURLOPT_READFUNCTION. Failing to diff --git a/docs/examples/ftpuploadresume.c b/docs/examples/ftpuploadresume.c index a9af3f12cd56..30305f62fe6c 100644 --- a/docs/examples/ftpuploadresume.c +++ b/docs/examples/ftpuploadresume.c @@ -72,7 +72,6 @@ static size_t read_cb(char *ptr, size_t size, size_t nmemb, void *stream) return n; } - static int upload(CURL *curl, const char *remotepath, const char *localpath, long timeout, long tries) { diff --git a/docs/examples/ghiper.c b/docs/examples/ghiper.c index d7b19abb9be3..8f320a6e5fae 100644 --- a/docs/examples/ghiper.c +++ b/docs/examples/ghiper.c @@ -66,9 +66,9 @@ #include -#define MSG_OUT g_print /* Change to "g_error" to write to stderr */ -#define SHOW_VERBOSE 0L /* Set to non-zero for libcurl messages */ -#define SHOW_PROGRESS 0 /* Set to non-zero to enable progress callback */ +#define MSG_OUT g_print /* Change to "g_error" to write to stderr */ +#define SHOW_VERBOSE 0L /* Set to non-zero for libcurl messages */ +#define SHOW_PROGRESS 0 /* Set to non-zero to enable progress callback */ /* Global information, common to all connections */ struct GlobalInfo { @@ -261,7 +261,7 @@ static int sock_cb(CURL *e, curl_socket_t s, int what, void *cbp, void *sockp) { struct GlobalInfo *g = (struct GlobalInfo *)cbp; struct SockInfo *fdp = (struct SockInfo *)sockp; - static const char *whatstr[] = {"none", "IN", "OUT", "INOUT", "REMOVE"}; + static const char *whatstr[] = { "none", "IN", "OUT", "INOUT", "REMOVE" }; MSG_OUT("socket callback: s=%d e=%p what=%s ", s, e, whatstr[what]); if(what == CURL_POLL_REMOVE) { diff --git a/docs/examples/hiperfifo.c b/docs/examples/hiperfifo.c index 576bbb8d2c2f..7b17731ebfb5 100644 --- a/docs/examples/hiperfifo.c +++ b/docs/examples/hiperfifo.c @@ -274,7 +274,7 @@ static int sock_cb(CURL *e, curl_socket_t s, int what, void *cbp, void *sockp) { struct GlobalInfo *g = (struct GlobalInfo *)cbp; struct SockInfo *fdp = (struct SockInfo *)sockp; - const char *whatstr[] = {"none", "IN", "OUT", "INOUT", "REMOVE"}; + const char *whatstr[] = { "none", "IN", "OUT", "INOUT", "REMOVE" }; fprintf(MSG_OUT, "socket callback: s=%d e=%p what=%s ", s, e, whatstr[what]); if(what == CURL_POLL_REMOVE) { diff --git a/docs/examples/hsts-preload.c b/docs/examples/hsts-preload.c index b029df2a0a30..cd6c30f9c6b6 100644 --- a/docs/examples/hsts-preload.c +++ b/docs/examples/hsts-preload.c @@ -93,7 +93,7 @@ int main(void) curl = curl_easy_init(); if(curl) { - struct state st = {0}; + struct state st = { 0 }; /* enable HSTS for this handle */ curl_easy_setopt(curl, CURLOPT_HSTS_CTRL, CURLHSTS_ENABLE); diff --git a/docs/examples/htmltidy.c b/docs/examples/htmltidy.c index 9865a633efcd..a3ecc01df175 100644 --- a/docs/examples/htmltidy.c +++ b/docs/examples/htmltidy.c @@ -79,8 +79,8 @@ int main(int argc, char **argv) CURL *curl; char curl_errbuf[CURL_ERROR_SIZE]; TidyDoc tdoc; - TidyBuffer docbuf = {0}; - TidyBuffer tidy_errbuf = {0}; + TidyBuffer docbuf = { 0 }; + TidyBuffer tidy_errbuf = { 0 }; CURLcode res; if(argc != 2) { diff --git a/docs/examples/htmltitle.cpp b/docs/examples/htmltitle.cpp index a6f944ff0eb9..ac351a8bf5f7 100644 --- a/docs/examples/htmltitle.cpp +++ b/docs/examples/htmltitle.cpp @@ -54,7 +54,6 @@ // // libxml callback context structure // - struct Context { Context() : addTitle(false) {} @@ -71,7 +70,6 @@ static std::string buffer; // // libcurl write callback function // - static size_t writer(char *data, size_t size, size_t nmemb, std::string *writerData) { @@ -86,7 +84,6 @@ static size_t writer(char *data, size_t size, size_t nmemb, // // libcurl connection initialization // - static bool init(CURL *&curl, const char *url) { CURLcode res; @@ -134,7 +131,6 @@ static bool init(CURL *&curl, const char *url) // // libxml start element callback function // - static void StartElement(void *voidContext, const xmlChar *name, const xmlChar **attributes) @@ -151,7 +147,6 @@ static void StartElement(void *voidContext, // // libxml end element callback function // - static void EndElement(void *voidContext, const xmlChar *name) { @@ -164,7 +159,6 @@ static void EndElement(void *voidContext, // // Text handling helper function // - static void handleCharacters(Context *context, const xmlChar *chars, int length) @@ -177,7 +171,6 @@ static void handleCharacters(Context *context, // // libxml PCDATA callback function // - static void Characters(void *voidContext, const xmlChar *chars, int length) @@ -190,7 +183,6 @@ static void Characters(void *voidContext, // // libxml CDATA callback function // - static void cdata(void *voidContext, const xmlChar *chars, int length) @@ -203,9 +195,7 @@ static void cdata(void *voidContext, // // libxml SAX callback structure // - -static htmlSAXHandler saxHandler = -{ +static htmlSAXHandler saxHandler = { NULL, NULL, NULL, @@ -243,7 +233,6 @@ static htmlSAXHandler saxHandler = // // Parse given (assumed to be) HTML text and return the title // - static void parseHtml(const std::string &html, std::string &title) { diff --git a/docs/examples/http2-download.c b/docs/examples/http2-download.c index e6fdbd6b9c75..054f697b3e89 100644 --- a/docs/examples/http2-download.c +++ b/docs/examples/http2-download.c @@ -200,10 +200,10 @@ int main(int argc, char **argv) /* if given a number, do that many transfers */ num_transfers = atoi(argv[1]); if((num_transfers < 1) || (num_transfers > 1000)) - num_transfers = 3; /* a suitable low default */ + num_transfers = 3; /* a suitable low default */ } else - num_transfers = 3; /* a suitable low default */ + num_transfers = 3; /* a suitable low default */ res = curl_global_init(CURL_GLOBAL_ALL); if(res) diff --git a/docs/examples/http2-serverpush.c b/docs/examples/http2-serverpush.c index 5c817ead5893..eb67bfe67108 100644 --- a/docs/examples/http2-serverpush.c +++ b/docs/examples/http2-serverpush.c @@ -136,7 +136,7 @@ static int setup(CURL *curl, const char *url) { out_download = fopen(OUTPUTFILE, "wb"); if(!out_download) - return 1; /* failed */ + return 1; /* failed */ /* set the same URL */ curl_easy_setopt(curl, CURLOPT_URL, url); diff --git a/docs/examples/http2-upload.c b/docs/examples/http2-upload.c index 9ec8cbf5bc37..e360127a44fd 100644 --- a/docs/examples/http2-upload.c +++ b/docs/examples/http2-upload.c @@ -72,8 +72,8 @@ static int my_gettimeofday(struct timeval *tp, void *tzp) { (void)tzp; if(tp) { - /* Offset between 1601-01-01 and 1970-01-01 in 100 nanosec units */ - #define WIN32_FT_OFFSET (116444736000000000) +/* Offset between 1601-01-01 and 1970-01-01 in 100 nanosec units */ +#define WIN32_FT_OFFSET (116444736000000000) union { CURL_TYPEOF_CURL_OFF_T ns100; /* time since 1 Jan 1601 in 100ns units */ FILETIME ft; diff --git a/docs/examples/imap-append.c b/docs/examples/imap-append.c index 91cbac69151a..e3665d012825 100644 --- a/docs/examples/imap-append.c +++ b/docs/examples/imap-append.c @@ -36,9 +36,9 @@ * Note that this example requires libcurl 7.30.0 or above. */ -#define FROM "" -#define TO "" -#define CC "" +#define FROM "" +#define TO "" +#define CC "" static const char *payload_text = "Date: Mon, 29 Nov 2010 21:54:29 +1100\r\n" @@ -95,7 +95,7 @@ int main(void) if(curl) { size_t filesize; long infilesize = LONG_MAX; - struct upload_status upload_ctx = {0}; + struct upload_status upload_ctx = { 0 }; /* Set username and password */ curl_easy_setopt(curl, CURLOPT_USERNAME, "user"); diff --git a/docs/examples/maxconnects.c b/docs/examples/maxconnects.c index 658b38d711e3..2ee1d305a93f 100644 --- a/docs/examples/maxconnects.c +++ b/docs/examples/maxconnects.c @@ -39,7 +39,8 @@ int main(void) curl = curl_easy_init(); if(curl) { - const char *urls[] = { "https://example.com", + const char *urls[] = { + "https://example.com", "https://curl.se", "https://www.example/", NULL /* end of list */ diff --git a/docs/examples/multi-app.c b/docs/examples/multi-app.c index d58181e027f4..51492e8adea4 100644 --- a/docs/examples/multi-app.c +++ b/docs/examples/multi-app.c @@ -36,7 +36,7 @@ */ #define HTTP_HANDLE 0 /* Index for the HTTP transfer */ -#define FTP_HANDLE 1 /* Index for the FTP transfer */ +#define FTP_HANDLE 1 /* Index for the FTP transfer */ #define HANDLECOUNT 2 /* Number of simultaneous transfers */ int main(void) diff --git a/docs/examples/multi-event.c b/docs/examples/multi-event.c index 901d7dd6e765..2eb3977200ec 100644 --- a/docs/examples/multi-event.c +++ b/docs/examples/multi-event.c @@ -183,8 +183,8 @@ static int handle_socket(CURL *curl, curl_socket_t s, int action, void *userp, case CURL_POLL_IN: case CURL_POLL_OUT: case CURL_POLL_INOUT: - curl_context = socketp ? - (struct curl_context *)socketp : create_curl_context(s); + curl_context = + socketp ? (struct curl_context *)socketp : create_curl_context(s); curl_multi_assign(multi, s, (void *)curl_context); @@ -197,7 +197,7 @@ static int handle_socket(CURL *curl, curl_socket_t s, int action, void *userp, event_del(curl_context->event); event_assign(curl_context->event, base, curl_context->sockfd, - (short)events, curl_perform, curl_context); + (short)events, curl_perform, curl_context); event_add(curl_context->event, NULL); break; diff --git a/docs/examples/multi-legacy.c b/docs/examples/multi-legacy.c index e34d1cd710a2..42670129f944 100644 --- a/docs/examples/multi-legacy.c +++ b/docs/examples/multi-legacy.c @@ -41,9 +41,9 @@ * Download an HTTP file and upload an FTP file simultaneously. */ -#define HTTP_HANDLE 0 /* Index for the HTTP transfer */ -#define FTP_HANDLE 1 /* Index for the FTP transfer */ -#define HANDLECOUNT 2 /* Number of simultaneous transfers */ +#define HTTP_HANDLE 0 /* Index for the HTTP transfer */ +#define FTP_HANDLE 1 /* Index for the FTP transfer */ +#define HANDLECOUNT 2 /* Number of simultaneous transfers */ int main(void) { @@ -140,7 +140,7 @@ int main(void) rc = 0; #else /* Portable sleep for platforms other than Windows. */ - struct timeval wait = {0}; + struct timeval wait = { 0 }; wait.tv_usec = 100 * 1000; /* 100ms */ rc = select(0, NULL, NULL, NULL, &wait); #endif @@ -155,7 +155,7 @@ int main(void) case -1: /* select error */ break; - case 0: /* timeout */ + case 0: /* timeout */ default: /* action */ curl_multi_perform(multi, &still_running); break; diff --git a/docs/examples/multi-uv.c b/docs/examples/multi-uv.c index 4053cb906112..13689ad3f8ef 100644 --- a/docs/examples/multi-uv.c +++ b/docs/examples/multi-uv.c @@ -201,8 +201,8 @@ static int cb_socket(CURL *curl, curl_socket_t s, int action, case CURL_POLL_IN: case CURL_POLL_OUT: case CURL_POLL_INOUT: - curl_context = socketp ? - (struct curl_context *)socketp : create_curl_context(s, uv); + curl_context = + socketp ? (struct curl_context *)socketp : create_curl_context(s, uv); curl_multi_assign(uv->multi, s, (void *)curl_context); @@ -230,7 +230,7 @@ static int cb_socket(CURL *curl, curl_socket_t s, int action, int main(int argc, char **argv) { CURLcode res; - struct datauv uv = {0}; + struct datauv uv = { 0 }; int running_handles; if(argc <= 1) diff --git a/docs/examples/multithread.c b/docs/examples/multithread.c index 308c1168e284..3d2f1df7de0b 100644 --- a/docs/examples/multithread.c +++ b/docs/examples/multithread.c @@ -45,7 +45,7 @@ https://curl.se/libcurl/c/threadsafe.html */ -static const char * const urls[NUMT]= { +static const char * const urls[NUMT] = { "https://curl.se/", "ftp://example.com/", "https://example.net/", diff --git a/docs/examples/post-callback.c b/docs/examples/post-callback.c index c463e3785ceb..0df09a34bf45 100644 --- a/docs/examples/post-callback.c +++ b/docs/examples/post-callback.c @@ -31,8 +31,9 @@ #include /* silly test data to POST */ -static const char data[]="Lorem ipsum dolor sit amet, consectetur adipiscing " - "elit. Sed vel urna neque. Ut quis leo metus. Quisque eleifend, ex at " +static const char data[] = + "Lorem ipsum dolor sit amet, consectetur adipiscing elit. " + "Sed vel urna neque. Ut quis leo metus. Quisque eleifend, ex at " "laoreet rhoncus, odio ipsum semper metus, at tempus ante urna in mauris. " "Suspendisse ornare tempor venenatis. Ut dui neque, pellentesque a ______ " "eget, mattis vitae ligula. Fusce ut pharetra est. Ut ullamcorper mi ac " @@ -61,7 +62,7 @@ static size_t read_cb(char *dest, size_t size, size_t nmemb, void *userp) return copy_this_much; /* we copied this many bytes */ } - return 0; /* no more data left to deliver */ + return 0; /* no more data left to deliver */ } int main(void) diff --git a/docs/examples/postinmemory.c b/docs/examples/postinmemory.c index 089d9a9c743c..0a2964f1c64d 100644 --- a/docs/examples/postinmemory.c +++ b/docs/examples/postinmemory.c @@ -68,7 +68,7 @@ int main(void) return (int)res; chunk.memory = malloc(1); /* grown as needed by realloc above */ - chunk.size = 0; /* no data at this point */ + chunk.size = 0; /* no data at this point */ curl = curl_easy_init(); if(curl) { diff --git a/docs/examples/progressfunc.c b/docs/examples/progressfunc.c index 59477951f934..41a87f2bf9a0 100644 --- a/docs/examples/progressfunc.c +++ b/docs/examples/progressfunc.c @@ -30,8 +30,8 @@ #include -#define MINIMAL_PROGRESS_FUNCTIONALITY_INTERVAL 3000000 -#define STOP_DOWNLOAD_AFTER_THIS_MANY_BYTES 6000 +#define MINIMAL_PROGRESS_FUNCTIONALITY_INTERVAL 3000000 +#define STOP_DOWNLOAD_AFTER_THIS_MANY_BYTES 6000 struct myprogress { curl_off_t lastruntime; /* type depends on version, see above */ diff --git a/docs/examples/protofeats.c b/docs/examples/protofeats.c index f93dccef003c..50b31cb9ea57 100644 --- a/docs/examples/protofeats.c +++ b/docs/examples/protofeats.c @@ -29,14 +29,14 @@ #include -#if !CURL_AT_LEAST_VERSION(7,87,0) +#if !CURL_AT_LEAST_VERSION(7, 87, 0) #error "too old libcurl" #endif int main(void) { curl_version_info_data *ver; - const char *const *ptr; + const char * const *ptr; CURLcode res = curl_global_init(CURL_GLOBAL_ALL); if(res) diff --git a/docs/examples/sendrecv.c b/docs/examples/sendrecv.c index 6f7cbb1b5188..e0bf417e481b 100644 --- a/docs/examples/sendrecv.c +++ b/docs/examples/sendrecv.c @@ -128,7 +128,7 @@ int main(void) do { nsent = 0; res = curl_easy_send(curl, request + nsent_total, - request_len - nsent_total, &nsent); + request_len - nsent_total, &nsent); nsent_total += nsent; if(res == CURLE_AGAIN && !wait_on_socket(sockfd, 0, 60000L)) { diff --git a/docs/examples/sessioninfo.c b/docs/examples/sessioninfo.c index e90b387da06e..dec9fa988d2e 100644 --- a/docs/examples/sessioninfo.c +++ b/docs/examples/sessioninfo.c @@ -73,8 +73,8 @@ static size_t write_cb(void *ptr, size_t size, size_t nmemb, void *stream) gnutls_x509_crt_import(cert, &chainp[i], GNUTLS_X509_FMT_DER)) { if(GNUTLS_E_SUCCESS == gnutls_x509_crt_print(cert, GNUTLS_CRT_PRINT_FULL, &dn)) { - fprintf(stderr, "Certificate #%u: %.*s", i, - (int)dn.size, dn.data); + fprintf(stderr, "Certificate #%u: %.*s", i, (int)dn.size, + dn.data); gnutls_free(dn.data); } diff --git a/docs/examples/smtp-authzid.c b/docs/examples/smtp-authzid.c index e7dd20f59093..f8e66069f871 100644 --- a/docs/examples/smtp-authzid.c +++ b/docs/examples/smtp-authzid.c @@ -40,13 +40,13 @@ /* The libcurl options want plain addresses, the viewable headers in the mail * can get a full name as well. */ -#define FROM_ADDR "" -#define SENDER_ADDR "" -#define TO_ADDR "" +#define FROM_ADDR "" +#define SENDER_ADDR "" +#define TO_ADDR "" -#define FROM_MAIL "Ursel " FROM_ADDR -#define SENDER_MAIL "Kurt " SENDER_ADDR -#define TO_MAIL "A Receiver " TO_ADDR +#define FROM_MAIL "Ursel " FROM_ADDR +#define SENDER_MAIL "Kurt " SENDER_ADDR +#define TO_MAIL "A Receiver " TO_ADDR static const char *payload_text = "Date: Mon, 29 Nov 2010 21:54:29 +1100\r\n" @@ -99,7 +99,7 @@ int main(void) curl = curl_easy_init(); if(curl) { struct curl_slist *recipients = NULL; - struct upload_status upload_ctx = {0}; + struct upload_status upload_ctx = { 0 }; /* This is the URL for your mailserver. In this example we connect to the smtp-submission port as we require an authenticated connection. */ diff --git a/docs/examples/smtp-mail.c b/docs/examples/smtp-mail.c index d5074abbf2f5..8ed91f55b722 100644 --- a/docs/examples/smtp-mail.c +++ b/docs/examples/smtp-mail.c @@ -37,9 +37,9 @@ /* The libcurl options want plain addresses, the viewable headers in the mail * can get a full name as well. */ -#define FROM_ADDR "" -#define TO_ADDR "" -#define CC_ADDR "" +#define FROM_ADDR "" +#define TO_ADDR "" +#define CC_ADDR "" #define FROM_MAIL "Sender Person " FROM_ADDR #define TO_MAIL "A Receiver " TO_ADDR @@ -96,7 +96,7 @@ int main(void) curl = curl_easy_init(); if(curl) { struct curl_slist *recipients = NULL; - struct upload_status upload_ctx = {0}; + struct upload_status upload_ctx = { 0 }; /* This is the URL for your mailserver */ curl_easy_setopt(curl, CURLOPT_URL, "smtp://mail.example.com"); diff --git a/docs/examples/smtp-mime.c b/docs/examples/smtp-mime.c index 553947b0976c..89bfebd39da4 100644 --- a/docs/examples/smtp-mime.c +++ b/docs/examples/smtp-mime.c @@ -37,9 +37,9 @@ * Note that this example requires libcurl 7.56.0 or above. */ -#define FROM "" -#define TO "" -#define CC "" +#define FROM "" +#define TO "" +#define CC "" static const char *headers_text[] = { "Date: Tue, 22 Aug 2017 14:08:43 +0100", @@ -47,7 +47,7 @@ static const char *headers_text[] = { "From: " FROM " (Example User)", "Cc: " CC " (Another example User)", "Message-ID: ", + "rfcpedant.example.org>", "Subject: example sending a MIME-formatted message", NULL }; @@ -66,7 +66,6 @@ static const char inline_html[] = "email viewers able to handle HTML.

" "\r\n"; - int main(void) { CURL *curl; diff --git a/docs/examples/smtp-multi.c b/docs/examples/smtp-multi.c index 8cb5e65a26b9..acc54bacdfcb 100644 --- a/docs/examples/smtp-multi.c +++ b/docs/examples/smtp-multi.c @@ -34,9 +34,9 @@ * libcurl's multi interface. */ -#define FROM_MAIL "" -#define TO_MAIL "" -#define CC_MAIL "" +#define FROM_MAIL "" +#define TO_MAIL "" +#define CC_MAIL "" static const char *payload_text = "Date: Mon, 29 Nov 2010 21:54:29 +1100\r\n" @@ -94,7 +94,7 @@ int main(void) if(multi) { int still_running = 1; struct curl_slist *recipients = NULL; - struct upload_status upload_ctx = {0}; + struct upload_status upload_ctx = { 0 }; /* This is the URL for your mailserver */ curl_easy_setopt(curl, CURLOPT_URL, "smtp://mail.example.com"); diff --git a/docs/examples/smtp-ssl.c b/docs/examples/smtp-ssl.c index 3b140c904c5c..3a5e3304394e 100644 --- a/docs/examples/smtp-ssl.c +++ b/docs/examples/smtp-ssl.c @@ -38,9 +38,9 @@ * Note that this example requires libcurl 7.20.0 or above. */ -#define FROM_MAIL "" -#define TO_MAIL "" -#define CC_MAIL "" +#define FROM_MAIL "" +#define TO_MAIL "" +#define CC_MAIL "" static const char *payload_text = "Date: Mon, 29 Nov 2010 21:54:29 +1100\r\n" @@ -93,7 +93,7 @@ int main(void) curl = curl_easy_init(); if(curl) { struct curl_slist *recipients = NULL; - struct upload_status upload_ctx = {0}; + struct upload_status upload_ctx = { 0 }; /* Set username and password */ curl_easy_setopt(curl, CURLOPT_USERNAME, "user"); diff --git a/docs/examples/smtp-tls.c b/docs/examples/smtp-tls.c index 3bf3b0cddf11..e9221b36c9f2 100644 --- a/docs/examples/smtp-tls.c +++ b/docs/examples/smtp-tls.c @@ -38,9 +38,9 @@ * Note that this example requires libcurl 7.20.0 or above. */ -#define FROM_MAIL "" -#define TO_MAIL "" -#define CC_MAIL "" +#define FROM_MAIL "" +#define TO_MAIL "" +#define CC_MAIL "" static const char *payload_text = "Date: Mon, 29 Nov 2010 21:54:29 +1100\r\n" @@ -93,7 +93,7 @@ int main(void) curl = curl_easy_init(); if(curl) { struct curl_slist *recipients = NULL; - struct upload_status upload_ctx = {0}; + struct upload_status upload_ctx = { 0 }; /* Set username and password */ curl_easy_setopt(curl, CURLOPT_USERNAME, "user"); diff --git a/docs/examples/synctime.c b/docs/examples/synctime.c index b2a3b926072d..a81f40e3ac21 100644 --- a/docs/examples/synctime.c +++ b/docs/examples/synctime.c @@ -58,8 +58,8 @@ */ #ifdef _MSC_VER #ifndef _CRT_SECURE_NO_WARNINGS -#define _CRT_SECURE_NO_WARNINGS /* for _snprintf(), fopen(), gmtime(), - localtime(), sscanf() */ +#define _CRT_SECURE_NO_WARNINGS /* for _snprintf(), fopen(), gmtime(), + localtime(), sscanf() */ #endif #endif @@ -74,9 +74,9 @@ int main(void) #else #if (defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0602)) || \ - defined(WINAPI_FAMILY) + defined(WINAPI_FAMILY) # include -# if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && \ +# if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && \ !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) # define CURL_WINDOWS_UWP # endif @@ -100,8 +100,8 @@ int main(void) #define snprintf _snprintf #endif -#define MAX_STRING 256 -#define MAX_STRING1 MAX_STRING + 1 +#define MAX_STRING 256 +#define MAX_STRING1 MAX_STRING + 1 #define SYNCTIME_UA "synctime/1.0" @@ -111,8 +111,7 @@ struct conf { char timeserver[MAX_STRING1]; }; -static const char DefaultTimeServer[3][MAX_STRING1] = -{ +static const char DefaultTimeServer[3][MAX_STRING1] = { "https://nist.time.gov/", "https://www.google.com/" }; @@ -128,8 +127,8 @@ static int AutoSyncTime; static SYSTEMTIME SYSTime; static SYSTEMTIME LOCALTime; -#define HTTP_COMMAND_HEAD 0 -#define HTTP_COMMAND_GET 1 +#define HTTP_COMMAND_HEAD 0 +#define HTTP_COMMAND_GET 1 static size_t write_cb(void *ptr, size_t size, size_t nmemb, void *stream) { @@ -167,17 +166,17 @@ static size_t SyncTime_CURL_WriteHeader(void *ptr, size_t size, size_t nmemb, if(RetVal == 7) { int i; - SYSTime.wMilliseconds = 500; /* adjust to midpoint, 0.5 sec */ + SYSTime.wMilliseconds = 500; /* adjust to midpoint, 0.5 sec */ for(i = 0; i < 12; i++) { if(strcmp(MthStr[i], TmpStr2) == 0) { SYSTime.wMonth = (WORD)(i + 1); break; } } - AutoSyncTime = 3; /* Computer clock is adjusted */ + AutoSyncTime = 3; /* Computer clock is adjusted */ } else { - AutoSyncTime = 0; /* Error in sscanf() fields conversion */ + AutoSyncTime = 0; /* Error in sscanf() fields conversion */ } } } @@ -222,7 +221,7 @@ static CURLcode SyncTime_CURL_Fetch(CURL *curl, const char *URL_Str, res = curl_easy_perform(curl); if(outfile) fclose(outfile); - return res; /* (CURLE_OK) */ + return res; /* (CURLE_OK) */ } static void showUsage(void) @@ -251,7 +250,7 @@ static int conf_init(struct conf *conf) *conf->http_proxy = 0; for(i = 0; i < MAX_STRING1; i++) - conf->proxy_user[i] = 0; /* Clean up password from memory */ + conf->proxy_user[i] = 0; /* Clean up password from memory */ *conf->timeserver = 0; return 1; } @@ -263,9 +262,9 @@ int main(int argc, char *argv[]) struct conf conf[1]; int RetValue; - ShowAllHeader = 0; /* Do not show HTTP Header */ - AutoSyncTime = 0; /* Do not synchronise computer clock */ - RetValue = 0; /* Successful Exit */ + ShowAllHeader = 0; /* Do not show HTTP Header */ + AutoSyncTime = 0; /* Do not synchronise computer clock */ + RetValue = 0; /* Successful Exit */ conf_init(conf); if(argc > 1) { @@ -295,7 +294,7 @@ int main(int argc, char *argv[]) } } - if(*conf->timeserver == 0) /* Use default server for time information */ + if(*conf->timeserver == 0) /* Use default server for time information */ snprintf(conf->timeserver, MAX_STRING, "%s", DefaultTimeServer[0]); /* Init CURL before usage */ diff --git a/docs/examples/websocket-cb.c b/docs/examples/websocket-cb.c index 78899826fb53..63d07c784146 100644 --- a/docs/examples/websocket-cb.c +++ b/docs/examples/websocket-cb.c @@ -33,8 +33,8 @@ static size_t write_cb(char *b, size_t size, size_t nitems, void *p) CURL *curl = p; size_t i; const struct curl_ws_frame *frame = curl_ws_meta(curl); - fprintf(stderr, "Type: %s\n", frame->flags & CURLWS_BINARY ? - "binary" : "text"); + fprintf(stderr, "Type: %s\n", + frame->flags & CURLWS_BINARY ? "binary" : "text"); fprintf(stderr, "Bytes: %u", (unsigned int)(nitems * size)); for(i = 0; i < nitems; i++) fprintf(stderr, "%02x ", (unsigned char)b[i]); diff --git a/docs/examples/websocket-updown.c b/docs/examples/websocket-updown.c index 87f7aea28752..a40bddf9cfb1 100644 --- a/docs/examples/websocket-updown.c +++ b/docs/examples/websocket-updown.c @@ -35,8 +35,8 @@ static size_t write_cb(char *b, size_t size, size_t nitems, void *p) size_t i; unsigned int blen = (unsigned int)(nitems * size); const struct curl_ws_frame *frame = curl_ws_meta(curl); - fprintf(stderr, "Type: %s\n", frame->flags & CURLWS_BINARY ? - "binary" : "text"); + fprintf(stderr, "Type: %s\n", + frame->flags & CURLWS_BINARY ? "binary" : "text"); if(frame->flags & CURLWS_BINARY) { fprintf(stderr, "Bytes: %u", blen); for(i = 0; i < nitems; i++) @@ -111,7 +111,6 @@ int main(int argc, const char *argv[]) curl_easy_setopt(curl, CURLOPT_READDATA, &rctx); curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L); - /* Perform the request, res gets the return code */ res = curl_easy_perform(curl); /* Check for errors */ diff --git a/docs/examples/websocket.c b/docs/examples/websocket.c index 0063f1b59c63..0075f68e6059 100644 --- a/docs/examples/websocket.c +++ b/docs/examples/websocket.c @@ -49,10 +49,10 @@ static CURLcode ping(CURL *curl, const char *send_payload) buf += sent; /* deduct what was sent */ blen -= sent; } - else if(res == CURLE_AGAIN) { /* blocked on sending */ + else if(res == CURLE_AGAIN) { /* blocked on sending */ fprintf(stderr, "ws: sent PING blocked, waiting a second\n"); - sleep(1); /* either select() on socket or max timeout would - be good here. */ + sleep(1); /* either select() on socket or max timeout would + be good here. */ } else /* real error sending */ break; @@ -85,8 +85,7 @@ static CURLcode recv_pong(CURL *curl, const char *expected_payload) same ? "same" : "different"); } else if(meta->flags & CURLWS_TEXT) { - fprintf(stderr, "ws: received TEXT frame '%.*s'\n", (int)rlen, - buffer); + fprintf(stderr, "ws: received TEXT frame '%.*s'\n", (int)rlen, buffer); } else if(meta->flags & CURLWS_BINARY) { fprintf(stderr, "ws: received BINARY frame of %u bytes\n", @@ -99,10 +98,10 @@ static CURLcode recv_pong(CURL *curl, const char *expected_payload) goto retry; } } - else if(res == CURLE_AGAIN) { /* blocked on receiving */ + else if(res == CURLE_AGAIN) { /* blocked on receiving */ fprintf(stderr, "ws: PONG not there yet, waiting a second\n"); - sleep(1); /* either select() on socket or max timeout would - be good here. */ + sleep(1); /* either select() on socket or max timeout would + be good here. */ goto retry; } if(res) diff --git a/lib/bufref.c b/lib/bufref.c index 8f52d48d20a5..e5b5a4d985cd 100644 --- a/lib/bufref.c +++ b/lib/bufref.c @@ -102,7 +102,7 @@ const char *Curl_bufref_ptr(const struct bufref *br) DEBUGASSERT(br->signature == SIGNATURE); DEBUGASSERT(br->ptr || !br->len); - return (const char *) br->ptr; + return (const char *)br->ptr; } /* diff --git a/lib/cookie.c b/lib/cookie.c index dff5198c1162..5c29768bbdfc 100644 --- a/lib/cookie.c +++ b/lib/cookie.c @@ -1036,7 +1036,7 @@ Curl_cookie_add(struct Curl_easy *data, /* Only show this when NOT reading the cookies from a file */ infof(data, "%s cookie %s=\"%s\" for domain %s, path %s, " "expire %" FMT_OFF_T, - replaces ? "Replaced":"Added", co->name, co->value, + replaces ? "Replaced" : "Added", co->name, co->value, co->domain, co->path, co->expires); if(!replaces) diff --git a/lib/curl_sha512_256.c b/lib/curl_sha512_256.c index cc49aa4c7750..78f60dfc2645 100644 --- a/lib/curl_sha512_256.c +++ b/lib/curl_sha512_256.c @@ -238,8 +238,7 @@ static CURLcode Curl_sha512_256_update(void *context, # bytes * @return always CURLE_OK */ -static CURLcode Curl_sha512_256_finish(unsigned char *digest, - void *context) +static CURLcode Curl_sha512_256_finish(unsigned char *digest, void *context) { Curl_sha512_256_ctx * const ctx = (Curl_sha512_256_ctx *)context; @@ -453,19 +452,19 @@ static void Curl_sha512_256_transform(uint64_t H[SHA512_256_HASH_SIZE_WORDS], /* 'Ch' and 'Maj' macro functions are defined with widely-used optimization. See FIPS PUB 180-4 formulae 4.8, 4.9. */ -#define Sha512_Ch(x, y, z) ( (z) ^ ((x) & ((y) ^ (z))) ) -#define Sha512_Maj(x, y, z) ( ((x) & (y)) ^ ((z) & ((x) ^ (y))) ) +#define Sha512_Ch(x, y, z) ((z) ^ ((x) & ((y) ^ (z)))) +#define Sha512_Maj(x, y, z) (((x) & (y)) ^ ((z) & ((x) ^ (y)))) /* Four 'Sigma' macro functions. See FIPS PUB 180-4 formulae 4.10, 4.11, 4.12, 4.13. */ #define SIG0(x) \ - ( Curl_rotr64((x), 28) ^ Curl_rotr64((x), 34) ^ Curl_rotr64((x), 39) ) + (Curl_rotr64((x), 28) ^ Curl_rotr64((x), 34) ^ Curl_rotr64((x), 39)) #define SIG1(x) \ - ( Curl_rotr64((x), 14) ^ Curl_rotr64((x), 18) ^ Curl_rotr64((x), 41) ) + (Curl_rotr64((x), 14) ^ Curl_rotr64((x), 18) ^ Curl_rotr64((x), 41)) #define sig0(x) \ - ( Curl_rotr64((x), 1) ^ Curl_rotr64((x), 8) ^ ((x) >> 7) ) + (Curl_rotr64((x), 1) ^ Curl_rotr64((x), 8) ^ ((x) >> 7)) #define sig1(x) \ - ( Curl_rotr64((x), 19) ^ Curl_rotr64((x), 61) ^ ((x) >> 6) ) + (Curl_rotr64((x), 19) ^ Curl_rotr64((x), 61) ^ ((x) >> 6)) if(1) { unsigned int t; @@ -628,9 +627,7 @@ static CURLcode Curl_sha512_256_update(void *context, if(length >= bytes_left) { /* Combine new data with data in the buffer and process the full block. */ - memcpy(((unsigned char *)ctx_buf) + bytes_have, - data, - bytes_left); + memcpy(((unsigned char *)ctx_buf) + bytes_have, data, bytes_left); data += bytes_left; length -= bytes_left; Curl_sha512_256_transform(ctx->H, ctx->buffer); diff --git a/lib/formdata.c b/lib/formdata.c index d5f6776a3d5f..b0c57b8d6f06 100644 --- a/lib/formdata.c +++ b/lib/formdata.c @@ -252,7 +252,7 @@ static CURLFORMcode FormAddCheck(struct FormInfo *first_form, (form->flags & HTTPPOST_BUFFER)) && !Curl_bufref_ptr(&form->contenttype)) { const char *f = Curl_bufref_ptr((form->flags & HTTPPOST_BUFFER) ? - &form->showfilename : &form->value); + &form->showfilename : &form->value); const char *type = Curl_mime_contenttype(f); if(!type) type = prevtype; @@ -276,7 +276,7 @@ static CURLFORMcode FormAddCheck(struct FormInfo *first_form, if(!(form->flags & (HTTPPOST_FILENAME | HTTPPOST_READFILE | HTTPPOST_PTRCONTENTS | HTTPPOST_PTRBUFFER | HTTPPOST_CALLBACK))) { - if(FormInfoCopyField(&form->value, (size_t) form->contentslength)) + if(FormInfoCopyField(&form->value, (size_t)form->contentslength)) return CURL_FORMADD_MEMORY; } post = AddHttpPost(form, post, httppost, last_post); @@ -315,11 +315,11 @@ static CURLFORMcode FormAdd(struct curl_httppost **httppost, struct curl_httppost *newchain = NULL; struct curl_httppost *lastnode = NULL; -#define form_ptr_arg(t) (forms ? (t) (void *) avalue : va_arg(params, t)) +#define form_ptr_arg(t) (forms ? (t)(void *)avalue : va_arg(params, t)) #ifdef HAVE_STDINT_H -#define form_int_arg(t) (forms ? (t) (uintptr_t) avalue : va_arg(params, t)) +#define form_int_arg(t) (forms ? (t)(uintptr_t)avalue : va_arg(params, t)) #else -#define form_int_arg(t) (forms ? (t) (void *) avalue : va_arg(params, t)) +#define form_int_arg(t) (forms ? (t)(void *)avalue : va_arg(params, t)) #endif /* @@ -391,7 +391,7 @@ static CURLFORMcode FormAdd(struct curl_httppost **httppost, if(curr->namelength) retval = CURL_FORMADD_OPTION_TWICE; else - curr->namelength = (size_t) form_int_arg(long); + curr->namelength = (size_t)form_int_arg(long); break; /* @@ -412,7 +412,7 @@ static CURLFORMcode FormAdd(struct curl_httppost **httppost, } break; case CURLFORM_CONTENTSLENGTH: - curr->contentslength = (curl_off_t)(size_t) form_int_arg(long); + curr->contentslength = (curl_off_t)(size_t)form_int_arg(long); break; case CURLFORM_CONTENTLEN: @@ -493,7 +493,7 @@ static CURLFORMcode FormAdd(struct curl_httppost **httppost, if(curr->bufferlength) retval = CURL_FORMADD_OPTION_TWICE; else - curr->bufferlength = (size_t) form_int_arg(long); + curr->bufferlength = (size_t)form_int_arg(long); break; case CURLFORM_STREAM: @@ -521,7 +521,7 @@ static CURLFORMcode FormAdd(struct curl_httppost **httppost, if(avalue) { form = NewFormInfo(); if(!form || Curl_bufref_memdup0(&form->contenttype, avalue, - strlen(avalue))) { + strlen(avalue))) { curlx_free(form); retval = CURL_FORMADD_MEMORY; } @@ -793,10 +793,10 @@ CURLcode Curl_getformdata(CURL *data, #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wcast-function-type-strict" #endif - result = curl_mime_data_cb(part, (curl_off_t) -1, - (curl_read_callback) fread, + result = curl_mime_data_cb(part, (curl_off_t)-1, + (curl_read_callback)fread, curlx_fseek, - NULL, (void *) stdin); + NULL, (void *)stdin); #if defined(__clang__) && __clang_major__ >= 16 #pragma clang diagnostic pop #endif diff --git a/lib/ftp.c b/lib/ftp.c index 49f042c7c4c7..4e528259c914 100644 --- a/lib/ftp.c +++ b/lib/ftp.c @@ -81,8 +81,8 @@ /* macro to check for a three-digit ftp status code at the start of the given string */ -#define STATUSCODE(line) (ISDIGIT(line[0]) && ISDIGIT(line[1]) && \ - ISDIGIT(line[2])) +#define STATUSCODE(line) \ + (ISDIGIT(line[0]) && ISDIGIT(line[1]) && ISDIGIT(line[2])) /* macro to check for the last line in an FTP server response */ #define LASTLINE(line) (STATUSCODE(line) && (' ' == line[3])) @@ -1749,8 +1749,7 @@ static CURLcode ftp_epsv_disable(struct Curl_easy *data, return result; } -static CURLcode ftp_control_addr_dup(struct Curl_easy *data, - char **newhostp) +static CURLcode ftp_control_addr_dup(struct Curl_easy *data, char **newhostp) { struct connectdata *conn = data->conn; struct ip_quadruple ipquad; diff --git a/lib/hostip.c b/lib/hostip.c index ba9e3ddd7ac9..4f4122d6ae1f 100644 --- a/lib/hostip.c +++ b/lib/hostip.c @@ -217,7 +217,7 @@ static timediff_t dnscache_prune(struct Curl_hash *hostcache, user.oldest_ms = 0; Curl_hash_clean_with_criterium(hostcache, - (void *) &user, + (void *)&user, dnscache_entry_is_stale); return user.oldest_ms; diff --git a/lib/http_aws_sigv4.c b/lib/http_aws_sigv4.c index da80f1965809..850daf413952 100644 --- a/lib/http_aws_sigv4.c +++ b/lib/http_aws_sigv4.c @@ -448,7 +448,7 @@ static CURLcode calc_payload_hash(struct Curl_easy *data, else post_data_len = (size_t)data->set.postfieldsize; } - result = Curl_sha256it(sha_hash, (const unsigned char *) post_data, + result = Curl_sha256it(sha_hash, (const unsigned char *)post_data, post_data_len); if(!result) sha256_to_hex(sha_hex, sha_hash); diff --git a/lib/ldap.c b/lib/ldap.c index b6ed43d90415..6104ff207344 100644 --- a/lib/ldap.c +++ b/lib/ldap.c @@ -143,11 +143,11 @@ static void ldap_free_urldesc_low(LDAPURLDesc *ludp); #endif /* !HAVE_LDAP_URL_PARSE */ #ifdef DEBUG_LDAP -#define LDAP_TRACE(x) \ -do { \ - ldap_trace_low("%u: ", __LINE__); \ - ldap_trace_low x; \ -} while(0) +#define LDAP_TRACE(x) \ + do { \ + ldap_trace_low("%u: ", __LINE__); \ + ldap_trace_low x; \ + } while(0) static void ldap_trace_low(const char *fmt, ...) CURL_PRINTF(1, 2); #else diff --git a/lib/url.c b/lib/url.c index 194810553e18..043d7ca72cb3 100644 --- a/lib/url.c +++ b/lib/url.c @@ -1769,7 +1769,7 @@ static CURLcode parseurlandfillconn(struct Curl_easy *data, if(!use_set_uh) { char *newurl; uc = curl_url_set(uh, CURLUPART_URL, Curl_bufref_ptr(&data->state.url), - (unsigned int) (CURLU_GUESS_SCHEME | + (unsigned int)(CURLU_GUESS_SCHEME | CURLU_NON_SUPPORT_SCHEME | (data->set.disallow_username_in_url ? CURLU_DISALLOW_USER : 0) | @@ -3199,7 +3199,7 @@ static CURLcode resolve_server(struct Curl_easy *data, #ifndef CURL_DISABLE_PROXY if(!unix_path && CONN_IS_PROXIED(conn) && conn->socks_proxy.host.name && - !strncmp(UNIX_SOCKET_PREFIX"/", + !strncmp(UNIX_SOCKET_PREFIX "/", conn->socks_proxy.host.name, sizeof(UNIX_SOCKET_PREFIX))) unix_path = conn->socks_proxy.host.name + sizeof(UNIX_SOCKET_PREFIX) - 1; #endif diff --git a/lib/vauth/digest_sspi.c b/lib/vauth/digest_sspi.c index fc2c1393750f..c92b53dcfc22 100644 --- a/lib/vauth/digest_sspi.c +++ b/lib/vauth/digest_sspi.c @@ -452,10 +452,10 @@ CURLcode Curl_auth_create_digest_http_message(struct Curl_easy *data, chlg_buf[0].cbBuffer = 0; chlg_buf[1].BufferType = SECBUFFER_PKG_PARAMS; chlg_buf[1].pvBuffer = CURL_UNCONST(request); - chlg_buf[1].cbBuffer = curlx_uztoul(strlen((const char *) request)); + chlg_buf[1].cbBuffer = curlx_uztoul(strlen((const char *)request)); chlg_buf[2].BufferType = SECBUFFER_PKG_PARAMS; chlg_buf[2].pvBuffer = CURL_UNCONST(uripath); - chlg_buf[2].cbBuffer = curlx_uztoul(strlen((const char *) uripath)); + chlg_buf[2].cbBuffer = curlx_uztoul(strlen((const char *)uripath)); chlg_buf[3].BufferType = SECBUFFER_PKG_PARAMS; chlg_buf[3].pvBuffer = NULL; chlg_buf[3].cbBuffer = 0; @@ -495,7 +495,7 @@ CURLcode Curl_auth_create_digest_http_message(struct Curl_easy *data, } /* Populate our identity domain */ - if(Curl_override_sspi_http_realm((const char *) digest->input_token, + if(Curl_override_sspi_http_realm((const char *)digest->input_token, &identity)) { Curl_sspi_free_identity(&identity); curlx_free(output_token); @@ -552,7 +552,7 @@ CURLcode Curl_auth_create_digest_http_message(struct Curl_easy *data, chlg_buf[0].cbBuffer = curlx_uztoul(digest->input_token_len); chlg_buf[1].BufferType = SECBUFFER_PKG_PARAMS; chlg_buf[1].pvBuffer = CURL_UNCONST(request); - chlg_buf[1].cbBuffer = curlx_uztoul(strlen((const char *) request)); + chlg_buf[1].cbBuffer = curlx_uztoul(strlen((const char *)request)); chlg_buf[2].BufferType = SECBUFFER_PKG_PARAMS; chlg_buf[2].pvBuffer = NULL; chlg_buf[2].cbBuffer = 0; @@ -565,7 +565,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((const char *) uripath); + spn = curlx_convert_UTF8_to_tchar((const char *)uripath); if(!spn) { Curl_pSecFn->FreeCredentialsHandle(&credentials); diff --git a/lib/vquic/curl_ngtcp2.c b/lib/vquic/curl_ngtcp2.c index 690ef252a037..b9eaa1e98e2e 100644 --- a/lib/vquic/curl_ngtcp2.c +++ b/lib/vquic/curl_ngtcp2.c @@ -73,7 +73,7 @@ #include "../curlx/warnless.h" -#define QUIC_MAX_STREAMS (256 * 1024) +#define QUIC_MAX_STREAMS (256 * 1024) #define QUIC_HANDSHAKE_TIMEOUT (10 * NGTCP2_SECONDS) /* A stream window is the maximum amount we need to buffer for @@ -91,12 +91,11 @@ * spares. Memory consumption goes down when streams run empty, * have a large upload done, etc. */ #define H3_STREAM_POOL_SPARES \ - (H3_STREAM_WINDOW_SIZE / H3_STREAM_CHUNK_SIZE ) / 2 + (H3_STREAM_WINDOW_SIZE / H3_STREAM_CHUNK_SIZE) / 2 /* Receive and Send max number of chunks just follows from the * chunk size and window size */ #define H3_STREAM_SEND_CHUNKS \ - (H3_STREAM_WINDOW_SIZE / H3_STREAM_CHUNK_SIZE) - + (H3_STREAM_WINDOW_SIZE / H3_STREAM_CHUNK_SIZE) /* * Store ngtcp2 version info in this buffer. @@ -959,7 +958,7 @@ static CURLcode cf_ngtcp2_adjust_pollset(struct Curl_cfilter *cf, CF_DATA_SAVE(save, cf, data); c_exhaust = want_send && (!ngtcp2_conn_get_cwnd_left(ctx->qconn) || - !ngtcp2_conn_get_max_data_left(ctx->qconn)); + !ngtcp2_conn_get_max_data_left(ctx->qconn)); s_exhaust = want_send && stream && stream->id >= 0 && stream->quic_flow_blocked; want_recv = (want_recv || c_exhaust || s_exhaust); @@ -2513,7 +2512,7 @@ static CURLcode cf_connect_start(struct Curl_cfilter *cf, CURLcode result; const struct Curl_sockaddr_ex *sockaddr = NULL; int qfd; - static const struct alpn_spec ALPN_SPEC_H3 = {{ "h3", "h3-29" }, 2}; + static const struct alpn_spec ALPN_SPEC_H3 = { { "h3", "h3-29" }, 2 }; DEBUGASSERT(ctx->initialized); ctx->dcid.datalen = NGTCP2_MAX_CIDLEN; diff --git a/lib/vquic/curl_osslq.c b/lib/vquic/curl_osslq.c index 73cea21a15dc..4e6e325295e4 100644 --- a/lib/vquic/curl_osslq.c +++ b/lib/vquic/curl_osslq.c @@ -70,13 +70,13 @@ * spares. Memory consumption goes down when streams run empty, * have a large upload done, etc. */ #define H3_STREAM_POOL_SPARES \ - (H3_STREAM_WINDOW_SIZE / H3_STREAM_CHUNK_SIZE ) / 2 + (H3_STREAM_WINDOW_SIZE / H3_STREAM_CHUNK_SIZE) / 2 /* Receive and Send max number of chunks just follows from the * chunk size and window size */ #define H3_STREAM_RECV_CHUNKS \ - (H3_STREAM_WINDOW_SIZE / H3_STREAM_CHUNK_SIZE) + (H3_STREAM_WINDOW_SIZE / H3_STREAM_CHUNK_SIZE) #define H3_STREAM_SEND_CHUNKS \ - (H3_STREAM_WINDOW_SIZE / H3_STREAM_CHUNK_SIZE) + (H3_STREAM_WINDOW_SIZE / H3_STREAM_CHUNK_SIZE) #if defined(OPENSSL_IS_BORINGSSL) || defined(OPENSSL_IS_AWSLC) typedef uint32_t sslerr_t; @@ -87,8 +87,7 @@ typedef unsigned long sslerr_t; /* How to access `call_data` from a cf_osslq filter */ #undef CF_CTX_CALL_DATA -#define CF_CTX_CALL_DATA(cf) \ - ((struct cf_osslq_ctx *)(cf)->ctx)->call_data +#define CF_CTX_CALL_DATA(cf) ((struct cf_osslq_ctx *)(cf)->ctx)->call_data static CURLcode cf_progress_ingress(struct Curl_cfilter *cf, struct Curl_easy *data); @@ -954,7 +953,7 @@ static int cb_h3_reset_stream(nghttp3_conn *conn, int64_t stream_id, (void)conn; if(stream && stream->s.ssl) { - SSL_STREAM_RESET_ARGS args = {0}; + SSL_STREAM_RESET_ARGS args = { 0 }; args.quic_error_code = app_error_code; rv = !SSL_stream_reset(stream->s.ssl, &args, sizeof(args)); CURL_TRC_CF(data, cf, "[%" PRId64 "] reset -> %d", stream_id, rv); diff --git a/lib/vquic/curl_quiche.c b/lib/vquic/curl_quiche.c index 7082d55916b8..feceaf6369d9 100644 --- a/lib/vquic/curl_quiche.c +++ b/lib/vquic/curl_quiche.c @@ -65,11 +65,11 @@ * stream buffer to not keep spares. Memory consumption goes down when streams * run empty, have a large upload done, etc. */ #define H3_STREAM_POOL_SPARES \ - (H3_STREAM_WINDOW_SIZE / H3_STREAM_CHUNK_SIZE ) / 2 + (H3_STREAM_WINDOW_SIZE / H3_STREAM_CHUNK_SIZE) / 2 /* Receive and Send max number of chunks just follows from the * chunk size and window size */ #define H3_STREAM_RECV_CHUNKS \ - (H3_STREAM_WINDOW_SIZE / H3_STREAM_CHUNK_SIZE) + (H3_STREAM_WINDOW_SIZE / H3_STREAM_CHUNK_SIZE) /* * Store quiche version info in this buffer. @@ -1228,7 +1228,7 @@ static CURLcode cf_quiche_ctx_open(struct Curl_cfilter *cf, int rv; CURLcode result; const struct Curl_sockaddr_ex *sockaddr; - static const struct alpn_spec ALPN_SPEC_H3 = {{ "h3" }, 1}; + static const struct alpn_spec ALPN_SPEC_H3 = { { "h3" }, 1 }; DEBUGASSERT(ctx->q.sockfd != CURL_SOCKET_BAD); DEBUGASSERT(ctx->initialized); diff --git a/lib/vquic/vquic-tls.c b/lib/vquic/vquic-tls.c index 99b19b369185..d121b993790b 100644 --- a/lib/vquic/vquic-tls.c +++ b/lib/vquic/vquic-tls.c @@ -178,12 +178,12 @@ CURLcode Curl_vquic_tls_verify_peer(struct curl_tls_ctx *ctx, if(!cert) result = CURLE_OUT_OF_MEMORY; else if(peer->sni && - (wolfSSL_X509_check_host(cert, peer->sni, strlen(peer->sni), 0, NULL) - == WOLFSSL_FAILURE)) + (wolfSSL_X509_check_host(cert, peer->sni, strlen(peer->sni), 0, + NULL) == WOLFSSL_FAILURE)) result = CURLE_PEER_FAILED_VERIFICATION; else if(!peer->sni && - (wolfSSL_X509_check_ip_asc(cert, peer->hostname, 0) - == WOLFSSL_FAILURE)) + (wolfSSL_X509_check_ip_asc(cert, peer->hostname, + 0) == WOLFSSL_FAILURE)) result = CURLE_PEER_FAILED_VERIFICATION; wolfSSL_X509_free(cert); } diff --git a/lib/vquic/vquic.c b/lib/vquic/vquic.c index a4dea8a77c43..125c31135ed8 100644 --- a/lib/vquic/vquic.c +++ b/lib/vquic/vquic.c @@ -124,7 +124,7 @@ static CURLcode do_sendmsg(struct Curl_cfilter *cf, CURLcode result = CURLE_OK; #ifdef HAVE_SENDMSG struct iovec msg_iov; - struct msghdr msg = {0}; + struct msghdr msg = { 0 }; ssize_t rv; #if defined(__linux__) && defined(UDP_SEGMENT) uint8_t msg_ctrl[32]; @@ -153,8 +153,7 @@ static CURLcode do_sendmsg(struct Curl_cfilter *cf, } #endif - while((rv = sendmsg(qctx->sockfd, &msg, 0)) == -1 && - SOCKERRNO == SOCKEINTR) + while((rv = sendmsg(qctx->sockfd, &msg, 0)) == -1 && SOCKERRNO == SOCKEINTR) ; if(!curlx_sztouz(rv, psent)) { @@ -516,7 +515,7 @@ static CURLcode recvmsg_packets(struct Curl_cfilter *cf, } curlx_strerror(SOCKERRNO, errstr, sizeof(errstr)); failf(data, "QUIC: recvmsg() unexpectedly returned %zd (errno=%d; %s)", - rc, SOCKERRNO, errstr); + rc, SOCKERRNO, errstr); result = CURLE_RECV_ERROR; goto out; } @@ -581,7 +580,7 @@ static CURLcode recvfrom_packets(struct Curl_cfilter *cf, } curlx_strerror(SOCKERRNO, errstr, sizeof(errstr)); failf(data, "QUIC: recvfrom() unexpectedly returned %zd (errno=%d; %s)", - rv, SOCKERRNO, errstr); + rv, SOCKERRNO, errstr); result = CURLE_RECV_ERROR; goto out; } diff --git a/lib/vquic/vquic_int.h b/lib/vquic/vquic_int.h index b4f2fd811680..cd8e8989d2ea 100644 --- a/lib/vquic/vquic_int.h +++ b/lib/vquic/vquic_int.h @@ -29,7 +29,7 @@ #ifdef USE_HTTP3 -#define MAX_PKT_BURST 10 +#define MAX_PKT_BURST 10 #define MAX_UDP_PAYLOAD_SIZE 1452 struct cf_quic_ctx { diff --git a/lib/vtls/apple.c b/lib/vtls/apple.c index 31108763a02a..f076caf5ffa2 100644 --- a/lib/vtls/apple.c +++ b/lib/vtls/apple.c @@ -54,31 +54,31 @@ #ifdef USE_APPLE_SECTRUST #define SSL_SYSTEM_VERIFIER -#if (defined(MAC_OS_X_VERSION_MAX_ALLOWED) \ - && MAC_OS_X_VERSION_MAX_ALLOWED >= 101400) \ - || (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) \ - && __IPHONE_OS_VERSION_MAX_ALLOWED >= 120000) +#if (defined(MAC_OS_X_VERSION_MAX_ALLOWED) && \ + MAC_OS_X_VERSION_MAX_ALLOWED >= 101400) || \ + (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && \ + __IPHONE_OS_VERSION_MAX_ALLOWED >= 120000) #define SUPPORTS_SecTrustEvaluateWithError 1 #endif -#if defined(SUPPORTS_SecTrustEvaluateWithError) \ - && ((defined(MAC_OS_X_VERSION_MIN_REQUIRED) \ - && MAC_OS_X_VERSION_MIN_REQUIRED >= 101400) \ - || (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) \ - && __IPHONE_OS_VERSION_MIN_REQUIRED >= 120000)) +#if defined(SUPPORTS_SecTrustEvaluateWithError) && \ + ((defined(MAC_OS_X_VERSION_MIN_REQUIRED) && \ + MAC_OS_X_VERSION_MIN_REQUIRED >= 101400) || \ + (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && \ + __IPHONE_OS_VERSION_MIN_REQUIRED >= 120000)) #define REQUIRES_SecTrustEvaluateWithError 1 #endif -#if defined(SUPPORTS_SecTrustEvaluateWithError) \ - && !defined(HAVE_BUILTIN_AVAILABLE) \ - && !defined(REQUIRES_SecTrustEvaluateWithError) +#if defined(SUPPORTS_SecTrustEvaluateWithError) && \ + !defined(HAVE_BUILTIN_AVAILABLE) && \ + !defined(REQUIRES_SecTrustEvaluateWithError) #undef SUPPORTS_SecTrustEvaluateWithError #endif -#if (defined(MAC_OS_X_VERSION_MAX_ALLOWED) \ - && MAC_OS_X_VERSION_MAX_ALLOWED >= 100900) \ - || (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) \ - && __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000) +#if (defined(MAC_OS_X_VERSION_MAX_ALLOWED) && \ + MAC_OS_X_VERSION_MAX_ALLOWED >= 100900) || \ + (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && \ + __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000) #define SUPPORTS_SecOCSP 1 #endif diff --git a/lib/vtls/cipher_suite.c b/lib/vtls/cipher_suite.c index 3726187d7fcc..58d755622070 100644 --- a/lib/vtls/cipher_suite.c +++ b/lib/vtls/cipher_suite.c @@ -157,7 +157,7 @@ struct cs_entry { }; /* !checksrc! disable COMMANOSPACE all */ -static const struct cs_entry cs_list [] = { +static const struct cs_entry cs_list[] = { /* TLS 1.3 ciphers */ #if defined(USE_MBEDTLS) || defined(USE_RUSTLS) CS_ENTRY(0x1301, TLS,AES,128,GCM,SHA256,,,), @@ -549,7 +549,7 @@ static const struct cs_entry cs_list [] = { static int cs_str_to_zip(const char *cs_str, size_t cs_len, uint8_t zip[6]) { - uint8_t indexes[8] = {0}; + uint8_t indexes[8] = { 0 }; const char *entry, *cur; const char *nxt = cs_str; const char *end = cs_str + cs_len; @@ -597,7 +597,7 @@ static int cs_str_to_zip(const char *cs_str, size_t cs_len, uint8_t zip[6]) static int cs_zip_to_str(const uint8_t zip[6], char *buf, size_t buf_size) { - uint8_t indexes[8] = {0}; + uint8_t indexes[8] = { 0 }; const char *entry; char separator = '-'; int idx, i, r; diff --git a/lib/vtls/schannel_verify.c b/lib/vtls/schannel_verify.c index e1a3731457b8..77f9177349d7 100644 --- a/lib/vtls/schannel_verify.c +++ b/lib/vtls/schannel_verify.c @@ -52,8 +52,8 @@ #define BACKEND ((struct schannel_ssl_backend_data *)connssl->backend) #define MAX_CAFILE_SIZE 1048576 /* 1 MiB */ -#define BEGIN_CERT "-----BEGIN CERTIFICATE-----" -#define END_CERT "\n-----END CERTIFICATE-----" +#define BEGIN_CERT "-----BEGIN CERTIFICATE-----" +#define END_CERT "\n-----END CERTIFICATE-----" struct cert_chain_engine_config_win8 { DWORD cbSize; @@ -532,7 +532,7 @@ CURLcode Curl_verify_host(struct Curl_cfilter *cf, struct Curl_easy *data) DWORD actual_len = 0; PCERT_ALT_NAME_INFO alt_name_info = NULL; DWORD alt_name_info_size = 0; - struct num_ip_data ip_blob = {0}; + struct num_ip_data ip_blob = { 0 }; bool Win8_compat; struct num_ip_data *p = &ip_blob; DWORD i; diff --git a/lib/vtls/x509asn1.c b/lib/vtls/x509asn1.c index f63a9fcb9928..d1329410bfc3 100644 --- a/lib/vtls/x509asn1.c +++ b/lib/vtls/x509asn1.c @@ -153,7 +153,7 @@ static const struct Curl_OID OIDtable[] = { { "2.16.840.1.101.3.4.2.2", "sha384" }, { "2.16.840.1.101.3.4.2.3", "sha512" }, { "1.2.840.113549.1.9.2", "unstructuredName" }, - { (const char *) NULL, (const char *) NULL } + { (const char *)NULL, (const char *)NULL } }; #endif /* WANT_EXTRACT_CERTINFO */ diff --git a/tests/libtest/cli_h2_pausing.c b/tests/libtest/cli_h2_pausing.c index 30bcfcf043a6..740c9c2226c5 100644 --- a/tests/libtest/cli_h2_pausing.c +++ b/tests/libtest/cli_h2_pausing.c @@ -174,22 +174,22 @@ static CURLcode test_cli_h2_pausing(const char *URL) handles[i].fail_write = 1; handles[i].curl = curl_easy_init(); if(!handles[i].curl || - curl_easy_setopt(handles[i].curl, CURLOPT_WRITEFUNCTION, cb) - != CURLE_OK || - curl_easy_setopt(handles[i].curl, CURLOPT_WRITEDATA, &handles[i]) - != CURLE_OK || - curl_easy_setopt(handles[i].curl, CURLOPT_FOLLOWLOCATION, 1L) - != CURLE_OK || - curl_easy_setopt(handles[i].curl, CURLOPT_VERBOSE, 1L) != CURLE_OK || - curl_easy_setopt(handles[i].curl, CURLOPT_DEBUGFUNCTION, cli_debug_cb) - != CURLE_OK || - curl_easy_setopt(handles[i].curl, CURLOPT_SSL_VERIFYPEER, 0L) - != CURLE_OK || - curl_easy_setopt(handles[i].curl, CURLOPT_RESOLVE, resolve) - != CURLE_OK || - curl_easy_setopt(handles[i].curl, CURLOPT_PIPEWAIT, 1L) != CURLE_OK || - curl_easy_setopt(handles[i].curl, CURLOPT_URL, url) != CURLE_OK) { - curl_mfprintf(stderr, "failed configuring easy handle - bailing out\n"); + curl_easy_setopt(handles[i].curl, CURLOPT_WRITEFUNCTION, cb) + != CURLE_OK || + curl_easy_setopt(handles[i].curl, CURLOPT_WRITEDATA, &handles[i]) + != CURLE_OK || + curl_easy_setopt(handles[i].curl, CURLOPT_FOLLOWLOCATION, 1L) + != CURLE_OK || + curl_easy_setopt(handles[i].curl, CURLOPT_VERBOSE, 1L) != CURLE_OK || + curl_easy_setopt(handles[i].curl, CURLOPT_DEBUGFUNCTION, cli_debug_cb) + != CURLE_OK || + curl_easy_setopt(handles[i].curl, CURLOPT_SSL_VERIFYPEER, 0L) + != CURLE_OK || + curl_easy_setopt(handles[i].curl, CURLOPT_RESOLVE, resolve) + != CURLE_OK || + curl_easy_setopt(handles[i].curl, CURLOPT_PIPEWAIT, 1L) != CURLE_OK || + curl_easy_setopt(handles[i].curl, CURLOPT_URL, url) != CURLE_OK) { + curl_mfprintf(stderr, "failed configuring easy handle - bailing out\n"); res = (CURLcode)2; goto cleanup; } diff --git a/tests/libtest/cli_hx_download.c b/tests/libtest/cli_hx_download.c index d139ea28f772..ca1e343a8d88 100644 --- a/tests/libtest/cli_hx_download.c +++ b/tests/libtest/cli_hx_download.c @@ -178,8 +178,8 @@ static int my_progress_d_cb(void *userdata, #endif #ifdef USE_MBEDTLS case CURLSSLBACKEND_MBEDTLS: { - const char *version = mbedtls_ssl_get_version( - (mbedtls_ssl_context*)tls->internals); + const char *version = + mbedtls_ssl_get_version((mbedtls_ssl_context *)tls->internals); assert(version); assert(strcmp(version, "unknown")); curl_mfprintf(stderr, "[t-%zu] info mbedTLS using %s\n", @@ -190,7 +190,7 @@ static int my_progress_d_cb(void *userdata, #ifdef USE_RUSTLS case CURLSSLBACKEND_RUSTLS: { int v = rustls_connection_get_protocol_version( - (struct rustls_connection*)tls->internals); + (struct rustls_connection *)tls->internals); assert(v); curl_mfprintf(stderr, "[t-%zu] info rustls TLS version 0x%x\n", t->idx, v); @@ -514,8 +514,8 @@ static CURLcode test_cli_hx_download(const char *URL) if(!t->started) { t->curl = curl_easy_init(); if(!t->curl || - setup_hx_download(t->curl, url, t, http_version, host, share, - use_earlydata, fresh_connect)) { + setup_hx_download(t->curl, url, t, http_version, host, share, + use_earlydata, fresh_connect)) { curl_mfprintf(stderr, "[t-%zu] FAILED setup\n", i); res = (CURLcode)1; goto cleanup; diff --git a/tests/libtest/first.c b/tests/libtest/first.c index e384971c7efc..f060560371ad 100644 --- a/tests/libtest/first.c +++ b/tests/libtest/first.c @@ -62,7 +62,7 @@ int unitfail; /* for unittests */ int coptind; const char *coptarg; -int cgetopt(int argc, const char *const argv[], const char *optstring) +int cgetopt(int argc, const char * const argv[], const char *optstring) { static int optpos = 1; int coptopt; @@ -141,7 +141,7 @@ static void memory_tracking_init(void) } } #else -# define memory_tracking_init() Curl_nop_stmt +#define memory_tracking_init() Curl_nop_stmt #endif /* returns a hexdump in a static memory area */ diff --git a/tests/libtest/first.h b/tests/libtest/first.h index 5fa587686b56..2ad600ef60e2 100644 --- a/tests/libtest/first.h +++ b/tests/libtest/first.h @@ -59,11 +59,11 @@ extern int unitfail; /* for unittests */ #define CURL_GNUC_DIAG #endif -#define test_setopt(A,B,C) \ +#define test_setopt(A, B, C) \ if((res = curl_easy_setopt((A), (B), (C))) != CURLE_OK) \ goto test_cleanup -#define test_multi_setopt(A,B,C) \ +#define test_multi_setopt(A, B, C) \ if((res = curl_multi_setopt((A), (B), (C))) != CURLE_OK) \ goto test_cleanup @@ -79,7 +79,7 @@ extern struct curltime tv_test_start; /* for test timing */ extern int coptind; extern const char *coptarg; -int cgetopt(int argc, const char *const argv[], const char *optstring); +int cgetopt(int argc, const char * const argv[], const char *optstring); extern int select_wrapper(int nfds, fd_set *rd, fd_set *wr, fd_set *exc, struct timeval *tv); @@ -100,18 +100,18 @@ void ws_close(CURL *curl); ** For portability reasons TEST_ERR_* values should be less than 127. */ -#define TEST_ERR_MAJOR_BAD CURLE_OBSOLETE20 -#define TEST_ERR_RUNS_FOREVER CURLE_OBSOLETE24 -#define TEST_ERR_EASY_INIT CURLE_OBSOLETE29 -#define TEST_ERR_MULTI CURLE_OBSOLETE32 -#define TEST_ERR_NUM_HANDLES CURLE_OBSOLETE34 -#define TEST_ERR_SELECT CURLE_OBSOLETE40 -#define TEST_ERR_SUCCESS CURLE_OBSOLETE41 -#define TEST_ERR_FAILURE CURLE_OBSOLETE44 -#define TEST_ERR_USAGE CURLE_OBSOLETE46 -#define TEST_ERR_FOPEN CURLE_OBSOLETE50 -#define TEST_ERR_FSTAT CURLE_OBSOLETE51 -#define TEST_ERR_BAD_TIMEOUT CURLE_OBSOLETE57 +#define TEST_ERR_MAJOR_BAD CURLE_OBSOLETE20 +#define TEST_ERR_RUNS_FOREVER CURLE_OBSOLETE24 +#define TEST_ERR_EASY_INIT CURLE_OBSOLETE29 +#define TEST_ERR_MULTI CURLE_OBSOLETE32 +#define TEST_ERR_NUM_HANDLES CURLE_OBSOLETE34 +#define TEST_ERR_SELECT CURLE_OBSOLETE40 +#define TEST_ERR_SUCCESS CURLE_OBSOLETE41 +#define TEST_ERR_FAILURE CURLE_OBSOLETE44 +#define TEST_ERR_USAGE CURLE_OBSOLETE46 +#define TEST_ERR_FOPEN CURLE_OBSOLETE50 +#define TEST_ERR_FSTAT CURLE_OBSOLETE51 +#define TEST_ERR_BAD_TIMEOUT CURLE_OBSOLETE57 /* ** Macros for test source code readability/maintainability. @@ -144,7 +144,7 @@ void ws_close(CURL *curl); /* ---------------------------------------------------------------- */ -#define exe_easy_init(A,Y,Z) do { \ +#define exe_easy_init(A, Y, Z) do { \ if(((A) = curl_easy_init()) == NULL) { \ curl_mfprintf(stderr, "%s:%d curl_easy_init() failed\n", (Y), (Z)); \ res = TEST_ERR_EASY_INIT; \ @@ -154,10 +154,10 @@ void ws_close(CURL *curl); #define res_easy_init(A) \ exe_easy_init((A), (__FILE__), (__LINE__)) -#define chk_easy_init(A,Y,Z) do { \ - exe_easy_init((A), (Y), (Z)); \ - if(res) \ - goto test_cleanup; \ +#define chk_easy_init(A, Y, Z) do { \ + exe_easy_init((A), (Y), (Z)); \ + if(res) \ + goto test_cleanup; \ } while(0) #define easy_init(A) \ @@ -165,7 +165,7 @@ void ws_close(CURL *curl); /* ---------------------------------------------------------------- */ -#define exe_multi_init(A,Y,Z) do { \ +#define exe_multi_init(A, Y, Z) do { \ if(((A) = curl_multi_init()) == NULL) { \ curl_mfprintf(stderr, "%s:%d curl_multi_init() failed\n", (Y), (Z)); \ res = TEST_ERR_MULTI; \ @@ -175,10 +175,10 @@ void ws_close(CURL *curl); #define res_multi_init(A) \ exe_multi_init((A), (__FILE__), (__LINE__)) -#define chk_multi_init(A,Y,Z) do { \ - exe_multi_init((A), (Y), (Z)); \ - if(res) \ - goto test_cleanup; \ +#define chk_multi_init(A, Y, Z) do { \ + exe_multi_init((A), (Y), (Z)); \ + if(res) \ + goto test_cleanup; \ } while(0) #define multi_init(A) \ @@ -186,7 +186,7 @@ void ws_close(CURL *curl); /* ---------------------------------------------------------------- */ -#define exe_easy_setopt(A,B,C,Y,Z) do { \ +#define exe_easy_setopt(A, B, C, Y, Z) do { \ CURLcode ec; \ if((ec = curl_easy_setopt((A), (B), (C))) != CURLE_OK) { \ curl_mfprintf(stderr, "%s:%d curl_easy_setopt() failed, " \ @@ -220,21 +220,21 @@ void ws_close(CURL *curl); } \ } while(0) -#define res_multi_setopt(A,B,C) \ +#define res_multi_setopt(A, B, C) \ exe_multi_setopt((A), (B), (C), (__FILE__), (__LINE__)) -#define chk_multi_setopt(A,B,C,Y,Z) do { \ +#define chk_multi_setopt(A, B, C, Y, Z) do { \ exe_multi_setopt((A), (B), (C), (Y), (Z)); \ if(res) \ goto test_cleanup; \ } while(0) -#define multi_setopt(A,B,C) \ +#define multi_setopt(A, B, C) \ chk_multi_setopt((A), (B), (C), (__FILE__), (__LINE__)) /* ---------------------------------------------------------------- */ -#define exe_multi_add_handle(A,B,Y,Z) do { \ +#define exe_multi_add_handle(A, B, Y, Z) do { \ CURLMcode ec; \ if((ec = curl_multi_add_handle((A), (B))) != CURLM_OK) { \ curl_mfprintf(stderr, "%s:%d curl_multi_add_handle() failed, " \ @@ -258,7 +258,7 @@ void ws_close(CURL *curl); /* ---------------------------------------------------------------- */ -#define exe_multi_remove_handle(A,B,Y,Z) do { \ +#define exe_multi_remove_handle(A, B, Y, Z) do { \ CURLMcode ec; \ if((ec = curl_multi_remove_handle((A), (B))) != CURLM_OK) { \ curl_mfprintf(stderr, "%s:%d curl_multi_remove_handle() failed, " \ @@ -283,7 +283,7 @@ void ws_close(CURL *curl); /* ---------------------------------------------------------------- */ -#define exe_multi_perform(A,B,Y,Z) do { \ +#define exe_multi_perform(A, B, Y, Z) do { \ CURLMcode ec; \ if((ec = curl_multi_perform((A), (B))) != CURLM_OK) { \ curl_mfprintf(stderr, "%s:%d curl_multi_perform() failed, " \ @@ -308,7 +308,7 @@ void ws_close(CURL *curl); goto test_cleanup; \ } while(0) -#define multi_perform(A,B) \ +#define multi_perform(A, B) \ chk_multi_perform((A), (B), (__FILE__), (__LINE__)) /* ---------------------------------------------------------------- */ @@ -343,7 +343,7 @@ void ws_close(CURL *curl); /* ---------------------------------------------------------------- */ -#define exe_multi_timeout(A,B,Y,Z) do { \ +#define exe_multi_timeout(A, B, Y, Z) do { \ CURLMcode ec; \ if((ec = curl_multi_timeout((A), (B))) != CURLM_OK) { \ curl_mfprintf(stderr, "%s:%d curl_multi_timeout() failed, " \ @@ -373,7 +373,7 @@ void ws_close(CURL *curl); /* ---------------------------------------------------------------- */ -#define exe_multi_poll(A,B,C,D,E,Y,Z) do { \ +#define exe_multi_poll(A, B, C, D, E, Y, Z) do { \ CURLMcode ec; \ if((ec = curl_multi_poll((A), (B), (C), (D), (E))) != CURLM_OK) { \ curl_mfprintf(stderr, "%s:%d curl_multi_poll() failed, " \ @@ -403,7 +403,7 @@ void ws_close(CURL *curl); /* ---------------------------------------------------------------- */ -#define exe_multi_wakeup(A,Y,Z) do { \ +#define exe_multi_wakeup(A, Y, Z) do { \ CURLMcode ec; \ if((ec = curl_multi_wakeup((A))) != CURLM_OK) { \ curl_mfprintf(stderr, "%s:%d curl_multi_wakeup() failed, " \ @@ -460,7 +460,7 @@ void ws_close(CURL *curl); #define TEST_HANG_TIMEOUT 60 * 1000 /* global default */ -#define exe_test_timedout(T,Y,Z) do { \ +#define exe_test_timedout(T, Y, Z) do { \ timediff_t timediff = curlx_timediff_ms(curlx_now(), tv_test_start); \ if(timediff > (T)) { \ curl_mfprintf(stderr, "%s:%d ABORTING TEST, since it seems " \ @@ -490,7 +490,7 @@ void ws_close(CURL *curl); /* ---------------------------------------------------------------- */ -#define exe_global_init(A,Y,Z) do { \ +#define exe_global_init(A, Y, Z) do { \ CURLcode ec; \ if((ec = curl_global_init((A))) != CURLE_OK) { \ curl_mfprintf(stderr, "%s:%d curl_global_init() failed, " \ diff --git a/tests/libtest/lib1156.c b/tests/libtest/lib1156.c index 1468b35e1cc7..bfabd4b412a3 100644 --- a/tests/libtest/lib1156.c +++ b/tests/libtest/lib1156.c @@ -34,11 +34,11 @@ */ -#define F_RESUME (1 << 0) /* resume/range. */ -#define F_HTTP416 (1 << 1) /* Server returns http code 416. */ -#define F_FAIL (1 << 2) /* Fail on error. */ -#define F_CONTENTRANGE (1 << 3) /* Server sends content-range hdr. */ -#define F_IGNOREBODY (1 << 4) /* Body should be ignored. */ +#define F_RESUME (1 << 0) /* resume/range. */ +#define F_HTTP416 (1 << 1) /* Server returns http code 416. */ +#define F_FAIL (1 << 2) /* Fail on error. */ +#define F_CONTENTRANGE (1 << 3) /* Server sends content-range hdr. */ +#define F_IGNOREBODY (1 << 4) /* Body should be ignored. */ struct testparams { unsigned int flags; /* ORed flags as above. */ diff --git a/tests/libtest/lib1506.c b/tests/libtest/lib1506.c index 8b986c59a029..a2d60e175758 100644 --- a/tests/libtest/lib1506.c +++ b/tests/libtest/lib1506.c @@ -26,7 +26,7 @@ static CURLcode test_lib1506(const char *URL) { CURLcode res = CURLE_OK; - CURL *curl[NUM_HANDLES] = {0}; + CURL *curl[NUM_HANDLES] = { 0 }; int running; CURLM *multi = NULL; size_t i; diff --git a/tests/libtest/lib1512.c b/tests/libtest/lib1512.c index 16648d7e56f4..e5c78d3e63b0 100644 --- a/tests/libtest/lib1512.c +++ b/tests/libtest/lib1512.c @@ -33,7 +33,7 @@ static CURLcode test_lib1512(const char *URL) { CURLcode res = CURLE_OK; - CURL *curl[2] = {NULL, NULL}; + CURL *curl[2] = { NULL, NULL }; const char *port = libtest_arg3; const char *address = libtest_arg2; char dnsentry[256]; diff --git a/tests/libtest/lib1514.c b/tests/libtest/lib1514.c index 0ae61d41e88e..be81c0e556e8 100644 --- a/tests/libtest/lib1514.c +++ b/tests/libtest/lib1514.c @@ -57,7 +57,7 @@ static CURLcode test_lib1514(const char *URL) static char testdata[] = "dummy"; - struct t1514_WriteThis pooh = { testdata, sizeof(testdata)-1 }; + struct t1514_WriteThis pooh = { testdata, sizeof(testdata) - 1 }; global_init(CURL_GLOBAL_ALL); diff --git a/tests/libtest/lib1520.c b/tests/libtest/lib1520.c index 076ab564d016..f6e41f16b12d 100644 --- a/tests/libtest/lib1520.c +++ b/tests/libtest/lib1520.c @@ -68,7 +68,7 @@ static CURLcode test_lib1520(const char *URL) CURLcode res; CURL *curl; struct curl_slist *rcpt_list = NULL; - struct upload_status upload_ctx = {0}; + struct upload_status upload_ctx = { 0 }; if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { curl_mfprintf(stderr, "curl_global_init() failed\n"); diff --git a/tests/libtest/lib1537.c b/tests/libtest/lib1537.c index f521986ebc54..9d59725fcf89 100644 --- a/tests/libtest/lib1537.c +++ b/tests/libtest/lib1537.c @@ -25,8 +25,8 @@ static CURLcode test_lib1537(const char *URL) { - const unsigned char a[] = {0x2f, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x91, 0xa2, 0xb3, 0xc4, 0xd5, 0xe6, 0xf7}; + const unsigned char a[] = { 0x2f, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, + 0x91, 0xa2, 0xb3, 0xc4, 0xd5, 0xe6, 0xf7 }; CURLcode res = CURLE_OK; char *ptr = NULL; int asize; diff --git a/tests/libtest/lib1541.c b/tests/libtest/lib1541.c index c39bee989cd7..f1c8c6791a9a 100644 --- a/tests/libtest/lib1541.c +++ b/tests/libtest/lib1541.c @@ -29,7 +29,7 @@ struct t1541_transfer_status { int bd_count; }; -#define KN(a) a, #a +#define KN(a) a, #a static void t1541_geterr(const char *name, CURLcode val, int lineno) { diff --git a/tests/libtest/lib1550.c b/tests/libtest/lib1550.c index b328dd27bc2a..bd9fead1eae8 100644 --- a/tests/libtest/lib1550.c +++ b/tests/libtest/lib1550.c @@ -30,9 +30,9 @@ static CURLcode test_lib1550(const char *URL) CURLM *multi; CURLcode res = CURLE_OK; static const char * const bl_servers[] = - {"Microsoft-IIS/6.0", "nginx/0.8.54", NULL}; + { "Microsoft-IIS/6.0", "nginx/0.8.54", NULL }; static const char * const bl_sites[] = - {"curl.se:443", "example.com:80", NULL}; + { "curl.se:443", "example.com:80", NULL }; global_init(CURL_GLOBAL_ALL); multi = curl_multi_init(); diff --git a/tests/libtest/lib1556.c b/tests/libtest/lib1556.c index e852bb322471..94d409295b3f 100644 --- a/tests/libtest/lib1556.c +++ b/tests/libtest/lib1556.c @@ -45,7 +45,7 @@ static CURLcode test_lib1556(const char *URL) CURLcode code; CURL *curl = NULL; CURLcode res = CURLE_OK; - struct headerinfo info = {0}; + struct headerinfo info = { 0 }; global_init(CURL_GLOBAL_ALL); diff --git a/tests/libtest/lib1560.c b/tests/libtest/lib1560.c index d080d38aa87e..deb24be9dcbc 100644 --- a/tests/libtest/lib1560.c +++ b/tests/libtest/lib1560.c @@ -1859,18 +1859,18 @@ static int get_nothing(void) return 0; } -static const struct clearurlcase clear_url_list[] ={ - {CURLUPART_SCHEME, "http", NULL, CURLUE_NO_SCHEME}, - {CURLUPART_USER, "user", NULL, CURLUE_NO_USER}, - {CURLUPART_PASSWORD, "password", NULL, CURLUE_NO_PASSWORD}, - {CURLUPART_OPTIONS, "options", NULL, CURLUE_NO_OPTIONS}, - {CURLUPART_HOST, "host", NULL, CURLUE_NO_HOST}, - {CURLUPART_ZONEID, "eth0", NULL, CURLUE_NO_ZONEID}, - {CURLUPART_PORT, "1234", NULL, CURLUE_NO_PORT}, - {CURLUPART_PATH, "/hello", "/", CURLUE_OK}, - {CURLUPART_QUERY, "a=b", NULL, CURLUE_NO_QUERY}, - {CURLUPART_FRAGMENT, "anchor", NULL, CURLUE_NO_FRAGMENT}, - {CURLUPART_URL, NULL, NULL, CURLUE_OK}, +static const struct clearurlcase clear_url_list[] = { + { CURLUPART_SCHEME, "http", NULL, CURLUE_NO_SCHEME }, + { CURLUPART_USER, "user", NULL, CURLUE_NO_USER }, + { CURLUPART_PASSWORD, "password", NULL, CURLUE_NO_PASSWORD }, + { CURLUPART_OPTIONS, "options", NULL, CURLUE_NO_OPTIONS }, + { CURLUPART_HOST, "host", NULL, CURLUE_NO_HOST }, + { CURLUPART_ZONEID, "eth0", NULL, CURLUE_NO_ZONEID }, + { CURLUPART_PORT, "1234", NULL, CURLUE_NO_PORT }, + { CURLUPART_PATH, "/hello", "/", CURLUE_OK }, + { CURLUPART_QUERY, "a=b", NULL, CURLUE_NO_QUERY }, + { CURLUPART_FRAGMENT, "anchor", NULL, CURLUE_NO_FRAGMENT }, + { CURLUPART_URL, NULL, NULL, CURLUE_OK }, }; static int clear_url(void) @@ -1935,7 +1935,7 @@ static int huge(void) memset(&bigpart[1], 'a', sizeof(bigpart) - 2); bigpart[sizeof(bigpart) - 1] = 0; - for(i = 0; i < 7; i++) { + for(i = 0; i < 7; i++) { char *partp; curl_msnprintf(total, sizeof(total), "%s://%s:%s@%s/%s?%s#%s", diff --git a/tests/libtest/lib1565.c b/tests/libtest/lib1565.c index 506959dd9083..5bc0e3465d58 100644 --- a/tests/libtest/lib1565.c +++ b/tests/libtest/lib1565.c @@ -26,7 +26,7 @@ #ifdef HAVE_PTHREAD_H #include -#define CONN_NUM 3 +#define CONN_NUM 3 #define TIME_BETWEEN_START_SECS 2 static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; diff --git a/tests/libtest/lib1597.c b/tests/libtest/lib1597.c index 0e86517eadb1..d5124a5141e9 100644 --- a/tests/libtest/lib1597.c +++ b/tests/libtest/lib1597.c @@ -36,7 +36,7 @@ static CURLcode test_lib1597(const char *URL) CURL *curl = NULL; CURLcode res = CURLE_OK; curl_version_info_data *curlinfo; - const char *const *proto; + const char * const *proto; int n; int i; static CURLcode ok = CURLE_OK; @@ -47,22 +47,22 @@ static CURLcode test_lib1597(const char *URL) static char protolist[1024]; static const struct pair prots[] = { - {"goobar", &unsup}, - {"http ", &unsup}, - {" http", &unsup}, - {"http", &httpcode}, - {"http,", &httpcode}, - {"https,", &httpscode}, - {"https,http", &httpscode}, - {"http,http", &httpcode}, - {"HTTP,HTTP", &httpcode}, - {",HTTP,HTTP", &httpcode}, - {"http,http,ft", &unsup}, - {"", &bad}, - {",,", &bad}, - {protolist, &ok}, - {"all", &ok}, - {NULL, NULL}, + { "goobar", &unsup }, + { "http ", &unsup }, + { " http", &unsup }, + { "http", &httpcode }, + { "http,", &httpcode }, + { "https,", &httpscode }, + { "https,http", &httpscode }, + { "http,http", &httpcode }, + { "HTTP,HTTP", &httpcode }, + { ",HTTP,HTTP", &httpcode }, + { "http,http,ft", &unsup }, + { "", &bad }, + { ",,", &bad }, + { protolist, &ok }, + { "all", &ok }, + { NULL, NULL }, }; (void)URL; diff --git a/tests/libtest/lib1911.c b/tests/libtest/lib1911.c index 0f88752b6fbd..9ec68749182f 100644 --- a/tests/libtest/lib1911.c +++ b/tests/libtest/lib1911.c @@ -49,9 +49,7 @@ static CURLcode test_lib1911(const char *URL) curl_mprintf("string length: %zu\n", strlen(testbuf)); - for(o = curl_easy_option_next(NULL); - o; - o = curl_easy_option_next(o)) { + for(o = curl_easy_option_next(NULL); o; o = curl_easy_option_next(o)) { if(o->type == CURLOT_STRING) { CURLcode res; /* diff --git a/tests/libtest/lib1912.c b/tests/libtest/lib1912.c index 76ba51c4479f..98623bd339f5 100644 --- a/tests/libtest/lib1912.c +++ b/tests/libtest/lib1912.c @@ -33,9 +33,7 @@ static CURLcode test_lib1912(const char *URL) int error = 0; #ifdef CURLINC_TYPECHECK_GCC_H const struct curl_easyoption *o; - for(o = curl_easy_option_next(NULL); - o; - o = curl_easy_option_next(o)) { + for(o = curl_easy_option_next(NULL); o; o = curl_easy_option_next(o)) { /* Test for mismatch OR missing typecheck macros */ if(curlcheck_long_option(o->id) != (o->type == CURLOT_LONG || o->type == CURLOT_VALUES)) { diff --git a/tests/libtest/lib1915.c b/tests/libtest/lib1915.c index adb589a8c0fb..406cea0205e7 100644 --- a/tests/libtest/lib1915.c +++ b/tests/libtest/lib1915.c @@ -97,7 +97,7 @@ static CURLcode test_lib1915(const char *URL) { CURLcode res = CURLE_OK; CURL *curl; - struct state st = {0}; + struct state st = { 0 }; global_init(CURL_GLOBAL_ALL); diff --git a/tests/libtest/lib1918.c b/tests/libtest/lib1918.c index d99563916416..1c8ccb78f984 100644 --- a/tests/libtest/lib1918.c +++ b/tests/libtest/lib1918.c @@ -30,9 +30,7 @@ static CURLcode test_lib1918(const char *URL) curl_global_init(CURL_GLOBAL_ALL); - for(o = curl_easy_option_next(NULL); - o; - o = curl_easy_option_next(o)) { + for(o = curl_easy_option_next(NULL); o; o = curl_easy_option_next(o)) { const struct curl_easyoption *ename = curl_easy_option_by_name(o->name); const struct curl_easyoption *eid = diff --git a/tests/libtest/lib1938.c b/tests/libtest/lib1938.c index b585c53c0114..b93f993a4541 100644 --- a/tests/libtest/lib1938.c +++ b/tests/libtest/lib1938.c @@ -29,7 +29,7 @@ static CURLcode test_lib1938(const char *URL) CURLcode res = TEST_ERR_MAJOR_BAD; struct curl_slist *connect_to = NULL; struct curl_slist *list = NULL; - unsigned char data[] = {0x70, 0x6f, 0x73, 0x74, 0, 0x44, 0x61, 0x74, 0x61}; + unsigned char data[] = { 0x70, 0x6f, 0x73, 0x74, 0, 0x44, 0x61, 0x74, 0x61 }; if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { curl_mfprintf(stderr, "curl_global_init() failed\n"); diff --git a/tests/libtest/lib2032.c b/tests/libtest/lib2032.c index a9cb29857130..7dc549f84e60 100644 --- a/tests/libtest/lib2032.c +++ b/tests/libtest/lib2032.c @@ -75,7 +75,7 @@ static size_t callback(char *ptr, size_t size, size_t nmemb, void *data) return size * nmemb; } -static CURLcode test_lib2032(const char *URL) /* libntlmconnect */ +static CURLcode test_lib2032(const char *URL) /* libntlmconnect */ { enum HandleState { ReadyForNewHandle, @@ -175,10 +175,9 @@ static CURLcode test_lib2032(const char *URL) /* libntlmconnect */ "handle (trying again)\n"); continue; } - state = num_handles < MAX_EASY_HANDLES ? ReadyForNewHandle - : NoMoreHandles; - curl_mfprintf(stderr, "%s:%d new state %d\n", - __FILE__, __LINE__, state); + state = + num_handles < MAX_EASY_HANDLES ? ReadyForNewHandle : NoMoreHandles; + curl_mfprintf(stderr, "%s:%d new state %d\n", __FILE__, __LINE__, state); } multi_timeout(multi, &timeout); diff --git a/tests/libtest/lib2301.c b/tests/libtest/lib2301.c index 6fb9e48618cb..70c40fa4c75f 100644 --- a/tests/libtest/lib2301.c +++ b/tests/libtest/lib2301.c @@ -46,9 +46,7 @@ static size_t t2301_write_cb(char *b, size_t size, size_t nitems, void *p) unsigned char *buffer = (unsigned char *)b; size_t i; size_t sent; - unsigned char pong[] = { - 0x8a, 0x0 - }; + unsigned char pong[] = { 0x8a, 0x0 }; size_t incoming = nitems; curl_mfprintf(stderr, "Called CURLOPT_WRITEFUNCTION with %zu bytes: ", nitems); diff --git a/tests/libtest/lib2402.c b/tests/libtest/lib2402.c index 49d87d1cd4f1..5f727f98e624 100644 --- a/tests/libtest/lib2402.c +++ b/tests/libtest/lib2402.c @@ -26,7 +26,7 @@ static CURLcode test_lib2402(const char *URL) { CURLcode res = CURLE_OK; - CURL *curl[NUM_HANDLES] = {0}; + CURL *curl[NUM_HANDLES] = { 0 }; int running; CURLM *multi = NULL; size_t i; diff --git a/tests/libtest/lib2404.c b/tests/libtest/lib2404.c index c20259744771..ef83a2509ed7 100644 --- a/tests/libtest/lib2404.c +++ b/tests/libtest/lib2404.c @@ -26,7 +26,7 @@ static CURLcode test_lib2404(const char *URL) { CURLcode res = CURLE_OK; - CURL *curl[NUM_HANDLES] = {0}; + CURL *curl[NUM_HANDLES] = { 0 }; int running; CURLM *multi = NULL; size_t i; diff --git a/tests/libtest/lib2405.c b/tests/libtest/lib2405.c index 89ab659bdd4e..7979d122e4e9 100644 --- a/tests/libtest/lib2405.c +++ b/tests/libtest/lib2405.c @@ -41,22 +41,23 @@ /* ---------------------------------------------------------------- */ -#define test_check(expected_fds) \ - if(res != CURLE_OK) { \ - curl_mfprintf(stderr, "test failed with code: %d\n", res); \ - goto test_cleanup; \ - } \ - else if(fd_count != expected_fds) { \ +#define test_check(expected_fds) \ + if(res != CURLE_OK) { \ + curl_mfprintf(stderr, "test failed with code: %d\n", res); \ + goto test_cleanup; \ + } \ + else if(fd_count != expected_fds) { \ curl_mfprintf(stderr, "Max number of waitfds: %u not as expected: %u\n", \ - fd_count, expected_fds); \ - res = TEST_ERR_FAILURE; \ - goto test_cleanup; \ + fd_count, expected_fds); \ + res = TEST_ERR_FAILURE; \ + goto test_cleanup; \ } -#define test_run_check(option, expected_fds) do { \ - res = test_run(URL, option, &fd_count); \ - test_check(expected_fds); \ -} while(0) +#define test_run_check(option, expected_fds) \ + do { \ + res = test_run(URL, option, &fd_count); \ + test_check(expected_fds); \ + } while(0) /* ---------------------------------------------------------------- */ diff --git a/tests/libtest/lib2502.c b/tests/libtest/lib2502.c index 48a8a93f0f8e..d7ab413f25a8 100644 --- a/tests/libtest/lib2502.c +++ b/tests/libtest/lib2502.c @@ -28,7 +28,7 @@ static CURLcode test_lib2502(const char *URL) { CURLcode res = CURLE_OK; - CURL *curl[NUM_HANDLES] = {0}; + CURL *curl[NUM_HANDLES] = { 0 }; int running; CURLM *multi = NULL; size_t i; diff --git a/tests/libtest/lib3207.c b/tests/libtest/lib3207.c index 8b20b311ebbf..76dcf4bac9a8 100644 --- a/tests/libtest/lib3207.c +++ b/tests/libtest/lib3207.c @@ -29,7 +29,7 @@ #include "curl_threads.h" -#define THREAD_SIZE 16 +#define THREAD_SIZE 16 #define PER_THREAD_SIZE 8 struct Ctx { diff --git a/tests/libtest/lib509.c b/tests/libtest/lib509.c index c065eb87c891..4f074da8ab32 100644 --- a/tests/libtest/lib509.c +++ b/tests/libtest/lib509.c @@ -76,8 +76,10 @@ static void custom_free(void *ptr) static CURLcode test_lib509(const char *URL) { - static const unsigned char a[] = {0x2f, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x91, 0xa2, 0xb3, 0xc4, 0xd5, 0xe6, 0xf7}; + static const unsigned char a[] = { + 0x2f, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, + 0x91, 0xa2, 0xb3, 0xc4, 0xd5, 0xe6, 0xf7 + }; CURLcode res; CURL *curl; int asize; diff --git a/tests/libtest/lib517.c b/tests/libtest/lib517.c index 843c5c03f0ef..379e2e70d0ba 100644 --- a/tests/libtest/lib517.c +++ b/tests/libtest/lib517.c @@ -31,130 +31,130 @@ static CURLcode test_lib517(const char *URL) }; static const struct dcheck dates[] = { - {"Sun, 06 Nov 1994 08:49:37 GMT", 784111777 }, - {"Sunday, 06-Nov-94 08:49:37 GMT", 784111777 }, - {"Sun Nov 6 08:49:37 1994", 784111777 }, - {"Sun Nov 6 8:49:37 1994", 784111777 }, - {"Sun Nov 6 8:9:37 1994", 784109377 }, - {"Sun Nov 6 008:09:37 1994", -1 }, - {"Nov Sun 6 8:9:7 1994", 784109347 }, - {"06 Nov 1994 08:49:37 GMT", 784111777 }, - {"06-Nov-94 08:49:37 GMT", 784111777 }, - {"Nov 6 08:49:37 1994", 784111777 }, - {"06 Nov 1994 08:49:37", 784111777 }, - {"06-Nov-94 08:49:37", 784111777 }, - {"1994 Nov 6 08:49:37", 784111777 }, - {"GMT 08:49:37 06-Nov-94 Sunday", 784111777 }, - {"94 6 Nov 08:49:37", 784111777 }, - {"1994 Nov 6", 784080000 }, - {"06-Nov-94", 784080000 }, - {"Sun Nov 6 94", 784080000 }, - {"1994.Nov.6", 784080000 }, - {"Sun/Nov/6/94/GMT", 784080000 }, - {"Sun, 06 Nov 1994 08:49:37 CET", 784108177 }, - {"06 Nov 1994 08:49:37 EST", 784129777 }, - {"Sun, 06 Nov 1994 08:49:37 UT", 784111777 }, - {"Sun, 12 Sep 2004 15:05:58 -0700", 1095026758 }, - {"Sat, 11 Sep 2004 21:32:11 +0200", 1094931131 }, - {"20040912 15:05:58 -0700", 1095026758 }, - {"20040911 +0200", 1094853600 }, - {"Thu, 01-Jan-1970 00:59:59 GMT", 3599 }, - {"Thu, 01-Jan-1970 01:00:00 GMT", 3600 }, - {"Sat, 15-Apr-17 21:01:22 GMT", 1492290082 }, - {"Thu, 19-Apr-2007 16:00:00 GMT", 1176998400 }, - {"Wed, 25 Apr 2007 21:02:13 GMT", 1177534933 }, - {"Thu, 19/Apr\\2007 16:00:00 GMT", 1176998400 }, - {"Fri, 1 Jan 2010 01:01:50 GMT", 1262307710 }, - {"Wednesday, 1-Jan-2003 00:00:00 GMT", 1041379200 }, - {", 1-Jan-2003 00:00:00 GMT", 1041379200 }, - {"1-Jan-2003 00:00:00 GMT", 1041379200 }, - {"1-Jan-2003 00:00:00 GMT", 1041379200 }, - {"Wed,18-Apr-07 22:50:12 GMT", 1176936612 }, - {"WillyWonka , 18-Apr-07 22:50:12 GMT", -1 }, - {"WillyWonka , 18-Apr-07 22:50:12", -1 }, - {"WillyWonka , 18-apr-07 22:50:12", -1 }, - {"Mon, 18-Apr-1977 22:50:13 GMT", 230251813 }, - {"Mon, 18-Apr-77 22:50:13 GMT", 230251813 }, - {"Sat, 15-Apr-17\"21:01:22\"GMT", 1492290082 }, - {"Partyday, 18- April-07 22:50:12", -1 }, - {"Partyday, 18 - Apri-07 22:50:12", -1 }, - {"Wednes, 1-Januar-2003 00:00:00 GMT", -1 },/* spellchecker:disable-line */ - {"Sat, 15-Apr-17 21:01:22", 1492290082 }, - {"Sat, 15-Apr-17 21:01:22 GMT-2", 1492290082 }, - {"Sat, 15-Apr-17 21:01:22 GMT BLAH", 1492290082 }, - {"Sat, 15-Apr-17 21:01:22 GMT-0400", 1492290082 }, - {"Sat, 15-Apr-17 21:01:22 GMT-0400 (EDT)", 1492290082 }, - {"Sat, 15-Apr-17 21:01:22 DST", -1 }, - {"Sat, 15-Apr-17 21:01:22 -0400", 1492304482 }, - {"Sat, 15-Apr-17 21:01:22 (hello there)", -1 }, - {"Sat, 15-Apr-17 21:01:22 11:22:33", -1 }, - {"Sat, 15-Apr-17 ::00 21:01:22", -1 }, - {"Sat, 15-Apr-17 boink:z 21:01:22", -1 }, - {"Sat, 15-Apr-17 91:22:33 21:01:22", -1 }, - {"Thu Apr 18 22:50:12 2007 GMT", 1176936612 }, - {"22:50:12 Thu Apr 18 2007 GMT", 1176936612 }, - {"Thu 22:50:12 Apr 18 2007 GMT", 1176936612 }, - {"Thu Apr 22:50:12 18 2007 GMT", 1176936612 }, - {"Thu Apr 18 22:50:12 2007 GMT", 1176936612 }, - {"Thu Apr 18 2007 22:50:12 GMT", 1176936612 }, - {"Thu Apr 18 2007 GMT 22:50:12", 1176936612 }, + { "Sun, 06 Nov 1994 08:49:37 GMT", 784111777 }, + { "Sunday, 06-Nov-94 08:49:37 GMT", 784111777 }, + { "Sun Nov 6 08:49:37 1994", 784111777 }, + { "Sun Nov 6 8:49:37 1994", 784111777 }, + { "Sun Nov 6 8:9:37 1994", 784109377 }, + { "Sun Nov 6 008:09:37 1994", -1 }, + { "Nov Sun 6 8:9:7 1994", 784109347 }, + { "06 Nov 1994 08:49:37 GMT", 784111777 }, + { "06-Nov-94 08:49:37 GMT", 784111777 }, + { "Nov 6 08:49:37 1994", 784111777 }, + { "06 Nov 1994 08:49:37", 784111777 }, + { "06-Nov-94 08:49:37", 784111777 }, + { "1994 Nov 6 08:49:37", 784111777 }, + { "GMT 08:49:37 06-Nov-94 Sunday", 784111777 }, + { "94 6 Nov 08:49:37", 784111777 }, + { "1994 Nov 6", 784080000 }, + { "06-Nov-94", 784080000 }, + { "Sun Nov 6 94", 784080000 }, + { "1994.Nov.6", 784080000 }, + { "Sun/Nov/6/94/GMT", 784080000 }, + { "Sun, 06 Nov 1994 08:49:37 CET", 784108177 }, + { "06 Nov 1994 08:49:37 EST", 784129777 }, + { "Sun, 06 Nov 1994 08:49:37 UT", 784111777 }, + { "Sun, 12 Sep 2004 15:05:58 -0700", 1095026758 }, + { "Sat, 11 Sep 2004 21:32:11 +0200", 1094931131 }, + { "20040912 15:05:58 -0700", 1095026758 }, + { "20040911 +0200", 1094853600 }, + { "Thu, 01-Jan-1970 00:59:59 GMT", 3599 }, + { "Thu, 01-Jan-1970 01:00:00 GMT", 3600 }, + { "Sat, 15-Apr-17 21:01:22 GMT", 1492290082 }, + { "Thu, 19-Apr-2007 16:00:00 GMT", 1176998400 }, + { "Wed, 25 Apr 2007 21:02:13 GMT", 1177534933 }, + { "Thu, 19/Apr\\2007 16:00:00 GMT", 1176998400 }, + { "Fri, 1 Jan 2010 01:01:50 GMT", 1262307710 }, + { "Wednesday, 1-Jan-2003 00:00:00 GMT", 1041379200 }, + { ", 1-Jan-2003 00:00:00 GMT", 1041379200 }, + { "1-Jan-2003 00:00:00 GMT", 1041379200 }, + { "1-Jan-2003 00:00:00 GMT", 1041379200 }, + { "Wed,18-Apr-07 22:50:12 GMT", 1176936612 }, + { "WillyWonka , 18-Apr-07 22:50:12 GMT", -1 }, + { "WillyWonka , 18-Apr-07 22:50:12", -1 }, + { "WillyWonka , 18-apr-07 22:50:12", -1 }, + { "Mon, 18-Apr-1977 22:50:13 GMT", 230251813 }, + { "Mon, 18-Apr-77 22:50:13 GMT", 230251813 }, + { "Sat, 15-Apr-17\"21:01:22\"GMT", 1492290082 }, + { "Partyday, 18- April-07 22:50:12", -1 }, + { "Partyday, 18 - Apri-07 22:50:12", -1 }, + { "Wednes, 1-Januar-2003 00:00:00 GMT", -1 }, + { "Sat, 15-Apr-17 21:01:22", 1492290082 }, + { "Sat, 15-Apr-17 21:01:22 GMT-2", 1492290082 }, + { "Sat, 15-Apr-17 21:01:22 GMT BLAH", 1492290082 }, + { "Sat, 15-Apr-17 21:01:22 GMT-0400", 1492290082 }, + { "Sat, 15-Apr-17 21:01:22 GMT-0400 (EDT)", 1492290082 }, + { "Sat, 15-Apr-17 21:01:22 DST", -1 }, + { "Sat, 15-Apr-17 21:01:22 -0400", 1492304482 }, + { "Sat, 15-Apr-17 21:01:22 (hello there)", -1 }, + { "Sat, 15-Apr-17 21:01:22 11:22:33", -1 }, + { "Sat, 15-Apr-17 ::00 21:01:22", -1 }, + { "Sat, 15-Apr-17 boink:z 21:01:22", -1 }, + { "Sat, 15-Apr-17 91:22:33 21:01:22", -1 }, + { "Thu Apr 18 22:50:12 2007 GMT", 1176936612 }, + { "22:50:12 Thu Apr 18 2007 GMT", 1176936612 }, + { "Thu 22:50:12 Apr 18 2007 GMT", 1176936612 }, + { "Thu Apr 22:50:12 18 2007 GMT", 1176936612 }, + { "Thu Apr 18 22:50:12 2007 GMT", 1176936612 }, + { "Thu Apr 18 2007 22:50:12 GMT", 1176936612 }, + { "Thu Apr 18 2007 GMT 22:50:12", 1176936612 }, - {"\"Thu Apr 18 22:50:12 2007 GMT\"", 1176936612 }, - {"-\"22:50:12 Thu Apr 18 2007 GMT\"", 1176936612 }, - {"*\"Thu 22:50:12 Apr 18 2007 GMT\"", 1176936612 }, - {";\"Thu Apr 22:50:12 18 2007 GMT\"", 1176936612 }, - {".\"Thu Apr 18 22:50:12 2007 GMT\"", 1176936612 }, - {"\"Thu Apr 18 2007 22:50:12 GMT\"", 1176936612 }, - {"\"Thu Apr 18 2007 GMT 22:50:12\"", 1176936612 }, + { "\"Thu Apr 18 22:50:12 2007 GMT\"", 1176936612 }, + { "-\"22:50:12 Thu Apr 18 2007 GMT\"", 1176936612 }, + { "*\"Thu 22:50:12 Apr 18 2007 GMT\"", 1176936612 }, + { ";\"Thu Apr 22:50:12 18 2007 GMT\"", 1176936612 }, + { ".\"Thu Apr 18 22:50:12 2007 GMT\"", 1176936612 }, + { "\"Thu Apr 18 2007 22:50:12 GMT\"", 1176936612 }, + { "\"Thu Apr 18 2007 GMT 22:50:12\"", 1176936612 }, - {"Sat, 15-Apr-17 21:01:22 GMT", 1492290082 }, - {"15-Sat, Apr-17 21:01:22 GMT", 1492290082 }, - {"15-Sat, Apr 21:01:22 GMT 17", 1492290082 }, - {"15-Sat, Apr 21:01:22 GMT 2017", 1492290082 }, - {"15 Apr 21:01:22 2017", 1492290082 }, - {"15 17 Apr 21:01:22", 1492290082 }, - {"Apr 15 17 21:01:22", 1492290082 }, - {"Apr 15 21:01:22 17", 1492290082 }, - {"2017 April 15 21:01:22", -1 }, - {"15 April 2017 21:01:22", -1 }, - {"98 April 17 21:01:22", -1 }, - {"Thu, 012-Aug-2008 20:49:07 GMT", 1218574147 }, - {"Thu, 999999999999-Aug-2007 20:49:07 GMT", -1 }, - {"Thu, 12-Aug-2007 20:61:99999999999 GMT", -1 }, - {"IAintNoDateFool", -1 }, - {"Thu Apr 18 22:50 2007 GMT", 1176936600 }, - {"20110623 12:34:56", 1308832496 }, - {"20110632 12:34:56", -1 }, - {"20110623 56:34:56", -1 }, - {"20111323 12:34:56", -1 }, - {"20110623 12:34:79", -1 }, - {"Wed, 31 Dec 2008 23:59:60 GMT", 1230768000 }, - {"Wed, 31 Dec 2008 23:59:61 GMT", -1 }, - {"Wed, 31 Dec 2008 24:00:00 GMT", -1 }, - {"Wed, 31 Dec 2008 23:60:59 GMT", -1 }, - {"20110623 12:3", 1308830580 }, - {"20110623 1:3", 1308790980 }, - {"20110623 1:30", 1308792600 }, - {"20110623 12:12:3", 1308831123 }, - {"20110623 01:12:3", 1308791523 }, - {"20110623 01:99:30", -1 }, - {"Thu, 01-Jan-1970 00:00:00 GMT", 0 }, - {"Thu, 31-Dec-1969 23:59:58 GMT", -2 }, - {"Thu, 31-Dec-1969 23:59:59 GMT", 0 }, /* avoids -1 ! */ + { "Sat, 15-Apr-17 21:01:22 GMT", 1492290082 }, + { "15-Sat, Apr-17 21:01:22 GMT", 1492290082 }, + { "15-Sat, Apr 21:01:22 GMT 17", 1492290082 }, + { "15-Sat, Apr 21:01:22 GMT 2017", 1492290082 }, + { "15 Apr 21:01:22 2017", 1492290082 }, + { "15 17 Apr 21:01:22", 1492290082 }, + { "Apr 15 17 21:01:22", 1492290082 }, + { "Apr 15 21:01:22 17", 1492290082 }, + { "2017 April 15 21:01:22", -1 }, + { "15 April 2017 21:01:22", -1 }, + { "98 April 17 21:01:22", -1 }, + { "Thu, 012-Aug-2008 20:49:07 GMT", 1218574147 }, + { "Thu, 999999999999-Aug-2007 20:49:07 GMT", -1 }, + { "Thu, 12-Aug-2007 20:61:99999999999 GMT", -1 }, + { "IAintNoDateFool", -1 }, + { "Thu Apr 18 22:50 2007 GMT", 1176936600 }, + { "20110623 12:34:56", 1308832496 }, + { "20110632 12:34:56", -1 }, + { "20110623 56:34:56", -1 }, + { "20111323 12:34:56", -1 }, + { "20110623 12:34:79", -1 }, + { "Wed, 31 Dec 2008 23:59:60 GMT", 1230768000 }, + { "Wed, 31 Dec 2008 23:59:61 GMT", -1 }, + { "Wed, 31 Dec 2008 24:00:00 GMT", -1 }, + { "Wed, 31 Dec 2008 23:60:59 GMT", -1 }, + { "20110623 12:3", 1308830580 }, + { "20110623 1:3", 1308790980 }, + { "20110623 1:30", 1308792600 }, + { "20110623 12:12:3", 1308831123 }, + { "20110623 01:12:3", 1308791523 }, + { "20110623 01:99:30", -1 }, + { "Thu, 01-Jan-1970 00:00:00 GMT", 0 }, + { "Thu, 31-Dec-1969 23:59:58 GMT", -2 }, + { "Thu, 31-Dec-1969 23:59:59 GMT", 0 }, /* avoids -1 ! */ #if SIZEOF_TIME_T > 4 - {"Sun, 06 Nov 2044 08:49:37 GMT", (time_t)2362034977LL }, - {"Sun, 06 Nov 3144 08:49:37 GMT", 37074617377 }, + { "Sun, 06 Nov 2044 08:49:37 GMT", (time_t)2362034977LL }, + { "Sun, 06 Nov 3144 08:49:37 GMT", 37074617377 }, #ifndef HAVE_TIME_T_UNSIGNED - {"Sun, 06 Nov 1900 08:49:37 GMT", (time_t)-2182259423LL }, - {"Sun, 06 Nov 1800 08:49:37 GMT", -5337933023 }, - {"Thu, 01-Jan-1583 00:00:00 GMT", -12212553600 }, + { "Sun, 06 Nov 1900 08:49:37 GMT", (time_t)-2182259423LL }, + { "Sun, 06 Nov 1800 08:49:37 GMT", -5337933023 }, + { "Thu, 01-Jan-1583 00:00:00 GMT", -12212553600 }, #endif /* HAVE_TIME_T_UNSIGNED */ - {"Thu, 01-Jan-1499 00:00:00 GMT", -1 }, + { "Thu, 01-Jan-1499 00:00:00 GMT", -1 }, #else - {"Sun, 06 Nov 2044 08:49:37 GMT", -1 }, + { "Sun, 06 Nov 2044 08:49:37 GMT", -1 }, #endif /* SIZEOF_TIME_T > 4 */ #ifndef HAVE_TIME_T_UNSIGNED - {"Sun, 06 Nov 1968 08:49:37 GMT", -36342623 }, + { "Sun, 06 Nov 1968 08:49:37 GMT", -36342623 }, #endif /* !HAVE_TIME_T_UNSIGNED */ { NULL, 0 } }; diff --git a/tests/libtest/lib518.c b/tests/libtest/lib518.c index d785857bb1c0..5488d4db0444 100644 --- a/tests/libtest/lib518.c +++ b/tests/libtest/lib518.c @@ -31,8 +31,8 @@ #define T518_SAFETY_MARGIN (16) -#define NUM_OPEN (FD_SETSIZE + 10) -#define NUM_NEEDED (NUM_OPEN + T518_SAFETY_MARGIN) +#define NUM_OPEN (FD_SETSIZE + 10) +#define NUM_NEEDED (NUM_OPEN + T518_SAFETY_MARGIN) #if defined(_WIN32) || defined(MSDOS) #define DEV_NULL "NUL" diff --git a/tests/libtest/lib530.c b/tests/libtest/lib530.c index f32d64b3033f..4e184361362c 100644 --- a/tests/libtest/lib530.c +++ b/tests/libtest/lib530.c @@ -52,7 +52,6 @@ static void t530_msg(const char *msg) curl_mfprintf(stderr, "%s %s\n", t530_tag(), msg); } - struct t530_Sockets { curl_socket_t *sockets; int count; /* number of sockets actually stored in array */ @@ -285,9 +284,9 @@ static CURLcode testone(const char *URL, int timer_fail_at, int socket_fail_at) CURLcode res = CURLE_OK; CURL *curl = NULL; CURLM *multi = NULL; - struct t530_ReadWriteSockets sockets = {{NULL, 0, 0}, {NULL, 0, 0}}; + struct t530_ReadWriteSockets sockets = { { NULL, 0, 0 }, { NULL, 0, 0 } }; int success = 0; - struct curltime timeout = {0}; + struct curltime timeout = { 0 }; timeout.tv_sec = (time_t)-1; /* set the limits */ @@ -328,7 +327,7 @@ static CURLcode testone(const char *URL, int timer_fail_at, int socket_fail_at) while(!t530_checkForCompletion(multi, &success)) { fd_set readSet, writeSet; curl_socket_t maxFd = 0; - struct timeval tv = {0}; + struct timeval tv = { 0 }; tv.tv_sec = 10; FD_ZERO(&readSet); diff --git a/tests/libtest/lib537.c b/tests/libtest/lib537.c index 31c5e306125a..24d166b5cc10 100644 --- a/tests/libtest/lib537.c +++ b/tests/libtest/lib537.c @@ -118,7 +118,7 @@ static int t537_test_rlimit(int keep_open) /* If the OS allows a HUGE number of open files, we do not run. * Modern debian sid reports a limit of 134217724 and this tests * takes minutes. */ -#define LIMIT_CAP (256 * 1024) +#define LIMIT_CAP (256 * 1024) if(rl.rlim_cur > LIMIT_CAP) { curl_mfprintf(stderr, "soft limit above %ld, not running\n", (long)LIMIT_CAP); diff --git a/tests/libtest/lib543.c b/tests/libtest/lib543.c index 9938d269addc..670f45e54024 100644 --- a/tests/libtest/lib543.c +++ b/tests/libtest/lib543.c @@ -28,9 +28,10 @@ static CURLcode test_lib543(const char *URL) { static const unsigned char a[] = { - 0x9c, 0x26, 0x4b, 0x3d, 0x49, 0x4, 0xa1, 0x1, - 0xe0, 0xd8, 0x7c, 0x20, 0xb7, 0xef, 0x53, 0x29, 0xfa, - 0x1d, 0x57, 0xe1}; + 0x9c, 0x26, 0x4b, 0x3d, 0x49, 0x4, 0xa1, 0x1, + 0xe0, 0xd8, 0x7c, 0x20, 0xb7, 0xef, 0x53, 0x29, 0xfa, + 0x1d, 0x57, 0xe1 + }; CURL *curl; CURLcode res = CURLE_OK; diff --git a/tests/libtest/lib544.c b/tests/libtest/lib544.c index 0d72af3042d5..77daeb5da8ea 100644 --- a/tests/libtest/lib544.c +++ b/tests/libtest/lib544.c @@ -32,7 +32,8 @@ static CURLcode test_lib544(const char *URL) 'T', 'h', 'i', 's', '\0', ' ', 'i', 's', ' ', 't', 'e', 's', 't', ' ', 'b', 'i', 'n', 'a', 'r', 'y', ' ', 'd', 'a', 't', 'a', ' ', 'w', 'i', 't', 'h', ' ', 'a', 'n', ' ', - 'e', 'm', 'b', 'e', 'd', 'd', 'e', 'd', ' ', 'N', 'U', 'L'}; + 'e', 'm', 'b', 'e', 'd', 'd', 'e', 'd', ' ', 'N', 'U', 'L' + }; char teststring[sizeof(teststring_init)]; diff --git a/tests/libtest/lib553.c b/tests/libtest/lib553.c index 4bc2568a46fd..cbf4b3013ce4 100644 --- a/tests/libtest/lib553.c +++ b/tests/libtest/lib553.c @@ -50,7 +50,7 @@ static size_t myreadfunc(char *ptr, size_t size, size_t nmemb, void *stream) return size; } -#define NUM_HEADERS 8 +#define NUM_HEADERS 8 #define SIZE_HEADERS 5000 static CURLcode test_lib553(const char *URL) diff --git a/tests/libtest/lib557.c b/tests/libtest/lib557.c index 9c4f7f9b9f3b..edf75907322c 100644 --- a/tests/libtest/lib557.c +++ b/tests/libtest/lib557.c @@ -46,7 +46,7 @@ #endif #endif -#define BUFSZ 256 +#define BUFSZ 256 struct unsshort_st { unsigned short num; /* unsigned short */ @@ -1166,9 +1166,9 @@ static int test_width_precision(void) { /* 325 is max precision (and width) for a double */ char larger[1024]; -#define SPACE60 " " +#define SPACE60 " " #define SPACE300 SPACE60 SPACE60 SPACE60 SPACE60 SPACE60 -#define OK325 SPACE300 " 0" +#define OK325 SPACE300 " 0" int rc; int errors = 0; diff --git a/tests/libtest/lib558.c b/tests/libtest/lib558.c index 94dd7f57b80f..27afa3c9d30a 100644 --- a/tests/libtest/lib558.c +++ b/tests/libtest/lib558.c @@ -25,8 +25,8 @@ static CURLcode test_lib558(const char *URL) { - unsigned char a[] = {0x2f, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x91, 0xa2, 0xb3, 0xc4, 0xd5, 0xe6, 0xf7}; + unsigned char a[] = { 0x2f, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, + 0x91, 0xa2, 0xb3, 0xc4, 0xd5, 0xe6, 0xf7 }; CURLcode res = CURLE_OK; char *ptr = NULL; int asize; diff --git a/tests/libtest/lib576.c b/tests/libtest/lib576.c index 7ee7bc9525d4..ae5f5d40b359 100644 --- a/tests/libtest/lib576.c +++ b/tests/libtest/lib576.c @@ -98,7 +98,7 @@ static CURLcode test_lib576(const char *URL) { CURL *curl = NULL; CURLcode res = CURLE_OK; - struct chunk_data chunk_data = {0, 0}; + struct chunk_data chunk_data = { 0, 0 }; curl_global_init(CURL_GLOBAL_ALL); curl = curl_easy_init(); if(!curl) { diff --git a/tests/libtest/lib582.c b/tests/libtest/lib582.c index dabebed6ce8f..3940d9c4702c 100644 --- a/tests/libtest/lib582.c +++ b/tests/libtest/lib582.c @@ -229,9 +229,9 @@ static CURLcode test_lib582(const char *URL) int hd; struct_stat file_info; CURLM *multi = NULL; - struct t582_ReadWriteSockets sockets = {{NULL, 0, 0}, {NULL, 0, 0}}; + struct t582_ReadWriteSockets sockets = { { NULL, 0, 0 }, { NULL, 0, 0 } }; int success = 0; - struct curltime timeout = {0}; + struct curltime timeout = { 0 }; timeout.tv_sec = (time_t)-1; assert(test_argc >= 5); @@ -304,7 +304,7 @@ static CURLcode test_lib582(const char *URL) while(!t582_checkForCompletion(multi, &success)) { fd_set readSet, writeSet; curl_socket_t maxFd = 0; - struct timeval tv = {0}; + struct timeval tv = { 0 }; tv.tv_sec = 10; FD_ZERO(&readSet); diff --git a/tests/libtest/lib654.c b/tests/libtest/lib654.c index 7d519d645331..37afec4f5a45 100644 --- a/tests/libtest/lib654.c +++ b/tests/libtest/lib654.c @@ -107,7 +107,7 @@ static CURLcode test_lib654(const char *URL) part = curl_mime_addpart(mime); curl_mime_filedata(part, libtest_arg2); part = curl_mime_addpart(mime); - curl_mime_data_cb(part, (curl_off_t) -1, t654_read_cb, NULL, + curl_mime_data_cb(part, (curl_off_t)-1, t654_read_cb, NULL, free_callback, &pooh); /* Bind mime data to its easy handle. */ diff --git a/tests/libtest/lib670.c b/tests/libtest/lib670.c index 886bf39a72bc..08dd7cfa08f9 100644 --- a/tests/libtest/lib670.c +++ b/tests/libtest/lib670.c @@ -23,7 +23,7 @@ ***************************************************************************/ #include "first.h" -#define PAUSE_TIME 5 +#define PAUSE_TIME 5 struct t670_ReadThis { CURL *curl; diff --git a/tests/libtest/lib678.c b/tests/libtest/lib678.c index 525407fddc37..3214694c7ddf 100644 --- a/tests/libtest/lib678.c +++ b/tests/libtest/lib678.c @@ -97,7 +97,7 @@ static CURLcode test_lib678(const char *URL) curl_global_init(CURL_GLOBAL_DEFAULT); if(!strcmp("check", URL)) { CURLcode w = CURLE_OK; - struct curl_blob blob = {0}; + struct curl_blob blob = { 0 }; CURL *curl = curl_easy_init(); if(curl) { w = curl_easy_setopt(curl, CURLOPT_CAINFO_BLOB, &blob); diff --git a/tests/libtest/lib758.c b/tests/libtest/lib758.c index fadb1db6fdd7..37bc3b0e62ec 100644 --- a/tests/libtest/lib758.c +++ b/tests/libtest/lib758.c @@ -57,8 +57,7 @@ static struct t758_ctx { static const char *t758_tag(void) { - curl_msnprintf(t758_ctx.buf, sizeof(t758_ctx.buf), - "[T758-%d-%d] [%d/%d]", + curl_msnprintf(t758_ctx.buf, sizeof(t758_ctx.buf), "[T758-%d-%d] [%d/%d]", t758_ctx.max_socket_calls, t758_ctx.max_timer_calls, t758_ctx.socket_calls, t758_ctx.timer_calls); return t758_ctx.buf; @@ -204,8 +203,8 @@ static int t758_cert_verify_callback(X509_STORE_CTX *ctx, void *arg) { SSL *ssl; (void)arg; - ssl = (SSL *)X509_STORE_CTX_get_ex_data(ctx, - SSL_get_ex_data_X509_STORE_CTX_idx()); + ssl = (SSL *)X509_STORE_CTX_get_ex_data( + ctx, SSL_get_ex_data_X509_STORE_CTX_idx()); t758_ctx.number_of_cert_verify_callbacks++; if(!t758_ctx.fake_async_cert_verification_pending) { t758_ctx.fake_async_cert_verification_pending = 1; @@ -222,8 +221,8 @@ static int t758_cert_verify_callback(X509_STORE_CTX *ctx, void *arg) } } -static CURLcode -t758_set_ssl_ctx_callback(CURL *curl, void *ssl_ctx, void *clientp) +static CURLcode t758_set_ssl_ctx_callback(CURL *curl, void *ssl_ctx, + void *clientp) { SSL_CTX *ctx = (SSL_CTX *)ssl_ctx; (void)curl; @@ -333,9 +332,9 @@ static CURLcode t758_one(const char *URL, int timer_fail_at, CURLcode res = CURLE_OK; CURL *curl = NULL; CURLM *multi = NULL; - struct t758_ReadWriteSockets sockets = {{NULL, 0, 0}, {NULL, 0, 0}}; + struct t758_ReadWriteSockets sockets = { { NULL, 0, 0 }, { NULL, 0, 0 } }; int success = 0; - struct curltime timeout = {0}; + struct curltime timeout = { 0 }; timeout.tv_sec = (time_t)-1; /* set the limits */ @@ -390,7 +389,7 @@ static CURLcode t758_one(const char *URL, int timer_fail_at, while(!t758_checkForCompletion(multi, &success)) { fd_set readSet, writeSet; curl_socket_t maxFd = 0; - struct timeval tv = {0}; + struct timeval tv = { 0 }; tv.tv_sec = 10; if(t758_ctx.fake_async_cert_verification_pending && diff --git a/tests/libtest/memptr.c b/tests/libtest/memptr.c index fe90b01a6cb1..3c383d9003e9 100644 --- a/tests/libtest/memptr.c +++ b/tests/libtest/memptr.c @@ -26,8 +26,8 @@ #ifndef CURL_STATICLIB #if defined(_MSC_VER) && defined(_DLL) -# pragma warning(push) -# pragma warning(disable:4232) /* MSVC extension, dllimport identity */ +#pragma warning(push) +#pragma warning(disable:4232) /* MSVC extension, dllimport identity */ #endif /* when libcurl is *not* static and we build libtests, the global pointers in @@ -44,7 +44,7 @@ curl_strdup_callback Curl_cstrdup = (curl_strdup_callback)strdup; curl_calloc_callback Curl_ccalloc = (curl_calloc_callback)calloc; #if defined(_MSC_VER) && defined(_DLL) -# pragma warning(pop) +#pragma warning(pop) #endif #endif /* !CURL_STATICLIB */ diff --git a/tests/server/dnsd.c b/tests/server/dnsd.c index 58bbd2f3f88c..eaf56b03fbe6 100644 --- a/tests/server/dnsd.c +++ b/tests/server/dnsd.c @@ -59,8 +59,8 @@ static int qname(const unsigned char **pkt, size_t *size) return 0; } -#define QTYPE_A 1 -#define QTYPE_AAAA 28 +#define QTYPE_A 1 +#define QTYPE_AAAA 28 #define QTYPE_HTTPS 0x41 static const char *type2string(unsigned short qtype) @@ -497,8 +497,7 @@ static int test_dnsd(int argc, char **argv) } flag = 1; - if(setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, - (void *)&flag, sizeof(flag))) { + if(setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void *)&flag, sizeof(flag))) { error = SOCKERRNO; logmsg("setsockopt(SO_REUSEADDR) failed with error (%d) %s", error, curlx_strerror(error, errbuf, sizeof(errbuf))); diff --git a/tests/server/getpart.c b/tests/server/getpart.c index becde4a9bb06..d76368e016a4 100644 --- a/tests/server/getpart.c +++ b/tests/server/getpart.c @@ -243,7 +243,7 @@ static int decodedata(char **buf, /* dest buffer */ int getpart(char **outbuf, size_t *outlen, const char *main, const char *sub, FILE *stream) { -# define MAX_TAG_LEN 200 +#define MAX_TAG_LEN 200 char curouter[MAX_TAG_LEN + 1]; /* current outermost section */ char curmain[MAX_TAG_LEN + 1]; /* current main section */ char cursub[MAX_TAG_LEN + 1]; /* current sub section */ diff --git a/tests/server/mqttd.c b/tests/server/mqttd.c index 081b038d075b..64ba64dc69ad 100644 --- a/tests/server/mqttd.c +++ b/tests/server/mqttd.c @@ -55,7 +55,7 @@ struct mqttd_configurable { int testnum; }; -#define REQUEST_DUMP "server.input" +#define REQUEST_DUMP "server.input" #define CONFIG_VERSION 5 static struct mqttd_configurable m_config; @@ -152,7 +152,6 @@ static void logprotocol(mqttdir dir, prefix, (int)remlen, data); } - /* return 0 on success */ static int connack(FILE *dump, curl_socket_t fd) { @@ -179,7 +178,7 @@ static int connack(FILE *dump, curl_socket_t fd) /* return 0 on success */ static int suback(FILE *dump, curl_socket_t fd, unsigned short packetid) { - unsigned char packet[]={ + unsigned char packet[] = { MQTT_MSG_SUBACK, 0x03, 0, 0, /* filled in below */ 0x00 @@ -202,7 +201,7 @@ static int suback(FILE *dump, curl_socket_t fd, unsigned short packetid) /* return 0 on success */ static int puback(FILE *dump, curl_socket_t fd, unsigned short packetid) { - unsigned char packet[]={ + unsigned char packet[] = { MQTT_MSG_PUBACK, 0x00, 0, 0 /* filled in below */ }; @@ -225,7 +224,7 @@ static int puback(FILE *dump, curl_socket_t fd, unsigned short packetid) /* return 0 on success */ static int disconnect(FILE *dump, curl_socket_t fd) { - unsigned char packet[]={ + unsigned char packet[] = { MQTT_MSG_DISCONNECT, 0x00, }; ssize_t rc = swrite(fd, (char *)packet, sizeof(packet)); @@ -364,7 +363,7 @@ static int publish(FILE *dump, return 1; } -#define MAX_TOPIC_LENGTH 65535 +#define MAX_TOPIC_LENGTH 65535 #define MAX_CLIENT_ID_LENGTH 32 static char topic[MAX_TOPIC_LENGTH + 1]; diff --git a/tests/server/rtspd.c b/tests/server/rtspd.c index 842562394058..6c7aa1e9d023 100644 --- a/tests/server/rtspd.c +++ b/tests/server/rtspd.c @@ -88,10 +88,10 @@ struct rtspd_httprequest { #define RESPONSE_DUMP "server.response" /* very-big-path support */ -#define MAXDOCNAMELEN 140000 +#define MAXDOCNAMELEN 140000 #define MAXDOCNAMELEN_TXT "139999" -#define REQUEST_KEYWORD_SIZE 256 +#define REQUEST_KEYWORD_SIZE 256 #define REQUEST_KEYWORD_SIZE_TXT "255" #define CMD_AUTH_REQUIRED "auth_required" @@ -110,14 +110,15 @@ static const char *docquit_rtsp = "HTTP/1.1 200 Goodbye" END_OF_HEADERS; /* sent as reply to a CONNECT */ static const char *docconnect = -"HTTP/1.1 200 Mighty fine indeed" END_OF_HEADERS; + "HTTP/1.1 200 Mighty fine indeed" END_OF_HEADERS; /* sent as reply to a "bad" CONNECT */ static const char *docbadconnect = -"HTTP/1.1 501 Forbidden you fool" END_OF_HEADERS; + "HTTP/1.1 501 Forbidden you fool" END_OF_HEADERS; /* send back this on HTTP 404 file not found */ -static const char *doc404_HTTP = "HTTP/1.1 404 Not Found\r\n" +static const char *doc404_HTTP = + "HTTP/1.1 404 Not Found\r\n" "Server: " RTSPDVERSION "\r\n" "Connection: close\r\n" "Content-Type: text/html" @@ -128,7 +129,8 @@ static const char *doc404_HTTP = "HTTP/1.1 404 Not Found\r\n" "\n" "

Not Found

\n" "The requested URL was not found on this server.\n" - "


" RTSPDVERSION "
\n" "\n"; + "


" RTSPDVERSION "
\n" + "\n"; /* send back this on RTSP 404 file not found */ static const char *doc404_RTSP = "RTSP/1.0 404 Not Found\r\n" @@ -1021,8 +1023,7 @@ static int test_rtspd(int argc, char *argv[]) curl_off_t num; if(!strcmp("--version", argv[arg])) { printf("rtspd IPv4%s" - "\n" - , + "\n", #ifdef USE_IPV6 "/IPv6" #else diff --git a/tests/server/sockfilt.c b/tests/server/sockfilt.c index 9560a3967646..db0261bf144d 100644 --- a/tests/server/sockfilt.c +++ b/tests/server/sockfilt.c @@ -173,7 +173,7 @@ static ssize_t write_wincon(int fd, const void *buf, size_t count) /* On Windows, we sometimes get this for a broken pipe, seemingly * when the client just closed stdin? */ -#define CURL_WIN32_EPIPE 109 +#define CURL_WIN32_EPIPE 109 /* * fullread is a wrapper around the read() function. This will repeat the call @@ -888,7 +888,6 @@ static bool disc_handshake(void) logmsg("Throwing away data bytes"); if(!read_data_block(buffer, sizeof(buffer), &buffer_len)) return FALSE; - } else if(!memcmp("QUIT", buffer, 4)) { /* just die */ @@ -1339,31 +1338,31 @@ static int test_sockfilt(int argc, char *argv[]) /* Active mode, we should connect to the given port number */ mode = ACTIVE; switch(socket_domain) { - case AF_INET: - memset(&me.sa4, 0, sizeof(me.sa4)); - me.sa4.sin_family = AF_INET; - me.sa4.sin_port = htons(server_connectport); - me.sa4.sin_addr.s_addr = INADDR_ANY; - if(!addr) - addr = "127.0.0.1"; - curlx_inet_pton(AF_INET, addr, &me.sa4.sin_addr); - - rc = connect(sock, &me.sa, sizeof(me.sa4)); - break; + case AF_INET: + memset(&me.sa4, 0, sizeof(me.sa4)); + me.sa4.sin_family = AF_INET; + me.sa4.sin_port = htons(server_connectport); + me.sa4.sin_addr.s_addr = INADDR_ANY; + if(!addr) + addr = "127.0.0.1"; + curlx_inet_pton(AF_INET, addr, &me.sa4.sin_addr); + + rc = connect(sock, &me.sa, sizeof(me.sa4)); + break; #ifdef USE_IPV6 - case AF_INET6: - memset(&me.sa6, 0, sizeof(me.sa6)); - me.sa6.sin6_family = AF_INET6; - me.sa6.sin6_port = htons(server_connectport); - if(!addr) - addr = "::1"; - curlx_inet_pton(AF_INET6, addr, &me.sa6.sin6_addr); - - rc = connect(sock, &me.sa, sizeof(me.sa6)); - break; + case AF_INET6: + memset(&me.sa6, 0, sizeof(me.sa6)); + me.sa6.sin6_family = AF_INET6; + me.sa6.sin6_port = htons(server_connectport); + if(!addr) + addr = "::1"; + curlx_inet_pton(AF_INET6, addr, &me.sa6.sin6_addr); + + rc = connect(sock, &me.sa, sizeof(me.sa6)); + break; #endif /* USE_IPV6 */ - default: - rc = 1; + default: + rc = 1; } if(rc) { error = SOCKERRNO; diff --git a/tests/server/socksd.c b/tests/server/socksd.c index f9fadd211328..99adb727fb9d 100644 --- a/tests/server/socksd.c +++ b/tests/server/socksd.c @@ -76,15 +76,15 @@ struct socksd_configurable { char password[256]; }; -#define CONFIG_VERSION 5 -#define CONFIG_NMETHODS_MIN 1 /* unauth, gssapi, auth */ -#define CONFIG_NMETHODS_MAX 3 +#define CONFIG_VERSION 5 +#define CONFIG_NMETHODS_MIN 1 /* unauth, gssapi, auth */ +#define CONFIG_NMETHODS_MAX 3 #define CONFIG_RESPONSEVERSION CONFIG_VERSION -#define CONFIG_RESPONSEMETHOD 0 /* no auth */ -#define CONFIG_REQCMD 1 /* CONNECT */ -#define CONFIG_PORT backendport -#define CONFIG_ADDR backendaddr -#define CONFIG_CONNECTREP 0 +#define CONFIG_RESPONSEMETHOD 0 /* no auth */ +#define CONFIG_REQCMD 1 /* CONNECT */ +#define CONFIG_PORT backendport +#define CONFIG_ADDR backendaddr +#define CONFIG_CONNECTREP 0 static struct socksd_configurable s_config; @@ -185,24 +185,24 @@ static void socksd_getconfig(void) } /* RFC 1928, SOCKS5 byte index */ -#define SOCKS5_VERSION 0 +#define SOCKS5_VERSION 0 #define SOCKS5_NMETHODS 1 /* number of methods that is listed */ /* in the request: */ -#define SOCKS5_REQCMD 1 +#define SOCKS5_REQCMD 1 #define SOCKS5_RESERVED 2 -#define SOCKS5_ATYP 3 -#define SOCKS5_DSTADDR 4 +#define SOCKS5_ATYP 3 +#define SOCKS5_DSTADDR 4 /* connect response */ -#define SOCKS5_REP 1 +#define SOCKS5_REP 1 #define SOCKS5_BNDADDR 4 /* auth request */ -#define SOCKS5_ULEN 1 +#define SOCKS5_ULEN 1 #define SOCKS5_UNAME 2 -#define SOCKS4_CD 1 +#define SOCKS4_CD 1 #define SOCKS4_DSTPORT 2 /* connect to a given IPv4 address, not the one asked for */ diff --git a/tests/server/sws.c b/tests/server/sws.c index 13f745546983..56135a832636 100644 --- a/tests/server/sws.c +++ b/tests/server/sws.c @@ -104,10 +104,10 @@ static size_t num_sockets = 0; static const char *cmdfile = "log/server.cmd"; /* very-big-path support */ -#define MAXDOCNAMELEN 140000 +#define MAXDOCNAMELEN 140000 #define MAXDOCNAMELEN_TXT "139999" -#define REQUEST_KEYWORD_SIZE 256 +#define REQUEST_KEYWORD_SIZE 256 #define REQUEST_KEYWORD_SIZE_TXT "255" #define CMD_AUTH_REQUIRED "auth_required" @@ -141,7 +141,8 @@ static const char *end_of_headers = END_OF_HEADERS; static const char *docquit_sws = "HTTP/1.1 200 Goodbye" END_OF_HEADERS; /* send back this on 404 file not found */ -static const char *doc404 = "HTTP/1.1 404 Not Found\r\n" +static const char *doc404 = + "HTTP/1.1 404 Not Found\r\n" "Server: " SWSVERSION "\r\n" "Connection: close\r\n" "Content-Type: text/html" @@ -152,7 +153,8 @@ static const char *doc404 = "HTTP/1.1 404 Not Found\r\n" "\n" "

Not Found

\n" "The requested URL was not found on this server.\n" - "


" SWSVERSION "
\n" "\n"; + "


" SWSVERSION "
\n" + "\n"; /* work around for handling trailing headers */ static int already_recv_zeroed_chunk = FALSE; @@ -332,8 +334,7 @@ static int sws_ProcessRequest(struct sws_httprequest *req) char *httppath = NULL; size_t npath = 0; /* httppath length */ - if(sscanf(line, - "%" REQUEST_KEYWORD_SIZE_TXT "s ", request) == 1) { + if(sscanf(line, "%" REQUEST_KEYWORD_SIZE_TXT "s ", request) == 1) { http = strstr(line + strlen(request), "HTTP/"); if(http && sscanf(http, "HTTP/%d.%d", &prot_major, &prot_minor) == 2) { @@ -833,7 +834,7 @@ static int sws_get_request(curl_socket_t sock, struct sws_httprequest *req) int rc; fd_set input; fd_set output; - struct timeval timeout = {0}; + struct timeval timeout = { 0 }; timeout.tv_sec = 1; /* 1000 ms */ logmsg("Got EAGAIN from sread"); @@ -1318,7 +1319,7 @@ static curl_socket_t connect_to(const char *ipaddr, unsigned short port) error = SOCKERRNO; if((error == SOCKEINPROGRESS) || (error == SOCKEWOULDBLOCK)) { fd_set output; - struct timeval timeout = {0}; + struct timeval timeout = { 0 }; timeout.tv_sec = 1; /* 1000 ms */ FD_ZERO(&output); @@ -1386,8 +1387,8 @@ static curl_socket_t connect_to(const char *ipaddr, unsigned short port) #define data_or_ctrl(x) ((x) ? "DATA" : "CTRL") -#define SWS_CTRL 0 -#define SWS_DATA 1 +#define SWS_CTRL 0 +#define SWS_DATA 1 static void http_connect(curl_socket_t *infdp, curl_socket_t rootfd, @@ -1395,10 +1396,10 @@ static void http_connect(curl_socket_t *infdp, unsigned short ipport, int keepalive_secs) { - curl_socket_t serverfd[2] = {CURL_SOCKET_BAD, CURL_SOCKET_BAD}; - curl_socket_t clientfd[2] = {CURL_SOCKET_BAD, CURL_SOCKET_BAD}; - ssize_t toc[2] = {0, 0}; /* number of bytes to client */ - ssize_t tos[2] = {0, 0}; /* number of bytes to server */ + curl_socket_t serverfd[2] = { CURL_SOCKET_BAD, CURL_SOCKET_BAD }; + curl_socket_t clientfd[2] = { CURL_SOCKET_BAD, CURL_SOCKET_BAD }; + ssize_t toc[2] = { 0, 0 }; /* number of bytes to client */ + ssize_t tos[2] = { 0, 0 }; /* number of bytes to server */ char readclient[2][256]; char readserver[2][256]; bool poll_client_rd[2] = { TRUE, TRUE }; @@ -1441,7 +1442,7 @@ static void http_connect(curl_socket_t *infdp, fd_set output; ssize_t rc; curl_socket_t maxfd = (curl_socket_t)-1; - struct timeval timeout = {0}; + struct timeval timeout = { 0 }; timeout.tv_sec = 1; /* 1000 ms */ FD_ZERO(&input); @@ -2176,8 +2177,7 @@ static int test_sws(int argc, char *argv[]) } flag = 1; - if(setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, - (void *)&flag, sizeof(flag))) { + if(setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void *)&flag, sizeof(flag))) { error = SOCKERRNO; logmsg("setsockopt(SO_REUSEADDR) failed with error (%d) %s", error, curlx_strerror(error, errbuf, sizeof(errbuf))); @@ -2314,7 +2314,7 @@ static int test_sws(int argc, char *argv[]) fd_set output; curl_socket_t maxfd = (curl_socket_t)-1; int active; - struct timeval timeout = {0}; + struct timeval timeout = { 0 }; timeout.tv_usec = 250000L; /* 250 ms */ /* Clear out closed sockets */ @@ -2458,7 +2458,7 @@ static int test_sws(int argc, char *argv[]) for(socket_idx = 1; socket_idx < num_sockets; ++socket_idx) if((all_sockets[socket_idx] != sock) && - (all_sockets[socket_idx] != CURL_SOCKET_BAD)) + (all_sockets[socket_idx] != CURL_SOCKET_BAD)) sclose(all_sockets[socket_idx]); if(sock != CURL_SOCKET_BAD) diff --git a/tests/server/tftpd.c b/tests/server/tftpd.c index 99c008031eab..d1867e7c872b 100644 --- a/tests/server/tftpd.c +++ b/tests/server/tftpd.c @@ -70,8 +70,8 @@ #include /***************************************************************************** -* This is a rewrite/clone of the arpa/tftp.h file for systems without it. * -*****************************************************************************/ + * This is a rewrite/clone of the arpa/tftp.h file for systems without it. * + *****************************************************************************/ #define SEGSIZE 512 /* data segment size */ #if defined(__GNUC__) && ((__GNUC__ >= 3) || \ @@ -105,8 +105,8 @@ struct tftphdr { #define TFTP_ENOUSER 7 /***************************************************************************** -* STRUCT DECLARATIONS AND DEFINES * -*****************************************************************************/ + * STRUCT DECLARATIONS AND DEFINES * + *****************************************************************************/ #ifndef PKTSIZE #define PKTSIZE (SEGSIZE + 4) /* SEGSIZE defined in arpa/tftp.h */ @@ -157,13 +157,13 @@ struct bf { #define opcode_ACK 4 #define opcode_ERROR 5 -#define TIMEOUT 5 +#define TIMEOUT 5 -#define REQUEST_DUMP "server.input" +#define REQUEST_DUMP "server.input" /***************************************************************************** -* GLOBAL VARIABLES * -*****************************************************************************/ + * GLOBAL VARIABLES * + *****************************************************************************/ static struct errmsg errmsgs[] = { { TFTP_EUNDEF, "Undefined error code" }, @@ -212,8 +212,8 @@ static const unsigned int rexmtval = TIMEOUT; #endif /***************************************************************************** -* FUNCTION PROTOTYPES * -*****************************************************************************/ + * FUNCTION PROTOTYPES * + *****************************************************************************/ static struct tftphdr *rw_init(int); @@ -249,8 +249,8 @@ static void justtimeout(int signum); #endif /* HAVE_ALARM && SIGALRM */ /***************************************************************************** -* FUNCTION IMPLEMENTATIONS * -*****************************************************************************/ + * FUNCTION IMPLEMENTATIONS * + *****************************************************************************/ #if defined(HAVE_ALARM) && defined(SIGALRM) @@ -482,9 +482,8 @@ static ssize_t write_behind(struct testcase *test, int convert) if(prevchar == '\r') { /* if prev char was cr */ if(c == '\n') /* if have cr,lf then just */ lseek(test->ofile, -1, SEEK_CUR); /* smash lf on top of the cr */ - else - if(c == '\0') /* if have cr,nul then */ - goto skipit; /* just skip over the putc */ + else if(c == '\0') /* if have cr,nul then */ + goto skipit; /* just skip over the putc */ /* else just fall through and allow it */ } /* formerly @@ -1204,8 +1203,7 @@ static void sendtftp(struct testcase *test, const struct formats *pf) (void)sigsetjmp(timeoutbuf, 1); #endif if(test->writedelay) { - logmsg("Pausing %d seconds before %d bytes", test->writedelay, - size); + logmsg("Pausing %d seconds before %d bytes", test->writedelay, size); curlx_wait_ms(1000 * test->writedelay); } @@ -1299,7 +1297,7 @@ static void recvtftp(struct testcase *test, const struct formats *pf) #endif if(got_exit_signal) goto abort; - if(n < 0) { /* really? */ + if(n < 0) { /* really? */ logmsg("read: fail"); goto abort; } @@ -1313,13 +1311,13 @@ static void recvtftp(struct testcase *test, const struct formats *pf) } /* Re-synchronize with the other side */ (void)synchnet(peer); - if(rdp->th_block == (recvblock-1)) + if(rdp->th_block == (recvblock - 1)) goto send_ack; /* rexmit */ } } size = writeit(test, &rdp, (int)(n - 4), pf->f_convert); - if(size != (n-4)) { /* ahem */ + if(size != (n - 4)) { /* ahem */ if(size < 0) nak(errno + 100); else diff --git a/tests/unit/unit1300.c b/tests/unit/unit1300.c index 53da9dd4f661..5fae379dced8 100644 --- a/tests/unit/unit1300.c +++ b/tests/unit/unit1300.c @@ -108,7 +108,7 @@ static CURLcode test_unit1300(const char *arg) Curl_llist_insert_next(&llist, Curl_llist_head(&llist), &unusedData_case3, &case3_list); fail_unless(Curl_node_elem(Curl_node_next(Curl_llist_head(&llist))) == - &unusedData_case3, + &unusedData_case3, "the node next to head is not getting set correctly"); fail_unless(Curl_node_elem(Curl_llist_tail(&llist)) == &unusedData_case3, "the list tail is not getting set correctly"); @@ -125,7 +125,7 @@ static CURLcode test_unit1300(const char *arg) Curl_llist_insert_next(&llist, Curl_llist_head(&llist), &unusedData_case2, &case2_list); fail_unless(Curl_node_elem(Curl_node_next(Curl_llist_head(&llist))) == - &unusedData_case2, + &unusedData_case2, "the node next to head is not getting set correctly"); /* better safe than sorry, check that the tail is not corrupted */ fail_unless(Curl_node_elem(Curl_llist_tail(&llist)) != &unusedData_case2, @@ -149,7 +149,7 @@ static CURLcode test_unit1300(const char *arg) Curl_node_remove(Curl_llist_head(&llist)); - fail_unless(Curl_llist_count(&llist) == (llist_size-1), + fail_unless(Curl_llist_count(&llist) == (llist_size - 1), "llist size not decremented as expected"); fail_unless(Curl_llist_head(&llist) == element_next, "llist new head not modified properly"); @@ -243,7 +243,7 @@ static CURLcode test_unit1300(const char *arg) */ Curl_llist_append(&llist, &unusedData_case2, &case2_list); fail_unless(Curl_node_elem(Curl_node_next(Curl_llist_head(&llist))) == - &unusedData_case2, + &unusedData_case2, "the node next to head is not getting set correctly"); fail_unless(Curl_node_elem(Curl_llist_tail(&llist)) == &unusedData_case2, "the list tail is not getting set correctly"); @@ -258,7 +258,7 @@ static CURLcode test_unit1300(const char *arg) */ Curl_llist_append(&llist, &unusedData_case3, &case3_list); fail_unless(Curl_node_elem(Curl_node_next(Curl_llist_head(&llist))) == - &unusedData_case2, + &unusedData_case2, "the node next to head did not stay the same"); fail_unless(Curl_node_elem(Curl_llist_tail(&llist)) == &unusedData_case3, "the list tail is not getting set correctly"); diff --git a/tests/unit/unit1302.c b/tests/unit/unit1302.c index 157f1f61ed9c..5fb3d5c6367a 100644 --- a/tests/unit/unit1302.c +++ b/tests/unit/unit1302.c @@ -41,87 +41,87 @@ static CURLcode test_unit1302(const char *arg) /* common base64 encoding */ struct etest encode[] = { - {"iiiiii", 1, "aQ==", 4 }, - {"iiiiii", 2, "aWk=", 4 }, - {"iiiiii", 3, "aWlp", 4 }, - {"iiiiii", 4, "aWlpaQ==", 8 }, - {"iiiiii", 5, "aWlpaWk=", 8 }, - {"iiiiii", 6, "aWlpaWlp", 8 }, - {"iiiiiii", 7, "aWlpaWlpaQ==", 12 }, - {"iiiiiiii", 8, "aWlpaWlpaWk=", 12 }, - {"iiiiiiiii", 9, "aWlpaWlpaWlp", 12 }, - {"iiiiiiiiii", 10, "aWlpaWlpaWlpaQ==", 16 }, - {"iiiiiiiiiii", 11, "aWlpaWlpaWlpaWk=", 16 }, - {"iiiiiiiiiiii", 12, "aWlpaWlpaWlpaWlp", 16 }, - {"\xff\x01\xfe\x02", 4, "/wH+Ag==", 8 }, - {"\xff\xff\xff\xff", 4, "/////w==", 8 }, - {"\x00\x00\x00\x00", 4, "AAAAAA==", 8 }, - {"\x00\x00\x00\x00", 1, "AA==", 4 }, + { "iiiiii", 1, "aQ==", 4 }, + { "iiiiii", 2, "aWk=", 4 }, + { "iiiiii", 3, "aWlp", 4 }, + { "iiiiii", 4, "aWlpaQ==", 8 }, + { "iiiiii", 5, "aWlpaWk=", 8 }, + { "iiiiii", 6, "aWlpaWlp", 8 }, + { "iiiiiii", 7, "aWlpaWlpaQ==", 12 }, + { "iiiiiiii", 8, "aWlpaWlpaWk=", 12 }, + { "iiiiiiiii", 9, "aWlpaWlpaWlp", 12 }, + { "iiiiiiiiii", 10, "aWlpaWlpaWlpaQ==", 16 }, + { "iiiiiiiiiii", 11, "aWlpaWlpaWlpaWk=", 16 }, + { "iiiiiiiiiiii", 12, "aWlpaWlpaWlpaWlp", 16 }, + { "\xff\x01\xfe\x02", 4, "/wH+Ag==", 8 }, + { "\xff\xff\xff\xff", 4, "/////w==", 8 }, + { "\x00\x00\x00\x00", 4, "AAAAAA==", 8 }, + { "\x00\x00\x00\x00", 1, "AA==", 4 }, }; /* base64 URL encoding */ struct etest url[] = { - {"", 0, "", 0 }, - {"iiiiiiiiiii", 1, "aQ", 2 }, - {"iiiiiiiiiii", 2, "aWk", 3 }, - {"iiiiiiiiiii", 3, "aWlp", 4 }, - {"iiiiiiiiiii", 4, "aWlpaQ", 6 }, - {"iiiiiiiiiii", 5, "aWlpaWk", 7 }, - {"iiiiiiiiiii", 6, "aWlpaWlp", 8 }, - {"iiiiiiiiiii", 7, "aWlpaWlpaQ", 10 }, - {"iiiiiiiiiii", 8, "aWlpaWlpaWk", 11 }, - {"iiiiiiiiiii", 9, "aWlpaWlpaWlp", 12 }, - {"iiiiiiiiiii", 10, "aWlpaWlpaWlpaQ", 14 }, - {"iiiiiiiiiii", 11, "aWlpaWlpaWlpaWk", 15 }, - {"iiiiiiiiiiii", 12, "aWlpaWlpaWlpaWlp", 16 }, - {"\xff\x01\xfe\x02", 4, "_wH-Ag", 6 }, - {"\xff\xff\xff\xff", 4, "_____w", 6 }, - {"\xff\x00\xff\x00", 4, "_wD_AA", 6 }, - {"\x00\xff\x00\xff", 4, "AP8A_w", 6 }, - {"\x00\x00\x00\x00", 4, "AAAAAA", 6 }, - {"\x00", 1, "AA", 2 }, - {"\x01", 1, "AQ", 2 }, - {"\x02", 1, "Ag", 2 }, - {"\x03", 1, "Aw", 2 }, - {"\x04", 1, "BA", 2 }, /* spellchecker:disable-line */ - {"\x05", 1, "BQ", 2 }, - {"\x06", 1, "Bg", 2 }, - {"\x07", 1, "Bw", 2 }, - {"\x08", 1, "CA", 2 }, - {"\x09", 1, "CQ", 2 }, - {"\x0a", 1, "Cg", 2 }, - {"\x0b", 1, "Cw", 2 }, - {"\x0c", 1, "DA", 2 }, - {"\x0d", 1, "DQ", 2 }, - {"\x0e", 1, "Dg", 2 }, - {"\x0f", 1, "Dw", 2 }, - {"\x10", 1, "EA", 2 }, + { "", 0, "", 0 }, + { "iiiiiiiiiii", 1, "aQ", 2 }, + { "iiiiiiiiiii", 2, "aWk", 3 }, + { "iiiiiiiiiii", 3, "aWlp", 4 }, + { "iiiiiiiiiii", 4, "aWlpaQ", 6 }, + { "iiiiiiiiiii", 5, "aWlpaWk", 7 }, + { "iiiiiiiiiii", 6, "aWlpaWlp", 8 }, + { "iiiiiiiiiii", 7, "aWlpaWlpaQ", 10 }, + { "iiiiiiiiiii", 8, "aWlpaWlpaWk", 11 }, + { "iiiiiiiiiii", 9, "aWlpaWlpaWlp", 12 }, + { "iiiiiiiiiii", 10, "aWlpaWlpaWlpaQ", 14 }, + { "iiiiiiiiiii", 11, "aWlpaWlpaWlpaWk", 15 }, + { "iiiiiiiiiiii", 12, "aWlpaWlpaWlpaWlp", 16 }, + { "\xff\x01\xfe\x02", 4, "_wH-Ag", 6 }, + { "\xff\xff\xff\xff", 4, "_____w", 6 }, + { "\xff\x00\xff\x00", 4, "_wD_AA", 6 }, + { "\x00\xff\x00\xff", 4, "AP8A_w", 6 }, + { "\x00\x00\x00\x00", 4, "AAAAAA", 6 }, + { "\x00", 1, "AA", 2 }, + { "\x01", 1, "AQ", 2 }, + { "\x02", 1, "Ag", 2 }, + { "\x03", 1, "Aw", 2 }, + { "\x04", 1, "BA", 2 }, /* spellchecker:disable-line */ + { "\x05", 1, "BQ", 2 }, + { "\x06", 1, "Bg", 2 }, + { "\x07", 1, "Bw", 2 }, + { "\x08", 1, "CA", 2 }, + { "\x09", 1, "CQ", 2 }, + { "\x0a", 1, "Cg", 2 }, + { "\x0b", 1, "Cw", 2 }, + { "\x0c", 1, "DA", 2 }, + { "\x0d", 1, "DQ", 2 }, + { "\x0e", 1, "Dg", 2 }, + { "\x0f", 1, "Dw", 2 }, + { "\x10", 1, "EA", 2 }, }; /* bad decode inputs */ struct etest badecode[] = { - {"", 0, "", 0 }, /* no dats means error */ - {"", 0, "a", 1 }, /* data is too short */ - {"", 0, "aQ", 2 }, /* data is too short */ - {"", 0, "aQ=", 3 }, /* data is too short */ - {"", 0, "====", 1 }, /* data is only padding characters */ - {"", 0, "====", 2 }, /* data is only padding characters */ - {"", 0, "====", 3 }, /* data is only padding characters */ - {"", 0, "====", 4 }, /* data is only padding characters */ - {"", 0, "a===", 4 }, /* contains three padding characters */ - {"", 0, "a=Q=", 4 }, /* contains a padding character mid input */ - {"", 0, "aWlpa=Q=", 8 }, /* contains a padding character mid input */ - {"", 0, "a\x1f==", 4 }, /* contains illegal base64 character */ - {"", 0, "abcd ", 5 }, /* contains illegal base64 character */ - {"", 0, "abcd ", 6 }, /* contains illegal base64 character */ - {"", 0, " abcd", 5 }, /* contains illegal base64 character */ - {"", 0, "_abcd", 5 }, /* contains illegal base64 character */ - {"", 0, "abcd-", 5 }, /* contains illegal base64 character */ - {"", 0, "abcd_", 5 }, /* contains illegal base64 character */ - {"", 0, "aWlpaWlpaQ==-", 17}, /* bad character after padding */ - {"", 0, "aWlpaWlpaQ==_", 17}, /* bad character after padding */ - {"", 0, "aWlpaWlpaQ== ", 17}, /* bad character after padding */ - {"", 0, "aWlpaWlpaQ=", 15} /* unaligned size, missing a padding char */ + { "", 0, "", 0 }, /* no dats means error */ + { "", 0, "a", 1 }, /* data is too short */ + { "", 0, "aQ", 2 }, /* data is too short */ + { "", 0, "aQ=", 3 }, /* data is too short */ + { "", 0, "====", 1 }, /* data is only padding characters */ + { "", 0, "====", 2 }, /* data is only padding characters */ + { "", 0, "====", 3 }, /* data is only padding characters */ + { "", 0, "====", 4 }, /* data is only padding characters */ + { "", 0, "a===", 4 }, /* contains three padding characters */ + { "", 0, "a=Q=", 4 }, /* contains a padding character mid input */ + { "", 0, "aWlpa=Q=", 8 }, /* contains a padding character mid input */ + { "", 0, "a\x1f==", 4 }, /* contains illegal base64 character */ + { "", 0, "abcd ", 5 }, /* contains illegal base64 character */ + { "", 0, "abcd ", 6 }, /* contains illegal base64 character */ + { "", 0, " abcd", 5 }, /* contains illegal base64 character */ + { "", 0, "_abcd", 5 }, /* contains illegal base64 character */ + { "", 0, "abcd-", 5 }, /* contains illegal base64 character */ + { "", 0, "abcd_", 5 }, /* contains illegal base64 character */ + { "", 0, "aWlpaWlpaQ==-", 17 }, /* bad character after padding */ + { "", 0, "aWlpaWlpaQ==_", 17 }, /* bad character after padding */ + { "", 0, "aWlpaWlpaQ== ", 17 }, /* bad character after padding */ + { "", 0, "aWlpaWlpaQ=", 15 } /* unaligned size, missing a padding char */ }; for(i = 0; i < CURL_ARRAYSIZE(encode); i++) { @@ -161,7 +161,7 @@ static CURLcode test_unit1302(const char *arg) Curl_safefree(decoded); } - for(i = 0 ; i < CURL_ARRAYSIZE(url); i++) { + for(i = 0; i < CURL_ARRAYSIZE(url); i++) { struct etest *e = &url[i]; char *out; size_t olen; diff --git a/tests/unit/unit1307.c b/tests/unit/unit1307.c index 3651b341ed39..5c147c6eda1a 100644 --- a/tests/unit/unit1307.c +++ b/tests/unit/unit1307.c @@ -36,17 +36,17 @@ #define MATCH CURL_FNMATCH_MATCH #define NOMATCH CURL_FNMATCH_NOMATCH -#define LINUX_DIFFER 0x80 -#define LINUX_SHIFT 8 -#define LINUX_MATCH ((CURL_FNMATCH_MATCH << LINUX_SHIFT) | LINUX_DIFFER) +#define LINUX_DIFFER 0x80 +#define LINUX_SHIFT 8 +#define LINUX_MATCH ((CURL_FNMATCH_MATCH << LINUX_SHIFT) | LINUX_DIFFER) #define LINUX_NOMATCH ((CURL_FNMATCH_NOMATCH << LINUX_SHIFT) | LINUX_DIFFER) -#define LINUX_FAIL ((CURL_FNMATCH_FAIL << LINUX_SHIFT) | LINUX_DIFFER) +#define LINUX_FAIL ((CURL_FNMATCH_FAIL << LINUX_SHIFT) | LINUX_DIFFER) -#define MAC_DIFFER 0x40 -#define MAC_SHIFT 16 -#define MAC_MATCH ((CURL_FNMATCH_MATCH << MAC_SHIFT) | MAC_DIFFER) -#define MAC_NOMATCH ((CURL_FNMATCH_NOMATCH << MAC_SHIFT) | MAC_DIFFER) -#define MAC_FAIL ((CURL_FNMATCH_FAIL << MAC_SHIFT) | MAC_DIFFER) +#define MAC_DIFFER 0x40 +#define MAC_SHIFT 16 +#define MAC_MATCH ((CURL_FNMATCH_MATCH << MAC_SHIFT) | MAC_DIFFER) +#define MAC_NOMATCH ((CURL_FNMATCH_NOMATCH << MAC_SHIFT) | MAC_DIFFER) +#define MAC_FAIL ((CURL_FNMATCH_FAIL << MAC_SHIFT) | MAC_DIFFER) static const char *ret2name(int i) { diff --git a/tests/unit/unit1309.c b/tests/unit/unit1309.c index af9a29e11085..46596544c610 100644 --- a/tests/unit/unit1309.c +++ b/tests/unit/unit1309.c @@ -67,8 +67,8 @@ static CURLcode test_unit1309(const char *arg) size_t storage[NUM_NODES * 3]; int rc; int i, j; - struct curltime tv_now = {0, 0}; - root = NULL; /* the empty tree */ + struct curltime tv_now = { 0, 0 }; + root = NULL; /* the empty tree */ /* add nodes */ for(i = 0; i < NUM_NODES; i++) { diff --git a/tests/unit/unit1323.c b/tests/unit/unit1323.c index 15d140e10a2a..c705dc96eb57 100644 --- a/tests/unit/unit1323.c +++ b/tests/unit/unit1323.c @@ -34,10 +34,10 @@ static CURLcode test_unit1323(const char *arg) }; struct a tests[] = { - { {36762, 8345}, {36761, 995926}, 13 }, - { {36761, 995926}, {36762, 8345}, -13 }, - { {36761, 995926}, {0, 0}, 36761995 }, - { {0, 0}, {36761, 995926}, -36761995 }, + { { 36762, 8345 }, { 36761, 995926 }, 13 }, + { { 36761, 995926 }, { 36762, 8345 }, -13 }, + { { 36761, 995926 }, { 0, 0 }, 36761995 }, + { { 0, 0 }, { 36761, 995926 }, -36761995 }, }; size_t i; diff --git a/tests/unit/unit1395.c b/tests/unit/unit1395.c index 395f3e7707d7..7ca7f22c105c 100644 --- a/tests/unit/unit1395.c +++ b/tests/unit/unit1395.c @@ -96,9 +96,9 @@ static CURLcode test_unit1395(const char *arg) { "/hello/1/./../2", "/hello/2" }, { "test/this", "test/this" }, { "test/this/../now", "test/now" }, - { "/1../moo../foo", "/1../moo../foo"}, - { "/../../moo", "/moo"}, - { "/../../moo?", "/moo?"}, + { "/1../moo../foo", "/1../moo../foo" }, + { "/../../moo", "/moo" }, + { "/../../moo?", "/moo?" }, { "/123?", "/123?" }, { "/", NULL }, { "", NULL }, diff --git a/tests/unit/unit1396.c b/tests/unit/unit1396.c index 0b74afa84f94..fd58c03b8004 100644 --- a/tests/unit/unit1396.c +++ b/tests/unit/unit1396.c @@ -52,33 +52,33 @@ static CURLcode test_unit1396(const char *arg) /* unescape, this => that */ const struct test list1[] = { - {"%61", 3, "a", 1}, - {"%61a", 4, "aa", 2}, - {"%61b", 4, "ab", 2}, - {"%6 1", 4, "%6 1", 4}, - {"%61", 1, "%", 1}, - {"%61", 2, "%6", 2}, - {"%6%a", 4, "%6%a", 4}, - {"%6a", 0, "j", 1}, - {"%FF", 0, "\xff", 1}, - {"%FF%00%ff", 9, "\xff\x00\xff", 3}, - {"%-2", 0, "%-2", 3}, - {"%FG", 0, "%FG", 3}, - {NULL, 0, NULL, 0} /* end of list marker */ + { "%61", 3, "a", 1 }, + { "%61a", 4, "aa", 2 }, + { "%61b", 4, "ab", 2 }, + { "%6 1", 4, "%6 1", 4 }, + { "%61", 1, "%", 1 }, + { "%61", 2, "%6", 2 }, + { "%6%a", 4, "%6%a", 4 }, + { "%6a", 0, "j", 1 }, + { "%FF", 0, "\xff", 1 }, + { "%FF%00%ff", 9, "\xff\x00\xff", 3 }, + { "%-2", 0, "%-2", 3 }, + { "%FG", 0, "%FG", 3 }, + { NULL, 0, NULL, 0 } /* end of list marker */ }; /* escape, this => that */ const struct test list2[] = { - {"a", 1, "a", 1}, - {"/", 1, "%2F", 3}, - {"a=b", 3, "a%3Db", 5}, - {"a=b", 0, "a%3Db", 5}, - {"a=b", 1, "a", 1}, - {"a=b", 2, "a%3D", 4}, - {"1/./0", 5, "1%2F.%2F0", 9}, - {"-._~!#%&", 0, "-._~%21%23%25%26", 16}, - {"a", 2, "a%00", 4}, - {"a\xff\x01g", 4, "a%FF%01g", 8}, - {NULL, 0, NULL, 0} /* end of list marker */ + { "a", 1, "a", 1 }, + { "/", 1, "%2F", 3 }, + { "a=b", 3, "a%3Db", 5 }, + { "a=b", 0, "a%3Db", 5 }, + { "a=b", 1, "a", 1 }, + { "a=b", 2, "a%3D", 4 }, + { "1/./0", 5, "1%2F.%2F0", 9 }, + { "-._~!#%&", 0, "-._~%21%23%25%26", 16 }, + { "a", 2, "a%00", 4 }, + { "a\xff\x01g", 4, "a%FF%01g", 8 }, + { NULL, 0, NULL, 0 } /* end of list marker */ }; int i; @@ -86,9 +86,7 @@ static CURLcode test_unit1396(const char *arg) abort_unless(easy != NULL, "returned NULL!"); for(i = 0; list1[i].in; i++) { int outlen; - char *out = curl_easy_unescape(easy, - list1[i].in, list1[i].inlen, - &outlen); + char *out = curl_easy_unescape(easy, list1[i].in, list1[i].inlen, &outlen); abort_unless(out != NULL, "returned NULL!"); fail_unless(outlen == list1[i].outlen, "wrong output length returned"); diff --git a/tests/unit/unit1397.c b/tests/unit/unit1397.c index e56b894e36b3..6726c5053064 100644 --- a/tests/unit/unit1397.c +++ b/tests/unit/unit1397.c @@ -39,56 +39,56 @@ static CURLcode test_unit1397(const char *arg) }; static const struct testcase tests[] = { - {"", "", FALSE}, - {"a", "", FALSE}, - {"", "b", FALSE}, - {"a", "b", FALSE}, - {"aa", "bb", FALSE}, - {"\xff", "\xff", TRUE}, - {"aa.aa.aa", "aa.aa.bb", FALSE}, - {"aa.aa.aa", "aa.aa.aa", TRUE}, - {"aa.aa.aa", "*.aa.bb", FALSE}, - {"aa.aa.aa", "*.aa.aa", TRUE}, - {"192.168.0.1", "192.168.0.1", TRUE}, - {"192.168.0.1", "*.168.0.1", FALSE}, - {"192.168.0.1", "*.0.1", FALSE}, - {"h.ello", "*.ello", FALSE}, - {"h.ello.", "*.ello", FALSE}, - {"h.ello", "*.ello.", FALSE}, - {"h.e.llo", "*.e.llo", TRUE}, - {"h.e.llo", " *.e.llo", FALSE}, - {" h.e.llo", "*.e.llo", TRUE}, - {"h.e.llo.", "*.e.llo", TRUE}, - {"*.e.llo.", "*.e.llo", TRUE}, - {"************.e.llo.", "*.e.llo", TRUE}, - {"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" - "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB" - "CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC" - "DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD" - "EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE" - ".e.llo.", "*.e.llo", TRUE}, - {"\xfe\xfe.e.llo.", "*.e.llo", TRUE}, - {"h.e.llo.", "*.e.llo.", TRUE}, - {"h.e.llo", "*.e.llo.", TRUE}, - {".h.e.llo", "*.e.llo.", FALSE}, - {"h.e.llo", "*.*.llo.", FALSE}, - {"h.e.llo", "h.*.llo", FALSE}, - {"h.e.llo", "h.e.*", FALSE}, - {"hello", "*.ello", FALSE}, - {"hello", "**llo", FALSE}, - {"bar.foo.example.com", "*.example.com", FALSE}, - {"foo.example.com", "*.example.com", TRUE}, - {"baz.example.net", "b*z.example.net", FALSE}, - {"foobaz.example.net", "*baz.example.net", FALSE}, - {"xn--l8j.example.local", "x*.example.local", FALSE}, - {"xn--l8j.example.net", "*.example.net", TRUE}, - {"xn--l8j.example.net", "*j.example.net", FALSE}, - {"xn--l8j.example.net", "xn--l8j.example.net", TRUE}, - {"xn--l8j.example.net", "xn--l8j.*.net", FALSE}, - {"xl8j.example.net", "*.example.net", TRUE}, - {"fe80::3285:a9ff:fe46:b619", "*::3285:a9ff:fe46:b619", FALSE}, - {"fe80::3285:a9ff:fe46:b619", "fe80::3285:a9ff:fe46:b619", TRUE}, - {NULL, NULL, FALSE} + { "", "", FALSE }, + { "a", "", FALSE }, + { "", "b", FALSE }, + { "a", "b", FALSE }, + { "aa", "bb", FALSE }, + { "\xff", "\xff", TRUE }, + { "aa.aa.aa", "aa.aa.bb", FALSE }, + { "aa.aa.aa", "aa.aa.aa", TRUE }, + { "aa.aa.aa", "*.aa.bb", FALSE }, + { "aa.aa.aa", "*.aa.aa", TRUE }, + { "192.168.0.1", "192.168.0.1", TRUE }, + { "192.168.0.1", "*.168.0.1", FALSE }, + { "192.168.0.1", "*.0.1", FALSE }, + { "h.ello", "*.ello", FALSE }, + { "h.ello.", "*.ello", FALSE }, + { "h.ello", "*.ello.", FALSE }, + { "h.e.llo", "*.e.llo", TRUE }, + { "h.e.llo", " *.e.llo", FALSE }, + { " h.e.llo", "*.e.llo", TRUE }, + { "h.e.llo.", "*.e.llo", TRUE }, + { "*.e.llo.", "*.e.llo", TRUE }, + { "************.e.llo.", "*.e.llo", TRUE }, + { "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB" + "CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC" + "DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD" + "EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE" + ".e.llo.", "*.e.llo", TRUE }, + { "\xfe\xfe.e.llo.", "*.e.llo", TRUE }, + { "h.e.llo.", "*.e.llo.", TRUE }, + { "h.e.llo", "*.e.llo.", TRUE }, + { ".h.e.llo", "*.e.llo.", FALSE }, + { "h.e.llo", "*.*.llo.", FALSE }, + { "h.e.llo", "h.*.llo", FALSE }, + { "h.e.llo", "h.e.*", FALSE }, + { "hello", "*.ello", FALSE }, + { "hello", "**llo", FALSE }, + { "bar.foo.example.com", "*.example.com", FALSE }, + { "foo.example.com", "*.example.com", TRUE }, + { "baz.example.net", "b*z.example.net", FALSE }, + { "foobaz.example.net", "*baz.example.net", FALSE }, + { "xn--l8j.example.local", "x*.example.local", FALSE }, + { "xn--l8j.example.net", "*.example.net", TRUE }, + { "xn--l8j.example.net", "*j.example.net", FALSE }, + { "xn--l8j.example.net", "xn--l8j.example.net", TRUE }, + { "xn--l8j.example.net", "xn--l8j.*.net", FALSE }, + { "xl8j.example.net", "*.example.net", TRUE }, + { "fe80::3285:a9ff:fe46:b619", "*::3285:a9ff:fe46:b619", FALSE }, + { "fe80::3285:a9ff:fe46:b619", "fe80::3285:a9ff:fe46:b619", TRUE }, + { NULL, NULL, FALSE } }; int i; diff --git a/tests/unit/unit1398.c b/tests/unit/unit1398.c index abd4447ca464..951a74589f7e 100644 --- a/tests/unit/unit1398.c +++ b/tests/unit/unit1398.c @@ -33,7 +33,7 @@ static CURLcode test_unit1398(const char *arg) UNITTEST_BEGIN_SIMPLE int rc; - char buf[3] = {'b', 'u', 'g'}; + char buf[3] = { 'b', 'u', 'g' }; static const char *str = "bug"; int width = 3; char output[130]; diff --git a/tests/unit/unit1600.c b/tests/unit/unit1600.c index a34720325570..20a299af7370 100644 --- a/tests/unit/unit1600.c +++ b/tests/unit/unit1600.c @@ -51,27 +51,36 @@ static CURLcode test_unit1600(const char *arg) UNITTEST_BEGIN(t1600_setup(&easy)) -#if defined(USE_NTLM) && (!defined(USE_WINDOWS_SSPI) || \ - defined(USE_WIN32_CRYPTO)) +#if defined(USE_NTLM) && \ + (!defined(USE_WINDOWS_SSPI) || defined(USE_WIN32_CRYPTO)) unsigned char output[21]; unsigned char *testp = output; Curl_ntlm_core_mk_nt_hash("1", output); verify_memory(testp, - "\x69\x94\x3c\x5e\x63\xb4\xd2\xc1\x04\xdb" - "\xbc\xc1\x51\x38\xb7\x2b\x00\x00\x00\x00\x00", 21); + "\x69\x94\x3c\x5e\x63\xb4\xd2\xc1\x04\xdb" + "\xbc\xc1\x51\x38\xb7\x2b\x00\x00\x00\x00\x00", + 21); Curl_ntlm_core_mk_nt_hash("hello-you-fool", output); verify_memory(testp, - "\x39\xaf\x87\xa6\x75\x0a\x7a\x00\xba\xa0" - "\xd3\x4f\x04\x9e\xc1\xd0\x00\x00\x00\x00\x00", 21); + "\x39\xaf\x87\xa6\x75\x0a\x7a\x00\xba\xa0" + "\xd3\x4f\x04\x9e\xc1\xd0\x00\x00\x00\x00\x00", + 21); - /* !checksrc! disable LONGLINE 2 */ - Curl_ntlm_core_mk_nt_hash("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", output); + Curl_ntlm_core_mk_nt_hash( + "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + "AAAAAAAA", + output); verify_memory(testp, - "\x36\x9d\xae\x06\x84\x7e\xe1\xc1\x4a\x94\x39\xea\x6f\x44\x8c\x65\x00\x00\x00\x00\x00", 21); + "\x36\x9d\xae\x06\x84\x7e\xe1\xc1\x4a\x94\x39\xea\x6f\x44\x8c" + "\x65\x00\x00\x00\x00\x00", + 21); #endif UNITTEST_END(t1600_stop(easy)) diff --git a/tests/unit/unit1601.c b/tests/unit/unit1601.c index fa7743785dcf..9b0b38486ff9 100644 --- a/tests/unit/unit1601.c +++ b/tests/unit/unit1601.c @@ -42,7 +42,7 @@ static CURLcode test_unit1601(const char *arg) verify_memory(testp, "\xc4\xca\x42\x38\xa0\xb9\x23\x82\x0d\xcc\x50\x9a\x6f" "\x75\x84\x9b", MD5_DIGEST_LEN); - Curl_md5it(output, (const unsigned char *) string2, strlen(string2)); + Curl_md5it(output, (const unsigned char *)string2, strlen(string2)); verify_memory(testp, "\x88\x67\x0b\x6d\x5d\x74\x2f\xad\xa5\xcd\xf9\xb6\x82" "\x87\x5f\x22", MD5_DIGEST_LEN); diff --git a/tests/unit/unit1606.c b/tests/unit/unit1606.c index c7f3d718c7d4..03126a74789f 100644 --- a/tests/unit/unit1606.c +++ b/tests/unit/unit1606.c @@ -52,7 +52,7 @@ static int runawhile(struct Curl_easy *easy, int dec) { int counter = 1; - struct curltime now = {1, 0}; + struct curltime now = { 1, 0 }; CURLcode res; int finaltime; diff --git a/tests/unit/unit1607.c b/tests/unit/unit1607.c index 233866da18b6..c23a59fa54db 100644 --- a/tests/unit/unit1607.c +++ b/tests/unit/unit1607.c @@ -140,7 +140,7 @@ static CURLcode test_unit1607(const char *arg) for(j = 0; j < addressnum; ++j) { uint16_t port = 0; - char ipaddress[MAX_IPADR_LEN] = {0}; + char ipaddress[MAX_IPADR_LEN] = { 0 }; if(!addr && !tests[i].address[j]) break; diff --git a/tests/unit/unit1609.c b/tests/unit/unit1609.c index bf912b99cd1a..b1eac34923dc 100644 --- a/tests/unit/unit1609.c +++ b/tests/unit/unit1609.c @@ -142,7 +142,7 @@ static CURLcode test_unit1609(const char *arg) for(j = 0; j < addressnum; ++j) { uint16_t port = 0; - char ipaddress[MAX_IPADR_LEN] = {0}; + char ipaddress[MAX_IPADR_LEN] = { 0 }; if(!addr && !tests[i].address[j]) break; diff --git a/tests/unit/unit1610.c b/tests/unit/unit1610.c index 5c47fe28e2c6..ba64a15a9603 100644 --- a/tests/unit/unit1610.c +++ b/tests/unit/unit1610.c @@ -49,14 +49,16 @@ static CURLcode test_unit1610(const char *arg) verify_memory(testp, "\x6b\x86\xb2\x73\xff\x34\xfc\xe1\x9d\x6b\x80\x4e\xff\x5a\x3f" "\x57\x47\xad\xa4\xea\xa2\x2f\x1d\x49\xc0\x1e\x52\xdd\xb7\x87" - "\x5b\x4b", CURL_SHA256_DIGEST_LENGTH); + "\x5b\x4b", + CURL_SHA256_DIGEST_LENGTH); Curl_sha256it(output, (const unsigned char *)string2, strlen(string2)); verify_memory(testp, "\xcb\xb1\x6a\x8a\xb9\xcb\xb9\x35\xa8\xcb\xa0\x2e\x28\xc0\x26" "\x30\xd1\x19\x9c\x1f\x02\x17\xf4\x7c\x96\x20\xf3\xef\xe8\x27" - "\x15\xae", CURL_SHA256_DIGEST_LENGTH); + "\x15\xae", + CURL_SHA256_DIGEST_LENGTH); #endif UNITTEST_END(curl_global_cleanup()) diff --git a/tests/unit/unit1611.c b/tests/unit/unit1611.c index 88c79eb3d9af..fbff7f9211dd 100644 --- a/tests/unit/unit1611.c +++ b/tests/unit/unit1611.c @@ -39,13 +39,15 @@ static CURLcode test_unit1611(const char *arg) verify_memory(testp, "\x8b\xe1\xec\x69\x7b\x14\xad\x3a\x53\xb3\x71\x43\x61\x20\x64" - "\x1d", MD4_DIGEST_LENGTH); + "\x1d", + MD4_DIGEST_LENGTH); Curl_md4it(output, (const unsigned char *)string2, strlen(string2)); verify_memory(testp, "\xa7\x16\x1c\xad\x7e\xbe\xdb\xbc\xf8\xc7\x23\x10\x2d\x2c\xe2" - "\x0b", MD4_DIGEST_LENGTH); + "\x0b", + MD4_DIGEST_LENGTH); #endif UNITTEST_END_SIMPLE diff --git a/tests/unit/unit1612.c b/tests/unit/unit1612.c index 7d8c9acf96b6..313ca0f32934 100644 --- a/tests/unit/unit1612.c +++ b/tests/unit/unit1612.c @@ -46,7 +46,8 @@ static CURLcode test_unit1612(const char *arg) verify_memory(testp, "\xd1\x29\x75\x43\x58\xdc\xab\x78\xdf\xcd\x7f\x2b\x29\x31\x13" - "\x37", HMAC_MD5_LENGTH); + "\x37", + HMAC_MD5_LENGTH); Curl_hmacit(&Curl_HMAC_MD5, (const unsigned char *)password, strlen(password), @@ -55,7 +56,8 @@ static CURLcode test_unit1612(const char *arg) verify_memory(testp, "\x75\xf1\xa7\xb9\xf5\x40\xe5\xa4\x98\x83\x9f\x64\x5a\x27\x6d" - "\xd0", HMAC_MD5_LENGTH); + "\xd0", + HMAC_MD5_LENGTH); #endif UNITTEST_END_SIMPLE diff --git a/tests/unit/unit1614.c b/tests/unit/unit1614.c index 7b66af843119..ed0e3aba9807 100644 --- a/tests/unit/unit1614.c +++ b/tests/unit/unit1614.c @@ -40,28 +40,28 @@ static CURLcode test_unit1614(const char *arg) bool match; }; struct check list4[] = { - { "192.160.0.1", "192.160.0.1", 33, FALSE}, - { "192.160.0.1", "192.160.0.1", 32, TRUE}, - { "192.160.0.1", "192.160.0.1", 0, TRUE}, - { "192.160.0.1", "192.160.0.1", 24, TRUE}, - { "192.160.0.1", "192.160.0.1", 26, TRUE}, - { "192.160.0.1", "192.160.0.1", 20, TRUE}, - { "192.160.0.1", "192.160.0.1", 18, TRUE}, - { "192.160.0.1", "192.160.0.1", 12, TRUE}, - { "192.160.0.1", "192.160.0.1", 8, TRUE}, - { "192.160.0.1", "10.0.0.1", 8, FALSE}, - { "192.160.0.1", "10.0.0.1", 32, FALSE}, - { "192.160.0.1", "10.0.0.1", 0, FALSE}, - { NULL, NULL, 0, FALSE} /* end marker */ + { "192.160.0.1", "192.160.0.1", 33, FALSE }, + { "192.160.0.1", "192.160.0.1", 32, TRUE }, + { "192.160.0.1", "192.160.0.1", 0, TRUE }, + { "192.160.0.1", "192.160.0.1", 24, TRUE }, + { "192.160.0.1", "192.160.0.1", 26, TRUE }, + { "192.160.0.1", "192.160.0.1", 20, TRUE }, + { "192.160.0.1", "192.160.0.1", 18, TRUE }, + { "192.160.0.1", "192.160.0.1", 12, TRUE }, + { "192.160.0.1", "192.160.0.1", 8, TRUE }, + { "192.160.0.1", "10.0.0.1", 8, FALSE }, + { "192.160.0.1", "10.0.0.1", 32, FALSE }, + { "192.160.0.1", "10.0.0.1", 0, FALSE }, + { NULL, NULL, 0, FALSE } /* end marker */ }; #ifdef USE_IPV6 struct check list6[] = { - { "::1", "::1", 0, TRUE}, - { "::1", "::1", 128, TRUE}, - { "::1", "0:0::1", 128, TRUE}, - { "::1", "0:0::1", 129, FALSE}, - { "fe80::ab47:4396:55c9:8474", "fe80::ab47:4396:55c9:8474", 64, TRUE}, - { NULL, NULL, 0, FALSE} /* end marker */ + { "::1", "::1", 0, TRUE }, + { "::1", "::1", 128, TRUE }, + { "::1", "0:0::1", 128, TRUE }, + { "::1", "0:0::1", 129, FALSE }, + { "fe80::ab47:4396:55c9:8474", "fe80::ab47:4396:55c9:8474", 64, TRUE }, + { NULL, NULL, 0, FALSE } /* end marker */ }; #endif struct noproxy { @@ -70,91 +70,91 @@ static CURLcode test_unit1614(const char *arg) bool match; }; struct noproxy list[] = { - { "www.example.com", "localhost .example.com .example.de", FALSE}, - { "www.example.com", "localhost,.example.com,.example.de", TRUE}, - { "www.example.com.", "localhost,.example.com,.example.de", TRUE}, - { "example.com", "localhost,.example.com,.example.de", TRUE}, - { "example.com.", "localhost,.example.com,.example.de", TRUE}, - { "www.example.com", "localhost,.example.com.,.example.de", TRUE}, - { "www.example.com", "localhost,www.example.com.,.example.de", TRUE}, - { "example.com", "localhost,example.com,.example.de", TRUE}, - { "example.com.", "localhost,example.com,.example.de", TRUE}, - { "nexample.com", "localhost,example.com,.example.de", FALSE}, - { "www.example.com", "localhost,example.com,.example.de", TRUE}, - { "127.0.0.1", "127.0.0.1,localhost", TRUE}, - { "127.0.0.1", "127.0.0.1,localhost,", TRUE}, - { "127.0.0.1", "127.0.0.1/8,localhost,", TRUE}, - { "127.0.0.1", "127.0.0.1/28,localhost,", TRUE}, - { "127.0.0.1", "127.0.0.1/31,localhost,", TRUE}, - { "127.0.0.1", "localhost,127.0.0.1", TRUE}, + { "www.example.com", "localhost .example.com .example.de", FALSE }, + { "www.example.com", "localhost,.example.com,.example.de", TRUE }, + { "www.example.com.", "localhost,.example.com,.example.de", TRUE }, + { "example.com", "localhost,.example.com,.example.de", TRUE }, + { "example.com.", "localhost,.example.com,.example.de", TRUE }, + { "www.example.com", "localhost,.example.com.,.example.de", TRUE }, + { "www.example.com", "localhost,www.example.com.,.example.de", TRUE }, + { "example.com", "localhost,example.com,.example.de", TRUE }, + { "example.com.", "localhost,example.com,.example.de", TRUE }, + { "nexample.com", "localhost,example.com,.example.de", FALSE }, + { "www.example.com", "localhost,example.com,.example.de", TRUE }, + { "127.0.0.1", "127.0.0.1,localhost", TRUE }, + { "127.0.0.1", "127.0.0.1,localhost,", TRUE }, + { "127.0.0.1", "127.0.0.1/8,localhost,", TRUE }, + { "127.0.0.1", "127.0.0.1/28,localhost,", TRUE }, + { "127.0.0.1", "127.0.0.1/31,localhost,", TRUE }, + { "127.0.0.1", "localhost,127.0.0.1", TRUE }, { "127.0.0.1", "localhost,127.0.0.1.127.0.0.1.127.0.0.1.127.0.0.1." "127.0.0.1.127.0.0.1.127.0.0.1.127.0.0.1.127.0.0.1.127.0.0.1.127." - "0.0.1.127.0.0.1.127.0.0." /* 128 bytes "address" */, FALSE}, + "0.0.1.127.0.0.1.127.0.0." /* 128 bytes "address" */, FALSE }, { "127.0.0.1", "localhost,127.0.0.1.127.0.0.1.127.0.0.1.127.0.0.1." "127.0.0.1.127.0.0.1.127.0.0.1.127.0.0.1.127.0.0.1.127.0.0.1.127." - "0.0.1.127.0.0.1.127.0.0" /* 127 bytes "address" */, FALSE}, - { "localhost", "localhost,127.0.0.1", TRUE}, - { "localhost", "127.0.0.1,localhost", TRUE}, - { "foobar", "barfoo", FALSE}, - { "foobar", "foobar", TRUE}, - { "192.168.0.1", "foobar", FALSE}, - { "192.168.0.1", "192.168.0.0/16", TRUE}, - { "192.168.0.1", "192.168.0.0/16a", FALSE}, - { "192.168.0.1", "192.168.0.0/16 ", TRUE}, - { "192.168.0.1", "192.168.0.0/a16", FALSE}, - { "192.168.0.1", "192.168.0.0/ 16", FALSE}, - { "192.168.0.1", "192.168.0.0/24", TRUE}, - { "192.168.0.1", "192.168.0.0/32", FALSE}, - { "192.168.0.1", "192.168.0.1/32", TRUE}, - { "192.168.0.1", "192.168.0.1/33", FALSE}, - { "192.168.0.1", "192.168.0.0", FALSE}, - { "192.168.1.1", "192.168.0.0/24", FALSE}, - { "192.168.1.1", "192.168.0.0/33", FALSE}, - { "192.168.1.1", "foo, bar, 192.168.0.0/24", FALSE}, - { "192.168.1.1", "foo, bar, 192.168.0.0/16", TRUE}, + "0.0.1.127.0.0.1.127.0.0" /* 127 bytes "address" */, FALSE }, + { "localhost", "localhost,127.0.0.1", TRUE }, + { "localhost", "127.0.0.1,localhost", TRUE }, + { "foobar", "barfoo", FALSE }, + { "foobar", "foobar", TRUE }, + { "192.168.0.1", "foobar", FALSE }, + { "192.168.0.1", "192.168.0.0/16", TRUE }, + { "192.168.0.1", "192.168.0.0/16a", FALSE }, + { "192.168.0.1", "192.168.0.0/16 ", TRUE }, + { "192.168.0.1", "192.168.0.0/a16", FALSE }, + { "192.168.0.1", "192.168.0.0/ 16", FALSE }, + { "192.168.0.1", "192.168.0.0/24", TRUE }, + { "192.168.0.1", "192.168.0.0/32", FALSE }, + { "192.168.0.1", "192.168.0.1/32", TRUE }, + { "192.168.0.1", "192.168.0.1/33", FALSE }, + { "192.168.0.1", "192.168.0.0", FALSE }, + { "192.168.1.1", "192.168.0.0/24", FALSE }, + { "192.168.1.1", "192.168.0.0/33", FALSE }, + { "192.168.1.1", "foo, bar, 192.168.0.0/24", FALSE }, + { "192.168.1.1", "foo, bar, 192.168.0.0/16", TRUE }, #ifdef USE_IPV6 - { "::1", "foo, bar, 192.168.0.0/16", FALSE}, - { "::1", "foo, bar, ::1/64", TRUE}, - { "::1", "::1/64", TRUE}, - { "::1", "::1/96", TRUE}, - { "::1", "::1/129", FALSE}, - { "::1", "::1/128", TRUE}, - { "::1", "::1/127", TRUE}, - { "::1", "::1/a127", FALSE}, - { "::1", "::1/127a", FALSE}, - { "::1", "::1/ 127", FALSE}, - { "::1", "::1/127 ", TRUE}, - { "::1", "::1/126", TRUE}, - { "::1", "::1/125", TRUE}, - { "::1", "::1/124", TRUE}, - { "::1", "::1/123", TRUE}, - { "::1", "::1/122", TRUE}, - { "2001:db8:8000::1", "2001:db8::/65", FALSE}, - { "2001:db8:8000::1", "2001:db8::/66", FALSE}, - { "2001:db8:8000::1", "2001:db8::/67", FALSE}, - { "2001:db8:8000::1", "2001:db8::/68", FALSE}, - { "2001:db8:8000::1", "2001:db8::/69", FALSE}, - { "2001:db8:8000::1", "2001:db8::/70", FALSE}, - { "2001:db8:8000::1", "2001:db8::/71", FALSE}, - { "2001:db8:8000::1", "2001:db8::/72", FALSE}, - { "2001:db8::1", "2001:db8::/65", TRUE}, - { "2001:db8::1", "2001:db8::/66", TRUE}, - { "2001:db8::1", "2001:db8::/67", TRUE}, - { "2001:db8::1", "2001:db8::/68", TRUE}, - { "2001:db8::1", "2001:db8::/69", TRUE}, - { "2001:db8::1", "2001:db8::/70", TRUE}, - { "2001:db8::1", "2001:db8::/71", TRUE}, - { "2001:db8::1", "2001:db8::/72", TRUE}, - { "::1", "::1/129", FALSE}, - { "bar", "foo, bar, ::1/64", TRUE}, - { "BAr", "foo, bar, ::1/64", TRUE}, - { "BAr", "foo,,,,, bar, ::1/64", TRUE}, + { "::1", "foo, bar, 192.168.0.0/16", FALSE }, + { "::1", "foo, bar, ::1/64", TRUE }, + { "::1", "::1/64", TRUE }, + { "::1", "::1/96", TRUE }, + { "::1", "::1/129", FALSE }, + { "::1", "::1/128", TRUE }, + { "::1", "::1/127", TRUE }, + { "::1", "::1/a127", FALSE }, + { "::1", "::1/127a", FALSE }, + { "::1", "::1/ 127", FALSE }, + { "::1", "::1/127 ", TRUE }, + { "::1", "::1/126", TRUE }, + { "::1", "::1/125", TRUE }, + { "::1", "::1/124", TRUE }, + { "::1", "::1/123", TRUE }, + { "::1", "::1/122", TRUE }, + { "2001:db8:8000::1", "2001:db8::/65", FALSE }, + { "2001:db8:8000::1", "2001:db8::/66", FALSE }, + { "2001:db8:8000::1", "2001:db8::/67", FALSE }, + { "2001:db8:8000::1", "2001:db8::/68", FALSE }, + { "2001:db8:8000::1", "2001:db8::/69", FALSE }, + { "2001:db8:8000::1", "2001:db8::/70", FALSE }, + { "2001:db8:8000::1", "2001:db8::/71", FALSE }, + { "2001:db8:8000::1", "2001:db8::/72", FALSE }, + { "2001:db8::1", "2001:db8::/65", TRUE }, + { "2001:db8::1", "2001:db8::/66", TRUE }, + { "2001:db8::1", "2001:db8::/67", TRUE }, + { "2001:db8::1", "2001:db8::/68", TRUE }, + { "2001:db8::1", "2001:db8::/69", TRUE }, + { "2001:db8::1", "2001:db8::/70", TRUE }, + { "2001:db8::1", "2001:db8::/71", TRUE }, + { "2001:db8::1", "2001:db8::/72", TRUE }, + { "::1", "::1/129", FALSE }, + { "bar", "foo, bar, ::1/64", TRUE }, + { "BAr", "foo, bar, ::1/64", TRUE }, + { "BAr", "foo,,,,, bar, ::1/64", TRUE }, #endif - { "www.example.com", "foo, .example.com", TRUE}, - { "www.example.com", "www2.example.com, .example.net", FALSE}, - { "example.com", ".example.com, .example.net", TRUE}, - { "nonexample.com", ".example.com, .example.net", FALSE}, - { NULL, NULL, FALSE} + { "www.example.com", "foo, .example.com", TRUE }, + { "www.example.com", "www2.example.com, .example.net", FALSE }, + { "example.com", ".example.com, .example.net", TRUE }, + { "nonexample.com", ".example.com, .example.net", FALSE }, + { NULL, NULL, FALSE } }; for(i = 0; list4[i].a; i++) { bool match = Curl_cidr4_match(list4[i].a, list4[i].n, list4[i].bits); diff --git a/tests/unit/unit1615.c b/tests/unit/unit1615.c index fadb1aaa59b4..93237db27449 100644 --- a/tests/unit/unit1615.c +++ b/tests/unit/unit1615.c @@ -34,77 +34,78 @@ static CURLcode test_unit1615(const char *arg) static const char test_str1[] = "1"; static const unsigned char precomp_hash1[CURL_SHA512_256_DIGEST_LENGTH] = { - 0x18, 0xd2, 0x75, 0x66, 0xbd, 0x1a, 0xc6, 0x6b, 0x23, 0x32, 0xd8, - 0xc5, 0x4a, 0xd4, 0x3f, 0x7b, 0xb2, 0x20, 0x79, 0xc9, 0x06, 0xd0, - 0x5f, 0x49, 0x1f, 0x3f, 0x07, 0xa2, 0x8d, 0x5c, 0x69, 0x90 + 0x18, 0xd2, 0x75, 0x66, 0xbd, 0x1a, 0xc6, 0x6b, 0x23, 0x32, 0xd8, + 0xc5, 0x4a, 0xd4, 0x3f, 0x7b, 0xb2, 0x20, 0x79, 0xc9, 0x06, 0xd0, + 0x5f, 0x49, 0x1f, 0x3f, 0x07, 0xa2, 0x8d, 0x5c, 0x69, 0x90 }; static const char test_str2[] = "hello-you-fool"; static const unsigned char precomp_hash2[CURL_SHA512_256_DIGEST_LENGTH] = { - 0xaf, 0x6f, 0xb4, 0xb0, 0x13, 0x9b, 0xee, 0x13, 0xd1, 0x95, 0x3c, - 0xb8, 0xc7, 0xcd, 0x5b, 0x19, 0xf9, 0xcd, 0xcd, 0x21, 0xef, 0xdf, - 0xa7, 0x42, 0x5c, 0x07, 0x13, 0xea, 0xcc, 0x1a, 0x39, 0x76 + 0xaf, 0x6f, 0xb4, 0xb0, 0x13, 0x9b, 0xee, 0x13, 0xd1, 0x95, 0x3c, + 0xb8, 0xc7, 0xcd, 0x5b, 0x19, 0xf9, 0xcd, 0xcd, 0x21, 0xef, 0xdf, + 0xa7, 0x42, 0x5c, 0x07, 0x13, 0xea, 0xcc, 0x1a, 0x39, 0x76 }; static const char test_str3[] = "abc"; static const unsigned char precomp_hash3[CURL_SHA512_256_DIGEST_LENGTH] = { - 0x53, 0x04, 0x8E, 0x26, 0x81, 0x94, 0x1E, 0xF9, 0x9B, 0x2E, 0x29, - 0xB7, 0x6B, 0x4C, 0x7D, 0xAB, 0xE4, 0xC2, 0xD0, 0xC6, 0x34, 0xFC, - 0x6D, 0x46, 0xE0, 0xE2, 0xF1, 0x31, 0x07, 0xE7, 0xAF, 0x23 + 0x53, 0x04, 0x8E, 0x26, 0x81, 0x94, 0x1E, 0xF9, 0x9B, 0x2E, 0x29, + 0xB7, 0x6B, 0x4C, 0x7D, 0xAB, 0xE4, 0xC2, 0xD0, 0xC6, 0x34, 0xFC, + 0x6D, 0x46, 0xE0, 0xE2, 0xF1, 0x31, 0x07, 0xE7, 0xAF, 0x23 }; static const char test_str4[] = ""; /* empty, zero size input */ static const unsigned char precomp_hash4[CURL_SHA512_256_DIGEST_LENGTH] = { - 0xc6, 0x72, 0xb8, 0xd1, 0xef, 0x56, 0xed, 0x28, 0xab, 0x87, 0xc3, - 0x62, 0x2c, 0x51, 0x14, 0x06, 0x9b, 0xdd, 0x3a, 0xd7, 0xb8, 0xf9, - 0x73, 0x74, 0x98, 0xd0, 0xc0, 0x1e, 0xce, 0xf0, 0x96, 0x7a + 0xc6, 0x72, 0xb8, 0xd1, 0xef, 0x56, 0xed, 0x28, 0xab, 0x87, 0xc3, + 0x62, 0x2c, 0x51, 0x14, 0x06, 0x9b, 0xdd, 0x3a, 0xd7, 0xb8, 0xf9, + 0x73, 0x74, 0x98, 0xd0, 0xc0, 0x1e, 0xce, 0xf0, 0x96, 0x7a }; static const char test_str5[] = - "abcdefghijklmnopqrstuvwxyzzyxwvutsrqponMLKJIHGFEDCBA" \ - "abcdefghijklmnopqrstuvwxyzzyxwvutsrqponMLKJIHGFEDCBA"; + "abcdefghijklmnopqrstuvwxyzzyxwvutsrqponMLKJIHGFEDCBA" + "abcdefghijklmnopqrstuvwxyzzyxwvutsrqponMLKJIHGFEDCBA"; static const unsigned char precomp_hash5[CURL_SHA512_256_DIGEST_LENGTH] = { - 0xad, 0xe9, 0x5d, 0x55, 0x3b, 0x9e, 0x45, 0x69, 0xdb, 0x53, 0xa4, - 0x04, 0x92, 0xe7, 0x87, 0x94, 0xff, 0xc9, 0x98, 0x5f, 0x93, 0x03, - 0x86, 0x45, 0xe1, 0x97, 0x17, 0x72, 0x7c, 0xbc, 0x31, 0x15 + 0xad, 0xe9, 0x5d, 0x55, 0x3b, 0x9e, 0x45, 0x69, 0xdb, 0x53, 0xa4, + 0x04, 0x92, 0xe7, 0x87, 0x94, 0xff, 0xc9, 0x98, 0x5f, 0x93, 0x03, + 0x86, 0x45, 0xe1, 0x97, 0x17, 0x72, 0x7c, 0xbc, 0x31, 0x15 }; static const char test_str6[] = - "/long/long/long/long/long/long/long/long/long/long/long" \ - "/long/long/long/long/long/long/long/long/long/long/long" \ - "/long/long/long/long/long/long/long/long/long/long/long" \ - "/long/long/long/long/long/long/long/long/long/long/long" \ - "/long/long/long/long/long/long/long/long/long/long/long" \ - "/long/long/long/long/long/long/long/long/long/long/long" \ - "/long/long/long/long/path?with%20some=parameters"; + "/long/long/long/long/long/long/long/long/long/long/long" + "/long/long/long/long/long/long/long/long/long/long/long" + "/long/long/long/long/long/long/long/long/long/long/long" + "/long/long/long/long/long/long/long/long/long/long/long" + "/long/long/long/long/long/long/long/long/long/long/long" + "/long/long/long/long/long/long/long/long/long/long/long" + "/long/long/long/long/path?with%20some=parameters"; static const unsigned char precomp_hash6[CURL_SHA512_256_DIGEST_LENGTH] = { - 0xbc, 0xab, 0xc6, 0x2c, 0x0a, 0x22, 0xd5, 0xcb, 0xac, 0xac, 0xe9, - 0x25, 0xcf, 0xce, 0xaa, 0xaf, 0x0e, 0xa1, 0xed, 0x42, 0x46, 0x8a, - 0xe2, 0x01, 0xee, 0x2f, 0xdb, 0x39, 0x75, 0x47, 0x73, 0xf1 + 0xbc, 0xab, 0xc6, 0x2c, 0x0a, 0x22, 0xd5, 0xcb, 0xac, 0xac, 0xe9, + 0x25, 0xcf, 0xce, 0xaa, 0xaf, 0x0e, 0xa1, 0xed, 0x42, 0x46, 0x8a, + 0xe2, 0x01, 0xee, 0x2f, 0xdb, 0x39, 0x75, 0x47, 0x73, 0xf1 }; static const char test_str7[] = "Simple string."; static const unsigned char precomp_hash7[CURL_SHA512_256_DIGEST_LENGTH] = { - 0xde, 0xcb, 0x3c, 0x81, 0x65, 0x4b, 0xa0, 0xf5, 0xf0, 0x45, 0x6b, - 0x7e, 0x61, 0xf5, 0x0d, 0xf5, 0x38, 0xa4, 0xfc, 0xb1, 0x8a, 0x95, - 0xff, 0x59, 0xbc, 0x04, 0x82, 0xcf, 0x23, 0xb2, 0x32, 0x56 + 0xde, 0xcb, 0x3c, 0x81, 0x65, 0x4b, 0xa0, 0xf5, 0xf0, 0x45, 0x6b, + 0x7e, 0x61, 0xf5, 0x0d, 0xf5, 0x38, 0xa4, 0xfc, 0xb1, 0x8a, 0x95, + 0xff, 0x59, 0xbc, 0x04, 0x82, 0xcf, 0x23, 0xb2, 0x32, 0x56 }; - static const unsigned char test_seq8[]= { - 255, 254, 253, 252, 251, 250, 249, 248, 247, 246, 245, 244, 243, 242, - 241, 240, 239, 238, 237, 236, 235, 234, 233, 232, 231, 230, 229, 228, - 227, 226, 225, 224, 223, 222, 221, 220, 219, 218, 217, 216, 215, 214, - 213, 212, 211, 210, 209, 208, 207, 206, 205, 204, 203, 202, 201, 200, - 199, 198, 197, 196, 195, 194, 193, 192, 191, 190, 189, 188, 187, 186, - 185, 184, 183, 182, 181, 180, 179, 178, 177, 176, 175, 174, 173, 172, - 171, 170, 169, 168, 167, 166, 165, 164, 163, 162, 161, 160, 159, 158, - 157, 156, 155, 154, 153, 152, 151, 150, 149, 148, 147, 146, 145, 144, - 143, 142, 141, 140, 139, 138, 137, 136, 135, 134, 133, 132, 131, 130, - 129, 128, 127, 126, 125, 124, 123, 122, 121, 120, 119, 118, 117, 116, - 115, 114, 113, 112, 111, 110, 109, 108, 107, 106, 105, 104, 103, 102, - 101, 100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, - 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, - 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, - 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, - 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, - 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1}; /* 255..1 sequence */ + static const unsigned char test_seq8[] = { + 255, 254, 253, 252, 251, 250, 249, 248, 247, 246, 245, 244, 243, 242, 241, + 240, 239, 238, 237, 236, 235, 234, 233, 232, 231, 230, 229, 228, 227, 226, + 225, 224, 223, 222, 221, 220, 219, 218, 217, 216, 215, 214, 213, 212, 211, + 210, 209, 208, 207, 206, 205, 204, 203, 202, 201, 200, 199, 198, 197, 196, + 195, 194, 193, 192, 191, 190, 189, 188, 187, 186, 185, 184, 183, 182, 181, + 180, 179, 178, 177, 176, 175, 174, 173, 172, 171, 170, 169, 168, 167, 166, + 165, 164, 163, 162, 161, 160, 159, 158, 157, 156, 155, 154, 153, 152, 151, + 150, 149, 148, 147, 146, 145, 144, 143, 142, 141, 140, 139, 138, 137, 136, + 135, 134, 133, 132, 131, 130, 129, 128, 127, 126, 125, 124, 123, 122, 121, + 120, 119, 118, 117, 116, 115, 114, 113, 112, 111, 110, 109, 108, 107, 106, + 105, 104, 103, 102, 101, 100, 99, 98, 97, 96, 95, 94, 93, 92, 91, + 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, + 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, + 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, + 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, + 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, + 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 + }; /* 255..1 sequence */ static const unsigned char precomp_hash8[CURL_SHA512_256_DIGEST_LENGTH] = { - 0x22, 0x31, 0xf2, 0xa1, 0xb4, 0x89, 0xb2, 0x44, 0xf7, 0x66, 0xa0, - 0xb8, 0x31, 0xed, 0xb7, 0x73, 0x8a, 0x34, 0xdc, 0x11, 0xc8, 0x2c, - 0xf2, 0xb5, 0x88, 0x60, 0x39, 0x6b, 0x5c, 0x06, 0x70, 0x37 + 0x22, 0x31, 0xf2, 0xa1, 0xb4, 0x89, 0xb2, 0x44, 0xf7, 0x66, 0xa0, + 0xb8, 0x31, 0xed, 0xb7, 0x73, 0x8a, 0x34, 0xdc, 0x11, 0xc8, 0x2c, + 0xf2, 0xb5, 0x88, 0x60, 0x39, 0x6b, 0x5c, 0x06, 0x70, 0x37 }; unsigned char output_buf[CURL_SHA512_256_DIGEST_LENGTH]; diff --git a/tests/unit/unit1620.c b/tests/unit/unit1620.c index b04424ae3bd3..e6070ad157d4 100644 --- a/tests/unit/unit1620.c +++ b/tests/unit/unit1620.c @@ -33,17 +33,16 @@ static CURLcode t1620_setup(void) return res; } -static void t1620_parse( - const char *input, - const char *exp_username, - const char *exp_password, - const char *exp_options) +static void t1620_parse(const char *input, + const char *exp_username, + const char *exp_password, + const char *exp_options) { char *userstr = NULL; char *passwdstr = NULL; char *options = NULL; - CURLcode rc = Curl_parse_login_details(input, strlen(input), - &userstr, &passwdstr, &options); + CURLcode rc = Curl_parse_login_details(input, strlen(input), &userstr, + &passwdstr, &options); fail_unless(rc == CURLE_OK, "Curl_parse_login_details() failed"); fail_unless(!!exp_username == !!userstr, "username expectation failed"); @@ -52,13 +51,13 @@ static void t1620_parse( if(!unitfail) { fail_unless(!userstr || !exp_username || - strcmp(userstr, exp_username) == 0, + strcmp(userstr, exp_username) == 0, "userstr should be equal to exp_username"); fail_unless(!passwdstr || !exp_password || - strcmp(passwdstr, exp_password) == 0, + strcmp(passwdstr, exp_password) == 0, "passwdstr should be equal to exp_password"); fail_unless(!options || !exp_options || - strcmp(options, exp_options) == 0, + strcmp(options, exp_options) == 0, "options should be equal to exp_options"); } diff --git a/tests/unit/unit1650.c b/tests/unit/unit1650.c index 309515d9b125..c9bb5745c7b7 100644 --- a/tests/unit/unit1650.c +++ b/tests/unit/unit1650.c @@ -31,13 +31,13 @@ static CURLcode test_unit1650(const char *arg) #ifndef CURL_DISABLE_DOH -#define DNS_PREAMBLE "\x00\x00\x01\x00\x00\x01\x00\x00\x00\x00\x00\x00" -#define LABEL_TEST "\x04\x74\x65\x73\x74" -#define LABEL_HOST "\x04\x68\x6f\x73\x74" -#define LABEL_NAME "\x04\x6e\x61\x6d\x65" -#define DNSA_TYPE "\x01" -#define DNSAAAA_TYPE "\x1c" -#define DNSA_EPILOGUE "\x00\x00" DNSA_TYPE "\x00\x01" +#define DNS_PREAMBLE "\x00\x00\x01\x00\x00\x01\x00\x00\x00\x00\x00\x00" +#define LABEL_TEST "\x04\x74\x65\x73\x74" +#define LABEL_HOST "\x04\x68\x6f\x73\x74" +#define LABEL_NAME "\x04\x6e\x61\x6d\x65" +#define DNSA_TYPE "\x01" +#define DNSAAAA_TYPE "\x1c" +#define DNSA_EPILOGUE "\x00\x00" DNSA_TYPE "\x00\x01" #define DNSAAAA_EPILOGUE "\x00\x00" DNSAAAA_TYPE "\x00\x01" #define DNS_Q1 DNS_PREAMBLE LABEL_TEST LABEL_HOST LABEL_NAME DNSA_EPILOGUE diff --git a/tests/unit/unit1651.c b/tests/unit/unit1651.c index ffaea47b20ea..251f2c1c8093 100644 --- a/tests/unit/unit1651.c +++ b/tests/unit/unit1651.c @@ -32,312 +32,336 @@ static CURLcode test_unit1651(const char *arg) #if defined(USE_GNUTLS) || defined(USE_SCHANNEL) /* cert captured from gdb when connecting to curl.se on October 26 - 2018. - !checksrc! disable CLOSEBRACE 1 */ + 2018. */ static unsigned char cert[] = { - 0x30, 0x82, 0x0F, 0x5B, 0x30, 0x82, 0x0E, 0x43, 0xA0, 0x03, 0x02, 0x01, 0x02, - 0x02, 0x0C, 0x08, 0x77, 0x99, 0x2C, 0x6B, 0x67, 0xE1, 0x18, 0xD6, 0x66, 0x66, - 0x9E, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, - 0x0B, 0x05, 0x00, 0x30, 0x57, 0x31, 0x0B, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, - 0x06, 0x13, 0x02, 0x42, 0x45, 0x31, 0x19, 0x30, 0x17, 0x06, 0x03, 0x55, 0x04, - 0x0A, 0x13, 0x10, 0x47, 0x6C, 0x6F, 0x62, 0x61, 0x6C, 0x53, 0x69, 0x67, 0x6E, - 0x20, 0x6E, 0x76, 0x2D, 0x73, 0x61, 0x31, 0x2D, 0x30, 0x2B, 0x06, 0x03, 0x55, - 0x04, 0x03, 0x13, 0x24, 0x47, 0x6C, 0x6F, 0x62, 0x61, 0x6C, 0x53, 0x69, 0x67, - 0x6E, 0x20, 0x43, 0x6C, 0x6F, 0x75, 0x64, 0x53, 0x53, 0x4C, 0x20, 0x43, 0x41, - 0x20, 0x2D, 0x20, 0x53, 0x48, 0x41, 0x32, 0x35, 0x36, 0x20, 0x2D, 0x20, 0x47, - 0x33, 0x30, 0x1E, 0x17, 0x0D, 0x31, 0x38, 0x31, 0x30, 0x32, 0x32, 0x31, 0x37, - 0x31, 0x38, 0x32, 0x31, 0x5A, 0x17, 0x0D, 0x31, 0x39, 0x30, 0x33, 0x32, 0x31, - 0x31, 0x33, 0x34, 0x33, 0x34, 0x34, 0x5A, 0x30, 0x77, 0x31, 0x0B, 0x30, 0x09, - 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x55, 0x53, 0x31, 0x13, 0x30, 0x11, - 0x06, 0x03, 0x55, 0x04, 0x08, 0x0C, 0x0A, 0x43, 0x61, 0x6C, 0x69, 0x66, 0x6F, - 0x72, 0x6E, 0x69, 0x61, 0x31, 0x16, 0x30, 0x14, 0x06, 0x03, 0x55, 0x04, 0x07, - 0x0C, 0x0D, 0x53, 0x61, 0x6E, 0x20, 0x46, 0x72, 0x61, 0x6E, 0x63, 0x69, 0x73, - 0x63, 0x6F, 0x31, 0x15, 0x30, 0x13, 0x06, 0x03, 0x55, 0x04, 0x0A, 0x0C, 0x0C, - 0x46, 0x61, 0x73, 0x74, 0x6C, 0x79, 0x2C, 0x20, 0x49, 0x6E, 0x63, 0x2E, 0x31, - 0x24, 0x30, 0x22, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0C, 0x1B, 0x6A, 0x32, 0x2E, - 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x2E, 0x67, 0x6C, 0x6F, 0x62, 0x61, 0x6C, - 0x2E, 0x66, 0x61, 0x73, 0x74, 0x6C, 0x79, 0x2E, 0x6E, 0x65, 0x74, 0x30, 0x82, - 0x01, 0x22, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, - 0x01, 0x01, 0x05, 0x00, 0x03, 0x82, 0x01, 0x0F, 0x00, 0x30, 0x82, 0x01, 0x0A, - 0x02, 0x82, 0x01, 0x01, 0x00, 0xC2, 0x72, 0xA2, 0x4A, 0xEF, 0x26, 0x42, 0xD7, - 0x85, 0x74, 0xC9, 0xB4, 0x9F, 0xE3, 0x31, 0xD1, 0x40, 0x77, 0xC9, 0x4B, 0x4D, - 0xFE, 0xC8, 0x75, 0xF3, 0x32, 0x76, 0xAD, 0xF9, 0x08, 0x22, 0x9E, 0xFA, 0x2F, - 0xFE, 0xEC, 0x6C, 0xC4, 0xF5, 0x1F, 0x70, 0xC9, 0x8F, 0x07, 0x48, 0x31, 0xAD, - 0x75, 0x18, 0xFC, 0x06, 0x5A, 0x4F, 0xDD, 0xFD, 0x05, 0x39, 0x6F, 0x22, 0xF9, - 0xAD, 0x62, 0x1A, 0x9E, 0xA6, 0x16, 0x48, 0x75, 0x8F, 0xB8, 0x07, 0x18, 0x25, - 0x1A, 0x87, 0x30, 0xB0, 0x3C, 0x6F, 0xE0, 0x9D, 0x90, 0x63, 0x2A, 0x16, 0x1F, - 0x0D, 0x10, 0xFC, 0x06, 0x7E, 0xEA, 0x51, 0xE2, 0xB0, 0x6D, 0x42, 0x4C, 0x2C, - 0x59, 0xF4, 0x6B, 0x99, 0x3E, 0x82, 0x1D, 0x08, 0x04, 0x2F, 0xA0, 0x63, 0x3C, - 0xAA, 0x0E, 0xE1, 0x5D, 0x67, 0x2D, 0xB3, 0xF4, 0x15, 0xD6, 0x16, 0x4E, 0xAA, - 0x91, 0x45, 0x6B, 0xC5, 0xA6, 0xED, 0x83, 0xAF, 0xF1, 0xD7, 0x42, 0x5E, 0x9B, - 0xC8, 0x39, 0x0C, 0x06, 0x76, 0x7A, 0xB8, 0x3E, 0x16, 0x70, 0xF5, 0xEB, 0x8B, - 0x33, 0x5A, 0xA9, 0x03, 0xED, 0x79, 0x0E, 0xAD, 0xBB, 0xC4, 0xF8, 0xDA, 0x93, - 0x53, 0x2A, 0xC4, 0xC9, 0x1A, 0xD1, 0xC3, 0x44, 0xD7, 0xC6, 0xD0, 0xC6, 0xAC, - 0x13, 0xE3, 0xB5, 0x73, 0x3A, 0xDF, 0x54, 0x15, 0xFB, 0xB4, 0x6B, 0x36, 0x39, - 0x18, 0xB5, 0x61, 0x12, 0xF0, 0x37, 0xAB, 0x81, 0x5F, 0x0C, 0xE7, 0xDF, 0xC1, - 0xC5, 0x5E, 0x99, 0x67, 0x85, 0xFF, 0xAD, 0xD6, 0x82, 0x09, 0x1F, 0x27, 0xE5, - 0x32, 0x52, 0x18, 0xEC, 0x35, 0x2F, 0x6C, 0xC9, 0xE6, 0x87, 0xCE, 0x30, 0xF6, - 0xDA, 0x04, 0x3F, 0xA5, 0x8A, 0x0C, 0xAE, 0x5B, 0xB0, 0xEC, 0x29, 0x9B, 0xEE, - 0x8F, 0x52, 0x1E, 0xE2, 0x56, 0x19, 0x45, 0x80, 0x3C, 0x02, 0x57, 0x5C, 0x52, - 0xD9, 0x02, 0x03, 0x01, 0x00, 0x01, 0xA3, 0x82, 0x0C, 0x05, 0x30, 0x82, 0x0C, - 0x01, 0x30, 0x0E, 0x06, 0x03, 0x55, 0x1D, 0x0F, 0x01, 0x01, 0xFF, 0x04, 0x04, - 0x03, 0x02, 0x05, 0xA0, 0x30, 0x81, 0x8A, 0x06, 0x08, 0x2B, 0x06, 0x01, 0x05, - 0x05, 0x07, 0x01, 0x01, 0x04, 0x7E, 0x30, 0x7C, 0x30, 0x42, 0x06, 0x08, 0x2B, - 0x06, 0x01, 0x05, 0x05, 0x07, 0x30, 0x02, 0x86, 0x36, 0x68, 0x74, 0x74, 0x70, - 0x3A, 0x2F, 0x2F, 0x73, 0x65, 0x63, 0x75, 0x72, 0x65, 0x2E, 0x67, 0x6C, 0x6F, - 0x62, 0x61, 0x6C, 0x73, 0x69, 0x67, 0x6E, 0x2E, 0x63, 0x6F, 0x6D, 0x2F, 0x63, - 0x61, 0x63, 0x65, 0x72, 0x74, 0x2F, 0x63, 0x6C, 0x6F, 0x75, 0x64, 0x73, 0x73, - 0x6C, 0x73, 0x68, 0x61, 0x32, 0x67, 0x33, 0x2E, 0x63, 0x72, 0x74, 0x30, 0x36, - 0x06, 0x08, 0x2B, 0x06, 0x01, 0x05, 0x05, 0x07, 0x30, 0x01, 0x86, 0x2A, 0x68, - 0x74, 0x74, 0x70, 0x3A, 0x2F, 0x2F, 0x6F, 0x63, 0x73, 0x70, 0x32, 0x2E, 0x67, - 0x6C, 0x6F, 0x62, 0x61, 0x6C, 0x73, 0x69, 0x67, 0x6E, 0x2E, 0x63, 0x6F, 0x6D, - 0x2F, 0x63, 0x6C, 0x6F, 0x75, 0x64, 0x73, 0x73, 0x6C, 0x73, 0x68, 0x61, 0x32, - 0x67, 0x33, 0x30, 0x56, 0x06, 0x03, 0x55, 0x1D, 0x20, 0x04, 0x4F, 0x30, 0x4D, - 0x30, 0x41, 0x06, 0x09, 0x2B, 0x06, 0x01, 0x04, 0x01, 0xA0, 0x32, 0x01, 0x14, - 0x30, 0x34, 0x30, 0x32, 0x06, 0x08, 0x2B, 0x06, 0x01, 0x05, 0x05, 0x07, 0x02, - 0x01, 0x16, 0x26, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3A, 0x2F, 0x2F, 0x77, 0x77, - 0x77, 0x2E, 0x67, 0x6C, 0x6F, 0x62, 0x61, 0x6C, 0x73, 0x69, 0x67, 0x6E, 0x2E, - 0x63, 0x6F, 0x6D, 0x2F, 0x72, 0x65, 0x70, 0x6F, 0x73, 0x69, 0x74, 0x6F, 0x72, - 0x79, 0x2F, 0x30, 0x08, 0x06, 0x06, 0x67, 0x81, 0x0C, 0x01, 0x02, 0x02, 0x30, - 0x09, 0x06, 0x03, 0x55, 0x1D, 0x13, 0x04, 0x02, 0x30, 0x00, 0x30, 0x82, 0x09, - 0x96, 0x06, 0x03, 0x55, 0x1D, 0x11, 0x04, 0x82, 0x09, 0x8D, 0x30, 0x82, 0x09, - 0x89, 0x82, 0x1B, 0x6A, 0x32, 0x2E, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x2E, - 0x67, 0x6C, 0x6F, 0x62, 0x61, 0x6C, 0x2E, 0x66, 0x61, 0x73, 0x74, 0x6C, 0x79, - 0x2E, 0x6E, 0x65, 0x74, 0x82, 0x0D, 0x2A, 0x2E, 0x61, 0x32, 0x70, 0x72, 0x65, - 0x73, 0x73, 0x65, 0x2E, 0x66, 0x72, 0x82, 0x19, 0x2A, 0x2E, 0x61, 0x64, 0x76, - 0x65, 0x6E, 0x74, 0x69, 0x73, 0x74, 0x62, 0x6F, 0x6F, 0x6B, 0x63, 0x65, 0x6E, - 0x74, 0x65, 0x72, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x14, 0x2A, 0x2E, 0x61, 0x70, - 0x69, 0x2E, 0x6C, 0x6F, 0x6C, 0x65, 0x73, 0x70, 0x6F, 0x72, 0x74, 0x73, 0x2E, - 0x63, 0x6F, 0x6D, 0x82, 0x0C, 0x2A, 0x2E, 0x62, 0x61, 0x61, 0x74, 0x63, 0x68, - 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x17, 0x2A, 0x2E, 0x62, 0x69, 0x6F, 0x74, 0x65, - 0x63, 0x68, 0x77, 0x65, 0x65, 0x6B, 0x62, 0x6F, 0x73, 0x74, 0x6F, 0x6E, 0x2E, - 0x63, 0x6F, 0x6D, 0x82, 0x10, 0x2A, 0x2E, 0x62, 0x6F, 0x78, 0x6F, 0x66, 0x73, - 0x74, 0x79, 0x6C, 0x65, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x0C, 0x2A, 0x2E, 0x63, - 0x61, 0x73, 0x70, 0x65, 0x72, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x11, 0x2A, 0x2E, - 0x63, 0x68, 0x61, 0x6B, 0x72, 0x61, 0x6C, 0x69, 0x6E, 0x75, 0x78, 0x2E, 0x6F, - 0x72, 0x67, 0x82, 0x18, 0x2A, 0x2E, 0x63, 0x6F, 0x6E, 0x76, 0x65, 0x72, 0x74, - 0x2E, 0x64, 0x73, 0x2E, 0x76, 0x65, 0x72, 0x69, 0x7A, 0x6F, 0x6E, 0x2E, 0x63, - 0x6F, 0x6D, 0x82, 0x15, 0x2A, 0x2E, 0x64, 0x65, 0x76, 0x73, 0x70, 0x61, 0x63, - 0x65, 0x73, 0x68, 0x69, 0x70, 0x2E, 0x63, 0x6F, 0x6D, 0x2E, 0x61, 0x75, 0x82, - 0x1B, 0x2A, 0x2E, 0x64, 0x65, 0x76, 0x73, 0x70, 0x61, 0x63, 0x65, 0x73, 0x68, - 0x69, 0x70, 0x69, 0x6E, 0x76, 0x65, 0x73, 0x74, 0x2E, 0x63, 0x6F, 0x6D, 0x2E, - 0x61, 0x75, 0x82, 0x0A, 0x2A, 0x2E, 0x65, 0x63, 0x68, 0x6C, 0x2E, 0x63, 0x6F, - 0x6D, 0x82, 0x0F, 0x2A, 0x2E, 0x66, 0x69, 0x6C, 0x65, 0x73, 0x74, 0x61, 0x63, - 0x6B, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x16, 0x2A, 0x2E, 0x66, 0x69, 0x6C, 0x65, - 0x73, 0x74, 0x61, 0x63, 0x6B, 0x2E, 0x6F, 0x6E, 0x65, 0x6D, 0x6F, 0x62, 0x2E, - 0x63, 0x6F, 0x6D, 0x82, 0x0D, 0x2A, 0x2E, 0x66, 0x69, 0x73, 0x2D, 0x73, 0x6B, - 0x69, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x0C, 0x2A, 0x2E, 0x66, 0x69, 0x73, 0x73, - 0x6B, 0x69, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x14, 0x2A, 0x2E, 0x66, 0x70, 0x2E, - 0x62, 0x72, 0x61, 0x6E, 0x64, 0x66, 0x6F, 0x6C, 0x64, 0x65, 0x72, 0x2E, 0x63, - 0x6F, 0x6D, 0x82, 0x0F, 0x2A, 0x2E, 0x66, 0x73, 0x2E, 0x65, 0x6E, 0x70, 0x6C, - 0x75, 0x67, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x0E, 0x2A, 0x2E, 0x66, 0x73, 0x2E, - 0x65, 0x6E, 0x70, 0x6C, 0x75, 0x67, 0x2E, 0x69, 0x6E, 0x82, 0x10, 0x2A, 0x2E, - 0x66, 0x73, 0x2E, 0x68, 0x65, 0x72, 0x6F, 0x69, 0x6E, 0x65, 0x2E, 0x63, 0x6F, - 0x6D, 0x82, 0x18, 0x2A, 0x2E, 0x66, 0x73, 0x2E, 0x6C, 0x65, 0x61, 0x72, 0x6E, - 0x7A, 0x69, 0x6C, 0x6C, 0x69, 0x6F, 0x6E, 0x63, 0x64, 0x6E, 0x2E, 0x63, 0x6F, - 0x6D, 0x82, 0x18, 0x2A, 0x2E, 0x66, 0x73, 0x2E, 0x6C, 0x6F, 0x63, 0x61, 0x6C, - 0x7A, 0x69, 0x6C, 0x6C, 0x69, 0x6F, 0x6E, 0x63, 0x64, 0x6E, 0x2E, 0x63, 0x6F, - 0x6D, 0x82, 0x12, 0x2A, 0x2E, 0x66, 0x73, 0x2E, 0x6D, 0x69, 0x6E, 0x64, 0x66, - 0x6C, 0x61, 0x73, 0x68, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x16, 0x2A, 0x2E, 0x66, - 0x73, 0x2E, 0x6F, 0x70, 0x73, 0x7A, 0x69, 0x6C, 0x6C, 0x69, 0x6F, 0x6E, 0x63, - 0x64, 0x6E, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x10, 0x2A, 0x2E, 0x66, 0x73, 0x2E, - 0x70, 0x69, 0x78, 0x76, 0x61, 0x6E, 0x61, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x15, - 0x2A, 0x2E, 0x66, 0x73, 0x2E, 0x71, 0x61, 0x7A, 0x69, 0x6C, 0x6C, 0x69, 0x6F, - 0x6E, 0x63, 0x64, 0x6E, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x17, 0x2A, 0x2E, 0x66, - 0x73, 0x2E, 0x74, 0x65, 0x73, 0x74, 0x7A, 0x69, 0x6C, 0x6C, 0x69, 0x6F, 0x6E, - 0x63, 0x64, 0x6E, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x09, 0x2A, 0x2E, 0x68, 0x61, - 0x78, 0x78, 0x2E, 0x73, 0x65, 0x82, 0x0D, 0x2A, 0x2E, 0x68, 0x6F, 0x6D, 0x65, - 0x61, 0x77, 0x61, 0x79, 0x2E, 0x6C, 0x6B, 0x82, 0x0F, 0x2A, 0x2E, 0x69, 0x64, - 0x61, 0x74, 0x61, 0x6C, 0x69, 0x6E, 0x6B, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x16, - 0x2A, 0x2E, 0x69, 0x64, 0x61, 0x74, 0x61, 0x6C, 0x69, 0x6E, 0x6B, 0x6D, 0x61, - 0x65, 0x73, 0x74, 0x72, 0x6F, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x11, 0x2A, 0x2E, - 0x69, 0x6D, 0x67, 0x2D, 0x74, 0x61, 0x62, 0x6F, 0x6F, 0x6C, 0x61, 0x2E, 0x63, - 0x6F, 0x6D, 0x82, 0x0F, 0x2A, 0x2E, 0x6A, 0x75, 0x6C, 0x69, 0x61, 0x6C, 0x61, - 0x6E, 0x67, 0x2E, 0x6F, 0x72, 0x67, 0x82, 0x10, 0x2A, 0x2E, 0x6B, 0x69, 0x6E, - 0x64, 0x73, 0x6E, 0x61, 0x63, 0x6B, 0x73, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x10, - 0x2A, 0x2E, 0x6B, 0x73, 0x73, 0x76, 0x61, 0x6E, 0x69, 0x6C, 0x6C, 0x61, 0x2E, - 0x63, 0x6F, 0x6D, 0x82, 0x0E, 0x2A, 0x2E, 0x6B, 0x73, 0x74, 0x63, 0x6F, 0x72, - 0x72, 0x61, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x10, 0x2A, 0x2E, 0x6B, 0x73, 0x74, - 0x76, 0x61, 0x6E, 0x69, 0x6C, 0x6C, 0x61, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x0C, - 0x2A, 0x2E, 0x6E, 0x65, 0x77, 0x73, 0x31, 0x32, 0x2E, 0x63, 0x6F, 0x6D, 0x82, - 0x1B, 0x2A, 0x2E, 0x70, 0x61, 0x72, 0x74, 0x69, 0x64, 0x65, 0x6E, 0x74, 0x69, - 0x66, 0x69, 0x65, 0x72, 0x2E, 0x73, 0x77, 0x69, 0x73, 0x63, 0x6F, 0x2E, 0x63, - 0x6F, 0x6D, 0x82, 0x13, 0x2A, 0x2E, 0x73, 0x68, 0x6F, 0x70, 0x72, 0x61, 0x63, - 0x68, 0x65, 0x6C, 0x7A, 0x6F, 0x65, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x0A, 0x2A, - 0x2E, 0x74, 0x61, 0x73, 0x74, 0x79, 0x2E, 0x63, 0x6F, 0x82, 0x0C, 0x2A, 0x2E, - 0x74, 0x65, 0x64, 0x63, 0x64, 0x6E, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x15, 0x2A, - 0x2E, 0x75, 0x70, 0x6C, 0x6F, 0x61, 0x64, 0x73, 0x2E, 0x66, 0x6F, 0x6C, 0x69, - 0x6F, 0x68, 0x64, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x14, 0x2A, 0x2E, 0x76, 0x6F, - 0x75, 0x63, 0x68, 0x65, 0x72, 0x63, 0x6F, 0x64, 0x65, 0x73, 0x2E, 0x63, 0x6F, - 0x2E, 0x75, 0x6B, 0x82, 0x0D, 0x2A, 0x2E, 0x77, 0x65, 0x61, 0x74, 0x68, 0x65, - 0x72, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x0D, 0x61, 0x2E, 0x69, 0x63, 0x61, 0x6E, - 0x76, 0x61, 0x73, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x0B, 0x61, 0x32, 0x70, 0x72, - 0x65, 0x73, 0x73, 0x65, 0x2E, 0x66, 0x72, 0x82, 0x17, 0x61, 0x64, 0x76, 0x65, - 0x6E, 0x74, 0x69, 0x73, 0x74, 0x62, 0x6F, 0x6F, 0x6B, 0x63, 0x65, 0x6E, 0x74, - 0x65, 0x72, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x11, 0x61, 0x70, 0x69, 0x2D, 0x6D, - 0x65, 0x72, 0x72, 0x79, 0x6A, 0x61, 0x6E, 0x65, 0x2E, 0x63, 0x6F, 0x6D, 0x82, - 0x12, 0x61, 0x70, 0x69, 0x73, 0x2E, 0x69, 0x64, 0x61, 0x74, 0x61, 0x6C, 0x69, - 0x76, 0x65, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x0F, 0x61, 0x70, 0x70, 0x2D, 0x61, - 0x70, 0x69, 0x2E, 0x74, 0x65, 0x64, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x12, 0x61, - 0x70, 0x70, 0x2E, 0x62, 0x69, 0x72, 0x63, 0x68, 0x62, 0x6F, 0x78, 0x2E, 0x63, - 0x6F, 0x2E, 0x75, 0x6B, 0x82, 0x0F, 0x61, 0x70, 0x70, 0x2E, 0x62, 0x69, 0x72, - 0x63, 0x68, 0x62, 0x6F, 0x78, 0x2E, 0x65, 0x73, 0x82, 0x1A, 0x61, 0x70, 0x70, - 0x2E, 0x73, 0x74, 0x61, 0x67, 0x69, 0x6E, 0x67, 0x2E, 0x62, 0x69, 0x72, 0x63, - 0x68, 0x62, 0x6F, 0x78, 0x2E, 0x63, 0x6F, 0x2E, 0x75, 0x6B, 0x82, 0x17, 0x61, - 0x70, 0x70, 0x2E, 0x73, 0x74, 0x61, 0x67, 0x69, 0x6E, 0x67, 0x2E, 0x62, 0x69, - 0x72, 0x63, 0x68, 0x62, 0x6F, 0x78, 0x2E, 0x65, 0x73, 0x82, 0x0A, 0x62, 0x61, - 0x61, 0x74, 0x63, 0x68, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x13, 0x62, 0x65, 0x72, - 0x6E, 0x61, 0x72, 0x64, 0x63, 0x6F, 0x6E, 0x74, 0x72, 0x6F, 0x6C, 0x73, 0x2E, - 0x63, 0x6F, 0x6D, 0x82, 0x15, 0x62, 0x69, 0x6F, 0x74, 0x65, 0x63, 0x68, 0x77, - 0x65, 0x65, 0x6B, 0x62, 0x6F, 0x73, 0x74, 0x6F, 0x6E, 0x2E, 0x63, 0x6F, 0x6D, - 0x82, 0x0E, 0x62, 0x6F, 0x78, 0x6F, 0x66, 0x73, 0x74, 0x79, 0x6C, 0x65, 0x2E, - 0x63, 0x6F, 0x6D, 0x82, 0x0A, 0x63, 0x61, 0x73, 0x70, 0x65, 0x72, 0x2E, 0x63, - 0x6F, 0x6D, 0x82, 0x0D, 0x63, 0x64, 0x6E, 0x2E, 0x69, 0x72, 0x73, 0x64, 0x6E, - 0x2E, 0x6E, 0x65, 0x74, 0x82, 0x0F, 0x63, 0x68, 0x61, 0x6B, 0x72, 0x61, 0x6C, - 0x69, 0x6E, 0x75, 0x78, 0x2E, 0x6F, 0x72, 0x67, 0x82, 0x13, 0x64, 0x65, 0x76, - 0x73, 0x70, 0x61, 0x63, 0x65, 0x73, 0x68, 0x69, 0x70, 0x2E, 0x63, 0x6F, 0x6D, - 0x2E, 0x61, 0x75, 0x82, 0x0B, 0x64, 0x69, 0x67, 0x69, 0x64, 0x61, 0x79, 0x2E, - 0x63, 0x6F, 0x6D, 0x82, 0x22, 0x64, 0x69, 0x67, 0x69, 0x74, 0x61, 0x6C, 0x4C, - 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x2E, 0x62, 0x65, 0x72, 0x6E, 0x61, 0x72, - 0x64, 0x63, 0x6F, 0x6E, 0x74, 0x72, 0x6F, 0x6C, 0x73, 0x2E, 0x63, 0x6F, 0x6D, - 0x82, 0x14, 0x64, 0x72, 0x77, 0x70, 0x2E, 0x73, 0x74, 0x61, 0x67, 0x69, 0x6E, - 0x67, 0x2E, 0x6D, 0x6F, 0x6F, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x08, 0x65, 0x63, - 0x68, 0x6C, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x14, 0x66, 0x69, 0x6C, 0x65, 0x73, - 0x74, 0x61, 0x63, 0x6B, 0x2E, 0x6F, 0x6E, 0x65, 0x6D, 0x6F, 0x62, 0x2E, 0x63, - 0x6F, 0x6D, 0x82, 0x0D, 0x66, 0x73, 0x2E, 0x65, 0x6E, 0x70, 0x6C, 0x75, 0x67, - 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x16, 0x66, 0x73, 0x2E, 0x6C, 0x65, 0x61, 0x72, - 0x6E, 0x7A, 0x69, 0x6C, 0x6C, 0x69, 0x6F, 0x6E, 0x63, 0x64, 0x6E, 0x2E, 0x63, - 0x6F, 0x6D, 0x82, 0x16, 0x66, 0x73, 0x2E, 0x6C, 0x6F, 0x63, 0x61, 0x6C, 0x7A, - 0x69, 0x6C, 0x6C, 0x69, 0x6F, 0x6E, 0x63, 0x64, 0x6E, 0x2E, 0x63, 0x6F, 0x6D, - 0x82, 0x14, 0x66, 0x73, 0x2E, 0x6F, 0x70, 0x73, 0x7A, 0x69, 0x6C, 0x6C, 0x69, - 0x6F, 0x6E, 0x63, 0x64, 0x6E, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x13, 0x66, 0x73, - 0x2E, 0x71, 0x61, 0x7A, 0x69, 0x6C, 0x6C, 0x69, 0x6F, 0x6E, 0x63, 0x64, 0x6E, - 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x15, 0x66, 0x73, 0x2E, 0x74, 0x65, 0x73, 0x74, - 0x7A, 0x69, 0x6C, 0x6C, 0x69, 0x6F, 0x6E, 0x63, 0x64, 0x6E, 0x2E, 0x63, 0x6F, - 0x6D, 0x82, 0x0B, 0x68, 0x6F, 0x6D, 0x65, 0x61, 0x77, 0x61, 0x79, 0x2E, 0x6C, - 0x6B, 0x82, 0x12, 0x69, 0x6D, 0x67, 0x2E, 0x74, 0x72, 0x69, 0x67, 0x67, 0x65, - 0x72, 0x6D, 0x61, 0x69, 0x6C, 0x2E, 0x69, 0x6F, 0x82, 0x0E, 0x6B, 0x69, 0x6E, - 0x64, 0x73, 0x6E, 0x61, 0x63, 0x6B, 0x73, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x0E, - 0x6B, 0x73, 0x73, 0x76, 0x61, 0x6E, 0x69, 0x6C, 0x6C, 0x61, 0x2E, 0x63, 0x6F, - 0x6D, 0x82, 0x0C, 0x6B, 0x73, 0x74, 0x63, 0x6F, 0x72, 0x72, 0x61, 0x2E, 0x63, - 0x6F, 0x6D, 0x82, 0x0D, 0x6D, 0x65, 0x6E, 0x75, 0x2E, 0x74, 0x72, 0x65, 0x65, - 0x7A, 0x2E, 0x69, 0x6F, 0x82, 0x17, 0x6D, 0x6F, 0x62, 0x69, 0x6C, 0x65, 0x61, - 0x70, 0x69, 0x2E, 0x69, 0x64, 0x61, 0x74, 0x61, 0x6C, 0x69, 0x6E, 0x6B, 0x2E, - 0x63, 0x6F, 0x6D, 0x82, 0x0A, 0x6E, 0x65, 0x77, 0x73, 0x31, 0x32, 0x2E, 0x63, - 0x6F, 0x6D, 0x82, 0x0B, 0x6F, 0x6D, 0x6E, 0x69, 0x67, 0x6F, 0x6E, 0x2E, 0x63, - 0x6F, 0x6D, 0x82, 0x0E, 0x6F, 0x72, 0x65, 0x69, 0x6C, 0x6C, 0x79, 0x2E, 0x72, - 0x65, 0x76, 0x69, 0x65, 0x77, 0x82, 0x11, 0x70, 0x6F, 0x70, 0x79, 0x6F, 0x75, - 0x72, 0x62, 0x75, 0x62, 0x62, 0x6C, 0x65, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x18, - 0x70, 0x72, 0x6F, 0x64, 0x2E, 0x62, 0x65, 0x72, 0x6E, 0x61, 0x72, 0x64, 0x63, - 0x6F, 0x6E, 0x74, 0x72, 0x6F, 0x6C, 0x73, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x18, - 0x72, 0x65, 0x6C, 0x65, 0x61, 0x73, 0x65, 0x2D, 0x70, 0x72, 0x69, 0x6D, 0x65, - 0x2E, 0x73, 0x70, 0x6F, 0x6B, 0x65, 0x6F, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x19, - 0x72, 0x65, 0x70, 0x6F, 0x73, 0x69, 0x74, 0x6F, 0x72, 0x69, 0x65, 0x73, 0x2E, - 0x73, 0x65, 0x6E, 0x73, 0x75, 0x61, 0x70, 0x70, 0x2E, 0x6F, 0x72, 0x67, 0x82, - 0x0C, 0x72, 0x6C, 0x2E, 0x74, 0x61, 0x6C, 0x69, 0x73, 0x2E, 0x63, 0x6F, 0x6D, - 0x82, 0x11, 0x73, 0x68, 0x6F, 0x70, 0x72, 0x61, 0x63, 0x68, 0x65, 0x6C, 0x7A, - 0x6F, 0x65, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x0F, 0x73, 0x74, 0x61, 0x67, 0x69, - 0x6E, 0x67, 0x2E, 0x6D, 0x6F, 0x6F, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x14, 0x73, - 0x74, 0x61, 0x74, 0x69, 0x63, 0x2E, 0x70, 0x6C, 0x75, 0x6D, 0x63, 0x61, 0x63, - 0x68, 0x65, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x14, 0x73, 0x74, 0x61, 0x79, 0x69, - 0x6E, 0x67, 0x61, 0x6C, 0x69, 0x76, 0x65, 0x2E, 0x6D, 0x73, 0x66, 0x2E, 0x6F, - 0x72, 0x67, 0x82, 0x08, 0x74, 0x61, 0x73, 0x74, 0x79, 0x2E, 0x63, 0x6F, 0x82, - 0x0C, 0x74, 0x6F, 0x70, 0x73, 0x70, 0x65, 0x65, 0x64, 0x2E, 0x63, 0x6F, 0x6D, - 0x82, 0x13, 0x75, 0x70, 0x6C, 0x6F, 0x61, 0x64, 0x73, 0x2E, 0x66, 0x6F, 0x6C, - 0x69, 0x6F, 0x68, 0x64, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x1A, 0x75, 0x73, 0x2D, - 0x65, 0x75, 0x2E, 0x66, 0x69, 0x6C, 0x65, 0x73, 0x74, 0x61, 0x63, 0x6B, 0x63, - 0x6F, 0x6E, 0x74, 0x65, 0x6E, 0x74, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x12, 0x76, - 0x6F, 0x75, 0x63, 0x68, 0x65, 0x72, 0x63, 0x6F, 0x64, 0x65, 0x73, 0x2E, 0x63, - 0x6F, 0x2E, 0x75, 0x6B, 0x82, 0x0B, 0x77, 0x65, 0x61, 0x74, 0x68, 0x65, 0x72, - 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x13, 0x77, 0x6F, 0x6D, 0x65, 0x6E, 0x73, 0x68, - 0x65, 0x61, 0x6C, 0x74, 0x68, 0x2D, 0x6A, 0x70, 0x2E, 0x63, 0x6F, 0x6D, 0x82, - 0x19, 0x77, 0x6F, 0x72, 0x6B, 0x65, 0x72, 0x62, 0x65, 0x65, 0x2E, 0x73, 0x74, - 0x61, 0x67, 0x69, 0x6E, 0x67, 0x2E, 0x6D, 0x6F, 0x6F, 0x2E, 0x63, 0x6F, 0x6D, - 0x82, 0x0A, 0x77, 0x77, 0x77, 0x2E, 0x61, 0x67, 0x66, 0x2E, 0x64, 0x6B, 0x82, - 0x14, 0x77, 0x77, 0x77, 0x2E, 0x61, 0x76, 0x65, 0x6E, 0x69, 0x72, 0x2D, 0x73, - 0x75, 0x69, 0x73, 0x73, 0x65, 0x2E, 0x63, 0x68, 0x82, 0x11, 0x77, 0x77, 0x77, - 0x2E, 0x63, 0x61, 0x6E, 0x73, 0x74, 0x61, 0x72, 0x2E, 0x63, 0x6F, 0x2E, 0x6E, - 0x7A, 0x82, 0x15, 0x77, 0x77, 0x77, 0x2E, 0x63, 0x61, 0x6E, 0x73, 0x74, 0x61, - 0x72, 0x62, 0x6C, 0x75, 0x65, 0x2E, 0x63, 0x6F, 0x2E, 0x6E, 0x7A, 0x82, 0x16, - 0x77, 0x77, 0x77, 0x2E, 0x63, 0x61, 0x6E, 0x73, 0x74, 0x61, 0x72, 0x62, 0x6C, - 0x75, 0x65, 0x2E, 0x63, 0x6F, 0x6D, 0x2E, 0x61, 0x75, 0x82, 0x1D, 0x77, 0x77, - 0x77, 0x2E, 0x63, 0x68, 0x61, 0x6D, 0x70, 0x69, 0x6F, 0x6E, 0x73, 0x68, 0x6F, - 0x63, 0x6B, 0x65, 0x79, 0x6C, 0x65, 0x61, 0x67, 0x75, 0x65, 0x2E, 0x6E, 0x65, - 0x74, 0x82, 0x0F, 0x77, 0x77, 0x77, 0x2E, 0x65, 0x78, 0x74, 0x65, 0x72, 0x72, - 0x6F, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x0C, 0x77, 0x77, 0x77, 0x2E, 0x65, 0x7A, - 0x75, 0x70, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x0B, 0x77, 0x77, 0x77, 0x2E, 0x65, - 0x7A, 0x75, 0x70, 0x2E, 0x64, 0x65, 0x82, 0x0B, 0x77, 0x77, 0x77, 0x2E, 0x65, - 0x7A, 0x75, 0x70, 0x2E, 0x65, 0x75, 0x82, 0x0B, 0x77, 0x77, 0x77, 0x2E, 0x65, - 0x7A, 0x75, 0x70, 0x2E, 0x6E, 0x6C, 0x82, 0x11, 0x77, 0x77, 0x77, 0x2E, 0x66, - 0x72, 0x61, 0x6E, 0x6B, 0x62, 0x6F, 0x64, 0x79, 0x2E, 0x63, 0x6F, 0x6D, 0x82, - 0x0D, 0x77, 0x77, 0x77, 0x2E, 0x67, 0x6C, 0x6F, 0x73, 0x73, 0x79, 0x2E, 0x63, - 0x6F, 0x82, 0x0F, 0x77, 0x77, 0x77, 0x2E, 0x67, 0x6F, 0x6C, 0x64, 0x63, 0x75, - 0x70, 0x2E, 0x6F, 0x72, 0x67, 0x82, 0x0F, 0x77, 0x77, 0x77, 0x2E, 0x69, 0x63, - 0x61, 0x6E, 0x76, 0x61, 0x73, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x0D, 0x77, 0x77, - 0x77, 0x2E, 0x6D, 0x6F, 0x6E, 0x69, 0x6E, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x16, - 0x77, 0x77, 0x77, 0x2E, 0x6F, 0x64, 0x65, 0x6E, 0x73, 0x65, 0x2D, 0x6D, 0x61, - 0x72, 0x63, 0x69, 0x70, 0x61, 0x6E, 0x2E, 0x64, 0x6B, 0x82, 0x15, 0x77, 0x77, - 0x77, 0x2E, 0x6F, 0x6E, 0x65, 0x63, 0x6C, 0x69, 0x63, 0x6B, 0x64, 0x72, 0x69, - 0x76, 0x65, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x12, 0x77, 0x77, 0x77, 0x2E, 0x6F, - 0x72, 0x65, 0x69, 0x6C, 0x6C, 0x79, 0x2E, 0x72, 0x65, 0x76, 0x69, 0x65, 0x77, - 0x82, 0x15, 0x77, 0x77, 0x77, 0x2E, 0x70, 0x6F, 0x70, 0x79, 0x6F, 0x75, 0x72, - 0x62, 0x75, 0x62, 0x62, 0x6C, 0x65, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x0E, 0x77, - 0x77, 0x77, 0x2E, 0x72, 0x61, 0x77, 0x6E, 0x65, 0x74, 0x2E, 0x63, 0x6F, 0x6D, - 0x82, 0x0E, 0x77, 0x77, 0x77, 0x2E, 0x73, 0x70, 0x6F, 0x6B, 0x65, 0x6F, 0x2E, - 0x63, 0x6F, 0x6D, 0x82, 0x10, 0x77, 0x77, 0x77, 0x2E, 0x74, 0x65, 0x61, 0x72, - 0x73, 0x68, 0x65, 0x65, 0x74, 0x2E, 0x63, 0x6F, 0x82, 0x10, 0x77, 0x77, 0x77, - 0x2E, 0x74, 0x6F, 0x70, 0x73, 0x70, 0x65, 0x65, 0x64, 0x2E, 0x63, 0x6F, 0x6D, - 0x82, 0x16, 0x77, 0x77, 0x77, 0x2E, 0x77, 0x68, 0x69, 0x74, 0x65, 0x6B, 0x65, - 0x79, 0x76, 0x69, 0x6C, 0x6C, 0x61, 0x73, 0x2E, 0x63, 0x6F, 0x6D, 0x30, 0x1D, - 0x06, 0x03, 0x55, 0x1D, 0x25, 0x04, 0x16, 0x30, 0x14, 0x06, 0x08, 0x2B, 0x06, - 0x01, 0x05, 0x05, 0x07, 0x03, 0x01, 0x06, 0x08, 0x2B, 0x06, 0x01, 0x05, 0x05, - 0x07, 0x03, 0x02, 0x30, 0x1D, 0x06, 0x03, 0x55, 0x1D, 0x0E, 0x04, 0x16, 0x04, - 0x14, 0xA8, 0x29, 0xFD, 0xA9, 0xA5, 0x1A, 0x1C, 0x37, 0x0B, 0x20, 0x3B, 0x98, - 0xB7, 0x25, 0x39, 0xCC, 0xE5, 0x2F, 0xF4, 0x94, 0x30, 0x1F, 0x06, 0x03, 0x55, - 0x1D, 0x23, 0x04, 0x18, 0x30, 0x16, 0x80, 0x14, 0xA9, 0x2B, 0x87, 0xE1, 0xCE, - 0x24, 0x47, 0x3B, 0x1B, 0xBF, 0xCF, 0x85, 0x37, 0x02, 0x55, 0x9D, 0x0D, 0x94, - 0x58, 0xE6, 0x30, 0x82, 0x01, 0x04, 0x06, 0x0A, 0x2B, 0x06, 0x01, 0x04, 0x01, - 0xD6, 0x79, 0x02, 0x04, 0x02, 0x04, 0x81, 0xF5, 0x04, 0x81, 0xF2, 0x00, 0xF0, - 0x00, 0x77, 0x00, 0xA4, 0xB9, 0x09, 0x90, 0xB4, 0x18, 0x58, 0x14, 0x87, 0xBB, - 0x13, 0xA2, 0xCC, 0x67, 0x70, 0x0A, 0x3C, 0x35, 0x98, 0x04, 0xF9, 0x1B, 0xDF, - 0xB8, 0xE3, 0x77, 0xCD, 0x0E, 0xC8, 0x0D, 0xDC, 0x10, 0x00, 0x00, 0x01, 0x66, - 0x9C, 0xC8, 0xE7, 0x38, 0x00, 0x00, 0x04, 0x03, 0x00, 0x48, 0x30, 0x46, 0x02, - 0x21, 0x00, 0xD9, 0x58, 0x6E, 0xFC, 0x4C, 0x3C, 0xAF, 0xF9, 0x5B, 0x7F, 0xDA, - 0x54, 0x95, 0xAF, 0xCF, 0xB3, 0x57, 0xB9, 0x56, 0x2C, 0xE8, 0xE0, 0xB1, 0x20, - 0x9B, 0xCB, 0x75, 0xAC, 0x4E, 0x54, 0xE9, 0x9D, 0x02, 0x21, 0x00, 0xE8, 0xF0, - 0xC0, 0x49, 0x23, 0x8E, 0x3D, 0x9B, 0xA5, 0x87, 0xA3, 0xBE, 0x6C, 0x21, 0x62, - 0xBB, 0xD2, 0x44, 0x5C, 0xE4, 0x7A, 0xCC, 0x46, 0x26, 0x04, 0x19, 0xA4, 0x2D, - 0x9B, 0x1C, 0x5D, 0x3A, 0x00, 0x75, 0x00, 0x6F, 0x53, 0x76, 0xAC, 0x31, 0xF0, - 0x31, 0x19, 0xD8, 0x99, 0x00, 0xA4, 0x51, 0x15, 0xFF, 0x77, 0x15, 0x1C, 0x11, - 0xD9, 0x02, 0xC1, 0x00, 0x29, 0x06, 0x8D, 0xB2, 0x08, 0x9A, 0x37, 0xD9, 0x13, - 0x00, 0x00, 0x01, 0x66, 0x9C, 0xC8, 0xE6, 0x20, 0x00, 0x00, 0x04, 0x03, 0x00, - 0x46, 0x30, 0x44, 0x02, 0x20, 0x14, 0xC8, 0x9F, 0xAC, 0x27, 0x48, 0xBE, 0x4D, - 0x0E, 0xC3, 0x26, 0x2E, 0x34, 0xCA, 0x38, 0xBA, 0x11, 0x3A, 0x68, 0x71, 0x88, - 0xEB, 0x24, 0x26, 0x59, 0x3E, 0xAC, 0xA8, 0x63, 0xCC, 0x8A, 0x0A, 0x02, 0x20, - 0x0F, 0x22, 0xBF, 0x0D, 0x1F, 0x8A, 0x8D, 0x1D, 0x91, 0x33, 0x3A, 0x40, 0xE4, - 0x23, 0x78, 0xFA, 0x22, 0xF5, 0x9B, 0xCB, 0x04, 0x4F, 0x53, 0x2D, 0x20, 0x75, - 0x2F, 0x76, 0x8A, 0xB1, 0xCD, 0x9D, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, - 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x0B, 0x05, 0x00, 0x03, 0x82, 0x01, 0x01, 0x00, - 0x03, 0x41, 0x0F, 0xF3, 0xA6, 0x62, 0xA2, 0xE5, 0xB4, 0x8D, 0xA8, 0x08, 0x71, - 0x7B, 0xB3, 0xE3, 0x51, 0x61, 0x0D, 0xC0, 0x67, 0x6C, 0x3C, 0x9C, 0x00, 0x0B, - 0x63, 0x77, 0xB6, 0xB6, 0x11, 0x67, 0x77, 0xA5, 0xE1, 0x49, 0xE0, 0x7F, 0xB7, - 0x1D, 0x61, 0xFB, 0x83, 0x9C, 0x83, 0x42, 0xE9, 0x31, 0xCA, 0x51, 0xE3, 0xC1, - 0xBD, 0x9B, 0x2F, 0xB5, 0x35, 0x05, 0x72, 0x7F, 0x40, 0xA6, 0x7C, 0xC9, 0xF1, - 0x59, 0xA7, 0x15, 0xB8, 0x12, 0xDA, 0xF8, 0xCE, 0x83, 0x61, 0xFC, 0x47, 0x96, - 0x9E, 0x74, 0xFE, 0xCD, 0xE4, 0x61, 0x92, 0xF2, 0x2E, 0x0C, 0x08, 0x4B, 0x60, - 0x2D, 0xF6, 0x50, 0x07, 0x83, 0xCA, 0xAF, 0xB9, 0x41, 0x33, 0x4A, 0x3E, 0x84, - 0xC7, 0x73, 0xC6, 0x1F, 0xFF, 0x7A, 0xDF, 0xAE, 0x47, 0x25, 0x32, 0xEB, 0xC0, - 0x43, 0x0C, 0xA6, 0x23, 0x13, 0x46, 0xC3, 0xFA, 0x44, 0xEA, 0x20, 0xEA, 0xCB, - 0x18, 0x17, 0x00, 0xB6, 0xE7, 0x6D, 0x8A, 0x14, 0x8C, 0x6A, 0xCA, 0x88, 0x4C, - 0xDA, 0xA8, 0xB9, 0x08, 0xAF, 0x39, 0xEE, 0xCF, 0xD7, 0xF7, 0x32, 0xC0, 0xF4, - 0xCF, 0x4E, 0x22, 0x38, 0xF7, 0xAF, 0xAE, 0x7D, 0x58, 0x5F, 0xA5, 0x2D, 0x4D, - 0xBB, 0x86, 0x10, 0xB3, 0x93, 0x62, 0x64, 0x27, 0xBF, 0xB1, 0xBB, 0x8F, 0x9F, - 0xFC, 0x07, 0x3C, 0x4B, 0x16, 0x7A, 0x84, 0x5E, 0xAF, 0xAD, 0x57, 0x9C, 0xFF, - 0x7A, 0xA7, 0xE0, 0x90, 0x89, 0x1C, 0xE8, 0xE5, 0x11, 0xF7, 0xB6, 0xDC, 0xCD, - 0x5E, 0xF7, 0x30, 0xA2, 0x2E, 0x67, 0x6D, 0x4A, 0x70, 0x26, 0xEA, 0xCD, 0x27, - 0x70, 0x77, 0x54, 0x57, 0x09, 0x03, 0x56, 0x4A, 0x33, 0x60, 0x00, 0x27, 0xFE, - 0xA7, 0xD7, 0xA9, 0xC4, 0xEC, 0x17, 0x17, 0x8D, 0x87, 0x70, 0x6B, 0x48, 0x88, - 0x61, 0x54, 0x4A, 0x2B, 0xB7, 0x6A, 0x12, 0x08, 0xFB, + 0x30, 0x82, 0x0F, 0x5B, 0x30, 0x82, 0x0E, 0x43, 0xA0, 0x03, 0x02, 0x01, + 0x02, 0x02, 0x0C, 0x08, 0x77, 0x99, 0x2C, 0x6B, 0x67, 0xE1, 0x18, 0xD6, + 0x66, 0x66, 0x9E, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, + 0x0D, 0x01, 0x01, 0x0B, 0x05, 0x00, 0x30, 0x57, 0x31, 0x0B, 0x30, 0x09, + 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x42, 0x45, 0x31, 0x19, 0x30, + 0x17, 0x06, 0x03, 0x55, 0x04, 0x0A, 0x13, 0x10, 0x47, 0x6C, 0x6F, 0x62, + 0x61, 0x6C, 0x53, 0x69, 0x67, 0x6E, 0x20, 0x6E, 0x76, 0x2D, 0x73, 0x61, + 0x31, 0x2D, 0x30, 0x2B, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x24, 0x47, + 0x6C, 0x6F, 0x62, 0x61, 0x6C, 0x53, 0x69, 0x67, 0x6E, 0x20, 0x43, 0x6C, + 0x6F, 0x75, 0x64, 0x53, 0x53, 0x4C, 0x20, 0x43, 0x41, 0x20, 0x2D, 0x20, + 0x53, 0x48, 0x41, 0x32, 0x35, 0x36, 0x20, 0x2D, 0x20, 0x47, 0x33, 0x30, + 0x1E, 0x17, 0x0D, 0x31, 0x38, 0x31, 0x30, 0x32, 0x32, 0x31, 0x37, 0x31, + 0x38, 0x32, 0x31, 0x5A, 0x17, 0x0D, 0x31, 0x39, 0x30, 0x33, 0x32, 0x31, + 0x31, 0x33, 0x34, 0x33, 0x34, 0x34, 0x5A, 0x30, 0x77, 0x31, 0x0B, 0x30, + 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x55, 0x53, 0x31, 0x13, + 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x08, 0x0C, 0x0A, 0x43, 0x61, 0x6C, + 0x69, 0x66, 0x6F, 0x72, 0x6E, 0x69, 0x61, 0x31, 0x16, 0x30, 0x14, 0x06, + 0x03, 0x55, 0x04, 0x07, 0x0C, 0x0D, 0x53, 0x61, 0x6E, 0x20, 0x46, 0x72, + 0x61, 0x6E, 0x63, 0x69, 0x73, 0x63, 0x6F, 0x31, 0x15, 0x30, 0x13, 0x06, + 0x03, 0x55, 0x04, 0x0A, 0x0C, 0x0C, 0x46, 0x61, 0x73, 0x74, 0x6C, 0x79, + 0x2C, 0x20, 0x49, 0x6E, 0x63, 0x2E, 0x31, 0x24, 0x30, 0x22, 0x06, 0x03, + 0x55, 0x04, 0x03, 0x0C, 0x1B, 0x6A, 0x32, 0x2E, 0x73, 0x68, 0x61, 0x72, + 0x65, 0x64, 0x2E, 0x67, 0x6C, 0x6F, 0x62, 0x61, 0x6C, 0x2E, 0x66, 0x61, + 0x73, 0x74, 0x6C, 0x79, 0x2E, 0x6E, 0x65, 0x74, 0x30, 0x82, 0x01, 0x22, + 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, + 0x01, 0x05, 0x00, 0x03, 0x82, 0x01, 0x0F, 0x00, 0x30, 0x82, 0x01, 0x0A, + 0x02, 0x82, 0x01, 0x01, 0x00, 0xC2, 0x72, 0xA2, 0x4A, 0xEF, 0x26, 0x42, + 0xD7, 0x85, 0x74, 0xC9, 0xB4, 0x9F, 0xE3, 0x31, 0xD1, 0x40, 0x77, 0xC9, + 0x4B, 0x4D, 0xFE, 0xC8, 0x75, 0xF3, 0x32, 0x76, 0xAD, 0xF9, 0x08, 0x22, + 0x9E, 0xFA, 0x2F, 0xFE, 0xEC, 0x6C, 0xC4, 0xF5, 0x1F, 0x70, 0xC9, 0x8F, + 0x07, 0x48, 0x31, 0xAD, 0x75, 0x18, 0xFC, 0x06, 0x5A, 0x4F, 0xDD, 0xFD, + 0x05, 0x39, 0x6F, 0x22, 0xF9, 0xAD, 0x62, 0x1A, 0x9E, 0xA6, 0x16, 0x48, + 0x75, 0x8F, 0xB8, 0x07, 0x18, 0x25, 0x1A, 0x87, 0x30, 0xB0, 0x3C, 0x6F, + 0xE0, 0x9D, 0x90, 0x63, 0x2A, 0x16, 0x1F, 0x0D, 0x10, 0xFC, 0x06, 0x7E, + 0xEA, 0x51, 0xE2, 0xB0, 0x6D, 0x42, 0x4C, 0x2C, 0x59, 0xF4, 0x6B, 0x99, + 0x3E, 0x82, 0x1D, 0x08, 0x04, 0x2F, 0xA0, 0x63, 0x3C, 0xAA, 0x0E, 0xE1, + 0x5D, 0x67, 0x2D, 0xB3, 0xF4, 0x15, 0xD6, 0x16, 0x4E, 0xAA, 0x91, 0x45, + 0x6B, 0xC5, 0xA6, 0xED, 0x83, 0xAF, 0xF1, 0xD7, 0x42, 0x5E, 0x9B, 0xC8, + 0x39, 0x0C, 0x06, 0x76, 0x7A, 0xB8, 0x3E, 0x16, 0x70, 0xF5, 0xEB, 0x8B, + 0x33, 0x5A, 0xA9, 0x03, 0xED, 0x79, 0x0E, 0xAD, 0xBB, 0xC4, 0xF8, 0xDA, + 0x93, 0x53, 0x2A, 0xC4, 0xC9, 0x1A, 0xD1, 0xC3, 0x44, 0xD7, 0xC6, 0xD0, + 0xC6, 0xAC, 0x13, 0xE3, 0xB5, 0x73, 0x3A, 0xDF, 0x54, 0x15, 0xFB, 0xB4, + 0x6B, 0x36, 0x39, 0x18, 0xB5, 0x61, 0x12, 0xF0, 0x37, 0xAB, 0x81, 0x5F, + 0x0C, 0xE7, 0xDF, 0xC1, 0xC5, 0x5E, 0x99, 0x67, 0x85, 0xFF, 0xAD, 0xD6, + 0x82, 0x09, 0x1F, 0x27, 0xE5, 0x32, 0x52, 0x18, 0xEC, 0x35, 0x2F, 0x6C, + 0xC9, 0xE6, 0x87, 0xCE, 0x30, 0xF6, 0xDA, 0x04, 0x3F, 0xA5, 0x8A, 0x0C, + 0xAE, 0x5B, 0xB0, 0xEC, 0x29, 0x9B, 0xEE, 0x8F, 0x52, 0x1E, 0xE2, 0x56, + 0x19, 0x45, 0x80, 0x3C, 0x02, 0x57, 0x5C, 0x52, 0xD9, 0x02, 0x03, 0x01, + 0x00, 0x01, 0xA3, 0x82, 0x0C, 0x05, 0x30, 0x82, 0x0C, 0x01, 0x30, 0x0E, + 0x06, 0x03, 0x55, 0x1D, 0x0F, 0x01, 0x01, 0xFF, 0x04, 0x04, 0x03, 0x02, + 0x05, 0xA0, 0x30, 0x81, 0x8A, 0x06, 0x08, 0x2B, 0x06, 0x01, 0x05, 0x05, + 0x07, 0x01, 0x01, 0x04, 0x7E, 0x30, 0x7C, 0x30, 0x42, 0x06, 0x08, 0x2B, + 0x06, 0x01, 0x05, 0x05, 0x07, 0x30, 0x02, 0x86, 0x36, 0x68, 0x74, 0x74, + 0x70, 0x3A, 0x2F, 0x2F, 0x73, 0x65, 0x63, 0x75, 0x72, 0x65, 0x2E, 0x67, + 0x6C, 0x6F, 0x62, 0x61, 0x6C, 0x73, 0x69, 0x67, 0x6E, 0x2E, 0x63, 0x6F, + 0x6D, 0x2F, 0x63, 0x61, 0x63, 0x65, 0x72, 0x74, 0x2F, 0x63, 0x6C, 0x6F, + 0x75, 0x64, 0x73, 0x73, 0x6C, 0x73, 0x68, 0x61, 0x32, 0x67, 0x33, 0x2E, + 0x63, 0x72, 0x74, 0x30, 0x36, 0x06, 0x08, 0x2B, 0x06, 0x01, 0x05, 0x05, + 0x07, 0x30, 0x01, 0x86, 0x2A, 0x68, 0x74, 0x74, 0x70, 0x3A, 0x2F, 0x2F, + 0x6F, 0x63, 0x73, 0x70, 0x32, 0x2E, 0x67, 0x6C, 0x6F, 0x62, 0x61, 0x6C, + 0x73, 0x69, 0x67, 0x6E, 0x2E, 0x63, 0x6F, 0x6D, 0x2F, 0x63, 0x6C, 0x6F, + 0x75, 0x64, 0x73, 0x73, 0x6C, 0x73, 0x68, 0x61, 0x32, 0x67, 0x33, 0x30, + 0x56, 0x06, 0x03, 0x55, 0x1D, 0x20, 0x04, 0x4F, 0x30, 0x4D, 0x30, 0x41, + 0x06, 0x09, 0x2B, 0x06, 0x01, 0x04, 0x01, 0xA0, 0x32, 0x01, 0x14, 0x30, + 0x34, 0x30, 0x32, 0x06, 0x08, 0x2B, 0x06, 0x01, 0x05, 0x05, 0x07, 0x02, + 0x01, 0x16, 0x26, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3A, 0x2F, 0x2F, 0x77, + 0x77, 0x77, 0x2E, 0x67, 0x6C, 0x6F, 0x62, 0x61, 0x6C, 0x73, 0x69, 0x67, + 0x6E, 0x2E, 0x63, 0x6F, 0x6D, 0x2F, 0x72, 0x65, 0x70, 0x6F, 0x73, 0x69, + 0x74, 0x6F, 0x72, 0x79, 0x2F, 0x30, 0x08, 0x06, 0x06, 0x67, 0x81, 0x0C, + 0x01, 0x02, 0x02, 0x30, 0x09, 0x06, 0x03, 0x55, 0x1D, 0x13, 0x04, 0x02, + 0x30, 0x00, 0x30, 0x82, 0x09, 0x96, 0x06, 0x03, 0x55, 0x1D, 0x11, 0x04, + 0x82, 0x09, 0x8D, 0x30, 0x82, 0x09, 0x89, 0x82, 0x1B, 0x6A, 0x32, 0x2E, + 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x2E, 0x67, 0x6C, 0x6F, 0x62, 0x61, + 0x6C, 0x2E, 0x66, 0x61, 0x73, 0x74, 0x6C, 0x79, 0x2E, 0x6E, 0x65, 0x74, + 0x82, 0x0D, 0x2A, 0x2E, 0x61, 0x32, 0x70, 0x72, 0x65, 0x73, 0x73, 0x65, + 0x2E, 0x66, 0x72, 0x82, 0x19, 0x2A, 0x2E, 0x61, 0x64, 0x76, 0x65, 0x6E, + 0x74, 0x69, 0x73, 0x74, 0x62, 0x6F, 0x6F, 0x6B, 0x63, 0x65, 0x6E, 0x74, + 0x65, 0x72, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x14, 0x2A, 0x2E, 0x61, 0x70, + 0x69, 0x2E, 0x6C, 0x6F, 0x6C, 0x65, 0x73, 0x70, 0x6F, 0x72, 0x74, 0x73, + 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x0C, 0x2A, 0x2E, 0x62, 0x61, 0x61, 0x74, + 0x63, 0x68, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x17, 0x2A, 0x2E, 0x62, 0x69, + 0x6F, 0x74, 0x65, 0x63, 0x68, 0x77, 0x65, 0x65, 0x6B, 0x62, 0x6F, 0x73, + 0x74, 0x6F, 0x6E, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x10, 0x2A, 0x2E, 0x62, + 0x6F, 0x78, 0x6F, 0x66, 0x73, 0x74, 0x79, 0x6C, 0x65, 0x2E, 0x63, 0x6F, + 0x6D, 0x82, 0x0C, 0x2A, 0x2E, 0x63, 0x61, 0x73, 0x70, 0x65, 0x72, 0x2E, + 0x63, 0x6F, 0x6D, 0x82, 0x11, 0x2A, 0x2E, 0x63, 0x68, 0x61, 0x6B, 0x72, + 0x61, 0x6C, 0x69, 0x6E, 0x75, 0x78, 0x2E, 0x6F, 0x72, 0x67, 0x82, 0x18, + 0x2A, 0x2E, 0x63, 0x6F, 0x6E, 0x76, 0x65, 0x72, 0x74, 0x2E, 0x64, 0x73, + 0x2E, 0x76, 0x65, 0x72, 0x69, 0x7A, 0x6F, 0x6E, 0x2E, 0x63, 0x6F, 0x6D, + 0x82, 0x15, 0x2A, 0x2E, 0x64, 0x65, 0x76, 0x73, 0x70, 0x61, 0x63, 0x65, + 0x73, 0x68, 0x69, 0x70, 0x2E, 0x63, 0x6F, 0x6D, 0x2E, 0x61, 0x75, 0x82, + 0x1B, 0x2A, 0x2E, 0x64, 0x65, 0x76, 0x73, 0x70, 0x61, 0x63, 0x65, 0x73, + 0x68, 0x69, 0x70, 0x69, 0x6E, 0x76, 0x65, 0x73, 0x74, 0x2E, 0x63, 0x6F, + 0x6D, 0x2E, 0x61, 0x75, 0x82, 0x0A, 0x2A, 0x2E, 0x65, 0x63, 0x68, 0x6C, + 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x0F, 0x2A, 0x2E, 0x66, 0x69, 0x6C, 0x65, + 0x73, 0x74, 0x61, 0x63, 0x6B, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x16, 0x2A, + 0x2E, 0x66, 0x69, 0x6C, 0x65, 0x73, 0x74, 0x61, 0x63, 0x6B, 0x2E, 0x6F, + 0x6E, 0x65, 0x6D, 0x6F, 0x62, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x0D, 0x2A, + 0x2E, 0x66, 0x69, 0x73, 0x2D, 0x73, 0x6B, 0x69, 0x2E, 0x63, 0x6F, 0x6D, + 0x82, 0x0C, 0x2A, 0x2E, 0x66, 0x69, 0x73, 0x73, 0x6B, 0x69, 0x2E, 0x63, + 0x6F, 0x6D, 0x82, 0x14, 0x2A, 0x2E, 0x66, 0x70, 0x2E, 0x62, 0x72, 0x61, + 0x6E, 0x64, 0x66, 0x6F, 0x6C, 0x64, 0x65, 0x72, 0x2E, 0x63, 0x6F, 0x6D, + 0x82, 0x0F, 0x2A, 0x2E, 0x66, 0x73, 0x2E, 0x65, 0x6E, 0x70, 0x6C, 0x75, + 0x67, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x0E, 0x2A, 0x2E, 0x66, 0x73, 0x2E, + 0x65, 0x6E, 0x70, 0x6C, 0x75, 0x67, 0x2E, 0x69, 0x6E, 0x82, 0x10, 0x2A, + 0x2E, 0x66, 0x73, 0x2E, 0x68, 0x65, 0x72, 0x6F, 0x69, 0x6E, 0x65, 0x2E, + 0x63, 0x6F, 0x6D, 0x82, 0x18, 0x2A, 0x2E, 0x66, 0x73, 0x2E, 0x6C, 0x65, + 0x61, 0x72, 0x6E, 0x7A, 0x69, 0x6C, 0x6C, 0x69, 0x6F, 0x6E, 0x63, 0x64, + 0x6E, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x18, 0x2A, 0x2E, 0x66, 0x73, 0x2E, + 0x6C, 0x6F, 0x63, 0x61, 0x6C, 0x7A, 0x69, 0x6C, 0x6C, 0x69, 0x6F, 0x6E, + 0x63, 0x64, 0x6E, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x12, 0x2A, 0x2E, 0x66, + 0x73, 0x2E, 0x6D, 0x69, 0x6E, 0x64, 0x66, 0x6C, 0x61, 0x73, 0x68, 0x2E, + 0x63, 0x6F, 0x6D, 0x82, 0x16, 0x2A, 0x2E, 0x66, 0x73, 0x2E, 0x6F, 0x70, + 0x73, 0x7A, 0x69, 0x6C, 0x6C, 0x69, 0x6F, 0x6E, 0x63, 0x64, 0x6E, 0x2E, + 0x63, 0x6F, 0x6D, 0x82, 0x10, 0x2A, 0x2E, 0x66, 0x73, 0x2E, 0x70, 0x69, + 0x78, 0x76, 0x61, 0x6E, 0x61, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x15, 0x2A, + 0x2E, 0x66, 0x73, 0x2E, 0x71, 0x61, 0x7A, 0x69, 0x6C, 0x6C, 0x69, 0x6F, + 0x6E, 0x63, 0x64, 0x6E, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x17, 0x2A, 0x2E, + 0x66, 0x73, 0x2E, 0x74, 0x65, 0x73, 0x74, 0x7A, 0x69, 0x6C, 0x6C, 0x69, + 0x6F, 0x6E, 0x63, 0x64, 0x6E, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x09, 0x2A, + 0x2E, 0x68, 0x61, 0x78, 0x78, 0x2E, 0x73, 0x65, 0x82, 0x0D, 0x2A, 0x2E, + 0x68, 0x6F, 0x6D, 0x65, 0x61, 0x77, 0x61, 0x79, 0x2E, 0x6C, 0x6B, 0x82, + 0x0F, 0x2A, 0x2E, 0x69, 0x64, 0x61, 0x74, 0x61, 0x6C, 0x69, 0x6E, 0x6B, + 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x16, 0x2A, 0x2E, 0x69, 0x64, 0x61, 0x74, + 0x61, 0x6C, 0x69, 0x6E, 0x6B, 0x6D, 0x61, 0x65, 0x73, 0x74, 0x72, 0x6F, + 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x11, 0x2A, 0x2E, 0x69, 0x6D, 0x67, 0x2D, + 0x74, 0x61, 0x62, 0x6F, 0x6F, 0x6C, 0x61, 0x2E, 0x63, 0x6F, 0x6D, 0x82, + 0x0F, 0x2A, 0x2E, 0x6A, 0x75, 0x6C, 0x69, 0x61, 0x6C, 0x61, 0x6E, 0x67, + 0x2E, 0x6F, 0x72, 0x67, 0x82, 0x10, 0x2A, 0x2E, 0x6B, 0x69, 0x6E, 0x64, + 0x73, 0x6E, 0x61, 0x63, 0x6B, 0x73, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x10, + 0x2A, 0x2E, 0x6B, 0x73, 0x73, 0x76, 0x61, 0x6E, 0x69, 0x6C, 0x6C, 0x61, + 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x0E, 0x2A, 0x2E, 0x6B, 0x73, 0x74, 0x63, + 0x6F, 0x72, 0x72, 0x61, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x10, 0x2A, 0x2E, + 0x6B, 0x73, 0x74, 0x76, 0x61, 0x6E, 0x69, 0x6C, 0x6C, 0x61, 0x2E, 0x63, + 0x6F, 0x6D, 0x82, 0x0C, 0x2A, 0x2E, 0x6E, 0x65, 0x77, 0x73, 0x31, 0x32, + 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x1B, 0x2A, 0x2E, 0x70, 0x61, 0x72, 0x74, + 0x69, 0x64, 0x65, 0x6E, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x2E, 0x73, + 0x77, 0x69, 0x73, 0x63, 0x6F, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x13, 0x2A, + 0x2E, 0x73, 0x68, 0x6F, 0x70, 0x72, 0x61, 0x63, 0x68, 0x65, 0x6C, 0x7A, + 0x6F, 0x65, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x0A, 0x2A, 0x2E, 0x74, 0x61, + 0x73, 0x74, 0x79, 0x2E, 0x63, 0x6F, 0x82, 0x0C, 0x2A, 0x2E, 0x74, 0x65, + 0x64, 0x63, 0x64, 0x6E, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x15, 0x2A, 0x2E, + 0x75, 0x70, 0x6C, 0x6F, 0x61, 0x64, 0x73, 0x2E, 0x66, 0x6F, 0x6C, 0x69, + 0x6F, 0x68, 0x64, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x14, 0x2A, 0x2E, 0x76, + 0x6F, 0x75, 0x63, 0x68, 0x65, 0x72, 0x63, 0x6F, 0x64, 0x65, 0x73, 0x2E, + 0x63, 0x6F, 0x2E, 0x75, 0x6B, 0x82, 0x0D, 0x2A, 0x2E, 0x77, 0x65, 0x61, + 0x74, 0x68, 0x65, 0x72, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x0D, 0x61, 0x2E, + 0x69, 0x63, 0x61, 0x6E, 0x76, 0x61, 0x73, 0x2E, 0x63, 0x6F, 0x6D, 0x82, + 0x0B, 0x61, 0x32, 0x70, 0x72, 0x65, 0x73, 0x73, 0x65, 0x2E, 0x66, 0x72, + 0x82, 0x17, 0x61, 0x64, 0x76, 0x65, 0x6E, 0x74, 0x69, 0x73, 0x74, 0x62, + 0x6F, 0x6F, 0x6B, 0x63, 0x65, 0x6E, 0x74, 0x65, 0x72, 0x2E, 0x63, 0x6F, + 0x6D, 0x82, 0x11, 0x61, 0x70, 0x69, 0x2D, 0x6D, 0x65, 0x72, 0x72, 0x79, + 0x6A, 0x61, 0x6E, 0x65, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x12, 0x61, 0x70, + 0x69, 0x73, 0x2E, 0x69, 0x64, 0x61, 0x74, 0x61, 0x6C, 0x69, 0x76, 0x65, + 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x0F, 0x61, 0x70, 0x70, 0x2D, 0x61, 0x70, + 0x69, 0x2E, 0x74, 0x65, 0x64, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x12, 0x61, + 0x70, 0x70, 0x2E, 0x62, 0x69, 0x72, 0x63, 0x68, 0x62, 0x6F, 0x78, 0x2E, + 0x63, 0x6F, 0x2E, 0x75, 0x6B, 0x82, 0x0F, 0x61, 0x70, 0x70, 0x2E, 0x62, + 0x69, 0x72, 0x63, 0x68, 0x62, 0x6F, 0x78, 0x2E, 0x65, 0x73, 0x82, 0x1A, + 0x61, 0x70, 0x70, 0x2E, 0x73, 0x74, 0x61, 0x67, 0x69, 0x6E, 0x67, 0x2E, + 0x62, 0x69, 0x72, 0x63, 0x68, 0x62, 0x6F, 0x78, 0x2E, 0x63, 0x6F, 0x2E, + 0x75, 0x6B, 0x82, 0x17, 0x61, 0x70, 0x70, 0x2E, 0x73, 0x74, 0x61, 0x67, + 0x69, 0x6E, 0x67, 0x2E, 0x62, 0x69, 0x72, 0x63, 0x68, 0x62, 0x6F, 0x78, + 0x2E, 0x65, 0x73, 0x82, 0x0A, 0x62, 0x61, 0x61, 0x74, 0x63, 0x68, 0x2E, + 0x63, 0x6F, 0x6D, 0x82, 0x13, 0x62, 0x65, 0x72, 0x6E, 0x61, 0x72, 0x64, + 0x63, 0x6F, 0x6E, 0x74, 0x72, 0x6F, 0x6C, 0x73, 0x2E, 0x63, 0x6F, 0x6D, + 0x82, 0x15, 0x62, 0x69, 0x6F, 0x74, 0x65, 0x63, 0x68, 0x77, 0x65, 0x65, + 0x6B, 0x62, 0x6F, 0x73, 0x74, 0x6F, 0x6E, 0x2E, 0x63, 0x6F, 0x6D, 0x82, + 0x0E, 0x62, 0x6F, 0x78, 0x6F, 0x66, 0x73, 0x74, 0x79, 0x6C, 0x65, 0x2E, + 0x63, 0x6F, 0x6D, 0x82, 0x0A, 0x63, 0x61, 0x73, 0x70, 0x65, 0x72, 0x2E, + 0x63, 0x6F, 0x6D, 0x82, 0x0D, 0x63, 0x64, 0x6E, 0x2E, 0x69, 0x72, 0x73, + 0x64, 0x6E, 0x2E, 0x6E, 0x65, 0x74, 0x82, 0x0F, 0x63, 0x68, 0x61, 0x6B, + 0x72, 0x61, 0x6C, 0x69, 0x6E, 0x75, 0x78, 0x2E, 0x6F, 0x72, 0x67, 0x82, + 0x13, 0x64, 0x65, 0x76, 0x73, 0x70, 0x61, 0x63, 0x65, 0x73, 0x68, 0x69, + 0x70, 0x2E, 0x63, 0x6F, 0x6D, 0x2E, 0x61, 0x75, 0x82, 0x0B, 0x64, 0x69, + 0x67, 0x69, 0x64, 0x61, 0x79, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x22, 0x64, + 0x69, 0x67, 0x69, 0x74, 0x61, 0x6C, 0x4C, 0x69, 0x62, 0x72, 0x61, 0x72, + 0x79, 0x2E, 0x62, 0x65, 0x72, 0x6E, 0x61, 0x72, 0x64, 0x63, 0x6F, 0x6E, + 0x74, 0x72, 0x6F, 0x6C, 0x73, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x14, 0x64, + 0x72, 0x77, 0x70, 0x2E, 0x73, 0x74, 0x61, 0x67, 0x69, 0x6E, 0x67, 0x2E, + 0x6D, 0x6F, 0x6F, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x08, 0x65, 0x63, 0x68, + 0x6C, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x14, 0x66, 0x69, 0x6C, 0x65, 0x73, + 0x74, 0x61, 0x63, 0x6B, 0x2E, 0x6F, 0x6E, 0x65, 0x6D, 0x6F, 0x62, 0x2E, + 0x63, 0x6F, 0x6D, 0x82, 0x0D, 0x66, 0x73, 0x2E, 0x65, 0x6E, 0x70, 0x6C, + 0x75, 0x67, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x16, 0x66, 0x73, 0x2E, 0x6C, + 0x65, 0x61, 0x72, 0x6E, 0x7A, 0x69, 0x6C, 0x6C, 0x69, 0x6F, 0x6E, 0x63, + 0x64, 0x6E, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x16, 0x66, 0x73, 0x2E, 0x6C, + 0x6F, 0x63, 0x61, 0x6C, 0x7A, 0x69, 0x6C, 0x6C, 0x69, 0x6F, 0x6E, 0x63, + 0x64, 0x6E, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x14, 0x66, 0x73, 0x2E, 0x6F, + 0x70, 0x73, 0x7A, 0x69, 0x6C, 0x6C, 0x69, 0x6F, 0x6E, 0x63, 0x64, 0x6E, + 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x13, 0x66, 0x73, 0x2E, 0x71, 0x61, 0x7A, + 0x69, 0x6C, 0x6C, 0x69, 0x6F, 0x6E, 0x63, 0x64, 0x6E, 0x2E, 0x63, 0x6F, + 0x6D, 0x82, 0x15, 0x66, 0x73, 0x2E, 0x74, 0x65, 0x73, 0x74, 0x7A, 0x69, + 0x6C, 0x6C, 0x69, 0x6F, 0x6E, 0x63, 0x64, 0x6E, 0x2E, 0x63, 0x6F, 0x6D, + 0x82, 0x0B, 0x68, 0x6F, 0x6D, 0x65, 0x61, 0x77, 0x61, 0x79, 0x2E, 0x6C, + 0x6B, 0x82, 0x12, 0x69, 0x6D, 0x67, 0x2E, 0x74, 0x72, 0x69, 0x67, 0x67, + 0x65, 0x72, 0x6D, 0x61, 0x69, 0x6C, 0x2E, 0x69, 0x6F, 0x82, 0x0E, 0x6B, + 0x69, 0x6E, 0x64, 0x73, 0x6E, 0x61, 0x63, 0x6B, 0x73, 0x2E, 0x63, 0x6F, + 0x6D, 0x82, 0x0E, 0x6B, 0x73, 0x73, 0x76, 0x61, 0x6E, 0x69, 0x6C, 0x6C, + 0x61, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x0C, 0x6B, 0x73, 0x74, 0x63, 0x6F, + 0x72, 0x72, 0x61, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x0D, 0x6D, 0x65, 0x6E, + 0x75, 0x2E, 0x74, 0x72, 0x65, 0x65, 0x7A, 0x2E, 0x69, 0x6F, 0x82, 0x17, + 0x6D, 0x6F, 0x62, 0x69, 0x6C, 0x65, 0x61, 0x70, 0x69, 0x2E, 0x69, 0x64, + 0x61, 0x74, 0x61, 0x6C, 0x69, 0x6E, 0x6B, 0x2E, 0x63, 0x6F, 0x6D, 0x82, + 0x0A, 0x6E, 0x65, 0x77, 0x73, 0x31, 0x32, 0x2E, 0x63, 0x6F, 0x6D, 0x82, + 0x0B, 0x6F, 0x6D, 0x6E, 0x69, 0x67, 0x6F, 0x6E, 0x2E, 0x63, 0x6F, 0x6D, + 0x82, 0x0E, 0x6F, 0x72, 0x65, 0x69, 0x6C, 0x6C, 0x79, 0x2E, 0x72, 0x65, + 0x76, 0x69, 0x65, 0x77, 0x82, 0x11, 0x70, 0x6F, 0x70, 0x79, 0x6F, 0x75, + 0x72, 0x62, 0x75, 0x62, 0x62, 0x6C, 0x65, 0x2E, 0x63, 0x6F, 0x6D, 0x82, + 0x18, 0x70, 0x72, 0x6F, 0x64, 0x2E, 0x62, 0x65, 0x72, 0x6E, 0x61, 0x72, + 0x64, 0x63, 0x6F, 0x6E, 0x74, 0x72, 0x6F, 0x6C, 0x73, 0x2E, 0x63, 0x6F, + 0x6D, 0x82, 0x18, 0x72, 0x65, 0x6C, 0x65, 0x61, 0x73, 0x65, 0x2D, 0x70, + 0x72, 0x69, 0x6D, 0x65, 0x2E, 0x73, 0x70, 0x6F, 0x6B, 0x65, 0x6F, 0x2E, + 0x63, 0x6F, 0x6D, 0x82, 0x19, 0x72, 0x65, 0x70, 0x6F, 0x73, 0x69, 0x74, + 0x6F, 0x72, 0x69, 0x65, 0x73, 0x2E, 0x73, 0x65, 0x6E, 0x73, 0x75, 0x61, + 0x70, 0x70, 0x2E, 0x6F, 0x72, 0x67, 0x82, 0x0C, 0x72, 0x6C, 0x2E, 0x74, + 0x61, 0x6C, 0x69, 0x73, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x11, 0x73, 0x68, + 0x6F, 0x70, 0x72, 0x61, 0x63, 0x68, 0x65, 0x6C, 0x7A, 0x6F, 0x65, 0x2E, + 0x63, 0x6F, 0x6D, 0x82, 0x0F, 0x73, 0x74, 0x61, 0x67, 0x69, 0x6E, 0x67, + 0x2E, 0x6D, 0x6F, 0x6F, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x14, 0x73, 0x74, + 0x61, 0x74, 0x69, 0x63, 0x2E, 0x70, 0x6C, 0x75, 0x6D, 0x63, 0x61, 0x63, + 0x68, 0x65, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x14, 0x73, 0x74, 0x61, 0x79, + 0x69, 0x6E, 0x67, 0x61, 0x6C, 0x69, 0x76, 0x65, 0x2E, 0x6D, 0x73, 0x66, + 0x2E, 0x6F, 0x72, 0x67, 0x82, 0x08, 0x74, 0x61, 0x73, 0x74, 0x79, 0x2E, + 0x63, 0x6F, 0x82, 0x0C, 0x74, 0x6F, 0x70, 0x73, 0x70, 0x65, 0x65, 0x64, + 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x13, 0x75, 0x70, 0x6C, 0x6F, 0x61, 0x64, + 0x73, 0x2E, 0x66, 0x6F, 0x6C, 0x69, 0x6F, 0x68, 0x64, 0x2E, 0x63, 0x6F, + 0x6D, 0x82, 0x1A, 0x75, 0x73, 0x2D, 0x65, 0x75, 0x2E, 0x66, 0x69, 0x6C, + 0x65, 0x73, 0x74, 0x61, 0x63, 0x6B, 0x63, 0x6F, 0x6E, 0x74, 0x65, 0x6E, + 0x74, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x12, 0x76, 0x6F, 0x75, 0x63, 0x68, + 0x65, 0x72, 0x63, 0x6F, 0x64, 0x65, 0x73, 0x2E, 0x63, 0x6F, 0x2E, 0x75, + 0x6B, 0x82, 0x0B, 0x77, 0x65, 0x61, 0x74, 0x68, 0x65, 0x72, 0x2E, 0x63, + 0x6F, 0x6D, 0x82, 0x13, 0x77, 0x6F, 0x6D, 0x65, 0x6E, 0x73, 0x68, 0x65, + 0x61, 0x6C, 0x74, 0x68, 0x2D, 0x6A, 0x70, 0x2E, 0x63, 0x6F, 0x6D, 0x82, + 0x19, 0x77, 0x6F, 0x72, 0x6B, 0x65, 0x72, 0x62, 0x65, 0x65, 0x2E, 0x73, + 0x74, 0x61, 0x67, 0x69, 0x6E, 0x67, 0x2E, 0x6D, 0x6F, 0x6F, 0x2E, 0x63, + 0x6F, 0x6D, 0x82, 0x0A, 0x77, 0x77, 0x77, 0x2E, 0x61, 0x67, 0x66, 0x2E, + 0x64, 0x6B, 0x82, 0x14, 0x77, 0x77, 0x77, 0x2E, 0x61, 0x76, 0x65, 0x6E, + 0x69, 0x72, 0x2D, 0x73, 0x75, 0x69, 0x73, 0x73, 0x65, 0x2E, 0x63, 0x68, + 0x82, 0x11, 0x77, 0x77, 0x77, 0x2E, 0x63, 0x61, 0x6E, 0x73, 0x74, 0x61, + 0x72, 0x2E, 0x63, 0x6F, 0x2E, 0x6E, 0x7A, 0x82, 0x15, 0x77, 0x77, 0x77, + 0x2E, 0x63, 0x61, 0x6E, 0x73, 0x74, 0x61, 0x72, 0x62, 0x6C, 0x75, 0x65, + 0x2E, 0x63, 0x6F, 0x2E, 0x6E, 0x7A, 0x82, 0x16, 0x77, 0x77, 0x77, 0x2E, + 0x63, 0x61, 0x6E, 0x73, 0x74, 0x61, 0x72, 0x62, 0x6C, 0x75, 0x65, 0x2E, + 0x63, 0x6F, 0x6D, 0x2E, 0x61, 0x75, 0x82, 0x1D, 0x77, 0x77, 0x77, 0x2E, + 0x63, 0x68, 0x61, 0x6D, 0x70, 0x69, 0x6F, 0x6E, 0x73, 0x68, 0x6F, 0x63, + 0x6B, 0x65, 0x79, 0x6C, 0x65, 0x61, 0x67, 0x75, 0x65, 0x2E, 0x6E, 0x65, + 0x74, 0x82, 0x0F, 0x77, 0x77, 0x77, 0x2E, 0x65, 0x78, 0x74, 0x65, 0x72, + 0x72, 0x6F, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x0C, 0x77, 0x77, 0x77, 0x2E, + 0x65, 0x7A, 0x75, 0x70, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x0B, 0x77, 0x77, + 0x77, 0x2E, 0x65, 0x7A, 0x75, 0x70, 0x2E, 0x64, 0x65, 0x82, 0x0B, 0x77, + 0x77, 0x77, 0x2E, 0x65, 0x7A, 0x75, 0x70, 0x2E, 0x65, 0x75, 0x82, 0x0B, + 0x77, 0x77, 0x77, 0x2E, 0x65, 0x7A, 0x75, 0x70, 0x2E, 0x6E, 0x6C, 0x82, + 0x11, 0x77, 0x77, 0x77, 0x2E, 0x66, 0x72, 0x61, 0x6E, 0x6B, 0x62, 0x6F, + 0x64, 0x79, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x0D, 0x77, 0x77, 0x77, 0x2E, + 0x67, 0x6C, 0x6F, 0x73, 0x73, 0x79, 0x2E, 0x63, 0x6F, 0x82, 0x0F, 0x77, + 0x77, 0x77, 0x2E, 0x67, 0x6F, 0x6C, 0x64, 0x63, 0x75, 0x70, 0x2E, 0x6F, + 0x72, 0x67, 0x82, 0x0F, 0x77, 0x77, 0x77, 0x2E, 0x69, 0x63, 0x61, 0x6E, + 0x76, 0x61, 0x73, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x0D, 0x77, 0x77, 0x77, + 0x2E, 0x6D, 0x6F, 0x6E, 0x69, 0x6E, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x16, + 0x77, 0x77, 0x77, 0x2E, 0x6F, 0x64, 0x65, 0x6E, 0x73, 0x65, 0x2D, 0x6D, + 0x61, 0x72, 0x63, 0x69, 0x70, 0x61, 0x6E, 0x2E, 0x64, 0x6B, 0x82, 0x15, + 0x77, 0x77, 0x77, 0x2E, 0x6F, 0x6E, 0x65, 0x63, 0x6C, 0x69, 0x63, 0x6B, + 0x64, 0x72, 0x69, 0x76, 0x65, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x12, 0x77, + 0x77, 0x77, 0x2E, 0x6F, 0x72, 0x65, 0x69, 0x6C, 0x6C, 0x79, 0x2E, 0x72, + 0x65, 0x76, 0x69, 0x65, 0x77, 0x82, 0x15, 0x77, 0x77, 0x77, 0x2E, 0x70, + 0x6F, 0x70, 0x79, 0x6F, 0x75, 0x72, 0x62, 0x75, 0x62, 0x62, 0x6C, 0x65, + 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x0E, 0x77, 0x77, 0x77, 0x2E, 0x72, 0x61, + 0x77, 0x6E, 0x65, 0x74, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x0E, 0x77, 0x77, + 0x77, 0x2E, 0x73, 0x70, 0x6F, 0x6B, 0x65, 0x6F, 0x2E, 0x63, 0x6F, 0x6D, + 0x82, 0x10, 0x77, 0x77, 0x77, 0x2E, 0x74, 0x65, 0x61, 0x72, 0x73, 0x68, + 0x65, 0x65, 0x74, 0x2E, 0x63, 0x6F, 0x82, 0x10, 0x77, 0x77, 0x77, 0x2E, + 0x74, 0x6F, 0x70, 0x73, 0x70, 0x65, 0x65, 0x64, 0x2E, 0x63, 0x6F, 0x6D, + 0x82, 0x16, 0x77, 0x77, 0x77, 0x2E, 0x77, 0x68, 0x69, 0x74, 0x65, 0x6B, + 0x65, 0x79, 0x76, 0x69, 0x6C, 0x6C, 0x61, 0x73, 0x2E, 0x63, 0x6F, 0x6D, + 0x30, 0x1D, 0x06, 0x03, 0x55, 0x1D, 0x25, 0x04, 0x16, 0x30, 0x14, 0x06, + 0x08, 0x2B, 0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x01, 0x06, 0x08, 0x2B, + 0x06, 0x01, 0x05, 0x05, 0x07, 0x03, 0x02, 0x30, 0x1D, 0x06, 0x03, 0x55, + 0x1D, 0x0E, 0x04, 0x16, 0x04, 0x14, 0xA8, 0x29, 0xFD, 0xA9, 0xA5, 0x1A, + 0x1C, 0x37, 0x0B, 0x20, 0x3B, 0x98, 0xB7, 0x25, 0x39, 0xCC, 0xE5, 0x2F, + 0xF4, 0x94, 0x30, 0x1F, 0x06, 0x03, 0x55, 0x1D, 0x23, 0x04, 0x18, 0x30, + 0x16, 0x80, 0x14, 0xA9, 0x2B, 0x87, 0xE1, 0xCE, 0x24, 0x47, 0x3B, 0x1B, + 0xBF, 0xCF, 0x85, 0x37, 0x02, 0x55, 0x9D, 0x0D, 0x94, 0x58, 0xE6, 0x30, + 0x82, 0x01, 0x04, 0x06, 0x0A, 0x2B, 0x06, 0x01, 0x04, 0x01, 0xD6, 0x79, + 0x02, 0x04, 0x02, 0x04, 0x81, 0xF5, 0x04, 0x81, 0xF2, 0x00, 0xF0, 0x00, + 0x77, 0x00, 0xA4, 0xB9, 0x09, 0x90, 0xB4, 0x18, 0x58, 0x14, 0x87, 0xBB, + 0x13, 0xA2, 0xCC, 0x67, 0x70, 0x0A, 0x3C, 0x35, 0x98, 0x04, 0xF9, 0x1B, + 0xDF, 0xB8, 0xE3, 0x77, 0xCD, 0x0E, 0xC8, 0x0D, 0xDC, 0x10, 0x00, 0x00, + 0x01, 0x66, 0x9C, 0xC8, 0xE7, 0x38, 0x00, 0x00, 0x04, 0x03, 0x00, 0x48, + 0x30, 0x46, 0x02, 0x21, 0x00, 0xD9, 0x58, 0x6E, 0xFC, 0x4C, 0x3C, 0xAF, + 0xF9, 0x5B, 0x7F, 0xDA, 0x54, 0x95, 0xAF, 0xCF, 0xB3, 0x57, 0xB9, 0x56, + 0x2C, 0xE8, 0xE0, 0xB1, 0x20, 0x9B, 0xCB, 0x75, 0xAC, 0x4E, 0x54, 0xE9, + 0x9D, 0x02, 0x21, 0x00, 0xE8, 0xF0, 0xC0, 0x49, 0x23, 0x8E, 0x3D, 0x9B, + 0xA5, 0x87, 0xA3, 0xBE, 0x6C, 0x21, 0x62, 0xBB, 0xD2, 0x44, 0x5C, 0xE4, + 0x7A, 0xCC, 0x46, 0x26, 0x04, 0x19, 0xA4, 0x2D, 0x9B, 0x1C, 0x5D, 0x3A, + 0x00, 0x75, 0x00, 0x6F, 0x53, 0x76, 0xAC, 0x31, 0xF0, 0x31, 0x19, 0xD8, + 0x99, 0x00, 0xA4, 0x51, 0x15, 0xFF, 0x77, 0x15, 0x1C, 0x11, 0xD9, 0x02, + 0xC1, 0x00, 0x29, 0x06, 0x8D, 0xB2, 0x08, 0x9A, 0x37, 0xD9, 0x13, 0x00, + 0x00, 0x01, 0x66, 0x9C, 0xC8, 0xE6, 0x20, 0x00, 0x00, 0x04, 0x03, 0x00, + 0x46, 0x30, 0x44, 0x02, 0x20, 0x14, 0xC8, 0x9F, 0xAC, 0x27, 0x48, 0xBE, + 0x4D, 0x0E, 0xC3, 0x26, 0x2E, 0x34, 0xCA, 0x38, 0xBA, 0x11, 0x3A, 0x68, + 0x71, 0x88, 0xEB, 0x24, 0x26, 0x59, 0x3E, 0xAC, 0xA8, 0x63, 0xCC, 0x8A, + 0x0A, 0x02, 0x20, 0x0F, 0x22, 0xBF, 0x0D, 0x1F, 0x8A, 0x8D, 0x1D, 0x91, + 0x33, 0x3A, 0x40, 0xE4, 0x23, 0x78, 0xFA, 0x22, 0xF5, 0x9B, 0xCB, 0x04, + 0x4F, 0x53, 0x2D, 0x20, 0x75, 0x2F, 0x76, 0x8A, 0xB1, 0xCD, 0x9D, 0x30, + 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x0B, + 0x05, 0x00, 0x03, 0x82, 0x01, 0x01, 0x00, 0x03, 0x41, 0x0F, 0xF3, 0xA6, + 0x62, 0xA2, 0xE5, 0xB4, 0x8D, 0xA8, 0x08, 0x71, 0x7B, 0xB3, 0xE3, 0x51, + 0x61, 0x0D, 0xC0, 0x67, 0x6C, 0x3C, 0x9C, 0x00, 0x0B, 0x63, 0x77, 0xB6, + 0xB6, 0x11, 0x67, 0x77, 0xA5, 0xE1, 0x49, 0xE0, 0x7F, 0xB7, 0x1D, 0x61, + 0xFB, 0x83, 0x9C, 0x83, 0x42, 0xE9, 0x31, 0xCA, 0x51, 0xE3, 0xC1, 0xBD, + 0x9B, 0x2F, 0xB5, 0x35, 0x05, 0x72, 0x7F, 0x40, 0xA6, 0x7C, 0xC9, 0xF1, + 0x59, 0xA7, 0x15, 0xB8, 0x12, 0xDA, 0xF8, 0xCE, 0x83, 0x61, 0xFC, 0x47, + 0x96, 0x9E, 0x74, 0xFE, 0xCD, 0xE4, 0x61, 0x92, 0xF2, 0x2E, 0x0C, 0x08, + 0x4B, 0x60, 0x2D, 0xF6, 0x50, 0x07, 0x83, 0xCA, 0xAF, 0xB9, 0x41, 0x33, + 0x4A, 0x3E, 0x84, 0xC7, 0x73, 0xC6, 0x1F, 0xFF, 0x7A, 0xDF, 0xAE, 0x47, + 0x25, 0x32, 0xEB, 0xC0, 0x43, 0x0C, 0xA6, 0x23, 0x13, 0x46, 0xC3, 0xFA, + 0x44, 0xEA, 0x20, 0xEA, 0xCB, 0x18, 0x17, 0x00, 0xB6, 0xE7, 0x6D, 0x8A, + 0x14, 0x8C, 0x6A, 0xCA, 0x88, 0x4C, 0xDA, 0xA8, 0xB9, 0x08, 0xAF, 0x39, + 0xEE, 0xCF, 0xD7, 0xF7, 0x32, 0xC0, 0xF4, 0xCF, 0x4E, 0x22, 0x38, 0xF7, + 0xAF, 0xAE, 0x7D, 0x58, 0x5F, 0xA5, 0x2D, 0x4D, 0xBB, 0x86, 0x10, 0xB3, + 0x93, 0x62, 0x64, 0x27, 0xBF, 0xB1, 0xBB, 0x8F, 0x9F, 0xFC, 0x07, 0x3C, + 0x4B, 0x16, 0x7A, 0x84, 0x5E, 0xAF, 0xAD, 0x57, 0x9C, 0xFF, 0x7A, 0xA7, + 0xE0, 0x90, 0x89, 0x1C, 0xE8, 0xE5, 0x11, 0xF7, 0xB6, 0xDC, 0xCD, 0x5E, + 0xF7, 0x30, 0xA2, 0x2E, 0x67, 0x6D, 0x4A, 0x70, 0x26, 0xEA, 0xCD, 0x27, + 0x70, 0x77, 0x54, 0x57, 0x09, 0x03, 0x56, 0x4A, 0x33, 0x60, 0x00, 0x27, + 0xFE, 0xA7, 0xD7, 0xA9, 0xC4, 0xEC, 0x17, 0x17, 0x8D, 0x87, 0x70, 0x6B, + 0x48, 0x88, 0x61, 0x54, 0x4A, 0x2B, 0xB7, 0x6A, 0x12, 0x08, 0xFB, }; CURLcode res; diff --git a/tests/unit/unit1660.c b/tests/unit/unit1660.c index 6b1dcce9fc4d..77d72a063135 100644 --- a/tests/unit/unit1660.c +++ b/tests/unit/unit1660.c @@ -52,17 +52,17 @@ static CURLcode test_unit1660(const char *arg) struct testit { const char *host; - const char *chost; /* if non-NULL, use to lookup with */ - const char *hdr; /* if NULL, just do the lookup */ + const char *chost; /* if non-NULL, use to lookup with */ + const char *hdr; /* if NULL, just do the lookup */ const CURLcode res; /* parse result */ }; static const struct testit headers[] = { /* two entries read from disk cache, verify first */ - { "-", "readfrom.example", NULL, CURLE_OK}, - { "-", "old.example", NULL, CURLE_OK}, + { "-", "readfrom.example", NULL, CURLE_OK }, + { "-", "old.example", NULL, CURLE_OK }, /* delete the remaining one read from disk */ - { "readfrom.example", NULL, "max-age=\"0\"", CURLE_OK}, + { "readfrom.example", NULL, "max-age=\"0\"", CURLE_OK }, { "example.com", NULL, "max-age=\"31536000\"\r\n", CURLE_OK }, { "example.com", NULL, "max-age=\"21536000\"\r\n", CURLE_OK }, @@ -90,10 +90,9 @@ static CURLcode test_unit1660(const char *arg) { "3.example.com", NULL, "max-age=\"21536000\"; include; includeSubDomains;", CURLE_OK }, /* remove the "3.example.com" one, should still match the example.com */ - { "3.example.com", NULL, "max-age=\"0\"; includeSubDomains;", - CURLE_OK }, - { "-", "foo.example.com", NULL, CURLE_OK}, - { "-", "foo.xample.com", NULL, CURLE_OK}, + { "3.example.com", NULL, "max-age=\"0\"; includeSubDomains;", CURLE_OK }, + { "-", "foo.example.com", NULL, CURLE_OK }, + { "-", "foo.xample.com", NULL, CURLE_OK }, /* should not match */ { "example.net", "forexample.net", "max-age=\"31536000\"\r\n", CURLE_OK }, diff --git a/tests/unit/unit1979.c b/tests/unit/unit1979.c index c3925d1bc0c5..796099d59280 100644 --- a/tests/unit/unit1979.c +++ b/tests/unit/unit1979.c @@ -127,7 +127,7 @@ static CURLcode test_unit1979(const char *arg) testcases[i].normalize); fail_unless(msnprintf_result >= 0, "curl_msnprintf fails"); fail_unless(!result && canonical_path_string && - !strcmp(canonical_path_string, testcases[i].canonical_url), + !strcmp(canonical_path_string, testcases[i].canonical_url), buffer); curlx_dyn_free(&canonical_path); } diff --git a/tests/unit/unit1980.c b/tests/unit/unit1980.c index 9e38d8a678ce..82bea8415a9f 100644 --- a/tests/unit/unit1980.c +++ b/tests/unit/unit1980.c @@ -98,7 +98,7 @@ static CURLcode test_unit1980(const char *arg) testcases[i].canonical_query); fail_unless(msnprintf_result >= 0, "curl_msnprintf fails"); fail_unless(!result && canonical_query_ptr && - !strcmp(canonical_query_ptr, testcases[i].canonical_query), + !strcmp(canonical_query_ptr, testcases[i].canonical_query), buffer); curlx_dyn_free(&canonical_query); } diff --git a/tests/unit/unit2604.c b/tests/unit/unit2604.c index fb05189714c3..2e61efc0a5f4 100644 --- a/tests/unit/unit2604.c +++ b/tests/unit/unit2604.c @@ -50,27 +50,27 @@ static CURLcode test_unit2604(const char *arg) int i; const size_t too_long = 90720; struct set list[] = { - { "-too-long-", "", "", "", CURLE_TOO_LARGE}, - { SA540 " c", SA540, "c", "/", CURLE_OK}, - { "\" " SA540 "\" c", " " SA540, "c", "/", CURLE_OK}, - { "a a", "a", "a", "/home/", CURLE_OK}, - { "b a", "b", "a", "/", CURLE_OK}, - { "a", "a", "", "/home/", CURLE_OK}, - { "b", "b", "", "/", CURLE_OK}, - { "\"foo bar\"\tb", "foo bar", "b", "/", CURLE_OK}, - { "/~/hej", "/home/user/hej", "", "/home/user", CURLE_OK}, - { "\"foo bar", "", "", "/", CURLE_QUOTE_ERROR}, - { "\"foo\\\"bar\" a", "foo\"bar", "a", "/", CURLE_OK}, - { "\"foo\\\'bar\" b", "foo\'bar", "b", "/", CURLE_OK}, - { "\"foo\\\\bar\" c", "foo\\bar", "c", "/", CURLE_OK}, - { "\"foo\\pbar\" c", "foo\\bar", "", "/", CURLE_QUOTE_ERROR}, - { "\"\" c", "", "", "", CURLE_QUOTE_ERROR}, - { "foo\"", "foo\"", "", "/", CURLE_OK}, - { "foo \"", "foo", "\"", "/", CURLE_OK}, - { " \t\t \t ", "", "", "/", CURLE_QUOTE_ERROR}, - { " ", "", "", "/", CURLE_QUOTE_ERROR}, - { "", "", "", "/", CURLE_QUOTE_ERROR}, - { " \r \n ", "\r", "\n ", "/", CURLE_OK}, + { "-too-long-", "", "", "", CURLE_TOO_LARGE }, + { SA540 " c", SA540, "c", "/", CURLE_OK }, + { "\" " SA540 "\" c", " " SA540, "c", "/", CURLE_OK }, + { "a a", "a", "a", "/home/", CURLE_OK }, + { "b a", "b", "a", "/", CURLE_OK }, + { "a", "a", "", "/home/", CURLE_OK }, + { "b", "b", "", "/", CURLE_OK }, + { "\"foo bar\"\tb", "foo bar", "b", "/", CURLE_OK }, + { "/~/hej", "/home/user/hej", "", "/home/user", CURLE_OK }, + { "\"foo bar", "", "", "/", CURLE_QUOTE_ERROR }, + { "\"foo\\\"bar\" a", "foo\"bar", "a", "/", CURLE_OK }, + { "\"foo\\\'bar\" b", "foo\'bar", "b", "/", CURLE_OK }, + { "\"foo\\\\bar\" c", "foo\\bar", "c", "/", CURLE_OK }, + { "\"foo\\pbar\" c", "foo\\bar", "", "/", CURLE_QUOTE_ERROR }, + { "\"\" c", "", "", "", CURLE_QUOTE_ERROR }, + { "foo\"", "foo\"", "", "/", CURLE_OK }, + { "foo \"", "foo", "\"", "/", CURLE_OK }, + { " \t\t \t ", "", "", "/", CURLE_QUOTE_ERROR }, + { " ", "", "", "/", CURLE_QUOTE_ERROR }, + { "", "", "", "/", CURLE_QUOTE_ERROR }, + { " \r \n ", "\r", "\n ", "/", CURLE_OK }, { NULL, NULL, NULL, NULL, CURLE_OK } }; diff --git a/tests/unit/unit2605.c b/tests/unit/unit2605.c index 49d0b0b000e9..e8fce4033420 100644 --- a/tests/unit/unit2605.c +++ b/tests/unit/unit2605.c @@ -40,32 +40,32 @@ static CURLcode test_unit2605(const char *arg) int i; struct range list[] = { - { "0-9", 100, 0, 10, CURLE_OK}, - { "1-10", 100, 1, 10, CURLE_OK}, - { "222222-222222", 300000, 222222, 1, CURLE_OK}, - { "4294967296 - 4294967297", 4294967298, 4294967296, 2, CURLE_OK}, - { "-10", 100, 90, 10, CURLE_OK}, - { "-20", 100, 80, 20, CURLE_OK}, - { "-1", 100, 99, 1, CURLE_OK}, - { "-0", 100, 0, 0, CURLE_RANGE_ERROR}, - { "--2", 100, 0, 0, CURLE_RANGE_ERROR}, - { "-100", 100, 0, 100, CURLE_OK}, - { "-101", 100, 0, 100, CURLE_OK}, - { "-1000", 100, 0, 100, CURLE_OK}, - { "2-1000", 100, 2, 98, CURLE_OK}, - { ".2-3", 100, 0, 0, CURLE_RANGE_ERROR}, - { "+2-3", 100, 0, 0, CURLE_RANGE_ERROR}, - { "2 - 3", 100, 2, 2, CURLE_OK}, - { " 2 - 3", 100, 2, 2, CURLE_RANGE_ERROR}, /* no leading space */ - { "2 - 3 ", 100, 2, 2, CURLE_RANGE_ERROR}, /* no trailing space */ - { "3-2", 100, 0, 0, CURLE_RANGE_ERROR}, - { "2.-3", 100, 0, 0, CURLE_RANGE_ERROR}, - { "-3-2", 100, 0, 0, CURLE_RANGE_ERROR}, - { "101-102", 100, 0, 0, CURLE_RANGE_ERROR}, - { "0-", 100, 0, 100, CURLE_OK}, - { "1-", 100, 1, 99, CURLE_OK}, - { "99-", 100, 99, 1, CURLE_OK}, - { "100-", 100, 0, 0, CURLE_RANGE_ERROR}, + { "0-9", 100, 0, 10, CURLE_OK }, + { "1-10", 100, 1, 10, CURLE_OK }, + { "222222-222222", 300000, 222222, 1, CURLE_OK }, + { "4294967296 - 4294967297", 4294967298, 4294967296, 2, CURLE_OK }, + { "-10", 100, 90, 10, CURLE_OK }, + { "-20", 100, 80, 20, CURLE_OK }, + { "-1", 100, 99, 1, CURLE_OK }, + { "-0", 100, 0, 0, CURLE_RANGE_ERROR }, + { "--2", 100, 0, 0, CURLE_RANGE_ERROR }, + { "-100", 100, 0, 100, CURLE_OK }, + { "-101", 100, 0, 100, CURLE_OK }, + { "-1000", 100, 0, 100, CURLE_OK }, + { "2-1000", 100, 2, 98, CURLE_OK }, + { ".2-3", 100, 0, 0, CURLE_RANGE_ERROR }, + { "+2-3", 100, 0, 0, CURLE_RANGE_ERROR }, + { "2 - 3", 100, 2, 2, CURLE_OK }, + { " 2 - 3", 100, 2, 2, CURLE_RANGE_ERROR }, /* no leading space */ + { "2 - 3 ", 100, 2, 2, CURLE_RANGE_ERROR }, /* no trailing space */ + { "3-2", 100, 0, 0, CURLE_RANGE_ERROR }, + { "2.-3", 100, 0, 0, CURLE_RANGE_ERROR }, + { "-3-2", 100, 0, 0, CURLE_RANGE_ERROR }, + { "101-102", 100, 0, 0, CURLE_RANGE_ERROR }, + { "0-", 100, 0, 100, CURLE_OK }, + { "1-", 100, 1, 99, CURLE_OK }, + { "99-", 100, 99, 1, CURLE_OK }, + { "100-", 100, 0, 0, CURLE_RANGE_ERROR }, { NULL, 0, 0, 0, CURLE_OK } }; @@ -78,10 +78,9 @@ static CURLcode test_unit2605(const char *arg) curl_off_t start; curl_off_t size; CURLcode res; - curl_mprintf("%u: '%s' (file size: %" FMT_OFF_T ")\n", - i, list[i].r, list[i].filesize); - res = Curl_ssh_range(curl, list[i].r, list[i].filesize, - &start, &size); + curl_mprintf("%u: '%s' (file size: %" FMT_OFF_T ")\n", i, list[i].r, + list[i].filesize); + res = Curl_ssh_range(curl, list[i].r, list[i].filesize, &start, &size); if(res != list[i].res) { curl_mprintf("... returned %d\n", res); unitfail++; diff --git a/tests/unit/unit3200.c b/tests/unit/unit3200.c index bfd4d1181b84..f7c82cee3768 100644 --- a/tests/unit/unit3200.c +++ b/tests/unit/unit3200.c @@ -28,7 +28,7 @@ static CURLcode test_unit3200(const char *arg) { UNITTEST_BEGIN_SIMPLE -#if !defined(CURL_DISABLE_COOKIES) || !defined(CURL_DISABLE_ALTSVC) || \ +#if !defined(CURL_DISABLE_COOKIES) || !defined(CURL_DISABLE_ALTSVC) || \ !defined(CURL_DISABLE_HSTS) || !defined(CURL_DISABLE_NETRC) #if defined(CURL_GNUC_DIAG) || defined(__clang__) diff --git a/tests/unit/unit3205.c b/tests/unit/unit3205.c index bb35fb2f8eae..df0ea7f8ddf8 100644 --- a/tests/unit/unit3205.c +++ b/tests/unit/unit3205.c @@ -442,26 +442,26 @@ static CURLcode test_unit3205(const char *arg) const char *str; }; static const struct test_str_entry test_str_list[] = { - { 0x1301, "TLS_AES_128_GCM_SHA256"}, - { 0x1302, "TLS_AES_256_GCM_SHA384"}, - { 0x1303, "TLS_CHACHA20_POLY1305_SHA256"}, - { 0xC02B, "ECDHE-ECDSA-AES128-GCM-SHA256"}, - { 0xC02F, "ECDHE-RSA-AES128-GCM-SHA256"}, - { 0xC02C, "ECDHE-ECDSA-AES256-GCM-SHA384"}, - { 0xC030, "ECDHE-RSA-AES256-GCM-SHA384"}, - { 0xCCA9, "ECDHE-ECDSA-CHACHA20-POLY1305"}, - { 0xCCA8, "ECDHE-RSA-CHACHA20-POLY1305"}, + { 0x1301, "TLS_AES_128_GCM_SHA256" }, + { 0x1302, "TLS_AES_256_GCM_SHA384" }, + { 0x1303, "TLS_CHACHA20_POLY1305_SHA256" }, + { 0xC02B, "ECDHE-ECDSA-AES128-GCM-SHA256" }, + { 0xC02F, "ECDHE-RSA-AES128-GCM-SHA256" }, + { 0xC02C, "ECDHE-ECDSA-AES256-GCM-SHA384" }, + { 0xC030, "ECDHE-RSA-AES256-GCM-SHA384" }, + { 0xCCA9, "ECDHE-ECDSA-CHACHA20-POLY1305" }, + { 0xCCA8, "ECDHE-RSA-CHACHA20-POLY1305" }, #ifdef USE_MBEDTLS - { 0x009E, "DHE-RSA-AES128-GCM-SHA256"}, - { 0x009F, "DHE-RSA-AES256-GCM-SHA384"}, + { 0x009E, "DHE-RSA-AES128-GCM-SHA256" }, + { 0x009F, "DHE-RSA-AES256-GCM-SHA384" }, #else - { 0x0000, "DHE-RSA-AES128-GCM-SHA256"}, - { 0x0000, "DHE-RSA-AES256-GCM-SHA384"}, + { 0x0000, "DHE-RSA-AES128-GCM-SHA256" }, + { 0x0000, "DHE-RSA-AES256-GCM-SHA384" }, #endif #ifdef USE_MBEDTLS - { 0xCCAA, "DHE-RSA-CHACHA20-POLY1305"}, + { 0xCCAA, "DHE-RSA-CHACHA20-POLY1305" }, #else - { 0x0000, "DHE-RSA-CHACHA20-POLY1305"}, + { 0x0000, "DHE-RSA-CHACHA20-POLY1305" }, #endif #ifdef USE_MBEDTLS { 0xC023, "ECDHE-ECDSA-AES128-SHA256" }, diff --git a/tests/unit/unit3211.c b/tests/unit/unit3211.c index 7f6c616909c0..689edb7b2b3f 100644 --- a/tests/unit/unit3211.c +++ b/tests/unit/unit3211.c @@ -127,11 +127,12 @@ static CURLcode test_unit3211(const char *arg) { UNITTEST_BEGIN_SIMPLE - static const unsigned int s1[] = { /* spread numbers, some at slot edges */ - 0, 1, 4, 17, 63, 64, 65, 66, - 90, 99, + static const unsigned int s1[] = { + /* spread numbers, some at slot edges */ + 0, 1, 4, 17, 63, 64, 65, 66, 90, 99, }; - static const unsigned int s2[] = { /* set with all bits in slot1 set */ + static const unsigned int s2[] = { + /* set with all bits in slot1 set */ 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, diff --git a/tests/unit/unit3212.c b/tests/unit/unit3212.c index 0bffd1f79ce3..3af35f0c575b 100644 --- a/tests/unit/unit3212.c +++ b/tests/unit/unit3212.c @@ -28,7 +28,7 @@ #include "curl_trc.h" #include "unitprotos.h" -#define TBL_SIZE 100 +#define TBL_SIZE 100 static CURLcode t3212_setup(struct uint32_tbl *tbl) { diff --git a/tests/unit/unit3213.c b/tests/unit/unit3213.c index dbd26f4aa49c..c3ec3958e83e 100644 --- a/tests/unit/unit3213.c +++ b/tests/unit/unit3213.c @@ -96,11 +96,12 @@ static CURLcode test_unit3213(const char *arg) { UNITTEST_BEGIN_SIMPLE - static const unsigned int s1[] = { /* spread numbers, some at slot edges */ - 0, 1, 4, 17, 63, 64, 65, 66, - 90, 99, + static const unsigned int s1[] = { + /* spread numbers, some at slot edges */ + 0, 1, 4, 17, 63, 64, 65, 66, 90, 99, }; - static const unsigned int s2[] = { /* set with all bits in slot1 set */ + static const unsigned int s2[] = { + /* set with all bits in slot1 set */ 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, @@ -110,7 +111,8 @@ static CURLcode test_unit3213(const char *arg) 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, }; - static const unsigned int s3[] = { /* very spread numbers */ + static const unsigned int s3[] = { + /* very spread numbers */ 2232, 5167, 8204, 8526, 8641, 10056, 10140, 10611, 10998, 11626, 13735, 15539, 17947, 24295, 27833, 30318, }; From dfd781ff627991c7b660fe6534c347b1a97bcc17 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Fri, 21 Nov 2025 12:34:02 +0100 Subject: [PATCH 189/415] tidy-up: miscellaneous - gnutls, mbedtls: fix casing in log messages. - src/tool_cfgable.h: drop unused header. - appveyor.sh: variable style. - cmakelint.sh: sync with libssh2, catch `.cmake.in` explicitly. - examples: drop obsolete comments, exclamation marks. - fix comment typos, casing. Closes #19839 --- CMakeLists.txt | 4 ++-- appveyor.sh | 4 ++-- docs/examples/anyauthput.c | 2 +- docs/examples/http2-upload.c | 2 +- docs/examples/simplessl.c | 5 ----- lib/urldata.h | 8 ++++---- lib/vtls/gtls.c | 12 ++++++------ lib/vtls/mbedtls.c | 20 ++++++++++---------- packages/OS400/.checksrc | 2 +- scripts/cmakelint.sh | 2 +- src/tool_cfgable.h | 1 - 11 files changed, 28 insertions(+), 34 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b45e7859e090..685335667b9f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,9 +66,9 @@ project(CURL LANGUAGES C) # CMake does not recognize some targets accurately. Touch up configuration manually as a workaround. -if(WINDOWS_STORE AND MINGW) # mingw UWP build +if(WINDOWS_STORE AND MINGW) # MinGW UWP build # CMake (as of v3.31.2) gets confused and applies the MSVC rc.exe command-line - # template to windres. Reset it to the windres template via 'Modules/Platform/Windows-windres.cmake': + # template to windres. Reset it to the windres template as in 'Modules/Platform/Windows-windres.cmake': set(CMAKE_RC_COMPILE_OBJECT " -O coff ") elseif(DOS AND CMAKE_C_COMPILER_ID STREQUAL "GNU") # DJGPP set(CMAKE_STATIC_LIBRARY_PREFIX "lib") diff --git a/appveyor.sh b/appveyor.sh index 56f8cc35277a..bfcc2b9e5a72 100644 --- a/appveyor.sh +++ b/appveyor.sh @@ -45,8 +45,8 @@ if [ "${BUILD_SYSTEM}" = 'CMake' ]; then # Install custom cmake version if [ -n "${CMAKE_VERSION:-}" ]; then cmake_ver=$(printf '%02d%02d' \ - "$(echo "$CMAKE_VERSION" | cut -f1 -d.)" \ - "$(echo "$CMAKE_VERSION" | cut -f2 -d.)") + "$(echo "${CMAKE_VERSION}" | cut -f1 -d.)" \ + "$(echo "${CMAKE_VERSION}" | cut -f2 -d.)") if [ "${cmake_ver}" -ge '0320' ]; then fn="cmake-${CMAKE_VERSION}-windows-x86_64" else diff --git a/docs/examples/anyauthput.c b/docs/examples/anyauthput.c index 247d4d0d3b3a..5a650b64c721 100644 --- a/docs/examples/anyauthput.c +++ b/docs/examples/anyauthput.c @@ -150,7 +150,7 @@ int main(int argc, char **argv) /* tell libcurl we can use "any" auth, which lets the lib pick one, but it also costs one extra round-trip and possibly sending of all the PUT - data twice!!! */ + data twice */ curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY); /* set username and password for the authentication */ diff --git a/docs/examples/http2-upload.c b/docs/examples/http2-upload.c index e360127a44fd..0f1ed748ca1d 100644 --- a/docs/examples/http2-upload.c +++ b/docs/examples/http2-upload.c @@ -27,7 +27,7 @@ */ #ifdef _MSC_VER #ifndef _CRT_SECURE_NO_WARNINGS -#define _CRT_SECURE_NO_WARNINGS /* for '_snprintf(), fopen(), localtime(), +#define _CRT_SECURE_NO_WARNINGS /* for _snprintf(), fopen(), localtime(), strerror() */ #endif #endif diff --git a/docs/examples/simplessl.c b/docs/examples/simplessl.c index 3cf4b462bd50..d08da207bfbf 100644 --- a/docs/examples/simplessl.c +++ b/docs/examples/simplessl.c @@ -46,11 +46,6 @@ 4. if you do not use a crypto engine: 4.1. set pKeyName to the filename of your client key 4.2. if the format of the key file is DER, set pKeyType to "DER" - - !! verify of the server certificate is not implemented here !! - - **** This example only works with libcurl 7.9.3 and later! **** - */ int main(void) diff --git a/lib/urldata.h b/lib/urldata.h index 899dfff0f10b..bbab0130d318 100644 --- a/lib/urldata.h +++ b/lib/urldata.h @@ -276,13 +276,13 @@ struct ssl_config_data { char *key_type; /* format for private key (default: PEM) */ char *key_passwd; /* plain text private key password */ BIT(certinfo); /* gather lots of certificate info */ - BIT(earlydata); /* use tls1.3 early data */ + BIT(earlydata); /* use TLS 1.3 early data */ BIT(enable_beast); /* allow this flaw for interoperability's sake */ BIT(no_revoke); /* disable SSL certificate revocation checks */ BIT(no_partialchain); /* do not 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(native_ca_store); /* use the native CA store of operating system */ BIT(auto_client_cert); /* automatically locate and use a client certificate for authentication (Schannel) */ BIT(custom_cafile); /* application has set custom CA file */ @@ -1159,7 +1159,7 @@ enum dupstring { STRING_SSL_PINNEDPUBLICKEY, /* public key file to verify peer against */ STRING_SSL_CIPHER_LIST, /* list of ciphers to use */ STRING_SSL_CIPHER13_LIST, /* list of TLS 1.3 ciphers to use */ - STRING_SSL_CRLFILE, /* crl file to check certificate */ + STRING_SSL_CRLFILE, /* CRL file to check certificate */ STRING_SSL_ISSUERCERT, /* issuer cert file to check certificate */ STRING_SERVICE_NAME, /* Service name */ #ifndef CURL_DISABLE_PROXY @@ -1173,7 +1173,7 @@ enum dupstring { STRING_SSL_PINNEDPUBLICKEY_PROXY, /* public key file to verify proxy */ STRING_SSL_CIPHER_LIST_PROXY, /* list of ciphers to use */ STRING_SSL_CIPHER13_LIST_PROXY, /* list of TLS 1.3 ciphers to use */ - STRING_SSL_CRLFILE_PROXY, /* crl file to check certificate */ + STRING_SSL_CRLFILE_PROXY, /* CRL file to check certificate */ STRING_SSL_ISSUERCERT_PROXY, /* issuer cert file to check certificate */ STRING_PROXY_SERVICE_NAME, /* Proxy service name */ #endif diff --git a/lib/vtls/gtls.c b/lib/vtls/gtls.c index e0ba48422b22..667b09c119fa 100644 --- a/lib/vtls/gtls.c +++ b/lib/vtls/gtls.c @@ -386,7 +386,7 @@ gnutls_set_ssl_version_min_max(struct Curl_easy *data, return CURLE_OK; } - failf(data, "GnuTLS: cannot set ssl protocol"); + failf(data, "GnuTLS: cannot set TLS protocol"); return CURLE_SSL_CONNECT_ERROR; } @@ -460,7 +460,7 @@ static CURLcode gtls_populate_creds(struct Curl_cfilter *cf, #else rc = gnutls_certificate_set_x509_system_trust(creds); if(rc < 0) - infof(data, "error reading native ca store (%s), continuing anyway", + infof(data, "error reading native CA store (%s), continuing anyway", gnutls_strerror(rc)); else { infof(data, " Native: %d certificates from system trust", rc); @@ -483,7 +483,7 @@ static CURLcode gtls_populate_creds(struct Curl_cfilter *cf, GNUTLS_X509_FMT_PEM); creds_are_empty = creds_are_empty && (rc <= 0); if(rc < 0) { - infof(data, "error reading ca cert blob (%s)%s", gnutls_strerror(rc), + infof(data, "error reading CA cert blob (%s)%s", gnutls_strerror(rc), (creds_are_empty ? "" : ", continuing anyway")); if(creds_are_empty) { ssl_config->certverifyresult = rc; @@ -504,7 +504,7 @@ static CURLcode gtls_populate_creds(struct Curl_cfilter *cf, GNUTLS_X509_FMT_PEM); creds_are_empty = creds_are_empty && (rc <= 0); if(rc < 0) { - infof(data, "error reading ca cert file %s (%s)%s", + infof(data, "error reading CA cert file %s (%s)%s", config->CAfile, gnutls_strerror(rc), (creds_are_empty ? "" : ", continuing anyway")); if(creds_are_empty) { @@ -522,7 +522,7 @@ static CURLcode gtls_populate_creds(struct Curl_cfilter *cf, GNUTLS_X509_FMT_PEM); creds_are_empty = creds_are_empty && (rc <= 0); if(rc < 0) { - infof(data, "error reading ca cert file %s (%s)%s", + infof(data, "error reading CA cert file %s (%s)%s", config->CApath, gnutls_strerror(rc), (creds_are_empty ? "" : ", continuing anyway")); if(creds_are_empty) { @@ -542,7 +542,7 @@ static CURLcode gtls_populate_creds(struct Curl_cfilter *cf, rc = gnutls_certificate_set_x509_crl_file(creds, config->CRLfile, GNUTLS_X509_FMT_PEM); if(rc < 0) { - failf(data, "error reading crl file %s (%s)", + failf(data, "error reading CRL file %s (%s)", config->CRLfile, gnutls_strerror(rc)); return CURLE_SSL_CRL_BADFILE; } diff --git a/lib/vtls/mbedtls.c b/lib/vtls/mbedtls.c index d33167037162..4eb10d690e5d 100644 --- a/lib/vtls/mbedtls.c +++ b/lib/vtls/mbedtls.c @@ -597,7 +597,7 @@ static CURLcode mbed_connect_step1(struct Curl_cfilter *cf, curlx_free(newblob); if(ret < 0) { mbedtls_strerror(ret, errorbuf, sizeof(errorbuf)); - failf(data, "Error importing ca cert blob - mbedTLS: (-0x%04X) %s", + failf(data, "Error importing CA cert blob - mbedTLS: (-0x%04X) %s", -ret, errorbuf); return CURLE_SSL_CERTPROBLEM; } @@ -609,12 +609,12 @@ static CURLcode mbed_connect_step1(struct Curl_cfilter *cf, if(ret < 0) { mbedtls_strerror(ret, errorbuf, sizeof(errorbuf)); - failf(data, "Error reading ca cert file %s - mbedTLS: (-0x%04X) %s", + failf(data, "Error reading CA cert file %s - mbedTLS: (-0x%04X) %s", ssl_cafile, -ret, errorbuf); return CURLE_SSL_CACERT_BADFILE; } #else - failf(data, "mbedtls: functions that use the file system not built in"); + failf(data, "mbedTLS: functions that use the file system not built in"); return CURLE_NOT_BUILT_IN; #endif } @@ -625,14 +625,14 @@ static CURLcode mbed_connect_step1(struct Curl_cfilter *cf, if(ret < 0) { mbedtls_strerror(ret, errorbuf, sizeof(errorbuf)); - failf(data, "Error reading ca cert path %s - mbedTLS: (-0x%04X) %s", + failf(data, "Error reading CA cert path %s - mbedTLS: (-0x%04X) %s", ssl_capath, -ret, errorbuf); if(verifypeer) return CURLE_SSL_CACERT_BADFILE; } #else - failf(data, "mbedtls: functions that use the file system not built in"); + failf(data, "mbedTLS: functions that use the file system not built in"); return CURLE_NOT_BUILT_IN; #endif } @@ -652,7 +652,7 @@ static CURLcode mbed_connect_step1(struct Curl_cfilter *cf, return CURLE_SSL_CERTPROBLEM; } #else - failf(data, "mbedtls: functions that use the file system not built in"); + failf(data, "mbedTLS: functions that use the file system not built in"); return CURLE_NOT_BUILT_IN; #endif } @@ -710,7 +710,7 @@ static CURLcode mbed_connect_step1(struct Curl_cfilter *cf, return CURLE_SSL_CERTPROBLEM; } #else - failf(data, "mbedtls: functions that use the file system not built in"); + failf(data, "mbedTLS: functions that use the file system not built in"); return CURLE_NOT_BUILT_IN; #endif } @@ -766,13 +766,13 @@ static CURLcode mbed_connect_step1(struct Curl_cfilter *cf, return CURLE_SSL_CRL_BADFILE; } #else - failf(data, "mbedtls: functions that use the file system not built in"); + failf(data, "mbedTLS: functions that use the file system not built in"); return CURLE_NOT_BUILT_IN; #endif } #else if(ssl_crlfile) { - failf(data, "mbedtls: crl support not built in"); + failf(data, "mbedTLS: CRL support not built in"); return CURLE_NOT_BUILT_IN; } #endif @@ -1161,7 +1161,7 @@ static CURLcode mbed_send(struct Curl_cfilter *cf, struct Curl_easy *data, DEBUGASSERT(backend); *pnwritten = 0; connssl->io_need = CURL_SSL_IO_NEED_NONE; - /* mbedtls is picky when a mbedtls_ssl_write) was previously blocked. + /* mbedTLS is picky when a mbedtls_ssl_write() was previously blocked. * It requires to be called with the same amount of bytes again, or it * will lose bytes, e.g. reporting all was sent but they were not. * Remember the blocked length and use that when set. */ diff --git a/packages/OS400/.checksrc b/packages/OS400/.checksrc index aae405506b9e..3bd88ff1e7db 100644 --- a/packages/OS400/.checksrc +++ b/packages/OS400/.checksrc @@ -2,7 +2,7 @@ # # SPDX-License-Identifier: curl -# Possible not what we want, but cannot test, just silence the warnings +# Possibly not what we want, but cannot test, just silence the warnings allowfunc calloc allowfunc free allowfunc malloc diff --git a/scripts/cmakelint.sh b/scripts/cmakelint.sh index 1e1cc592ed3f..a9bd7472d479 100755 --- a/scripts/cmakelint.sh +++ b/scripts/cmakelint.sh @@ -52,7 +52,7 @@ cd "$(dirname "$0")"/.. # strip off the leading ./ to make the grep regexes work properly find . -type f | sed 's@^\./@@' fi -} | grep -E '(^CMake|/CMake|\.cmake$)' | grep -v -E '(\.h\.cmake|\.c)$' \ +} | grep -E '(^CMake|/CMake|\.cmake$|\.cmake\.in$)' | grep -v -E '(\.h\.cmake|\.c)$' \ | xargs \ cmake-lint \ --suppress-decorations \ diff --git a/src/tool_cfgable.h b/src/tool_cfgable.h index 5652229d4b79..d02635ce244e 100644 --- a/src/tool_cfgable.h +++ b/src/tool_cfgable.h @@ -24,7 +24,6 @@ * ***************************************************************************/ -#include #include "tool_setup.h" #include "tool_sdecls.h" #include "tool_urlglob.h" From f97e62ff147feff09e1a29a2db6b4a7f928d75a0 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Tue, 2 Dec 2025 17:45:18 +0100 Subject: [PATCH 190/415] sws: fix binding to unix socket on Windows Windows 10.17063+ (having unix socket support) fails to set for unix sockets the `SO_REUSEADDR` option, with error 10045 (`WSAEOPNOTSUPP`), and also fails to set `SO_KEEPALIVE` with error 10042 (`WSAENOPROTOOPT`). Fix by not enabling these socket options on Windows for unix sockets. Also: - fixing test 1435, 1436 to run in CI. - fixing the `socksd` test server for test 1467, 1468, 1470. But, also disable these for now due to another Windows issue: #19825 Ref: https://stackoverflow.com/questions/68791319/unix-domain-socket-bind-failed-in-windows/68794755#68794755 Ref: #19810 Closes #19812 --- tests/data/test1467 | 2 ++ tests/data/test1468 | 2 ++ tests/data/test1470 | 2 ++ tests/server/sws.c | 39 ++++++++++++++++--------- tests/server/util.c | 70 ++++++++++++++++++++++++--------------------- 5 files changed, 70 insertions(+), 45 deletions(-) diff --git a/tests/data/test1467 b/tests/data/test1467 index 69b04d8bf485..46cb69059ba5 100644 --- a/tests/data/test1467 +++ b/tests/data/test1467 @@ -30,9 +30,11 @@ Funny-head: yesyes # # Client-side +# --socks5 cannot accept Windows absolute paths proxy UnixSockets +!win32 http diff --git a/tests/data/test1468 b/tests/data/test1468 index 7cb9b1345629..1ed654adcc8a 100644 --- a/tests/data/test1468 +++ b/tests/data/test1468 @@ -31,9 +31,11 @@ Funny-head: yesyes # # Client-side +# --socks5h cannot accept Windows absolute paths proxy UnixSockets +!win32 http diff --git a/tests/data/test1470 b/tests/data/test1470 index c93af27f7db3..691fcc9a44cc 100644 --- a/tests/data/test1470 +++ b/tests/data/test1470 @@ -32,9 +32,11 @@ Funny-head: yesyes # # Client-side +# --proxy cannot accept Windows absolute paths proxy UnixSockets +!win32 https diff --git a/tests/server/sws.c b/tests/server/sws.c index 56135a832636..c7ce24922418 100644 --- a/tests/server/sws.c +++ b/tests/server/sws.c @@ -1863,14 +1863,20 @@ static curl_socket_t accept_connection(curl_socket_t sock) return CURL_SOCKET_BAD; } - if(setsockopt(msgsock, SOL_SOCKET, SO_KEEPALIVE, - (void *)&flag, sizeof(flag))) { - error = SOCKERRNO; - logmsg("setsockopt(SO_KEEPALIVE) failed with error (%d) %s", - error, curlx_strerror(error, errbuf, sizeof(errbuf))); - sclose(msgsock); - return CURL_SOCKET_BAD; +#if defined(_WIN32) && defined(USE_UNIX_SOCKETS) + if(socket_domain != AF_UNIX) { +#endif + if(setsockopt(msgsock, SOL_SOCKET, SO_KEEPALIVE, + (void *)&flag, sizeof(flag))) { + error = SOCKERRNO; + logmsg("setsockopt(SO_KEEPALIVE) failed with error (%d) %s", + error, curlx_strerror(error, errbuf, sizeof(errbuf))); + sclose(msgsock); + return CURL_SOCKET_BAD; + } +#if defined(_WIN32) && defined(USE_UNIX_SOCKETS) } +#endif /* ** As soon as this server accepts a connection from the test harness it @@ -2176,13 +2182,20 @@ static int test_sws(int argc, char *argv[]) goto sws_cleanup; } - flag = 1; - if(setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void *)&flag, sizeof(flag))) { - error = SOCKERRNO; - logmsg("setsockopt(SO_REUSEADDR) failed with error (%d) %s", - error, curlx_strerror(error, errbuf, sizeof(errbuf))); - goto sws_cleanup; +#if defined(_WIN32) && defined(USE_UNIX_SOCKETS) + if(socket_domain != AF_UNIX) { +#endif + flag = 1; + if(setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, + (void *)&flag, sizeof(flag))) { + error = SOCKERRNO; + logmsg("setsockopt(SO_REUSEADDR) failed with error (%d) %s", + error, curlx_strerror(error, errbuf, sizeof(errbuf))); + goto sws_cleanup; + } +#if defined(_WIN32) && defined(USE_UNIX_SOCKETS) } +#endif if(curlx_nonblock(sock, TRUE)) { error = SOCKERRNO; logmsg("curlx_nonblock failed with error (%d) %s", diff --git a/tests/server/util.c b/tests/server/util.c index 624826571a9f..b021aa43dc91 100644 --- a/tests/server/util.c +++ b/tests/server/util.c @@ -763,42 +763,48 @@ curl_socket_t sockdaemon(curl_socket_t sock, (void)unix_socket; #endif - do { - attempt++; - flag = 1; - rc = setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, - (void *)&flag, sizeof(flag)); - if(rc) { - error = SOCKERRNO; - logmsg("setsockopt(SO_REUSEADDR) failed with error (%d) %s", - error, curlx_strerror(error, errbuf, sizeof(errbuf))); - if(maxretr) { - rc = curlx_wait_ms(delay); - if(rc) { - /* should not happen */ - error = SOCKERRNO; - logmsg("curlx_wait_ms() failed with error (%d) %s", - error, curlx_strerror(error, errbuf, sizeof(errbuf))); - sclose(sock); - return CURL_SOCKET_BAD; - } - if(got_exit_signal) { - logmsg("signalled to die, exiting..."); - sclose(sock); - return CURL_SOCKET_BAD; +#if defined(_WIN32) && defined(USE_UNIX_SOCKETS) + if(socket_domain != AF_UNIX) { +#endif + do { + attempt++; + flag = 1; + rc = setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, + (void *)&flag, sizeof(flag)); + if(rc) { + error = SOCKERRNO; + logmsg("setsockopt(SO_REUSEADDR) failed with error (%d) %s", + error, curlx_strerror(error, errbuf, sizeof(errbuf))); + if(maxretr) { + rc = curlx_wait_ms(delay); + if(rc) { + /* should not happen */ + error = SOCKERRNO; + logmsg("curlx_wait_ms() failed with error (%d) %s", + error, curlx_strerror(error, errbuf, sizeof(errbuf))); + sclose(sock); + return CURL_SOCKET_BAD; + } + if(got_exit_signal) { + logmsg("signalled to die, exiting..."); + sclose(sock); + return CURL_SOCKET_BAD; + } + totdelay += delay; + delay *= 2; /* double the sleep for next attempt */ } - totdelay += delay; - delay *= 2; /* double the sleep for next attempt */ } - } - } while(rc && maxretr--); + } while(rc && maxretr--); - if(rc) { - logmsg("setsockopt(SO_REUSEADDR) failed %d times in %d ms. Error (%d) %s", - attempt, totdelay, - error, curlx_strerror(error, errbuf, sizeof(errbuf))); - logmsg("Continuing anyway..."); + if(rc) { + logmsg("setsockopt(SO_REUSEADDR) failed %d times in %d ms. " + "Error (%d) %s", attempt, totdelay, + error, curlx_strerror(error, errbuf, sizeof(errbuf))); + logmsg("Continuing anyway..."); + } +#if defined(_WIN32) && defined(USE_UNIX_SOCKETS) } +#endif /* When the specified listener port is zero, it is actually a request to let the system choose a non-zero available port. */ From df07f431e2077881b13e655083a3929242615056 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Sat, 29 Nov 2025 10:54:28 +0100 Subject: [PATCH 191/415] mbedtls: sync format across log messages Closes #19842 --- lib/vtls/mbedtls.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/vtls/mbedtls.c b/lib/vtls/mbedtls.c index 4eb10d690e5d..49c557de0311 100644 --- a/lib/vtls/mbedtls.c +++ b/lib/vtls/mbedtls.c @@ -597,7 +597,7 @@ static CURLcode mbed_connect_step1(struct Curl_cfilter *cf, curlx_free(newblob); if(ret < 0) { mbedtls_strerror(ret, errorbuf, sizeof(errorbuf)); - failf(data, "Error importing CA cert blob - mbedTLS: (-0x%04X) %s", + failf(data, "mbedTLS: error importing CA cert blob: (-0x%04X) %s", -ret, errorbuf); return CURLE_SSL_CERTPROBLEM; } @@ -609,7 +609,7 @@ static CURLcode mbed_connect_step1(struct Curl_cfilter *cf, if(ret < 0) { mbedtls_strerror(ret, errorbuf, sizeof(errorbuf)); - failf(data, "Error reading CA cert file %s - mbedTLS: (-0x%04X) %s", + failf(data, "mbedTLS: error reading CA cert file %s: (-0x%04X) %s", ssl_cafile, -ret, errorbuf); return CURLE_SSL_CACERT_BADFILE; } @@ -625,7 +625,7 @@ static CURLcode mbed_connect_step1(struct Curl_cfilter *cf, if(ret < 0) { mbedtls_strerror(ret, errorbuf, sizeof(errorbuf)); - failf(data, "Error reading CA cert path %s - mbedTLS: (-0x%04X) %s", + failf(data, "mbedTLS: error reading CA cert path %s: (-0x%04X) %s", ssl_capath, -ret, errorbuf); if(verifypeer) @@ -646,7 +646,7 @@ static CURLcode mbed_connect_step1(struct Curl_cfilter *cf, if(ret) { mbedtls_strerror(ret, errorbuf, sizeof(errorbuf)); - failf(data, "Error reading client cert file %s - mbedTLS: (-0x%04X) %s", + failf(data, "mbedTLS: error reading client cert file %s: (-0x%04X) %s", ssl_cert, -ret, errorbuf); return CURLE_SSL_CERTPROBLEM; @@ -671,7 +671,7 @@ static CURLcode mbed_connect_step1(struct Curl_cfilter *cf, if(ret) { mbedtls_strerror(ret, errorbuf, sizeof(errorbuf)); - failf(data, "Error reading client cert data %s - mbedTLS: (-0x%04X) %s", + failf(data, "mbedTLS: error reading client cert data %s: (-0x%04X) %s", ssl_config->key, -ret, errorbuf); return CURLE_SSL_CERTPROBLEM; } @@ -705,7 +705,7 @@ static CURLcode mbed_connect_step1(struct Curl_cfilter *cf, if(ret) { mbedtls_strerror(ret, errorbuf, sizeof(errorbuf)); - failf(data, "Error reading private key %s - mbedTLS: (-0x%04X) %s", + failf(data, "mbedTLS: error reading private key %s: (-0x%04X) %s", ssl_config->key, -ret, errorbuf); return CURLE_SSL_CERTPROBLEM; } @@ -743,7 +743,7 @@ static CURLcode mbed_connect_step1(struct Curl_cfilter *cf, if(ret) { mbedtls_strerror(ret, errorbuf, sizeof(errorbuf)); - failf(data, "Error parsing private key - mbedTLS: (-0x%04X) %s", + failf(data, "mbedTLS: error parsing private key: (-0x%04X) %s", -ret, errorbuf); return CURLE_SSL_CERTPROBLEM; } @@ -760,7 +760,7 @@ static CURLcode mbed_connect_step1(struct Curl_cfilter *cf, if(ret) { mbedtls_strerror(ret, errorbuf, sizeof(errorbuf)); - failf(data, "Error reading CRL file %s - mbedTLS: (-0x%04X) %s", + failf(data, "mbedTLS: error reading CRL file %s: (-0x%04X) %s", ssl_crlfile, -ret, errorbuf); return CURLE_SSL_CRL_BADFILE; @@ -822,7 +822,7 @@ static CURLcode mbed_connect_step1(struct Curl_cfilter *cf, ret = mbedtls_ssl_setup(&backend->ssl, &backend->config); if(ret) { mbedtls_strerror(ret, errorbuf, sizeof(errorbuf)); - failf(data, "ssl_setup failed - mbedTLS: (-0x%04X) %s", + failf(data, "mbedTLS: ssl_setup failed: (-0x%04X) %s", -ret, errorbuf); return CURLE_SSL_CONNECT_ERROR; } From 6d042273cde6e4f0fd3ea0af25b37c96356ac9c6 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Thu, 4 Dec 2025 20:28:34 +0100 Subject: [PATCH 192/415] openssl: simplify `HAVE_KEYLOG_CALLBACK` guard non-LibreSSL always includes BoringSSL and AWS-LC, no need to check for them explicitly. Follow-up to 69c89bf3d3137fcbb2b8bc57233182adcf1e2817 #18330 Closes #19843 --- lib/vtls/openssl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/vtls/openssl.h b/lib/vtls/openssl.h index ff8246b4fae3..c3ba67a8ff41 100644 --- a/lib/vtls/openssl.h +++ b/lib/vtls/openssl.h @@ -51,7 +51,7 @@ * BoringSSL: supported since d28f59c27bac (committed 2015-11-19) * LibreSSL: not supported. 3.5.0+ has a stub function that does nothing. */ -#if !defined(LIBRESSL_VERSION_NUMBER) || defined(HAVE_BORINGSSL_LIKE) +#ifndef LIBRESSL_VERSION_NUMBER #define HAVE_KEYLOG_CALLBACK #endif From ebe6fa08c9df12aa1c66cacf49a6e503a6e45d02 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Thu, 4 Dec 2025 20:11:45 +0100 Subject: [PATCH 193/415] docs/libcurl: fix C formatting nits Closes #19844 --- docs/libcurl/curl_easy_nextheader.md | 2 +- docs/libcurl/curl_easy_pause.md | 1 - docs/libcurl/curl_formadd.md | 2 +- docs/libcurl/curl_formget.md | 4 +-- docs/libcurl/curl_mime_data_cb.md | 2 +- docs/libcurl/curl_mprintf.md | 2 +- docs/libcurl/curl_multi_fdset.md | 2 +- docs/libcurl/curl_ws_meta.md | 4 +-- docs/libcurl/libcurl-tutorial.md | 32 +++++++++++----------- docs/libcurl/opts/CURLINFO_USED_PROXY.md | 2 +- docs/libcurl/opts/CURLOPT_COOKIELIST.md | 2 +- docs/libcurl/opts/CURLOPT_SOCKS5_AUTH.md | 2 +- docs/libcurl/opts/CURLOPT_WRITEFUNCTION.md | 2 +- 13 files changed, 28 insertions(+), 31 deletions(-) diff --git a/docs/libcurl/curl_easy_nextheader.md b/docs/libcurl/curl_easy_nextheader.md index 2dbdf61ccdbd..c3dd223b8c8c 100644 --- a/docs/libcurl/curl_easy_nextheader.md +++ b/docs/libcurl/curl_easy_nextheader.md @@ -83,7 +83,7 @@ int main(void) } /* extract the normal headers + 1xx + trailers from the last request */ - unsigned int origin = CURLH_HEADER| CURLH_1XX | CURLH_TRAILER; + unsigned int origin = CURLH_HEADER | CURLH_1XX | CURLH_TRAILER; while((h = curl_easy_nextheader(curl, origin, -1, prev))) { printf("%s: %s\n", h->name, h->value); prev = h; diff --git a/docs/libcurl/curl_easy_pause.md b/docs/libcurl/curl_easy_pause.md index 2f47c4ef3f7f..b6390058e89a 100644 --- a/docs/libcurl/curl_easy_pause.md +++ b/docs/libcurl/curl_easy_pause.md @@ -109,7 +109,6 @@ int main(void) if(curl) { /* pause a transfer in both directions */ curl_easy_pause(curl, CURLPAUSE_RECV | CURLPAUSE_SEND); - } } ~~~ diff --git a/docs/libcurl/curl_formadd.md b/docs/libcurl/curl_formadd.md index f35e50eab754..ca05f4310aff 100644 --- a/docs/libcurl/curl_formadd.md +++ b/docs/libcurl/curl_formadd.md @@ -225,7 +225,7 @@ int main(void) char file2[] = "your-face.jpg"; /* add null character into htmlbuffer, to demonstrate that transfers of buffers containing null characters actually work - */ + */ htmlbuffer[8] = '\0'; /* Add simple name/content section */ diff --git a/docs/libcurl/curl_formget.md b/docs/libcurl/curl_formget.md index 264eb5cbcbb3..316609e93a97 100644 --- a/docs/libcurl/curl_formget.md +++ b/docs/libcurl/curl_formget.md @@ -54,7 +54,7 @@ This, because first then does libcurl known which actual read callback to use. size_t print_httppost_callback(void *arg, const char *buf, size_t len) { fwrite(buf, len, 1, stdout); - (*(size_t *) arg) += len; + (*(size_t *)arg) += len; return len; } @@ -62,7 +62,7 @@ size_t print_httppost(struct curl_httppost *post) { size_t total_size = 0; if(curl_formget(post, &total_size, print_httppost_callback)) { - return (size_t) -1; + return (size_t)-1; } return total_size; } diff --git a/docs/libcurl/curl_mime_data_cb.md b/docs/libcurl/curl_mime_data_cb.md index 9b3fdd5593bd..bed7c5d78f47 100644 --- a/docs/libcurl/curl_mime_data_cb.md +++ b/docs/libcurl/curl_mime_data_cb.md @@ -120,7 +120,7 @@ struct ctl { size_t read_callback(char *buffer, size_t size, size_t nitems, void *arg) { - struct ctl *p = (struct ctl *) arg; + struct ctl *p = (struct ctl *)arg; curl_off_t sz = p->size - p->position; nitems *= size; diff --git a/docs/libcurl/curl_mprintf.md b/docs/libcurl/curl_mprintf.md index a592cfb3e661..508dece91974 100644 --- a/docs/libcurl/curl_mprintf.md +++ b/docs/libcurl/curl_mprintf.md @@ -274,7 +274,7 @@ const char *name = "John"; int main(void) { curl_mprintf("My name is %s\n", name); - curl_mprintf("Pi is almost %f\n", (double)25.0/8); + curl_mprintf("Pi is almost %f\n", (double)25.0 / 8); } ~~~ diff --git a/docs/libcurl/curl_multi_fdset.md b/docs/libcurl/curl_multi_fdset.md index 1396738014c3..24d6664f4998 100644 --- a/docs/libcurl/curl_multi_fdset.md +++ b/docs/libcurl/curl_multi_fdset.md @@ -92,7 +92,7 @@ int main(void) int maxfd; int rc; CURLMcode mc; - struct timeval timeout = {1, 0}; + struct timeval timeout = { 1, 0 }; CURLM *multi = curl_multi_init(); diff --git a/docs/libcurl/curl_ws_meta.md b/docs/libcurl/curl_ws_meta.md index e34e5476764a..978520afd8d0 100644 --- a/docs/libcurl/curl_ws_meta.md +++ b/docs/libcurl/curl_ws_meta.md @@ -137,8 +137,7 @@ struct customdata { void *ptr; }; -static size_t writecb(char *buffer, - size_t size, size_t nitems, void *p) +static size_t writecb(char *buffer, size_t size, size_t nitems, void *p) { struct customdata *c = (struct customdata *)p; const struct curl_ws_frame *m = curl_ws_meta(c->easy); @@ -158,7 +157,6 @@ int main(void) curl_easy_setopt(curl, CURLOPT_WRITEDATA, &custom); curl_easy_perform(curl); - } return 0; } diff --git a/docs/libcurl/libcurl-tutorial.md b/docs/libcurl/libcurl-tutorial.md index e515b3b7b067..7b01d234c4c9 100644 --- a/docs/libcurl/libcurl-tutorial.md +++ b/docs/libcurl/libcurl-tutorial.md @@ -448,7 +448,7 @@ claims to support. This method does however add a round-trip since libcurl must first ask the server what it supports: ~~~c - curl_easy_setopt(handle, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST|CURLAUTH_BASIC); + curl_easy_setopt(handle, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST | CURLAUTH_BASIC); ~~~ For convenience, you can use the *CURLAUTH_ANY* define (instead of a list with @@ -468,7 +468,7 @@ pages using the \ tag uses. We provide a pointer to the data and tell libcurl to post it all to the remote site: ~~~c - char *data="name=daniel&project=curl"; + char *data = "name=daniel&project=curl"; curl_easy_setopt(handle, CURLOPT_POSTFIELDS, data); curl_easy_setopt(handle, CURLOPT_URL, "http://posthere.com/"); @@ -487,7 +487,7 @@ done in a generic way, by building a list of our own headers and then passing that list to libcurl. ~~~c - struct curl_slist *headers=NULL; + struct curl_slist *headers = NULL; headers = curl_slist_append(headers, "Content-Type: text/xml"); /* post binary data */ @@ -574,8 +574,8 @@ parts, you post the whole form. The MIME API example above is expressed as follows using this function: ~~~c - struct curl_httppost *post=NULL; - struct curl_httppost *last=NULL; + struct curl_httppost *post = NULL; + struct curl_httppost *last = NULL; curl_formadd(&post, &last, CURLFORM_COPYNAME, "name", CURLFORM_COPYCONTENTS, "daniel", CURLFORM_END); @@ -605,7 +605,7 @@ shows how you set headers to one specific part when you add that to the post handle: ~~~c - struct curl_slist *headers=NULL; + struct curl_slist *headers = NULL; headers = curl_slist_append(headers, "Content-Type: text/xml"); curl_formadd(&post, &last, @@ -675,7 +675,7 @@ becomes: ~~~c part = curl_mime_addpart(multipart); curl_mime_name(part, "logotype-image"); - curl_mime_data_cb(part, (curl_off_t) -1, fread, fseek, NULL, stdin); + curl_mime_data_cb(part, (curl_off_t)-1, fread, fseek, NULL, stdin); ~~~ curl_mime_name(3) always copies the field name. The special filename "-" is @@ -717,7 +717,7 @@ becomes: ~~~c part = curl_mime_addpart(multipart); curl_mime_name(part, "stream"); - curl_mime_data_cb(part, (curl_off_t) datasize, + curl_mime_data_cb(part, (curl_off_t)datasize, myreadfunc, NULL, NULL, arg); curl_mime_filename(part, "archive.zip"); curl_mime_type(part, "application/zip"); @@ -738,7 +738,7 @@ becomes: ~~~c part = curl_mime_addpart(multipart); curl_mime_name(part, "memfile"); - curl_mime_data(part, databuffer, (curl_off_t) sizeof databuffer); + curl_mime_data(part, databuffer, (curl_off_t)sizeof(databuffer)); curl_mime_filename(part, "memfile.bin"); ~~~ @@ -802,12 +802,12 @@ Example C++ code: ~~~c class AClass { - static size_t write_data(void *ptr, size_t size, size_t nmemb, - void *ourpointer) - { - /* do what you want with the data */ - } - } + static size_t write_data(void *ptr, size_t size, size_t nmemb, + void *ourpointer) + { + /* do what you want with the data */ + } +} ~~~ # Proxies @@ -1046,7 +1046,7 @@ request, and you are free to pass any amount of extra headers that you think fit. Adding headers is this easy: ~~~c -struct curl_slist *headers=NULL; /* init to NULL is important */ +struct curl_slist *headers = NULL; /* init to NULL is important */ headers = curl_slist_append(headers, "Hey-server-hey: how are you?"); headers = curl_slist_append(headers, "X-silly-content: yes"); diff --git a/docs/libcurl/opts/CURLINFO_USED_PROXY.md b/docs/libcurl/opts/CURLINFO_USED_PROXY.md index 01ef3610db0e..3d652c73b016 100644 --- a/docs/libcurl/opts/CURLINFO_USED_PROXY.md +++ b/docs/libcurl/opts/CURLINFO_USED_PROXY.md @@ -53,7 +53,7 @@ int main(int argc, char *argv[]) long used; res = curl_easy_getinfo(curl, CURLINFO_USED_PROXY, &used); if(!res) { - printf("The proxy was %sused\n", used ? "": "NOT "); + printf("The proxy was %sused\n", used ? "" : "NOT "); } } curl_easy_cleanup(curl); diff --git a/docs/libcurl/opts/CURLOPT_COOKIELIST.md b/docs/libcurl/opts/CURLOPT_COOKIELIST.md index a2c43d8dfe2d..5124a53e64b6 100644 --- a/docs/libcurl/opts/CURLOPT_COOKIELIST.md +++ b/docs/libcurl/opts/CURLOPT_COOKIELIST.md @@ -77,7 +77,7 @@ NULL ~~~c /* an inline import of a cookie in Netscape format. */ -#define SEP "\t" /* Tab separates the fields */ +#define SEP "\t" /* Tab separates the fields */ int main(void) { diff --git a/docs/libcurl/opts/CURLOPT_SOCKS5_AUTH.md b/docs/libcurl/opts/CURLOPT_SOCKS5_AUTH.md index a9adf6b77d5a..826fc4c1f2b3 100644 --- a/docs/libcurl/opts/CURLOPT_SOCKS5_AUTH.md +++ b/docs/libcurl/opts/CURLOPT_SOCKS5_AUTH.md @@ -35,7 +35,7 @@ password with the CURLOPT_PROXYUSERPWD(3) option. # DEFAULT -CURLAUTH_BASIC|CURLAUTH_GSSAPI +CURLAUTH_BASIC | CURLAUTH_GSSAPI # %PROTOCOLS% diff --git a/docs/libcurl/opts/CURLOPT_WRITEFUNCTION.md b/docs/libcurl/opts/CURLOPT_WRITEFUNCTION.md index 973a0aea754e..ad4b4e0360f3 100644 --- a/docs/libcurl/opts/CURLOPT_WRITEFUNCTION.md +++ b/docs/libcurl/opts/CURLOPT_WRITEFUNCTION.md @@ -106,7 +106,7 @@ static size_t cb(char *data, size_t size, size_t nmemb, void *clientp) int main(void) { - struct memory chunk = {0}; + struct memory chunk = { 0 }; CURLcode res; CURL *curl = curl_easy_init(); if(curl) { From a1531261b1ed6d0936646794cc169eb6f55bf3ff Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 4 Dec 2025 19:57:44 +0100 Subject: [PATCH 194/415] CURLMOPT_SOCKETFUNCTION.md: fix the callback argument use The example code does not use curl_multi_assign(), but its callback function used socketp (called sockp in the function) to get the struct priv pointer instead of the correct clientp (cbp). Reported-by: Greg Hudson Fixes #19840 Closes #19841 --- docs/libcurl/opts/CURLMOPT_SOCKETFUNCTION.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/libcurl/opts/CURLMOPT_SOCKETFUNCTION.md b/docs/libcurl/opts/CURLMOPT_SOCKETFUNCTION.md index fae15d58a2a9..411b856e9328 100644 --- a/docs/libcurl/opts/CURLMOPT_SOCKETFUNCTION.md +++ b/docs/libcurl/opts/CURLMOPT_SOCKETFUNCTION.md @@ -109,7 +109,7 @@ struct priv { static int sock_cb(CURL *e, curl_socket_t s, int what, void *cbp, void *sockp) { - struct priv *p = sockp; + struct priv *p = cbp; printf("our ptr: %p\n", p->ours); if(what == CURL_POLL_REMOVE) { From f1f76e0ea83921000f228ce49748047e33e1e46d Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 4 Dec 2025 19:01:02 +0100 Subject: [PATCH 195/415] url: if curl_url_get() fails due to OOM, error out properly Even if the scheme is "file"! Closes #19838 --- lib/url.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/url.c b/lib/url.c index 043d7ca72cb3..0643ceea7f8c 100644 --- a/lib/url.c +++ b/lib/url.c @@ -1919,7 +1919,8 @@ static CURLcode parseurlandfillconn(struct Curl_easy *data, uc = curl_url_get(uh, CURLUPART_PORT, &data->state.up.port, CURLU_DEFAULT_PORT); if(uc) { - if(!curl_strequal("file", data->state.up.scheme)) + if((uc == CURLUE_OUT_OF_MEMORY) || + !curl_strequal("file", data->state.up.scheme)) return CURLE_OUT_OF_MEMORY; } else { From 859ce48de12986f5bf846c2800dacab893ff12c1 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Thu, 4 Dec 2025 15:32:44 +0100 Subject: [PATCH 196/415] ldap: detect version of "legacy" LDAP Legacy LDAP means an OpenLDAP-compatible implementation without the private API `ldap_init_fd()` introduced in OpenLDAP 2.4.6+ (2007-10-31), and not WinLDAP. One known example is Apple's LDAP build, which is based on OpenLDAP 2.4.28 (2011-11-25), without providing this private API. The version query API was introduced around 1998-1999, before the minimum (2.0 2000-08-01) required by curl. Follow-up to 3e2a946926853608d67805bd9f4a58345fff364a #19808 Closes #19832 --- lib/ldap.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/lib/ldap.c b/lib/ldap.c index 6104ff207344..92cfa3967fcf 100644 --- a/lib/ldap.c +++ b/lib/ldap.c @@ -1029,7 +1029,27 @@ void Curl_ldap_version(char *buf, size_t bufsz) #ifdef USE_WIN32_LDAP curl_msnprintf(buf, bufsz, "WinLDAP"); #else - curl_msnprintf(buf, bufsz, "LDAP/1"); +#ifdef __APPLE__ + static const char *flavor = "/Apple"; +#else + static const char *flavor = ""; +#endif + LDAPAPIInfo api; + api.ldapai_info_version = LDAP_API_INFO_VERSION; + + if(ldap_get_option(NULL, LDAP_OPT_API_INFO, &api) == LDAP_OPT_SUCCESS) { + unsigned int patch = (unsigned int)(api.ldapai_vendor_version % 100); + unsigned int major = (unsigned int)(api.ldapai_vendor_version / 10000); + unsigned int minor = + (((unsigned int)api.ldapai_vendor_version - major * 10000) + - patch) / 100; + curl_msnprintf(buf, bufsz, "%s/%u.%u.%u%s", + api.ldapai_vendor_name, major, minor, patch, flavor); + ldap_memfree(api.ldapai_vendor_name); + ber_memvfree((void **)api.ldapai_extensions); + } + else + curl_msnprintf(buf, bufsz, "LDAP/1"); #endif } From 68a44edd500ac36754eea4f80beb5dcbe8534723 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 5 Dec 2025 08:51:11 +0100 Subject: [PATCH 197/415] TODO: remove a mandriva.com reference It's a casino now --- docs/TODO | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/docs/TODO b/docs/TODO index 99e8d1dd605b..817591dfb7cb 100644 --- a/docs/TODO +++ b/docs/TODO @@ -1177,9 +1177,7 @@ -y/-Y) the next attempt does not resume the transfer properly from what was downloaded in the previous attempt but truncates and restarts at the original position where it was at before the previous failed attempt. See - https://curl.se/mail/lib-2008-01/0080.html and Mandriva bug report - https://qa.mandriva.com/show_bug.cgi?id=22565 - + https://curl.se/mail/lib-2008-01/0080.html 19. Build From 8d9aa6d6e12cb35b074dd66da454795c8808a41b Mon Sep 17 00:00:00 2001 From: Stefan Eissing Date: Tue, 2 Dec 2025 15:53:29 +0100 Subject: [PATCH 198/415] tests/servers: put unix-domain-path inside LOGDIR Change Unix domain socket paths from `/tmp/curl-socksd-` to `/drive/path/to/LOGDIR/PIDDIR/*-uds` to avoid having to create and delete them before use. Also to use a path which remains an absolute one while passed from MSYS2 Perl to native Windows curl tool and test server via the command-line, and keep pointing to the same location, fixing: ``` === Start of file commands.log ../src/curl.exe -q --output log/3/curl1468.out --include --trace-ascii log/3/trace1468 --trace-time http://this.is.a.host.name:64405/1468 --proxy socks5h://localhost/tmp/curl-socksd-YnbvRo98 [...] === End of file commands.log === Start of file socks2_server.log [...] 14:11:54.597968 Listening on Unix socket D:/a/_temp/msys64/tmp/curl-socksd-YnbvRo98 ``` Ref: https://github.com/curl/curl/actions/runs/19896583933/job/57028545111?pr=19812 The curl tool is pending #19825 to fix accepting an absolute unix domain socket path on Windows. Assisted-by: Viktor Szakats Closes #19810 --- tests/servers.pm | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/tests/servers.pm b/tests/servers.pm index db4b3757b547..f23d897fdd84 100644 --- a/tests/servers.pm +++ b/tests/servers.pm @@ -195,14 +195,8 @@ use File::Temp qw/ tempfile/; ####################################################################### # Initialize configuration variables sub initserverconfig { - my ($fh, $socks) = tempfile("curl-socksd-XXXXXXXX", TMPDIR => 1); - close($fh); - unlink($socks); - my ($f2, $http) = tempfile("curl-http-XXXXXXXX", TMPDIR => 1); - close($f2); - unlink($http); - $SOCKSUNIXPATH = $socks; # SOCKS Unix domain socket - $HTTPUNIXPATH = $http; # HTTP Unix domain socket + $SOCKSUNIXPATH = "$pwd/$LOGDIR/$PIDDIR/socks-uds"; # SOCKS Unix domain socket + $HTTPUNIXPATH = "$pwd/$LOGDIR/$PIDDIR/http-uds"; # HTTP Unix domain socket $stunnel = checkcmd("stunnel4") || checkcmd("tstunnel") || checkcmd("stunnel"); # get the name of the current user From 2d6ade19fc4261e22e9d32a00bf60eabb8694bcb Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Fri, 5 Dec 2025 12:43:37 +0100 Subject: [PATCH 199/415] ldap: improve detection of Apple LDAP When detecting the Apple fork of "legacy" LDAP, replace the `__APPLE__` macro (which can be present also when using an old mainline OpenLDAP while building for an Apple platform) with `LDAP_OPT_X_TLS_PASSPHRASE` which is an Apple-specific macro, merged by Apple in 2007, later adding the comment 'Apple Specific code'. This macro hasn't been retrofitted to OpenLDAP since then, and unlikely to happen in the future. Refs: https://github.com/apple-oss-distributions/OpenLDAP/commit/c4d990a6cfa0cb71d6dffe6f6aeeb722fd7c627b#diff-0f7a5f85bae4de860b70aabf34aa12b0ecc37e748cd96e203e2d8ddb30a207c3R145 https://github.com/apple-oss-distributions/OpenLDAP/commit/49ac28a486d72f36cd9713b41180b41d34f18ef6#diff-0f7a5f85bae4de860b70aabf34aa12b0ecc37e748cd96e203e2d8ddb30a207c3R166 Follow-up to 859ce48de12986f5bf846c2800dacab893ff12c1 #19832 Closes #19849 --- lib/ldap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ldap.c b/lib/ldap.c index 92cfa3967fcf..3dfbb330dc94 100644 --- a/lib/ldap.c +++ b/lib/ldap.c @@ -1029,7 +1029,7 @@ void Curl_ldap_version(char *buf, size_t bufsz) #ifdef USE_WIN32_LDAP curl_msnprintf(buf, bufsz, "WinLDAP"); #else -#ifdef __APPLE__ +#ifdef LDAP_OPT_X_TLS_PASSPHRASE static const char *flavor = "/Apple"; #else static const char *flavor = ""; From 4e051ff5506319ee87e3656be8f76b01de217103 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Thu, 4 Dec 2025 23:54:25 +0100 Subject: [PATCH 200/415] curlx: limit use of system allocators to the minimum possible Clone a multibye conversion function into curlx/fopen, and use that local copy from curlx/fopen functions. Adjust allocators in curlx/fopen to use curl's in normal builds, and system allocators in TrackMemory builds to avoid recursion. This allows to switch curlx/multibyte functions to curl allocators in all configurations, as they are no longer called by curlx/fopen, and a recursive call can no longer happen. After this patch the system allocator is only used in TrackMemory Windows builds, within curlx `fopen`, `freopen`, `stat` and `open` functions. Also: - test 1, 440, 767: raise allocation limitsto fit the extra allocations in Windows Unicode builds. - replace all uses of `curlx_unicodefree()` macro with `curlx_free()` across the codebase. - curlx/multibyte: delete `curlx_unicodefree()`. - ldap: join Windows and non-Windows codepaths that became identical after moving from `curlx_unicodefree()` to `curlx_free()`. - vauth: drop a strdup from standard to curl allocator since the original allocation is now already done by curl's. - tool_doswin: drop now superfluous strdup from `FindWin32CACert()`. - memanalyzer.pm: sync weirdo `calloc` log message with `malloc`'s. Fixes #19748 Closes #19845 --- lib/curl_sspi.c | 14 ++++---- lib/curlx/curlx.h | 1 - lib/curlx/fopen.c | 69 +++++++++++++++++++++++++++----------- lib/curlx/multibyte.c | 13 +++---- lib/curlx/multibyte.h | 27 ++------------- lib/ldap.c | 15 ++------- lib/rename.c | 8 ++--- lib/socks_sspi.c | 4 +-- lib/vauth/digest_sspi.c | 8 ++--- lib/vauth/vauth.c | 12 ++----- lib/vtls/schannel.c | 16 ++++----- lib/vtls/schannel_verify.c | 4 +-- src/tool_doswin.c | 7 ++-- src/tool_filetime.c | 4 +-- src/tool_getparam.h | 2 +- tests/data/test1 | 2 +- tests/data/test440 | 2 +- tests/data/test767 | 2 +- tests/memanalyzer.pm | 3 +- 19 files changed, 100 insertions(+), 113 deletions(-) diff --git a/lib/curl_sspi.c b/lib/curl_sspi.c index 264703d8cd70..712fab2e9e82 100644 --- a/lib/curl_sspi.c +++ b/lib/curl_sspi.c @@ -132,7 +132,7 @@ CURLcode Curl_create_sspi_identity(const char *userp, const char *passwdp, /* Setup the identity's user and length */ dup_user.tchar_ptr = curlx_tcsdup(user.tchar_ptr); if(!dup_user.tchar_ptr) { - curlx_unicodefree(useranddomain.tchar_ptr); + curlx_free(useranddomain.tchar_ptr); return CURLE_OUT_OF_MEMORY; } identity->User = dup_user.tbyte_ptr; @@ -142,19 +142,19 @@ CURLcode Curl_create_sspi_identity(const char *userp, const char *passwdp, /* Setup the identity's domain and length */ dup_domain.tchar_ptr = curlx_malloc(sizeof(TCHAR) * (domlen + 1)); if(!dup_domain.tchar_ptr) { - curlx_unicodefree(useranddomain.tchar_ptr); + curlx_free(useranddomain.tchar_ptr); return CURLE_OUT_OF_MEMORY; } if(_tcsncpy_s(dup_domain.tchar_ptr, domlen + 1, domain.tchar_ptr, domlen)) { - curlx_unicodefree(dup_domain.tchar_ptr); - curlx_unicodefree(useranddomain.tchar_ptr); + curlx_free(dup_domain.tchar_ptr); + curlx_free(useranddomain.tchar_ptr); return CURLE_OUT_OF_MEMORY; } identity->Domain = dup_domain.tbyte_ptr; identity->DomainLength = curlx_uztoul(domlen); dup_domain.tchar_ptr = NULL; - curlx_unicodefree(useranddomain.tchar_ptr); + curlx_free(useranddomain.tchar_ptr); /* Setup the identity's password and length */ passwd.tchar_ptr = curlx_convert_UTF8_to_tchar(passwdp); @@ -162,14 +162,14 @@ CURLcode Curl_create_sspi_identity(const char *userp, const char *passwdp, return CURLE_OUT_OF_MEMORY; dup_passwd.tchar_ptr = curlx_tcsdup(passwd.tchar_ptr); if(!dup_passwd.tchar_ptr) { - curlx_unicodefree(passwd.tchar_ptr); + curlx_free(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_free(passwd.tchar_ptr); /* Setup the identity's flags */ identity->Flags = (unsigned long) diff --git a/lib/curlx/curlx.h b/lib/curlx/curlx.h index 480e91950de0..af46fae671d5 100644 --- a/lib/curlx/curlx.h +++ b/lib/curlx/curlx.h @@ -52,7 +52,6 @@ curlx_convert_wchar_to_UTF8() curlx_convert_UTF8_to_tchar() curlx_convert_tchar_to_UTF8() - curlx_unicodefree() */ #include "version_win32.h" diff --git a/lib/curlx/fopen.c b/lib/curlx/fopen.c index 1838b7de8b8c..c9b7a9c0b590 100644 --- a/lib/curlx/fopen.c +++ b/lib/curlx/fopen.c @@ -22,11 +22,6 @@ * ***************************************************************************/ -/* - * Use system allocators to avoid infinite recursion when called by curl's - * memory tracker memdebug functions. - */ - #include "../curl_setup.h" #include "fopen.h" @@ -46,10 +41,43 @@ int curlx_fseek(void *stream, curl_off_t offset, int whence) #ifdef _WIN32 -#include "multibyte.h" - #include /* for _SH_DENYNO */ +#ifdef CURLDEBUG +/* + * Use system allocators to avoid infinite recursion when called by curl's + * memory tracker memdebug functions. + */ +#define CURLX_MALLOC(x) malloc(x) +#define CURLX_FREE(x) free(x) +#else +#define CURLX_MALLOC(x) curlx_malloc(x) +#define CURLX_FREE(x) curlx_free(x) +#endif + +#ifdef _UNICODE +static wchar_t *fn_convert_UTF8_to_wchar(const char *str_utf8) +{ + wchar_t *str_w = NULL; + + if(str_utf8) { + int str_w_len = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, + str_utf8, -1, NULL, 0); + if(str_w_len > 0) { + str_w = CURLX_MALLOC(str_w_len * sizeof(wchar_t)); + if(str_w) { + if(MultiByteToWideChar(CP_UTF8, 0, + str_utf8, -1, str_w, str_w_len) == 0) { + CURLX_FREE(str_w); + return NULL; + } + } + } + } + return str_w; +} +#endif + /* declare GetFullPathNameW for mingw-w64 UWP builds targeting old windows */ #if defined(CURL_WINDOWS_UWP) && defined(__MINGW32__) && \ (_WIN32_WINNT < _WIN32_WINNT_WIN10) @@ -228,7 +256,7 @@ int curlx_win32_open(const char *filename, int oflag, ...) const TCHAR *target = NULL; #ifdef _UNICODE - wchar_t *filename_w = curlx_convert_UTF8_to_wchar(filename); + wchar_t *filename_w = fn_convert_UTF8_to_wchar(filename); #endif va_list param; @@ -244,7 +272,7 @@ int curlx_win32_open(const char *filename, int oflag, ...) else target = filename_w; errno = _wsopen_s(&result, target, oflag, _SH_DENYNO, pmode); - curlx_unicodefree(filename_w); + CURLX_FREE(filename_w); } else /* !checksrc! disable ERRNOVAR 1 */ @@ -268,8 +296,8 @@ FILE *curlx_win32_fopen(const char *filename, const char *mode) const TCHAR *target = NULL; #ifdef _UNICODE - wchar_t *filename_w = curlx_convert_UTF8_to_wchar(filename); - wchar_t *mode_w = curlx_convert_UTF8_to_wchar(mode); + wchar_t *filename_w = fn_convert_UTF8_to_wchar(filename); + wchar_t *mode_w = fn_convert_UTF8_to_wchar(mode); if(filename_w && mode_w) { if(fix_excessive_path(filename_w, &fixed)) target = fixed; @@ -280,8 +308,8 @@ FILE *curlx_win32_fopen(const char *filename, const char *mode) else /* !checksrc! disable ERRNOVAR 1 */ errno = EINVAL; - curlx_unicodefree(filename_w); - curlx_unicodefree(mode_w); + CURLX_FREE(filename_w); + CURLX_FREE(mode_w); #else if(fix_excessive_path(filename, &fixed)) target = fixed; @@ -306,8 +334,8 @@ FILE *curlx_win32_freopen(const char *filename, const char *mode, FILE *fp) const TCHAR *target = NULL; #ifdef _UNICODE - wchar_t *filename_w = curlx_convert_UTF8_to_wchar(filename); - wchar_t *mode_w = curlx_convert_UTF8_to_wchar(mode); + wchar_t *filename_w = fn_convert_UTF8_to_wchar(filename); + wchar_t *mode_w = fn_convert_UTF8_to_wchar(mode); if(filename_w && mode_w) { if(fix_excessive_path(filename_w, &fixed)) target = fixed; @@ -318,8 +346,8 @@ FILE *curlx_win32_freopen(const char *filename, const char *mode, FILE *fp) else /* !checksrc! disable ERRNOVAR 1 */ errno = EINVAL; - curlx_unicodefree(filename_w); - curlx_unicodefree(mode_w); + CURLX_FREE(filename_w); + CURLX_FREE(mode_w); #else if(fix_excessive_path(filename, &fixed)) target = fixed; @@ -339,7 +367,7 @@ int curlx_win32_stat(const char *path, struct_stat *buffer) const TCHAR *target = NULL; #ifdef _UNICODE - wchar_t *path_w = curlx_convert_UTF8_to_wchar(path); + wchar_t *path_w = fn_convert_UTF8_to_wchar(path); if(path_w) { if(fix_excessive_path(path_w, &fixed)) target = fixed; @@ -350,7 +378,7 @@ int curlx_win32_stat(const char *path, struct_stat *buffer) #else result = _wstati64(target, buffer); #endif - curlx_unicodefree(path_w); + CURLX_FREE(path_w); } else /* !checksrc! disable ERRNOVAR 1 */ @@ -371,4 +399,7 @@ int curlx_win32_stat(const char *path, struct_stat *buffer) return result; } +#undef CURLX_MALLOC +#undef CURLX_FREE + #endif /* _WIN32 */ diff --git a/lib/curlx/multibyte.c b/lib/curlx/multibyte.c index 3a33fcedfc65..71170df2c549 100644 --- a/lib/curlx/multibyte.c +++ b/lib/curlx/multibyte.c @@ -22,11 +22,6 @@ * ***************************************************************************/ -/* - * Use system allocators to avoid infinite recursion when called by curl's - * memory tracker memdebug functions. - */ - #include "../curl_setup.h" #if defined(_WIN32) && defined(UNICODE) @@ -45,11 +40,11 @@ wchar_t *curlx_convert_UTF8_to_wchar(const char *str_utf8) int str_w_len = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, str_utf8, -1, NULL, 0); if(str_w_len > 0) { - str_w = CURLX_MALLOC(str_w_len * sizeof(wchar_t)); + str_w = curlx_malloc(str_w_len * sizeof(wchar_t)); if(str_w) { if(MultiByteToWideChar(CP_UTF8, 0, str_utf8, -1, str_w, str_w_len) == 0) { - CURLX_FREE(str_w); + curlx_free(str_w); return NULL; } } @@ -67,11 +62,11 @@ char *curlx_convert_wchar_to_UTF8(const wchar_t *str_w) int bytes = WideCharToMultiByte(CP_UTF8, 0, str_w, -1, NULL, 0, NULL, NULL); if(bytes > 0) { - str_utf8 = CURLX_MALLOC(bytes); + str_utf8 = curlx_malloc(bytes); if(str_utf8) { if(WideCharToMultiByte(CP_UTF8, 0, str_w, -1, str_utf8, bytes, NULL, NULL) == 0) { - CURLX_FREE(str_utf8); + curlx_free(str_utf8); return NULL; } } diff --git a/lib/curlx/multibyte.h b/lib/curlx/multibyte.h index fd264e180efa..8b19257222ca 100644 --- a/lib/curlx/multibyte.h +++ b/lib/curlx/multibyte.h @@ -29,32 +29,16 @@ /* * 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. + * main purpose is to minimize the number of preprocessor conditional + * directives needed by code using these to differentiate Unicode from + * non-Unicode builds. * * In the case of a non-Unicode build the tchar strings are char strings that * are duplicated via strdup and remain in whatever the passed in encoding is, * which is assumed to be UTF-8 but may be other encoding. Therefore the * significance of the conversion functions is primarily for Unicode builds. - * - * Allocated memory should be free'd with curlx_unicodefree(). - * - * Use system allocators to avoid infinite recursion when called by curl's - * memory tracker memdebug functions. */ -#ifdef CURLDEBUG -#define CURLX_MALLOC(x) malloc(x) -#define CURLX_FREE(x) free(x) -#else -#define CURLX_MALLOC(x) curlx_malloc(x) -#define CURLX_FREE(x) curlx_free(x) -#endif - -/* the purpose of this macro is to free() without being traced by memdebug */ -#define curlx_unicodefree(ptr) CURLX_FREE(ptr) - #ifdef UNICODE /* MultiByte conversions using Windows kernel32 library. */ @@ -73,13 +57,8 @@ typedef union { #else /* !UNICODE */ -#ifdef CURLDEBUG -#define curlx_convert_UTF8_to_tchar(ptr) _strdup(ptr) -#define curlx_convert_tchar_to_UTF8(ptr) _strdup(ptr) -#else #define curlx_convert_UTF8_to_tchar(ptr) curlx_strdup(ptr) #define curlx_convert_tchar_to_UTF8(ptr) curlx_strdup(ptr) -#endif typedef union { char *tchar_ptr; diff --git a/lib/ldap.c b/lib/ldap.c index 3dfbb330dc94..ba9620b4b185 100644 --- a/lib/ldap.c +++ b/lib/ldap.c @@ -96,7 +96,7 @@ #include "connect.h" #ifdef USE_WIN32_LDAP -#define FREE_ON_WINLDAP(x) curlx_unicodefree(x) +#define FREE_ON_WINLDAP(x) curlx_free(x) #define curl_ldap_num_t ULONG #else #define FREE_ON_WINLDAP(x) @@ -296,8 +296,8 @@ static ULONG ldap_win_bind(struct Curl_easy *data, LDAP *server, rc = ldap_simple_bind_s(server, inuser, inpass); - curlx_unicodefree(inuser); - curlx_unicodefree(inpass); + curlx_free(inuser); + curlx_free(inpass); } #ifdef USE_WINDOWS_SSPI else { @@ -1000,22 +1000,13 @@ static void ldap_free_urldesc_low(LDAPURLDesc *ludp) if(!ludp) return; -#ifdef USE_WIN32_LDAP - curlx_unicodefree(ludp->lud_dn); - curlx_unicodefree(ludp->lud_filter); -#else curlx_free(ludp->lud_dn); curlx_free(ludp->lud_filter); -#endif if(ludp->lud_attrs) { size_t i; for(i = 0; i < ludp->lud_attrs_dups; i++) { -#ifdef USE_WIN32_LDAP - curlx_unicodefree(ludp->lud_attrs[i]); -#else curlx_free(ludp->lud_attrs[i]); -#endif } curlx_free(ludp->lud_attrs); } diff --git a/lib/rename.c b/lib/rename.c index d3f80422e641..11cd680aa6dd 100644 --- a/lib/rename.c +++ b/lib/rename.c @@ -46,14 +46,14 @@ int Curl_rename(const char *oldpath, const char *newpath) for(;;) { timediff_t diff; if(MoveFileEx(tchar_oldpath, tchar_newpath, MOVEFILE_REPLACE_EXISTING)) { - curlx_unicodefree(tchar_oldpath); - curlx_unicodefree(tchar_newpath); + curlx_free(tchar_oldpath); + curlx_free(tchar_newpath); break; } diff = curlx_timediff_ms(curlx_now(), start); if(diff < 0 || diff > max_wait_ms) { - curlx_unicodefree(tchar_oldpath); - curlx_unicodefree(tchar_newpath); + curlx_free(tchar_oldpath); + curlx_free(tchar_newpath); return 1; } Sleep(1); diff --git a/lib/socks_sspi.c b/lib/socks_sspi.c index 17e875557eea..84d530151c55 100644 --- a/lib/socks_sspi.c +++ b/lib/socks_sspi.c @@ -175,7 +175,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(struct Curl_cfilter *cf, &output_desc, &sspi_ret_flags, NULL); - curlx_unicodefree(sname); + curlx_free(sname); Curl_safefree(sspi_recv_token.pvBuffer); sspi_recv_token.cbBuffer = 0; @@ -298,7 +298,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(struct Curl_cfilter *cf, char *user_utf8 = curlx_convert_tchar_to_UTF8(names.sUserName); infof(data, "SOCKS5 server authenticated user %s with GSS-API.", (user_utf8 ? user_utf8 : "(unknown)")); - curlx_unicodefree(user_utf8); + curlx_free(user_utf8); #endif Curl_pSecFn->FreeContextBuffer(names.sUserName); names.sUserName = NULL; diff --git a/lib/vauth/digest_sspi.c b/lib/vauth/digest_sspi.c index c92b53dcfc22..dc3afcc88357 100644 --- a/lib/vauth/digest_sspi.c +++ b/lib/vauth/digest_sspi.c @@ -273,7 +273,7 @@ CURLcode Curl_override_sspi_http_realm(const char *chlg, dup_domain.tchar_ptr = curlx_tcsdup(domain.tchar_ptr); if(!dup_domain.tchar_ptr) { - curlx_unicodefree(domain.tchar_ptr); + curlx_free(domain.tchar_ptr); return CURLE_OUT_OF_MEMORY; } @@ -282,7 +282,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_free(domain.tchar_ptr); } else { /* Unknown specifier, ignore it! */ @@ -579,7 +579,7 @@ CURLcode Curl_auth_create_digest_http_message(struct Curl_easy *data, digest->http_context = curlx_calloc(1, sizeof(CtxtHandle)); if(!digest->http_context) { Curl_pSecFn->FreeCredentialsHandle(&credentials); - curlx_unicodefree(spn); + curlx_free(spn); Curl_sspi_free_identity(p_identity); curlx_free(output_token); return CURLE_OUT_OF_MEMORY; @@ -592,7 +592,7 @@ CURLcode Curl_auth_create_digest_http_message(struct Curl_easy *data, &chlg_desc, 0, digest->http_context, &resp_desc, &attrs, NULL); - curlx_unicodefree(spn); + curlx_free(spn); if(status == SEC_I_COMPLETE_NEEDED || status == SEC_I_COMPLETE_AND_CONTINUE) diff --git a/lib/vauth/vauth.c b/lib/vauth/vauth.c index 9b87bd2c6757..25924806f2b9 100644 --- a/lib/vauth/vauth.c +++ b/lib/vauth/vauth.c @@ -71,7 +71,6 @@ TCHAR *Curl_auth_build_spn(const char *service, const char *host, { char *utf8_spn = NULL; TCHAR *tchar_spn = NULL; - TCHAR *dupe_tchar_spn = NULL; (void)realm; @@ -87,16 +86,11 @@ TCHAR *Curl_auth_build_spn(const char *service, const char *host, if(!utf8_spn) return NULL; - /* Allocate and return a TCHAR based SPN. Since curlx_convert_UTF8_to_tchar - must be freed by curlx_unicodefree we will dupe the result so that the - pointer this function returns can be normally free'd. */ + /* Allocate and return a TCHAR based SPN. */ tchar_spn = curlx_convert_UTF8_to_tchar(utf8_spn); curlx_free(utf8_spn); - if(!tchar_spn) - return NULL; - dupe_tchar_spn = curlx_tcsdup(tchar_spn); - curlx_unicodefree(tchar_spn); - return dupe_tchar_spn; + + return tchar_spn; } #endif /* USE_WINDOWS_SSPI */ diff --git a/lib/vtls/schannel.c b/lib/vtls/schannel.c index 21314d16ecb3..f1b47cb47fd8 100644 --- a/lib/vtls/schannel.c +++ b/lib/vtls/schannel.c @@ -547,7 +547,7 @@ static CURLcode schannel_acquire_credential_handle(struct Curl_cfilter *cf, failf(data, "schannel: Failed to get certificate location" " or file for %s", data->set.ssl.primary.clientcert); - curlx_unicodefree(cert_path); + curlx_free(cert_path); return result; } } @@ -558,7 +558,7 @@ static CURLcode schannel_acquire_credential_handle(struct Curl_cfilter *cf, " for %s", blob ? "(memory blob)" : data->set.ssl.primary.clientcert); curlx_free(cert_store_path); - curlx_unicodefree(cert_path); + curlx_free(cert_path); if(fInCert) curlx_fclose(fInCert); return CURLE_SSL_CERTPROBLEM; @@ -576,7 +576,7 @@ static CURLcode schannel_acquire_credential_handle(struct Curl_cfilter *cf, const char *cert_showfilename_error = blob ? "(memory blob)" : data->set.ssl.primary.clientcert; curlx_free(cert_store_path); - curlx_unicodefree(cert_path); + curlx_free(cert_path); if(fInCert) { long cert_tell = 0; bool continue_reading = fseek(fInCert, 0, SEEK_END) == 0; @@ -686,8 +686,8 @@ static CURLcode schannel_acquire_credential_handle(struct Curl_cfilter *cf, (path_utf8 ? path_utf8 : "(unknown)"), GetLastError()); curlx_free(cert_store_path); - curlx_unicodefree(path_utf8); - curlx_unicodefree(cert_path); + curlx_free(path_utf8); + curlx_free(cert_path); return CURLE_SSL_CERTPROBLEM; } curlx_free(cert_store_path); @@ -701,7 +701,7 @@ static CURLcode schannel_acquire_credential_handle(struct Curl_cfilter *cf, cert_thumbprint_data, &cert_thumbprint.cbData, NULL, NULL)) { - curlx_unicodefree(cert_path); + curlx_free(cert_path); CertCloseStore(cert_store, 0); return CURLE_SSL_CERTPROBLEM; } @@ -710,7 +710,7 @@ static CURLcode schannel_acquire_credential_handle(struct Curl_cfilter *cf, cert_store, X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, 0, CERT_FIND_HASH, &cert_thumbprint, NULL); - curlx_unicodefree(cert_path); + curlx_free(cert_path); if(!client_certs[0]) { /* CRYPT_E_NOT_FOUND / E_INVALIDARG */ @@ -1485,7 +1485,7 @@ static void schannel_session_free(void *sessionid) cred->refcount--; if(cred->refcount == 0) { Curl_pSecFn->FreeCredentialsHandle(&cred->cred_handle); - curlx_unicodefree(cred->sni_hostname); + curlx_free(cred->sni_hostname); if(cred->client_cert_store) { CertCloseStore(cred->client_cert_store, 0); cred->client_cert_store = NULL; diff --git a/lib/vtls/schannel_verify.c b/lib/vtls/schannel_verify.c index 77f9177349d7..f45977bcb607 100644 --- a/lib/vtls/schannel_verify.c +++ b/lib/vtls/schannel_verify.c @@ -347,7 +347,7 @@ static CURLcode add_certs_file_to_store(HCERTSTORE trust_store, CloseHandle(ca_file_handle); } Curl_safefree(ca_file_buffer); - curlx_unicodefree(ca_file_tstr); + curlx_free(ca_file_tstr); return result; } @@ -648,7 +648,7 @@ CURLcode Curl_verify_host(struct Curl_cfilter *cf, struct Curl_easy *data) result = CURLE_PEER_FAILED_VERIFICATION; } - curlx_unicodefree(cert_hostname); + curlx_free(cert_hostname); } } diff --git a/src/tool_doswin.c b/src/tool_doswin.c index 040792f465a7..855ce0897ca1 100644 --- a/src/tool_doswin.c +++ b/src/tool_doswin.c @@ -593,11 +593,8 @@ CURLcode FindWin32CACert(struct OperationConfig *config, res_len = SearchPath(NULL, bundle_file, NULL, PATH_MAX, buf, &ptr); if(res_len > 0) { - char *mstr = curlx_convert_tchar_to_UTF8(buf); - tool_safefree(config->cacert); - if(mstr) - config->cacert = curlx_strdup(mstr); - curlx_unicodefree(mstr); + curlx_free(config->cacert); + config->cacert = curlx_convert_tchar_to_UTF8(buf); if(!config->cacert) result = CURLE_OUT_OF_MEMORY; } diff --git a/src/tool_filetime.c b/src/tool_filetime.c index 2d362b4bb7cb..9e548cd50e3e 100644 --- a/src/tool_filetime.c +++ b/src/tool_filetime.c @@ -47,7 +47,7 @@ int getfiletime(const char *filename, curl_off_t *stamp) (FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE), NULL, OPEN_EXISTING, 0, NULL); - curlx_unicodefree(tchar_filename); + curlx_free(tchar_filename); if(hfile != INVALID_HANDLE_VALUE) { FILETIME ft; if(GetFileTime(hfile, NULL, NULL, &ft)) { @@ -113,7 +113,7 @@ void setfiletime(curl_off_t filetime, const char *filename) (FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE), NULL, OPEN_EXISTING, 0, NULL); - curlx_unicodefree(tchar_filename); + curlx_free(tchar_filename); if(hfile != INVALID_HANDLE_VALUE) { curl_off_t converted = ((curl_off_t)filetime * 10000000) + 116444736000000000; diff --git a/src/tool_getparam.h b/src/tool_getparam.h index 10b235187436..1b0d8017d5e5 100644 --- a/src/tool_getparam.h +++ b/src/tool_getparam.h @@ -383,7 +383,7 @@ ParameterError parse_args(int argc, argv_item_t argv[]); #define convert_UTF8_to_tchar(ptr) curlx_convert_UTF8_to_wchar((ptr)) #define convert_tchar_to_UTF8(ptr) curlx_convert_wchar_to_UTF8((ptr)) -#define unicodefree(ptr) curlx_unicodefree(ptr) +#define unicodefree(ptr) curlx_free(ptr) #else diff --git a/tests/data/test1 b/tests/data/test1 index ee0b63404884..cee68e69438f 100644 --- a/tests/data/test1 +++ b/tests/data/test1 @@ -50,7 +50,7 @@ Accept: */* -Allocations: 120 +Allocations: 135 Maximum allocated: 136000 diff --git a/tests/data/test440 b/tests/data/test440 index 127fb16270ab..39246e49789b 100644 --- a/tests/data/test440 +++ b/tests/data/test440 @@ -74,7 +74,7 @@ https://this.hsts.example./%TESTNUMBER 56 -Allocations: 145 +Allocations: 160 diff --git a/tests/data/test767 b/tests/data/test767 index 83d68841b010..7561c8adba42 100644 --- a/tests/data/test767 +++ b/tests/data/test767 @@ -51,7 +51,7 @@ Accept: */* -Allocations: 120 +Allocations: 135 Maximum allocated: 136000 diff --git a/tests/memanalyzer.pm b/tests/memanalyzer.pm index 7dbdf7b94a91..8c7515e4ff04 100644 --- a/tests/memanalyzer.pm +++ b/tests/memanalyzer.pm @@ -191,7 +191,8 @@ sub memanalyze { if($sizeataddr{$addr} && $sizeataddr{$addr}>0) { # this means weeeeeirdo - push @res, "Mixed debug compile, rebuild curl now\n"; + push @res, "Mixed debug compile ($source:$linenum at line $lnum), rebuild curl now\n"; + push @res, "We think $sizeataddr{$addr} bytes are already allocated at that memory address: $addr!\n"; } $sizeataddr{$addr} = $size; From af5def0738dd53db84a23221be9bf352d8708917 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Thu, 4 Dec 2025 22:48:20 +0100 Subject: [PATCH 201/415] tidy-up: avoid `(())`, clang-format fixes and more - drop redundant parentheses from macro definitions. - apply clang-format in some places missed earlier. - wolfssl: fix a macro guard comment. - curl_setup.h: drop empty lines - FAQ: fix C formatting. Closes #19854 --- docs/FAQ | 2 +- lib/conncache.c | 6 +- lib/curl_setup.h | 19 +- lib/curl_setup_once.h | 10 +- lib/curlx/base64.c | 13 +- lib/curlx/multibyte.h | 4 +- lib/curlx/strparse.h | 2 +- lib/vtls/wolfssl.c | 4 +- src/tool_bname.h | 2 +- src/tool_dirhie.c | 2 +- src/tool_getparam.h | 6 +- tests/libtest/first.h | 541 ++++++++++++++++++++------------------ tests/libtest/unitcheck.h | 3 +- 13 files changed, 322 insertions(+), 292 deletions(-) diff --git a/docs/FAQ b/docs/FAQ index 15cfee848cc6..2e5e5901bef5 100644 --- a/docs/FAQ +++ b/docs/FAQ @@ -1157,7 +1157,7 @@ FAQ struct MemoryStruct *mem = (struct MemoryStruct *)data; mem->memory = (char *)realloc(mem->memory, mem->size + realsize + 1); - if (mem->memory) { + if(mem->memory) { memcpy(&(mem->memory[mem->size]), ptr, realsize); mem->size += realsize; mem->memory[mem->size] = 0; diff --git a/lib/conncache.c b/lib/conncache.c index 18b760afe052..54248d14ad6e 100644 --- a/lib/conncache.c +++ b/lib/conncache.c @@ -48,9 +48,9 @@ #define CPOOL_IS_LOCKED(c) ((c) && (c)->locked) -#define CPOOL_LOCK(c,d) \ +#define CPOOL_LOCK(c, d) \ do { \ - if((c)) { \ + if(c) { \ if(CURL_SHARE_KEEP_CONNECT((c)->share)) \ Curl_share_lock((d), CURL_LOCK_DATA_CONNECT, \ CURL_LOCK_ACCESS_SINGLE); \ @@ -61,7 +61,7 @@ #define CPOOL_UNLOCK(c,d) \ do { \ - if((c)) { \ + if(c) { \ DEBUGASSERT((c)->locked); \ (c)->locked = FALSE; \ if(CURL_SHARE_KEEP_CONNECT((c)->share)) \ diff --git a/lib/curl_setup.h b/lib/curl_setup.h index ca275df0ada0..c4be90b655e0 100644 --- a/lib/curl_setup.h +++ b/lib/curl_setup.h @@ -180,7 +180,6 @@ * AIX 4.3 and newer needs _THREAD_SAFE defined to build * proper reentrant code. Others may also need it. */ - #ifdef NEED_THREAD_SAFE # ifndef _THREAD_SAFE # define _THREAD_SAFE @@ -192,7 +191,6 @@ * things to appear in the system header files. Unixware needs it * to build proper reentrant code. Others may also need it. */ - #ifdef NEED_REENTRANT # ifndef _REENTRANT # define _REENTRANT @@ -219,7 +217,6 @@ /* * Disable other protocols when http is the only one desired. */ - #ifdef HTTP_ONLY # ifndef CURL_DISABLE_DICT # define CURL_DISABLE_DICT @@ -268,7 +265,6 @@ /* * When http is disabled rtsp is not supported. */ - #if defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_RTSP) # define CURL_DISABLE_RTSP #endif @@ -276,7 +272,6 @@ /* * When HTTP is disabled, disable HTTP-only features */ - #ifdef CURL_DISABLE_HTTP # define CURL_DISABLE_ALTSVC 1 # define CURL_DISABLE_COOKIES 1 @@ -298,7 +293,6 @@ /* * OS/400 setup file includes some system headers. */ - #ifdef __OS400__ # include "setup-os400.h" #endif @@ -306,7 +300,6 @@ /* * VMS setup file includes some system headers. */ - #ifdef __VMS # include "setup-vms.h" #endif @@ -314,7 +307,6 @@ /* * Windows setup file includes some system headers. */ - #ifdef _WIN32 # include "setup-win32.h" #endif @@ -340,7 +332,6 @@ #endif /* based on logic in "curl/mprintf.h" */ - #if (defined(__GNUC__) || defined(__clang__) || \ defined(__IAR_SYSTEMS_ICC__)) && \ defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \ @@ -612,10 +603,10 @@ #if SIZEOF_LONG > SIZEOF_SIZE_T #error "unexpected: 'long' is larger than 'size_t'" #endif + /* * Arg 2 type for gethostname in case it has not been defined in config file. */ - #ifndef GETHOSTNAME_TYPE_ARG2 # ifdef USE_WINSOCK # define GETHOSTNAME_TYPE_ARG2 int @@ -625,10 +616,9 @@ #endif /* Below we define some functions. They should - 4. set the SIGALRM signal timeout 5. set dir/file naming defines - */ + */ #ifdef _WIN32 @@ -664,7 +654,6 @@ /* * Mutually exclusive CURLRES_* definitions. */ - #if defined(USE_IPV6) && defined(HAVE_GETADDRINFO) # define CURLRES_IPV6 #elif defined(USE_IPV6) && (defined(_WIN32) || defined(__CYGWIN__)) @@ -792,7 +781,6 @@ /* * Include macros and defines that should only be processed once. */ - #ifndef HEADER_CURL_SETUP_ONCE_H #include "curl_setup_once.h" #endif @@ -800,7 +788,6 @@ /* * Definition of our NOP statement Object-like macro */ - #ifndef Curl_nop_stmt #define Curl_nop_stmt do { } while(0) #endif @@ -808,7 +795,6 @@ /* * Ensure that Winsock and lwIP TCP/IP stacks are not mixed. */ - #if defined(__LWIP_OPT_H__) || defined(LWIP_HDR_OPT_H) # if defined(SOCKET) || defined(USE_WINSOCK) # error "Winsock and lwIP TCP/IP stack definitions shall not coexist!" @@ -818,7 +804,6 @@ /* * shutdown() flags for systems that do not define them */ - #ifndef SHUT_RD #define SHUT_RD 0x00 #endif diff --git a/lib/curl_setup_once.h b/lib/curl_setup_once.h index cf494b2ba8b0..f9395aa7b51a 100644 --- a/lib/curl_setup_once.h +++ b/lib/curl_setup_once.h @@ -181,15 +181,15 @@ struct timeval { * Function-like macro definition used to close a socket. */ #ifdef HAVE_CLOSESOCKET -# define CURL_SCLOSE(x) closesocket((x)) +# define CURL_SCLOSE(x) closesocket(x) #elif defined(HAVE_CLOSESOCKET_CAMEL) -# define CURL_SCLOSE(x) CloseSocket((x)) +# define CURL_SCLOSE(x) CloseSocket(x) #elif defined(MSDOS) /* Watt-32 */ -# define CURL_SCLOSE(x) close_s((x)) +# define CURL_SCLOSE(x) close_s(x) #elif defined(USE_LWIPSOCK) -# define CURL_SCLOSE(x) lwip_close((x)) +# define CURL_SCLOSE(x) lwip_close(x) #else -# define CURL_SCLOSE(x) close((x)) +# define CURL_SCLOSE(x) close(x) #endif /* diff --git a/lib/curlx/base64.c b/lib/curlx/base64.c index 4fc525387e5f..6ea1e425b49c 100644 --- a/lib/curlx/base64.c +++ b/lib/curlx/base64.c @@ -39,12 +39,13 @@ const char Curl_base64encdec[] = static const char base64url[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"; -static const unsigned char decodetable[] = -{ 62, 255, 255, 255, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 255, 255, 255, - 255, 255, 255, 255, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, - 17, 18, 19, 20, 21, 22, 23, 24, 25, 255, 255, 255, 255, 255, 255, 26, 27, 28, - 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, - 48, 49, 50, 51 }; +static const unsigned char decodetable[] = { + 62, 255, 255, 255, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 255, + 255, 255, 255, 255, 255, 255, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, + 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, + 255, 255, 255, 255, 255, 255, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, + 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51 +}; /* * curlx_base64_decode() * diff --git a/lib/curlx/multibyte.h b/lib/curlx/multibyte.h index 8b19257222ca..26da0f0843e0 100644 --- a/lib/curlx/multibyte.h +++ b/lib/curlx/multibyte.h @@ -45,8 +45,8 @@ wchar_t *curlx_convert_UTF8_to_wchar(const char *str_utf8); char *curlx_convert_wchar_to_UTF8(const wchar_t *str_w); -#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_convert_UTF8_to_tchar(ptr) curlx_convert_UTF8_to_wchar(ptr) +#define curlx_convert_tchar_to_UTF8(ptr) curlx_convert_wchar_to_UTF8(ptr) typedef union { unsigned short *tchar_ptr; diff --git a/lib/curlx/strparse.h b/lib/curlx/strparse.h index 6a0bf28d6cbc..7fb90ac40f89 100644 --- a/lib/curlx/strparse.h +++ b/lib/curlx/strparse.h @@ -45,7 +45,7 @@ struct Curl_str { void curlx_str_init(struct Curl_str *out); void curlx_str_assign(struct Curl_str *out, const char *str, size_t len); -#define curlx_str(x) ((x)->str) +#define curlx_str(x) ((x)->str) #define curlx_strlen(x) ((x)->len) /* Get a word until the first space diff --git a/lib/vtls/wolfssl.c b/lib/vtls/wolfssl.c index cfefeb9320c7..d4d586b0ea35 100644 --- a/lib/vtls/wolfssl.c +++ b/lib/vtls/wolfssl.c @@ -1515,7 +1515,7 @@ static CURLcode wssl_connect_step1(struct Curl_cfilter *cf, wolfSSL_BIO_set_data(bio, cf); wolfSSL_set_bio(wssl->ssl, bio, bio); } -#else /* USE_BIO_CHAIN */ +#else /* !USE_BIO_CHAIN */ curl_socket_t sockfd = Curl_conn_cf_get_socket(cf, data); if(sockfd > INT_MAX) { failf(data, "SSL: socket value too large"); @@ -1526,7 +1526,7 @@ static CURLcode wssl_connect_step1(struct Curl_cfilter *cf, failf(data, "SSL: wolfSSL_set_fd failed"); return CURLE_SSL_CONNECT_ERROR; } -#endif /* !USE_BIO_CHAIN */ +#endif /* USE_BIO_CHAIN */ return CURLE_OK; } diff --git a/src/tool_bname.h b/src/tool_bname.h index d091c2231a8d..4047c5cc78c8 100644 --- a/src/tool_bname.h +++ b/src/tool_bname.h @@ -29,7 +29,7 @@ char *tool_basename(char *path); -#define basename(x) tool_basename((x)) +#define basename(x) tool_basename(x) #endif /* HAVE_BASENAME */ diff --git a/src/tool_dirhie.c b/src/tool_dirhie.c index 058403d66688..e0eef03a11a3 100644 --- a/src/tool_dirhie.c +++ b/src/tool_dirhie.c @@ -31,7 +31,7 @@ #include "tool_msgs.h" #if defined(_WIN32) || (defined(MSDOS) && !defined(__DJGPP__)) -# define mkdir(x, y) (mkdir)((x)) +# define mkdir(x, y) (mkdir)(x) # ifndef F_OK # define F_OK 0 # endif diff --git a/src/tool_getparam.h b/src/tool_getparam.h index 1b0d8017d5e5..44eb361edca5 100644 --- a/src/tool_getparam.h +++ b/src/tool_getparam.h @@ -381,15 +381,15 @@ ParameterError parse_args(int argc, argv_item_t argv[]); #if defined(UNICODE) && defined(_WIN32) -#define convert_UTF8_to_tchar(ptr) curlx_convert_UTF8_to_wchar((ptr)) -#define convert_tchar_to_UTF8(ptr) curlx_convert_wchar_to_UTF8((ptr)) +#define convert_UTF8_to_tchar(ptr) curlx_convert_UTF8_to_wchar(ptr) +#define convert_tchar_to_UTF8(ptr) curlx_convert_wchar_to_UTF8(ptr) #define unicodefree(ptr) curlx_free(ptr) #else #define convert_UTF8_to_tchar(ptr) (const char *)(ptr) #define convert_tchar_to_UTF8(ptr) (const char *)(ptr) -#define unicodefree(ptr) do {} while(0) +#define unicodefree(ptr) do {} while(0) #endif diff --git a/tests/libtest/first.h b/tests/libtest/first.h index 2ad600ef60e2..c536adc2ca60 100644 --- a/tests/libtest/first.h +++ b/tests/libtest/first.h @@ -59,12 +59,12 @@ extern int unitfail; /* for unittests */ #define CURL_GNUC_DIAG #endif -#define test_setopt(A, B, C) \ - if((res = curl_easy_setopt((A), (B), (C))) != CURLE_OK) \ +#define test_setopt(A, B, C) \ + if((res = curl_easy_setopt(A, B, C)) != CURLE_OK) \ goto test_cleanup -#define test_multi_setopt(A, B, C) \ - if((res = curl_multi_setopt((A), (B), (C))) != CURLE_OK) \ +#define test_multi_setopt(A, B, C) \ + if((res = curl_multi_setopt(A, B, C)) != CURLE_OK) \ goto test_cleanup extern const char *libtest_arg2; /* set by first.c to the argv[2] or NULL */ @@ -144,376 +144,419 @@ void ws_close(CURL *curl); /* ---------------------------------------------------------------- */ -#define exe_easy_init(A, Y, Z) do { \ - if(((A) = curl_easy_init()) == NULL) { \ - curl_mfprintf(stderr, "%s:%d curl_easy_init() failed\n", (Y), (Z)); \ - res = TEST_ERR_EASY_INIT; \ - } \ -} while(0) +#define exe_easy_init(A, Y, Z) \ + do { \ + if(((A) = curl_easy_init()) == NULL) { \ + curl_mfprintf(stderr, "%s:%d curl_easy_init() failed\n", Y, Z); \ + res = TEST_ERR_EASY_INIT; \ + } \ + } while(0) #define res_easy_init(A) \ - exe_easy_init((A), (__FILE__), (__LINE__)) + exe_easy_init(A, __FILE__, __LINE__) -#define chk_easy_init(A, Y, Z) do { \ - exe_easy_init((A), (Y), (Z)); \ - if(res) \ - goto test_cleanup; \ -} while(0) +#define chk_easy_init(A, Y, Z) \ + do { \ + exe_easy_init(A, Y, Z); \ + if(res) \ + goto test_cleanup; \ + } while(0) #define easy_init(A) \ - chk_easy_init((A), (__FILE__), (__LINE__)) + chk_easy_init(A, __FILE__, __LINE__) /* ---------------------------------------------------------------- */ -#define exe_multi_init(A, Y, Z) do { \ - if(((A) = curl_multi_init()) == NULL) { \ - curl_mfprintf(stderr, "%s:%d curl_multi_init() failed\n", (Y), (Z)); \ - res = TEST_ERR_MULTI; \ - } \ -} while(0) +#define exe_multi_init(A, Y, Z) \ + do { \ + if(((A) = curl_multi_init()) == NULL) { \ + curl_mfprintf(stderr, "%s:%d curl_multi_init() failed\n", Y, Z); \ + res = TEST_ERR_MULTI; \ + } \ + } while(0) #define res_multi_init(A) \ - exe_multi_init((A), (__FILE__), (__LINE__)) + exe_multi_init(A, __FILE__, __LINE__) -#define chk_multi_init(A, Y, Z) do { \ - exe_multi_init((A), (Y), (Z)); \ - if(res) \ - goto test_cleanup; \ -} while(0) +#define chk_multi_init(A, Y, Z) \ + do { \ + exe_multi_init(A, Y, Z); \ + if(res) \ + goto test_cleanup; \ + } while(0) #define multi_init(A) \ - chk_multi_init((A), (__FILE__), (__LINE__)) + chk_multi_init(A, __FILE__, __LINE__) /* ---------------------------------------------------------------- */ -#define exe_easy_setopt(A, B, C, Y, Z) do { \ - CURLcode ec; \ - if((ec = curl_easy_setopt((A), (B), (C))) != CURLE_OK) { \ - curl_mfprintf(stderr, "%s:%d curl_easy_setopt() failed, " \ - "with code %d (%s)\n", \ - (Y), (Z), ec, curl_easy_strerror(ec)); \ - res = ec; \ - } \ -} while(0) +#define exe_easy_setopt(A, B, C, Y, Z) \ + do { \ + CURLcode ec; \ + if((ec = curl_easy_setopt(A, B, C)) != CURLE_OK) { \ + curl_mfprintf(stderr, \ + "%s:%d curl_easy_setopt() failed, " \ + "with code %d (%s)\n", \ + Y, Z, ec, curl_easy_strerror(ec)); \ + res = ec; \ + } \ + } while(0) #define res_easy_setopt(A, B, C) \ - exe_easy_setopt((A), (B), (C), (__FILE__), (__LINE__)) + exe_easy_setopt(A, B, C, __FILE__, __LINE__) -#define chk_easy_setopt(A, B, C, Y, Z) do { \ - exe_easy_setopt((A), (B), (C), (Y), (Z)); \ - if(res) \ - goto test_cleanup; \ -} while(0) +#define chk_easy_setopt(A, B, C, Y, Z) \ + do { \ + exe_easy_setopt(A, B, C, Y, Z); \ + if(res) \ + goto test_cleanup; \ + } while(0) #define easy_setopt(A, B, C) \ - chk_easy_setopt((A), (B), (C), (__FILE__), (__LINE__)) + chk_easy_setopt(A, B, C, __FILE__, __LINE__) /* ---------------------------------------------------------------- */ -#define exe_multi_setopt(A, B, C, Y, Z) do { \ - CURLMcode ec; \ - if((ec = curl_multi_setopt((A), (B), (C))) != CURLM_OK) { \ - curl_mfprintf(stderr, "%s:%d curl_multi_setopt() failed, " \ - "with code %d (%s)\n", \ - (Y), (Z), ec, curl_multi_strerror(ec)); \ - res = TEST_ERR_MULTI; \ - } \ -} while(0) +#define exe_multi_setopt(A, B, C, Y, Z) \ + do { \ + CURLMcode ec; \ + if((ec = curl_multi_setopt(A, B, C)) != CURLM_OK) { \ + curl_mfprintf(stderr, \ + "%s:%d curl_multi_setopt() failed, " \ + "with code %d (%s)\n", \ + Y, Z, ec, curl_multi_strerror(ec)); \ + res = TEST_ERR_MULTI; \ + } \ + } while(0) #define res_multi_setopt(A, B, C) \ - exe_multi_setopt((A), (B), (C), (__FILE__), (__LINE__)) + exe_multi_setopt(A, B, C, __FILE__, __LINE__) -#define chk_multi_setopt(A, B, C, Y, Z) do { \ - exe_multi_setopt((A), (B), (C), (Y), (Z)); \ - if(res) \ - goto test_cleanup; \ -} while(0) +#define chk_multi_setopt(A, B, C, Y, Z) \ + do { \ + exe_multi_setopt(A, B, C, Y, Z); \ + if(res) \ + goto test_cleanup; \ + } while(0) #define multi_setopt(A, B, C) \ - chk_multi_setopt((A), (B), (C), (__FILE__), (__LINE__)) + chk_multi_setopt(A, B, C, __FILE__, __LINE__) /* ---------------------------------------------------------------- */ -#define exe_multi_add_handle(A, B, Y, Z) do { \ - CURLMcode ec; \ - if((ec = curl_multi_add_handle((A), (B))) != CURLM_OK) { \ - curl_mfprintf(stderr, "%s:%d curl_multi_add_handle() failed, " \ - "with code %d (%s)\n", \ - (Y), (Z), ec, curl_multi_strerror(ec)); \ - res = TEST_ERR_MULTI; \ - } \ -} while(0) +#define exe_multi_add_handle(A, B, Y, Z) \ + do { \ + CURLMcode ec; \ + if((ec = curl_multi_add_handle(A, B)) != CURLM_OK) { \ + curl_mfprintf(stderr, \ + "%s:%d curl_multi_add_handle() failed, " \ + "with code %d (%s)\n", \ + Y, Z, ec, curl_multi_strerror(ec)); \ + res = TEST_ERR_MULTI; \ + } \ + } while(0) #define res_multi_add_handle(A, B) \ - exe_multi_add_handle((A), (B), (__FILE__), (__LINE__)) + exe_multi_add_handle(A, B, __FILE__, __LINE__) -#define chk_multi_add_handle(A, B, Y, Z) do { \ - exe_multi_add_handle((A), (B), (Y), (Z)); \ - if(res) \ - goto test_cleanup; \ -} while(0) +#define chk_multi_add_handle(A, B, Y, Z) \ + do { \ + exe_multi_add_handle(A, B, Y, Z); \ + if(res) \ + goto test_cleanup; \ + } while(0) #define multi_add_handle(A, B) \ - chk_multi_add_handle((A), (B), (__FILE__), (__LINE__)) + chk_multi_add_handle(A, B, __FILE__, __LINE__) /* ---------------------------------------------------------------- */ -#define exe_multi_remove_handle(A, B, Y, Z) do { \ - CURLMcode ec; \ - if((ec = curl_multi_remove_handle((A), (B))) != CURLM_OK) { \ - curl_mfprintf(stderr, "%s:%d curl_multi_remove_handle() failed, " \ - "with code %d (%s)\n", \ - (Y), (Z), ec, curl_multi_strerror(ec)); \ - res = TEST_ERR_MULTI; \ - } \ -} while(0) +#define exe_multi_remove_handle(A, B, Y, Z) \ + do { \ + CURLMcode ec; \ + if((ec = curl_multi_remove_handle(A, B)) != CURLM_OK) { \ + curl_mfprintf(stderr, \ + "%s:%d curl_multi_remove_handle() failed, " \ + "with code %d (%s)\n", \ + Y, Z, ec, curl_multi_strerror(ec)); \ + res = TEST_ERR_MULTI; \ + } \ + } while(0) #define res_multi_remove_handle(A, B) \ - exe_multi_remove_handle((A), (B), (__FILE__), (__LINE__)) - -#define chk_multi_remove_handle(A, B, Y, Z) do { \ - exe_multi_remove_handle((A), (B), (Y), (Z)); \ - if(res) \ - goto test_cleanup; \ -} while(0) + exe_multi_remove_handle(A, B, __FILE__, __LINE__) +#define chk_multi_remove_handle(A, B, Y, Z) \ + do { \ + exe_multi_remove_handle(A, B, Y, Z); \ + if(res) \ + goto test_cleanup; \ + } while(0) #define multi_remove_handle(A, B) \ - chk_multi_remove_handle((A), (B), (__FILE__), (__LINE__)) + chk_multi_remove_handle(A, B, __FILE__, __LINE__) /* ---------------------------------------------------------------- */ -#define exe_multi_perform(A, B, Y, Z) do { \ - CURLMcode ec; \ - if((ec = curl_multi_perform((A), (B))) != CURLM_OK) { \ - curl_mfprintf(stderr, "%s:%d curl_multi_perform() failed, " \ - "with code %d (%s)\n", \ - (Y), (Z), ec, curl_multi_strerror(ec)); \ - res = TEST_ERR_MULTI; \ - } \ - else if(*((B)) < 0) { \ - curl_mfprintf(stderr, "%s:%d curl_multi_perform() succeeded, " \ - "but returned invalid running_handles value (%d)\n", \ - (Y), (Z), (int)*((B))); \ - res = TEST_ERR_NUM_HANDLES; \ - } \ -} while(0) +#define exe_multi_perform(A, B, Y, Z) \ + do { \ + CURLMcode ec; \ + if((ec = curl_multi_perform(A, B)) != CURLM_OK) { \ + curl_mfprintf(stderr, \ + "%s:%d curl_multi_perform() failed, " \ + "with code %d (%s)\n", \ + Y, Z, ec, curl_multi_strerror(ec)); \ + res = TEST_ERR_MULTI; \ + } \ + else if(*(B) < 0) { \ + curl_mfprintf(stderr, \ + "%s:%d curl_multi_perform() succeeded, " \ + "but returned invalid running_handles value (%d)\n", \ + Y, Z, (int)*(B)); \ + res = TEST_ERR_NUM_HANDLES; \ + } \ + } while(0) #define res_multi_perform(A, B) \ - exe_multi_perform((A), (B), (__FILE__), (__LINE__)) + exe_multi_perform(A, B, __FILE__, __LINE__) -#define chk_multi_perform(A, B, Y, Z) do { \ - exe_multi_perform((A), (B), (Y), (Z)); \ - if(res) \ - goto test_cleanup; \ -} while(0) +#define chk_multi_perform(A, B, Y, Z) \ + do { \ + exe_multi_perform(A, B, Y, Z); \ + if(res) \ + goto test_cleanup; \ + } while(0) #define multi_perform(A, B) \ - chk_multi_perform((A), (B), (__FILE__), (__LINE__)) + chk_multi_perform(A, B, __FILE__, __LINE__) /* ---------------------------------------------------------------- */ -#define exe_multi_fdset(A, B, C, D, E, Y, Z) do { \ - CURLMcode ec; \ - if((ec = curl_multi_fdset((A), (B), (C), (D), (E))) != CURLM_OK) { \ - curl_mfprintf(stderr, "%s:%d curl_multi_fdset() failed, " \ - "with code %d (%s)\n", \ - (Y), (Z), ec, curl_multi_strerror(ec)); \ - res = TEST_ERR_MULTI; \ - } \ - else if(*((E)) < -1) { \ - curl_mfprintf(stderr, "%s:%d curl_multi_fdset() succeeded, " \ - "but returned invalid max_fd value (%d)\n", \ - (Y), (Z), (int)*((E))); \ - res = TEST_ERR_NUM_HANDLES; \ - } \ -} while(0) +#define exe_multi_fdset(A, B, C, D, E, Y, Z) \ + do { \ + CURLMcode ec; \ + if((ec = curl_multi_fdset(A, B, C, D, E)) != CURLM_OK) { \ + curl_mfprintf(stderr, \ + "%s:%d curl_multi_fdset() failed, " \ + "with code %d (%s)\n", \ + Y, Z, ec, curl_multi_strerror(ec)); \ + res = TEST_ERR_MULTI; \ + } \ + else if(*(E) < -1) { \ + curl_mfprintf(stderr, \ + "%s:%d curl_multi_fdset() succeeded, " \ + "but returned invalid max_fd value (%d)\n", \ + Y, Z, (int)*(E)); \ + res = TEST_ERR_NUM_HANDLES; \ + } \ + } while(0) #define res_multi_fdset(A, B, C, D, E) \ - exe_multi_fdset((A), (B), (C), (D), (E), (__FILE__), (__LINE__)) + exe_multi_fdset(A, B, C, D, E, __FILE__, __LINE__) -#define chk_multi_fdset(A, B, C, D, E, Y, Z) do { \ - exe_multi_fdset((A), (B), (C), (D), (E), (Y), (Z)); \ - if(res) \ - goto test_cleanup; \ +#define chk_multi_fdset(A, B, C, D, E, Y, Z) \ + do { \ + exe_multi_fdset(A, B, C, D, E, Y, Z); \ + if(res) \ + goto test_cleanup; \ } while(0) #define multi_fdset(A, B, C, D, E) \ - chk_multi_fdset((A), (B), (C), (D), (E), (__FILE__), (__LINE__)) + chk_multi_fdset(A, B, C, D, E, __FILE__, __LINE__) /* ---------------------------------------------------------------- */ -#define exe_multi_timeout(A, B, Y, Z) do { \ - CURLMcode ec; \ - if((ec = curl_multi_timeout((A), (B))) != CURLM_OK) { \ - curl_mfprintf(stderr, "%s:%d curl_multi_timeout() failed, " \ - "with code %d (%s)\n", \ - (Y), (Z), ec, curl_multi_strerror(ec)); \ - res = TEST_ERR_BAD_TIMEOUT; \ - } \ - else if(*((B)) < -1L) { \ - curl_mfprintf(stderr, "%s:%d curl_multi_timeout() succeeded, " \ - "but returned invalid timeout value (%ld)\n", \ - (Y), (Z), (long)*((B))); \ - res = TEST_ERR_BAD_TIMEOUT; \ - } \ -} while(0) +#define exe_multi_timeout(A, B, Y, Z) \ + do { \ + CURLMcode ec; \ + if((ec = curl_multi_timeout(A, B)) != CURLM_OK) { \ + curl_mfprintf(stderr, \ + "%s:%d curl_multi_timeout() failed, " \ + "with code %d (%s)\n", \ + Y, Z, ec, curl_multi_strerror(ec)); \ + res = TEST_ERR_BAD_TIMEOUT; \ + } \ + else if(*(B) < -1L) { \ + curl_mfprintf(stderr, \ + "%s:%d curl_multi_timeout() succeeded, " \ + "but returned invalid timeout value (%ld)\n", \ + Y, Z, (long)*(B)); \ + res = TEST_ERR_BAD_TIMEOUT; \ + } \ + } while(0) #define res_multi_timeout(A, B) \ - exe_multi_timeout((A), (B), (__FILE__), (__LINE__)) + exe_multi_timeout(A, B, __FILE__, __LINE__) -#define chk_multi_timeout(A, B, Y, Z) do { \ - exe_multi_timeout((A), (B), (Y), (Z)); \ - if(res) \ - goto test_cleanup; \ +#define chk_multi_timeout(A, B, Y, Z) \ + do { \ + exe_multi_timeout(A, B, Y, Z); \ + if(res) \ + goto test_cleanup; \ } while(0) #define multi_timeout(A, B) \ - chk_multi_timeout((A), (B), (__FILE__), (__LINE__)) + chk_multi_timeout(A, B, __FILE__, __LINE__) /* ---------------------------------------------------------------- */ -#define exe_multi_poll(A, B, C, D, E, Y, Z) do { \ - CURLMcode ec; \ - if((ec = curl_multi_poll((A), (B), (C), (D), (E))) != CURLM_OK) { \ - curl_mfprintf(stderr, "%s:%d curl_multi_poll() failed, " \ - "with code %d (%s)\n", \ - (Y), (Z), ec, curl_multi_strerror(ec)); \ - res = TEST_ERR_MULTI; \ - } \ - else if(*((E)) < 0) { \ - curl_mfprintf(stderr, "%s:%d curl_multi_poll() succeeded, " \ - "but returned invalid numfds value (%d)\n", \ - (Y), (Z), (int)*((E))); \ - res = TEST_ERR_NUM_HANDLES; \ - } \ -} while(0) +#define exe_multi_poll(A, B, C, D, E, Y, Z) \ + do { \ + CURLMcode ec; \ + if((ec = curl_multi_poll(A, B, C, D, E)) != CURLM_OK) { \ + curl_mfprintf(stderr, \ + "%s:%d curl_multi_poll() failed, " \ + "with code %d (%s)\n", \ + Y, Z, ec, curl_multi_strerror(ec)); \ + res = TEST_ERR_MULTI; \ + } \ + else if(*(E) < 0) { \ + curl_mfprintf(stderr, \ + "%s:%d curl_multi_poll() succeeded, " \ + "but returned invalid numfds value (%d)\n", \ + Y, Z, (int)*(E)); \ + res = TEST_ERR_NUM_HANDLES; \ + } \ + } while(0) #define res_multi_poll(A, B, C, D, E) \ - exe_multi_poll((A), (B), (C), (D), (E), (__FILE__), (__LINE__)) + exe_multi_poll(A, B, C, D, E, __FILE__, __LINE__) -#define chk_multi_poll(A, B, C, D, E, Y, Z) do { \ - exe_multi_poll((A), (B), (C), (D), (E), (Y), (Z)); \ - if(res) \ - goto test_cleanup; \ -} while(0) +#define chk_multi_poll(A, B, C, D, E, Y, Z) \ + do { \ + exe_multi_poll(A, B, C, D, E, Y, Z); \ + if(res) \ + goto test_cleanup; \ + } while(0) #define multi_poll(A, B, C, D, E) \ - chk_multi_poll((A), (B), (C), (D), (E), (__FILE__), (__LINE__)) + chk_multi_poll(A, B, C, D, E, __FILE__, __LINE__) /* ---------------------------------------------------------------- */ -#define exe_multi_wakeup(A, Y, Z) do { \ - CURLMcode ec; \ - if((ec = curl_multi_wakeup((A))) != CURLM_OK) { \ - curl_mfprintf(stderr, "%s:%d curl_multi_wakeup() failed, " \ - "with code %d (%s)\n", \ - (Y), (Z), ec, curl_multi_strerror(ec)); \ - res = TEST_ERR_MULTI; \ - } \ -} while(0) +#define exe_multi_wakeup(A, Y, Z) \ + do { \ + CURLMcode ec; \ + if((ec = curl_multi_wakeup(A)) != CURLM_OK) { \ + curl_mfprintf(stderr, \ + "%s:%d curl_multi_wakeup() failed, " \ + "with code %d (%s)\n", \ + Y, Z, ec, curl_multi_strerror(ec)); \ + res = TEST_ERR_MULTI; \ + } \ + } while(0) #define res_multi_wakeup(A) \ - exe_multi_wakeup((A), (__FILE__), (__LINE__)) + exe_multi_wakeup(A, __FILE__, __LINE__) -#define chk_multi_wakeup(A, Y, Z) do { \ - exe_multi_wakeup((A), (Y), (Z)); \ - if(res) \ - goto test_cleanup; \ -} while(0) +#define chk_multi_wakeup(A, Y, Z) \ + do { \ + exe_multi_wakeup(A, Y, Z); \ + if(res) \ + goto test_cleanup; \ + } while(0) #define multi_wakeup(A) \ - chk_multi_wakeup((A), (__FILE__), (__LINE__)) + chk_multi_wakeup(A, __FILE__, __LINE__) /* ---------------------------------------------------------------- */ -#define exe_select_test(A, B, C, D, E, Y, Z) do { \ - int ec; \ - if(select_wrapper((A), (B), (C), (D), (E)) == -1) { \ - char ecbuf[STRERROR_LEN]; \ - ec = SOCKERRNO; \ - curl_mfprintf(stderr, "%s:%d select() failed, with " \ - "errno %d (%s)\n", \ - (Y), (Z), \ - ec, curlx_strerror(ec, ecbuf, sizeof(ecbuf))); \ - res = TEST_ERR_SELECT; \ - } \ +#define exe_select_test(A, B, C, D, E, Y, Z) \ + do { \ + int ec; \ + if(select_wrapper(A, B, C, D, E) == -1) { \ + char ecbuf[STRERROR_LEN]; \ + ec = SOCKERRNO; \ + curl_mfprintf(stderr, \ + "%s:%d select() failed, with " \ + "errno %d (%s)\n", \ + Y, Z, ec, curlx_strerror(ec, ecbuf, sizeof(ecbuf))); \ + res = TEST_ERR_SELECT; \ + } \ } while(0) #define res_select_test(A, B, C, D, E) \ - exe_select_test((A), (B), (C), (D), (E), (__FILE__), (__LINE__)) + exe_select_test(A, B, C, D, E, __FILE__, __LINE__) -#define chk_select_test(A, B, C, D, E, Y, Z) do { \ - exe_select_test((A), (B), (C), (D), (E), (Y), (Z)); \ - if(res) \ - goto test_cleanup; \ +#define chk_select_test(A, B, C, D, E, Y, Z) \ + do { \ + exe_select_test(A, B, C, D, E, Y, Z); \ + if(res) \ + goto test_cleanup; \ } while(0) #define select_test(A, B, C, D, E) \ - chk_select_test((A), (B), (C), (D), (E), (__FILE__), (__LINE__)) + chk_select_test(A, B, C, D, E, __FILE__, __LINE__) /* ---------------------------------------------------------------- */ -#define start_test_timing() do { \ - tv_test_start = curlx_now(); \ -} while(0) +#define start_test_timing() \ + do { \ + tv_test_start = curlx_now(); \ + } while(0) #define TEST_HANG_TIMEOUT 60 * 1000 /* global default */ -#define exe_test_timedout(T, Y, Z) do { \ - timediff_t timediff = curlx_timediff_ms(curlx_now(), tv_test_start); \ - if(timediff > (T)) { \ - curl_mfprintf(stderr, "%s:%d ABORTING TEST, since it seems " \ - "that it would have run forever (%ld ms > %ld ms)\n", \ - (Y), (Z), (long)timediff, (long)(TEST_HANG_TIMEOUT)); \ - res = TEST_ERR_RUNS_FOREVER; \ - } \ -} while(0) +#define exe_test_timedout(T, Y, Z) \ + do { \ + timediff_t timediff = curlx_timediff_ms(curlx_now(), tv_test_start); \ + if(timediff > (T)) { \ + curl_mfprintf(stderr, \ + "%s:%d ABORTING TEST, since it seems " \ + "that it would have run forever (%ld ms > %ld ms)\n", \ + Y, Z, (long)timediff, (long)(TEST_HANG_TIMEOUT)); \ + res = TEST_ERR_RUNS_FOREVER; \ + } \ + } while(0) #define res_test_timedout() \ - exe_test_timedout(TEST_HANG_TIMEOUT, (__FILE__), (__LINE__)) + exe_test_timedout(TEST_HANG_TIMEOUT, __FILE__, __LINE__) #define res_test_timedout_custom(T) \ - exe_test_timedout((T), (__FILE__), (__LINE__)) + exe_test_timedout(T, __FILE__, __LINE__) -#define chk_test_timedout(T, Y, Z) do { \ - exe_test_timedout(T, Y, Z); \ - if(res) \ - goto test_cleanup; \ +#define chk_test_timedout(T, Y, Z) \ + do { \ + exe_test_timedout(T, Y, Z); \ + if(res) \ + goto test_cleanup; \ } while(0) #define abort_on_test_timeout() \ - chk_test_timedout(TEST_HANG_TIMEOUT, (__FILE__), (__LINE__)) + chk_test_timedout(TEST_HANG_TIMEOUT, __FILE__, __LINE__) #define abort_on_test_timeout_custom(T) \ - chk_test_timedout((T), (__FILE__), (__LINE__)) + chk_test_timedout(T, __FILE__, __LINE__) /* ---------------------------------------------------------------- */ -#define exe_global_init(A, Y, Z) do { \ - CURLcode ec; \ - if((ec = curl_global_init((A))) != CURLE_OK) { \ - curl_mfprintf(stderr, "%s:%d curl_global_init() failed, " \ - "with code %d (%s)\n", \ - (Y), (Z), ec, curl_easy_strerror(ec)); \ - res = ec; \ - } \ -} while(0) +#define exe_global_init(A, Y, Z) \ + do { \ + CURLcode ec; \ + if((ec = curl_global_init(A)) != CURLE_OK) { \ + curl_mfprintf(stderr, \ + "%s:%d curl_global_init() failed, " \ + "with code %d (%s)\n", \ + Y, Z, ec, curl_easy_strerror(ec)); \ + res = ec; \ + } \ + } while(0) #define res_global_init(A) \ - exe_global_init((A), (__FILE__), (__LINE__)) + exe_global_init(A, __FILE__, __LINE__) -#define chk_global_init(A, Y, Z) do { \ - exe_global_init((A), (Y), (Z)); \ - if(res) \ - return res; \ +#define chk_global_init(A, Y, Z) \ + do { \ + exe_global_init(A, Y, Z); \ + if(res) \ + return res; \ } while(0) /* global_init() is different than other macros. In case of failure it 'return's instead of going to 'test_cleanup'. */ #define global_init(A) \ - chk_global_init((A), (__FILE__), (__LINE__)) + chk_global_init(A, __FILE__, __LINE__) #define NO_SUPPORT_BUILT_IN \ { \ diff --git a/tests/libtest/unitcheck.h b/tests/libtest/unitcheck.h index 8007f9f8b5ca..231aacff838f 100644 --- a/tests/libtest/unitcheck.h +++ b/tests/libtest/unitcheck.h @@ -56,7 +56,8 @@ /* fail() is for when the test case figured out by itself that a check proved a failure */ -#define fail(msg) do { \ +#define fail(msg) \ + do { \ curl_mfprintf(stderr, "%s:%d test FAILED: '%s'\n", \ __FILE__, __LINE__, msg); \ unitfail++; \ From cca815ccfd98279f704f3bc75ed0cef8976e150f Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Fri, 5 Dec 2025 16:14:19 +0100 Subject: [PATCH 202/415] test1498: disable 'HTTP PUT from stdin' test on Windows Test became flaky with memanalyze errors after merging #19845, in a TrackMemory Windows Unicode c-ares openssl-quic build: GHA/windows: mingw, AM x86_64 c-ares U. Disable it until further investigation. This test uses the Windows-specific multi-threaded stdin code that caused issues in the past. It's also using `TerminateThread()`, that apps aren't supposed to. Examples: https://github.com/curl/curl/pull/19845#issuecomment-3614921298 https://github.com/curl/curl/actions/runs/19948992659/job/57205061260?pr=19845#step:13:3028 https://github.com/curl/curl/actions/runs/19966429786/job/57259325027?pr=19852#step:13:3030 Also seen to fail earlier while testing torture tests on Windows: https://github.com/curl/curl/pull/19675#issuecomment-3573154110 Ref: 4e051ff5506319ee87e3656be8f76b01de217103 #19845 Closes #19855 --- tests/data/test1498 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/data/test1498 b/tests/data/test1498 index 467730d3a5a8..b9ba70fbc0eb 100644 --- a/tests/data/test1498 +++ b/tests/data/test1498 @@ -25,6 +25,9 @@ blablabla http + +!win32 + HTTP PUT from stdin using period From 0b69c4713147cd7c13d1e006abd95df688d687e2 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 5 Dec 2025 13:17:11 +0100 Subject: [PATCH 203/415] docs: remove dead URLs - KNOWN_BUGS: remove dead URL - ECH: remove two dead URLs - MAIL-ETIQUETTE: remove dead URL --- docs/ECH.md | 2 -- docs/KNOWN_BUGS | 2 +- docs/MAIL-ETIQUETTE.md | 3 +-- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/docs/ECH.md b/docs/ECH.md index b40cd17e78b6..6f236a106b52 100644 --- a/docs/ECH.md +++ b/docs/ECH.md @@ -76,8 +76,6 @@ The above works for these test sites: ```sh https://defo.ie/ech-check.php -https://draft-13.esni.defo.ie:8413/stats -https://draft-13.esni.defo.ie:8414/stats https://crypto.cloudflare.com/cdn-cgi/trace https://tls-ech.dev ``` diff --git a/docs/KNOWN_BUGS b/docs/KNOWN_BUGS index 15ca40102aa8..278cc2a0977b 100644 --- a/docs/KNOWN_BUGS +++ b/docs/KNOWN_BUGS @@ -311,7 +311,7 @@ problems may have been fixed or changed somewhat since this was written. libcurl fails to build with MIT Kerberos for Windows (KfW) due to KfW's library header files exporting symbols/macros that should be kept private to - the KfW library. See ticket #5601 at https://krbdev.mit.edu/rt/ + the KfW library. 6.3 NTLM in system context uses wrong name diff --git a/docs/MAIL-ETIQUETTE.md b/docs/MAIL-ETIQUETTE.md index 3de77b17bf7a..4c2f95f38bee 100644 --- a/docs/MAIL-ETIQUETTE.md +++ b/docs/MAIL-ETIQUETTE.md @@ -223,8 +223,7 @@ mails to your friends. We speak plain text mails. ### Quoting Quote as little as possible. Just enough to provide the context you cannot -eave out. A lengthy description can be found -[here](https://www.netmeister.org/news/learn2quote.html). +leave out. ### Digest From 58394b1c8c3bad2b4c0a96b3da194c81afedaf7f Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 5 Dec 2025 13:33:02 +0100 Subject: [PATCH 204/415] docs: use .example URLs for proxies --- docs/cmdline-opts/proxy-cacert.md | 2 +- docs/cmdline-opts/proxy-capath.md | 2 +- docs/cmdline-opts/proxy-cert-type.md | 2 +- docs/cmdline-opts/proxy-cert.md | 2 +- docs/cmdline-opts/proxy-ciphers.md | 2 +- docs/cmdline-opts/proxy-crlfile.md | 2 +- docs/cmdline-opts/proxy-insecure.md | 2 +- docs/cmdline-opts/proxy-key-type.md | 2 +- docs/cmdline-opts/proxy-key.md | 2 +- docs/cmdline-opts/proxy-pass.md | 2 +- docs/cmdline-opts/proxy-ssl-allow-beast.md | 2 +- docs/cmdline-opts/proxy-ssl-auto-client-cert.md | 2 +- docs/cmdline-opts/proxy-tlsauthtype.md | 2 +- docs/cmdline-opts/proxy-tlspassword.md | 2 +- docs/cmdline-opts/proxy-tlsuser.md | 2 +- docs/cmdline-opts/proxy-tlsv1.md | 2 +- docs/libcurl/opts/CURLINFO_PROXY_SSL_VERIFYRESULT.md | 2 +- docs/libcurl/opts/CURLOPT_PROXY_CAINFO.md | 2 +- docs/libcurl/opts/CURLOPT_PROXY_CAINFO_BLOB.md | 2 +- docs/libcurl/opts/CURLOPT_PROXY_CAPATH.md | 2 +- docs/libcurl/opts/CURLOPT_PROXY_ISSUERCERT.md | 2 +- docs/libcurl/opts/CURLOPT_PROXY_ISSUERCERT_BLOB.md | 2 +- docs/libcurl/opts/CURLOPT_PROXY_KEYPASSWD.md | 2 +- docs/libcurl/opts/CURLOPT_PROXY_PINNEDPUBLICKEY.md | 2 +- docs/libcurl/opts/CURLOPT_PROXY_SSLCERT.md | 2 +- docs/libcurl/opts/CURLOPT_PROXY_SSLCERTTYPE.md | 2 +- docs/libcurl/opts/CURLOPT_PROXY_SSLCERT_BLOB.md | 2 +- docs/libcurl/opts/CURLOPT_PROXY_SSLKEY.md | 2 +- docs/libcurl/opts/CURLOPT_PROXY_SSLKEYTYPE.md | 2 +- docs/libcurl/opts/CURLOPT_PROXY_SSLKEY_BLOB.md | 2 +- docs/libcurl/opts/CURLOPT_PROXY_SSL_OPTIONS.md | 2 +- docs/libcurl/opts/CURLOPT_PROXY_TLSAUTH_PASSWORD.md | 2 +- docs/libcurl/opts/CURLOPT_PROXY_TLSAUTH_TYPE.md | 2 +- docs/libcurl/opts/CURLOPT_PROXY_TLSAUTH_USERNAME.md | 2 +- 34 files changed, 34 insertions(+), 34 deletions(-) diff --git a/docs/cmdline-opts/proxy-cacert.md b/docs/cmdline-opts/proxy-cacert.md index 682349a7e260..0b2405d1c96a 100644 --- a/docs/cmdline-opts/proxy-cacert.md +++ b/docs/cmdline-opts/proxy-cacert.md @@ -14,7 +14,7 @@ See-also: - dump-ca-embed - proxy Example: - - --proxy-cacert CA-file.txt -x https://proxy $URL + - --proxy-cacert CA-file.txt -x https://proxy.example $URL --- # `--proxy-cacert` diff --git a/docs/cmdline-opts/proxy-capath.md b/docs/cmdline-opts/proxy-capath.md index 91575ae4d8b8..344756a43ebb 100644 --- a/docs/cmdline-opts/proxy-capath.md +++ b/docs/cmdline-opts/proxy-capath.md @@ -13,7 +13,7 @@ See-also: - capath - dump-ca-embed Example: - - --proxy-capath /local/directory -x https://proxy $URL + - --proxy-capath /local/directory -x https://proxy.example $URL --- # `--proxy-capath` diff --git a/docs/cmdline-opts/proxy-cert-type.md b/docs/cmdline-opts/proxy-cert-type.md index 8a1121bb36b3..3dcd2017c46e 100644 --- a/docs/cmdline-opts/proxy-cert-type.md +++ b/docs/cmdline-opts/proxy-cert-type.md @@ -11,7 +11,7 @@ See-also: - proxy-cert - proxy-key Example: - - --proxy-cert-type PEM --proxy-cert file -x https://proxy $URL + - --proxy-cert-type PEM --proxy-cert file -x https://proxy.example $URL --- # `--proxy-cert-type` diff --git a/docs/cmdline-opts/proxy-cert.md b/docs/cmdline-opts/proxy-cert.md index 734766730c67..929791e3a152 100644 --- a/docs/cmdline-opts/proxy-cert.md +++ b/docs/cmdline-opts/proxy-cert.md @@ -12,7 +12,7 @@ See-also: - proxy-key - proxy-cert-type Example: - - --proxy-cert file -x https://proxy $URL + - --proxy-cert file -x https://proxy.example $URL --- # `--proxy-cert` diff --git a/docs/cmdline-opts/proxy-ciphers.md b/docs/cmdline-opts/proxy-ciphers.md index 420e7563bdd7..4cb85e1e67fa 100644 --- a/docs/cmdline-opts/proxy-ciphers.md +++ b/docs/cmdline-opts/proxy-ciphers.md @@ -13,7 +13,7 @@ See-also: - ciphers - proxy Example: - - --proxy-ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256 -x https://proxy $URL + - --proxy-ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256 -x https://proxy.example $URL --- # `--proxy-ciphers` diff --git a/docs/cmdline-opts/proxy-crlfile.md b/docs/cmdline-opts/proxy-crlfile.md index 726e44955781..9f7d3304fa2b 100644 --- a/docs/cmdline-opts/proxy-crlfile.md +++ b/docs/cmdline-opts/proxy-crlfile.md @@ -11,7 +11,7 @@ See-also: - crlfile - proxy Example: - - --proxy-crlfile rejects.txt -x https://proxy $URL + - --proxy-crlfile rejects.txt -x https://proxy.example $URL --- # `--proxy-crlfile` diff --git a/docs/cmdline-opts/proxy-insecure.md b/docs/cmdline-opts/proxy-insecure.md index 5796c36237d5..0c2d8b99bc08 100644 --- a/docs/cmdline-opts/proxy-insecure.md +++ b/docs/cmdline-opts/proxy-insecure.md @@ -10,7 +10,7 @@ See-also: - proxy - insecure Example: - - --proxy-insecure -x https://proxy $URL + - --proxy-insecure -x https://proxy.example $URL --- # `--proxy-insecure` diff --git a/docs/cmdline-opts/proxy-key-type.md b/docs/cmdline-opts/proxy-key-type.md index 587c13c59284..e4551400168d 100644 --- a/docs/cmdline-opts/proxy-key-type.md +++ b/docs/cmdline-opts/proxy-key-type.md @@ -11,7 +11,7 @@ See-also: - proxy-key - proxy Example: - - --proxy-key-type DER --proxy-key here -x https://proxy $URL + - --proxy-key-type DER --proxy-key here -x https://proxy.example $URL --- # `--proxy-key-type` diff --git a/docs/cmdline-opts/proxy-key.md b/docs/cmdline-opts/proxy-key.md index 7caa636e363f..8ee78c46eac6 100644 --- a/docs/cmdline-opts/proxy-key.md +++ b/docs/cmdline-opts/proxy-key.md @@ -11,7 +11,7 @@ See-also: - proxy-key-type - proxy Example: - - --proxy-key here -x https://proxy $URL + - --proxy-key here -x https://proxy.example $URL --- # `--proxy-key` diff --git a/docs/cmdline-opts/proxy-pass.md b/docs/cmdline-opts/proxy-pass.md index 88cefd54c894..1005d95d2f3a 100644 --- a/docs/cmdline-opts/proxy-pass.md +++ b/docs/cmdline-opts/proxy-pass.md @@ -11,7 +11,7 @@ See-also: - proxy - proxy-key Example: - - --proxy-pass secret --proxy-key here -x https://proxy $URL + - --proxy-pass secret --proxy-key here -x https://proxy.example $URL --- # `--proxy-pass` diff --git a/docs/cmdline-opts/proxy-ssl-allow-beast.md b/docs/cmdline-opts/proxy-ssl-allow-beast.md index 089038dec49d..909a7f026ed1 100644 --- a/docs/cmdline-opts/proxy-ssl-allow-beast.md +++ b/docs/cmdline-opts/proxy-ssl-allow-beast.md @@ -10,7 +10,7 @@ See-also: - ssl-allow-beast - proxy Example: - - --proxy-ssl-allow-beast -x https://proxy $URL + - --proxy-ssl-allow-beast -x https://proxy.example $URL --- # `--proxy-ssl-allow-beast` diff --git a/docs/cmdline-opts/proxy-ssl-auto-client-cert.md b/docs/cmdline-opts/proxy-ssl-auto-client-cert.md index 578a7a6417cd..e041b81523a2 100644 --- a/docs/cmdline-opts/proxy-ssl-auto-client-cert.md +++ b/docs/cmdline-opts/proxy-ssl-auto-client-cert.md @@ -10,7 +10,7 @@ See-also: - ssl-auto-client-cert - proxy Example: - - --proxy-ssl-auto-client-cert -x https://proxy $URL + - --proxy-ssl-auto-client-cert -x https://proxy.example $URL --- # `--proxy-ssl-auto-client-cert` diff --git a/docs/cmdline-opts/proxy-tlsauthtype.md b/docs/cmdline-opts/proxy-tlsauthtype.md index 684a7d55ef06..84becc149e99 100644 --- a/docs/cmdline-opts/proxy-tlsauthtype.md +++ b/docs/cmdline-opts/proxy-tlsauthtype.md @@ -12,7 +12,7 @@ See-also: - proxy-tlsuser - proxy-tlspassword Example: - - --proxy-tlsauthtype SRP -x https://proxy $URL + - --proxy-tlsauthtype SRP -x https://proxy.example $URL --- # `--proxy-tlsauthtype` diff --git a/docs/cmdline-opts/proxy-tlspassword.md b/docs/cmdline-opts/proxy-tlspassword.md index fe9ae7d2e200..63c252156627 100644 --- a/docs/cmdline-opts/proxy-tlspassword.md +++ b/docs/cmdline-opts/proxy-tlspassword.md @@ -11,7 +11,7 @@ See-also: - proxy - proxy-tlsuser Example: - - --proxy-tlspassword passwd -x https://proxy $URL + - --proxy-tlspassword passwd -x https://proxy.example $URL --- # `--proxy-tlspassword` diff --git a/docs/cmdline-opts/proxy-tlsuser.md b/docs/cmdline-opts/proxy-tlsuser.md index 351770111948..610a2169b885 100644 --- a/docs/cmdline-opts/proxy-tlsuser.md +++ b/docs/cmdline-opts/proxy-tlsuser.md @@ -11,7 +11,7 @@ See-also: - proxy - proxy-tlspassword Example: - - --proxy-tlsuser smith -x https://proxy $URL + - --proxy-tlsuser smith -x https://proxy.example $URL --- # `--proxy-tlsuser` diff --git a/docs/cmdline-opts/proxy-tlsv1.md b/docs/cmdline-opts/proxy-tlsv1.md index 7b322e3a32de..20643fd82b80 100644 --- a/docs/cmdline-opts/proxy-tlsv1.md +++ b/docs/cmdline-opts/proxy-tlsv1.md @@ -9,7 +9,7 @@ Multi: mutex See-also: - proxy Example: - - --proxy-tlsv1 -x https://proxy $URL + - --proxy-tlsv1 -x https://proxy.example $URL --- # `--proxy-tlsv1` diff --git a/docs/libcurl/opts/CURLINFO_PROXY_SSL_VERIFYRESULT.md b/docs/libcurl/opts/CURLINFO_PROXY_SSL_VERIFYRESULT.md index 17dab0e32419..39fe1c70d2b9 100644 --- a/docs/libcurl/opts/CURLINFO_PROXY_SSL_VERIFYRESULT.md +++ b/docs/libcurl/opts/CURLINFO_PROXY_SSL_VERIFYRESULT.md @@ -50,7 +50,7 @@ int main(void) long verifyresult; curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); - curl_easy_setopt(curl, CURLOPT_PROXY, "https://proxy:443"); + curl_easy_setopt(curl, CURLOPT_PROXY, "https://proxy.example:443"); res = curl_easy_perform(curl); if(res) { diff --git a/docs/libcurl/opts/CURLOPT_PROXY_CAINFO.md b/docs/libcurl/opts/CURLOPT_PROXY_CAINFO.md index 6be10774db83..55c97b769f7e 100644 --- a/docs/libcurl/opts/CURLOPT_PROXY_CAINFO.md +++ b/docs/libcurl/opts/CURLOPT_PROXY_CAINFO.md @@ -72,7 +72,7 @@ int main(void) CURLcode res; curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); /* using an HTTPS proxy */ - curl_easy_setopt(curl, CURLOPT_PROXY, "https://localhost:443"); + curl_easy_setopt(curl, CURLOPT_PROXY, "https://proxy.example:443"); curl_easy_setopt(curl, CURLOPT_PROXY_CAINFO, "/etc/certs/cabundle.pem"); res = curl_easy_perform(curl); curl_easy_cleanup(curl); diff --git a/docs/libcurl/opts/CURLOPT_PROXY_CAINFO_BLOB.md b/docs/libcurl/opts/CURLOPT_PROXY_CAINFO_BLOB.md index 16af56e5cda6..5efc5e5f089e 100644 --- a/docs/libcurl/opts/CURLOPT_PROXY_CAINFO_BLOB.md +++ b/docs/libcurl/opts/CURLOPT_PROXY_CAINFO_BLOB.md @@ -73,7 +73,7 @@ int main(void) struct curl_blob blob; curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); /* using an HTTPS proxy */ - curl_easy_setopt(curl, CURLOPT_PROXY, "https://localhost:443"); + curl_easy_setopt(curl, CURLOPT_PROXY, "https://proxy.example:443"); blob.data = strpem; blob.len = strlen(strpem); blob.flags = CURL_BLOB_COPY; diff --git a/docs/libcurl/opts/CURLOPT_PROXY_CAPATH.md b/docs/libcurl/opts/CURLOPT_PROXY_CAPATH.md index d0fce53cae06..0cb17c31bfaa 100644 --- a/docs/libcurl/opts/CURLOPT_PROXY_CAPATH.md +++ b/docs/libcurl/opts/CURLOPT_PROXY_CAPATH.md @@ -64,7 +64,7 @@ int main(void) CURLcode res; curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); /* using an HTTPS proxy */ - curl_easy_setopt(curl, CURLOPT_PROXY, "https://localhost:443"); + curl_easy_setopt(curl, CURLOPT_PROXY, "https://proxy.example:443"); curl_easy_setopt(curl, CURLOPT_PROXY_CAPATH, "/etc/cert-dir"); res = curl_easy_perform(curl); curl_easy_cleanup(curl); diff --git a/docs/libcurl/opts/CURLOPT_PROXY_ISSUERCERT.md b/docs/libcurl/opts/CURLOPT_PROXY_ISSUERCERT.md index 88af6f8ed9d1..54e900d2fdb3 100644 --- a/docs/libcurl/opts/CURLOPT_PROXY_ISSUERCERT.md +++ b/docs/libcurl/opts/CURLOPT_PROXY_ISSUERCERT.md @@ -70,7 +70,7 @@ int main(void) CURLcode res; curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); /* using an HTTPS proxy */ - curl_easy_setopt(curl, CURLOPT_PROXY, "https://localhost:443"); + curl_easy_setopt(curl, CURLOPT_PROXY, "https://proxy.example:443"); curl_easy_setopt(curl, CURLOPT_PROXY_ISSUERCERT, "/etc/certs/cacert.pem"); res = curl_easy_perform(curl); curl_easy_cleanup(curl); diff --git a/docs/libcurl/opts/CURLOPT_PROXY_ISSUERCERT_BLOB.md b/docs/libcurl/opts/CURLOPT_PROXY_ISSUERCERT_BLOB.md index a6977513974b..dd8e81b8d40a 100644 --- a/docs/libcurl/opts/CURLOPT_PROXY_ISSUERCERT_BLOB.md +++ b/docs/libcurl/opts/CURLOPT_PROXY_ISSUERCERT_BLOB.md @@ -77,7 +77,7 @@ int main(void) struct curl_blob blob; curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); /* using an HTTPS proxy */ - curl_easy_setopt(curl, CURLOPT_PROXY, "https://localhost:443"); + curl_easy_setopt(curl, CURLOPT_PROXY, "https://proxy.example:443"); blob.data = certificateData; blob.len = filesize; blob.flags = CURL_BLOB_COPY; diff --git a/docs/libcurl/opts/CURLOPT_PROXY_KEYPASSWD.md b/docs/libcurl/opts/CURLOPT_PROXY_KEYPASSWD.md index 4d8287095312..9b59ec1fd1a7 100644 --- a/docs/libcurl/opts/CURLOPT_PROXY_KEYPASSWD.md +++ b/docs/libcurl/opts/CURLOPT_PROXY_KEYPASSWD.md @@ -61,7 +61,7 @@ int main(void) if(curl) { CURLcode res; curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin"); - curl_easy_setopt(curl, CURLOPT_PROXY, "https://proxy:443"); + curl_easy_setopt(curl, CURLOPT_PROXY, "https://proxy.example:443"); curl_easy_setopt(curl, CURLOPT_PROXY_KEYPASSWD, "superman"); res = curl_easy_perform(curl); curl_easy_cleanup(curl); diff --git a/docs/libcurl/opts/CURLOPT_PROXY_PINNEDPUBLICKEY.md b/docs/libcurl/opts/CURLOPT_PROXY_PINNEDPUBLICKEY.md index 49c28a7b6e6e..70c294c5ac5b 100644 --- a/docs/libcurl/opts/CURLOPT_PROXY_PINNEDPUBLICKEY.md +++ b/docs/libcurl/opts/CURLOPT_PROXY_PINNEDPUBLICKEY.md @@ -67,7 +67,7 @@ int main(void) CURL *curl = curl_easy_init(); if(curl) { curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); - curl_easy_setopt(curl, CURLOPT_PROXY, "https://proxy:443"); + curl_easy_setopt(curl, CURLOPT_PROXY, "https://proxy.example:443"); curl_easy_setopt(curl, CURLOPT_PROXY_PINNEDPUBLICKEY, "sha256//YhKJKSzoTt2b5FP18fvpHo7fJYqQCjA" "a3HWY3tvRMwE=;sha256//t62CeU2tQiqkexU74" diff --git a/docs/libcurl/opts/CURLOPT_PROXY_SSLCERT.md b/docs/libcurl/opts/CURLOPT_PROXY_SSLCERT.md index f54832839f45..efea446a25e5 100644 --- a/docs/libcurl/opts/CURLOPT_PROXY_SSLCERT.md +++ b/docs/libcurl/opts/CURLOPT_PROXY_SSLCERT.md @@ -64,7 +64,7 @@ int main(void) if(curl) { CURLcode res; curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); - curl_easy_setopt(curl, CURLOPT_PROXY, "https://proxy"); + curl_easy_setopt(curl, CURLOPT_PROXY, "https://proxy.example"); curl_easy_setopt(curl, CURLOPT_PROXY_SSLCERT, "client.pem"); curl_easy_setopt(curl, CURLOPT_PROXY_SSLKEY, "key.pem"); curl_easy_setopt(curl, CURLOPT_PROXY_KEYPASSWD, "s3cret"); diff --git a/docs/libcurl/opts/CURLOPT_PROXY_SSLCERTTYPE.md b/docs/libcurl/opts/CURLOPT_PROXY_SSLCERTTYPE.md index f616c75e4034..e0c07e325d0b 100644 --- a/docs/libcurl/opts/CURLOPT_PROXY_SSLCERTTYPE.md +++ b/docs/libcurl/opts/CURLOPT_PROXY_SSLCERTTYPE.md @@ -60,7 +60,7 @@ int main(void) if(curl) { CURLcode res; curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); - curl_easy_setopt(curl, CURLOPT_PROXY, "https://proxy"); + curl_easy_setopt(curl, CURLOPT_PROXY, "https://proxy.example"); curl_easy_setopt(curl, CURLOPT_PROXY_SSLCERT, "client.pem"); curl_easy_setopt(curl, CURLOPT_PROXY_SSLCERTTYPE, "PEM"); curl_easy_setopt(curl, CURLOPT_PROXY_SSLKEY, "key.pem"); diff --git a/docs/libcurl/opts/CURLOPT_PROXY_SSLCERT_BLOB.md b/docs/libcurl/opts/CURLOPT_PROXY_SSLCERT_BLOB.md index e3b947b14615..83bd4d6ea814 100644 --- a/docs/libcurl/opts/CURLOPT_PROXY_SSLCERT_BLOB.md +++ b/docs/libcurl/opts/CURLOPT_PROXY_SSLCERT_BLOB.md @@ -68,7 +68,7 @@ int main(void) blob.len = filesize; blob.flags = CURL_BLOB_COPY; curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); - curl_easy_setopt(curl, CURLOPT_PROXY, "https://proxy"); + curl_easy_setopt(curl, CURLOPT_PROXY, "https://proxy.example"); curl_easy_setopt(curl, CURLOPT_PROXY_SSLKEY, "key.pem"); curl_easy_setopt(curl, CURLOPT_PROXY_KEYPASSWD, "s3cret"); curl_easy_setopt(curl, CURLOPT_PROXY_SSLCERT_BLOB, &blob); diff --git a/docs/libcurl/opts/CURLOPT_PROXY_SSLKEY.md b/docs/libcurl/opts/CURLOPT_PROXY_SSLKEY.md index 74b431a6b06e..443097dfb452 100644 --- a/docs/libcurl/opts/CURLOPT_PROXY_SSLKEY.md +++ b/docs/libcurl/opts/CURLOPT_PROXY_SSLKEY.md @@ -64,7 +64,7 @@ int main(void) if(curl) { CURLcode res; curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); - curl_easy_setopt(curl, CURLOPT_PROXY, "https://proxy"); + curl_easy_setopt(curl, CURLOPT_PROXY, "https://proxy.example"); curl_easy_setopt(curl, CURLOPT_PROXY_SSLCERT, "client.pem"); curl_easy_setopt(curl, CURLOPT_PROXY_SSLKEY, "key.pem"); curl_easy_setopt(curl, CURLOPT_PROXY_KEYPASSWD, "s3cret"); diff --git a/docs/libcurl/opts/CURLOPT_PROXY_SSLKEYTYPE.md b/docs/libcurl/opts/CURLOPT_PROXY_SSLKEYTYPE.md index df14f081f5cd..cf44f3718ab9 100644 --- a/docs/libcurl/opts/CURLOPT_PROXY_SSLKEYTYPE.md +++ b/docs/libcurl/opts/CURLOPT_PROXY_SSLKEYTYPE.md @@ -53,7 +53,7 @@ int main(void) if(curl) { CURLcode res; curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); - curl_easy_setopt(curl, CURLOPT_PROXY, "https://proxy"); + curl_easy_setopt(curl, CURLOPT_PROXY, "https://proxy.example"); curl_easy_setopt(curl, CURLOPT_PROXY_SSLCERT, "client.pem"); curl_easy_setopt(curl, CURLOPT_PROXY_SSLKEY, "key.pem"); curl_easy_setopt(curl, CURLOPT_PROXY_SSLKEYTYPE, "PEM"); diff --git a/docs/libcurl/opts/CURLOPT_PROXY_SSLKEY_BLOB.md b/docs/libcurl/opts/CURLOPT_PROXY_SSLKEY_BLOB.md index 91e91468493d..da997695d04b 100644 --- a/docs/libcurl/opts/CURLOPT_PROXY_SSLKEY_BLOB.md +++ b/docs/libcurl/opts/CURLOPT_PROXY_SSLKEY_BLOB.md @@ -62,7 +62,7 @@ int main(void) CURLcode res; struct curl_blob blob; curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); - curl_easy_setopt(curl, CURLOPT_PROXY, "https://proxy"); + curl_easy_setopt(curl, CURLOPT_PROXY, "https://proxy.example"); blob.data = certificateData; blob.len = filesize; blob.flags = CURL_BLOB_COPY; diff --git a/docs/libcurl/opts/CURLOPT_PROXY_SSL_OPTIONS.md b/docs/libcurl/opts/CURLOPT_PROXY_SSL_OPTIONS.md index 18b7ce6b36a1..ec9ccc16c8c0 100644 --- a/docs/libcurl/opts/CURLOPT_PROXY_SSL_OPTIONS.md +++ b/docs/libcurl/opts/CURLOPT_PROXY_SSL_OPTIONS.md @@ -106,7 +106,7 @@ int main(void) if(curl) { CURLcode res; curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); - curl_easy_setopt(curl, CURLOPT_PROXY, "https://proxy"); + curl_easy_setopt(curl, CURLOPT_PROXY, "https://proxy.example"); /* weaken TLS only for use with silly proxies */ curl_easy_setopt(curl, CURLOPT_PROXY_SSL_OPTIONS, CURLSSLOPT_ALLOW_BEAST | CURLSSLOPT_NO_REVOKE); diff --git a/docs/libcurl/opts/CURLOPT_PROXY_TLSAUTH_PASSWORD.md b/docs/libcurl/opts/CURLOPT_PROXY_TLSAUTH_PASSWORD.md index 91f211071641..540d96149feb 100644 --- a/docs/libcurl/opts/CURLOPT_PROXY_TLSAUTH_PASSWORD.md +++ b/docs/libcurl/opts/CURLOPT_PROXY_TLSAUTH_PASSWORD.md @@ -58,7 +58,7 @@ int main(void) if(curl) { CURLcode res; curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); - curl_easy_setopt(curl, CURLOPT_PROXY, "https://proxy"); + curl_easy_setopt(curl, CURLOPT_PROXY, "https://proxy.example"); curl_easy_setopt(curl, CURLOPT_PROXY_TLSAUTH_TYPE, "SRP"); curl_easy_setopt(curl, CURLOPT_PROXY_TLSAUTH_USERNAME, "user"); curl_easy_setopt(curl, CURLOPT_PROXY_TLSAUTH_PASSWORD, "secret"); diff --git a/docs/libcurl/opts/CURLOPT_PROXY_TLSAUTH_TYPE.md b/docs/libcurl/opts/CURLOPT_PROXY_TLSAUTH_TYPE.md index 4c7cfd700f91..ceb1c1c09184 100644 --- a/docs/libcurl/opts/CURLOPT_PROXY_TLSAUTH_TYPE.md +++ b/docs/libcurl/opts/CURLOPT_PROXY_TLSAUTH_TYPE.md @@ -65,7 +65,7 @@ int main(void) if(curl) { CURLcode res; curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); - curl_easy_setopt(curl, CURLOPT_PROXY, "https://proxy"); + curl_easy_setopt(curl, CURLOPT_PROXY, "https://proxy.example"); curl_easy_setopt(curl, CURLOPT_PROXY_TLSAUTH_TYPE, "SRP"); curl_easy_setopt(curl, CURLOPT_PROXY_TLSAUTH_USERNAME, "user"); curl_easy_setopt(curl, CURLOPT_PROXY_TLSAUTH_PASSWORD, "secret"); diff --git a/docs/libcurl/opts/CURLOPT_PROXY_TLSAUTH_USERNAME.md b/docs/libcurl/opts/CURLOPT_PROXY_TLSAUTH_USERNAME.md index 44e32299ee04..cbc895275355 100644 --- a/docs/libcurl/opts/CURLOPT_PROXY_TLSAUTH_USERNAME.md +++ b/docs/libcurl/opts/CURLOPT_PROXY_TLSAUTH_USERNAME.md @@ -58,7 +58,7 @@ int main(void) if(curl) { CURLcode res; curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); - curl_easy_setopt(curl, CURLOPT_PROXY, "https://proxy"); + curl_easy_setopt(curl, CURLOPT_PROXY, "https://proxy.example"); curl_easy_setopt(curl, CURLOPT_PROXY_TLSAUTH_TYPE, "SRP"); curl_easy_setopt(curl, CURLOPT_PROXY_TLSAUTH_USERNAME, "user"); curl_easy_setopt(curl, CURLOPT_PROXY_TLSAUTH_PASSWORD, "secret"); From e80682d4296087972ea8e02fc7bf026b982f007e Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 5 Dec 2025 14:04:25 +0100 Subject: [PATCH 205/415] FAQ: fix hackerone URL --- docs/FAQ | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/FAQ b/docs/FAQ index 2e5e5901bef5..b8a39474590f 100644 --- a/docs/FAQ +++ b/docs/FAQ @@ -292,7 +292,7 @@ FAQ from having to repeat ourselves even more. Thanks for respecting this. If you have found or simply suspect a security problem in curl or libcurl, - submit all the details at https://hackerone.one/curl. On there we keep the + submit all the details at https://hackerone.com/curl. On there we keep the issue private while we investigate, confirm it, work and validate a fix and agree on a time schedule for publication etc. That way we produce a fix in a timely manner before the flaw is announced to the world, reducing the impact From ca24b6a061cf1ab99ccf7c79e8b79193534cf70d Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 5 Dec 2025 14:11:39 +0100 Subject: [PATCH 206/415] DISTROS: remove broken URLs for buildroot --- docs/DISTROS.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/DISTROS.md b/docs/DISTROS.md index 132ad86a0cfe..451de7fc1a84 100644 --- a/docs/DISTROS.md +++ b/docs/DISTROS.md @@ -49,8 +49,8 @@ archives](https://curl.se/mail/list.cgi?list=curl-distros)). *Rolling Release* -- curl package source and patches: https://git.buildroot.net/buildroot/tree/package/libcurl -- curl issues: https://bugs.buildroot.org/buglist.cgi?quicksearch=curl +- curl package source and patches: **missing URL** +- curl issues: **missing URL** ## Chimera From 51587f6f14af22e932d2448ed3a7b0052e880ea1 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 5 Dec 2025 11:45:35 +0100 Subject: [PATCH 207/415] mdlinkcheck: detect and check "raw" links - URLs specified outside of the markdown []() are now extracted and checked - also check TODO, FAQ and KNOWN_BUGS - more aggressive avoiding to check github.com/curl/curl, all uses of example domains and some more established URLs on the curl.se site - list all errors in the end to make them easier to spot in CI logs Closes #19848 --- .github/workflows/checkdocs.yml | 6 +-- scripts/mdlinkcheck | 80 +++++++++++++++++++++++++++------ 2 files changed, 68 insertions(+), 18 deletions(-) diff --git a/.github/workflows/checkdocs.yml b/.github/workflows/checkdocs.yml index 60d42301941e..ba3858f66c46 100644 --- a/.github/workflows/checkdocs.yml +++ b/.github/workflows/checkdocs.yml @@ -15,8 +15,7 @@ name: 'Docs' paths: - '.github/workflows/checkdocs.yml' - '.github/scripts/**' - - '.github/scripts/mdlinkcheck' - - '/scripts/**' + - 'scripts/**' - '**.md' - 'docs/*' pull_request: @@ -25,8 +24,7 @@ name: 'Docs' paths: - '.github/workflows/checkdocs.yml' - '.github/scripts/**' - - '.github/scripts/mdlinkcheck' - - '/scripts/**' + - 'scripts/**' - '**.md' - 'docs/*' diff --git a/scripts/mdlinkcheck b/scripts/mdlinkcheck index 6b648786f33e..734617949d2d 100755 --- a/scripts/mdlinkcheck +++ b/scripts/mdlinkcheck @@ -27,7 +27,10 @@ use strict; use warnings; my %whitelist = ( + 'https://curl.se' => 1, 'https://curl.se/' => 1, + 'https://curl.se/bug/' => 1, + 'https://curl.se/bug/view.cgi' => 1, 'https://curl.se/changes.html' => 1, 'https://curl.se/dev/advisory.html' => 1, 'https://curl.se/dev/builds.html' => 1, @@ -40,19 +43,25 @@ my %whitelist = ( 'https://curl.se/docs/bugbounty.html' => 1, 'https://curl.se/docs/caextract.html' => 1, 'https://curl.se/docs/copyright.html' => 1, + 'https://curl.se/docs/http-cookies.html' => 1, 'https://curl.se/docs/install.html' => 1, 'https://curl.se/docs/knownbugs.html' => 1, 'https://curl.se/docs/manpage.html' => 1, + 'https://curl.se/docs/releases.html' => 1, 'https://curl.se/docs/security.html' => 1, + 'https://curl.se/docs/ssl-ciphers.html' => 1, + 'https://curl.se/docs/ssl-compared.html' => 1, 'https://curl.se/docs/sslcerts.html' => 1, 'https://curl.se/docs/thanks.html' => 1, 'https://curl.se/docs/todo.html' => 1, 'https://curl.se/docs/vulnerabilities.html' => 1, + 'https://curl.se/download.html' => 1, 'https://curl.se/libcurl/' => 1, - 'https://curl.se/libcurl/c/CURLOPT_SSLVERSION.html' => 1, 'https://curl.se/libcurl/c/CURLOPT_SSL_CIPHER_LIST.html' => 1, + 'https://curl.se/libcurl/c/CURLOPT_SSLVERSION.html' => 1, 'https://curl.se/libcurl/c/CURLOPT_TLS13_CIPHERS.html' => 1, 'https://curl.se/libcurl/c/libcurl.html' => 1, + 'https://curl.se/libcurl/c/threadsafe.html' => 1, 'https://curl.se/logo/curl-logo.svg' => 1, 'https://curl.se/mail/' => 1, 'https://curl.se/mail/etiquette.html' => 1, @@ -62,14 +71,15 @@ my %whitelist = ( 'https://curl.se/rfc/rfc2255.txt' => 1, 'https://curl.se/sponsors.html' => 1, 'https://curl.se/support.html' => 1, + 'https://curl.se/windows' => 1, + 'https://curl.se/windows/' => 1, + + 'https://testclutch.curl.se/' => 1, - 'https://github.com/curl/curl' => 1, 'https://github.com/curl/curl-fuzzer' => 1, 'https://github.com/curl/curl-www' => 1, - 'https://github.com/curl/curl/discussions' => 1, - 'https://github.com/curl/curl/issues' => 1, - 'https://github.com/curl/curl/labels/help%20wanted' => 1, - 'https://github.com/curl/curl/pulls' => 1, + 'https://github.com/curl/curl.git' => 1, + 'https://github.com/curl/curl/wcurl' => 1, ); @@ -77,7 +87,7 @@ my %url; my %flink; # list all .md files in the repo -my @files=`git ls-files '**.md'`; +my @files=`git ls-files '**.md' docs/TODO docs/KNOWN_BUGS docs/FAQ`; sub storelink { my ($f, $line, $link) = @_; @@ -91,7 +101,29 @@ sub storelink { $link =~ s:\#.*\z::; if($link =~ /^(https|http):/) { - $url{$link} .= "$f:$line "; + if($whitelist{$link}) { + #print "-- whitelisted: $link\n"; + } + # example.com is just example + elsif($link =~ /^https:\/\/(.*)example.(com|org|net)/) { + #print "-- example: $link\n"; + } + # so is using the .example TLD + elsif($link =~ /^https:\/\/(.*)\.example(\/|$|:)/) { + #print "-- .example: $link\n"; + } + # so is using anything on localhost + elsif($link =~ /^http(s|):\/\/localhost/) { + #print "-- localhost: $link\n"; + } + # ignore all links to curl's github repo + elsif($link =~ /^https:\/\/github.com\/curl\/curl(\/|$)/) { + #print "-- curl github repo: $link\n"; + } + else { + #print "ADD '$link'\n"; + $url{$link} .= "$f:$line "; + } return; } @@ -119,11 +151,19 @@ sub findlinks { return; while() { + chomp; if(/\]\(([^)]*)/) { my $link = $1; #print "$f:$line $link\n"; storelink($f, $line, $link); } + # ignore trailing: dot, quote, asterisk, hash, comma, question mark, + # colon, closing parenthesis, closing angle bracket, whitespace, pipe, + # backtick, semicolon + elsif(/(https:\/\/[a-z0-9.\/:%_-]+[^."*\#,?:\)> \t|`;])/i) { + #print "RAW "; + storelink($f, $line, $1); + } $line++; } close(F); @@ -133,11 +173,10 @@ sub checkurl { my ($url) = @_; if($whitelist{$url}) { - #print "$url is whitelisted\n"; + #print STDERR "$url is whitelisted\n"; return 0; } - print "check $url\n"; $url =~ s/\+/%2B/g; my @content; if(open(my $fh, '-|', 'curl', '-ILfsm10', '--retry', '2', '--retry-delay', '5', @@ -146,9 +185,10 @@ sub checkurl { close $fh; } if(!$content[0]) { - print STDERR "FAIL\n"; + print "FAIL: $url\n"; return 1; # fail } + print "OK: $url\n"; return 0; # ok } @@ -157,14 +197,19 @@ for my $f (@files) { findlinks($f); } -my $error; +#for my $u (sort keys %url) { +# print "$u\n"; +#} +#exit; +my $error; +my @errlist; for my $u (sort keys %url) { my $r = checkurl($u); if($r) { for my $f (split(/ /, $url{$u})) { - printf "%s ERROR links to missing URL %s\n", $f, $u; + push @errlist, sprintf "%s ERROR links to missing URL %s\n", $f, $u; $error++; } } @@ -173,10 +218,17 @@ for my $u (sort keys %url) { for my $l (sort keys %flink) { if(! -r $l) { for my $f (split(/ /, $flink{$l})) { - printf "%s ERROR links to missing file %s\n", $f, $l; + push @errlist, sprintf "%s ERROR links to missing file %s\n", $f, $l; $error++; } } } +printf "Checked %d URLs\n", scalar(keys %url); +if($error) { + print "$error URLs had problems:\n"; + for(@errlist) { + print $_; + } +} exit 1 if($error); From 15e5ac6da8d4827e04c5a32d4672f58492615729 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 5 Dec 2025 23:51:47 +0100 Subject: [PATCH 208/415] RELEASE-NOTES: synced --- RELEASE-NOTES | 76 +++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 68 insertions(+), 8 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 512bc5425d57..af81fffb902f 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -4,7 +4,7 @@ curl and libcurl 8.18.0 Command line options: 273 curl_easy_setopt() options: 308 Public functions in libcurl: 100 - Contributors: 3554 + Contributors: 3556 This release includes the following changes: @@ -50,11 +50,13 @@ This release includes the following bugfixes: o conncache: silence `-Wnull-dereference` on gcc 14 RISC-V 64 [17] o conncontrol: reuse handling [170] o connect: reshuffle Curl_timeleft_ms to avoid 'redundant condition' [100] + o connection: attached transfer count [228] o cookie: propagate errors better, cleanup the internal API [118] o cookie: return error on OOM [131] o cshutdn: acknowledge FD_SETSIZE for shutdown descriptors [25] o curl: fix progress meter in parallel mode [15] o curl_fopen: do not pass invalid mode flags to `open()` on Windows [84] + o curl_gssapi: make sure Curl_gss_log_error() has an initialized buffer [257] o curl_sasl: make Curl_sasl_decode_mech compare case insensitively [160] o curl_setup.h: document more funcs flagged by `_CRT_SECURE_NO_WARNINGS` [124] o curl_setup.h: drop stray `#undef stat` (Windows) [103] @@ -62,21 +64,28 @@ This release includes the following bugfixes: o CURLINFO: remove 'get' and 'get the' from each short desc [50] o CURLINFO_SCHEME/PROTOCOL: they return the "scheme" for a "transfer" [48] o CURLINFO_TLS_SSL_PTR.md: remove CURLINFO_TLS_SESSION text [49] + o CURLMOPT_SOCKETFUNCTION.md: fix the callback argument use [206] o CURLOPT_READFUNCTION.md: clarify the size of the buffer [47] o CURLOPT_SSH_KEYFUNCTION.md: fix minor indent mistake in example o curlx/fopen: replace open CRT functions their with `_s` counterparts (Windows) [204] o curlx/multibyte: stop setting macros for non-Windows [226] o curlx/strerr: use `strerror_s()` on Windows [75] + o curlx: limit use of system allocators to the minimum possible [169] o curlx: replace `mbstowcs`/`wcstombs` with `_s` counterparts (Windows) [143] o curlx: replace `sprintf` with `snprintf` [194] o curlx: use curlx allocators in non-memdebug builds (Windows) [155] o digest_sspi: fix a memory leak on error path [149] o digest_sspi: properly free sspi identity [12] o DISTROS.md: add OpenBSD [126] + o DISTROS: remove broken URLs for buildroot o doc: some returned in-memory data may not be altered [196] + o docs/libcurl: fix C formatting nits [207] + o docs: clarify how to do unix domain sockets with SOCKS proxy [240] o docs: fix checksrc `EQUALSPACE` warnings [21] o docs: mention umask need when curl creates files [56] + o docs: remove dead URLs o docs: spell it Rustls with a capital R [181] + o docs: use .example URLs for proxies o example: fix formatting nits [232] o examples/crawler: fix variable [92] o examples/multi-uv: fix invalid req->data access [177] @@ -84,6 +93,7 @@ This release includes the following bugfixes: o examples: fix minor typo [203] o examples: make functions/data static where missing [139] o examples: tidy-up headers and includes [138] + o FAQ: fix hackerone URL o file: do not pass invalid mode flags to `open()` on upload (Windows) [83] o ftp: refactor a piece of code by merging the repeated part [40] o ftp: remove #ifdef for define that is always defined [76] @@ -103,16 +113,22 @@ This release includes the following bugfixes: o http: handle oom error from Curl_input_digest() [192] o http: replace atoi use in Curl_http_follow with curlx_str_number [65] o http: the :authority header should never contain user+password [147] + o idn: avoid allocations and wcslen on Windows [247] o idn: fix memory leak in `win32_ascii_to_idn()` [173] o idn: use curlx allocators on Windows [165] o imap: make sure Curl_pgrsSetDownloadSize() does not overflow [200] o INSTALL-CMAKE.md: document static option defaults more [37] o krb5: fix detecting channel binding feature [187] o krb5_sspi: unify a part of error handling [80] + o ldap: call ldap_init() before setting the options [236] + o ldap: improve detection of Apple LDAP [174] + o ldap: provide version for "legacy" ldap as well [254] o lib/sendf.h: forward declare two structs [221] o lib: cleanup for some typos about spaces and code style [3] o lib: eliminate size_t casts [112] o lib: error for OOM when extracting URL query [127] + o lib: fix formatting nits (part 2) [253] + o lib: fix formatting nits (part 3) [248] o lib: fix formatting nits [215] o lib: fix gssapi.h include on IBMi [55] o lib: refactor the type of funcs which have useless return and checks [1] @@ -129,6 +145,7 @@ This release includes the following bugfixes: o m4/sectrust: fix test(1) operator [4] o manage: expand the 'libcurl support required' message [208] o mbedtls: fix potential use of uninitialized `nread` [8] + o mbedtls: sync format across log messages [213] o mbedtls_threadlock: avoid calloc, use array [244] o memdebug: add mutex for thread safety [184] o mk-ca-bundle.pl: default to SHA256 fingerprints with `-t` option [73] @@ -139,6 +156,7 @@ This release includes the following bugfixes: o multibyte: limit `curlx_convert_*wchar*()` functions to Unicode builds [135] o ngtcp2+openssl: fix leak of session [172] o ngtcp2: remove the unused Curl_conn_is_ngtcp2 function [85] + o noproxy: fix ipv6 handling [239] o noproxy: replace atoi with curlx_str_number [67] o openssl: exit properly on OOM when getting certchain [133] o openssl: fix a potential memory leak of bio_out [150] @@ -146,6 +164,7 @@ This release includes the following bugfixes: o openssl: no verify failf message unless strict [166] o openssl: release ssl_session if sess_reuse_cb fails [43] o openssl: remove code handling default version [28] + o openssl: simplify `HAVE_KEYLOG_CALLBACK` guard [212] o OS400/ccsidcurl: fix curl_easy_setopt_ccsid for non-converted blobs [94] o OS400/makefile.sh: fix shellcheck warning SC2038 [86] o osslq: code readability [5] @@ -153,7 +172,10 @@ This release includes the following bugfixes: o projects/README.md: Markdown fixes [148] o pytest fixes and improvements [159] o pytest: disable two H3 earlydata tests for all platforms (was: macOS) [116] + o pytest: fix and improve reliability [251] + o pytest: improve stragglers [252] o pytest: skip H2 tests if feature missing from curl [46] + o quiche: use client writer [255] o ratelimit: redesign [209] o rtmp: fix double-free on URL parse errors [27] o rtmp: precaution for a potential integer truncation [54] @@ -161,6 +183,7 @@ This release includes the following bugfixes: o runtests: detect bad libssh differently for test 1459 [11] o runtests: drop Python 2 support remains [45] o runtests: enable torture testing with threaded resolver [176] + o runtests: make memanalyzer a Perl module (for 1.1-2x speed-up per test run) [238] o rustls: fix a potential memory issue [81] o rustls: minor adjustment of sizeof() [38] o rustls: simplify init err path [219] @@ -178,21 +201,29 @@ This release includes the following bugfixes: o socks_sspi: use free() not FreeContextBuffer() [93] o speedcheck: do not trigger low speed cancel on transfers with CURL_READFUNC_PAUSE [113] o speedlimit: also reset on send unpausing [197] + o src: fix formatting nits [246] o ssh: tracing and better pollset handling [230] + o sws: fix binding to unix socket on Windows [214] o telnet: replace atoi for BINARY handling with curlx_str_number [66] o TEST-SUITE.md: correct the man page's path [136] o test07_22: fix flakiness [95] + o test1498: disable 'HTTP PUT from stdin' test on Windows [115] o test2045: replace HTML multi-line comment markup with `#` comments [36] + o test3207: enable memdebug for this test again [249] o test363: delete stray character (typo) from a section tag [52] + o test787: fix possible typo `&` -> `%` in curl option [241] o tests/data: replace hard-coded test numbers with `%TESTNUMBER` [33] o tests/data: support using native newlines on disk, drop `.gitattributes` [91] o tests/server: do not fall back to original data file in `test2fopen()` [32] o tests/server: replace `atoi()` and `atol()` with `curlx_str_number()` [110] + o tests: add `%AMP` macro, use it in two tests [245] o tests: allow 2500-2503 to use ~2MB malloc [31] o tests: fix formatting nits [225] o tftp: release filename if conn_get_remote_addr fails [42] o tftpd: fix/tidy up `open()` mode flags [57] + o tidy-up: avoid `(())`, clang-format fixes and more [141] o tidy-up: move `CURL_UNCONST()` out from macro `curl_unicodefree()` [121] + o TODO: remove a mandriva.com reference o tool: consider (some) curl_easy_setopt errors fatal [7] o tool: log when loading .curlrc in verbose mode [191] o tool_cfgable: free ssl-sessions at exit [123] @@ -212,6 +243,7 @@ This release includes the following bugfixes: o tool_urlglob: clean up used memory on errors better [44] o tool_writeout: bail out proper on OOM [104] o url: fix return code for OOM in parse_proxy() [193] + o url: if curl_url_get() fails due to OOM, error out properly [205] o url: if OOM in parse_proxy() return error [132] o urlapi: fix mem-leaks in curl_url_get error paths [22] o urlapi: handle OOM properly when setting URL [180] @@ -253,14 +285,15 @@ advice from friends like these: Aleksandr Sergeev, Aleksei Bavshin, Andrew Kirillov, BANADDA, boingball, Brad King, bttrfl on github, Christian Schmitz, Dan Fandrich, Daniel McCarney, Daniel Stenberg, Deniz Parlak, Fd929c2CE5fA on github, - ffath-vo on github, Gisle Vanem, Jiyong Yang, Juliusz Sosinowicz, Kai Pastor, - Leonardo Taccari, letshack9707 on hackerone, Marc Aldorasi, Marcel Raad, - Max Faxälv, nait-furry, ncaklovic on github, Nick Korepanov, - Omdahake on github, Patrick Monnerat, pelioro on hackerone, Ray Satiro, - renovate[bot], Samuel Henrique, st751228051 on github, Stanislav Fort, - Stefan Eissing, Sunny, Thomas Klausner, Viktor Szakats, Wesley Moore, + ffath-vo on github, Georg Schulz-Allgaier, Gisle Vanem, Greg Hudson, + Jiyong Yang, Juliusz Sosinowicz, Kai Pastor, Leonardo Taccari, + letshack9707 on hackerone, Marc Aldorasi, Marcel Raad, Max Faxälv, + nait-furry, ncaklovic on github, Nick Korepanov, Omdahake on github, + Patrick Monnerat, pelioro on hackerone, Ray Satiro, renovate[bot], + Samuel Henrique, st751228051 on github, Stanislav Fort, Stefan Eissing, + Sunny, Theo Buehler, Thomas Klausner, Viktor Szakats, Wesley Moore, Xiaoke Wang, Yedaya Katsman - (41 contributors) + (44 contributors) References to bug reports and discussions on issues: @@ -377,6 +410,7 @@ References to bug reports and discussions on issues: [112] = https://curl.se/bug/?i=19495 [113] = https://curl.se/bug/?i=19653 [114] = https://curl.se/bug/?i=19605 + [115] = https://curl.se/bug/?i=19855 [116] = https://curl.se/bug/?i=19724 [117] = https://curl.se/bug/?i=19644 [118] = https://curl.se/bug/?i=19493 @@ -402,6 +436,7 @@ References to bug reports and discussions on issues: [138] = https://curl.se/bug/?i=19580 [139] = https://curl.se/bug/?i=19579 [140] = https://curl.se/bug/?i=19175 + [141] = https://curl.se/bug/?i=19854 [142] = https://curl.se/bug/?i=19572 [143] = https://curl.se/bug/?i=19581 [144] = https://curl.se/bug/?i=19571 @@ -429,10 +464,12 @@ References to bug reports and discussions on issues: [166] = https://curl.se/bug/?i=19615 [167] = https://curl.se/bug/?i=19609 [168] = https://curl.se/bug/?i=19612 + [169] = https://curl.se/bug/?i=19748 [170] = https://curl.se/bug/?i=19333 [171] = https://curl.se/bug/?i=19714 [172] = https://curl.se/bug/?i=19717 [173] = https://curl.se/bug/?i=19789 + [174] = https://curl.se/bug/?i=19849 [175] = https://curl.se/bug/?i=19784 [176] = https://curl.se/bug/?i=19786 [177] = https://curl.se/bug/?i=19462 @@ -461,10 +498,16 @@ References to bug reports and discussions on issues: [202] = https://curl.se/bug/?i=19669 [203] = https://curl.se/bug/?i=19683 [204] = https://curl.se/bug/?i=19643 + [205] = https://curl.se/bug/?i=19838 + [206] = https://curl.se/bug/?i=19840 + [207] = https://curl.se/bug/?i=19844 [208] = https://curl.se/bug/?i=19665 [209] = https://curl.se/bug/?i=19384 [210] = https://curl.se/bug/?i=19769 [211] = https://curl.se/bug/?i=19768 + [212] = https://curl.se/bug/?i=19843 + [213] = https://curl.se/bug/?i=19842 + [214] = https://curl.se/bug/?i=19812 [215] = https://curl.se/bug/?i=19764 [217] = https://curl.se/bug/?i=19763 [219] = https://curl.se/bug/?i=19759 @@ -474,8 +517,25 @@ References to bug reports and discussions on issues: [223] = https://curl.se/bug/?i=16973 [225] = https://curl.se/bug/?i=19754 [226] = https://curl.se/bug/?i=19751 + [228] = https://curl.se/bug/?i=19836 [230] = https://curl.se/bug/?i=19745 [232] = https://curl.se/bug/?i=19746 + [236] = https://curl.se/bug/?i=19830 + [238] = https://curl.se/bug/?i=19786 + [239] = https://curl.se/bug/?i=19828 + [240] = https://curl.se/bug/?i=19829 + [241] = https://curl.se/bug/?i=19826 [242] = https://curl.se/bug/?i=19734 [243] = https://curl.se/bug/?i=19733 [244] = https://curl.se/bug/?i=19732 + [245] = https://curl.se/bug/?i=19824 + [246] = https://curl.se/bug/?i=19823 + [247] = https://curl.se/bug/?i=19798 + [248] = https://curl.se/bug/?i=19811 + [249] = https://curl.se/bug/?i=19813 + [251] = https://curl.se/bug/?i=19970 + [252] = https://curl.se/bug/?i=19809 + [253] = https://curl.se/bug/?i=19800 + [254] = https://curl.se/bug/?i=19808 + [255] = https://curl.se/bug/?i=19803 + [257] = https://curl.se/bug/?i=19802 From 891566c72da47250c13047f7df0d8aa94a6ff842 Mon Sep 17 00:00:00 2001 From: Stefan Eissing Date: Fri, 5 Dec 2025 14:12:47 +0100 Subject: [PATCH 209/415] ftp: make EPRT connections non-blocking On platforms where neither accept4 nor fcntl was available, an EPRT connection did not send the accepted socket as non-blocking. This became apparent when TLS was in use and the test receive on shutdown did simply hang. Reported-by: Denis Goleshchikhin Fixes #19753 Closes #19851 --- lib/cf-socket.c | 17 ++- tests/http/test_30_vsftpd.py | 13 ++- tests/http/test_31_vsftpds.py | 13 ++- tests/http/test_32_ftps_vsftpd.py | 13 ++- tests/libtest/Makefile.inc | 1 + tests/libtest/cli_ftp_upload.c | 182 ++++++++++++++++++++++++++++++ 6 files changed, 231 insertions(+), 8 deletions(-) create mode 100644 tests/libtest/cli_ftp_upload.c diff --git a/lib/cf-socket.c b/lib/cf-socket.c index 1881683cc8ed..469e9229fd69 100644 --- a/lib/cf-socket.c +++ b/lib/cf-socket.c @@ -2114,15 +2114,22 @@ static CURLcode cf_tcp_accept_connect(struct Curl_cfilter *cf, curlx_strerror(SOCKERRNO, errbuf, sizeof(errbuf))); return CURLE_FTP_ACCEPT_FAILED; } -#if !defined(HAVE_ACCEPT4) && defined(HAVE_FCNTL) - if((fcntl(s_accepted, F_SETFD, FD_CLOEXEC) < 0) || - (curlx_nonblock(s_accepted, TRUE) < 0)) { - failf(data, "fcntl set CLOEXEC/NONBLOCK: %s", +#ifndef HAVE_ACCEPT4 +#ifdef HAVE_FCNTL + if(fcntl(s_accepted, F_SETFD, FD_CLOEXEC) < 0) { + failf(data, "fcntl set CLOEXEC: %s", curlx_strerror(SOCKERRNO, errbuf, sizeof(errbuf))); Curl_socket_close(data, cf->conn, s_accepted); return CURLE_FTP_ACCEPT_FAILED; } -#endif +#endif /* HAVE_FCNTL */ + if(curlx_nonblock(s_accepted, TRUE) < 0) { + failf(data, "set socket NONBLOCK: %s", + curlx_strerror(SOCKERRNO, errbuf, sizeof(errbuf))); + Curl_socket_close(data, cf->conn, s_accepted); + return CURLE_FTP_ACCEPT_FAILED; + } +#endif /* !HAVE_ACCEPT4 */ infof(data, "Connection accepted from server"); /* Replace any filter on SECONDARY with one listening on this socket */ diff --git a/tests/http/test_30_vsftpd.py b/tests/http/test_30_vsftpd.py index 7d113d5363fe..bcc8b76fddeb 100644 --- a/tests/http/test_30_vsftpd.py +++ b/tests/http/test_30_vsftpd.py @@ -31,7 +31,7 @@ import shutil import pytest -from testenv import Env, CurlClient, VsFTPD +from testenv import Env, CurlClient, VsFTPD, LocalClient log = logging.getLogger(__name__) @@ -235,6 +235,17 @@ def test_30_11_download_non_existing(self, env: Env, vsftpd: VsFTPD): r.check_stats(count=1, exitcode=78) r.check_stats_timelines() + def test_30_12_upload_eprt(self, env: Env, vsftpd: VsFTPD): + docname = 'test_30_12' + client = LocalClient(name='cli_ftp_upload', env=env) + if not client.exists(): + pytest.skip(f'example client not built: {client.name}') + url = f'ftp://{env.ftp_domain}:{vsftpd.port}/{docname}' + r = client.run(args=['-r', f'{env.ftp_domain}:{vsftpd.port}:127.0.0.1', url]) + r.check_exit_code(0) + dstfile = os.path.join(vsftpd.docs_dir, docname) + assert os.path.exists(dstfile), f'{r.dump_logs()}' + def check_downloads(self, client, srcfile: str, count: int, complete: bool = True): for i in range(count): diff --git a/tests/http/test_31_vsftpds.py b/tests/http/test_31_vsftpds.py index 93fef708ccdd..ba4696c0cb29 100644 --- a/tests/http/test_31_vsftpds.py +++ b/tests/http/test_31_vsftpds.py @@ -31,7 +31,7 @@ import shutil import pytest -from testenv import Env, CurlClient, VsFTPD +from testenv import Env, CurlClient, VsFTPD, LocalClient log = logging.getLogger(__name__) @@ -260,6 +260,17 @@ def test_31_11_download_non_existing(self, env: Env, vsftpds: VsFTPD): r.check_exit_code(78) r.check_stats(count=1, exitcode=78) + def test_31_12_upload_eprt(self, env: Env, vsftpds: VsFTPD): + docname = 'test_31_12' + client = LocalClient(name='cli_ftp_upload', env=env) + if not client.exists(): + pytest.skip(f'example client not built: {client.name}') + url = f'ftp://{env.ftp_domain}:{vsftpds.port}/{docname}' + r = client.run(args=['-r', f'{env.ftp_domain}:{vsftpds.port}:127.0.0.1', url]) + r.check_exit_code(0) + dstfile = os.path.join(vsftpds.docs_dir, docname) + assert os.path.exists(dstfile), f'{r.dump_logs()}' + def check_downloads(self, client, srcfile: str, count: int, complete: bool = True): for i in range(count): diff --git a/tests/http/test_32_ftps_vsftpd.py b/tests/http/test_32_ftps_vsftpd.py index 7a849d374044..bac40580eecb 100644 --- a/tests/http/test_32_ftps_vsftpd.py +++ b/tests/http/test_32_ftps_vsftpd.py @@ -31,7 +31,7 @@ import shutil import pytest -from testenv import Env, CurlClient, VsFTPD +from testenv import Env, CurlClient, VsFTPD, LocalClient log = logging.getLogger(__name__) @@ -273,6 +273,17 @@ def test_32_11_download_non_existing(self, env: Env, vsftpds: VsFTPD): r.check_exit_code(78) r.check_stats(count=1, exitcode=78) + def test_32_12_upload_eprt(self, env: Env, vsftpds: VsFTPD): + docname = 'test_32_12' + client = LocalClient(name='cli_ftp_upload', env=env) + if not client.exists(): + pytest.skip(f'example client not built: {client.name}') + url = f'ftps://{env.ftp_domain}:{vsftpds.port}/{docname}' + r = client.run(args=['-r', f'{env.ftp_domain}:{vsftpds.port}:127.0.0.1', url]) + r.check_exit_code(0) + dstfile = os.path.join(vsftpds.docs_dir, docname) + assert os.path.exists(dstfile), f'{r.dump_logs()}' + def check_downloads(self, client, srcfile: str, count: int, complete: bool = True): for i in range(count): diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc index 8efeba914df8..a0d78f96c381 100644 --- a/tests/libtest/Makefile.inc +++ b/tests/libtest/Makefile.inc @@ -48,6 +48,7 @@ CURLX_C = \ # All libtest programs TESTS_C = \ + cli_ftp_upload.c \ cli_h2_pausing.c \ cli_h2_serverpush.c \ cli_h2_upgrade_extreme.c \ diff --git a/tests/libtest/cli_ftp_upload.c b/tests/libtest/cli_ftp_upload.c new file mode 100644 index 000000000000..7493a210e6e9 --- /dev/null +++ b/tests/libtest/cli_ftp_upload.c @@ -0,0 +1,182 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) Daniel Stenberg, , et al. + * + * This software is licensed as described in the 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. + * + * SPDX-License-Identifier: curl + * + ***************************************************************************/ + +#include "first.h" + +#include "testtrace.h" + + +#ifndef CURL_DISABLE_FTP + +struct test_cli_ftp_upload_data { + const char *data; + size_t data_len; + size_t offset; + int done; +}; + +static size_t test_cli_ftp_upload_read(char *buf, + size_t nitems, size_t blen, + void *userdata) +{ + struct test_cli_ftp_upload_data *d = userdata; + size_t nread = d->data_len - d->offset; + + if(nread) { + if(nread > (nitems * blen)) + nread = (nitems * blen); + memcpy(buf, d->data + d->offset, nread); + d->offset += nread; + } + else + d->done = 1; + return nread; +} + +static void usage_ftp_upload(const char *msg) +{ + if(msg) + curl_mfprintf(stderr, "%s\n", msg); + curl_mfprintf(stderr, + "usage: [options] url\n" + " -r :: resolve information\n" + ); +} + +#endif + +static CURLcode test_cli_ftp_upload(const char *URL) +{ +#ifndef CURL_DISABLE_FTP + CURLM *multi_handle; + CURL *curl_handle; + int running_handles = 0; + int max_fd = -1; + struct timeval timeout = { 1, 0 }; + fd_set fdread; + fd_set fdwrite; + fd_set fdexcep; + struct test_cli_ftp_upload_data data; + struct curl_slist *host = NULL; + const char *resolve = NULL, *url; + int ch; + CURLcode result = CURLE_FAILED_INIT; + curl_off_t uploadsize = -1; + + (void)URL; + while((ch = cgetopt(test_argc, test_argv, "r:")) + != -1) { + switch(ch) { + case 'r': + resolve = coptarg; + break; + default: + usage_ftp_upload("unknown option"); + return (CURLcode)1; + } + } + test_argc -= coptind; + test_argv += coptind; + if(test_argc != 1) { + usage_ftp_upload("not enough arguments"); + return (CURLcode)2; + } + url = test_argv[0]; + + if(resolve) + host = curl_slist_append(NULL, resolve); + + memset(&data, 0, sizeof(data)); + data.data = "abcdefghijklmnopqrstuvwxyz" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; + data.data_len = strlen(data.data); + + curl_global_init(CURL_GLOBAL_ALL); + multi_handle = curl_multi_init(); + curl_handle = curl_easy_init(); + + curl_easy_setopt(curl_handle, CURLOPT_FTPPORT, "-"); + curl_easy_setopt(curl_handle, CURLOPT_FTP_USE_EPRT, 1L); + curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, 0L); + curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYHOST, 0L); + curl_easy_setopt(curl_handle, CURLOPT_USE_SSL, CURLUSESSL_TRY); + curl_easy_setopt(curl_handle, CURLOPT_URL, url); + curl_easy_setopt(curl_handle, CURLOPT_USERPWD, NULL); + curl_easy_setopt(curl_handle, CURLOPT_FTP_CREATE_MISSING_DIRS, + CURLFTP_CREATE_DIR); + curl_easy_setopt(curl_handle, CURLOPT_UPLOAD, 1L); + curl_easy_setopt(curl_handle, CURLOPT_READFUNCTION, + test_cli_ftp_upload_read); + curl_easy_setopt(curl_handle, CURLOPT_READDATA, &data); + curl_easy_setopt(curl_handle, CURLOPT_INFILESIZE_LARGE, uploadsize); + + curl_easy_setopt(curl_handle, CURLOPT_VERBOSE, 1L); + curl_easy_setopt(curl_handle, CURLOPT_DEBUGFUNCTION, cli_debug_cb); + if(host) + curl_easy_setopt(curl_handle, CURLOPT_RESOLVE, host); + + curl_multi_add_handle(multi_handle, curl_handle); + curl_multi_perform(multi_handle, &running_handles); + while(running_handles && !data.done) { + FD_ZERO(&fdread); + FD_ZERO(&fdwrite); + FD_ZERO(&fdexcep); + + curl_multi_fdset(multi_handle, &fdread, &fdwrite, &fdexcep, &max_fd); + select(max_fd + 1, &fdread, &fdwrite, &fdexcep, &timeout); + curl_multi_perform(multi_handle, &running_handles); + } + while(running_handles) { + curl_mfprintf(stderr, "reports to hang herel\n"); + curl_multi_perform(multi_handle, &running_handles); + } + + while(1) { + int msgq = 0; + struct CURLMsg *msg = curl_multi_info_read(multi_handle, &msgq); + if(msg && (msg->msg == CURLMSG_DONE)) { + if(msg->easy_handle == curl_handle) { + result = msg->data.result; + } + } + else + break; + } + + curl_multi_remove_handle(multi_handle, curl_handle); + + curl_easy_reset(curl_handle); + curl_easy_cleanup(curl_handle); + curl_multi_cleanup(multi_handle); + curl_global_cleanup(); + curl_slist_free_all(host); + + curl_mfprintf(stderr, "transfer result: %d\n", result); + return result; +#else /* !CURL_DISABLE_FTP */ + (void)URL; + curl_mfprintf(stderr, "FTP not enabled in libcurl\n"); + return (CURLcode)1; +#endif /* CURL_DISABLE_FTP */ +} From 1c0822e8cb4ba96e4bf555d4c46bcae1d85ca343 Mon Sep 17 00:00:00 2001 From: "Robert W. Van Kirk" Date: Sat, 6 Dec 2025 12:00:00 -0600 Subject: [PATCH 210/415] formdata: validate callback is non-NULL before use curl_formget() accepts a user-provided callback function but does not validate it is non-NULL before calling it. If a caller passes NULL, the function will crash with SIGSEGV. Add NULL check at the start of the function to return an appropriate error code instead of crashing. Signed-off-by: Robert W. Van Kirk Closes #19858 --- lib/formdata.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/formdata.c b/lib/formdata.c index b0c57b8d6f06..8f95fc3df036 100644 --- a/lib/formdata.c +++ b/lib/formdata.c @@ -636,6 +636,10 @@ int curl_formget(struct curl_httppost *form, void *arg, CURLcode result; curl_mimepart toppart; + /* Validate callback is provided */ + if(!append) + return (int)CURLE_BAD_FUNCTION_ARGUMENT; + Curl_mime_initpart(&toppart); /* default form is empty */ result = Curl_getformdata(NULL, &toppart, form, NULL); if(!result) From 0b5ece553cf97f16b36bb7a6bf1071d0ae3cb3aa Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sat, 6 Dec 2025 18:01:09 +0100 Subject: [PATCH 211/415] altsvc: make it one malloc instead of three per entry Also return OOM correctly. Closes #19857 --- lib/altsvc.c | 47 ++++++++++++++++++++--------------------------- lib/setopt.c | 2 +- 2 files changed, 21 insertions(+), 28 deletions(-) diff --git a/lib/altsvc.c b/lib/altsvc.c index f2906ad4e379..31f6b515bec2 100644 --- a/lib/altsvc.c +++ b/lib/altsvc.c @@ -64,12 +64,7 @@ const char *Curl_alpnid2str(enum alpnid id) } } -static void altsvc_free(struct altsvc *as) -{ - curlx_free(as->src.host); - curlx_free(as->dst.host); - curlx_free(as); -} +#define altsvc_free(x) curlx_free(x) static struct altsvc *altsvc_createid(const char *srchost, size_t hlen, @@ -80,38 +75,35 @@ static struct altsvc *altsvc_createid(const char *srchost, size_t srcport, size_t dstport) { - struct altsvc *as = curlx_calloc(1, sizeof(struct altsvc)); - if(!as) - return NULL; - DEBUGASSERT(hlen); - DEBUGASSERT(dlen); - if(!hlen || !dlen) - /* bad input */ - goto error; + struct altsvc *as; if((hlen > 2) && srchost[0] == '[') { /* IPv6 address, strip off brackets */ srchost++; hlen -= 2; } - else if(srchost[hlen - 1] == '.') { + else if(hlen && (srchost[hlen - 1] == '.')) { /* strip off trailing dot */ hlen--; - if(!hlen) - goto error; } if((dlen > 2) && dsthost[0] == '[') { /* IPv6 address, strip off brackets */ dsthost++; dlen -= 2; } + if(!hlen || !dlen) + /* bad input */ + return NULL; + /* struct size plus both strings */ + as = curlx_calloc(1, sizeof(struct altsvc) + (hlen + 1) + (dlen + 1)); + if(!as) + return NULL; + as->src.host = (char *)as + sizeof(struct altsvc); + memcpy(as->src.host, srchost, hlen); + /* the null terminator is already there */ - as->src.host = Curl_memdup0(srchost, hlen); - if(!as->src.host) - goto error; - - as->dst.host = Curl_memdup0(dsthost, dlen); - if(!as->dst.host) - goto error; + as->dst.host = (char *)as + sizeof(struct altsvc) + hlen + 1; + memcpy(as->dst.host, dsthost, dlen); + /* the null terminator is already there */ as->src.alpnid = srcalpnid; as->dst.alpnid = dstalpnid; @@ -119,9 +111,6 @@ static struct altsvc *altsvc_createid(const char *srchost, as->dst.port = (unsigned short)dstport; return as; -error: - altsvc_free(as); - return NULL; } static struct altsvc *altsvc_create(struct Curl_str *srchost, @@ -194,6 +183,8 @@ static CURLcode altsvc_add(struct altsvcinfo *asi, const char *line) as->persist = persist ? 1 : 0; Curl_llist_append(&asi->list, as, &as->node); } + else + return CURLE_OUT_OF_MEMORY; } return CURLE_OK; @@ -600,6 +591,8 @@ CURLcode Curl_altsvc_parse(struct Curl_easy *data, (int)curlx_strlen(&dsthost), curlx_str(&dsthost), dstport, Curl_alpnid2str(dstalpnid)); } + else + return CURLE_OUT_OF_MEMORY; } } else diff --git a/lib/setopt.c b/lib/setopt.c index 476506dad4dc..24d8fe8de060 100644 --- a/lib/setopt.c +++ b/lib/setopt.c @@ -2532,7 +2532,7 @@ static CURLcode setopt_cptr(struct Curl_easy *data, CURLoption option, if(result) return result; if(ptr) - (void)Curl_altsvc_load(data->asi, ptr); + return Curl_altsvc_load(data->asi, ptr); break; #endif /* ! CURL_DISABLE_ALTSVC */ #ifdef USE_ECH From f4b56f34ba881efad011ce1361c52340e3de3a2e Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sat, 6 Dec 2025 23:45:06 +0100 Subject: [PATCH 212/415] asyn-thrdd: fix Curl_async_getaddrinfo() on systems without getaddrinfo Follow-up to ce06fe77710525 Bug: https://github.com/curl/curl/commit/ce06fe7771052549ff430c86173b2eaca91f8a9c#r172215567 Reported-by: Harry Sintonen Closes #19859 --- lib/asyn-thrdd.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/lib/asyn-thrdd.c b/lib/asyn-thrdd.c index e5bf0629d38f..aa686271a0dd 100644 --- a/lib/asyn-thrdd.c +++ b/lib/asyn-thrdd.c @@ -725,24 +725,18 @@ CURLcode Curl_async_pollset(struct Curl_easy *data, struct easy_pollset *ps) /* * Curl_async_getaddrinfo() - for platforms without getaddrinfo */ -struct Curl_addrinfo *Curl_async_getaddrinfo(struct Curl_easy *data, - const char *hostname, - int port, - int ip_version, - int *waitp) +CURLcode Curl_async_getaddrinfo(struct Curl_easy *data, const char *hostname, + int port, int ip_version) { (void)ip_version; - *waitp = 0; /* default to synchronous response */ /* fire up a new resolver thread! */ if(async_thrdd_init(data, hostname, port, ip_version, NULL)) { - *waitp = 1; /* expect asynchronous response */ - return NULL; + return CURLE_OK; } failf(data, "getaddrinfo() thread failed"); - - return NULL; + return CURLE_FAILED_INIT; } #else /* !HAVE_GETADDRINFO */ From 65597f8fc92671400ddd3572749e58b07c3c8477 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sun, 7 Dec 2025 00:03:56 +0100 Subject: [PATCH 213/415] noproxy: fix build on systems without IPv6 Follow-up to ff2aaed9ba6f186feb57f89fc6854 Reported-by: Harry Sintonen Closes #19860 --- lib/noproxy.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/noproxy.c b/lib/noproxy.c index e0d0877fdc4f..86acf8ba2b91 100644 --- a/lib/noproxy.c +++ b/lib/noproxy.c @@ -211,8 +211,10 @@ bool Curl_check_noproxy(const char *name, const char *no_proxy) namelen = strlen(name); if(curlx_inet_pton(AF_INET, name, &address) == 1) type = TYPE_IPV4; +#ifdef USE_IPV6 else if(curlx_inet_pton(AF_INET6, name, &address) == 1) type = TYPE_IPV6; +#endif else { /* ignore trailing dots in the hostname */ if(name[namelen - 1] == '.') From 9ec63d8565c9d3194c70e2ad3433b623308ee467 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sun, 7 Dec 2025 12:24:33 +0100 Subject: [PATCH 214/415] hsts: use one malloc instead of two per entry Closes #19861 --- lib/hsts.c | 21 +++++---------------- lib/hsts.h | 2 +- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/lib/hsts.c b/lib/hsts.c index 66f983e493fb..62c4c587dfb3 100644 --- a/lib/hsts.c +++ b/lib/hsts.c @@ -75,11 +75,7 @@ struct hsts *Curl_hsts_init(void) return h; } -static void hsts_free(struct stsentry *e) -{ - curlx_free(CURL_UNCONST(e->host)); - curlx_free(e); -} +#define hsts_free(x) curlx_free(x) void Curl_hsts_cleanup(struct hsts **hp) { @@ -111,18 +107,11 @@ static CURLcode hsts_create(struct hsts *h, /* strip off any trailing dot */ --hlen; if(hlen) { - char *duphost; - struct stsentry *sts = curlx_calloc(1, sizeof(struct stsentry)); + struct stsentry *sts = curlx_calloc(1, sizeof(struct stsentry) + hlen); if(!sts) return CURLE_OUT_OF_MEMORY; - - duphost = Curl_memdup0(hostname, hlen); - if(!duphost) { - curlx_free(sts); - return CURLE_OUT_OF_MEMORY; - } - - sts->host = duphost; + /* the null terminator is already there */ + memcpy(sts->host, hostname, hlen); sts->expires = expires; sts->includeSubDomains = subdomains; Curl_llist_append(&h->list, sts, &sts->node); @@ -294,7 +283,7 @@ static CURLcode hsts_push(struct Curl_easy *data, struct tm stamp; CURLcode result; - e.name = (char *)CURL_UNCONST(sts->host); + e.name = (char *)sts->host; e.namelen = strlen(sts->host); e.includeSubDomains = sts->includeSubDomains; diff --git a/lib/hsts.h b/lib/hsts.h index 91fe778788c7..bd6ebba4dea4 100644 --- a/lib/hsts.h +++ b/lib/hsts.h @@ -35,9 +35,9 @@ extern time_t deltatime; struct stsentry { struct Curl_llist_node node; - const char *host; curl_off_t expires; /* the timestamp of this entry's expiry */ BIT(includeSubDomains); + char host[1]; }; /* The HSTS cache. Needs to be able to tailmatch hostnames. */ From a3f4fd25d3991fe955afa2f5e3994c04339cc842 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sun, 7 Dec 2025 12:35:42 +0100 Subject: [PATCH 215/415] http: return OOM errors from hsts properly When Curl_hsts_parse() fails with out of memory, return it to parent. Closes #19862 --- lib/http.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/http.c b/lib/http.c index ba42f19ff0f9..ce5f5becdf0e 100644 --- a/lib/http.c +++ b/lib/http.c @@ -3501,8 +3501,11 @@ static CURLcode http_header_s(struct Curl_easy *data, if(v) { CURLcode check = Curl_hsts_parse(data->hsts, conn->host.name, v); - if(check) + if(check) { + if(check == CURLE_OUT_OF_MEMORY) + return check; infof(data, "Illegal STS header skipped"); + } #ifdef DEBUGBUILD else infof(data, "Parsed STS header fine (%zu entries)", From cc5c1553fbdb8c1391d0cf81134583ee32da64d4 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Fri, 5 Dec 2025 14:53:35 +0100 Subject: [PATCH 216/415] wolfssl: fix possible assert with `!HAVE_NO_EX` wolfSSL builds Without this option `wolfSSL_get_app_data()` always returns NULL. Disable codepaths using it (and its `set` pair) when curl is built against a wolfSSL library with this option missing. Fixing: ``` curl: ../../lib/vtls/wolfssl.c:486: wssl_vtls_new_session_cb: Assertion `cf != ((void *)0)' failed. ``` wolfSSL can be built with the `--enable-context-extra-user-data` or `-DWOLFSSL_EX_DATA` option to enable this feature. Some higher-level features also enable it automatically like QUIC, ASIO. Reported-by: Yedaya Katsman Bug: https://github.com/curl/curl/pull/19816#issuecomment-3606447845 Ref: https://github.com/curl/curl/actions/runs/19871780796/job/56949160740 Closes #19852 --- lib/vtls/wolfssl.c | 8 ++++++++ lib/vtls/wolfssl.h | 2 ++ 2 files changed, 10 insertions(+) diff --git a/lib/vtls/wolfssl.c b/lib/vtls/wolfssl.c index d4d586b0ea35..0c47e9c2eefb 100644 --- a/lib/vtls/wolfssl.c +++ b/lib/vtls/wolfssl.c @@ -414,6 +414,7 @@ static void wssl_bio_cf_free_methods(void) #endif /* !USE_BIO_CHAIN */ +#ifdef HAVE_EX_DATA CURLcode Curl_wssl_cache_session(struct Curl_cfilter *cf, struct Curl_easy *data, const char *ssl_peer_key, @@ -497,6 +498,7 @@ static int wssl_vtls_new_session_cb(WOLFSSL *ssl, WOLFSSL_SESSION *session) } return 0; } +#endif static CURLcode wssl_on_session_reuse(struct Curl_cfilter *cf, struct Curl_easy *data, @@ -1260,10 +1262,12 @@ CURLcode Curl_wssl_ctx_init(struct wssl_ctx *wctx, } #endif +#ifdef HAVE_EX_DATA if(Curl_ssl_scache_use(cf, data) && (transport != TRNSPRT_QUIC)) { /* Register to get notified when a new session is received */ wolfSSL_CTX_sess_set_new_cb(wctx->ssl_ctx, wssl_vtls_new_session_cb); } +#endif if(cb_setup) { result = cb_setup(cf, data, cb_user_data); @@ -1304,7 +1308,11 @@ CURLcode Curl_wssl_ctx_init(struct wssl_ctx *wctx, goto out; } +#ifdef HAVE_EX_DATA wolfSSL_set_app_data(wctx->ssl, ssl_user_data); +#else + (void)ssl_user_data; +#endif #ifdef WOLFSSL_QUIC if(transport == TRNSPRT_QUIC) wolfSSL_set_quic_use_legacy_codepoint(wctx->ssl, 0); diff --git a/lib/vtls/wolfssl.h b/lib/vtls/wolfssl.h index 5e3c9e2c5dd6..736da9a1a6a2 100644 --- a/lib/vtls/wolfssl.h +++ b/lib/vtls/wolfssl.h @@ -75,6 +75,7 @@ CURLcode Curl_wssl_setup_x509_store(struct Curl_cfilter *cf, struct Curl_easy *data, struct wssl_ctx *wssl); +#ifdef HAVE_EX_DATA CURLcode Curl_wssl_cache_session(struct Curl_cfilter *cf, struct Curl_easy *data, const char *ssl_peer_key, @@ -83,6 +84,7 @@ CURLcode Curl_wssl_cache_session(struct Curl_cfilter *cf, const char *alpn, unsigned char *quic_tp, size_t quic_tp_len); +#endif CURLcode Curl_wssl_verify_pinned(struct Curl_cfilter *cf, struct Curl_easy *data, From f08417c4259a3b9a2e4d72a48fa02ce6502cb587 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Sun, 7 Dec 2025 16:58:34 +0100 Subject: [PATCH 217/415] runner.pm: run memanalyzer as a Perl module To improve performance of torture tests. Also on Windows, where this patch may make those viable for CI. Linux !FTP 4m47 -> 4m24 (-shallow=25) Linux FTP 2m30 -> 2m23 (-shallow=25) macOS !FTP 14m30 -> 13m07 (-shallow=25) macOS FTP 3m57 -> 3m59 (-shallow=25) Windows !FTP >25m -> 4m47 to 14m45 (-shallow=5 to 25) (not in CI) Linux Before: https://github.com/curl/curl/actions/runs/20006771767/job/57370205514 After: https://github.com/curl/curl/actions/runs/20006783210/job/57370236911?pr=19863 macOS: Before: https://github.com/curl/curl/actions/runs/20006771786/job/57370205769 After: https://github.com/curl/curl/actions/runs/20006783177/job/57370236995?pr=19863 Windows: Before: https://github.com/curl/curl/actions/runs/19667198537/job/56326962912?pr=19675 After: https://github.com/curl/curl/actions/runs/20007175773/job/57371768734?pr=19863 After shallow=25: https://github.com/curl/curl/actions/runs/20008523913/job/57374427449?pr=19865 Ref: #19675 Follow-up to 472bc9032374f98f48f7a2df6c644cff91fe142c #19821 Closes #19863 --- tests/runner.pm | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/runner.pm b/tests/runner.pm index b69bbf2420aa..10be04bd4b49 100644 --- a/tests/runner.pm +++ b/tests/runner.pm @@ -107,6 +107,7 @@ use testutil qw( subnewlines ); use valgrind; +use memanalyzer; ####################################################################### @@ -449,7 +450,7 @@ sub torture { # memanalyze -v is our friend, get the number of allocations made my $count=0; - my @out = `$memanalyze -v "$LOGDIR/$MEMDUMP"`; + my @out = memanalyze("$LOGDIR/$MEMDUMP", 1, 0, 0); for(@out) { if(/^Operations: (\d+)/) { $count = $1; @@ -549,7 +550,7 @@ sub torture { $fail=1; } else { - my @memdata=`$memanalyze "$LOGDIR/$MEMDUMP"`; + my @memdata = memanalyze("$LOGDIR/$MEMDUMP", 0, 0, 0); my $leak=0; for(@memdata) { if($_ ne "") { @@ -561,7 +562,7 @@ sub torture { if($leak) { logmsg "** MEMORY FAILURE\n"; logmsg @memdata; - logmsg `$memanalyze -l "$LOGDIR/$MEMDUMP"`; + logmsg memanalyze("$LOGDIR/$MEMDUMP", 0, 0, 1); $fail = 1; } } From c6e5dfa2c67570f98225959148a6e78c1e2180f2 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sun, 7 Dec 2025 13:17:24 +0100 Subject: [PATCH 218/415] cookie: allocate the main struct once cookie is fine This delays the allocating of the cookie struct until after all the checks have been done, as many cookies are received and discarded instead of accepted and this then saves one allocation for every discarded cookie. Closes #19864 --- lib/cookie.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/lib/cookie.c b/lib/cookie.c index 5c29768bbdfc..743ed56404a5 100644 --- a/lib/cookie.c +++ b/lib/cookie.c @@ -65,14 +65,15 @@ static void cap_expires(time_t now, struct Cookie *co) } } -static void freecookie(struct Cookie *co) +static void freecookie(struct Cookie *co, bool maintoo) { curlx_free(co->domain); curlx_free(co->path); curlx_free(co->spath); curlx_free(co->name); curlx_free(co->value); - curlx_free(co); + if(maintoo) + curlx_free(co); } static bool cookie_tailmatch(const char *cookie_domain, @@ -312,7 +313,7 @@ static void remove_expired(struct CookieInfo *ci) if(co->expires) { if(co->expires < now) { Curl_node_remove(n); - freecookie(co); + freecookie(co, TRUE); ci->numcookies--; } else if(co->expires < ci->next_expiration) @@ -938,7 +939,7 @@ static bool replace_existing(struct Curl_easy *data, Curl_node_remove(replace_n); /* free the old cookie */ - freecookie(repl); + freecookie(repl, TRUE); } *replacep = replace_old; return TRUE; @@ -964,6 +965,7 @@ Curl_cookie_add(struct Curl_easy *data, unless set */ bool secure) /* TRUE if connection is over secure origin */ { + struct Cookie comem; struct Cookie *co; size_t myhash; CURLcode result; @@ -975,10 +977,8 @@ Curl_cookie_add(struct Curl_easy *data, if(data->req.setcookies >= MAX_SET_COOKIE_AMOUNT) return CURLE_OK; /* silently ignore */ - /* First, alloc and init a new struct for it */ - co = curlx_calloc(1, sizeof(struct Cookie)); - if(!co) - return CURLE_OUT_OF_MEMORY; /* bail out if we are this low on memory */ + co = &comem; + memset(co, 0, sizeof(comem)); if(httpheader) result = parse_cookie_header(data, co, ci, &okay, @@ -1028,6 +1028,13 @@ Curl_cookie_add(struct Curl_easy *data, if(!replace_existing(data, co, ci, secure, &replaces)) goto fail; + /* clone the stack struct into heap */ + co = Curl_memdup(&comem, sizeof(comem)); + if(!co) { + co = &comem; + goto fail; /* bail out if we are this low on memory */ + } + /* add this cookie to the list */ myhash = cookiehash(co->domain); Curl_llist_append(&ci->cookielist[myhash], co, &co->node); @@ -1054,7 +1061,7 @@ Curl_cookie_add(struct Curl_easy *data, return result; fail: - freecookie(co); + freecookie(co, FALSE); return result; } @@ -1382,7 +1389,7 @@ void Curl_cookie_clearall(struct CookieInfo *ci) struct Cookie *c = Curl_node_elem(n); struct Curl_llist_node *e = Curl_node_next(n); Curl_node_remove(n); - freecookie(c); + freecookie(c, TRUE); n = e; } } @@ -1411,7 +1418,7 @@ void Curl_cookie_clearsess(struct CookieInfo *ci) e = Curl_node_next(n); /* in case the node is removed, get it early */ if(!curr->expires) { Curl_node_remove(n); - freecookie(curr); + freecookie(curr, TRUE); ci->numcookies--; } } From 524936fbebf2a37f5d02c97da2842fa6655a25bd Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sun, 7 Dec 2025 13:49:33 +0100 Subject: [PATCH 219/415] cookie: when parsing a cookie header, delay all allocations until okay To avoid wasting time allocating data for incoming cookies that are discarded for one reason or another, delay allocations until after verifications are done. Closes #19864 --- lib/cookie.c | 145 +++++++++++++++++++++++++++------------------------ 1 file changed, 77 insertions(+), 68 deletions(-) diff --git a/lib/cookie.c b/lib/cookie.c index 743ed56404a5..743a7a832860 100644 --- a/lib/cookie.c +++ b/lib/cookie.c @@ -43,8 +43,6 @@ #include "bufref.h" #include "curlx/strparse.h" -static void strstore(char **str, const char *newstr, size_t len); - /* number of seconds in 400 days */ #define COOKIES_MAXAGE (400 * 24 * 3600) @@ -263,15 +261,17 @@ static char *sanitize_cookie_path(const char *cookie_path) * parsing in a last-wins scenario. The caller is responsible for checking * for OOM errors. */ -static void strstore(char **str, const char *newstr, size_t len) +static CURLcode strstore(char **str, const char *newstr, size_t len) { DEBUGASSERT(str); - curlx_free(*str); if(!len) { len++; newstr = ""; } *str = Curl_memdup0(newstr, len); + if(!*str) + return CURLE_OUT_OF_MEMORY; + return CURLE_OK; } /* @@ -356,14 +356,15 @@ static bool bad_domain(const char *domain, size_t len) fine. The prime reason for filtering out control bytes is that some HTTP servers return 400 for requests that contain such. */ -static bool invalid_octets(const char *ptr) +static bool invalid_octets(const char *ptr, size_t len) { const unsigned char *p = (const unsigned char *)ptr; /* Reject all bytes \x01 - \x1f (*except* \x09, TAB) + \x7f */ - while(*p) { + while(len && *p) { if(((*p != 9) && (*p < 0x20)) || (*p == 0x7f)) return TRUE; p++; + len--; } return FALSE; } @@ -375,6 +376,57 @@ static bool invalid_octets(const char *ptr) */ #define MAX_DATE_LENGTH 80 +#define COOKIE_NAME 0 +#define COOKIE_VALUE 1 +#define COOKIE_DOMAIN 2 +#define COOKIE_PATH 3 + +#define COOKIE_PIECES 4 /* the list above */ + +static CURLcode storecookie(struct Cookie *co, struct Curl_str *cp, + const char *path, const char *domain) +{ + CURLcode result; + result = strstore(&co->name, curlx_str(&cp[COOKIE_NAME]), + curlx_strlen(&cp[COOKIE_NAME])); + if(!result) + result = strstore(&co->value, curlx_str(&cp[COOKIE_VALUE]), + curlx_strlen(&cp[COOKIE_VALUE])); + if(!result) { + if(curlx_strlen(&cp[COOKIE_PATH])) + result = strstore(&co->path, curlx_str(&cp[COOKIE_PATH]), + curlx_strlen(&cp[COOKIE_PATH])); + else if(path) { + /* No path was given in the header line, set the default */ + const char *endslash = strrchr(path, '/'); + if(endslash) { + size_t pathlen = (endslash - path + 1); /* include end slash */ + co->path = Curl_memdup0(path, pathlen); + if(!co->path) + result = CURLE_OUT_OF_MEMORY; + } + } + + if(!result && co->path) { + co->spath = sanitize_cookie_path(co->path); + if(!co->spath) + result = CURLE_OUT_OF_MEMORY; + } + } + if(!result) { + if(curlx_strlen(&cp[COOKIE_DOMAIN])) + result = strstore(&co->domain, curlx_str(&cp[COOKIE_DOMAIN]), + curlx_strlen(&cp[COOKIE_DOMAIN])); + else if(domain) { + /* no domain was given in the header line, set the default */ + co->domain = curlx_strdup(domain); + if(!co->domain) + result = CURLE_OUT_OF_MEMORY; + } + } + return result; +} + /* this function return errors on OOM etc, not on plain cookie format problems */ static CURLcode @@ -393,6 +445,8 @@ parse_cookie_header(struct Curl_easy *data, /* This line was read off an HTTP-header */ time_t now; size_t linelength = strlen(ptr); + CURLcode result; + struct Curl_str cookie[COOKIE_PIECES] = { 0 }; *okay = FALSE; if(linelength > MAX_COOKIE_LINE) /* discard overly long lines at once */ @@ -449,29 +503,18 @@ parse_cookie_header(struct Curl_easy *data, else if(!strncmp("__Host-", curlx_str(&name), 7)) co->prefix_host = TRUE; - /* - * Use strstore() below to properly deal with received cookie - * headers that have the same string property set more than once, - * and then we use the last one. - */ - - if(!co->name) { + if(!curlx_strlen(&cookie[COOKIE_NAME])) { /* The first name/value pair is the actual cookie name */ - if(!sep) - /* Bad name/value pair. */ - return CURLE_OK; - - strstore(&co->name, curlx_str(&name), curlx_strlen(&name)); - if(co->name) - strstore(&co->value, curlx_str(&val), curlx_strlen(&val)); - if(!co->name || !co->value) - return CURLE_OUT_OF_MEMORY; - done = TRUE; - - if(invalid_octets(co->value) || invalid_octets(co->name)) { + if(!sep || + /* Bad name/value pair. */ + invalid_octets(curlx_str(&name), curlx_strlen(&name)) || + invalid_octets(curlx_str(&val), curlx_strlen(&val))) { infof(data, "invalid octets in name/value, cookie dropped"); return CURLE_OK; } + cookie[COOKIE_NAME] = name; + cookie[COOKIE_VALUE] = val; + done = TRUE; } else if(!curlx_strlen(&val)) { /* @@ -501,13 +544,7 @@ parse_cookie_header(struct Curl_easy *data, if(done) ; else if(curlx_str_casecompare(&name, "path")) { - strstore(&co->path, curlx_str(&val), curlx_strlen(&val)); - if(!co->path) - return CURLE_OUT_OF_MEMORY; - curlx_free(co->spath); /* if this is set again */ - co->spath = sanitize_cookie_path(co->path); - if(!co->spath) - return CURLE_OUT_OF_MEMORY; + cookie[COOKIE_PATH] = val; } else if(curlx_str_casecompare(&name, "domain") && curlx_strlen(&val)) { bool is_ip; @@ -538,10 +575,7 @@ parse_cookie_header(struct Curl_easy *data, (curlx_strlen(&val) == strlen(domain))) || (!is_ip && cookie_tailmatch(curlx_str(&val), curlx_strlen(&val), domain))) { - strstore(&co->domain, curlx_str(&val), curlx_strlen(&val)); - if(!co->domain) - return CURLE_OUT_OF_MEMORY; - + cookie[COOKIE_DOMAIN] = val; if(!is_ip) co->tailmatch = TRUE; /* we always do that if the domain name was given */ @@ -627,40 +661,15 @@ parse_cookie_header(struct Curl_easy *data, break; } while(1); - if(!co->domain && domain) { - /* no domain was given in the header line, set the default */ - co->domain = curlx_strdup(domain); - if(!co->domain) - return CURLE_OUT_OF_MEMORY; - } - - if(!co->path && path) { - /* - * No path was given in the header line, set the default. - */ - const char *endslash = strrchr(path, '/'); - if(endslash) { - size_t pathlen = (endslash - path + 1); /* include end slash */ - co->path = Curl_memdup0(path, pathlen); - if(co->path) { - co->spath = sanitize_cookie_path(co->path); - if(!co->spath) - return CURLE_OUT_OF_MEMORY; - } - else - return CURLE_OUT_OF_MEMORY; - } - } - - /* - * If we did not get a cookie name, or a bad one, the this is an illegal - * line so bail out. - */ - if(!co->name) + if(!curlx_strlen(&cookie[COOKIE_NAME])) + /* If we did not get a cookie name, or a bad one, bail out. */ return CURLE_OK; - *okay = TRUE; - return CURLE_OK; + /* the header was fine, now store the data */ + result = storecookie(co, &cookie[0], path, domain); + if(!result) + *okay = TRUE; + return result; } static CURLcode parse_netscape(struct Cookie *co, From a093c93994d2afed3beed94809844c961d3f4a64 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sun, 7 Dec 2025 16:09:13 +0100 Subject: [PATCH 220/415] cookie: only keep and use the canonical cleaned up path Instead of keeping both versions around. Closes #19864 --- lib/cookie.c | 82 ++++++++++++++++-------------------- lib/cookie.h | 3 +- tests/data/test1105 | 4 +- tests/data/test1561 | 2 +- tests/data/test1903 | 4 +- tests/data/test1905 | 4 +- tests/data/test31 | 28 ++++++------- tests/data/test420 | 8 ++-- tests/data/test444 | 100 ++++++++++++++++++++++---------------------- tests/data/test46 | 2 +- tests/data/test61 | 4 +- 11 files changed, 116 insertions(+), 125 deletions(-) diff --git a/lib/cookie.c b/lib/cookie.c index 743a7a832860..7efce5611f2a 100644 --- a/lib/cookie.c +++ b/lib/cookie.c @@ -67,7 +67,6 @@ static void freecookie(struct Cookie *co, bool maintoo) { curlx_free(co->domain); curlx_free(co->path); - curlx_free(co->spath); curlx_free(co->name); curlx_free(co->value); if(maintoo) @@ -227,20 +226,19 @@ static size_t cookiehash(const char * const domain) /* * cookie path sanitize */ -static char *sanitize_cookie_path(const char *cookie_path) +static char *sanitize_cookie_path(const char *cookie_path, size_t len) { - size_t len = strlen(cookie_path); - /* some sites send path attribute within '"'. */ - if(cookie_path[0] == '\"') { + if(len && (cookie_path[0] == '\"')) { cookie_path++; len--; + + if(len && (cookie_path[len - 1] == '\"')) + len--; } - if(len && (cookie_path[len - 1] == '\"')) - len--; /* RFC6265 5.2.4 The Path Attribute */ - if(cookie_path[0] != '/') + if(!len || (cookie_path[0] != '/')) /* Let cookie-path be the default-path. */ return curlx_strdup("/"); @@ -393,23 +391,23 @@ static CURLcode storecookie(struct Cookie *co, struct Curl_str *cp, result = strstore(&co->value, curlx_str(&cp[COOKIE_VALUE]), curlx_strlen(&cp[COOKIE_VALUE])); if(!result) { - if(curlx_strlen(&cp[COOKIE_PATH])) - result = strstore(&co->path, curlx_str(&cp[COOKIE_PATH]), - curlx_strlen(&cp[COOKIE_PATH])); + size_t plen = 0; + if(curlx_strlen(&cp[COOKIE_PATH])) { + path = curlx_str(&cp[COOKIE_PATH]); + plen = curlx_strlen(&cp[COOKIE_PATH]); + } else if(path) { /* No path was given in the header line, set the default */ const char *endslash = strrchr(path, '/'); - if(endslash) { - size_t pathlen = (endslash - path + 1); /* include end slash */ - co->path = Curl_memdup0(path, pathlen); - if(!co->path) - result = CURLE_OUT_OF_MEMORY; - } + if(endslash) + plen = (endslash - path + 1); /* include end slash */ + else + plen = strlen(path); } - if(!result && co->path) { - co->spath = sanitize_cookie_path(co->path); - if(!co->spath) + if(path) { + co->path = sanitize_cookie_path(path, plen); + if(!co->path) result = CURLE_OUT_OF_MEMORY; } } @@ -734,23 +732,17 @@ static CURLcode parse_netscape(struct Cookie *co, /* The file format allows the path field to remain not filled in */ if(strncmp("TRUE", ptr, len) && strncmp("FALSE", ptr, len)) { /* only if the path does not look like a boolean option! */ - co->path = Curl_memdup0(ptr, len); + co->path = sanitize_cookie_path(ptr, len); if(!co->path) return CURLE_OUT_OF_MEMORY; - else { - co->spath = sanitize_cookie_path(co->path); - if(!co->spath) - return CURLE_OUT_OF_MEMORY; - } break; } - /* this does not look like a path, make one up! */ - co->path = curlx_strdup("/"); - if(!co->path) - return CURLE_OUT_OF_MEMORY; - co->spath = curlx_strdup("/"); - if(!co->spath) - return CURLE_OUT_OF_MEMORY; + else { + /* this does not look like a path, make one up! */ + co->path = curlx_strdup("/"); + if(!co->path) + return CURLE_OUT_OF_MEMORY; + } fields++; /* add a field and fall down to secure */ FALLTHROUGH(); case 3: @@ -875,7 +867,7 @@ static bool replace_existing(struct Curl_easy *data, matching_domains = TRUE; if(matching_domains && /* the domains were identical */ - clist->spath && co->spath && /* both have paths */ + clist->path && co->path && /* both have paths */ clist->secure && !co->secure && !secure) { size_t cllen; const char *sep = NULL; @@ -887,15 +879,15 @@ static bool replace_existing(struct Curl_easy *data, * "/loginhelper" is ok. */ - DEBUGASSERT(clist->spath[0]); - if(clist->spath[0]) - sep = strchr(clist->spath + 1, '/'); + DEBUGASSERT(clist->path[0]); + if(clist->path[0]) + sep = strchr(clist->path + 1, '/'); if(sep) - cllen = sep - clist->spath; + cllen = sep - clist->path; else - cllen = strlen(clist->spath); + cllen = strlen(clist->path); - if(curl_strnequal(clist->spath, co->spath, cllen)) { + if(curl_strnequal(clist->path, co->path, cllen)) { infof(data, "cookie '%s' for domain '%s' dropped, would " "overlay an existing cookie", co->name, co->domain); return FALSE; @@ -918,10 +910,10 @@ static bool replace_existing(struct Curl_easy *data, if(replace_old) { /* the domains were identical */ - if(clist->spath && co->spath && - !curl_strequal(clist->spath, co->spath)) + if(clist->path && co->path && + !curl_strequal(clist->path, co->path)) replace_old = FALSE; - else if(!clist->spath != !co->spath) + else if(!clist->path != !co->path) replace_old = FALSE; } @@ -1007,7 +999,7 @@ Curl_cookie_add(struct Curl_easy *data, * The __Host- prefix requires the cookie to be secure, have a "/" path * and not have a domain set. */ - if(co->secure && co->path && strcmp(co->path, "/") == 0 && !co->tailmatch) + if(co->secure && co->path && !strcmp(co->path, "/") && !co->tailmatch) ; else goto fail; @@ -1324,7 +1316,7 @@ CURLcode Curl_cookie_getlist(struct Curl_easy *data, * now check the left part of the path with the cookies path * requirement */ - if(!co->spath || pathmatch(co->spath, path)) { + if(!co->path || pathmatch(co->path, path)) { /* * This is a match and we add it to the return-linked-list diff --git a/lib/cookie.h b/lib/cookie.h index c1fb23ee4c23..03877e509f1d 100644 --- a/lib/cookie.h +++ b/lib/cookie.h @@ -34,8 +34,7 @@ struct Cookie { struct Curl_llist_node getnode; /* for getlist */ char *name; /* = value */ char *value; /* name = */ - char *path; /* path = which is in Set-Cookie: */ - char *spath; /* sanitized cookie path */ + char *path; /* canonical path */ char *domain; /* domain = */ curl_off_t expires; /* expires = */ unsigned int creationtime; /* time when the cookie was written */ diff --git a/tests/data/test1105 b/tests/data/test1105 index ea42efb6a9c0..e0766817295e 100644 --- a/tests/data/test1105 +++ b/tests/data/test1105 @@ -61,8 +61,8 @@ userid=myname&password=mypassword # https://curl.se/docs/http-cookies.html # This file was generated by libcurl! Edit at your own risk. -127.0.0.1 FALSE "/silly/" FALSE 0 mismatch this -127.0.0.1 FALSE /we/want/ FALSE 0 foobar name +127.0.0.1 FALSE /silly FALSE 0 mismatch this +127.0.0.1 FALSE /we/want FALSE 0 foobar name diff --git a/tests/data/test1561 b/tests/data/test1561 index df9477dd47bd..84b291b12e26 100644 --- a/tests/data/test1561 +++ b/tests/data/test1561 @@ -98,7 +98,7 @@ Accept: */* www.example.com FALSE / TRUE 0 __Host-SID 12346 .example.com TRUE / TRUE 0 supersupersuper secret .example.com TRUE / TRUE 0 __SecURE-SID 12346 -.example.com TRUE /%TESTNUMBER/login/ TRUE 0 supersuper secret +.example.com TRUE /%TESTNUMBER/login TRUE 0 supersuper secret .example.com TRUE /1561 TRUE 0 super secret diff --git a/tests/data/test1903 b/tests/data/test1903 index 228b4d6ae46f..9b90151c0962 100644 --- a/tests/data/test1903 +++ b/tests/data/test1903 @@ -55,8 +55,8 @@ cookies # https://curl.se/docs/http-cookies.html # This file was generated by libcurl! Edit at your own risk. -%HOSTIP FALSE /we/want/ FALSE 0 foobar name -%HOSTIP FALSE /we/want/ FALSE 0 secondcookie present +%HOSTIP FALSE /we/want FALSE 0 foobar name +%HOSTIP FALSE /we/want FALSE 0 secondcookie present diff --git a/tests/data/test1905 b/tests/data/test1905 index 690e8553ec0f..e09f8dc60eaf 100644 --- a/tests/data/test1905 +++ b/tests/data/test1905 @@ -53,8 +53,8 @@ Accept: */* # https://curl.se/docs/http-cookies.html # This file was generated by libcurl! Edit at your own risk. -%HOSTIP FALSE /we/want/ FALSE 0 secondcookie present -%HOSTIP FALSE /we/want/ FALSE 0 foobar name +%HOSTIP FALSE /we/want FALSE 0 secondcookie present +%HOSTIP FALSE /we/want FALSE 0 foobar name diff --git a/tests/data/test31 b/tests/data/test31 index 8d99df6da8af..8353b709fc09 100644 --- a/tests/data/test31 +++ b/tests/data/test31 @@ -111,22 +111,22 @@ Accept: */* # https://curl.se/docs/http-cookies.html # This file was generated by libcurl! Edit at your own risk. -test31.curl FALSE /we/want/ FALSE 0 %hex[%c3%82%c2%b3%c3%83%5c%78%39%32%c3%83%5c%78%39%61%c3%83%5c%78%38%64%c3%83%5c%78%39%37]hex% %96%A6g%9Ay%B0%A5g%A7tm%7C%95%9A -test31.curl FALSE /we/want/ FALSE 0 prespace yes before -test31.curl FALSE /we/want/ FALSE 0 withspaces2 before equals -test31.curl FALSE /we/want/ FALSE 0 withspaces yes within and around -.test31.curl TRUE /we/want/ FALSE 0 blexp yesyes -#HttpOnly_test31.curl FALSE /silly/ FALSE 0 magic yessir -test31.curl FALSE /we/want/ FALSE %days[400] nodomain value +test31.curl FALSE /we/want FALSE 0 %hex[%c3%82%c2%b3%c3%83%5c%78%39%32%c3%83%5c%78%39%61%c3%83%5c%78%38%64%c3%83%5c%78%39%37]hex% %96%A6g%9Ay%B0%A5g%A7tm%7C%95%9A +test31.curl FALSE /we/want FALSE 0 prespace yes before +test31.curl FALSE /we/want FALSE 0 withspaces2 before equals +test31.curl FALSE /we/want FALSE 0 withspaces yes within and around +.test31.curl TRUE /we/want FALSE 0 blexp yesyes +#HttpOnly_test31.curl FALSE /silly FALSE 0 magic yessir +test31.curl FALSE /we/want FALSE %days[400] nodomain value .test31.curl TRUE / FALSE 0 partmatch present -#HttpOnly_.test31.curl TRUE /p4/ FALSE 0 httponly myvalue1 -#HttpOnly_.test31.curl TRUE /p4/ FALSE 0 httpo4 value4 -#HttpOnly_.test31.curl TRUE /p3/ FALSE 0 httpo3 value3 -#HttpOnly_.test31.curl TRUE /p2/ FALSE 0 httpo2 value2 -#HttpOnly_.test31.curl TRUE /p1/ FALSE 0 httpo1 value1 +#HttpOnly_.test31.curl TRUE /p4 FALSE 0 httponly myvalue1 +#HttpOnly_.test31.curl TRUE /p4 FALSE 0 httpo4 value4 +#HttpOnly_.test31.curl TRUE /p3 FALSE 0 httpo3 value3 +#HttpOnly_.test31.curl TRUE /p2 FALSE 0 httpo2 value2 +#HttpOnly_.test31.curl TRUE /p1 FALSE 0 httpo1 value1 .test31.curl TRUE /overwrite FALSE 0 overwrite this2 -.test31.curl TRUE /silly/ FALSE 0 ISMATCH this -.test31.curl TRUE /silly/ FALSE 0 ismatch this +.test31.curl TRUE /silly FALSE 0 ISMATCH this +.test31.curl TRUE /silly FALSE 0 ismatch this test31.curl FALSE / FALSE 0 blankdomain sure diff --git a/tests/data/test420 b/tests/data/test420 index c1d6173f4fea..7b8bd08fde00 100644 --- a/tests/data/test420 +++ b/tests/data/test420 @@ -44,9 +44,9 @@ http://%HOSTIP:%HTTPPORT/func_test/del_cookie -b %LOGDIR/cookie%TESTNUMBER -c %L #HttpOnly_%HOSTIP FALSE /func_test FALSE 21709598616 mycookie5 990 #HttpOnly_%HOSTIP FALSE /func_test FALSE 21709598616 mycookie4 950 #HttpOnly_%HOSTIP FALSE /func_test FALSE 21709598616 mycookie3 900 -#HttpOnly_%HOSTIP FALSE /func_test/ FALSE 21709598616 mycookie2 5900 +#HttpOnly_%HOSTIP FALSE /func_test FALSE 21709598616 mycookie2 5900 #HttpOnly_%HOSTIP FALSE / FALSE 21709598616 mycookie1 4900 -#HttpOnly_%HOSTIP FALSE /func_test/ FALSE 0 mycookie 1200 +#HttpOnly_%HOSTIP FALSE /func_test FALSE 0 mycookie 1200 cookies @@ -61,7 +61,7 @@ GET /func_test/del_cookie HTTP/1.1 Host: %HOSTIP:%HTTPPORT User-Agent: curl/%VERSION Accept: */* -Cookie: mycookie2=5900; mycookie=1200; mycookie3=900; mycookie4=950; mycookie5=990; mycookie6=991; mycookie1=4900 +Cookie: mycookie2=5900; mycookie3=900; mycookie4=950; mycookie5=990; mycookie6=991; mycookie=1200; mycookie1=4900 @@ -69,7 +69,7 @@ Cookie: mycookie2=5900; mycookie=1200; mycookie3=900; mycookie4=950; mycookie5=9 # https://curl.se/docs/http-cookies.html # This file was generated by libcurl! Edit at your own risk. -#HttpOnly_127.0.0.1 FALSE /func_test/ FALSE 21709598616 mycookie2 5900 +#HttpOnly_127.0.0.1 FALSE /func_test FALSE 21709598616 mycookie2 5900 diff --git a/tests/data/test444 b/tests/data/test444 index 4c092bef1b94..0b050e114676 100644 --- a/tests/data/test444 +++ b/tests/data/test444 @@ -138,56 +138,56 @@ Accept: */* # https://curl.se/docs/http-cookies.html # This file was generated by libcurl! Edit at your own risk. -attack.invalid FALSE /a/b/ FALSE 0 cookie-50 yes -attack.invalid FALSE /a/b/ FALSE 0 cookie-49 yes -attack.invalid FALSE /a/b/ FALSE 0 cookie-48 yes -attack.invalid FALSE /a/b/ FALSE 0 cookie-47 yes -attack.invalid FALSE /a/b/ FALSE 0 cookie-46 yes -attack.invalid FALSE /a/b/ FALSE 0 cookie-45 yes -attack.invalid FALSE /a/b/ FALSE 0 cookie-44 yes -attack.invalid FALSE /a/b/ FALSE 0 cookie-43 yes -attack.invalid FALSE /a/b/ FALSE 0 cookie-42 yes -attack.invalid FALSE /a/b/ FALSE 0 cookie-41 yes -attack.invalid FALSE /a/b/ FALSE 0 cookie-40 yes -attack.invalid FALSE /a/b/ FALSE 0 cookie-39 yes -attack.invalid FALSE /a/b/ FALSE 0 cookie-38 yes -attack.invalid FALSE /a/b/ FALSE 0 cookie-37 yes -attack.invalid FALSE /a/b/ FALSE 0 cookie-36 yes -attack.invalid FALSE /a/b/ FALSE 0 cookie-35 yes -attack.invalid FALSE /a/b/ FALSE 0 cookie-34 yes -attack.invalid FALSE /a/b/ FALSE 0 cookie-33 yes -attack.invalid FALSE /a/b/ FALSE 0 cookie-32 yes -attack.invalid FALSE /a/b/ FALSE 0 cookie-31 yes -attack.invalid FALSE /a/b/ FALSE 0 cookie-30 yes -attack.invalid FALSE /a/b/ FALSE 0 cookie-29 yes -attack.invalid FALSE /a/b/ FALSE 0 cookie-28 yes -attack.invalid FALSE /a/b/ FALSE 0 cookie-27 yes -attack.invalid FALSE /a/b/ FALSE 0 cookie-26 yes -attack.invalid FALSE /a/b/ FALSE 0 cookie-25 yes -attack.invalid FALSE /a/b/ FALSE 0 cookie-24 yes -attack.invalid FALSE /a/b/ FALSE 0 cookie-23 yes -attack.invalid FALSE /a/b/ FALSE 0 cookie-22 yes -attack.invalid FALSE /a/b/ FALSE 0 cookie-21 yes -attack.invalid FALSE /a/b/ FALSE 0 cookie-20 yes -attack.invalid FALSE /a/b/ FALSE 0 cookie-19 yes -attack.invalid FALSE /a/b/ FALSE 0 cookie-18 yes -attack.invalid FALSE /a/b/ FALSE 0 cookie-17 yes -attack.invalid FALSE /a/b/ FALSE 0 cookie-16 yes -attack.invalid FALSE /a/b/ FALSE 0 cookie-15 yes -attack.invalid FALSE /a/b/ FALSE 0 cookie-14 yes -attack.invalid FALSE /a/b/ FALSE 0 cookie-13 yes -attack.invalid FALSE /a/b/ FALSE 0 cookie-12 yes -attack.invalid FALSE /a/b/ FALSE 0 cookie-11 yes -attack.invalid FALSE /a/b/ FALSE 0 cookie-10 yes -attack.invalid FALSE /a/b/ FALSE 0 cookie-9 yes -attack.invalid FALSE /a/b/ FALSE 0 cookie-8 yes -attack.invalid FALSE /a/b/ FALSE 0 cookie-7 yes -attack.invalid FALSE /a/b/ FALSE 0 cookie-6 yes -attack.invalid FALSE /a/b/ FALSE 0 cookie-5 yes -attack.invalid FALSE /a/b/ FALSE 0 cookie-4 yes -attack.invalid FALSE /a/b/ FALSE 0 cookie-3 yes -attack.invalid FALSE /a/b/ FALSE 0 cookie-2 yes -attack.invalid FALSE /a/b/ FALSE 0 cookie-1 yes +attack.invalid FALSE /a/b FALSE 0 cookie-50 yes +attack.invalid FALSE /a/b FALSE 0 cookie-49 yes +attack.invalid FALSE /a/b FALSE 0 cookie-48 yes +attack.invalid FALSE /a/b FALSE 0 cookie-47 yes +attack.invalid FALSE /a/b FALSE 0 cookie-46 yes +attack.invalid FALSE /a/b FALSE 0 cookie-45 yes +attack.invalid FALSE /a/b FALSE 0 cookie-44 yes +attack.invalid FALSE /a/b FALSE 0 cookie-43 yes +attack.invalid FALSE /a/b FALSE 0 cookie-42 yes +attack.invalid FALSE /a/b FALSE 0 cookie-41 yes +attack.invalid FALSE /a/b FALSE 0 cookie-40 yes +attack.invalid FALSE /a/b FALSE 0 cookie-39 yes +attack.invalid FALSE /a/b FALSE 0 cookie-38 yes +attack.invalid FALSE /a/b FALSE 0 cookie-37 yes +attack.invalid FALSE /a/b FALSE 0 cookie-36 yes +attack.invalid FALSE /a/b FALSE 0 cookie-35 yes +attack.invalid FALSE /a/b FALSE 0 cookie-34 yes +attack.invalid FALSE /a/b FALSE 0 cookie-33 yes +attack.invalid FALSE /a/b FALSE 0 cookie-32 yes +attack.invalid FALSE /a/b FALSE 0 cookie-31 yes +attack.invalid FALSE /a/b FALSE 0 cookie-30 yes +attack.invalid FALSE /a/b FALSE 0 cookie-29 yes +attack.invalid FALSE /a/b FALSE 0 cookie-28 yes +attack.invalid FALSE /a/b FALSE 0 cookie-27 yes +attack.invalid FALSE /a/b FALSE 0 cookie-26 yes +attack.invalid FALSE /a/b FALSE 0 cookie-25 yes +attack.invalid FALSE /a/b FALSE 0 cookie-24 yes +attack.invalid FALSE /a/b FALSE 0 cookie-23 yes +attack.invalid FALSE /a/b FALSE 0 cookie-22 yes +attack.invalid FALSE /a/b FALSE 0 cookie-21 yes +attack.invalid FALSE /a/b FALSE 0 cookie-20 yes +attack.invalid FALSE /a/b FALSE 0 cookie-19 yes +attack.invalid FALSE /a/b FALSE 0 cookie-18 yes +attack.invalid FALSE /a/b FALSE 0 cookie-17 yes +attack.invalid FALSE /a/b FALSE 0 cookie-16 yes +attack.invalid FALSE /a/b FALSE 0 cookie-15 yes +attack.invalid FALSE /a/b FALSE 0 cookie-14 yes +attack.invalid FALSE /a/b FALSE 0 cookie-13 yes +attack.invalid FALSE /a/b FALSE 0 cookie-12 yes +attack.invalid FALSE /a/b FALSE 0 cookie-11 yes +attack.invalid FALSE /a/b FALSE 0 cookie-10 yes +attack.invalid FALSE /a/b FALSE 0 cookie-9 yes +attack.invalid FALSE /a/b FALSE 0 cookie-8 yes +attack.invalid FALSE /a/b FALSE 0 cookie-7 yes +attack.invalid FALSE /a/b FALSE 0 cookie-6 yes +attack.invalid FALSE /a/b FALSE 0 cookie-5 yes +attack.invalid FALSE /a/b FALSE 0 cookie-4 yes +attack.invalid FALSE /a/b FALSE 0 cookie-3 yes +attack.invalid FALSE /a/b FALSE 0 cookie-2 yes +attack.invalid FALSE /a/b FALSE 0 cookie-1 yes diff --git a/tests/data/test46 b/tests/data/test46 index 715616e23c23..9d872bab6d87 100644 --- a/tests/data/test46 +++ b/tests/data/test46 @@ -87,7 +87,7 @@ Cookie: empty=; mooo2=indeed2; mooo=indeed # https://curl.se/docs/http-cookies.html # This file was generated by libcurl! Edit at your own risk. -domain..tld FALSE /want/ FALSE 0 simplyhuge %repeat[3998 x z]% +domain..tld FALSE /want FALSE 0 simplyhuge %repeat[3998 x z]% domain..tld FALSE / FALSE 0 justaname%TAB domain..tld FALSE / FALSE 0 ASPSESSIONIDQGGQQSJJ GKNBDIFAAOFDPDAIEAKDIBKE domain..tld FALSE / FALSE 0 ckySession temporary diff --git a/tests/data/test61 b/tests/data/test61 index cd38c000051b..050d0b393cb7 100644 --- a/tests/data/test61 +++ b/tests/data/test61 @@ -71,8 +71,8 @@ Accept: */* # https://curl.se/docs/http-cookies.html # This file was generated by libcurl! Edit at your own risk. -.host.foo.com TRUE /we/want/ FALSE %days[400] test2 yes -#HttpOnly_.foo.com TRUE /we/want/ FALSE %days[400] test yes +.host.foo.com TRUE /we/want FALSE %days[400] test2 yes +#HttpOnly_.foo.com TRUE /we/want FALSE %days[400] test yes From a78a07d3a9dc808a51f464d0dd297939e544e2a4 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sun, 7 Dec 2025 23:44:31 +0100 Subject: [PATCH 221/415] cookie: cleanups and improvements - Stricter cookie validation with earlier rejection of empty/invalid cookie names - secure and httponly attributes no longer accept = with empty values (only bare keywords) - Validation checks (length, TAB, prefixes) moved into the first name/value pair block for better code organization - Deferred time(NULL) calls for better performance when expires/max-age aren't used - Simplified loop control flow by removing done flag - The cookie size restriction now only applies to name + value, not other parts of the header line. - Fixed a gcc 4.8.1 quirk Closes #19868 --- lib/cookie.c | 160 +++++++++++++++++++------------------------- tests/data/test1160 | 2 +- tests/data/test31 | 30 +++++---- 3 files changed, 87 insertions(+), 105 deletions(-) diff --git a/lib/cookie.c b/lib/cookie.c index 7efce5611f2a..716a487750e2 100644 --- a/lib/cookie.c +++ b/lib/cookie.c @@ -441,85 +441,79 @@ parse_cookie_header(struct Curl_easy *data, origin */ { /* This line was read off an HTTP-header */ - time_t now; + time_t now = 0; size_t linelength = strlen(ptr); - CURLcode result; - struct Curl_str cookie[COOKIE_PIECES] = { 0 }; + CURLcode result = CURLE_OK; + struct Curl_str cookie[COOKIE_PIECES]; *okay = FALSE; if(linelength > MAX_COOKIE_LINE) /* discard overly long lines at once */ return CURLE_OK; - now = time(NULL); + /* memset instead of initializer because gcc 4.8.1 is silly */ + memset(cookie, 0, sizeof(cookie)); do { struct Curl_str name; struct Curl_str val; /* we have a = pair or a stand-alone word here */ if(!curlx_str_cspn(&ptr, &name, ";\t\r\n=")) { - bool done = FALSE; bool sep = FALSE; curlx_str_trimblanks(&name); if(!curlx_str_single(&ptr, '=')) { sep = TRUE; /* a '=' was used */ - if(!curlx_str_cspn(&ptr, &val, ";\r\n")) { + if(!curlx_str_cspn(&ptr, &val, ";\r\n")) curlx_str_trimblanks(&val); - - /* Reject cookies with a TAB inside the value */ - if(memchr(curlx_str(&val), '\t', curlx_strlen(&val))) { - infof(data, "cookie contains TAB, dropping"); - return CURLE_OK; - } - } } - else { + else curlx_str_init(&val); - } - - /* - * Check for too long individual name or contents, or too long - * combination of name + contents. Chrome and Firefox support 4095 or - * 4096 bytes combo - */ - if(curlx_strlen(&name) >= (MAX_NAME - 1) || - curlx_strlen(&val) >= (MAX_NAME - 1) || - ((curlx_strlen(&name) + curlx_strlen(&val)) > MAX_NAME)) { - infof(data, "oversized cookie dropped, name/val %zu + %zu bytes", - curlx_strlen(&name), curlx_strlen(&val)); - return CURLE_OK; - } - - /* - * Check if we have a reserved prefix set before anything else, as we - * otherwise have to test for the prefix in both the cookie name and - * "the rest". Prefixes must start with '__' and end with a '-', so - * only test for names where that can possibly be true. - */ - if(!strncmp("__Secure-", curlx_str(&name), 9)) - co->prefix_secure = TRUE; - else if(!strncmp("__Host-", curlx_str(&name), 7)) - co->prefix_host = TRUE; if(!curlx_strlen(&cookie[COOKIE_NAME])) { /* The first name/value pair is the actual cookie name */ if(!sep || /* Bad name/value pair. */ invalid_octets(curlx_str(&name), curlx_strlen(&name)) || - invalid_octets(curlx_str(&val), curlx_strlen(&val))) { + invalid_octets(curlx_str(&val), curlx_strlen(&val)) || + !curlx_strlen(&name)) { infof(data, "invalid octets in name/value, cookie dropped"); return CURLE_OK; } + + /* + * Check for too long individual name or contents, or too long + * combination of name + contents. Chrome and Firefox support 4095 or + * 4096 bytes combo + */ + if(curlx_strlen(&name) >= (MAX_NAME - 1) || + curlx_strlen(&val) >= (MAX_NAME - 1) || + ((curlx_strlen(&name) + curlx_strlen(&val)) > MAX_NAME)) { + infof(data, "oversized cookie dropped, name/val %zu + %zu bytes", + curlx_strlen(&name), curlx_strlen(&val)); + return CURLE_OK; + } + + /* Reject cookies with a TAB inside the value */ + if(curlx_strlen(&val) && + memchr(curlx_str(&val), '\t', curlx_strlen(&val))) { + infof(data, "cookie contains TAB, dropping"); + return CURLE_OK; + } + + /* Check if we have a reserved prefix set. */ + if(!strncmp("__Secure-", curlx_str(&name), 9)) + co->prefix_secure = TRUE; + else if(!strncmp("__Host-", curlx_str(&name), 7)) + co->prefix_host = TRUE; + cookie[COOKIE_NAME] = name; cookie[COOKIE_VALUE] = val; - done = TRUE; } - else if(!curlx_strlen(&val)) { + else if(!sep) { /* - * this was a "=" with no content, and we must allow - * 'secure' and 'httponly' specified this weirdly + * this is a "" with no content */ - done = TRUE; + /* * secure cookies are only allowed to be set when the connection is * using a secure protocol, or when the cookie is being set by @@ -529,18 +523,13 @@ parse_cookie_header(struct Curl_easy *data, if(secure || !ci->running) co->secure = TRUE; else { - infof(data, "skipped cookie %s because not 'secure'", co->name); + infof(data, "skipped cookie because not 'secure'"); return CURLE_OK; } } else if(curlx_str_casecompare(&name, "httponly")) co->httponly = TRUE; - else if(sep) - /* there was a '=' so we are not done parsing this field */ - done = FALSE; } - if(done) - ; else if(curlx_str_casecompare(&name, "path")) { cookie[COOKIE_PATH] = val; } @@ -588,9 +577,6 @@ parse_cookie_header(struct Curl_easy *data, return CURLE_OK; } } - else if(curlx_str_casecompare(&name, "version")) { - /* just ignore */ - } else if(curlx_str_casecompare(&name, "max-age") && curlx_strlen(&val)) { /* * Defined in RFC2109: @@ -606,6 +592,8 @@ parse_cookie_header(struct Curl_easy *data, if(*maxage == '\"') maxage++; rc = curlx_str_number(&maxage, &co->expires, CURL_OFF_T_MAX); + if(!now) + now = time(NULL); switch(rc) { case STRE_OVERFLOW: /* overflow, used max value */ @@ -627,46 +615,38 @@ parse_cookie_header(struct Curl_easy *data, } cap_expires(now, co); } - else if(curlx_str_casecompare(&name, "expires") && curlx_strlen(&val)) { - if(!co->expires && (curlx_strlen(&val) < MAX_DATE_LENGTH)) { - /* - * Let max-age have priority. - * - * If the date cannot get parsed for whatever reason, the cookie - * will be treated as a session cookie - */ - char dbuf[MAX_DATE_LENGTH + 1]; - time_t date = 0; - memcpy(dbuf, curlx_str(&val), curlx_strlen(&val)); - dbuf[curlx_strlen(&val)] = 0; - if(!Curl_getdate_capped(dbuf, &date)) { - if(!date) - date++; - co->expires = (curl_off_t)date; - } - else - co->expires = 0; - cap_expires(now, co); + else if(curlx_str_casecompare(&name, "expires") && curlx_strlen(&val) && + !co->expires && (curlx_strlen(&val) < MAX_DATE_LENGTH)) { + /* + * Let max-age have priority. + * + * If the date cannot get parsed for whatever reason, the cookie + * will be treated as a session cookie + */ + char dbuf[MAX_DATE_LENGTH + 1]; + time_t date = 0; + memcpy(dbuf, curlx_str(&val), curlx_strlen(&val)); + dbuf[curlx_strlen(&val)] = 0; + if(!Curl_getdate_capped(dbuf, &date)) { + if(!date) + date++; + co->expires = (curl_off_t)date; } + else + co->expires = 0; + if(!now) + now = time(NULL); + cap_expires(now, co); } - - /* - * Else, this is the second (or more) name we do not know about! - */ } + } while(!curlx_str_single(&ptr, ';')); - if(curlx_str_single(&ptr, ';')) - break; - } while(1); - - if(!curlx_strlen(&cookie[COOKIE_NAME])) - /* If we did not get a cookie name, or a bad one, bail out. */ - return CURLE_OK; - - /* the header was fine, now store the data */ - result = storecookie(co, &cookie[0], path, domain); - if(!result) - *okay = TRUE; + if(curlx_strlen(&cookie[COOKIE_NAME])) { + /* the header was fine, now store the data */ + result = storecookie(co, &cookie[0], path, domain); + if(!result) + *okay = TRUE; + } return result; } diff --git a/tests/data/test1160 b/tests/data/test1160 index 9eca524c658f..d26ad4133f21 100644 --- a/tests/data/test1160 +++ b/tests/data/test1160 @@ -14,7 +14,7 @@ cookies HTTP/1.1 200 OK Date: Tue, 09 Nov 2010 14:49:00 GMT Content-Length: 0 -Set-Cookie: ____________%hex[%ff]hex%= ;%repeat[117 x %20]%%hex[%ff]hex%%repeat[2602 x %20]%%repeat[434 x z]%%hex[%86%85%85%80]hex%%repeat[49 x z]%%hex[%fa]hex%%repeat[540 x z]%%hex[%f3%a0%81%96]hex%zzzzzzzzzzzz~%repeat[82 x z]%%hex[%b6]hex%%repeat[364 x z]% +Set-Cookie: %repeat[4000 x n]%=%repeat[4096 x v]% diff --git a/tests/data/test31 b/tests/data/test31 index 8353b709fc09..e13fed55c625 100644 --- a/tests/data/test31 +++ b/tests/data/test31 @@ -18,6 +18,8 @@ Server: test-server/fake%CR Content-Length: 4%CR Content-Type: text/html%CR Funny-head: yesyes%CR +Set-Cookie: +Set-Cookie: ; Set-Cookie: blankdomain=sure; domain=; path=/ Set-Cookie: foobar=name; domain=anything.com; path=/ ; secure%CR Set-Cookie:ismatch=this ; domain=test31.curl; path=/silly/%CR @@ -25,27 +27,27 @@ Set-Cookie:ISMATCH=this ; domain=test31.curl; path=/silly/%CR Set-Cookie: overwrite=this ; domain=test31.curl; path=/overwrite/%CR Set-Cookie: overwrite=this2 ; domain=test31.curl; path=/overwrite%CR Set-Cookie: sec1value=secure1 ; domain=test31.curl; path=/secure1/ ; secure%CR -Set-Cookie: sec2value=secure2 ; domain=test31.curl; path=/secure2/ ; secure=%CR -Set-Cookie: sec3value=secure3 ; domain=test31.curl; path=/secure3/ ; secure=%CR -Set-Cookie: sec4value=secure4 ; secure=; domain=test31.curl; path=/secure4/ ; %CR +Set-Cookie: sec2value=secure2 ; domain=test31.curl; path=/secure2/ ; secure%CR +Set-Cookie: sec3value=secure3 ; domain=test31.curl; path=/secure3/ ; secure%CR +Set-Cookie: sec4value=secure4 ; secure; domain=test31.curl; path=/secure4/ ; %CR Set-Cookie: sec5value=secure5 ; secure; domain=test31.curl; path=/secure5/ ; %CR Set-Cookie: sec6value=secure6 ; secure ; domain=test31.curl; path=/secure6/ ; %CR Set-Cookie: sec7value=secure7 ; secure ; domain=test31.curl; path=/secure7/ ; %CR -Set-Cookie: sec8value=secure8 ; secure= ; domain=test31.curl; path=/secure8/ ; %CR -Set-Cookie: secure=very1 ; secure=; domain=test31.curl; path=/secure9/; %CR +Set-Cookie: sec8value=secure8 ; secure ; domain=test31.curl; path=/secure8/ ; %CR +Set-Cookie: secure=very1 ; secure; domain=test31.curl; path=/secure9/; %CR Set-Cookie: httpo1=value1 ; domain=test31.curl; path=/p1/; httponly%CR -Set-Cookie: httpo2=value2 ; domain=test31.curl; path=/p2/; httponly=%CR +Set-Cookie: httpo2=value2 ; domain=test31.curl; path=/p2/; httponly%CR Set-Cookie: httpo3=value3 ; httponly; domain=test31.curl; path=/p3/;%CR -Set-Cookie: httpo4=value4 ; httponly=; domain=test31.curl; path=/p4/; %CR +Set-Cookie: httpo4=value4 ; httponly; domain=test31.curl; path=/p4/; %CR Set-Cookie: httponly=myvalue1 ; domain=test31.curl; path=/p4/; httponly%CR Set-Cookie: httpandsec=myvalue2 ; domain=test31.curl; path=/p4/; httponly; secure%CR -Set-Cookie: httpandsec2=myvalue3; domain=test31.curl; path=/p4/; httponly=; secure%CR -Set-Cookie: httpandsec3=myvalue4 ; domain=test31.curl; path=/p4/; httponly; secure=%CR -Set-Cookie: httpandsec4=myvalue5 ; domain=test31.curl; path=/p4/; httponly=; secure=%CR -Set-Cookie: httpandsec5=myvalue6 ; domain=test31.curl; path=/p4/; secure; httponly=%CR -Set-Cookie: httpandsec6=myvalue7 ; domain=test31.curl; path=/p4/; secure=; httponly=%CR +Set-Cookie: httpandsec2=myvalue3; domain=test31.curl; path=/p4/; httponly; secure%CR +Set-Cookie: httpandsec3=myvalue4 ; domain=test31.curl; path=/p4/; httponly; secure%CR +Set-Cookie: httpandsec4=myvalue5 ; domain=test31.curl; path=/p4/; httponly; secure%CR +Set-Cookie: httpandsec5=myvalue6 ; domain=test31.curl; path=/p4/; secure; httponly%CR +Set-Cookie: httpandsec6=myvalue7 ; domain=test31.curl; path=/p4/; secure; httponly%CR Set-Cookie: httpandsec7=myvalue8 ; domain=test31.curl; path=/p4/; secure; httponly%CR -Set-Cookie: httpandsec8=myvalue9; domain=test31.curl; path=/p4/; secure=; httponly%CR +Set-Cookie: httpandsec8=myvalue9; domain=test31.curl; path=/p4/; secure; httponly%CR Set-Cookie: partmatch=present; domain=test31.curl ; path=/;%CR Set-Cookie:eat=this; domain=moo.foo.moo;%CR Set-Cookie: eat=this-too; domain=.foo.moo;%CR @@ -67,7 +69,7 @@ Set-Cookie: partialip=nono; domain=.0.0.1;%CR Set-Cookie: withspaces= yes within and around ;%CR Set-Cookie: withspaces2 =before equals;%CR Set-Cookie: prespace= yes before;%CR -Set-Cookie: securewithspace=after ; secure =%CR +Set-Cookie: securewithspace=after ; secure %CR Set-Cookie: %hex[%c3%82%c2%b3%c3%83%5c%78%39%32%c3%83%5c%78%39%61%c3%83%5c%78%38%64%c3%83%5c%78%39%37]hex%=%96%A6g%9Ay%B0%A5g%A7tm%7C%95%9A %CR boo From 121c54016869622729131fe36d111f52cb1fac89 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Sun, 7 Dec 2025 20:03:38 +0100 Subject: [PATCH 222/415] sspi: fix memory leaks on error paths in `Curl_create_sspi_identity()` Detected by Windows torture test 1072 (with `-shallow=20/13`), test 579 (with `-shallow=18/14/13`), and test 1286 (with `-shallow=15`). ``` ** MEMORY FAILURE Leak detected: memory still allocated: 20 bytes At 1a1e8136328, there is 18 bytes. allocated by D:/a/curl/curl/lib/curl_sspi.c:133 At 1a1e8139368, there is 2 bytes. allocated by D:/a/curl/curl/lib/curl_sspi.c:143 1072: torture FAILED: function number 207 in test. invoke with "-t207" to repeat this single case. Warning: http2 server unexpectedly alive ``` Ref: https://github.com/curl/curl/actions/runs/20008523913/job/57374427439?pr=19865 Also simplify the code a little. Cherry-picked from #19865 Closes #19866 --- lib/curl_sspi.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/lib/curl_sspi.c b/lib/curl_sspi.c index 712fab2e9e82..35a9bc33e6cc 100644 --- a/lib/curl_sspi.c +++ b/lib/curl_sspi.c @@ -135,33 +135,34 @@ CURLcode Curl_create_sspi_identity(const char *userp, const char *passwdp, curlx_free(useranddomain.tchar_ptr); return CURLE_OUT_OF_MEMORY; } - identity->User = dup_user.tbyte_ptr; - identity->UserLength = curlx_uztoul(_tcslen(dup_user.tchar_ptr)); - dup_user.tchar_ptr = NULL; /* Setup the identity's domain and length */ dup_domain.tchar_ptr = curlx_malloc(sizeof(TCHAR) * (domlen + 1)); if(!dup_domain.tchar_ptr) { + curlx_free(dup_user.tchar_ptr); curlx_free(useranddomain.tchar_ptr); return CURLE_OUT_OF_MEMORY; } if(_tcsncpy_s(dup_domain.tchar_ptr, domlen + 1, domain.tchar_ptr, domlen)) { + curlx_free(dup_user.tchar_ptr); curlx_free(dup_domain.tchar_ptr); curlx_free(useranddomain.tchar_ptr); return CURLE_OUT_OF_MEMORY; } - identity->Domain = dup_domain.tbyte_ptr; - identity->DomainLength = curlx_uztoul(domlen); - dup_domain.tchar_ptr = NULL; curlx_free(useranddomain.tchar_ptr); /* Setup the identity's password and length */ passwd.tchar_ptr = curlx_convert_UTF8_to_tchar(passwdp); - if(!passwd.tchar_ptr) + if(!passwd.tchar_ptr) { + curlx_free(dup_user.tchar_ptr); + curlx_free(dup_domain.tchar_ptr); return CURLE_OUT_OF_MEMORY; + } dup_passwd.tchar_ptr = curlx_tcsdup(passwd.tchar_ptr); if(!dup_passwd.tchar_ptr) { + curlx_free(dup_user.tchar_ptr); + curlx_free(dup_domain.tchar_ptr); curlx_free(passwd.tchar_ptr); return CURLE_OUT_OF_MEMORY; } @@ -171,6 +172,13 @@ CURLcode Curl_create_sspi_identity(const char *userp, const char *passwdp, curlx_free(passwd.tchar_ptr); + identity->User = dup_user.tbyte_ptr; + identity->UserLength = curlx_uztoul(_tcslen(dup_user.tchar_ptr)); + dup_user.tchar_ptr = NULL; + identity->Domain = dup_domain.tbyte_ptr; + identity->DomainLength = curlx_uztoul(domlen); + dup_domain.tchar_ptr = NULL; + /* Setup the identity's flags */ identity->Flags = (unsigned long) #ifdef UNICODE From 2535c4298fede065c80b9255328c18b68d739522 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 8 Dec 2025 10:20:04 +0100 Subject: [PATCH 223/415] hostcheck: fail wildcard match if host starts with a dot A hostname cannot start with a dot when DNS is used, but there are other ways. Amend unit test 1397 Closes #19869 --- lib/vtls/hostcheck.c | 4 ++-- tests/unit/unit1397.c | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/vtls/hostcheck.c b/lib/vtls/hostcheck.c index fbd460bc15b1..e56860a35ba9 100644 --- a/lib/vtls/hostcheck.c +++ b/lib/vtls/hostcheck.c @@ -92,8 +92,8 @@ static bool hostmatch(const char *hostname, if(strncmp(pattern, "*.", 2)) return pmatch(hostname, hostlen, pattern, patternlen); - /* detect IP address as hostname and fail the match if so */ - else if(Curl_host_is_ipnum(hostname)) + /* detect host as IP address or starting with a dot and fail if so */ + else if(Curl_host_is_ipnum(hostname) || (hostname[0] == '.')) return FALSE; /* We require at least 2 dots in the pattern to avoid too wide wildcard diff --git a/tests/unit/unit1397.c b/tests/unit/unit1397.c index 6726c5053064..dc4f13583790 100644 --- a/tests/unit/unit1397.c +++ b/tests/unit/unit1397.c @@ -39,6 +39,8 @@ static CURLcode test_unit1397(const char *arg) }; static const struct testcase tests[] = { + {".hello.com", "*.hello.com", FALSE }, + {"a.hello.com", "*.hello.com", TRUE }, { "", "", FALSE }, { "a", "", FALSE }, { "", "b", FALSE }, From d360ddb1b2e5cc350307f7829ffccdcae062d319 Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Sun, 7 Dec 2025 15:23:00 +0100 Subject: [PATCH 224/415] test1475: consistently use %CR in headers Gets the test working when using Privoxy as proxy. Closes #19870 --- tests/data/test1475 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/data/test1475 b/tests/data/test1475 index 1f11829d72e4..b35009d9a8f7 100644 --- a/tests/data/test1475 +++ b/tests/data/test1475 @@ -15,7 +15,7 @@ Resume HTTP/1.1 416 Invalid range%CR Connection: close%CR Content-Length: 0%CR -Content-Range: */100 +Content-Range: */100%CR %CR @@ -35,7 +35,7 @@ Content-Range: */100 HTTP/1.1 416 Invalid range%CR Connection: close%CR Content-Length: 0%CR -Content-Range: */100 +Content-Range: */100%CR %CR From 96ba7a79fc561ef8e7bedafacb70d9659224ee1f Mon Sep 17 00:00:00 2001 From: Stefan Eissing Date: Fri, 5 Dec 2025 15:38:12 +0100 Subject: [PATCH 225/415] gnutls: add PROFILE_MEDIUM as default Raise the default GnuTLS priority settings by adding PROFILE_MEDIUM for more secure connection handling. Reported-by: Harry Sintonen Closes #19853 --- lib/vtls/gtls.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/vtls/gtls.c b/lib/vtls/gtls.c index 667b09c119fa..c7f8f346739a 100644 --- a/lib/vtls/gtls.c +++ b/lib/vtls/gtls.c @@ -305,16 +305,17 @@ static gnutls_x509_crt_fmt_t gnutls_do_file_type(const char *type) return GNUTLS_X509_FMT_PEM; /* default to PEM */ } -#define GNUTLS_CIPHERS "NORMAL:-ARCFOUR-128:-CTYPE-ALL:+CTYPE-X509" +#define GNUTLS_CIPHERS "NORMAL:%PROFILE_MEDIUM:-ARCFOUR-128:"\ + "-CTYPE-ALL:+CTYPE-X509" /* If GnuTLS was compiled without support for SRP it will error out if SRP is requested in the priority string, so treat it specially */ #define GNUTLS_SRP "+SRP" #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:" \ + "NORMAL:%PROFILE_MEDIUM:-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:" \ "%DISABLE_TLS13_COMPAT_MODE" static CURLcode From 4a92afce703541732489b67d9600ab1d78d2a0f7 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 8 Dec 2025 11:43:12 +0100 Subject: [PATCH 226/415] DISTROS: fix a Mageia URL Since we check the provided URLs now, use the direct, working URL. --- docs/DISTROS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/DISTROS.md b/docs/DISTROS.md index 451de7fc1a84..7f61e2aa3f5b 100644 --- a/docs/DISTROS.md +++ b/docs/DISTROS.md @@ -165,7 +165,7 @@ unless it is specific to Homebrew's way of packaging software. - curl: https://svnweb.mageia.org/packages/cauldron/curl/current/SPECS/curl.spec?view=markup - curl issues: https://bugs.mageia.org/buglist.cgi?bug_status=NEW&bug_status=UNCONFIRMED&bug_status=NEEDINFO&bug_status=UPSTREAM&bug_status=ASSIGNED&component=RPM%20Packages&f1=cf_rpmpkg&list_id=176576&o1=casesubstring&product=Mageia&query_format=advanced&v1=curl - curl patches: https://svnweb.mageia.org/packages/cauldron/curl/current/SOURCES/ -- curl patches in stable distro releases: https://svnweb.mageia.org/packages/updates//curl/current/SOURCES/ +- curl patches in stable distro releases: https://svnweb.mageia.org/packages/updates/9/curl/current/SOURCES/ - curl security: https://advisories.mageia.org/src_curl.html ## MSYS2 From 81e5e2434e03cf32c843650a9e08f193419e2f3d Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Mon, 8 Dec 2025 11:06:49 +0100 Subject: [PATCH 227/415] GHA/linux: blind try to make Renovate detect Fil-C releases 0.675 has been out for 2 weeks, Renovate did not detect it with `semver-partial`. Try with `semver-coerced`. Refs: https://docs.renovatebot.com/modules/versioning/semver-coerced/ https://docs.renovatebot.com/modules/versioning/semver-partial/ Follow-up to 16c6ea36cca6684aacbcb33578af61b28e3fee0d #19391 --- .github/workflows/linux.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 390cab72923f..7eb54125ff87 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -57,7 +57,7 @@ env: OPENLDAP_VERSION: 2.6.10 # renovate: datasource=github-tags depName=nghttp2/nghttp2 versioning=semver registryUrl=https://github.com NGHTTP2_VERSION: 1.68.0 - # renovate: datasource=github-tags depName=pizlonator/fil-c versioning=semver-partial registryUrl=https://github.com + # renovate: datasource=github-tags depName=pizlonator/fil-c versioning=semver-coerced registryUrl=https://github.com FIL_C_VERSION: 0.674 jobs: From c56ee2ab784d2031e125ba6dc7bcdef3aec9b3d6 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 8 Dec 2025 11:07:26 +0000 Subject: [PATCH 228/415] GHA/linux: update dependency pizlonator/fil-c to v0.675 Closes #19873 --- .github/workflows/linux.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 7eb54125ff87..27ad6b739331 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -58,7 +58,7 @@ env: # renovate: datasource=github-tags depName=nghttp2/nghttp2 versioning=semver registryUrl=https://github.com NGHTTP2_VERSION: 1.68.0 # renovate: datasource=github-tags depName=pizlonator/fil-c versioning=semver-coerced registryUrl=https://github.com - FIL_C_VERSION: 0.674 + FIL_C_VERSION: 0.675 jobs: linux: From a1c01b2015cb0082ec9ad2235953e46690410309 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 8 Dec 2025 11:16:18 +0100 Subject: [PATCH 229/415] mdlinkcheck: ignore IP numbers, allow '@' in raw URLs --- scripts/mdlinkcheck | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/mdlinkcheck b/scripts/mdlinkcheck index 734617949d2d..dfeeac0f60e6 100755 --- a/scripts/mdlinkcheck +++ b/scripts/mdlinkcheck @@ -120,6 +120,9 @@ sub storelink { elsif($link =~ /^https:\/\/github.com\/curl\/curl(\/|$)/) { #print "-- curl github repo: $link\n"; } + elsif($link =~ /^(https|http):\/\/[0-9.]+(\/|$)/) { + #print "-- IPv4 number: $link\n"; + } else { #print "ADD '$link'\n"; $url{$link} .= "$f:$line "; @@ -160,7 +163,7 @@ sub findlinks { # ignore trailing: dot, quote, asterisk, hash, comma, question mark, # colon, closing parenthesis, closing angle bracket, whitespace, pipe, # backtick, semicolon - elsif(/(https:\/\/[a-z0-9.\/:%_-]+[^."*\#,?:\)> \t|`;])/i) { + elsif(/(https:\/\/[a-z0-9.\/:%_+@-]+[^."*\#,?:\)> \t|`;])/i) { #print "RAW "; storelink($f, $line, $1); } From ab9beda1b3e5fc9c163111ff93ff17b73217a74c Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 8 Dec 2025 11:11:02 +0100 Subject: [PATCH 230/415] docs: switch more URLs to https:// Normalize using https:// almost everywhere instead of http:// Closes #19872 --- .github/scripts/codespell-ignore.words | 2 +- .github/scripts/typos.toml | 2 +- docs/FAQ | 16 ++--- docs/MANUAL.md | 64 +++++++++---------- docs/TheArtOfHttpScripting.md | 54 ++++++++-------- docs/URL-SYNTAX.md | 10 +-- docs/cmdline-opts/_ENVIRONMENT.md | 4 +- docs/cmdline-opts/_GLOBBING.md | 10 +-- docs/libcurl/libcurl-security.md | 22 +++---- docs/libcurl/libcurl-tutorial.md | 4 +- docs/libcurl/opts/CURLINFO_PROXYAUTH_USED.md | 2 +- docs/libcurl/opts/CURLOPT_NOPROXY.md | 2 +- docs/libcurl/opts/CURLOPT_PROXY.md | 2 +- .../opts/CURLOPT_SUPPRESS_CONNECT_HEADERS.md | 2 +- 14 files changed, 99 insertions(+), 97 deletions(-) diff --git a/.github/scripts/codespell-ignore.words b/.github/scripts/codespell-ignore.words index fa8a432b95aa..1a5e106400a6 100644 --- a/.github/scripts/codespell-ignore.words +++ b/.github/scripts/codespell-ignore.words @@ -7,7 +7,7 @@ bu clen CNA hel -htpt +htpts inout PASE passwor diff --git a/.github/scripts/typos.toml b/.github/scripts/typos.toml index ec6b9bb05015..2b12004f489d 100644 --- a/.github/scripts/typos.toml +++ b/.github/scripts/typos.toml @@ -6,7 +6,7 @@ extend-ignore-identifiers-re = [ "^(ba|fo|pn|PN|UE)$", "^(CNA|ser)$", - "^(ECT0|ECT1|HELO|htpt|PASE)$", + "^(ECT0|ECT1|HELO|htpts|PASE)$", "^[A-Za-z0-9_-]*(EDE|GOST)[A-Z0-9_-]*$", # ciphers "^0x[0-9a-fA-F]+FUL$", # unsigned long hex literals ending with 'F' "^(eyeballers|HELO_smtp|Januar|optin|passin|perfec|SMTP_HELO)$", diff --git a/docs/FAQ b/docs/FAQ index b8a39474590f..230b850bac80 100644 --- a/docs/FAQ +++ b/docs/FAQ @@ -533,7 +533,7 @@ FAQ that informs the client about this is only interpreted if you are using the -L/--location option. As in: - curl -L http://example.com + curl -L https://example.com Not all redirects are HTTP ones, see 4.14 @@ -719,13 +719,13 @@ FAQ Set a custom Host: header that identifies the server name you want to reach but use the target IP address in the URL: - curl --header "Host: www.example.com" http://127.0.0.1/ + curl --header "Host: www.example.com" https://somewhere.example/ You can also opt to add faked hostname entries to curl with the --resolve option. That has the added benefit that things like redirects will also work properly. The above operation would instead be done as: - curl --resolve www.example.com:80:127.0.0.1 http://www.example.com/ + curl --resolve www.example.com:80:127.0.0.1 https://www.example.com/ 3.20 How to SFTP from my user's home directory? @@ -753,8 +753,8 @@ FAQ be disabled or not supported. Note that this error will also occur if you pass a wrongly spelled protocol - part as in "htpt://example.com" or as in the less evident case if you prefix - the protocol part with a space as in " http://example.com/". + part as in "htpts://example.com" or as in the less evident case if you + prefix the protocol part with a space as in " https://example.com/". 3.22 curl -X gives me HTTP problems @@ -762,7 +762,7 @@ FAQ By default you use curl without explicitly saying which request method to use when the URL identifies an HTTP transfer. If you just pass in a URL like - "curl http://example.com" it will use GET. If you use -d or -F curl will use + "curl https://example.com" it will use GET. If you use -d or -F curl will use POST, -I will cause a HEAD and -T will make it a PUT. If for whatever reason you are not happy with these default choices that curl @@ -796,7 +796,7 @@ FAQ An example that would invoke a remote CGI that uses &-symbols could be: - curl 'http://www.example.com/cgi-bin/query?text=yes&q=curl' + curl 'https://www.example.com/cgi-bin/query?text=yes&q=curl' In Windows, the standard DOS shell treats the percent sign specially and you need to use TWO percent signs for each single one you want to use in the @@ -865,7 +865,7 @@ FAQ If you get this return code and an HTML output similar to this:

Moved Permanently

The document has moved here. + HREF="https://same_url_now_with_a_trailing_slash.example/">here. it might be because you requested a directory URL but without the trailing slash. Try the same operation again _with_ the trailing URL, or use the diff --git a/docs/MANUAL.md b/docs/MANUAL.md index 9ff5c097c7f7..1acb4d2244e2 100644 --- a/docs/MANUAL.md +++ b/docs/MANUAL.md @@ -34,7 +34,7 @@ Get the definition of curl from a dictionary: Fetch two documents at once: - curl ftp://ftp.example.com/ http://www.example.com:8000/ + curl ftp://ftp.example.com/ https://www.example.com:8000/ Get a file off an FTPS server: @@ -71,12 +71,12 @@ Get a file from an SMB server: Get a webpage and store in a local file with a specific name: - curl -o thatpage.html http://www.example.com/ + curl -o thatpage.html https://www.example.com/ Get a webpage and store in a local file, make the local file get the name of the remote document (if no filename part is specified in the URL, this fails): - curl -O http://www.example.com/index.html + curl -O https://www.example.com/index.html Fetch two files and store them with their remote names: @@ -115,14 +115,14 @@ matching public key file must be specified using the `--pubkey` option. ### HTTP -curl also supports user and password in HTTP URLs, thus you can pick a file +curl also supports user and password in HTTP(S) URLs. You can download a file like: - curl http://name:passwd@http.server.example/full/path/to/file + curl https://name:passwd@http.server.example/full/path/to/file or specify user and password separately like in - curl -u name:passwd http://http.server.example/full/path/to/file + curl -u name:passwd https://http.server.example/full/path/to/file HTTP offers many different methods of authentication and curl supports several: Basic, Digest, NTLM and Negotiate (SPNEGO). Without telling which @@ -151,19 +151,19 @@ Get an ftp file using an HTTP proxy named my-proxy that uses port 888: curl -x my-proxy:888 ftp://ftp.example.com/README -Get a file from an HTTP server that requires user and password, using the +Get a file from an HTTPS server that requires user and password, using the same proxy as above: - curl -u user:passwd -x my-proxy:888 http://www.example.com/ + curl -u user:passwd -x my-proxy:888 https://www.example.com/ Some proxies require special authentication. Specify by using -U as above: - curl -U user:passwd -x my-proxy:888 http://www.example.com/ + curl -U user:passwd -x my-proxy:888 https://www.example.com/ A comma-separated list of hosts and domains which do not use the proxy can be specified as: - curl --noproxy example.com -x my-proxy:888 http://www.example.com/ + curl --noproxy example.com -x my-proxy:888 https://www.example.com/ If the proxy is specified with `--proxy1.0` instead of `--proxy` or `-x`, then curl uses HTTP/1.0 instead of HTTP/1.1 for any `CONNECT` attempts. @@ -204,11 +204,11 @@ one or more sub-parts of a specified document. curl supports this with the Get the first 100 bytes of a document: - curl -r 0-99 http://www.example.com/ + curl -r 0-99 https://www.example.com/ Get the last 500 bytes of a document: - curl -r -500 http://www.example.com/ + curl -r -500 https://www.example.com/ curl also supports simple ranges for FTP files as well. Then you can only specify start and stop position. @@ -251,9 +251,9 @@ fashion similar to: ### HTTP -Upload all data on stdin to a specified HTTP site: +Upload all data on stdin to a specified HTTPS site: - curl -T - http://www.example.com/myfile + curl -T - https://www.example.com/myfile Note that the HTTP server must have been configured to accept PUT before this can be done successfully. @@ -305,12 +305,12 @@ The post data must be urlencoded. Post a simple `name` and `phone` guestbook. - curl -d "name=Rafael%20Sagula&phone=3320780" http://www.example.com/guest.cgi + curl -d "name=Rafael%20Sagula&phone=3320780" https://www.example.com/guest.cgi Or automatically [URL encode the data](https://everything.curl.dev/http/post/url-encode). curl --data-urlencode "name=Rafael Sagula&phone=3320780" - http://www.example.com/guest.cgi + https://www.example.com/guest.cgi How to post a form with curl, lesson #1: @@ -329,7 +329,7 @@ of the letter's ASCII code. Example: -(say if `http://example.com` had the following html) +(say if `https://example.com` had the following html) ```html
@@ -345,7 +345,7 @@ We want to enter user `foobar` with password `12345`. To post to this, you would enter a curl command line like: curl -d "user=foobar&pass=12345&id=blablabla&ding=submit" - http://example.com/post.cgi + https://example.com/post.cgi While `-d` uses the application/x-www-form-urlencoded mime-type, generally understood by CGI's and similar, curl also supports the more capable @@ -359,7 +359,7 @@ example, the field name `coolfiles` is used to send three files, with different content types using the following syntax: curl -F "coolfiles=@fil1.gif;type=image/gif,fil2.txt,fil3.html" - http://www.example.com/postit.cgi + https://www.example.com/postit.cgi If the content-type is not specified, curl tries to guess from the file extension (it only knows a few), or use the previously specified type (from an @@ -376,7 +376,7 @@ the names of the input fields. In our example, the input field names are curl -F "file=@cooltext.txt" -F "yourname=Daniel" -F "filedescription=Cool text file with cool text inside" - http://www.example.com/postit.cgi + https://www.example.com/postit.cgi To send two files in one post you can do it in two ways: @@ -402,7 +402,7 @@ used on the command line. It is especially useful to fool or trick stupid servers or CGI scripts that rely on that information being available or contain certain data. - curl -e www.example.org http://www.example.com/ + curl -e www.example.org https://www.example.com/ ## User Agent @@ -413,7 +413,7 @@ accept certain browsers. Example: - curl -A 'Mozilla/3.0 (Win95; I)' http://www.bank.example.com/ + curl -A 'Mozilla/3.0 (Win95; I)' https://www.bank.example.com/ Other common strings: @@ -596,14 +596,14 @@ Force curl to get and display a local help page in case it is invoked without URL by making a config file similar to: # default url to get - url = "http://help.with.curl.example.com/curlhelp.html" + url = "https://help.with.curl.example.com/curlhelp.html" You can specify another config file to be read by using the `-K`/`--config` flag. If you set config filename to `-` it reads the config from stdin, which can be handy if you want to hide options from being visible in process tables etc: - echo "user = user:passwd" | curl -K - http://that.secret.example.com + echo "user = user:passwd" | curl -K - https://that.secret.example.com ## Extra Headers @@ -685,11 +685,11 @@ Download with `PORT` but use 192.168.0.10 as our IP address to use: Get a webpage from a server using a specified port for the interface: - curl --interface eth0:1 http://www.example.com/ + curl --interface eth0:1 https://www.example.com/ or - curl --interface 192.168.1.10 http://www.example.com/ + curl --interface 192.168.1.10 https://www.example.com/ ## HTTPS @@ -740,7 +740,7 @@ Continue uploading a document: Continue downloading a document from a web server - curl -C - -o file http://www.example.com/ + curl -C - -o file https://www.example.com/ ## Time Conditions @@ -751,17 +751,17 @@ them with the `-z`/`--time-cond` flag. For example, you can easily make a download that only gets performed if the remote file is newer than a local copy. It would be made like: - curl -z local.html http://remote.example.com/remote.html + curl -z local.html https://remote.example.com/remote.html Or you can download a file only if the local file is newer than the remote one. Do this by prepending the date string with a `-`, as in: - curl -z -local.html http://remote.example.com/remote.html + curl -z -local.html https://remote.example.com/remote.html You can specify a plain text date as condition. Tell curl to only download the file if it was updated since January 12, 2012: - curl -z "Jan 12 2012" http://remote.example.com/remote.html + curl -z "Jan 12 2012" https://remote.example.com/remote.html curl accepts a wide range of date formats. You always make the date check the other way around by prepending it with a dash (`-`). @@ -944,7 +944,7 @@ URL you specify. Note that this also goes for the `-O` option (but not For example: get two files and use `-O` for the first and a custom file name for the second: - curl -O http://example.com/file.txt ftp://example.com/moo.exe -o moo.jpg + curl -O https://example.com/file.txt ftp://example.com/moo.exe -o moo.jpg You can also upload multiple files in a similar fashion: @@ -957,7 +957,7 @@ and fall back to IPv4 if the connection fails. The `--ipv4` and `--ipv6` options can specify which address to use when both are available. IPv6 addresses can also be specified directly in URLs using the syntax: - http://[2001:1890:1112:1::20]/overview.html + https://[2001:1890:1112:1::20]/overview.html When this style is used, the `-g` option must be given to stop curl from interpreting the square brackets as special globbing characters. Link local diff --git a/docs/TheArtOfHttpScripting.md b/docs/TheArtOfHttpScripting.md index 46369d6eafb0..f7cf43602d90 100644 --- a/docs/TheArtOfHttpScripting.md +++ b/docs/TheArtOfHttpScripting.md @@ -57,7 +57,7 @@ SPDX-License-Identifier: curl offer even more details as they show **everything** curl sends and receives. Use it like this: - curl --trace-ascii debugdump.txt http://www.example.com/ + curl --trace-ascii debugdump.txt https://www.example.com/ ## See the Timing @@ -67,7 +67,7 @@ SPDX-License-Identifier: curl [`--trace-time`](https://curl.se/docs/manpage.html#--trace-time) option is what you need. It prepends the time to each trace output line: - curl --trace-ascii d.txt --trace-time http://example.com/ + curl --trace-ascii d.txt --trace-time https://example.com/ ## See which Transfer @@ -78,7 +78,7 @@ SPDX-License-Identifier: curl you need. It prepends the transfer and connection identifier to each trace output line: - curl --trace-ascii d.txt --trace-ids http://example.com/ + curl --trace-ascii d.txt --trace-ids https://example.com/ ## See the Response @@ -104,7 +104,7 @@ SPDX-License-Identifier: curl IP address for a hostname than what would otherwise be used, by using curl's [`--resolve`](https://curl.se/docs/manpage.html#--resolve) option: - curl --resolve www.example.org:80:127.0.0.1 http://www.example.org/ + curl --resolve www.example.org:80:127.0.0.1 https://www.example.org/ ## Port number @@ -115,14 +115,14 @@ SPDX-License-Identifier: curl number immediately following the hostname. Like when doing HTTP to port 1234: - curl http://www.example.org:1234/ + curl https://www.example.org:1234/ The port number you specify in the URL is the number that the server uses to offer its services. Sometimes you may use a proxy, and then you may need to specify that proxy's port number separately from what curl needs to connect to the server. Like when using an HTTP proxy on port 4321: - curl --proxy http://proxy.example.org:4321 http://remote.example.org/ + curl --proxy http://proxy.example.org:4321 https://remote.example.org/ ## Username and password @@ -133,11 +133,11 @@ SPDX-License-Identifier: curl You can opt to either insert the user and password in the URL or you can provide them separately: - curl http://user:password@example.org/ + curl https://user:password@example.org/ or - curl -u user:password http://example.org/ + curl -u user:password https://example.org/ You need to pay attention that this kind of HTTP authentication is not what is usually done and requested by user-oriented websites these days. They tend @@ -188,7 +188,7 @@ SPDX-License-Identifier: curl Example, send two GET requests: - curl http://url1.example.com http://url2.example.com + curl https://url1.example.com https://url2.example.com If you use [`--data`](https://curl.se/docs/manpage.html#-d) to POST to the URL, using multiple URLs means that you send that same POST to all the @@ -196,7 +196,7 @@ SPDX-License-Identifier: curl Example, send two POSTs: - curl --data name=curl http://url1.example.com http://url2.example.com + curl --data name=curl https://url1.example.com https://url2.example.com ## Multiple HTTP methods in a single command line @@ -214,11 +214,11 @@ SPDX-License-Identifier: curl Perhaps this is best shown with a few examples. To send first a HEAD and then a GET: - curl -I http://example.com --next http://example.com + curl -I https://example.com --next https://example.com To first send a POST and then a GET: - curl -d score=10 http://example.com/post.cgi --next http://example.com/results.html + curl -d score=10 https://example.com/post.cgi --next https://example.com/results.html # HTML forms @@ -261,7 +261,7 @@ SPDX-License-Identifier: curl To make curl do the GET form post for you, just enter the expected created URL: - curl "http://www.example.com/when/junk.cgi?birthyear=1905&press=OK" + curl "https://www.example.com/when/junk.cgi?birthyear=1905&press=OK" ## POST @@ -287,7 +287,7 @@ SPDX-License-Identifier: curl And to use curl to post this form with the same data filled in as before, we could do it like: - curl --data "birthyear=1905&press=%20OK%20" http://www.example.com/when/junk.cgi + curl --data "birthyear=1905&press=%20OK%20" https://www.example.com/when/junk.cgi This kind of POST uses the Content-Type `application/x-www-form-urlencoded` and is the most widely used POST kind. @@ -299,7 +299,7 @@ SPDX-License-Identifier: curl Recent curl versions can in fact url-encode POST data for you, like this: - curl --data-urlencode "name=I am Daniel" http://www.example.com + curl --data-urlencode "name=I am Daniel" https://www.example.com If you repeat `--data` several times on the command line, curl concatenates all the given data pieces - and put a `&` symbol between each data segment. @@ -371,7 +371,7 @@ SPDX-License-Identifier: curl Put a file to an HTTP server with curl: - curl --upload-file uploadfile http://www.example.com/receive.cgi + curl --upload-file uploadfile https://www.example.com/receive.cgi # HTTP Authentication @@ -386,7 +386,7 @@ SPDX-License-Identifier: curl To tell curl to use a user and password for authentication: - curl --user name:password http://www.example.com + curl --user name:password https://www.example.com ## Other Authentication @@ -440,7 +440,7 @@ SPDX-License-Identifier: curl Use curl to set the referer field with: - curl --referer http://www.example.come http://www.example.com + curl --referer https://www.example.come https://www.example.com ## User Agent @@ -481,7 +481,7 @@ SPDX-License-Identifier: curl To tell curl to follow a Location: - curl --location http://www.example.com + curl --location https://www.example.com If you use curl to POST to a site that immediately redirects you to another page, you can safely use [`--location`](https://curl.se/docs/manpage.html#-L) @@ -519,14 +519,14 @@ SPDX-License-Identifier: curl The simplest way to send a few cookies to the server when getting a page with curl is to add them on the command line like: - curl --cookie "name=Daniel" http://www.example.com + curl --cookie "name=Daniel" https://www.example.com Cookies are sent as common HTTP headers. This is practical as it allows curl to record cookies simply by recording headers. Record cookies with curl by using the [`--dump-header`](https://curl.se/docs/manpage.html#-D) (`-D`) option like: - curl --dump-header headers_and_cookies http://www.example.com + curl --dump-header headers_and_cookies https://www.example.com (Take note that the [`--cookie-jar`](https://curl.se/docs/manpage.html#-c) option described @@ -538,7 +538,7 @@ SPDX-License-Identifier: curl believing you had a previous connection). To use previously stored cookies, you run curl like: - curl --cookie stored_cookies_in_file http://www.example.com + curl --cookie stored_cookies_in_file https://www.example.com curl's "cookie engine" gets enabled when you use the [`--cookie`](https://curl.se/docs/manpage.html#-b) option. If you only @@ -547,7 +547,7 @@ SPDX-License-Identifier: curl page and follow a location (and thus possibly send back cookies it received), you can invoke it like: - curl --cookie nada --location http://www.example.com + curl --cookie nada --location https://www.example.com curl has the ability to read and write cookie files that use the same file format that Netscape and Mozilla once used. It is a convenient way to share @@ -557,7 +557,7 @@ SPDX-License-Identifier: curl cookie file at the end of an operation: curl --cookie cookies.txt --cookie-jar newcookies.txt \ - http://www.example.com + https://www.example.com # HTTPS @@ -620,12 +620,12 @@ SPDX-License-Identifier: curl You can delete a default header by providing one without content. Like you can ruin the request by chopping off the `Host:` header: - curl --header "Host:" http://www.example.com + curl --header "Host:" https://www.example.com You can add headers the same way. Your server may want a `Destination:` header, and you can add it: - curl --header "Destination: http://nowhere" http://example.com + curl --header "Destination: nowhere" https://example.com ## More on changed methods @@ -638,7 +638,7 @@ SPDX-License-Identifier: curl thinks it sends a POST. You can change the normal GET to a POST method by simply adding `-X POST` in a command line like: - curl -X POST http://example.org/ + curl -X POST https://example.org/ curl however still acts as if it sent a GET so it does not send any request body etc. diff --git a/docs/URL-SYNTAX.md b/docs/URL-SYNTAX.md index 6232e3f609b8..d69ab674796d 100644 --- a/docs/URL-SYNTAX.md +++ b/docs/URL-SYNTAX.md @@ -130,7 +130,7 @@ character or string. For example, this could look like: - http://user:password@www.example.com:80/index.html?foo=bar#top + https://user:password@www.example.com:80/index.html?foo=bar#top ## Scheme @@ -169,13 +169,13 @@ local network name of the machine on your network or the IP address of the server or machine represented by either an IPv4 or IPv6 address (within brackets). For example: - http://www.example.com/ + https://www.example.com/ - http://hostname/ + https://hostname.example/ - http://192.168.0.1/ + https://192.168.0.1/ - http://[2001:1890:1112:1::20]/ + https://[2001:1890:1112:1::20]/ ### "localhost" diff --git a/docs/cmdline-opts/_ENVIRONMENT.md b/docs/cmdline-opts/_ENVIRONMENT.md index 53fe5c34212f..1ac85fb12841 100644 --- a/docs/cmdline-opts/_ENVIRONMENT.md +++ b/docs/cmdline-opts/_ENVIRONMENT.md @@ -31,12 +31,12 @@ This environment variable disables use of the proxy even when specified with the --proxy option. That is NO_PROXY=direct.example.com curl -x http://proxy.example.com - http://direct.example.com + https://direct.example.com accesses the target URL directly, and NO_PROXY=direct.example.com curl -x http://proxy.example.com - http://somewhere.example.com + https://somewhere.example.com accesses the target URL through the proxy. diff --git a/docs/cmdline-opts/_GLOBBING.md b/docs/cmdline-opts/_GLOBBING.md index c3c7951acb27..37c8d430693d 100644 --- a/docs/cmdline-opts/_GLOBBING.md +++ b/docs/cmdline-opts/_GLOBBING.md @@ -6,7 +6,9 @@ or ranges within brackets. We call this "globbing". Provide a list with three different names like this: - http://site.{one,two,three}.com + https://fun.example/{one,two,three}.jpg + + sftp://{one,two,three}.example/README Do sequences of alphanumeric series by using [] as in: @@ -23,14 +25,14 @@ With letters through the alphabet: Nested sequences are not supported, but you can use several ones next to each other: - http://example.com/archive[1996-1999]/vol[1-4]/part{a,b,c}.html + https://example.com/archive[1996-1999]/vol[1-4]/part{a,b,c}.html You can specify a step counter for the ranges to get every Nth number or letter: - http://example.com/file[1-100:10].txt + https://example.com/file[1-100:10].txt - http://example.com/file[a-z:2].txt + https://example.com/file[a-z:2].txt When using [] or {} sequences when invoked from a command line prompt, you probably have to put the full URL within double quotes to avoid the shell from diff --git a/docs/libcurl/libcurl-security.md b/docs/libcurl/libcurl-security.md index 7fbd32974d2c..62dc12e97e35 100644 --- a/docs/libcurl/libcurl-security.md +++ b/docs/libcurl/libcurl-security.md @@ -144,9 +144,10 @@ The CURLOPT_REDIR_PROTOCOLS_STR(3) and CURLOPT_NETRC(3) options can be used to mitigate against this kind of attack. A redirect can also specify a location available only on the machine running -libcurl, including servers hidden behind a firewall from the attacker. -E.g. **http://127.0.0.1/** or **http://intranet/delete-stuff.cgi?delete=all** or -**tftp://bootp-server/pc-config-data** +libcurl, including servers hidden behind a firewall from the attacker. E.g. +**https://127.0.0.1/** or +**https://intranet.example/delete-stuff.cgi?delete=all** or +**tftp://bootp-server.example/pc-config-data** Applications can mitigate against this by disabling CURLOPT_FOLLOWLOCATION(3) and handling redirects itself, sanitizing URLs @@ -172,11 +173,10 @@ way you did not intend such as injecting new headers. A user who can control the DNS server of a domain being passed in within a URL can change the address of the host to a local, private address which a server-side libcurl-using application could then use. E.g. the innocuous URL -**http://fuzzybunnies.example.com/** could actually resolve to the IP -address of a server behind a firewall, such as 127.0.0.1 or -10.1.2.3. Applications can mitigate against this by setting a -CURLOPT_OPENSOCKETFUNCTION(3) or CURLOPT_PREREQFUNCTION(3) and -checking the address before a connection. +**https://fuzzybunnies.example.com/** could actually resolve to the IP address +of a server behind a firewall, such as 127.0.0.1 or 10.1.2.3. Applications can +mitigate against this by setting a CURLOPT_OPENSOCKETFUNCTION(3) or +CURLOPT_PREREQFUNCTION(3) and checking the address before a connection. All the malicious scenarios regarding redirected URLs apply just as well to non-redirected URLs, if the user is allowed to specify an arbitrary URL that @@ -254,7 +254,7 @@ the request. If cookies are enabled and cached, then a user could craft a URL which performs some malicious action to a site whose authentication is already stored in a cookie. E.g. -**http://mail.example.com/delete-stuff.cgi?delete=all** Applications can +**https://mail.example.com/delete-stuff.cgi?delete=all** Applications can mitigate against this by disabling cookies or clearing them between requests. # Dangerous SCP URLs @@ -315,8 +315,8 @@ if creative use of special characters are applied? If the user can set the URL, the user can also specify the scheme part to other protocols that you did not intend for users to use and perhaps did not -consider. curl supports over 20 different URL schemes. "http://" might be what -you thought, "ftp://" or "imap://" might be what the user gives your +consider. curl supports over 27 different URL schemes. `https://` might be +what you expect, `ftp://` or `imap://` might be what the user gives your application. Also, cross-protocol operations might be done by using a particular scheme in the URL but point to a server doing a different protocol on a non-standard port. diff --git a/docs/libcurl/libcurl-tutorial.md b/docs/libcurl/libcurl-tutorial.md index 7b01d234c4c9..a5bebc665598 100644 --- a/docs/libcurl/libcurl-tutorial.md +++ b/docs/libcurl/libcurl-tutorial.md @@ -194,7 +194,7 @@ One of the most basic properties to set in the handle is the URL. You set your preferred URL to transfer with CURLOPT_URL(3) in a manner similar to: ~~~c - curl_easy_setopt(handle, CURLOPT_URL, "http://example.com/"); + curl_easy_setopt(handle, CURLOPT_URL, "https://example.com/"); ~~~ Let's assume for a while that you want to receive data as the URL identifies a @@ -470,7 +470,7 @@ libcurl to post it all to the remote site: ~~~c char *data = "name=daniel&project=curl"; curl_easy_setopt(handle, CURLOPT_POSTFIELDS, data); - curl_easy_setopt(handle, CURLOPT_URL, "http://posthere.com/"); + curl_easy_setopt(handle, CURLOPT_URL, "https://posthere.example/"); curl_easy_perform(handle); /* post away! */ ~~~ diff --git a/docs/libcurl/opts/CURLINFO_PROXYAUTH_USED.md b/docs/libcurl/opts/CURLINFO_PROXYAUTH_USED.md index 92316f1a3eb8..eace7222d11a 100644 --- a/docs/libcurl/opts/CURLINFO_PROXYAUTH_USED.md +++ b/docs/libcurl/opts/CURLINFO_PROXYAUTH_USED.md @@ -45,7 +45,7 @@ int main(void) if(curl) { CURLcode res; curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); - curl_easy_setopt(curl, CURLOPT_PROXY, "http://proxy.example.com"); + curl_easy_setopt(curl, CURLOPT_PROXY, "http://proxy.example"); curl_easy_setopt(curl, CURLOPT_PROXYAUTH, CURLAUTH_BASIC | CURLAUTH_DIGEST); curl_easy_setopt(curl, CURLOPT_PROXYUSERNAME, "shrek"); diff --git a/docs/libcurl/opts/CURLOPT_NOPROXY.md b/docs/libcurl/opts/CURLOPT_NOPROXY.md index 117cf09be887..40f3d4cc6547 100644 --- a/docs/libcurl/opts/CURLOPT_NOPROXY.md +++ b/docs/libcurl/opts/CURLOPT_NOPROXY.md @@ -76,7 +76,7 @@ int main(void) /* accept various URLs */ curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/"); /* use this proxy */ - curl_easy_setopt(curl, CURLOPT_PROXY, "http://proxy:80"); + curl_easy_setopt(curl, CURLOPT_PROXY, "http://proxy.example:80"); /* ... but make sure this host name is not proxied */ curl_easy_setopt(curl, CURLOPT_NOPROXY, "www.example.com"); curl_easy_perform(curl); diff --git a/docs/libcurl/opts/CURLOPT_PROXY.md b/docs/libcurl/opts/CURLOPT_PROXY.md index fca07f23f6f9..2d9d456dba9f 100644 --- a/docs/libcurl/opts/CURLOPT_PROXY.md +++ b/docs/libcurl/opts/CURLOPT_PROXY.md @@ -138,7 +138,7 @@ int main(void) CURL *curl = curl_easy_init(); if(curl) { curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/file.txt"); - curl_easy_setopt(curl, CURLOPT_PROXY, "http://proxy:80"); + curl_easy_setopt(curl, CURLOPT_PROXY, "http://proxy.example:80"); curl_easy_perform(curl); } } diff --git a/docs/libcurl/opts/CURLOPT_SUPPRESS_CONNECT_HEADERS.md b/docs/libcurl/opts/CURLOPT_SUPPRESS_CONNECT_HEADERS.md index b05824630bb7..e86be358edf6 100644 --- a/docs/libcurl/opts/CURLOPT_SUPPRESS_CONNECT_HEADERS.md +++ b/docs/libcurl/opts/CURLOPT_SUPPRESS_CONNECT_HEADERS.md @@ -83,7 +83,7 @@ int main(void) curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); curl_easy_setopt(curl, CURLOPT_HEADER, 1L); - curl_easy_setopt(curl, CURLOPT_PROXY, "http://foo:3128"); + curl_easy_setopt(curl, CURLOPT_PROXY, "http://proxy.example:3128"); curl_easy_setopt(curl, CURLOPT_HTTPPROXYTUNNEL, 1L); curl_easy_setopt(curl, CURLOPT_SUPPRESS_CONNECT_HEADERS, 1L); From 7dd5bb77c397e7b7a7f323224c34488f1130399a Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Sun, 7 Dec 2025 17:36:54 +0100 Subject: [PATCH 231/415] CI/windows: add torture tests with Schannel With Schannel and Unicode, `-shallow=13`. It finishes in 12 minutes, making it the slowest Windows job. It's still on par with torture jobs on other platforms (though they manage to fit `-shallow=25`). Also `-shallow=13` still caught leaks in multiple tests. Also: - test2300: exclude from CI Windows torture tests. - experimental. The downside of going with deeper torture tests, is that it requires increasing the job timeout. This in turns means that a hung job takes more minutes to be killed (due to GitHub bugs where a hung step does not honor the per-step timeout on Windows, another bug where a hung job gets killed +5 minutes above the workflow timeout, and another bug (or feature?) where other failed/hung jobs in the the workflow cannot be restarted till the last job finishes or gets killed. And all this probably related to a Perl bug which makes it hang on fork errors, which is turn related to Cygwin/MSYS2 runtime bugs which breaks fork in case of curl's mixed MSYS2-Perl/native-curl-binaries environment.) The end result in longer forced waits before being able to restart flaky jobs, which slows down iterations and annoying. Also tried: - non-c-ares job: detected known issues much less often. - replaced libidn2 with WinIDN: detected known issues much less often. - runtests -j9-j20 values: did not make a difference. - other `-shallow` values: 20 is the max feasible, but comes with the downside described above. Ref: #19675 (reboot of) Follow-up to f08417c4259a3b9a2e4d72a48fa02ce6502cb587 #19863 Closes #19865 --- .github/workflows/windows.yml | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index d2e97851fc69..8dca6ce891e4 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -198,25 +198,26 @@ jobs: matrix: include: # MSYS - - { build: 'autotools', sys: 'msys' , env: 'x86_64' , tflags: '' , config: '--enable-debug --with-openssl --disable-threaded-resolver --disable-proxy', install: 'openssl-devel libssh2-devel', name: '!proxy' } - - { build: 'autotools', sys: 'msys' , env: 'x86_64' , tflags: 'skiprun', config: '--enable-debug --with-openssl --disable-threaded-resolver', install: 'openssl-devel libssh2-devel', name: 'default' } - - { build: 'cmake' , sys: 'msys' , env: 'x86_64' , tflags: '' , config: '-DENABLE_DEBUG=ON -DENABLE_THREADED_RESOLVER=OFF', install: 'openssl-devel libssh2-devel', name: 'default' } - - { build: 'autotools', sys: 'msys' , env: 'x86_64' , tflags: '' , config: '--with-openssl', install: 'openssl-devel libssh2-devel', name: 'default R' } + - { build: 'autotools', sys: 'msys' , env: 'x86_64' , tflags: '' , config: '--enable-debug --with-openssl --disable-threaded-resolver --disable-proxy', install: 'openssl-devel libssh2-devel', name: '!proxy' } + - { build: 'autotools', sys: 'msys' , env: 'x86_64' , tflags: 'skiprun' , config: '--enable-debug --with-openssl --disable-threaded-resolver', install: 'openssl-devel libssh2-devel', name: 'default' } + - { build: 'cmake' , sys: 'msys' , env: 'x86_64' , tflags: '' , config: '-DENABLE_DEBUG=ON -DENABLE_THREADED_RESOLVER=OFF', install: 'openssl-devel libssh2-devel', name: 'default' } + - { build: 'autotools', sys: 'msys' , env: 'x86_64' , tflags: '' , config: '--with-openssl', install: 'openssl-devel libssh2-devel', name: 'default R' } # MinGW - - { build: 'autotools', sys: 'mingw64' , env: 'x86_64' , tflags: 'skiprun', config: '--enable-debug --with-openssl --disable-threaded-resolver --disable-curldebug --enable-static=no --without-zlib CPPFLAGS=-D_WIN32_WINNT=0x0501', install: 'mingw-w64-x86_64-openssl mingw-w64-x86_64-libssh2', name: 'default XP' } - - { build: 'autotools', sys: 'mingw64' , env: 'x86_64' , tflags: '' , config: '--enable-debug --with-openssl --enable-windows-unicode --enable-ares --with-openssl-quic --enable-shared=no', install: 'mingw-w64-x86_64-c-ares mingw-w64-x86_64-openssl mingw-w64-x86_64-nghttp3 mingw-w64-x86_64-libssh2', name: 'c-ares U' } - - { build: 'cmake' , sys: 'mingw64' , env: 'x86_64' , tflags: '' , config: '-DENABLE_DEBUG=ON -DBUILD_SHARED_LIBS=OFF -DCURL_USE_SCHANNEL=ON -DENABLE_UNICODE=ON -DENABLE_ARES=ON', install: 'mingw-w64-x86_64-c-ares mingw-w64-x86_64-libssh2', type: 'Debug', name: 'schannel c-ares U' } + - { build: 'autotools', sys: 'mingw64' , env: 'x86_64' , tflags: 'skiprun' , config: '--enable-debug --with-openssl --disable-threaded-resolver --disable-curldebug --enable-static=no --without-zlib CPPFLAGS=-D_WIN32_WINNT=0x0501', install: 'mingw-w64-x86_64-openssl mingw-w64-x86_64-libssh2', name: 'default XP' } + - { build: 'autotools', sys: 'mingw64' , env: 'x86_64' , tflags: '' , config: '--enable-debug --with-openssl --enable-windows-unicode --enable-ares --with-openssl-quic --enable-shared=no', install: 'mingw-w64-x86_64-c-ares mingw-w64-x86_64-openssl mingw-w64-x86_64-nghttp3 mingw-w64-x86_64-libssh2', name: 'c-ares U' } + - { build: 'cmake' , sys: 'mingw64' , env: 'x86_64' , tflags: '' , config: '-DENABLE_DEBUG=ON -DBUILD_SHARED_LIBS=OFF -DCURL_USE_SCHANNEL=ON -DENABLE_UNICODE=ON -DENABLE_ARES=ON', install: 'mingw-w64-x86_64-c-ares mingw-w64-x86_64-libssh2', type: 'Debug', name: 'schannel c-ares U' } + - { build: 'cmake' , sys: 'mingw64' , env: 'x86_64' , tflags: '-t --shallow=13 !FTP', config: '-DENABLE_DEBUG=ON -DBUILD_SHARED_LIBS=OFF -DCURL_USE_SCHANNEL=ON -DENABLE_UNICODE=ON -DENABLE_ARES=ON', install: 'mingw-w64-x86_64-c-ares mingw-w64-x86_64-libssh2', type: 'Debug', name: 'schannel U torture' } # WARNING: libssh uses hard-coded world-writable paths (/etc/..., ~/.ssh/) to # read its configuration from, making it vulnerable to attacks on # Windows. Do not use this component till there is a fix for these. # https://github.com/curl/curl-for-win/blob/3951808deb04df9489ee17430f236ed54436f81a/libssh.sh#L6-L8 - - { build: 'cmake' , sys: 'clang64' , env: 'clang-x86_64' , tflags: '' , config: '-DENABLE_DEBUG=ON -DBUILD_SHARED_LIBS=OFF -DCURL_USE_GNUTLS=ON -DENABLE_UNICODE=OFF -DUSE_NGTCP2=ON -DCURL_USE_LIBSSH2=OFF -DCURL_USE_LIBSSH=ON', install: 'mingw-w64-clang-x86_64-gnutls mingw-w64-clang-x86_64-nghttp3 mingw-w64-clang-x86_64-ngtcp2 mingw-w64-clang-x86_64-libssh', type: 'Debug', name: 'gnutls libssh' } - - { build: 'cmake' , sys: 'clangarm64', env: 'clang-aarch64', tflags: 'skiprun', config: '-DENABLE_DEBUG=OFF -DBUILD_SHARED_LIBS=ON -DCURL_USE_SCHANNEL=ON -DENABLE_UNICODE=ON -DENABLE_CURLDEBUG=ON', install: 'mingw-w64-clang-aarch64-libssh2', type: 'Release', name: 'schannel R TrackMemory', image: 'windows-11-arm' } - - { build: 'cmake' , sys: 'clang64' , env: 'clang-x86_64' , tflags: 'skiprun', config: '-DENABLE_DEBUG=ON -DBUILD_SHARED_LIBS=OFF -DCURL_USE_OPENSSL=ON -DENABLE_UNICODE=OFF -DUSE_NGTCP2=ON', install: 'mingw-w64-clang-x86_64-openssl mingw-w64-clang-x86_64-nghttp3 mingw-w64-clang-x86_64-ngtcp2 mingw-w64-clang-x86_64-libssh2', type: 'Release', name: 'openssl', chkprefill: '_chkprefill' } - - { build: 'cmake' , sys: 'ucrt64' , env: 'ucrt-x86_64' , tflags: 'skiprun', config: '-DENABLE_DEBUG=OFF -DBUILD_SHARED_LIBS=ON -DCURL_USE_OPENSSL=ON', install: 'mingw-w64-ucrt-x86_64-openssl mingw-w64-ucrt-x86_64-libssh2', type: 'Release', test: 'uwp', name: 'schannel' } - # { build: 'autotools', sys: 'ucrt64' , env: 'ucrt-x86_64' , tflags: 'skiprun', config: '--without-debug --with-schannel --enable-shared', install: 'mingw-w64-ucrt-x86_64-libssh2', type: 'Release', test: 'uwp', name: 'schannel' } - - { build: 'cmake' , sys: 'mingw64' , env: 'x86_64' , tflags: 'skiprun', config: '-DENABLE_DEBUG=ON -DBUILD_SHARED_LIBS=ON -DCURL_USE_SCHANNEL=ON -DENABLE_UNICODE=ON -DCMAKE_VERBOSE_MAKEFILE=ON', install: 'mingw-w64-x86_64-libssh2', type: 'Debug', cflags: '-DCURL_SCHANNEL_DEV_DEBUG', name: 'schannel dev debug', image: 'windows-2025' } - - { build: 'cmake' , sys: 'mingw32' , env: 'i686' , tflags: 'skiprun', config: '-DENABLE_DEBUG=OFF -DBUILD_SHARED_LIBS=ON -DCURL_USE_SCHANNEL=ON -DENABLE_UNICODE=ON', install: 'mingw-w64-i686-libssh2', type: 'Release', name: 'schannel R' } + - { build: 'cmake' , sys: 'clang64' , env: 'clang-x86_64' , tflags: '' , config: '-DENABLE_DEBUG=ON -DBUILD_SHARED_LIBS=OFF -DCURL_USE_GNUTLS=ON -DENABLE_UNICODE=OFF -DUSE_NGTCP2=ON -DCURL_USE_LIBSSH2=OFF -DCURL_USE_LIBSSH=ON', install: 'mingw-w64-clang-x86_64-gnutls mingw-w64-clang-x86_64-nghttp3 mingw-w64-clang-x86_64-ngtcp2 mingw-w64-clang-x86_64-libssh', type: 'Debug', name: 'gnutls libssh' } + - { build: 'cmake' , sys: 'clangarm64', env: 'clang-aarch64', tflags: 'skiprun' , config: '-DENABLE_DEBUG=OFF -DBUILD_SHARED_LIBS=ON -DCURL_USE_SCHANNEL=ON -DENABLE_UNICODE=ON -DENABLE_CURLDEBUG=ON', install: 'mingw-w64-clang-aarch64-libssh2', type: 'Release', name: 'schannel R TrackMemory', image: 'windows-11-arm' } + - { build: 'cmake' , sys: 'clang64' , env: 'clang-x86_64' , tflags: 'skiprun' , config: '-DENABLE_DEBUG=ON -DBUILD_SHARED_LIBS=OFF -DCURL_USE_OPENSSL=ON -DENABLE_UNICODE=OFF -DUSE_NGTCP2=ON', install: 'mingw-w64-clang-x86_64-openssl mingw-w64-clang-x86_64-nghttp3 mingw-w64-clang-x86_64-ngtcp2 mingw-w64-clang-x86_64-libssh2', type: 'Release', name: 'openssl', chkprefill: '_chkprefill' } + - { build: 'cmake' , sys: 'ucrt64' , env: 'ucrt-x86_64' , tflags: 'skiprun' , config: '-DENABLE_DEBUG=OFF -DBUILD_SHARED_LIBS=ON -DCURL_USE_OPENSSL=ON', install: 'mingw-w64-ucrt-x86_64-openssl mingw-w64-ucrt-x86_64-libssh2', type: 'Release', test: 'uwp', name: 'schannel' } + # { build: 'autotools', sys: 'ucrt64' , env: 'ucrt-x86_64' , tflags: 'skiprun' , config: '--without-debug --with-schannel --enable-shared', install: 'mingw-w64-ucrt-x86_64-libssh2', type: 'Release', test: 'uwp', name: 'schannel' } + - { build: 'cmake' , sys: 'mingw64' , env: 'x86_64' , tflags: 'skiprun' , config: '-DENABLE_DEBUG=ON -DBUILD_SHARED_LIBS=ON -DCURL_USE_SCHANNEL=ON -DENABLE_UNICODE=ON -DCMAKE_VERBOSE_MAKEFILE=ON', install: 'mingw-w64-x86_64-libssh2', type: 'Debug', cflags: '-DCURL_SCHANNEL_DEV_DEBUG', name: 'schannel dev debug', image: 'windows-2025' } + - { build: 'cmake' , sys: 'mingw32' , env: 'i686' , tflags: 'skiprun' , config: '-DENABLE_DEBUG=OFF -DBUILD_SHARED_LIBS=ON -DCURL_USE_SCHANNEL=ON -DENABLE_UNICODE=ON', install: 'mingw-w64-i686-libssh2', type: 'Release', name: 'schannel R' } fail-fast: false steps: - uses: msys2/setup-msys2@fb197b72ce45fb24f17bf3f807a388985654d1f2 # v2.29.0 @@ -367,7 +368,7 @@ jobs: - name: 'run tests' if: ${{ matrix.tflags != 'skipall' && matrix.tflags != 'skiprun' }} - timeout-minutes: 10 + timeout-minutes: ${{ contains(matrix.tflags, '-t') && 15 || 10 }} env: MATRIX_INSTALL: '${{ matrix.install }}' TFLAGS: '${{ matrix.tflags }}' @@ -378,6 +379,9 @@ jobs: if [[ "${MATRIX_INSTALL}" = *'libssh2-wincng'* ]]; then TFLAGS+=' ~SCP ~SFTP' # Flaky: `-8, Unable to exchange encryption keys`. https://github.com/libssh2/libssh2/issues/804 fi + if [[ "${TFLAGS}" = *'-t'* ]]; then + TFLAGS+=' !2300' # Leaks memory and file handle via tool_doswin.c / win32_stdin_read_thread() + fi fi if [ -x "$(cygpath "${SYSTEMROOT}/System32/curl.exe")" ]; then TFLAGS+=" -ac $(cygpath "${SYSTEMROOT}/System32/curl.exe")" From cc853ddc3dcf6478690a60c2cfd529e4c94e462c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 Dec 2025 14:20:54 +0000 Subject: [PATCH 232/415] GHA: bump pip-dependencies ruff, psutil, pytest - update `ruff` from 0.14.5 to 0.14.8 - update `psutil` from 7.1.2 to 7.1.3 - update `pytest` from 8.4.2 to 9.0.1 Closes #19876 --- .github/scripts/requirements.txt | 2 +- tests/http/requirements.txt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/scripts/requirements.txt b/.github/scripts/requirements.txt index 874e710997fe..537f329acafd 100644 --- a/.github/scripts/requirements.txt +++ b/.github/scripts/requirements.txt @@ -6,4 +6,4 @@ cmakelang==0.6.13 codespell==2.4.1 pytype==2024.10.11 reuse==6.2.0 -ruff==0.14.5 +ruff==0.14.8 diff --git a/tests/http/requirements.txt b/tests/http/requirements.txt index a27bf48ea196..fde20ec152ce 100644 --- a/tests/http/requirements.txt +++ b/tests/http/requirements.txt @@ -4,7 +4,7 @@ cryptography==46.0.3 filelock==3.20.0 -psutil==7.1.2 -pytest==8.4.2 +psutil==7.1.3 +pytest==9.0.1 pytest-xdist==3.8.0 websockets==15.0.1 From 64a1092a7953446299b1114a15e7e82e7b5fefd2 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Mon, 8 Dec 2025 17:02:26 +0100 Subject: [PATCH 233/415] IPFS.md: wrap long lines Closes #19880 --- docs/IPFS.md | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/docs/IPFS.md b/docs/IPFS.md index 8ce51325bfd2..c39f802dd918 100644 --- a/docs/IPFS.md +++ b/docs/IPFS.md @@ -7,22 +7,38 @@ SPDX-License-Identifier: curl # IPFS For an overview about IPFS, visit the [IPFS project site](https://ipfs.tech/). -In IPFS there are two protocols. IPFS and IPNS (their workings are explained in detail [here](https://docs.ipfs.tech/concepts/)). The ideal way to access data on the IPFS network is through those protocols. For example to access the Big Buck Bunny video the ideal way to access it is like: `ipfs://bafybeigagd5nmnn2iys2f3doro7ydrevyr2mzarwidgadawmamiteydbzi` +In IPFS there are two protocols. IPFS and IPNS (their workings are explained +in detail [here](https://docs.ipfs.tech/concepts/)). The ideal way to access +data on the IPFS network is through those protocols. For example to access +the Big Buck Bunny video the ideal way to access it is like: +`ipfs://bafybeigagd5nmnn2iys2f3doro7ydrevyr2mzarwidgadawmamiteydbzi` ## IPFS Gateways IPFS Gateway acts as a bridge between traditional HTTP clients and IPFS. -IPFS Gateway specifications of HTTP semantics can be found [here](https://specs.ipfs.tech/http-gateways/). +IPFS Gateway specifications of HTTP semantics can be found +[here](https://specs.ipfs.tech/http-gateways/). ### Deserialized responses -By default, a gateway acts as a bridge between traditional HTTP clients and IPFS and performs necessary hash verification and deserialization. Through such gateway, users can download files, directories, and other content-addressed data stored with IPFS or IPNS as if they were stored in a traditional web server. +By default, a gateway acts as a bridge between traditional HTTP clients and +IPFS and performs necessary hash verification and deserialization. Through such +gateway, users can download files, directories, and other content-addressed +data stored with IPFS or IPNS as if they were stored in a traditional web +server. ### Verifiable responses -By explicitly requesting [application/vnd.ipld.raw](https://www.iana.org/assignments/media-types/application/vnd.ipld.raw) or [application/vnd.ipld.car](https://www.iana.org/assignments/media-types/application/vnd.ipld.car) responses, by means defined in [Trustless Gateway Specification](https://specs.ipfs.tech/http-gateways/trustless-gateway/), the user is able to fetch raw content-addressed data and [perform hash verification themselves](https://docs.ipfs.tech/reference/http/gateway/#trustless-verifiable-retrieval). +By explicitly requesting +[application/vnd.ipld.raw](https://www.iana.org/assignments/media-types/application/vnd.ipld.raw) or +[application/vnd.ipld.car](https://www.iana.org/assignments/media-types/application/vnd.ipld.car) +responses, by means defined in +[Trustless Gateway Specification](https://specs.ipfs.tech/http-gateways/trustless-gateway/), +the user is able to fetch raw content-addressed data and +[perform hash verification themselves](https://docs.ipfs.tech/reference/http/gateway/#trustless-verifiable-retrieval). -This enables users to use untrusted, public gateways without worrying they might return invalid/malicious bytes. +This enables users to use untrusted, public gateways without worrying they +might return invalid/malicious bytes. ## IPFS and IPNS protocol handling From 16f4b2038503aac2e32dca2abff8dd44e7591810 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 8 Dec 2025 15:54:38 +0100 Subject: [PATCH 234/415] KNOWN_BUGS: remove link to codepoints.net The site is so slow it often triggers a failure for the link checker. Closes #19878 --- docs/KNOWN_BUGS | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/KNOWN_BUGS b/docs/KNOWN_BUGS index 278cc2a0977b..e28a90053dd9 100644 --- a/docs/KNOWN_BUGS +++ b/docs/KNOWN_BUGS @@ -322,7 +322,6 @@ problems may have been fixed or changed somewhat since this was written. 6.5 NTLM does not support password with Unicode 'SECTION SIGN' character https://en.wikipedia.org/wiki/Section_sign - https://codepoints.net/U+00A7 SECTION SIGN https://github.com/curl/curl/issues/2120 6.6 libcurl can fail to try alternatives with --proxy-any From 09e48d5a046fc9b97c15f9b1d2e21de38eda508d Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 8 Dec 2025 15:50:48 +0100 Subject: [PATCH 235/415] mk-ca-bundle.md: the file format docs URL is permaredirected Closes #19877 --- docs/mk-ca-bundle.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/mk-ca-bundle.md b/docs/mk-ca-bundle.md index fe68635263a6..bb5b7b1a48f9 100644 --- a/docs/mk-ca-bundle.md +++ b/docs/mk-ca-bundle.md @@ -122,6 +122,5 @@ Returns 0 on success. Returns 1 if it fails to download data. # FILE FORMAT -The file format used by Mozilla for this trust information is documented here: - -https://p11-glue.freedesktop.org/doc/storing-trust-policy/storing-trust-existing.html +The file format used by Mozilla for this trust information is [documented +here](https://p11-glue.github.io/p11-glue/doc/storing-trust-policy/storing-trust-existing.html). From 2ae983bf4ea5ef86f0e68ea0ff219a91b1aa3428 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Mon, 8 Dec 2025 16:44:29 +0100 Subject: [PATCH 236/415] tidy-up: URLs - to avoid dupes. - missing slashes. - drop `.git` suffix from GitHub git repo URLs for a few outliers. - use short YouTube URL like curl-www does. - sync two RFC doc URLs with others. Closes #19879 --- README | 2 +- README.md | 2 +- docs/CONTRIBUTE.md | 2 +- docs/DISTROS.md | 2 +- docs/ECH.md | 2 +- docs/FAQ | 2 +- docs/HTTP3.md | 6 +++--- docs/INSTALL.md | 4 ++-- docs/KNOWN_BUGS | 2 ++ docs/TODO | 2 +- docs/testcurl.md | 2 +- 11 files changed, 15 insertions(+), 13 deletions(-) diff --git a/README b/README index df320f94810e..2f68ef0c9f4f 100644 --- a/README +++ b/README @@ -38,7 +38,7 @@ GIT To download the latest source code off the GIT server, do this: - git clone https://github.com/curl/curl.git + git clone https://github.com/curl/curl (you will get a directory named curl created, filled with the source code) diff --git a/README.md b/README.md index 2fe531628188..69e8b937dc17 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ Visit the [curl website](https://curl.se/) for the latest news and downloads. Download the latest source from the Git server: - git clone https://github.com/curl/curl.git + git clone https://github.com/curl/curl ## Security problems diff --git a/docs/CONTRIBUTE.md b/docs/CONTRIBUTE.md index 4a34a539bbe9..3abf729598a7 100644 --- a/docs/CONTRIBUTE.md +++ b/docs/CONTRIBUTE.md @@ -289,7 +289,7 @@ Just ask if this is what you would want. You are required to have posted several high quality patches first, before you can be granted push access. ## Useful resources - - [Webinar on getting code into curl](https://www.youtube.com/watch?v=QmZ3W1d6LQI) + - [Webinar on getting code into curl](https://youtu.be/QmZ3W1d6LQI) # Update copyright and license information diff --git a/docs/DISTROS.md b/docs/DISTROS.md index 7f61e2aa3f5b..8810cc999150 100644 --- a/docs/DISTROS.md +++ b/docs/DISTROS.md @@ -256,7 +256,7 @@ can also be used on other distributions ## Rocky Linux - curl: https://git.rockylinux.org/staging/rpms/curl/-/blob/r9/SPECS/curl.spec -- curl issues: https://bugs.rockylinux.org +- curl issues: https://bugs.rockylinux.org/ - curl patches: https://git.rockylinux.org/staging/rpms/curl/-/tree/r9/SOURCES ## SerenityOS diff --git a/docs/ECH.md b/docs/ECH.md index 6f236a106b52..042719245c0c 100644 --- a/docs/ECH.md +++ b/docs/ECH.md @@ -77,7 +77,7 @@ The above works for these test sites: ```sh https://defo.ie/ech-check.php https://crypto.cloudflare.com/cdn-cgi/trace -https://tls-ech.dev +https://tls-ech.dev/ ``` The list above has 4 different server technologies, implemented by 3 different diff --git a/docs/FAQ b/docs/FAQ index 230b850bac80..ef93c91c4153 100644 --- a/docs/FAQ +++ b/docs/FAQ @@ -1043,7 +1043,7 @@ FAQ you will find that even if D:\blah.txt does exist, curl returns a 'file not found' error. - According to RFC 1738 (https://www.ietf.org/rfc/rfc1738.txt), + According to RFC 1738 (https://datatracker.ietf.org/doc/html/rfc1738), file:// URLs must contain a host component, but it is ignored by most implementations. In the above example, 'D:' is treated as the host component, and is taken away. Thus, curl tries to open '/blah.txt'. diff --git a/docs/HTTP3.md b/docs/HTTP3.md index def30798ecca..2b0a4c72b872 100644 --- a/docs/HTTP3.md +++ b/docs/HTTP3.md @@ -140,7 +140,7 @@ Build curl: Build GnuTLS: - % git clone --depth 1 https://gitlab.com/gnutls/gnutls.git + % git clone --depth 1 https://gitlab.com/gnutls/gnutls % cd gnutls % ./bootstrap % ./configure --prefix= @@ -182,7 +182,7 @@ Build curl: Build wolfSSL: - % git clone https://github.com/wolfSSL/wolfssl.git + % git clone https://github.com/wolfSSL/wolfssl % cd wolfssl % autoreconf -fi % ./configure --prefix= --enable-quic --enable-session-ticket --enable-earlydata --enable-psk --enable-harden --enable-altcertchains @@ -386,7 +386,7 @@ above. Get, build and install nghttp2: - % git clone https://github.com/nghttp2/nghttp2.git + % git clone https://github.com/nghttp2/nghttp2 % cd nghttp2 % autoreconf -fi % PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/home/daniel/build-quictls/lib/pkgconfig:/home/daniel/build-nghttp3/lib/pkgconfig:/home/daniel/build-ngtcp2/lib/pkgconfig LDFLAGS=-L/home/daniel/build-quictls/lib CFLAGS=-I/home/daniel/build-quictls/include ./configure --enable-maintainer-mode --prefix=/home/daniel/build-nghttp2 --disable-shared --enable-app --enable-http3 --without-jemalloc --without-libxml2 --without-systemd diff --git a/docs/INSTALL.md b/docs/INSTALL.md index 1859dc21ae7f..751b21e62051 100644 --- a/docs/INSTALL.md +++ b/docs/INSTALL.md @@ -18,7 +18,7 @@ libcurl from [source code](https://curl.se/download.html). You can download and install curl and libcurl using the [vcpkg](https://github.com/Microsoft/vcpkg) dependency manager: - git clone https://github.com/Microsoft/vcpkg.git + git clone https://github.com/Microsoft/vcpkg cd vcpkg ./bootstrap-vcpkg.sh ./vcpkg integrate install @@ -244,7 +244,7 @@ Either run setup-x86_64.exe, then search and select packages individually, or tr setup-x86_64.exe -P binutils -P gcc-core -P libpsl-devel -P libtool -P perl -P make If the latter, matching packages should appear in the install rows (*is fickle though*) after selecting -the download site i.e. `https://mirrors.kernel.org`. In either case, follow the GUI prompts +the download site i.e. `https://mirrors.kernel.org/`. In either case, follow the GUI prompts until you reach the "Select Packages" window; then select packages, click next, and finish the `cygwin` package installation. diff --git a/docs/KNOWN_BUGS b/docs/KNOWN_BUGS index e28a90053dd9..f65e9f1ae264 100644 --- a/docs/KNOWN_BUGS +++ b/docs/KNOWN_BUGS @@ -321,6 +321,8 @@ problems may have been fixed or changed somewhat since this was written. 6.5 NTLM does not support password with Unicode 'SECTION SIGN' character + Code point: U+00A7 + https://en.wikipedia.org/wiki/Section_sign https://github.com/curl/curl/issues/2120 diff --git a/docs/TODO b/docs/TODO index 817591dfb7cb..22ca27f88d99 100644 --- a/docs/TODO +++ b/docs/TODO @@ -771,7 +771,7 @@ DNS-Based Authentication of Named Entities (DANE) is a way to provide SSL keys and certs over DNS using DNSSEC as an alternative to the CA model. - https://www.rfc-editor.org/rfc/rfc6698.txt + https://datatracker.ietf.org/doc/html/rfc6698 An initial patch was posted by Suresh Krishnaswamy on March 7th 2013 (https://curl.se/mail/lib-2013-03/0075.html) but it was a too simple diff --git a/docs/testcurl.md b/docs/testcurl.md index e4acab6db7de..b5149e098b57 100644 --- a/docs/testcurl.md +++ b/docs/testcurl.md @@ -102,7 +102,7 @@ snapshots automatically): $ mkdir curl-testing $ cd curl-testing - $ git clone https://github.com/curl/curl.git + $ git clone https://github.com/curl/curl With the curl sources checked out, or downloaded, you can start testing right away. If you want to use *testcurl* without command line arguments and to have From d75716e4e55c7074566f48d8c03bfd721461e105 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Mon, 1 Dec 2025 13:31:42 +0100 Subject: [PATCH 237/415] tests/data: move `--libcurl` output to external data files To make the test files XML-compliant, and the expected results possibly easier to manage by keeping them in `.c` files. Non-XML-compliant files are down to 36 after this patch. Also: - make all macro expansions apply to `%includetext` contents. Closes #19799 --- docs/tests/FILEFORMAT.md | 3 +- scripts/checksrc-all.pl | 1 + tests/data/Makefile.am | 4 +- tests/data/data1400.c | 46 +++++++++++++++++++++ tests/data/data1401.c | 58 +++++++++++++++++++++++++++ tests/data/data1402.c | 48 ++++++++++++++++++++++ tests/data/data1403.c | 46 +++++++++++++++++++++ tests/data/data1404.c | 83 ++++++++++++++++++++++++++++++++++++++ tests/data/data1405.c | 66 ++++++++++++++++++++++++++++++ tests/data/data1406.c | 56 ++++++++++++++++++++++++++ tests/data/data1407.c | 46 +++++++++++++++++++++ tests/data/data1420.c | 46 +++++++++++++++++++++ tests/data/data1465.c | 48 ++++++++++++++++++++++ tests/data/data1481.c | 49 ++++++++++++++++++++++ tests/data/test1400 | 49 +--------------------- tests/data/test1401 | 60 +-------------------------- tests/data/test1402 | 51 +---------------------- tests/data/test1403 | 49 +--------------------- tests/data/test1404 | 87 +--------------------------------------- tests/data/test1405 | 72 ++------------------------------- tests/data/test1406 | 62 ++-------------------------- tests/data/test1407 | 53 ++---------------------- tests/data/test1420 | 52 ++---------------------- tests/data/test1465 | 51 +---------------------- tests/data/test1481 | 52 +----------------------- tests/runner.pm | 6 +++ tests/testutil.pm | 31 +++++++++----- 27 files changed, 645 insertions(+), 630 deletions(-) create mode 100644 tests/data/data1400.c create mode 100644 tests/data/data1401.c create mode 100644 tests/data/data1402.c create mode 100644 tests/data/data1403.c create mode 100644 tests/data/data1404.c create mode 100644 tests/data/data1405.c create mode 100644 tests/data/data1406.c create mode 100644 tests/data/data1407.c create mode 100644 tests/data/data1420.c create mode 100644 tests/data/data1465.c create mode 100644 tests/data/data1481.c diff --git a/docs/tests/FILEFORMAT.md b/docs/tests/FILEFORMAT.md index 90a249fac2d2..c655a4d863d3 100644 --- a/docs/tests/FILEFORMAT.md +++ b/docs/tests/FILEFORMAT.md @@ -115,7 +115,8 @@ the include instruction: %include filename% Or, a variant of the above where the file is loaded as a newline-agnostic -text file, and `%CR`, `%SP`, `%TAB` macros are expanded after inclusion: +text file, and whitespace, special character macros and variables expanded +after inclusion: %includetext filename% diff --git a/scripts/checksrc-all.pl b/scripts/checksrc-all.pl index 08ff6cfbf5fb..764895148e50 100755 --- a/scripts/checksrc-all.pl +++ b/scripts/checksrc-all.pl @@ -22,6 +22,7 @@ } @files = grep !/\/CMakeFiles\//, @files; +@files = grep !/tests\/data\/data.+\.c/, @files; @files = map { dirname($_) } @files; my @dirs = sort { $a cmp $b } keys %{{ map { $_ => 1 } @files }}; diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am index 18c6969391be..910dbd69915a 100644 --- a/tests/data/Makefile.am +++ b/tests/data/Makefile.am @@ -283,4 +283,6 @@ test3200 test3201 test3202 test3203 test3204 test3205 test3206 test3207 test3208 test3209 test3210 test3211 test3212 test3213 test3214 test3215 test3216 \ test4000 test4001 -EXTRA_DIST = $(TESTCASES) DISABLED data-xml1 +EXTRA_DIST = $(TESTCASES) DISABLED data-xml1 \ +data1400.c data1401.c data1402.c data1403.c data1404.c data1405.c data1406.c \ +data1407.c data1420.c data1465.c data1481.c diff --git a/tests/data/data1400.c b/tests/data/data1400.c new file mode 100644 index 000000000000..8aeb3c8fc88b --- /dev/null +++ b/tests/data/data1400.c @@ -0,0 +1,46 @@ +/********* Sample code generated by the curl command line tool ********** + * All curl_easy_setopt() options are documented at: + * https://curl.se/libcurl/c/curl_easy_setopt.html + ************************************************************************/ +#include + +int main(int argc, char *argv[]) +{ + CURLcode ret; + CURL *hnd; + + hnd = curl_easy_init(); + curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L); + curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L); + curl_easy_setopt(hnd, CURLOPT_URL, "http://%HOSTIP:%HTTPPORT/we/want/%TESTNUMBER"); + curl_easy_setopt(hnd, CURLOPT_USERAGENT, "curl/%VERSION"); + curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 50L); + curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L); + + /* Here is a list of options the curl code used that cannot get generated + as source easily. You may choose to either not use them or implement + them yourself. + + CURLOPT_DEBUGFUNCTION was set to a function pointer + CURLOPT_DEBUGDATA was set to an object pointer + CURLOPT_WRITEDATA was set to an object pointer + CURLOPT_WRITEFUNCTION was set to a function pointer + CURLOPT_READDATA was set to an object pointer + CURLOPT_READFUNCTION was set to a function pointer + CURLOPT_SEEKDATA was set to an object pointer + CURLOPT_SEEKFUNCTION was set to a function pointer + CURLOPT_HEADERFUNCTION was set to a function pointer + CURLOPT_HEADERDATA was set to an object pointer + CURLOPT_ERRORBUFFER was set to an object pointer + CURLOPT_STDERR was set to an object pointer + + */ + + ret = curl_easy_perform(hnd); + + curl_easy_cleanup(hnd); + hnd = NULL; + + return (int)ret; +} +/**** End of sample code ****/ diff --git a/tests/data/data1401.c b/tests/data/data1401.c new file mode 100644 index 000000000000..dfea0bb673e7 --- /dev/null +++ b/tests/data/data1401.c @@ -0,0 +1,58 @@ +/********* Sample code generated by the curl command line tool ********** + * All curl_easy_setopt() options are documented at: + * https://curl.se/libcurl/c/curl_easy_setopt.html + ************************************************************************/ +#include + +int main(int argc, char *argv[]) +{ + CURLcode ret; + CURL *hnd; + struct curl_slist *slist1; + + slist1 = NULL; + slist1 = curl_slist_append(slist1, "X-Files: Mulder"); + slist1 = curl_slist_append(slist1, "X-Men: cyclops, iceman"); + + hnd = curl_easy_init(); + curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L); + curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L); + curl_easy_setopt(hnd, CURLOPT_URL, "http://%HOSTIP:%HTTPPORT/we/want/%TESTNUMBER"); + curl_easy_setopt(hnd, CURLOPT_USERPWD, "fake:user"); + curl_easy_setopt(hnd, CURLOPT_HTTPAUTH, (long)CURLAUTH_BASIC); + curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, slist1); + curl_easy_setopt(hnd, CURLOPT_USERAGENT, "MyUA"); + curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 50L); + curl_easy_setopt(hnd, CURLOPT_COOKIE, "chocolate=chip"); + curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L); + curl_easy_setopt(hnd, CURLOPT_PROTOCOLS_STR, "file,ftp,http"); + + /* Here is a list of options the curl code used that cannot get generated + as source easily. You may choose to either not use them or implement + them yourself. + + CURLOPT_DEBUGFUNCTION was set to a function pointer + CURLOPT_DEBUGDATA was set to an object pointer + CURLOPT_WRITEDATA was set to an object pointer + CURLOPT_WRITEFUNCTION was set to a function pointer + CURLOPT_READDATA was set to an object pointer + CURLOPT_READFUNCTION was set to a function pointer + CURLOPT_SEEKDATA was set to an object pointer + CURLOPT_SEEKFUNCTION was set to a function pointer + CURLOPT_HEADERFUNCTION was set to a function pointer + CURLOPT_HEADERDATA was set to an object pointer + CURLOPT_ERRORBUFFER was set to an object pointer + CURLOPT_STDERR was set to an object pointer + + */ + + ret = curl_easy_perform(hnd); + + curl_easy_cleanup(hnd); + hnd = NULL; + curl_slist_free_all(slist1); + slist1 = NULL; + + return (int)ret; +} +/**** End of sample code ****/ diff --git a/tests/data/data1402.c b/tests/data/data1402.c new file mode 100644 index 000000000000..917b4aa82290 --- /dev/null +++ b/tests/data/data1402.c @@ -0,0 +1,48 @@ +/********* Sample code generated by the curl command line tool ********** + * All curl_easy_setopt() options are documented at: + * https://curl.se/libcurl/c/curl_easy_setopt.html + ************************************************************************/ +#include + +int main(int argc, char *argv[]) +{ + CURLcode ret; + CURL *hnd; + + hnd = curl_easy_init(); + curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L); + curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L); + curl_easy_setopt(hnd, CURLOPT_URL, "http://%HOSTIP:%HTTPPORT/we/want/%TESTNUMBER"); + curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "foo=bar&baz=quux"); + curl_easy_setopt(hnd, CURLOPT_POSTFIELDSIZE_LARGE, (curl_off_t)16); + curl_easy_setopt(hnd, CURLOPT_USERAGENT, "curl/%VERSION"); + curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 50L); + curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L); + + /* Here is a list of options the curl code used that cannot get generated + as source easily. You may choose to either not use them or implement + them yourself. + + CURLOPT_DEBUGFUNCTION was set to a function pointer + CURLOPT_DEBUGDATA was set to an object pointer + CURLOPT_WRITEDATA was set to an object pointer + CURLOPT_WRITEFUNCTION was set to a function pointer + CURLOPT_READDATA was set to an object pointer + CURLOPT_READFUNCTION was set to a function pointer + CURLOPT_SEEKDATA was set to an object pointer + CURLOPT_SEEKFUNCTION was set to a function pointer + CURLOPT_HEADERFUNCTION was set to a function pointer + CURLOPT_HEADERDATA was set to an object pointer + CURLOPT_ERRORBUFFER was set to an object pointer + CURLOPT_STDERR was set to an object pointer + + */ + + ret = curl_easy_perform(hnd); + + curl_easy_cleanup(hnd); + hnd = NULL; + + return (int)ret; +} +/**** End of sample code ****/ diff --git a/tests/data/data1403.c b/tests/data/data1403.c new file mode 100644 index 000000000000..38226573cde4 --- /dev/null +++ b/tests/data/data1403.c @@ -0,0 +1,46 @@ +/********* Sample code generated by the curl command line tool ********** + * All curl_easy_setopt() options are documented at: + * https://curl.se/libcurl/c/curl_easy_setopt.html + ************************************************************************/ +#include + +int main(int argc, char *argv[]) +{ + CURLcode ret; + CURL *hnd; + + hnd = curl_easy_init(); + curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L); + curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L); + curl_easy_setopt(hnd, CURLOPT_URL, "http://%HOSTIP:%HTTPPORT/we/want/%TESTNUMBER\?foo=bar&baz=quux"); + curl_easy_setopt(hnd, CURLOPT_USERAGENT, "curl/%VERSION"); + curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 50L); + curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L); + + /* Here is a list of options the curl code used that cannot get generated + as source easily. You may choose to either not use them or implement + them yourself. + + CURLOPT_DEBUGFUNCTION was set to a function pointer + CURLOPT_DEBUGDATA was set to an object pointer + CURLOPT_WRITEDATA was set to an object pointer + CURLOPT_WRITEFUNCTION was set to a function pointer + CURLOPT_READDATA was set to an object pointer + CURLOPT_READFUNCTION was set to a function pointer + CURLOPT_SEEKDATA was set to an object pointer + CURLOPT_SEEKFUNCTION was set to a function pointer + CURLOPT_HEADERFUNCTION was set to a function pointer + CURLOPT_HEADERDATA was set to an object pointer + CURLOPT_ERRORBUFFER was set to an object pointer + CURLOPT_STDERR was set to an object pointer + + */ + + ret = curl_easy_perform(hnd); + + curl_easy_cleanup(hnd); + hnd = NULL; + + return (int)ret; +} +/**** End of sample code ****/ diff --git a/tests/data/data1404.c b/tests/data/data1404.c new file mode 100644 index 000000000000..24b68adb064d --- /dev/null +++ b/tests/data/data1404.c @@ -0,0 +1,83 @@ +/********* Sample code generated by the curl command line tool ********** + * All curl_easy_setopt() options are documented at: + * https://curl.se/libcurl/c/curl_easy_setopt.html + ************************************************************************/ +#include + +int main(int argc, char *argv[]) +{ + CURLcode ret; + CURL *hnd; + curl_mime *mime1; + curl_mimepart *part1; + curl_mime *mime2; + curl_mimepart *part2; + struct curl_slist *slist1; + + mime1 = NULL; + mime2 = NULL; + slist1 = NULL; + slist1 = curl_slist_append(slist1, "X-testheader-1: header 1"); + slist1 = curl_slist_append(slist1, "X-testheader-2: header 2"); + + hnd = curl_easy_init(); + curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L); + curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L); + curl_easy_setopt(hnd, CURLOPT_URL, "http://%HOSTIP:%HTTPPORT/we/want/%TESTNUMBER"); + mime1 = curl_mime_init(hnd); + part1 = curl_mime_addpart(mime1); + curl_mime_data(part1, "value", CURL_ZERO_TERMINATED); + curl_mime_name(part1, "name"); + part1 = curl_mime_addpart(mime1); + mime2 = curl_mime_init(hnd); + part2 = curl_mime_addpart(mime2); + curl_mime_filedata(part2, "%LOGDIR/test%TESTNUMBER.txt"); + part2 = curl_mime_addpart(mime2); + curl_mime_filedata(part2, "%LOGDIR/test%TESTNUMBER.txt"); + curl_mime_encoder(part2, "8bit"); + curl_mime_type(part2, "magic/content"); + part2 = curl_mime_addpart(mime2); + curl_mime_filedata(part2, "%LOGDIR/test%TESTNUMBER.txt"); + curl_mime_headers(part2, slist1, 1); + slist1 = NULL; + curl_mime_subparts(part1, mime2); + mime2 = NULL; + curl_mime_name(part1, "file"); + curl_easy_setopt(hnd, CURLOPT_MIMEPOST, mime1); + curl_easy_setopt(hnd, CURLOPT_USERAGENT, "curl/%VERSION"); + curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 50L); + curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L); + + /* Here is a list of options the curl code used that cannot get generated + as source easily. You may choose to either not use them or implement + them yourself. + + CURLOPT_DEBUGFUNCTION was set to a function pointer + CURLOPT_DEBUGDATA was set to an object pointer + CURLOPT_WRITEDATA was set to an object pointer + CURLOPT_WRITEFUNCTION was set to a function pointer + CURLOPT_READDATA was set to an object pointer + CURLOPT_READFUNCTION was set to a function pointer + CURLOPT_SEEKDATA was set to an object pointer + CURLOPT_SEEKFUNCTION was set to a function pointer + CURLOPT_HEADERFUNCTION was set to a function pointer + CURLOPT_HEADERDATA was set to an object pointer + CURLOPT_ERRORBUFFER was set to an object pointer + CURLOPT_STDERR was set to an object pointer + + */ + + ret = curl_easy_perform(hnd); + + curl_easy_cleanup(hnd); + hnd = NULL; + curl_mime_free(mime1); + mime1 = NULL; + curl_mime_free(mime2); + mime2 = NULL; + curl_slist_free_all(slist1); + slist1 = NULL; + + return (int)ret; +} +/**** End of sample code ****/ diff --git a/tests/data/data1405.c b/tests/data/data1405.c new file mode 100644 index 000000000000..e80b77eddad2 --- /dev/null +++ b/tests/data/data1405.c @@ -0,0 +1,66 @@ +/********* Sample code generated by the curl command line tool ********** + * All curl_easy_setopt() options are documented at: + * https://curl.se/libcurl/c/curl_easy_setopt.html + ************************************************************************/ +#include + +int main(int argc, char *argv[]) +{ + CURLcode ret; + CURL *hnd; + struct curl_slist *slist1; + struct curl_slist *slist2; + struct curl_slist *slist3; + + slist1 = NULL; + slist1 = curl_slist_append(slist1, "NOOP 1"); + slist1 = curl_slist_append(slist1, "*FAIL"); + slist2 = NULL; + slist2 = curl_slist_append(slist2, "NOOP 3"); + slist3 = NULL; + slist3 = curl_slist_append(slist3, "NOOP 2"); + slist3 = curl_slist_append(slist3, "*FAIL HARD"); + + hnd = curl_easy_init(); + curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L); + curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L); + curl_easy_setopt(hnd, CURLOPT_URL, "ftp://%HOSTIP:%FTPPORT/%TESTNUMBER"); + curl_easy_setopt(hnd, CURLOPT_FTP_SKIP_PASV_IP, 1L); + curl_easy_setopt(hnd, CURLOPT_QUOTE, slist1); + curl_easy_setopt(hnd, CURLOPT_POSTQUOTE, slist2); + curl_easy_setopt(hnd, CURLOPT_PREQUOTE, slist3); + curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L); + + /* Here is a list of options the curl code used that cannot get generated + as source easily. You may choose to either not use them or implement + them yourself. + + CURLOPT_DEBUGFUNCTION was set to a function pointer + CURLOPT_DEBUGDATA was set to an object pointer + CURLOPT_WRITEDATA was set to an object pointer + CURLOPT_WRITEFUNCTION was set to a function pointer + CURLOPT_READDATA was set to an object pointer + CURLOPT_READFUNCTION was set to a function pointer + CURLOPT_SEEKDATA was set to an object pointer + CURLOPT_SEEKFUNCTION was set to a function pointer + CURLOPT_HEADERFUNCTION was set to a function pointer + CURLOPT_HEADERDATA was set to an object pointer + CURLOPT_ERRORBUFFER was set to an object pointer + CURLOPT_STDERR was set to an object pointer + + */ + + ret = curl_easy_perform(hnd); + + curl_easy_cleanup(hnd); + hnd = NULL; + curl_slist_free_all(slist1); + slist1 = NULL; + curl_slist_free_all(slist2); + slist2 = NULL; + curl_slist_free_all(slist3); + slist3 = NULL; + + return (int)ret; +} +/**** End of sample code ****/ diff --git a/tests/data/data1406.c b/tests/data/data1406.c new file mode 100644 index 000000000000..b71dffa88f5a --- /dev/null +++ b/tests/data/data1406.c @@ -0,0 +1,56 @@ +/********* Sample code generated by the curl command line tool ********** + * All curl_easy_setopt() options are documented at: + * https://curl.se/libcurl/c/curl_easy_setopt.html + ************************************************************************/ +#include + +int main(int argc, char *argv[]) +{ + CURLcode ret; + CURL *hnd; + struct curl_slist *slist1; + + slist1 = NULL; + slist1 = curl_slist_append(slist1, "recipient.one@example.com"); + slist1 = curl_slist_append(slist1, "recipient.two@example.com"); + + hnd = curl_easy_init(); + curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L); + curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L); + curl_easy_setopt(hnd, CURLOPT_URL, "smtp://%HOSTIP:%SMTPPORT/%TESTNUMBER"); + curl_easy_setopt(hnd, CURLOPT_UPLOAD, 1L); + curl_easy_setopt(hnd, CURLOPT_USERAGENT, "curl/%VERSION"); + curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L); + curl_easy_setopt(hnd, CURLOPT_MAIL_FROM, "sender@example.com"); + curl_easy_setopt(hnd, CURLOPT_MAIL_RCPT, slist1); + curl_easy_setopt(hnd, CURLOPT_INFILESIZE_LARGE, (curl_off_t)38); + + /* Here is a list of options the curl code used that cannot get generated + as source easily. You may choose to either not use them or implement + them yourself. + + CURLOPT_DEBUGFUNCTION was set to a function pointer + CURLOPT_DEBUGDATA was set to an object pointer + CURLOPT_WRITEDATA was set to an object pointer + CURLOPT_WRITEFUNCTION was set to a function pointer + CURLOPT_READDATA was set to an object pointer + CURLOPT_READFUNCTION was set to a function pointer + CURLOPT_SEEKDATA was set to an object pointer + CURLOPT_SEEKFUNCTION was set to a function pointer + CURLOPT_HEADERFUNCTION was set to a function pointer + CURLOPT_HEADERDATA was set to an object pointer + CURLOPT_ERRORBUFFER was set to an object pointer + CURLOPT_STDERR was set to an object pointer + + */ + + ret = curl_easy_perform(hnd); + + curl_easy_cleanup(hnd); + hnd = NULL; + curl_slist_free_all(slist1); + slist1 = NULL; + + return (int)ret; +} +/**** End of sample code ****/ diff --git a/tests/data/data1407.c b/tests/data/data1407.c new file mode 100644 index 000000000000..f1d2b30f0f0b --- /dev/null +++ b/tests/data/data1407.c @@ -0,0 +1,46 @@ +/********* Sample code generated by the curl command line tool ********** + * All curl_easy_setopt() options are documented at: + * https://curl.se/libcurl/c/curl_easy_setopt.html + ************************************************************************/ +#include + +int main(int argc, char *argv[]) +{ + CURLcode ret; + CURL *hnd; + + hnd = curl_easy_init(); + curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L); + curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L); + curl_easy_setopt(hnd, CURLOPT_URL, "pop3://%HOSTIP:%POP3PORT/%TESTNUMBER"); + curl_easy_setopt(hnd, CURLOPT_DIRLISTONLY, 1L); + curl_easy_setopt(hnd, CURLOPT_USERPWD, "user:secret"); + curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L); + + /* Here is a list of options the curl code used that cannot get generated + as source easily. You may choose to either not use them or implement + them yourself. + + CURLOPT_DEBUGFUNCTION was set to a function pointer + CURLOPT_DEBUGDATA was set to an object pointer + CURLOPT_WRITEDATA was set to an object pointer + CURLOPT_WRITEFUNCTION was set to a function pointer + CURLOPT_READDATA was set to an object pointer + CURLOPT_READFUNCTION was set to a function pointer + CURLOPT_SEEKDATA was set to an object pointer + CURLOPT_SEEKFUNCTION was set to a function pointer + CURLOPT_HEADERFUNCTION was set to a function pointer + CURLOPT_HEADERDATA was set to an object pointer + CURLOPT_ERRORBUFFER was set to an object pointer + CURLOPT_STDERR was set to an object pointer + + */ + + ret = curl_easy_perform(hnd); + + curl_easy_cleanup(hnd); + hnd = NULL; + + return (int)ret; +} +/**** End of sample code ****/ diff --git a/tests/data/data1420.c b/tests/data/data1420.c new file mode 100644 index 000000000000..8405d8ba4c94 --- /dev/null +++ b/tests/data/data1420.c @@ -0,0 +1,46 @@ +/********* Sample code generated by the curl command line tool ********** + * All curl_easy_setopt() options are documented at: + * https://curl.se/libcurl/c/curl_easy_setopt.html + ************************************************************************/ +#include + +int main(int argc, char *argv[]) +{ + CURLcode ret; + CURL *hnd; + + hnd = curl_easy_init(); + curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L); + curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L); + curl_easy_setopt(hnd, CURLOPT_URL, "imap://%HOSTIP:%IMAPPORT/%TESTNUMBER/;MAILINDEX=1"); + curl_easy_setopt(hnd, CURLOPT_USERPWD, "user:secret"); + curl_easy_setopt(hnd, CURLOPT_USERAGENT, "curl/%VERSION"); + curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L); + + /* Here is a list of options the curl code used that cannot get generated + as source easily. You may choose to either not use them or implement + them yourself. + + CURLOPT_DEBUGFUNCTION was set to a function pointer + CURLOPT_DEBUGDATA was set to an object pointer + CURLOPT_WRITEDATA was set to an object pointer + CURLOPT_WRITEFUNCTION was set to a function pointer + CURLOPT_READDATA was set to an object pointer + CURLOPT_READFUNCTION was set to a function pointer + CURLOPT_SEEKDATA was set to an object pointer + CURLOPT_SEEKFUNCTION was set to a function pointer + CURLOPT_HEADERFUNCTION was set to a function pointer + CURLOPT_HEADERDATA was set to an object pointer + CURLOPT_ERRORBUFFER was set to an object pointer + CURLOPT_STDERR was set to an object pointer + + */ + + ret = curl_easy_perform(hnd); + + curl_easy_cleanup(hnd); + hnd = NULL; + + return (int)ret; +} +/**** End of sample code ****/ diff --git a/tests/data/data1465.c b/tests/data/data1465.c new file mode 100644 index 000000000000..09e13f28d564 --- /dev/null +++ b/tests/data/data1465.c @@ -0,0 +1,48 @@ +/********* Sample code generated by the curl command line tool ********** + * All curl_easy_setopt() options are documented at: + * https://curl.se/libcurl/c/curl_easy_setopt.html + ************************************************************************/ +#include + +int main(int argc, char *argv[]) +{ + CURLcode ret; + CURL *hnd; + + hnd = curl_easy_init(); + curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L); + curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L); + curl_easy_setopt(hnd, CURLOPT_URL, "http://%HOSTIP:%HTTPPORT/we/want/%TESTNUMBER"); + curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "ab\201cd\000e\\\"\?\r\n\t\001fghi\x1ajklm\xfd"); + curl_easy_setopt(hnd, CURLOPT_POSTFIELDSIZE_LARGE, (curl_off_t)24); + curl_easy_setopt(hnd, CURLOPT_USERAGENT, "curl/%VERSION"); + curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 50L); + curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L); + + /* Here is a list of options the curl code used that cannot get generated + as source easily. You may choose to either not use them or implement + them yourself. + + CURLOPT_DEBUGFUNCTION was set to a function pointer + CURLOPT_DEBUGDATA was set to an object pointer + CURLOPT_WRITEDATA was set to an object pointer + CURLOPT_WRITEFUNCTION was set to a function pointer + CURLOPT_READDATA was set to an object pointer + CURLOPT_READFUNCTION was set to a function pointer + CURLOPT_SEEKDATA was set to an object pointer + CURLOPT_SEEKFUNCTION was set to a function pointer + CURLOPT_HEADERFUNCTION was set to a function pointer + CURLOPT_HEADERDATA was set to an object pointer + CURLOPT_ERRORBUFFER was set to an object pointer + CURLOPT_STDERR was set to an object pointer + + */ + + ret = curl_easy_perform(hnd); + + curl_easy_cleanup(hnd); + hnd = NULL; + + return (int)ret; +} +/**** End of sample code ****/ diff --git a/tests/data/data1481.c b/tests/data/data1481.c new file mode 100644 index 000000000000..b8741c0d95bc --- /dev/null +++ b/tests/data/data1481.c @@ -0,0 +1,49 @@ +/********* Sample code generated by the curl command line tool ********** + * All curl_easy_setopt() options are documented at: + * https://curl.se/libcurl/c/curl_easy_setopt.html + ************************************************************************/ +#include + +int main(int argc, char *argv[]) +{ + CURLcode ret; + CURL *hnd; + + hnd = curl_easy_init(); + curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L); + curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L); + curl_easy_setopt(hnd, CURLOPT_URL, "http://moo/"); + curl_easy_setopt(hnd, CURLOPT_PROXY, "http://%HOSTIP:%HTTPPORT"); + curl_easy_setopt(hnd, CURLOPT_USERAGENT, "curl/%VERSION"); + curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 50L); + curl_easy_setopt(hnd, CURLOPT_SSLVERSION, (long)(CURL_SSLVERSION_TLSv1_2 | CURL_SSLVERSION_MAX_TLSv1_3)); + curl_easy_setopt(hnd, CURLOPT_PROXY_SSLVERSION, (long)CURL_SSLVERSION_TLSv1); + curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L); + + /* Here is a list of options the curl code used that cannot get generated + as source easily. You may choose to either not use them or implement + them yourself. + + CURLOPT_DEBUGFUNCTION was set to a function pointer + CURLOPT_DEBUGDATA was set to an object pointer + CURLOPT_WRITEDATA was set to an object pointer + CURLOPT_WRITEFUNCTION was set to a function pointer + CURLOPT_READDATA was set to an object pointer + CURLOPT_READFUNCTION was set to a function pointer + CURLOPT_SEEKDATA was set to an object pointer + CURLOPT_SEEKFUNCTION was set to a function pointer + CURLOPT_HEADERFUNCTION was set to a function pointer + CURLOPT_HEADERDATA was set to an object pointer + CURLOPT_ERRORBUFFER was set to an object pointer + CURLOPT_STDERR was set to an object pointer + + */ + + ret = curl_easy_perform(hnd); + + curl_easy_cleanup(hnd); + hnd = NULL; + + return (int)ret; +} +/**** End of sample code ****/ diff --git a/tests/data/test1400 b/tests/data/test1400 index 9c54240c2f1a..5b7758fae8f2 100644 --- a/tests/data/test1400 +++ b/tests/data/test1400 @@ -4,7 +4,6 @@ HTTP HTTP GET --libcurl -notxml @@ -49,7 +48,6 @@ Accept: */* -s/(USERAGENT, \")[^\"]+/${1}stripped/ # CURLOPT_SSL_VERIFYPEER, SSH_KNOWNHOSTS and HTTP_VERSION vary with # CURLOPT_INTERLEAVEDATA requires RTSP protocol # configurations - just ignore them @@ -62,52 +60,7 @@ $_ = '' if /CURLOPT_INTERLEAVEDATA/ $_ = '' if /CURLOPT_TIMEOUT_MS/ -/********* Sample code generated by the curl command line tool ********** - * All curl_easy_setopt() options are documented at: - * https://curl.se/libcurl/c/curl_easy_setopt.html - ************************************************************************/ -#include - -int main(int argc, char *argv[]) -{ - CURLcode ret; - CURL *hnd; - - hnd = curl_easy_init(); - curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L); - curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L); - curl_easy_setopt(hnd, CURLOPT_URL, "http://%HOSTIP:%HTTPPORT/we/want/%TESTNUMBER"); - curl_easy_setopt(hnd, CURLOPT_USERAGENT, "stripped"); - curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 50L); - curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L); - - /* Here is a list of options the curl code used that cannot get generated - as source easily. You may choose to either not use them or implement - them yourself. - - CURLOPT_DEBUGFUNCTION was set to a function pointer - CURLOPT_DEBUGDATA was set to an object pointer - CURLOPT_WRITEDATA was set to an object pointer - CURLOPT_WRITEFUNCTION was set to a function pointer - CURLOPT_READDATA was set to an object pointer - CURLOPT_READFUNCTION was set to a function pointer - CURLOPT_SEEKDATA was set to an object pointer - CURLOPT_SEEKFUNCTION was set to a function pointer - CURLOPT_HEADERFUNCTION was set to a function pointer - CURLOPT_HEADERDATA was set to an object pointer - CURLOPT_ERRORBUFFER was set to an object pointer - CURLOPT_STDERR was set to an object pointer - - */ - - ret = curl_easy_perform(hnd); - - curl_easy_cleanup(hnd); - hnd = NULL; - - return (int)ret; -} -/**** End of sample code ****/ +%includetext %SRCDIR/data/data1400.c% diff --git a/tests/data/test1401 b/tests/data/test1401 index e2f51f39112b..87ed2e4543f6 100644 --- a/tests/data/test1401 +++ b/tests/data/test1401 @@ -7,7 +7,6 @@ HTTP Basic auth HTTP set cookie cookies --libcurl -notxml @@ -71,64 +70,7 @@ $_ = '' if /CURLOPT_SSLVERSION/ $_ = '' if /CURLOPT_TIMEOUT_MS/ -/********* Sample code generated by the curl command line tool ********** - * All curl_easy_setopt() options are documented at: - * https://curl.se/libcurl/c/curl_easy_setopt.html - ************************************************************************/ -#include - -int main(int argc, char *argv[]) -{ - CURLcode ret; - CURL *hnd; - struct curl_slist *slist1; - - slist1 = NULL; - slist1 = curl_slist_append(slist1, "X-Files: Mulder"); - slist1 = curl_slist_append(slist1, "X-Men: cyclops, iceman"); - - hnd = curl_easy_init(); - curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L); - curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L); - curl_easy_setopt(hnd, CURLOPT_URL, "http://%HOSTIP:%HTTPPORT/we/want/%TESTNUMBER"); - curl_easy_setopt(hnd, CURLOPT_USERPWD, "fake:user"); - curl_easy_setopt(hnd, CURLOPT_HTTPAUTH, (long)CURLAUTH_BASIC); - curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, slist1); - curl_easy_setopt(hnd, CURLOPT_USERAGENT, "MyUA"); - curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 50L); - curl_easy_setopt(hnd, CURLOPT_COOKIE, "chocolate=chip"); - curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L); - curl_easy_setopt(hnd, CURLOPT_PROTOCOLS_STR, "file,ftp,http"); - - /* Here is a list of options the curl code used that cannot get generated - as source easily. You may choose to either not use them or implement - them yourself. - - CURLOPT_DEBUGFUNCTION was set to a function pointer - CURLOPT_DEBUGDATA was set to an object pointer - CURLOPT_WRITEDATA was set to an object pointer - CURLOPT_WRITEFUNCTION was set to a function pointer - CURLOPT_READDATA was set to an object pointer - CURLOPT_READFUNCTION was set to a function pointer - CURLOPT_SEEKDATA was set to an object pointer - CURLOPT_SEEKFUNCTION was set to a function pointer - CURLOPT_HEADERFUNCTION was set to a function pointer - CURLOPT_HEADERDATA was set to an object pointer - CURLOPT_ERRORBUFFER was set to an object pointer - CURLOPT_STDERR was set to an object pointer - - */ - - ret = curl_easy_perform(hnd); - - curl_easy_cleanup(hnd); - hnd = NULL; - curl_slist_free_all(slist1); - slist1 = NULL; - - return (int)ret; -} -/**** End of sample code ****/ +%includetext %SRCDIR/data/data1401.c% diff --git a/tests/data/test1402 b/tests/data/test1402 index 77c0798da287..86eb102045e5 100644 --- a/tests/data/test1402 +++ b/tests/data/test1402 @@ -53,8 +53,6 @@ Content-Type: application/x-www-form-urlencoded foo=bar&baz=quux -# curl's default user-agent varies with version, libraries etc. -s/(USERAGENT, \")[^\"]+/${1}stripped/ # CURLOPT_SSL_VERIFYPEER, SSH_KNOWNHOSTS and HTTP_VERSION vary with # configurations - just ignore them $_ = '' if /CURLOPT_SSL_VERIFYPEER/ @@ -65,54 +63,7 @@ $_ = '' if /CURLOPT_SSLVERSION/ $_ = '' if /CURLOPT_TIMEOUT_MS/ -/********* Sample code generated by the curl command line tool ********** - * All curl_easy_setopt() options are documented at: - * https://curl.se/libcurl/c/curl_easy_setopt.html - ************************************************************************/ -#include - -int main(int argc, char *argv[]) -{ - CURLcode ret; - CURL *hnd; - - hnd = curl_easy_init(); - curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L); - curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L); - curl_easy_setopt(hnd, CURLOPT_URL, "http://%HOSTIP:%HTTPPORT/we/want/%TESTNUMBER"); - curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "foo=bar&baz=quux"); - curl_easy_setopt(hnd, CURLOPT_POSTFIELDSIZE_LARGE, (curl_off_t)16); - curl_easy_setopt(hnd, CURLOPT_USERAGENT, "stripped"); - curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 50L); - curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L); - - /* Here is a list of options the curl code used that cannot get generated - as source easily. You may choose to either not use them or implement - them yourself. - - CURLOPT_DEBUGFUNCTION was set to a function pointer - CURLOPT_DEBUGDATA was set to an object pointer - CURLOPT_WRITEDATA was set to an object pointer - CURLOPT_WRITEFUNCTION was set to a function pointer - CURLOPT_READDATA was set to an object pointer - CURLOPT_READFUNCTION was set to a function pointer - CURLOPT_SEEKDATA was set to an object pointer - CURLOPT_SEEKFUNCTION was set to a function pointer - CURLOPT_HEADERFUNCTION was set to a function pointer - CURLOPT_HEADERDATA was set to an object pointer - CURLOPT_ERRORBUFFER was set to an object pointer - CURLOPT_STDERR was set to an object pointer - - */ - - ret = curl_easy_perform(hnd); - - curl_easy_cleanup(hnd); - hnd = NULL; - - return (int)ret; -} -/**** End of sample code ****/ +%includetext %SRCDIR/data/data1402.c% diff --git a/tests/data/test1403 b/tests/data/test1403 index 94ada0fdd9cd..6627b70aa1f3 100644 --- a/tests/data/test1403 +++ b/tests/data/test1403 @@ -50,8 +50,6 @@ Accept: */* -# curl's default user-agent varies with version, libraries etc. -s/(USERAGENT, \")[^\"]+/${1}stripped/ # CURLOPT_SSL_VERIFYPEER, SSH_KNOWNHOSTS and HTTP_VERSION vary with # configurations - just ignore them $_ = '' if /CURLOPT_SSL_VERIFYPEER/ @@ -62,52 +60,7 @@ $_ = '' if /CURLOPT_SSLVERSION/ $_ = '' if /CURLOPT_TIMEOUT_MS/ -/********* Sample code generated by the curl command line tool ********** - * All curl_easy_setopt() options are documented at: - * https://curl.se/libcurl/c/curl_easy_setopt.html - ************************************************************************/ -#include - -int main(int argc, char *argv[]) -{ - CURLcode ret; - CURL *hnd; - - hnd = curl_easy_init(); - curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L); - curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L); - curl_easy_setopt(hnd, CURLOPT_URL, "http://%HOSTIP:%HTTPPORT/we/want/%TESTNUMBER\?foo=bar&baz=quux"); - curl_easy_setopt(hnd, CURLOPT_USERAGENT, "stripped"); - curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 50L); - curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L); - - /* Here is a list of options the curl code used that cannot get generated - as source easily. You may choose to either not use them or implement - them yourself. - - CURLOPT_DEBUGFUNCTION was set to a function pointer - CURLOPT_DEBUGDATA was set to an object pointer - CURLOPT_WRITEDATA was set to an object pointer - CURLOPT_WRITEFUNCTION was set to a function pointer - CURLOPT_READDATA was set to an object pointer - CURLOPT_READFUNCTION was set to a function pointer - CURLOPT_SEEKDATA was set to an object pointer - CURLOPT_SEEKFUNCTION was set to a function pointer - CURLOPT_HEADERFUNCTION was set to a function pointer - CURLOPT_HEADERDATA was set to an object pointer - CURLOPT_ERRORBUFFER was set to an object pointer - CURLOPT_STDERR was set to an object pointer - - */ - - ret = curl_easy_perform(hnd); - - curl_easy_cleanup(hnd); - hnd = NULL; - - return (int)ret; -} -/**** End of sample code ****/ +%includetext %SRCDIR/data/data1403.c% diff --git a/tests/data/test1404 b/tests/data/test1404 index 3ffcde893903..4471101246c0 100644 --- a/tests/data/test1404 +++ b/tests/data/test1404 @@ -6,7 +6,6 @@ HTTP HTTP FORMPOST HTTP file upload --libcurl -notxml @@ -95,8 +94,6 @@ dummy data ------------------------------9ef8d6205763--%CR -# curl's default user-agent varies with version, libraries etc. -s/(USERAGENT, \")[^\"]+/${1}stripped/ # CURLOPT_SSL_VERIFYPEER, SSH_KNOWNHOSTS and HTTP_VERSION vary with # configurations - just ignore them $_ = '' if /CURLOPT_SSL_VERIFYPEER/ @@ -109,89 +106,7 @@ $_ = '' if /CURLOPT_TIMEOUT_MS/ $_ = '' if /\/\* "value" \*\// -/********* Sample code generated by the curl command line tool ********** - * All curl_easy_setopt() options are documented at: - * https://curl.se/libcurl/c/curl_easy_setopt.html - ************************************************************************/ -#include - -int main(int argc, char *argv[]) -{ - CURLcode ret; - CURL *hnd; - curl_mime *mime1; - curl_mimepart *part1; - curl_mime *mime2; - curl_mimepart *part2; - struct curl_slist *slist1; - - mime1 = NULL; - mime2 = NULL; - slist1 = NULL; - slist1 = curl_slist_append(slist1, "X-testheader-1: header 1"); - slist1 = curl_slist_append(slist1, "X-testheader-2: header 2"); - - hnd = curl_easy_init(); - curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L); - curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L); - curl_easy_setopt(hnd, CURLOPT_URL, "http://%HOSTIP:%HTTPPORT/we/want/%TESTNUMBER"); - mime1 = curl_mime_init(hnd); - part1 = curl_mime_addpart(mime1); - curl_mime_data(part1, "value", CURL_ZERO_TERMINATED); - curl_mime_name(part1, "name"); - part1 = curl_mime_addpart(mime1); - mime2 = curl_mime_init(hnd); - part2 = curl_mime_addpart(mime2); - curl_mime_filedata(part2, "%LOGDIR/test%TESTNUMBER.txt"); - part2 = curl_mime_addpart(mime2); - curl_mime_filedata(part2, "%LOGDIR/test%TESTNUMBER.txt"); - curl_mime_encoder(part2, "8bit"); - curl_mime_type(part2, "magic/content"); - part2 = curl_mime_addpart(mime2); - curl_mime_filedata(part2, "%LOGDIR/test%TESTNUMBER.txt"); - curl_mime_headers(part2, slist1, 1); - slist1 = NULL; - curl_mime_subparts(part1, mime2); - mime2 = NULL; - curl_mime_name(part1, "file"); - curl_easy_setopt(hnd, CURLOPT_MIMEPOST, mime1); - curl_easy_setopt(hnd, CURLOPT_USERAGENT, "stripped"); - curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 50L); - curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L); - - /* Here is a list of options the curl code used that cannot get generated - as source easily. You may choose to either not use them or implement - them yourself. - - CURLOPT_DEBUGFUNCTION was set to a function pointer - CURLOPT_DEBUGDATA was set to an object pointer - CURLOPT_WRITEDATA was set to an object pointer - CURLOPT_WRITEFUNCTION was set to a function pointer - CURLOPT_READDATA was set to an object pointer - CURLOPT_READFUNCTION was set to a function pointer - CURLOPT_SEEKDATA was set to an object pointer - CURLOPT_SEEKFUNCTION was set to a function pointer - CURLOPT_HEADERFUNCTION was set to a function pointer - CURLOPT_HEADERDATA was set to an object pointer - CURLOPT_ERRORBUFFER was set to an object pointer - CURLOPT_STDERR was set to an object pointer - - */ - - ret = curl_easy_perform(hnd); - - curl_easy_cleanup(hnd); - hnd = NULL; - curl_mime_free(mime1); - mime1 = NULL; - curl_mime_free(mime2); - mime2 = NULL; - curl_slist_free_all(slist1); - slist1 = NULL; - - return (int)ret; -} -/**** End of sample code ****/ +%includetext %SRCDIR/data/data1404.c% diff --git a/tests/data/test1405 b/tests/data/test1405 index 84ccd6a0fb59..880f345e7270 100644 --- a/tests/data/test1405 +++ b/tests/data/test1405 @@ -6,7 +6,6 @@ FTP post-quote pre-quote --libcurl -notxml # Server-side @@ -62,74 +61,6 @@ RETR %TESTNUMBER NOOP 3 QUIT - -/********* Sample code generated by the curl command line tool ********** - * All curl_easy_setopt() options are documented at: - * https://curl.se/libcurl/c/curl_easy_setopt.html - ************************************************************************/ -#include - -int main(int argc, char *argv[]) -{ - CURLcode ret; - CURL *hnd; - struct curl_slist *slist1; - struct curl_slist *slist2; - struct curl_slist *slist3; - - slist1 = NULL; - slist1 = curl_slist_append(slist1, "NOOP 1"); - slist1 = curl_slist_append(slist1, "*FAIL"); - slist2 = NULL; - slist2 = curl_slist_append(slist2, "NOOP 3"); - slist3 = NULL; - slist3 = curl_slist_append(slist3, "NOOP 2"); - slist3 = curl_slist_append(slist3, "*FAIL HARD"); - - hnd = curl_easy_init(); - curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L); - curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L); - curl_easy_setopt(hnd, CURLOPT_URL, "ftp://%HOSTIP:%FTPPORT/%TESTNUMBER"); - curl_easy_setopt(hnd, CURLOPT_FTP_SKIP_PASV_IP, 1L); - curl_easy_setopt(hnd, CURLOPT_QUOTE, slist1); - curl_easy_setopt(hnd, CURLOPT_POSTQUOTE, slist2); - curl_easy_setopt(hnd, CURLOPT_PREQUOTE, slist3); - curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L); - - /* Here is a list of options the curl code used that cannot get generated - as source easily. You may choose to either not use them or implement - them yourself. - - CURLOPT_DEBUGFUNCTION was set to a function pointer - CURLOPT_DEBUGDATA was set to an object pointer - CURLOPT_WRITEDATA was set to an object pointer - CURLOPT_WRITEFUNCTION was set to a function pointer - CURLOPT_READDATA was set to an object pointer - CURLOPT_READFUNCTION was set to a function pointer - CURLOPT_SEEKDATA was set to an object pointer - CURLOPT_SEEKFUNCTION was set to a function pointer - CURLOPT_HEADERFUNCTION was set to a function pointer - CURLOPT_HEADERDATA was set to an object pointer - CURLOPT_ERRORBUFFER was set to an object pointer - CURLOPT_STDERR was set to an object pointer - - */ - - ret = curl_easy_perform(hnd); - - curl_easy_cleanup(hnd); - hnd = NULL; - curl_slist_free_all(slist1); - slist1 = NULL; - curl_slist_free_all(slist2); - slist2 = NULL; - curl_slist_free_all(slist3); - slist3 = NULL; - - return (int)ret; -} -/**** End of sample code ****/ - # CURLOPT_USERAGENT and CURLOPT_MAXREDIRS requires HTTP protocol # CURLOPT_INTERLEAVEDATA requires RTSP (HTTP) protocol @@ -146,5 +77,8 @@ $_ = '' if /CURLOPT_INTERLEAVEDATA/ $_ = '' if /CURLOPT_SSLVERSION/ $_ = '' if /CURLOPT_TIMEOUT_MS/ + +%includetext %SRCDIR/data/data1405.c% + diff --git a/tests/data/test1406 b/tests/data/test1406 index 776c880dad67..0dfa41839b17 100644 --- a/tests/data/test1406 +++ b/tests/data/test1406 @@ -5,7 +5,6 @@ SMTP --libcurl -notxml @@ -63,67 +62,9 @@ To: another body . - -/********* Sample code generated by the curl command line tool ********** - * All curl_easy_setopt() options are documented at: - * https://curl.se/libcurl/c/curl_easy_setopt.html - ************************************************************************/ -#include - -int main(int argc, char *argv[]) -{ - CURLcode ret; - CURL *hnd; - struct curl_slist *slist1; - - slist1 = NULL; - slist1 = curl_slist_append(slist1, "recipient.one@example.com"); - slist1 = curl_slist_append(slist1, "recipient.two@example.com"); - - hnd = curl_easy_init(); - curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L); - curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L); - curl_easy_setopt(hnd, CURLOPT_URL, "smtp://%HOSTIP:%SMTPPORT/%TESTNUMBER"); - curl_easy_setopt(hnd, CURLOPT_UPLOAD, 1L); - curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L); - curl_easy_setopt(hnd, CURLOPT_MAIL_FROM, "sender@example.com"); - curl_easy_setopt(hnd, CURLOPT_MAIL_RCPT, slist1); - curl_easy_setopt(hnd, CURLOPT_INFILESIZE_LARGE, (curl_off_t)38); - - /* Here is a list of options the curl code used that cannot get generated - as source easily. You may choose to either not use them or implement - them yourself. - - CURLOPT_DEBUGFUNCTION was set to a function pointer - CURLOPT_DEBUGDATA was set to an object pointer - CURLOPT_WRITEDATA was set to an object pointer - CURLOPT_WRITEFUNCTION was set to a function pointer - CURLOPT_READDATA was set to an object pointer - CURLOPT_READFUNCTION was set to a function pointer - CURLOPT_SEEKDATA was set to an object pointer - CURLOPT_SEEKFUNCTION was set to a function pointer - CURLOPT_HEADERFUNCTION was set to a function pointer - CURLOPT_HEADERDATA was set to an object pointer - CURLOPT_ERRORBUFFER was set to an object pointer - CURLOPT_STDERR was set to an object pointer - - */ - - ret = curl_easy_perform(hnd); - - curl_easy_cleanup(hnd); - hnd = NULL; - curl_slist_free_all(slist1); - slist1 = NULL; - - return (int)ret; -} -/**** End of sample code ****/ - # These options vary with configurations - just ignore them # CURLOPT_INTERLEAVEDATA requires RTSP (HTTP) protocol -$_ = '' if /CURLOPT_USERAGENT/ $_ = '' if /CURLOPT_MAXREDIRS/ $_ = '' if /CURLOPT_SSL_VERIFYPEER/ $_ = '' if /CURLOPT_SSH_KNOWNHOSTS/ @@ -133,5 +74,8 @@ $_ = '' if /CURLOPT_INTERLEAVEDATA/ $_ = '' if /CURLOPT_SSLVERSION/ $_ = '' if /CURLOPT_TIMEOUT_MS/ + +%includetext %SRCDIR/data/data1406.c% + diff --git a/tests/data/test1407 b/tests/data/test1407 index f767622b0b04..300b5efdaea3 100644 --- a/tests/data/test1407 +++ b/tests/data/test1407 @@ -6,7 +6,6 @@ POP3 Clear Text LIST --libcurl -notxml @@ -50,56 +49,9 @@ PASS secret LIST %TESTNUMBER QUIT - -/********* Sample code generated by the curl command line tool ********** - * All curl_easy_setopt() options are documented at: - * https://curl.se/libcurl/c/curl_easy_setopt.html - ************************************************************************/ -#include - -int main(int argc, char *argv[]) -{ - CURLcode ret; - CURL *hnd; - - hnd = curl_easy_init(); - curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L); - curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L); - curl_easy_setopt(hnd, CURLOPT_URL, "pop3://%HOSTIP:%POP3PORT/%TESTNUMBER"); - curl_easy_setopt(hnd, CURLOPT_DIRLISTONLY, 1L); - curl_easy_setopt(hnd, CURLOPT_USERPWD, "user:secret"); - curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L); - - /* Here is a list of options the curl code used that cannot get generated - as source easily. You may choose to either not use them or implement - them yourself. - - CURLOPT_DEBUGFUNCTION was set to a function pointer - CURLOPT_DEBUGDATA was set to an object pointer - CURLOPT_WRITEDATA was set to an object pointer - CURLOPT_WRITEFUNCTION was set to a function pointer - CURLOPT_READDATA was set to an object pointer - CURLOPT_READFUNCTION was set to a function pointer - CURLOPT_SEEKDATA was set to an object pointer - CURLOPT_SEEKFUNCTION was set to a function pointer - CURLOPT_HEADERFUNCTION was set to a function pointer - CURLOPT_HEADERDATA was set to an object pointer - CURLOPT_ERRORBUFFER was set to an object pointer - CURLOPT_STDERR was set to an object pointer - - */ - - ret = curl_easy_perform(hnd); - - curl_easy_cleanup(hnd); - hnd = NULL; - - return (int)ret; -} -/**** End of sample code ****/ - # These options vary with configurations - just ignore them +# CURLOPT_USERAGENT and CURLOPT_MAXREDIRS requires HTTP protocol # CURLOPT_INTERLEAVEDATA requires RTSP (HTTP) protocol $_ = '' if /CURLOPT_USERAGENT/ $_ = '' if /CURLOPT_MAXREDIRS/ @@ -111,5 +63,8 @@ $_ = '' if /CURLOPT_INTERLEAVEDATA/ $_ = '' if /CURLOPT_SSLVERSION/ $_ = '' if /CURLOPT_TIMEOUT_MS/ + +%includetext %SRCDIR/data/data1407.c% + diff --git a/tests/data/test1420 b/tests/data/test1420 index 22d918acf521..530cf985bd2c 100644 --- a/tests/data/test1420 +++ b/tests/data/test1420 @@ -6,7 +6,6 @@ IMAP Clear Text FETCH --libcurl -notxml @@ -56,57 +55,9 @@ A003 SELECT %TESTNUMBER A004 FETCH 1 BODY[] A005 LOGOUT - -/********* Sample code generated by the curl command line tool ********** - * All curl_easy_setopt() options are documented at: - * https://curl.se/libcurl/c/curl_easy_setopt.html - ************************************************************************/ -#include - -int main(int argc, char *argv[]) -{ - CURLcode ret; - CURL *hnd; - - hnd = curl_easy_init(); - curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L); - curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L); - curl_easy_setopt(hnd, CURLOPT_URL, "imap://%HOSTIP:%IMAPPORT/%TESTNUMBER/;MAILINDEX=1"); - curl_easy_setopt(hnd, CURLOPT_USERPWD, "user:secret"); - curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L); - - /* Here is a list of options the curl code used that cannot get generated - as source easily. You may choose to either not use them or implement - them yourself. - - CURLOPT_DEBUGFUNCTION was set to a function pointer - CURLOPT_DEBUGDATA was set to an object pointer - CURLOPT_WRITEDATA was set to an object pointer - CURLOPT_WRITEFUNCTION was set to a function pointer - CURLOPT_READDATA was set to an object pointer - CURLOPT_READFUNCTION was set to a function pointer - CURLOPT_SEEKDATA was set to an object pointer - CURLOPT_SEEKFUNCTION was set to a function pointer - CURLOPT_HEADERFUNCTION was set to a function pointer - CURLOPT_HEADERDATA was set to an object pointer - CURLOPT_ERRORBUFFER was set to an object pointer - CURLOPT_STDERR was set to an object pointer - - */ - - ret = curl_easy_perform(hnd); - - curl_easy_cleanup(hnd); - hnd = NULL; - - return (int)ret; -} -/**** End of sample code ****/ - # These options vary with configurations - just ignore them # CURLOPT_INTERLEAVEDATA requires RTSP (HTTP) protocol -$_ = '' if /CURLOPT_USERAGENT/ $_ = '' if /CURLOPT_MAXREDIRS/ $_ = '' if /CURLOPT_SSL_VERIFYPEER/ $_ = '' if /CURLOPT_SSH_KNOWNHOSTS/ @@ -115,5 +66,8 @@ $_ = '' if /CURLOPT_INTERLEAVEDATA/ $_ = '' if /CURLOPT_SSLVERSION/ $_ = '' if /CURLOPT_TIMEOUT_MS/ + +%includetext %SRCDIR/data/data1420.c% + diff --git a/tests/data/test1465 b/tests/data/test1465 index b9e85535bac0..0026ae383122 100644 --- a/tests/data/test1465 +++ b/tests/data/test1465 @@ -4,7 +4,6 @@ HTTP HTTP POST --libcurl -notxml @@ -57,7 +56,6 @@ Content-Type: application/x-www-form-urlencoded %hex[ab%81cd%00e\"?%0D%0A%09%01fghi%1Ajklm%FD]hex% - # CURLOPT_SSL_VERIFYPEER, SSH_KNOWNHOSTS and HTTP_VERSION vary with # configurations - just ignore them $_ = '' if /CURLOPT_SSL_VERIFYPEER/ @@ -68,54 +66,7 @@ $_ = '' if /CURLOPT_SSLVERSION/ $_ = '' if /CURLOPT_TIMEOUT_MS/ -/********* Sample code generated by the curl command line tool ********** - * All curl_easy_setopt() options are documented at: - * https://curl.se/libcurl/c/curl_easy_setopt.html - ************************************************************************/ -#include - -int main(int argc, char *argv[]) -{ - CURLcode ret; - CURL *hnd; - - hnd = curl_easy_init(); - curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L); - curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L); - curl_easy_setopt(hnd, CURLOPT_URL, "http://%HOSTIP:%HTTPPORT/we/want/%TESTNUMBER"); - curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "ab\201cd\000e\\\"\?\r\n\t\001fghi\x1ajklm\xfd"); - curl_easy_setopt(hnd, CURLOPT_POSTFIELDSIZE_LARGE, (curl_off_t)24); - curl_easy_setopt(hnd, CURLOPT_USERAGENT, "curl/%VERSION"); - curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 50L); - curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L); - - /* Here is a list of options the curl code used that cannot get generated - as source easily. You may choose to either not use them or implement - them yourself. - - CURLOPT_DEBUGFUNCTION was set to a function pointer - CURLOPT_DEBUGDATA was set to an object pointer - CURLOPT_WRITEDATA was set to an object pointer - CURLOPT_WRITEFUNCTION was set to a function pointer - CURLOPT_READDATA was set to an object pointer - CURLOPT_READFUNCTION was set to a function pointer - CURLOPT_SEEKDATA was set to an object pointer - CURLOPT_SEEKFUNCTION was set to a function pointer - CURLOPT_HEADERFUNCTION was set to a function pointer - CURLOPT_HEADERDATA was set to an object pointer - CURLOPT_ERRORBUFFER was set to an object pointer - CURLOPT_STDERR was set to an object pointer - - */ - - ret = curl_easy_perform(hnd); - - curl_easy_cleanup(hnd); - hnd = NULL; - - return (int)ret; -} -/**** End of sample code ****/ +%includetext %SRCDIR/data/data1465.c% diff --git a/tests/data/test1481 b/tests/data/test1481 index 30b6d420e1e7..a3e259545047 100644 --- a/tests/data/test1481 +++ b/tests/data/test1481 @@ -4,7 +4,6 @@ HTTP HTTP GET --libcurl -notxml @@ -52,7 +51,6 @@ Proxy-Connection: Keep-Alive -s/(USERAGENT, \")[^\"]+/${1}stripped/ # CURLOPT_SSL_VERIFYPEER, SSH_KNOWNHOSTS and HTTP_VERSION vary with # CURLOPT_INTERLEAVEDATA requires RTSP protocol # configurations - just ignore them @@ -64,55 +62,7 @@ $_ = '' if /CURLOPT_INTERLEAVEDATA/ $_ = '' if /CURLOPT_TIMEOUT_MS/ -/********* Sample code generated by the curl command line tool ********** - * All curl_easy_setopt() options are documented at: - * https://curl.se/libcurl/c/curl_easy_setopt.html - ************************************************************************/ -#include - -int main(int argc, char *argv[]) -{ - CURLcode ret; - CURL *hnd; - - hnd = curl_easy_init(); - curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L); - curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L); - curl_easy_setopt(hnd, CURLOPT_URL, "http://moo/"); - curl_easy_setopt(hnd, CURLOPT_PROXY, "http://%HOSTIP:%HTTPPORT"); - curl_easy_setopt(hnd, CURLOPT_USERAGENT, "stripped"); - curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 50L); - curl_easy_setopt(hnd, CURLOPT_SSLVERSION, (long)(CURL_SSLVERSION_TLSv1_2 | CURL_SSLVERSION_MAX_TLSv1_3)); - curl_easy_setopt(hnd, CURLOPT_PROXY_SSLVERSION, (long)CURL_SSLVERSION_TLSv1); - curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L); - - /* Here is a list of options the curl code used that cannot get generated - as source easily. You may choose to either not use them or implement - them yourself. - - CURLOPT_DEBUGFUNCTION was set to a function pointer - CURLOPT_DEBUGDATA was set to an object pointer - CURLOPT_WRITEDATA was set to an object pointer - CURLOPT_WRITEFUNCTION was set to a function pointer - CURLOPT_READDATA was set to an object pointer - CURLOPT_READFUNCTION was set to a function pointer - CURLOPT_SEEKDATA was set to an object pointer - CURLOPT_SEEKFUNCTION was set to a function pointer - CURLOPT_HEADERFUNCTION was set to a function pointer - CURLOPT_HEADERDATA was set to an object pointer - CURLOPT_ERRORBUFFER was set to an object pointer - CURLOPT_STDERR was set to an object pointer - - */ - - ret = curl_easy_perform(hnd); - - curl_easy_cleanup(hnd); - hnd = NULL; - - return (int)ret; -} -/**** End of sample code ****/ +%includetext %SRCDIR/data/data1481.c% diff --git a/tests/runner.pm b/tests/runner.pm index 10be04bd4b49..97c62023dddb 100644 --- a/tests/runner.pm +++ b/tests/runner.pm @@ -101,6 +101,8 @@ use testutil qw( logmsg runclient exerunner + subtextfile + subchars subbase64 subsha256base64file substrippemfile @@ -367,6 +369,10 @@ sub prepro { $data_crlf = ""; } subvariables(\$s, $testnum, "%"); + if(subtextfile(\$s)) { + subvariables(\$s, $testnum, "%"); + } + subchars(\$s); subbase64(\$s); subsha256base64file(\$s); substrippemfile(\$s); diff --git a/tests/testutil.pm b/tests/testutil.pm index 4666770f072d..80479a0c7524 100644 --- a/tests/testutil.pm +++ b/tests/testutil.pm @@ -38,6 +38,8 @@ BEGIN { runclientoutput setlogfunc exerunner + subtextfile + subchars subbase64 subnewlines subsha256base64file @@ -110,6 +112,25 @@ sub includefile { return join("", @a); } +sub subtextfile { + my ($thing) = @_; + + my $count = ($$thing =~ s/%includetext ([^%]*)%[\n\r]+/includefile($1, 1)/ge); + + return $count > 0; +} + +sub subchars { + my ($thing) = @_; + + $$thing =~ s/%SP/ /g; # space + $$thing =~ s/%TAB/\t/g; # horizontal tab + $$thing =~ s/%CR/\r/g; # carriage return aka \r aka 0x0d + $$thing =~ s/%LT//g; + $$thing =~ s/%AMP/&/g; +} + sub subbase64 { my ($thing) = @_; @@ -150,16 +171,6 @@ sub subbase64 { $$thing =~ s/%%DAYS%%/%alternatives[$d,$d2]/; } - # include a file, expand space macros - $$thing =~ s/%includetext ([^%]*)%[\n\r]+/includefile($1, 1)/ge; - - $$thing =~ s/%SP/ /g; # space - $$thing =~ s/%TAB/\t/g; # horizontal tab - $$thing =~ s/%CR/\r/g; # carriage return aka \r aka 0x0d - $$thing =~ s/%LT//g; - $$thing =~ s/%AMP/&/g; - # include a file $$thing =~ s/%include ([^%]*)%[\n\r]+/includefile($1, 0)/ge; } From cce660693ceddd6006b5775de8e97f1d5a6434d7 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Tue, 9 Dec 2025 01:46:06 +0100 Subject: [PATCH 238/415] tests/data: use more `%TESTNUMBER` macro for previous patch Follow-up to d75716e4e55c7074566f48d8c03bfd721461e105 #19799 Cherry-picked from #19882 Closes #19885 --- tests/data/test1400 | 2 +- tests/data/test1401 | 2 +- tests/data/test1402 | 2 +- tests/data/test1403 | 2 +- tests/data/test1404 | 2 +- tests/data/test1405 | 2 +- tests/data/test1406 | 2 +- tests/data/test1407 | 2 +- tests/data/test1420 | 2 +- tests/data/test1465 | 2 +- tests/data/test1481 | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/data/test1400 b/tests/data/test1400 index 5b7758fae8f2..289f35720891 100644 --- a/tests/data/test1400 +++ b/tests/data/test1400 @@ -60,7 +60,7 @@ $_ = '' if /CURLOPT_INTERLEAVEDATA/ $_ = '' if /CURLOPT_TIMEOUT_MS/ -%includetext %SRCDIR/data/data1400.c% +%includetext %SRCDIR/data/data%TESTNUMBER.c% diff --git a/tests/data/test1401 b/tests/data/test1401 index 87ed2e4543f6..c66517c414c7 100644 --- a/tests/data/test1401 +++ b/tests/data/test1401 @@ -70,7 +70,7 @@ $_ = '' if /CURLOPT_SSLVERSION/ $_ = '' if /CURLOPT_TIMEOUT_MS/ -%includetext %SRCDIR/data/data1401.c% +%includetext %SRCDIR/data/data%TESTNUMBER.c% diff --git a/tests/data/test1402 b/tests/data/test1402 index 86eb102045e5..401daa3ba5b7 100644 --- a/tests/data/test1402 +++ b/tests/data/test1402 @@ -63,7 +63,7 @@ $_ = '' if /CURLOPT_SSLVERSION/ $_ = '' if /CURLOPT_TIMEOUT_MS/ -%includetext %SRCDIR/data/data1402.c% +%includetext %SRCDIR/data/data%TESTNUMBER.c% diff --git a/tests/data/test1403 b/tests/data/test1403 index 6627b70aa1f3..2a9cba0bed15 100644 --- a/tests/data/test1403 +++ b/tests/data/test1403 @@ -60,7 +60,7 @@ $_ = '' if /CURLOPT_SSLVERSION/ $_ = '' if /CURLOPT_TIMEOUT_MS/ -%includetext %SRCDIR/data/data1403.c% +%includetext %SRCDIR/data/data%TESTNUMBER.c% diff --git a/tests/data/test1404 b/tests/data/test1404 index 4471101246c0..173214c8c120 100644 --- a/tests/data/test1404 +++ b/tests/data/test1404 @@ -106,7 +106,7 @@ $_ = '' if /CURLOPT_TIMEOUT_MS/ $_ = '' if /\/\* "value" \*\// -%includetext %SRCDIR/data/data1404.c% +%includetext %SRCDIR/data/data%TESTNUMBER.c% diff --git a/tests/data/test1405 b/tests/data/test1405 index 880f345e7270..5464d6ad316e 100644 --- a/tests/data/test1405 +++ b/tests/data/test1405 @@ -78,7 +78,7 @@ $_ = '' if /CURLOPT_SSLVERSION/ $_ = '' if /CURLOPT_TIMEOUT_MS/ -%includetext %SRCDIR/data/data1405.c% +%includetext %SRCDIR/data/data%TESTNUMBER.c% diff --git a/tests/data/test1406 b/tests/data/test1406 index 0dfa41839b17..83319c07d9e7 100644 --- a/tests/data/test1406 +++ b/tests/data/test1406 @@ -75,7 +75,7 @@ $_ = '' if /CURLOPT_SSLVERSION/ $_ = '' if /CURLOPT_TIMEOUT_MS/ -%includetext %SRCDIR/data/data1406.c% +%includetext %SRCDIR/data/data%TESTNUMBER.c% diff --git a/tests/data/test1407 b/tests/data/test1407 index 300b5efdaea3..b2da0479ae42 100644 --- a/tests/data/test1407 +++ b/tests/data/test1407 @@ -64,7 +64,7 @@ $_ = '' if /CURLOPT_SSLVERSION/ $_ = '' if /CURLOPT_TIMEOUT_MS/ -%includetext %SRCDIR/data/data1407.c% +%includetext %SRCDIR/data/data%TESTNUMBER.c% diff --git a/tests/data/test1420 b/tests/data/test1420 index 530cf985bd2c..6194d81e8119 100644 --- a/tests/data/test1420 +++ b/tests/data/test1420 @@ -67,7 +67,7 @@ $_ = '' if /CURLOPT_SSLVERSION/ $_ = '' if /CURLOPT_TIMEOUT_MS/ -%includetext %SRCDIR/data/data1420.c% +%includetext %SRCDIR/data/data%TESTNUMBER.c% diff --git a/tests/data/test1465 b/tests/data/test1465 index 0026ae383122..58f202499f4e 100644 --- a/tests/data/test1465 +++ b/tests/data/test1465 @@ -66,7 +66,7 @@ $_ = '' if /CURLOPT_SSLVERSION/ $_ = '' if /CURLOPT_TIMEOUT_MS/ -%includetext %SRCDIR/data/data1465.c% +%includetext %SRCDIR/data/data%TESTNUMBER.c% diff --git a/tests/data/test1481 b/tests/data/test1481 index a3e259545047..490206895595 100644 --- a/tests/data/test1481 +++ b/tests/data/test1481 @@ -62,7 +62,7 @@ $_ = '' if /CURLOPT_INTERLEAVEDATA/ $_ = '' if /CURLOPT_TIMEOUT_MS/ -%includetext %SRCDIR/data/data1481.c% +%includetext %SRCDIR/data/data%TESTNUMBER.c% From 86f5bd3c6e67809e4feac4df42e422c54277df05 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Thu, 21 Aug 2025 13:59:46 +0200 Subject: [PATCH 239/415] curl_setup.h: fix `FMT_SOCKET_T` to be unsigned on Windows To match the Windows socket type. Ref: https://learn.microsoft.com/windows/win32/winsock/socket-data-type-2 Cherry-picked from #18343 Closes #19881 --- lib/curl_setup.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/curl_setup.h b/lib/curl_setup.h index c4be90b655e0..829650aee4d4 100644 --- a/lib/curl_setup.h +++ b/lib/curl_setup.h @@ -519,9 +519,13 @@ #endif #if SIZEOF_CURL_SOCKET_T < 8 +#ifdef _WIN32 +# define FMT_SOCKET_T "u" +#else # define FMT_SOCKET_T "d" -#elif defined(__MINGW32__) -# define FMT_SOCKET_T "zd" +#endif +#elif defined(_WIN32) +# define FMT_SOCKET_T "zu" #else # define FMT_SOCKET_T "qd" #endif From bf70031518ee1e0d222246edf308585fb692371b Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 9 Dec 2025 09:23:35 +0100 Subject: [PATCH 240/415] RELEASE-NOTES: synced --- RELEASE-NOTES | 64 ++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 53 insertions(+), 11 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index af81fffb902f..d34291718ae4 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -4,7 +4,7 @@ curl and libcurl 8.18.0 Command line options: 273 curl_easy_setopt() options: 308 Public functions in libcurl: 100 - Contributors: 3556 + Contributors: 3557 This release includes the following changes: @@ -17,10 +17,12 @@ This release includes the following changes: This release includes the following bugfixes: o _PROGRESS.md: add the E unit, mention kibibyte [24] + o altsvc: make it one malloc instead of three per entry [266] o AmigaOS: increase minimum stack size for tool_main [137] o apple-sectrust: always ask when `native_ca_store` is in use [162] o asyn-ares: handle Curl_dnscache_mk_entry() OOM error [199] o asyn-ares: remove hostname free on OOM [122] + o asyn-thrdd: fix Curl_async_getaddrinfo() on systems without getaddrinfo [265] o asyn-thrdd: release rrname if ares_init_options fails [41] o auth: always treat Curl_auth_ntlm_get() returning NULL as OOM [186] o autotools: add nettle library detection via pkg-config (for GnuTLS) [178] @@ -51,8 +53,11 @@ This release includes the following bugfixes: o conncontrol: reuse handling [170] o connect: reshuffle Curl_timeleft_ms to avoid 'redundant condition' [100] o connection: attached transfer count [228] + o cookie: allocate the main struct once cookie is fine [259] + o cookie: only keep and use the canonical cleaned up path [256] o cookie: propagate errors better, cleanup the internal API [118] o cookie: return error on OOM [131] + o cookie: when parsing a cookie header, delay all allocations until okay [258] o cshutdn: acknowledge FD_SETSIZE for shutdown descriptors [25] o curl: fix progress meter in parallel mode [15] o curl_fopen: do not pass invalid mode flags to `open()` on Windows [84] @@ -77,6 +82,7 @@ This release includes the following bugfixes: o digest_sspi: fix a memory leak on error path [149] o digest_sspi: properly free sspi identity [12] o DISTROS.md: add OpenBSD [126] + o DISTROS: fix a Mageia URL o DISTROS: remove broken URLs for buildroot o doc: some returned in-memory data may not be altered [196] o docs/libcurl: fix C formatting nits [207] @@ -85,6 +91,7 @@ This release includes the following bugfixes: o docs: mention umask need when curl creates files [56] o docs: remove dead URLs o docs: spell it Rustls with a capital R [181] + o docs: switch more URLs to https:// [229] o docs: use .example URLs for proxies o example: fix formatting nits [232] o examples/crawler: fix variable [92] @@ -95,23 +102,29 @@ This release includes the following bugfixes: o examples: tidy-up headers and includes [138] o FAQ: fix hackerone URL o file: do not pass invalid mode flags to `open()` on upload (Windows) [83] + o formdata: validate callback is non-NULL before use [267] + o ftp: make EPRT connections non-blocking [268] o ftp: refactor a piece of code by merging the repeated part [40] o ftp: remove #ifdef for define that is always defined [76] o getinfo: improve perf in debug mode [99] + o gnutls: add PROFILE_MEDIUM as default [233] o gnutls: report accurate error when TLS-SRP is not built-in [18] o gtls: add return checks and optimize the code [2] o gtls: skip session resumption when verifystatus is set o h2/h3: handle methods with spaces [146] + o hostcheck: fail wildcard match if host starts with a dot [235] o hostip: don't store negative lookup on OOM [61] o hostip: make more functions return CURLcode [202] o hostip: only store negative response for CURLE_COULDNT_RESOLVE_HOST [183] o hsts: propagate and error out correctly on OOM [130] + o hsts: use one malloc instead of two per entry [263] o http: acknowledge OOM errors from Curl_input_ntlm [185] o http: avoid two strdup()s and do minor simplifications [144] o http: error on OOM when creating range header [59] o http: fix OOM exit in Curl_http_follow [179] o http: handle oom error from Curl_input_digest() [192] o http: replace atoi use in Curl_http_follow with curlx_str_number [65] + o http: return OOM errors from hsts properly [262] o http: the :authority header should never contain user+password [147] o idn: avoid allocations and wcslen on Windows [247] o idn: fix memory leak in `win32_ascii_to_idn()` [173] @@ -147,7 +160,9 @@ This release includes the following bugfixes: o mbedtls: fix potential use of uninitialized `nread` [8] o mbedtls: sync format across log messages [213] o mbedtls_threadlock: avoid calloc, use array [244] + o mdlinkcheck: ignore IP numbers, allow '@' in raw URLs o memdebug: add mutex for thread safety [184] + o mk-ca-bundle.md: the file format docs URL is permaredirected [188] o mk-ca-bundle.pl: default to SHA256 fingerprints with `-t` option [73] o mk-ca-bundle.pl: use `open()` with argument list to replace backticks [71] o mqtt: reject overly big messages [39] @@ -156,6 +171,7 @@ This release includes the following bugfixes: o multibyte: limit `curlx_convert_*wchar*()` functions to Unicode builds [135] o ngtcp2+openssl: fix leak of session [172] o ngtcp2: remove the unused Curl_conn_is_ngtcp2 function [85] + o noproxy: fix build on systems without IPv6 [264] o noproxy: fix ipv6 handling [239] o noproxy: replace atoi with curlx_str_number [67] o openssl: exit properly on OOM when getting certchain [133] @@ -180,6 +196,7 @@ This release includes the following bugfixes: o rtmp: fix double-free on URL parse errors [27] o rtmp: precaution for a potential integer truncation [54] o rtmp: stop redefining `setsockopt` system symbol on Windows [211] + o runner.pm: run memanalyzer as a Perl module [260] o runtests: detect bad libssh differently for test 1459 [11] o runtests: drop Python 2 support remains [45] o runtests: enable torture testing with threaded resolver [176] @@ -203,15 +220,18 @@ This release includes the following bugfixes: o speedlimit: also reset on send unpausing [197] o src: fix formatting nits [246] o ssh: tracing and better pollset handling [230] + o sspi: fix memory leaks on error paths in `Curl_create_sspi_identity()` [237] o sws: fix binding to unix socket on Windows [214] o telnet: replace atoi for BINARY handling with curlx_str_number [66] o TEST-SUITE.md: correct the man page's path [136] o test07_22: fix flakiness [95] + o test1475: consistently use %CR in headers [234] o test1498: disable 'HTTP PUT from stdin' test on Windows [115] o test2045: replace HTML multi-line comment markup with `#` comments [36] o test3207: enable memdebug for this test again [249] o test363: delete stray character (typo) from a section tag [52] o test787: fix possible typo `&` -> `%` in curl option [241] + o tests/data: move `--libcurl` output to external data files [34] o tests/data: replace hard-coded test numbers with `%TESTNUMBER` [33] o tests/data: support using native newlines on disk, drop `.gitattributes` [91] o tests/server: do not fall back to original data file in `test2fopen()` [32] @@ -223,6 +243,7 @@ This release includes the following bugfixes: o tftpd: fix/tidy up `open()` mode flags [57] o tidy-up: avoid `(())`, clang-format fixes and more [141] o tidy-up: move `CURL_UNCONST()` out from macro `curl_unicodefree()` [121] + o tidy-up: URLs [182] o TODO: remove a mandriva.com reference o tool: consider (some) curl_easy_setopt errors fatal [7] o tool: log when loading .curlrc in verbose mode [191] @@ -260,6 +281,7 @@ This release includes the following bugfixes: o wolfssl: avoid NULL dereference in OOM situation [77] o wolfssl: fix a potential memory leak of session [6] o wolfssl: fix cipher list, skip 5.8.4 regression [117] + o wolfssl: fix possible assert with `!HAVE_NO_EX` wolfSSL builds [261] o wolfssl: simplify wssl_send_earlydata [111] This release includes the following known bugs: @@ -284,16 +306,16 @@ advice from friends like these: Aleksandr Sergeev, Aleksei Bavshin, Andrew Kirillov, BANADDA, boingball, Brad King, bttrfl on github, Christian Schmitz, Dan Fandrich, - Daniel McCarney, Daniel Stenberg, Deniz Parlak, Fd929c2CE5fA on github, - ffath-vo on github, Georg Schulz-Allgaier, Gisle Vanem, Greg Hudson, - Jiyong Yang, Juliusz Sosinowicz, Kai Pastor, Leonardo Taccari, - letshack9707 on hackerone, Marc Aldorasi, Marcel Raad, Max Faxälv, - nait-furry, ncaklovic on github, Nick Korepanov, Omdahake on github, - Patrick Monnerat, pelioro on hackerone, Ray Satiro, renovate[bot], - Samuel Henrique, st751228051 on github, Stanislav Fort, Stefan Eissing, - Sunny, Theo Buehler, Thomas Klausner, Viktor Szakats, Wesley Moore, - Xiaoke Wang, Yedaya Katsman - (44 contributors) + Daniel McCarney, Daniel Stenberg, Denis Goleshchikhin, Deniz Parlak, + dependabot[bot], Fabian Keil, Fd929c2CE5fA on github, ffath-vo on github, + Georg Schulz-Allgaier, Gisle Vanem, Greg Hudson, Harry Sintonen, Jiyong Yang, + Juliusz Sosinowicz, Kai Pastor, Leonardo Taccari, letshack9707 on hackerone, + Marc Aldorasi, Marcel Raad, Max Faxälv, nait-furry, ncaklovic on github, + Nick Korepanov, Omdahake on github, Patrick Monnerat, pelioro on hackerone, + Ray Satiro, renovate[bot], Robert W. Van Kirk, Samuel Henrique, + st751228051 on github, Stanislav Fort, Stefan Eissing, Sunny, Theo Buehler, + Thomas Klausner, Viktor Szakats, Wesley Moore, Xiaoke Wang, Yedaya Katsman + (49 contributors) References to bug reports and discussions on issues: @@ -330,6 +352,7 @@ References to bug reports and discussions on issues: [31] = https://curl.se/bug/?i=19716 [32] = https://curl.se/bug/?i=19429 [33] = https://curl.se/bug/?i=19427 + [34] = https://curl.se/bug/?i=19799 [35] = https://curl.se/bug/?i=19420 [36] = https://curl.se/bug/?i=19498 [37] = https://curl.se/bug/?i=19419 @@ -477,11 +500,13 @@ References to bug reports and discussions on issues: [179] = https://curl.se/bug/?i=19705 [180] = https://curl.se/bug/?i=19704 [181] = https://curl.se/bug/?i=19702 + [182] = https://curl.se/bug/?i=19879 [183] = https://curl.se/bug/?i=19701 [184] = https://curl.se/bug/?i=19785 [185] = https://curl.se/bug/?i=19781 [186] = https://curl.se/bug/?i=19782 [187] = https://curl.se/bug/?i=19164 + [188] = https://curl.se/bug/?i=19877 [189] = https://curl.se/bug/?i=19604 [190] = https://curl.se/bug/?i=19269 [191] = https://curl.se/bug/?i=19663 @@ -518,9 +543,14 @@ References to bug reports and discussions on issues: [225] = https://curl.se/bug/?i=19754 [226] = https://curl.se/bug/?i=19751 [228] = https://curl.se/bug/?i=19836 + [229] = https://curl.se/bug/?i=19872 [230] = https://curl.se/bug/?i=19745 [232] = https://curl.se/bug/?i=19746 + [233] = https://curl.se/bug/?i=19853 + [234] = https://curl.se/bug/?i=19870 + [235] = https://curl.se/bug/?i=19869 [236] = https://curl.se/bug/?i=19830 + [237] = https://curl.se/bug/?i=19866 [238] = https://curl.se/bug/?i=19786 [239] = https://curl.se/bug/?i=19828 [240] = https://curl.se/bug/?i=19829 @@ -538,4 +568,16 @@ References to bug reports and discussions on issues: [253] = https://curl.se/bug/?i=19800 [254] = https://curl.se/bug/?i=19808 [255] = https://curl.se/bug/?i=19803 + [256] = https://curl.se/bug/?i=19864 [257] = https://curl.se/bug/?i=19802 + [258] = https://curl.se/bug/?i=19864 + [259] = https://curl.se/bug/?i=19864 + [260] = https://curl.se/bug/?i=19863 + [261] = https://curl.se/bug/?i=19816 + [262] = https://curl.se/bug/?i=19862 + [263] = https://curl.se/bug/?i=19861 + [264] = https://curl.se/bug/?i=19860 + [265] = https://github.com/curl/curl/commit/ce06fe7771052549ff430c86173b2eaca91f8a9c#r172215567 + [266] = https://curl.se/bug/?i=19857 + [267] = https://curl.se/bug/?i=19858 + [268] = https://curl.se/bug/?i=19753 From 70d71e8761843ac81e388f15b373bd025d77a4dc Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Tue, 9 Dec 2025 01:15:29 +0100 Subject: [PATCH 241/415] tests/data: move section data to external files To make the test files XML-compliant, and the expected results possibly easier to manage by keeping them in `.md`, `.html`, `.1` and `.txt` files. Non-XML-compliant files are down to 31 (1.6%) after this patch. Closes #19882 --- .github/scripts/pyspelling.yaml | 2 +- .github/scripts/spacecheck.pl | 1 + tests/data/Makefile.am | 7 +- tests/data/data1461.txt | 21 +++ tests/data/data1463.txt | 5 + tests/data/data1705-1.md | 11 ++ tests/data/data1705-2.md | 40 +++++ tests/data/data1705-3.md | 48 ++++++ tests/data/data1705-4.md | 22 +++ tests/data/data1705-stdout.1 | 126 ++++++++++++++++ tests/data/data1706-1.md | 11 ++ tests/data/data1706-2.md | 36 +++++ tests/data/data1706-3.md | 48 ++++++ tests/data/data1706-4.md | 22 +++ tests/data/data1706-stdout.txt | 116 +++++++++++++++ tests/data/data320.html | 20 +++ tests/data/test1461 | 23 +-- tests/data/test1463 | 7 +- tests/data/test1464 | 6 +- tests/data/test1705 | 253 +------------------------------- tests/data/test1706 | 239 +----------------------------- tests/data/test320 | 26 +--- 22 files changed, 547 insertions(+), 543 deletions(-) create mode 100644 tests/data/data1461.txt create mode 100644 tests/data/data1463.txt create mode 100644 tests/data/data1705-1.md create mode 100644 tests/data/data1705-2.md create mode 100644 tests/data/data1705-3.md create mode 100644 tests/data/data1705-4.md create mode 100644 tests/data/data1705-stdout.1 create mode 100644 tests/data/data1706-1.md create mode 100644 tests/data/data1706-2.md create mode 100644 tests/data/data1706-3.md create mode 100644 tests/data/data1706-4.md create mode 100644 tests/data/data1706-stdout.txt create mode 100644 tests/data/data320.html diff --git a/.github/scripts/pyspelling.yaml b/.github/scripts/pyspelling.yaml index 8e26b76189bc..bb0585ab7ab8 100644 --- a/.github/scripts/pyspelling.yaml +++ b/.github/scripts/pyspelling.yaml @@ -30,4 +30,4 @@ matrix: - 'strong' - 'em' sources: - - '**/*.md|!docs/BINDINGS.md|!docs/DISTROS.md|!docs/CIPHERS-TLS12.md|!docs/wcurl.md' + - '**/*.md|!docs/BINDINGS.md|!docs/DISTROS.md|!docs/CIPHERS-TLS12.md|!docs/wcurl.md|!tests/data/data*.md' diff --git a/.github/scripts/spacecheck.pl b/.github/scripts/spacecheck.pl index d0776a97d1fe..2c3a2e3b0a61 100755 --- a/.github/scripts/spacecheck.pl +++ b/.github/scripts/spacecheck.pl @@ -31,6 +31,7 @@ "Makefile\\.(am|example)\$", "/mkfile", "\\.sln\$", + "^tests/data/data1706-stdout.txt", "^tests/data/test", ); diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am index 910dbd69915a..140d507d777a 100644 --- a/tests/data/Makefile.am +++ b/tests/data/Makefile.am @@ -283,6 +283,9 @@ test3200 test3201 test3202 test3203 test3204 test3205 test3206 test3207 test3208 test3209 test3210 test3211 test3212 test3213 test3214 test3215 test3216 \ test4000 test4001 -EXTRA_DIST = $(TESTCASES) DISABLED data-xml1 \ +EXTRA_DIST = $(TESTCASES) DISABLED data-xml1 data320.html \ +data1461.txt data1463.txt \ data1400.c data1401.c data1402.c data1403.c data1404.c data1405.c data1406.c \ -data1407.c data1420.c data1465.c data1481.c +data1407.c data1420.c data1465.c data1481.c \ +data1705-1.md data1705-2.md data1705-3.md data1705-4.md data1705-stdout.1 \ +data1706-1.md data1706-2.md data1706-3.md data1706-4.md data1706-stdout.txt diff --git a/tests/data/data1461.txt b/tests/data/data1461.txt new file mode 100644 index 000000000000..62fe8de989c7 --- /dev/null +++ b/tests/data/data1461.txt @@ -0,0 +1,21 @@ +Usage: curl [options...] + -d, --data HTTP POST data + -f, --fail Fail fast with no output on HTTP errors + -h, --help Get help for commands + -o, --output Write to file instead of stdout + -O, --remote-name Write output to file named as remote file + -i, --show-headers Show response headers in output + -s, --silent Silent mode + -T, --upload-file Transfer local FILE to destination + -u, --user Server user and password + -A, --user-agent Send User-Agent to server + -v, --verbose Make the operation more talkative + -V, --version Show version number and quit + +This is not the full help; this menu is split into categories. +Use "--help category" to get an overview of all categories, which are: +auth, connection, curl, deprecated, dns, file, ftp, global, http, imap, ldap,%SP +output, pop3, post, proxy, scp, sftp, smtp, ssh, telnet, tftp, timeout, tls,%SP +upload, verbose. +Use "--help all" to list all options +Use "--help [option]" to view documentation for a given option diff --git a/tests/data/data1463.txt b/tests/data/data1463.txt new file mode 100644 index 000000000000..830377fc0dc2 --- /dev/null +++ b/tests/data/data1463.txt @@ -0,0 +1,5 @@ +file: FILE protocol + --create-file-mode File mode for created files + -I, --head Show document info only + -l, --list-only List only mode + -r, --range Retrieve only the bytes within RANGE diff --git a/tests/data/data1705-1.md b/tests/data/data1705-1.md new file mode 100644 index 000000000000..3e06c1b38ffe --- /dev/null +++ b/tests/data/data1705-1.md @@ -0,0 +1,11 @@ + + +# DESCRIPTION + +**curl** is a tool for transferring data from or to a server using URLs. It +supports these protocols: DICT, FILE, FTP, FTPS, GOPHER, GOPHERS, HTTP, HTTPS, +IMAP, IMAPS, LDAP, LDAPS, MQTT, POP3, POP3S, RTMP, RTMPS, RTSP, SCP, SFTP, +SMB, SMBS, SMTP, SMTPS, TELNET, TFTP, WS and WSS. + +curl is powered by libcurl for all transfer-related features. See +*libcurl(3)* for details. diff --git a/tests/data/data1705-2.md b/tests/data/data1705-2.md new file mode 100644 index 000000000000..812862a952e5 --- /dev/null +++ b/tests/data/data1705-2.md @@ -0,0 +1,40 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Short: v +Long: fakeitreal +Mutexed: trace trace-ascii +Help: Make the operation more talkative +Category: important verbose global +Added: 4.0 +Multi: boolean +Scope: global +See-also: + - include + - silent + - trace + - trace-ascii +Example: + - --fakeitreal $URL +--- + +# `--verbose` + +Makes curl verbose during the operation. Useful for debugging and seeing +what's going on under the hood. A line starting with \> means header data sent +by curl, \< means header data received by curl that is hidden in normal cases, +and a line starting with * means additional info provided by curl. + +If you only want HTTP headers in the output, --include or --dump-header might +be more suitable options. + +If you think this option still does not give you enough details, consider using +--trace or --trace-ascii instead. + +Note that verbose output of curl activities and network traffic might contain +sensitive data, including usernames, credentials or secret data content. Be +aware and be careful when sharing trace logs with others. + +End with a quote + + hello diff --git a/tests/data/data1705-3.md b/tests/data/data1705-3.md new file mode 100644 index 000000000000..5041962d4045 --- /dev/null +++ b/tests/data/data1705-3.md @@ -0,0 +1,48 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Long: proto +Arg: +Help: Enable/disable PROTOCOLS +Added: 7.20.2 +Category: connection curl +Multi: single +See-also: + - fakeitreal + - proto-default +Example: + - --proto =http,https,sftp $URL +--- + +# `--proto` + +Limit what protocols to allow for transfers. Protocols are evaluated left to +right, are comma separated, and are each a protocol name or 'all', optionally +prefixed by zero or more modifiers. Available modifiers are: + +## + +Permit this protocol in addition to protocols already permitted (this is +the default if no modifier is used). + +## - +Deny this protocol, removing it from the list of protocols already permitted. + +## = +Permit only this protocol (ignoring the list already permitted), though +subject to later modification by subsequent entries in the comma separated +list. + +## + +For example: --proto -ftps uses the default protocols, but disables ftps + +--proto -all,https,+http only enables http and https + +--proto =http,https also only enables http and https + +Unknown and disabled protocols produce a warning. This allows scripts to +safely rely on being able to disable potentially dangerous protocols, without +relying upon support for that protocol being built into curl to avoid an error. + +This option can be used multiple times, in which case the effect is the same +as concatenating the protocols into one instance of the option. diff --git a/tests/data/data1705-4.md b/tests/data/data1705-4.md new file mode 100644 index 000000000000..297b56c4b64c --- /dev/null +++ b/tests/data/data1705-4.md @@ -0,0 +1,22 @@ + + +# PROXY PROTOCOL PREFIXES +The proxy string may be specified with a protocol:// prefix to specify +alternative proxy protocols. (Added in 7.21.7) + +If no protocol is specified in the proxy string or if the string does not +match a supported one, the proxy is treated as an HTTP proxy. + +The supported proxy protocol prefixes are as follows: +## http:// +Makes it use it as an HTTP proxy. The default if no scheme prefix is used. +## https:// +Makes it treated as an **HTTPS** proxy. +## socks4:// +Makes it the equivalent of --socks4 +## socks4a:// +Makes it the equivalent of --socks4a +## socks5:// +Makes it the equivalent of --socks5 +## socks5h:// +Makes it the equivalent of --socks5-hostname diff --git a/tests/data/data1705-stdout.1 b/tests/data/data1705-stdout.1 new file mode 100644 index 000000000000..f4439a21f121 --- /dev/null +++ b/tests/data/data1705-stdout.1 @@ -0,0 +1,126 @@ +.\" ************************************************************************** +.\" * _ _ ____ _ +.\" * Project ___| | | | _ \| | +.\" * / __| | | | |_) | | +.\" * | (__| |_| | _ <| |___ +.\" * \___|\___/|_| \_\_____| +.\" * +.\" * Copyright (C) Daniel Stenberg, , et al. +.\" * +.\" * This software is licensed as described in the 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. +.\" * +.\" * SPDX-License-Identifier: curl +.\" * +.\" ************************************************************************** +.\" +.\" DO NOT EDIT. Generated by the curl project managen man page generator. +.\" +.TH curl 1 "%DATE" "curl %VERNUM" "curl Manual" +.SH DESCRIPTION +\fBcurl\fP is a tool for transferring data from or to a server using URLs. It +supports these protocols: DICT, FILE, FTP, FTPS, GOPHER, GOPHERS, HTTP, HTTPS, +IMAP, IMAPS, LDAP, LDAPS, MQTT, POP3, POP3S, RTMP, RTMPS, RTSP, SCP, SFTP, +SMB, SMBS, SMTP, SMTPS, TELNET, TFTP, WS and WSS. + +curl is powered by libcurl for all transfer\-related features. See +\fIlibcurl(3)\fP for details. +.IP "\-v, \-\-fakeitreal" +Makes curl verbose during the operation. Useful for debugging and seeing +what\(aqs going on under the hood. A line starting with > means header data sent +by curl, < means header data received by curl that is hidden in normal cases, +and a line starting with * means additional info provided by curl. + +If you only want HTTP headers in the output, \fI\-\-include\fP or \fI\-\-dump\-header\fP might +be more suitable options. + +If you think this option still does not give you enough details, consider using +\fI\-\-trace\fP or \fI\-\-trace\-ascii\fP instead. + +Note that verbose output of curl activities and network traffic might contain +sensitive data, including usernames, credentials or secret data content. Be +aware and be careful when sharing trace logs with others. + +End with a quote + +.nf +hello +.fi + +This option is global and does not need to be specified for each use of \fI\-\-next\fP. + +Providing \fI\-\-fakeitreal\fP multiple times has no extra effect. +Disable it again with \-\-no-fakeitreal. + +Example: +.nf +curl --fakeitreal https://example.com +.fi + +This option is mutually exclusive with \fI\-\-trace\fP and \fI\-\-trace\-ascii\fP. +See also \fI\-\-include\fP, \fI\-\-silent\fP, \fI\-\-trace\fP and \fI\-\-trace\-ascii\fP. +.IP "\-\-proto " +Limit what protocols to allow for transfers. Protocols are evaluated left to +right, are comma separated, and are each a protocol name or \(aqall\(aq, optionally +prefixed by zero or more modifiers. Available modifiers are: +.RS +.IP + +Permit this protocol in addition to protocols already permitted (this is +the default if no modifier is used). +.IP - +Deny this protocol, removing it from the list of protocols already permitted. +.IP = +Permit only this protocol (ignoring the list already permitted), though +subject to later modification by subsequent entries in the comma separated +list. +.RE +.IP +For example: \fI\-\-proto\fP \-ftps uses the default protocols, but disables ftps + +\fI\-\-proto\fP \-all,https,+http only enables http and https + +\fI\-\-proto\fP =http,https also only enables http and https + +Unknown and disabled protocols produce a warning. This allows scripts to +safely rely on being able to disable potentially dangerous protocols, without +relying upon support for that protocol being built into curl to avoid an error. + +This option can be used multiple times, in which case the effect is the same +as concatenating the protocols into one instance of the option. + +If \fI\-\-proto\fP is provided several times, the last set value is used. + +Example: +.nf +curl --proto =http,https,sftp https://example.com +.fi + +See also \fI\-\-fakeitreal\fP and \fI\-\-proto\-default\fP. +.SH PROXY PROTOCOL PREFIXES +The proxy string may be specified with a protocol:// prefix to specify +alternative proxy protocols. + +If no protocol is specified in the proxy string or if the string does not +match a supported one, the proxy is treated as an HTTP proxy. + +The supported proxy protocol prefixes are as follows: +.IP http:// +Makes it use it as an HTTP proxy. The default if no scheme prefix is used. +.IP https:// +Makes it treated as an \fBHTTPS\fP proxy. +.IP socks4:// +Makes it the equivalent of \fI\-\-socks4\fP +.IP socks4a:// +Makes it the equivalent of \fI\-\-socks4a\fP +.IP socks5:// +Makes it the equivalent of \fI\-\-socks5\fP +.IP socks5h:// +Makes it the equivalent of \fI\-\-socks5\-hostname\fP diff --git a/tests/data/data1706-1.md b/tests/data/data1706-1.md new file mode 100644 index 000000000000..3e06c1b38ffe --- /dev/null +++ b/tests/data/data1706-1.md @@ -0,0 +1,11 @@ + + +# DESCRIPTION + +**curl** is a tool for transferring data from or to a server using URLs. It +supports these protocols: DICT, FILE, FTP, FTPS, GOPHER, GOPHERS, HTTP, HTTPS, +IMAP, IMAPS, LDAP, LDAPS, MQTT, POP3, POP3S, RTMP, RTMPS, RTSP, SCP, SFTP, +SMB, SMBS, SMTP, SMTPS, TELNET, TFTP, WS and WSS. + +curl is powered by libcurl for all transfer-related features. See +*libcurl(3)* for details. diff --git a/tests/data/data1706-2.md b/tests/data/data1706-2.md new file mode 100644 index 000000000000..6665c5b21c4d --- /dev/null +++ b/tests/data/data1706-2.md @@ -0,0 +1,36 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Short: v +Long: fakeitreal +Mutexed: trace trace-ascii +Help: Make the operation more talkative +Category: important verbose global +Added: 4.0 +Multi: boolean +Scope: global +See-also: + - include + - silent + - trace + - trace-ascii +Example: + - --fakeitreal $URL +--- + +# `--verbose` + +Makes curl verbose during the operation. Useful for debugging and seeing +what's going on under the hood. A line starting with \> means header data sent +by curl, \< means header data received by curl that is hidden in normal cases, +and a line starting with * means additional info provided by curl. + +If you only want HTTP headers in the output, --include or --dump-header might +be more suitable options. + +If you think this option still does not give you enough details, consider using +--trace or --trace-ascii instead. + +Note that verbose output of curl activities and network traffic might contain +sensitive data, including usernames, credentials or secret data content. Be +aware and be careful when sharing trace logs with others. diff --git a/tests/data/data1706-3.md b/tests/data/data1706-3.md new file mode 100644 index 000000000000..5041962d4045 --- /dev/null +++ b/tests/data/data1706-3.md @@ -0,0 +1,48 @@ +--- +c: Copyright (C) Daniel Stenberg, , et al. +SPDX-License-Identifier: curl +Long: proto +Arg: +Help: Enable/disable PROTOCOLS +Added: 7.20.2 +Category: connection curl +Multi: single +See-also: + - fakeitreal + - proto-default +Example: + - --proto =http,https,sftp $URL +--- + +# `--proto` + +Limit what protocols to allow for transfers. Protocols are evaluated left to +right, are comma separated, and are each a protocol name or 'all', optionally +prefixed by zero or more modifiers. Available modifiers are: + +## + +Permit this protocol in addition to protocols already permitted (this is +the default if no modifier is used). + +## - +Deny this protocol, removing it from the list of protocols already permitted. + +## = +Permit only this protocol (ignoring the list already permitted), though +subject to later modification by subsequent entries in the comma separated +list. + +## + +For example: --proto -ftps uses the default protocols, but disables ftps + +--proto -all,https,+http only enables http and https + +--proto =http,https also only enables http and https + +Unknown and disabled protocols produce a warning. This allows scripts to +safely rely on being able to disable potentially dangerous protocols, without +relying upon support for that protocol being built into curl to avoid an error. + +This option can be used multiple times, in which case the effect is the same +as concatenating the protocols into one instance of the option. diff --git a/tests/data/data1706-4.md b/tests/data/data1706-4.md new file mode 100644 index 000000000000..297b56c4b64c --- /dev/null +++ b/tests/data/data1706-4.md @@ -0,0 +1,22 @@ + + +# PROXY PROTOCOL PREFIXES +The proxy string may be specified with a protocol:// prefix to specify +alternative proxy protocols. (Added in 7.21.7) + +If no protocol is specified in the proxy string or if the string does not +match a supported one, the proxy is treated as an HTTP proxy. + +The supported proxy protocol prefixes are as follows: +## http:// +Makes it use it as an HTTP proxy. The default if no scheme prefix is used. +## https:// +Makes it treated as an **HTTPS** proxy. +## socks4:// +Makes it the equivalent of --socks4 +## socks4a:// +Makes it the equivalent of --socks4a +## socks5:// +Makes it the equivalent of --socks5 +## socks5h:// +Makes it the equivalent of --socks5-hostname diff --git a/tests/data/data1706-stdout.txt b/tests/data/data1706-stdout.txt new file mode 100644 index 000000000000..b352864a8d75 --- /dev/null +++ b/tests/data/data1706-stdout.txt @@ -0,0 +1,116 @@ +DESCRIPTION + + curl is a tool for transferring data from or to a server using URLs. It + supports these protocols: DICT, FILE, FTP, FTPS, GOPHER, GOPHERS, HTTP, + HTTPS, IMAP, IMAPS, LDAP, LDAPS, MQTT, POP3, POP3S, RTMP, RTMPS, RTSP, + SCP, SFTP, SMB, SMBS, SMTP, SMTPS, TELNET, TFTP, WS and WSS. + + curl is powered by libcurl for all transfer-related features. See + libcurl(3) for details. + + -v, --fakeitreal + Makes curl verbose during the operation. Useful for debugging and + seeing what's going on under the hood. A line starting with > + means header data sent by curl, < means header data received by + curl that is hidden in normal cases, and a line starting with * + means additional info provided by curl. + + If you only want HTTP headers in the output, --include or + --dump-header might be more suitable options. + + If you think this option still does not give you enough details, + consider using --trace or --trace-ascii instead. + + Note that verbose output of curl activities and network traffic + might contain sensitive data, including usernames, credentials or + secret data content. Be aware and be careful when sharing trace + logs with others. + + This option is global and does not need to be specified for each + use of --next. Providing --fakeitreal multiple times has no extra + effect. Disable it again with --no-fakeitreal. + + Example: + curl --fakeitreal https://example.com + + This option is mutually exclusive with --trace and --trace-ascii. + See also --include, --silent, --trace and --trace-ascii. + + --proto + Limit what protocols to allow for transfers. Protocols are + evaluated left to right, are comma separated, and are each a + protocol name or 'all', optionally prefixed by zero or more + modifiers. Available modifiers are: + + + + + Permit this protocol in addition to protocols already + permitted (this is the default if no modifier is used). + + - + + Deny this protocol, removing it from the list of protocols + already permitted. + + = + + Permit only this protocol (ignoring the list already + permitted), though subject to later modification by subsequent + entries in the comma separated list. + + For example: --proto -ftps uses the default protocols, but + disables ftps + + --proto -all,https,+http only enables http and https + + --proto =http,https also only enables http and https + + Unknown and disabled protocols produce a warning. This allows + scripts to safely rely on being able to disable potentially + dangerous protocols, without relying upon support for that + protocol being built into curl to avoid an error. + + This option can be used multiple times, in which case the effect + is the same as concatenating the protocols into one instance of + the option. If --proto is provided several times, the last set + value is used. + + Example: + curl --proto =http,https,sftp https://example.com + + See also --fakeitreal and --proto-default. + +PROXY PROTOCOL PREFIXES + + The proxy string may be specified with a protocol:// prefix to specify + alternative proxy protocols. + + If no protocol is specified in the proxy string or if the string does not + match a supported one, the proxy is treated as an HTTP proxy. + + The supported proxy protocol prefixes are as follows: + + http:// + + Makes it use it as an HTTP proxy. The default if no scheme prefix is + used. + + https:// + + Makes it treated as an HTTPS proxy. + + socks4:// + + Makes it the equivalent of --socks4 + + socks4a:// + + Makes it the equivalent of --socks4a + + socks5:// + + Makes it the equivalent of --socks5 + + socks5h:// + + Makes it the equivalent of --socks5-hostname diff --git a/tests/data/data320.html b/tests/data/data320.html new file mode 100644 index 000000000000..2756af5f3b98 --- /dev/null +++ b/tests/data/data320.html @@ -0,0 +1,20 @@ + +

This is GnuTLS

+ + +

Session ID: 003030000100000001000000000000000030330001000000B062410001000000

+
If your browser supports session resuming, then you should see the same session ID, when you press the reload button.
+

Connected as user 'jsmith'.

+

+ + + + + +

Protocol version:TLS1.2
Key Exchange:SRP
CompressionNULL
CipherAES-NNN-CBC
MACSHA1
CiphersuiteSRP_SHA_AES_NNN_CBC_SHA1
+


Your HTTP header was:

Host: localhost:9011%CR
+User-Agent: curl-test-suite%CR
+Accept: */*%CR
+%CR
+

+ diff --git a/tests/data/test1461 b/tests/data/test1461 index f45d0dcd1229..27c58bfeea8c 100644 --- a/tests/data/test1461 +++ b/tests/data/test1461 @@ -2,7 +2,6 @@ --help -notxml @@ -32,27 +31,7 @@ curl important --help 0 -Usage: curl [options...] - -d, --data HTTP POST data - -f, --fail Fail fast with no output on HTTP errors - -h, --help Get help for commands - -o, --output Write to file instead of stdout - -O, --remote-name Write output to file named as remote file - -i, --show-headers Show response headers in output - -s, --silent Silent mode - -T, --upload-file Transfer local FILE to destination - -u, --user Server user and password - -A, --user-agent Send User-Agent to server - -v, --verbose Make the operation more talkative - -V, --version Show version number and quit - -This is not the full help; this menu is split into categories. -Use "--help category" to get an overview of all categories, which are: -auth, connection, curl, deprecated, dns, file, ftp, global, http, imap, ldap,%SP -output, pop3, post, proxy, scp, sftp, smtp, ssh, telnet, tftp, timeout, tls,%SP -upload, verbose. -Use "--help all" to list all options -Use "--help [option]" to view documentation for a given option +%includetext %SRCDIR/data/data%TESTNUMBER.txt% diff --git a/tests/data/test1463 b/tests/data/test1463 index e67bdfdae452..61168ad303a2 100644 --- a/tests/data/test1463 +++ b/tests/data/test1463 @@ -3,7 +3,6 @@ FILE --help -notxml @@ -33,11 +32,7 @@ curl file category --help 0 -file: FILE protocol - --create-file-mode File mode for created files - -I, --head Show document info only - -l, --list-only List only mode - -r, --range Retrieve only the bytes within RANGE +%includetext %SRCDIR/data/data%TESTNUMBER.txt% diff --git a/tests/data/test1464 b/tests/data/test1464 index 4a4f6b3633c9..be0b0c5f4d7c 100644 --- a/tests/data/test1464 +++ b/tests/data/test1464 @@ -33,11 +33,7 @@ curl file category --help with lower/upper mix 0 -file: FILE protocol - --create-file-mode File mode for created files - -I, --head Show document info only - -l, --list-only List only mode - -r, --range Retrieve only the bytes within RANGE +%includetext %SRCDIR/data/data1463.txt% diff --git a/tests/data/test1705 b/tests/data/test1705 index dc2120786054..5db0039d825c 100644 --- a/tests/data/test1705 +++ b/tests/data/test1705 @@ -4,7 +4,6 @@ script documentation managen -notxml @@ -23,133 +22,16 @@ _footer.md
- - -# DESCRIPTION - -**curl** is a tool for transferring data from or to a server using URLs. It -supports these protocols: DICT, FILE, FTP, FTPS, GOPHER, GOPHERS, HTTP, HTTPS, -IMAP, IMAPS, LDAP, LDAPS, MQTT, POP3, POP3S, RTMP, RTMPS, RTSP, SCP, SFTP, -SMB, SMBS, SMTP, SMTPS, TELNET, TFTP, WS and WSS. - -curl is powered by libcurl for all transfer-related features. See -*libcurl(3)* for details. +%includetext %SRCDIR/data/data%TESTNUMBER-1.md% ---- -c: Copyright (C) Daniel Stenberg, , et al. -SPDX-License-Identifier: curl -Short: v -Long: fakeitreal -Mutexed: trace trace-ascii -Help: Make the operation more talkative -Category: important verbose global -Added: 4.0 -Multi: boolean -Scope: global -See-also: - - include - - silent - - trace - - trace-ascii -Example: - - --fakeitreal $URL ---- - -# `--verbose` - -Makes curl verbose during the operation. Useful for debugging and seeing -what's going on under the hood. A line starting with \> means header data sent -by curl, \< means header data received by curl that is hidden in normal cases, -and a line starting with * means additional info provided by curl. - -If you only want HTTP headers in the output, --include or --dump-header might -be more suitable options. - -If you think this option still does not give you enough details, consider using ---trace or --trace-ascii instead. - -Note that verbose output of curl activities and network traffic might contain -sensitive data, including usernames, credentials or secret data content. Be -aware and be careful when sharing trace logs with others. - -End with a quote - - hello +%includetext %SRCDIR/data/data%TESTNUMBER-2.md% ---- -c: Copyright (C) Daniel Stenberg, , et al. -SPDX-License-Identifier: curl -Long: proto -Arg: -Help: Enable/disable PROTOCOLS -Added: 7.20.2 -Category: connection curl -Multi: single -See-also: - - fakeitreal - - proto-default -Example: - - --proto =http,https,sftp $URL ---- - -# `--proto` - -Limit what protocols to allow for transfers. Protocols are evaluated left to -right, are comma separated, and are each a protocol name or 'all', optionally -prefixed by zero or more modifiers. Available modifiers are: - -## + -Permit this protocol in addition to protocols already permitted (this is -the default if no modifier is used). - -## - -Deny this protocol, removing it from the list of protocols already permitted. - -## = -Permit only this protocol (ignoring the list already permitted), though -subject to later modification by subsequent entries in the comma separated -list. - -## - -For example: --proto -ftps uses the default protocols, but disables ftps - ---proto -all,https,+http only enables http and https - ---proto =http,https also only enables http and https - -Unknown and disabled protocols produce a warning. This allows scripts to -safely rely on being able to disable potentially dangerous protocols, without -relying upon support for that protocol being built into curl to avoid an error. - -This option can be used multiple times, in which case the effect is the same -as concatenating the protocols into one instance of the option. +%includetext %SRCDIR/data/data%TESTNUMBER-3.md% - - -# PROXY PROTOCOL PREFIXES -The proxy string may be specified with a protocol:// prefix to specify -alternative proxy protocols. (Added in 7.21.7) - -If no protocol is specified in the proxy string or if the string does not -match a supported one, the proxy is treated as an HTTP proxy. - -The supported proxy protocol prefixes are as follows: -## http:// -Makes it use it as an HTTP proxy. The default if no scheme prefix is used. -## https:// -Makes it treated as an **HTTPS** proxy. -## socks4:// -Makes it the equivalent of --socks4 -## socks4a:// -Makes it the equivalent of --socks4a -## socks5:// -Makes it the equivalent of --socks5 -## socks5h:// -Makes it the equivalent of --socks5-hostname +%includetext %SRCDIR/data/data%TESTNUMBER-4.md% @@ -168,132 +50,7 @@ WARN: option1.md mutexes a non-existing option: trace-ascii option2.md:15:1:WARN: see-also a non-existing option: proto-default -.\" ************************************************************************** -.\" * _ _ ____ _ -.\" * Project ___| | | | _ \| | -.\" * / __| | | | |_) | | -.\" * | (__| |_| | _ <| |___ -.\" * \___|\___/|_| \_\_____| -.\" * -.\" * Copyright (C) Daniel Stenberg, , et al. -.\" * -.\" * This software is licensed as described in the 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. -.\" * -.\" * SPDX-License-Identifier: curl -.\" * -.\" ************************************************************************** -.\" -.\" DO NOT EDIT. Generated by the curl project managen man page generator. -.\" -.TH curl 1 "%DATE" "curl %VERNUM" "curl Manual" -.SH DESCRIPTION -\fBcurl\fP is a tool for transferring data from or to a server using URLs. It -supports these protocols: DICT, FILE, FTP, FTPS, GOPHER, GOPHERS, HTTP, HTTPS, -IMAP, IMAPS, LDAP, LDAPS, MQTT, POP3, POP3S, RTMP, RTMPS, RTSP, SCP, SFTP, -SMB, SMBS, SMTP, SMTPS, TELNET, TFTP, WS and WSS. - -curl is powered by libcurl for all transfer\-related features. See -\fIlibcurl(3)\fP for details. -.IP "\-v, \-\-fakeitreal" -Makes curl verbose during the operation. Useful for debugging and seeing -what\(aqs going on under the hood. A line starting with > means header data sent -by curl, < means header data received by curl that is hidden in normal cases, -and a line starting with * means additional info provided by curl. - -If you only want HTTP headers in the output, \fI\-\-include\fP or \fI\-\-dump\-header\fP might -be more suitable options. - -If you think this option still does not give you enough details, consider using -\fI\-\-trace\fP or \fI\-\-trace\-ascii\fP instead. - -Note that verbose output of curl activities and network traffic might contain -sensitive data, including usernames, credentials or secret data content. Be -aware and be careful when sharing trace logs with others. - -End with a quote - -.nf -hello -.fi - -This option is global and does not need to be specified for each use of \fI\-\-next\fP. - -Providing \fI\-\-fakeitreal\fP multiple times has no extra effect. -Disable it again with \-\-no-fakeitreal. - -Example: -.nf -curl --fakeitreal https://example.com -.fi - -This option is mutually exclusive with \fI\-\-trace\fP and \fI\-\-trace\-ascii\fP. -See also \fI\-\-include\fP, \fI\-\-silent\fP, \fI\-\-trace\fP and \fI\-\-trace\-ascii\fP. -.IP "\-\-proto " -Limit what protocols to allow for transfers. Protocols are evaluated left to -right, are comma separated, and are each a protocol name or \(aqall\(aq, optionally -prefixed by zero or more modifiers. Available modifiers are: -.RS -.IP + -Permit this protocol in addition to protocols already permitted (this is -the default if no modifier is used). -.IP - -Deny this protocol, removing it from the list of protocols already permitted. -.IP = -Permit only this protocol (ignoring the list already permitted), though -subject to later modification by subsequent entries in the comma separated -list. -.RE -.IP -For example: \fI\-\-proto\fP \-ftps uses the default protocols, but disables ftps - -\fI\-\-proto\fP \-all,https,+http only enables http and https - -\fI\-\-proto\fP =http,https also only enables http and https - -Unknown and disabled protocols produce a warning. This allows scripts to -safely rely on being able to disable potentially dangerous protocols, without -relying upon support for that protocol being built into curl to avoid an error. - -This option can be used multiple times, in which case the effect is the same -as concatenating the protocols into one instance of the option. - -If \fI\-\-proto\fP is provided several times, the last set value is used. - -Example: -.nf -curl --proto =http,https,sftp https://example.com -.fi - -See also \fI\-\-fakeitreal\fP and \fI\-\-proto\-default\fP. -.SH PROXY PROTOCOL PREFIXES -The proxy string may be specified with a protocol:// prefix to specify -alternative proxy protocols. - -If no protocol is specified in the proxy string or if the string does not -match a supported one, the proxy is treated as an HTTP proxy. - -The supported proxy protocol prefixes are as follows: -.IP http:// -Makes it use it as an HTTP proxy. The default if no scheme prefix is used. -.IP https:// -Makes it treated as an \fBHTTPS\fP proxy. -.IP socks4:// -Makes it the equivalent of \fI\-\-socks4\fP -.IP socks4a:// -Makes it the equivalent of \fI\-\-socks4a\fP -.IP socks5:// -Makes it the equivalent of \fI\-\-socks5\fP -.IP socks5h:// -Makes it the equivalent of \fI\-\-socks5\-hostname\fP +%includetext %SRCDIR/data/data%TESTNUMBER-stdout.1% diff --git a/tests/data/test1706 b/tests/data/test1706 index dd24365d056b..cfe628530863 100644 --- a/tests/data/test1706 +++ b/tests/data/test1706 @@ -4,7 +4,6 @@ script documentation managen -notxml @@ -23,129 +22,16 @@ _footer.md
- - -# DESCRIPTION - -**curl** is a tool for transferring data from or to a server using URLs. It -supports these protocols: DICT, FILE, FTP, FTPS, GOPHER, GOPHERS, HTTP, HTTPS, -IMAP, IMAPS, LDAP, LDAPS, MQTT, POP3, POP3S, RTMP, RTMPS, RTSP, SCP, SFTP, -SMB, SMBS, SMTP, SMTPS, TELNET, TFTP, WS and WSS. - -curl is powered by libcurl for all transfer-related features. See -*libcurl(3)* for details. +%includetext %SRCDIR/data/data%TESTNUMBER-1.md% ---- -c: Copyright (C) Daniel Stenberg, , et al. -SPDX-License-Identifier: curl -Short: v -Long: fakeitreal -Mutexed: trace trace-ascii -Help: Make the operation more talkative -Category: important verbose global -Added: 4.0 -Multi: boolean -Scope: global -See-also: - - include - - silent - - trace - - trace-ascii -Example: - - --fakeitreal $URL ---- - -# `--verbose` - -Makes curl verbose during the operation. Useful for debugging and seeing -what's going on under the hood. A line starting with \> means header data sent -by curl, \< means header data received by curl that is hidden in normal cases, -and a line starting with * means additional info provided by curl. - -If you only want HTTP headers in the output, --include or --dump-header might -be more suitable options. - -If you think this option still does not give you enough details, consider using ---trace or --trace-ascii instead. - -Note that verbose output of curl activities and network traffic might contain -sensitive data, including usernames, credentials or secret data content. Be -aware and be careful when sharing trace logs with others. +%includetext %SRCDIR/data/data%TESTNUMBER-2.md% ---- -c: Copyright (C) Daniel Stenberg, , et al. -SPDX-License-Identifier: curl -Long: proto -Arg: -Help: Enable/disable PROTOCOLS -Added: 7.20.2 -Category: connection curl -Multi: single -See-also: - - fakeitreal - - proto-default -Example: - - --proto =http,https,sftp $URL ---- - -# `--proto` - -Limit what protocols to allow for transfers. Protocols are evaluated left to -right, are comma separated, and are each a protocol name or 'all', optionally -prefixed by zero or more modifiers. Available modifiers are: - -## + -Permit this protocol in addition to protocols already permitted (this is -the default if no modifier is used). - -## - -Deny this protocol, removing it from the list of protocols already permitted. - -## = -Permit only this protocol (ignoring the list already permitted), though -subject to later modification by subsequent entries in the comma separated -list. - -## - -For example: --proto -ftps uses the default protocols, but disables ftps - ---proto -all,https,+http only enables http and https - ---proto =http,https also only enables http and https - -Unknown and disabled protocols produce a warning. This allows scripts to -safely rely on being able to disable potentially dangerous protocols, without -relying upon support for that protocol being built into curl to avoid an error. - -This option can be used multiple times, in which case the effect is the same -as concatenating the protocols into one instance of the option. +%includetext %SRCDIR/data/data%TESTNUMBER-3.md% - - -# PROXY PROTOCOL PREFIXES -The proxy string may be specified with a protocol:// prefix to specify -alternative proxy protocols. (Added in 7.21.7) - -If no protocol is specified in the proxy string or if the string does not -match a supported one, the proxy is treated as an HTTP proxy. - -The supported proxy protocol prefixes are as follows: -## http:// -Makes it use it as an HTTP proxy. The default if no scheme prefix is used. -## https:// -Makes it treated as an **HTTPS** proxy. -## socks4:// -Makes it the equivalent of --socks4 -## socks4a:// -Makes it the equivalent of --socks4a -## socks5:// -Makes it the equivalent of --socks5 -## socks5h:// -Makes it the equivalent of --socks5-hostname +%includetext %SRCDIR/data/data%TESTNUMBER-4.md% @@ -164,122 +50,7 @@ WARN: option1.md mutexes a non-existing option: trace-ascii option2.md:15:1:WARN: see-also a non-existing option: proto-default -DESCRIPTION - - curl is a tool for transferring data from or to a server using URLs. It - supports these protocols: DICT, FILE, FTP, FTPS, GOPHER, GOPHERS, HTTP, - HTTPS, IMAP, IMAPS, LDAP, LDAPS, MQTT, POP3, POP3S, RTMP, RTMPS, RTSP, - SCP, SFTP, SMB, SMBS, SMTP, SMTPS, TELNET, TFTP, WS and WSS. - - curl is powered by libcurl for all transfer-related features. See - libcurl(3) for details. - - -v, --fakeitreal - Makes curl verbose during the operation. Useful for debugging and - seeing what's going on under the hood. A line starting with > - means header data sent by curl, < means header data received by - curl that is hidden in normal cases, and a line starting with * - means additional info provided by curl. - - If you only want HTTP headers in the output, --include or - --dump-header might be more suitable options. - - If you think this option still does not give you enough details, - consider using --trace or --trace-ascii instead. - - Note that verbose output of curl activities and network traffic - might contain sensitive data, including usernames, credentials or - secret data content. Be aware and be careful when sharing trace - logs with others. - - This option is global and does not need to be specified for each - use of --next. Providing --fakeitreal multiple times has no extra - effect. Disable it again with --no-fakeitreal. - - Example: - curl --fakeitreal https://example.com - - This option is mutually exclusive with --trace and --trace-ascii. - See also --include, --silent, --trace and --trace-ascii. - - --proto - Limit what protocols to allow for transfers. Protocols are - evaluated left to right, are comma separated, and are each a - protocol name or 'all', optionally prefixed by zero or more - modifiers. Available modifiers are: - - + - - Permit this protocol in addition to protocols already - permitted (this is the default if no modifier is used). - - - - - Deny this protocol, removing it from the list of protocols - already permitted. - - = - - Permit only this protocol (ignoring the list already - permitted), though subject to later modification by subsequent - entries in the comma separated list. - - For example: --proto -ftps uses the default protocols, but - disables ftps - - --proto -all,https,+http only enables http and https - - --proto =http,https also only enables http and https - - Unknown and disabled protocols produce a warning. This allows - scripts to safely rely on being able to disable potentially - dangerous protocols, without relying upon support for that - protocol being built into curl to avoid an error. - - This option can be used multiple times, in which case the effect - is the same as concatenating the protocols into one instance of - the option. If --proto is provided several times, the last set - value is used. - - Example: - curl --proto =http,https,sftp https://example.com - - See also --fakeitreal and --proto-default. - -PROXY PROTOCOL PREFIXES - - The proxy string may be specified with a protocol:// prefix to specify - alternative proxy protocols. - - If no protocol is specified in the proxy string or if the string does not - match a supported one, the proxy is treated as an HTTP proxy. - - The supported proxy protocol prefixes are as follows: - - http:// - - Makes it use it as an HTTP proxy. The default if no scheme prefix is - used. - - https:// - - Makes it treated as an HTTPS proxy. - - socks4:// - - Makes it the equivalent of --socks4 - - socks4a:// - - Makes it the equivalent of --socks4a - - socks5:// - - Makes it the equivalent of --socks5 - - socks5h:// - - Makes it the equivalent of --socks5-hostname +%includetext %SRCDIR/data/data%TESTNUMBER-stdout.txt% diff --git a/tests/data/test320 b/tests/data/test320 index 0967823d388b..ca68674571f4 100644 --- a/tests/data/test320 +++ b/tests/data/test320 @@ -11,31 +11,7 @@ notxml # Server-side -HTTP/1.0 200 OK%CR -Content-type: text/html%CR -%CR - - -

This is GnuTLS

- - -

Session ID: 003030000100000001000000000000000030330001000000B062410001000000

-
If your browser supports session resuming, then you should see the same session ID, when you press the reload button.
-

Connected as user 'jsmith'.

-

- - - - - -

Protocol version:TLS1.2
Key Exchange:SRP
CompressionNULL
CipherAES-NNN-CBC
MACSHA1
CiphersuiteSRP_SHA_AES_NNN_CBC_SHA1
-


Your HTTP header was:

Host: localhost:9011%CR
-User-Agent: curl-test-suite%CR
-Accept: */*%CR
-%CR
-

- - +%includetext %SRCDIR/data/data%TESTNUMBER.html%
From 4c3614304faf07a643ca060eeccde21c8896940b Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 9 Dec 2025 09:58:48 +0100 Subject: [PATCH 242/415] headers: add length argument to Curl_headers_push() - the length is already known by parent functions - avoids strlen() calls - avoids strchr() calls for trimming off newline characters Closes #19886 --- lib/headers.c | 25 +++++++++++++------------ lib/headers.h | 4 ++-- lib/http2.c | 7 ++++--- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/lib/headers.c b/lib/headers.c index 7cf215c0800e..46de5d107bc9 100644 --- a/lib/headers.c +++ b/lib/headers.c @@ -266,30 +266,31 @@ static CURLcode unfold_value(struct Curl_easy *data, const char *value, /* * Curl_headers_push() gets passed a full HTTP header to store. It gets called - * immediately before the header callback. The header is CRLF terminated. + * immediately before the header callback. The header is CRLF, CR or LF + * terminated. */ CURLcode Curl_headers_push(struct Curl_easy *data, const char *header, + size_t hlen, /* length of header */ unsigned char type) { char *value = NULL; char *name = NULL; - char *end; - size_t hlen; /* length of the incoming header */ struct Curl_header_store *hs; CURLcode result = CURLE_OUT_OF_MEMORY; + const size_t ilen = hlen; if((header[0] == '\r') || (header[0] == '\n')) /* ignore the body separator */ return CURLE_OK; - end = strchr(header, '\r'); - if(!end) { - end = strchr(header, '\n'); - if(!end) - /* neither CR nor LF as terminator is not a valid header */ - return CURLE_WEIRD_SERVER_REPLY; - } - hlen = end - header; + /* trim off newline characters */ + if(hlen && (header[hlen - 1] == '\n')) + hlen--; + if(hlen && (header[hlen - 1] == '\r')) + hlen--; + if(hlen == ilen) + /* neither CR nor LF as terminator is not a valid header */ + return CURLE_WEIRD_SERVER_REPLY; if((header[0] == ' ') || (header[0] == '\t')) { if(data->state.prevhead) @@ -359,7 +360,7 @@ static CURLcode hds_cw_collect_write(struct Curl_easy *data, (type & CLIENTWRITE_1XX ? CURLH_1XX : (type & CLIENTWRITE_TRAILER ? CURLH_TRAILER : CURLH_HEADER))); - CURLcode result = Curl_headers_push(data, buf, htype); + CURLcode result = Curl_headers_push(data, buf, blen, htype); CURL_TRC_WRITE(data, "header_collect pushed(type=%x, len=%zu) -> %d", htype, blen, result); if(result) diff --git a/lib/headers.h b/lib/headers.h index 7249355f0ccd..adb03af75b5e 100644 --- a/lib/headers.h +++ b/lib/headers.h @@ -46,7 +46,7 @@ CURLcode Curl_headers_init(struct Curl_easy *data); * Curl_headers_push() gets passed a full header to store. */ CURLcode Curl_headers_push(struct Curl_easy *data, const char *header, - unsigned char type); + size_t hlen, unsigned char type); /* * Curl_headers_cleanup(). Free all stored headers and associated memory. @@ -55,7 +55,7 @@ CURLcode Curl_headers_cleanup(struct Curl_easy *data); #else #define Curl_headers_init(x) CURLE_OK -#define Curl_headers_push(x, y, z) CURLE_OK +#define Curl_headers_push(x,y,z,a) CURLE_OK #define Curl_headers_cleanup(x) Curl_nop_stmt #endif diff --git a/lib/http2.c b/lib/http2.c index deed6ece7ee1..83b9280b2a15 100644 --- a/lib/http2.c +++ b/lib/http2.c @@ -1664,15 +1664,16 @@ static int on_header(nghttp2_session *session, const nghttp2_frame *frame, memcmp(HTTP_PSEUDO_STATUS, name, namelen) == 0) { /* nghttp2 guarantees :status is received first and only once. */ char buffer[32]; + size_t hlen; result = Curl_http_decode_status(&stream->status_code, (const char *)value, valuelen); if(result) { cf_h2_header_error(cf, data_s, stream, result); return NGHTTP2_ERR_CALLBACK_FAILURE; } - curl_msnprintf(buffer, sizeof(buffer), HTTP_PSEUDO_STATUS ":%u\r", - stream->status_code); - result = Curl_headers_push(data_s, buffer, CURLH_PSEUDO); + hlen = curl_msnprintf(buffer, sizeof(buffer), HTTP_PSEUDO_STATUS ":%u\r", + stream->status_code); + result = Curl_headers_push(data_s, buffer, hlen, CURLH_PSEUDO); if(result) { cf_h2_header_error(cf, data_s, stream, result); return NGHTTP2_ERR_CALLBACK_FAILURE; From 43c781a1162f9be92b4a938660da62a02039b2b3 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 9 Dec 2025 10:04:34 +0100 Subject: [PATCH 243/415] imap: check buffer length before accessing it Pointed out by ZeroPath Closes #19887 --- lib/imap.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/imap.c b/lib/imap.c index cbc4506a9d85..05d195ec58f4 100644 --- a/lib/imap.c +++ b/lib/imap.c @@ -1308,13 +1308,13 @@ static CURLcode imap_state_select_resp(struct Curl_easy *data, imapstate instate) { CURLcode result = CURLE_OK; - const char *line = curlx_dyn_ptr(&imapc->pp.recvbuf); - (void)instate; if(imapcode == '*') { /* See if this is an UIDVALIDITY response */ - if(checkprefix("OK [UIDVALIDITY ", line + 2)) { + const char *line = curlx_dyn_ptr(&imapc->pp.recvbuf); + size_t len = curlx_dyn_len(&imapc->pp.recvbuf); + if((len >= 18) && checkprefix("OK [UIDVALIDITY ", &line[2])) { curl_off_t value; const char *p = &line[2] + strlen("OK [UIDVALIDITY "); if(!curlx_str_number(&p, &value, UINT_MAX)) { From 3dd1ffdeb0efc1b222383102a2fc328ddb850fce Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 8 Dec 2025 13:07:49 +0100 Subject: [PATCH 244/415] FAQ/TODO/KNOWN_BUGS: convert to markdown - convert to markdown - auto-generate the TOCs on the website, remove them from the docs - cleanups - spellchecked - updated links Closes #19875 --- .github/scripts/badwords.ok | 2 +- .github/scripts/pyspelling.words | 15 + .github/workflows/checkdocs.yml | 2 +- README | 3 +- REUSE.toml | 3 - docs/FAQ | 1559 ------------------------------ docs/FAQ.md | 1432 +++++++++++++++++++++++++++ docs/KNOWN_BUGS | 663 ------------- docs/KNOWN_BUGS.md | 546 +++++++++++ docs/Makefile.am | 7 +- docs/TODO | 1301 ------------------------- docs/TODO.md | 1111 +++++++++++++++++++++ packages/OS400/makefile.sh | 2 +- scripts/mdlinkcheck | 2 +- 14 files changed, 3114 insertions(+), 3534 deletions(-) delete mode 100644 docs/FAQ create mode 100644 docs/FAQ.md delete mode 100644 docs/KNOWN_BUGS create mode 100644 docs/KNOWN_BUGS.md delete mode 100644 docs/TODO create mode 100644 docs/TODO.md diff --git a/.github/scripts/badwords.ok b/.github/scripts/badwords.ok index d5401a822870..fe2d9cfaf1ed 100644 --- a/.github/scripts/badwords.ok +++ b/.github/scripts/badwords.ok @@ -4,4 +4,4 @@ # # whitelisted uses of bad words # file:[line]:rule -docs/FAQ::\bwill\b +docs/FAQ.md::\bwill\b diff --git a/.github/scripts/pyspelling.words b/.github/scripts/pyspelling.words index 984424200b9e..6b755d2043d7 100644 --- a/.github/scripts/pyspelling.words +++ b/.github/scripts/pyspelling.words @@ -53,6 +53,7 @@ axTLS backend backends backoff +backtick backticks balancers Baratov @@ -171,8 +172,10 @@ dbg Debian DEBUGBUILD decrypt +decrypted decrypting deepcode +defacto DELE DER dereference @@ -201,6 +204,7 @@ DLLs DNS dns dnsop +DNSSEC DoH DoT doxygen @@ -214,6 +218,7 @@ dynbuf EAGAIN EBCDIC ECC +ECCN ECDHE ECH ECHConfig @@ -258,6 +263,7 @@ Fedora Feltzing ffi filesize +filesystem FindCURL FLOSS fnmatch @@ -299,6 +305,7 @@ Ghedini giga Gisle Glesys +glibc globbed globbing gmail @@ -380,6 +387,7 @@ imap IMAPS imaps impacket +implementers init initializer inlined @@ -433,6 +441,7 @@ ldap LDAPS ldaps LF +LGPL LGTM libbacktrace libbrotlidec @@ -568,6 +577,7 @@ Necko NetBSD netrc netstat +NetWare Netware NFS nghttp @@ -711,6 +721,7 @@ ROADMAP Roadmap Rockbox roffit +RPC RPG RR RRs @@ -798,6 +809,7 @@ sprintf src SRP SRWLOCK +SSI SSL ssl SSLeay @@ -962,8 +974,10 @@ wcurl WebDAV WebOS webpage +webpages WebSocket WEBSOCKET +Wget WHATWG whitespace Whitespaces @@ -982,6 +996,7 @@ www Xbox XDG xdigit +XHTML Xilinx xmllint XP diff --git a/.github/workflows/checkdocs.yml b/.github/workflows/checkdocs.yml index ba3858f66c46..a079aeaa7062 100644 --- a/.github/workflows/checkdocs.yml +++ b/.github/workflows/checkdocs.yml @@ -138,7 +138,7 @@ jobs: persist-credentials: false - name: 'badwords' - run: .github/scripts/badwords.pl -w .github/scripts/badwords.ok '**.md' docs/FAQ docs/KNOWN_BUGS docs/TODO packages/OS400/README.OS400 < .github/scripts/badwords.txt + run: .github/scripts/badwords.pl -w .github/scripts/badwords.ok '**.md' packages/OS400/README.OS400 < .github/scripts/badwords.txt - name: 'verify synopsis' run: .github/scripts/verify-synopsis.pl docs/libcurl/curl*.md diff --git a/README b/README index 2f68ef0c9f4f..9401434b484e 100644 --- a/README +++ b/README @@ -15,7 +15,8 @@ README available to be used by your software. Read the libcurl.3 man page to learn how. - You find answers to the most frequent questions we get in the FAQ document. + You find answers to the most frequent questions we get in the FAQ.md + document. Study the COPYING file for distribution terms. diff --git a/REUSE.toml b/REUSE.toml index e9e9ecf03d32..e341973ad3d3 100644 --- a/REUSE.toml +++ b/REUSE.toml @@ -13,14 +13,11 @@ SPDX-PackageDownloadLocation = "https://curl.se/" [[annotations]] path = [ - "docs/FAQ", "docs/INSTALL", - "docs/KNOWN_BUGS", "docs/libcurl/symbols-in-versions", "docs/MAIL-ETIQUETTE", "docs/options-in-versions", "docs/THANKS", - "docs/TODO", "lib/libcurl.vers.in", "lib/libcurl.def", "packages/OS400/README.OS400", diff --git a/docs/FAQ b/docs/FAQ deleted file mode 100644 index ef93c91c4153..000000000000 --- a/docs/FAQ +++ /dev/null @@ -1,1559 +0,0 @@ - _ _ ____ _ - ___| | | | _ \| | - / __| | | | |_) | | - | (__| |_| | _ <| |___ - \___|\___/|_| \_\_____| - -FAQ - - 1. Philosophy - 1.1 What is curl? - 1.2 What is libcurl? - 1.3 What is curl not? - 1.4 When will you make curl do XXXX ? - 1.5 Who makes curl? - 1.6 What do you get for making curl? - 1.7 What about CURL from curl.com? - 1.8 I have a problem, who do I mail? - 1.9 Where do I buy commercial support for curl? - 1.10 How many are using curl? - 1.11 Why do you not update ca-bundle.crt - 1.12 I have a problem, who can I chat with? - 1.13 curl's ECCN number? - 1.14 How do I submit my patch? - 1.15 How do I port libcurl to my OS? - - 2. Install Related Problems - 2.1 configure fails when using static libraries - 2.2 Does curl work/build with other SSL libraries? - 2.3 How do I upgrade curl.exe in Windows? - 2.4 Does curl support SOCKS (RFC 1928) ? - - 3. Usage Problems - 3.1 curl: (1) SSL is disabled, https: not supported - 3.2 How do I tell curl to resume a transfer? - 3.3 Why does my posting using -F not work? - 3.4 How do I tell curl to run custom FTP commands? - 3.5 How can I disable the Accept: */* header? - 3.6 Does curl support ASP, XML, XHTML or HTML version Y? - 3.7 Can I use curl to delete/rename a file through FTP? - 3.8 How do I tell curl to follow HTTP redirects? - 3.9 How do I use curl in my favorite programming language? - 3.10 What about SOAP, WebDAV, XML-RPC or similar protocols over HTTP? - 3.11 How do I POST with a different Content-Type? - 3.12 Why do FTP-specific features over HTTP proxy fail? - 3.13 Why do my single/double quotes fail? - 3.14 Does curl support JavaScript or PAC (automated proxy config)? - 3.15 Can I do recursive fetches with curl? - 3.16 What certificates do I need when I use SSL? - 3.17 How do I list the root directory of an FTP server? - 3.18 Can I use curl to send a POST/PUT and not wait for a response? - 3.19 How do I get HTTP from a host using a specific IP address? - 3.20 How to SFTP from my user's home directory? - 3.21 Protocol xxx not supported or disabled in libcurl - 3.22 curl -X gives me HTTP problems - - 4. Running Problems - 4.2 Why do I get problems when I use & or % in the URL? - 4.3 How can I use {, }, [ or ] to specify multiple URLs? - 4.4 Why do I get downloaded data even though the webpage does not exist? - 4.5 Why do I get return code XXX from an HTTP server? - 4.5.1 "400 Bad Request" - 4.5.2 "401 Unauthorized" - 4.5.3 "403 Forbidden" - 4.5.4 "404 Not Found" - 4.5.5 "405 Method Not Allowed" - 4.5.6 "301 Moved Permanently" - 4.6 Can you tell me what error code 142 means? - 4.7 How do I keep usernames and passwords secret in curl command lines? - 4.8 I found a bug - 4.9 curl cannot authenticate to a server that requires NTLM? - 4.10 My HTTP request using HEAD, PUT or DELETE does not work - 4.11 Why do my HTTP range requests return the full document? - 4.12 Why do I get "certificate verify failed" ? - 4.13 Why is curl -R on Windows one hour off? - 4.14 Redirects work in browser but not with curl - 4.15 FTPS does not work - 4.16 My HTTP POST or PUT requests are slow - 4.17 Non-functional connect timeouts on Windows - 4.18 file:// URLs containing drive letters (Windows, NetWare) - 4.19 Why does not curl return an error when the network cable is unplugged? - 4.20 curl does not return error for HTTP non-200 responses - - 5. libcurl Issues - 5.1 Is libcurl thread-safe? - 5.2 How can I receive all data into a large memory chunk? - 5.3 How do I fetch multiple files with libcurl? - 5.4 Does libcurl do Winsock initialization on Win32 systems? - 5.5 Does CURLOPT_WRITEDATA and CURLOPT_READDATA work on Win32 ? - 5.6 What about Keep-Alive or persistent connections? - 5.7 Link errors when building libcurl on Windows - 5.8 libcurl.so.X: open failed: No such file or directory - 5.9 How does libcurl resolve hostnames? - 5.10 How do I prevent libcurl from writing the response to stdout? - 5.11 How do I make libcurl not receive the whole HTTP response? - 5.12 Can I make libcurl fake or hide my real IP address? - 5.13 How do I stop an ongoing transfer? - 5.14 Using C++ non-static functions for callbacks? - 5.15 How do I get an FTP directory listing? - 5.16 I want a different time-out - 5.17 Can I write a server with libcurl? - 5.18 Does libcurl use threads? - - 6. License Issues - 6.1 I have a GPL program, can I use the libcurl library? - 6.2 I have a closed-source program, can I use the libcurl library? - 6.3 I have a BSD licensed program, can I use the libcurl library? - 6.4 I have a program that uses LGPL libraries, can I use libcurl? - 6.5 Can I modify curl/libcurl for my program and keep the changes secret? - 6.6 Can you please change the curl/libcurl license to XXXX? - 6.7 What are my obligations when using libcurl in my commercial apps? - - 7. PHP/CURL Issues - 7.1 What is PHP/CURL? - 7.2 Who wrote PHP/CURL? - 7.3 Can I perform multiple requests using the same handle? - 7.4 Does PHP/CURL have dependencies? - - 8. Development - 8.1 Why does curl use C89? - 8.2 Will curl be rewritten? - -============================================================================== - -1. Philosophy - - 1.1 What is curl? - - curl is the name of the project. The name is a play on 'Client for URLs', - originally with URL spelled in uppercase to make it obvious it deals with - URLs. The fact it can also be read as 'see URL' also helped, it works as - an abbreviation for "Client URL Request Library" or why not the recursive - version: "curl URL Request Library". - - The curl project produces two products: - - libcurl - - A client-side URL transfer library, supporting DICT, FILE, FTP, FTPS, - GOPHER, GOPHERS, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, MQTT, POP3, POP3S, - RTMP, RTMPS, RTSP, SCP, SFTP, SMB, SMBS, SMTP, SMTPS, TELNET, TFTP, WS - and WSS. - - libcurl supports HTTPS certificates, HTTP POST, HTTP PUT, FTP uploading, - Kerberos, SPNEGO, HTTP form based upload, proxies, cookies, user+password - authentication, file transfer resume, http proxy tunneling and more. - - libcurl is highly portable, it builds and works identically on numerous - platforms, including Solaris, NetBSD, FreeBSD, OpenBSD, Darwin, HP-UX, - IRIX, AIX, Tru64, Linux, UnixWare, HURD, Windows, Amiga, OS/2, macOS, - Ultrix, QNX, OpenVMS, RISC OS, Novell NetWare, DOS, Symbian, OSF, Android, - Minix, IBM TPF and more... - - libcurl is free, thread-safe, IPv6 compatible, feature rich, well - supported and fast. - - curl - - A command line tool for getting or sending data using URL syntax. - - Since curl uses libcurl, curl supports the same wide range of common - Internet protocols that libcurl does. - - We pronounce curl with an initial k sound. It rhymes with words like girl - and earl. This is a short WAV file to help you: - - https://media.merriam-webster.com/soundc11/c/curl0001.wav - - There are numerous sub-projects and related projects that also use the word - curl in the project names in various combinations, but you should take - notice that this FAQ is directed at the command-line tool named curl (and - libcurl the library), and may therefore not be valid for other curl-related - projects. (There is however a small section for the PHP/CURL in this FAQ.) - - 1.2 What is libcurl? - - libcurl is a reliable and portable library for doing Internet data transfers - using one or more of its supported Internet protocols. - - You can use libcurl freely in your application, be it open source, - commercial or closed-source. - - libcurl is most probably the most portable, most powerful and most often - used C-based multi-platform file transfer library on this planet - be it - open source or commercial. - - 1.3 What is curl not? - - curl is not a wget clone. That is a common misconception. Never, during - curl's development, have we intended curl to replace wget or compete on its - market. curl is targeted at single-shot file transfers. - - curl is not a website mirroring program. If you want to use curl to mirror - something: fine, go ahead and write a script that wraps around curl or use - libcurl to make it reality. - - curl is not an FTP site mirroring program. Sure, get and send FTP with curl - but if you want systematic and sequential behavior you should write a - script (or write a new program that interfaces libcurl) and do it. - - curl is not a PHP tool, even though it works perfectly well when used from - or with PHP (when using the PHP/CURL module). - - curl is not a program for a single operating system. curl exists, compiles, - builds and runs under a wide range of operating systems, including all - modern Unixes (and a bunch of older ones too), Windows, Amiga, OS/2, macOS, - QNX etc. - - 1.4 When will you make curl do XXXX ? - - We love suggestions of what to change in order to make curl and libcurl - better. We do however believe in a few rules when it comes to the future of - curl: - - curl -- the command line tool -- is to remain a non-graphical command line - tool. If you want GUIs or fancy scripting capabilities, you should look for - another tool that uses libcurl. - - We do not add things to curl that other small and available tools already do - well at the side. curl's output can be piped into another program or - redirected to another file for the next program to interpret. - - We focus on protocol related issues and improvements. If you want to do more - magic with the supported protocols than curl currently does, chances are - good we will agree. If you want to add more protocols, we may agree. - - If you want someone else to do all the work while you wait for us to - implement it for you, that is not a friendly attitude. We spend a - considerable time already on maintaining and developing curl. In order to - get more out of us, you should consider trading in some of your time and - effort in return. Simply go to the GitHub repository which resides at - https://github.com/curl/curl, fork the project, and create pull requests - with your proposed changes. - - If you write the code, chances are better that it will get into curl faster. - - 1.5 Who makes curl? - - curl and libcurl are not made by any single individual. Daniel Stenberg is - project leader and main developer, but other persons' submissions are - important and crucial. Anyone can contribute and post their changes and - improvements and have them inserted in the main sources (of course on the - condition that developers agree that the fixes are good). - - The full list of all contributors is found in the docs/THANKS file. - - curl is developed by a community, with Daniel at the wheel. - - 1.6 What do you get for making curl? - - Project curl is entirely free and open. We do this voluntarily, mostly in - our spare time. Companies may pay individual developers to work on curl. - This is not controlled by nor supervised in any way by the curl project. - - We get help from companies. Haxx provides website, bandwidth, mailing lists - etc, GitHub hosts the primary git repository and other services like the bug - tracker at https://github.com/curl/curl. Also again, some companies have - sponsored certain parts of the development in the past and I hope some will - continue to do so in the future. - - If you want to support our project, consider a donation or a banner-program - or even better: by helping us with coding, documenting or testing etc. - - See also: https://curl.se/sponsors.html - - 1.7 What about CURL from curl.com? - - During the summer of 2001, curl.com was busy advertising their client-side - programming language for the web, named CURL. - - We are in no way associated with curl.com or their CURL programming - language. - - Our project name curl has been in effective use since 1998. We were not the - first computer related project to use the name "curl" and do not claim any - rights to the name. - - We recognize that we will be living in parallel with curl.com and wish them - every success. - - 1.8 I have a problem, who do I mail? - - Please do not mail any single individual unless you really need to. Keep - curl-related questions on a suitable mailing list. All available mailing - lists are listed in the MANUAL document and online at - https://curl.se/mail/ - - Keeping curl-related questions and discussions on mailing lists allows - others to join in and help, to share their ideas, to contribute their - suggestions and to spread their wisdom. Keeping discussions on public mailing - lists also allows for others to learn from this (both current and future - users thanks to the web based archives of the mailing lists), thus saving us - from having to repeat ourselves even more. Thanks for respecting this. - - If you have found or simply suspect a security problem in curl or libcurl, - submit all the details at https://hackerone.com/curl. On there we keep the - issue private while we investigate, confirm it, work and validate a fix and - agree on a time schedule for publication etc. That way we produce a fix in a - timely manner before the flaw is announced to the world, reducing the impact - the problem risks having on existing users. - - Security issues can also be taking to the curl security team by emailing - security at curl.se (closed list of receivers, mails are not disclosed). - - 1.9 Where do I buy commercial support for curl? - - curl is fully open source. It means you can hire any skilled engineer to fix - your curl-related problems. - - We list available alternatives on the curl website: - https://curl.se/support.html - - 1.10 How many are using curl? - - It is impossible to tell. - - We do not know how many users that knowingly have installed and use curl. - - We do not know how many users that use curl without knowing that they are in - fact using it. - - We do not know how many users that downloaded or installed curl and then - never use it. - - In 2020, we estimate that curl runs in roughly ten billion installations - world wide. - - 1.11 Why do you not update ca-bundle.crt - - In the curl project we have decided not to attempt to keep this file updated - (or even present) since deciding what to add to a ca cert bundle is an - undertaking we have not been ready to accept, and the one we can get from - Mozilla is perfectly fine so there is no need to duplicate that work. - - Today, with many services performed over HTTPS, every operating system - should come with a default ca cert bundle that can be deemed somewhat - trustworthy and that collection (if reasonably updated) should be deemed to - be a lot better than a private curl version. - - If you want the most recent collection of ca certs that Mozilla Firefox - uses, we recommend that you extract the collection yourself from Mozilla - Firefox (by running 'make ca-bundle), or by using our online service setup - for this purpose: https://curl.se/docs/caextract.html - - 1.12 I have a problem who, can I chat with? - - There is a bunch of friendly people hanging out in the #curl channel on the - IRC network libera.chat. If you are polite and nice, chances are good that - you can get -- or provide -- help instantly. - - 1.13 curl's ECCN number? - - The US government restricts exports of software that contains or uses - cryptography. When doing so, the Export Control Classification Number (ECCN) - is used to identify the level of export control etc. - - Apache Software Foundation gives a good explanation of ECCNs at - https://www.apache.org/dev/crypto.html - - We believe curl's number might be ECCN 5D002, another possibility is - 5D992. It seems necessary to write them (the authority that administers ECCN - numbers), asking to confirm. - - Comprehensible explanations of the meaning of such numbers and how to obtain - them (resp.) are here - - https://www.bis.doc.gov/licensing/exportingbasics.htm - https://www.bis.doc.gov/licensing/do_i_needaneccn.html - - An incomprehensible description of the two numbers above is here - https://www.bis.doc.gov/index.php/documents/new-encryption/1653-ccl5-pt2-3 - - 1.14 How do I submit my patch? - - We strongly encourage you to submit changes and improvements directly as - "pull requests" on GitHub: https://github.com/curl/curl/pulls - - If you for any reason cannot or will not deal with GitHub, send your patch to - the curl-library mailing list. We are many subscribers there and there are - lots of people who can review patches, comment on them and "receive" them - properly. - - Lots of more details are found in the CONTRIBUTE.md and INTERNALS.md - documents. - - 1.15 How do I port libcurl to my OS? - - Here's a rough step-by-step: - - 1. copy a suitable lib/config-*.h file as a start to lib/config-[youros].h - - 2. edit lib/config-[youros].h to match your OS and setup - - 3. edit lib/curl_setup.h to include config-[youros].h when your OS is - detected by the preprocessor, in the style others already exist - - 4. compile lib/*.c and make them into a library - - -2. Install Related Problems - - 2.1 configure fails when using static libraries - - You may find that configure fails to properly detect the entire dependency - chain of libraries when you provide static versions of the libraries that - configure checks for. - - The reason why static libraries is much harder to deal with is that for them - we do not get any help but the script itself must know or check what more - libraries that are needed (with shared libraries, that dependency "chain" is - handled automatically). This is an error-prone process and one that also - tends to vary over time depending on the release versions of the involved - components and may also differ between operating systems. - - For that reason, configure does few attempts to actually figure this out and - you are instead encouraged to set LIBS and LDFLAGS accordingly when you - invoke configure, and point out the needed libraries and set the necessary - flags yourself. - - 2.2 Does curl work with other SSL libraries? - - curl has been written to use a generic SSL function layer internally, and - that SSL functionality can then be provided by one out of many different SSL - backends. - - curl can be built to use one of the following SSL alternatives: OpenSSL, - LibreSSL, BoringSSL, AWS-LC, GnuTLS, wolfSSL, mbedTLS, Schannel (native - Windows) or Rustls. They all have their pros and cons, and we try to - maintain a comparison of them here: https://curl.se/docs/ssl-compared.html - - 2.3 How do I upgrade curl.exe in Windows? - - The curl tool that is shipped as an integrated component of Windows 10 and - Windows 11 is managed by Microsoft. If you were to delete the file or - replace it with a newer version downloaded from https://curl.se/windows, - then Windows Update will cease to work on your system. - - There is no way to independently force an upgrade of the curl.exe that is - part of Windows other than through the regular Windows update process. There - is also nothing the curl project itself can do about this, since this is - managed and controlled entirely by Microsoft as owners of the operating - system. - - You can always download and install the latest version of curl for Windows - from https://curl.se/windows into a separate location. - - 2.4 Does curl support SOCKS (RFC 1928) ? - - Yes, SOCKS 4 and 5 are supported. - -3. Usage problems - - 3.1 curl: (1) SSL is disabled, https: not supported - - If you get this output when trying to get anything from an HTTPS server, it - means that the instance of curl/libcurl that you are using was built without - support for this protocol. - - This could have happened if the configure script that was run at build time - could not find all libs and include files curl requires for SSL to work. If - the configure script fails to find them, curl is simply built without SSL - support. - - To get HTTPS support into a curl that was previously built but that reports - that HTTPS is not supported, you should dig through the document and logs - and check out why the configure script does not find the SSL libs and/or - include files. - - Also, check out the other paragraph in this FAQ labeled "configure does not - find OpenSSL even when it is installed". - - 3.2 How do I tell curl to resume a transfer? - - curl supports resumed transfers both ways on both FTP and HTTP. - Try the -C option. - - 3.3 Why does my posting using -F not work? - - You cannot arbitrarily use -F or -d, the choice between -F or -d depends on - the HTTP operation you need curl to do and what the web server that will - receive your post expects. - - If the form you are trying to submit uses the type 'multipart/form-data', - then and only then you must use the -F type. In all the most common cases, - you should use -d which then causes a posting with the type - 'application/x-www-form-urlencoded'. - - This is described in some detail in the MANUAL and TheArtOfHttpScripting - documents, and if you do not understand it the first time, read it again - before you post questions about this to the mailing list. Also, try reading - through the mailing list archives for old postings and questions regarding - this. - - 3.4 How do I tell curl to run custom FTP commands? - - You can tell curl to perform optional commands both before and/or after a - file transfer. Study the -Q/--quote option. - - Since curl is used for file transfers, you do not normally use curl to - perform FTP commands without transferring anything. Therefore you must - always specify a URL to transfer to/from even when doing custom FTP - commands, or use -I which implies the "no body" option sent to libcurl. - - 3.5 How can I disable the Accept: */* header? - - You can change all internally generated headers by adding a replacement with - the -H/--header option. By adding a header with empty contents you safely - disable that one. Use -H "Accept:" to disable that specific header. - - 3.6 Does curl support ASP, XML, XHTML or HTML version Y? - - To curl, all contents are alike. It does not matter how the page was - generated. It may be ASP, PHP, Perl, shell-script, SSI or plain HTML - files. There is no difference to curl and it does not even know what kind of - language that generated the page. - - See also item 3.14 regarding JavaScript. - - 3.7 Can I use curl to delete/rename a file through FTP? - - Yes. You specify custom FTP commands with -Q/--quote. - - One example would be to delete a file after you have downloaded it: - - curl -O ftp://example.com/coolfile -Q '-DELE coolfile' - - or rename a file after upload: - - curl -T infile ftp://example.com/dir/ -Q "-RNFR infile" -Q "-RNTO newname" - - 3.8 How do I tell curl to follow HTTP redirects? - - curl does not follow so-called redirects by default. The Location: header - that informs the client about this is only interpreted if you are using the - -L/--location option. As in: - - curl -L https://example.com - - Not all redirects are HTTP ones, see 4.14 - - 3.9 How do I use curl in my favorite programming language? - - Many programming languages have interfaces/bindings that allow you to use - curl without having to use the command line tool. If you are fluent in such - a language, you may prefer to use one of these interfaces instead. - - Find out more about which languages that support curl directly, and how to - install and use them, in the libcurl section of the curl website: - https://curl.se/libcurl/ - - All the various bindings to libcurl are made by other projects and people, - outside of the curl project. The curl project itself only produces libcurl - with its plain C API. If you do not find anywhere else to ask you can ask - about bindings on the curl-library list too, but be prepared that people on - that list may not know anything about bindings. - - In December 2021, there were interfaces available for the following - languages: Ada95, Basic, C, C++, Ch, Cocoa, D, Delphi, Dylan, Eiffel, - Euphoria, Falcon, Ferite, Gambas, glib/GTK+, Go, Guile, Harbour, Haskell, - Java, Julia, Lisp, Lua, Mono, .NET, node.js, Object-Pascal, OCaml, Pascal, - Perl, PHP, PostgreSQL, Python, R, Rexx, Ring, RPG, Ruby, Rust, Scheme, - Scilab, S-Lang, Smalltalk, SP-Forth, SPL, Tcl, Visual Basic, Visual FoxPro, - Q, wxwidgets, XBLite and Xoho. By the time you read this, additional ones - may have appeared. - - 3.10 What about SOAP, WebDAV, XML-RPC or similar protocols over HTTP? - - curl adheres to the HTTP spec, which basically means you can play with *any* - protocol that is built on top of HTTP. Protocols such as SOAP, WebDAV and - XML-RPC are all such ones. You can use -X to set custom requests and -H to - set custom headers (or replace internally generated ones). - - Using libcurl is of course just as good and you would just use the proper - library options to do the same. - - 3.11 How do I POST with a different Content-Type? - - You can always replace the internally generated headers with -H/--header. - To make a simple HTTP POST with text/xml as content-type, do something like: - - curl -d "datatopost" -H "Content-Type: text/xml" [URL] - - 3.12 Why do FTP-specific features over HTTP proxy fail? - - Because when you use an HTTP proxy, the protocol spoken on the network will - be HTTP, even if you specify an FTP URL. This effectively means that you - normally cannot use FTP-specific features such as FTP upload and FTP quote - etc. - - There is one exception to this rule, and that is if you can "tunnel through" - the given HTTP proxy. Proxy tunneling is enabled with a special option (-p) - and is generally not available as proxy admins usually disable tunneling to - ports other than 443 (which is used for HTTPS access through proxies). - - 3.13 Why do my single/double quotes fail? - - To specify a command line option that includes spaces, you might need to - put the entire option within quotes. Like in: - - curl -d " with spaces " example.com - - or perhaps - - curl -d ' with spaces ' example.com - - Exactly what kind of quotes and how to do this is entirely up to the shell - or command line interpreter that you are using. For most Unix shells, you - can more or less pick either single (') or double (") quotes. For - Windows/DOS command prompts you must use double (") quotes, and if the - option string contains inner double quotes you can escape them with a - backslash. - - For Windows powershell the arguments are not always passed on as expected - because curl is not a powershell script. You may or may not be able to use - single quotes. To escape inner double quotes seems to require a - backslash-backtick escape sequence and the outer quotes as double quotes. - - Please study the documentation for your particular environment. Examples in - the curl docs will use a mix of both of these as shown above. You must - adjust them to work in your environment. - - Remember that curl works and runs on more operating systems than most single - individuals have ever tried. - - 3.14 Does curl support JavaScript or PAC (automated proxy config)? - - Many webpages do magic stuff using embedded JavaScript. curl and libcurl - have no built-in support for that, so it will be treated just like any other - contents. - - .pac files are a Netscape invention and are sometimes used by organizations - to allow them to differentiate which proxies to use. The .pac contents is - just a JavaScript program that gets invoked by the browser and that returns - the name of the proxy to connect to. Since curl does not support JavaScript, - it cannot support .pac proxy configuration either. - - Some workarounds usually suggested to overcome this JavaScript dependency: - - Depending on the JavaScript complexity, write up a script that translates it - to another language and execute that. - - Read the JavaScript code and rewrite the same logic in another language. - - Implement a JavaScript interpreter, people have successfully used the - Mozilla JavaScript engine in the past. - - Ask your admins to stop this, for a static proxy setup or similar. - - 3.15 Can I do recursive fetches with curl? - - No. curl itself has no code that performs recursive operations, such as - those performed by wget and similar tools. - - There exists wrapper scripts with that functionality (for example the - curlmirror perl script), and you can write programs based on libcurl to do - it, but the command line tool curl itself cannot. - - 3.16 What certificates do I need when I use SSL? - - There are three different kinds of "certificates" to keep track of when we - talk about using SSL-based protocols (HTTPS or FTPS) using curl or libcurl. - - CLIENT CERTIFICATE - - The server you communicate with may require that you can provide this in - order to prove that you actually are who you claim to be. If the server - does not require this, you do not need a client certificate. - - A client certificate is always used together with a private key, and the - private key has a passphrase that protects it. - - SERVER CERTIFICATE - - The server you communicate with has a server certificate. You can and should - verify this certificate to make sure that you are truly talking to the real - server and not a server impersonating it. - - CERTIFICATE AUTHORITY CERTIFICATE ("CA cert") - - You often have several CA certs in a CA cert bundle that can be used to - verify a server certificate that was signed by one of the authorities in the - bundle. curl does not come with a CA cert bundle but most curl installs - provide one. You can also override the default. - - The server certificate verification process is made by using a Certificate - Authority certificate ("CA cert") that was used to sign the server - certificate. Server certificate verification is enabled by default in curl - and libcurl and is often the reason for problems as explained in FAQ entry - 4.12 and the SSLCERTS document - (https://curl.se/docs/sslcerts.html). Server certificates that are - "self-signed" or otherwise signed by a CA that you do not have a CA cert - for, cannot be verified. If the verification during a connect fails, you are - refused access. You then need to explicitly disable the verification to - connect to the server. - - 3.17 How do I list the root directory of an FTP server? - - There are two ways. The way defined in the RFC is to use an encoded slash - in the first path part. List the "/tmp" directory like this: - - curl ftp://ftp.example.com/%2ftmp/ - - or the not-quite-kosher-but-more-readable way, by simply starting the path - section of the URL with a slash: - - curl ftp://ftp.example.com//tmp/ - - 3.18 Can I use curl to send a POST/PUT and not wait for a response? - - No. - - You can easily write your own program using libcurl to do such stunts. - - 3.19 How do I get HTTP from a host using a specific IP address? - - For example, you may be trying out a website installation that is not yet in - the DNS. Or you have a site using multiple IP addresses for a given host - name and you want to address a specific one out of the set. - - Set a custom Host: header that identifies the server name you want to reach - but use the target IP address in the URL: - - curl --header "Host: www.example.com" https://somewhere.example/ - - You can also opt to add faked hostname entries to curl with the --resolve - option. That has the added benefit that things like redirects will also work - properly. The above operation would instead be done as: - - curl --resolve www.example.com:80:127.0.0.1 https://www.example.com/ - - 3.20 How to SFTP from my user's home directory? - - Contrary to how FTP works, SFTP and SCP URLs specify the exact directory to - work with. It means that if you do not specify that you want the user's home - directory, you get the actual root directory. - - To specify a file in your user's home directory, you need to use the correct - URL syntax which for SFTP might look similar to: - - curl -O -u user:password sftp://example.com/~/file.txt - - and for SCP it is just a different protocol prefix: - - curl -O -u user:password scp://example.com/~/file.txt - - 3.21 Protocol xxx not supported or disabled in libcurl - - When passing on a URL to curl to use, it may respond that the particular - protocol is not supported or disabled. The particular way this error message - is phrased is because curl does not make a distinction internally of whether - a particular protocol is not supported (i.e. never got any code added that - knows how to speak that protocol) or if it was explicitly disabled. curl can - be built to only support a given set of protocols, and the rest would then - be disabled or not supported. - - Note that this error will also occur if you pass a wrongly spelled protocol - part as in "htpts://example.com" or as in the less evident case if you - prefix the protocol part with a space as in " https://example.com/". - - 3.22 curl -X gives me HTTP problems - - In normal circumstances, -X should hardly ever be used. - - By default you use curl without explicitly saying which request method to - use when the URL identifies an HTTP transfer. If you just pass in a URL like - "curl https://example.com" it will use GET. If you use -d or -F curl will use - POST, -I will cause a HEAD and -T will make it a PUT. - - If for whatever reason you are not happy with these default choices that curl - does for you, you can override those request methods by specifying -X - [WHATEVER]. This way you can for example send a DELETE by doing "curl -X - DELETE [URL]". - - It is thus pointless to do "curl -XGET [URL]" as GET would be used anyway. - In the same vein it is pointless to do "curl -X POST -d data [URL]". You can - make a fun and somewhat rare request that sends a request-body in a GET - request with something like "curl -X GET -d data [URL]" - - Note that -X does not actually change curl's behavior as it only modifies the - actual string sent in the request, but that may of course trigger a - different set of events. - - Accordingly, by using -XPOST on a command line that for example would follow - a 303 redirect, you will effectively prevent curl from behaving - correctly. Be aware. - - -4. Running Problems - - 4.2 Why do I get problems when I use & or % in the URL? - - In general Unix shells, the & symbol is treated specially and when used, it - runs the specified command in the background. To safely send the & as a part - of a URL, you should quote the entire URL by using single (') or double (") - quotes around it. Similar problems can also occur on some shells with other - characters, including ?*!$~(){}<>\|;`. When in doubt, quote the URL. - - An example that would invoke a remote CGI that uses &-symbols could be: - - curl 'https://www.example.com/cgi-bin/query?text=yes&q=curl' - - In Windows, the standard DOS shell treats the percent sign specially and you - need to use TWO percent signs for each single one you want to use in the - URL. - - If you want a literal percent sign to be part of the data you pass in a POST - using -d/--data you must encode it as '%25' (which then also needs the - percent sign doubled on Windows machines). - - 4.3 How can I use {, }, [ or ] to specify multiple URLs? - - Because those letters have a special meaning to the shell, to be used in - a URL specified to curl you must quote them. - - An example that downloads two URLs (sequentially) would be: - - curl '{curl,www}.haxx.se' - - To be able to use those characters as actual parts of the URL (without using - them for the curl URL "globbing" system), use the -g/--globoff option: - - curl -g 'www.example.com/weirdname[].html' - - 4.4 Why do I get downloaded data even though the webpage does not exist? - - curl asks remote servers for the page you specify. If the page does not exist - at the server, the HTTP protocol defines how the server should respond and - that means that headers and a "page" will be returned. That is simply how - HTTP works. - - By using the --fail option you can tell curl explicitly to not get any data - if the HTTP return code does not say success. - - 4.5 Why do I get return code XXX from an HTTP server? - - RFC 2616 clearly explains the return codes. This is a short transcript. Go - read the RFC for exact details: - - 4.5.1 "400 Bad Request" - - The request could not be understood by the server due to malformed - syntax. The client SHOULD NOT repeat the request without modifications. - - 4.5.2 "401 Unauthorized" - - The request requires user authentication. - - 4.5.3 "403 Forbidden" - - The server understood the request, but is refusing to fulfill it. - Authorization will not help and the request SHOULD NOT be repeated. - - 4.5.4 "404 Not Found" - - The server has not found anything matching the Request-URI. No indication - is given as to whether the condition is temporary or permanent. - - 4.5.5 "405 Method Not Allowed" - - The method specified in the Request-Line is not allowed for the resource - identified by the Request-URI. The response MUST include an Allow header - containing a list of valid methods for the requested resource. - - 4.5.6 "301 Moved Permanently" - - If you get this return code and an HTML output similar to this: - -

Moved Permanently

The document has moved here. - - it might be because you requested a directory URL but without the trailing - slash. Try the same operation again _with_ the trailing URL, or use the - -L/--location option to follow the redirection. - - 4.6 Can you tell me what error code 142 means? - - All curl error codes are described at the end of the man page, in the - section called "EXIT CODES". - - Error codes that are larger than the highest documented error code means - that curl has exited due to a crash. This is a serious error, and we - appreciate a detailed bug report from you that describes how we could go - ahead and repeat this. - - 4.7 How do I keep usernames and passwords secret in curl command lines? - - This problem has two sides: - - The first part is to avoid having clear-text passwords in the command line - so that they do not appear in 'ps' outputs and similar. That is easily - avoided by using the "-K" option to tell curl to read parameters from a file - or stdin to which you can pass the secret info. curl itself will also - attempt to "hide" the given password by blanking out the option - this - does not work on all platforms. - - To keep the passwords in your account secret from the rest of the world is - not a task that curl addresses. You could of course encrypt them somehow to - at least hide them from being read by human eyes, but that is not what - anyone would call security. - - Also note that regular HTTP (using Basic authentication) and FTP passwords - are sent as cleartext across the network. All it takes for anyone to fetch - them is to listen on the network. Eavesdropping is easy. Use more secure - authentication methods (like Digest, Negotiate or even NTLM) or consider the - SSL-based alternatives HTTPS and FTPS. - - 4.8 I found a bug - - It is not a bug if the behavior is documented. Read the docs first. - Especially check out the KNOWN_BUGS file, it may be a documented bug. - - If it is a problem with a binary you have downloaded or a package for your - particular platform, try contacting the person who built the package/archive - you have. - - If there is a bug, read the BUGS document first. Then report it as described - in there. - - 4.9 curl cannot authenticate to a server that requires NTLM? - - NTLM support requires OpenSSL, GnuTLS, mbedTLS or Microsoft Windows - libraries at build-time to provide this functionality. - - 4.10 My HTTP request using HEAD, PUT or DELETE does not work - - Many web servers allow or demand that the administrator configures the - server properly for these requests to work on the web server. - - Some servers seem to support HEAD only on certain kinds of URLs. - - To fully grasp this, try the documentation for the particular server - software you are trying to interact with. This is not anything curl can do - anything about. - - 4.11 Why do my HTTP range requests return the full document? - - Because the range may not be supported by the server, or the server may - choose to ignore it and return the full document anyway. - - 4.12 Why do I get "certificate verify failed" ? - - When you invoke curl and get an error 60 error back it means that curl - could not verify that the server's certificate was good. curl verifies the - certificate using the CA cert bundle and verifying for which names the - certificate has been granted. - - To completely disable the certificate verification, use -k. This does - however enable man-in-the-middle attacks and makes the transfer INSECURE. - We strongly advise against doing this for more than experiments. - - If you get this failure with a CA cert bundle installed and used, the - server's certificate might not be signed by one of the CA's in your CA - store. It might for example be self-signed. You then correct this problem by - obtaining a valid CA cert for the server. Or again, decrease the security by - disabling this check. - - At times, you find that the verification works in your favorite browser but - fails in curl. When this happens, the reason is usually that the server - sends an incomplete cert chain. The server is mandated to send all - "intermediate certificates" but does not. This typically works with browsers - anyway since they A) cache such certs and B) supports AIA which downloads - such missing certificates on demand. This is a server misconfiguration. A - good way to figure out if this is the case it to use the SSL Labs server - test and check the certificate chain: https://www.ssllabs.com/ssltest/ - - Details are also in the SSLCERTS.md document, found online here: - https://curl.se/docs/sslcerts.html - - 4.13 Why is curl -R on Windows one hour off? - - Since curl 7.53.0 this issue should be fixed as long as curl was built with - any modern compiler that allows for a 64-bit curl_off_t type. For older - compilers or prior curl versions it may set a time that appears one hour off. - This happens due to a flaw in how Windows stores and uses file modification - times and it is not easily worked around. For more details read this: - https://www.codeproject.com/Articles/1144/Beating-the-Daylight-Savings-Time-bug-and-getting - - 4.14 Redirects work in browser but not with curl - - curl supports HTTP redirects well (see item 3.8). Browsers generally support - at least two other ways to perform redirects that curl does not: - - Meta tags. You can write an HTML tag that will cause the browser to redirect - to another given URL after a certain time. - - JavaScript. You can write a JavaScript program embedded in an HTML page that - redirects the browser to another given URL. - - There is no way to make curl follow these redirects. You must either - manually figure out what the page is set to do, or write a script that parses - the results and fetches the new URL. - - 4.15 FTPS does not work - - curl supports FTPS (sometimes known as FTP-SSL) both implicit and explicit - mode. - - When a URL is used that starts with FTPS://, curl assumes implicit SSL on - the control connection and will therefore immediately connect and try to - speak SSL. FTPS:// connections default to port 990. - - To use explicit FTPS, you use an FTP:// URL and the --ssl-reqd option (or one - of its related flavors). This is the most common method, and the one - mandated by RFC 4217. This kind of connection will then of course use the - standard FTP port 21 by default. - - 4.16 My HTTP POST or PUT requests are slow - - libcurl makes all POST and PUT requests (except for requests with a small - request body) use the "Expect: 100-continue" header. This header allows the - server to deny the operation early so that libcurl can bail out before having - to send any data. This is useful in authentication cases and others. - - However, many servers do not implement the Expect: stuff properly and if the - server does not respond (positively) within 1 second libcurl will continue - and send off the data anyway. - - You can disable libcurl's use of the Expect: header the same way you disable - any header, using -H / CURLOPT_HTTPHEADER, or by forcing it to use HTTP 1.0. - - 4.17 Non-functional connect timeouts - - In most Windows setups having a timeout longer than 21 seconds make no - difference, as it will only send 3 TCP SYN packets and no more. The second - packet sent three seconds after the first and the third six seconds after - the second. No more than three packets are sent, no matter how long the - timeout is set. - - See option TcpMaxConnectRetransmissions on this page: - https://web.archive.org/web/20160819015101/support.microsoft.com/en-us/kb/175523 - - Also, even on non-Windows systems there may run a firewall or anti-virus - software or similar that accepts the connection but does not actually do - anything else. This will make (lib)curl to consider the connection connected - and thus the connect timeout will not trigger. - - 4.18 file:// URLs containing drive letters (Windows, NetWare) - - When using curl to try to download a local file, one might use a URL - in this format: - - file://D:/blah.txt - - you will find that even if D:\blah.txt does exist, curl returns a 'file - not found' error. - - According to RFC 1738 (https://datatracker.ietf.org/doc/html/rfc1738), - file:// URLs must contain a host component, but it is ignored by - most implementations. In the above example, 'D:' is treated as the - host component, and is taken away. Thus, curl tries to open '/blah.txt'. - If your system is installed to drive C:, that will resolve to 'C:\blah.txt', - and if that does not exist you will get the not found error. - - To fix this problem, use file:// URLs with *three* leading slashes: - - file:///D:/blah.txt - - Alternatively, if it makes more sense, specify 'localhost' as the host - component: - - file://localhost/D:/blah.txt - - In either case, curl should now be looking for the correct file. - - 4.19 Why does not curl return an error when the network cable is unplugged? - - Unplugging a cable is not an error situation. The TCP/IP protocol stack - was designed to be fault tolerant, so even though there may be a physical - break somewhere the connection should not be affected, just possibly - delayed. Eventually, the physical break will be fixed or the data will be - re-routed around the physical problem through another path. - - In such cases, the TCP/IP stack is responsible for detecting when the - network connection is irrevocably lost. Since with some protocols it is - perfectly legal for the client to wait indefinitely for data, the stack may - never report a problem, and even when it does, it can take up to 20 minutes - for it to detect an issue. The curl option --keepalive-time enables - keep-alive support in the TCP/IP stack which makes it periodically probe the - connection to make sure it is still available to send data. That should - reliably detect any TCP/IP network failure. - - TCP keep alive will not detect the network going down before the TCP/IP - connection is established (e.g. during a DNS lookup) or using protocols that - do not use TCP. To handle those situations, curl offers a number of timeouts - on its own. --speed-limit/--speed-time will abort if the data transfer rate - falls too low, and --connect-timeout and --max-time can be used to put an - overall timeout on the connection phase or the entire transfer. - - A libcurl-using application running in a known physical environment (e.g. - an embedded device with only a single network connection) may want to act - immediately if its lone network connection goes down. That can be achieved - by having the application monitor the network connection on its own using an - OS-specific mechanism, then signaling libcurl to abort (see also item 5.13). - - 4.20 curl does not return error for HTTP non-200 responses - - Correct. Unless you use -f (--fail). - - When doing HTTP transfers, curl will perform exactly what you are asking it - to do and if successful it will not return an error. You can use curl to - test your web server's "file not found" page (that gets 404 back), you can - use it to check your authentication protected webpages (that gets a 401 - back) and so on. - - The specific HTTP response code does not constitute a problem or error for - curl. It simply sends and delivers HTTP as you asked and if that worked, - everything is fine and dandy. The response code is generally providing more - higher level error information that curl does not care about. The error was - not in the HTTP transfer. - - If you want your command line to treat error codes in the 400 and up range - as errors and thus return a non-zero value and possibly show an error - message, curl has a dedicated option for that: -f (CURLOPT_FAILONERROR in - libcurl speak). - - You can also use the -w option and the variable %{response_code} to extract - the exact response code that was returned in the response. - -5. libcurl Issues - - 5.1 Is libcurl thread-safe? - - Yes. - - We have written the libcurl code specifically adjusted for multi-threaded - programs. libcurl will use thread-safe functions instead of non-safe ones if - your system has such. Note that you must never share the same handle in - multiple threads. - - There may be some exceptions to thread safety depending on how libcurl was - built. Please review the guidelines for thread safety to learn more: - https://curl.se/libcurl/c/threadsafe.html - - 5.2 How can I receive all data into a large memory chunk? - - [ See also the examples/getinmemory.c source ] - - You are in full control of the callback function that gets called every time - there is data received from the remote server. You can make that callback do - whatever you want. You do not have to write the received data to a file. - - One solution to this problem could be to have a pointer to a struct that you - pass to the callback function. You set the pointer using the - CURLOPT_WRITEDATA option. Then that pointer will be passed to the callback - instead of a FILE * to a file: - - /* imaginary struct */ - struct MemoryStruct { - char *memory; - size_t size; - }; - - /* imaginary callback function */ - size_t - WriteMemoryCallback(void *ptr, size_t size, size_t nmemb, void *data) - { - size_t realsize = size * nmemb; - struct MemoryStruct *mem = (struct MemoryStruct *)data; - - mem->memory = (char *)realloc(mem->memory, mem->size + realsize + 1); - if(mem->memory) { - memcpy(&(mem->memory[mem->size]), ptr, realsize); - mem->size += realsize; - mem->memory[mem->size] = 0; - } - return realsize; - } - - 5.3 How do I fetch multiple files with libcurl? - - libcurl has excellent support for transferring multiple files. You should - just repeatedly set new URLs with curl_easy_setopt() and then transfer it - with curl_easy_perform(). The handle you get from curl_easy_init() is not - only reusable, but you are even encouraged to reuse it if you can, as that - will enable libcurl to use persistent connections. - - 5.4 Does libcurl do Winsock initialization on Win32 systems? - - Yes, if told to in the curl_global_init() call. - - 5.5 Does CURLOPT_WRITEDATA and CURLOPT_READDATA work on Win32 ? - - Yes, but you cannot open a FILE * and pass the pointer to a DLL and have - that DLL use the FILE * (as the DLL and the client application cannot access - each others' variable memory areas). If you set CURLOPT_WRITEDATA you must - also use CURLOPT_WRITEFUNCTION as well to set a function that writes the - file, even if that simply writes the data to the specified FILE *. - Similarly, if you use CURLOPT_READDATA you must also specify - CURLOPT_READFUNCTION. - - 5.6 What about Keep-Alive or persistent connections? - - curl and libcurl have excellent support for persistent connections when - transferring several files from the same server. curl will attempt to reuse - connections for all URLs specified on the same command line/config file, and - libcurl will reuse connections for all transfers that are made using the - same libcurl handle. - - When you use the easy interface the connection cache is kept within the easy - handle. If you instead use the multi interface, the connection cache will be - kept within the multi handle and will be shared among all the easy handles - that are used within the same multi handle. - - 5.7 Link errors when building libcurl on Windows - - You need to make sure that your project, and all the libraries (both static - and dynamic) that it links against, are compiled/linked against the same run - time library. - - This is determined by the /MD, /ML, /MT (and their corresponding /M?d) - options to the command line compiler. /MD (linking against MSVCRT dll) seems - to be the most commonly used option. - - When building an application that uses the static libcurl library, you must - add -DCURL_STATICLIB to your CFLAGS. Otherwise the linker will look for - dynamic import symbols. If you are using Visual Studio, you need to instead - add CURL_STATICLIB in the "Preprocessor Definitions" section. - - If you get a linker error like "unknown symbol __imp__curl_easy_init ..." you - have linked against the wrong (static) library. If you want to use the - libcurl.dll and import lib, you do not need any extra CFLAGS, but use one of - the import libraries below. These are the libraries produced by the various - lib/Makefile.* files: - - Target: static lib. import lib for libcurl*.dll. - ----------------------------------------------------------- - MinGW: libcurl.a libcurldll.a - MSVC (release): libcurl.lib libcurl_imp.lib - MSVC (debug): libcurld.lib libcurld_imp.lib - Borland: libcurl.lib libcurl_imp.lib - - 5.8 libcurl.so.X: open failed: No such file or directory - - This is an error message you might get when you try to run a program linked - with a shared version of libcurl and your runtime linker (ld.so) could not - find the shared library named libcurl.so.X. (Where X is the number of the - current libcurl ABI, typically 3 or 4). - - You need to make sure that ld.so finds libcurl.so.X. You can do that - multiple ways, and it differs somewhat between different operating systems. - They are usually: - - * Add an option to the linker command line that specify the hard-coded path - the runtime linker should check for the lib (usually -R) - - * Set an environment variable (LD_LIBRARY_PATH for example) where ld.so - should check for libs - - * Adjust the system's config to check for libs in the directory where you have - put the library (like Linux's /etc/ld.so.conf) - - 'man ld.so' and 'man ld' will tell you more details - - 5.9 How does libcurl resolve hostnames? - - libcurl supports a large number of name resolve functions. One of them is - picked at build-time and will be used unconditionally. Thus, if you want to - change name resolver function you must rebuild libcurl and tell it to use a - different function. - - - The non-IPv6 resolver that can use one of four different hostname resolve - calls (depending on what your system supports): - - A - gethostbyname() - B - gethostbyname_r() with 3 arguments - C - gethostbyname_r() with 5 arguments - D - gethostbyname_r() with 6 arguments - - - The IPv6-resolver that uses getaddrinfo() - - - The c-ares based name resolver that uses the c-ares library for resolves. - Using this offers asynchronous name resolves. - - - The threaded resolver (default option on Windows). It uses: - - A - gethostbyname() on plain IPv4 hosts - B - getaddrinfo() on IPv6 enabled hosts - - Also note that libcurl never resolves or reverse-lookups addresses given as - pure numbers, such as 127.0.0.1 or ::1. - - 5.10 How do I prevent libcurl from writing the response to stdout? - - libcurl provides a default built-in write function that writes received data - to stdout. Set the CURLOPT_WRITEFUNCTION to receive the data, or possibly - set CURLOPT_WRITEDATA to a different FILE * handle. - - 5.11 How do I make libcurl not receive the whole HTTP response? - - You make the write callback (or progress callback) return an error and - libcurl will then abort the transfer. - - 5.12 Can I make libcurl fake or hide my real IP address? - - No. libcurl operates on a higher level. Besides, faking IP address would - imply sending IP packets with a made-up source address, and then you normally - get a problem with receiving the packet sent back as they would then not be - routed to you. - - If you use a proxy to access remote sites, the sites will not see your local - IP address but instead the address of the proxy. - - Also note that on many networks NATs or other IP-munging techniques are used - that makes you see and use a different IP address locally than what the - remote server will see you coming from. You may also consider using - https://www.torproject.org/ . - - 5.13 How do I stop an ongoing transfer? - - With the easy interface you make sure to return the correct error code from - one of the callbacks, but none of them are instant. There is no function you - can call from another thread or similar that will stop it immediately. - Instead, you need to make sure that one of the callbacks you use returns an - appropriate value that will stop the transfer. Suitable callbacks that you - can do this with include the progress callback, the read callback and the - write callback. - - If you are using the multi interface, you can also stop a transfer by - removing the particular easy handle from the multi stack at any moment you - think the transfer is done or when you wish to abort the transfer. - - 5.14 Using C++ non-static functions for callbacks? - - libcurl is a C library, it does not know anything about C++ member functions. - - You can overcome this "limitation" with relative ease using a static - member function that is passed a pointer to the class: - - // f is the pointer to your object. - static size_t YourClass::func(void *buffer, size_t sz, size_t n, void *f) - { - // Call non-static member function. - static_cast(f)->nonStaticFunction(); - } - - // This is how you pass pointer to the static function: - curl_easy_setopt(hcurl, CURLOPT_WRITEFUNCTION, YourClass::func); - curl_easy_setopt(hcurl, CURLOPT_WRITEDATA, this); - - 5.15 How do I get an FTP directory listing? - - If you end the FTP URL you request with a slash, libcurl will provide you - with a directory listing of that given directory. You can also set - CURLOPT_CUSTOMREQUEST to alter what exact listing command libcurl would use - to list the files. - - The follow-up question tends to be how is a program supposed to parse the - directory listing. How does it know what's a file and what's a directory and - what's a symlink etc. If the FTP server supports the MLSD command then it - will return data in a machine-readable format that can be parsed for type. - The types are specified by RFC 3659 section 7.5.1. If MLSD is not supported - then you have to work with what you are given. The LIST output format is - entirely at the server's own liking and the NLST output does not reveal any - types and in many cases does not even include all the directory entries. - Also, both LIST and NLST tend to hide Unix-style hidden files (those that - start with a dot) by default so you need to do "LIST -a" or similar to see - them. - - Example - List only directories. - ftp.funet.fi supports MLSD and ftp.kernel.org does not: - - curl -s ftp.funet.fi/pub/ -X MLSD | \ - perl -lne 'print if s/(?:^|;)type=dir;[^ ]+ (.+)$/$1/' - - curl -s ftp.kernel.org/pub/linux/kernel/ | \ - perl -lne 'print if s/^d[-rwx]{9}(?: +[^ ]+){7} (.+)$/$1/' - - If you need to parse LIST output in libcurl one such existing - list parser is available at https://cr.yp.to/ftpparse.html Versions of - libcurl since 7.21.0 also provide the ability to specify a wildcard to - download multiple files from one FTP directory. - - 5.16 I want a different time-out - - Sometimes users realize that CURLOPT_TIMEOUT and CURLOPT_CONNECTIMEOUT are - not sufficiently advanced or flexible to cover all the various use cases and - scenarios applications end up with. - - libcurl offers many more ways to time-out operations. A common alternative - is to use the CURLOPT_LOW_SPEED_LIMIT and CURLOPT_LOW_SPEED_TIME options to - specify the lowest possible speed to accept before to consider the transfer - timed out. - - The most flexible way is by writing your own time-out logic and using - CURLOPT_XFERINFOFUNCTION (perhaps in combination with other callbacks) and - use that to figure out exactly when the right condition is met when the - transfer should get stopped. - - 5.17 Can I write a server with libcurl? - - No. libcurl offers no functions or building blocks to build any kind of - Internet protocol server. libcurl is only a client-side library. For server - libraries, you need to continue your search elsewhere but there exist many - good open source ones out there for most protocols you could want a server - for. There are also really good stand-alone servers that have been tested - and proven for many years. There is no need for you to reinvent them. - - 5.18 Does libcurl use threads? - - Put simply: no, libcurl will execute in the same thread you call it in. All - callbacks will be called in the same thread as the one you call libcurl in. - - If you want to avoid your thread to be blocked by the libcurl call, you make - sure you use the non-blocking multi API which will do transfers - asynchronously - still in the same single thread. - - libcurl will potentially internally use threads for name resolving, if it - was built to work like that, but in those cases it will create the child - threads by itself and they will only be used and then killed internally by - libcurl and never exposed to the outside. - -6. License Issues - - curl and libcurl are released under an MIT/X derivative license. The license - is liberal and should not impose a problem for your project. This section is - just a brief summary for the cases we get the most questions. (Parts of this - section was much enhanced by Bjorn Reese.) - - We are not lawyers and this is not legal advice. You should probably consult - one if you want true and accurate legal insights without our prejudice. Note - especially that this section concerns the libcurl license only; compiling in - features of libcurl that depend on other libraries (e.g. OpenSSL) may affect - the licensing obligations of your application. - - 6.1 I have a GPL program, can I use the libcurl library? - - Yes - - Since libcurl may be distributed under the MIT/X derivative license, it can - be used together with GPL in any software. - - 6.2 I have a closed-source program, can I use the libcurl library? - - Yes - - libcurl does not put any restrictions on the program that uses the library. - - 6.3 I have a BSD licensed program, can I use the libcurl library? - - Yes - - libcurl does not put any restrictions on the program that uses the library. - - 6.4 I have a program that uses LGPL libraries, can I use libcurl? - - Yes - - The LGPL license does not clash with other licenses. - - 6.5 Can I modify curl/libcurl for my program and keep the changes secret? - - Yes - - The MIT/X derivative license practically allows you to do almost anything - with the sources, on the condition that the copyright texts in the sources - are left intact. - - 6.6 Can you please change the curl/libcurl license to XXXX? - - No. - - We have carefully picked this license after years of development and - discussions and a large amount of people have contributed with source code - knowing that this is the license we use. This license puts the restrictions - we want on curl/libcurl and it does not spread to other programs or - libraries that use it. It should be possible for everyone to use libcurl or - curl in their projects, no matter what license they already have in use. - - 6.7 What are my obligations when using libcurl in my commercial apps? - - Next to none. All you need to adhere to is the MIT-style license (stated in - the COPYING file) which basically says you have to include the copyright - notice in "all copies" and that you may not use the copyright holder's name - when promoting your software. - - You do not have to release any of your source code. - - You do not have to reveal or make public any changes to the libcurl source - code. - - You do not have to broadcast to the world that you are using libcurl within - your app. - - All we ask is that you disclose "the copyright notice and this permission - notice" somewhere. Most probably like in the documentation or in the section - where other third party dependencies already are mentioned and acknowledged. - - As can be seen here: https://curl.se/docs/companies.html and elsewhere, - more and more companies are discovering the power of libcurl and take - advantage of it even in commercial environments. - - -7. PHP/CURL Issues - - 7.1 What is PHP/CURL? - - The module for PHP that makes it possible for PHP programs to access curl- - functions from within PHP. - - In the curl project we call this module PHP/CURL to differentiate it from - curl the command line tool and libcurl the library. The PHP team however - does not refer to it like this (for unknown reasons). They call it plain - CURL (often using all caps) or sometimes ext/curl, but both cause much - confusion to users which in turn gives us a higher question load. - - 7.2 Who wrote PHP/CURL? - - PHP/CURL was initially written by Sterling Hughes. - - 7.3 Can I perform multiple requests using the same handle? - - Yes - at least in PHP version 4.3.8 and later (this has been known to not - work in earlier versions, but the exact version when it started to work is - unknown to me). - - After a transfer, you just set new options in the handle and make another - transfer. This will make libcurl reuse the same connection if it can. - - 7.4 Does PHP/CURL have dependencies? - - PHP/CURL is a module that comes with the regular PHP package. It depends on - and uses libcurl, so you need to have libcurl installed properly before - PHP/CURL can be used. - -8. Development - - 8.1 Why does curl use C89? - - As with everything in curl, there is a history and we keep using what we have - used before until someone brings up the subject and argues for and works on - changing it. - - We started out using C89 in the 1990s because that was the only way to write - a truly portable C program and have it run as widely as possible. C89 was for - a long time even necessary to make things work on otherwise considered modern - platforms such as Windows. Today, we do not really know how many users that - still require the use of a C89 compiler. - - We will continue to use C89 for as long as nobody brings up a strong enough - reason for us to change our minds. The core developers of the project do not - feel restricted by this and we are not convinced that going C99 will offer us - enough of a benefit to warrant the risk of cutting off a share of users. - - 8.2 Will curl be rewritten? - - In one go: no. Little by little over time? Maybe. - - Over the years, new languages and clever operating environments come and go. - Every now and then the urge apparently arises to request that we rewrite curl - in another language. - - Some the most important properties in curl are maintaining the API and ABI - for libcurl and keeping the behavior for the command line tool. As long as we - can do that, everything else is up for discussion. To maintain the ABI, we - probably have to maintain a certain amount of code in C, and to remain rock - stable, we will never risk anything by rewriting a lot of things in one go. - That said, we can certainly offer more and more optional backends written in - other languages, as long as those backends can be plugged in at build-time. - Backends can be written in any language, but should probably provide APIs - usable from C to ease integration and transition. diff --git a/docs/FAQ.md b/docs/FAQ.md new file mode 100644 index 000000000000..ffef644418b2 --- /dev/null +++ b/docs/FAQ.md @@ -0,0 +1,1432 @@ + + +# Frequently Asked Questions + +# Philosophy + +## What is curl? + +curl is the name of the project. The name is a play on *Client for URLs*, +originally with URL spelled in uppercase to make it obvious it deals with +URLs. The fact it can also be read as *see URL* also helped, it works as an +abbreviation for *Client URL Request Library* or why not the recursive +version: *curl URL Request Library*. + +The curl project produces two products: + +### libcurl + +A client-side URL transfer library, supporting DICT, FILE, FTP, FTPS, GOPHER, +GOPHERS, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, MQTT, POP3, POP3S, RTMP, +RTMPS, RTSP, SCP, SFTP, SMB, SMBS, SMTP, SMTPS, TELNET, TFTP, WS and WSS. + +libcurl supports HTTPS certificates, HTTP POST, HTTP PUT, FTP uploading, +Kerberos, SPNEGO, HTTP form based upload, proxies, cookies, user+password +authentication, file transfer resume, http proxy tunneling and more. + +libcurl is highly portable, it builds and works identically on numerous +platforms. The [internals document](https://curl.se/docs/install.html#Ports) +lists more than 110 operating systems and 28 CPU architectures on which curl +has been reported to run. + +libcurl is free, thread-safe, IPv6 compatible, feature rich, well supported +and fast. + +### curl + +A command line tool for getting or sending data using URL syntax. + +Since curl uses libcurl, curl supports the same wide range of common Internet +protocols that libcurl does. + +We pronounce curl with an initial k sound. It rhymes with words like girl and +earl. [This is a short WAV +file](https://media.merriam-webster.com/soundc11/c/curl0001.wav) to help you. + +There are numerous sub-projects and related projects that also use the word +curl in the project names in various combinations, but you should take notice +that this FAQ is directed at the command-line tool named curl (and libcurl the +library), and may therefore not be valid for other curl-related projects. +(There is however a small section for the PHP/CURL in this FAQ.) + +## What is libcurl? + +libcurl is a reliable and portable library for doing Internet data transfers +using one or more of its supported Internet protocols. + +You can use libcurl freely in your application, be it open source, commercial +or closed-source. + +libcurl is most probably the most portable, most powerful and most often used +C-based multi-platform file transfer library on this planet - be it open +source or commercial. + +## What is curl not? + +curl is not a Wget clone. That is a common misconception. Never, during curl's +development, have we intended curl to replace Wget or compete on its market. +curl is targeted at single-shot file transfers. + +curl is not a website mirroring program. If you want to use curl to mirror +something: fine, go ahead and write a script that wraps around curl or use +libcurl to make it reality. + +curl is not an FTP site mirroring program. Sure, get and send FTP with curl +but if you want systematic and sequential behavior you should write a script +(or write a new program that interfaces libcurl) and do it. + +curl is not a PHP tool, even though it works perfectly well when used from or +with PHP (when using the PHP/CURL module). + +curl is not a program for a single operating system. curl exists, compiles, +builds and runs under a wide range of operating systems, including all modern +Unixes (and a bunch of older ones too), Windows, Amiga, OS/2, macOS, QNX etc. + +## When will you make curl do ... ? + +We love suggestions of what to change in order to make curl and libcurl +better. We do however believe in a few rules when it comes to the future of +curl: + +curl the command line tool is to remain a non-graphical command line tool. If +you want GUIs or fancy scripting capabilities, you should look for another +tool that uses libcurl. + +We do not add things to curl that other small and available tools already do +well at the side. curl's output can be piped into another program or +redirected to another file for the next program to interpret. + +We focus on protocol related issues and improvements. If you want to do more +magic with the supported protocols than curl currently does, chances are good +we will agree. If you want to add more protocols, we may agree. + +If you want someone else to do all the work while you wait for us to implement +it for you, that is not a friendly attitude. We spend a considerable time +already on maintaining and developing curl. In order to get more out of us, +you should consider trading in some of your time and effort in return. Simply +go to the [GitHub repository](https://github.com/curl/curl), fork the project, +and create pull requests with your proposed changes. + +If you write the code, chances are better that it will get into curl faster. + +## Who makes curl? + +curl and libcurl are not made by any single individual. Daniel Stenberg is +project leader and main developer, but other persons' submissions are +important and crucial. Anyone can contribute and post their changes and +improvements and have them inserted in the main sources (of course on the +condition that developers agree that the fixes are good). + +The full list of all contributors is found in the docs/THANKS file. + +curl is developed by a community, with Daniel at the wheel. + +## What do you get for making curl? + +Project curl is entirely free and open. We do this voluntarily, mostly in our +spare time. Companies may pay individual developers to work on curl. This is +not controlled by nor supervised in any way by the curl project. + +We get help from companies. Haxx provides website, bandwidth, mailing lists +etc, GitHub hosts [the primary git repository](https://github.com/curl/curl) +and other services like the bug tracker. Also again, some companies have +sponsored certain parts of the development in the past and I hope some will +continue to do so in the future. + +If you want to [support our project](https://curl.se/sponsors.html), consider +a donation or a banner-program or even better: by helping us with coding, +documenting or testing etc. + +## What about CURL from curl.com? + +During the summer of 2001, curl.com was busy advertising their client-side +programming language for the web, named CURL. + +We are in no way associated with curl.com or their CURL programming language. + +Our project name curl has been in effective use since 1998. We were not the +first computer related project to use the name *curl* and do not claim any +rights to the name. + +We recognize that we will be living in parallel with curl.com and wish them +every success. + +## I have a problem, who do I mail? + +Please do not mail any single individual unless you really need to. Keep +curl-related questions on a suitable mailing list. All available mailing lists +are listed [online](https://curl.se/mail/). + +Keeping curl-related questions and discussions on mailing lists allows others +to join in and help, to share their ideas, to contribute their suggestions and +to spread their wisdom. Keeping discussions on public mailing lists also +allows for others to learn from this (both current and future users thanks to +the web based archives of the mailing lists), thus saving us from having to +repeat ourselves even more. Thanks for respecting this. + +If you have found or simply suspect a security problem in curl or libcurl, +submit all the details at [HackerOne](https://hackerone.com/curl). On there we +keep the issue private while we investigate, confirm it, work and validate a +fix and agree on a time schedule for publication etc. That way we produce a +fix in a timely manner before the flaw is announced to the world, reducing the +impact the problem risks having on existing users. + +Security issues can also be taking to the curl security team by emailing +security at curl.se (closed list of receivers, mails are not disclosed). + +## Where do I buy commercial support for curl? + +curl is fully open source. It means you can hire any skilled engineer to fix +your curl-related problems. + +We list [available alternatives](https://curl.se/support.html). + +## How many are using curl? + +It is impossible to tell. + +We do not know how many users that knowingly have installed and use curl. + +We do not know how many users that use curl without knowing that they are in +fact using it. + +We do not know how many users that downloaded or installed curl and then never +use it. + +In 2025, we estimate that curl runs in roughly thirty billion installations +world wide. + +## Why do you not update ca-bundle.crt + +In the curl project we have decided not to attempt to keep this file updated +(or even present) since deciding what to add to a ca cert bundle is an +undertaking we have not been ready to accept, and the one we can get from +Mozilla is perfectly fine so there is no need to duplicate that work. + +Today, with many services performed over HTTPS, every operating system should +come with a default ca cert bundle that can be deemed somewhat trustworthy and +that collection (if reasonably updated) should be deemed to be a lot better +than a private curl version. + +If you want the most recent collection of ca certs that Mozilla Firefox uses, +we recommend that using our online [CA certificate +service](https://curl.se/docs/caextract.html) setup for this purpose. + +## I have a problem who, can I chat with? + +There is a bunch of friendly people hanging out in the #curl channel on the +IRC network libera.chat. If you are polite and nice, chances are good that you +can get -- or provide -- help instantly. + +## curl's ECCN number? + +The US government restricts exports of software that contains or uses +cryptography. When doing so, the Export Control Classification Number (ECCN) +is used to identify the level of export control etc. + +Apache Software Foundation has [a good explanation of +ECCN](https://www.apache.org/dev/crypto.html). + +We believe curl's number might be ECCN 5D002, another possibility is 5D992. It +seems necessary to write them (the authority that administers ECCN numbers), +asking to confirm. + +Comprehensible explanations of the meaning of such numbers and how to obtain +them (resp.) are [here](https://www.bis.gov/licensing/classify-your-item) +and [here](https://www.bis.gov/licensing/classify-your-item/publicly-available-classification-information). + +An incomprehensible description of the two numbers above is available on +[bis.doc.gov](https://www.bis.doc.gov/index.php/documents/new-encryption/1653-ccl5-pt2-3) + +## How do I submit my patch? + +We strongly encourage you to submit changes and improvements directly as [pull +requests on GitHub](https://github.com/curl/curl/pulls). + +If you for any reason cannot or will not deal with GitHub, send your patch to +the curl-library mailing list. We are many subscribers there and there are +lots of people who can review patches, comment on them and receive them +properly. + +Lots of more details are found in the +[contribute](https://curl.se/dev/contribute.html) and +[internals](https://curl.se/dev/internals.html) +documents. + +## How do I port libcurl to my OS? + +Here's a rough step-by-step: + +1. copy a suitable lib/config-*.h file as a start to `lib/config-[youros].h` +2. edit `lib/config-[youros].h` to match your OS and setup +3. edit `lib/curl_setup.h` to include `config-[youros].h` when your OS is + detected by the preprocessor, in the style others already exist +4. compile `lib/*.c` and make them into a library + +# Install + +## configure fails when using static libraries + +You may find that configure fails to properly detect the entire dependency +chain of libraries when you provide static versions of the libraries that +configure checks for. + +The reason why static libraries is much harder to deal with is that for them +we do not get any help but the script itself must know or check what more +libraries that are needed (with shared libraries, that dependency chain is +handled automatically). This is an error-prone process and one that also tends +to vary over time depending on the release versions of the involved components +and may also differ between operating systems. + +For that reason, configure does few attempts to actually figure this out and +you are instead encouraged to set `LIBS` and `LDFLAGS` accordingly when you invoke +configure, and point out the needed libraries and set the necessary flags +yourself. + +## Does curl work with other SSL libraries? + +curl has been written to use a generic SSL function layer internally, and +that SSL functionality can then be provided by one out of many different SSL +backends. + +curl can be built to use one of the following SSL alternatives: OpenSSL, +LibreSSL, BoringSSL, AWS-LC, GnuTLS, wolfSSL, mbedTLS, Schannel (native +Windows) or Rustls. They all have their pros and cons, and we maintain [a TLS +library comparison](https://curl.se/docs/ssl-compared.html). + +## How do I upgrade curl.exe in Windows? + +The curl tool that is shipped as an integrated component of Windows 10 and +Windows 11 is managed by Microsoft. If you were to delete the file or replace +it with a newer version downloaded from [the curl +website](https://curl.se/windows), then Windows Update will cease to work on +your system. + +There is no way to independently force an upgrade of the curl.exe that is part +of Windows other than through the regular Windows update process. There is +also nothing the curl project itself can do about this, since this is managed +and controlled entirely by Microsoft as owners of the operating system. + +You can always download and install [the latest version of curl for +Windows](https://curl.se/windows) into a separate location. + +## Does curl support SOCKS (RFC 1928) ? + +Yes, SOCKS 4 and 5 are supported. + +# Usage + +## curl: (1) SSL is disabled, https: not supported + +If you get this output when trying to get anything from an HTTPS server, it +means that the instance of curl/libcurl that you are using was built without +support for this protocol. + +This could have happened if the configure script that was run at build time +could not find all libs and include files curl requires for SSL to work. If +the configure script fails to find them, curl is simply built without SSL +support. + +To get HTTPS support into a curl that was previously built but that reports +that HTTPS is not supported, you should dig through the document and logs and +check out why the configure script does not find the SSL libs and/or include +files. + +## How do I tell curl to resume a transfer? + +curl supports resumed transfers both ways on both FTP and HTTP. Try the `-C` +option. + +## Why does my posting using -F not work? + +You cannot arbitrarily use `-F` or `-d`, the choice between `-F` or `-d` +depends on the HTTP operation you need curl to do and what the web server that +will receive your post expects. + +If the form you are trying to submit uses the type 'multipart/form-data', +then and only then you must use the -F type. In all the most common cases, +you should use `-d` which then causes a posting with the type +`application/x-www-form-urlencoded`. + +This is described in some detail in the +[Manual](https://curl.se/docs/tutorial.html) and [The Art Of HTTP +Scripting](https://curl.se/docs/httpscripting.html) documents, and if you do +not understand it the first time, read it again before you post questions +about this to the mailing list. Also, try reading through the mailing list +archives for old postings and questions regarding this. + +## How do I tell curl to run custom FTP commands? + +You can tell curl to perform optional commands both before and/or after a file +transfer. Study the `-Q`/`--quote` option. + +Since curl is used for file transfers, you do not normally use curl to perform +FTP commands without transferring anything. Therefore you must always specify +a URL to transfer to/from even when doing custom FTP commands, or use `-I` +which implies the *no body*" option sent to libcurl. + +## How can I disable the Accept: header? + +You can change this and all internally generated headers by adding a +replacement with the `-H`/`--header` option. By adding a header with empty +contents you safely disable that one. Use `-H Accept:` to disable that +specific header. + +## Does curl support ASP, XML, XHTML or HTML version Y? + +To curl, all contents are alike. It does not matter how the page was +generated. It may be ASP, PHP, Perl, shell-script, SSI or plain HTML +files. There is no difference to curl and it does not even know what kind of +language that generated the page. + +See also the separate question about JavaScript. + +## Can I use curl to delete/rename a file through FTP? + +Yes. You specify custom FTP commands with `-Q`/`--quote`. + +One example would be to delete a file after you have downloaded it: + + curl -O ftp://example.com/coolfile -Q '-DELE coolfile' + +or rename a file after upload: + + curl -T infile ftp://example.com/dir/ -Q "-RNFR infile" -Q "-RNTO newname" + +## How do I tell curl to follow HTTP redirects? + +curl does not follow so-called redirects by default. The `Location:` header that +informs the client about this is only interpreted if you are using the +`-L`/`--location` option. As in: + + curl -L https://example.com + +Not all redirects are HTTP ones. See [Redirects work in browser but not with +curl](#redirects-work-in-browser-but-not-with-curl) + +## How do I use curl in my favorite programming language? + +Many programming languages have interfaces and bindings that allow you to use +curl without having to use the command line tool. If you are fluent in such a +language, you may prefer to use one of these interfaces instead. + +Find out more about which languages that support curl directly, and how to +install and use them, in the [libcurl section of the curl +website](https://curl.se/libcurl/). + +All the various bindings to libcurl are made by other projects and people, +outside of the curl project. The curl project itself only produces libcurl +with its plain C API. If you do not find anywhere else to ask you can ask +about bindings on the curl-library list too, but be prepared that people on +that list may not know anything about bindings. + +In December 2025 there were around **60** different [interfaces +available](https://curl.se/libcurl/bindings.html) for just about all the +languages you can imagine. + +## What about SOAP, WebDAV, XML-RPC or similar protocols over HTTP? + +curl adheres to the HTTP spec, which basically means you can play with *any* +protocol that is built on top of HTTP. Protocols such as SOAP, WebDAV and +XML-RPC are all such ones. You can use `-X` to set custom requests and -H to +set custom headers (or replace internally generated ones). + +Using libcurl is of course just as good and you would just use the proper +library options to do the same. + +## How do I POST with a different Content-Type? + +You can always replace the internally generated headers with `-H`/`--header`. +To make a simple HTTP POST with `text/xml` as content-type, do something like: + + curl -d "datatopost" -H "Content-Type: text/xml" [URL] + +## Why do FTP-specific features over HTTP proxy fail? + +Because when you use an HTTP proxy, the protocol spoken on the network will be +HTTP, even if you specify an FTP URL. This effectively means that you normally +cannot use FTP-specific features such as FTP upload and FTP quote etc. + +There is one exception to this rule, and that is if you can *tunnel through* +the given HTTP proxy. Proxy tunneling is enabled with a special option (`-p`) +and is generally not available as proxy admins usually disable tunneling to +ports other than 443 (which is used for HTTPS access through proxies). + +## Why do my single/double quotes fail? + +To specify a command line option that includes spaces, you might need to put +the entire option within quotes. Like in: + + curl -d " with spaces " example.com + +or perhaps + + curl -d ' with spaces ' example.com + +Exactly what kind of quotes and how to do this is entirely up to the shell or +command line interpreter that you are using. For most Unix shells, you can +more or less pick either single (`'`) or double (`"`) quotes. For Windows/DOS +command prompts you must use double (") quotes, and if the option string +contains inner double quotes you can escape them with a backslash. + +For Windows PowerShell the arguments are not always passed on as expected +because curl is not a PowerShell script. You may or may not be able to use +single quotes. To escape inner double quotes seems to require a +backslash-backtick escape sequence and the outer quotes as double quotes. + +Please study the documentation for your particular environment. Examples in +the curl docs will use a mix of both of these as shown above. You must adjust +them to work in your environment. + +Remember that curl works and runs on more operating systems than most single +individuals have ever tried. + +## Does curl support JavaScript or PAC (automated proxy config)? + +Many webpages do magic stuff using embedded JavaScript. curl and libcurl have +no built-in support for that, so it will be treated just like any other +contents. + +`.pac` files are a Netscape invention and are sometimes used by organizations +to allow them to differentiate which proxies to use. The `.pac` contents is +just a JavaScript program that gets invoked by the browser and that returns +the name of the proxy to connect to. Since curl does not support JavaScript, +it cannot support .pac proxy configuration either. + +Some workarounds usually suggested to overcome this JavaScript dependency: + +Depending on the JavaScript complexity, write up a script that translates it +to another language and execute that. + +Read the JavaScript code and rewrite the same logic in another language. + +Implement a JavaScript interpreter, people have successfully used the +Mozilla JavaScript engine in the past. + +Ask your admins to stop this, for a static proxy setup or similar. + +## Can I do recursive fetches with curl? + +No. curl itself has no code that performs recursive operations, such as those +performed by Wget and similar tools. + +There exists curl using scripts with that functionality, and you can write +programs based on libcurl to do it, but the command line tool curl itself +cannot. + +## What certificates do I need when I use SSL? + +There are three different kinds of certificates to keep track of when we talk +about using SSL-based protocols (HTTPS or FTPS) using curl or libcurl. + +### Client certificate + +The server you communicate with may require that you can provide this in +order to prove that you actually are who you claim to be. If the server +does not require this, you do not need a client certificate. + +A client certificate is always used together with a private key, and the +private key has a passphrase that protects it. + +### Server certificate + +The server you communicate with has a server certificate. You can and should +verify this certificate to make sure that you are truly talking to the real +server and not a server impersonating it. + +Servers often also provide an intermediate certificate. It acts as a bridge +between a website's SSL certificate and a Certificate Authority's (CA) root +certificate, creating a "chain of trust". + +### Certificate Authority Certificate ("CA cert") + +You often have several CA certs in a CA cert bundle that can be used to verify +a server certificate that was signed by one of the authorities in the bundle. +curl does not come with a CA cert bundle but most curl installs provide one. +You can also override the default. + +Server certificate verification is enabled by default in curl and libcurl. +Server certificates that are *self-signed* or otherwise signed by a CA that +you do not have a CA cert for, cannot be verified. If the verification during +a connect fails, you are refused access. You then might have to explicitly +disable the verification to connect to the server. + +## How do I list the root directory of an FTP server? + +There are two ways. The way defined in the RFC is to use an encoded slash in +the first path part. List the `/tmp` directory like this: + + curl ftp://ftp.example.com/%2ftmp/ + +or the not-quite-kosher-but-more-readable way, by simply starting the path +section of the URL with a slash: + + curl ftp://ftp.example.com//tmp/ + +## Can I use curl to send a POST/PUT and not wait for a response? + +No. + +You can easily write your own program using libcurl to do such stunts. + +## How do I get HTTP from a host using a specific IP address? + +For example, you may be trying out a website installation that is not yet in +the DNS. Or you have a site using multiple IP addresses for a given host +name and you want to address a specific one out of the set. + +Set a custom `Host:` header that identifies the server name you want to reach +but use the target IP address in the URL: + + curl --header "Host: www.example.com" https://somewhere.example/ + +You can also opt to add faked hostname entries to curl with the --resolve +option. That has the added benefit that things like redirects will also work +properly. The above operation would instead be done as: + + curl --resolve www.example.com:80:127.0.0.1 https://www.example.com/ + +## How to SFTP from my user's home directory? + +Contrary to how FTP works, SFTP and SCP URLs specify the exact directory to +work with. It means that if you do not specify that you want the user's home +directory, you get the actual root directory. + +To specify a file in your user's home directory, you need to use the correct +URL syntax which for SFTP might look similar to: + + curl -O -u user:password sftp://example.com/~/file.txt + +and for SCP it is just a different protocol prefix: + + curl -O -u user:password scp://example.com/~/file.txt + +## Protocol xxx not supported or disabled in libcurl + +When passing on a URL to curl to use, it may respond that the particular +protocol is not supported or disabled. The particular way this error message +is phrased is because curl does not make a distinction internally of whether a +particular protocol is not supported (i.e. never got any code added that knows +how to speak that protocol) or if it was explicitly disabled. curl can be +built to only support a given set of protocols, and the rest would then be +disabled or not supported. + +Note that this error will also occur if you pass a wrongly spelled protocol +part as in `htpts://example.com` or as in the less evident case if you prefix +the protocol part with a space as in `" https://example.com/"`. + +## curl `-X` gives me HTTP problems + +In normal circumstances, `-X` should hardly ever be used. + +By default you use curl without explicitly saying which request method to use +when the URL identifies an HTTP transfer. If you just pass in a URL like `curl +https://example.com` it will use GET. If you use `-d` or `-F`, curl will use +POST, `-I` will cause a HEAD and `-T` will make it a PUT. + +If for whatever reason you are not happy with these default choices that curl +does for you, you can override those request methods by specifying `-X +[WHATEVER]`. This way you can for example send a DELETE by doing +`curl -X DELETE [URL]`. + +It is thus pointless to do `curl -XGET [URL]` as GET would be used anyway. In +the same vein it is pointless to do `curl -X POST -d data [URL`. You can make +a fun and somewhat rare request that sends a request-body in a GET request +with something like `curl -X GET -d data [URL]`. + +Note that `-X` does not actually change curl's behavior as it only modifies +the actual string sent in the request, but that may of course trigger a +different set of events. + +Accordingly, by using `-XPOST` on a command line that for example would follow +a 303 redirect, you will effectively prevent curl from behaving correctly. Be +aware. + +# Running + +## Why do I get problems when I use & or % in the URL? + +In general Unix shells, the & symbol is treated specially and when used, it +runs the specified command in the background. To safely send the & as a part +of a URL, you should quote the entire URL by using single (`'`) or double +(`"`) quotes around it. Similar problems can also occur on some shells with +other characters, including ?*!$~(){}<>\|;`. When in doubt, quote the URL. + +An example that would invoke a remote CGI that uses &-symbols could be: + + curl 'https://www.example.com/cgi-bin/query?text=yes&q=curl' + +In Windows, the standard DOS shell treats the percent sign specially and you +need to use TWO percent signs for each single one you want to use in the URL. + +If you want a literal percent sign to be part of the data you pass in a POST +using `-d`/`--data` you must encode it as `%25` (which then also needs the +percent sign doubled on Windows machines). + +## How can I use {, }, [ or ] to specify multiple URLs? + +Because those letters have a special meaning to the shell, to be used in a URL +specified to curl you must quote them. + +An example that downloads two URLs (sequentially) would be: + + curl '{curl,www}.haxx.se' + +To be able to use those characters as actual parts of the URL (without using +them for the curl URL *globbing* system), use the `-g`/`--globoff` option: + + curl -g 'www.example.com/weirdname[].html' + +## Why do I get downloaded data even though the webpage does not exist? + +curl asks remote servers for the page you specify. If the page does not exist +at the server, the HTTP protocol defines how the server should respond and +that means that headers and a page will be returned. That is simply how HTTP +works. + +By using the `--fail` option you can tell curl explicitly to not get any data +if the HTTP return code does not say success. + +## Why do I get return code XXX from an HTTP server? + +RFC 2616 clearly explains the return codes. This is a short transcript. Go +read the RFC for exact details: + +### 400 Bad Request + +The request could not be understood by the server due to malformed +syntax. The client SHOULD NOT repeat the request without modifications. + +### 401 Unauthorized + +The request requires user authentication. + +### 403 Forbidden + +The server understood the request, but is refusing to fulfill it. +Authorization will not help and the request SHOULD NOT be repeated. + +### 404 Not Found + +The server has not found anything matching the Request-URI. No indication is +given as to whether the condition is temporary or permanent. + +### 405 Method Not Allowed + +The method specified in the Request-Line is not allowed for the resource +identified by the Request-URI. The response MUST include an `Allow:` header +containing a list of valid methods for the requested resource. + +### 301 Moved Permanently + +If you get this return code and an HTML output similar to this: + +

Moved Permanently

The document has moved here. + +it might be because you requested a directory URL but without the trailing +slash. Try the same operation again _with_ the trailing URL, or use the +`-L`/`--location` option to follow the redirection. + +## Can you tell me what error code 142 means? + +All curl error codes are described at the end of the man page, in the section +called **EXIT CODES**. + +Error codes that are larger than the highest documented error code means that +curl has exited due to a crash. This is a serious error, and we appreciate a +detailed bug report from you that describes how we could go ahead and repeat +this. + +## How do I keep usernames and passwords secret in curl command lines? + +This problem has two sides: + +The first part is to avoid having clear-text passwords in the command line so +that they do not appear in *ps* outputs and similar. That is easily avoided by +using the `-K` option to tell curl to read parameters from a file or stdin to +which you can pass the secret info. curl itself will also attempt to hide the +given password by blanking out the option - this does not work on all +platforms. + +To keep the passwords in your account secret from the rest of the world is +not a task that curl addresses. You could of course encrypt them somehow to +at least hide them from being read by human eyes, but that is not what +anyone would call security. + +Also note that regular HTTP (using Basic authentication) and FTP passwords are +sent as cleartext across the network. All it takes for anyone to fetch them is +to listen on the network. Eavesdropping is easy. Use more secure +authentication methods (like Digest, Negotiate or even NTLM) or consider the +SSL-based alternatives HTTPS and FTPS. + +## I found a bug + +It is not a bug if the behavior is documented. Read the docs first. Especially +check out the KNOWN_BUGS file, it may be a documented bug. + +If it is a problem with a binary you have downloaded or a package for your +particular platform, try contacting the person who built the package/archive +you have. + +If there is a bug, read the BUGS document first. Then report it as described +in there. + +## curl cannot authenticate to a server that requires NTLM? + +NTLM support requires OpenSSL, GnuTLS, mbedTLS or Microsoft Windows libraries +at build-time to provide this functionality. + +## My HTTP request using HEAD, PUT or DELETE does not work + +Many web servers allow or demand that the administrator configures the server +properly for these requests to work on the web server. + +Some servers seem to support HEAD only on certain kinds of URLs. + +To fully grasp this, try the documentation for the particular server software +you are trying to interact with. This is not anything curl can do anything +about. + +## Why do my HTTP range requests return the full document? + +Because the range may not be supported by the server, or the server may choose +to ignore it and return the full document anyway. + +## Why do I get "certificate verify failed" ? + +When you invoke curl and get an error 60 error back it means that curl could +not verify that the server's certificate was good. curl verifies the +certificate using the CA cert bundle and verifying for which names the +certificate has been granted. + +To completely disable the certificate verification, use `-k`. This does +however enable man-in-the-middle attacks and makes the transfer **insecure**. +We strongly advise against doing this for more than experiments. + +If you get this failure with a CA cert bundle installed and used, the server's +certificate might not be signed by one of the certificate authorities in your +CA store. It might for example be self-signed. You then correct this problem +by obtaining a valid CA cert for the server. Or again, decrease the security +by disabling this check. + +At times, you find that the verification works in your favorite browser but +fails in curl. When this happens, the reason is usually that the server sends +an incomplete cert chain. The server is mandated to send all *intermediate +certificates* but does not. This typically works with browsers anyway since +they A) cache such certs and B) supports AIA which downloads such missing +certificates on demand. This is a bad server configuration. A good way to +figure out if this is the case it to use [the SSL Labs +server](https://www.ssllabs.com/ssltest/) test and check the certificate +chain. + +Details are also in [the SSL certificates +document](https://curl.se/docs/sslcerts.html). + + +## Why is curl -R on Windows one hour off? + +Since curl 7.53.0 this issue should be fixed as long as curl was built with +any modern compiler that allows for a 64-bit curl_off_t type. For older +compilers or prior curl versions it may set a time that appears one hour off. +This happens due to a flaw in how Windows stores and uses file modification +times and it is not easily worked around. For more details [read +this](https://www.codeproject.com/articles/Beating-the-Daylight-Savings-Time-Bug-and-Getting#comments-section). + +## Redirects work in browser but not with curl + +curl supports HTTP redirects well (see a previous question above). Browsers +generally support at least two other ways to perform redirects that curl does +not: + +Meta tags. You can write an HTML tag that will cause the browser to redirect +to another given URL after a certain time. + +JavaScript. You can write a JavaScript program embedded in an HTML page that +redirects the browser to another given URL. + +There is no way to make curl follow these redirects. You must either manually +figure out what the page is set to do, or write a script that parses the +results and fetches the new URL. + +## FTPS does not work + +curl supports FTPS (sometimes known as FTP-SSL) both implicit and explicit +mode. + +When a URL is used that starts with `FTPS://`, curl assumes implicit SSL on +the control connection and will therefore immediately connect and try to speak +SSL. `FTPS://` connections default to port 990. + +To use explicit FTPS, you use an `FTP://` URL and the `--ssl-reqd` option (or +one of its related flavors). This is the most common method, and the one +mandated by RFC 4217. This kind of connection will then of course use the +standard FTP port 21 by default. + +## My HTTP POST or PUT requests are slow + +libcurl makes all POST and PUT requests (except for requests with a small +request body) use the `Expect: 100-continue` header. This header allows the +server to deny the operation early so that libcurl can bail out before having +to send any data. This is useful in authentication cases and others. + +However, many servers do not implement the `Expect:` stuff properly and if the +server does not respond (positively) within 1 second libcurl will continue and +send off the data anyway. + +You can disable libcurl's use of the `Expect:` header the same way you disable +any header, using `-H` / `CURLOPT_HTTPHEADER`, or by forcing it to use HTTP +1.0. + +## Non-functional connect timeouts + +In most Windows setups having a timeout longer than 21 seconds make no +difference, as it will only send 3 TCP SYN packets and no more. The second +packet sent three seconds after the first and the third six seconds after +the second. No more than three packets are sent, no matter how long the +timeout is set. + +See option `TcpMaxConnectRetransmissions` on [this +page](https://support.microsoft.com/bg-bg/topic/hotfix-enables-the-configuration-of-the-tcp-maximum-syn-retransmission-amount-in-windows-7-or-windows-server-2008-r2-1b6f8352-2c5f-58bb-ead7-2cf021407c8e). + +Also, even on non-Windows systems there may run a firewall or anti-virus +software or similar that accepts the connection but does not actually do +anything else. This will make (lib)curl to consider the connection connected +and thus the connect timeout will not trigger. + +## file:// URLs containing drive letters (Windows, NetWare) + +When using curl to try to download a local file, one might use a URL in this +format: + + file://D:/blah.txt + +you will find that even if `D:\blah.txt` does exist, curl returns a 'file not +found' error. + +According to [RFC 1738](https://www.ietf.org/rfc/rfc1738.txt), `file://` URLs +must contain a host component, but it is ignored by most implementations. In +the above example, `D:` is treated as the host component, and is taken away. +Thus, curl tries to open `/blah.txt`. If your system is installed to drive C:, +that will resolve to `C:\blah.txt`, and if that does not exist you will get +the not found error. + +To fix this problem, use `file://` URLs with *three* leading slashes: + + file:///D:/blah.txt + +Alternatively, if it makes more sense, specify `localhost` as the host +component: + + file://localhost/D:/blah.txt + +In either case, curl should now be looking for the correct file. + +## Why does not curl return an error when the network cable is unplugged? + +Unplugging a cable is not an error situation. The TCP/IP protocol stack was +designed to be fault tolerant, so even though there may be a physical break +somewhere the connection should not be affected, just possibly delayed. +Eventually, the physical break will be fixed or the data will be re-routed +around the physical problem through another path. + +In such cases, the TCP/IP stack is responsible for detecting when the network +connection is irrevocably lost. Since with some protocols it is perfectly +legal for the client to wait indefinitely for data, the stack may never report +a problem, and even when it does, it can take up to 20 minutes for it to +detect an issue. The curl option `--keepalive-time` enables keep-alive support +in the TCP/IP stack which makes it periodically probe the connection to make +sure it is still available to send data. That should reliably detect any +TCP/IP network failure. + +TCP keep alive will not detect the network going down before the TCP/IP +connection is established (e.g. during a DNS lookup) or using protocols that +do not use TCP. To handle those situations, curl offers a number of timeouts +on its own. `--speed-limit`/`--speed-time` will abort if the data transfer +rate falls too low, and `--connect-timeout` and `--max-time` can be used to +put an overall timeout on the connection phase or the entire transfer. + +A libcurl-using application running in a known physical environment (e.g. an +embedded device with only a single network connection) may want to act +immediately if its lone network connection goes down. That can be achieved by +having the application monitor the network connection on its own using an +OS-specific mechanism, then signaling libcurl to abort. + +## curl does not return error for HTTP non-200 responses + +Correct. Unless you use `-f` (`--fail`) or `--fail-with-body`. + +When doing HTTP transfers, curl will perform exactly what you are asking it to +do and if successful it will not return an error. You can use curl to test +your web server's "file not found" page (that gets 404 back), you can use it +to check your authentication protected webpages (that gets a 401 back) and so +on. + +The specific HTTP response code does not constitute a problem or error for +curl. It simply sends and delivers HTTP as you asked and if that worked, +everything is fine and dandy. The response code is generally providing more +higher level error information that curl does not care about. The error was +not in the HTTP transfer. + +If you want your command line to treat error codes in the 400 and up range as +errors and thus return a non-zero value and possibly show an error message, +curl has a dedicated option for that: `-f` (`CURLOPT_FAILONERROR` in libcurl +speak). + +You can also use the `-w` option and the variable `%{response_code}` to +extract the exact response code that was returned in the response. + +# libcurl + +## Is libcurl thread-safe? + +Yes. + +We have written the libcurl code specifically adjusted for multi-threaded +programs. libcurl will use thread-safe functions instead of non-safe ones if +your system has such. Note that you must never share the same handle in +multiple threads. + +There may be some exceptions to thread safety depending on how libcurl was +built. Please review [the guidelines for thread +safety](https://curl.se/libcurl/c/threadsafe.html) to learn more. + +## How can I receive all data into a large memory chunk? + +(See the [get in memory](https://curl.se/libcurl/c/getinmemory.html) example.) + +You are in full control of the callback function that gets called every time +there is data received from the remote server. You can make that callback do +whatever you want. You do not have to write the received data to a file. + +One solution to this problem could be to have a pointer to a struct that you +pass to the callback function. You set the pointer using the CURLOPT_WRITEDATA +option. Then that pointer will be passed to the callback instead of a FILE * +to a file: + +~~~c +/* store data this struct */ +struct MemoryStruct { + char *memory; + size_t size; +}; + +/* imaginary callback function */ +size_t +WriteMemoryCallback(void *ptr, size_t size, size_t nmemb, void *data) +{ + size_t realsize = size * nmemb; + struct MemoryStruct *mem = (struct MemoryStruct *)data; + + mem->memory = (char *)realloc(mem->memory, mem->size + realsize + 1); + if(mem->memory) { + memcpy(&(mem->memory[mem->size]), ptr, realsize); + mem->size += realsize; + mem->memory[mem->size] = 0; + } + return realsize; +} +~~~ + +## How do I fetch multiple files with libcurl? + +libcurl has excellent support for transferring multiple files. You should just +repeatedly set new URLs with `curl_easy_setopt()` and then transfer it with +`curl_easy_perform()`. The handle you get from curl_easy_init() is not only +reusable, but you are even encouraged to reuse it if you can, as that will +enable libcurl to use persistent connections. + +## Does libcurl do Winsock initialization on Win32 systems? + +Yes, if told to in the `curl_global_init()` call. + +## Does CURLOPT_WRITEDATA and CURLOPT_READDATA work on Win32 ? + +Yes, but you cannot open a FILE * and pass the pointer to a DLL and have that +DLL use the FILE * (as the DLL and the client application cannot access each +others' variable memory areas). If you set `CURLOPT_WRITEDATA` you must also use +`CURLOPT_WRITEFUNCTION` as well to set a function that writes the file, even if +that simply writes the data to the specified FILE *. Similarly, if you use +`CURLOPT_READDATA` you must also specify `CURLOPT_READFUNCTION`. + +## What about Keep-Alive or persistent connections? + +curl and libcurl have excellent support for persistent connections when +transferring several files from the same server. curl will attempt to reuse +connections for all URLs specified on the same command line/config file, and +libcurl will reuse connections for all transfers that are made using the same +libcurl handle. + +When you use the easy interface the connection cache is kept within the easy +handle. If you instead use the multi interface, the connection cache will be +kept within the multi handle and will be shared among all the easy handles +that are used within the same multi handle. + +## Link errors when building libcurl on Windows + +You need to make sure that your project, and all the libraries (both static +and dynamic) that it links against, are compiled/linked against the same run +time library. + +This is determined by the `/MD`, `/ML`, `/MT` (and their corresponding `/M?d`) +options to the command line compiler. `/MD` (linking against `MSVCRT.dll`) +seems to be the most commonly used option. + +When building an application that uses the static libcurl library, you must +add `-DCURL_STATICLIB` to your `CFLAGS`. Otherwise the linker will look for +dynamic import symbols. If you are using Visual Studio, you need to instead +add `CURL_STATICLIB` in the "Preprocessor Definitions" section. + +If you get a linker error like `unknown symbol __imp__curl_easy_init ...` you +have linked against the wrong (static) library. If you want to use the +libcurl.dll and import lib, you do not need any extra `CFLAGS`, but use one of +the import libraries below. These are the libraries produced by the various +lib/Makefile.* files: + +| Target | static lib | import lib for DLL | +|----------------|----------------|--------------------| +| MinGW | `libcurl.a` | `libcurldll.a` | +| MSVC (release) | `libcurl.lib` | `libcurl_imp.lib` | +| MSVC (debug) | `libcurld.lib` | `libcurld_imp.lib` | + +## libcurl.so.X: open failed: No such file or directory + +This is an error message you might get when you try to run a program linked +with a shared version of libcurl and your runtime linker (`ld.so`) could not +find the shared library named `libcurl.so.X`. (Where X is the number of the +current libcurl ABI, typically 3 or 4). + +You need to make sure that `ld.so` finds `libcurl.so.X`. You can do that +multiple ways, and it differs somewhat between different operating systems. +They are usually: + +* Add an option to the linker command line that specify the hard-coded path + the runtime linker should check for the lib (usually `-R`) +* Set an environment variable (`LD_LIBRARY_PATH` for example) where `ld.so` + should check for libs +* Adjust the system's config to check for libs in the directory where you have + put the library (like Linux's `/etc/ld.so.conf`) + +`man ld.so` and`'man ld` will tell you more details + +## How does libcurl resolve hostnames? + +libcurl supports a large number of name resolve functions. One of them is +picked at build-time and will be used unconditionally. Thus, if you want to +change name resolver function you must rebuild libcurl and tell it to use a +different function. + +### The non-IPv6 resolver + +The non-IPv6 resolver that can use one of four different hostname resolve +calls depending on what your system supports: + +1. gethostbyname() +2. gethostbyname_r() with 3 arguments +3. gethostbyname_r() with 5 arguments +4. gethostbyname_r() with 6 arguments + +### The IPv6 resolver + +Uses getaddrinfo() + +### The cares resolver + +The c-ares based name resolver that uses the c-ares library for resolves. +Using this offers asynchronous name resolves. + +## The threaded resolver + +It uses the IPv6 or the non-IPv6 resolver solution in a temporary thread. + +## How do I prevent libcurl from writing the response to stdout? + +libcurl provides a default built-in write function that writes received data +to stdout. Set the `CURLOPT_WRITEFUNCTION` to receive the data, or possibly +set `CURLOPT_WRITEDATA` to a different FILE * handle. + +## How do I make libcurl not receive the whole HTTP response? + +You make the write callback (or progress callback) return an error and libcurl +will then abort the transfer. + +## Can I make libcurl fake or hide my real IP address? + +No. libcurl operates on a higher level. Besides, faking IP address would +imply sending IP packets with a made-up source address, and then you normally +get a problem with receiving the packet sent back as they would then not be +routed to you. + +If you use a proxy to access remote sites, the sites will not see your local +IP address but instead the address of the proxy. + +Also note that on many networks NATs or other IP-munging techniques are used +that makes you see and use a different IP address locally than what the remote +server will see you coming from. You may also consider using +[Tor]()https://www.torproject.org/). + +## How do I stop an ongoing transfer? + +With the easy interface you make sure to return the correct error code from +one of the callbacks, but none of them are instant. There is no function you +can call from another thread or similar that will stop it immediately. +Instead, you need to make sure that one of the callbacks you use returns an +appropriate value that will stop the transfer. Suitable callbacks that you can +do this with include the progress callback, the read callback and the write +callback. + +If you are using the multi interface, you can also stop a transfer by removing +the particular easy handle from the multi stack at any moment you think the +transfer is done or when you wish to abort the transfer. + +## Using C++ non-static functions for callbacks? + +libcurl is a C library, it does not know anything about C++ member functions. + +You can overcome this limitation with relative ease using a static member +function that is passed a pointer to the class: + +~~~c++ +// f is the pointer to your object. +static size_t YourClass::func(void *buffer, size_t sz, size_t n, void *f) +{ + // Call non-static member function. + static_cast(f)->nonStaticFunction(); +} + +// This is how you pass pointer to the static function: +curl_easy_setopt(hcurl, CURLOPT_WRITEFUNCTION, YourClass::func); +curl_easy_setopt(hcurl, CURLOPT_WRITEDATA, this); +~~~ + +## How do I get an FTP directory listing? + +If you end the FTP URL you request with a slash, libcurl will provide you with +a directory listing of that given directory. You can also set +`CURLOPT_CUSTOMREQUEST` to alter what exact listing command libcurl would use +to list the files. + +The follow-up question tends to be how is a program supposed to parse the +directory listing. How does it know what's a file and what's a directory and +what's a symlink etc. If the FTP server supports the `MLSD` command then it +will return data in a machine-readable format that can be parsed for type. The +types are specified by RFC 3659 section 7.5.1. If `MLSD` is not supported then +you have to work with what you are given. The `LIST` output format is entirely +at the server's own liking and the `NLST` output does not reveal any types and +in many cases does not even include all the directory entries. Also, both +`LIST` and `NLST` tend to hide Unix-style hidden files (those that start with +a dot) by default so you need to do `LIST -a` or similar to see them. + +Example - List only directories. `ftp.funet.fi` supports `MLSD` and +`ftp.kernel.org` does not: + + curl -s ftp.funet.fi/pub/ -X MLSD | \ + perl -lne 'print if s/(?:^|;)type=dir;[^ ]+ (.+)$/$1/' + + curl -s ftp.kernel.org/pub/linux/kernel/ | \ + perl -lne 'print if s/^d[-rwx]{9}(?: +[^ ]+){7} (.+)$/$1/' + +If you need to parse LIST output, libcurl provides the ability to specify a +wildcard to download multiple files from an FTP directory. + +## I want a different time-out + +Sometimes users realize that `CURLOPT_TIMEOUT` and `CURLOPT_CONNECTIMEOUT` are +not sufficiently advanced or flexible to cover all the various use cases and +scenarios applications end up with. + +libcurl offers many more ways to time-out operations. A common alternative is +to use the `CURLOPT_LOW_SPEED_LIMIT` and `CURLOPT_LOW_SPEED_TIME` options to +specify the lowest possible speed to accept before to consider the transfer +timed out. + +The most flexible way is by writing your own time-out logic and using +`CURLOPT_XFERINFOFUNCTION` (perhaps in combination with other callbacks) and +use that to figure out exactly when the right condition is met when the +transfer should get stopped. + +## Can I write a server with libcurl? + +No. libcurl offers no functions or building blocks to build any kind of +Internet protocol server. libcurl is only a client-side library. For server +libraries, you need to continue your search elsewhere but there exist many +good open source ones out there for most protocols you could want a server +for. There are also really good stand-alone servers that have been tested and +proven for many years. There is no need for you to reinvent them. + +## Does libcurl use threads? + +Put simply: no, libcurl will execute in the same thread you call it in. All +callbacks will be called in the same thread as the one you call libcurl in. + +If you want to avoid your thread to be blocked by the libcurl call, you make +sure you use the non-blocking multi API which will do transfers +asynchronously - still in the same single thread. + +libcurl will potentially internally use threads for name resolving, if it was +built to work like that, but in those cases it will create the child threads +by itself and they will only be used and then killed internally by libcurl and +never exposed to the outside. + +# License + +curl and libcurl are released under an MIT/X derivative license. The license +is liberal and should not impose a problem for your project. This section is +just a brief summary for the cases we get the most questions. + +We are not lawyers and this is not legal advice. You should probably consult +one if you want true and accurate legal insights without our prejudice. Note +especially that this section concerns the libcurl license only; compiling in +features of libcurl that depend on other libraries (e.g. OpenSSL) may affect +the licensing obligations of your application. + +## I have a GPL program, can I use the libcurl library? + +Yes + +Since libcurl may be distributed under the MIT/X derivative license, it can be +used together with GPL in any software. + +## I have a closed-source program, can I use the libcurl library? + +Yes + +libcurl does not put any restrictions on the program that uses the library. + +## I have a BSD licensed program, can I use the libcurl library? + +Yes + +libcurl does not put any restrictions on the program that uses the library. + +## I have a program that uses LGPL libraries, can I use libcurl? + +Yes + +The LGPL license does not clash with other licenses. + +## Can I modify curl/libcurl for my program and keep the changes secret? + +Yes + +The MIT/X derivative license practically allows you to do almost anything with +the sources, on the condition that the copyright texts in the sources are left +intact. + +## Can you please change the curl/libcurl license? + +No. + +We have carefully picked this license after years of development and +discussions and a large amount of people have contributed with source code +knowing that this is the license we use. This license puts the restrictions we +want on curl/libcurl and it does not spread to other programs or libraries +that use it. It should be possible for everyone to use libcurl or curl in +their projects, no matter what license they already have in use. + +## What are my obligations when using libcurl in my commercial apps? + +Next to none. All you need to adhere to is the MIT-style license (stated in +the COPYING file) which basically says you have to include the copyright +notice in *all copies* and that you may not use the copyright holder's name +when promoting your software. + +You do not have to release any of your source code. + +You do not have to reveal or make public any changes to the libcurl source +code. + +You do not have to broadcast to the world that you are using libcurl within +your app. + +All we ask is that you disclose *the copyright notice and this permission +notice* somewhere. Most probably like in the documentation or in the section +where other third party dependencies already are mentioned and acknowledged. + +As can be seen [here](https://curl.se/docs/companies.html) and elsewhere, more +and more companies are discovering the power of libcurl and take advantage of +it even in commercial environments. + +## What license does curl use exactly? + +curl is released under an [MIT derivative +license](https://curl.se/docs/copyright.html). It is similar but not identical +to the MIT license. + +The difference is considered big enough to make SPDX list it under its own +identifier: [curl](https://spdx.org/licenses/curl.html). + +The changes done to the license that make it uniquely curl were tiny and +well-intended, but the reasons for them have been forgotten and we strongly +discourage others from doing the same thing. + +# PHP/CURL + +## What is PHP/CURL? + +The module for PHP that makes it possible for PHP programs to access curl +functions from within PHP. + +In the curl project we call this module PHP/CURL to differentiate it from curl +the command line tool and libcurl the library. The PHP team however does not +refer to it like this (for unknown reasons). They call it plain CURL (often +using all caps) or sometimes ext/curl, but both cause much confusion to users +which in turn gives us a higher question load. + +## Who wrote PHP/CURL? + +PHP/CURL was initially written by Sterling Hughes. + +## Can I perform multiple requests using the same handle? + +Yes. + +After a transfer, you just set new options in the handle and make another +transfer. This will make libcurl reuse the same connection if it can. + +## Does PHP/CURL have dependencies? + +PHP/CURL is a module that comes with the regular PHP package. It depends on +and uses libcurl, so you need to have libcurl installed properly before +PHP/CURL can be used. + +# Development + +## Why does curl use C89? + +As with everything in curl, there is a history and we keep using what we have +used before until someone brings up the subject and argues for and works on +changing it. + +We started out using C89 in the 1990s because that was the only way to write a +truly portable C program and have it run as widely as possible. C89 was for a +long time even necessary to make things work on otherwise considered modern +platforms such as Windows. Today, we do not really know how many users that +still require the use of a C89 compiler. + +We will continue to use C89 for as long as nobody brings up a strong enough +reason for us to change our minds. The core developers of the project do not +feel restricted by this and we are not convinced that going C99 will offer us +enough of a benefit to warrant the risk of cutting off a share of users. + +## Will curl be rewritten? + +In one go: no. Little by little over time? Sure. + +Over the years, new languages and clever operating environments come and go. +Every now and then the urge apparently arises to request that we rewrite curl +in another language. + +Some the most important properties in curl are maintaining the API and ABI for +libcurl and keeping the behavior for the command line tool. As long as we can +do that, everything else is up for discussion. To maintain the ABI, we +probably have to maintain a certain amount of code in C, and to remain rock +stable, we will never risk anything by rewriting a lot of things in one go. +That said, we can certainly offer more and more optional backends written in +other languages, as long as those backends can be plugged in at build-time. +Backends can be written in any language, but should probably provide APIs +usable from C to ease integration and transition. diff --git a/docs/KNOWN_BUGS b/docs/KNOWN_BUGS deleted file mode 100644 index f65e9f1ae264..000000000000 --- a/docs/KNOWN_BUGS +++ /dev/null @@ -1,663 +0,0 @@ - _ _ ____ _ - ___| | | | _ \| | - / __| | | | |_) | | - | (__| |_| | _ <| |___ - \___|\___/|_| \_\_____| - - Known Bugs - -These are problems and bugs known to exist at the time of this release. Feel -free to join in and help us correct one or more of these. Also be sure to -check the changelog of the current development status, as one or more of these -problems may have been fixed or changed somewhat since this was written. - - 1. HTTP - - 2. TLS - 2.1 IMAPS connection fails with Rustls error - 2.2 Access violation sending client cert with Schannel - 2.5 Client cert handling with Issuer DN differs between backends - 2.7 Client cert (MTLS) issues with Schannel - 2.11 Schannel TLS 1.2 handshake bug in old Windows versions - 2.13 CURLOPT_CERTINFO results in CURLE_OUT_OF_MEMORY with Schannel - 2.14 mbedTLS and CURLE_AGAIN handling - - 3. Email protocols - 3.1 IMAP SEARCH ALL truncated response - 3.2 No disconnect command - 3.4 AUTH PLAIN for SMTP is not working on all servers - 3.5 APOP authentication fails on POP3 - 3.6 POP3 issue when reading small chunks - - 4. Command line - 4.1 -T /dev/stdin may upload with an incorrect content length - 4.2 -T - always uploads chunked - - 5. Build and portability issues - 5.1 OS400 port requires deprecated IBM library - 5.2 curl-config --libs contains private details - 5.3 LDFLAGS passed too late making libs linked incorrectly - 5.6 Cygwin: make install installs curl-config.1 twice - 5.12 flaky CI builds - 5.13 long paths are not fully supported on Windows - 5.15 Unicode on Windows - - 6. Authentication - 6.1 Digest auth-int for PUT/POST - 6.2 MIT Kerberos for Windows build - 6.3 NTLM in system context uses wrong name - 6.5 NTLM does not support password with Unicode 'SECTION SIGN' character - 6.6 libcurl can fail to try alternatives with --proxy-any - 6.7 Do not clear digest for single realm - 6.9 SHA-256 digest not supported in Windows SSPI builds - 6.10 curl never completes Negotiate over HTTP - 6.11 Negotiate on Windows fails - 6.13 Negotiate against Hadoop HDFS - - 7. FTP - 7.4 FTP with ACCT - 7.12 FTPS directory listing hangs on Windows with Schannel - - 9. SFTP and SCP - 9.1 SFTP does not do CURLOPT_POSTQUOTE correct - 9.3 Remote recursive folder creation with SFTP - 9.4 libssh blocking and infinite loop problem - 9.5 Cygwin: "WARNING: UNPROTECTED PRIVATE KEY FILE!" - - 10. Connection - 10.1 --interface with link-scoped IPv6 address - 10.2 Does not acknowledge getaddrinfo sorting policy - 10.3 SOCKS-SSPI discards the security context - - 11. Internals - 11.1 gssapi library name + version is missing in curl_version_info() - 11.2 error buffer not set if connection to multiple addresses fails - 11.4 HTTP test server 'connection-monitor' problems - 11.5 Connection information when using TCP Fast Open - 11.6 test cases sometimes timeout - 11.7 CURLOPT_CONNECT_TO does not work for HTTPS proxy - 11.8 WinIDN test failures - 11.9 setting a disabled option should return CURLE_NOT_BUILT_IN - - 12. LDAP - 12.1 OpenLDAP hangs after returning results - 12.2 LDAP on Windows does authentication wrong? - 12.3 LDAP on Windows does not work - 12.4 LDAPS requests to ActiveDirectory server hang - - 13. TCP/IP - 13.1 telnet code does not handle partial writes properly - 13.2 Trying local ports fails on Windows - - 15. CMake - 15.1 cmake outputs: no version information available - 15.6 uses -lpthread instead of Threads::Threads - 15.7 generated .pc file contains strange entries - 15.13 CMake build with MIT Kerberos does not work - - 16. aws-sigv4 - 16.2 aws-sigv4 does not handle multipart/form-data correctly - - 17. HTTP/2 - 17.1 HTTP/2 prior knowledge over proxy - 17.2 HTTP/2 frames while in the connection pool kill reuse - 17.3 ENHANCE_YOUR_CALM causes infinite retries - 17.4 HTTP/2 + TLS spends a lot of time in recv - - 18. HTTP/3 - 18.1 connection migration does not work - 18.2 quiche: QUIC connection is draining - 18.3 OpenSSL-QUIC problems on google.com - - 19. RTSP - 19.1 Some methods do not support response bodies - -============================================================================== - -1. HTTP - -2. TLS - -2.1 IMAPS connection fails with Rustls error - - https://github.com/curl/curl/issues/10457 - -2.2 Access violation sending client cert with Schannel - - When using Schannel to do client certs, curl sets PKCS12_NO_PERSIST_KEY to - avoid leaking the private key into the filesystem. Unfortunately that flag - instead seems to trigger a crash. - - See https://github.com/curl/curl/issues/17626 - -2.5 Client cert handling with Issuer DN differs between backends - - When the specified client certificate does not match any of the - server-specified DNs, the OpenSSL and GnuTLS backends behave differently. - The github discussion may contain a solution. - - See https://github.com/curl/curl/issues/1411 - -2.7 Client cert (MTLS) issues with Schannel - - See https://github.com/curl/curl/issues/3145 - -2.11 Schannel TLS 1.2 handshake bug in old Windows versions - - In old versions of Windows such as 7 and 8.1 the Schannel TLS 1.2 handshake - implementation likely has a bug that can rarely cause the key exchange to - fail, resulting in error SEC_E_BUFFER_TOO_SMALL or SEC_E_MESSAGE_ALTERED. - - https://github.com/curl/curl/issues/5488 - -2.13 CURLOPT_CERTINFO results in CURLE_OUT_OF_MEMORY with Schannel - - https://github.com/curl/curl/issues/8741 - -2.14 mbedTLS and CURLE_AGAIN handling - - https://github.com/curl/curl/issues/15801 - -3. Email protocols - -3.1 IMAP SEARCH ALL truncated response - - IMAP "SEARCH ALL" truncates output on large boxes. "A quick search of the - code reveals that pingpong.c contains some truncation code, at line 408, when - it deems the server response to be too large truncating it to 40 characters" - https://curl.se/bug/view.cgi?id=1366 - -3.2 No disconnect command - - The disconnect commands (LOGOUT and QUIT) may not be sent by IMAP, POP3 and - SMTP if a failure occurs during the authentication phase of a connection. - -3.4 AUTH PLAIN for SMTP is not working on all servers - - Specifying "--login-options AUTH=PLAIN" on the command line does not seem to - work correctly. - - See https://github.com/curl/curl/issues/4080 - -3.5 APOP authentication fails on POP3 - - See https://github.com/curl/curl/issues/10073 - -3.6 POP3 issue when reading small chunks - - CURL_DBG_SOCK_RMAX=4 ./runtests.pl -v 982 - - See https://github.com/curl/curl/issues/12063 - -4. Command line - -4.1 -T /dev/stdin may upload with an incorrect content length - - -T stats the path to figure out its size in bytes to use it as Content-Length - if it is a regular file. - - The problem with that is that, on BSDs and some other UNIXes (not Linux), - open(path) may not give you a file descriptor with a 0 offset from the start - of the file. - - See https://github.com/curl/curl/issues/12177 - -4.2 -T - always uploads chunked - - When the `<` shell operator is used. curl should realise that stdin is a - regular file in this case, and that it can do a non-chunked upload, like it - would do if you used -T file. - - See https://github.com/curl/curl/issues/12171 - -5. Build and portability issues - -5.1 OS400 port requires deprecated IBM library - - curl for OS400 requires QADRT to build, which provides ASCII wrappers for - libc/POSIX functions in the ILE, but IBM no longer supports or even offers - this library to download. - - See https://github.com/curl/curl/issues/5176 - -5.2 curl-config --libs contains private details - - "curl-config --libs" include details set in LDFLAGS when configure is run - that might be needed only for building libcurl. Further, curl-config --cflags - suffers from the same effects with CFLAGS/CPPFLAGS. - -5.3 LDFLAGS passed too late making libs linked incorrectly - - Compiling latest curl on HP-UX and linking against a custom OpenSSL (which is - on the default loader/linker path), fails because the generated Makefile has - LDFLAGS passed on after LIBS. - - See https://github.com/curl/curl/issues/14893 - -5.6 Cygwin: make install installs curl-config.1 twice - - https://github.com/curl/curl/issues/8839 - -5.12 flaky CI builds - - We run many CI builds for each commit and PR on github, and especially a - number of the Windows builds are flaky. This means that we rarely get all CI - builds go green and complete without errors. This is unfortunate as it makes - us sometimes miss actual build problems and it is surprising to newcomers to - the project who (rightfully) do not expect this. - - See https://github.com/curl/curl/issues/6972 - -5.13 long paths are not fully supported on Windows - - curl on Windows cannot access long paths (paths longer than 260 characters). - However, as a workaround, the Windows path prefix \\?\ which disables all - path interpretation may work to allow curl to access the path. For example: - \\?\c:\longpath. - - See https://github.com/curl/curl/issues/8361 - -5.15 Unicode on Windows - - Passing in a Unicode filename with -o: - - https://github.com/curl/curl/issues/11461 - - Passing in Unicode character with -d: - - https://github.com/curl/curl/issues/12231 - - Windows Unicode builds use homedir in current locale - - The Windows Unicode builds of curl use the current locale, but expect Unicode - UTF-8 encoded paths for internal use such as open, access and stat. The - user's home directory is retrieved via curl_getenv in the current locale and - not as UTF-8 encoded Unicode. - - See https://github.com/curl/curl/pull/7252 and - https://github.com/curl/curl/pull/7281 - - Cannot handle Unicode arguments in non-Unicode builds on Windows - - If a URL or filename cannot be encoded using the user's current codepage then - it can only be encoded properly in the Unicode character set. Windows uses - UTF-16 encoding for Unicode and stores it in wide characters, however curl - and libcurl are not equipped for that at the moment except when built with - _UNICODE and UNICODE defined. Except for Cygwin, Windows cannot use UTF-8 as - a locale. - - https://curl.se/bug/?i=345 - https://curl.se/bug/?i=731 - https://curl.se/bug/?i=3747 - - NTLM authentication and Unicode - - NTLM authentication involving Unicode username or password only works - properly if built with UNICODE defined together with the Schannel backend. - The original problem was mentioned in: - https://curl.se/mail/lib-2009-10/0024.html - https://curl.se/bug/view.cgi?id=896 - - The Schannel version verified to work as mentioned in - https://curl.se/mail/lib-2012-07/0073.html - -6. Authentication - -6.1 Digest auth-int for PUT/POST - - We do not support auth-int for Digest using PUT or POST - -6.2 MIT Kerberos for Windows build - - libcurl fails to build with MIT Kerberos for Windows (KfW) due to KfW's - library header files exporting symbols/macros that should be kept private to - the KfW library. - -6.3 NTLM in system context uses wrong name - - NTLM authentication using SSPI (on Windows) when (lib)curl is running in - "system context" makes it use wrong(?) username - at least when compared to - what winhttp does. See https://curl.se/bug/view.cgi?id=535 - -6.5 NTLM does not support password with Unicode 'SECTION SIGN' character - - Code point: U+00A7 - - https://en.wikipedia.org/wiki/Section_sign - https://github.com/curl/curl/issues/2120 - -6.6 libcurl can fail to try alternatives with --proxy-any - - When connecting via a proxy using --proxy-any, a failure to establish an - authentication causes libcurl to abort trying other options if the failed - method has a higher preference than the alternatives. As an example, - --proxy-any against a proxy which advertise Negotiate and NTLM, but which - fails to set up Kerberos authentication does not proceed to try - authentication using NTLM. - - https://github.com/curl/curl/issues/876 - -6.7 Do not clear digest for single realm - - https://github.com/curl/curl/issues/3267 - -6.9 SHA-256 digest not supported in Windows SSPI builds - - Windows builds of curl that have SSPI enabled use the native Windows API calls - to create authentication strings. The call to InitializeSecurityContext fails - with SEC_E_QOP_NOT_SUPPORTED which causes curl to fail with CURLE_AUTH_ERROR. - - Microsoft does not document supported digest algorithms and that SEC_E error - code is not a documented error for InitializeSecurityContext (digest). - - https://github.com/curl/curl/issues/6302 - -6.10 curl never completes Negotiate over HTTP - - Apparently it is not working correctly...? - - See https://github.com/curl/curl/issues/5235 - -6.11 Negotiate on Windows fails - - When using --negotiate (or NTLM) with curl on Windows, SSL/TLS handshake - fails despite having a valid kerberos ticket cached. Works without any issue - in Unix/Linux. - - https://github.com/curl/curl/issues/5881 - -6.13 Negotiate authentication against Hadoop HDFS - - https://github.com/curl/curl/issues/8264 - -7. FTP - -7.4 FTP with ACCT - - When doing an operation over FTP that requires the ACCT command (but not when - logging in), the operation fails since libcurl does not detect this and thus - fails to issue the correct command: https://curl.se/bug/view.cgi?id=635 - -7.12 FTPS server compatibility on Windows with Schannel - - FTPS is not widely used with the Schannel TLS backend and so there may be - more bugs compared to other TLS backends such as OpenSSL. In the past users - have reported hanging and failed connections. It is likely some changes to - curl since then fixed the issues. None of the reported issues can be - reproduced any longer. - - If you encounter an issue connecting to your server via FTPS with the latest - curl and Schannel then please search for open issues or file a new issue. - -9. SFTP and SCP - -9.1 SFTP does not do CURLOPT_POSTQUOTE correct - - When libcurl sends CURLOPT_POSTQUOTE commands when connected to an SFTP - server using the multi interface, the commands are not being sent correctly - and instead the connection is "cancelled" (the operation is considered done) - prematurely. There is a half-baked (busy-looping) patch provided in the bug - report but it cannot be accepted as-is. See - https://curl.se/bug/view.cgi?id=748 - -9.3 Remote recursive folder creation with SFTP - - On this servers, the curl fails to create directories on the remote server - even when the CURLOPT_FTP_CREATE_MISSING_DIRS option is set. - - See https://github.com/curl/curl/issues/5204 - -9.4 libssh blocking and infinite loop problem - - In the SSH_SFTP_INIT state for libssh, the ssh session working mode is set to - blocking mode. If the network is suddenly disconnected during sftp - transmission, curl is stuck, even if curl is configured with a timeout. - - https://github.com/curl/curl/issues/8632 - -9.5 Cygwin: "WARNING: UNPROTECTED PRIVATE KEY FILE!" - - Running SCP and SFTP tests on Cygwin makes this warning message appear. - - https://github.com/curl/curl/issues/11244 - -10. Connection - -10.1 --interface with link-scoped IPv6 address - - When you give the `--interface` option telling curl to use a specific - interface for its outgoing traffic in combination with an IPv6 address in the - URL that uses a link-local scope, curl might pick the wrong address from the - named interface and the subsequent transfer fails. - - Example command line: - - curl --interface eth0 'http://[fe80:928d:xxff:fexx:xxxx]/' - - The fact that the given IP address is link-scoped should probably be used as - input to somehow make curl make a better choice for this. - - https://github.com/curl/curl/issues/14782 - -10.2 Does not acknowledge getaddrinfo sorting policy - - Even if a user edits /etc/gai.conf to prefer IPv4, curl still prefers and - tries IPv6 addresses first. - - https://github.com/curl/curl/issues/16718 - - -10.3 SOCKS-SSPI discards the security context - - After a successful SSPI/GSS-API exchange, the function queries and logs the - authenticated username and reports the supported data-protection level, but - then immediately deletes the negotiated SSPI security context and frees the - credentials before returning. The negotiated context is not stored on the - connection and is therefore never used to protect later SOCKS5 traffic. - -11. Internals - -11.1 gssapi library name + version is missing in curl_version_info() - - The struct needs to be expanded and code added to store this info. - - See https://github.com/curl/curl/issues/13492 - -11.2 error buffer not set if connection to multiple addresses fails - - If you ask libcurl to resolve a hostname like example.com to IPv6 addresses - when you only have IPv4 connectivity. libcurl fails with - CURLE_COULDNT_CONNECT, but the error buffer set by CURLOPT_ERRORBUFFER - remains empty. Issue: https://github.com/curl/curl/issues/544 - -11.4 HTTP test server 'connection-monitor' problems - - The 'connection-monitor' feature of the sws HTTP test server does not work - properly if some tests are run in unexpected order. Like 1509 and then 1525. - - See https://github.com/curl/curl/issues/868 - -11.5 Connection information when using TCP Fast Open - - CURLINFO_LOCAL_PORT (and possibly a few other) fails when TCP Fast Open is - enabled. - - See https://github.com/curl/curl/issues/1332 and - https://github.com/curl/curl/issues/4296 - -11.6 test cases sometimes timeout - - Occasionally, one of the tests timeouts. Inexplicably. - - See https://github.com/curl/curl/issues/13350 - -11.7 CURLOPT_CONNECT_TO does not work for HTTPS proxy - - It is unclear if the same option should even cover the proxy connection or if - if requires a separate option. - - See https://github.com/curl/curl/issues/14481 - -11.8 WinIDN test failures - - Test 165 disabled when built with WinIDN. - -11.9 setting a disabled option should return CURLE_NOT_BUILT_IN - - When curl has been built with specific features or protocols disabled, - setting such options with curl_easy_setopt() should rather return - CURLE_NOT_BUILT_IN instead of CURLE_UNKNOWN_OPTION to signal the difference - to the application - - See https://github.com/curl/curl/issues/15472 - -12. LDAP - -12.1 OpenLDAP hangs after returning results - - By configuration defaults, OpenLDAP automatically chase referrals on - secondary socket descriptors. The OpenLDAP backend is asynchronous and thus - should monitor all socket descriptors involved. Currently, these secondary - descriptors are not monitored, causing OpenLDAP library to never receive - data from them. - - As a temporary workaround, disable referrals chasing by configuration. - - The fix is not easy: proper automatic referrals chasing requires a - synchronous bind callback and monitoring an arbitrary number of socket - descriptors for a single easy handle (currently limited to 5). - - Generic LDAP is synchronous: OK. - - See https://github.com/curl/curl/issues/622 and - https://curl.se/mail/lib-2016-01/0101.html - -12.2 LDAP on Windows does authentication wrong? - - https://github.com/curl/curl/issues/3116 - -12.3 LDAP on Windows does not work - - A simple curl command line getting "ldap://ldap.forumsys.com" returns an - error that says "no memory" ! - - https://github.com/curl/curl/issues/4261 - -12.4 LDAPS requests to ActiveDirectory server hang - - https://github.com/curl/curl/issues/9580 - -13. TCP/IP - -13.1 telnet code does not handle partial writes properly - - It probably does not happen too easily because of how slow and infrequent - sends are normally performed. - -13.2 Trying local ports fails on Windows - - This makes '--local-port [range]' to not work since curl cannot properly - detect if a port is already in use, so it tries the first port, uses that and - then subsequently fails anyway if that was actually in use. - - https://github.com/curl/curl/issues/8112 - -15. CMake - -15.1 cmake outputs: no version information available - - Something in the SONAME generation seems to be wrong in the cmake build. - - https://github.com/curl/curl/issues/11158 - -15.6 uses -lpthread instead of Threads::Threads - - See https://github.com/curl/curl/issues/6166 - -15.7 generated .pc file contains strange entries - - The Libs.private field of the generated .pc file contains -lgcc -lgcc_s -lc - -lgcc -lgcc_s - - See https://github.com/curl/curl/issues/6167 - -15.13 CMake build with MIT Kerberos does not work - - Minimum CMake version was bumped in curl 7.71.0 (#5358) Since CMake 3.2 - try_compile started respecting the CMAKE_EXE_FLAGS. The code dealing with - MIT Kerberos detection sets few variables to potentially weird mix of space, - and ;-separated flags. It had to blow up at some point. All the CMake checks - that involve compilation are doomed from that point, the configured tree - cannot be built. - - https://github.com/curl/curl/issues/6904 - -16. aws-sigv4 - -16.2 aws-sigv4 does not handle multipart/form-data correctly - - https://github.com/curl/curl/issues/13351 - -17. HTTP/2 - -17.1 HTTP/2 prior knowledge over proxy - - https://github.com/curl/curl/issues/12641 - -17.2 HTTP/2 frames while in the connection pool kill reuse - - If the server sends HTTP/2 frames (like for example an HTTP/2 PING frame) to - curl while the connection is held in curl's connection pool, the socket is - found readable when considered for reuse and that makes curl think it is dead - and then it is closed and a new connection gets created instead. - - This is *best* fixed by adding monitoring to connections while they are kept - in the pool so that pings can be responded to appropriately. - -17.3 ENHANCE_YOUR_CALM causes infinite retries - - Infinite retries with 2 parallel requests on one connection receiving GOAWAY - with ENHANCE_YOUR_CALM error code. - - See https://github.com/curl/curl/issues/5119 - -17.4 HTTP/2 + TLS spends a lot of time in recv - - It has been observed that by making the speed limit less accurate we could - improve this performance. (by reverting - https://github.com/curl/curl/commit/db5c9f4f9e0779b49624752b135281a0717b277b) - Can we find a golden middle ground? - - See https://curl.se/mail/lib-2024-05/0026.html and - https://github.com/curl/curl/issues/13416 - -18. HTTP/3 - -18.1 connection migration does not work - - https://github.com/curl/curl/issues/7695 - -18.2 quiche: QUIC connection is draining - - The transfer ends with error "QUIC connection is draining". - - https://github.com/curl/curl/issues/12037 - -18.3 OpenSSL-QUIC problems on google.com - - With some specific Google servers, and seemingly timing dependent, the - OpenSSL-QUIC backend seems to not actually send off the HTTP/3 request which - makes the QUIC connection just sit idle until killed by the server. curl or - OpenSSL bug? - - https://github.com/curl/curl/issues/18336 - -19. RTSP - -19.1 Some methods do not support response bodies - - The RTSP implementation is written to assume that a number of RTSP methods - always get responses without bodies, even though there seems to be no - indication in the RFC that this is always the case. - - https://github.com/curl/curl/issues/12414 diff --git a/docs/KNOWN_BUGS.md b/docs/KNOWN_BUGS.md new file mode 100644 index 000000000000..1f5cebee27c7 --- /dev/null +++ b/docs/KNOWN_BUGS.md @@ -0,0 +1,546 @@ + + +# Known bugs intro + +These are problems and bugs known to exist at the time of this release. Feel +free to join in and help us correct one or more of these. Also be sure to +check the changelog of the current development status, as one or more of these +problems may have been fixed or changed somewhat since this was written. + +# TLS + +## IMAPS connection fails with Rustls error + +[curl issue 10457](https://github.com/curl/curl/issues/10457) + +## Access violation sending client cert with Schannel + +When using Schannel to do client certs, curl sets `PKCS12_NO_PERSIST_KEY` to +avoid leaking the private key into the filesystem. Unfortunately that flag +instead seems to trigger a crash. + +See [curl issue 17626](https://github.com/curl/curl/issues/17626) + +## Client cert handling with Issuer `DN` differs between backends + +When the specified client certificate does not match any of the +server-specified `DN` fields, the OpenSSL and GnuTLS backends behave +differently. The GitHub discussion may contain a solution. + +See [curl issue 1411](https://github.com/curl/curl/issues/1411) + +## Client cert (MTLS) issues with Schannel + +See [curl issue 3145](https://github.com/curl/curl/issues/3145) + +## Schannel TLS 1.2 handshake bug in old Windows versions + +In old versions of Windows such as 7 and 8.1 the Schannel TLS 1.2 handshake +implementation likely has a bug that can rarely cause the key exchange to +fail, resulting in error SEC_E_BUFFER_TOO_SMALL or SEC_E_MESSAGE_ALTERED. + +[curl issue 5488](https://github.com/curl/curl/issues/5488) + +## `CURLOPT_CERTINFO` results in `CURLE_OUT_OF_MEMORY` with Schannel + +[curl issue 8741](https://github.com/curl/curl/issues/8741) + +## mbedTLS and CURLE_AGAIN handling + +[curl issue 15801](https://github.com/curl/curl/issues/15801) + +# Email protocols + +## IMAP `SEARCH ALL` truncated response + +IMAP `SEARCH ALL` truncates output on large boxes. "A quick search of the code +reveals that `pingpong.c` contains some truncation code, at line 408, when it +deems the server response to be too large truncating it to 40 characters" + +https://curl.se/bug/view.cgi?id=1366 + +## No disconnect command + +The disconnect commands (`LOGOUT` and `QUIT`) may not be sent by IMAP, POP3 +and SMTP if a failure occurs during the authentication phase of a connection. + +## `AUTH PLAIN` for SMTP is not working on all servers + +Specifying `--login-options AUTH=PLAIN` on the command line does not seem to +work correctly. + +See [curl issue 4080](https://github.com/curl/curl/issues/4080) + +## `APOP` authentication fails on POP3 + +See [curl issue 10073](https://github.com/curl/curl/issues/10073) + +## POP3 issue when reading small chunks + + CURL_DBG_SOCK_RMAX=4 ./runtests.pl -v 982 + +See [curl issue 12063](https://github.com/curl/curl/issues/12063) + +# Command line + +## `-T /dev/stdin` may upload with an incorrect content length + +`-T` stats the path to figure out its size in bytes to use it as +`Content-Length` if it is a regular file. + +The problem with that is that on BSD and some other UNIX systems (not Linux), +open(path) may not give you a file descriptor with a 0 offset from the start +of the file. + +See [curl issue 12177](https://github.com/curl/curl/issues/12177) + +## `-T -` always uploads chunked + +When the `<` shell operator is used. curl should realize that stdin is a +regular file in this case, and that it can do a non-chunked upload, like it +would do if you used `-T` file. + +See [curl issue 12171](https://github.com/curl/curl/issues/12171) + +# Build and portability issues + +## OS400 port requires deprecated IBM library + +curl for OS400 requires `QADRT` to build, which provides ASCII wrappers for +libc/POSIX functions in the ILE, but IBM no longer supports or even offers +this library to download. + +See [curl issue 5176](https://github.com/curl/curl/issues/5176) + +## `curl-config --libs` contains private details + +`curl-config --libs` include details set in `LDFLAGS` when configure is run +that might be needed only for building libcurl. Further, `curl-config +--cflags` suffers from the same effects with `CFLAGS`/`CPPFLAGS`. + +## `LDFLAGS` passed too late making libs linked incorrectly + +Compiling latest curl on HP-UX and linking against a custom OpenSSL (which is +on the default loader/linker path), fails because the generated Makefile has +`LDFLAGS` passed on after `LIBS`. + +See [curl issue 14893](https://github.com/curl/curl/issues/14893) + +## Cygwin: make install installs curl-config.1 twice + +[curl issue 8839](https://github.com/curl/curl/issues/8839) + +## flaky CI builds + +We run many CI builds for each commit and PR on GitHub, and especially a +number of the Windows builds are flaky. This means that we rarely get all CI +builds go green and complete without errors. This is unfortunate as it makes +us sometimes miss actual build problems and it is surprising to newcomers to +the project who (rightfully) do not expect this. + +See [curl issue 6972](https://github.com/curl/curl/issues/6972) + +## long paths are not fully supported on Windows + +curl on Windows cannot access long paths (paths longer than 260 characters). +However, as a workaround, the Windows path prefix `\\?\` which disables all +path interpretation may work to allow curl to access the path. For example: +`\\?\c:\longpath`. + +See [curl issue 8361](https://github.com/curl/curl/issues/8361) + +## Unicode on Windows + +Passing in a Unicode filename with -o: + +[curl issue 11461](https://github.com/curl/curl/issues/11461) + +Passing in Unicode character with -d: + + [curl issue 12231](https://github.com/curl/curl/issues/12231) + +Windows Unicode builds use the home directory in current locale. + +The Windows Unicode builds of curl use the current locale, but expect Unicode +UTF-8 encoded paths for internal use such as open, access and stat. The user's +home directory is retrieved via curl_getenv in the current locale and not as +UTF-8 encoded Unicode. + +See [curl pull request 7252](https://github.com/curl/curl/pull/7252) and [curl pull request 7281](https://github.com/curl/curl/pull/7281) + +Cannot handle Unicode arguments in non-Unicode builds on Windows + +If a URL or filename cannot be encoded using the user's current code page then +it can only be encoded properly in the Unicode character set. Windows uses +UTF-16 encoding for Unicode and stores it in wide characters, however curl and +libcurl are not equipped for that at the moment except when built with +_UNICODE and UNICODE defined. Except for Cygwin, Windows cannot use UTF-8 as a +locale. + + https://curl.se/bug/?i=345 + https://curl.se/bug/?i=731 + https://curl.se/bug/?i=3747 + +NTLM authentication and Unicode + +NTLM authentication involving Unicode username or password only works properly +if built with UNICODE defined together with the Schannel backend. The original +problem was mentioned in: https://curl.se/mail/lib-2009-10/0024.html and +https://curl.se/bug/view.cgi?id=896 + +The Schannel version verified to work as mentioned in +https://curl.se/mail/lib-2012-07/0073.html + +# Authentication + +## Digest `auth-int` for PUT/POST + +We do not support auth-int for Digest using PUT or POST + +## MIT Kerberos for Windows build + +libcurl fails to build with MIT Kerberos for Windows (`KfW`) due to its +library header files exporting symbols/macros that should be kept private to +the library. + +## NTLM in system context uses wrong name + +NTLM authentication using SSPI (on Windows) when (lib)curl is running in +"system context" makes it use wrong(?) username - at least when compared to +what `winhttp` does. See https://curl.se/bug/view.cgi?id=535 + +## NTLM does not support password with Unicode 'SECTION SIGN' character + + https://en.wikipedia.org/wiki/Section_sign + [curl issue 2120](https://github.com/curl/curl/issues/2120) + +## libcurl can fail to try alternatives with `--proxy-any` + +When connecting via a proxy using `--proxy-any`, a failure to establish an +authentication causes libcurl to abort trying other options if the failed +method has a higher preference than the alternatives. As an example, +`--proxy-any` against a proxy which advertise Negotiate and NTLM, but which +fails to set up Kerberos authentication does not proceed to try authentication +using NTLM. + +[curl issue 876](https://github.com/curl/curl/issues/876) + +## Do not clear digest for single realm + + [curl issue 3267](https://github.com/curl/curl/issues/3267) + +## SHA-256 digest not supported in Windows SSPI builds + +Windows builds of curl that have SSPI enabled use the native Windows API calls +to create authentication strings. The call to `InitializeSecurityContext` fails +with `SEC_E_QOP_NOT_SUPPORTED` which causes curl to fail with +`CURLE_AUTH_ERROR`. + +Microsoft does not document supported digest algorithms and that `SEC_E` error +code is not a documented error for `InitializeSecurityContext` (digest). + + [curl issue 6302](https://github.com/curl/curl/issues/6302) + +## curl never completes Negotiate over HTTP + +Apparently it is not working correctly...? + +See [curl issue 5235](https://github.com/curl/curl/issues/5235) + +## Negotiate on Windows fails + +When using `--negotiate` (or NTLM) with curl on Windows, SSL/TLS handshake +fails despite having a valid kerberos ticket cached. Works without any issue +in Unix/Linux. + +[curl issue 5881](https://github.com/curl/curl/issues/5881) + +## Negotiate authentication against Hadoop + +[curl issue 8264](https://github.com/curl/curl/issues/8264) + +# FTP + +## FTP with ACCT + +When doing an operation over FTP that requires the `ACCT` command (but not when +logging in), the operation fails since libcurl does not detect this and thus +fails to issue the correct command: https://curl.se/bug/view.cgi?id=635 + +## FTPS server compatibility on Windows with Schannel + +FTPS is not widely used with the Schannel TLS backend and so there may be more +bugs compared to other TLS backends such as OpenSSL. In the past users have +reported hanging and failed connections. It is likely some changes to curl +since then fixed the issues. None of the reported issues can be reproduced any +longer. + +If you encounter an issue connecting to your server via FTPS with the latest +curl and Schannel then please search for open issues or file a new issue. + +# SFTP and SCP + +## SFTP does not do `CURLOPT_POSTQUOTE` correct + +When libcurl sends `CURLOPT_POSTQUOTE` commands when connected to an SFTP +server using the multi interface, the commands are not being sent correctly +and instead the connection is canceled (the operation is considered done) +prematurely. There is a half-baked (busy-looping) patch provided in the bug +report but it cannot be accepted as-is. See +https://curl.se/bug/view.cgi?id=748 + +## Remote recursive folder creation with SFTP + +On this servers, the curl fails to create directories on the remote server +even when the `CURLOPT_FTP_CREATE_MISSING_DIRS` option is set. + +See [curl issue 5204](https://github.com/curl/curl/issues/5204) + +## libssh blocking and infinite loop problem + +In the `SSH_SFTP_INIT` state for libssh, the ssh session working mode is set +to blocking mode. If the network is suddenly disconnected during sftp +transmission, curl is stuck, even if curl is configured with a timeout. + + [curl issue 8632](https://github.com/curl/curl/issues/8632) + +## Cygwin: "WARNING: UNPROTECTED PRIVATE KEY FILE!" + +Running SCP and SFTP tests on Cygwin makes this warning message appear. + +[curl issue 11244](https://github.com/curl/curl/issues/11244) + +# Connection + +## `--interface` with link-scoped IPv6 address + +When you give the `--interface` option telling curl to use a specific +interface for its outgoing traffic in combination with an IPv6 address in the +URL that uses a link-local scope, curl might pick the wrong address from the +named interface and the subsequent transfer fails. + +Example command line: + + curl --interface eth0 'http://[fe80:928d:xxff:fexx:xxxx]/' + +The fact that the given IP address is link-scoped should probably be used as +input to somehow make curl make a better choice for this. + +[curl issue 14782](https://github.com/curl/curl/issues/14782) + +## Does not acknowledge getaddrinfo sorting policy + +Even if a user edits `/etc/gai.conf` to prefer IPv4, curl still prefers and +tries IPv6 addresses first. + +[curl issue 16718](https://github.com/curl/curl/issues/16718) + +## SOCKS-SSPI discards the security context + +After a successful SSPI/GSS-API exchange, the function queries and logs the +authenticated username and reports the supported data-protection level, but +then immediately deletes the negotiated SSPI security context and frees the +credentials before returning. The negotiated context is not stored on the +connection and is therefore never used to protect later SOCKS5 traffic. + +# Internals + +## GSSAPI library name + version is missing in `curl_version_info()` + +The struct needs to be expanded and code added to store this info. + +See [curl issue 13492](https://github.com/curl/curl/issues/13492) + +## error buffer not set if connection to multiple addresses fails + +If you ask libcurl to resolve a hostname like example.com to IPv6 addresses +when you only have IPv4 connectivity. libcurl fails with +`CURLE_COULDNT_CONNECT`, but the error buffer set by `CURLOPT_ERRORBUFFER` +remains empty. Issue: [curl issue 544](https://github.com/curl/curl/issues/544) + +## HTTP test server 'connection-monitor' problems + +The `connection-monitor` feature of the HTTP test server does not work +properly if some tests are run in unexpected order. Like 1509 and then 1525. + +See [curl issue 868](https://github.com/curl/curl/issues/868) + +## Connection information when using TCP Fast Open + +`CURLINFO_LOCAL_PORT` (and possibly a few other) fails when TCP Fast Open is +enabled. + +See [curl issue 1332](https://github.com/curl/curl/issues/1332) and +[curl issue 4296](https://github.com/curl/curl/issues/4296) + +## test cases sometimes timeout + +Occasionally, one of the tests timeouts. Inexplicably. + +See [curl issue 13350](https://github.com/curl/curl/issues/13350) + +## `CURLOPT_CONNECT_TO` does not work for HTTPS proxy + +It is unclear if the same option should even cover the proxy connection or if +if requires a separate option. + +See [curl issue 14481](https://github.com/curl/curl/issues/14481) + +## WinIDN test failures + +Test 165 disabled when built with WinIDN. + +## setting a disabled option should return `CURLE_NOT_BUILT_IN` + +When curl has been built with specific features or protocols disabled, setting +such options with `curl_easy_setopt()` should rather return +`CURLE_NOT_BUILT_IN` instead of `CURLE_UNKNOWN_OPTION` to signal the +difference to the application + +See [curl issue 15472](https://github.com/curl/curl/issues/15472) + +# LDAP + +## OpenLDAP hangs after returning results + +By configuration defaults, OpenLDAP automatically chase referrals on secondary +socket descriptors. The OpenLDAP backend is asynchronous and thus should +monitor all socket descriptors involved. Currently, these secondary +descriptors are not monitored, causing OpenLDAP library to never receive data +from them. + +As a temporary workaround, disable referrals chasing by configuration. + +The fix is not easy: proper automatic referrals chasing requires a synchronous +bind callback and monitoring an arbitrary number of socket descriptors for a +single easy handle (currently limited to 5). + +Generic LDAP is synchronous: OK. + +See [curl issue 622](https://github.com/curl/curl/issues/622) and +https://curl.se/mail/lib-2016-01/0101.html + +## LDAP on Windows does authentication wrong? + +[curl issue 3116](https://github.com/curl/curl/issues/3116) + +## LDAP on Windows does not work + +A simple curl command line getting `ldap://ldap.forumsys.com` returns an error +that says `no memory` ! + +[curl issue 4261](https://github.com/curl/curl/issues/4261) + +## LDAPS requests to Active Directory server hang + +[curl issue 9580](https://github.com/curl/curl/issues/9580) + +# TCP/IP + +## telnet code does not handle partial writes properly + +It probably does not happen too easily because of how slow and infrequent +sends are normally performed. + +## Trying local ports fails on Windows + +This makes `--local-port [range]` to not work since curl cannot properly +detect if a port is already in use, so it tries the first port, uses that and +then subsequently fails anyway if that was actually in use. + +[curl issue 8112](https://github.com/curl/curl/issues/8112) + +# CMake + +## cmake outputs: no version information available + +Something in the SONAME generation seems to be wrong in the cmake build. + +[curl issue 11158](https://github.com/curl/curl/issues/11158) + +## uses `-lpthread` instead of `Threads::Threads` + +See [curl issue 6166](https://github.com/curl/curl/issues/6166) + +## generated `.pc` file contains strange entries + +The `Libs.private` field of the generated `.pc` file contains `-lgcc -lgcc_s +-lc -lgcc -lgcc_s`. + +See [curl issue 6167](https://github.com/curl/curl/issues/6167) + +## CMake build with MIT Kerberos does not work + +Minimum CMake version was bumped in curl 7.71.0 (#5358) Since CMake 3.2 +try_compile started respecting the `CMAKE_EXE_FLAGS`. The code dealing with +MIT Kerberos detection sets few variables to potentially weird mix of space, +and ;-separated flags. It had to blow up at some point. All the CMake checks +that involve compilation are doomed from that point, the configured tree +cannot be built. + +[curl issue 6904](https://github.com/curl/curl/issues/6904) + +# Authentication + +## `--aws-sigv4` does not handle multipart/form-data correctly + +[curl issue 13351](https://github.com/curl/curl/issues/13351) + +# HTTP/2 + +## HTTP/2 prior knowledge over proxy + + [curl issue 12641](https://github.com/curl/curl/issues/12641) + +## HTTP/2 frames while in the connection pool kill reuse + +If the server sends HTTP/2 frames (like for example an HTTP/2 PING frame) to +curl while the connection is held in curl's connection pool, the socket is +found readable when considered for reuse and that makes curl think it is dead +and then it is closed and a new connection gets created instead. + +This is *best* fixed by adding monitoring to connections while they are kept +in the pool so that pings can be responded to appropriately. + +## `ENHANCE_YOUR_CALM` causes infinite retries + +Infinite retries with 2 parallel requests on one connection receiving `GOAWAY` +with `ENHANCE_YOUR_CALM` error code. + +See [curl issue 5119](https://github.com/curl/curl/issues/5119) + +## HTTP/2 + TLS spends a lot of time in recv + +It has been observed that by making the speed limit less accurate we could +improve this performance. (by reverting +[db5c9f4f9e0779](https://github.com/curl/curl/commit/db5c9f4f9e0779b49624752b135281a0717b277b)) +Can we find a golden middle ground? + +See https://curl.se/mail/lib-2024-05/0026.html and +[curl issue 13416](https://github.com/curl/curl/issues/13416) + +# HTTP/3 + +## connection migration does not work + +[curl issue 7695](https://github.com/curl/curl/issues/7695) + +## quiche: QUIC connection is draining + +The transfer ends with error "QUIC connection is draining". + +[curl issue 12037](https://github.com/curl/curl/issues/12037) + +# RTSP + +## Some methods do not support response bodies + +The RTSP implementation is written to assume that a number of RTSP methods +always get responses without bodies, even though there seems to be no +indication in the RFC that this is always the case. + +[curl issue 12414](https://github.com/curl/curl/issues/12414) diff --git a/docs/Makefile.am b/docs/Makefile.am index da5812a0eb76..0b619b600883 100644 --- a/docs/Makefile.am +++ b/docs/Makefile.am @@ -93,7 +93,7 @@ EXTRA_DIST = \ EARLY-RELEASE.md \ ECH.md \ EXPERIMENTAL.md \ - FAQ \ + FAQ.md \ FEATURES.md \ GOVERNANCE.md \ HELP-US.md \ @@ -108,7 +108,7 @@ EXTRA_DIST = \ INSTALL.md \ INTERNALS.md \ IPFS.md \ - KNOWN_BUGS \ + KNOWN_BUGS.md \ KNOWN_RISKS.md \ MAIL-ETIQUETTE.md \ MANUAL.md \ @@ -121,7 +121,8 @@ EXTRA_DIST = \ SPONSORS.md \ SSL-PROBLEMS.md \ SSLCERTS.md \ - THANKS TODO \ + THANKS \ + TODO.md \ TheArtOfHttpScripting.md \ URL-SYNTAX.md \ VERSIONS.md \ diff --git a/docs/TODO b/docs/TODO deleted file mode 100644 index 22ca27f88d99..000000000000 --- a/docs/TODO +++ /dev/null @@ -1,1301 +0,0 @@ - _ _ ____ _ - ___| | | | _ \| | - / __| | | | |_) | | - | (__| |_| | _ <| |___ - \___|\___/|_| \_\_____| - - Things that could be nice to do in the future - - Things to do in project curl. Please tell us what you think, contribute and - send us patches that improve things. - - Be aware that these are things that we could do, or have once been considered - things we could do. If you want to work on any of these areas, please - consider bringing it up for discussions first on the mailing list so that we - all agree it is still a good idea for the project. - - All bugs documented in the KNOWN_BUGS document are subject for fixing. - - 1. libcurl - 1.1 TFO support on Windows - 1.2 Consult %APPDATA% also for .netrc - 1.3 struct lifreq - 1.4 alt-svc sharing - 1.5 get rid of PATH_MAX - 1.6 thread-safe sharing - 1.10 auto-detect proxy - 1.12 updated DNS server while running - 1.13 c-ares and CURLOPT_OPENSOCKETFUNCTION - 1.15 Monitor connections in the connection pool - 1.16 Try to URL encode given URL - 1.17 Add support for IRIs - 1.18 try next proxy if one does not work - 1.19 provide timing info for each redirect - 1.20 SRV and URI DNS records - 1.22 CURLINFO_PAUSE_STATE - 1.25 Expose tried IP addresses that failed - 1.30 config file parsing - 1.31 erase secrets from heap/stack after use - 1.32 add asynch getaddrinfo support - 1.33 make DoH inherit more transfer properties - - 2. libcurl - multi interface - 2.1 More non-blocking - 2.2 Better support for same name resolves - 2.3 Non-blocking curl_multi_remove_handle() - 2.4 Split connect and authentication process - 2.5 Edge-triggered sockets should work - 2.6 multi upkeep - 2.7 Virtual external sockets - 2.8 dynamically decide to use socketpair - - 3. Documentation - 3.1 Improve documentation about fork safety - - 4. FTP - 4.1 HOST - 4.2 A fixed directory listing format - 4.6 GSSAPI via Windows SSPI - 4.7 STAT for LIST without data connection - 4.8 Passive transfer could try other IP addresses - - 5. HTTP - 5.1 Provide the error body from a CONNECT response - 5.2 Obey Retry-After in redirects - 5.3 Rearrange request header order - 5.4 Allow SAN names in HTTP/2 server push - 5.5 auth= in URLs - 5.6 alt-svc should fallback if alt-svc does not work - 5.7 Require HTTP version X or higher - - 6. TELNET - 6.1 ditch stdin - 6.2 ditch telnet-specific select - 6.3 feature negotiation debug data - 6.4 exit immediately upon connection if stdin is /dev/null - - 7. SMTP - 7.1 Passing NOTIFY option to CURLOPT_MAIL_RCPT - 7.2 Enhanced capability support - 7.3 Add CURLOPT_MAIL_CLIENT option - - 8. POP3 - 8.2 Enhanced capability support - - 9. IMAP - 9.1 Enhanced capability support - - 10. LDAP - 10.1 SASL based authentication mechanisms - 10.2 CURLOPT_SSL_CTX_FUNCTION for LDAPS - 10.3 Paged searches on LDAP server - 10.4 Certificate-Based Authentication - - 11. SMB - 11.1 File listing support - 11.2 Honor file timestamps - 11.3 Use NTLMv2 - 11.4 Create remote directories - - 12. FILE - 12.1 Directory listing on non-POSIX - - 13. TLS - 13.1 TLS-PSK with OpenSSL - 13.2 TLS channel binding - 13.3 Defeat TLS fingerprinting - 13.4 Consider OCSP stapling by default - 13.6 Provide callback for cert verification - 13.7 Less memory massaging with Schannel - 13.8 Support DANE - 13.9 TLS record padding - 13.10 Support Authority Information Access certificate extension (AIA) - 13.11 Some TLS options are not offered for HTTPS proxies - 13.13 Make sure we forbid TLS 1.3 post-handshake authentication - 13.14 Support the clienthello extension - 13.16 Share the CA cache - 13.17 Add missing features to TLS backends - - 14. Proxy - 14.1 Retry SOCKS handshake on address type not supported - - 15. Schannel - 15.1 Extend support for client certificate authentication - 15.2 Extend support for the --ciphers option - 15.4 Add option to allow abrupt server closure - - 16. SASL - 16.1 Other authentication mechanisms - 16.2 Add QOP support to GSSAPI authentication - - 17. SSH protocols - 17.1 Multiplexing - 17.2 Handle growing SFTP files - 17.3 Read keys from ~/.ssh/id_ecdsa, id_ed25519 - 17.4 Support CURLOPT_PREQUOTE - 17.5 SSH over HTTPS proxy with more backends - 17.6 SFTP with SCP:// - - 18. Command line tool - 18.1 sync - 18.2 glob posts - 18.4 --proxycommand - 18.5 UTF-8 filenames in Content-Disposition - 18.6 Option to make -Z merge lined based outputs on stdout - 18.7 specify which response codes that make -f/--fail return error - 18.9 Choose the name of file in braces for complex URLs - 18.10 improve how curl works in a Windows console window - 18.11 Windows: set attribute 'archive' for completed downloads - 18.12 keep running, read instructions from pipe/socket - 18.13 Acknowledge Ratelimit headers - 18.14 --dry-run - 18.15 --retry should resume - 18.17 consider filename from the redirected URL with -O ? - 18.18 retry on network is unreachable - 18.20 hostname sections in config files - 18.21 retry on the redirected-to URL - 18.23 Set the modification date on an uploaded file - 18.24 Use multiple parallel transfers for a single download - 18.25 Prevent terminal injection when writing to terminal - 18.26 Custom progress meter update interval - 18.27 -J and -O with %-encoded filenames - 18.28 -J with -C - - 18.29 --retry and transfer timeouts - - 19. Build - 19.2 Enable PIE and RELRO by default - 19.3 Do not use GNU libtool on OpenBSD - 19.4 Package curl for Windows in a signed installer - 19.5 make configure use --cache-file more and better - - 20. Test suite - 20.1 SSL tunnel - 20.2 more protocols supported - 20.3 more platforms supported - 20.4 write an SMB test server to replace impacket - 20.5 Use the RFC 6265 test suite - 20.6 Run web-platform-tests URL tests - - 21. MQTT - 21.1 Support rate-limiting - 21.2 Support MQTTS - 21.3 Handle network blocks - 21.4 large payloads - - 22. TFTP - 22.1 TFTP does not convert LF to CRLF for mode=netascii - - 23. Gopher - 23.1 Handle network blocks - -============================================================================== - -1. libcurl - -1.1 TFO support on Windows - - libcurl supports the CURLOPT_TCP_FASTOPEN option since 7.49.0 for Linux and - macOS. Windows supports TCP Fast Open starting with Windows 10, version 1607 - and we should add support for it. - - TCP Fast Open is supported on several platforms but not on Windows. Work on - this was once started but never finished. - - See https://github.com/curl/curl/pull/3378 - -1.2 Consult %APPDATA% also for .netrc - - %APPDATA%\.netrc is not considered when running on Windows. should not it? - - See https://github.com/curl/curl/issues/4016 - -1.3 struct lifreq - - Use 'struct lifreq' and SIOCGLIFADDR instead of 'struct ifreq' and - SIOCGIFADDR on newer Solaris versions as they claim the latter is obsolete. - To support IPv6 interface addresses for network interfaces properly. - -1.4 alt-svc sharing - - The share interface could benefit from allowing the alt-svc cache to be - possible to share between easy handles. - - See https://github.com/curl/curl/issues/4476 - - The share interface offers CURL_LOCK_DATA_CONNECT to have multiple easy - handle share a connection cache, but due to how connections are used they are - still not thread-safe when used shared. - - See https://github.com/curl/curl/issues/4915 and lib1541.c - - The share interface offers CURL_LOCK_DATA_HSTS to have multiple easy handle - share an HSTS cache, but this is not thread-safe. - -1.5 get rid of PATH_MAX - - Having code use and rely on PATH_MAX is not nice: - https://insanecoding.blogspot.com/2007/11/pathmax-simply-isnt.html - - Currently the libssh2 SSH based code uses it, but to remove PATH_MAX from - there we need libssh2 to properly tell us when we pass in a too small buffer - and its current API (as of libssh2 1.2.7) does not. - -1.6 thread-safe sharing - - Using the share interface users can share some data between easy handles but - several of the sharing options are documented as not safe and supported to - share between multiple concurrent threads. Fixing this would enable more - users to share data in more powerful ways. - -1.10 auto-detect proxy - - libcurl could be made to detect the system proxy setup automatically and use - that. On Windows, macOS and Linux desktops for example. - - The pull-request to use libproxy for this was deferred due to doubts on the - reliability of the dependency and how to use it: - https://github.com/curl/curl/pull/977 - - libdetectproxy is a (C++) library for detecting the proxy on Windows - https://github.com/paulharris/libdetectproxy - -1.12 updated DNS server while running - - If /etc/resolv.conf gets updated while a program using libcurl is running, it - is may cause name resolves to fail unless res_init() is called. We should - consider calling res_init() + retry once unconditionally on all name resolve - failures to mitigate against this. Firefox works like that. Note that Windows - does not have res_init() or an alternative. - - https://github.com/curl/curl/issues/2251 - -1.13 c-ares and CURLOPT_OPENSOCKETFUNCTION - - curl creates most sockets via the CURLOPT_OPENSOCKETFUNCTION callback and - close them with the CURLOPT_CLOSESOCKETFUNCTION callback. However, c-ares - does not use those functions and instead opens and closes the sockets itself. - This means that when curl passes the c-ares socket to the - CURLMOPT_SOCKETFUNCTION it is not owned by the application like other - sockets. - - See https://github.com/curl/curl/issues/2734 - -1.15 Monitor connections in the connection pool - - libcurl's connection cache or pool holds a number of open connections for the - purpose of possible subsequent connection reuse. It may contain a few up to a - significant amount of connections. Currently, libcurl leaves all connections - as they are and first when a connection is iterated over for matching or - reuse purpose it is verified that it is still alive. - - Those connections may get closed by the server side for idleness or they may - get an HTTP/2 ping from the peer to verify that they are still alive. By - adding monitoring of the connections while in the pool, libcurl can detect - dead connections (and close them) better and earlier, and it can handle - HTTP/2 pings to keep such ones alive even when not actively doing transfers - on them. - -1.16 Try to URL encode given URL - - Given a URL that for example contains spaces, libcurl could have an option - that would try somewhat harder than it does now and convert spaces to %20 and - perhaps URL encoded byte values over 128 etc (basically do what the redirect - following code already does). - - https://github.com/curl/curl/issues/514 - -1.17 Add support for IRIs - - IRIs (RFC 3987) allow localized, non-ASCII, names in the URL. To properly - support this, curl/libcurl would need to translate/encode the given input - from the input string encoding into percent encoded output "over the wire". - - To make that work smoothly for curl users even on Windows, curl would - probably need to be able to convert from several input encodings. - -1.18 try next proxy if one does not work - - Allow an application to specify a list of proxies to try, and failing to - connect to the first go on and try the next instead until the list is - exhausted. Browsers support this feature at least when they specify proxies - using PACs. - - https://github.com/curl/curl/issues/896 - -1.19 provide timing info for each redirect - - curl and libcurl provide timing information via a set of different - time-stamps (CURLINFO_*_TIME). When curl is following redirects, those - returned time value are the accumulated sums. An improvement could be to - offer separate timings for each redirect. - - https://github.com/curl/curl/issues/6743 - -1.20 SRV and URI DNS records - - Offer support for resolving SRV and URI DNS records for libcurl to know which - server to connect to for various protocols (including HTTP). - -1.22 CURLINFO_PAUSE_STATE - - Return information about the transfer's current pause state, in both - directions. https://github.com/curl/curl/issues/2588 - -1.25 Expose tried IP addresses that failed - - When libcurl fails to connect to a host, it could offer the application the - addresses that were used in the attempt. Source + dest IP, source + dest port - and protocol (UDP or TCP) for each failure. Possibly as a callback. Perhaps - also provide "reason". - - https://github.com/curl/curl/issues/2126 - -1.30 config file parsing - - Consider providing an API, possibly in a separate companion library, for - parsing a config file like curl's -K/--config option to allow applications to - get the same ability to read curl options from files. - - See https://github.com/curl/curl/issues/3698 - -1.31 erase secrets from heap/stack after use - - Introducing a concept and system to erase secrets from memory after use, it - could help mitigate and lessen the impact of (future) security problems etc. - However: most secrets are passed to libcurl as clear text from the - application and then clearing them within the library adds nothing... - - https://github.com/curl/curl/issues/7268 - -1.32 add asynch getaddrinfo support - - Use getaddrinfo_a() to provide an asynch name resolver backend to libcurl - that does not use threads and does not depend on c-ares. The getaddrinfo_a - function is (probably?) glibc specific but that is a widely used libc among - our users. - - https://github.com/curl/curl/pull/6746 - -1.33 make DoH inherit more transfer properties - - Some options are not inherited because they are not relevant for the DoH SSL - connections, or inheriting the option may result in unexpected behavior. For - example the user's debug function callback is not inherited because it would - be unexpected for internal handles (ie DoH handles) to be passed to that - callback. - - If an option is not inherited then it is not possible to set it separately - for DoH without a DoH-specific option. For example: - CURLOPT_DOH_SSL_VERIFYHOST, CURLOPT_DOH_SSL_VERIFYPEER and - CURLOPT_DOH_SSL_VERIFYSTATUS. - - See https://github.com/curl/curl/issues/6605 - -2. libcurl - multi interface - -2.1 More non-blocking - - Make sure we do not ever loop because of non-blocking sockets returning - EWOULDBLOCK or similar. Blocking cases include: - - - Name resolves on non-Windows unless c-ares or the threaded resolver is used. - - - The threaded resolver may block on cleanup: - https://github.com/curl/curl/issues/4852 - - - file:// transfers - - - TELNET transfers - - - GSSAPI authentication for FTP transfers - - - The "DONE" operation (post transfer protocol-specific actions) for the - protocols SFTP, SMTP, FTP. Fixing multi_done() for this is a worthy task. - - - curl_multi_remove_handle for any of the above. See section 2.3. - - - Calling curl_ws_send() from a callback - -2.2 Better support for same name resolves - - If a name resolve has been initiated for name NN and a second easy handle - wants to resolve that name as well, make it wait for the first resolve to end - up in the cache instead of doing a second separate resolve. This is - especially needed when adding many simultaneous handles using the same host - name when the DNS resolver can get flooded. - -2.3 Non-blocking curl_multi_remove_handle() - - The multi interface has a few API calls that assume a blocking behavior, like - add_handle() and remove_handle() which limits what we can do internally. The - multi API need to be moved even more into a single function that "drives" - everything in a non-blocking manner and signals when something is done. A - remove or add would then only ask for the action to get started and then - multi_perform() etc still be called until the add/remove is completed. - -2.4 Split connect and authentication process - - The multi interface treats the authentication process as part of the connect - phase. As such any failures during authentication does not trigger the - relevant QUIT or LOGOFF for protocols such as IMAP, POP3 and SMTP. - -2.5 Edge-triggered sockets should work - - The multi_socket API should work with edge-triggered socket events. One of - the internal actions that need to be improved for this to work perfectly is - the 'maxloops' handling in transfer.c:readwrite_data(). - -2.6 multi upkeep - - In libcurl 7.62.0 we introduced curl_easy_upkeep. It unfortunately only works - on easy handles. We should introduces a version of that for the multi handle, - and also consider doing "upkeep" automatically on connections in the - connection pool when the multi handle is in used. - - See https://github.com/curl/curl/issues/3199 - -2.7 Virtual external sockets - - libcurl performs operations on the given file descriptor that presumes it is - a socket and an application cannot replace them at the moment. Allowing an - application to fully replace those would allow a larger degree of freedom and - flexibility. - - See https://github.com/curl/curl/issues/5835 - -2.8 dynamically decide to use socketpair - - For users who do not use curl_multi_wait() or do not care for - curl_multi_wakeup(), we could introduce a way to make libcurl NOT - create a socketpair in the multi handle. - - See https://github.com/curl/curl/issues/4829 - -3. Documentation - -3.1 Improve documentation about fork safety - - See https://github.com/curl/curl/issues/6968 - -4. FTP - -4.1 HOST - - HOST is a command for a client to tell which hostname to use, to offer FTP - servers named-based virtual hosting: - - https://datatracker.ietf.org/doc/html/rfc7151 - -4.2 A fixed directory listing format - - Since listing the contents of a remove directory with FTP is returning the - list in a format and style the server likes without any estblished or even - defactor standard existing, it would be a feature to users if curl could - parse the directory listing and output a general curl format that is fixed - and the same, independent of the server's choice. This would allow users to - better and more reliably extract information about remote content via FTP - directory listings. - -4.6 GSSAPI via Windows SSPI - - In addition to currently supporting the SASL GSSAPI mechanism (Kerberos V5) - via third-party GSS-API libraries, such as MIT Kerberos, also add support - for GSSAPI authentication via Windows SSPI. - -4.7 STAT for LIST without data connection - - Some FTP servers allow STAT for listing directories instead of using LIST, - and the response is then sent over the control connection instead of as the - otherwise usedw data connection: https://www.nsftools.com/tips/RawFTP.htm#STAT - - This is not detailed in any FTP specification. - -4.8 Passive transfer could try other IP addresses - - When doing FTP operations through a proxy at localhost, the reported spotted - that curl only tried to connect once to the proxy, while it had multiple - addresses and a failed connect on one address should make it try the next. - - After switching to passive mode (EPSV), curl could try all IP addresses for - "localhost". Currently it tries ::1, but it should also try 127.0.0.1. - - See https://github.com/curl/curl/issues/1508 - -5. HTTP - -5.1 Provide the error body from a CONNECT response - - When curl receives a body response from a CONNECT request to a proxy, it - always just reads and ignores it. It would make some users happy if curl - instead optionally would be able to make that responsible available. Via a - new callback? Through some other means? - - See https://github.com/curl/curl/issues/9513 - -5.2 Obey Retry-After in redirects - - The Retry-After is said to dictate "the minimum time that the user agent is - asked to wait before issuing the redirected request" and libcurl does not - obey this. - - See https://github.com/curl/curl/issues/11447 - -5.3 Rearrange request header order - - Server implementers often make an effort to detect browser and to reject - clients it can detect to not match. One of the last details we cannot yet - control in libcurl's HTTP requests, which also can be exploited to detect - that libcurl is in fact used even when it tries to impersonate a browser, is - the order of the request headers. I propose that we introduce a new option in - which you give headers a value, and then when the HTTP request is built it - sorts the headers based on that number. We could then have internally created - headers use a default value so only headers that need to be moved have to be - specified. - -5.4 Allow SAN names in HTTP/2 server push - - curl only allows HTTP/2 push promise if the provided :authority header value - exactly matches the hostname given in the URL. It could be extended to allow - any name that would match the Subject Alternative Names in the server's TLS - certificate. - - See https://github.com/curl/curl/pull/3581 - -5.5 auth= in URLs - - Add the ability to specify the preferred authentication mechanism to use by - using ;auth= in the login part of the URL. - - For example: - - http://test:pass;auth=NTLM@example.com would be equivalent to specifying - --user test:pass;auth=NTLM or --user test:pass --ntlm from the command line. - - Additionally this should be implemented for proxy base URLs as well. - -5.6 alt-svc should fallback if alt-svc does not work - - The alt-svc: header provides a set of alternative services for curl to use - instead of the original. If the first attempted one fails, it should try the - next etc and if all alternatives fail go back to the original. - - See https://github.com/curl/curl/issues/4908 - -5.7 Require HTTP version X or higher - - curl and libcurl provide options for trying higher HTTP versions (for example - HTTP/2) but then still allows the server to pick version 1.1. We could - consider adding a way to require a minimum version. - - See https://github.com/curl/curl/issues/7980 - -6. TELNET - -6.1 ditch stdin - - Reading input (to send to the remote server) on stdin is a crappy solution - for library purposes. We need to invent a good way for the application to be - able to provide the data to send. - -6.2 ditch telnet-specific select - - Move the telnet support's network select() loop go away and merge the code - into the main transfer loop. Until this is done, the multi interface does not - work for telnet. - -6.3 feature negotiation debug data - - Add telnet feature negotiation data to the debug callback as header data. - -6.4 exit immediately upon connection if stdin is /dev/null - - If it did, curl could be used to probe if there is an server there listening - on a specific port. That is, the following command would exit immediately - after the connection is established with exit code 0: - - curl -s --connect-timeout 2 telnet://example.com:80 NOTIFY=SUCCESS,FAILURE" ); - - https://github.com/curl/curl/issues/8232 - -7.2 Enhanced capability support - - Add the ability, for an application that uses libcurl, to obtain the list of - capabilities returned from the EHLO command. - -7.3 Add CURLOPT_MAIL_CLIENT option - - Rather than use the URL to specify the mail client string to present in the - HELO and EHLO commands, libcurl should support a new CURLOPT specifically for - specifying this data as the URL is non-standard and to be honest a bit of a - hack ;-) - - Please see the following thread for more information: - https://curl.se/mail/lib-2012-05/0178.html - - -8. POP3 - -8.2 Enhanced capability support - - Add the ability, for an application that uses libcurl, to obtain the list of - capabilities returned from the CAPA command. - -9. IMAP - -9.1 Enhanced capability support - - Add the ability, for an application that uses libcurl, to obtain the list of - capabilities returned from the CAPABILITY command. - -10. LDAP - -10.1 SASL based authentication mechanisms - - Currently the LDAP module only supports ldap_simple_bind_s() in order to bind - to an LDAP server. However, this function sends username and password details - using the simple authentication mechanism (as clear text). However, it should - be possible to use ldap_bind_s() instead specifying the security context - information ourselves. - -10.2 CURLOPT_SSL_CTX_FUNCTION for LDAPS - - CURLOPT_SSL_CTX_FUNCTION works perfectly for HTTPS and email protocols, but - it has no effect for LDAPS connections. - - https://github.com/curl/curl/issues/4108 - -10.3 Paged searches on LDAP server - - https://github.com/curl/curl/issues/4452 - -10.4 Certificate-Based Authentication - - LDAPS not possible with macOS and Windows with Certificate-Based Authentication - - https://github.com/curl/curl/issues/9641 - -11. SMB - -11.1 File listing support - - Add support for listing the contents of an SMB share. The output should - probably be the same as/similar to FTP. - -11.2 Honor file timestamps - - The timestamp of the transferred file should reflect that of the original - file. - -11.3 Use NTLMv2 - - Currently the SMB authentication uses NTLMv1. - -11.4 Create remote directories - - Support for creating remote directories when uploading a file to a directory - that does not exist on the server, just like --ftp-create-dirs. - - -12. FILE - -12.1 Directory listing on non-POSIX - - Listing the contents of a directory accessed with FILE only works on - platforms with opendir. Support could be added for more systems, like - Windows. - -13. TLS - -13.1 TLS-PSK with OpenSSL - - Transport Layer Security pre-shared key ciphersuites (TLS-PSK) is a set of - cryptographic protocols that provide secure communication based on pre-shared - keys (PSKs). These pre-shared keys are symmetric keys shared in advance among - the communicating parties. - - https://github.com/curl/curl/issues/5081 - -13.2 TLS channel binding - - TLS 1.2 and 1.3 provide the ability to extract some secret data from the TLS - connection and use it in the client request (usually in some sort of - authentication) to ensure that the data sent is bound to the specific TLS - connection and cannot be successfully intercepted by a proxy. This - functionality can be used in a standard authentication mechanism such as - GSS-API or SCRAM, or in custom approaches like custom HTTP Authentication - headers. - - For TLS 1.2, the binding type is usually tls-unique, and for TLS 1.3 it is - tls-exporter. - - https://datatracker.ietf.org/doc/html/rfc5929 - https://datatracker.ietf.org/doc/html/rfc9266 - https://github.com/curl/curl/issues/9226 - -13.3 Defeat TLS fingerprinting - - By changing the order of TLS extensions provided in the TLS handshake, it is - sometimes possible to circumvent TLS fingerprinting by servers. The TLS - extension order is of course not the only way to fingerprint a client. - -13.4 Consider OCSP stapling by default - - Treat a negative response a reason for aborting the connection. Since OCSP - stapling is presumed to get used much less in the future when Let's Encrypt - drops the OCSP support, the benefit of this might however be limited. - - https://github.com/curl/curl/issues/15483 - -13.6 Provide callback for cert verification - - OpenSSL supports a callback for customised verification of the peer - certificate, but this does not seem to be exposed in the libcurl APIs. Could - it be? There is so much that could be done if it were. - -13.7 Less memory massaging with Schannel - - The Schannel backend does a lot of custom memory management we would rather - avoid: the repeated alloc + free in sends and the custom memory + realloc - system for encrypted and decrypted data. That should be avoided and reduced - for 1) efficiency and 2) safety. - -13.8 Support DANE - - DNS-Based Authentication of Named Entities (DANE) is a way to provide SSL - keys and certs over DNS using DNSSEC as an alternative to the CA model. - https://datatracker.ietf.org/doc/html/rfc6698 - - An initial patch was posted by Suresh Krishnaswamy on March 7th 2013 - (https://curl.se/mail/lib-2013-03/0075.html) but it was a too simple - approach. See Daniel's comments: - https://curl.se/mail/lib-2013-03/0103.html . libunbound may be the - correct library to base this development on. - - Björn Stenberg wrote a separate initial take on DANE that was never - completed. - -13.9 TLS record padding - - TLS (1.3) offers optional record padding and OpenSSL provides an API for it. - I could make sense for libcurl to offer this ability to applications to make - traffic patterns harder to figure out by network traffic observers. - - See https://github.com/curl/curl/issues/5398 - -13.10 Support Authority Information Access certificate extension (AIA) - - AIA can provide various things like CRLs but more importantly information - about intermediate CA certificates that can allow validation path to be - fulfilled when the HTTPS server does not itself provide them. - - Since AIA is about downloading certs on demand to complete a TLS handshake, - it is probably a bit tricky to get done right. - - See https://github.com/curl/curl/issues/2793 - -13.11 Some TLS options are not offered for HTTPS proxies - - Some TLS related options to the command line tool and libcurl are only - provided for the server and not for HTTPS proxies. --proxy-tls-max, - --proxy-tlsv1.3, --proxy-curves and a few more. - For more Documentation on this see: - https://curl.se/libcurl/c/tls-options.html - - https://github.com/curl/curl/issues/12286 - -13.13 Make sure we forbid TLS 1.3 post-handshake authentication - - RFC 8740 explains how using HTTP/2 must forbid the use of TLS 1.3 - post-handshake authentication. We should make sure to live up to that. - - See https://github.com/curl/curl/issues/5396 - -13.14 Support the clienthello extension - - Certain stupid networks and middle boxes have a problem with SSL handshake - packets that are within a certain size range because how that sets some bits - that previously (in older TLS version) were not set. The clienthello - extension adds padding to avoid that size range. - - https://datatracker.ietf.org/doc/html/rfc7685 - https://github.com/curl/curl/issues/2299 - -13.16 Share the CA cache - - For TLS backends that supports CA caching, it makes sense to allow the share - object to be used to store the CA cache as well via the share API. Would - allow multiple easy handles to reuse the CA cache and save themselves from a - lot of extra processing overhead. - -13.17 Add missing features to TLS backends - - The feature matrix at https://curl.se/libcurl/c/tls-options.html shows which - features are supported by which TLS backends, and thus also where there are - feature gaps. - -14. Proxy - -14.1 Retry SOCKS handshake on address type not supported - - When curl resolves a hostname, it might get a mix of IPv6 and IPv4 returned. - curl might then use an IPv6 address with a SOCKS5 proxy, which - if it does - not support IPv6 - returns "Address type not supported" and curl exits with - that error. - - Perhaps it is preferred if curl would in this situation instead first retry - the SOCKS handshake again for this case and then use one of the IPv4 - addresses for the target host. - - See https://github.com/curl/curl/issues/17222 - -15. Schannel - -15.1 Extend support for client certificate authentication - - The existing support for the -E/--cert and --key options could be - extended by supplying a custom certificate and key in PEM format, see: - - Getting a Certificate for Schannel - https://learn.microsoft.com/windows/win32/secauthn/getting-a-certificate-for-schannel - -15.2 Extend support for the --ciphers option - - The existing support for the --ciphers option could be extended - by mapping the OpenSSL/GnuTLS cipher suites to the Schannel APIs, see - - Specifying Schannel Ciphers and Cipher Strengths - https://learn.microsoft.com/windows/win32/secauthn/specifying-schannel-ciphers-and-cipher-strengths - -15.4 Add option to allow abrupt server closure - - libcurl with Schannel errors without a known termination point from the server - (such as length of transfer, or SSL "close notify" alert) to prevent against - a truncation attack. Really old servers may neglect to send any termination - point. An option could be added to ignore such abrupt closures. - - https://github.com/curl/curl/issues/4427 - -16. SASL - -16.1 Other authentication mechanisms - - Add support for other authentication mechanisms such as OLP, - GSS-SPNEGO and others. - -16.2 Add QOP support to GSSAPI authentication - - Currently the GSSAPI authentication only supports the default QOP of auth - (Authentication), whilst Kerberos V5 supports both auth-int (Authentication - with integrity protection) and auth-conf (Authentication with integrity and - privacy protection). - - -17. SSH protocols - -17.1 Multiplexing - - SSH is a perfectly fine multiplexed protocols which would allow libcurl to do - multiple parallel transfers from the same host using the same connection, - much in the same spirit as HTTP/2 does. libcurl however does not take - advantage of that ability but does instead always create a new connection for - new transfers even if an existing connection already exists to the host. - - To fix this, libcurl would have to detect an existing connection and "attach" - the new transfer to the existing one. - -17.2 Handle growing SFTP files - - The SFTP code in libcurl checks the file size *before* a transfer starts and - then proceeds to transfer exactly that amount of data. If the remote file - grows while the transfer is in progress libcurl does not notice and does not - adapt. The OpenSSH SFTP command line tool does and libcurl could also just - attempt to download more to see if there is more to get... - - https://github.com/curl/curl/issues/4344 - -17.3 Read keys from ~/.ssh/id_ecdsa, id_ed25519 - - The libssh2 backend in curl is limited to only reading keys from id_rsa and - id_dsa, which makes it fail connecting to servers that use more modern key - types. - - https://github.com/curl/curl/issues/8586 - -17.4 Support CURLOPT_PREQUOTE - - The two other QUOTE options are supported for SFTP, but this was left out for - unknown reasons. - -17.5 SSH over HTTPS proxy with more backends - - The SSH based protocols SFTP and SCP did not work over HTTPS proxy at - all until PR https://github.com/curl/curl/pull/6021 brought the - functionality with the libssh2 backend. Presumably, this support - can/could be added for the other backends as well. - -17.6 SFTP with SCP:// - - OpenSSH 9 switched their 'scp' tool to speak SFTP under the hood. Going - forward it might be worth having curl or libcurl attempt SFTP if SCP fails to - follow suite. - -18. Command line tool - -18.1 sync - - "curl --sync http://example.com/feed[1-100].rss" or - "curl --sync http://example.net/{index,calendar,history}.html" - - Downloads a range or set of URLs using the remote name, but only if the - remote file is newer than the local file. A Last-Modified HTTP date header - should also be used to set the mod date on the downloaded file. - -18.2 glob posts - - Globbing support for -d and -F, as in 'curl -d "name=foo[0-9]" URL'. - This is easily scripted though. - -18.4 --proxycommand - - Allow the user to make curl run a command and use its stdio to make requests - and not do any network connection by itself. Example: - - curl --proxycommand 'ssh pi@raspberrypi.local -W 10.1.1.75 80' \ - http://some/otherwise/unavailable/service.php - - See https://github.com/curl/curl/issues/4941 - -18.5 UTF-8 filenames in Content-Disposition - - RFC 6266 documents how UTF-8 names can be passed to a client in the - Content-Disposition header, and curl does not support this. - - https://github.com/curl/curl/issues/1888 - -18.6 Option to make -Z merge lined based outputs on stdout - - When a user requests multiple lined based files using -Z and sends them to - stdout, curl does not "merge" and send complete lines fine but may send - partial lines from several sources. - - https://github.com/curl/curl/issues/5175 - -18.7 specify which response codes that make -f/--fail return error - - Allows a user to better specify exactly which error code(s) that are fine - and which are errors for their specific uses cases - -18.9 Choose the name of file in braces for complex URLs - - When using braces to download a list of URLs and you use complicated names - in the list of alternatives, it could be handy to allow curl to use other - names when saving. - - Consider a way to offer that. Possibly like - {partURL1:name1,partURL2:name2,partURL3:name3} where the name following the - colon is the output name. - - See https://github.com/curl/curl/issues/221 - -18.10 improve how curl works in a Windows console window - - If you pull the scrollbar when transferring with curl in a Windows console - window, the transfer is interrupted and can get disconnected. This can - probably be improved. See https://github.com/curl/curl/issues/322 - -18.11 Windows: set attribute 'archive' for completed downloads - - The archive bit (FILE_ATTRIBUTE_ARCHIVE, 0x20) separates files that shall be - backed up from those that are either not ready or have not changed. - - Downloads in progress are neither ready to be backed up, nor should they be - opened by a different process. Only after a download has been completed it is - sensible to include it in any integer snapshot or backup of the system. - - See https://github.com/curl/curl/issues/3354 - -18.12 keep running, read instructions from pipe/socket - - Provide an option that makes curl not exit after the last URL (or even work - without a given URL), and then make it read instructions passed on a pipe or - over a socket to make further instructions so that a second subsequent curl - invoke can talk to the still running instance and ask for transfers to get - done, and thus maintain its connection pool, DNS cache and more. - -18.13 Acknowledge Ratelimit headers - - Consider a command line option that can make curl do multiple serial requests - while acknowledging server specified rate limits: - https://datatracker.ietf.org/doc/draft-ietf-httpapi-ratelimit-headers/ - - See https://github.com/curl/curl/issues/5406 - -18.14 --dry-run - - A command line option that makes curl show exactly what it would do and send - if it would run for real. - - See https://github.com/curl/curl/issues/5426 - -18.15 --retry should resume - - When --retry is used and curl actually retries transfer, it should use the - already transferred data and do a resumed transfer for the rest (when - possible) so that it does not have to transfer the same data again that was - already transferred before the retry. - - See https://github.com/curl/curl/issues/1084 - -18.17 consider filename from the redirected URL with -O ? - - When a user gives a URL and uses -O, and curl follows a redirect to a new - URL, the filename is not extracted and used from the newly redirected-to URL - even if the new URL may have a much more sensible filename. - - This is clearly documented and helps for security since there is no surprise - to users which filename that might get overwritten, but maybe a new option - could allow for this or maybe -J should imply such a treatment as well as -J - already allows for the server to decide what filename to use so it already - provides the "may overwrite any file" risk. - - This is extra tricky if the original URL has no filename part at all since - then the current code path does error out with an error message, and we - cannot *know* already at that point if curl is redirected to a URL that has a - filename... - - See https://github.com/curl/curl/issues/1241 - -18.18 retry on network is unreachable - - The --retry option retries transfers on "transient failures". We later added - --retry-connrefused to also retry for "connection refused" errors. - - Suggestions have been brought to also allow retry on "network is unreachable" - errors and while totally reasonable, maybe we should consider a way to make - this more configurable than to add a new option for every new error people - want to retry for? - - https://github.com/curl/curl/issues/1603 - -18.20 hostname sections in config files - - config files would be more powerful if they could set different - configurations depending on used URLs, hostname or possibly origin. Then a - default .curlrc could a specific user-agent only when doing requests against - a certain site. - -18.21 retry on the redirected-to URL - - When curl is told to --retry a failed transfer and follows redirects, it - might get an HTTP 429 response from the redirected-to URL and not the - original one, which then could make curl decide to rather retry the transfer - on that URL only instead of the original operation to the original URL. - - Perhaps extra emphasized if the original transfer is a large POST that - redirects to a separate GET, and that GET is what gets the 529 - - See https://github.com/curl/curl/issues/5462 - -18.23 Set the modification date on an uploaded file - - For SFTP and possibly FTP, curl could offer an option to set the - modification time for the uploaded file. - - See https://github.com/curl/curl/issues/5768 - -18.24 Use multiple parallel transfers for a single download - - To enhance transfer speed, downloading a single URL can be split up into - multiple separate range downloads that get combined into a single final - result. - - An ideal implementation would not use a specified number of parallel - transfers, but curl could: - - First start getting the full file as transfer A - - If after N seconds have passed and the transfer is expected to continue for - M seconds or more, add a new transfer (B) that asks for the second half of - A's content (and stop A at the middle). - - If splitting up the work improves the transfer rate, it could then be done - again. Then again, etc up to a limit. - - This way, if transfer B fails (because Range: is not supported) it lets - transfer A remain the single one. N and M could be set to some sensible - defaults. - - See https://github.com/curl/curl/issues/5774 - -18.25 Prevent terminal injection when writing to terminal - - curl could offer an option to make escape sequence either non-functional or - avoid cursor moves or similar to reduce the risk of a user getting tricked by - clever tricks. - - See https://github.com/curl/curl/issues/6150 - -18.26 Custom progress meter update interval - - Users who are for example doing large downloads in CI or remote setups might - want the occasional progress meter update to see that the transfer is - progressing and has not stuck, but they may not appreciate the - many-times-a-second frequency curl can end up doing it with now. - -18.27 -J and -O with %-encoded filenames - - -J/--remote-header-name does not decode %-encoded filenames. RFC 6266 details - how it should be done. The can of worm is basically that we have no charset - handling in curl and ASCII >=128 is a challenge for us. Not to mention that - decoding also means that we need to check for nastiness that is attempted, - like "../" sequences and the like. Probably everything to the left of any - embedded slashes should be cut off. - https://curl.se/bug/view.cgi?id=1294 - - -O also does not decode %-encoded names, and while it has even less - information about the charset involved the process is similar to the -J case. - - Note that we do not decode -O without the user asking for it with some other - means, since -O has always been documented to use the name exactly as - specified in the URL. - -18.28 -J with -C - - - When using -J (with -O), automatically resumed downloading together with "-C - -" fails. Without -J the same command line works. This happens because the - resume logic is worked out before the target filename (and thus its - pre-transfer size) has been figured out. This can be improved. - - https://curl.se/bug/view.cgi?id=1169 - -18.29 --retry and transfer timeouts - - If using --retry and the transfer timeouts (possibly due to using -m or - -y/-Y) the next attempt does not resume the transfer properly from what was - downloaded in the previous attempt but truncates and restarts at the original - position where it was at before the previous failed attempt. See - https://curl.se/mail/lib-2008-01/0080.html - -19. Build - -19.2 Enable PIE and RELRO by default - - Especially when having programs that execute curl via the command line, PIE - renders the exploitation of memory corruption vulnerabilities a lot more - difficult. This can be attributed to the additional information leaks being - required to conduct a successful attack. RELRO, on the other hand, masks - different binary sections like the GOT as read-only and thus kills a handful - of techniques that come in handy when attackers are able to arbitrarily - overwrite memory. A few tests showed that enabling these features had close - to no impact, neither on the performance nor on the general functionality of - curl. - -19.3 Do not use GNU libtool on OpenBSD - - When compiling curl on OpenBSD with "--enable-debug" it gives linking errors - when you use GNU libtool. This can be fixed by using the libtool provided by - OpenBSD itself. However for this the user always needs to invoke make with - "LIBTOOL=/usr/bin/libtool". It would be nice if the script could have some - magic to detect if this system is an OpenBSD host and then use the OpenBSD - libtool instead. - - See https://github.com/curl/curl/issues/5862 - -19.4 Package curl for Windows in a signed installer - - See https://github.com/curl/curl/issues/5424 - -19.5 make configure use --cache-file more and better - - The configure script can be improved to cache more values so that repeated - invokes run much faster. - - See https://github.com/curl/curl/issues/7753 - -20. Test suite - -20.1 SSL tunnel - - Make our own version of stunnel for simple port forwarding to enable HTTPS - and FTP-SSL tests without the stunnel dependency, and it could allow us to - provide test tools built with either OpenSSL or GnuTLS - -20.2 more protocols supported - - Extend the test suite to include more protocols. The telnet could just do FTP - or http operations (for which we have test servers). - -20.3 more platforms supported - - Make the test suite work on more platforms. OpenBSD and macOS. Remove - fork()s and it should become even more portable. - -20.4 write an SMB test server to replace impacket - - This would allow us to run SMB tests on more platforms and do better and more - covering tests. - - See https://github.com/curl/curl/issues/15697 - -20.5 Use the RFC 6265 test suite - - A test suite made for HTTP cookies (RFC 6265) by Adam Barth is available at - https://github.com/abarth/http-state/tree/master/tests - - It would be good if someone would write a script/setup that would run curl - with that test suite and detect deviances. Ideally, that would even be - incorporated into our regular test suite. - -20.6 Run web-platform-tests URL tests - - Run web-platform-tests URL tests and compare results with browsers on wpt.fyi - - It would help us find issues to fix and help us document where our parser - differs from the WHATWG URL spec parsers. - - See https://github.com/curl/curl/issues/4477 - -21. MQTT - -21.1 Support rate-limiting - - The rate-limiting logic is done in the PERFORMING state in multi.c but MQTT - is not (yet) implemented to use that. - -21.2 Support MQTTS - -21.3 Handle network blocks - - Running test suite with `CURL_DBG_SOCK_WBLOCK=90 ./runtests.pl -a mqtt` makes - several MQTT test cases fail where they should not. - -21.4 large payloads - - libcurl unnecessarily allocates heap memory to hold the entire payload to get - sent, when the data is already perfectly accessible where it is when - `CURLOPT_POSTFIELDS` is used. This is highly inefficient for larger payloads. - Additionally, libcurl does not support using the read callback for sending - MQTT which is yet another way to avoid having to hold large payload in - memory. - -22. TFTP - -22.1 TFTP does not convert LF to CRLF for mode=netascii - - RFC 3617 defines that an TFTP transfer can be done using "netascii" mode. - curl does not support extracting that mode from the URL nor does it treat - such transfers specifically. It should probably do LF to CRLF translations - for them. - - See https://github.com/curl/curl/issues/12655 - -23. Gopher - -23.1 Handle network blocks - - Running test suite with - `CURL_DBG_SOCK_WBLOCK=90 ./runtests.pl -a 1200 to 1300` makes several - Gopher test cases fail where they should not. diff --git a/docs/TODO.md b/docs/TODO.md new file mode 100644 index 000000000000..09b45443c791 --- /dev/null +++ b/docs/TODO.md @@ -0,0 +1,1111 @@ + + +# TODO intro + +Things to do in project curl. Please tell us what you think, contribute and +send us patches that improve things. + +Be aware that these are things that we could do, or have once been considered +things we could do. If you want to work on any of these areas, please consider +bringing it up for discussions first on the mailing list so that we all agree +it is still a good idea for the project. + +All bugs documented in the [known_bugs +document](https://curl.se/docs/knownbugs.html) are subject for fixing. + +# libcurl + +## TCP Fast Open support on Windows + +libcurl supports the `CURLOPT_TCP_FASTOPEN` option since 7.49.0 for Linux and +macOS. Windows supports TCP Fast Open starting with Windows 10, version 1607 +and we should add support for it. + +TCP Fast Open is supported on several platforms but not on Windows. Work on +this was once started but never finished. + +See [curl pull request 3378](https://github.com/curl/curl/pull/3378) + +## Consult `%APPDATA%` also for `.netrc` + +`%APPDATA%\.netrc` is not considered when running on Windows. Should not it? + +See [curl issue 4016](https://github.com/curl/curl/issues/4016) + +## `struct lifreq` + +Use `struct lifreq` and `SIOCGLIFADDR` instead of `struct ifreq` and +`SIOCGIFADDR` on newer Solaris versions as they claim the latter is obsolete. +To support IPv6 interface addresses for network interfaces properly. + +## alt-svc sharing + +The share interface could benefit from allowing the alt-svc cache to be +possible to share between easy handles. + +See [curl issue 4476](https://github.com/curl/curl/issues/4476) + +The share interface offers CURL_LOCK_DATA_CONNECT to have multiple easy +handle share a connection cache, but due to how connections are used they are +still not thread-safe when used shared. + +See [curl issue 4915](https://github.com/curl/curl/issues/4915) and lib1541.c + +The share interface offers CURL_LOCK_DATA_HSTS to have multiple easy handle +share an HSTS cache, but this is not thread-safe. + +## get rid of PATH_MAX + +Having code use and rely on PATH_MAX is not nice: +https://insanecoding.blogspot.com/2007/11/pathmax-simply-isnt.html + +Currently the libssh2 SSH based code uses it, but to remove PATH_MAX from +there we need libssh2 to properly tell us when we pass in a too small buffer +and its current API (as of libssh2 1.2.7) does not. + +## thread-safe sharing + +Using the share interface users can share some data between easy handles but +several of the sharing options are documented as not safe and supported to +share between multiple concurrent threads. Fixing this would enable more users +to share data in more powerful ways. + +## auto-detect proxy + +libcurl could be made to detect the system proxy setup automatically and use +that. On Windows, macOS and Linux desktops for example. + +The [pull-request to use *libproxy*](https://github.com/curl/curl/pull/977) +for this was deferred due to doubts on the reliability of the dependency and +how to use it. + +[*libdetectproxy*](https://github.com/paulharris/libdetectproxy) is a (C++) +library for detecting the proxy on Windows. + +## updated DNS server while running + +If `/etc/resolv.conf` gets updated while a program using libcurl is running, it +is may cause name resolves to fail unless `res_init()` is called. We should +consider calling `res_init()` + retry once unconditionally on all name resolve +failures to mitigate against this. Firefox works like that. Note that Windows +does not have `res_init()` or an alternative. + +[curl issue 2251](https://github.com/curl/curl/issues/2251) + +## c-ares and CURLOPT_OPENSOCKETFUNCTION + +curl creates most sockets via the CURLOPT_OPENSOCKETFUNCTION callback and +close them with the CURLOPT_CLOSESOCKETFUNCTION callback. However, c-ares does +not use those functions and instead opens and closes the sockets itself. This +means that when curl passes the c-ares socket to the CURLMOPT_SOCKETFUNCTION +it is not owned by the application like other sockets. + +See [curl issue 2734](https://github.com/curl/curl/issues/2734) + +## Monitor connections in the connection pool + +libcurl's connection cache or pool holds a number of open connections for the +purpose of possible subsequent connection reuse. It may contain a few up to a +significant amount of connections. Currently, libcurl leaves all connections +as they are and first when a connection is iterated over for matching or reuse +purpose it is verified that it is still alive. + +Those connections may get closed by the server side for idleness or they may +get an HTTP/2 ping from the peer to verify that they are still alive. By +adding monitoring of the connections while in the pool, libcurl can detect +dead connections (and close them) better and earlier, and it can handle HTTP/2 +pings to keep such ones alive even when not actively doing transfers on them. + +## Try to URL encode given URL + +Given a URL that for example contains spaces, libcurl could have an option +that would try somewhat harder than it does now and convert spaces to %20 and +perhaps URL encoded byte values over 128 etc (basically do what the redirect +following code already does). + +[curl issue 514](https://github.com/curl/curl/issues/514) + +## Add support for IRIs + +IRIs (RFC 3987) allow localized, non-ASCII, names in the URL. To properly +support this, curl/libcurl would need to translate/encode the given input +from the input string encoding into percent encoded output "over the wire". + +To make that work smoothly for curl users even on Windows, curl would probably +need to be able to convert from several input encodings. + +## try next proxy if one does not work + +Allow an application to specify a list of proxies to try, and failing to +connect to the first go on and try the next instead until the list is +exhausted. Browsers support this feature at least when they specify proxies +using `PAC`. + +[curl issue 896](https://github.com/curl/curl/issues/896) + +## provide timing info for each redirect + +curl and libcurl provide timing information via a set of different time-stamps +(CURLINFO_*_TIME). When curl is following redirects, those returned time value +are the accumulated sums. An improvement could be to offer separate timings +for each redirect. + +[curl issue 6743](https://github.com/curl/curl/issues/6743) + +## `SRV` and `URI` DNS records + +Offer support for resolving `SRV` and `URI` DNS records for libcurl to know which +server to connect to for various protocols (including HTTP). + +## CURLINFO_PAUSE_STATE + +Return information about the transfer's current pause state, in both +directions. See [curl issue 2588](https://github.com/curl/curl/issues/2588) + +## Expose tried IP addresses that failed + +When libcurl fails to connect to a host, it could offer the application the +addresses that were used in the attempt. Source + destination IP, source + +destination port and protocol (UDP or TCP) for each failure. Possibly as a +callback. Perhaps also provide reason. + +[curl issue 2126](https://github.com/curl/curl/issues/2126) + +## config file parsing + +Consider providing an API, possibly in a separate companion library, for +parsing a config file like curl's `-K`/`--config` option to allow applications +to get the same ability to read curl options from files. + +See [curl issue 3698](https://github.com/curl/curl/issues/3698) + +## erase secrets from heap/stack after use + +Introducing a concept and system to erase secrets from memory after use, it +could help mitigate and lessen the impact of (future) security problems etc. +However: most secrets are passed to libcurl as clear text from the application +and then clearing them within the library adds nothing... + +[curl issue 7268](https://github.com/curl/curl/issues/7268) + +## add asynch getaddrinfo support + +Use `getaddrinfo_a()` to provide an asynch name resolver backend to libcurl +that does not use threads and does not depend on c-ares. The `getaddrinfo_a` +function is (probably?) glibc specific but that is a widely used libc among +our users. + +[curl pull request 6746](https://github.com/curl/curl/pull/6746) + +## make DoH inherit more transfer properties + +Some options are not inherited because they are not relevant for the DoH SSL +connections, or inheriting the option may result in unexpected behavior. For +example the user's debug function callback is not inherited because it would +be unexpected for internal handles (i.e DoH handles) to be passed to that +callback. + +If an option is not inherited then it is not possible to set it separately +for DoH without a DoH-specific option. For example: +`CURLOPT_DOH_SSL_VERIFYHOST`, `CURLOPT_DOH_SSL_VERIFYPEER` and +`CURLOPT_DOH_SSL_VERIFYSTATUS`. + +See [curl issue 6605](https://github.com/curl/curl/issues/6605) + +# libcurl - multi interface + +## More non-blocking + +Make sure we do not ever loop because of non-blocking sockets returning +`EWOULDBLOCK` or similar. Blocking cases include: + +- Name resolves on non-Windows unless c-ares or the threaded resolver is used. +- The threaded resolver may block on cleanup: + [curl issue 4852](https://github.com/curl/curl/issues/4852) +- `file://` transfers +- TELNET transfers +- GSSAPI authentication for FTP transfers +- The "DONE" operation (post transfer protocol-specific actions) for the +protocols SFTP, SMTP, FTP. Fixing `multi_done()` for this is a worthy task. +- `curl_multi_remove_handle()` for any of the above. +- Calling `curl_ws_send()` from a callback + +## Better support for same name resolves + +If a name resolve has been initiated for a given name and a second easy handle +wants to resolve that same name as well, make it wait for the first resolve to +end up in the cache instead of doing a second separate resolve. This is +especially needed when adding many simultaneous handles using the same +hostname when the DNS resolver can get flooded. + +## Non-blocking `curl_multi_remove_handle()` + +The multi interface has a few API calls that assume a blocking behavior, like +`add_handle()` and `remove_handle()` which limits what we can do internally. +The multi API need to be moved even more into a single function that "drives" +everything in a non-blocking manner and signals when something is done. A +remove or add would then only ask for the action to get started and then +`multi_perform()` etc still be called until the add/remove is completed. + +## Split connect and authentication process + +The multi interface treats the authentication process as part of the connect +phase. As such any failures during authentication does not trigger the +relevant QUIT or LOGOFF for protocols such as IMAP, POP3 and SMTP. + +## Edge-triggered sockets should work + +The multi_socket API should work with edge-triggered socket events. One of the +internal actions that need to be improved for this to work perfectly is the +`maxloops` handling in `transfer.c:readwrite_data()`. + +## multi upkeep + +In libcurl 7.62.0 we introduced `curl_easy_upkeep`. It unfortunately only +works on easy handles. We should introduces a version of that for the multi +handle, and also consider doing `upkeep` automatically on connections in the +connection pool when the multi handle is in used. + +See [curl issue 3199](https://github.com/curl/curl/issues/3199) + +## Virtual external sockets + +libcurl performs operations on the given file descriptor that presumes it is a +socket and an application cannot replace them at the moment. Allowing an +application to fully replace those would allow a larger degree of freedom and +flexibility. + +See [curl issue 5835](https://github.com/curl/curl/issues/5835) + +## dynamically decide to use socketpair + +For users who do not use `curl_multi_wait()` or do not care for +`curl_multi_wakeup()`, we could introduce a way to make libcurl NOT create a +socketpair in the multi handle. + +See [curl issue 4829](https://github.com/curl/curl/issues/4829) + +# Documentation + +## Improve documentation about fork safety + +See [curl issue 6968](https://github.com/curl/curl/issues/6968) + +# FTP + +## HOST + +HOST is a command for a client to tell which hostname to use, to offer FTP +servers named-based virtual hosting: + +https://datatracker.ietf.org/doc/html/rfc7151 + +## A fixed directory listing format + +Since listing the contents of a remove directory with FTP is returning the +list in a format and style the server likes without any established or even +defacto standard existing, it would be a feature to users if curl could parse +the directory listing and output a general curl format that is fixed and the +same, independent of the server's choice. This would allow users to better and +more reliably extract information about remote content via FTP directory +listings. + +## GSSAPI via Windows SSPI + +In addition to currently supporting the SASL GSSAPI mechanism (Kerberos V5) +via third-party GSS-API libraries, such as MIT Kerberos, also add support for +GSSAPI authentication via Windows SSPI. + +## STAT for LIST without data connection + +Some FTP servers allow STAT for listing directories instead of using LIST, and +the response is then sent over the control connection instead of as the +otherwise used data connection. + +This is not detailed in any FTP specification. + +## Passive transfer could try other IP addresses + +When doing FTP operations through a proxy at localhost, the reported spotted +that curl only tried to connect once to the proxy, while it had multiple +addresses and a failed connect on one address should make it try the next. + +After switching to passive mode (EPSV), curl could try all IP addresses for +`localhost`. Currently it tries `::1`, but it should also try `127.0.0.1`. + +See [curl issue 1508](https://github.com/curl/curl/issues/1508) + +# HTTP + +## Provide the error body from a CONNECT response + +When curl receives a body response from a CONNECT request to a proxy, it +always just reads and ignores it. It would make some users happy if curl +instead optionally would be able to make that responsible available. Via a new +callback? Through some other means? + +See [curl issue 9513](https://github.com/curl/curl/issues/9513) + +## Obey `Retry-After` in redirects + +The `Retry-After` response header is said to dictate "the minimum time that +the user agent is asked to wait before issuing the redirected request" and +libcurl does not obey this. + +See [curl issue 11447](https://github.com/curl/curl/issues/11447) + +## Rearrange request header order + +Server implementers often make an effort to detect browser and to reject +clients it can detect to not match. One of the last details we cannot yet +control in libcurl's HTTP requests, which also can be exploited to detect that +libcurl is in fact used even when it tries to impersonate a browser, is the +order of the request headers. I propose that we introduce a new option in +which you give headers a value, and then when the HTTP request is built it +sorts the headers based on that number. We could then have internally created +headers use a default value so only headers that need to be moved have to be +specified. + +## Allow SAN names in HTTP/2 server push + +curl only allows HTTP/2 push promise if the provided :authority header value +exactly matches the hostname given in the URL. It could be extended to allow +any name that would match the Subject Alternative Names in the server's TLS +certificate. + +See [curl pull request 3581](https://github.com/curl/curl/pull/3581) + +## `auth=` in URLs + +Add the ability to specify the preferred authentication mechanism to use by +using `;auth=` in the login part of the URL. + +For example: + +`http://test:pass;auth=NTLM@example.com` would be equivalent to specifying +`--user test:pass;auth=NTLM` or `--user test:pass --ntlm` from the command +line. + +Additionally this should be implemented for proxy base URLs as well. + +## alt-svc should fallback if alt-svc does not work + +The `alt-svc:` header provides a set of alternative services for curl to use +instead of the original. If the first attempted one fails, it should try the +next etc and if all alternatives fail go back to the original. + +See [curl issue 4908](https://github.com/curl/curl/issues/4908) + +## Require HTTP version X or higher + +curl and libcurl provide options for trying higher HTTP versions (for example +HTTP/2) but then still allows the server to pick version 1.1. We could +consider adding a way to require a minimum version. + +See [curl issue 7980](https://github.com/curl/curl/issues/7980) + +# TELNET + +## ditch stdin + +Reading input (to send to the remote server) on stdin is a crappy solution for +library purposes. We need to invent a good way for the application to be able +to provide the data to send. + +## ditch telnet-specific select + +Move the telnet support's network `select()` loop go away and merge the code +into the main transfer loop. Until this is done, the multi interface does not +work for telnet. + +## feature negotiation debug data + +Add telnet feature negotiation data to the debug callback as header data. + +## exit immediately upon connection if stdin is /dev/null + +If it did, curl could be used to probe if there is an server there listening +on a specific port. That is, the following command would exit immediately +after the connection is established with exit code 0: + + curl -s --connect-timeout 2 telnet://example.com:80 NOTIFY=SUCCESS,FAILURE");`. + +[curl issue 8232](https://github.com/curl/curl/issues/8232) + +## Enhanced capability support + +Add the ability, for an application that uses libcurl, to obtain the list of +capabilities returned from the EHLO command. + +## Add `CURLOPT_MAIL_CLIENT` option + +Rather than use the URL to specify the mail client string to present in the +`HELO` and `EHLO` commands, libcurl should support a new `CURLOPT` +specifically for specifying this data as the URL is non-standard and to be +honest a bit of a hack. + +Please see the following thread for more information: +https://curl.se/mail/lib-2012-05/0178.html + + +# POP3 + +## Enhanced capability support + +Add the ability, for an application that uses libcurl, to obtain the list of +capabilities returned from the CAPA command. + +# IMAP + +## Enhanced capability support + + Add the ability, for an application that uses libcurl, to obtain the list of + capabilities returned from the CAPABILITY command. + +# LDAP + +## SASL based authentication mechanisms + +Currently the LDAP module only supports ldap_simple_bind_s() in order to bind +to an LDAP server. However, this function sends username and password details +using the simple authentication mechanism (as clear text). However, it should +be possible to use ldap_bind_s() instead specifying the security context +information ourselves. + +## `CURLOPT_SSL_CTX_FUNCTION` for LDAPS + +`CURLOPT_SSL_CTX_FUNCTION` works perfectly for HTTPS and email protocols, but +it has no effect for LDAPS connections. + + [curl issue 4108](https://github.com/curl/curl/issues/4108) + +## Paged searches on LDAP server + +[curl issue 4452](https://github.com/curl/curl/issues/4452) + +## Certificate-Based Authentication + +LDAPS not possible with macOS and Windows with Certificate-Based Authentication + +[curl issue 9641](https://github.com/curl/curl/issues/9641) + +# SMB + +## Support modern versions + +curl only supports version 1, which barely anyone is using anymore. + +## File listing support + +Add support for listing the contents of an SMB share. The output should +probably be the same as/similar to FTP. + +## Honor file timestamps + +The timestamp of the transferred file should reflect that of the original +file. + +## Use NTLMv2 + +Currently the SMB authentication uses NTLMv1. + +## Create remote directories + +Support for creating remote directories when uploading a file to a directory +that does not exist on the server, just like `--ftp-create-dirs`. + +# FILE + +## Directory listing on non-POSIX + +Listing the contents of a directory accessed with FILE only works on platforms +with `opendir()`. Support could be added for more systems, like Windows. + +# TLS + +## `TLS-PSK` with OpenSSL + +Transport Layer Security pre-shared key cipher suites (`TLS-PSK`) is a set of +cryptographic protocols that provide secure communication based on pre-shared +keys (`PSK`). These pre-shared keys are symmetric keys shared in advance among +the communicating parties. + +[curl issue 5081](https://github.com/curl/curl/issues/5081) + +## TLS channel binding + +TLS 1.2 and 1.3 provide the ability to extract some secret data from the TLS +connection and use it in the client request (usually in some sort of +authentication) to ensure that the data sent is bound to the specific TLS +connection and cannot be successfully intercepted by a proxy. This +functionality can be used in a standard authentication mechanism such as +GSS-API or SCRAM, or in custom approaches like custom HTTP Authentication +headers. + +For TLS 1.2, the binding type is usually `tls-unique`, and for TLS 1.3 it is +`tls-exporter`. + +- https://datatracker.ietf.org/doc/html/rfc5929 +- https://datatracker.ietf.org/doc/html/rfc9266 +- [curl issue 9226](https://github.com/curl/curl/issues/9226) + +## Defeat TLS fingerprinting + +By changing the order of TLS extensions provided in the TLS handshake, it is +sometimes possible to circumvent TLS fingerprinting by servers. The TLS +extension order is of course not the only way to fingerprint a client. + +## Consider OCSP stapling by default + +Treat a negative response a reason for aborting the connection. Since OCSP +stapling is presumed to get used much less in the future when Let's Encrypt +drops the OCSP support, the benefit of this might however be limited. + +[curl issue 15483](https://github.com/curl/curl/issues/15483) + +## Provide callback for cert verification + +OpenSSL supports a callback for customized verification of the peer +certificate, but this does not seem to be exposed in the libcurl APIs. Could +it be? There is so much that could be done if it were. + +## Less memory massaging with Schannel + +The Schannel backend does a lot of custom memory management we would rather +avoid: the repeated allocation + free in sends and the custom memory + realloc +system for encrypted and decrypted data. That should be avoided and reduced +for 1) efficiency and 2) safety. + +## Support DANE + +[DNS-Based Authentication of Named Entities +(DANE)](https://www.rfc-editor.org/rfc/rfc6698.txt) is a way to provide SSL +keys and certs over DNS using DNSSEC as an alternative to the CA model. + +A patch was posted on March 7 2013 +(https://curl.se/mail/lib-2013-03/0075.html) but it was a too simple approach. +See Daniel's comments: https://curl.se/mail/lib-2013-03/0103.html + +Björn Stenberg once wrote a separate initial take on DANE that was never +completed. + +## TLS record padding + +TLS (1.3) offers optional record padding and OpenSSL provides an API for it. I +could make sense for libcurl to offer this ability to applications to make +traffic patterns harder to figure out by network traffic observers. + +See [curl issue 5398](https://github.com/curl/curl/issues/5398) + +## Support Authority Information Access certificate extension (AIA) + +AIA can provide various things like certificate revocation lists but more +importantly information about intermediate CA certificates that can allow +validation path to be fulfilled when the HTTPS server does not itself provide +them. + +Since AIA is about downloading certs on demand to complete a TLS handshake, it +is probably a bit tricky to get done right and a serious privacy leak. + +See [curl issue 2793](https://github.com/curl/curl/issues/2793) + +## Some TLS options are not offered for HTTPS proxies + +Some TLS related options to the command line tool and libcurl are only +provided for the server and not for HTTPS proxies. `--proxy-tls-max`, +`--proxy-tlsv1.3`, `--proxy-curves` and a few more. For more Documentation on +this see: https://curl.se/libcurl/c/tls-options.html + +[curl issue 12286](https://github.com/curl/curl/issues/12286) + +## Make sure we forbid TLS 1.3 post-handshake authentication + +RFC 8740 explains how using HTTP/2 must forbid the use of TLS 1.3 +post-handshake authentication. We should make sure to live up to that. + +See [curl issue 5396](https://github.com/curl/curl/issues/5396) + +## Support the `clienthello` extension + +Certain stupid networks and middle boxes have a problem with SSL handshake +packets that are within a certain size range because how that sets some bits +that previously (in older TLS version) were not set. The `clienthello` +extension adds padding to avoid that size range. + +- https://datatracker.ietf.org/doc/html/rfc7685 +- [curl issue 2299](https://github.com/curl/curl/issues/2299) + +## Share the CA cache + +For TLS backends that supports CA caching, it makes sense to allow the share +object to be used to store the CA cache as well via the share API. Would allow +multiple easy handles to reuse the CA cache and save themselves from a lot of +extra processing overhead. + +## Add missing features to TLS backends + +The feature matrix at https://curl.se/libcurl/c/tls-options.html shows which +features are supported by which TLS backends, and thus also where there are +feature gaps. + +# Proxy + +## Retry SOCKS handshake on address type not supported + +When curl resolves a hostname, it might get a mix of IPv6 and IPv4 returned. +curl might then use an IPv6 address with a SOCKS5 proxy, which - if it does +not support IPv6 - returns "Address type not supported" and curl exits with +that error. + +Perhaps it is preferred if curl would in this situation instead first retry +the SOCKS handshake again for this case and then use one of the IPv4 addresses +for the target host. + +See [curl issue 17222](https://github.com/curl/curl/issues/17222) + +# Schannel + +## Extend support for client certificate authentication + +The existing support for the `-E`/`--cert` and `--key` options could be +extended by supplying a custom certificate and key in PEM format, see: +[Getting a Certificate for +Schannel](https://learn.microsoft.com/windows/win32/secauthn/getting-a-certificate-for-schannel) + +## Extend support for the `--ciphers` option + +The existing support for the `--ciphers` option could be extended by mapping +the OpenSSL/GnuTLS cipher suites to the Schannel APIs, see [Specifying +Schannel Ciphers and Cipher +Strengths](https://learn.microsoft.com/windows/win32/secauthn/specifying-schannel-ciphers-and-cipher-strengths). + +## Add option to allow abrupt server closure + +libcurl with Schannel errors without a known termination point from the server +(such as length of transfer, or SSL "close notify" alert) to prevent against a +truncation attack. Really old servers may neglect to send any termination +point. An option could be added to ignore such abrupt closures. + +[curl issue 4427](https://github.com/curl/curl/issues/4427) + +# SASL + +## Other authentication mechanisms + +Add support for other authentication mechanisms such as `OLP`, `GSS-SPNEGO` +and others. + +## Add `QOP` support to GSSAPI authentication + +Currently the GSSAPI authentication only supports the default `QOP` of auth +(Authentication), whilst Kerberos V5 supports both `auth-int` (Authentication +with integrity protection) and `auth-conf` (Authentication with integrity and +privacy protection). + +# SSH protocols + +## Multiplexing + +SSH is a perfectly fine multiplexed protocols which would allow libcurl to do +multiple parallel transfers from the same host using the same connection, much +in the same spirit as HTTP/2 does. libcurl however does not take advantage of +that ability but does instead always create a new connection for new transfers +even if an existing connection already exists to the host. + +To fix this, libcurl would have to detect an existing connection and "attach" +the new transfer to the existing one. + +## Handle growing SFTP files + +The SFTP code in libcurl checks the file size *before* a transfer starts and +then proceeds to transfer exactly that amount of data. If the remote file +grows while the transfer is in progress libcurl does not notice and does not +adapt. The OpenSSH SFTP command line tool does and libcurl could also just +attempt to download more to see if there is more to get... + +[curl issue 4344](https://github.com/curl/curl/issues/4344) + +## Read keys from `~/.ssh/id_ecdsa`, `id_ed25519` + +The libssh2 backend in curl is limited to only reading keys from `id_rsa` and +`id_dsa`, which makes it fail connecting to servers that use more modern key +types. + +[curl issue 8586](https://github.com/curl/curl/issues/8586) + +## Support `CURLOPT_PREQUOTE` + +The two other `QUOTE` options are supported for SFTP, but this was left out +for unknown reasons. + +## SSH over HTTPS proxy for libssh + +The SSH based protocols SFTP and SCP did not work over HTTPS proxy at all +until [curl pull request 6021](https://github.com/curl/curl/pull/6021) brought +the functionality with the libssh2 backend. Presumably, this support can/could +be added for the libssh backend as well. + +## SFTP with `SCP://` + +OpenSSH 9 switched their `scp` tool to speak SFTP under the hood. Going +forward it might be worth having curl or libcurl attempt SFTP if SCP fails to +follow suite. + +# Command line tool + +## sync + +`curl --sync http://example.com/feed[1-100].rss` or +`curl --sync http://example.net/{index,calendar,history}.html` + +Downloads a range or set of URLs using the remote name, but only if the remote +file is newer than the local file. A `Last-Modified` HTTP date header should +also be used to set the mod date on the downloaded file. + +## glob posts + +Globbing support for `-d` and `-F`, as in `curl -d "name=foo[0-9]" URL`. This +is easily scripted though. + +## `--proxycommand` + +Allow the user to make curl run a command and use its stdio to make requests +and not do any network connection by itself. Example: + + curl --proxycommand 'ssh pi@raspberrypi.local -W 10.1.1.75 80' \ + http://some/otherwise/unavailable/service.php + +See [curl issue 4941](https://github.com/curl/curl/issues/4941) + +## UTF-8 filenames in Content-Disposition + +RFC 6266 documents how UTF-8 names can be passed to a client in the +`Content-Disposition` header, and curl does not support this. + +[curl issue 1888](https://github.com/curl/curl/issues/1888) + +## Option to make `-Z` merge lined based outputs on stdout + +When a user requests multiple lined based files using `-Z` and sends them to +stdout, curl does not *merge* and send complete lines fine but may send +partial lines from several sources. + +[curl issue 5175](https://github.com/curl/curl/issues/5175) + +## specify which response codes that make `-f`/`--fail` return error + +Allows a user to better specify exactly which error code(s) that are fine and +which are errors for their specific uses cases + +## Choose the name of file in braces for complex URLs + +When using braces to download a list of URLs and you use complicated names +in the list of alternatives, it could be handy to allow curl to use other +names when saving. + +Consider a way to offer that. Possibly like +`{partURL1:name1,partURL2:name2,partURL3:name3}` where the name following the +colon is the output name. + +See [curl issue 221](https://github.com/curl/curl/issues/221) + +## improve how curl works in a Windows console window + +If you pull the scroll bar when transferring with curl in a Windows console +window, the transfer is interrupted and can get disconnected. This can +probably be improved. See [curl issue 322](https://github.com/curl/curl/issues/322) + +## Windows: set attribute 'archive' for completed downloads + +The archive bit (`FILE_ATTRIBUTE_ARCHIVE, 0x20`) separates files that shall be +backed up from those that are either not ready or have not changed. + +Downloads in progress are neither ready to be backed up, nor should they be +opened by a different process. Only after a download has been completed it is +sensible to include it in any integer snapshot or backup of the system. + +See [curl issue 3354](https://github.com/curl/curl/issues/3354) + +## keep running, read instructions from pipe/socket + +Provide an option that makes curl not exit after the last URL (or even work +without a given URL), and then make it read instructions passed on a pipe or +over a socket to make further instructions so that a second subsequent curl +invoke can talk to the still running instance and ask for transfers to get +done, and thus maintain its connection pool, DNS cache and more. + +## Acknowledge `Ratelimit` headers + +Consider a command line option that can make curl do multiple serial requests +while acknowledging server specified [rate +limits](https://datatracker.ietf.org/doc/draft-ietf-httpapi-ratelimit-headers/). + +See [curl issue 5406](https://github.com/curl/curl/issues/5406) + +## `--dry-run` + +A command line option that makes curl show exactly what it would do and send +if it would run for real. + +See [curl issue 5426](https://github.com/curl/curl/issues/5426) + +## `--retry` should resume + +When `--retry` is used and curl actually retries transfer, it should use the +already transferred data and do a resumed transfer for the rest (when +possible) so that it does not have to transfer the same data again that was +already transferred before the retry. + +See [curl issue 1084](https://github.com/curl/curl/issues/1084) + +## consider filename from the redirected URL with `-O` ? + +When a user gives a URL and uses `-O`, and curl follows a redirect to a new +URL, the filename is not extracted and used from the newly redirected-to URL +even if the new URL may have a much more sensible filename. + +This is clearly documented and helps for security since there is no surprise +to users which filename that might get overwritten, but maybe a new option +could allow for this or maybe `-J` should imply such a treatment as well as +`-J` already allows for the server to decide what filename to use so it +already provides the "may overwrite any file" risk. + +This is extra tricky if the original URL has no filename part at all since +then the current code path does error out with an error message, and we cannot +*know* already at that point if curl is redirected to a URL that has a +filename... + +See [curl issue 1241](https://github.com/curl/curl/issues/1241) + +## retry on network is unreachable + +The `--retry` option retries transfers on *transient failures*. We later added +`--retry-connrefused` to also retry for *connection refused* errors. + +Suggestions have been brought to also allow retry on *network is unreachable* +errors and while totally reasonable, maybe we should consider a way to make +this more configurable than to add a new option for every new error people +want to retry for? + +[curl issue 1603](https://github.com/curl/curl/issues/1603) + +## hostname sections in config files + +config files would be more powerful if they could set different configurations +depending on used URLs, hostname or possibly origin. Then a default `.curlrc` +could a specific user-agent only when doing requests against a certain site. + +## retry on the redirected-to URL + +When curl is told to `--retry` a failed transfer and follows redirects, it +might get an HTTP 429 response from the redirected-to URL and not the original +one, which then could make curl decide to rather retry the transfer on that +URL only instead of the original operation to the original URL. + +Perhaps extra emphasized if the original transfer is a large POST that +redirects to a separate GET, and that GET is what gets the 529 + +See [curl issue 5462](https://github.com/curl/curl/issues/5462) + +## Set the modification date on an uploaded file + +For SFTP and possibly FTP, curl could offer an option to set the modification +time for the uploaded file. + +See [curl issue 5768](https://github.com/curl/curl/issues/5768) + +## Use multiple parallel transfers for a single download + +To enhance transfer speed, downloading a single URL can be split up into +multiple separate range downloads that get combined into a single final +result. + +An ideal implementation would not use a specified number of parallel +transfers, but curl could: +- First start getting the full file as transfer A +- If after N seconds have passed and the transfer is expected to continue for + M seconds or more, add a new transfer (B) that asks for the second half of + A's content (and stop A at the middle). +- If splitting up the work improves the transfer rate, it could then be done + again. Then again, etc up to a limit. + +This way, if transfer B fails (because Range: is not supported) it lets +transfer A remain the single one. N and M could be set to some sensible +defaults. + +See [curl issue 5774](https://github.com/curl/curl/issues/5774) + +## Prevent terminal injection when writing to terminal + +curl could offer an option to make escape sequence either non-functional or +avoid cursor moves or similar to reduce the risk of a user getting tricked by +clever tricks. + +See [curl issue 6150](https://github.com/curl/curl/issues/6150) + +## `-J` and `-O` with %-encoded filenames + +`-J`/`--remote-header-name` does not decode %-encoded filenames. RFC 6266 +details how it should be done. The can of worm is basically that we have no +charset handling in curl and ASCII >=128 is a challenge for us. Not to mention +that decoding also means that we need to check for nastiness that is +attempted, like `../` sequences and the like. Probably everything to the left +of any embedded slashes should be cut off. See +https://curl.se/bug/view.cgi?id=1294 + +`-O` also does not decode %-encoded names, and while it has even less +information about the charset involved the process is similar to the `-J` +case. + +Note that we do not decode `-O` without the user asking for it with some other +means, since `-O` has always been documented to use the name exactly as +specified in the URL. + +## `-J` with `-C -` + +When using `-J` (with `-O`), automatically resumed downloading together with +`-C -` fails. Without `-J` the same command line works. This happens because +the resume logic is worked out before the target filename (and thus its +pre-transfer size) has been figured out. This can be improved. + +https://curl.se/bug/view.cgi?id=1169 + +## `--retry` and transfer timeouts + +If using `--retry` and the transfer timeouts (possibly due to using -m or +`-y`/`-Y`) the next attempt does not resume the transfer properly from what +was downloaded in the previous attempt but truncates and restarts at the +original position where it was at before the previous failed attempt. See +https://curl.se/mail/lib-2008-01/0080.html + +# Build + +## Enable `PIE` and `RELRO` by default + +Especially when having programs that execute curl via the command line, `PIE` +renders the exploitation of memory corruption vulnerabilities a lot more +difficult. This can be attributed to the additional information leaks being +required to conduct a successful attack. `RELRO`, on the other hand, masks +different binary sections like the `GOT` as read-only and thus kills a handful +of techniques that come in handy when attackers are able to arbitrarily +overwrite memory. A few tests showed that enabling these features had close to +no impact, neither on the performance nor on the general functionality of +curl. + +## Do not use GNU libtool on OpenBSD + +When compiling curl on OpenBSD with `--enable-debug` it gives linking errors +when you use GNU libtool. This can be fixed by using the libtool provided by +OpenBSD itself. However for this the user always needs to invoke make with +`LIBTOOL=/usr/bin/libtool`. It would be nice if the script could have some +magic to detect if this system is an OpenBSD host and then use the OpenBSD +libtool instead. + +See [curl issue 5862](https://github.com/curl/curl/issues/5862) + +## Package curl for Windows in a signed installer + +See [curl issue 5424](https://github.com/curl/curl/issues/5424) + +## make configure use `--cache-file` more and better + +The configure script can be improved to cache more values so that repeated +invokes run much faster. + +See [curl issue 7753](https://github.com/curl/curl/issues/7753) + +# Test suite + +## SSL tunnel + +Make our own version of stunnel for simple port forwarding to enable HTTPS and +FTP-SSL tests without the stunnel dependency, and it could allow us to provide +test tools built with either OpenSSL or GnuTLS + +## more protocols supported + +Extend the test suite to include more protocols. The telnet could just do FTP +or http operations (for which we have test servers). + +## more platforms supported + +Make the test suite work on more platforms. OpenBSD and macOS. Remove fork()s +and it should become even more portable. + +## write an SMB test server to replace impacket + +This would allow us to run SMB tests on more platforms and do better and more +covering tests. + +See [curl issue 15697](https://github.com/curl/curl/issues/15697) + +## Use the RFC 6265 test suite + +A test suite made for HTTP cookies (RFC 6265) by Adam Barth [is +available](https://github.com/abarth/http-state/tree/master/tests). + +It would be good if someone would write a script/setup that would run curl +with that test suite and detect deviance. Ideally, that would even be +incorporated into our regular test suite. + +## Run web-platform-tests URL tests + +Run web-platform-tests URL tests and compare results with browsers on +`wpt.fyi`. + +It would help us find issues to fix and help us document where our parser +differs from the WHATWG URL spec parsers. + +See [curl issue 4477](https://github.com/curl/curl/issues/4477) + +# MQTT + +## Support rate-limiting + +The rate-limiting logic is done in the PERFORMING state in multi.c but MQTT is +not (yet) implemented to use that. + +## Support MQTTS + +## Handle network blocks + +Running test suite with `CURL_DBG_SOCK_WBLOCK=90 ./runtests.pl -a mqtt` makes +several MQTT test cases fail where they should not. + +## large payloads + +libcurl unnecessarily allocates heap memory to hold the entire payload to get +sent, when the data is already perfectly accessible where it is when +`CURLOPT_POSTFIELDS` is used. This is highly inefficient for larger payloads. +Additionally, libcurl does not support using the read callback for sending +MQTT which is yet another way to avoid having to hold large payload in memory. + +# TFTP + +## TFTP does not convert LF to CRLF for `mode=netascii` + +RFC 3617 defines that an TFTP transfer can be done using `netascii` mode. curl +does not support extracting that mode from the URL nor does it treat such +transfers specifically. It should probably do LF to CRLF translations for +them. + +See [curl issue 12655](https://github.com/curl/curl/issues/12655) + +# Gopher + +## Handle network blocks + +Running test suite with `CURL_DBG_SOCK_WBLOCK=90 ./runtests.pl -a 1200 to +1300` makes several Gopher test cases fail where they should not. diff --git a/packages/OS400/makefile.sh b/packages/OS400/makefile.sh index df47a7441e50..2b688a4421d4 100755 --- a/packages/OS400/makefile.sh +++ b/packages/OS400/makefile.sh @@ -67,7 +67,7 @@ fi # Copy some documentation files if needed. for TEXT in "${TOPDIR}/COPYING" "${SCRIPTDIR}/README.OS400" \ - "${TOPDIR}/CHANGES.md" "${TOPDIR}/docs/THANKS" "${TOPDIR}/docs/FAQ" \ + "${TOPDIR}/CHANGES.md" "${TOPDIR}/docs/THANKS" "${TOPDIR}/docs/FAQ.md" \ "${TOPDIR}/docs/FEATURES" "${TOPDIR}/docs/SSLCERTS.md" \ "${TOPDIR}/docs/RESOURCES" "${TOPDIR}/docs/VERSIONS.md" \ "${TOPDIR}/docs/HISTORY.md" diff --git a/scripts/mdlinkcheck b/scripts/mdlinkcheck index dfeeac0f60e6..bce3ca3fd56c 100755 --- a/scripts/mdlinkcheck +++ b/scripts/mdlinkcheck @@ -87,7 +87,7 @@ my %url; my %flink; # list all .md files in the repo -my @files=`git ls-files '**.md' docs/TODO docs/KNOWN_BUGS docs/FAQ`; +my @files=`git ls-files '**.md'`; sub storelink { my ($f, $line, $link) = @_; From 4fb609f9633d199f84ac255e8efd5ef2858e6185 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 9 Dec 2025 11:13:31 +0100 Subject: [PATCH 245/415] FAQ: fix minor link syntax mistake --- docs/FAQ.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/FAQ.md b/docs/FAQ.md index ffef644418b2..f6911990d94b 100644 --- a/docs/FAQ.md +++ b/docs/FAQ.md @@ -1167,7 +1167,7 @@ IP address but instead the address of the proxy. Also note that on many networks NATs or other IP-munging techniques are used that makes you see and use a different IP address locally than what the remote server will see you coming from. You may also consider using -[Tor]()https://www.torproject.org/). +[Tor](https://www.torproject.org/). ## How do I stop an ongoing transfer? From 761750b9dea1873ec2dac3d2352062057feb3f8b Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 9 Dec 2025 04:48:05 +0000 Subject: [PATCH 246/415] Dockerfile: update debian:bookworm-slim digest to 1371f81 Closes #19883 --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 3d2e942cdff4..36daff397b10 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,7 +24,7 @@ # $ ./scripts/maketgz 8.7.1 # To update, get the latest digest e.g. from https://hub.docker.com/_/debian/tags -FROM debian:bookworm-slim@sha256:936abff852736f951dab72d91a1b6337cf04217b2a77a5eaadc7c0f2f1ec1758 +FROM debian:bookworm-slim@sha256:1371f816c47921a144436ca5a420122a30de85f95401752fd464d9d4e1e08271 RUN apt-get update -qq && apt-get install -qq -y --no-install-recommends \ build-essential make autoconf automake libtool git perl zip zlib1g-dev gawk && \ From 4fe629c12a446a2e7b9090e7cfbaaf3be47c68d3 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 9 Dec 2025 11:03:54 +0000 Subject: [PATCH 247/415] Dockerfile: update debian:bookworm-slim digest to e899040 Closes #19891 --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 36daff397b10..e5f2b4073af0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,7 +24,7 @@ # $ ./scripts/maketgz 8.7.1 # To update, get the latest digest e.g. from https://hub.docker.com/_/debian/tags -FROM debian:bookworm-slim@sha256:1371f816c47921a144436ca5a420122a30de85f95401752fd464d9d4e1e08271 +FROM debian:bookworm-slim@sha256:e899040a73d36e2b36fa33216943539d9957cba8172b858097c2cabcdb20a3e2 RUN apt-get update -qq && apt-get install -qq -y --no-install-recommends \ build-essential make autoconf automake libtool git perl zip zlib1g-dev gawk && \ From 1dd758b36d281cbdc4f26cf223760b53b3333b7e Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Tue, 9 Dec 2025 12:14:21 +0100 Subject: [PATCH 248/415] test1464: mark XML-compliant Closes #19892 --- tests/data/test1464 | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/data/test1464 b/tests/data/test1464 index be0b0c5f4d7c..a0562d286034 100644 --- a/tests/data/test1464 +++ b/tests/data/test1464 @@ -3,7 +3,6 @@ FILE --help -notxml From d14bf19fdaec3734cb2ffd0d8685ac1cc5302814 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Tue, 9 Dec 2025 12:18:31 +0100 Subject: [PATCH 249/415] test1025, 1221: fold long command-lines Closes #19893 --- tests/data/test1015 | 6 +++++- tests/data/test1221 | 8 +++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/data/test1015 b/tests/data/test1015 index 4fe79c7b9902..2cd937806043 100644 --- a/tests/data/test1015 +++ b/tests/data/test1015 @@ -29,7 +29,11 @@ http --data-urlencode -http://%HOSTIP:%HTTPPORT/%TESTNUMBER --data-urlencode "my name is moo[]" --data-urlencode "y e s=s_i_r" --data-urlencode "v_alue@%LOGDIR/%TESTNUMBER.txt" --data-urlencode @%LOGDIR/%TESTNUMBER.txt +http://%HOSTIP:%HTTPPORT/%TESTNUMBER +--data-urlencode "my name is moo[]" +--data-urlencode "y e s=s_i_r" +--data-urlencode "v_alue@%LOGDIR/%TESTNUMBER.txt" +--data-urlencode @%LOGDIR/%TESTNUMBER.txt content to _?!#$'|%LT%GT diff --git a/tests/data/test1221 b/tests/data/test1221 index 12a82be1ee74..5f200c17abbe 100644 --- a/tests/data/test1221 +++ b/tests/data/test1221 @@ -30,7 +30,13 @@ http --url-query with --data-urlencode -http://%HOSTIP:%HTTPPORT/%TESTNUMBER --url-query "my name is moo[]" --url-query "yes=s i r" --url-query "v_alue@%LOGDIR/%TESTNUMBER.txt" --url-query @%LOGDIR/%TESTNUMBER.txt --url-query "+%3d%3d" --data-urlencode "start=once upon the time" +http://%HOSTIP:%HTTPPORT/%TESTNUMBER +--url-query "my name is moo[]" +--url-query "yes=s i r" +--url-query "v_alue@%LOGDIR/%TESTNUMBER.txt" +--url-query @%LOGDIR/%TESTNUMBER.txt +--url-query "+%3d%3d" +--data-urlencode "start=once upon the time" content to _?!#$'|%LT%GT From b739102ea6eee0a609da5d9547f18930b89a0a87 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 9 Dec 2025 11:53:45 +0100 Subject: [PATCH 250/415] TODO: remove ancient entries no longer considered - TCP Fast Open support on Windows TFO doesn't really work on the internet and isn't really used anywhere. We use QUIC now. - get rid of PATH_MAX Not a priority and when using 3rd party libraries not really up to us. - auto-detect proxy A dream we can just stop having. - config file parsing Let's not do that in our library. - add asynch getaddrinfo support Let's not add a limited glibc specific backend with bad API - FTP HOST If we managed this far without name based vhost FTP, let's not. Closes #19890 --- docs/TODO.md | 75 +++++----------------------------------------------- 1 file changed, 7 insertions(+), 68 deletions(-) diff --git a/docs/TODO.md b/docs/TODO.md index 09b45443c791..2b77b8ce0b9e 100644 --- a/docs/TODO.md +++ b/docs/TODO.md @@ -19,17 +19,6 @@ document](https://curl.se/docs/knownbugs.html) are subject for fixing. # libcurl -## TCP Fast Open support on Windows - -libcurl supports the `CURLOPT_TCP_FASTOPEN` option since 7.49.0 for Linux and -macOS. Windows supports TCP Fast Open starting with Windows 10, version 1607 -and we should add support for it. - -TCP Fast Open is supported on several platforms but not on Windows. Work on -this was once started but never finished. - -See [curl pull request 3378](https://github.com/curl/curl/pull/3378) - ## Consult `%APPDATA%` also for `.netrc` `%APPDATA%\.netrc` is not considered when running on Windows. Should not it? @@ -58,15 +47,6 @@ See [curl issue 4915](https://github.com/curl/curl/issues/4915) and lib1541.c The share interface offers CURL_LOCK_DATA_HSTS to have multiple easy handle share an HSTS cache, but this is not thread-safe. -## get rid of PATH_MAX - -Having code use and rely on PATH_MAX is not nice: -https://insanecoding.blogspot.com/2007/11/pathmax-simply-isnt.html - -Currently the libssh2 SSH based code uses it, but to remove PATH_MAX from -there we need libssh2 to properly tell us when we pass in a too small buffer -and its current API (as of libssh2 1.2.7) does not. - ## thread-safe sharing Using the share interface users can share some data between easy handles but @@ -74,18 +54,6 @@ several of the sharing options are documented as not safe and supported to share between multiple concurrent threads. Fixing this would enable more users to share data in more powerful ways. -## auto-detect proxy - -libcurl could be made to detect the system proxy setup automatically and use -that. On Windows, macOS and Linux desktops for example. - -The [pull-request to use *libproxy*](https://github.com/curl/curl/pull/977) -for this was deferred due to doubts on the reliability of the dependency and -how to use it. - -[*libdetectproxy*](https://github.com/paulharris/libdetectproxy) is a (C++) -library for detecting the proxy on Windows. - ## updated DNS server while running If `/etc/resolv.conf` gets updated while a program using libcurl is running, it @@ -156,11 +124,6 @@ for each redirect. [curl issue 6743](https://github.com/curl/curl/issues/6743) -## `SRV` and `URI` DNS records - -Offer support for resolving `SRV` and `URI` DNS records for libcurl to know which -server to connect to for various protocols (including HTTP). - ## CURLINFO_PAUSE_STATE Return information about the transfer's current pause state, in both @@ -175,14 +138,6 @@ callback. Perhaps also provide reason. [curl issue 2126](https://github.com/curl/curl/issues/2126) -## config file parsing - -Consider providing an API, possibly in a separate companion library, for -parsing a config file like curl's `-K`/`--config` option to allow applications -to get the same ability to read curl options from files. - -See [curl issue 3698](https://github.com/curl/curl/issues/3698) - ## erase secrets from heap/stack after use Introducing a concept and system to erase secrets from memory after use, it @@ -192,15 +147,6 @@ and then clearing them within the library adds nothing... [curl issue 7268](https://github.com/curl/curl/issues/7268) -## add asynch getaddrinfo support - -Use `getaddrinfo_a()` to provide an asynch name resolver backend to libcurl -that does not use threads and does not depend on c-ares. The `getaddrinfo_a` -function is (probably?) glibc specific but that is a widely used libc among -our users. - -[curl pull request 6746](https://github.com/curl/curl/pull/6746) - ## make DoH inherit more transfer properties Some options are not inherited because they are not relevant for the DoH SSL @@ -297,13 +243,6 @@ See [curl issue 6968](https://github.com/curl/curl/issues/6968) # FTP -## HOST - -HOST is a command for a client to tell which hostname to use, to offer FTP -servers named-based virtual hosting: - -https://datatracker.ietf.org/doc/html/rfc7151 - ## A fixed directory listing format Since listing the contents of a remove directory with FTP is returning the @@ -471,18 +410,18 @@ capabilities returned from the CAPA command. ## Enhanced capability support - Add the ability, for an application that uses libcurl, to obtain the list of - capabilities returned from the CAPABILITY command. +Add the ability, for an application that uses libcurl, to obtain the list of +capabilities returned from the CAPABILITY command. # LDAP ## SASL based authentication mechanisms -Currently the LDAP module only supports ldap_simple_bind_s() in order to bind -to an LDAP server. However, this function sends username and password details -using the simple authentication mechanism (as clear text). However, it should -be possible to use ldap_bind_s() instead specifying the security context -information ourselves. +Currently the LDAP module only supports `ldap_simple_bind_s()` in order to +bind to an LDAP server. However, this function sends username and password +details using the simple authentication mechanism (as clear text). However, it +should be possible to use `ldap_bind_s()` instead specifying the security +context information ourselves. ## `CURLOPT_SSL_CTX_FUNCTION` for LDAPS From e28dc58b6525241fb8e90f7cc6bd91c13616f27c Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Tue, 9 Dec 2025 12:55:26 +0100 Subject: [PATCH 251/415] examples: use 64-bit `fstat` on Windows Closes #19896 --- docs/examples/anyauthput.c | 4 ++-- docs/examples/fileupload.c | 4 ++-- docs/examples/ftpupload.c | 4 ++-- docs/examples/http2-upload.c | 4 ++-- docs/examples/httpput.c | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/examples/anyauthput.c b/docs/examples/anyauthput.c index 5a650b64c721..a8f179e8e75d 100644 --- a/docs/examples/anyauthput.c +++ b/docs/examples/anyauthput.c @@ -41,9 +41,9 @@ #ifdef _WIN32 #undef stat -#define stat _stat +#define stat _stati64 #undef fstat -#define fstat _fstat +#define fstat _fstati64 #define fileno _fileno #endif diff --git a/docs/examples/fileupload.c b/docs/examples/fileupload.c index da69e4a8ead1..4639b6b12f3e 100644 --- a/docs/examples/fileupload.c +++ b/docs/examples/fileupload.c @@ -39,9 +39,9 @@ #ifdef _WIN32 #undef stat -#define stat _stat +#define stat _stati64 #undef fstat -#define fstat _fstat +#define fstat _fstati64 #define fileno _fileno #endif diff --git a/docs/examples/ftpupload.c b/docs/examples/ftpupload.c index 48c76a4898a7..36663d5afb31 100644 --- a/docs/examples/ftpupload.c +++ b/docs/examples/ftpupload.c @@ -44,9 +44,9 @@ #ifdef _WIN32 #include #undef stat -#define stat _stat +#define stat _stati64 #undef fstat -#define fstat _fstat +#define fstat _fstati64 #define fileno _fileno #else #include diff --git a/docs/examples/http2-upload.c b/docs/examples/http2-upload.c index 0f1ed748ca1d..8ed6568542a1 100644 --- a/docs/examples/http2-upload.c +++ b/docs/examples/http2-upload.c @@ -56,9 +56,9 @@ #ifdef _WIN32 #undef stat -#define stat _stat +#define stat _stati64 #undef fstat -#define fstat _fstat +#define fstat _fstati64 #define fileno _fileno #endif diff --git a/docs/examples/httpput.c b/docs/examples/httpput.c index 026fde1210ea..8892d76f077a 100644 --- a/docs/examples/httpput.c +++ b/docs/examples/httpput.c @@ -39,9 +39,9 @@ #ifdef _WIN32 #undef stat -#define stat _stat +#define stat _stati64 #undef fstat -#define fstat _fstat +#define fstat _fstati64 #define fileno _fileno #endif From e76080fb73f3f73d415427678843b643462448cd Mon Sep 17 00:00:00 2001 From: Yedaya Katsman Date: Tue, 2 Dec 2025 19:40:07 +0200 Subject: [PATCH 252/415] test: add test 2090 for SSLKEYLOGFILE structure Only the TLS 1.2 structure for now since it's simpler, and only has a single label type. This has the bonus of also testing libressl that only supports logging keys in TLS 1.2 Closes #19816 --- tests/data/Makefile.am | 2 +- tests/data/test2090 | 61 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 tests/data/test2090 diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am index 140d507d777a..63cc4729f314 100644 --- a/tests/data/Makefile.am +++ b/tests/data/Makefile.am @@ -253,7 +253,7 @@ test2056 test2057 test2058 test2059 test2060 test2061 test2062 test2063 \ test2064 test2065 test2066 test2067 test2068 test2069 test2070 test2071 \ test2072 test2073 test2074 test2075 test2076 test2077 test2078 test2079 \ test2080 test2081 test2082 test2083 test2084 test2085 test2086 test2087 \ -test2088 test2089 \ +test2088 test2089 test2090 \ test2100 test2101 test2102 test2103 test2104 \ \ test2200 test2201 test2202 test2203 test2204 test2205 \ diff --git a/tests/data/test2090 b/tests/data/test2090 new file mode 100644 index 000000000000..8e1223b99e1f --- /dev/null +++ b/tests/data/test2090 @@ -0,0 +1,61 @@ + + + +HTTPS +TLS + + + +# +# Server-side + + +HTTP/1.1 200 OK +Date: Tue, 09 Nov 2010 14:49:00 GMT +Server: test-server/fake +Content-Length: 7 + +MooMoo + + + +# +# Client-side + + +SSL +!Schannel +!mbedtls + + +SSLKEYLOGFILE=%LOGDIR/%TESTNUMBER.log.ssl + + +https + + +HTTPS request with SSLKEYLOGFILE set + + +--cacert %CERTDIR/certs/test-ca.crt --tls-max 1.2 https://localhost:%HTTPSPORT/%TESTNUMBER + + + +# +# Verify data after the test has been "shot" + + +GET /%TESTNUMBER HTTP/1.1 +Host: localhost:%HTTPSPORT +User-Agent: curl/%VERSION +Accept: */* + + + +CLIENT_RANDOM %repeat[32 x 9A]% %repeat[48 x BC]% + + +s/^CLIENT_RANDOM [0-9a-fA-F]{64} [0-9a-fA-F]{96}/CLIENT_RANDOM %repeat[32 x 9A]% %repeat[48 x BC]%/g + + + From 8e847fa5364be06737cd6c08beeb866006817a8d Mon Sep 17 00:00:00 2001 From: Yedaya Katsman Date: Tue, 2 Dec 2025 21:59:53 +0200 Subject: [PATCH 253/415] gtls: Call keylog_close in cleanup --- lib/vtls/gtls.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/vtls/gtls.c b/lib/vtls/gtls.c index c7f8f346739a..d1236aefba0c 100644 --- a/lib/vtls/gtls.c +++ b/lib/vtls/gtls.c @@ -169,6 +169,7 @@ static int gtls_init(void) static void gtls_cleanup(void) { gnutls_global_deinit(); + Curl_tls_keylog_close(); } #ifndef CURL_DISABLE_VERBOSE_STRINGS From f450f3801b6b9dff0ea280f5fb4bf28203f7b313 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Tue, 9 Dec 2025 14:27:44 +0100 Subject: [PATCH 254/415] GHA/windows: re-enable `taskkill` Nothing conclusive for the last ~30 days when `taskkill` was made a no-op. Jobs remained flaky with all known failure modes. Sometimes they finish green on the first run, sometimes they fail. Hard to say more without comparing detailed stats for this period and the preceding (or upcoming) one. In almost all runs, the PID to be killed did not exist at the time of check. Follow-up to 2701ac6a4d16a62130dad05be1c484903b8545c7 #19421 Closes #19897 --- .github/workflows/windows.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 8dca6ce891e4..9d7f0dc88d32 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -37,7 +37,6 @@ permissions: {} env: CURL_CI: github - CURL_TEST_NO_TASKKILL: '1' jobs: cygwin: From 5ed7b5b01bb1a5645a9937573fddbf34782b5c83 Mon Sep 17 00:00:00 2001 From: Stefan Eissing Date: Mon, 8 Dec 2025 13:36:19 +0100 Subject: [PATCH 255/415] alt-svc: more flexibility on same destination When the Alt-Svc points to the same host and port, add the destination ALPN to the `wanted` versions and set it also as the `preferred` version in negotiations. This allows Alt-Svc for h3 to point to h2 and have it tried first. Also, this allows Alt-Svc to say http/1.1 is preferred and changes the ALPN protocol ordering for the TLS handshake. Add tests in various combination to verify this works. Reported-by: yushicheng7788 on github Fixes #19740 Closes #19874 --- lib/altsvc.c | 6 ++- lib/altsvc.h | 3 +- lib/cf-https-connect.c | 25 ++++++++++++ lib/http.h | 1 + lib/url.c | 28 ++++++++++++-- lib/vtls/vtls.c | 23 +++++++---- tests/http/test_06_eyeballs.py | 16 ++++++++ tests/http/test_12_reuse.py | 71 ++++++++++++++++++---------------- tests/http/testenv/curl.py | 11 +++++- 9 files changed, 135 insertions(+), 49 deletions(-) diff --git a/lib/altsvc.c b/lib/altsvc.c index 31f6b515bec2..c422736fd230 100644 --- a/lib/altsvc.c +++ b/lib/altsvc.c @@ -622,7 +622,8 @@ bool Curl_altsvc_lookup(struct altsvcinfo *asi, enum alpnid srcalpnid, const char *srchost, int srcport, struct altsvc **dstentry, - const int versions) /* one or more bits */ + const int versions, /* one or more bits */ + bool *psame_destination) { struct Curl_llist_node *e; struct Curl_llist_node *n; @@ -631,6 +632,7 @@ bool Curl_altsvc_lookup(struct altsvcinfo *asi, DEBUGASSERT(srchost); DEBUGASSERT(dstentry); + *psame_destination = FALSE; for(e = Curl_llist_head(&asi->list); e; e = n) { struct altsvc *as = Curl_node_elem(e); n = Curl_node_next(e); @@ -646,6 +648,8 @@ bool Curl_altsvc_lookup(struct altsvcinfo *asi, (versions & (int)as->dst.alpnid)) { /* match */ *dstentry = as; + *psame_destination = (srcport == as->dst.port) && + hostcompare(srchost, as->dst.host); return TRUE; } } diff --git a/lib/altsvc.h b/lib/altsvc.h index d370b4e4b195..c6f1b902c78a 100644 --- a/lib/altsvc.h +++ b/lib/altsvc.h @@ -65,7 +65,8 @@ 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 */ + bool *psame_destination); #else /* disabled */ #define Curl_altsvc_save(a, b, c) diff --git a/lib/cf-https-connect.c b/lib/cf-https-connect.c index acb3bcdd3a7a..47555fed94f2 100644 --- a/lib/cf-https-connect.c +++ b/lib/cf-https-connect.c @@ -710,6 +710,31 @@ CURLcode Curl_cf_https_setup(struct Curl_easy *data, } #endif + /* Add preferred HTTP version ALPN first */ + if(data->state.http_neg.preferred && + (alpn_count < CURL_ARRAYSIZE(alpn_ids)) && + (data->state.http_neg.preferred & data->state.http_neg.allowed)) { + enum alpnid alpn_pref = ALPN_none; + switch(data->state.http_neg.preferred) { + case CURL_HTTP_V3x: + if(!Curl_conn_may_http3(data, conn, conn->transport_wanted)) + alpn_pref = ALPN_h3; + break; + case CURL_HTTP_V2x: + alpn_pref = ALPN_h2; + break; + case CURL_HTTP_V1x: + alpn_pref = ALPN_h1; + break; + default: + break; + } + if(alpn_pref && + !cf_https_alpns_contain(alpn_pref, alpn_ids, alpn_count)) { + alpn_ids[alpn_count++] = alpn_pref; + } + } + if((alpn_count < CURL_ARRAYSIZE(alpn_ids)) && (data->state.http_neg.wanted & CURL_HTTP_V3x) && !cf_https_alpns_contain(ALPN_h3, alpn_ids, alpn_count)) { diff --git a/lib/http.h b/lib/http.h index 1c7ebdf8d7f1..c0f13ce1b0e3 100644 --- a/lib/http.h +++ b/lib/http.h @@ -72,6 +72,7 @@ struct http_negotiation { unsigned char rcvd_min; /* minimum version seen in responses, 09, 10, 11 */ http_majors wanted; /* wanted major versions when talking to server */ http_majors allowed; /* allowed major versions when talking to server */ + http_majors preferred; /* preferred major version when talking to server */ BIT(h2_upgrade); /* Do HTTP Upgrade from 1.1 to 2 */ BIT(h2_prior_knowledge); /* Directly do HTTP/2 without ALPN/SSL */ BIT(accept_09); /* Accept an HTTP/0.9 response */ diff --git a/lib/url.c b/lib/url.c index 0643ceea7f8c..98fc8ce44f87 100644 --- a/lib/url.c +++ b/lib/url.c @@ -3060,6 +3060,7 @@ static CURLcode parse_connect_to_slist(struct Curl_easy *data, struct altsvc *as = NULL; int allowed_alpns = ALPN_none; struct http_negotiation *neg = &data->state.http_neg; + bool same_dest = FALSE; DEBUGF(infof(data, "Alt-svc check wanted=%x, allowed=%x", neg->wanted, neg->allowed)); @@ -3083,7 +3084,7 @@ static CURLcode parse_connect_to_slist(struct Curl_easy *data, hit = Curl_altsvc_lookup(data->asi, ALPN_h3, host, conn->remote_port, /* from */ &as /* to */, - allowed_alpns); + allowed_alpns, &same_dest); } #endif #ifdef USE_HTTP2 @@ -3093,7 +3094,7 @@ static CURLcode parse_connect_to_slist(struct Curl_easy *data, hit = Curl_altsvc_lookup(data->asi, ALPN_h2, host, conn->remote_port, /* from */ &as /* to */, - allowed_alpns); + allowed_alpns, &same_dest); } #endif if(!hit && (neg->wanted & CURL_HTTP_V1x) && @@ -3102,10 +3103,29 @@ static CURLcode parse_connect_to_slist(struct Curl_easy *data, hit = Curl_altsvc_lookup(data->asi, ALPN_h1, host, conn->remote_port, /* from */ &as /* to */, - allowed_alpns); + allowed_alpns, &same_dest); } - if(hit) { + if(hit && same_dest) { + /* same destination, but more HTTPS version options */ + switch(as->dst.alpnid) { + case ALPN_h1: + neg->wanted |= CURL_HTTP_V1x; + neg->preferred = CURL_HTTP_V1x; + break; + case ALPN_h2: + neg->wanted |= CURL_HTTP_V2x; + neg->preferred = CURL_HTTP_V2x; + break; + case ALPN_h3: + neg->wanted |= CURL_HTTP_V3x; + neg->preferred = CURL_HTTP_V3x; + break; + default: /* should not be possible */ + break; + } + } + else if(hit) { char *hostd = curlx_strdup((char *)as->dst.host); if(!hostd) return CURLE_OUT_OF_MEMORY; diff --git a/lib/vtls/vtls.c b/lib/vtls/vtls.c index e342953778b0..696c7fbaf860 100644 --- a/lib/vtls/vtls.c +++ b/lib/vtls/vtls.c @@ -145,22 +145,28 @@ static const struct alpn_spec ALPN_SPEC_H2 = { static const struct alpn_spec ALPN_SPEC_H2_H11 = { { ALPN_H2, ALPN_HTTP_1_1 }, 2 }; +static const struct alpn_spec ALPN_SPEC_H11_H2 = { + { ALPN_HTTP_1_1, ALPN_H2 }, 2 +}; #endif #if !defined(CURL_DISABLE_HTTP) || !defined(CURL_DISABLE_PROXY) -static const struct alpn_spec *alpn_get_spec(http_majors allowed, +static const struct alpn_spec *alpn_get_spec(http_majors wanted, + http_majors preferred, bool use_alpn) { if(!use_alpn) return NULL; #ifdef USE_HTTP2 - if(allowed & CURL_HTTP_V2x) { - if(allowed & CURL_HTTP_V1x) - return &ALPN_SPEC_H2_H11; + if(wanted & CURL_HTTP_V2x) { + if(wanted & CURL_HTTP_V1x) + return (preferred == CURL_HTTP_V1x) ? + &ALPN_SPEC_H11_H2 : &ALPN_SPEC_H2_H11; return &ALPN_SPEC_H2; } #else - (void)allowed; + (void)wanted; + (void)preferred; #endif /* Use the ALPN protocol "http/1.1" for HTTP/1.x. Avoid "http/1.0" because some servers do not support it. */ @@ -1718,6 +1724,7 @@ static CURLcode cf_ssl_create(struct Curl_cfilter **pcf, ctx = cf_ctx_new(data, NULL); #else ctx = cf_ctx_new(data, alpn_get_spec(data->state.http_neg.wanted, + data->state.http_neg.preferred, conn->bits.tls_enable_alpn)); #endif if(!ctx) { @@ -1770,17 +1777,17 @@ static CURLcode cf_ssl_proxy_create(struct Curl_cfilter **pcf, CURLcode result; /* ALPN is default, but if user explicitly disables it, obey */ bool use_alpn = data->set.ssl_enable_alpn; - http_majors allowed = CURL_HTTP_V1x; + http_majors wanted = CURL_HTTP_V1x; (void)conn; #ifdef USE_HTTP2 if(conn->http_proxy.proxytype == CURLPROXY_HTTPS2) { use_alpn = TRUE; - allowed = (CURL_HTTP_V1x | CURL_HTTP_V2x); + wanted = (CURL_HTTP_V1x | CURL_HTTP_V2x); } #endif - ctx = cf_ctx_new(data, alpn_get_spec(allowed, use_alpn)); + ctx = cf_ctx_new(data, alpn_get_spec(wanted, 0, use_alpn)); if(!ctx) { result = CURLE_OUT_OF_MEMORY; goto out; diff --git a/tests/http/test_06_eyeballs.py b/tests/http/test_06_eyeballs.py index 7d2677447671..3b374e8158e3 100644 --- a/tests/http/test_06_eyeballs.py +++ b/tests/http/test_06_eyeballs.py @@ -133,3 +133,19 @@ def test_06_13_timers(self, env: Env): he_timers_set = [line for line in r.trace_lines if re.match(r'.*\[TIMER] \[HAPPY_EYEBALLS] set for', line)] assert len(he_timers_set) == 2, f'found: {"".join(he_timers_set)}\n{r.dump_logs()}' + + # download using HTTP/3 on missing server with alt-svc pointing there + @pytest.mark.skipif(condition=not Env.have_h3(), reason="missing HTTP/3 support") + def test_06_20_h2_altsvc_h3_fallback(self, env: Env, httpd, nghttpx): + curl = CurlClient(env=env) + urln = f'https://{env.domain1}:{env.https_only_tcp_port}/data.json' + altsvc_file = curl.mk_altsvc_file('test_06', + 'h2', env.domain1, env.https_only_tcp_port, + 'h3', env.domain1, env.https_only_tcp_port) + r = curl.http_download(urls=[urln], extra_args=[ + '--alt-svc', altsvc_file + ]) + # Should try a QUIC connection that fails and fallback to h2 + r.check_exit_code(0) + r.check_response(count=1, http_status=200) + assert r.stats[0]['http_version'] == '2' diff --git a/tests/http/test_12_reuse.py b/tests/http/test_12_reuse.py index 1d4a4a0ae2f8..522df92708cf 100644 --- a/tests/http/test_12_reuse.py +++ b/tests/http/test_12_reuse.py @@ -26,6 +26,7 @@ # import logging import os +import re from datetime import datetime, timedelta import pytest @@ -77,10 +78,11 @@ def test_12_02_h1_conn_timeout(self, env: Env, httpd, configures_httpd, nghttpx, @pytest.mark.skipif(condition=not Env.have_h3(), reason="h3 not supported") def test_12_03_as_follow_h2h3(self, env: Env, httpd, configures_httpd, nghttpx): - # write an alt-svc file that advises h3 instead of h2 - asfile = os.path.join(env.gen_dir, 'alt-svc-12_03.txt') - self.create_asfile(asfile, f'h2 {env.domain1} {env.https_port} h3 {env.domain1} {env.h3_port}') curl = CurlClient(env=env) + # write an alt-svc file that advises h3 instead of h2 + asfile = curl.mk_altsvc_file('test_12', + 'h2', env.domain1, env.https_port, + 'h3', env.domain1, env.h3_port) urln = f'https://{env.authority_for(env.domain1, "h2")}/data.json' r = curl.http_download(urls=[urln], with_stats=True, extra_args=[ '--alt-svc', f'{asfile}', @@ -112,54 +114,47 @@ def test_12_04_as_follow_h3h2(self, env: Env, httpd, configures_httpd, nghttpx): @pytest.mark.skipif(condition=not Env.have_h3(), reason="h3 not supported") def test_12_05_as_follow_h3h1(self, env: Env, httpd, configures_httpd, nghttpx): # With '--http3` an Alt-Svc redirection from h3 to h1 is allowed - count = 2 # write an alt-svc file the advises h1 instead of h3 - asfile = os.path.join(env.gen_dir, 'alt-svc-12_05.txt') - ts = datetime.now() + timedelta(hours=24) - expires = f'{ts.year:04}{ts.month:02}{ts.day:02} {ts.hour:02}:{ts.minute:02}:{ts.second:02}' - with open(asfile, 'w') as fd: - fd.write(f'h3 {env.domain1} {env.https_port} http/1.1 {env.domain1} {env.https_port} "{expires}" 0 0') - log.info(f'altscv: {open(asfile).readlines()}') curl = CurlClient(env=env) - urln = f'https://{env.authority_for(env.domain1, "h3")}/data.json?[0-{count-1}]' + asfile = curl.mk_altsvc_file('test_12', + 'h3', env.domain1, env.https_port, + 'http/1.1', env.domain1, env.https_port) + urln = f'https://{env.authority_for(env.domain1, "h3")}/data.json' r = curl.http_download(urls=[urln], with_stats=True, extra_args=[ '--alt-svc', f'{asfile}', '--http3' ]) - r.check_response(count=count, http_status=200) - # We expect the connection to be reused and use HTTP/1.1 + r.check_response(count=1, http_status=200) + # We expect the connection to be preferring HTTP/1.1 in the ALPN assert r.total_connects == 1 - for s in r.stats: - assert s['http_version'] == '1.1', f'{s}' + re_m = re.compile(r'.* ALPN: curl offers http/1.1,h2') + lines = [line for line in r.trace_lines if re_m.match(line)] + assert len(lines), f'{r.dump_logs()}' @pytest.mark.skipif(condition=not Env.have_h3(), reason="h3 not supported") def test_12_06_as_ignore_h3h1(self, env: Env, httpd, configures_httpd, nghttpx): # With '--http3-only` an Alt-Svc redirection from h3 to h1 is ignored - count = 2 # write an alt-svc file the advises h1 instead of h3 - asfile = os.path.join(env.gen_dir, 'alt-svc-12_05.txt') - ts = datetime.now() + timedelta(hours=24) - expires = f'{ts.year:04}{ts.month:02}{ts.day:02} {ts.hour:02}:{ts.minute:02}:{ts.second:02}' - with open(asfile, 'w') as fd: - fd.write(f'h3 {env.domain1} {env.https_port} http/1.1 {env.domain1} {env.https_port} "{expires}" 0 0') - log.info(f'altscv: {open(asfile).readlines()}') curl = CurlClient(env=env) - urln = f'https://{env.authority_for(env.domain1, "h3")}/data.json?[0-{count-1}]' + asfile = curl.mk_altsvc_file('test_12', + 'h3', env.domain1, env.https_port, + 'http/1.1', env.domain1, env.https_port) + urln = f'https://{env.authority_for(env.domain1, "h3")}/data.json' r = curl.http_download(urls=[urln], with_stats=True, extra_args=[ '--alt-svc', f'{asfile}', '--http3-only' ]) - r.check_response(count=count, http_status=200) + r.check_response(count=1, http_status=200) # We expect the connection to be stay on h3, since we used --http3-only assert r.total_connects == 1 - for s in r.stats: - assert s['http_version'] == '3', f'{s}' + assert r.stats[0]['http_version'] == '3', f'{r.stats}' @pytest.mark.skipif(condition=not Env.have_h3(), reason="h3 not supported") def test_12_07_as_ignore_h2h3(self, env: Env, httpd, configures_httpd, nghttpx): # With '--http2` an Alt-Svc redirection from h2 to h3 is ignored # write an alt-svc file that advises h3 instead of h2 - asfile = os.path.join(env.gen_dir, 'alt-svc-12_03.txt') - self.create_asfile(asfile, f'h2 {env.domain1} {env.https_port} h3 {env.domain1} {env.h3_port}') curl = CurlClient(env=env) + asfile = curl.mk_altsvc_file('test_12', + 'h2', env.domain1, env.https_port, + 'h3', env.domain1, env.h3_port) urln = f'https://{env.authority_for(env.domain1, "h2")}/data.json' r = curl.http_download(urls=[urln], with_stats=True, extra_args=[ '--alt-svc', f'{asfile}', '--http2' @@ -167,9 +162,17 @@ def test_12_07_as_ignore_h2h3(self, env: Env, httpd, configures_httpd, nghttpx): r.check_response(count=1, http_status=200) assert r.stats[0]['http_version'] == '2', f'{r.stats}' - def create_asfile(self, fpath, line): - ts = datetime.now() + timedelta(hours=24) - expires = f'{ts.year:04}{ts.month:02}{ts.day:02} {ts.hour:02}:{ts.minute:02}:{ts.second:02}' - with open(fpath, 'w') as fd: - fd.write(f'{line} "{expires}" 0 0') - log.info(f'altscv: {open(fpath).readlines()}') + # download using HTTP/3 on available server with alt-svc to h2, use h2 + @pytest.mark.skipif(condition=not Env.have_h3(), reason="missing HTTP/3 support") + def test_12_08_h3_altsvc_h2_used(self, env: Env, httpd, nghttpx): + curl = CurlClient(env=env) + urln = f'https://{env.domain1}:{env.https_port}/data.json' + altsvc_file = curl.mk_altsvc_file('test_12', + 'h3', env.domain1, env.https_port, + 'h2', env.domain1, env.https_port) + r = curl.http_download(urls=[urln], extra_args=[ + '--http3', '--alt-svc', altsvc_file + ]) + r.check_exit_code(0) + r.check_response(count=1, http_status=200) + assert r.stats[0]['http_version'] == '2' diff --git a/tests/http/testenv/curl.py b/tests/http/testenv/curl.py index f54170baba58..d9fe0706ac43 100644 --- a/tests/http/testenv/curl.py +++ b/tests/http/testenv/curl.py @@ -36,7 +36,7 @@ import shutil import subprocess from statistics import mean, fmean -from datetime import timedelta, datetime +from datetime import timedelta, datetime, timezone from typing import List, Optional, Dict, Union, Any from urllib.parse import urlparse @@ -1211,3 +1211,12 @@ def _generate_flame(self, curl_args: List[str], rc = p.returncode if rc != 0: raise Exception(f'{fg_gen_flame} returned error {rc}') + + def mk_altsvc_file(self, name, src_alpn, src_host, src_port, + dest_alpn, dest_host, dest_port): + fpath = os.path.join(self.run_dir, f'{name}.altsvc') + ts = datetime.now(timezone.utc) + timedelta(hours=1) + ts = ts.strftime('%Y%m%d %H:%M:%S') + with open(fpath, 'w') as fd: + fd.write(f'{src_alpn} {src_host} {src_port} {dest_alpn} {dest_host} {dest_port} "{ts}" 1 0\n') + return fpath From 9711c986ba832507e8248bfff112623916cbc367 Mon Sep 17 00:00:00 2001 From: Stefan Eissing Date: Tue, 9 Dec 2025 12:51:17 +0100 Subject: [PATCH 256/415] multi: remove MSTATE_TUNNELING MSTATE_TUNNELING is no longer in use now that we have proxy connection filters. Remove the state. Remove the http handler `connect_it` method as it was merely a NOP. Closes #19894 --- lib/cfilters.c | 6 +++++- lib/curl_trc.c | 1 - lib/http.c | 13 ++---------- lib/http.h | 1 - lib/multi.c | 53 ++++++++++------------------------------------- lib/multihandle.h | 37 +++++++++++++++------------------ lib/rtsp.c | 7 ++----- lib/ws.c | 4 ++-- 8 files changed, 39 insertions(+), 83 deletions(-) diff --git a/lib/cfilters.c b/lib/cfilters.c index f51da8521aff..acffae3f0035 100644 --- a/lib/cfilters.c +++ b/lib/cfilters.c @@ -577,7 +577,11 @@ bool Curl_conn_is_connected(struct connectdata *conn, int sockindex) if(!CONN_SOCK_IDX_VALID(sockindex)) return FALSE; cf = conn->cfilter[sockindex]; - return cf && cf->connected; + if(cf) + return cf->connected; + else if(conn->handler->flags & PROTOPT_NONETWORK) + return TRUE; + return FALSE; } bool Curl_conn_is_ip_connected(struct Curl_easy *data, int sockindex) diff --git a/lib/curl_trc.c b/lib/curl_trc.c index 430d4c56a198..169f7a7d6d47 100644 --- a/lib/curl_trc.c +++ b/lib/curl_trc.c @@ -332,7 +332,6 @@ static const char * const Curl_trc_mstate_names[] = { "CONNECT", "RESOLVING", "CONNECTING", - "TUNNELING", "PROTOCONNECT", "PROTOCONNECTING", "DO", diff --git a/lib/http.c b/lib/http.c index ce5f5becdf0e..d5aca0e8005b 100644 --- a/lib/http.c +++ b/lib/http.c @@ -121,7 +121,7 @@ const struct Curl_handler Curl_handler_http = { Curl_http, /* do_it */ Curl_http_done, /* done */ ZERO_NULL, /* do_more */ - Curl_http_connect, /* connect_it */ + ZERO_NULL, /* connect_it */ ZERO_NULL, /* connecting */ ZERO_NULL, /* doing */ ZERO_NULL, /* proto_pollset */ @@ -152,7 +152,7 @@ const struct Curl_handler Curl_handler_https = { Curl_http, /* do_it */ Curl_http_done, /* done */ ZERO_NULL, /* do_more */ - Curl_http_connect, /* connect_it */ + ZERO_NULL, /* connect_it */ NULL, /* connecting */ ZERO_NULL, /* doing */ NULL, /* proto_pollset */ @@ -1533,15 +1533,6 @@ bool Curl_compareheader(const char *headerline, /* line to check */ return FALSE; /* no match */ } -/* - * Curl_http_connect() performs HTTP stuff to do at connect-time, called from - * the generic Curl_connect(). - */ -CURLcode Curl_http_connect(struct Curl_easy *data, bool *done) -{ - return Curl_conn_connect(data, FIRSTSOCKET, FALSE, done); -} - /* this returns the socket to wait for in the DO and DOING state for the multi interface and then we are always _sending_ a request and thus we wait for the single socket to become writable only */ diff --git a/lib/http.h b/lib/http.h index c0f13ce1b0e3..26762b62058b 100644 --- a/lib/http.h +++ b/lib/http.h @@ -113,7 +113,6 @@ CURLcode Curl_http_setup_conn(struct Curl_easy *data, struct connectdata *conn); CURLcode Curl_http(struct Curl_easy *data, bool *done); CURLcode Curl_http_done(struct Curl_easy *data, CURLcode, bool premature); -CURLcode Curl_http_connect(struct Curl_easy *data, bool *done); CURLcode Curl_http_doing_pollset(struct Curl_easy *data, struct easy_pollset *ps); CURLcode Curl_http_perform_pollset(struct Curl_easy *data, diff --git a/lib/multi.c b/lib/multi.c index 531ec6605e46..760f03186d67 100644 --- a/lib/multi.c +++ b/lib/multi.c @@ -142,7 +142,6 @@ static void mstate(struct Curl_easy *data, CURLMstate state Curl_init_CONNECT, /* CONNECT */ NULL, /* RESOLVING */ NULL, /* CONNECTING */ - NULL, /* TUNNELING */ NULL, /* PROTOCONNECT */ NULL, /* PROTOCONNECTING */ NULL, /* DO */ @@ -1122,7 +1121,6 @@ CURLMcode Curl_multi_pollset(struct Curl_easy *data, break; case MSTATE_CONNECTING: - case MSTATE_TUNNELING: result = mstate_connecting_pollset(data, ps); break; @@ -1862,43 +1860,29 @@ static CURLcode protocol_doing(struct Curl_easy *data, bool *done) */ static CURLcode protocol_connect(struct Curl_easy *data, bool *protocol_done) { - CURLcode result = CURLE_OK; struct connectdata *conn = data->conn; + CURLcode result = CURLE_OK; + DEBUGASSERT(conn); DEBUGASSERT(protocol_done); + DEBUGASSERT(Curl_conn_is_connected(conn, FIRSTSOCKET)); *protocol_done = FALSE; - - if(Curl_conn_is_connected(conn, FIRSTSOCKET) && conn->bits.protoconnstart) { - /* We already are connected, get back. This may happen when the connect - worked fine in the first call, like when we connect to a local server - or proxy. Note that we do not know if the protocol is actually done. - - Unless this protocol does not have any protocol-connect callback, as - then we know we are done. */ - if(!conn->handler->connecting) - *protocol_done = TRUE; - - return CURLE_OK; - } - if(!conn->bits.protoconnstart) { if(conn->handler->connect_it) { - /* is there a protocol-specific connect() procedure? */ - /* Call the protocol-specific connect function */ result = conn->handler->connect_it(data, protocol_done); + if(result) + return result; } - else - *protocol_done = TRUE; - - /* it has started, possibly even completed but that knowledge is not stored - in this bit! */ - if(!result) - conn->bits.protoconnstart = TRUE; + conn->bits.protoconnstart = TRUE; } - return result; /* pass back status */ + /* Unless this protocol does not have any protocol-connect callback, as + then we know we are done. */ + if(!conn->handler->connecting) + *protocol_done = TRUE; + return CURLE_OK; } static void set_in_callback(struct Curl_multi *multi, bool value) @@ -2469,21 +2453,6 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi, rc = state_resolving(multi, data, &stream_error, &result); break; -#ifndef CURL_DISABLE_HTTP - case MSTATE_TUNNELING: - /* this is HTTP-specific, but sending CONNECT to a proxy is HTTP... */ - DEBUGASSERT(data->conn); - result = Curl_http_connect(data, &protocol_connected); - if(!result) { - rc = CURLM_CALL_MULTI_PERFORM; - /* initiate protocol connect phase */ - multistate(data, MSTATE_PROTOCONNECT); - } - else - stream_error = TRUE; - break; -#endif - case MSTATE_CONNECTING: /* awaiting a completion of an asynch TCP connect */ DEBUGASSERT(data->conn); diff --git a/lib/multihandle.h b/lib/multihandle.h index a267a209ee56..d71958c414f2 100644 --- a/lib/multihandle.h +++ b/lib/multihandle.h @@ -51,26 +51,23 @@ struct Curl_message { */ typedef enum { MSTATE_INIT, /* 0 - start in this state */ - MSTATE_PENDING, /* 1 - no connections, waiting for one */ - MSTATE_SETUP, /* 2 - start a new transfer */ - MSTATE_CONNECT, /* 3 - resolve/connect has been sent off */ - MSTATE_RESOLVING, /* 4 - awaiting the resolve to finalize */ - MSTATE_CONNECTING, /* 5 - awaiting the TCP connect to finalize */ - MSTATE_TUNNELING, /* 6 - awaiting HTTPS proxy SSL initialization to - complete and/or proxy CONNECT to finalize */ - MSTATE_PROTOCONNECT, /* 7 - initiate protocol connect procedure */ - MSTATE_PROTOCONNECTING, /* 8 - completing the protocol-specific connect - phase */ - MSTATE_DO, /* 9 - start send off the request (part 1) */ - MSTATE_DOING, /* 10 - sending off the request (part 1) */ - MSTATE_DOING_MORE, /* 11 - send off the request (part 2) */ - MSTATE_DID, /* 12 - done sending off request */ - MSTATE_PERFORMING, /* 13 - transfer data */ - MSTATE_RATELIMITING, /* 14 - wait because limit-rate exceeded */ - MSTATE_DONE, /* 15 - post data transfer operation */ - MSTATE_COMPLETED, /* 16 - operation complete */ - MSTATE_MSGSENT, /* 17 - the operation complete message is sent */ - MSTATE_LAST /* 18 - not a true state, never use this */ + MSTATE_PENDING, /* no connections, waiting for one */ + MSTATE_SETUP, /* start a new transfer */ + MSTATE_CONNECT, /* resolve/connect has been sent off */ + MSTATE_RESOLVING, /* awaiting the resolve to finalize */ + MSTATE_CONNECTING, /* awaiting the TCP connect to finalize */ + MSTATE_PROTOCONNECT, /* initiate protocol connect procedure */ + MSTATE_PROTOCONNECTING, /* completing the protocol-specific connect phase */ + MSTATE_DO, /* start send off the request (part 1) */ + MSTATE_DOING, /* sending off the request (part 1) */ + MSTATE_DOING_MORE, /* send off the request (part 2) */ + MSTATE_DID, /* done sending off request */ + MSTATE_PERFORMING, /* transfer data */ + MSTATE_RATELIMITING, /* wait because limit-rate exceeded */ + MSTATE_DONE, /* post data transfer operation */ + MSTATE_COMPLETED, /* operation complete */ + MSTATE_MSGSENT, /* the operation complete message is sent */ + MSTATE_LAST /* not a true state, never use this */ } CURLMstate; #define CURLPIPE_ANY (CURLPIPE_MULTIPLEX) diff --git a/lib/rtsp.c b/lib/rtsp.c index 0a807899f9a9..8cd756c4a7f9 100644 --- a/lib/rtsp.c +++ b/lib/rtsp.c @@ -214,13 +214,10 @@ static CURLcode rtsp_connect(struct Curl_easy *data, bool *done) { struct rtsp_conn *rtspc = Curl_conn_meta_get(data->conn, CURL_META_RTSP_CONN); - CURLcode httpStatus; if(!rtspc) return CURLE_FAILED_INIT; - httpStatus = Curl_http_connect(data, done); - /* Initialize the CSeq if not already done */ if(data->state.rtsp_next_client_CSeq == 0) data->state.rtsp_next_client_CSeq = 1; @@ -228,8 +225,8 @@ static CURLcode rtsp_connect(struct Curl_easy *data, bool *done) data->state.rtsp_next_server_CSeq = 1; rtspc->rtp_channel = -1; - - return httpStatus; + *done = TRUE; + return CURLE_OK; } static CURLcode rtsp_done(struct Curl_easy *data, diff --git a/lib/ws.c b/lib/ws.c index eab06f4f118c..38d4195879e1 100644 --- a/lib/ws.c +++ b/lib/ws.c @@ -1914,7 +1914,7 @@ const struct Curl_handler Curl_handler_ws = { Curl_http, /* do_it */ Curl_http_done, /* done */ ZERO_NULL, /* do_more */ - Curl_http_connect, /* connect_it */ + ZERO_NULL, /* connect_it */ ZERO_NULL, /* connecting */ ZERO_NULL, /* doing */ ZERO_NULL, /* proto_pollset */ @@ -1941,7 +1941,7 @@ const struct Curl_handler Curl_handler_wss = { Curl_http, /* do_it */ Curl_http_done, /* done */ ZERO_NULL, /* do_more */ - Curl_http_connect, /* connect_it */ + ZERO_NULL, /* connect_it */ NULL, /* connecting */ ZERO_NULL, /* doing */ NULL, /* proto_pollset */ From 44e64919cf11c6027d02123c0a02371c0fbf1b48 Mon Sep 17 00:00:00 2001 From: Stefan Eissing Date: Tue, 9 Dec 2025 12:54:00 +0100 Subject: [PATCH 257/415] pytest: socksd startup delay Add a small delay after the startup of the danted socks daemon to give it more time to become responsive. Closes #19895 --- tests/http/test_40_socks.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/http/test_40_socks.py b/tests/http/test_40_socks.py index 8c6a81f4f6ad..1c844b82aae8 100644 --- a/tests/http/test_40_socks.py +++ b/tests/http/test_40_socks.py @@ -26,6 +26,7 @@ # import logging import os +import time from typing import Generator import pytest @@ -42,6 +43,7 @@ class TestSocks: def danted(self, env: Env) -> Generator[Dante, None, None]: danted = Dante(env=env) assert danted.initial_start() + time.sleep(1) yield danted danted.stop() From 197904d4b1f816ff6a05f0123b9a31663e5a454c Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Tue, 9 Dec 2025 15:32:42 +0100 Subject: [PATCH 258/415] config-win32.h: delete obsolete, non-Windows comments Closes #19899 --- lib/config-win32.h | 36 ------------------------------------ 1 file changed, 36 deletions(-) diff --git a/lib/config-win32.h b/lib/config-win32.h index 4bf034bea31b..4b9ba3e32cb6 100644 --- a/lib/config-win32.h +++ b/lib/config-win32.h @@ -79,9 +79,6 @@ /* HEADER FILES */ /* ---------------------------------------------------------------- */ -/* Define if you have the header file. */ -/* #define HAVE_ARPA_INET_H 1 */ - /* Define if you have the header file. */ #define HAVE_FCNTL_H 1 @@ -91,12 +88,6 @@ /* Define if you have the header file. */ #define HAVE_LOCALE_H 1 -/* Define if you have the header file. */ -/* #define HAVE_NETDB_H 1 */ - -/* Define if you have the header file. */ -/* #define HAVE_NETINET_IN_H 1 */ - /* Define to 1 if you have the header file. */ #if (defined(_MSC_VER) && (_MSC_VER >= 1800)) || defined(__MINGW32__) #define HAVE_STDBOOL_H 1 @@ -112,24 +103,12 @@ #define HAVE_SYS_PARAM_H 1 #endif -/* Define if you have the header file. */ -/* #define HAVE_SYS_SELECT_H 1 */ - -/* Define if you have the header file. */ -/* #define HAVE_SYS_SOCKIO_H 1 */ - /* Define if you have the header file. */ #define HAVE_SYS_TYPES_H 1 /* Define if you have the header file. */ #define HAVE_SYS_UTIME_H 1 -/* Define if you have the header file. */ -/* #define HAVE_TERMIO_H 1 */ - -/* Define if you have the header file. */ -/* #define HAVE_TERMIOS_H 1 */ - /* Define if you have the header file. */ #ifdef __MINGW32__ #define HAVE_UNISTD_H 1 @@ -286,9 +265,6 @@ /* Define to the size of `int', as computed by sizeof. */ #define SIZEOF_INT 4 -/* Define to the size of `long long', as computed by sizeof. */ -/* #define SIZEOF_LONG_LONG 8 */ - /* Define to the size of `long', as computed by sizeof. */ #define SIZEOF_LONG 4 @@ -306,15 +282,6 @@ /* COMPILER SPECIFIC */ /* ---------------------------------------------------------------- */ -/* Define to nothing if compiler does not support 'const' qualifier. */ -/* #define const */ - -/* Define to nothing if compiler does not support 'volatile' qualifier. */ -/* #define volatile */ - -/* Windows should not have HAVE_GMTIME_R defined */ -/* #undef HAVE_GMTIME_R */ - /* Define if the compiler supports the 'long long' data type. */ #if defined(_MSC_VER) || defined(__MINGW32__) #define HAVE_LONGLONG 1 @@ -377,9 +344,6 @@ * Undefine both USE_ARES and USE_THREADS_WIN32 for synchronous DNS. */ -/* Define to enable c-ares asynchronous DNS lookups. */ -/* #define USE_ARES 1 */ - /* Default define to enable threaded asynchronous DNS lookups. */ #if !defined(USE_SYNC_DNS) && !defined(USE_ARES) && \ !defined(USE_THREADS_WIN32) From 74bc0c80b31c98dc9e49f261d0f2a196ff6b145f Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Tue, 9 Dec 2025 15:55:25 +0100 Subject: [PATCH 259/415] configure: delete unused variable Follow-up to 4d73854462f30948acab12984b611e9e33ee41e6 #9044 Closes #19901 --- configure.ac | 1 - 1 file changed, 1 deletion(-) diff --git a/configure.ac b/configure.ac index 1481a096b2bc..f0d05b18278e 100644 --- a/configure.ac +++ b/configure.ac @@ -4066,7 +4066,6 @@ CPPFLAGS=$o AC_CHECK_TYPE(long long, [AC_DEFINE(HAVE_LONGLONG, 1, [Define to 1 if the compiler supports the 'long long' data type.])] - longlong="yes" ) if test ${ac_cv_sizeof_curl_off_t} -lt 8; then From 073b85cefe30e27316c6bcbb382b746e9a412e73 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 9 Dec 2025 14:39:16 +0100 Subject: [PATCH 260/415] GHA: make links get checked daily Assisted-by: Viktor Szakats Closes #19898 --- .github/workflows/checkdocs.yml | 11 ----------- .github/workflows/checkurls.yml | 28 ++++++++++++++++++++++++++++ scripts/mdlinkcheck | 4 ++-- 3 files changed, 30 insertions(+), 13 deletions(-) create mode 100644 .github/workflows/checkurls.yml diff --git a/.github/workflows/checkdocs.yml b/.github/workflows/checkdocs.yml index a079aeaa7062..7962034e9673 100644 --- a/.github/workflows/checkdocs.yml +++ b/.github/workflows/checkdocs.yml @@ -89,17 +89,6 @@ jobs: # - name: 'check special prose' # run: proselint docs/internals/CHECKSRC.md docs/libcurl/curl_mprintf.md docs/libcurl/opts/CURLOPT_INTERFACE.md docs/cmdline-opts/interface.md - linkcheck: - name: 'linkcheck' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 - with: - persist-credentials: false - - - name: 'mdlinkcheck' - run: ./scripts/mdlinkcheck - pyspelling: name: 'pyspelling' runs-on: ubuntu-latest diff --git a/.github/workflows/checkurls.yml b/.github/workflows/checkurls.yml new file mode 100644 index 000000000000..f407859c75fd --- /dev/null +++ b/.github/workflows/checkurls.yml @@ -0,0 +1,28 @@ +# Copyright (C) Daniel Stenberg, , et al. +# +# SPDX-License-Identifier: curl + +name: 'URLs' + +'on': + schedule: + - cron: '10 5 * * *' + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }} + cancel-in-progress: true + +permissions: {} + +jobs: + linkcheck: + if: ${{ github.repository_owner == 'curl' }} + name: 'linkcheck' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 + with: + persist-credentials: false + + - name: 'mdlinkcheck' + run: ./scripts/mdlinkcheck diff --git a/scripts/mdlinkcheck b/scripts/mdlinkcheck index bce3ca3fd56c..c28f7dd1ed1a 100755 --- a/scripts/mdlinkcheck +++ b/scripts/mdlinkcheck @@ -86,8 +86,8 @@ my %whitelist = ( my %url; my %flink; -# list all .md files in the repo -my @files=`git ls-files '**.md'`; +# list all files to scan for links +my @files=`git ls-files docs src lib scripts`; sub storelink { my ($f, $line, $link) = @_; From 163705db756557e6c07ac9386663f0576ebfd64e Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Tue, 9 Dec 2025 10:31:20 +0100 Subject: [PATCH 261/415] windows: assume `USE_WIN32_LARGE_FILES` All Windows platforms support it. It was permanently enabled with most build methods. The exception is autotools where it is enabled by default, with an option to disable it. It changed the build in a few places for rarely tested code paths, but not bringing other advantages (and used some 64-bit APIs anyway). This patch makes autotools' `--disable-largefile` option a no-op for Windows. Closes #19888 --- CMakeLists.txt | 5 +---- acinclude.m4 | 27 --------------------------- configure.ac | 1 - lib/config-win32.h | 13 ++++--------- lib/curl_config.h.cmake | 3 --- lib/curl_setup.h | 23 +++++++---------------- lib/curlx/fopen.c | 10 +--------- lib/version.c | 3 +-- src/tool_cb_see.c | 2 +- 9 files changed, 15 insertions(+), 72 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 685335667b9f..8b3cbecc51f0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1772,8 +1772,6 @@ if(WIN32) endif() list(APPEND CURL_LIBS "bcrypt") - set(USE_WIN32_LARGE_FILES ON) - # We use crypto functions that are not available for UWP apps if(NOT WINDOWS_STORE) set(USE_WIN32_CRYPTO ON) @@ -1972,8 +1970,7 @@ curl_add_if("asyn-rr" USE_ARES AND ENABLE_THREADED_RESOLVER AND USE_HTTPSR curl_add_if("IDN" (HAVE_LIBIDN2 AND HAVE_IDN2_H) OR USE_WIN32_IDN OR USE_APPLE_IDN) -curl_add_if("Largefile" (SIZEOF_CURL_OFF_T GREATER 4) AND - ((SIZEOF_OFF_T GREATER 4) OR USE_WIN32_LARGE_FILES)) +curl_add_if("Largefile" (SIZEOF_CURL_OFF_T GREATER 4) AND ((SIZEOF_OFF_T GREATER 4) OR WIN32)) curl_add_if("SSPI" USE_WINDOWS_SSPI) curl_add_if("GSS-API" HAVE_GSSAPI) curl_add_if("alt-svc" NOT CURL_DISABLE_ALTSVC) diff --git a/acinclude.m4 b/acinclude.m4 index 60e05add111e..0627ed1fd7e5 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -1307,33 +1307,6 @@ AS_HELP_STRING([--without-ca-embed], [Do not embed a default CA bundle in the cu fi ]) -dnl CURL_CHECK_WIN32_LARGEFILE -dnl ------------------------------------------------- -dnl Check if curl's Win32 large file will be used - -AC_DEFUN([CURL_CHECK_WIN32_LARGEFILE], [ - AC_REQUIRE([CURL_CHECK_NATIVE_WINDOWS])dnl - if test "$curl_cv_native_windows" = 'yes'; then - AC_MSG_CHECKING([whether build target supports Win32 large files]) - dnl All mingw-w64 versions support large files - curl_win32_has_largefile='yes' - case "$curl_win32_has_largefile" in - yes) - if test x"$enable_largefile" = 'xno'; then - AC_MSG_RESULT([yes (large file disabled)]) - else - AC_MSG_RESULT([yes (large file enabled)]) - AC_DEFINE_UNQUOTED(USE_WIN32_LARGE_FILES, 1, - [Define to 1 if you are building a Windows target with large file support.]) - fi - ;; - *) - AC_MSG_RESULT([no]) - ;; - esac - fi -]) - dnl CURL_CHECK_WIN32_CRYPTO dnl ------------------------------------------------- dnl Check if curl's Win32 crypto lib can be used diff --git a/configure.ac b/configure.ac index f0d05b18278e..64fa6516ec8f 100644 --- a/configure.ac +++ b/configure.ac @@ -618,7 +618,6 @@ dnl ********************************************************************** dnl Compilation based checks should not be done before this point. dnl ********************************************************************** -CURL_CHECK_WIN32_LARGEFILE CURL_CHECK_WIN32_CRYPTO curl_cv_apple='no' diff --git a/lib/config-win32.h b/lib/config-win32.h index 4b9ba3e32cb6..2bdb555084cf 100644 --- a/lib/config-win32.h +++ b/lib/config-win32.h @@ -318,19 +318,14 @@ /* LARGE FILE SUPPORT */ /* ---------------------------------------------------------------- */ -#if defined(_MSC_VER) || defined(__MINGW32__) -# define USE_WIN32_LARGE_FILES /* Number of bits in a file offset, on hosts where this is settable. */ -# ifdef __MINGW32__ -# ifndef _FILE_OFFSET_BITS -# define _FILE_OFFSET_BITS 64 -# endif -# endif +#ifdef __MINGW32__ +# undef _FILE_OFFSET_BITS +# define _FILE_OFFSET_BITS 64 #endif /* Define to the size of `off_t', as computed by sizeof. */ -#if defined(__MINGW32__) && \ - defined(_FILE_OFFSET_BITS) && (_FILE_OFFSET_BITS == 64) +#ifdef __MINGW32__ # define SIZEOF_OFF_T 8 #else # define SIZEOF_OFF_T 4 diff --git a/lib/curl_config.h.cmake b/lib/curl_config.h.cmake index 37ec3d9a6551..eaac11ec00da 100644 --- a/lib/curl_config.h.cmake +++ b/lib/curl_config.h.cmake @@ -761,9 +761,6 @@ ${SIZEOF_TIME_T_CODE} /* if Unix domain sockets are enabled */ #cmakedefine USE_UNIX_SOCKETS 1 -/* Define to 1 if you are building a Windows target with large file support. */ -#cmakedefine USE_WIN32_LARGE_FILES 1 - /* to enable SSPI support */ #cmakedefine USE_WINDOWS_SSPI 1 diff --git a/lib/curl_setup.h b/lib/curl_setup.h index 829650aee4d4..a7dc41493c0f 100644 --- a/lib/curl_setup.h +++ b/lib/curl_setup.h @@ -471,22 +471,13 @@ # endif # include # include -# ifdef USE_WIN32_LARGE_FILES - /* Large file (>2Gb) support using Win32 functions. */ -# undef lseek -# define lseek(fdes, offset, whence) _lseeki64(fdes, offset, whence) -# undef fstat -# define fstat(fdes, stp) _fstati64(fdes, stp) -# define struct_stat struct _stati64 -# define LSEEK_ERROR (__int64)-1 -# else - /* Small file (<2Gb) support using Win32 functions. */ -# undef lseek -# define lseek(fdes, offset, whence) _lseek(fdes, (long)offset, whence) -# define fstat(fdes, stp) _fstat(fdes, stp) -# define struct_stat struct _stat -# define LSEEK_ERROR (long)-1 -# endif + /* Large file (>2Gb) support using Win32 functions. */ +# undef lseek +# define lseek(fdes, offset, whence) _lseeki64(fdes, offset, whence) +# undef fstat +# define fstat(fdes, stp) _fstati64(fdes, stp) +# define struct_stat struct _stati64 +# define LSEEK_ERROR (__int64)-1 #elif defined(__DJGPP__) /* Requires DJGPP 2.04 */ # include diff --git a/lib/curlx/fopen.c b/lib/curlx/fopen.c index c9b7a9c0b590..75ff63901e81 100644 --- a/lib/curlx/fopen.c +++ b/lib/curlx/fopen.c @@ -28,7 +28,7 @@ int curlx_fseek(void *stream, curl_off_t offset, int whence) { -#if defined(_WIN32) && defined(USE_WIN32_LARGE_FILES) +#ifdef _WIN32 return _fseeki64(stream, (__int64)offset, whence); #elif defined(HAVE_FSEEKO) && defined(HAVE_DECL_FSEEKO) return fseeko(stream, (off_t)offset, whence); @@ -373,11 +373,7 @@ int curlx_win32_stat(const char *path, struct_stat *buffer) target = fixed; else target = path_w; -#ifndef USE_WIN32_LARGE_FILES - result = _wstat(target, buffer); -#else result = _wstati64(target, buffer); -#endif CURLX_FREE(path_w); } else @@ -388,11 +384,7 @@ int curlx_win32_stat(const char *path, struct_stat *buffer) target = fixed; else target = path; -#ifndef USE_WIN32_LARGE_FILES - result = _stat(target, buffer); -#else result = _stati64(target, buffer); -#endif #endif CURLX_FREE(fixed); diff --git a/lib/version.c b/lib/version.c index 79654fa9755c..fe4f637d6796 100644 --- a/lib/version.c +++ b/lib/version.c @@ -500,8 +500,7 @@ static const struct feat features_table[] = { #ifdef USE_KERBEROS5 FEATURE("Kerberos", NULL, CURL_VERSION_KERBEROS5), #endif -#if (SIZEOF_CURL_OFF_T > 4) && \ - ( (SIZEOF_OFF_T > 4) || defined(USE_WIN32_LARGE_FILES) ) +#if (SIZEOF_CURL_OFF_T > 4) && ((SIZEOF_OFF_T > 4) || defined(_WIN32)) FEATURE("Largefile", NULL, CURL_VERSION_LARGEFILE), #endif #ifdef HAVE_LIBZ diff --git a/src/tool_cb_see.c b/src/tool_cb_see.c index ea5c8e313b40..6c3cadc7f58f 100644 --- a/src/tool_cb_see.c +++ b/src/tool_cb_see.c @@ -38,7 +38,7 @@ int tool_seek_cb(void *userdata, curl_off_t offset, int whence) { struct per_transfer *per = userdata; -#if (SIZEOF_CURL_OFF_T > SIZEOF_OFF_T) && !defined(USE_WIN32_LARGE_FILES) +#if (SIZEOF_CURL_OFF_T > SIZEOF_OFF_T) && !defined(_WIN32) /* OUR_MAX_SEEK_L has 'long' data type, OUR_MAX_SEEK_O has 'curl_off_t, both represent the same value. Maximum offset used here when we lseek From a7c974e038572bd1d4a653afbd6de5fad5a10215 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Wed, 8 Oct 2025 16:20:54 +0200 Subject: [PATCH 262/415] DEPRECATE: add CMake <3.18 deprecation for April 2026 CMake 3.18 was released on 2020-07-15. It enables using (and/or dropping workarounds) for these features: LTO support, better performance and pkg-config support, `OBJECT` target, `-S`, `-B`, `--verbose`, `--install` on the command-line, lib directory support in interface targets, target_link_options(), LINK_OPTIONS, FetchContent, `list(PREPEND ...)`, unity, Ninja, fixed imported global issues. Ref: https://github.com/curl/curl/discussions/18704 Closes #19902 --- docs/DEPRECATE.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/DEPRECATE.md b/docs/DEPRECATE.md index 2a3cbfc78d88..2219bd32645e 100644 --- a/docs/DEPRECATE.md +++ b/docs/DEPRECATE.md @@ -50,6 +50,12 @@ RTMP in curl is powered by the 3rd party library librtmp. Support for RTMP in libcurl gets removed in April 2026. +## CMake 3.17 and earlier + +We remove support for CMake <3.18 in April 2026. + +CMake 3.18 was released on 2020-07-15. + ## Past removals - axTLS (removed in 7.63.0) From 920319855de090b0eacc27812baf71e82c178ea3 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Tue, 9 Dec 2025 22:26:41 +0100 Subject: [PATCH 263/415] mdlinkcheck: exclude self from URL search To avoid picking up the whitelist. Closes #19909 --- scripts/mdlinkcheck | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/mdlinkcheck b/scripts/mdlinkcheck index c28f7dd1ed1a..f83144108e39 100755 --- a/scripts/mdlinkcheck +++ b/scripts/mdlinkcheck @@ -197,7 +197,9 @@ sub checkurl { for my $f (@files) { chomp $f; - findlinks($f); + if($f !~ /\/mdlinkcheck$/) { + findlinks($f); + } } #for my $u (sort keys %url) { From 3fb932d49255d92141c27d3e9a040752622620b7 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Tue, 9 Dec 2025 23:27:34 +0100 Subject: [PATCH 264/415] mdlinkcheck: do not pick up single quote and backslash after URLs Closes #19910 --- scripts/mdlinkcheck | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/mdlinkcheck b/scripts/mdlinkcheck index f83144108e39..446cb9f1dd6e 100755 --- a/scripts/mdlinkcheck +++ b/scripts/mdlinkcheck @@ -160,10 +160,10 @@ sub findlinks { #print "$f:$line $link\n"; storelink($f, $line, $link); } - # ignore trailing: dot, quote, asterisk, hash, comma, question mark, - # colon, closing parenthesis, closing angle bracket, whitespace, pipe, - # backtick, semicolon - elsif(/(https:\/\/[a-z0-9.\/:%_+@-]+[^."*\#,?:\)> \t|`;])/i) { + # ignore trailing: dot, double quote, single quote, asterisk, hash, + # comma, question mark, colon, closing parenthesis, backslash, + # closing angle bracket, whitespace, pipe, backtick, semicolon + elsif(/(https:\/\/[a-z0-9.\/:%_+@-]+[^."'*\#,?:\)> \t|`;\\])/i) { #print "RAW "; storelink($f, $line, $1); } From bd19433b0ebbd719487577f8ffa25ba6bdb8f909 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Tue, 9 Dec 2025 20:06:33 +0100 Subject: [PATCH 265/415] build: set `-Wno-format-signedness` Explicitly disable these warnings to allow using `-Weverything`. There are around 600 of them across the codebase. Silencing them has some drawbacks: - enums (`CURLcode` mostly) would have to be cast to int to avoid different signedness depending on C compiler. (llvm/gcc: unsigned, MSVC/clang-cl: signed by default) - hex masks need casts to unsigned to avoid the warning. - fixing remaining warnings is annoying without fixing the above. - without fixing all warnings the option cannot be enabled, to keep the codebase warning free. Ref: #18343 (silenced all warnings, but without the enum cast) Follow-up to 92f215fea1aa8bd5b1709d38f42aab77ab3fc662 #18477 Closes #19907 --- CMake/PickyWarnings.cmake | 7 +++++++ m4/curl-compilers.m4 | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/CMake/PickyWarnings.cmake b/CMake/PickyWarnings.cmake index e9a0d61c0ef6..00451f7480bd 100644 --- a/CMake/PickyWarnings.cmake +++ b/CMake/PickyWarnings.cmake @@ -232,6 +232,12 @@ if(PICKY_COMPILER) -Wcast-function-type-strict # clang 16.0 appleclang 16.0 ) endif() + if((CMAKE_C_COMPILER_ID STREQUAL "Clang" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 19.1) OR + (CMAKE_C_COMPILER_ID STREQUAL "AppleClang" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 17.0)) + list(APPEND _picky_enable + -Wno-format-signedness # clang 19.1 gcc 5.1 appleclang 17.0 # In clang-cl enums are signed ints by default + ) + endif() if(CMAKE_C_COMPILER_ID STREQUAL "Clang" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 21.1) list(APPEND _picky_enable -Warray-compare # clang 20.1 gcc 12.0 appleclang ? @@ -282,6 +288,7 @@ if(PICKY_COMPILER) if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 5.0) list(APPEND _picky_enable -Warray-bounds=2 # clang 3.0 gcc 5.0 (clang default: -Warray-bounds) + -Wno-format-signedness # clang 19.1 gcc 5.1 appleclang 17.0 ) endif() if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 6.0) diff --git a/m4/curl-compilers.m4 b/m4/curl-compilers.m4 index dda5b7934ef3..343391d6020c 100644 --- a/m4/curl-compilers.m4 +++ b/m4/curl-compilers.m4 @@ -936,6 +936,10 @@ AC_DEFUN([CURL_SET_COMPILER_WARNING_OPTS], [ if test "$compiler_num" -ge "1700"; then CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [cast-function-type-strict]) # with Apple clang it requires 16.0 or above fi + dnl clang 19 or later + if test "$compiler_num" -ge "1901"; then + tmp_CFLAGS="$tmp_CFLAGS -Wno-format-signedness" + fi dnl clang 20 or later if test "$compiler_num" -ge "2001"; then CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [array-compare]) @@ -1115,6 +1119,7 @@ AC_DEFUN([CURL_SET_COMPILER_WARNING_OPTS], [ dnl Only gcc 5 or later if test "$compiler_num" -ge "500"; then tmp_CFLAGS="$tmp_CFLAGS -Warray-bounds=2" + tmp_CFLAGS="$tmp_CFLAGS -Wno-format-signedness" fi # dnl Only gcc 6 or later From d371288de73465efb1b26958150d04f8adfe6fd2 Mon Sep 17 00:00:00 2001 From: Stefan Eissing Date: Tue, 9 Dec 2025 17:00:52 +0100 Subject: [PATCH 266/415] test: increase altsvc test reliability Move new tests from test_12 to test_06 (eyeballing) where they better fit. Increase reliability by check Alt-Svc redirects from h3 to a lower version for a port where no h3 is available. Closes #19903 --- tests/http/test_06_eyeballs.py | 66 +++++++++++++++++++++ tests/http/test_12_reuse.py | 104 --------------------------------- 2 files changed, 66 insertions(+), 104 deletions(-) diff --git a/tests/http/test_06_eyeballs.py b/tests/http/test_06_eyeballs.py index 3b374e8158e3..6129ab5f1755 100644 --- a/tests/http/test_06_eyeballs.py +++ b/tests/http/test_06_eyeballs.py @@ -149,3 +149,69 @@ def test_06_20_h2_altsvc_h3_fallback(self, env: Env, httpd, nghttpx): r.check_exit_code(0) r.check_response(count=1, http_status=200) assert r.stats[0]['http_version'] == '2' + + @pytest.mark.skipif(condition=not Env.have_h3(), reason="h3 not supported") + def test_06_21_as_follow_h3h1(self, env: Env, httpd, configures_httpd, nghttpx): + # With '--http3` an Alt-Svc redirection from h3 to h1 is allowed + # write an alt-svc file the advises h1 instead of h3 + curl = CurlClient(env=env) + asfile = curl.mk_altsvc_file('test_12', + 'h3', env.domain1, env.https_only_tcp_port, + 'http/1.1', env.domain1, env.https_only_tcp_port) + urln = f'https://{env.domain1}:{env.https_only_tcp_port}/data.json' + r = curl.http_download(urls=[urln], with_stats=True, extra_args=[ + '--alt-svc', f'{asfile}', '--http3' + ]) + r.check_response(count=1, http_status=200) + # We expect the connection to be preferring HTTP/1.1 in the ALPN + assert r.total_connects == 1, f'{r.dump_logs()}' + re_m = re.compile(r'.* ALPN: curl offers http/1.1,h2') + lines = [line for line in r.trace_lines if re_m.match(line)] + assert len(lines), f'{r.dump_logs()}' + + @pytest.mark.skipif(condition=not Env.have_h3(), reason="h3 not supported") + def test_06_22_as_ignore_h3h1(self, env: Env, httpd, configures_httpd, nghttpx): + # With '--http3-only` an Alt-Svc redirection from h3 to h1 is ignored + # write an alt-svc file the advises h1 instead of h3 + curl = CurlClient(env=env) + asfile = curl.mk_altsvc_file('test_12', + 'h3', env.domain1, env.https_port, + 'http/1.1', env.domain1, env.https_port) + urln = f'https://{env.authority_for(env.domain1, "h3")}/data.json' + r = curl.http_download(urls=[urln], with_stats=True, extra_args=[ + '--alt-svc', f'{asfile}', '--http3-only' + ]) + r.check_response(count=1, http_status=200) + # We expect the connection to be stay on h3, since we used --http3-only + assert r.total_connects == 1 + assert r.stats[0]['http_version'] == '3', f'{r.stats}' + + @pytest.mark.skipif(condition=not Env.have_h3(), reason="h3 not supported") + def test_06_23_as_ignore_h2h3(self, env: Env, httpd, configures_httpd, nghttpx): + # With '--http2` an Alt-Svc redirection from h2 to h3 is ignored + # write an alt-svc file that advises h3 instead of h2 + curl = CurlClient(env=env) + asfile = curl.mk_altsvc_file('test_12', + 'h2', env.domain1, env.https_port, + 'h3', env.domain1, env.h3_port) + urln = f'https://{env.authority_for(env.domain1, "h2")}/data.json' + r = curl.http_download(urls=[urln], with_stats=True, extra_args=[ + '--alt-svc', f'{asfile}', '--http2' + ]) + r.check_response(count=1, http_status=200) + assert r.stats[0]['http_version'] == '2', f'{r.stats}' + + # download using HTTP/3 on available server with alt-svc to h2, use h2 + @pytest.mark.skipif(condition=not Env.have_h3(), reason="missing HTTP/3 support") + def test_06_24_h3_altsvc_h2_used(self, env: Env, httpd, nghttpx): + curl = CurlClient(env=env) + urln = f'https://{env.domain1}:{env.https_only_tcp_port}/data.json' + altsvc_file = curl.mk_altsvc_file('test_12', + 'h3', env.domain1, env.https_only_tcp_port, + 'h2', env.domain1, env.https_only_tcp_port) + r = curl.http_download(urls=[urln], extra_args=[ + '--http3', '--alt-svc', altsvc_file + ]) + r.check_exit_code(0) + r.check_response(count=1, http_status=200) + assert r.stats[0]['http_version'] == '2' diff --git a/tests/http/test_12_reuse.py b/tests/http/test_12_reuse.py index 522df92708cf..6f267d986283 100644 --- a/tests/http/test_12_reuse.py +++ b/tests/http/test_12_reuse.py @@ -25,9 +25,6 @@ ########################################################################### # import logging -import os -import re -from datetime import datetime, timedelta import pytest from testenv import Env, CurlClient @@ -75,104 +72,3 @@ def test_12_02_h1_conn_timeout(self, env: Env, httpd, configures_httpd, nghttpx, r.check_response(count=count, http_status=200) # Connections time out on server before we send another request, assert r.total_connects == count - - @pytest.mark.skipif(condition=not Env.have_h3(), reason="h3 not supported") - def test_12_03_as_follow_h2h3(self, env: Env, httpd, configures_httpd, nghttpx): - curl = CurlClient(env=env) - # write an alt-svc file that advises h3 instead of h2 - asfile = curl.mk_altsvc_file('test_12', - 'h2', env.domain1, env.https_port, - 'h3', env.domain1, env.h3_port) - urln = f'https://{env.authority_for(env.domain1, "h2")}/data.json' - r = curl.http_download(urls=[urln], with_stats=True, extra_args=[ - '--alt-svc', f'{asfile}', - ]) - r.check_response(count=1, http_status=200) - assert r.stats[0]['http_version'] == '3', f'{r.stats}' - - @pytest.mark.skipif(condition=not Env.have_h3(), reason="h3 not supported") - def test_12_04_as_follow_h3h2(self, env: Env, httpd, configures_httpd, nghttpx): - count = 2 - # write an alt-svc file the advises h2 instead of h3 - asfile = os.path.join(env.gen_dir, 'alt-svc-12_04.txt') - ts = datetime.now() + timedelta(hours=24) - expires = f'{ts.year:04}{ts.month:02}{ts.day:02} {ts.hour:02}:{ts.minute:02}:{ts.second:02}' - with open(asfile, 'w') as fd: - fd.write(f'h3 {env.domain1} {env.https_port} h2 {env.domain1} {env.https_port} "{expires}" 0 0') - log.info(f'altscv: {open(asfile).readlines()}') - curl = CurlClient(env=env) - urln = f'https://{env.authority_for(env.domain1, "h3")}/data.json?[0-{count-1}]' - r = curl.http_download(urls=[urln], with_stats=True, extra_args=[ - '--alt-svc', f'{asfile}', '--http3' - ]) - r.check_response(count=count, http_status=200) - # We expect the connection to be reused and use HTTP/2 - assert r.total_connects == 1 - for s in r.stats: - assert s['http_version'] == '2', f'{s}' - - @pytest.mark.skipif(condition=not Env.have_h3(), reason="h3 not supported") - def test_12_05_as_follow_h3h1(self, env: Env, httpd, configures_httpd, nghttpx): - # With '--http3` an Alt-Svc redirection from h3 to h1 is allowed - # write an alt-svc file the advises h1 instead of h3 - curl = CurlClient(env=env) - asfile = curl.mk_altsvc_file('test_12', - 'h3', env.domain1, env.https_port, - 'http/1.1', env.domain1, env.https_port) - urln = f'https://{env.authority_for(env.domain1, "h3")}/data.json' - r = curl.http_download(urls=[urln], with_stats=True, extra_args=[ - '--alt-svc', f'{asfile}', '--http3' - ]) - r.check_response(count=1, http_status=200) - # We expect the connection to be preferring HTTP/1.1 in the ALPN - assert r.total_connects == 1 - re_m = re.compile(r'.* ALPN: curl offers http/1.1,h2') - lines = [line for line in r.trace_lines if re_m.match(line)] - assert len(lines), f'{r.dump_logs()}' - - @pytest.mark.skipif(condition=not Env.have_h3(), reason="h3 not supported") - def test_12_06_as_ignore_h3h1(self, env: Env, httpd, configures_httpd, nghttpx): - # With '--http3-only` an Alt-Svc redirection from h3 to h1 is ignored - # write an alt-svc file the advises h1 instead of h3 - curl = CurlClient(env=env) - asfile = curl.mk_altsvc_file('test_12', - 'h3', env.domain1, env.https_port, - 'http/1.1', env.domain1, env.https_port) - urln = f'https://{env.authority_for(env.domain1, "h3")}/data.json' - r = curl.http_download(urls=[urln], with_stats=True, extra_args=[ - '--alt-svc', f'{asfile}', '--http3-only' - ]) - r.check_response(count=1, http_status=200) - # We expect the connection to be stay on h3, since we used --http3-only - assert r.total_connects == 1 - assert r.stats[0]['http_version'] == '3', f'{r.stats}' - - @pytest.mark.skipif(condition=not Env.have_h3(), reason="h3 not supported") - def test_12_07_as_ignore_h2h3(self, env: Env, httpd, configures_httpd, nghttpx): - # With '--http2` an Alt-Svc redirection from h2 to h3 is ignored - # write an alt-svc file that advises h3 instead of h2 - curl = CurlClient(env=env) - asfile = curl.mk_altsvc_file('test_12', - 'h2', env.domain1, env.https_port, - 'h3', env.domain1, env.h3_port) - urln = f'https://{env.authority_for(env.domain1, "h2")}/data.json' - r = curl.http_download(urls=[urln], with_stats=True, extra_args=[ - '--alt-svc', f'{asfile}', '--http2' - ]) - r.check_response(count=1, http_status=200) - assert r.stats[0]['http_version'] == '2', f'{r.stats}' - - # download using HTTP/3 on available server with alt-svc to h2, use h2 - @pytest.mark.skipif(condition=not Env.have_h3(), reason="missing HTTP/3 support") - def test_12_08_h3_altsvc_h2_used(self, env: Env, httpd, nghttpx): - curl = CurlClient(env=env) - urln = f'https://{env.domain1}:{env.https_port}/data.json' - altsvc_file = curl.mk_altsvc_file('test_12', - 'h3', env.domain1, env.https_port, - 'h2', env.domain1, env.https_port) - r = curl.http_download(urls=[urln], extra_args=[ - '--http3', '--alt-svc', altsvc_file - ]) - r.check_exit_code(0) - r.check_response(count=1, http_status=200) - assert r.stats[0]['http_version'] == '2' From 00f06127ce4e0d9115770a2896c816fde087ae71 Mon Sep 17 00:00:00 2001 From: Stefan Eissing Date: Tue, 9 Dec 2025 15:48:52 +0100 Subject: [PATCH 267/415] memdebug: fix realloc logging Do the whole realloc and the subsequent logging under mutex lock. This fixed log entries that state allocation a memory location before realloc logs it as being freed. Closes #19900 --- lib/memdebug.c | 88 +++++++++++++++++++++++++++++++++++++------------- 1 file changed, 65 insertions(+), 23 deletions(-) diff --git a/lib/memdebug.c b/lib/memdebug.c index 991c9eb921c3..05cd45a6f9bd 100644 --- a/lib/memdebug.c +++ b/lib/memdebug.c @@ -71,6 +71,29 @@ static bool dbg_mutex_init = 0; static curl_mutex_t dbg_mutex; #endif +static bool curl_dbg_lock(void) +{ +#if defined(USE_THREADS_POSIX) || defined(USE_THREADS_WIN32) + if(dbg_mutex_init) { + Curl_mutex_acquire(&dbg_mutex); + return TRUE; + } +#endif + return FALSE; +} + +static void curl_dbg_unlock(bool was_locked) +{ +#if defined(USE_THREADS_POSIX) || defined(USE_THREADS_WIN32) + if(was_locked) + Curl_mutex_release(&dbg_mutex); +#else + (void)was_locked; +#endif +} + +static void curl_dbg_log_locked(const char *format, ...) CURL_PRINTF(1, 2); + /* LeakSantizier (LSAN) calls _exit() instead of exit() when a leak is detected on exit so the logfile must be closed explicitly or data could be lost. Though _exit() does not call atexit handlers such as this, LSAN's call to @@ -295,6 +318,7 @@ void *curl_dbg_realloc(void *ptr, size_t wantedsize, int line, const char *source) { struct memdebug *mem = NULL; + bool was_locked; size_t size = sizeof(struct memdebug) + wantedsize; @@ -303,6 +327,10 @@ void *curl_dbg_realloc(void *ptr, size_t wantedsize, if(countcheck("realloc", line, source)) return NULL; + /* need to realloc under lock, as we get out-of-order log + * entries otherwise, since another thread might alloc the + * memory released by realloc() before otherwise would log it. */ + was_locked = curl_dbg_lock(); #ifdef __INTEL_COMPILER # pragma warning(push) # pragma warning(disable:1684) @@ -318,10 +346,11 @@ void *curl_dbg_realloc(void *ptr, size_t wantedsize, mem = (Curl_crealloc)(mem, size); if(source) - curl_dbg_log("MEM %s:%d realloc(%p, %zu) = %p\n", - source, line, (void *)ptr, wantedsize, - mem ? (void *)mem->mem : (void *)0); + curl_dbg_log_locked("MEM %s:%d realloc(%p, %zu) = %p\n", + source, line, (void *)ptr, wantedsize, + mem ? (void *)mem->mem : (void *)0); + curl_dbg_unlock(was_locked); if(mem) { mem->size = wantedsize; return mem->mem; @@ -522,29 +551,18 @@ int curl_dbg_fclose(FILE *file, int line, const char *source) return res; } -/* this does the writing to the memory tracking log file */ -void curl_dbg_log(const char *format, ...) +static void curl_dbg_vlog(const char * const fmt, + va_list ap) CURL_PRINTF(1, 0); + +static void curl_dbg_vlog(const char * const fmt, va_list ap) { char buf[1024]; - size_t nchars; - va_list ap; - - if(!curl_dbg_logfile) - return; - - va_start(ap, format); - nchars = curl_mvsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); + size_t nchars = curl_mvsnprintf(buf, sizeof(buf), fmt, ap); if(nchars > (int)sizeof(buf) - 1) nchars = (int)sizeof(buf) - 1; if(nchars > 0) { -#if defined(USE_THREADS_POSIX) || defined(USE_THREADS_WIN32) - bool lock_mutex = dbg_mutex_init; - if(lock_mutex) - Curl_mutex_acquire(&dbg_mutex); -#endif if(sizeof(membuf) - nchars < memwidx) { /* flush */ fwrite(membuf, 1, memwidx, curl_dbg_logfile); @@ -557,11 +575,35 @@ void curl_dbg_log(const char *format, ...) } memcpy(&membuf[memwidx], buf, nchars); memwidx += nchars; -#if defined(USE_THREADS_POSIX) || defined(USE_THREADS_WIN32) - if(lock_mutex) - Curl_mutex_release(&dbg_mutex); -#endif } } +static void curl_dbg_log_locked(const char *format, ...) +{ + va_list ap; + + if(!curl_dbg_logfile) + return; + + va_start(ap, format); + curl_dbg_vlog(format, ap); + va_end(ap); +} + +/* this does the writing to the memory tracking log file */ +void curl_dbg_log(const char *format, ...) +{ + bool was_locked; + va_list ap; + + if(!curl_dbg_logfile) + return; + + was_locked = curl_dbg_lock(); + va_start(ap, format); + curl_dbg_vlog(format, ap); + va_end(ap); + curl_dbg_unlock(was_locked); +} + #endif /* CURLDEBUG */ From d9d2e339ced3fa02dd0e72e68b0a9b68069c0801 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Tue, 9 Dec 2025 21:24:28 +0100 Subject: [PATCH 268/415] tidy-up: URLs (cont.) and mdlinkcheck - add missing ending slashes. To avoid duplicates and to use canonical URLs. - reapply lost updates. Follow-up to 2ae983bf4ea5ef86f0e68ea0ff219a91b1aa3428 #19879 - mdlinkcheck: include the `include` directory. - mdlinkcheck: show unused whitelist items. - mdlinkcheck: improve debug output. - mdlinkcheck: delete redundant whitelist items. - examples/simplessl: lowercase the protocol part. - BINDINGS: replace one remaining HTTP URL with HTTPS. Issue: https://github.com/pycurl/pycurl/issues/892 - BINDINGS: fix a broken link. - BINDINGS: follow a refresh content redirect. - KNOWN_BUGS: whitespace. Closes #19911 --- docs/BINDINGS.md | 6 +- docs/FAQ.md | 16 ++--- docs/INFRASTRUCTURE.md | 6 +- docs/KNOWN_BUGS.md | 16 ++--- docs/TODO.md | 4 +- docs/TheArtOfHttpScripting.md | 4 +- docs/cmdline-opts/_WWW.md | 2 +- docs/examples/10-at-a-time.c | 90 +++++++++++++-------------- docs/examples/crawler.c | 2 +- docs/examples/maxconnects.c | 4 +- docs/examples/simplessl.c | 2 +- docs/internals/CONNECTION-FILTERS.md | 8 +-- docs/tests/TEST-SUITE.md | 4 +- lib/curl_rtmp.c | 2 +- packages/vms/curl_gnv_build_steps.txt | 2 +- scripts/mdlinkcheck | 21 ++++--- 16 files changed, 98 insertions(+), 91 deletions(-) diff --git a/docs/BINDINGS.md b/docs/BINDINGS.md index 065126efd723..56f0376b6415 100644 --- a/docs/BINDINGS.md +++ b/docs/BINDINGS.md @@ -49,7 +49,7 @@ Clojure: [clj-curl](https://github.com/lsevero/clj-curl) by Lucas Severo [Fortran](https://github.com/interkosmos/fortran-curl) Written by Philipp Engel -[Gambas](https://gambas.sourceforge.net/) +[Gambas](https://gambaswiki.org/website/en/main.html) [glib/GTK+](https://web.archive.org/web/20100526203452/atterer.net/glibcurl) Written by Richard Atterer @@ -102,7 +102,7 @@ Bailiff and Bálint Szilakszi, [PureBasic](https://web.archive.org/web/20250325015028/www.purebasic.com/documentation/http/index.html) uses libcurl in its "native" HTTP subsystem -[Python](http://pycurl.io/) PycURL by Kjetil Jacobsen +[Python](https://github.com/pycurl/pycurl) PycURL by Kjetil Jacobsen [Python](https://pypi.org/project/pymcurl/) mcurl by Ganesh Viswanathan @@ -112,7 +112,7 @@ Bailiff and Bálint Szilakszi, [Rexx](https://rexxcurl.sourceforge.net/) Written Mark Hessling -[Ring](https://ring-lang.sourceforge.io/doc1.3/libcurl.html) RingLibCurl by Mahmoud Fayed +[Ring](https://ring-lang.github.io/doc1.24/libcurl.html) RingLibCurl by Mahmoud Fayed RPG, support for ILE/RPG on OS/400 is included in source distribution diff --git a/docs/FAQ.md b/docs/FAQ.md index f6911990d94b..eba30f1fefd5 100644 --- a/docs/FAQ.md +++ b/docs/FAQ.md @@ -303,7 +303,7 @@ library comparison](https://curl.se/docs/ssl-compared.html). The curl tool that is shipped as an integrated component of Windows 10 and Windows 11 is managed by Microsoft. If you were to delete the file or replace it with a newer version downloaded from [the curl -website](https://curl.se/windows), then Windows Update will cease to work on +website](https://curl.se/windows/), then Windows Update will cease to work on your system. There is no way to independently force an upgrade of the curl.exe that is part @@ -312,7 +312,7 @@ also nothing the curl project itself can do about this, since this is managed and controlled entirely by Microsoft as owners of the operating system. You can always download and install [the latest version of curl for -Windows](https://curl.se/windows) into a separate location. +Windows](https://curl.se/windows/) into a separate location. ## Does curl support SOCKS (RFC 1928) ? @@ -908,12 +908,12 @@ format: you will find that even if `D:\blah.txt` does exist, curl returns a 'file not found' error. -According to [RFC 1738](https://www.ietf.org/rfc/rfc1738.txt), `file://` URLs -must contain a host component, but it is ignored by most implementations. In -the above example, `D:` is treated as the host component, and is taken away. -Thus, curl tries to open `/blah.txt`. If your system is installed to drive C:, -that will resolve to `C:\blah.txt`, and if that does not exist you will get -the not found error. +According to [RFC 1738](https://datatracker.ietf.org/doc/html/rfc1738), +`file://` URLs must contain a host component, but it is ignored by most +implementations. In the above example, `D:` is treated as the host component, +and is taken away. Thus, curl tries to open `/blah.txt`. If your system is +installed to drive C:, that will resolve to `C:\blah.txt`, and if that does +not exist you will get the not found error. To fix this problem, use `file://` URLs with *three* leading slashes: diff --git a/docs/INFRASTRUCTURE.md b/docs/INFRASTRUCTURE.md index 13240b31b5fa..7a6bafb9dbab 100644 --- a/docs/INFRASTRUCTURE.md +++ b/docs/INFRASTRUCTURE.md @@ -100,11 +100,11 @@ company). The machine is physically located in Sweden. curl release tarballs are hosted on https://curl.se/download.html. They are uploaded there at release-time by the release manager. -curl-for-win downloads are hosted on https://curl.se/windows and are uploaded +curl-for-win downloads are hosted on https://curl.se/windows/ and are uploaded to the server by Viktor Szakats. -curl-for-QNX downloads are hosted on and are uploaded to -the server by Daniel Stenberg. +curl-for-QNX downloads are hosted on and are uploaded +to the server by Daniel Stenberg. Daily release tarball-like snapshots are generated automatically and are provided for download at . diff --git a/docs/KNOWN_BUGS.md b/docs/KNOWN_BUGS.md index 1f5cebee27c7..83a30fd9e897 100644 --- a/docs/KNOWN_BUGS.md +++ b/docs/KNOWN_BUGS.md @@ -161,7 +161,7 @@ Passing in a Unicode filename with -o: Passing in Unicode character with -d: - [curl issue 12231](https://github.com/curl/curl/issues/12231) +[curl issue 12231](https://github.com/curl/curl/issues/12231) Windows Unicode builds use the home directory in current locale. @@ -215,8 +215,10 @@ what `winhttp` does. See https://curl.se/bug/view.cgi?id=535 ## NTLM does not support password with Unicode 'SECTION SIGN' character - https://en.wikipedia.org/wiki/Section_sign - [curl issue 2120](https://github.com/curl/curl/issues/2120) +Code point: U+00A7 + +https://en.wikipedia.org/wiki/Section_sign +[curl issue 2120](https://github.com/curl/curl/issues/2120) ## libcurl can fail to try alternatives with `--proxy-any` @@ -231,7 +233,7 @@ using NTLM. ## Do not clear digest for single realm - [curl issue 3267](https://github.com/curl/curl/issues/3267) +[curl issue 3267](https://github.com/curl/curl/issues/3267) ## SHA-256 digest not supported in Windows SSPI builds @@ -243,7 +245,7 @@ with `SEC_E_QOP_NOT_SUPPORTED` which causes curl to fail with Microsoft does not document supported digest algorithms and that `SEC_E` error code is not a documented error for `InitializeSecurityContext` (digest). - [curl issue 6302](https://github.com/curl/curl/issues/6302) +[curl issue 6302](https://github.com/curl/curl/issues/6302) ## curl never completes Negotiate over HTTP @@ -306,7 +308,7 @@ In the `SSH_SFTP_INIT` state for libssh, the ssh session working mode is set to blocking mode. If the network is suddenly disconnected during sftp transmission, curl is stuck, even if curl is configured with a timeout. - [curl issue 8632](https://github.com/curl/curl/issues/8632) +[curl issue 8632](https://github.com/curl/curl/issues/8632) ## Cygwin: "WARNING: UNPROTECTED PRIVATE KEY FILE!" @@ -494,7 +496,7 @@ cannot be built. ## HTTP/2 prior knowledge over proxy - [curl issue 12641](https://github.com/curl/curl/issues/12641) +[curl issue 12641](https://github.com/curl/curl/issues/12641) ## HTTP/2 frames while in the connection pool kill reuse diff --git a/docs/TODO.md b/docs/TODO.md index 2b77b8ce0b9e..0224ae87332c 100644 --- a/docs/TODO.md +++ b/docs/TODO.md @@ -530,8 +530,8 @@ for 1) efficiency and 2) safety. ## Support DANE [DNS-Based Authentication of Named Entities -(DANE)](https://www.rfc-editor.org/rfc/rfc6698.txt) is a way to provide SSL -keys and certs over DNS using DNSSEC as an alternative to the CA model. +(DANE)](https://datatracker.ietf.org/doc/html/rfc6698) is a way to provide +SSL keys and certs over DNS using DNSSEC as an alternative to the CA model. A patch was posted on March 7 2013 (https://curl.se/mail/lib-2013-03/0075.html) but it was a too simple approach. diff --git a/docs/TheArtOfHttpScripting.md b/docs/TheArtOfHttpScripting.md index f7cf43602d90..ab4961c5781c 100644 --- a/docs/TheArtOfHttpScripting.md +++ b/docs/TheArtOfHttpScripting.md @@ -91,7 +91,7 @@ SPDX-License-Identifier: curl The Uniform Resource Locator format is how you specify the address of a particular resource on the Internet. You know these, you have seen URLs like - https://curl.se or https://example.com a million times. RFC 3986 is the + https://curl.se/ or https://example.com/ a million times. RFC 3986 is the canonical spec. The formal name is not URL, it is **URI**. ## Host @@ -158,7 +158,7 @@ SPDX-License-Identifier: curl issues a GET request to the server and receives the document it asked for. If you issue the command line - curl https://curl.se + curl https://curl.se/ you get a webpage returned in your terminal window. The entire HTML document this URL identifies. diff --git a/docs/cmdline-opts/_WWW.md b/docs/cmdline-opts/_WWW.md index 35d946697f94..8656e9ee8c8f 100644 --- a/docs/cmdline-opts/_WWW.md +++ b/docs/cmdline-opts/_WWW.md @@ -1,4 +1,4 @@ # WWW -https://curl.se +https://curl.se/ diff --git a/docs/examples/10-at-a-time.c b/docs/examples/10-at-a-time.c index 08f1f25f7f7f..db420eebfb67 100644 --- a/docs/examples/10-at-a-time.c +++ b/docs/examples/10-at-a-time.c @@ -31,53 +31,53 @@ #include static const char *urls[] = { - "https://www.microsoft.com", - "https://opensource.org", - "https://www.google.com", - "https://www.yahoo.com", - "https://www.ibm.com", - "https://www.mysql.com", - "https://www.oracle.com", - "https://www.ripe.net", - "https://www.iana.org", - "https://www.amazon.com", - "https://www.netcraft.com", - "https://www.heise.de", - "https://www.chip.de", - "https://www.ca.com", - "https://www.cnet.com", - "https://www.mozilla.org", - "https://www.cnn.com", - "https://www.wikipedia.org", - "https://www.dell.com", - "https://www.hp.com", - "https://www.cert.org", - "https://www.mit.edu", - "https://www.nist.gov", - "https://www.ebay.com", - "https://www.playstation.com", - "https://www.uefa.com", - "https://www.ieee.org", - "https://www.apple.com", - "https://www.symantec.com", - "https://www.zdnet.com", + "https://www.microsoft.com/", + "https://opensource.org/", + "https://www.google.com/", + "https://www.yahoo.com/", + "https://www.ibm.com/", + "https://www.mysql.com/", + "https://www.oracle.com/", + "https://www.ripe.net/", + "https://www.iana.org/", + "https://www.amazon.com/", + "https://www.netcraft.com/", + "https://www.heise.de/", + "https://www.chip.de/", + "https://www.ca.com/", + "https://www.cnet.com/", + "https://www.mozilla.org/", + "https://www.cnn.com/", + "https://www.wikipedia.org/", + "https://www.dell.com/", + "https://www.hp.com/", + "https://www.cert.org/", + "https://www.mit.edu/", + "https://www.nist.gov/", + "https://www.ebay.com/", + "https://www.playstation.com/", + "https://www.uefa.com/", + "https://www.ieee.org/", + "https://www.apple.com/", + "https://www.symantec.com/", + "https://www.zdnet.com/", "https://www.fujitsu.com/global/", - "https://www.supermicro.com", - "https://www.hotmail.com", - "https://www.ietf.org", - "https://www.bbc.co.uk", - "https://news.google.com", - "https://www.foxnews.com", - "https://www.msn.com", - "https://www.wired.com", - "https://www.sky.com", - "https://www.usatoday.com", - "https://www.cbs.com", + "https://www.supermicro.com/", + "https://www.hotmail.com/", + "https://www.ietf.org/", + "https://www.bbc.co.uk/", + "https://news.google.com/", + "https://www.foxnews.com/", + "https://www.msn.com/", + "https://www.wired.com/", + "https://www.sky.com/", + "https://www.usatoday.com/", + "https://www.cbs.com/", "https://www.nbc.com/", - "https://slashdot.org", - "https://www.informationweek.com", - "https://apache.org", - "https://www.un.org", + "https://slashdot.org/", + "https://www.informationweek.com/", + "https://apache.org/", + "https://www.un.org/", }; #define MAX_PARALLEL 10 /* number of simultaneous transfers */ diff --git a/docs/examples/crawler.c b/docs/examples/crawler.c index 09c0c7d6923f..d153cc21c5ac 100644 --- a/docs/examples/crawler.c +++ b/docs/examples/crawler.c @@ -47,7 +47,7 @@ static int max_total = 20000; static int max_requests = 500; static size_t max_link_per_page = 5; static int follow_relative_links = 0; -static const char *start_page = "https://www.reuters.com"; +static const char *start_page = "https://www.reuters.com/"; static int pending_interrupt = 0; static void sighandler(int dummy) diff --git a/docs/examples/maxconnects.c b/docs/examples/maxconnects.c index 2ee1d305a93f..95231d600268 100644 --- a/docs/examples/maxconnects.c +++ b/docs/examples/maxconnects.c @@ -40,8 +40,8 @@ int main(void) curl = curl_easy_init(); if(curl) { const char *urls[] = { - "https://example.com", - "https://curl.se", + "https://example.com/", + "https://curl.se/", "https://www.example/", NULL /* end of list */ }; diff --git a/docs/examples/simplessl.c b/docs/examples/simplessl.c index d08da207bfbf..c60b91057e9a 100644 --- a/docs/examples/simplessl.c +++ b/docs/examples/simplessl.c @@ -84,7 +84,7 @@ int main(void) goto error; /* what call to write: */ - curl_easy_setopt(curl, CURLOPT_URL, "HTTPS://secure.site.example"); + curl_easy_setopt(curl, CURLOPT_URL, "https://secure.site.example/"); curl_easy_setopt(curl, CURLOPT_HEADERDATA, headerfile); #ifdef USE_ENGINE diff --git a/docs/internals/CONNECTION-FILTERS.md b/docs/internals/CONNECTION-FILTERS.md index 09acc7ad9560..08fb36738578 100644 --- a/docs/internals/CONNECTION-FILTERS.md +++ b/docs/internals/CONNECTION-FILTERS.md @@ -233,7 +233,7 @@ Users of `curl` may activate them by adding the name of the filter type to the of an HTTP/2 request, invoke curl with: ``` -> curl -v --trace-config ids,time,http/2 https://curl.se +> curl -v --trace-config ids,time,http/2 https://curl.se/ ``` Which gives you trace output with time information, transfer+connection ids @@ -260,7 +260,7 @@ into IPv4 and IPv6 and makes parallel attempts. The connection filter chain looks like this: ``` -* create connection for http://curl.se +* create connection for http://curl.se/ conn[curl.se] --> SETUP[TCP] --> HAPPY-EYEBALLS --> NULL * start connect conn[curl.se] --> SETUP[TCP] --> HAPPY-EYEBALLS --> NULL @@ -276,7 +276,7 @@ The modular design of connection filters and that we can plug them into each oth The `HAPPY-EYEBALLS` on the other hand stays focused on its side of the problem. We can use it also to make other type of connection by just giving it another filter type to try to have happy eyeballing for QUIC: ``` -* create connection for --http3-only https://curl.se +* create connection for --http3-only https://curl.se/ conn[curl.se] --> SETUP[QUIC] --> HAPPY-EYEBALLS --> NULL * start connect conn[curl.se] --> SETUP[QUIC] --> HAPPY-EYEBALLS --> NULL @@ -292,7 +292,7 @@ type that is used for `--http3` when **both** HTTP/3 and HTTP/2 or HTTP/1.1 shall be attempted: ``` -* create connection for --http3 https://curl.se +* create connection for --http3 https://curl.se/ conn[curl.se] --> HTTPS-CONNECT --> NULL * start connect conn[curl.se] --> HTTPS-CONNECT --> NULL diff --git a/docs/tests/TEST-SUITE.md b/docs/tests/TEST-SUITE.md index 527a8599eafd..6a2e60c81759 100644 --- a/docs/tests/TEST-SUITE.md +++ b/docs/tests/TEST-SUITE.md @@ -214,13 +214,13 @@ SPDX-License-Identifier: curl to drown in output. The newly introduced *connection filters* allows one to dynamically increase log verbosity for a particular *filter type*. Example: - CURL_DEBUG=ssl curl -v https://curl.se + CURL_DEBUG=ssl curl -v https://curl.se/ makes the `ssl` connection filter log more details. One may do that for every filter type and also use a combination of names, separated by `,` or space. - CURL_DEBUG=ssl,http/2 curl -v https://curl.se + CURL_DEBUG=ssl,http/2 curl -v https://curl.se/ The order of filter type names is not relevant. Names used here are case insensitive. Note that these names are implementation internals and diff --git a/lib/curl_rtmp.c b/lib/curl_rtmp.c index e0597cdcca92..45a50674f50b 100644 --- a/lib/curl_rtmp.c +++ b/lib/curl_rtmp.c @@ -62,7 +62,7 @@ static Curl_recv rtmp_recv; static Curl_send rtmp_send; /* - * RTMP protocol handler.h, based on https://rtmpdump.mplayerhq.hu + * RTMP protocol handler.h, based on https://rtmpdump.mplayerhq.hu/ */ const struct Curl_handler Curl_handler_rtmp = { diff --git a/packages/vms/curl_gnv_build_steps.txt b/packages/vms/curl_gnv_build_steps.txt index 0c30924998ea..c84431f7faee 100644 --- a/packages/vms/curl_gnv_build_steps.txt +++ b/packages/vms/curl_gnv_build_steps.txt @@ -38,7 +38,7 @@ time that this document was written. [gnv.common_src]curl_*_original_src.bck is the original source of the curl kit as provided by the curl project. [gnv.vms_src]curl-*_vms_src.bck, if present, has the OpenVMS specific files that are used for building that are not yet in -the curl source kits for that release distributed https://curl.se +the curl source kits for that release distributed https://curl.se/ These backup savesets should be restored to different directory trees on an ODS-5 volume(s) which are referenced by concealed rooted logical names. diff --git a/scripts/mdlinkcheck b/scripts/mdlinkcheck index 446cb9f1dd6e..f50d77527a29 100755 --- a/scripts/mdlinkcheck +++ b/scripts/mdlinkcheck @@ -71,14 +71,12 @@ my %whitelist = ( 'https://curl.se/rfc/rfc2255.txt' => 1, 'https://curl.se/sponsors.html' => 1, 'https://curl.se/support.html' => 1, - 'https://curl.se/windows' => 1, 'https://curl.se/windows/' => 1, 'https://testclutch.curl.se/' => 1, 'https://github.com/curl/curl-fuzzer' => 1, 'https://github.com/curl/curl-www' => 1, - 'https://github.com/curl/curl.git' => 1, 'https://github.com/curl/curl/wcurl' => 1, ); @@ -87,7 +85,7 @@ my %url; my %flink; # list all files to scan for links -my @files=`git ls-files docs src lib scripts`; +my @files=`git ls-files docs include lib scripts src`; sub storelink { my ($f, $line, $link) = @_; @@ -103,6 +101,7 @@ sub storelink { if($link =~ /^(https|http):/) { if($whitelist{$link}) { #print "-- whitelisted: $link\n"; + $whitelist{$link}++; } # example.com is just example elsif($link =~ /^https:\/\/(.*)example.(com|org|net)/) { @@ -164,7 +163,7 @@ sub findlinks { # comma, question mark, colon, closing parenthesis, backslash, # closing angle bracket, whitespace, pipe, backtick, semicolon elsif(/(https:\/\/[a-z0-9.\/:%_+@-]+[^."'*\#,?:\)> \t|`;\\])/i) { - #print "RAW "; + #print "RAW '$_'\n"; storelink($f, $line, $1); } $line++; @@ -202,10 +201,16 @@ for my $f (@files) { } } -#for my $u (sort keys %url) { -# print "$u\n"; -#} -#exit; +for my $u (sort keys %whitelist) { + if($whitelist{$u} == 1) { + printf "warning: unused whitelist entry: '$u'\n"; + } +} + +for my $u (sort keys %url) { + print "$u\n"; +} +exit; my $error; my @errlist; From 6532398af4b0bbde31d7b25a8896beaf143fa86a Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 10 Dec 2025 01:51:54 +0000 Subject: [PATCH 269/415] GHA: update dependencies and actions - update dependency awslabs/aws-lc to v1.65.1 - update dependency pizlonator/fil-c to v0.676 - update github/codeql-action action to v4.31.7 Closes #19905 Closes #19912 Closes #19913 --- .github/workflows/codeql.yml | 8 ++++---- .github/workflows/http3-linux.yml | 2 +- .github/workflows/linux.yml | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 9ee723cf73ec..32220298077e 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -50,13 +50,13 @@ jobs: persist-credentials: false - name: 'initialize' - uses: github/codeql-action/init@014f16e7ab1402f30e7c3329d33797e7948572db # v4.31.3 + uses: github/codeql-action/init@cf1bb45a277cb3c205638b2cd5c984db1c46a412 # v4.31.7 with: languages: actions, python queries: security-extended - name: 'perform analysis' - uses: github/codeql-action/analyze@014f16e7ab1402f30e7c3329d33797e7948572db # v4.31.3 + uses: github/codeql-action/analyze@cf1bb45a277cb3c205638b2cd5c984db1c46a412 # v4.31.7 c: if: ${{ github.repository_owner == 'curl' || github.event_name != 'schedule' }} @@ -87,7 +87,7 @@ jobs: persist-credentials: false - name: 'initialize' - uses: github/codeql-action/init@014f16e7ab1402f30e7c3329d33797e7948572db # v4.31.3 + uses: github/codeql-action/init@cf1bb45a277cb3c205638b2cd5c984db1c46a412 # v4.31.7 with: languages: cpp build-mode: manual @@ -131,4 +131,4 @@ jobs: fi - name: 'perform analysis' - uses: github/codeql-action/analyze@014f16e7ab1402f30e7c3329d33797e7948572db # v4.31.3 + uses: github/codeql-action/analyze@cf1bb45a277cb3c205638b2cd5c984db1c46a412 # v4.31.7 diff --git a/.github/workflows/http3-linux.yml b/.github/workflows/http3-linux.yml index 77fd1edc09aa..86c9f3459d7c 100644 --- a/.github/workflows/http3-linux.yml +++ b/.github/workflows/http3-linux.yml @@ -43,7 +43,7 @@ env: # renovate: datasource=github-tags depName=libressl/portable versioning=semver registryUrl=https://github.com LIBRESSL_VERSION: 4.2.1 # renovate: datasource=github-tags depName=awslabs/aws-lc versioning=semver registryUrl=https://github.com - AWSLC_VERSION: 1.63.0 + AWSLC_VERSION: 1.65.1 # renovate: datasource=github-tags depName=google/boringssl versioning=semver registryUrl=https://github.com BORINGSSL_VERSION: 0.20251124.0 # renovate: datasource=github-tags depName=gnutls/nettle versioning=semver registryUrl=https://github.com diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 27ad6b739331..2bcdf4e223ba 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -46,7 +46,7 @@ env: # renovate: datasource=github-tags depName=Mbed-TLS/mbedtls versioning=semver:^3.0.0 registryUrl=https://github.com MBEDTLS_VERSION_PREV: 3.6.4 # renovate: datasource=github-tags depName=awslabs/aws-lc versioning=semver registryUrl=https://github.com - AWSLC_VERSION: 1.63.0 + AWSLC_VERSION: 1.65.1 # renovate: datasource=github-tags depName=google/boringssl versioning=semver registryUrl=https://github.com BORINGSSL_VERSION: 0.20251124.0 # handled in renovate.json @@ -58,7 +58,7 @@ env: # renovate: datasource=github-tags depName=nghttp2/nghttp2 versioning=semver registryUrl=https://github.com NGHTTP2_VERSION: 1.68.0 # renovate: datasource=github-tags depName=pizlonator/fil-c versioning=semver-coerced registryUrl=https://github.com - FIL_C_VERSION: 0.675 + FIL_C_VERSION: 0.676 jobs: linux: From b11b67c96fe2b027c6985f7071b33b5a2d36b65e Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 10 Dec 2025 09:29:43 +0100 Subject: [PATCH 270/415] test318: tweak the name a little to make it properly differ from test 317 --- tests/data/test318 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/data/test318 b/tests/data/test318 index 990b6371a011..8d42d0c68112 100644 --- a/tests/data/test318 +++ b/tests/data/test318 @@ -62,7 +62,7 @@ contents http -HTTP with custom Authorization: and redirect to new host +HTTP with custom Authorization: then trusted redirect to new host http://first.host.it.is/we/want/that/page/%TESTNUMBER -x %HOSTIP:%HTTPPORT -H "Authorization: s3cr3t" --proxy-user testing:this --location-trusted From 2180d7b4bc126b1920eab139f9ca0b253e7c02f0 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 10 Dec 2025 09:19:32 +0100 Subject: [PATCH 271/415] CURLOPT_FOLLOWLOCATION.md: s/Authentication:/Authorization:/ Closes #19915 --- docs/libcurl/opts/CURLOPT_FOLLOWLOCATION.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/libcurl/opts/CURLOPT_FOLLOWLOCATION.md b/docs/libcurl/opts/CURLOPT_FOLLOWLOCATION.md index f3e3b99bd3aa..f67f85c6f2f4 100644 --- a/docs/libcurl/opts/CURLOPT_FOLLOWLOCATION.md +++ b/docs/libcurl/opts/CURLOPT_FOLLOWLOCATION.md @@ -63,7 +63,7 @@ or just lacks features, it is easy to instead implement your own redirect follow logic with the use of curl_easy_getinfo(3)'s CURLINFO_REDIRECT_URL(3) option instead of using CURLOPT_FOLLOWLOCATION(3). -By default, libcurl only sends `Authentication:` or explicitly set `Cookie:` +By default, libcurl only sends `Authorization:` or explicitly set `Cookie:` headers to the initial host given in the original URL, to avoid leaking username + password to other sites. CURLOPT_UNRESTRICTED_AUTH(3) is provided to change that behavior. From 26d766596e12e0ca9b00422789a8b6afbc0c7fe8 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 10 Dec 2025 08:45:34 +0100 Subject: [PATCH 272/415] mdlinkcheck: add --dry-run to only show all found URLs - remove the debug tracing leftovers from d9d2e339ced3fa02 that made exit unconditonally Closes #19914 --- scripts/mdlinkcheck | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/scripts/mdlinkcheck b/scripts/mdlinkcheck index f50d77527a29..bd54d96fe2ea 100755 --- a/scripts/mdlinkcheck +++ b/scripts/mdlinkcheck @@ -84,6 +84,12 @@ my %whitelist = ( my %url; my %flink; +my $dry; +if(defined $ARGV[0] && $ARGV[0] eq "--dry-run") { + $dry = 1; + shift @ARGV; +} + # list all files to scan for links my @files=`git ls-files docs include lib scripts src`; @@ -207,10 +213,12 @@ for my $u (sort keys %whitelist) { } } -for my $u (sort keys %url) { - print "$u\n"; +if($dry) { + for my $u (sort keys %url) { + print "$u\n"; + } + exit; } -exit; my $error; my @errlist; From 0b96f7573f18fd1fbc6317e0ef232d20a40cc874 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Wed, 10 Dec 2025 11:47:40 +0100 Subject: [PATCH 273/415] GHA/checkurls: add dry run on push To verify if the basics work. Downside is that the scheduled (live) runs are intermixed with the dry runs and less obvious to find in the default list: https://github.com/curl/curl/actions/workflows/checkurls.yml This URL filters for scheduled runs only: https://github.com/curl/curl/actions/workflows/checkurls.yml?query=event%3Aschedule Seems fine, because we're only interested in red runs. Closes #19917 --- .github/workflows/checkurls.yml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/checkurls.yml b/.github/workflows/checkurls.yml index f407859c75fd..b9d5f185d485 100644 --- a/.github/workflows/checkurls.yml +++ b/.github/workflows/checkurls.yml @@ -5,6 +5,13 @@ name: 'URLs' 'on': + push: + branches: + - master + - '*/ci' + pull_request: + branches: + - master schedule: - cron: '10 5 * * *' @@ -16,7 +23,7 @@ permissions: {} jobs: linkcheck: - if: ${{ github.repository_owner == 'curl' }} + if: ${{ github.repository_owner == 'curl' || github.event_name != 'schedule' }} name: 'linkcheck' runs-on: ubuntu-latest steps: @@ -24,5 +31,10 @@ jobs: with: persist-credentials: false + - name: 'mdlinkcheck (dry run)' + if: ${{ github.event_name != 'schedule' }} + run: ./scripts/mdlinkcheck --dry-run + - name: 'mdlinkcheck' + if: ${{ github.event_name == 'schedule' }} run: ./scripts/mdlinkcheck From 14478429e71ef0eee6d12b73113e9ff8e3ae9e75 Mon Sep 17 00:00:00 2001 From: Stefan Eissing Date: Wed, 10 Dec 2025 11:17:49 +0100 Subject: [PATCH 274/415] pytest: quiche flakiness Let nghttpx only use http/1.1 to backend. This reproduces the bug in quiche with higher frequency. Allow test_14_05 to now return a 400 in addition to the 431 we get from a h2 backend to nghttpx. Skip test_05_02 in h3 on quiche not newer than version 0.24.4 in which its bug is fixed: https://github.com/cloudflare/quiche/pull/2278 Ref: https://github.com/cloudflare/quiche/issues/2277 Closes #19770 (original Issue) Closes #19916 --- tests/http/test_05_errors.py | 3 +++ tests/http/test_14_auth.py | 5 +++-- tests/http/testenv/nghttpx.py | 1 - 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/http/test_05_errors.py b/tests/http/test_05_errors.py index 102b92e20256..5fada1500593 100644 --- a/tests/http/test_05_errors.py +++ b/tests/http/test_05_errors.py @@ -60,6 +60,9 @@ def test_05_01_partial_1(self, env: Env, httpd, nghttpx, proto): def test_05_02_partial_20(self, env: Env, httpd, nghttpx, proto): if proto == 'h3' and env.curl_uses_ossl_quic(): pytest.skip("openssl-quic is flaky in yielding proper error codes") + if proto == 'h3' and env.curl_uses_lib('quiche') and \ + not env.curl_lib_version_at_least('quiche', '0.24.5'): + pytest.skip("quiche issue #2277 not fixed") count = 20 curl = CurlClient(env=env) urln = f'https://{env.authority_for(env.domain1, proto)}' \ diff --git a/tests/http/test_14_auth.py b/tests/http/test_14_auth.py index 0187c76a6a70..9f2ae7a27f0f 100644 --- a/tests/http/test_14_auth.py +++ b/tests/http/test_14_auth.py @@ -107,8 +107,9 @@ def test_14_05_basic_large_pw(self, env: Env, httpd, nghttpx, proto): '--basic', '--user', f'test:{password}', '--trace-config', 'http/2,http/3' ]) - # but apache denies on length limit - r.check_response(http_status=431) + # but apache either denies on length limit or gives a 400 + r.check_exit_code(0) + assert r.stats[0]['http_code'] in [400, 431] # PUT data, basic auth with very large pw @pytest.mark.parametrize("proto", Env.http_mplx_protos()) diff --git a/tests/http/testenv/nghttpx.py b/tests/http/testenv/nghttpx.py index 106766fc0fe7..950d567f24b8 100644 --- a/tests/http/testenv/nghttpx.py +++ b/tests/http/testenv/nghttpx.py @@ -247,7 +247,6 @@ def start(self, wait_live=True): '--frontend-quic-early-data', ]) args.extend([ - f'--backend=127.0.0.1,{self.env.https_port};{self._domain};sni={self._domain};proto=h2;tls', f'--backend=127.0.0.1,{self.env.http_port}', '--log-level=ERROR', f'--pid-file={self._pid_file}', From 0295c9401d5bfe8bd490c3f14fecda54c6032fce Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Wed, 10 Dec 2025 15:37:44 +0100 Subject: [PATCH 275/415] ldap: drop PP logic for old, unsupported, Windows SDKs `LDAP_VENDOR_NAME` and `winber.h` are available in all supported MS SDK and mingw-w64 versions. Stop checking for them. Also drop redundant parenthesis in PP expression. Closes #19918 --- lib/ldap.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/lib/ldap.c b/lib/ldap.c index ba9620b4b185..b51aab56fb44 100644 --- a/lib/ldap.c +++ b/lib/ldap.c @@ -64,19 +64,14 @@ # pragma warning(pop) # endif # include -# ifndef LDAP_VENDOR_NAME -# error Your Platform SDK is NOT sufficient for LDAP support! \ - Update your Platform SDK, or disable LDAP support! -# else -# include -# endif +# include #else # define LDAP_DEPRECATED 1 /* Be sure ldap_init() is defined. */ # ifdef HAVE_LBER_H # include # endif # include -# if (defined(HAVE_LDAP_SSL) && defined(HAVE_LDAP_SSL_H)) +# if defined(HAVE_LDAP_SSL) && defined(HAVE_LDAP_SSL_H) # include # endif /* HAVE_LDAP_SSL && HAVE_LDAP_SSL_H */ #endif From edbbcbb1273d513b0a484c7a28df000c41148ddd Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Wed, 10 Dec 2025 15:48:31 +0100 Subject: [PATCH 276/415] config-win32.h: drop unused/obsolete `CURL_HAS_OPENLDAP_LDAPSDK` Meant for use from `Makefile.mk`. The suggested replacement is CMake or autotools. Follow-up to ba8752e5566076acc8bdec7ae4ec78901f7050f4 #12224 Closes #19920 --- lib/config-win32.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/config-win32.h b/lib/config-win32.h index 2bdb555084cf..002782c6ea9e 100644 --- a/lib/config-win32.h +++ b/lib/config-win32.h @@ -353,10 +353,7 @@ /* LDAP SUPPORT */ /* ---------------------------------------------------------------- */ -#ifdef CURL_HAS_OPENLDAP_LDAPSDK -#undef USE_WIN32_LDAP -#define HAVE_LDAP_URL_PARSE 1 -#elif !defined(CURL_WINDOWS_UWP) +#ifndef CURL_WINDOWS_UWP #undef HAVE_LDAP_URL_PARSE #define HAVE_LDAP_SSL 1 #define USE_WIN32_LDAP 1 From a73040ac8abb979d50e5c13306dee8adcf8f33a8 Mon Sep 17 00:00:00 2001 From: Stefan Eissing Date: Wed, 10 Dec 2025 16:07:59 +0100 Subject: [PATCH 277/415] quiche: fix version for skip due to flakiness 0.24.6 is the quiche version without the fix for proper handling fo RESET streams. Require a verion higher than that to run test_05_02. Follow-up to 14478429e71ef0eee6d12b73113e9ff8e3ae9e75 #19916 Closes #19921 --- tests/http/test_05_errors.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/http/test_05_errors.py b/tests/http/test_05_errors.py index 5fada1500593..89a8acdebef3 100644 --- a/tests/http/test_05_errors.py +++ b/tests/http/test_05_errors.py @@ -61,7 +61,7 @@ def test_05_02_partial_20(self, env: Env, httpd, nghttpx, proto): if proto == 'h3' and env.curl_uses_ossl_quic(): pytest.skip("openssl-quic is flaky in yielding proper error codes") if proto == 'h3' and env.curl_uses_lib('quiche') and \ - not env.curl_lib_version_at_least('quiche', '0.24.5'): + not env.curl_lib_version_at_least('quiche', '0.24.7'): pytest.skip("quiche issue #2277 not fixed") count = 20 curl = CurlClient(env=env) From cc285649dc95b73eef5d498d93d0cdcc75b1e5c7 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Wed, 10 Dec 2025 18:45:06 +0100 Subject: [PATCH 278/415] autotools: fix LargeFile feature display on Windows (after prev patch) Always show it on Windows, regardless of the `--disable-largefile` build option. Follow-up to 163705db756557e6c07ac9386663f0576ebfd64e #19888 Closes #19922 --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 64fa6516ec8f..40d4fc29fe4e 100644 --- a/configure.ac +++ b/configure.ac @@ -5317,7 +5317,7 @@ fi if test ${ac_cv_sizeof_curl_off_t} -gt 4; then if test ${ac_cv_sizeof_off_t} -gt 4 -o \ - "$curl_win32_file_api" = "win32_large_files"; then + "$curl_cv_native_windows" = "yes"; then SUPPORT_FEATURES="$SUPPORT_FEATURES Largefile" fi fi From 8db0e286b363ad788d6dc0779d605b83c7ed4caf Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Tue, 5 Aug 2025 16:07:21 +0200 Subject: [PATCH 279/415] autotools: tidy-up `if` expressions - drop x-hacks for curl internal variables and certain autotools ones that do not hold custom values. - make x-hacks consistently use `"x$var" = "xval"` style. - add a few x-hacks for input/external variables that may hold custom values. - prefer `-z` and `-n` to test empty/non-empty. This also makes some x-hacks unnecessary. - optimized negated test `-z` and `-n` options. - prefer `&&` and `||` over `-a` and `-o`. For better POSIX compatibility: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html - quote variables passed to `test`, where missing. - quote string literals in comparisons. - fix some indentation, whitespace. Note that a few `case` statements also use the x-hack, which looks unnecessary. This patch does not change them. Verified by comparing feature detection results with a reference CI run from before this patch (PR #19922). Refs: https://www.shellcheck.net/wiki/SC2268 https://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html https://www.vidarholen.net/contents/blog/?p=1035 https://mywiki.wooledge.org/BashPitfalls#A.5B_.24foo_.3D_.22bar.22_.5D Closes #18189 --- acinclude.m4 | 52 ++-- configure.ac | 618 +++++++++++++++++++------------------- curl-config.in | 2 +- docs/libcurl/libcurl.m4 | 30 +- m4/curl-amissl.m4 | 4 +- m4/curl-apple-sectrust.m4 | 6 +- m4/curl-compilers.m4 | 35 +-- m4/curl-confopts.m4 | 18 +- m4/curl-functions.m4 | 24 +- m4/curl-gnutls.m4 | 18 +- m4/curl-mbedtls.m4 | 18 +- m4/curl-openssl.m4 | 28 +- m4/curl-rustls.m4 | 18 +- m4/curl-schannel.m4 | 8 +- m4/curl-sysconfig.m4 | 2 +- m4/curl-wolfssl.m4 | 20 +- m4/xc-lt-iface.m4 | 26 +- m4/xc-val-flgs.m4 | 24 +- m4/zz40-xc-ovr.m4 | 4 +- 19 files changed, 478 insertions(+), 477 deletions(-) diff --git a/acinclude.m4 b/acinclude.m4 index 0627ed1fd7e5..d95cbd3f5b6d 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -190,7 +190,7 @@ AC_DEFUN([CURL_CHECK_NATIVE_WINDOWS], [ curl_cv_native_windows="no" ]) ]) - AM_CONDITIONAL(DOING_NATIVE_WINDOWS, test "x$curl_cv_native_windows" = xyes) + AM_CONDITIONAL(DOING_NATIVE_WINDOWS, test "$curl_cv_native_windows" = "yes") ]) @@ -910,7 +910,7 @@ AC_DEFUN([CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC], [ curl_func_clock_gettime="yes" ;; *) - if test "x$dontwant_rt" = "xyes" ; then + if test "$dontwant_rt" = "yes"; then AC_MSG_WARN([needs -lrt but asked not to use it, HAVE_CLOCK_GETTIME_MONOTONIC will not be defined]) curl_func_clock_gettime="no" else @@ -926,7 +926,7 @@ AC_DEFUN([CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC], [ esac # dnl only do runtime verification when not cross-compiling - if test "x$cross_compiling" != "xyes" && + if test "$cross_compiling" != "yes" && test "$curl_func_clock_gettime" = "yes"; then AC_MSG_CHECKING([if monotonic clock_gettime works]) CURL_RUN_IFELSE([ @@ -1082,7 +1082,7 @@ dnl macro. It must also run AFTER all lib-checking macros are complete. AC_DEFUN([CURL_VERIFY_RUNTIMELIBS], [ dnl this test is of course not sensible if we are cross-compiling! - if test "x$cross_compiling" != xyes; then + if test "$cross_compiling" != "yes"; then dnl just run a program to verify that the libs checked for previous to this dnl point also is available runtime! @@ -1149,22 +1149,22 @@ AS_HELP_STRING([--without-ca-path], [Do not use a default CA path]), capath_warning=" (warning: certs not found)" check_capath="" - if test "x$APPLE_SECTRUST_ENABLED" = "x1"; then + if test "$APPLE_SECTRUST_ENABLED" = "1"; then ca_native="Apple SecTrust" else ca_native="no" fi - if test "x$want_ca" != "xno" -a "x$want_ca" != "xunset" -a \ - "x$want_capath" != "xno" -a "x$want_capath" != "xunset"; then + if test "x$want_ca" != "xno" && test "x$want_ca" != "xunset" && + test "x$want_capath" != "xno" && test "x$want_capath" != "xunset"; then dnl both given ca="$want_ca" capath="$want_capath" - elif test "x$want_ca" != "xno" -a "x$want_ca" != "xunset"; then + elif test "x$want_ca" != "xno" && test "x$want_ca" != "xunset"; then dnl --with-ca-bundle given ca="$want_ca" capath="no" - elif test "x$want_capath" != "xno" -a "x$want_capath" != "xunset"; then + elif test "x$want_capath" != "xno" && test "x$want_capath" != "xunset"; then dnl --with-ca-path given capath="$want_capath" ca="no" @@ -1177,15 +1177,15 @@ AS_HELP_STRING([--without-ca-path], [Do not use a default CA path]), dnl Both auto-detections can be skipped by --without-ca-* ca="no" capath="no" - if test "x$cross_compiling" != "xyes" -a \ - "x$curl_cv_native_windows" != "xyes"; then + if test "$cross_compiling" != "yes" && + test "$curl_cv_native_windows" != "yes"; then dnl NOT cross-compiling and... dnl neither of the --with-ca-* options are provided if test "x$want_ca" = "xunset"; then dnl the path we previously would have installed the curl CA bundle dnl to, and thus we now check for an already existing cert in that dnl place in case we find no other - if test "x$prefix" != xNONE; then + if test "x$prefix" != "xNONE"; then cac="${prefix}/share/curl/curl-ca-bundle.crt" else cac="$ac_default_prefix/share/curl/curl-ca-bundle.crt" @@ -1221,7 +1221,7 @@ AS_HELP_STRING([--without-ca-path], [Do not use a default CA path]), check_capath="$capath" fi - if test ! -z "$check_capath"; then + if test -n "$check_capath"; then for a in "$check_capath"; do if test -d "$a" && ls "$a"/[[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]].0 >/dev/null 2>/dev/null; then if test "x$capath" = "xno"; then @@ -1257,14 +1257,14 @@ AS_HELP_STRING([--without-ca-path], [Do not use a default CA path]), AS_HELP_STRING([--with-ca-fallback], [Use OpenSSL's built-in CA store]) AS_HELP_STRING([--without-ca-fallback], [Do not use OpenSSL's built-in CA store]), [ - if test "x$with_ca_fallback" != "xyes" -a "x$with_ca_fallback" != "xno"; then + if test "x$with_ca_fallback" != "xyes" && test "x$with_ca_fallback" != "xno"; then AC_MSG_ERROR([--with-ca-fallback only allows yes or no as parameter]) fi ], [ with_ca_fallback="no"]) AC_MSG_RESULT([$with_ca_fallback]) if test "x$with_ca_fallback" = "xyes"; then - if test "x$OPENSSL_ENABLED" != "x1"; then + if test "$OPENSSL_ENABLED" != "1"; then AC_MSG_ERROR([--with-ca-fallback only works with OpenSSL]) fi AC_DEFINE_UNQUOTED(CURL_CA_FALLBACK, 1, [define "1" to use OpenSSL's built-in CA store]) @@ -1293,7 +1293,7 @@ AS_HELP_STRING([--without-ca-embed], [Do not embed a default CA bundle in the cu [ want_ca_embed="unset" ]) CURL_CA_EMBED='' - if test "x$want_ca_embed" != "xno" -a "x$want_ca_embed" != "xunset" -a -f "$want_ca_embed"; then + if test "x$want_ca_embed" != "xno" && test "x$want_ca_embed" != "xunset" && test -f "$want_ca_embed"; then if test -n "$PERL"; then CURL_CA_EMBED="$want_ca_embed" AC_SUBST(CURL_CA_EMBED) @@ -1315,7 +1315,7 @@ AC_DEFUN([CURL_CHECK_WIN32_CRYPTO], [ AC_REQUIRE([CURL_CHECK_NATIVE_WINDOWS])dnl AC_MSG_CHECKING([whether build target supports Win32 crypto API]) curl_win32_crypto_api="no" - if test "$curl_cv_native_windows" = "yes" -a "$curl_cv_winuwp" != "yes"; then + if test "$curl_cv_native_windows" = "yes" && test "$curl_cv_winuwp" != "yes"; then AC_COMPILE_IFELSE([ AC_LANG_PROGRAM([[ #undef inline @@ -1382,7 +1382,7 @@ AC_DEFUN([CURL_CHECK_PKGCONFIG], [ [$PATH:/usr/bin:/usr/local/bin]) fi - if test "x$PKGCONFIG" != "xno"; then + if test "$PKGCONFIG" != "no"; then AC_MSG_CHECKING([for $1 options with pkg-config]) dnl ask pkg-config about $1 itexists=`CURL_EXPORT_PCDIR([$2]) dnl @@ -1423,7 +1423,7 @@ dnl Save build info for test runner to pick up and log AC_DEFUN([CURL_PREPARE_BUILDINFO], [ curl_pflags="" - if test "$curl_cv_apple" = 'yes'; then + if test "$curl_cv_apple" = "yes"; then curl_pflags="${curl_pflags} APPLE" fi case $host in @@ -1443,20 +1443,20 @@ AC_DEFUN([CURL_PREPARE_BUILDINFO], [ fi ;; esac - if test "$curl_cv_native_windows" = 'yes'; then + if test "$curl_cv_native_windows" = "yes"; then curl_pflags="${curl_pflags} WIN32" fi - if test "$curl_cv_winuwp" = 'yes'; then + if test "$curl_cv_winuwp" = "yes"; then curl_pflags="${curl_pflags} UWP" fi - if test "$curl_cv_cygwin" = 'yes'; then + if test "$curl_cv_cygwin" = "yes"; then curl_pflags="${curl_pflags} CYGWIN" fi case $host_os in msdos*) curl_pflags="${curl_pflags} DOS";; amiga*) curl_pflags="${curl_pflags} AMIGA";; esac - if test "x$compiler_id" = 'xGNU_C'; then + if test "$compiler_id" = "GNU_C"; then curl_pflags="${curl_pflags} GCC" fi if test "$compiler_id" = "APPLECLANG"; then @@ -1467,7 +1467,7 @@ AC_DEFUN([CURL_PREPARE_BUILDINFO], [ case $host_os in mingw*) curl_pflags="${curl_pflags} MINGW";; esac - if test "x$cross_compiling" = 'xyes'; then + if test "$cross_compiling" = "yes"; then curl_pflags="${curl_pflags} CROSS" fi squeeze curl_pflags @@ -1509,7 +1509,7 @@ TEST EINVAL TEST AC_MSG_RESULT([$cpp]) dnl we need cpp -P so check if it works then - if test "x$cpp" = "xyes"; then + if test "$cpp" = "yes"; then AC_MSG_CHECKING([if cpp -P works]) OLDCPPFLAGS=$CPPFLAGS CPPFLAGS="$CPPFLAGS -P" @@ -1519,7 +1519,7 @@ TEST EINVAL TEST ], [cpp_p=yes], [cpp_p=no]) AC_MSG_RESULT([$cpp_p]) - if test "x$cpp_p" = "xno"; then + if test "$cpp_p" = "no"; then AC_MSG_WARN([failed to figure out cpp -P alternative]) # without -P CPPPFLAG="" diff --git a/configure.ac b/configure.ac index 40d4fc29fe4e..3c0bfaa3531f 100644 --- a/configure.ac +++ b/configure.ac @@ -44,12 +44,12 @@ AM_MAINTAINER_MODE m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) CURL_CHECK_OPTION_DEBUG -AM_CONDITIONAL(DEBUGBUILD, test x$want_debug = xyes) +AM_CONDITIONAL(DEBUGBUILD, test "$want_debug" = "yes") CURL_CHECK_OPTION_OPTIMIZE CURL_CHECK_OPTION_WARNINGS CURL_CHECK_OPTION_WERROR CURL_CHECK_OPTION_CURLDEBUG -AM_CONDITIONAL(CURLDEBUG, test x$want_curldebug = xyes) +AM_CONDITIONAL(CURLDEBUG, test "$want_curldebug" = "yes") CURL_CHECK_OPTION_SYMBOL_HIDING CURL_CHECK_OPTION_ARES CURL_CHECK_OPTION_RT @@ -225,7 +225,7 @@ AS_HELP_STRING([--with-ssl=PATH],[old version of --with-openssl]) AS_HELP_STRING([--without-ssl], [build without any TLS library]),[ OPT_SSL=$withval OPT_OPENSSL=$withval - if test X"$withval" != Xno; then + if test "x$withval" != "xno"; then TLSCHOICE="${TLSCHOICE:+$TLSCHOICE, }OpenSSL" else SSL_DISABLED="D" @@ -235,7 +235,7 @@ AS_HELP_STRING([--without-ssl], [build without any TLS library]),[ AC_ARG_WITH(openssl,dnl AS_HELP_STRING([--with-openssl=PATH],[Where to look for OpenSSL, PATH points to the SSL installation (default: /usr/local/ssl); when possible, set the PKG_CONFIG_PATH environment variable instead of using this option]),[ OPT_OPENSSL=$withval - if test X"$withval" != Xno; then + if test "x$withval" != "xno"; then TLSCHOICE="${TLSCHOICE:+$TLSCHOICE, }OpenSSL" fi ]) @@ -244,7 +244,7 @@ OPT_GNUTLS=no AC_ARG_WITH(gnutls,dnl AS_HELP_STRING([--with-gnutls=PATH],[where to look for GnuTLS, PATH points to the installation root]),[ OPT_GNUTLS=$withval - if test X"$withval" != Xno; then + if test "x$withval" != "xno"; then TLSCHOICE="${TLSCHOICE:+$TLSCHOICE, }GnuTLS" fi ]) @@ -253,7 +253,7 @@ OPT_MBEDTLS=no AC_ARG_WITH(mbedtls,dnl AS_HELP_STRING([--with-mbedtls=PATH],[where to look for mbedTLS, PATH points to the installation root]),[ OPT_MBEDTLS=$withval - if test X"$withval" != Xno; then + if test "x$withval" != "xno"; then TLSCHOICE="${TLSCHOICE:+$TLSCHOICE, }mbedTLS" fi ]) @@ -262,7 +262,7 @@ OPT_WOLFSSL=no AC_ARG_WITH(wolfssl,dnl AS_HELP_STRING([--with-wolfssl=PATH],[where to look for wolfSSL, PATH points to the installation root (default: system lib default)]),[ OPT_WOLFSSL=$withval - if test X"$withval" != Xno; then + if test "x$withval" != "xno"; then TLSCHOICE="${TLSCHOICE:+$TLSCHOICE, }wolfSSL" fi ]) @@ -271,7 +271,7 @@ OPT_RUSTLS=no AC_ARG_WITH(rustls,dnl AS_HELP_STRING([--with-rustls=PATH],[where to look for Rustls, PATH points to the installation root]),[ OPT_RUSTLS=$withval - if test X"$withval" != Xno; then + if test "x$withval" != "xno"; then TLSCHOICE="${TLSCHOICE:+$TLSCHOICE, }Rustls" experimental="$experimental Rustls" fi @@ -291,7 +291,7 @@ TEST_NGHTTPX=nghttpx AC_ARG_WITH(test-nghttpx,dnl AS_HELP_STRING([--with-test-nghttpx=PATH],[where to find nghttpx for testing]), TEST_NGHTTPX=$withval - if test X"$TEST_NGHTTPX" = "Xno"; then + if test "x$TEST_NGHTTPX" = "xno"; then TEST_NGHTTPX="" fi ) @@ -307,7 +307,7 @@ fi AC_ARG_WITH(test-caddy,dnl AS_HELP_STRING([--with-test-caddy=PATH],[where to find caddy for testing]), CADDY=$withval - if test X"$CADDY" = "Xno"; then + if test "x$CADDY" = "xno"; then CADDY="" fi ) @@ -323,7 +323,7 @@ fi AC_ARG_WITH(test-vsftpd,dnl AS_HELP_STRING([--with-test-vsftpd=PATH],[where to find vsftpd for testing]), VSFTPD=$withval - if test X"$VSFTPD" = "Xno"; then + if test "x$VSFTPD" = "xno"; then VSFTPD="" fi ) @@ -335,31 +335,31 @@ HTTPD_ENABLED="maybe" AC_ARG_WITH(test-httpd, [AS_HELP_STRING([--with-test-httpd=PATH], [where to find httpd/apache2 for testing])], [request_httpd=$withval], [request_httpd=check]) -if test x"$request_httpd" = "xcheck" -o x"$request_httpd" = "xyes"; then +if test "x$request_httpd" = "xcheck" || test "x$request_httpd" = "xyes"; then if test -x "/usr/sbin/apache2"; then # common location on distros (debian/ubuntu) HTTPD="/usr/sbin/apache2" AC_PATH_PROG([APXS], [apxs]) - if test "x$APXS" = "x"; then + if test -z "$APXS"; then AC_MSG_NOTICE([apache2-dev not installed, httpd tests disabled]) HTTPD_ENABLED="no" fi else AC_PATH_PROG([HTTPD], [httpd]) - if test "x$HTTPD" = "x"; then + if test -z "$HTTPD"; then AC_PATH_PROG([HTTPD], [apache2]) fi AC_PATH_PROG([APXS], [apxs]) - if test "x$HTTPD" = "x"; then + if test -z "$HTTPD"; then AC_MSG_NOTICE([httpd/apache2 not in PATH, http tests disabled]) HTTPD_ENABLED="no" fi - if test "x$APXS" = "x"; then + if test -z "$APXS"; then AC_MSG_NOTICE([apxs not in PATH, http tests disabled]) HTTPD_ENABLED="no" fi fi -elif test x"$request_httpd" != "xno"; then +elif test "x$request_httpd" != "xno"; then HTTPD="${request_httpd}/bin/httpd" APXS="${request_httpd}/bin/apxs" if test ! -x "${HTTPD}"; then @@ -372,7 +372,7 @@ elif test x"$request_httpd" != "xno"; then AC_MSG_NOTICE([using HTTPD=$HTTPD for tests]) fi fi -if test x"$HTTPD_ENABLED" = "xno"; then +if test "$HTTPD_ENABLED" = "no"; then HTTPD="" APXS="" fi @@ -385,17 +385,17 @@ DANTED_ENABLED="maybe" AC_ARG_WITH(test-danted, [AS_HELP_STRING([--with-test-danted=PATH], [where to find danted socks daemon for testing])], [request_danted=$withval], [request_danted=check]) -if test x"$request_danted" = "xcheck" -o x"$request_danted" = "xyes"; then +if test "x$request_danted" = "xcheck" || test "x$request_danted" = "xyes"; then if test -x "/usr/sbin/danted"; then # common location on distros (debian/ubuntu) DANTED="/usr/sbin/danted" else AC_PATH_PROG([DANTED], [danted]) - if test "x$DANTED" = "x"; then + if test -z "$DANTED"; then AC_PATH_PROG([DANTED], [danted]) fi fi -elif test x"$request_danted" != "xno"; then +elif test "x$request_danted" != "xno"; then DANTED="${request_danted}" if test ! -x "${DANTED}"; then AC_MSG_NOTICE([danted not found as ${DANTED}, danted tests disabled]) @@ -404,13 +404,13 @@ elif test x"$request_danted" != "xno"; then AC_MSG_NOTICE([using DANTED=$DANTED for tests]) fi fi -if test x"$DANTED_ENABLED" = "xno"; then +if test "$DANTED_ENABLED" = "no"; then DANTED="" fi AC_SUBST(DANTED) dnl the nghttpx we might use in httpd testing -if test "x$TEST_NGHTTPX" != "x" -a "x$TEST_NGHTTPX" != "xnghttpx"; then +if test -n "$TEST_NGHTTPX" && test "x$TEST_NGHTTPX" != "xnghttpx"; then HTTPD_NGHTTPX="$TEST_NGHTTPX" else AC_PATH_PROG([HTTPD_NGHTTPX], [nghttpx], [], @@ -419,7 +419,7 @@ fi AC_SUBST(HTTPD_NGHTTPX) dnl the Caddy server we might use in testing -if test "x$TEST_CADDY" != "x"; then +if test -n "$TEST_CADDY"; then CADDY="$TEST_CADDY" else AC_PATH_PROG([CADDY], [caddy]) @@ -480,11 +480,11 @@ AM_CONDITIONAL(NOT_CURL_CI, test -z "$CURL_CI") # AM_CONDITIONAL([CURL_LT_SHLIB_USE_VERSION_INFO], - [test "x$xc_lt_shlib_use_version_info" = 'xyes']) + [test "$xc_lt_shlib_use_version_info" = "yes"]) AM_CONDITIONAL([CURL_LT_SHLIB_USE_NO_UNDEFINED], - [test "x$xc_lt_shlib_use_no_undefined" = 'xyes']) + [test "$xc_lt_shlib_use_no_undefined" = "yes"]) AM_CONDITIONAL([CURL_LT_SHLIB_USE_MIMPURE_TEXT], - [test "x$xc_lt_shlib_use_mimpure_text" = 'xyes']) + [test "$xc_lt_shlib_use_mimpure_text" = "yes"]) # # Due to libtool and automake machinery limitations of not allowing @@ -503,7 +503,7 @@ AM_CONDITIONAL([CURL_LT_SHLIB_USE_MIMPURE_TEXT], # AM_CONDITIONAL([USE_CPPFLAG_CURL_STATICLIB], - [test "x$xc_lt_build_static_only" = 'xyes']) + [test "$xc_lt_build_static_only" = "yes"]) # # Make staticlib CPPFLAG variable and its definition visible in output @@ -515,7 +515,7 @@ LIBCURL_PC_CFLAGS_PRIVATE='-DCURL_STATICLIB' AC_SUBST(LIBCURL_PC_CFLAGS_PRIVATE) LIBCURL_PC_CFLAGS= -if test "x$xc_lt_build_static_only" = 'xyes'; then +if test "$xc_lt_build_static_only" = "yes"; then LIBCURL_PC_CFLAGS="${LIBCURL_PC_CFLAGS_PRIVATE}" fi AC_SUBST([LIBCURL_PC_CFLAGS]) @@ -555,7 +555,7 @@ if test "$compiler_id" = "INTEL_UNIX_C"; then fi CURL_CFLAG_EXTRAS="" -if test X"$want_werror" = Xyes; then +if test "$want_werror" = "yes"; then CURL_CFLAG_EXTRAS="-Werror" if test "$compiler_id" = "GNU_C"; then dnl enable -pedantic-errors for GCC 5 and later, @@ -563,12 +563,12 @@ if test X"$want_werror" = Xyes; then if test "$compiler_num" -ge "500"; then CURL_CFLAG_EXTRAS="$CURL_CFLAG_EXTRAS -pedantic-errors" fi - elif test "$compiler_id" = "CLANG" -o "$compiler_id" = "APPLECLANG"; then + elif test "$compiler_id" = "CLANG" || test "$compiler_id" = "APPLECLANG"; then CURL_CFLAG_EXTRAS="$CURL_CFLAG_EXTRAS -pedantic-errors" fi fi AC_SUBST(CURL_CFLAG_EXTRAS) -AM_CONDITIONAL(CURL_WERROR, test X"$want_werror" = Xyes) +AM_CONDITIONAL(CURL_WERROR, test "$want_werror" = "yes") CURL_CHECK_COMPILER_HALT_ON_ERROR CURL_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE @@ -579,8 +579,8 @@ supports_unittests=yes # cross-compilation of unit tests static library/programs fails when # libcurl shared library is built. This might be due to a libtool or # automake issue. In this case we disable unit tests. -if test "x$cross_compiling" != "xno" && - test "x$enable_shared" != "xno"; then +if test "$cross_compiling" != "no" && + test "$enable_shared" != "no"; then supports_unittests=no fi @@ -604,7 +604,7 @@ case $host_os in ;; esac -AM_CONDITIONAL(BUILD_UNITTESTS, test x$supports_unittests = xyes) +AM_CONDITIONAL(BUILD_UNITTESTS, test "$supports_unittests" = "yes") # In order to detect support of sendmmsg() and accept4(), we need to escape the POSIX # jail by defining _GNU_SOURCE or will not expose it. @@ -625,7 +625,7 @@ case $host in *-apple-*) curl_cv_apple='yes';; esac -if test "$curl_cv_apple" = 'yes'; then +if test "$curl_cv_apple" = "yes"; then CURL_DARWIN_CFLAGS CURL_SUPPORTS_BUILTIN_AVAILABLE fi @@ -663,11 +663,11 @@ AS_HELP_STRING([--disable-unity],[Disable unity (default)]), esac ], AC_MSG_RESULT([no]) ) -if test -z "$PERL" -a "$want_unity" = 'yes'; then +if test -z "$PERL" && test "$want_unity" = "yes"; then AC_MSG_WARN([perl was not found. Will not enable unity.]) want_unity='no' fi -AM_CONDITIONAL([USE_UNITY], [test "$want_unity" = 'yes']) +AM_CONDITIONAL([USE_UNITY], [test "$want_unity" = "yes"]) dnl ************************************************************ dnl switch off particular protocols @@ -745,7 +745,7 @@ AS_HELP_STRING([--disable-ipfs],[Disable IPFS support]), CURL_DISABLE_IPFS=1 ;; *) - if test x$CURL_DISABLE_HTTP = x1; then + if test "$CURL_DISABLE_HTTP" = "1"; then AC_MSG_ERROR(HTTP support needs to be enabled in order to enable IPFS support!) else AC_MSG_RESULT(yes) @@ -753,7 +753,7 @@ AS_HELP_STRING([--disable-ipfs],[Disable IPFS support]), fi ;; esac ], - if test "x$CURL_DISABLE_HTTP" != "x1"; then + if test "$CURL_DISABLE_HTTP" != "1"; then AC_MSG_RESULT(yes) curl_ipfs_msg="enabled" else @@ -791,7 +791,7 @@ AS_HELP_STRING([--disable-ldaps],[Disable LDAPS support]), CURL_DISABLE_LDAPS=1 ;; *) - if test "x$CURL_DISABLE_LDAP" = "x1"; then + if test "$CURL_DISABLE_LDAP" = "1"; then AC_MSG_RESULT(LDAP needs to be enabled to support LDAPS) AC_DEFINE(CURL_DISABLE_LDAPS, 1, [to disable LDAPS]) CURL_DISABLE_LDAPS=1 @@ -802,7 +802,7 @@ AS_HELP_STRING([--disable-ldaps],[Disable LDAPS support]), fi ;; esac ],[ - if test "x$CURL_DISABLE_LDAP" = "x1"; then + if test "$CURL_DISABLE_LDAP" = "1"; then AC_MSG_RESULT(no) AC_DEFINE(CURL_DISABLE_LDAPS, 1, [to disable LDAPS]) CURL_DISABLE_LDAPS=1 @@ -817,27 +817,27 @@ AC_MSG_CHECKING([whether to support rtsp]) AC_ARG_ENABLE(rtsp, AS_HELP_STRING([--enable-rtsp],[Enable RTSP support]) AS_HELP_STRING([--disable-rtsp],[Disable RTSP support]), - [ case "$enableval" in - no) +[ case "$enableval" in + no) + AC_MSG_RESULT(no) + AC_DEFINE(CURL_DISABLE_RTSP, 1, [to disable RTSP]) + CURL_DISABLE_RTSP=1 + ;; + *) + if test "$CURL_DISABLE_HTTP" = "1"; then + AC_MSG_ERROR(HTTP support needs to be enabled in order to enable RTSP support!) + else + AC_MSG_RESULT(yes) + curl_rtsp_msg="enabled" + fi + ;; + esac ], + if test "$CURL_DISABLE_HTTP" != "1"; then + AC_MSG_RESULT(yes) + curl_rtsp_msg="enabled" + else AC_MSG_RESULT(no) - AC_DEFINE(CURL_DISABLE_RTSP, 1, [to disable RTSP]) - CURL_DISABLE_RTSP=1 - ;; - *) - if test x$CURL_DISABLE_HTTP = x1; then - AC_MSG_ERROR(HTTP support needs to be enabled in order to enable RTSP support!) - else - AC_MSG_RESULT(yes) - curl_rtsp_msg="enabled" - fi - ;; - esac ], - if test "x$CURL_DISABLE_HTTP" != "x1"; then - AC_MSG_RESULT(yes) - curl_rtsp_msg="enabled" - else - AC_MSG_RESULT(no) - fi + fi ) AC_MSG_CHECKING([whether to support proxies]) @@ -892,7 +892,7 @@ AS_HELP_STRING([--disable-telnet],[Disable TELNET support]), AC_MSG_RESULT(yes) ) -if test "$curl_cv_winuwp" = 'yes'; then +if test "$curl_cv_winuwp" = "yes"; then AC_DEFINE(CURL_DISABLE_TELNET, 1, [to disable TELNET]) CURL_DISABLE_TELNET=1 fi @@ -1063,7 +1063,7 @@ AS_HELP_STRING([--disable-docs],[Disable documentation]), AC_MSG_RESULT(yes) BUILD_DOCS=1 ) -if test -z "$PERL" -a "x$BUILD_DOCS" != "x0"; then +if test -z "$PERL" && test "$BUILD_DOCS" != "0"; then AC_MSG_WARN([perl was not found. Will not build documentation.]) BUILD_DOCS=0 fi @@ -1191,14 +1191,14 @@ fi # In UWP mode gethostbyname gets detected via the core libs, but some # code (in6addr_any) still need ws2_32, so let us detect and add it. -if test "$HAVE_GETHOSTBYNAME" != "1" -o "$curl_cv_winuwp" = "yes"; then +if test "$HAVE_GETHOSTBYNAME" != "1" || test "$curl_cv_winuwp" = "yes"; then if test "$curl_cv_native_windows" = "yes"; then dnl This is for Winsock systems winsock_LIB="-lws2_32" if test "$curl_cv_winuwp" != "yes"; then winsock_LIB="$winsock_LIB -liphlpapi" fi - if test ! -z "$winsock_LIB"; then + if test -n "$winsock_LIB"; then my_ac_save_LIBS=$LIBS LIBS="$winsock_LIB $LIBS" AC_MSG_CHECKING([for gethostbyname in $winsock_LIB]) @@ -1261,7 +1261,7 @@ if test "$HAVE_GETHOSTBYNAME" != "1"; then ]) fi -if test "$HAVE_GETHOSTBYNAME" != "1" -o "${with_amissl+set}" = set; then +if test "$HAVE_GETHOSTBYNAME" != "1" || test "${with_amissl+set}" = "set"; then dnl This is for AmigaOS with bsdsocket.library - needs testing before -lnet AC_MSG_CHECKING([for gethostbyname for AmigaOS bsdsocket.library]) AC_LINK_IFELSE([ @@ -1331,10 +1331,10 @@ AS_HELP_STRING([--with-zlib=PATH],[search for zlib in PATH]) AS_HELP_STRING([--without-zlib],[disable use of zlib]), [OPT_ZLIB="$withval"]) -if test "$OPT_ZLIB" = "no"; then +if test "x$OPT_ZLIB" = "xno"; then AC_MSG_WARN([zlib disabled]) else - if test "$OPT_ZLIB" = "yes"; then + if test "x$OPT_ZLIB" = "xyes"; then OPT_ZLIB="" fi @@ -1434,7 +1434,7 @@ else fi dnl set variable for use in automakefile(s) -AM_CONDITIONAL(HAVE_LIBZ, test x"$AMFIXLIB" = x1) +AM_CONDITIONAL(HAVE_LIBZ, test "$AMFIXLIB" = "1") AC_SUBST(ZLIB_LIBS) dnl ********************************************************************** @@ -1450,7 +1450,7 @@ AS_HELP_STRING([--with-brotli=PATH],[Where to look for brotli, PATH points to th AS_HELP_STRING([--without-brotli], [disable BROTLI]), OPT_BROTLI=$withval) -if test X"$OPT_BROTLI" != Xno; then +if test "x$OPT_BROTLI" != "xno"; then dnl backup the pre-brotli variables CLEANLDFLAGS="$LDFLAGS" CLEANLDFLAGSPC="$LDFLAGSPC" @@ -1509,7 +1509,7 @@ if test X"$OPT_BROTLI" != Xno; then AC_DEFINE(HAVE_BROTLI, 1, [if BROTLI is in use]) ) - if test X"$OPT_BROTLI" != Xoff && + if test "x$OPT_BROTLI" != "xoff" && test "$HAVE_BROTLI" != "1"; then AC_MSG_ERROR([BROTLI libs and/or directories were not found where specified!]) fi @@ -1520,7 +1520,7 @@ if test X"$OPT_BROTLI" != Xno; then dnl linker does not search through, we need to add it to CURL_LIBRARY_PATH dnl to prevent further configure tests to fail due to this - if test "x$cross_compiling" != "xyes"; then + if test "$cross_compiling" != "yes"; then CURL_LIBRARY_PATH="$CURL_LIBRARY_PATH:$DIR_BROTLI" export CURL_LIBRARY_PATH AC_MSG_NOTICE([Added $DIR_BROTLI to CURL_LIBRARY_PATH]) @@ -1547,7 +1547,7 @@ AS_HELP_STRING([--with-zstd=PATH],[Where to look for libzstd, PATH points to the AS_HELP_STRING([--without-zstd], [disable libzstd]), OPT_ZSTD=$withval) -if test X"$OPT_ZSTD" != Xno; then +if test "x$OPT_ZSTD" != "xno"; then dnl backup the pre-zstd variables CLEANLDFLAGS="$LDFLAGS" CLEANLDFLAGSPC="$LDFLAGSPC" @@ -1598,7 +1598,7 @@ if test X"$OPT_ZSTD" != Xno; then AC_DEFINE(HAVE_ZSTD, 1, [if libzstd is in use]) ) - if test X"$OPT_ZSTD" != Xoff && + if test "x$OPT_ZSTD" != "xoff" && test "$HAVE_ZSTD" != "1"; then AC_MSG_ERROR([libzstd was not found where specified!]) fi @@ -1610,7 +1610,7 @@ if test X"$OPT_ZSTD" != Xno; then dnl CURL_LIBRARY_PATH to prevent further configure tests to fail due to dnl this - if test "x$cross_compiling" != "xyes"; then + if test "$cross_compiling" != "yes"; then CURL_LIBRARY_PATH="$CURL_LIBRARY_PATH:$DIR_ZSTD" export CURL_LIBRARY_PATH AC_MSG_NOTICE([Added $DIR_ZSTD to CURL_LIBRARY_PATH]) @@ -1674,7 +1674,7 @@ AS_HELP_STRING([--disable-ipv6],[Disable IPv6 support]), ) ) -if test "$ipv6" = yes; then +if test "$ipv6" = "yes"; then curl_ipv6_msg="enabled" AC_DEFINE(USE_IPV6, 1, [Define if you want to enable IPv6 support]) IPV6_ENABLED=1 @@ -1732,7 +1732,7 @@ int main(int argc, char **argv) ],[ curl_cv_writable_argv=cross ]) -if test "$curl_cv_writable_argv" = 'cross' -a "$curl_cv_apple" = 'yes'; then +if test "$curl_cv_writable_argv" = "cross" && test "$curl_cv_apple" = "yes"; then curl_cv_writable_argv=yes fi case $curl_cv_writable_argv in @@ -1773,9 +1773,9 @@ AC_ARG_WITH(gssapi-libs, AC_ARG_WITH(gssapi, AS_HELP_STRING([--with-gssapi=DIR], [Where to look for GSS-API]), [ GSSAPI_ROOT="$withval" - if test x"$GSSAPI_ROOT" != xno; then + if test "$GSSAPI_ROOT" != "no"; then want_gss="yes" - if test x"$GSSAPI_ROOT" = xyes; then + if test "$GSSAPI_ROOT" = "yes"; then dnl if yes, then use default root GSSAPI_ROOT="/usr" fi @@ -1787,16 +1787,16 @@ AC_ARG_WITH(gssapi, save_CPPFLAGS="$CPPFLAGS" AC_MSG_CHECKING([if GSS-API support is requested]) -if test x"$want_gss" = xyes; then +if test "$want_gss" = "yes"; then AC_MSG_RESULT(yes) - if test $GSSAPI_ROOT != "/usr"; then + if test "$GSSAPI_ROOT" != "/usr"; then CURL_CHECK_PKGCONFIG(mit-krb5-gssapi, $GSSAPI_ROOT/lib/pkgconfig) else CURL_CHECK_PKGCONFIG(mit-krb5-gssapi) fi if test -z "$GSSAPI_INCS"; then - if test -n "$host_alias" -a -f "$GSSAPI_ROOT/bin/$host_alias-krb5-config"; then + if test -n "$host_alias" && test -f "$GSSAPI_ROOT/bin/$host_alias-krb5-config"; then GSSAPI_INCS=`$GSSAPI_ROOT/bin/$host_alias-krb5-config --cflags gssapi` elif test "$PKGCONFIG" != "no"; then GSSAPI_INCS=`$PKGCONFIG --cflags mit-krb5-gssapi` @@ -1821,7 +1821,7 @@ if test x"$want_gss" = xyes; then [gssapi/gssapi.h gssapi/gssapi_generic.h gssapi/gssapi_krb5.h], [], [not_mit=1]) - if test "x$not_mit" = "x1"; then + if test "$not_mit" = "1"; then dnl MIT not found AC_MSG_ERROR([MIT or GNU GSS library required, but not found]) fi @@ -1830,7 +1830,7 @@ if test x"$want_gss" = xyes; then else AC_MSG_RESULT(no) fi -if test x"$want_gss" = xyes; then +if test "$want_gss" = "yes"; then AC_DEFINE(HAVE_GSSAPI, 1, [if you have GSS-API libraries]) HAVE_GSSAPI=1 curl_gss_msg="enabled (MIT Kerberos)" @@ -1843,15 +1843,15 @@ if test x"$want_gss" = xyes; then LIBS="-lgss $LIBS" link_pkgconfig=1 elif test -z "$GSSAPI_LIB_DIR"; then - if test "$curl_cv_apple" = 'yes'; then + if test "$curl_cv_apple" = "yes"; then LIBS="-lgssapi_krb5 -lresolv $LIBS" else - if test $GSSAPI_ROOT != "/usr"; then + if test "$GSSAPI_ROOT" != "/usr"; then CURL_CHECK_PKGCONFIG(mit-krb5-gssapi, $GSSAPI_ROOT/lib/pkgconfig) else CURL_CHECK_PKGCONFIG(mit-krb5-gssapi) fi - if test -n "$host_alias" -a -f "$GSSAPI_ROOT/bin/$host_alias-krb5-config"; then + if test -n "$host_alias" && test -f "$GSSAPI_ROOT/bin/$host_alias-krb5-config"; then dnl krb5-config does not have --libs-only-L or similar, put everything dnl into LIBS gss_libs=`$GSSAPI_ROOT/bin/$host_alias-krb5-config --libs gssapi` @@ -1886,7 +1886,7 @@ if test x"$want_gss" = xyes; then fi fi gss_version="" - if test -n "$host_alias" -a -f "$GSSAPI_ROOT/bin/$host_alias-krb5-config"; then + if test -n "$host_alias" && test -f "$GSSAPI_ROOT/bin/$host_alias-krb5-config"; then gss_version=`$GSSAPI_ROOT/bin/$host_alias-krb5-config --version | $SED 's/Kerberos 5 release //'` elif test "$PKGCONFIG" != "no"; then gss_version=`$PKGCONFIG --modversion mit-krb5-gssapi` @@ -1920,7 +1920,7 @@ else CPPFLAGS="$save_CPPFLAGS" fi -if test x"$want_gss" = xyes; then +if test "$want_gss" = "yes"; then AC_MSG_CHECKING([if we can link against GSS-API library]) AC_LINK_IFELSE([ AC_LANG_FUNC_LINK_TRY([gss_init_sec_context]) @@ -1933,11 +1933,11 @@ if test x"$want_gss" = xyes; then fi build_libstubgss=no -if test x"$want_gss" = "xyes"; then +if test "$want_gss" = "yes"; then build_libstubgss=yes fi -AM_CONDITIONAL(BUILD_STUB_GSS, test "x$build_libstubgss" = "xyes") +AM_CONDITIONAL(BUILD_STUB_GSS, test "$build_libstubgss" = "yes") dnl ------------------------------------------------------------- dnl parse --with-default-ssl-backend so it can be validated below @@ -1974,12 +1974,12 @@ CURL_WITH_RUSTLS CURL_WITH_APPLE_SECTRUST dnl link required libraries for USE_WIN32_CRYPTO or SCHANNEL_ENABLED -if test "x$USE_WIN32_CRYPTO" = "x1" -o "x$SCHANNEL_ENABLED" = "x1"; then +if test "$USE_WIN32_CRYPTO" = "1" || test "$SCHANNEL_ENABLED" = "1"; then LIBS="-ladvapi32 -lcrypt32 $LIBS" fi dnl link bcrypt for BCryptGenRandom() (used when building for Vista or newer) -if test "x$curl_cv_native_windows" = "xyes"; then +if test "$curl_cv_native_windows" = "yes"; then LIBS="-lbcrypt $LIBS" fi @@ -2014,13 +2014,13 @@ if test -n "$ssl_backends"; then curl_ssl_msg="enabled ($ssl_backends)" fi -if test no = "$VALID_DEFAULT_SSL_BACKEND"; then +if test "$VALID_DEFAULT_SSL_BACKEND" = "no"; then if test -n "$SSL_ENABLED"; then AC_MSG_ERROR([Default SSL backend $DEFAULT_SSL_BACKEND not enabled!]) else AC_MSG_ERROR([Default SSL backend requires SSL!]) fi -elif test yes = "$VALID_DEFAULT_SSL_BACKEND"; then +elif test "$VALID_DEFAULT_SSL_BACKEND" = "yes"; then AC_DEFINE_UNQUOTED([CURL_DEFAULT_SSL_BACKEND], ["$DEFAULT_SSL_BACKEND"], [Default SSL backend]) fi @@ -2033,7 +2033,7 @@ if test -n "$check_for_ca_bundle"; then CURL_CHECK_CA_EMBED fi -AM_CONDITIONAL(CURL_CA_EMBED_SET, test "x$CURL_CA_EMBED" != "x") +AM_CONDITIONAL(CURL_CA_EMBED_SET, test -n "$CURL_CA_EMBED") dnl ---------------------- dnl check unsafe CA search @@ -2090,7 +2090,7 @@ AS_HELP_STRING([--with-libpsl=PATH],[Where to look for libpsl, PATH points to th AS_HELP_STRING([--without-libpsl], [disable LIBPSL]), OPT_LIBPSL=$withval) -if test X"$OPT_LIBPSL" != Xno; then +if test "x$OPT_LIBPSL" != "xno"; then dnl backup the pre-libpsl variables CLEANLDFLAGS="$LDFLAGS" CLEANLDFLAGSPC="$LDFLAGSPC" @@ -2163,7 +2163,7 @@ AS_HELP_STRING([--with-libgsasl=PATH],[Where to look for libgsasl, PATH points t AS_HELP_STRING([--without-libgsasl], [disable libgsasl support for SCRAM]), OPT_LIBGSASL=$withval) -if test "$OPT_LIBGSASL" != no; then +if test "x$OPT_LIBGSASL" != "xno"; then dnl backup the pre-libgsasl variables CLEANLDFLAGS="$LDFLAGS" CLEANLDFLAGSPC="$LDFLAGSPC" @@ -2243,7 +2243,7 @@ AS_HELP_STRING([--with-libssh=PATH],[Where to look for libssh, PATH points to th AS_HELP_STRING([--with-libssh], [enable libssh]), OPT_LIBSSH=$withval, OPT_LIBSSH=no) -if test X"$OPT_LIBSSH2" != Xno; then +if test "x$OPT_LIBSSH2" != "xno"; then dnl backup the pre-libssh2 variables CLEANLDFLAGS="$LDFLAGS" CLEANLDFLAGSPC="$LDFLAGSPC" @@ -2295,7 +2295,7 @@ if test X"$OPT_LIBSSH2" != Xno; then USE_LIBSSH2=1 ) - if test X"$OPT_LIBSSH2" != Xoff && + if test "x$OPT_LIBSSH2" != "xoff" && test "$USE_LIBSSH2" != "1"; then AC_MSG_ERROR([libssh2 libs and/or directories were not found where specified!]) fi @@ -2306,7 +2306,7 @@ if test X"$OPT_LIBSSH2" != Xno; then dnl linker does not search through, we need to add it to CURL_LIBRARY_PATH dnl to prevent further configure tests to fail due to this - if test "x$cross_compiling" != "xyes"; then + if test "$cross_compiling" != "yes"; then CURL_LIBRARY_PATH="$CURL_LIBRARY_PATH:$DIR_SSH2" export CURL_LIBRARY_PATH AC_MSG_NOTICE([Added $DIR_SSH2 to CURL_LIBRARY_PATH]) @@ -2320,7 +2320,7 @@ if test X"$OPT_LIBSSH2" != Xno; then CPPFLAGS=$CLEANCPPFLAGS LIBS=$CLEANLIBS fi -elif test X"$OPT_LIBSSH" != Xno; then +elif test "x$OPT_LIBSSH" != "xno"; then dnl backup the pre-libssh variables CLEANLDFLAGS="$LDFLAGS" CLEANLDFLAGSPC="$LDFLAGSPC" @@ -2371,7 +2371,7 @@ elif test X"$OPT_LIBSSH" != Xno; then USE_LIBSSH=1 ) - if test X"$OPT_LIBSSH" != Xoff && + if test "x$OPT_LIBSSH" != "xoff" && test "$USE_LIBSSH" != "1"; then AC_MSG_ERROR([libssh libs and/or directories were not found where specified!]) fi @@ -2386,7 +2386,7 @@ elif test X"$OPT_LIBSSH" != Xno; then dnl linker does not search through, we need to add it to CURL_LIBRARY_PATH dnl to prevent further configure tests to fail due to this - if test "x$cross_compiling" != "xyes"; then + if test "$cross_compiling" != "yes"; then CURL_LIBRARY_PATH="$CURL_LIBRARY_PATH:$DIR_SSH" export CURL_LIBRARY_PATH AC_MSG_NOTICE([Added $DIR_SSH to CURL_LIBRARY_PATH]) @@ -2456,14 +2456,14 @@ case "$OPT_LDAP" in ;; esac -if test x$CURL_DISABLE_LDAP != x1 && test "$want_ldap" != "no"; then +if test "$CURL_DISABLE_LDAP" != "1" && test "$want_ldap" != "no"; then CURL_CHECK_HEADER_LBER CURL_CHECK_HEADER_LDAP CURL_CHECK_HEADER_LDAP_SSL if test -z "$LDAPLIBNAME"; then - if test "$curl_cv_native_windows" = "yes" -a "$curl_cv_winuwp" != "yes"; then + if test "$curl_cv_native_windows" = "yes" && test "$curl_cv_winuwp" != "yes"; then dnl Windows uses a single and unique LDAP library name LDAPLIBNAME="wldap32" LBERLIBNAME="no" @@ -2472,7 +2472,7 @@ if test x$CURL_DISABLE_LDAP != x1 && test "$want_ldap" != "no"; then if test "$LDAPLIBNAME"; then dnl If we have both LDAP and LBER library names, check if we need both - if test "$LBERLIBNAME" -a "$LBERLIBNAME" != "no"; then + if test "$LBERLIBNAME" && test "$LBERLIBNAME" != "no"; then dnl Try LDAP first, then with LBER if needed AC_CHECK_LIB("$LDAPLIBNAME", ldap_init, [ldap_lib_ok=yes], [ldap_lib_ok=no]) if test "$ldap_lib_ok" = "no"; then @@ -2527,7 +2527,7 @@ if test x$CURL_DISABLE_LDAP != x1 && test "$want_ldap" != "no"; then fi fi -if test x$CURL_DISABLE_LDAP != x1; then +if test "$CURL_DISABLE_LDAP" != "1"; then dnl Add to library path if needed if test -n "$DIR_LDAP"; then dnl when the ldap shared lib were found in a path that the runtime @@ -2535,7 +2535,7 @@ if test x$CURL_DISABLE_LDAP != x1; then dnl CURL_LIBRARY_PATH to prevent further configure tests to fail due to dnl this - if test "x$cross_compiling" != "xyes"; then + if test "$cross_compiling" != "yes"; then CURL_LIBRARY_PATH="$CURL_LIBRARY_PATH:$DIR_LDAP" export CURL_LIBRARY_PATH AC_MSG_NOTICE([Added $DIR_LDAP to CURL_LIBRARY_PATH]) @@ -2546,7 +2546,7 @@ if test x$CURL_DISABLE_LDAP != x1; then dnl If name is "no" then do not define this library at all dnl (it is only needed if libldap.so's dependencies are broken). dnl Skip this check if we already determined we need both libraries above - if test "$LBERLIBNAME" != "no" -a "$ldap_lib_ok" != "yes"; then + if test "$LBERLIBNAME" != "no" && test "$ldap_lib_ok" != "yes"; then AC_CHECK_LIB("$LBERLIBNAME", ber_free,, [ AC_MSG_WARN(["$LBERLIBNAME" is not an LBER library: LDAP disabled]) AC_DEFINE(CURL_DISABLE_LDAP, 1, [to disable LDAP]) @@ -2563,7 +2563,7 @@ if test x$CURL_DISABLE_LDAP != x1; then fi fi -if test x$CURL_DISABLE_LDAP != x1; then +if test "$CURL_DISABLE_LDAP" != "1"; then AC_CHECK_FUNCS([ldap_url_parse \ ldap_init_fd]) @@ -2571,7 +2571,7 @@ if test x$CURL_DISABLE_LDAP != x1; then curl_ldap_msg="enabled (winldap)" AC_DEFINE(USE_WIN32_LDAP, 1, [Use Windows LDAP implementation]) else - if test "x$ac_cv_func_ldap_init_fd" = "xyes"; then + if test "$ac_cv_func_ldap_init_fd" = "yes"; then curl_ldap_msg="enabled (OpenLDAP)" AC_DEFINE(USE_OPENLDAP, 1, [Use OpenLDAP-specific code]) USE_OPENLDAP=1 @@ -2581,7 +2581,7 @@ if test x$CURL_DISABLE_LDAP != x1; then fi fi -if test x$CURL_DISABLE_LDAPS != x1; then +if test "$CURL_DISABLE_LDAPS" != "1"; then curl_ldaps_msg="enabled" fi @@ -2596,7 +2596,7 @@ AS_HELP_STRING([--with-librtmp=PATH],[Where to look for librtmp, PATH points to AS_HELP_STRING([--without-librtmp], [disable LIBRTMP]), OPT_LIBRTMP=$withval) -if test X"$OPT_LIBRTMP" != Xno; then +if test "x$OPT_LIBRTMP" != "xno"; then dnl backup the pre-librtmp variables CLEANLDFLAGS="$LDFLAGS" CLEANLDFLAGSPC="$LDFLAGSPC" @@ -2660,7 +2660,7 @@ if test X"$OPT_LIBRTMP" != Xno; then LIBS=$CLEANLIBS ) - if test X"$OPT_LIBRTMP" != Xoff && + if test "x$OPT_LIBRTMP" != "xoff" && test "$USE_LIBRTMP" != "1"; then AC_MSG_ERROR([librtmp libs and/or directories were not found where specified!]) fi @@ -2690,17 +2690,17 @@ AS_HELP_STRING([--disable-versioned-symbols], [Disable versioned symbols in shar AC_MSG_RESULT(yes) if test "x$enableval" != "xyes"; then versioned_symbols_flavour="$enableval" - elif test "x$CURL_WITH_MULTI_SSL" = "x1"; then + elif test "$CURL_WITH_MULTI_SSL" = "1"; then versioned_symbols_flavour="MULTISSL_" - elif test "x$OPENSSL_ENABLED" = "x1"; then + elif test "$OPENSSL_ENABLED" = "1"; then versioned_symbols_flavour="OPENSSL_" - elif test "x$MBEDTLS_ENABLED" = "x1"; then + elif test "$MBEDTLS_ENABLED" = "1"; then versioned_symbols_flavour="MBEDTLS_" - elif test "x$WOLFSSL_ENABLED" = "x1"; then + elif test "$WOLFSSL_ENABLED" = "1"; then versioned_symbols_flavour="WOLFSSL_" - elif test "x$GNUTLS_ENABLED" = "x1"; then + elif test "$GNUTLS_ENABLED" = "1"; then versioned_symbols_flavour="GNUTLS_" - elif test "x$RUSTLS_ENABLED" = "x1"; then + elif test "$RUSTLS_ENABLED" = "1"; then versioned_symbols_flavour="RUSTLS_" else versioned_symbols_flavour="" @@ -2718,7 +2718,7 @@ AS_HELP_STRING([--disable-versioned-symbols], [Disable versioned symbols in shar AC_SUBST([CURL_LIBCURL_VERSIONED_SYMBOLS_PREFIX], ["$versioned_symbols_flavour"]) AC_SUBST([CURL_LIBCURL_VERSIONED_SYMBOLS_SONAME], ["4"]) dnl Keep in sync with VERSIONCHANGE - VERSIONDEL in lib/Makefile.soname AM_CONDITIONAL([CURL_LT_SHLIB_USE_VERSIONED_SYMBOLS], - [test "x$versioned_symbols" = 'xyes']) + [test "$versioned_symbols" = "yes"]) dnl ---------------------------- dnl check Windows Unicode option @@ -2726,7 +2726,7 @@ dnl ---------------------------- want_winuni="no" if test "$curl_cv_native_windows" = "yes"; then - if test "$curl_cv_winuwp" = 'yes'; then + if test "$curl_cv_winuwp" = "yes"; then want_winuni="yes" else AC_MSG_CHECKING([whether to enable Windows Unicode (Windows native builds only)]) @@ -2758,7 +2758,7 @@ dnl check WinIDN option before other IDN libraries dnl ------------------------------------------------- tst_links_winidn='no' -if test "$curl_cv_native_windows" = 'yes'; then +if test "$curl_cv_native_windows" = "yes"; then AC_MSG_CHECKING([whether to enable Windows native IDN (Windows native builds only)]) OPT_WINIDN="default" AC_ARG_WITH(winidn, @@ -2848,7 +2848,7 @@ dnl Check for the presence of AppleIDN dnl ********************************************************************** tst_links_appleidn='no' -if test "$curl_cv_apple" = 'yes'; then +if test "$curl_cv_apple" = "yes"; then AC_MSG_CHECKING([whether to build with Apple IDN]) OPT_IDN="default" AC_ARG_WITH(apple-idn, @@ -2887,10 +2887,10 @@ AC_ARG_WITH(libidn2, AS_HELP_STRING([--with-libidn2=PATH],[Enable libidn2 usage]) AS_HELP_STRING([--without-libidn2],[Disable libidn2 usage]), [OPT_IDN=$withval]) -if test "x$tst_links_winidn" = "xyes"; then +if test "$tst_links_winidn" = "yes"; then want_idn="no" AC_MSG_RESULT([no (using WinIDN instead)]) -elif test "x$tst_links_appleidn" = "xyes"; then +elif test "$tst_links_appleidn" = "yes"; then want_idn="no" AC_MSG_RESULT([no (using AppleIDN instead)]) else @@ -2998,7 +2998,7 @@ if test "$want_idn" = "yes"; then IDN_ENABLED=1 curl_idn_msg="enabled (libidn2)" - if test -n "$IDN_DIR" -a "x$cross_compiling" != "xyes"; then + if test -n "$IDN_DIR" && test "$cross_compiling" != "yes"; then CURL_LIBRARY_PATH="$CURL_LIBRARY_PATH:$IDN_DIR" export CURL_LIBRARY_PATH AC_MSG_NOTICE([Added $IDN_DIR to CURL_LIBRARY_PATH]) @@ -3020,7 +3020,7 @@ dnl ********************************************************************** OPT_H2="yes" -if test "x$disable_http" = "xyes"; then +if test "$disable_http" = "yes"; then # without HTTP nghttp2 is no use OPT_H2="no" fi @@ -3048,7 +3048,7 @@ case "$OPT_H2" in ;; esac -if test X"$want_nghttp2" != Xno; then +if test "$want_nghttp2" != "no"; then dnl backup the pre-nghttp2 variables CLEANLDFLAGS="$LDFLAGS" CLEANLDFLAGSPC="$LDFLAGSPC" @@ -3071,12 +3071,12 @@ if test X"$want_nghttp2" != Xno; then AC_MSG_NOTICE([-L is $LD_H2]) DIR_H2=`echo $LD_H2 | $SED -e 's/^-L//'` - elif test x"$want_nghttp2_path" != x; then + elif test -n "$want_nghttp2_path"; then LIB_H2="-lnghttp2" LD_H2=-L${want_nghttp2_path}/lib$libsuff CPP_H2=-I${want_nghttp2_path}/include DIR_H2=${want_nghttp2_path}/lib$libsuff - elif test X"$want_nghttp2" != Xdefault; then + elif test "$want_nghttp2" != "default"; then dnl no nghttp2 pkg-config found and no custom directory specified, dnl deal with it AC_MSG_ERROR([--with-nghttp2 was specified but could not find libnghttp2 pkg-config file.]) @@ -3118,7 +3118,7 @@ dnl ********************************************************************** OPT_TCP2="no" -if test "x$disable_http" = "xyes"; then +if test "$disable_http" = "yes"; then # without HTTP, ngtcp2 is no use OPT_TCP2="no" fi @@ -3145,7 +3145,7 @@ case "$OPT_TCP2" in esac curl_tcp2_msg="no (--with-ngtcp2)" -if test X"$want_tcp2" != Xno; then +if test "$want_tcp2" != "no"; then if test "$QUIC_ENABLED" != "yes"; then AC_MSG_ERROR([the detected TLS library does not support QUIC, making --with-ngtcp2 a no-no]) @@ -3177,7 +3177,7 @@ if test X"$want_tcp2" != Xno; then CPPFLAGS="$CPPFLAGS $CPP_TCP2" LIBS="$LIB_TCP2 $LIBS" - if test "x$cross_compiling" != "xyes"; then + if test "$cross_compiling" != "yes"; then DIR_TCP2=`echo $LD_TCP2 | $SED -e 's/^-L//'` fi AC_CHECK_LIB(ngtcp2, ngtcp2_conn_client_new_versioned, @@ -3200,7 +3200,7 @@ if test X"$want_tcp2" != Xno; then else dnl no ngtcp2 pkg-config found, deal with it - if test X"$want_tcp2" != Xdefault; then + if test "$want_tcp2" != "default"; then dnl To avoid link errors, we do not allow --with-ngtcp2 without dnl a pkgconfig file AC_MSG_ERROR([--with-ngtcp2 was specified but could not find ngtcp2 pkg-config file.]) @@ -3208,7 +3208,8 @@ if test X"$want_tcp2" != Xno; then fi fi -if test "x$USE_NGTCP2" = "x1" -a "x$OPENSSL_ENABLED" = "x1" -a "$HAVE_LIBRESSL" = "1"; then +if test "$USE_NGTCP2" = "1" && test "$OPENSSL_ENABLED" = "1" && test "$HAVE_LIBRESSL" = "1"; then + dnl backup the pre-ngtcp2_crypto_libressl variables CLEANLDFLAGS="$LDFLAGS" CLEANLDFLAGSPC="$LDFLAGSPC" @@ -3235,7 +3236,7 @@ if test "x$USE_NGTCP2" = "x1" -a "x$OPENSSL_ENABLED" = "x1" -a "$HAVE_LIBRESSL" CPPFLAGS="$CPPFLAGS $CPP_NGTCP2_CRYPTO_LIBRESSL" LIBS="$LIB_NGTCP2_CRYPTO_LIBRESSL $LIBS" - if test "x$cross_compiling" != "xyes"; then + if test "$cross_compiling" != "yes"; then DIR_NGTCP2_CRYPTO_LIBRESSL=`echo $LD_NGTCP2_CRYPTO_LIBRESSL | $SED -e 's/^-L//'` fi AC_CHECK_LIB(ngtcp2_crypto_libressl, ngtcp2_crypto_recv_client_initial_cb, @@ -3257,7 +3258,7 @@ if test "x$USE_NGTCP2" = "x1" -a "x$OPENSSL_ENABLED" = "x1" -a "$HAVE_LIBRESSL" else dnl no ngtcp2_crypto_libressl pkg-config found, deal with it - if test X"$want_tcp2" != Xdefault; then + if test "$want_tcp2" != "default"; then dnl To avoid link errors, we do not allow --with-ngtcp2 without dnl a pkgconfig file AC_MSG_WARN([--with-ngtcp2 was specified but could not find ngtcp2_crypto_libressl pkg-config file.]) @@ -3267,8 +3268,9 @@ if test "x$USE_NGTCP2" = "x1" -a "x$OPENSSL_ENABLED" = "x1" -a "$HAVE_LIBRESSL" fi fi -if test "x$USE_NGTCP2" = "x1" -a "x$OPENSSL_ENABLED" = "x1" -a "$HAVE_LIBRESSL" != "1" -a \ - "x$OPENSSL_IS_BORINGSSL" != "x1" -a "x$OPENSSL_QUIC_API2" != "x1"; then +if test "$USE_NGTCP2" = "1" && test "$OPENSSL_ENABLED" = "1" && test "$OPENSSL_IS_BORINGSSL" != "1" && + test "$OPENSSL_QUIC_API2" != "1"; then + dnl backup the pre-ngtcp2_crypto_quictls variables CLEANLDFLAGS="$LDFLAGS" CLEANLDFLAGSPC="$LDFLAGSPC" @@ -3295,7 +3297,7 @@ if test "x$USE_NGTCP2" = "x1" -a "x$OPENSSL_ENABLED" = "x1" -a "$HAVE_LIBRESSL" CPPFLAGS="$CPPFLAGS $CPP_NGTCP2_CRYPTO_QUICTLS" LIBS="$LIB_NGTCP2_CRYPTO_QUICTLS $LIBS" - if test "x$cross_compiling" != "xyes"; then + if test "$cross_compiling" != "yes"; then DIR_NGTCP2_CRYPTO_QUICTLS=`echo $LD_NGTCP2_CRYPTO_QUICTLS | $SED -e 's/^-L//'` fi AC_CHECK_LIB(ngtcp2_crypto_quictls, ngtcp2_crypto_recv_client_initial_cb, @@ -3317,7 +3319,7 @@ if test "x$USE_NGTCP2" = "x1" -a "x$OPENSSL_ENABLED" = "x1" -a "$HAVE_LIBRESSL" else dnl no ngtcp2_crypto_quictls pkg-config found, deal with it - if test X"$want_tcp2" != Xdefault; then + if test "$want_tcp2" != "default"; then dnl To avoid link errors, we do not allow --with-ngtcp2 without dnl a pkgconfig file AC_MSG_ERROR([--with-ngtcp2 was specified but could not find ngtcp2_crypto_quictls pkg-config file.]) @@ -3325,8 +3327,9 @@ if test "x$USE_NGTCP2" = "x1" -a "x$OPENSSL_ENABLED" = "x1" -a "$HAVE_LIBRESSL" fi fi -if test "x$USE_NGTCP2" = "x1" -a "x$OPENSSL_ENABLED" = "x1" -a \ - "x$OPENSSL_IS_BORINGSSL" != "x1" -a "x$OPENSSL_QUIC_API2" = "x1"; then +if test "$USE_NGTCP2" = "1" && test "$OPENSSL_ENABLED" = "1" && test "$OPENSSL_IS_BORINGSSL" != "1" && + test "$OPENSSL_QUIC_API2" = "1"; then + dnl backup the pre-ngtcp2_crypto_ossl variables CLEANLDFLAGS="$LDFLAGS" CLEANLDFLAGSPC="$LDFLAGSPC" @@ -3353,7 +3356,7 @@ if test "x$USE_NGTCP2" = "x1" -a "x$OPENSSL_ENABLED" = "x1" -a \ CPPFLAGS="$CPPFLAGS $CPP_NGTCP2_CRYPTO_OSSL" LIBS="$LIB_NGTCP2_CRYPTO_OSSL $LIBS" - if test "x$cross_compiling" != "xyes"; then + if test "$cross_compiling" != "yes"; then DIR_NGTCP2_CRYPTO_OSSL=`echo $LD_NGTCP2_CRYPTO_OSSL | $SED -e 's/^-L//'` fi AC_CHECK_LIB(ngtcp2_crypto_ossl, ngtcp2_crypto_recv_client_initial_cb, @@ -3376,7 +3379,7 @@ if test "x$USE_NGTCP2" = "x1" -a "x$OPENSSL_ENABLED" = "x1" -a \ else dnl no ngtcp2_crypto_ossl pkg-config found, deal with it - if test X"$want_tcp2" != Xdefault; then + if test "$want_tcp2" != "default"; then dnl To avoid link errors, we do not allow --with-ngtcp2 without dnl a pkgconfig file AC_MSG_ERROR([--with-ngtcp2 was specified but could not find ngtcp2_crypto_ossl pkg-config file.]) @@ -3384,7 +3387,8 @@ if test "x$USE_NGTCP2" = "x1" -a "x$OPENSSL_ENABLED" = "x1" -a \ fi fi -if test "x$USE_NGTCP2" = "x1" -a "x$OPENSSL_ENABLED" = "x1" -a "x$OPENSSL_IS_BORINGSSL" = "x1"; then +if test "$USE_NGTCP2" = "1" && test "$OPENSSL_ENABLED" = "1" && test "$OPENSSL_IS_BORINGSSL" = "1"; then + dnl backup the pre-ngtcp2_crypto_boringssl variables CLEANLDFLAGS="$LDFLAGS" CLEANLDFLAGSPC="$LDFLAGSPC" @@ -3411,7 +3415,7 @@ if test "x$USE_NGTCP2" = "x1" -a "x$OPENSSL_ENABLED" = "x1" -a "x$OPENSSL_IS_BOR CPPFLAGS="$CPPFLAGS $CPP_NGTCP2_CRYPTO_BORINGSSL" LIBS="$LIB_NGTCP2_CRYPTO_BORINGSSL $LIBS" - if test "x$cross_compiling" != "xyes"; then + if test "$cross_compiling" != "yes"; then DIR_NGTCP2_CRYPTO_BORINGSSL=`echo $LD_NGTCP2_CRYPTO_BORINGSSL | $SED -e 's/^-L//'` fi AC_CHECK_LIB(ngtcp2_crypto_boringssl, ngtcp2_crypto_recv_client_initial_cb, @@ -3433,7 +3437,7 @@ if test "x$USE_NGTCP2" = "x1" -a "x$OPENSSL_ENABLED" = "x1" -a "x$OPENSSL_IS_BOR else dnl no ngtcp2_crypto_boringssl pkg-config found, deal with it - if test X"$want_tcp2" != Xdefault; then + if test "$want_tcp2" != "default"; then dnl To avoid link errors, we do not allow --with-ngtcp2 without dnl a pkgconfig file AC_MSG_ERROR([--with-ngtcp2 was specified but could not find ngtcp2_crypto_boringssl pkg-config file.]) @@ -3441,7 +3445,7 @@ if test "x$USE_NGTCP2" = "x1" -a "x$OPENSSL_ENABLED" = "x1" -a "x$OPENSSL_IS_BOR fi fi -if test "x$USE_NGTCP2" = "x1" -a "x$GNUTLS_ENABLED" = "x1"; then +if test "$USE_NGTCP2" = "1" && test "$GNUTLS_ENABLED" = "1"; then dnl backup the pre-ngtcp2_crypto_gnutls variables CLEANLDFLAGS="$LDFLAGS" CLEANLDFLAGSPC="$LDFLAGSPC" @@ -3468,7 +3472,7 @@ if test "x$USE_NGTCP2" = "x1" -a "x$GNUTLS_ENABLED" = "x1"; then CPPFLAGS="$CPPFLAGS $CPP_NGTCP2_CRYPTO_GNUTLS" LIBS="$LIB_NGTCP2_CRYPTO_GNUTLS $LIBS" - if test "x$cross_compiling" != "xyes"; then + if test "$cross_compiling" != "yes"; then DIR_NGTCP2_CRYPTO_GNUTLS=`echo $LD_NGTCP2_CRYPTO_GNUTLS | $SED -e 's/^-L//'` fi AC_CHECK_LIB(ngtcp2_crypto_gnutls, ngtcp2_crypto_recv_client_initial_cb, @@ -3490,7 +3494,7 @@ if test "x$USE_NGTCP2" = "x1" -a "x$GNUTLS_ENABLED" = "x1"; then else dnl no ngtcp2_crypto_gnutls pkg-config found, deal with it - if test X"$want_tcp2" != Xdefault; then + if test "$want_tcp2" != "default"; then dnl To avoid link errors, we do not allow --with-ngtcp2 without dnl a pkgconfig file AC_MSG_ERROR([--with-ngtcp2 was specified but could not find ngtcp2_crypto_gnutls pkg-config file.]) @@ -3498,7 +3502,7 @@ if test "x$USE_NGTCP2" = "x1" -a "x$GNUTLS_ENABLED" = "x1"; then fi fi -if test "x$USE_NGTCP2" = "x1" -a "x$WOLFSSL_ENABLED" = "x1"; then +if test "$USE_NGTCP2" = "1" && test "$WOLFSSL_ENABLED" = "1"; then dnl backup the pre-ngtcp2_crypto_wolfssl variables CLEANLDFLAGS="$LDFLAGS" CLEANLDFLAGSPC="$LDFLAGSPC" @@ -3525,7 +3529,7 @@ if test "x$USE_NGTCP2" = "x1" -a "x$WOLFSSL_ENABLED" = "x1"; then CPPFLAGS="$CPPFLAGS $CPP_NGTCP2_CRYPTO_WOLFSSL" LIBS="$LIB_NGTCP2_CRYPTO_WOLFSSL $LIBS" - if test "x$cross_compiling" != "xyes"; then + if test "$cross_compiling" != "yes"; then DIR_NGTCP2_CRYPTO_WOLFSSL=`echo $LD_NGTCP2_CRYPTO_WOLFSSL | $SED -e 's/^-L//'` fi AC_CHECK_LIB(ngtcp2_crypto_wolfssl, ngtcp2_crypto_recv_client_initial_cb, @@ -3547,7 +3551,7 @@ if test "x$USE_NGTCP2" = "x1" -a "x$WOLFSSL_ENABLED" = "x1"; then else dnl no ngtcp2_crypto_wolfssl pkg-config found, deal with it - if test X"$want_tcp2" != Xdefault; then + if test "$want_tcp2" != "default"; then dnl To avoid link errors, we do not allow --with-ngtcp2 without dnl a pkgconfig file AC_MSG_ERROR([--with-ngtcp2 was specified but could not find ngtcp2_crypto_wolfssl pkg-config file.]) @@ -3561,7 +3565,7 @@ dnl ********************************************************************** OPT_OPENSSL_QUIC="no" -if test "x$disable_http" = "xyes" -o "x$OPENSSL_ENABLED" != "x1"; then +if test "$disable_http" = "yes" || test "$OPENSSL_ENABLED" != "1"; then # without HTTP or without openssl, no use OPT_OPENSSL_QUIC="no" fi @@ -3582,12 +3586,12 @@ case "$OPT_OPENSSL_QUIC" in esac curl_openssl_quic_msg="no (--with-openssl-quic)" -if test "x$want_openssl_quic" = "xyes"; then +if test "$want_openssl_quic" = "yes"; then - if test "$USE_NGTCP2" = 1; then + if test "$USE_NGTCP2" = "1"; then AC_MSG_ERROR([--with-openssl-quic and --with-ngtcp2 are mutually exclusive]) fi - if test "$have_openssl_quic" != 1; then + if test "$have_openssl_quic" != "1"; then AC_MSG_ERROR([--with-openssl-quic requires quic support and OpenSSL >= 3.3.0]) fi AC_DEFINE(USE_OPENSSL_QUIC, 1, [if openssl QUIC is in use]) @@ -3600,7 +3604,7 @@ dnl ********************************************************************** OPT_NGHTTP3="yes" -if test "x$USE_NGTCP2" != "x1" -a "x$USE_OPENSSL_QUIC" != "x1"; then +if test "$USE_NGTCP2" != "1" && test "$USE_OPENSSL_QUIC" != "1"; then # without ngtcp2 or openssl quic, nghttp3 is of no use for us OPT_NGHTTP3="no" want_nghttp3="no" @@ -3628,9 +3632,9 @@ case "$OPT_NGHTTP3" in esac curl_http3_msg="no (--with-nghttp3)" -if test X"$want_nghttp3" != Xno; then +if test "$want_nghttp3" != "no"; then - if test "x$USE_NGTCP2" != "x1" -a "x$USE_OPENSSL_QUIC" != "x1"; then + if test "$USE_NGTCP2" != "1" && test "$USE_OPENSSL_QUIC" != "1"; then # without ngtcp2 or openssl quic, nghttp3 is of no use for us AC_MSG_ERROR([nghttp3 enabled without a QUIC library; enable ngtcp2 or OpenSSL-QUIC]) fi @@ -3661,7 +3665,7 @@ if test X"$want_nghttp3" != Xno; then CPPFLAGS="$CPPFLAGS $CPP_NGHTTP3" LIBS="$LIB_NGHTTP3 $LIBS" - if test "x$cross_compiling" != "xyes"; then + if test "$cross_compiling" != "yes"; then DIR_NGHTTP3=`echo $LD_NGHTTP3 | $SED -e 's/^-L//'` fi AC_CHECK_LIB(nghttp3, nghttp3_conn_client_new_versioned, @@ -3684,7 +3688,7 @@ if test X"$want_nghttp3" != Xno; then else dnl no nghttp3 pkg-config found, deal with it - if test X"$want_nghttp3" != Xdefault; then + if test "$want_nghttp3" != "default"; then dnl To avoid link errors, we do not allow --with-nghttp3 without dnl a pkgconfig file AC_MSG_ERROR([--with-nghttp3 was specified but could not find nghttp3 pkg-config file.]) @@ -3696,7 +3700,7 @@ dnl ********************************************************************** dnl Check for ngtcp2 and nghttp3 (HTTP/3 with ngtcp2 + nghttp3) dnl ********************************************************************** -if test "x$USE_NGTCP2" = "x1" -a "x$USE_NGHTTP3" = "x1"; then +if test "$USE_NGTCP2" = "1" && test "$USE_NGHTTP3" = "1"; then USE_NGTCP2_H3=1 AC_MSG_NOTICE([HTTP3 support is experimental]) curl_h3_msg="enabled (ngtcp2 + nghttp3)" @@ -3706,7 +3710,7 @@ dnl ********************************************************************** dnl Check for OpenSSL and nghttp3 (HTTP/3 with nghttp3 using OpenSSL QUIC) dnl ********************************************************************** -if test "x$USE_OPENSSL_QUIC" = "x1" -a "x$USE_NGHTTP3" = "x1"; then +if test "$USE_OPENSSL_QUIC" = "1" && test "$USE_NGHTTP3" = "1"; then experimental="$experimental HTTP3" USE_OPENSSL_H3=1 AC_MSG_NOTICE([HTTP3 support is experimental]) @@ -3719,7 +3723,7 @@ dnl ********************************************************************** OPT_QUICHE="no" -if test "x$disable_http" = "xyes" -o "x$USE_NGTCP" = "x1"; then +if test "$disable_http" = "yes" || test "$USE_NGTCP" = "1"; then # without HTTP or with ngtcp2, quiche is no use OPT_QUICHE="no" fi @@ -3745,13 +3749,13 @@ case "$OPT_QUICHE" in ;; esac -if test X"$want_quiche" != Xno; then +if test "$want_quiche" != "no"; then if test "$QUIC_ENABLED" != "yes"; then AC_MSG_ERROR([the detected TLS library does not support QUIC, making --with-quiche a no-no]) fi - if test "$NGHTTP3_ENABLED" = 1; then + if test "$NGHTTP3_ENABLED" = "1"; then AC_MSG_ERROR([--with-quiche and --with-ngtcp2 are mutually exclusive]) fi @@ -3781,7 +3785,7 @@ if test X"$want_quiche" != Xno; then CPPFLAGS="$CPPFLAGS $CPP_QUICHE" LIBS="$LIB_QUICHE $LIBS" - if test "x$cross_compiling" != "xyes"; then + if test "$cross_compiling" != "yes"; then DIR_QUICHE=`echo $LD_QUICHE | $SED -e 's/^-L//'` fi AC_CHECK_LIB(quiche, quiche_conn_send_ack_eliciting, @@ -3809,7 +3813,7 @@ if test X"$want_quiche" != Xno; then ) else dnl no quiche pkg-config found, deal with it - if test X"$want_quiche" != Xdefault; then + if test "$want_quiche" != "default"; then dnl To avoid link errors, we do not allow --with-quiche without dnl a pkgconfig file AC_MSG_ERROR([--with-quiche was specified but could not find quiche pkg-config file.]) @@ -3843,8 +3847,8 @@ case "$OPT_LIBUV" in ;; esac -if test X"$want_libuv" != Xno; then - if test x$want_debug != xyes; then +if test "$want_libuv" != "no"; then + if test "$want_debug" != "yes"; then AC_MSG_ERROR([Using libuv without debug support enabled is useless]) fi @@ -3874,7 +3878,7 @@ if test X"$want_libuv" != Xno; then CPPFLAGS="$CPPFLAGS $CPP_LIBUV" LIBS="$LIB_LIBUV $LIBS" - if test "x$cross_compiling" != "xyes"; then + if test "$cross_compiling" != "yes"; then DIR_LIBUV=`echo $LD_LIBUV | $SED -e 's/^-L//'` fi AC_CHECK_LIB(uv, uv_default_loop, @@ -3897,7 +3901,7 @@ if test X"$want_libuv" != Xno; then else dnl no libuv pkg-config found, deal with it - if test X"$want_libuv" != Xdefault; then + if test "$want_libuv" != "default"; then dnl To avoid link errors, we do not allow --with-libuv without dnl a pkgconfig file AC_MSG_ERROR([--with-libuv was specified but could not find libuv pkg-config file.]) @@ -3930,11 +3934,11 @@ case "$OPT_ZSH_FPATH" in AC_SUBST(ZSH_FUNCTIONS_DIR) ;; esac -if test -z "$PERL" -a x"$ZSH_FUNCTIONS_DIR" != x; then +if test -z "$PERL" && test -n "$ZSH_FUNCTIONS_DIR"; then AC_MSG_WARN([perl was not found. Will not install zsh completions.]) ZSH_FUNCTIONS_DIR='' fi -AM_CONDITIONAL(USE_ZSH_COMPLETION, test x"$ZSH_FUNCTIONS_DIR" != x) +AM_CONDITIONAL(USE_ZSH_COMPLETION, test -n "$ZSH_FUNCTIONS_DIR") dnl ********************************************************************** dnl Check for fish completion path @@ -3965,11 +3969,11 @@ case "$OPT_FISH_FPATH" in AC_SUBST(FISH_FUNCTIONS_DIR) ;; esac -if test -z "$PERL" -a x"$FISH_FUNCTIONS_DIR" != x; then +if test -z "$PERL" && test -n "$FISH_FUNCTIONS_DIR"; then AC_MSG_WARN([perl was not found. Will not install fish completions.]) FISH_FUNCTIONS_DIR='' fi -AM_CONDITIONAL(USE_FISH_COMPLETION, test x"$FISH_FUNCTIONS_DIR" != x) +AM_CONDITIONAL(USE_FISH_COMPLETION, test -n "$FISH_FUNCTIONS_DIR") dnl Now check for the most basic headers. Then we can use these dnl ones as default-headers when checking for the rest! @@ -4067,7 +4071,7 @@ AC_CHECK_TYPE(long long, [Define to 1 if the compiler supports the 'long long' data type.])] ) -if test ${ac_cv_sizeof_curl_off_t} -lt 8; then +if test "$ac_cv_sizeof_curl_off_t" -lt 8; then AC_MSG_ERROR([64-bit curl_off_t is required]) fi @@ -4088,7 +4092,7 @@ AC_CHECK_TYPE([bool],[ #endif ]) -if test "$curl_cv_native_windows" != 'yes'; then +if test "$curl_cv_native_windows" != "yes"; then # check for sa_family_t AC_CHECK_TYPE(sa_family_t, AC_DEFINE(HAVE_SA_FAMILY_T, 1, [Define to 1 if symbol `sa_family_t' exists]),, @@ -4203,7 +4207,7 @@ AC_CHECK_FUNCS([\ utimes \ ]) -if test "$curl_cv_native_windows" = 'yes'; then +if test "$curl_cv_native_windows" = "yes"; then AC_MSG_CHECKING([for if_nametoindex on Windows]) AC_LINK_IFELSE([ AC_LANG_PROGRAM([[ @@ -4236,7 +4240,7 @@ else fi AC_CHECK_FUNCS([setmode]) -if test "$curl_cv_native_windows" = 'yes' -o "$curl_cv_cygwin" = 'yes'; then +if test "$curl_cv_native_windows" = "yes" || test "$curl_cv_cygwin" = "yes"; then AC_CHECK_FUNCS([_setmode]) fi @@ -4244,7 +4248,7 @@ if test -z "$ssl_backends"; then AC_CHECK_FUNCS([arc4random]) fi -if test "$curl_cv_native_windows" != 'yes'; then +if test "$curl_cv_native_windows" != "yes"; then AC_CHECK_FUNCS([fseeko]) dnl On Android, the only way to know if fseeko can be used is to see if it is @@ -4260,7 +4264,7 @@ fi CURL_CHECK_NONBLOCKING_SOCKET dnl set variable for use in automakefile(s) -AM_CONDITIONAL(BUILD_DOCS, test x"$BUILD_DOCS" = x1) +AM_CONDITIONAL(BUILD_DOCS, test "$BUILD_DOCS" = "1") dnl ************************************************************************* dnl If the manual variable still is set, then we go with providing a built-in @@ -4271,12 +4275,12 @@ if test "$USE_MANUAL" = "1"; then fi dnl set variable for use in automakefile(s) -AM_CONDITIONAL(USE_MANUAL, test x"$USE_MANUAL" = x1) +AM_CONDITIONAL(USE_MANUAL, test "$USE_MANUAL" = "1") CURL_CHECK_LIB_ARES CURL_CHECK_OPTION_THREADED_RESOLVER -if test "$ipv6" = yes -a "$curl_cv_apple" = 'yes'; then +if test "$ipv6" = "yes" && test "$curl_cv_apple" = "yes"; then CURL_DARWIN_SYSTEMCONFIGURATION fi @@ -4321,7 +4325,7 @@ if test "$want_threaded_resolver" = "yes" && test "$USE_THREADS_WIN32" != "1"; t *-ibm-aix*) dnl Check if compiler is xlC COMPILER_VERSION=`"$CC" -qversion 2>/dev/null` - if test x"$COMPILER_VERSION" = "x"; then + if test -z "$COMPILER_VERSION"; then CFLAGS="$CFLAGS -pthread" else CFLAGS="$CFLAGS -qthreaded" @@ -4340,7 +4344,7 @@ if test "$want_threaded_resolver" = "yes" && test "$USE_THREADS_WIN32" != "1"; t [ CFLAGS="$save_CFLAGS"]) fi - if test "x$USE_THREADS_POSIX" = "x1"; then + if test "$USE_THREADS_POSIX" = "1"; then AC_DEFINE(USE_THREADS_POSIX, 1, [if you want POSIX threaded DNS lookup]) curl_res_msg="POSIX threaded" fi @@ -4348,7 +4352,7 @@ if test "$want_threaded_resolver" = "yes" && test "$USE_THREADS_WIN32" != "1"; t fi dnl Did we find a threading option? -if test "$want_threaded_resolver" != "no" -a "x$USE_THREADS_POSIX" != "x1" -a "x$USE_THREADS_WIN32" != "x1"; then +if test "$want_threaded_resolver" != "no" && test "$USE_THREADS_POSIX" != "1" && test "$USE_THREADS_WIN32" != "1"; then AC_MSG_ERROR([Threaded resolver enabled but no thread library found]) fi @@ -4400,7 +4404,7 @@ AS_HELP_STRING([--disable-verbose],[Disable verbose strings]), AC_MSG_RESULT(yes) ) -if test "$curl_cv_winuwp" != 'yes'; then +if test "$curl_cv_winuwp" != "yes"; then dnl ************************************************************ dnl enable SSPI support dnl @@ -4421,7 +4425,7 @@ if test "$curl_cv_winuwp" != 'yes'; then fi ;; *) - if test "x$SCHANNEL_ENABLED" = "x1"; then + if test "$SCHANNEL_ENABLED" = "1"; then # --with-schannel implies --enable-sspi AC_MSG_RESULT(yes) else @@ -4429,7 +4433,7 @@ if test "$curl_cv_winuwp" != 'yes'; then fi ;; esac ], - if test "x$SCHANNEL_ENABLED" = "x1"; then + if test "$SCHANNEL_ENABLED" = "1"; then # --with-schannel implies --enable-sspi AC_MSG_RESULT(yes) else @@ -4437,7 +4441,7 @@ if test "$curl_cv_winuwp" != 'yes'; then fi ) - if test "x$USE_WINDOWS_SSPI" = "x1"; then + if test "$USE_WINDOWS_SSPI" = "1"; then LIBS="-lsecur32 $LIBS" fi fi @@ -4599,7 +4603,7 @@ AS_HELP_STRING([--disable-tls-srp],[Disable TLS-SRP authentication]), want_tls_srp=yes ) -if test "$want_tls_srp" = "yes" && ( test "x$HAVE_GNUTLS_SRP" = "x1" || test "x$HAVE_OPENSSL_SRP" = "x1"); then +if test "$want_tls_srp" = "yes" && (test "$HAVE_GNUTLS_SRP" = "1" || test "$HAVE_OPENSSL_SRP" = "1"); then AC_DEFINE(USE_TLS_SRP, 1, [Use TLS-SRP authentication]) USE_TLS_SRP=1 curl_tls_srp_msg="enabled" @@ -4626,8 +4630,8 @@ AS_HELP_STRING([--disable-unix-sockets],[Disable Unix domain sockets]), want_unix_sockets=auto ] ) -if test "x$want_unix_sockets" != "xno"; then - if test "x$curl_cv_native_windows" = "xyes"; then +if test "$want_unix_sockets" != "no"; then + if test "$curl_cv_native_windows" = "yes"; then USE_UNIX_SOCKETS=1 AC_DEFINE(USE_UNIX_SOCKETS, 1, [Use Unix domain sockets]) curl_unix_sockets_msg="enabled" @@ -4637,7 +4641,7 @@ if test "x$want_unix_sockets" != "xno"; then USE_UNIX_SOCKETS=1 curl_unix_sockets_msg="enabled" ], [ - if test "x$want_unix_sockets" = "xyes"; then + if test "$want_unix_sockets" = "yes"; then AC_MSG_ERROR([--enable-unix-sockets is not available on this platform!]) fi ], [ @@ -4774,12 +4778,12 @@ AS_HELP_STRING([--disable-form-api],[Disable form API support]), ;; *) AC_MSG_RESULT(yes) - test "$enable_mime" = no && + test "x$enable_mime" = "xno" && AC_MSG_ERROR(MIME support needs to be enabled in order to enable form API support) ;; esac ], [ - if test "$enable_mime" = no; then + if test "x$enable_mime" = "xno"; then enable_form_api=no AC_MSG_RESULT(no) AC_DEFINE(CURL_DISABLE_FORM_API, 1, [disable form API]) @@ -4968,7 +4972,7 @@ else hsts="no" fi -if test "x$hsts" != "xyes"; then +if test "$hsts" != "yes"; then curl_hsts_msg="no (--enable-hsts)"; AC_DEFINE(CURL_DISABLE_HSTS, 1, [disable alt-svc]) fi @@ -4977,7 +4981,7 @@ fi dnl ************************************************************* dnl check whether ECH support, if desired, is actually available dnl -if test "x$want_ech" != "xno"; then +if test "$want_ech" != "no"; then AC_MSG_CHECKING([whether ECH support is available]) dnl assume NOT and look for sufficient condition @@ -4988,25 +4992,25 @@ if test "x$want_ech" != "xno"; then ECH_SUPPORT='' dnl check for OpenSSL equivalent - if test "x$OPENSSL_ENABLED" = "x1"; then + if test "$OPENSSL_ENABLED" = "1"; then AC_CHECK_FUNCS(SSL_set1_ech_config_list, ECH_SUPPORT="$ECH_SUPPORT OpenSSL" ECH_ENABLED_OPENSSL=1) fi - if test "x$WOLFSSL_ENABLED" = "x1"; then + if test "$WOLFSSL_ENABLED" = "1"; then AC_CHECK_FUNCS(wolfSSL_CTX_GenerateEchConfig, ECH_SUPPORT="$ECH_SUPPORT wolfSSL" ECH_ENABLED_WOLFSSL=1) fi - if test "x$RUSTLS_ENABLED" = "x1"; then + if test "$RUSTLS_ENABLED" = "1"; then ECH_SUPPORT="$ECH_SUPPORT rustls-ffi" ECH_ENABLED_RUSTLS=1 fi dnl now deal with whatever we found - if test "x$ECH_ENABLED_OPENSSL" = "x1" -o \ - "x$ECH_ENABLED_WOLFSSL" = "x1" -o \ - "x$ECH_ENABLED_RUSTLS" = "x1"; then + if test "$ECH_ENABLED_OPENSSL" = "1" || + test "$ECH_ENABLED_WOLFSSL" = "1" || + test "$ECH_ENABLED_RUSTLS" = "1"; then AC_DEFINE(USE_ECH, 1, [if ECH support is available]) AC_MSG_RESULT(ECH support available via:$ECH_SUPPORT) experimental="$experimental ECH" @@ -5022,7 +5026,7 @@ AC_MSG_CHECKING([whether to enable HTTPS-RR support]) dnl ************************************************************* dnl check whether HTTPSRR support if desired dnl -if test "x$want_httpsrr" != "xno"; then +if test "$want_httpsrr" != "no"; then AC_MSG_RESULT([yes]) AC_DEFINE(USE_HTTPSRR, 1, [enable HTTPS RR support]) experimental="$experimental HTTPSRR" @@ -5032,7 +5036,7 @@ else # no HTTPSRR wanted if test "$want_threaded_resolver" = "yes"; then # and using the threaded resolver - if test "x$USE_ARES" = "x1"; then + if test "$USE_ARES" = "1"; then AC_MSG_ERROR([without HTTPS-RR support, asking for both threaded resolver and c-ares support is ambivalent. Please drop one of them.]) fi fi @@ -5042,11 +5046,11 @@ fi dnl ************************************************************* dnl check whether OpenSSL (lookalikes) have SSL_set0_wbio dnl -if test "x$OPENSSL_ENABLED" = "x1"; then +if test "$OPENSSL_ENABLED" = "1"; then AC_CHECK_FUNCS([SSL_set0_wbio]) fi -if test "x$CURL_DISABLE_HTTP" != "x1"; then +if test "$CURL_DISABLE_HTTP" != "1"; then dnl ************************************************************* dnl WebSockets dnl @@ -5061,7 +5065,7 @@ if test "x$CURL_DISABLE_HTTP" != "x1"; then CURL_DISABLE_WEBSOCKETS=1 ;; *) - if test ${ac_cv_sizeof_curl_off_t} -gt 4; then + if test "$ac_cv_sizeof_curl_off_t" -gt 4; then AC_MSG_RESULT(yes) else dnl WebSockets requires >32-bit curl_off_t @@ -5083,14 +5087,14 @@ fi dnl ************************************************************* dnl check whether experimental SSL Session Im-/Export is enabled dnl -if test "x$want_ssls_export" != "xno"; then +if test "$want_ssls_export" != "no"; then AC_MSG_CHECKING([whether SSL session export support is available]) dnl assume NOT and look for sufficient condition SSLS_EXPORT_ENABLED=0 SSLS_EXPORT_SUPPORT='' - if test "x$SSL_ENABLED" != "x1"; then + if test "$SSL_ENABLED" != "1"; then AC_MSG_WARN([--enable-ssls-export ignored: No SSL support]) else SSLS_EXPORT_ENABLED=1 @@ -5139,7 +5143,7 @@ dnl all link targets in given makefile. BLANK_AT_MAKETIME= AC_SUBST(BLANK_AT_MAKETIME) -AM_CONDITIONAL(CROSSCOMPILING, test x$cross_compiling = xyes) +AM_CONDITIONAL(CROSSCOMPILING, test "$cross_compiling" = "yes") dnl yes or no ENABLE_SHARED="$enable_shared" @@ -5155,7 +5159,7 @@ LIBCURL_PC_REQUIRES_PRIVATE=`echo $LIBCURL_PC_REQUIRES_PRIVATE | tr ' ' ','` AC_SUBST(LIBCURL_PC_REQUIRES_PRIVATE) dnl Merge pkg-config private fields into public ones when static-only -if test "x$enable_shared" = "xno"; then +if test "$enable_shared" = "no"; then LIBCURL_PC_REQUIRES=$LIBCURL_PC_REQUIRES_PRIVATE LIBCURL_PC_LIBS=$LIBCURL_PC_LIBS_PRIVATE else @@ -5172,119 +5176,117 @@ dnl For keeping supported features and protocols also in pkg-config file dnl since it is more cross-compile friendly than curl-config dnl -if test "x$OPENSSL_ENABLED" = "x1"; then +if test "$OPENSSL_ENABLED" = "1"; then SUPPORT_FEATURES="$SUPPORT_FEATURES SSL" elif test -n "$SSL_ENABLED"; then SUPPORT_FEATURES="$SUPPORT_FEATURES SSL" fi -if test "x$IPV6_ENABLED" = "x1"; then +if test "$IPV6_ENABLED" = "1"; then SUPPORT_FEATURES="$SUPPORT_FEATURES IPv6" fi -if test "x$USE_UNIX_SOCKETS" = "x1"; then +if test "$USE_UNIX_SOCKETS" = "1"; then SUPPORT_FEATURES="$SUPPORT_FEATURES UnixSockets" fi -if test "x$HAVE_LIBZ" = "x1"; then +if test "$HAVE_LIBZ" = "1"; then SUPPORT_FEATURES="$SUPPORT_FEATURES libz" fi -if test "x$HAVE_BROTLI" = "x1"; then +if test "$HAVE_BROTLI" = "1"; then SUPPORT_FEATURES="$SUPPORT_FEATURES brotli" fi -if test "x$HAVE_ZSTD" = "x1"; then +if test "$HAVE_ZSTD" = "1"; then SUPPORT_FEATURES="$SUPPORT_FEATURES zstd" fi -if test "x$USE_ARES" = "x1" -o "x$USE_THREADS_POSIX" = "x1" \ - -o "x$USE_THREADS_WIN32" = "x1"; then +if test "$USE_ARES" = "1" || test "$USE_THREADS_POSIX" = "1" || test "$USE_THREADS_WIN32" = "1"; then SUPPORT_FEATURES="$SUPPORT_FEATURES AsynchDNS" fi -if test "x$USE_ARES" = "x1" -a "$want_threaded_resolver" = "yes" -a "x$want_httpsrr" != "xno"; then +if test "$USE_ARES" = "1" && test "$want_threaded_resolver" = "yes" && test "$want_httpsrr" != "no"; then SUPPORT_FEATURES="$SUPPORT_FEATURES asyn-rr" fi -if test "x$IDN_ENABLED" = "x1"; then +if test "$IDN_ENABLED" = "1"; then SUPPORT_FEATURES="$SUPPORT_FEATURES IDN" fi -if test "x$USE_WINDOWS_SSPI" = "x1"; then +if test "$USE_WINDOWS_SSPI" = "1"; then SUPPORT_FEATURES="$SUPPORT_FEATURES SSPI" fi -if test "x$HAVE_GSSAPI" = "x1"; then +if test "$HAVE_GSSAPI" = "1"; then SUPPORT_FEATURES="$SUPPORT_FEATURES GSS-API" fi -if test "x$curl_psl_msg" = "xenabled"; then +if test "$curl_psl_msg" = "enabled"; then SUPPORT_FEATURES="$SUPPORT_FEATURES PSL" fi -if test "x$curl_gsasl_msg" = "xenabled"; then +if test "$curl_gsasl_msg" = "enabled"; then SUPPORT_FEATURES="$SUPPORT_FEATURES gsasl" fi -if test "x$enable_altsvc" = "xyes"; then +if test "$enable_altsvc" = "yes"; then SUPPORT_FEATURES="$SUPPORT_FEATURES alt-svc" fi -if test "x$hsts" = "xyes"; then +if test "$hsts" = "yes"; then SUPPORT_FEATURES="$SUPPORT_FEATURES HSTS" fi -if test "x$CURL_DISABLE_NEGOTIATE_AUTH" != "x1" -a \ - \( "x$HAVE_GSSAPI" = "x1" -o "x$USE_WINDOWS_SSPI" = "x1" \); then +if test "$CURL_DISABLE_NEGOTIATE_AUTH" != "1" && (test "$HAVE_GSSAPI" = "1" || test "$USE_WINDOWS_SSPI" = "1"); then SUPPORT_FEATURES="$SUPPORT_FEATURES SPNEGO" fi -if test "x$CURL_DISABLE_KERBEROS_AUTH" != "x1" -a \ - \( "x$HAVE_GSSAPI" = "x1" -o "x$USE_WINDOWS_SSPI" = "x1" \); then +if test "$CURL_DISABLE_KERBEROS_AUTH" != "1" && (test "$HAVE_GSSAPI" = "1" || test "$USE_WINDOWS_SSPI" = "1"); then SUPPORT_FEATURES="$SUPPORT_FEATURES Kerberos" fi use_curl_ntlm_core=no -if test "x$CURL_DISABLE_NTLM" != "x1"; then - if test "x$HAVE_DES_ECB_ENCRYPT" = "x1" \ - -o "x$GNUTLS_ENABLED" = "x1" \ - -o "x$USE_WIN32_CRYPTO" = "x1" \ - -o "x$HAVE_WOLFSSL_DES_ECB_ENCRYPT" = "x1" \ - -o "x$HAVE_MBEDTLS_DES_CRYPT_ECB" = "x1"; then +if test "$CURL_DISABLE_NTLM" != "1"; then + if test "$HAVE_DES_ECB_ENCRYPT" = "1" || + test "$GNUTLS_ENABLED" = "1" || + test "$USE_WIN32_CRYPTO" = "1" || + test "$HAVE_WOLFSSL_DES_ECB_ENCRYPT" = "1" || + test "$HAVE_MBEDTLS_DES_CRYPT_ECB" = "1"; then use_curl_ntlm_core=yes fi - if test "x$use_curl_ntlm_core" = "xyes" \ - -o "x$USE_WINDOWS_SSPI" = "x1"; then + if test "$use_curl_ntlm_core" = "yes" || + test "$USE_WINDOWS_SSPI" = "1"; then SUPPORT_FEATURES="$SUPPORT_FEATURES NTLM" fi fi -if test "x$USE_TLS_SRP" = "x1"; then +if test "$USE_TLS_SRP" = "1"; then SUPPORT_FEATURES="$SUPPORT_FEATURES TLS-SRP" fi -if test "x$USE_NGHTTP2" = "x1"; then +if test "$USE_NGHTTP2" = "1"; then SUPPORT_FEATURES="$SUPPORT_FEATURES HTTP2" fi -if test "x$USE_NGTCP2_H3" = "x1" -o "x$USE_QUICHE" = "x1" \ - -o "x$USE_OPENSSL_H3" = "x1"; then - if test "x$CURL_WITH_MULTI_SSL" = "x1"; then +if test "$USE_NGTCP2_H3" = "1" || + test "$USE_QUICHE" = "1" || + test "$USE_OPENSSL_H3" = "1"; then + if test "$CURL_WITH_MULTI_SSL" = "1"; then AC_MSG_ERROR([MultiSSL cannot be enabled with HTTP/3 and vice versa]) fi SUPPORT_FEATURES="$SUPPORT_FEATURES HTTP3" fi -if test "x$CURL_WITH_MULTI_SSL" = "x1"; then +if test "$CURL_WITH_MULTI_SSL" = "1"; then SUPPORT_FEATURES="$SUPPORT_FEATURES MultiSSL" fi AC_MSG_CHECKING([if this build supports HTTPS-proxy]) dnl if not explicitly turned off, HTTPS-proxy comes with some TLS backends -if test "x$CURL_DISABLE_HTTP" != "x1"; then - if test "x$https_proxy" != "xno"; then - if test "x$OPENSSL_ENABLED" = "x1" \ - -o "x$GNUTLS_ENABLED" = "x1" \ - -o "x$RUSTLS_ENABLED" = "x1" \ - -o "x$SCHANNEL_ENABLED" = "x1" \ - -o "x$GNUTLS_ENABLED" = "x1" \ - -o "x$MBEDTLS_ENABLED" = "x1"; then +if test "$CURL_DISABLE_HTTP" != "1"; then + if test "$https_proxy" != "no"; then + if test "$OPENSSL_ENABLED" = "1" || + test "$GNUTLS_ENABLED" = "1" || + test "$RUSTLS_ENABLED" = "1" || + test "$SCHANNEL_ENABLED" = "1" || + test "$GNUTLS_ENABLED" = "1" || + test "$MBEDTLS_ENABLED" = "1"; then SUPPORT_FEATURES="$SUPPORT_FEATURES HTTPS-proxy" AC_MSG_RESULT([yes]) - elif test "x$WOLFSSL_ENABLED" = "x1" -a "x$HAVE_WOLFSSL_BIO_NEW" = "x1"; then + elif test "$WOLFSSL_ENABLED" = "1" && test "$HAVE_WOLFSSL_BIO_NEW" = "1"; then SUPPORT_FEATURES="$SUPPORT_FEATURES HTTPS-proxy" AC_MSG_RESULT([yes]) else @@ -5297,35 +5299,34 @@ else AC_MSG_RESULT([no]) fi -if test "x$OPENSSL_ENABLED" = "x1" -o -n "$SSL_ENABLED"; then - if test "x$ECH_ENABLED" = "x1"; then +if test "$OPENSSL_ENABLED" = "1" || test -n "$SSL_ENABLED"; then + if test "$ECH_ENABLED" = "1"; then SUPPORT_FEATURES="$SUPPORT_FEATURES ECH" fi fi -if test "x$APPLE_SECTRUST_ENABLED" = "x1"; then +if test "$APPLE_SECTRUST_ENABLED" = "1"; then SUPPORT_FEATURES="$SUPPORT_FEATURES AppleSecTrust" fi -if test "x$want_httpsrr" != "xno"; then +if test "$want_httpsrr" != "no"; then SUPPORT_FEATURES="$SUPPORT_FEATURES HTTPSRR" fi -if test "x$SSLS_EXPORT_ENABLED" = "x1"; then +if test "$SSLS_EXPORT_ENABLED" = "1"; then SUPPORT_FEATURES="$SUPPORT_FEATURES SSLS-EXPORT" fi -if test ${ac_cv_sizeof_curl_off_t} -gt 4; then - if test ${ac_cv_sizeof_off_t} -gt 4 -o \ - "$curl_cv_native_windows" = "yes"; then +if test "$ac_cv_sizeof_curl_off_t" -gt 4; then + if test "$ac_cv_sizeof_off_t" -gt 4 || + test "$curl_cv_native_windows" = "yes"; then SUPPORT_FEATURES="$SUPPORT_FEATURES Largefile" fi fi if test "$tst_atomic" = "yes"; then SUPPORT_FEATURES="$SUPPORT_FEATURES threadsafe" -elif test "x$USE_THREADS_POSIX" = "x1" -a \ - "x$ac_cv_header_pthread_h" = "xyes"; then +elif test "$USE_THREADS_POSIX" = "1" && test "$ac_cv_header_pthread_h" = "yes"; then SUPPORT_FEATURES="$SUPPORT_FEATURES threadsafe" else AC_COMPILE_IFELSE([ @@ -5342,16 +5343,16 @@ else ]) fi -if test "x$want_winuni" = "xyes"; then +if test "$want_winuni" = "yes"; then SUPPORT_FEATURES="$SUPPORT_FEATURES Unicode" fi -if test "x$want_debug" = "xyes"; then +if test "$want_debug" = "yes"; then SUPPORT_FEATURES="$SUPPORT_FEATURES Debug" fi -if test "x$want_curldebug" = "xyes"; then +if test "$want_curldebug" = "yes"; then SUPPORT_FEATURES="$SUPPORT_FEATURES TrackMemory" fi -if test "x$CURL_CA_EMBED" != "x"; then +if test -n "$CURL_CA_EMBED"; then SUPPORT_FEATURES="$SUPPORT_FEATURES CAcert" CURL_CA_EMBED_msg="$CURL_CA_EMBED" else @@ -5369,93 +5370,92 @@ fi AC_SUBST(SUPPORT_FEATURES) dnl For supported protocols in pkg-config file -if test "x$CURL_DISABLE_HTTP" != "x1"; then +if test "$CURL_DISABLE_HTTP" != "1"; then SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS HTTP" - if test "x$SSL_ENABLED" = "x1"; then + if test "$SSL_ENABLED" = "1"; then SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS HTTPS" fi fi -if test "x$CURL_DISABLE_FTP" != "x1"; then +if test "$CURL_DISABLE_FTP" != "1"; then SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS FTP" - if test "x$SSL_ENABLED" = "x1"; then + if test "$SSL_ENABLED" = "1"; then SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS FTPS" fi fi -if test "x$CURL_DISABLE_FILE" != "x1"; then +if test "$CURL_DISABLE_FILE" != "1"; then SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS FILE" fi -if test "x$CURL_DISABLE_TELNET" != "x1"; then +if test "$CURL_DISABLE_TELNET" != "1"; then SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS TELNET" fi -if test "x$CURL_DISABLE_LDAP" != "x1"; then +if test "$CURL_DISABLE_LDAP" != "1"; then SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS LDAP" - if test "x$CURL_DISABLE_LDAPS" != "x1"; then - if (test "x$USE_OPENLDAP" = "x1" && test "x$SSL_ENABLED" = "x1") || - (test "x$USE_OPENLDAP" != "x1" && test "x$HAVE_LDAP_SSL" = "x1"); then + if test "$CURL_DISABLE_LDAPS" != "1"; then + if (test "$USE_OPENLDAP" = "1" && test "$SSL_ENABLED" = "1") || + (test "$USE_OPENLDAP" != "1" && test "$HAVE_LDAP_SSL" = "1"); then SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS LDAPS" fi fi fi -if test "x$CURL_DISABLE_DICT" != "x1"; then +if test "$CURL_DISABLE_DICT" != "1"; then SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS DICT" fi -if test "x$CURL_DISABLE_TFTP" != "x1"; then +if test "$CURL_DISABLE_TFTP" != "1"; then SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS TFTP" fi -if test "x$CURL_DISABLE_GOPHER" != "x1"; then +if test "$CURL_DISABLE_GOPHER" != "1"; then SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS GOPHER" - if test "x$SSL_ENABLED" = "x1"; then + if test "$SSL_ENABLED" = "1"; then SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS GOPHERS" fi fi -if test "x$CURL_DISABLE_MQTT" != "x1"; then +if test "$CURL_DISABLE_MQTT" != "1"; then SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS MQTT" fi -if test "x$CURL_DISABLE_POP3" != "x1"; then +if test "$CURL_DISABLE_POP3" != "1"; then SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS POP3" - if test "x$SSL_ENABLED" = "x1"; then + if test "$SSL_ENABLED" = "1"; then SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS POP3S" fi fi -if test "x$CURL_DISABLE_IMAP" != "x1"; then +if test "$CURL_DISABLE_IMAP" != "1"; then SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS IMAP" - if test "x$SSL_ENABLED" = "x1"; then + if test "$SSL_ENABLED" = "1"; then SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS IMAPS" fi fi -if test "x$CURL_DISABLE_SMB" != "x1" \ - -a "x$use_curl_ntlm_core" = "xyes"; then +if test "$CURL_DISABLE_SMB" != "1" && test "$use_curl_ntlm_core" = "yes"; then SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS SMB" - if test "x$SSL_ENABLED" = "x1"; then + if test "$SSL_ENABLED" = "1"; then SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS SMBS" fi fi -if test "x$CURL_DISABLE_SMTP" != "x1"; then +if test "$CURL_DISABLE_SMTP" != "1"; then SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS SMTP" - if test "x$SSL_ENABLED" = "x1"; then + if test "$SSL_ENABLED" = "1"; then SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS SMTPS" fi fi -if test "x$USE_LIBSSH2" = "x1"; then +if test "$USE_LIBSSH2" = "1"; then SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS SCP" SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS SFTP" fi -if test "x$USE_LIBSSH" = "x1"; then +if test "$USE_LIBSSH" = "1"; then SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS SCP" SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS SFTP" fi -if test "x$CURL_DISABLE_IPFS" != "x1"; then +if test "$CURL_DISABLE_IPFS" != "1"; then SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS IPFS IPNS" fi -if test "x$CURL_DISABLE_RTSP" != "x1"; then +if test "$CURL_DISABLE_RTSP" != "1"; then SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS RTSP" fi -if test "x$USE_LIBRTMP" = "x1"; then +if test "$USE_LIBRTMP" = "1"; then SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS RTMP" fi -if test "x$CURL_DISABLE_WEBSOCKETS" != "x1"; then +if test "$CURL_DISABLE_WEBSOCKETS" != "1"; then SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS WS" - if test "x$SSL_ENABLED" = "x1"; then + if test "$SSL_ENABLED" = "1"; then SUPPORT_PROTOCOLS="$SUPPORT_PROTOCOLS WSS" fi fi @@ -5487,8 +5487,8 @@ XC_CHECK_BUILD_FLAGS SSL_BACKENDS=${ssl_backends} AC_SUBST(SSL_BACKENDS) -if test "x$want_curldebug_assumed" = "xyes" && - test "x$want_curldebug" = "xyes" && test "x$USE_ARES" = "x1"; then +if test "$want_curldebug_assumed" = "yes" && + test "$want_curldebug" = "yes" && test "$USE_ARES" = "1"; then ac_configure_args="$ac_configure_args --enable-curldebug" fi diff --git a/curl-config.in b/curl-config.in index ce23519c3306..a1c81858753f 100644 --- a/curl-config.in +++ b/curl-config.in @@ -149,7 +149,7 @@ while test "$#" -gt 0; do ;; --libs) - if test "@libdir@" != '/usr/lib' -a "@libdir@" != '/usr/lib64'; then + if test "@libdir@" != '/usr/lib' && test "@libdir@" != '/usr/lib64'; then curllibdir="-L@libdir@ " else curllibdir='' diff --git a/docs/libcurl/libcurl.m4 b/docs/libcurl/libcurl.m4 index 973493f03af5..96248ddc25f4 100644 --- a/docs/libcurl/libcurl.m4 +++ b/docs/libcurl/libcurl.m4 @@ -86,7 +86,7 @@ AC_DEFUN([LIBCURL_CHECK_CONFIG], AS_HELP_STRING([--with-libcurl=PREFIX],[look for the curl library in PREFIX/lib and headers in PREFIX/include]), [_libcurl_with=$withval],[_libcurl_with=ifelse([$1],,[yes],[$1])]) - if test "$_libcurl_with" != "no"; then + if test "x$_libcurl_with" != "xno"; then AC_PROG_AWK @@ -102,7 +102,7 @@ AC_DEFUN([LIBCURL_CHECK_CONFIG], AC_PATH_PROG([_libcurl_config],[curl-config],[],[$PATH]) fi - if test x$_libcurl_config != "x"; then + if test -n "$_libcurl_config"; then AC_CACHE_CHECK([for the version of libcurl], [libcurl_cv_lib_curl_version], [libcurl_cv_lib_curl_version=`$_libcurl_config --version | $AWK '{print $[]2}'`]) @@ -110,11 +110,11 @@ AC_DEFUN([LIBCURL_CHECK_CONFIG], _libcurl_version=`echo $libcurl_cv_lib_curl_version | $_libcurl_version_parse` _libcurl_wanted=`echo ifelse([$2],,[0],[$2]) | $_libcurl_version_parse` - if test $_libcurl_wanted -gt 0; then + if test "$_libcurl_wanted" -gt 0; then AC_CACHE_CHECK([for libcurl >= version $2], [libcurl_cv_lib_version_ok], [ - if test $_libcurl_version -ge $_libcurl_wanted; then + if test "$_libcurl_version" -ge "$_libcurl_wanted"; then libcurl_cv_lib_version_ok=yes else libcurl_cv_lib_version_ok=no @@ -122,11 +122,11 @@ AC_DEFUN([LIBCURL_CHECK_CONFIG], ]) fi - if test $_libcurl_wanted -eq 0 || test x$libcurl_cv_lib_version_ok = xyes; then - if test x"$LIBCURL_CPPFLAGS" = "x"; then + if test "$_libcurl_wanted" -eq 0 || test "$libcurl_cv_lib_version_ok" = "yes"; then + if test -z "$LIBCURL_CPPFLAGS"; then LIBCURL_CPPFLAGS=`$_libcurl_config --cflags` fi - if test x"$LIBCURL" = "x"; then + if test -z "$LIBCURL"; then LIBCURL=`$_libcurl_config --libs` # This is so silly, but Apple actually has a bug in their @@ -143,7 +143,7 @@ AC_DEFUN([LIBCURL_CHECK_CONFIG], _libcurl_features=`$_libcurl_config --feature` # Is it modern enough to have --protocols? (7.12.4) - if test $_libcurl_version -ge 461828; then + if test "$_libcurl_version" -ge 461828; then _libcurl_protocols=`$_libcurl_config --protocols` fi else @@ -153,7 +153,7 @@ AC_DEFUN([LIBCURL_CHECK_CONFIG], unset _libcurl_wanted fi - if test $_libcurl_try_link = yes; then + if test "$_libcurl_try_link" = "yes"; then # we did not find curl-config, so let's see if the user-supplied # link line (or failing that, "-lcurl") is enough. @@ -187,7 +187,7 @@ AC_DEFUN([LIBCURL_CHECK_CONFIG], unset _libcurl_save_libs ]) - if test $libcurl_cv_lib_curl_usable = yes; then + if test "$libcurl_cv_lib_curl_usable" = "yes"; then # Does curl_free() exist in this version of libcurl? # If not, fake it with free() @@ -217,25 +217,25 @@ AC_DEFUN([LIBCURL_CHECK_CONFIG], eval AS_TR_SH(libcurl_feature_$_libcurl_feature)=yes done - if test "x$_libcurl_protocols" = "x"; then + if test -z "$_libcurl_protocols"; then # We do not have --protocols, so just assume that all # protocols are available _libcurl_protocols="HTTP FTP FILE TELNET LDAP DICT TFTP" - if test x$libcurl_feature_SSL = xyes; then + if test "$libcurl_feature_SSL" = "yes"; then _libcurl_protocols="$_libcurl_protocols HTTPS" # FTPS was not standards-compliant until version # 7.11.0 (0x070b00 == 461568) - if test $_libcurl_version -ge 461568; then + if test "$_libcurl_version" -ge 461568; then _libcurl_protocols="$_libcurl_protocols FTPS" fi fi # RTSP, IMAP, POP3 and SMTP were added in # 7.20.0 (0x071400 == 463872) - if test $_libcurl_version -ge 463872; then + if test "$_libcurl_version" -ge 463872; then _libcurl_protocols="$_libcurl_protocols RTSP IMAP POP3 SMTP" fi fi @@ -261,7 +261,7 @@ AC_DEFUN([LIBCURL_CHECK_CONFIG], unset _libcurl_ldflags fi - if test x$_libcurl_with = xno || test x$libcurl_cv_lib_curl_usable != xyes; then + if test "x$_libcurl_with" = "xno" || test "$libcurl_cv_lib_curl_usable" != "yes"; then # This is the IF-NO path ifelse([$4],,:,[$4]) else diff --git a/m4/curl-amissl.m4 b/m4/curl-amissl.m4 index a70a5366321e..86468890e86b 100644 --- a/m4/curl-amissl.m4 +++ b/m4/curl-amissl.m4 @@ -25,7 +25,7 @@ AC_DEFUN([CURL_WITH_AMISSL], [ AC_MSG_CHECKING([whether to enable Amiga native SSL/TLS (AmiSSL v5)]) if test "$HAVE_PROTO_BSDSOCKET_H" = "1"; then - if test "x$OPT_AMISSL" != xno; then + if test "x$OPT_AMISSL" != "xno"; then ssl_msg= AC_COMPILE_IFELSE([ AC_LANG_PROGRAM([[ @@ -43,7 +43,7 @@ if test "$HAVE_PROTO_BSDSOCKET_H" = "1"; then ],[ AC_MSG_RESULT([yes]) ssl_msg="AmiSSL" - test amissl != "$DEFAULT_SSL_BACKEND" || VALID_DEFAULT_SSL_BACKEND=yes + test "amissl" != "$DEFAULT_SSL_BACKEND" || VALID_DEFAULT_SSL_BACKEND=yes AMISSL_ENABLED=1 OPENSSL_ENABLED=1 # Use AmiSSL's built-in ca bundle diff --git a/m4/curl-apple-sectrust.m4 b/m4/curl-apple-sectrust.m4 index d42fe860a5fa..c70b7ac8cd61 100644 --- a/m4/curl-apple-sectrust.m4 +++ b/m4/curl-apple-sectrust.m4 @@ -24,7 +24,7 @@ AC_DEFUN([CURL_WITH_APPLE_SECTRUST], [ AC_MSG_CHECKING([whether to enable Apple OS native certificate validation]) -if test "x$OPT_APPLE_SECTRUST" = xyes; then +if test "x$OPT_APPLE_SECTRUST" = "xyes"; then AC_COMPILE_IFELSE([ AC_LANG_PROGRAM([[ #include @@ -41,10 +41,10 @@ if test "x$OPT_APPLE_SECTRUST" = xyes; then ],[ build_for_apple="no" ]) - if test "x$build_for_apple" = "xno"; then + if test "$build_for_apple" = "no"; then AC_MSG_ERROR([Apple SecTrust can only be enabled for Apple OS targets]) fi - if test "x$OPENSSL_ENABLED" = "x1" -o "x$GNUTLS_ENABLED" = "x1"; then + if test "$OPENSSL_ENABLED" = "1" || test "$GNUTLS_ENABLED" = "1"; then AC_MSG_RESULT(yes) AC_DEFINE(USE_APPLE_SECTRUST, 1, [enable Apple OS certificate validation]) APPLE_SECTRUST_ENABLED=1 diff --git a/m4/curl-compilers.m4 b/m4/curl-compilers.m4 index 343391d6020c..7b4b5bed2318 100644 --- a/m4/curl-compilers.m4 +++ b/m4/curl-compilers.m4 @@ -88,7 +88,7 @@ AC_DEFUN([CURL_CHECK_COMPILER_CLANG], [ AC_MSG_RESULT([yes]) AC_MSG_CHECKING([if compiler is xlclang]) CURL_CHECK_DEF([__ibmxl__], [], [silent]) - if test "$curl_cv_have_def___ibmxl__" = "yes" ; then + if test "$curl_cv_have_def___ibmxl__" = "yes"; then dnl IBM's almost-compatible clang version AC_MSG_RESULT([yes]) compiler_id="XLCLANG" @@ -118,7 +118,7 @@ AC_DEFUN([CURL_CHECK_COMPILER_CLANG], [ clangvlo=`echo $clangver | cut -d . -f2` compiler_ver="$clangver" compiler_num=`(expr $clangvhi "*" 100 + $clangvlo) 2>/dev/null` - if test "$appleclang" = '1' && test "$oldapple" = '0'; then + if test "$appleclang" = "1" && test "$oldapple" = "0"; then dnl Starting with Xcode 7 / clang 3.7, Apple clang does not tell its upstream version if test "$compiler_num" -ge '1700'; then compiler_num='1901' elif test "$compiler_num" -ge '1600'; then compiler_num='1700' @@ -396,7 +396,8 @@ AC_DEFUN([CURL_CONVERT_INCLUDE_TO_ISYSTEM], [ AC_REQUIRE([CURL_CHECK_COMPILER])dnl AC_MSG_CHECKING([convert -I options to -isystem]) if test "$compiler_id" = "GNU_C" || - test "$compiler_id" = "CLANG" -o "$compiler_id" = "APPLECLANG"; then + test "$compiler_id" = "CLANG" || + test "$compiler_id" = "APPLECLANG"; then AC_MSG_RESULT([yes]) tmp_has_include="no" tmp_chg_FLAGS="$CFLAGS" @@ -475,7 +476,7 @@ AC_DEFUN([CURL_COMPILER_WORKS_IFELSE], [ ]) fi dnl only do runtime verification when not cross-compiling - if test "x$cross_compiling" != "xyes" && + if test "$cross_compiling" != "yes" && test "$tmp_compiler_works" = "yes"; then CURL_RUN_IFELSE([ AC_LANG_PROGRAM([[ @@ -632,7 +633,7 @@ AC_DEFUN([CURL_SET_COMPILER_BASIC_OPTS], [ squeeze tmp_CPPFLAGS squeeze tmp_CFLAGS # - if test ! -z "$tmp_CFLAGS" || test ! -z "$tmp_CPPFLAGS"; then + if test -n "$tmp_CFLAGS" || test -n "$tmp_CPPFLAGS"; then AC_MSG_CHECKING([if compiler accepts some basic options]) CPPFLAGS="$tmp_save_CPPFLAGS $tmp_CPPFLAGS" CFLAGS="$tmp_save_CFLAGS $tmp_CFLAGS" @@ -972,7 +973,7 @@ AC_DEFUN([CURL_SET_COMPILER_WARNING_OPTS], [ # dnl Do not enable -pedantic when cross-compiling with a gcc older dnl than 3.0, to avoid warnings from third party system headers. - if test "x$cross_compiling" != "xyes" || + if test "$cross_compiling" != "yes" || test "$compiler_num" -ge "300"; then tmp_CFLAGS="$tmp_CFLAGS -pedantic" fi @@ -985,7 +986,7 @@ AC_DEFUN([CURL_SET_COMPILER_WARNING_OPTS], [ if test "$compiler_num" -ge "104"; then CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [pointer-arith write-strings]) dnl If not cross-compiling with a gcc older than 3.0 - if test "x$cross_compiling" != "xyes" || + if test "$cross_compiling" != "yes" || test "$compiler_num" -ge "300"; then CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [unused shadow]) fi @@ -995,7 +996,7 @@ AC_DEFUN([CURL_SET_COMPILER_WARNING_OPTS], [ if test "$compiler_num" -ge "207"; then CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [nested-externs]) dnl If not cross-compiling with a gcc older than 3.0 - if test "x$cross_compiling" != "xyes" || + if test "$cross_compiling" != "yes" || test "$compiler_num" -ge "300"; then CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [missing-declarations]) CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [missing-prototypes]) @@ -1173,7 +1174,7 @@ AC_DEFUN([CURL_SET_COMPILER_WARNING_OPTS], [ else dnl When cross-compiling with a gcc older than 3.0, disable dnl some warnings triggered on third party system headers. - if test "x$cross_compiling" = "xyes"; then + if test "$cross_compiling" = "yes"; then if test "$compiler_num" -ge "104"; then dnl gcc 1.4 or later tmp_CFLAGS="$tmp_CFLAGS -Wno-unused -Wno-shadow" @@ -1190,19 +1191,19 @@ AC_DEFUN([CURL_SET_COMPILER_WARNING_OPTS], [ tmp_CFLAGS="$tmp_CFLAGS -Wno-shadow" tmp_CFLAGS="$tmp_CFLAGS -Wno-unreachable-code" fi - if test "$compiler_num" -ge "402" -a "$compiler_num" -lt "406"; then + if test "$compiler_num" -ge "402" && test "$compiler_num" -lt "406"; then dnl GCC <4.6 do not support #pragma to suppress warnings locally. Disable globally instead. tmp_CFLAGS="$tmp_CFLAGS -Wno-overlength-strings" fi - if test "$compiler_num" -ge "400" -a "$compiler_num" -lt "407"; then + if test "$compiler_num" -ge "400" && test "$compiler_num" -lt "407"; then dnl https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84685 tmp_CFLAGS="$tmp_CFLAGS -Wno-missing-field-initializers" fi - if test "$compiler_num" -ge "403" -a "$compiler_num" -lt "408"; then + if test "$compiler_num" -ge "403" && test "$compiler_num" -lt "408"; then dnl Avoid false positives tmp_CFLAGS="$tmp_CFLAGS -Wno-type-limits" fi - if test "$compiler_num" -ge "501" -a "$compiler_num" -lt "505"; then + if test "$compiler_num" -ge "501" && test "$compiler_num" -lt "505"; then dnl Avoid false positives tmp_CFLAGS="$tmp_CFLAGS -Wno-conversion" fi @@ -1308,7 +1309,7 @@ AC_DEFUN([CURL_SET_COMPILER_WARNING_OPTS], [ squeeze tmp_CPPFLAGS squeeze tmp_CFLAGS # - if test ! -z "$tmp_CFLAGS" || test ! -z "$tmp_CPPFLAGS"; then + if test -n "$tmp_CFLAGS" || test -n "$tmp_CPPFLAGS"; then AC_MSG_CHECKING([if compiler accepts strict warning options]) CPPFLAGS="$tmp_save_CPPFLAGS $tmp_CPPFLAGS" CFLAGS="$tmp_save_CFLAGS $tmp_CFLAGS" @@ -1491,7 +1492,7 @@ AC_DEFUN([CURL_CHECK_COMPILER_SYMBOL_HIDING], [ GNU_C) dnl Only gcc 3.4 or later if test "$compiler_num" -ge "304"; then - if $CC --help --verbose 2>/dev/null | grep fvisibility= >/dev/null ; then + if $CC --help --verbose 2>/dev/null | grep fvisibility= >/dev/null; then tmp_EXTERN="__attribute__((__visibility__(\"default\")))" tmp_CFLAGS="-fvisibility=hidden" supports_symbol_hiding="yes" @@ -1501,7 +1502,7 @@ AC_DEFUN([CURL_CHECK_COMPILER_SYMBOL_HIDING], [ INTEL_UNIX_C) dnl Only icc 9.0 or later if test "$compiler_num" -ge "900"; then - if $CC --help --verbose 2>&1 | grep fvisibility= > /dev/null ; then + if $CC --help --verbose 2>&1 | grep fvisibility= > /dev/null; then tmp_save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -fvisibility=hidden" AC_LINK_IFELSE([ @@ -1520,7 +1521,7 @@ AC_DEFUN([CURL_CHECK_COMPILER_SYMBOL_HIDING], [ fi ;; SUNPRO_C) - if $CC 2>&1 | grep flags >/dev/null && $CC -flags | grep xldscope= >/dev/null ; then + if $CC 2>&1 | grep flags >/dev/null && $CC -flags | grep xldscope= >/dev/null; then tmp_EXTERN="__global" tmp_CFLAGS="-xldscope=hidden" supports_symbol_hiding="yes" diff --git a/m4/curl-confopts.m4 b/m4/curl-confopts.m4 index 5149e8a34ae9..a54037369267 100644 --- a/m4/curl-confopts.m4 +++ b/m4/curl-confopts.m4 @@ -93,7 +93,7 @@ AS_HELP_STRING([--disable-ares],[Disable c-ares for DNS lookups]), *) dnl --enable-ares option used want_ares="yes" - if test -n "$enableval" && test "$enableval" != "yes"; then + if test -n "$enableval" && test "x$enableval" != "xyes"; then want_ares_path="$enableval" fi ;; @@ -392,15 +392,15 @@ AC_DEFUN([CURL_CHECK_NONBLOCKING_SOCKET], [ tst_method="unknown" AC_MSG_CHECKING([how to set a socket into non-blocking mode]) - if test "x$curl_cv_func_fcntl_o_nonblock" = "xyes"; then + if test "$curl_cv_func_fcntl_o_nonblock" = "yes"; then tst_method="fcntl O_NONBLOCK" - elif test "x$curl_cv_func_ioctl_fionbio" = "xyes"; then + elif test "$curl_cv_func_ioctl_fionbio" = "yes"; then tst_method="ioctl FIONBIO" - elif test "x$curl_cv_func_ioctlsocket_fionbio" = "xyes"; then + elif test "$curl_cv_func_ioctlsocket_fionbio" = "yes"; then tst_method="ioctlsocket FIONBIO" - elif test "x$curl_cv_func_ioctlsocket_camel_fionbio" = "xyes"; then + elif test "$curl_cv_func_ioctlsocket_camel_fionbio" = "yes"; then tst_method="IoctlSocket FIONBIO" - elif test "x$curl_cv_func_setsockopt_so_nonblock" = "xyes"; then + elif test "$curl_cv_func_setsockopt_so_nonblock" = "yes"; then tst_method="setsockopt SO_NONBLOCK" fi AC_MSG_RESULT([$tst_method]) @@ -433,7 +433,7 @@ AC_DEFUN([CURL_CONFIGURE_SYMBOL_HIDING], [ else AC_MSG_RESULT([no]) fi - AM_CONDITIONAL(DOING_CURL_SYMBOL_HIDING, test x$doing_symbol_hiding = xyes) + AM_CONDITIONAL(DOING_CURL_SYMBOL_HIDING, test "$doing_symbol_hiding" = "yes") AC_SUBST(CFLAG_CURL_SYMBOL_HIDING) ]) @@ -456,7 +456,7 @@ AC_DEFUN([CURL_CHECK_LIB_ARES], [ dnl c-ares library path has been specified ARES_PCDIR="$want_ares_path/lib/pkgconfig" CURL_CHECK_PKGCONFIG(libcares, [$ARES_PCDIR]) - if test "$PKGCONFIG" != "no" ; then + if test "$PKGCONFIG" != "no"; then ares_LIBS=`CURL_EXPORT_PCDIR([$ARES_PCDIR]) $PKGCONFIG --libs-only-l libcares` ares_LDFLAGS=`CURL_EXPORT_PCDIR([$ARES_PCDIR]) @@ -475,7 +475,7 @@ AC_DEFUN([CURL_CHECK_LIB_ARES], [ else dnl c-ares path not specified, use defaults CURL_CHECK_PKGCONFIG(libcares) - if test "$PKGCONFIG" != "no" ; then + if test "$PKGCONFIG" != "no"; then ares_LIBS=`$PKGCONFIG --libs-only-l libcares` ares_LDFLAGS=`$PKGCONFIG --libs-only-L libcares` ares_CPPFLAGS=`$PKGCONFIG --cflags-only-I libcares` diff --git a/m4/curl-functions.m4 b/m4/curl-functions.m4 index a9b9ee58449e..5512a5d28c4c 100644 --- a/m4/curl-functions.m4 +++ b/m4/curl-functions.m4 @@ -1339,7 +1339,7 @@ AC_DEFUN([CURL_CHECK_FUNC_GETADDRINFO], [ fi # dnl only do runtime verification when not cross-compiling - if test "x$cross_compiling" != "xyes" && + if test "$cross_compiling" != "yes" && test "$tst_compi_getaddrinfo" = "yes"; then AC_MSG_CHECKING([if getaddrinfo seems to work]) CURL_RUN_IFELSE([ @@ -1415,7 +1415,7 @@ AC_DEFUN([CURL_CHECK_FUNC_GETADDRINFO], [ # if test "$curl_cv_func_getaddrinfo" = "yes"; then AC_MSG_CHECKING([if getaddrinfo is threadsafe]) - if test "$curl_cv_apple" = 'yes'; then + if test "$curl_cv_apple" = "yes"; then dnl Darwin 6.0 and macOS 10.2.X and newer tst_tsafe_getaddrinfo="yes" fi @@ -2027,7 +2027,7 @@ AC_DEFUN([CURL_CHECK_FUNC_GETIFADDRS], [ fi # dnl only do runtime verification when not cross-compiling - if test "x$cross_compiling" != "xyes" && + if test "$cross_compiling" != "yes" && test "$tst_compi_getifaddrs" = "yes"; then AC_MSG_CHECKING([if getifaddrs seems to work]) CURL_RUN_IFELSE([ @@ -2148,7 +2148,7 @@ AC_DEFUN([CURL_CHECK_FUNC_GMTIME_R], [ fi # dnl only do runtime verification when not cross-compiling - if test "x$cross_compiling" != "xyes" && + if test "$cross_compiling" != "yes" && test "$tst_compi_gmtime_r" = "yes"; then AC_MSG_CHECKING([if gmtime_r seems to work]) CURL_RUN_IFELSE([ @@ -2268,7 +2268,7 @@ AC_DEFUN([CURL_CHECK_FUNC_INET_NTOP], [ fi # dnl only do runtime verification when not cross-compiling - if test "x$cross_compiling" != "xyes" && + if test "$cross_compiling" != "yes" && test "$tst_compi_inet_ntop" = "yes"; then AC_MSG_CHECKING([if inet_ntop seems to work]) CURL_RUN_IFELSE([ @@ -2429,7 +2429,7 @@ AC_DEFUN([CURL_CHECK_FUNC_INET_PTON], [ fi # dnl only do runtime verification when not cross-compiling - if test "x$cross_compiling" != "xyes" && + if test "$cross_compiling" != "yes" && test "$tst_compi_inet_pton" = "yes"; then AC_MSG_CHECKING([if inet_pton seems to work]) CURL_RUN_IFELSE([ @@ -4016,7 +4016,7 @@ AC_DEFUN([CURL_CHECK_FUNC_STRERROR_R], [ fi # dnl only do runtime verification when not cross-compiling - if test "x$cross_compiling" != "xyes" && + if test "$cross_compiling" != "yes" && test "$tst_glibc_strerror_r" = "yes"; then AC_MSG_CHECKING([if strerror_r seems to work]) CURL_RUN_IFELSE([ @@ -4079,7 +4079,7 @@ AC_DEFUN([CURL_CHECK_FUNC_STRERROR_R], [ fi # dnl only do runtime verification when not cross-compiling - if test "x$cross_compiling" != "xyes" && + if test "$cross_compiling" != "yes" && test "$tst_posix_strerror_r" = "yes"; then AC_MSG_CHECKING([if strerror_r seems to work]) CURL_RUN_IFELSE([ @@ -4259,7 +4259,7 @@ dnl CURL_LIBRARY_PATH variable. It keeps the LD_LIBRARY_PATH dnl changes contained within this macro. AC_DEFUN([CURL_RUN_IFELSE], [ - if test "$curl_cv_apple" = 'yes'; then + if test "$curl_cv_apple" = "yes"; then AC_RUN_IFELSE([AC_LANG_SOURCE([$1])], $2, $3, $4) else oldcc=$CC @@ -4291,7 +4291,7 @@ AC_DEFUN([CURL_COVERAGE],[ coverage="$enableval") dnl if not gcc or clang switch off again - AS_IF([test "$compiler_id" != "GNU_C" -a "$compiler_id" != "CLANG" -a "$compiler_id" != "APPLECLANG"], coverage="no" ) + AS_IF([test "$compiler_id" != "GNU_C" && test "$compiler_id" != "CLANG" && test "$compiler_id" != "APPLECLANG"], coverage="no" ) AC_MSG_RESULT($coverage) if test "x$coverage" = "xyes"; then @@ -4390,11 +4390,11 @@ AC_DEFUN([CURL_SIZEOF], [ r=0 ]) dnl get out of the loop once matched - if test $r -gt 0; then + if test "$r" -gt 0; then break; fi done - if test $r -eq 0; then + if test "$r" -eq 0; then AC_MSG_ERROR([Failed to find size of $1]) fi AC_MSG_RESULT($r) diff --git a/m4/curl-gnutls.m4 b/m4/curl-gnutls.m4 index f1aa04d3faf6..533d72129eb0 100644 --- a/m4/curl-gnutls.m4 +++ b/m4/curl-gnutls.m4 @@ -27,10 +27,10 @@ dnl check for GnuTLS dnl ---------------------------------------------------- AC_DEFUN([CURL_WITH_GNUTLS], [ -if test "x$OPT_GNUTLS" != xno; then +if test "x$OPT_GNUTLS" != "xno"; then ssl_msg= - if test X"$OPT_GNUTLS" != Xno; then + if test "x$OPT_GNUTLS" != "xno"; then addld="" addlib="" @@ -42,7 +42,7 @@ if test "x$OPT_GNUTLS" != xno; then dnl this is with no particular path given CURL_CHECK_PKGCONFIG(gnutls) - if test "$PKGCONFIG" != "no" ; then + if test "$PKGCONFIG" != "no"; then addlib=`$PKGCONFIG --libs-only-l gnutls` addld=`$PKGCONFIG --libs-only-L gnutls` addcflags=`$PKGCONFIG --cflags-only-I gnutls` @@ -106,7 +106,7 @@ if test "x$OPT_GNUTLS" != xno; then USE_GNUTLS="yes" ssl_msg="GnuTLS" QUIC_ENABLED=yes - test gnutls != "$DEFAULT_SSL_BACKEND" || VALID_DEFAULT_SSL_BACKEND=yes + test "gnutls" != "$DEFAULT_SSL_BACKEND" || VALID_DEFAULT_SSL_BACKEND=yes ], [ LIBS="$CLEANLIBS" @@ -115,7 +115,7 @@ if test "x$OPT_GNUTLS" != xno; then LDFLAGSPC="$CLEANLDFLAGSPC" ]) - if test "x$USE_GNUTLS" = "xyes"; then + if test "$USE_GNUTLS" = "yes"; then AC_MSG_NOTICE([detected GnuTLS version $version]) check_for_ca_bundle=1 if test -n "$gtlslib"; then @@ -123,7 +123,7 @@ if test "x$OPT_GNUTLS" != xno; then dnl linker does not search through, we need to add it to dnl CURL_LIBRARY_PATH to prevent further configure tests to fail dnl due to this - if test "x$cross_compiling" != "xyes"; then + if test "$cross_compiling" != "yes"; then CURL_LIBRARY_PATH="$CURL_LIBRARY_PATH:$gtlslib" export CURL_LIBRARY_PATH AC_MSG_NOTICE([Added $gtlslib to CURL_LIBRARY_PATH]) @@ -147,12 +147,12 @@ if test "$GNUTLS_ENABLED" = "1"; then AC_CHECK_LIB(gnutls, nettle_MD5Init, [ USE_GNUTLS_NETTLE=1 ]) # If not, try linking directly to both of them to see if they are available - if test "$USE_GNUTLS_NETTLE" = ""; then + if test -z "$USE_GNUTLS_NETTLE"; then dnl this is with no particular path given CURL_CHECK_PKGCONFIG(nettle) - if test "$PKGCONFIG" != "no" ; then + if test "$PKGCONFIG" != "no"; then addlib=`$PKGCONFIG --libs-only-l nettle` addld=`$PKGCONFIG --libs-only-L nettle` addcflags=`$PKGCONFIG --cflags-only-I nettle` @@ -192,7 +192,7 @@ if test "$GNUTLS_ENABLED" = "1"; then fi fi fi - if test "$USE_GNUTLS_NETTLE" = ""; then + if test -z "$USE_GNUTLS_NETTLE"; then AC_MSG_ERROR([GnuTLS found, but nettle was not found]) fi else diff --git a/m4/curl-mbedtls.m4 b/m4/curl-mbedtls.m4 index 93da5b25e068..7c5bccd22983 100644 --- a/m4/curl-mbedtls.m4 +++ b/m4/curl-mbedtls.m4 @@ -27,19 +27,19 @@ dnl check for mbedTLS dnl ---------------------------------------------------- AC_DEFUN([CURL_WITH_MBEDTLS], [ -if test "x$OPT_MBEDTLS" != xno; then +if test "x$OPT_MBEDTLS" != "xno"; then _cppflags=$CPPFLAGS _ldflags=$LDFLAGS _ldflagspc=$LDFLAGSPC ssl_msg= - if test X"$OPT_MBEDTLS" != Xno; then + if test "x$OPT_MBEDTLS" != "xno"; then - if test "$OPT_MBEDTLS" = "yes"; then + if test "x$OPT_MBEDTLS" = "xyes"; then OPT_MBEDTLS="" fi - if test -z "$OPT_MBEDTLS" ; then + if test -z "$OPT_MBEDTLS"; then dnl check for lib first without setting any new path AC_CHECK_LIB(mbedtls, mbedtls_havege_init, @@ -49,7 +49,7 @@ if test "x$OPT_MBEDTLS" != xno; then MBEDTLS_ENABLED=1 USE_MBEDTLS="yes" ssl_msg="mbedTLS" - test mbedtls != "$DEFAULT_SSL_BACKEND" || VALID_DEFAULT_SSL_BACKEND=yes + test "mbedtls" != "$DEFAULT_SSL_BACKEND" || VALID_DEFAULT_SSL_BACKEND=yes ], [], -lmbedx509 -lmbedcrypto) fi @@ -58,7 +58,7 @@ if test "x$OPT_MBEDTLS" != xno; then addcflags="" mbedtlslib="" - if test "x$USE_MBEDTLS" != "xyes"; then + if test "$USE_MBEDTLS" != "yes"; then dnl add the path and test again addld=-L$OPT_MBEDTLS/lib$libsuff addcflags=-I$OPT_MBEDTLS/include @@ -76,7 +76,7 @@ if test "x$OPT_MBEDTLS" != xno; then MBEDTLS_ENABLED=1 USE_MBEDTLS="yes" ssl_msg="mbedTLS" - test mbedtls != "$DEFAULT_SSL_BACKEND" || VALID_DEFAULT_SSL_BACKEND=yes + test "mbedtls" != "$DEFAULT_SSL_BACKEND" || VALID_DEFAULT_SSL_BACKEND=yes ], [ CPPFLAGS=$_cppflags @@ -85,7 +85,7 @@ if test "x$OPT_MBEDTLS" != xno; then ], -lmbedx509 -lmbedcrypto) fi - if test "x$USE_MBEDTLS" = "xyes"; then + if test "$USE_MBEDTLS" = "yes"; then AC_MSG_NOTICE([detected mbedTLS]) check_for_ca_bundle=1 @@ -96,7 +96,7 @@ if test "x$OPT_MBEDTLS" != xno; then dnl linker does not search through, we need to add it to dnl CURL_LIBRARY_PATH to prevent further configure tests to fail dnl due to this - if test "x$cross_compiling" != "xyes"; then + if test "$cross_compiling" != "yes"; then CURL_LIBRARY_PATH="$CURL_LIBRARY_PATH:$mbedtlslib" export CURL_LIBRARY_PATH AC_MSG_NOTICE([Added $mbedtlslib to CURL_LIBRARY_PATH]) diff --git a/m4/curl-openssl.m4 b/m4/curl-openssl.m4 index b9b93e2ea01f..3892e0e89f02 100644 --- a/m4/curl-openssl.m4 +++ b/m4/curl-openssl.m4 @@ -30,7 +30,7 @@ dnl Check for OpenSSL libraries and headers dnl ********************************************************************** AC_DEFUN([CURL_WITH_OPENSSL], [ -if test "x$OPT_OPENSSL" != xno; then +if test "x$OPT_OPENSSL" != "xno"; then ssl_msg= dnl backup the pre-ssl variables @@ -102,7 +102,7 @@ if test "x$OPT_OPENSSL" != xno; then dnl in case pkg-config comes up empty, use what we got dnl via --with-openssl LIB_OPENSSL="$PREFIX_OPENSSL/lib$libsuff" - if test "$PREFIX_OPENSSL" != "/usr" ; then + if test "$PREFIX_OPENSSL" != "/usr"; then SSL_LDFLAGS="-L$LIB_OPENSSL" SSL_CPPFLAGS="-I$PREFIX_OPENSSL/include" fi @@ -113,7 +113,7 @@ if test "x$OPT_OPENSSL" != xno; then CURL_CHECK_PKGCONFIG(openssl, [$OPENSSL_PCDIR]) - if test "$PKGCONFIG" != "no" ; then + if test "$PKGCONFIG" != "no"; then SSL_LIBS=`CURL_EXPORT_PCDIR([$OPENSSL_PCDIR]) dnl $PKGCONFIG --libs-only-l --libs-only-other openssl 2>/dev/null` @@ -148,11 +148,11 @@ if test "x$OPT_OPENSSL" != xno; then HAVECRYPTO="yes" LIBS="-lcrypto $LIBS" ],[ - if test -n "$LIB_OPENSSL" ; then + if test -n "$LIB_OPENSSL"; then LDFLAGS="$CLEANLDFLAGS -L$LIB_OPENSSL" LDFLAGSPC="$CLEANLDFLAGSPC -L$LIB_OPENSSL" fi - if test "$PKGCONFIG" = "no" -a -n "$PREFIX_OPENSSL" ; then + if test "$PKGCONFIG" = "no" && test -n "$PREFIX_OPENSSL"; then # only set this if pkg-config was not used CPPFLAGS="$CLEANCPPFLAGS -I$PREFIX_OPENSSL/include" fi @@ -203,33 +203,33 @@ if test "x$OPT_OPENSSL" != xno; then ]) ]) - if test X"$HAVECRYPTO" = X"yes"; then + if test "$HAVECRYPTO" = "yes"; then dnl This is only reasonable to do if crypto actually is there: check for dnl SSL libs NOTE: it is important to do this AFTER the crypto lib AC_CHECK_LIB(ssl, SSL_connect) - if test "$ac_cv_lib_ssl_SSL_connect" = yes; then + if test "$ac_cv_lib_ssl_SSL_connect" = "yes"; then dnl Have the libraries--check for OpenSSL headers AC_CHECK_HEADERS(openssl/x509.h openssl/rsa.h openssl/crypto.h \ openssl/pem.h openssl/ssl.h openssl/err.h, ssl_msg="OpenSSL" - test openssl != "$DEFAULT_SSL_BACKEND" || VALID_DEFAULT_SSL_BACKEND=yes + test "openssl" != "$DEFAULT_SSL_BACKEND" || VALID_DEFAULT_SSL_BACKEND=yes OPENSSL_ENABLED=1 AC_DEFINE(USE_OPENSSL, 1, [if OpenSSL is in use])) fi - if test X"$OPENSSL_ENABLED" != X"1"; then + if test "$OPENSSL_ENABLED" != "1"; then LIBS="$CLEANLIBS" fi - if test X"$OPT_OPENSSL" != Xoff && + if test "x$OPT_OPENSSL" != "xoff" && test "$OPENSSL_ENABLED" != "1"; then AC_MSG_ERROR([OpenSSL libs and/or directories were not found where specified!]) fi fi - if test X"$OPENSSL_ENABLED" = X"1"; then + if test "$OPENSSL_ENABLED" = "1"; then dnl These can only exist if OpenSSL exists AC_MSG_CHECKING([for BoringSSL]) @@ -319,7 +319,7 @@ if test "x$OPT_OPENSSL" != xno; then dnl when the ssl shared libs were found in a path that the runtime dnl linker does not search through, we need to add it to CURL_LIBRARY_PATH dnl to prevent further configure tests to fail due to this - if test "x$cross_compiling" != "xyes"; then + if test "$cross_compiling" != "yes"; then CURL_LIBRARY_PATH="$CURL_LIBRARY_PATH:$LIB_OPENSSL" export CURL_LIBRARY_PATH AC_MSG_NOTICE([Added $LIB_OPENSSL to CURL_LIBRARY_PATH]) @@ -332,7 +332,7 @@ if test "x$OPT_OPENSSL" != xno; then test -z "$ssl_msg" || ssl_backends="${ssl_backends:+$ssl_backends, }$ssl_msg" fi -if test X"$OPT_OPENSSL" != Xno && +if test "x$OPT_OPENSSL" != "xno" && test "$OPENSSL_ENABLED" != "1"; then AC_MSG_NOTICE([OPT_OPENSSL: $OPT_OPENSSL]) AC_MSG_NOTICE([OPENSSL_ENABLED: $OPENSSL_ENABLED]) @@ -389,7 +389,7 @@ if test "$OPENSSL_ENABLED" = "1"; then AC_ARG_ENABLE(openssl-auto-load-config, AS_HELP_STRING([--enable-openssl-auto-load-config],[Enable automatic loading of OpenSSL configuration]) AS_HELP_STRING([--disable-openssl-auto-load-config],[Disable automatic loading of OpenSSL configuration]), - [ if test X"$enableval" = X"no"; then + [ if test "x$enableval" = "xno"; then AC_MSG_NOTICE([automatic loading of OpenSSL configuration disabled]) AC_DEFINE(CURL_DISABLE_OPENSSL_AUTO_LOAD_CONFIG, 1, [if the OpenSSL configuration will not be loaded automatically]) fi diff --git a/m4/curl-rustls.m4 b/m4/curl-rustls.m4 index 7b7e9975240c..f1b5d6b1df44 100644 --- a/m4/curl-rustls.m4 +++ b/m4/curl-rustls.m4 @@ -27,7 +27,7 @@ dnl ---------------------------------------------------- dnl check for Rustls dnl ---------------------------------------------------- -if test "x$OPT_RUSTLS" != xno; then +if test "x$OPT_RUSTLS" != "xno"; then ssl_msg= dnl backup the pre-ssl variables @@ -83,14 +83,14 @@ if test "x$OPT_RUSTLS" != xno; then CPPFLAGS="$CPPFLAGS $addcflags" fi - if test "$curl_cv_apple" = 'yes'; then + if test "$curl_cv_apple" = "yes"; then RUSTLS_LDFLAGS="-framework Security -framework Foundation" else RUSTLS_LDFLAGS="-lpthread -ldl -lm" fi LIB_RUSTLS="$PREFIX_RUSTLS/lib$libsuff" - if test "$PREFIX_RUSTLS" != "/usr" ; then + if test "$PREFIX_RUSTLS" != "/usr"; then SSL_LDFLAGS="-L$LIB_RUSTLS $RUSTLS_LDFLAGS" SSL_CPPFLAGS="-I$PREFIX_RUSTLS/include" fi @@ -108,7 +108,7 @@ if test "x$OPT_RUSTLS" != xno; then CURL_CHECK_PKGCONFIG(rustls, [$RUSTLS_PCDIR]) - if test "$PKGCONFIG" != "no" ; then + if test "$PKGCONFIG" != "no"; then SSL_LIBS=`CURL_EXPORT_PCDIR([$RUSTLS_PCDIR]) dnl $PKGCONFIG --libs-only-l --libs-only-other rustls 2>/dev/null` @@ -136,7 +136,7 @@ if test "x$OPT_RUSTLS" != xno; then AC_DEFINE(USE_RUSTLS, 1, [if Rustls is enabled]) USE_RUSTLS="yes" RUSTLS_ENABLED=1 - test rustls != "$DEFAULT_SSL_BACKEND" || VALID_DEFAULT_SSL_BACKEND=yes + test "rustls" != "$DEFAULT_SSL_BACKEND" || VALID_DEFAULT_SSL_BACKEND=yes else AC_MSG_ERROR([pkg-config: Could not find Rustls]) fi @@ -152,7 +152,7 @@ if test "x$OPT_RUSTLS" != xno; then LDFLAGS="$CLEANLDFLAGS $SSL_LDFLAGS" LDFLAGSPC="$CLEANLDFLAGSPC $SSL_LDFLAGS" - if test "x$USE_RUSTLS" = "xyes"; then + if test "$USE_RUSTLS" = "yes"; then AC_MSG_NOTICE([detected Rustls]) check_for_ca_bundle=1 @@ -161,7 +161,7 @@ if test "x$OPT_RUSTLS" != xno; then dnl linker does not search through, we need to add it to dnl CURL_LIBRARY_PATH so that further configure tests do not dnl fail due to this - if test "x$cross_compiling" != "xyes"; then + if test "$cross_compiling" != "yes"; then CURL_LIBRARY_PATH="$CURL_LIBRARY_PATH:$LIB_RUSTLS" export CURL_LIBRARY_PATH AC_MSG_NOTICE([Added $LIB_RUSTLS to CURL_LIBRARY_PATH]) @@ -177,7 +177,7 @@ if test "x$OPT_RUSTLS" != xno; then RUSTLS_ENABLED=1 USE_RUSTLS="yes" ssl_msg="Rustls" - test rustls != "$DEFAULT_SSL_BACKEND" || VALID_DEFAULT_SSL_BACKEND=yes + test "rustls" != "$DEFAULT_SSL_BACKEND" || VALID_DEFAULT_SSL_BACKEND=yes ], AC_MSG_ERROR([--with-rustls was specified but could not find compatible Rustls.]), $RUSTLS_LDFLAGS) @@ -185,7 +185,7 @@ if test "x$OPT_RUSTLS" != xno; then test -z "$ssl_msg" || ssl_backends="${ssl_backends:+$ssl_backends, }$ssl_msg" - if test X"$OPT_RUSTLS" != Xno && + if test "x$OPT_RUSTLS" != "xno" && test "$RUSTLS_ENABLED" != "1"; then AC_MSG_NOTICE([OPT_RUSTLS: $OPT_RUSTLS]) AC_MSG_NOTICE([RUSTLS_ENABLED: $RUSTLS_ENABLED]) diff --git a/m4/curl-schannel.m4 b/m4/curl-schannel.m4 index 1aa66dc2c84a..c67098fa113e 100644 --- a/m4/curl-schannel.m4 +++ b/m4/curl-schannel.m4 @@ -24,17 +24,17 @@ AC_DEFUN([CURL_WITH_SCHANNEL], [ AC_MSG_CHECKING([whether to enable Windows native SSL/TLS]) -if test "x$OPT_SCHANNEL" != xno; then +if test "x$OPT_SCHANNEL" != "xno"; then ssl_msg= if test "x$OPT_SCHANNEL" != "xno" && - test "x$curl_cv_native_windows" = "xyes"; then - if test "$curl_cv_winuwp" = 'yes'; then + test "$curl_cv_native_windows" = "yes"; then + if test "$curl_cv_winuwp" = "yes"; then AC_MSG_ERROR([UWP does not support Schannel.]) fi AC_MSG_RESULT(yes) AC_DEFINE(USE_SCHANNEL, 1, [to enable Windows native SSL/TLS support]) ssl_msg="Schannel" - test schannel != "$DEFAULT_SSL_BACKEND" || VALID_DEFAULT_SSL_BACKEND=yes + test "schannel" != "$DEFAULT_SSL_BACKEND" || VALID_DEFAULT_SSL_BACKEND=yes SCHANNEL_ENABLED=1 # --with-schannel implies --enable-sspi AC_DEFINE(USE_WINDOWS_SSPI, 1, [to enable SSPI support]) diff --git a/m4/curl-sysconfig.m4 b/m4/curl-sysconfig.m4 index f5ebe0391b20..7ad1285ef2df 100644 --- a/m4/curl-sysconfig.m4 +++ b/m4/curl-sysconfig.m4 @@ -40,7 +40,7 @@ AC_MSG_CHECKING([whether to link macOS CoreFoundation, CoreServices, and SystemC ],[ build_for_macos="no" ]) - if test "x$build_for_macos" != xno; then + if test "$build_for_macos" != "no"; then AC_MSG_RESULT(yes) SYSCONFIG_LDFLAGS='-framework CoreFoundation -framework CoreServices -framework SystemConfiguration' LDFLAGS="$LDFLAGS $SYSCONFIG_LDFLAGS" diff --git a/m4/curl-wolfssl.m4 b/m4/curl-wolfssl.m4 index 0eba972b633b..4cbc6f5c0c4e 100644 --- a/m4/curl-wolfssl.m4 +++ b/m4/curl-wolfssl.m4 @@ -36,14 +36,14 @@ case "$OPT_WOLFSSL" in ;; esac -if test "x$OPT_WOLFSSL" != xno; then +if test "$OPT_WOLFSSL" != "no"; then _cppflags=$CPPFLAGS _ldflags=$LDFLAGS _ldflagspc=$LDFLAGSPC ssl_msg= - if test X"$OPT_WOLFSSL" != Xno; then + if test "$OPT_WOLFSSL" != "no"; then if test "$OPT_WOLFSSL" = "yes"; then OPT_WOLFSSL="" @@ -56,7 +56,7 @@ if test "x$OPT_WOLFSSL" != xno; then addld="" addlib="" addcflags="" - if test "$PKGCONFIG" != "no" ; then + if test "$PKGCONFIG" != "no"; then addlib=`CURL_EXPORT_PCDIR([$wolfpkg]) $PKGCONFIG --libs-only-l wolfssl` addld=`CURL_EXPORT_PCDIR([$wolfpkg]) @@ -76,13 +76,13 @@ if test "x$OPT_WOLFSSL" != xno; then fi fi - if test "$curl_cv_apple" = 'yes'; then + if test "$curl_cv_apple" = "yes"; then addlib="$addlib -framework Security -framework CoreFoundation" else addlib="$addlib -lm" fi - if test "x$USE_WOLFSSL" != "xyes"; then + if test "$USE_WOLFSSL" != "yes"; then LDFLAGS="$LDFLAGS $addld" LDFLAGSPC="$LDFLAGSPC $addld" @@ -114,7 +114,7 @@ if test "x$OPT_WOLFSSL" != xno; then WOLFSSL_ENABLED=1 USE_WOLFSSL="yes" ssl_msg="wolfSSL" - test wolfssl != "$DEFAULT_SSL_BACKEND" || VALID_DEFAULT_SSL_BACKEND=yes + test "wolfssl" != "$DEFAULT_SSL_BACKEND" || VALID_DEFAULT_SSL_BACKEND=yes ], [ AC_MSG_RESULT(no) @@ -126,7 +126,7 @@ if test "x$OPT_WOLFSSL" != xno; then LIBS="$my_ac_save_LIBS" fi - if test "x$USE_WOLFSSL" = "xyes"; then + if test "$USE_WOLFSSL" = "yes"; then AC_MSG_NOTICE([detected wolfSSL]) check_for_ca_bundle=1 @@ -150,12 +150,12 @@ if test "x$OPT_WOLFSSL" != xno; then dnl if this symbol is present, we want the include path to include the dnl OpenSSL API root as well - if test "x$ac_cv_func_wolfSSL_DES_ecb_encrypt" = 'xyes'; then + if test "$ac_cv_func_wolfSSL_DES_ecb_encrypt" = "yes"; then HAVE_WOLFSSL_DES_ECB_ENCRYPT=1 fi dnl if this symbol is present, we can make use of BIO filter chains - if test "x$ac_cv_func_wolfSSL_BIO_new" = 'xyes'; then + if test "$ac_cv_func_wolfSSL_BIO_new" = "yes"; then HAVE_WOLFSSL_BIO_NEW=1 fi @@ -164,7 +164,7 @@ if test "x$OPT_WOLFSSL" != xno; then dnl linker does not search through, we need to add it to dnl CURL_LIBRARY_PATH to prevent further configure tests to fail dnl due to this - if test "x$cross_compiling" != "xyes"; then + if test "$cross_compiling" != "yes"; then CURL_LIBRARY_PATH="$CURL_LIBRARY_PATH:$wolfssllibpath" export CURL_LIBRARY_PATH AC_MSG_NOTICE([Added $wolfssllibpath to CURL_LIBRARY_PATH]) diff --git a/m4/xc-lt-iface.m4 b/m4/xc-lt-iface.m4 index 22eecd349f20..83bf62ccf6cf 100644 --- a/m4/xc-lt-iface.m4 +++ b/m4/xc-lt-iface.m4 @@ -59,8 +59,8 @@ case "x$enable_static" in @%:@ ( xc_lt_want_enable_static='no' ;; esac -if test "x$xc_lt_want_enable_shared" = 'xno' && - test "x$xc_lt_want_enable_static" = 'xno'; then +if test "$xc_lt_want_enable_shared" = "no" && + test "$xc_lt_want_enable_static" = "no"; then AC_MSG_ERROR([can not disable shared and static libraries simultaneously]) fi @@ -71,8 +71,8 @@ fi # must be used in order to build a proper static library. # -if test "x$xc_lt_want_enable_shared" = 'xyes' && - test "x$xc_lt_want_enable_static" = 'xyes'; then +if test "$xc_lt_want_enable_shared" = "yes" && + test "$xc_lt_want_enable_static" = "yes"; then case $host_os in @%:@ ( os2* | aix*) xc_lt_want_enable_static='no' @@ -117,7 +117,7 @@ esac # be overridden using 'configure --disable-shared --without-pic'. # -if test "x$xc_lt_want_with_pic" = 'xdefault'; then +if test "$xc_lt_want_with_pic" = "default"; then case $host_cpu in @%:@ ( x86_64 | amd64 | ia64) case $host_os in @%:@ ( @@ -229,7 +229,7 @@ m4_define([_XC_CHECK_LT_SHLIB_USE_VERSION_INFO], AC_MSG_CHECKING([whether to build shared libraries with -version-info]) xc_lt_shlib_use_version_info='yes' -if test "x$version_type" = 'xnone'; then +if test "$version_type" = "none"; then xc_lt_shlib_use_version_info='no' fi case $host_os in @%:@ ( @@ -259,9 +259,9 @@ m4_define([_XC_CHECK_LT_SHLIB_USE_NO_UNDEFINED], AC_MSG_CHECKING([whether to build shared libraries with -no-undefined]) xc_lt_shlib_use_no_undefined='no' -if test "x$allow_undefined" = 'xno'; then +if test "x$allow_undefined" = "xno"; then xc_lt_shlib_use_no_undefined='yes' -elif test "x$allow_undefined_flag" = 'xunsupported'; then +elif test "x$allow_undefined_flag" = "xunsupported"; then xc_lt_shlib_use_no_undefined='yes' fi case $host_os in @%:@ ( @@ -293,7 +293,7 @@ AC_MSG_CHECKING([whether to build shared libraries with -mimpure-text]) xc_lt_shlib_use_mimpure_text='no' case $host_os in @%:@ ( solaris2*) - if test "x$GCC" = 'xyes'; then + if test "x$GCC" = "xyes"; then xc_lt_shlib_use_mimpure_text='yes' fi ;; @@ -367,8 +367,8 @@ m4_define([_XC_CHECK_LT_BUILD_SINGLE_VERSION], # AC_MSG_CHECKING([whether to build shared libraries only]) -if test "$xc_lt_build_shared" = 'yes' && - test "$xc_lt_build_static" = 'no'; then +if test "$xc_lt_build_shared" = "yes" && + test "$xc_lt_build_static" = "no"; then xc_lt_build_shared_only='yes' else xc_lt_build_shared_only='no' @@ -380,8 +380,8 @@ AC_MSG_RESULT([$xc_lt_build_shared_only]) # AC_MSG_CHECKING([whether to build static libraries only]) -if test "$xc_lt_build_static" = 'yes' && - test "$xc_lt_build_shared" = 'no'; then +if test "$xc_lt_build_static" = "yes" && + test "$xc_lt_build_shared" = "no"; then xc_lt_build_static_only='yes' else xc_lt_build_static_only='no' diff --git a/m4/xc-val-flgs.m4 b/m4/xc-val-flgs.m4 index 4715163c9e7e..fd906434966e 100644 --- a/m4/xc-val-flgs.m4 +++ b/m4/xc-val-flgs.m4 @@ -39,7 +39,7 @@ AC_DEFUN([_XC_CHECK_VAR_LIBS], [ ;; esac done - if test $xc_bad_var_libs = yes; then + if test "$xc_bad_var_libs" = "yes"; then AC_MSG_NOTICE([using LIBS: $LIBS]) AC_MSG_NOTICE([LIBS note: LIBS should only be used to specify libraries (-lname).]) fi @@ -68,7 +68,7 @@ AC_DEFUN([_XC_CHECK_VAR_LDFLAGS], [ ;; esac done - if test $xc_bad_var_ldflags = yes; then + if test "$xc_bad_var_ldflags" = "yes"; then AC_MSG_NOTICE([using LDFLAGS: $LDFLAGS]) xc_bad_var_msg="LDFLAGS note: LDFLAGS should only be used to specify linker flags, not" for xc_word in $LDFLAGS; do @@ -110,7 +110,7 @@ AC_DEFUN([_XC_CHECK_VAR_CPPFLAGS], [ ;; esac done - if test $xc_bad_var_cppflags = yes; then + if test "$xc_bad_var_cppflags" = "yes"; then AC_MSG_NOTICE([using CPPFLAGS: $CPPFLAGS]) xc_bad_var_msg="CPPFLAGS note: CPPFLAGS should only be used to specify C preprocessor flags, not" for xc_word in $CPPFLAGS; do @@ -158,7 +158,7 @@ AC_DEFUN([_XC_CHECK_VAR_CFLAGS], [ ;; esac done - if test $xc_bad_var_cflags = yes; then + if test "$xc_bad_var_cflags" = "yes"; then AC_MSG_NOTICE([using CFLAGS: $CFLAGS]) xc_bad_var_msg="CFLAGS note: CFLAGS should only be used to specify C compiler flags, not" for xc_word in $CFLAGS; do @@ -207,10 +207,10 @@ AC_DEFUN([XC_CHECK_USER_FLAGS], [ _XC_CHECK_VAR_LDFLAGS _XC_CHECK_VAR_CPPFLAGS _XC_CHECK_VAR_CFLAGS - if test $xc_bad_var_libs = yes || - test $xc_bad_var_cflags = yes || - test $xc_bad_var_ldflags = yes || - test $xc_bad_var_cppflags = yes; then + if test "$xc_bad_var_libs" = "yes" || + test "$xc_bad_var_cflags" = "yes" || + test "$xc_bad_var_ldflags" = "yes" || + test "$xc_bad_var_cppflags" = "yes"; then AC_MSG_ERROR([Can not continue. Fix errors mentioned immediately above this line.]) fi ]) @@ -235,10 +235,10 @@ AC_DEFUN([XC_CHECK_BUILD_FLAGS], [ _XC_CHECK_VAR_LDFLAGS _XC_CHECK_VAR_CPPFLAGS _XC_CHECK_VAR_CFLAGS - if test $xc_bad_var_libs = yes || - test $xc_bad_var_cflags = yes || - test $xc_bad_var_ldflags = yes || - test $xc_bad_var_cppflags = yes; then + if test "$xc_bad_var_libs" = "yes" || + test "$xc_bad_var_cflags" = "yes" || + test "$xc_bad_var_ldflags" = "yes" || + test "$xc_bad_var_cppflags" = "yes"; then AC_MSG_WARN([Continuing even with errors mentioned immediately above this line.]) fi ]) diff --git a/m4/zz40-xc-ovr.m4 b/m4/zz40-xc-ovr.m4 index 5389a455614c..02c86c9eeaad 100644 --- a/m4/zz40-xc-ovr.m4 +++ b/m4/zz40-xc-ovr.m4 @@ -393,7 +393,7 @@ done IFS=$xc_tst_prev_IFS xc_tst_dirs_sem=`expr "$xc_tst_dirs_sem" : '.*'` -if test $xc_tst_dirs_sem -eq $xc_tst_dirs_col; then +if test "$xc_tst_dirs_sem" -eq "$xc_tst_dirs_col"; then # When both counting methods give the same result we do not want to # chose one over the other, and consider auto-detection not possible. if test -z "$PATH_SEPARATOR"; then @@ -404,7 +404,7 @@ if test $xc_tst_dirs_sem -eq $xc_tst_dirs_col; then fi else # Separator with the greater directory count is the auto-detected one. - if test $xc_tst_dirs_sem -gt $xc_tst_dirs_col; then + if test "$xc_tst_dirs_sem" -gt "$xc_tst_dirs_col"; then xc_tst_auto_separator=';' else xc_tst_auto_separator=':' From 73b732e3e8d3b23bc8b11ee8024448f9e61ced7d Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Wed, 10 Dec 2025 22:42:35 +0100 Subject: [PATCH 280/415] tests/data: replace `&` with `%AMP` For XML-compliance. Closes #19923 --- tests/data/test1011 | 7 +++---- tests/data/test1012 | 7 +++---- tests/data/test1015 | 3 +-- tests/data/test1076 | 7 +++---- tests/data/test1105 | 7 +++---- tests/data/test1138 | 7 +++---- tests/data/test1221 | 3 +-- tests/data/test1332 | 7 +++---- tests/data/test1402 | 3 +-- tests/data/test1403 | 3 +-- tests/data/test1598 | 3 +-- tests/data/test1977 | 5 ++--- tests/data/test199 | 7 +++---- tests/data/test3 | 5 ++--- tests/data/test32 | 5 ++--- tests/data/test40 | 7 +++---- tests/data/test439 | 5 ++--- tests/data/test48 | 7 +++---- tests/data/test568 | 3 +-- tests/data/test733 | 5 ++--- tests/data/test734 | 5 ++--- tests/data/test735 | 5 ++--- tests/data/test739 | 3 +-- 23 files changed, 48 insertions(+), 71 deletions(-) diff --git a/tests/data/test1011 b/tests/data/test1011 index 4f5111dea23b..c15fab06dc64 100644 --- a/tests/data/test1011 +++ b/tests/data/test1011 @@ -4,7 +4,6 @@ HTTP HTTP POST followlocation -notxml # @@ -12,7 +11,7 @@ notxml HTTP/1.1 301 OK -Location: moo.html&testcase=/%TESTNUMBER0002 +Location: moo.html%AMPtestcase=/%TESTNUMBER0002 Date: Tue, 09 Nov 2010 14:49:00 GMT Content-Length: 0 @@ -27,7 +26,7 @@ body HTTP/1.1 301 OK -Location: moo.html&testcase=/%TESTNUMBER0002 +Location: moo.html%AMPtestcase=/%TESTNUMBER0002 Date: Tue, 09 Nov 2010 14:49:00 GMT Content-Length: 0 @@ -65,7 +64,7 @@ Accept: */* Content-Length: 3 Content-Type: application/x-www-form-urlencoded -mooGET /blah/moo.html&testcase=/%TESTNUMBER0002 HTTP/1.1 +mooGET /blah/moo.html%AMPtestcase=/%TESTNUMBER0002 HTTP/1.1 Host: %HOSTIP:%HTTPPORT User-Agent: curl/%VERSION Accept: */* diff --git a/tests/data/test1012 b/tests/data/test1012 index ef2d679bfc4c..fe678aa00696 100644 --- a/tests/data/test1012 +++ b/tests/data/test1012 @@ -4,7 +4,6 @@ HTTP HTTP POST followlocation -notxml # @@ -12,7 +11,7 @@ notxml HTTP/1.1 301 OK swsclose -Location: moo.html&testcase=/%TESTNUMBER0002 +Location: moo.html%AMPtestcase=/%TESTNUMBER0002 Date: Tue, 09 Nov 2010 14:49:00 GMT Connection: close @@ -27,7 +26,7 @@ body HTTP/1.1 301 OK swsclose -Location: moo.html&testcase=/%TESTNUMBER0002 +Location: moo.html%AMPtestcase=/%TESTNUMBER0002 Date: Tue, 09 Nov 2010 14:49:00 GMT Connection: close @@ -65,7 +64,7 @@ Accept: */* Content-Length: 3 Content-Type: application/x-www-form-urlencoded -mooPOST /blah/moo.html&testcase=/%TESTNUMBER0002 HTTP/1.1 +mooPOST /blah/moo.html%AMPtestcase=/%TESTNUMBER0002 HTTP/1.1 Host: %HOSTIP:%HTTPPORT User-Agent: curl/%VERSION Accept: */* diff --git a/tests/data/test1015 b/tests/data/test1015 index 2cd937806043..0f5ec3f6329b 100644 --- a/tests/data/test1015 +++ b/tests/data/test1015 @@ -4,7 +4,6 @@ HTTP HTTP POST --data-urlencode -notxml @@ -51,7 +50,7 @@ Accept: */* Content-Length: 119 Content-Type: application/x-www-form-urlencoded -my+name+is+moo%5B%5D&y e s=s_i_r&v_alue=content+to+_%3F%21%23%24%27%7C%3C%3E%0A&content+to+_%3F%21%23%24%27%7C%3C%3E%0A +my+name+is+moo%5B%5D%AMPy e s=s_i_r%AMPv_alue=content+to+_%3F%21%23%24%27%7C%3C%3E%0A%AMPcontent+to+_%3F%21%23%24%27%7C%3C%3E%0A diff --git a/tests/data/test1076 b/tests/data/test1076 index 08eba396c597..8d9f0f1a326e 100644 --- a/tests/data/test1076 +++ b/tests/data/test1076 @@ -4,7 +4,6 @@ HTTP HTTP POST followlocation -notxml # @@ -12,7 +11,7 @@ notxml HTTP/1.1 302 OK swsclose -Location: moo.html&testcase=/%TESTNUMBER0002 +Location: moo.html%AMPtestcase=/%TESTNUMBER0002 Date: Tue, 09 Nov 2010 14:49:00 GMT Connection: close @@ -27,7 +26,7 @@ body HTTP/1.1 302 OK swsclose -Location: moo.html&testcase=/%TESTNUMBER0002 +Location: moo.html%AMPtestcase=/%TESTNUMBER0002 Date: Tue, 09 Nov 2010 14:49:00 GMT Connection: close @@ -65,7 +64,7 @@ Accept: */* Content-Length: 3 Content-Type: application/x-www-form-urlencoded -mooPOST /blah/moo.html&testcase=/%TESTNUMBER0002 HTTP/1.1 +mooPOST /blah/moo.html%AMPtestcase=/%TESTNUMBER0002 HTTP/1.1 Host: %HOSTIP:%HTTPPORT User-Agent: curl/%VERSION Accept: */* diff --git a/tests/data/test1105 b/tests/data/test1105 index e0766817295e..5c850cd6d4af 100644 --- a/tests/data/test1105 +++ b/tests/data/test1105 @@ -5,7 +5,6 @@ HTTP HTTP POST cookies cookiejar -notxml @@ -36,7 +35,7 @@ http HTTP with cookie parser and header recording -"http://%HOSTIP:%HTTPPORT/we/want/%TESTNUMBER?parm1=this*that/other/thing&parm2=foobar/%TESTNUMBER" -c %LOGDIR/cookie%TESTNUMBER.txt -d "userid=myname&password=mypassword" +"http://%HOSTIP:%HTTPPORT/we/want/%TESTNUMBER?parm1=this*that/other/thing%AMPparm2=foobar/%TESTNUMBER" -c %LOGDIR/cookie%TESTNUMBER.txt -d "userid=myname%AMPpassword=mypassword" cookies @@ -47,14 +46,14 @@ local-http # Verify data after the test has been "shot" -POST /we/want/%TESTNUMBER?parm1=this*that/other/thing&parm2=foobar/%TESTNUMBER HTTP/1.1 +POST /we/want/%TESTNUMBER?parm1=this*that/other/thing%AMPparm2=foobar/%TESTNUMBER HTTP/1.1 Host: %HOSTIP:%HTTPPORT User-Agent: curl/%VERSION Accept: */* Content-Length: 33 Content-Type: application/x-www-form-urlencoded -userid=myname&password=mypassword +userid=myname%AMPpassword=mypassword # Netscape HTTP Cookie File diff --git a/tests/data/test1138 b/tests/data/test1138 index a3e65d0e0fb7..71a44a5a4256 100644 --- a/tests/data/test1138 +++ b/tests/data/test1138 @@ -4,7 +4,6 @@ HTTP HTTP GET followlocation -notxml # @@ -12,7 +11,7 @@ notxml HTTP/1.1 302 OK swsclose -Location: ../moo.html/?name=%hex[%d8%a2%d8%ba%d8%a7%d8%b2%2d%d8%b3%d9%85%2d%d8%b2%d8%af%d8%a7%db%8c%db%8c%2d%d8%a7%d8%b2%2d%d8%a8%d8%a7%d8%b2%d8%a7%d8%b1%2d%d9%be%d9%88%d9%84]hex%&testcase=/%TESTNUMBER0002 +Location: ../moo.html/?name=%hex[%d8%a2%d8%ba%d8%a7%d8%b2%2d%d8%b3%d9%85%2d%d8%b2%d8%af%d8%a7%db%8c%db%8c%2d%d8%a7%d8%b2%2d%d8%a8%d8%a7%d8%b2%d8%a7%d8%b1%2d%d9%be%d9%88%d9%84]hex%%AMPtestcase=/%TESTNUMBER0002 Date: Tue, 09 Nov 2010 14:49:00 GMT Connection: close @@ -27,7 +26,7 @@ body HTTP/1.1 302 OK swsclose -Location: ../moo.html/?name=%hex[%d8%a2%d8%ba%d8%a7%d8%b2%2d%d8%b3%d9%85%2d%d8%b2%d8%af%d8%a7%db%8c%db%8c%2d%d8%a7%d8%b2%2d%d8%a8%d8%a7%d8%b2%d8%a7%d8%b1%2d%d9%be%d9%88%d9%84]hex%&testcase=/%TESTNUMBER0002 +Location: ../moo.html/?name=%hex[%d8%a2%d8%ba%d8%a7%d8%b2%2d%d8%b3%d9%85%2d%d8%b2%d8%af%d8%a7%db%8c%db%8c%2d%d8%a7%d8%b2%2d%d8%a8%d8%a7%d8%b2%d8%a7%d8%b1%2d%d9%be%d9%88%d9%84]hex%%AMPtestcase=/%TESTNUMBER0002 Date: Tue, 09 Nov 2010 14:49:00 GMT Connection: close @@ -63,7 +62,7 @@ Host: %HOSTIP:%HTTPPORT User-Agent: curl/%VERSION Accept: */* -GET /we/are/all/moo.html/?name=%D8%A2%D8%BA%D8%A7%D8%B2-%D8%B3%D9%85-%D8%B2%D8%AF%D8%A7%DB%8C%DB%8C-%D8%A7%D8%B2-%D8%A8%D8%A7%D8%B2%D8%A7%D8%B1-%D9%BE%D9%88%D9%84&testcase=/%TESTNUMBER0002 HTTP/1.1 +GET /we/are/all/moo.html/?name=%D8%A2%D8%BA%D8%A7%D8%B2-%D8%B3%D9%85-%D8%B2%D8%AF%D8%A7%DB%8C%DB%8C-%D8%A7%D8%B2-%D8%A8%D8%A7%D8%B2%D8%A7%D8%B1-%D9%BE%D9%88%D9%84%AMPtestcase=/%TESTNUMBER0002 HTTP/1.1 Host: %HOSTIP:%HTTPPORT User-Agent: curl/%VERSION Accept: */* diff --git a/tests/data/test1221 b/tests/data/test1221 index 5f200c17abbe..2f1df8d2aa94 100644 --- a/tests/data/test1221 +++ b/tests/data/test1221 @@ -5,7 +5,6 @@ HTTP HTTP POST --data-urlencode --url-query -notxml @@ -47,7 +46,7 @@ content to _?!#$'|%LT%GT # Verify data after the test has been "shot" -POST /%TESTNUMBER?my+name+is+moo%5b%5d&yes=s+i+r&v_alue=content+to+_%3f%21%23%24%27%7c%3c%3e%0a&content+to+_%3f%21%23%24%27%7c%3c%3e%0a&%3d%3d HTTP/1.1 +POST /%TESTNUMBER?my+name+is+moo%5b%5d%AMPyes=s+i+r%AMPv_alue=content+to+_%3f%21%23%24%27%7c%3c%3e%0a%AMPcontent+to+_%3f%21%23%24%27%7c%3c%3e%0a%AMP%3d%3d HTTP/1.1 Host: %HOSTIP:%HTTPPORT User-Agent: curl/%VERSION Accept: */* diff --git a/tests/data/test1332 b/tests/data/test1332 index f1b596e31016..032cca7b5383 100644 --- a/tests/data/test1332 +++ b/tests/data/test1332 @@ -5,7 +5,6 @@ HTTP HTTP POST followlocation -notxml # @@ -13,7 +12,7 @@ notxml HTTP/1.1 303 OK swsclose -Location: moo.html&testcase=/%TESTNUMBER0002 +Location: moo.html%AMPtestcase=/%TESTNUMBER0002 Date: Tue, 09 Nov 2010 14:49:00 GMT Connection: close @@ -28,7 +27,7 @@ body HTTP/1.1 303 OK swsclose -Location: moo.html&testcase=/%TESTNUMBER0002 +Location: moo.html%AMPtestcase=/%TESTNUMBER0002 Date: Tue, 09 Nov 2010 14:49:00 GMT Connection: close @@ -66,7 +65,7 @@ Accept: */* Content-Length: 3 Content-Type: application/x-www-form-urlencoded -mooPOST /blah/moo.html&testcase=/%TESTNUMBER0002 HTTP/1.1 +mooPOST /blah/moo.html%AMPtestcase=/%TESTNUMBER0002 HTTP/1.1 Host: %HOSTIP:%HTTPPORT User-Agent: curl/%VERSION Accept: */* diff --git a/tests/data/test1402 b/tests/data/test1402 index 401daa3ba5b7..66d3c9dc3d72 100644 --- a/tests/data/test1402 +++ b/tests/data/test1402 @@ -4,7 +4,6 @@ HTTP HTTP POST --libcurl -notxml @@ -50,7 +49,7 @@ Accept: */* Content-Length: 16 Content-Type: application/x-www-form-urlencoded -foo=bar&baz=quux +foo=bar%AMPbaz=quux # CURLOPT_SSL_VERIFYPEER, SSH_KNOWNHOSTS and HTTP_VERSION vary with diff --git a/tests/data/test1403 b/tests/data/test1403 index 2a9cba0bed15..1055d29a83a4 100644 --- a/tests/data/test1403 +++ b/tests/data/test1403 @@ -4,7 +4,6 @@ HTTP HTTP GET --libcurl -notxml @@ -43,7 +42,7 @@ http://%HOSTIP:%HTTPPORT/we/want/%TESTNUMBER --libcurl %LOGDIR/test%TESTNUMBER.c # Verify data after the test has been "shot" -GET /we/want/%TESTNUMBER?foo=bar&baz=quux HTTP/1.1 +GET /we/want/%TESTNUMBER?foo=bar%AMPbaz=quux HTTP/1.1 Host: %HOSTIP:%HTTPPORT User-Agent: curl/%VERSION Accept: */* diff --git a/tests/data/test1598 b/tests/data/test1598 index f3143432edd0..f7c935a19013 100644 --- a/tests/data/test1598 +++ b/tests/data/test1598 @@ -5,7 +5,6 @@ HTTP HTTP POST CURLOPT_HTTPTRAILER_FUNCTION CURLOPT_HTTPTRAILER_DATA -notxml @@ -50,7 +49,7 @@ Transfer-Encoding: chunked Content-Type: application/x-www-form-urlencoded 11 -xxx=yyy&aaa=bbbbb +xxx=yyy%AMPaaa=bbbbb 0 my-super-awesome-trailer: trail1 my-other-awesome-trailer: trail2 diff --git a/tests/data/test1977 b/tests/data/test1977 index d62ed337e61a..dba5504e1030 100644 --- a/tests/data/test1977 +++ b/tests/data/test1977 @@ -3,7 +3,6 @@ CURLOPT_CURLU CURLINFO_EFFECTIVE_URL -notxml @@ -43,7 +42,7 @@ http://%HOSTIP:%HTTPPORT/%TESTNUMBER effective URL: http://%HOSTIP:%HTTPPORT/%TESTNUMBER effective URL: http://%HOSTIP:%HTTPPORT/%TESTNUMBER?foo -effective URL: http://%HOSTIP:%HTTPPORT/%TESTNUMBER?foo&bar +effective URL: http://%HOSTIP:%HTTPPORT/%TESTNUMBER?foo%AMPbar GET /%TESTNUMBER HTTP/1.1 @@ -54,7 +53,7 @@ GET /%TESTNUMBER?foo HTTP/1.1 Host: %HOSTIP:%HTTPPORT Accept: */* -GET /%TESTNUMBER?foo&bar HTTP/1.1 +GET /%TESTNUMBER?foo%AMPbar HTTP/1.1 Host: %HOSTIP:%HTTPPORT Accept: */* diff --git a/tests/data/test199 b/tests/data/test199 index fc8a8e96a0dc..996abb089e8f 100644 --- a/tests/data/test199 +++ b/tests/data/test199 @@ -4,7 +4,6 @@ HTTP HTTP GET globbing -notxml # @@ -36,7 +35,7 @@ http HTTP with -d, -G and {} --d "foo=moo&moo=poo" "http://%HOSTIP:%HTTPPORT/{%TESTNUMBER,%TESTNUMBER}" -G +-d "foo=moo%AMPmoo=poo" "http://%HOSTIP:%HTTPPORT/{%TESTNUMBER,%TESTNUMBER}" -G @@ -44,12 +43,12 @@ HTTP with -d, -G and {} # Verify data after the test has been "shot" -GET /%TESTNUMBER?foo=moo&moo=poo HTTP/1.1 +GET /%TESTNUMBER?foo=moo%AMPmoo=poo HTTP/1.1 Host: %HOSTIP:%HTTPPORT User-Agent: curl/%VERSION Accept: */* -GET /%TESTNUMBER?foo=moo&moo=poo HTTP/1.1 +GET /%TESTNUMBER?foo=moo%AMPmoo=poo HTTP/1.1 Host: %HOSTIP:%HTTPPORT User-Agent: curl/%VERSION Accept: */* diff --git a/tests/data/test3 b/tests/data/test3 index 50fdfeea48c3..c2f8e11a9c57 100644 --- a/tests/data/test3 +++ b/tests/data/test3 @@ -4,7 +4,6 @@ HTTP HTTP POST HTTP Basic auth -notxml # @@ -37,7 +36,7 @@ http HTTP POST with auth and contents but with content-length set to 0 - -d "fooo=mooo&pooo=clue&doo=%20%20%20++++" -u "fake:-user" http://%HOSTIP:%HTTPPORT/%TESTNUMBER + -d "fooo=mooo%AMPpooo=clue%AMPdoo=%20%20%20++++" -u "fake:-user" http://%HOSTIP:%HTTPPORT/%TESTNUMBER @@ -53,7 +52,7 @@ Accept: */* Content-Length: 37 Content-Type: application/x-www-form-urlencoded -fooo=mooo&pooo=clue&doo=%20%20%20++++ +fooo=mooo%AMPpooo=clue%AMPdoo=%20%20%20++++ diff --git a/tests/data/test32 b/tests/data/test32 index 94b9531ca5ed..e96389f98972 100644 --- a/tests/data/test32 +++ b/tests/data/test32 @@ -4,7 +4,6 @@ HTTP HTTP GET -G -notxml # @@ -36,7 +35,7 @@ http HTTP with -d and -G --d "foo=moo&moo=poo" http://%HOSTIP:%HTTPPORT/%TESTNUMBER -G +-d "foo=moo%AMPmoo=poo" http://%HOSTIP:%HTTPPORT/%TESTNUMBER -G @@ -44,7 +43,7 @@ HTTP with -d and -G # Verify data after the test has been "shot" -GET /%TESTNUMBER?foo=moo&moo=poo HTTP/1.1 +GET /%TESTNUMBER?foo=moo%AMPmoo=poo HTTP/1.1 Host: %HOSTIP:%HTTPPORT User-Agent: curl/%VERSION Accept: */* diff --git a/tests/data/test40 b/tests/data/test40 index 04efdbbc70b4..4f728fe8623b 100644 --- a/tests/data/test40 +++ b/tests/data/test40 @@ -4,7 +4,6 @@ HTTP HTTP GET followlocation -notxml # @@ -12,7 +11,7 @@ notxml HTTP/1.1 302 OK swsclose -Location: ../moo.html/?name=d a niel&testcase=/%TESTNUMBER0002%repeat[4 x ]% +Location: ../moo.html/?name=d a niel%AMPtestcase=/%TESTNUMBER0002%repeat[4 x ]% Date: Tue, 09 Nov 2010 14:49:00 GMT Connection: close @@ -27,7 +26,7 @@ body HTTP/1.1 302 OK swsclose -Location: ../moo.html/?name=d a niel&testcase=/%TESTNUMBER0002%repeat[4 x ]% +Location: ../moo.html/?name=d a niel%AMPtestcase=/%TESTNUMBER0002%repeat[4 x ]% Date: Tue, 09 Nov 2010 14:49:00 GMT Connection: close @@ -63,7 +62,7 @@ Host: %HOSTIP:%HTTPPORT User-Agent: curl/%VERSION Accept: */* -GET /we/are/all/moo.html/?name=d+a+niel&testcase=/%TESTNUMBER0002 HTTP/1.1 +GET /we/are/all/moo.html/?name=d+a+niel%AMPtestcase=/%TESTNUMBER0002 HTTP/1.1 Host: %HOSTIP:%HTTPPORT User-Agent: curl/%VERSION Accept: */* diff --git a/tests/data/test439 b/tests/data/test439 index 8529797242b9..949f887ef909 100644 --- a/tests/data/test439 +++ b/tests/data/test439 @@ -3,7 +3,6 @@ HTTP aws-sigv4 -notxml @@ -40,7 +39,7 @@ aws aws-sigv4 with query -"http://fake.fake.fake:8000/%TESTNUMBER/?name=me&noval&aim=b%aad&&&weirdo=*.//-" -u user:secret --aws-sigv4 "aws:amz:us-east-2:es" --connect-to fake.fake.fake:8000:%HOSTIP:%HTTPPORT +"http://fake.fake.fake:8000/%TESTNUMBER/?name=me%AMPnoval%AMPaim=b%aad%AMP%AMP%AMPweirdo=*.//-" -u user:secret --aws-sigv4 "aws:amz:us-east-2:es" --connect-to fake.fake.fake:8000:%HOSTIP:%HTTPPORT @@ -48,7 +47,7 @@ aws-sigv4 with query # Verify data after the test has been "shot" -GET /%TESTNUMBER/?name=me&noval&aim=b%aad&&&weirdo=*.//- HTTP/1.1 +GET /%TESTNUMBER/?name=me%AMPnoval%AMPaim=b%aad%AMP%AMP%AMPweirdo=*.//- HTTP/1.1 Host: fake.fake.fake:8000 Authorization: AWS4-HMAC-SHA256 Credential=user/19700101/us-east-2/es/aws4_request, SignedHeaders=host;x-amz-date, Signature=9dd8592929306832a6673d10063491391e486e5f50de4647ea7c2c797277e0a6 X-Amz-Date: 19700101T000000Z diff --git a/tests/data/test48 b/tests/data/test48 index c161ba5dca91..21cdbd368f94 100644 --- a/tests/data/test48 +++ b/tests/data/test48 @@ -4,7 +4,6 @@ HTTP HTTP HEAD -G -notxml # @@ -30,7 +29,7 @@ http HTTP with -d and -G and -I --d "foo=moo&moo=poo" http://%HOSTIP:%HTTPPORT/%TESTNUMBER -G -I http://%HOSTIP:%HTTPPORT/%TESTNUMBER +-d "foo=moo%AMPmoo=poo" http://%HOSTIP:%HTTPPORT/%TESTNUMBER -G -I http://%HOSTIP:%HTTPPORT/%TESTNUMBER @@ -38,12 +37,12 @@ HTTP with -d and -G and -I # Verify data after the test has been "shot" -HEAD /%TESTNUMBER?foo=moo&moo=poo HTTP/1.1 +HEAD /%TESTNUMBER?foo=moo%AMPmoo=poo HTTP/1.1 Host: %HOSTIP:%HTTPPORT User-Agent: curl/%VERSION Accept: */* -HEAD /%TESTNUMBER?foo=moo&moo=poo HTTP/1.1 +HEAD /%TESTNUMBER?foo=moo%AMPmoo=poo HTTP/1.1 Host: %HOSTIP:%HTTPPORT User-Agent: curl/%VERSION Accept: */* diff --git a/tests/data/test568 b/tests/data/test568 index a2438916d46e..6c8eaade7389 100644 --- a/tests/data/test568 +++ b/tests/data/test568 @@ -5,7 +5,6 @@ RTSP ANNOUNCE -notxml @@ -107,7 +106,7 @@ CSeq: 3 Content-Type: posty goodness Content-Length: 35 -postyfield=postystuff&project=curl +postyfield=postystuff%AMPproject=curl OPTIONS rtsp://%HOSTIP:%RTSPPORT/%TESTNUMBER0004 RTSP/1.0 CSeq: 4 diff --git a/tests/data/test733 b/tests/data/test733 index 0bf953cca210..8235e7199973 100644 --- a/tests/data/test733 +++ b/tests/data/test733 @@ -2,7 +2,6 @@ IPFS -notxml @@ -38,7 +37,7 @@ http IPFS with path and query args ---ipfs-gateway http://%HOSTIP:%HTTPPORT "ipfs://bafybeidecnvkrygux6uoukouzps5ofkeevoqland7kopseiod6pzqvjg7u/a/b?foo=bar&aaa=bbb" +--ipfs-gateway http://%HOSTIP:%HTTPPORT "ipfs://bafybeidecnvkrygux6uoukouzps5ofkeevoqland7kopseiod6pzqvjg7u/a/b?foo=bar%AMPaaa=bbb" @@ -46,7 +45,7 @@ IPFS with path and query args # Verify data after the test has been "shot" -GET /ipfs/bafybeidecnvkrygux6uoukouzps5ofkeevoqland7kopseiod6pzqvjg7u/a/b?foo=bar&aaa=bbb HTTP/1.1 +GET /ipfs/bafybeidecnvkrygux6uoukouzps5ofkeevoqland7kopseiod6pzqvjg7u/a/b?foo=bar%AMPaaa=bbb HTTP/1.1 Host: %HOSTIP:%HTTPPORT User-Agent: curl/%VERSION Accept: */* diff --git a/tests/data/test734 b/tests/data/test734 index 01107fbf6b3d..6c87bd1eb49c 100644 --- a/tests/data/test734 +++ b/tests/data/test734 @@ -2,7 +2,6 @@ IPFS -notxml @@ -38,7 +37,7 @@ http IPFS with path, query args and gateway with path ---ipfs-gateway http://%HOSTIP:%HTTPPORT/some/path "ipfs://bafybeidecnvkrygux6uoukouzps5ofkeevoqland7kopseiod6pzqvjg7u/a/b?foo=bar&aaa=bbb" +--ipfs-gateway http://%HOSTIP:%HTTPPORT/some/path "ipfs://bafybeidecnvkrygux6uoukouzps5ofkeevoqland7kopseiod6pzqvjg7u/a/b?foo=bar%AMPaaa=bbb" @@ -46,7 +45,7 @@ IPFS with path, query args and gateway with path # Verify data after the test has been "shot" -GET /some/path/ipfs/bafybeidecnvkrygux6uoukouzps5ofkeevoqland7kopseiod6pzqvjg7u/a/b?foo=bar&aaa=bbb HTTP/1.1 +GET /some/path/ipfs/bafybeidecnvkrygux6uoukouzps5ofkeevoqland7kopseiod6pzqvjg7u/a/b?foo=bar%AMPaaa=bbb HTTP/1.1 Host: %HOSTIP:%HTTPPORT User-Agent: curl/%VERSION Accept: */* diff --git a/tests/data/test735 b/tests/data/test735 index 574d8bd492ba..d23a0fe6d970 100644 --- a/tests/data/test735 +++ b/tests/data/test735 @@ -2,7 +2,6 @@ IPFS -notxml @@ -38,7 +37,7 @@ http IPNS with path, query args and gateway with path ---ipfs-gateway http://%HOSTIP:%HTTPPORT/some/path "ipns://fancy.tld/a/b?foo=bar&aaa=bbb" +--ipfs-gateway http://%HOSTIP:%HTTPPORT/some/path "ipns://fancy.tld/a/b?foo=bar%AMPaaa=bbb" @@ -46,7 +45,7 @@ IPNS with path, query args and gateway with path # Verify data after the test has been "shot" -GET /some/path/ipns/fancy.tld/a/b?foo=bar&aaa=bbb HTTP/1.1 +GET /some/path/ipns/fancy.tld/a/b?foo=bar%AMPaaa=bbb HTTP/1.1 Host: %HOSTIP:%HTTPPORT User-Agent: curl/%VERSION Accept: */* diff --git a/tests/data/test739 b/tests/data/test739 index 3e712f513e39..b51afb5a412c 100644 --- a/tests/data/test739 +++ b/tests/data/test739 @@ -2,7 +2,6 @@ IPFS -notxml @@ -24,7 +23,7 @@ http IPNS path and query args for gateway and IPFS URL (malformed gateway URL) ---ipfs-gateway "http://%HOSTIP:%HTTPPORT/some/path?biz=baz" "ipns://fancy.tld/a/b?foo=bar&aaa=bbb" +--ipfs-gateway "http://%HOSTIP:%HTTPPORT/some/path?biz=baz" "ipns://fancy.tld/a/b?foo=bar%AMPaaa=bbb" From 7109b427fbf0711ba1a6e22f0ff565f93fbeb9ea Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Wed, 10 Dec 2025 22:57:58 +0100 Subject: [PATCH 281/415] tests/data: replace `<` with `%LT` For XML-compliance. Closes #19924 --- tests/data/test1189 | 5 ++--- tests/data/test163 | 3 +-- tests/data/test39 | 5 ++--- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/tests/data/test1189 b/tests/data/test1189 index b5574cef507d..8fdb3d9ac193 100644 --- a/tests/data/test1189 +++ b/tests/data/test1189 @@ -3,7 +3,6 @@ HTTP HTTP FORMPOST -notxml # Server-side @@ -34,7 +33,7 @@ http://%HOSTIP:%HTTPPORT/we/want/%TESTNUMBER --form-escape -F name=daniel -F tool=curl --form-string "str1=@literal" ---form-string "str2= HTTP HTTP POST -notxml @@ -31,7 +30,7 @@ http HTTP multipart formpost with contents from a file -http://%HOSTIP:%HTTPPORT/we/want/%TESTNUMBER -F "name=<%LOGDIR/field%TESTNUMBER" -F tool=curl +http://%HOSTIP:%HTTPPORT/we/want/%TESTNUMBER -F "name=%LT%LOGDIR/field%TESTNUMBER" -F tool=curl # We create this file before the command is invoked! diff --git a/tests/data/test39 b/tests/data/test39 index b0062543378c..c1c8ab6aca3d 100644 --- a/tests/data/test39 +++ b/tests/data/test39 @@ -3,7 +3,6 @@ HTTP HTTP FORMPOST -notxml # Server-side @@ -34,7 +33,7 @@ http://%HOSTIP:%HTTPPORT/we/want/%TESTNUMBER -F name=daniel -F tool=curl --form-string "str1=@literal" ---form-string "str2= Date: Wed, 10 Dec 2025 23:07:50 +0100 Subject: [PATCH 282/415] tests/data: replace `<`, `>` with `%LT`, `%GT` For XML-compliance. Closes #19925 --- tests/data/test1683 | 5 ++--- tests/data/test320 | 5 ++--- tests/data/test646 | 7 +++---- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/tests/data/test1683 b/tests/data/test1683 index 47d280cd14a1..dd0c80528a43 100644 --- a/tests/data/test1683 +++ b/tests/data/test1683 @@ -4,7 +4,6 @@ HTTP HTTP GET --no-clobber -notxml @@ -40,7 +39,7 @@ http://%HOSTIP:%HTTPPORT/%TESTNUMBER -o %LOGDIR/exist%TESTNUMBER --no-clobber to stay the same -%PERL -e 'for my $i ((1..100)) { my $filename = "%LOGDIR/exist%TESTNUMBER.$i"; open(FH, ">", $filename) or die $!; print FH "to stay the same" ; close(FH) }' +%PERL -e 'for my $i ((1..100)) { my $filename = "%LOGDIR/exist%TESTNUMBER.$i"; open(FH, "%GT", $filename) or die $!; print FH "to stay the same" ; close(FH) }' @@ -54,7 +53,7 @@ to stay the same to stay the same -%PERL -e 'for my $i ((1..100)) { my $filename = "%LOGDIR/exist%TESTNUMBER.$i"; open(FH, "<", $filename) or die $!; ( eq "to stay the same" and eq "") or die "incorrect $filename" ; close(FH) }' +%PERL -e 'for my $i ((1..100)) { my $filename = "%LOGDIR/exist%TESTNUMBER.$i"; open(FH, "%LT", $filename) or die $!; (%LTFH%GT eq "to stay the same" and %LTFH%GT eq "") or die "incorrect $filename" ; close(FH) }' diff --git a/tests/data/test320 b/tests/data/test320 index ca68674571f4..e046b4db45ca 100644 --- a/tests/data/test320 +++ b/tests/data/test320 @@ -4,7 +4,6 @@ HTTPS HTTP GET TLS-SRP -notxml @@ -43,11 +42,11 @@ Accept: */* -s/^

Connected as user 'jsmith'.*/FINE/ +s/^%LTp%GTConnected as user 'jsmith'.*/FINE/ s/Protocol version:.*[0-9]// s/GNUTLS/GnuTLS/ s/(AES[-_])\d\d\d([-_]CBC)/$1NNN$2/ -s/^<.*\n// +s/^%LT.*\n// s/^\n// diff --git a/tests/data/test646 b/tests/data/test646 index 39fafa573ce5..0ded08bcace2 100644 --- a/tests/data/test646 +++ b/tests/data/test646 @@ -3,7 +3,6 @@ SMTP MULTIPART -notxml @@ -35,10 +34,10 @@ smtp://%HOSTIP:%SMTPPORT/%TESTNUMBER --mail-rcpt recipient@example.com --mail-from sender@example.com -F "=(;type=multipart/alternative" --F "= This is the html version;headers=X-test1: this is a header;type=text/html;headers=X-test2: this is another header " +-F "= %LTbody%GTThis is the html version%LT/body%GT;headers=X-test1: this is a header;type=text/html;headers=X-test2: this is another header " -F "=This is the plain text version;headers=@%LOGDIR/headers%TESTNUMBER" -F "=)" --F "=@%LOGDIR/test%TESTNUMBER.txt;headers=<%LOGDIR/headers%TESTNUMBER" +-F "=@%LOGDIR/test%TESTNUMBER.txt;headers=%LT%LOGDIR/headers%TESTNUMBER" -H "From: different" -H "To: another" -H "Reply-To: %LTfollowup@example.com%GT" @@ -88,7 +87,7 @@ Content-Transfer-Encoding: 8bit%CR X-test1: this is a header%CR X-test2: this is another header%CR %CR -This is the html version%CR +%LTbody%GTThis is the html version%LT/body%GT%CR ------------------------------%CR X-fileheader1: This is a header from a file%CR X-fileheader2: This is #a folded header%CR From 319298484f212bfd6a673fbbab21c7afcf6259ad Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Wed, 10 Dec 2025 23:21:10 +0100 Subject: [PATCH 283/415] runtests: add support for single-quoted attributes, use it With this, all test data files are XML-compliant. Also: - test1158, test1186: use single quotes for the test filename attribute containing a double quote. For XML-compliance. - drop support for unquoted attributes. For XML-compliance. Closes #19926 --- tests/data/test1158 | 3 +-- tests/data/test1186 | 3 +-- tests/getpart.pm | 6 ++++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/data/test1158 b/tests/data/test1158 index a791c6fd4ccf..befecd763bdb 100644 --- a/tests/data/test1158 +++ b/tests/data/test1158 @@ -3,7 +3,6 @@ HTTP HTTP FORMPOST -notxml # Server-side @@ -37,7 +36,7 @@ http://%HOSTIP:%HTTPPORT/we/want/%TESTNUMBER -F 'file3=@"%LOGDIR/test%TESTNUMBER\".txt";type=m/f,"%LOGDIR/test%TESTNUMBER\".txt"' # We create this file before the command is invoked! - + foo bar This is a bar foo bar diff --git a/tests/data/test1186 b/tests/data/test1186 index 7a8b69486b7d..439dbebcf54e 100644 --- a/tests/data/test1186 +++ b/tests/data/test1186 @@ -3,7 +3,6 @@ HTTP HTTP FORMPOST -notxml # Server-side @@ -37,7 +36,7 @@ http://%HOSTIP:%HTTPPORT/we/want/%TESTNUMBER --form-escape -F 'file3=@"%LOGDIR/test%TESTNUMBER\".txt";type=m/f,"%LOGDIR/test%TESTNUMBER\".txt"' # We create this file before the command is invoked! - + foo bar This is a bar foo bar diff --git a/tests/getpart.pm b/tests/getpart.pm index 7fa703d0b178..69b810db5c47 100644 --- a/tests/getpart.pm +++ b/tests/getpart.pm @@ -76,9 +76,10 @@ sub testcaseattr { for(@xml) { if(($_ =~ /^ *\]*)/)) { my $attr=$1; - while($attr =~ s/ *([^=]*)= *(\"([^\"]*)\"|([^\> ]*))//) { + while($attr =~ s/ *([^=]*)= *(\"([^\"]*)\"|\'([^\']*)\')//) { my ($var, $cont)=($1, $2); $cont =~ s/^\"(.*)\"$/$1/; + $cont =~ s/^\'(.*)\'$/$1/; $hash{$var}=$cont; } } @@ -108,9 +109,10 @@ sub getpartattr { $inside++; my $attr=$1; - while($attr =~ s/ *([^=]*)= *(\"([^\"]*)\"|([^\> ]*))//) { + while($attr =~ s/ *([^=]*)= *(\"([^\"]*)\"|\'([^\']*)\')//) { my ($var, $cont)=($1, $2); $cont =~ s/^\"(.*)\"$/$1/; + $cont =~ s/^\'(.*)\'$/$1/; $hash{$var}=$cont; } last; From bfe6eb1c06f295a45c4d2c9c7aa8f09895706313 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Wed, 10 Dec 2025 23:44:43 +0100 Subject: [PATCH 284/415] runtests: drop `notxml` keyword, verify all test data files as XML Follow-up to 7f3731ce142c1d74023abad183cc8ce0fd527fab #19595 Closes #19927 --- .github/workflows/checksrc.yml | 4 ++-- docs/tests/FILEFORMAT.md | 5 ----- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/.github/workflows/checksrc.yml b/.github/workflows/checksrc.yml index 1b471e50cfe7..8552ad4c7950 100644 --- a/.github/workflows/checksrc.yml +++ b/.github/workflows/checksrc.yml @@ -139,8 +139,8 @@ jobs: - name: 'check' run: | { - git grep -z -i -l -E '^<\?xml' || true - git grep -z -L -F 'notxml' 'tests/data/test*' || true + git grep -i -l -E '^<\?xml' -z || true + git ls-files 'tests/data/test*' -z || true } | xargs -0 -r xmllint >/dev/null miscchecks: diff --git a/docs/tests/FILEFORMAT.md b/docs/tests/FILEFORMAT.md index c655a4d863d3..84188e9dd9dc 100644 --- a/docs/tests/FILEFORMAT.md +++ b/docs/tests/FILEFORMAT.md @@ -257,11 +257,6 @@ often run on overloaded machines with unpredictable timing. Tests using non-7-bit-ASCII characters must provide them with `%hex[]` or similar. -In most cases test files comply with the XML format, and pass xmllint cleanly. -If the data file uses the `&` character, or has other, non-compliant content, -and making it XML-compliant is not possible or unpractical, use the `notxml` -keyword to exclude it from linter checks. - ## `` ### `` From bb134bba293ffd2128a43d17137e1fb2a84bdd47 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 11 Dec 2025 09:11:45 +0100 Subject: [PATCH 285/415] test3214: allow a larger struct Curl_easy In my local build it is now 5840 bytes. Add a 10 byte margin. Closes #19932 --- tests/unit/unit3214.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/unit3214.c b/tests/unit/unit3214.c index d992a35dc0db..ae03d5410ca9 100644 --- a/tests/unit/unit3214.c +++ b/tests/unit/unit3214.c @@ -41,7 +41,7 @@ static void checksize(const char *name, size_t size, size_t allowed) } /* the maximum sizes we allow specific structs to grow to */ -#define MAX_CURL_EASY 5800 +#define MAX_CURL_EASY 5850 #define MAX_CONNECTDATA 1300 #define MAX_CURL_MULTI 850 #define MAX_CURL_HTTPPOST 112 From 1a822275d333dc6da6043497160fd04c8fa48640 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 10 Dec 2025 11:40:47 +0100 Subject: [PATCH 286/415] curl_sasl: if redirected, require permission to use bearer Closes #19933 --- lib/curl_sasl.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/curl_sasl.c b/lib/curl_sasl.c index 3e4bafc19ae4..b93bafbefac3 100644 --- a/lib/curl_sasl.c +++ b/lib/curl_sasl.c @@ -452,7 +452,9 @@ static bool sasl_choose_ntlm(struct Curl_easy *data, struct sasl_ctx *sctx) static bool sasl_choose_oauth(struct Curl_easy *data, struct sasl_ctx *sctx) { - const char *oauth_bearer = data->set.str[STRING_BEARER]; + const char *oauth_bearer = + (!data->state.this_is_a_follow || data->set.allow_auth_to_other_hosts) ? + data->set.str[STRING_BEARER] : NULL; if(sctx->user && oauth_bearer && (sctx->enabledmechs & SASL_MECH_OAUTHBEARER)) { @@ -477,7 +479,9 @@ static bool sasl_choose_oauth(struct Curl_easy *data, struct sasl_ctx *sctx) static bool sasl_choose_oauth2(struct Curl_easy *data, struct sasl_ctx *sctx) { - const char *oauth_bearer = data->set.str[STRING_BEARER]; + const char *oauth_bearer = + (!data->state.this_is_a_follow || data->set.allow_auth_to_other_hosts) ? + data->set.str[STRING_BEARER] : NULL; if(sctx->user && oauth_bearer && (sctx->enabledmechs & SASL_MECH_XOAUTH2)) { From f72c3779144955def08c493ed7aef3661b0bb43e Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 10 Dec 2025 10:49:54 +0100 Subject: [PATCH 287/415] tests: verify setting bearer and doing redirects Test 778, 779 and 795 --- tests/data/Makefile.am | 6 +-- tests/data/test778 | 97 ++++++++++++++++++++++++++++++++++++++++++ tests/data/test779 | 76 +++++++++++++++++++++++++++++++++ tests/data/test795 | 74 ++++++++++++++++++++++++++++++++ 4 files changed, 250 insertions(+), 3 deletions(-) create mode 100644 tests/data/test778 create mode 100644 tests/data/test779 create mode 100644 tests/data/test795 diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am index 63cc4729f314..7faa27da3545 100644 --- a/tests/data/Makefile.am +++ b/tests/data/Makefile.am @@ -110,9 +110,9 @@ test736 test737 test738 test739 test740 test741 test742 test743 test744 \ test745 test746 test747 test748 test749 test750 test751 test752 test753 \ test754 test755 test756 test757 test758 test759 test760 test761 test762 \ test763 test764 test765 test766 test767 test768 test769 test770 test771 \ -test772 test773 test774 test775 test776 test777 \ -test780 test781 test782 test783 test784 test785 test786 test787 test788 \ -test789 test790 test791 test792 test793 test794 test796 test797 \ +test772 test773 test774 test775 test776 test777 test778 test779 test780 \ +test781 test782 test783 test784 test785 test786 test787 test788 test789 \ +test790 test791 test792 test793 test794 test795 test796 test797 \ \ test799 test800 test801 test802 test803 test804 test805 test806 test807 \ test808 test809 test810 test811 test812 test813 test814 test815 test816 \ diff --git a/tests/data/test778 b/tests/data/test778 new file mode 100644 index 000000000000..84e84b8cd3b8 --- /dev/null +++ b/tests/data/test778 @@ -0,0 +1,97 @@ + + + +HTTP +HTTP proxy +HTTP Basic auth +HTTP proxy Basic auth +followlocation +oauth2-bearer + + +# +# Server-side + + +HTTP/1.1 302 OK +Date: Tue, 09 Nov 2010 14:49:00 GMT +Server: test-server/fake swsclose +Content-Type: text/html +Funny-head: yesyes +Location: http://goto.second.host.now/%TESTNUMBER0002 +Content-Length: 8 +Connection: close + +contents + + +HTTP/1.1 200 OK +Date: Tue, 09 Nov 2010 14:49:00 GMT +Server: test-server/fake swsclose +Content-Type: text/html +Funny-head: yesyes +Content-Length: 9 + +contents + + + +HTTP/1.1 302 OK +Date: Tue, 09 Nov 2010 14:49:00 GMT +Server: test-server/fake swsclose +Content-Type: text/html +Funny-head: yesyes +Location: http://goto.second.host.now/%TESTNUMBER0002 +Content-Length: 8 +Connection: close + +HTTP/1.1 200 OK +Date: Tue, 09 Nov 2010 14:49:00 GMT +Server: test-server/fake swsclose +Content-Type: text/html +Funny-head: yesyes +Content-Length: 9 + +contents + + + +# +# Client-side + + +http + + +HTTP --oauth2-bearer redirect to new host (not passed on) + + +http://first.host.it.is/we/want/that/page/%TESTNUMBER -x %HOSTIP:%HTTPPORT --oauth2-bearer s3cr3t --proxy-user testing:this --location + + +proxy + + + +# +# Verify data after the test has been "shot" + + +GET http://first.host.it.is/we/want/that/page/%TESTNUMBER HTTP/1.1 +Host: first.host.it.is +Proxy-Authorization: Basic %b64[testing:this]b64% +Authorization: Bearer s3cr3t +User-Agent: curl/%VERSION +Accept: */* +Proxy-Connection: Keep-Alive + +GET http://goto.second.host.now/%TESTNUMBER0002 HTTP/1.1 +Host: goto.second.host.now +Proxy-Authorization: Basic %b64[testing:this]b64% +User-Agent: curl/%VERSION +Accept: */* +Proxy-Connection: Keep-Alive + + + + diff --git a/tests/data/test779 b/tests/data/test779 new file mode 100644 index 000000000000..f833c3782c62 --- /dev/null +++ b/tests/data/test779 @@ -0,0 +1,76 @@ + + + +HTTP +IMAP +oauth2-bearer +followlocation + + +# +# Server-side + + +AUTH XOAUTH2 +REPLY AUTHENTICATE + +REPLY dXNlcj12AWF1dGg9QmVhcmVyIHMzY3IzdAEB B002 OK AUTHENTICATE completed + + +HTTP/1.1 302 OK +Date: Tue, 09 Nov 2010 14:49:00 GMT +Server: test-server/fake swsclose +Content-Type: text/html +Funny-head: yesyes +Location: imap://v@host:%IMAPPORT/%TESTNUMBER0002/ +Content-Length: 8 +Connection: close + +contents + + + +HTTP/1.1 302 OK +Date: Tue, 09 Nov 2010 14:49:00 GMT +Server: test-server/fake swsclose +Content-Type: text/html +Funny-head: yesyes +Location: imap://v@host:%IMAPPORT/%TESTNUMBER0002/ +Content-Length: 8 +Connection: close + + + + +# +# Client-side + + +http +imap + + +HTTP --oauth2-bearer redirects to IMAP + + +http://%HOSTIP:%HTTPPORT/page/%TESTNUMBER --oauth2-bearer s3cr3t --location --proto-redir imap --resolve host:%IMAPPORT:%HOSTIP + + + +# +# Verify data after the test has been "shot" + + +GET /page/%TESTNUMBER HTTP/1.1 +Host: %HOSTIP:%HTTPPORT +Authorization: Bearer s3cr3t +User-Agent: curl/%VERSION +Accept: */* + +B001 CAPABILITY + +# curl: (67) Login denied + +67 + + + diff --git a/tests/data/test795 b/tests/data/test795 new file mode 100644 index 000000000000..ab33ea5be6fa --- /dev/null +++ b/tests/data/test795 @@ -0,0 +1,74 @@ + + + +HTTP +IMAP +followlocation + + +# +# Server-side + + +AUTH PLAIN +CAPA SASL-IR +REPLY AUTHENTICATE B002 OK AUTHENTICATE completed + + +HTTP/1.1 302 OK +Date: Tue, 09 Nov 2010 14:49:00 GMT +Server: test-server/fake swsclose +Content-Type: text/html +Funny-head: yesyes +Location: imap://v@host:%IMAPPORT/%TESTNUMBER0002/ +Content-Length: 8 +Connection: close + +contents + + + +HTTP/1.1 302 OK +Date: Tue, 09 Nov 2010 14:49:00 GMT +Server: test-server/fake swsclose +Content-Type: text/html +Funny-head: yesyes +Location: imap://v@host:%IMAPPORT/%TESTNUMBER0002/ +Content-Length: 8 +Connection: close + + + + +# +# Client-side + + +http +imap + + +HTTP with credentials redirects to IMAP + + +http://@%HOSTIP:%HTTPPORT/page/%TESTNUMBER -u user:secret --location --proto-redir imap --resolve host:%IMAPPORT:%HOSTIP + + + +# +# Verify data after the test has been "shot" + + +GET /page/%TESTNUMBER HTTP/1.1 +Host: %HOSTIP:%HTTPPORT +Authorization: Basic %b64[user:secret]b64% +User-Agent: curl/%VERSION +Accept: */* + +B001 CAPABILITY +B002 AUTHENTICATE PLAIN AHYA +B003 LIST "%TESTNUMBER0002" * +B004 LOGOUT + + + From 869248cc3e53f0f0e183e057e7c95ffa03ef84c7 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Thu, 11 Dec 2025 01:43:21 +0100 Subject: [PATCH 288/415] autotools: drop reference to deleted `CURL_CHECK_CURLDEBUG` The referred function has been deleted earlier. Also: - drop commented reference to deleted `CURL_CHECK_OPTION_THREADS`. 0d4fdbf15d8eec908b3e63b606f112b18a63015e #16054 Follow-up to 96a1a05f662677af64b16d862c4126ed52ea4b30 #14096 Closes #19928 --- m4/curl-confopts.m4 | 2 -- 1 file changed, 2 deletions(-) diff --git a/m4/curl-confopts.m4 b/m4/curl-confopts.m4 index a54037369267..ff1b8b744ed3 100644 --- a/m4/curl-confopts.m4 +++ b/m4/curl-confopts.m4 @@ -73,7 +73,6 @@ dnl --enable-ares or --disable-ares, and dnl set shell variable want_ares as appropriate. AC_DEFUN([CURL_CHECK_OPTION_ARES], [ -dnl AC_BEFORE([$0],[CURL_CHECK_OPTION_THREADS])dnl AC_BEFORE([$0],[CURL_CHECK_LIB_ARES])dnl AC_MSG_CHECKING([whether to enable c-ares for DNS lookups]) OPT_ARES="default" @@ -109,7 +108,6 @@ dnl --enable-curldebug or --disable-curldebug, and set dnl shell variable want_curldebug value as appropriate. AC_DEFUN([CURL_CHECK_OPTION_CURLDEBUG], [ - AC_BEFORE([$0],[CURL_CHECK_CURLDEBUG])dnl AC_MSG_CHECKING([whether to enable curl debug memory tracking]) OPT_CURLDEBUG_BUILD="default" AC_ARG_ENABLE(curldebug, From 421f931e7aafb9b64c0b15555ec8d828c8e62948 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Thu, 11 Dec 2025 01:52:58 +0100 Subject: [PATCH 289/415] test1165: drop reference to deleted `CURL_DISABLE_TESTS` Follow-up to bf823397bad09791277e983e44e8f0edc3c089b2 #16134 Closes #19929 --- tests/test1165.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test1165.pl b/tests/test1165.pl index 049b764647fd..49806c66ca31 100755 --- a/tests/test1165.pl +++ b/tests/test1165.pl @@ -70,7 +70,7 @@ sub scanconf_cmake { while() { if(/(CURL_DISABLE_[A-Z0-9_]+)/g) { my ($sym)=($1); - if(not $sym =~ /^(CURL_DISABLE_INSTALL|CURL_DISABLE_TESTS|CURL_DISABLE_SRP)$/) { + if(not $sym =~ /^(CURL_DISABLE_INSTALL|CURL_DISABLE_SRP)$/) { $hashr->{$sym} = 1; } } From 8ff5222b4e2b4c18c941fde483b53d1be2674604 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Thu, 11 Dec 2025 02:13:46 +0100 Subject: [PATCH 290/415] docs: fold long lines Also: - replace a 'will' found by badwords. - drop duplicate empty lines. Closes #19930 --- docs/ALTSVC.md | 3 +- docs/internals/BUFQ.md | 2 - docs/internals/CLIENT-READERS.md | 139 ++++++++++++++++++++------- docs/internals/CLIENT-WRITERS.md | 93 +++++++++++++----- docs/internals/CONNECTION-FILTERS.md | 11 ++- docs/internals/MQTT.md | 12 +-- docs/internals/SCORECARD.md | 45 +++++---- docs/internals/TLS-SESSIONS.md | 1 - docs/internals/UINT_SETS.md | 124 +++++++++++++----------- docs/tests/HTTP.md | 90 +++++++++++++---- 10 files changed, 352 insertions(+), 168 deletions(-) diff --git a/docs/ALTSVC.md b/docs/ALTSVC.md index bcdf5650743b..24b961a3fb4a 100644 --- a/docs/ALTSVC.md +++ b/docs/ALTSVC.md @@ -35,7 +35,8 @@ space separated fields. 4. The ALPN id for the destination host 5. The hostname for the destination host 6. The port number for the destination host -7. The expiration date and time of this entry within double quotes. The date format is "YYYYMMDD HH:MM:SS" and the time zone is GMT. +7. The expiration date and time of this entry within double quotes. + The date format is "YYYYMMDD HH:MM:SS" and the time zone is GMT. 8. Boolean (1 or 0) if "persist" was set for this entry 9. Integer priority value (not currently used) diff --git a/docs/internals/BUFQ.md b/docs/internals/BUFQ.md index 6028711d2c50..8136d588f6e9 100644 --- a/docs/internals/BUFQ.md +++ b/docs/internals/BUFQ.md @@ -14,7 +14,6 @@ to and read from. It manages read and write positions and has a maximum size. Its basic read/write functions have a similar signature and return code handling as many internal curl read and write ones. - ``` ssize_t Curl_bufq_write(struct bufq *q, const unsigned char *buf, size_t len, CURLcode *err); @@ -150,7 +149,6 @@ reports **full**, but one can **still** write. This option is necessary, if partial writes need to be avoided. It means that you need other checks to keep the `bufq` from growing ever larger and larger. - ## pools A `struct bufc_pool` may be used to create chunks for a `bufq` and keep spare diff --git a/docs/internals/CLIENT-READERS.md b/docs/internals/CLIENT-READERS.md index 35caaa6bfc6d..bb94bba95f11 100644 --- a/docs/internals/CLIENT-READERS.md +++ b/docs/internals/CLIENT-READERS.md @@ -6,26 +6,41 @@ SPDX-License-Identifier: curl # curl client readers -Client readers is a design in the internals of libcurl, not visible in its public API. They were started -in curl v8.7.0. This document describes the concepts, its high level implementation and the motivations. +Client readers is a design in the internals of libcurl, not visible in its +public API. They were started in curl v8.7.0. This document describes +the concepts, its high level implementation and the motivations. ## Naming -`libcurl` operates between clients and servers. A *client* is the application using libcurl, like the command line tool `curl` itself. Data to be uploaded to a server is **read** from the client and **sent** to the server, the servers response is **received** by `libcurl` and then **written** to the client. +`libcurl` operates between clients and servers. A *client* is the application +using libcurl, like the command line tool `curl` itself. Data to be uploaded +to a server is **read** from the client and **sent** to the server, the servers +response is **received** by `libcurl` and then **written** to the client. -With this naming established, client readers are concerned with providing data from the application to the server. Applications register callbacks via `CURLOPT_READFUNCTION`, data via `CURLOPT_POSTFIELDS` and other options to be used by `libcurl` when the request is send. +With this naming established, client readers are concerned with providing data +from the application to the server. Applications register callbacks via +`CURLOPT_READFUNCTION`, data via `CURLOPT_POSTFIELDS` and other options to be +used by `libcurl` when the request is send. ## Invoking -The transfer loop that sends and receives, is using `Curl_client_read()` to get more data to send for a transfer. If no specific reader has been installed yet, the default one that uses `CURLOPT_READFUNCTION` is added. The prototype is +The transfer loop that sends and receives, is using `Curl_client_read()` to get +more data to send for a transfer. If no specific reader has been installed yet, +the default one that uses `CURLOPT_READFUNCTION` is added. The prototype is ``` CURLcode Curl_client_read(struct Curl_easy *data, char *buf, size_t blen, size_t *nread, bool *eos); ``` -The arguments are the transfer to read for, a buffer to hold the read data, its length, the actual number of bytes placed into the buffer and the `eos` (*end of stream*) flag indicating that no more data is available. The `eos` flag may be set for a read amount, if that amount was the last. That way curl can avoid to read an additional time. +The arguments are the transfer to read for, a buffer to hold the read data, its +length, the actual number of bytes placed into the buffer and the `eos` (*end of +stream*) flag indicating that no more data is available. The `eos` flag may be +set for a read amount, if that amount was the last. That way curl can avoid to +read an additional time. -The implementation of `Curl_client_read()` uses a chain of *client reader* instances to get the data. This is similar to the design of *client writers*. The chain of readers allows processing of the data to send. +The implementation of `Curl_client_read()` uses a chain of *client reader* +instances to get the data. This is similar to the design of *client writers*. +The chain of readers allows processing of the data to send. The definition of a reader is: @@ -51,11 +66,17 @@ struct Curl_creader { }; ``` -`Curl_creader` is a reader instance with a `next` pointer to form the chain. It as a type `crt` which provides the implementation. The main callback is `do_read()` which provides the data to the caller. The others are for setup and tear down. `needs_rewind()` is explained further below. +`Curl_creader` is a reader instance with a `next` pointer to form the chain. +It as a type `crt` which provides the implementation. The main callback is +`do_read()` which provides the data to the caller. The others are for setup +and tear down. `needs_rewind()` is explained further below. ## Phases and Ordering -Since client readers may transform the data being read through the chain, the order in which they are called is relevant for the outcome. When a reader is created, it gets the `phase` property in which it operates. Reader phases are defined like: +Since client readers may transform the data being read through the chain, +the order in which they are called is relevant for the outcome. When a reader +is created, it gets the `phase` property in which it operates. Reader phases +are defined like: ``` typedef enum { @@ -67,65 +88,115 @@ typedef enum { } Curl_creader_phase; ``` -If a reader for phase `PROTOCOL` is added to the chain, it is always added *after* any `NET` or `TRANSFER_ENCODE` readers and *before* and `CONTENT_ENCODE` and `CLIENT` readers. If there is already a reader for the same phase, the new reader is added before the existing one(s). +If a reader for phase `PROTOCOL` is added to the chain, it is always added +*after* any `NET` or `TRANSFER_ENCODE` readers and *before* and +`CONTENT_ENCODE` and `CLIENT` readers. If there is already a reader for the +same phase, the new reader is added before the existing one(s). ### Example: `chunked` reader -In `http_chunks.c` a client reader for chunked uploads is implemented. This one operates at phase `CURL_CR_TRANSFER_ENCODE`. Any data coming from the reader "below" has the HTTP/1.1 chunk handling applied and returned to the caller. +In `http_chunks.c` a client reader for chunked uploads is implemented. This +one operates at phase `CURL_CR_TRANSFER_ENCODE`. Any data coming from the +reader "below" has the HTTP/1.1 chunk handling applied and returned to the +caller. -When this reader sees an `eos` from below, it generates the terminal chunk, adding trailers if provided by the application. When that last chunk is fully returned, it also sets `eos` to the caller. +When this reader sees an `eos` from below, it generates the terminal chunk, +adding trailers if provided by the application. When that last chunk is fully +returned, it also sets `eos` to the caller. ### Example: `lineconv` reader -In `sendf.c` a client reader that does line-end conversions is implemented. It operates at `CURL_CR_CONTENT_ENCODE` and converts any "\n" to "\r\n". This is used for FTP ASCII uploads or when the general `crlf` options has been set. +In `sendf.c` a client reader that does line-end conversions is implemented. It +operates at `CURL_CR_CONTENT_ENCODE` and converts any "\n" to "\r\n". This is +used for FTP ASCII uploads or when the general `crlf` options has been set. ### Example: `null` reader -Implemented in `sendf.c` for phase `CURL_CR_CLIENT`, this reader has the simple job of providing transfer bytes of length 0 to the caller, immediately indicating an `eos`. This reader is installed by HTTP for all GET/HEAD requests and when authentication is being negotiated. +Implemented in `sendf.c` for phase `CURL_CR_CLIENT`, this reader has the +simple job of providing transfer bytes of length 0 to the caller, immediately +indicating an `eos`. This reader is installed by HTTP for all GET/HEAD +requests and when authentication is being negotiated. ### Example: `buf` reader -Implemented in `sendf.c` for phase `CURL_CR_CLIENT`, this reader get a buffer pointer and a length and provides exactly these bytes. This one is used in HTTP for sending `postfields` provided by the application. +Implemented in `sendf.c` for phase `CURL_CR_CLIENT`, this reader get a buffer +pointer and a length and provides exactly these bytes. This one is used in +HTTP for sending `postfields` provided by the application. ## Request retries -Sometimes it is necessary to send a request with client data again. Transfer handling can inquire via `Curl_client_read_needs_rewind()` if a rewind (e.g. a reset of the client data) is necessary. This asks all installed readers if they need it and give `FALSE` of none does. +Sometimes it is necessary to send a request with client data again. Transfer +handling can inquire via `Curl_client_read_needs_rewind()` if a rewind (e.g. a +reset of the client data) is necessary. This asks all installed readers if +they need it and give `FALSE` of none does. ## Upload Size -Many protocols need to know the amount of bytes delivered by the client readers in advance. They may invoke `Curl_creader_total_length(data)` to retrieve that. However, not all reader chains know the exact value beforehand. In that case, the call returns `-1` for "unknown". +Many protocols need to know the amount of bytes delivered by the client +readers in advance. They may invoke `Curl_creader_total_length(data)` to +retrieve that. However, not all reader chains know the exact value beforehand. +In that case, the call returns `-1` for "unknown". -Even if the length of the "raw" data is known, the length that is send may not. Example: with option `--crlf` the uploaded content undergoes line-end conversion. The line converting reader does not know in advance how many newlines it may encounter. Therefore it must return `-1` for any positive raw content length. +Even if the length of the "raw" data is known, the length that is send may +not. Example: with option `--crlf` the uploaded content undergoes line-end +conversion. The line converting reader does not know in advance how many +newlines it may encounter. Therefore it must return `-1` for any positive raw +content length. -In HTTP, once the correct client readers are installed, the protocol asks the readers for the total length. If that is known, it can set `Content-Length:` accordingly. If not, it may choose to add an HTTP "chunked" reader. +In HTTP, once the correct client readers are installed, the protocol asks the +readers for the total length. If that is known, it can set `Content-Length:` +accordingly. If not, it may choose to add an HTTP "chunked" reader. -In addition, there is `Curl_creader_client_length(data)` which gives the total length as reported by the reader in phase `CURL_CR_CLIENT` without asking other readers that may transform the raw data. This is useful in estimating the size of an upload. The HTTP protocol uses this to determine if `Expect: 100-continue` shall be done. +In addition, there is `Curl_creader_client_length(data)` which gives the total +length as reported by the reader in phase `CURL_CR_CLIENT` without asking +other readers that may transform the raw data. This is useful in estimating +the size of an upload. The HTTP protocol uses this to determine if `Expect: +100-continue` shall be done. ## Resuming -Uploads can start at a specific offset, if so requested. The "resume from" that offset. This applies to the reader in phase `CURL_CR_CLIENT` that delivers the "raw" content. Resumption can fail if the installed reader does not support it or if the offset is too large. +Uploads can start at a specific offset, if so requested. The "resume from" +that offset. This applies to the reader in phase `CURL_CR_CLIENT` that +delivers the "raw" content. Resumption can fail if the installed reader does +not support it or if the offset is too large. -The total length reported by the reader changes when resuming. Example: resuming an upload of 100 bytes by 25 reports a total length of 75 afterwards. +The total length reported by the reader changes when resuming. Example: +resuming an upload of 100 bytes by 25 reports a total length of 75 afterwards. -If `resume_from()` is invoked twice, it is additive. There is currently no way to undo a resume. +If `resume_from()` is invoked twice, it is additive. There is currently no way +to undo a resume. ## Rewinding -When a request is retried, installed client readers are discarded and replaced by new ones. This works only if the new readers upload the same data. For many readers, this is not an issue. The "null" reader always does the same. Also the `buf` reader, initialized with the same buffer, does this. - -Readers operating on callbacks to the application need to "rewind" the underlying content. For example, when reading from a `FILE*`, the reader needs to `fseek()` to the beginning. The following methods are used: - -1. `Curl_creader_needs_rewind(data)`: tells if a rewind is necessary, given the current state of the reader chain. If nothing really has been read so far, this returns `FALSE`. -2. `Curl_creader_will_rewind(data)`: tells if the reader chain rewinds at the start of the next request. -3. `Curl_creader_set_rewind(data, TRUE)`: marks the reader chain for rewinding at the start of the next request. -4. `Curl_client_start(data)`: tells the readers that a new request starts and they need to rewind if requested. - +When a request is retried, installed client readers are discarded and replaced +by new ones. This works only if the new readers upload the same data. For many +readers, this is not an issue. The "null" reader always does the same. Also +the `buf` reader, initialized with the same buffer, does this. + +Readers operating on callbacks to the application need to "rewind" the +underlying content. For example, when reading from a `FILE*`, the reader needs +to `fseek()` to the beginning. The following methods are used: + +1. `Curl_creader_needs_rewind(data)`: tells if a rewind is necessary, given + the current state of the reader chain. If nothing really has been read so + far, this returns `FALSE`. +2. `Curl_creader_will_rewind(data)`: tells if the reader chain rewinds at + the start of the next request. +3. `Curl_creader_set_rewind(data, TRUE)`: marks the reader chain for rewinding + at the start of the next request. +4. `Curl_client_start(data)`: tells the readers that a new request starts and + they need to rewind if requested. ## Summary and Outlook -By adding the client reader interface, any protocol can control how/if it wants the curl transfer to send bytes for a request. The transfer loop becomes then blissfully ignorant of the specifics. +By adding the client reader interface, any protocol can control how/if it wants +the curl transfer to send bytes for a request. The transfer loop becomes then +blissfully ignorant of the specifics. -The protocols on the other hand no longer have to care to package data most efficiently. At any time, should more data be needed, it can be read from the client. This is used when sending HTTP requests headers to add as much request body data to the initial sending as there is room for. +The protocols on the other hand no longer have to care to package data most +efficiently. At any time, should more data be needed, it can be read from the +client. This is used when sending HTTP requests headers to add as much request +body data to the initial sending as there is room for. Future enhancements based on the client readers: * `expect-100` handling: place that into an HTTP specific reader at diff --git a/docs/internals/CLIENT-WRITERS.md b/docs/internals/CLIENT-WRITERS.md index 9f7197d22890..b07a562afbfb 100644 --- a/docs/internals/CLIENT-WRITERS.md +++ b/docs/internals/CLIENT-WRITERS.md @@ -6,24 +6,35 @@ SPDX-License-Identifier: curl # curl client writers -Client writers is a design in the internals of libcurl, not visible in its public API. They were started -in curl v8.5.0. This document describes the concepts, its high level implementation and the motivations. +Client writers is a design in the internals of libcurl, not visible in its +public API. They were started in curl v8.5.0. This document describes the +concepts, its high level implementation and the motivations. ## Naming -`libcurl` operates between clients and servers. A *client* is the application using libcurl, like the command line tool `curl` itself. Data to be uploaded to a server is **read** from the client and **send** to the server, the servers response is **received** by `libcurl` and then **written** to the client. +`libcurl` operates between clients and servers. A *client* is the application +using libcurl, like the command line tool `curl` itself. Data to be uploaded +to a server is **read** from the client and **send** to the server, the +servers response is **received** by `libcurl` and then **written** to the +client. -With this naming established, client writers are concerned with writing responses from the server to the application. Applications register callbacks via `CURLOPT_WRITEFUNCTION` and `CURLOPT_HEADERFUNCTION` to be invoked by `libcurl` when the response is received. +With this naming established, client writers are concerned with writing +responses from the server to the application. Applications register callbacks +via `CURLOPT_WRITEFUNCTION` and `CURLOPT_HEADERFUNCTION` to be invoked by +`libcurl` when the response is received. ## Invoking -All code in `libcurl` that handles response data is ultimately expected to forward this data via `Curl_client_write()` to the application. The exact prototype of this function is: +All code in `libcurl` that handles response data is ultimately expected to +forward this data via `Curl_client_write()` to the application. The exact +prototype of this function is: ``` CURLcode Curl_client_write(struct Curl_easy *data, int type, const char *buf, size_t blen); ``` -The `type` argument specifies what the bytes in `buf` actually are. The following bits are defined: +The `type` argument specifies what the bytes in `buf` actually are. +The following bits are defined: ``` #define CLIENTWRITE_BODY (1<<0) /* non-meta information, BODY */ #define CLIENTWRITE_INFO (1<<1) /* meta information, not a HEADER */ @@ -35,11 +46,15 @@ The `type` argument specifies what the bytes in `buf` actually are. The followin ``` The main types here are `CLIENTWRITE_BODY` and `CLIENTWRITE_HEADER`. They are -mutually exclusive. The other bits are enhancements to `CLIENTWRITE_HEADER` to -specify what the header is about. They are only used in HTTP and related +mutually exclusive. The other bits are enhancements to `CLIENTWRITE_HEADER` +to specify what the header is about. They are only used in HTTP and related protocols (RTSP and WebSocket). -The implementation of `Curl_client_write()` uses a chain of *client writer* instances to process the call and make sure that the bytes reach the proper application callbacks. This is similar to the design of connection filters: client writers can be chained to process the bytes written through them. The definition is: +The implementation of `Curl_client_write()` uses a chain of *client writer* +instances to process the call and make sure that the bytes reach the proper +application callbacks. This is similar to the design of connection filters: +client writers can be chained to process the bytes written through them. The +definition is: ``` struct Curl_cwtype { @@ -60,11 +75,17 @@ struct Curl_cwriter { }; ``` -`Curl_cwriter` is a writer instance with a `next` pointer to form the chain. It has a type `cwt` which provides the implementation. The main callback is `do_write()` that processes the data and calls then the `next` writer. The others are for setup and tear down. +`Curl_cwriter` is a writer instance with a `next` pointer to form the chain. +It has a type `cwt` which provides the implementation. The main callback is +`do_write()` that processes the data and calls then the `next` writer. The +others are for setup and tear down. ## Phases and Ordering -Since client writers may transform the bytes written through them, the order in which the are called is relevant for the outcome. When a writer is created, one property it gets is the `phase` in which it operates. Writer phases are defined like: +Since client writers may transform the bytes written through them, the order +in which the are called is relevant for the outcome. When a writer is created, +one property it gets is the `phase` in which it operates. Writer phases are +defined like: ``` typedef enum { @@ -76,15 +97,28 @@ typedef enum { } Curl_cwriter_phase; ``` -If a writer for phase `PROTOCOL` is added to the chain, it is always added *after* any `RAW` or `TRANSFER_DECODE` and *before* any `CONTENT_DECODE` and `CLIENT` phase writer. If there is already a writer for the same phase present, the new writer is inserted just before that one. - -All transfers have a chain of 3 writers by default. A specific protocol handler may alter that by adding additional writers. The 3 standard writers are (name, phase): - -1. `"raw", CURL_CW_RAW `: if the transfer is verbose, it forwards the body data to the debug function. -1. `"download", CURL_CW_PROTOCOL`: checks that protocol limits are kept and updates progress counters. When a download has a known length, it checks that it is not exceeded and errors otherwise. -1. `"client", CURL_CW_CLIENT`: the main work horse. It invokes the application callbacks or writes to the configured file handles. It chops large writes into smaller parts, as documented for `CURLOPT_WRITEFUNCTION`. If also handles *pausing* of transfers when the application callback returns `CURL_WRITEFUNC_PAUSE`. - -With these writers always in place, libcurl's protocol handlers automatically have these implemented. +If a writer for phase `PROTOCOL` is added to the chain, it is always added +*after* any `RAW` or `TRANSFER_DECODE` and *before* any `CONTENT_DECODE` and +`CLIENT` phase writer. If there is already a writer for the same phase +present, the new writer is inserted just before that one. + +All transfers have a chain of 3 writers by default. A specific protocol +handler may alter that by adding additional writers. The 3 standard writers +are (name, phase): + +1. `"raw", CURL_CW_RAW `: if the transfer is verbose, it forwards the body data + to the debug function. +1. `"download", CURL_CW_PROTOCOL`: checks that protocol limits are kept and + updates progress counters. When a download has a known length, it checks + that it is not exceeded and errors otherwise. +1. `"client", CURL_CW_CLIENT`: the main work horse. It invokes the application + callbacks or writes to the configured file handles. It chops large writes + into smaller parts, as documented for `CURLOPT_WRITEFUNCTION`. If also + handles *pausing* of transfers when the application callback returns + `CURL_WRITEFUNC_PAUSE`. + +With these writers always in place, libcurl's protocol handlers automatically +have these implemented. ## Enhanced Use @@ -112,12 +146,23 @@ which always is ordered before writers in phase `CURL_CW_CONTENT_DECODE`. What else? -Well, HTTP servers may also apply a `Transfer-Encoding` to the body of a response. The most well-known one is `chunked`, but algorithms like `gzip` and friends could also be applied. The difference to content encodings is that decoding needs to happen *before* protocol checks, for example on length, are done. +Well, HTTP servers may also apply a `Transfer-Encoding` to the body of a +response. The most well-known one is `chunked`, but algorithms like `gzip` and +friends could also be applied. The difference to content encodings is that +decoding needs to happen *before* protocol checks, for example on length, are +done. -That is why transfer decoding writers are added for phase `CURL_CW_TRANSFER_DECODE`. Which makes their operation happen *before* phase `CURL_CW_PROTOCOL` where length may be checked. +That is why transfer decoding writers are added for phase +`CURL_CW_TRANSFER_DECODE`. Which makes their operation happen *before* phase +`CURL_CW_PROTOCOL` where length may be checked. ## Summary -By adding the common behavior of all protocols into `Curl_client_write()` we make sure that they do apply everywhere. Protocol handler have less to worry about. Changes to default behavior can be done without affecting handler implementations. +By adding the common behavior of all protocols into `Curl_client_write()` we +make sure that they do apply everywhere. Protocol handler have less to worry +about. Changes to default behavior can be done without affecting handler +implementations. -Having a writer chain as implementation allows protocol handlers with extra needs, like HTTP, to add to this for special behavior. The common way of writing the actual response data stays the same. +Having a writer chain as implementation allows protocol handlers with extra +needs, like HTTP, to add to this for special behavior. The common way of +writing the actual response data stays the same. diff --git a/docs/internals/CONNECTION-FILTERS.md b/docs/internals/CONNECTION-FILTERS.md index 08fb36738578..3fbb041a16d8 100644 --- a/docs/internals/CONNECTION-FILTERS.md +++ b/docs/internals/CONNECTION-FILTERS.md @@ -271,9 +271,14 @@ conn[curl.se] --> SETUP[TCP] --> HAPPY-EYEBALLS --> TCP[2a04:4e42:c00::347]:443 * transfer ``` -The modular design of connection filters and that we can plug them into each other is used to control the parallel attempts. When a `TCP` filter does not connect (in time), it is torn down and another one is created for the next address. This keeps the `TCP` filter simple. - -The `HAPPY-EYEBALLS` on the other hand stays focused on its side of the problem. We can use it also to make other type of connection by just giving it another filter type to try to have happy eyeballing for QUIC: +The modular design of connection filters and that we can plug them into each +other is used to control the parallel attempts. When a `TCP` filter does not +connect (in time), it is torn down and another one is created for the next +address. This keeps the `TCP` filter simple. + +The `HAPPY-EYEBALLS` on the other hand stays focused on its side of the +problem. We can use it also to make other type of connection by just giving it +another filter type to try to have happy eyeballing for QUIC: ``` * create connection for --http3-only https://curl.se/ diff --git a/docs/internals/MQTT.md b/docs/internals/MQTT.md index 9b8d0efaae2d..acf7464be55c 100644 --- a/docs/internals/MQTT.md +++ b/docs/internals/MQTT.md @@ -12,7 +12,6 @@ A plain "GET" subscribes to the topic and prints all published messages. Doing a "POST" publishes the post data to the topic and exits. - ### Subscribing Command usage: @@ -26,9 +25,10 @@ Example subscribe: This sends an MQTT SUBSCRIBE packet for the topic `bedroom/temp` and listen in for incoming PUBLISH packets. -You can set the upkeep interval ms option to make curl send MQTT ping requests to the -server at an internal, to prevent the connection to get closed because of idleness. -You might then need to use the progress callback to cancel the operation. +You can set the upkeep interval ms option to make curl send MQTT ping requests +to the server at an internal, to prevent the connection to get closed because +of idleness. You might then need to use the progress callback to cancel the +operation. ### Publishing @@ -45,8 +45,8 @@ payload `75`. ## What does curl deliver as a response to a subscribe -Whenever a PUBLISH packet is received, curl outputs two bytes topic length (MSB | LSB), the topic followed by the -payload. +Whenever a PUBLISH packet is received, curl outputs two bytes topic length +(MSB | LSB), the topic followed by the payload. ## Caveats diff --git a/docs/internals/SCORECARD.md b/docs/internals/SCORECARD.md index 546959760417..145267f8c3a6 100644 --- a/docs/internals/SCORECARD.md +++ b/docs/internals/SCORECARD.md @@ -12,14 +12,14 @@ curl/libcurl in a reproducible fashion to judge improvements or detect regressions. They are not intended to represent real world scenarios as such. -This script is not part of any official interface and we may -change it in the future according to the project's needs. +This script is not part of any official interface and we may change it in +the future according to the project's needs. ## setup -When you are able to run curl's `pytest` suite, scorecard should work -for you as well. They start a local Apache httpd or Caddy server and -invoke the locally build `src/curl` (by default). +When you are able to run curl's `pytest` suite, scorecard should work for you +as well. They start a local Apache httpd or Caddy server and invoke the +locally build `src/curl` (by default). ## invocation @@ -29,8 +29,9 @@ A typical invocation for measuring performance of HTTP/2 downloads would be: curl> python3 tests/http/scorecard.py -d h2 ``` -and this prints a table with the results. The last argument is the protocol to test and -it can be `h1`, `h2` or `h3`. You can add `--json` to get results in JSON instead of text. +and this prints a table with the results. The last argument is the protocol to +test and it can be `h1`, `h2` or `h3`. You can add `--json` to get results in +JSON instead of text. Help for all command line options are available via: @@ -40,11 +41,12 @@ curl> python3 tests/http/scorecard.py -h ## scenarios -Apart from `-d/--downloads` there is `-u/--uploads` and `-r/--requests`. These are run with -a variation of resource sizes and parallelism by default. You can specify these in some way -if you are just interested in a particular case. +Apart from `-d/--downloads` there is `-u/--uploads` and `-r/--requests`. These +are run with a variation of resource sizes and parallelism by default. You can +specify these in some way if you are just interested in a particular case. -For example, to run downloads of a 1 MB resource only, 100 times with at max 6 parallel transfers, use: +For example, to run downloads of a 1 MB resource only, 100 times with at max 6 +parallel transfers, use: ``` curl> python3 tests/http/scorecard.py -d --download-sizes=1mb --download-count=100 --download-parallel=6 h2 @@ -61,21 +63,28 @@ involved. (Note: this does not work for HTTP/3) ## flame graphs -With the excellent [Flame Graph](https://github.com/brendangregg/FlameGraph) by Brendan Gregg, scorecard can turn `perf`/`dtrace` samples into an interactive SVG. Either clone the `Flamegraph` repository next to your `curl` project or set the environment variable `FLAMEGRAPH` to the location of your clone. Then run scorecard with the `--flame` option, like +With the excellent [Flame Graph](https://github.com/brendangregg/FlameGraph) +by Brendan Gregg, scorecard can turn `perf`/`dtrace` samples into an +interactive SVG. Either clone the `Flamegraph` repository next to your `curl` +project or set the environment variable `FLAMEGRAPH` to the location of your +clone. Then run scorecard with the `--flame` option, like ``` curl> FLAMEGRAPH=/Users/sei/projects/FlameGraph python3 tests/http/scorecard.py \ -r --request-count=50000 --request-parallels=100 --samples=1 --flame h2 ``` -and the SVG of the run is in `tests/http/gen/curl/curl.flamegraph.svg`. You can open that in Firefox and zoom in/out of stacks of interest. -The flame graph is about the last run of `curl`. That is why you should add scorecard arguments -that restrict measurements to a single run. +and the SVG of the run is in `tests/http/gen/curl/curl.flamegraph.svg`. You +can open that in Firefox and zoom in/out of stacks of interest. + +The flame graph is about the last run of `curl`. That is why you should add +scorecard arguments that restrict measurements to a single run. ### Measures/Privileges -The `--flame` option uses `perf` on linux and `dtrace` on macOS. Since both tools require special -privileges, they are run via the `sudo` command by scorecard. This means you need to issue a -`sudo` recently enough before running scorecard, so no new password check is needed. +The `--flame` option uses `perf` on linux and `dtrace` on macOS. Since both +tools require special privileges, they are run via the `sudo` command by +scorecard. This means you need to issue a `sudo` recently enough before +running scorecard, so no new password check is needed. There is no support right now for measurements on other platforms. diff --git a/docs/internals/TLS-SESSIONS.md b/docs/internals/TLS-SESSIONS.md index 8f887d2e071d..add735bb03bd 100644 --- a/docs/internals/TLS-SESSIONS.md +++ b/docs/internals/TLS-SESSIONS.md @@ -68,7 +68,6 @@ peer keys for this reason. a previous ticket, curl might trust a server which no longer has a root certificate in the file. - ## Session Cache Access #### Lookups diff --git a/docs/internals/UINT_SETS.md b/docs/internals/UINT_SETS.md index 85952c9803fe..5158d7e6bdde 100644 --- a/docs/internals/UINT_SETS.md +++ b/docs/internals/UINT_SETS.md @@ -6,27 +6,26 @@ SPDX-License-Identifier: curl # `uint32_t` Sets -The multi handle tracks added easy handles via an `uint32_t` -it calls an `mid`. There are four data structures for `uint32_t` -optimized for the multi use case. +The multi handle tracks added easy handles via an `uint32_t` it calls an +`mid`. There are four data structures for `uint32_t` optimized for the multi +use case. ## `uint32_tbl` -`uint32_table`, implemented in `uint-table.[ch]` manages an array -of `void *`. The `uint32_t` is the index into this array. It is -created with a *capacity* which can be *resized*. The table assigns -the index when a `void *` is *added*. It keeps track of the last -assigned index and uses the next available larger index for a -subsequent add. Reaching *capacity* it wraps around. +`uint32_table`, implemented in `uint-table.[ch]` manages an array of `void *`. +The `uint32_t` is the index into this array. It is created with a *capacity* +which can be *resized*. The table assigns the index when a `void *` is +*added*. It keeps track of the last assigned index and uses the next available +larger index for a subsequent add. Reaching *capacity* it wraps around. The table *can not* store `NULL` values. The largest possible index is `UINT32_MAX - 1`. -The table is iterated over by asking for the *first* existing index, -meaning the smallest number that has an entry, if the table is not -empty. To get the *next* entry, one passes the index of the previous -iteration step. It does not matter if the previous index is still -in the table. Sample code for a table iteration would look like this: +The table is iterated over by asking for the *first* existing index, meaning +the smallest number that has an entry, if the table is not empty. To get +the *next* entry, one passes the index of the previous iteration step. It does +not matter if the previous index is still in the table. Sample code for a table +iteration would look like this: ```c uint32_t int mid; @@ -50,46 +49,50 @@ This iteration has the following properties: ### Memory -For storing 1000 entries, the table would allocate one block of 8KB on a 64-bit system, -plus the 2 pointers and 3 `uint32_t` in its base `struct uint32_tbl`. A resize -allocates a completely new pointer array, copy the existing entries and free the previous one. +For storing 1000 entries, the table would allocate one block of 8KB on +a 64-bit system, plus the 2 pointers and 3 `uint32_t` in its base `struct +uint32_tbl`. A resize allocates a completely new pointer array, copy +the existing entries and free the previous one. ### Performance -Lookups of entries are only an index into the array, O(1) with a tiny 1. Adding -entries and iterations are more work: +Lookups of entries are only an index into the array, O(1) with a tiny 1. +Adding entries and iterations are more work: -1. adding an entry means "find the first free index larger than the previous assigned - one". Worst case for this is a table with only a single free index where `capacity - 1` - checks on `NULL` values would be performed, O(N). If the single free index is randomly - distributed, this would be O(N/2). -2. iterating a table scans for the first not `NULL` entry after the start index. This - makes a complete iteration O(N) work. +1. adding an entry means "find the first free index larger than the previous + assigned one". Worst case for this is a table with only a single free index + where `capacity - 1` checks on `NULL` values would be performed, O(N). If + the single free index is randomly distributed, this would be O(N/2). +2. iterating a table scans for the first not `NULL` entry after the start + index. This makes a complete iteration O(N) work. -In the multi use case, point 1 is remedied by growing the table so that a good chunk -of free entries always exists. +In the multi use case, point 1 is remedied by growing the table so that a good +chunk of free entries always exists. -Point 2 is less of an issue for a multi, since it does not really matter when the -number of transfer is relatively small. A multi managing a larger set needs to operate -event based anyway and table iterations rarely are needed. +Point 2 is less of an issue for a multi, since it does not really matter when +the number of transfer is relatively small. A multi managing a larger set +needs to operate event based anyway and table iterations rarely are needed. For these reasons, the simple implementation was preferred. Should this become -a concern, there are options like "free index lists" or, alternatively, an internal -bitset that scans better. +a concern, there are options like "free index lists" or, alternatively, an +internal bitset that scans better. ## `uint32_bset` -A bitset for `uint32_t` values, allowing fast add/remove operations. It is initialized -with a *capacity*, meaning it can store only the numbers in the range `[0, capacity-1]`. -It can be *resized* and safely *iterated*. `uint32_bset` is designed to operate in combination with `uint_tbl`. +A bitset for `uint32_t` values, allowing fast add/remove operations. It is +initialized with a *capacity*, meaning it can store only the numbers in the +range `[0, capacity-1]`. It can be *resized* and safely *iterated*. +`uint32_bset` is designed to operate in combination with `uint_tbl`. -The bitset keeps an array of `uint64_t`. The first array entry keeps the numbers 0 to 63, the -second 64 to 127 and so on. A bitset with capacity 1024 would therefore allocate an array -of 16 64-bit values (128 bytes). Operations for an unsigned int divide it by 64 for the array index and then check/set/clear the bit of the remainder. +The bitset keeps an array of `uint64_t`. The first array entry keeps the +numbers 0 to 63, the second 64 to 127 and so on. A bitset with capacity 1024 +would therefore allocate an array of 16 64-bit values (128 bytes). Operations +for an unsigned int divide it by 64 for the array index and then +check/set/clear the bit of the remainder. -Iterator works the same as with `uint32_tbl`: ask the bitset for the *first* number present and -then use that to get the *next* higher number present. Like the table, this safe for -adds/removes and growing the set while iterating. +Iterator works the same as with `uint32_tbl`: ask the bitset for the *first* +number present and then use that to get the *next* higher number present. Like +the table, this safe for adds/removes and growing the set while iterating. ### Memory @@ -98,31 +101,36 @@ A bitset for 40000 transfers occupies 5KB of memory. ## Performance -Operations for add/remove/check are O(1). Iteration needs to scan for the next bit set. The -number of scans is small (see memory footprint) and, for checking bits, many compilers -offer primitives for special CPU instructions. +Operations for add/remove/check are O(1). Iteration needs to scan for the next +bit set. The number of scans is small (see memory footprint) and, for checking +bits, many compilers offer primitives for special CPU instructions. ## `uint32_spbset` -While the memory footprint of `uint32_bset` is good, it still needs 5KB to store the single number 40000. This -is not optimal when many are needed. For example, in event based processing, each socket needs to -keep track of the transfers involved. There are many sockets potentially, but each one mostly tracks -a single transfer or few (on HTTP/2 connection borderline up to 100). +While the memory footprint of `uint32_bset` is good, it still needs 5KB to +store the single number 40000. This is not optimal when many are needed. For +example, in event based processing, each socket needs to keep track of the +transfers involved. There are many sockets potentially, but each one mostly +tracks a single transfer or few (on HTTP/2 connection borderline up to 100). -For such uses cases, the `uint32_spbset` is intended: track a small number of unsigned int, potentially -rather "close" together. It keeps "chunks" with an offset and has no capacity limit. +For such uses cases, the `uint32_spbset` is intended: track a small number of +unsigned int, potentially rather "close" together. It keeps "chunks" with an +offset and has no capacity limit. -Example: adding the number 40000 to an empty sparse bitset would have one chunk with offset 39936, keeping -track of the numbers 39936 to 40192 (a chunk has 4 64-bit values). The numbers in that range can be handled -without further allocations. +Example: adding the number 40000 to an empty sparse bitset would have one +chunk with offset 39936, keeping track of the numbers 39936 to 40192 (a chunk +has 4 64-bit values). The numbers in that range can be handled without further +allocations. -The worst case is then storing 100 numbers that lie in separate intervals. Then 100 chunks -would need to be allocated and linked, resulting in overall 4 KB of memory used. +The worst case is then storing 100 numbers that lie in separate intervals. +Then 100 chunks would need to be allocated and linked, resulting in overall 4 +KB of memory used. Iterating a sparse bitset works the same as for bitset and table. ## `uint32_hash` -At last, there are places in libcurl such as the HTTP/2 and HTTP/3 protocol implementations that need -to store their own data related to a transfer. `uint32_hash` allows then to associate an unsigned int, -e.g. the transfer's `mid`, to their own data. +At last, there are places in libcurl such as the HTTP/2 and HTTP/3 protocol +implementations that need to store their own data related to a transfer. +`uint32_hash` allows then to associate an unsigned int, e.g. the transfer's +`mid`, to their own data. diff --git a/docs/tests/HTTP.md b/docs/tests/HTTP.md index afbfe9e5bd96..658abac25505 100644 --- a/docs/tests/HTTP.md +++ b/docs/tests/HTTP.md @@ -6,7 +6,9 @@ SPDX-License-Identifier: curl # The curl HTTP Test Suite -This is an additional test suite using a combination of Apache httpd and nghttpx servers to perform various tests beyond the capabilities of the standard curl test suite. +This is an additional test suite using a combination of Apache httpd and +nghttpx servers to perform various tests beyond the capabilities of the +standard curl test suite. # Usage @@ -23,13 +25,17 @@ collected 5 items tests/http/test_01_basic.py ..... ``` -Pytest takes arguments. `-v` increases its verbosity and can be used several times. `-k ` can be used to run only matching test cases. The `expr` can be something resembling a python test or just a string that needs to match test cases in their names. +Pytest takes arguments. `-v` increases its verbosity and can be used several +times. `-k ` can be used to run only matching test cases. The `expr` can +be something resembling a python test or just a string that needs to match +test cases in their names. ``` curl/tests/http> pytest -vv -k test_01_02 ``` -runs all test cases that have `test_01_02` in their name. This does not have to be the start of the name. +runs all test cases that have `test_01_02` in their name. This does not have +to be the start of the name. Depending on your setup, some test cases may be skipped and appear as `s` in the output. If you run pytest verbose, it also gives you the reason for @@ -40,7 +46,8 @@ skipping. You need: 1. a recent Python, the `cryptography` module and, of course, `pytest` -2. an apache httpd development version. On Debian/Ubuntu, the package `apache2-dev` has this +2. an apache httpd development version. On Debian/Ubuntu, the package + `apache2-dev` has this 3. a local `curl` project build 3. optionally, a `nghttpx` with HTTP/3 enabled or h3 test cases are skipped @@ -48,33 +55,49 @@ You need: Via curl's `configure` script you may specify: - * `--with-test-nghttpx=` if you have nghttpx to use somewhere outside your `$PATH`. - * `--with-test-httpd=` if you have an Apache httpd installed somewhere else. On Debian/Ubuntu it will otherwise look into `/usr/bin` and `/usr/sbin` to find those. - * `--with-test-caddy=` if you have a Caddy web server installed somewhere else. - * `--with-test-vsftpd=` if you have a vsftpd ftp server installed somewhere else. + * `--with-test-nghttpx=` if you have nghttpx to use + somewhere outside your `$PATH`. + + * `--with-test-httpd=` if you have an Apache httpd + installed somewhere else. On Debian/Ubuntu it otherwise looks into + `/usr/bin` and `/usr/sbin` to find those. + + * `--with-test-caddy=` if you have a Caddy web server + installed somewhere else. + + * `--with-test-vsftpd=` if you have a vsftpd ftp + server installed somewhere else. + * `--with-test-danted=` if you have `dante-server` installed ## Usage Tips -Several test cases are parameterized, for example with the HTTP version to use. If you want to run a test with a particular protocol only, use a command line like: +Several test cases are parameterized, for example with the HTTP version to +use. If you want to run a test with a particular protocol only, use a command +line like: ``` curl/tests/http> pytest -k "test_02_06 and h2" ``` -Test cases can be repeated, with the `pytest-repeat` module (`pip install pytest-repeat`). Like in: +Test cases can be repeated, with the `pytest-repeat` module (`pip install +pytest-repeat`). Like in: ``` curl/tests/http> pytest -k "test_02_06 and h2" --count=100 ``` -which then runs this test case a hundred times. In case of flaky tests, you can make pytest stop on the first one with: +which then runs this test case a hundred times. In case of flaky tests, you +can make pytest stop on the first one with: ``` curl/tests/http> pytest -k "test_02_06 and h2" --count=100 --maxfail=1 ``` -which allow you to inspect output and log files for the failed run. Speaking of log files, the verbosity of pytest is also used to collect curl trace output. If you specify `-v` three times, the `curl` command is started with `--trace`: +which allow you to inspect output and log files for the failed run. Speaking +of log files, the verbosity of pytest is also used to collect curl trace +output. If you specify `-v` three times, the `curl` command is started with +`--trace`: ``` curl/tests/http> pytest -vvv -k "test_02_06 and h2" --count=100 --maxfail=1 @@ -84,7 +107,10 @@ all of curl's output and trace file are found in `tests/http/gen/curl`. ## Writing Tests -There is a lot of [`pytest` documentation](https://docs.pytest.org/) with examples. No use in repeating that here. Assuming you are somewhat familiar with it, it is useful how *this* general test suite is setup. Especially if you want to add test cases. +There is a lot of [`pytest` documentation](https://docs.pytest.org/) with +examples. No use in repeating that here. Assuming you are somewhat familiar +with it, it is useful how *this* general test suite is setup. Especially if +you want to add test cases. ### Servers @@ -110,22 +136,44 @@ left behind. ### Test Cases -Tests making use of these fixtures have them in their parameter list. This tells pytest that a particular test needs them, so it has to create them. Since one can invoke pytest for just a single test, it is important that a test references the ones it needs. +Tests making use of these fixtures have them in their parameter list. This +tells pytest that a particular test needs them, so it has to create them. +Since one can invoke pytest for just a single test, it is important that a +test references the ones it needs. -All test cases start with `test_` in their name. We use a double number scheme to group them. This makes it ease to run only specific tests and also give a short mnemonic to communicate trouble with others in the project. Otherwise you are free to name test cases as you think fitting. +All test cases start with `test_` in their name. We use a double number scheme +to group them. This makes it ease to run only specific tests and also give a +short mnemonic to communicate trouble with others in the project. Otherwise +you are free to name test cases as you think fitting. -Tests are grouped thematically in a file with a single Python test class. This is convenient if you need a special "fixture" for several tests. "fixtures" can have "class" scope. +Tests are grouped thematically in a file with a single Python test class. This +is convenient if you need a special "fixture" for several tests. "fixtures" +can have "class" scope. -There is a curl helper class that knows how to invoke curl and interpret its output. Among other things, it does add the local CA to the command line, so that SSL connections to the test servers are verified. Nothing prevents anyone from running curl directly, for specific uses not covered by the `CurlClient` class. +There is a curl helper class that knows how to invoke curl and interpret its +output. Among other things, it does add the local CA to the command line, so +that SSL connections to the test servers are verified. Nothing prevents anyone +from running curl directly, for specific uses not covered by the `CurlClient` +class. ### mod_curltest -The module source code is found in `testenv/mod_curltest`. It is compiled using the `apxs` command, commonly provided via the `apache2-dev` package. Compilation is quick and done once at the start of a test run. +The module source code is found in `testenv/mod_curltest`. It is compiled +using the `apxs` command, commonly provided via the `apache2-dev` package. +Compilation is quick and done once at the start of a test run. + +The module adds 2 "handlers" to the Apache server (right now). Handler are +pieces of code that receive HTTP requests and generate the response. Those +handlers are: + +* `curltest-echo`: hooked up on the path `/curltest/echo`. This one echoes + a request and copies all data from the request body to the response body. + Useful for simulating upload and checking that the data arrived as intended. -The module adds 2 "handlers" to the Apache server (right now). Handler are pieces of code that receive HTTP requests and generate the response. Those handlers are: +* `curltest-tweak`: hooked up on the path `/curltest/tweak`. This handler is + more of a Swiss army knife. It interprets parameters from the URL query + string to drive its behavior. -* `curltest-echo`: hooked up on the path `/curltest/echo`. This one echoes a request and copies all data from the request body to the response body. Useful for simulating upload and checking that the data arrived as intended. -* `curltest-tweak`: hooked up on the path `/curltest/tweak`. This handler is more of a Swiss army knife. It interprets parameters from the URL query string to drive its behavior. * `status=nnn`: generate a response with HTTP status code `nnn`. * `chunks=n`: generate `n` chunks of data in the response body, defaults to 3. * `chunk_size=nnn`: each chunk should contain `nnn` bytes of data. Maximum is 16KB right now. From 46429d6f44d89bf09ec5c802fbeb8b1e68da2b5e Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Thu, 11 Dec 2025 02:46:24 +0100 Subject: [PATCH 291/415] GHA/checkdocs: re-enable proselint, update setup, fix issues found - update configuration and invocation. - install via pip. - drop a file exception. - alpha sort proselint settings. - FILEFORMAT: update text about XML compliance. - CI job takes 22 seconds total. Ref: https://github.com/amperser/proselint/releases/tag/v0.16.0 Follow-up to 38bfe1c2aa2a6c8af29d525eb231ad66861199b1 #15314 Closes #19931 --- .github/scripts/requirements-proselint.txt | 5 + .github/workflows/checkdocs.yml | 104 ++++++++++----------- docs/HTTP3.md | 2 +- docs/INFRASTRUCTURE.md | 4 +- docs/cmdline-opts/form.md | 2 +- docs/cmdline-opts/ssl.md | 3 +- docs/cmdline-opts/upload-flags.md | 2 +- docs/internals/CODE_STYLE.md | 4 +- docs/libcurl/opts/CURLOPT_USE_SSL.md | 2 +- docs/tests/FILEFORMAT.md | 7 +- 10 files changed, 68 insertions(+), 67 deletions(-) create mode 100644 .github/scripts/requirements-proselint.txt diff --git a/.github/scripts/requirements-proselint.txt b/.github/scripts/requirements-proselint.txt new file mode 100644 index 000000000000..189610944297 --- /dev/null +++ b/.github/scripts/requirements-proselint.txt @@ -0,0 +1,5 @@ +# Copyright (C) Daniel Stenberg, , et al. +# +# SPDX-License-Identifier: curl + +proselint==0.16.0 diff --git a/.github/workflows/checkdocs.yml b/.github/workflows/checkdocs.yml index 7962034e9673..9272969275da 100644 --- a/.github/workflows/checkdocs.yml +++ b/.github/workflows/checkdocs.yml @@ -35,59 +35,57 @@ concurrency: permissions: {} jobs: - # proselint: - # name: 'proselint' - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 - # with: - # persist-credentials: false - # - # - name: 'install prereqs' - # run: | - # sudo rm -f /etc/apt/sources.list.d/microsoft-prod.list - # sudo apt-get -o Dpkg::Use-Pty=0 update - # sudo rm -f /var/lib/man-db/auto-update - # sudo apt-get -o Dpkg::Use-Pty=0 install python3-proselint - # - # # config file help: https://github.com/amperser/proselint/ - # - name: 'create proselint config' - # run: | - # cat < ~/.proselintrc.json - # { - # "checks": { - # "typography.diacritical_marks": false, - # "typography.symbols": false, - # "annotations.misc": false, - # "security.password": false, - # "misc.annotations": false - # } - # } - # JSON - # - # - name: 'trim headers off all *.md files' - # run: git ls-files '*.md' -z | xargs -0 -n1 .github/scripts/trimmarkdownheader.pl - # - # - name: 'check prose' - # run: git ls-files '*.md' -z | grep -Evz 'CHECKSRC\.md|DISTROS\.md|curl_mprintf\.md|CURLOPT_INTERFACE\.md|interface\.md' | xargs -0 proselint -- README - # - # # This is for CHECKSRC and files with aggressive exclamation mark needs - # - name: 'create second proselint config' - # run: | - # cat < ~/.proselintrc.json - # { - # "checks": { - # "typography.diacritical_marks": false, - # "typography.symbols": false, - # "typography.exclamation": false, - # "lexical_illusions.misc": false, - # "annotations.misc": false - # } - # } - # JSON - # - # - name: 'check special prose' - # run: proselint docs/internals/CHECKSRC.md docs/libcurl/curl_mprintf.md docs/libcurl/opts/CURLOPT_INTERFACE.md docs/cmdline-opts/interface.md + # config file help: https://github.com/amperser/proselint/ + proselint: + name: 'proselint' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 + with: + persist-credentials: false + + - name: 'install prereqs' + run: | + python3 -m venv ~/venv + ~/venv/bin/pip --disable-pip-version-check --no-input --no-cache-dir install --progress-bar off --prefer-binary -r .github/scripts/requirements-proselint.txt + + - name: 'trim headers off all *.md files' + run: git ls-files '*.md' -z | xargs -0 -n1 .github/scripts/trimmarkdownheader.pl + + - name: 'check prose' + run: | + cat < ~/.proselintrc.json + { + "checks": { + "annotations.misc": false, + "lexical_illusions": false, + "misc.annotations": false, + "redundancy.misc.garner": false, + "security.password": false, + "spelling.ve_of": false, + "typography.diacritical_marks": false, + "typography.symbols": false + } + } + JSON + source ~/venv/bin/activate + git ls-files README '*.md' -z | grep -Evz '(CHECKSRC|DISTROS|CURLOPT_INTERFACE|interface)\.md' | xargs -0 proselint check -- + + - name: 'check special prose' # For CHECKSRC and files with aggressive exclamation mark needs + run: | + cat < ~/.proselintrc.json + { + "checks": { + "annotations.misc": false, + "lexical_illusions": false, + "typography.diacritical_marks": false, + "typography.punctuation.exclamation": false, + "typography.symbols": false + } + } + JSON + source ~/venv/bin/activate + proselint check docs/internals/CHECKSRC.md docs/libcurl/opts/CURLOPT_INTERFACE.md docs/cmdline-opts/interface.md pyspelling: name: 'pyspelling' diff --git a/docs/HTTP3.md b/docs/HTTP3.md index 2b0a4c72b872..e18277cb3c87 100644 --- a/docs/HTTP3.md +++ b/docs/HTTP3.md @@ -317,7 +317,7 @@ See this [list of public HTTP/3 servers](https://bagder.github.io/HTTP3-test/) ### HTTPS eyeballing With option `--http3` curl attempts earlier HTTP versions as well should the -connect attempt via HTTP/3 not succeed "fast enough". This strategy is similar +connect attempt via HTTP/3 fail "fast enough". This strategy is similar to IPv4/6 happy eyeballing where the alternate address family is used in parallel after a short delay. diff --git a/docs/INFRASTRUCTURE.md b/docs/INFRASTRUCTURE.md index 7a6bafb9dbab..6acc8757f010 100644 --- a/docs/INFRASTRUCTURE.md +++ b/docs/INFRASTRUCTURE.md @@ -60,7 +60,7 @@ account. We regularly run our code through the [Coverity static code analyzer](https://scan.coverity.com/) thanks to them offering this service to -us for free. +us free of charge. ## CodeSonar @@ -76,7 +76,7 @@ domain names, including `curl.se` and `curl.dev`. Daniel Stenberg owns these domain names. Until a few years ago, the curl website was present at `curl.haxx.se`. The -`haxx.se` domain is owned by Haxx AB, administrated by Daniel Stenberg. The +`haxx.se` domain is owned by Haxx AB, administered by Daniel Stenberg. The curl.haxx.se name is meant to keep working and be redirecting to curl.se for the foreseeable future. diff --git a/docs/cmdline-opts/form.md b/docs/cmdline-opts/form.md index 100e29e5716e..abe4fa998b25 100644 --- a/docs/cmdline-opts/form.md +++ b/docs/cmdline-opts/form.md @@ -127,7 +127,7 @@ text file: curl -F '=(;type=multipart/alternative' \ -F '=plain text message' \ -F '= HTML message;type=text/html' \ - -F '=)' -F '=@textfile.txt' ... smtp://example.com + -F '=)' -F '=@textfile.txt' ... smtp://example.com Data can be encoded for transfer using encoder=. Available encodings are *binary* and *8bit* that do nothing else than adding the corresponding diff --git a/docs/cmdline-opts/ssl.md b/docs/cmdline-opts/ssl.md index 0c0f28172acb..5951d0199123 100644 --- a/docs/cmdline-opts/ssl.md +++ b/docs/cmdline-opts/ssl.md @@ -28,8 +28,7 @@ different levels of encryption required. This option is handled in LDAP (added in 7.81.0). It is fully supported by the OpenLDAP backend and ignored by the generic ldap backend. -Please note that a server may close the connection if the negotiation does -not succeed. +Please note that a server may close the connection if the negotiation fails. This option was formerly known as --ftp-ssl (added in 7.11.0). That option name can still be used but might be removed in a future version. diff --git a/docs/cmdline-opts/upload-flags.md b/docs/cmdline-opts/upload-flags.md index d17614876836..6c014d0895f3 100644 --- a/docs/cmdline-opts/upload-flags.md +++ b/docs/cmdline-opts/upload-flags.md @@ -21,5 +21,5 @@ specified as either a single flag value or a comma-separated list of flag values. These values are case-sensitive and may be negated by prepending them with a '-' character. Currently the following flag values are accepted: answered, deleted, draft, flagged, and -seen. The currently-accepted flag values are used to set flags on +seen. The currently accepted flag values are used to set flags on IMAP uploads. diff --git a/docs/internals/CODE_STYLE.md b/docs/internals/CODE_STYLE.md index 43b873be9b37..d8f97594f5bf 100644 --- a/docs/internals/CODE_STYLE.md +++ b/docs/internals/CODE_STYLE.md @@ -24,8 +24,8 @@ need to copy the style already used in the source code and there are no particularly unusual rules in our set of rules. We also work hard on writing code that are warning-free on all the major -platforms and in general on as many platforms as possible. Code that obviously -causes warnings is not accepted as-is. +platforms and in general on as many platforms as possible. Code that causes +warnings is not accepted as-is. ## Readability diff --git a/docs/libcurl/opts/CURLOPT_USE_SSL.md b/docs/libcurl/opts/CURLOPT_USE_SSL.md index 9a2d2abe5e9a..0729f6e84ee2 100644 --- a/docs/libcurl/opts/CURLOPT_USE_SSL.md +++ b/docs/libcurl/opts/CURLOPT_USE_SSL.md @@ -45,7 +45,7 @@ do not attempt to use SSL. ## CURLUSESSL_TRY Try using SSL, proceed as normal otherwise. Note that server may close the -connection if the negotiation does not succeed. +connection if the negotiation fails. ## CURLUSESSL_CONTROL diff --git a/docs/tests/FILEFORMAT.md b/docs/tests/FILEFORMAT.md index 84188e9dd9dc..4749d809e0d2 100644 --- a/docs/tests/FILEFORMAT.md +++ b/docs/tests/FILEFORMAT.md @@ -11,10 +11,9 @@ XML. All data for a single test case resides in a single ASCII file. Labels mark the beginning and the end of all sections, and each label must be written in its own line. Comments are either XML-style (enclosed with ``) or shell script style (beginning with `#`) and must appear on their own -lines and not alongside actual test data. Most test data files are -syntactically-valid XML (a few files are not); lack of support for character -entities is a big difference but macros like %CR fill that particular role -here. +lines and not alongside actual test data. Test data files are syntactically +valid XML; lack of support for character entities is a big difference but macros +like %CR fill that particular role here. Each test case source exists as a file matching the format `tests/data/testNUM`, where `NUM` is the unique test number, and must begin From 624d98e79ccde1304f40967509b56c32feb2da48 Mon Sep 17 00:00:00 2001 From: Christian Schmitz Date: Thu, 11 Dec 2025 14:37:13 +0100 Subject: [PATCH 292/415] transfer: remove @param for err for xfer_recv_resp function. The err parameter in xfer_recv_resp doesn't exist anymore. Removed in cb2bcb681fc9044d2a7adaaa621. Closes #19937 --- lib/transfer.c | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/transfer.c b/lib/transfer.c index 11e7e6e793c3..bd6be821dc2a 100644 --- a/lib/transfer.c +++ b/lib/transfer.c @@ -181,7 +181,6 @@ CURLcode Curl_xfer_send_shutdown(struct Curl_easy *data, bool *done) * @param buf buffer to keep response data received * @param blen length of `buf` * @param eos_reliable if EOS detection in underlying connection is reliable - * @param err error code in case of -1 return * @return number of bytes read or -1 for error */ static CURLcode xfer_recv_resp(struct Curl_easy *data, From 846eaf4e6b5518f95423b8e95b6a2f70cc144bd4 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 11 Dec 2025 15:38:00 +0100 Subject: [PATCH 293/415] RELEASE-NOTES: synced --- RELEASE-NOTES | 72 +++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 59 insertions(+), 13 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index d34291718ae4..df1e2a1de13f 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -4,7 +4,7 @@ curl and libcurl 8.18.0 Command line options: 273 curl_easy_setopt() options: 308 Public functions in libcurl: 100 - Contributors: 3557 + Contributors: 3559 This release includes the following changes: @@ -17,6 +17,7 @@ This release includes the following changes: This release includes the following bugfixes: o _PROGRESS.md: add the E unit, mention kibibyte [24] + o alt-svc: more flexibility on same destination [298] o altsvc: make it one malloc instead of three per entry [266] o AmigaOS: increase minimum stack size for tool_main [137] o apple-sectrust: always ask when `native_ca_store` is in use [162] @@ -27,10 +28,13 @@ This release includes the following bugfixes: o auth: always treat Curl_auth_ntlm_get() returning NULL as OOM [186] o autotools: add nettle library detection via pkg-config (for GnuTLS) [178] o autotools: drop autoconf <2.59 compatibility code (zz60-xc-ovr) [70] + o autotools: fix LargeFile feature display on Windows (after prev patch) [276] + o autotools: tidy-up `if` expressions [275] o badwords: fix issues found in scripts and other files [142] o badwords: fix issues found in tests [156] o build: add build-level `CURL_DISABLE_TYPECHECK` options [163] o build: exclude clang prereleases from compiler warning options [154] + o build: set `-Wno-format-signedness` [288] o build: tidy-up MSVC CRT warning suppression macros [140] o ccsidcurl: make curl_mime_data_ccsid() use the converted size [74] o cf-https-connect: allocate ctx at first in cf_hc_create() [79] @@ -47,8 +51,11 @@ This release includes the following bugfixes: o cmake: save and restore `CMAKE_MODULE_PATH` in `curl-config.cmake` [222] o code: minor indent fixes before closing braces [107] o CODE_STYLE.md: sync banned function list with checksrc.pl [243] + o config-win32.h: delete obsolete, non-Windows comments [295] + o config-win32.h: drop unused/obsolete `CURL_HAS_OPENLDAP_LDAPSDK` [278] o config2setopts: bail out if curl_url_get() returns OOM [102] o config2setopts: exit if curl_url_set() fails on OOM [105] + o configure: delete unused variable [294] o conncache: silence `-Wnull-dereference` on gcc 14 RISC-V 64 [17] o conncontrol: reuse handling [170] o connect: reshuffle Curl_timeleft_ms to avoid 'redundant condition' [100] @@ -62,6 +69,7 @@ This release includes the following bugfixes: o curl: fix progress meter in parallel mode [15] o curl_fopen: do not pass invalid mode flags to `open()` on Windows [84] o curl_gssapi: make sure Curl_gss_log_error() has an initialized buffer [257] + o curl_sasl: if redirected, require permission to use bearer [250] o curl_sasl: make Curl_sasl_decode_mech compare case insensitively [160] o curl_setup.h: document more funcs flagged by `_CRT_SECURE_NO_WARNINGS` [124] o curl_setup.h: drop stray `#undef stat` (Windows) [103] @@ -70,6 +78,7 @@ This release includes the following bugfixes: o CURLINFO_SCHEME/PROTOCOL: they return the "scheme" for a "transfer" [48] o CURLINFO_TLS_SSL_PTR.md: remove CURLINFO_TLS_SESSION text [49] o CURLMOPT_SOCKETFUNCTION.md: fix the callback argument use [206] + o CURLOPT_FOLLOWLOCATION.md: s/Authentication:/Authorization:/ [283] o CURLOPT_READFUNCTION.md: clarify the size of the buffer [47] o CURLOPT_SSH_KEYFUNCTION.md: fix minor indent mistake in example o curlx/fopen: replace open CRT functions their with `_s` counterparts (Windows) [204] @@ -79,12 +88,14 @@ This release includes the following bugfixes: o curlx: replace `mbstowcs`/`wcstombs` with `_s` counterparts (Windows) [143] o curlx: replace `sprintf` with `snprintf` [194] o curlx: use curlx allocators in non-memdebug builds (Windows) [155] + o DEPRECATE: add CMake <3.18 deprecation for April 2026 [291] o digest_sspi: fix a memory leak on error path [149] o digest_sspi: properly free sspi identity [12] o DISTROS.md: add OpenBSD [126] o DISTROS: fix a Mageia URL o DISTROS: remove broken URLs for buildroot o doc: some returned in-memory data may not be altered [196] + o Dockerfile: update debian:bookworm-slim digest to e899040 [305] o docs/libcurl: fix C formatting nits [207] o docs: clarify how to do unix domain sockets with SOCKS proxy [240] o docs: fix checksrc `EQUALSPACE` warnings [21] @@ -100,6 +111,8 @@ This release includes the following bugfixes: o examples: fix minor typo [203] o examples: make functions/data static where missing [139] o examples: tidy-up headers and includes [138] + o examples: use 64-bit `fstat` on Windows [301] + o FAQ/TODO/KNOWN_BUGS: convert to markdown [307] o FAQ: fix hackerone URL o file: do not pass invalid mode flags to `open()` on upload (Windows) [83] o formdata: validate callback is non-NULL before use [267] @@ -110,8 +123,10 @@ This release includes the following bugfixes: o gnutls: add PROFILE_MEDIUM as default [233] o gnutls: report accurate error when TLS-SRP is not built-in [18] o gtls: add return checks and optimize the code [2] + o gtls: Call keylog_close in cleanup o gtls: skip session resumption when verifystatus is set o h2/h3: handle methods with spaces [146] + o headers: add length argument to Curl_headers_push() [309] o hostcheck: fail wildcard match if host starts with a dot [235] o hostip: don't store negative lookup on OOM [61] o hostip: make more functions return CURLcode [202] @@ -129,11 +144,13 @@ This release includes the following bugfixes: o idn: avoid allocations and wcslen on Windows [247] o idn: fix memory leak in `win32_ascii_to_idn()` [173] o idn: use curlx allocators on Windows [165] + o imap: check buffer length before accessing it [308] o imap: make sure Curl_pgrsSetDownloadSize() does not overflow [200] o INSTALL-CMAKE.md: document static option defaults more [37] o krb5: fix detecting channel binding feature [187] o krb5_sspi: unify a part of error handling [80] o ldap: call ldap_init() before setting the options [236] + o ldap: drop PP logic for old, unsupported, Windows SDKs [279] o ldap: improve detection of Apple LDAP [174] o ldap: provide version for "legacy" ldap as well [254] o lib/sendf.h: forward declare two structs [221] @@ -162,11 +179,13 @@ This release includes the following bugfixes: o mbedtls_threadlock: avoid calloc, use array [244] o mdlinkcheck: ignore IP numbers, allow '@' in raw URLs o memdebug: add mutex for thread safety [184] + o memdebug: fix realloc logging [286] o mk-ca-bundle.md: the file format docs URL is permaredirected [188] o mk-ca-bundle.pl: default to SHA256 fingerprints with `-t` option [73] o mk-ca-bundle.pl: use `open()` with argument list to replace backticks [71] o mqtt: reject overly big messages [39] o multi: make max_total_* members size_t [158] + o multi: remove MSTATE_TUNNELING [297] o multi: simplify admin handle processing [189] o multibyte: limit `curlx_convert_*wchar*()` functions to Unicode builds [135] o ngtcp2+openssl: fix leak of session [172] @@ -190,6 +209,7 @@ This release includes the following bugfixes: o pytest: disable two H3 earlydata tests for all platforms (was: macOS) [116] o pytest: fix and improve reliability [251] o pytest: improve stragglers [252] + o pytest: quiche flakiness [280] o pytest: skip H2 tests if feature missing from curl [46] o quiche: use client writer [255] o ratelimit: redesign [209] @@ -228,6 +248,7 @@ This release includes the following bugfixes: o test1475: consistently use %CR in headers [234] o test1498: disable 'HTTP PUT from stdin' test on Windows [115] o test2045: replace HTML multi-line comment markup with `#` comments [36] + o test318: tweak the name a little o test3207: enable memdebug for this test again [249] o test363: delete stray character (typo) from a section tag [52] o test787: fix possible typo `&` -> `%` in curl option [241] @@ -243,6 +264,7 @@ This release includes the following bugfixes: o tftpd: fix/tidy up `open()` mode flags [57] o tidy-up: avoid `(())`, clang-format fixes and more [141] o tidy-up: move `CURL_UNCONST()` out from macro `curl_unicodefree()` [121] + o tidy-up: URLs (cont.) and mdlinkcheck [285] o tidy-up: URLs [182] o TODO: remove a mandriva.com reference o tool: consider (some) curl_easy_setopt errors fatal [7] @@ -276,6 +298,7 @@ This release includes the following bugfixes: o vtls: handle possible malicious certs_num from peer [53] o vtls: pinned key check [98] o wcurl: import v2025.11.09 [29] + o windows: assume `USE_WIN32_LARGE_FILES` [292] o windows: use `_strdup()` instead of `strdup()` where missing [145] o wolfSSL: able to differentiate between IP and DNS in alt names [13] o wolfssl: avoid NULL dereference in OOM situation [77] @@ -304,18 +327,20 @@ Planned upcoming removals include: This release would not have looked like this without help, code, reports and advice from friends like these: - Aleksandr Sergeev, Aleksei Bavshin, Andrew Kirillov, BANADDA, boingball, - Brad King, bttrfl on github, Christian Schmitz, Dan Fandrich, - Daniel McCarney, Daniel Stenberg, Denis Goleshchikhin, Deniz Parlak, - dependabot[bot], Fabian Keil, Fd929c2CE5fA on github, ffath-vo on github, - Georg Schulz-Allgaier, Gisle Vanem, Greg Hudson, Harry Sintonen, Jiyong Yang, - Juliusz Sosinowicz, Kai Pastor, Leonardo Taccari, letshack9707 on hackerone, - Marc Aldorasi, Marcel Raad, Max Faxälv, nait-furry, ncaklovic on github, - Nick Korepanov, Omdahake on github, Patrick Monnerat, pelioro on hackerone, - Ray Satiro, renovate[bot], Robert W. Van Kirk, Samuel Henrique, - st751228051 on github, Stanislav Fort, Stefan Eissing, Sunny, Theo Buehler, - Thomas Klausner, Viktor Szakats, Wesley Moore, Xiaoke Wang, Yedaya Katsman - (49 contributors) + Aleksandr Sergeev, Aleksei Bavshin, Andrew Kirillov, + anonymous237 on hackerone, BANADDA, boingball, Brad King, bttrfl on github, + Christian Schmitz, Dan Fandrich, Daniel McCarney, Daniel Stenberg, + Denis Goleshchikhin, Deniz Parlak, dependabot[bot], Fabian Keil, + Fd929c2CE5fA on github, ffath-vo on github, Georg Schulz-Allgaier, + Gisle Vanem, Greg Hudson, Harry Sintonen, Jiyong Yang, Juliusz Sosinowicz, + Kai Pastor, Leonardo Taccari, letshack9707 on hackerone, Marc Aldorasi, + Marcel Raad, Max Faxälv, nait-furry, ncaklovic on github, Nick Korepanov, + Omdahake on github, Patrick Monnerat, pelioro on hackerone, Ray Satiro, + renovate[bot], Robert W. Van Kirk, Samuel Henrique, st751228051 on github, + Stanislav Fort, Stefan Eissing, Sunny, Theo Buehler, Thomas Klausner, + Viktor Szakats, Wesley Moore, Xiaoke Wang, Yedaya Katsman, Yuhao Jiang, + yushicheng7788 on github + (52 contributors) References to bug reports and discussions on issues: @@ -563,6 +588,7 @@ References to bug reports and discussions on issues: [247] = https://curl.se/bug/?i=19798 [248] = https://curl.se/bug/?i=19811 [249] = https://curl.se/bug/?i=19813 + [250] = https://curl.se/bug/?i=19933 [251] = https://curl.se/bug/?i=19970 [252] = https://curl.se/bug/?i=19809 [253] = https://curl.se/bug/?i=19800 @@ -581,3 +607,23 @@ References to bug reports and discussions on issues: [266] = https://curl.se/bug/?i=19857 [267] = https://curl.se/bug/?i=19858 [268] = https://curl.se/bug/?i=19753 + [275] = https://curl.se/bug/?i=18189 + [276] = https://curl.se/bug/?i=19922 + [278] = https://curl.se/bug/?i=19920 + [279] = https://curl.se/bug/?i=19918 + [280] = https://curl.se/bug/?i=19770 + [283] = https://curl.se/bug/?i=19915 + [285] = https://curl.se/bug/?i=19911 + [286] = https://curl.se/bug/?i=19900 + [288] = https://curl.se/bug/?i=19907 + [291] = https://curl.se/bug/?i=19902 + [292] = https://curl.se/bug/?i=19888 + [294] = https://curl.se/bug/?i=19901 + [295] = https://curl.se/bug/?i=19899 + [297] = https://curl.se/bug/?i=19894 + [298] = https://curl.se/bug/?i=19740 + [301] = https://curl.se/bug/?i=19896 + [305] = https://curl.se/bug/?i=19891 + [307] = https://curl.se/bug/?i=19875 + [308] = https://curl.se/bug/?i=19887 + [309] = https://curl.se/bug/?i=19886 From 2e3687c60c5c9720992a7cebf9493ec2d28a1cf6 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 11 Dec 2025 17:16:37 +0100 Subject: [PATCH 294/415] mdlinkcheck: only look for markdown links in markdown files It finds debug outputs in source code otherwise. Output the whitelist "warnings" to stderr to better allow us to count URLs with `./mdlinkcheck --dry-run | wc -l`. Closes #19938 --- scripts/mdlinkcheck | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/mdlinkcheck b/scripts/mdlinkcheck index bd54d96fe2ea..4ee0b537525a 100755 --- a/scripts/mdlinkcheck +++ b/scripts/mdlinkcheck @@ -158,9 +158,12 @@ sub findlinks { open(F, "<:crlf", "$f") || return; + # is it a markdown extension? + my $md = ($f =~ /\.md$/i); + while() { chomp; - if(/\]\(([^)]*)/) { + if($md && /\]\(([^)]*)/) { my $link = $1; #print "$f:$line $link\n"; storelink($f, $line, $link); @@ -209,7 +212,7 @@ for my $f (@files) { for my $u (sort keys %whitelist) { if($whitelist{$u} == 1) { - printf "warning: unused whitelist entry: '$u'\n"; + printf STDERR "warning: unused whitelist entry: '$u'\n"; } } From 141ce4be64aaf79cfdd5f66f6d1e8466c3c7d2e4 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 11 Dec 2025 22:24:51 +0000 Subject: [PATCH 295/415] GHA: update actions/cache action to v5 Closes #19940 --- .github/workflows/http3-linux.yml | 46 +++++++++++++++---------------- .github/workflows/linux.yml | 24 ++++++++-------- .github/workflows/macos.yml | 2 +- .github/workflows/windows.yml | 2 +- 4 files changed, 37 insertions(+), 37 deletions(-) diff --git a/.github/workflows/http3-linux.yml b/.github/workflows/http3-linux.yml index 86c9f3459d7c..a9b8c44f0006 100644 --- a/.github/workflows/http3-linux.yml +++ b/.github/workflows/http3-linux.yml @@ -68,7 +68,7 @@ jobs: steps: - name: 'cache openssl' - uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + uses: actions/cache@a7833574556fa59680c1b7cb190c1735db73ebf0 # v5.0.0 id: cache-openssl-http3-no-deprecated env: cache-name: cache-openssl-http3-no-deprecated @@ -77,7 +77,7 @@ jobs: key: ${{ runner.os }}-http3-build-${{ env.cache-name }}-${{ env.OPENSSL_VERSION }} - name: 'cache libressl' - uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + uses: actions/cache@a7833574556fa59680c1b7cb190c1735db73ebf0 # v5.0.0 id: cache-libressl env: cache-name: cache-libressl @@ -86,7 +86,7 @@ jobs: key: ${{ runner.os }}-http3-build-${{ env.cache-name }}-${{ env.LIBRESSL_VERSION }} - name: 'cache awslc' - uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + uses: actions/cache@a7833574556fa59680c1b7cb190c1735db73ebf0 # v5.0.0 id: cache-awslc env: cache-name: cache-awslc @@ -95,7 +95,7 @@ jobs: key: ${{ runner.os }}-http3-build-${{ env.cache-name }}-${{ env.AWSLC_VERSION }} - name: 'cache boringssl' - uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + uses: actions/cache@a7833574556fa59680c1b7cb190c1735db73ebf0 # v5.0.0 id: cache-boringssl env: cache-name: cache-boringssl @@ -104,7 +104,7 @@ jobs: key: ${{ runner.os }}-http3-build-${{ env.cache-name }}-${{ env.BORINGSSL_VERSION }} - name: 'cache nettle' - uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + uses: actions/cache@a7833574556fa59680c1b7cb190c1735db73ebf0 # v5.0.0 id: cache-nettle env: cache-name: cache-nettle @@ -113,7 +113,7 @@ jobs: key: ${{ runner.os }}-http3-build-${{ env.cache-name }}-${{ env.NETTLE_VERSION }} - name: 'cache gnutls' - uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + uses: actions/cache@a7833574556fa59680c1b7cb190c1735db73ebf0 # v5.0.0 id: cache-gnutls env: cache-name: cache-gnutls @@ -122,7 +122,7 @@ jobs: key: ${{ runner.os }}-http3-build-${{ env.cache-name }}-${{ env.GNUTLS_VERSION }}-${{ env.NETTLE_VERSION }} - name: 'cache wolfssl' - uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + uses: actions/cache@a7833574556fa59680c1b7cb190c1735db73ebf0 # v5.0.0 id: cache-wolfssl env: cache-name: cache-wolfssl @@ -131,7 +131,7 @@ jobs: key: ${{ runner.os }}-http3-build-${{ env.cache-name }}-${{ env.WOLFSSL_VERSION }} - name: 'cache nghttp3' - uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + uses: actions/cache@a7833574556fa59680c1b7cb190c1735db73ebf0 # v5.0.0 id: cache-nghttp3 env: cache-name: cache-nghttp3 @@ -140,7 +140,7 @@ jobs: key: ${{ runner.os }}-http3-build-${{ env.cache-name }}-${{ env.NGHTTP3_VERSION }} - name: 'cache ngtcp2' - uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + uses: actions/cache@a7833574556fa59680c1b7cb190c1735db73ebf0 # v5.0.0 id: cache-ngtcp2 env: cache-name: cache-ngtcp2 @@ -149,7 +149,7 @@ jobs: key: ${{ runner.os }}-http3-build-${{ env.cache-name }}-${{ env.NGTCP2_VERSION }}-${{ env.OPENSSL_VERSION }}-${{ env.LIBRESSL_VERSION }}-${{ env.AWSLC_VERSION }}-${{ env.NETTLE_VERSION }}-${{ env.GNUTLS_VERSION }}-${{ env.WOLFSSL_VERSION }} - name: 'cache ngtcp2 boringssl' - uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + uses: actions/cache@a7833574556fa59680c1b7cb190c1735db73ebf0 # v5.0.0 id: cache-ngtcp2-boringssl env: cache-name: cache-ngtcp2-boringssl @@ -158,7 +158,7 @@ jobs: key: ${{ runner.os }}-http3-build-${{ env.cache-name }}-${{ env.NGTCP2_VERSION }}-${{ env.BORINGSSL_VERSION }} - name: 'cache nghttp2' - uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + uses: actions/cache@a7833574556fa59680c1b7cb190c1735db73ebf0 # v5.0.0 id: cache-nghttp2 env: cache-name: cache-nghttp2 @@ -486,7 +486,7 @@ jobs: echo 'CXX=g++-12' >> "$GITHUB_ENV" - name: 'cache openssl' - uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + uses: actions/cache@a7833574556fa59680c1b7cb190c1735db73ebf0 # v5.0.0 id: cache-openssl-http3-no-deprecated env: cache-name: cache-openssl-http3-no-deprecated @@ -496,7 +496,7 @@ jobs: fail-on-cache-miss: true - name: 'cache libressl' - uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + uses: actions/cache@a7833574556fa59680c1b7cb190c1735db73ebf0 # v5.0.0 id: cache-libressl env: cache-name: cache-libressl @@ -506,7 +506,7 @@ jobs: fail-on-cache-miss: true - name: 'cache awslc' - uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + uses: actions/cache@a7833574556fa59680c1b7cb190c1735db73ebf0 # v5.0.0 id: cache-awslc env: cache-name: cache-awslc @@ -516,7 +516,7 @@ jobs: fail-on-cache-miss: true - name: 'cache boringssl' - uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + uses: actions/cache@a7833574556fa59680c1b7cb190c1735db73ebf0 # v5.0.0 id: cache-boringssl env: cache-name: cache-boringssl @@ -527,7 +527,7 @@ jobs: - name: 'cache nettle' if: ${{ matrix.build.name == 'gnutls' }} - uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + uses: actions/cache@a7833574556fa59680c1b7cb190c1735db73ebf0 # v5.0.0 id: cache-nettle env: cache-name: cache-nettle @@ -538,7 +538,7 @@ jobs: - name: 'cache gnutls' if: ${{ matrix.build.name == 'gnutls' }} - uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + uses: actions/cache@a7833574556fa59680c1b7cb190c1735db73ebf0 # v5.0.0 id: cache-gnutls env: cache-name: cache-gnutls @@ -549,7 +549,7 @@ jobs: - name: 'cache wolfssl' if: ${{ matrix.build.name == 'wolfssl' }} - uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + uses: actions/cache@a7833574556fa59680c1b7cb190c1735db73ebf0 # v5.0.0 id: cache-wolfssl env: cache-name: cache-wolfssl @@ -559,7 +559,7 @@ jobs: fail-on-cache-miss: true - name: 'cache nghttp3' - uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + uses: actions/cache@a7833574556fa59680c1b7cb190c1735db73ebf0 # v5.0.0 id: cache-nghttp3 env: cache-name: cache-nghttp3 @@ -569,7 +569,7 @@ jobs: fail-on-cache-miss: true - name: 'cache ngtcp2' - uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + uses: actions/cache@a7833574556fa59680c1b7cb190c1735db73ebf0 # v5.0.0 id: cache-ngtcp2 env: cache-name: cache-ngtcp2 @@ -579,7 +579,7 @@ jobs: fail-on-cache-miss: true - name: 'cache ngtcp2 boringssl' - uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + uses: actions/cache@a7833574556fa59680c1b7cb190c1735db73ebf0 # v5.0.0 id: cache-ngtcp2-boringssl env: cache-name: cache-ngtcp2-boringssl @@ -589,7 +589,7 @@ jobs: fail-on-cache-miss: true - name: 'cache nghttp2' - uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + uses: actions/cache@a7833574556fa59680c1b7cb190c1735db73ebf0 # v5.0.0 id: cache-nghttp2 env: cache-name: cache-nghttp2 @@ -600,7 +600,7 @@ jobs: - name: 'cache quiche' if: ${{ matrix.build.name == 'quiche' }} - uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + uses: actions/cache@a7833574556fa59680c1b7cb190c1735db73ebf0 # v5.0.0 id: cache-quiche env: cache-name: cache-quiche diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 2bcdf4e223ba..3a9c35fe385c 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -399,7 +399,7 @@ jobs: - name: 'cache libressl' if: ${{ contains(matrix.build.install_steps, 'libressl') }} - uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + uses: actions/cache@a7833574556fa59680c1b7cb190c1735db73ebf0 # v5.0.0 id: cache-libressl env: cache-name: cache-libressl @@ -419,7 +419,7 @@ jobs: - name: 'cache libressl (filc)' if: ${{ contains(matrix.build.install_steps, 'libressl-filc') }} - uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + uses: actions/cache@a7833574556fa59680c1b7cb190c1735db73ebf0 # v5.0.0 id: cache-libressl-filc env: cache-name: cache-libressl-filc @@ -440,7 +440,7 @@ jobs: - name: 'cache nghttp2 (filc)' if: ${{ contains(matrix.build.install_steps, 'nghttp2-filc') }} - uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + uses: actions/cache@a7833574556fa59680c1b7cb190c1735db73ebf0 # v5.0.0 id: cache-nghttp2-filc env: cache-name: cache-nghttp2-filc @@ -462,7 +462,7 @@ jobs: - name: 'cache wolfssl (all)' if: ${{ contains(matrix.build.install_steps, 'wolfssl-all') }} - uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + uses: actions/cache@a7833574556fa59680c1b7cb190c1735db73ebf0 # v5.0.0 id: cache-wolfssl-all env: cache-name: cache-wolfssl-all @@ -483,7 +483,7 @@ jobs: - name: 'cache wolfssl (opensslextra)' # does support `OPENSSL_COEXIST` if: ${{ contains(matrix.build.install_steps, 'wolfssl-opensslextra') }} - uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + uses: actions/cache@a7833574556fa59680c1b7cb190c1735db73ebf0 # v5.0.0 id: cache-wolfssl-opensslextra env: cache-name: cache-wolfssl-opensslextra @@ -504,7 +504,7 @@ jobs: - name: 'cache mbedtls' if: ${{ contains(matrix.build.install_steps, 'mbedtls') }} - uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + uses: actions/cache@a7833574556fa59680c1b7cb190c1735db73ebf0 # v5.0.0 id: cache-mbedtls-threadsafe env: cache-name: cache-mbedtls-threadsafe @@ -527,7 +527,7 @@ jobs: - name: 'cache mbedtls (prev)' if: ${{ contains(matrix.build.install_steps, 'mbedtls-prev') }} - uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + uses: actions/cache@a7833574556fa59680c1b7cb190c1735db73ebf0 # v5.0.0 id: cache-mbedtls-threadsafe-prev env: cache-name: cache-mbedtls-threadsafe-prev @@ -550,7 +550,7 @@ jobs: - name: 'cache openldap (static)' if: ${{ contains(matrix.build.install_steps, 'openldap-static') }} - uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + uses: actions/cache@a7833574556fa59680c1b7cb190c1735db73ebf0 # v5.0.0 id: cache-openldap-static env: cache-name: cache-openldap-static @@ -569,7 +569,7 @@ jobs: - name: 'cache openssl (thread sanitizer)' if: ${{ contains(matrix.build.install_steps, 'openssl-tsan') }} - uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + uses: actions/cache@a7833574556fa59680c1b7cb190c1735db73ebf0 # v5.0.0 id: cache-openssl-tsan env: cache-name: cache-openssl-tsan @@ -588,7 +588,7 @@ jobs: - name: 'cache awslc' if: ${{ contains(matrix.build.install_steps, 'awslc') }} - uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + uses: actions/cache@a7833574556fa59680c1b7cb190c1735db73ebf0 # v5.0.0 id: cache-awslc env: cache-name: cache-awslc @@ -608,7 +608,7 @@ jobs: - name: 'cache boringssl' if: ${{ contains(matrix.build.install_steps, 'boringssl') }} - uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + uses: actions/cache@a7833574556fa59680c1b7cb190c1735db73ebf0 # v5.0.0 id: cache-boringssl env: cache-name: cache-boringssl @@ -629,7 +629,7 @@ jobs: - name: 'cache rustls' if: ${{ contains(matrix.build.install_steps, 'rustls') }} - uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + uses: actions/cache@a7833574556fa59680c1b7cb190c1735db73ebf0 # v5.0.0 id: cache-rustls env: cache-name: cache-rustls diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 25ac41c61ee1..8ed4ef14eab2 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -112,7 +112,7 @@ jobs: - name: 'cache libressl' if: ${{ contains(matrix.build.install_steps, 'libressl') }} - uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + uses: actions/cache@a7833574556fa59680c1b7cb190c1735db73ebf0 # v5.0.0 id: cache-libressl env: cache-name: cache-libressl diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 9d7f0dc88d32..d3d3de8522da 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -480,7 +480,7 @@ jobs: ${{ matrix.install }} - name: 'cache compiler (gcc ${{ matrix.ver }}-${{ matrix.env }})' - uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + uses: actions/cache@a7833574556fa59680c1b7cb190c1735db73ebf0 # v5.0.0 id: cache-compiler with: path: D:\my-cache From fe8393d7db8c9c708f7dc45e5ee3b2c1eb9d979a Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Sun, 7 Dec 2025 16:49:55 +0100 Subject: [PATCH 296/415] tidy-up: miscellaneous - drop stray duplicate empty lines in docs, scripts, test data, include, examples, tests. - drop duplicate PP parenthesis. - curl-functions.m4: move literals to the right side in if expressions, to match rest of the source code. - FAQ.md: delete language designator from an URL. - packages: apply clang-format (OS400, VMS). - scripts/schemetable.c: apply clang-format. - data320: delete duplicate empty line that doesn't change the outcome. - spacecheck: extend to check for duplicate empty lines (with exceptions.) - fix whitespace nits Closes #19936 --- .github/scripts/cmp-config.pl | 1 - .github/scripts/randcurl.pl | 1 - .github/scripts/spacecheck.pl | 26 +- .github/scripts/verify-synopsis.pl | 1 - .github/workflows/macos.yml | 2 +- CMake/CurlTests.c | 19 +- CMakeLists.txt | 1 - acinclude.m4 | 2 +- configure.ac | 9 - docs/FAQ.md | 3 +- docs/MANUAL.md | 1 - docs/SSLCERTS.md | 1 - docs/TODO.md | 1 - docs/TheArtOfHttpScripting.md | 1 - docs/examples/ephiperfifo.c | 1 - docs/examples/evhiperfifo.c | 1 - docs/examples/ghiper.c | 1 - docs/examples/hiperfifo.c | 1 - docs/examples/htmltitle.cpp | 4 +- docs/examples/http2-upload.c | 2 +- docs/examples/postit2-formadd.c | 1 - docs/libcurl/curl_easy_getinfo.md | 1 - include/curl/curl.h | 38 +-- include/curl/easy.h | 2 - include/curl/multi.h | 94 +++--- include/curl/typecheck-gcc.h | 7 +- lib/cf-https-connect.h | 1 - lib/cfilters.h | 1 - lib/config-os400.h | 1 - lib/curl_hmac.h | 1 - lib/curl_memrchr.h | 2 +- lib/curl_setup_once.h | 1 - lib/curl_trc.h | 1 - lib/cw-pause.h | 1 - lib/dynhds.h | 1 - lib/functypes.h | 1 - lib/hostip.h | 1 - lib/http.h | 1 - lib/ldap.c | 2 +- lib/optiontable.pl | 2 - lib/setup-os400.h | 4 - lib/urldata.h | 1 - lib/vquic/vquic.h | 1 - lib/vtls/gtls.c | 2 +- lib/vtls/x509asn1.c | 2 +- m4/curl-amissl.m4 | 3 +- m4/curl-functions.m4 | 162 +++++----- packages/OS400/ccsidcurl.c | 420 +++++++++++--------------- packages/OS400/ccsidcurl.h | 1 - packages/OS400/curlcl.c | 25 +- packages/OS400/curlmain.c | 14 +- packages/OS400/os400sys.c | 255 +++++++--------- packages/OS400/os400sys.h | 35 +-- packages/vms/curl_crtl_init.c | 56 ++-- packages/vms/curlmsg.h | 170 +++++------ packages/vms/report_openssl_version.c | 15 +- scripts/cd2cd | 1 - scripts/checksrc.pl | 1 - scripts/ciconfig.pl | 2 - scripts/delta | 2 +- scripts/firefox-db2pem.sh | 1 - scripts/managen | 3 - scripts/mk-ca-bundle.pl | 1 - scripts/schemetable.c | 85 +++--- src/tool_parsecfg.c | 1 - tests/appveyor.pm | 1 - tests/data/data320.html | 1 - tests/data/test1109 | 1 - tests/data/test1110 | 1 - tests/data/test1111 | 1 - tests/data/test1331 | 2 - tests/data/test1408 | 2 - tests/data/test1409 | 1 - tests/data/test1410 | 1 - tests/data/test1411 | 1 - tests/data/test161 | 1 - tests/data/test2030 | 1 - tests/data/test2045 | 1 - tests/data/test206 | 1 - tests/data/test2202 | 1 - tests/data/test228 | 1 - tests/data/test3105 | 1 - tests/data/test399 | 1 - tests/data/test698 | 1 - tests/devtest.pl | 3 - tests/directories.pm | 1 - tests/getpart.pm | 11 +- tests/globalconfig.pm | 1 - tests/libtest/cli_ftp_upload.c | 5 +- tests/libtest/lib651.c | 1 - tests/libtest/mk-lib1521.pl | 2 - tests/libtest/unitcheck.h | 1 + tests/negtelnetserver.py | 11 - tests/pathhelp.pm | 1 - tests/processhelp.pm | 3 - tests/runner.pm | 15 - tests/runtests.pl | 23 +- tests/serverhelp.pm | 16 - tests/servers.pm | 13 - tests/smbserver.py | 1 - tests/sshhelp.pm | 23 -- tests/sshserver.pl | 34 --- tests/test1119.pl | 1 - tests/test1139.pl | 2 - tests/test1140.pl | 3 - tests/test1165.pl | 1 - tests/test1167.pl | 1 - tests/test1173.pl | 2 - tests/test1222.pl | 4 +- tests/test1275.pl | 1 - tests/test1477.pl | 1 - tests/testcurl.pl | 1 - tests/testutil.pm | 2 - tests/unit/unit1397.c | 4 +- tests/util.py | 3 - tests/valgrind.pm | 1 - 116 files changed, 675 insertions(+), 1040 deletions(-) diff --git a/.github/scripts/cmp-config.pl b/.github/scripts/cmp-config.pl index 3ad0570e2839..a74389637f16 100755 --- a/.github/scripts/cmp-config.pl +++ b/.github/scripts/cmp-config.pl @@ -136,6 +136,5 @@ sub grepit { } } - # return the exit code from diff exit system("diff -u /tmp/autotools /tmp/cmake") >> 8; diff --git a/.github/scripts/randcurl.pl b/.github/scripts/randcurl.pl index b085d2ef13d5..f9c24d90db6c 100755 --- a/.github/scripts/randcurl.pl +++ b/.github/scripts/randcurl.pl @@ -116,7 +116,6 @@ sub randarg { '26' => 1, ); - sub runone { my $a; my $nargs = getnum(60) + 1; diff --git a/.github/scripts/spacecheck.pl b/.github/scripts/spacecheck.pl index 2c3a2e3b0a61..f06766570c75 100755 --- a/.github/scripts/spacecheck.pl +++ b/.github/scripts/spacecheck.pl @@ -39,6 +39,13 @@ "\\.(bat|sln)\$", ); +my @double_empty_lines = ( + "^lib/.+\\.(c|h)\$", + "^packages/", + "^tests/data/test", + "\\.(m4|py)\$", +); + my @non_ascii_allowed = ( '\xC3\xB6', # UTF-8 for https://codepoints.net/U+00F6 LATIN SMALL LETTER O WITH DIAERESIS ); @@ -100,7 +107,7 @@ sub eol_detect { my @err = (); if(!fn_match($filename, @tabs) && - $content =~ /\t/) { + $content =~ /\t/) { push @err, "content: has tab"; } @@ -111,12 +118,12 @@ sub eol_detect { } if($eol ne "crlf" && - fn_match($filename, @need_crlf)) { + fn_match($filename, @need_crlf)) { push @err, "content: must use CRLF EOL for this file type"; } if($eol ne "lf" && $content ne "" && - !fn_match($filename, @need_crlf)) { + !fn_match($filename, @need_crlf)) { push @err, "content: must use LF EOL for this file type"; } @@ -131,20 +138,27 @@ sub eol_detect { } if($content ne "" && - $content !~ /\n\z/) { + $content !~ /\n\z/) { push @err, "content: has no EOL at EOF"; } if($content =~ /\n\n\z/ || - $content =~ /\r\n\r\n\z/) { + $content =~ /\r\n\r\n\z/) { push @err, "content: has multiple EOL at EOF"; } if($content =~ /\n\n\n\n/ || - $content =~ /\r\n\r\n\r\n\r\n/) { + $content =~ /\r\n\r\n\r\n\r\n/) { push @err, "content: has 3 or more consecutive empty lines"; } + if(!fn_match($filename, @double_empty_lines)) { + if($content =~ /\n\n\n/ || + $content =~ /\r\n\r\n\r\n/) { + push @err, "content: has 2 consecutive empty lines"; + } + } + if($content =~ /([\x00-\x08\x0b\x0c\x0e-\x1f\x7f])/) { push @err, "content: has binary contents"; } diff --git a/.github/scripts/verify-synopsis.pl b/.github/scripts/verify-synopsis.pl index 1c6b00b60bd1..19fbc31a7c81 100755 --- a/.github/scripts/verify-synopsis.pl +++ b/.github/scripts/verify-synopsis.pl @@ -39,7 +39,6 @@ sub testcompile { return $rc; } - sub extract { my($f) = @_; my $syn = 0; diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 8ed4ef14eab2..cae51f5f7ec7 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -618,7 +618,7 @@ jobs: - name: 'configure / ${{ matrix.build }}' run: | - if [ "${MATRIX_COMPILER}" = 'gcc-13' ] && [ "${MATRIX_IMAGE}" = 'macos-15' ] ; then + if [ "${MATRIX_COMPILER}" = 'gcc-13' ] && [ "${MATRIX_IMAGE}" = 'macos-15' ]; then # Ref: https://github.com/Homebrew/homebrew-core/issues/194778#issuecomment-2793243409 /opt/homebrew/opt/gcc@13/libexec/gcc/aarch64-apple-darwin24/13/install-tools/mkheaders fi diff --git a/CMake/CurlTests.c b/CMake/CurlTests.c index 40fa50fe83dc..a06c7701f57b 100644 --- a/CMake/CurlTests.c +++ b/CMake/CurlTests.c @@ -29,7 +29,7 @@ #include /* */ #if defined(sun) || defined(__sun__) || \ - defined(__SUNPRO_C) || defined(__SUNPRO_CC) + defined(__SUNPRO_C) || defined(__SUNPRO_CC) # if defined(__SVR4) || defined(__srv4__) # define PLATFORM_SOLARIS # else @@ -119,7 +119,10 @@ int main(void) #include #include #include -int main(void) { return 0; } +int main(void) +{ + return 0; +} #endif #ifdef HAVE_FILE_OFFSET_BITS @@ -128,7 +131,7 @@ int main(void) { return 0; } We cannot simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) +#define LARGE_OFF_T (((off_t)1 << 62) - 1 + ((off_t)1 << 62)) static int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; @@ -272,7 +275,10 @@ int main(void) #include #include -static void check(char c) { (void)c; } +static void check(char c) +{ + (void)c; +} int main(void) { @@ -289,7 +295,10 @@ int main(void) #include /* Float, because a pointer cannot be implicitly cast to float */ -static void check(float f) { (void)f; } +static void check(float f) +{ + (void)f; +} int main(void) { diff --git a/CMakeLists.txt b/CMakeLists.txt index 8b3cbecc51f0..af3d1f88464e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1833,7 +1833,6 @@ if(CURL_LTO) endif() endif() - # Ugly (but functional) way to include "Makefile.inc" by transforming it # (= regenerate it). function(curl_transform_makefile_inc _input_file _output_file) diff --git a/acinclude.m4 b/acinclude.m4 index d95cbd3f5b6d..f38eac821107 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -769,7 +769,7 @@ AC_DEFUN([CURL_CHECK_STRUCT_TIMEVAL], [ #include ]],[[ struct timeval ts; - ts.tv_sec = 0; + ts.tv_sec = 0; ts.tv_usec = 0; (void)ts; ]]) diff --git a/configure.ac b/configure.ac index 3c0bfaa3531f..e465ee6a8aef 100644 --- a/configure.ac +++ b/configure.ac @@ -520,7 +520,6 @@ if test "$xc_lt_build_static_only" = "yes"; then fi AC_SUBST([LIBCURL_PC_CFLAGS]) - dnl ********************************************************************** dnl platform/compiler/architecture specific checks/flags dnl ********************************************************************** @@ -2152,7 +2151,6 @@ if test "x$OPT_LIBPSL" != "xno"; then fi AM_CONDITIONAL([USE_LIBPSL], [test "$curl_psl_msg" = "enabled"]) - dnl ********************************************************************** dnl Check for libgsasl dnl ********************************************************************** @@ -2236,7 +2234,6 @@ AS_HELP_STRING([--with-libssh2=PATH],[Where to look for libssh2, PATH points to AS_HELP_STRING([--with-libssh2], [enable libssh2]), OPT_LIBSSH2=$withval, OPT_LIBSSH2=no) - OPT_LIBSSH=off AC_ARG_WITH(libssh,dnl AS_HELP_STRING([--with-libssh=PATH],[Where to look for libssh, PATH points to the libssh installation; when possible, set the PKG_CONFIG_PATH environment variable instead of using this option]) @@ -2619,7 +2616,6 @@ if test "x$OPT_LIBRTMP" != "xno"; then dnl a pkgconfig file AC_MSG_ERROR([--librtmp was specified but could not find librtmp pkgconfig file.]) fi - ;; off) dnl no --with-librtmp option given, just check default places @@ -3685,7 +3681,6 @@ if test "$want_nghttp3" != "no"; then CPPFLAGS=$CLEANCPPFLAGS LIBS=$CLEANLIBS ) - else dnl no nghttp3 pkg-config found, deal with it if test "$want_nghttp3" != "default"; then @@ -3898,7 +3893,6 @@ if test "$want_libuv" != "no"; then CPPFLAGS=$CLEANCPPFLAGS LIBS=$CLEANLIBS ) - else dnl no libuv pkg-config found, deal with it if test "$want_libuv" != "default"; then @@ -4042,7 +4036,6 @@ dnl default includes ] ) - dnl Checks for typedefs, structures, and compiler characteristics. AC_C_CONST AC_TYPE_SIZE_T @@ -4977,7 +4970,6 @@ if test "$hsts" != "yes"; then AC_DEFINE(CURL_DISABLE_HSTS, 1, [disable alt-svc]) fi - dnl ************************************************************* dnl check whether ECH support, if desired, is actually available dnl @@ -5042,7 +5034,6 @@ else fi fi - dnl ************************************************************* dnl check whether OpenSSL (lookalikes) have SSL_set0_wbio dnl diff --git a/docs/FAQ.md b/docs/FAQ.md index eba30f1fefd5..0febe1b73ca6 100644 --- a/docs/FAQ.md +++ b/docs/FAQ.md @@ -827,7 +827,6 @@ chain. Details are also in [the SSL certificates document](https://curl.se/docs/sslcerts.html). - ## Why is curl -R on Windows one hour off? Since curl 7.53.0 this issue should be fixed as long as curl was built with @@ -891,7 +890,7 @@ the second. No more than three packets are sent, no matter how long the timeout is set. See option `TcpMaxConnectRetransmissions` on [this -page](https://support.microsoft.com/bg-bg/topic/hotfix-enables-the-configuration-of-the-tcp-maximum-syn-retransmission-amount-in-windows-7-or-windows-server-2008-r2-1b6f8352-2c5f-58bb-ead7-2cf021407c8e). +page](https://support.microsoft.com/topic/hotfix-enables-the-configuration-of-the-tcp-maximum-syn-retransmission-amount-in-windows-7-or-windows-server-2008-r2-1b6f8352-2c5f-58bb-ead7-2cf021407c8e). Also, even on non-Windows systems there may run a firewall or anti-virus software or similar that accepts the connection but does not actually do diff --git a/docs/MANUAL.md b/docs/MANUAL.md index 1acb4d2244e2..c52e231bdc47 100644 --- a/docs/MANUAL.md +++ b/docs/MANUAL.md @@ -276,7 +276,6 @@ this: curl --trace my-trace.txt www.haxx.se - ## Detailed Information Different protocols provide different ways of getting detailed information diff --git a/docs/SSLCERTS.md b/docs/SSLCERTS.md index de3954553421..3506fbd787d1 100644 --- a/docs/SSLCERTS.md +++ b/docs/SSLCERTS.md @@ -133,7 +133,6 @@ Apple SecTrust and your own file to be considered, use: curl --ca-native --cacert mycerts.pem https://example.com - #### Other Combinations How well the use of native CA stores work in all other combinations depends diff --git a/docs/TODO.md b/docs/TODO.md index 0224ae87332c..3d2eec531268 100644 --- a/docs/TODO.md +++ b/docs/TODO.md @@ -398,7 +398,6 @@ honest a bit of a hack. Please see the following thread for more information: https://curl.se/mail/lib-2012-05/0178.html - # POP3 ## Enhanced capability support diff --git a/docs/TheArtOfHttpScripting.md b/docs/TheArtOfHttpScripting.md index ab4961c5781c..bab52cca47b3 100644 --- a/docs/TheArtOfHttpScripting.md +++ b/docs/TheArtOfHttpScripting.md @@ -198,7 +198,6 @@ SPDX-License-Identifier: curl curl --data name=curl https://url1.example.com https://url2.example.com - ## Multiple HTTP methods in a single command line Sometimes you need to operate on several URLs in a single command line and do diff --git a/docs/examples/ephiperfifo.c b/docs/examples/ephiperfifo.c index cafea9693fe4..14a381753851 100644 --- a/docs/examples/ephiperfifo.c +++ b/docs/examples/ephiperfifo.c @@ -41,7 +41,6 @@ Whenever there is input into the fifo, the program reads the input as a list of URL's and creates some new easy handles to fetch each URL via the curl_multi "hiper" API. - Thus, you can try a single URL: % echo http://www.yahoo.com > hiper.fifo diff --git a/docs/examples/evhiperfifo.c b/docs/examples/evhiperfifo.c index 922197c3cb5a..46cfc0a85937 100644 --- a/docs/examples/evhiperfifo.c +++ b/docs/examples/evhiperfifo.c @@ -44,7 +44,6 @@ Whenever there is input into the fifo, the program reads the input as a list of URL's and creates some new easy handles to fetch each URL via the curl_multi "hiper" API. - Thus, you can try a single URL: % echo http://www.yahoo.com > hiper.fifo diff --git a/docs/examples/ghiper.c b/docs/examples/ghiper.c index 8f320a6e5fae..b3e080355098 100644 --- a/docs/examples/ghiper.c +++ b/docs/examples/ghiper.c @@ -41,7 +41,6 @@ of URL's and creates some new easy handles to fetch each URL via the curl_multi "hiper" API. - Thus, you can try a single URL: % echo http://www.yahoo.com > hiper.fifo diff --git a/docs/examples/hiperfifo.c b/docs/examples/hiperfifo.c index 7b17731ebfb5..79af5268c830 100644 --- a/docs/examples/hiperfifo.c +++ b/docs/examples/hiperfifo.c @@ -41,7 +41,6 @@ Whenever there is input into the fifo, the program reads the input as a list of URL's and creates some new easy handles to fetch each URL via the curl_multi "hiper" API. - Thus, you can try a single URL: % echo http://www.yahoo.com > hiper.fifo diff --git a/docs/examples/htmltitle.cpp b/docs/examples/htmltitle.cpp index ac351a8bf5f7..4d698f253c13 100644 --- a/docs/examples/htmltitle.cpp +++ b/docs/examples/htmltitle.cpp @@ -46,9 +46,9 @@ // #ifdef _WIN32 -#define COMPARE(a, b) (!_stricmp((a), (b))) +#define COMPARE(a, b) (!_stricmp(a, b)) #else -#define COMPARE(a, b) (!strcasecmp((a), (b))) +#define COMPARE(a, b) (!strcasecmp(a, b)) #endif // diff --git a/docs/examples/http2-upload.c b/docs/examples/http2-upload.c index 8ed6568542a1..7becf5116926 100644 --- a/docs/examples/http2-upload.c +++ b/docs/examples/http2-upload.c @@ -67,7 +67,7 @@ #endif #ifdef _MSC_VER -#define gettimeofday(a, b) my_gettimeofday((a), (b)) +#define gettimeofday(a, b) my_gettimeofday(a, b) static int my_gettimeofday(struct timeval *tp, void *tzp) { (void)tzp; diff --git a/docs/examples/postit2-formadd.c b/docs/examples/postit2-formadd.c index 086cae0e51b9..7e5f08ef6617 100644 --- a/docs/examples/postit2-formadd.c +++ b/docs/examples/postit2-formadd.c @@ -74,7 +74,6 @@ int main(int argc, char *argv[]) CURLFORM_COPYCONTENTS, "postit2-formadd.c", CURLFORM_END); - /* Fill in the submit field too, even if this is rarely needed */ curl_formadd(&formpost, &lastptr, diff --git a/docs/libcurl/curl_easy_getinfo.md b/docs/libcurl/curl_easy_getinfo.md index 9515fadeed2c..e05beb614e08 100644 --- a/docs/libcurl/curl_easy_getinfo.md +++ b/docs/libcurl/curl_easy_getinfo.md @@ -398,7 +398,6 @@ An overview of the time values available from curl_easy_getinfo(3) |--|--|--|--|--|--|--|--TOTAL |--|--|--|--|--|--|--|--REDIRECT - CURLINFO_QUEUE_TIME_T(3), CURLINFO_NAMELOOKUP_TIME_T(3), CURLINFO_CONNECT_TIME_T(3), CURLINFO_APPCONNECT_TIME_T(3), CURLINFO_PRETRANSFER_TIME_T(3), CURLINFO_POSTTRANSFER_TIME_T(3), diff --git a/include/curl/curl.h b/include/curl/curl.h index 9e07527dc9c4..250f3f679aab 100644 --- a/include/curl/curl.h +++ b/include/curl/curl.h @@ -229,7 +229,6 @@ struct curl_httppost { set. Added in 7.46.0 */ }; - /* This is a return code for the progress callback that, when returned, will signal libcurl to continue executing the default progress function */ #define CURL_PROGRESSFUNC_CONTINUE 0x10000001 @@ -844,7 +843,7 @@ typedef enum { #define CURLAUTH_AWS_SIGV4 (((unsigned long)1)<<7) #define CURLAUTH_ONLY (((unsigned long)1)<<31) #define CURLAUTH_ANY (~CURLAUTH_DIGEST_IE) -#define CURLAUTH_ANYSAFE (~(CURLAUTH_BASIC|CURLAUTH_DIGEST_IE)) +#define CURLAUTH_ANYSAFE (~(CURLAUTH_BASIC | CURLAUTH_DIGEST_IE)) #define CURLSSH_AUTH_ANY ~0L /* all types supported by the server */ #define CURLSSH_AUTH_NONE 0L /* none allowed, silly but complete */ @@ -916,7 +915,6 @@ typedef int /* return CURLE_OK to accept */ /* or something else to refuse */ - /* parameter for the CURLOPT_USE_SSL option */ #define CURLUSESSL_NONE 0L /* do not attempt to use SSL */ #define CURLUSESSL_TRY 1L /* try using SSL, proceed anyway otherwise */ @@ -1115,7 +1113,6 @@ typedef CURLSTScode (*curl_hstswrite_callback)(CURL *easy, /* *STRINGPOINT is an alias for OBJECTPOINT to allow tools to extract the string options from the header file */ - #define CURLOPT(na,t,nu) na = t + nu #define CURLOPTDEPRECATED(na,t,nu,v,m) na CURL_DEPRECATED(v,m) = t + nu @@ -1874,9 +1871,7 @@ typedef enum { libcurl will ask for the compressed methods it knows of, and if that is not any, it will not ask for transfer-encoding at all even if this - option is set to 1. - - */ + option is set to 1. */ CURLOPT(CURLOPT_TRANSFER_ENCODING, CURLOPTTYPE_LONG, 207), /* Callback function for closing socket (instead of close(2)). The callback @@ -2294,10 +2289,9 @@ typedef enum { #undef CURLOPT_DNS_USE_GLOBAL_CACHE /* soon obsolete */ #endif - - /* Below here follows defines for the CURLOPT_IPRESOLVE option. If a host - name resolves addresses using more than one IP protocol version, this - option might be handy to force libcurl to use a specific IP version. */ +/* Below here follows defines for the CURLOPT_IPRESOLVE option. If a host + name resolves addresses using more than one IP protocol version, this + option might be handy to force libcurl to use a specific IP version. */ #define CURL_IPRESOLVE_WHATEVER 0L /* default, uses addresses to all IP versions that your system allows */ #define CURL_IPRESOLVE_V4 1L /* uses only IPv4 addresses/connections */ @@ -2381,7 +2375,7 @@ enum CURL_NETRC_OPTION { #define CURL_SSLVERSION_MAX_TLSv1_2 (CURL_SSLVERSION_TLSv1_2 << 16) #define CURL_SSLVERSION_MAX_TLSv1_3 (CURL_SSLVERSION_TLSv1_3 << 16) - /* never use, keep last */ +/* never use, keep last */ #define CURL_SSLVERSION_MAX_LAST (CURL_SSLVERSION_LAST << 16) #define CURL_TLSAUTH_NONE 0L @@ -2403,7 +2397,7 @@ enum CURL_TLSAUTH { #define CURL_REDIR_POST_302 2L #define CURL_REDIR_POST_303 4L #define CURL_REDIR_POST_ALL \ - (CURL_REDIR_POST_301|CURL_REDIR_POST_302|CURL_REDIR_POST_303) + (CURL_REDIR_POST_301 | CURL_REDIR_POST_302 | CURL_REDIR_POST_303) #define CURL_TIMECOND_NONE 0L #define CURL_TIMECOND_IFMODSINCE 1L @@ -2418,7 +2412,7 @@ typedef enum { } curl_TimeCond; /* Special size_t value signaling a null-terminated string. */ -#define CURL_ZERO_TERMINATED ((size_t) -1) +#define CURL_ZERO_TERMINATED ((size_t)-1) /* curl_strequal() and curl_strnequal() are subject for removal in a future release */ @@ -2705,7 +2699,6 @@ CURL_EXTERN char *curl_easy_escape(CURL *handle, CURL_EXTERN char *curl_escape(const char *string, int length); - /* * NAME curl_easy_unescape() * @@ -2743,10 +2736,9 @@ CURL_EXTERN void curl_free(void *p); * * curl_global_init() should be invoked exactly once for each application that * uses libcurl and before any call of other libcurl functions. - + * * This function is thread-safe if CURL_VERSION_THREADSAFE is set in the * curl_version_info_data.features flag (fetch by curl_version_info()). - */ CURL_EXTERN CURLcode curl_global_init(long flags); @@ -2787,10 +2779,9 @@ CURL_EXTERN void curl_global_cleanup(void); * * curl_global_trace() can be invoked at application start to * configure which components in curl should participate in tracing. - + * * This function is thread-safe if CURL_VERSION_THREADSAFE is set in the * curl_version_info_data.features flag (fetch by curl_version_info()). - */ CURL_EXTERN CURLcode curl_global_trace(const char *config); @@ -3017,12 +3008,11 @@ typedef enum { #define CURL_GLOBAL_SSL (1<<0) /* no purpose since 7.57.0 */ #define CURL_GLOBAL_WIN32 (1<<1) -#define CURL_GLOBAL_ALL (CURL_GLOBAL_SSL|CURL_GLOBAL_WIN32) +#define CURL_GLOBAL_ALL (CURL_GLOBAL_SSL | CURL_GLOBAL_WIN32) #define CURL_GLOBAL_NOTHING 0 #define CURL_GLOBAL_DEFAULT CURL_GLOBAL_ALL #define CURL_GLOBAL_ACK_EINTR (1<<2) - /***************************************************************************** * Setup defines, protos etc for the sharing stuff. */ @@ -3060,7 +3050,6 @@ typedef void (*curl_unlock_function)(CURL *handle, curl_lock_data data, void *userptr); - typedef enum { CURLSHE_OK, /* all is fine */ CURLSHE_BAD_OPTION, /* 1 */ @@ -3264,8 +3253,8 @@ CURL_EXTERN CURLcode curl_easy_pause(CURL *handle, int bitmask); #define CURLPAUSE_SEND (1<<2) #define CURLPAUSE_SEND_CONT (0) -#define CURLPAUSE_ALL (CURLPAUSE_RECV|CURLPAUSE_SEND) -#define CURLPAUSE_CONT (CURLPAUSE_RECV_CONT|CURLPAUSE_SEND_CONT) +#define CURLPAUSE_ALL (CURLPAUSE_RECV | CURLPAUSE_SEND) +#define CURLPAUSE_CONT (CURLPAUSE_RECV_CONT | CURLPAUSE_SEND_CONT) /* * NAME curl_easy_ssls_import() @@ -3310,7 +3299,6 @@ CURL_EXTERN CURLcode curl_easy_ssls_export(CURL *handle, curl_ssls_export_cb *export_fn, void *userptr); - #ifdef __cplusplus } /* end of extern "C" */ #endif diff --git a/include/curl/easy.h b/include/curl/easy.h index 8a1d68dfd8b9..85cfd830f7e2 100644 --- a/include/curl/easy.h +++ b/include/curl/easy.h @@ -58,7 +58,6 @@ CURL_EXTERN void curl_easy_cleanup(CURL *curl); */ CURL_EXTERN CURLcode curl_easy_getinfo(CURL *curl, CURLINFO info, ...); - /* * NAME curl_easy_duphandle() * @@ -108,7 +107,6 @@ CURL_EXTERN CURLcode curl_easy_recv(CURL *curl, void *buffer, size_t buflen, CURL_EXTERN CURLcode curl_easy_send(CURL *curl, const void *buffer, size_t buflen, size_t *n); - /* * NAME curl_easy_upkeep() * diff --git a/include/curl/multi.h b/include/curl/multi.h index e307b98f4c25..f3f66030ca25 100644 --- a/include/curl/multi.h +++ b/include/curl/multi.h @@ -136,25 +136,25 @@ CURL_EXTERN CURLM *curl_multi_init(void); CURL_EXTERN CURLMcode curl_multi_add_handle(CURLM *multi_handle, CURL *curl_handle); - /* - * Name: curl_multi_remove_handle() - * - * Desc: removes a curl handle from the multi stack again - * - * Returns: CURLMcode type, general multi error code. - */ +/* + * Name: curl_multi_remove_handle() + * + * Desc: removes a curl handle from the multi stack again + * + * Returns: CURLMcode type, general multi error code. + */ CURL_EXTERN CURLMcode curl_multi_remove_handle(CURLM *multi_handle, CURL *curl_handle); - /* - * Name: curl_multi_fdset() - * - * Desc: Ask curl for its fd_set sets. The app can use these to select() or - * poll() on. We want curl_multi_perform() called as soon as one of - * them are ready. - * - * Returns: CURLMcode type, general multi error code. - */ +/* + * Name: curl_multi_fdset() + * + * Desc: Ask curl for its fd_set sets. The app can use these to select() or + * poll() on. We want curl_multi_perform() called as soon as one of + * them are ready. + * + * Returns: CURLMcode type, general multi error code. + */ CURL_EXTERN CURLMcode curl_multi_fdset(CURLM *multi_handle, fd_set *read_fd_set, fd_set *write_fd_set, @@ -198,35 +198,35 @@ CURL_EXTERN CURLMcode curl_multi_poll(CURLM *multi_handle, */ CURL_EXTERN CURLMcode curl_multi_wakeup(CURLM *multi_handle); - /* - * Name: curl_multi_perform() - * - * Desc: When the app thinks there is data available for curl it calls this - * function to read/write whatever there is right now. This returns - * as soon as the reads and writes are done. This function does not - * require that there actually is data available for reading or that - * data can be written, it can be called just in case. It returns - * the number of handles that still transfer data in the second - * argument's integer-pointer. - * - * Returns: CURLMcode type, general multi error code. *NOTE* that this only - * returns errors etc regarding the whole multi stack. There might - * still have occurred problems on individual transfers even when - * this returns OK. - */ +/* + * Name: curl_multi_perform() + * + * Desc: When the app thinks there is data available for curl it calls this + * function to read/write whatever there is right now. This returns + * as soon as the reads and writes are done. This function does not + * require that there actually is data available for reading or that + * data can be written, it can be called just in case. It returns + * the number of handles that still transfer data in the second + * argument's integer-pointer. + * + * Returns: CURLMcode type, general multi error code. *NOTE* that this only + * returns errors etc regarding the whole multi stack. There might + * still have occurred problems on individual transfers even when + * this returns OK. + */ CURL_EXTERN CURLMcode curl_multi_perform(CURLM *multi_handle, int *running_handles); - /* - * Name: curl_multi_cleanup() - * - * Desc: Cleans up and removes a whole multi stack. It does not free or - * touch any individual easy handles in any way. We need to define - * in what state those handles will be if this function is called - * in the middle of a transfer. - * - * Returns: CURLMcode type, general multi error code. - */ +/* + * Name: curl_multi_cleanup() + * + * Desc: Cleans up and removes a whole multi stack. It does not free or + * touch any individual easy handles in any way. We need to define + * in what state those handles will be if this function is called + * in the middle of a transfer. + * + * Returns: CURLMcode type, general multi error code. + */ CURL_EXTERN CURLMcode curl_multi_cleanup(CURLM *multi_handle); /* @@ -327,8 +327,8 @@ curl_multi_socket_all(CURLM *multi_handle, int *running_handles); #ifndef CURL_ALLOW_OLD_MULTI_SOCKET /* This macro below was added in 7.16.3 to push users who recompile to use - the new curl_multi_socket_action() instead of the old curl_multi_socket() -*/ + * the new curl_multi_socket_action() instead of the old curl_multi_socket() + */ #define curl_multi_socket(x,y,z) curl_multi_socket_action(x,y,0,z) #endif @@ -351,10 +351,10 @@ typedef enum { /* This is the argument passed to the socket callback */ CURLOPT(CURLMOPT_SOCKETDATA, CURLOPTTYPE_OBJECTPOINT, 2), - /* set to 1 to enable pipelining for this multi handle */ + /* set to 1 to enable pipelining for this multi handle */ CURLOPT(CURLMOPT_PIPELINING, CURLOPTTYPE_LONG, 3), - /* This is the timer callback function pointer */ + /* This is the timer callback function pointer */ CURLOPT(CURLMOPT_TIMERFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 4), /* This is the argument passed to the timer callback */ @@ -429,7 +429,6 @@ typedef enum { CURL_EXTERN CURLMcode curl_multi_setopt(CURLM *multi_handle, CURLMoption option, ...); - /* * Name: curl_multi_assign() * @@ -454,7 +453,6 @@ CURL_EXTERN CURLMcode curl_multi_assign(CURLM *multi_handle, */ CURL_EXTERN CURL **curl_multi_get_handles(CURLM *multi_handle); - typedef enum { CURLMINFO_NONE, /* first, never use this */ /* The number of easy handles currently managed by the multi handle, diff --git a/include/curl/typecheck-gcc.h b/include/curl/typecheck-gcc.h index bf03e0d9359b..0642afd91ed2 100644 --- a/include/curl/typecheck-gcc.h +++ b/include/curl/typecheck-gcc.h @@ -264,7 +264,6 @@ */ #define curl_share_setopt(share,opt,param) curl_share_setopt(share,opt,param) - /* the actual warnings, triggered by calling the Wcurl_easy_setopt_err* * functions */ @@ -590,8 +589,9 @@ CURLWARNING(Wcurl_easy_getinfo_err_curl_off_t, #define curlcheck_off_t_info(info) \ (CURLINFO_OFF_T < (info)) - -/* typecheck helpers -- check whether given expression has requested type */ +/* + * typecheck helpers -- check whether given expression has requested type + */ /* For pointers, you can use the curlcheck_ptr/curlcheck_arr macros, * otherwise define a new macro. Search for __builtin_types_compatible_p @@ -641,7 +641,6 @@ CURLWARNING(Wcurl_easy_getinfo_err_curl_off_t, (curlcheck_NULL(expr) || \ __builtin_types_compatible_p(__typeof__(expr), CURL *)) - /* evaluates to true if expr is a long (no matter the signedness) * XXX: for now, int is also accepted (and therefore short and char, which * are promoted to int when passed to a variadic function) */ diff --git a/lib/cf-https-connect.h b/lib/cf-https-connect.h index df51b62479d7..df29c8ddd7e1 100644 --- a/lib/cf-https-connect.h +++ b/lib/cf-https-connect.h @@ -44,6 +44,5 @@ CURLcode Curl_cf_https_setup(struct Curl_easy *data, struct connectdata *conn, int sockindex); - #endif /* !CURL_DISABLE_HTTP */ #endif /* HEADER_CURL_CF_HTTP_H */ diff --git a/lib/cfilters.h b/lib/cfilters.h index 73b9cb03e034..6834c4133a75 100644 --- a/lib/cfilters.h +++ b/lib/cfilters.h @@ -316,7 +316,6 @@ void Curl_conn_cf_discard_all(struct Curl_easy *data, struct connectdata *conn, int sockindex); - CURLcode Curl_conn_cf_connect(struct Curl_cfilter *cf, struct Curl_easy *data, bool *done); diff --git a/lib/config-os400.h b/lib/config-os400.h index b08400fe972a..3a48406b2a62 100644 --- a/lib/config-os400.h +++ b/lib/config-os400.h @@ -132,7 +132,6 @@ /* Define if you have the `socket' function. */ #define HAVE_SOCKET - /* The following define is needed on OS400 to enable strcmpi(), stricmp() and strdup(). */ #define __cplusplus__strings__ diff --git a/lib/curl_hmac.h b/lib/curl_hmac.h index 285846afe705..5444d62bd207 100644 --- a/lib/curl_hmac.h +++ b/lib/curl_hmac.h @@ -48,7 +48,6 @@ struct HMAC_params { unsigned int resultlen; /* Result length (bytes). */ }; - /* HMAC computation context. */ struct HMAC_context { const struct HMAC_params *hash; /* Hash function definition. */ diff --git a/lib/curl_memrchr.h b/lib/curl_memrchr.h index 73bd346cdee6..8e5d17708b39 100644 --- a/lib/curl_memrchr.h +++ b/lib/curl_memrchr.h @@ -35,7 +35,7 @@ #else /* HAVE_MEMRCHR */ void *Curl_memrchr(const void *s, int c, size_t n); -#define memrchr(x, y, z) Curl_memrchr((x), (y), (z)) +#define memrchr(x, y, z) Curl_memrchr(x, y, z) #endif /* HAVE_MEMRCHR */ diff --git a/lib/curl_setup_once.h b/lib/curl_setup_once.h index f9395aa7b51a..742d000b8556 100644 --- a/lib/curl_setup_once.h +++ b/lib/curl_setup_once.h @@ -160,7 +160,6 @@ struct timeval { #endif #endif /* HAVE_RECV */ - #ifdef __minix /* Minix does not support send on TCP sockets */ #define swrite(x, y, z) (ssize_t)write((SEND_TYPE_ARG1)(x), \ diff --git a/lib/curl_trc.h b/lib/curl_trc.h index 0c47d58798dc..6d6a22ef9909 100644 --- a/lib/curl_trc.h +++ b/lib/curl_trc.h @@ -65,7 +65,6 @@ void Curl_failf(struct Curl_easy *data, #define CURL_LOG_LVL_NONE 0 #define CURL_LOG_LVL_INFO 1 - #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define CURL_HAVE_C99 #endif diff --git a/lib/cw-pause.h b/lib/cw-pause.h index 2aa1a499cddd..5421bfd663f7 100644 --- a/lib/cw-pause.h +++ b/lib/cw-pause.h @@ -36,5 +36,4 @@ extern const struct Curl_cwtype Curl_cwt_pause; CURLcode Curl_cw_pause_flush(struct Curl_easy *data); - #endif /* HEADER_CURL_CW_PAUSE_H */ diff --git a/lib/dynhds.h b/lib/dynhds.h index e533dcc3699e..d405a60c2193 100644 --- a/lib/dynhds.h +++ b/lib/dynhds.h @@ -126,7 +126,6 @@ size_t Curl_dynhds_remove(struct dynhds *dynhds, const char *name, size_t namelen); size_t Curl_dynhds_cremove(struct dynhds *dynhds, const char *name); - /** * Set the give header name and value, replacing any entries with * the same name. The header is added at the end of all (remaining) diff --git a/lib/functypes.h b/lib/functypes.h index b4dccc0ce487..92f6b45cd200 100644 --- a/lib/functypes.h +++ b/lib/functypes.h @@ -68,7 +68,6 @@ #define SEND_TYPE_RETV int #endif - #ifndef RECV_TYPE_ARG1 #define RECV_TYPE_ARG1 int #endif diff --git a/lib/hostip.h b/lib/hostip.h index 780d93038f93..3672a03506b3 100644 --- a/lib/hostip.h +++ b/lib/hostip.h @@ -116,7 +116,6 @@ bool Curl_ipv6works(struct Curl_easy *data); #define Curl_ipv6works(x) FALSE #endif - /* unlink a dns entry, potentially shared with a cache */ void Curl_resolv_unlink(struct Curl_easy *data, struct Curl_dns_entry **pdns); diff --git a/lib/http.h b/lib/http.h index 26762b62058b..b193a1dfc857 100644 --- a/lib/http.h +++ b/lib/http.h @@ -213,7 +213,6 @@ Curl_http_output_auth(struct Curl_easy *data, /* Decode HTTP status code string. */ CURLcode Curl_http_decode_status(int *pstatus, const char *s, size_t len); - /** * All about a core HTTP request, excluding body and trailers */ diff --git a/lib/ldap.c b/lib/ldap.c index b51aab56fb44..b94fff34d847 100644 --- a/lib/ldap.c +++ b/lib/ldap.c @@ -95,7 +95,7 @@ #define curl_ldap_num_t ULONG #else #define FREE_ON_WINLDAP(x) -#define curl_ldap_num_t int +#define curl_ldap_num_t int #endif #ifndef HAVE_LDAP_URL_PARSE diff --git a/lib/optiontable.pl b/lib/optiontable.pl index 54b86d72e1ed..5e0c720f04e3 100755 --- a/lib/optiontable.pl +++ b/lib/optiontable.pl @@ -77,7 +77,6 @@ sub add { } } - my $fl; while() { my $l = $_; @@ -122,7 +121,6 @@ sub add { } } - for my $name (sort @names) { my $oname = $name; my $a = $alias{$name}; diff --git a/lib/setup-os400.h b/lib/setup-os400.h index 01f939951008..4cb0d89c3882 100644 --- a/lib/setup-os400.h +++ b/lib/setup-os400.h @@ -76,7 +76,6 @@ extern OM_uint32 Curl_gss_import_name_a(OM_uint32 * minor_status, gss_name_t * out_name); #define gss_import_name Curl_gss_import_name_a - extern OM_uint32 Curl_gss_display_status_a(OM_uint32 * minor_status, OM_uint32 status_value, int status_type, gss_OID mech_type, @@ -84,7 +83,6 @@ extern OM_uint32 Curl_gss_display_status_a(OM_uint32 * minor_status, gss_buffer_t status_string); #define gss_display_status Curl_gss_display_status_a - extern OM_uint32 Curl_gss_init_sec_context_a(OM_uint32 * minor_status, gss_cred_id_t cred_handle, gss_ctx_id_t * context_handle, @@ -101,13 +99,11 @@ extern OM_uint32 Curl_gss_init_sec_context_a(OM_uint32 * minor_status, OM_uint32 * time_rec); #define gss_init_sec_context Curl_gss_init_sec_context_a - extern OM_uint32 Curl_gss_delete_sec_context_a(OM_uint32 *minor_status, gss_ctx_id_t *context_handle, gss_buffer_t output_token); #define gss_delete_sec_context Curl_gss_delete_sec_context_a - /* LDAP wrappers. */ #define BerValue struct berval diff --git a/lib/urldata.h b/lib/urldata.h index bbab0130d318..7d5166e8e06f 100644 --- a/lib/urldata.h +++ b/lib/urldata.h @@ -133,7 +133,6 @@ typedef unsigned int curl_prot_t; input easier and better. */ #define CURL_MAX_INPUT_LENGTH 8000000 - #include "cookie.h" #include "psl.h" #include "formdata.h" diff --git a/lib/vquic/vquic.h b/lib/vquic/vquic.h index fd2dac7c22eb..fa2c0d4e816e 100644 --- a/lib/vquic/vquic.h +++ b/lib/vquic/vquic.h @@ -40,7 +40,6 @@ CURLcode Curl_qlogdir(struct Curl_easy *data, size_t scidlen, int *qlogfdp); - CURLcode Curl_cf_quic_create(struct Curl_cfilter **pcf, struct Curl_easy *data, struct connectdata *conn, diff --git a/lib/vtls/gtls.c b/lib/vtls/gtls.c index d1236aefba0c..a98ff4a62059 100644 --- a/lib/vtls/gtls.c +++ b/lib/vtls/gtls.c @@ -306,7 +306,7 @@ static gnutls_x509_crt_fmt_t gnutls_do_file_type(const char *type) return GNUTLS_X509_FMT_PEM; /* default to PEM */ } -#define GNUTLS_CIPHERS "NORMAL:%PROFILE_MEDIUM:-ARCFOUR-128:"\ +#define GNUTLS_CIPHERS "NORMAL:%PROFILE_MEDIUM:-ARCFOUR-128:" \ "-CTYPE-ALL:+CTYPE-X509" /* If GnuTLS was compiled without support for SRP it will error out if SRP is requested in the priority string, so treat it specially diff --git a/lib/vtls/x509asn1.c b/lib/vtls/x509asn1.c index d1329410bfc3..4f3c6ca170b9 100644 --- a/lib/vtls/x509asn1.c +++ b/lib/vtls/x509asn1.c @@ -54,7 +54,7 @@ */ /* Largest supported ASN.1 structure. */ -#define CURL_ASN1_MAX ((size_t) 0x40000) /* 256K */ +#define CURL_ASN1_MAX ((size_t)0x40000) /* 256K */ /* ASN.1 classes. */ /* #define CURL_ASN1_UNIVERSAL 0 */ diff --git a/m4/curl-amissl.m4 b/m4/curl-amissl.m4 index 86468890e86b..a1c2d3979cbd 100644 --- a/m4/curl-amissl.m4 +++ b/m4/curl-amissl.m4 @@ -33,8 +33,7 @@ if test "$HAVE_PROTO_BSDSOCKET_H" = "1"; then #include ]],[[ #if defined(AMISSL_CURRENT_VERSION) && defined(AMISSL_V3xx) && \ - (OPENSSL_VERSION_NUMBER >= 0x30000000L) && \ - defined(PROTO_AMISSL_H) + (OPENSSL_VERSION_NUMBER >= 0x30000000L) && defined(PROTO_AMISSL_H) return 0; #else #error not AmiSSL v5 / OpenSSL 3 diff --git a/m4/curl-functions.m4 b/m4/curl-functions.m4 index 5512a5d28c4c..85ccd1ff6ca9 100644 --- a/m4/curl-functions.m4 +++ b/m4/curl-functions.m4 @@ -508,7 +508,7 @@ AC_DEFUN([CURL_CHECK_FUNC_ALARM], [ AC_LANG_PROGRAM([[ $curl_includes_unistd ]],[[ - if(0 != alarm(0)) + if(alarm(0) != 0) return 1; ]]) ],[ @@ -599,7 +599,7 @@ AC_DEFUN([CURL_CHECK_FUNC_BASENAME], [ $curl_includes_libgen $curl_includes_unistd ]],[[ - if(0 != basename(0)) + if(basename(0) != 0) return 1; ]]) ],[ @@ -659,7 +659,7 @@ AC_DEFUN([CURL_CHECK_FUNC_CLOSESOCKET], [ AC_LANG_PROGRAM([[ $curl_includes_winsock2 ]],[[ - if(0 != closesocket(0)) + if(closesocket(0) != 0) return 1; ]]) ],[ @@ -689,7 +689,7 @@ AC_DEFUN([CURL_CHECK_FUNC_CLOSESOCKET], [ AC_LANG_PROGRAM([[ $curl_includes_winsock2 ]],[[ - if(0 != closesocket(0)) + if(closesocket(0) != 0) return 1; ]]) ],[ @@ -750,7 +750,7 @@ AC_DEFUN([CURL_CHECK_FUNC_CLOSESOCKET_CAMEL], [ $curl_includes_bsdsocket $curl_includes_sys_socket ]],[[ - if(0 != CloseSocket(0)) + if(CloseSocket(0) != 0) return 1; ]]) ],[ @@ -768,7 +768,7 @@ AC_DEFUN([CURL_CHECK_FUNC_CLOSESOCKET_CAMEL], [ $curl_includes_bsdsocket $curl_includes_sys_socket ]],[[ - if(0 != CloseSocket(0)) + if(CloseSocket(0) != 0) return 1; ]]) ],[ @@ -851,7 +851,7 @@ AC_DEFUN([CURL_CHECK_FUNC_FCNTL], [ AC_LANG_PROGRAM([[ $curl_includes_fcntl ]],[[ - if(0 != fcntl(0, 0, 0)) + if(fcntl(0, 0, 0) != 0) return 1; ]]) ],[ @@ -917,7 +917,7 @@ AC_DEFUN([CURL_CHECK_FUNC_FCNTL_O_NONBLOCK], [ $curl_includes_fcntl ]],[[ int flags = 0; - if(0 != fcntl(0, F_SETFL, flags | O_NONBLOCK)) + if(fcntl(0, F_SETFL, flags | O_NONBLOCK) != 0) return 1; ]]) ],[ @@ -1098,7 +1098,7 @@ AC_DEFUN([CURL_CHECK_FUNC_FSETXATTR], [ AC_LANG_PROGRAM([[ $curl_includes_sys_xattr ]],[[ - if(0 != fsetxattr(0, "", 0, 0, 0)) + if(fsetxattr(0, "", 0, 0, 0) != 0) return 1; ]]) ],[ @@ -1116,7 +1116,7 @@ AC_DEFUN([CURL_CHECK_FUNC_FSETXATTR], [ AC_LANG_PROGRAM([[ $curl_includes_sys_xattr ]],[[ - if(0 != fsetxattr(0, 0, 0, 0, 0, 0)) + if(fsetxattr(0, 0, 0, 0, 0, 0) != 0) return 1; ]]) ],[ @@ -1218,7 +1218,7 @@ AC_DEFUN([CURL_CHECK_FUNC_FTRUNCATE], [ AC_LANG_PROGRAM([[ $curl_includes_unistd ]],[[ - if(0 != ftruncate(0, 0)) + if(ftruncate(0, 0) != 0) return 1; ]]) ],[ @@ -1291,7 +1291,7 @@ AC_DEFUN([CURL_CHECK_FUNC_GETADDRINFO], [ $curl_includes_netdb ]],[[ struct addrinfo *ai = 0; - if(0 != getaddrinfo(0, 0, 0, &ai)) + if(getaddrinfo(0, 0, 0, &ai) != 0) return 1; ]]) ],[ @@ -1326,7 +1326,7 @@ AC_DEFUN([CURL_CHECK_FUNC_GETADDRINFO], [ $curl_includes_netdb ]],[[ struct addrinfo *ai = 0; - if(0 != getaddrinfo(0, 0, 0, &ai)) + if(getaddrinfo(0, 0, 0, &ai) != 0) return 1; ]]) ],[ @@ -1537,7 +1537,7 @@ AC_DEFUN([CURL_CHECK_FUNC_GETHOSTBYNAME_R], [ $curl_includes_netdb $curl_includes_bsdsocket ]],[[ - if(0 != gethostbyname_r(0, 0, 0)) + if(gethostbyname_r(0, 0, 0) != 0) return 1; ]]) ],[ @@ -1556,7 +1556,7 @@ AC_DEFUN([CURL_CHECK_FUNC_GETHOSTBYNAME_R], [ $curl_includes_netdb $curl_includes_bsdsocket ]],[[ - if(0 != gethostbyname_r(0, 0, 0, 0, 0)) + if(gethostbyname_r(0, 0, 0, 0, 0) != 0) return 1; ]]) ],[ @@ -1575,7 +1575,7 @@ AC_DEFUN([CURL_CHECK_FUNC_GETHOSTBYNAME_R], [ $curl_includes_netdb $curl_includes_bsdsocket ]],[[ - if(0 != gethostbyname_r(0, 0, 0, 0, 0, 0)) + if(gethostbyname_r(0, 0, 0, 0, 0, 0) != 0) return 1; ]]) ],[ @@ -1660,7 +1660,7 @@ AC_DEFUN([CURL_CHECK_FUNC_GETHOSTNAME], [ $curl_includes_bsdsocket ]],[[ char s[1]; - if(0 != gethostname((void *)s, 0)) + if(gethostname((void *)s, 0) != 0) return 1; ]]) ],[ @@ -1695,7 +1695,7 @@ AC_DEFUN([CURL_CHECK_FUNC_GETHOSTNAME], [ $curl_includes_bsdsocket ]],[[ char s[1]; - if(0 != gethostname((void *)s, 0)) + if(gethostname((void *)s, 0) != 0) return 1; ]]) ],[ @@ -1727,7 +1727,7 @@ AC_DEFUN([CURL_CHECK_FUNC_GETHOSTNAME], [ int FUNCALLCONV gethostname($tst_arg1, $tst_arg2); ]],[[ char s[1]; - if(0 != gethostname(($tst_arg1)s, 0)) + if(gethostname(($tst_arg1)s, 0) != 0) return 1; ]]) ],[ @@ -1795,7 +1795,7 @@ AC_DEFUN([CURL_CHECK_FUNC_GETPEERNAME], [ $curl_includes_bsdsocket $curl_includes_sys_socket ]],[[ - if(0 != getpeername(0, (void *)0, (void *)0)) + if(getpeername(0, (void *)0, (void *)0) != 0) return 1; ]]) ],[ @@ -1829,7 +1829,7 @@ AC_DEFUN([CURL_CHECK_FUNC_GETPEERNAME], [ $curl_includes_bsdsocket $curl_includes_sys_socket ]],[[ - if(0 != getpeername(0, (void *)0, (void *)0)) + if(getpeername(0, (void *)0, (void *)0) != 0) return 1; ]]) ],[ @@ -1893,7 +1893,7 @@ AC_DEFUN([CURL_CHECK_FUNC_GETSOCKNAME], [ $curl_includes_bsdsocket $curl_includes_sys_socket ]],[[ - if(0 != getsockname(0, (void *)0, (void *)0)) + if(getsockname(0, (void *)0, (void *)0) != 0) return 1; ]]) ],[ @@ -1927,7 +1927,7 @@ AC_DEFUN([CURL_CHECK_FUNC_GETSOCKNAME], [ $curl_includes_bsdsocket $curl_includes_sys_socket ]],[[ - if(0 != getsockname(0, (void *)0, (void *)0)) + if(getsockname(0, (void *)0, (void *)0) != 0) return 1; ]]) ],[ @@ -2014,7 +2014,7 @@ AC_DEFUN([CURL_CHECK_FUNC_GETIFADDRS], [ AC_LANG_PROGRAM([[ $curl_includes_ifaddrs ]],[[ - if(0 != getifaddrs(0)) + if(getifaddrs(0) != 0) return 1; ]]) ],[ @@ -2134,7 +2134,7 @@ AC_DEFUN([CURL_CHECK_FUNC_GMTIME_R], [ ]],[[ time_t tm = 1170352587; struct tm result; - if(0 != gmtime_r(&tm, &result)) + if(gmtime_r(&tm, &result) != 0) return 1; (void)result; ]]) @@ -2255,7 +2255,7 @@ AC_DEFUN([CURL_CHECK_FUNC_INET_NTOP], [ ]],[[ char ipv4res[sizeof("255.255.255.255")]; unsigned char ipv4a[5] = ""; - if(0 != inet_ntop(0, ipv4a, ipv4res, 0)) + if(inet_ntop(0, ipv4a, ipv4res, 0) != 0) return 1; ]]) ],[ @@ -2414,9 +2414,9 @@ AC_DEFUN([CURL_CHECK_FUNC_INET_PTON], [ AC_LANG_PROGRAM([[ $curl_includes_arpa_inet ]],[[ - unsigned char ipv4a[4+1] = ""; + unsigned char ipv4a[4 + 1] = ""; const char *ipv4src = "192.168.100.1"; - if(0 != inet_pton(0, ipv4src, ipv4a)) + if(inet_pton(0, ipv4src, ipv4a) != 0) return 1; ]]) ],[ @@ -2438,45 +2438,45 @@ AC_DEFUN([CURL_CHECK_FUNC_INET_PTON], [ $curl_includes_arpa_inet $curl_includes_string ]],[[ - unsigned char ipv6a[16+1]; - unsigned char ipv4a[4+1]; + unsigned char ipv6a[16 + 1]; + unsigned char ipv4a[4 + 1]; const char *ipv6src = "fe80::214:4fff:fe0b:76c8"; const char *ipv4src = "192.168.100.1"; /* - */ memset(ipv4a, 1, sizeof(ipv4a)); - if(1 != inet_pton(AF_INET, ipv4src, ipv4a)) + if(inet_pton(AF_INET, ipv4src, ipv4a) != 1) return 1; /* fail */ /* - */ - if( (ipv4a[0] != 0xc0) || - (ipv4a[1] != 0xa8) || - (ipv4a[2] != 0x64) || - (ipv4a[3] != 0x01) || - (ipv4a[4] != 0x01) ) + if((ipv4a[0] != 0xc0) || + (ipv4a[1] != 0xa8) || + (ipv4a[2] != 0x64) || + (ipv4a[3] != 0x01) || + (ipv4a[4] != 0x01)) return 1; /* fail */ /* - */ memset(ipv6a, 1, sizeof(ipv6a)); - if(1 != inet_pton(AF_INET6, ipv6src, ipv6a)) + if(inet_pton(AF_INET6, ipv6src, ipv6a) != 1) return 1; /* fail */ /* - */ - if( (ipv6a[0] != 0xfe) || - (ipv6a[1] != 0x80) || - (ipv6a[8] != 0x02) || - (ipv6a[9] != 0x14) || - (ipv6a[10] != 0x4f) || - (ipv6a[11] != 0xff) || - (ipv6a[12] != 0xfe) || - (ipv6a[13] != 0x0b) || - (ipv6a[14] != 0x76) || - (ipv6a[15] != 0xc8) || - (ipv6a[16] != 0x01) ) + if((ipv6a[0] != 0xfe) || + (ipv6a[1] != 0x80) || + (ipv6a[8] != 0x02) || + (ipv6a[9] != 0x14) || + (ipv6a[10] != 0x4f) || + (ipv6a[11] != 0xff) || + (ipv6a[12] != 0xfe) || + (ipv6a[13] != 0x0b) || + (ipv6a[14] != 0x76) || + (ipv6a[15] != 0xc8) || + (ipv6a[16] != 0x01)) return 1; /* fail */ /* - */ - if( (ipv6a[2] != 0x0) || - (ipv6a[3] != 0x0) || - (ipv6a[4] != 0x0) || - (ipv6a[5] != 0x0) || - (ipv6a[6] != 0x0) || - (ipv6a[7] != 0x0) ) + if((ipv6a[2] != 0x0) || + (ipv6a[3] != 0x0) || + (ipv6a[4] != 0x0) || + (ipv6a[5] != 0x0) || + (ipv6a[6] != 0x0) || + (ipv6a[7] != 0x0)) return 1; /* fail */ /* - */ return 0; @@ -2565,7 +2565,7 @@ AC_DEFUN([CURL_CHECK_FUNC_IOCTL], [ AC_LANG_PROGRAM([[ $curl_includes_stropts ]],[[ - if(0 != ioctl(0, 0, 0)) + if(ioctl(0, 0, 0) != 0) return 1; ]]) ],[ @@ -2623,7 +2623,7 @@ AC_DEFUN([CURL_CHECK_FUNC_IOCTL_FIONBIO], [ $curl_includes_stropts ]],[[ int flags = 0; - if(0 != ioctl(0, FIONBIO, &flags)) + if(ioctl(0, FIONBIO, &flags) != 0) return 1; ]]) ],[ @@ -2680,7 +2680,7 @@ AC_DEFUN([CURL_CHECK_FUNC_IOCTL_SIOCGIFADDR], [ #include ]],[[ struct ifreq ifr; - if(0 != ioctl(0, SIOCGIFADDR, &ifr)) + if(ioctl(0, SIOCGIFADDR, &ifr) != 0) return 1; ]]) ],[ @@ -2738,7 +2738,7 @@ AC_DEFUN([CURL_CHECK_FUNC_IOCTLSOCKET], [ AC_LANG_PROGRAM([[ $curl_includes_winsock2 ]],[[ - if(0 != ioctlsocket(0, 0, 0)) + if(ioctlsocket(0, 0, 0) != 0) return 1; ]]) ],[ @@ -2768,7 +2768,7 @@ AC_DEFUN([CURL_CHECK_FUNC_IOCTLSOCKET], [ AC_LANG_PROGRAM([[ $curl_includes_winsock2 ]],[[ - if(0 != ioctlsocket(0, 0, 0)) + if(ioctlsocket(0, 0, 0) != 0) return 1; ]]) ],[ @@ -2827,7 +2827,7 @@ AC_DEFUN([CURL_CHECK_FUNC_IOCTLSOCKET_FIONBIO], [ $curl_includes_winsock2 ]],[[ unsigned long flags = 0; - if(0 != ioctlsocket(0, FIONBIO, &flags)) + if(ioctlsocket(0, FIONBIO, &flags) != 0) return 1; ]]) ],[ @@ -2884,7 +2884,7 @@ AC_DEFUN([CURL_CHECK_FUNC_IOCTLSOCKET_CAMEL], [ AC_LANG_PROGRAM([[ $curl_includes_bsdsocket ]],[[ - if(0 != IoctlSocket(0, 0, 0)) + if(IoctlSocket(0, 0, 0) != 0) return 1; ]]) ],[ @@ -2901,7 +2901,7 @@ AC_DEFUN([CURL_CHECK_FUNC_IOCTLSOCKET_CAMEL], [ AC_LANG_PROGRAM([[ $curl_includes_bsdsocket ]],[[ - if(0 != IoctlSocket(0, 0, 0)) + if(IoctlSocket(0, 0, 0) != 0) return 1; ]]) ],[ @@ -2959,7 +2959,7 @@ AC_DEFUN([CURL_CHECK_FUNC_IOCTLSOCKET_CAMEL_FIONBIO], [ $curl_includes_bsdsocket ]],[[ long flags = 0; - if(0 != IoctlSocket(0, FIONBIO, &flags)) + if(IoctlSocket(0, FIONBIO, &flags) != 0) return 1; ]]) ],[ @@ -3030,7 +3030,7 @@ AC_DEFUN([CURL_CHECK_FUNC_MEMRCHR], [ AC_LANG_PROGRAM([[ $curl_includes_string ]],[[ - if(0 != memrchr("", 0, 0)) + if(memrchr("", 0, 0) != 0) return 1; ]]) ],[ @@ -3062,7 +3062,7 @@ AC_DEFUN([CURL_CHECK_FUNC_MEMRCHR], [ AC_LANG_PROGRAM([[ $curl_includes_string ]],[[ - if(0 != memrchr("", 0, 0)) + if(memrchr("", 0, 0) != 0) return 1; ]]) ],[ @@ -3147,7 +3147,7 @@ AC_DEFUN([CURL_CHECK_FUNC_SIGACTION], [ AC_LANG_PROGRAM([[ $curl_includes_signal ]],[[ - if(0 != sigaction(0, 0, 0)) + if(sigaction(0, 0, 0) != 0) return 1; ]]) ],[ @@ -3232,7 +3232,7 @@ AC_DEFUN([CURL_CHECK_FUNC_SIGINTERRUPT], [ AC_LANG_PROGRAM([[ $curl_includes_signal ]],[[ - if(0 != siginterrupt(0, 0)) + if(siginterrupt(0, 0) != 0) return 1; ]]) ],[ @@ -3317,7 +3317,7 @@ AC_DEFUN([CURL_CHECK_FUNC_SIGNAL], [ AC_LANG_PROGRAM([[ $curl_includes_signal ]],[[ - if(0 != signal(0, 0)) + if(signal(0, 0) != 0) return 1; ]]) ],[ @@ -3391,7 +3391,7 @@ AC_DEFUN([CURL_CHECK_FUNC_SIGSETJMP], [ $curl_includes_setjmp ]],[[ sigjmp_buf env; - if(0 != sigsetjmp(env, 0)) + if(sigsetjmp(env, 0) != 0) return 1; ]]) ],[ @@ -3424,7 +3424,7 @@ AC_DEFUN([CURL_CHECK_FUNC_SIGSETJMP], [ $curl_includes_setjmp ]],[[ sigjmp_buf env; - if(0 != sigsetjmp(env, 0)) + if(sigsetjmp(env, 0) != 0) return 1; ]]) ],[ @@ -3487,7 +3487,7 @@ AC_DEFUN([CURL_CHECK_FUNC_SOCKET], [ $curl_includes_bsdsocket $curl_includes_sys_socket ]],[[ - if(0 != socket(0, 0, 0)) + if(socket(0, 0, 0) != 0) return 1; ]]) ],[ @@ -3521,7 +3521,7 @@ AC_DEFUN([CURL_CHECK_FUNC_SOCKET], [ $curl_includes_bsdsocket $curl_includes_sys_socket ]],[[ - if(0 != socket(0, 0, 0)) + if(socket(0, 0, 0) != 0) return 1; ]]) ],[ @@ -3607,7 +3607,7 @@ AC_DEFUN([CURL_CHECK_FUNC_SOCKETPAIR], [ $curl_includes_sys_socket ]],[[ int sv[2]; - if(0 != socketpair(0, 0, 0, sv)) + if(socketpair(0, 0, 0, sv) != 0) return 1; ]]) ],[ @@ -3692,7 +3692,7 @@ AC_DEFUN([CURL_CHECK_FUNC_STRCASECMP], [ AC_LANG_PROGRAM([[ $curl_includes_string ]],[[ - if(0 != strcasecmp("", "")) + if(strcasecmp("", "") != 0) return 1; ]]) ],[ @@ -3776,7 +3776,7 @@ AC_DEFUN([CURL_CHECK_FUNC_STRCMPI], [ AC_LANG_PROGRAM([[ $curl_includes_string ]],[[ - if(0 != strcmpi(0, 0)) + if(strcmpi(0, 0) != 0) return 1; ]]) ],[ @@ -3971,7 +3971,7 @@ AC_DEFUN([CURL_CHECK_FUNC_STRERROR_R], [ $curl_includes_string ]],[[ char s[1]; - if(0 != strerror_r(0, s, 0)) + if(strerror_r(0, s, 0) != 0) return 1; ]]) ],[ @@ -3994,7 +3994,7 @@ AC_DEFUN([CURL_CHECK_FUNC_STRERROR_R], [ char *strerror_r(int errnum, char *workbuf, $arg3 bufsize); ]],[[ char s[1]; - if(0 != strerror_r(0, s, 0)) + if(strerror_r(0, s, 0) != 0) return 1; (void)s; ]]) @@ -4057,7 +4057,7 @@ AC_DEFUN([CURL_CHECK_FUNC_STRERROR_R], [ int strerror_r(int errnum, char *resultbuf, $arg3 bufsize); ]],[[ char s[1]; - if(0 != strerror_r(0, s, 0)) + if(strerror_r(0, s, 0) != 0) return 1; (void)s; ]]) @@ -4213,7 +4213,7 @@ AC_DEFUN([CURL_CHECK_FUNC_STRICMP], [ AC_LANG_PROGRAM([[ $curl_includes_string ]],[[ - if(0 != stricmp(0, 0)) + if(stricmp(0, 0) != 0) return 1; ]]) ],[ @@ -4380,8 +4380,8 @@ AC_DEFUN([CURL_SIZEOF], [ $2 ]],[ switch(0) { - case 0: - case (sizeof($1) == $typesize):; + case 0: + case (sizeof($1) == $typesize):; } ]) ],[ diff --git a/packages/OS400/ccsidcurl.c b/packages/OS400/ccsidcurl.c index b176def67d18..0982eed639f7 100644 --- a/packages/OS400/ccsidcurl.c +++ b/packages/OS400/ccsidcurl.c @@ -46,20 +46,17 @@ #include "os400sys.h" #ifndef SIZE_MAX -#define SIZE_MAX ((size_t) ~0) /* Is unsigned on OS/400. */ +#define SIZE_MAX ((size_t)~0) /* Is unsigned on OS/400. */ #endif +#define ASCII_CCSID 819 /* Use ISO-8859-1 as ASCII. */ +#define NOCONV_CCSID 65535 /* No conversion. */ +#define ICONV_ID_SIZE 32 /* Size of iconv_open() code identifier. */ +#define ICONV_OPEN_ERROR(t) ((t).return_value == -1) -#define ASCII_CCSID 819 /* Use ISO-8859-1 as ASCII. */ -#define NOCONV_CCSID 65535 /* No conversion. */ -#define ICONV_ID_SIZE 32 /* Size of iconv_open() code identifier. */ -#define ICONV_OPEN_ERROR(t) ((t).return_value == -1) +#define ALLOC_GRANULE 8 /* Alloc. granule for curl_formadd_ccsid(). */ -#define ALLOC_GRANULE 8 /* Alloc. granule for curl_formadd_ccsid(). */ - - -static void -makeOS400IconvCode(char buf[ICONV_ID_SIZE], unsigned int ccsid) +static void makeOS400IconvCode(char buf[ICONV_ID_SIZE], unsigned int ccsid) { /** *** Convert a CCSID to the corresponding IBM iconv_open() character @@ -78,10 +75,8 @@ makeOS400IconvCode(char buf[ICONV_ID_SIZE], unsigned int ccsid) curl_msprintf(buf, "IBMCCSID%05u0000000", ccsid); } - -static iconv_t -iconv_open_CCSID(unsigned int ccsidout, unsigned int ccsidin, - unsigned int cstr) +static iconv_t iconv_open_CCSID(unsigned int ccsidout, unsigned int ccsidin, + unsigned int cstr) { char fromcode[ICONV_ID_SIZE]; char tocode[ICONV_ID_SIZE]; @@ -95,18 +90,16 @@ iconv_open_CCSID(unsigned int ccsidout, unsigned int ccsidin, makeOS400IconvCode(fromcode, ccsidin); makeOS400IconvCode(tocode, ccsidout); - memset(tocode + 13, 0, sizeof(tocode) - 13); /* Dest. code id format. */ + memset(tocode + 13, 0, sizeof(tocode) - 13); /* Dest. code id format. */ if(cstr) - fromcode[18] = '1'; /* Set null-terminator flag. */ + fromcode[18] = '1'; /* Set null-terminator flag. */ return iconv_open(tocode, fromcode); } - -static int -convert(char *d, size_t dlen, int dccsid, - const char *s, int slen, int sccsid) +static int convert(char *d, size_t dlen, int dccsid, const char *s, int slen, + int sccsid) { int i; iconv_t cd; @@ -141,7 +134,7 @@ convert(char *d, size_t dlen, int dccsid, cd = iconv_open_CCSID(dccsid, sccsid, 1); } else { - lslen = (size_t) slen; + lslen = (size_t)slen; cd = iconv_open_CCSID(dccsid, sccsid, 0); } @@ -150,7 +143,7 @@ convert(char *d, size_t dlen, int dccsid, i = dlen; - if((int) iconv(cd, (char * *) &s, &lslen, &d, &dlen) < 0) + if((int)iconv(cd, (char **)&s, &lslen, &d, &dlen) < 0) i = -1; else i -= dlen; @@ -159,7 +152,6 @@ convert(char *d, size_t dlen, int dccsid, return i; } - static char *dynconvert(int dccsid, const char *s, int slen, int sccsid, int *olen) { @@ -171,18 +163,18 @@ static char *dynconvert(int dccsid, const char *s, int slen, int sccsid, /* Like convert, but the destination is allocated and returned. */ - dlen = (size_t) (slen < 0 ? strlen(s) : slen) + 1; - dlen *= MAX_CONV_EXPANSION; /* Allow some expansion. */ + dlen = (size_t)(slen < 0 ? strlen(s) : slen) + 1; + dlen *= MAX_CONV_EXPANSION; /* Allow some expansion. */ d = malloc(dlen); if(!d) - return (char *) NULL; + return (char *)NULL; l = convert(d, dlen, dccsid, s, slen, sccsid); if(l < 0) { free(d); - return (char *) NULL; + return (char *)NULL; } if(slen < 0) { @@ -194,14 +186,14 @@ static char *dynconvert(int dccsid, const char *s, int slen, int sccsid, if(l2 < 0) { free(d); - return (char *) NULL; + return (char *)NULL; } l += l2; } - if((size_t) l < dlen) { - cp = realloc(d, l); /* Shorten to minimum needed. */ + if((size_t)l < dlen) { + cp = realloc(d, l); /* Shorten to minimum needed. */ if(cp) d = cp; @@ -212,11 +204,10 @@ static char *dynconvert(int dccsid, const char *s, int slen, int sccsid, return d; } - -static struct curl_slist * -slist_convert(int dccsid, struct curl_slist *from, int sccsid) +static struct curl_slist *slist_convert(int dccsid, struct curl_slist *from, + int sccsid) { - struct curl_slist *to = (struct curl_slist *) NULL; + struct curl_slist *to = (struct curl_slist *)NULL; for(; from; from = from->next) { struct curl_slist *nl; @@ -224,7 +215,7 @@ slist_convert(int dccsid, struct curl_slist *from, int sccsid) if(!cp) { curl_slist_free_all(to); - return (struct curl_slist *) NULL; + return (struct curl_slist *)NULL; } nl = Curl_slist_append_nodup(to, cp); if(!nl) { @@ -237,15 +228,14 @@ slist_convert(int dccsid, struct curl_slist *from, int sccsid) return to; } - -static char * -keyed_string(localkey_t key, const char *ascii, unsigned int ccsid) +static char *keyed_string(localkey_t key, const char *ascii, + unsigned int ccsid) { int i; char *ebcdic; if(!ascii) - return (char *) NULL; + return (char *)NULL; i = MAX_CONV_EXPANSION * (strlen(ascii) + 1); @@ -254,40 +244,32 @@ keyed_string(localkey_t key, const char *ascii, unsigned int ccsid) return ebcdic; if(convert(ebcdic, i, ccsid, ascii, -1, ASCII_CCSID) < 0) - return (char *) NULL; + return (char *)NULL; return ebcdic; } - -const char * -curl_to_ccsid(const char *s, unsigned int ccsid) +const char *curl_to_ccsid(const char *s, unsigned int ccsid) { if(s) s = dynconvert(ccsid, s, -1, ASCII_CCSID, NULL); return s; } - -const char * -curl_from_ccsid(const char *s, unsigned int ccsid) +const char *curl_from_ccsid(const char *s, unsigned int ccsid) { if(s) s = dynconvert(ASCII_CCSID, s, -1, ccsid, NULL); return s; } - -char * -curl_version_ccsid(unsigned int ccsid) +char *curl_version_ccsid(unsigned int ccsid) { return keyed_string(LK_CURL_VERSION, curl_version(), ccsid); } - -char * -curl_easy_escape_ccsid(CURL *handle, const char *string, int length, - unsigned int sccsid, unsigned int dccsid) +char *curl_easy_escape_ccsid(CURL *handle, const char *string, int length, + unsigned int sccsid, unsigned int dccsid) { char *s; char *d; @@ -295,30 +277,28 @@ curl_easy_escape_ccsid(CURL *handle, const char *string, int length, if(!string) { /* !checksrc! disable ERRNOVAR 1 */ errno = EINVAL; - return (char *) NULL; + return (char *)NULL; } s = dynconvert(ASCII_CCSID, string, length ? length : -1, sccsid, NULL); if(!s) - return (char *) NULL; + return (char *)NULL; d = curl_easy_escape(handle, s, 0); free(s); if(!d) - return (char *) NULL; + return (char *)NULL; s = dynconvert(dccsid, d, -1, ASCII_CCSID, NULL); free(d); return s; } - -char * -curl_easy_unescape_ccsid(CURL *handle, const char *string, int length, - int *outlength, - unsigned int sccsid, unsigned int dccsid) +char *curl_easy_unescape_ccsid(CURL *handle, const char *string, int length, + int *outlength, unsigned int sccsid, + unsigned int dccsid) { char *s; char *d; @@ -326,19 +306,19 @@ curl_easy_unescape_ccsid(CURL *handle, const char *string, int length, if(!string) { /* !checksrc! disable ERRNOVAR 1 */ errno = EINVAL; - return (char *) NULL; + return (char *)NULL; } s = dynconvert(ASCII_CCSID, string, length ? length : -1, sccsid, NULL); if(!s) - return (char *) NULL; + return (char *)NULL; d = curl_easy_unescape(handle, s, 0, outlength); free(s); if(!d) - return (char *) NULL; + return (char *)NULL; s = dynconvert(dccsid, d, -1, ASCII_CCSID, NULL); free(d); @@ -349,14 +329,13 @@ curl_easy_unescape_ccsid(CURL *handle, const char *string, int length, return s; } - -struct curl_slist * -curl_slist_append_ccsid(struct curl_slist *list, - const char *data, unsigned int ccsid) +struct curl_slist *curl_slist_append_ccsid(struct curl_slist *list, + const char *data, + unsigned int ccsid) { char *s; - s = (char *) NULL; + s = (char *)NULL; if(!data) return curl_slist_append(list, data); @@ -364,16 +343,15 @@ curl_slist_append_ccsid(struct curl_slist *list, s = dynconvert(ASCII_CCSID, data, -1, ccsid, NULL); if(!s) - return (struct curl_slist *) NULL; + return (struct curl_slist *)NULL; list = curl_slist_append(list, s); free(s); return list; } - -time_t -curl_getdate_ccsid(const char *p, const time_t *unused, unsigned int ccsid) +time_t curl_getdate_ccsid(const char *p, const time_t *unused, + unsigned int ccsid) { char *s; time_t t; @@ -384,17 +362,15 @@ curl_getdate_ccsid(const char *p, const time_t *unused, unsigned int ccsid) s = dynconvert(ASCII_CCSID, p, -1, ccsid, NULL); if(!s) - return (time_t) -1; + return (time_t)-1; t = curl_getdate(s, unused); free(s); return t; } - -static int -convert_version_info_string(const char **stringp, - char **bufp, int *left, unsigned int ccsid) +static int convert_version_info_string(const char **stringp, char **bufp, + int *left, unsigned int ccsid) { /* Helper for curl_version_info_ccsid(): convert a string if defined. Result is stored in the `*left'-byte buffer at `*bufp'. @@ -415,9 +391,8 @@ convert_version_info_string(const char **stringp, return 0; } - -curl_version_info_data * -curl_version_info_ccsid(CURLversion stamp, unsigned int ccsid) +curl_version_info_data *curl_version_info_ccsid(CURLversion stamp, + unsigned int ccsid) { curl_version_info_data *p; char *cp; @@ -457,7 +432,7 @@ curl_version_info_ccsid(CURLversion stamp, unsigned int ccsid) /* If caller has been compiled with a newer version, error. */ if(stamp > CURLVERSION_NOW) - return (curl_version_info_data *) NULL; + return (curl_version_info_data *)NULL; p = curl_version_info(stamp); @@ -477,7 +452,7 @@ curl_version_info_ccsid(CURLversion stamp, unsigned int ccsid) } for(i = 0; i < sizeof(charfields) / sizeof(charfields[0]); i++) { - cpp = (const char **) ((char *) p + charfields[i]); + cpp = (const char **)((char *)p + charfields[i]); if(*cpp) n += strlen(*cpp) + 1; } @@ -490,70 +465,60 @@ curl_version_info_ccsid(CURLversion stamp, unsigned int ccsid) n += nproto * sizeof(const char *); cp = Curl_thread_buffer(LK_VERSION_INFO_DATA, n); - id = (curl_version_info_data *) Curl_thread_buffer(LK_VERSION_INFO, - sizeof(*id)); + id = (curl_version_info_data *)Curl_thread_buffer(LK_VERSION_INFO, + sizeof(*id)); if(!id || !cp) - return (curl_version_info_data *) NULL; + return (curl_version_info_data *)NULL; /* Copy data and convert strings. */ - memcpy((char *) id, (char *) p, sizeof(*p)); + memcpy((char *)id, (char *)p, sizeof(*p)); if(id->protocols) { i = nproto * sizeof(id->protocols[0]); - id->protocols = (const char * const *) cp; - memcpy(cp, (char *) p->protocols, i); + id->protocols = (const char * const *)cp; + memcpy(cp, (char *)p->protocols, i); cp += i; n -= i; for(i = 0; id->protocols[i]; i++) - if(convert_version_info_string(((const char * *) id->protocols) + i, - &cp, &n, ccsid)) - return (curl_version_info_data *) NULL; + if(convert_version_info_string(((const char **)id->protocols) + i, + &cp, &n, ccsid)) + return (curl_version_info_data *)NULL; } for(i = 0; i < sizeof(charfields) / sizeof(charfields[0]); i++) { - cpp = (const char **) ((char *) p + charfields[i]); + cpp = (const char **)((char *)p + charfields[i]); if(*cpp && convert_version_info_string(cpp, &cp, &n, ccsid)) - return (curl_version_info_data *) NULL; + return (curl_version_info_data *)NULL; } return id; } - -const char * -curl_easy_strerror_ccsid(CURLcode error, unsigned int ccsid) +const char *curl_easy_strerror_ccsid(CURLcode error, unsigned int ccsid) { return keyed_string(LK_EASY_STRERROR, curl_easy_strerror(error), ccsid); } - -const char * -curl_share_strerror_ccsid(CURLSHcode error, unsigned int ccsid) +const char *curl_share_strerror_ccsid(CURLSHcode error, unsigned int ccsid) { return keyed_string(LK_SHARE_STRERROR, curl_share_strerror(error), ccsid); } - -const char * -curl_multi_strerror_ccsid(CURLMcode error, unsigned int ccsid) +const char *curl_multi_strerror_ccsid(CURLMcode error, unsigned int ccsid) { return keyed_string(LK_MULTI_STRERROR, curl_multi_strerror(error), ccsid); } - -const char * -curl_url_strerror_ccsid(CURLUcode error, unsigned int ccsid) +const char *curl_url_strerror_ccsid(CURLUcode error, unsigned int ccsid) { return keyed_string(LK_URL_STRERROR, curl_url_strerror(error), ccsid); } - -void -curl_certinfo_free_all(struct curl_certinfo *info) +void curl_certinfo_free_all(struct curl_certinfo *info) { /* Free all memory used by certificate info. */ if(info) { @@ -562,15 +527,13 @@ curl_certinfo_free_all(struct curl_certinfo *info) for(i = 0; i < info->num_of_certs; i++) curl_slist_free_all(info->certinfo[i]); - free((char *) info->certinfo); + free((char *)info->certinfo); } - free((char *) info); + free((char *)info); } } - -CURLcode -curl_easy_getinfo_ccsid(CURL *curl, CURLINFO info, ...) +CURLcode curl_easy_getinfo_ccsid(CURL *curl, CURLINFO info, ...) { va_list arg; void *paramp; @@ -580,7 +543,7 @@ curl_easy_getinfo_ccsid(CURL *curl, CURLINFO info, ...) /* WARNING: unlike curl_easy_getinfo(), the strings returned by this procedure have to be free'ed. */ - data = (struct Curl_easy *) curl; + data = (struct Curl_easy *)curl; va_start(arg, info); paramp = va_arg(arg, void *); ret = Curl_getinfo(data, info, paramp); @@ -592,11 +555,11 @@ curl_easy_getinfo_ccsid(CURL *curl, CURLINFO info, ...) struct curl_certinfo *cipf; struct curl_certinfo *cipt; - switch((int) info & CURLINFO_TYPEMASK) { + switch((int)info & CURLINFO_TYPEMASK) { case CURLINFO_STRING: ccsid = va_arg(arg, unsigned int); - cpp = (char * *) paramp; + cpp = (char **)paramp; if(*cpp) { *cpp = dynconvert(ccsid, *cpp, -1, ASCII_CCSID, NULL); @@ -611,15 +574,15 @@ curl_easy_getinfo_ccsid(CURL *curl, CURLINFO info, ...) ccsid = va_arg(arg, unsigned int); switch(info) { case CURLINFO_CERTINFO: - cipf = *(struct curl_certinfo * *) paramp; + cipf = *(struct curl_certinfo **)paramp; if(cipf) { - cipt = (struct curl_certinfo *) malloc(sizeof(*cipt)); + cipt = (struct curl_certinfo *)malloc(sizeof(*cipt)); if(!cipt) ret = CURLE_OUT_OF_MEMORY; else { - cipt->certinfo = (struct curl_slist **) - calloc(cipf->num_of_certs + - 1, sizeof(struct curl_slist *)); + cipt->certinfo = + (struct curl_slist **)calloc(cipf->num_of_certs + 1, + sizeof(struct curl_slist *)); if(!cipt->certinfo) ret = CURLE_OUT_OF_MEMORY; else { @@ -629,20 +592,20 @@ curl_easy_getinfo_ccsid(CURL *curl, CURLINFO info, ...) for(i = 0; i < cipf->num_of_certs; i++) if(cipf->certinfo[i]) if(!(cipt->certinfo[i] = slist_convert(ccsid, - cipf->certinfo[i], - ASCII_CCSID))) { + cipf->certinfo[i], + ASCII_CCSID))) { ret = CURLE_OUT_OF_MEMORY; break; } - } } + } if(ret != CURLE_OK) { curl_certinfo_free_all(cipt); - cipt = (struct curl_certinfo *) NULL; + cipt = (struct curl_certinfo *)NULL; } - *(struct curl_certinfo * *) paramp = cipt; + *(struct curl_certinfo **)paramp = cipt; } break; @@ -653,7 +616,7 @@ curl_easy_getinfo_ccsid(CURL *curl, CURLINFO info, ...) break; default: - slp = (struct curl_slist **) paramp; + slp = (struct curl_slist **)paramp; if(*slp) { *slp = slist_convert(ccsid, *slp, ASCII_CCSID); if(!*slp) @@ -668,9 +631,7 @@ curl_easy_getinfo_ccsid(CURL *curl, CURLINFO info, ...) return ret; } - -static int -Curl_is_formadd_string(CURLformoption option) +static int Curl_is_formadd_string(CURLformoption option) { switch(option) { @@ -687,23 +648,20 @@ Curl_is_formadd_string(CURLformoption option) return 0; } - -static void -Curl_formadd_release_local(struct curl_forms *forms, int nargs, int skip) +static void Curl_formadd_release_local(struct curl_forms *forms, int nargs, + int skip) { while(nargs--) if(nargs != skip) if(Curl_is_formadd_string(forms[nargs].option)) if(forms[nargs].value) - free((char *) forms[nargs].value); + free((char *)forms[nargs].value); - free((char *) forms); + free((char *)forms); } - -static int -Curl_formadd_convert(struct curl_forms *forms, - int formx, int lengthx, unsigned int ccsid) +static int Curl_formadd_convert(struct curl_forms *forms, int formx, + int lengthx, unsigned int ccsid) { int l; char *cp; @@ -713,7 +671,7 @@ Curl_formadd_convert(struct curl_forms *forms, return 0; if(lengthx >= 0) - l = (int) forms[lengthx].value; + l = (int)forms[lengthx].value; else l = strlen(forms[formx].value) + 1; @@ -722,15 +680,15 @@ Curl_formadd_convert(struct curl_forms *forms, if(!cp) return -1; - l = convert(cp, MAX_CONV_EXPANSION * l, ASCII_CCSID, - forms[formx].value, l, ccsid); + l = convert(cp, MAX_CONV_EXPANSION * l, ASCII_CCSID, forms[formx].value, l, + ccsid); if(l < 0) { free(cp); return -1; } - cp2 = realloc(cp, l); /* Shorten buffer to the string size. */ + cp2 = realloc(cp, l); /* Shorten buffer to the string size. */ if(cp2) cp = cp2; @@ -738,15 +696,13 @@ Curl_formadd_convert(struct curl_forms *forms, forms[formx].value = cp; if(lengthx >= 0) - forms[lengthx].value = (char *) l; /* Update length after conversion. */ + forms[lengthx].value = (char *)l; /* Update length after conversion. */ return l; } - -CURLFORMcode -curl_formadd_ccsid(struct curl_httppost **httppost, - struct curl_httppost **last_post, ...) +CURLFORMcode curl_formadd_ccsid(struct curl_httppost **httppost, + struct curl_httppost **last_post, ...) { va_list arg; CURLformoption option; @@ -797,7 +753,7 @@ curl_formadd_ccsid(struct curl_httppost **httppost, lengthx = -1; namex = -1; namelengthx = -1; - forms = (struct curl_forms *) NULL; + forms = (struct curl_forms *)NULL; va_start(arg, last_post); for(;;) { @@ -831,14 +787,14 @@ curl_formadd_ccsid(struct curl_httppost **httppost, if(option == CURLFORM_END) break; - } + } /* Dispatch by option. */ switch(option) { case CURLFORM_END: - forms = (struct curl_forms *) NULL; /* Leave array mode. */ + forms = (struct curl_forms *)NULL; /* Leave array mode. */ continue; case CURLFORM_ARRAY: @@ -851,7 +807,7 @@ curl_formadd_ccsid(struct curl_httppost **httppost, break; case CURLFORM_COPYNAME: - option = CURLFORM_PTRNAME; /* Static for now. */ + option = CURLFORM_PTRNAME; /* Static for now. */ case CURLFORM_PTRNAME: if(namex >= 0) @@ -861,10 +817,10 @@ curl_formadd_ccsid(struct curl_httppost **httppost, if(!forms) { value = va_arg(arg, char *); - nameccsid = (unsigned int) va_arg(arg, long); + nameccsid = (unsigned int)va_arg(arg, long); } else { - nameccsid = (unsigned int) forms->value; + nameccsid = (unsigned int)forms->value; forms++; } @@ -878,10 +834,10 @@ curl_formadd_ccsid(struct curl_httppost **httppost, if(!forms) { value = va_arg(arg, char *); - contentccsid = (unsigned int) va_arg(arg, long); + contentccsid = (unsigned int)va_arg(arg, long); } else { - contentccsid = (unsigned int) forms->value; + contentccsid = (unsigned int)forms->value; forms++; } @@ -890,7 +846,7 @@ curl_formadd_ccsid(struct curl_httppost **httppost, case CURLFORM_PTRCONTENTS: case CURLFORM_BUFFERPTR: if(!forms) - value = va_arg(arg, char *); /* No conversion. */ + value = va_arg(arg, char *); /* No conversion. */ break; @@ -898,7 +854,7 @@ curl_formadd_ccsid(struct curl_httppost **httppost, lengthx = nargs; if(!forms) - value = (char *) va_arg(arg, long); + value = (char *)va_arg(arg, long); break; @@ -906,7 +862,7 @@ curl_formadd_ccsid(struct curl_httppost **httppost, lengthx = nargs; if(!forms) - value = (char *) va_arg(arg, curl_off_t); + value = (char *)va_arg(arg, curl_off_t); break; @@ -914,25 +870,25 @@ curl_formadd_ccsid(struct curl_httppost **httppost, namelengthx = nargs; if(!forms) - value = (char *) va_arg(arg, long); + value = (char *)va_arg(arg, long); break; case CURLFORM_BUFFERLENGTH: if(!forms) - value = (char *) va_arg(arg, long); + value = (char *)va_arg(arg, long); break; case CURLFORM_CONTENTHEADER: if(!forms) - value = (char *) va_arg(arg, struct curl_slist *); + value = (char *)va_arg(arg, struct curl_slist *); break; case CURLFORM_STREAM: if(!forms) - value = (char *) va_arg(arg, void *); + value = (char *)va_arg(arg, void *); break; @@ -958,10 +914,10 @@ curl_formadd_ccsid(struct curl_httppost **httppost, if(!forms) { value = va_arg(arg, char *); - ccsid = (unsigned int) va_arg(arg, long); + ccsid = (unsigned int)va_arg(arg, long); } else { - ccsid = (unsigned int) forms->value; + ccsid = (unsigned int)forms->value; forms++; } @@ -992,15 +948,15 @@ curl_formadd_ccsid(struct curl_httppost **httppost, if(Curl_formadd_convert(lforms, namex, namelengthx, nameccsid) < 0) result = CURL_FORMADD_MEMORY; else - lforms[namex].option = CURLFORM_COPYNAME; /* Force copy. */ - } + lforms[namex].option = CURLFORM_COPYNAME; /* Force copy. */ + } if(result == CURL_FORMADD_OK) { if(Curl_formadd_convert(lforms, contentx, lengthx, contentccsid) < 0) result = CURL_FORMADD_MEMORY; else contentx = -1; - } + } /* Do the formadd with our converted parameters. */ @@ -1008,7 +964,7 @@ curl_formadd_ccsid(struct curl_httppost **httppost, lforms[nargs].option = CURLFORM_END; result = curl_formadd(httppost, last_post, CURLFORM_ARRAY, lforms, CURLFORM_END); - } + } /* Terminate. */ @@ -1016,37 +972,35 @@ curl_formadd_ccsid(struct curl_httppost **httppost, return result; } - struct cfcdata { curl_formget_callback append; void * arg; unsigned int ccsid; }; - -static size_t -Curl_formget_callback_ccsid(void *arg, const char *buf, size_t len) +static size_t Curl_formget_callback_ccsid(void *arg, const char *buf, + size_t len) { struct cfcdata *p; char *b; int l; size_t ret; - p = (struct cfcdata *) arg; + p = (struct cfcdata *)arg; - if((long) len <= 0) + if((long)len <= 0) return (*p->append)(p->arg, buf, len); b = malloc(MAX_CONV_EXPANSION * len); if(!b) - return (size_t) -1; + return (size_t)-1; l = convert(b, MAX_CONV_EXPANSION * len, p->ccsid, buf, len, ASCII_CCSID); if(l < 0) { free(b); - return (size_t) -1; + return (size_t)-1; } ret = (*p->append)(p->arg, b, l); @@ -1054,22 +1008,18 @@ Curl_formget_callback_ccsid(void *arg, const char *buf, size_t len) return ret == l ? len : -1; } - -int -curl_formget_ccsid(struct curl_httppost *form, void *arg, - curl_formget_callback append, unsigned int ccsid) +int curl_formget_ccsid(struct curl_httppost *form, void *arg, + curl_formget_callback append, unsigned int ccsid) { struct cfcdata lcfc; lcfc.append = append; lcfc.arg = arg; lcfc.ccsid = ccsid; - return curl_formget(form, (void *) &lcfc, Curl_formget_callback_ccsid); + return curl_formget(form, (void *)&lcfc, Curl_formget_callback_ccsid); } - -CURLcode -curl_easy_setopt_ccsid(CURL *easy, CURLoption tag, ...) +CURLcode curl_easy_setopt_ccsid(CURL *easy, CURLoption tag, ...) { CURLcode result; va_list arg; @@ -1247,13 +1197,13 @@ curl_easy_setopt_ccsid(CURL *easy, CURLoption tag, ...) break; } - data->set.postfieldsize = pfsize; /* Replace data size. */ + data->set.postfieldsize = pfsize; /* Replace data size. */ s = cp; cp = NULL; } result = curl_easy_setopt(easy, CURLOPT_POSTFIELDS, s); - data->set.str[STRING_COPYPOSTFIELDS] = s; /* Give to library. */ + data->set.str[STRING_COPYPOSTFIELDS] = s; /* Give to library. */ break; default: @@ -1265,7 +1215,7 @@ curl_easy_setopt_ccsid(CURL *easy, CURLoption tag, ...) if(bp && bp->data && bp->len && ccsid != NOCONV_CCSID && ccsid != ASCII_CCSID) { - pfsize = (curl_off_t) bp->len * MAX_CONV_EXPANSION; + pfsize = (curl_off_t)bp->len * MAX_CONV_EXPANSION; if(pfsize > SIZE_MAX) pfsize = SIZE_MAX; @@ -1293,7 +1243,7 @@ curl_easy_setopt_ccsid(CURL *easy, CURLoption tag, ...) break; } FALLTHROUGH(); - case CURLOPT_ERRORBUFFER: /* This is an output buffer. */ + case CURLOPT_ERRORBUFFER: /* This is an output buffer. */ result = Curl_vsetopt(easy, tag, arg); break; } @@ -1303,46 +1253,39 @@ curl_easy_setopt_ccsid(CURL *easy, CURLoption tag, ...) return result; } - /* ILE/RPG helper functions. */ -char * -curl_form_long_value(long value) +char *curl_form_long_value(long value) { /* ILE/RPG cannot cast an integer to a pointer. This procedure does it. */ - return (char *) value; + return (char *)value; } - -CURLcode -curl_easy_setopt_RPGnum_(CURL *easy, CURLoption tag, curl_off_t arg) +CURLcode curl_easy_setopt_RPGnum_(CURL *easy, CURLoption tag, curl_off_t arg) { /* ILE/RPG procedure overloading cannot discriminate between different size and/or signedness of format arguments. This provides a generic wrapper that adapts size to the given tag expectation. This procedure is not intended to be explicitly called from user code. */ if(tag / 10000 != CURLOPTTYPE_OFF_T) - return curl_easy_setopt(easy, tag, (long) arg); + return curl_easy_setopt(easy, tag, (long)arg); return curl_easy_setopt(easy, tag, arg); } - -CURLcode -curl_multi_setopt_RPGnum_(CURLM *multi, CURLMoption tag, curl_off_t arg) +CURLcode curl_multi_setopt_RPGnum_(CURLM *multi, CURLMoption tag, + curl_off_t arg) { /* Likewise, for multi handle. */ if(tag / 10000 != CURLOPTTYPE_OFF_T) - return curl_multi_setopt(multi, tag, (long) arg); + return curl_multi_setopt(multi, tag, (long)arg); return curl_multi_setopt(multi, tag, arg); } - -char * -curl_pushheader_bynum_cssid(struct curl_pushheaders *h, - size_t num, unsigned int ccsid) +char *curl_pushheader_bynum_cssid(struct curl_pushheaders *h, size_t num, + unsigned int ccsid) { - char *d = (char *) NULL; + char *d = (char *)NULL; char *s = curl_pushheader_bynum(h, num); if(s) @@ -1351,19 +1294,18 @@ curl_pushheader_bynum_cssid(struct curl_pushheaders *h, return d; } - -char * -curl_pushheader_byname_ccsid(struct curl_pushheaders *h, const char *header, - unsigned int ccsidin, unsigned int ccsidout) +char *curl_pushheader_byname_ccsid(struct curl_pushheaders *h, + const char *header, unsigned int ccsidin, + unsigned int ccsidout) { - char *d = (char *) NULL; + char *d = (char *)NULL; if(header) { header = dynconvert(ASCII_CCSID, header, -1, ccsidin, NULL); if(header) { char *s = curl_pushheader_byname(h, header); - free((char *) header); + free((char *)header); if(s) d = dynconvert(ccsidout, s, -1, ASCII_CCSID, NULL); @@ -1377,7 +1319,7 @@ static CURLcode mime_string_call(curl_mimepart *part, const char *string, unsigned int ccsid, CURLcode (*mimefunc)(curl_mimepart *part, const char *string)) { - char *s = (char *) NULL; + char *s = (char *)NULL; CURLcode result; if(!string) @@ -1391,45 +1333,40 @@ mime_string_call(curl_mimepart *part, const char *string, unsigned int ccsid, return result; } -CURLcode -curl_mime_name_ccsid(curl_mimepart *part, const char *name, unsigned int ccsid) +CURLcode curl_mime_name_ccsid(curl_mimepart *part, const char *name, + unsigned int ccsid) { return mime_string_call(part, name, ccsid, curl_mime_name); } -CURLcode -curl_mime_filename_ccsid(curl_mimepart *part, - const char *filename, unsigned int ccsid) +CURLcode curl_mime_filename_ccsid(curl_mimepart *part, const char *filename, + unsigned int ccsid) { return mime_string_call(part, filename, ccsid, curl_mime_filename); } -CURLcode -curl_mime_type_ccsid(curl_mimepart *part, - const char *mimetype, unsigned int ccsid) +CURLcode curl_mime_type_ccsid(curl_mimepart *part, const char *mimetype, + unsigned int ccsid) { return mime_string_call(part, mimetype, ccsid, curl_mime_type); } -CURLcode -curl_mime_encoder_ccsid(curl_mimepart *part, - const char *encoding, unsigned int ccsid) +CURLcode curl_mime_encoder_ccsid(curl_mimepart *part, const char *encoding, + unsigned int ccsid) { return mime_string_call(part, encoding, ccsid, curl_mime_encoder); } -CURLcode -curl_mime_filedata_ccsid(curl_mimepart *part, - const char *filename, unsigned int ccsid) +CURLcode curl_mime_filedata_ccsid(curl_mimepart *part, const char *filename, + unsigned int ccsid) { return mime_string_call(part, filename, ccsid, curl_mime_filedata); } -CURLcode -curl_mime_data_ccsid(curl_mimepart *part, - const char *data, size_t datasize, unsigned int ccsid) +CURLcode curl_mime_data_ccsid(curl_mimepart *part, const char *data, + size_t datasize, unsigned int ccsid) { - char *s = (char *) NULL; + char *s = (char *)NULL; CURLcode result; int osize; @@ -1444,9 +1381,8 @@ curl_mime_data_ccsid(curl_mimepart *part, return result; } -CURLUcode -curl_url_get_ccsid(CURLU *handle, CURLUPart what, char **part, - unsigned int flags, unsigned int ccsid) +CURLUcode curl_url_get_ccsid(CURLU *handle, CURLUPart what, char **part, + unsigned int flags, unsigned int ccsid) { char *s = (char *)NULL; CURLUcode result; @@ -1468,9 +1404,8 @@ curl_url_get_ccsid(CURLU *handle, CURLUPart what, char **part, return result; } -CURLUcode -curl_url_set_ccsid(CURLU *handle, CURLUPart what, const char *part, - unsigned int flags, unsigned int ccsid) +CURLUcode curl_url_set_ccsid(CURLU *handle, CURLUPart what, const char *part, + unsigned int flags, unsigned int ccsid) { char *s = (char *)NULL; CURLUcode result; @@ -1513,14 +1448,13 @@ curl_easy_option_get_name_ccsid(const struct curl_easyoption *option, if(option && option->name) name = dynconvert(ccsid, option->name, -1, ASCII_CCSID, NULL); - return (const char *) name; + return (const char *)name; } /* Header API CCSID support. */ -CURLHcode -curl_easy_header_ccsid(CURL *easy, const char *name, size_t index, - unsigned int origin, int request, - struct curl_header **hout, unsigned int ccsid) +CURLHcode curl_easy_header_ccsid(CURL *easy, const char *name, size_t index, + unsigned int origin, int request, + struct curl_header **hout, unsigned int ccsid) { CURLHcode result = CURLHE_BAD_ARGUMENT; diff --git a/packages/OS400/ccsidcurl.h b/packages/OS400/ccsidcurl.h index ab01d32b854b..f9e667a9e41c 100644 --- a/packages/OS400/ccsidcurl.h +++ b/packages/OS400/ccsidcurl.h @@ -28,7 +28,6 @@ #include "easy.h" #include "multi.h" - CURL_EXTERN char *curl_version_ccsid(unsigned int ccsid); CURL_EXTERN char *curl_easy_escape_ccsid(CURL *handle, const char *string, int length, diff --git a/packages/OS400/curlcl.c b/packages/OS400/curlcl.c index ca497b351d43..7a7f3c6459d6 100644 --- a/packages/OS400/curlcl.c +++ b/packages/OS400/curlcl.c @@ -48,16 +48,13 @@ struct arguments { struct vary2 *cmdargs; /* Command line arguments. */ }; -static int -is_ifs(char c) +static int is_ifs(char c) { return c == ' ' || c == '\t' || c == '\r' || c == '\n'; } -static int -parse_command_line(const char *cmdargs, size_t len, - size_t *argc, char **argv, - size_t *argsize, char *argbuf) +static int parse_command_line(const char *cmdargs, size_t len, size_t *argc, + char **argv, size_t *argsize, char *argbuf) { const char *endline = cmdargs + len; char quote = '\0'; @@ -126,9 +123,7 @@ parse_command_line(const char *cmdargs, size_t len, return 0; } - -int -main(int argsc, struct arguments *args) +int main(int argsc, struct arguments *args) { size_t argc; char **argv; @@ -154,20 +149,20 @@ main(int argsc, struct arguments *args) if(!exitcode) { /* Allocate space for parsed arguments. */ - argv = (char **) malloc((argc + 1) * sizeof(*argv) + argsize); + argv = (char **)malloc((argc + 1) * sizeof(*argv) + argsize); if(!argv) { fputs("Memory allocation error\n", stderr); exitcode = -2; } else { - _SYSPTR pgmptr = rslvsp(WLI_PGM, (char *) CURLPGM, library, _AUTH_NONE); - _LU_Work_Area_T *luwrka = (_LU_Work_Area_T *) _LUWRKA(); + _SYSPTR pgmptr = rslvsp(WLI_PGM, (char *)CURLPGM, library, _AUTH_NONE); + _LU_Work_Area_T *luwrka = (_LU_Work_Area_T *)_LUWRKA(); - parse_command_line(args->cmdargs->string, args->cmdargs->len, - &argc, argv, &argsize, (char *) (argv + argc + 1)); + parse_command_line(args->cmdargs->string, args->cmdargs->len, &argc, + argv, &argsize, (char *)(argv + argc + 1)); /* Call program. */ - _CALLPGMV((void *) &pgmptr, argv, argc); + _CALLPGMV((void *)&pgmptr, argv, argc); exitcode = luwrka->LU_RC; free(argv); diff --git a/packages/OS400/curlmain.c b/packages/OS400/curlmain.c index 19328f7c8446..54ca865264dd 100644 --- a/packages/OS400/curlmain.c +++ b/packages/OS400/curlmain.c @@ -41,15 +41,13 @@ extern int QadrtFreeConversionTable(void); extern int QadrtFreeEnviron(void); extern char * setlocale_a(int, const char *); - /* The ASCII main program. */ -extern int main_a(int argc, char * * argv); +extern int main_a(int argc, char **argv); /* Global values of original EBCDIC arguments. */ int ebcdic_argc; char ** ebcdic_argv; - int main(int argc, char **argv) { int i; @@ -63,8 +61,8 @@ int main(int argc, char **argv) char dummybuf[128]; /* To/From codes are 32 byte long strings with reserved fields initialized to ZEROs */ - const char tocode[32] = {"IBMCCSID01208"}; /* Use UTF-8. */ - const char fromcode[32] = {"IBMCCSID000000000010"}; + const char tocode[32] = { "IBMCCSID01208" }; /* Use UTF-8. */ + const char fromcode[32] = { "IBMCCSID000000000010" }; ebcdic_argc = argc; ebcdic_argv = argv; @@ -88,10 +86,10 @@ int main(int argc, char **argv) } /* Allocate memory for the ASCII arguments and vector. */ - argv = (char **) malloc((argc + 1) * sizeof(*argv) + bytecount); + argv = (char **)malloc((argc + 1) * sizeof(*argv) + bytecount); /* Build the vector and convert argument encoding. */ - outbuf = (char *) (argv + argc + 1); + outbuf = (char *)(argv + argc + 1); outbytesleft = bytecount; for(i = 0; i < argc; i++) { @@ -112,7 +110,7 @@ int main(int argc, char **argv) i = main_a(argc, argv); /* Clean-up allocated items. */ - free((char *) argv); + free((char *)argv); QadrtFreeConversionTable(); QadrtFreeEnviron(); diff --git a/packages/OS400/os400sys.c b/packages/OS400/os400sys.c index 4d31d3827c88..04be163617a8 100644 --- a/packages/OS400/os400sys.c +++ b/packages/OS400/os400sys.c @@ -65,14 +65,13 @@ #pragma convert(0) /* Restore EBCDIC. */ -#define MIN_BYTE_GAIN 1024 /* Minimum gain when shortening a buffer. */ +#define MIN_BYTE_GAIN 1024 /* Minimum gain when shortening a buffer. */ struct buffer_t { unsigned long size; /* Buffer size. */ char *buf; /* Buffer address. */ }; - static char *buffer_undef(localkey_t key, long size); static char *buffer_threaded(localkey_t key, long size); static char *buffer_unthreaded(localkey_t key, long size); @@ -86,10 +85,10 @@ char *(*Curl_thread_buffer)(localkey_t key, long size) = buffer_undef; static void thdbufdestroy(void *private) { if(private) { - struct buffer_t *p = (struct buffer_t *) private; + struct buffer_t *p = (struct buffer_t *)private; localkey_t i; - for(i = (localkey_t) 0; i < LK_LAST; i++) { + for(i = (localkey_t)0; i < LK_LAST; i++) { free(p->buf); p++; } @@ -98,27 +97,23 @@ static void thdbufdestroy(void *private) } } - -static void -terminate(void) +static void terminate(void) { if(Curl_thread_buffer == buffer_threaded) { locbufs = pthread_getspecific(thdkey); - pthread_setspecific(thdkey, (void *) NULL); + pthread_setspecific(thdkey, (void *)NULL); pthread_key_delete(thdkey); } if(Curl_thread_buffer != buffer_undef) { - thdbufdestroy((void *) locbufs); - locbufs = (struct buffer_t *) NULL; + thdbufdestroy((void *)locbufs); + locbufs = (struct buffer_t *)NULL; } Curl_thread_buffer = buffer_undef; } - -static char * -get_buffer(struct buffer_t *buf, long size) +static char *get_buffer(struct buffer_t *buf, long size) { char *cp; @@ -136,7 +131,7 @@ get_buffer(struct buffer_t *buf, long size) return buf->buf; } - if((unsigned long) size <= buf->size) { + if((unsigned long)size <= buf->size) { /* Shorten the buffer only if it frees a significant byte count. This avoids some realloc() overhead. */ @@ -157,27 +152,23 @@ get_buffer(struct buffer_t *buf, long size) return cp; } - /* * Get buffer address for the given local key. * This is always called though `Curl_thread_buffer' and when threads are * NOT made available by the os, so no mutex lock/unlock occurs. */ -static char * -buffer_unthreaded(localkey_t key, long size) +static char *buffer_unthreaded(localkey_t key, long size) { return get_buffer(locbufs + key, size); } - /* * Get buffer address for the given local key, taking care of * concurrent threads. * This is always called though `Curl_thread_buffer' and when threads are * made available by the os. */ -static char * -buffer_threaded(localkey_t key, long size) +static char *buffer_threaded(localkey_t key, long size) { struct buffer_t *bufs; @@ -185,30 +176,28 @@ buffer_threaded(localkey_t key, long size) make sure it is at least `size'-byte long. Set `size' to < 0 to get its address only. */ - bufs = (struct buffer_t *) pthread_getspecific(thdkey); + bufs = (struct buffer_t *)pthread_getspecific(thdkey); if(!bufs) { if(size < 0) - return (char *) NULL; /* No buffer yet. */ + return (char *)NULL; /* No buffer yet. */ /* Allocate buffer descriptors for the current thread. */ - bufs = calloc((size_t) LK_LAST, sizeof(*bufs)); + bufs = calloc((size_t)LK_LAST, sizeof(*bufs)); if(!bufs) - return (char *) NULL; + return (char *)NULL; - if(pthread_setspecific(thdkey, (void *) bufs)) { + if(pthread_setspecific(thdkey, (void *)bufs)) { free(bufs); - return (char *) NULL; + return (char *)NULL; } } return get_buffer(bufs + key, size); } - -static char * -buffer_undef(localkey_t key, long size) +static char *buffer_undef(localkey_t key, long size) { /* Define the buffer system, get the buffer for the given local key in the current thread, and make sure it is at least `size'-byte long. @@ -218,7 +207,7 @@ buffer_undef(localkey_t key, long size) /* Determine if we can use pthread-specific data. */ - if(Curl_thread_buffer == buffer_undef) { /* If unchanged during lock. */ + if(Curl_thread_buffer == buffer_undef) { /* If unchanged during lock. */ /* OS400 interactive jobs do not support threads: check here. */ if(!pthread_key_create(&thdkey, thdbufdestroy)) { /* Threads are supported: use the thread-aware buffer procedure. */ @@ -227,10 +216,10 @@ buffer_undef(localkey_t key, long size) else { /* No multi-threading available: allocate storage for single-thread * buffer headers. */ - locbufs = calloc((size_t) LK_LAST, sizeof(*locbufs)); + locbufs = calloc((size_t)LK_LAST, sizeof(*locbufs)); if(!locbufs) { - pthread_mutex_unlock(&mutex); /* For symetry: will probably fail. */ - return (char *) NULL; + pthread_mutex_unlock(&mutex); /* For symetry: will probably fail. */ + return (char *)NULL; } else Curl_thread_buffer = buffer_unthreaded; /* Use unthreaded version. */ @@ -243,15 +232,13 @@ buffer_undef(localkey_t key, long size) return Curl_thread_buffer(key, size); } - -static char * -set_thread_string(localkey_t key, const char *s) +static char *set_thread_string(localkey_t key, const char *s) { int i; char *cp; if(!s) - return (char *) NULL; + return (char *)NULL; i = strlen(s) + 1; cp = Curl_thread_buffer(key, MAX_CONV_EXPANSION * i + 1); @@ -264,12 +251,10 @@ set_thread_string(localkey_t key, const char *s) return cp; } - -int -Curl_getnameinfo_a(const struct sockaddr *sa, socklen_t salen, - char *nodename, socklen_t nodenamelen, - char *servname, socklen_t servnamelen, - int flags) +int Curl_getnameinfo_a(const struct sockaddr *sa, socklen_t salen, + char *nodename, socklen_t nodenamelen, + char *servname, socklen_t servnamelen, + int flags) { char *enodename = NULL; char *eservname = NULL; @@ -289,20 +274,20 @@ Curl_getnameinfo_a(const struct sockaddr *sa, socklen_t salen, } } - status = getnameinfo(sa, salen, enodename, nodenamelen, - eservname, servnamelen, flags); + status = getnameinfo(sa, salen, enodename, nodenamelen, eservname, + servnamelen, flags); if(!status) { int i; if(enodename) { - i = QadrtConvertE2A(nodename, enodename, - nodenamelen - 1, strlen(enodename)); + i = QadrtConvertE2A(nodename, enodename, nodenamelen - 1, + strlen(enodename)); nodename[i] = '\0'; } if(eservname) { - i = QadrtConvertE2A(servname, eservname, - servnamelen - 1, strlen(eservname)); + i = QadrtConvertE2A(servname, eservname, servnamelen - 1, + strlen(eservname)); servname[i] = '\0'; } } @@ -312,18 +297,16 @@ Curl_getnameinfo_a(const struct sockaddr *sa, socklen_t salen, return status; } -int -Curl_getaddrinfo_a(const char *nodename, const char *servname, - const struct addrinfo *hints, - struct addrinfo **res) +int Curl_getaddrinfo_a(const char *nodename, const char *servname, + const struct addrinfo *hints, struct addrinfo **res) { char *enodename; char *eservname; int status; int i; - enodename = (char *) NULL; - eservname = (char *) NULL; + enodename = (char *)NULL; + eservname = (char *)NULL; if(nodename) { i = strlen(nodename); @@ -360,8 +343,7 @@ Curl_getaddrinfo_a(const char *nodename, const char *servname, /* ASCII wrappers for the GSSAPI procedures. */ -static int -Curl_gss_convert_in_place(OM_uint32 *minor_status, gss_buffer_t buf) +static int Curl_gss_convert_in_place(OM_uint32 *minor_status, gss_buffer_t buf) { unsigned int i = buf->length; @@ -388,10 +370,8 @@ Curl_gss_convert_in_place(OM_uint32 *minor_status, gss_buffer_t buf) return 0; } - -OM_uint32 -Curl_gss_import_name_a(OM_uint32 *minor_status, gss_buffer_t in_name, - gss_OID in_name_type, gss_name_t *out_name) +OM_uint32 Curl_gss_import_name_a(OM_uint32 *minor_status, gss_buffer_t in_name, + gss_OID in_name_type, gss_name_t *out_name) { OM_uint32 rc; unsigned int i; @@ -400,7 +380,7 @@ Curl_gss_import_name_a(OM_uint32 *minor_status, gss_buffer_t in_name, if(!in_name || !in_name->value || !in_name->length) return gss_import_name(minor_status, in_name, in_name_type, out_name); - memcpy((char *) &in, (char *) in_name, sizeof(in)); + memcpy((char *)&in, (char *)in_name, sizeof(in)); i = in.length; in.value = malloc(i + 1); @@ -413,17 +393,17 @@ Curl_gss_import_name_a(OM_uint32 *minor_status, gss_buffer_t in_name, } QadrtConvertA2E(in.value, in_name->value, i, i); - ((char *) in.value)[i] = '\0'; + ((char *)in.value)[i] = '\0'; rc = gss_import_name(minor_status, &in, in_name_type, out_name); free(in.value); return rc; } -OM_uint32 -Curl_gss_display_status_a(OM_uint32 *minor_status, OM_uint32 status_value, - int status_type, gss_OID mech_type, - gss_msg_ctx_t *message_context, - gss_buffer_t status_string) +OM_uint32 Curl_gss_display_status_a(OM_uint32 *minor_status, + OM_uint32 status_value, int status_type, + gss_OID mech_type, + gss_msg_ctx_t *message_context, + gss_buffer_t status_string) { int rc; @@ -477,7 +457,7 @@ Curl_gss_init_sec_context_a(OM_uint32 *minor_status, } QadrtConvertA2E(in.value, input_token->value, i, i); - ((char *) in.value)[i] = '\0'; + ((char *)in.value)[i] = '\0'; in.length = i; inp = ∈ } @@ -503,11 +483,9 @@ Curl_gss_init_sec_context_a(OM_uint32 *minor_status, return rc; } - -OM_uint32 -Curl_gss_delete_sec_context_a(OM_uint32 *minor_status, - gss_ctx_id_t *context_handle, - gss_buffer_t output_token) +OM_uint32 Curl_gss_delete_sec_context_a(OM_uint32 *minor_status, + gss_ctx_id_t *context_handle, + gss_buffer_t output_token) { OM_uint32 rc; @@ -533,38 +511,36 @@ Curl_gss_delete_sec_context_a(OM_uint32 *minor_status, /* ASCII wrappers for the LDAP procedures. */ -void * -Curl_ldap_init_a(char *host, int port) +void *Curl_ldap_init_a(char *host, int port) { size_t i; char *ehost; void *result; if(!host) - return (void *) ldap_init(host, port); + return (void *)ldap_init(host, port); i = strlen(host); ehost = malloc(i + 1); if(!ehost) - return (void *) NULL; + return (void *)NULL; QadrtConvertA2E(ehost, host, i, i); ehost[i] = '\0'; - result = (void *) ldap_init(ehost, port); + result = (void *)ldap_init(ehost, port); free(ehost); return result; } -int -Curl_ldap_simple_bind_s_a(void *ld, char *dn, char *passwd) +int Curl_ldap_simple_bind_s_a(void *ld, char *dn, char *passwd) { int i; char *edn; char *epasswd; - edn = (char *) NULL; - epasswd = (char *) NULL; + edn = (char *)NULL; + epasswd = (char *)NULL; if(dn) { i = strlen(dn); @@ -596,9 +572,8 @@ Curl_ldap_simple_bind_s_a(void *ld, char *dn, char *passwd) return i; } -int -Curl_ldap_search_s_a(void *ld, char *base, int scope, char *filter, - char **attrs, int attrsonly, LDAPMessage **res) +int Curl_ldap_search_s_a(void *ld, char *base, int scope, char *filter, + char **attrs, int attrsonly, LDAPMessage **res) { int i; int j; @@ -607,9 +582,9 @@ Curl_ldap_search_s_a(void *ld, char *base, int scope, char *filter, char **eattrs; int status; - ebase = (char *) NULL; - efilter = (char *) NULL; - eattrs = (char **) NULL; + ebase = (char *)NULL; + efilter = (char *)NULL; + eattrs = (char **)NULL; status = LDAP_SUCCESS; if(base) { @@ -676,14 +651,13 @@ Curl_ldap_search_s_a(void *ld, char *base, int scope, char *filter, return status; } - -struct berval ** -Curl_ldap_get_values_len_a(void *ld, LDAPMessage *entry, const char *attr) +struct berval **Curl_ldap_get_values_len_a(void *ld, LDAPMessage *entry, + const char *attr) { char *cp; struct berval **result; - cp = (char *) NULL; + cp = (char *)NULL; if(attr) { int i = strlen(attr); @@ -692,7 +666,7 @@ Curl_ldap_get_values_len_a(void *ld, LDAPMessage *entry, const char *attr) if(!cp) { ldap_set_lderrno(ld, LDAP_NO_MEMORY, NULL, ldap_err2string(LDAP_NO_MEMORY)); - return (struct berval **) NULL; + return (struct berval **)NULL; } QadrtConvertA2E(cp, attr, i, i); @@ -708,14 +682,12 @@ Curl_ldap_get_values_len_a(void *ld, LDAPMessage *entry, const char *attr) return result; } -char * -Curl_ldap_err2string_a(int error) +char *Curl_ldap_err2string_a(int error) { return set_thread_string(LK_LDAP_ERROR, ldap_err2string(error)); } -char * -Curl_ldap_get_dn_a(void *ld, LDAPMessage *entry) +char *Curl_ldap_get_dn_a(void *ld, LDAPMessage *entry) { int i; char *cp; @@ -744,9 +716,8 @@ Curl_ldap_get_dn_a(void *ld, LDAPMessage *entry) return cp; } -char * -Curl_ldap_first_attribute_a(void *ld, - LDAPMessage *entry, BerElement **berptr) +char *Curl_ldap_first_attribute_a(void *ld, LDAPMessage *entry, + BerElement **berptr) { int i; char *cp; @@ -775,9 +746,8 @@ Curl_ldap_first_attribute_a(void *ld, return cp; } -char * -Curl_ldap_next_attribute_a(void *ld, - LDAPMessage *entry, BerElement *berptr) +char *Curl_ldap_next_attribute_a(void *ld, LDAPMessage *entry, + BerElement *berptr) { int i; char *cp; @@ -808,9 +778,8 @@ Curl_ldap_next_attribute_a(void *ld, #endif /* CURL_DISABLE_LDAP */ -static int -sockaddr2ebcdic(struct sockaddr_storage *dstaddr, - const struct sockaddr *srcaddr, int srclen) +static int sockaddr2ebcdic(struct sockaddr_storage *dstaddr, + const struct sockaddr *srcaddr, int srclen) { const struct sockaddr_un *srcu; struct sockaddr_un *dstu; @@ -826,13 +795,13 @@ sockaddr2ebcdic(struct sockaddr_storage *dstaddr, return -1; } - memcpy((char *) dstaddr, (char *) srcaddr, srclen); + memcpy((char *)dstaddr, (char *)srcaddr, srclen); switch(srcaddr->sa_family) { case AF_UNIX: - srcu = (const struct sockaddr_un *) srcaddr; - dstu = (struct sockaddr_un *) dstaddr; + srcu = (const struct sockaddr_un *)srcaddr; + dstu = (struct sockaddr_un *)dstaddr; dstsize = sizeof(*dstaddr) - offsetof(struct sockaddr_un, sun_path); srclen -= offsetof(struct sockaddr_un, sun_path); i = QadrtConvertA2E(dstu->sun_path, srcu->sun_path, dstsize - 1, srclen); @@ -843,10 +812,8 @@ sockaddr2ebcdic(struct sockaddr_storage *dstaddr, return srclen; } - -static int -sockaddr2ascii(struct sockaddr *dstaddr, int dstlen, - const struct sockaddr_storage *srcaddr, int srclen) +static int sockaddr2ascii(struct sockaddr *dstaddr, int dstlen, + const struct sockaddr_storage *srcaddr, int srclen) { const struct sockaddr_un *srcu; struct sockaddr_un *dstu; @@ -864,15 +831,15 @@ sockaddr2ascii(struct sockaddr *dstaddr, int dstlen, return -1; } - memcpy((char *) dstaddr, (char *) srcaddr, srclen); + memcpy((char *)dstaddr, (char *)srcaddr, srclen); if(srclen >= offsetof(struct sockaddr_storage, ss_family) + sizeof(srcaddr->ss_family)) { switch(srcaddr->ss_family) { case AF_UNIX: - srcu = (const struct sockaddr_un *) srcaddr; - dstu = (struct sockaddr_un *) dstaddr; + srcu = (const struct sockaddr_un *)srcaddr; + dstu = (struct sockaddr_un *)dstaddr; dstsize = dstlen - offsetof(struct sockaddr_un, sun_path); srclen -= offsetof(struct sockaddr_un, sun_path); if(dstsize > 0 && srclen > 0) { @@ -887,8 +854,7 @@ sockaddr2ascii(struct sockaddr *dstaddr, int dstlen, return srclen; } -int -Curl_os400_connect(int sd, struct sockaddr *destaddr, int addrlen) +int Curl_os400_connect(int sd, struct sockaddr *destaddr, int addrlen) { int i; struct sockaddr_storage laddr; @@ -898,11 +864,10 @@ Curl_os400_connect(int sd, struct sockaddr *destaddr, int addrlen) if(i < 0) return -1; - return connect(sd, (struct sockaddr *) &laddr, i); + return connect(sd, (struct sockaddr *)&laddr, i); } -int -Curl_os400_bind(int sd, struct sockaddr *localaddr, int addrlen) +int Curl_os400_bind(int sd, struct sockaddr *localaddr, int addrlen) { int i; struct sockaddr_storage laddr; @@ -912,12 +877,11 @@ Curl_os400_bind(int sd, struct sockaddr *localaddr, int addrlen) if(i < 0) return -1; - return bind(sd, (struct sockaddr *) &laddr, i); + return bind(sd, (struct sockaddr *)&laddr, i); } -int -Curl_os400_sendto(int sd, char *buffer, int buflen, int flags, - const struct sockaddr *dstaddr, int addrlen) +int Curl_os400_sendto(int sd, char *buffer, int buflen, int flags, + const struct sockaddr *dstaddr, int addrlen) { int i; struct sockaddr_storage laddr; @@ -927,12 +891,11 @@ Curl_os400_sendto(int sd, char *buffer, int buflen, int flags, if(i < 0) return -1; - return sendto(sd, buffer, buflen, flags, (struct sockaddr *) &laddr, i); + return sendto(sd, buffer, buflen, flags, (struct sockaddr *)&laddr, i); } -int -Curl_os400_recvfrom(int sd, char *buffer, int buflen, int flags, - struct sockaddr *fromaddr, int *addrlen) +int Curl_os400_recvfrom(int sd, char *buffer, int buflen, int flags, + struct sockaddr *fromaddr, int *addrlen) { int rcvlen; struct sockaddr_storage laddr; @@ -943,7 +906,7 @@ Curl_os400_recvfrom(int sd, char *buffer, int buflen, int flags, laddr.ss_family = AF_UNSPEC; /* To detect if unused. */ rcvlen = recvfrom(sd, buffer, buflen, flags, - (struct sockaddr *) &laddr, &laddrlen); + (struct sockaddr *)&laddr, &laddrlen); if(rcvlen < 0) return rcvlen; @@ -959,12 +922,11 @@ Curl_os400_recvfrom(int sd, char *buffer, int buflen, int flags, return rcvlen; } -int -Curl_os400_getpeername(int sd, struct sockaddr *addr, int *addrlen) +int Curl_os400_getpeername(int sd, struct sockaddr *addr, int *addrlen) { struct sockaddr_storage laddr; int laddrlen = sizeof(laddr); - int retcode = getpeername(sd, (struct sockaddr *) &laddr, &laddrlen); + int retcode = getpeername(sd, (struct sockaddr *)&laddr, &laddrlen); if(!retcode) { laddrlen = sockaddr2ascii(addr, *addrlen, &laddr, laddrlen); @@ -976,12 +938,11 @@ Curl_os400_getpeername(int sd, struct sockaddr *addr, int *addrlen) return retcode; } -int -Curl_os400_getsockname(int sd, struct sockaddr *addr, int *addrlen) +int Curl_os400_getsockname(int sd, struct sockaddr *addr, int *addrlen) { struct sockaddr_storage laddr; int laddrlen = sizeof(laddr); - int retcode = getsockname(sd, (struct sockaddr *) &laddr, &laddrlen); + int retcode = getsockname(sd, (struct sockaddr *)&laddr, &laddrlen); if(!retcode) { laddrlen = sockaddr2ascii(addr, *addrlen, &laddr, laddrlen); @@ -993,17 +954,14 @@ Curl_os400_getsockname(int sd, struct sockaddr *addr, int *addrlen) return retcode; } - #ifdef HAVE_LIBZ -const char * -Curl_os400_zlibVersion(void) +const char *Curl_os400_zlibVersion(void) { return set_thread_string(LK_ZLIB_VERSION, zlibVersion()); } - -int -Curl_os400_inflateInit_(z_streamp strm, const char *version, int stream_size) +int Curl_os400_inflateInit_(z_streamp strm, const char *version, + int stream_size) { z_const char *msgb4 = strm->msg; int ret; @@ -1016,9 +974,8 @@ Curl_os400_inflateInit_(z_streamp strm, const char *version, int stream_size) return ret; } -int -Curl_os400_inflateInit2_(z_streamp strm, int windowBits, - const char *version, int stream_size) +int Curl_os400_inflateInit2_(z_streamp strm, int windowBits, + const char *version, int stream_size) { z_const char *msgb4 = strm->msg; int ret; @@ -1031,8 +988,7 @@ Curl_os400_inflateInit2_(z_streamp strm, int windowBits, return ret; } -int -Curl_os400_inflate(z_streamp strm, int flush) +int Curl_os400_inflate(z_streamp strm, int flush) { z_const char *msgb4 = strm->msg; int ret; @@ -1045,8 +1001,7 @@ Curl_os400_inflate(z_streamp strm, int flush) return ret; } -int -Curl_os400_inflateEnd(z_streamp strm) +int Curl_os400_inflateEnd(z_streamp strm) { z_const char *msgb4 = strm->msg; int ret; diff --git a/packages/OS400/os400sys.h b/packages/OS400/os400sys.h index d5ff412f2852..eb2cdb828ace 100644 --- a/packages/OS400/os400sys.h +++ b/packages/OS400/os400sys.h @@ -28,30 +28,27 @@ #ifndef __OS400_SYS_ #define __OS400_SYS_ - /* Per-thread item identifiers. */ typedef enum { - LK_GSK_ERROR, - LK_LDAP_ERROR, - LK_CURL_VERSION, - LK_VERSION_INFO, - LK_VERSION_INFO_DATA, - LK_EASY_STRERROR, - LK_SHARE_STRERROR, - LK_MULTI_STRERROR, - LK_URL_STRERROR, - LK_ZLIB_VERSION, - LK_ZLIB_MSG, - LK_LAST -} localkey_t; - - -extern char * (* Curl_thread_buffer)(localkey_t key, long size); - + LK_GSK_ERROR, + LK_LDAP_ERROR, + LK_CURL_VERSION, + LK_VERSION_INFO, + LK_VERSION_INFO_DATA, + LK_EASY_STRERROR, + LK_SHARE_STRERROR, + LK_MULTI_STRERROR, + LK_URL_STRERROR, + LK_ZLIB_VERSION, + LK_ZLIB_MSG, + LK_LAST +} localkey_t; + +extern char *(*Curl_thread_buffer)(localkey_t key, long size); /* Maximum string expansion factor due to character code conversion. */ -#define MAX_CONV_EXPANSION 4 /* Can deal with UTF-8. */ +#define MAX_CONV_EXPANSION 4 /* Can deal with UTF-8. */ #endif diff --git a/packages/vms/curl_crtl_init.c b/packages/vms/curl_crtl_init.c index d6500c08cde3..7966a38f820b 100644 --- a/packages/vms/curl_crtl_init.c +++ b/packages/vms/curl_crtl_init.c @@ -78,34 +78,29 @@ struct itmlst_3 { #pragma member_alignment restore #ifdef __VAX -#define ENABLE "ENABLE" +#define ENABLE "ENABLE" #define DISABLE "DISABLE" #else -#define ENABLE TRUE +#define ENABLE TRUE #define DISABLE 0 -int decc$feature_get_index (const char *name); -int decc$feature_set_value (int index, int mode, int value); +int decc$feature_get_index(const char *name); +int decc$feature_set_value(int index, int mode, int value); #endif -int SYS$TRNLNM( - const unsigned long *attr, - const struct dsc$descriptor_s *table_dsc, - struct dsc$descriptor_s *name_dsc, - const unsigned char *acmode, - const struct itmlst_3 *item_list); -int SYS$CRELNM( - const unsigned long *attr, - const struct dsc$descriptor_s *table_dsc, - const struct dsc$descriptor_s *name_dsc, - const unsigned char *acmode, - const struct itmlst_3 *item_list); - +int SYS$TRNLNM(const unsigned long *attr, + const struct dsc$descriptor_s *table_dsc, + struct dsc$descriptor_s *name_dsc, + const unsigned char *acmode, + const struct itmlst_3 *item_list); +int SYS$CRELNM(const unsigned long *attr, + const struct dsc$descriptor_s *table_dsc, + const struct dsc$descriptor_s *name_dsc, + const unsigned char *acmode, + const struct itmlst_3 *item_list); /* Take all the fun out of simply looking up a logical name */ -static int sys_trnlnm(const char *logname, - char *value, - int value_len) +static int sys_trnlnm(const char *logname, char *value, int value_len) { const $DESCRIPTOR(table_dsc, "LNM$FILE_DEV"); const unsigned long attr = LNM$M_CASE_BLIND; @@ -140,8 +135,7 @@ static int sys_trnlnm(const char *logname, } /* How to simply create a logical name */ -static int sys_crelnm(const char *logname, - const char *value) +static int sys_crelnm(const char *logname, const char *value) { int ret_val; const char *proc_table = "LNM$PROCESS_TABLE"; @@ -149,12 +143,12 @@ static int sys_crelnm(const char *logname, struct dsc$descriptor_s logname_dsc; struct itmlst_3 item_list[2]; - proc_table_dsc.dsc$a_pointer = (char *) proc_table; + proc_table_dsc.dsc$a_pointer = (char *)proc_table; proc_table_dsc.dsc$w_length = strlen(proc_table); proc_table_dsc.dsc$b_dtype = DSC$K_DTYPE_T; proc_table_dsc.dsc$b_class = DSC$K_CLASS_S; - logname_dsc.dsc$a_pointer = (char *) logname; + logname_dsc.dsc$a_pointer = (char *)logname; logname_dsc.dsc$w_length = strlen(logname); logname_dsc.dsc$b_dtype = DSC$K_DTYPE_T; logname_dsc.dsc$b_class = DSC$K_CLASS_S; @@ -172,7 +166,6 @@ static int sys_crelnm(const char *logname, return ret_val; } - /* Start of DECC RTL Feature handling */ /* @@ -191,7 +184,7 @@ static void set_feature_default(const char *name, int value) index = decc$feature_get_index(name); if(index > 0) - decc$feature_set_value (index, 0, value); + decc$feature_set_value(index, 0, value); } #endif @@ -202,7 +195,7 @@ static void set_features(void) int use_unix_settings = 1; status = sys_trnlnm("GNV$UNIX_SHELL", - unix_shell_name, sizeof(unix_shell_name) -1); + unix_shell_name, sizeof(unix_shell_name) - 1); if(!$VMS_STATUS_SUCCESS(status)) { use_unix_settings = 0; } @@ -262,7 +255,6 @@ static void set_features(void) set_feature_default("DECC$FILE_OWNER_UNIX", ENABLE); set_feature_default("DECC$POSIX_SEEK_STREAM_FILE", ENABLE); - } else { set_feature_default("DECC$FILENAME_UNIX_REPORT", ENABLE); @@ -285,10 +277,9 @@ static void set_features(void) /* Commented here to prevent future bugs: A program or user should */ /* never ever enable DECC$POSIX_STYLE_UID. */ /* It will probably break all code that accesses UIDs */ - /* do_not_set_default ("DECC$POSIX_STYLE_UID", TRUE); */ + /* do_not_set_default("DECC$POSIX_STYLE_UID", TRUE); */ } - /* Some boilerplate to force this to be a proper LIB$INITIALIZE section */ #pragma nostandard @@ -306,7 +297,7 @@ static void set_features(void) # endif #endif /* Set our contribution to the LIB$INITIALIZE array */ -void (* const iniarray[])(void) = {set_features }; +void (* const iniarray[])(void) = { set_features }; #ifndef __VAX # if __INITIAL_POINTER_SIZE # pragma __pointer_size __restore @@ -315,7 +306,6 @@ void (* const iniarray[])(void) = {set_features }; # endif #endif - /* ** Force a reference to LIB$INITIALIZE to ensure it ** exists in the image. @@ -324,7 +314,7 @@ int LIB$INITIALIZE(void); #ifdef __DECC #pragma extern_model strict_refdef #endif - int lib_init_ref = (int) LIB$INITIALIZE; +int lib_init_ref = (int)LIB$INITIALIZE; #ifdef __DECC #pragma extern_model restore #pragma standard diff --git a/packages/vms/curlmsg.h b/packages/vms/curlmsg.h index 9b5c4c76d144..f05c3a8f5a03 100644 --- a/packages/vms/curlmsg.h +++ b/packages/vms/curlmsg.h @@ -50,93 +50,93 @@ /* IF YOU UPDATE THIS FILE, UPDATE CURLMSG_VMS.H SO THAT THEY ARE IN SYNC */ /* */ -#define CURL_FACILITY 3841 -#define CURL_OK 251756553 -#define CURL_UNSUPPORTED_PROTOCOL 251756562 -#define CURL_FAILED_INIT 251756570 -#define CURL_URL_MALFORMAT 251756578 -#define CURL_OBSOLETE4 251756586 -#define CURL_COULDNT_RESOLVE_PROXY 251756594 -#define CURL_COULDNT_RESOLVE_HOST 251756602 -#define CURL_COULDNT_CONNECT 251756610 -#define CURL_WEIRD_SERVER_REPLY 251756618 +#define CURL_FACILITY 3841 +#define CURL_OK 251756553 +#define CURL_UNSUPPORTED_PROTOCOL 251756562 +#define CURL_FAILED_INIT 251756570 +#define CURL_URL_MALFORMAT 251756578 +#define CURL_OBSOLETE4 251756586 +#define CURL_COULDNT_RESOLVE_PROXY 251756594 +#define CURL_COULDNT_RESOLVE_HOST 251756602 +#define CURL_COULDNT_CONNECT 251756610 +#define CURL_WEIRD_SERVER_REPLY 251756618 #define CURL_FTP_WEIRD_SERVER_REPLY CURL_WEIRD_SERVER_REPLY -#define CURL_FTP_ACCESS_DENIED 251756626 -#define CURL_OBSOLETE10 251756634 -#define CURL_FTP_WEIRD_PASS_REPLY 251756642 -#define CURL_OBSOLETE12 251756650 -#define CURL_FTP_WEIRD_PASV_REPLY 251756658 -#define CURL_FTP_WEIRD_227_FORMAT 251756666 -#define CURL_FTP_CANT_GET_HOST 251756674 -#define CURL_OBSOLETE16 251756682 -#define CURL_FTP_COULDNT_SET_TYPE 251756690 -#define CURL_PARTIAL_FILE 251756698 -#define CURL_FTP_COULDNT_RETR_FILE 251756706 -#define CURL_OBSOLETE20 251756714 -#define CURL_QUOTE_ERROR 251756722 -#define CURL_HTTP_RETURNED_ERROR 251756730 -#define CURL_WRITE_ERROR 251756738 -#define CURL_OBSOLETE24 251756746 -#define CURL_UPLOAD_FAILED 251756754 -#define CURL_READ_ERROR 251756762 -#define CURL_OUT_OF_MEMORY 251756770 -#define CURL_OPERATION_TIMEOUTED 251756778 -#define CURL_OBSOLETE29 251756786 -#define CURL_FTP_PORT_FAILED 251756794 -#define CURL_FTP_COULDNT_USE_REST 251756802 -#define CURL_OBSOLETE32 251756810 -#define CURL_RANGE_ERROR 251756818 -#define CURL_HTTP_POST_ERROR 251756826 -#define CURL_SSL_CONNECT_ERROR 251756834 -#define CURL_BAD_DOWNLOAD_RESUME 251756842 +#define CURL_FTP_ACCESS_DENIED 251756626 +#define CURL_OBSOLETE10 251756634 +#define CURL_FTP_WEIRD_PASS_REPLY 251756642 +#define CURL_OBSOLETE12 251756650 +#define CURL_FTP_WEIRD_PASV_REPLY 251756658 +#define CURL_FTP_WEIRD_227_FORMAT 251756666 +#define CURL_FTP_CANT_GET_HOST 251756674 +#define CURL_OBSOLETE16 251756682 +#define CURL_FTP_COULDNT_SET_TYPE 251756690 +#define CURL_PARTIAL_FILE 251756698 +#define CURL_FTP_COULDNT_RETR_FILE 251756706 +#define CURL_OBSOLETE20 251756714 +#define CURL_QUOTE_ERROR 251756722 +#define CURL_HTTP_RETURNED_ERROR 251756730 +#define CURL_WRITE_ERROR 251756738 +#define CURL_OBSOLETE24 251756746 +#define CURL_UPLOAD_FAILED 251756754 +#define CURL_READ_ERROR 251756762 +#define CURL_OUT_OF_MEMORY 251756770 +#define CURL_OPERATION_TIMEOUTED 251756778 +#define CURL_OBSOLETE29 251756786 +#define CURL_FTP_PORT_FAILED 251756794 +#define CURL_FTP_COULDNT_USE_REST 251756802 +#define CURL_OBSOLETE32 251756810 +#define CURL_RANGE_ERROR 251756818 +#define CURL_HTTP_POST_ERROR 251756826 +#define CURL_SSL_CONNECT_ERROR 251756834 +#define CURL_BAD_DOWNLOAD_RESUME 251756842 #define CURL_FILE_COULDNT_READ_FILE 251756850 -#define CURL_LDAP_CANNOT_BIND 251756858 -#define CURL_LDAP_SEARCH_FAILED 251756866 -#define CURL_OBSOLETE40 251756874 -#define CURL_FUNCTION_NOT_FOUND 251756882 -#define CURL_ABORTED_BY_CALLBACK 251756890 -#define CURL_BAD_FUNCTION_ARGUMENT 251756898 -#define CURL_OBSOLETE44 251756906 -#define CURL_INTERFACE_FAILED 251756914 -#define CURL_OBSOLETE46 251756922 -#define CURL_TOO_MANY_REDIRECTS 251756930 -#define CURL_UNKNOWN_TELNET_OPTION 251756938 -#define CURL_TELNET_OPTION_SYNTAX 251756946 -#define CURL_OBSOLETE50 251756954 -#define CURL_PEER_FAILED_VERIF 251756962 -#define CURL_GOT_NOTHING 251756970 -#define CURL_SSL_ENGINE_NOTFOUND 251756978 -#define CURL_SSL_ENGINE_SETFAILED 251756986 -#define CURL_SEND_ERROR 251756994 -#define CURL_RECV_ERROR 251757002 -#define CURL_OBSOLETE57 251757010 -#define CURL_SSL_CERTPROBLEM 251757018 -#define CURL_SSL_CIPHER 251757026 -#define CURL_SSL_CACERT 251757034 -#define CURL_BAD_CONTENT_ENCODING 251757042 -#define CURL_LDAP_INVALID_URL 251757050 -#define CURL_FILESIZE_EXCEEDED 251757058 -#define CURL_USE_SSL_FAILED 251757066 -#define CURL_SEND_FAIL_REWIND 251757074 -#define CURL_SSL_ENGINE_INITFAILED 251757082 -#define CURL_LOGIN_DENIED 251757090 -#define CURL_TFTP_NOTFOUND 251757098 -#define CURL_TFTP_PERM 251757106 -#define CURL_REMOTE_DISK_FULL 251757114 -#define CURL_TFTP_ILLEGAL 251757122 -#define CURL_TFTP_UNKNOWNID 251757130 -#define CURL_REMOTE_FILE_EXISTS 251757138 -#define CURL_TFTP_NOSUCHUSER 251757146 -#define CURL_CONV_FAILED 251757154 -#define CURL_CONV_REQD 251757162 -#define CURL_SSL_CACERT_BADFILE 251757170 -#define CURL_REMOTE_FILE_NOT_FOUND 251757178 -#define CURL_SSH 251757186 -#define CURL_SSL_SHUTDOWN_FAILED 251757194 -#define CURL_AGAIN 251757202 -#define CURL_SSL_CRL_BADFILE 251757210 -#define CURL_SSL_ISSUER_ERROR 251757218 -#define CURL_CURL_LAST 251757226 +#define CURL_LDAP_CANNOT_BIND 251756858 +#define CURL_LDAP_SEARCH_FAILED 251756866 +#define CURL_OBSOLETE40 251756874 +#define CURL_FUNCTION_NOT_FOUND 251756882 +#define CURL_ABORTED_BY_CALLBACK 251756890 +#define CURL_BAD_FUNCTION_ARGUMENT 251756898 +#define CURL_OBSOLETE44 251756906 +#define CURL_INTERFACE_FAILED 251756914 +#define CURL_OBSOLETE46 251756922 +#define CURL_TOO_MANY_REDIRECTS 251756930 +#define CURL_UNKNOWN_TELNET_OPTION 251756938 +#define CURL_TELNET_OPTION_SYNTAX 251756946 +#define CURL_OBSOLETE50 251756954 +#define CURL_PEER_FAILED_VERIF 251756962 +#define CURL_GOT_NOTHING 251756970 +#define CURL_SSL_ENGINE_NOTFOUND 251756978 +#define CURL_SSL_ENGINE_SETFAILED 251756986 +#define CURL_SEND_ERROR 251756994 +#define CURL_RECV_ERROR 251757002 +#define CURL_OBSOLETE57 251757010 +#define CURL_SSL_CERTPROBLEM 251757018 +#define CURL_SSL_CIPHER 251757026 +#define CURL_SSL_CACERT 251757034 +#define CURL_BAD_CONTENT_ENCODING 251757042 +#define CURL_LDAP_INVALID_URL 251757050 +#define CURL_FILESIZE_EXCEEDED 251757058 +#define CURL_USE_SSL_FAILED 251757066 +#define CURL_SEND_FAIL_REWIND 251757074 +#define CURL_SSL_ENGINE_INITFAILED 251757082 +#define CURL_LOGIN_DENIED 251757090 +#define CURL_TFTP_NOTFOUND 251757098 +#define CURL_TFTP_PERM 251757106 +#define CURL_REMOTE_DISK_FULL 251757114 +#define CURL_TFTP_ILLEGAL 251757122 +#define CURL_TFTP_UNKNOWNID 251757130 +#define CURL_REMOTE_FILE_EXISTS 251757138 +#define CURL_TFTP_NOSUCHUSER 251757146 +#define CURL_CONV_FAILED 251757154 +#define CURL_CONV_REQD 251757162 +#define CURL_SSL_CACERT_BADFILE 251757170 +#define CURL_REMOTE_FILE_NOT_FOUND 251757178 +#define CURL_SSH 251757186 +#define CURL_SSL_SHUTDOWN_FAILED 251757194 +#define CURL_AGAIN 251757202 +#define CURL_SSL_CRL_BADFILE 251757210 +#define CURL_SSL_ISSUER_ERROR 251757218 +#define CURL_CURL_LAST 251757226 #pragma __member_alignment __restore diff --git a/packages/vms/report_openssl_version.c b/packages/vms/report_openssl_version.c index dd1713b24446..d2b0d367bc49 100644 --- a/packages/vms/report_openssl_version.c +++ b/packages/vms/report_openssl_version.c @@ -35,15 +35,14 @@ #include #include -unsigned long LIB$SET_SYMBOL( - const struct dsc$descriptor_s * symbol, - const struct dsc$descriptor_s * value, - const unsigned long *table_type); +unsigned long LIB$SET_SYMBOL(const struct dsc$descriptor_s *symbol, + const struct dsc$descriptor_s *value, + const unsigned long *table_type); int main(int argc, char **argv) { void *libptr; - const char * (*ssl_version)(int t); + const char *(*ssl_version)(int t); const char *version; if(argc < 1) { @@ -53,11 +52,11 @@ int main(int argc, char **argv) libptr = dlopen(argv[1], 0); - ssl_version = (const char * (*)(int))dlsym(libptr, "SSLeay_version"); + ssl_version = (const char *(*)(int))dlsym(libptr, "SSLeay_version"); if(!ssl_version) { - ssl_version = (const char * (*)(int))dlsym(libptr, "ssleay_version"); + ssl_version = (const char *(*)(int))dlsym(libptr, "ssleay_version"); if(!ssl_version) { - ssl_version = (const char * (*)(int))dlsym(libptr, "SSLEAY_VERSION"); + ssl_version = (const char *(*)(int))dlsym(libptr, "SSLEAY_VERSION"); } } diff --git a/scripts/cd2cd b/scripts/cd2cd index 9356ade6e63b..d593e9a579ba 100755 --- a/scripts/cd2cd +++ b/scripts/cd2cd @@ -54,7 +54,6 @@ while(1) { } } - use POSIX qw(strftime); my @ts; if(defined($ENV{SOURCE_DATE_EPOCH})) { diff --git a/scripts/checksrc.pl b/scripts/checksrc.pl index 87b72af96326..54436b8358ea 100755 --- a/scripts/checksrc.pl +++ b/scripts/checksrc.pl @@ -1205,7 +1205,6 @@ sub scanfile { } - if($errors || $warnings || $verbose) { printf "checksrc: %d errors and %d warnings\n", $errors, $warnings; if($suppressed) { diff --git a/scripts/ciconfig.pl b/scripts/ciconfig.pl index c56c31e2be62..95ce0fb877ed 100755 --- a/scripts/ciconfig.pl +++ b/scripts/ciconfig.pl @@ -108,7 +108,6 @@ ); - sub configureopts { my ($opts)=@_; my %thisin; @@ -189,7 +188,6 @@ sub scanjobs { } } - print "ENABLED configure options that are not available\n"; for my $w (sort keys %with) { if(!$avail{$w}) { diff --git a/scripts/delta b/scripts/delta index b6a1df8a17e2..c67d98a2c3d4 100755 --- a/scripts/delta +++ b/scripts/delta @@ -95,7 +95,7 @@ my $deletes=`git diff-tree --diff-filter=A -r --summary origin/$branch $start 2> my $creates=`git diff-tree --diff-filter=D -r --summary origin/$branch $start 2>/dev/null | wc -l`; # Time since that tag -my $tagged=`git for-each-ref --format="%(refname:short) | %(taggerdate:unix)" refs/tags/* | grep ^$start | cut "-d|" -f2`; # Unix timestamp +my $tagged=`git for-each-ref --format="%(refname:short) | %(taggerdate:unix)" refs/tags/* | grep ^$start | cut '-d|' -f2`; # Unix timestamp my $taggednice=`git for-each-ref --format="%(refname:short) | %(creatordate)" refs/tags/* | grep ^$start | cut '-d|' -f2`; # human readable time chomp $taggednice; my $now=POSIX::strftime("%s", localtime()); diff --git a/scripts/firefox-db2pem.sh b/scripts/firefox-db2pem.sh index 634e429b504f..7d31b1288693 100755 --- a/scripts/firefox-db2pem.sh +++ b/scripts/firefox-db2pem.sh @@ -54,7 +54,6 @@ cat > "$out" < 4)" }, - {"smbs", "#if defined(USE_SSL) && !defined(CURL_DISABLE_SMB) && \\\n" - " defined(USE_CURL_NTLM_CORE) && (SIZEOF_CURL_OFF_T > 4)" }, - {"smtp", "#ifndef CURL_DISABLE_SMTP" }, - {"smtps", "#if defined(USE_SSL) && !defined(CURL_DISABLE_SMTP)" }, - {"telnet", "#ifndef CURL_DISABLE_TELNET" }, - {"tftp", "#ifndef CURL_DISABLE_TFTP" }, - {"ws", - "#if !defined(CURL_DISABLE_WEBSOCKETS) && !defined(CURL_DISABLE_HTTP)" }, - {"wss", "#if !defined(CURL_DISABLE_WEBSOCKETS) && \\\n" - " defined(USE_SSL) && !defined(CURL_DISABLE_HTTP)" }, + { "dict", "#ifndef CURL_DISABLE_DICT" }, + { "file", "#ifndef CURL_DISABLE_FILE" }, + { "ftp", "#ifndef CURL_DISABLE_FTP" }, + { "ftps", "#if defined(USE_SSL) && !defined(CURL_DISABLE_FTP)" }, + { "gopher", "#ifndef CURL_DISABLE_GOPHER" }, + { "gophers", "#if defined(USE_SSL) && !defined(CURL_DISABLE_GOPHER)" }, + { "http", "#ifndef CURL_DISABLE_HTTP" }, + { "https", "#if defined(USE_SSL) && !defined(CURL_DISABLE_HTTP)" }, + { "imap", "#ifndef CURL_DISABLE_IMAP" }, + { "imaps", "#if defined(USE_SSL) && !defined(CURL_DISABLE_IMAP)" }, + { "ldap", "#ifndef CURL_DISABLE_LDAP" }, + { "ldaps", "#if !defined(CURL_DISABLE_LDAP) && \\\n" + " !defined(CURL_DISABLE_LDAPS) && \\\n" + " ((defined(USE_OPENLDAP) && defined(USE_SSL)) || \\\n" + " (!defined(USE_OPENLDAP) && defined(HAVE_LDAP_SSL)))" }, + { "mqtt", "#ifndef CURL_DISABLE_MQTT" }, + { "pop3", "#ifndef CURL_DISABLE_POP3" }, + { "pop3s", "#if defined(USE_SSL) && !defined(CURL_DISABLE_POP3)" }, + { "rtmp", "#ifdef USE_LIBRTMP" }, + { "rtmpt", "#ifdef USE_LIBRTMP" }, + { "rtmpe", "#ifdef USE_LIBRTMP" }, + { "rtmpte", "#ifdef USE_LIBRTMP" }, + { "rtmps", "#ifdef USE_LIBRTMP" }, + { "rtmpts", "#ifdef USE_LIBRTMP" }, + { "rtsp", "#ifndef CURL_DISABLE_RTSP" }, + { "scp", "#ifdef USE_SSH" }, + { "sftp", "#ifdef USE_SSH" }, + { "smb", "#if !defined(CURL_DISABLE_SMB) && \\\n" + " defined(USE_CURL_NTLM_CORE) && (SIZEOF_CURL_OFF_T > 4)" }, + { "smbs", "#if defined(USE_SSL) && !defined(CURL_DISABLE_SMB) && \\\n" + " defined(USE_CURL_NTLM_CORE) && (SIZEOF_CURL_OFF_T > 4)" }, + { "smtp", "#ifndef CURL_DISABLE_SMTP" }, + { "smtps", "#if defined(USE_SSL) && !defined(CURL_DISABLE_SMTP)" }, + { "telnet", "#ifndef CURL_DISABLE_TELNET" }, + { "tftp", "#ifndef CURL_DISABLE_TFTP" }, + { "ws", + "#if !defined(CURL_DISABLE_WEBSOCKETS) && !defined(CURL_DISABLE_HTTP)" }, + { "wss", "#if !defined(CURL_DISABLE_WEBSOCKETS) && \\\n" + " defined(USE_SSL) && !defined(CURL_DISABLE_HTTP)" }, { NULL, NULL } }; @@ -108,7 +108,8 @@ static void showtable(int try, int init, int shift) " s++;\n" " l--;\n" " }\n" - "*/\n", init, shift); + "*/\n", + init, shift); printf(" static const struct Curl_handler * const protocols[%d] = {", try); @@ -158,10 +159,10 @@ int main(void) for(j = 0; j < i; j++) { if(num[j] == v) { - /* +#if 0 printf("NOPE: %u is a dupe (%s and %s)\n", v, scheme[i], scheme[j]); - */ +#endif badcombo = 1; break; } diff --git a/src/tool_parsecfg.c b/src/tool_parsecfg.c index 0466c547c3e3..fd669f96cf9a 100644 --- a/src/tool_parsecfg.c +++ b/src/tool_parsecfg.c @@ -273,7 +273,6 @@ ParameterError parseconfig(const char *filename, int max_recursive, return err; } - static bool get_line(FILE *input, struct dynbuf *buf, bool *error) { CURLcode result; diff --git a/tests/appveyor.pm b/tests/appveyor.pm index ed1728682c53..f332bc2b277a 100644 --- a/tests/appveyor.pm +++ b/tests/appveyor.pm @@ -38,7 +38,6 @@ BEGIN { ); } - my %APPVEYOR_TEST_NAMES; # JSON and shell-quoted test names by test number sub appveyor_check_environment { diff --git a/tests/data/data320.html b/tests/data/data320.html index 2756af5f3b98..307bb87c473c 100644 --- a/tests/data/data320.html +++ b/tests/data/data320.html @@ -1,7 +1,6 @@

This is GnuTLS

-

Session ID: 003030000100000001000000000000000030330001000000B062410001000000

If your browser supports session resuming, then you should see the same session ID, when you press the reload button.

Connected as user 'jsmith'.

diff --git a/tests/data/test1109 b/tests/data/test1109 index 043e22cd0829..667e09821597 100644 --- a/tests/data/test1109 +++ b/tests/data/test1109 @@ -30,7 +30,6 @@ http://%HOSTIP:%HTTPPORT/%TESTNUMBER#test
- # Verify data after the test has been "shot" diff --git a/tests/data/test1110 b/tests/data/test1110 index 2d57e49d61e1..ac282f572caa 100644 --- a/tests/data/test1110 +++ b/tests/data/test1110 @@ -31,7 +31,6 @@ http://%HOSTIP:%HTTPPORT/%TESTNUMBER?q=foobar#fragment - # Verify data after the test has been "shot" diff --git a/tests/data/test1111 b/tests/data/test1111 index 8cf705afe7e1..9d9232248a95 100644 --- a/tests/data/test1111 +++ b/tests/data/test1111 @@ -31,7 +31,6 @@ http://%HOSTIP:%HTTPPORT/%TESTNUMBER?q=foobar#fragment#fragment2 - # Verify data after the test has been "shot" diff --git a/tests/data/test1331 b/tests/data/test1331 index 7f8ff7868001..10df80f16a3f 100644 --- a/tests/data/test1331 +++ b/tests/data/test1331 @@ -49,8 +49,6 @@ Content-Length: 6 hello - - # Client-side diff --git a/tests/data/test1408 b/tests/data/test1408 index 1ae279c34887..88436dab0ee3 100644 --- a/tests/data/test1408 +++ b/tests/data/test1408 @@ -31,8 +31,6 @@ Set-Cookie: time=2 -foo- - - # diff --git a/tests/data/test1409 b/tests/data/test1409 index e0c32be188a5..de145ff9d619 100644 --- a/tests/data/test1409 +++ b/tests/data/test1409 @@ -6,7 +6,6 @@ FAILURE - # # Client-side diff --git a/tests/data/test1410 b/tests/data/test1410 index 73362dc00588..c370e1da5f60 100644 --- a/tests/data/test1410 +++ b/tests/data/test1410 @@ -6,7 +6,6 @@ FAILURE - # # Client-side diff --git a/tests/data/test1411 b/tests/data/test1411 index 6eaa65d32889..309dc1692a69 100644 --- a/tests/data/test1411 +++ b/tests/data/test1411 @@ -23,7 +23,6 @@ Funny-head: yesyes
- # # Client-side diff --git a/tests/data/test161 b/tests/data/test161 index 7908c41d2a93..80a03882da74 100644 --- a/tests/data/test161 +++ b/tests/data/test161 @@ -29,7 +29,6 @@ ftp://%HOSTIP:%FTPPORT/%TESTNUMBER - # Verify data after the test has been "shot" # This does not send QUIT because of known bug: diff --git a/tests/data/test2030 b/tests/data/test2030 index 47f01a14ed69..307b223264c4 100644 --- a/tests/data/test2030 +++ b/tests/data/test2030 @@ -25,7 +25,6 @@ ensure that the order does not matter. --> --> - HTTP/1.1 401 Need Digest or NTLM auth diff --git a/tests/data/test2045 b/tests/data/test2045 index 241d9fc14f6b..0532be5708fa 100644 --- a/tests/data/test2045 +++ b/tests/data/test2045 @@ -6,7 +6,6 @@ FTP - # # Server-side diff --git a/tests/data/test206 b/tests/data/test206 index 7a2acac7005f..b036eb9d405d 100644 --- a/tests/data/test206 +++ b/tests/data/test206 @@ -17,7 +17,6 @@ connection-monitor auth_required - # this is returned first since we get no proxy-auth HTTP/1.1 407 Authorization Required to proxy me my dear diff --git a/tests/data/test2202 b/tests/data/test2202 index 9bb03799362f..6330b9519d26 100644 --- a/tests/data/test2202 +++ b/tests/data/test2202 @@ -50,7 +50,6 @@ client CONNECT 2e 00044d51545404c2003c000c6375726c server CONNACK 2 20020005 - # 8 is CURLE_WEIRD_SERVER_REPLY 8 diff --git a/tests/data/test228 b/tests/data/test228 index e9acda8ddb3d..e609aaa74175 100644 --- a/tests/data/test228 +++ b/tests/data/test228 @@ -34,7 +34,6 @@ ftp://%HOSTIP:%FTPPORT/%TESTNUMBER --ftp-account "one count" - # Verify data after the test has been "shot" diff --git a/tests/data/test3105 b/tests/data/test3105 index 543d52e43234..64f1c5ab4cd2 100644 --- a/tests/data/test3105 +++ b/tests/data/test3105 @@ -5,7 +5,6 @@ curl_multi_remove_handle - # # Client-side diff --git a/tests/data/test399 b/tests/data/test399 index bd73155253a2..8495446c0d9c 100644 --- a/tests/data/test399 +++ b/tests/data/test399 @@ -5,7 +5,6 @@ URL - # # Client-side diff --git a/tests/data/test698 b/tests/data/test698 index 3335e3875d6f..a3e16a511e2c 100644 --- a/tests/data/test698 +++ b/tests/data/test698 @@ -34,7 +34,6 @@ ftp://%HOSTIP:%FTPPORT/%TESTNUMBER --ftp-account "one count" ftp://%HOSTIP:%FTPP - # Verify data after the test has been "shot" diff --git a/tests/devtest.pl b/tests/devtest.pl index a2a9cde87543..46adb6136a50 100755 --- a/tests/devtest.pl +++ b/tests/devtest.pl @@ -64,7 +64,6 @@ BEGIN ); use getpart; - ####################################################################### # logmsg is our general message logging subroutine. # This function is currently required to be here by servers.pm @@ -105,7 +104,6 @@ sub parseprotocols { push @protocols, 'none'; } - ####################################################################### # Initialize @protocols from the curl binary under test # @@ -117,7 +115,6 @@ sub init_protocols { } } - ####################################################################### # Initialize the test harness to run tests # diff --git a/tests/directories.pm b/tests/directories.pm index 8b3c1addfaa7..cbb5921cd396 100644 --- a/tests/directories.pm +++ b/tests/directories.pm @@ -37,7 +37,6 @@ BEGIN { ); } - my %file_chmod1 = ( 'name' => 'chmod1', 'content' => "This file should have permissions 444\n", diff --git a/tests/getpart.pm b/tests/getpart.pm index 69b810db5c47..b88cce628bc8 100644 --- a/tests/getpart.pm +++ b/tests/getpart.pm @@ -103,8 +103,8 @@ sub getpartattr { if(!$inside && ($_ =~ /^ *\<$section/)) { $inside++; } - if((1 ==$inside) && ( ($_ =~ /^ *\<$part ([^>]*)/) || - !(defined($part)) ) + if((1 == $inside) && (($_ =~ /^ *\<$part ([^>]*)/) || + !(defined($part))) ) { $inside++; my $attr=$1; @@ -118,10 +118,10 @@ sub getpartattr { last; } # detect end of section when part was not found - elsif((1 ==$inside) && ($_ =~ /^ *\<\/$section\>/)) { + elsif((1 == $inside) && ($_ =~ /^ *\<\/$section\>/)) { last; } - elsif((2 ==$inside) && ($_ =~ /^ *\<\/$part/)) { + elsif((2 == $inside) && ($_ =~ /^ *\<\/$part/)) { $inside--; } } @@ -252,7 +252,6 @@ sub loadtest { return 0; } - # Return entire document as list of lines sub fulltest { return @xml; @@ -323,7 +322,6 @@ sub savetest { # Strip off all lines that match the specified pattern and return # the new array. # - sub striparray { my ($pattern, $arrayref) = @_; @@ -423,5 +421,4 @@ sub loadarray { return @array; } - 1; diff --git a/tests/globalconfig.pm b/tests/globalconfig.pm index 8543b3aec440..8d5105a36c61 100644 --- a/tests/globalconfig.pm +++ b/tests/globalconfig.pm @@ -85,7 +85,6 @@ use pathhelp qw( use Cwd qw(getcwd); use File::Spec; - ####################################################################### # global configuration variables # diff --git a/tests/libtest/cli_ftp_upload.c b/tests/libtest/cli_ftp_upload.c index 7493a210e6e9..32835bc12329 100644 --- a/tests/libtest/cli_ftp_upload.c +++ b/tests/libtest/cli_ftp_upload.c @@ -21,12 +21,10 @@ * SPDX-License-Identifier: curl * ***************************************************************************/ - #include "first.h" #include "testtrace.h" - #ifndef CURL_DISABLE_FTP struct test_cli_ftp_upload_data { @@ -85,8 +83,7 @@ static CURLcode test_cli_ftp_upload(const char *URL) curl_off_t uploadsize = -1; (void)URL; - while((ch = cgetopt(test_argc, test_argv, "r:")) - != -1) { + while((ch = cgetopt(test_argc, test_argv, "r:")) != -1) { switch(ch) { case 'r': resolve = coptarg; diff --git a/tests/libtest/lib651.c b/tests/libtest/lib651.c index 1e38d18895cc..0a7684abe454 100644 --- a/tests/libtest/lib651.c +++ b/tests/libtest/lib651.c @@ -55,7 +55,6 @@ static CURLcode test_lib651(const char *URL) if(formrc) curl_mprintf("curl_formadd(1) = %d\n", formrc); - curl = curl_easy_init(); if(!curl) { curl_mfprintf(stderr, "curl_easy_init() failed\n"); diff --git a/tests/libtest/mk-lib1521.pl b/tests/libtest/mk-lib1521.pl index bfb0e590e78f..77e10a05d90f 100755 --- a/tests/libtest/mk-lib1521.pl +++ b/tests/libtest/mk-lib1521.pl @@ -74,7 +74,6 @@ 'CURLOPT_SOCKS5_AUTH', ); - # # Generate a set of string checks # @@ -626,7 +625,6 @@ } } - print $fh <