Skip to content

Commit a4465a7

Browse files
author
Matthew Garrett
authored
Merge pull request mjg59#46 from Danielhiversen/patch-10
validate the authorization
2 parents b30fc0d + 39e170c commit a4465a7

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

broadlink/__init__.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,16 @@ def auth(self):
179179
aes = AES.new(bytes(self.key), AES.MODE_CBC, bytes(self.iv))
180180
payload = aes.decrypt(bytes(enc_payload))
181181

182+
if not payload:
183+
return False
184+
185+
key = payload[0x04:0x14]
186+
if len(key) % 16 != 0:
187+
return False
188+
182189
self.id = payload[0x00:0x04]
183-
self.key = payload[0x04:0x14]
190+
self.key = key
191+
return True
184192

185193
def get_type(self):
186194
return self.type

0 commit comments

Comments
 (0)