Skip to content

Commit

Permalink
Gracefully handle malformed dispatcher frames in SCIONElement (#2094)
Browse files Browse the repository at this point in the history
  • Loading branch information
shitz authored Nov 6, 2018
1 parent af1713b commit e72ec2f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
3 changes: 1 addition & 2 deletions python/lib/socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,7 @@ def recv(self, block=True):
return None, None
cookie, addr_type, packet_len = struct.unpack("!8sBI", buf)
if cookie != self.COOKIE:
logging.critical("Dispatcher socket out of sync")
raise SCIONIOError
raise SCIONIOError("Dispatcher socket out of sync")
port_len = 0
if addr_type != AddrType.NONE:
port_len = 2
Expand Down
9 changes: 7 additions & 2 deletions python/scion_elem/scion_elem.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
from lib.errors import (
SCIONBaseError,
SCIONChecksumFailed,
SCIONIOError,
SCIONServiceLookupError,
)
from lib.log import log_exception
Expand Down Expand Up @@ -1033,9 +1034,13 @@ def handle_accept(self, sock):

def handle_recv(self, sock):
"""
Callback to handle a ready recving socket
Callback to handle a ready receiving socket
"""
packet, addr = sock.recv()
try:
packet, addr = sock.recv()
except SCIONIOError as e:
logging.error("Socket IO error: %s", e)
return
if packet is None:
self._socks.remove(sock)
sock.close()
Expand Down

0 comments on commit e72ec2f

Please sign in to comment.