MdeModulePkg/SdBlockIoPei: Add check for DeviceIndex

DeviceIndex is used as index in Slot[]. The max size of Slot[]
is SD_PEIM_MAX_SLOTS. So DeviceIndex should be checked before used.

Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Signed-off-by: Shenglei Zhang <shenglei.zhang@intel.com>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
This commit is contained in:
Shenglei Zhang 2019-10-15 13:51:55 +08:00 committed by Liming Gao
parent df50c2fcd8
commit d3eac77eeb

@ -174,7 +174,7 @@ SdBlockIoPeimGetMediaInfo (
Private = GET_SD_PEIM_HC_PRIVATE_DATA_FROM_THIS (This);
if ((DeviceIndex == 0) || (DeviceIndex > Private->TotalBlkIoDevices)) {
if ((DeviceIndex == 0) || (DeviceIndex > Private->TotalBlkIoDevices) || (DeviceIndex > SD_PEIM_MAX_SLOTS)) {
return EFI_INVALID_PARAMETER;
}
@ -252,7 +252,7 @@ SdBlockIoPeimReadBlocks (
return EFI_SUCCESS;
}
if ((DeviceIndex == 0) || (DeviceIndex > Private->TotalBlkIoDevices)) {
if ((DeviceIndex == 0) || (DeviceIndex > Private->TotalBlkIoDevices) || (DeviceIndex > SD_PEIM_MAX_SLOTS)) {
return EFI_INVALID_PARAMETER;
}