Commit Graph

38400 Commits

Author SHA1 Message Date
Daniel Stenberg
6d1d50d65d
protocol: use scheme names lowercase
When composing the <scheme>_proxy environment variable, we assume the
handler->scheme name is already lowercase.

This makes unit test 1627 verify that is the case.

Follow-up to c294f9cb56

Spotted by Codex Security

Closes #21033
2026-03-20 16:00:30 +01:00
Daniel Stenberg
0b182ae529
file: init fd to -1 to prevent close fd 0 on early failure
Spotted by Codex Security

Closes #21029
2026-03-20 15:00:21 +01:00
Viktor Szakats
2cdb2209da
getinfo: initialize PureInfo field used_proxy
Found by Codex Security

Follow-up to cc04c73677 #12719

Closes #21020
2026-03-20 13:47:32 +01:00
Daniel Stenberg
e3ed70ce72
url: use the socks type for socks proxy
Reported by Codex Security

Closes #21025
2026-03-20 13:17:22 +01:00
Daniel Stenberg
14782b36fe
x509asn1: fixed and adapted for ASN1tostr unit testing
- move defines to header file
- make bit2str require < 8 unused bits
- make bool strings stricter
- make UTime2str show + or - for custom time zones
- removed unused 'type' argument to ASN1tostr() function
- fix int2str for negative values. All values below 10000 are now shown
  in decimal properly, also possibly negative values.

Add unit test 1667 to verify ASN1tostr

Closes #21013
2026-03-20 13:03:40 +01:00
Daniel Stenberg
756725a32b
tool_operate: drop the scheme-guessing in the -G handling
Prior to this, -G would override the scheme set with --proto-default and
revert back to guessing the scheme based on the hostname.

Add test 2008 to verify the fix

Spotted by Codex Security

Closes #20992
2026-03-20 11:57:10 +01:00
Viktor Szakats
8a1f361716
build: limit unitprotos.h include to units target
To omit it from `tunits`.

Also: move the include to `unitcheck.h` to save a guard.

Ref: https://github.com/curl/curl/pull/21014#issuecomment-4093742896
Reported-by: Daniel Stenberg
Fixes #21021
Follow-up to 98d8e82c74 #21014

Closes #21024
2026-03-20 11:31:35 +01:00
Daniel Stenberg
2b3332e749
tests/unit/README: describe how to unit test static functions
UNITTEST explained

Closes #21018
2026-03-20 07:56:19 +01:00
Daniel Stenberg
98d8e82c74
lib: move all UNITTEST prototypes to C files
- make extract-unit-protos handle multi-line prototypes - but they need
  to be above the implementation

- Prototypes for static functions we use in unit tests should not be in
  header files. We generate lib/unitprotos.h for this purpose

- Removed some function wrappers written for unit tests and make them
  use UNITTEST function directly.

- Renamed time2str() in the tool to timebuf() since we have the same
  name in lib/ and in unit tests they can both be used non-static in a
  build.

This reverts commit f95fadd116.

Follow-up to #21010

Closes #21014
2026-03-20 07:47:57 +01:00
Viktor Szakats
7242cea7f6
GHA/macos: restore compatibility with Intel runners
By generalizing Homebrew prefix in shared code paths, where missing.
No strong reason, sometimes it's useful for tests.

Follow-up to e5316069f1 #18818

Closes #21019
2026-03-20 01:42:47 +01:00
Viktor Szakats
6b645f91f6
mk-lib1521.pl: fix 4 callback function types passed to setopt
Silencing these warnings (seen on Solaris 11 SPARC GCC 4.9.2 + OpenCSW):
```
lib1521.c: In function 'test_lib1521':
/include/curl/typecheck-gcc.h:93:13: warning: call to 'Wcurl_easy_setopt_err_conv_cb' declared with attribute warning: curl_easy_setopt expects a curl_conv_callback argument
curl_easy_setopt(curl, CURLOPT_CONV_FROM_NETWORK_FUNCTION,
curl_easy_setopt(curl, CURLOPT_CONV_TO_NETWORK_FUNCTION,
curl_easy_setopt(curl, CURLOPT_CONV_FROM_UTF8_FUNCTION,
/include/curl/typecheck-gcc.h:123:13: warning: call to 'Wcurl_easy_setopt_err_interleave_cb' declared with attribute warning: curl_easy_setopt expects a curl_interleave_callback argument
curl_easy_setopt(curl, CURLOPT_INTERLEAVEFUNCTION,
```
Ref: https://curl.se/dev/log.cgi?id=20260319160651-1785427#prob2

