From 0ba7fffd25ca2751b26dbcd97c0002996d43651a Mon Sep 17 00:00:00 2001 From: lgao4 Date: Sat, 24 Jan 2009 03:39:02 +0000 Subject: [PATCH] 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@7366 6f19259b-4bc3-4df7-8a09-765794883524 --- .../Library/BaseUefiDecompressLib/BaseUefiDecompressLib.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.c b/MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.c index 840ea5f2c1..9d0fd7d131 100644 --- a/MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.c +++ b/MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.c @@ -221,7 +221,7 @@ MakeTable ( Index = (UINT16) (Len - TableBits); while (Index != 0) { - if (*Pointer == 0) { + if (*Pointer == 0 && Avail < (2 * NC - 1)) { Sd->mRight[Avail] = Sd->mLeft[Avail] = 0; *Pointer = Avail++; } @@ -375,7 +375,7 @@ ReadPTLen ( // if (Index == Special) { CharC = (UINT16) GetBits (Sd, 2); - while ((INT16) (--CharC) >= 0) { + while ((INT16) (--CharC) >= 0 && Index < NPT) { Sd->mPTLen[Index++] = 0; } } @@ -457,7 +457,7 @@ ReadCLen ( CharC = (UINT16) (GetBits (Sd, CBIT) + 20); } - while ((INT16) (--CharC) >= 0) { + while ((INT16) (--CharC) >= 0 && Index < NC) { Sd->mCLen[Index++] = 0; }