SEDbgMuxApp: properly handle peer.recv() returning None

In 2990cc14b8 I introduced a regression,
which affects the 'establish' command: if no data is received from a
Data Provider during 500 ms, the application crashes:

    File "sedbgmux.py", line 151, in do_establish
      if f['MsgType'] != DbgMuxFrame.MsgType.ConnData:
  TypeError: 'NoneType' object is not subscriptable

This is happening because peer.recv() is returning None.
This commit is contained in:
Vadim Yanitskiy 2022-07-14 17:53:42 +07:00
parent 2990cc14b8
commit 530975eff2
1 changed files with 2 additions and 1 deletions

View File

@ -147,7 +147,8 @@ class SEDbgMuxApp(cmd2.Cmd):
# Read the messages
while True:
f = self.peer.recv()
if f is None:
continue # No more data in the buffer
if f['MsgType'] != DbgMuxFrame.MsgType.ConnData:
log.warning('Unexpected frame: %s', f)
self.peer.send(DbgMuxFrame.MsgType.Ack)