diff options
-rw-r--r-- | sys/dev/pv/hvs.c | 5 | ||||
-rw-r--r-- | sys/dev/usb/umass.c | 10 | ||||
-rw-r--r-- | sys/scsi/mpath_hds.c | 6 | ||||
-rw-r--r-- | sys/scsi/scsi_all.h | 6 | ||||
-rw-r--r-- | sys/scsi/scsi_base.c | 15 |
5 files changed, 22 insertions, 20 deletions
diff --git a/sys/dev/pv/hvs.c b/sys/dev/pv/hvs.c index 271d7270455..0d5e6523561 100644 --- a/sys/dev/pv/hvs.c +++ b/sys/dev/pv/hvs.c @@ -590,7 +590,8 @@ fixup_inquiry(struct scsi_xfer *xs, struct hvs_srb *srb) int datalen, resplen; char vendor[8]; - resplen = srb->srb_datalen >= 5 ? inq->additional_length + 5 : 0; + resplen = srb->srb_datalen >= SID_SCSI2_HDRLEN ? + SID_SCSI2_HDRLEN + inq->additional_length : 0; datalen = MIN(resplen, srb->srb_datalen); /* Fixup wrong response from WS2012 */ @@ -601,7 +602,7 @@ fixup_inquiry(struct scsi_xfer *xs, struct hvs_srb *srb) (inq->version == 0 || inq->response_format == 0)) { inq->version = SCSI_REV_SPC3; inq->response_format = SID_SCSI2_RESPONSE; - } else if (datalen >= SID_INQUIRY_HDR + SID_SCSI2_ALEN) { + } else if (datalen >= SID_SCSI2_HDRLEN + SID_SCSI2_ALEN) { /* * Upgrade SPC2 to SPC3 if host is Win8 or WS2012 R2 * to support UNMAP feature. diff --git a/sys/dev/usb/umass.c b/sys/dev/usb/umass.c index 02391ee39ef..de23c439817 100644 --- a/sys/dev/usb/umass.c +++ b/sys/dev/usb/umass.c @@ -1,4 +1,4 @@ -/* $OpenBSD: umass.c,v 1.77 2020/06/24 07:46:10 patrick Exp $ */ +/* $OpenBSD: umass.c,v 1.78 2020/09/05 14:21:52 krw Exp $ */ /* $NetBSD: umass.c,v 1.116 2004/06/30 05:53:46 mycroft Exp $ */ /* @@ -819,13 +819,13 @@ umass_adjust_transfer(struct umass_softc *sc) { switch (sc->sc_cmd) { case UMASS_CPROTO_UFI: - sc->cbw.bCDBLength = UFI_COMMAND_LENGTH; + sc->cbw.bCDBLength = UFI_COMMAND_LENGTH; /* Adjust the length field in certain scsi commands. */ switch (sc->cbw.CBWCDB[0]) { case INQUIRY: - if (sc->transfer_datalen > 36) { - sc->transfer_datalen = 36; - sc->cbw.CBWCDB[4] = 36; + if (sc->transfer_datalen > SID_SCSI2_HDRLEN + SID_SCSI2_ALEN) { + sc->transfer_datalen = SID_SCSI2_HDRLEN + SID_SCSI2_ALEN; + sc->cbw.CBWCDB[4] = sc->transfer_datalen; } break; case MODE_SENSE_BIG: diff --git a/sys/scsi/mpath_hds.c b/sys/scsi/mpath_hds.c index 3662beb26ec..6e64c807153 100644 --- a/sys/scsi/mpath_hds.c +++ b/sys/scsi/mpath_hds.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mpath_hds.c,v 1.23 2020/06/30 18:43:37 krw Exp $ */ +/* $OpenBSD: mpath_hds.c,v 1.24 2020/09/05 14:21:52 krw Exp $ */ /* * Copyright (c) 2011 David Gwynne <dlg@openbsd.org> @@ -261,7 +261,7 @@ hds_inquiry(struct scsi_link *link, int *mode) { struct scsi_xfer *xs; u_int8_t *buf; - size_t len = link->inqdata.additional_length + 5; + size_t len = SID_SCSI2_HDRLEN + link->inqdata.additional_length; int error; if (len < HDS_INQ_TYPE_OFFSET + sizeof(int)) @@ -296,7 +296,7 @@ hds_info(struct hds_softc *sc) struct scsi_link *link = sc->sc_path.p_link; struct scsi_xfer *xs; u_int8_t *buf; - size_t len = link->inqdata.additional_length + 5; + size_t len = SID_SCSI2_HDRLEN + link->inqdata.additional_length; char ldev[9], ctrl, port; int error; diff --git a/sys/scsi/scsi_all.h b/sys/scsi/scsi_all.h index a0b013ae3ae..a537de82a7a 100644 --- a/sys/scsi/scsi_all.h +++ b/sys/scsi/scsi_all.h @@ -1,4 +1,4 @@ -/* $OpenBSD: scsi_all.h,v 1.62 2020/09/02 23:41:01 krw Exp $ */ +/* $OpenBSD: scsi_all.h,v 1.63 2020/09/05 14:21:52 krw Exp $ */ /* $NetBSD: scsi_all.h,v 1.10 1996/09/12 01:57:17 thorpej Exp $ */ /* @@ -252,8 +252,8 @@ struct scsi_inquiry_data { #define SID_TrmIOP 0x40 /* obsolete */ #define SID_AENC 0x80 /* obsolete */ u_int8_t additional_length; -#define SID_INQUIRY_HDR 5 /* Bytes up to & including additional_length */ -#define SID_SCSI2_ALEN 31 /* Additional bytes of basic SCSI2 info */ +#define SID_SCSI2_HDRLEN 5 /* Bytes up to & including additional_length */ +#define SID_SCSI2_ALEN 31 /* Additional bytes of basic SCSI2 info */ u_int8_t spc3_flags; #define SPC3_SID_PROTECT 0x01 /* 0 == Type 0, 1 == Type 1, 2 or 3 */ #define SPC3_SID_RESERVED 0x06 diff --git a/sys/scsi/scsi_base.c b/sys/scsi/scsi_base.c index f582d5fb07c..00402e42be7 100644 --- a/sys/scsi/scsi_base.c +++ b/sys/scsi/scsi_base.c @@ -1,4 +1,4 @@ -/* $OpenBSD: scsi_base.c,v 1.273 2020/09/01 12:17:53 krw Exp $ */ +/* $OpenBSD: scsi_base.c,v 1.274 2020/09/05 14:21:52 krw Exp $ */ /* $NetBSD: scsi_base.c,v 1.43 1997/04/02 02:29:36 mycroft Exp $ */ /* @@ -849,7 +849,7 @@ scsi_inquire(struct scsi_link *link, struct scsi_inquiry_data *inqbuf, * information. This avoids problems with devices that choke trying to * supply more. */ - bytes = 36; + bytes = SID_SCSI2_HDRLEN + SID_SCSI2_ALEN; #ifdef SCSIDEBUG again: @@ -872,13 +872,14 @@ again: #ifdef SCSIDEBUG sc_print_addr(link); - if (bytes > inqbuf->additional_length + 4) - bytes = inqbuf->additional_length + 4; + if (bytes > SID_SCSI2_HDRLEN + inqbuf->additional_length) + bytes = SID_SCSI2_HDRLEN + inqbuf->additional_length; printf("got %zu of %u bytes of inquiry data:\n", - bytes, inqbuf->additional_length + 4); + bytes, SID_SCSI2_HDRLEN + inqbuf->additional_length); scsi_show_mem((u_char *)inqbuf, bytes); - if (bytes == 36 && bytes < inqbuf->additional_length + 4) { - bytes = inqbuf->additional_length + 4; + if (bytes == SID_SCSI2_HDRLEN + SID_SCSI2_ALEN && bytes < + SID_SCSI2_HDRLEN + inqbuf->additional_length) { + bytes = SID_SCSI2_HDRLEN + inqbuf->additional_length; if (bytes > sizeof(*inqbuf)) bytes = sizeof(*inqbuf); goto again; |