summaryrefslogtreecommitdiff
path: root/MdePkg
diff options
context:
space:
mode:
authorlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>2009-01-22 15:40:06 +0000
committerlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>2009-01-22 15:40:06 +0000
commit9872985bb1e537d36c3d9625ffbb3f6f7f16edf3 (patch)
treeb5efce92b43723be60be61ae22e06cf4313658e7 /MdePkg
parent80882266edab7e0f88684c436ed97d773034b480 (diff)
downloadedk2-platforms-9872985bb1e537d36c3d9625ffbb3f6f7f16edf3.tar.xz
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
Diffstat (limited to 'MdePkg')
-rw-r--r--MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.c b/MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.c
index f32eac49bf..58f7791fe7 100644
--- a/MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.c
+++ b/MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.c
@@ -153,14 +153,15 @@ MakeTable (
UINT16 WordOfCount;
- for (Index = 1; Index <= 16; Index++) {
+ for (Index = 0; Index <= 16; Index++) {
Count[Index] = 0;
}
for (Index = 0; Index < NumOfChar; Index++) {
Count[BitLen[Index]]++;
}
-
+
+ Start[0] = 0;
Start[1] = 0;
for (Index = 1; Index <= 16; Index++) {
@@ -175,7 +176,8 @@ MakeTable (
}
JuBits = (UINT16) (16 - TableBits);
-
+
+ Weight[0] = 0;
for (Index = 1; Index <= TableBits; Index++) {
Start[Index] >>= JuBits;
Weight[Index] = (UINT16) (1U << (TableBits - Index));
@@ -201,7 +203,7 @@ MakeTable (
for (Char = 0; Char < NumOfChar; Char++) {
Len = BitLen[Char];
- if (Len == 0) {
+ if (Len == 0 || Len >= 17) {
continue;
}
@@ -221,7 +223,7 @@ MakeTable (
while (Index != 0) {
if (*Pointer == 0) {
- Sd->mRight[Avail] = Sd->mLeft[Avail] = 0;
+ Sd->mRight[Avail] = Sd->mLeft[Avail] = 0;
*Pointer = Avail++;
}
@@ -347,7 +349,7 @@ ReadPTLen (
Index = 0;
- while (Index < Number) {
+ while (Index < Number && Index < NPT) {
CharC = (UINT16) (Sd->mBitBuf >> (BITBUFSIZ - 3));
@@ -382,7 +384,7 @@ ReadPTLen (
}
}
- while (Index < nn) {
+ while (Index < nn && Index < NPT) {
Sd->mPTLen[Index++] = 0;
}
@@ -428,7 +430,7 @@ ReadCLen (
}
Index = 0;
- while (Index < Number) {
+ while (Index < Number && Index < NC) {
CharC = Sd->mPTTable[Sd->mBitBuf >> (BITBUFSIZ - 8)];
if (CharC >= NT) {
Mask = 1U << (BITBUFSIZ - 1 - 8);