Don't overwrite array bounds when mass storage device reports > 2 LUNs

USG_1.0
Robert Fisk 7 years ago
parent 0c7cc00c0a
commit 8f1d3d9a72

@ -300,6 +300,10 @@ static USBH_StatusTypeDef USBH_MSC_ClassRequest(USBH_HandleTypeDef *phost)
MSC_Handle->max_lun = (uint8_t )(MSC_Handle->max_lun) + 1; MSC_Handle->max_lun = (uint8_t )(MSC_Handle->max_lun) + 1;
USBH_UsrLog ("Number of supported LUN: %lu", (int32_t)(MSC_Handle->max_lun)); USBH_UsrLog ("Number of supported LUN: %lu", (int32_t)(MSC_Handle->max_lun));
if (MSC_Handle->max_lun > MAX_SUPPORTED_LUN)
{
MSC_Handle->max_lun = MAX_SUPPORTED_LUN;
}
for(i = 0; i < MSC_Handle->max_lun; i++) for(i = 0; i < MSC_Handle->max_lun; i++)
{ {
MSC_Handle->unit[i].prev_ready_state = USBH_FAIL; MSC_Handle->unit[i].prev_ready_state = USBH_FAIL;

Loading…
Cancel
Save