usb: mass_storage: check LBA range

Check if LBA is in range of the memory size.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
This commit is contained in:
Johann Fischer 2020-03-04 00:11:01 +01:00 committed by Johan Hedberg
commit 23ace0e556

View file

@ -438,6 +438,13 @@ static bool infoTransfer(void)
(cbw.CB[5] << 0);
LOG_DBG("LBA (block) : 0x%x ", n);
if ((n * BLOCK_SIZE) >= memory_size) {
LOG_ERR("LBA out of range");
csw.Status = CSW_FAILED;
sendCSW();
return false;
}
addr = n * BLOCK_SIZE;
/* Number of Blocks to transfer */