From 30885edb7e89a97cd30593a0043eab303683e341 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Mon, 1 Jun 2020 22:24:00 +0300 Subject: [PATCH] wpaspy: Be a bit more careful on detaching the control interface Check that the client socket is still open before trying to detach the control interface to avoid undesired exceptions on cleanup paths on unexpected errors due to the socket getting closed. Signed-off-by: Jouni Malinen --- wpaspy/wpaspy.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/wpaspy/wpaspy.py b/wpaspy/wpaspy.py index 89e973b98..c50cd531e 100644 --- a/wpaspy/wpaspy.py +++ b/wpaspy/wpaspy.py @@ -113,6 +113,9 @@ class Ctrl: def detach(self): if not self.attached: return None + if self.s.fileno() == -1: + self.attached = False + return None while self.pending(): ev = self.recv() res = self.request("DETACH")