]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Add more check to make sure code run safely.
authorlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 11 Jun 2010 07:47:06 +0000 (07:47 +0000)
committerlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 11 Jun 2010 07:47:06 +0000 (07:47 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10574 6f19259b-4bc3-4df7-8a09-765794883524

25 files changed:
EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/Debug.c
EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/Perf.c
EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Graphics.c
EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Print.c
EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Unicode/Sprint.c
EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Graphics.c
EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Print.c
EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Unicode/Sprint.c
EdkCompatibilityPkg/Foundation/Library/Dxe/Hob/Hob.c
EdkCompatibilityPkg/Foundation/Library/Dxe/Print/Unicode/SPrint.c
EdkCompatibilityPkg/Foundation/Library/Dxe/PrintLite/Unicode/SPrint.c
EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrCommon.c
EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrString.c
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/BasePeCoff.c
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.c
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxePerformanceLib/PerformanceLib.c
EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/HiiLib/HiiLib.c
EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Decompress.c
EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/PeCoffLoader.c
EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Debug.c
EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ipf/RuntimeLib.c
EdkCompatibilityPkg/Sample/Platform/Generic/MonoStatusCode/Library/Pei/MemoryStatusCode/MemoryStatusCode.c
EdkCompatibilityPkg/Sample/Platform/Generic/RuntimeDxe/StatusCode/Lib/BsSerialStatusCode/BsSerialStatusCode.c
EdkCompatibilityPkg/Sample/Platform/Generic/RuntimeDxe/StatusCode/Lib/RtMemoryStatusCode/RtMemoryStatusCode.c
EdkCompatibilityPkg/Sample/Platform/Generic/RuntimeDxe/StatusCode/Lib/RtPlatformStatusCode/Nt32/RtPlatformStatusCode.c

index 1c7f7b9cc7bd509e920247c0ecf46e8229167ed9..3c43451d09ac73cd9a1f621da9bf048bb4931aa5 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004 - 2006, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
@@ -75,7 +75,7 @@ Returns:
     );\r
 \r
   //\r
-  // Put break point in module that contained the error.\r
+  // Put dead loop in module that contained the error.\r
   //\r
   EFI_DEADLOOP ();\r
 }\r
index 497c0cf4959986867d9788e848126a516703dd8c..96f11bb44d76e32280610a7ac5ca11298fc48f5c 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004 - 2005, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
@@ -825,6 +825,11 @@ Returns:
     return EFI_OUT_OF_RESOURCES;\r
   }\r
 \r
