Welcome! Log In Create A New Profile

Advanced

[nginx] Win32: extended ngx_random() range to 0x7fffffff.

Sergey Kandaurov
December 25, 2023 12:16PM
details: https://hg.nginx.org/nginx/rev/514c518b9d6c
branches:
changeset: 9198:514c518b9d6c
user: J Carter <jordanc.carter@outlook.com>
date: Sat Dec 09 08:38:14 2023 +0000
description:
Win32: extended ngx_random() range to 0x7fffffff.

rand() is used on win32. RAND_MAX is implementation defined. win32's is
0x7fff.

Existing uses of ngx_random() rely upon 0x7fffffff range provided by
POSIX implementations of random().

diffstat:

src/os/win32/ngx_win32_config.h | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)

diffs (16 lines):

diff -r cc16989c6d61 -r 514c518b9d6c src/os/win32/ngx_win32_config.h
--- a/src/os/win32/ngx_win32_config.h Sat Dec 16 03:40:01 2023 +0400
+++ b/src/os/win32/ngx_win32_config.h Sat Dec 09 08:38:14 2023 +0000
@@ -280,7 +280,11 @@ typedef int sig_atomic_t

#define NGX_HAVE_GETADDRINFO 1

-#define ngx_random rand
+#define ngx_random() \
+ ((long) (0x7fffffff & ( ((uint32_t) rand() << 16) \
+ ^ ((uint32_t) rand() << 8) \
+ ^ ((uint32_t) rand()) )))
+
#define ngx_debug_init()


_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
https://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[nginx] Win32: extended ngx_random() range to 0x7fffffff.

Sergey Kandaurov 255 December 25, 2023 12:16PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 343
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready