Fix possible buffer overwrites

This commit is contained in:
Theo Arends 2020-10-10 15:42:27 +02:00
parent b8e55203b6
commit 81cd344beb
2 changed files with 3 additions and 2 deletions

View File

@ -206,7 +206,9 @@ bool DomoticzMqttData(void) {
if (XdrvMailbox.data_len < 20) {
return true; // No valid data
}
JsonParser parser(XdrvMailbox.data);
String domoticz_data = XdrvMailbox.data; // Copy the string into a new buffer that will be modified
JsonParser parser((char*)domoticz_data.c_str());
JsonParserObject domoticz = parser.getRootObject();
if (!domoticz) {
return true; // To much or invalid data

View File

@ -1166,7 +1166,6 @@ void DisplayAnalyzeJson(char *topic, char *json)
// tele/th1/SENSOR {"Time":"2017-09-20T11:54:48","DS18B20":{"Temperature":49.7},"TempUnit":"C"}
String jsonStr = json; // Move from stack to heap to fix watchdogs (20180626)
JsonParser parser((char*)jsonStr.c_str());
JsonParserObject root = parser.getRootObject();
if (root) { // did JSON parsing went ok?