svn commit: r275604 - stable/9/sys/cam

Alexander Motin mav at FreeBSD.org
Mon Dec 8 09:48:47 UTC 2014


Author: mav
Date: Mon Dec  8 09:48:46 2014
New Revision: 275604
URL: https://svnweb.freebsd.org/changeset/base/275604

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/9/sys/cam/cam_xpt.c
Directory Properties:
  stable/9/   (props changed)
  stable/9/sys/   (props changed)

Modified: stable/9/sys/cam/cam_xpt.c
==============================================================================
--- stable/9/sys/cam/cam_xpt.c	Mon Dec  8 09:47:49 2014	(r275603)
+++ stable/9/sys/cam/cam_xpt.c	Mon Dec  8 09:48:46 2014	(r275604)
@@ -1158,8 +1158,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);


More information about the svn-src-stable-9 mailing list