]> git.mxchange.org Git - hub.git/blobdiff - application/hub/classes/package/class_NetworkPackage.php
Also check for empty hash here, too.
[hub.git] / application / hub / classes / package / class_NetworkPackage.php
index 4e4f384eb4eaa0c36815444f616ad85d0bd820f4..bc471498e948c0aafe883b81c6133800de03a809 100644 (file)
@@ -360,6 +360,12 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R
                        //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: senderData=' . print_r($senderData, TRUE));
                        assert(isset($senderData[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_PRIVATE_KEY_HASH]));
 
+                       // Don't accept empty hashes
+                       if (empty($senderData[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_PRIVATE_KEY_HASH])) {
+                               // Don't accept
+                               die('[' . __METHOD__ . ':' . __LINE__ . ':] Empty private key hash: senderData=' . print_r($senderData, TRUE));
+                       } // END - if
+
                        // Return it
                        return $senderData[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_PRIVATE_KEY_HASH];
                } // END - if
@@ -368,6 +374,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 +712,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 +722,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 +1400,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);