summaryrefslogtreecommitdiff
path: root/EdkCompatibilityPkg
diff options
context:
space:
mode:
authorlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>2010-02-25 10:08:54 +0000
committerlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>2010-02-25 10:08:54 +0000
commit234980f6e935a51fdafecb9930b4a2ecbf47b727 (patch)
treee8bd9c36871f0c62d1e48b291cbcf0f9ee396cab /EdkCompatibilityPkg
parentbade9bf5b274d379aa8ae579b9b34819102e10d4 (diff)
downloadedk2-platforms-234980f6e935a51fdafecb9930b4a2ecbf47b727.tar.xz
Add more check to avoid code enter into wrong state.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10068 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'EdkCompatibilityPkg')
-rw-r--r--EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/HiiDatabase.c12
-rw-r--r--EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/Package.c12
-rw-r--r--EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/SetupBrowser.c2
-rw-r--r--EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/UefiIfrParser.c26
-rw-r--r--EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/Utility.c4
-rw-r--r--EdkCompatibilityPkg/Compatibility/PiSmbiosRecordOnDataHubSmbiosRecordThunk/ConvLib.c2
-rw-r--r--EdkCompatibilityPkg/Compatibility/PiSmbiosRecordOnDataHubSmbiosRecordThunk/Translate.c2
7 files changed, 46 insertions, 14 deletions
diff --git a/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/HiiDatabase.c b/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/HiiDatabase.c
index ec7159b60b..48f2ff29bd 100644
--- a/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/HiiDatabase.c
+++ b/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/HiiDatabase.c
@@ -243,7 +243,7 @@ InitializeHiiDatabase (
@param This A pointer to the EFI_HII_PROTOCOL instance.
@param HandleBufferLength On input, a pointer to the length of the handle buffer.
On output, the length of the handle buffer that is required for the handles found.
- @param Handle An array of EFI_HII_HANDLE instances returned.
+ @param Handle Pointer to an array of EFI_HII_HANDLE instances returned.
Type EFI_HII_HANDLE is defined in EFI_HII_PROTOCOL.NewPack() in the Packages section.
@retval EFI_SUCCESS Handle was updated successfully.
@@ -257,13 +257,13 @@ EFIAPI
HiiFindHandles (
IN EFI_HII_PROTOCOL *This,
IN OUT UINT16 *HandleBufferLength,
- OUT FRAMEWORK_EFI_HII_HANDLE Handle[1]
+ OUT FRAMEWORK_EFI_HII_HANDLE *Handle
)
{
- UINT16 Count;
- LIST_ENTRY *Link;
- HII_THUNK_CONTEXT *ThunkContext;
- HII_THUNK_PRIVATE_DATA *Private;
+ UINT16 Count;
+ LIST_ENTRY *Link;
+ HII_THUNK_CONTEXT *ThunkContext;
+ HII_THUNK_PRIVATE_DATA *Private;
if (HandleBufferLength == NULL) {
return EFI_INVALID_PARAMETER;
diff --git a/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/Package.c b/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/Package.c
index 58dba9dc20..fb664a2928 100644
--- a/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/Package.c
+++ b/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/Package.c
@@ -401,8 +401,12 @@ FindStringPackAndUpdatePackListWithOnlyIfrPack (
if (ThunkContext != IfrThunkContext) {
if (CompareGuid (&IfrThunkContext->TagGuid, &ThunkContext->TagGuid) && (ThunkContext->IfrPackageCount == 0)) {
+ StringPackageListHeader = NULL;
Status = ExportPackageLists (ThunkContext->UefiHiiHandle, &StringPackageListHeader, &Size);
ASSERT_EFI_ERROR (Status);
+ if (StringPackageListHeader == NULL) {
+ return EFI_NOT_FOUND;
+ }
IfrThunkContext->StringPackageCount = GetPackageCountByType (StringPackageListHeader, EFI_HII_PACKAGE_STRINGS);
//
@@ -506,6 +510,10 @@ UefiRegisterPackageList (
ASSERT ((StringPackageCount >=1 && IfrPackageCount == 1) || (FontPackageCount > 0));
if (IfrPackageCount > 0) {
IfrPackage = GetIfrPackage (Packages);
+ if (IfrPackage == NULL) {
+ Status = EFI_NOT_FOUND;
+ goto Done;
+ }
GetFormSetGuid (IfrPackage, &ThunkContext->TagGuid);
} else {
ASSERT (FontPackageCount > 0);
@@ -860,8 +868,12 @@ RemovePackNotify (
//
if (ThunkContext != NULL) {
if (!ThunkContext->ByFrameworkHiiNewPack) {
+ HiiPackageList = NULL;
Status = ExportPackageLists (Handle, &HiiPackageList, &BufferSize);
ASSERT_EFI_ERROR (Status);
+ if (HiiPackageList == NULL) {
+ return EFI_NOT_FOUND;
+ }
if (GetPackageCountByType (HiiPackageList, EFI_HII_PACKAGE_STRINGS) == 1) {
//
diff --git a/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/SetupBrowser.c b/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/SetupBrowser.c
index b16d25797b..3503bc0715 100644
--- a/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/SetupBrowser.c
+++ b/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/SetupBrowser.c
@@ -102,7 +102,7 @@ PlatformBdsShowProgress (
(VOID **) &UgaDraw
);
}
- if (EFI_ERROR (Status)) {
+ if (EFI_ERROR (Status) || (GraphicsOutput == NULL && UgaDraw == NULL)) {
return EFI_UNSUPPORTED;
}
diff --git a/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/UefiIfrParser.c b/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/UefiIfrParser.c
index 98754ec544..faff074209 100644
--- a/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/UefiIfrParser.c
+++ b/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/UefiIfrParser.c
@@ -556,7 +556,7 @@ ParseOpCodes (
//
// If scope bit set, push onto scope stack
//
- if (Scope) {
+ if (Scope != 0) {
PushScope (Operand);
}
@@ -717,15 +717,17 @@ ParseOpCodes (
//
case EFI_IFR_SUBTITLE_OP:
CurrentStatement = CreateStatement (OpCodeData, FormSet, CurrentForm);
+ ASSERT (CurrentStatement != NULL);
CurrentStatement->Flags = ((EFI_IFR_SUBTITLE *) OpCodeData)->Flags;
- if (Scope) {
+ if (Scope != 0) {
mInScopeSubtitle = TRUE;
}
break;
case EFI_IFR_TEXT_OP:
CurrentStatement = CreateStatement (OpCodeData, FormSet, CurrentForm);
+ ASSERT (CurrentStatement != NULL);
CopyMem (&CurrentStatement->TextTwo, &((EFI_IFR_TEXT *) OpCodeData)->TextTwo, sizeof (EFI_STRING_ID));
break;
@@ -735,6 +737,7 @@ ParseOpCodes (
//
case EFI_IFR_ACTION_OP:
CurrentStatement = CreateQuestion (OpCodeData, FormSet, CurrentForm);
+ ASSERT (CurrentStatement != NULL);
if (OpCodeLength == sizeof (EFI_IFR_ACTION_1)) {
//
@@ -748,11 +751,13 @@ ParseOpCodes (
case EFI_IFR_RESET_BUTTON_OP:
CurrentStatement = CreateStatement (OpCodeData, FormSet, CurrentForm);
+ ASSERT (CurrentStatement != NULL);
CopyMem (&CurrentStatement->DefaultId, &((EFI_IFR_RESET_BUTTON *) OpCodeData)->DefaultId, sizeof (EFI_DEFAULT_ID));
break;
case EFI_IFR_REF_OP:
CurrentStatement = CreateQuestion (OpCodeData, FormSet, CurrentForm);
+ ASSERT (CurrentStatement != NULL);
CopyMem (&CurrentStatement->RefFormId, &((EFI_IFR_REF *) OpCodeData)->FormId, sizeof (EFI_FORM_ID));
if (OpCodeLength >= sizeof (EFI_IFR_REF2)) {
@@ -771,6 +776,7 @@ ParseOpCodes (
case EFI_IFR_ONE_OF_OP:
case EFI_IFR_NUMERIC_OP:
CurrentStatement = CreateQuestion (OpCodeData, FormSet, CurrentForm);
+ ASSERT (CurrentStatement != NULL);
CurrentStatement->Flags = ((EFI_IFR_ONE_OF *) OpCodeData)->Flags;
Value = &CurrentStatement->HiiValue;
@@ -820,6 +826,7 @@ ParseOpCodes (
case EFI_IFR_ORDERED_LIST_OP:
CurrentStatement = CreateQuestion (OpCodeData, FormSet, CurrentForm);
+ ASSERT (CurrentStatement != NULL);
CurrentStatement->Flags = ((EFI_IFR_ORDERED_LIST *) OpCodeData)->Flags;
CurrentStatement->MaxContainers = ((EFI_IFR_ORDERED_LIST *) OpCodeData)->MaxContainers;
@@ -837,6 +844,7 @@ ParseOpCodes (
case EFI_IFR_CHECKBOX_OP:
CurrentStatement = CreateQuestion (OpCodeData, FormSet, CurrentForm);
+ ASSERT (CurrentStatement != NULL);
CurrentStatement->Flags = ((EFI_IFR_CHECKBOX *) OpCodeData)->Flags;
CurrentStatement->StorageWidth = sizeof (BOOLEAN);
@@ -846,6 +854,7 @@ ParseOpCodes (
case EFI_IFR_STRING_OP:
CurrentStatement = CreateQuestion (OpCodeData, FormSet, CurrentForm);
+ ASSERT (CurrentStatement != NULL);
//
// MinSize is the minimum number of characters that can be accepted for this opcode,
@@ -864,6 +873,7 @@ ParseOpCodes (
case EFI_IFR_PASSWORD_OP:
CurrentStatement = CreateQuestion (OpCodeData, FormSet, CurrentForm);
+ ASSERT (CurrentStatement != NULL);
//
// MinSize is the minimum number of characters that can be accepted for this opcode,
@@ -881,6 +891,7 @@ ParseOpCodes (
case EFI_IFR_DATE_OP:
CurrentStatement = CreateQuestion (OpCodeData, FormSet, CurrentForm);
+ ASSERT (CurrentStatement != NULL);
CurrentStatement->Flags = ((EFI_IFR_DATE *) OpCodeData)->Flags;
CurrentStatement->HiiValue.Type = EFI_IFR_TYPE_DATE;
@@ -889,6 +900,7 @@ ParseOpCodes (
case EFI_IFR_TIME_OP:
CurrentStatement = CreateQuestion (OpCodeData, FormSet, CurrentForm);
+ ASSERT (CurrentStatement != NULL);
CurrentStatement->Flags = ((EFI_IFR_TIME *) OpCodeData)->Flags;
CurrentStatement->HiiValue.Type = EFI_IFR_TYPE_TIME;
@@ -999,10 +1011,17 @@ ParseOpCodes (
break;
default:
+ //
+ // Make sure CurrentStatement is not NULL.
+ // If it is NULL, 1) ParseOpCodes functions may parse the IFR wrongly. Or 2) the IFR
+ // file is wrongly generated by tools such as VFR Compiler.
+ //
+ ASSERT (CurrentStatement != NULL);
ImageId = &CurrentStatement->ImageId;
break;
}
-
+
+ ASSERT (ImageId != NULL);
CopyMem (ImageId, &((EFI_IFR_IMAGE *) OpCodeData)->Id, sizeof (EFI_IMAGE_ID));
break;
@@ -1010,6 +1029,7 @@ ParseOpCodes (
// Refresh
//
case EFI_IFR_REFRESH_OP:
+ ASSERT (CurrentStatement != NULL);
CurrentStatement->RefreshInterval = ((EFI_IFR_REFRESH *) OpCodeData)->RefreshInterval;
break;
diff --git a/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/Utility.c b/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/Utility.c
index 3edb806447..d1d5d4d398 100644
--- a/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/Utility.c
+++ b/EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/Utility.c
@@ -727,8 +727,8 @@ GetIfrBinaryData (
Status = mHiiDatabase->ExportPackageLists (mHiiDatabase, Handle, &BufferSize, HiiPackageList);
}
- if (EFI_ERROR (Status)) {
- return Status;
+ if (EFI_ERROR (Status) || HiiPackageList == NULL) {
+ return EFI_NOT_FOUND;
}
//
diff --git a/EdkCompatibilityPkg/Compatibility/PiSmbiosRecordOnDataHubSmbiosRecordThunk/ConvLib.c b/EdkCompatibilityPkg/Compatibility/PiSmbiosRecordOnDataHubSmbiosRecordThunk/ConvLib.c
index fac1fb7b58..224f621e9d 100644
--- a/EdkCompatibilityPkg/Compatibility/PiSmbiosRecordOnDataHubSmbiosRecordThunk/ConvLib.c
+++ b/EdkCompatibilityPkg/Compatibility/PiSmbiosRecordOnDataHubSmbiosRecordThunk/ConvLib.c
@@ -377,7 +377,7 @@ SmbiosFindHandle (
}
}
- if (Link == &mStructureList) {
+ if (Link == &mStructureList || StructureNode == NULL) {
return EFI_NOT_FOUND;
} else {
*HandleNum = StructureNode->Structure->Handle;
diff --git a/EdkCompatibilityPkg/Compatibility/PiSmbiosRecordOnDataHubSmbiosRecordThunk/Translate.c b/EdkCompatibilityPkg/Compatibility/PiSmbiosRecordOnDataHubSmbiosRecordThunk/Translate.c
index 3230d96576..ad41ec0783 100644
--- a/EdkCompatibilityPkg/Compatibility/PiSmbiosRecordOnDataHubSmbiosRecordThunk/Translate.c
+++ b/EdkCompatibilityPkg/Compatibility/PiSmbiosRecordOnDataHubSmbiosRecordThunk/Translate.c
@@ -161,7 +161,7 @@ SmbiosProcessDataRecord (
}
}
- if (Link == &mStructureList) {
+ if (Link == &mStructureList || StructureNode == NULL) {
//
// Not found, create a new structure