[PATCH] Fix potential bugs of wpa_ctrl_request

xinpeng wang wangxinpeng at uniontech.com
Fri Jul 23 02:41:25 PDT 2021


wpa_ctrl_request will block for up to 10 seconds while waiting for the reply,
but when this function call select is interrupted, re-assign the timeout parameter to 10s,
which will cause the time to exceed 10s;
if it is interrupted all the time, this function may block for a very long time

Signed-off-by: Xinpeng Wang <wangxinpeng at uniontech.com>
Signed-off-by: xinpeng wang <wangxinpeng at uniontech.com>
---
 src/common/wpa_ctrl.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/common/wpa_ctrl.c b/src/common/wpa_ctrl.c
index 40a979531..2d6f2bd06 100644
--- a/src/common/wpa_ctrl.c
+++ b/src/common/wpa_ctrl.c
@@ -539,9 +539,9 @@ retry_send:
 	}
 	os_free(cmd_buf);
 
+	tv.tv_sec = 10;
+	tv.tv_usec = 0;
 	for (;;) {
-		tv.tv_sec = 10;
-		tv.tv_usec = 0;
 		FD_ZERO(&rfds);
 		FD_SET(ctrl->s, &rfds);
 		res = select(ctrl->s + 1, &rfds, NULL, NULL, &tv);
@@ -567,6 +567,8 @@ retry_send:
 					reply[res] = '\0';
 					msg_cb(reply, res);
 				}
+				tv.tv_sec = 10;
+				tv.tv_usec = 0;
 				continue;
 			}
 			*reply_len = res;
-- 
2.20.1






More information about the Hostap mailing list