Add extra tests to the MassStorage device demo and class driver for validating comman...
authorDean Camera <dean@fourwalledcubicle.com>
Tue, 21 Jul 2009 04:46:48 +0000 (04:46 +0000)
committerDean Camera <dean@fourwalledcubicle.com>
Tue, 21 Jul 2009 04:46:48 +0000 (04:46 +0000)
Demos/Device/LowLevel/MassStorage/MassStorage.c
LUFA/Drivers/USB/Class/Device/MassStorage.c

index ebb8e5c..2c80fc5 100644 (file)
@@ -256,6 +256,8 @@ static bool ReadInCommandBlock(void)
        /* Verify the command block - abort if invalid */\r
        if ((CommandBlock.Signature         != CBW_SIGNATURE) ||\r
            (CommandBlock.LUN               >= TOTAL_LUNS)    ||\r
+               (CommandBlock.Flags              & 0x1F)          ||\r
+               (CommandBlock.SCSICommandLength == 0)             ||\r
                (CommandBlock.SCSICommandLength >  MAX_SCSI_COMMAND_LENGTH))\r
        {\r
                /* Stall both data pipes until reset by host */\r
index ceb4b96..f7f3fd9 100644 (file)
@@ -149,6 +149,8 @@ static bool MS_Device_ReadInCommandBlock(USB_ClassInfo_MS_Device_t* const MSInte
 \r
        if ((MSInterfaceInfo->State.CommandBlock.Signature         != MS_CBW_SIGNATURE)                  ||\r
            (MSInterfaceInfo->State.CommandBlock.LUN               >= MSInterfaceInfo->Config.TotalLUNs) ||\r
+               (MSInterfaceInfo->State.CommandBlock.Flags              & 0x1F)                              ||\r
+               (MSInterfaceInfo->State.CommandBlock.SCSICommandLength == 0)                                 ||\r
                (MSInterfaceInfo->State.CommandBlock.SCSICommandLength >  16))\r
        {\r
                Endpoint_StallTransaction();\r