]> git.ipfire.org Git - thirdparty/curl.git/log
thirdparty/curl.git
3 years agotidy-up: delete unused build configuration macros
Viktor Szakats [Tue, 19 Jul 2022 15:06:26 +0000 (15:06 +0000)] 
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 de71e68000c8624ea13f90b136f8734dd0fb1bdc)
- `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

3 years agoRELEASE-NOTES: synced
Daniel Stenberg [Tue, 19 Jul 2022 13:03:02 +0000 (15:03 +0200)] 
RELEASE-NOTES: synced

3 years agocookie: treat a blank domain in Set-Cookie: as non-existing
Daniel Stenberg [Mon, 18 Jul 2022 22:05:43 +0000 (00:05 +0200)] 
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

3 years agobase64: base64url encoding has no padding
Patrick Monnerat [Tue, 12 Jul 2022 17:03:45 +0000 (19:03 +0200)] 
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

3 years agoeasyoptions: fix icc warning
Daniel Stenberg [Mon, 18 Jul 2022 21:38:36 +0000 (23:38 +0200)] 
easyoptions: fix icc warning

    easyoptions.c(360): error #188: enumerated type mixed with another type

Ref: #9156
Reported-by: Matthew Thompson
Closes #9176

3 years agoh2h3: fix overriding the 'TE: Trailers' header
lwthiker [Sun, 17 Jul 2022 16:11:33 +0000 (19:11 +0300)] 
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

3 years agolib3026: reduce the number of threads to 100
Daniel Stenberg [Sun, 17 Jul 2022 21:48:22 +0000 (23:48 +0200)] 
lib3026: reduce the number of threads to 100

Down from 1000, to make it run and work in more systems.

Fixes #9172
Reported-by: Érico Nogueira Rolim
Closes #9173

3 years agodoh: move doh related struct definitions to doh.h
Daniel Stenberg [Sun, 17 Jul 2022 21:58:43 +0000 (23:58 +0200)] 
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

3 years agoMakefile.m32: stop trying to build libcares.a [ci skip]
Viktor Szakats [Sun, 17 Jul 2022 21:45:34 +0000 (21:45 +0000)] 
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] 46c92c0b806da041d7a5c6fb64dbcdc474d99b31

Reviewed-by: Daniel Stenberg
Closes #9169

3 years agocurl: writeout: fix repeated header outputs
Daniel Stenberg [Wed, 13 Jul 2022 21:53:05 +0000 (23:53 +0200)] 
curl: writeout: fix repeated header outputs

The function stored a terminating zero into the buffer for convenience,
but when on repeated calls that would cause problems. Starting now, the
passed in buffer is not modified.

Reported-by: highmtworks on github
Fixes #9150
Closes #9152

3 years agocurl_multi_timeout.3: clarify usage
Daniel Stenberg [Thu, 14 Jul 2022 21:37:13 +0000 (23:37 +0200)] 
curl_multi_timeout.3: clarify usage

Fixes #9155
Closes #9157
Reported-by: jvvprasad78 on github
3 years agomprintf: make dprintf_formatf never return negative
Daniel Stenberg [Wed, 13 Jul 2022 21:46:16 +0000 (23:46 +0200)] 
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
3 years agotrace: 0x7F character is non-printable
Viktor Szakats [Sun, 17 Jul 2022 10:10:35 +0000 (10:10 +0000)] 
trace: 0x7F character is non-printable

`0x7F` is `DEL`, a non-printable symbol, so print it as
`UNPRINTABLE_CHAR`.

Reported-by: MasterInQuestion on github
Fixes #9162
Closes #9166

3 years agodoh: use https protocol by default
Viktor Szakats [Sat, 16 Jul 2022 14:10:39 +0000 (14:10 +0000)] 
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

3 years agoopenssl: fix BoringSSL symbol conflicts with LDAP and Schannel
Viktor Szakats [Thu, 14 Jul 2022 07:14:22 +0000 (07:14 +0000)] 
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] https://github.com/curl/curl/commit/fbe07c6829ba8c5793c84c2856526e19e9029ab9

Co-authored-by: Jay Satiro
Closes #9110

3 years agoasyn-thread: make getaddrinfo_complete return CURLcode
Daniel Stenberg [Tue, 12 Jul 2022 21:06:01 +0000 (23:06 +0200)] 
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

3 years agoeasy_lock: fix build with icc
Daniel Stenberg [Tue, 12 Jul 2022 13:57:02 +0000 (15:57 +0200)] 
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

3 years agoconfigure: fix --disable-headers-api
Daniel Stenberg [Tue, 12 Jul 2022 13:53:11 +0000 (15:53 +0200)] 
configure: fix --disable-headers-api

Reported-by: Michał Antoniak
Fixes #9134
Closes #9143

3 years agotest3026: require 'threadsafe'
Daniel Stenberg [Tue, 12 Jul 2022 13:37:21 +0000 (15:37 +0200)] 
test3026: require 'threadsafe'

Reported-by: Sukanya Hanumanthu
Fixes #9141
Closes #9142

3 years agoCMake: link curl to its dependencies with PRIVATE
Even Rouault [Fri, 8 Jul 2022 11:30:57 +0000 (13:30 +0200)] 
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

3 years agoCMake: remove APPEND in export(TARGETS)
Even Rouault [Fri, 8 Jul 2022 11:25:14 +0000 (13:25 +0200)] 
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

3 years agongtcp2: implement cb_h3_stop_sending and cb_h3_reset_stream callbacks
Tatsuhiro Tsujikawa [Sat, 9 Jul 2022 07:25:14 +0000 (16:25 +0900)] 
ngtcp2: implement cb_h3_stop_sending and cb_h3_reset_stream callbacks

Closes #9135

3 years agoRELEASE-NOTES: synced
Daniel Stenberg [Mon, 11 Jul 2022 21:38:02 +0000 (23:38 +0200)] 
RELEASE-NOTES: synced

3 years agobuild: improve OS string in CMake and `config-win32.h`
Viktor Szakats [Mon, 11 Jul 2022 19:41:31 +0000 (19:41 +0000)] 
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:
435f395f3f8c11eebfcc243ca55ebcc11a19b8b8, thus retiring the
`CURL_OS_SUFFIX` CMake option.

Reviewed-by: Jay Satiro
Closes #9117

3 years agoMakefile.m32: add `CURL_RC` and `CURL_STRIP` variables [ci skip]
Viktor Szakats [Sun, 10 Jul 2022 22:28:14 +0000 (22:28 +0000)] 
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

3 years agongtcp2: fix stall or busy loop on STOP_SENDING with upload data
Tatsuhiro Tsujikawa [Fri, 8 Jul 2022 09:48:09 +0000 (18:48 +0900)] 
ngtcp2: fix stall or busy loop on STOP_SENDING with upload data

Fixes #9122
Closes #9123

3 years agotool_operate: better cleanup of easy handle in exit path
xkernel [Sun, 10 Jul 2022 16:23:03 +0000 (18:23 +0200)] 
tool_operate: better cleanup of easy handle in exit path

Closes #9114

3 years agogetinfo: return better error on NULL as first argument
xkernel [Sun, 10 Jul 2022 16:22:23 +0000 (18:22 +0200)] 
getinfo: return better error on NULL as first argument

Closes #9114

3 years agotool_getparam: repair cleanarg
Daniel Stenberg [Sun, 10 Jul 2022 13:22:13 +0000 (15:22 +0200)] 
tool_getparam: repair cleanarg

Regression since 9e5669f.

Make sure the "cleaning" of command line arguments is done on the
original argv[] pointers. As a bonus, it also exits better on out of
memory error.

Reported-by: Litter White
Fixes #9128
Closes #9130

3 years agodocs: explain curl_easy_escape/unescape curl handle is ignored
Jay Satiro [Fri, 8 Jul 2022 06:04:35 +0000 (02:04 -0400)] 
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

3 years agoopenssl: add `CURL_BORINGSSL_VERSION` to identify BoringSSL
Viktor Szakats [Fri, 8 Jul 2022 10:10:04 +0000 (10:10 +0000)] 
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

3 years agoescape: remove outdated comment
Jay Satiro [Fri, 8 Jul 2022 05:39:55 +0000 (01:39 -0400)] 
escape: remove outdated comment

Bug: https://github.com/curl/curl/discussions/9115
Reported-by: Ted Lyngmo
3 years agongtcp2: Fix missing initialization of nghttp3_nv.flags
Tatsuhiro Tsujikawa [Thu, 7 Jul 2022 15:01:48 +0000 (00:01 +0900)] 
ngtcp2: Fix missing initialization of nghttp3_nv.flags

Closes https://github.com/curl/curl/pull/9118

3 years agonetrc.d: remove spurious quote
Brad Forschinger [Wed, 6 Jul 2022 07:45:07 +0000 (17:45 +1000)] 
netrc.d: remove spurious quote

Closes #9111

3 years agoMakefile.m32: add `NGTCP2_LIBS` option [ci skip]
Viktor Szakats [Wed, 6 Jul 2022 09:22:42 +0000 (09:22 +0000)] 
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

3 years agodigest: fix missing increment of 'nc' value for auth-int
Evgeny Grin (Karlson2k) [Sun, 3 Jul 2022 14:58:50 +0000 (17:58 +0300)] 
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

3 years agoRELEASE-NOTES: synced
Daniel Stenberg [Tue, 5 Jul 2022 08:39:52 +0000 (10:39 +0200)] 
RELEASE-NOTES: synced

Bumped to 7.85.0

3 years agourldata: reduce size of four ftp related members
Daniel Stenberg [Mon, 4 Jul 2022 22:11:35 +0000 (00:11 +0200)] 
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

3 years agourldata: reduce three type-members from int to uchar
Daniel Stenberg [Mon, 4 Jul 2022 22:04:38 +0000 (00:04 +0200)] 
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

3 years agoCURLOPT_SERVER_RESPONSE_TIMEOUT: the new name
Daniel Stenberg [Mon, 4 Jul 2022 21:22:36 +0000 (23:22 +0200)] 
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

3 years agourldata: make 'ftp_create_missing_dirs' a uchar
Daniel Stenberg [Mon, 4 Jul 2022 21:09:15 +0000 (23:09 +0200)] 
urldata: make 'ftp_create_missing_dirs' a uchar

It only ever holds the values 0-2.

Closes #9103

3 years agocmake: support ngtcp2 boringssl backend
Don [Tue, 28 Jun 2022 22:33:25 +0000 (15:33 -0700)] 
cmake: support ngtcp2 boringssl backend

Update the ngtcp2 find module to detect the boringssl backend. Determine
if the underlying OpenSSL implementation is BoringSSL and if so use that
as the ngtcp2 backend.

Reviewed-by: Jakub Zakrzewski
Closes #9065

3 years agourldata: change 4 timeouts to unsigned int from long
Daniel Stenberg [Mon, 4 Jul 2022 12:58:08 +0000 (14:58 +0200)] 
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

3 years agourldata: make 'use_netrc' a uchar
Daniel Stenberg [Mon, 4 Jul 2022 13:03:35 +0000 (15:03 +0200)] 
urldata: make 'use_netrc' a uchar

Closes #9102

3 years agourldata: make 'buffer_size' an unsigned int
Daniel Stenberg [Mon, 4 Jul 2022 17:41:52 +0000 (19:41 +0200)] 
urldata: make 'buffer_size' an unsigned int

It is already capped at READBUFFER_MAX which fits easily in 32 bits.

Closes #9098

3 years agourldata: remove the unused 'rtspversion' struct member
Daniel Stenberg [Mon, 4 Jul 2022 12:49:28 +0000 (14:49 +0200)] 
urldata: remove the unused 'rtspversion' struct member

Closes #9100

3 years agourldata: make 'use_port' an usigned short
Daniel Stenberg [Mon, 4 Jul 2022 17:42:40 +0000 (19:42 +0200)] 
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

3 years agourldata: store dns cache timeout in an int
Daniel Stenberg [Mon, 4 Jul 2022 17:28:49 +0000 (19:28 +0200)] 
urldata: store dns cache timeout in an int

68 years ought to be enough for most.

Closes #9097

3 years agocurl: proto2num: make sure obuf is inited
Daniel Stenberg [Mon, 4 Jul 2022 10:50:15 +0000 (12:50 +0200)] 
curl: proto2num: make sure obuf is inited

Detected by Coverity. CID 1507052.

Closes #9096

3 years agocookie: use %zu to infof() for size_t values
Daniel Stenberg [Mon, 4 Jul 2022 10:48:10 +0000 (12:48 +0200)] 
cookie: use %zu to infof() for size_t values

Detected by Coverity. CID 1507051
Closes #9095

3 years agomakefile.m32: add support for custom ARCH [ci skip]
Viktor Szakats [Mon, 4 Jul 2022 10:26:30 +0000 (10:26 +0000)] 
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

3 years agocmake: do not force Windows target versions
Viktor Szakats [Mon, 4 Jul 2022 09:40:55 +0000 (09:40 +0000)] 
cmake: do not force Windows target versions

The goal of this patch is to avoid CMake forcing specific Windows
versions and rely on toolchain defaults or manual selection instead.
This gives back control to the user. This also brings CMake closer to
how autotools and `Makefile.m32` behaves in this regard.

- CMake had a setting `ENABLE_INET_PTON` defaulting to `ON`, which did
  nothing else than fixing the Windows build target to Vista. This also
  happened when the toolchain did not have Vista support (e.g. original
  MinGW), breaking such builds.

  In other environments it did not make a user-facing difference,
  because libcurl has its own pton() implementation, so it works well
  with or without Vista's inet_pton().

  This patch drops this setting. inet_pton() is now used whenever
  building for Vista or newer, either when requested manually or by
  default with modern toolchains (e.g. mingw-w64). Older envs will fall
  back to curl's pton().

  Ref: https://github.com/curl/curl/pull/9027#issuecomment-1164157604
  Ref: https://github.com/curl/curl/pull/8997#issuecomment-1164344155

- When the user did no select a Windows target version manually, stop
  explicitly targeting Windows XP, and instead use the toolchain default.

  This may pose an issue with old toolchains defaulting to pre-XP
  targets. In such case you must manually target Windows XP via:
    `-DCURL_TARGET_WINDOWS_VERSION=0x0501`
  or
    `-DCMAKE_C_FLAGS=-D_WIN32_WINNT=0x0501`

Reviewed-by: Jay Satiro
Reviewed-by: Marcel Raad
Closes #9046

3 years agowindows: improve random source
Viktor Szakats [Mon, 4 Jul 2022 09:38:24 +0000 (09:38 +0000)] 
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

3 years agosetopt: add CURLOPT_PROTOCOLS_STR and CURLOPT_REDIR_PROTOCOLS_STR
Daniel Stenberg [Mon, 13 Jun 2022 07:30:45 +0000 (09:30 +0200)] 
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

3 years agodigest: simplify a switch() to a simple if
Daniel Stenberg [Mon, 4 Jul 2022 06:27:21 +0000 (08:27 +0200)] 
digest: simplify a switch() to a simple if

3 years agodigest: provide a special bit for "sess" algos
Daniel Stenberg [Mon, 4 Jul 2022 06:27:15 +0000 (08:27 +0200)] 
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

3 years agoselect: do not return fatal error on EINTR from poll()
Thomas Weißschuh [Sun, 3 Jul 2022 16:20:44 +0000 (18:20 +0200)] 
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

3 years agocmake: fix build for mingw cross compile
Kai Pastor [Sat, 2 Jul 2022 07:36:09 +0000 (09:36 +0200)] 
cmake: fix build for mingw cross compile

- Change normaliz lib name to all lowercase.

This is from a standing patch in vcpkg:
Mingw has libnormaliz.a. For case-sensitive file systems (e.g. cross
builds from Linux), the spelling must match exactly.

Closes https://github.com/curl/curl/pull/9084

3 years agoeasy_lock: fix build for mingw
Jay Satiro [Fri, 1 Jul 2022 07:02:20 +0000 (03:02 -0400)] 
easy_lock: fix build for mingw

- Define SRWLOCK symbols missing in some mingw environments.

Closes https://github.com/curl/curl/pull/8997

3 years agotool_progress: avoid division by zero in parallel progress meter
Daniel Stenberg [Fri, 1 Jul 2022 22:02:04 +0000 (00:02 +0200)] 
tool_progress: avoid division by zero in parallel progress meter

Reported-by: Brian Carpenter
Fixes #9082
Closes #9083

3 years agohttp_aws_sigv4.c: remove two unusued includes
Daniel Stenberg [Fri, 1 Jul 2022 14:43:02 +0000 (16:43 +0200)] 
http_aws_sigv4.c: remove two unusued includes

Closes #9080

3 years ago.mailmap: additional edit
Daniel Stenberg [Fri, 1 Jul 2022 07:56:07 +0000 (09:56 +0200)] 
.mailmap: additional edit

Follow-up to 861e2a8aca6c7 so that Evgeny appears with the same in git
logs even when using old email.

3 years agoRELEASE-NOTES: synced
Daniel Stenberg [Fri, 1 Jul 2022 07:53:08 +0000 (09:53 +0200)] 
RELEASE-NOTES: synced

bumped to 7.84.1

3 years ago.mailmap: updated
Evgeny Grin (Karlson2k) [Thu, 30 Jun 2022 14:31:52 +0000 (17:31 +0300)] 
.mailmap: updated

3 years agoTHANKS: merged two entries for Evgeny Grin
Evgeny Grin (Karlson2k) [Thu, 30 Jun 2022 11:27:23 +0000 (14:27 +0300)] 
THANKS: merged two entries for Evgeny Grin

Also updated THANKS-filter file

Closes #9076

3 years agolib/curl_path.c: add ISC to license expression
Jilayne Lovejoy [Thu, 30 Jun 2022 17:01:49 +0000 (11:01 -0600)] 
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

3 years agohyper: use wakers for curl pause/resume
Sean McArthur [Thu, 30 Jun 2022 00:45:32 +0000 (17:45 -0700)] 
hyper: use wakers for curl pause/resume

Closes #9070

3 years agoMakefile.m32: do not set the libcurl.rc debug flag [ci skip]
Viktor Szakats [Thu, 30 Jun 2022 08:14:29 +0000 (08:14 +0000)] 
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

3 years agocurl.h: CURLE_CONV_FAILED is obsoleted
Daniel Stenberg [Wed, 29 Jun 2022 08:42:04 +0000 (10:42 +0200)] 
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

3 years agocurl: output warning when a cookie is dropped due to size
Daniel Stenberg [Tue, 28 Jun 2022 15:15:24 +0000 (17:15 +0200)] 
curl: output warning when a cookie is dropped due to size

Dropped from the request, that is.

Closes #9064

3 years agocurl_mime_data.3: polish the wording
Daniel Stenberg [Tue, 28 Jun 2022 11:01:40 +0000 (13:01 +0200)] 
curl_mime_data.3: polish the wording

Closes #9063

3 years agoconfigure: check for the stdatomic.h header in configure
Daniel Stenberg [Tue, 28 Jun 2022 06:37:22 +0000 (08:37 +0200)] 
configure: check for the stdatomic.h header in configure

... and only set HAVE_ATOMIC if that header exists since we use
typedefes set in it.

Reported-by: Ryan Schmidt
Fixes #9059
Closes #9060

3 years agoeasy_lock: fix the #ifdef conditional for ia32_pause
Daniel Stenberg [Tue, 28 Jun 2022 08:21:07 +0000 (10:21 +0200)] 
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

3 years agoeasy_lock: switch to using atomic_int instead of bool
Daniel Stenberg [Tue, 28 Jun 2022 07:00:25 +0000 (09:00 +0200)] 
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

3 years agongtcp2: fix incompatible function pointer types
vvb2060 [Mon, 27 Jun 2022 19:50:33 +0000 (03:50 +0800)] 
ngtcp2: fix incompatible function pointer types

Closes #9056

3 years agoeasy_lock.h: use __asm__ instead of asm to fix build
vvb2060 [Mon, 27 Jun 2022 19:48:43 +0000 (03:48 +0800)] 
easy_lock.h: use __asm__ instead of asm to fix build

Closes #9056

3 years agolibcurl-security.3: fix typo on macro "SH_"
Samuel Henrique [Mon, 27 Jun 2022 21:27:06 +0000 (22:27 +0100)] 
libcurl-security.3: fix typo on macro "SH_"

During the packaging of the latest curl release for Debian, Lintian
warned me about a typo which causes the section name "Secrets in memory"
to not be rendered in the manpage due to "SH_" not being recognized as a
header.

Closes #9057

3 years agoeasy_lock.h: include sched.h if available to fix build
Daniel Stenberg [Mon, 27 Jun 2022 06:46:21 +0000 (08:46 +0200)] 
easy_lock.h: include sched.h if available to fix build

Patched-by: Harry Sintonen
Closes #9054

3 years agoRELEASE-NOTES: synced curl-7_84_0
Daniel Stenberg [Mon, 27 Jun 2022 06:07:28 +0000 (08:07 +0200)] 
RELEASE-NOTES: synced

Version 7.84.0 release

3 years agoTHANKS: contributors from 7.84.0 release notes
Daniel Stenberg [Mon, 27 Jun 2022 06:07:28 +0000 (08:07 +0200)] 
THANKS: contributors from 7.84.0 release notes

3 years agohsts: use Curl_fopen()
Daniel Stenberg [Wed, 25 May 2022 08:09:54 +0000 (10:09 +0200)] 
hsts: use Curl_fopen()

3 years agoaltsvc: use Curl_fopen()
Daniel Stenberg [Wed, 25 May 2022 08:09:53 +0000 (10:09 +0200)] 
altsvc: use Curl_fopen()

3 years agofopen: add Curl_fopen() for better overwriting of files
Daniel Stenberg [Wed, 25 May 2022 08:09:53 +0000 (10:09 +0200)] 
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

3 years agotest444: test many received Set-Cookie:
Daniel Stenberg [Sun, 26 Jun 2022 09:01:01 +0000 (11:01 +0200)] 
test444: test many received Set-Cookie:

The amount of sent cookies in the test is limited to 80 because hyper
has its own strict limits in how many headers it allows to be received
which triggers at some point beyond this number.

3 years agotest442/443: test cookie caps
Daniel Stenberg [Sun, 26 Jun 2022 09:01:01 +0000 (11:01 +0200)] 
test442/443: test cookie caps

442 - verify that only 150 cookies are sent
443 - verify that the cookie: header remains less than 8K in size

3 years agocookie: apply limits
Daniel Stenberg [Sun, 26 Jun 2022 09:00:48 +0000 (11:00 +0200)] 
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

3 years agotest387: verify rejection of compression chain attack
Daniel Stenberg [Mon, 16 May 2022 14:29:07 +0000 (16:29 +0200)] 
test387: verify rejection of compression chain attack

3 years agocontent_encoding: return error on too many compression steps
Daniel Stenberg [Mon, 16 May 2022 14:28:13 +0000 (16:28 +0200)] 
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

3 years agokrb5: return error properly on decode errors
Daniel Stenberg [Thu, 9 Jun 2022 07:27:24 +0000 (09:27 +0200)] 
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

3 years agoeasy_lock.h: remove use of the deprecated ATOMIC_VAR_INIT macro
Daniel Stenberg [Thu, 23 Jun 2022 10:02:32 +0000 (12:02 +0200)] 
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

3 years agongtcp2: avoid supplying 0 length `msg_control` to sendmsg()
Stefan Eissing [Wed, 22 Jun 2022 13:25:40 +0000 (15:25 +0200)] 
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

3 years agoftp: restore protocol state after http proxy CONNECT
Tom Eccles [Thu, 23 Jun 2022 09:09:25 +0000 (10:09 +0100)] 
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

3 years agoTHANKS: add contributor missing from aea8ac1
Jay Satiro [Thu, 23 Jun 2022 08:06:23 +0000 (04:06 -0400)] 
THANKS: add contributor missing from aea8ac1

aea8ac1 fixed #8980 which was reported by Sgharat on github, but that
info was not included in the commit message.

3 years agocurl_setup: include _mingw.h
Jay Satiro [Wed, 22 Jun 2022 07:35:19 +0000 (03:35 -0400)] 
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

3 years agorand: stop detecting /dev/urandom in cross-builds
Viktor Szakats [Wed, 22 Jun 2022 09:35:46 +0000 (09:35 +0000)] 
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

3 years agoci: avoid `cmake -Hpath`
Emanuele Torre [Wed, 15 Jun 2022 18:00:42 +0000 (20:00 +0200)] 
ci: avoid `cmake -Hpath`

This is an undocumented option similar to the `-Spath' option introduced
in cmake 3.13.
Replace all instances of `-Hpath' with `-Spath' in macos workflow.
Replace `-H. -Bpath' with `mkdir path; cd ./path; cmake ..' in zuul
scripts since it runs an older version of cmake.

