From 7c53f67f53ef5f0b07b4e3c8b9e874b52942af6c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Thu, 16 Feb 2023 20:20:08 +0100 Subject: [PATCH] Continued: - added more checks on parameter --- .../classes/stacker/file/class_BaseFileStack.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/framework/main/classes/stacker/file/class_BaseFileStack.php b/framework/main/classes/stacker/file/class_BaseFileStack.php index 6718eac2..ef8a7c8a 100644 --- a/framework/main/classes/stacker/file/class_BaseFileStack.php +++ b/framework/main/classes/stacker/file/class_BaseFileStack.php @@ -705,10 +705,23 @@ abstract class BaseFileStack extends BaseStacker { * @param $hash Hash from encoded value * @param $encoded Encoded value to be written to the file * @return $data Gap position and length of the raw data + * @throws InvalidArgumentException If a parameter has an invalid value */ public function writeDataToFreeGap (string $stackName, string $hash, string $encoded) { - // Raw data been written to the file + // Check parameter /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: stackName=%s,hash{}=0x%s,encoded()=%d - CALLED!', $stackName, bin2hex($hash), strlen($encoded))); + if (empty($stackName)) { + // Throw IAE + throw new InvalidArgumentException('Parameter "stackName" is empty'); + } elseif (empty($hash)) { + // Throw IAE + throw new InvalidArgumentException('Parameter "hash" is empty'); + } elseif (empty($encoded)) { + // Throw IAE + throw new InvalidArgumentException('Parameter "encoded" is empty'); + } + + // Raw data been written to the file $rawData = sprintf('%s%s%s%s%s', $stackName, BinaryFile::SEPARATOR_GROUP_HASH, -- 2.39.5