summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukas Reschke <lukas@statuscode.ch>2013-03-02 02:59:00 -0800
committerLukas Reschke <lukas@statuscode.ch>2013-03-02 02:59:00 -0800
commit5a9e9e0b51b13cf1bb06cc129ba0b86c48ae79f9 (patch)
tree021deb166eef890982eda399d37833d0f5569794
parent4c8c97474062515001ba24e0b15a9fdb4574cce1 (diff)
parent07b956c22d8ba5a6ac94dc3047bde8ca7a91609f (diff)
downloadnextcloud-server-5a9e9e0b51b13cf1bb06cc129ba0b86c48ae79f9.tar.gz
nextcloud-server-5a9e9e0b51b13cf1bb06cc129ba0b86c48ae79f9.zip
Merge pull request #2026 from j-ed/master
do not try to extract image infos from 0- or better less than 12-byte length files.
-rw-r--r--lib/image.php11
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/image.php b/lib/image.php
index 97b0231047b..c1b187608a6 100644
--- a/lib/image.php
+++ b/lib/image.php
@@ -35,7 +35,13 @@ class OC_Image {
* @returns string The mime type if the it could be determined, otherwise an empty string.
*/
static public function getMimeTypeForFile($filepath) {
- $imagetype = exif_imagetype($filepath);
+ // exif_imagetype throws "read error!" if file is less than 12 byte
+ if (filesize($filepath) > 11) {
+ $imagetype = exif_imagetype($filepath);
+ }
+ else {
+ $imagetype = false;
+ }
return $imagetype ? image_type_to_mime_type($imagetype) : '';
}
@@ -385,7 +391,8 @@ class OC_Image {
* @returns An image resource or false on error
*/
public function loadFromFile($imagepath=false) {
- if(!is_file($imagepath) || !file_exists($imagepath) || !is_readable($imagepath)) {
+ // exif_imagetype throws "read error!" if file is less than 12 byte
+ if(!is_file($imagepath) || !file_exists($imagepath) || filesize($imagepath) < 12 || !is_readable($imagepath)) {
// Debug output disabled because this method is tried before loadFromBase64?
OC_Log::write('core', 'OC_Image->loadFromFile, couldn\'t load: '.$imagepath, OC_Log::DEBUG);
return false;