Граф коммитов

12700 Коммитов

Автор SHA1 Сообщение Дата
Daniel Stenberg 657101ec0c
url: reject URLs with hostnames longer than 65535 bytes
It *probably* causes other problems too since DNS can't resolve such
long names, but the SNI field in TLS is limited to 16 bits length.

Closes #9317
2022-08-15 10:52:26 +02:00
Daniel Stenberg e65187e188
ngtcp2: fix picky compiler warnings with wolfSSL for QUIC
Follow-up to 8a13be227e

Closes #9315
2022-08-15 09:39:09 +02:00
Daniel Stenberg c031ec53f8
ngtcp2: remove leftover variable
Mistake leftover from my edit before push.

Follow-up from 8a13be227e
Reported-by: Viktor Szakats
Bug: https://github.com/curl/curl/pull/9290#issuecomment-1214569167
2022-08-15 08:22:20 +02:00
Viktor Szakats 5fd7cd7302
Makefile.m32: allow -nghttp3/-ngtcp2 without -ssl [ci skip]
Before this patch `-nghttp3`/`-ngtcp2` had an effect only when `-ssl`
was also enabled. `-ssl` meaning OpenSSL (and its forks). After
8a13be227e nghttp3/ngtcp2 can also be
used together with wolfSSL. This patch adds the ability to enable
`-nghttp3`/`-ngtcp2` independently from `-ssl` (OpenSSL), allowing to
use it with wolfSSL or other, future TLS backends.

Before this patch, it was fine to enable `-nghttp3`/`-ngtcp2`
unconditionally. After this patch, this is no longer the case, and now
it's the user's responsibility to enable `-nghttp3`/`-ngtcp2` only
together with a compatible TLS backend.

When using a TLS backend other than OpenSSL, the TLS-specific ngtcp2
library must be configured manually, e.g.:
  `export CURL_LDFLAG_EXTRAS=-lngtcp2_crypto_wolfssl`

(or via `NGTCP2_LIBS`)

Closes #9314
2022-08-15 02:49:59 +00:00
Stefan Eissing 8a13be227e
quic: add support via wolfSSL
- based on ngtcp2 PR https://github.com/ngtcp2/ngtcp2/pull/505
- configure adapted to build against ngtcp2 wolfssl crypto lib
- quic code added for creation of WOLFSSL* instances

Closes #9290
2022-08-15 00:48:55 +02:00
David Carlier 6526b36271 memdebug: add annotation attributes
memory debug tracking annotates whether the returned pointer does not
`alias`, hints where the size required is, for Windows to be better
debugged via Visual Studio.

Closes https://github.com/curl/curl/pull/9306
2022-08-14 10:53:18 +02:00
Daniel Stenberg 011788f0b6
msh3: fix the QUIC disconnect function
And free request related memory better in 'done'. Fixes a memory-leak.

Reported-by: Gisle Vanem
Fixes #8915
Closes #9304
2022-08-13 00:19:29 +02:00
Daniel Stenberg ed6e0febe0
connect: close the happy eyeballs loser connection when using QUIC
Reviewed-by: Nick Banks

Closes #9303
2022-08-12 16:29:12 +02:00
Emil Engler 764c958c52
refactor: split resolve_server() into functions
This commit splits the branch-heavy resolve_server() function into
various sub-functions, in order to reduce the amount of nested
if/else-statements.

Beside this, it also removes many else-sequences, by returning in the
previous if-statement.

Closes #9283
2022-08-12 16:27:36 +02:00
Daniel Stenberg 193772084f
schannel: re-indent to use curl style better
Only white space changes

Closes #9301
2022-08-12 16:04:08 +02:00
Daniel Stenberg b5c0fe20e3
hostip: resolve *.localhost to 127.0.0.1/::1
Following the footsteps of other clients like Firefox/Chrome.  RFC 6761
says clients SHOULD do this.

Add test 389 to verify.

Reported-by: TheKnarf on github
Fixes #9192
Closes #9296
2022-08-11 14:01:37 +02:00
Daniel Stenberg d48dd1573c
config: remove the check for and use of SIZEOF_SHORT
shorts are 2 bytes on all platforms curl runs and have ever run on.

Closes #9291
2022-08-11 09:07:06 +02:00
Futaura 55a138acc4
amigaos: fix threaded resolver on AmigaOS 4.x
Replace ip4 resolution function on AmigaOS 4.x, as it requires runtime
feature detection and extra code to make it thread safe.

Closes #9265
2022-08-10 14:14:27 +02:00
Emil Engler 34886a444f
imap: use ISALNUM() for alphanumeric checks
This commit replaces a self-made character check for alphanumeric
characters within imap_is_bchar() with the ISALNUM() macro, as it is
reduces the size of the code and makes the performance better, due to
ASCII arithmetic.

Closes #9289
2022-08-10 14:12:22 +02:00
Cering 6ba3047378
connect: add quic connection information
Fixes #9286
Closes #9287
2022-08-10 08:41:50 +02:00
Daniel Stenberg 15f7feac22
urldata: move smaller fields down in connectdata struct
By (almost) sorting the struct fields in connectdata in a decending size
order, having the single char ones last, we reduce the number of holes
in the struct and thus the amount of storage needed.

Closes #9280
2022-08-08 19:57:49 +02:00
Daniel Stenberg ca528d1de7
ldap: adapt to conn->port now being an 'int'
Remove typecasts. Fix printf() formats.

Follow-up from 764c6bd3bf.
Pointed out by Coverity CID 1507858.

Closes #9281
2022-08-08 19:56:14 +02:00
Futaura 23c708cdc8
file: add handling of native AmigaOS paths
On AmigaOS 4.x, handle native absolute paths, whilst blocking relative
paths. Also allow unix style paths if feature enabled at link time.

Inspiration-from: Michael Trebilcock

Closes #9259
2022-08-08 16:42:10 +02:00
Daniel Stenberg a29d34b0b7
urldata: make 'negnpn' use less storage
The connectdata struct field 'negnpn' never holds a value larger than
30, so an unsigned char saves 3 bytes struct space.

Closes #9279
2022-08-08 14:31:06 +02:00
Daniel Stenberg a550831023
urldata: make three *_proto struct fields smaller
Use 'unsigned char' for storage instead of the enum, for three GSSAPI
related fields in the connectdata struct.

Closes #9278
2022-08-08 14:30:25 +02:00
Daniel Stenberg 0f23341953
connect: set socktype/protocol correctly
So that an address used from the DNS cache that was previously used for
QUIC can be reused for TCP and vice versa.

To make this possible, set conn->transport to "unix" for unix domain
connections ... and store the transport struct field in an unsigned char
to use less space.

Reported-by: ウさん
Fixes #9274
Closes #9276
2022-08-08 13:26:11 +02:00
Futaura a041ed8cde
amissl: allow AmiSSL to be used with AmigaOS 4.x builds
Enable AmiSSL to be used instead of static OpenSSL link libraries.
for AmigaOS 4.x, as it already is in the AmigaOS 3.x build.

Closes #9269
2022-08-08 10:48:11 +02:00
opensignature dc8c859b0c
openssl: add details to "unable to set client certificate" error
from: "curl: (58) unable to set client certificate"

to: curl: (58) unable to set client certificate [error:0A00018F:SSL
routines::ee key too small]

Closes #9228
2022-08-08 09:49:38 +02:00
Futaura e1acfafa49
amissl: make AmiSSL v5 a minimum requirement
AmiSSL v5 is the latest version, featuring a port of OpenSSL 3.0.
Support for previous OpenSSL 1.1.x versions has been dropped, so
makes sense to enforce v5 as the minimum requirement. This also
allows all the AmiSSL stub workarounds to be removed as they are
now provided in a link library in the AmiSSL SDK.

Closes #9267
2022-08-08 09:16:01 +02:00
Daniel Stenberg 0ad7c8d7d5
digest: pass over leading spaces in qop values
When parsing the "qop=" parameter of the digest authentication, and the
value is provided within quotes, the list of values can have leading
white space which the parser previously did not handle correctly.

Add test case 388 to verify.

Reported-by: vlubart on github
Fixes #9264
Closes #9270
2022-08-08 08:28:04 +02:00
Evgeny Grin (Karlson2k) 3fe24ea322
digest: reject broken header with session protocol but without qop
Closes #9077
2022-08-07 14:39:57 +02:00
Andrew Lambert 4641575fcd
curl_easy_header: Add CURLH_PSEUDO to sanity check
Fixes #9235
Closes #9236
2022-08-06 17:08:16 +02:00
Wyatt O'Day 8beff43559 schannel: Add TLS 1.3 support
- Support TLS 1.3 as the default max TLS version for Windows Server 2022
  and Windows 11.

- Support specifying TLS 1.3 ciphers via existing option
  CURLOPT_TLS13_CIPHERS (tool: --tls13-ciphers).

Closes https://github.com/curl/curl/pull/8419
2022-08-02 13:54:31 -04:00
Nao Yonashiro 2086b69b57 quiche: fix build failure
Reviewed-by: Alessandro Ghedini
Closes #9223
2022-08-02 16:49:36 +02:00
Sean McArthur 3b52a80c05
hyper: enable obs-folded multiline headers
Closes #9216
2022-07-28 00:36:18 +02:00
Daniel Stenberg 3141062c23
connect: revert the use of IP*_RECVERR
The options were added in #6341 and d13179d, but cause problems: Lots of
POLLIN event occurs but recvfrom read nothing.

Reported-by: Tatsuhiro Tsujikawa
Fixes #9209
Closes #9215
2022-07-28 00:34:23 +02:00
Jay Satiro 9bd40e2b69 ngtcp2: Fix build error due to change in nghttp3 prototypes
ngtcp2/nghttp3@4a066b2 changed nghttp3_conn_block_stream and
nghttp3_conn_shutdown_stream_write return from int to void.

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

Fixes https://github.com/curl/curl/issues/9204
Closes https://github.com/curl/curl/pull/9200
2022-07-26 13:23:56 -04:00
Evgeny Grin (Karlson2k) 6e241bbf1d digest: fix memory leak, fix not quoted 'opaque'
Fix leak regression introduced by 3a6fe0c.

Closes https://github.com/curl/curl/pull/9199
2022-07-25 15:06:30 -04:00
Daniel Stenberg 07535a4f87
sendf: skip storing HTTP headers if HTTP disabled
Closes #9179
2022-07-23 13:39:10 +02:00
Daniel Stenberg 3be0c67379
url: enumerated type mixed with another type
Follow-up to 1c58e7ae99ce2030213f28b

