summaryrefslogtreecommitdiff
path: root/lib
Commit message (Collapse)AuthorAgeFilesLines
* lib: fix compiler warnings with `CURL_DISABLE_VERBOSE_STRINGS`Marcel Raad2020-01-034-10/+15
| | | | Closes https://github.com/curl/curl/pull/4775
* bearssl: Improve I/O handlingMichael Forney2019-12-311-85/+77
| | | | | | | | | | | | | | | | | Factor out common I/O loop as bearssl_run_until, which reads/writes TLS records until the desired engine state is reached. This is now used for the handshake, read, write, and close. Match OpenSSL SSL_write behavior, and don't return the number of bytes written until the corresponding records have been completely flushed across the socket. This involves keeping track of the length of data buffered into the TLS engine, and assumes that when CURLE_AGAIN is returned, the write function will be called again with the same data and length arguments. This is the same requirement of SSL_write. Handle TLS close notify as EOF when reading by returning 0. Closes https://github.com/curl/curl/pull/4748
* lib: remove erroneous +x file permission on some c filesXiang Xiao2019-12-272-0/+0
| | | | | | Modified by commit eb9a604 accidentally. Closes https://github.com/curl/curl/pull/4756
* lib: fix warnings found when porting to NuttXXiang Xiao2019-12-273-1/+5
| | | | | | | | | | | | - Undefine DEBUGASSERT in curl_setup_once.h in case it was already defined as a system macro. - Don't compile write32_le in curl_endian unless CURL_SIZEOF_CURL_OFF_T > 4, since it's only used by Curl_write64_le. - Include <arpa/inet.h> in socketpair.c. Closes https://github.com/curl/curl/pull/4756
* ngtcp2: Support the latest update key callback typeJay Satiro2019-12-202-33/+1
| | | | | | | | | | | | | | | - Remove our cb_update_key in favor of ngtcp2's new ngtcp2_crypto_update_key_cb which does the same thing. Several days ago the ngtcp2_update_key callback function prototype was changed in ngtcp2/ngtcp2@42ce09c. Though it would be possible to fix up our cb_update_key for that change they also added ngtcp2_crypto_update_key_cb which does the same thing so we'll use that instead. Ref: https://github.com/ngtcp2/ngtcp2/commit/42ce09c Closes https://github.com/curl/curl/pull/4735
* create_conn: prefer multiplexing to using new connectionsDaniel Stenberg2019-12-191-18/+0
| | | | | | | | | | | ... as it would previously prefer new connections rather than multiplexing in most conditions! The (now removed) code was a leftover from the Pipelining code that was translated wrongly into a multiplex-only world. Reported-by: Kunal Ekawde Bug: https://curl.haxx.se/mail/lib-2019-12/0060.html Closes #4732
* strerror: Fix compiler warning "empty expression"Gisle Vanem2019-12-181-1/+1
| | | | | | | | | | | | | - Remove the final semi-colon in the SEC2TXT() macro definition. Before: #define SEC2TXT(sec) case sec: txt = #sec; break; After: #define SEC2TXT(sec) case sec: txt = #sec; break Prior to this change SEC2TXT(foo); would generate break;; which caused the empty expression warning. Ref: https://github.com/curl/curl/commit/5b22e1a#r36458547
* define: remove HAVE_ENGINE_LOAD_BUILTIN_ENGINES, not used anymoreDaniel Stenberg2019-12-176-16/+2
| | | | | | | | | It is covered by USE_OPENSSL_ENGINE now. Reported-by: Gisle Vanem Bug: https://github.com/curl/curl/commit/87b9337c8f76c21c57b204e88b68c6ecf3bd1ac0#commitcomment-36447951 Closes #4725
* lib: remove ASSIGNWITHINCONDITION exceptions, use our code styleDaniel Stenberg2019-12-172-5/+14
| | | | | | | | | | ... even for macros Reviewed-by: Daniel Gustafsson Reviewed-by: Jay Satiro Reported-by: Jay Satiro Fixes #4683 Closes #4722
* Revert "checksrc: fix regexp for ASSIGNWITHINCONDITION"Daniel Stenberg2019-12-162-1/+2
| | | | | | This reverts commit ba82673dac3e8d00a76aa5e3779a0cb80e7442af. Bug: #4683
* libssh2: add support for ECDSA and ed25519 knownhost keysSantino Keupp2019-12-151-47/+81
| | | | | | | | ... if a new enough libssh2 version is present. Source: https://curl.haxx.se/mail/archive-2019-12/0023.html Co-Authored-by: Daniel Stenberg Closes #4714
* multi: free sockhash on OOMDaniel Stenberg2019-12-131-0/+1
| | | | | | | | This would otherwise leak memory in the error path. Detected by torture test 1540. Closes #4713
* hostip: suppress compiler warningMarcel Raad2019-12-131-0/+4
| | | | | | | With `--disable-doh --disable-threaded-resolver`, the `dns` parameter is not used. Closes https://github.com/curl/curl/pull/4692
* ntlm_wb: fix double-free in OOMDaniel Stenberg2019-12-131-11/+6
| | | | | | Detected by torture testing test 1310 Closes #4710
* altsvc: make the save function ignore NULL filenamesDaniel Stenberg2019-12-121-2/+2
| | | | | | It might happen in OOM situations. Detected bv torture tests. Closes #4707
* doh: make it behave when built without proxy supportDaniel Stenberg2019-12-121-16/+18
| | | | | | | Reported-by: Marcel Raad Bug: https://github.com/curl/curl/pull/4692#issuecomment-564115734 Closes #4704
* conncache: CONNECT_ONLY connections assumed always in-useDaniel Stenberg2019-12-111-1/+2
| | | | | | | | | | | | | | | This makes them never to be considered "the oldest" to be discarded when reaching the connection cache limit. The reasoning here is that CONNECT_ONLY is primarily used in combination with using the connection's socket post connect and since that is used outside of curl's knowledge we must assume that it is in use until explicitly closed. Reported-by: Pavel Pavlov Reported-by: Pavel Löbl Fixes #4426 Fixes #4369 Closes #4696
* vtls: make BearSSL possible to set with CURL_SSL_BACKENDGisle Vanem2019-12-101-0/+3
| | | | | | Ref: https://github.com/curl/curl/commit/9b879160df01e7ddbb4770904391d3b74114302b#commitcomment-36355622 Closes #4698
* conn: always set bits.close with connclose()Daniel Stenberg2019-12-092-3/+4
| | | | Closes #4690
* conncache: fix multi-thread use of shared connection cacheDaniel Stenberg2019-12-097-52/+52
| | | | | | | | | It could accidentally let the connection get used by more than one thread, leading to double-free and more. Reported-by: Christopher Reid Fixes #4544 Closes #4557
* lib: fix some loose ends for recently added CURLSSLOPT_NO_PARTIALCHAINJay Satiro2019-12-051-0/+1
| | | | | | | | | | | | | Add support for CURLSSLOPT_NO_PARTIALCHAIN in CURLOPT_PROXY_SSL_OPTIONS and OS400 package spec. Also I added the option to the NameValue list in the tool even though it isn't exposed as a command-line option (...yet?). (NameValue stringizes the option name for the curl cmd -> libcurl source generator) Follow-up to 564d88a which added CURLSSLOPT_NO_PARTIALCHAIN. Ref: https://github.com/curl/curl/pull/4655
* setopt: Fix ALPN / NPN user option when built without HTTP2Jay Satiro2019-12-051-2/+0
| | | | | | | | | | | | | | | | - Stop treating lack of HTTP2 as an unknown option error result for CURLOPT_SSL_ENABLE_ALPN and CURLOPT_SSL_ENABLE_NPN. Prior to this change it was impossible to disable ALPN / NPN if libcurl was built without HTTP2. Setting either option would result in CURLE_UNKNOWN_OPTION and the respective internal option would not be set. That was incorrect since ALPN and NPN are used independent of HTTP2. Reported-by: Shailesh Kapse Fixes https://github.com/curl/curl/issues/4668 Closes https://github.com/curl/curl/pull/4672
* curl_setup: fix `CURLRES_IPV6` conditionMarcel Raad2019-12-051-6/+6
| | | | | | | | | Move the definition of `CURLRES_IPV6` to before undefining `HAVE_GETADDRINFO`. Regression from commit 67a08dca27a which caused some tests to fail and others to be skipped with c-ares. Fixes https://github.com/curl/curl/issues/4673 Closes https://github.com/curl/curl/pull/4677
* CMake: add support for building with the NSS vtls backendPeter Wu2019-12-041-0/+3
| | | | | | | | Options are cross-checked with configure.ac and acinclude.m4. Tested on Arch Linux, untested on other platforms like Windows or macOS. Closes #4663 Reviewed-by: Kamil Dudka
* hostip4.c: bump copyright year rangeDaniel Stenberg2019-12-031-1/+1
|
* curl_setup: disable IPv6 resolver without `getaddrinfo`Marcel Raad2019-12-033-3/+23
| | | | | | | | | | Also, use `CURLRES_IPV6` only for actual DNS resolution, not for IPv6 address support. This makes it possible to connect to IPv6 literals by setting `ENABLE_IPV6` even without `getaddrinfo` support. It also fixes the CMake build when using the synchronous resolver without `getaddrinfo` support. Closes https://github.com/curl/curl/pull/4662
* openssl: CURLSSLOPT_NO_PARTIALCHAIN can disable partial cert chainsDaniel Stenberg2019-12-033-6/+10
| | | | Closes #4655
* openssl: set X509_V_FLAG_PARTIAL_CHAINDaniel Stenberg2019-12-031-9/+17
| | | | | | | | | | | | Have intermediate certificates in the trust store be treated as trust-anchors, in the same way as self-signed root CA certificates are. This allows users to verify servers using the intermediate cert only, instead of needing the whole chain. Other TLS backends already accept partial chains. Reported-by: Jeffrey Walton Bug: https://curl.haxx.se/mail/lib-2019-11/0094.html
* copyright: fix the year ranges for two filesDaniel Stenberg2019-12-021-1/+1
| | | | Follow-up to 9c1806ae
* build: Disable Visual Studio warning "conditional expression is constant"Jay Satiro2019-12-0121-47/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Disable warning C4127 "conditional expression is constant" globally in curl_setup.h for when building with Microsoft's compiler. This mainly affects building with the Visual Studio project files found in the projects dir. Prior to this change the cmake and winbuild build systems already disabled 4127 globally for when building with Microsoft's compiler. Also, 4127 was already disabled for all build systems in the limited circumstance of the WHILE_FALSE macro which disabled the warning specifically for while(0). This commit removes the WHILE_FALSE macro and all other cruft in favor of disabling globally in curl_setup. Background: We have various macros that cause 0 or 1 to be evaluated, which would cause warning C4127 in Visual Studio. For example this causes it: #define Curl_resolver_asynch() 1 Full behavior is not clearly defined and inconsistent across versions. However it is documented that since VS 2015 Update 3 Microsoft has addressed this somewhat but not entirely, not warning on while(true) for example. Prior to this change some C4127 warnings occurred when I built with Visual Studio using the generated projects in the projects dir. Closes https://github.com/curl/curl/pull/4658
* openssl: retrieve reported LibreSSL version at runtimeJay Satiro2019-12-011-6/+24
| | | | | | | | | | - Retrieve LibreSSL runtime version when supported (>= 2.7.1). For earlier versions we continue to use the compile-time version. Ref: https://man.openbsd.org/OPENSSL_VERSION_NUMBER.3 Closes https://github.com/curl/curl/pull/2425
* strerror: Add Curl_winapi_strerror for Win API specific errorsJay Satiro2019-12-013-350/+245
| | | | | | | | | | | | | | | - In all code call Curl_winapi_strerror instead of Curl_strerror when the error code is known to be from Windows GetLastError. Curl_strerror prefers CRT error codes (errno) over Windows API error codes (GetLastError) when the two overlap. When we know the error code is from GetLastError it is more accurate to prefer the Windows API error messages. Reported-by: Richard Alcock Fixes https://github.com/curl/curl/issues/4550 Closes https://github.com/curl/curl/pull/4581
* global_init: undo the "intialized" bump in case of failureDaniel Stenberg2019-12-021-5/+9
| | | | | | | | | ... so that failures in the global init function don't count as a working init and it can then be called again. Reported-by: Paul Groke Fixes #4636 Closes #4653
* parsedate: offer a getdate_capped() alternativeDaniel Stenberg2019-11-296-9/+36
| | | | | | | | | | | ... and use internally. This function will return TIME_T_MAX instead of failure if the parsed data is found to be larger than what can be represented. TIME_T_MAX being the largest value curl can represent. Reviewed-by: Daniel Gustafsson Reported-by: JanB on github Fixes #4152 Closes #4651
* sha256: bump the copyright year rangeDaniel Stenberg2019-11-281-1/+1
| | | | Follow-up from 66e21520f
* curl_setup_once: consistently use WHILE_FALSE in macrosDaniel Gustafsson2019-11-283-4/+4
| | | | | | | | | The WHILE_FALSE construction is used to avoid compiler warnings in macro constructions. This fixes a few instances where it was not used in order to keep the code consistent. Closes #4649 Reviewed-by: Daniel Stenberg <daniel@haxx.se>
* http_ntlm: Remove duplicate NSS initialisationSteve Holme2019-11-281-8/+1
| | | | | | | | | | | Given that this is performed by the NTLM code there is no need to perform the initialisation in the HTTP layer. This also keeps the initialisation the same as the SASL based protocols and also fixes a possible compilation issue if both NSS and SSPI were to be used as multiple SSL backends. Reviewed-by: Kamil Dudka Closes #3935
* checksrc: fix regexp for ASSIGNWITHINCONDITIONDaniel Gustafsson2019-11-282-2/+1
| | | | | | | | | | | | | | | | | | | | | The regexp looking for assignments within conditions was too greedy and matched a too long string in the case of multiple conditionals on the same line. This is basically only a problem in single line macros, and the code which exemplified this was essentially: do { if((x) != NULL) { x = NULL; } } while(0) ..where the final parenthesis of while(0) matched the regexp, and the legal assignment in the block triggered the warning. Fix by making the regexp less greedy by matching for the tell-tale signs of the if statement ending. Also remove the one occurrence where the warning was disabled due to a construction like the above, where the warning didn't apply when fixed. Closes #4647 Reviewed-by: Daniel Stenberg <daniel@haxx.se>
* doh: use dedicated probe slotsNiall2019-11-282-41/+63
| | | | | | ... to easier allow additional DNS transactions. Closes #4629
* ngtcp2: fix thread-safety bug in error-handlingDavid Benjamin2019-11-281-2/+3
| | | | | | | | ERR_error_string(NULL) should never be called. It places the error in a global buffer, which is not thread-safe. Use ERR_error_string_n with a local buffer instead. Closes #4645
* XFERINFOFUNCTION: support CURL_PROGRESSFUNC_CONTINUEJohn Schroeder2019-11-261-7/+11
| | | | | | | | | (also for PROGRESSFUNCTION) By returning this value from the callback, the internal progress function call is still called afterward. Closes #4599
* TLS: add BearSSL vtls implementationMichael Forney2019-11-267-4/+918
| | | | Closes #4597
* multi: add curl_multi_wakeup()Gergely Nagy2019-11-253-3/+124
| | | | | | | | | | | | This commit adds curl_multi_wakeup() which was previously in the TODO list under the curl_multi_unblock name. On some platforms and with some configurations this feature might not be available or can fail, in these cases a new error code (CURLM_WAKEUP_FAILURE) is returned from curl_multi_wakeup(). Fixes #4418 Closes #4608
* schannel: fix --tls-max for when min is --tlsv1 or defaultXiaoyin Liu2019-11-241-4/+0
| | | | | | | | Prior to this change schannel ignored --tls-max (CURL_SSLVERSION_MAX_ macros) when --tlsv1 (CURL_SSLVERSION_TLSv1) or default TLS (CURL_SSLVERSION_DEFAULT), using a max of TLS 1.2 always. Closes https://github.com/curl/curl/pull/4633
* openssl: Revert to less sensitivity for SYSCALL errorsJay Satiro2019-11-221-13/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Disable the extra sensitivity except in debug builds (--enable-debug). - Improve SYSCALL error message logic in ossl_send and ossl_recv so that "No error" / "Success" socket error text isn't shown on SYSCALL error. Prior to this change 0ab38f5 (precedes 7.67.0) increased the sensitivity of OpenSSL's SSL_ERROR_SYSCALL error so that abrupt server closures were also considered errors. For example, a server that does not send a known protocol termination point (eg HTTP content length or chunked encoding) _and_ does not send a TLS termination point (close_notify alert) would cause an error if it closed the connection. To be clear that behavior made it into release build 7.67.0 unintentionally. Several users have reported it as an issue. Ultimately the idea is a good one, since it can help prevent against a truncation attack. Other SSL backends may already behave similarly (such as Windows native OS SSL Schannel). However much more of our user base is using OpenSSL and there is a mass of legacy users in that space, so I think that behavior should be partially reverted and then rolled out slowly. This commit changes the behavior so that the increased sensitivity is disabled in all curl builds except curl debug builds (DEBUGBUILD). If after a period of time there are no major issues then it can be enabled in dev and release builds with the newest OpenSSL (1.1.1+), since users using the newest OpenSSL are the least likely to have legacy problems. Bug: https://github.com/curl/curl/issues/4409#issuecomment-555955794 Reported-by: Bjoern Franke Fixes https://github.com/curl/curl/issues/4624 Closes https://github.com/curl/curl/pull/4623
* openssl: improve error message for SYSCALL during connectDaniel Stenberg2019-11-221-1/+6
| | | | | | | Reported-by: Paulo Roberto Tomasi Bug: https://curl.haxx.se/mail/archive-2019-11/0005.html Closes https://github.com/curl/curl/pull/4593
* include: make CURLE_HTTP3 use a new error codeDaniel Stenberg2019-11-211-0/+1
| | | | | | | | | To avoid potential issues with error code reuse. Reported-by: Christoph M. Becker Assisted-by: Dan Fandrich Fixes #4601 Closes #4627
* ngtcp2: use overflow buffer for extra HTTP/3 dataJavier Blazquez2019-11-186-37/+218
| | | | | Fixes #4525 Closes #4603
* altsvc: bump to h3-24Daniel Stenberg2019-11-181-2/+2
| | | | | | ... as both ngtcp2 and quiche now support that in their master branches Closes #4604
* ngtcp2: free used resources on disconnectDaniel Stenberg2019-11-182-7/+17
| | | | | Fixes #4614 Closes #4615