Add check when use Index as Array [Index] to avoid out of Array bound.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7348 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
lgao4 2009-01-22 15:40:06 +00:00
parent 80882266ed
commit 9872985bb1
2 changed files with 11 additions and 8 deletions

View File

@ -588,6 +588,7 @@ GetDriverBindingHandleFromImageHandle (
@param Private Pointer to EFI_CALLBACK_INFO. @param Private Pointer to EFI_CALLBACK_INFO.
@param KeyValue The callback key value of device controller item in first page. @param KeyValue The callback key value of device controller item in first page.
KeyValue is larger than or equal to KEY_VALUE_DEVICE_OFFSET.
@param FakeNvData Pointer to PLAT_OVER_MNGR_DATA. @param FakeNvData Pointer to PLAT_OVER_MNGR_DATA.
@retval EFI_SUCCESS Always returned. @retval EFI_SUCCESS Always returned.

View File

@ -153,7 +153,7 @@ MakeTable (
UINT16 WordOfCount; UINT16 WordOfCount;
for (Index = 1; Index <= 16; Index++) { for (Index = 0; Index <= 16; Index++) {
Count[Index] = 0; Count[Index] = 0;
} }
@ -161,6 +161,7 @@ MakeTable (
Count[BitLen[Index]]++; Count[BitLen[Index]]++;
} }
Start[0] = 0;
Start[1] = 0; Start[1] = 0;
for (Index = 1; Index <= 16; Index++) { for (Index = 1; Index <= 16; Index++) {
@ -176,6 +177,7 @@ MakeTable (
JuBits = (UINT16) (16 - TableBits); JuBits = (UINT16) (16 - TableBits);
Weight[0] = 0;
for (Index = 1; Index <= TableBits; Index++) { for (Index = 1; Index <= TableBits; Index++) {
Start[Index] >>= JuBits; Start[Index] >>= JuBits;
Weight[Index] = (UINT16) (1U << (TableBits - Index)); Weight[Index] = (UINT16) (1U << (TableBits - Index));
@ -201,7 +203,7 @@ MakeTable (
for (Char = 0; Char < NumOfChar; Char++) { for (Char = 0; Char < NumOfChar; Char++) {
Len = BitLen[Char]; Len = BitLen[Char];
if (Len == 0) { if (Len == 0 || Len >= 17) {
continue; continue;
} }
@ -347,7 +349,7 @@ ReadPTLen (
Index = 0; Index = 0;
while (Index < Number) { while (Index < Number && Index < NPT) {
CharC = (UINT16) (Sd->mBitBuf >> (BITBUFSIZ - 3)); CharC = (UINT16) (Sd->mBitBuf >> (BITBUFSIZ - 3));
@ -382,7 +384,7 @@ ReadPTLen (
} }
} }
while (Index < nn) { while (Index < nn && Index < NPT) {
Sd->mPTLen[Index++] = 0; Sd->mPTLen[Index++] = 0;
} }
@ -428,7 +430,7 @@ ReadCLen (
} }
Index = 0; Index = 0;
while (Index < Number) { while (Index < Number && Index < NC) {
CharC = Sd->mPTTable[Sd->mBitBuf >> (BITBUFSIZ - 8)]; CharC = Sd->mPTTable[Sd->mBitBuf >> (BITBUFSIZ - 8)];
if (CharC >= NT) { if (CharC >= NT) {
Mask = 1U << (BITBUFSIZ - 1 - 8); Mask = 1U << (BITBUFSIZ - 1 - 8);