Commit 26e8ece04f for openssl.org
commit 26e8ece04f23a8e6ebd3aaa736bf383713fd25c1
Author: Eugene Syromiatnikov <esyr@openssl.org>
Date: Mon Feb 23 15:48:23 2026 +0100
ssl/ech/ech_store.c: do not raise errors on allocation failures
The default CRYPTO_malloc() implementation (with OPENSSL_malloc()
and OPENSSL_zalloc() being wrappers for it) raises an error
on allocation, and both OPENSSL_strdup() and OPENSSL_memdup() use
CRYPTO_malloc() internally for memory allocation, so there is no need
to explicitly raise an error on an allocation failure; remove these.
Signed-off-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
MergeDate: Wed Feb 25 11:20:14 2026
(Merged from https://github.com/openssl/openssl/pull/30146)
diff --git a/ssl/ech/ech_store.c b/ssl/ech/ech_store.c
index 5c90217271..b327f000f3 100644
--- a/ssl/ech/ech_store.c
+++ b/ssl/ech/ech_store.c
@@ -579,10 +579,8 @@ static int ech_read_priv_echconfiglist(OSSL_ECHSTORE *es, BIO *in,
btmp = BIO_push(btmp1, btmp);
/* overestimate but good enough */
binbuf = OPENSSL_malloc(encodedlen);
- if (binbuf == NULL) {
- ERR_raise(ERR_LIB_SSL, ERR_R_INTERNAL_ERROR);
+ if (binbuf == NULL)
goto err;
- }
tdeclen = BIO_read(btmp, binbuf, (int)encodedlen);
if (tdeclen <= 0) { /* need int for -1 return in failure case */
ERR_raise(ERR_LIB_SSL, ERR_R_INTERNAL_ERROR);
@@ -613,16 +611,13 @@ OSSL_ECHSTORE *OSSL_ECHSTORE_new(OSSL_LIB_CTX *libctx, const char *propq)
OSSL_ECHSTORE *es = NULL;
es = OPENSSL_zalloc(sizeof(*es));
- if (es == NULL) {
- ERR_raise(ERR_LIB_SSL, ERR_R_INTERNAL_ERROR);
+ if (es == NULL)
return 0;
- }
es->libctx = libctx;
if (propq != NULL) {
es->propq = OPENSSL_strdup(propq);
if (es->propq == NULL) {
OPENSSL_free(es);
- ERR_raise(ERR_LIB_SSL, ERR_R_INTERNAL_ERROR);
return 0;
}
}
@@ -754,29 +749,21 @@ int OSSL_ECHSTORE_new_config(OSSL_ECHSTORE *es,
ERR_raise(ERR_LIB_SSL, ERR_R_INTERNAL_ERROR);
goto err;
}
- if ((ee = OPENSSL_zalloc(sizeof(*ee))) == NULL) {
- ERR_raise(ERR_LIB_SSL, ERR_R_INTERNAL_ERROR);
+ if ((ee = OPENSSL_zalloc(sizeof(*ee))) == NULL)
goto err;
- }
ee->suites = OPENSSL_malloc(sizeof(*ee->suites));
- if (ee->suites == NULL) {
- ERR_raise(ERR_LIB_SSL, ERR_R_INTERNAL_ERROR);
+ if (ee->suites == NULL)
goto err;
- }
ee->version = echversion;
ee->pub_len = publen;
ee->pub = OPENSSL_memdup(pub, publen);
- if (ee->pub == NULL) {
- ERR_raise(ERR_LIB_SSL, ERR_R_INTERNAL_ERROR);
+ if (ee->pub == NULL)
goto err;
- }
ee->nsuites = 1;
ee->suites[0] = suite;
ee->public_name = OPENSSL_strdup(public_name);
- if (ee->public_name == NULL) {
- ERR_raise(ERR_LIB_SSL, ERR_R_INTERNAL_ERROR);
+ if (ee->public_name == NULL)
goto err;
- }
ee->max_name_length = max_name_length;
ee->config_id = config_id;
ee->keyshare = privp;