chiark / gitweb /
mtu: Discard over-mtu packets
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 18 Jun 2019 17:41:27 +0000 (18:41 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 18 Jun 2019 17:41:27 +0000 (18:41 +0100)
There is no authentication of packet data.  Bad captive portals
etc. can send garbage bad enough to overflow the mtu and cause the
client to crash.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
hippotatlib/__init__.py

index 6423ba346f77fbdc3d5ce332dcc2eb295177f648..91696b1b954f3dc91675208310e06dbec0575aed 100644 (file)
@@ -232,6 +232,7 @@ class SlipStreamDecoder():
     self._buffer = b''
     self._on_packet = on_packet
     self._desc = desc
+    self._mtu = mtu
     self._log('__init__')
 
   def _log(self, msg, **kwargs):
@@ -249,7 +250,7 @@ class SlipStreamDecoder():
 
   def _maybe_packet(self, packet):
     self._log('maybepacket', d=packet)
-    if len(packet):
+    if len(packet) and len(packet) <= self._mtu:
       self._on_packet(packet)
 
   def flush(self):