Commit Graph

15706 Commits

Author SHA1 Message Date
Viktor Szakats
2dc71ba8bf
badwords: check indented lines in source code, fix fallouts
- badwords.pl: add `-a` option to check all lines in source code files.
  Before this patch indented lines were skipped (to avoid Markdown code
  fences.)
- GHA/checksrc: use `-a` when verifying the source code.
- GHA/checksrc: disable `So` and `But` rules for source code.
- GHA/checksrc: add docs/examples to the verified sources.
- badwords.txt: delete 4 duplicates.
- badwords.txt: group and sort contractions.
- badwords.txt: allow ` url = `, `DIR`, `<file name`.

Closes #19536
2025-11-15 13:25:02 +01:00
Viktor Szakats
af4c789e00
badwords: fix two exceptions and drop them
Also:
- extend `dir` rule to exclude C assignments.

Closes #19532
2025-11-14 17:32:04 +01:00
Daniel Stenberg
3d91ca8cdb
vquic-tls/gnutls: call Curl_gtls_verifyserver unconditionally
Closes #19531
2025-11-14 17:05:11 +01:00
Stefan Eissing
dc34498d18
cf-socket: trace ignored errors
Instead of blasting the user with infof() statements.

Reported-by: Aleksandr Sergeev
Fixes #19520
Closes #19527
2025-11-14 17:04:15 +01:00
Stefan Eissing
9f979ea683
vtls: pinned key check
Cleanup the vtls pinned key matching somewhat. Add a DEBUGF
for pinned key hashes that do not match, so we can see in
traces what was going on.

Ref #19489
Closes #19529
2025-11-14 17:01:44 +01:00
Stefan Eissing
0abb72210e
getinfo: improve perf in debug mode
Save some cpu cycles in debug mode for getinfo. Look up env vars for
overwriting variables only when variables are actually requested.

Closes #19525
2025-11-14 16:47:47 +01:00
Daniel Stenberg
9a633ec04f
connect: reshuffle Curl_timeleft_ms to avoid 'redundant condition'
Line 143: "if(duringconnect)" would always equal true. While this is
harmless, I believe this minor tweak makes the flow slightly more
obvious to the reader and avoids the redundant condition.

Pointed out by CodeSonar

Closes #19523
2025-11-14 15:12:58 +01:00
Viktor Szakats
ae7b4eeade
curl_setup.h: drop stray #undef stat (Windows)
Follow-up to 9678ff5b1b #18776

Closes #19519
2025-11-14 01:47:12 +01:00
Daniel Stenberg
0afb52a0cd
code: minor indent fixes before closing braces
Closes #19512
2025-11-13 17:27:40 +01:00
Daniel Stenberg
833c429627
wolfssl: simplify wssl_send_earlydata
Move out logic from a switch() expression and return error directly
instead of using goto. This also removes the odd-looking two subsequent
closing braces at the same indent level.

Closes #19509
2025-11-13 13:46:28 +01:00
Stefan Eissing
cb2bcb681f
lib: eliminate size_t casts
Add new functions in `curlx/warnless.h` for controlled type
conversions:

* curlx_uitouz, convert unsigned into to size_t (should always work)
* curlx_uztoso, convert size_t to curl_off_t, capping at CURL_OFF_T_MAX
* curlx_sztouz, convert ssize_t to size_t, return TRUE when ok
* curlx_sotouz_range, convert curl_off_t to size_t interval, capping
  values to interval bounds

Remove some unnecesary casts, convert some internal recv functions
to the "return result, have size_t* arg" pattern.

Closes #19495
2025-11-13 13:32:19 +01:00
Stefan Eissing
78a610cb83
lib: rename curlx_timediff to curlx_timeleft_ms
Rename `Curl_timeleft()` to `Curl_timeleft_ms()` to make the units in
the returned `timediff_t` clear. (We used to always have ms there, but
with QUIC started to sometimes calc ns as well).

Rename some assigned vars without `_ms` suffix for clarity as well.

Closes #19486
2025-11-13 13:12:58 +01:00
Daniel Stenberg
3f0629ca44
cookie: propagate errors better, cleanup the internal API
Overhaul of the internal cookie APIs and an attempt to better return
errors for OOM and similar critical problems, separate from ordinary and
benign parsing problems.

Closes #19493
2025-11-13 10:07:24 +01:00
Daniel Stenberg
296ffc45c3
schannel: replace atoi() with curlx_str_number()
The last atoi() call removed from libcurl

Closes #19483
2025-11-13 09:06:02 +01:00
Daniel Stenberg
a862920246
hostip: don't store negative lookup on OOM
When convert_ipaddr_direct() returns error due to OOM, it must not be
stored as a negative cache result.

