diff options
author | Olivier Martin <olivier.martin@arm.com> | 2013-06-19 18:00:46 +0000 |
---|---|---|
committer | oliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524> | 2013-06-19 18:00:46 +0000 |
commit | 40761653599e4be2c4fa38cd002033e3458786e4 (patch) | |
tree | 494b7175fc690bd75f2ffd7513f8d1a8fe3d3243 /ArmPlatformPkg | |
parent | 9d94fa2da2ee112cf3f4d5b0afc70dc915a72195 (diff) | |
download | edk2-platforms-40761653599e4be2c4fa38cd002033e3458786e4.tar.xz |
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
Diffstat (limited to 'ArmPlatformPkg')
-rw-r--r-- | ArmPlatformPkg/Bds/BdsHelper.c | 6 |
1 files changed, 3 insertions, 3 deletions
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);
|