arduino/ArduinoCore-mbed

WhdSTAInterface::set_timeout(_timeout) crashes: 0239-WHD-add-join-timeout-parameter-to-WiFiSTAInterface-a.patch has a bug.

dac1e opened this issue · 1 comments

dac1e commented

0239-WHD-add-join-timeout-parameter-to-WiFiSTAInterface-a.patch has a bug.

This patch introduced the override of a new function 'nsapi_error_t set_timeout(uint32_t timeout)'.

The function in the patch file has no return value and looks as follows:

nsapi_error_t set_timeout(uint32_t timeout)
{
_timeout = timeout;
}

It should look as follows:

nsapi_error_t set_timeout(uint32_t timeout)
{
_timeout = timeout;
return NSAPI_ERROR_OK;
}

When I run the WifiAdvanceChatServer example on Arduino Giga, the function call

wifi_if->set_timeout(_timeout);

in line 78 of library file Wifi.cpp crashed.
The function set_timeout(uint32_t timeout) didn't return and rather fell through into the
implementation of

nsapi_error_t WhdSTAInterface::connect(
const char *ssid, const char *pass,
nsapi_security_t security,
uint8_t channel)

which crashed, because the function accessed random parameter values.

@dac1e Thanks. I've created a PR to fix this bug #1012