Skip to content

Commit 19d28a9

Browse files
committed
Fix also cdc_msc example.
1 parent bd08753 commit 19d28a9

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

examples/device/cdc_msc/src/msc_disk.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,9 @@ int32_t tud_msc_read10_cb(uint8_t lun, uint32_t lba, uint32_t offset, void* buff
192192
// out of ramdisk
193193
if ( lba >= DISK_BLOCK_NUM ) return -1;
194194

195+
// Check for overflow of offset + bufsize
196+
if ( offset + bufsize >= DISK_BLOCK_SIZE ) return -1;
197+
195198
uint8_t const* addr = msc_disk[lba] + offset;
196199
memcpy(buffer, addr, bufsize);
197200

0 commit comments

Comments
 (0)