12080 Commits

Author SHA1 Message Date
Daniel Stenberg
f77292663c
http_proxy: don't close the socket (too early)
... and double-check in the OpenSSL shutdown that the socket is actually
still there before it is used.

Fixes #8193
Closes #8195

Reported-by: Leszek Kubik
2021-12-29 23:20:03 +01:00
Daniel Stenberg
8fbd6feddf
ngtcp2: verify the server certificate for the gnutls case
Closes #8178
2021-12-28 23:34:30 +01:00
Daniel Stenberg
c148f0f551
ngtcp2: verify the server cert on connect (quictls)
Make ngtcp2+quictls correctly acknowledge `CURLOPT_SSL_VERIFYPEER` and
`CURLOPT_SSL_VERIFYHOST`.

The name check now uses a function from lib/vtls/openssl.c which will
need attention for when TLS is not done by OpenSSL or is disabled while
QUIC is enabled.

Possibly the servercert() function in openssl.c should be adjusted to be
able to use for both regular TLS and QUIC.

Ref: #8173
Closes #8178
2021-12-28 23:34:23 +01:00
Daniel Stenberg
21248e052d
checksrc: detect more kinds of NULL comparisons we avoid
Co-authored-by: Jay Satiro
Closes #8180
2021-12-27 23:39:26 +01:00
Daniel Stenberg
7a08bb709c
mesalink: remove the BACKEND define kludge
Closes #8183
2021-12-26 18:33:07 +01:00
Daniel Stenberg
b8ef4a845b
schannel: remove the BACKEND define kludge
Closes #8182
2021-12-26 11:59:28 +01:00
Daniel Stenberg
4a2ab69ab5
gtls: check return code for gnutls_alpn_set_protocols
Closes #8181
2021-12-26 11:28:23 +01:00
Vladimir Panteleev
1b9f1f6055
http: Fix CURLOPT_HTTP200ALIASES
The httpcode < 100 check was also triggered when none of the fields were
parsed, thus making the if(!nc) block unreachable.

Closes #8171
2021-12-21 08:44:55 +01:00
Daniel Stenberg
556a42edfb
nss:set_cipher don't clobber the cipher list
The string is set by the user and needs to remain intact for proper
connection reuse etc.

Reported-by: Eric Musser
Fixes #8160
Closes #8161
2021-12-20 10:51:44 +01:00
Daniel Stenberg
7a92f865b4
misc: s/e-mail/email
Consistency is king. Following the lead in everything curl.

Closes #8159
2021-12-19 23:48:13 +01:00
Jay Satiro
79d6057f1b openssl: define HAVE_OPENSSL_VERSION for OpenSSL 1.1.0+
Prior to this change OpenSSL_version was only detected in configure
builds. For other builds the old version parsing code was used which
would result in incorrect versioning for OpenSSL 3:

Before:

curl 7.80.0 (i386-pc-win32) libcurl/7.80.0 OpenSSL/3.0.0a zlib/1.2.11
WinIDN libssh2/1.9.0

After:

curl 7.80.0 (i386-pc-win32) libcurl/7.80.0 OpenSSL/3.0.1 zlib/1.2.11
WinIDN libssh2/1.9.0

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

Fixes https://github.com/curl/curl/issues/8154
Closes https://github.com/curl/curl/pull/8155
2021-12-16 13:49:52 -05:00
Daniel Stenberg
c9e0549113
x509asn1: return early on errors
Overhaul to make sure functions that detect errors bail out early with
error rather than trying to continue and risk hiding the problem.

Closes #8147
2021-12-15 08:19:29 +01:00
Patrick Monnerat
cdc1da9120
openldap: several minor improvements
- Early check proper LDAP URL syntax. Reject URLs with a userinfo part.
- Use dynamic memory for ldap_init_fd() URL rather than a
  stack-allocated buffer.
- Never chase referrals: supporting it would require additional parallel
  connections and alternate authentication credentials.
