From 0aac8125ea591e3fc66407f0246282a91c2335a4 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Mon, 15 Feb 2021 18:01:02 +0100 Subject: [PATCH] Add more failsafe to autoexec.bat --- tasmota/xdrv_50_filesystem.ino | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/tasmota/xdrv_50_filesystem.ino b/tasmota/xdrv_50_filesystem.ino index c022e89be..68af9e892 100644 --- a/tasmota/xdrv_50_filesystem.ino +++ b/tasmota/xdrv_50_filesystem.ino @@ -363,16 +363,19 @@ void UfsAutoexec(void) { file.read(buf, 1); if ((buf[0] == '\n') || (buf[0] == '\r')) { // Line terminated with linefeed or carriage return - break; + if (index < sizeof(cmd_line) - 1) { + // Process line + break; + } else { + // Discard too long line and start with next line + index = 0; + } } else if ((0 == index) && isspace(buf[0])) { // Skip leading spaces (' ','\t','\n','\v','\f','\r') - } else { - cmd_line[index] = buf[0]; - index++; - if (index >= sizeof(cmd_line) - 1) { - break; - } + } + else if (index < sizeof(cmd_line) - 2) { + cmd_line[index++] = buf[0]; } } if ((index > 0) && (cmd_line[0] != ';')) { // Information but no comment