[openssl-commits] [openssl] master update

Richard Levitte levitte at openssl.org
Wed Mar 30 18:25:16 UTC 2016


The branch master has been updated
       via  087ca80ad83071dde0bb6bc1c28c743caa00eaf8 (commit)
       via  90dbd25097d7d4af0bea0cd9cab60d749ed0a6a2 (commit)
       via  fcd9c8c0149d989bf0ab28e14bbaa49e5060db9b (commit)
      from  622c7e99a9e9c4632b483895cf2dc5edaa2e52bd (commit)


- Log -----------------------------------------------------------------
commit 087ca80ad83071dde0bb6bc1c28c743caa00eaf8
Author: Richard Levitte <levitte at openssl.org>
Date:   Wed Mar 30 08:35:18 2016 +0200

    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: Andy Polyakov <appro at openssl.org>

commit 90dbd25097d7d4af0bea0cd9cab60d749ed0a6a2
Author: Richard Levitte <levitte at openssl.org>
Date:   Wed Mar 30 08:32:19 2016 +0200

    Fix pointer size issue with setbuf() on VMS
    
    setbuf() is only for 32-bit pointers.  If compiled with /POINTER_SIZE=64,
    we get a nasty warning about possible loss of data.  However, since
    the only pointer used in the call is a FILE *, and the C RTL shouldn't
    give us a pointer above the first 4GB, it's safe to turn off the
    warning for this call.
    
    Reviewed-by: Andy Polyakov <appro at openssl.org>

commit fcd9c8c0149d989bf0ab28e14bbaa49e5060db9b
Author: Richard Levitte <levitte at openssl.org>
Date:   Wed Mar 30 06:40:37 2016 +0200

    Fix pointer size issues on VMS
    
    On VMS, the C compiler can work with 32-bit and 64-bit pointers, and
    the command line determines what the initial pointer size shall be.
    
    However, there is some functionality that only works with 32-bit
    pointers.  In this case, it's gethostbyname(), getservbyname() and
    accompanying structures, so we need to make sure that we define our
    own pointers as 32-bit ones.
    
    Furthermore, there seems to be a bug in VMS C netdb.h, where struct
    addrinfo is always defined with 32-bit pointers no matter what, but
    the functions handling it are adapted to the initial pointer size.
    This leads to pointer size warnings when compiling with
    /POINTER_SIZE=64.  The workaround is to force struct addrinfo to be
    the 64-bit variant if the initial pointer size is 64.
    
    Reviewed-by: Andy Polyakov <appro at openssl.org>

-----------------------------------------------------------------------

Summary of changes:
 apps/apps.c          | 14 ++++++++++++++
 apps/apps.h          | 11 +++++++++++
 apps/openssl.c       | 21 ++++++++++-----------
 apps/vms_decc_init.c |  3 ++-
 crypto/bio/b_addr.c  | 37 +++++++++++++++++++++++++++++++++++++
 crypto/bio/bio_lcl.h | 12 ++++++++++++
 6 files changed, 86 insertions(+), 12 deletions(-)

diff --git a/apps/apps.c b/apps/apps.c
index 128f387..e124149 100644
--- a/apps/apps.c
+++ b/apps/apps.c
@@ -2499,7 +2499,21 @@ BIO *dup_bio_err(int format)
 
 void unbuffer(FILE *fp)
 {
+/*
+ * On VMS, setbuf() will only take 32-bit pointers, and a compilation
+ * with /POINTER_SIZE=64 will give off a MAYLOSEDATA2 warning here.
+ * However, we trust that the C RTL will never give us a FILE pointer
+ * above the first 4 GB of memory, so we simply turn off the warning
+ * temporarily.
+ */
+#if defined(OPENSSL_SYS_VMS) && defined(__DECC)
+# pragma environment save
+# pragma message disable maylosedata2
+#endif
     setbuf(fp, NULL);
+#if defined(OPENSSL_SYS_VMS) && defined(__DECC)
+# pragma environment restore
+#endif
 }
 
 static const char *modestr(char mode, int format)
diff --git a/apps/apps.h b/apps/apps.h
index fc480e1..7cf0dc4 100644
--- a/apps/apps.h
+++ b/apps/apps.h
@@ -445,6 +445,17 @@ typedef struct args_st {
     char **argv;
 } 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
 typedef struct pw_cb_data {
     const void *password;
diff --git a/apps/openssl.c b/apps/openssl.c
index 2d9ddaa..166c7a1 100644
--- a/apps/openssl.c
+++ b/apps/openssl.c
@@ -207,15 +207,12 @@ static char *make_config_name()
     return p;
 }
 
