diff options
| author | Ha Thach <[email protected]> | 2021-10-01 00:08:32 +0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-10-01 00:08:32 +0700 |
| commit | e7ef322268ae215c8a281ae135dca816841a7008 (patch) | |
| tree | 72fa7bab64f4deaf9e6d700a6b447f8b090996d9 /src/class | |
| parent | 5b55b0d2594d86dc17c806d51aa7f28679947990 (diff) | |
| parent | 7708997a679f61b2ea8fdc7bec880cd19ecaa28f (diff) | |
Merge pull request #1113 from szymonh/master
Assure msc device block size is not zero
Diffstat (limited to 'src/class')
| -rw-r--r-- | src/class/msc/msc_device.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/class/msc/msc_device.c b/src/class/msc/msc_device.c index 0fd592129..87ebe227f 100644 --- a/src/class/msc/msc_device.c +++ b/src/class/msc/msc_device.c @@ -1,4 +1,4 @@ -/* +/* * The MIT License (MIT) * * Copyright (c) 2019 Ha Thach (tinyusb.org) @@ -182,11 +182,16 @@ uint8_t rdwr10_validate_cmd(msc_cbw_t const* cbw) TU_LOG(MSC_DEBUG, " SCSI case 8 (Hi <> Do)\r\n"); status = MSC_CSW_STATUS_PHASE_ERROR; } - else if ( !block_count ) + else if ( 0 == block_count ) { - TU_LOG(MSC_DEBUG, " SCSI case 4 Hi > Dn\r\n"); + TU_LOG(MSC_DEBUG, " SCSI case 4 Hi > Dn (READ10) or case 9 Ho > Dn (WRITE10) \r\n"); status = MSC_CSW_STATUS_FAILED; } + else if ( cbw->total_bytes / block_count == 0 ) + { + TU_LOG(MSC_DEBUG, " Computed block size = 0. SCSI case 7 Hi < Di (READ10) or case 13 Ho < Do (WRIT10)\r\n"); + status = MSC_CSW_STATUS_PHASE_ERROR; + } } return status; |
