Fix the handling of corrupted files
authorAlexander Ebert <ebert@woltlab.com>
Tue, 30 Jul 2024 09:21:08 +0000 (11:21 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Tue, 30 Jul 2024 09:21:08 +0000 (11:21 +0200)
wcfsetup/install/files/lib/data/file/FileEditor.class.php
wcfsetup/install/files/lib/system/worker/AttachmentRebuildDataWorker.class.php

index 2b860602c2c5cb3e70aa2e4b43dde4ffbd13b173..05656ed22c693ec57afc398c40637d67a497cf5a 100644 (file)
@@ -128,7 +128,11 @@ class FileEditor extends DatabaseObjectEditor
 
         $width = $height = null;
         if ($isImage) {
-            [$width, $height] = \getimagesize($pathname);
+            try {
+                [$width, $height] = \getimagesize($pathname);
+            } catch (\Throwable) {
+                return null;
+            }
         }
 
         $fileAction = new FileAction([], 'create', ['data' => [
index 78d256d056bd3d2275e445c41f16209f1d8eb4a4..4f52554d1e4137ea172eaa8a20731c97c92cf6fa 100644 (file)
@@ -6,10 +6,6 @@ use wcf\data\attachment\Attachment;
 use wcf\data\attachment\AttachmentEditor;
 use wcf\data\attachment\AttachmentList;
 use wcf\data\file\FileEditor;
-use wcf\system\database\exception\DatabaseQueryException;
-use wcf\system\exception\SystemException;
-use wcf\system\database\exception\DatabaseQueryExecutionException;
-use wcf\system\database\exception\DatabaseTransactionException;
 use wcf\system\WCF;
 
 /**