Commit 3ed9249
0ldev
fix: two bugs found in code review
Bug 1 — soft_ap_ssid buffer overflow (Politician.cpp begin())
wifi_ap_config_t::ssid is uint8_t[32]. The previous memcpy used raw
strlen() without any guard, so a caller-supplied SSID longer than 32
bytes would write past the ssid[] field into the adjacent password[]
field of the stack-allocated wifi_config_t. Added:
if (ap_ssid_len > 32) ap_ssid_len = 32;
before the memcpy.
Bug 2 — TOCTOU race in setTargetBySsid() (Politician.cpp)
The function released _lock before dereferencing _apCache[best].bssid
and _apCache[best].channel. On a dual-core ESP32, the worker task on
Core 0 can evict or overwrite that cache slot between the lock release
and the setTarget() call, causing the engine to lock onto the wrong AP.
Fix: copy bssid/channel into local variables before xSemaphoreGive,
then call setTarget() with the local copies.
Note: ClientFoundCb signature change
ClientFoundCb changed from (bssid, sta, rssi) to (const ClientRecord &).
Added migration note at top of README.1 parent 8ba74e1 commit 3ed9249
2 files changed
Lines changed: 30 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
10 | 26 | | |
11 | 27 | | |
12 | 28 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
146 | 146 | | |
147 | 147 | | |
148 | 148 | | |
149 | | - | |
150 | | - | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
151 | 153 | | |
152 | 154 | | |
153 | 155 | | |
| |||
573 | 575 | | |
574 | 576 | | |
575 | 577 | | |
576 | | - | |
577 | | - | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
578 | 582 | | |
579 | 583 | | |
580 | 584 | | |
581 | 585 | | |
582 | 586 | | |
583 | 587 | | |
584 | 588 | | |
585 | | - | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
586 | 593 | | |
587 | 594 | | |
588 | 595 | | |
589 | 596 | | |
590 | | - | |
591 | | - | |
| 597 | + | |
| 598 | + | |
592 | 599 | | |
593 | 600 | | |
594 | 601 | | |
| |||
0 commit comments