FatPkg/FatPei: Check array offset before use

Move the range check before array access to enforce the bounds
as expected.

Cc: Ray Ni <ray.ni@intel.com>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
This commit is contained in:
Michael Kubacki 2023-12-12 14:00:40 -05:00 committed by mergify[bot]
parent 7f5e75895b
commit 3ce5f2d445
1 changed files with 1 additions and 1 deletions

View File

@ -459,7 +459,7 @@ GetRecoveryCapsuleInfo (
// Find corresponding physical block device // Find corresponding physical block device
// //
BlockDeviceNo = PrivateData->Volume[Index].BlockDeviceNo; BlockDeviceNo = PrivateData->Volume[Index].BlockDeviceNo;
while (PrivateData->BlockDevice[BlockDeviceNo].Logical && BlockDeviceNo < PrivateData->BlockDeviceCount) { while (BlockDeviceNo < PrivateData->BlockDeviceCount && PrivateData->BlockDevice[BlockDeviceNo].Logical) {
BlockDeviceNo = PrivateData->BlockDevice[BlockDeviceNo].ParentDevNo; BlockDeviceNo = PrivateData->BlockDevice[BlockDeviceNo].ParentDevNo;
} }