diff options
Diffstat (limited to 'src/lib/libcrypto/dso')
| -rw-r--r-- | src/lib/libcrypto/dso/dso.h | 386 | ||||
| -rw-r--r-- | src/lib/libcrypto/dso/dso_dlfcn.c | 355 | ||||
| -rw-r--r-- | src/lib/libcrypto/dso/dso_err.c | 159 | ||||
| -rw-r--r-- | src/lib/libcrypto/dso/dso_lib.c | 454 | ||||
| -rw-r--r-- | src/lib/libcrypto/dso/dso_null.c | 74 | ||||
| -rw-r--r-- | src/lib/libcrypto/dso/dso_openssl.c | 75 |
6 files changed, 0 insertions, 1503 deletions
diff --git a/src/lib/libcrypto/dso/dso.h b/src/lib/libcrypto/dso/dso.h deleted file mode 100644 index 42de08089e..0000000000 --- a/src/lib/libcrypto/dso/dso.h +++ /dev/null | |||
| @@ -1,386 +0,0 @@ | |||
| 1 | /* $OpenBSD: dso.h,v 1.11 2015/02/07 13:19:15 doug Exp $ */ | ||
| 2 | /* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL | ||
| 3 | * project 2000. | ||
| 4 | */ | ||
| 5 | /* ==================================================================== | ||
| 6 | * Copyright (c) 2000 The OpenSSL Project. All rights reserved. | ||
| 7 | * | ||
| 8 | * Redistribution and use in source and binary forms, with or without | ||
| 9 | * modification, are permitted provided that the following conditions | ||
| 10 | * are met: | ||
| 11 | * | ||
| 12 | * 1. Redistributions of source code must retain the above copyright | ||
| 13 | * notice, this list of conditions and the following disclaimer. | ||
| 14 | * | ||
| 15 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 16 | * notice, this list of conditions and the following disclaimer in | ||
| 17 | * the documentation and/or other materials provided with the | ||
| 18 | * distribution. | ||
| 19 | * | ||
| 20 | * 3. All advertising materials mentioning features or use of this | ||
| 21 | * software must display the following acknowledgment: | ||
| 22 | * "This product includes software developed by the OpenSSL Project | ||
| 23 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" | ||
| 24 | * | ||
| 25 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
| 26 | * endorse or promote products derived from this software without | ||
| 27 | * prior written permission. For written permission, please contact | ||
| 28 | * licensing@OpenSSL.org. | ||
| 29 | * | ||
| 30 | * 5. Products derived from this software may not be called "OpenSSL" | ||
| 31 | * nor may "OpenSSL" appear in their names without prior written | ||
| 32 | * permission of the OpenSSL Project. | ||
| 33 | * | ||
| 34 | * 6. Redistributions of any form whatsoever must retain the following | ||
| 35 | * acknowledgment: | ||
| 36 | * "This product includes software developed by the OpenSSL Project | ||
| 37 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" | ||
| 38 | * | ||
| 39 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
| 40 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 41 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 42 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
| 43 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 44 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 46 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 47 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 48 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 49 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
| 50 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 51 | * ==================================================================== | ||
| 52 | * | ||
| 53 | * This product includes cryptographic software written by Eric Young | ||
| 54 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
| 55 | * Hudson (tjh@cryptsoft.com). | ||
| 56 | * | ||
| 57 | */ | ||
| 58 | |||
| 59 | #ifndef HEADER_DSO_H | ||
| 60 | #define HEADER_DSO_H | ||
| 61 | |||
| 62 | #include <openssl/crypto.h> | ||
| 63 | |||
| 64 | #ifdef __cplusplus | ||
| 65 | extern "C" { | ||
| 66 | #endif | ||
| 67 | |||
| 68 | /* These values are used as commands to DSO_ctrl() */ | ||
| 69 | #define DSO_CTRL_GET_FLAGS 1 | ||
| 70 | #define DSO_CTRL_SET_FLAGS 2 | ||
| 71 | #define DSO_CTRL_OR_FLAGS 3 | ||
| 72 | |||
| 73 | /* By default, DSO_load() will translate the provided filename into a form | ||
| 74 | * typical for the platform (more specifically the DSO_METHOD) using the | ||
| 75 | * dso_name_converter function of the method. Eg. win32 will transform "blah" | ||
| 76 | * into "blah.dll", and dlfcn will transform it into "libblah.so". The | ||
| 77 | * behaviour can be overridden by setting the name_converter callback in the DSO | ||
| 78 | * object (using DSO_set_name_converter()). This callback could even utilise | ||
| 79 | * the DSO_METHOD's converter too if it only wants to override behaviour for | ||
| 80 | * one or two possible DSO methods. However, the following flag can be set in a | ||
| 81 | * DSO to prevent *any* native name-translation at all - eg. if the caller has | ||
| 82 | * prompted the user for a path to a driver library so the filename should be | ||
| 83 | * interpreted as-is. */ | ||
| 84 | #define DSO_FLAG_NO_NAME_TRANSLATION 0x01 | ||
| 85 | /* An extra flag to give if only the extension should be added as | ||
| 86 | * translation. This is obviously only of importance on Unix and | ||
| 87 | * other operating systems where the translation also may prefix | ||
| 88 | * the name with something, like 'lib', and ignored everywhere else. | ||
| 89 | * This flag is also ignored if DSO_FLAG_NO_NAME_TRANSLATION is used | ||
| 90 | * at the same time. */ | ||
| 91 | #define DSO_FLAG_NAME_TRANSLATION_EXT_ONLY 0x02 | ||
| 92 | |||
| 93 | /* The following flag controls the translation of symbol names to upper | ||
| 94 | * case. This is currently only being implemented for OpenVMS. | ||
| 95 | */ | ||
| 96 | #define DSO_FLAG_UPCASE_SYMBOL 0x10 | ||
| 97 | |||
| 98 | /* This flag loads the library with public symbols. | ||
| 99 | * Meaning: The exported symbols of this library are public | ||
| 100 | * to all libraries loaded after this library. | ||
| 101 | * At the moment only implemented in unix. | ||
| 102 | */ | ||
| 103 | #define DSO_FLAG_GLOBAL_SYMBOLS 0x20 | ||
| 104 | |||
| 105 | |||
| 106 | typedef void (*DSO_FUNC_TYPE)(void); | ||
| 107 | |||
| 108 | typedef struct dso_st DSO; | ||
| 109 | |||
| 110 | /* The function prototype used for method functions (or caller-provided | ||
| 111 | * callbacks) that transform filenames. They are passed a DSO structure pointer | ||
| 112 | * (or NULL if they are to be used independantly of a DSO object) and a | ||
| 113 | * filename to transform. They should either return NULL (if there is an error | ||
| 114 | * condition) or a newly allocated string containing the transformed form that | ||
| 115 | * the caller will need to free with free() when done. */ | ||
| 116 | typedef char* (*DSO_NAME_CONVERTER_FUNC)(DSO *, const char *); | ||
| 117 | /* The function prototype used for method functions (or caller-provided | ||
| 118 | * callbacks) that merge two file specifications. They are passed a | ||
| 119 | * DSO structure pointer (or NULL if they are to be used independantly of | ||
| 120 | * a DSO object) and two file specifications to merge. They should | ||
| 121 | * either return NULL (if there is an error condition) or a newly allocated | ||
| 122 | * string containing the result of merging that the caller will need | ||
| 123 | * to free with free() when done. | ||
| 124 | * Here, merging means that bits and pieces are taken from each of the | ||
| 125 | * file specifications and added together in whatever fashion that is | ||
| 126 | * sensible for the DSO method in question. The only rule that really | ||
| 127 | * applies is that if the two specification contain pieces of the same | ||
| 128 | * type, the copy from the first string takes priority. One could see | ||
| 129 | * it as the first specification is the one given by the user and the | ||
| 130 | * second being a bunch of defaults to add on if they're missing in the | ||
| 131 | * first. */ | ||
| 132 | typedef char* (*DSO_MERGER_FUNC)(DSO *, const char *, const char *); | ||
| 133 | |||
| 134 | typedef struct dso_meth_st { | ||
| 135 | const char *name; | ||
| 136 | /* Loads a shared library, NB: new DSO_METHODs must ensure that a | ||
| 137 | * successful load populates the loaded_filename field, and likewise a | ||
| 138 | * successful unload frees and NULLs it out. */ | ||
| 139 | int (*dso_load)(DSO *dso); | ||
| 140 | /* Unloads a shared library */ | ||
| 141 | int (*dso_unload)(DSO *dso); | ||
| 142 | /* Binds a variable */ | ||
| 143 | void *(*dso_bind_var)(DSO *dso, const char *symname); | ||
| 144 | /* Binds a function - assumes a return type of DSO_FUNC_TYPE. | ||
| 145 | * This should be cast to the real function prototype by the | ||
| 146 | * caller. Platforms that don't have compatible representations | ||
| 147 | * for different prototypes (this is possible within ANSI C) | ||
| 148 | * are highly unlikely to have shared libraries at all, let | ||
| 149 | * alone a DSO_METHOD implemented for them. */ | ||
| 150 | DSO_FUNC_TYPE (*dso_bind_func)(DSO *dso, const char *symname); | ||
| 151 | |||
| 152 | /* The generic (yuck) "ctrl()" function. NB: Negative return | ||
| 153 | * values (rather than zero) indicate errors. */ | ||
| 154 | long (*dso_ctrl)(DSO *dso, int cmd, long larg, void *parg); | ||
| 155 | /* The default DSO_METHOD-specific function for converting filenames to | ||
| 156 | * a canonical native form. */ | ||
| 157 | DSO_NAME_CONVERTER_FUNC dso_name_converter; | ||
| 158 | /* The default DSO_METHOD-specific function for converting filenames to | ||
| 159 | * a canonical native form. */ | ||
| 160 | DSO_MERGER_FUNC dso_merger; | ||
| 161 | |||
| 162 | /* [De]Initialisation handlers. */ | ||
| 163 | int (*init)(DSO *dso); | ||
| 164 | int (*finish)(DSO *dso); | ||
| 165 | |||
| 166 | /* Return pathname of the module containing location */ | ||
| 167 | int (*pathbyaddr)(void *addr, char *path, int sz); | ||
| 168 | /* Perform global symbol lookup, i.e. among *all* modules */ | ||
| 169 | void *(*globallookup)(const char *symname); | ||
| 170 | } DSO_METHOD; | ||
| 171 | |||
| 172 | /**********************************************************************/ | ||
| 173 | /* The low-level handle type used to refer to a loaded shared library */ | ||
| 174 | |||
| 175 | struct dso_st { | ||
| 176 | DSO_METHOD *meth; | ||
| 177 | /* Standard dlopen uses a (void *). Win32 uses a HANDLE. VMS | ||
| 178 | * doesn't use anything but will need to cache the filename | ||
| 179 | * for use in the dso_bind handler. All in all, let each | ||
| 180 | * method control its own destiny. "Handles" and such go in | ||
| 181 | * a STACK. */ | ||
| 182 | STACK_OF(void) *meth_data; | ||
| 183 | int references; | ||
| 184 | int flags; | ||
| 185 | /* For use by applications etc ... use this for your bits'n'pieces, | ||
| 186 | * don't touch meth_data! */ | ||
| 187 | CRYPTO_EX_DATA ex_data; | ||
| 188 | /* If this callback function pointer is set to non-NULL, then it will | ||
| 189 | * be used in DSO_load() in place of meth->dso_name_converter. NB: This | ||
| 190 | * should normally set using DSO_set_name_converter(). */ | ||
| 191 | DSO_NAME_CONVERTER_FUNC name_converter; | ||
| 192 | /* If this callback function pointer is set to non-NULL, then it will | ||
| 193 | * be used in DSO_load() in place of meth->dso_merger. NB: This | ||
| 194 | * should normally set using DSO_set_merger(). */ | ||
| 195 | DSO_MERGER_FUNC merger; | ||
| 196 | /* This is populated with (a copy of) the platform-independant | ||
| 197 | * filename used for this DSO. */ | ||
| 198 | char *filename; | ||
| 199 | /* This is populated with (a copy of) the translated filename by which | ||
| 200 | * the DSO was actually loaded. It is NULL iff the DSO is not currently | ||
| 201 | * loaded. NB: This is here because the filename translation process | ||
| 202 | * may involve a callback being invoked more than once not only to | ||
| 203 | * convert to a platform-specific form, but also to try different | ||
| 204 | * filenames in the process of trying to perform a load. As such, this | ||
| 205 | * variable can be used to indicate (a) whether this DSO structure | ||
| 206 | * corresponds to a loaded library or not, and (b) the filename with | ||
| 207 | * which it was actually loaded. */ | ||
| 208 | char *loaded_filename; | ||
| 209 | }; | ||
| 210 | |||
| 211 | |||
| 212 | DSO * DSO_new(void); | ||
| 213 | DSO * DSO_new_method(DSO_METHOD *method); | ||
| 214 | int DSO_free(DSO *dso); | ||
| 215 | int DSO_flags(DSO *dso); | ||
| 216 | int DSO_up_ref(DSO *dso); | ||
| 217 | long DSO_ctrl(DSO *dso, int cmd, long larg, void *parg); | ||
| 218 | |||
| 219 | /* This function sets the DSO's name_converter callback. If it is non-NULL, | ||
| 220 | * then it will be used instead of the associated DSO_METHOD's function. If | ||
| 221 | * oldcb is non-NULL then it is set to the function pointer value being | ||
| 222 | * replaced. Return value is non-zero for success. */ | ||
| 223 | int DSO_set_name_converter(DSO *dso, DSO_NAME_CONVERTER_FUNC cb, | ||
| 224 | DSO_NAME_CONVERTER_FUNC *oldcb); | ||
| 225 | /* These functions can be used to get/set the platform-independant filename | ||
| 226 | * used for a DSO. NB: set will fail if the DSO is already loaded. */ | ||
| 227 | const char *DSO_get_filename(DSO *dso); | ||
| 228 | int DSO_set_filename(DSO *dso, const char *filename); | ||
| 229 | /* This function will invoke the DSO's name_converter callback to translate a | ||
| 230 | * filename, or if the callback isn't set it will instead use the DSO_METHOD's | ||
| 231 | * converter. If "filename" is NULL, the "filename" in the DSO itself will be | ||
| 232 | * used. If the DSO_FLAG_NO_NAME_TRANSLATION flag is set, then the filename is | ||
| 233 | * simply duplicated. NB: This function is usually called from within a | ||
| 234 | * DSO_METHOD during the processing of a DSO_load() call, and is exposed so that | ||
| 235 | * caller-created DSO_METHODs can do the same thing. A non-NULL return value | ||
| 236 | * will need to be free()'d. */ | ||
| 237 | char *DSO_convert_filename(DSO *dso, const char *filename); | ||
| 238 | /* This function will invoke the DSO's merger callback to merge two file | ||
| 239 | * specifications, or if the callback isn't set it will instead use the | ||
| 240 | * DSO_METHOD's merger. A non-NULL return value will need to be | ||
| 241 | * free()'d. */ | ||
| 242 | char *DSO_merge(DSO *dso, const char *filespec1, const char *filespec2); | ||
| 243 | /* If the DSO is currently loaded, this returns the filename that it was loaded | ||
| 244 | * under, otherwise it returns NULL. So it is also useful as a test as to | ||
| 245 | * whether the DSO is currently loaded. NB: This will not necessarily return | ||
| 246 | * the same value as DSO_convert_filename(dso, dso->filename), because the | ||
| 247 | * DSO_METHOD's load function may have tried a variety of filenames (with | ||
| 248 | * and/or without the aid of the converters) before settling on the one it | ||
| 249 | * actually loaded. */ | ||
| 250 | const char *DSO_get_loaded_filename(DSO *dso); | ||
| 251 | |||
| 252 | void DSO_set_default_method(DSO_METHOD *meth); | ||
| 253 | DSO_METHOD *DSO_get_default_method(void); | ||
| 254 | DSO_METHOD *DSO_get_method(DSO *dso); | ||
| 255 | DSO_METHOD *DSO_set_method(DSO *dso, DSO_METHOD *meth); | ||
| 256 | |||
| 257 | /* The all-singing all-dancing load function, you normally pass NULL | ||
| 258 | * for the first and third parameters. Use DSO_up and DSO_free for | ||
| 259 | * subsequent reference count handling. Any flags passed in will be set | ||
| 260 | * in the constructed DSO after its init() function but before the | ||
| 261 | * load operation. If 'dso' is non-NULL, 'flags' is ignored. */ | ||
| 262 | DSO *DSO_load(DSO *dso, const char *filename, DSO_METHOD *meth, int flags); | ||
| 263 | |||
| 264 | /* This function binds to a variable inside a shared library. */ | ||
| 265 | void *DSO_bind_var(DSO *dso, const char *symname); | ||
| 266 | |||
| 267 | /* This function binds to a function inside a shared library. */ | ||
| 268 | DSO_FUNC_TYPE DSO_bind_func(DSO *dso, const char *symname); | ||
| 269 | |||
| 270 | /* This method is the default, but will beg, borrow, or steal whatever | ||
| 271 | * method should be the default on any particular platform (including | ||
| 272 | * DSO_METH_null() if necessary). */ | ||
| 273 | DSO_METHOD *DSO_METHOD_openssl(void); | ||
| 274 | |||
| 275 | /* This method is defined for all platforms - if a platform has no | ||
| 276 | * DSO support then this will be the only method! */ | ||
| 277 | DSO_METHOD *DSO_METHOD_null(void); | ||
| 278 | |||
| 279 | /* If DSO_DLFCN is defined, the standard dlfcn.h-style functions | ||
| 280 | * (dlopen, dlclose, dlsym, etc) will be used and incorporated into | ||
| 281 | * this method. If not, this method will return NULL. */ | ||
| 282 | DSO_METHOD *DSO_METHOD_dlfcn(void); | ||
| 283 | |||
| 284 | /* This function writes null-terminated pathname of DSO module | ||
| 285 | * containing 'addr' into 'sz' large caller-provided 'path' and | ||
| 286 | * returns the number of characters [including trailing zero] | ||
| 287 | * written to it. If 'sz' is 0 or negative, 'path' is ignored and | ||
| 288 | * required amount of charachers [including trailing zero] to | ||
| 289 | * accomodate pathname is returned. If 'addr' is NULL, then | ||
| 290 | * pathname of cryptolib itself is returned. Negative or zero | ||
| 291 | * return value denotes error. | ||
| 292 | */ | ||
| 293 | int DSO_pathbyaddr(void *addr, char *path, int sz); | ||
| 294 | |||
| 295 | /* This function should be used with caution! It looks up symbols in | ||
| 296 | * *all* loaded modules and if module gets unloaded by somebody else | ||
| 297 | * attempt to dereference the pointer is doomed to have fatal | ||
| 298 | * consequences. Primary usage for this function is to probe *core* | ||
| 299 | * system functionality, e.g. check if getnameinfo(3) is available | ||
| 300 | * at run-time without bothering about OS-specific details such as | ||
| 301 | * libc.so.versioning or where does it actually reside: in libc | ||
| 302 | * itself or libsocket. */ | ||
| 303 | void *DSO_global_lookup(const char *name); | ||
| 304 | |||
| 305 | /* BEGIN ERROR CODES */ | ||
| 306 | /* The following lines are auto generated by the script mkerr.pl. Any changes | ||
| 307 | * made after this point may be overwritten when the script is next run. | ||
| 308 | */ | ||
| 309 | void ERR_load_DSO_strings(void); | ||
| 310 | |||
| 311 | /* Error codes for the DSO functions. */ | ||
| 312 | |||
| 313 | /* Function codes. */ | ||
| 314 | #define DSO_F_BEOS_BIND_FUNC 144 | ||
| 315 | #define DSO_F_BEOS_BIND_VAR 145 | ||
| 316 | #define DSO_F_BEOS_LOAD 146 | ||
| 317 | #define DSO_F_BEOS_NAME_CONVERTER 147 | ||
| 318 | #define DSO_F_BEOS_UNLOAD 148 | ||
| 319 | #define DSO_F_DLFCN_BIND_FUNC 100 | ||
| 320 | #define DSO_F_DLFCN_BIND_VAR 101 | ||
| 321 | #define DSO_F_DLFCN_LOAD 102 | ||
| 322 | #define DSO_F_DLFCN_MERGER 130 | ||
| 323 | #define DSO_F_DLFCN_NAME_CONVERTER 123 | ||
| 324 | #define DSO_F_DLFCN_UNLOAD 103 | ||
| 325 | #define DSO_F_DL_BIND_FUNC 104 | ||
| 326 | #define DSO_F_DL_BIND_VAR 105 | ||
| 327 | #define DSO_F_DL_LOAD 106 | ||
| 328 | #define DSO_F_DL_MERGER 131 | ||
| 329 | #define DSO_F_DL_NAME_CONVERTER 124 | ||
| 330 | #define DSO_F_DL_UNLOAD 107 | ||
| 331 | #define DSO_F_DSO_BIND_FUNC 108 | ||
| 332 | #define DSO_F_DSO_BIND_VAR 109 | ||
| 333 | #define DSO_F_DSO_CONVERT_FILENAME 126 | ||
| 334 | #define DSO_F_DSO_CTRL 110 | ||
| 335 | #define DSO_F_DSO_FREE 111 | ||
| 336 | #define DSO_F_DSO_GET_FILENAME 127 | ||
| 337 | #define DSO_F_DSO_GET_LOADED_FILENAME 128 | ||
| 338 | #define DSO_F_DSO_GLOBAL_LOOKUP 139 | ||
| 339 | #define DSO_F_DSO_LOAD 112 | ||
| 340 | #define DSO_F_DSO_MERGE 132 | ||
| 341 | #define DSO_F_DSO_NEW_METHOD 113 | ||
| 342 | #define DSO_F_DSO_PATHBYADDR 140 | ||
| 343 | #define DSO_F_DSO_SET_FILENAME 129 | ||
| 344 | #define DSO_F_DSO_SET_NAME_CONVERTER 122 | ||
| 345 | #define DSO_F_DSO_UP_REF 114 | ||
| 346 | #define DSO_F_GLOBAL_LOOKUP_FUNC 138 | ||
| 347 | #define DSO_F_PATHBYADDR 137 | ||
| 348 | #define DSO_F_VMS_BIND_SYM 115 | ||
| 349 | #define DSO_F_VMS_LOAD 116 | ||
| 350 | #define DSO_F_VMS_MERGER 133 | ||
| 351 | #define DSO_F_VMS_UNLOAD 117 | ||
| 352 | #define DSO_F_WIN32_BIND_FUNC 118 | ||
| 353 | #define DSO_F_WIN32_BIND_VAR 119 | ||
| 354 | #define DSO_F_WIN32_GLOBALLOOKUP 142 | ||
| 355 | #define DSO_F_WIN32_GLOBALLOOKUP_FUNC 143 | ||
| 356 | #define DSO_F_WIN32_JOINER 135 | ||
| 357 | #define DSO_F_WIN32_LOAD 120 | ||
| 358 | #define DSO_F_WIN32_MERGER 134 | ||
| 359 | #define DSO_F_WIN32_NAME_CONVERTER 125 | ||
| 360 | #define DSO_F_WIN32_PATHBYADDR 141 | ||
| 361 | #define DSO_F_WIN32_SPLITTER 136 | ||
| 362 | #define DSO_F_WIN32_UNLOAD 121 | ||
| 363 | |||
| 364 | /* Reason codes. */ | ||
| 365 | #define DSO_R_CTRL_FAILED 100 | ||
| 366 | #define DSO_R_DSO_ALREADY_LOADED 110 | ||
| 367 | #define DSO_R_EMPTY_FILE_STRUCTURE 113 | ||
| 368 | #define DSO_R_FAILURE 114 | ||
| 369 | #define DSO_R_FILENAME_TOO_BIG 101 | ||
| 370 | #define DSO_R_FINISH_FAILED 102 | ||
| 371 | #define DSO_R_INCORRECT_FILE_SYNTAX 115 | ||
| 372 | #define DSO_R_LOAD_FAILED 103 | ||
| 373 | #define DSO_R_NAME_TRANSLATION_FAILED 109 | ||
| 374 | #define DSO_R_NO_FILENAME 111 | ||
| 375 | #define DSO_R_NO_FILE_SPECIFICATION 116 | ||
| 376 | #define DSO_R_NULL_HANDLE 104 | ||
| 377 | #define DSO_R_SET_FILENAME_FAILED 112 | ||
| 378 | #define DSO_R_STACK_ERROR 105 | ||
| 379 | #define DSO_R_SYM_FAILURE 106 | ||
| 380 | #define DSO_R_UNLOAD_FAILED 107 | ||
| 381 | #define DSO_R_UNSUPPORTED 108 | ||
| 382 | |||
| 383 | #ifdef __cplusplus | ||
| 384 | } | ||
| 385 | #endif | ||
| 386 | #endif | ||
diff --git a/src/lib/libcrypto/dso/dso_dlfcn.c b/src/lib/libcrypto/dso/dso_dlfcn.c deleted file mode 100644 index f22e641bab..0000000000 --- a/src/lib/libcrypto/dso/dso_dlfcn.c +++ /dev/null | |||
| @@ -1,355 +0,0 @@ | |||
| 1 | /* $OpenBSD: dso_dlfcn.c,v 1.28 2015/02/07 13:19:15 doug Exp $ */ | ||
| 2 | /* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL | ||
| 3 | * project 2000. | ||
| 4 | */ | ||
| 5 | /* ==================================================================== | ||
| 6 | * Copyright (c) 2000 The OpenSSL Project. All rights reserved. | ||
| 7 | * | ||
| 8 | * Redistribution and use in source and binary forms, with or without | ||
| 9 | * modification, are permitted provided that the following conditions | ||
| 10 | * are met: | ||
| 11 | * | ||
| 12 | * 1. Redistributions of source code must retain the above copyright | ||
| 13 | * notice, this list of conditions and the following disclaimer. | ||
| 14 | * | ||
| 15 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 16 | * notice, this list of conditions and the following disclaimer in | ||
| 17 | * the documentation and/or other materials provided with the | ||
| 18 | * distribution. | ||
| 19 | * | ||
| 20 | * 3. All advertising materials mentioning features or use of this | ||
| 21 | * software must display the following acknowledgment: | ||
| 22 | * "This product includes software developed by the OpenSSL Project | ||
| 23 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" | ||
| 24 | * | ||
| 25 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
| 26 | * endorse or promote products derived from this software without | ||
| 27 | * prior written permission. For written permission, please contact | ||
| 28 | * licensing@OpenSSL.org. | ||
| 29 | * | ||
| 30 | * 5. Products derived from this software may not be called "OpenSSL" | ||
| 31 | * nor may "OpenSSL" appear in their names without prior written | ||
| 32 | * permission of the OpenSSL Project. | ||
| 33 | * | ||
| 34 | * 6. Redistributions of any form whatsoever must retain the following | ||
| 35 | * acknowledgment: | ||
| 36 | * "This product includes software developed by the OpenSSL Project | ||
| 37 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" | ||
| 38 | * | ||
| 39 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
| 40 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 41 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 42 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
| 43 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 44 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 46 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 47 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 48 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 49 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
| 50 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 51 | * ==================================================================== | ||
| 52 | * | ||
| 53 | * This product includes cryptographic software written by Eric Young | ||
| 54 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
| 55 | * Hudson (tjh@cryptsoft.com). | ||
| 56 | * | ||
| 57 | */ | ||
| 58 | |||
| 59 | #include <stdio.h> | ||
| 60 | #include <string.h> | ||
| 61 | |||
| 62 | #include <openssl/dso.h> | ||
| 63 | #include <openssl/err.h> | ||
| 64 | |||
| 65 | #ifndef DSO_DLFCN | ||
| 66 | DSO_METHOD * | ||
| 67 | DSO_METHOD_dlfcn(void) | ||
| 68 | { | ||
| 69 | return NULL; | ||
| 70 | } | ||
| 71 | #else | ||
| 72 | |||
| 73 | #ifdef HAVE_DLFCN_H | ||
| 74 | # include <dlfcn.h> | ||
| 75 | # define HAVE_DLINFO 1 | ||
| 76 | #endif | ||
| 77 | |||
| 78 | /* Part of the hack in "dlfcn_load" ... */ | ||
| 79 | #define DSO_MAX_TRANSLATED_SIZE 256 | ||
| 80 | |||
| 81 | static int dlfcn_load(DSO *dso); | ||
| 82 | static int dlfcn_unload(DSO *dso); | ||
| 83 | static void *dlfcn_bind_var(DSO *dso, const char *symname); | ||
| 84 | static DSO_FUNC_TYPE dlfcn_bind_func(DSO *dso, const char *symname); | ||
| 85 | static char *dlfcn_name_converter(DSO *dso, const char *filename); | ||
| 86 | static char *dlfcn_merger(DSO *dso, const char *filespec1, | ||
| 87 | const char *filespec2); | ||
| 88 | static int dlfcn_pathbyaddr(void *addr, char *path, int sz); | ||
| 89 | static void *dlfcn_globallookup(const char *name); | ||
| 90 | |||
| 91 | static DSO_METHOD dso_meth_dlfcn = { | ||
| 92 | .name = "OpenSSL 'dlfcn' shared library method", | ||
| 93 | .dso_load = dlfcn_load, | ||
| 94 | .dso_unload = dlfcn_unload, | ||
| 95 | .dso_bind_var = dlfcn_bind_var, | ||
| 96 | .dso_bind_func = dlfcn_bind_func, | ||
| 97 | .dso_name_converter = dlfcn_name_converter, | ||
| 98 | .dso_merger = dlfcn_merger, | ||
| 99 | .pathbyaddr = dlfcn_pathbyaddr, | ||
| 100 | .globallookup = dlfcn_globallookup | ||
| 101 | }; | ||
| 102 | |||
| 103 | DSO_METHOD * | ||
| 104 | DSO_METHOD_dlfcn(void) | ||
| 105 | { | ||
| 106 | return (&dso_meth_dlfcn); | ||
| 107 | } | ||
| 108 | |||
| 109 | /* For this DSO_METHOD, our meth_data STACK will contain; | ||
| 110 | * (i) the handle (void*) returned from dlopen(). | ||
| 111 | */ | ||
| 112 | |||
| 113 | static int | ||
| 114 | dlfcn_load(DSO *dso) | ||
| 115 | { | ||
| 116 | void *ptr = NULL; | ||
| 117 | /* See applicable comments in dso_dl.c */ | ||
| 118 | char *filename = DSO_convert_filename(dso, NULL); | ||
| 119 | int flags = RTLD_LAZY; | ||
| 120 | |||
| 121 | if (filename == NULL) { | ||
| 122 | DSOerr(DSO_F_DLFCN_LOAD, DSO_R_NO_FILENAME); | ||
| 123 | goto err; | ||
| 124 | } | ||
| 125 | |||
| 126 | if (dso->flags & DSO_FLAG_GLOBAL_SYMBOLS) | ||
| 127 | flags |= RTLD_GLOBAL; | ||
| 128 | ptr = dlopen(filename, flags); | ||
| 129 | if (ptr == NULL) { | ||
| 130 | DSOerr(DSO_F_DLFCN_LOAD, DSO_R_LOAD_FAILED); | ||
| 131 | ERR_asprintf_error_data("filename(%s): %s", filename, | ||
| 132 | dlerror()); | ||
| 133 | goto err; | ||
| 134 | } | ||
| 135 | if (!sk_void_push(dso->meth_data, (char *)ptr)) { | ||
| 136 | DSOerr(DSO_F_DLFCN_LOAD, DSO_R_STACK_ERROR); | ||
| 137 | goto err; | ||
| 138 | } | ||
| 139 | /* Success */ | ||
| 140 | dso->loaded_filename = filename; | ||
| 141 | return (1); | ||
| 142 | |||
| 143 | err: | ||
| 144 | /* Cleanup! */ | ||
| 145 | free(filename); | ||
| 146 | if (ptr != NULL) | ||
| 147 | dlclose(ptr); | ||
| 148 | return (0); | ||
| 149 | } | ||
| 150 | |||
| 151 | static int | ||
| 152 | dlfcn_unload(DSO *dso) | ||
| 153 | { | ||
| 154 | void *ptr; | ||
| 155 | if (dso == NULL) { | ||
| 156 | DSOerr(DSO_F_DLFCN_UNLOAD, ERR_R_PASSED_NULL_PARAMETER); | ||
| 157 | return (0); | ||
| 158 | } | ||
| 159 | if (sk_void_num(dso->meth_data) < 1) | ||
| 160 | return (1); | ||
| 161 | ptr = sk_void_pop(dso->meth_data); | ||
| 162 | if (ptr == NULL) { | ||
| 163 | DSOerr(DSO_F_DLFCN_UNLOAD, DSO_R_NULL_HANDLE); | ||
| 164 | /* Should push the value back onto the stack in | ||
| 165 | * case of a retry. */ | ||
| 166 | sk_void_push(dso->meth_data, ptr); | ||
| 167 | return (0); | ||
| 168 | } | ||
| 169 | /* For now I'm not aware of any errors associated with dlclose() */ | ||
| 170 | dlclose(ptr); | ||
| 171 | return (1); | ||
| 172 | } | ||
| 173 | |||
| 174 | static void * | ||
| 175 | dlfcn_bind_var(DSO *dso, const char *symname) | ||
| 176 | { | ||
| 177 | void *ptr, *sym; | ||
| 178 | |||
| 179 | if ((dso == NULL) || (symname == NULL)) { | ||
| 180 | DSOerr(DSO_F_DLFCN_BIND_VAR, ERR_R_PASSED_NULL_PARAMETER); | ||
| 181 | return (NULL); | ||
| 182 | } | ||
| 183 | if (sk_void_num(dso->meth_data) < 1) { | ||
| 184 | DSOerr(DSO_F_DLFCN_BIND_VAR, DSO_R_STACK_ERROR); | ||
| 185 | return (NULL); | ||
| 186 | } | ||
| 187 | ptr = sk_void_value(dso->meth_data, sk_void_num(dso->meth_data) - 1); | ||
| 188 | if (ptr == NULL) { | ||
| 189 | DSOerr(DSO_F_DLFCN_BIND_VAR, DSO_R_NULL_HANDLE); | ||
| 190 | return (NULL); | ||
| 191 | } | ||
| 192 | sym = dlsym(ptr, symname); | ||
| 193 | if (sym == NULL) { | ||
| 194 | DSOerr(DSO_F_DLFCN_BIND_VAR, DSO_R_SYM_FAILURE); | ||
| 195 | ERR_asprintf_error_data("symname(%s): %s", symname, dlerror()); | ||
| 196 | return (NULL); | ||
| 197 | } | ||
| 198 | return (sym); | ||
| 199 | } | ||
| 200 | |||
| 201 | static DSO_FUNC_TYPE | ||
| 202 | dlfcn_bind_func(DSO *dso, const char *symname) | ||
| 203 | { | ||
| 204 | void *ptr; | ||
| 205 | union { | ||
| 206 | DSO_FUNC_TYPE sym; | ||
| 207 | void *dlret; | ||
| 208 | } u; | ||
| 209 | |||
| 210 | if ((dso == NULL) || (symname == NULL)) { | ||
| 211 | DSOerr(DSO_F_DLFCN_BIND_FUNC, ERR_R_PASSED_NULL_PARAMETER); | ||
| 212 | return (NULL); | ||
| 213 | } | ||
| 214 | if (sk_void_num(dso->meth_data) < 1) { | ||
| 215 | DSOerr(DSO_F_DLFCN_BIND_FUNC, DSO_R_STACK_ERROR); | ||
| 216 | return (NULL); | ||
| 217 | } | ||
| 218 | ptr = sk_void_value(dso->meth_data, sk_void_num(dso->meth_data) - 1); | ||
| 219 | if (ptr == NULL) { | ||
| 220 | DSOerr(DSO_F_DLFCN_BIND_FUNC, DSO_R_NULL_HANDLE); | ||
| 221 | return (NULL); | ||
| 222 | } | ||
| 223 | u.dlret = dlsym(ptr, symname); | ||
| 224 | if (u.dlret == NULL) { | ||
| 225 | DSOerr(DSO_F_DLFCN_BIND_FUNC, DSO_R_SYM_FAILURE); | ||
| 226 | ERR_asprintf_error_data("symname(%s): %s", symname, dlerror()); | ||
| 227 | return (NULL); | ||
| 228 | } | ||
| 229 | return u.sym; | ||
| 230 | } | ||
| 231 | |||
| 232 | static char * | ||
| 233 | dlfcn_merger(DSO *dso, const char *filespec1, const char *filespec2) | ||
| 234 | { | ||
| 235 | char *merged; | ||
| 236 | |||
| 237 | if (!filespec1 && !filespec2) { | ||
| 238 | DSOerr(DSO_F_DLFCN_MERGER, | ||
| 239 | ERR_R_PASSED_NULL_PARAMETER); | ||
| 240 | return (NULL); | ||
| 241 | } | ||
| 242 | /* If the first file specification is a rooted path, it rules. | ||
| 243 | same goes if the second file specification is missing. */ | ||
| 244 | if (!filespec2 || (filespec1 != NULL && filespec1[0] == '/')) { | ||
| 245 | merged = strdup(filespec1); | ||
| 246 | if (!merged) { | ||
| 247 | DSOerr(DSO_F_DLFCN_MERGER, ERR_R_MALLOC_FAILURE); | ||
| 248 | return (NULL); | ||
| 249 | } | ||
| 250 | } | ||
| 251 | /* If the first file specification is missing, the second one rules. */ | ||
| 252 | else if (!filespec1) { | ||
| 253 | merged = strdup(filespec2); | ||
| 254 | if (!merged) { | ||
| 255 | DSOerr(DSO_F_DLFCN_MERGER, ERR_R_MALLOC_FAILURE); | ||
| 256 | return (NULL); | ||
| 257 | } | ||
| 258 | } else | ||
| 259 | /* This part isn't as trivial as it looks. It assumes that | ||
| 260 | the second file specification really is a directory, and | ||
| 261 | makes no checks whatsoever. Therefore, the result becomes | ||
| 262 | the concatenation of filespec2 followed by a slash followed | ||
| 263 | by filespec1. */ | ||
| 264 | { | ||
| 265 | size_t spec2len, len; | ||
| 266 | |||
| 267 | spec2len = strlen(filespec2); | ||
| 268 | len = spec2len + (filespec1 ? strlen(filespec1) : 0); | ||
| 269 | |||
| 270 | if (filespec2 && filespec2[spec2len - 1] == '/') { | ||
| 271 | spec2len--; | ||
| 272 | len--; | ||
| 273 | } | ||
| 274 | merged = malloc(len + 2); | ||
| 275 | if (!merged) { | ||
| 276 | DSOerr(DSO_F_DLFCN_MERGER, ERR_R_MALLOC_FAILURE); | ||
| 277 | return (NULL); | ||
| 278 | } | ||
| 279 | strlcpy(merged, filespec2, len + 2); | ||
| 280 | merged[spec2len] = '/'; | ||
| 281 | strlcpy(&merged[spec2len + 1], filespec1, len + 1 - spec2len); | ||
| 282 | } | ||
| 283 | return (merged); | ||
| 284 | } | ||
| 285 | |||
| 286 | #define DSO_ext ".so" | ||
| 287 | #define DSO_extlen 3 | ||
| 288 | |||
| 289 | static char * | ||
| 290 | dlfcn_name_converter(DSO *dso, const char *filename) | ||
| 291 | { | ||
| 292 | char *translated; | ||
| 293 | int ret; | ||
| 294 | |||
| 295 | if (strchr(filename, '/') == NULL) { | ||
| 296 | /* Bare name, so convert to "%s.so" or "lib%s.so" */ | ||
| 297 | if ((DSO_flags(dso) & DSO_FLAG_NAME_TRANSLATION_EXT_ONLY) == 0) | ||
| 298 | ret = asprintf(&translated, "lib%s" DSO_ext, filename); | ||
| 299 | else | ||
| 300 | ret = asprintf(&translated, "%s" DSO_ext, filename); | ||
| 301 | if (ret == -1) | ||
| 302 | translated = NULL; | ||
| 303 | } else { | ||
| 304 | /* Full path, so just duplicate it */ | ||
| 305 | translated = strdup(filename); | ||
| 306 | } | ||
| 307 | |||
| 308 | if (translated == NULL) | ||
| 309 | DSOerr(DSO_F_DLFCN_NAME_CONVERTER, | ||
| 310 | DSO_R_NAME_TRANSLATION_FAILED); | ||
| 311 | return (translated); | ||
| 312 | } | ||
| 313 | |||
| 314 | static int | ||
| 315 | dlfcn_pathbyaddr(void *addr, char *path, int sz) | ||
| 316 | { | ||
| 317 | Dl_info dli; | ||
| 318 | int len; | ||
| 319 | |||
| 320 | if (addr == NULL) { | ||
| 321 | union{ | ||
| 322 | int(*f)(void*, char*, int); | ||
| 323 | void *p; | ||
| 324 | } t = { dlfcn_pathbyaddr }; | ||
| 325 | addr = t.p; | ||
| 326 | } | ||
| 327 | |||
| 328 | if (dladdr(addr, &dli)) { | ||
| 329 | len = (int)strlen(dli.dli_fname); | ||
| 330 | if (sz <= 0) | ||
| 331 | return len + 1; | ||
| 332 | if (len >= sz) | ||
| 333 | len = sz - 1; | ||
| 334 | memcpy(path, dli.dli_fname, len); | ||
| 335 | path[len++] = 0; | ||
| 336 | return len; | ||
| 337 | } | ||
| 338 | |||
| 339 | ERR_asprintf_error_data("dlfcn_pathbyaddr(): %s", dlerror()); | ||
| 340 | return -1; | ||
| 341 | } | ||
| 342 | |||
| 343 | static void * | ||
| 344 | dlfcn_globallookup(const char *name) | ||
| 345 | { | ||
| 346 | void *ret = NULL, *handle = dlopen(NULL, RTLD_LAZY); | ||
| 347 | |||
| 348 | if (handle) { | ||
| 349 | ret = dlsym(handle, name); | ||
| 350 | dlclose(handle); | ||
| 351 | } | ||
| 352 | |||
| 353 | return ret; | ||
| 354 | } | ||
| 355 | #endif /* DSO_DLFCN */ | ||
diff --git a/src/lib/libcrypto/dso/dso_err.c b/src/lib/libcrypto/dso/dso_err.c deleted file mode 100644 index b8514a4aef..0000000000 --- a/src/lib/libcrypto/dso/dso_err.c +++ /dev/null | |||
| @@ -1,159 +0,0 @@ | |||
| 1 | /* $OpenBSD: dso_err.c,v 1.8 2014/07/10 22:45:56 jsing Exp $ */ | ||
| 2 | /* ==================================================================== | ||
| 3 | * Copyright (c) 1999-2006 The OpenSSL Project. All rights reserved. | ||
| 4 | * | ||
| 5 | * Redistribution and use in source and binary forms, with or without | ||
| 6 | * modification, are permitted provided that the following conditions | ||
| 7 | * are met: | ||
| 8 | * | ||
| 9 | * 1. Redistributions of source code must retain the above copyright | ||
| 10 | * notice, this list of conditions and the following disclaimer. | ||
| 11 | * | ||
| 12 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 13 | * notice, this list of conditions and the following disclaimer in | ||
| 14 | * the documentation and/or other materials provided with the | ||
| 15 | * distribution. | ||
| 16 | * | ||
| 17 | * 3. All advertising materials mentioning features or use of this | ||
| 18 | * software must display the following acknowledgment: | ||
| 19 | * "This product includes software developed by the OpenSSL Project | ||
| 20 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" | ||
| 21 | * | ||
| 22 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
| 23 | * endorse or promote products derived from this software without | ||
| 24 | * prior written permission. For written permission, please contact | ||
| 25 | * openssl-core@OpenSSL.org. | ||
| 26 | * | ||
| 27 | * 5. Products derived from this software may not be called "OpenSSL" | ||
| 28 | * nor may "OpenSSL" appear in their names without prior written | ||
| 29 | * permission of the OpenSSL Project. | ||
| 30 | * | ||
| 31 | * 6. Redistributions of any form whatsoever must retain the following | ||
| 32 | * acknowledgment: | ||
| 33 | * "This product includes software developed by the OpenSSL Project | ||
| 34 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" | ||
| 35 | * | ||
| 36 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
| 37 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 38 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 39 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
| 40 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 41 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 42 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 43 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 44 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 45 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 46 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
| 47 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 48 | * ==================================================================== | ||
| 49 | * | ||
| 50 | * This product includes cryptographic software written by Eric Young | ||
| 51 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
| 52 | * Hudson (tjh@cryptsoft.com). | ||
| 53 | * | ||
| 54 | */ | ||
| 55 | |||
| 56 | /* NOTE: this file was auto generated by the mkerr.pl script: any changes | ||
| 57 | * made to it will be overwritten when the script next updates this file, | ||
| 58 | * only reason strings will be preserved. | ||
| 59 | */ | ||
| 60 | |||
| 61 | #include <stdio.h> | ||
| 62 | |||
| 63 | #include <openssl/opensslconf.h> | ||
| 64 | |||
| 65 | #include <openssl/err.h> | ||
| 66 | #include <openssl/dso.h> | ||
| 67 | |||
| 68 | /* BEGIN ERROR CODES */ | ||
| 69 | #ifndef OPENSSL_NO_ERR | ||
| 70 | |||
| 71 | #define ERR_FUNC(func) ERR_PACK(ERR_LIB_DSO,func,0) | ||
| 72 | #define ERR_REASON(reason) ERR_PACK(ERR_LIB_DSO,0,reason) | ||
| 73 | |||
| 74 | static ERR_STRING_DATA DSO_str_functs[]= { | ||
| 75 | {ERR_FUNC(DSO_F_BEOS_BIND_FUNC), "BEOS_BIND_FUNC"}, | ||
| 76 | {ERR_FUNC(DSO_F_BEOS_BIND_VAR), "BEOS_BIND_VAR"}, | ||
| 77 | {ERR_FUNC(DSO_F_BEOS_LOAD), "BEOS_LOAD"}, | ||
| 78 | {ERR_FUNC(DSO_F_BEOS_NAME_CONVERTER), "BEOS_NAME_CONVERTER"}, | ||
| 79 | {ERR_FUNC(DSO_F_BEOS_UNLOAD), "BEOS_UNLOAD"}, | ||
| 80 | {ERR_FUNC(DSO_F_DLFCN_BIND_FUNC), "DLFCN_BIND_FUNC"}, | ||
| 81 | {ERR_FUNC(DSO_F_DLFCN_BIND_VAR), "DLFCN_BIND_VAR"}, | ||
| 82 | {ERR_FUNC(DSO_F_DLFCN_LOAD), "DLFCN_LOAD"}, | ||
| 83 | {ERR_FUNC(DSO_F_DLFCN_MERGER), "DLFCN_MERGER"}, | ||
| 84 | {ERR_FUNC(DSO_F_DLFCN_NAME_CONVERTER), "DLFCN_NAME_CONVERTER"}, | ||
| 85 | {ERR_FUNC(DSO_F_DLFCN_UNLOAD), "DLFCN_UNLOAD"}, | ||
| 86 | {ERR_FUNC(DSO_F_DL_BIND_FUNC), "DL_BIND_FUNC"}, | ||
| 87 | {ERR_FUNC(DSO_F_DL_BIND_VAR), "DL_BIND_VAR"}, | ||
| 88 | {ERR_FUNC(DSO_F_DL_LOAD), "DL_LOAD"}, | ||
| 89 | {ERR_FUNC(DSO_F_DL_MERGER), "DL_MERGER"}, | ||
| 90 | {ERR_FUNC(DSO_F_DL_NAME_CONVERTER), "DL_NAME_CONVERTER"}, | ||
| 91 | {ERR_FUNC(DSO_F_DL_UNLOAD), "DL_UNLOAD"}, | ||
| 92 | {ERR_FUNC(DSO_F_DSO_BIND_FUNC), "DSO_bind_func"}, | ||
| 93 | {ERR_FUNC(DSO_F_DSO_BIND_VAR), "DSO_bind_var"}, | ||
| 94 | {ERR_FUNC(DSO_F_DSO_CONVERT_FILENAME), "DSO_convert_filename"}, | ||
| 95 | {ERR_FUNC(DSO_F_DSO_CTRL), "DSO_ctrl"}, | ||
| 96 | {ERR_FUNC(DSO_F_DSO_FREE), "DSO_free"}, | ||
| 97 | {ERR_FUNC(DSO_F_DSO_GET_FILENAME), "DSO_get_filename"}, | ||
| 98 | {ERR_FUNC(DSO_F_DSO_GET_LOADED_FILENAME), "DSO_get_loaded_filename"}, | ||
| 99 | {ERR_FUNC(DSO_F_DSO_GLOBAL_LOOKUP), "DSO_global_lookup"}, | ||
| 100 | {ERR_FUNC(DSO_F_DSO_LOAD), "DSO_load"}, | ||
| 101 | {ERR_FUNC(DSO_F_DSO_MERGE), "DSO_merge"}, | ||
| 102 | {ERR_FUNC(DSO_F_DSO_NEW_METHOD), "DSO_new_method"}, | ||
| 103 | {ERR_FUNC(DSO_F_DSO_PATHBYADDR), "DSO_pathbyaddr"}, | ||
| 104 | {ERR_FUNC(DSO_F_DSO_SET_FILENAME), "DSO_set_filename"}, | ||
| 105 | {ERR_FUNC(DSO_F_DSO_SET_NAME_CONVERTER), "DSO_set_name_converter"}, | ||
| 106 | {ERR_FUNC(DSO_F_DSO_UP_REF), "DSO_up_ref"}, | ||
| 107 | {ERR_FUNC(DSO_F_GLOBAL_LOOKUP_FUNC), "GLOBAL_LOOKUP_FUNC"}, | ||
| 108 | {ERR_FUNC(DSO_F_PATHBYADDR), "PATHBYADDR"}, | ||
| 109 | {ERR_FUNC(DSO_F_VMS_BIND_SYM), "VMS_BIND_SYM"}, | ||
| 110 | {ERR_FUNC(DSO_F_VMS_LOAD), "VMS_LOAD"}, | ||
| 111 | {ERR_FUNC(DSO_F_VMS_MERGER), "VMS_MERGER"}, | ||
| 112 | {ERR_FUNC(DSO_F_VMS_UNLOAD), "VMS_UNLOAD"}, | ||
| 113 | {ERR_FUNC(DSO_F_WIN32_BIND_FUNC), "WIN32_BIND_FUNC"}, | ||
| 114 | {ERR_FUNC(DSO_F_WIN32_BIND_VAR), "WIN32_BIND_VAR"}, | ||
| 115 | {ERR_FUNC(DSO_F_WIN32_GLOBALLOOKUP), "WIN32_GLOBALLOOKUP"}, | ||
| 116 | {ERR_FUNC(DSO_F_WIN32_GLOBALLOOKUP_FUNC), "WIN32_GLOBALLOOKUP_FUNC"}, | ||
| 117 | {ERR_FUNC(DSO_F_WIN32_JOINER), "WIN32_JOINER"}, | ||
| 118 | {ERR_FUNC(DSO_F_WIN32_LOAD), "WIN32_LOAD"}, | ||
| 119 | {ERR_FUNC(DSO_F_WIN32_MERGER), "WIN32_MERGER"}, | ||
| 120 | {ERR_FUNC(DSO_F_WIN32_NAME_CONVERTER), "WIN32_NAME_CONVERTER"}, | ||
| 121 | {ERR_FUNC(DSO_F_WIN32_PATHBYADDR), "WIN32_PATHBYADDR"}, | ||
| 122 | {ERR_FUNC(DSO_F_WIN32_SPLITTER), "WIN32_SPLITTER"}, | ||
| 123 | {ERR_FUNC(DSO_F_WIN32_UNLOAD), "WIN32_UNLOAD"}, | ||
| 124 | {0, NULL} | ||
| 125 | }; | ||
| 126 | |||
| 127 | static ERR_STRING_DATA DSO_str_reasons[]= { | ||
| 128 | {ERR_REASON(DSO_R_CTRL_FAILED) , "control command failed"}, | ||
| 129 | {ERR_REASON(DSO_R_DSO_ALREADY_LOADED) , "dso already loaded"}, | ||
| 130 | {ERR_REASON(DSO_R_EMPTY_FILE_STRUCTURE) , "empty file structure"}, | ||
| 131 | {ERR_REASON(DSO_R_FAILURE) , "failure"}, | ||
| 132 | {ERR_REASON(DSO_R_FILENAME_TOO_BIG) , "filename too big"}, | ||
| 133 | {ERR_REASON(DSO_R_FINISH_FAILED) , "cleanup method function failed"}, | ||
| 134 | {ERR_REASON(DSO_R_INCORRECT_FILE_SYNTAX) , "incorrect file syntax"}, | ||
| 135 | {ERR_REASON(DSO_R_LOAD_FAILED) , "could not load the shared library"}, | ||
| 136 | {ERR_REASON(DSO_R_NAME_TRANSLATION_FAILED), "name translation failed"}, | ||
| 137 | {ERR_REASON(DSO_R_NO_FILENAME) , "no filename"}, | ||
| 138 | {ERR_REASON(DSO_R_NO_FILE_SPECIFICATION) , "no file specification"}, | ||
| 139 | {ERR_REASON(DSO_R_NULL_HANDLE) , "a null shared library handle was used"}, | ||
| 140 | {ERR_REASON(DSO_R_SET_FILENAME_FAILED) , "set filename failed"}, | ||
| 141 | {ERR_REASON(DSO_R_STACK_ERROR) , "the meth_data stack is corrupt"}, | ||
| 142 | {ERR_REASON(DSO_R_SYM_FAILURE) , "could not bind to the requested symbol name"}, | ||
| 143 | {ERR_REASON(DSO_R_UNLOAD_FAILED) , "could not unload the shared library"}, | ||
| 144 | {ERR_REASON(DSO_R_UNSUPPORTED) , "functionality not supported"}, | ||
| 145 | {0, NULL} | ||
| 146 | }; | ||
| 147 | |||
| 148 | #endif | ||
| 149 | |||
| 150 | void | ||
| 151 | ERR_load_DSO_strings(void) | ||
| 152 | { | ||
| 153 | #ifndef OPENSSL_NO_ERR | ||
| 154 | if (ERR_func_error_string(DSO_str_functs[0].error) == NULL) { | ||
| 155 | ERR_load_strings(0, DSO_str_functs); | ||
| 156 | ERR_load_strings(0, DSO_str_reasons); | ||
| 157 | } | ||
| 158 | #endif | ||
| 159 | } | ||
diff --git a/src/lib/libcrypto/dso/dso_lib.c b/src/lib/libcrypto/dso/dso_lib.c deleted file mode 100644 index 3002e4d99c..0000000000 --- a/src/lib/libcrypto/dso/dso_lib.c +++ /dev/null | |||
| @@ -1,454 +0,0 @@ | |||
| 1 | /* $OpenBSD: dso_lib.c,v 1.18 2014/07/11 08:44:48 jsing Exp $ */ | ||
| 2 | /* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL | ||
| 3 | * project 2000. | ||
| 4 | */ | ||
| 5 | /* ==================================================================== | ||
| 6 | * Copyright (c) 2000 The OpenSSL Project. All rights reserved. | ||
| 7 | * | ||
| 8 | * Redistribution and use in source and binary forms, with or without | ||
| 9 | * modification, are permitted provided that the following conditions | ||
| 10 | * are met: | ||
| 11 | * | ||
| 12 | * 1. Redistributions of source code must retain the above copyright | ||
| 13 | * notice, this list of conditions and the following disclaimer. | ||
| 14 | * | ||
| 15 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 16 | * notice, this list of conditions and the following disclaimer in | ||
| 17 | * the documentation and/or other materials provided with the | ||
| 18 | * distribution. | ||
| 19 | * | ||
| 20 | * 3. All advertising materials mentioning features or use of this | ||
| 21 | * software must display the following acknowledgment: | ||
| 22 | * "This product includes software developed by the OpenSSL Project | ||
| 23 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" | ||
| 24 | * | ||
| 25 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
| 26 | * endorse or promote products derived from this software without | ||
| 27 | * prior written permission. For written permission, please contact | ||
| 28 | * licensing@OpenSSL.org. | ||
| 29 | * | ||
| 30 | * 5. Products derived from this software may not be called "OpenSSL" | ||
| 31 | * nor may "OpenSSL" appear in their names without prior written | ||
| 32 | * permission of the OpenSSL Project. | ||
| 33 | * | ||
| 34 | * 6. Redistributions of any form whatsoever must retain the following | ||
| 35 | * acknowledgment: | ||
| 36 | * "This product includes software developed by the OpenSSL Project | ||
| 37 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" | ||
| 38 | * | ||
| 39 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
| 40 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 41 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 42 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
| 43 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 44 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 46 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 47 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 48 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 49 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
| 50 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 51 | * ==================================================================== | ||
| 52 | * | ||
| 53 | * This product includes cryptographic software written by Eric Young | ||
| 54 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
| 55 | * Hudson (tjh@cryptsoft.com). | ||
| 56 | * | ||
| 57 | */ | ||
| 58 | |||
| 59 | #include <stdio.h> | ||
| 60 | #include <string.h> | ||
| 61 | |||
| 62 | #include <openssl/crypto.h> | ||
| 63 | #include <openssl/dso.h> | ||
| 64 | #include <openssl/err.h> | ||
| 65 | |||
| 66 | static DSO_METHOD *default_DSO_meth = NULL; | ||
| 67 | |||
| 68 | DSO * | ||
| 69 | DSO_new(void) | ||
| 70 | { | ||
| 71 | return (DSO_new_method(NULL)); | ||
| 72 | } | ||
| 73 | |||
| 74 | void | ||
| 75 | DSO_set_default_method(DSO_METHOD *meth) | ||
| 76 | { | ||
| 77 | default_DSO_meth = meth; | ||
| 78 | } | ||
| 79 | |||
| 80 | DSO_METHOD * | ||
| 81 | DSO_get_default_method(void) | ||
| 82 | { | ||
| 83 | return (default_DSO_meth); | ||
| 84 | } | ||
| 85 | |||
| 86 | DSO_METHOD * | ||
| 87 | DSO_get_method(DSO *dso) | ||
| 88 | { | ||
| 89 | return (dso->meth); | ||
| 90 | } | ||
| 91 | |||
| 92 | DSO_METHOD * | ||
| 93 | DSO_set_method(DSO *dso, DSO_METHOD *meth) | ||
| 94 | { | ||
| 95 | DSO_METHOD *mtmp; | ||
| 96 | |||
| 97 | mtmp = dso->meth; | ||
| 98 | dso->meth = meth; | ||
| 99 | return (mtmp); | ||
| 100 | } | ||
| 101 | |||
| 102 | DSO * | ||
| 103 | DSO_new_method(DSO_METHOD *meth) | ||
| 104 | { | ||
| 105 | DSO *ret; | ||
| 106 | |||
| 107 | if (default_DSO_meth == NULL) | ||
| 108 | /* We default to DSO_METH_openssl() which in turn defaults | ||
| 109 | * to stealing the "best available" method. Will fallback | ||
| 110 | * to DSO_METH_null() in the worst case. */ | ||
| 111 | default_DSO_meth = DSO_METHOD_openssl(); | ||
| 112 | ret = calloc(1, sizeof(DSO)); | ||
| 113 | if (ret == NULL) { | ||
| 114 | DSOerr(DSO_F_DSO_NEW_METHOD, ERR_R_MALLOC_FAILURE); | ||
| 115 | return (NULL); | ||
| 116 | } | ||
| 117 | ret->meth_data = sk_void_new_null(); | ||
| 118 | if (ret->meth_data == NULL) { | ||
| 119 | /* sk_new doesn't generate any errors so we do */ | ||
| 120 | DSOerr(DSO_F_DSO_NEW_METHOD, ERR_R_MALLOC_FAILURE); | ||
| 121 | free(ret); | ||
| 122 | return (NULL); | ||
| 123 | } | ||
| 124 | if (meth == NULL) | ||
| 125 | ret->meth = default_DSO_meth; | ||
| 126 | else | ||
| 127 | ret->meth = meth; | ||
| 128 | ret->references = 1; | ||
| 129 | if ((ret->meth->init != NULL) && !ret->meth->init(ret)) { | ||
| 130 | free(ret); | ||
| 131 | ret = NULL; | ||
| 132 | } | ||
| 133 | return (ret); | ||
| 134 | } | ||
| 135 | |||
| 136 | int | ||
| 137 | DSO_free(DSO *dso) | ||
| 138 | { | ||
| 139 | int i; | ||
| 140 | |||
| 141 | if (dso == NULL) { | ||
| 142 | DSOerr(DSO_F_DSO_FREE, ERR_R_PASSED_NULL_PARAMETER); | ||
| 143 | return (0); | ||
| 144 | } | ||
| 145 | |||
| 146 | i = CRYPTO_add(&dso->references, -1, CRYPTO_LOCK_DSO); | ||
| 147 | if (i > 0) | ||
| 148 | return (1); | ||
| 149 | |||
| 150 | if ((dso->meth->dso_unload != NULL) && !dso->meth->dso_unload(dso)) { | ||
| 151 | DSOerr(DSO_F_DSO_FREE, DSO_R_UNLOAD_FAILED); | ||
| 152 | return (0); | ||
| 153 | } | ||
| 154 | |||
| 155 | if ((dso->meth->finish != NULL) && !dso->meth->finish(dso)) { | ||
| 156 | DSOerr(DSO_F_DSO_FREE, DSO_R_FINISH_FAILED); | ||
| 157 | return (0); | ||
| 158 | } | ||
| 159 | |||
| 160 | sk_void_free(dso->meth_data); | ||
| 161 | free(dso->filename); | ||
| 162 | free(dso->loaded_filename); | ||
| 163 | free(dso); | ||
| 164 | return (1); | ||
| 165 | } | ||
| 166 | |||
| 167 | int | ||
| 168 | DSO_flags(DSO *dso) | ||
| 169 | { | ||
| 170 | return ((dso == NULL) ? 0 : dso->flags); | ||
| 171 | } | ||
| 172 | |||
| 173 | |||
| 174 | int | ||
| 175 | DSO_up_ref(DSO *dso) | ||
| 176 | { | ||
| 177 | if (dso == NULL) { | ||
| 178 | DSOerr(DSO_F_DSO_UP_REF, ERR_R_PASSED_NULL_PARAMETER); | ||
| 179 | return (0); | ||
| 180 | } | ||
| 181 | |||
| 182 | CRYPTO_add(&dso->references, 1, CRYPTO_LOCK_DSO); | ||
| 183 | return (1); | ||
| 184 | } | ||
| 185 | |||
| 186 | DSO * | ||
| 187 | DSO_load(DSO *dso, const char *filename, DSO_METHOD *meth, int flags) | ||
| 188 | { | ||
| 189 | DSO *ret; | ||
| 190 | int allocated = 0; | ||
| 191 | |||
| 192 | if (dso == NULL) { | ||
| 193 | ret = DSO_new_method(meth); | ||
| 194 | if (ret == NULL) { | ||
| 195 | DSOerr(DSO_F_DSO_LOAD, ERR_R_MALLOC_FAILURE); | ||
| 196 | goto err; | ||
| 197 | } | ||
| 198 | allocated = 1; | ||
| 199 | /* Pass the provided flags to the new DSO object */ | ||
| 200 | if (DSO_ctrl(ret, DSO_CTRL_SET_FLAGS, flags, NULL) < 0) { | ||
| 201 | DSOerr(DSO_F_DSO_LOAD, DSO_R_CTRL_FAILED); | ||
| 202 | goto err; | ||
| 203 | } | ||
| 204 | } else | ||
| 205 | ret = dso; | ||
| 206 | /* Don't load if we're currently already loaded */ | ||
| 207 | if (ret->filename != NULL) { | ||
| 208 | DSOerr(DSO_F_DSO_LOAD, DSO_R_DSO_ALREADY_LOADED); | ||
| 209 | goto err; | ||
| 210 | } | ||
| 211 | /* filename can only be NULL if we were passed a dso that already has | ||
| 212 | * one set. */ | ||
| 213 | if (filename != NULL) | ||
| 214 | if (!DSO_set_filename(ret, filename)) { | ||
| 215 | DSOerr(DSO_F_DSO_LOAD, DSO_R_SET_FILENAME_FAILED); | ||
| 216 | goto err; | ||
| 217 | } | ||
| 218 | filename = ret->filename; | ||
| 219 | if (filename == NULL) { | ||
| 220 | DSOerr(DSO_F_DSO_LOAD, DSO_R_NO_FILENAME); | ||
| 221 | goto err; | ||
| 222 | } | ||
| 223 | if (ret->meth->dso_load == NULL) { | ||
| 224 | DSOerr(DSO_F_DSO_LOAD, DSO_R_UNSUPPORTED); | ||
| 225 | goto err; | ||
| 226 | } | ||
| 227 | if (!ret->meth->dso_load(ret)) { | ||
| 228 | DSOerr(DSO_F_DSO_LOAD, DSO_R_LOAD_FAILED); | ||
| 229 | goto err; | ||
| 230 | } | ||
| 231 | /* Load succeeded */ | ||
| 232 | return (ret); | ||
| 233 | |||
| 234 | err: | ||
| 235 | if (allocated) | ||
| 236 | DSO_free(ret); | ||
| 237 | return (NULL); | ||
| 238 | } | ||
| 239 | |||
| 240 | void * | ||
| 241 | DSO_bind_var(DSO *dso, const char *symname) | ||
| 242 | { | ||
| 243 | void *ret = NULL; | ||
| 244 | |||
| 245 | if ((dso == NULL) || (symname == NULL)) { | ||
| 246 | DSOerr(DSO_F_DSO_BIND_VAR, ERR_R_PASSED_NULL_PARAMETER); | ||
| 247 | return (NULL); | ||
| 248 | } | ||
| 249 | if (dso->meth->dso_bind_var == NULL) { | ||
| 250 | DSOerr(DSO_F_DSO_BIND_VAR, DSO_R_UNSUPPORTED); | ||
| 251 | return (NULL); | ||
| 252 | } | ||
| 253 | if ((ret = dso->meth->dso_bind_var(dso, symname)) == NULL) { | ||
| 254 | DSOerr(DSO_F_DSO_BIND_VAR, DSO_R_SYM_FAILURE); | ||
| 255 | return (NULL); | ||
| 256 | } | ||
| 257 | /* Success */ | ||
| 258 | return (ret); | ||
| 259 | } | ||
| 260 | |||
| 261 | DSO_FUNC_TYPE | ||
| 262 | DSO_bind_func(DSO *dso, const char *symname) | ||
| 263 | { | ||
| 264 | DSO_FUNC_TYPE ret = NULL; | ||
| 265 | |||
| 266 | if ((dso == NULL) || (symname == NULL)) { | ||
| 267 | DSOerr(DSO_F_DSO_BIND_FUNC, ERR_R_PASSED_NULL_PARAMETER); | ||
| 268 | return (NULL); | ||
| 269 | } | ||
| 270 | if (dso->meth->dso_bind_func == NULL) { | ||
| 271 | DSOerr(DSO_F_DSO_BIND_FUNC, DSO_R_UNSUPPORTED); | ||
| 272 | return (NULL); | ||
| 273 | } | ||
| 274 | if ((ret = dso->meth->dso_bind_func(dso, symname)) == NULL) { | ||
| 275 | DSOerr(DSO_F_DSO_BIND_FUNC, DSO_R_SYM_FAILURE); | ||
| 276 | return (NULL); | ||
| 277 | } | ||
| 278 | /* Success */ | ||
| 279 | return (ret); | ||
| 280 | } | ||
| 281 | |||
| 282 | /* I don't really like these *_ctrl functions very much to be perfectly | ||
| 283 | * honest. For one thing, I think I have to return a negative value for | ||
| 284 | * any error because possible DSO_ctrl() commands may return values | ||
| 285 | * such as "size"s that can legitimately be zero (making the standard | ||
| 286 | * "if(DSO_cmd(...))" form that works almost everywhere else fail at | ||
| 287 | * odd times. I'd prefer "output" values to be passed by reference and | ||
| 288 | * the return value as success/failure like usual ... but we conform | ||
| 289 | * when we must... :-) */ | ||
| 290 | long | ||
| 291 | DSO_ctrl(DSO *dso, int cmd, long larg, void *parg) | ||
| 292 | { | ||
| 293 | if (dso == NULL) { | ||
| 294 | DSOerr(DSO_F_DSO_CTRL, ERR_R_PASSED_NULL_PARAMETER); | ||
| 295 | return (-1); | ||
| 296 | } | ||
| 297 | /* We should intercept certain generic commands and only pass control | ||
| 298 | * to the method-specific ctrl() function if it's something we don't | ||
| 299 | * handle. */ | ||
| 300 | switch (cmd) { | ||
| 301 | case DSO_CTRL_GET_FLAGS: | ||
| 302 | return dso->flags; | ||
| 303 | case DSO_CTRL_SET_FLAGS: | ||
| 304 | dso->flags = (int)larg; | ||
| 305 | return (0); | ||
| 306 | case DSO_CTRL_OR_FLAGS: | ||
| 307 | dso->flags |= (int)larg; | ||
| 308 | return (0); | ||
| 309 | default: | ||
| 310 | break; | ||
| 311 | } | ||
| 312 | if ((dso->meth == NULL) || (dso->meth->dso_ctrl == NULL)) { | ||
| 313 | DSOerr(DSO_F_DSO_CTRL, DSO_R_UNSUPPORTED); | ||
| 314 | return (-1); | ||
| 315 | } | ||
| 316 | return (dso->meth->dso_ctrl(dso, cmd, larg, parg)); | ||
| 317 | } | ||
| 318 | |||
| 319 | int | ||
| 320 | DSO_set_name_converter(DSO *dso, DSO_NAME_CONVERTER_FUNC cb, | ||
| 321 | DSO_NAME_CONVERTER_FUNC *oldcb) | ||
| 322 | { | ||
| 323 | if (dso == NULL) { | ||
| 324 | DSOerr(DSO_F_DSO_SET_NAME_CONVERTER, | ||
| 325 | ERR_R_PASSED_NULL_PARAMETER); | ||
| 326 | return (0); | ||
| 327 | } | ||
| 328 | if (oldcb) | ||
| 329 | *oldcb = dso->name_converter; | ||
| 330 | dso->name_converter = cb; | ||
| 331 | return (1); | ||
| 332 | } | ||
| 333 | |||
| 334 | const char * | ||
| 335 | DSO_get_filename(DSO *dso) | ||
| 336 | { | ||
| 337 | if (dso == NULL) { | ||
| 338 | DSOerr(DSO_F_DSO_GET_FILENAME, ERR_R_PASSED_NULL_PARAMETER); | ||
| 339 | return (NULL); | ||
| 340 | } | ||
| 341 | return (dso->filename); | ||
| 342 | } | ||
| 343 | |||
| 344 | int | ||
| 345 | DSO_set_filename(DSO *dso, const char *filename) | ||
| 346 | { | ||
| 347 | char *copied; | ||
| 348 | |||
| 349 | if ((dso == NULL) || (filename == NULL)) { | ||
| 350 | DSOerr(DSO_F_DSO_SET_FILENAME, ERR_R_PASSED_NULL_PARAMETER); | ||
| 351 | return (0); | ||
| 352 | } | ||
| 353 | if (dso->loaded_filename) { | ||
| 354 | DSOerr(DSO_F_DSO_SET_FILENAME, DSO_R_DSO_ALREADY_LOADED); | ||
| 355 | return (0); | ||
| 356 | } | ||
| 357 | /* We'll duplicate filename */ | ||
| 358 | copied = strdup(filename); | ||
| 359 | if (copied == NULL) { | ||
| 360 | DSOerr(DSO_F_DSO_SET_FILENAME, ERR_R_MALLOC_FAILURE); | ||
| 361 | return (0); | ||
| 362 | } | ||
| 363 | free(dso->filename); | ||
| 364 | dso->filename = copied; | ||
| 365 | return (1); | ||
| 366 | } | ||
| 367 | |||
| 368 | char * | ||
| 369 | DSO_merge(DSO *dso, const char *filespec1, const char *filespec2) | ||
| 370 | { | ||
| 371 | char *result = NULL; | ||
| 372 | |||
| 373 | if (dso == NULL || filespec1 == NULL) { | ||
| 374 | DSOerr(DSO_F_DSO_MERGE, ERR_R_PASSED_NULL_PARAMETER); | ||
| 375 | return (NULL); | ||
| 376 | } | ||
| 377 | if ((dso->flags & DSO_FLAG_NO_NAME_TRANSLATION) == 0) { | ||
| 378 | if (dso->merger != NULL) | ||
| 379 | result = dso->merger(dso, filespec1, filespec2); | ||
| 380 | else if (dso->meth->dso_merger != NULL) | ||
| 381 | result = dso->meth->dso_merger(dso, | ||
| 382 | filespec1, filespec2); | ||
| 383 | } | ||
| 384 | return (result); | ||
| 385 | } | ||
| 386 | |||
| 387 | char * | ||
| 388 | DSO_convert_filename(DSO *dso, const char *filename) | ||
| 389 | { | ||
| 390 | char *result = NULL; | ||
| 391 | |||
| 392 | if (dso == NULL) { | ||
| 393 | DSOerr(DSO_F_DSO_CONVERT_FILENAME, ERR_R_PASSED_NULL_PARAMETER); | ||
| 394 | return (NULL); | ||
| 395 | } | ||
| 396 | if (filename == NULL) | ||
| 397 | filename = dso->filename; | ||
| 398 | if (filename == NULL) { | ||
| 399 | DSOerr(DSO_F_DSO_CONVERT_FILENAME, DSO_R_NO_FILENAME); | ||
| 400 | return (NULL); | ||
| 401 | } | ||
| 402 | if ((dso->flags & DSO_FLAG_NO_NAME_TRANSLATION) == 0) { | ||
| 403 | if (dso->name_converter != NULL) | ||
| 404 | result = dso->name_converter(dso, filename); | ||
| 405 | else if (dso->meth->dso_name_converter != NULL) | ||
| 406 | result = dso->meth->dso_name_converter(dso, filename); | ||
| 407 | } | ||
| 408 | if (result == NULL) { | ||
| 409 | result = strdup(filename); | ||
| 410 | if (result == NULL) { | ||
| 411 | DSOerr(DSO_F_DSO_CONVERT_FILENAME, | ||
| 412 | ERR_R_MALLOC_FAILURE); | ||
| 413 | return (NULL); | ||
| 414 | } | ||
| 415 | } | ||
| 416 | return (result); | ||
| 417 | } | ||
| 418 | |||
| 419 | const char * | ||
| 420 | DSO_get_loaded_filename(DSO *dso) | ||
| 421 | { | ||
| 422 | if (dso == NULL) { | ||
| 423 | DSOerr(DSO_F_DSO_GET_LOADED_FILENAME, | ||
| 424 | ERR_R_PASSED_NULL_PARAMETER); | ||
| 425 | return (NULL); | ||
| 426 | } | ||
| 427 | return (dso->loaded_filename); | ||
| 428 | } | ||
| 429 | |||
| 430 | int | ||
| 431 | DSO_pathbyaddr(void *addr, char *path, int sz) | ||
| 432 | { | ||
| 433 | DSO_METHOD *meth = default_DSO_meth; | ||
| 434 | if (meth == NULL) | ||
| 435 | meth = DSO_METHOD_openssl(); | ||
| 436 | if (meth->pathbyaddr == NULL) { | ||
| 437 | DSOerr(DSO_F_DSO_PATHBYADDR, DSO_R_UNSUPPORTED); | ||
| 438 | return -1; | ||
| 439 | } | ||
| 440 | return (*meth->pathbyaddr)(addr, path, sz); | ||
| 441 | } | ||
| 442 | |||
| 443 | void * | ||
| 444 | DSO_global_lookup(const char *name) | ||
| 445 | { | ||
| 446 | DSO_METHOD *meth = default_DSO_meth; | ||
| 447 | if (meth == NULL) | ||
| 448 | meth = DSO_METHOD_openssl(); | ||
| 449 | if (meth->globallookup == NULL) { | ||
| 450 | DSOerr(DSO_F_DSO_GLOBAL_LOOKUP, DSO_R_UNSUPPORTED); | ||
| 451 | return NULL; | ||
| 452 | } | ||
| 453 | return (*meth->globallookup)(name); | ||
| 454 | } | ||
diff --git a/src/lib/libcrypto/dso/dso_null.c b/src/lib/libcrypto/dso/dso_null.c deleted file mode 100644 index a3dc0ec1ff..0000000000 --- a/src/lib/libcrypto/dso/dso_null.c +++ /dev/null | |||
| @@ -1,74 +0,0 @@ | |||
| 1 | /* $OpenBSD: dso_null.c,v 1.7 2014/07/11 08:44:48 jsing Exp $ */ | ||
| 2 | /* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL | ||
| 3 | * project 2000. | ||
| 4 | */ | ||
| 5 | /* ==================================================================== | ||
| 6 | * Copyright (c) 2000 The OpenSSL Project. All rights reserved. | ||
| 7 | * | ||
| 8 | * Redistribution and use in source and binary forms, with or without | ||
| 9 | * modification, are permitted provided that the following conditions | ||
| 10 | * are met: | ||
| 11 | * | ||
| 12 | * 1. Redistributions of source code must retain the above copyright | ||
| 13 | * notice, this list of conditions and the following disclaimer. | ||
| 14 | * | ||
| 15 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 16 | * notice, this list of conditions and the following disclaimer in | ||
| 17 | * the documentation and/or other materials provided with the | ||
| 18 | * distribution. | ||
| 19 | * | ||
| 20 | * 3. All advertising materials mentioning features or use of this | ||
| 21 | * software must display the following acknowledgment: | ||
| 22 | * "This product includes software developed by the OpenSSL Project | ||
| 23 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" | ||
| 24 | * | ||
| 25 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
| 26 | * endorse or promote products derived from this software without | ||
| 27 | * prior written permission. For written permission, please contact | ||
| 28 | * licensing@OpenSSL.org. | ||
| 29 | * | ||
| 30 | * 5. Products derived from this software may not be called "OpenSSL" | ||
| 31 | * nor may "OpenSSL" appear in their names without prior written | ||
| 32 | * permission of the OpenSSL Project. | ||
| 33 | * | ||
| 34 | * 6. Redistributions of any form whatsoever must retain the following | ||
| 35 | * acknowledgment: | ||
| 36 | * "This product includes software developed by the OpenSSL Project | ||
| 37 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" | ||
| 38 | * | ||
| 39 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
| 40 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 41 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 42 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
| 43 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 44 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 46 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 47 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 48 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 49 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
| 50 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 51 | * ==================================================================== | ||
| 52 | * | ||
| 53 | * This product includes cryptographic software written by Eric Young | ||
| 54 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
| 55 | * Hudson (tjh@cryptsoft.com). | ||
| 56 | * | ||
| 57 | */ | ||
| 58 | |||
| 59 | /* This "NULL" method is provided as the fallback for systems that have | ||
| 60 | * no appropriate support for "shared-libraries". */ | ||
| 61 | |||
| 62 | #include <stdio.h> | ||
| 63 | |||
| 64 | #include <openssl/dso.h> | ||
| 65 | |||
| 66 | static DSO_METHOD dso_meth_null = { | ||
| 67 | .name = "NULL shared library method" | ||
| 68 | }; | ||
| 69 | |||
| 70 | DSO_METHOD * | ||
| 71 | DSO_METHOD_null(void) | ||
| 72 | { | ||
| 73 | return (&dso_meth_null); | ||
| 74 | } | ||
diff --git a/src/lib/libcrypto/dso/dso_openssl.c b/src/lib/libcrypto/dso/dso_openssl.c deleted file mode 100644 index 37d8d5805f..0000000000 --- a/src/lib/libcrypto/dso/dso_openssl.c +++ /dev/null | |||
| @@ -1,75 +0,0 @@ | |||
| 1 | /* $OpenBSD: dso_openssl.c,v 1.6 2014/07/11 08:44:48 jsing Exp $ */ | ||
| 2 | /* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL | ||
| 3 | * project 2000. | ||
| 4 | */ | ||
| 5 | /* ==================================================================== | ||
| 6 | * Copyright (c) 2000 The OpenSSL Project. All rights reserved. | ||
| 7 | * | ||
| 8 | * Redistribution and use in source and binary forms, with or without | ||
| 9 | * modification, are permitted provided that the following conditions | ||
| 10 | * are met: | ||
| 11 | * | ||
| 12 | * 1. Redistributions of source code must retain the above copyright | ||
| 13 | * notice, this list of conditions and the following disclaimer. | ||
| 14 | * | ||
| 15 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 16 | * notice, this list of conditions and the following disclaimer in | ||
| 17 | * the documentation and/or other materials provided with the | ||
| 18 | * distribution. | ||
| 19 | * | ||
| 20 | * 3. All advertising materials mentioning features or use of this | ||
| 21 | * software must display the following acknowledgment: | ||
| 22 | * "This product includes software developed by the OpenSSL Project | ||
| 23 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" | ||
| 24 | * | ||
| 25 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
| 26 | * endorse or promote products derived from this software without | ||
| 27 | * prior written permission. For written permission, please contact | ||
| 28 | * licensing@OpenSSL.org. | ||
| 29 | * | ||
| 30 | * 5. Products derived from this software may not be called "OpenSSL" | ||
| 31 | * nor may "OpenSSL" appear in their names without prior written | ||
| 32 | * permission of the OpenSSL Project. | ||
| 33 | * | ||
| 34 | * 6. Redistributions of any form whatsoever must retain the following | ||
| 35 | * acknowledgment: | ||
| 36 | * "This product includes software developed by the OpenSSL Project | ||
| 37 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" | ||
| 38 | * | ||
| 39 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
| 40 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 41 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 42 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
| 43 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 44 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 46 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 47 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 48 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 49 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
| 50 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 51 | * ==================================================================== | ||
| 52 | * | ||
| 53 | * This product includes cryptographic software written by Eric Young | ||
| 54 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
| 55 | * Hudson (tjh@cryptsoft.com). | ||
| 56 | * | ||
| 57 | */ | ||
| 58 | |||
| 59 | #include <stdio.h> | ||
| 60 | |||
| 61 | #include <openssl/dso.h> | ||
| 62 | |||
| 63 | /* We just pinch the method from an appropriate "default" method. */ | ||
| 64 | |||
| 65 | DSO_METHOD * | ||
| 66 | DSO_METHOD_openssl(void) | ||
| 67 | { | ||
| 68 | #ifdef DEF_DSO_METHOD | ||
| 69 | return (DEF_DSO_METHOD()); | ||
| 70 | #elif defined(DSO_DLFCN) | ||
| 71 | return (DSO_METHOD_dlfcn()); | ||
| 72 | #else | ||
| 73 | return (DSO_METHOD_null()); | ||
| 74 | #endif | ||
| 75 | } | ||
