[openssl-commits] [openssl] master update

Richard Levitte levitte at openssl.org
Fri May 20 14:09:51 UTC 2016


The branch master has been updated
       via  06593767b21d4ebacc3e6ecc8daedd9d5c5f9f97 (commit)
       via  8ff889c2a242927305d013e3bf79c7bb735793b0 (commit)
      from  d7295cd6d2e9f01b6aee367004e18c4c0a607565 (commit)


- Log -----------------------------------------------------------------
commit 06593767b21d4ebacc3e6ecc8daedd9d5c5f9f97
Author: Richard Levitte <levitte at openssl.org>
Date:   Fri May 20 15:18:22 2016 +0200

    Clean up the VMS hacks in crypto/rand/randfile.c
    
    Reviewed-by: Andy Polyakov <appro at openssl.org>

commit 8ff889c2a242927305d013e3bf79c7bb735793b0
Author: Richard Levitte <levitte at openssl.org>
Date:   Fri May 20 11:12:15 2016 +0200

    VMS: setbuf() only takes 32-bit pointers
    
    Giving setbuf() a 64-bit pointer isn't faulty, as the argument is
    passed by a 64-bit register anyway, so you only get a warning
    (MAYLOSEDATA2) pointing out that only the least significant 32 bits
    will be used.
    
    However, we know that a FILE* returned by fopen() and such really is a
    32-bit pointer (a study of the system header files make that clear),
    so we temporarly turn off that warning when calling setbuf().
    
    Reviewed-by: Andy Polyakov <appro at openssl.org>

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

Summary of changes:
 crypto/rand/randfile.c | 50 ++++++++++++++++++++++++++++++++++++++------------
 1 file changed, 38 insertions(+), 12 deletions(-)

diff --git a/crypto/rand/randfile.c b/crypto/rand/randfile.c
index 4354764..49f5405 100644
--- a/crypto/rand/randfile.c
+++ b/crypto/rand/randfile.c
@@ -65,12 +65,45 @@
 
 #ifdef OPENSSL_SYS_VMS
 /*
+ * Misc hacks needed for specific cases.
+ *
+ * __FILE_ptr32 is a type provided by DEC C headers (types.h specifically)
+ * to make sure the FILE* is a 32-bit pointer no matter what.  We know that
+ * stdio function return this type (a study of stdio.h proves it).
+ * Additionally, we create a similar char pointer type for the sake of
+ * vms_setbuf below.
+ */
+# if __INITIAL_POINTER_SIZE == 64
+#  pragma pointer_size save
+#  pragma pointer_size 32
+# endif
+typedef char *char_ptr32;
+# if __INITIAL_POINTER_SIZE == 64
+#  pragma pointer_size restore
+# endif
+
+/*
+ * On VMS, setbuf() will only take 32-bit pointers, and a compilation
+ * with /POINTER_SIZE=64 will give off a MAYLOSEDATA2 warning here.
+ * Since we know that the FILE* really is a 32-bit pointer expanded to
+ * 64 bits, we also know it's safe to convert it back to a 32-bit pointer.
+ * As for the buffer parameter, we only use NULL here, so that passes as
+ * well...
+ */
+static void vms_setbuf(FILE *fp, char *buf)
+{
+    setbuf((__FILE_ptr32)fp, (char_ptr32)buf);
+}
+/*
  * This declaration is a nasty hack to get around vms' extension to fopen for
- * passing in sharing options being disabled by our /STANDARD=ANSI89
+ * passing in sharing options being disabled by /STANDARD=ANSI89
  */
-static FILE *(*const vms_fopen)(const char *, const char *, ...) =
-    (FILE *(*)(const char *, const char *, ...))fopen;
+static __FILE_ptr32 (*const vms_fopen)(const char *, const char *, ...) =
+    (__FILE_ptr32 (*)(const char *, const char *, ...))fopen;
 # define VMS_OPEN_ATTRS "shr=get,put,upd,del","ctx=bin,stm","rfm=stm","rat=none","mrs=0"
+
+# define fopen(fname,mode) vms_fopen((fname), (mode), VMS_OPEN_ATTRS)
+# define setbuf(fp,buf) vms_setbuf((fp), (buf))
 #endif
 
 #define RFILE ".rnd"
@@ -112,11 +145,7 @@ int RAND_load_file(const char *file, long bytes)
     if (bytes == 0)
         return (ret);
 
-#ifdef OPENSSL_SYS_VMS
-    in = vms_fopen(file, "rb", VMS_OPEN_ATTRS);
-#else
     in = fopen(file, "rb");
-#endif
     if (in == NULL)
         goto err;
 #if defined(S_ISBLK) && defined(S_ISCHR) && !defined(OPENSSL_NO_POSIX_IO)
@@ -212,13 +241,10 @@ int RAND_write_file(const char *file)
      * rand file in a concurrent use situation.
      */
 
-    out = vms_fopen(file, "rb+", VMS_OPEN_ATTRS);
-    if (out == NULL)
-        out = vms_fopen(file, "wb", VMS_OPEN_ATTRS);
-#else
+    out = fopen(file, "rb+");
+#endif
     if (out == NULL)
         out = fopen(file, "wb");
-#endif
     if (out == NULL)
         goto err;
 


More information about the openssl-commits mailing list