-#if defined( OPENSSL_SYS_VMS)
-extern char **copy_argv(int *argc, char **argv);
-#endif
-
 int main(int argc, char *argv[])
 {
     FUNCTION f, *fp;
     LHASH_OF(FUNCTION) *prog = NULL;
     char **copied_argv = NULL;
+    char **argv_alias  = NULL;
     char *p, *pname;
     char buf[1024];
     const char *prompt;
@@ -231,8 +228,10 @@ int main(int argc, char *argv[])
     bio_out = dup_bio_out(FORMAT_TEXT);
     bio_err = dup_bio_err(FORMAT_TEXT);
 
-#if defined( OPENSSL_SYS_VMS)
-    copied_argv = argv = copy_argv(&argc, argv);
+#if defined( OPENSSL_SYS_VMS) && defined(__DECC)
+    copied_argv = argv_alias = copy_argv(&argc, argv);
+#else
+    argv_alias = argv;
 #endif
 
     p = getenv("OPENSSL_DEBUG_MEMORY");
@@ -256,22 +255,22 @@ int main(int argc, char *argv[])
         goto end;
 
     prog = prog_init();
-    pname = opt_progname(argv[0]);
+    pname = opt_progname(argv_alias[0]);
 
     /* first check the program name */
     f.name = pname;
     fp = lh_FUNCTION_retrieve(prog, &f);
     if (fp != NULL) {
-        argv[0] = pname;
-        ret = fp->func(argc, argv);
+        argv_alias[0] = pname;
+        ret = fp->func(argc, argv_alias);
         goto end;
     }
 
     /* If there is stuff on the command line, run with that. */
     if (argc != 1) {
         argc--;
-        argv++;
-        ret = do_cmd(prog, argc, argv);
+        argv_alias++;
+        ret = do_cmd(prog, argc, argv_alias);
         if (ret < 0)
             ret = 0;
         goto end;
diff --git a/apps/vms_decc_init.c b/apps/vms_decc_init.c
index b66c00f..8f8ffc6 100644
--- a/apps/vms_decc_init.c
+++ b/apps/vms_decc_init.c
@@ -105,7 +105,8 @@ decc_feat_t decc_feat_array[] = {
     {(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
diff --git a/crypto/bio/b_addr.c b/crypto/bio/b_addr.c
index 663ec2e..ed4c139 100644
--- a/crypto/bio/b_addr.c
+++ b/crypto/bio/b_addr.c
@@ -722,6 +722,15 @@ int BIO_lookup(const char *host, const char *service,
     } else {
 #endif
         const struct hostent *he;
+/*
+ * Because struct hostent is defined for 32-bit pointers only with
+ * VMS C, we need to make sure that '&he_fallback_address' and
+ * '&he_fallback_addresses' are 32-bit pointers
+ */
+#if defined(OPENSSL_SYS_VMS) && defined(__DECC)
+# pragma pointer_size save
+# pragma pointer_size 32
+#endif
         /* Windows doesn't seem to have in_addr_t */
 #ifdef OPENSSL_SYS_WINDOWS
         static uint32_t he_fallback_address;
@@ -735,6 +744,10 @@ int BIO_lookup(const char *host, const char *service,
         static const struct hostent he_fallback =
             { NULL, NULL, AF_INET, sizeof(he_fallback_address),
               (char **)&he_fallback_addresses };
+#if defined(OPENSSL_SYS_VMS) && defined(__DECC)
+# pragma pointer_size restore
+#endif
+
         struct servent *se;
         /* Apprently, on WIN64, s_proto and s_port have traded places... */
 #ifdef _WIN64
@@ -782,7 +795,19 @@ int BIO_lookup(const char *host, const char *service,
         } else {
             char *endp = NULL;
             long portnum = strtol(service, &endp, 10);
+
+/*
+ * Because struct servent is defined for 32-bit pointers only with
+ * VMS C, we need to make sure that 'proto' is a 32-bit pointer.
+ */
+#if defined(OPENSSL_SYS_VMS) && defined(__DECC)
+# pragma pointer_size save
+# pragma pointer_size 32
+#endif
             char *proto = NULL;
+#if defined(OPENSSL_SYS_VMS) && defined(__DECC)
+# pragma pointer_size restore
+#endif
 
             switch (socktype) {
             case SOCK_STREAM:
@@ -819,7 +844,19 @@ int BIO_lookup(const char *host, const char *service,
         *res = NULL;
 
         {
+/*
+ * Because hostent::h_addr_list is an array of 32-bit pointers with VMS C,
+ * we must make sure our iterator designates the same element type, hence
+ * the pointer size dance.
+ */
+#if defined(OPENSSL_SYS_VMS) && defined(__DECC)
+# pragma pointer_size save
+# pragma pointer_size 32
+#endif
             char **addrlistp;
+#if defined(OPENSSL_SYS_VMS) && defined(__DECC)
+# pragma pointer_size restore
+#endif
             size_t addresses;
             BIO_ADDRINFO *tmp_bai = NULL;
 
diff --git a/crypto/bio/bio_lcl.h b/crypto/bio/bio_lcl.h
index 1e409f8..7f3b222 100644
--- a/crypto/bio/bio_lcl.h
+++ b/crypto/bio/bio_lcl.h
@@ -32,6 +32,18 @@
 # endif
 
 # ifdef AI_PASSIVE
+
+/*
+ * There's a bug in VMS C header file netdb.h, where struct addrinfo
+ * always is the P32 variant, but the functions that handle that structure,
+ * such as getaddrinfo() and freeaddrinfo() adapt to the initial pointer
+ * size.  The easiest workaround is to force struct addrinfo to be the
+ * 64-bit variant when compiling in P64 mode.
+ */
+#  if defined(OPENSSL_SYS_VMS) && __INITIAL_POINTER_SIZE == 64
+#   define addrinfo __addrinfo64
+#  endif
+
 #  define bio_addrinfo_st addrinfo
 #  define bai_family      ai_family
 #  define bai_socktype    ai_socktype


More information about the openssl-commits mailing list