From: Weilu Jia Date: Tue, 13 Dec 2016 02:17:10 +0000 (-0800) Subject: vici: Check for closed connection in Python bindings X-Git-Tag: 5.5.2dr3~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=351179d4dc96d20c1b76740c87e9b0355bed8222;p=thirdparty%2Fstrongswan.git vici: Check for closed connection in Python bindings The Python VICI library does not check if the socket is closed. If the daemon closes the connection, _recvall() spins forever. Closes strongswan/strongswan#56. --- diff --git a/src/libcharon/plugins/vici/python/vici/protocol.py b/src/libcharon/plugins/vici/python/vici/protocol.py index 4951817eb0..880d3343c4 100644 --- a/src/libcharon/plugins/vici/python/vici/protocol.py +++ b/src/libcharon/plugins/vici/python/vici/protocol.py @@ -33,7 +33,10 @@ class Transport(object): """Ensure to read count bytes from the socket""" data = b"" while len(data) < count: - data += self.socket.recv(count - len(data)) + buf = self.socket.recv(count - len(data)) + if not buf: + raise socket.error('Connection closed') + data += buf return data