diff options
| author | hathach <[email protected]> | 2021-08-28 20:26:56 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2021-08-28 20:26:56 +0700 |
| commit | 54013737d5949152959e470d3df3d0465296e251 (patch) | |
| tree | 24f2a933c874101a1abe302783d2f944ad0344ca /examples/device/dynamic_configuration/src | |
| parent | a53839ef44345377e863e4635909c2dacc81f059 (diff) | |
fix msc example with out of bound lba (due to compliant test)
Diffstat (limited to 'examples/device/dynamic_configuration/src')
| -rw-r--r-- | examples/device/dynamic_configuration/src/msc_disk.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/examples/device/dynamic_configuration/src/msc_disk.c b/examples/device/dynamic_configuration/src/msc_disk.c index a4826fbe1..b9205f0c2 100644 --- a/examples/device/dynamic_configuration/src/msc_disk.c +++ b/examples/device/dynamic_configuration/src/msc_disk.c @@ -178,6 +178,9 @@ 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; + uint8_t const* addr = msc_disk[lba] + offset; memcpy(buffer, addr, bufsize); @@ -190,6 +193,9 @@ int32_t tud_msc_write10_cb(uint8_t lun, uint32_t lba, uint32_t offset, uint8_t* { (void) lun; + // out of ramdisk + if ( lba >= DISK_BLOCK_NUM ) return -1; + #ifndef CFG_EXAMPLE_MSC_READONLY uint8_t* addr = msc_disk[lba] + offset; memcpy(addr, buffer, bufsize); |
