From 0085e02a5bc61872b044a871cb8fbb545e02aecc Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Tue, 11 Oct 2022 11:12:54 +0200 Subject: [PATCH] Fix possible buffer overflows with exception --- tasmota/tasmota_xdrv_driver/xdrv_03_energy.ino | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tasmota/tasmota_xdrv_driver/xdrv_03_energy.ino b/tasmota/tasmota_xdrv_driver/xdrv_03_energy.ino index 1eed96c20..4636e6390 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_03_energy.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_03_energy.ino @@ -181,12 +181,12 @@ char* WebEnergyFormat(char* result, float* input, uint32_t resolution, uint32_t } } #ifdef USE_ENERGY_COLUMN_GUI - ext_snprintf_P(result, TOPSZ *2, PSTR("")); // Skip first column + ext_snprintf_P(result, GUISZ, PSTR("")); // Skip first column if ((Energy.phase_count > 1) && single) { // Need to set colspan so need new columns // 1.23  // 1.23  // 1.23  - ext_snprintf_P(result, TOPSZ *2, PSTR("%s%*_f "), + ext_snprintf_P(result, GUISZ, PSTR("%s%*_f "), result, (Energy.phase_count *2) -1, (Settings->flag5.gui_table_align)?PSTR("right"):PSTR("center"), resolution, &input[0]); } else { // 1.23  @@ -194,11 +194,11 @@ char* WebEnergyFormat(char* result, float* input, uint32_t resolution, uint32_t // 1.23 1.23 1.23  // 1.23 1.23 1.23 1.23  for (uint32_t i = 0; i < Energy.phase_count; i++) { - ext_snprintf_P(result, TOPSZ *2, PSTR("%s%*_f "), + ext_snprintf_P(result, GUISZ, PSTR("%s%*_f "), result, (Settings->flag5.gui_table_align)?PSTR("right"):PSTR("left"), resolution, &input[i]); } } - ext_snprintf_P(result, TOPSZ *2, PSTR("%s"), result); + ext_snprintf_P(result, GUISZ, PSTR("%s"), result); #else // not USE_ENERGY_COLUMN_GUI uint32_t index = (single) ? 1 : Energy.phase_count; // 1,2,3 result[0] = '\0'; @@ -1166,9 +1166,9 @@ void EnergyShow(bool json) { energy_tariff = true; } - char value_chr[TOPSZ * 2]; // Used by EnergyFormatIndex - char value2_chr[TOPSZ * 2]; - char value3_chr[TOPSZ * 2]; + char value_chr[GUISZ]; // Used by EnergyFormatIndex + char value2_chr[GUISZ]; + char value3_chr[GUISZ]; if (json) { bool show_energy_period = (0 == TasmotaGlobal.tele_period);