From 778893d0813e78dc679cfad68c2ca9ec30a9c079 Mon Sep 17 00:00:00 2001 From: Michael Pivato Date: Tue, 15 Jan 2019 10:39:25 +1030 Subject: [PATCH] Fix message unpacking for commander --- DecisionSystem/CentralisedDecision/commander.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/DecisionSystem/CentralisedDecision/commander.py b/DecisionSystem/CentralisedDecision/commander.py index c78d15a..840a822 100644 --- a/DecisionSystem/CentralisedDecision/commander.py +++ b/DecisionSystem/CentralisedDecision/commander.py @@ -60,7 +60,12 @@ class Commander: self.make_decision() def on_message(self, client, userdata, message): - messageDict = umsgpack.unpackb() + try: + messageDict = umsgpack.unpackb(message.payload) + except: + print("Incorrect Message") + return + if "type" in messageDict.keys: # Need to consider that a malicious message may have a type with incorrect subtypes. if messageDict["type"] == "connect":