summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Matthews <robert.matthews@hp.com>2013-08-28 14:38:13 +0000
committerjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>2013-08-28 14:38:13 +0000
commited34da4007594b753ae9dffe30d5c32c7c8d98bf (patch)
tree8b2a9ad2e8ea8a113cde1d94f071bff39a25b5e9
parentdb44ea6c4e093c1a53d752bb21b9eba8ad8fdaa9 (diff)
ShellPkg: Fix LastError environment variable truncation
-Fixes LastError environment variable being truncated to 32 bits on 64 bit systems -Fixes possible buffer overrun issue with LastError string value Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Robert Matthews <robert.matthews@hp.com> Reviewed-by: Jaben Carsey <Jaben.carsey@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14608 6f19259b-4bc3-4df7-8a09-765794883524
-rw-r--r--ShellPkg/Application/Shell/Shell.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/ShellPkg/Application/Shell/Shell.c b/ShellPkg/Application/Shell/Shell.c
index 3df55e1a1..3019c7d41 100644
--- a/ShellPkg/Application/Shell/Shell.c
+++ b/ShellPkg/Application/Shell/Shell.c
@@ -2,6 +2,7 @@
This is THE shell (application)
Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2013, Hewlett-Packard Development Company, L.P.
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -1359,7 +1360,7 @@ RunCommand(
UINTN Argc;
CHAR16 **Argv;
BOOLEAN LastError;
- CHAR16 LeString[11];
+ CHAR16 LeString[19];
CHAR16 *PostAliasCmdLine;
UINTN PostAliasSize;
CHAR16 *PostVariableCmdLine;
@@ -1556,7 +1557,7 @@ RunCommand(
if (!EFI_ERROR(Status)) {
Status = ShellCommandRunCommandHandler(ShellInfoObject.NewShellParametersProtocol->Argv[0], &ShellStatus, &LastError);
ASSERT_EFI_ERROR(Status);
- UnicodeSPrint(LeString, sizeof(LeString)*sizeof(LeString[0]), L"0x%08x", ShellStatus);
+ UnicodeSPrint(LeString, sizeof(LeString), L"0x%08Lx", ShellStatus);
DEBUG_CODE(InternalEfiShellSetEnv(L"DebugLasterror", LeString, TRUE););
if (LastError) {
InternalEfiShellSetEnv(L"Lasterror", LeString, TRUE);
@@ -1607,7 +1608,7 @@ RunCommand(
//
// Updatet last error status.
//
- UnicodeSPrint(LeString, sizeof(LeString)*sizeof(LeString[0]), L"0x%08x", StatusCode);
+ UnicodeSPrint(LeString, sizeof(LeString), L"0x%08Lx", StatusCode);
DEBUG_CODE(InternalEfiShellSetEnv(L"DebugLasterror", LeString, TRUE););
InternalEfiShellSetEnv(L"Lasterror", LeString, TRUE);
}
@@ -1909,7 +1910,7 @@ RunScriptFileHandle (
}
if (ShellCommandGetScriptExit()) {
- UnicodeSPrint(LeString, sizeof(LeString)*sizeof(LeString[0]), L"0x%Lx", ShellCommandGetExitCode());
+ UnicodeSPrint(LeString, sizeof(LeString), L"0x%Lx", ShellCommandGetExitCode());
DEBUG_CODE(InternalEfiShellSetEnv(L"DebugLasterror", LeString, TRUE););
InternalEfiShellSetEnv(L"Lasterror", LeString, TRUE);