diff --git a/README.md b/README.md index e00731177..eddbb9413 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ ## Sonoff-Tasmota Provide ESP8266 based Sonoff by [iTead Studio](https://www.itead.cc/) and ElectroDragon IoT Relay with Serial, Web and MQTT control allowing 'Over the Air' or OTA firmware updates using Arduino IDE. -Current version is **5.6.1k** - See [sonoff/_releasenotes.ino](https://github.com/arendst/Sonoff-Tasmota/blob/development/sonoff/_releasenotes.ino) for change information. +Current version is **5.6.1l** - See [sonoff/_releasenotes.ino](https://github.com/arendst/Sonoff-Tasmota/blob/development/sonoff/_releasenotes.ino) for change information. ### ATTENTION All versions diff --git a/sonoff/_releasenotes.ino b/sonoff/_releasenotes.ino index 57183d6f0..27dad4200 100644 --- a/sonoff/_releasenotes.ino +++ b/sonoff/_releasenotes.ino @@ -1,4 +1,9 @@ -/* 5.6.1k +/* 5.6.1l + * Fix some string length issues + * Add more string length tests by using strncpy + * Tried to fix Exception 3 as I can't reproduce (#830) + * + * 5.6.1k * Fix preprocessor language selection * * 5.6.1j diff --git a/sonoff/sonoff.ino b/sonoff/sonoff.ino index 0a311ea37..a3245227f 100644 --- a/sonoff/sonoff.ino +++ b/sonoff/sonoff.ino @@ -25,7 +25,7 @@ - Select IDE Tools - Flash Size: "1M (no SPIFFS)" ====================================================*/ -#define VERSION 0x0506010B // 5.6.1k +#define VERSION 0x0506010C // 5.6.1l enum log_t {LOG_LEVEL_NONE, LOG_LEVEL_ERROR, LOG_LEVEL_INFO, LOG_LEVEL_DEBUG, LOG_LEVEL_DEBUG_MORE, LOG_LEVEL_ALL}; enum week_t {Last, First, Second, Third, Fourth}; @@ -544,7 +544,7 @@ void mqtt_publishPowerBlinkState(byte device) void mqtt_connected() { char stopic[TOPSZ]; - char svalue[128]; // was MESSZ + char svalue[164]; // was MESSZ if (sysCfg.flag.mqtt_enabled) { diff --git a/sonoff/support.ino b/sonoff/support.ino index 44cbaf0ce..dd15ccea4 100644 --- a/sonoff/support.ino +++ b/sonoff/support.ino @@ -69,7 +69,7 @@ String getResetReason() { char buff[32]; if (osw_flag) { - strcpy_P(buff, PSTR(D_BLOCKED_LOOP)); + strncpy_P(buff, PSTR(D_BLOCKED_LOOP), sizeof(buff)); return String(buff); } else { return ESP.getResetReason(); @@ -151,11 +151,11 @@ char* _dtostrf(double number, unsigned char prec, char *s, bool i18n) bool negative = false; if (isnan(number)) { - strcpy(s, "nan"); + strcpy_P(s, PSTR("nan")); return s; } if (isinf(number)) { - strcpy(s, "inf"); + strcpy_P(s, PSTR("inf")); return s; } char decimal = '.'; diff --git a/sonoff/webserver.ino b/sonoff/webserver.ino index c12da3973..b1a65feb0 100644 --- a/sonoff/webserver.ino +++ b/sonoff/webserver.ino @@ -433,7 +433,7 @@ void handleRoot() } else { char stemp[10], line[160]; String page = FPSTR(HTTP_HEAD); - page.replace(F("{v}"), S_MAIN_MENU); + page.replace(F("{v}"), FPSTR(S_MAIN_MENU)); page.replace(F(""), F("")); page += F("
"); @@ -592,7 +592,7 @@ void handleConfig() addLog_P(LOG_LEVEL_DEBUG, S_LOG_HTTP, S_CONFIGURATION); String page = FPSTR(HTTP_HEAD); - page.replace(F("{v}"), S_CONFIGURATION); + page.replace(F("{v}"), FPSTR(S_CONFIGURATION)); page += FPSTR(HTTP_BTN_MENU2); if (sysCfg.flag.mqtt_enabled) { page += FPSTR(HTTP_BTN_MENU3); @@ -656,7 +656,7 @@ void handleModule() addLog_P(LOG_LEVEL_DEBUG, S_LOG_HTTP, S_CONFIGURE_MODULE); String page = FPSTR(HTTP_HEAD); - page.replace(F("{v}"), S_CONFIGURE_MODULE); + page.replace(F("{v}"), FPSTR(S_CONFIGURE_MODULE)); page += FPSTR(HTTP_FORM_MODULE); snprintf_P(stemp, sizeof(stemp), modules[MODULE].name); page.replace(F("{mt}"), stemp); @@ -720,7 +720,7 @@ void handleWifi(boolean scan) addLog_P(LOG_LEVEL_DEBUG, S_LOG_HTTP, S_CONFIGURE_WIFI); String page = FPSTR(HTTP_HEAD); - page.replace(F("{v}"), S_CONFIGURE_WIFI); + page.replace(F("{v}"), FPSTR(S_CONFIGURE_WIFI)); if (scan) { #ifdef USE_EMULATION @@ -731,7 +731,7 @@ void handleWifi(boolean scan) if (0 == n) { addLog_P(LOG_LEVEL_DEBUG, S_LOG_WIFI, S_NO_NETWORKS_FOUND); - page += S_NO_NETWORKS_FOUND; + page += FPSTR(S_NO_NETWORKS_FOUND); page += F(". " D_REFRESH_TO_SCAN_AGAIN "."); } else { //sort networks @@ -820,7 +820,7 @@ void handleMqtt() addLog_P(LOG_LEVEL_DEBUG, S_LOG_HTTP, S_CONFIGURE_MQTT); String page = FPSTR(HTTP_HEAD); - page.replace(F("{v}"), S_CONFIGURE_MQTT); + page.replace(F("{v}"), FPSTR(S_CONFIGURE_MQTT)); page += FPSTR(HTTP_FORM_MQTT); char str[sizeof(sysCfg.mqtt_client)]; getClient(str, MQTT_CLIENT_ID, sizeof(sysCfg.mqtt_client)); @@ -845,7 +845,7 @@ void handleLog() addLog_P(LOG_LEVEL_DEBUG, S_LOG_HTTP, S_CONFIGURE_LOGGING); String page = FPSTR(HTTP_HEAD); - page.replace(F("{v}"), S_CONFIGURE_LOGGING); + page.replace(F("{v}"), FPSTR(S_CONFIGURE_LOGGING)); page += FPSTR(HTTP_FORM_LOG1); for (byte idx = 0; idx < 3; idx++) { page += FPSTR(HTTP_FORM_LOG2); @@ -894,7 +894,7 @@ void handleOther() char stemp[40]; String page = FPSTR(HTTP_HEAD); - page.replace(F("{v}"), S_CONFIGURE_OTHER); + page.replace(F("{v}"), FPSTR(S_CONFIGURE_OTHER)); page += FPSTR(HTTP_FORM_OTHER); page.replace(F("{p1}"), sysCfg.web_password); page.replace(F("{r1}"), (sysCfg.flag.mqtt_enabled) ? F(" checked") : F("")); @@ -1064,7 +1064,7 @@ void handleSave() restart = (!strlen(webServer->arg("r").c_str())) ? 1 : atoi(webServer->arg("r").c_str()); if (restart) { String page = FPSTR(HTTP_HEAD); - page.replace(F("{v}"), S_SAVE_CONFIGURATION); + page.replace(F("{v}"), FPSTR(S_SAVE_CONFIGURATION)); page += F("
" D_CONFIGURATION_SAVED "
"); page += result; page += F("
"); @@ -1093,7 +1093,7 @@ void handleReset() addLog_P(LOG_LEVEL_DEBUG, S_LOG_HTTP, S_RESET_CONFIGURATION); String page = FPSTR(HTTP_HEAD); - page.replace(F("{v}"), S_RESET_CONFIGURATION); + page.replace(F("{v}"), FPSTR(S_RESET_CONFIGURATION)); page += F("
" D_CONFIGURATION_RESET "
"); page += FPSTR(HTTP_MSG_RSTRT); page += FPSTR(HTTP_BTN_MAIN); @@ -1111,7 +1111,7 @@ void handleRestore() addLog_P(LOG_LEVEL_DEBUG, S_LOG_HTTP, S_RESTORE_CONFIGURATION); String page = FPSTR(HTTP_HEAD); - page.replace(F("{v}"), S_RESTORE_CONFIGURATION); + page.replace(F("{v}"), FPSTR(S_RESTORE_CONFIGURATION)); page += FPSTR(HTTP_FORM_RST); page += FPSTR(HTTP_FORM_RST_UPG); page.replace(F("{r1}"), F(D_RESTORE)); @@ -1130,7 +1130,7 @@ void handleUpgrade() addLog_P(LOG_LEVEL_DEBUG, S_LOG_HTTP, S_FIRMWARE_UPGRADE); String page = FPSTR(HTTP_HEAD); - page.replace(F("{v}"), S_FIRMWARE_UPGRADE); + page.replace(F("{v}"), FPSTR(S_FIRMWARE_UPGRADE)); page += FPSTR(HTTP_FORM_UPG); page.replace(F("{o1}"), sysCfg.otaUrl); page += FPSTR(HTTP_FORM_RST_UPG); @@ -1158,7 +1158,7 @@ void handleUpgradeStart() } String page = FPSTR(HTTP_HEAD); - page.replace(F("{v}"), S_INFORMATION); + page.replace(F("{v}"), FPSTR(S_INFORMATION)); page += F("
" D_UPGRADE_STARTED " ...
"); page += FPSTR(HTTP_MSG_RSTRT); page += FPSTR(HTTP_BTN_MAIN); @@ -1183,20 +1183,20 @@ void handleUploadDone() mqttcounter = 0; String page = FPSTR(HTTP_HEAD); - page.replace(F("{v}"), S_INFORMATION); + page.replace(F("{v}"), FPSTR(S_INFORMATION)); page += F("
" D_UPLOAD " " D_FAILED "

