From: Alexander Ebert Date: Fri, 19 Jan 2024 10:54:28 +0000 (+0100) Subject: Safeguard against invalid EXIF values X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=c5bb7db7e5dc4529953f9241d2f9a8175af1922e;p=GitHub%2FWoltLab%2FWCF.git Safeguard against invalid EXIF values See https://www.woltlab.com/community/thread/304312-fehlermeldung-division-by-zero-bei-anzeigen-aktualisieren-galerie-bilder-aktuali/ --- diff --git a/wcfsetup/install/files/lib/util/ExifUtil.class.php b/wcfsetup/install/files/lib/util/ExifUtil.class.php index bdee394585..bc2d515807 100644 --- a/wcfsetup/install/files/lib/util/ExifUtil.class.php +++ b/wcfsetup/install/files/lib/util/ExifUtil.class.php @@ -300,6 +300,12 @@ final class ExifUtil $denonimator = $data[1]; $gcd = self::gcd($numerator, $denonimator); + // When the numerator equals 0 (e.g. 0/10), then the resulting GCD will + // equal null, resulting in a division by zero below. + if ($gcd === 0) { + return $rational; + } + return \sprintf('%d/%d', \intdiv($numerator, $gcd), \intdiv($denonimator, $gcd)); }