From ab5158dcd3e202369bf8d7b0596827d007afa554 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Sun, 3 Dec 2017 22:39:01 -0600 Subject: [PATCH] Random: return empty string if $length is 0 --- phpseclib/Crypt/Random.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/phpseclib/Crypt/Random.php b/phpseclib/Crypt/Random.php index 18034216..85c302f2 100644 --- a/phpseclib/Crypt/Random.php +++ b/phpseclib/Crypt/Random.php @@ -67,6 +67,10 @@ if (!function_exists('crypt_random_string')) { */ function crypt_random_string($length) { + if (!$length) { + return ''; + } + if (CRYPT_RANDOM_IS_WINDOWS) { // method 1. prior to PHP 5.3, mcrypt_create_iv() would call rand() on windows if (extension_loaded('mcrypt') && version_compare(PHP_VERSION, '5.3.0', '>=')) {