aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJ Carter <jordanc.carter@outlook.com>2023-12-09 08:38:14 +0000
committerJ Carter <jordanc.carter@outlook.com>2023-12-09 08:38:14 +0000
commitc0134ded9fce48f36465cb1a1adbcc52e32f8c65 (patch)
treee1413ba8181e1b7ec302c2e04d6724be3aaa506d /src
parent5e743242849f4724392c742b59e3757e5c7ea499 (diff)
downloadnginx-c0134ded9fce48f36465cb1a1adbcc52e32f8c65.tar.gz
nginx-c0134ded9fce48f36465cb1a1adbcc52e32f8c65.zip
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 (limited to 'src')
-rw-r--r--src/os/win32/ngx_win32_config.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/os/win32/ngx_win32_config.h b/src/os/win32/ngx_win32_config.h
index 406003a78..704561355 100644
--- a/src/os/win32/ngx_win32_config.h
+++ b/src/os/win32/ngx_win32_config.h
@@ -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()