Skip to content

Fixed SSID length limit to 32 bytes #4691

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
7 changes: 5 additions & 2 deletions libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ wl_status_t ESP8266WiFiSTAClass::begin(const char* ssid, const char *passphrase,
return WL_CONNECT_FAILED;
}

if(!ssid || *ssid == 0x00 || strlen(ssid) > 31) {
if(!ssid || *ssid == 0x00 || strlen(ssid) > 32) {
// fail SSID too long or missing!
return WL_CONNECT_FAILED;
}
Expand Down Expand Up @@ -519,7 +519,10 @@ wl_status_t ESP8266WiFiSTAClass::status() {
String ESP8266WiFiSTAClass::SSID() const {
struct station_config conf;
wifi_station_get_config(&conf);
return String(reinterpret_cast<char*>(conf.ssid));
char tmp[33]; //SSID is 32 chars plus null term
memcpy(tmp, conf.ssid, sizeof(conf.ssid));
tmp[32] = 0; //null term in case of 32 byte ssid
return String(reinterpret_cast<char*>(tmp));
}

/**
Expand Down
5 changes: 4 additions & 1 deletion libraries/ESP8266WiFi/src/ESP8266WiFiScan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,10 @@ String ESP8266WiFiScanClass::SSID(uint8_t i) {
return "";
}

return String(reinterpret_cast<const char*>(it->ssid));
char tmp[33]; //SSID is 32 byte plus null term
memcpy(tmp, it->ssid, sizeof(it->ssid));
tmp[32] = 0; //null term in case of 32 byte ssid
return String(reinterpret_cast<char*>(tmp));
}


Expand Down