Commit Graph

29255 Commits

Author SHA1 Message Date
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
Daniel Stenberg
1527dd07f1
tool_getparam: pass in the snprintf("%.*s") string length as 'int'
Reported by Coverity CID 1515928

Closes #9679
2022-10-10 08:42:48 +02:00
Paul Seligman
b261389dba
ws: minor fixes for web sockets without the CONNECT_ONLY flag
- Fixed an issue where is_in_callback was getting cleared when using web
  sockets with debug logging enabled
- Ensure the handle is is_in_callback when calling out to fwrite_func
- Change the write vs. send_data decision to whether or not the handle
  is in CONNECT_ONLY mode.
- Account for buflen not including the header length in curl_ws_send

Closes #9665
2022-10-09 23:09:58 +02:00
Marc Hoersken
d905de2769
CI/cirrus: merge existing macOS jobs into a job matrix
Ref: #9627
Reviewed-by: Philip H.

Closes #9672
2022-10-08 23:49:55 +02:00
Daniel Stenberg
ed5095ed94
strcase: add and use Curl_timestrcmp
This is a strcmp() alternative function for comparing "secrets",
designed to take the same time no matter the content to not leak
match/non-match info to observers based on how fast it is.

The time this function takes is only a function of the shortest input
string.

Reported-by: Trail of Bits

Closes #9658
2022-10-08 11:50:47 +02:00
Daniel Stenberg
b90f857fab
tool_getparam: split out data_urlencode() into its own function
Closes #9673
2022-10-08 11:48:20 +02:00
Daniel Stenberg
4232e1ac84
connect: fix Curl_updateconninfo for TRNSPRT_UNIX
Reported-by: Vasiliy Ulyanov
Fixes #9664
Closes #9670
2022-10-08 11:45:20 +02:00
Daniel Stenberg
c02291fd47
ws: fix Coverity complaints
Coverity pointed out several flaws where variables remained
uninitialized after forks.

Follow-up to e3f335148a

Closes #9666
2022-10-08 11:44:18 +02:00
Marc Hoersken
187f152a1d
CI/GHA: merge msh3 and openssl3 builds into linux workflow
Continue work on merging all Linux workflows into one file.

Follow up to #9501
Closes #9646
2022-10-07 21:47:51 +02:00
Daniel Stenberg
642404717c
curl_ws_send.3: call the argument 'fragsize'
Since WebSocket works with "fragments" not "frames"

Closes #9668
2022-10-07 18:34:01 +02:00
Daniel Stenberg
00452e6aaf
easy: avoid Intel error #2312: pointer cast involving 64-bit pointed-to type
Follow-up to e3f335148a

Closes #9669
2022-10-07 18:32:07 +02:00
Daniel Stenberg
41e1b30ea1
tool_main: exit at once if out of file descriptors
If the main_checkfds function cannot create new file descriptors in an
attempt to detect of stdin, stdout or stderr are closed.

Also changed the check to use fcntl() to check if the descriptors are
open, which avoids superfluously calling pipe() if they all already are.

Follow-up to facfa19cdd

Reported-by: Trail of Bits

Closes #9663
2022-10-07 17:45:07 +02:00
Daniel Stenberg
e3f335148a
websockets: remodeled API to support 63 bit frame sizes
curl_ws_recv() now receives data to fill up the provided buffer, but can
return a partial fragment. The function now also get a pointer to a
curl_ws_frame struct with metadata that also mentions the offset and
total size of the fragment (of which you might be receiving a smaller
piece). This way, large incoming fragments will be "streamed" to the
application. When the curl_ws_frame struct field 'bytesleft' is 0, the
final fragment piece has been delivered.

curl_ws_recv() was also adjusted to work with a buffer size smaller than
the fragment size. (Possibly needless to say as the fragment size can
now be 63 bit large).

curl_ws_send() now supports sending a piece of a fragment, in a
streaming manner, in addition to sending the entire fragment in a single
call if it is small enough. To send a huge fragment, curl_ws_send() can
be used to send it in many small calls by first telling libcurl about
the total expected fragment size, and then send the payload in N number
of separate invokes and libcurl will stream those over the wire.

The struct curl_ws_meta() returns is now called 'curl_ws_frame' and it
has been extended with two new fields: *offset* and *bytesleft*. To help
describe the passed on data chunk when a fragment is delivered in many
smaller pieces.

The documentation has been updated accordingly.

Closes #9636
2022-10-07 12:50:58 +02:00
Patrick Monnerat
83de62babc
docs/examples: avoid deprecated options in examples where possible
Example programs targeting a deprecated feature/option are commented with
a warning about it.
Other examples are adapted to not use deprecated options.

