2015-01-22 03:40:55 +00:00
|
|
|
/*
|
2016-05-17 18:51:26 +00:00
|
|
|
* Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved.
|
2000-09-15 21:22:50 +00:00
|
|
|
*
|
2018-12-06 12:37:48 +00:00
|
|
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
2016-05-17 18:51:26 +00:00
|
|
|
* this file except in compliance with the License. You can obtain a copy
|
|
|
|
* in the file LICENSE in the source distribution or at
|
|
|
|
* https://www.openssl.org/source/license.html
|
2000-09-15 21:22:50 +00:00
|
|
|
*/
|
|
|
|
|
2016-03-22 17:16:54 +00:00
|
|
|
#include "dso_locl.h"
|
2014-04-27 20:06:50 +00:00
|
|
|
|
2016-03-22 17:35:03 +00:00
|
|
|
#ifdef OPENSSL_SYS_VMS
|
2014-04-27 20:06:50 +00:00
|
|
|
|
2015-01-22 03:40:55 +00:00
|
|
|
# pragma message disable DOLLARID
|
2016-03-22 17:16:54 +00:00
|
|
|
# include <errno.h>
|
2015-01-22 03:40:55 +00:00
|
|
|
# include <rms.h>
|
|
|
|
# include <lib$routines.h>
|
2016-03-23 18:30:31 +00:00
|
|
|
# include <libfisdef.h>
|
2015-01-22 03:40:55 +00:00
|
|
|
# include <stsdef.h>
|
|
|
|
# include <descrip.h>
|
|
|
|
# include <starlet.h>
|
2015-12-30 13:54:29 +00:00
|
|
|
# include "../vms_rms.h"
|
2011-03-19 10:58:14 +00:00
|
|
|
|
|
|
|
/* Some compiler options may mask the declaration of "_malloc32". */
|
2015-01-22 03:40:55 +00:00
|
|
|
# if __INITIAL_POINTER_SIZE && defined _ANSI_C_SOURCE
|
|
|
|
# if __INITIAL_POINTER_SIZE == 64
|
|
|
|
# pragma pointer_size save
|
|
|
|
# pragma pointer_size 32
|
|
|
|
void *_malloc32(__size_t);
|
|
|
|
# pragma pointer_size restore
|
|
|
|
# endif /* __INITIAL_POINTER_SIZE == 64 */
|
|
|
|
# endif /* __INITIAL_POINTER_SIZE && defined
|
|
|
|
* _ANSI_C_SOURCE */
|
|
|
|
|
|
|
|
# pragma message disable DOLLARID
|
2000-09-15 21:22:50 +00:00
|
|
|
|
This changes the behaviour of the DSO mechanism for determining an
appropriate filename translation on the host system. Apart from this point,
users should also note that there's a slight change in the API functions
too. The DSO now contains its own to-be-converted filename
("dso->filename"), and at the time the DSO loads the "dso->loaded_filename"
value is set to the translated form. As such, this also provides an impicit
way of determining if the DSO is currently loaded or not. Except, perhaps,
VMS .... :-)
The various DSO_METHODs have been updated for this mechanism except VMS
which is deliberately broken for now, Richard is going to look at how to
fit it in (the source comments in there explain "the issue").
Basically, the new callback scheme allows the filename conversion to
(a) be turned off altogether through the use of the
DSO_FLAG_NO_NAME_TRANSLATION flag,
(b) be handled in the default way using the default DSO_METHOD's converter
(c) overriden per-DSO by setting the override callback
(d) a mix of (b) and (c) - eg. implement an override callback that;
(i) checks if we're win32 "if(strstr(dso->meth->name, "win32"))..."
and if so, convert "blah" into "blah32.dll" (the default is
otherwise to make it "blah.dll").
(ii) default to the normal behaviour - eg. we're not on win32, so
finish with (return dso->meth->dso_name_converter(dso,NULL)).
(e) be retried a number of times by writing a new DSO_METHOD where the
"dso_load()" handler will call the converter repeatedly. Then the
custom converter could use state information in the DSO to suggest
different conversions or paths each time it is invoked.
2000-10-26 17:38:59 +00:00
|
|
|
static int vms_load(DSO *dso);
|
2000-09-15 21:22:50 +00:00
|
|
|
static int vms_unload(DSO *dso);
|
|
|
|
static DSO_FUNC_TYPE vms_bind_func(DSO *dso, const char *symname);
|
2001-02-20 13:23:42 +00:00
|
|
|
static char *vms_name_converter(DSO *dso, const char *filename);
|
2002-07-15 15:35:40 +00:00
|
|
|
static char *vms_merger(DSO *dso, const char *filespec1,
|
2015-01-22 03:40:55 +00:00
|
|
|
const char *filespec2);
|
2000-09-15 21:22:50 +00:00
|
|
|
|
|
|
|
static DSO_METHOD dso_meth_vms = {
|
2015-01-22 03:40:55 +00:00
|
|
|
"OpenSSL 'VMS' shared library method",
|
|
|
|
vms_load,
|
|
|
|
NULL, /* unload */
|
|
|
|
vms_bind_func,
|
|
|
|
NULL, /* ctrl */
|
|
|
|
vms_name_converter,
|
|
|
|
vms_merger,
|
|
|
|
NULL, /* init */
|
2016-10-15 14:23:03 +00:00
|
|
|
NULL, /* finish */
|
|
|
|
NULL, /* pathbyaddr */
|
|
|
|
NULL /* globallookup */
|
2015-01-22 03:40:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* On VMS, the only "handle" is the file name. LIB$FIND_IMAGE_SYMBOL depends
|
2000-09-15 21:22:50 +00:00
|
|
|
* on the reference to the file name being the same for all calls regarding
|
|
|
|
* one shared image, so we'll just store it in an instance of the following
|
|
|
|
* structure and put a pointer to that instance in the meth_data stack.
|
|
|
|
*/
|
2015-01-22 03:40:55 +00:00
|
|
|
typedef struct dso_internal_st {
|
|
|
|
/*
|
|
|
|
* This should contain the name only, no directory, no extension, nothing
|
|
|
|
* but a name.
|
|
|
|
*/
|
|
|
|
struct dsc$descriptor_s filename_dsc;
|
|
|
|
char filename[NAMX_MAXRSS + 1];
|
|
|
|
/*
|
|
|
|
* This contains whatever is not in filename, if needed. Normally not
|
|
|
|
* defined.
|
|
|
|
*/
|
|
|
|
struct dsc$descriptor_s imagename_dsc;
|
|
|
|
char imagename[NAMX_MAXRSS + 1];
|
|
|
|
} DSO_VMS_INTERNAL;
|
2000-09-15 21:22:50 +00:00
|
|
|
|
2016-03-22 17:35:03 +00:00
|
|
|
DSO_METHOD *DSO_METHOD_openssl(void)
|
2015-01-22 03:40:55 +00:00
|
|
|
{
|
2016-03-22 17:35:03 +00:00
|
|
|
return &dso_meth_vms;
|
2015-01-22 03:40:55 +00:00
|
|
|
}
|
2000-09-15 21:22:50 +00:00
|
|
|
|
This changes the behaviour of the DSO mechanism for determining an
appropriate filename translation on the host system. Apart from this point,
users should also note that there's a slight change in the API functions
too. The DSO now contains its own to-be-converted filename
("dso->filename"), and at the time the DSO loads the "dso->loaded_filename"
value is set to the translated form. As such, this also provides an impicit
way of determining if the DSO is currently loaded or not. Except, perhaps,
VMS .... :-)
The various DSO_METHODs have been updated for this mechanism except VMS
which is deliberately broken for now, Richard is going to look at how to
fit it in (the source comments in there explain "the issue").
Basically, the new callback scheme allows the filename conversion to
(a) be turned off altogether through the use of the
DSO_FLAG_NO_NAME_TRANSLATION flag,
(b) be handled in the default way using the default DSO_METHOD's converter
(c) overriden per-DSO by setting the override callback
(d) a mix of (b) and (c) - eg. implement an override callback that;
(i) checks if we're win32 "if(strstr(dso->meth->name, "win32"))..."
and if so, convert "blah" into "blah32.dll" (the default is
otherwise to make it "blah.dll").
(ii) default to the normal behaviour - eg. we're not on win32, so
finish with (return dso->meth->dso_name_converter(dso,NULL)).
(e) be retried a number of times by writing a new DSO_METHOD where the
"dso_load()" handler will call the converter repeatedly. Then the
custom converter could use state information in the DSO to suggest
different conversions or paths each time it is invoked.
2000-10-26 17:38:59 +00:00
|
|
|
static int vms_load(DSO *dso)
|
2015-01-22 03:40:55 +00:00
|
|
|
{
|
|
|
|
void *ptr = NULL;
|
|
|
|
/* See applicable comments in dso_dl.c */
|
|
|
|
char *filename = DSO_convert_filename(dso, NULL);
|
2011-03-19 10:58:14 +00:00
|
|
|
|
|
|
|
/* Ensure 32-bit pointer for "p", and appropriate malloc() function. */
|
2015-01-22 03:40:55 +00:00
|
|
|
# if __INITIAL_POINTER_SIZE == 64
|
|
|
|
# define DSO_MALLOC _malloc32
|
|
|
|
# pragma pointer_size save
|
|
|
|
# pragma pointer_size 32
|
|
|
|
# else /* __INITIAL_POINTER_SIZE == 64 */
|
|
|
|
# define DSO_MALLOC OPENSSL_malloc
|
|
|
|
# endif /* __INITIAL_POINTER_SIZE == 64 [else] */
|
|
|
|
|
|
|
|
DSO_VMS_INTERNAL *p = NULL;
|
|
|
|
|
|
|
|
# if __INITIAL_POINTER_SIZE == 64
|
|
|
|
# pragma pointer_size restore
|
|
|
|
# endif /* __INITIAL_POINTER_SIZE == 64 */
|
|
|
|
|
|
|
|
const char *sp1, *sp2; /* Search result */
|
2016-05-03 20:40:33 +00:00
|
|
|
const char *ext = NULL; /* possible extension to add */
|
2015-01-22 03:40:55 +00:00
|
|
|
|
|
|
|
if (filename == NULL) {
|
|
|
|
DSOerr(DSO_F_VMS_LOAD, DSO_R_NO_FILENAME);
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
2015-01-05 11:30:03 +00:00
|
|
|
/*-
|
|
|
|
* A file specification may look like this:
|
|
|
|
*
|
|
|
|
* node::dev:[dir-spec]name.type;ver
|
|
|
|
*
|
|
|
|
* or (for compatibility with TOPS-20):
|
|
|
|
*
|
|
|
|
* node::dev:<dir-spec>name.type;ver
|
|
|
|
*
|
|
|
|
* and the dir-spec uses '.' as separator. Also, a dir-spec
|
|
|
|
* may consist of several parts, with mixed use of [] and <>:
|
|
|
|
*
|
|
|
|
* [dir1.]<dir2>
|
|
|
|
*
|
|
|
|
* We need to split the file specification into the name and
|
|
|
|
* the rest (both before and after the name itself).
|
|
|
|
*/
|
2015-01-22 03:40:55 +00:00
|
|
|
/*
|
|
|
|
* Start with trying to find the end of a dir-spec, and save the position
|
|
|
|
* of the byte after in sp1
|
|
|
|
*/
|
|
|
|
sp1 = strrchr(filename, ']');
|
|
|
|
sp2 = strrchr(filename, '>');
|
|
|
|
if (sp1 == NULL)
|
|
|
|
sp1 = sp2;
|
|
|
|
if (sp2 != NULL && sp2 > sp1)
|
|
|
|
sp1 = sp2;
|
|
|
|
if (sp1 == NULL)
|
|
|
|
sp1 = strrchr(filename, ':');
|
|
|
|
if (sp1 == NULL)
|
|
|
|
sp1 = filename;
|
|
|
|
else
|
|
|
|
sp1++; /* The byte after the found character */
|
|
|
|
/* Now, let's see if there's a type, and save the position in sp2 */
|
|
|
|
sp2 = strchr(sp1, '.');
|
2015-01-30 03:44:17 +00:00
|
|
|
/*
|
|
|
|
* If there is a period and the next character is a semi-colon,
|
|
|
|
* we need to add an extension
|
|
|
|
*/
|
|
|
|
if (sp2 != NULL && sp2[1] == ';')
|
|
|
|
ext = ".EXE";
|
2015-01-22 03:40:55 +00:00
|
|
|
/*
|
|
|
|
* If we found it, that's where we'll cut. Otherwise, look for a version
|
|
|
|
* number and save the position in sp2
|
|
|
|
*/
|
2015-01-30 03:44:17 +00:00
|
|
|
if (sp2 == NULL) {
|
2015-01-22 03:40:55 +00:00
|
|
|
sp2 = strchr(sp1, ';');
|
2015-01-30 03:44:17 +00:00
|
|
|
ext = ".EXE";
|
|
|
|
}
|
2015-01-22 03:40:55 +00:00
|
|
|
/*
|
|
|
|
* If there was still nothing to find, set sp2 to point at the end of the
|
|
|
|
* string
|
|
|
|
*/
|
|
|
|
if (sp2 == NULL)
|
|
|
|
sp2 = sp1 + strlen(sp1);
|
|
|
|
|
|
|
|
/* Check that we won't get buffer overflows */
|
|
|
|
if (sp2 - sp1 > FILENAME_MAX
|
|
|
|
|| (sp1 - filename) + strlen(sp2) > FILENAME_MAX) {
|
|
|
|
DSOerr(DSO_F_VMS_LOAD, DSO_R_FILENAME_TOO_BIG);
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
2015-05-02 03:10:31 +00:00
|
|
|
p = DSO_MALLOC(sizeof(*p));
|
2015-01-22 03:40:55 +00:00
|
|
|
if (p == NULL) {
|
|
|
|
DSOerr(DSO_F_VMS_LOAD, ERR_R_MALLOC_FAILURE);
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
strncpy(p->filename, sp1, sp2 - sp1);
|
|
|
|
p->filename[sp2 - sp1] = '\0';
|
|
|
|
|
|
|
|
strncpy(p->imagename, filename, sp1 - filename);
|
|
|
|
p->imagename[sp1 - filename] = '\0';
|
2015-01-30 03:44:17 +00:00
|
|
|
if (ext) {
|
|
|
|
strcat(p->imagename, ext);
|
|
|
|
if (*sp2 == '.')
|
|
|
|
sp2++;
|
|
|
|
}
|
2015-01-22 03:40:55 +00:00
|
|
|
strcat(p->imagename, sp2);
|
|
|
|
|
|
|
|
p->filename_dsc.dsc$w_length = strlen(p->filename);
|
|
|
|
p->filename_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
|
|
|
|
p->filename_dsc.dsc$b_class = DSC$K_CLASS_S;
|
|
|
|
p->filename_dsc.dsc$a_pointer = p->filename;
|
|
|
|
p->imagename_dsc.dsc$w_length = strlen(p->imagename);
|
|
|
|
p->imagename_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
|
|
|
|
p->imagename_dsc.dsc$b_class = DSC$K_CLASS_S;
|
|
|
|
p->imagename_dsc.dsc$a_pointer = p->imagename;
|
|
|
|
|
|
|
|
if (!sk_void_push(dso->meth_data, (char *)p)) {
|
|
|
|
DSOerr(DSO_F_VMS_LOAD, DSO_R_STACK_ERROR);
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Success (for now, we lie. We actually do not know...) */
|
|
|
|
dso->loaded_filename = filename;
|
2017-10-09 11:05:58 +00:00
|
|
|
return 1;
|
2015-01-22 03:40:55 +00:00
|
|
|
err:
|
|
|
|
/* Cleanup! */
|
2015-05-01 14:02:07 +00:00
|
|
|
OPENSSL_free(p);
|
|
|
|
OPENSSL_free(filename);
|
2017-10-17 14:04:09 +00:00
|
|
|
return 0;
|
2015-01-22 03:40:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Note that this doesn't actually unload the shared image, as there is no
|
2000-09-15 21:22:50 +00:00
|
|
|
* such thing in VMS. Next time it get loaded again, a new copy will
|
|
|
|
* actually be loaded.
|
|
|
|
*/
|
|
|
|
static int vms_unload(DSO *dso)
|
2015-01-22 03:40:55 +00:00
|
|
|
{
|
|
|
|
DSO_VMS_INTERNAL *p;
|
|
|
|
if (dso == NULL) {
|
|
|
|
DSOerr(DSO_F_VMS_UNLOAD, ERR_R_PASSED_NULL_PARAMETER);
|
2017-10-17 14:04:09 +00:00
|
|
|
return 0;
|
2015-01-22 03:40:55 +00:00
|
|
|
}
|
|
|
|
if (sk_void_num(dso->meth_data) < 1)
|
2017-10-09 11:05:58 +00:00
|
|
|
return 1;
|
2015-01-22 03:40:55 +00:00
|
|
|
p = (DSO_VMS_INTERNAL *)sk_void_pop(dso->meth_data);
|
|
|
|
if (p == NULL) {
|
|
|
|
DSOerr(DSO_F_VMS_UNLOAD, DSO_R_NULL_HANDLE);
|
2017-10-17 14:04:09 +00:00
|
|
|
return 0;
|
2015-01-22 03:40:55 +00:00
|
|
|
}
|
|
|
|
/* Cleanup */
|
|
|
|
OPENSSL_free(p);
|
2017-10-09 11:05:58 +00:00
|
|
|
return 1;
|
2015-01-22 03:40:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We must do this in a separate function because of the way the exception
|
|
|
|
* handler works (it makes this function return
|
|
|
|
*/
|
2000-09-15 21:22:50 +00:00
|
|
|
static int do_find_symbol(DSO_VMS_INTERNAL *ptr,
|
2015-01-22 03:40:55 +00:00
|
|
|
struct dsc$descriptor_s *symname_dsc, void **sym,
|
|
|
|
unsigned long flags)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Make sure that signals are caught and returned instead of aborting the
|
|
|
|
* program. The exception handler gets unestablished automatically on
|
|
|
|
* return from this function.
|
|
|
|
*/
|
|
|
|
lib$establish(lib$sig_to_ret);
|
|
|
|
|
|
|
|
if (ptr->imagename_dsc.dsc$w_length)
|
|
|
|
return lib$find_image_symbol(&ptr->filename_dsc,
|
|
|
|
symname_dsc, sym,
|
|
|
|
&ptr->imagename_dsc, flags);
|
|
|
|
else
|
|
|
|
return lib$find_image_symbol(&ptr->filename_dsc,
|
|
|
|
symname_dsc, sym, 0, flags);
|
|
|
|
}
|
2000-09-15 21:22:50 +00:00
|
|
|
|
2016-09-08 18:48:30 +00:00
|
|
|
# ifndef LIB$M_FIS_MIXEDCASE
|
|
|
|
# define LIB$M_FIS_MIXEDCASE (1 << 4);
|
|
|
|
# endif
|
2000-09-17 14:42:46 +00:00
|
|
|
void vms_bind_sym(DSO *dso, const char *symname, void **sym)
|
2015-01-22 03:40:55 +00:00
|
|
|
{
|
|
|
|
DSO_VMS_INTERNAL *ptr;
|
2016-09-08 18:48:30 +00:00
|
|
|
int status = 0;
|
2015-01-22 03:40:55 +00:00
|
|
|
struct dsc$descriptor_s symname_dsc;
|
2000-09-15 21:22:50 +00:00
|
|
|
|
2011-03-19 10:58:14 +00:00
|
|
|
/* Arrange 32-bit pointer to (copied) string storage, if needed. */
|
2015-01-22 03:40:55 +00:00
|
|
|
# if __INITIAL_POINTER_SIZE == 64
|
|
|
|
# define SYMNAME symname_32p
|
|
|
|
# pragma pointer_size save
|
|
|
|
# pragma pointer_size 32
|
|
|
|
char *symname_32p;
|
|
|
|
# pragma pointer_size restore
|
|
|
|
char symname_32[NAMX_MAXRSS + 1];
|
|
|
|
# else /* __INITIAL_POINTER_SIZE == 64 */
|
|
|
|
# define SYMNAME ((char *) symname)
|
|
|
|
# endif /* __INITIAL_POINTER_SIZE == 64 [else] */
|
|
|
|
|
|
|
|
*sym = NULL;
|
|
|
|
|
|
|
|
if ((dso == NULL) || (symname == NULL)) {
|
|
|
|
DSOerr(DSO_F_VMS_BIND_SYM, ERR_R_PASSED_NULL_PARAMETER);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
# if __INITIAL_POINTER_SIZE == 64
|
|
|
|
/* Copy the symbol name to storage with a 32-bit pointer. */
|
|
|
|
symname_32p = symname_32;
|
|
|
|
strcpy(symname_32p, symname);
|
|
|
|
# endif /* __INITIAL_POINTER_SIZE == 64 [else] */
|
|
|
|
|
|
|
|
symname_dsc.dsc$w_length = strlen(SYMNAME);
|
|
|
|
symname_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
|
|
|
|
symname_dsc.dsc$b_class = DSC$K_CLASS_S;
|
|
|
|
symname_dsc.dsc$a_pointer = SYMNAME;
|
|
|
|
|
|
|
|
if (sk_void_num(dso->meth_data) < 1) {
|
|
|
|
DSOerr(DSO_F_VMS_BIND_SYM, DSO_R_STACK_ERROR);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
ptr = (DSO_VMS_INTERNAL *)sk_void_value(dso->meth_data,
|
|
|
|
sk_void_num(dso->meth_data) - 1);
|
|
|
|
if (ptr == NULL) {
|
|
|
|
DSOerr(DSO_F_VMS_BIND_SYM, DSO_R_NULL_HANDLE);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-09-08 18:48:30 +00:00
|
|
|
status = do_find_symbol(ptr, &symname_dsc, sym, LIB$M_FIS_MIXEDCASE);
|
2015-01-22 03:40:55 +00:00
|
|
|
|
2016-09-08 18:48:30 +00:00
|
|
|
if (!$VMS_STATUS_SUCCESS(status))
|
|
|
|
status = do_find_symbol(ptr, &symname_dsc, sym, 0);
|
2015-01-22 03:40:55 +00:00
|
|
|
|
|
|
|
if (!$VMS_STATUS_SUCCESS(status)) {
|
|
|
|
unsigned short length;
|
|
|
|
char errstring[257];
|
|
|
|
struct dsc$descriptor_s errstring_dsc;
|
|
|
|
|
|
|
|
errstring_dsc.dsc$w_length = sizeof(errstring);
|
|
|
|
errstring_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
|
|
|
|
errstring_dsc.dsc$b_class = DSC$K_CLASS_S;
|
|
|
|
errstring_dsc.dsc$a_pointer = errstring;
|
|
|
|
|
|
|
|
*sym = NULL;
|
|
|
|
|
|
|
|
status = sys$getmsg(status, &length, &errstring_dsc, 1, 0);
|
|
|
|
|
|
|
|
if (!$VMS_STATUS_SUCCESS(status))
|
|
|
|
lib$signal(status); /* This is really bad. Abort! */
|
|
|
|
else {
|
|
|
|
errstring[length] = '\0';
|
|
|
|
|
|
|
|
DSOerr(DSO_F_VMS_BIND_SYM, DSO_R_SYM_FAILURE);
|
|
|
|
if (ptr->imagename_dsc.dsc$w_length)
|
|
|
|
ERR_add_error_data(9,
|
|
|
|
"Symbol ", symname,
|
|
|
|
" in ", ptr->filename,
|
|
|
|
" (", ptr->imagename, ")",
|
|
|
|
": ", errstring);
|
|
|
|
else
|
|
|
|
ERR_add_error_data(6,
|
|
|
|
"Symbol ", symname,
|
|
|
|
" in ", ptr->filename, ": ", errstring);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2000-09-15 21:22:50 +00:00
|
|
|
|
|
|
|
static DSO_FUNC_TYPE vms_bind_func(DSO *dso, const char *symname)
|
2015-01-22 03:40:55 +00:00
|
|
|
{
|
|
|
|
DSO_FUNC_TYPE sym = 0;
|
|
|
|
vms_bind_sym(dso, symname, (void **)&sym);
|
|
|
|
return sym;
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *vms_merger(DSO *dso, const char *filespec1,
|
|
|
|
const char *filespec2)
|
|
|
|
{
|
|
|
|
int status;
|
|
|
|
int filespec1len, filespec2len;
|
|
|
|
struct FAB fab;
|
|
|
|
struct NAMX_STRUCT nam;
|
|
|
|
char esa[NAMX_MAXRSS + 1];
|
|
|
|
char *merged;
|
2002-07-15 15:35:40 +00:00
|
|
|
|
2011-03-19 10:58:14 +00:00
|
|
|
/* Arrange 32-bit pointer to (copied) string storage, if needed. */
|
2015-01-22 03:40:55 +00:00
|
|
|
# if __INITIAL_POINTER_SIZE == 64
|
|
|
|
# define FILESPEC1 filespec1_32p;
|
|
|
|
# define FILESPEC2 filespec2_32p;
|
|
|
|
# pragma pointer_size save
|
|
|
|
# pragma pointer_size 32
|
|
|
|
char *filespec1_32p;
|
|
|
|
char *filespec2_32p;
|
|
|
|
# pragma pointer_size restore
|
|
|
|
char filespec1_32[NAMX_MAXRSS + 1];
|
|
|
|
char filespec2_32[NAMX_MAXRSS + 1];
|
|
|
|
# else /* __INITIAL_POINTER_SIZE == 64 */
|
|
|
|
# define FILESPEC1 ((char *) filespec1)
|
|
|
|
# define FILESPEC2 ((char *) filespec2)
|
|
|
|
# endif /* __INITIAL_POINTER_SIZE == 64 [else] */
|
|
|
|
|
|
|
|
if (!filespec1)
|
|
|
|
filespec1 = "";
|
|
|
|
if (!filespec2)
|
|
|
|
filespec2 = "";
|
|
|
|
filespec1len = strlen(filespec1);
|
|
|
|
filespec2len = strlen(filespec2);
|
|
|
|
|
|
|
|
# if __INITIAL_POINTER_SIZE == 64
|
|
|
|
/* Copy the file names to storage with a 32-bit pointer. */
|
|
|
|
filespec1_32p = filespec1_32;
|
|
|
|
filespec2_32p = filespec2_32;
|
|
|
|
strcpy(filespec1_32p, filespec1);
|
|
|
|
strcpy(filespec2_32p, filespec2);
|
|
|
|
# endif /* __INITIAL_POINTER_SIZE == 64 [else] */
|
|
|
|
|
|
|
|
fab = cc$rms_fab;
|
|
|
|
nam = CC_RMS_NAMX;
|
|
|
|
|
|
|
|
FAB_OR_NAML(fab, nam).FAB_OR_NAML_FNA = FILESPEC1;
|
|
|
|
FAB_OR_NAML(fab, nam).FAB_OR_NAML_FNS = filespec1len;
|
|
|
|
FAB_OR_NAML(fab, nam).FAB_OR_NAML_DNA = FILESPEC2;
|
|
|
|
FAB_OR_NAML(fab, nam).FAB_OR_NAML_DNS = filespec2len;
|
|
|
|
NAMX_DNA_FNA_SET(fab)
|
|
|
|
|
|
|
|
nam.NAMX_ESA = esa;
|
|
|
|
nam.NAMX_ESS = NAMX_MAXRSS;
|
|
|
|
nam.NAMX_NOP = NAM$M_SYNCHK | NAM$M_PWD;
|
|
|
|
SET_NAMX_NO_SHORT_UPCASE(nam);
|
|
|
|
|
|
|
|
fab.FAB_NAMX = &nam;
|
|
|
|
|
|
|
|
status = sys$parse(&fab, 0, 0);
|
|
|
|
|
|
|
|
if (!$VMS_STATUS_SUCCESS(status)) {
|
|
|
|
unsigned short length;
|
|
|
|
char errstring[257];
|
|
|
|
struct dsc$descriptor_s errstring_dsc;
|
|
|
|
|
|
|
|
errstring_dsc.dsc$w_length = sizeof(errstring);
|
|
|
|
errstring_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
|
|
|
|
errstring_dsc.dsc$b_class = DSC$K_CLASS_S;
|
|
|
|
errstring_dsc.dsc$a_pointer = errstring;
|
|
|
|
|
|
|
|
status = sys$getmsg(status, &length, &errstring_dsc, 1, 0);
|
|
|
|
|
|
|
|
if (!$VMS_STATUS_SUCCESS(status))
|
|
|
|
lib$signal(status); /* This is really bad. Abort! */
|
|
|
|
else {
|
|
|
|
errstring[length] = '\0';
|
|
|
|
|
|
|
|
DSOerr(DSO_F_VMS_MERGER, DSO_R_FAILURE);
|
|
|
|
ERR_add_error_data(7,
|
|
|
|
"filespec \"", filespec1, "\", ",
|
|
|
|
"defaults \"", filespec2, "\": ", errstring);
|
|
|
|
}
|
2017-10-17 14:04:09 +00:00
|
|
|
return NULL;
|
2015-01-22 03:40:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
merged = OPENSSL_malloc(nam.NAMX_ESL + 1);
|
2015-10-30 11:12:26 +00:00
|
|
|
if (merged == NULL)
|
2015-01-22 03:40:55 +00:00
|
|
|
goto malloc_err;
|
|
|
|
strncpy(merged, nam.NAMX_ESA, nam.NAMX_ESL);
|
|
|
|
merged[nam.NAMX_ESL] = '\0';
|
2017-10-17 14:04:09 +00:00
|
|
|
return merged;
|
2002-07-15 15:35:40 +00:00
|
|
|
malloc_err:
|
2015-01-22 03:40:55 +00:00
|
|
|
DSOerr(DSO_F_VMS_MERGER, ERR_R_MALLOC_FAILURE);
|
|
|
|
}
|
2002-07-15 15:35:40 +00:00
|
|
|
|
2000-12-31 01:55:46 +00:00
|
|
|
static char *vms_name_converter(DSO *dso, const char *filename)
|
2015-01-22 03:40:55 +00:00
|
|
|
{
|
|
|
|
int len = strlen(filename);
|
|
|
|
char *not_translated = OPENSSL_malloc(len + 1);
|
2015-10-30 11:12:26 +00:00
|
|
|
if (not_translated != NULL)
|
2015-03-04 17:49:51 +00:00
|
|
|
strcpy(not_translated, filename);
|
2017-10-17 14:04:09 +00:00
|
|
|
return not_translated;
|
2015-01-22 03:40:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* OPENSSL_SYS_VMS */
|