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.c36
1 files changed, 34 insertions, 2 deletions
diff --git a/src/lib/libcrypto/dso/dso_dlfcn.c b/src/lib/libcrypto/dso/dso_dlfcn.c
index 9d49ebc253..0422a4859a 100644
--- a/src/lib/libcrypto/dso/dso_dlfcn.c
+++ b/src/lib/libcrypto/dso/dso_dlfcn.c
@@ -56,6 +56,10 @@
56 * 56 *
57 */ 57 */
58 58
59#ifdef __linux
60#define _GNU_SOURCE
61#endif
62
59#include <stdio.h> 63#include <stdio.h>
60#include "cryptlib.h" 64#include "cryptlib.h"
61#include <openssl/dso.h> 65#include <openssl/dso.h>
@@ -228,7 +232,7 @@ static void *dlfcn_bind_var(DSO *dso, const char *symname)
228static DSO_FUNC_TYPE dlfcn_bind_func(DSO *dso, const char *symname) 232static DSO_FUNC_TYPE dlfcn_bind_func(DSO *dso, const char *symname)
229 { 233 {
230 void *ptr; 234 void *ptr;
231 DSO_FUNC_TYPE sym; 235 DSO_FUNC_TYPE sym, *tsym = &sym;
232 236
233 if((dso == NULL) || (symname == NULL)) 237 if((dso == NULL) || (symname == NULL))
234 { 238 {
@@ -246,7 +250,7 @@ static DSO_FUNC_TYPE dlfcn_bind_func(DSO *dso, const char *symname)
246 DSOerr(DSO_F_DLFCN_BIND_FUNC,DSO_R_NULL_HANDLE); 250 DSOerr(DSO_F_DLFCN_BIND_FUNC,DSO_R_NULL_HANDLE);
247 return(NULL); 251 return(NULL);
248 } 252 }
249 sym = (DSO_FUNC_TYPE)dlsym(ptr, symname); 253 *(void**)(tsym) = dlsym(ptr, symname);
250 if(sym == NULL) 254 if(sym == NULL)
251 { 255 {
252 DSOerr(DSO_F_DLFCN_BIND_FUNC,DSO_R_SYM_FAILURE); 256 DSOerr(DSO_F_DLFCN_BIND_FUNC,DSO_R_SYM_FAILURE);
@@ -290,4 +294,32 @@ static char *dlfcn_name_converter(DSO *dso, const char *filename)
290 return(translated); 294 return(translated);
291 } 295 }
292 296
297#ifdef OPENSSL_FIPS
298static void dlfcn_ref_point(){}
299
300int DSO_pathbyaddr(void *addr,char *path,int sz)
301 {
302 Dl_info dli;
303 int len;
304
305 if (addr == NULL)
306 {
307 union { void(*f)(void); void *p; } t = { dlfcn_ref_point };
308 addr = t.p;
309 }
310
311 if (dladdr(addr,&dli))
312 {
313 len = (int)strlen(dli.dli_fname);
314 if (sz <= 0) return len+1;
315 if (len >= sz) len=sz-1;
316 memcpy(path,dli.dli_fname,len);
317 path[len++]=0;
318 return len;
319 }
320
321 ERR_add_error_data(4, "dlfcn_pathbyaddr(): ", dlerror());
322 return -1;
323 }
324#endif
293#endif /* DSO_DLFCN */ 325#endif /* DSO_DLFCN */