]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPlatformPkg/Bds: Moved the PrintLib() after forcing the last character to be null
authorOlivier Martin <olivier.martin@arm.com>
Wed, 19 Jun 2013 18:00:46 +0000 (18:00 +0000)
committeroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 19 Jun 2013 18:00:46 +0000 (18:00 +0000)
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

ArmPlatformPkg/Bds/BdsHelper.c

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