Skip to content

Commit

Permalink
random_bytes() only for >PHP7 (prasathmani#1066)
Browse files Browse the repository at this point in the history
  • Loading branch information
paponius authored Jun 29, 2023
1 parent f380478 commit eb8f3d8
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion tinyfilemanager.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,11 @@ function session_error_handling_function($code, $msg, $file, $line) {

//Generating CSRF Token
if (empty($_SESSION['token'])) {
$_SESSION['token'] = bin2hex(random_bytes(32));
if (function_exists('random_bytes')) {
$_SESSION['token'] = bin2hex(random_bytes(32));
} else {
$_SESSION['token'] = bin2hex(openssl_random_pseudo_bytes(32));
}
}

if (empty($auth_users)) {
Expand Down

0 comments on commit eb8f3d8

Please sign in to comment.