Closes #19484
2025-11-12 12:19:12 +01:00
Daniel Stenberg
b2e0b4d008
libssh2: replace atoi() in ssh_force_knownhost_key_type
Closes #19479
2025-11-12 11:18:26 +01:00
Daniel Stenberg
7428060b0e
libssh2: cleanup ssh_force_knownhost_key_type
- Use arrays instead pointers
- Narrow variable scopes

Closes #19479
2025-11-12 11:18:18 +01:00
Daniel Stenberg
7aaf9a3152
http: replace atoi use in Curl_http_follow with curlx_str_number
In an attempt to weed out atoi() use all over.

Closes #19478
2025-11-12 10:44:49 +01:00
Daniel Stenberg
3b4bf3fcfa
telnet: replace atoi for BINARY handling with curlx_str_number
Also, only consider 0 to be a valid switch-off. Previously any value
except 1 had the same effect.

Closes #19477
2025-11-12 10:41:52 +01:00
Daniel Stenberg
97b0abb46b
noproxy: replace atoi with curlx_str_number
To better reject junk and detect overflows. There were already
additional precautions and protections in place, but this is cleaner.

Extended the 1614 unit tests with some more bad syntax cases.

Closes #19475
2025-11-12 10:30:59 +01:00
Viktor Szakats
4841e4290d
badwords: re-sync with curl-www, fix issues found
Also:
- replace `manpage` with `man page`, add to `badwords.txt`.
- badwords.pl: import `-w` feature from curl-www, syncing the two
  scripts fully.
- badwords.txt: import missing items from curl-www, syncing the two
  files fully.
- pyspelling.words: drop `cURL` allowed word.

Closes #19468
2025-11-12 00:53:44 +01:00
Daniel Stenberg
f1f5cc781c
cf-socket: split out the MTU and GRO setopts into sep functions
It simplifies the #ifdefs and declaring of local variables slightly.

Closes #19467
2025-11-11 17:57:40 +01:00
Daniel Stenberg
3d9f7b436c
noproxy: simplify Curl_check_noproxy
By creating two separate matching functions for name and IP.

Closes #19466
2025-11-11 16:43:41 +01:00
Daniel Stenberg
6ca1d05797
ftp: remove #ifdef for define that is always defined
The CURL_FTP_HTTPSTYLE_HEAD logic was added back in 2007 with the
intention to remove that logic one day, but since we never bump the
SONAME it is not likely to happen anytime soon. Remove again for
readability.

Follow-up to 3217809294

Closes #19463
2025-11-11 16:27:19 +01:00
Daniel Stenberg
5bd670c393
wolfssl: avoid NULL dereference in OOM situation
Verify that wolfSSL_BIO_meth_new() actually works and handle situations
where it returns NULL.

Reported-by: Stanislav Fort (Aisle Research)
Closes #19459
2025-11-11 16:23:27 +01:00
Daniel Stenberg
28380bb9fd
progress: show fewer digits
Without unit, show up to 99999 "raw" (5 digits). After that, prefer to
show the number as less than 1000 per unit and use single decimal
fraction. Like '123.4M' (spending 6 characters).

This now makes the largest possible size to show 8.0E (exabytes).

Probably makes the output easier to read.

Fixes #19431
Reported-by: Fd929c2CE5fA on github
Closes #19433
2025-11-11 16:22:34 +01:00
x2018
0dacc07969
cf-https-connect: allocate ctx at first in cf_hc_create()
Closes #19454
2025-11-11 16:18:55 +01:00
x2018
10b2dd8e6b
krb5_sspi: unify a part of error handling
Closes #19452
2025-11-11 16:17:53 +01:00
x2018
3f1a8dbb98
rustls: fix a potential memory issue
Closes #19425
2025-11-11 16:16:23 +01:00
Daniel Stenberg
c545e10fa7
sftp: fix range downloads in both SSH backends
When asking for the last N bytes of a file, and that size was larger
than the file size, it would miss the first byte due to a logic error.

The fixed range parser is now made a common function in the file now
renamed to vssh.c (from curl_path.c) - used by both backends.

Unit test 2605 verifies the parser.

Reported-by: Stanislav Fort (Aisle Research)
Closes #19460
2025-11-11 14:51:22 +01:00
Daniel Stenberg
7e87255020
socks_sspi: use free() not FreeContextBuffer()
The memory is allocated with malloc().

This reverts commit 1d01d4975f.

