Fix an issue in the PCD service to prevent potential out of bound array access

that can cause an exception. mPeiExMapppingTableSize is the table size, but the 
code needs to check the entry number.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Samer El-Haj-Mahmoud <elhaj@hp.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16448 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
Samer El-Haj-Mahmoud 2014-11-26 07:17:31 +00:00 committed by lzeng14
parent 42645c3dcf
commit 8cc87d32c6

@ -1,6 +1,7 @@
/** @file
Help functions used by PCD DXE driver.
Copyright (c) 2014, Hewlett-Packard Development Company, L.P.<BR>
Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@ -1508,7 +1509,7 @@ GetExPcdTokenNumber (
MatchGuidIdx = MatchGuid - GuidTable;
for (Index = 0; Index < mPeiExMapppingTableSize; Index++) {
for (Index = 0; Index < mPcdDatabase.PeiDb->ExTokenCount; Index++) {
if ((ExTokenNumber == ExMap[Index].ExTokenNumber) &&
(MatchGuidIdx == ExMap[Index].ExGuidIndex)) {
return ExMap[Index].TokenNumber;
@ -1529,7 +1530,7 @@ GetExPcdTokenNumber (
MatchGuidIdx = MatchGuid - GuidTable;
for (Index = 0; Index < mDxeExMapppingTableSize; Index++) {
for (Index = 0; Index < mPcdDatabase.DxeDb->ExTokenCount; Index++) {
if ((ExTokenNumber == ExMap[Index].ExTokenNumber) &&
(MatchGuidIdx == ExMap[Index].ExGuidIndex)) {
return ExMap[Index].TokenNumber;