Revision: 14608
          http://sourceforge.net/p/edk2/code/14608
Author:   jcarsey
Date:     2013-08-28 14:38:13 +0000 (Wed, 28 Aug 2013)
Log Message:
-----------
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 <[email protected]>
Reviewed-by: Jaben Carsey <[email protected]>

Modified Paths:
--------------
    trunk/edk2/ShellPkg/Application/Shell/Shell.c

Modified: trunk/edk2/ShellPkg/Application/Shell/Shell.c
===================================================================
--- trunk/edk2/ShellPkg/Application/Shell/Shell.c       2013-08-28 09:06:40 UTC 
(rev 14607)
+++ trunk/edk2/ShellPkg/Application/Shell/Shell.c       2013-08-28 14:38:13 UTC 
(rev 14608)
@@ -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 @@
   UINTN                     Argc;
   CHAR16                    **Argv;
   BOOLEAN                   LastError;
-  CHAR16                    LeString[11];
+  CHAR16                    LeString[19];
   CHAR16                    *PostAliasCmdLine;
   UINTN                     PostAliasSize;
   CHAR16                    *PostVariableCmdLine;
@@ -1556,7 +1557,7 @@
         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 @@
             //
             // 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 @@
         }
 
         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);
 

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58040911&iu=/4140/ostg.clktrk
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to