From 7bb8c2c80c4ade483efc7cd02ce21d98d76dfc11 Mon Sep 17 00:00:00 2001 From: Kevin Trocolli Date: Wed, 3 May 2023 03:25:55 -0400 Subject: [PATCH] billing: handle malformed requests --- core/allnet.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/core/allnet.py b/core/allnet.py index 119f0ae..ab435e7 100644 --- a/core/allnet.py +++ b/core/allnet.py @@ -249,14 +249,18 @@ class AllnetServlet: signer = PKCS1_v1_5.new(rsa) digest = SHA.new() - kc_playlimit = int(req_dict[0]["playlimit"]) - kc_nearfull = int(req_dict[0]["nearfull"]) - kc_billigtype = int(req_dict[0]["billingtype"]) - kc_playcount = int(req_dict[0]["playcnt"]) - kc_serial: str = req_dict[0]["keychipid"] - kc_game: str = req_dict[0]["gameid"] - kc_date = strptime(req_dict[0]["date"], "%Y%m%d%H%M%S") - kc_serial_bytes = kc_serial.encode() + try: + kc_playlimit = int(req_dict[0]["playlimit"]) + kc_nearfull = int(req_dict[0]["nearfull"]) + kc_billigtype = int(req_dict[0]["billingtype"]) + kc_playcount = int(req_dict[0]["playcnt"]) + kc_serial: str = req_dict[0]["keychipid"] + kc_game: str = req_dict[0]["gameid"] + kc_date = strptime(req_dict[0]["date"], "%Y%m%d%H%M%S") + kc_serial_bytes = kc_serial.encode() + + except KeyError as e: + return f"result=5&linelimit=&message={e} field is missing".encode() machine = self.data.arcade.get_machine(kc_serial) if machine is None and not self.config.server.allow_unregistered_serials: