diff options
author | Richard Levitte <levitte@openssl.org> | 2020-11-04 16:14:00 +0100 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2020-11-13 09:35:31 +0100 |
commit | a150f8e1fcc38752fef4d7c75d765d8efc7d46d6 (patch) | |
tree | f7f62c9a5d8407d8b17820fbef67378aa7b9ddbb /crypto/conf | |
parent | Convert all {NAME}err() in crypto/ to their corresponding ERR_raise() call (diff) | |
download | openssl-a150f8e1fcc38752fef4d7c75d765d8efc7d46d6.tar.xz openssl-a150f8e1fcc38752fef4d7c75d765d8efc7d46d6.zip |
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/conf')
-rw-r--r-- | crypto/conf/conf_def.c | 9 | ||||
-rw-r--r-- | crypto/conf/conf_lib.c | 4 | ||||
-rw-r--r-- | crypto/conf/conf_mod.c | 24 | ||||
-rw-r--r-- | crypto/conf/conf_ssl.c | 25 |
4 files changed, 29 insertions, 33 deletions
diff --git a/crypto/conf/conf_def.c b/crypto/conf/conf_def.c index 5923f88212..2637e17fd8 100644 --- a/crypto/conf/conf_def.c +++ b/crypto/conf/conf_def.c @@ -462,8 +462,8 @@ static int def_load_bio(CONF *conf, BIO *in, long *line) } continue; } else if (*p != '=') { - ERR_raise(ERR_LIB_CONF, CONF_R_MISSING_EQUAL_SIGN); - ERR_add_error_data(2, "HERE-->", p); + ERR_raise_data(ERR_LIB_CONF, CONF_R_MISSING_EQUAL_SIGN, + "HERE-->%s", p); goto err; } *end = '\0'; @@ -760,9 +760,8 @@ static BIO *process_include(char *include, OPENSSL_DIR_CTX **dirctx, if (S_ISDIR(st.st_mode)) { if (*dirctx != NULL) { - ERR_raise(ERR_LIB_CONF, - CONF_R_RECURSIVE_DIRECTORY_INCLUDE); - ERR_add_error_data(1, include); + ERR_raise_data(ERR_LIB_CONF, CONF_R_RECURSIVE_DIRECTORY_INCLUDE, + "%s", include); return NULL; } /* a directory, load its contents */ diff --git a/crypto/conf/conf_lib.c b/crypto/conf/conf_lib.c index d100d5ed5c..1f106d8c07 100644 --- a/crypto/conf/conf_lib.c +++ b/crypto/conf/conf_lib.c @@ -279,8 +279,8 @@ char *NCONF_get_string(const CONF *conf, const char *group, const char *name) ERR_raise(ERR_LIB_CONF, CONF_R_NO_CONF_OR_ENVIRONMENT_VARIABLE); return NULL; } - ERR_raise(ERR_LIB_CONF, CONF_R_NO_VALUE); - ERR_add_error_data(4, "group=", group, " name=", name); + ERR_raise_data(ERR_LIB_CONF, CONF_R_NO_VALUE, + "group=%s name=%s", group, name); return NULL; } diff --git a/crypto/conf/conf_mod.c b/crypto/conf/conf_mod.c index 9a07beb6b6..cb1bf7cd3c 100644 --- a/crypto/conf/conf_mod.c +++ b/crypto/conf/conf_mod.c @@ -121,8 +121,9 @@ int CONF_modules_load(const CONF *cnf, const char *appname, if (values == NULL) { if (!(flags & CONF_MFLAGS_SILENT)) { ERR_clear_last_mark(); - ERR_raise(ERR_LIB_CONF, CONF_R_OPENSSL_CONF_REFERENCES_MISSING_SECTION); - ERR_add_error_data(2, "openssl_conf=", vsection); + ERR_raise_data(ERR_LIB_CONF, + CONF_R_OPENSSL_CONF_REFERENCES_MISSING_SECTION, + "openssl_conf=%s", vsection); } else { ERR_pop_to_mark(); } @@ -228,8 +229,8 @@ static int module_run(const CONF *cnf, const char *name, const char *value, if (!md) { if (!(flags & CONF_MFLAGS_SILENT)) { - ERR_raise(ERR_LIB_CONF, CONF_R_UNKNOWN_MODULE_NAME); - ERR_add_error_data(2, "module=", name); + ERR_raise_data(ERR_LIB_CONF, CONF_R_UNKNOWN_MODULE_NAME, + "module=%s", name); } return -1; } @@ -237,14 +238,10 @@ static int module_run(const CONF *cnf, const char *name, const char *value, ret = module_init(md, name, value, cnf); if (ret <= 0) { - if (!(flags & CONF_MFLAGS_SILENT)) { - char rcode[DECIMAL_SIZE(ret) + 1]; - - ERR_raise(ERR_LIB_CONF, CONF_R_MODULE_INITIALIZATION_ERROR); - BIO_snprintf(rcode, sizeof(rcode), "%-8d", ret); - ERR_add_error_data(6, "module=", name, ", value=", value, - ", retcode=", rcode); - } + if (!(flags & CONF_MFLAGS_SILENT)) + ERR_raise_data(ERR_LIB_CONF, CONF_R_MODULE_INITIALIZATION_ERROR, + "module=%s, value=%s retcode=%-8d", + name, value, ret); } return ret; @@ -287,8 +284,7 @@ static CONF_MODULE *module_load_dso(const CONF *cnf, err: DSO_free(dso); - ERR_raise(ERR_LIB_CONF, errcode); - ERR_add_error_data(4, "module=", name, ", path=", path); + ERR_raise_data(ERR_LIB_CONF, errcode, "module=%s, path=%s", name, path); return NULL; } diff --git a/crypto/conf/conf_ssl.c b/crypto/conf/conf_ssl.c index 6512dda132..a4b35bab99 100644 --- a/crypto/conf/conf_ssl.c +++ b/crypto/conf/conf_ssl.c @@ -68,11 +68,12 @@ static int ssl_module_init(CONF_IMODULE *md, const CONF *cnf) ssl_conf_section = CONF_imodule_get_value(md); cmd_lists = NCONF_get_section(cnf, ssl_conf_section); if (sk_CONF_VALUE_num(cmd_lists) <= 0) { - if (cmd_lists == NULL) - ERR_raise(ERR_LIB_CONF, CONF_R_SSL_SECTION_NOT_FOUND); - else - ERR_raise(ERR_LIB_CONF, CONF_R_SSL_SECTION_EMPTY); - ERR_add_error_data(2, "section=", ssl_conf_section); + int rcode = + cmd_lists == NULL + ? CONF_R_SSL_SECTION_NOT_FOUND + : CONF_R_SSL_SECTION_EMPTY; + + ERR_raise_data(ERR_LIB_CONF, rcode, "section=%s", ssl_conf_section); goto err; } cnt = sk_CONF_VALUE_num(cmd_lists); @@ -87,13 +88,13 @@ static int ssl_module_init(CONF_IMODULE *md, const CONF *cnf) STACK_OF(CONF_VALUE) *cmds = NCONF_get_section(cnf, sect->value); if (sk_CONF_VALUE_num(cmds) <= 0) { - if (cmds == NULL) - ERR_raise(ERR_LIB_CONF, - CONF_R_SSL_COMMAND_SECTION_NOT_FOUND); - else - ERR_raise(ERR_LIB_CONF, - CONF_R_SSL_COMMAND_SECTION_EMPTY); - ERR_add_error_data(4, "name=", sect->name, ", value=", sect->value); + int rcode = + cmds == NULL + ? CONF_R_SSL_COMMAND_SECTION_NOT_FOUND + : CONF_R_SSL_COMMAND_SECTION_EMPTY; + + ERR_raise_data(ERR_LIB_CONF, rcode, + "name=%s, value=%s", sect->name, sect->value); goto err; } ssl_name->name = OPENSSL_strdup(sect->name); |