Closes #9179
2022-07-23 13:39:06 +02:00
Daniel Stenberg 8cd57d6e39
urldata: change second proxytype field to unsigned char to match
To avoid "enumerated type mixed with another type"

Closes #9179
2022-07-23 13:39:03 +02:00
Daniel Stenberg 8d1da2e172
http: typecast the httpreq assignment to avoid icc compiler warning
error #188: enumerated type mixed with another type

Closes #9179
2022-07-23 13:39:00 +02:00
Daniel Stenberg dcbc9226bc
urldata: make state.httpreq an unsigned char
To match set.method used for the same purpose.

Closes #9179
2022-07-23 13:38:57 +02:00
Daniel Stenberg 32db1ed867
splay: avoid using -1 in unsigned variable
To fix icc compiler warning integer conversion resulted in a change of sign

Closes #9179
2022-07-23 13:38:54 +02:00
Daniel Stenberg 6531c0e85a
sendf: store the header type in an usigned char to avoid icc warnings
Closes #9179
2022-07-23 13:38:50 +02:00
Daniel Stenberg 4c57fdcf87
multi: fix the return code from Curl_pgrsDone()
It does not return a CURLcode. Detected by the icc compiler warning
"enumerated type mixed with another type"

Closes #9179
2022-07-23 13:38:47 +02:00
Daniel Stenberg 74d47e22aa
sendf: make Curl_debug a void function
As virtually no called checked the return code, and those that did
wrongly treated it as a CURLcode. Detected by the icc compiler warning:
enumerated type mixed with another type

Closes #9179
2022-07-23 13:38:43 +02:00
Daniel Stenberg f273b59144
http_chunks: remove an assign + typecast
As it caused icc to complain: "pointer cast involving 64-bit pointed-to
type"

Closes #9179
2022-07-23 13:38:36 +02:00
Daniel Stenberg 336f7cd5af
vtls: make Curl_ssl_backend() return the enum type curl_sslbackend
To fix the icc warning enumerated type mixed with another type

Closes #9179
2022-07-23 13:38:33 +02:00
Daniel Stenberg fe8f1512e5
ftp: use a correct expire ID for timer expiry
This was an accurate error pointed out by the icc warning: enumerated
type mixed with another type

Ref: #9179
Closes #9184
2022-07-20 00:50:19 +02:00
Daniel Stenberg 6f037100eb
sendf: fix paused header writes since after the header API
Regression since d1e4a67

Reported-by: Sergey Ogryzkov
Fixes #9180
Closes #9182
2022-07-20 00:49:06 +02:00
Daniel Stenberg 7935972b37
mprintf: fix *dyn_vprintf() when out-of-memory
Follow-up to 0e48ac1f99. Torture-testing 1455 would lead to a memory
leak otherwise.

Closes #9185
2022-07-19 23:56:03 +02:00
Daniel Stenberg c61e6de7d5
file: fix icc enumerated type mixed with another type warning
Ref: #9179
Closes #9181
2022-07-19 18:10:08 +02:00
Viktor Szakats 4d73854462
tidy-up: delete unused build configuration macros
Most of them feature guards:

- `CURL_INCLUDES_SYS_UIO` [1]
- `HAVE_ALLOCA_H` [2]
- `HAVE_CRYPTO_CLEANUP_ALL_EX_DATA` (unused since de71e68000)
- `HAVE_DLFCN_H`
- `HAVE_DLOPEN`
- `HAVE_DOPRNT`
- `HAVE_FCNTL`
- `HAVE_GETHOSTBYNAME` [3]
- `HAVE_GETOPT_H`
- `HAVE_GETPASS`
- `HAVE_GETPROTOBYNAME`
- `HAVE_GETSERVBYNAME`
- `HAVE_IDN_FREE*`
- `HAVE_INET_ADDR`
- `HAVE_IOCTL`
- `HAVE_KRB4`
- `HAVE_KRB_GET_OUR_IP_FOR_REALM`
- `HAVE_KRB_H`
- `HAVE_LDAPSSL_H`
- `HAVE_LDAP_INIT_FD`
- `HAVE_LIBDL`
- `HAVE_LIBNSL`
- `HAVE_LIBRESOLV*`
- `HAVE_LIBUCB`
- `HAVE_LL`
- `HAVE_LOCALTIME_R`
- `HAVE_MALLOC_H`
- `HAVE_MEMCPY`
- `HAVE_MEMORY_H`
- `HAVE_NETINET_IF_ETHER_H`
- `HAVE_NI_WITHSCOPEID`
- `HAVE_OPENSSL_CRYPTO_H`
- `HAVE_OPENSSL_ERR_H`
- `HAVE_OPENSSL_PEM_H`
- `HAVE_OPENSSL_PKCS12_H`
- `HAVE_OPENSSL_RAND_H`
- `HAVE_OPENSSL_RSA_H`
- `HAVE_OPENSSL_SSL_H`
- `HAVE_OPENSSL_X509_H`
- `HAVE_PEM_H`
- `HAVE_POLL`
- `HAVE_RAND_SCREEN`
- `HAVE_RAND_STATUS`
- `HAVE_RECVFROM`
- `HAVE_SETSOCKOPT`
- `HAVE_SETVBUF`
- `HAVE_SIZEOF_LONG_DOUBLE`
- `HAVE_SOCKIO_H`
- `HAVE_SOCK_OPTS`
- `HAVE_STDIO_H`
- `HAVE_STRCASESTR`
- `HAVE_STRFTIME`
- `HAVE_STRLCAT`
- `HAVE_STRNCMPI`
- `HAVE_STRNICMP`
- `HAVE_STRSTR`
- `HAVE_STRUCT_IN6_ADDR`
- `HAVE_TLD_H`
- `HAVE_TLD_STRERROR`
- `HAVE_UNAME`
- `HAVE_USLEEP`
- `HAVE_WINBER_H`
- `HAVE_WRITEV`
- `HAVE_X509_H`
- `LT_OBJDIR`
- `NEED_BASENAME_PROTO`
- `NOT_NEED_LIBNSL`
- `OPENSSL_NO_KRB5`
- `RECVFROM_TYPE*`
- `SIZEOF_LONG_DOUBLE`
- `STRERROR_R_TYPE_ARG3`
- `USE_YASSLEMUL`
- `_USRDLL` (from CMake) [4]

[1] Related parts in `m4/curl-functions.m4` and `configure.ac` might
    also be deleted.

[2] Related comment can possibly be deleted in
    `packages/vms/generate_config_vms_h_curl.com`.

[3] There are more instances of this in autotools, but I did not dare to
    touch those. Looked like it's used to detect socket support.

[4] This is necessary for MFC (Microsoft Foundation Class) DLLs to
    force linking MFC components statically to the DLL. `libcurl.dll`
    does not use MFC, so we can delete this define.
    Ref: https://docs.microsoft.com/cpp/build/regular-dlls-statically-linked-to-mfc

Script that can help finding unused settings like above:
```shell

autoheader configure.ac  # generate lib/curl_config.h.in

{
  grep -o -E    'set\([A-Z][A-Z0-9_]{3,}'          CMake/Platforms/WindowsCache.cmake | sed -E 's|set\(||g'
  grep -o -E -h '#define +[A-Z][A-Z0-9_]{3,}'      lib/config-*.h                     | sed -E 's|#define +||g'
  grep -o -E    '#cmakedefine +[A-Z][A-Z0-9_]{3,}' lib/curl_config.h.cmake            | sed -E 's|#cmakedefine +||g'
  grep -o -E    '#undef +[A-Z][A-Z0-9_]{3,}'       lib/curl_config.h.in               | sed -E 's|#undef +||g'
} | sort -u | grep -v -F 'HEADER_CURL_' | while read -r def; do
  c="$(git grep -w -F "${def}" | grep -v -E -c '(/libcurl\.tmpl|^lib/config-|^lib/curl_config\.h\.cmake|^CMakeLists\.txt|^CMake/Platforms/WindowsCache\.cmake|^packages/vms/config_h\.com|^m4/curl-functions\.m4|^acinclude\.m4|^configure\.ac)')"
  if [ "${c}" = '0' ]; then
    echo "${def}"
  fi
done
```

Reviewed-by: Daniel Stenberg
Closes #9044
2022-07-19 15:12:19 +00:00
Daniel Stenberg 4c0ac2aa59
cookie: treat a blank domain in Set-Cookie: as non-existing
This matches what RFC 6265 section 5.2.3 says.

Extended test 31 to verify.

Fixes #9164
Reported-by: Gwen Shapira
Closes #9177
2022-07-19 11:52:54 +02:00
Patrick Monnerat c2e72c7812
base64: base64url encoding has no padding
See RFC4648 section 5 and RFC7540 section 3.2.1.

Suppress generation of '=' padding of base64url encoding. This is
accomplished by considering the string beginning at offset 64 in the
character table as the padding: this is "=" for base64, "" for base64url.

Also use strchr() to replace character search loops where possible.

Suppress erroneous comments about empty encoding results.

Adjust unit test 1302 to unpadded base64url encoding and add tests for
empty results.

Closes #9139
2022-07-19 11:06:20 +02:00
Daniel Stenberg dfe5a3023b
easyoptions: fix icc warning
easyoptions.c(360): error #188: enumerated type mixed with another type

Ref: #9156
Reported-by: Matthew Thompson
Closes #9176
2022-07-19 11:01:15 +02:00
lwthiker b9b6148c45
h2h3: fix overriding the 'TE: Trailers' header
A 'TE: Trailers' header is explicitly replaced by 'te: trailers'
(lowercase) in Curl_pseudo_headers() when building the list of HTTP/2 or
HTTP/3 headers. However, this is then replaced again by the original
value due to a bug, resulting in the uppercased version being sent. Some
HTTP/2 servers reject the whole HTTP/2 stream when this is the case.

Closes #9170
2022-07-19 00:19:13 +02:00
Daniel Stenberg fe93bb4d1f
doh: move doh related struct definitions to doh.h
and make 'dnstype' in 'struct dnsprobe' use the DNStype to fix the icc compiler warning:

  doh.c(924): error #188: enumerated type mixed with another type

Reported-by: Matthew Thompson
Ref #9156
Closes #9174
2022-07-18 11:55:26 +02:00
Viktor Szakats f9ff59ebe2
Makefile.m32: stop trying to build libcares.a [ci skip]
Before this patch, `lib/Makefile.m32` had a rule to build `libcares.a` in
`-cares`-enabled builds, via c-ares's own `Makefile.m32`. Committed in
2007 [1]. The commit message doesn't specifically address this particular
change. This logic comes from the times when c-ares was part of the curl
source tree, hence the special treatment.

This feature creates problems when building c-ares first, using CMake
and pointing `LIBCARES_PATH` to its install prefix, where `Makefile.m32`
is missing in such case. A sub-build for c-ares is undesired also when
c-ares had already been build via its own `Makefile.m32`.

To avoid the sub-build, this patch deletes its Makefile rule. After this
patch `libcares.a` needs to be manually built before using it in
`Makefile.m32`. Aligning it with the rest of dependencies.

[1] 46c92c0b80

Reviewed-by: Daniel Stenberg
Closes #9169
2022-07-17 21:46:01 +00:00
Daniel Stenberg 0e48ac1f99
mprintf: make dprintf_formatf never return negative
This function no longer returns a negative value if the formatting
string is bad since the return value would sometimes be propagated as a
return code from the mprintf* functions and they are documented to
return the length of the output. Which cannot be negative.

Fixes #9149
Closes #9151
Reported-by: yiyuaner on github
2022-07-17 23:27:02 +02:00
Viktor Szakats a19f0601fe
doh: use https protocol by default
The only allowed protocol is https, so it makes sense to use that
by default if not passed explicitly by the user.

Reported-by: MasterInQuestion on github
Reviewed-by: Jay Satiro
Fixes #9163
Closes #9165
2022-07-16 14:10:39 +00:00
Viktor Szakats 4c46c829f5
openssl: fix BoringSSL symbol conflicts with LDAP and Schannel
Same issue as here [1], but this time when building curl with BoringSSL
for Windows with LDAP(S) or Schannel support enabled.

Apply the same fix [2] for these source files as well.

This can also be fixed by moving `#include "urldata.h"` _before_
including `winldap.h` and `schnlsp.h` respectively. This seems like
a cleaner fix, though I'm not sure why it works and if it has any
downside.

[1] https://github.com/curl/curl/issues/5669
[2] fbe07c6829

Co-authored-by: Jay Satiro
Closes #9110
2022-07-14 07:14:22 +00:00
Daniel Stenberg 451bcc1a91
asyn-thread: make getaddrinfo_complete return CURLcode
... as the only caller that cares about what it returns assumes that
anyway. This caused icc to warn:

asyn-thread.c(505): error #188: enumerated type mixed with another type
        result = getaddrinfo_complete(data);

Repoorted-by: Matthew Thompson
Bug: https://github.com/curl/curl/issues/9081#issuecomment-1182143076
Closes #9146
2022-07-13 23:26:13 +02:00
Daniel Stenberg e0c68f0255
easy_lock: fix build with icc
The Intel compiler tries to look like GCC *and* clang *and* it lies in
its __has_builtin() function (returns true when it should return false),
so override it.

Reported-by: Matthew Thompson
Fixes #9081
Closes #9144
2022-07-12 23:08:35 +02:00
Even Rouault 0525614269
CMake: link curl to its dependencies with PRIVATE
The current PUBLIC visibility causes issues for downstream users.
Cf https://github.com/OSGeo/PROJ/pull/3172#issuecomment-1157942986

Reviewed-by: Jakub Zakrzewski
Closes #9125
2022-07-12 17:18:39 +02:00
Even Rouault 7ac3607584
CMake: remove APPEND in export(TARGETS)
When running cmake several times, new content was appended to already
existing generated files, which is not appropriate

Reviewed-by: Jakub Zakrzewski
Closes #9124
2022-07-12 17:17:07 +02:00
Tatsuhiro Tsujikawa e9a2eced69
ngtcp2: implement cb_h3_stop_sending and cb_h3_reset_stream callbacks
Closes #9135
2022-07-12 17:15:52 +02:00
Viktor Szakats ca73991774
build: improve OS string in CMake and `config-win32.h`
This patch makes CMake fill the "OS string" with the value of
`CMAKE_C_COMPILER_TARGET`, if passed. This typically contains a triplet,
the same we can pass to `./configure` via `--host=`.

For non-CMake, non-autotools, Windows builds, this patch adds the ability
to override the default `OS` value in `lib/config-win32.h`.

With these its possible to get the same OS string across the three build
systems.

This patch supersedes the earlier, partial, CMake-only solution:
435f395f3f, thus retiring the
`CURL_OS_SUFFIX` CMake option.

Reviewed-by: Jay Satiro
Closes #9117
2022-07-11 19:41:31 +00:00
Viktor Szakats 1d5b7b7009
Makefile.m32: add `CURL_RC` and `CURL_STRIP` variables [ci skip]
They allow to override the hardcoded values for the `windres` and `strip`
tools, complementing the existing set of `CURL_{CC,AR,RANLIB}` variables.

`CURL_RC` comes handy when using LLVM tools with `CROSSPREFIX=llvm-` and
`CURL_CC=clang` set on current latest debian:unstable or earlier, where
`llvm-windres` is missing, and a `CURL_RC=<triplet>-windres` fixes it.
Hopefully this will be fixed in the llvm package. FWIW `llvm-windres`
does exist in Homebrew llvm, MSYS2 llvm and llvm-mingw.

Reviewed-by: Daniel Stenberg
Closes #9132
2022-07-10 22:28:14 +00:00
Tatsuhiro Tsujikawa 4989cd099e
ngtcp2: fix stall or busy loop on STOP_SENDING with upload data
Fixes #9122
Closes #9123
2022-07-10 23:18:00 +02:00
xkernel afdbb176f6
getinfo: return better error on NULL as first argument
Closes #9114
2022-07-10 18:22:23 +02:00
Jay Satiro eab25898b3 docs: explain curl_easy_escape/unescape curl handle is ignored
26101421 (precedes 7.82.0) removed character conversion support used by
very old legacy operating systems and since then the curl handle passed
to curl_easy_escape/unescape is always ignored.

Bug: https://github.com/curl/curl/discussions/9115
Reported-by: Ted Lyngmo

Closes https://github.com/curl/curl/pull/9121
2022-07-10 02:59:58 -04:00
Viktor Szakats 9153ba708b
openssl: add `CURL_BORINGSSL_VERSION` to identify BoringSSL
BoringSSL doesn't keep a version number, and doesn't self-identify itself
via any other revision number via its own headers. We can identify
BoringSSL revisions by their commit hash. This hash is typically known by
the builder. This patch adds a way to pass this hash to libcurl, so that
it can display in the curl version string:

For example:

`CFLAGS=-DCURL_BORINGSSL_VERSION="c239ffd0"`

```
curl 7.84.0 (x86_64-w64-mingw32) libcurl/7.84.0 BoringSSL/c239ffd0 (Schannel) zlib/1.2.12 [...]
Release-Date: 2022-06-27
Protocols: dict file ftp ftps gopher gophers http https imap imaps ldap ldaps mqtt pop3 [...]
Features: alt-svc AsynchDNS brotli gsasl HSTS HTTP2 HTTP3 HTTPS-proxy IDN IPv6 Kerberos [...]
```

The setting is optional, and if not passed, BoringSSL will appear without
a version number, like before this patch.

Closes #9113
2022-07-08 10:12:15 +00:00
Jay Satiro 30c862513d escape: remove outdated comment
Bug: https://github.com/curl/curl/discussions/9115
Reported-by: Ted Lyngmo
2022-07-08 01:39:55 -04:00
Tatsuhiro Tsujikawa 7f5a29e689 ngtcp2: Fix missing initialization of nghttp3_nv.flags
Closes https://github.com/curl/curl/pull/9118
2022-07-08 00:12:08 -04:00
Viktor Szakats 190caa9ce2
Makefile.m32: add `NGTCP2_LIBS` option [ci skip]
Makefile.m32's ngtcp2 has its two libs hardwired for OpenSSL.
Add `NGTCP2_LIBS` envvar to override them with a custom list,
making it possible to use BoringSSL, or any other backend.

Closes #9109
2022-07-06 09:22:42 +00:00
Evgeny Grin (Karlson2k) 647ed7c78b digest: fix missing increment of 'nc' value for auth-int
- Increment nc regardless of qop type.

Prior to this change nc was only incremented for qop type auth even
though libcurl sends nc with any qop.

Closes https://github.com/curl/curl/pull/9090
2022-07-06 04:14:37 -04:00
Daniel Stenberg 1b3d59acf9
urldata: reduce size of four ftp related members
ftp_filemethod, ftpsslauth and ftp_ccc are now uchars

accepttimeout is now unsigned int - almost 50 days ought to be enough
for this value.

Closes #9106
2022-07-05 10:18:48 +02:00
Daniel Stenberg dcb7d4f904
urldata: reduce three type-members from int to uchar
- timecondition
 - proxytype
 - method

... previously used their enum type in the struct, which made them
unnecesarily large.

Closes #9105
2022-07-05 10:17:31 +02:00
Daniel Stenberg be43dd600a
CURLOPT_SERVER_RESPONSE_TIMEOUT: the new name
Starting now, CURLOPT_FTP_RESPONSE_TIMEOUT is the alias instead of the
other way around.

Since 7.20.0, CURLOPT_SERVER_RESPONSE_TIMEOUT has existed as an alias
but since the option is for more protocols than FTP the more "correct"
version of the option is the "server" one so now we switch.

Closes #9104
2022-07-05 10:16:05 +02:00
Daniel Stenberg 671cc8e110
urldata: make 'ftp_create_missing_dirs' a uchar
It only ever holds the values 0-2.

Closes #9103
2022-07-05 10:10:49 +02:00
Daniel Stenberg 3622bf4e79
urldata: change 4 timeouts to unsigned int from long
They're not used for that long times anyway, 32 bit milliseconds is long
enough.

Closes #9101
2022-07-05 00:15:54 +02:00
Daniel Stenberg fe14ff6150
urldata: make 'use_netrc' a uchar
Closes #9102
2022-07-04 23:04:24 +02:00
Daniel Stenberg 3fa343a35c
urldata: make 'buffer_size' an unsigned int
It is already capped at READBUFFER_MAX which fits easily in 32 bits.

Closes #9098
2022-07-04 23:03:44 +02:00
Daniel Stenberg cb17b12b01
urldata: remove the unused 'rtspversion' struct member
Closes #9100
2022-07-04 19:44:10 +02:00
Daniel Stenberg 1d85d2e4f9
urldata: make 'use_port' an usigned short
... instead of a long. It is already enforced to not attempt to set any
value outside of 16 bits unsigned.

Closes #9099
2022-07-04 19:42:40 +02:00
Daniel Stenberg ccc8092b05
urldata: store dns cache timeout in an int
68 years ought to be enough for most.

Closes #9097
2022-07-04 19:28:50 +02:00
Daniel Stenberg c5f3c47cbb
cookie: use %zu to infof() for size_t values
Detected by Coverity. CID 1507051
Closes #9095
2022-07-04 14:37:48 +02:00
Viktor Szakats 8ef0f35a04
makefile.m32: add support for custom ARCH [ci skip]
When building curl for target platform other than x64 and x86, it is now
possible to pass `ARCH=custom`, that will omit all hardcoded logic for
setting up CFLAGS/LDFLAGS/RCFLAGS for these platforms, and let these be
customized via `CURL_CFLAG_EXTRAS`, `CURL_LDFLAG_EXTRAS`, and a newly
added one for the resource compiler: `CURL_RCFLAG_EXTRAS`.

This makes it possible to use `makefile.m32` to build for ARM64 for
example.

Reviewed-by: Daniel Stenberg
Closes #9092
2022-07-04 10:26:30 +00:00
Viktor Szakats 76172511e7
windows: improve random source
- Use the Windows API to seed the fallback random generator.

  This ensures to always have a random seed, even when libcurl is built
  with a vtls backend lacking a random generator API, such as rustls
  (experimental), GSKit and certain mbedTLS builds, or, when libcurl is
  built without a TLS backend. We reuse the Windows-specific random
  function from the Schannel backend.

- Implement support for `BCryptGenRandom()` [1] on Windows, as a
  replacement for the deprecated `CryptGenRandom()` [2] function.

  It is used as the secure random generator for Schannel, and also to
  provide entropy for libcurl's fallback random generator. The new
  function is supported on Vista and newer via its `bcrypt.dll`. It is
  used automatically when building for supported versions. It also works
  in UWP apps (the old function did not).

- Clear entropy buffer before calling the Windows random generator.

  This avoids using arbitrary application memory as entropy (with
  `CryptGenRandom()`) and makes sure to return in a predictable state
  when an API call fails.

[1] https://docs.microsoft.com/windows/win32/api/bcrypt/nf-bcrypt-bcryptgenrandom
[2] https://docs.microsoft.com/windows/win32/api/wincrypt/nf-wincrypt-cryptgenrandom

Closes #9027
2022-07-04 09:38:24 +00:00
Daniel Stenberg e6f8445ede
setopt: add CURLOPT_PROTOCOLS_STR and CURLOPT_REDIR_PROTOCOLS_STR
... as replacements for deprecated CURLOPT_PROTOCOLS and
CURLOPT_REDIR_PROTOCOLS as these new ones do not risk running into the
32 bit limit the old ones are facing.

CURLINFO_PROTCOOL is now deprecated.

The curl tool is updated to use the new options.

Added test 1597 to verify the libcurl protocol parser.

Closes #8992
2022-07-04 08:35:09 +02:00
Daniel Stenberg 193215db3c
digest: simplify a switch() to a simple if 2022-07-04 08:27:21 +02:00
Daniel Stenberg a44c9ba799
digest: provide a special bit for "sess" algos
Also shortened the names and moved them to the .c file since they are
private for this source file only. Also made them #defines instead of
enum.

Closes #9079
2022-07-04 08:27:15 +02:00
Thomas Weißschuh 52e822173a select: do not return fatal error on EINTR from poll()
The same was done for select() in 5912da25 but poll() was missed.

Bug: https://bugs.archlinux.org/task/75201
Reported-by: Alexandre Bury (gyscos at archlinux)

Ref: https://github.com/curl/curl/issues/8921
Ref: https://github.com/curl/curl/pull/8961
Ref: https://github.com/curl/curl/commit/5912da25#r77584294

Closes https://github.com/curl/curl/pull/9091
2022-07-04 00:58:07 -04:00
Jay Satiro bbffb8c285 easy_lock: fix build for mingw
- Define SRWLOCK symbols missing in some mingw environments.

Closes https://github.com/curl/curl/pull/8997
2022-07-02 23:52:07 -04:00
Daniel Stenberg 4d4c2274d0
http_aws_sigv4.c: remove two unusued includes
Closes #9080
2022-07-01 23:33:42 +02:00
Jilayne Lovejoy 28971bd453
lib/curl_path.c: add ISC to license expression
THe text of the ISC license is in this file, so the SPDX license
expression should be updated

Closes #9073
2022-07-01 09:40:31 +02:00
Sean McArthur be8d2b037d
hyper: use wakers for curl pause/resume
Closes #9070
2022-06-30 10:19:08 +02:00
Viktor Szakats c7f53b7493
Makefile.m32: do not set the libcurl.rc debug flag [ci skip]
Delete `-DDEBUGBUILD=0` windres option. This was likely meant to
disable VS_FF_DEBUG in FILEFLAGS, but any assigned value enabled
it instead. Delete this unnecessary option and thus sync up with
how CMake compiles libcurl.rc by default.

Reviewed-by: Jay Satiro
Closes #9069
2022-06-30 08:14:29 +00:00
Daniel Stenberg 1dda49a1d3
curl.h: CURLE_CONV_FAILED is obsoleted
The last use was removed in 7.82.0. Updated some docs too to reflect the
current error code situation.

Closes #9067
2022-06-29 16:03:02 +02:00
Daniel Stenberg 33fd57b8ff
easy_lock: fix the #ifdef conditional for ia32_pause
To work better with new and old clang compilers.

Reported-by: Ryan Schmidt
Assisted-by: Joshua Root

Fixes #9058
Closes #9062
2022-06-28 16:56:50 +02:00
Daniel Stenberg 50efb0822a
easy_lock: switch to using atomic_int instead of bool
To work with more compilers without requiring separate libs to
link. Like with gcc-12 for RISC-V on Linux.

Reported-by: Adam Sampson
Fixes #9055
Closes #9061
2022-06-28 12:45:47 +02:00
vvb2060 e631f6e10e
ngtcp2: fix incompatible function pointer types
Closes #9056
2022-06-28 00:02:36 +02:00
vvb2060 5a1a892565
easy_lock.h: use __asm__ instead of asm to fix build
Closes #9056
2022-06-28 00:02:26 +02:00
Daniel Stenberg e2e7f54b7b
easy_lock.h: include sched.h if available to fix build
Patched-by: Harry Sintonen

Closes #9054
2022-06-27 10:59:52 +02:00
Daniel Stenberg d64115d7bb
hsts: use Curl_fopen() 2022-06-26 11:04:02 +02:00
Daniel Stenberg fab970a5d1
altsvc: use Curl_fopen() 2022-06-26 11:04:02 +02:00
Daniel Stenberg 20f9dd6bae
fopen: add Curl_fopen() for better overwriting of files
Bug: https://curl.se/docs/CVE-2022-32207.html
CVE-2022-32207
Reported-by: Harry Sintonen
Closes #9050
2022-06-26 11:03:57 +02:00
Daniel Stenberg 48d7064a49
cookie: apply limits
- Send no more than 150 cookies per request
- Cap the max length used for a cookie: header to 8K
- Cap the max number of received Set-Cookie: headers to 50

Bug: https://curl.se/docs/CVE-2022-32205.html
CVE-2022-32205
Reported-by: Harry Sintonen
Closes #9048
2022-06-26 11:00:48 +02:00
Daniel Stenberg 3a09fbb7f2
content_encoding: return error on too many compression steps
The max allowed steps is arbitrarily set to 5.

Bug: https://curl.se/docs/CVE-2022-32206.html
CVE-2022-32206
Reported-by: Harry Sintonen
Closes #9049
2022-06-25 22:14:21 +02:00
Daniel Stenberg 6ecdf5136b
krb5: return error properly on decode errors
Bug: https://curl.se/docs/CVE-2022-32208.html
CVE-2022-32208
Reported-by: Harry Sintonen
Closes #9051
2022-06-25 22:13:09 +02:00
Daniel Stenberg 2b67a0a112
easy_lock.h: remove use of the deprecated ATOMIC_VAR_INIT macro
clang 14 warns about its use. It is being deprecated by the working
group for the programming language C: "The macro ATOMIC_VAR_INIT is
basically useless for the purpose for which it was designed"

Ref: https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2886.htm

Reported-by: Tatsuhiro Tsujikawa
Fixes #9041
Closes #9042
2022-06-23 16:17:09 +02:00
Stefan Eissing 8135d420ee
ngtcp2: avoid supplying 0 length `msg_control` to sendmsg()
Testing on macOS 12.4, sendmsg() fails with EINVAL when a msg_control
buffer is provided in sengmsg(), even though msg_controllen was set to
0.

Initialize msg.msg_controllen just as needed and also perform the size
assertion only when needed.

Closes #9039
2022-06-23 16:11:32 +02:00
Tom Eccles 71bbabb167
ftp: restore protocol state after http proxy CONNECT
connect_init() (lib/http_proxy.c) swaps out the protocol state while
working on the proxy connection, this is then restored by
Curl_connect_done() after the connection completes.

ftp_do_more() extracted the protocol state pointer to a local variable
at the start of the function then calls Curl_proxy_connect(). If the proxy
connection completes, Curl_proxy_connect() will call Curl_connect_done()
(via Curl_proxyCONNECT()), which restores data->req.p to point to the ftp
protocol state instead of the http proxy protocol state, but the local
variable in ftp_do_more still pointed to the old value.

Ultimately this meant that the state worked on by ftp_do_more() was the
http proxy state not the ftp state initialised by ftp_connect(), but
subsequent calls to any ftp_ function would use the original state.

For my use-case, the visible consequence was that ftp->downloadsize was
never set and so downloaded data was never returned to the application.

This commit updates the ftp protocol state pointer in ftp_do_more() after
Curl_proxy_connect() returns, ensuring that the correct state pointer is
used.

Fixes #8737
Closes #9043
2022-06-23 16:07:20 +02:00
Jay Satiro 3733717509 curl_setup: include _mingw.h
Prior to this change _mingw.h needed to be included in each unit before
evaluating __MINGW{32,64}_xxx_VERSION macros since it defines them. It
is included only in some mingw headers (eg stdio.h) and not others
(eg windows.h) so it's better to explicitly include it once.

