summaryrefslogtreecommitdiffstats
path: root/crypto/conf
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2020-11-04 12:23:19 +0100
committerRichard Levitte <levitte@openssl.org>2020-11-13 09:35:02 +0100
commit9311d0c471ca2eaa259e8c1bbbeb7c46394c7ba2 (patch)
treee82c26569e5a952980e65a746af920beed602aab /crypto/conf
parent31a6b52f6db009c639c67387a707dd235f29a430 (diff)
Convert all {NAME}err() in crypto/ to their corresponding ERR_raise() call
This includes error reporting for libcrypto sub-libraries in surprising places. This was done using util/err-to-raise 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.c56
-rw-r--r--crypto/conf/conf_lib.c31
-rw-r--r--crypto/conf/conf_mod.c16
-rw-r--r--crypto/conf/conf_ssl.c8
4 files changed, 53 insertions, 58 deletions
diff --git a/crypto/conf/conf_def.c b/crypto/conf/conf_def.c
index dd2d16647a..5923f88212 100644
--- a/crypto/conf/conf_def.c
+++ b/crypto/conf/conf_def.c
@@ -174,9 +174,9 @@ static int def_load(CONF *conf, const char *name, long *line)
#endif
if (in == NULL) {
if (ERR_GET_REASON(ERR_peek_last_error()) == BIO_R_NO_SUCH_FILE)
- CONFerr(CONF_F_DEF_LOAD, CONF_R_NO_SUCH_FILE);
+ ERR_raise(ERR_LIB_CONF, CONF_R_NO_SUCH_FILE);
else
- CONFerr(CONF_F_DEF_LOAD, ERR_R_SYS_LIB);
+ ERR_raise(ERR_LIB_CONF, ERR_R_SYS_LIB);
return 0;
}
@@ -208,24 +208,24 @@ static int def_load_bio(CONF *conf, BIO *in, long *line)
#endif
if ((buff = BUF_MEM_new()) == NULL) {
- CONFerr(CONF_F_DEF_LOAD_BIO, ERR_R_BUF_LIB);
+ ERR_raise(ERR_LIB_CONF, ERR_R_BUF_LIB);
goto err;
}
section = OPENSSL_strdup("default");
if (section == NULL) {
- CONFerr(CONF_F_DEF_LOAD_BIO, ERR_R_MALLOC_FAILURE);
+ ERR_raise(ERR_LIB_CONF, ERR_R_MALLOC_FAILURE);
goto err;
}
if (_CONF_new_data(conf) == 0) {
- CONFerr(CONF_F_DEF_LOAD_BIO, ERR_R_MALLOC_FAILURE);
+ ERR_raise(ERR_LIB_CONF, ERR_R_MALLOC_FAILURE);
goto err;
}
sv = _CONF_new_section(conf, section);
if (sv == NULL) {
- CONFerr(CONF_F_DEF_LOAD_BIO, CONF_R_UNABLE_TO_CREATE_NEW_SECTION);
+ ERR_raise(ERR_LIB_CONF, CONF_R_UNABLE_TO_CREATE_NEW_SECTION);
goto err;
}
@@ -233,7 +233,7 @@ static int def_load_bio(CONF *conf, BIO *in, long *line)
again = 0;
for (;;) {
if (!BUF_MEM_grow(buff, bufnum + CONFBUFSIZE)) {
- CONFerr(CONF_F_DEF_LOAD_BIO, ERR_R_BUF_LIB);
+ ERR_raise(ERR_LIB_CONF, ERR_R_BUF_LIB);
goto err;
}
p = &(buff->data[bufnum]);
@@ -329,8 +329,7 @@ static int def_load_bio(CONF *conf, BIO *in, long *line)
ss = p;
goto again;
}
- CONFerr(CONF_F_DEF_LOAD_BIO,
- CONF_R_MISSING_CLOSE_SQUARE_BRACKET);
+ ERR_raise(ERR_LIB_CONF, CONF_R_MISSING_CLOSE_SQUARE_BRACKET);
goto err;
}
*end = '\0';
@@ -339,8 +338,7 @@ static int def_load_bio(CONF *conf, BIO *in, long *line)
if ((sv = _CONF_get_section(conf, section)) == NULL)
sv = _CONF_new_section(conf, section);
if (sv == NULL) {
- CONFerr(CONF_F_DEF_LOAD_BIO,
- CONF_R_UNABLE_TO_CREATE_NEW_SECTION);
+ ERR_raise(ERR_LIB_CONF, CONF_R_UNABLE_TO_CREATE_NEW_SECTION);
goto err;
}
continue;
@@ -370,7 +368,7 @@ static int def_load_bio(CONF *conf, BIO *in, long *line)
/* Pragma values take the form keyword:value */
pval = strchr(p, ':');
if (pval == NULL || pval == p || pval[1] == '\0') {
- CONFerr(CONF_F_DEF_LOAD_BIO, CONF_R_INVALID_PRAGMA);
+ ERR_raise(ERR_LIB_CONF, CONF_R_INVALID_PRAGMA);
goto err;
}
@@ -391,7 +389,7 @@ static int def_load_bio(CONF *conf, BIO *in, long *line)
|| strcmp(pval, "false") == 0) {
conf->flag_dollarid = 0;
} else {
- CONFerr(CONF_F_DEF_LOAD_BIO, CONF_R_INVALID_PRAGMA);
+ ERR_raise(ERR_LIB_CONF, CONF_R_INVALID_PRAGMA);
goto err;
}
}
@@ -449,13 +447,13 @@ static int def_load_bio(CONF *conf, BIO *in, long *line)
/* push the currently processing BIO onto stack */
if (biosk == NULL) {
if ((biosk = sk_BIO_new_null()) == NULL) {
- CONFerr(CONF_F_DEF_LOAD_BIO, ERR_R_MALLOC_FAILURE);
+ ERR_raise(ERR_LIB_CONF, ERR_R_MALLOC_FAILURE);
BIO_free(next);
goto err;
}
}
if (!sk_BIO_push(biosk, in)) {
- CONFerr(CONF_F_DEF_LOAD_BIO, ERR_R_MALLOC_FAILURE);
+ ERR_raise(ERR_LIB_CONF, ERR_R_MALLOC_FAILURE);
BIO_free(next);
goto err;
}
@@ -464,7 +462,7 @@ static int def_load_bio(CONF *conf, BIO *in, long *line)
}
continue;
} else if (*p != '=') {
- CONFerr(CONF_F_DEF_LOAD_BIO, CONF_R_MISSING_EQUAL_SIGN);
+ ERR_raise(ERR_LIB_CONF, CONF_R_MISSING_EQUAL_SIGN);
ERR_add_error_data(2, "HERE-->", p);
goto err;
}
@@ -474,13 +472,13 @@ static int def_load_bio(CONF *conf, BIO *in, long *line)
trim_ws(conf, start);
if ((v = OPENSSL_malloc(sizeof(*v))) == NULL) {
- CONFerr(CONF_F_DEF_LOAD_BIO, ERR_R_MALLOC_FAILURE);
+ ERR_raise(ERR_LIB_CONF, ERR_R_MALLOC_FAILURE);
goto err;
}
v->name = OPENSSL_strdup(pname);
v->value = NULL;
if (v->name == NULL) {
- CONFerr(CONF_F_DEF_LOAD_BIO, ERR_R_MALLOC_FAILURE);
+ ERR_raise(ERR_LIB_CONF, ERR_R_MALLOC_FAILURE);
goto err;
}
if (!str_copy(conf, psection, &(v->value), start))
@@ -491,14 +489,14 @@ static int def_load_bio(CONF *conf, BIO *in, long *line)
== NULL)
tv = _CONF_new_section(conf, psection);
if (tv == NULL) {
- CONFerr(CONF_F_DEF_LOAD_BIO,
- CONF_R_UNABLE_TO_CREATE_NEW_SECTION);
+ ERR_raise(ERR_LIB_CONF,
+ CONF_R_UNABLE_TO_CREATE_NEW_SECTION);
goto err;
}
} else
tv = sv;
if (_CONF_add_string(conf, tv, v) == 0) {
- CONFerr(CONF_F_DEF_LOAD_BIO, ERR_R_MALLOC_FAILURE);
+ ERR_raise(ERR_LIB_CONF, ERR_R_MALLOC_FAILURE);
goto err;
}
v = NULL;
@@ -681,7 +679,7 @@ static int str_copy(CONF *conf, char *section, char **pto, char *from)
rp = e;
if (q) {
if (r != q) {
- CONFerr(CONF_F_STR_COPY, CONF_R_NO_CLOSE_BRACE);
+ ERR_raise(ERR_LIB_CONF, CONF_R_NO_CLOSE_BRACE);
goto err;
}
e++;
@@ -701,16 +699,16 @@ static int str_copy(CONF *conf, char *section, char **pto, char *from)
*rrp = rr;
*rp = r;
if (p == NULL) {
- CONFerr(CONF_F_STR_COPY, CONF_R_VARIABLE_HAS_NO_VALUE);
+ ERR_raise(ERR_LIB_CONF, CONF_R_VARIABLE_HAS_NO_VALUE);
goto err;
}
newsize = strlen(p) + buf->length - (e - from);
if (newsize > MAX_CONF_VALUE_LENGTH) {
- CONFerr(CONF_F_STR_COPY, CONF_R_VARIABLE_EXPANSION_TOO_LONG);
+ ERR_raise(ERR_LIB_CONF, CONF_R_VARIABLE_EXPANSION_TOO_LONG);
goto err;
}
if (!BUF_MEM_grow_clean(buf, newsize)) {
- CONFerr(CONF_F_STR_COPY, ERR_R_MALLOC_FAILURE);
+ ERR_raise(ERR_LIB_CONF, ERR_R_MALLOC_FAILURE);
goto err;
}
while (*p)
@@ -755,16 +753,14 @@ static BIO *process_include(char *include, OPENSSL_DIR_CTX **dirctx,
BIO *next;
if (stat(include, &st) < 0) {
- ERR_raise_data(ERR_LIB_SYS, errno,
- "calling stat(%s)",
- include);
+ ERR_raise_data(ERR_LIB_SYS, errno, "calling stat(%s)", include);
/* missing include file is not fatal error */
return NULL;
}
if (S_ISDIR(st.st_mode)) {
if (*dirctx != NULL) {
- CONFerr(CONF_F_PROCESS_INCLUDE,
+ ERR_raise(ERR_LIB_CONF,
CONF_R_RECURSIVE_DIRECTORY_INCLUDE);
ERR_add_error_data(1, include);
return NULL;
@@ -804,7 +800,7 @@ static BIO *get_next_file(const char *path, OPENSSL_DIR_CTX **dirctx)
newlen = pathlen + namelen + 2;
newpath = OPENSSL_zalloc(newlen);
if (newpath == NULL) {
- CONFerr(CONF_F_GET_NEXT_FILE, ERR_R_MALLOC_FAILURE);
+ ERR_raise(ERR_LIB_CONF, ERR_R_MALLOC_FAILURE);
break;
}
#ifdef OPENSSL_SYS_VMS
diff --git a/crypto/conf/conf_lib.c b/crypto/conf/conf_lib.c
index 7a3ab72247..d100d5ed5c 100644
--- a/crypto/conf/conf_lib.c
+++ b/crypto/conf/conf_lib.c
@@ -54,7 +54,7 @@ LHASH_OF(CONF_VALUE) *CONF_load(LHASH_OF(CONF_VALUE) *conf, const char *file,
in = BIO_new_file(file, "rb");
#endif
if (in == NULL) {
- CONFerr(CONF_F_CONF_LOAD, ERR_R_SYS_LIB);
+ ERR_raise(ERR_LIB_CONF, ERR_R_SYS_LIB);
return NULL;
}
@@ -71,7 +71,7 @@ LHASH_OF(CONF_VALUE) *CONF_load_fp(LHASH_OF(CONF_VALUE) *conf, FILE *fp,
BIO *btmp;
LHASH_OF(CONF_VALUE) *ltmp;
if ((btmp = BIO_new_fp(fp, BIO_NOCLOSE)) == NULL) {
- CONFerr(CONF_F_CONF_LOAD_FP, ERR_R_BUF_LIB);
+ ERR_raise(ERR_LIB_CONF, ERR_R_BUF_LIB);
return NULL;
}
ltmp = CONF_load_bio(conf, btmp, eline);
@@ -153,7 +153,7 @@ int CONF_dump_fp(LHASH_OF(CONF_VALUE) *conf, FILE *out)
int ret;
if ((btmp = BIO_new_fp(out, BIO_NOCLOSE)) == NULL) {
- CONFerr(CONF_F_CONF_DUMP_FP, ERR_R_BUF_LIB);
+ ERR_raise(ERR_LIB_CONF, ERR_R_BUF_LIB);
return 0;
}
ret = CONF_dump_bio(conf, btmp);
@@ -187,7 +187,7 @@ CONF *NCONF_new_ex(OSSL_LIB_CTX *libctx, CONF_METHOD *meth)
ret = meth->create(meth);
if (ret == NULL) {
- CONFerr(0, ERR_R_MALLOC_FAILURE);
+ ERR_raise(ERR_LIB_CONF, ERR_R_MALLOC_FAILURE);
return NULL;
}
ret->libctx = libctx;
@@ -217,7 +217,7 @@ void NCONF_free_data(CONF *conf)
int NCONF_load(CONF *conf, const char *file, long *eline)
{
if (conf == NULL) {
- CONFerr(CONF_F_NCONF_LOAD, CONF_R_NO_CONF);
+ ERR_raise(ERR_LIB_CONF, CONF_R_NO_CONF);
return 0;
}
@@ -230,7 +230,7 @@ int NCONF_load_fp(CONF *conf, FILE *fp, long *eline)
BIO *btmp;
int ret;
if ((btmp = BIO_new_fp(fp, BIO_NOCLOSE)) == NULL) {
- CONFerr(CONF_F_NCONF_LOAD_FP, ERR_R_BUF_LIB);
+ ERR_raise(ERR_LIB_CONF, ERR_R_BUF_LIB);
return 0;
}
ret = NCONF_load_bio(conf, btmp, eline);
@@ -242,7 +242,7 @@ int NCONF_load_fp(CONF *conf, FILE *fp, long *eline)
int NCONF_load_bio(CONF *conf, BIO *bp, long *eline)
{
if (conf == NULL) {
- CONFerr(CONF_F_NCONF_LOAD_BIO, CONF_R_NO_CONF);
+ ERR_raise(ERR_LIB_CONF, CONF_R_NO_CONF);
return 0;
}
@@ -252,12 +252,12 @@ int NCONF_load_bio(CONF *conf, BIO *bp, long *eline)
STACK_OF(CONF_VALUE) *NCONF_get_section(const CONF *conf, const char *section)
{
if (conf == NULL) {
- CONFerr(CONF_F_NCONF_GET_SECTION, CONF_R_NO_CONF);
+ ERR_raise(ERR_LIB_CONF, CONF_R_NO_CONF);
return NULL;
}
if (section == NULL) {
- CONFerr(CONF_F_NCONF_GET_SECTION, CONF_R_NO_SECTION);
+ ERR_raise(ERR_LIB_CONF, CONF_R_NO_SECTION);
return NULL;
}
@@ -276,11 +276,10 @@ char *NCONF_get_string(const CONF *conf, const char *group, const char *name)
return s;
if (conf == NULL) {
- CONFerr(CONF_F_NCONF_GET_STRING,
- CONF_R_NO_CONF_OR_ENVIRONMENT_VARIABLE);
+ ERR_raise(ERR_LIB_CONF, CONF_R_NO_CONF_OR_ENVIRONMENT_VARIABLE);
return NULL;
}
- CONFerr(CONF_F_NCONF_GET_STRING, CONF_R_NO_VALUE);
+ ERR_raise(ERR_LIB_CONF, CONF_R_NO_VALUE);
ERR_add_error_data(4, "group=", group, " name=", name);
return NULL;
}
@@ -304,7 +303,7 @@ int NCONF_get_number_e(const CONF *conf, const char *group, const char *name,
int (*to_int)(const CONF *, char) = &default_to_int;
if (result == NULL) {
- CONFerr(CONF_F_NCONF_GET_NUMBER_E, ERR_R_PASSED_NULL_PARAMETER);
+ ERR_raise(ERR_LIB_CONF, ERR_R_PASSED_NULL_PARAMETER);
return 0;
}
@@ -323,7 +322,7 @@ int NCONF_get_number_e(const CONF *conf, const char *group, const char *name,
const int d = to_int(conf, *str);
if (res > (LONG_MAX - d) / 10L) {
- CONFerr(CONF_F_NCONF_GET_NUMBER_E, CONF_R_NUMBER_TOO_LARGE);
+ ERR_raise(ERR_LIB_CONF, CONF_R_NUMBER_TOO_LARGE);
return 0;
}
res = res * 10 + d;
@@ -351,7 +350,7 @@ int NCONF_dump_fp(const CONF *conf, FILE *out)
BIO *btmp;
int ret;
if ((btmp = BIO_new_fp(out, BIO_NOCLOSE)) == NULL) {
- CONFerr(CONF_F_NCONF_DUMP_FP, ERR_R_BUF_LIB);
+ ERR_raise(ERR_LIB_CONF, ERR_R_BUF_LIB);
return 0;
}
ret = NCONF_dump_bio(conf, btmp);
@@ -363,7 +362,7 @@ int NCONF_dump_fp(const CONF *conf, FILE *out)
int NCONF_dump_bio(const CONF *conf, BIO *out)
{
if (conf == NULL) {
- CONFerr(CONF_F_NCONF_DUMP_BIO, CONF_R_NO_CONF);
+ ERR_raise(ERR_LIB_CONF, CONF_R_NO_CONF);
return 0;
}
diff --git a/crypto/conf/conf_mod.c b/crypto/conf/conf_mod.c
index f287cb28eb..9a07beb6b6 100644
--- a/crypto/conf/conf_mod.c
+++ b/crypto/conf/conf_mod.c
@@ -121,7 +121,7 @@ int CONF_modules_load(const CONF *cnf, const char *appname,
if (values == NULL) {
if (!(flags & CONF_MFLAGS_SILENT)) {
ERR_clear_last_mark();
- CONFerr(0, CONF_R_OPENSSL_CONF_REFERENCES_MISSING_SECTION);
+ ERR_raise(ERR_LIB_CONF, CONF_R_OPENSSL_CONF_REFERENCES_MISSING_SECTION);
ERR_add_error_data(2, "openssl_conf=", vsection);
} else {
ERR_pop_to_mark();
@@ -228,7 +228,7 @@ static int module_run(const CONF *cnf, const char *name, const char *value,
if (!md) {
if (!(flags & CONF_MFLAGS_SILENT)) {
- CONFerr(CONF_F_MODULE_RUN, CONF_R_UNKNOWN_MODULE_NAME);
+ ERR_raise(ERR_LIB_CONF, CONF_R_UNKNOWN_MODULE_NAME);
ERR_add_error_data(2, "module=", name);
}
return -1;
@@ -240,7 +240,7 @@ static int module_run(const CONF *cnf, const char *name, const char *value,
if (!(flags & CONF_MFLAGS_SILENT)) {
char rcode[DECIMAL_SIZE(ret) + 1];
- CONFerr(CONF_F_MODULE_RUN, CONF_R_MODULE_INITIALIZATION_ERROR);
+ 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);
@@ -287,7 +287,7 @@ static CONF_MODULE *module_load_dso(const CONF *cnf,
err:
DSO_free(dso);
- CONFerr(CONF_F_MODULE_LOAD_DSO, errcode);
+ ERR_raise(ERR_LIB_CONF, errcode);
ERR_add_error_data(4, "module=", name, ", path=", path);
return NULL;
}
@@ -302,7 +302,7 @@ static CONF_MODULE *module_add(DSO *dso, const char *name,
if (supported_modules == NULL)
return NULL;
if ((tmod = OPENSSL_zalloc(sizeof(*tmod))) == NULL) {
- CONFerr(CONF_F_MODULE_ADD, ERR_R_MALLOC_FAILURE);
+ ERR_raise(ERR_LIB_CONF, ERR_R_MALLOC_FAILURE);
return NULL;
}
@@ -385,13 +385,13 @@ static int module_init(CONF_MODULE *pmod, const char *name, const char *value,
if (initialized_modules == NULL) {
initialized_modules = sk_CONF_IMODULE_new_null();
if (!initialized_modules) {
- CONFerr(CONF_F_MODULE_INIT, ERR_R_MALLOC_FAILURE);
+ ERR_raise(ERR_LIB_CONF, ERR_R_MALLOC_FAILURE);
goto err;
}
}
if (!sk_CONF_IMODULE_push(initialized_modules, imod)) {
- CONFerr(CONF_F_MODULE_INIT, ERR_R_MALLOC_FAILURE);
+ ERR_raise(ERR_LIB_CONF, ERR_R_MALLOC_FAILURE);
goto err;
}
@@ -582,7 +582,7 @@ int CONF_parse_list(const char *list_, int sep, int nospc,
const char *lstart, *tmpend, *p;
if (list_ == NULL) {
- CONFerr(CONF_F_CONF_PARSE_LIST, CONF_R_LIST_CANNOT_BE_NULL);
+ ERR_raise(ERR_LIB_CONF, CONF_R_LIST_CANNOT_BE_NULL);
return 0;
}
diff --git a/crypto/conf/conf_ssl.c b/crypto/conf/conf_ssl.c
index 5b949be616..6512dda132 100644
--- a/crypto/conf/conf_ssl.c
+++ b/crypto/conf/conf_ssl.c
@@ -69,9 +69,9 @@ static int ssl_module_init(CONF_IMODULE *md, const CONF *cnf)
cmd_lists = NCONF_get_section(cnf, ssl_conf_section);
if (sk_CONF_VALUE_num(cmd_lists) <= 0) {
if (cmd_lists == NULL)
- CONFerr(CONF_F_SSL_MODULE_INIT, CONF_R_SSL_SECTION_NOT_FOUND);
+ ERR_raise(ERR_LIB_CONF, CONF_R_SSL_SECTION_NOT_FOUND);
else
- CONFerr(CONF_F_SSL_MODULE_INIT, CONF_R_SSL_SECTION_EMPTY);
+ ERR_raise(ERR_LIB_CONF, CONF_R_SSL_SECTION_EMPTY);
ERR_add_error_data(2, "section=", ssl_conf_section);
goto err;
}
@@ -88,10 +88,10 @@ static int ssl_module_init(CONF_IMODULE *md, const CONF *cnf)
if (sk_CONF_VALUE_num(cmds) <= 0) {
if (cmds == NULL)
- CONFerr(CONF_F_SSL_MODULE_INIT,
+ ERR_raise(ERR_LIB_CONF,
CONF_R_SSL_COMMAND_SECTION_NOT_FOUND);
else
- CONFerr(CONF_F_SSL_MODULE_INIT,
+ ERR_raise(ERR_LIB_CONF,
CONF_R_SSL_COMMAND_SECTION_EMPTY);
ERR_add_error_data(4, "name=", sect->name, ", value=", sect->value);
goto err;