Skip to content

Commit 1085b24

Browse files
authored
Initialize local variable for AP config
The AP configuration variable wasn't initialized, so the fields contained random data. Then, they were filled using memcpy() with the size of the data to copy, leaving the remainder of the fields containing random data. For example, the pwd variable containing the entered password was copied without null termination into the pwd field, and the rest of the pwd field contained random data. This caused connection failures depending on the content of the random data.
1 parent 428df2a commit 1085b24

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Diff for: libraries/ESPhost/examples/ESP32_TEST/ESP32_TEST.ino

+1-1
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ void connectAccessPoint() {
297297
int i = stoi(ap_str);
298298

299299
Serial.println(">>> [APP]: Connecting to Access Point");
300-
WifiApCfg_t ap;
300+
WifiApCfg_t ap{};
301301
memcpy(ap.ssid,access_point_list[i].ssid,SSID_LENGTH);
302302
memcpy(ap.pwd,pwd.c_str(),pwd.size());
303303
memcpy(ap.bssid,access_point_list[i].bssid,BSSID_LENGTH);

0 commit comments

Comments
 (0)