]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
ssl/ech/ech_store.c: do not raise errors on allocation failures
authorEugene Syromiatnikov <esyr@openssl.org>
Mon, 23 Feb 2026 14:48:23 +0000 (15:48 +0100)
committerTomas Mraz <tomas@openssl.org>
Wed, 25 Feb 2026 11:19:43 +0000 (12:19 +0100)
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)

ssl/ech/ech_store.c

index 5c9021727113b521bfc44a243dd1ec30af6f9ff9..b327f000f3724588d235873821f8943a9d58c773 100644 (file)
@@ -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;