Reported-by: Stanislav Fort (Aisle Research)
Closes #19445
2025-11-10 13:39:22 +01:00
x2018
323b33d51f
digest_sspi: properly free sspi identity
Closes #19426
2025-11-10 09:20:26 +01:00
Daniel Stenberg
660f244640
urlapi: fix mem-leaks in curl_url_get error paths
Reported-by: Stanislav Fort (Aisle Research)
Closes #19440
2025-11-10 09:16:20 +01:00
x2018
baafa5ff76
schannel: fix potental memory leak of cert_store_path on four error paths
Closes #19423
2025-11-10 09:14:56 +01:00
x2018
87149c8383
mqtt: properly handle the message which exceeds maxsize
We should goto fail as topic is allocated.

Follow-up to 92fd791

Closes #19417
2025-11-10 09:07:27 +01:00
Stanislav Fort
b0aba1005b
cshutdn: acknowledge FD_SETSIZE for shutdown descriptors
In the logic called for curl_multi_fdset().

File descriptors larger than FD_SETSIZE size are simply ignored, which
of course will make things break but at least it does not trash memory.

Reported-by: Stanislav Fort (Aisle Research)
Closes #19439
2025-11-10 08:54:43 +01:00
Daniel Stenberg
00872d5c98
rtmp: fix double-free on URL parse errors
Reported-by: Stanislav Fort (Aisle Research)
Closes #19438
2025-11-10 08:53:30 +01:00
Daniel Stenberg
c791223743
setopt: disable CURLOPT_HAPROXY_CLIENT_IP on NULL
As documented.

Reported-by: Stanislav Fort (Aisle Research)
Closes #19434
2025-11-10 07:49:00 +01:00
Daniel Stenberg
92fd791f31
mqtt: reject overly big messages
Reported-by: Jiyong Yang
Closes #19415
2025-11-09 11:40:28 +01:00
x2018
a002c50510
ftp: refactor a piece of code by merging the repeated part
Closes #19411
2025-11-09 11:39:56 +01:00
x2018
1bddfe02d5
asyn-thrdd: release rrname if ares_init_options fails
Closes #19410
2025-11-09 11:35:04 +01:00
x2018
59584399a5
tftp: release filename if conn_get_remote_addr fails
Closes #19409
2025-11-09 11:32:57 +01:00
x2018
239c389836
openssl: release ssl_session if sess_reuse_cb fails
Closes #19405
2025-11-09 11:31:20 +01:00
Stefan Eissing
f55974c139
vtls: fix CURLOPT_CAPATH use
A regression in curl 8.17.0 led to a customer CAPATH set by the
application (or the curl command) to be ignored unless licurl was built
with a default CAPATH.

Add test cases using `--capath` on the custom pytest CA, generated with
the help of the openssl command when available.

Fixes #19401
Reported-by: Brad King
Closes #19308
2025-11-08 17:02:54 +01:00
x2018
9c0ccd2739
vtls: handle possible malicious certs_num from peer
For GnuTLS, mbedTLS, Rustls, Schannel and wolfSSL

This check was previously added for OpenSSL in 3df71e6dc2

Closes #19397
2025-11-08 10:33:06 +01:00
x2018
a6fcaf2958
rtmp: precaution for a potential integer truncation
On some platforms, socket descriptors may use types larger than int.
When these values exceed INT_MAX, conversion to int can truncate to
negative values causing RTMP connection failures, and even accidentally
affect other socket when high-value descriptors map to existing
lower-value sockets after integer conversion. This check ensures socket
values are within the safe range before passing them to the RTMP
library.

Closes #19399
2025-11-08 10:28:43 +01:00
Andrew
2d99cf0761
lib: fix gssapi.h include on IBMi
Fixes #19336
Closes #19337
2025-11-08 10:25:12 +01:00
Daniel Stenberg
9d1acd048c
gtls: skip session resumption when verifystatus is set
Resumed TLS sessions skip OCSP stapled-response verification. Force a
full handshake so verifystatus() runs.

Follow-up to 4bfd7a9615

Pointed out by ZeroPath
2025-11-07 14:14:54 +01:00
x2018
608d96694b
lib: refactor the type of funcs which have useless return and checks
Some internal functions always return CURLE_OK.

- Curl_http_proxy_get_destination() does that from bb4032a, (2 years
  ago) And the original inline code does not need to check the status.

- Curl_wildcard_init() does that from e60fe20. (8 years ago)

- Curl_initinfo() does that from a very beginning.

- Curl_pgrsSetDownloadCounter() did not have a return before 914e49b,
  ad051e1 recovered its content (2 years ago) but did not completely
  recovered the changes related to it.

- auth_digest_get_qop_values() does that from 676de7f.

This directly changes their type to void and cleaned the remaining
checks for their return value.

Closes #19386
2025-11-07 13:01:39 +01:00
Stefan Eissing
2684af257e
osslq: code readability
- remove assertions that are unnecessary
- lookup stream after assertions

Closes #19394
2025-11-07 12:58:26 +01:00