summaryrefslogtreecommitdiffstats
path: root/UefiCpuPkg/Library
diff options
context:
space:
mode:
authorMichael D Kinney <michael.d.kinney@intel.com>2024-10-23 18:47:22 -0700
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2024-11-11 01:27:03 +0000
commit171335e34ea9c28845ae37d0d045cb9a5035eedb (patch)
treeff58266b92c0f688fccb5fc46eaedc309cf5c3c8 /UefiCpuPkg/Library
parentfadf4f377e86aebf64bfc0c57cdcfe5e70f04443 (diff)
downloadedk2-171335e34ea9c28845ae37d0d045cb9a5035eedb.tar.gz
edk2-171335e34ea9c28845ae37d0d045cb9a5035eedb.tar.bz2
edk2-171335e34ea9c28845ae37d0d045cb9a5035eedb.zip
UefiCpuPkg/MtrrLib: Fix unit test read overflow
Change conditional check to check the array index before reading the array member to prevent read past end of buffer. Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Diffstat (limited to 'UefiCpuPkg/Library')
-rw-r--r--UefiCpuPkg/Library/MtrrLib/UnitTest/Support.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/UefiCpuPkg/Library/MtrrLib/UnitTest/Support.c b/UefiCpuPkg/Library/MtrrLib/UnitTest/Support.c
index 7df5b9745f..ef3016db83 100644
--- a/UefiCpuPkg/Library/MtrrLib/UnitTest/Support.c
+++ b/UefiCpuPkg/Library/MtrrLib/UnitTest/Support.c
@@ -745,7 +745,7 @@ GetNextDifferentElementInSortedArray (
UINT64 CurrentElement;
CurrentElement = Array[Index];
- while (CurrentElement == Array[Index] && Index < Count) {
+ while ((Index < Count) && (CurrentElement == Array[Index])) {
Index++;
}