[openssl-commits] [openssl] master update

bernd.edlinger at hotmail.de bernd.edlinger at hotmail.de
Mon Nov 5 21:42:14 UTC 2018


The branch master has been updated
       via  fb9c3ff565aa11b08646e0f9f28fc082ed365cbd (commit)
       via  7ecd6c5186f3958b726edb3f5e5851f12ad56485 (commit)
       via  c5e0b3a6d5f02aa53cf2a7c0cffb42e434ee3470 (commit)
       via  17209be89b4d5aad94b91cfe0d9d24d5243a4a2f (commit)
      from  2087028612027368e9508e1b253aab715a5a35d6 (commit)


- Log -----------------------------------------------------------------
commit fb9c3ff565aa11b08646e0f9f28fc082ed365cbd
Author: Bernd Edlinger <bernd.edlinger at hotmail.de>
Date:   Fri Nov 2 11:46:38 2018 +0100

    Fix error handling in RAND_DRBG_uninstantiate
    
    Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre at ncp-e.com>
    Reviewed-by: Paul Dale <paul.dale at oracle.com>
    (Merged from https://github.com/openssl/openssl/pull/7517)

commit 7ecd6c5186f3958b726edb3f5e5851f12ad56485
Author: Bernd Edlinger <bernd.edlinger at hotmail.de>
Date:   Tue Oct 30 21:02:22 2018 +0100

    Fix error handling in drbgtest.c
    
    Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre at ncp-e.com>
    Reviewed-by: Paul Dale <paul.dale at oracle.com>
    (Merged from https://github.com/openssl/openssl/pull/7517)

commit c5e0b3a6d5f02aa53cf2a7c0cffb42e434ee3470
Author: Bernd Edlinger <bernd.edlinger at hotmail.de>
Date:   Tue Oct 30 20:57:53 2018 +0100

    Fix error handling in rand_drbg_new
    
    Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre at ncp-e.com>
    Reviewed-by: Paul Dale <paul.dale at oracle.com>
    (Merged from https://github.com/openssl/openssl/pull/7517)

commit 17209be89b4d5aad94b91cfe0d9d24d5243a4a2f
Author: Bernd Edlinger <bernd.edlinger at hotmail.de>
Date:   Mon Oct 29 13:48:53 2018 +0100

    Fix error handling in RAND_DRBG_set
    
    Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre at ncp-e.com>
    Reviewed-by: Paul Dale <paul.dale at oracle.com>
    (Merged from https://github.com/openssl/openssl/pull/7517)

-----------------------------------------------------------------------

Summary of changes:
 crypto/rand/drbg_lib.c | 13 ++++++++-----
 test/drbgtest.c        | 33 +++++++++++++++++++--------------
 2 files changed, 27 insertions(+), 19 deletions(-)

diff --git a/crypto/rand/drbg_lib.c b/crypto/rand/drbg_lib.c
index 8e372e5..2cfa4f5 100644
--- a/crypto/rand/drbg_lib.c
+++ b/crypto/rand/drbg_lib.c
@@ -180,12 +180,17 @@ int RAND_DRBG_set(RAND_DRBG *drbg, int type, unsigned int flags)
         else
             ret = drbg_hash_init(drbg);
     } else {
+        drbg->type = 0;
+        drbg->flags = 0;
+        drbg->meth = NULL;
         RANDerr(RAND_F_RAND_DRBG_SET, RAND_R_UNSUPPORTED_DRBG_TYPE);
         return 0;
     }
 
-    if (ret == 0)
+    if (ret == 0) {
+        drbg->state = DRBG_ERROR;
         RANDerr(RAND_F_RAND_DRBG_SET, RAND_R_ERROR_INITIALISING_DRBG);
+    }
     return ret;
 }
 
@@ -290,10 +295,7 @@ static RAND_DRBG *rand_drbg_new(int secure,
     return drbg;
 
  err:
-    if (drbg->secure)
-        OPENSSL_secure_free(drbg);
-    else
-        OPENSSL_free(drbg);
+    RAND_DRBG_free(drbg);
 
     return NULL;
 }
@@ -435,6 +437,7 @@ int RAND_DRBG_uninstantiate(RAND_DRBG *drbg)
 {
     int index = -1, type, flags;
     if (drbg->meth == NULL) {
+        drbg->state = DRBG_ERROR;
         RANDerr(RAND_F_RAND_DRBG_UNINSTANTIATE,
                 RAND_R_NO_DRBG_IMPLEMENTATION_SELECTED);
         return 0;
diff --git a/test/drbgtest.c b/test/drbgtest.c
index 882fef8..a3beebc 100644
--- a/test/drbgtest.c
+++ b/test/drbgtest.c
@@ -799,12 +799,15 @@ static void run_multi_thread_test(void)
 {
     unsigned char buf[256];
     time_t start = time(NULL);
-    RAND_DRBG *public, *private;
+    RAND_DRBG *public = NULL, *private = NULL;
 
-    public = RAND_DRBG_get0_public();
-    private = RAND_DRBG_get0_private();
-    RAND_DRBG_set_reseed_time_interval(public, 1);
+    if (!TEST_ptr(public = RAND_DRBG_get0_public())
+            || !TEST_ptr(private = RAND_DRBG_get0_private())) {
+        multi_thread_rand_bytes_succeeded = 0;
+        return;
+    }
     RAND_DRBG_set_reseed_time_interval(private, 1);
+    RAND_DRBG_set_reseed_time_interval(public, 1);
 
     do {
         if (RAND_bytes(buf, sizeof(buf)) <= 0)
@@ -936,13 +939,16 @@ static size_t rand_drbg_seedlen(RAND_DRBG *drbg)
  */
 static int test_rand_seed(void)
 {
-    RAND_DRBG *master = RAND_DRBG_get0_master();
+    RAND_DRBG *master = NULL;
     unsigned char rand_buf[256];
     size_t rand_buflen;
-#ifdef OPENSSL_RAND_SEED_NONE
-    size_t required_seed_buflen = rand_drbg_seedlen(master);
-#else
     size_t required_seed_buflen = 0;
+
+    if (!TEST_ptr(master = RAND_DRBG_get0_master()))
+        return 0;
+
+#ifdef OPENSSL_RAND_SEED_NONE
+    required_seed_buflen = rand_drbg_seedlen(master);
 #endif
 
     memset(rand_buf, 0xCD, sizeof(rand_buf));
@@ -1025,14 +1031,13 @@ err:
 
 static int test_set_defaults(void)
 {
-    RAND_DRBG *master, *public, *private;
-
-    master = RAND_DRBG_get0_master();
-    public = RAND_DRBG_get0_public();
-    private = RAND_DRBG_get0_private();
+    RAND_DRBG *master = NULL, *public = NULL, *private = NULL;
 
            /* Check the default type and flags for master, public and private */
-    return TEST_int_eq(master->type, RAND_DRBG_TYPE)
+    return TEST_ptr(master = RAND_DRBG_get0_master())
+           && TEST_ptr(public = RAND_DRBG_get0_public())
+           && TEST_ptr(private = RAND_DRBG_get0_private())
+           && TEST_int_eq(master->type, RAND_DRBG_TYPE)
            && TEST_int_eq(master->flags,
                           RAND_DRBG_FLAGS | RAND_DRBG_FLAG_MASTER)
            && TEST_int_eq(public->type, RAND_DRBG_TYPE)


More information about the openssl-commits mailing list