From eb97a47a253b0eedcddf61c66e96a1acfa24154d Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Sat, 9 Jan 2021 20:09:53 +0100 Subject: [PATCH] Warn other user is the data contains a zero --- squinnondation/messages.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/squinnondation/messages.py b/squinnondation/messages.py index 56694fd..0f31845 100644 --- a/squinnondation/messages.py +++ b/squinnondation/messages.py @@ -301,6 +301,12 @@ class DataTLV(TLV): "You are not my neighbour, I don't listen to your DataTLV. Please say me Hello before."))) return + if 0 in self.data: + user.send_packet(sender, Packet.construct(WarningTLV.construct( + f"The length of your DataTLV mismatches. You told me that the length is {len(self.data)} " + f"while a zero was found at index {self.data.index(0)}."))) + self.data = self.data[:self.data.index(0)] + msg = self.data.decode('UTF-8') # Acknowledge the packet