summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>2011-04-19 01:41:46 +0000
committervanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>2011-04-19 01:41:46 +0000
commit0d18fb2565ec66a35dbe6fce0df267f23c8ef9f0 (patch)
treef727f0a6fb62180daa53d6c48231007c36d31c92
parent832b5d6a42ad122cf6a8405b9bc4d8c23a4538b6 (diff)
downloadedk2-0d18fb2565ec66a35dbe6fce0df267f23c8ef9f0.zip
edk2-0d18fb2565ec66a35dbe6fce0df267f23c8ef9f0.tar.gz
edk2-0d18fb2565ec66a35dbe6fce0df267f23c8ef9f0.tar.bz2
sync patch r10863, r10396, r10864, r10873 from main trunk.
Add security check to make code run safe. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/branches/UDK2010@11554 6f19259b-4bc3-4df7-8a09-765794883524
-rw-r--r--EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/Forms.c1
-rw-r--r--EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/OpcodeCreation.c18
-rw-r--r--EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/UefiIfrParser.c10
-rw-r--r--EdkCompatibilityPkg/Foundation/Efi/Include/EfiDevicePath.h2
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/Debug.c4
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/Perf.c12
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Dxe/EfiIfrSupportLib/IfrOpCodeCreation.c26
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Graphics.c6
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Print.c31
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Unicode/Sprint.c8
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Graphics.c6
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Print.c31
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Unicode/Sprint.c8
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Dxe/Hob/Hob.c27
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Dxe/Print/Unicode/SPrint.c8
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Dxe/PrintLite/Unicode/SPrint.c8
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrCommon.c6
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrOpCodeCreation.c26
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrString.c9
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/GetPowerOfTwo64.c2
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DivS64x64Remainder.c4
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/MultS64x64.c2
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SynchronizationMsc.c2
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/BasePeCoff.c39
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/PrintLib.c2
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.c54
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxePerformanceLib/PerformanceLib.c5
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c2
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/HiiLib/HiiLib.c5
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiHobLib/HobLib.c16
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiReportStatusCodeLib/ReportStatusCodeLib.c2
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/SmmRuntimeDxeReportStatusCodeLib/SmmRuntimeDxeSupport.c2
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/ReportStatusCode.c2
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Pei/Hob/PeiHobLib.c22
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Decompress.c51
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/PeCoffLoader.c39
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Debug.c6
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Io.c9
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ipf/RuntimeLib.c4
-rw-r--r--EdkCompatibilityPkg/Sample/Platform/Generic/MonoStatusCode/Library/Pei/MemoryStatusCode/MemoryStatusCode.c8
-rw-r--r--EdkCompatibilityPkg/Sample/Platform/Generic/RuntimeDxe/StatusCode/Lib/BsSerialStatusCode/BsSerialStatusCode.c6
-rw-r--r--EdkCompatibilityPkg/Sample/Platform/Generic/RuntimeDxe/StatusCode/Lib/RtMemoryStatusCode/RtMemoryStatusCode.c5
-rw-r--r--EdkCompatibilityPkg/Sample/Platform/Generic/RuntimeDxe/StatusCode/Lib/RtPlatformStatusCode/Nt32/RtPlatformStatusCode.c6
43 files changed, 364 insertions, 178 deletions
diff --git a/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/Forms.c b/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/Forms.c
index bf05852..c26862e 100644
--- a/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/Forms.c
+++ b/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/Forms.c
@@ -570,6 +570,7 @@ HiiThunkUpdateForm (
if (Data->DataCount != 0) {
ThunkContext = UefiHiiHandleToThunkContext (Private, UefiHiiHandle);
+ ASSERT (ThunkContext != NULL);
Status = FwUpdateDataToUefiUpdateData (ThunkContext, Data, StartOpCodeHandle);
ASSERT_EFI_ERROR (Status);
diff --git a/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/OpcodeCreation.c b/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/OpcodeCreation.c
index 0692c2a..b064e37 100644
--- a/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/OpcodeCreation.c
+++ b/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/OpcodeCreation.c
@@ -193,7 +193,7 @@ F2UCreateTextOpCode (
ZeroMem (&UTextOpCode, sizeof(UTextOpCode));
UTextOpCode.Header.OpCode = EFI_IFR_TEXT_OP;
- UTextOpCode.Header.Length = sizeof (EFI_IFR_TEXT);
+ UTextOpCode.Header.Length = (UINT8) sizeof (EFI_IFR_TEXT);
UTextOpCode.Statement.Help = FwOpcode->Help;
@@ -229,7 +229,7 @@ F2UCreateReferenceOpCode (
ZeroMem (&UOpcode, sizeof(UOpcode));
- UOpcode.Header.Length = sizeof(UOpcode);
+ UOpcode.Header.Length = (UINT8) sizeof (UOpcode);
UOpcode.Header.OpCode = EFI_IFR_REF_OP;
UOpcode.Question.Header.Prompt = FwOpcode->Prompt;
@@ -269,7 +269,7 @@ F2UCreateOneOfOptionOpCode (
ZeroMem (&UOpcode, sizeof(UOpcode));
- UOpcode.Header.Length = sizeof(UOpcode);
+ UOpcode.Header.Length = (UINT8) sizeof (UOpcode);
UOpcode.Header.OpCode = EFI_IFR_ONE_OF_OPTION_OP;
UOpcode.Option = FwOpcode->Option;
@@ -374,7 +374,7 @@ F2UCreateOneOfOpCode (
ZeroMem (&UOpcode, sizeof(UOpcode));
*OpcodeCount = 0;
- UOpcode.Header.Length = sizeof(UOpcode);
+ UOpcode.Header.Length = (UINT8) sizeof (UOpcode);
UOpcode.Header.OpCode = EFI_IFR_ONE_OF_OP;
UOpcode.Header.Scope = 1;
@@ -491,7 +491,7 @@ F2UCreateOrderedListOpCode (
ZeroMem (&UOpcode, sizeof(UOpcode));
*OpcodeCount = 0;
- UOpcode.Header.Length = sizeof(UOpcode);
+ UOpcode.Header.Length = (UINT8) sizeof (UOpcode);
UOpcode.Header.OpCode = EFI_IFR_ORDERED_LIST_OP;
UOpcode.Header.Scope = 1;
@@ -587,7 +587,7 @@ F2UCreateCheckBoxOpCode (
ZeroMem (&UOpcode, sizeof(UOpcode));
- UOpcode.Header.Length = sizeof(UOpcode);
+ UOpcode.Header.Length = (UINT8) sizeof (UOpcode);
UOpcode.Header.OpCode = EFI_IFR_CHECKBOX_OP;
UOpcode.Question.Header.Prompt = FwOpcode->Prompt;
@@ -667,7 +667,7 @@ F2UCreateNumericOpCode (
UOpcode.Question.QuestionId = FwOpcode->Key;
}
- UOpcode.Header.Length = sizeof(UOpcode);
+ UOpcode.Header.Length = (UINT8) sizeof (UOpcode);
UOpcode.Header.OpCode = EFI_IFR_NUMERIC_OP;
//
// We need to create a nested default value for the UEFI Numeric Opcode.
@@ -717,7 +717,7 @@ F2UCreateNumericOpCode (
// We need to create a default value.
//
ZeroMem (&UOpcodeDefault, sizeof (UOpcodeDefault));
- UOpcodeDefault.Header.Length = sizeof (UOpcodeDefault);
+ UOpcodeDefault.Header.Length = (UINT8) sizeof (UOpcodeDefault);
UOpcodeDefault.Header.OpCode = EFI_IFR_DEFAULT_OP;
UOpcodeDefault.DefaultId = 0;
@@ -786,7 +786,7 @@ F2UCreateStringOpCode (
UOpcode.Question.QuestionId = FwOpcode->Key;
}
- UOpcode.Header.Length = sizeof(UOpcode);
+ UOpcode.Header.Length = (UINT8) sizeof (UOpcode);
UOpcode.Header.OpCode = EFI_IFR_STRING_OP;
UOpcode.Question.Header.Prompt = FwOpcode->Prompt;
diff --git a/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/UefiIfrParser.c b/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/UefiIfrParser.c
index d425c36..5b37999 100644
--- a/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/UefiIfrParser.c
+++ b/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/UefiIfrParser.c
@@ -805,7 +805,7 @@ ParseOpCodes (
CurrentStatement->Minimum = ((EFI_IFR_NUMERIC *) OpCodeData)->data.u8.MinValue;
CurrentStatement->Maximum = ((EFI_IFR_NUMERIC *) OpCodeData)->data.u8.MaxValue;
CurrentStatement->Step = ((EFI_IFR_NUMERIC *) OpCodeData)->data.u8.Step;
- CurrentStatement->StorageWidth = sizeof (UINT8);
+ CurrentStatement->StorageWidth = (UINT16) sizeof (UINT8);
Value->Type = EFI_IFR_TYPE_NUM_SIZE_8;
break;
@@ -813,7 +813,7 @@ ParseOpCodes (
CopyMem (&CurrentStatement->Minimum, &((EFI_IFR_NUMERIC *) OpCodeData)->data.u16.MinValue, sizeof (UINT16));
CopyMem (&CurrentStatement->Maximum, &((EFI_IFR_NUMERIC *) OpCodeData)->data.u16.MaxValue, sizeof (UINT16));
CopyMem (&CurrentStatement->Step, &((EFI_IFR_NUMERIC *) OpCodeData)->data.u16.Step, sizeof (UINT16));
- CurrentStatement->StorageWidth = sizeof (UINT16);
+ CurrentStatement->StorageWidth = (UINT16) sizeof (UINT16);
Value->Type = EFI_IFR_TYPE_NUM_SIZE_16;
break;
@@ -821,7 +821,7 @@ ParseOpCodes (
CopyMem (&CurrentStatement->Minimum, &((EFI_IFR_NUMERIC *) OpCodeData)->data.u32.MinValue, sizeof (UINT32));
CopyMem (&CurrentStatement->Maximum, &((EFI_IFR_NUMERIC *) OpCodeData)->data.u32.MaxValue, sizeof (UINT32));
CopyMem (&CurrentStatement->Step, &((EFI_IFR_NUMERIC *) OpCodeData)->data.u32.Step, sizeof (UINT32));
- CurrentStatement->StorageWidth = sizeof (UINT32);
+ CurrentStatement->StorageWidth = (UINT16) sizeof (UINT32);
Value->Type = EFI_IFR_TYPE_NUM_SIZE_32;
break;
@@ -829,7 +829,7 @@ ParseOpCodes (
CopyMem (&CurrentStatement->Minimum, &((EFI_IFR_NUMERIC *) OpCodeData)->data.u64.MinValue, sizeof (UINT64));
CopyMem (&CurrentStatement->Maximum, &((EFI_IFR_NUMERIC *) OpCodeData)->data.u64.MaxValue, sizeof (UINT64));
CopyMem (&CurrentStatement->Step, &((EFI_IFR_NUMERIC *) OpCodeData)->data.u64.Step, sizeof (UINT64));
- CurrentStatement->StorageWidth = sizeof (UINT64);
+ CurrentStatement->StorageWidth = (UINT16) sizeof (UINT64);
Value->Type = EFI_IFR_TYPE_NUM_SIZE_64;
break;
@@ -866,7 +866,7 @@ ParseOpCodes (
ASSERT (CurrentStatement != NULL);
CurrentStatement->Flags = ((EFI_IFR_CHECKBOX *) OpCodeData)->Flags;
- CurrentStatement->StorageWidth = sizeof (BOOLEAN);
+ CurrentStatement->StorageWidth = (UINT16) sizeof (BOOLEAN);
CurrentStatement->HiiValue.Type = EFI_IFR_TYPE_BOOLEAN;
break;
diff --git a/EdkCompatibilityPkg/Foundation/Efi/Include/EfiDevicePath.h b/EdkCompatibilityPkg/Foundation/Efi/Include/EfiDevicePath.h
index 6b25f5f..de0c340 100644
--- a/EdkCompatibilityPkg/Foundation/Efi/Include/EfiDevicePath.h
+++ b/EdkCompatibilityPkg/Foundation/Efi/Include/EfiDevicePath.h
@@ -58,7 +58,7 @@ Abstract:
#define SetDevicePathEndNode(a) { \
(a)->Type = END_DEVICE_PATH_TYPE; \
(a)->SubType = END_ENTIRE_DEVICE_PATH_SUBTYPE; \
- (a)->Length[0] = sizeof(EFI_DEVICE_PATH_PROTOCOL); \
+ (a)->Length[0] = (UINT8) sizeof (EFI_DEVICE_PATH_PROTOCOL); \
(a)->Length[1] = 0; \
}
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/Debug.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/Debug.c
index 9824cd8..0337669 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
+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 1c2b8b3..049a33a 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
+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/EfiIfrSupportLib/IfrOpCodeCreation.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiIfrSupportLib/IfrOpCodeCreation.c
index a4be883..7de6644 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiIfrSupportLib/IfrOpCodeCreation.c
+++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiIfrSupportLib/IfrOpCodeCreation.c
@@ -51,7 +51,7 @@ Returns:
EFI_IFR_SUBTITLE Subtitle;
Subtitle.Header.OpCode = EFI_IFR_SUBTITLE_OP;
- Subtitle.Header.Length = sizeof (EFI_IFR_SUBTITLE);
+ Subtitle.Header.Length = (UINT8) sizeof (EFI_IFR_SUBTITLE);
Subtitle.SubTitle = StringToken;
EfiCopyMem (FormBuffer, &Subtitle, sizeof (EFI_IFR_SUBTITLE));
@@ -100,7 +100,7 @@ Returns:
EFI_IFR_TEXT Text;
Text.Header.OpCode = EFI_IFR_TEXT_OP;
- Text.Header.Length = sizeof (EFI_IFR_TEXT);
+ Text.Header.Length = (UINT8) sizeof (EFI_IFR_TEXT);
Text.Text = StringToken;
Text.TextTwo = StringTokenTwo;
@@ -155,7 +155,7 @@ Returns:
EFI_IFR_REF Hyperlink;
Hyperlink.Header.OpCode = EFI_IFR_REF_OP;
- Hyperlink.Header.Length = sizeof (EFI_IFR_REF);
+ Hyperlink.Header.Length = (UINT8) sizeof (EFI_IFR_REF);
Hyperlink.FormId = FormId;
Hyperlink.Prompt = StringToken;
Hyperlink.Help = StringTokenTwo;
@@ -228,7 +228,7 @@ Returns:
}
OneOf.Header.OpCode = EFI_IFR_ONE_OF_OP;
- OneOf.Header.Length = sizeof (EFI_IFR_ONE_OF);
+ OneOf.Header.Length = (UINT8) sizeof (EFI_IFR_ONE_OF);
OneOf.QuestionId = QuestionId;
OneOf.Width = DataWidth;
OneOf.Prompt = PromptToken;
@@ -243,7 +243,7 @@ Returns:
for (Index = 0; Index < OptionCount; Index++) {
OneOfOption.Header.OpCode = EFI_IFR_ONE_OF_OPTION_OP;
- OneOfOption.Header.Length = sizeof (EFI_IFR_ONE_OF_OPTION);
+ OneOfOption.Header.Length = (UINT8) sizeof (EFI_IFR_ONE_OF_OPTION);
OneOfOption.Option = OptionsList[Index].StringToken;
OneOfOption.Value = OptionsList[Index].Value;
@@ -255,7 +255,7 @@ Returns:
LocalBuffer = (UINT8 *) (LocalBuffer + sizeof (EFI_IFR_ONE_OF_OPTION));
}
- EndOneOf.Header.Length = sizeof (EFI_IFR_END_ONE_OF);
+ EndOneOf.Header.Length = (UINT8) sizeof (EFI_IFR_END_ONE_OF);
EndOneOf.Header.OpCode = EFI_IFR_END_ONE_OF_OP;
EfiCopyMem (LocalBuffer, &EndOneOf, sizeof (EFI_IFR_END_ONE_OF));
@@ -316,7 +316,7 @@ Returns:
UINT8 *LocalBuffer;
OrderedList.Header.OpCode = EFI_IFR_ORDERED_LIST_OP;
- OrderedList.Header.Length = sizeof (EFI_IFR_ORDERED_LIST);
+ OrderedList.Header.Length = (UINT8) sizeof (EFI_IFR_ORDERED_LIST);
OrderedList.QuestionId = QuestionId;
OrderedList.MaxEntries = MaxEntries;
OrderedList.Prompt = PromptToken;
@@ -331,7 +331,7 @@ Returns:
for (Index = 0; Index < OptionCount; Index++) {
OrderedListOption.Header.OpCode = EFI_IFR_ONE_OF_OPTION_OP;
- OrderedListOption.Header.Length = sizeof (EFI_IFR_ONE_OF_OPTION);
+ OrderedListOption.Header.Length = (UINT8) sizeof (EFI_IFR_ONE_OF_OPTION);
OrderedListOption.Option = OptionsList[Index].StringToken;
OrderedListOption.Value = OptionsList[Index].Value;
@@ -343,7 +343,7 @@ Returns:
LocalBuffer = (UINT8 *) (LocalBuffer + sizeof (EFI_IFR_ONE_OF_OPTION));
}
- EndOrderedList.Header.Length = sizeof (EFI_IFR_END_ONE_OF);
+ EndOrderedList.Header.Length = (UINT8) sizeof (EFI_IFR_END_ONE_OF);
EndOrderedList.Header.OpCode = EFI_IFR_END_ONE_OF_OP;
EfiCopyMem (LocalBuffer, &EndOrderedList, sizeof (EFI_IFR_END_ONE_OF));
@@ -406,7 +406,7 @@ Returns:
}
CheckBox.Header.OpCode = EFI_IFR_CHECKBOX_OP;
- CheckBox.Header.Length = sizeof (EFI_IFR_CHECK_BOX);
+ CheckBox.Header.Length = (UINT8) sizeof (EFI_IFR_CHECK_BOX);
CheckBox.QuestionId = QuestionId;
CheckBox.Width = DataWidth;
CheckBox.Prompt = PromptToken;
@@ -486,7 +486,7 @@ Returns:
}
Numeric.Header.OpCode = EFI_IFR_NUMERIC_OP;
- Numeric.Header.Length = sizeof (EFI_IFR_NUMERIC);
+ Numeric.Header.Length = (UINT8) sizeof (EFI_IFR_NUMERIC);
Numeric.QuestionId = QuestionId;
Numeric.Width = DataWidth;
Numeric.Prompt = PromptToken;
@@ -555,7 +555,7 @@ Returns:
EFI_IFR_STRING String;
String.Header.OpCode = EFI_IFR_STRING_OP;
- String.Header.Length = sizeof (EFI_IFR_STRING);
+ String.Header.Length = (UINT8) sizeof (EFI_IFR_STRING);
String.QuestionId = QuestionId;
String.Width = DataWidth;
String.Prompt = PromptToken;
@@ -604,7 +604,7 @@ Returns:
EFI_IFR_BANNER Banner;
Banner.Header.OpCode = EFI_IFR_BANNER_OP;
- Banner.Header.Length = sizeof (EFI_IFR_BANNER);
+ Banner.Header.Length = (UINT8) sizeof (EFI_IFR_BANNER);
EfiCopyMem (&Banner.Title, &Title, sizeof (UINT16));
EfiCopyMem (&Banner.LineNumber, &LineNumber, sizeof (UINT16));
Banner.Alignment = Alignment;
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Graphics.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Graphics.c
index 0844a6f..fc86b90 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
+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 2ed4eec..618d124 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
+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
--*/
{
@@ -189,9 +188,10 @@ Returns:
//
// For now, allocate an arbitrarily long buffer
//
+ BufferLen = 0;
Buffer = EfiLibAllocateZeroPool (0x10000);
if (Buffer == NULL) {
- return EFI_OUT_OF_RESOURCES;
+ return 0;
}
if (GraphicsOutput != NULL) {
@@ -371,10 +371,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;
}
@@ -424,14 +429,15 @@ Returns:
Handle = gST->ConsoleOutHandle;
+ GraphicsOutput = NULL;
+ UgaDraw = NULL;
Status = gBS->HandleProtocol (
Handle,
&gEfiGraphicsOutputProtocolGuid,
(VOID**)&GraphicsOutput
);
- UgaDraw = NULL;
- if (EFI_ERROR (Status)) {
+ if (EFI_ERROR (Status) || (GraphicsOutput == NULL)) {
GraphicsOutput = NULL;
Status = gBS->HandleProtocol (
@@ -440,19 +446,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 6b70aa6..12ee9ef 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
+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 739c735..d6d7005 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
+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 29da267..30931ed 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
+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
--*/
{
@@ -156,9 +155,10 @@ Returns:
//
// For now, allocate an arbitrarily long buffer
//
+ BufferLen = 0;
Buffer = EfiLibAllocateZeroPool (0x10000);
if (Buffer == NULL) {
- return EFI_OUT_OF_RESOURCES;
+ return 0;
}
if (GraphicsOutput != NULL) {
@@ -337,10 +337,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;
}
@@ -390,14 +395,15 @@ Returns:
Handle = gST->ConsoleOutHandle;
+ GraphicsOutput = NULL;
+ UgaDraw = NULL;
Status = gBS->HandleProtocol (
Handle,
&gEfiGraphicsOutputProtocolGuid,
(VOID **) &GraphicsOutput
);
- UgaDraw = NULL;
- if (EFI_ERROR (Status)) {
+ if (EFI_ERROR (Status) || (GraphicsOutput == NULL)) {
GraphicsOutput = NULL;
Status = gBS->HandleProtocol (
@@ -406,19 +412,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 6b70aa6..12ee9ef 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
+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 6bae74c..9754e14 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
+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 6b70aa6..12ee9ef 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
+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 6b70aa6..12ee9ef 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
+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 91548c4..05c78b0 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
+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/UefiIfrOpCodeCreation.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrOpCodeCreation.c
index 5646326..4fe7a06 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrOpCodeCreation.c
+++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrOpCodeCreation.c
@@ -84,7 +84,7 @@ CreateEndOpCode (
return EFI_BUFFER_TOO_SMALL;
}
- End.Header.Length = sizeof (EFI_IFR_END);
+ End.Header.Length = (UINT8) sizeof (EFI_IFR_END);
End.Header.OpCode = EFI_IFR_END_OP;
End.Header.Scope = 0;
@@ -116,7 +116,7 @@ CreateDefaultOpCode (
}
Default.Header.OpCode = EFI_IFR_DEFAULT_OP;
- Default.Header.Length = sizeof (EFI_IFR_DEFAULT);
+ Default.Header.Length = (UINT8) sizeof (EFI_IFR_DEFAULT);
Default.Header.Scope = 0;
Default.Type = Type;
Default.DefaultId = EFI_HII_DEFAULT_CLASS_STANDARD;
@@ -153,7 +153,7 @@ CreateActionOpCode (
}
Action.Header.OpCode = EFI_IFR_ACTION_OP;
- Action.Header.Length = sizeof (EFI_IFR_ACTION);
+ Action.Header.Length = (UINT8) sizeof (EFI_IFR_ACTION);
Action.Header.Scope = 0;
Action.Question.QuestionId = QuestionId;
Action.Question.Header.Prompt = Prompt;
@@ -188,7 +188,7 @@ CreateSubTitleOpCode (
}
Subtitle.Header.OpCode = EFI_IFR_SUBTITLE_OP;
- Subtitle.Header.Length = sizeof (EFI_IFR_SUBTITLE);
+ Subtitle.Header.Length = (UINT8) sizeof (EFI_IFR_SUBTITLE);
Subtitle.Header.Scope = Scope;
Subtitle.Statement.Prompt = Prompt;
Subtitle.Statement.Help = Help;
@@ -220,7 +220,7 @@ CreateTextOpCode (
}
Text.Header.OpCode = EFI_IFR_TEXT_OP;
- Text.Header.Length = sizeof (EFI_IFR_TEXT);
+ Text.Header.Length = (UINT8) sizeof (EFI_IFR_TEXT);
Text.Header.Scope = 0;
Text.Statement.Prompt = Prompt;
Text.Statement.Help = Help;
@@ -257,7 +257,7 @@ CreateGotoOpCode (
}
Goto.Header.OpCode = EFI_IFR_REF_OP;
- Goto.Header.Length = sizeof (EFI_IFR_REF);
+ Goto.Header.Length = (UINT8) sizeof (EFI_IFR_REF);
Goto.Header.Scope = 0;
Goto.Question.Header.Prompt = Prompt;
Goto.Question.Header.Help = Help;
@@ -297,7 +297,7 @@ CreateOneOfOptionOpCode (
for (Index = 0; Index < OptionCount; Index++) {
OneOfOption.Header.OpCode = EFI_IFR_ONE_OF_OPTION_OP;
- OneOfOption.Header.Length = sizeof (EFI_IFR_ONE_OF_OPTION);
+ OneOfOption.Header.Length = (UINT8) sizeof (EFI_IFR_ONE_OF_OPTION);
OneOfOption.Header.Scope = 0;
OneOfOption.Option = OptionsList[Index].StringToken;
@@ -345,7 +345,7 @@ CreateOneOfOpCode (
}
OneOf.Header.OpCode = EFI_IFR_ONE_OF_OP;
- OneOf.Header.Length = sizeof (EFI_IFR_ONE_OF);
+ OneOf.Header.Length = (UINT8) sizeof (EFI_IFR_ONE_OF);
OneOf.Header.Scope = 1;
OneOf.Question.Header.Prompt = Prompt;
OneOf.Question.Header.Help = Help;
@@ -406,7 +406,7 @@ CreateOrderedListOpCode (
}
OrderedList.Header.OpCode = EFI_IFR_ORDERED_LIST_OP;
- OrderedList.Header.Length = sizeof (EFI_IFR_ORDERED_LIST);
+ OrderedList.Header.Length = (UINT8) sizeof (EFI_IFR_ORDERED_LIST);
OrderedList.Header.Scope = 1;
OrderedList.Question.Header.Prompt = Prompt;
OrderedList.Question.Header.Help = Help;
@@ -454,7 +454,7 @@ CreateCheckBoxOpCode (
}
CheckBox.Header.OpCode = EFI_IFR_CHECKBOX_OP;
- CheckBox.Header.Length = sizeof (EFI_IFR_CHECKBOX);
+ CheckBox.Header.Length = (UINT8) sizeof (EFI_IFR_CHECKBOX);
CheckBox.Header.Scope = 0;
CheckBox.Question.QuestionId = QuestionId;
CheckBox.Question.VarStoreId = VarStoreId;
@@ -506,7 +506,7 @@ CreateNumericOpCode (
}
Numeric.Header.OpCode = EFI_IFR_NUMERIC_OP;
- Numeric.Header.Length = sizeof (EFI_IFR_NUMERIC);
+ Numeric.Header.Length = (UINT8) sizeof (EFI_IFR_NUMERIC);
Numeric.Header.Scope = 1;
Numeric.Question.QuestionId = QuestionId;
Numeric.Question.VarStoreId = VarStoreId;
@@ -587,7 +587,7 @@ CreateStringOpCode (
}
String.Header.OpCode = EFI_IFR_STRING_OP;
- String.Header.Length = sizeof (EFI_IFR_STRING);
+ String.Header.Length = (UINT8) sizeof (EFI_IFR_STRING);
String.Header.Scope = 0;
String.Question.Header.Prompt = Prompt;
String.Question.Header.Help = Help;
@@ -624,7 +624,7 @@ CreateBannerOpCode (
}
Banner.Header.OpCode = EFI_IFR_GUID_OP;
- Banner.Header.Length = sizeof (EFI_IFR_GUID_BANNER);
+ Banner.Header.Length = (UINT8) sizeof (EFI_IFR_GUID_BANNER);
Banner.Header.Scope = 0;
EfiCopyMem (&Banner.Guid, &mIfrVendorGuid, sizeof (EFI_IFR_GUID));
Banner.ExtendOpCode = EFI_IFR_EXTEND_OP_BANNER;
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrString.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrString.c
index 74ca418..f5f92b8 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
+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
@@ -489,6 +489,7 @@ Returns:
EFI_HII_HANDLE *HiiHandleBuffer;
EFI_GUID Guid;
+ HiiHandleBuffer = NULL;
Status = GetHiiHandles (&HandleBufferLen, &HiiHandleBuffer);
if (EFI_ERROR(Status)) {
return Status;
@@ -551,6 +552,9 @@ IfrLibNewString (
LocateHiiProtocols ();
Languages = GetSupportedLanguages (PackageList);
+ if (Languages == NULL) {
+ return EFI_NOT_FOUND;
+ }
LangStrings = Languages;
while (*LangStrings != 0) {
@@ -677,6 +681,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/BaseLib/GetPowerOfTwo64.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/GetPowerOfTwo64.c
index bc10d87..444d984 100644
--- a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/GetPowerOfTwo64.c
+++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/GetPowerOfTwo64.c
@@ -45,5 +45,5 @@ GetPowerOfTwo64 (
return 0;
}
- return LShiftU64 (1, HighBitSet64 (Operand));
+ return LShiftU64 (1, (UINTN) HighBitSet64 (Operand));
}
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DivS64x64Remainder.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DivS64x64Remainder.c
index 140e3b1..b0b82f7 100644
--- a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DivS64x64Remainder.c
+++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DivS64x64Remainder.c
@@ -49,8 +49,8 @@ InternalMathDivRemS64x64 (
INT64 Quot;
Quot = InternalMathDivRemU64x64 (
- Dividend >= 0 ? Dividend : -Dividend,
- Divisor >= 0 ? Divisor : -Divisor,
+ (UINT64) (Dividend >= 0 ? Dividend : -Dividend),
+ (UINT64) (Divisor >= 0 ? Divisor : -Divisor),
(UINT64 *) Remainder
);
if (Remainder != NULL && Dividend < 0) {
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/MultS64x64.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/MultS64x64.c
index 62e0574..8b57aac 100644
--- a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/MultS64x64.c
+++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/MultS64x64.c
@@ -45,5 +45,5 @@ MultS64x64 (
IN INT64 Multiplier
)
{
- return (INT64)MultU64x64 (Multiplicand, Multiplier);
+ return (INT64)MultU64x64 ((UINT64) Multiplicand, (UINT64) Multiplier);
}
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SynchronizationMsc.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SynchronizationMsc.c
index 11cb5e6..3a75496 100644
--- a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SynchronizationMsc.c
+++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SynchronizationMsc.c
@@ -353,7 +353,7 @@ InterlockedCompareExchangePointer (
{
UINT8 SizeOfValue;
- SizeOfValue = sizeof (*Value);
+ SizeOfValue = (UINT8) sizeof (*Value);
switch (SizeOfValue) {
case sizeof (UINT32):
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/BasePeCoff.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/BasePeCoff.c
index 489667c..fba9853 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
+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/BasePrintLib/PrintLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/PrintLib.c
index d7f6bd7..3ce91bc 100644
--- a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/PrintLib.c
+++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/PrintLib.c
@@ -424,7 +424,7 @@ BasePrintLibVSPrint (
ArgumentString = StatusString [Index + WARNING_STATUS_NUMBER];
}
} else {
- Index = Status;
+ Index = (UINTN) Status;
if (Index <= WARNING_STATUS_NUMBER) {
ArgumentString = StatusString [Index];
}
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.c
index caa8917..4ff4e4d 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
+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
@@ -142,7 +142,7 @@ GlueMakeTable (
UINT16 Start[18];
UINT16 *Pointer;
UINT16 Index3;
- volatile UINT16 Index;
+ UINT16 Index;
UINT16 Len;
UINT16 Char;
UINT16 JuBits;
@@ -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 285056e..7ce4984 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
+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/DxeReportStatusCodeLib/ReportStatusCodeLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c
index cac0b4b..a6b9abf 100644
--- a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c
+++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c
@@ -512,7 +512,7 @@ GlueReportStatusCodeEx (
//
// Fill in the extended data header
//
- StatusCodeData->HeaderSize = sizeof (EFI_STATUS_CODE_DATA);
+ StatusCodeData->HeaderSize = (UINT16) sizeof (EFI_STATUS_CODE_DATA);
StatusCodeData->Size = (UINT16)ExtendedDataSize;
if (ExtendedDataGuid == NULL) {
ExtendedDataGuid = &gEfiStatusCodeSpecificDataGuid;
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/HiiLib/HiiLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/HiiLib/HiiLib.c
index 302747e..0644488 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
+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/EdkIIGlueLib/Library/PeiHobLib/HobLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiHobLib/HobLib.c
index 0d2ba02..8c23b82 100644
--- a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiHobLib/HobLib.c
+++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiHobLib/HobLib.c
@@ -254,7 +254,7 @@ GlueBuildModuleHob (
{
EFI_HOB_MEMORY_ALLOCATION_MODULE *Hob;
- Hob = InternalPeiCreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION_MODULE));
+ Hob = InternalPeiCreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, (UINT16) sizeof (EFI_HOB_MEMORY_ALLOCATION_MODULE));
CopyGuid (&(Hob->MemoryAllocationHeader.Name), &gEfiHobMemoryAllocModuleGuid);
Hob->MemoryAllocationHeader.MemoryBaseAddress = MemoryAllocationModule;
@@ -295,7 +295,7 @@ BuildResourceDescriptorHob (
{
EFI_HOB_RESOURCE_DESCRIPTOR *Hob;
- Hob = InternalPeiCreateHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, sizeof (EFI_HOB_RESOURCE_DESCRIPTOR));
+ Hob = InternalPeiCreateHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, (UINT16) sizeof (EFI_HOB_RESOURCE_DESCRIPTOR));
Hob->ResourceType = ResourceType;
Hob->ResourceAttribute = ResourceAttribute;
@@ -402,7 +402,7 @@ BuildFvHob (
// Check FV Signature
//
ASSERT (((EFI_FIRMWARE_VOLUME_HEADER*)((UINTN)BaseAddress))->Signature == EFI_FVH_SIGNATURE);
- Hob = InternalPeiCreateHob (EFI_HOB_TYPE_FV, sizeof (EFI_HOB_FIRMWARE_VOLUME));
+ Hob = InternalPeiCreateHob (EFI_HOB_TYPE_FV, (UINT16) sizeof (EFI_HOB_FIRMWARE_VOLUME));
Hob->BaseAddress = BaseAddress;
Hob->Length = Length;
@@ -429,7 +429,7 @@ BuildCvHob (
{
EFI_HOB_CAPSULE_VOLUME *Hob;
- Hob = InternalPeiCreateHob (EFI_HOB_TYPE_CV, sizeof (EFI_HOB_CAPSULE_VOLUME));
+ Hob = InternalPeiCreateHob (EFI_HOB_TYPE_CV, (UINT16) sizeof (EFI_HOB_CAPSULE_VOLUME));
Hob->BaseAddress = BaseAddress;
Hob->Length = Length;
@@ -456,7 +456,7 @@ BuildCpuHob (
{
EFI_HOB_CPU *Hob;
- Hob = InternalPeiCreateHob (EFI_HOB_TYPE_CPU, sizeof (EFI_HOB_CPU));
+ Hob = InternalPeiCreateHob (EFI_HOB_TYPE_CPU, (UINT16) sizeof (EFI_HOB_CPU));
Hob->SizeOfMemorySpace = SizeOfMemorySpace;
Hob->SizeOfIoSpace = SizeOfIoSpace;
@@ -488,7 +488,7 @@ BuildStackHob (
{
EFI_HOB_MEMORY_ALLOCATION_STACK *Hob;
- Hob = InternalPeiCreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION_STACK));
+ Hob = InternalPeiCreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, (UINT16) sizeof (EFI_HOB_MEMORY_ALLOCATION_STACK));
CopyGuid (&(Hob->AllocDescriptor.Name), &gEfiHobMemoryAllocStackGuid);
Hob->AllocDescriptor.MemoryBaseAddress = BaseAddress;
@@ -524,7 +524,7 @@ BuildBspStoreHob (
{
EFI_HOB_MEMORY_ALLOCATION_BSP_STORE *Hob;
- Hob = InternalPeiCreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION_BSP_STORE));
+ Hob = InternalPeiCreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, (UINT16) sizeof (EFI_HOB_MEMORY_ALLOCATION_BSP_STORE));
CopyGuid (&(Hob->AllocDescriptor.Name), &gEfiHobMemoryAllocBspStoreGuid);
Hob->AllocDescriptor.MemoryBaseAddress = BaseAddress;
@@ -560,7 +560,7 @@ GlueBuildMemoryAllocationHob (
{
EFI_HOB_MEMORY_ALLOCATION *Hob;
- Hob = InternalPeiCreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION));
+ Hob = InternalPeiCreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, (UINT16) sizeof (EFI_HOB_MEMORY_ALLOCATION));
ZeroMem (&(Hob->AllocDescriptor.Name), sizeof (EFI_GUID));
Hob->AllocDescriptor.MemoryBaseAddress = BaseAddress;
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiReportStatusCodeLib/ReportStatusCodeLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiReportStatusCodeLib/ReportStatusCodeLib.c
index 5b62746..3bef56f 100644
--- a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiReportStatusCodeLib/ReportStatusCodeLib.c
+++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/PeiReportStatusCodeLib/ReportStatusCodeLib.c
@@ -447,7 +447,7 @@ GlueReportStatusCodeEx (
return EFI_OUT_OF_RESOURCES;
}
StatusCodeData = (EFI_STATUS_CODE_DATA *)Buffer;
- StatusCodeData->HeaderSize = sizeof (EFI_STATUS_CODE_DATA);
+ StatusCodeData->HeaderSize = (UINT16) sizeof (EFI_STATUS_CODE_DATA);
StatusCodeData->Size = (UINT16)ExtendedDataSize;
if (ExtendedDataGuid == NULL) {
ExtendedDataGuid = &gEfiStatusCodeSpecificDataGuid;
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/SmmRuntimeDxeReportStatusCodeLib/SmmRuntimeDxeSupport.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/SmmRuntimeDxeReportStatusCodeLib/SmmRuntimeDxeSupport.c
index 6cb0f0b..ba91a8d 100644
--- a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/SmmRuntimeDxeReportStatusCodeLib/SmmRuntimeDxeSupport.c
+++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/SmmRuntimeDxeReportStatusCodeLib/SmmRuntimeDxeSupport.c
@@ -319,7 +319,7 @@ InternalReportStatusCodeEx (
//
// Fill in the extended data header
//
- mStatusCodeData->HeaderSize = sizeof (EFI_STATUS_CODE_DATA);
+ mStatusCodeData->HeaderSize = (UINT16) sizeof (EFI_STATUS_CODE_DATA);
mStatusCodeData->Size = (UINT16)ExtendedDataSize;
if (ExtendedDataGuid == NULL) {
ExtendedDataGuid = &gEfiStatusCodeSpecificDataGuid;
diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/ReportStatusCode.c b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/ReportStatusCode.c
index 49328e6..0064e7f 100644
--- a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/ReportStatusCode.c
+++ b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/ReportStatusCode.c
@@ -49,7 +49,7 @@ Returns:
--*/
{
- Data->HeaderSize = sizeof (EFI_STATUS_CODE_DATA);
+ Data->HeaderSize = (UINT16) sizeof (EFI_STATUS_CODE_DATA);
Data->Size = (UINT16)(DataSize - sizeof (EFI_STATUS_CODE_DATA));
EfiCommonLibCopyMem (&Data->Type, TypeGuid, sizeof (EFI_GUID));
diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/Hob/PeiHobLib.c b/EdkCompatibilityPkg/Foundation/Library/Pei/Hob/PeiHobLib.c
index 130ce6d..72d3339 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Pei/Hob/PeiHobLib.c
+++ b/EdkCompatibilityPkg/Foundation/Library/Pei/Hob/PeiHobLib.c
@@ -52,7 +52,7 @@ Returns:
Hob.Raw = HobStart;
Hob.Header->HobType = EFI_HOB_TYPE_END_OF_HOB_LIST;
- Hob.Header->HobLength = sizeof(EFI_HOB_GENERIC_HEADER);
+ Hob.Header->HobLength = (UINT16) sizeof (EFI_HOB_GENERIC_HEADER);
Hob.Header++;
return Hob;
@@ -102,7 +102,7 @@ Returns:
HandOffHob.Raw = HobStart;
Hob.Raw = HobStart;
Hob.Header->HobType = EFI_HOB_TYPE_HANDOFF;
- Hob.Header->HobLength = sizeof(EFI_HOB_HANDOFF_INFO_TABLE);
+ Hob.Header->HobLength = (UINT16) sizeof (EFI_HOB_HANDOFF_INFO_TABLE);
Hob.HandoffInformationTable->Version = Version;
Hob.HandoffInformationTable->BootMode = BootMode;
@@ -161,7 +161,7 @@ Returns:
Hob.Raw = (VOID*)(UINTN)(HandOffHob.HandoffInformationTable->EfiEndOfHobList);
Hob.Header->HobType = EFI_HOB_TYPE_MEMORY_ALLOCATION;
- Hob.Header->HobLength = sizeof(EFI_HOB_MEMORY_ALLOCATION_MODULE);
+ Hob.Header->HobLength = (UINT16) sizeof (EFI_HOB_MEMORY_ALLOCATION_MODULE);
CopyMem(&(Hob.MemoryAllocationModule->ModuleName), ModuleName, sizeof(EFI_GUID));
CopyMem(&(Hob.MemoryAllocationModule->MemoryAllocationHeader.Name), &gEfiHobMemeryAllocModuleGuid, sizeof(EFI_GUID));
@@ -218,7 +218,7 @@ Returns:
Hob.Raw = (VOID *)(UINTN)(HandOffHob.HandoffInformationTable->EfiEndOfHobList);
Hob.Header->HobType = EFI_HOB_TYPE_RESOURCE_DESCRIPTOR;
- Hob.Header->HobLength = sizeof(EFI_HOB_RESOURCE_DESCRIPTOR);
+ Hob.Header->HobLength = (UINT16) sizeof (EFI_HOB_RESOURCE_DESCRIPTOR);
Hob.ResourceDescriptor->ResourceType = ResourceType;
Hob.ResourceDescriptor->ResourceAttribute = ResourceAttribute;
@@ -319,7 +319,7 @@ Returns:
Hob.Raw = (VOID*)(UINTN)(HandOffHob.HandoffInformationTable->EfiEndOfHobList);
Hob.Header->HobType = EFI_HOB_TYPE_FV;
- Hob.Header->HobLength = sizeof(EFI_HOB_FIRMWARE_VOLUME);
+ Hob.Header->HobLength = (UINT16) sizeof (EFI_HOB_FIRMWARE_VOLUME);
Hob.FirmwareVolume->BaseAddress = BaseAddress;
Hob.FirmwareVolume->Length = Length;
@@ -368,7 +368,7 @@ Returns:
Hob.Raw = (VOID*)(UINTN)HandOffHob.HandoffInformationTable->EfiEndOfHobList;
Hob.Header->HobType = EFI_HOB_TYPE_CPU;
- Hob.Header->HobLength = sizeof(EFI_HOB_CPU);
+ Hob.Header->HobLength = (UINT16) sizeof (EFI_HOB_CPU);
Hob.Cpu->SizeOfMemorySpace = SizeOfMemorySpace;
Hob.Cpu->SizeOfIoSpace = SizeOfIoSpace;
@@ -416,7 +416,7 @@ Returns:
Hob.Raw = (VOID*)(UINTN)HandOffHob.HandoffInformationTable->EfiEndOfHobList;
Hob.Header->HobType = EFI_HOB_TYPE_MEMORY_ALLOCATION;
- Hob.Header->HobLength = sizeof(EFI_HOB_MEMORY_ALLOCATION_STACK);
+ Hob.Header->HobLength = (UINT16) sizeof (EFI_HOB_MEMORY_ALLOCATION_STACK);
CopyMem(&(Hob.MemoryAllocationStack->AllocDescriptor.Name), &gEfiHobMemeryAllocStackGuid, sizeof(EFI_GUID));
(Hob.MemoryAllocationStack->AllocDescriptor).MemoryBaseAddress = BaseAddress;
@@ -468,7 +468,7 @@ Returns:
HandOffHob.Raw = HobStart;
Hob.Raw = (VOID *)(UINTN)HandOffHob.HandoffInformationTable->EfiEndOfHobList;
Hob.Header->HobType = EFI_HOB_TYPE_MEMORY_ALLOCATION;
- Hob.Header->HobLength = sizeof(EFI_HOB_MEMORY_ALLOCATION_BSP_STORE);
+ Hob.Header->HobLength = (UINT16) sizeof (EFI_HOB_MEMORY_ALLOCATION_BSP_STORE);
(Hob.MemoryAllocationBspStore->AllocDescriptor).MemoryBaseAddress = BaseAddress;
(Hob.MemoryAllocationBspStore->AllocDescriptor).MemoryLength = Length;
@@ -525,12 +525,12 @@ Returns:
Hob.Raw = (VOID*)(UINTN)HandOffHob.HandoffInformationTable->EfiEndOfHobList;
Hob.Header->HobType = EFI_HOB_TYPE_MEMORY_ALLOCATION;
- Hob.Header->HobLength = sizeof(EFI_HOB_MEMORY_ALLOCATION);
+ Hob.Header->HobLength = (UINT16) sizeof (EFI_HOB_MEMORY_ALLOCATION);
if (Name != NULL) {
- CopyMem(&(Hob.MemoryAllocation->AllocDescriptor.Name), &Name, sizeof(EFI_GUID));
+ CopyMem (&(Hob.MemoryAllocation->AllocDescriptor.Name), &Name, sizeof (EFI_GUID));
} else {
- ZeroMem(&Hob.MemoryAllocation->AllocDescriptor.Name, sizeof(EFI_GUID));
+ ZeroMem (&Hob.MemoryAllocation->AllocDescriptor.Name, sizeof (EFI_GUID));
}
(Hob.MemoryAllocation->AllocDescriptor).MemoryBaseAddress = BaseAddress;
diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Decompress.c b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/Decompress.c
index ea12d02..4c05a2b 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
+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 b037818..31b6237 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
+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 55e831c..649f671 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
+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/Io.c b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Io.c
index b7571b4..b375a83 100644
--- a/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Io.c
+++ b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Io.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004, Intel Corporation
+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
@@ -42,6 +42,7 @@ Returns:
{
UINT8 Buffer;
+ Buffer = 0;
EfiIoRead (EfiCpuIoWidthUint8, Address, 1, &Buffer);
return Buffer;
}
@@ -65,6 +66,7 @@ Returns:
{
UINT16 Buffer;
+ Buffer = 0;
EfiIoRead (EfiCpuIoWidthUint16, Address, 1, &Buffer);
return Buffer;
}
@@ -88,6 +90,7 @@ Returns:
{
UINT32 Buffer;
+ Buffer = 0;
EfiIoRead (EfiCpuIoWidthUint32, Address, 1, &Buffer);
return Buffer;
}
@@ -177,6 +180,7 @@ Returns:
{
UINT8 Buffer;
+ Buffer = 0;
EfiMemRead (EfiCpuIoWidthUint8, Address, 1, &Buffer);
return Buffer;
}
@@ -200,6 +204,7 @@ Returns:
{
UINT16 Buffer;
+ Buffer = 0;
EfiMemRead (EfiCpuIoWidthUint16, Address, 1, &Buffer);
return Buffer;
}
@@ -223,6 +228,7 @@ Returns:
{
UINT32 Buffer;
+ Buffer = 0;
EfiMemRead (EfiCpuIoWidthUint32, Address, 1, &Buffer);
return Buffer;
}
@@ -246,6 +252,7 @@ Returns:
{
UINT64 Buffer;
+ Buffer = 0;
EfiMemRead (EfiCpuIoWidthUint64, Address, 1, &Buffer);
return Buffer;
}
diff --git a/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ipf/RuntimeLib.c b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ipf/RuntimeLib.c
index 878a0b9..72c4ed5 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
+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 35e22e7..9f1a435 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
+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 9c42cb1..d84619c 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
+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 28b5af5..4003fe7 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
+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 46aedad..bc3f928 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
+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);
}
}