Skip to content

fix(wifi): replace credentials completely; reject over-long SSIDs / passwords (#848) - #849

Merged
finger563 merged 3 commits into
mainfrom
fix/wifi-credentials-stale-bytes
Oct 20, 2026
Merged

finger563 merged 3 commits into
mainfrom
fix/wifi-credentials-stale-bytes

Conversation

@finger563

Copy link
Copy Markdown
Contributor

Summary

Fixes #848. WifiSta::connect(ssid, password) loaded the stored STA configuration and copied the new SSID / password over it without clearing the fields, so a shorter value kept the trailing bytes of the previous one (1234567890 → abcdefgh became abcdefgh90) and authentication failed. An empty password silently kept the old one, although the API documents an empty password as "open network". None of the credential setters checked the value length against the 32-byte SSID / 64-byte password fields.

  • New wifi_credentials::set_field() (include/wifi_credentials.hpp, standard-library only): clears the whole field, then copies the value; refuses (field untouched) a value longer than the field; an empty value clears it.
  • WifiSta::set_config / connect(ssid, password) and WifiAp::set_config / set_ssid_and_password use it and log + return false on an over-long SSID or password. connect() now clears the stored password for an empty one, as its doc says (the rest of the stored STA configuration is still kept).
  • Host test components/wifi/test/wifi_credentials_host_test.cpp covers the reported case, the SSID, the empty value, the exactly-full field and the one-byte-too-long refusal.
  • Doxyfile + the wifi_sta docs page include the new header.

Test plan

  • c++ -std=c++23 -Wall -Wextra -Werror host test passes
  • components/wifi/example builds for esp32 (IDF 6.1)
  • Reporter's scenario on hardware (connect with a 10-character password, reconnect with an 8-character one)

🤖 Generated with Claude Code

https://claude.ai/code/session_01DFjjnq3XCTRAXENSxsCxJU

…onger than their fields

WifiSta::connect(ssid, password) loaded the stored STA configuration and
memcpy'd the new SSID and password over it without clearing the fields, so a
shorter value kept the trailing bytes of the previous one ("1234567890" ->
"abcdefgh" became "abcdefgh90") and authentication failed; an empty password
silently kept the old one although the API documents it as "open network".
None of the setters checked the lengths against the 32 / 64-byte fields.

New wifi_credentials::set_field() (standard-library only, host test in
components/wifi/test) clears a field and copies the value, refusing one that
does not fit; WifiSta::set_config / connect and WifiAp::set_config /
set_ssid_and_password use it and log + return false on an over-long value.
An empty password now clears the stored one, as documented.

Fixes #848

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DFjjnq3XCTRAXENSxsCxJU
@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

✅Static analysis result - no issues found! ✅

@finger563 finger563 self-assigned this Oct 20, 2026
@finger563 finger563 added bug Something isn't working wifi labels Oct 20, 2026
finger563 and others added 2 commits October 20, 2026 09:45
…(cppcheck)

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DFjjnq3XCTRAXENSxsCxJU
…s are used

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DFjjnq3XCTRAXENSxsCxJU
@finger563
finger563 merged commit 6cab119 into main Oct 20, 2026
172 of 175 checks passed
@finger563
finger563 deleted the fix/wifi-credentials-stale-bytes branch October 20, 2026 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working wifi

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Stale characters remain in Wi-Fi credentials when updating to shorter strings

1 participant