15155 WPTS BVT_SMB2Basic_Query_FileNormalizedNameInformation
Reviewed by: Garrett D'Amore <garrett@damore.org>
Reviewed by: Andy Stormont <andyjstormont@gmail.com>
Reviewed by: Matt Barden <mbarden@racktopsystems.com>
Approved by: Dan McDonald <danmcd@mnx.io>
diff --git a/usr/src/uts/common/fs/smbsrv/smb2_qinfo_file.c b/usr/src/uts/common/fs/smbsrv/smb2_qinfo_file.c
index 1683904..dcfd771 100644
--- a/usr/src/uts/common/fs/smbsrv/smb2_qinfo_file.c
+++ b/usr/src/uts/common/fs/smbsrv/smb2_qinfo_file.c
@@ -32,6 +32,7 @@
 static uint32_t smb2_qif_ea_size(smb_request_t *, smb_queryinfo_t *);
 static uint32_t smb2_qif_access(smb_request_t *, smb_queryinfo_t *);
 static uint32_t smb2_qif_name(smb_request_t *, smb_queryinfo_t *);
+static uint32_t smb2_qif_normalized_name(smb_request_t *, smb_queryinfo_t *);
 static uint32_t smb2_qif_position(smb_request_t *, smb_queryinfo_t *);
 static uint32_t smb2_qif_full_ea(smb_request_t *, smb_queryinfo_t *);
 static uint32_t smb2_qif_mode(smb_request_t *, smb_queryinfo_t *);
@@ -81,6 +82,7 @@
 		break;
 
 	case FileNameInformation:
+	case FileNormalizedNameInformation:
 		getname = B_TRUE;
 		break;
 
@@ -147,6 +149,9 @@
 	case FileNameInformation:
 		status = smb2_qif_name(sr, qi);
 		break;
+	case FileNormalizedNameInformation:
+		status = smb2_qif_normalized_name(sr, qi);
+		break;
 	case FilePositionInformation:
 		status = smb2_qif_position(sr, qi);
 		break;
@@ -401,15 +406,51 @@
 static uint32_t
 smb2_qif_name(smb_request_t *sr, smb_queryinfo_t *qi)
 {
+	char *name;
+	uint32_t nlen;
 	int rc;
 
-	ASSERT(qi->qi_namelen > 0);
+	/* SMB2 leaves off the leading / */
+	nlen = qi->qi_namelen;
+	name = qi->qi_name;
+	if (qi->qi_name[0] == '\\') {
+		name++;
+		nlen -= 2;
+	}
 
 	rc = smb_mbc_encodef(
 	    &sr->raw_data, "llU",
 	    0, /* FileIndex	 (l) */
-	    qi->qi_namelen,	/* l */
-	    qi->qi_name);	/* U */
+	    nlen,	/* l */
+	    name);	/* U */
+	if (rc != 0)
+		return (NT_STATUS_BUFFER_OVERFLOW);
+
+	return (0);
+}
+
+/*
+ * FileNormalizedNameInformation
+ */
+static uint32_t
+smb2_qif_normalized_name(smb_request_t *sr, smb_queryinfo_t *qi)
+{
+	char *name;
+	uint32_t nlen;
+	int rc;
+
+	/* SMB2 leaves off the leading / */
+	nlen = qi->qi_namelen;
+	name = qi->qi_name;
+	if (qi->qi_name[0] == '\\') {
+		name++;
+		nlen -= 2;
+	}
+
+	rc = smb_mbc_encodef(
+	    &sr->raw_data, "lU",
+	    nlen,	/* l */
+	    name);	/* U */
 	if (rc != 0)
 		return (NT_STATUS_BUFFER_OVERFLOW);