Compare commits

...

6 commits

Author SHA1 Message Date
Daniel Stenberg
f54d5ccad6 fixup Viktor's extra case 2026-03-01 13:55:45 +01:00
Daniel Stenberg
f26a291755 urlapi: typecast CURLU_URLDECODE to uint when toggling it off
In this use case 'unsigned value &= ~DEFINE;'

As otherwise the right side is treated as signed, which annoyingly
triggers UBSan.

Reported-by: xmoezzz on github
Fixes #20753
2026-03-01 13:55:45 +01:00
Viktor Szakats
1b35c9e1e3
cmake: rename testbins target to tt, restore internal option
To make it easy to type. The internal option is used in CI.

Follow-up to aae361242f #20708

Closes #20768
2026-03-01 00:24:47 +01:00
Viktor Szakats
7a80082471
GHA/windows: bump clang-tidy job to clang v20 (from v18)
Adds 50 seconds to the 5m long build step. Also more prerequisites to
install, with no apparent effect on step time.

Follow-up to 9b52d516bb #20732

Closes #20775
2026-03-01 00:24:47 +01:00
Viktor Szakats
35bbb2e830
clang-tidy: fix issues found with build-fuzzing
- curl_sha512_256: add missing, drop redundant, parentheses.
- doh: drop redundant returns.
- url: add missing parentheses.
- vtls: fix unused const variables.
- tests/unit: fix missing header with clang-tidy and !threaded-resolver.
  Follow-up to 57ff2d6c91 #20106

Closes #20774
2026-03-01 00:04:18 +01:00
Viktor Szakats
bcc8144b89
clang-tidy: silence more minor issues found by v22
Also one found manually in lib/curl_sha512_256.c.

Follow-up to 7a08c5d820 #20762

Closes #20770
2026-02-28 13:16:54 +01:00
21 changed files with 62 additions and 56 deletions

View file

@ -677,10 +677,12 @@ jobs:
include:
- { build: 'autotools', compiler: 'gcc' }
- { build: 'cmake' , compiler: 'gcc' }
- { build: 'cmake' , compiler: 'clang-tidy' }
- { build: 'cmake' , compiler: 'clang-tidy', install_packages: 'clang-20 clang-tidy-20' }
steps:
- name: 'install packages'
run: sudo apt-get -o Dpkg::Use-Pty=0 install gcc-mingw-w64-x86-64-win32
env:
MATRIX_INSTALL_PACKAGES: '${{ matrix.install_packages }}'
run: sudo apt-get -o Dpkg::Use-Pty=0 install gcc-mingw-w64-x86-64-win32 ${MATRIX_INSTALL_PACKAGES}
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
@ -694,10 +696,10 @@ jobs:
run: |
if [ "${MATRIX_BUILD}" = 'cmake' ]; then
if [ "${MATRIX_COMPILER}" = 'clang-tidy' ]; then
options+=' -DCURL_CLANG_TIDY=ON'
options+=' -DCURL_CLANG_TIDY=ON -DCLANG_TIDY=/usr/bin/clang-tidy-20'
options+=' -DENABLE_UNICODE=ON -DUSE_SSLS_EXPORT=ON'
options+=' -DCMAKE_C_COMPILER=clang'
options+=" -DCMAKE_RC_COMPILER=llvm-windres-$(clang -dumpversion | cut -d '.' -f 1)"
options+=' -DCMAKE_C_COMPILER=clang-20'
options+=" -DCMAKE_RC_COMPILER=llvm-windres-$(clang-20 -dumpversion | cut -d '.' -f 1)"
else
options+=" -DCMAKE_C_COMPILER=${TRIPLET}-gcc"
fi

View file

@ -63,7 +63,7 @@ This release includes the following bugfixes:
o cmake: normalize uppercase hex winver (for display) [191]
o cmake: omit `curl.rc` from curltool lib [209]
o cmake: reference OpenSSL and ZLIB imported targets only when enabled [41]
o cmake: replace internal option with a new `testbins` target [220]
o cmake: replace internal option with a new `tt` (test tools) target [220]
o cmake: silence potential unused var warnings in C++ test snippet [201]
o cmake: silence silly Apple clang warnings in C89 mode, test in CI [14]
o cmake: silence useless compiler warnings triggered by the FASTBuild generator [43]

View file

