summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/dso/dso_dlfcn.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/dso/dso_dlfcn.c')
-rw-r--r--src/lib/libcrypto/dso/dso_dlfcn.c40
1 files changed, 19 insertions, 21 deletions
diff --git a/src/lib/libcrypto/dso/dso_dlfcn.c b/src/lib/libcrypto/dso/dso_dlfcn.c
index f22e641bab..95afd26b82 100644
--- a/src/lib/libcrypto/dso/dso_dlfcn.c
+++ b/src/lib/libcrypto/dso/dso_dlfcn.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: dso_dlfcn.c,v 1.28 2015/02/07 13:19:15 doug Exp $ */ 1/* $OpenBSD: dso_dlfcn.c,v 1.29 2017/01/29 17:49:23 beck Exp $ */
2/* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL 2/* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL
3 * project 2000. 3 * project 2000.
4 */ 4 */
@@ -119,7 +119,7 @@ dlfcn_load(DSO *dso)
119 int flags = RTLD_LAZY; 119 int flags = RTLD_LAZY;
120 120
121 if (filename == NULL) { 121 if (filename == NULL) {
122 DSOerr(DSO_F_DLFCN_LOAD, DSO_R_NO_FILENAME); 122 DSOerror(DSO_R_NO_FILENAME);
123 goto err; 123 goto err;
124 } 124 }
125 125
@@ -127,13 +127,13 @@ dlfcn_load(DSO *dso)
127 flags |= RTLD_GLOBAL; 127 flags |= RTLD_GLOBAL;
128 ptr = dlopen(filename, flags); 128 ptr = dlopen(filename, flags);
129 if (ptr == NULL) { 129 if (ptr == NULL) {
130 DSOerr(DSO_F_DLFCN_LOAD, DSO_R_LOAD_FAILED); 130 DSOerror(DSO_R_LOAD_FAILED);
131 ERR_asprintf_error_data("filename(%s): %s", filename, 131 ERR_asprintf_error_data("filename(%s): %s", filename,
132 dlerror()); 132 dlerror());
133 goto err; 133 goto err;
134 } 134 }
135 if (!sk_void_push(dso->meth_data, (char *)ptr)) { 135 if (!sk_void_push(dso->meth_data, (char *)ptr)) {
136 DSOerr(DSO_F_DLFCN_LOAD, DSO_R_STACK_ERROR); 136 DSOerror(DSO_R_STACK_ERROR);
137 goto err; 137 goto err;
138 } 138 }
139 /* Success */ 139 /* Success */
@@ -153,14 +153,14 @@ dlfcn_unload(DSO *dso)
153{ 153{
154 void *ptr; 154 void *ptr;
155 if (dso == NULL) { 155 if (dso == NULL) {
156 DSOerr(DSO_F_DLFCN_UNLOAD, ERR_R_PASSED_NULL_PARAMETER); 156 DSOerror(ERR_R_PASSED_NULL_PARAMETER);
157 return (0); 157 return (0);
158 } 158 }
159 if (sk_void_num(dso->meth_data) < 1) 159 if (sk_void_num(dso->meth_data) < 1)
160 return (1); 160 return (1);
161 ptr = sk_void_pop(dso->meth_data); 161 ptr = sk_void_pop(dso->meth_data);
162 if (ptr == NULL) { 162 if (ptr == NULL) {
163 DSOerr(DSO_F_DLFCN_UNLOAD, DSO_R_NULL_HANDLE); 163 DSOerror(DSO_R_NULL_HANDLE);
164 /* Should push the value back onto the stack in 164 /* Should push the value back onto the stack in
165 * case of a retry. */ 165 * case of a retry. */
166 sk_void_push(dso->meth_data, ptr); 166 sk_void_push(dso->meth_data, ptr);
@@ -177,21 +177,21 @@ dlfcn_bind_var(DSO *dso, const char *symname)
177 void *ptr, *sym; 177 void *ptr, *sym;
178 178
179 if ((dso == NULL) || (symname == NULL)) { 179 if ((dso == NULL) || (symname == NULL)) {
180 DSOerr(DSO_F_DLFCN_BIND_VAR, ERR_R_PASSED_NULL_PARAMETER); 180 DSOerror(ERR_R_PASSED_NULL_PARAMETER);
181 return (NULL); 181 return (NULL);
182 } 182 }
183 if (sk_void_num(dso->meth_data) < 1) { 183 if (sk_void_num(dso->meth_data) < 1) {
184 DSOerr(DSO_F_DLFCN_BIND_VAR, DSO_R_STACK_ERROR); 184 DSOerror(DSO_R_STACK_ERROR);
185 return (NULL); 185 return (NULL);
186 } 186 }
187 ptr = sk_void_value(dso->meth_data, sk_void_num(dso->meth_data) - 1); 187 ptr = sk_void_value(dso->meth_data, sk_void_num(dso->meth_data) - 1);
188 if (ptr == NULL) { 188 if (ptr == NULL) {
189 DSOerr(DSO_F_DLFCN_BIND_VAR, DSO_R_NULL_HANDLE); 189 DSOerror(DSO_R_NULL_HANDLE);
190 return (NULL); 190 return (NULL);
191 } 191 }
192 sym = dlsym(ptr, symname); 192 sym = dlsym(ptr, symname);
193 if (sym == NULL) { 193 if (sym == NULL) {
194 DSOerr(DSO_F_DLFCN_BIND_VAR, DSO_R_SYM_FAILURE); 194 DSOerror(DSO_R_SYM_FAILURE);
195 ERR_asprintf_error_data("symname(%s): %s", symname, dlerror()); 195 ERR_asprintf_error_data("symname(%s): %s", symname, dlerror());
196 return (NULL); 196 return (NULL);
197 } 197 }
@@ -208,21 +208,21 @@ dlfcn_bind_func(DSO *dso, const char *symname)
208 } u; 208 } u;
209 209
210 if ((dso == NULL) || (symname == NULL)) { 210 if ((dso == NULL) || (symname == NULL)) {
211 DSOerr(DSO_F_DLFCN_BIND_FUNC, ERR_R_PASSED_NULL_PARAMETER); 211 DSOerror(ERR_R_PASSED_NULL_PARAMETER);
212 return (NULL); 212 return (NULL);
213 } 213 }
214 if (sk_void_num(dso->meth_data) < 1) { 214 if (sk_void_num(dso->meth_data) < 1) {
215 DSOerr(DSO_F_DLFCN_BIND_FUNC, DSO_R_STACK_ERROR); 215 DSOerror(DSO_R_STACK_ERROR);
216 return (NULL); 216 return (NULL);
217 } 217 }
218 ptr = sk_void_value(dso->meth_data, sk_void_num(dso->meth_data) - 1); 218 ptr = sk_void_value(dso->meth_data, sk_void_num(dso->meth_data) - 1);
219 if (ptr == NULL) { 219 if (ptr == NULL) {
220 DSOerr(DSO_F_DLFCN_BIND_FUNC, DSO_R_NULL_HANDLE); 220 DSOerror(DSO_R_NULL_HANDLE);
221 return (NULL); 221 return (NULL);
222 } 222 }
223 u.dlret = dlsym(ptr, symname); 223 u.dlret = dlsym(ptr, symname);
224 if (u.dlret == NULL) { 224 if (u.dlret == NULL) {
225 DSOerr(DSO_F_DLFCN_BIND_FUNC, DSO_R_SYM_FAILURE); 225 DSOerror(DSO_R_SYM_FAILURE);
226 ERR_asprintf_error_data("symname(%s): %s", symname, dlerror()); 226 ERR_asprintf_error_data("symname(%s): %s", symname, dlerror());
227 return (NULL); 227 return (NULL);
228 } 228 }
@@ -235,8 +235,7 @@ dlfcn_merger(DSO *dso, const char *filespec1, const char *filespec2)
235 char *merged; 235 char *merged;
236 236
237 if (!filespec1 && !filespec2) { 237 if (!filespec1 && !filespec2) {
238 DSOerr(DSO_F_DLFCN_MERGER, 238 DSOerror(ERR_R_PASSED_NULL_PARAMETER);
239 ERR_R_PASSED_NULL_PARAMETER);
240 return (NULL); 239 return (NULL);
241 } 240 }
242 /* If the first file specification is a rooted path, it rules. 241 /* If the first file specification is a rooted path, it rules.
@@ -244,7 +243,7 @@ dlfcn_merger(DSO *dso, const char *filespec1, const char *filespec2)
244 if (!filespec2 || (filespec1 != NULL && filespec1[0] == '/')) { 243 if (!filespec2 || (filespec1 != NULL && filespec1[0] == '/')) {
245 merged = strdup(filespec1); 244 merged = strdup(filespec1);
246 if (!merged) { 245 if (!merged) {
247 DSOerr(DSO_F_DLFCN_MERGER, ERR_R_MALLOC_FAILURE); 246 DSOerror(ERR_R_MALLOC_FAILURE);
248 return (NULL); 247 return (NULL);
249 } 248 }
250 } 249 }
@@ -252,7 +251,7 @@ dlfcn_merger(DSO *dso, const char *filespec1, const char *filespec2)
252 else if (!filespec1) { 251 else if (!filespec1) {
253 merged = strdup(filespec2); 252 merged = strdup(filespec2);
254 if (!merged) { 253 if (!merged) {
255 DSOerr(DSO_F_DLFCN_MERGER, ERR_R_MALLOC_FAILURE); 254 DSOerror(ERR_R_MALLOC_FAILURE);
256 return (NULL); 255 return (NULL);
257 } 256 }
258 } else 257 } else
@@ -273,7 +272,7 @@ dlfcn_merger(DSO *dso, const char *filespec1, const char *filespec2)
273 } 272 }
274 merged = malloc(len + 2); 273 merged = malloc(len + 2);
275 if (!merged) { 274 if (!merged) {
276 DSOerr(DSO_F_DLFCN_MERGER, ERR_R_MALLOC_FAILURE); 275 DSOerror(ERR_R_MALLOC_FAILURE);
277 return (NULL); 276 return (NULL);
278 } 277 }
279 strlcpy(merged, filespec2, len + 2); 278 strlcpy(merged, filespec2, len + 2);
@@ -306,8 +305,7 @@ dlfcn_name_converter(DSO *dso, const char *filename)
306 } 305 }
307 306
308 if (translated == NULL) 307 if (translated == NULL)
309 DSOerr(DSO_F_DLFCN_NAME_CONVERTER, 308 DSOerror(DSO_R_NAME_TRANSLATION_FAILED);
310 DSO_R_NAME_TRANSLATION_FAILED);
311 return (translated); 309 return (translated);
312} 310}
313 311