Stop raising ERR_R_MALLOC_FAILURE in most places#19301
Stop raising ERR_R_MALLOC_FAILURE in most places#19301levitte wants to merge 10 commits intoopenssl:masterfrom
Conversation
In other words, make it raise ERR_R_MALLOC_FAILURE appropriately.
Since OPENSSL_malloc() and friends report ERR_R_MALLOC_FAILURE, and
at least handle the file name and line number they are called from,
there's no need to report ERR_R_MALLOC_FAILURE where they are called
directly, or when SSLfatal() and RLAYERfatal() is used, the reason
`ERR_R_MALLOC_FAILURE` is changed to `ERR_R_CRYPTO_LIB`.
There were a number of places where `ERR_R_MALLOC_FAILURE` was reported
even though it was a function from a different sub-system that was
called. Those places are changed to report ERR_R_{lib}_LIB, where
{lib} is the name of that sub-system.
Some of them are tricky to get right, as we have a lot of functions
that belong in the ASN1 sub-system, and all the `sk_` calls or from
the CRYPTO sub-system.
Some extra adaptation was necessary where there were custom OPENSSL_malloc()
wrappers, and some bugs are fixed alongside these changes.
|
This is in draft for a bit, I need to re-read what I've done after a pause. |
That could actually be made into a completely separate fix commit. It's quite independent from all the rest |
Engines lacked the possibility to refer to themselves in this form:
WHATEVERerr(WHATEVER_F_SOMETHING, WHATEVER_R_WHATEVER_LIB);
This little change makes that possible, and gets used in e_capi.
t8m
left a comment
There was a problem hiding this comment.
I've found just two mistakes in this gargantuan PR. How did you do it, even with some scripting, I cannot imagine. Great work!
Grep, and eyeballing |
|
I'm re-reading my changes, and clearly got blurry-eyed in some sections. Corrections coming up! |
|
@levitte it looks impossible to review all the affected files. |
... I think that'll be something for tomorrow, although I'm hoping that someone has the stamina 😉 |
|
Should the draft status be removed? IMO this is good to go. |
|
Second review, @openssl/committers ? |
|
This pull request is ready to merge |
In other words, make it raise ERR_R_MALLOC_FAILURE appropriately. Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Hugo Landau <hlandau@openssl.org> (Merged from #19301)
Since OPENSSL_malloc() and friends report ERR_R_MALLOC_FAILURE, and
at least handle the file name and line number they are called from,
there's no need to report ERR_R_MALLOC_FAILURE where they are called
directly, or when SSLfatal() and RLAYERfatal() is used, the reason
`ERR_R_MALLOC_FAILURE` is changed to `ERR_R_CRYPTO_LIB`.
There were a number of places where `ERR_R_MALLOC_FAILURE` was reported
even though it was a function from a different sub-system that was
called. Those places are changed to report ERR_R_{lib}_LIB, where
{lib} is the name of that sub-system.
Some of them are tricky to get right, as we have a lot of functions
that belong in the ASN1 sub-system, and all the `sk_` calls or from
the CRYPTO sub-system.
Some extra adaptation was necessary where there were custom OPENSSL_malloc()
wrappers, and some bugs are fixed alongside these changes.
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from #19301)
Engines lacked the possibility to refer to themselves in this form:
WHATEVERerr(WHATEVER_F_SOMETHING, WHATEVER_R_WHATEVER_LIB);
This little change makes that possible, and gets used in e_capi.
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from #19301)
In other words, make it raise ERR_R_MALLOC_FAILURE appropriately. Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Hugo Landau <hlandau@openssl.org> (Merged from openssl#19301)
Since OPENSSL_malloc() and friends report ERR_R_MALLOC_FAILURE, and
at least handle the file name and line number they are called from,
there's no need to report ERR_R_MALLOC_FAILURE where they are called
directly, or when SSLfatal() and RLAYERfatal() is used, the reason
`ERR_R_MALLOC_FAILURE` is changed to `ERR_R_CRYPTO_LIB`.
There were a number of places where `ERR_R_MALLOC_FAILURE` was reported
even though it was a function from a different sub-system that was
called. Those places are changed to report ERR_R_{lib}_LIB, where
{lib} is the name of that sub-system.
Some of them are tricky to get right, as we have a lot of functions
that belong in the ASN1 sub-system, and all the `sk_` calls or from
the CRYPTO sub-system.
Some extra adaptation was necessary where there were custom OPENSSL_malloc()
wrappers, and some bugs are fixed alongside these changes.
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from openssl#19301)
Engines lacked the possibility to refer to themselves in this form:
WHATEVERerr(WHATEVER_F_SOMETHING, WHATEVER_R_WHATEVER_LIB);
This little change makes that possible, and gets used in e_capi.
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from openssl#19301)
|
@levitte I am curious about the differences in error handling between EVP_KDF_CTX_new() and EVP_MAC_CTX_new(). When OPENSSL_zalloc() fails, EVP_KDF_CTX_new() will raises ERR_R_EVP_LIB, whereas EVP_MAC_CTX_new() does not. Instead, EVP_MAC_CTX_new() only raises ERR_R_EVP_LIB when newctx() fails. This makes EVP_MAC_CTX_new() seem more reasonable in its error handling. Are there any other concerns I haven't noticed? Please enlighten me on this. Thanks. |
Since
OPENSSL_malloc()and friends reportERR_R_MALLOC_FAILURE, and at least handle the file name and line number they are called from, there's no need to reportERR_R_MALLOC_FAILUREwhere they are called directly, or whenSSLfatal()andRLAYERfatal()is used, the reasonERR_R_MALLOC_FAILUREis changed toERR_R_CRYPTO_LIB.There were a number of places where
ERR_R_MALLOC_FAILUREwas reported even though it was a function from a different sub-system that was called. Those places are changed to reportERR_R_{lib}_LIB, where{lib}is the name of that sub-system.Some of them are tricky to get right, as we have a lot of functions that belong in the ASN1 sub-system, and all the
sk_calls or from the CRYPTO sub-system.Some extra adaptation was necessary where there were custom
OPENSSL_malloc()wrappers, and some bugs are fixed alongside these changes.Most notably,
CRYPTO_secure_malloc()has been changed to also raiseERR_R_MALLOC_FAILUREwhen appropriate.This is an alternative to #19072