summaryrefslogtreecommitdiff
path: root/src/lib/libc/stdlib/recallocarray.c (unfollow)
Commit message (Collapse)AuthorFilesLines
2021-01-09Bail out early after finding an single chain if we are have been called frombeck1-1/+9
x509_vfy and have an xsc. There's no point in finding more chains since that API can not return them, and all we do is trigger buggy callbacks in calling software. ok jsing@
2021-01-08search the intermediates only after searching the root certs, clarifybeck1-11/+15
this in the comments. helps avoid annoying situations with the legacy callback ok jsing@
2021-01-07Rename two local variables ssl to s for consistencytb2-11/+11
In our tls13_* files, we use SSL *s for local variables and SSL *ssl for function arguments. This is odd, but probably the result of finger memory. We intended to use ssl everywhere. Be that as it may, all local variables except in two functions ended up being called s, so align the two outliers with that. As noted by jsing, this is not ideal either as in tls13_legacy_servername_process() the ssl_ctx is now inconsistent. Renaming all s to ssl is a substantial amount of unnecessary churn at a moment that isn't ideal, so we have to live with that. ok bcook inoguchi jsing
2021-01-07Make tls12_record_layer_free() NULL safe.jsing1-1/+5
This is not an issue currently, but avoids future surprises. Noted by tb@
2021-01-07Move the read MAC key into the TLSv1.2 record layer.jsing4-23/+20
ok inoguchi@ tb@
2021-01-06Use tls13_secret_{init,cleanup}() for the finished_keytb2-10/+10
This trades an array on the stack for a dynamically allocated secret in tls13_{client,server}_finished_send() but has the benefit of wiping out an intermediate secret on function exit. ok jsing
2021-01-06Fix two issues related to thread private data in asr.otto1-3/+10
- setting up asr in single thread mode and then starting threads using asr would lead to multiple threads sharing the same resolver. - destruction of a thread that has been using asr would leak data. Problem originally reported by Alexey Sokolov and Uli Schlachter. ok kettenis@
2021-01-05Avoid local variable in tls13_secret_init().tb1-6/+2
suggested by jsing
2021-01-05Convert tls13_record_layer.c to tls13_secret_{init,cleanup}()tb1-21/+11
ok jsing
2021-01-05Convert tls13_exporter() to tls13_secret_{init,cleanup}()tb1-8/+5
ok jsing
2021-01-05Use KNF for licence commenttb1-2/+3
ok jsing
2021-01-05Move tls13_secrets_destroy() below _create()tb1-29/+29
ok jsing
2021-01-05Convert tls13_secrets_{create,destroy}() to tls13_secret_{init,cleanup}()tb1-71/+34
ok jsing
2021-01-05Add tls13_secret_{init,cleanup}()tb2-2/+29
These are two functions that will help streamlining various functions in the TLSv1.3 code that do not need to know about the interna of this struct. input/ok jsing
2021-01-05Fix indent.jsing1-2/+2
2021-01-05Use consistent names in tls13_{client,server}_finished_{recv,send}().jsing2-12/+12
In tls13_{client,server}_finished_recv() we use verify_data_len, which makes more sense than hmac_len. Use the same name in tls13_{client,server}_finished_send(), keeping things consistent between functions. ok tb@
2021-01-05Use legacy verifier when building auto chains.jsing2-2/+6
The new verifier builds all chains, starting with the shortest possible path. It also does not currently return partial chains. Both of these things conflict with auto chain, where we want to build the longest possible chain (to include all intermediates, and probably the root unnecessarily), as well as using an incomplete chain when a trusted chain is not known. Depending on software configuration, we can end up building a chain consisting only of a leaf certificate, rather than a longer chain. This results in auto chain not including intermediates, which is undesireable. For now, switch auto chain building to use the legacy verifier. This should resolve the issues encountered by ajacoutot@ with sendmail. ok tb@
2021-01-05Handle X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE in new verifier.jsing1-1/+4
Yet another mostly meaningless error value... Noted by and ok tb@
2021-01-05Gracefully handle root certificates being both trusted and untrusted.jsing2-4/+16
When a certificate (namely a root) is specified as both a trusted and untrusted certificate, the new verifier will find multiple chains - the first being back to the trusted root certificate and a second via the root that is untrusted, followed by the trusted root certificate. This situation can be triggered by a server that (unnecessarily) includes the root certificate in its certificate list. While this validates correctly (using the first chain), it means that we encounter a failure while building the second chain due to the root certificate already being in the chain. When this occurs we call the verify callback indicating a bad certificate. Some sensitive software (including bacula and icinga), treat this single bad chain callback as terminal, even though we successfully verify the certificate. Avoid this problem by simply dumping the chain if we encounter a situation where the certificate is already in the chain and also a trusted root - we'll have already picked up the trusted root as a shorter path. Issue with icinga2 initially reported by Theodore Wynnychenko. Fix tested by sthen@ for both bacula and icinga2. ok tb@
2021-01-05Remove memset that was made redundant with the ASN1_time_parse()tb1-4/+1
fix in libcrypto/asn1/a_time_tm.c r1.16. Suggested by jsing
2021-01-05double word fix; from martin vahlensieckjmc2-6/+6
2021-01-04whitespacetb3-10/+10
2021-01-04Keep the various free calls of tls13_record_layer_free() in thetb1-4/+4
order of the struct members for reviewability. ok jsing
2021-01-02Tweak previous:schwarze1-19/+34
* Do not abuse .Bl -tag for lists without bodies, use .Bl -item instead. * In tagged lists, put bodies into bodies, not into heads. * Add a few missing macros. * Drop some useless quoting.
2021-01-02Make list of DHE parameters more prominentkn1-6/+19
Follow the previous commit and complete the manual page for consistency; better readable and tags for free. OK tb
2021-01-02Free {alert,phh}_data in tls13_record_layer_free()tb1-1/+4
httpd(8)'s incorrect tls_close() after closing the underlying socket led to a leak: tls_close()'s attempt to send out the close_notify won't work very well over a closed pipe. This resulted in alert_data still hanging off the TLSv1.3 context's record layer struct. The tls_free() call should have cleaned this up but failed to do so. The record layer's phh_data potentially has the same issue, so free it as well. This diff makes -current httpd(8) run in constant memory over hundreds of thousands TLS connections with a static site. ok inoguchi jsing
2020-12-31Remove unused categories in re_guts; they are written to but never read.millert1-39/+2
From miod@, OK tb@
2020-12-30Make the list of supported protocols more prominentkn1-5/+15
Manuals like httpd.conf(5) refer to this for valid protocol strings, but elements inlined into sentences are hard find to spot. Use a list as already done elsewhere in this manual. OK jmc on earlier version Feeback OK tb
2020-12-30Document meaning of '*' in genrsa outputtb1-3/+6
ok inoguchi jmc kn
2020-12-28Fix an off-by-one error in the marking of the O_CH operator followingmillert1-1/+4
an OOR2 operator. Also includes a regress test for the issue. From FreeBSD via miod@
2020-12-26Start each regress run from scratch with new keys and CA database.bluhm1-12/+17
2020-12-26Convert CA regress implementation from shell script to make file.bluhm5-141/+100
Ensure that it works with obj directory and link regress to build.
2020-12-25Add to *FLAGS and *ADD rather than overwriting themtb1-6/+6
This makes CFLAGS pick up -O2, which shaves a few seconds runtime off these very slow tests.
2020-12-22Destroy the mutex in tls_config objects when tls_config_free is called.bcook1-1/+3
Add a stub for pthread_mutex_destroy() for installers. ok tb@
2020-12-22Revert call to pthread_mutex_destroy until installers have a stub.bcook1-3/+1
noted by deraadt@
2020-12-21Destroy the mutex in a tls_config object when tls_config_free is called.bcook1-1/+3
ok inoguchi@
2020-12-17Remove echo headlines.bluhm15-46/+15
2020-12-16Remove a redundant memset call.tb1-2/+2
2020-12-16Remove two reduntat memset calls.tb2-5/+2
pointed out by jsing
2020-12-16Avoid potential use of uninitialized in ASN1_time_parsetb1-4/+3
When parsing an UTCTime into a struct tm that wasn't cleared by the caller, the years would be added to the already present value, which could give an incorrect result. This is an issue in ASN1_UTCTIME_cmp_time_t(), which is practically unused. Fix this by always zeroing the passed struct tm. Issue reported by Olivier Taïbi, thanks! ok jsing
2020-12-16Fix some KNF issuestb1-7/+8
2020-12-15Use natural sizes for S3I(s)->tmp's *_md arraystb1-6/+4
It is a historical artifact that cert_verify_md[], finish_md[] and peer_finish_md[] are twice as large as they need to be. This is confusing, especially for finish_md[] and peer_finish_md[] which are copied to to previous_client_finished[] and previous_server_finished[] which are only half as large. It is easy to check that they will never get more than EVP_MAX_MD_SIZE data written to them. In 1998, EVP_MAX_MD_SIZE was 20 bytes long (for SHA-1). This got bumped to 16+20 for the SSLv3-specific md5+sha1. Apparently under the impression that EVP_MAX_MD_SIZE was still 20 bytes, someone else doubled finish_md[]'s size to EVP_MAX_MD_SIZE*2 and added /* actually only needs to be 16+20 */. A bit later finish_md[] was split up, and still a bit later the comment was amended for TLSv1. Shortly thereafter SHA-512 required a bump of EVP_MAX_MD_SIZE to 64 by a third person and we have been carrying 192 bytes of untouched memory in each of our SSLs ever since. ok inoguchi jsing (jsing had the same diff)
2020-12-15Fix return value variable type in tls_keypair_load_certinoguchi1-2/+2
ERR_peek_error() returns unsigned long. Reported by github issue by @rozhuk-im. ok bcook@ jsing@
2020-12-14Fix SSL_get{,_peer}_finished() with TLSv1.3tb2-2/+28
As reported by Steffen Ullrich and bluhm, the Finished tests in p5-Net-SSLeay's t/local/43_misc_functions.t broke with with TLSv1.3. The reason for this is that we don't copy the MDs over to the SSL, so the API functions can't retrieve them. This commit fixes this part of the test (one unrelated test still fails). ok inoguchi jsing
2020-12-14Switch finish{,_peer}_md_len from int to size_ttb1-3/+3
This is the natural type for these and it simplifies an upcoming commit. The few consumers have been carefully checked to be fine with this. ok inoguchi jsing
2020-12-08LibreSSL 3.3.1libressl-v3.3.1bcook1-3/+3
2020-12-08Fix a NULL dereference in GENERAL_NAME_cmp()tb6-11/+94
Comparing two GENERAL_NAME structures containing an EDIPARTYNAME can lead to a crash. This enables a denial of service attack for an attacker who can control both sides of the comparison. Issue reported to OpenSSL on Nov 9 by David Benjamin. OpenSSL shared the information with us on Dec 1st. Fix from Matt Caswell (OpenSSL) with a few small tweaks. ok jsing
2020-12-06Enable t_mmap-1 test. It is skipped on NetBSD, but works for us.bluhm2-3/+10
2020-12-05Mark bitmask_{start,end}_values[] and g_probable_mtu[] const.tb1-4/+4
ok jsing kn
2020-12-05Mark nid_list[] const. This moves 116 bytes to .rodata.tb1-2/+2
ok jsing kn