summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/bio/bio_lib.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Hide symbols for two missed public functions in bio.hbeck2024-07-091-1/+2
| | | | ok tb@
* Unify *_up_ref() implementationstb2024-03-271-3/+2
| | | | | | No need for an inconsistently named local variable and a ternary operator. ok jsing
* Remove BIO_set()tb2024-03-021-9/+1
| | | | | | | This used to be a dangerous implementation detail of BIO_new() that was never used outside of libcrypto. ok jsing
* Use calloc() instead of malloc() in BIO_new().jsing2024-02-171-16/+5
| | | | ok tb@
* Inline and disable BIO_set().jsing2024-02-161-21/+19
| | | | | | | | BIO_set() is a dangerous function that cannot be used safely. Thankfully, the only consumer is BIO_new(), hence inline the functionality and disable the BIO_set() function (for complete removal in the near future). ok tb@
* Use 'bio' more consistently for function arguments.jsing2024-02-161-58/+61
| | | | | | | | Rather than 'a' or 'b', use 'bio' more consistently - there are still some more complex cases that have been left alone for now. Also use fewer parentheses. No change to generated assembly other than line numbers.
* Fix two leaks in BIO_dup_chain()tb2023-08-071-19/+17
| | | | | | | | If CRYPTO_dup_ex_data() fails, the new_bio is leaked. If an error occurs after the first iteration, all members of the new chain except the head are leaked. ok jsing
* BIO_indent: use %*s rather than puts in a looptb2023-07-101-6/+5
| | | | ok beck jsing millert
* Unbreak the namespace build after a broken mk.conf and tool misfire hadbeck2023-07-071-2/+1
| | | | | | | | me aliasing symbols not in the headers I was procesing. This unbreaks the namespace build so it will pass again ok tb@
* Hide symbols in asn1 and biobeck2023-07-051-1/+51
| | | | ok jsing@
* Streaming BIOs assume they can write to NULL BIOstb2023-03-151-5/+4
| | | | | | | | | | At least SMIME_text() relies on this. Pushing an error on the stack trips PKCS7 regress in py-cryptography, so indicate nothing was written instead of throwing an error. Reported by Alex Gaynor a while back ok jsing
* Revert BIO_push(3) cycle prevention (bio_lib.c rev. 1.42).schwarze2022-12-161-7/+1
| | | | | | | | | | | | | | | | | | | jsing@ worries that cycle prevention might increase risk because software that is not checking return values (and indeed, not checking is likely common in practice) might silently behave incorrectly with cycle prevention whereas without, it will likely either crash right away through infinite recursion or at least hang in an infinite loop when trying to use the cyclic chain, in both cases making it likely that the bug will be found and fixed. Besides, tb@ points out that BIO_set_next(3) ought to behave as similarly as possible to BIO_push(3), but adding cycle prevention to BIO_set_next(3) would be even less convincing because that function does not provide a return value, encouraging users to expect that it will always succeed. While a safe idiom for checking the success of BIO_set_next(3) could easily be designed, let's be realistic: application software would be highly unlikely to pick up such an idiom.
* Improve the implementation of BIO_push(3) such that it changes nothingschwarze2022-12-071-1/+7
| | | | | | and reports failure if a call would result in a cycle. The algorithm used was originally suggested by jsing@. Feedback and OK tb@.
* Make sure BIO_push(3) always preserves all invariants of the prev_bioschwarze2022-12-061-3/+10
| | | | | | | | | | | | | | | | | | | | and next_bio fields of all BIO objects in all affected chains, no matter what the arguments are. In particular, if the second argument (the one to be appended) is not at the beginning of its chain, properly detach the beginning of its chain before appending. We have weak indications that this bug might affect real-world code. For example, in FreeRDP, file libfreerdp/crypto/tls.c, function bio_rdp_tls_ctrl(), case BIO_C_SET_SSL, BIO_push(3) is definitely called with a second argument that is *not* at the beginning of its chain. Admittedly, that code is hard to fathom, but it does appear to result in a bogus prev_bio pointer without this patch. The practical impact of this bug in this and other software remains unknown; the consequences might possibly escalate up to use-after-free issues if BIO_pop(3) is afterwards called on corrupted BIO objects. OK tb@
* Improve the poorly designed BIO_set_next(3) API to always preserve allschwarze2022-12-061-3/+18
| | | | | | | | | | | | | | | | | invariants of the prev_bio and next_bio fields of all BIO objects in all involved chains, no matter which arguments this function is called with. Both real-world uses of this function (in libssl and freerdp) have been audited to make sure this makes nothing worse. We believe libssl behaves correctly before and after the patch (mostly because the second argument is NULL there), and we believe the code in freerdp behaves incorrectly before and after the patch, leaving a prev_bio pointer in place that is becoming bogus, only in a different object before and after the patch. But after the patch, that bogus pointer is due to a separate bug in BIO_push(3), which we are planning to fix afterwards. Joint work with and OK tb@.
* Revert bio_prev removaltb2022-12-021-1/+10
| | | | | | | | | As schwarze points out, you can pop any BIO in a chain, not just the first one (bonus points for a great name for this API). The internal doubly linked was used to fix up the BIO chain bio was part of when you BIO_pop() a bio that wasn't in the first position, which is explicitly allowed in our documentation and implied by OpenSSL's.
* Mostly align BIO_read()/BIO_write() return values with OpenSSL 3.x.jsing2022-11-301-7/+21
| | | | | | | | | | For various historical reasons, there are a number of cases where our BIO_read() and BIO_write() return slightly different values to what OpenSSL 3.x does (of course OpenSSL 1.0 differs from OpenSSL 1.1 which differs from OpenSSL 3.x). Mostly align these - some further work will be needed. Issue raised by tb@ who also wrote some test code.
* Retire prev_biotb2022-11-281-10/+1
| | | | | | | | | | | | | While BIO chains are doubly linked lists, nothing has ever made use of this fact internally. Even libssl has failed to maintain prev_bio properly in two places for a long time. When BIO was made opaque, the opportunity to fix that was missed. Instead, BIO_set_next() now allows breaking the lists from outside the library, which freerdp has long done. Problem found by schwarze while trying to document BIO_set_next(). schwarze likes the idea ok jsing
* Initialize readbytes in BIO_gets()tb2022-08-151-2/+2
| | | | | | | | If the bgets() callback returns <= 0, we currently rely on the user provided callback to set readbytes, which isn't ideal. This also matches what's done in BIO_read() and BIO_write(). ok jsing
* Implement new-style OpenSSL BIO callbackstb2022-01-141-85/+203
| | | | | | | | | | This provides support for new-style BIO callbacks in BIO_{read,write,gets,puts}() and a helper function to work out whether it should call the new or the old style callback. It also adds a few typedefs and minor code cleanup as well as the BIO_{get,set}_callback_ex() from jsing, ok tb
* Add a new, mostly empty, bio_local.h and include it in the filestb2022-01-071-1/+3
| | | | | | that will need it in the upcoming bump. discussed with jsing
* Prepare to provide BIO_set_retry_reason()tb2022-01-051-1/+7
| | | | | | Needed by freerdp. ok inoguchi jsing
* Prepare to provide BIO_set_next().tb2022-01-051-1/+7
| | | | | | This will be needed in libssl and freerdp after the next bump. ok inoguchi jsing
* Fix an issue that might possibly turn into a DOS depending onschwarze2021-12-091-3/+3
| | | | | | | | | | how application software uses the API function BIO_indent(3): If the caller asks for some output, but not more than some negative number of bytes, give them zero bytes of output rather than drowning them in nearly INT_MAX bytes. OK tb@
* Prepare to provide BIO_get_init()tb2021-10-241-1/+7
| | | | ok beck jsing
* Add input validation to BIO_read()/BIO_write().jsing2019-04-141-4/+14
| | | | | | | | | Some bread/bwrite functions implement this themselves, while others do not. This makes it consistent across all BIO implementations. Addresses an issue that Guido Vranken found with his fuzzer. ok tb@
* const for BIO_{new,set}() and most of the BIO_{f,s}_*() family oftb2018-05-011-3/+3
| | | | | | functions. ok beck, jsing
* Provide BIO_up_ref().jsing2018-02-221-1/+8
|
* Provide BIO_{g,s}et_shutdown().tb2018-02-201-1/+13
| | | | ok jsing
* Provide BIO_get_new_index().jsing2018-02-201-1/+15
| | | | Based on BoringSSL.
* Provide BIO_{g,s}et_data() and BIO_set_init().tb2018-02-181-1/+19
| | | | ok jsing
* Send the function codes from the error functions to the bit bucket,beck2017-01-291-12/+12
| | | | | | as was done earlier in libssl. Thanks inoguchi@ for noticing libssl had more reacharounds into this. ok jsing@ inoguchi@
* Remove more IMPLEMENT_STACK_OF noops that have been hiding for the lastjsing2015-02-101-3/+1
| | | | 15 years.
* BIO_free() returns immediately when the sole input is NULL.doug2014-07-251-3/+2
| | | | | | Remove unnecessary NULL check. ok miod@
* Fix a memory leak in BIO_free() which no current BIO can trigger; OpenSSLmiod2014-07-111-4/+3
| | | | PR #3439 via OpenSSL trunk
* Only import cryptlib.h in the four source files that actually need it.jsing2014-07-111-4/+5
| | | | | | | | Remove the openssl public includes from cryptlib.h and add a small number of includes into the source files that actually need them. While here, also sort/group/tidy the includes. ok beck@ miod@
* tags as requested by miod and teduderaadt2014-06-121-1/+1
|
* Bring malloc/calloc/realloc sequences to modern standardderaadt2014-04-211-1/+1
| | | | ok guenther
* kill REF_PRINT/REF_CHECK debugging framework noone would usederaadt2014-04-171-9/+0
| | | | ok miod
* some KNF cleanup following the scriptderaadt2014-04-171-18/+18
|
* Change library to use intrinsic memory allocation functions instead ofbeck2014-04-171-3/+3
| | | | | | | | OPENSSL_foo wrappers. This changes: OPENSSL_malloc->malloc OPENSSL_free->free OPENSSL_relloc->realloc OPENSSL_freeFunc->free
* More KNF.jsing2014-04-161-18/+20
|
* First pass at applying KNF to the OpenSSL code, which almost makes itjsing2014-04-151-358/+390
| | | | | readable. This pass is whitespace only and can readily be verified using tr and md5.
* resolve conflictsdjm2012-10-131-14/+14
|
* openssl-1.0.0e: resolve conflictsdjm2011-11-031-2/+2
|
* resolve conflicts, fix local changesdjm2010-10-011-2/+2
|
* resolve conflictsdjm2008-09-061-7/+53
|
* merge 0.9.7b with local changes; crank majors for libssl/libcryptomarkus2003-05-121-1/+14
|
* OpenSSL 0.9.7 stable 2002 05 08 mergebeck2002-05-151-9/+10
|
* openssl-engine-0.9.6 mergebeck2000-12-151-11/+19
|