From 0c10c79979df18c488f7a266a3cc17b77ae775f8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Thu, 15 Sep 2022 12:33:33 +0200 Subject: [PATCH] Add safety check to PackageInstallationNodeBuilder to detect corrupted installation plans --- .../package/PackageInstallationNodeBuilder.class.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/wcfsetup/install/files/lib/system/package/PackageInstallationNodeBuilder.class.php b/wcfsetup/install/files/lib/system/package/PackageInstallationNodeBuilder.class.php index 91a9f30633..589831f0e8 100644 --- a/wcfsetup/install/files/lib/system/package/PackageInstallationNodeBuilder.class.php +++ b/wcfsetup/install/files/lib/system/package/PackageInstallationNodeBuilder.class.php @@ -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++; -- 2.20.1