Fix potential out of bounds access in msc_disk.c
This commit is contained in:
@@ -191,6 +191,8 @@ int32_t tud_msc_read10_cb(uint8_t lun, uint32_t lba, uint32_t offset, void* buff
|
||||
|
||||
// out of ramdisk
|
||||
if ( lba >= DISK_BLOCK_NUM ) return -1;
|
||||
// Check for overflow of offset + bufsize
|
||||
if ( offset + bufsize >= DISK_BLOCK_SIZE ) return -1;
|
||||
|
||||
uint8_t const* addr = msc_disk[lba] + offset;
|
||||
memcpy(buffer, addr, bufsize);
|
||||
|
Reference in New Issue
Block a user