Commit Graph

11860 Commits

Author SHA1 Message Date
Gisle Vanem c6fd7cbf10 [SChannel] Use '_tcsncmp()' instead
Revert previous change for PellesC. 

Instead replace all use of `_tcsnccmp()` with `_tcsncmp()`.
2021-07-16 07:30:35 +02:00
Gisle Vanem 3cd9a23e80 [PellesC] missing '_tcsnccmp'
PellesC compiler does not have this macro in it's `<tchar.h>`
2021-07-16 07:30:35 +02:00
Jonathan Wernberg 9bf79d0a5a
Revert "ftp: Expression 'ftpc->wait_data_conn' is always false"
The reverted commit introduced a logic error in code that was
correct.

The client using libcurl would notice the error since FTP file
uploads in active transfer mode would somtimes complete with
success despite no transfer having been performed and the
"uploaded" file thus not being on the remote server afterwards.

The FTP server would notice the error because it receives a
RST on the data connection it has established with the client
before any data was transferred at all.

The logic error happens if the STOR response from the server have
arrived by the time ftp_multi_statemach() in the affected code path
is called, but the incoming data connection have not arrived yet.
In that case, the processing of the STOR response will cause
'ftpc->wait_data_conn' to be set to TRUE, contradicting the comment
in the code. Since 'complete' will also be set, later logic would
believe the transfer was done.

In most cases, the STOR response will not have arrived yet when
the affected code path is executed, or the incoming connection will
also have arrived, and thus the error would not express itself.
But if the speed difference of the device using libcurl and the
FTP server is exactly right, the error may happen as often as in
one out of hundred file transfers.

This reverts commit 49f3117a23.

Bug: https://curl.se/mail/lib-2021-07/0025.html
Closes #7362
2021-07-08 10:18:25 +02:00
Daniel Stenberg 9053dbbf62
msnprintf: return number of printed characters excluding null byte
... even when the output is "capped" by the maximum length argument.

Clarified in the docs.

Closes #7361
2021-07-08 10:05:39 +02:00
Daniel Stenberg e7416cfd2b
infof: remove newline from format strings, always append it
- the data needs to be "line-based" anyway since it's also passed to the
  debug callback/application

- it makes infof() work like failf() and consistency is good

- there's an assert that triggers on newlines in the format string

- Also removes a few instances of "..."

- Removes the code that would append "..." to the end of the data *iff*
  it was truncated in infof()

Closes #7357
2021-07-07 22:54:01 +02:00
Daniel Stenberg 1e488d38c9
wolfssl: failing to set a session id is not reason to error out
... as it is *probably* just timed out.

Reported-by: Francisco Munoz

Closes #7358
2021-07-07 10:19:28 +02:00
Daniel Stenberg c3d612662d
test1147: hyper doesn't allow "crazy" request headers like built-in
... so strip that from the test.

Closes #7349
2021-07-05 22:51:13 +02:00
Daniel Stenberg a62ece3f57
c-hyper: bail on too long response headers
To match with built-in behaviors. Makes test 1154 work.

Closes #7350
2021-07-05 22:49:12 +02:00
Daniel Stenberg 0b0269341b
c-hyper: add support for transfer-encoding in the request
Closes #7348
2021-07-05 22:46:01 +02:00
Andrea Pappacoda 4f3828d5a2
cmake: remove libssh2 feature checks
libssh2 features are detected based on version since commit
9dbbba9976

Closes #7343
2021-07-05 22:44:00 +02:00
Daniel Stenberg cffbccd096
socks4: scan for the IPv4 address in resolve results
Follow-up to 84d2839740 which changed the resolving to always resolve
both address families, but since SOCKS4 only supports IPv4 it should
scan for and use the first available IPv4 address.

Reported-by: shithappens2016 on github
Fixes #7345
Closes #7346
2021-07-05 22:38:13 +02:00
Daniel Stenberg e081048c44
formdata: avoid "Argument cannot be negative" warning
... when converting a curl_off_t to size_t, by using
CURL_ZERO_TERMINATED before passing the argument to the function.

Detected by Coverity CID 1486590.

Closes #7328
Assisted-by: Daniel Gustafsson
2021-07-01 14:15:16 +02:00
Daniel Stenberg 1ff1d9e179
lib: more %u for port and int for %*s fixes
Detected by Coverity

Closes #7329
2021-07-01 09:12:58 +02:00
Daniel Stenberg 6a40e6f8be
doh: (void)-prefix call to curl_easy_setopt 2021-07-01 00:06:27 +02:00
Daniel Stenberg 78fc6522c2
lib: fix type of len passed to *printf's %*s
... it needs to be 'int'. Detected by Coverity CID 1486611 (etc)

Closes #7326
2021-06-30 23:53:58 +02:00
Daniel Stenberg d696ee00ee
lib: use %u instead of %ld for port number printf
Follow-up to 764c6bd3bf which changed the type of some port number
fields. Detected by Coverity (CID 1486624) etc.

Closes #7325
2021-06-30 23:25:35 +02:00
Daniel Stenberg 63c7668182
version: turn version number functions into returning void
... as we never use the return codes from them.