Closes #9661
2022-10-07 09:46:25 +02:00
Viktor Szakats
28687ae271
cmake: fix enabling websocket support
Follow-up from 664249d095

Closes #9660
2022-10-06 21:34:37 +00:00
Viktor Szakats
0c327464ca
tidy-up: delete parallel/unused feature flags
Detecting headers and lib separately makes sense when headers come in
variations or with extra ones, but this wasn't the case here. These were
duplicate/parallel macros that we had to keep in sync with each other
for a working build. This patch leaves a single macro for each of these
dependencies:

- Rely on `HAVE_LIBZ`, delete parallel `HAVE_ZLIB_H`.

  Also delete CMake logic making sure these two were in sync, along with
  a toggle to turn off that logic, called `CURL_SPECIAL_LIBZ`.

  Also delete stray `HAVE_ZLIB` defines.

  There is also a `USE_ZLIB` variant in `lib/config-dos.h`. This patch
  retains it for compatibility and deprecates it.

- Rely on `USE_LIBSSH2`, delete parallel `HAVE_LIBSSH2_H`.

  Also delete `LIBSSH2_WIN32`, `LIBSSH2_LIBRARY` from
  `winbuild/MakefileBuild.vc`, these have a role when building libssh2
  itself. And `CURL_USE_LIBSSH`, which had no use at all.

  Also delete stray `HAVE_LIBSSH2` defines.

- Rely on `USE_LIBSSH`, delete parallel `HAVE_LIBSSH_LIBSSH_H`.

  Also delete `LIBSSH_WIN32`, `LIBSSH_LIBRARY` and `HAVE_LIBSSH` from
  `winbuild/MakefileBuild.vc`, these were the result of copy-pasting the
  libssh2 line, and were not having any use.

- Delete unused `HAVE_LIBPSL_H` and `HAVE_LIBPSL`.

Reviewed-by: Daniel Stenberg

Closes #9652
2022-10-06 15:30:13 +00:00
Daniel Stenberg
6d90308a39
netrc: compare user name case sensitively
User name comparisions in netrc need to match the case.

Closes #9657
2022-10-06 10:25:06 +02:00
Daniel Stenberg
ea3ce80fa8
CURLOPT_COOKIEFILE: insist on "" for enable-without-file
The former way that also suggested using a non-existing file to just
enable the cookie engine could lead to developers maybe a bit carelessly
guessing a file name that will not exist, and then in a future due to
circumstances, such a file could be made to exist and then accidentally
libcurl would read cookies not actually meant to.

Reported-by: Trail of bits

Closes #9654
2022-10-06 10:17:31 +02:00
Daniel Stenberg
3f44eb8124
tests/Makefile: remove run time stats from ci-test
The ci-test is the normal makefile target invoked in CI jobs. This has
been using the -r option to runtests.pl since a long time, but I find
that it mostly just adds many lines to the test output report without
anyone caring much about those stats.

Remove it.

Closes #9656
2022-10-06 10:16:00 +02:00
Patrick Monnerat
2e475deb80
tool: reorganize function c_escape around a dynbuf
This is a bit shorter and a lot safer.

Substrings of unescaped characters are added by a single call to reduce
overhead.

Extend test 1465 to handle more kind of escapes.

Closes #9653
2022-10-06 09:03:33 +02:00
Jay Satiro
eada290098 CURLOPT_HTTPPOST.3: bolden the deprecation notice
Ref: https://github.com/curl/curl/pull/9621

Closes https://github.com/curl/curl/pull/9637
2022-10-05 18:41:55 -04:00
John Bampton
e80c4ff3d0
misc: fix spelling in docs and comments
also: remove outdated sentence

Closes #9644
2022-10-05 16:12:10 +02:00
Patrick Monnerat
172259c4de
tool: avoid generating ambiguous escaped characters in --libcurl
C string hexadecimal-escaped characters may have more than 2 digits.
This results in a wrong C compiler interpretation of a 2-digit escaped
character when followed by an hex digit character.

The solution retained here is to represent such characters as 3-digit
octal escapes.

Adjust and extend test 1465 for this case.

Closes #9643
2022-10-05 16:09:46 +02:00
Daniel Stenberg
3664bccc54
configure: the ngtcp2 option should default to 'no'
While still experimental.

Bug: https://curl.se/mail/lib-2022-10/0007.html
Reported-by: Daniel Hallberg

Closes #9650
2022-10-05 16:05:29 +02:00
Daniel Stenberg
5299301a9b
CURLOPT_MIMEPOST.3: add an (inline) example
Reported-by: Jay Satiro
Bug: https://github.com/curl/curl/pull/9637#issuecomment-1268070723

