Fix string copy

strncpy only copies the bytes specified, so if you set a name like "PORTAL" and then want to set a name like "HELLO" the result for apName would be "HELLOL".

Instead copy the size of MAX_AP_NAME_SIZE.
This commit is contained in:
Sjoer van der Ploeg
2023-08-21 19:23:03 +02:00
committed by GitHub
parent 9db9c630e4
commit def6d2d277

View File

@@ -203,7 +203,7 @@ bool EvilPortal::setAP(LinkedList<ssid>* ssids, LinkedList<AccessPoint>* access_
}
if (ap_config != "") {
strncpy(apName, ap_config.c_str(), strlen(ap_config.c_str()));
strncpy(apName, ap_config.c_str(), MAX_AP_NAME_SIZE);
this->has_ap = true;
Serial.println("ap config set");
return true;
@@ -304,4 +304,4 @@ void EvilPortal::main(uint8_t scan_mode) {
#endif
}
}
}
}