diff options
| author | Weilu Jia <optix2000@teitoku.net> | 2016-12-12 18:17:10 -0800 |
|---|---|---|
| committer | Tobias Brunner <tobias@strongswan.org> | 2016-12-14 11:35:31 +0100 |
| commit | 351179d4dc96d20c1b76740c87e9b0355bed8222 (patch) | |
| tree | f428385d6022ff3cc3d1656482b17a68d3c1a6b9 /src/libcharon/plugins/vici/python | |
| parent | 564a19967477adb60e018609d3ab76c554705f08 (diff) | |
| download | strongswan-351179d4dc96d20c1b76740c87e9b0355bed8222.tar.bz2 strongswan-351179d4dc96d20c1b76740c87e9b0355bed8222.tar.xz | |
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.
Diffstat (limited to 'src/libcharon/plugins/vici/python')
| -rw-r--r-- | src/libcharon/plugins/vici/python/vici/protocol.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/libcharon/plugins/vici/python/vici/protocol.py b/src/libcharon/plugins/vici/python/vici/protocol.py index 4951817eb..880d3343c 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 |
