check bufferlength, add formatstrings

This commit is contained in:
MichaelDvP
2021-07-14 17:00:14 +02:00
parent 1e61b5670e
commit 65c9bf7e52
3 changed files with 15 additions and 11 deletions

View File

@@ -1475,7 +1475,11 @@ bool Thermostat::set_datetime(const char * value, const int8_t id) {
// sets the thermostat working mode, where mode is a string
// converts string mode to HeatingCircuit::Mode
bool Thermostat::set_mode(const char * value, const int8_t id) {
std::string mode(10, '\0');
std::string mode(20, '\0');
if (strlen(value) >= 20) {
LOG_WARNING(F("Set mode: Invalid mode"));
return false;
}
if (value[0] >= '0' && value[0] <= '9') {
uint8_t num = value[0] - '0';