From: Roland Haeder Date: Thu, 3 Sep 2015 19:54:03 +0000 (+0200) Subject: Added check on empty hash X-Git-Url: https://git.mxchange.org/?p=hub.git;a=commitdiff_plain;h=ca28f9b53360b2b76522682420fc6dc0ed014883 Added check on empty hash Signed-off-by: Roland Haeder --- diff --git a/application/hub/classes/package/class_NetworkPackage.php b/application/hub/classes/package/class_NetworkPackage.php index 4e4f384eb..3fdc59eed 100644 --- a/application/hub/classes/package/class_NetworkPackage.php +++ b/application/hub/classes/package/class_NetworkPackage.php @@ -368,6 +368,12 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R //* DEBUG-DIE */ die('decodedData=' . print_r($decodedData, TRUE)); assert(isset($decodedData[self::PACKAGE_CONTENT_PRIVATE_KEY_HASH])); + // Don't accept empty keys + if (empty($decodedData[self::PACKAGE_CONTENT_PRIVATE_KEY_HASH])) { + // This needs fixing + die('[' . __METHOD__ . ':' . __LINE__ . ':] Empty private key hash: decodedData=' . print_r($decodedData, TRUE)); + } // END - if + // There is no DHT entry so, accept the hash from decoded data return $decodedData[self::PACKAGE_CONTENT_PRIVATE_KEY_HASH]; } @@ -700,6 +706,7 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R assert(isset($decodedArray[self::PACKAGE_CONTENT_SENDER])); assert(isset($decodedArray[self::PACKAGE_CONTENT_MESSAGE])); assert(isset($decodedArray[self::PACKAGE_CONTENT_HASH])); + assert(isset($decodedArray[self::PACKAGE_CONTENT_PRIVATE_KEY_HASH])); // Is the feature enabled? if (!FrameworkFeature::isFeatureAvailable('hubcoin_reward')) { @@ -709,7 +716,7 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R } // END - if // Check validity - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: senderId=' . $decodedArray[self::PACKAGE_CONTENT_SENDER] . ',message()=' . strlen($decodedArray[self::PACKAGE_CONTENT_MESSAGE]) . '),hash=' . $decodedArray[self::PACKAGE_CONTENT_HASH]); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: senderId=' . $decodedArray[self::PACKAGE_CONTENT_SENDER] . ',message()=' . strlen($decodedArray[self::PACKAGE_CONTENT_MESSAGE]) . ',hash=' . $decodedArray[self::PACKAGE_CONTENT_HASH]); //* DEBUG-DIE: */ die(__METHOD__ . ': decodedArray=' . print_r($decodedArray, TRUE)); $isHashValid = FrameworkFeature::callFeature('hubcoin_reward', 'checkHash', array($decodedArray[self::PACKAGE_CONTENT_SENDER] . ':' . $decodedArray[self::PACKAGE_CONTENT_MESSAGE] . ':' . $this->determineSenderPrivateKeyHash($decodedArray), $decodedArray[self::PACKAGE_CONTENT_HASH])); @@ -1387,7 +1394,7 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R $chainInstance->processMessage($decodedContent, $this); /* - * Post-processing of message data (this won't remote the message from + * Post-processing of message data (this won't remove the message from * the stack). */ $chainInstance->postProcessMessage($this);