diff options
author | dufault <dufault@FreeBSD.org> | 1995-01-24 12:04:56 +0000 |
---|---|---|
committer | dufault <dufault@FreeBSD.org> | 1995-01-24 12:04:56 +0000 |
commit | fd80285ef935db8289b5581db14bd8e113016382 (patch) | |
tree | 3b22f3852242f6ca42b9ab3bf820f690108ae1b6 /sys/scsi | |
parent | a9e08ab1e382c62f084401bff2ad5528a3b71e3e (diff) | |
download | FreeBSD-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')
-rw-r--r-- | sys/scsi/scsi_base.c | 17 | ||||
-rw-r--r-- | sys/scsi/st.c | 4 |
2 files changed, 18 insertions, 3 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")); diff --git a/sys/scsi/st.c b/sys/scsi/st.c index 5dba78e..86f31e7 100644 --- a/sys/scsi/st.c +++ b/sys/scsi/st.c @@ -12,7 +12,7 @@ * on the understanding that TFS is not responsible for the correct * functioning of this software in any circumstances. * - * $Id: st.c,v 1.23 1994/12/16 06:03:26 phk Exp $ + * $Id: st.c,v 1.24 1995/01/08 13:38:36 dufault Exp $ */ /* @@ -602,7 +602,7 @@ stopen(dev, flags) * This time take notice of the return result */ if (errno = (scsi_test_unit_ready(sc_link, 0))) { - printf("st%d: not ready\n", unit); + uprintf("st%d: not ready\n", unit); st_unmount(unit, NOEJECT); return (errno); } |