X-Git-Url: https://git.p6c8.net/jirafeau/pcanterino.git/blobdiff_plain/6fdc9ef24d11ad73c879be49d9c2e254505d40b6..2d5f96c44be85bab39fa867e27048db4f5ab7a3b:/lib/functions.php?ds=sidebyside diff --git a/lib/functions.php b/lib/functions.php index e5a05b0..0676c6f 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -544,7 +544,7 @@ function jirafeau_add_file($file, $one_time_download, $key, $time, $ip, $crypt, /* hash password or empty. */ $password = ''; if (!empty($key)) { - $password = md5($key); + $password = '[SHA256]' . hash('sha256', $key); } /* create link file */ @@ -947,6 +947,7 @@ function jirafeau_admin_bug_report($cfg) $out .= "- version: " . JIRAFEAU_VERSION . "
"; $jirafeau_options = [ 'debug', + 'debug_enforce_classic_upload', 'file_hash', 'litespeed_workaround', 'store_uploader_ip', @@ -1021,11 +1022,16 @@ function jirafeau_get_async_ref($ref) $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); @@ -1088,10 +1094,10 @@ function jirafeau_async_init($filename, $type, $one_time, $key, $time, $ip) $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. */ @@ -1119,6 +1125,11 @@ function jirafeau_async_init($filename, $type, $one_time, $key, $time, $ip) */ 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); @@ -1126,6 +1137,7 @@ function jirafeau_async_push($ref, $data, $code, $max_file_size) if (count($a) == 0) { return "Error: cannot find transfer"; } + if ($a['next_code'] != "$code") { return "Error: bad transfer code"; } @@ -1192,6 +1204,11 @@ function jirafeau_async_push($ref, $data, $code, $max_file_size) */ 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 @@ -1642,7 +1659,7 @@ function jirafeau_escape($string) 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()