- Do not wait 1 microsecond while polling/reading query response data.
- Store last received server code for retrieval with CURLINFO_RESPONSE_CODE.

Closes #8140
2021-12-15 08:07:53 +01:00
MAntoniak
39406280bb
misc: remove unused doh flags when CURL_DISABLE_DOH is defined
Closes #8148
2021-12-15 08:01:21 +01:00
Daniel Stenberg
867ad1cd8b
mbedtls: fix CURLOPT_SSLCERT_BLOB
The memory passed to mbedTLS for this needs to be null terminated.

Reported-by: Florian Van Heghe
Closes #8146
2021-12-14 15:35:54 +01:00
Daniel Stenberg
64e8bf9ff4
asyn-ares: ares_getaddrinfo needs no happy eyeballs timer
Closes #8142
2021-12-14 15:34:43 +01:00
MrDwZ
1cdfdcde3b check ssl_config when re-use proxy connection 2021-12-14 14:46:10 +01:00
Daniel Stenberg
9d0d16d435
mbedtls: do a separate malloc for ca_info_blob
Since the mbedTLS API requires the data to the null terminated.

Follow-up to 456c53730d21b1fad0c7f72c1817

Fixes #8139
Closes #8145
2021-12-14 11:52:14 +01:00
Patrick Monnerat
2300ad26d3
openldap: simplify ldif generation code
and take care of zero-length values, avoiding conversion to base64
and/or trailing spaces.

Closes #8136
2021-12-13 15:57:19 +01:00
x2018
d6ff35b5a5
sha256/md5: return errors when init fails
Closes #8133
2021-12-13 15:54:16 +01:00
Patrick Monnerat
b40e4c0d47
openldap: process search query response messages one by one
Upon receiving large result sets, this reduces memory consumption and
allows starting to output results while the transfer is still in
progress.

Closes #8101
2021-12-11 12:54:50 +01:00
Daniel Stenberg
254f7bd78a
hash: lazy-alloc the table in Curl_hash_add()
This makes Curl_hash_init() infallible which saves error paths.

Closes #8132
2021-12-10 23:16:43 +01:00
Daniel Stenberg
e43ad4b474
multi: cleanup the socket hash when destroying it
Since each socket hash entry may themselves have a hash table in them,
the destroying of the socket hash needs to make sure all the subhashes
are also correctly destroyed to avoid leaking memory.

Fixes #8129
Closes #8131
2021-12-10 17:02:04 +01:00
Daniel Stenberg
8d8f384f32
hash: add asserts to help detect bad usage
For example trying to add entries after the hash has been "cleaned up"

Closes #8115
2021-12-09 10:18:41 +01:00
Daniel Stenberg
2b3dd01b77
multi: handle errors returned from socket/timer callbacks
The callbacks were partially documented to support this. Now the
behavior is documented and returning error from either of these
callbacks will effectively kill all currently ongoing transfers.

Added test 530 to verify

Reported-by: Marcelo Juchem
Fixes #8083
Closes #8089
2021-12-06 14:55:52 +01:00
Daniel Stenberg
b3f9c1aa09
http2:set_transfer_url() return early on OOM
If curl_url() returns NULL this should return early to avoid mistakes -
even if right now the subsequent function invokes are all OK.

Coverity (wrongly) pointed out this as a NULL deref.

Closes #8100
2021-12-06 14:32:29 +01:00
Patrick Monnerat
a40160aee8
openldap: implement STARTTLS
As this introduces use of CURLOPT_USE_SSL option for LDAP, also check
this option in ldap.c as it is not supported by this backend.

Closes #8065
2021-12-06 07:53:04 +01:00
Daniel Stenberg
92d1aee8b1
urlapi: accept port number zero
This is a regression since 7.62.0 (fb30ac5a2d).

Updated test 1560 accordingly

