summaryrefslogtreecommitdiffstats
path: root/UefiCpuPkg/Library
diff options
context:
space:
mode:
authorxli24 <xli24@6f19259b-4bc3-4df7-8a09-765794883524>2010-03-04 06:38:22 +0000
committerxli24 <xli24@6f19259b-4bc3-4df7-8a09-765794883524>2010-03-04 06:38:22 +0000
commit5bdfa4e58ad64cbc825d03397b15f5b2bcebda4e (patch)
tree70596ff95e7b56cf54205c6d138508f7a9a03e2b /UefiCpuPkg/Library
parent2d5ac154354a192fa40f218a43f766214fdbb311 (diff)
downloadedk2-5bdfa4e58ad64cbc825d03397b15f5b2bcebda4e.tar.gz
edk2-5bdfa4e58ad64cbc825d03397b15f5b2bcebda4e.tar.bz2
edk2-5bdfa4e58ad64cbc825d03397b15f5b2bcebda4e.zip
Add array index check to avoid potential buffer overflow.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10179 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'UefiCpuPkg/Library')
-rw-r--r--UefiCpuPkg/Library/MtrrLib/MtrrLib.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/UefiCpuPkg/Library/MtrrLib/MtrrLib.c b/UefiCpuPkg/Library/MtrrLib/MtrrLib.c
index 3c3115c8a0..4e6878f282 100644
--- a/UefiCpuPkg/Library/MtrrLib/MtrrLib.c
+++ b/UefiCpuPkg/Library/MtrrLib/MtrrLib.c
@@ -1156,6 +1156,8 @@ MtrrGetMemoryAttribute (
// Go through the variable MTRR
//
VariableMtrrCount = GetVariableMtrrCount ();
+ ASSERT (VariableMtrrCount <= MTRR_NUMBER_OF_VARIABLE_MTRR);
+
for (Index = 0; Index < VariableMtrrCount; Index++) {
if (VariableMtrr[Index].Valid) {
if (Address >= VariableMtrr[Index].BaseAddress &&
@@ -1189,6 +1191,8 @@ MtrrGetVariableMtrr (
UINT32 VariableMtrrCount;
VariableMtrrCount = GetVariableMtrrCount ();
+ ASSERT (VariableMtrrCount <= MTRR_NUMBER_OF_VARIABLE_MTRR);
+
for (Index = 0; Index < VariableMtrrCount; Index++) {
VariableSettings->Mtrr[Index].Base =
AsmReadMsr64 (MTRR_LIB_IA32_VARIABLE_MTRR_BASE + (Index << 1));
@@ -1215,6 +1219,8 @@ MtrrSetVariableMtrrWorker (
UINT32 VariableMtrrCount;
VariableMtrrCount = GetVariableMtrrCount ();
+ ASSERT (VariableMtrrCount <= MTRR_NUMBER_OF_VARIABLE_MTRR);
+
for (Index = 0; Index < VariableMtrrCount; Index++) {
AsmWriteMsr64 (
MTRR_LIB_IA32_VARIABLE_MTRR_BASE + (Index << 1),