Follow-up to de0adda78c

Closes #21017
2026-03-20 01:42:47 +01:00
Viktor Szakats
585955cd9a
servers.pm: fix to check gopher6 server on its ipv6 port
Found by Codex Security

Closes #21016
2026-03-20 01:42:47 +01:00
Viktor Szakats
43397b0283
cmake: extend C89-specific warning suppressions to all llvm/clang
From Apple clang-only prior to this patch.

Silencing (seen after macos-15 runner accidentally switched to
llvm/clang by default):
```
/Users/runner/work/curl/curl/lib/curlx/warnless.h:64:1: error: '_Bool' is a C99 extension [-Werror,-Wc99-extensions]
   64 | bool curlx_sztouz(ssize_t sznum, size_t *puznum);
      | ^
/opt/homebrew/Cellar/llvm@18/18.1.8/lib/clang/18/include/stdbool.h:20:14: note: expanded from macro 'bool'
   20 | #define bool _Bool
      |              ^
[...]
```
Ref: https://github.com/curl/curl/actions/runs/23304345180/job/67774031335?pr=21014#step:11:39

Follow-up to 09c9afdd71 #20363
Ref: https://github.com/actions/runner-images/issues/13827

Closes #21015
2026-03-19 17:54:10 +01:00
Viktor Szakats
a9e341a469
optiontable: replace stdin with filename arg, harden open() call
Closes #21008
2026-03-19 15:06:43 +01:00
Viktor Szakats
f95fadd116
x509asn1: move declaration to header
Fixing clang-tidy warning:
```
tests/unit/unit1666.c:50:12: error: call to undeclared function 'encodeOID'; ISO C99 and later do not support implicit function declarations [clang-diagnostic-implicit-function-declaration]
   50 |   result = encodeOID(dbuf, oid, oid + spec->size);
      |            ^
```
Ref: https://github.com/curl/curl/actions/runs/23297585235/job/67749144361?pr=21008#step:46:736

Follow-up to 673e14cd33 #21003

Closes #21010
2026-03-19 15:04:12 +01:00
Viktor Szakats
51f813308e
scripts: harden / tidy up more Perl system() calls
Closes #21007
2026-03-19 14:26:56 +01:00
Viktor Szakats
31add10322
docs: enable more compiler warnings for C snippets, fix 3 finds
Also:
- sync gcc option order.
- unfold lines in C snippet.

Closes #21006
2026-03-19 14:21:53 +01:00
Daniel Stenberg
673e14cd33
x509asn1: improve encodeOID
- return error on zero length input
- return error on OOM or doing too large output
- fix full 32-bit number support
- fix the broken handling of the first and second numbers
- support up to 32-bit minus 80 for the second number
- a field with a leading 0x80 is now considered an error, since it only
  works as padding and is then no longer the shortest possible version

Add unit tests in 1666

Bonus: removed the last argument to OID2str() as it was always set TRUE.

Closes #21003
2026-03-19 13:55:34 +01:00
Viktor Szakats
ce51fb493c
include: drop 'will' from public headers
Closes #21005
2026-03-19 12:02:10 +01:00
Viktor Szakats
387efe3d28
extract-unit-protos: retain internal paths for includes
Follow-up to 3058ed3df8 #20623

Closes #21004
2026-03-19 12:02:10 +01:00
Jason Stangroome
ae864e824e
examples: fix typo in comment
noticed while reviewing https://github.com/curl/curl/pull/20793

Ref: https://github.com/curl/curl/pull/20793/changes#r2957089487

Closes #21001
2026-03-19 12:02:10 +01:00
renovate[bot]
e9c3dacc5e
GHA: update dependency wolfSSL/wolfssl to v5.9.0
Closes #20998
2026-03-19 12:02:10 +01:00
Viktor Szakats
3bc6ae5500
mod_curltest: fix allocation size
It wasn't causing an issue with current usage.

Found by Codex Security

