Commit Graph

5157 Commits

Author SHA1 Message Date
Patrick Monnerat
2437fac013
lib: sanitize conditional exclusion around MIME
The introduction of CURL_DISABLE_MIME came with some additional bugs:
- Disabled MIME is compiled-in anyway if SMTP and/or IMAP is enabled.
- CURLOPT_MIMEPOST, CURLOPT_MIME_OPTIONS and CURLOPT_HTTPHEADER are
  conditioned on HTTP, although also needed for SMTP and IMAP MIME mail
  uploads.

In addition, the CURLOPT_HTTPHEADER and --header documentation does not
mention their use for MIME mail.

This commit fixes the problems above.

Closes #9610
2022-09-29 10:51:04 +02:00
Dan Fandrich
2e9de98dd5 tests: Remove a duplicated keyword 2022-09-28 13:24:26 -07:00
Dan Fandrich
98aa994868 docs: document more server names for test files 2022-09-28 13:24:26 -07:00
Daniel Stenberg
ac612dfeee
altsvc: reject bad port numbers
The existing code tried but did not properly reject alternative services
using negative or too large port numbers.

With this fix, the logic now also flushes the old entries immediately
before adding a new one, making a following header with an illegal entry
not flush the already stored entry.

Report from the ongoing source code audit by Trail of Bits.

Adjusted test 356 to verify.

Closes #9607
2022-09-28 12:44:37 +02:00
Daniel Stenberg
eb0167ff7d
urlapi: reject more bad characters from the host name field
Extended test 1560 to verify

Report from the ongoing source code audit by Trail of Bits.

Closes #9608
2022-09-28 08:22:42 +02:00
Patrick Monnerat
d08c01e50f
tests: skip mime/form tests when mime is not built-in
Closes #9596
2022-09-27 09:41:05 +02:00
Daniel Stenberg
1a87a1efba
url: a zero-length userinfo part in the URL is still a (blank) user
Adjusted test 1560 to verify

Reported-by: Jay Satiro

Fixes #9088
Closes #9590
2022-09-26 07:45:53 +02:00
Patrick Monnerat
549032df41
lib517: fix C89 constant signedness
In C89, positive integer literals that overflow an int but not an
unsigned int may be understood as a negative int.

lib517.c:129:3: warning: this decimal constant is unsigned only in ISO C90
   {"Sun, 06 Nov 2044 08:49:37 GMT", 2362034977 },
   ^

Closes #9572
2022-09-22 23:08:08 +02:00
Daniel Stenberg
a34610b92e
manpage-syntax.pl: all libcurl option symbols should be \fI-tagged
... as that makes them links to their corresponding man page.

This script is used for test 1173.

Closes #9574
2022-09-22 17:35:08 +02:00
Patrick Monnerat
677266c769
tool: remove protocol count limitation
Replace bit mask protocol sets by null-terminated arrays of protocol
tokens. These are the addresses of the protocol names returned by
curl_version_info().

Protocol names are sorted case-insensitively before output to satisfy CI
tests matches consistency.

The protocol list returned by curl_version_info() is augmented with all
RTMP protocol variants.

Test 1401 adjusted for new alpha ordered output.

Closes #9546
2022-09-22 13:49:10 +02:00
Daniel Stenberg
fb11e45f9c
test972: verify the output without using external tool
It seems too restrictive to assume and use an external tool to verify
the JSON. This now verifies the outut byte per byte. We could consider
building a local "JSON verifyer" in a future.

Remove 'jsonlint' from the CI job.

Reported-by: Marcel Raad
Fixes #9563
Closes #9564
2022-09-22 13:46:40 +02:00
Daniel Stenberg
34c598a9b3
symbol-scan.pl: scan and verify .3 man pages
This script now also finds all .3 man pages in docs/include and
docs/include/opts, extracts all uses of CURL* symbols and verifies that all
symbols mentioned in docs are defined in public headers.

A "global symbol" is one of those matching a known prefix and the script makes
an attempt to check all/most of them. Just using *all* symbols that match
CURL* proved matching a little too many other references as well and turned
difficult turning into something useful.

Closes #9544
2022-09-22 09:43:34 +02:00
Daniel Stenberg
c3feb8e165
symbol-scan.pl: also check for LIBCURL* symbols
Closes #9544
2022-09-22 09:43:30 +02:00
Daniel Stenberg
6c951c427f
test1119: scan all public headers
Previously this test only scanned a subset of the headers, which made us
accidentally miss symbols that were provided in the others. Now, the script
iterates over all headers present in include/curl.

Closes #9544
2022-09-22 09:43:13 +02:00
Daniel Stenberg
fd1ce3d4b0
docs: spellfixes
Pointed by the new CI job
2022-09-21 15:20:08 +02:00
Patrick Monnerat
6fbf7d34b5
unit test 1655: make it C89-compliant
Initializations performed in unit test 1655 use automatic variables in
aggregates and thus can only be computed at run-time. Using gcc in C89
dialect mode produces warning messages like:

