diff options
| author | Ritvik <[email protected]> | 2025-01-09 15:40:21 -0500 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-01-09 15:40:21 -0500 |
| commit | 19b6baa45521a221c4d0a6a2cf6d9e210551bf73 (patch) | |
| tree | 43f365d8fce1f4aa9e170f5e82cb85abf4b1f9c0 /examples | |
| parent | 2495563600f1cd2220d740895fad701dd48f1fb6 (diff) | |
Fix potential out of bounds access in msc_disk.c
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/device/cdc_msc_freertos/src/msc_disk.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/examples/device/cdc_msc_freertos/src/msc_disk.c b/examples/device/cdc_msc_freertos/src/msc_disk.c index d2f8628f1..f48d976f2 100644 --- a/examples/device/cdc_msc_freertos/src/msc_disk.c +++ b/examples/device/cdc_msc_freertos/src/msc_disk.c @@ -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); |
