From 5e8c1669febf9b5d6a501d8982fb48e3d4b8946f Mon Sep 17 00:00:00 2001 From: Xottab-DUTY Date: Mon, 12 Feb 2024 22:54:55 +0500 Subject: [PATCH] Improve robustness of "-$" command line key when it's used incorrectly (#1582) --- src/xrGame/Level_start.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/xrGame/Level_start.cpp b/src/xrGame/Level_start.cpp index 4336437b26e..986554d4755 100644 --- a/src/xrGame/Level_start.cpp +++ b/src/xrGame/Level_start.cpp @@ -248,10 +248,17 @@ bool CLevel::net_start6() { if (strstr(Core.Params, "-$")) { - string256 buf, cmd, param; - sscanf(strstr(Core.Params, "-$") + 2, "%[^ ] %[^ ] ", cmd, param); - strconcat(sizeof(buf), buf, cmd, " ", param); - Console->Execute(buf); + string256 buf{}, cmd{}, param{}; + const int result = sscanf(strstr(Core.Params, "-$") + 2, "%[^ ] %[^ ] ", cmd, param); + if (result == 2) + { + strconcat(buf, cmd, " ", param); + Console->Execute(buf); + } + else + { + Log("! The key '-$' is not being used correctly. Correct format: -$ "); + } } } else