[openssl-commits] [openssl] master update

Rich Salz rsalz at openssl.org
Mon Jul 17 12:41:31 UTC 2017


The branch master has been updated
       via  54e5ba058b4f2c6042c14d44868077e9ffcff818 (commit)
      from  f1b8b0010a5cdd76d1284ea47e9b5995dcd6f089 (commit)


- Log -----------------------------------------------------------------
commit 54e5ba058b4f2c6042c14d44868077e9ffcff818
Author: Rich Salz <rsalz at openssl.org>
Date:   Mon Jul 17 02:52:26 2017 -0400

    Fix use-after-free
    
    Also fix a RANDerr call.
    
    Reviewed-by: Andy Polyakov <appro at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/3947)

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

Summary of changes:
 apps/app_rand.c        | 9 ++++++---
 crypto/rand/randfile.c | 2 +-
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/apps/app_rand.c b/apps/app_rand.c
index 3a05352..28caad4 100644
--- a/apps/app_rand.c
+++ b/apps/app_rand.c
@@ -13,7 +13,7 @@
 #include <openssl/rand.h>
 #include <openssl/conf.h>
 
-static const char *save_rand_file;
+static char *save_rand_file;
 
 void app_RAND_load_conf(CONF *c, const char *section)
 {
@@ -29,7 +29,7 @@ void app_RAND_load_conf(CONF *c, const char *section)
         return;
     }
     if (save_rand_file == NULL)
-        save_rand_file = randfile;
+        save_rand_file = OPENSSL_strdup(randfile);
 }
 
 static int loadfiles(char *name)
@@ -66,6 +66,8 @@ void app_RAND_write(void)
         BIO_printf(bio_err, "Cannot write random bytes:\n");
         ERR_print_errors(bio_err);
     }
+    OPENSSL_free(save_rand_file);
+    save_rand_file =  NULL;
 }
 
 
@@ -84,7 +86,8 @@ int opt_rand(int opt)
         return loadfiles(opt_arg());
         break;
     case OPT_R_WRITERAND:
-        save_rand_file = opt_arg();
+        OPENSSL_free(save_rand_file);
+        save_rand_file = OPENSSL_strdup(opt_arg());
         break;
     }
     return 1;
diff --git a/crypto/rand/randfile.c b/crypto/rand/randfile.c
index 904653f..f502642 100644
--- a/crypto/rand/randfile.c
+++ b/crypto/rand/randfile.c
@@ -176,7 +176,7 @@ int RAND_write_file(const char *file)
     if (out == NULL)
         out = openssl_fopen(file, "wb");
     if (out == NULL) {
-        RANDerr(RAND_F_RAND_LOAD_FILE, RAND_R_CANNOT_OPEN_FILE);
+        RANDerr(RAND_F_RAND_WRITE_FILE, RAND_R_CANNOT_OPEN_FILE);
         ERR_add_error_data(2, "Filename=", file);
         return -1;
     }


More information about the openssl-commits mailing list