mirror of https://github.com/acidanthera/audk.git
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
This commit is contained in:
parent
2d5ac15435
commit
5bdfa4e58a
|
@ -857,6 +857,7 @@ RefreshGcdMemoryAttributes (
|
||||||
UINT32 FirmwareVariableMtrrCount;
|
UINT32 FirmwareVariableMtrrCount;
|
||||||
|
|
||||||
FirmwareVariableMtrrCount = GetFirmwareVariableMtrrCount ();
|
FirmwareVariableMtrrCount = GetFirmwareVariableMtrrCount ();
|
||||||
|
ASSERT (FirmwareVariableMtrrCount <= MTRR_NUMBER_OF_VARIABLE_MTRR);
|
||||||
|
|
||||||
// mIsFlushingGCD = TRUE;
|
// mIsFlushingGCD = TRUE;
|
||||||
mIsFlushingGCD = FALSE;
|
mIsFlushingGCD = FALSE;
|
||||||
|
|
|
@ -1156,6 +1156,8 @@ MtrrGetMemoryAttribute (
|
||||||
// Go through the variable MTRR
|
// Go through the variable MTRR
|
||||||
//
|
//
|
||||||
VariableMtrrCount = GetVariableMtrrCount ();
|
VariableMtrrCount = GetVariableMtrrCount ();
|
||||||
|
ASSERT (VariableMtrrCount <= MTRR_NUMBER_OF_VARIABLE_MTRR);
|
||||||
|
|
||||||
for (Index = 0; Index < VariableMtrrCount; Index++) {
|
for (Index = 0; Index < VariableMtrrCount; Index++) {
|
||||||
if (VariableMtrr[Index].Valid) {
|
if (VariableMtrr[Index].Valid) {
|
||||||
if (Address >= VariableMtrr[Index].BaseAddress &&
|
if (Address >= VariableMtrr[Index].BaseAddress &&
|
||||||
|
@ -1189,6 +1191,8 @@ MtrrGetVariableMtrr (
|
||||||
UINT32 VariableMtrrCount;
|
UINT32 VariableMtrrCount;
|
||||||
|
|
||||||
VariableMtrrCount = GetVariableMtrrCount ();
|
VariableMtrrCount = GetVariableMtrrCount ();
|
||||||
|
ASSERT (VariableMtrrCount <= MTRR_NUMBER_OF_VARIABLE_MTRR);
|
||||||
|
|
||||||
for (Index = 0; Index < VariableMtrrCount; Index++) {
|
for (Index = 0; Index < VariableMtrrCount; Index++) {
|
||||||
VariableSettings->Mtrr[Index].Base =
|
VariableSettings->Mtrr[Index].Base =
|
||||||
AsmReadMsr64 (MTRR_LIB_IA32_VARIABLE_MTRR_BASE + (Index << 1));
|
AsmReadMsr64 (MTRR_LIB_IA32_VARIABLE_MTRR_BASE + (Index << 1));
|
||||||
|
@ -1215,6 +1219,8 @@ MtrrSetVariableMtrrWorker (
|
||||||
UINT32 VariableMtrrCount;
|
UINT32 VariableMtrrCount;
|
||||||
|
|
||||||
VariableMtrrCount = GetVariableMtrrCount ();
|
VariableMtrrCount = GetVariableMtrrCount ();
|
||||||
|
ASSERT (VariableMtrrCount <= MTRR_NUMBER_OF_VARIABLE_MTRR);
|
||||||
|
|
||||||
for (Index = 0; Index < VariableMtrrCount; Index++) {
|
for (Index = 0; Index < VariableMtrrCount; Index++) {
|
||||||
AsmWriteMsr64 (
|
AsmWriteMsr64 (
|
||||||
MTRR_LIB_IA32_VARIABLE_MTRR_BASE + (Index << 1),
|
MTRR_LIB_IA32_VARIABLE_MTRR_BASE + (Index << 1),
|
||||||
|
|
Loading…
Reference in New Issue