Add extra tests to the MassStorage device demo and class driver for validating command blocks from the host.

pull/1469/head
Dean Camera 16 years ago
parent 67f390fe74
commit d0db78432f

@ -256,6 +256,8 @@ static bool ReadInCommandBlock(void)
/* Verify the command block - abort if invalid */ /* Verify the command block - abort if invalid */
if ((CommandBlock.Signature != CBW_SIGNATURE) || if ((CommandBlock.Signature != CBW_SIGNATURE) ||
(CommandBlock.LUN >= TOTAL_LUNS) || (CommandBlock.LUN >= TOTAL_LUNS) ||
(CommandBlock.Flags & 0x1F) ||
(CommandBlock.SCSICommandLength == 0) ||
(CommandBlock.SCSICommandLength > MAX_SCSI_COMMAND_LENGTH)) (CommandBlock.SCSICommandLength > MAX_SCSI_COMMAND_LENGTH))
{ {
/* Stall both data pipes until reset by host */ /* Stall both data pipes until reset by host */

@ -149,6 +149,8 @@ static bool MS_Device_ReadInCommandBlock(USB_ClassInfo_MS_Device_t* const MSInte
if ((MSInterfaceInfo->State.CommandBlock.Signature != MS_CBW_SIGNATURE) || if ((MSInterfaceInfo->State.CommandBlock.Signature != MS_CBW_SIGNATURE) ||
(MSInterfaceInfo->State.CommandBlock.LUN >= MSInterfaceInfo->Config.TotalLUNs) || (MSInterfaceInfo->State.CommandBlock.LUN >= MSInterfaceInfo->Config.TotalLUNs) ||
(MSInterfaceInfo->State.CommandBlock.Flags & 0x1F) ||
(MSInterfaceInfo->State.CommandBlock.SCSICommandLength == 0) ||
(MSInterfaceInfo->State.CommandBlock.SCSICommandLength > 16)) (MSInterfaceInfo->State.CommandBlock.SCSICommandLength > 16))
{ {
Endpoint_StallTransaction(); Endpoint_StallTransaction();

Loading…
Cancel
Save