\r
\r
#include <Base.h>\r
-\r
-\r
#include <Library/BaseLib.h>\r
-#include <Library/UefiDecompressLib.h>\r
#include <Library/DebugLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/UefiDecompressLib.h>\r
\r
#include "BaseUefiDecompressLibInternals.h"\r
\r
UINT16 Start[18];\r
UINT16 *Pointer;\r
UINT16 Index3;\r
- volatile UINT16 Index;\r
+ UINT16 Index;\r
UINT16 Len;\r
UINT16 Char;\r
UINT16 JuBits;\r
UINT16 WordOfCount;\r
\r
\r
- for (Index = 1; Index <= 16; Index++) {\r
+ for (Index = 0; Index <= 16; Index++) {\r
Count[Index] = 0;\r
}\r
\r
for (Index = 0; Index < NumOfChar; Index++) {\r
- ASSERT (BitLen[Index] != 0);\r
Count[BitLen[Index]]++;\r
}\r
-\r
+ \r
+ Start[0] = 0;\r
Start[1] = 0;\r
\r
for (Index = 1; Index <= 16; Index++) {\r
}\r
\r
JuBits = (UINT16) (16 - TableBits);\r
-\r
+ \r
+ Weight[0] = 0;\r
for (Index = 1; Index <= TableBits; Index++) {\r
Start[Index] >>= JuBits;\r
Weight[Index] = (UINT16) (1U << (TableBits - Index));\r
\r
if (Index != 0) {\r
Index3 = (UINT16) (1U << TableBits);\r
- while (Index != Index3) {\r
- Table[Index++] = 0;\r
+ if (Index < Index3) {\r
+ SetMem16 (Table + Index, (Index3 - Index) * sizeof (*Table), 0);\r
}\r
}\r
\r
for (Char = 0; Char < NumOfChar; Char++) {\r
\r
Len = BitLen[Char];\r
- if (Len == 0) {\r
+ if (Len == 0 || Len >= 17) {\r
continue;\r
}\r
\r
\r
while (Index != 0) {\r
if (*Pointer == 0) {\r
- Sd->mRight[Avail] = Sd->mLeft[Avail] = 0;\r
+ Sd->mRight[Avail] = Sd->mLeft[Avail] = 0;\r
*Pointer = Avail++;\r
}\r
\r
{\r
UINT16 Number;\r
UINT16 CharC;\r
- volatile UINT16 Index;\r
+ UINT16 Index;\r
UINT32 Mask;\r
\r
//\r
Sd->mPTTable[Index] = CharC;\r
}\r
\r
- for (Index = 0; Index < nn; Index++) {\r
- Sd->mPTLen[Index] = 0;\r
- }\r
+ SetMem (Sd->mPTLen, nn, 0);\r
\r
return 0;\r
}\r
\r
Index = 0;\r
\r
- while (Index < Number) {\r
+ while (Index < Number && Index < NPT) {\r
\r
CharC = (UINT16) (Sd->mBitBuf >> (BITBUFSIZ - 3));\r
\r
}\r
}\r
\r
- while (Index < nn) {\r
+ while (Index < nn && Index < NPT) {\r
Sd->mPTLen[Index++] = 0;\r
}\r
\r
{\r
UINT16 Number;\r
UINT16 CharC;\r
- volatile UINT16 Index;\r
+ UINT16 Index;\r
UINT32 Mask;\r
\r
Number = (UINT16) GetBits (Sd, CBIT);\r
//\r
CharC = (UINT16) GetBits (Sd, CBIT);\r
\r
- for (Index = 0; Index < NC; Index++) {\r
- Sd->mCLen[Index] = 0;\r
- }\r
+ SetMem (Sd->mCLen, NC, 0);\r
\r
for (Index = 0; Index < 4096; Index++) {\r
Sd->mCTable[Index] = CharC;\r
}\r
\r
Index = 0;\r
- while (Index < Number) {\r
+ while (Index < Number && Index < NC) {\r
CharC = Sd->mPTTable[Sd->mBitBuf >> (BITBUFSIZ - 8)];\r
if (CharC >= NT) {\r
Mask = 1U << (BITBUFSIZ - 1 - 8);\r
}\r
}\r
\r
- while (Index < NC) {\r
- Sd->mCLen[Index++] = 0;\r
- }\r
+ SetMem (Sd->mCLen + Index, NC - Index, 0);\r
\r
MakeTable (Sd, NC, Sd->mCLen, 12, Sd->mCTable);\r
\r
IN OUT VOID *Scratch OPTIONAL\r
)\r
{\r
- volatile UINT32 Index;\r
UINT32 CompSize;\r
UINT32 OrigSize;\r
SCRATCH_DATA *Sd;\r
}\r
\r
Src = Src + 8;\r
+ SetMem (Sd, sizeof (SCRATCH_DATA), 0);\r
\r
- for (Index = 0; Index < sizeof (SCRATCH_DATA); Index++) {\r
- ((UINT8 *) Sd)[Index] = 0;\r
- }\r
//\r
// The length of the field 'Position Set Code Length Array Size' in Block Header.\r
// For UEFI 2.0 de/compression algorithm(Version 1), mPBit = 4\r