diff options
| author | markus <> | 2002-09-05 12:51:52 +0000 |
|---|---|---|
| committer | markus <> | 2002-09-05 12:51:52 +0000 |
| commit | 5514995a9d5ed91db089875adb509c7781357c0e (patch) | |
| tree | 2484410a46ba6c05ef94c253da36fbceef990b64 /src/lib/libcrypto/dso | |
| parent | fd9566423b542798f5c8b06e68101a9ea5bb9885 (diff) | |
| download | openbsd-5514995a9d5ed91db089875adb509c7781357c0e.tar.gz openbsd-5514995a9d5ed91db089875adb509c7781357c0e.tar.bz2 openbsd-5514995a9d5ed91db089875adb509c7781357c0e.zip | |
import openssl-0.9.7-beta1
Diffstat (limited to 'src/lib/libcrypto/dso')
| -rw-r--r-- | src/lib/libcrypto/dso/README | 24 | ||||
| -rw-r--r-- | src/lib/libcrypto/dso/dso_dl.c | 111 | ||||
| -rw-r--r-- | src/lib/libcrypto/dso/dso_vms.c | 86 | ||||
| -rw-r--r-- | src/lib/libcrypto/dso/dso_win32.c | 112 |
4 files changed, 189 insertions, 144 deletions
diff --git a/src/lib/libcrypto/dso/README b/src/lib/libcrypto/dso/README index 6ba03c5631..d0bc9a89fb 100644 --- a/src/lib/libcrypto/dso/README +++ b/src/lib/libcrypto/dso/README | |||
| @@ -1,16 +1,3 @@ | |||
| 1 | TODO | ||
| 2 | ---- | ||
| 3 | |||
| 4 | Find a way where name-translation can be done in a way that is | ||
| 5 | sensitive to particular methods (ie. generic code could still do | ||
| 6 | different path/filename substitutions on win32 to what it does on | ||
| 7 | *nix) but doesn't assume some canonical form. Already one case | ||
| 8 | exists where the "blah -> (libblah.so,blah.dll)" mapping doesn't | ||
| 9 | suffice. I suspect a callback with an enumerated (or string?) | ||
| 10 | parameter could be the way to go here ... DSO_ctrl the callback | ||
| 11 | into place and it can be invoked to handle name translation with | ||
| 12 | some clue to the calling code as to what kind of system it is. | ||
| 13 | |||
| 14 | NOTES | 1 | NOTES |
| 15 | ----- | 2 | ----- |
| 16 | 3 | ||
| @@ -21,4 +8,15 @@ according to their man page, prefer developers to move to that. | |||
| 21 | I'll leave Richard's changes there as I guess dso_dl is needed | 8 | I'll leave Richard's changes there as I guess dso_dl is needed |
| 22 | for HPUX10.20. | 9 | for HPUX10.20. |
| 23 | 10 | ||
| 11 | There is now a callback scheme in place where filename conversion can | ||
| 12 | (a) be turned off altogether through the use of the | ||
| 13 | DSO_FLAG_NO_NAME_TRANSLATION flag, | ||
| 14 | (b) be handled by default using the default DSO_METHOD's converter | ||
| 15 | (c) overriden per-DSO by setting the override callback | ||
| 16 | (d) a mix of (b) and (c) - eg. implement an override callback that; | ||
| 17 | (i) checks if we're win32 (if(strstr(dso->meth->name, "win32")....) | ||
| 18 | and if so, convert "blah" into "blah32.dll" (the default is | ||
| 19 | otherwise to make it "blah.dll"). | ||
| 20 | (ii) default to the normal behaviour - we're not on win32, eg. | ||
| 21 | finish with (return dso->meth->dso_name_converter(dso,NULL)). | ||
| 24 | 22 | ||
diff --git a/src/lib/libcrypto/dso/dso_dl.c b/src/lib/libcrypto/dso/dso_dl.c index 69810fc3bb..195717e993 100644 --- a/src/lib/libcrypto/dso/dso_dl.c +++ b/src/lib/libcrypto/dso/dso_dl.c | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* dso_dl.c */ | 1 | /* dso_dl.c */ |
| 2 | /* Written by Richard Levitte (levitte@openssl.org) for the OpenSSL | 2 | /* Written by Richard Levitte (richard@levitte.org) for the OpenSSL |
| 3 | * project 2000. | 3 | * project 2000. |
| 4 | */ | 4 | */ |
| 5 | /* ==================================================================== | 5 | /* ==================================================================== |
| @@ -72,7 +72,7 @@ DSO_METHOD *DSO_METHOD_dl(void) | |||
| 72 | /* Part of the hack in "dl_load" ... */ | 72 | /* Part of the hack in "dl_load" ... */ |
| 73 | #define DSO_MAX_TRANSLATED_SIZE 256 | 73 | #define DSO_MAX_TRANSLATED_SIZE 256 |
| 74 | 74 | ||
| 75 | static int dl_load(DSO *dso, const char *filename); | 75 | static int dl_load(DSO *dso); |
| 76 | static int dl_unload(DSO *dso); | 76 | static int dl_unload(DSO *dso); |
| 77 | static void *dl_bind_var(DSO *dso, const char *symname); | 77 | static void *dl_bind_var(DSO *dso, const char *symname); |
| 78 | static DSO_FUNC_TYPE dl_bind_func(DSO *dso, const char *symname); | 78 | static DSO_FUNC_TYPE dl_bind_func(DSO *dso, const char *symname); |
| @@ -81,8 +81,9 @@ static int dl_unbind_var(DSO *dso, char *symname, void *symptr); | |||
| 81 | static int dl_unbind_func(DSO *dso, char *symname, DSO_FUNC_TYPE symptr); | 81 | static int dl_unbind_func(DSO *dso, char *symname, DSO_FUNC_TYPE symptr); |
| 82 | static int dl_init(DSO *dso); | 82 | static int dl_init(DSO *dso); |
| 83 | static int dl_finish(DSO *dso); | 83 | static int dl_finish(DSO *dso); |
| 84 | #endif | ||
| 85 | static int dl_ctrl(DSO *dso, int cmd, long larg, void *parg); | 84 | static int dl_ctrl(DSO *dso, int cmd, long larg, void *parg); |
| 85 | #endif | ||
| 86 | static char *dl_name_converter(DSO *dso, const char *filename); | ||
| 86 | 87 | ||
| 87 | static DSO_METHOD dso_meth_dl = { | 88 | static DSO_METHOD dso_meth_dl = { |
| 88 | "OpenSSL 'dl' shared library method", | 89 | "OpenSSL 'dl' shared library method", |
| @@ -95,7 +96,8 @@ static DSO_METHOD dso_meth_dl = { | |||
| 95 | NULL, /* unbind_var */ | 96 | NULL, /* unbind_var */ |
| 96 | NULL, /* unbind_func */ | 97 | NULL, /* unbind_func */ |
| 97 | #endif | 98 | #endif |
| 98 | dl_ctrl, | 99 | NULL, /* ctrl */ |
| 100 | dl_name_converter, | ||
| 99 | NULL, /* init */ | 101 | NULL, /* init */ |
| 100 | NULL /* finish */ | 102 | NULL /* finish */ |
| 101 | }; | 103 | }; |
| @@ -111,35 +113,43 @@ DSO_METHOD *DSO_METHOD_dl(void) | |||
| 111 | * type so the cast is safe. | 113 | * type so the cast is safe. |
| 112 | */ | 114 | */ |
| 113 | 115 | ||
| 114 | static int dl_load(DSO *dso, const char *filename) | 116 | static int dl_load(DSO *dso) |
| 115 | { | 117 | { |
| 116 | shl_t ptr; | 118 | shl_t ptr = NULL; |
| 117 | char translated[DSO_MAX_TRANSLATED_SIZE]; | 119 | /* We don't do any fancy retries or anything, just take the method's |
| 118 | int len; | 120 | * (or DSO's if it has the callback set) best translation of the |
| 121 | * platform-independant filename and try once with that. */ | ||
| 122 | char *filename= DSO_convert_filename(dso, NULL); | ||
| 119 | 123 | ||
| 120 | /* The same comment as in dlfcn_load applies here. bleurgh. */ | 124 | if(filename == NULL) |
| 121 | len = strlen(filename); | ||
| 122 | if((dso->flags & DSO_FLAG_NAME_TRANSLATION) && | ||
| 123 | (len + 6 < DSO_MAX_TRANSLATED_SIZE) && | ||
| 124 | (strstr(filename, "/") == NULL)) | ||
| 125 | { | 125 | { |
| 126 | sprintf(translated, "lib%s.so", filename); | 126 | DSOerr(DSO_F_DL_LOAD,DSO_R_NO_FILENAME); |
| 127 | ptr = shl_load(translated, BIND_IMMEDIATE, NULL); | 127 | goto err; |
| 128 | } | 128 | } |
| 129 | else | 129 | ptr = shl_load(filename, BIND_IMMEDIATE|DYNAMIC_PATH, NULL); |
| 130 | ptr = shl_load(filename, BIND_IMMEDIATE, NULL); | ||
| 131 | if(ptr == NULL) | 130 | if(ptr == NULL) |
| 132 | { | 131 | { |
| 133 | DSOerr(DSO_F_DL_LOAD,DSO_R_LOAD_FAILED); | 132 | DSOerr(DSO_F_DL_LOAD,DSO_R_LOAD_FAILED); |
| 134 | return(0); | 133 | ERR_add_error_data(4, "filename(", filename, "): ", |
| 134 | strerror(errno)); | ||
| 135 | goto err; | ||
| 135 | } | 136 | } |
| 136 | if(!sk_push(dso->meth_data, (char *)ptr)) | 137 | if(!sk_push(dso->meth_data, (char *)ptr)) |
| 137 | { | 138 | { |
| 138 | DSOerr(DSO_F_DL_LOAD,DSO_R_STACK_ERROR); | 139 | DSOerr(DSO_F_DL_LOAD,DSO_R_STACK_ERROR); |
| 139 | shl_unload(ptr); | 140 | goto err; |
| 140 | return(0); | ||
| 141 | } | 141 | } |
| 142 | /* Success, stick the converted filename we've loaded under into the DSO | ||
| 143 | * (it also serves as the indicator that we are currently loaded). */ | ||
| 144 | dso->loaded_filename = filename; | ||
| 142 | return(1); | 145 | return(1); |
| 146 | err: | ||
| 147 | /* Cleanup! */ | ||
| 148 | if(filename != NULL) | ||
| 149 | OPENSSL_free(filename); | ||
| 150 | if(ptr != NULL) | ||
| 151 | shl_unload(ptr); | ||
| 152 | return(0); | ||
| 143 | } | 153 | } |
| 144 | 154 | ||
| 145 | static int dl_unload(DSO *dso) | 155 | static int dl_unload(DSO *dso) |
| @@ -187,9 +197,11 @@ static void *dl_bind_var(DSO *dso, const char *symname) | |||
| 187 | DSOerr(DSO_F_DL_BIND_VAR,DSO_R_NULL_HANDLE); | 197 | DSOerr(DSO_F_DL_BIND_VAR,DSO_R_NULL_HANDLE); |
| 188 | return(NULL); | 198 | return(NULL); |
| 189 | } | 199 | } |
| 190 | if (shl_findsym(ptr, symname, TYPE_UNDEFINED, &sym) < 0) | 200 | if (shl_findsym(&ptr, symname, TYPE_UNDEFINED, &sym) < 0) |
| 191 | { | 201 | { |
| 192 | DSOerr(DSO_F_DL_BIND_VAR,DSO_R_SYM_FAILURE); | 202 | DSOerr(DSO_F_DL_BIND_VAR,DSO_R_SYM_FAILURE); |
| 203 | ERR_add_error_data(4, "symname(", symname, "): ", | ||
| 204 | strerror(errno)); | ||
| 193 | return(NULL); | 205 | return(NULL); |
| 194 | } | 206 | } |
| 195 | return(sym); | 207 | return(sym); |
| @@ -216,36 +228,57 @@ static DSO_FUNC_TYPE dl_bind_func(DSO *dso, const char *symname) | |||
| 216 | DSOerr(DSO_F_DL_BIND_FUNC,DSO_R_NULL_HANDLE); | 228 | DSOerr(DSO_F_DL_BIND_FUNC,DSO_R_NULL_HANDLE); |
| 217 | return(NULL); | 229 | return(NULL); |
| 218 | } | 230 | } |
| 219 | if (shl_findsym(ptr, symname, TYPE_UNDEFINED, &sym) < 0) | 231 | if (shl_findsym(&ptr, symname, TYPE_UNDEFINED, &sym) < 0) |
| 220 | { | 232 | { |
| 221 | DSOerr(DSO_F_DL_BIND_FUNC,DSO_R_SYM_FAILURE); | 233 | DSOerr(DSO_F_DL_BIND_FUNC,DSO_R_SYM_FAILURE); |
| 234 | ERR_add_error_data(4, "symname(", symname, "): ", | ||
| 235 | strerror(errno)); | ||
| 222 | return(NULL); | 236 | return(NULL); |
| 223 | } | 237 | } |
| 224 | return((DSO_FUNC_TYPE)sym); | 238 | return((DSO_FUNC_TYPE)sym); |
| 225 | } | 239 | } |
| 226 | 240 | ||
| 227 | static int dl_ctrl(DSO *dso, int cmd, long larg, void *parg) | 241 | /* This function is identical to the one in dso_dlfcn.c, but as it is highly |
| 242 | * unlikely that both the "dl" *and* "dlfcn" variants are being compiled at the | ||
| 243 | * same time, there's no great duplicating the code. Figuring out an elegant | ||
| 244 | * way to share one copy of the code would be more difficult and would not | ||
| 245 | * leave the implementations independant. */ | ||
| 246 | #if defined(__hpux) | ||
| 247 | static const char extension[] = ".sl"; | ||
| 248 | #else | ||
| 249 | static const char extension[] = ".so"; | ||
| 250 | #endif | ||
| 251 | static char *dl_name_converter(DSO *dso, const char *filename) | ||
| 228 | { | 252 | { |
| 229 | if(dso == NULL) | 253 | char *translated; |
| 254 | int len, rsize, transform; | ||
| 255 | |||
| 256 | len = strlen(filename); | ||
| 257 | rsize = len + 1; | ||
| 258 | transform = (strstr(filename, "/") == NULL); | ||
| 230 | { | 259 | { |
| 231 | DSOerr(DSO_F_DL_CTRL,ERR_R_PASSED_NULL_PARAMETER); | 260 | /* We will convert this to "%s.s?" or "lib%s.s?" */ |
| 232 | return(-1); | 261 | rsize += strlen(extension);/* The length of ".s?" */ |
| 262 | if ((DSO_flags(dso) & DSO_FLAG_NAME_TRANSLATION_EXT_ONLY) == 0) | ||
| 263 | rsize += 3; /* The length of "lib" */ | ||
| 233 | } | 264 | } |
| 234 | switch(cmd) | 265 | translated = OPENSSL_malloc(rsize); |
| 266 | if(translated == NULL) | ||
| 235 | { | 267 | { |
| 236 | case DSO_CTRL_GET_FLAGS: | 268 | DSOerr(DSO_F_DL_NAME_CONVERTER, |
| 237 | return dso->flags; | 269 | DSO_R_NAME_TRANSLATION_FAILED); |
| 238 | case DSO_CTRL_SET_FLAGS: | 270 | return(NULL); |
| 239 | dso->flags = (int)larg; | 271 | } |
| 240 | return(0); | 272 | if(transform) |
| 241 | case DSO_CTRL_OR_FLAGS: | 273 | { |
| 242 | dso->flags |= (int)larg; | 274 | if ((DSO_flags(dso) & DSO_FLAG_NAME_TRANSLATION_EXT_ONLY) == 0) |
| 243 | return(0); | 275 | sprintf(translated, "lib%s%s", filename, extension); |
| 244 | default: | 276 | else |
| 245 | break; | 277 | sprintf(translated, "%s%s", filename, extension); |
| 246 | } | 278 | } |
| 247 | DSOerr(DSO_F_DL_CTRL,DSO_R_UNKNOWN_COMMAND); | 279 | else |
| 248 | return(-1); | 280 | sprintf(translated, "%s", filename); |
| 281 | return(translated); | ||
| 249 | } | 282 | } |
| 250 | 283 | ||
| 251 | #endif /* DSO_DL */ | 284 | #endif /* DSO_DL */ |
diff --git a/src/lib/libcrypto/dso/dso_vms.c b/src/lib/libcrypto/dso/dso_vms.c index 8ff7090129..1674619d17 100644 --- a/src/lib/libcrypto/dso/dso_vms.c +++ b/src/lib/libcrypto/dso/dso_vms.c | |||
| @@ -59,18 +59,17 @@ | |||
| 59 | #include <stdio.h> | 59 | #include <stdio.h> |
| 60 | #include <string.h> | 60 | #include <string.h> |
| 61 | #include <errno.h> | 61 | #include <errno.h> |
| 62 | #ifdef VMS | 62 | #include "cryptlib.h" |
| 63 | #include <openssl/dso.h> | ||
| 64 | #ifdef OPENSSL_SYS_VMS | ||
| 63 | #pragma message disable DOLLARID | 65 | #pragma message disable DOLLARID |
| 64 | #include <lib$routines.h> | 66 | #include <lib$routines.h> |
| 65 | #include <libfisdef.h> | ||
| 66 | #include <stsdef.h> | 67 | #include <stsdef.h> |
| 67 | #include <descrip.h> | 68 | #include <descrip.h> |
| 68 | #include <starlet.h> | 69 | #include <starlet.h> |
| 69 | #endif | 70 | #endif |
| 70 | #include "cryptlib.h" | ||
| 71 | #include <openssl/dso.h> | ||
| 72 | 71 | ||
| 73 | #ifndef VMS | 72 | #ifndef OPENSSL_SYS_VMS |
| 74 | DSO_METHOD *DSO_METHOD_vms(void) | 73 | DSO_METHOD *DSO_METHOD_vms(void) |
| 75 | { | 74 | { |
| 76 | return NULL; | 75 | return NULL; |
| @@ -78,7 +77,7 @@ DSO_METHOD *DSO_METHOD_vms(void) | |||
| 78 | #else | 77 | #else |
| 79 | #pragma message disable DOLLARID | 78 | #pragma message disable DOLLARID |
| 80 | 79 | ||
| 81 | static int vms_load(DSO *dso, const char *filename); | 80 | static int vms_load(DSO *dso); |
| 82 | static int vms_unload(DSO *dso); | 81 | static int vms_unload(DSO *dso); |
| 83 | static void *vms_bind_var(DSO *dso, const char *symname); | 82 | static void *vms_bind_var(DSO *dso, const char *symname); |
| 84 | static DSO_FUNC_TYPE vms_bind_func(DSO *dso, const char *symname); | 83 | static DSO_FUNC_TYPE vms_bind_func(DSO *dso, const char *symname); |
| @@ -87,8 +86,9 @@ static int vms_unbind_var(DSO *dso, char *symname, void *symptr); | |||
| 87 | static int vms_unbind_func(DSO *dso, char *symname, DSO_FUNC_TYPE symptr); | 86 | static int vms_unbind_func(DSO *dso, char *symname, DSO_FUNC_TYPE symptr); |
| 88 | static int vms_init(DSO *dso); | 87 | static int vms_init(DSO *dso); |
| 89 | static int vms_finish(DSO *dso); | 88 | static int vms_finish(DSO *dso); |
| 90 | #endif | ||
| 91 | static long vms_ctrl(DSO *dso, int cmd, long larg, void *parg); | 89 | static long vms_ctrl(DSO *dso, int cmd, long larg, void *parg); |
| 90 | #endif | ||
| 91 | static char *vms_name_converter(DSO *dso, const char *filename); | ||
| 92 | 92 | ||
| 93 | static DSO_METHOD dso_meth_vms = { | 93 | static DSO_METHOD dso_meth_vms = { |
| 94 | "OpenSSL 'VMS' shared library method", | 94 | "OpenSSL 'VMS' shared library method", |
| @@ -101,7 +101,8 @@ static DSO_METHOD dso_meth_vms = { | |||
| 101 | NULL, /* unbind_var */ | 101 | NULL, /* unbind_var */ |
| 102 | NULL, /* unbind_func */ | 102 | NULL, /* unbind_func */ |
| 103 | #endif | 103 | #endif |
| 104 | vms_ctrl, | 104 | NULL, /* ctrl */ |
| 105 | vms_name_converter, | ||
| 105 | NULL, /* init */ | 106 | NULL, /* init */ |
| 106 | NULL /* finish */ | 107 | NULL /* finish */ |
| 107 | }; | 108 | }; |
| @@ -129,11 +130,20 @@ DSO_METHOD *DSO_METHOD_vms(void) | |||
| 129 | return(&dso_meth_vms); | 130 | return(&dso_meth_vms); |
| 130 | } | 131 | } |
| 131 | 132 | ||
| 132 | static int vms_load(DSO *dso, const char *filename) | 133 | static int vms_load(DSO *dso) |
| 133 | { | 134 | { |
| 135 | void *ptr = NULL; | ||
| 136 | /* See applicable comments in dso_dl.c */ | ||
| 137 | char *filename = DSO_convert_filename(dso, NULL); | ||
| 134 | DSO_VMS_INTERNAL *p; | 138 | DSO_VMS_INTERNAL *p; |
| 135 | const char *sp1, *sp2; /* Search result */ | 139 | const char *sp1, *sp2; /* Search result */ |
| 136 | 140 | ||
| 141 | if(filename == NULL) | ||
| 142 | { | ||
| 143 | DSOerr(DSO_F_DLFCN_LOAD,DSO_R_NO_FILENAME); | ||
| 144 | goto err; | ||
| 145 | } | ||
| 146 | |||
| 137 | /* A file specification may look like this: | 147 | /* A file specification may look like this: |
| 138 | * | 148 | * |
| 139 | * node::dev:[dir-spec]name.type;ver | 149 | * node::dev:[dir-spec]name.type;ver |
| @@ -175,14 +185,14 @@ static int vms_load(DSO *dso, const char *filename) | |||
| 175 | || (sp1 - filename) + strlen(sp2) > FILENAME_MAX) | 185 | || (sp1 - filename) + strlen(sp2) > FILENAME_MAX) |
| 176 | { | 186 | { |
| 177 | DSOerr(DSO_F_VMS_LOAD,DSO_R_FILENAME_TOO_BIG); | 187 | DSOerr(DSO_F_VMS_LOAD,DSO_R_FILENAME_TOO_BIG); |
| 178 | return(0); | 188 | goto err; |
| 179 | } | 189 | } |
| 180 | 190 | ||
| 181 | p = (DSO_VMS_INTERNAL *)OPENSSL_malloc(sizeof(DSO_VMS_INTERNAL)); | 191 | p = (DSO_VMS_INTERNAL *)OPENSSL_malloc(sizeof(DSO_VMS_INTERNAL)); |
| 182 | if(p == NULL) | 192 | if(p == NULL) |
| 183 | { | 193 | { |
| 184 | DSOerr(DSO_F_VMS_LOAD,ERR_R_MALLOC_FAILURE); | 194 | DSOerr(DSO_F_VMS_LOAD,ERR_R_MALLOC_FAILURE); |
| 185 | return(0); | 195 | goto err; |
| 186 | } | 196 | } |
| 187 | 197 | ||
| 188 | strncpy(p->filename, sp1, sp2-sp1); | 198 | strncpy(p->filename, sp1, sp2-sp1); |
| @@ -204,10 +214,19 @@ static int vms_load(DSO *dso, const char *filename) | |||
| 204 | if(!sk_push(dso->meth_data, (char *)p)) | 214 | if(!sk_push(dso->meth_data, (char *)p)) |
| 205 | { | 215 | { |
| 206 | DSOerr(DSO_F_VMS_LOAD,DSO_R_STACK_ERROR); | 216 | DSOerr(DSO_F_VMS_LOAD,DSO_R_STACK_ERROR); |
| 207 | OPENSSL_free(p); | 217 | goto err; |
| 208 | return(0); | ||
| 209 | } | 218 | } |
| 219 | |||
| 220 | /* Success (for now, we lie. We actually do not know...) */ | ||
| 221 | dso->loaded_filename = filename; | ||
| 210 | return(1); | 222 | return(1); |
| 223 | err: | ||
| 224 | /* Cleanup! */ | ||
| 225 | if(p != NULL) | ||
| 226 | OPENSSL_free(p); | ||
| 227 | if(filename != NULL) | ||
| 228 | OPENSSL_free(filename); | ||
| 229 | return(0); | ||
| 211 | } | 230 | } |
| 212 | 231 | ||
| 213 | /* Note that this doesn't actually unload the shared image, as there is no | 232 | /* Note that this doesn't actually unload the shared image, as there is no |
| @@ -260,7 +279,12 @@ void vms_bind_sym(DSO *dso, const char *symname, void **sym) | |||
| 260 | { | 279 | { |
| 261 | DSO_VMS_INTERNAL *ptr; | 280 | DSO_VMS_INTERNAL *ptr; |
| 262 | int status; | 281 | int status; |
| 263 | int flags = LIB$M_FIS_MIXEDCASE; | 282 | #if 0 |
| 283 | int flags = (1<<4); /* LIB$M_FIS_MIXEDCASE, but this symbol isn't | ||
| 284 | defined in VMS older than 7.0 or so */ | ||
| 285 | #else | ||
| 286 | int flags = 0; | ||
| 287 | #endif | ||
| 264 | struct dsc$descriptor_s symname_dsc; | 288 | struct dsc$descriptor_s symname_dsc; |
| 265 | *sym = NULL; | 289 | *sym = NULL; |
| 266 | 290 | ||
| @@ -344,28 +368,12 @@ static DSO_FUNC_TYPE vms_bind_func(DSO *dso, const char *symname) | |||
| 344 | return sym; | 368 | return sym; |
| 345 | } | 369 | } |
| 346 | 370 | ||
| 347 | static long vms_ctrl(DSO *dso, int cmd, long larg, void *parg) | 371 | static char *vms_name_converter(DSO *dso, const char *filename) |
| 348 | { | 372 | { |
| 349 | if(dso == NULL) | 373 | int len = strlen(filename); |
| 350 | { | 374 | char *not_translated = OPENSSL_malloc(len+1); |
| 351 | DSOerr(DSO_F_VMS_CTRL,ERR_R_PASSED_NULL_PARAMETER); | 375 | strcpy(not_translated,filename); |
| 352 | return(-1); | 376 | return(not_translated); |
| 353 | } | 377 | } |
| 354 | switch(cmd) | 378 | |
| 355 | { | 379 | #endif /* OPENSSL_SYS_VMS */ |
| 356 | case DSO_CTRL_GET_FLAGS: | ||
| 357 | return dso->flags; | ||
| 358 | case DSO_CTRL_SET_FLAGS: | ||
| 359 | dso->flags = (int)larg; | ||
| 360 | return(0); | ||
| 361 | case DSO_CTRL_OR_FLAGS: | ||
| 362 | dso->flags |= (int)larg; | ||
| 363 | return(0); | ||
| 364 | default: | ||
| 365 | break; | ||
| 366 | } | ||
| 367 | DSOerr(DSO_F_VMS_CTRL,DSO_R_UNKNOWN_COMMAND); | ||
| 368 | return(-1); | ||
| 369 | } | ||
| 370 | |||
| 371 | #endif /* VMS */ | ||
diff --git a/src/lib/libcrypto/dso/dso_win32.c b/src/lib/libcrypto/dso/dso_win32.c index 7f1d904806..af8586d754 100644 --- a/src/lib/libcrypto/dso/dso_win32.c +++ b/src/lib/libcrypto/dso/dso_win32.c | |||
| @@ -61,7 +61,7 @@ | |||
| 61 | #include "cryptlib.h" | 61 | #include "cryptlib.h" |
| 62 | #include <openssl/dso.h> | 62 | #include <openssl/dso.h> |
| 63 | 63 | ||
| 64 | #ifndef WIN32 | 64 | #ifndef OPENSSL_SYS_WIN32 |
| 65 | DSO_METHOD *DSO_METHOD_win32(void) | 65 | DSO_METHOD *DSO_METHOD_win32(void) |
| 66 | { | 66 | { |
| 67 | return NULL; | 67 | return NULL; |
| @@ -71,7 +71,7 @@ DSO_METHOD *DSO_METHOD_win32(void) | |||
| 71 | /* Part of the hack in "win32_load" ... */ | 71 | /* Part of the hack in "win32_load" ... */ |
| 72 | #define DSO_MAX_TRANSLATED_SIZE 256 | 72 | #define DSO_MAX_TRANSLATED_SIZE 256 |
| 73 | 73 | ||
| 74 | static int win32_load(DSO *dso, const char *filename); | 74 | static int win32_load(DSO *dso); |
| 75 | static int win32_unload(DSO *dso); | 75 | static int win32_unload(DSO *dso); |
| 76 | static void *win32_bind_var(DSO *dso, const char *symname); | 76 | static void *win32_bind_var(DSO *dso, const char *symname); |
| 77 | static DSO_FUNC_TYPE win32_bind_func(DSO *dso, const char *symname); | 77 | static DSO_FUNC_TYPE win32_bind_func(DSO *dso, const char *symname); |
| @@ -80,8 +80,9 @@ static int win32_unbind_var(DSO *dso, char *symname, void *symptr); | |||
| 80 | static int win32_unbind_func(DSO *dso, char *symname, DSO_FUNC_TYPE symptr); | 80 | static int win32_unbind_func(DSO *dso, char *symname, DSO_FUNC_TYPE symptr); |
| 81 | static int win32_init(DSO *dso); | 81 | static int win32_init(DSO *dso); |
| 82 | static int win32_finish(DSO *dso); | 82 | static int win32_finish(DSO *dso); |
| 83 | #endif | ||
| 84 | static long win32_ctrl(DSO *dso, int cmd, long larg, void *parg); | 83 | static long win32_ctrl(DSO *dso, int cmd, long larg, void *parg); |
| 84 | #endif | ||
| 85 | static char *win32_name_converter(DSO *dso, const char *filename); | ||
| 85 | 86 | ||
| 86 | static DSO_METHOD dso_meth_win32 = { | 87 | static DSO_METHOD dso_meth_win32 = { |
| 87 | "OpenSSL 'win32' shared library method", | 88 | "OpenSSL 'win32' shared library method", |
| @@ -94,7 +95,8 @@ static DSO_METHOD dso_meth_win32 = { | |||
| 94 | NULL, /* unbind_var */ | 95 | NULL, /* unbind_var */ |
| 95 | NULL, /* unbind_func */ | 96 | NULL, /* unbind_func */ |
| 96 | #endif | 97 | #endif |
| 97 | win32_ctrl, | 98 | NULL, /* ctrl */ |
| 99 | win32_name_converter, | ||
| 98 | NULL, /* init */ | 100 | NULL, /* init */ |
| 99 | NULL /* finish */ | 101 | NULL /* finish */ |
| 100 | }; | 102 | }; |
| @@ -109,50 +111,48 @@ DSO_METHOD *DSO_METHOD_win32(void) | |||
| 109 | * LoadLibrary(), and copied. | 111 | * LoadLibrary(), and copied. |
| 110 | */ | 112 | */ |
| 111 | 113 | ||
| 112 | static int win32_load(DSO *dso, const char *filename) | 114 | static int win32_load(DSO *dso) |
| 113 | { | 115 | { |
| 114 | HINSTANCE h, *p; | 116 | HINSTANCE h = NULL, *p = NULL; |
| 115 | char translated[DSO_MAX_TRANSLATED_SIZE]; | 117 | /* See applicable comments from dso_dl.c */ |
| 116 | int len; | 118 | char *filename = DSO_convert_filename(dso, NULL); |
| 117 | 119 | ||
| 118 | /* NB: This is a hideous hack, but I'm not yet sure what | 120 | if(filename == NULL) |
| 119 | * to replace it with. This attempts to convert any filename, | ||
| 120 | * that looks like it has no path information, into a | ||
| 121 | * translated form, e. "blah" -> "blah.dll" ... I'm more | ||
| 122 | * comfortable putting hacks into win32 code though ;-) */ | ||
| 123 | len = strlen(filename); | ||
| 124 | if((dso->flags & DSO_FLAG_NAME_TRANSLATION) && | ||
| 125 | (len + 4 < DSO_MAX_TRANSLATED_SIZE) && | ||
| 126 | (strstr(filename, "/") == NULL) && | ||
| 127 | (strstr(filename, "\\") == NULL) && | ||
| 128 | (strstr(filename, ":") == NULL)) | ||
| 129 | { | 121 | { |
| 130 | sprintf(translated, "%s.dll", filename); | 122 | DSOerr(DSO_F_WIN32_LOAD,DSO_R_NO_FILENAME); |
| 131 | h = LoadLibrary(translated); | 123 | goto err; |
| 132 | } | 124 | } |
| 133 | else | 125 | h = LoadLibrary(filename); |
| 134 | h = LoadLibrary(filename); | ||
| 135 | if(h == NULL) | 126 | if(h == NULL) |
| 136 | { | 127 | { |
| 137 | DSOerr(DSO_F_WIN32_LOAD,DSO_R_LOAD_FAILED); | 128 | DSOerr(DSO_F_WIN32_LOAD,DSO_R_LOAD_FAILED); |
| 138 | return(0); | 129 | ERR_add_error_data(3, "filename(", filename, ")"); |
| 130 | goto err; | ||
| 139 | } | 131 | } |
| 140 | p = (HINSTANCE *)OPENSSL_malloc(sizeof(HINSTANCE)); | 132 | p = (HINSTANCE *)OPENSSL_malloc(sizeof(HINSTANCE)); |
| 141 | if(p == NULL) | 133 | if(p == NULL) |
| 142 | { | 134 | { |
| 143 | DSOerr(DSO_F_WIN32_LOAD,ERR_R_MALLOC_FAILURE); | 135 | DSOerr(DSO_F_WIN32_LOAD,ERR_R_MALLOC_FAILURE); |
| 144 | FreeLibrary(h); | 136 | goto err; |
| 145 | return(0); | ||
| 146 | } | 137 | } |
| 147 | *p = h; | 138 | *p = h; |
| 148 | if(!sk_push(dso->meth_data, (char *)p)) | 139 | if(!sk_push(dso->meth_data, (char *)p)) |
| 149 | { | 140 | { |
| 150 | DSOerr(DSO_F_WIN32_LOAD,DSO_R_STACK_ERROR); | 141 | DSOerr(DSO_F_WIN32_LOAD,DSO_R_STACK_ERROR); |
| 151 | FreeLibrary(h); | 142 | goto err; |
| 152 | OPENSSL_free(p); | ||
| 153 | return(0); | ||
| 154 | } | 143 | } |
| 144 | /* Success */ | ||
| 145 | dso->loaded_filename = filename; | ||
| 155 | return(1); | 146 | return(1); |
| 147 | err: | ||
| 148 | /* Cleanup !*/ | ||
| 149 | if(filename != NULL) | ||
| 150 | OPENSSL_free(filename); | ||
| 151 | if(p != NULL) | ||
| 152 | OPENSSL_free(p); | ||
| 153 | if(h != NULL) | ||
| 154 | FreeLibrary(h); | ||
| 155 | return(0); | ||
| 156 | } | 156 | } |
| 157 | 157 | ||
| 158 | static int win32_unload(DSO *dso) | 158 | static int win32_unload(DSO *dso) |
| @@ -211,6 +211,7 @@ static void *win32_bind_var(DSO *dso, const char *symname) | |||
| 211 | if(sym == NULL) | 211 | if(sym == NULL) |
| 212 | { | 212 | { |
| 213 | DSOerr(DSO_F_WIN32_BIND_VAR,DSO_R_SYM_FAILURE); | 213 | DSOerr(DSO_F_WIN32_BIND_VAR,DSO_R_SYM_FAILURE); |
| 214 | ERR_add_error_data(3, "symname(", symname, ")"); | ||
| 214 | return(NULL); | 215 | return(NULL); |
| 215 | } | 216 | } |
| 216 | return(sym); | 217 | return(sym); |
| @@ -241,33 +242,38 @@ static DSO_FUNC_TYPE win32_bind_func(DSO *dso, const char *symname) | |||
| 241 | if(sym == NULL) | 242 | if(sym == NULL) |
| 242 | { | 243 | { |
| 243 | DSOerr(DSO_F_WIN32_BIND_FUNC,DSO_R_SYM_FAILURE); | 244 | DSOerr(DSO_F_WIN32_BIND_FUNC,DSO_R_SYM_FAILURE); |
| 245 | ERR_add_error_data(3, "symname(", symname, ")"); | ||
| 244 | return(NULL); | 246 | return(NULL); |
| 245 | } | 247 | } |
| 246 | return((DSO_FUNC_TYPE)sym); | 248 | return((DSO_FUNC_TYPE)sym); |
| 247 | } | 249 | } |
| 248 | 250 | ||
| 249 | static long win32_ctrl(DSO *dso, int cmd, long larg, void *parg) | 251 | static char *win32_name_converter(DSO *dso, const char *filename) |
| 250 | { | 252 | { |
| 251 | if(dso == NULL) | 253 | char *translated; |
| 252 | { | 254 | int len, transform; |
| 253 | DSOerr(DSO_F_WIN32_CTRL,ERR_R_PASSED_NULL_PARAMETER); | 255 | |
| 254 | return(-1); | 256 | len = strlen(filename); |
| 255 | } | 257 | transform = ((strstr(filename, "/") == NULL) && |
| 256 | switch(cmd) | 258 | (strstr(filename, "\\") == NULL) && |
| 257 | { | 259 | (strstr(filename, ":") == NULL)); |
| 258 | case DSO_CTRL_GET_FLAGS: | 260 | if(transform) |
| 259 | return dso->flags; | 261 | /* We will convert this to "%s.dll" */ |
| 260 | case DSO_CTRL_SET_FLAGS: | 262 | translated = OPENSSL_malloc(len + 5); |
| 261 | dso->flags = (int)larg; | 263 | else |
| 262 | return(0); | 264 | /* We will simply duplicate filename */ |
| 263 | case DSO_CTRL_OR_FLAGS: | 265 | translated = OPENSSL_malloc(len + 1); |
| 264 | dso->flags |= (int)larg; | 266 | if(translated == NULL) |
| 265 | return(0); | 267 | { |
| 266 | default: | 268 | DSOerr(DSO_F_WIN32_NAME_CONVERTER, |
| 267 | break; | 269 | DSO_R_NAME_TRANSLATION_FAILED); |
| 268 | } | 270 | return(NULL); |
| 269 | DSOerr(DSO_F_WIN32_CTRL,DSO_R_UNKNOWN_COMMAND); | 271 | } |
| 270 | return(-1); | 272 | if(transform) |
| 271 | } | 273 | sprintf(translated, "%s.dll", filename); |
| 274 | else | ||
| 275 | sprintf(translated, "%s", filename); | ||
| 276 | return(translated); | ||
| 277 | } | ||
| 272 | 278 | ||
| 273 | #endif /* WIN32 */ | 279 | #endif /* OPENSSL_SYS_WIN32 */ |
