diff options
Diffstat (limited to 'src/lib/libcrypto/dso/dso_vms.c')
-rw-r--r-- | src/lib/libcrypto/dso/dso_vms.c | 82 |
1 files changed, 45 insertions, 37 deletions
diff --git a/src/lib/libcrypto/dso/dso_vms.c b/src/lib/libcrypto/dso/dso_vms.c index ab48b63eb7..1674619d17 100644 --- a/src/lib/libcrypto/dso/dso_vms.c +++ b/src/lib/libcrypto/dso/dso_vms.c | |||
@@ -59,17 +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 <stsdef.h> | 67 | #include <stsdef.h> |
66 | #include <descrip.h> | 68 | #include <descrip.h> |
67 | #include <starlet.h> | 69 | #include <starlet.h> |
68 | #endif | 70 | #endif |
69 | #include "cryptlib.h" | ||
70 | #include <openssl/dso.h> | ||
71 | 71 | ||
72 | #ifndef VMS | 72 | #ifndef OPENSSL_SYS_VMS |
73 | DSO_METHOD *DSO_METHOD_vms(void) | 73 | DSO_METHOD *DSO_METHOD_vms(void) |
74 | { | 74 | { |
75 | return NULL; | 75 | return NULL; |
@@ -77,7 +77,7 @@ DSO_METHOD *DSO_METHOD_vms(void) | |||
77 | #else | 77 | #else |
78 | #pragma message disable DOLLARID | 78 | #pragma message disable DOLLARID |
79 | 79 | ||
80 | static int vms_load(DSO *dso, const char *filename); | 80 | static int vms_load(DSO *dso); |
81 | static int vms_unload(DSO *dso); | 81 | static int vms_unload(DSO *dso); |
82 | static void *vms_bind_var(DSO *dso, const char *symname); | 82 | static void *vms_bind_var(DSO *dso, const char *symname); |
83 | 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); |
@@ -86,8 +86,9 @@ static int vms_unbind_var(DSO *dso, char *symname, void *symptr); | |||
86 | 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); |
87 | static int vms_init(DSO *dso); | 87 | static int vms_init(DSO *dso); |
88 | static int vms_finish(DSO *dso); | 88 | static int vms_finish(DSO *dso); |
89 | #endif | ||
90 | 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); | ||
91 | 92 | ||
92 | static DSO_METHOD dso_meth_vms = { | 93 | static DSO_METHOD dso_meth_vms = { |
93 | "OpenSSL 'VMS' shared library method", | 94 | "OpenSSL 'VMS' shared library method", |
@@ -100,7 +101,8 @@ static DSO_METHOD dso_meth_vms = { | |||
100 | NULL, /* unbind_var */ | 101 | NULL, /* unbind_var */ |
101 | NULL, /* unbind_func */ | 102 | NULL, /* unbind_func */ |
102 | #endif | 103 | #endif |
103 | vms_ctrl, | 104 | NULL, /* ctrl */ |
105 | vms_name_converter, | ||
104 | NULL, /* init */ | 106 | NULL, /* init */ |
105 | NULL /* finish */ | 107 | NULL /* finish */ |
106 | }; | 108 | }; |
@@ -128,11 +130,20 @@ DSO_METHOD *DSO_METHOD_vms(void) | |||
128 | return(&dso_meth_vms); | 130 | return(&dso_meth_vms); |
129 | } | 131 | } |
130 | 132 | ||
131 | static int vms_load(DSO *dso, const char *filename) | 133 | static int vms_load(DSO *dso) |
132 | { | 134 | { |
135 | void *ptr = NULL; | ||
136 | /* See applicable comments in dso_dl.c */ | ||
137 | char *filename = DSO_convert_filename(dso, NULL); | ||
133 | DSO_VMS_INTERNAL *p; | 138 | DSO_VMS_INTERNAL *p; |
134 | const char *sp1, *sp2; /* Search result */ | 139 | const char *sp1, *sp2; /* Search result */ |
135 | 140 | ||
141 | if(filename == NULL) | ||
142 | { | ||
143 | DSOerr(DSO_F_DLFCN_LOAD,DSO_R_NO_FILENAME); | ||
144 | goto err; | ||
145 | } | ||
146 | |||
136 | /* A file specification may look like this: | 147 | /* A file specification may look like this: |
137 | * | 148 | * |
138 | * node::dev:[dir-spec]name.type;ver | 149 | * node::dev:[dir-spec]name.type;ver |
@@ -174,14 +185,14 @@ static int vms_load(DSO *dso, const char *filename) | |||
174 | || (sp1 - filename) + strlen(sp2) > FILENAME_MAX) | 185 | || (sp1 - filename) + strlen(sp2) > FILENAME_MAX) |
175 | { | 186 | { |
176 | DSOerr(DSO_F_VMS_LOAD,DSO_R_FILENAME_TOO_BIG); | 187 | DSOerr(DSO_F_VMS_LOAD,DSO_R_FILENAME_TOO_BIG); |
177 | return(0); | 188 | goto err; |
178 | } | 189 | } |
179 | 190 | ||
180 | p = (DSO_VMS_INTERNAL *)OPENSSL_malloc(sizeof(DSO_VMS_INTERNAL)); | 191 | p = (DSO_VMS_INTERNAL *)OPENSSL_malloc(sizeof(DSO_VMS_INTERNAL)); |
181 | if(p == NULL) | 192 | if(p == NULL) |
182 | { | 193 | { |
183 | DSOerr(DSO_F_VMS_LOAD,ERR_R_MALLOC_FAILURE); | 194 | DSOerr(DSO_F_VMS_LOAD,ERR_R_MALLOC_FAILURE); |
184 | return(0); | 195 | goto err; |
185 | } | 196 | } |
186 | 197 | ||
187 | strncpy(p->filename, sp1, sp2-sp1); | 198 | strncpy(p->filename, sp1, sp2-sp1); |
@@ -203,10 +214,19 @@ static int vms_load(DSO *dso, const char *filename) | |||
203 | if(!sk_push(dso->meth_data, (char *)p)) | 214 | if(!sk_push(dso->meth_data, (char *)p)) |
204 | { | 215 | { |
205 | DSOerr(DSO_F_VMS_LOAD,DSO_R_STACK_ERROR); | 216 | DSOerr(DSO_F_VMS_LOAD,DSO_R_STACK_ERROR); |
206 | OPENSSL_free(p); | 217 | goto err; |
207 | return(0); | ||
208 | } | 218 | } |
219 | |||
220 | /* Success (for now, we lie. We actually do not know...) */ | ||
221 | dso->loaded_filename = filename; | ||
209 | 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); | ||
210 | } | 230 | } |
211 | 231 | ||
212 | /* 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 |
@@ -259,8 +279,12 @@ void vms_bind_sym(DSO *dso, const char *symname, void **sym) | |||
259 | { | 279 | { |
260 | DSO_VMS_INTERNAL *ptr; | 280 | DSO_VMS_INTERNAL *ptr; |
261 | int status; | 281 | int status; |
282 | #if 0 | ||
262 | int flags = (1<<4); /* LIB$M_FIS_MIXEDCASE, but this symbol isn't | 283 | int flags = (1<<4); /* LIB$M_FIS_MIXEDCASE, but this symbol isn't |
263 | defined in VMS older than 7.0 or so */ | 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 */ | ||