Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 8 Dec 2014 09:47:50 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r275603 - stable/10/sys/cam
Message-ID:  <201412080947.sB89loHl003240@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Mon Dec  8 09:47:49 2014
New Revision: 275603
URL: https://svnweb.freebsd.org/changeset/base/275603

Log:
  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.

Modified:
  stable/10/sys/cam/cam_xpt.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/cam/cam_xpt.c
==============================================================================
--- stable/10/sys/cam/cam_xpt.c	Mon Dec  8 09:09:50 2014	(r275602)
+++ stable/10/sys/cam/cam_xpt.c	Mon Dec  8 09:47:49 2014	(r275603)
@@ -1140,8 +1140,15 @@ xpt_getattr(char *buf, size_t len, const
 		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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201412080947.sB89loHl003240>