diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/Debug.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/Debug.c
index 1c7f7b9cc7..3c43451d09 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/Debug.c
+++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/Debug.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2006, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.
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
@@ -75,7 +75,7 @@ Returns:
);
//
- // Put break point in module that contained the error.
+ // Put dead loop in module that contained the error.
//
EFI_DEADLOOP ();
}
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/Perf.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/Perf.c
index 497c0cf495..96f11bb44d 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/Perf.c
+++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/Perf.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2005, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.
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
@@ -825,6 +825,11 @@ Returns:
return EFI_OUT_OF_RESOURCES;
}
+ //
+ // Initialize 'LogHob' to NULL before usage.
+ //
+ LogHob = NULL;
+
if (Ticker != 0) {
TimerValue = Ticker;
} else {
@@ -837,7 +842,10 @@ Returns:
EfiLibGetSystemConfigurationTable (&gEfiHobListGuid, &HobList);
do {
Status = GetNextGuidHob (&HobList, &gEfiPeiPerformanceHobGuid, (VOID **) &LogHob, NULL);
- if (EFI_ERROR (Status)) {
+ if (EFI_ERROR (Status) || (LogHob == NULL)) {
+ //
+ // Failed to get HOB for ProtocolGuid.
+ //
break;
}
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Graphics.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Graphics.c
index e913d592e2..6a8183e131 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Graphics.c
+++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Graphics.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2009, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.
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
@@ -436,11 +436,13 @@ Returns:
if (GraphicsOutput != NULL) {
SizeOfX = GraphicsOutput->Mode->Info->HorizontalResolution;
SizeOfY = GraphicsOutput->Mode->Info->VerticalResolution;
- } else {
+ } else if (UgaDraw != NULL) {
Status = UgaDraw->GetMode (UgaDraw, &SizeOfX, &SizeOfY, &ColorDepth, &RefreshRate);
if (EFI_ERROR (Status)) {
return EFI_UNSUPPORTED;
}
+ } else {
+ return EFI_UNSUPPORTED;
}
Instance = 0;
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Print.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Print.c
index 316fe71e23..03b66623c9 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Print.c
+++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Print.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.
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
@@ -158,8 +158,7 @@ Arguments:
Returns:
- EFI_SUCCESS - success
- EFI_OUT_OF_RESOURCES - out of resources
+ Length of string printed to the console
--*/
{
@@ -191,7 +190,7 @@ Returns:
//
Buffer = EfiLibAllocateZeroPool (0x10000);
if (Buffer == NULL) {
- return EFI_OUT_OF_RESOURCES;
+ return 0;
}
if (GraphicsOutput != NULL) {
@@ -371,10 +370,15 @@ Error:
EfiLibSafeFreePool (Blt);
EfiLibSafeFreePool (FontInfo);
#else
- gBS->FreePool (LineBuffer);
+ EfiLibSafeFreePool (LineBuffer);
#endif
gBS->FreePool (Buffer);
- return Status;
+
+ if (EFI_ERROR (Status)) {
+ return 0;
+ }
+
+ return BufferLen;
}
@@ -440,19 +444,20 @@ Returns:
(VOID**)&UgaDraw
);
- if (EFI_ERROR (Status)) {
- return Status;
+ if (EFI_ERROR (Status) || (UgaDraw == NULL)) {
+ return 0;
}
}
+ Sto = NULL;
Status = gBS->HandleProtocol (
Handle,
&gEfiSimpleTextOutProtocolGuid,
(VOID**)&Sto
);
- if (EFI_ERROR (Status)) {
- return Status;
+ if (EFI_ERROR (Status) || (Sto == NULL)) {
+ return 0;
}
return _IPrint (GraphicsOutput, UgaDraw, Sto, X, Y, ForeGround, BackGround, Fmt, Args);
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Unicode/Sprint.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Unicode/Sprint.c
index 3eb6c85b8a..de99ee07ea 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Unicode/Sprint.c
+++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Unicode/Sprint.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.
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
@@ -123,8 +123,8 @@ Returns:
--*/
{
UINTN Index;
- CHAR16 UnicodeFormat[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];
- CHAR16 UnicodeResult[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];
+ CHAR16 UnicodeFormat[EFI_DRIVER_LIB_MAX_PRINT_BUFFER+1];
+ CHAR16 UnicodeResult[EFI_DRIVER_LIB_MAX_PRINT_BUFFER+1];
for (Index = 0; Index < EFI_DRIVER_LIB_MAX_PRINT_BUFFER && FormatString[Index] != '\0'; Index++) {
UnicodeFormat[Index] = (CHAR16) FormatString[Index];
@@ -132,7 +132,7 @@ Returns:
UnicodeFormat[Index] = '\0';
- Index = VSPrint (UnicodeResult, EFI_DRIVER_LIB_MAX_PRINT_BUFFER, UnicodeFormat, Marker);
+ Index = VSPrint (UnicodeResult, sizeof (UnicodeResult), UnicodeFormat, Marker);
for (Index = 0; (Index < (BufferSize - 1)) && UnicodeResult[Index] != '\0'; Index++) {
Buffer[Index] = (CHAR8) UnicodeResult[Index];
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Graphics.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Graphics.c
index 619cbf9a0f..cfdccc5455 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Graphics.c
+++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Graphics.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2009, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.
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
@@ -435,11 +435,13 @@ Returns:
if (GraphicsOutput != NULL) {
SizeOfX = GraphicsOutput->Mode->Info->HorizontalResolution;
SizeOfY = GraphicsOutput->Mode->Info->VerticalResolution;
- } else {
+ } else if (UgaDraw != NULL) {
Status = UgaDraw->GetMode (UgaDraw, &SizeOfX, &SizeOfY, &ColorDepth, &RefreshRate);
if (EFI_ERROR (Status)) {
return EFI_UNSUPPORTED;
}
+ } else {
+ return EFI_UNSUPPORTED;
}
Instance = 0;
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Print.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Print.c
index ddfd3d9311..5b815e610e 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Print.c
+++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Print.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.
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
@@ -125,8 +125,7 @@ Arguments:
Returns:
- EFI_SUCCESS - success
- EFI_OUT_OF_RESOURCES - out of resources
+ Length of string printed to the console
--*/
{
@@ -158,7 +157,7 @@ Returns:
//
Buffer = EfiLibAllocateZeroPool (0x10000);
if (Buffer == NULL) {
- return EFI_OUT_OF_RESOURCES;
+ return 0;
}
if (GraphicsOutput != NULL) {
@@ -337,10 +336,15 @@ Error:
EfiLibSafeFreePool (Blt);
EfiLibSafeFreePool (FontInfo);
#else
- gBS->FreePool (LineBuffer);
+ EfiLibSafeFreePool (LineBuffer);
#endif
gBS->FreePool (Buffer);
- return Status;
+
+ if (EFI_ERROR (Status)) {
+ return 0;
+ }
+
+ return BufferLen;
}
@@ -406,19 +410,20 @@ Returns:
(VOID **) &UgaDraw
);
- if (EFI_ERROR (Status)) {
- return Status;
+ if (EFI_ERROR (Status) || (UgaDraw != NULL)) {
+ return 0;
}
}
+ Sto = NULL;
Status = gBS->HandleProtocol (
Handle,
&gEfiSimpleTextOutProtocolGuid,
(VOID **) &Sto
);
- if (EFI_ERROR (Status)) {
- return Status;
+ if (EFI_ERROR (Status) || (Sto != NULL)) {
+ return 0;
}
return _IPrint (GraphicsOutput, UgaDraw, Sto, X, Y, ForeGround, BackGround, Fmt, Args);
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Unicode/Sprint.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Unicode/Sprint.c
index 3eb6c85b8a..de99ee07ea 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Unicode/Sprint.c
+++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Unicode/Sprint.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.
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
@@ -123,8 +123,8 @@ Returns:
--*/
{
UINTN Index;
- CHAR16 UnicodeFormat[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];
- CHAR16 UnicodeResult[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];
+ CHAR16 UnicodeFormat[EFI_DRIVER_LIB_MAX_PRINT_BUFFER+1];
+ CHAR16 UnicodeResult[EFI_DRIVER_LIB_MAX_PRINT_BUFFER+1];
for (Index = 0; Index < EFI_DRIVER_LIB_MAX_PRINT_BUFFER && FormatString[Index] != '\0'; Index++) {
UnicodeFormat[Index] = (CHAR16) FormatString[Index];
@@ -132,7 +132,7 @@ Returns:
UnicodeFormat[Index] = '\0';
- Index = VSPrint (UnicodeResult, EFI_DRIVER_LIB_MAX_PRINT_BUFFER, UnicodeFormat, Marker);
+ Index = VSPrint (UnicodeResult, sizeof (UnicodeResult), UnicodeFormat, Marker);
for (Index = 0; (Index < (BufferSize - 1)) && UnicodeResult[Index] != '\0'; Index++) {
Buffer[Index] = (CHAR8) UnicodeResult[Index];
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Hob/Hob.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/Hob/Hob.c
index 3cb75d5075..ae35d990be 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Dxe/Hob/Hob.c
+++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/Hob/Hob.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2006, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.
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
@@ -466,6 +466,10 @@ Returns:
EFI_STATUS Status;
VOID *HobStart2;
+ //
+ // Initialize 'Buffer' to NULL before usage
+ //
+ Buffer = NULL;
HobStart2 = HobStart;
Status = GetNextGuidHob (
&HobStart2,
@@ -473,9 +477,14 @@ Returns:
&Buffer,
&BufferSize
);
-
+ if (EFI_ERROR (Status) || (Buffer == NULL)) {
+ //
+ // Failed to get HOB for gPalEntryHob
+ //
+ return EFI_NOT_FOUND;
+ }
*PalEntry = *((EFI_PHYSICAL_ADDRESS *) Buffer);
- return Status;
+ return EFI_SUCCESS;
}
@@ -508,6 +517,10 @@ Returns:
EFI_STATUS Status;
VOID *HobStart2;
+ //
+ // Initialize 'Buffer' to NULL before usage
+ //
+ Buffer = NULL;
HobStart2 = HobStart;
Status = GetNextGuidHob (
&HobStart2,
@@ -515,7 +528,13 @@ Returns:
&Buffer,
&BufferSize
);
+ if (EFI_ERROR (Status) || (Buffer == NULL)) {
+ //
+ // Failed to get HOB for gEfiIoBaseHobGuid
+ //
+ return EFI_NOT_FOUND;
+ }
*IoPortSpaceAddress = *((EFI_PHYSICAL_ADDRESS *) Buffer);
- return Status;
+ return EFI_SUCCESS;
}
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Print/Unicode/SPrint.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/Print/Unicode/SPrint.c
index 3eb6c85b8a..de99ee07ea 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Dxe/Print/Unicode/SPrint.c
+++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/Print/Unicode/SPrint.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.
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
@@ -123,8 +123,8 @@ Returns:
--*/
{
UINTN Index;
- CHAR16 UnicodeFormat[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];
- CHAR16 UnicodeResult[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];
+ CHAR16 UnicodeFormat[EFI_DRIVER_LIB_MAX_PRINT_BUFFER+1];
+ CHAR16 UnicodeResult[EFI_DRIVER_LIB_MAX_PRINT_BUFFER+1];
for (Index = 0; Index < EFI_DRIVER_LIB_MAX_PRINT_BUFFER && FormatString[Index] != '\0'; Index++) {
UnicodeFormat[Index] = (CHAR16) FormatString[Index];
@@ -132,7 +132,7 @@ Returns:
UnicodeFormat[Index] = '\0';
- Index = VSPrint (UnicodeResult, EFI_DRIVER_LIB_MAX_PRINT_BUFFER, UnicodeFormat, Marker);
+ Index = VSPrint (UnicodeResult, sizeof (UnicodeResult), UnicodeFormat, Marker);
for (Index = 0; (Index < (BufferSize - 1)) && UnicodeResult[Index] != '\0'; Index++) {
Buffer[Index] = (CHAR8) UnicodeResult[Index];
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/PrintLite/Unicode/SPrint.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/PrintLite/Unicode/SPrint.c
index 3eb6c85b8a..de99ee07ea 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Dxe/PrintLite/Unicode/SPrint.c
+++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/PrintLite/Unicode/SPrint.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.
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
@@ -123,8 +123,8 @@ Returns:
--*/
{
UINTN Index;
- CHAR16 UnicodeFormat[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];
- CHAR16 UnicodeResult[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];
+ CHAR16 UnicodeFormat[EFI_DRIVER_LIB_MAX_PRINT_BUFFER+1];
+ CHAR16 UnicodeResult[EFI_DRIVER_LIB_MAX_PRINT_BUFFER+1];
for (Index = 0; Index < EFI_DRIVER_LIB_MAX_PRINT_BUFFER && FormatString[Index] != '\0'; Index++) {
UnicodeFormat[Index] = (CHAR16) FormatString[Index];
@@ -132,7 +132,7 @@ Returns:
UnicodeFormat[Index] = '\0';
- Index = VSPrint (UnicodeResult, EFI_DRIVER_LIB_MAX_PRINT_BUFFER, UnicodeFormat, Marker);
+ Index = VSPrint (UnicodeResult, sizeof (UnicodeResult), UnicodeFormat, Marker);
for (Index = 0; (Index < (BufferSize - 1)) && UnicodeResult[Index] != '\0'; Index++) {
Buffer[Index] = (CHAR8) UnicodeResult[Index];
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrCommon.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrCommon.c
index 8d885cfd68..90afafe837 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrCommon.c
+++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrCommon.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2007, Intel Corporation. All rights reserved.
+Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.
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
@@ -554,7 +554,11 @@ Returns:
Status = HiiDatabase->ExportPackageLists (HiiDatabase, Handle, &BufferSize, HiiPackageList);
}
+ if (HiiPackageList == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
if (EFI_ERROR (Status)) {
+ gBS->FreePool (HiiPackageList);
return Status;
}
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrString.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrString.c
index 3fe278aaf0..01bad65001 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrString.c
+++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrString.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2007, Intel Corporation. All rights reserved.
+Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.
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
@@ -551,6 +551,9 @@ IfrLibNewString (
LocateHiiProtocols ();
Languages = GetSupportedLanguages (PackageList);
+ if (Languages == NULL) {
+ return EFI_NOT_FOUND;
+ }
LangStrings = Languages;
while (*LangStrings != 0) {
@@ -677,6 +680,9 @@ IfrLibSetString (
LocateHiiProtocols ();
Languages = GetSupportedLanguages (PackageList);
+ if (Languages == NULL) {
+ return EFI_NOT_FOUND;
+ }
LangStrings = Languages;
while (*LangStrings != 0) {
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/BasePeCoff.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/BasePeCoff.c
index cafda9ed8f..f99c23e5ee 100644
--- a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/BasePeCoff.c
+++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/BasePeCoff.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2006, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.
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
@@ -581,12 +581,18 @@ GluePeCoffLoaderRelocateImage (
// the optional header to verify a desired directory entry is there.
//
- if (NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC) {
+ if (NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC && RelocDir->Size > 0) {
RelocBase = PeCoffLoaderImageAddress (ImageContext, RelocDir->VirtualAddress);
RelocBaseEnd = PeCoffLoaderImageAddress (
ImageContext,
RelocDir->VirtualAddress + RelocDir->Size - 1
);
+ if ((RelocBase == NULL) || (RelocBaseEnd == NULL)) {
+ //
+ // If the base start or end address resolved to 0, then fail.
+ //
+ return RETURN_LOAD_ERROR;
+ }
} else {
//
// Set base and end to bypass processing below.
@@ -602,13 +608,21 @@ GluePeCoffLoaderRelocateImage (
// Find the relocation block
//
RelocDir = &Hdr.Te->DataDirectory[0];
- RelocBase = (EFI_IMAGE_BASE_RELOCATION *)(UINTN)(
- ImageContext->ImageAddress +
- RelocDir->VirtualAddress +
- sizeof(EFI_TE_IMAGE_HEADER) -
- Hdr.Te->StrippedSize
- );
- RelocBaseEnd = (EFI_IMAGE_BASE_RELOCATION *) ((UINTN) RelocBase + (UINTN) RelocDir->Size - 1);
+ if (RelocDir->Size > 0) {
+ RelocBase = (EFI_IMAGE_BASE_RELOCATION *)(UINTN)(
+ ImageContext->ImageAddress +
+ RelocDir->VirtualAddress +
+ sizeof(EFI_TE_IMAGE_HEADER) -
+ Hdr.Te->StrippedSize
+ );
+ RelocBaseEnd = (EFI_IMAGE_BASE_RELOCATION *) ((UINTN) RelocBase + (UINTN) RelocDir->Size - 1);
+ } else {
+ //
+ // Set base and end to bypass processing below.
+ //
+ RelocBase = NULL;
+ RelocBaseEnd = NULL;
+ }
}
//
@@ -621,6 +635,13 @@ GluePeCoffLoaderRelocateImage (
RelocEnd = (UINT16 *) ((CHAR8 *) RelocBase + RelocBase->SizeOfBlock);
if (!(ImageContext->IsTeImage)) {
FixupBase = PeCoffLoaderImageAddress (ImageContext, RelocBase->VirtualAddress);
+
+ if (FixupBase == NULL) {
+ //
+ // If the FixupBase address resolved to 0, then fail.
+ //
+ return RETURN_LOAD_ERROR;
+ }
} else {
FixupBase = (CHAR8 *)(UINTN)(ImageContext->ImageAddress +
RelocBase->VirtualAddress +
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.c
index d91153fbdf..30ec41769e 100644
--- a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.c
+++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2006, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.
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
@@ -152,15 +152,32 @@ GlueMakeTable (
UINT16 WordOfStart;
UINT16 WordOfCount;
-
- for (Index = 1; Index <= 16; Index++) {
+ //
+ // TableBits should not be greater than 16.
+ //
+ if (TableBits >= (sizeof (Count)/sizeof (UINT16))) {
+ return (UINT16) BAD_TABLE;
+ }
+
+ //
+ // Initialize Count array starting from Index 0, as there is a possibility of Count array being uninitialized.
+ //
+ for (Index = 0; Index <= 16; Index++) {
Count[Index] = 0;
}
for (Index = 0; Index < NumOfChar; Index++) {
- Count[BitLen[Index]]++;
+ //
+ // Count array index should not be greater than or equal to its size.
+ //
+ if (BitLen[Index] < (sizeof (Count)/sizeof (UINT16))) {
+ Count[BitLen[Index]]++;
+ } else {
+ return (UINT16) BAD_TABLE;
+ }
}
+ Start[0] = 0;
Start[1] = 0;
for (Index = 1; Index <= 16; Index++) {
@@ -201,7 +218,7 @@ GlueMakeTable (
for (Char = 0; Char < NumOfChar; Char++) {
Len = BitLen[Char];
- if (Len == 0) {
+ if (Len == 0 || Len >= 17) {
continue;
}
@@ -220,14 +237,20 @@ GlueMakeTable (
Index = (UINT16) (Len - TableBits);
while (Index != 0) {
- if (*Pointer == 0) {
+ //
+ // Avail should be lesser than size of mRight and mLeft to prevent buffer overflow.
+ //
+ if ((*Pointer == 0) && (Avail < sizeof (Sd->mRight)/sizeof (UINT16)) && (Avail < sizeof (Sd->mLeft)/sizeof (UINT16))) {
Sd->mRight[Avail] = Sd->mLeft[Avail] = 0;
*Pointer = Avail++;
}
- if (Index3 & Mask) {
+ //
+ // *Pointer should be lesser than size of mRight and mLeft to prevent buffer overflow.
+ //
+ if ((Index3 & Mask) && (*Pointer < (sizeof (Sd->mRight)/sizeof (UINT16)))) {
Pointer = &Sd->mRight[*Pointer];
- } else {
+ } else if (*Pointer < (sizeof (Sd->mLeft)/sizeof (UINT16))) {
Pointer = &Sd->mLeft[*Pointer];
}
@@ -328,6 +351,13 @@ GlueReadPTLen (
//
Number = (UINT16) GetBits (Sd, nbit);
+ if ((Number > sizeof (Sd->mPTLen)) || (nn > sizeof (Sd->mPTLen))) {
+ //
+ // Fail if Number or nn is greater than size of mPTLen
+ //
+ return (UINT16) BAD_TABLE;
+ }
+
if (Number == 0) {
//
// This represents only Huffman code used
@@ -377,6 +407,12 @@ GlueReadPTLen (
if (Index == Special) {
CharC = (UINT16) GetBits (Sd, 2);
while ((INT16) (--CharC) >= 0) {
+ if (Index >= sizeof (Sd->mPTLen)) {
+ //
+ // Fail if Index is greater than or equal to mPTLen
+ //
+ return (UINT16) BAD_TABLE;
+ }
Sd->mPTLen[Index++] = 0;
}
}
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxePerformanceLib/PerformanceLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxePerformanceLib/PerformanceLib.c
index 9c3e1366b6..5949025d2b 100644
--- a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxePerformanceLib/PerformanceLib.c
+++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxePerformanceLib/PerformanceLib.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2006, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.
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
@@ -483,6 +483,9 @@ Returns:
do {
GuidHob = (EFI_HOB_GUID_TYPE *)GlueGetNextGuidHob (&gEfiPeiPerformanceHobGuid, &HobList);
+ if (GuidHob == NULL) {
+ break;
+ }
LogHob = (EFI_HOB_GUID_DATA_PERFORMANCE_LOG *)GET_GUID_HOB_DATA (GuidHob);
for (Index = 0; Index < LogHob->NumberOfEntries; Index++) {
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/HiiLib/HiiLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/HiiLib/HiiLib.c
index 07bb0eea79..77634d906c 100644
--- a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/HiiLib/HiiLib.c
+++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/HiiLib/HiiLib.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.
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
@@ -52,6 +52,9 @@ GluePreparePackages (
HiiPackages = AllocateZeroPool (sizeof (EFI_HII_PACKAGES) + NumberOfPackages * sizeof (VOID *));
ASSERT (HiiPackages != NULL);
+ if (HiiPackages == NULL) {
+ return NULL;
+ }
HiiPackages->GuidId = (EFI_GUID *) Guid;
HiiPackages->NumberOfPackages = NumberOfPackages;
diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Decompress.c b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Decompress.c
index ff467375b0..6d09c6152e 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Decompress.c
+++ b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Decompress.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.
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
@@ -312,14 +312,32 @@ Returns:
UINT16 NextCode;
UINT16 Mask;
- for (Index = 1; Index <= 16; Index++) {
+ //
+ // TableBits should not be greater than 16.
+ //
+ if (TableBits >= (sizeof (Count)/sizeof (UINT16))) {
+ return (UINT16) BAD_TABLE;
+ }
+
+ //
+ // Initialize Count array starting from Index 0, as there is a possibility of Count array being uninitialized.
+ //
+ for (Index = 0; Index <= 16; Index++) {
Count[Index] = 0;
}
for (Index = 0; Index < NumOfChar; Index++) {
- Count[BitLen[Index]]++;
+ //
+ // Count array index should not be greater than or equal to its size.
+ //
+ if (BitLen[Index] < (sizeof (Count)/sizeof (UINT16))) {
+ Count[BitLen[Index]]++;
+ } else {
+ return (UINT16) BAD_TABLE;
+ }
}
+ Start[0] = 0;
Start[1] = 0;
for (Index = 1; Index <= 16; Index++) {
@@ -358,7 +376,7 @@ Returns:
for (Char = 0; Char < NumOfChar; Char++) {
Len = BitLen[Char];
- if (Len == 0) {
+ if (Len == 0 || Len >= 17) {
continue;
}
@@ -377,14 +395,20 @@ Returns:
Index = (UINT16) (Len - TableBits);
while (Index != 0) {
- if (*Pointer == 0) {
+ //
+ // Avail should be lesser than size of mRight and mLeft to prevent buffer overflow.
+ //
+ if ((*Pointer == 0) && (Avail < sizeof (Sd->mRight)/sizeof (UINT16)) && (Avail < sizeof (Sd->mLeft)/sizeof (UINT16))) {
Sd->mRight[Avail] = Sd->mLeft[Avail] = 0;
*Pointer = Avail++;
}
- if (Index3 & Mask) {
+ //
+ // *Pointer should be lesser than size of mRight and mLeft to prevent buffer overflow.
+ //
+ if ((Index3 & Mask) && (*Pointer < (sizeof (Sd->mRight)/sizeof (UINT16)))) {
Pointer = &Sd->mRight[*Pointer];
- } else {
+ } else if (*Pointer < (sizeof (Sd->mLeft)/sizeof (UINT16))) {
Pointer = &Sd->mLeft[*Pointer];
}
@@ -493,6 +517,13 @@ Returns:
Number = (UINT16) GetBits (Sd, nbit);
+ if ((Number > sizeof (Sd->mPTLen)) || (nn > sizeof (Sd->mPTLen))) {
+ //
+ // Fail if Number or nn is greater than size of mPTLen
+ //
+ return (UINT16) BAD_TABLE;
+ }
+
if (Number == 0) {
CharC = (UINT16) GetBits (Sd, nbit);
@@ -528,6 +559,12 @@ Returns:
if (Index == Special) {
CharC = (UINT16) GetBits (Sd, 2);
while ((INT16) (--CharC) >= 0) {
+ if (Index >= sizeof (Sd->mPTLen)) {
+ //
+ // Fail if Index is greater than or equal to mPTLen
+ //
+ return (UINT16) BAD_TABLE;
+ }
Sd->mPTLen[Index++] = 0;
}
}
diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/PeCoffLoader.c b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/PeCoffLoader.c
index 68c4e96e8d..bc4ca8ee66 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/PeCoffLoader.c
+++ b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/PeCoffLoader.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2005 - 2007, Intel Corporation. All rights reserved.
+Copyright (c) 2005 - 2010, Intel Corporation. All rights reserved.
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
@@ -785,12 +785,18 @@ Returns:
// the optional header to verify a desired directory entry is there.
//
- if (NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC) {
+ if (NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC && RelocDir->Size > 0) {
RelocBase = PeCoffLoaderImageAddress (ImageContext, RelocDir->VirtualAddress);
RelocBaseEnd = PeCoffLoaderImageAddress (
ImageContext,
RelocDir->VirtualAddress + RelocDir->Size - 1
);
+ if ((RelocBase == NULL) || (RelocBaseEnd == NULL)) {
+ //
+ // If the base start or end address resolved to 0, then fail.
+ //
+ return EFI_LOAD_ERROR;
+ }
} else {
//
// Set base and end to bypass processing below.
@@ -806,13 +812,21 @@ Returns:
// Find the relocation block
//
RelocDir = &Hdr.Te->DataDirectory[0];
- RelocBase = (EFI_IMAGE_BASE_RELOCATION *)(UINTN)(
- ImageContext->ImageAddress +
- RelocDir->VirtualAddress +
- sizeof(EFI_TE_IMAGE_HEADER) -
- Hdr.Te->StrippedSize
- );
- RelocBaseEnd = (EFI_IMAGE_BASE_RELOCATION *) ((UINTN) RelocBase + (UINTN) RelocDir->Size - 1);
+ if (RelocDir->Size > 0) {
+ RelocBase = (EFI_IMAGE_BASE_RELOCATION *)(UINTN)(
+ ImageContext->ImageAddress +
+ RelocDir->VirtualAddress +
+ sizeof(EFI_TE_IMAGE_HEADER) -
+ Hdr.Te->StrippedSize
+ );
+ RelocBaseEnd = (EFI_IMAGE_BASE_RELOCATION *) ((UINTN) RelocBase + (UINTN) RelocDir->Size - 1);
+ } else {
+ //
+ // Set base and end to bypass processing below.
+ //
+ RelocBase = NULL;
+ RelocBaseEnd = NULL;
+ }
}
//
@@ -825,6 +839,13 @@ Returns:
RelocEnd = (UINT16 *) ((CHAR8 *) RelocBase + RelocBase->SizeOfBlock);
if (!(ImageContext->IsTeImage)) {
FixupBase = PeCoffLoaderImageAddress (ImageContext, RelocBase->VirtualAddress);
+
+ if (FixupBase == NULL) {
+ //
+ // If the FixupBase address resolved to 0, then fail.
+ //
+ return EFI_LOAD_ERROR;
+ }
} else {
FixupBase = (CHAR8 *)(UINTN)(ImageContext->ImageAddress +
RelocBase->VirtualAddress +
diff --git a/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Debug.c b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Debug.c
index cc903cfd67..ce5f049039 100644
--- a/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Debug.c
+++ b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Debug.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.
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
@@ -66,9 +66,9 @@ Returns:
);
//
- // Put break point in module that contained the error.
+ // Put dead loop in module that contained the error.
//
- EFI_BREAKPOINT ();
+ EFI_DEADLOOP ();
}
VOID
diff --git a/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ipf/RuntimeLib.c b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ipf/RuntimeLib.c
index cd548dac2a..2e63672582 100644
--- a/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ipf/RuntimeLib.c
+++ b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ipf/RuntimeLib.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2005, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.
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
@@ -947,6 +947,7 @@ Returns:
EFI_GUID Guid = EFI_EXTENDED_SAL_BASE_IO_SERVICES_PROTOCOL_GUID;
ReturnReg = EfiCallEsalService (&Guid, IoRead, (UINT64) Width, Address, Count, (UINT64) Buffer, 0, 0, 0);
+ ASSERT (ReturnReg.Status == EFI_SAL_SUCCESS);
return ReturnReg.Status;
@@ -1015,6 +1016,7 @@ Returns:
EFI_GUID Guid = EFI_EXTENDED_SAL_BASE_IO_SERVICES_PROTOCOL_GUID;
ReturnReg = EfiCallEsalService (&Guid, MemRead, (UINT64) Width, Address, Count, (UINT64) Buffer, 0, 0, 0);
+ ASSERT (ReturnReg.Status == EFI_SAL_SUCCESS);
return ReturnReg.Status;
diff --git a/EdkCompatibilityPkg/Sample/Platform/Generic/MonoStatusCode/Library/Pei/MemoryStatusCode/MemoryStatusCode.c b/EdkCompatibilityPkg/Sample/Platform/Generic/MonoStatusCode/Library/Pei/MemoryStatusCode/MemoryStatusCode.c
index c15a930075..dd4128f365 100644
--- a/EdkCompatibilityPkg/Sample/Platform/Generic/MonoStatusCode/Library/Pei/MemoryStatusCode/MemoryStatusCode.c
+++ b/EdkCompatibilityPkg/Sample/Platform/Generic/MonoStatusCode/Library/Pei/MemoryStatusCode/MemoryStatusCode.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.
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
@@ -289,8 +289,7 @@ Returns:
&mPpiListStatusCode
);
if (EFI_ERROR (Status)) {
- EFI_BREAKPOINT ();
- return ;
+ EFI_DEADLOOP ();
}
//
// Publish a GUIDed HOB that contains a pointer to the status code PPI
@@ -306,8 +305,7 @@ Returns:
sizeof (VOID *)
);
if (EFI_ERROR (Status)) {
- EFI_BREAKPOINT ();
- return ;
+ EFI_DEADLOOP ();
}
}
}
diff --git a/EdkCompatibilityPkg/Sample/Platform/Generic/RuntimeDxe/StatusCode/Lib/BsSerialStatusCode/BsSerialStatusCode.c b/EdkCompatibilityPkg/Sample/Platform/Generic/RuntimeDxe/StatusCode/Lib/BsSerialStatusCode/BsSerialStatusCode.c
index ed96cfbb03..15603cb645 100644
--- a/EdkCompatibilityPkg/Sample/Platform/Generic/RuntimeDxe/StatusCode/Lib/BsSerialStatusCode/BsSerialStatusCode.c
+++ b/EdkCompatibilityPkg/Sample/Platform/Generic/RuntimeDxe/StatusCode/Lib/BsSerialStatusCode/BsSerialStatusCode.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.
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
@@ -2073,8 +2073,8 @@ Returns:
{
UINTN Current;
- ASSERT (Table);
- ASSERT (Token);
+ ASSERT (Table != NULL);
+ ASSERT (Token != NULL);
Current = 0;
*Token = 0;
diff --git a/EdkCompatibilityPkg/Sample/Platform/Generic/RuntimeDxe/StatusCode/Lib/RtMemoryStatusCode/RtMemoryStatusCode.c b/EdkCompatibilityPkg/Sample/Platform/Generic/RuntimeDxe/StatusCode/Lib/RtMemoryStatusCode/RtMemoryStatusCode.c
index d4c41961f5..9ee89b6071 100644
--- a/EdkCompatibilityPkg/Sample/Platform/Generic/RuntimeDxe/StatusCode/Lib/RtMemoryStatusCode/RtMemoryStatusCode.c
+++ b/EdkCompatibilityPkg/Sample/Platform/Generic/RuntimeDxe/StatusCode/Lib/RtMemoryStatusCode/RtMemoryStatusCode.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2006, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.
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
@@ -124,6 +124,7 @@ Returns:
// Locate the HOB that contains the PPI structure for the memory journal
// We don't check for more than one.
//
+ StatusCodeMemoryPpi = NULL;
EfiLibGetSystemConfigurationTable (
&gEfiHobListGuid,
&HobList
@@ -134,7 +135,7 @@ Returns:
(VOID **) &StatusCodeMemoryPpi,
NULL
);
- if (EFI_ERROR (Status)) {
+ if (EFI_ERROR (Status) || (StatusCodeMemoryPpi == NULL)) {
return ;
}
//
diff --git a/EdkCompatibilityPkg/Sample/Platform/Generic/RuntimeDxe/StatusCode/Lib/RtPlatformStatusCode/Nt32/RtPlatformStatusCode.c b/EdkCompatibilityPkg/Sample/Platform/Generic/RuntimeDxe/StatusCode/Lib/RtPlatformStatusCode/Nt32/RtPlatformStatusCode.c
index 9ec2198d35..f4c6426394 100644
--- a/EdkCompatibilityPkg/Sample/Platform/Generic/RuntimeDxe/StatusCode/Lib/RtPlatformStatusCode/Nt32/RtPlatformStatusCode.c
+++ b/EdkCompatibilityPkg/Sample/Platform/Generic/RuntimeDxe/StatusCode/Lib/RtPlatformStatusCode/Nt32/RtPlatformStatusCode.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2006, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.
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
@@ -133,11 +133,11 @@ Returns:
// is connected.
//
mPeiReportStatusCode = NULL;
-
+ Pointer = NULL;
Status = EfiLibGetSystemConfigurationTable (&gEfiHobListGuid, &HobList);
if (!EFI_ERROR (Status)) {
Status = GetNextGuidHob (&HobList, &gEfiStatusCodeRuntimeProtocolGuid, &Pointer, NULL);
- if (!EFI_ERROR (Status)) {
+ if (!EFI_ERROR (Status) && (Pointer != NULL)) {
mPeiReportStatusCode = (EFI_REPORT_STATUS_CODE) (*(UINTN *) Pointer);
}
}