Commit Graph

35949 Commits

Author SHA1 Message Date
Jay Satiro
6c70ec16c7 http: ignore invalid Retry-After times
- Treat negative Retry-After date-based times as 0.

- Treat Retry-After times greater than 6 hours as 6 hours.

Prior to this change Retry-After did not have a limited range and the
server could have set a time greater than 6 hours or a date in the past
that would result in a negative time, either of which may be unexpected
by the user.

The 6 hour limit is purposely not documented so that it can be changed
in the future if necessary.

Closes https://github.com/curl/curl/pull/15833
2024-12-31 03:19:22 -05:00
Viktor Szakats
8d1f26b866
GHA/http3-linux: do run on cmake build updates
Closes #15874
2024-12-31 04:16:19 +01:00
Viktor Szakats
1e14e1682c
examples/block-ip: drop redundant memory.h include
Not used elsewhere in the repo.
2024-12-31 00:35:57 +01:00
Viktor Szakats
f7c2bf0818
cmake: rename Windows detection cache file
To flatten the directory tree.

Closes #15859
2024-12-31 00:24:00 +01:00
Stefan Eissing
8a66c11a29
vtls: only remember the expiry timestamp in session cache
Instead of receive and lifetime, keep only the eppch seconds when a
session expires.

Closes #15861
2024-12-30 16:14:52 +01:00
Daniel Stenberg
c2d37463b9
curl/var: change byte offset syntax for assignments
Follow-up to 40c264db61 after discussions on IRC.

The new style is

  name[0-99]=contents

and

  name[0-99]@filename

A) This does not cause the same problems with old curl versions trying
the new syntax as this way will cause old curls just fail with syntax
error and not risk using the wrong file.

B) Adds the same byte range support for "normal" assigns, which the
previous syntax did not. Thus lets a user get a partial content of a
variable etc.

Added test 790 and 791 to verify non-file assigns with ranges.

Closes #15862
2024-12-30 15:55:54 +01:00
Viktor Szakats
e7b90dadb2
GHA/non-native: measure duration of individual build steps inside VMs
Closes #15864
2024-12-30 14:23:45 +01:00
dependabot[bot]
5dc5bd7638
CI: bump actions/cache from 4.1.2 to 4.2.0
Bumps [actions/cache](https://github.com/actions/cache) from 4.1.2 to 4.2.0.
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](https://github.com/actions/cache/compare/v4.1.2...1bd1e32a3bdc45362d1e726936510720a7c30a57)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Closes #15817
2024-12-30 14:05:25 +01:00
dependabot[bot]
2a6dfe0274
CI: bump actions/upload-artifact from 4.4.3 to 4.5.0
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4.4.3 to 4.5.0.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](b4b15b8c7c...6f51ac03b9)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Closes #15816
2024-12-30 14:03:46 +01:00
Daniel Stenberg
53fcac438a
TheArtOfHttpScripting.md: rewrite double 'that'
Closes #15863
2024-12-30 14:02:37 +01:00
Stefan Eissing
a2622cdbd5
mbedtls: fix handling of blocked sends
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.

Reported-by: Tamás Bálint Misius
Fixes #15801
Closes #15846
2024-12-30 10:20:27 +01:00
Daniel Stenberg
c445b7426a
checksrc: introduce 'banfunc' to ban specific functions
Use 'banfunc' and 'allowfunc' in .checksrc to specify which functions to
ban or allow to be used. This saves us from having to edit the script
going forward when we want to ban or allow specific functions.

This replaces a set of previous rules and all banned functions are now
checked with the BANNEDFUNC rule.

There is a set of default banned functions, shown by invoking
./checksrc.

Also, -a and -b options are added to specify allowed or banned functions
on the command line.

Closes #15835
2024-12-30 08:25:56 +01:00
Daniel Stenberg
66e5351e0a
urlapi: fix redirect to a new fragment or query (only)
The redirect logic was broken when the redirect-to URL was a relative
URL only as a fragment or query (starting with '#' or '?').

Extended test 1560 to reproduce, then verify.

Reported-by: Jeroen Ooms
Fixes #15836
Closes #15848
2024-12-30 08:23:26 +01:00
renovate[bot]
687a62f100
CI: update vmactions/omnios-vm digest
to 8eba2a9217

Closes #15853
2024-12-30 01:34:53 +01:00
Daniel Stenberg
f0cfead78f
RELEASE-NOTES: synced
Bump the planned next version to 8.12.0
2024-12-29 14:23:21 +01:00
Viktor Szakats
b8b982c136
cmake: use STREQUAL to detect Linux
Instead of `MATCHES`.
To sync with another check that already used `STREQUAL`.

Closes #15855
2024-12-29 13:14:58 +01:00
Christopher Dannemiller
c78044c07e multi: fix curl_multi_waitfds reporting of fd_count
- Make curl_multi_waitfds consistent with the documentation.

Issue Addressed:

 - The documentation of curl_multi_waitfds indicates that users should
   be able to call curl_multi_waitfds with a NULL ufds. However, before
   this change, the function would return CURLM_BAD_FUNCTION_ARGUMENT.
 - Additionally, the documentation suggests that users can use this
   function to determine the number of file descriptors (fds) needed.
   However, the function would stop counting fds if the supplied fds
   were exhausted.

Changes Made:

 - NULL ufds Handling: curl_multi_waitfds can now accept a NULL ufds if
   size is also zero.
 - Counting File Descriptors: If curl_multi_waitfds is passed a NULL
   ufds, or the size of ufds is insufficient, the output parameter
   fd_count will return the number of fds needed. This value may be
   higher than actually needed but never lower.

Testing:

 - Test 2405 has been updated to cover the usage scenarios described
   above.

Fixes https://github.com/curl/curl/issues/15146
Closes https://github.com/curl/curl/pull/15155
2024-12-29 01:05:09 -05:00
Viktor Szakats
7d6edf1d8d
GHA/windows: shorten job timeouts
To reduce the wait for re-running stuck jobs.

Sometimes jobs hang/get stuck while running tests, ignoring the step
timeout.

Closes #15851
2024-12-29 01:13:32 +01:00
Viktor Szakats
abb4fa5b62
cmake: optimize out 4 picky warning option detections with gcc
Follow-up to 9c543de0ec #10973
Closes #15850
2024-12-29 01:13:31 +01:00
Viktor Szakats
3780c7abcd
cmake: drop unused HAVE_SYS_XATTR_H detection
Follow-up to 8e34505776 #15164
Follow-up to 1c877a0712 #1176

Closes #15845
2024-12-28 12:29:59 +01:00
Viktor Szakats
ef07663bc4
cmake: tidy up local variable names
Closes #15843
2024-12-28 12:29:59 +01:00
Viktor Szakats
aed02db247
cmake: drop duplicate Windows cache value
Closes #15840
2024-12-28 10:34:37 +01:00
Viktor Szakats
c5dff4b817
tidy-up: rename MHDX_INLINE to CURL_FORCEINLINE
Closes #15839
2024-12-28 10:34:35 +01:00
Viktor Szakats
bae9d5d780
GHA/non-native: fix CM/AM in FreeBSD job names
Closes #15837
2024-12-27 23:08:00 +01:00
Jay Satiro
39e21794a7 cookie: fix crash in netscape cookie parsing
- Parse the input string without modifying it.

Prior to this change a segfault could occur if the input string was
const because the tokenizer modified the input string. For example if
the user set CURLOPT_COOKIELIST to a const string then libcurl would
likely cause a crash when modifying that string. Even if the string was
not const or a crash did not occur there was still the incorrect and
unexpected modification of the user's input string.

This issue was caused by 30da1f59 (precedes 8.11.0) which refactored
some options parsing and eliminated the copy of the input string. Also,
an earlier commit f88cc654 incorrectly cast the input pointer when
passing it to strtok.

Co-authored-by: Daniel Stenberg

Closes https://github.com/curl/curl/pull/15826
2024-12-27 13:16:08 -05:00
Viktor Szakats
fabfa8e402
clang-tidy: add to CI, add cmake support, fix fallouts
build:
- autotools: fix to build generated sources for the `tidy` target.
- autotools: allow passing custom clang-tidy options via
  `CURL_CLANG_TIDYFLAGS` env.
- cmake: add `CURL_CLANG_TIDY` option to configure for `clang-tidy`.
  Also add:
  - `CLANG_TIDY` variable to customize the `clang-tidy` tool.
  - `CURL_CLANG_TIDYFLAGS` to pass custom options to `clang-tidy`.
