summaryrefslogtreecommitdiffstats
path: root/sys/scsi/scsi_base.c
diff options
context:
space:
mode:
authordufault <dufault@FreeBSD.org>1995-01-24 12:04:56 +0000
committerdufault <dufault@FreeBSD.org>1995-01-24 12:04:56 +0000
commitfd80285ef935db8289b5581db14bd8e113016382 (patch)
tree3b22f3852242f6ca42b9ab3bf820f690108ae1b6 /sys/scsi/scsi_base.c
parenta9e08ab1e382c62f084401bff2ad5528a3b71e3e (diff)
downloadFreeBSD-src-fd80285ef935db8289b5581db14bd8e113016382.zip
FreeBSD-src-fd80285ef935db8289b5581db14bd8e113016382.tar.gz
1. Reject obviously broken CDB command lengths
2. Use "uprintf" (instead of printf) to log the "tape not ready" message
Diffstat (limited to 'sys/scsi/scsi_base.c')
-rw-r--r--sys/scsi/scsi_base.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/sys/scsi/scsi_base.c b/sys/scsi/scsi_base.c
index ac790cc..6dc2249 100644
--- a/sys/scsi/scsi_base.c
+++ b/sys/scsi/scsi_base.c
@@ -8,7 +8,7 @@
* file.
*
* Written by Julian Elischer (julian@dialix.oz.au)
- * $Id: scsi_base.c,v 1.16 1995/01/08 13:38:31 dufault Exp $
+ * $Id: scsi_base.c,v 1.17 1995/01/19 12:41:35 dufault Exp $
*/
#define SPLSD splbio
@@ -406,6 +406,21 @@ scsi_scsi_cmd(sc_link, scsi_cmd, cmdlen, data_addr, datalen,
errval retval;
u_int32 s;
+ /*
+ * Illegal command lengths will wedge host adapter software.
+ * Reject zero length commands and assert all defined commands
+ * are the correct length.
+ */
+ if (cmdlen == 0)
+ return EFAULT;
+ else
+ {
+ static u_int8 sizes[] = {6, 10, 10, 0, 0, 12, 0, 0 };
+ u_int8 size = sizes[((scsi_cmd->opcode) >> 5)];
+ if (size && (size != cmdlen))
+ return EIO;
+ }
+
if (bp && !(flags & SCSI_USER)) flags |= SCSI_NOSLEEP;
SC_DEBUG(sc_link, SDEV_DB2, ("scsi_cmd\n"));
OpenPOWER on IntegriCloud