Commit Graph

15871 Commits

Author SHA1 Message Date
Daniel Stenberg
9ec63d8565
hsts: use one malloc instead of two per entry
Closes #19861
2025-12-07 12:54:03 +01:00
Daniel Stenberg
65597f8fc9
noproxy: fix build on systems without IPv6
Follow-up to ff2aaed9ba
Reported-by: Harry Sintonen
Closes #19860
2025-12-07 00:42:16 +01:00
Daniel Stenberg
f4b56f34ba
asyn-thrdd: fix Curl_async_getaddrinfo() on systems without getaddrinfo
Follow-up to ce06fe7771
Bug: ce06fe7771 (r172215567)
Reported-by: Harry Sintonen
Closes #19859
2025-12-07 00:08:19 +01:00
Daniel Stenberg
0b5ece553c
altsvc: make it one malloc instead of three per entry
Also return OOM correctly.

Closes #19857
2025-12-06 23:50:58 +01:00
Robert W. Van Kirk
1c0822e8cb
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 <robert@rwvk.tech>
Closes #19858
2025-12-06 23:47:50 +01:00
Stefan Eissing
891566c72d
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
2025-12-06 14:48:04 +01:00
Viktor Szakats
af5def0738
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
2025-12-05 16:07:03 +01:00
Viktor Szakats
4e051ff550
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
2025-12-05 15:32:59 +01:00
Viktor Szakats
2d6ade19fc
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:
c4d990a6cf (diff-0f7a5f85bae4de860b70aabf34aa12b0ecc37e748cd96e203e2d8ddb30a207c3R145)
49ac28a486 (diff-0f7a5f85bae4de860b70aabf34aa12b0ecc37e748cd96e203e2d8ddb30a207c3R166)

Follow-up to 859ce48de1 #19832
Closes #19849
2025-12-05 13:16:07 +01:00
Viktor Szakats
859ce48de1
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 3e2a946926 #19808
Closes #19832
2025-12-04 23:14:01 +01:00
Daniel Stenberg
f1f76e0ea8
url: if curl_url_get() fails due to OOM, error out properly
Even if the scheme is "file"!

Closes #19838
2025-12-04 23:01:01 +01:00
Viktor Szakats
6d042273cd
openssl: simplify HAVE_KEYLOG_CALLBACK guard
non-LibreSSL always includes BoringSSL and AWS-LC, no need to check for
them explicitly.

Follow-up to 69c89bf3d3 #18330
Closes #19843
2025-12-04 22:49:03 +01:00
Viktor Szakats
df07f431e2
mbedtls: sync format across log messages
Closes #19842
2025-12-04 22:49:03 +01:00
Viktor Szakats
dfd781ff62
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
2025-12-04 20:14:11 +01:00
Viktor Szakats
0476e4fc65
tidy-up: one more round of formatting nits
Closes #19835
2025-12-04 19:30:59 +01:00
Daniel Stenberg
d517efe5bd
bufref: add Curl_bufref_dup that returns a strdup()ed version
Cleans up a common pattern somewhat. Implemented as a macro.

Closes #19834
2025-12-04 19:04:19 +01:00
Stefan Eissing
d7928029fc
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
2025-12-04 18:45:38 +01:00
Daniel Stenberg
1def380032
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
2025-12-04 16:49:16 +01:00
Patrick Monnerat
fe7703a0b3
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
2025-12-04 16:17:36 +01:00
Patrick Monnerat
2cb868242d
lib: turn state.referer into a struct bufref
Closes #19827
2025-12-04 16:17:33 +01:00
Patrick Monnerat
36542b7349
lib: turn state.url into a struct bufref
Closes #19827
2025-12-04 16:17:31 +01:00
Patrick Monnerat
f39b8a1174
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
2025-12-04 16:17:21 +01:00
Daniel Stenberg
39d1976b7f
ldap: call ldap_init() before setting the options
Closes #19830
2025-12-04 16:14:48 +01:00
Theo Buehler
608f5dd455
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
2025-12-04 16:14:12 +01:00
Georg Schulz-Allgaier
ff2aaed9ba
noproxy: fix ipv6 handling
Closes #19828
2025-12-04 12:16:02 +01:00
Viktor Szakats
6694a42aa0
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
2025-12-03 14:50:21 +01:00
Viktor Szakats
c3b030b860
lib: fix formatting nits (part 3)
From `lib/h` to `lib/w`.

