aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/rand
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2020-11-04 16:14:00 +0100
committerRichard Levitte <levitte@openssl.org>2020-11-13 09:35:31 +0100
commita150f8e1fcc38752fef4d7c75d765d8efc7d46d6 (patch)
treef7f62c9a5d8407d8b17820fbef67378aa7b9ddbb /crypto/rand
parent9311d0c471ca2eaa259e8c1bbbeb7c46394c7ba2 (diff)
downloadopenssl-a150f8e1fcc38752fef4d7c75d765d8efc7d46d6.tar.gz
CRYPTO: refactor ERR_raise()+ERR_add_error_data() to ERR_raise_data()
This is not done absolutely everywhere, as there are places where the use of ERR_add_error_data() is quite complex, but at least the simple cases are done. Reviewed-by: Paul Dale <paul.dale@oracle.com> (Merged from https://github.com/openssl/openssl/pull/13318)
Diffstat (limited to 'crypto/rand')
-rw-r--r--crypto/rand/rand_lib.c5
-rw-r--r--crypto/rand/randfile.c19
2 files changed, 12 insertions, 12 deletions
diff --git a/crypto/rand/rand_lib.c b/crypto/rand/rand_lib.c
index fdce6711ed..211f4f3f51 100644
--- a/crypto/rand/rand_lib.c
+++ b/crypto/rand/rand_lib.c
@@ -645,8 +645,9 @@ static int random_conf_init(CONF_IMODULE *md, const CONF *cnf)
if (!random_set_string(&dgbl->rng_propq, cval->value))
return 0;
} else {
- ERR_raise(ERR_LIB_CRYPTO, CRYPTO_R_UNKNOWN_NAME_IN_RANDOM_SECTION);
- ERR_add_error_data(4, "name=", cval->name, ", value=", cval->value);
+ ERR_raise_data(ERR_LIB_CRYPTO,
+ CRYPTO_R_UNKNOWN_NAME_IN_RANDOM_SECTION,
+ "name=%s, value=%s", cval->name, cval->value);
r = 0;
}
}
diff --git a/crypto/rand/randfile.c b/crypto/rand/randfile.c
index b104895e3a..655dc71b06 100644
--- a/crypto/rand/randfile.c
+++ b/crypto/rand/randfile.c
@@ -94,15 +94,15 @@ int RAND_load_file(const char *file, long bytes)
return 0;
if ((in = openssl_fopen(file, "rb")) == NULL) {
- ERR_raise(ERR_LIB_RAND, RAND_R_CANNOT_OPEN_FILE);
- ERR_add_error_data(2, "Filename=", file);
+ ERR_raise_data(ERR_LIB_RAND, RAND_R_CANNOT_OPEN_FILE,
+ "Filename=%s", file);
return -1;
}
#ifndef OPENSSL_NO_POSIX_IO
if (fstat(fileno(in), &sb) < 0) {
- ERR_raise(ERR_LIB_RAND, RAND_R_INTERNAL_ERROR);
- ERR_add_error_data(2, "Filename=", file);
+ ERR_raise_data(ERR_LIB_RAND, RAND_R_INTERNAL_ERROR,
+ "Filename=%s", file);
fclose(in);
return -1;
}
@@ -162,8 +162,7 @@ int RAND_load_file(const char *file, long bytes)
OPENSSL_cleanse(buf, sizeof(buf));
fclose(in);
if (!RAND_status()) {
- ERR_raise(ERR_LIB_RAND, RAND_R_RESEED_ERROR);
- ERR_add_error_data(2, "Filename=", file);
+ ERR_raise_data(ERR_LIB_RAND, RAND_R_RESEED_ERROR, "Filename=%s", file);
return -1;
}
@@ -179,8 +178,8 @@ int RAND_write_file(const char *file)
struct stat sb;
if (stat(file, &sb) >= 0 && !S_ISREG(sb.st_mode)) {
- ERR_raise(ERR_LIB_RAND, RAND_R_NOT_A_REGULAR_FILE);
- ERR_add_error_data(2, "Filename=", file);
+ ERR_raise_data(ERR_LIB_RAND, RAND_R_NOT_A_REGULAR_FILE,
+ "Filename=%s", file);
return -1;
}
#endif
@@ -229,8 +228,8 @@ int RAND_write_file(const char *file)
if (out == NULL)
out = openssl_fopen(file, "wb");
if (out == NULL) {
- ERR_raise(ERR_LIB_RAND, RAND_R_CANNOT_OPEN_FILE);
- ERR_add_error_data(2, "Filename=", file);
+ ERR_raise_data(ERR_LIB_RAND, RAND_R_CANNOT_OPEN_FILE,
+ "Filename=%s", file);
return -1;
}