提交 087ca80a 编写于 作者: R Richard Levitte

Fix pointer size issues with argv on VMS

The argument 'argv' in 'main' is a short pointer to a short pointer on
VMS, regardless of initial pointer size.  We must therefore make sure
that 'copy_argv' gets a 32-bit pointer for argv, and that the copied
argv is used for the rest of main().

This introduces the local type argv_t, which will have correct pointer
size in all cases (and be harmless on all other platforms) as well as
the macro Argv, which is defined as 'copied_argv' or 'argv', as the
case may be.
Reviewed-by: NAndy Polyakov <appro@openssl.org>
上级 90dbd250
...@@ -445,6 +445,17 @@ typedef struct args_st { ...@@ -445,6 +445,17 @@ typedef struct args_st {
char **argv; char **argv;
} ARGS; } ARGS;
#if defined(OPENSSL_SYS_VMS) && defined(__DECC)
# pragma pointer_size save
# pragma pointer_size 32
typedef char **argv_t;
# pragma pointer_size restore
char **copy_argv(int *argc, argv_t argv);
#else
typedef char **argv_t;
#endif
# define PW_MIN_LENGTH 4 # define PW_MIN_LENGTH 4
typedef struct pw_cb_data { typedef struct pw_cb_data {
const void *password; const void *password;
......
...@@ -207,15 +207,12 @@ static char *make_config_name() ...@@ -207,15 +207,12 @@ static char *make_config_name()
return p; return p;
} }
#if defined( OPENSSL_SYS_VMS)
extern char **copy_argv(int *argc, char **argv);
#endif
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
FUNCTION f, *fp; FUNCTION f, *fp;
LHASH_OF(FUNCTION) *prog = NULL; LHASH_OF(FUNCTION) *prog = NULL;
char **copied_argv = NULL; char **copied_argv = NULL;
char **argv_alias = NULL;
char *p, *pname; char *p, *pname;
char buf[1024]; char buf[1024];
const char *prompt; const char *prompt;
...@@ -231,8 +228,10 @@ int main(int argc, char *argv[]) ...@@ -231,8 +228,10 @@ int main(int argc, char *argv[])
bio_out = dup_bio_out(FORMAT_TEXT); bio_out = dup_bio_out(FORMAT_TEXT);
bio_err = dup_bio_err(FORMAT_TEXT); bio_err = dup_bio_err(FORMAT_TEXT);
#if defined( OPENSSL_SYS_VMS) #if defined( OPENSSL_SYS_VMS) && defined(__DECC)
copied_argv = argv = copy_argv(&argc, argv); copied_argv = argv_alias = copy_argv(&argc, argv);
#else
argv_alias = argv;
#endif #endif
p = getenv("OPENSSL_DEBUG_MEMORY"); p = getenv("OPENSSL_DEBUG_MEMORY");
...@@ -256,22 +255,22 @@ int main(int argc, char *argv[]) ...@@ -256,22 +255,22 @@ int main(int argc, char *argv[])
goto end; goto end;
prog = prog_init(); prog = prog_init();
pname = opt_progname(argv[0]); pname = opt_progname(argv_alias[0]);
/* first check the program name */ /* first check the program name */
f.name = pname; f.name = pname;
fp = lh_FUNCTION_retrieve(prog, &f); fp = lh_FUNCTION_retrieve(prog, &f);
if (fp != NULL) { if (fp != NULL) {
argv[0] = pname; argv_alias[0] = pname;
ret = fp->func(argc, argv); ret = fp->func(argc, argv_alias);
goto end; goto end;
} }
/* If there is stuff on the command line, run with that. */ /* If there is stuff on the command line, run with that. */
if (argc != 1) { if (argc != 1) {
argc--; argc--;
argv++; argv_alias++;
ret = do_cmd(prog, argc, argv); ret = do_cmd(prog, argc, argv_alias);
if (ret < 0) if (ret < 0)
ret = 0; ret = 0;
goto end; goto end;
......
...@@ -105,7 +105,8 @@ decc_feat_t decc_feat_array[] = { ...@@ -105,7 +105,8 @@ decc_feat_t decc_feat_array[] = {
{(char *)NULL, 0} {(char *)NULL, 0}
}; };
char **copy_argv(int *argc, char *argv[])
char **copy_argv(int *argc, argv_t argv)
{ {
/*- /*-
* The note below is for historical purpose. On VMS now we always * The note below is for historical purpose. On VMS now we always
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册