From: Roland Häder Date: Thu, 16 Feb 2023 19:20:08 +0000 (+0100) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=7c53f67f53ef5f0b07b4e3c8b9e874b52942af6c;p=core.git Continued: - added more checks on parameter --- 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,