ArmPlatformPkg/Bds: Moved the PrintLib() after forcing the last character to be null

That should prevent the risk of buffer overflow.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Olivier Martin <olivier.martin@arm.com>


git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14430 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
Olivier Martin 2013-06-19 18:00:46 +00:00 committed by oliviermartin
parent 9d94fa2da2
commit 4076165359
1 changed files with 3 additions and 3 deletions

View File

@ -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);