commit 2b45995159b020b9a58bd618fffd54cd2ac1ec25
parent 6336ae0a80efab0d65b7d62411625a7f90371c6a
Author: parazyd <parazyd@dyne.org>
Date: Wed, 7 Apr 2021 18:41:39 +0200
Add some safety checks for "params" in query.
Diffstat:
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/electrumobelisk/protocol.py b/electrumobelisk/protocol.py
@@ -152,7 +152,7 @@ class ElectrumProtocol(asyncio.Protocol): # pylint: disable=R0904,R0902
return await self._send_reply(writer, resp, query)
async def blockchain_block_header(self, query):
- if "params" not in query:
+ if "params" not in query or len(query["params"]) < 1:
return {"error": "malformed query"}
# TODO: cp_height
index = query["params"][0]
@@ -266,7 +266,7 @@ class ElectrumProtocol(asyncio.Protocol): # pylint: disable=R0904,R0902
if self.version_called:
self.log.warning("Got a subsequent %s call", query["method"])
return
- if len(query["params"]) != 2:
+ if "params" not in query or len(query["params"]) != 2:
return {"error": "malformed request"}
client_ver = query["params"][1]
if isinstance(client_ver, list):