From feadd48d1c68ea29eef5d4789371537f67b612fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Sat, 31 Oct 2015 22:59:08 +0000 Subject: [PATCH] [NTVDM]: Correctly compute the command-line length to be communicated to COMMAND.COM for standalone mode. svn path=/trunk/; revision=69767 --- reactos/subsystems/mvdm/ntvdm/dos/dem.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/reactos/subsystems/mvdm/ntvdm/dos/dem.c b/reactos/subsystems/mvdm/ntvdm/dos/dem.c index 0ed51c292ba..0848d456bf6 100644 --- a/reactos/subsystems/mvdm/ntvdm/dos/dem.c +++ b/reactos/subsystems/mvdm/ntvdm/dos/dem.c @@ -378,20 +378,18 @@ Command: #endif + /* Compute the command line length, not counting the terminating "\r\n" */ CmdLen = strlen(CmdLine); - DPRINT1("Starting '%s' ('%.*s')...\n", - AppName, - /* Display the command line without the terminating 0d 0a (and skip the terminating NULL) */ - CmdLen >= 2 ? (CmdLine[CmdLen - 2] == '\r' ? CmdLen - 2 - : CmdLen) - : CmdLen, - CmdLine); + if (CmdLen >= 2 && CmdLine[CmdLen - 2] == '\r') + CmdLen -= 2; + + DPRINT1("Starting '%s' ('%.*s')...\n", AppName, CmdLen, CmdLine); /* Start the process */ // FIXME: Merge 'Env' with the master environment SEG_OFF_TO_PTR(SYSTEM_ENV_BLOCK, 0) // FIXME: Environment RtlCopyMemory(SEG_OFF_TO_PTR(DataStruct->AppNameSeg, DataStruct->AppNameOff), AppName, MAX_PATH); - *(PBYTE)(SEG_OFF_TO_PTR(DataStruct->CmdLineSeg, DataStruct->CmdLineOff)) = (BYTE)(strlen(CmdLine) - 2); + *(PBYTE)(SEG_OFF_TO_PTR(DataStruct->CmdLineSeg, DataStruct->CmdLineOff)) = (BYTE)CmdLen; RtlCopyMemory(SEG_OFF_TO_PTR(DataStruct->CmdLineSeg, DataStruct->CmdLineOff + 1), CmdLine, DOS_CMDLINE_LENGTH); #ifndef STANDALONE