+  //\r
+  // Initialize 'LogHob' to NULL before usage.\r
+  //\r
+  LogHob = NULL;\r
+\r
   if (Ticker != 0) {\r
     TimerValue = Ticker;\r
   } else {\r
@@ -837,7 +842,10 @@ Returns:
   EfiLibGetSystemConfigurationTable (&gEfiHobListGuid, &HobList);\r
   do {\r
     Status = GetNextGuidHob (&HobList, &gEfiPeiPerformanceHobGuid, (VOID **) &LogHob, NULL);\r
-    if (EFI_ERROR (Status)) {\r
+    if (EFI_ERROR (Status) || (LogHob == NULL)) {\r
+      //\r
+      // Failed to get HOB for ProtocolGuid.\r
+      //\r
       break;\r
     }\r
 \r
index e913d592e2880abcaa3095c8651042916a8d56b7..6a8183e13185a16c10e5c3dae521cc7d604117c1 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004 - 2009, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
@@ -436,11 +436,13 @@ Returns:
   if (GraphicsOutput != NULL) {\r
     SizeOfX = GraphicsOutput->Mode->Info->HorizontalResolution;\r
     SizeOfY = GraphicsOutput->Mode->Info->VerticalResolution;\r
-  } else {\r
+  } else if (UgaDraw != NULL) {\r
     Status = UgaDraw->GetMode (UgaDraw, &SizeOfX, &SizeOfY, &ColorDepth, &RefreshRate);\r
     if (EFI_ERROR (Status)) {\r
       return EFI_UNSUPPORTED;\r
     }\r
+  } else {\r
+    return EFI_UNSUPPORTED;\r
   }\r
 \r
   Instance = 0;\r
index 316fe71e23f2349cd2d85d3dc2983d294b2c2c80..03b66623c94132a3ea602b52e645b1dfebe1024c 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
@@ -158,8 +158,7 @@ Arguments:
 \r
 Returns: \r
 \r
-  EFI_SUCCESS             -  success\r
-  EFI_OUT_OF_RESOURCES    -  out of resources\r
+  Length of string printed to the console\r
 \r
 --*/\r
 {\r
@@ -191,7 +190,7 @@ Returns:
   //\r
   Buffer = EfiLibAllocateZeroPool (0x10000);\r
   if (Buffer == NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
+    return 0;\r
   }\r
 \r
   if (GraphicsOutput != NULL) {\r
@@ -371,10 +370,15 @@ Error:
   EfiLibSafeFreePool (Blt);\r
   EfiLibSafeFreePool (FontInfo);\r
 #else\r
-  gBS->FreePool (LineBuffer);\r
+  EfiLibSafeFreePool (LineBuffer);\r
 #endif  \r
   gBS->FreePool (Buffer);\r
-  return Status;\r
+  \r
+  if (EFI_ERROR (Status)) {\r
+    return 0;\r
+  }\r
+\r
+  return BufferLen;\r
 }\r
 \r
 \r
@@ -440,19 +444,20 @@ Returns:
                     (VOID**)&UgaDraw\r
                     );\r
 \r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
+    if (EFI_ERROR (Status) || (UgaDraw == NULL)) {\r
+      return 0;\r
     }\r
   }\r
 \r
+  Sto = NULL;\r
   Status = gBS->HandleProtocol (\r
                   Handle,\r
                   &gEfiSimpleTextOutProtocolGuid,\r
                   (VOID**)&Sto\r
                   );\r
 \r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
+  if (EFI_ERROR (Status) || (Sto == NULL)) {\r
+    return 0;\r
   }\r
 \r
   return _IPrint (GraphicsOutput, UgaDraw, Sto, X, Y, ForeGround, BackGround, Fmt, Args);\r
index 3eb6c85b8aa11caa299adedbd35c907ba2e36761..de99ee07ea3b36202747c94c3aaad807ed426d02 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
@@ -123,8 +123,8 @@ Returns:
 --*/\r
 {\r
   UINTN   Index;\r
-  CHAR16  UnicodeFormat[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];\r
-  CHAR16  UnicodeResult[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];\r
+  CHAR16  UnicodeFormat[EFI_DRIVER_LIB_MAX_PRINT_BUFFER+1];\r
+  CHAR16  UnicodeResult[EFI_DRIVER_LIB_MAX_PRINT_BUFFER+1];\r
 \r
   for (Index = 0; Index < EFI_DRIVER_LIB_MAX_PRINT_BUFFER && FormatString[Index] != '\0'; Index++) {\r
     UnicodeFormat[Index] = (CHAR16) FormatString[Index];\r
@@ -132,7 +132,7 @@ Returns:
 \r
   UnicodeFormat[Index]  = '\0';\r
 \r
-  Index                 = VSPrint (UnicodeResult, EFI_DRIVER_LIB_MAX_PRINT_BUFFER, UnicodeFormat, Marker);\r
+  Index                 = VSPrint (UnicodeResult, sizeof (UnicodeResult), UnicodeFormat, Marker);\r
 \r
   for (Index = 0; (Index < (BufferSize - 1)) && UnicodeResult[Index] != '\0'; Index++) {\r
     Buffer[Index] = (CHAR8) UnicodeResult[Index];\r
index 619cbf9a0f40d0541f8c21a4badd92ae9d5d38ba..cfdccc54553d1e3422652097f04477cdb45ba059 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004 - 2009, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
@@ -435,11 +435,13 @@ Returns:
   if (GraphicsOutput != NULL) {\r
     SizeOfX = GraphicsOutput->Mode->Info->HorizontalResolution;\r
     SizeOfY = GraphicsOutput->Mode->Info->VerticalResolution;\r
-  } else {\r
+  } else if (UgaDraw != NULL) {\r
     Status = UgaDraw->GetMode (UgaDraw, &SizeOfX, &SizeOfY, &ColorDepth, &RefreshRate);\r
     if (EFI_ERROR (Status)) {\r
       return EFI_UNSUPPORTED;\r
     }\r
+  } else {\r
+    return EFI_UNSUPPORTED;\r
   }\r
 \r
   Instance = 0;\r
index ddfd3d9311161996b2e18ed3d8f58cf45ae157d2..5b815e610e452bfaf6e38cca352e2ccf678b3666 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
@@ -125,8 +125,7 @@ Arguments:
 \r
 Returns: \r
 \r
-  EFI_SUCCESS             -  success\r
-  EFI_OUT_OF_RESOURCES    -  out of resources\r
+  Length of string printed to the console\r
 \r
 --*/\r
 {\r
@@ -158,7 +157,7 @@ Returns:
   //\r
   Buffer = EfiLibAllocateZeroPool (0x10000);\r
   if (Buffer == NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
+    return 0;\r
   }\r
 \r
   if (GraphicsOutput != NULL) {\r
@@ -337,10 +336,15 @@ Error:
   EfiLibSafeFreePool (Blt);\r
   EfiLibSafeFreePool (FontInfo);\r
 #else\r
-  gBS->FreePool (LineBuffer);\r
+  EfiLibSafeFreePool (LineBuffer);\r
 #endif  \r
   gBS->FreePool (Buffer);\r
-  return Status;\r
+  \r
+  if (EFI_ERROR (Status)) {\r
+    return 0;\r
+  }\r
+\r
+  return BufferLen;\r
 }\r
 \r
 \r
@@ -406,19 +410,20 @@ Returns:
                     (VOID **) &UgaDraw\r
                     );\r
 \r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
+    if (EFI_ERROR (Status) || (UgaDraw != NULL)) {\r
+      return 0;\r
     }\r
   }\r
 \r
+  Sto = NULL;\r
   Status = gBS->HandleProtocol (\r
                   Handle,\r
                   &gEfiSimpleTextOutProtocolGuid,\r
                   (VOID **) &Sto\r
                   );\r
 \r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
+  if (EFI_ERROR (Status) || (Sto != NULL)) {\r
+    return 0;\r
   }\r
 \r
   return _IPrint (GraphicsOutput, UgaDraw, Sto, X, Y, ForeGround, BackGround, Fmt, Args);\r
index 3eb6c85b8aa11caa299adedbd35c907ba2e36761..de99ee07ea3b36202747c94c3aaad807ed426d02 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
@@ -123,8 +123,8 @@ Returns:
 --*/\r
 {\r
   UINTN   Index;\r
-  CHAR16  UnicodeFormat[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];\r
-  CHAR16  UnicodeResult[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];\r
+  CHAR16  UnicodeFormat[EFI_DRIVER_LIB_MAX_PRINT_BUFFER+1];\r
+  CHAR16  UnicodeResult[EFI_DRIVER_LIB_MAX_PRINT_BUFFER+1];\r
 \r
   for (Index = 0; Index < EFI_DRIVER_LIB_MAX_PRINT_BUFFER && FormatString[Index] != '\0'; Index++) {\r
     UnicodeFormat[Index] = (CHAR16) FormatString[Index];\r
@@ -132,7 +132,7 @@ Returns:
 \r
   UnicodeFormat[Index]  = '\0';\r
 \r
-  Index                 = VSPrint (UnicodeResult, EFI_DRIVER_LIB_MAX_PRINT_BUFFER, UnicodeFormat, Marker);\r
+  Index                 = VSPrint (UnicodeResult, sizeof (UnicodeResult), UnicodeFormat, Marker);\r
 \r
   for (Index = 0; (Index < (BufferSize - 1)) && UnicodeResult[Index] != '\0'; Index++) {\r
     Buffer[Index] = (CHAR8) UnicodeResult[Index];\r
index 3cb75d507516c0ab5b126d76817360904497526a..ae35d990bef45146e967848f8c24dfc180c42afd 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004 - 2006, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
@@ -466,6 +466,10 @@ Returns:
   EFI_STATUS  Status;\r
   VOID        *HobStart2;\r
 \r
+  //\r
+  // Initialize 'Buffer' to NULL before usage\r
+  //\r
+  Buffer = NULL;\r
   HobStart2 = HobStart;\r
   Status = GetNextGuidHob (\r
             &HobStart2,\r
@@ -473,9 +477,14 @@ Returns:
             &Buffer,\r
             &BufferSize\r
             );\r
-\r
+  if (EFI_ERROR (Status) || (Buffer == NULL)) {\r
+    //\r
+    // Failed to get HOB for gPalEntryHob\r
+    //\r
+    return EFI_NOT_FOUND;\r
+  }\r
   *PalEntry = *((EFI_PHYSICAL_ADDRESS *) Buffer);\r
-  return Status;\r
+  return EFI_SUCCESS;\r
 }\r
 \r
 \r
@@ -508,6 +517,10 @@ Returns:
   EFI_STATUS  Status;\r
   VOID        *HobStart2;\r
 \r
+  //\r
+  // Initialize 'Buffer' to NULL before usage\r
+  //\r
+  Buffer = NULL;\r
   HobStart2 = HobStart;\r
   Status = GetNextGuidHob (\r
             &HobStart2,\r
@@ -515,7 +528,13 @@ Returns:
             &Buffer,\r
             &BufferSize\r
             );\r
+  if (EFI_ERROR (Status) || (Buffer == NULL)) {\r
+    //\r
+    // Failed to get HOB for gEfiIoBaseHobGuid\r
+    //\r
+    return EFI_NOT_FOUND;\r
+  }\r
 \r
   *IoPortSpaceAddress = *((EFI_PHYSICAL_ADDRESS *) Buffer);\r
-  return Status;\r
+  return EFI_SUCCESS;\r
 }\r
index 3eb6c85b8aa11caa299adedbd35c907ba2e36761..de99ee07ea3b36202747c94c3aaad807ed426d02 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
@@ -123,8 +123,8 @@ Returns:
 --*/\r
 {\r
   UINTN   Index;\r
-  CHAR16  UnicodeFormat[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];\r
-  CHAR16  UnicodeResult[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];\r
+  CHAR16  UnicodeFormat[EFI_DRIVER_LIB_MAX_PRINT_BUFFER+1];\r
+  CHAR16  UnicodeResult[EFI_DRIVER_LIB_MAX_PRINT_BUFFER+1];\r
 \r
   for (Index = 0; Index < EFI_DRIVER_LIB_MAX_PRINT_BUFFER && FormatString[Index] != '\0'; Index++) {\r
     UnicodeFormat[Index] = (CHAR16) FormatString[Index];\r
@@ -132,7 +132,7 @@ Returns:
 \r
   UnicodeFormat[Index]  = '\0';\r
 \r
-  Index                 = VSPrint (UnicodeResult, EFI_DRIVER_LIB_MAX_PRINT_BUFFER, UnicodeFormat, Marker);\r
+  Index                 = VSPrint (UnicodeResult, sizeof (UnicodeResult), UnicodeFormat, Marker);\r
 \r
   for (Index = 0; (Index < (BufferSize - 1)) && UnicodeResult[Index] != '\0'; Index++) {\r
     Buffer[Index] = (CHAR8) UnicodeResult[Index];\r
index 3eb6c85b8aa11caa299adedbd35c907ba2e36761..de99ee07ea3b36202747c94c3aaad807ed426d02 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
@@ -123,8 +123,8 @@ Returns:
 --*/\r
 {\r
   UINTN   Index;\r
-  CHAR16  UnicodeFormat[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];\r
-  CHAR16  UnicodeResult[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];\r
+  CHAR16  UnicodeFormat[EFI_DRIVER_LIB_MAX_PRINT_BUFFER+1];\r
+  CHAR16  UnicodeResult[EFI_DRIVER_LIB_MAX_PRINT_BUFFER+1];\r
 \r
   for (Index = 0; Index < EFI_DRIVER_LIB_MAX_PRINT_BUFFER && FormatString[Index] != '\0'; Index++) {\r
     UnicodeFormat[Index] = (CHAR16) FormatString[Index];\r
@@ -132,7 +132,7 @@ Returns:
 \r
   UnicodeFormat[Index]  = '\0';\r
 \r
-  Index                 = VSPrint (UnicodeResult, EFI_DRIVER_LIB_MAX_PRINT_BUFFER, UnicodeFormat, Marker);\r
+  Index                 = VSPrint (UnicodeResult, sizeof (UnicodeResult), UnicodeFormat, Marker);\r
 \r
   for (Index = 0; (Index < (BufferSize - 1)) && UnicodeResult[Index] != '\0'; Index++) {\r
     Buffer[Index] = (CHAR8) UnicodeResult[Index];\r
index 8d885cfd68b7723bde5ef7079e75633ad695fa94..90afafe83721df7d5243e31d9264e77d458ffb21 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -554,7 +554,11 @@ Returns:
 \r
     Status = HiiDatabase->ExportPackageLists (HiiDatabase, Handle, &BufferSize, HiiPackageList);\r
   }\r
+  if (HiiPackageList == NULL) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
   if (EFI_ERROR (Status)) {\r
+    gBS->FreePool (HiiPackageList);\r
     return Status;\r
   }\r
 \r
index 3fe278aaf0638a196c73e0bba648b128ab989c54..01bad650010edd980677e910738eb297f18afa1f 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -551,6 +551,9 @@ IfrLibNewString (
   LocateHiiProtocols ();\r
 \r
   Languages = GetSupportedLanguages (PackageList);\r
+  if (Languages == NULL) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
 \r
   LangStrings = Languages;\r
   while (*LangStrings != 0) {\r
@@ -677,6 +680,9 @@ IfrLibSetString (
   LocateHiiProtocols ();\r
 \r
   Languages = GetSupportedLanguages (PackageList);\r
+  if (Languages == NULL) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
 \r
   LangStrings = Languages;\r
   while (*LangStrings != 0) {\r
index cafda9ed8f00de0f2fe9a88df38b175657288ec8..f99c23e5ee4cf1f722fbc9adaa4e5621b9c16b2c 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004 - 2006, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
@@ -581,12 +581,18 @@ GluePeCoffLoaderRelocateImage (
     // the optional header to verify a desired directory entry is there.\r
     //\r
 \r
-    if (NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC) {\r
+    if (NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC && RelocDir->Size > 0) {\r
       RelocBase = PeCoffLoaderImageAddress (ImageContext, RelocDir->VirtualAddress);\r
       RelocBaseEnd = PeCoffLoaderImageAddress (\r
                       ImageContext,\r
                       RelocDir->VirtualAddress + RelocDir->Size - 1\r
                       );\r
+      if ((RelocBase == NULL) || (RelocBaseEnd == NULL)) {\r
+        //\r
+        // If the base start or end address resolved to 0, then fail.\r
+        //\r
+        return RETURN_LOAD_ERROR;\r
+      }\r
     } else {\r
       //\r
       // Set base and end to bypass processing below.\r
@@ -602,13 +608,21 @@ GluePeCoffLoaderRelocateImage (
     // Find the relocation block\r
     //\r
     RelocDir = &Hdr.Te->DataDirectory[0];\r
-    RelocBase = (EFI_IMAGE_BASE_RELOCATION *)(UINTN)(\r
-                                    ImageContext->ImageAddress +\r
-                                    RelocDir->VirtualAddress +\r
-                                    sizeof(EFI_TE_IMAGE_HEADER) -\r
-                                    Hdr.Te->StrippedSize\r
-                                    );\r
-    RelocBaseEnd = (EFI_IMAGE_BASE_RELOCATION *) ((UINTN) RelocBase + (UINTN) RelocDir->Size - 1);\r
+    if (RelocDir->Size > 0) {\r
+      RelocBase = (EFI_IMAGE_BASE_RELOCATION *)(UINTN)(\r
+                                      ImageContext->ImageAddress +\r
+                                      RelocDir->VirtualAddress +\r
+                                      sizeof(EFI_TE_IMAGE_HEADER) -\r
+                                      Hdr.Te->StrippedSize\r
+                                      );\r
+      RelocBaseEnd = (EFI_IMAGE_BASE_RELOCATION *) ((UINTN) RelocBase + (UINTN) RelocDir->Size - 1);\r
+    } else {\r
+      //\r
+      // Set base and end to bypass processing below.\r
+      //\r
+      RelocBase = NULL;\r
+      RelocBaseEnd = NULL;\r
+    }\r
   }\r
 \r
   //\r
@@ -621,6 +635,13 @@ GluePeCoffLoaderRelocateImage (
     RelocEnd  = (UINT16 *) ((CHAR8 *) RelocBase + RelocBase->SizeOfBlock);\r
     if (!(ImageContext->IsTeImage)) {\r
       FixupBase = PeCoffLoaderImageAddress (ImageContext, RelocBase->VirtualAddress);\r
+\r
+      if (FixupBase == NULL) {\r
+        //\r
+        // If the FixupBase address resolved to 0, then fail.\r
+        //\r
+        return RETURN_LOAD_ERROR;\r
+      }\r
     } else {\r
       FixupBase = (CHAR8 *)(UINTN)(ImageContext->ImageAddress +\r
                     RelocBase->VirtualAddress +\r
index d91153fbdf6a96118a6ca68a0e3beb2d05eac80f..30ec41769edc1751afc97245bfcfd3687282a669 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004 - 2006, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
@@ -152,15 +152,32 @@ GlueMakeTable (
   UINT16  WordOfStart;\r
   UINT16  WordOfCount;\r
 \r
-\r
-  for (Index = 1; Index <= 16; Index++) {\r
+  //\r
+  // TableBits should not be greater than 16.\r
+  //\r
+  if (TableBits >= (sizeof (Count)/sizeof (UINT16))) {\r
+    return (UINT16) BAD_TABLE;\r
+  }\r
\r
+  //\r
+  // Initialize Count array starting from Index 0, as there is a possibility of Count array being uninitialized.\r
+  //\r
+  for (Index = 0; Index <= 16; Index++) {\r
     Count[Index] = 0;\r
   }\r
 \r
   for (Index = 0; Index < NumOfChar; Index++) {\r
-    Count[BitLen[Index]]++;\r
+    //\r
+    // Count array index should not be greater than or equal to its size.\r
+    //\r
+    if (BitLen[Index] < (sizeof (Count)/sizeof (UINT16))) {\r
+      Count[BitLen[Index]]++;\r
+    } else {\r
+      return (UINT16) BAD_TABLE;\r
+    }\r
   }\r
 \r
+  Start[0] = 0;\r
   Start[1] = 0;\r
 \r
   for (Index = 1; Index <= 16; Index++) {\r
@@ -201,7 +218,7 @@ GlueMakeTable (
   for (Char = 0; Char < NumOfChar; Char++) {\r
 \r
     Len = BitLen[Char];\r
-    if (Len == 0) {\r
+    if (Len == 0 || Len >= 17) {\r
       continue;\r
     }\r
 \r
@@ -220,14 +237,20 @@ GlueMakeTable (
       Index   = (UINT16) (Len - TableBits);\r
 \r
       while (Index != 0) {\r
-        if (*Pointer == 0) {\r
+        //\r
+        // Avail should be lesser than size of mRight and mLeft to prevent buffer overflow.\r
+        //\r
+        if ((*Pointer == 0) && (Avail < sizeof (Sd->mRight)/sizeof (UINT16)) && (Avail < sizeof (Sd->mLeft)/sizeof (UINT16))) {\r
           Sd->mRight[Avail]                     = Sd->mLeft[Avail] = 0;\r
           *Pointer = Avail++;\r
         }\r
 \r
-        if (Index3 & Mask) {\r
+        //\r
+        // *Pointer should be lesser than size of mRight and mLeft to prevent buffer overflow.\r
+        //\r
+        if ((Index3 & Mask) && (*Pointer < (sizeof (Sd->mRight)/sizeof (UINT16)))) {\r
           Pointer = &Sd->mRight[*Pointer];\r
-        } else {\r
+        } else if (*Pointer < (sizeof (Sd->mLeft)/sizeof (UINT16))) {\r
           Pointer = &Sd->mLeft[*Pointer];\r
         }\r
 \r
@@ -328,6 +351,13 @@ GlueReadPTLen (
   //\r
   Number = (UINT16) GetBits (Sd, nbit);\r
 \r
+  if ((Number > sizeof (Sd->mPTLen)) || (nn > sizeof (Sd->mPTLen))) {\r
+    //\r
+    // Fail if Number or nn is greater than size of mPTLen\r
+    //\r
+    return (UINT16) BAD_TABLE;\r
+  }\r
+\r
   if (Number == 0) {\r
     //\r
     // This represents only Huffman code used\r
@@ -377,6 +407,12 @@ GlueReadPTLen (
     if (Index == Special) {\r
       CharC = (UINT16) GetBits (Sd, 2);\r
       while ((INT16) (--CharC) >= 0) {\r
+         if (Index >= sizeof (Sd->mPTLen)) {\r
+          //\r
+          // Fail if Index is greater than or equal to mPTLen\r
+          //\r
+          return (UINT16) BAD_TABLE;\r
+        }\r
         Sd->mPTLen[Index++] = 0;\r
       }\r
     }\r
index 9c3e1366b6040fdf94f51d3909193af23f5fbc17..5949025d2bd6d274de4d1b22ba766e2aa6aa7d70 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004 - 2006, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
@@ -483,6 +483,9 @@ Returns:
 \r
   do {\r
     GuidHob = (EFI_HOB_GUID_TYPE *)GlueGetNextGuidHob (&gEfiPeiPerformanceHobGuid, &HobList);\r
+    if (GuidHob == NULL) {\r
+      break;\r
+    }\r
     LogHob  = (EFI_HOB_GUID_DATA_PERFORMANCE_LOG *)GET_GUID_HOB_DATA (GuidHob);\r
 \r
     for (Index = 0; Index < LogHob->NumberOfEntries; Index++) {\r
index 07bb0eea796189cd7fc2d249eec958a026f1659a..77634d906c23aeece21360b7c5b4926efce7f0dd 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
@@ -52,6 +52,9 @@ GluePreparePackages (
 \r
   HiiPackages                   = AllocateZeroPool (sizeof (EFI_HII_PACKAGES) + NumberOfPackages * sizeof (VOID *));\r
   ASSERT (HiiPackages != NULL);\r
+  if (HiiPackages == NULL) {\r
+    return NULL;\r
+  }\r
 \r
   HiiPackages->GuidId           = (EFI_GUID *) Guid;\r
   HiiPackages->NumberOfPackages = NumberOfPackages;\r
index ff467375b021498a5397f5315cfdabebd50857f1..6d09c6152e4e9f89e268fa54df64a91e2626b99f 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
@@ -312,14 +312,32 @@ Returns:
   UINT16  NextCode;\r
   UINT16  Mask;\r
 \r
-  for (Index = 1; Index <= 16; Index++) {\r
+  //\r
+  // TableBits should not be greater than 16.\r
+  //\r
+  if (TableBits >= (sizeof (Count)/sizeof (UINT16))) {\r
+    return (UINT16) BAD_TABLE;\r
+  }\r
\r
+  //\r
+  // Initialize Count array starting from Index 0, as there is a possibility of Count array being uninitialized.\r
+  //\r
+  for (Index = 0; Index <= 16; Index++) {\r
     Count[Index] = 0;\r
   }\r
 \r
   for (Index = 0; Index < NumOfChar; Index++) {\r
-    Count[BitLen[Index]]++;\r
+    //\r
+    // Count array index should not be greater than or equal to its size.\r
+    //\r
+    if (BitLen[Index] < (sizeof (Count)/sizeof (UINT16))) {\r
+      Count[BitLen[Index]]++;\r
+    } else {\r
+      return (UINT16) BAD_TABLE;\r
+    }\r
   }\r
 \r
+  Start[0] = 0;\r
   Start[1] = 0;\r
 \r
   for (Index = 1; Index <= 16; Index++) {\r
@@ -358,7 +376,7 @@ Returns:
   for (Char = 0; Char < NumOfChar; Char++) {\r
 \r
     Len = BitLen[Char];\r
-    if (Len == 0) {\r
+    if (Len == 0 || Len >= 17) {\r
       continue;\r
     }\r
 \r
@@ -377,14 +395,20 @@ Returns:
       Index   = (UINT16) (Len - TableBits);\r
 \r
       while (Index != 0) {\r
-        if (*Pointer == 0) {\r
+        //\r
+        // Avail should be lesser than size of mRight and mLeft to prevent buffer overflow.\r
+        //\r
+        if ((*Pointer == 0) && (Avail < sizeof (Sd->mRight)/sizeof (UINT16)) && (Avail < sizeof (Sd->mLeft)/sizeof (UINT16))) {\r
           Sd->mRight[Avail]                     = Sd->mLeft[Avail] = 0;\r
           *Pointer = Avail++;\r
         }\r
 \r
-        if (Index3 & Mask) {\r
+        //\r
+        // *Pointer should be lesser than size of mRight and mLeft to prevent buffer overflow.\r
+        //\r
+        if ((Index3 & Mask) && (*Pointer < (sizeof (Sd->mRight)/sizeof (UINT16)))) {\r
           Pointer = &Sd->mRight[*Pointer];\r
-        } else {\r
+        } else if (*Pointer < (sizeof (Sd->mLeft)/sizeof (UINT16))) {\r
           Pointer = &Sd->mLeft[*Pointer];\r
         }\r
 \r
@@ -493,6 +517,13 @@ Returns:
 \r
   Number = (UINT16) GetBits (Sd, nbit);\r
 \r
+  if ((Number > sizeof (Sd->mPTLen)) || (nn > sizeof (Sd->mPTLen))) {\r
+    //\r
+    // Fail if Number or nn is greater than size of mPTLen\r
+    //\r
+    return (UINT16) BAD_TABLE;\r
+  }\r
+\r
   if (Number == 0) {\r
     CharC = (UINT16) GetBits (Sd, nbit);\r
 \r
@@ -528,6 +559,12 @@ Returns:
     if (Index == Special) {\r
       CharC = (UINT16) GetBits (Sd, 2);\r
       while ((INT16) (--CharC) >= 0) {\r
+        if (Index >= sizeof (Sd->mPTLen)) {\r
+          //\r
+          // Fail if Index is greater than or equal to mPTLen\r
+          //\r
+          return (UINT16) BAD_TABLE;\r
+        }\r
         Sd->mPTLen[Index++] = 0;\r
       }\r
     }\r
index 68c4e96e8d1d59650ac8bf96ce1e88209f86e06c..bc4ca8ee6689c6a119b3c8bf8b277fc8e3a9095d 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2005 - 2007, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2005 - 2010, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
@@ -785,12 +785,18 @@ Returns:
     // the optional header to verify a desired directory entry is there.\r
     //\r
 \r
-    if (NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC) {\r
+    if (NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC && RelocDir->Size > 0) {\r
       RelocBase = PeCoffLoaderImageAddress (ImageContext, RelocDir->VirtualAddress);\r
       RelocBaseEnd = PeCoffLoaderImageAddress (\r
                       ImageContext,\r
                       RelocDir->VirtualAddress + RelocDir->Size - 1\r
                       );\r
+      if ((RelocBase == NULL) || (RelocBaseEnd == NULL)) {\r
+        //\r
+        // If the base start or end address resolved to 0, then fail.\r
+        //\r
+        return EFI_LOAD_ERROR;\r
+      }\r
     } else {\r
       //\r
       // Set base and end to bypass processing below.\r
@@ -806,13 +812,21 @@ Returns:
     // Find the relocation block\r
     //\r
     RelocDir = &Hdr.Te->DataDirectory[0];\r
-    RelocBase = (EFI_IMAGE_BASE_RELOCATION *)(UINTN)(\r
-                                    ImageContext->ImageAddress + \r
-                                    RelocDir->VirtualAddress +\r
-                                    sizeof(EFI_TE_IMAGE_HEADER) - \r
-                                    Hdr.Te->StrippedSize\r
-                                    );\r
-    RelocBaseEnd = (EFI_IMAGE_BASE_RELOCATION *) ((UINTN) RelocBase + (UINTN) RelocDir->Size - 1);\r
+    if (RelocDir->Size > 0) {\r
+      RelocBase = (EFI_IMAGE_BASE_RELOCATION *)(UINTN)(\r
+                                      ImageContext->ImageAddress +\r
+                                      RelocDir->VirtualAddress +\r
+                                      sizeof(EFI_TE_IMAGE_HEADER) -\r
+                                      Hdr.Te->StrippedSize\r
+                                      );\r
+      RelocBaseEnd = (EFI_IMAGE_BASE_RELOCATION *) ((UINTN) RelocBase + (UINTN) RelocDir->Size - 1);\r
+    } else {\r
+      //\r
+      // Set base and end to bypass processing below.\r
+      //\r
+      RelocBase = NULL;\r
+      RelocBaseEnd = NULL;\r
+    }\r
   }\r
   \r
   //\r
@@ -825,6 +839,13 @@ Returns:
     RelocEnd  = (UINT16 *) ((CHAR8 *) RelocBase + RelocBase->SizeOfBlock);\r
     if (!(ImageContext->IsTeImage)) {\r
       FixupBase = PeCoffLoaderImageAddress (ImageContext, RelocBase->VirtualAddress);\r
+\r
+      if (FixupBase == NULL) {\r
+        //\r
+        // If the FixupBase address resolved to 0, then fail.\r
+        //\r
+        return EFI_LOAD_ERROR;\r
+      }\r
     } else {\r
       FixupBase = (CHAR8 *)(UINTN)(ImageContext->ImageAddress +\r
                     RelocBase->VirtualAddress +\r
index cc903cfd67ee4d94dcf80477005f0dcc724c9923..ce5f0490392b7ffc530d7426f82fbfb13ee479ac 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
@@ -66,9 +66,9 @@ Returns:
     );\r
 \r
   //\r
-  // Put break point in module that contained the error.\r
+  // Put dead loop in module that contained the error.\r
   //\r
-  EFI_BREAKPOINT ();\r
+  EFI_DEADLOOP ();\r
 }\r
 \r
 VOID\r
index cd548dac2a3980d4d142c29aaa986d9abcb62c56..2e63672582a04faef6137d650e6cbeb6296c8872 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004 - 2005, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
@@ -947,6 +947,7 @@ Returns:
   EFI_GUID Guid = EFI_EXTENDED_SAL_BASE_IO_SERVICES_PROTOCOL_GUID;\r
 \r
   ReturnReg = EfiCallEsalService (&Guid, IoRead, (UINT64) Width, Address, Count, (UINT64) Buffer, 0, 0, 0);\r
+  ASSERT (ReturnReg.Status == EFI_SAL_SUCCESS);\r
 \r
   return ReturnReg.Status;\r
 \r
@@ -1015,6 +1016,7 @@ Returns:
   EFI_GUID Guid = EFI_EXTENDED_SAL_BASE_IO_SERVICES_PROTOCOL_GUID;\r
 \r
   ReturnReg = EfiCallEsalService (&Guid, MemRead, (UINT64) Width, Address, Count, (UINT64) Buffer, 0, 0, 0);\r
+  ASSERT (ReturnReg.Status == EFI_SAL_SUCCESS);\r
 \r
   return ReturnReg.Status;\r
 \r
index c15a930075486ae5b68fe837f7b43bff847c1526..dd4128f365235e3b2061cea0e66cad2201ea93d5 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
@@ -289,8 +289,7 @@ Returns:
                               &mPpiListStatusCode\r
                               );\r
     if (EFI_ERROR (Status)) {\r
-      EFI_BREAKPOINT ();\r
-      return ;\r
+      EFI_DEADLOOP ();\r
     }\r
     //\r
     // Publish a GUIDed HOB that contains a pointer to the status code PPI\r
@@ -306,8 +305,7 @@ Returns:
               sizeof (VOID *)\r
               );\r
     if (EFI_ERROR (Status)) {\r
-      EFI_BREAKPOINT ();\r
-      return ;\r
+      EFI_DEADLOOP ();\r
     }\r
   }\r
 }\r
index ed96cfbb03d59c298d1f94f18f630f28477a9b34..15603cb645a465db676e07ebe1128246c640bbc4 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
@@ -2073,8 +2073,8 @@ Returns:
 {\r
   UINTN Current;\r
 \r
-  ASSERT (Table);\r
-  ASSERT (Token);\r
+  ASSERT (Table != NULL);\r
+  ASSERT (Token != NULL);\r
 \r
   Current = 0;\r
   *Token  = 0;\r
index d4c41961f52b5c582ec68318926ec1705a94e021..9ee89b6071d1c71c665561acf081e2c23f990568 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004 - 2006, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
@@ -124,6 +124,7 @@ Returns:
   // Locate the HOB that contains the PPI structure for the memory journal\r
   // We don't check for more than one.\r
   //\r
+  StatusCodeMemoryPpi = NULL;\r
   EfiLibGetSystemConfigurationTable (\r
     &gEfiHobListGuid,\r
     &HobList\r
@@ -134,7 +135,7 @@ Returns:
             (VOID **) &StatusCodeMemoryPpi,\r
             NULL\r
             );\r
-  if (EFI_ERROR (Status)) {\r
+  if (EFI_ERROR (Status) || (StatusCodeMemoryPpi == NULL)) {\r
     return ;\r
   }\r
   //\r
index 9ec2198d355a4c61f5bb428158886e7e00bbd11b..f4c64263945863055b89be51b26dc46e2d7e7168 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004 - 2006, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
@@ -133,11 +133,11 @@ Returns:
   // is connected.\r
   //\r
   mPeiReportStatusCode  = NULL;\r
-\r
+  Pointer               = NULL;\r
   Status                = EfiLibGetSystemConfigurationTable (&gEfiHobListGuid, &HobList);\r
   if (!EFI_ERROR (Status)) {\r
     Status = GetNextGuidHob (&HobList, &gEfiStatusCodeRuntimeProtocolGuid, &Pointer, NULL);\r
-    if (!EFI_ERROR (Status)) {\r
+    if (!EFI_ERROR (Status) && (Pointer != NULL)) {\r
       mPeiReportStatusCode = (EFI_REPORT_STATUS_CODE) (*(UINTN *) Pointer);\r
     }\r
   }\r