From 80740117b9ab81aca4bd4864f3824fcedb8767a4 Mon Sep 17 00:00:00 2001 From: Peter Veenstra Date: Thu, 24 May 2018 18:09:21 +0000 Subject: [PATCH] Take length in consideration before moving the echo off upwards. Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4106 --- src/shell/shell.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/shell/shell.cpp b/src/shell/shell.cpp index b802844b..faad912d 100644 --- a/src/shell/shell.cpp +++ b/src/shell/shell.cpp @@ -368,11 +368,13 @@ public: char * extra = const_cast(section->data.c_str()); if (extra && !secure && !control->cmdline->FindExist("-noautoexec",true)) { /* detect if "echo off" is the first line */ + size_t firstline_length = strcspn(extra,"\r\n"); bool echo_off = !strncasecmp(extra,"echo off",8); - if (echo_off) extra += 8; + if (echo_off && firstline_length == 8) extra += 8; else { echo_off = !strncasecmp(extra,"@echo off",9); - if (echo_off) extra += 9; + if (echo_off && firstline_length == 9) extra += 9; + else echo_off = false; } /* if "echo off" move it to the front of autoexec.bat */