[PATCH] Fix potential bugs of wpa_ctrl_request

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxx>
Signed-off-by: xinpeng wang <wangxinpeng@xxxxxxxxxxxxx>
---
 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




_______________________________________________
Hostap mailing list
Hostap@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/hostap



[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux