Created
March 26, 2012 04:35
-
-
Save voidlizard/2202952 to your computer and use it in GitHub Desktop.
STM32_F105-07_F2xx_USB-Host-Device_Lib_V2.0.0 USBD MSC SCSI block overflow bug patch (Maximum storage size ~ 4G because of uint32_t overflow)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/STM32_F105-07_F2xx_USB-Host-Device_Lib_V2.0.0/Libraries/STM32_USB_Device_Library/Class/msc/src/usbd_msc_scsi.c b/lib/STM32_F105-07_F2xx_USB-Host-Device_Lib_V2.0.0/Libraries/STM32_USB_Device_Library/Class/msc/src/usbd_msc_scsi.c | |
index 3db6ea1..1cd4f10 100644 | |
--- a/lib/STM32_F105-07_F2xx_USB-Host-Device_Lib_V2.0.0/Libraries/STM32_USB_Device_Library/Class/msc/src/usbd_msc_scsi.c | |
+++ b/lib/STM32_F105-07_F2xx_USB-Host-Device_Lib_V2.0.0/Libraries/STM32_USB_Device_Library/Class/msc/src/usbd_msc_scsi.c | |
@@ -70,11 +70,11 @@ SCSI_Sense_TypeDef SCSI_Sense [SENSE_LIST_DEEPTH]; | |
uint8_t SCSI_Sense_Head; | |
uint8_t SCSI_Sense_Tail; | |
-uint32_t SCSI_blk_size; | |
-uint32_t SCSI_blk_nbr; | |
+static uint32_t SCSI_blk_size; | |
+static uint32_t SCSI_blk_nbr; | |
-uint32_t SCSI_blk_addr; | |
-uint32_t SCSI_blk_len; | |
+static uint64_t SCSI_blk_addr; | |
+static uint32_t SCSI_blk_len; | |
USB_OTG_CORE_HANDLE *cdev; | |
/** | |
@@ -97,7 +97,7 @@ static int8_t SCSI_Write10(uint8_t lun , uint8_t *params); | |
static int8_t SCSI_Read10(uint8_t lun , uint8_t *params); | |
static int8_t SCSI_Verify10(uint8_t lun, uint8_t *params); | |
static int8_t SCSI_CheckAddressRange (uint8_t lun , | |
- uint32_t blk_offset , | |
+ uint64_t blk_offset , | |
uint16_t blk_nbr); | |
static int8_t SCSI_ProcessRead (uint8_t lun); | |
@@ -608,7 +608,7 @@ static int8_t SCSI_Verify10(uint8_t lun , uint8_t *params){ | |
* @param blk_nbr: number of block to be processed | |
* @retval status | |
*/ | |
-static int8_t SCSI_CheckAddressRange (uint8_t lun , uint32_t blk_offset , uint16_t blk_nbr) | |
+static int8_t SCSI_CheckAddressRange (uint8_t lun , uint64_t blk_offset , uint16_t blk_nbr) | |
{ | |
if ((blk_offset + blk_nbr) > SCSI_blk_nbr ) | |
@@ -635,7 +635,7 @@ static int8_t SCSI_ProcessRead (uint8_t lun) | |
status = USBD_STORAGE_fops->Read(lun , | |
MSC_BOT_Data, | |
- SCSI_blk_addr / SCSI_blk_size, | |
+ (uint32_t)(SCSI_blk_addr / SCSI_blk_size), | |
len / SCSI_blk_size); | |
if( status == (-100) ) { // FIXME: hack to handle NAK condition?? | |
@@ -685,7 +685,7 @@ static int8_t SCSI_ProcessWrite (uint8_t lun) | |
if(USBD_STORAGE_fops->Write(lun , | |
MSC_BOT_Data, | |
- SCSI_blk_addr / SCSI_blk_size, | |
+ (uint32_t)(SCSI_blk_addr / SCSI_blk_size), | |
len / SCSI_blk_size) < 0) | |
{ | |
SCSI_SenseCode(lun, HARDWARE_ERROR, WRITE_FAULT); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment