[Taranis] Bug on SD massstorage write (on block numbers > 0xFFFF)

This commit is contained in:
bsongis@gmail.com
2013-05-18 20:38:11 +00:00
parent 878c7b081c
commit ae82c5f7a0
2 changed files with 13 additions and 3 deletions
@@ -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;
}
+7 -3
View File
@@ -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, &sector_count) != RES_OK)
return -1;
static DWORD sector_count = 0;
if (sector_count == 0) {
if (disk_ioctl(0, GET_SECTOR_COUNT, &sector_count) != RES_OK) {
sector_count = 0;
return -1;
}
}
*block_num = sector_count;
}