[LEDE-DEV] hostapd: cli treat UNKNOWN COMMAND as failing
Denton Gentry
denny at geekhold.com
Sat Apr 8 20:33:07 PDT 2017
Avoid infinite loop at 100% CPU when running hostapd_cli
if CONFIG_CTRL_IFACE_MIB is not defined.
_newselect(4, [3], NULL, NULL, ...)
recvfrom(3, "UNKNOWN COMMAND\n", 4095, 0, NULL, NULL) = 16
sendto(3, "STA-NEXT UNKNOWN COMMAND", 24, 0, NULL, 0) = 24
Signed-off-by: Denton Gentry <denny at geekhold.com>
---
.../patches/381-hostapd_cli_UNKNOWN-COMMAND.patch | 35 ++++++++++++++++++++++
1 file changed, 35 insertions(+)
create mode 100644
package/network/services/hostapd/patches/381-hostapd_cli_UNKNOWN-COMMAND.patch
diff --git a/package/network/services/hostapd/patches/381-hostapd_cli_UNKNOWN-COMMAND.patch
b/package/network/services/hostapd/patches/381-hostapd_cli_UNKNOWN-COMMAND.patch
new file mode 100644
index 0000000..0e0a763
--- /dev/null
+++ b/package/network/services/hostapd/patches/381-hostapd_cli_UNKNOWN-COMMAND.patch
@@ -0,0 +1,35 @@
+From e41c99b9ca39d1be92ff67e2ab4e90b30bc2c247 Mon Sep 17 00:00:00 2001
+From: Denton Gentry <denny at geekhold.com>
+Date: Sat, 8 Apr 2017 23:55:07 +0000
+Subject: [PATCH] hostapd_cli: FAIL and UNKNOWN COMMAND are errors.
+
+Otherwise, running hostapd_cli without having
+CONFIG_CTRL_IFACE_MIB defined results in an infinite
+loop at 100% CPU:
+
+_newselect(4, [3], NULL, NULL, {tv_sec=10, tv_usec=0}) = 1 (in [3],
left {tv_sec=9, tv_usec=999987})
+recvfrom(3, "UNKNOWN COMMAND\n", 4095, 0, NULL, NULL) = 16
+sendto(3, "STA-NEXT UNKNOWN COMMAND", 24, 0, NULL, 0) = 24
+_newselect(4, [3], NULL, NULL, {tv_sec=10, tv_usec=0}) = 1 (in [3],
left {tv_sec=9, tv_usec=999989})
+recvfrom(3, "UNKNOWN COMMAND\n", 4095, 0, NULL, NULL) = 16
+sendto(3, "STA-NEXT UNKNOWN COMMAND", 24, 0, NULL, 0) = 24
+---
+ hostapd/hostapd_cli.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/hostapd/hostapd_cli.c b/hostapd/hostapd_cli.c
+index a2fd9ac..a6e1289 100644
+--- a/hostapd/hostapd_cli.c
++++ b/hostapd/hostapd_cli.c
+@@ -771,7 +771,7 @@ static int wpa_ctrl_command_sta(struct wpa_ctrl
*ctrl, const char *cmd,
+ }
+
+ buf[len] = '\0';
+- if (memcmp(buf, "FAIL", 4) == 0)
++ if (memcmp(buf, "FAIL", 4) == 0 || memcmp(buf, "UNKNOWN
COMMAND", 15) == 0)
+ return -1;
+ if (print)
+ printf("%s", buf);
+--
+2.7.4
+
--
2.7.4
More information about the Lede-dev
mailing list