plaisthos has uploaded this change for review. ( 
http://gerrit.openvpn.net/c/openvpn/+/1732?usp=email )


Change subject: Make get_random return int64 instead of long
......................................................................

Make get_random return int64 instead of long

This avoids having get_ranomd being different on 32bit/Windows vs
64 bit Unix platform. Also adjust platform_create_temp_file to
create the same files on all platforms.

Change-Id: Ifefb3ad204c0c16cb4952dd6e8661fdc9136b125
Signed-off-by: Arne Schwabe <[email protected]>
---
M src/openvpn/crypto.c
M src/openvpn/crypto.h
M src/openvpn/platform.c
3 files changed, 7 insertions(+), 6 deletions(-)



  git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/32/1732/1

diff --git a/src/openvpn/crypto.c b/src/openvpn/crypto.c
index 7954e8a..3d79fe5 100644
--- a/src/openvpn/crypto.c
+++ b/src/openvpn/crypto.c
@@ -1731,11 +1731,12 @@
     ASSERT(rand_bytes(output, len));
 }

-/* an analogue to the random() function, but use prng_bytes */
-long int
+/* an analogue to the random() function, but use prng_bytes and
+ * also int64_t instead of long to avoid LLP64 vs LP64 */
+int64_t
 get_random(void)
 {
-    long int l;
+    int64_t l;
     prng_bytes((unsigned char *)&l, sizeof(l));
     if (l < 0)
     {
diff --git a/src/openvpn/crypto.h b/src/openvpn/crypto.h
index fbca2a0..74e828b 100644
--- a/src/openvpn/crypto.h
+++ b/src/openvpn/crypto.h
@@ -604,7 +604,7 @@
 void prng_bytes(uint8_t *output, int len);

 /* an analogue to the random() function, but use prng_bytes */
-long int get_random(void);
+int64_t get_random(void);

 /** Print a cipher list entry */
 void print_cipher(const char *cipher);
diff --git a/src/openvpn/platform.c b/src/openvpn/platform.c
index 9fa9363..85b6408 100644
--- a/src/openvpn/platform.c
+++ b/src/openvpn/platform.c
@@ -543,7 +543,7 @@
     const char *retfname = NULL;
     unsigned int attempts = 0;
     char fname[256] = { 0 };
-    const char *fname_fmt = PACKAGE "_%.*s_%08lx%08lx.tmp";
+    const char *fname_fmt = PACKAGE "_%.*s_%08" PRIx64 "%08" PRIx64 ".tmp";
     const int max_prefix_len = sizeof(fname) - (sizeof(PACKAGE) + 7 + (2 * 8));

     while (attempts < 6)
@@ -551,7 +551,7 @@
         ++attempts;

         if (!checked_snprintf(fname, sizeof(fname), fname_fmt, max_prefix_len, 
prefix,
-                              (unsigned long)get_random(), (unsigned 
long)get_random()))
+                              get_random(), get_random()))
         {
             msg(M_WARN, "ERROR: temporary filename too long");
             return NULL;

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1732?usp=email
To unsubscribe, or for help writing mail filters, visit 
http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ifefb3ad204c0c16cb4952dd6e8661fdc9136b125
Gerrit-Change-Number: 1732
Gerrit-PatchSet: 1
Gerrit-Owner: plaisthos <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

Reply via email to