X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;f=vendor%2Fparagonie%2Frandom_compat%2Flib%2Frandom_bytes_libsodium.php;h=7a95e2b40cf3136017c2806a4b352a14361232a0;hb=4e1bfbf98b844da83b18aca92ef00f11a4735806;hp=4af1a242279f7e2f759f13e4d45336d1e2889b9c;hpb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;p=yaffs-website diff --git a/vendor/paragonie/random_compat/lib/random_bytes_libsodium.php b/vendor/paragonie/random_compat/lib/random_bytes_libsodium.php index 4af1a2422..7a95e2b40 100644 --- a/vendor/paragonie/random_compat/lib/random_bytes_libsodium.php +++ b/vendor/paragonie/random_compat/lib/random_bytes_libsodium.php @@ -5,7 +5,7 @@ * * The MIT License (MIT) * - * Copyright (c) 2015 - 2017 Paragon Initiative Enterprises + * Copyright (c) 2015 - 2018 Paragon Initiative Enterprises * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -43,6 +43,7 @@ if (!is_callable('random_bytes')) { function random_bytes($bytes) { try { + /** @var int $bytes */ $bytes = RandomCompat_intval($bytes); } catch (TypeError $ex) { throw new TypeError( @@ -60,6 +61,7 @@ if (!is_callable('random_bytes')) { * \Sodium\randombytes_buf() doesn't allow more than 2147483647 bytes to be * generated in one invocation. */ + /** @var string|bool $buf */ if ($bytes > 2147483647) { $buf = ''; for ($i = 0; $i < $bytes; $i += 1073741824) { @@ -69,10 +71,11 @@ if (!is_callable('random_bytes')) { $buf .= \Sodium\randombytes_buf($n); } } else { + /** @var string|bool $buf */ $buf = \Sodium\randombytes_buf($bytes); } - if ($buf !== false) { + if (is_string($buf)) { if (RandomCompat_strlen($buf) === $bytes) { return $buf; }