You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by yl...@apache.org on 2021/09/12 11:54:40 UTC

svn commit: r1893270 - /apr/apr/trunk/crypto/apr_crypto_openssl.c

Author: ylavic
Date: Sun Sep 12 11:54:40 2021
New Revision: 1893270

URL: http://svn.apache.org/viewvc?rev=1893270&view=rev
Log:
apr_crypto: cprng_stream_ctx_make() to return NULL *ctx on failure.

apr_crypto_prng_create() relies on cprng_stream_ctx_make() to not set a
freed/dangling cprng->ctx on failure when given NULL.


Modified:
    apr/apr/trunk/crypto/apr_crypto_openssl.c

Modified: apr/apr/trunk/crypto/apr_crypto_openssl.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/crypto/apr_crypto_openssl.c?rev=1893270&r1=1893269&r2=1893270&view=diff
==============================================================================
--- apr/apr/trunk/crypto/apr_crypto_openssl.c (original)
+++ apr/apr/trunk/crypto/apr_crypto_openssl.c Sun Sep 12 11:54:40 2021
@@ -1555,11 +1555,13 @@ static apr_status_t cprng_stream_ctx_mak
     EVP_CIPHER_CTX *ctx;
     const EVP_CIPHER *ecipher;
 
+    *psctx = NULL;
+
     if (pool) {
-        *psctx = sctx = apr_palloc(pool, sizeof(cprng_stream_ctx_t));
+        sctx = apr_palloc(pool, sizeof(cprng_stream_ctx_t));
     }
     else {
-        *psctx = sctx = malloc(sizeof(cprng_stream_ctx_t));
+        sctx = malloc(sizeof(cprng_stream_ctx_t));
     }
     if (!sctx) {
         return APR_ENOMEM;
@@ -1619,6 +1621,7 @@ static apr_status_t cprng_stream_ctx_mak
         return APR_ENOMEM;
     }
 
+    *psctx = sctx;
     return APR_SUCCESS;
 }