Commit 49baa77d authored by Tom Niget's avatar Tom Niget Committed by Tom Niget

bug: handle and log UTF-8 decoding failures in X.509

Those usually indicate that we're decoding something we shouldn't be, or that something wrong happened during decryption.
parent 57dfcd95
......@@ -302,7 +302,11 @@ class Peer:
if self._hmac(msg[:i]) == msg[i:] and self._i < seqno:
self._last = None
self._i = seqno
try:
return msg[4:i].decode()
except UnicodeDecodeError:
logging.error("Invalid message from %s: %r", self.prefix, msg)
raise
def encode(self, msg: str | bytes, _pack=seqno_struct.pack) -> bytes:
self._j += 1
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment