summaryrefslogtreecommitdiff
path: root/EdkModulePkg/Universal/PCD
diff options
context:
space:
mode:
authorqwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524>2006-07-06 13:34:25 +0000
committerqwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524>2006-07-06 13:34:25 +0000
commit2b21a9713ce974c14f26dfb5d3496372e04b501b (patch)
treeb83008e7480ff94f7cea085778cac2a60c5f10cc /EdkModulePkg/Universal/PCD
parent3dd19b0d56310e40705bd6d38524ef488d94ed28 (diff)
downloadedk2-platforms-2b21a9713ce974c14f26dfb5d3496372e04b501b.tar.xz
Fixed a bug when input a invalid token number (not ZERO nor a valid token number) PcdLib should ASSERT.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@802 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'EdkModulePkg/Universal/PCD')
-rw-r--r--EdkModulePkg/Universal/PCD/Dxe/Pcd.c32
-rw-r--r--EdkModulePkg/Universal/PCD/Dxe/Service.c42
-rw-r--r--EdkModulePkg/Universal/PCD/Dxe/Service.h16
-rw-r--r--EdkModulePkg/Universal/PCD/Pei/Pcd.c3
4 files changed, 52 insertions, 41 deletions
diff --git a/EdkModulePkg/Universal/PCD/Dxe/Pcd.c b/EdkModulePkg/Universal/PCD/Dxe/Pcd.c
index b78752df29..115b1ac938 100644
--- a/EdkModulePkg/Universal/PCD/Dxe/Pcd.c
+++ b/EdkModulePkg/Universal/PCD/Dxe/Pcd.c
@@ -499,12 +499,18 @@ DxePcdGetNextToken (
IN OUT UINTN *TokenNumber
)
{
- UINTN ExTokenNumber;
-
+ EFI_STATUS Status;
+
+ Status = EFI_NOT_FOUND;
//
// Scan the local token space
//
if (Guid == NULL) {
+ if (((*TokenNumber > PEI_NEX_TOKEN_NUMBER) && (*TokenNumber < PEI_LOCAL_TOKEN_NUMBER)) ||
+ ((*TokenNumber > (PEI_LOCAL_TOKEN_NUMBER + DXE_NEX_TOKEN_NUMBER)))) {
+ return EFI_NOT_FOUND;
+ }
+
(*TokenNumber)++;
if (*TokenNumber > PEI_NEX_TOKEN_NUMBER &&
*TokenNumber <= PEI_LOCAL_TOKEN_NUMBER) {
@@ -525,10 +531,9 @@ DxePcdGetNextToken (
}
if (!PEI_EXMAP_TABLE_EMPTY) {
- ExTokenNumber = *TokenNumber;
- ExTokenNumber = ExGetNextTokeNumber (
+ Status = ExGetNextTokeNumber (
Guid,
- ExTokenNumber,
+ TokenNumber,
mPcdDatabase->PeiDb.Init.GuidTable,
sizeof(mPcdDatabase->PeiDb.Init.GuidTable),
mPcdDatabase->PeiDb.Init.ExMapTable,
@@ -536,13 +541,14 @@ DxePcdGetNextToken (
);
}
- if ((ExTokenNumber == PCD_INVALID_TOKEN_NUMBER) &&
- !DXE_EXMAP_TABLE_EMPTY
- ) {
- ExTokenNumber = *TokenNumber;
- ExTokenNumber = ExGetNextTokeNumber (
+ if (Status == EFI_SUCCESS) {
+ return Status;
+ }
+
+ if (!DXE_EXMAP_TABLE_EMPTY) {
+ Status = ExGetNextTokeNumber (
Guid,
- ExTokenNumber,
+ TokenNumber,
mPcdDatabase->DxeDb.Init.GuidTable,
sizeof(mPcdDatabase->DxeDb.Init.GuidTable),
mPcdDatabase->DxeDb.Init.ExMapTable,
@@ -550,9 +556,7 @@ DxePcdGetNextToken (
);
}
- *TokenNumber = ExTokenNumber;
-
- return EFI_SUCCESS;
+ return Status;
}
diff --git a/EdkModulePkg/Universal/PCD/Dxe/Service.c b/EdkModulePkg/Universal/PCD/Dxe/Service.c
index adbbe5fc5a..613d8c84d1 100644
--- a/EdkModulePkg/Universal/PCD/Dxe/Service.c
+++ b/EdkModulePkg/Universal/PCD/Dxe/Service.c
@@ -109,7 +109,7 @@ GetWorker (
Name = &(StringTable[VariableHead->StringIndex]);
VaraiableDefaultBuffer = (UINT8 *) PcdDb + VariableHead->DefaultValueOffset;
- Status = GetHiiVariable (Guid, Name, (VOID*)&Data, &DataSize);
+ Status = GetHiiVariable (Guid, Name, &Data, &DataSize);
if (Status == EFI_SUCCESS) {
if (GetSize == 0) {
//
@@ -252,14 +252,14 @@ DxeUnRegisterCallBackWorker (
-UINTN
+EFI_STATUS
ExGetNextTokeNumber (
- IN CONST EFI_GUID *Guid,
- IN UINTN TokenNumber,
- IN EFI_GUID *GuidTable,
- IN UINTN SizeOfGuidTable,
- IN DYNAMICEX_MAPPING *ExMapTable,
- IN UINTN SizeOfExMapTable
+ IN CONST EFI_GUID *Guid,
+ IN OUT UINTN *TokenNumber,
+ IN EFI_GUID *GuidTable,
+ IN UINTN SizeOfGuidTable,
+ IN DYNAMICEX_MAPPING *ExMapTable,
+ IN UINTN SizeOfExMapTable
)
{
EFI_GUID *MatchGuid;
@@ -269,7 +269,7 @@ ExGetNextTokeNumber (
MatchGuid = ScanGuid (GuidTable, SizeOfGuidTable, Guid);
if (MatchGuid == NULL) {
- return PCD_INVALID_TOKEN_NUMBER;
+ return EFI_NOT_FOUND;
}
Found = FALSE;
@@ -282,35 +282,39 @@ ExGetNextTokeNumber (
}
if (Found) {
- if (TokenNumber == PCD_INVALID_TOKEN_NUMBER) {
- return ExMapTable[Idx].ExTokenNumber;
+ if (*TokenNumber == PCD_INVALID_TOKEN_NUMBER) {
+ *TokenNumber = ExMapTable[Idx].ExTokenNumber;
+ return EFI_SUCCESS;
}
for ( ; Idx < SizeOfExMapTable; Idx++) {
- if (ExMapTable[Idx].ExTokenNumber == TokenNumber) {
+ if (ExMapTable[Idx].ExTokenNumber == *TokenNumber) {
Idx++;
if (Idx == SizeOfExMapTable) {
//
// Exceed the length of ExMap Table
//
- return PCD_INVALID_TOKEN_NUMBER;
+ *TokenNumber = PCD_INVALID_TOKEN_NUMBER;
+ return EFI_SUCCESS;
} else if (ExMapTable[Idx].ExGuidIndex == GuidTableIdx) {
//
// Found the next match
//
- return ExMapTable[Idx].ExTokenNumber;
+ *TokenNumber = ExMapTable[Idx].ExTokenNumber;
+ return EFI_SUCCESS;
} else {
//
// Guid has been changed. It is the next Token Space Guid.
// We should flag no more TokenNumber.
//
- return PCD_INVALID_TOKEN_NUMBER;
+ *TokenNumber = PCD_INVALID_TOKEN_NUMBER;
+ return EFI_SUCCESS;
}
}
}
}
- return PCD_INVALID_TOKEN_NUMBER;
+ return EFI_NOT_FOUND;
}
@@ -375,13 +379,13 @@ EFI_STATUS
GetHiiVariable (
IN EFI_GUID *VariableGuid,
IN UINT16 *VariableName,
- OUT VOID **VariableData,
+ OUT UINT8 **VariableData,
OUT UINTN *VariableSize
)
{
UINTN Size;
EFI_STATUS Status;
- VOID *Buffer;
+ UINT8 *Buffer;
Size = 0;
Buffer = NULL;
@@ -395,7 +399,7 @@ GetHiiVariable (
);
if (Status == EFI_BUFFER_TOO_SMALL) {
- Buffer = AllocatePool (Size);
+ Buffer = (UINT8 *) AllocatePool (Size);
ASSERT (Buffer != NULL);
diff --git a/EdkModulePkg/Universal/PCD/Dxe/Service.h b/EdkModulePkg/Universal/PCD/Dxe/Service.h
index ff90fa5479..271d8b32c4 100644
--- a/EdkModulePkg/Universal/PCD/Dxe/Service.h
+++ b/EdkModulePkg/Universal/PCD/Dxe/Service.h
@@ -397,7 +397,7 @@ EFI_STATUS
GetHiiVariable (
IN EFI_GUID *VariableGuid,
IN UINT16 *VariableName,
- OUT VOID **VariableData,
+ OUT UINT8 **VariableData,
OUT UINTN *VariableSize
)
;
@@ -441,14 +441,14 @@ GetExPcdTokenNumber (
-UINTN
+EFI_STATUS
ExGetNextTokeNumber (
- IN CONST EFI_GUID *Guid,
- IN UINTN TokenNumber,
- IN EFI_GUID *GuidTable,
- IN UINTN SizeOfGuidTable,
- IN DYNAMICEX_MAPPING *ExMapTable,
- IN UINTN SizeOfExMapTable
+ IN CONST EFI_GUID *Guid,
+ IN OUT UINTN *TokenNumber,
+ IN EFI_GUID *GuidTable,
+ IN UINTN SizeOfGuidTable,
+ IN DYNAMICEX_MAPPING *ExMapTable,
+ IN UINTN SizeOfExMapTable
)
;
diff --git a/EdkModulePkg/Universal/PCD/Pei/Pcd.c b/EdkModulePkg/Universal/PCD/Pei/Pcd.c
index 6d90671852..4ae4b27ef4 100644
--- a/EdkModulePkg/Universal/PCD/Pei/Pcd.c
+++ b/EdkModulePkg/Universal/PCD/Pei/Pcd.c
@@ -480,6 +480,9 @@ PeiPcdGetNextToken (
BOOLEAN Found;
if (Guid == NULL) {
+ if (*TokenNumber > PEI_NEX_TOKEN_NUMBER) {
+ return EFI_NOT_FOUND;
+ }
(*TokenNumber)++;
if (*TokenNumber > PEI_NEX_TOKEN_NUMBER) {
*TokenNumber = PCD_INVALID_TOKEN_NUMBER;