- apply `--enable-werror` and `-DCURL_WERROR=ON` to `clang-tidy`.

CI/GHA:
- add clang-tidy job for Linux, using autotools and clang-tidy v18.
  This one needs to disable `clang-analyzer-valist.Uninitialized`
  to avoid false positives:
  https://github.com/llvm/llvm-project/issues/40656
  Duration: 5.5 minutes
- add clang-tidy job for macOS, using cmake and clang-tidy v19.
  This one also covers tests and examples, and doesn't hit the false
  positives seen with llvm v18 and earlier.
  Duration: 4.5 minutes
- Linux/macOS: skip installing test dependencies when not building or
  running tests.

fix fallouts reported by `clang-tidy`:
- lib:
  - cf-h2-proxy: unused assignment in non-debug builds.
  - cf-socket: silence warning.
    FIXME: https://github.com/curl/curl/pull/15825#issuecomment-2561867769
  - ftp: NULL passed to `strncmp()`.
  - http2: NULL-ptr deref.
  - mprintf: silence warning.
- src/tool_writeout: NULL passed to `fputs()`.
- examples:
  - invalid file pointers.
  - missing `fclose()`.
- tests:
  - http/clients/hx-download: memory leaks on error.
  - http/clients/hx-download: memory leak on repeat `-r` option.
  - server: double `fclose()`.
    https://www.man7.org/linux/man-pages/man3/fclose.3.html
  - server: invalid file pointer/handle.
  - server/getpart: unused assignments.
  - server/mqttd: leak on failed `realloc()`.
  - server/tftpd: NULL passed to `strcmp()`.

Closes #15825
2024-12-27 13:42:32 +01:00
Viktor Szakats
421e592db2
cmake: add librtmp Find module
The new detection method also allows to enable librtmp without using
OpenSSL as a curl TLS backend at the same time.

Also:
- implement manual version detection for librtmp.
  Version info is in hex. With CMake 3.13 and newer, extract it as a hex
  number. With earlier CMake version, just strip the leading zeroes.
  Doing more here seems overkill because librtmp has been standing
  at 2.3/2.4 for a decade now. Bumping into hex digits seems unlikely
  before deprecating CMake 3.13 support.
  librtmp advertises v2.4 via its `pkg-config` module, and v2.3 via
  its public header. The latter shows up in `curl -V` and either can
  be shown at configure-time depending on detection method.
  This isn't a curl bug.
- GHA/macos: enable rtmp in a job.
- apply the "half-detection" fix to the Find module.
  `librtmp` is also affected (in CI too), because it depends on libssl and
  libcrypto.

Closes #15832
2024-12-27 12:52:23 +01:00
Jay Satiro
5e1700d167 curl_ws_recv.md: fix typo 2024-12-27 00:37:53 -05:00
Viktor Szakats
fb1883d226
cmake: move pkg-config names to Find modules
Make the Find modules set and return their respective `pkg-config`
module name(s) to the CMake build process, which then adds those
to the `Requires:` list.

Before this patch, `pkg-config` module names were maintainted in two
separate places. After this patch, they are maintained in the Find
modules for dependencies that have one (most do).

Re-align existing modules with this change: msh3, mbedtls, rustls.
These modules return their `pkg-config` module name only when
detected via `pkg-config`.

Follow-up to d511ec8b0a #15573
Closes #15800
2024-12-26 12:59:59 +01:00
Viktor Szakats
a1eaa12a83
cmake: allow CURL_LTO regardless of CURL_BUILD_TYPE, enable in CI
Before this patch `CURL_LTO` only applied to builds explicitly
configured for `Release` or `RelWithDebInfo` via `CURL_BUILD_TYPE`.

After this patch it enables LTO regardess of build type.

Also:
- GHA/linux: enable LTO in an existing job.

Follow-up to 4ccf7622db #4799
Closes #15829
2024-12-25 21:46:55 +01:00
Viktor Szakats
98f419172b
cmake/FindLibpsl: protect against pkg-config "half-detection"
Same issue as seen before with libssh2: `libpsl`'s pkg-config module
depends on another module, but that's not found. CMake ends up reporting
`LIBPSL_FOUND=YES`, while leaving `LIBPSL_INCLUDE_DIRS` empty. Then
the build fails to find `psl.h`.

