Skip to content

Commit 7b9f93b

Browse files
committed
remove loop
The limit is big enough, and it's questionable such amount of random data can ever make sense anyway.
1 parent 97d6204 commit 7b9f93b

File tree

1 file changed

+2
-16
lines changed

1 file changed

+2
-16
lines changed

win32/winutil.c

+2-16
Original file line numberDiff line numberDiff line change
@@ -94,22 +94,8 @@ PHP_WINUTIL_API int php_win32_get_random_bytes(unsigned char *buf, size_t size)
9494
}
9595
#endif
9696

97-
#if ZEND_ENABLE_ZVAL_LONG64
98-
BOOL call_ret;
99-
size_t got = 0;
100-
101-
do {
102-
ULONG to_read = (ULONG)(size - got);
103-
call_ret = NT_SUCCESS(BCryptGenRandom(bcrypt_algo, buf, to_read, 0));
104-
if (call_ret) {
105-
got += to_read;
106-
buf += to_read;
107-
}
108-
} while (call_ret && got < size);
109-
ret = (got == size);
110-
#else
111-
ret = NT_SUCCESS(BCryptGenRandom(bcrypt_algo, buf, size, 0));
112-
#endif
97+
/* No sense to loop here, the limit is huge enough. */
98+
ret = NT_SUCCESS(BCryptGenRandom(bcrypt_algo, buf, (ULONG)size, 0));
11399

114100
return ret ? SUCCESS : FAILURE;
115101
}

0 commit comments

Comments
 (0)