Commit Graph

29336 Commits

Author SHA1 Message Date
Daniel Stenberg
bdaa6dd5ba
libssh: if sftp_init fails, don't get the sftp error code
This flow extracted the wrong code (sftp code instead of ssh code), and
the code is sometimes (erroneously) returned as zero anyway, so skip
getting it and set a generic error.

Reported-by: David McLaughlin
Fixes #9737
Closes #9740
2022-10-16 23:48:50 +02:00
Daniel Stenberg
9660f23010
mqtt: return error for too long topic
Closes #9744
2022-10-16 23:47:31 +02:00
Rickard Hallerbäck
703efb3379
tool_paramhlp: make the max argument a 'double'
To fix compiler warnings "Implicit conversion from 'long' to 'double'
may lose precision"

Closes #9700
2022-10-16 00:46:52 +02:00
Philip H
1de60b18de
cirrus-ci: add more macOS builds with m1 based on x86_64 builds
Also refactor macOS builds to use task matrix.

Assisted-by: Marc Hörsken
Closes #9565
2022-10-15 21:40:19 +02:00
Viktor Szakats
86f2d8f67f
cmake: set HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID on Windows
`lib/config-win32.h` enables this configuration option unconditionally.
Make it apply to CMake builds as well.

While here, delete a broken check for
`HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID` from `CMakeLists.txt`. This came with
the initial commit [1], but did not include the actual verification code
inside `CMake/CurlTests.c`, so it always failed. A later commit [2]
added a second test, for non-Windows platforms.

Enabling this flag causes test 1056 to fail with CMake builds, as they
do with autotools builds. Let's apply the same solution and ignore the
results here as well.

[1] 4c5307b456
[2] aec7c5a87c

Reviewed-by: Daniel Stenberg
Assisted-by: Marcel Raad

Closes #9726
2022-10-14 19:07:16 +00:00
Viktor Szakats
67d88626d4
cmake: set HAVE_GETADDRINFO_THREADSAFE on Windows
autotools enables this configuration option unconditionally for Windows
[^1]. Do the same in CMake.

The above will make this work for all reasonably recent environments.
The logic present in `lib/config-win32.h` [^2] has the following
exceptions which we did not cover in this CMake update:

- Builds targeting Windows 2000 and earlier
- MS Visual C++ 5.0 (1997) and earlier

Also make sure to disable this feature when `HAVE_GETADDRINFO` isn't
set, to avoid a broken build. We might want to handle that in the C
sources in a future commit.

[^1]: 68fa9bf3f5/m4/curl-functions.m4 (L2067-L2070)

[^2]: 68fa9bf3f5/lib/config-win32.h (L511-L528)

Closes #9727
2022-10-14 18:19:09 +00:00
Viktor Szakats
790779fc34
cmake: sync HAVE_SIGNAL detection with autotools
`HAVE_SIGNAL` means the availability of the `signal()` function in
autotools, while in CMake it meant the availability of that function
_and_ the symbol `SIGALRM`.

The latter is not available on Windows, but the function is, which means
on Windows, autotools did define `HAVE_SIGNAL`, but CMake did not,
introducing a slight difference into the binaries.

This patch syncs CMake behaviour with autotools to look for the function
only.

The logic came with the initial commit adding CMake support to curl, so
the commit history doesn't reveal the reason behind it. In any case,
it's best to check the existence of `SIGALRM` directly in the source
before use. For now, curl builds fine with `HAVE_SIGNAL` enabled and
`SIGALRM` missing.

Follow-up to 68fa9bf3f5

Closes #9725
2022-10-14 18:06:30 +00:00
Viktor Szakats
1d64a2bf5b
cmake: delete duplicate HAVE_GETADDRINFO test
A custom `HAVE_GETADDRINFO` check came with the initial CMake commit
[1]. A later commit [2] added a standard check for it as well. The
standard check run before the custom one, so CMake ignored the latter.

The custom check was also non-portable, so this patch deletes it in
favor of the standard check.

[1] 4c5307b456
[2] aec7c5a87c

Closes #9731
2022-10-14 17:31:19 +00:00
Daniel Stenberg
8c452b4003
tool_formparse: unroll the NULL_CHECK and CONST_FREE macros
To make the code read more obvious

Assisted-by: Jay Satiro

Closes #9710
2022-10-14 11:50:28 +02:00
Christopher Sauer
d91f01f231
docs/INSTALL: update Android Instructions for newer NDKs
Closes #9732
2022-10-14 10:48:14 +02:00
Daniel Stenberg
05f477ad4b
markdown-uppercase: ignore quoted sections
Sections within the markdown ~~~ or ``` are now ignored.

Closes #9733
2022-10-14 10:47:14 +02:00
Daniel Stenberg
a0d776f332
RELEASE-NOTES: synced 2022-10-14 08:32:38 +02:00
Daniel Stenberg
3068cc764d
test8: update as cookies no longer can have "embedded" TABs in content 2022-10-14 08:23:39 +02:00
Daniel Stenberg
bfadd20f90
test1105: extend to verify TAB in name/content discarding cookies 2022-10-14 08:23:39 +02:00
Daniel Stenberg
bfe9b59be4
cookie: reject cookie names or content with TAB characters
TABs in name and content seem allowed by RFC 6265: "the algorithm strips
leading and trailing whitespace from the cookie name and value (but
maintains internal whitespace)"

Cookies with TABs in the names are rejected by Firefox and Chrome.

TABs in content are stripped out by Firefox, while Chrome discards the
whole cookie.

TABs in cookies also cause issues in saved netscape cookie files.

Reported-by: Trail of Bits

URL: https://curl.se/mail/lib-2022-10/0032.html
URL: https://github.com/httpwg/http-extensions/issues/2262

Closes #9659
2022-10-14 08:22:10 +02:00
Daniel Stenberg
f67f60c14b
curl/add_parallel_transfers: better error handling
1 - consider the transfer handled at once when in the function, to avoid
    the same list entry to get added more than once in rare error
    situations

2 - set the ERRORBUFFER for the handle first after it has been added
    successfully

Reported-by: Trail of Bits

Closes #9729
2022-10-14 08:15:55 +02:00
Daniel Stenberg
57e2bb52aa
netrc: remove the two 'changed' arguments
As no user of these functions used the returned content.
2022-10-13 23:42:07 +02:00
Daniel Stenberg
c4715b1c92
test495: verify URL encoded user name + netrc-optional
Reproduced issue #9709
2022-10-13 23:42:07 +02:00
Daniel Stenberg
a2aa980886
netrc: use the URL-decoded user
When the user name is provided in the URL it is URL encoded there, but
when used for authentication the encoded version should be used.

Regression introduced after 7.83.0

Reported-by: Jonas Haag
Fixes #9709
Closes #9715
2022-10-13 23:42:07 +02:00
Shaun Mirani
6efb6b1e77
url: allow non-HTTPS HSTS-matching for debug builds
Closes #9728
2022-10-13 23:28:43 +02:00
Daniel Stenberg
502b6a5a32
test1275: remove the check of stderr
To avoid the mysterious test failures on Windows, instead rely on the
error code returned on failure.

Fixes #9716
Closes #9723
2022-10-13 23:21:08 +02:00
Viktor Szakats
68fa9bf3f5
lib: set more flags in config-win32.h
The goal is to add any flag that affect the created binary, to get in
sync with the ones built with CMake and autotools.

I took these flags from curl-for-win [0], where they've been tested with
mingw-w64 and proven to work well.

This patch brings them to curl as follows:

- Enable unconditionally those force-enabled via
  `CMake/WindowsCache.cmake`:

  - `HAVE_SETJMP_H`
  - `HAVE_STRING_H`
  - `HAVE_SIGNAL` (CMake equivalent is `HAVE_SIGNAL_FUNC`)

- Expand existing guards with mingw-w64:

  - `HAVE_STDBOOL_H`
  - `HAVE_BOOL_T`

- Enable Win32 API functions for Windows Vista and later:

  - `HAVE_INET_NTOP`
  - `HAVE_INET_PTON`

- Set sizes, if not already set:

  - `SIZEOF_OFF_T = 8`
  - `_FILE_OFFSET_BITS = 64` when `USE_WIN32_LARGE_FILES` is set,
    and using mingw-w64.

- Add the remaining for mingw-w64 only. Feel free to expand as desired:

  - `HAVE_LIBGEN_H`
  - `HAVE_FTRUNCATE`
  - `HAVE_BASENAME`
  - `HAVE_STRTOK_R`

Future TODO:

- `HAVE_SIGNAL` has a different meaning in CMake. It's enabled when both
  the `signal()` function and the `SIGALRM` macro are found. In
  autotools and this header, it means the function only. For the
  function alone, CMake uses `HAVE_SIGNAL_FUNC`.

[0] c9b9a5f273/curl-m32.sh (L53-L58)

Reviewed-by: Daniel Stenberg

Closes #9712
2022-10-13 15:43:31 +00:00
Daniel Stenberg
1d2e6f9284
tests: add tests/markdown-uppercase.pl to dist tarball
Follow-up to aafb06c592

Closes #9722
2022-10-13 17:35:14 +02:00
Daniel Stenberg
eef7ad1573
tool_paramhelp: asserts verify maximum sizes for string loading
The two defines MAX_FILE2MEMORY and MAX_FILE2STRING define the largest
strings accepted when loading files into memory, but as the size is
later used as input to functions that take the size as 'int' as
argument, the sizes must not be larger than INT_MAX.

These two new assert()s make the code error out if someone would bump
the sizes without this consideration.

Reported-by Trail of Bits

Closes #9719
2022-10-13 17:31:51 +02:00
Daniel Stenberg
b46136f9b1
http: try parsing Retry-After: as a number first
Since the date parser allows YYYYMMDD as a date format (due to it being
a bit too generic for parsing this particular header), a large integer
number could wrongly match that pattern and cause the parser to generate
a wrong value.

No date format accepted for this header starts with a decimal number, so
by reversing the check and trying a number first we can deduct that if
that works, it was not a date.

Reported-by Trail of Bits

Closes #9718
2022-10-13 17:27:08 +02:00
Patrick Monnerat
b0e4ebe960
doc: fix deprecation versions inconsistencies
Ref: https://curl.se/mail/lib-2022-10/0026.html

Closes #9711
2022-10-13 13:59:56 +02:00
Daniel Stenberg
57ba1dd519
http_aws_sigv4: fix strlen() check
The check was off-by-one leading to buffer overflow.

Follow-up to 29c4aa00a1

Detected by OSS-Fuzz

Closes #9714
2022-10-13 09:04:54 +02:00
Daniel Stenberg
0bb2f64905
curl/main_checkfds: check the fcntl return code better
fcntl() can (in theory) return a non-zero number for success, so a
better test for error is checking for -1 explicitly.

Follow-up to 41e1b30ea1

Mentioned-by: Dominik Klemba

Closes #9708
2022-10-12 23:51:15 +02:00
Viktor Szakats
0df0aa74be
tidy-up: delete unused HAVE_STRUCT_POLLFD
It was only defined in `lib/config-win32.h`, when building for Vista.

It was only used in `select.h`, in a condition that also included a
check for `POLLIN` which is a superior choice for this detection and
which was already used by cmake and autotools builds.

Delete both instances of this macro.

Closes #9707
2022-10-12 14:19:09 +00:00
Daniel Stenberg
aafb06c592
test1275: verify upercase after period in markdown
Script based on the #9474 pull-request logic, but implemented in perl.

Updated docs/URL-SYNTAX.md accordingly.

Suggested-by: Dan Fandrich

Closes #9697
2022-10-12 14:19:50 +02:00
12932
ddeec8feba
misc: nitpick grammar in comments/docs
because the 'u' in URL is actually a consonant *sound* it is only
correct to write "a URL"

sorry this is a bit nitpicky :P

https://english.stackexchange.com/questions/152/when-should-i-use-a-vs-an
https://www.techtarget.com/whatis/feature/Which-is-correct-a-URL-or-an-URL

Closes #9699
2022-10-12 11:32:43 +02:00
Viktor Szakats
aa970c4c08
Makefile.m32: drop CROSSPREFIX and our CC/AR defaults [ci skip]
This patch aimed to fix a regression [0], where `CC` initialization
moved beyond its first use. But, on closer inspection it turned out that
the `CC` initialization does not work as expected due to GNU Make
filling it with `cc` by default. So unless implicit values were
explicitly disabled via a GNU Make option, the default value of
`$CROSSPREFIX` + `gcc` was never used. At the same time the implicit
value `cc` maps to `gcc` in (most/all?) MinGW envs.

`AR` has the same issue, with a default value of `ar`.

We could reintroduce a separate variable to fix this without ill
effects, but for simplicity and flexibility, it seems better to drop
support for `CROSSPREFIX`, along with our own `CC`/`AR` init logic, and
require the caller to initialize `CC`, `AR` and `RC` to the full
(prefixed if necessary) names of these tools, as desired.

We keep `RC ?= windres` because `RC` is empty by default.

Also fix grammar in a comment.

[0] 10fbd8b4e3

Closes #9698
2022-10-11 21:16:00 +00:00
Viktor Szakats
28edcbe195
smb: replace CURL_WIN32 with WIN32
PR #9255 aimed to fix a Cygwin/MSYS issue (#8220). It used the
`CURL_WIN32` macro, but that one is not defined here, while compiling
curl itself. This patch changes this to `WIN32`, assuming this was the
original intent.

Regression from 1c52e8a379

Reviewed-by: Marcel Raad

Closes #9701
2022-10-11 21:05:44 +00:00
Matthias Gatto
29c4aa00a1
aws_sigv4: fix header computation
Handle canonical headers and signed headers creation as explained here:
https://docs.aws.amazon.com/general/latest/gr/sigv4-create-canonical-request.html

The algo tells that signed and canonical must contain at last host and
x-amz-date.

So we check whatever thoses are present in the curl http headers list.
If they are, we use the one enter by curl user, otherwise we generate
them.  then we to lower, and remove space from each http headers plus
host and x-amz-date, then sort them all by alphabetical order.

This patch also fix a bug with host header, which was ignoring the port.

Closes #7966
2022-10-11 14:33:46 +02:00
Aftab Alam
3c0050d13e README.md: link the curl logo to the website
- Link the curl:// image to https://curl.se/

Closes https://github.com/curl/curl/pull/9675
2022-10-11 04:04:55 -04:00
Dustin Howett
1027d52e7d schannel: when importing PFX, disable key persistence
By default, the PFXImportCertStore API persists the key in the user's
key store (as though the certificate was being imported for permanent,
ongoing use.)

The documentation specifies that keys that are not to be persisted
should be imported with the flag PKCS12_NO_PERSIST_KEY.
NOTE: this flag is only supported on versions of Windows newer than XP
and Server 2003.

--

This is take 2 of the original fix. It extends the lifetime of the
client certificate store to that of the credential handle. The original
fix which landed in 70d010d and was later reverted in aec8d30 failed to
work properly because it did not do that.

Minor changes were made to the schannel credential context to support
closing the client certificate store handle at the end of an SSL session.

--

Reported-by: ShadowZzj@users.noreply.github.com

Fixes https://github.com/curl/curl/issues/9300
Supersedes https://github.com/curl/curl/pull/9363
Closes https://github.com/curl/curl/pull/9460
2022-10-11 04:04:54 -04:00
Viktor Szakats
66e68ca47f
Makefile.m32: support more options [ci skip]
- Add support for these options:
  `-wolfssl`, `-wolfssh`, `-mbedtls`, `-libssh`, `-psl`

  Caveats:
  - `-wolfssh` requires `-wolfssl`.
  - `-wolfssl` cannot be used with OpenSSL backends in parallel.
  - `-libssh` has build issues with BoringSSL and LibreSSL, and also
     what looks like a world-writable-config vulnerability on Windows.
     Consider it experimental.
  - `-psl` requires `-idn2` and extra libs passed via
    `LIBS=-liconv -lunistring`.

- Detect BoringSSL/wolfSSL and set ngtcp2 crypto lib accordingly.
- Generalize MultiSSL detection.
- Use else-if syntax. Requires GNU Make 3.81 (2006-04-01).
- Document more customization options.

This brings over some configuration logic from `curl-for-win`.

Closes #9680
2022-10-11 07:56:01 +00:00
Viktor Szakats
474a947e66
cmake: enable more detection on Windows
Enable `HAVE_UNISTD_H`, `HAVE_STRTOK_R` and `HAVE_STRCASECMP` detection
on Windows, instead of having predefined values.

With these features detected correctly, CMake Windows builds get closer
to the autotools and `config-win32.h` ones.

This also fixes detecting `HAVE_FTRUNCATE` correctly, which required
`unistd.h`.

Fixing `ftruncate()` in turn causes a build warning/error with legacy
MinGW/MSYS1 due to an offset type size mismatch. This env misses to
detect `HAVE_FILE_OFFSET_BITS`, which may be a reason. This patch
force-disables `HAVE_FTRUNCATE` for this platform.

Reviewed-by: Daniel Stenberg

Closes #9687
2022-10-11 07:52:32 +00:00
Viktor Szakats
23029838e2
autotools: allow unix sockets on Windows
Fixes: 73a070d96f/curl-autotools.sh (L44-L47)

On Windows this feature is present, but not the header used in the
detection logic. It also requires an elaborate enabler logic
(as seen in `lib/curl_setup.h`). Let's always allow it and let the
lib code deal with the details.

Closes #9688
2022-10-11 07:51:59 +00:00
Viktor Szakats
3b4837459b
cmake: add missing inet_ntop check
This adds the missing half of the check, next to the other half
already present in `lib/curl_config.h.cmake`.

Force disable `HAVE_INET_NTOP` for old MSVC where it caused compiler
warnings.

Reviewed-by: Daniel Stenberg

Closes #9689
2022-10-11 07:42:16 +00:00
Daniel Stenberg
23151d667f
RELEASE-NOTES: synced 2022-10-11 08:29:06 +02:00
bsergean
e71a9b488f
asyn-ares: set hint flags when calling ares_getaddrinfo
The hint flag is ARES_AI_NUMERICSERV, and it will save a call to
getservbyname or getservbyname_r to set it.

Closes #9694
2022-10-11 08:23:33 +02:00
Daniel Stenberg
66313cf4b3
header.d: add category smtp and imap
They were previously (erroneously) added manually to tool_listhelp.c
which would make them get removed again when the file is updated next
time, unless added correctly here in header.d

Follow-up to 2437fac01

Closes #9690
2022-10-11 08:13:27 +02:00
Daniel Stenberg
671adfa493
curl/get_url_file_name: use libcurl URL parser
To avoid URL tricks, use the URL parser for this.

This update changes curl's behavior slightly in that it will ignore the
possible query part from the URL and only use the file name from the
actual path from the URL. I consider it a bugfix.

"curl -O localhost/name?giveme-giveme" will now save the output in the
local file named 'name'

Updated test 1210 to verify

Assisted-by: Jay Satiro

Closes #9684
2022-10-11 08:09:47 +02:00
Martin Ågren
c96462addc
docs: fix grammar around needing pass phrase
"You never needed a pass phrase" reads like it's about to be followed by
something like "until version so-and-so", but that is not what is
intended. Change to "You never need a pass phrase". There are two
instances of this text, so make sure to update both.
2022-10-11 08:05:26 +02:00
Xiang Xiao
d91c736f6c
cmake: add the check of HAVE_SOCKETPAIR
which is used by Curl_socketpair

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

Closes #9686
2022-10-10 23:23:22 +02:00
Daniel Stenberg
d24a2ffefe
curl/add_file_name_to_url: use the libcurl URL parser
instead of the custom error-prone parser, to extract and update the path
of the given URL

Closes #9683
2022-10-10 22:39:41 +02:00
Daniel Stenberg
b82eb72d80
single_transfer: use the libcurl URL parser when appending query parts
Instead of doing "manual" error-prone parsing in another place.

Used when --data contents is added to the URL query when -G is provided.

Closes #9681
2022-10-10 15:46:05 +02:00
Daniel Stenberg
0554de58c6
ws: fix buffer pointer use in the callback loop
Closes #9678
2022-10-10 11:21:56 +02:00
Petr Štetiar
8af6b087e0
curl-wolfssl.m4: error out if wolfSSL is not usable
When I explicitly declare, that I would like to have curl built with
wolfSSL support using `--with-wolfssl` configure option, then I would
expect, that either I endup with curl having that support, for example
in form of https support or it wouldn't be available at all.

Downstream projects like for example OpenWrt build curl wolfSSL variant
with `--with-wolfssl` already, but in certain corner cases it does fail:

  configure:25299: checking for wolfSSL_Init in -lwolfssl
  configure:25321: x86_64-openwrt-linux-musl-gcc -o conftest [snip]
  In file included from target-x86_64_musl/usr/include/wolfssl/wolfcrypt/dsa.h:33,
                   from target-x86_64_musl/usr/include/wolfssl/wolfcrypt/asn_public.h:35,
                  from target-x86_64_musl/usr/include/wolfssl/ssl.h:35,
                   from conftest.c:47:
  target-x86_64_musl/usr/include/wolfssl/wolfcrypt/integer.h:37:14: fatal error: wolfssl/wolfcrypt/sp_int.h: No such file or directory
       #include <wolfssl/wolfcrypt/sp_int.h>
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
  compilation terminated.

and in the end thus produces curl without https support:

 curl: (1) Protocol "https" not supported or disabled in libcurl

So fix it, by making the working wolfSSL mandatory and error out in
configure step when that's not the case:

 checking for wolfSSL_Init in -lwolfssl... no
 configure: error: --with-wolfssl but wolfSSL was not found or doesn't work

References: https://github.com/openwrt/packages/issues/19005
References: https://github.com/openwrt/packages/issues/19547
Signed-off-by: Petr Štetiar <ynezz@true.cz>

Closes #9682
2022-10-10 11:17:53 +02:00