From f65d8c0cbf72ad6f68502df771fb0c91a6c3185c Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Mon, 24 Sep 2018 11:44:40 +0200 Subject: [PATCH] Fix possible array overflow Fix possible array overflow (#3887 ) --- sonoff/sonoff.ino | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sonoff/sonoff.ino b/sonoff/sonoff.ino index dc1445fc4..91c1fbb9b 100755 --- a/sonoff/sonoff.ino +++ b/sonoff/sonoff.ino @@ -462,10 +462,11 @@ void MqttDataHandler(char* topic, byte* data, unsigned int data_len) grpflg = (strstr(topicBuf, Settings.mqtt_grptopic) != NULL); fallback_topic_flag = (strstr(topicBuf, mqtt_client) != NULL); - type = strrchr(topicBuf, '/') +1; // Last part of received topic is always the command (type) + type = strrchr(topicBuf, '/'); // Last part of received topic is always the command (type) index = 1; if (type != NULL) { + type++; for (i = 0; i < strlen(type); i++) { type[i] = toupper(type[i]); }