diff --git a/ArmPlatformPkg/Bds/BdsHelper.c b/ArmPlatformPkg/Bds/BdsHelper.c index fa3026c8ff..9747b3fbd3 100644 --- a/ArmPlatformPkg/Bds/BdsHelper.c +++ b/ArmPlatformPkg/Bds/BdsHelper.c @@ -29,13 +29,13 @@ EditHIInputStr ( // The command line must be at least one character long ASSERT (MaxCmdLine > 0); - Print (CmdLine); - // Ensure the last character of the buffer is the NULL character CmdLine[MaxCmdLine - 1] = '\0'; + Print (CmdLine); + // To prevent a buffer overflow, we only allow to enter (MaxCmdLine-1) characters - for (CmdLineIndex = StrLen (CmdLine); CmdLineIndex < MaxCmdLine-1; ) { + for (CmdLineIndex = StrLen (CmdLine); CmdLineIndex < MaxCmdLine - 1; ) { Status = gBS->WaitForEvent (1, &gST->ConIn->WaitForKey, &WaitIndex); ASSERT_EFI_ERROR (Status);