summaryrefslogtreecommitdiffstats
path: root/crypto/dso
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/dso
parentConvert all {NAME}err() in crypto/ to their corresponding ERR_raise() call (diff)
downloadopenssl-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/dso')
-rw-r--r--crypto/dso/dso_dl.c16
-rw-r--r--crypto/dso/dso_dlfcn.c9
-rw-r--r--crypto/dso/dso_vms.c23
-rw-r--r--crypto/dso/dso_win32.c7
4 files changed, 30 insertions, 25 deletions
diff --git a/crypto/dso/dso_dl.c b/crypto/dso/dso_dl.c
index 721fb14c83..36dcf1d73d 100644
--- a/crypto/dso/dso_dl.c
+++ b/crypto/dso/dso_dl.c
@@ -69,9 +69,13 @@ static int dl_load(DSO *dso)
DYNAMIC_PATH), 0L);
if (ptr == NULL) {
char errbuf[160];
- ERR_raise(ERR_LIB_DSO, DSO_R_LOAD_FAILED);
+
if (openssl_strerror_r(errno, errbuf, sizeof(errbuf)))
- ERR_add_error_data(4, "filename(", filename, "): ", errbuf);
+ ERR_raise_data(ERR_LIB_DSO, DSO_R_LOAD_FAILED,
+ "filename(%s): %s", filename, errbuf);
+ else
+ ERR_raise_data(ERR_LIB_DSO, DSO_R_LOAD_FAILED,
+ "filename(%s): errno %d", filename, errno);
goto err;
}
if (!sk_push(dso->meth_data, (char *)ptr)) {
@@ -135,9 +139,13 @@ static DSO_FUNC_TYPE dl_bind_func(DSO *dso, const char *symname)
}
if (shl_findsym(&ptr, symname, TYPE_UNDEFINED, &sym) < 0) {
char errbuf[160];
- ERR_raise(ERR_LIB_DSO, DSO_R_SYM_FAILURE);
+
if (openssl_strerror_r(errno, errbuf, sizeof(errbuf)))
- ERR_add_error_data(4, "symname(", symname, "): ", errbuf);
+ ERR_raise_data(ERR_LIB_DSO, DSO_R_SYM_FAILURE,
+ "symname(%s): %s", symname, errbuf);
+ else
+ ERR_raise_data(ERR_LIB_DSO, DSO_R_SYM_FAILURE,
+ "symname(%s): errno %d", symname, errno);
return NULL;
}
return (DSO_FUNC_TYPE)sym;
diff --git a/crypto/dso/dso_dlfcn.c b/crypto/dso/dso_dlfcn.c
index 4137d7d9f8..76bc6055bc 100644
--- a/crypto/dso/dso_dlfcn.c
+++ b/crypto/dso/dso_dlfcn.c
@@ -115,8 +115,8 @@ static int dlfcn_load(DSO *dso)
# endif
ptr = dlopen(filename, flags);
if (ptr == NULL) {
- ERR_raise(ERR_LIB_DSO, DSO_R_LOAD_FAILED);
- ERR_add_error_data(4, "filename(", filename, "): ", dlerror());
+ ERR_raise_data(ERR_LIB_DSO, DSO_R_LOAD_FAILED,
+ "filename(%s): %s", filename, dlerror());
goto err;
}
/*
@@ -185,8 +185,8 @@ static DSO_FUNC_TYPE dlfcn_bind_func(DSO *dso, const char *symname)
}
u.dlret = dlsym(ptr, symname);
if (u.dlret == NULL) {
- ERR_raise(ERR_LIB_DSO, DSO_R_SYM_FAILURE);
- ERR_add_error_data(4, "symname(", symname, "): ", dlerror());
+ ERR_raise_data(ERR_LIB_DSO, DSO_R_SYM_FAILURE,
+ "symname(%s): %s", symname, dlerror());
return NULL;
}
return u.sym;
@@ -437,6 +437,7 @@ static int dlfcn_pathbyaddr(void *addr, char *path, int sz)
return len;
}
+ /* TODO: what error report does this attach to? */
ERR_add_error_data(2, "dlfcn_pathbyaddr(): ", dlerror());
# endif
return -1;
diff --git a/crypto/dso/dso_vms.c b/crypto/dso/dso_vms.c
index 90b94992b4..03abcc0d73 100644
--- a/crypto/dso/dso_vms.c
+++ b/crypto/dso/dso_vms.c
@@ -336,17 +336,15 @@ void vms_bind_sym(DSO *dso, const char *symname, void **sym)
else {
errstring[length] = '\0';
- ERR_raise(ERR_LIB_DSO, DSO_R_SYM_FAILURE);
if (ptr->imagename_dsc.dsc$w_length)
- ERR_add_error_data(9,
- "Symbol ", symname,
- " in ", ptr->filename,
- " (", ptr->imagename, ")",
- ": ", errstring);
+ ERR_raise_data(ERR_LIB_DSO, DSO_R_SYM_FAILURE,
+ "Symbol %s in %s (%s): %s",
+ symname, ptr->filename, ptr->imagename,
+ errstring);
else
- ERR_add_error_data(6,
- "Symbol ", symname,
- " in ", ptr->filename, ": ", errstring);
+ ERR_raise_data(ERR_LIB_DSO, DSO_R_SYM_FAILURE,
+ "Symbol %s in %s: %s",
+ symname, ptr->filename, errstring);
}
return;
}
@@ -436,10 +434,9 @@ static char *vms_merger(DSO *dso, const char *filespec1,
else {
errstring[length] = '\0';
- ERR_raise(ERR_LIB_DSO, DSO_R_FAILURE);
- ERR_add_error_data(7,
- "filespec \"", filespec1, "\", ",
- "defaults \"", filespec2, "\": ", errstring);
+ ERR_raise_data(ERR_LIB_DSO, DSO_R_FAILURE,
+ "filespec \"%s\", default \"%s\": %s",
+ filespec1, filespec2, errstring);
}
return NULL;
}
diff --git a/crypto/dso/dso_win32.c b/crypto/dso/dso_win32.c
index 3b4d596220..4d3059d438 100644
--- a/crypto/dso/dso_win32.c
+++ b/crypto/dso/dso_win32.c
@@ -105,8 +105,8 @@ static int win32_load(DSO *dso)
}
h = LoadLibraryA(filename);
if (h == NULL) {
- ERR_raise(ERR_LIB_DSO, DSO_R_LOAD_FAILED);
- ERR_add_error_data(3, "filename(", filename, ")");
+ ERR_raise_data(ERR_LIB_DSO, DSO_R_LOAD_FAILED,
+ "filename(%s)", filename);
goto err;
}
p = OPENSSL_malloc(sizeof(*p));
@@ -181,8 +181,7 @@ static DSO_FUNC_TYPE win32_bind_func(DSO *dso, const char *symname)
}
sym.f = GetProcAddress(*ptr, symname);
if (sym.p == NULL) {
- ERR_raise(ERR_LIB_DSO, DSO_R_SYM_FAILURE);
- ERR_add_error_data(3, "symname(", symname, ")");
+ ERR_raise_data(ERR_LIB_DSO, DSO_R_SYM_FAILURE, "symname(%s)", symname);
return NULL;
}
return (DSO_FUNC_TYPE)sym.f;