Closes https://github.com/curl/curl/pull/9036
2022-06-23 03:34:51 -04:00
Viktor Szakats 70adb81c6f
rand: stop detecting /dev/urandom in cross-builds
- Prevent CMake to auto-detect /dev/urandom when cross-building.
  Before this patch, it would detect it in a cross-build scenario on *nix
  hosts with this device present. This was a problem for example with
  Windows builds, but it could affect any target system with this device
  missing. This also syncs detection behaviour with autotools, which also
  skips it for cross-builds.
- Also, make sure to never use the file RANDOM_FILE as entropy for libcurl's
  fallback random number generator on Windows. Windows does not have the
  concept of reading a random stream from a filename, nor any guaranteed
  non-world-writable path on disk. With this, a manual misconfiguration or
  an overeager auto-detection can no longer result in a user-controllable
  seed source.

Reviewed-by: Daniel Stenberg
Closes #9038
2022-06-22 09:35:46 +00:00
Viktor Szakats 6c501cb624
Makefile.m32: stop forcing XP target with ipv6 enabled [ci skip]
Since this [1] commit in 2011, `_WIN32_WINNT` was set fixed to Windows
XP when the `-ipv6` option is selected. Maybe this was added to support
pre-XP Windows versions (?). These days libcurl builds fine for both XP
and post-XP versions with IPv6 support enabled. The relevance of pre-XP
version is also low by now. Other build methods also do not impose such
limitation for a similar configuration. So, drop this hard-wired
`_WIN32_WINNT` limit from `Makefile.m32`, thus building for the default
Windows version set by the compiler. This is Vista for recent MinGW
versions.

Old behaviour can be restored by setting this envvar:
export CURL_CFLAG_EXTRAS=-D_WIN32_WINNT=0x0501

[1] 98a61d8e2e

Closes #9035
2022-06-22 00:06:48 +00:00
Daniel Stenberg d5dc3629eb
easy: remove dead code
Follow-up from 5912da253b

Detected by Coverity (CID 1506519)

Closes #9029
2022-06-20 10:44:28 +02:00
Glenn Strauss 7f43f3dc59
transfer: upload performance; avoid tiny send
Append to the upload buffer when only small amount remains in buffer
rather than performing a separate tiny send to empty buffer.

Avoid degenerative upload behavior which might cause curl to send mostly
1-byte DATA frames after exhausing the h2 send window size

Related discussion: https://github.com/nghttp2/nghttp2/issues/1722

Signed-off-by: Glenn Strauss <gstrauss@gluelogic.com>
Closes #8965
2022-06-20 09:42:40 +02:00
Pierrick Charron 4bf2c231d7
urlapi: make curl_url_set(url, CURLUPART_URL, NULL, 0) clear all parts
As per the documentation :

> Setting a part to a NULL pointer will effectively remove that
> part's contents from the CURLU handle.

But currently clearing CURLUPART_URL does nothing and returns
CURLUE_OK. This change will clear all parts of the URL at once.

Closes #9028
2022-06-20 08:15:51 +02:00
Jay Satiro a8a4abb2ae vtls: make curl_global_sslset thread-safe
.. and update some docs to explain curl_global_* is now thread-safe.

Follow-up to 23af112 which made curl_global_init/cleanup thread-safe.

Closes https://github.com/curl/curl/pull/9016
2022-06-16 03:18:40 -04:00
Daniel Stenberg ef22d5c42a
libssh: skip the fake-close when libssh does the right thing
Starting in libssh 0.10.0 ssh_disconnect() will no longer close our
socket. Instead it will be kept alive as we want it, and it is our
responsibility to close it later.

Ref: #8718
Ref: https://gitlab.com/libssh/libssh-mirror/-/merge_requests/240
Closes #9021
2022-06-15 23:43:35 +02:00
Viktor Szakats a94d6fe706
version: rename threadsafe-init to threadsafe
Referring to Daniel's article [1], making the init function thread-safe
was the last bit to make libcurl thread-safe as a whole. So the name of
the feature may as well be the more concise 'threadsafe', also telling
the story that libcurl is now fully thread-safe, not just its init
function. Chances are high that libcurl wants to remain so in the
future, so there is little likelihood of ever needing any other distinct
`threadsafe-<name>` feature flags.

For consistency we also shorten `CURL_VERSION_THREADSAFE_INIT` to
`CURL_VERSION_THREADSAFE`, update its description and reference libcurl's
thread safety documentation.

[1]: https://daniel.haxx.se/blog/2022/06/08/making-libcurl-init-more-thread-safe/

Reviewed-by: Daniel Stenberg
Reviewed-by: Jay Satiro
Closes #8989
2022-06-13 18:59:45 +00:00
Daniel Stenberg be632e23df
easy_lock: add SPDX license identifier
Closes #8998
2022-06-13 09:36:25 +02:00
max.mehl ad9bc5976d
copyright: make repository REUSE compliant
Add licensing and copyright information for all files in this repository. This
either happens in the file itself as a comment header or in the file
`.reuse/dep5`.

This commit also adds a Github workflow to check pull requests and adapts
copyright.pl to the changes.

Closes #8869
2022-06-13 09:13:00 +02:00
Viktor Szakats dd94076947
ngtcp2: fix typo in preprocessor condition
Ref: 927ede7edc

Bug: https://github.com/curl/curl/pull/8981#discussion_r894312185
Reported-by: Emil Engler
Closes #8987
2022-06-10 23:07:15 +00:00
Tatsuhiro Tsujikawa 927ede7edc
ngtcp2: build without sendmsg
Closes #8981
2022-06-10 09:10:54 +02:00
Tatsuhiro Tsujikawa d2c6d8be18
ngtcp2: use handshake helper funcs to simplify TLS handshake integration
Closes #8968
2022-06-10 09:07:33 +02:00
Daniel Stenberg 90a7017acb
url: URL encode the path when extracted, if spaces were set 2022-06-08 16:32:46 +02:00
Daniel Stenberg c3fc406ebb
urlapi: support CURLU_URLENCODE for curl_url_get() 2022-06-08 16:32:46 +02:00
Daniel Stenberg 5912da253b
select: return error from "lethal" poll/select errors
Adds two new error codes: CURLE_UNRECOVERABLE_POLL and
CURLM_UNRECOVERABLE_POLL one each for the easy and the multi interfaces.

Reported-by: Harry Sintonen
Fixes #8921
Closes #8961
2022-06-08 11:07:01 +02:00
Daniel Stenberg 07058f6ad8
transfer: maintain --path-as-is after redirects
Reported-by: Marcus T
Fixes #8974
Closes #8975
2022-06-08 10:30:36 +02:00
Thomas Guillem 2ed1012564
curl_version_info: add CURL_VERSION_THREADSAFE_INIT
This flag can be used to make sure that curl_global_init() is
thread-safe.

This can be useful for libraries that can't control what other
dependencies are doing with Curl.

Closes #8680
2022-06-07 13:34:03 +02:00
Thomas Guillem 23af112f55
lib: make curl_global_init() threadsafe when possible
Use a posix pthread or a Windows SRWLOCK to lock curl_global_init*() and
curl_global_cleanup().

Closes #8680
2022-06-07 13:34:03 +02:00
Daniel Stenberg 6754f99398
ftp: when failing to do a secure GSSAPI login, fail hard
... instead of switching to cleartext. For the sake of security.

Reported-by: Harry Sintonen
Bug: https://hackerone.com/reports/1590102
Closes #8963
2022-06-06 11:55:39 +02:00
Daniel Stenberg 21ea13cfe1
http2: reject overly many push-promise headers
Getting more than a thousand of them is rather a sign of some kind of
attack.

Reported-by: Harry Sintonen
Bug: https://hackerone.com/reports/1589847
Closes #8962
2022-06-06 11:53:49 +02:00
Fabian Keil 9dbce9b3d0
misc: spelling improvements
Closes #8956
2022-06-05 12:15:23 +02:00
Tatsuhiro Tsujikawa 298c1dfc7b
ngtcp2: fix assertion failure on EMSGSIZE
Closes #8958
2022-06-05 12:12:26 +02:00
Daniel Stenberg 2bd75e5686
easy/transfer: fix cookie-disabled build
Follow-up from 45de940ceb
Reported-by: Marcel Raad
Fixes #8953
Closes #8954
2022-06-02 22:54:12 +02:00
Wolf Vollprecht 4d4eb8e587
netrc: check %USERPROFILE% as well on Windows
Closes #8855
2022-06-02 09:32:51 +02:00
michael musset 1544513958
libssh2: add CURLOPT_SSH_HOSTKEYFUNCTION
The callback set by CURLOPT_SSH_HOSTKEYFUNCTION is called to check
wether or not the connection should continue.

The host key is passed in argument with a custom handle for the
application.

It overrides CURLOPT_SSH_KNOWNHOSTS

Closes #7959
2022-06-02 08:34:31 +02:00
Evgeny Grin f59508e6cd
digest: tolerate missing "realm"
Server headers may not define "realm", avoid NULL pointer dereference
in such cases.

Closes #8912
2022-06-02 08:18:54 +02:00
Evgeny Grin 807f440301
digest: added detection of more syntax error in server headers
Invalid headers should not be processed otherwise they may create
a security risk.

Closes #8912
2022-06-02 08:18:48 +02:00
Evgeny Grin 3a6fe0c767
digest: unquote realm and nonce before processing
RFC 7616 (and 2617) requires values to be "unquoted" before used for
digest calculations. The only place where unquoting can be done
correctly is header parsing function (realm="DOMAIN\\host" and
realm=DOMAN\\host are different realms).

This commit adds unquoting (de-escaping) of all values during header
parsing and quoting of the values during header forming. This approach
should be most straightforward and easy to read/maintain as all values
are processed in the same way as required by RFC.

Closes #8912
2022-06-02 08:18:34 +02:00
Daniel Stenberg f810047f9d
headers: handle unfold of space-cleansed headers
Detected by OSS-fuzz

Bug: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=47767

Updated test 1274

Closes #8947
2022-06-01 15:24:49 +02:00
Daniel Stenberg 45de940ceb
lib: make more protocol specific struct fields #ifdefed
... so that they don't take up space if the protocols are disabled in
the build.

Closes #8944
2022-06-01 14:31:49 +02:00
Daniel Stenberg 8b1ae28509
urldata: store tcp_keepidle and tcp_keepintvl as ints
They can't be set larger than INT_MAX in the setsocket API calls.

Also document the max values in their respective man pages.

