]> git.p6c8.net - jirafeau_mojo42.git/commitdiff
[BUGFIX] Fix crash when admin downloads
authorJerome Jutteau <jerome@jutteau.fr>
Tue, 18 Sep 2018 19:59:31 +0000 (21:59 +0200)
committerJerome Jutteau <jerome@jutteau.fr>
Mon, 21 Oct 2019 19:36:13 +0000 (21:36 +0200)
If the admin tries to download a big file, the file read can cause a
crash.

Fixes #174

Signed-off-by: Jerome Jutteau <jerome@jutteau.fr>
admin.php

index 3e8f51712e943ffb930862b10c1ec4c19c39f008..4a3d25fa6605c9bb4b08f17c002cc4ea743be75a 100644 (file)
--- a/admin.php
+++ b/admin.php
@@ -255,7 +255,12 @@ if (php_sapi_name() == "cli") {
           header('Content-Disposition: attachment; filename="' .
                   $l['file_name'] . '"');
           if (file_exists(VAR_FILES . $p . $l['md5'])) {
-              readfile(VAR_FILES . $p . $l['md5']);
+              $r = fopen(VAR_FILES . $p . $l['md5'], 'r');
+              while (!feof($r)) {
+                  print fread($r, 1024);
+                  ob_flush();
+              }
+              fclose($r);
           }
           exit;
       }

patrick-canterino.de