unit1655.c:96:7: warning: initializer element is not computable at load time [-Wpedantic]
   96 |     { toolong, DOH_DNS_NAME_TOO_LONG },  /* expect early failure */
      |       ^~~~~~~

Fix the problem by converting these automatic pointer variables to
static arrays.

Closes #9551
2022-09-21 09:14:34 +02:00
Daniel Stenberg
fda897f5a1
docs: fix proselint complaints 2022-09-19 17:32:12 +02:00
Daniel Stenberg
307b7543ea
misc: null-terminate
Make use of this term consistently.

Closes #9527
2022-09-17 23:19:29 +02:00
Patrick Monnerat
7ca36f4956
lib1597: make it C89-compliant again
Automatic variable addresses cannot be used in an initialisation
aggregate.

Follow-up to 9d51329

Reported-by: Daniel Stenberg
Fixes: #9524
Closes #9525
2022-09-17 17:26:43 +02:00
Patrick Monnerat
9d51329047
setopt: use the handler table for protocol name to number conversions
This also returns error CURLE_UNSUPPORTED_PROTOCOL rather than
CURLE_BAD_FUNCTION_ARGUMENT when a listed protocol name is not found.

A new schemelen parameter is added to Curl_builtin_scheme() to support
this extended use.

Note that disabled protocols are not recognized anymore.

Tests adapted accordingly.

Closes #9472
2022-09-16 23:29:01 +02:00
Daniel Stenberg
1edb15925e
test1948: verify PUT + POST reusing the same handle
Reproduced #9507, verifies the fix
2022-09-15 23:44:15 +02:00
Daniel Stenberg
c4768f168c
lib1560: extended to verify detect/reject of unknown schemes
... when no guessing is allowed.
2022-09-15 09:31:45 +02:00
Daniel Stenberg
7f5fe74323
strerror: improve two URL API error messages 2022-09-15 09:31:29 +02:00
Marcel Raad
d7dceb57d1
lib and tests: add missing curl.h includes
Closes https://github.com/curl/curl/pull/9453
2022-09-12 09:41:47 +02:00
Daniel Stenberg
5d254bbced
tool_setopt: use better English in --libcurl source comments
Like this:

  XYZ was set to an object pointer
  ABC was set to a function pointer

Closes #9475
2022-09-12 08:38:14 +02:00
Daniel Stenberg
22e34da091
tests/libtest/Makefile.inc: fixup merge conflict mistake 2022-09-09 15:13:15 +02:00
Daniel Stenberg
0aaebf62ec
tests: add websockets tests
- add websockets support to sws
 - 2300: first very basic websockets test
 - 2301: first libcurl test for ws (not working yet)
 - 2302: use the ws callback
 - 2303: test refused upgrade
2022-09-09 15:11:14 +02:00
Daniel Stenberg
ef80a87f40
libtest/lib1560: test basic websocket URL parsing 2022-09-09 15:11:14 +02:00
Daniel Stenberg
d96ccab4d6
test415: verify Content-Length parser with control code + negative value 2022-09-09 15:02:23 +02:00
Daniel Stenberg
9c9e83931e
headers: reset the requests counter at transfer start
If not, reusing an easy handle to do a subsequent transfer would
continue the counter from the previous invoke, which then would make use
of the header API difficult/impossible as the request counter
mismatched.

Add libtest 1947 to verify.

Reported-by: Andrew Lambert
Fixes #9424
Closes #9447
2022-09-09 14:46:06 +02:00
Michael Heimpold
d668685657
ftp: ignore a 550 response to MDTM
The 550 is overused as a return code for multiple error case, e.g.
file not found and/or insufficient permissions to access the file.

So we cannot fail hard in this case.

Adjust test 511 since we now fail later.
Add new test 3027 which check that when MDTM failed, but the file could
actually be retrieved, that in this case no filetime is provided.

Reported-by: Michael Heimpold
Fixes #9357
Closes #9387
2022-09-07 10:26:55 +02:00
Daniel Stenberg
f703cf971c
urlapi: leaner with fewer allocs
Slightly faster with more robust code. Uses fewer and smaller mallocs.

- remove two fields from the URL handle struct
- reduce copies and allocs
- use dynbuf buffers more instead of custom malloc + copies
- uses dynbuf to build the host name in reduces serial alloc+free within
  the same function.
- move dedotdotify into urlapi.c and make it static, not strdup the input
  and optimize it by checking for . and / before using strncmp
- remove a few strlen() calls
- add Curl_dyn_setlen() that can "trim" an existing dynbuf

