/** @file\r
*\r
-* Copyright (c) 2011-2012, ARM Limited. All rights reserved.\r
+* Copyright (c) 2011-2013, ARM Limited. All rights reserved.\r
* \r
* This program and the accompanying materials \r
* are licensed and made available under the terms and conditions of the BSD License \r
EFI_INPUT_KEY Key;\r
EFI_STATUS Status;\r
\r
+ // The command line must be at least one character long\r
+ ASSERT (MaxCmdLine > 0);\r
+\r
Print (CmdLine);\r
\r
- for (CmdLineIndex = StrLen (CmdLine); CmdLineIndex < MaxCmdLine; ) {\r
+ // Ensure the last character of the buffer is the NULL character\r
+ CmdLine[MaxCmdLine - 1] = '\0';\r
+\r
+ // To prevent a buffer overflow, we only allow to enter (MaxCmdLine-1) characters\r
+ for (CmdLineIndex = StrLen (CmdLine); CmdLineIndex < MaxCmdLine-1; ) {\r
Status = gBS->WaitForEvent (1, &gST->ConIn->WaitForKey, &WaitIndex);\r
ASSERT_EFI_ERROR (Status);\r
\r