error_log("PHP extension sodium not loaded, won't encrypt in Jirafeau");
}
if ($crypt_module_enabled == true && extension_loaded('sodium') == true) {
- $crypt_key = jirafeau_encrypt_file($file_path, $file_path.'crypt');
+ $crypt_key = jirafeau_encrypt_file($file_path, $file_path.'.crypt');
if (strlen($crypt_key) > 0) {
- if (rename($file_path.'crypt', $file_path) === true) {
+ if (rename($file_path.'.crypt', $file_path) === true) {
$crypted = true;
}
}
/* hash password or empty. */
$password = '';
if (!empty($key)) {
- $password = md5($key);
+ $password = '[SHA256]' . hash('sha256', $key);
}
/* create link file */
$out .= "- version: " . JIRAFEAU_VERSION . "<br/>";
$jirafeau_options = [
'debug',
+ 'debug_enforce_classic_upload',
'file_hash',
'litespeed_workaround',
'store_uploader_ip',
$out = array();
$refinfos = VAR_ASYNC . s2p("$ref") . "$ref";
- if (!file_exists($refinfos)) {
+ if (!is_file($refinfos)) {
return $out;
}
$c = file($refinfos);
+
+ if(empty($c)) {
+ return $out;
+ }
+
$out['file_name'] = trim($c[0]);
$out['mime_type'] = trim($c[1]);
$out['key'] = trim($c[2], NL);
$w_path = $p . $ref . '_data';
touch($w_path);
- /* md5 password or empty */
+ /* sha256 password or empty */
$password = '';
if (!empty($key)) {
- $password = md5($key);
+ $password = '[SHA256]' . hash('sha256', $key);
}
/* Store information. */
*/
function jirafeau_async_push($ref, $data, $code, $max_file_size)
{
+ /* Validate ref string. */
+ if (!ctype_xdigit(trim($ref))) {
+ return "Error: Malformed ref string";
+ }
+
/* Get async infos. */
$a = jirafeau_get_async_ref($ref);
if (count($a) == 0) {
return "Error: cannot find transfer";
}
+
if ($a['next_code'] != "$code") {
return "Error: bad transfer code";
}
*/
function jirafeau_async_end($ref, $code, $crypt, $link_name_length, $file_hash_method)
{
+ /* Validate ref string. */
+ if (!ctype_xdigit(trim($ref))) {
+ return "Error: Malformed ref string";
+ }
+
/* Get async infos. */
$a = jirafeau_get_async_ref($ref);
if (count($a) == 0
function jirafeau_admin_session_start()
{
$_SESSION['admin_auth'] = true;
- $_SESSION['admin_csrf'] = md5(uniqid(mt_rand(), true));
+ $_SESSION['admin_csrf'] = hash('sha256', uniqid(mt_rand(), true));
}
function jirafeau_session_end()