Reviewed-by: Daniel Gustafsson
Closes #7319
2021-06-30 23:23:34 +02:00
Daniel Stenberg 5372ee37d3
mqtt: extend the error message for no topic
... and mention that it needs URL encoding.

Reported-by: Peter Körner
Fixes #7316
Closes #7317
2021-06-30 15:02:24 +02:00
Daniel Stenberg e6caaa41b0
formdata: correct typecast in curl_mime_data call
Coverity pointed out it the mismatch. CID 1486590

Closes #7327
2021-06-30 15:00:00 +02:00
Daniel Stenberg 81cc2e48da
url: (void)-prefix a curl_url_get() call
Coverity (CID 1486645) pointed out a use of curl_url_get() in the
parse_proxy function where the return code wasn't checked. A
(void)-prefix makes the intention obvious.

Closes #7320
2021-06-30 14:58:47 +02:00
Daniel Stenberg 97fa671a73
vtls: use free() not curl_free()
curl_free() is provided for users of the API to free returned data,
there's no need to use it internally.

Closes #7318
2021-06-30 13:50:18 +02:00
Jay Satiro ca8893468f http: fix crash in rate-limited upload
- Don't set the size of the piece of data to send to the rate limit if
  that limit is larger than the buffer size that will hold the piece.

Prior to this change if CURLOPT_MAX_SEND_SPEED_LARGE
(curl tool: --limit-rate) was set then it was possible that a temporary
buffer used for uploading could be written to out of bounds. A likely
scenario for this would be a non-trivial amount of post data combined
with a rate limit larger than CURLOPT_UPLOAD_BUFFERSIZE (default 64k).

The bug was introduced in 24e469f which is in releases since 7.76.0.

perl -e "print '0' x 200000" > tmp
curl --limit-rate 128k -d @tmp httpbin.org/post

Reported-by: Richard Marion

Fixes https://github.com/curl/curl/issues/7308
Closes https://github.com/curl/curl/pull/7315
2021-06-29 15:18:08 -04:00
Daniel Stenberg 4aed7a1923
openssl: avoid static variable for seed flag
Avoid the race condition risk by instead storing the "seeded" flag in
the multi handle. Modern OpenSSL versions handle the seeding itself so
doing the seeding once per multi-handle instead of once per process is
less of an issue.

Reported-by: Gerrit Renker
Fixes #7296
Closes #7306
2021-06-29 14:18:15 +02:00
Andrei Rybak 278b46751e misc: fix typos in comments which repeat a word
Fix typos in code comments which repeat various words.  In trivial
cases, just delete the repeated word.  Reword the affected sentence in
"lib/url.c" for it to make sense.

Closes #7303
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
2021-06-28 12:41:56 +02:00
Richard Whitehouse 0842175fa4
multi: alter transfer timeout ordering
- Check whether a connection has succeded before checking whether it's
  timed out.

  This means if we've connected quickly, but subsequently been
  descheduled, we allow the connection to succeed. Note, if we timeout,
  but between checking the timeout, and connecting to the server the
  connection succeeds, we will allow it to go ahead. This is viewed as
  an acceptable trade off.

- Add additional failf logging around failed connection attempts to
  propogate the cause up to the caller.

Co-Authored-by: Martin Howarth
Closes #7178
2021-06-24 15:51:39 +02:00
Daniel Stenberg 9accc48850
multi: do not switch off connect_only flag when closing
... as it made protocol specific disconnect commands wrongly get used.

Bug: https://curl.se/mail/lib-2021-06/0024.html
Reported-by: Aleksander Mazur
Closes #7288
2021-06-24 09:07:34 +02:00
Daniel Stenberg a629506d42
http: make the haproxy support work with unix domain sockets
... it should then pass on "PROXY UNKNOWN" since it doesn't know the
involved IP addresses.

Reported-by: Valentín Gutiérrez
Fixes #7290
Closes #7291
2021-06-24 09:01:49 +02:00
Bachue Zhou a8472bb8ea
quiche: use send() instead of sendto() to avoid macOS issue
sendto() always returns "Socket is already connected" error on macos

Closes #7260
2021-06-21 14:54:51 +02:00
Li Xinwei 30e491e5c9
cmake: fix support for UnixSockets feature on Win32
Move the definition of sockaddr_un struct from config-win32.h to
curl_setup.h, so that it could be shared by all build systems.

Add ADDRESS_FAMILY typedef for old mingw, now old mingw can also use
unix sockets.

Also fix the build of tests/server/sws.c on Win32 when USE_UNIX_SOCKETS
is defined.

Closes #7034
2021-06-21 14:52:27 +02:00
Gregory Muchka 62be096085
hostip: (macOS) free returned memory of SCDynamicStoreCopyProxies
From Apples documentation on SCDynamicStoreCopyProxies, "Return Value: A
dictionary of key-value pairs that represent the current internet proxy
settings, or NULL if no proxy settings have been defined or if an error
occurred. You must release the returned value."

Failure to release the returned value of SCDynamicStoreCopyProxies can
result in a memory leak.

