From b70c214584109d102848f2c8ee5ddc1e1cbefdb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torma=20Krist=C3=B3f?= Date: Sun, 25 Apr 2021 18:25:27 +0200 Subject: [PATCH 1/2] fix cascading memes --- server/netwrapper.py | 1 + server/server.py | 2 ++ 2 files changed, 3 insertions(+) diff --git a/server/netwrapper.py b/server/netwrapper.py index 4eca973..11aa462 100644 --- a/server/netwrapper.py +++ b/server/netwrapper.py @@ -140,3 +140,4 @@ class NetWrapper: return plaintext except Exception: print("Incorrect decryption") + return "ERROR".encode('UTF-8') diff --git a/server/server.py b/server/server.py index 812aab1..29717f1 100644 --- a/server/server.py +++ b/server/server.py @@ -40,6 +40,8 @@ class Server: self.networkInstance.sendMessage("LINOK".encode('UTF-8')) elif command == "LINERROR": self.networkInstance.sendMessage("LINERROR".encode('UTF-8')) + elif command == "ERROR": + return None parsedCommand = command.split(" ") if len(parsedCommand) > 3: self.networkInstance.sendMessage("ERROR".encode('UTF-8')) From b6d46ea1bf5b3b78539c5c3c9488e739a532d1b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torma=20Krist=C3=B3f?= Date: Sun, 25 Apr 2021 18:29:00 +0200 Subject: [PATCH 2/2] return bytes --- server/executor.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/server/executor.py b/server/executor.py index b28379d..5c67947 100644 --- a/server/executor.py +++ b/server/executor.py @@ -72,11 +72,14 @@ class Executor: f.close() return currenctfile - def getFileInCurrentDirectory(self, file: str): + def getFileInCurrentDirectory(self, file: str) -> bytes: file = self.sanitizeFile(file) currentfile = os.path.join(self.currentDirectory, file) if os.path.exists(currentfile): - return open(currentfile, "r") + f = open(currentfile, "rb") + content = f.read() + f.close() + return content else: raise Exception('File not found')