diff options
| author | djm <> | 2010-10-01 22:59:01 +0000 |
|---|---|---|
| committer | djm <> | 2010-10-01 22:59:01 +0000 |
| commit | 8922d4bc4a8b8893d72a48deb2cdf58215f98505 (patch) | |
| tree | 939b752540947d33507b3acc48d76a8bfb7c3dc3 /src/lib/libcrypto/dso | |
| parent | 76262f7bf9262f965142b1b2b2105cb279c5c696 (diff) | |
| download | openbsd-8922d4bc4a8b8893d72a48deb2cdf58215f98505.tar.gz openbsd-8922d4bc4a8b8893d72a48deb2cdf58215f98505.tar.bz2 openbsd-8922d4bc4a8b8893d72a48deb2cdf58215f98505.zip | |
resolve conflicts, fix local changes
Diffstat (limited to 'src/lib/libcrypto/dso')
| -rw-r--r-- | src/lib/libcrypto/dso/Makefile.ssl | 142 | ||||
| -rw-r--r-- | src/lib/libcrypto/dso/dso.h | 43 | ||||
| -rw-r--r-- | src/lib/libcrypto/dso/dso_dl.c | 56 | ||||
| -rw-r--r-- | src/lib/libcrypto/dso/dso_dlfcn.c | 157 | ||||
| -rw-r--r-- | src/lib/libcrypto/dso/dso_err.c | 14 | ||||
| -rw-r--r-- | src/lib/libcrypto/dso/dso_lib.c | 35 | ||||
| -rw-r--r-- | src/lib/libcrypto/dso/dso_null.c | 4 | ||||
| -rw-r--r-- | src/lib/libcrypto/dso/dso_openssl.c | 2 | ||||
| -rw-r--r-- | src/lib/libcrypto/dso/dso_vms.c | 12 | ||||
| -rw-r--r-- | src/lib/libcrypto/dso/dso_win32.c | 228 |
10 files changed, 482 insertions, 211 deletions
diff --git a/src/lib/libcrypto/dso/Makefile.ssl b/src/lib/libcrypto/dso/Makefile.ssl deleted file mode 100644 index c0449d184e..0000000000 --- a/src/lib/libcrypto/dso/Makefile.ssl +++ /dev/null | |||
| @@ -1,142 +0,0 @@ | |||
| 1 | # | ||
| 2 | # SSLeay/crypto/dso/Makefile | ||
| 3 | # | ||
| 4 | |||
| 5 | DIR= dso | ||
| 6 | TOP= ../.. | ||
| 7 | CC= cc | ||
| 8 | INCLUDES= -I.. -I$(TOP) -I../../include | ||
| 9 | CFLAG=-g | ||
| 10 | INSTALL_PREFIX= | ||
| 11 | OPENSSLDIR= /usr/local/ssl | ||
| 12 | INSTALLTOP=/usr/local/ssl | ||
| 13 | MAKE= make -f Makefile.ssl | ||
| 14 | MAKEDEPPROG= makedepend | ||
| 15 | MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) | ||
| 16 | MAKEFILE= Makefile.ssl | ||
| 17 | AR= ar r | ||
| 18 | |||
| 19 | CFLAGS= $(INCLUDES) $(CFLAG) | ||
| 20 | |||
| 21 | GENERAL=Makefile | ||
| 22 | TEST= | ||
| 23 | APPS= | ||
| 24 | |||
| 25 | LIB=$(TOP)/libcrypto.a | ||
| 26 | LIBSRC= dso_dl.c dso_dlfcn.c dso_err.c dso_lib.c dso_null.c \ | ||
| 27 | dso_openssl.c dso_win32.c dso_vms.c | ||
| 28 | LIBOBJ= dso_dl.o dso_dlfcn.o dso_err.o dso_lib.o dso_null.o \ | ||
| 29 | dso_openssl.o dso_win32.o dso_vms.o | ||
| 30 | |||
| 31 | SRC= $(LIBSRC) | ||
| 32 | |||
| 33 | EXHEADER= dso.h | ||
| 34 | HEADER= $(EXHEADER) | ||
| 35 | |||
| 36 | ALL= $(GENERAL) $(SRC) $(HEADER) | ||
| 37 | |||
| 38 | top: | ||
| 39 | (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) | ||
| 40 | |||
| 41 | all: lib | ||
| 42 | |||
| 43 | lib: $(LIBOBJ) | ||
| 44 | $(AR) $(LIB) $(LIBOBJ) | ||
| 45 | $(RANLIB) $(LIB) || echo Never mind. | ||
| 46 | @touch lib | ||
| 47 | |||
| 48 | files: | ||
| 49 | $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO | ||
| 50 | |||
| 51 | links: | ||
| 52 | @sh $(TOP)/util/point.sh Makefile.ssl Makefile | ||
| 53 | @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) | ||
| 54 | @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) | ||
| 55 | @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) | ||
| 56 | |||
| 57 | install: | ||
| 58 | @for i in $(EXHEADER) ; \ | ||
| 59 | do \ | ||
| 60 | (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \ | ||
| 61 | chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \ | ||
| 62 | done; | ||
| 63 | |||
| 64 | tags: | ||
| 65 | ctags $(SRC) | ||
| 66 | |||
| 67 | tests: | ||
| 68 | |||
| 69 | lint: | ||
| 70 | lint -DLINT $(INCLUDES) $(SRC)>fluff | ||
| 71 | |||
| 72 | depend: | ||
| 73 | $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC) | ||
| 74 | |||
| 75 | dclean: | ||
| 76 | $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new | ||
| 77 | mv -f Makefile.new $(MAKEFILE) | ||
| 78 | |||
| 79 | clean: | ||
| 80 | rm -f *.o */*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff | ||
| 81 | |||
| 82 | # DO NOT DELETE THIS LINE -- make depend depends on it. | ||
| 83 | |||
| 84 | dso_dl.o: ../../e_os.h ../../include/openssl/bio.h | ||
| 85 | dso_dl.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | ||
| 86 | dso_dl.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h | ||
| 87 | dso_dl.o: ../../include/openssl/err.h ../../include/openssl/lhash.h | ||
| 88 | dso_dl.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
| 89 | dso_dl.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | ||
| 90 | dso_dl.o: ../../include/openssl/symhacks.h ../cryptlib.h dso_dl.c | ||
| 91 | dso_dlfcn.o: ../../e_os.h ../../include/openssl/bio.h | ||
| 92 | dso_dlfcn.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | ||
| 93 | dso_dlfcn.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h | ||
| 94 | dso_dlfcn.o: ../../include/openssl/err.h ../../include/openssl/lhash.h | ||
| 95 | dso_dlfcn.o: ../../include/openssl/opensslconf.h | ||
| 96 | dso_dlfcn.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h | ||
| 97 | dso_dlfcn.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
| 98 | dso_dlfcn.o: ../cryptlib.h dso_dlfcn.c | ||
| 99 | dso_err.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h | ||
| 100 | dso_err.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h | ||
| 101 | dso_err.o: ../../include/openssl/err.h ../../include/openssl/lhash.h | ||
| 102 | dso_err.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
| 103 | dso_err.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | ||
| 104 | dso_err.o: ../../include/openssl/symhacks.h dso_err.c | ||
| 105 | dso_lib.o: ../../e_os.h ../../include/openssl/bio.h | ||
| 106 | dso_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | ||
| 107 | dso_lib.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h | ||
| 108 | dso_lib.o: ../../include/openssl/err.h ../../include/openssl/lhash.h | ||
| 109 | dso_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
| 110 | dso_lib.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | ||
| 111 | dso_lib.o: ../../include/openssl/symhacks.h ../cryptlib.h dso_lib.c | ||
| 112 | dso_null.o: ../../e_os.h ../../include/openssl/bio.h | ||
| 113 | dso_null.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | ||
| 114 | dso_null.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h | ||
| 115 | dso_null.o: ../../include/openssl/err.h ../../include/openssl/lhash.h | ||
| 116 | dso_null.o: ../../include/openssl/opensslconf.h | ||
| 117 | dso_null.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h | ||
| 118 | dso_null.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
| 119 | dso_null.o: ../cryptlib.h dso_null.c | ||
| 120 | dso_openssl.o: ../../e_os.h ../../include/openssl/bio.h | ||
| 121 | dso_openssl.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | ||
| 122 | dso_openssl.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h | ||
| 123 | dso_openssl.o: ../../include/openssl/err.h ../../include/openssl/lhash.h | ||
| 124 | dso_openssl.o: ../../include/openssl/opensslconf.h | ||
| 125 | dso_openssl.o: ../../include/openssl/opensslv.h | ||
| 126 | dso_openssl.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | ||
| 127 | dso_openssl.o: ../../include/openssl/symhacks.h ../cryptlib.h dso_openssl.c | ||
| 128 | dso_vms.o: ../../e_os.h ../../include/openssl/bio.h | ||
| 129 | dso_vms.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | ||
| 130 | dso_vms.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h | ||
| 131 | dso_vms.o: ../../include/openssl/err.h ../../include/openssl/lhash.h | ||
| 132 | dso_vms.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
| 133 | dso_vms.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h | ||
| 134 | dso_vms.o: ../../include/openssl/symhacks.h ../cryptlib.h dso_vms.c | ||
| 135 | dso_win32.o: ../../e_os.h ../../include/openssl/bio.h | ||
| 136 | dso_win32.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h | ||
| 137 | dso_win32.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h | ||
| 138 | dso_win32.o: ../../include/openssl/err.h ../../include/openssl/lhash.h | ||
| 139 | dso_win32.o: ../../include/openssl/opensslconf.h | ||
| 140 | dso_win32.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h | ||
| 141 | dso_win32.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h | ||
| 142 | dso_win32.o: ../cryptlib.h dso_win32.c | ||
diff --git a/src/lib/libcrypto/dso/dso.h b/src/lib/libcrypto/dso/dso.h index 3e51913a72..839f2e0617 100644 --- a/src/lib/libcrypto/dso/dso.h +++ b/src/lib/libcrypto/dso/dso.h | |||
| @@ -170,6 +170,11 @@ typedef struct dso_meth_st | |||
| 170 | /* [De]Initialisation handlers. */ | 170 | /* [De]Initialisation handlers. */ |
| 171 | int (*init)(DSO *dso); | 171 | int (*init)(DSO *dso); |
| 172 | int (*finish)(DSO *dso); | 172 | int (*finish)(DSO *dso); |
| 173 | |||
| 174 | /* Return pathname of the module containing location */ | ||
| 175 | int (*pathbyaddr)(void *addr,char *path,int sz); | ||
| 176 | /* Perform global symbol lookup, i.e. among *all* modules */ | ||
| 177 | void *(*globallookup)(const char *symname); | ||
| 173 | } DSO_METHOD; | 178 | } DSO_METHOD; |
| 174 | 179 | ||
| 175 | /**********************************************************************/ | 180 | /**********************************************************************/ |
| @@ -183,7 +188,7 @@ struct dso_st | |||
| 183 | * for use in the dso_bind handler. All in all, let each | 188 | * for use in the dso_bind handler. All in all, let each |
| 184 | * method control its own destiny. "Handles" and such go in | 189 | * method control its own destiny. "Handles" and such go in |
| 185 | * a STACK. */ | 190 | * a STACK. */ |
| 186 | STACK *meth_data; | 191 | STACK_OF(void) *meth_data; |
| 187 | int references; | 192 | int references; |
| 188 | int flags; | 193 | int flags; |
| 189 | /* For use by applications etc ... use this for your bits'n'pieces, | 194 | /* For use by applications etc ... use this for your bits'n'pieces, |
| @@ -296,6 +301,30 @@ DSO_METHOD *DSO_METHOD_win32(void); | |||
| 296 | /* If VMS is defined, use shared images. If not, return NULL. */ | 301 | /* If VMS is defined, use shared images. If not, return NULL. */ |
| 297 | DSO_METHOD *DSO_METHOD_vms(void); | 302 | DSO_METHOD *DSO_METHOD_vms(void); |
| 298 | 303 | ||
| 304 | /* This function writes null-terminated pathname of DSO module | ||
| 305 | * containing 'addr' into 'sz' large caller-provided 'path' and | ||
| 306 | * returns the number of characters [including trailing zero] | ||
| 307 | * written to it. If 'sz' is 0 or negative, 'path' is ignored and | ||
| 308 | * required amount of charachers [including trailing zero] to | ||
| 309 | * accomodate pathname is returned. If 'addr' is NULL, then | ||
| 310 | * pathname of cryptolib itself is returned. Negative or zero | ||
| 311 | * return value denotes error. | ||
| 312 | */ | ||
| 313 | int DSO_pathbyaddr(void *addr,char *path,int sz); | ||
| 314 | |||
| 315 | /* This function should be used with caution! It looks up symbols in | ||
| 316 | * *all* loaded modules and if module gets unloaded by somebody else | ||
| 317 | * attempt to dereference the pointer is doomed to have fatal | ||
| 318 | * consequences. Primary usage for this function is to probe *core* | ||
| 319 | * system functionality, e.g. check if getnameinfo(3) is available | ||
| 320 | * at run-time without bothering about OS-specific details such as | ||
| 321 | * libc.so.versioning or where does it actually reside: in libc | ||
| 322 | * itself or libsocket. */ | ||
| 323 | void *DSO_global_lookup(const char *name); | ||
| 324 | |||
| 325 | /* If BeOS is defined, use shared images. If not, return NULL. */ | ||
| 326 | DSO_METHOD *DSO_METHOD_beos(void); | ||
| 327 | |||
| 299 | /* BEGIN ERROR CODES */ | 328 | /* BEGIN ERROR CODES */ |
| 300 | /* The following lines are auto generated by the script mkerr.pl. Any changes | 329 | /* The following lines are auto generated by the script mkerr.pl. Any changes |
| 301 | * made after this point may be overwritten when the script is next run. | 330 | * made after this point may be overwritten when the script is next run. |
| @@ -305,6 +334,11 @@ void ERR_load_DSO_strings(void); | |||
| 305 | /* Error codes for the DSO functions. */ | 334 | /* Error codes for the DSO functions. */ |
| 306 | 335 | ||
| 307 | /* Function codes. */ | 336 | /* Function codes. */ |
| 337 | #define DSO_F_BEOS_BIND_FUNC 144 | ||
| 338 | #define DSO_F_BEOS_BIND_VAR 145 | ||
| 339 | #define DSO_F_BEOS_LOAD 146 | ||
| 340 | #define DSO_F_BEOS_NAME_CONVERTER 147 | ||
| 341 | #define DSO_F_BEOS_UNLOAD 148 | ||
| 308 | #define DSO_F_DLFCN_BIND_FUNC 100 | 342 | #define DSO_F_DLFCN_BIND_FUNC 100 |
| 309 | #define DSO_F_DLFCN_BIND_VAR 101 | 343 | #define DSO_F_DLFCN_BIND_VAR 101 |
| 310 | #define DSO_F_DLFCN_LOAD 102 | 344 | #define DSO_F_DLFCN_LOAD 102 |
| @@ -324,22 +358,29 @@ void ERR_load_DSO_strings(void); | |||
| 324 | #define DSO_F_DSO_FREE 111 | 358 | #define DSO_F_DSO_FREE 111 |
| 325 | #define DSO_F_DSO_GET_FILENAME 127 | 359 | #define DSO_F_DSO_GET_FILENAME 127 |
| 326 | #define DSO_F_DSO_GET_LOADED_FILENAME 128 | 360 | #define DSO_F_DSO_GET_LOADED_FILENAME 128 |
| 361 | #define DSO_F_DSO_GLOBAL_LOOKUP 139 | ||
| 327 | #define DSO_F_DSO_LOAD 112 | 362 | #define DSO_F_DSO_LOAD 112 |
| 328 | #define DSO_F_DSO_MERGE 132 | 363 | #define DSO_F_DSO_MERGE 132 |
| 329 | #define DSO_F_DSO_NEW_METHOD 113 | 364 | #define DSO_F_DSO_NEW_METHOD 113 |
| 365 | #define DSO_F_DSO_PATHBYADDR 140 | ||
| 330 | #define DSO_F_DSO_SET_FILENAME 129 | 366 | #define DSO_F_DSO_SET_FILENAME 129 |
| 331 | #define DSO_F_DSO_SET_NAME_CONVERTER 122 | 367 | #define DSO_F_DSO_SET_NAME_CONVERTER 122 |
| 332 | #define DSO_F_DSO_UP_REF 114 | 368 | #define DSO_F_DSO_UP_REF 114 |
| 369 | #define DSO_F_GLOBAL_LOOKUP_FUNC 138 | ||
| 370 | #define DSO_F_PATHBYADDR 137 | ||
| 333 | #define DSO_F_VMS_BIND_SYM 115 | 371 | #define DSO_F_VMS_BIND_SYM 115 |
| 334 | #define DSO_F_VMS_LOAD 116 | 372 | #define DSO_F_VMS_LOAD 116 |
| 335 | #define DSO_F_VMS_MERGER 133 | 373 | #define DSO_F_VMS_MERGER 133 |
| 336 | #define DSO_F_VMS_UNLOAD 117 | 374 | #define DSO_F_VMS_UNLOAD 117 |
| 337 | #define DSO_F_WIN32_BIND_FUNC 118 | 375 | #define DSO_F_WIN32_BIND_FUNC 118 |
| 338 | #define DSO_F_WIN32_BIND_VAR 119 | 376 | #define DSO_F_WIN32_BIND_VAR 119 |
| 377 | #define DSO_F_WIN32_GLOBALLOOKUP 142 | ||
| 378 | #define DSO_F_WIN32_GLOBALLOOKUP_FUNC 143 | ||
| 339 | #define DSO_F_WIN32_JOINER 135 | 379 | #define DSO_F_WIN32_JOINER 135 |
| 340 | #define DSO_F_WIN32_LOAD 120 | 380 | #define DSO_F_WIN32_LOAD 120 |
| 341 | #define DSO_F_WIN32_MERGER 134 | 381 | #define DSO_F_WIN32_MERGER 134 |
| 342 | #define DSO_F_WIN32_NAME_CONVERTER 125 | 382 | #define DSO_F_WIN32_NAME_CONVERTER 125 |
| 383 | #define DSO_F_WIN32_PATHBYADDR 141 | ||
| 343 | #define DSO_F_WIN32_SPLITTER 136 | 384 | #define DSO_F_WIN32_SPLITTER 136 |
| 344 | #define DSO_F_WIN32_UNLOAD 121 | 385 | #define DSO_F_WIN32_UNLOAD 121 |
| 345 | 386 | ||
diff --git a/src/lib/libcrypto/dso/dso_dl.c b/src/lib/libcrypto/dso/dso_dl.c index 417abb6ea9..c3b4f6cf45 100644 --- a/src/lib/libcrypto/dso/dso_dl.c +++ b/src/lib/libcrypto/dso/dso_dl.c | |||
| @@ -85,6 +85,8 @@ static int dl_ctrl(DSO *dso, int cmd, long larg, void *parg); | |||
| 85 | #endif | 85 | #endif |
| 86 | static char *dl_name_converter(DSO *dso, const char *filename); | 86 | static char *dl_name_converter(DSO *dso, const char *filename); |
| 87 | static char *dl_merger(DSO *dso, const char *filespec1, const char *filespec2); | 87 | static char *dl_merger(DSO *dso, const char *filespec1, const char *filespec2); |
| 88 | static int dl_pathbyaddr(void *addr,char *path,int sz); | ||
| 89 | static void *dl_globallookup(const char *name); | ||
| 88 | 90 | ||
| 89 | static DSO_METHOD dso_meth_dl = { | 91 | static DSO_METHOD dso_meth_dl = { |
| 90 | "OpenSSL 'dl' shared library method", | 92 | "OpenSSL 'dl' shared library method", |
| @@ -101,7 +103,9 @@ static DSO_METHOD dso_meth_dl = { | |||
| 101 | dl_name_converter, | 103 | dl_name_converter, |
| 102 | dl_merger, | 104 | dl_merger, |
| 103 | NULL, /* init */ | 105 | NULL, /* init */ |
| 104 | NULL /* finish */ | 106 | NULL, /* finish */ |
| 107 | dl_pathbyaddr, | ||
| 108 | dl_globallookup | ||
| 105 | }; | 109 | }; |
| 106 | 110 | ||
| 107 | DSO_METHOD *DSO_METHOD_dl(void) | 111 | DSO_METHOD *DSO_METHOD_dl(void) |
| @@ -255,18 +259,20 @@ static char *dl_merger(DSO *dso, const char *filespec1, const char *filespec2) | |||
| 255 | same goes if the second file specification is missing. */ | 259 | same goes if the second file specification is missing. */ |
| 256 | if (!filespec2 || filespec1[0] == '/') | 260 | if (!filespec2 || filespec1[0] == '/') |
| 257 | { | 261 | { |
| 258 | merged = OPENSSL_malloc(strlen(filespec1) + 1); | 262 | size_t len = strlen(filespec1) + 1; |
| 263 | merged = OPENSSL_malloc(len); | ||
| 259 | if(!merged) | 264 | if(!merged) |
| 260 | { | 265 | { |
| 261 | DSOerr(DSO_F_DL_MERGER, | 266 | DSOerr(DSO_F_DL_MERGER, |
| 262 | ERR_R_MALLOC_FAILURE); | 267 | ERR_R_MALLOC_FAILURE); |
| 263 | return(NULL); | 268 | return(NULL); |
| 264 | } | 269 | } |
| 265 | strcpy(merged, filespec1); | 270 | memcpy(merged, filespec1, len); |
| 266 | } | 271 | } |
| 267 | /* If the first file specification is missing, the second one rules. */ | 272 | /* If the first file specification is missing, the second one rules. */ |
| 268 | else if (!filespec1) | 273 | else if (!filespec1) |
| 269 | { | 274 | { |
| 275 | size_t len = strlen(filespec2) + 1; | ||
| 270 | merged = OPENSSL_malloc(strlen(filespec2) + 1); | 276 | merged = OPENSSL_malloc(strlen(filespec2) + 1); |
| 271 | if(!merged) | 277 | if(!merged) |
| 272 | { | 278 | { |
| @@ -274,7 +280,7 @@ static char *dl_merger(DSO *dso, const char *filespec1, const char *filespec2) | |||
| 274 | ERR_R_MALLOC_FAILURE); | 280 | ERR_R_MALLOC_FAILURE); |
| 275 | return(NULL); | 281 | return(NULL); |
| 276 | } | 282 | } |
| 277 | strcpy(merged, filespec2); | 283 | memcpy(merged, filespec2, len); |
| 278 | } | 284 | } |
| 279 | else | 285 | else |
| 280 | /* This part isn't as trivial as it looks. It assumes that | 286 | /* This part isn't as trivial as it looks. It assumes that |
| @@ -283,7 +289,7 @@ static char *dl_merger(DSO *dso, const char *filespec1, const char *filespec2) | |||
| 283 | the concatenation of filespec2 followed by a slash followed | 289 | the concatenation of filespec2 followed by a slash followed |
| 284 | by filespec1. */ | 290 | by filespec1. */ |
| 285 | { | 291 | { |
| 286 | int spec2len, len; | 292 | size_t spec2len, len; |
| 287 | 293 | ||
| 288 | spec2len = (filespec2 ? strlen(filespec2) : 0); | 294 | spec2len = (filespec2 ? strlen(filespec2) : 0); |
| 289 | len = spec2len + (filespec1 ? strlen(filespec1) : 0); | 295 | len = spec2len + (filespec1 ? strlen(filespec1) : 0); |
| @@ -300,9 +306,9 @@ static char *dl_merger(DSO *dso, const char *filespec1, const char *filespec2) | |||
| 300 | ERR_R_MALLOC_FAILURE); | 306 | ERR_R_MALLOC_FAILURE); |
| 301 | return(NULL); | 307 | return(NULL); |
| 302 | } | 308 | } |
| 303 | strcpy(merged, filespec2); | 309 | strlcpy(merged, filespec2, len + 2); |
| 304 | merged[spec2len] = '/'; | 310 | merged[spec2len] = '/'; |
| 305 | strcpy(&merged[spec2len + 1], filespec1); | 311 | strlcpy(&merged[spec2len + 1], filespec1, 1 + len - spec2len); |
| 306 | } | 312 | } |
| 307 | return(merged); | 313 | return(merged); |
| 308 | } | 314 | } |
| @@ -350,4 +356,40 @@ static char *dl_name_converter(DSO *dso, const char *filename) | |||
| 350 | return(translated); | 356 | return(translated); |
| 351 | } | 357 | } |
| 352 | 358 | ||
| 359 | static int dl_pathbyaddr(void *addr,char *path,int sz) | ||
| 360 | { | ||
| 361 | struct shl_descriptor inf; | ||
| 362 | int i,len; | ||
| 363 | |||
| 364 | if (addr == NULL) | ||
| 365 | { | ||
| 366 | union { int(*f)(void*,char*,int); void *p; } t = | ||
| 367 | { dl_pathbyaddr }; | ||
| 368 | addr = t.p; | ||
| 369 | } | ||
| 370 | |||
| 371 | for (i=-1;shl_get_r(i,&inf)==0;i++) | ||
| 372 | { | ||
| 373 | if (((size_t)addr >= inf.tstart && (size_t)addr < inf.tend) || | ||
| 374 | ((size_t)addr >= inf.dstart && (size_t)addr < inf.dend)) | ||
| 375 | { | ||
| 376 | len = (int)strlen(inf.filename); | ||
| 377 | if (sz <= 0) return len+1; | ||
| 378 | if (len >= sz) len=sz-1; | ||
| 379 | memcpy(path,inf.filename,len); | ||
| 380 | path[len++] = 0; | ||
| 381 | return len; | ||
| 382 | } | ||
| 383 | } | ||
| 384 | |||
| 385 | return -1; | ||
| 386 | } | ||
| 387 | |||
| 388 | static void *dl_globallookup(const char *name) | ||
| 389 | { | ||
| 390 | void *ret; | ||
| 391 | shl_t h = NULL; | ||
| 392 | |||
| 393 | return shl_findsym(&h,name,TYPE_UNDEFINED,&ret) ? NULL : ret; | ||
| 394 | } | ||
| 353 | #endif /* DSO_DL */ | 395 | #endif /* DSO_DL */ |
diff --git a/src/lib/libcrypto/dso/dso_dlfcn.c b/src/lib/libcrypto/dso/dso_dlfcn.c index 656cd496f8..5dceaf7b00 100644 --- a/src/lib/libcrypto/dso/dso_dlfcn.c +++ b/src/lib/libcrypto/dso/dso_dlfcn.c | |||
| @@ -56,6 +56,16 @@ | |||
| 56 | * | 56 | * |
| 57 | */ | 57 | */ |
| 58 | 58 | ||
| 59 | /* We need to do this early, because stdio.h includes the header files | ||
| 60 | that handle _GNU_SOURCE and other similar macros. Defining it later | ||
| 61 | is simply too late, because those headers are protected from re- | ||
| 62 | inclusion. */ | ||
| 63 | #ifdef __linux | ||
| 64 | # ifndef _GNU_SOURCE | ||
| 65 | # define _GNU_SOURCE /* make sure dladdr is declared */ | ||
| 66 | # endif | ||
| 67 | #endif | ||
| 68 | |||
| 59 | #include <stdio.h> | 69 | #include <stdio.h> |
| 60 | #include "cryptlib.h" | 70 | #include "cryptlib.h" |
| 61 | #include <openssl/dso.h> | 71 | #include <openssl/dso.h> |
| @@ -68,7 +78,16 @@ DSO_METHOD *DSO_METHOD_dlfcn(void) | |||
| 68 | #else | 78 | #else |
| 69 | 79 | ||
| 70 | #ifdef HAVE_DLFCN_H | 80 | #ifdef HAVE_DLFCN_H |
| 71 | #include <dlfcn.h> | 81 | # ifdef __osf__ |
| 82 | # define __EXTENSIONS__ | ||
| 83 | # endif | ||
| 84 | # include <dlfcn.h> | ||
| 85 | # define HAVE_DLINFO 1 | ||
| 86 | # if defined(_AIX) || defined(__CYGWIN__) || \ | ||
| 87 | defined(__SCO_VERSION__) || defined(_SCO_ELF) || \ | ||
| 88 | (defined(__OpenBSD__) && !defined(RTLD_SELF)) | ||
| 89 | # undef HAVE_DLINFO | ||
| 90 | # endif | ||
| 72 | #endif | 91 | #endif |
| 73 | 92 | ||
| 74 | /* Part of the hack in "dlfcn_load" ... */ | 93 | /* Part of the hack in "dlfcn_load" ... */ |
| @@ -87,6 +106,8 @@ static long dlfcn_ctrl(DSO *dso, int cmd, long larg, void *parg); | |||
| 87 | static char *dlfcn_name_converter(DSO *dso, const char *filename); | 106 | static char *dlfcn_name_converter(DSO *dso, const char *filename); |
| 88 | static char *dlfcn_merger(DSO *dso, const char *filespec1, | 107 | static char *dlfcn_merger(DSO *dso, const char *filespec1, |
| 89 | const char *filespec2); | 108 | const char *filespec2); |
| 109 | static int dlfcn_pathbyaddr(void *addr,char *path,int sz); | ||
| 110 | static void *dlfcn_globallookup(const char *name); | ||
| 90 | 111 | ||
| 91 | static DSO_METHOD dso_meth_dlfcn = { | 112 | static DSO_METHOD dso_meth_dlfcn = { |
| 92 | "OpenSSL 'dlfcn' shared library method", | 113 | "OpenSSL 'dlfcn' shared library method", |
| @@ -103,7 +124,9 @@ static DSO_METHOD dso_meth_dlfcn = { | |||
| 103 | dlfcn_name_converter, | 124 | dlfcn_name_converter, |
| 104 | dlfcn_merger, | 125 | dlfcn_merger, |
| 105 | NULL, /* init */ | 126 | NULL, /* init */ |
| 106 | NULL /* finish */ | 127 | NULL, /* finish */ |
| 128 | dlfcn_pathbyaddr, | ||
| 129 | dlfcn_globallookup | ||
| 107 | }; | 130 | }; |
| 108 | 131 | ||
| 109 | DSO_METHOD *DSO_METHOD_dlfcn(void) | 132 | DSO_METHOD *DSO_METHOD_dlfcn(void) |
| @@ -163,7 +186,7 @@ static int dlfcn_load(DSO *dso) | |||
| 163 | ERR_add_error_data(4, "filename(", filename, "): ", dlerror()); | 186 | ERR_add_error_data(4, "filename(", filename, "): ", dlerror()); |
| 164 | goto err; | 187 | goto err; |
| 165 | } | 188 | } |
| 166 | if(!sk_push(dso->meth_data, (char *)ptr)) | 189 | if(!sk_void_push(dso->meth_data, (char *)ptr)) |
| 167 | { | 190 | { |
| 168 | DSOerr(DSO_F_DLFCN_LOAD,DSO_R_STACK_ERROR); | 191 | DSOerr(DSO_F_DLFCN_LOAD,DSO_R_STACK_ERROR); |
| 169 | goto err; | 192 | goto err; |
| @@ -188,15 +211,15 @@ static int dlfcn_unload(DSO *dso) | |||
| 188 | DSOerr(DSO_F_DLFCN_UNLOAD,ERR_R_PASSED_NULL_PARAMETER); | 211 | DSOerr(DSO_F_DLFCN_UNLOAD,ERR_R_PASSED_NULL_PARAMETER); |
| 189 | return(0); | 212 | return(0); |
| 190 | } | 213 | } |
| 191 | if(sk_num(dso->meth_data) < 1) | 214 | if(sk_void_num(dso->meth_data) < 1) |
| 192 | return(1); | 215 | return(1); |
| 193 | ptr = (void *)sk_pop(dso->meth_data); | 216 | ptr = sk_void_pop(dso->meth_data); |
| 194 | if(ptr == NULL) | 217 | if(ptr == NULL) |
| 195 | { | 218 | { |
| 196 | DSOerr(DSO_F_DLFCN_UNLOAD,DSO_R_NULL_HANDLE); | 219 | DSOerr(DSO_F_DLFCN_UNLOAD,DSO_R_NULL_HANDLE); |
| 197 | /* Should push the value back onto the stack in | 220 | /* Should push the value back onto the stack in |
| 198 | * case of a retry. */ | 221 | * case of a retry. */ |
| 199 | sk_push(dso->meth_data, (char *)ptr); | 222 | sk_void_push(dso->meth_data, ptr); |
| 200 | return(0); | 223 | return(0); |
| 201 | } | 224 | } |
| 202 | /* For now I'm not aware of any errors associated with dlclose() */ | 225 | /* For now I'm not aware of any errors associated with dlclose() */ |
| @@ -213,12 +236,12 @@ static void *dlfcn_bind_var(DSO *dso, const char *symname) | |||
| 213 | DSOerr(DSO_F_DLFCN_BIND_VAR,ERR_R_PASSED_NULL_PARAMETER); | 236 | DSOerr(DSO_F_DLFCN_BIND_VAR,ERR_R_PASSED_NULL_PARAMETER); |
| 214 | return(NULL); | 237 | return(NULL); |
| 215 | } | 238 | } |
| 216 | if(sk_num(dso->meth_data) < 1) | 239 | if(sk_void_num(dso->meth_data) < 1) |
| 217 | { | 240 | { |
| 218 | DSOerr(DSO_F_DLFCN_BIND_VAR,DSO_R_STACK_ERROR); | 241 | DSOerr(DSO_F_DLFCN_BIND_VAR,DSO_R_STACK_ERROR); |
| 219 | return(NULL); | 242 | return(NULL); |
| 220 | } | 243 | } |
| 221 | ptr = (void *)sk_value(dso->meth_data, sk_num(dso->meth_data) - 1); | 244 | ptr = sk_void_value(dso->meth_data, sk_void_num(dso->meth_data) - 1); |
| 222 | if(ptr == NULL) | 245 | if(ptr == NULL) |
| 223 | { | 246 | { |
| 224 | DSOerr(DSO_F_DLFCN_BIND_VAR,DSO_R_NULL_HANDLE); | 247 | DSOerr(DSO_F_DLFCN_BIND_VAR,DSO_R_NULL_HANDLE); |
| @@ -237,32 +260,35 @@ static void *dlfcn_bind_var(DSO *dso, const char *symname) | |||
| 237 | static DSO_FUNC_TYPE dlfcn_bind_func(DSO *dso, const char *symname) | 260 | static DSO_FUNC_TYPE dlfcn_bind_func(DSO *dso, const char *symname) |
| 238 | { | 261 | { |
| 239 | void *ptr; | 262 | void *ptr; |
| 240 | DSO_FUNC_TYPE sym, *tsym = &sym; | 263 | union { |
| 264 | DSO_FUNC_TYPE sym; | ||
| 265 | void *dlret; | ||
| 266 | } u; | ||
| 241 | 267 | ||
| 242 | if((dso == NULL) || (symname == NULL)) | 268 | if((dso == NULL) || (symname == NULL)) |
| 243 | { | 269 | { |
| 244 | DSOerr(DSO_F_DLFCN_BIND_FUNC,ERR_R_PASSED_NULL_PARAMETER); | 270 | DSOerr(DSO_F_DLFCN_BIND_FUNC,ERR_R_PASSED_NULL_PARAMETER); |
| 245 | return(NULL); | 271 | return(NULL); |
| 246 | } | 272 | } |
| 247 | if(sk_num(dso->meth_data) < 1) | 273 | if(sk_void_num(dso->meth_data) < 1) |
| 248 | { | 274 | { |
| 249 | DSOerr(DSO_F_DLFCN_BIND_FUNC,DSO_R_STACK_ERROR); | 275 | DSOerr(DSO_F_DLFCN_BIND_FUNC,DSO_R_STACK_ERROR); |
| 250 | return(NULL); | 276 | return(NULL); |
| 251 | } | 277 | } |
| 252 | ptr = (void *)sk_value(dso->meth_data, sk_num(dso->meth_data) - 1); | 278 | ptr = sk_void_value(dso->meth_data, sk_void_num(dso->meth_data) - 1); |
| 253 | if(ptr == NULL) | 279 | if(ptr == NULL) |
| 254 | { | 280 | { |
| 255 | DSOerr(DSO_F_DLFCN_BIND_FUNC,DSO_R_NULL_HANDLE); | 281 | DSOerr(DSO_F_DLFCN_BIND_FUNC,DSO_R_NULL_HANDLE); |
| 256 | return(NULL); | 282 | return(NULL); |
| 257 | } | 283 | } |
| 258 | *(void **)(tsym) = dlsym(ptr, symname); | 284 | u.dlret = dlsym(ptr, symname); |
| 259 | if(sym == NULL) | 285 | if(u.dlret == NULL) |
| 260 | { | 286 | { |
| 261 | DSOerr(DSO_F_DLFCN_BIND_FUNC,DSO_R_SYM_FAILURE); | 287 | DSOerr(DSO_F_DLFCN_BIND_FUNC,DSO_R_SYM_FAILURE); |
| 262 | ERR_add_error_data(4, "symname(", symname, "): ", dlerror()); | 288 | ERR_add_error_data(4, "symname(", symname, "): ", dlerror()); |
| 263 | return(NULL); | 289 | return(NULL); |
| 264 | } | 290 | } |
| 265 | return(sym); | 291 | return u.sym; |
| 266 | } | 292 | } |
| 267 | 293 | ||
| 268 | static char *dlfcn_merger(DSO *dso, const char *filespec1, | 294 | static char *dlfcn_merger(DSO *dso, const char *filespec1, |
| @@ -279,14 +305,13 @@ static char *dlfcn_merger(DSO *dso, const char *filespec1, | |||
| 279 | } | 305 | } |
| 280 | /* If the first file specification is a rooted path, it rules. | 306 | /* If the first file specification is a rooted path, it rules. |
| 281 | same goes if the second file specification is missing. */ | 307 | same goes if the second file specification is missing. */ |
| 282 | if (!filespec2 || filespec1[0] == '/') | 308 | if (!filespec2 || (filespec1 != NULL && filespec1[0] == '/')) |
| 283 | { | 309 | { |
| 284 | len = strlen(filespec1) + 1; | 310 | len = strlen(filespec1) + 1; |
| 285 | merged = OPENSSL_malloc(len); | 311 | merged = OPENSSL_malloc(len); |
| 286 | if(!merged) | 312 | if(!merged) |
| 287 | { | 313 | { |
| 288 | DSOerr(DSO_F_DLFCN_MERGER, | 314 | DSOerr(DSO_F_DLFCN_MERGER, ERR_R_MALLOC_FAILURE); |
| 289 | ERR_R_MALLOC_FAILURE); | ||
| 290 | return(NULL); | 315 | return(NULL); |
| 291 | } | 316 | } |
| 292 | strlcpy(merged, filespec1, len); | 317 | strlcpy(merged, filespec1, len); |
| @@ -313,7 +338,7 @@ static char *dlfcn_merger(DSO *dso, const char *filespec1, | |||
| 313 | { | 338 | { |
| 314 | int spec2len, len; | 339 | int spec2len, len; |
| 315 | 340 | ||
| 316 | spec2len = (filespec2 ? strlen(filespec2) : 0); | 341 | spec2len = strlen(filespec2); |
| 317 | len = spec2len + (filespec1 ? strlen(filespec1) : 0); | 342 | len = spec2len + (filespec1 ? strlen(filespec1) : 0); |
| 318 | 343 | ||
| 319 | if(filespec2 && filespec2[spec2len - 1] == '/') | 344 | if(filespec2 && filespec2[spec2len - 1] == '/') |
| @@ -335,6 +360,15 @@ static char *dlfcn_merger(DSO *dso, const char *filespec1, | |||
| 335 | return(merged); | 360 | return(merged); |
| 336 | } | 361 | } |
| 337 | 362 | ||
| 363 | #ifdef OPENSSL_SYS_MACOSX | ||
| 364 | #define DSO_ext ".dylib" | ||
| 365 | #define DSO_extlen 6 | ||
| 366 | #else | ||
| 367 | #define DSO_ext ".so" | ||
| 368 | #define DSO_extlen 3 | ||
| 369 | #endif | ||
| 370 | |||
| 371 | |||
| 338 | static char *dlfcn_name_converter(DSO *dso, const char *filename) | 372 | static char *dlfcn_name_converter(DSO *dso, const char *filename) |
| 339 | { | 373 | { |
| 340 | char *translated; | 374 | char *translated; |
| @@ -345,8 +379,8 @@ static char *dlfcn_name_converter(DSO *dso, const char *filename) | |||
| 345 | transform = (strstr(filename, "/") == NULL); | 379 | transform = (strstr(filename, "/") == NULL); |
| 346 | if(transform) | 380 | if(transform) |
| 347 | { | 381 | { |
| 348 | /* We will convert this to "%s.so" or "lib%s.so" */ | 382 | /* We will convert this to "%s.so" or "lib%s.so" etc */ |
| 349 | rsize += 3; /* The length of ".so" */ | 383 | rsize += DSO_extlen; /* The length of ".so" */ |
| 350 | if ((DSO_flags(dso) & DSO_FLAG_NAME_TRANSLATION_EXT_ONLY) == 0) | 384 | if ((DSO_flags(dso) & DSO_FLAG_NAME_TRANSLATION_EXT_ONLY) == 0) |
| 351 | rsize += 3; /* The length of "lib" */ | 385 | rsize += 3; /* The length of "lib" */ |
| 352 | } | 386 | } |
| @@ -360,13 +394,92 @@ static char *dlfcn_name_converter(DSO *dso, const char *filename) | |||
| 360 | if(transform) | 394 | if(transform) |
| 361 | { | 395 | { |
| 362 | if ((DSO_flags(dso) & DSO_FLAG_NAME_TRANSLATION_EXT_ONLY) == 0) | 396 | if ((DSO_flags(dso) & DSO_FLAG_NAME_TRANSLATION_EXT_ONLY) == 0) |
| 363 | snprintf(translated, rsize, "lib%s.so", filename); | 397 | snprintf(translated, rsize, "lib%s" DSO_ext, filename); |
| 364 | else | 398 | else |
| 365 | snprintf(translated, rsize, "%s.so", filename); | 399 | snprintf(translated, rsize, "%s" DSO_ext, filename); |
| 366 | } | 400 | } |
| 367 | else | 401 | else |
| 368 | snprintf(translated, rsize, "%s", filename); | 402 | snprintf(translated, rsize, "%s", filename); |
| 369 | return(translated); | 403 | return(translated); |
| 370 | } | 404 | } |
| 371 | 405 | ||
| 406 | #if defined(__sgi) && !defined(__OpenBSD__) | ||
| 407 | /* | ||
| 408 | This is a quote from IRIX manual for dladdr(3c): | ||
| 409 | |||
| 410 | <dlfcn.h> does not contain a prototype for dladdr or definition of | ||
| 411 | Dl_info. The #include <dlfcn.h> in the SYNOPSIS line is traditional, | ||
| 412 | but contains no dladdr prototype and no IRIX library contains an | ||
| 413 | implementation. Write your own declaration based on the code below. | ||
| 414 | |||
| 415 | The following code is dependent on internal interfaces that are not | ||
| 416 | part of the IRIX compatibility guarantee; however, there is no future | ||
| 417 | intention to change this interface, so on a practical level, the code | ||
| 418 | below is safe to use on IRIX. | ||
| 419 | */ | ||
| 420 | #include <rld_interface.h> | ||
| 421 | #ifndef _RLD_INTERFACE_DLFCN_H_DLADDR | ||
| 422 | #define _RLD_INTERFACE_DLFCN_H_DLADDR | ||
| 423 | typedef struct Dl_info { | ||
| 424 | const char * dli_fname; | ||
| 425 | void * dli_fbase; | ||
| 426 | const char * dli_sname; | ||
| 427 | void * dli_saddr; | ||
| 428 | int dli_version; | ||
| 429 | int dli_reserved1; | ||
| 430 | long dli_reserved[4]; | ||
| 431 | } Dl_info; | ||
| 432 | #else | ||
| 433 | typedef struct Dl_info Dl_info; | ||
| 434 | #endif | ||
| 435 | #define _RLD_DLADDR 14 | ||
| 436 | |||
| 437 | static int dladdr(void *address, Dl_info *dl) | ||
| 438 | { | ||
| 439 | void *v; | ||
| 440 | v = _rld_new_interface(_RLD_DLADDR,address,dl); | ||
| 441 | return (int)v; | ||
| 442 | } | ||
| 443 | #endif /* __sgi */ | ||
| 444 | |||
| 445 | static int dlfcn_pathbyaddr(void *addr,char *path,int sz) | ||
| 446 | { | ||
| 447 | #ifdef HAVE_DLINFO | ||
| 448 | Dl_info dli; | ||
| 449 | int len; | ||
| 450 | |||
| 451 | if (addr == NULL) | ||
| 452 | { | ||
| 453 | union { int(*f)(void*,char*,int); void *p; } t = | ||
| 454 | { dlfcn_pathbyaddr }; | ||
| 455 | addr = t.p; | ||
| 456 | } | ||
| 457 | |||
| 458 | if (dladdr(addr,&dli)) | ||
| 459 | { | ||
| 460 | len = (int)strlen(dli.dli_fname); | ||
| 461 | if (sz <= 0) return len+1; | ||
| 462 | if (len >= sz) len=sz-1; | ||
| 463 | memcpy(path,dli.dli_fname,len); | ||
| 464 | path[len++]=0; | ||
| 465 | return len; | ||
| 466 | } | ||
| 467 | |||
| 468 | ERR_add_error_data(4, "dlfcn_pathbyaddr(): ", dlerror()); | ||
| 469 | #endif | ||
| 470 | return -1; | ||
| 471 | } | ||
| 472 | |||
| 473 | static void *dlfcn_globallookup(const char *name) | ||
| 474 | { | ||
| 475 | void *ret = NULL,*handle = dlopen(NULL,RTLD_LAZY); | ||
| 476 | |||
| 477 | if (handle) | ||
| 478 | { | ||
| 479 | ret = dlsym(handle,name); | ||
| 480 | dlclose(handle); | ||
| 481 | } | ||
| 482 | |||
| 483 | return ret; | ||
| 484 | } | ||
| 372 | #endif /* DSO_DLFCN */ | 485 | #endif /* DSO_DLFCN */ |
diff --git a/src/lib/libcrypto/dso/dso_err.c b/src/lib/libcrypto/dso/dso_err.c index a8b0a210de..2bb07c2514 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-2005 The OpenSSL Project. All rights reserved. | 3 | * Copyright (c) 1999-2006 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 |
| @@ -70,6 +70,11 @@ | |||
| 70 | 70 | ||
| 71 | static ERR_STRING_DATA DSO_str_functs[]= | 71 | static ERR_STRING_DATA DSO_str_functs[]= |
| 72 | { | 72 | { |
| 73 | {ERR_FUNC(DSO_F_BEOS_BIND_FUNC), "BEOS_BIND_FUNC"}, | ||
| 74 | {ERR_FUNC(DSO_F_BEOS_BIND_VAR), "BEOS_BIND_VAR"}, | ||
| 75 | {ERR_FUNC(DSO_F_BEOS_LOAD), "BEOS_LOAD"}, | ||
| 76 | {ERR_FUNC(DSO_F_BEOS_NAME_CONVERTER), "BEOS_NAME_CONVERTER"}, | ||
| 77 | {ERR_FUNC(DSO_F_BEOS_UNLOAD), "BEOS_UNLOAD"}, | ||
| 73 | {ERR_FUNC(DSO_F_DLFCN_BIND_FUNC), "DLFCN_BIND_FUNC"}, | 78 | {ERR_FUNC(DSO_F_DLFCN_BIND_FUNC), "DLFCN_BIND_FUNC"}, |
| 74 | {ERR_FUNC(DSO_F_DLFCN_BIND_VAR), "DLFCN_BIND_VAR"}, | 79 | {ERR_FUNC(DSO_F_DLFCN_BIND_VAR), "DLFCN_BIND_VAR"}, |
| 75 | {ERR_FUNC(DSO_F_DLFCN_LOAD), "DLFCN_LOAD"}, | 80 | {ERR_FUNC(DSO_F_DLFCN_LOAD), "DLFCN_LOAD"}, |
| @@ -89,22 +94,29 @@ static ERR_STRING_DATA DSO_str_functs[]= | |||
| 89 | {ERR_FUNC(DSO_F_DSO_FREE), "DSO_free"}, | 94 | {ERR_FUNC(DSO_F_DSO_FREE), "DSO_free"}, |
| 90 | {ERR_FUNC(DSO_F_DSO_GET_FILENAME), "DSO_get_filename"}, | 95 | {ERR_FUNC(DSO_F_DSO_GET_FILENAME), "DSO_get_filename"}, |
| 91 | {ERR_FUNC(DSO_F_DSO_GET_LOADED_FILENAME), "DSO_get_loaded_filename"}, | 96 | {ERR_FUNC(DSO_F_DSO_GET_LOADED_FILENAME), "DSO_get_loaded_filename"}, |
| 97 | {ERR_FUNC(DSO_F_DSO_GLOBAL_LOOKUP), "DSO_global_lookup"}, | ||
| 92 | {ERR_FUNC(DSO_F_DSO_LOAD), "DSO_load"}, | 98 | {ERR_FUNC(DSO_F_DSO_LOAD), "DSO_load"}, |
| 93 | {ERR_FUNC(DSO_F_DSO_MERGE), "DSO_merge"}, | 99 | {ERR_FUNC(DSO_F_DSO_MERGE), "DSO_merge"}, |
| 94 | {ERR_FUNC(DSO_F_DSO_NEW_METHOD), "DSO_new_method"}, | 100 | {ERR_FUNC(DSO_F_DSO_NEW_METHOD), "DSO_new_method"}, |
| 101 | {ERR_FUNC(DSO_F_DSO_PATHBYADDR), "DSO_pathbyaddr"}, | ||
| 95 | {ERR_FUNC(DSO_F_DSO_SET_FILENAME), "DSO_set_filename"}, | 102 | {ERR_FUNC(DSO_F_DSO_SET_FILENAME), "DSO_set_filename"}, |
| 96 | {ERR_FUNC(DSO_F_DSO_SET_NAME_CONVERTER), "DSO_set_name_converter"}, | 103 | {ERR_FUNC(DSO_F_DSO_SET_NAME_CONVERTER), "DSO_set_name_converter"}, |
| 97 | {ERR_FUNC(DSO_F_DSO_UP_REF), "DSO_up_ref"}, | 104 | {ERR_FUNC(DSO_F_DSO_UP_REF), "DSO_up_ref"}, |
| 105 | {ERR_FUNC(DSO_F_GLOBAL_LOOKUP_FUNC), "GLOBAL_LOOKUP_FUNC"}, | ||
| 106 | {ERR_FUNC(DSO_F_PATHBYADDR), "PATHBYADDR"}, | ||
| 98 | {ERR_FUNC(DSO_F_VMS_BIND_SYM), "VMS_BIND_SYM"}, | 107 | {ERR_FUNC(DSO_F_VMS_BIND_SYM), "VMS_BIND_SYM"}, |
| 99 | {ERR_FUNC(DSO_F_VMS_LOAD), "VMS_LOAD"}, | 108 | {ERR_FUNC(DSO_F_VMS_LOAD), "VMS_LOAD"}, |
| 100 | {ERR_FUNC(DSO_F_VMS_MERGER), "VMS_MERGER"}, | 109 | {ERR_FUNC(DSO_F_VMS_MERGER), "VMS_MERGER"}, |
| 101 | {ERR_FUNC(DSO_F_VMS_UNLOAD), "VMS_UNLOAD"}, | 110 | {ERR_FUNC(DSO_F_VMS_UNLOAD), "VMS_UNLOAD"}, |
| 102 | {ERR_FUNC(DSO_F_WIN32_BIND_FUNC), "WIN32_BIND_FUNC"}, | 111 | {ERR_FUNC(DSO_F_WIN32_BIND_FUNC), "WIN32_BIND_FUNC"}, |
| 103 | {ERR_FUNC(DSO_F_WIN32_BIND_VAR), "WIN32_BIND_VAR"}, | 112 | {ERR_FUNC(DSO_F_WIN32_BIND_VAR), "WIN32_BIND_VAR"}, |
| 113 | {ERR_FUNC(DSO_F_WIN32_GLOBALLOOKUP), "WIN32_GLOBALLOOKUP"}, | ||
| 114 | {ERR_FUNC(DSO_F_WIN32_GLOBALLOOKUP_FUNC), "WIN32_GLOBALLOOKUP_FUNC"}, | ||
| 104 | {ERR_FUNC(DSO_F_WIN32_JOINER), "WIN32_JOINER"}, | 115 | {ERR_FUNC(DSO_F_WIN32_JOINER), "WIN32_JOINER"}, |
| 105 | {ERR_FUNC(DSO_F_WIN32_LOAD), "WIN32_LOAD"}, | 116 | {ERR_FUNC(DSO_F_WIN32_LOAD), "WIN32_LOAD"}, |
| 106 | {ERR_FUNC(DSO_F_WIN32_MERGER), "WIN32_MERGER"}, | 117 | {ERR_FUNC(DSO_F_WIN32_MERGER), "WIN32_MERGER"}, |
| 107 | {ERR_FUNC(DSO_F_WIN32_NAME_CONVERTER), "WIN32_NAME_CONVERTER"}, | 118 | {ERR_FUNC(DSO_F_WIN32_NAME_CONVERTER), "WIN32_NAME_CONVERTER"}, |
| 119 | {ERR_FUNC(DSO_F_WIN32_PATHBYADDR), "WIN32_PATHBYADDR"}, | ||
| 108 | {ERR_FUNC(DSO_F_WIN32_SPLITTER), "WIN32_SPLITTER"}, | 120 | {ERR_FUNC(DSO_F_WIN32_SPLITTER), "WIN32_SPLITTER"}, |
| 109 | {ERR_FUNC(DSO_F_WIN32_UNLOAD), "WIN32_UNLOAD"}, | 121 | {ERR_FUNC(DSO_F_WIN32_UNLOAD), "WIN32_UNLOAD"}, |
| 110 | {0,NULL} | 122 | {0,NULL} |
diff --git a/src/lib/libcrypto/dso/dso_lib.c b/src/lib/libcrypto/dso/dso_lib.c index 49bdd71309..8a15b794ab 100644 --- a/src/lib/libcrypto/dso/dso_lib.c +++ b/src/lib/libcrypto/dso/dso_lib.c | |||
| @@ -107,7 +107,7 @@ DSO *DSO_new_method(DSO_METHOD *meth) | |||
| 107 | return(NULL); | 107 | return(NULL); |
| 108 | } | 108 | } |
| 109 | memset(ret, 0, sizeof(DSO)); | 109 | memset(ret, 0, sizeof(DSO)); |
| 110 | ret->meth_data = sk_new_null(); | 110 | ret->meth_data = sk_void_new_null(); |
| 111 | if(ret->meth_data == NULL) | 111 | if(ret->meth_data == NULL) |
| 112 | { | 112 | { |
| 113 | /* sk_new doesn't generate any errors so we do */ | 113 | /* sk_new doesn't generate any errors so we do */ |
| @@ -163,7 +163,7 @@ int DSO_free(DSO *dso) | |||
| 163 | return(0); | 163 | return(0); |
| 164 | } | 164 | } |
| 165 | 165 | ||
| 166 | sk_free(dso->meth_data); | 166 | sk_void_free(dso->meth_data); |
| 167 | if(dso->filename != NULL) | 167 | if(dso->filename != NULL) |
| 168 | OPENSSL_free(dso->filename); | 168 | OPENSSL_free(dso->filename); |
| 169 | if(dso->loaded_filename != NULL) | 169 | if(dso->loaded_filename != NULL) |
| @@ -399,13 +399,6 @@ char *DSO_merge(DSO *dso, const char *filespec1, const char *filespec2) | |||
| 399 | DSOerr(DSO_F_DSO_MERGE,ERR_R_PASSED_NULL_PARAMETER); | 399 | DSOerr(DSO_F_DSO_MERGE,ERR_R_PASSED_NULL_PARAMETER); |
| 400 | return(NULL); | 400 | return(NULL); |
| 401 | } | 401 | } |
| 402 | if(filespec1 == NULL) | ||
| 403 | filespec1 = dso->filename; | ||
| 404 | if(filespec1 == NULL) | ||
| 405 | { | ||
| 406 | DSOerr(DSO_F_DSO_MERGE,DSO_R_NO_FILE_SPECIFICATION); | ||
| 407 | return(NULL); | ||
| 408 | } | ||
| 409 | if((dso->flags & DSO_FLAG_NO_NAME_TRANSLATION) == 0) | 402 | if((dso->flags & DSO_FLAG_NO_NAME_TRANSLATION) == 0) |
| 410 | { | 403 | { |
| 411 | if(dso->merger != NULL) | 404 | if(dso->merger != NULL) |
| @@ -464,3 +457,27 @@ const char *DSO_get_loaded_filename(DSO *dso) | |||
| 464 | } | 457 | } |
| 465 | return(dso->loaded_filename); | 458 | return(dso->loaded_filename); |
| 466 | } | 459 | } |
| 460 | |||
| 461 | int DSO_pathbyaddr(void *addr,char *path,int sz) | ||
| 462 | { | ||
| 463 | DSO_METHOD *meth = default_DSO_meth; | ||
| 464 | if (meth == NULL) meth = DSO_METHOD_openssl(); | ||
| 465 | if (meth->pathbyaddr == NULL) | ||
| 466 | { | ||
| 467 | DSOerr(DSO_F_DSO_PATHBYADDR,DSO_R_UNSUPPORTED); | ||
| 468 | return -1; | ||
| 469 | } | ||
| 470 | return (*meth->pathbyaddr)(addr,path,sz); | ||
| 471 | } | ||
| 472 | |||
| 473 | void *DSO_global_lookup(const char *name) | ||
| 474 | { | ||
| 475 | DSO_METHOD *meth = default_DSO_meth; | ||
| 476 | if (meth == NULL) meth = DSO_METHOD_openssl(); | ||
| 477 | if (meth->globallookup == NULL) | ||
| 478 | { | ||
| 479 | DSOerr(DSO_F_DSO_GLOBAL_LOOKUP,DSO_R_UNSUPPORTED); | ||
| 480 | return NULL; | ||
| 481 | } | ||
| 482 | return (*meth->globallookup)(name); | ||
| 483 | } | ||
diff --git a/src/lib/libcrypto/dso/dso_null.c b/src/lib/libcrypto/dso/dso_null.c index 4972984651..49d842d1f5 100644 --- a/src/lib/libcrypto/dso/dso_null.c +++ b/src/lib/libcrypto/dso/dso_null.c | |||
| @@ -78,7 +78,9 @@ static DSO_METHOD dso_meth_null = { | |||
| 78 | NULL, /* dso_name_converter */ | 78 | NULL, /* dso_name_converter */ |
| 79 | NULL, /* dso_merger */ | 79 | NULL, /* dso_merger */ |
| 80 | NULL, /* init */ | 80 | NULL, /* init */ |
| 81 | NULL /* finish */ | 81 | NULL, /* finish */ |
| 82 | NULL, /* pathbyaddr */ | ||
| 83 | NULL /* globallookup */ | ||
| 82 | }; | 84 | }; |
| 83 | 85 | ||
| 84 | DSO_METHOD *DSO_METHOD_null(void) | 86 | DSO_METHOD *DSO_METHOD_null(void) |
diff --git a/src/lib/libcrypto/dso/dso_openssl.c b/src/lib/libcrypto/dso/dso_openssl.c index a4395ebffe..b17e8e8e9e 100644 --- a/src/lib/libcrypto/dso/dso_openssl.c +++ b/src/lib/libcrypto/dso/dso_openssl.c | |||
| @@ -74,6 +74,8 @@ DSO_METHOD *DSO_METHOD_openssl(void) | |||
| 74 | return(DSO_METHOD_win32()); | 74 | return(DSO_METHOD_win32()); |
| 75 | #elif defined(DSO_VMS) | 75 | #elif defined(DSO_VMS) |
| 76 | return(DSO_METHOD_vms()); | 76 | return(DSO_METHOD_vms()); |
| 77 | #elif defined(DSO_BEOS) | ||
| 78 | return(DSO_METHOD_beos()); | ||
| 77 | #else | 79 | #else |
| 78 | return(DSO_METHOD_null()); | 80 | return(DSO_METHOD_null()); |
| 79 | #endif | 81 | #endif |
diff --git a/src/lib/libcrypto/dso/dso_vms.c b/src/lib/libcrypto/dso/dso_vms.c index 2c434ee8a6..321512772a 100644 --- a/src/lib/libcrypto/dso/dso_vms.c +++ b/src/lib/libcrypto/dso/dso_vms.c | |||
| @@ -215,7 +215,7 @@ static int vms_load(DSO *dso) | |||
| 215 | p->imagename_dsc.dsc$b_class = DSC$K_CLASS_S; | 215 | p->imagename_dsc.dsc$b_class = DSC$K_CLASS_S; |
| 216 | p->imagename_dsc.dsc$a_pointer = p->imagename; | 216 | p->imagename_dsc.dsc$a_pointer = p->imagename; |
| 217 | 217 | ||
| 218 | if(!sk_push(dso->meth_data, (char *)p)) | 218 | if(!sk_void_push(dso->meth_data, (char *)p)) |
| 219 | { | 219 | { |
| 220 | DSOerr(DSO_F_VMS_LOAD,DSO_R_STACK_ERROR); | 220 | DSOerr(DSO_F_VMS_LOAD,DSO_R_STACK_ERROR); |
| 221 | goto err; | 221 | goto err; |
| @@ -245,9 +245,9 @@ static int vms_unload(DSO *dso) | |||
| 245 | DSOerr(DSO_F_VMS_UNLOAD,ERR_R_PASSED_NULL_PARAMETER); | 245 | DSOerr(DSO_F_VMS_UNLOAD,ERR_R_PASSED_NULL_PARAMETER); |
| 246 | return(0); | 246 | return(0); |
| 247 | } | 247 | } |
| 248 | if(sk_num(dso->meth_data) < 1) | 248 | if(sk_void_num(dso->meth_data) < 1) |
| 249 | return(1); | 249 | return(1); |
| 250 | p = (DSO_VMS_INTERNAL *)sk_pop(dso->meth_data); | 250 | p = (DSO_VMS_INTERNAL *)sk_void_pop(dso->meth_data); |
| 251 | if(p == NULL) | 251 | if(p == NULL) |
| 252 | { | 252 | { |
| 253 | DSOerr(DSO_F_VMS_UNLOAD,DSO_R_NULL_HANDLE); | 253 | DSOerr(DSO_F_VMS_UNLOAD,DSO_R_NULL_HANDLE); |
| @@ -302,13 +302,13 @@ void vms_bind_sym(DSO *dso, const char *symname, void **sym) | |||
| 302 | DSOerr(DSO_F_VMS_BIND_SYM,ERR_R_PASSED_NULL_PARAMETER); | 302 | DSOerr(DSO_F_VMS_BIND_SYM,ERR_R_PASSED_NULL_PARAMETER); |
| 303 | return; | 303 | return; |
| 304 | } | 304 | } |
| 305 | if(sk_num(dso->meth_data) < 1) | 305 | if(sk_void_num(dso->meth_data) < 1) |
| 306 | { | 306 | { |
| 307 | DSOerr(DSO_F_VMS_BIND_SYM,DSO_R_STACK_ERROR); | 307 | DSOerr(DSO_F_VMS_BIND_SYM,DSO_R_STACK_ERROR); |
| 308 | return; | 308 | return; |
| 309 | } | 309 | } |
| 310 | ptr = (DSO_VMS_INTERNAL *)sk_value(dso->meth_data, | 310 | ptr = (DSO_VMS_INTERNAL *)sk_void_value(dso->meth_data, |
| 311 | sk_num(dso->meth_data) - 1); | 311 | sk_void_num(dso->meth_data) - 1); |
| 312 | if(ptr == NULL) | 312 | if(ptr == NULL) |
| 313 | { | 313 | { |
| 314 | DSOerr(DSO_F_VMS_BIND_SYM,DSO_R_NULL_HANDLE); | 314 | DSOerr(DSO_F_VMS_BIND_SYM,DSO_R_NULL_HANDLE); |
diff --git a/src/lib/libcrypto/dso/dso_win32.c b/src/lib/libcrypto/dso/dso_win32.c index fd3dd6a7fe..6fb6c54181 100644 --- a/src/lib/libcrypto/dso/dso_win32.c +++ b/src/lib/libcrypto/dso/dso_win32.c | |||
| @@ -96,7 +96,11 @@ static HINSTANCE LoadLibraryA(LPCSTR lpLibFileName) | |||
| 96 | #else | 96 | #else |
| 97 | fnamw = (WCHAR *)alloca (len_0*sizeof(WCHAR)); | 97 | fnamw = (WCHAR *)alloca (len_0*sizeof(WCHAR)); |
| 98 | #endif | 98 | #endif |
| 99 | if (fnamw == NULL) return NULL; | 99 | if (fnamw == NULL) |
| 100 | { | ||
| 101 | SetLastError(ERROR_NOT_ENOUGH_MEMORY); | ||
| 102 | return NULL; | ||
| 103 | } | ||
| 100 | 104 | ||
| 101 | #if defined(_WIN32_WCE) && _WIN32_WCE>=101 | 105 | #if defined(_WIN32_WCE) && _WIN32_WCE>=101 |
| 102 | if (!MultiByteToWideChar(CP_ACP,0,lpLibFileName,len_0,fnamw,len_0)) | 106 | if (!MultiByteToWideChar(CP_ACP,0,lpLibFileName,len_0,fnamw,len_0)) |
| @@ -124,6 +128,8 @@ static long win32_ctrl(DSO *dso, int cmd, long larg, void *parg); | |||
| 124 | static char *win32_name_converter(DSO *dso, const char *filename); | 128 | static char *win32_name_converter(DSO *dso, const char *filename); |
| 125 | static char *win32_merger(DSO *dso, const char *filespec1, | 129 | static char *win32_merger(DSO *dso, const char *filespec1, |
| 126 | const char *filespec2); | 130 | const char *filespec2); |
| 131 | static int win32_pathbyaddr(void *addr,char *path,int sz); | ||
| 132 | static void *win32_globallookup(const char *name); | ||
| 127 | 133 | ||
| 128 | static const char *openssl_strnchr(const char *string, int c, size_t len); | 134 | static const char *openssl_strnchr(const char *string, int c, size_t len); |
| 129 | 135 | ||
| @@ -142,7 +148,9 @@ static DSO_METHOD dso_meth_win32 = { | |||
| 142 | win32_name_converter, | 148 | win32_name_converter, |
| 143 | win32_merger, | 149 | win32_merger, |
| 144 | NULL, /* init */ | 150 | NULL, /* init */ |
| 145 | NULL /* finish */ | 151 | NULL, /* finish */ |
| 152 | win32_pathbyaddr, | ||
| 153 | win32_globallookup | ||
| 146 | }; | 154 | }; |
| 147 | 155 | ||
| 148 | DSO_METHOD *DSO_METHOD_win32(void) | 156 | DSO_METHOD *DSO_METHOD_win32(void) |
| @@ -180,7 +188,7 @@ static int win32_load(DSO *dso) | |||
| 180 | goto err; | 188 | goto err; |
| 181 | } | 189 | } |
| 182 | *p = h; | 190 | *p = h; |
| 183 | if(!sk_push(dso->meth_data, (char *)p)) | 191 | if(!sk_void_push(dso->meth_data, p)) |
| 184 | { | 192 | { |
| 185 | DSOerr(DSO_F_WIN32_LOAD,DSO_R_STACK_ERROR); | 193 | DSOerr(DSO_F_WIN32_LOAD,DSO_R_STACK_ERROR); |
| 186 | goto err; | 194 | goto err; |
| @@ -207,9 +215,9 @@ static int win32_unload(DSO *dso) | |||
| 207 | DSOerr(DSO_F_WIN32_UNLOAD,ERR_R_PASSED_NULL_PARAMETER); | 215 | DSOerr(DSO_F_WIN32_UNLOAD,ERR_R_PASSED_NULL_PARAMETER); |
| 208 | return(0); | 216 | return(0); |
| 209 | } | 217 | } |
| 210 | if(sk_num(dso->meth_data) < 1) | 218 | if(sk_void_num(dso->meth_data) < 1) |
| 211 | return(1); | 219 | return(1); |
| 212 | p = (HINSTANCE *)sk_pop(dso->meth_data); | 220 | p = sk_void_pop(dso->meth_data); |
| 213 | if(p == NULL) | 221 | if(p == NULL) |
| 214 | { | 222 | { |
| 215 | DSOerr(DSO_F_WIN32_UNLOAD,DSO_R_NULL_HANDLE); | 223 | DSOerr(DSO_F_WIN32_UNLOAD,DSO_R_NULL_HANDLE); |
| @@ -220,7 +228,7 @@ static int win32_unload(DSO *dso) | |||
| 220 | DSOerr(DSO_F_WIN32_UNLOAD,DSO_R_UNLOAD_FAILED); | 228 | DSOerr(DSO_F_WIN32_UNLOAD,DSO_R_UNLOAD_FAILED); |
| 221 | /* We should push the value back onto the stack in | 229 | /* We should push the value back onto the stack in |
| 222 | * case of a retry. */ | 230 | * case of a retry. */ |
| 223 | sk_push(dso->meth_data, (char *)p); | 231 | sk_void_push(dso->meth_data, p); |
| 224 | return(0); | 232 | return(0); |
| 225 | } | 233 | } |
| 226 | /* Cleanup */ | 234 | /* Cleanup */ |
| @@ -240,12 +248,12 @@ static void *win32_bind_var(DSO *dso, const char *symname) | |||
| 240 | DSOerr(DSO_F_WIN32_BIND_VAR,ERR_R_PASSED_NULL_PARAMETER); | 248 | DSOerr(DSO_F_WIN32_BIND_VAR,ERR_R_PASSED_NULL_PARAMETER); |
| 241 | return(NULL); | 249 | return(NULL); |
| 242 | } | 250 | } |
| 243 | if(sk_num(dso->meth_data) < 1) | 251 | if(sk_void_num(dso->meth_data) < 1) |
| 244 | { | 252 | { |
| 245 | DSOerr(DSO_F_WIN32_BIND_VAR,DSO_R_STACK_ERROR); | 253 | DSOerr(DSO_F_WIN32_BIND_VAR,DSO_R_STACK_ERROR); |
| 246 | return(NULL); | 254 | return(NULL); |
| 247 | } | 255 | } |
| 248 | ptr = (HINSTANCE *)sk_value(dso->meth_data, sk_num(dso->meth_data) - 1); | 256 | ptr = sk_void_value(dso->meth_data, sk_void_num(dso->meth_data) - 1); |
| 249 | if(ptr == NULL) | 257 | if(ptr == NULL) |
| 250 | { | 258 | { |
| 251 | DSOerr(DSO_F_WIN32_BIND_VAR,DSO_R_NULL_HANDLE); | 259 | DSOerr(DSO_F_WIN32_BIND_VAR,DSO_R_NULL_HANDLE); |
| @@ -271,12 +279,12 @@ static DSO_FUNC_TYPE win32_bind_func(DSO *dso, const char *symname) | |||
| 271 | DSOerr(DSO_F_WIN32_BIND_FUNC,ERR_R_PASSED_NULL_PARAMETER); | 279 | DSOerr(DSO_F_WIN32_BIND_FUNC,ERR_R_PASSED_NULL_PARAMETER); |
| 272 | return(NULL); | 280 | return(NULL); |
| 273 | } | 281 | } |
| 274 | if(sk_num(dso->meth_data) < 1) | 282 | if(sk_void_num(dso->meth_data) < 1) |
| 275 | { | 283 | { |
| 276 | DSOerr(DSO_F_WIN32_BIND_FUNC,DSO_R_STACK_ERROR); | 284 | DSOerr(DSO_F_WIN32_BIND_FUNC,DSO_R_STACK_ERROR); |
| 277 | return(NULL); | 285 | return(NULL); |
| 278 | } | 286 | } |
| 279 | ptr = (HINSTANCE *)sk_value(dso->meth_data, sk_num(dso->meth_data) - 1); | 287 | ptr = sk_void_value(dso->meth_data, sk_void_num(dso->meth_data) - 1); |
| 280 | if(ptr == NULL) | 288 | if(ptr == NULL) |
| 281 | { | 289 | { |
| 282 | DSOerr(DSO_F_WIN32_BIND_FUNC,DSO_R_NULL_HANDLE); | 290 | DSOerr(DSO_F_WIN32_BIND_FUNC,DSO_R_NULL_HANDLE); |
| @@ -327,8 +335,8 @@ static struct file_st *win32_splitter(DSO *dso, const char *filename, | |||
| 327 | memset(result, 0, sizeof(struct file_st)); | 335 | memset(result, 0, sizeof(struct file_st)); |
| 328 | position = IN_DEVICE; | 336 | position = IN_DEVICE; |
| 329 | 337 | ||
| 330 | if(filename[0] == '\\' && filename[1] == '\\' | 338 | if((filename[0] == '\\' && filename[1] == '\\') |
| 331 | || filename[0] == '/' && filename[1] == '/') | 339 | || (filename[0] == '/' && filename[1] == '/')) |
| 332 | { | 340 | { |
| 333 | position = IN_NODE; | 341 | position = IN_NODE; |
| 334 | filename += 2; | 342 | filename += 2; |
| @@ -347,10 +355,11 @@ static struct file_st *win32_splitter(DSO *dso, const char *filename, | |||
| 347 | DSOerr(DSO_F_WIN32_SPLITTER, | 355 | DSOerr(DSO_F_WIN32_SPLITTER, |
| 348 | DSO_R_INCORRECT_FILE_SYNTAX); | 356 | DSO_R_INCORRECT_FILE_SYNTAX); |
| 349 | /*goto err;*/ | 357 | /*goto err;*/ |
| 358 | OPENSSL_free(result); | ||
| 350 | return(NULL); | 359 | return(NULL); |
| 351 | } | 360 | } |
| 352 | result->device = start; | 361 | result->device = start; |
| 353 | result->devicelen = filename - start; | 362 | result->devicelen = (int)(filename - start); |
| 354 | position = IN_FILE; | 363 | position = IN_FILE; |
| 355 | start = ++filename; | 364 | start = ++filename; |
| 356 | result->dir = start; | 365 | result->dir = start; |
| @@ -359,7 +368,7 @@ static struct file_st *win32_splitter(DSO *dso, const char *filename, | |||
| 359 | case '/': | 368 | case '/': |
| 360 | if(position == IN_NODE) | 369 | if(position == IN_NODE) |
| 361 | { | 370 | { |
| 362 | result->nodelen = filename - start; | 371 | result->nodelen = (int)(filename - start); |
| 363 | position = IN_FILE; | 372 | position = IN_FILE; |
| 364 | start = ++filename; | 373 | start = ++filename; |
| 365 | result->dir = start; | 374 | result->dir = start; |
| @@ -369,20 +378,20 @@ static struct file_st *win32_splitter(DSO *dso, const char *filename, | |||
| 369 | position = IN_FILE; | 378 | position = IN_FILE; |
| 370 | filename++; | 379 | filename++; |
| 371 | result->dir = start; | 380 | result->dir = start; |
| 372 | result->dirlen = filename - start; | 381 | result->dirlen = (int)(filename - start); |
| 373 | start = filename; | 382 | start = filename; |
| 374 | } | 383 | } |
| 375 | else | 384 | else |
| 376 | { | 385 | { |
| 377 | filename++; | 386 | filename++; |
| 378 | result->dirlen += filename - start; | 387 | result->dirlen += (int)(filename - start); |
| 379 | start = filename; | 388 | start = filename; |
| 380 | } | 389 | } |
| 381 | break; | 390 | break; |
| 382 | case '\0': | 391 | case '\0': |
| 383 | if(position == IN_NODE) | 392 | if(position == IN_NODE) |
| 384 | { | 393 | { |
| 385 | result->nodelen = filename - start; | 394 | result->nodelen = (int)(filename - start); |
| 386 | } | 395 | } |
| 387 | else | 396 | else |
| 388 | { | 397 | { |
| @@ -396,13 +405,13 @@ static struct file_st *win32_splitter(DSO *dso, const char *filename, | |||
| 396 | result->dirlen = 0; | 405 | result->dirlen = 0; |
| 397 | } | 406 | } |
| 398 | result->dirlen += | 407 | result->dirlen += |
| 399 | filename - start; | 408 | (int)(filename - start); |
| 400 | } | 409 | } |
| 401 | else | 410 | else |
| 402 | { | 411 | { |
| 403 | result->file = start; | 412 | result->file = start; |
| 404 | result->filelen = | 413 | result->filelen = |
| 405 | filename - start; | 414 | (int)(filename - start); |
| 406 | } | 415 | } |
| 407 | } | 416 | } |
| 408 | } | 417 | } |
| @@ -496,7 +505,7 @@ static char *win32_joiner(DSO *dso, const struct file_st *file_split) | |||
| 496 | + file_split->predirlen | 505 | + file_split->predirlen |
| 497 | - (start - file_split->predir); | 506 | - (start - file_split->predir); |
| 498 | strncpy(&result[offset], start, | 507 | strncpy(&result[offset], start, |
| 499 | end - start); offset += end - start; | 508 | end - start); offset += (int)(end - start); |
| 500 | result[offset] = '\\'; offset++; | 509 | result[offset] = '\\'; offset++; |
| 501 | start = end + 1; | 510 | start = end + 1; |
| 502 | } | 511 | } |
| @@ -517,7 +526,7 @@ static char *win32_joiner(DSO *dso, const struct file_st *file_split) | |||
| 517 | + file_split->dirlen | 526 | + file_split->dirlen |
| 518 | - (start - file_split->dir); | 527 | - (start - file_split->dir); |
| 519 | strncpy(&result[offset], start, | 528 | strncpy(&result[offset], start, |
| 520 | end - start); offset += end - start; | 529 | end - start); offset += (int)(end - start); |
| 521 | result[offset] = '\\'; offset++; | 530 | result[offset] = '\\'; offset++; |
| 522 | start = end + 1; | 531 | start = end + 1; |
| 523 | } | 532 | } |
| @@ -613,6 +622,8 @@ static char *win32_merger(DSO *dso, const char *filespec1, const char *filespec2 | |||
| 613 | 622 | ||
| 614 | merged = win32_joiner(dso, filespec1_split); | 623 | merged = win32_joiner(dso, filespec1_split); |
| 615 | } | 624 | } |
| 625 | OPENSSL_free(filespec1_split); | ||
| 626 | OPENSSL_free(filespec2_split); | ||
| 616 | return(merged); | 627 | return(merged); |
| 617 | } | 628 | } |
| 618 | 629 | ||
| @@ -656,5 +667,178 @@ static const char *openssl_strnchr(const char *string, int c, size_t len) | |||
| 656 | return NULL; | 667 | return NULL; |
| 657 | } | 668 | } |
| 658 | 669 | ||
| 670 | #include <tlhelp32.h> | ||
| 671 | #ifdef _WIN32_WCE | ||
| 672 | # define DLLNAME "TOOLHELP.DLL" | ||
| 673 | #else | ||
| 674 | # ifdef MODULEENTRY32 | ||
| 675 | # undef MODULEENTRY32 /* unmask the ASCII version! */ | ||
| 676 | # endif | ||
| 677 | # define DLLNAME "KERNEL32.DLL" | ||
| 678 | #endif | ||
| 679 | |||
| 680 | typedef HANDLE (WINAPI *CREATETOOLHELP32SNAPSHOT)(DWORD, DWORD); | ||
| 681 | typedef BOOL (WINAPI *CLOSETOOLHELP32SNAPSHOT)(HANDLE); | ||
| 682 | typedef BOOL (WINAPI *MODULE32)(HANDLE, MODULEENTRY32 *); | ||
| 659 | 683 | ||
| 660 | #endif /* OPENSSL_SYS_WIN32 */ | 684 | static int win32_pathbyaddr(void *addr,char *path,int sz) |
| 685 | { | ||
| 686 | HMODULE dll; | ||
| 687 | HANDLE hModuleSnap = INVALID_HANDLE_VALUE; | ||
| 688 | MODULEENTRY32 me32; | ||
| 689 | CREATETOOLHELP32SNAPSHOT create_snap; | ||
| 690 | CLOSETOOLHELP32SNAPSHOT close_snap; | ||
| 691 | MODULE32 module_first, module_next; | ||
| 692 | int len; | ||
| 693 | |||
| 694 | if (addr == NULL) | ||
| 695 | { | ||
| 696 | union { int(*f)(void*,char*,int); void *p; } t = | ||
| 697 | { win32_pathbyaddr }; | ||
| 698 | addr = t.p; | ||
| 699 | } | ||
| 700 | |||
| 701 | dll = LoadLibrary(TEXT(DLLNAME)); | ||
| 702 | if (dll == NULL) | ||
| 703 | { | ||
| 704 | DSOerr(DSO_F_WIN32_PATHBYADDR,DSO_R_UNSUPPORTED); | ||
| 705 | return -1; | ||
| 706 | } | ||
| 707 | |||
| 708 | create_snap = (CREATETOOLHELP32SNAPSHOT) | ||
| 709 | GetProcAddress(dll,"CreateToolhelp32Snapshot"); | ||
| 710 | if (create_snap == NULL) | ||
| 711 | { | ||
| 712 | FreeLibrary(dll); | ||
| 713 | DSOerr(DSO_F_WIN32_PATHBYADDR,DSO_R_UNSUPPORTED); | ||
| 714 | return -1; | ||
| 715 | } | ||
| 716 | /* We take the rest for granted... */ | ||
| 717 | #ifdef _WIN32_WCE | ||
| 718 | close_snap = (CLOSETOOLHELP32SNAPSHOT) | ||
| 719 | GetProcAddress(dll,"CloseToolhelp32Snapshot"); | ||
| 720 | #else | ||
| 721 | close_snap = (CLOSETOOLHELP32SNAPSHOT)CloseHandle; | ||
| 722 | #endif | ||
| 723 | module_first = (MODULE32)GetProcAddress(dll,"Module32First"); | ||
| 724 | module_next = (MODULE32)GetProcAddress(dll,"Module32Next"); | ||
| 725 | |||
| 726 | hModuleSnap = (*create_snap)(TH32CS_SNAPMODULE,0); | ||
| 727 | if( hModuleSnap == INVALID_HANDLE_VALUE ) | ||
| 728 | { | ||
| 729 | FreeLibrary(dll); | ||
| 730 | DSOerr(DSO_F_WIN32_PATHBYADDR,DSO_R_UNSUPPORTED); | ||
| 731 | return -1; | ||
| 732 | } | ||
| 733 | |||
| 734 | me32.dwSize = sizeof(me32); | ||
| 735 | |||
| 736 | if(!(*module_first)(hModuleSnap,&me32)) | ||
| 737 | { | ||
| 738 | (*close_snap)(hModuleSnap); | ||
| 739 | FreeLibrary(dll); | ||
| 740 | DSOerr(DSO_F_WIN32_PATHBYADDR,DSO_R_FAILURE); | ||
| 741 | return -1; | ||
| 742 | } | ||
| 743 | |||
| 744 | do { | ||
| 745 | if ((BYTE *)addr >= me32.modBaseAddr && | ||
| 746 | (BYTE *)addr < me32.modBaseAddr+me32.modBaseSize) | ||
| 747 | { | ||
| 748 | (*close_snap)(hModuleSnap); | ||
| 749 | FreeLibrary(dll); | ||
| 750 | #ifdef _WIN32_WCE | ||
| 751 | # if _WIN32_WCE >= 101 | ||
| 752 | return WideCharToMultiByte(CP_ACP,0,me32.szExePath,-1, | ||
| 753 | path,sz,NULL,NULL); | ||
| 754 | # else | ||
| 755 | len = (int)wcslen(me32.szExePath); | ||
| 756 | if (sz <= 0) return len+1; | ||
| 757 | if (len >= sz) len=sz-1; | ||
| 758 | for(i=0;i<len;i++) | ||
| 759 | path[i] = (char)me32.szExePath[i]; | ||
| 760 | path[len++] = 0; | ||
| 761 | return len; | ||
| 762 | # endif | ||
| 763 | #else | ||
| 764 | len = (int)strlen(me32.szExePath); | ||
| 765 | if (sz <= 0) return len+1; | ||
| 766 | if (len >= sz) len=sz-1; | ||
| 767 | memcpy(path,me32.szExePath,len); | ||
| 768 | path[len++] = 0; | ||
| 769 | return len; | ||
| 770 | #endif | ||
| 771 | } | ||
| 772 | } while((*module_next)(hModuleSnap, &me32)); | ||
| 773 | |||
| 774 | (*close_snap)(hModuleSnap); | ||
| 775 | FreeLibrary(dll); | ||
| 776 | return 0; | ||
| 777 | } | ||
| 778 | |||
| 779 | static void *win32_globallookup(const char *name) | ||
| 780 | { | ||
| 781 | HMODULE dll; | ||
| 782 | HANDLE hModuleSnap = INVALID_HANDLE_VALUE; | ||
| 783 | MODULEENTRY32 me32; | ||
| 784 | CREATETOOLHELP32SNAPSHOT create_snap; | ||
| 785 | CLOSETOOLHELP32SNAPSHOT close_snap; | ||
| 786 | MODULE32 module_first, module_next; | ||
| 787 | FARPROC ret=NULL; | ||
| 788 | |||
| 789 | dll = LoadLibrary(TEXT(DLLNAME)); | ||
| 790 | if (dll == NULL) | ||
| 791 | { | ||
| 792 | DSOerr(DSO_F_WIN32_GLOBALLOOKUP,DSO_R_UNSUPPORTED); | ||
| 793 | return NULL; | ||
| 794 | } | ||
| 795 | |||
| 796 | create_snap = (CREATETOOLHELP32SNAPSHOT) | ||
| 797 | GetProcAddress(dll,"CreateToolhelp32Snapshot"); | ||
| 798 | if (create_snap == NULL) | ||
| 799 | { | ||
| 800 | FreeLibrary(dll); | ||
| 801 | DSOerr(DSO_F_WIN32_GLOBALLOOKUP,DSO_R_UNSUPPORTED); | ||
| 802 | return NULL; | ||
| 803 | } | ||
| 804 | /* We take the rest for granted... */ | ||
| 805 | #ifdef _WIN32_WCE | ||
| 806 | close_snap = (CLOSETOOLHELP32SNAPSHOT) | ||
| 807 | GetProcAddress(dll,"CloseToolhelp32Snapshot"); | ||
| 808 | #else | ||
| 809 | close_snap = (CLOSETOOLHELP32SNAPSHOT)CloseHandle; | ||
| 810 | #endif | ||
| 811 | module_first = (MODULE32)GetProcAddress(dll,"Module32First"); | ||
| 812 | module_next = (MODULE32)GetProcAddress(dll,"Module32Next"); | ||
| 813 | |||
| 814 | hModuleSnap = (*create_snap)(TH32CS_SNAPMODULE,0); | ||
| 815 | if( hModuleSnap == INVALID_HANDLE_VALUE ) | ||
| 816 | { | ||
| 817 | FreeLibrary(dll); | ||
| 818 | DSOerr(DSO_F_WIN32_GLOBALLOOKUP,DSO_R_UNSUPPORTED); | ||
| 819 | return NULL; | ||
| 820 | } | ||
| 821 | |||
| 822 | me32.dwSize = sizeof(me32); | ||
| 823 | |||
| 824 | if (!(*module_first)(hModuleSnap,&me32)) | ||
| 825 | { | ||
| 826 | (*close_snap)(hModuleSnap); | ||
| 827 | FreeLibrary(dll); | ||
| 828 | return NULL; | ||
| 829 | } | ||
| 830 | |||
| 831 | do { | ||
| 832 | if ((ret = GetProcAddress(me32.hModule,name))) | ||
| 833 | { | ||
| 834 | (*close_snap)(hModuleSnap); | ||
| 835 | FreeLibrary(dll); | ||
| 836 | return ret; | ||
| 837 | } | ||
| 838 | } while((*module_next)(hModuleSnap,&me32)); | ||
| 839 | |||
| 840 | (*close_snap)(hModuleSnap); | ||
| 841 | FreeLibrary(dll); | ||
| 842 | return NULL; | ||
| 843 | } | ||
| 844 | #endif /* DSO_WIN32 */ | ||