The missing dependency in this case is `icu4c`, which is "keg-only",
meaning it's not exposed in the default Homebrew header, pkg-config,
lib, etc locations. It must be added to the `PKG_CONFIG_PATH` env, as
suggested by the warnings messages of `pkgconf`.

To avoid this fallout, let's ensure that `LIBPSL_INCLUDE_DIRS` is
non-empty when detecting via `pkg-config` and fall back to the CMake
detection method otherwise.

This was an issue till Homebrew libpsl 0.21.5_1, fixed in 0.21.5_2, that
no longer depends on `icu4c`.

Example log:
```
-- Checking for module 'libpsl'
--   Found libpsl, version 0.21.5
Package icu-uc was not found in the pkg-config search path.
Perhaps you should add the directory containing `icu-uc.pc'
to the PKG_CONFIG_PATH environment variable
Package 'icu-uc', required by 'libpsl', not found
[...]
-- Found Libpsl (via pkg-config):  (found version "0.21.5")
[...]
In file included from curl/_bld/lib/CMakeFiles/libcurl_static.dir/Unity/unity_0_c.c:4:
In file included from curl/lib/altsvc.c:32:
In file included from curl/lib/urldata.h:145:
curl/lib/psl.h:28:10: fatal error: 'libpsl.h' file not found
         ^~~~~~~~~~
1 error generated.
```

Follow-up to 39c741b7b0 #15408
Closes #15827
2024-12-25 21:46:55 +01:00
Viktor Szakats
32bc428826
cmake/FindLDAP: avoid empty 'Requires' item when omitting pkg-config module
`list(APPEND ...)` does this automatically, but we're _prepending_ LDAP
(to follow historical code and also autotools). `list(PREPEND ...)`
would likely do that the same, but it requires CMake 3.15 so we do this
manually and the manual method needs to skip the empty value manually.

Follow-up to 49f2a23d50 #15273
Closes #15828
2024-12-24 11:59:02 +01:00
Viktor Szakats
7a70b46481
tidy-up: misc
- lib1531: fix to use `curl_off_t`.
- src/tool_doswin: merge `_WIN32` guards.
- src/tool_doswin: limit `S_ISCHR()` to MS-DOS.
- src: dedupe `CURL_O_BINARY` macro into `tool_setup.h`.
- CMake/CurlTests.c: cleanup/formatting `HAVE_FILE_OFFSET_BITS` test.
- examples/httpput-postfields: delete unused include.
- spelling: MultiSSL.
- whitespace.

Ref: #15652
Closes #15799
2024-12-24 01:27:26 +01:00
Viktor Szakats
415741ef94
curl-config: tidy up, optimize
- optimize out `cppflag_curl_staticlib` variable.
- optimize out `CPPFLAG_CURL_STATICLIB` variable and simplify logic.
- lowercase local variable name `CURLLIBDIR`.

Closes #15810
2024-12-24 01:21:38 +01:00
Viktor Szakats
f5d0ba0e75
cmake: move GSS init before feature detections
To sync up with other dependency initializations.

Closes #15809
2024-12-24 01:21:38 +01:00
Daniel Stenberg
822971170c
curl_url_set.md: adjust the added-in to 7.62.0
Reported-by: Jeroen Ooms
Fixes #15822
Closes #15823
2024-12-24 00:42:38 +01:00
Marcel Raad
826727bfeb
http: fix build with CURL_DISABLE_COOKIES
This fixes an oversight from commit fc3e1cbc50.

Closes https://github.com/curl/curl/pull/15820
2024-12-23 23:13:11 +01:00
Daniel Stenberg
770835c175
RELEASE-NOTES: synced 2024-12-23 23:06:36 +01:00
Daniel Stenberg
9d5ecc9613
getinfo: provide info which auth was used for HTTP and proxy
CURLINFO_HTTPAUTH_USED and CURLINFO_PROXYAUTH_USED

Tested in 590 and 694

Ref: #12668
Idea-by: Ganesh Viswanathan
Closes #15450
2024-12-23 23:03:54 +01:00
Daniel Stenberg
f3efab1bb4
build: fix the tidy targets for autotools
To make them run clang-tidy correctly. clang-tidy occasionally finds
mistakes none of the other static code analyzers we use finds.

Also added the
-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling
flag, to make it not complain about memcpy()

"make tidy" in the build root works fine now. The previous clang-tidy CI
job was removed in e43c3b3e3e. It is probably time to bring it
back.

Closes #15813
2024-12-23 23:03:10 +01:00
Viktor Szakats
c80c399c45
build: drop -Winline picky warning
To avoid this in certain debug build cases:
```
./lib/easy_lock.h:72:20: error: inlining failed in call to 'curl_simple_lock_lock': function not considered for inlining [-Werror=inline]
```

Ref: #13596
Reported-by: Rudi Heitbaum
Fixes #15815
Closes #15819
2024-12-23 22:13:23 +01:00
Viktor Szakats
6dacd2f208
src: add CURL_STRICMP() macro, use _stricmp() on Windows
Add `CURL_STRICMP()` macro that works on all platforms depending on
which lib C function is available.

Make sure to always use `_stricmp()` on Windows, which is the
non-deprecated, official API for this on this platform. Before this
patch it used a MinGW-specific call, or a deprecated compatibility
wrapper with MSVC.

Drop `stricmp` variant detections on Windows with autotools.

https://learn.microsoft.com/cpp/c-runtime-library/reference/stricmp-wcsicmp-mbsicmp-stricmp-l-wcsicmp-l-mbsicmp-l

Ref: #15652
Closes #15788
2024-12-23 22:06:07 +01:00
Stefan Eissing
68bd759c2b
QUIC: 0RTT for gnutls via CURLSSLOPT_EARLYDATA
When a QUIC TLS session announced early data support and
'CURLSSLOPT_EARLYDATA' is set for the transfer, send initial request and
body (up to the 128k we buffer) as 0RTT when curl is built with
ngtcp2+gnutls.

QUIC 0RTT needs not only the TLS session but the QUIC transport
paramters as well. Store those and the earlydata max value together with
the session in the cache.

Add test case for h3 use of this. Enable quic early data in nghttpx for
testing.

Closes #15667
2024-12-23 17:07:15 +01:00
Daniel Stenberg
b399a98d2d
ngtcp2: fix two cases of value stored never read
Detected by clang-tidy

Closes #15812
2024-12-23 13:45:07 +01:00
Daniel Stenberg
0ebd286aa3
CURLOPT_PROXY.md: clarify the crendential support in proxy URLs
Ref: #15802
Closes #15805
2024-12-23 11:52:42 +01:00
Daniel Stenberg
6090018305
openssl: fix ECH logic
- on error, bail out proper
- remove unused #define

Closes #15814
2024-12-23 11:49:57 +01:00
Daniel Stenberg
173805b2e7
GHA: drop codeql
We started using codeql for static code analysis in 7183f5acc3,
June 2020.

Since then, not a single commit has been merged into the source code
repository citing codeql as source or reason. Yet, it keeps getting
updated and we get constant reminders to upgrade the pinning it to the
latest hash.

During 4.5 years with intense development and significant code churn.
While Coverity, scan-build and CodeSonar have belped us point out many
mistakes, codeql has remained silent (or had false positives).

For this little gain, I think we spend a disproportionate amount of work
on codeql maintanance.

We can try again in a future if we think it improves.

Assisted-by: Viktor Szakats
Closes #15798
2024-12-23 08:51:21 +01:00
Daniel Stenberg
5bdcaa76d1
vquic: make vquic_send_packets not return without setting psent
This is debug code, but since the caller might use the value even when
this function returns error, it needs to be cleared properly here.

Spotted by Clang-tidy

Closes #15807
2024-12-23 08:29:52 +01:00
Daniel Stenberg
3f041a3852
vquic: fix 4th function call argument is an uninitialized value
As recvmmsg_packets() could fail early and goto out before 'pkts' were
assigned.

Caught by clang-tidy

Closes #15808
2024-12-23 08:28:27 +01:00
Daniel Stenberg
ebcf3d20d7
http2: fix value stored to 'result' is never read
Detected by clang-tidy

Closes #15806
2024-12-23 08:27:28 +01:00