@ -552,12 +552,12 @@ Note: These variables are internal and subject to change.
## Useful build targets
- `testbins`: Build test binaries (servers, tools).
Individual targets: `curlinfo`, `libtests`, `servers`, `tunits`, `units`
- `testdeps`: Build test dependencies (test binaries, test certificates).
Test certificates: `build-certs` (clean with `clean-certs`)
- `tests`: Run tests (`runtests.pl`). Customize via the `TFLAGS` environment variable, e.g. `TFLAGS=1621`.
Other flavors: `test-am`, `test-ci`, `test-event`, `test-full`, `test-nonflaky`, `test-quiet`, `test-torture`
- `tt`: Build test binaries (servers, tools).
Individual targets: `curlinfo`, `libtests`, `servers`, `tunits`, `units`
- `curl-pytest`: Run tests (pytest).
Other flavor: `curl-test-ci`
- `curl-examples`: Build examples

View file

@ -452,14 +452,14 @@ static void Curl_sha512_256_transform(uint64_t H[SHA512_256_HASH_SIZE_WORDS],
/* 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))
#define SIG1(x) \
(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))
#define sig1(x) \
(Curl_rotr64((x), 19) ^ Curl_rotr64((x), 61) ^ ((x) >> 6))
#define SIG0(x) \
(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))
#define sig0(x) \
(Curl_rotr64(x, 1) ^ Curl_rotr64(x, 8) ^ ((x) >> 7))
#define sig1(x) \
(Curl_rotr64(x, 19) ^ Curl_rotr64(x, 61) ^ ((x) >> 6))
if(1) {
unsigned int t;
@ -520,8 +520,8 @@ static void Curl_sha512_256_transform(uint64_t H[SHA512_256_HASH_SIZE_WORDS],
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)); \
(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,
@ -530,7 +530,7 @@ static void Curl_sha512_256_transform(uint64_t H[SHA512_256_HASH_SIZE_WORDS],
#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)); \
SHA2STEP64(vA, vB, vC, vD, vE, vF, vG, tmp_h_, kt, wt); \
(vH) = (vG); \
(vG) = (vF); \
(vF) = (vE); \
@ -546,7 +546,7 @@ static void Curl_sha512_256_transform(uint64_t H[SHA512_256_HASH_SIZE_WORDS],
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)
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
@ -727,10 +727,10 @@ static CURLcode Curl_sha512_256_finish(unsigned char *digest, void *context)
/* Put in BE mode the leftmost part of the hash as the final digest.
See FIPS PUB 180-4 section 6.7. */
CURL_PUT_64BIT_BE(digest + 0 * SHA512_256_BYTES_IN_WORD, ctx->H[0]);
CURL_PUT_64BIT_BE(digest + 1 * SHA512_256_BYTES_IN_WORD, ctx->H[1]);
CURL_PUT_64BIT_BE(digest + 2 * SHA512_256_BYTES_IN_WORD, ctx->H[2]);
CURL_PUT_64BIT_BE(digest + 3 * SHA512_256_BYTES_IN_WORD, ctx->H[3]);
CURL_PUT_64BIT_BE(digest + (0 * SHA512_256_BYTES_IN_WORD), ctx->H[0]);
CURL_PUT_64BIT_BE(digest + (1 * SHA512_256_BYTES_IN_WORD), ctx->H[1]);
CURL_PUT_64BIT_BE(digest + (2 * SHA512_256_BYTES_IN_WORD), ctx->H[2]);
CURL_PUT_64BIT_BE(digest + (3 * SHA512_256_BYTES_IN_WORD), ctx->H[3]);
/* Erase potentially sensitive data. */
memset(ctx, 0, sizeof(struct Curl_sha512_256ctx));

View file

@ -201,7 +201,6 @@ static void doh_print_buf(struct Curl_easy *data,
infof(data, "%s: len=%d, val=%s", prefix, (int)len, hexstr);
else
infof(data, "%s: len=%d (truncated)val=%s", prefix, (int)len, hexstr);
return;
}
#endif
@ -1191,7 +1190,6 @@ UNITTEST void doh_print_httpsrr(struct Curl_easy *data,
}
else
infof(data, "HTTPS RR: no ipv6hints");
return;
}
# endif
#endif

View file

