summaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authorThomas Citharel <tcit@tcit.fr>2023-02-13 16:47:26 +0100
committerThomas Citharel <tcit@tcit.fr>2023-02-13 16:47:28 +0100
commite60888d98892be22477ea6ace68255d7202dbec8 (patch)
treea306ec6cbb6a052d464e9d97eb421ec83a1f85af /lib/private
parent8f0849a3177315547625c4d30a79da648165a830 (diff)
downloadnextcloud-server-e60888d98892be22477ea6ace68255d7202dbec8.tar.gz
nextcloud-server-e60888d98892be22477ea6ace68255d7202dbec8.zip
fix(preview-generator): Throw exception before dividing by zero when generating previews
If the maximum preview generated gives some kind of invalid IImage, it's dimentions and filename can be set to zero. And then later we do a division by zero to keep the aspect ratio of the previews. Signed-off-by: Thomas Citharel <tcit@tcit.fr>
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/Preview/Generator.php4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/private/Preview/Generator.php b/lib/private/Preview/Generator.php
index 47f2952c6e6..fd0a1009663 100644
--- a/lib/private/Preview/Generator.php
+++ b/lib/private/Preview/Generator.php
@@ -170,6 +170,10 @@ class Generator {
[$maxWidth, $maxHeight] = $this->getPreviewSize($maxPreview, $previewVersion);
+ if ($maxWidth <= 0 || $maxHeight <= 0) {
+ throw new NotFoundException('The maximum preview sizes are zero or less pixels');
+ }
+
$preview = null;
foreach ($specifications as $specification) {