Closes #8940
2022-06-01 08:12:09 +02:00
Daniel Stenberg 4651945822
urldata: reduce size of a few struct fields
When the values are never larger than 32 bit, ints are better than longs.

Closes #8940
2022-06-01 08:12:09 +02:00
Daniel Stenberg b1c1df0b6b
urldata: remove three unused booleans from struct UserDefined
- is_fwrite_set
- free_referer
- strip_path_slash

Closes #8940
2022-06-01 08:12:09 +02:00
Tatsuhiro Tsujikawa 3288e9c6d3
ngtcp2: enable Linux GSO
Enable Linux GSO in ngtcp2 QUIC.  In order to recover from the
EAGAIN/EWOULDBLOCK by sendmsg with multiple packets in one GSO write,
packet buffer is now held by struct quicsocket.  GSO write might fail in
runtime depending on NIC.  Disable GSO if sendmsg returns EIO.

Closes #8909
2022-05-31 16:04:12 +02:00
Daniel Stenberg b7baa78451
headers_push: error out if a folded header has no previous header
As that would indicate an illegal header. The fuzzer reached the assert
in unfold_value() proving that this case can happen.

Follow-up to c9b60f0053

Closes #8939
2022-05-31 14:03:44 +02:00
Daniel Stenberg eeaae10c0f
netrc: support quoted strings
The .netrc parser now accepts strings within double-quotes in order to
deal with for example passwords containing white space - which
previously was not possible.

A password that starts with a double-quote also ends with one, and
double-quotes themselves are escaped with backslashes, like \". It also
supports \n, \r and \t for newline, carriage return and tabs
respectively.

If the password does not start with a double quote, it will end at first
white space and no escaping is performed.

WARNING: this change is not entirely backwards compatible. If anyone
previously used a double-quote as the first letter of their password,
the parser will now get it differently compared to before. This is
highly unfortunate but hard to avoid.

Reported-by: ImpatientHippo on GitHub
Fixes #8908
Closes #8937
2022-05-31 09:04:56 +02:00
Daniel Stenberg 4d94fac9f0
headers api: remove EXPERIMENTAL tag
Closes #8900
2022-05-30 14:13:48 +02:00
Daniel Gustafsson 739275a1d9 cookies: fix documentation comment
Commit 4073cd83b2 added the noexpire parameter to Curl_cookie_add but
missed updating the documentation comment at the head of the file.
2022-05-30 13:46:25 +02:00
Viktor Szakats a77d14d22a
cmake: do not add libcurl.rc to the static libcurl library
Fixes: https://github.com/curl/curl/pull/8918#issuecomment-1138263855

Reviewed-By: Karlson2k@users.noreply.github.com
Closes #8923
2022-05-26 15:54:47 +00:00
Daniel Stenberg b67dcc8ed7
c-hyper: mark status line as status for Curl_client_write()
To make sure the headers API can filter it out as not a regular header.

Reported-by: Gisle Vanem
Fixes #8894
Closes #8914
2022-05-25 13:07:12 +02:00
Daniel Stenberg 5bf1ff002d
headers: fix the unfold realloc to use proper new size
Previously it didn't take the old name length into acount

Follow-up to: c9b60f0053
Closes #8913
2022-05-25 11:56:25 +02:00
Daniel Stenberg c9b60f0053
http: restore header folding behavior
Folded header lines will now get passed through like before. The headers
API is adapted and will provide the content unfolded.

Added test 1274 and extended test 1940 to verify.

Reported-by: Petr Pisar
Fixes #8844
Closes #8899
2022-05-24 23:33:47 +02:00
Viktor Szakats 16a58e9f93
Makefile.m32: delete obsolete options, improve -On [ci skip]
- `-D_AMD64_` has not been necessary for mingw-w64 builds for a long time now.
- `-fno-strict-aliasing` is mentioned for Intel C compiler in autotools, and
  I used this with VxWorks in another project, but otherwise this isn't
  necessary anymore as a default. If a target still needs it, it can be
  added with `CURL_CFLAG_EXTRAS=-fno-strict-aliasing`
- bump up default optimization level to `-O3` (from `-O2`), and also rearrange
  option order so the default can now be overridden via
  `CURL_CFLAG_EXTRAS`.
- delete `-g` (generate debug info) from `CFLAGS` and `-s` from `LDFLAGS`
  (strip debug info). They were working against each other. Now, if someone
  needs debug info, it can be enabled via `CURL_CFLAG_EXTRAS=-g`

Closes #8904
2022-05-24 17:04:38 +00:00
Daniel Gustafsson e70928b091 doh: remove UNITTEST macro definition
The UNITTEST macro is defined by curl_setup.h so there is no use in
carry a local copy of the logic.

Closes: #8902
Reviewed-by: Daniel Stenberg <daniel@haxx.se>
2022-05-24 12:46:22 +02:00
Daniel Stenberg dcaae6bb5b
cookie: fix false positive "potentially uninitialized local variable"
Reviewed-by: Daniel Gustafsson
Closes #8903
2022-05-24 12:16:08 +02:00
Daniel Stenberg 5a4dbb8ae3
hyper: use 'alt-used'
Makes test 412+413 work

Closes #8898
2022-05-23 16:47:17 +02:00
Daniel Stenberg 7bc785387d
CURLINFO_CAPATH/CAINFO: get the default CA paths from libcurl
Closes #8888
2022-05-23 08:44:29 +02:00
Daniel Stenberg 3c8b969de6
links: update dead links
The wiki pages are gone, remove and link to more long-living docs.

Closes #8897
2022-05-23 08:40:13 +02:00
Daniel Stenberg 216636a4ce
ntlm: (void) typecast msnprintf() where we ignore return code
Follow-up to 5a41abef6, to please Coverity
2022-05-23 08:13:48 +02:00
Daniel Gustafsson 5a41abef6d ntlm: copy NTLM_HOSTNAME to host buffer
Commit 709ae2454f added a fake hostname to avoid leaking the local
hostname, but omitted copying it to the host buffer.  Fix by copying
and adjust the test fallout.

Closes: #8895
Fixes: #8893
Reported-by: Patrick Monnerat <patrick@monnerat.net>
Reviewed-by: Daniel Stenberg <daniel@haxx.se>
2022-05-22 23:26:24 +02:00
Tatsuhiro Tsujikawa 8ea851b29d
ngtcp2: Allow curl to send larger UDP datagrams
Allow curl to send larger UDP datagram if Path MTU Discovery finds the
availability of larger path MTU.  To make it work and not to send
fragmented packet, we need to set DF bit.  That makes send(2) fail with
EMSGSIZE if UDP datagram is too large.  In that case, just let it be
lost.  This patch enables DF bit for Linux only.

Closes #8883
2022-05-20 17:50:38 +02:00
Daniel Stenberg 709ae2454f
ntlm: provide a fixed fake host name
The NTLM protocol includes providing the local host name, but apparently
other implementations already provide a fixed fake name instead to avoid
leaking the real local name.

The exact name used is 'WORKSTATION', because Firefox uses that.

The change is written to allow someone to "back-pedal" fairly easy in
case of need.

Reported-by: Carlo Alberto
Fixes #8859
Closes #8889
2022-05-20 16:24:13 +02:00
Daniel Stenberg a7a18d7589
wolfssl: correct the failf() message when a handle can't be made
Closes #8885
2022-05-19 19:05:17 +02:00
Viktor Szakats a820c55a72
Makefile.m32: delete two obsolete OpenSSL options [ci skip]
- -DOPENSSL_NO_KRB5: No longer used by OpenSSL 1.1.x, 3.x, or
  LibreSSL 3.5.x, yet it collides with the latter, which defines
  it unconditionally, resulting in this warning:
    ../../libressl/include/openssl/opensslfeatures.h:14:9: warning: 'OPENSSL_NO_KRB5' macro redefined [-Wmacro-redefined]
  It was originally added to curl in 2004.

- -DHAVE_OPENSSL_PKCS12_H: No longer used by OpenSSL 1.1.x, 3.x, or
  LibreSSL back to at least 2.5.5. Originally added in the same
  commit as the above, in 2004.

Closes #8884
2022-05-19 16:47:54 +00:00
Balakrishnan Balasubramanian dfa84a0450
socks: support unix sockets for socks proxy
Usage:
  curl -x "socks5h://localhost/run/tor/socks" "https://example.com"

Updated runtests.pl to run a socksd server listening on unix socket

Added tests test1467 test1468

Added documentation for proxy command line option and socks proxy
options

Closes #8668
2022-05-19 15:35:03 +02:00
Vincent Torri ee52bead4d
cmake: add libpsl support
Fixes #8865
Closes #8867
2022-05-19 15:29:55 +02:00
Tatsuhiro Tsujikawa 9accb9a5be
ngtcp2: extend QUIC transport parameters buffer
Extend QUIC transport parameters buffer because 64 bytes are too
short for the ever increasing parameters.

Closes #8872
2022-05-19 14:56:50 +02:00
Tatsuhiro Tsujikawa 136ab928c8
ngtcp2: handle error from ngtcp2_conn_submit_crypto_data
Closes #8871
2022-05-19 14:55:37 +02:00
Tatsuhiro Tsujikawa fe1d00e71b
ngtcp2: send appropriate connection close error code
Closes #8870
2022-05-19 14:54:46 +02:00
Harry Sintonen e9a8451a3b
cookie: address secure domain overlay
Bug: https://hackerone.com/reports/1560324
Co-authored-by: Daniel Stenberg
Closes #8840
2022-05-19 14:48:26 +02:00
Frank Gevaerts b12c2b91df
strcase: some optimisations
Lookup tables for toupper() and tolower() make Curl_strcasecompare()
about 1.5 times faster. Reorganising Curl_strcasecompare() to fully exit
early then also allows simplifying the check at the end, for another
15%. In total, the changes make Curl_strcasecompare() around 1.6 to 1.7
times faster.

Note that these optimisation assume ASCII. The original
Curl_raw_toupper() and raw_tolower() look like they already made that
assumption.

Closes #8875
2022-05-19 12:03:57 +02:00
Daniel Stenberg 0842936292
lib/vssh/wolfssh.h: removed
Unused header file

Reported-by: Illarion Taev
Fixes #8863
Closes #8866
2022-05-17 17:31:02 +02:00
Elms 835a205370
wolfSSL: explicitly use compatibility layer
This change removes adding an include `$prefix/wolfssl` or similar to
allow for openssl include aliasing. Include paths of `wolfssl/openssl/`
are used to explicitly use wolfSSL includes. This fixes cmake builds as
well as avoiding potentially using openSSL headers since include path
order is not guaranteed.

