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 bug. in sta mode, empty passphrase should not use secure auth mode #5516

Merged
merged 3 commits into from Dec 18, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 5 additions & 4 deletions libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp
Expand Up @@ -113,21 +113,22 @@ wl_status_t ESP8266WiFiSTAClass::begin(const char* ssid, const char *passphrase,
return WL_CONNECT_FAILED;
}

if(passphrase && strlen(passphrase) > 64) {
int passphraseLen = passphrase == nullptr ? 0 : strlen(passphrase);
if(passphraseLen > 64) {
// fail passphrase too long!
return WL_CONNECT_FAILED;
}

struct station_config conf;
conf.threshold.authmode = (passphraseLen == 0) ? AUTH_OPEN : (_useInsecureWEP ? AUTH_WEP : AUTH_WPA_PSK);

if(strlen(ssid) == 32)
memcpy(reinterpret_cast<char*>(conf.ssid), ssid, 32); //copied in without null term
else
strcpy(reinterpret_cast<char*>(conf.ssid), ssid);

conf.threshold.authmode = AUTH_OPEN;
if(passphrase) {
acevest marked this conversation as resolved.
Show resolved Hide resolved
conf.threshold.authmode = _useInsecureWEP ? AUTH_WEP : AUTH_WPA_PSK;
if (strlen(passphrase) == 64) // it's not a passphrase, is the PSK, which is copied into conf.password without null term
if (passphraseLen == 64) // it's not a passphrase, is the PSK, which is copied into conf.password without null term
memcpy(reinterpret_cast<char*>(conf.password), passphrase, 64);
else
strcpy(reinterpret_cast<char*>(conf.password), passphrase);
Expand Down