summaryrefslogtreecommitdiffstats
path: root/sys/cam/cam_xpt.c
diff options
context:
space:
mode:
authormav <mav@FreeBSD.org>2014-12-08 09:47:49 +0000
committermav <mav@FreeBSD.org>2014-12-08 09:47:49 +0000
commit16ad04df256e79f57632a0b181805e24a560dc79 (patch)
treea684a07e2a8deca0962ecd48518b89aa0d465b63 /sys/cam/cam_xpt.c
parent26dad09e504647f7c89715ad31cf37b57a372e97 (diff)
downloadFreeBSD-src-16ad04df256e79f57632a0b181805e24a560dc79.zip
FreeBSD-src-16ad04df256e79f57632a0b181805e24a560dc79.tar.gz
MFC r275368:
When passing LUN IDs through treat ASCII values as fixed-length, not interpreating NULLs as EOLs, but converting them to spaces. SPC-4 does not tell that T10-based IDs should be NULL-terminated/padded. And while it tells that it should include only ASCII chars (0x20-0x7F), there are some USB sticks (SanDisk Ultra Fit), that have NULLs inside the value. Treating NULLs as EOLs there made those LUN IDs non-unique.
Diffstat (limited to 'sys/cam/cam_xpt.c')
-rw-r--r--sys/cam/cam_xpt.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/sys/cam/cam_xpt.c b/sys/cam/cam_xpt.c
index d423b95..6a7218f 100644
--- a/sys/cam/cam_xpt.c
+++ b/sys/cam/cam_xpt.c
@@ -1140,8 +1140,15 @@ xpt_getattr(char *buf, size_t len, const char *attr, struct cam_path *path)
if (idd == NULL)
goto out;
ret = 0;
- if ((idd->proto_codeset & SVPD_ID_CODESET_MASK) == SVPD_ID_CODESET_ASCII ||
- (idd->proto_codeset & SVPD_ID_CODESET_MASK) == SVPD_ID_CODESET_UTF8) {
+ if ((idd->proto_codeset & SVPD_ID_CODESET_MASK) == SVPD_ID_CODESET_ASCII) {
+ if (idd->length < len) {
+ for (l = 0; l < idd->length; l++)
+ buf[l] = idd->identifier[l] ?
+ idd->identifier[l] : ' ';
+ buf[l] = 0;
+ } else
+ ret = EFAULT;
+ } else if ((idd->proto_codeset & SVPD_ID_CODESET_MASK) == SVPD_ID_CODESET_UTF8) {
l = strnlen(idd->identifier, idd->length);
if (l < len) {
bcopy(idd->identifier, buf, l);
OpenPOWER on IntegriCloud