Truncated valgrind output capturing the crash follows:
Invalid read of size 8
at 0x628B4A0: PR_Close (priometh.c:104)
by 0x43C088: nss_close (nss.c:1356)
by 0x43C17F: Curl_nss_close (nss.c:1377)
by 0x438F42: Curl_ssl_close (vtls.c:618)
by 0x45460B: Curl_disconnect (url.c:3000)
by 0x42EACA: close_all_connections (multi.c:1887)
by 0x42EB37: curl_multi_cleanup (multi.c:1907)
by 0x44B4CA: Curl_close (url.c:427)
by 0x4282C2: curl_easy_cleanup (easy.c:859)
by 0x41341C: main_free (tool_main.c:206)
by 0x4134F4: main (tool_main.c:260)
Address 0x99afa10 is 0 bytes inside a block of size 48 free'd
at 0x4C29D6A: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
by 0x62A2C33: pt_Close (ptio.c:1277)
by 0x43BACD: nspr_io_close (nss.c:1141)
by 0x54D6E25: ssl_DefClose (ssldef.c:203)
by 0x43BACD: nspr_io_close (nss.c:1141)
by 0x54D6E25: ssl_DefClose (ssldef.c:203)
by 0x43C088: nss_close (nss.c:1356)
by 0x43C173: Curl_nss_close (nss.c:1376)
by 0x438F42: Curl_ssl_close (vtls.c:618)
by 0x45460B: Curl_disconnect (url.c:3000)
by 0x42EACA: close_all_connections (multi.c:1887)
by 0x42EB37: curl_multi_cleanup (multi.c:1907)
Block was alloc'd at
at 0x4C28C50: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
by 0x6289F71: _PR_Getfd (prfdcach.c:103)
by 0x62A4816: pt_SetMethods.isra.13 (ptio.c:3303)
by 0x62A56E5: PR_ImportTCPSocket (ptio.c:4577)
by 0x43D4D0: nss_setup_connect (nss.c:1733)
by 0x43DDCA: nss_connect_common (nss.c:1929)
by 0x43DF1E: Curl_nss_connect_nonblocking (nss.c:1985)
by 0x4386CE: Curl_ssl_connect_nonblocking (vtls.c:364)
by 0x47F02C: https_proxy_connect (http_proxy.c:58)
by 0x47F086: Curl_proxy_connect (http_proxy.c:74)
by 0x445891: Curl_http_connect (http.c:1348)
by 0x42D613: multi_runsingle (multi.c:1233)
Without this workaround, NSS re-uses a session cache entry despite the
server name does not match. This causes SNI host name to differ from
the actual host name. Consequently, certain servers (e.g. github.com)
respond by 400 to such requests.
Bug: https://bugzilla.mozilla.org/1202264
HTTPS proxies:
An HTTPS proxy receives all transactions over an SSL/TLS connection. Once a
secure connection with the proxy is established, the user agent uses the proxy
as usual, including sending CONNECT requests to instruct the proxy to establish
a [usually secure] TCP tunnel with an origin server. HTTPS proxies protect
nearly all aspects of user-proxy communications as opposed to HTTP proxies that
receive all requests (including CONNECT requests) in vulnerable clear text.
With HTTPS proxies, it is possible to have two concurrent _nested_ SSL/TLS
sessions: the "outer" one between the user agent and the proxy and the "inner"
one between the user agent and the origin server (through the proxy). This
change adds supports for such nested sessions as well.
The secure connection with the proxy requires its own set of the usual
SSL/TLS-related options (their descriptions need polishing):
--proxy-cacert FILE CA certificate to verify peer against
--proxy-capath DIR CA directory to verify peer against
--proxy-cert CERT[:PASSWD] Client certificate file and password
--proxy-cert-type TYPE Certificate file type (DER/PEM/ENG)
--proxy-ciphers LIST SSL ciphers to use
--proxy-crlfile FILE Get a CRL list in PEM format from the given file
--proxy-insecure Allow connections to SSL sites without certs
--proxy-key KEY Private key file name
--proxy-key-type TYPE Private key file type (DER/PEM/ENG)
--proxy-pass PASS Pass phrase for the private key
--proxy-ssl-allow-beast Allow security flaw to improve interop
--proxy-sslv2 Use SSLv2
--proxy-sslv3 Use SSLv3
--proxy-tlsv1 Use TLSv1
--proxy-tlsuser USER TLS username
--proxy-tlspassword STRING TLS password
--proxy-tlsauthtype STRING TLS authentication type (default SRP)
All --proxy-foo options are independent from their --foo counterparts, except
--proxy-crlfile defaults to --crlfile and --proxy-capath defaults to --capath.
Curl now also supports %{proxy_ssl_verify_result} --write-out variable,
similar to the existing %{ssl_verify_result} variable.
SOCKS proxy + HTTP/HTTPS proxy combination:
If both --socks* and --proxy options are given, Curl first connects to the
SOCKS proxy and then connects (through SOCKS) to the HTTP or HTTPS proxy.
This header file must be included after all header files except
memdebug.h, as it does similar memory function redefinitions and can be
similarly affected by conflicting definitions in system or dependent
library headers.
The function "free" is documented in the way that no action shall occur for
a passed null pointer. It is therefore not needed that a function caller
repeats a corresponding check.
http://stackoverflow.com/questions/18775608/free-a-null-pointer-anyway-or-check-first
This issue was fixed by using the software Coccinelle 1.0.0-rc24.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
The vtls layer now checks the return value, so it is no longer necessary
to abort if a random number cannot be provided by NSS. This also fixes
the following Coverity report:
Error: FORWARD_NULL (CWE-476):
lib/vtls/nss.c:1918: var_compare_op: Comparing "data" to null implies that "data" might be null.
lib/vtls/nss.c:1923: var_deref_model: Passing null pointer "data" to "Curl_failf", which dereferences it.
lib/sendf.c:154:3: deref_parm: Directly dereferencing parameter "data".
Correctly check for memcmp() return value (it returns 0 if the strings match).
This is not really important, since curl is going to use http/1.1 anyway, but
it's still a bug I guess.
Carrying on from commit 037cd0d991, removed the following unimplemented
instances of curlssl_close_all():
Curl_axtls_close_all()
Curl_darwinssl_close_all()
Curl_cyassl_close_all()
Curl_gskit_close_all()
Curl_gtls_close_all()
Curl_nss_close_all()
Curl_polarssl_close_all()
curl_schannel.h:123: warning: right-hand operand of comma expression
has no effect
Some instances of the curlssl_close_all() function were declared with a
void return type whilst others as int. The schannel version returned
CURLE_NOT_BUILT_IN and others simply returned zero, but in all cases the
return code was ignored by the calling function Curl_ssl_close_all().
For the time being and to keep the internal API consistent, changed all
declarations to use a void return type.
To reduce code we might want to consider removing the unimplemented
versions and use a void #define like schannel does.
- Remove SSLv3 from SSL default in darwinssl, schannel, cyassl, nss,
openssl effectively making the default TLS 1.x. axTLS is not affected
since it supports only TLS, and gnutls is not affected since it already
defaults to TLS 1.x.
- Update CURLOPT_SSLVERSION doc
To force each backend implementation to really attempt to provide proper
random. If a proper random function is missing, then we can explicitly
make use of the default one we use when TLS support is missing.
This commit makes sure it works for darwinssl, gnutls, nss and openssl.