Follow-up to 35cfb081d2 #16541

Closes #20994
2026-03-19 12:02:10 +01:00
Viktor Szakats
6c0772fd7f
openssl: fix memory leaks in ECH code (OpenSSL 3)
Also drop an unnecessary cast.

Found by Codex Security

Follow-up to a362962b72 #11922

Closes #20993
2026-03-19 12:02:10 +01:00
Viktor Szakats
fc222ec11f
tool_operate: fix condition for loading curl-ca-bundle.crt (Windows)
It was incorrecly loaded with env `CURL_CA_BUNDLE` unset +
`SSL_CERT_DIR` set + `SSL_CERT_FILE` unset.

Found by Codex Security

Follow-up to 29bce9857a #11325 #11531

Closes #20989
2026-03-19 12:02:10 +01:00
Viktor Szakats
2bb3643bc1
sws: fix potential OOB write
Found by Codex Security

Follow-up to 0aaebf62ec

Closes #20988
2026-03-19 12:02:10 +01:00
Viktor Szakats
1c7a270e26
sshserver.pl: harden more system() calls
Ref: https://perldoc.perl.org/functions/system

Closes #20997
2026-03-19 11:27:03 +01:00
Viktor Szakats
1509b0ce6a
sshserver.pl: pass command-line to system() safely
Found by Codex Security

Follow-up to 89f306ae40 #16781

Closes #20996
2026-03-19 11:27:03 +01:00
Viktor Szakats
86c25c06c9
x509asn1: fix to return error in an error case from encodeOID()
Found by Codex Security

Follow-up to d8b0318ad6 #3582

Closes #20991
2026-03-19 11:17:17 +01:00
Viktor Szakats
59405ffb7d
build: enable -Wimplicit-int-enum-cast compiler warning, fix issues
Offered by clang 21+.

Closes #20990
2026-03-19 11:17:17 +01:00
Viktor Szakats
d86fd143a1
synctime: fix off-by-one read and write to a read-only buffer (Windows)
Also making the `--synctime` option work.

Off-by-one found by Codex Security

Assisted-by: Jay Satiro

Closes #20987
2026-03-19 11:17:17 +01:00
Viktor Szakats
e345dfb958
asyn-ares: drop orphaned variable references
In rare, conditional `#if` branches.

Found by Codex Security

Follow-up to ac7e2c3dc6 #17450
Follow-up to 7bf576064c #17167

Closes #20999
2026-03-19 02:24:06 +01:00
renovate[bot]
ad9836dfa4
GHA: update dependency nghttp2/nghttp2 to v1.68.1
Closes #20982
2026-03-18 15:06:44 +01:00
Viktor Szakats
d986b89c88
rand: use BCryptGenRandom() in UWP builds
Also:
- fix build configuration to correctly set Win10 target in the mingw-w64
  CI build, to enable the `BCryptGenRandom()` prototype in v6+ SDK
  headers.

Ref: https://learn.microsoft.com/windows/win32/api/bcrypt/nf-bcrypt-bcryptgenrandom

Issue raised by Codex Security

Closes #20983
2026-03-18 14:47:39 +01:00
Stefan Eissing
41aaac61e2
lib: always use Curl_1st_fatal instead of Curl_1st_err
Curl_1st_err() does not return the second error if the first result is
CURLE_AGAIN. This may cause errors to not become noticeable when they
should be.

Replace all use of Curl_1st_err() with Curl_1st_fatal(), which handles
CURLE_AGAIN as a not-a-real-error case.

Closes #20980
2026-03-18 13:38:51 +01:00
Viktor Szakats
77c5470147
scripts: drop unused CI scripts
Replaced by Test Clutch:
https://testclutch.curl.se/static/reports/feature-matrix.html

Closes #20981
2026-03-18 13:07:13 +01:00
Viktor Szakats
454db7aeee
badwords: prefer 'null-terminated'
Aligning with existing text.

Closes #20979
2026-03-18 11:40:13 +01:00
Viktor Szakats
a3699e8b9e
examples/websocket: fix to sleep more on Windows
Found by Codex Security

Follow-up to d4b8589055 #13771

Closes #20978
2026-03-18 11:37:15 +01:00
Viktor Szakats
c5daffe5f3
delta: avoid potential zero division
Found by Codex Security

