Skip to content

Commit

Permalink
Limit avatar upload dimensions to reduce PHP out-of-memory errors hop…
Browse files Browse the repository at this point in the history
…efully?
  • Loading branch information
RedEnchilada committed Dec 2, 2014
1 parent 583ba9c commit 62f37f3
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions actions/avatarsettings.php
Expand Up @@ -362,6 +362,13 @@ function uploadAvatar()

$imagefile = new ImageFile(null, $temp_file_name);
}

if ($imagefile->width * $imagefile->height > 3000*3000) { // guesstimated sane limit
$imagefile->unlink();

$this->showForm(_('File is too big for our servers to process. (Maximum image dimensions should be 9000000 square pixels, or around 3000x3000.)'));
return;
}

$cur = common_current_user();
$type = $imagefile->preferredType();
Expand Down

0 comments on commit 62f37f3

Please sign in to comment.