summaryrefslogtreecommitdiff
path: root/lib/libcrypto/bio/bio_lib.c
AgeCommit message (Collapse)Author
2024-07-09Hide symbols for two missed public functions in bio.hBob Beck
ok tb@
2024-03-27Unify *_up_ref() implementationsTheo Buehler
No need for an inconsistently named local variable and a ternary operator. ok jsing
2024-03-02Remove BIO_set()Theo Buehler
This used to be a dangerous implementation detail of BIO_new() that was never used outside of libcrypto. ok jsing
2024-02-17Use calloc() instead of malloc() in BIO_new().Joel Sing
ok tb@
2024-02-16Inline and disable BIO_set().Joel Sing
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@
2024-02-16Use 'bio' more consistently for function arguments.Joel Sing
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.
2023-08-07Fix two leaks in BIO_dup_chain()Theo Buehler
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
2023-07-10BIO_indent: use %*s rather than puts in a loopTheo Buehler
ok beck jsing millert
2023-07-07Unbreak the namespace build after a broken mk.conf and tool misfire hadBob Beck
me aliasing symbols not in the headers I was procesing. This unbreaks the namespace build so it will pass again ok tb@
2023-07-05Hide symbols in asn1 and bioBob Beck
ok jsing@
2023-03-15Streaming BIOs assume they can write to NULL BIOsTheo Buehler
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
2022-12-16Revert BIO_push(3) cycle prevention (bio_lib.c rev. 1.42).Ingo Schwarze
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.
2022-12-07Improve the implementation of BIO_push(3) such that it changes nothingIngo Schwarze
and reports failure if a call would result in a cycle. The algorithm used was originally suggested by jsing@. Feedback and OK tb@.
2022-12-06Make sure BIO_push(3) always preserves all invariants of the prev_bioIngo Schwarze
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@
2022-12-06Improve the poorly designed BIO_set_next(3) API to always preserve allIngo Schwarze
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@.
2022-12-02Revert bio_prev removalTheo Buehler
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.
2022-11-30Mostly align BIO_read()/BIO_write() return values with OpenSSL 3.x.Joel Sing
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.
2022-11-28Retire prev_bioTheo Buehler
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
2022-08-15Initialize readbytes in BIO_gets()Theo Buehler
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
2022-01-14Implement new-style OpenSSL BIO callbacksTheo Buehler
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
2022-01-07Add a new, mostly empty, bio_local.h and include it in the filesTheo Buehler
that will need it in the upcoming bump. discussed with jsing
2022-01-05Prepare to provide BIO_set_retry_reason()Theo Buehler
Needed by freerdp. ok inoguchi jsing
2022-01-05Prepare to provide BIO_set_next().Theo Buehler
This will be needed in libssl and freerdp after the next bump. ok inoguchi jsing
2021-12-09Fix an issue that might possibly turn into a DOS depending onIngo Schwarze
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@
2021-10-24Prepare to provide BIO_get_init()Theo Buehler
ok beck jsing
2019-04-14Add input validation to BIO_read()/BIO_write().Joel Sing
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@
2018-05-01const for BIO_{new,set}() and most of the BIO_{f,s}_*() family ofTheo Buehler
functions. ok beck, jsing
2018-02-22Provide BIO_up_ref().Joel Sing
2018-02-20Provide BIO_{g,s}et_shutdown().Theo Buehler
ok jsing
2018-02-20Provide BIO_get_new_index().Joel Sing
Based on BoringSSL.
2018-02-18Provide BIO_{g,s}et_data() and BIO_set_init().Theo Buehler
ok jsing
2017-01-29Send the function codes from the error functions to the bit bucket,Bob Beck
as was done earlier in libssl. Thanks inoguchi@ for noticing libssl had more reacharounds into this. ok jsing@ inoguchi@
2015-02-10Remove more IMPLEMENT_STACK_OF noops that have been hiding for the lastJoel Sing
15 years.
2014-07-25BIO_free() returns immediately when the sole input is NULL.Doug Hogan
Remove unnecessary NULL check. ok miod@
2014-07-11Fix a memory leak in BIO_free() which no current BIO can trigger; OpenSSLMiod Vallat
PR #3439 via OpenSSL trunk
2014-07-11Only import cryptlib.h in the four source files that actually need it.Joel Sing
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@
2014-06-12tags as requested by miod and teduTheo de Raadt
2014-04-21Bring malloc/calloc/realloc sequences to modern standardTheo de Raadt
ok guenther
2014-04-17kill REF_PRINT/REF_CHECK debugging framework noone would useTheo de Raadt
ok miod
2014-04-17some KNF cleanup following the scriptTheo de Raadt
2014-04-17Change library to use intrinsic memory allocation functions instead ofBob Beck
OPENSSL_foo wrappers. This changes: OPENSSL_malloc->malloc OPENSSL_free->free OPENSSL_relloc->realloc OPENSSL_freeFunc->free
2014-04-16More KNF.Joel Sing
2014-04-15First pass at applying KNF to the OpenSSL code, which almost makes itJoel Sing
readable. This pass is whitespace only and can readily be verified using tr and md5.
2012-10-13resolve conflictsDamien Miller
2011-11-03openssl-1.0.0e: resolve conflictsDamien Miller
2010-10-01resolve conflicts, fix local changesDamien Miller
2008-09-06resolve conflictsDamien Miller
2003-05-12merge 0.9.7b with local changes; crank majors for libssl/libcryptoMarkus Friedl
2002-05-15OpenSSL 0.9.7 stable 2002 05 08 mergeBob Beck
2000-12-15openssl-engine-0.9.6 mergeBob Beck