maxlength null string fix

pr#244
This commit is contained in:
Shawn A
2017-08-30 09:15:36 -05:00
parent 04a9dda74b
commit 9160b5bd3b
2 changed files with 5 additions and 6 deletions
+4 -5
View File
@@ -41,7 +41,7 @@ void WiFiManagerParameter::init(const char *id, const char *placeholder, const c
_value[i] = 0;
}
if (defaultValue != NULL) {
strncpy(_value, defaultValue, length);
strncpy(_value, defaultValue, length+1); // length+1 due to null terminated string
}
_customHTML = custom;
@@ -84,7 +84,7 @@ void WiFiManager::addParameter(WiFiManagerParameter *p) {
// constructor
WiFiManager::WiFiManager() {
_usermode = WiFi.getMode();
WiFi.persistent(false); // disable persistent so scannetworks and mode switching is not saved
WiFi.persistent(false); // disable persistent so scannetworks and mode switching do not cause overwrites
}
// destructor
@@ -309,6 +309,7 @@ boolean WiFiManager::stopConfigPortal(){
bool ret = WiFi.softAPdisconnect(false);
if(!ret)DEBUG_WM(F("disconnect configportal - softAPdisconnect failed"));
wifimode(WIFI_STA); // set back to sta, @todo use preservation variable
WiFi.mode(_usermode);
configPortalActive = false;
return ret;
}
@@ -575,7 +576,7 @@ void WiFiManager::handleWifi(boolean scan) {
page += item;
delay(0);
} else {
DEBUG_WM(F("Skipping due to quality"));
DEBUG_WM(F("Skipping , does not meet _minimumQuality"));
}
}
@@ -659,13 +660,11 @@ void WiFiManager::handleWifi(boolean scan) {
page += FPSTR(HTTP_FORM_END);
page += FPSTR(HTTP_SCAN_LINK);
page += FPSTR(HTTP_END);
server->sendHeader("Content-Length", String(page.length()));
server->send(200, "text/html", page);
DEBUG_WM(F("Sent config page"));
}