Safeguard against invalid EXIF values
authorAlexander Ebert <ebert@woltlab.com>
Fri, 19 Jan 2024 10:54:28 +0000 (11:54 +0100)
committerOlaf Braun <info@braun-development.de>
Thu, 7 Mar 2024 15:36:30 +0000 (16:36 +0100)
See https://www.woltlab.com/community/thread/304312-fehlermeldung-division-by-zero-bei-anzeigen-aktualisieren-galerie-bilder-aktuali/

wcfsetup/install/files/lib/util/ExifUtil.class.php

index bdee394585bc09ad8bd9cd520ce44be60eabdc9d..bc2d515807452d1bd1211088bd9c34402ecf73de 100644 (file)
@@ -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));
     }