Mair / esp32-course

Course on the ESP32 IDF
https://learnesp32.com
282 stars 122 forks source link

Protect against logical comparison errors in wifi_connect.c #265

Open e5h opened 3 months ago

e5h commented 3 months ago

If any additional bits are being used in wifi_connect (eg. by setting both a CONNECTED and IP_ASSIGNED flag), a direct comparison of result == CONNECTED will fail even if the CONNECTED bit is set, due to the presence of other bits.

Since the checked flags are cleared via xClearOnExit = pdTRUE, the flag notifying an IP assignment will be lost, and not set again in any reasonable amount of time. This is a simple change to evaluate the bitwise & result of the return to evaluate if the correct flag has been set.