Closes #20977
2026-03-18 11:37:15 +01:00
Viktor Szakats
578ee6b79b
gcc: guard #pragma diagnostic in core code for <4.6, disable picky warnings
Extend `#pragma diagnostic push`/`pop` guards to the whole codebase
(from tests and examples only) to disable it for GCC <4.6. Rename guard
to `CURL_HAVE_DIAG` and make it include llvm/clang to be interchangeable
with `__GNUC__ || __clang__` in this context.

The above means no longer disabling certain warnings locally, so pair
this with disabling all picky warnings for GCC <4.6.

Also:
- drop global workarounds for misbehaving GCC <4.6 compiler warnings.
  Not needed with picky warnings disabled.

Reported-by: fds242 on github
Reported-by: Sergey Fedorov
Thanks-to: Orgad Shaneh
Follow-up to f07a98ae11 #20366
Fixes #20892
Fixes #20924
Closes #20902
Closes #20907
2026-03-18 11:33:37 +01:00
Ercan Ermis
c3f04e76ae
ftp: reject PWD responses containing control characters
A malicious or compromised FTP server could include control characters
(e.g. bare \r, or bytes 0x01-0x1f/0x7f) inside the quoted directory path
of its 257 PWD response. That string is stored verbatim as
ftpc->entrypath and later sent unescaped in a CWD command on connection
reuse via Curl_pp_sendf(), which performs no sanitization before
appending \r\n.

Reject the entire path if any control character is encountered during
extraction so that tainted data never reaches a subsequent FTP command.

Add test case 3217 and 3218 to verify. Adjusted test 1152 accordingly.

Closes #20949
2026-03-18 11:24:41 +01:00
Viktor Szakats
650b33a3db
badwords: pass config as filename arg
Instead of stdin.

To simplify the command-line, and allow using a safe and portable
`system()` call from `badwords-all`.

Ref: https://perldoc.perl.org/functions/system

Closes #20970
2026-03-18 11:22:23 +01:00
Daniel Stenberg
3f06e27502
urlapi: make dedotdotify handle leading dots correctly
Paths starting with one or two leading dots but without a following
slash were not handled correctly.

Follow-up to c31dd6631f

Extended test 1395 accordingly with a set of new test string.

Reported by Codex Security

Closes #20974
2026-03-18 11:14:20 +01:00
Daniel Stenberg
acb4fcb2ef
tool_msgs: avoid null pointer deref for early errors
When errorf()/warnf() is used early on, before the global pointer is
setup, curl would previosly deref the null pointer.

Follow-up to 3b40128b0f

Found by Codex Security

Closes #20967
2026-03-18 10:40:19 +01:00
Daniel Stenberg
a43ea5943b
http2: clear the h2 session at delete
When calling nghttp2 to delete session, clear the pointer to avoid risk
of UAF.

Pointed out by Codex Security

Closes #20975
2026-03-18 10:34:48 +01:00
Daniel Stenberg
02e04eaee7
asyn-ares: fix HTTPS-lookup when not on port 443
Follow-up to 8d0bfe74fb

Spotted by Codex Security

Closes #20966
2026-03-18 10:25:52 +01:00
Daniel Stenberg
b11f43a4db
top-complexity: prevent filename-based shell injection risk
As we run this script in CI, this should reduce the risk of mischief

Found by Codex Security

Closes #20969
2026-03-18 10:24:53 +01:00
Daniel Stenberg
80b6cd92af
tool_formparse: propagate my_get_line errors when reading headers
The read_field_headers() function would return "ok" even if the
underlying file read returned error, thus would the parent not become
aware of the problem.

Follow-up to f847d2ed02

Found by Codex Security

Closes #20963
2026-03-17 23:41:23 +01:00
Daniel Stenberg
0d7677ac72
generate.bat: remove extra % from VC11 and VC12 runs
The extra % translates to nothing, so this did not break anything they
are just superfluous.

Follow-up to 57d349fe0e

Assisted-by: Viktor Szakats

Found by Codex Security
2026-03-17 23:39:33 +01:00
Viktor Szakats
650546fbe0
cmake: document functions used from Windows system DLLs
Closes #20965
2026-03-17 22:17:36 +01:00