]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/random_compat/random_bytes_openssl.php
WordPress 4.5
[autoinstalls/wordpress.git] / wp-includes / random_compat / random_bytes_openssl.php
index 3e12d3da59212107d9c64b1066551aec4f881ed2..62bf770352f66e5f4686a6c296dfcb67872bbd37 100644 (file)
@@ -48,12 +48,13 @@ function random_bytes($bytes)
             'random_bytes(): $bytes must be an integer'
         );
     }
+
     if ($bytes < 1) {
         throw new Error(
             'Length must be greater than 0'
         );
     }
-    $secure = true;
+
     /**
      * $secure is passed by reference. If it's set to false, fail. Note
      * that this will only return false if this function fails to return
@@ -61,12 +62,18 @@ function random_bytes($bytes)
      * 
      * @ref https://github.com/paragonie/random_compat/issues/6#issuecomment-119564973
      */
+    $secure = true;
     $buf = openssl_random_pseudo_bytes($bytes, $secure);
-    if ($buf !== false && $secure) {
-        if (RandomCompat_strlen($buf) === $bytes) {
-            return $buf;
-        }
+    if (
+        $buf !== false
+        &&
+        $secure
+        &&
+        RandomCompat_strlen($buf) === $bytes
+    ) {
+        return $buf;
     }
+
     /**
      * If we reach here, PHP has failed us.
      */