Source: https://developer.apple.com/documentation/systemconfiguration/1517088-scdynamicstorecopyproxies

Closes #7265
2021-06-21 14:05:49 +02:00
Jay Satiro b31d9ccfc2 vtls: fix warning due to function prototype mismatch
b09c8ee changed the function prototype. Caught by Visual Studio.
2021-06-21 01:59:05 -04:00
Jay Satiro 765e060796 curl_multibyte: Remove local encoding fallbacks
- If the UTF-8 to UTF-16 conversion fails in Windows Unicode builds then
  no longer fall back to assuming the string is in a local encoding.

Background:

Some functions in Windows Unicode builds must convert UTF-8 to UTF-16 to
pass to the Windows CRT API wide-character functions since in Windows
UTF-8 is not a valid locale (or at least 99% of the time right now).

Prior to this change if the Unicode encoding conversion failed then
libcurl would assume, for backwards compatibility with applications that
may have written their code for non-Unicode builds, attempt to convert
the string from local encoding to UTF-16.

That type of "best effort" could theoretically cause some type of
security or other problem if a string that was locally encoded was also
valid UTF-8, and therefore an unexpected UTF-8 to UTF-16 conversion
could occur.

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

Closes https://github.com/curl/curl/pull/7257
2021-06-21 01:57:16 -04:00
Daniel Stenberg 4331c6dceb
curl_endian: remove the unused Curl_write64_le function
The last usage was removed in cca455a36

Closes #7280
2021-06-20 23:38:32 +02:00
Daniel Stenberg a6da296867
vtls: only store TIMER_APPCONNECT for non-proxy connect
Introducing a 'isproxy' argument to the connect function so that it
knows wether to store the time stamp or not.

Reported-by: Yongkang Huang
Fixes #7274
Closes #7274
2021-06-19 23:02:16 +02:00
Daniel Stenberg bfa0309175
gnutls: set the preferred TLS versions in correct order
Regression since 781864bedb (curl 7.77.0)

Reported-by: civodul on github
Assisted-by: Nikos Mavrogiannopoulos
Fixes #7277
Closes #7278
2021-06-18 23:22:21 +02:00
Gergely Nagy 6f5ff0ee04
configure/cmake: remove checks for unused gethostbyaddr and gethostbyaddr_r
Closes #7276
2021-06-18 13:52:21 +02:00
Gergely Nagy f471efa78c
configure/cmake: remove checks for unused inet_ntoa and inet_ntoa_r
Closes #7276
2021-06-18 13:52:18 +02:00
Gergely Nagy e92603289a
configure/cmake: remove unused define HAVE_PERROR
Closes #7276
2021-06-18 13:52:16 +02:00
Gergely Nagy 343e6beda3
configure/cmake: remove unused define HAVE_FREEIFADDRS
Closes #7276
2021-06-18 13:52:10 +02:00
Gergely Nagy 9bf0e7b2ef
configure/cmake: remove unused define HAVE_FORK
Closes #7276
2021-06-18 13:52:08 +02:00
Gergely Nagy 4e03d45bf9
configure/cmake: remove unused define HAVE_FDOPEN
Closes #7276
2021-06-18 13:52:05 +02:00
Gergely Nagy a407a82d0b
configure/cmake: remove checks for unused sgtty.h
Closes #7276
2021-06-18 13:52:02 +02:00
Gergely Nagy 8c24cf5238
configure/cmake: remove remaining checks for rsa.h
Closes #7276
2021-06-18 13:51:59 +02:00
Gergely Nagy baae00f66b
configure/cmake: remove remaining checks for err.h
Closes #7276
2021-06-18 13:51:57 +02:00
Gergely Nagy 376d2380d2
configure/cmake: remove remaining checks for crypto.h
Closes #7276
2021-06-18 13:51:54 +02:00
Gergely Nagy 67af0f7eae
configure/cmake: remove checks for unused getservbyport_r
Closes #7276
2021-06-18 13:51:45 +02:00
Daniel Stenberg fa34353d07
libssh2: limit time a disconnect can take to 1 second
Closes #7271
2021-06-17 17:06:31 +02:00
Daniel Stenberg 720b4a1a43
TLS: prevent shutdown loops to get stuck
... by making sure the loops are only allowed to read the shutdown
traffic a limited number of times.

Reported-by: Harry Sintonen
Closes #7271
2021-06-17 17:06:21 +02:00
Daniel Stenberg 80e1054fe5
hyper: propagate errors back up from read callbacks
Makes test 513 work with hyper

Closes #7266
2021-06-17 08:19:31 +02:00
Viktor Szakats 2026124691
idn: fix libidn2 with windows unicode builds
Unicode Windows builds use UTF-8 strings internally in libcurl,
so make sure to call the UTF-8 flavour of the libidn2 API. Also
document that Windows builds with libidn2 and UNICODE do expect
CURLOPT_URL as an UTF-8 string.

Reported-by: dEajL3kA on github
Assisted-by: Jay Satiro
Reviewed-by: Marcel Raad
Closes #7246
Fixes #7228
2021-06-15 12:10:48 +00:00