| OLD | NEW |
| 1 /* dso_lib.c -*- mode:C; c-file-style: "eay" -*- */ | 1 /* dso_lib.c -*- mode:C; c-file-style: "eay" -*- */ |
| 2 /* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL | 2 /* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL |
| 3 * project 2000. | 3 * project 2000. |
| 4 */ | 4 */ |
| 5 /* ==================================================================== | 5 /* ==================================================================== |
| 6 * Copyright (c) 2000 The OpenSSL Project. All rights reserved. | 6 * Copyright (c) 2000 The OpenSSL Project. All rights reserved. |
| 7 * | 7 * |
| 8 * Redistribution and use in source and binary forms, with or without | 8 * Redistribution and use in source and binary forms, with or without |
| 9 * modification, are permitted provided that the following conditions | 9 * modification, are permitted provided that the following conditions |
| 10 * are met: | 10 * are met: |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 * to stealing the "best available" method. Will fallback | 100 * to stealing the "best available" method. Will fallback |
| 101 * to DSO_METH_null() in the worst case. */ | 101 * to DSO_METH_null() in the worst case. */ |
| 102 default_DSO_meth = DSO_METHOD_openssl(); | 102 default_DSO_meth = DSO_METHOD_openssl(); |
| 103 ret = (DSO *)OPENSSL_malloc(sizeof(DSO)); | 103 ret = (DSO *)OPENSSL_malloc(sizeof(DSO)); |
| 104 if(ret == NULL) | 104 if(ret == NULL) |
| 105 { | 105 { |
| 106 DSOerr(DSO_F_DSO_NEW_METHOD,ERR_R_MALLOC_FAILURE); | 106 DSOerr(DSO_F_DSO_NEW_METHOD,ERR_R_MALLOC_FAILURE); |
| 107 return(NULL); | 107 return(NULL); |
| 108 } | 108 } |
| 109 memset(ret, 0, sizeof(DSO)); | 109 memset(ret, 0, sizeof(DSO)); |
| 110 » ret->meth_data = sk_new_null(); | 110 » ret->meth_data = sk_void_new_null(); |
| 111 if(ret->meth_data == NULL) | 111 if(ret->meth_data == NULL) |
| 112 { | 112 { |
| 113 /* sk_new doesn't generate any errors so we do */ | 113 /* sk_new doesn't generate any errors so we do */ |
| 114 DSOerr(DSO_F_DSO_NEW_METHOD,ERR_R_MALLOC_FAILURE); | 114 DSOerr(DSO_F_DSO_NEW_METHOD,ERR_R_MALLOC_FAILURE); |
| 115 OPENSSL_free(ret); | 115 OPENSSL_free(ret); |
| 116 return(NULL); | 116 return(NULL); |
| 117 } | 117 } |
| 118 if(meth == NULL) | 118 if(meth == NULL) |
| 119 ret->meth = default_DSO_meth; | 119 ret->meth = default_DSO_meth; |
| 120 else | 120 else |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 DSOerr(DSO_F_DSO_FREE,DSO_R_UNLOAD_FAILED); | 156 DSOerr(DSO_F_DSO_FREE,DSO_R_UNLOAD_FAILED); |
| 157 return(0); | 157 return(0); |
| 158 } | 158 } |
| 159 | 159 |
| 160 if((dso->meth->finish != NULL) && !dso->meth->finish(dso)) | 160 if((dso->meth->finish != NULL) && !dso->meth->finish(dso)) |
| 161 { | 161 { |
| 162 DSOerr(DSO_F_DSO_FREE,DSO_R_FINISH_FAILED); | 162 DSOerr(DSO_F_DSO_FREE,DSO_R_FINISH_FAILED); |
| 163 return(0); | 163 return(0); |
| 164 } | 164 } |
| 165 | 165 |
| 166 » sk_free(dso->meth_data); | 166 » sk_void_free(dso->meth_data); |
| 167 if(dso->filename != NULL) | 167 if(dso->filename != NULL) |
| 168 OPENSSL_free(dso->filename); | 168 OPENSSL_free(dso->filename); |
| 169 if(dso->loaded_filename != NULL) | 169 if(dso->loaded_filename != NULL) |
| 170 OPENSSL_free(dso->loaded_filename); | 170 OPENSSL_free(dso->loaded_filename); |
| 171 | 171 |
| 172 OPENSSL_free(dso); | 172 OPENSSL_free(dso); |
| 173 return(1); | 173 return(1); |
| 174 } | 174 } |
| 175 | 175 |
| 176 int DSO_flags(DSO *dso) | 176 int DSO_flags(DSO *dso) |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 | 392 |
| 393 char *DSO_merge(DSO *dso, const char *filespec1, const char *filespec2) | 393 char *DSO_merge(DSO *dso, const char *filespec1, const char *filespec2) |
| 394 { | 394 { |
| 395 char *result = NULL; | 395 char *result = NULL; |
| 396 | 396 |
| 397 if(dso == NULL || filespec1 == NULL) | 397 if(dso == NULL || filespec1 == NULL) |
| 398 { | 398 { |
| 399 DSOerr(DSO_F_DSO_MERGE,ERR_R_PASSED_NULL_PARAMETER); | 399 DSOerr(DSO_F_DSO_MERGE,ERR_R_PASSED_NULL_PARAMETER); |
| 400 return(NULL); | 400 return(NULL); |
| 401 } | 401 } |
| 402 if(filespec1 == NULL) | |
| 403 filespec1 = dso->filename; | |
| 404 if(filespec1 == NULL) | |
| 405 { | |
| 406 DSOerr(DSO_F_DSO_MERGE,DSO_R_NO_FILE_SPECIFICATION); | |
| 407 return(NULL); | |
| 408 } | |
| 409 if((dso->flags & DSO_FLAG_NO_NAME_TRANSLATION) == 0) | 402 if((dso->flags & DSO_FLAG_NO_NAME_TRANSLATION) == 0) |
| 410 { | 403 { |
| 411 if(dso->merger != NULL) | 404 if(dso->merger != NULL) |
| 412 result = dso->merger(dso, filespec1, filespec2); | 405 result = dso->merger(dso, filespec1, filespec2); |
| 413 else if(dso->meth->dso_merger != NULL) | 406 else if(dso->meth->dso_merger != NULL) |
| 414 result = dso->meth->dso_merger(dso, | 407 result = dso->meth->dso_merger(dso, |
| 415 filespec1, filespec2); | 408 filespec1, filespec2); |
| 416 } | 409 } |
| 417 return(result); | 410 return(result); |
| 418 } | 411 } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 const char *DSO_get_loaded_filename(DSO *dso) | 450 const char *DSO_get_loaded_filename(DSO *dso) |
| 458 { | 451 { |
| 459 if(dso == NULL) | 452 if(dso == NULL) |
| 460 { | 453 { |
| 461 DSOerr(DSO_F_DSO_GET_LOADED_FILENAME, | 454 DSOerr(DSO_F_DSO_GET_LOADED_FILENAME, |
| 462 ERR_R_PASSED_NULL_PARAMETER); | 455 ERR_R_PASSED_NULL_PARAMETER); |
| 463 return(NULL); | 456 return(NULL); |
| 464 } | 457 } |
| 465 return(dso->loaded_filename); | 458 return(dso->loaded_filename); |
| 466 } | 459 } |
| 460 |
| 461 int DSO_pathbyaddr(void *addr,char *path,int sz) |
| 462 { |
| 463 DSO_METHOD *meth = default_DSO_meth; |
| 464 if (meth == NULL) meth = DSO_METHOD_openssl(); |
| 465 if (meth->pathbyaddr == NULL) |
| 466 { |
| 467 DSOerr(DSO_F_DSO_PATHBYADDR,DSO_R_UNSUPPORTED); |
| 468 return -1; |
| 469 } |
| 470 return (*meth->pathbyaddr)(addr,path,sz); |
| 471 } |
| 472 |
| 473 void *DSO_global_lookup(const char *name) |
| 474 { |
| 475 DSO_METHOD *meth = default_DSO_meth; |
| 476 if (meth == NULL) meth = DSO_METHOD_openssl(); |
| 477 if (meth->globallookup == NULL) |
| 478 { |
| 479 DSOerr(DSO_F_DSO_GLOBAL_LOOKUP,DSO_R_UNSUPPORTED); |
| 480 return NULL; |
| 481 } |
| 482 return (*meth->globallookup)(name); |
| 483 } |
| OLD | NEW |