Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 64 character WPA2 PSK password. #1146

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions Sming/SmingCore/Platform/Station.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ bool StationClass::config(String ssid, String password, bool autoConnectOnStartu
station_config config = {0};

if (ssid.length() >= sizeof(config.ssid)) return false;
if (password.length() >= sizeof(config.password)) return false;
if (password.length() > sizeof(config.password)) return false;

bool enabled = isEnabled();
bool dhcp = isEnabledDHCP();
Expand All @@ -70,7 +70,12 @@ bool StationClass::config(String ssid, String password, bool autoConnectOnStartu
memset(config.password, 0, sizeof(config.password));
config.bssid_set = false;
strcpy((char*)config.ssid, ssid.c_str());
strcpy((char*)config.password, password.c_str());
if (password.length() == 64) {
memcpy((char*)config.password, password.c_str(), 64);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue with this is that station_config::password is exactly 64 chars so you will have no ending zero... IMHO the correct fix would be to declare uint8 password[65]; in esp_sta.h, and signal a bug to espressif.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WPA passphrases are 8-63 ASCII characters by 802.11 spec so this is not a bug.

}
else {
strcpy((char*)config.password, password.c_str());
}

noInterrupts();

Expand Down