| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/dso/dso_lib.c |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | /* | - | ||||||||||||
| 2 | * Copyright 2000-2017 The OpenSSL Project Authors. All Rights Reserved. | - | ||||||||||||
| 3 | * | - | ||||||||||||
| 4 | * Licensed under the OpenSSL license (the "License"). You may not use | - | ||||||||||||
| 5 | * this file except in compliance with the License. You can obtain a copy | - | ||||||||||||
| 6 | * in the file LICENSE in the source distribution or at | - | ||||||||||||
| 7 | * https://www.openssl.org/source/license.html | - | ||||||||||||
| 8 | */ | - | ||||||||||||
| 9 | - | |||||||||||||
| 10 | #include "dso_locl.h" | - | ||||||||||||
| 11 | #include "internal/refcount.h" | - | ||||||||||||
| 12 | - | |||||||||||||
| 13 | static DSO_METHOD *default_DSO_meth = NULL; | - | ||||||||||||
| 14 | - | |||||||||||||
| 15 | static DSO *DSO_new_method(DSO_METHOD *meth) | - | ||||||||||||
| 16 | { | - | ||||||||||||
| 17 | DSO *ret; | - | ||||||||||||
| 18 | - | |||||||||||||
| 19 | if (default_DSO_meth == NULL) {
| 0-368 | ||||||||||||
| 20 | /* | - | ||||||||||||
| 21 | * We default to DSO_METH_openssl() which in turn defaults to | - | ||||||||||||
| 22 | * stealing the "best available" method. Will fallback to | - | ||||||||||||
| 23 | * DSO_METH_null() in the worst case. | - | ||||||||||||
| 24 | */ | - | ||||||||||||
| 25 | default_DSO_meth = DSO_METHOD_openssl(); | - | ||||||||||||
| 26 | } executed 368 times by 1 test: end of blockExecuted by:
| 368 | ||||||||||||
| 27 | ret = OPENSSL_zalloc(sizeof(*ret)); | - | ||||||||||||
| 28 | if (ret == NULL) {
| 0-368 | ||||||||||||
| 29 | DSOerr(DSO_F_DSO_NEW_METHOD, ERR_R_MALLOC_FAILURE); | - | ||||||||||||
| 30 | return NULL; never executed: return ((void *)0) ; | 0 | ||||||||||||
| 31 | } | - | ||||||||||||
| 32 | ret->meth_data = sk_void_new_null(); | - | ||||||||||||
| 33 | if (ret->meth_data == NULL) {
| 0-368 | ||||||||||||
| 34 | /* sk_new doesn't generate any errors so we do */ | - | ||||||||||||
| 35 | DSOerr(DSO_F_DSO_NEW_METHOD, ERR_R_MALLOC_FAILURE); | - | ||||||||||||
| 36 | OPENSSL_free(ret); | - | ||||||||||||
| 37 | return NULL; never executed: return ((void *)0) ; | 0 | ||||||||||||
| 38 | } | - | ||||||||||||
| 39 | ret->meth = default_DSO_meth; | - | ||||||||||||
| 40 | ret->references = 1; | - | ||||||||||||
| 41 | ret->lock = CRYPTO_THREAD_lock_new(); | - | ||||||||||||
| 42 | if (ret->lock == NULL) {
| 0-368 | ||||||||||||
| 43 | DSOerr(DSO_F_DSO_NEW_METHOD, ERR_R_MALLOC_FAILURE); | - | ||||||||||||
| 44 | sk_void_free(ret->meth_data); | - | ||||||||||||
| 45 | OPENSSL_free(ret); | - | ||||||||||||
| 46 | return NULL; never executed: return ((void *)0) ; | 0 | ||||||||||||
| 47 | } | - | ||||||||||||
| 48 | - | |||||||||||||
| 49 | if ((ret->meth->init != NULL) && !ret->meth->init(ret)) {
| 0-368 | ||||||||||||
| 50 | DSO_free(ret); | - | ||||||||||||
| 51 | ret = NULL; | - | ||||||||||||
| 52 | } never executed: end of block | 0 | ||||||||||||
| 53 | - | |||||||||||||
| 54 | return ret; executed 368 times by 1 test: return ret;Executed by:
| 368 | ||||||||||||
| 55 | } | - | ||||||||||||
| 56 | - | |||||||||||||
| 57 | DSO *DSO_new(void) | - | ||||||||||||
| 58 | { | - | ||||||||||||
| 59 | return DSO_new_method(NULL); executed 368 times by 1 test: return DSO_new_method( ((void *)0) );Executed by:
| 368 | ||||||||||||
| 60 | } | - | ||||||||||||
| 61 | - | |||||||||||||
| 62 | int DSO_free(DSO *dso) | - | ||||||||||||
| 63 | { | - | ||||||||||||
| 64 | int i; | - | ||||||||||||
| 65 | - | |||||||||||||
| 66 | if (dso == NULL)
| 368-9790 | ||||||||||||
| 67 | return 1; executed 9790 times by 1 test: return 1;Executed by:
| 9790 | ||||||||||||
| 68 | - | |||||||||||||
| 69 | if (CRYPTO_DOWN_REF(&dso->references, &i, dso->lock) <= 0)
| 0-368 | ||||||||||||
| 70 | return 0; never executed: return 0; | 0 | ||||||||||||
| 71 | - | |||||||||||||
| 72 | REF_PRINT_COUNT("DSO", dso); | - | ||||||||||||
| 73 | if (i > 0)
| 0-368 | ||||||||||||
| 74 | return 1; never executed: return 1; | 0 | ||||||||||||
| 75 | REF_ASSERT_ISNT(i < 0); | - | ||||||||||||
| 76 | - | |||||||||||||
| 77 | if ((dso->flags & DSO_FLAG_NO_UNLOAD_ON_FREE) == 0) {
| 0-368 | ||||||||||||
| 78 | if ((dso->meth->dso_unload != NULL) && !dso->meth->dso_unload(dso)) {
| 0-368 | ||||||||||||
| 79 | DSOerr(DSO_F_DSO_FREE, DSO_R_UNLOAD_FAILED); | - | ||||||||||||
| 80 | return 0; never executed: return 0; | 0 | ||||||||||||
| 81 | } | - | ||||||||||||
| 82 | } executed 368 times by 1 test: end of blockExecuted by:
| 368 | ||||||||||||
| 83 | - | |||||||||||||
| 84 | if ((dso->meth->finish != NULL) && !dso->meth->finish(dso)) {
| 0-368 | ||||||||||||
| 85 | DSOerr(DSO_F_DSO_FREE, DSO_R_FINISH_FAILED); | - | ||||||||||||
| 86 | return 0; never executed: return 0; | 0 | ||||||||||||
| 87 | } | - | ||||||||||||
| 88 | - | |||||||||||||
| 89 | sk_void_free(dso->meth_data); | - | ||||||||||||
| 90 | OPENSSL_free(dso->filename); | - | ||||||||||||
| 91 | OPENSSL_free(dso->loaded_filename); | - | ||||||||||||
| 92 | CRYPTO_THREAD_lock_free(dso->lock); | - | ||||||||||||
| 93 | OPENSSL_free(dso); | - | ||||||||||||
| 94 | return 1; executed 368 times by 1 test: return 1;Executed by:
| 368 | ||||||||||||
| 95 | } | - | ||||||||||||
| 96 | - | |||||||||||||
| 97 | int DSO_flags(DSO *dso) | - | ||||||||||||
| 98 | { | - | ||||||||||||
| 99 | return ((dso == NULL) ? 0 : dso->flags); executed 736 times by 1 test: return ((dso == ((void *)0) ) ? 0 : dso->flags);Executed by:
| 0-736 | ||||||||||||
| 100 | } | - | ||||||||||||
| 101 | - | |||||||||||||
| 102 | int DSO_up_ref(DSO *dso) | - | ||||||||||||
| 103 | { | - | ||||||||||||
| 104 | int i; | - | ||||||||||||
| 105 | - | |||||||||||||
| 106 | if (dso == NULL) {
| 0 | ||||||||||||
| 107 | DSOerr(DSO_F_DSO_UP_REF, ERR_R_PASSED_NULL_PARAMETER); | - | ||||||||||||
| 108 | return 0; never executed: return 0; | 0 | ||||||||||||
| 109 | } | - | ||||||||||||
| 110 | - | |||||||||||||
| 111 | if (CRYPTO_UP_REF(&dso->references, &i, dso->lock) <= 0)
| 0 | ||||||||||||
| 112 | return 0; never executed: return 0; | 0 | ||||||||||||
| 113 | - | |||||||||||||
| 114 | REF_PRINT_COUNT("DSO", r); | - | ||||||||||||
| 115 | REF_ASSERT_ISNT(i < 2); | - | ||||||||||||
| 116 | return ((i > 1) ? 1 : 0); never executed: return ((i > 1) ? 1 : 0);
| 0 | ||||||||||||
| 117 | } | - | ||||||||||||
| 118 | - | |||||||||||||
| 119 | DSO *DSO_load(DSO *dso, const char *filename, DSO_METHOD *meth, int flags) | - | ||||||||||||
| 120 | { | - | ||||||||||||
| 121 | DSO *ret; | - | ||||||||||||
| 122 | int allocated = 0; | - | ||||||||||||
| 123 | - | |||||||||||||
| 124 | if (dso == NULL) {
| 0-368 | ||||||||||||
| 125 | ret = DSO_new_method(meth); | - | ||||||||||||
| 126 | if (ret == NULL) {
| 0 | ||||||||||||
| 127 | DSOerr(DSO_F_DSO_LOAD, ERR_R_MALLOC_FAILURE); | - | ||||||||||||
| 128 | goto err; never executed: goto err; | 0 | ||||||||||||
| 129 | } | - | ||||||||||||
| 130 | allocated = 1; | - | ||||||||||||
| 131 | /* Pass the provided flags to the new DSO object */ | - | ||||||||||||
| 132 | if (DSO_ctrl(ret, DSO_CTRL_SET_FLAGS, flags, NULL) < 0) {
| 0 | ||||||||||||
| 133 | DSOerr(DSO_F_DSO_LOAD, DSO_R_CTRL_FAILED); | - | ||||||||||||
| 134 | goto err; never executed: goto err; | 0 | ||||||||||||
| 135 | } | - | ||||||||||||
| 136 | } else never executed: end of block | 0 | ||||||||||||
| 137 | ret = dso; executed 368 times by 1 test: ret = dso;Executed by:
| 368 | ||||||||||||
| 138 | /* Don't load if we're currently already loaded */ | - | ||||||||||||
| 139 | if (ret->filename != NULL) {
| 0-368 | ||||||||||||
| 140 | DSOerr(DSO_F_DSO_LOAD, DSO_R_DSO_ALREADY_LOADED); | - | ||||||||||||
| 141 | goto err; never executed: goto err; | 0 | ||||||||||||
| 142 | } | - | ||||||||||||
| 143 | /* | - | ||||||||||||
| 144 | * filename can only be NULL if we were passed a dso that already has one | - | ||||||||||||
| 145 | * set. | - | ||||||||||||
| 146 | */ | - | ||||||||||||
| 147 | if (filename != NULL)
| 0-368 | ||||||||||||
| 148 | if (!DSO_set_filename(ret, filename)) {
| 0-368 | ||||||||||||
| 149 | DSOerr(DSO_F_DSO_LOAD, DSO_R_SET_FILENAME_FAILED); | - | ||||||||||||
| 150 | goto err; never executed: goto err; | 0 | ||||||||||||
| 151 | } | - | ||||||||||||
| 152 | filename = ret->filename; | - | ||||||||||||
| 153 | if (filename == NULL) {
| 0-368 | ||||||||||||
| 154 | DSOerr(DSO_F_DSO_LOAD, DSO_R_NO_FILENAME); | - | ||||||||||||
| 155 | goto err; never executed: goto err; | 0 | ||||||||||||
| 156 | } | - | ||||||||||||
| 157 | if (ret->meth->dso_load == NULL) {
| 0-368 | ||||||||||||
| 158 | DSOerr(DSO_F_DSO_LOAD, DSO_R_UNSUPPORTED); | - | ||||||||||||
| 159 | goto err; never executed: goto err; | 0 | ||||||||||||
| 160 | } | - | ||||||||||||
| 161 | if (!ret->meth->dso_load(ret)) {
| 0-368 | ||||||||||||
| 162 | DSOerr(DSO_F_DSO_LOAD, DSO_R_LOAD_FAILED); | - | ||||||||||||
| 163 | goto err; never executed: goto err; | 0 | ||||||||||||
| 164 | } | - | ||||||||||||
| 165 | /* Load succeeded */ | - | ||||||||||||
| 166 | return ret; executed 368 times by 1 test: return ret;Executed by:
| 368 | ||||||||||||
| 167 | err: | - | ||||||||||||
| 168 | if (allocated)
| 0 | ||||||||||||
| 169 | DSO_free(ret); never executed: DSO_free(ret); | 0 | ||||||||||||
| 170 | return NULL; never executed: return ((void *)0) ; | 0 | ||||||||||||
| 171 | } | - | ||||||||||||
| 172 | - | |||||||||||||
| 173 | DSO_FUNC_TYPE DSO_bind_func(DSO *dso, const char *symname) | - | ||||||||||||
| 174 | { | - | ||||||||||||
| 175 | DSO_FUNC_TYPE ret = NULL; | - | ||||||||||||
| 176 | - | |||||||||||||
| 177 | if ((dso == NULL) || (symname == NULL)) {
| 0-736 | ||||||||||||
| 178 | DSOerr(DSO_F_DSO_BIND_FUNC, ERR_R_PASSED_NULL_PARAMETER); | - | ||||||||||||
| 179 | return NULL; never executed: return ((void *)0) ; | 0 | ||||||||||||
| 180 | } | - | ||||||||||||
| 181 | if (dso->meth->dso_bind_func == NULL) {
| 0-736 | ||||||||||||
| 182 | DSOerr(DSO_F_DSO_BIND_FUNC, DSO_R_UNSUPPORTED); | - | ||||||||||||
| 183 | return NULL; never executed: return ((void *)0) ; | 0 | ||||||||||||
| 184 | } | - | ||||||||||||
| 185 | if ((ret = dso->meth->dso_bind_func(dso, symname)) == NULL) {
| 0-736 | ||||||||||||
| 186 | DSOerr(DSO_F_DSO_BIND_FUNC, DSO_R_SYM_FAILURE); | - | ||||||||||||
| 187 | return NULL; never executed: return ((void *)0) ; | 0 | ||||||||||||
| 188 | } | - | ||||||||||||
| 189 | /* Success */ | - | ||||||||||||
| 190 | return ret; executed 736 times by 1 test: return ret;Executed by:
| 736 | ||||||||||||
| 191 | } | - | ||||||||||||
| 192 | - | |||||||||||||
| 193 | /* | - | ||||||||||||
| 194 | * I don't really like these *_ctrl functions very much to be perfectly | - | ||||||||||||
| 195 | * honest. For one thing, I think I have to return a negative value for any | - | ||||||||||||
| 196 | * error because possible DSO_ctrl() commands may return values such as | - | ||||||||||||
| 197 | * "size"s that can legitimately be zero (making the standard | - | ||||||||||||
| 198 | * "if (DSO_cmd(...))" form that works almost everywhere else fail at odd | - | ||||||||||||
| 199 | * times. I'd prefer "output" values to be passed by reference and the return | - | ||||||||||||
| 200 | * value as success/failure like usual ... but we conform when we must... :-) | - | ||||||||||||
| 201 | */ | - | ||||||||||||
| 202 | long DSO_ctrl(DSO *dso, int cmd, long larg, void *parg) | - | ||||||||||||
| 203 | { | - | ||||||||||||
| 204 | if (dso == NULL) {
| 0-368 | ||||||||||||
| 205 | DSOerr(DSO_F_DSO_CTRL, ERR_R_PASSED_NULL_PARAMETER); | - | ||||||||||||
| 206 | return -1; never executed: return -1; | 0 | ||||||||||||
| 207 | } | - | ||||||||||||
| 208 | /* | - | ||||||||||||
| 209 | * We should intercept certain generic commands and only pass control to | - | ||||||||||||
| 210 | * the method-specific ctrl() function if it's something we don't handle. | - | ||||||||||||
| 211 | */ | - | ||||||||||||
| 212 | switch (cmd) { | - | ||||||||||||
| 213 | case DSO_CTRL_GET_FLAGS: never executed: case 1: | 0 | ||||||||||||
| 214 | return dso->flags; never executed: return dso->flags; | 0 | ||||||||||||
| 215 | case DSO_CTRL_SET_FLAGS: executed 368 times by 1 test: case 2:Executed by:
| 368 | ||||||||||||
| 216 | dso->flags = (int)larg; | - | ||||||||||||
| 217 | return 0; executed 368 times by 1 test: return 0;Executed by:
| 368 | ||||||||||||
| 218 | case DSO_CTRL_OR_FLAGS: never executed: case 3: | 0 | ||||||||||||
| 219 | dso->flags |= (int)larg; | - | ||||||||||||
| 220 | return 0; never executed: return 0; | 0 | ||||||||||||
| 221 | default: never executed: default: | 0 | ||||||||||||
| 222 | break; never executed: break; | 0 | ||||||||||||
| 223 | } | - | ||||||||||||
| 224 | if ((dso->meth == NULL) || (dso->meth->dso_ctrl == NULL)) {
| 0 | ||||||||||||
| 225 | DSOerr(DSO_F_DSO_CTRL, DSO_R_UNSUPPORTED); | - | ||||||||||||
| 226 | return -1; never executed: return -1; | 0 | ||||||||||||
| 227 | } | - | ||||||||||||
| 228 | return dso->meth->dso_ctrl(dso, cmd, larg, parg); never executed: return dso->meth->dso_ctrl(dso, cmd, larg, parg); | 0 | ||||||||||||
| 229 | } | - | ||||||||||||
| 230 | - | |||||||||||||
| 231 | const char *DSO_get_filename(DSO *dso) | - | ||||||||||||
| 232 | { | - | ||||||||||||
| 233 | if (dso == NULL) {
| 0 | ||||||||||||
| 234 | DSOerr(DSO_F_DSO_GET_FILENAME, ERR_R_PASSED_NULL_PARAMETER); | - | ||||||||||||
| 235 | return NULL; never executed: return ((void *)0) ; | 0 | ||||||||||||
| 236 | } | - | ||||||||||||
| 237 | return dso->filename; never executed: return dso->filename; | 0 | ||||||||||||
| 238 | } | - | ||||||||||||
| 239 | - | |||||||||||||
| 240 | int DSO_set_filename(DSO *dso, const char *filename) | - | ||||||||||||
| 241 | { | - | ||||||||||||
| 242 | char *copied; | - | ||||||||||||
| 243 | - | |||||||||||||
| 244 | if ((dso == NULL) || (filename == NULL)) {
| 0-368 | ||||||||||||
| 245 | DSOerr(DSO_F_DSO_SET_FILENAME, ERR_R_PASSED_NULL_PARAMETER); | - | ||||||||||||
| 246 | return 0; never executed: return 0; | 0 | ||||||||||||
| 247 | } | - | ||||||||||||
| 248 | if (dso->loaded_filename) {
| 0-368 | ||||||||||||
| 249 | DSOerr(DSO_F_DSO_SET_FILENAME, DSO_R_DSO_ALREADY_LOADED); | - | ||||||||||||
| 250 | return 0; never executed: return 0; | 0 | ||||||||||||
| 251 | } | - | ||||||||||||
| 252 | /* We'll duplicate filename */ | - | ||||||||||||
| 253 | copied = OPENSSL_strdup(filename); | - | ||||||||||||
| 254 | if (copied == NULL) {
| 0-368 | ||||||||||||
| 255 | DSOerr(DSO_F_DSO_SET_FILENAME, ERR_R_MALLOC_FAILURE); | - | ||||||||||||
| 256 | return 0; never executed: return 0; | 0 | ||||||||||||
| 257 | } | - | ||||||||||||
| 258 | OPENSSL_free(dso->filename); | - | ||||||||||||
| 259 | dso->filename = copied; | - | ||||||||||||
| 260 | return 1; executed 368 times by 1 test: return 1;Executed by:
| 368 | ||||||||||||
| 261 | } | - | ||||||||||||
| 262 | - | |||||||||||||
| 263 | char *DSO_merge(DSO *dso, const char *filespec1, const char *filespec2) | - | ||||||||||||
| 264 | { | - | ||||||||||||
| 265 | char *result = NULL; | - | ||||||||||||
| 266 | - | |||||||||||||
| 267 | if (dso == NULL || filespec1 == NULL) {
| 0-368 | ||||||||||||
| 268 | DSOerr(DSO_F_DSO_MERGE, ERR_R_PASSED_NULL_PARAMETER); | - | ||||||||||||
| 269 | return NULL; never executed: return ((void *)0) ; | 0 | ||||||||||||
| 270 | } | - | ||||||||||||
| 271 | if ((dso->flags & DSO_FLAG_NO_NAME_TRANSLATION) == 0) {
| 0-368 | ||||||||||||
| 272 | if (dso->merger != NULL)
| 0-368 | ||||||||||||
| 273 | result = dso->merger(dso, filespec1, filespec2); never executed: result = dso->merger(dso, filespec1, filespec2); | 0 | ||||||||||||
| 274 | else if (dso->meth->dso_merger != NULL)
| 0-368 | ||||||||||||
| 275 | result = dso->meth->dso_merger(dso, filespec1, filespec2); executed 368 times by 1 test: result = dso->meth->dso_merger(dso, filespec1, filespec2);Executed by:
| 368 | ||||||||||||
| 276 | } executed 368 times by 1 test: end of blockExecuted by:
| 368 | ||||||||||||
| 277 | return result; executed 368 times by 1 test: return result;Executed by:
| 368 | ||||||||||||
| 278 | } | - | ||||||||||||
| 279 | - | |||||||||||||
| 280 | char *DSO_convert_filename(DSO *dso, const char *filename) | - | ||||||||||||
| 281 | { | - | ||||||||||||
| 282 | char *result = NULL; | - | ||||||||||||
| 283 | - | |||||||||||||
| 284 | if (dso == NULL) {
| 0-736 | ||||||||||||
| 285 | DSOerr(DSO_F_DSO_CONVERT_FILENAME, ERR_R_PASSED_NULL_PARAMETER); | - | ||||||||||||
| 286 | return NULL; never executed: return ((void *)0) ; | 0 | ||||||||||||
| 287 | } | - | ||||||||||||
| 288 | if (filename == NULL)
| 368 | ||||||||||||
| 289 | filename = dso->filename; executed 368 times by 1 test: filename = dso->filename;Executed by:
| 368 | ||||||||||||
| 290 | if (filename == NULL) {
| 0-736 | ||||||||||||
| 291 | DSOerr(DSO_F_DSO_CONVERT_FILENAME, DSO_R_NO_FILENAME); | - | ||||||||||||
| 292 | return NULL; never executed: return ((void *)0) ; | 0 | ||||||||||||
| 293 | } | - | ||||||||||||
| 294 | if ((dso->flags & DSO_FLAG_NO_NAME_TRANSLATION) == 0) {
| 0-736 | ||||||||||||
| 295 | if (dso->name_converter != NULL)
| 0-736 | ||||||||||||
| 296 | result = dso->name_converter(dso, filename); never executed: result = dso->name_converter(dso, filename); | 0 | ||||||||||||
| 297 | else if (dso->meth->dso_name_converter != NULL)
| 0-736 | ||||||||||||
| 298 | result = dso->meth->dso_name_converter(dso, filename); executed 736 times by 1 test: result = dso->meth->dso_name_converter(dso, filename);Executed by:
| 736 | ||||||||||||
| 299 | } executed 736 times by 1 test: end of blockExecuted by:
| 736 | ||||||||||||
| 300 | if (result == NULL) {
| 0-736 | ||||||||||||
| 301 | result = OPENSSL_strdup(filename); | - | ||||||||||||
| 302 | if (result == NULL) {
| 0 | ||||||||||||
| 303 | DSOerr(DSO_F_DSO_CONVERT_FILENAME, ERR_R_MALLOC_FAILURE); | - | ||||||||||||
| 304 | return NULL; never executed: return ((void *)0) ; | 0 | ||||||||||||
| 305 | } | - | ||||||||||||
| 306 | } never executed: end of block | 0 | ||||||||||||
| 307 | return result; executed 736 times by 1 test: return result;Executed by:
| 736 | ||||||||||||
| 308 | } | - | ||||||||||||
| 309 | - | |||||||||||||
| 310 | int DSO_pathbyaddr(void *addr, char *path, int sz) | - | ||||||||||||
| 311 | { | - | ||||||||||||
| 312 | DSO_METHOD *meth = default_DSO_meth; | - | ||||||||||||
| 313 | if (meth == NULL)
| 0 | ||||||||||||
| 314 | meth = DSO_METHOD_openssl(); never executed: meth = DSO_METHOD_openssl(); | 0 | ||||||||||||
| 315 | if (meth->pathbyaddr == NULL) {
| 0 | ||||||||||||
| 316 | DSOerr(DSO_F_DSO_PATHBYADDR, DSO_R_UNSUPPORTED); | - | ||||||||||||
| 317 | return -1; never executed: return -1; | 0 | ||||||||||||
| 318 | } | - | ||||||||||||
| 319 | return (*meth->pathbyaddr) (addr, path, sz); never executed: return (*meth->pathbyaddr) (addr, path, sz); | 0 | ||||||||||||
| 320 | } | - | ||||||||||||
| 321 | - | |||||||||||||
| 322 | DSO *DSO_dsobyaddr(void *addr, int flags) | - | ||||||||||||
| 323 | { | - | ||||||||||||
| 324 | DSO *ret = NULL; | - | ||||||||||||
| 325 | char *filename = NULL; | - | ||||||||||||
| 326 | int len = DSO_pathbyaddr(addr, NULL, 0); | - | ||||||||||||
| 327 | - | |||||||||||||
| 328 | if (len < 0)
| 0 | ||||||||||||
| 329 | return NULL; never executed: return ((void *)0) ; | 0 | ||||||||||||
| 330 | - | |||||||||||||
| 331 | filename = OPENSSL_malloc(len); | - | ||||||||||||
| 332 | if (filename != NULL
| 0 | ||||||||||||
| 333 | && DSO_pathbyaddr(addr, filename, len) == len)
| 0 | ||||||||||||
| 334 | ret = DSO_load(NULL, filename, NULL, flags); never executed: ret = DSO_load( ((void *)0) , filename, ((void *)0) , flags); | 0 | ||||||||||||
| 335 | - | |||||||||||||
| 336 | OPENSSL_free(filename); | - | ||||||||||||
| 337 | return ret; never executed: return ret; | 0 | ||||||||||||
| 338 | } | - | ||||||||||||
| 339 | - | |||||||||||||
| 340 | void *DSO_global_lookup(const char *name) | - | ||||||||||||
| 341 | { | - | ||||||||||||
| 342 | DSO_METHOD *meth = default_DSO_meth; | - | ||||||||||||
| 343 | if (meth == NULL)
| 0 | ||||||||||||
| 344 | meth = DSO_METHOD_openssl(); never executed: meth = DSO_METHOD_openssl(); | 0 | ||||||||||||
| 345 | if (meth->globallookup == NULL) {
| 0 | ||||||||||||
| 346 | DSOerr(DSO_F_DSO_GLOBAL_LOOKUP, DSO_R_UNSUPPORTED); | - | ||||||||||||
| 347 | return NULL; never executed: return ((void *)0) ; | 0 | ||||||||||||
| 348 | } | - | ||||||||||||
| 349 | return (*meth->globallookup) (name); never executed: return (*meth->globallookup) (name); | 0 | ||||||||||||
| 350 | } | - | ||||||||||||
| Source code | Switch to Preprocessed file |