]> git.p6c8.net - jirafeau/pcanterino.git/commitdiff
Merge branch 'fix_legacy_upload' into 'next-release'
authorPatrick Canterino <patrick@patrick-canterino.de>
Fri, 5 Jun 2026 14:02:08 +0000 (16:02 +0200)
committerPatrick Canterino <patrick@patrick-canterino.de>
Fri, 5 Jun 2026 14:02:08 +0000 (16:02 +0200)
Fixed file encryption on classic upload

See merge request jirafeau/Jirafeau!34

f.php
lib/functions.php
script.php

diff --git a/f.php b/f.php
index 269b10be94725f3395ec739c2e0a614767dbab80..870b4bdd8aa28b400d92f668c83ca784f1d7cfe6 100644 (file)
--- a/f.php
+++ b/f.php
@@ -171,7 +171,9 @@ if (!empty($link['key'])) {
         require(JIRAFEAU_ROOT.'lib/template/footer.php');
         exit;
     } else {
-        if (hash_equals($link['key'], md5($_POST['key']))) {
+        if (strpos($link['key'], '[SHA256]') == 0 && hash_equals(substr($link['key'], 8), hash('sha256', $_POST['key']))) {
+            $password_challenged = true;
+        } elseif (hash_equals($link['key'], md5($_POST['key']))) {
             $password_challenged = true;
         } else {
             sleep(2);
index e5a05b0e559ebe520eb7e99b4a06f96c061a5bbd..948a436de4843bd28f1b1210e1fcc3f379a8923f 100644 (file)
@@ -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 */
@@ -1088,10 +1088,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. */
@@ -1642,7 +1642,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()
index ae574494bf2165f2698c96b06b4f28773be762db..301ebe8cb088e83e6d9774bdc852d36811e10c68 100644 (file)
@@ -183,7 +183,7 @@ if (isset($_FILES['file']) && is_writable(VAR_FILES)
         echo 'Error 9';
         exit;
     }
-    if (strlen($link['key']) > 0 && md5($key) != $link['key']) {
+    if (strlen($link['key']) > 0 && hash('sha256', $key) != $link['key']) {
         sleep(2);
         echo 'Error 10';
         exit;

patrick-canterino.de