summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnatol Belski <ab@php.net>2017-02-12 19:25:23 +0100
committerAnatol Belski <ab@php.net>2017-02-12 19:25:23 +0100
commit7b9f93b3f9f89e866d43aad3730e592a77c70f51 (patch)
tree7b85764be12da53828c677cb2d11988f3ee3f14f
parent97d620449cef55410ecd93964f9bff4c9dc7247d (diff)
downloadphp-git-7b9f93b3f9f89e866d43aad3730e592a77c70f51.tar.gz
remove loop
The limit is big enough, and it's questionable such amount of random data can ever make sense anyway.
-rw-r--r--win32/winutil.c18
1 files changed, 2 insertions, 16 deletions
diff --git a/win32/winutil.c b/win32/winutil.c
index 40a8700647..d3a61f1aac 100644
--- a/win32/winutil.c
+++ b/win32/winutil.c
@@ -94,22 +94,8 @@ PHP_WINUTIL_API int php_win32_get_random_bytes(unsigned char *buf, size_t size)
}
#endif
-#if ZEND_ENABLE_ZVAL_LONG64
- BOOL call_ret;
- size_t got = 0;
-
- do {
- ULONG to_read = (ULONG)(size - got);
- call_ret = NT_SUCCESS(BCryptGenRandom(bcrypt_algo, buf, to_read, 0));
- if (call_ret) {
- got += to_read;
- buf += to_read;
- }
- } while (call_ret && got < size);
- ret = (got == size);
-#else
- ret = NT_SUCCESS(BCryptGenRandom(bcrypt_algo, buf, size, 0));
-#endif
+ /* No sense to loop here, the limit is huge enough. */
+ ret = NT_SUCCESS(BCryptGenRandom(bcrypt_algo, buf, (ULONG)size, 0));
return ret ? SUCCESS : FAILURE;
}