summaryrefslogtreecommitdiffstats
path: root/lib/private/legacy
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2017-03-08 21:48:30 +0100
committerRoeland Jago Douma <roeland@famdouma.nl>2017-03-08 21:48:30 +0100
commit7dd760d737b9742e5e600a8dbf48293f567d7f72 (patch)
treeb1bf481cc67377df65b882c3d4253f25179c3024 /lib/private/legacy
parent2a8e922d67a1246e101f926f1b0ab287db71929e (diff)
downloadnextcloud-server-7dd760d737b9742e5e600a8dbf48293f567d7f72.tar.gz
nextcloud-server-7dd760d737b9742e5e600a8dbf48293f567d7f72.zip
Test is a file is a valid jpg file
During preview generation if we provide an invalid JPG file the system errors out with a PHP Fatal Error. Now we can't catch Fatal Errors (in 5.6). I suspect that exif_imagetype to fall back to the extention. However a valid jpg file has a size. So we request the size of the image and just drop out if that returns false. Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'lib/private/legacy')
-rw-r--r--lib/private/legacy/image.php6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/private/legacy/image.php b/lib/private/legacy/image.php
index ed7dfce29a6..e26148bdf15 100644
--- a/lib/private/legacy/image.php
+++ b/lib/private/legacy/image.php
@@ -562,7 +562,11 @@ class OC_Image implements \OCP\IImage {
break;
case IMAGETYPE_JPEG:
if (imagetypes() & IMG_JPG) {
- $this->resource = imagecreatefromjpeg($imagePath);
+ if (getimagesize($imagePath) !== false) {
+ $this->resource = imagecreatefromjpeg($imagePath);
+ } else {
+ $this->logger->debug('OC_Image->loadFromFile, JPG image not valid: ' . $imagePath, array('app' => 'core'));
+ }
} else {
$this->logger->debug('OC_Image->loadFromFile, JPG images not supported: ' . $imagePath, array('app' => 'core'));
}