diff options
Diffstat (limited to 'src/lib/libcrypto/dso')
-rw-r--r-- | src/lib/libcrypto/dso/dso_dl.c | 35 | ||||
-rw-r--r-- | src/lib/libcrypto/dso/dso_dlfcn.c | 36 | ||||
-rw-r--r-- | src/lib/libcrypto/dso/dso_err.c | 96 | ||||
-rw-r--r-- | src/lib/libcrypto/dso/dso_win32.c | 21 |
4 files changed, 138 insertions, 50 deletions
diff --git a/src/lib/libcrypto/dso/dso_dl.c b/src/lib/libcrypto/dso/dso_dl.c index 79d2cb4d8c..f7b4dfc0c3 100644 --- a/src/lib/libcrypto/dso/dso_dl.c +++ b/src/lib/libcrypto/dso/dso_dl.c | |||
@@ -126,7 +126,8 @@ static int dl_load(DSO *dso) | |||
126 | DSOerr(DSO_F_DL_LOAD,DSO_R_NO_FILENAME); | 126 | DSOerr(DSO_F_DL_LOAD,DSO_R_NO_FILENAME); |
127 | goto err; | 127 | goto err; |
128 | } | 128 | } |
129 | ptr = shl_load(filename, BIND_IMMEDIATE|DYNAMIC_PATH, 0L); | 129 | ptr = shl_load(filename, BIND_IMMEDIATE | |
130 | (dso->flags&DSO_FLAG_NO_NAME_TRANSLATION?0:DYNAMIC_PATH), 0L); | ||
130 | if(ptr == NULL) | 131 | if(ptr == NULL) |
131 | { | 132 | { |
132 | DSOerr(DSO_F_DL_LOAD,DSO_R_LOAD_FAILED); | 133 | DSOerr(DSO_F_DL_LOAD,DSO_R_LOAD_FAILED); |
@@ -281,4 +282,36 @@ static char *dl_name_converter(DSO *dso, const char *filename) | |||
281 | return(translated); | 282 | return(translated); |
282 | } | 283 | } |
283 | 284 | ||
285 | #ifdef OPENSSL_FIPS | ||
286 | static void dl_ref_point(){} | ||
287 | |||
288 | int DSO_pathbyaddr(void *addr,char *path,int sz) | ||
289 | { | ||
290 | struct shl_descriptor inf; | ||
291 | int i,len; | ||
292 | |||
293 | if (addr == NULL) | ||
294 | { | ||
295 | union { void(*f)(); void *p; } t = { dl_ref_point }; | ||
296 | addr = t.p; | ||
297 | } | ||
298 | |||
299 | for (i=-1;shl_get_r(i,&inf)==0;i++) | ||
300 | { | ||
301 | if (((size_t)addr >= inf.tstart && (size_t)addr < inf.tend) || | ||
302 | ((size_t)addr >= inf.dstart && (size_t)addr < inf.dend)) | ||
303 | { | ||
304 | len = (int)strlen(inf.filename); | ||
305 | if (sz <= 0) return len+1; | ||
306 | if (len >= sz) len=sz-1; | ||
307 | memcpy(path,inf.filename,len); | ||
308 | path[len++] = 0; | ||
309 | return len; | ||
310 | } | ||
311 | } | ||
312 | |||
313 | return -1; | ||
314 | } | ||
315 | #endif | ||
316 | |||
284 | #endif /* DSO_DL */ | 317 | #endif /* DSO_DL */ |
diff --git a/src/lib/libcrypto/dso/dso_dlfcn.c b/src/lib/libcrypto/dso/dso_dlfcn.c index 2e72969431..d48b4202f2 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) | |||
228 | static DSO_FUNC_TYPE dlfcn_bind_func(DSO *dso, const char *symname) | 232 | static 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 | ||
298 | static void dlfcn_ref_point(){} | ||
299 | |||
300 | int 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 */ |
diff --git a/src/lib/libcrypto/dso/dso_err.c b/src/lib/libcrypto/dso/dso_err.c index cf452de1aa..581677cc36 100644 --- a/src/lib/libcrypto/dso/dso_err.c +++ b/src/lib/libcrypto/dso/dso_err.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* crypto/dso/dso_err.c */ | 1 | /* crypto/dso/dso_err.c */ |
2 | /* ==================================================================== | 2 | /* ==================================================================== |
3 | * Copyright (c) 1999 The OpenSSL Project. All rights reserved. | 3 | * Copyright (c) 1999-2005 The OpenSSL Project. All rights reserved. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions | 6 | * modification, are permitted provided that the following conditions |
@@ -64,56 +64,60 @@ | |||
64 | 64 | ||
65 | /* BEGIN ERROR CODES */ | 65 | /* BEGIN ERROR CODES */ |
66 | #ifndef OPENSSL_NO_ERR | 66 | #ifndef OPENSSL_NO_ERR |
67 | |||
68 | #define ERR_FUNC(func) ERR_PACK(ERR_LIB_DSO,func,0) | ||
69 | #define ERR_REASON(reason) ERR_PACK(ERR_LIB_DSO,0,reason) | ||
70 | |||
67 | static ERR_STRING_DATA DSO_str_functs[]= | 71 | static ERR_STRING_DATA DSO_str_functs[]= |
68 | { | 72 | { |
69 | {ERR_PACK(0,DSO_F_DLFCN_BIND_FUNC,0), "DLFCN_BIND_FUNC"}, | 73 | {ERR_FUNC(DSO_F_DLFCN_BIND_FUNC), "DLFCN_BIND_FUNC"}, |
70 | {ERR_PACK(0,DSO_F_DLFCN_BIND_VAR,0), "DLFCN_BIND_VAR"}, | 74 | {ERR_FUNC(DSO_F_DLFCN_BIND_VAR), "DLFCN_BIND_VAR"}, |
71 | {ERR_PACK(0,DSO_F_DLFCN_LOAD,0), "DLFCN_LOAD"}, | 75 | {ERR_FUNC(DSO_F_DLFCN_LOAD), "DLFCN_LOAD"}, |
72 | {ERR_PACK(0,DSO_F_DLFCN_NAME_CONVERTER,0), "DLFCN_NAME_CONVERTER"}, | 76 | {ERR_FUNC(DSO_F_DLFCN_NAME_CONVERTER), "DLFCN_NAME_CONVERTER"}, |
73 | {ERR_PACK(0,DSO_F_DLFCN_UNLOAD,0), "DLFCN_UNLOAD"}, | 77 | {ERR_FUNC(DSO_F_DLFCN_UNLOAD), "DLFCN_UNLOAD"}, |
74 | {ERR_PACK(0,DSO_F_DL_BIND_FUNC,0), "DL_BIND_FUNC"}, | 78 | {ERR_FUNC(DSO_F_DL_BIND_FUNC), "DL_BIND_FUNC"}, |
75 | {ERR_PACK(0,DSO_F_DL_BIND_VAR,0), "DL_BIND_VAR"}, | 79 | {ERR_FUNC(DSO_F_DL_BIND_VAR), "DL_BIND_VAR"}, |
76 | {ERR_PACK(0,DSO_F_DL_LOAD,0), "DL_LOAD"}, | 80 | {ERR_FUNC(DSO_F_DL_LOAD), "DL_LOAD"}, |
77 | {ERR_PACK(0,DSO_F_DL_NAME_CONVERTER,0), "DL_NAME_CONVERTER"}, | 81 | {ERR_FUNC(DSO_F_DL_NAME_CONVERTER), "DL_NAME_CONVERTER"}, |
78 | {ERR_PACK(0,DSO_F_DL_UNLOAD,0), "DL_UNLOAD"}, | 82 | {ERR_FUNC(DSO_F_DL_UNLOAD), "DL_UNLOAD"}, |
79 | {ERR_PACK(0,DSO_F_DSO_BIND_FUNC,0), "DSO_bind_func"}, | 83 | {ERR_FUNC(DSO_F_DSO_BIND_FUNC), "DSO_bind_func"}, |
80 | {ERR_PACK(0,DSO_F_DSO_BIND_VAR,0), "DSO_bind_var"}, | 84 | {ERR_FUNC(DSO_F_DSO_BIND_VAR), "DSO_bind_var"}, |
81 | {ERR_PACK(0,DSO_F_DSO_CONVERT_FILENAME,0), "DSO_convert_filename"}, | 85 | {ERR_FUNC(DSO_F_DSO_CONVERT_FILENAME), "DSO_convert_filename"}, |
82 | {ERR_PACK(0,DSO_F_DSO_CTRL,0), "DSO_ctrl"}, | 86 | {ERR_FUNC(DSO_F_DSO_CTRL), "DSO_ctrl"}, |
83 | {ERR_PACK(0,DSO_F_DSO_FREE,0), "DSO_free"}, | 87 | {ERR_FUNC(DSO_F_DSO_FREE), "DSO_free"}, |
84 | {ERR_PACK(0,DSO_F_DSO_GET_FILENAME,0), "DSO_get_filename"}, | 88 | {ERR_FUNC(DSO_F_DSO_GET_FILENAME), "DSO_get_filename"}, |
85 | {ERR_PACK(0,DSO_F_DSO_GET_LOADED_FILENAME,0), "DSO_get_loaded_filename"}, | 89 | {ERR_FUNC(DSO_F_DSO_GET_LOADED_FILENAME), "DSO_get_loaded_filename"}, |
86 | {ERR_PACK(0,DSO_F_DSO_LOAD,0), "DSO_load"}, | 90 | {ERR_FUNC(DSO_F_DSO_LOAD), "DSO_load"}, |
87 | {ERR_PACK(0,DSO_F_DSO_NEW_METHOD,0), "DSO_new_method"}, | 91 | {ERR_FUNC(DSO_F_DSO_NEW_METHOD), "DSO_new_method"}, |
88 | {ERR_PACK(0,DSO_F_DSO_SET_FILENAME,0), "DSO_set_filename"}, | 92 | {ERR_FUNC(DSO_F_DSO_SET_FILENAME), "DSO_set_filename"}, |
89 | {ERR_PACK(0,DSO_F_DSO_SET_NAME_CONVERTER,0), "DSO_set_name_converter"}, | 93 | {ERR_FUNC(DSO_F_DSO_SET_NAME_CONVERTER), "DSO_set_name_converter"}, |
90 | {ERR_PACK(0,DSO_F_DSO_UP_REF,0), "DSO_up_ref"}, | 94 | {ERR_FUNC(DSO_F_DSO_UP_REF), "DSO_up_ref"}, |
91 | {ERR_PACK(0,DSO_F_VMS_BIND_VAR,0), "VMS_BIND_VAR"}, | 95 | {ERR_FUNC(DSO_F_VMS_BIND_VAR), "VMS_BIND_VAR"}, |
92 | {ERR_PACK(0,DSO_F_VMS_LOAD,0), "VMS_LOAD"}, | 96 | {ERR_FUNC(DSO_F_VMS_LOAD), "VMS_LOAD"}, |
93 | {ERR_PACK(0,DSO_F_VMS_UNLOAD,0), "VMS_UNLOAD"}, | 97 | {ERR_FUNC(DSO_F_VMS_UNLOAD), "VMS_UNLOAD"}, |
94 | {ERR_PACK(0,DSO_F_WIN32_BIND_FUNC,0), "WIN32_BIND_FUNC"}, | 98 | {ERR_FUNC(DSO_F_WIN32_BIND_FUNC), "WIN32_BIND_FUNC"}, |
95 | {ERR_PACK(0,DSO_F_WIN32_BIND_VAR,0), "WIN32_BIND_VAR"}, | 99 | {ERR_FUNC(DSO_F_WIN32_BIND_VAR), "WIN32_BIND_VAR"}, |
96 | {ERR_PACK(0,DSO_F_WIN32_LOAD,0), "WIN32_LOAD"}, | 100 | {ERR_FUNC(DSO_F_WIN32_LOAD), "WIN32_LOAD"}, |
97 | {ERR_PACK(0,DSO_F_WIN32_NAME_CONVERTER,0), "WIN32_NAME_CONVERTER"}, | 101 | {ERR_FUNC(DSO_F_WIN32_NAME_CONVERTER), "WIN32_NAME_CONVERTER"}, |
98 | {ERR_PACK(0,DSO_F_WIN32_UNLOAD,0), "WIN32_UNLOAD"}, | 102 | {ERR_FUNC(DSO_F_WIN32_UNLOAD), "WIN32_UNLOAD"}, |
99 | {0,NULL} | 103 | {0,NULL} |
100 | }; | 104 | }; |
101 | 105 | ||
102 | static ERR_STRING_DATA DSO_str_reasons[]= | 106 | static ERR_STRING_DATA DSO_str_reasons[]= |
103 | { | 107 | { |
104 | {DSO_R_CTRL_FAILED ,"control command failed"}, | 108 | {ERR_REASON(DSO_R_CTRL_FAILED) ,"control command failed"}, |
105 | {DSO_R_DSO_ALREADY_LOADED ,"dso already loaded"}, | 109 | {ERR_REASON(DSO_R_DSO_ALREADY_LOADED) ,"dso already loaded"}, |
106 | {DSO_R_FILENAME_TOO_BIG ,"filename too big"}, | 110 | {ERR_REASON(DSO_R_FILENAME_TOO_BIG) ,"filename too big"}, |
107 | {DSO_R_FINISH_FAILED ,"cleanup method function failed"}, | 111 | {ERR_REASON(DSO_R_FINISH_FAILED) ,"cleanup method function failed"}, |
108 | {DSO_R_LOAD_FAILED ,"could not load the shared library"}, | 112 | {ERR_REASON(DSO_R_LOAD_FAILED) ,"could not load the shared library"}, |
109 | {DSO_R_NAME_TRANSLATION_FAILED ,"name translation failed"}, | 113 | {ERR_REASON(DSO_R_NAME_TRANSLATION_FAILED),"name translation failed"}, |
110 | {DSO_R_NO_FILENAME ,"no filename"}, | 114 | {ERR_REASON(DSO_R_NO_FILENAME) ,"no filename"}, |
111 | {DSO_R_NULL_HANDLE ,"a null shared library handle was used"}, | 115 | {ERR_REASON(DSO_R_NULL_HANDLE) ,"a null shared library handle was used"}, |
112 | {DSO_R_SET_FILENAME_FAILED ,"set filename failed"}, | 116 | {ERR_REASON(DSO_R_SET_FILENAME_FAILED) ,"set filename failed"}, |
113 | {DSO_R_STACK_ERROR ,"the meth_data stack is corrupt"}, | 117 | {ERR_REASON(DSO_R_STACK_ERROR) ,"the meth_data stack is corrupt"}, |
114 | {DSO_R_SYM_FAILURE ,"could not bind to the requested symbol name"}, | 118 | {ERR_REASON(DSO_R_SYM_FAILURE) ,"could not bind to the requested symbol name"}, |
115 | {DSO_R_UNLOAD_FAILED ,"could not unload the shared library"}, | 119 | {ERR_REASON(DSO_R_UNLOAD_FAILED) ,"could not unload the shared library"}, |
116 | {DSO_R_UNSUPPORTED ,"functionality not supported"}, | 120 | {ERR_REASON(DSO_R_UNSUPPORTED) ,"functionality not supported"}, |
117 | {0,NULL} | 121 | {0,NULL} |
118 | }; | 122 | }; |
119 | 123 | ||
@@ -127,8 +131,8 @@ void ERR_load_DSO_strings(void) | |||
127 | { | 131 | { |
128 | init=0; | 132 | init=0; |
129 | #ifndef OPENSSL_NO_ERR | 133 | #ifndef OPENSSL_NO_ERR |
130 | ERR_load_strings(ERR_LIB_DSO,DSO_str_functs); | 134 | ERR_load_strings(0,DSO_str_functs); |
131 | ERR_load_strings(ERR_LIB_DSO,DSO_str_reasons); | 135 | ERR_load_strings(0,DSO_str_reasons); |
132 | #endif | 136 | #endif |
133 | 137 | ||
134 | } | 138 | } |
diff --git a/src/lib/libcrypto/dso/dso_win32.c b/src/lib/libcrypto/dso/dso_win32.c index 3fa90eb27c..cc4ac68696 100644 --- a/src/lib/libcrypto/dso/dso_win32.c +++ b/src/lib/libcrypto/dso/dso_win32.c | |||
@@ -68,6 +68,25 @@ DSO_METHOD *DSO_METHOD_win32(void) | |||
68 | } | 68 | } |
69 | #else | 69 | #else |
70 | 70 | ||
71 | #ifdef _WIN32_WCE | ||
72 | # if _WIN32_WCE < 300 | ||
73 | static FARPROC GetProcAddressA(HMODULE hModule,LPCSTR lpProcName) | ||
74 | { | ||
75 | WCHAR lpProcNameW[64]; | ||
76 | int i; | ||
77 | |||
78 | for (i=0;lpProcName[i] && i<64;i++) | ||
79 | lpProcNameW[i] = (WCHAR)lpProcName[i]; | ||
80 | if (i==64) return NULL; | ||
81 | lpProcNameW[i] = 0; | ||
82 | |||
83 | return GetProcAddressW(hModule,lpProcNameW); | ||
84 | } | ||
85 | # endif | ||
86 | # undef GetProcAddress | ||
87 | # define GetProcAddress GetProcAddressA | ||
88 | #endif | ||
89 | |||
71 | /* Part of the hack in "win32_load" ... */ | 90 | /* Part of the hack in "win32_load" ... */ |
72 | #define DSO_MAX_TRANSLATED_SIZE 256 | 91 | #define DSO_MAX_TRANSLATED_SIZE 256 |
73 | 92 | ||
@@ -122,7 +141,7 @@ static int win32_load(DSO *dso) | |||
122 | DSOerr(DSO_F_WIN32_LOAD,DSO_R_NO_FILENAME); | 141 | DSOerr(DSO_F_WIN32_LOAD,DSO_R_NO_FILENAME); |
123 | goto err; | 142 | goto err; |
124 | } | 143 | } |
125 | h = LoadLibrary(filename); | 144 | h = LoadLibraryA(filename); |
126 | if(h == NULL) | 145 | if(h == NULL) |
127 | { | 146 | { |
128 | DSOerr(DSO_F_WIN32_LOAD,DSO_R_LOAD_FAILED); | 147 | DSOerr(DSO_F_WIN32_LOAD,DSO_R_LOAD_FAILED); |