From fea4173b437976e2e7c30eca94fa7b806937455c Mon Sep 17 00:00:00 2001 From: tomcw Date: Mon, 1 Jan 2024 11:11:51 +0000 Subject: [PATCH] Debugger: CmdOutputRun: . for scripts that can be loaded: output script pathname to console. . for scripts that can't be loaded: don't truncate pathname that's output to console. --- source/Debugger/Debug.cpp | 16 +++++++++------- source/Debugger/Debugger_Symbols.cpp | 1 - 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/source/Debugger/Debug.cpp b/source/Debugger/Debug.cpp index 1c80a1f4..9850a6d0 100644 --- a/source/Debugger/Debug.cpp +++ b/source/Debugger/Debug.cpp @@ -6408,6 +6408,9 @@ Update_t CmdOutputRun (int nArgs) { g_bScriptReadOk = true; + ConsolePrintFormat("%sRun script: ", CHC_INFO); + ConsolePrintFormat("%s%s", CHC_PATH, sFileName.c_str()); // Output pathname to console to indicate the script has been read + int nLine = script.GetNumLines(); Update_t bUpdateDisplay = UPDATE_NOTHING; @@ -6421,9 +6424,8 @@ Update_t CmdOutputRun (int nArgs) } else { - std::string sMiniFileName = sFileName.substr(0, MIN(sFileName.size(), CONSOLE_WIDTH)); - ConsolePrintFormat("%sCouldn't load filename:", CHC_ERROR); - ConsolePrintFormat("%s%s", CHC_STRING, sMiniFileName.c_str()); + ConsolePrintFormat("%sCouldn't load script:", CHC_WARNING); + ConsolePrintFormat("%s%s", CHC_STRING, sFileName.c_str()); } return ConsoleUpdate(); @@ -9011,28 +9013,28 @@ void DebugInitialize () // Look in g_sCurrentDir, otherwise try g_sProgramDir std::string pathname = g_sCurrentDir + debuggerAutoRunName; - if (pathname.size() >= MAX_PATH) + errno_t error = strncpy_s(g_aArgs[1].sArg, MAX_PATH, pathname.c_str(), pathname.size()); + if (error != 0) { ConsolePrintFormat("%sPathname too long:", CHC_ERROR); ConsolePrintFormat("%s%s", CHC_STRING, pathname.c_str()); } else { - strncpy_s(g_aArgs[1].sArg, MAX_PATH, pathname.c_str(), _TRUNCATE); CmdOutputRun(1); } if (!g_bScriptReadOk) { pathname = g_sProgramDir + debuggerAutoRunName; - if (pathname.size() >= MAX_PATH) + error = strncpy_s(g_aArgs[1].sArg, MAX_PATH, pathname.c_str(), pathname.size()); + if (error != 0) { ConsolePrintFormat("%sPathname too long:", CHC_ERROR); ConsolePrintFormat("%s%s", CHC_STRING, pathname.c_str()); } else { - strncpy_s(g_aArgs[1].sArg, MAX_PATH, pathname.c_str(), _TRUNCATE); CmdOutputRun(1); } } diff --git a/source/Debugger/Debugger_Symbols.cpp b/source/Debugger/Debugger_Symbols.cpp index eef15680..7e380b10 100644 --- a/source/Debugger/Debugger_Symbols.cpp +++ b/source/Debugger/Debugger_Symbols.cpp @@ -646,7 +646,6 @@ int ParseSymbolTable(const std::string & pPathFileName, SymbolTable_Index_e eSym { bFileDisplayed = true; - // TODO: Must check for buffer overflow ! ConsolePrintFormat( "%s%s" , CHC_PATH , pPathFileName.c_str()