Repository navigation
fix(wifi): replace credentials completely; reject over-long SSIDs / passwords (#848) - #849
Merged
Merged
Conversation
…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
|
✅Static analysis result - no issues found! ✅ |
…(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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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→abcdefghbecameabcdefgh90) 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.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)andWifiAp::set_config/set_ssid_and_passworduse it and log + returnfalseon 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).components/wifi/test/wifi_credentials_host_test.cppcovers the reported case, the SSID, the empty value, the exactly-full field and the one-byte-too-long refusal.Test plan
c++ -std=c++23 -Wall -Wextra -Werrorhost test passescomponents/wifi/examplebuilds for esp32 (IDF 6.1)🤖 Generated with Claude Code
https://claude.ai/code/session_01DFjjnq3XCTRAXENSxsCxJU