"); switch (_uploaderror) { - case 1: strcpy_P(error, PSTR(D_UPLOAD_ERR_1)); break; - case 2: strcpy_P(error, PSTR(D_UPLOAD_ERR_2)); break; - case 3: strcpy_P(error, PSTR(D_UPLOAD_ERR_3)); break; - case 4: strcpy_P(error, PSTR(D_UPLOAD_ERR_4)); break; - case 5: strcpy_P(error, PSTR(D_UPLOAD_ERR_5)); break; - case 6: strcpy_P(error, PSTR(D_UPLOAD_ERR_6)); break; - case 7: strcpy_P(error, PSTR(D_UPLOAD_ERR_7)); break; - case 8: strcpy_P(error, PSTR(D_UPLOAD_ERR_8)); break; - case 9: strcpy_P(error, PSTR(D_UPLOAD_ERR_9)); break; + case 1: strncpy_P(error, PSTR(D_UPLOAD_ERR_1), sizeof(error)); break; + case 2: strncpy_P(error, PSTR(D_UPLOAD_ERR_2), sizeof(error)); break; + case 3: strncpy_P(error, PSTR(D_UPLOAD_ERR_3), sizeof(error)); break; + case 4: strncpy_P(error, PSTR(D_UPLOAD_ERR_4), sizeof(error)); break; + case 5: strncpy_P(error, PSTR(D_UPLOAD_ERR_5), sizeof(error)); break; + case 6: strncpy_P(error, PSTR(D_UPLOAD_ERR_6), sizeof(error)); break; + case 7: strncpy_P(error, PSTR(D_UPLOAD_ERR_7), sizeof(error)); break; + case 8: strncpy_P(error, PSTR(D_UPLOAD_ERR_8), sizeof(error)); break; + case 9: strncpy_P(error, PSTR(D_UPLOAD_ERR_9), sizeof(error)); break; default: snprintf_P(error, sizeof(error), PSTR(D_UPLOAD_ERROR_CODE " %d"), _uploaderror); } @@ -1400,7 +1400,7 @@ void handleConsole() addLog_P(LOG_LEVEL_DEBUG, S_LOG_HTTP, S_CONSOLE); String page = FPSTR(HTTP_HEAD); - page.replace(F("{v}"), S_CONSOLE); + page.replace(F("{v}"), FPSTR(S_CONSOLE)); page.replace(F(""), FPSTR(HTTP_SCRIPT_CONSOL)); page.replace(F(""), F("")); page += FPSTR(HTTP_FORM_CMND); @@ -1477,7 +1477,7 @@ void handleInfo() int freeMem = ESP.getFreeHeap(); String page = FPSTR(HTTP_HEAD); - page.replace(F("{v}"), S_INFORMATION); + page.replace(F("{v}"), FPSTR(S_INFORMATION)); // page += F("
 Information "); page += F(""); page += F(""); @@ -1578,7 +1578,7 @@ void handleRestart() addLog_P(LOG_LEVEL_DEBUG, S_LOG_HTTP, S_RESTART); String page = FPSTR(HTTP_HEAD); - page.replace(F("{v}"), S_RESTART); + page.replace(F("{v}"), FPSTR(S_RESTART)); page += FPSTR(HTTP_MSG_RSTRT); if (HTTP_MANAGER == _httpflag) { _httpflag = HTTP_ADMIN; diff --git a/sonoff/xdrv_domoticz.ino b/sonoff/xdrv_domoticz.ino index 6ea9e6a46..5c3d18e2b 100644 --- a/sonoff/xdrv_domoticz.ino +++ b/sonoff/xdrv_domoticz.ino @@ -341,7 +341,7 @@ void handleDomoticz() char stemp[20]; String page = FPSTR(HTTP_HEAD); - page.replace("{v}", S_CONFIGURE_DOMOTICZ); + page.replace(F("{v}"), FPSTR(S_CONFIGURE_DOMOTICZ)); page += FPSTR(HTTP_FORM_DOMOTICZ); for (int i = 0; i < 4; i++) { if (i < Maxdevice) { diff --git a/sonoff/xdrv_snfbridge.ino b/sonoff/xdrv_snfbridge.ino index c69765423..dc6232d19 100644 --- a/sonoff/xdrv_snfbridge.ino +++ b/sonoff/xdrv_snfbridge.ino @@ -77,7 +77,7 @@ void sb_received() if (!((rid == sfb_lastrid) && (now - sfb_lasttime < SFB_TIME_AVOID_DUPLICATE))) { sfb_lastrid = rid; sfb_lasttime = now; - strcpy_P(rfkey, PSTR("\"" D_NONE "\"")); + strncpy_P(rfkey, PSTR("\"" D_NONE "\""), sizeof(rfkey)); for (i = 1; i <= 16; i++) { if (sysCfg.sfb_code[i][0]) { sid = sysCfg.sfb_code[i][6] << 16 | sysCfg.sfb_code[i][7] << 8 | sysCfg.sfb_code[i][8]; diff --git a/sonoff/xsns_bh1750.ino b/sonoff/xsns_bh1750.ino index cfce0fc3f..ded769ef4 100644 --- a/sonoff/xsns_bh1750.ino +++ b/sonoff/xsns_bh1750.ino @@ -64,7 +64,7 @@ boolean bh1750_detect() if (!status) { success = true; bh1750type = 1; - strcpy(bh1750stype, "BH1750"); + strcpy_P(bh1750stype, PSTR("BH1750")); } if (success) { snprintf_P(log, sizeof(log), PSTR(D_LOG_I2C "%s " D_FOUND_AT " 0x%x"), bh1750stype, bh1750addr);