com php-src: fix loop: win32/winutil.c

[email protected] (Anatol Belski)
Newsgroups php.cvs
Message-ID <[email protected]>
Commit:    97d620449cef55410ecd93964f9bff4c9dc7247d
Author:    Anatol Belski <[email protected]>         Sun, 12 Feb 2017 19:15:40 +0100
Parents:   d53d0a5dc43869a29f8908687e4790d7f2847830
Branches:  master

Link:       http://git.php.net/?p=php-src.git;a=commitdiff;h=97d620449cef55410ecd93964f9bff4c9dc7247d

Log:
fix loop

Changed paths:
  M  win32/winutil.c


Diff:
diff --git a/win32/winutil.c b/win32/winutil.c
index 8e47d48..40a8700 100644
--- a/win32/winutil.c
+++ b/win32/winutil.c
@@ -84,7 +84,6 @@ BOOL php_win32_init_random_bytes(void)
 PHP_WINUTIL_API int php_win32_get_random_bytes(unsigned char *buf, size_t size) {  /* {{{ */
 
 	BOOL ret;
-	size_t got = 0;
 
 #if 0
 	/* Currently we fail on startup, with CNG API it shows no regressions so far and is secure.
@@ -96,18 +95,21 @@ 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);
-		ret = ret && NT_SUCCESS(BCryptGenRandom(bcrypt_algo, buf, to_read, 0));
-		if (ret) {
+		call_ret = NT_SUCCESS(BCryptGenRandom(bcrypt_algo, buf, to_read, 0));
+		if (call_ret) {
 			got += to_read;
 			buf += to_read;
 		}
-	} while (ret && got < size);
+	} while (call_ret && got < size);
+	ret = (got == size);
 #else
 	ret = NT_SUCCESS(BCryptGenRandom(bcrypt_algo, buf, size, 0));
 #endif
-	assert(got == size);
 
 	return ret ? SUCCESS : FAILURE;
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.