Skip to content

Commit dae2e71

Browse files
jfischer-nonashif
authored andcommitted
usb: mass_storage: check LBA range
Check if LBA is in range of the memory size. Signed-off-by: Johann Fischer <[email protected]> Signed-off-by: David Brown <[email protected]>
1 parent afb307d commit dae2e71

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

subsys/usb/class/mass_storage.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,13 @@ static bool infoTransfer(void)
433433
(cbw.CB[5] << 0);
434434

435435
LOG_DBG("LBA (block) : 0x%x ", n);
436+
if ((n * BLOCK_SIZE) >= memory_size) {
437+
LOG_ERR("LBA out of range");
438+
csw.Status = CSW_FAILED;
439+
sendCSW();
440+
return false;
441+
}
442+
436443
addr = n * BLOCK_SIZE;
437444

438445
/* Number of Blocks to transfer */

0 commit comments

Comments
 (0)