DSO *DSO_new_method(DSO_METHOD *meth) { DSO *ret; if (default_DSO_meth == NULL) { /* * We default to DSO_METH_openssl() which in turn defaults to * stealing the "best available" method. Will fallback to * DSO_METH_null() in the worst case. */ default_DSO_meth = DSO_METHOD_openssl(); } ret = OPENSSL_zalloc(sizeof(*ret)); if (ret == NULL) { DSOerr(DSO_F_DSO_NEW_METHOD, ERR_R_MALLOC_FAILURE); return (NULL); } ret->meth_data = sk_void_new_null(); if (ret->meth_data == NULL) { /* sk_new doesn't generate any errors so we do */ DSOerr(DSO_F_DSO_NEW_METHOD, ERR_R_MALLOC_FAILURE); OPENSSL_free(ret); return (NULL); } if (meth == NULL) ret->meth = default_DSO_meth; else ret->meth = meth; ret->references = 1; if ((ret->meth->init != NULL) && !ret->meth->init(ret)) { OPENSSL_free(ret); ret = NULL; } return (ret); }
void *DSO_global_lookup(const char *name) { DSO_METHOD *meth = default_DSO_meth; if (meth == NULL) meth = DSO_METHOD_openssl(); if (meth->globallookup == NULL) { DSOerr(DSO_F_DSO_GLOBAL_LOOKUP,DSO_R_UNSUPPORTED); return NULL; } return (*meth->globallookup)(name); }
int DSO_pathbyaddr(void *addr,char *path,int sz) { DSO_METHOD *meth = default_DSO_meth; if (meth == NULL) meth = DSO_METHOD_openssl(); if (meth->pathbyaddr == NULL) { DSOerr(DSO_F_DSO_PATHBYADDR,DSO_R_UNSUPPORTED); return -1; } return (*meth->pathbyaddr)(addr,path,sz); }
DSO *DSO_new_method(DSO_METHOD *meth) { DSO *ret; if (default_DSO_meth == NULL) /* We default to DSO_METH_openssl() which in turn defaults * to stealing the "best available" method. Will fallback * to DSO_METH_null() in the worst case. */ default_DSO_meth = DSO_METHOD_openssl(); ret = calloc(1, sizeof(DSO)); if (ret == NULL) { DSOerr(DSO_F_DSO_NEW_METHOD, ERR_R_MALLOC_FAILURE); return NULL; } ret->meth_data = sk_void_new_null(); if (ret->meth_data == NULL) { /* sk_new doesn't generate any errors so we do */ DSOerr(DSO_F_DSO_NEW_METHOD, ERR_R_MALLOC_FAILURE); free(ret); return NULL; } if (meth == NULL) ret->meth = default_DSO_meth; else ret->meth = meth; ret->references = 1; ret->lock = CRYPTO_thread_new(); if (ret->lock == NULL) { sk_void_free(ret->meth_data); free(ret); return NULL; } if ((ret->meth->init != NULL) && !ret->meth->init(ret)) { DSO_free(ret); ret = NULL; } return ret; }