Also fix a RANDerr call.
Reviewed-by: Andy Polyakov <appro@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/3947)
#include <openssl/rand.h>
#include <openssl/conf.h>
#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)
{
void app_RAND_load_conf(CONF *c, const char *section)
{
return;
}
if (save_rand_file == NULL)
return;
}
if (save_rand_file == NULL)
- save_rand_file = randfile;
+ save_rand_file = OPENSSL_strdup(randfile);
}
static int loadfiles(char *name)
}
static int loadfiles(char *name)
BIO_printf(bio_err, "Cannot write random bytes:\n");
ERR_print_errors(bio_err);
}
BIO_printf(bio_err, "Cannot write random bytes:\n");
ERR_print_errors(bio_err);
}
+ OPENSSL_free(save_rand_file);
+ save_rand_file = NULL;
return loadfiles(opt_arg());
break;
case OPT_R_WRITERAND:
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());
if (out == NULL)
out = openssl_fopen(file, "wb");
if (out == NULL) {
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;
}
ERR_add_error_data(2, "Filename=", file);
return -1;
}