Improved malformed packet detection

This commit is contained in:
Mark Qvist 2022-01-11 03:06:16 +01:00
parent 4253175627
commit fdaa58a6fa
3 changed files with 28 additions and 20 deletions

View File

@ -765,7 +765,7 @@ class Link:
return plaintext
except Exception as e:
RNS.log("Decryption failed on link "+str(self)+". The contained exception was: "+str(e), RNS.LOG_ERROR)
RNS.log(traceback.format_exc(), RNS.LOG_ERROR)
# RNS.log(traceback.format_exc(), RNS.LOG_ERROR)
# TODO: Think long about implications here
# self.teardown()

View File

@ -185,6 +185,7 @@ class Packet:
def unpack(self):
try:
self.flags = self.raw[0]
self.hops = self.raw[1]
@ -206,6 +207,11 @@ class Packet:
self.packed = False
self.update_hash()
return True
except Exception as e:
RNS.log("Received malformed packet, dropping it. The contained exception was: "+str(e), RNS.LOG_EXTREME)
return False
def send(self):
"""

View File

@ -585,7 +585,9 @@ class Transport:
Transport.jobs_locked = True
packet = RNS.Packet(None, raw)
packet.unpack()
if not packet.unpack():
return
packet.receiving_interface = interface
packet.hops += 1