diff options
Diffstat (limited to 'sys/scsi/safte.c')
-rw-r--r-- | sys/scsi/safte.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/sys/scsi/safte.c b/sys/scsi/safte.c index ce874794f35..f6385878573 100644 --- a/sys/scsi/safte.c +++ b/sys/scsi/safte.c @@ -1,4 +1,4 @@ -/* $OpenBSD: safte.c,v 1.34 2007/03/22 16:55:31 deraadt Exp $ */ +/* $OpenBSD: safte.c,v 1.35 2007/04/03 04:15:50 dlg Exp $ */ /* * Copyright (c) 2005 David Gwynne <dlg@openbsd.org> @@ -112,7 +112,7 @@ safte_match(struct device *parent, void *match, void *aux) struct scsi_inquiry_data inqbuf; struct scsi_inquiry cmd; struct safte_inq *si = (struct safte_inq *)&inqbuf.extra; - int flags; + int length, flags; if (inq == NULL) return (0); @@ -127,14 +127,15 @@ safte_match(struct device *parent, void *match, void *aux) (inq->response_format & SID_ANSII) != 2) return (0); - memset(&cmd, 0, sizeof(cmd)); - cmd.opcode = INQUIRY; - cmd.length = inq->additional_length + SAFTE_EXTRA_OFFSET; - if (cmd.length < SAFTE_INQ_LEN) + length = inq->additional_length + SAFTE_EXTRA_OFFSET; + if (length < SAFTE_INQ_LEN) return (0); + if (length > sizeof(inqbuf)) + length = sizeof(inqbuf); - if (cmd.length > sizeof(inqbuf)) - cmd.length = sizeof(inqbuf); + memset(&cmd, 0, sizeof(cmd)); + cmd.opcode = INQUIRY; + _lto2b(length, cmd.length); memset(&inqbuf, 0, sizeof(inqbuf)); memset(&inqbuf.extra, ' ', sizeof(inqbuf.extra)); @@ -144,7 +145,7 @@ safte_match(struct device *parent, void *match, void *aux) flags |= SCSI_AUTOCONF; if (scsi_scsi_cmd(sa->sa_sc_link, (struct scsi_generic *)&cmd, - sizeof(cmd), (u_char *)&inqbuf, cmd.length, 2, 10000, NULL, + sizeof(cmd), (u_char *)&inqbuf, length, 2, 10000, NULL, flags) != 0) return (0); |