From: Arne Schwabe <[email protected]> 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]> Acked-by: Gert Doering <[email protected]> Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1732 --- This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master. Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1732 This mail reflects revision 2 of this Change. Acked-by according to Gerrit (reflected above): Gert Doering <[email protected]> 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..ee5b50f 100644 --- a/src/openvpn/crypto.h +++ b/src/openvpn/crypto.h @@ -603,8 +603,13 @@ */ void prng_bytes(uint8_t *output, int len); -/* an analogue to the random() function, but use prng_bytes */ -long int get_random(void); +/** + * an analogue to the random() function, but use prng_bytes and + * also int64_t instead of long to avoid LLP64 vs LP64 + * + * @return Returns a random positive 63 bit integer + */ +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; _______________________________________________ Openvpn-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openvpn-devel