Reported-by: Brad Fitzpatrick
Fixes #8090
Closes #8091
2021-12-03 22:58:41 +01:00
Florian Van Heghe
456c53730d
mbedTLS: include NULL byte in blob data length for CURLOPT_CAINFO_BLOB
Fixes #8079
Closes #8081
2021-12-02 11:15:05 +01:00
Wyatt O'Day
7da636cad5 version_win32: Check build number and platform id
Prior to this change the build number was not checked during version
comparison, and the platform id was supposed to be checked but wasn't.

Checking the build number is required for enabling "evergreen"
Windows 10/11 features (like TLS 1.3).

Ref: https://github.com/curl/curl/pull/7784

Closes https://github.com/curl/curl/pull/7824
Closes https://github.com/curl/curl/pull/7867
2021-12-02 03:39:14 -05:00
Jay Satiro
3467e89bb9 libssh2: fix error message for sha256 mismatch
- On mismatch error show sha256 fingerprint in base64 format.

Prior to this change the fingerprint was mistakenly printed in binary.
2021-12-02 02:19:51 -05:00
x2018
34294a65b2
openssl: check the return value of BIO_new()
Closes #8078
2021-12-01 11:51:53 +01:00
Florian Van Heghe
8443f975c0
mbedTLS: add support for CURLOPT_CAINFO_BLOB
Closes #8071
2021-11-30 16:19:46 +01:00
Glenn Strauss
aae235b6ba
digest: compute user:realm:pass digest w/o userhash
https://datatracker.ietf.org/doc/html/rfc7616#section-3.4.4
  ... the client MUST calculate a hash of the username after
      any other hash calculation ...

Signed-off-by: Glenn Strauss <gstrauss@gluelogic.com>
Closes #8066
2021-11-30 13:57:46 +01:00
Patrick Monnerat
ac89965f99
openldap: handle connect phase with a state machine
Closes #8054
2021-11-26 14:32:12 +01:00
Viktor Szakats
8c0336cf5d
Makefile.m32: rename -winssl option to -schannel and tidy up
- accept `-schannel` as an alternative to `CFG` option `-winssl`
  (latter still accepted, but deprecated)
- rename internal variable `WINSSL` to `SCHANNEL`
- make the `CFG` option evaluation shorter, without repeating the option
  name

Reviewed-by: Marcel Raad
Reviewed-by: Daniel Stenberg
Closes #8053
2021-11-25 17:36:38 +00:00
Daniel Stenberg
4183b8fe9a
urlapi: provide more detailed return codes
Previously, the return code CURLUE_MALFORMED_INPUT was used for almost
30 different URL format violations. This made it hard for users to
understand why a particular URL was not acceptable. Since the API cannot
point out a specific position within the URL for the problem, this now
instead introduces a number of additional and more fine-grained error
codes to allow the API to return more exactly in what "part" or section
of the URL a problem was detected.

Also bug-fixes curl_url_get() with CURLUPART_ZONEID, which previously
returned CURLUE_OK even if no zoneid existed.

Test cases in 1560 have been adjusted and extended. Tests 1538 and 1559
have been updated.

Updated libcurl-errors.3 and curl_url_strerror() accordingly.

Closes #8049
2021-11-25 08:36:04 +01:00
Daniel Stenberg
a5f5687368
urlapi: make Curl_is_absolute_url always use MAX_SCHEME_LEN
Instad of having all callers pass in the maximum length, always use
it. The passed in length is instead used only as the length of the
target buffer for to storing the scheme name in, if used.

Added the scheme max length restriction to the curl_url_set.3 man page.

Follow-up to 45bcb2eaa78c79

Closes #8047
2021-11-25 08:33:48 +01:00
Daniel Stenberg
3e6eb18fce
urlapi: reject short file URLs
file URLs that are 6 bytes or shorter are not complete. Return
CURLUE_MALFORMED_INPUT for those. Extended test 1560 to verify.

Triggered by #8041
Closes #8042
2021-11-23 08:45:21 +01:00
Stefan Eissing
45bcb2eaa7
urlapi: cleanup scheme parsing
Makea Curl_is_absolute_url() always leave a defined 'buf' and avoids
copying on urls that do not start with a scheme.

Closes #8043
2021-11-22 22:41:11 +01:00
Jacob Hoffman-Andrews
3f8fde366f
rustls: remove comment about checking handshaking
The comment is incorrect in two ways:
 - It says the check needs to be last, but the check is actually first.
 - is_handshaking actually starts out true.

Closes #8038
2021-11-20 22:57:13 +01:00
Marcel Raad
9b9485e7ac openssl: use non-deprecated API to read key parameters
With OpenSSL 3.0, the parameters are read directly from the `EVP_PKEY`
using `EVP_PKEY_get_bn_param`.

Closes https://github.com/curl/curl/pull/7893
2021-11-20 12:04:57 +01:00
Marcel Raad
9b923eaf3e openssl: reduce code duplication
`BN_print`'s `BIGNUM` parameter has been `const` since OpenSSL 0.9.4.

Closes https://github.com/curl/curl/pull/7893
2021-11-20 12:04:56 +01:00
Marcel Raad
6147dfab93 openssl: remove RSA_METHOD_FLAG_NO_CHECK handling if unavailable
The flag has been deprecated without replacement in OpenSSL 3.0.

Closes https://github.com/curl/curl/pull/7893
2021-11-20 12:04:56 +01:00
Marcel Raad
1e80f56d0b openssl: remove usage of deprecated SSL_get_peer_certificate
The function name was changed to `SSL_get1_peer_certificate` in OpenSSL
3.0.

Closes https://github.com/curl/curl/pull/7893
2021-11-20 12:04:56 +01:00
Daniel Stenberg
6e061ae63a
http: enable haproxy support for hyper backend
This is done by having native code do the haproxy header output before
hyper issues its request. The little downside with this approach is that
we need the entire Curl_buffer_send() function built, which is otherwise
not used for hyper builds.

If hyper ends up getting native support for the haproxy protocols we can
backpedal on this.

Enables test 1455 and 1456

Closes #8034
2021-11-19 14:06:42 +01:00
Don
f99a4c759f
cmake: don't set _USRDLL on a static Windows build
Closes #8030
2021-11-18 11:26:30 +01:00
Daniel Stenberg
4d97fe5473
tftp: mark protocol as not possible to do over CONNECT
... and make connect_init() refusing trying to tunnel protocols marked
as not working. Avoids a double-free.

Reported-by: Even Rouault
Fixes #8018
Closes #8020
2021-11-15 23:13:09 +01:00
Patrick Monnerat
b20b364764
mime: use percent-escaping for multipart form field and file names
Until now, form field and file names where escaped using the
backslash-escaping algorithm defined for multipart mails. This commit
replaces this with the percent-escaping method for URLs.

As this may introduce incompatibilities with server-side applications, a
new libcurl option CURLOPT_MIME_OPTIONS with bitmask
CURLMIMEOPT_FORMESCAPE is introduced to revert to legacy use of
backslash-escaping. This is controlled by new cli tool option
--form-escape.

New tests and documentation are provided for this feature.

Reported by: Ryan Sleevi
Fixes #7789
Closes #7805
2021-11-15 10:40:03 +01:00
Jacob Hoffman-Andrews
00f4ed2aad
rustls: read of zero bytes might be okay
When we're reading out plaintext from rustls' internal buffers, we might
get a read of zero bytes (meaning a clean TCP close, including
close_notify). However, we shouldn't return immediately when that
happens, since we may have already copied out some plaintext bytes.
Break out of the loop when we get a read of zero bytes, and figure out
which path we're dealing with.

Acked-by: Kevin Burke

Closes #8003
2021-11-13 22:57:51 +01:00