@ -1247,7 +1247,7 @@ void Curl_ldap_version(char *buf, size_t bufsz)
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)
(((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);

View file

@ -953,7 +953,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
@ -1009,8 +1009,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,
@ -1178,7 +1178,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
#ifdef USE_SPNEGO

View file

@ -1274,7 +1274,7 @@ static CURLUcode redirect_url(const char *base, const char *relurl,
if(!curlx_dyn_addn(&urlbuf, base, prelen) &&
!urlencode_str(&urlbuf, useurl, strlen(useurl), !host_changed, FALSE)) {
uc = parseurl_and_replace(curlx_dyn_ptr(&urlbuf), u,
flags & ~CURLU_PATH_AS_IS);
flags & ~(unsigned int)CURLU_PATH_AS_IS);
}
else
uc = CURLUE_OUT_OF_MEMORY;
@ -1555,7 +1555,7 @@ CURLUcode curl_url_get(const CURLU *u, CURLUPart what,
case CURLUPART_SCHEME:
ptr = u->scheme;
ifmissing = CURLUE_NO_SCHEME;
flags &= ~CURLU_URLDECODE; /* never for schemes */
flags &= ~(unsigned int)CURLU_URLDECODE; /* never for schemes */
if((flags & CURLU_NO_GUESS_SCHEME) && u->guessed_scheme)
return CURLUE_NO_SCHEME;
break;
@ -1582,7 +1582,7 @@ CURLUcode curl_url_get(const CURLU *u, CURLUPart what,
case CURLUPART_PORT:
ptr = u->port;
ifmissing = CURLUE_NO_PORT;
flags &= ~CURLU_URLDECODE; /* never for port */
flags &= ~(unsigned int)CURLU_URLDECODE; /* never for port */
if(!ptr && (flags & CURLU_DEFAULT_PORT) && u->scheme) {
/* there is no stored port number, but asked to deliver
a default one for the scheme */

View file

@ -1000,10 +1000,11 @@ static int myssh_in_UPLOAD_INIT(struct Curl_easy *data,
if(!sshc->sftp_file) {
int err = sftp_get_error(sshc->sftp_session);
if(((err == SSH_FX_NO_SUCH_FILE || err == SSH_FX_FAILURE ||
err == SSH_FX_NO_SUCH_PATH)) &&
(data->set.ftp_create_missing_dirs &&
(strlen(sshp->path) > 1))) {
if((err == SSH_FX_NO_SUCH_FILE ||
err == SSH_FX_FAILURE ||
err == SSH_FX_NO_SUCH_PATH) &&
data->set.ftp_create_missing_dirs &&
(strlen(sshp->path) > 1)) {
/* try to create the path remotely */
rc = 0;
sshc->secondCreateDirs = 1;

View file

@ -967,11 +967,11 @@ static CURLcode sftp_upload_init(struct Curl_easy *data,
sftp_libssh2_strerror(sftperr));
return sftp_libssh2_error_to_CURLE(sftperr);
}
if(((sftperr == LIBSSH2_FX_NO_SUCH_FILE) ||
(sftperr == LIBSSH2_FX_FAILURE) ||
(sftperr == LIBSSH2_FX_NO_SUCH_PATH)) &&
(data->set.ftp_create_missing_dirs &&
(strlen(sshp->path) > 1))) {
if((sftperr == LIBSSH2_FX_NO_SUCH_FILE ||
sftperr == LIBSSH2_FX_FAILURE ||
sftperr == LIBSSH2_FX_NO_SUCH_PATH) &&
data->set.ftp_create_missing_dirs &&
(strlen(sshp->path) > 1)) {
/* try to create the path remotely */
sshc->secondCreateDirs = 1;
myssh_to(data, sshc, SSH_SFTP_CREATE_DIRS_INIT);

View file

@ -577,7 +577,7 @@ init_config_builder(struct Curl_easy *data,
}
#endif /* USE_ECH */
cipher_suites = curlx_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;

View file

@ -136,7 +136,6 @@ static const struct alpn_spec ALPN_SPEC_H11 = {
static const struct alpn_spec ALPN_SPEC_H10_H11 = {
{ ALPN_HTTP_1_0, ALPN_HTTP_1_1 }, 2
};
#endif /* !CURL_DISABLE_HTTP || !CURL_DISABLE_PROXY */
#ifdef USE_HTTP2
static const struct alpn_spec ALPN_SPEC_H2 = {
{ ALPN_H2 }, 1
@ -149,7 +148,6 @@ static const struct alpn_spec ALPN_SPEC_H11_H2 = {
};
#endif /* USE_HTTP2 */
#if !defined(CURL_DISABLE_HTTP) || !defined(CURL_DISABLE_PROXY)
static const struct alpn_spec *alpn_get_spec(http_majors wanted,
http_majors preferred,
bool only_http_10,

View file

@ -29,21 +29,21 @@ mark_as_advanced(TEST_NGHTTPX)
# Consumed variables: TEST_NGHTTPX
configure_file("config.in" "${CMAKE_CURRENT_BINARY_DIR}/config" @ONLY)
add_custom_target(testbins)
add_custom_target(tt)
if(BUILD_CURL_EXE)
add_dependencies(testbins "curlinfo")
add_dependencies(tt "curlinfo")
endif()
if(CURL_BUILD_EVERYTHING)
set_target_properties(testbins PROPERTIES EXCLUDE_FROM_ALL FALSE)
set_target_properties(tt PROPERTIES EXCLUDE_FROM_ALL FALSE)
endif()
if(CURL_CLANG_TIDY)
add_custom_target(tests-clang-tidy)
add_dependencies(testbins tests-clang-tidy)
add_dependencies(tt tests-clang-tidy)
endif()
add_custom_target(testdeps)
add_dependencies(testdeps "testbins")
add_dependencies(testdeps "tt")
add_subdirectory(http)
add_subdirectory(server)

View file

@ -31,7 +31,11 @@ add_custom_command(OUTPUT ${GENERATEDCERTS}
VERBATIM
)
add_custom_target(build-certs DEPENDS ${GENERATEDCERTS})
add_dependencies(testdeps build-certs)
option(_CURL_SKIP_BUILD_CERTS "Skip building certs with testdeps" OFF) # Internal option to increase perf for build tests
if(NOT _CURL_SKIP_BUILD_CERTS)
add_dependencies(testdeps build-certs)
endif()
add_custom_target(clean-certs
COMMAND ${CMAKE_COMMAND} -E remove ${GENERATEDCERTS}

View file

@ -52,7 +52,7 @@ add_custom_command(OUTPUT "${BUNDLE}.c"
VERBATIM)
add_executable(${BUNDLE} EXCLUDE_FROM_ALL "${BUNDLE}.c")
add_dependencies(testbins ${BUNDLE})
add_dependencies(tt ${BUNDLE})
target_link_libraries(${BUNDLE} ${LIB_SELECTED} ${CURL_LIBS})
target_include_directories(${BUNDLE} PRIVATE
"${PROJECT_BINARY_DIR}/lib" # for "curl_config.h"

View file

@ -39,7 +39,7 @@ add_custom_command(OUTPUT "${BUNDLE}.c"
VERBATIM)
add_executable(${BUNDLE} EXCLUDE_FROM_ALL "${BUNDLE}.c")
add_dependencies(testbins ${BUNDLE})
add_dependencies(tt ${BUNDLE})
target_link_libraries(${BUNDLE} ${CURL_NETWORK_AND_TIME_LIBS})
target_include_directories(${BUNDLE} PRIVATE
"${PROJECT_BINARY_DIR}/lib" # for "curl_config.h"

View file

@ -39,7 +39,7 @@ add_custom_command(OUTPUT "${BUNDLE}.c"
VERBATIM)
add_executable(${BUNDLE} EXCLUDE_FROM_ALL "${BUNDLE}.c")
add_dependencies(testbins ${BUNDLE})
add_dependencies(tt ${BUNDLE})
target_link_libraries(${BUNDLE} curltool ${LIB_SELECTED})
target_include_directories(${BUNDLE} PRIVATE
"${PROJECT_BINARY_DIR}/lib" # for "curl_config.h"

View file

@ -40,7 +40,7 @@ add_custom_command(OUTPUT "${BUNDLE}.c"
add_executable(${BUNDLE} EXCLUDE_FROM_ALL "${BUNDLE}.c")
add_dependencies(${BUNDLE} curlu-unitprotos)
add_dependencies(testbins ${BUNDLE})
add_dependencies(tt ${BUNDLE})
target_link_libraries(${BUNDLE} curlu)
target_include_directories(${BUNDLE} PRIVATE
"${PROJECT_BINARY_DIR}/lib" # for "curl_config.h", "unitprotos.h"

View file

@ -25,6 +25,7 @@
#include "urldata.h"
#include "connect.h"
#include "curl_addrinfo.h"
static CURLcode t1607_setup(void)
{

View file

@ -25,6 +25,7 @@
#include "urldata.h"
#include "connect.h"
#include "curl_addrinfo.h"
static CURLcode t1609_setup(void)
{

View file

@ -46,6 +46,7 @@
#include "cf-ip-happy.h"
#include "multiif.h"
#include "select.h"
#include "curl_addrinfo.h"
#include "curl_trc.h"
static CURLcode t2600_setup(CURL **easy)