param was using user length for strncpy, causing overflows

This commit is contained in:
tablatronix
2018-07-13 23:43:07 -05:00
parent abbc110656
commit 933f86720a
+6 -1
View File
@@ -63,12 +63,17 @@ WiFiManagerParameter::~WiFiManagerParameter() {
void WiFiManagerParameter::setValue(const char *defaultValue, int length) {
_length = length;
length = strlen(defaultValue); // length actual
if(_length < length){
// Serial.println("defaultValue length mismatch");
}
_value = new char[length + 1];
for (int i = 0; i < length + 1; i++) {
_value[i] = 0;
}
if (defaultValue != NULL) {
strncpy(_value, defaultValue, length + 1); // length+1 due to null terminated string
strncpy(_value, defaultValue, length);
_value[length] = '\0'; // explicit null
}
}
const char* WiFiManagerParameter::getValue() {