[Taranis] Bug on SD massstorage write (on block numbers > 0xFFFF)
This commit is contained in:
+6
@@ -616,12 +616,18 @@ static int8_t SCSI_Verify10(uint8_t lun , uint8_t *params){
|
||||
*/
|
||||
static int8_t SCSI_CheckAddressRange (uint8_t lun , uint32_t blk_offset , uint16_t blk_nbr)
|
||||
{
|
||||
if (USBD_STORAGE_fops->GetCapacity(lun, &SCSI_blk_nbr, &SCSI_blk_size) != 0)
|
||||
{
|
||||
SCSI_SenseCode(lun, NOT_READY, MEDIUM_NOT_PRESENT);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((blk_offset + blk_nbr) > SCSI_blk_nbr )
|
||||
{
|
||||
SCSI_SenseCode(lun, ILLEGAL_REQUEST, ADDRESS_OUT_OF_RANGE);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -148,9 +148,13 @@ int8_t STORAGE_GetCapacity (uint8_t lun, uint32_t *block_num, uint32_t *block_si
|
||||
|
||||
*block_size = 512;
|
||||
|
||||
DWORD sector_count = 0;
|
||||
if (disk_ioctl(0, GET_SECTOR_COUNT, §or_count) != RES_OK)
|
||||
return -1;
|
||||
static DWORD sector_count = 0;
|
||||
if (sector_count == 0) {
|
||||
if (disk_ioctl(0, GET_SECTOR_COUNT, §or_count) != RES_OK) {
|
||||
sector_count = 0;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
*block_num = sector_count;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user