Replace `Cwd::abs_path()` with `File::Spec->rel2abs()`. The former
requires the file to exist, but in some cases, it's missing.
Seen in MSVC vcpkg jobs using Chocolatey OpenSSH v8.0.0.1 ending up with
`$path=/d/a/curl/curl/bld/tests/log/3/server/ssh_server.pid`, which does
not exist while converting to an absolute path (the path is already
absolute, but the conversion is done unconditionally):
```
Use of uninitialized value in subroutine entry at D:/a/curl/curl/tests/pathhelp.pm line 128.
can't convert empty path at D:/a/curl/curl/tests/pathhelp.pm line 128.
```
Ref: https://github.com/curl/curl/actions/runs/13747741797/job/38444844173#step:14:1233 (master)
Ref: https://github.com/curl/curl/actions/runs/13751862952/job/38453816737#step:14:3185 (trace)
Also ignore 3 new libssh2 jobs failing due to memleak.
Partial revert of 1bd5ac998b#16570Closes#16636
It contains a series of bugfixes and updates applied to libcurl's
`Curl_wait_ms()` over the years, but missed from the copy in
`tests/server/util.c`:
- d65321f939,
52e822173a,
5912da253b
- 4a8f459837
- 1ad49feb71
It fixes `wait_ms()` to check for, and return `SOCKERRNO`. Fixing error
handling on Windows.
Also:
- tests/server: change callers to check `SOCKERRNO`.
- `wait_ms()`: fix to check for the correct error code on Windows.
Pending for `Curl_wait_ms()`: #16621.
- `Curl_wait_ms()`: tidy-up `Sleep()` argument cast (nit).
- lib/curl_trc: drop an unused header.
Closes#16627
It fixes test 2302, 2303, 2307 with MSVC and clang on Windows.
GCC Windows builds were not affected.
Failure was caused by stack overflow due to a 1MB+ sized test struct on
stack. Replace it with dynamic allocation.
Also unignore affected tests in GHA/windows.
As seen under WINE with llvm-mingw:
```
$ wine64 libtests.exe lib2302 ws://127.0.0.1:59964/2302 > stdout2302 2> stderr2302
Test: lib2302
URL: ws://127.0.0.1:59964/2302
wine: Unhandled stack overflow at address 000000014007486A (thread 0024), starting debugger...
Unhandled exception: stack overflow in 64-bit code (0x000000014007486a).
```
Ref: #16629 (discovery)
Ref: 1bd5ac998b#16570Closes#16630
The GnuTLS MSVC/vcpkg build doesn't actually work on Windows. Let's
restore the build itself, to keep it fit for more testing. With disabled
tests (and examples) to keep it fast and not add to flakiness.
Also:
- enable GnuTLS in the MultiSSL job.
- limit building examples to one normal and one UWP job. It saves
6 x 1-1.5 minutes. Coverage remains the same, because example builds
only depend on the toolchain / target, not on the actual features
(except IPv6, but that's enabled for all.)
Closes#16623
The only user is error display code following an `mkdir()` call. In this
case the redefinition didn't cause an issue, but was unnecessary.
Follow-up to d69425ed7d#16615Closes#16620
These were not used in curl sources at all.
Except `EDQUOT` which was used after `mkdir()` in `src/tool_dirhie.c`
for error display. It should not be redefined to a winsock2 error.
This makes the "exceeded your quota" error correctly appear on Windows,
if detected, after operations that create directories.
After this patch there remain 14 `E*` macro redefines on Windows,
down from 40 before this patch.
Bug: https://github.com/curl/curl/pull/16553#issuecomment-2704679377
Ref: #16612
Ref: #16605Closes#16615
Windows's winsock2 returns socket errors via `WSAGetLastError()` and
not via `errno` like most systems out there. This was covered by
switching to the `SOCKERRNO` curl macro earlier. But, on Windows the
returned socket error codes have different values than the standard
POSIX errno values. Existing code was using the POSIX values for all
these checks. Meaning they never actually matched on Windows.
This patch defines a set of `SOCKERRNO` constants that map to the
correct socket error values for Windows and other platforms.
The reverse issue exists in core curl code, which redefines POSIX errno
values to winsock2 ones, breaking non-socket uses on Windows.
Cherry-picked from #15000
Follow-up to adcfd4fb3e#16553
Bug: https://github.com/curl/curl/pull/16553#issuecomment-2704679377Closes#16612
1.2.5.2 was released on 2011-12-18. (vs. 1.2.0.4 on 2003-08-10)
It allows to:
- use `Z_BLOCK` unconditionally.
- use `inflateReset2()` to replace `inflateEnd()` + `inflateInit2()`
and save a memory allocation.
- use `Z_CONST` and `z_const` (in a future commit).
Suggested-by: Dan Fandrich
Ref: https://github.com/curl/curl/pull/16142#discussion_r1985449743Closes#16616
Quiche needs to find easy handles to events. Do this by iterating
over the filters stream hash and lookup the easy handle on a match.
This O(+streams-in-filter) vs O(all easy handles), at least once
we fix the multi lookup to use a hash.
Closes#16607
- enable zstd in Cygwin and MSYS jobs.
- dl-mingw: use Ninja in the 9.5.0 (winlibs-mingw) job.
The download package is shipping with it. Saves 15s build time.
Keep testing GNU Makefiles with the two mingw-builds jobs.
- dl-mingw: split `env` prop to `env` and `ver` to aid integrating with
MSYS2.
- dl-mingw: install MSYS2 with options to make it quick (<20s).
It allows to use MSYS2 dependency packages with the downloaded
toolchains. It also makes configuration cleaner. Install libpsl.
- dl-mingw: enable mbedTLS in the 7.3.0 job.
(OpenSSL took a long time to install, wolfSSL misses features.)
Assisted-by: Jeremy Drake
Closes#16429
Seen with downloaded mingw 7.3.0 when built against MSYS2 mbedTLS 3.6.2:
```
lib/vtls/cipher_suite.c: In function 'cs_zip_to_str':
lib/vtls/cipher_suite.c:789:16: error: conversion to 'uint8_t {aka unsigned char}' from 'int' may alter its value [-Werror=conversion]
indexes[1] = ((zip[0] << 4) & 0x3F) | zip[1] >> 4;
^
lib/vtls/cipher_suite.c:790:16: error: conversion to 'uint8_t {aka unsigned char}' from 'int' may alter its value [-Werror=conversion]
indexes[2] = ((zip[1] << 2) & 0x3F) | zip[2] >> 6;
^
lib/vtls/cipher_suite.c:793:16: error: conversion to 'uint8_t {aka unsigned char}' from 'int' may alter its value [-Werror=conversion]
indexes[5] = ((zip[3] << 4) & 0x3F) | zip[4] >> 4;
^
lib/vtls/cipher_suite.c:794:16: error: conversion to 'uint8_t {aka unsigned char}' from 'int' may alter its value [-Werror=conversion]
indexes[6] = ((zip[4] << 2) & 0x3F) | zip[5] >> 6;
^
```
Ref: https://github.com/curl/curl/actions/runs/13719756989/job/38372409927?pr=16429#step:10:21
Cherry-picked from #16429Closes#16614
Iterate over the filters stream hash instead, lookup easy handles
at the multi when needed.
This also limits to pollset array sizes to the number of streams
on the connection and not the total number of transfers in the multi.
Closes#16611
General tidy-ups, to identify and reduce duplications and potential
issues, while also making the server modules compile as a single binary.
- ensure unique symbols and no shadowing across server sources, by
renaming variables.
- move globals common to multiple servers into shared `util` module.
- drop constants with a single use.
- undef macro before re-using them across server sources.
- move common functions into shared `util` module.
- drop redundant static declarations.
- disable IPv6 code when built without IPv6.
- start syncing the 3 almost identical copies of `sockdaemon` function.
- drop unused `timeval.h` header.
- drop `poll()` from `wait_ms()`, for macOS, following an earlier core
update.
Follow-up to c72cefea0f#15096
Follow-up to 9213e4e497#16525
Cherry-picked from #15000Closes#16609
Apply downstream patches from the vcpkg project:
- cmake: remove duplicates from `CURL_LIBDIRS`.
- cmake: set `CURL_LIBDIRS` as `INTERFACE_LINK_DIRECTORIES` for static
libcurl.
To support CMake <3.13, change downstream patch from:
```cmake
target_link_directories(${LIB_STATIC} INTERFACE ${CURL_LIBDIRS})
```
to:
```cmake
set_target_properties(${LIB_STATIC} PROPERTIES [...] INTERFACE_LINK_DIRECTORIES "${CURL_LIBDIRS}")
```
Co-authored-by: Kai Pastor
Ref: https://github.com/microsoft/vcpkg/pull/43819Closes#16610
Apply downstream patch from the vcpkg project:
- cmake/FindBrotli: streamline detecting multiple pkg-config modules.
Add `libbrotlicommon` to `Requires.private` in `libcurl.pc`.
Apply the above idea to the rest of multi-module dependencies:
- cmake/FindMbedTLS: streamline detecting multiple pkg-config modules
Add `mbedx509`, `mbedcrypto` to `Requires.private` in `libcurl.pc`.
- cmake/FindLDAP: streamline detecting multiple pkg-config modules
And sync these changes with autotools, and add `libbrotlicommon`,
`mbedx509`, `mbedcrypto` to `Requires.private`.
Co-authored-by: Kai Pastor
Ref: https://github.com/microsoft/vcpkg/pull/43819Closes#16479
For the case when the connection struct is all setup, the protocol
handler allocates data in its setup_connection function, but the
connection struct is discarded again before used further because a
connection reuse is prefered. Then the handler's disconnect function was
not previously called, which then would lead to a memory leak.
I added test case 698 that reproduces the leak and the fix.
Reported-by: Philippe Antoine
Closes#16604
Add support for running pytest in GHA/macos jobs.
Experimental, with caveats:
- slow.
- `httpd` often fails to start.
- 10-15 tests (depending on C compiler) fail consistently:
02_20, 02_33, 02_34, 03_01, 03_03, 05_04, 07_42.
- Homebrew build of vsftpd misses TLS support.
- `nghttpx` temporarily disabled for pytest.
You can test pytest by adding `install_steps: pytest` to a job.
Closes#16518
Fixed a heap read overflow when parsing the HTTP RR svcparams. Also the
code failed to enforce the requirements of SvcParamKey order specified
in section 2.2 of the RFC 9460.
Closes#16598
Before this patch `--http2` did not work in gcc builds with Secure
Transport, because ALPN relied on a compiler supporting the
`HAVE_BUILTIN_AVAILABLE` aka `__builtin_available()` feature. This
is clang-specific and missing from gcc (as of gcc v14).
Add support for ALPN and HTTP/2 when this compiler feature is missing.
Also drop test exceptions from GHA/macos in CI.
Follow-up to 092f6815c8
Ref: c349bd668c#14097 (issue 15.)
Ref: #4314Closes#16581
Change the format of error messages sent to stderr from tests and test
servers. As a workaround to avoid triggering Visual Studio's MSBuild
tool's built-in regexp matcher, and making it mark builds failed for
reasons we don't want them to hard fail.
Roughly, the pattern to avoid is the word "error" (case-insensitive)
in the same line with a colon `:`.
It affected GHA/windows MSVC CI jobs, causing flakiness:
```
CUSTOMBUILD : fopen() failed with error : 13 Permission denied [D:\a\curl\curl\bld\tests\test-ci.vcxproj]
Error opening file: log/4/smtp_sockfilt.log
[...]
CUSTOMBUILD : fopen() failed with error : 13 Permission denied [D:\a\curl\curl\bld\tests\test-ci.vcxproj]
Error opening file: log/8/imap_sockfilt.log
Msg not logged: 00:18:10.656000 > 178 bytes data, server => client
[...]
TESTDONE: 1629 tests out of 1634 reported OK: 99%
Building Custom Rule D:/a/curl/curl/tests/CMakeLists.txt
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(254,5): error MSB8066: Custom build for 'D:\a\curl\curl\bld\CMakeFiles\621f80ddbb0fa48179f056ca77842ff0\test-ci.rule;D:\a\curl\curl\tests\CMakeLists.txt' exited with code -1. [D:\a\curl\curl\bld\tests\test-ci.vcxproj]
Error: Process completed with exit code 1.
```
Ref: https://github.com/curl/curl/actions/runs/13643149623/job/38137076210?pr=16490#step:14:3125
Ref: https://github.com/curl/curl/actions/runs/13688765792/job/38277961720?pr=16582#step:14:1717
The `IgnoreStandardErrorWarningFormat="true"` MSBuild Exec option
controls this behavior:
https://learn.microsoft.com/visualstudio/msbuild/exec-task#parameters
I couldn't figure out a way to apply it to CMake builds.
MSBuid pattern matching rules:
353c0f3d37/src/Shared/CanonicalError.cshttps://learn.microsoft.com/visualstudio/msbuild/msbuild-diagnostic-format-for-tasks
Note: There may be further error messages output from runtests scripts,
that use this format, which are not explicitly fatal. They may need
future fixes.
Thanks-to: Dion Williams
Ref: https://github.com/curl/curl/discussions/14854#discussioncomment-12382190
Ref: https://github.com/curl/curl/discussions/14854#discussioncomment-12395224Closes#16583
Disable these winsock2 functions on Windows to use the curl wrappers
and preserve `WSAGetLastError()` aka `SOCKERRNO` error codes.
curl sources uses `inet_pton()` and `inet_ntop()` via its own `Curl_`
prefixed wrappers. These wrappers promise to not overwrite
`WSAGetLastError()` aka `SOCKERRNO` error codes when calling them.
But, for Windows builds with these built-in winsock2 functions detected
(meaning all supported Windows versions, except Windows CE),
the wrappers were 1-to-1 mapped to the winsock2 functions, which broke
this promise.
b06c12b724/lib/inet_ntop.c (L188-L190)b06c12b724/lib/inet_pton.c (L66-L70)
These promises are old (a1d5983991) and
may not be valid anymore. In this case, the callers would have to be
updated to use `SOCKERRNO` to retrieve any error, instead of using
`errno` as they do now.
https://learn.microsoft.com/windows/win32/api/ws2tcpip/nf-ws2tcpip-inet_ntophttps://learn.microsoft.com/windows/win32/api/ws2tcpip/nf-ws2tcpip-inet_ptonCloses#16577
Since more than one handle can be removed in a single call to
multi_runsingle(), we cannot easily continue on the next node when a
node has been removed since that node migth ALSO have been removed.
Reported-by: Philippe Antoine
Closes#16588
- brings this functionality to all users of this function automatically
and consistently
- consistently returns every line without trailing \n
Closes#16590
Keep only the generated files needed for tests. Place generated
intermediaries in `tests/certs/gen` where they are ignored by git. No
longer generated `*.dhp` files.
Have a shorter naming scheme: `test-ca` instead of `EdelCurlRoot-ca` and
`test-localhost` instead of `Server-localhost-sv`, etc.
Remove the `stunnel` certificate as it was nearly a duplicate of
`test-localhost`.
No longer copy a generated certificates to `tests/stunnel.pem`. Let test
server default to `certs/test-localhost.pem` instead.
Closes#16593
Re-enable running tests 19, 504, 704, 705, 1233 in CI MSYS jobs.
We carried over these exceptions from AppVeyor CI, where they have been
present for a long time. Cygwin jobs do not need these exceptions and
Cygwin and MSYS are similar envs. Time to re-evaluate if skipping them
is still necessary on MSYS.
Closes#16592