Skip to content

Commit

Permalink
Fix potential out of bounds access in msc_disk.c
Browse files Browse the repository at this point in the history
  • Loading branch information
PwnVerse authored Jan 9, 2025
1 parent 2495563 commit 19b6baa
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion examples/device/cdc_msc_freertos/src/msc_disk.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,9 @@ 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);

Expand Down

0 comments on commit 19b6baa

Please sign in to comment.