Closes #9649
2022-10-05 16:04:08 +02:00
Viktor Szakats
14aa9b193c
Makefile.m32: exclude libs & libpaths for shared mode exes [ci skip]
Exclude linker flags specifying depedency libs and libpaths, when
building against `libcurl.dll`. In such case these options are not
necessary (but may cause errors if not/wrongly configured.)

Also move and reword a comment on `CPPFLAGS` to not apply to
`UNICODE` options. These are necessary for all build targets.

Closes #9651
2022-10-05 14:00:36 +00:00
Jay Satiro
d57f906b2a runtests: fix uninitialized value on ignored tests
- Don't show TESTFAIL message (ie tests failed which aren't ignored) if
  only ignored tests failed.

Before:
IGNORED: failed tests: 571 612 1056
TESTDONE: 1214 tests out of 1217 reported OK: 99%
Use of uninitialized value $failed in concatenation (.) or string at
./runtests.pl line 6290.
TESTFAIL: These test cases failed:

After:
IGNORED: failed tests: 571 612 1056
TESTDONE: 1214 tests out of 1217 reported OK: 99%

Closes https://github.com/curl/curl/pull/9648
2022-10-05 04:00:40 -04:00
Jay Satiro
258ee7372f cirrus: use make LDFLAGS=-all-static instead of curl_LDFLAGS
- Correct the use of -all-static for static Windows CI builds.

curl_LDFLAGS was removed from the makefile when metalink support was
removed. LDFLAGS=-all-static is passed to make only, because it is not a
valid option for configure compilation tests.

Closes https://github.com/curl/curl/pull/9633
2022-10-05 03:45:40 -04:00
Viktor Szakats
4d7372415d
Makefile.m32: fix regression with tool_hugehelp [ci skip]
In a recent commit I mistakenly deleted this logic, after seeing a
reference to a filename ending with `.cvs` and thinking it must have
been long gone. Turns out this is an existing file. Restore the rule
and the necessary `COPY` definitions with it.

The restored logic is required for a successful build on a bare source
tree (as opposed to a source release tarball).

Also shorten an existing condition similar to the one added in this
patch.

Regression since 07a0047882

Closes #9645
2022-10-04 19:14:38 +00:00
Viktor Szakats
784400806c
Makefile.m32: deduplicate build rules [ci skip]
After this patch, we reduce the three copies of most `Makefile.m32`
logic to one. This now resides in `lib/Makefile.m32`. It makes future
updates easier, the code shorter, with a small amount of added
complexity.

`Makefile.m32` reduction:

|                   |  bytes | LOC total |  blank |  comment |  code |
|-------------------|-------:|----------:|-------:|---------:|------:|
| 7.85.0            |  34772 |      1337 |     79 |      192 |  1066 |
| before this patch |  17601 |       625 |     62 |      106 |   457 |
| after this patch  |  11680 |       392 |     52 |      104 |   236 |

Details:

- Change rules to create objects for the `v*` subdirs in the `lib` dir.
  This allows to use a shared compile rule and assumes that filenames
  are not (and will not be) colliding across these directories.
  `Makefile.m32` now also stores a list of these subdirs. They are
  changing rarely though.

- Sync as much as possible between the three `Makefile.m32` scripts'
  rules and their source/target sections.

- After this patch `CPPFLAGS` are all applied to the `src` sources once
  again. This matches the behaviour of cmake/autotools. Only zlib ones
  are actually required there.

- Use `.rc` names from `Makefile.inc` instead of keeping a duplicate.

- Change examples to link `libcurl.dll` by default. This makes building
  trivial, even as a cross-build:
    `CC=x86_64-w64-mingw32-gcc make -f Makefile.m32`
  To run them, you need to move/copy or add-to-path `libcurl.dll`.
  You can select static mode via `CFG=-static`.

- List more of the `Makefile.m32` config variables.

- Drop `.rc` support from examples. It made it fragile without much
  benefit.

- Include a necessary system lib for the `externalsocket.c` example.

- Exclude unnecessary systems libs when building in `-dyn` mode.

Closes #9642
2022-10-04 17:11:02 +00:00
Daniel Stenberg
a2d0154e93
RELEASE-NOTES: synced 2022-10-04 16:24:19 +02:00
Daniel Stenberg
90ddfa465b
CURLOPT_COOKIELIST.3: fix formatting mistake
Also, updated manpage-syntax.pl to make it detect this error in test
1173.

Reported-by: ProceduralMan on github
Fixes #9639
Closes #9640
2022-10-04 11:59:55 +02:00