summaryrefslogtreecommitdiff
path: root/crypto/comp
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2022-09-29 13:57:34 +0200
committerRichard Levitte <levitte@openssl.org>2022-10-05 14:02:03 +0200
commite077455e9e57ed4ee4676996b4a9aa11df6327a6 (patch)
treeedcb7412024f95fbc97c2c7a780f78ad05d586e3 /crypto/comp
parent9167a47f78159b0578bc032401ab1d66e14eecdb (diff)
downloadopenssl-new-e077455e9e57ed4ee4676996b4a9aa11df6327a6.tar.gz
Stop raising ERR_R_MALLOC_FAILURE in most places
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 https://github.com/openssl/openssl/pull/19301)
Diffstat (limited to 'crypto/comp')
-rw-r--r--crypto/comp/c_zlib.c12
-rw-r--r--crypto/comp/comp_lib.c4
2 files changed, 4 insertions, 12 deletions
diff --git a/crypto/comp/c_zlib.c b/crypto/comp/c_zlib.c
index 9a7087e444..4ab876b59f 100644
--- a/crypto/comp/c_zlib.c
+++ b/crypto/comp/c_zlib.c
@@ -321,10 +321,8 @@ static int bio_zlib_new(BIO *bi)
}
# endif
ctx = OPENSSL_zalloc(sizeof(*ctx));
- if (ctx == NULL) {
- ERR_raise(ERR_LIB_COMP, ERR_R_MALLOC_FAILURE);
+ if (ctx == NULL)
return 0;
- }
ctx->ibufsize = ZLIB_DEFAULT_BUFSIZE;
ctx->obufsize = ZLIB_DEFAULT_BUFSIZE;
ctx->zin.zalloc = Z_NULL;
@@ -376,10 +374,8 @@ static int bio_zlib_read(BIO *b, char *out, int outl)
BIO_clear_retry_flags(b);
if (!ctx->ibuf) {
ctx->ibuf = OPENSSL_malloc(ctx->ibufsize);
- if (ctx->ibuf == NULL) {
- ERR_raise(ERR_LIB_COMP, ERR_R_MALLOC_FAILURE);
+ if (ctx->ibuf == NULL)
return 0;
- }
if ((ret = inflateInit(zin)) != Z_OK) {
ERR_raise_data(ERR_LIB_COMP, COMP_R_ZLIB_INFLATE_ERROR,
"zlib error: %s", zError(ret));
@@ -441,10 +437,8 @@ static int bio_zlib_write(BIO *b, const char *in, int inl)
if (!ctx->obuf) {
ctx->obuf = OPENSSL_malloc(ctx->obufsize);
/* Need error here */
- if (ctx->obuf == NULL) {
- ERR_raise(ERR_LIB_COMP, ERR_R_MALLOC_FAILURE);
+ if (ctx->obuf == NULL)
return 0;
- }
ctx->optr = ctx->obuf;
ctx->ocount = 0;
if ((ret = deflateInit(zout, ctx->comp_level)) != Z_OK) {
diff --git a/crypto/comp/comp_lib.c b/crypto/comp/comp_lib.c
index bf9069d871..c5946fecdb 100644
--- a/crypto/comp/comp_lib.c
+++ b/crypto/comp/comp_lib.c
@@ -19,10 +19,8 @@ COMP_CTX *COMP_CTX_new(COMP_METHOD *meth)
{
COMP_CTX *ret;
- if ((ret = OPENSSL_zalloc(sizeof(*ret))) == NULL) {
- ERR_raise(ERR_LIB_COMP, ERR_R_MALLOC_FAILURE);
+ if ((ret = OPENSSL_zalloc(sizeof(*ret))) == NULL)
return NULL;
- }
ret->meth = meth;
if ((ret->meth->init != NULL) && !ret->meth->init(ret)) {
OPENSSL_free(ret);