Add safety check to PackageInstallationNodeBuilder to detect corrupted installation...
authorTim Düsterhus <duesterhus@woltlab.com>
Thu, 15 Sep 2022 10:33:33 +0000 (12:33 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Thu, 15 Sep 2022 10:33:33 +0000 (12:33 +0200)
wcfsetup/install/files/lib/system/package/PackageInstallationNodeBuilder.class.php

index 91a9f306334fdf26a24efb5b7172b7021138906a..589831f0e8f5ee77e56620872fed95d98b5ed9e4 100644 (file)
@@ -598,6 +598,13 @@ class PackageInstallationNodeBuilder
         $this->emptyNode = true;
         $instructions = ($this->installation->getAction() == 'install') ? $this->installation->getArchive()->getInstallInstructions() : $this->installation->getArchive()->getUpdateInstructions();
         $count = \count($instructions);
+
+        if ($count === 0) {
+            // Abort if an empty list of instructions is received. This most likely indicates that
+            // the update instructions have been erroneously discarded.
+            throw new \Exception('Received an empty list of instructions.');
+        }
+
         $i = 0;
         foreach ($instructions as $pip) {
             $i++;