[PATCH] Fix potential bugs of wpa_ctrl_request

Johannes Berg johannes at sipsolutions.net
Fri Jul 23 04:02:58 PDT 2021

On Fri, 2021-07-23 at 06:01 -0400, Alan DeKok wrote:
> On Jul 23, 2021, at 5:41 AM, xinpeng wang <wangxinpeng at uniontech.com> wrote:
> > 
> > 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
>   This patch helps on Linux, it is likely to not work on other systems.
>   Setting the time outside of the loop is good, but that relies on select() updating the value of &tv when it returns.  IIRC, only Linux does that.  Other operating systems don't touch "tv", which means it's value is left at 10.
>   I've attached my own attempt at a patch.  It calculates the end time, and then updates "tv" on every iteration of the loop.

Looks good to me. Technically, you could also move the "started_at"
variable into the loop together with "diff", you only need "ending_at"
to be outside.


More information about the Hostap mailing list