summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGordon Ross <gwr@racktopsystems.com>2022-01-15 15:48:14 -0500
committerToomas Soome <tsoome@me.com>2022-11-16 18:18:09 +0200
commit3cfbf5be38df79575cc7d2705bb059b2feca1332 (patch)
tree1f8be1723a9307fcd939c4c62ab0a9221dde00fc
parentbf4554a2fffed30a37fb5ff4467267a2eaeea07f (diff)
downloadillumos-gate-3cfbf5be38df79575cc7d2705bb059b2feca1332.tar.gz
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>
-rw-r--r--usr/src/uts/common/fs/smbsrv/smb2_qinfo_file.c47
1 files changed, 44 insertions, 3 deletions
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 1683904e33..dcfd771baa 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_internal(smb_request_t *, smb_queryinfo_t *);
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 @@ smb2_qinfo_file(smb_request_t *sr, smb_queryinfo_t *qi)
break;
case FileNameInformation:
+ case FileNormalizedNameInformation:
getname = B_TRUE;
break;
@@ -147,6 +149,9 @@ smb2_qinfo_file(smb_request_t *sr, smb_queryinfo_t *qi)
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 @@ smb2_qif_access(smb_request_t *sr, smb_queryinfo_t *qi)
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);