Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use random_bytes instead of uniqid #963

Merged
merged 2 commits into from
May 29, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/Doctrine/Common/Proxy/ProxyGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use function array_slice;
use function array_unique;
use function assert;
use function bin2hex;
use function call_user_func;
use function chmod;
use function class_exists;
Expand All @@ -43,6 +44,7 @@
use function mkdir;
use function preg_match;
use function preg_match_all;
use function random_bytes;
use function rename;
use function rtrim;
use function sprintf;
Expand All @@ -52,7 +54,6 @@
use function strtr;
use function substr;
use function trim;
use function uniqid;
use function var_export;

use const DIRECTORY_SEPARATOR;
Expand Down Expand Up @@ -338,7 +339,8 @@ public function generateProxyClass(ClassMetadata $class, $fileName = false)
throw UnexpectedValueException::proxyDirectoryNotWritable($this->proxyDirectory);
}

$tmpFileName = $fileName . '.' . uniqid('', true);
/** @noinspection PhpUnhandledExceptionInspection */
greg0ire marked this conversation as resolved.
Show resolved Hide resolved
$tmpFileName = $fileName . '.' . bin2hex(random_bytes(12));

file_put_contents($tmpFileName, $proxyCode);
@chmod($tmpFileName, 0664);
Expand Down