diff options
| author | Ha Thach <[email protected]> | 2025-01-25 23:46:06 +0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-01-25 23:46:06 +0700 |
| commit | 37e6f496197e0bc35ca0f71cfef80c19be273ca3 (patch) | |
| tree | 8991bd4e093c98548cd44f8e02ac87cae7f849fe /examples/device/cdc_msc | |
| parent | 597446fbeab9524ba675502c3b6a42d51c0b57ad (diff) | |
| parent | f6f02f189354bf3576372611145f670f29e0ba58 (diff) | |
Merge pull request #2964 from hathach/fix-2939
fix bug introduced by 2939, with correct offset check logic
Diffstat (limited to 'examples/device/cdc_msc')
| -rw-r--r-- | examples/device/cdc_msc/src/msc_disk.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/examples/device/cdc_msc/src/msc_disk.c b/examples/device/cdc_msc/src/msc_disk.c index c1132bbfc..d325d77fa 100644 --- a/examples/device/cdc_msc/src/msc_disk.c +++ b/examples/device/cdc_msc/src/msc_disk.c @@ -190,10 +190,14 @@ int32_t tud_msc_read10_cb(uint8_t lun, uint32_t lba, uint32_t offset, void* buff (void) lun; // out of ramdisk - if ( lba >= DISK_BLOCK_NUM ) return -1; + if ( lba >= DISK_BLOCK_NUM ) { + return -1; + } // Check for overflow of offset + bufsize - if ( offset + bufsize >= DISK_BLOCK_SIZE ) return -1; + if ( offset + bufsize > DISK_BLOCK_SIZE ) { + return -1; + } uint8_t const* addr = msc_disk[lba] + offset; memcpy(buffer, addr, bufsize); |