Closes #8864
2022-05-17 16:58:03 +02:00
Daniel Stenberg 8d86718f3f
opts: deprecate RANDOM_FILE and EGDSOCKET
These two options were only ever used for the OpenSSL backend for
versions before 1.1.0. They were never used for other backends and they
are not used with recent OpenSSL versions. They were never used much by
applications.

The defines RANDOM_FILE and EGD_SOCKET can still be set at build-time
for ancient EOL OpenSSL versions.

Closes #8670
2022-05-17 11:05:54 +02:00
Harry Sintonen 1b3dcaed9f
bindlocal: don't use a random port if port number would wrap
Earlier if CURLOPT_LOCALPORT + CURLOPT_LOCALPORTRANGE would go past port
65535 the code would fall back to random port rather than giving up.

Closes #8862
2022-05-17 08:53:25 +02:00
Daniel Gustafsson 542c78dda7 transfer: Fix potential NULL pointer dereference
Commit 0ef54abf52 accidentally used the conn variable before the
assertion for it being NULL. Fix by moving the assignment which use
conn to after the assertion.

Closes: #8857
Reviewed-by: Daniel Stenberg <daniel@haxx.se>
2022-05-16 21:18:46 +02:00
vvb2060 on github adde9f0e8c
ngtcp2: support boringssl crypto backend
Closes #8789
2022-05-16 18:21:54 +02:00
Tatsuhiro Tsujikawa 6fcd3e6f51
quic: add Curl_quic_idle
Add Curl_quic_idle which is called when no HTTP level read or write is
performed.  It is a good place to handle timer expiry for QUIC transport
(.e.g, retransmission).

Closes #8698
2022-05-16 18:19:08 +02:00
Gregor Jasny 53678992d5
mprintf: ignore clang non-literal format string
Closes #8740
2022-05-16 18:18:12 +02:00
Nick Zitzmann e0b43c8eb9
sectransp: check for a function defined when __BLOCKS__ is undefined
SecTrustEvaluateAsync() is defined in the macOS 10.7 SDK, but it
requires Grand Central Dispatch to be supported by the compiler, and
some third-party macOS compilers do not support Grand Central Dispatch.
SecTrustCopyPublicKey() is not present in macOS 10.6, so this shouldn't
adversely affect anything.

Fixes #8846
Reported-by: Egor Pugin
Closes #8854
2022-05-16 18:15:04 +02:00
Tatsuhiro Tsujikawa 5980068c87
ngtcp2: Correct use of ngtcp2 and nghttp3 signed integer types
Closes #8851
2022-05-16 10:02:50 +02:00
Tatsuhiro Tsujikawa 33e819d799
ngtcp2: Fix alert_read_func return value
Closes #8852
2022-05-16 09:57:37 +02:00
Harry Sintonen 8540f95444
Curl_parsenetrc: don't access local pwbuf outside of scope
Accessing local variables outside of the scope is forbidden and
depending on the compiler can result in the value being
overwritten. Fixed by moving the pwbuf to be in scope.

Closes #8850
2022-05-16 09:56:26 +02:00
Daniel Stenberg 06d12105c7
url: free old conn better on reuse
Make use of conn_free() better and avoid duplicate code.

Reported-by: Andrea Pappacoda
Fixes #8841
Closes #8842
2022-05-14 18:05:20 +02:00
Daniel Gustafsson f1cdeff37a gssapi: initialize gss_buffer_desc strings
Explicitly initialize gss_buffer_desc strings such that a call to
freeing resources will succeed even if no data has been allocated
to it.

Reported-by: Jay Satiro <raysatiro@yahoo.com>
2022-05-12 14:12:41 +02:00
Daniel Gustafsson 7360f9a565 gssapi: improve handling of errors from gss_display_status
In case gss_display_status() returns an error, avoid trying to add
it to the buffer as the message may well be a NULL pointer.

Originally this fix comes from a discussion in issue #8816.

Closes: #8832
Reviewed-by: Jay Satiro <raysatiro@yahoo.com>
2022-05-12 14:11:52 +02:00
steini2000 f9bc378ab7 http2: always debug print stream id in decimal with %u
Prior to this change the stream id shown could be hex or decimal which
was inconsistent and confusing.

Closes https://github.com/curl/curl/pull/8808
2022-05-12 01:31:32 -04:00
Kamil Dudka 9494cdc3d2 url: remove redundant #ifdefs in allocate_conn()
No change in behavior intended by this commit.
2022-05-11 15:51:29 +02:00
Daniel Gustafsson 37f892fb8c aws-sigv4: fix potentional NULL pointer arithmetic
We need to check if the strchr() call returns NULL (due to missing
char) before we use the returned value in arithmetic.  There is no
live bug here, but fixing it before it can become for hygiene.

Closes: #8814
Reviewed-by: Daniel Stenberg <daniel@haxx.se>
2022-05-11 10:52:56 +02:00
Daniel Stenberg fdb5e21b4d
quiche: support ca-fallback
Follow-up to b01f3e679f which added this for ngtcp2/openssl

Removed from KNOWN_BUGS

Fixes #8696
Closes #8830
2022-05-11 10:49:31 +02:00
Daniel Gustafsson bcf03dd213 x509asn1: mark msnprintf return as unchecked
We have lots of unchecked msnprintf calls, and this particular msnprintf
call isn't more interesting than the others, but this one yields a Coverity
warning so let's implicitly silence it. Going over the other invocations
is probably a worthwhile project, but for now let's keep the static
analyzers happy.

Closes: #8831
Reviewed-by: Daniel Stenberg <daniel@haxx.se>
2022-05-11 10:38:08 +02:00
Tatsuhiro Tsujikawa b01f3e679f
ngtcp2: add ca-fallback support for OpenSSL backend
Closes #8828
2022-05-10 09:43:08 +02:00
Daniel Stenberg 1645e9b445
url: check SSH config match on connection reuse
CVE-2022-27782

Reported-by: Harry Sintonen
Bug: https://curl.se/docs/CVE-2022-27782.html
Closes #8825
2022-05-09 23:13:53 +02:00
Daniel Stenberg f18af4f874
tls: check more TLS details for connection reuse
CVE-2022-27782

Reported-by: Harry Sintonen
Bug: https://curl.se/docs/CVE-2022-27782.html
Closes #8825
2022-05-09 23:13:53 +02:00
Daniel Stenberg 7e92d12b4e
cookies: make bad_domain() not consider a trailing dot fine
The check for a dot in the domain must not consider a single trailing
dot to be fine, as then TLD + trailing dot is fine and curl will accept
setting cookies for it.

CVE-2022-27779

Reported-by: Axel Chong
Bug: https://curl.se/docs/CVE-2022-27779.html
Closes #8820
2022-05-09 16:47:28 +02:00
Daniel Stenberg fae6fea209
hsts: ignore trailing dots when comparing hosts names
CVE-2022-30115

Reported-by: Axel Chong
Bug: https://curl.se/docs/CVE-2022-30115.html
Closes #8821
2022-05-09 12:54:39 +02:00
Daniel Stenberg 914aaab915
urlapi: reject percent-decoding host name into separator bytes
CVE-2022-27780

Reported-by: Axel Chong
Bug: https://curl.se/docs/CVE-2022-27780.html
Closes #8826
2022-05-09 12:50:34 +02:00
Daniel Stenberg 5c7da89d40
nss: return error if seemingly stuck in a cert loop
CVE-2022-27781

Reported-by: Florian Kohnhäuser
Bug: https://curl.se/docs/CVE-2022-27781.html
Closes #8822
2022-05-09 10:07:15 +02:00
Daniel Stenberg a1d23f287e
altsvc: fix host name matching for trailing dots
Closes #8819
2022-05-09 09:39:15 +02:00
Garrett Squire 652fd3fab8
hyper: fix test 357
This change fixes the hyper API such that PUT requests that receive a
417 response can retry without the Expect header.

Closes #8811
2022-05-08 23:19:05 +02:00
Harry Sintonen 4fc35c829c
sectransp: bail out if SSLSetPeerDomainName fails
Before the code would just warn about SSLSetPeerDomainName() errors.

Closes #8798
2022-05-06 16:25:20 +02:00
Daniel Stenberg a8a1dd8ecc
http_proxy/hyper: handle closed connections
Enable test 1021 for hyper builds.

Patched-by: Prithvi MK
Fixes #8700
Closes #8806
2022-05-06 11:01:54 +02:00
Jay Satiro 6285957f1d mbedtls: fix some error messages
Prior to this change some of the error messages misidentified the
function that failed.
2022-05-05 03:13:24 -04:00
Sergey Markelov 137a668e8c
x509asn1: make do_pubkey handle EC public keys
Closes #8757
2022-05-05 08:44:23 +02:00
Harry Sintonen d7fb9ab7ce
mbedtls: bail out if rng init fails
There was a failf() call but no actual error return.

Closes #8796
2022-05-05 08:40:38 +02:00
Sergey Markelov b5b86856a9
urlapi: address (harmless) UndefinedBehavior sanitizer warning
`while(i--)` causes runtime error: unsigned integer overflow: 0 - 1
cannot be represented in type 'size_t' (aka 'unsigned long')

Closes #8797
2022-05-05 08:38:06 +02:00
Harry Sintonen 1a78051732
gskit_connect_step1: fixed bogus setsockopt calls
setsockopt takes a reference to value, not value. With the current
code this just leads to -1 return value with errno EFAULT.

Closes #8793
2022-05-04 23:33:17 +02:00
Daniel Gustafsson 79939ec18a gskit: remove unused function set_callback
This function has been unused since the initial commit of the GSKit
backend in 0eba02fd4.  The motivation for the code was getting the
whole certificate chain: the only place where the latter is available
is as a callback parameter.  Unfortunately it is not possible to pass
a user pointer to this callback, which precludes the possibility to
associate the cert chain with a data/conn structure.

For further information, search for pgsk_cert_validation_callback on:
https://www.ibm.com/docs/api/v1/content/ssw_ibm_i_71/apis/gsk_attribute_set_callback.htm

As the upstream library never added a parameter like that to the API,
we give up the wait and remove the dead code.

Closes: #8782
Reviewed-by: Patrick Monnerat <patrick@monnerat.net>
2022-05-01 22:59:25 +02:00
Yusuke Nakamura 2e2767a378
msh3: get msh3 version from MsH3Version
Closes #8762
2022-04-30 10:51:22 +02:00
Yusuke Nakamura 279dfb620b
msh3: psss remote_port to MsH3ConnectionOpen
MsH3 supported additional "Port" parameter to connect not hosted on
443 port QUIC website.

