tAdd some safety checks for "params" in query. - obelisk - Electrum server using libbitcoin as its backend
HTML git clone https://git.parazyd.org/obelisk
DIR Log
DIR Files
DIR Refs
DIR README
DIR LICENSE
---
DIR commit 2b45995159b020b9a58bd618fffd54cd2ac1ec25
DIR parent 6336ae0a80efab0d65b7d62411625a7f90371c6a
HTML Author: parazyd <parazyd@dyne.org>
Date: Wed, 7 Apr 2021 18:41:39 +0200
Add some safety checks for "params" in query.
Diffstat:
M electrumobelisk/protocol.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
---
DIR diff --git a/electrumobelisk/protocol.py b/electrumobelisk/protocol.py
t@@ -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]
t@@ -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):