[LEDE-DEV] hostapd: cli treat UNKNOWN COMMAND as failing

Denton Gentry denny at geekhold.com
Sun Apr 9 06:57:29 PDT 2017


I'll get git send-email configured with a working SMTP server and send
this again, even in plain text mode my email client wrapped the lines.

On Sat, Apr 8, 2017 at 8:33 PM, Denton Gentry <denny at geekhold.com> wrote:
> 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