summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormav <mav@FreeBSD.org>2017-01-05 11:34:30 +0000
committermav <mav@FreeBSD.org>2017-01-05 11:34:30 +0000
commit0c2d11b23972e5b1e61036417ccec7397ed24f1b (patch)
treee1b1da30b787d915388820eaa11a7f1619b6c96c
parent79680b01685243554c3d48137c8b6daaead225e3 (diff)
downloadFreeBSD-src-0c2d11b23972e5b1e61036417ccec7397ed24f1b.zip
FreeBSD-src-0c2d11b23972e5b1e61036417ccec7397ed24f1b.tar.gz
MFC r310284:
When writing fixed format sense data, set VALID bit only if provided value for INFORMATION field fit into available 4 bytes (has no non-zero bytes except last 4), as explicitly required by SPC-5 specification.
-rw-r--r--sys/cam/scsi/scsi_all.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/sys/cam/scsi/scsi_all.c b/sys/cam/scsi/scsi_all.c
index d822463..9642e7c 100644
--- a/sys/cam/scsi/scsi_all.c
+++ b/sys/cam/scsi/scsi_all.c
@@ -4020,11 +4020,17 @@ scsi_set_sense_data_va(struct scsi_sense_data *sense_data,
data_dest = &sense->info[0];
len_to_copy = MIN(sense_len,
sizeof(sense->info));
- /*
- * We're setting the info field, so
- * set the valid bit.
- */
- sense->error_code |= SSD_ERRCODE_VALID;
+
+ /* Set VALID bit only if no overflow. */
+ for (i = 0; i < sense_len - len_to_copy;
+ i++) {
+ if (data[i] != 0)
+ break;
+ }
+ if (i >= sense_len - len_to_copy) {
+ sense->error_code |=
+ SSD_ERRCODE_VALID;
+ }
}
/*
OpenPOWER on IntegriCloud