Added check on empty hash
authorRoland Haeder <roland@mxchange.org>
Thu, 3 Sep 2015 19:54:03 +0000 (21:54 +0200)
committerRoland Haeder <roland@mxchange.org>
Thu, 3 Sep 2015 19:54:03 +0000 (21:54 +0200)
Signed-off-by: Roland Haeder <roland@mxchange.org>
application/hub/classes/package/class_NetworkPackage.php

index 4e4f384..3fdc59e 100644 (file)
@@ -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);