* https://github.com/nibanks/msh3/releases/tag/v0.3.0
* https://github.com/nibanks/msh3/pull/37

Closes #8762
2022-04-30 10:51:09 +02:00
Christian Weisgerber a3cf94f3ef
openssl: define HAVE_SSL_CTX_SET_EC_CURVES for libressl
SSL_CTX_set1_curves_list() has been available since LibreSSL 2.5.3,
released five years ago.

Bug: https://curl.se/mail/lib-2022-04/0059.html
Closes #8773
2022-04-29 23:02:45 +02:00
Daniel Stenberg d7b970e46b
http: move Curl_allow_auth_to_host()
It was mistakenly put within the CURL_DISABLE_HTTP_AUTH #ifdef

Reported-by: Michael Olbrich
Fixes #8772
Closes #8775
2022-04-29 22:56:47 +02:00
Daniel Gustafsson 59d89286d4 msh3: print boolean value as text representation
Print the boolean value as its string representation instead of with
%hhu which isn't a format we typically use.

Closes: #8763
Reviewed-by: Nick Banks <nibanks@microsoft.com>
2022-04-29 11:40:25 +02:00
Daniel Stenberg 6eb7fb37d9
mbedtls: fix compile when h2-enabled
Fixes #8766
Reported-by: LigH-de on github
Closes #8768
2022-04-28 17:11:50 +02:00
Adam Rosenfield e07a9b668a
conn: fix typo 'connnection' -> 'connection' in two function names
Closes #8759
2022-04-27 11:50:13 +02:00
Daniel Stenberg 0935315562
gnutls: don't leak the SRP credentials in redirects
Follow-up to 620ea21410 and 139a54ed0a

Reported-by: Harry Sintonen
Closes #8752
2022-04-26 07:46:20 +02:00
Daniel Stenberg 139a54ed0a
openssl: don't leak the SRP credentials in redirects either
Follow-up to 620ea21410

Reported-by: Harry Sintonen
Closes #8751
2022-04-25 22:34:40 +02:00
Liam Warfield aad7d9f9a6
hyper: fix tests 580 and 581 for hyper
Hyper now has the ability to preserve header order. This commit adds a
few lines setting the connection options for this feature.

Related to issue #8617
Closes #8707
2022-04-25 17:33:08 +02:00
Daniel Stenberg 030adbceeb
conncache: remove name arg from Curl_conncache_find_bundle
To simplify, and also since the returned name is not the full actual
name used for the check. The port number and zone id is also involved,
so just showing the name is misleading.

Closes #8750
2022-04-25 16:25:42 +02:00
Daniel Stenberg 620ea21410
transfer: redirects to other protocols or ports clear auth
... unless explicitly permitted.

Bug: https://curl.se/docs/CVE-2022-27774.html
Reported-by: Harry Sintonen
Closes #8748
2022-04-25 16:24:33 +02:00
Daniel Stenberg 08b8ef4e72
connect: store "conn_remote_port" in the info struct
To make it available after the connection ended.
2022-04-25 16:24:33 +02:00
Daniel Stenberg 6e65999395
http: avoid auth/cookie on redirects same host diff port
CVE-2022-27776

Reported-by: Harry Sintonen
Bug: https://curl.se/docs/CVE-2022-27776.html
Closes #8749
2022-04-25 13:05:40 +02:00
Daniel Stenberg 8f2079154f
libssh2: make the md5 comparison fail if wrong length
Making it just skip the check unless exactly 32 is too brittle. Even if
the docs says it needs to be exactly 32, it is be safer to make the
comparison fail here instead.

Reported-by: Harry Sintonen
Bug: https://hackerone.com/reports/1549461
Closes #8745
2022-04-25 13:01:20 +02:00
Daniel Stenberg 058f98dc3f
conncache: include the zone id in the "bundle" hashkey
Make connections to two separate IPv6 zone ids create separate
connections.

Reported-by: Harry Sintonen
Bug: https://curl.se/docs/CVE-2022-27775.html
Closes #8747
2022-04-25 11:48:00 +02:00
Patrick Monnerat 852aa5ad35
url: check sasl additional parameters for connection reuse.
Also move static function safecmp() as non-static Curl_safecmp() since
its purpose is needed at several places.

Bug: https://curl.se/docs/CVE-2022-22576.html

CVE-2022-22576

Closes #8746
2022-04-25 11:44:05 +02:00
Daniel Stenberg ff2f3e8367
libssh2: compare sha256 strings case sensitively
Reported-by: Harry Sintonen
Bug: https://hackerone.com/reports/1549435
Closes #8744
2022-04-25 11:41:20 +02:00
Tatsuhiro Tsujikawa ca94497a82
ngtcp2: deal with sub-millisecond timeout
Closes #8738
2022-04-25 11:37:18 +02:00
Daniel Stenberg 4ec0549c39
misc: update copyright year ranges 2022-04-25 09:31:09 +02:00
Tatsuhiro Tsujikawa 458c4b1df7
ngtcp2: avoid busy loop in low CWND situation
Closes #8739
2022-04-24 23:21:27 +02:00
Daniel Gustafsson e498a9b1fe macos: set .plist version in autoconf
Set the libcurl version in libcurl.plist like how libcurl.vers is
created.

Closes: #8692
Reviewed-by: Daniel Stenberg <daniel@haxx.se>
Reviewed-by: Nick Zitzmann <nickzman@gmail.com>
2022-04-20 15:26:13 +02:00
Daniel Gustafsson a6cdfd24ee cookies: Improve errorhandling for reading cookiefile
The existing programming had some issues with errorhandling for reading
the cookie file. If the file failed to open, we would silently ignore it
and continue as if there was no file (or stdin) passed. In this case, we
would also call fclose() on the NULL FILE pointer, which is undefined
behavior. Fix by ensuring that the FILE pointer is set before calling
fclose on it, and issue a warning in case the file cannot be opened.
Erroring out on nonexisting file would break backwards compatibility of
very old behavior so we can't really go there.

Closes: #8699
Reviewed-by: Daniel Stenberg <daniel@haxx.se>
Reviewed-by: Jay Satiro <raysatiro@yahoo.com>
2022-04-20 14:17:29 +02:00
Jay Dommaschk c4d032af2a
libssh: fix double close
libssh closes the socket in ssh_diconnect() so make sure that libcurl
does not also close it.

Fixes #8708
Closes #8718
2022-04-20 09:12:36 +02:00
Marc Hoersken 68035af29d
timediff.[ch]: add curlx helper functions for timeval conversions
Also move timediff_t definitions from timeval.h to timediff.h and
then make timeval.h include the new standalone-capable timediff.h.

Reviewed-by: Jay Satiro
Reviewed-by: Daniel Stenberg

Supersedes #5888
Closes #8595
2022-04-17 13:11:27 +02:00
Daniel Stenberg 6968fb9d54
lib: remove exclamation marks
... from infof() and failf() calls. Make them less attention seeking.

Closes #8713
2022-04-16 11:55:05 +02:00
Daniel Gustafsson 34bbf96475 infof: consistent capitalization of warning messages
Ensure that all infof calls with a warning message are capitalized
in the same way.  At some point we should probably set up a style-
guide for infof but until then let's aim for a little consistenncy
where we can.

Closes: #8711
Reviewed-by: Daniel Stenberg <daniel@haxx.se>
2022-04-14 21:13:29 +02:00
Tatsuhiro Tsujikawa cd29c1651e
ngtcp2: fix memory leak
Closes #8691
2022-04-10 23:10:21 +02:00
Tatsuhiro Tsujikawa fa25dab7fd
ngtcp2: remove remote_addr which is not used in a meaningful way
Closes #8689
2022-04-10 23:09:41 +02:00
Tatsuhiro Tsujikawa f15beb6f30
ngtcp2: enlarge H3_SEND_SIZE
Make h3_SEND_SIZE larger because current value (20KiB) is too small
for the high latency environment.

Closes #8690
2022-04-10 23:08:33 +02:00
Tatsuhiro Tsujikawa 990bfdd7bc
ngtcp2: fix HTTP/3 upload stall and avoid busy loop
This commit fixes HTTP/3 upload stall if upload data is larger than
H3_SEND_SIZE.  Only check writability of socket if a stream is
writable to avoid busy loop when QUIC flow control window is filled
up, or upload buffer is full.

Closes #8688
2022-04-10 23:07:42 +02:00
Nick Banks 37492ebbfa
msh3: add support for QUIC and HTTP/3 using msh3
Considered experimental, as the other HTTP/3 backends.

Closes #8517
2022-04-10 18:23:04 +02:00
Daniel Stenberg fbba7dd796
schannel: remove dead code that will never run
As the condition can't ever evaluate true

Reported-by: Andrey Alifanov
Ref: #8675
Closes #8677
2022-04-06 08:33:20 +02:00
Daniel Stenberg d4cf98bbd1
connecache: remove duplicate connc->closure_handle check
The superfluous extra check could cause analyzer false positives
and doesn't serve any purpose.

Closes #8676
2022-04-06 08:32:04 +02:00
MAntoniak ba83c522f5
mbedtls: remove server_fd from backend
Closes #8682
2022-04-06 08:31:12 +02:00
Tatsuhiro Tsujikawa 92c0123585
ngtcp2: use token when detecting :status header field
Closes #8679
2022-04-05 16:48:44 +02:00
Tatsuhiro Tsujikawa 913b80d5fd
ngtcp2: make curl 1ms faster
Pass 0 for an already expired timer.

Closes #8678
2022-04-05 16:47:18 +02:00
Tatsuhiro Tsujikawa 1b1443a8ed
ngtcp2: fix QUIC_IDLE_TIMEOUT
QUIC_IDLE_TIMEOUT should be of type ngtcp2_duration which is
nanoseconds resolution.

Closes #8678
2022-04-05 16:47:07 +02:00
Daniel Stenberg 4a8f6869db
English: use American spelling consistently
Authorization, Initialization, Organization etc.

Closes #8673
2022-04-05 14:55:47 +02:00
Daniel Stenberg 854ec76551
http: streamclose "already downloaded"
Instead of connclose()ing, since when HTTP/2 is used it doesn't need to
close the connection as stopping the current transfer is enough.

Reported-by: Evangelos Foutras
Closes #8665
2022-04-01 23:30:43 +02:00