From 3ce5f2d445e51efe2aebaa227a055e5c8522d00b Mon Sep 17 00:00:00 2001 From: Michael Kubacki Date: Tue, 12 Dec 2023 14:00:40 -0500 Subject: FatPkg/FatPei: Check array offset before use Move the range check before array access to enforce the bounds as expected. Cc: Ray Ni Signed-off-by: Michael Kubacki Reviewed-by: Michael D Kinney --- FatPkg/FatPei/FatLiteApi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'FatPkg') diff --git a/FatPkg/FatPei/FatLiteApi.c b/FatPkg/FatPei/FatLiteApi.c index cc48c4c66b..b89ab7009d 100644 --- a/FatPkg/FatPei/FatLiteApi.c +++ b/FatPkg/FatPei/FatLiteApi.c @@ -459,7 +459,7 @@ GetRecoveryCapsuleInfo ( // Find corresponding physical block device // 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; } -- cgit v1.2.3