Closes #9408
2022-09-07 10:21:45 +02:00
Dan Fandrich
2a0a62a5d1 tests: fix tag syntax errors in test files 2022-09-06 11:31:07 -07:00
Daniel Stenberg
f65f750742
curl_ctype: convert to macros-only
This no longer provide functions, only macros. Runs faster and produces
smaller output.

The biggest precaution this change brings:

DO NOT use post/pre-increments when passing arguments to the macros.

Closes #9429
2022-09-06 08:36:33 +02:00
Daniel Stenberg
8dd95da35b
ctype: remove all use of <ctype.h>, use our own versions
Except in the test servers.

Closes #9433
2022-09-06 08:32:36 +02:00
Daniel Stenberg
9178208a8e
tests/certs/scripts: insert standard curl source headers
... including the SPDX-License-Identifier.

These omissions were not detected by the RUEUSE CI job nor the copyright.pl
scanners because we have a general wildcard in .reuse/dep5 for
"tests/certs/*".

Reported-by: Samuel Henrique
Fixes #9417
Closes #9420
2022-09-04 15:55:19 +02:00
Samuel Henrique
464ff5a610
manpages: Fix spelling of "allows to" -> "allows one to"
References:
 https://salsa.debian.org/lintian/lintian/-/blob/master/tags/t/typo-in-manual-page.tag
 https://english.stackexchange.com/questions/60271/grammatical-complements-for-allow/60285#60285

Closes #9419
2022-09-02 14:45:01 +02:00
Viktor Szakats
c9061f242b
misc: spelling fixes
Found using codespell 2.2.1.

Also delete the redundant protocol designator from an archive.org URL.

Reviewed-by: Daniel Stenberg
Closes #9403
2022-08-31 14:31:01 +00:00
Daniel Stenberg
592290ed75
lib530: simplify realloc failure exit path
To make code analyzers happier

Closes #9392
2022-08-30 15:38:20 +02:00
Orgad Shaneh
56f1bbdd0c
tests: add tests for netrc login/password combinations
Covers the following PRs:

- #9066
- #9247
- #9248

Closes #9256
2022-08-29 17:26:21 +02:00
Daniel Stenberg
2fc031d834
test8: verify that "ctrl-byte cookies" are ignored 2022-08-29 11:20:53 +02:00
Daniel Stenberg
7632c0d25a
multi: use larger dns hash table for multi interface
Have curl_multi_init() use a much larger DNS hash table than used for
the easy interface to scale and perform better when used with _many_
host names.

curl_share_init() sets an in-between size.

Inspired-by: Ivan Tsybulin
See #9340
Closes #9376
2022-08-29 00:07:09 +02:00
Marc Hoersken
c5c6e86783
CI/runtests.pl: add param for dedicated curl to talk to APIs
This should make it possible to also report test failures
if our freshly build curl binary is not fully functional.

Reviewed-by: Daniel Stenberg
Closes #9360
2022-08-28 19:18:22 +02:00
Jay Satiro
ef121401d6 tests: fix http2 tests to use CRLF headers
Prior to this change some tests that rely on nghttpx proxy did not use
CRLF headers everywhere. A recent change in nghttp2, which updated its
version of llhttp (HTTP parser), requires curl's HTTP/1.1 test server to
use CRLF headers.

Ref: https://github.com/nghttp2/nghttp2/commit/9d389e8

Fixes https://github.com/curl/curl/issues/9364
Closes https://github.com/curl/curl/pull/9365
2022-08-25 12:05:30 -04:00
Daniel Stenberg
3f98eaafa0
unit1303: four tests should have TRUE for 'connecting'
To match the comments.

Reported-by: Wu Zheng

See #9355
Closes #9356
2022-08-23 17:39:37 +02:00
Marc Hoersken
91948a9eaf
tests/server/sockfilt.c: avoid race condition without a mutex
Avoid loosing any triggered handles by first aborting and joining
the waiting threads before evaluating the individual signal state.

This removes the race condition and therefore need for a mutex.

Closes #9023
2022-08-23 12:17:20 +02:00
Daniel Stenberg
d162fca69a
tests/data/CMakeLists: remove making the 'show' makefile target
It is not used by runtests since 3c0f462

Closes #9333
2022-08-18 11:40:12 +02:00
Daniel Stenberg
aedd0a7c9b
tests/data/Makefile: remove 'filecheck' target
No practical use anymore since 3c0f4622cd

Closes #9332
2022-08-18 11:39:12 +02:00
Daniel Stenberg
04427fc207
test399: switch it to use a config file instead
... as using a 65535 bytes host name in a URL does not fit on the
command line on some systems - like Windows.

Reported-by: Marcel Raad
Fixes #9321
Closes #9322
2022-08-16 16:35:47 +02:00
Daniel Stenberg
88f1f11e01
test399: verify check of too long host name 2022-08-15 10:57:16 +02:00