Fixes #9008
Closes #9014

3 years agoINTERNALS: bring back the "Library symbols" section
Daniel Stenberg [Wed, 22 Jun 2022 07:40:39 +0000 (09:40 +0200)] 
INTERNALS: bring back the "Library symbols" section

Most contents was moved, but this text should remain here.

Follow-up to: d324ac8
Reported-by: Viktor Szakats
Bug: https://github.com/curl/curl/pull/9027#discussion_r903382326
Closes #9037

3 years agoMakefile.m32: stop forcing XP target with ipv6 enabled [ci skip]
Viktor Szakats [Wed, 22 Jun 2022 00:06:48 +0000 (00:06 +0000)] 
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] 98a61d8e2e8982786aaf3916cbbcac96838316e7

Closes #9035

3 years agoCONTRIBUTE: mention how we maintain REUSE compliance
Daniel Stenberg [Tue, 21 Jun 2022 14:56:19 +0000 (16:56 +0200)] 
CONTRIBUTE: mention how we maintain REUSE compliance

for copyright and license information of all files stored in git

Closes #9032

3 years agoCURLOPT_ALTSVC.3: document the file format
Daniel Stenberg [Tue, 21 Jun 2022 17:23:42 +0000 (19:23 +0200)] 
CURLOPT_ALTSVC.3: document the file format

Closes #9033