part 1: 47a1ab2ebe #19764
part 2: 86b346443b #19800

Closes #19811
2025-12-03 14:50:16 +01:00
Stefan Eissing
9cf4a400d2
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
2025-12-02 17:04:20 +01:00
Viktor Szakats
86b346443b
lib: fix formatting nits (part 2)
From `lib/curl*` to `lib/g*`. With fixes to part 1.

part 1: 47a1ab2ebe #19764

Closes #19800
2025-12-02 16:52:54 +01:00
Daniel Stenberg
3e2a946926
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
2025-12-02 16:27:16 +01:00
Stefan Eissing
b30c1b97b9
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
2025-12-02 16:25:03 +01:00
Daniel Stenberg
c1c3487d79
curl_gssapi: make sure Curl_gss_log_error() has an initialized buffer
Reported-by: Stanislav Fort (Aisle Research)

Closes #19802
2025-12-02 10:14:15 +01:00
Stefan Eissing
dc29590d60
memdebug: log socket close before closing
To not get a mixup in the memdebug log order.

Closes #19793
2025-12-02 00:58:31 +01:00
Daniel Stenberg
85a6936d76
libssh2: consider strdup() failures OOM and return correctly
In the ssh_state_pkey_init function.

Closes #19791
2025-12-01 22:17:21 +01:00
Viktor Szakats
9517b41b50
multibyte: limit curlx_convert_*wchar*() functions to Unicode builds
Follow-up to ccb68d2e3b #19790

Closes #19796
2025-12-01 21:32:10 +01:00
Viktor Szakats
189fda0026
memdebug: replace macro constant with sizeof()
Closes #19795
2025-12-01 21:32:10 +01:00
Viktor Szakats
5356bce6ab
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
2025-12-01 21:32:09 +01:00
Viktor Szakats
a3fcd80de4
curlx: use curlx allocators in non-memdebug builds (Windows)
To limit raw allocators to `CURLDEBUG` (memdebug/TrackMemory) Windows
UNICODE builds.

Closes #19788
2025-12-01 19:42:56 +01:00
Viktor Szakats
ccb68d2e3b
idn: use curlx allocators on Windows
Replace `curlx_convert*()` functions with local copies that always use
the curlx allocator.

Closes #19790
2025-12-01 18:46:55 +01:00
Viktor Szakats
3387133450
lib: delete unused curlx/multibyte.h includes
Closes #19792
2025-12-01 18:09:09 +01:00
Viktor Szakats
ca1919caee
idn: fix memory leak in win32_ascii_to_idn()
Closes #19789
2025-12-01 16:39:07 +01:00
Stefan Eissing
d1b85bc49c
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 a7bebd8502
Closes #19787
2025-12-01 14:12:59 +01:00
Stefan Eissing
a7bebd8502
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
2025-12-01 13:43:41 +01:00
Daniel Stenberg
c6c4a99300
http: acknowledge OOM errors from Curl_input_ntlm
Closes #19781
2025-12-01 12:47:57 +01:00
Daniel Stenberg
012fa2b91b
auth: always treat Curl_auth_ntlm_get() returning NULL as OOM
Closes #19782
2025-12-01 12:47:23 +01:00
Viktor Szakats
4aed2dcc89
krb5: fix detecting channel binding feature
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 8616e5aada #19164
Closes #19603
Closes #19760
2025-12-01 11:43:20 +01:00
Viktor Szakats
dabfae84f0
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
2025-12-01 11:43:20 +01:00
Daniel Stenberg
729316a9e4
http: handle oom error from Curl_input_digest()
Closes #19780
2025-12-01 10:47:33 +01:00
Daniel Stenberg
cffc912844
url: fix return code for OOM in parse_proxy()
Closes #19779
2025-12-01 10:18:58 +01:00
Daniel Stenberg
41931f1659
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
2025-12-01 08:37:23 +01:00