summaryrefslogtreecommitdiff
path: root/src/lib/libc/stdlib/recallocarray.c (unfollow)
Commit message (Collapse)AuthorFilesLines
2020-11-20fix confusing line break and indenttb1-3/+4
2020-11-19$OpenBSD$tb1-0/+1
2020-11-18Plug leak in x509_verify_chain_dup()tb1-2/+2
x509_verify_chain_new() allocates a few members of a certificate chain: an empty stack of certificates, a list of errors encountered while validating the chain, and a list of name constraints. The function to copy a chain would allocate a new chain using x509_verify_chain_new() and then clobber its members by copies of the old chain. Fix this by replacing x509_verify_chain_new() with calloc(). Found by review while investigating the report by Hanno Zysik who found the same leak using valgrind. This is a cleaner version of my initial fix from jsing. ok jsing
2020-11-18Plug a big memory leak in the new validatortb1-1/+6
The legacy validator would only call x509_vfy_check_policy() once at the very end after cobbling together a chain. Therefore it didn't matter that X509_policy_check() always allocates a new tree on top of the one that might have been passed in. This is in stark contrast to other, similar APIs in this code base. The new validator calls this function several times over while building its chains. This adds up to a sizable leak in the new validator. Reported with a reproducer by Hanno Zysik on github, who also bisected this to the commit enabling the new validator. Narrowed down to x509_vfy_check_policy() by jsing. We simultaenously came up with a functionally identical fix. ok jsing
2020-11-18zap ugly empty line before closing bracetb1-2/+1
2020-11-18Move freeing of the verify context to its natural place instead oftb1-2/+2
a few lines after. stylistic nit from jsing
2020-11-18KNF (whitespace)tb4-13/+13
2020-11-18bump to 3.3.0bcook1-3/+3
2020-11-18Don't leak verify and store contexts.tb1-1/+3
2020-11-17typo & punctuation in commenttb1-3/+3
2020-11-16Implement exporter for TLSv1.3.jsing4-8/+121
This implements the key material exporter for TLSv1.3, as defined in RFC8446 section 7.5. Issue reported by nmathewson on github. ok inoguchi@ tb@
2020-11-16Use X509_V_OK instead of 0.jsing1-4/+3
ok beck@ tb@
2020-11-16Add back an X509_STORE_CTX error code assignment.jsing1-2/+3
This was inadvertently removed in r1.19. Spotted by tb@ ok beck@ tb@
2020-11-15Return the specific failure for a "self signed certificate" in the chainbeck1-1/+14
in order to be compatible with the openssl error craziness in the legacy verifier case. This will fix a regress problem noticed by znc ok tb@
2020-11-11Handle additional certificate error cases in new X.509 verifier.jsing2-12/+79
With the old verifier, the verify callback can always return 1 instructing the verifier to simply continue regardless of a certificate verification failure (e.g. the certificate is expired or revoked). This would result in a chain being built, however the first error encountered would be persisted, which allows the caller to build the chain, have the verification process succeed, yet upon inspecting the error code note that the chain is not valid for some reason. Mimic this behaviour by keeping track of certificate errors while building chains - when we finish verification, find the certificate error closest to the leaf certificate and expose that via the X509_STORE_CTX. There are various corner cases that we also have to handle, like the fact that we keep an certificate error until we find the issuer, at which point we have to clear it. Issue reported by Ilya Shipitcin due to failing haproxy regression tests. With much discussion and input from beck@ and tb@! ok beck@ tb@
2020-11-11Implement auto chain for the TLSv1.3 server.jsing1-1/+23
Apparently OpenLDAP relies on this craziness to provide intermediates, rather than specifying the chain directly like a normal TLS server would. Issue noted by sthen@ and Bernard Spil, who both also tested this diff. ok tb@
2020-11-11Use size_t for key_block_len.jsing2-9/+7
This allows us to remove a check and will make future changes simpler. Use suitable names for tls1_generate_key_block() arguments while here. ok inoguchi@ tb@
2020-11-11Run the atf cleanup block after each test. This makes more testsbluhm1-9/+11
pass when run as non root.
2020-11-11Update getentropy on Windows to use Cryptography Next Generation (CNG).bcook1-18/+9
wincrypt is deprecated and no longer works with newer Windows environments, such as in Windows Store apps.
2020-11-10Declare prototype of __syscall locally. Fixes t_syscall test.bluhm2-3/+7
2020-11-09Sync libc syscall tests with changes in upstream NetBSD. Use #ifdefbluhm20-283/+212
to document differences to NetBSD behaviour, this helps to track upstream. Mark currently failing test as expected failures. So test programs get compiled and executed, but it shows that further investigation is necceassry.
2020-11-05Skip test if web server cannot be pinged.bluhm1-6/+14
2020-11-03Wrap remaining overlong lines.tb1-7/+7
2020-11-03garbage collect an essentially unused variable and wrap some overlongtb1-8/+10
lines
2020-11-03* ptr -> *ptrtb1-5/+5
2020-11-03X509_verify_cert()'s return value is not reliable if the callbacktb1-20/+22
returns 1. verify.c's cb() ignores a bunch of things to display as much info as possible. Thus, check the error code on the store ctx as well, similar to OpenSSL commit d9e309a6 (old licence). This makes openssl verify error on expired certs, at least with the legacy verify code. While here, fix a number of style issues, simplify and plug a leak. ok inoguchi
2020-11-03Fix bad indent.jsing1-7/+6
2020-11-03Only check BIO_should_read() on read and BIO_should_write() on write.jsing1-5/+1
The TLSv1.3 code that drives a BIO currently checks BIO_should_read() after BIO_write() and BIO_should_write() after BIO_read(), which was modelled on SSL_get_error(). However, there are certain cases where this can confuse the caller - primarily where the same BIO is being used for both read and write and the caller is manipulating the retry flags. SSL_get_error() tends avoids this issue by relying on another layer of state tracking. Unfortunately haproxy hits this situation - it has its own BIO_METHOD, the same BIO is used for both read and write and it manipulates the retry flags - resulting in it stalling. Issued noted by Thorsten Lockert <tholo@tzecmaun.org> ok beck@ tb@
2020-11-03Hook X509_STORE_CTX get_issuer() callback from new X509 verifier.jsing1-3/+17
If we fail to find a parent certificate from either the supplied roots or intermediates and we have a X509_STORE_CTX, call its get_issuer() callback to see if it can supply a suitable certificate. This makes things like certificates by directory (aka by_dir) work correctly. Issue noted by Uwe Werler <uwe@werler.is> ok beck@ tb@
2020-11-02typo: ASN1_parse_time -> ASN1_time_parsetb1-3/+3
2020-11-01some comma fixes; from varik valeforjmc1-12/+12
(audio.4 tweaked from that submitted)
2020-10-30botan2 uses C++11, so use ports-gcc on gcc-archstb1-1/+12
This makes this interop test pass on sparc64.
2020-10-29Do not fail with obscure error messages on 'make'tb3-6/+12
Fix some tests that fail with obscure error messages on 'make' if the required package (either version of OpenSSL or Botan 2) isn't installed. This can be avoided by doing 'make regress' instead. I'll try to adjust my finger memory for the many tests outside the LibreSSL tree that have the same "problem". The fix here is unintrusive and I've been wasting enough time with this to want to change it. ok bluhm
2020-10-26catch unset error when validation fails.beck2-2/+16
2020-10-26Add a safety net to ensure that we set an error on the store context.tb1-1/+3
Suggested by and discussed with beck
2020-10-26If x509_verify() fails, ensure that the error is also set on the storetb1-10/+15
context. This is what is returned in SSL_get_verify_result(). Spotted and initial diff from jeremy; discussed with jsing ok beck
2020-10-26Make sure that x509_vfy_check_id() failure also sets ctx->error, not onlytb1-3/+8
ctx->xsc->error. Will be needed in an upcoming diff. from beck
2020-10-26Add a -legacy_verify flag to force use of the old validator for debuggingtb3-4/+13
and testing purposes. ok beck inoguchi jsing
2020-10-21Stop documenting some functions as macros.tb3-19/+7
In x509.h r1.70 (2018/08/24) I turned some macros into actual functions to follow what OpenSSL is doing since 1.1.0. The documentation still claims that they are implemented as macros. Update a doc sync commit hash while there.
2020-10-21On machines with a userland timecounter we bypass the gettimeofday(2)kettenis1-2/+16
syscall. So whenever we pass a bad address we get a SIGSEGV instead of EFAULT. POSIX explicitly allows this behaviour. So adjust the test to deal with this case. ok deraadt@, millert@, guenther@
2020-10-19Skip floating-point exception checks on arm64 and armv7 as the hardwarekettenis2-2/+6
(typically) doesn't implement support for these. ok patrick@, drahn@
2020-10-18XFAIL tests on arm64 and armv7 as floating-point exception support iskettenis1-1/+6
optional and isn't implemented on most hardware.
2020-10-16make this test compile and pass on sparc64tb1-2/+2
Two functions missed (void) in their declaration which made gcc whine "warning: function declaration isn't a prototype".
2020-10-16Add an explicit cast to make this test compile and pass with gcc.tb1-2/+2
gcc emits a signed vs unsigned comparison warning which breaks the build due to -Werror.
2020-10-16Refactor a bunch of oscpcheck for single return to clean it up,beck1-63/+95
and add the ability to parse a port in the specified ocsp url. Since this will now pass them, enable regress tests previously committed for ocspcheck. mostly by me with some cleanup by tb after an obvious yak was found to shave in the OCSP routines in libcrypto ok tb@
2020-10-15Test DTLS timeouts and retransmissions by dropping specific messages.jsing1-5/+299
Provide a BIO that can drop specific messages in order to trigger and test DTLS timeouts and retransmissions. Note that the SSL buffering BIO (bbio) has to be removed to ensure that handshake messages are sent individually. This would have detected the recent DTLS breakage with retransmissions for a flight that includes a CCS.
2020-10-15Unbreak DTLS retransmissions for flights that include a CCS.jsing1-7/+8
When retransmitting a flight that includes a CCS, the record protection from the previous epoch has to be used to send the messages up to and including the CCS, with messages after the CCS using record protection from the current epoch. The code that restores the record protection state failed to work correctly with the new TLSv1.2 record layer. ok tb@
2020-10-15Improve poll and event handling.jsing1-8/+27
In particular, ensure we clear events when the client or server side has completed and fix timeouts to ensure we use a non-zero timeout if present.
2020-10-15zap annoying stray spacestb1-4/+4
2020-10-14Replace SSL_IS_DTLS with SSL_is_dtls().jsing11-96/+92
Garbage collect the now unused SSL_IS_DTLS macro. ok tb@