summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRalph Boehme <slow@samba.org>2015-08-24 17:45:14 +0200
committerKarolin Seeger <kseeger@samba.org>2016-01-06 10:07:18 +0100
commit76213b06292e865d36c04f8e98e45105cf71e838 (patch)
tree96a480f07d38c0b05c6c92a37503d802e7be9961
parent73dac61aeb87d7a18b7465abf76c053d2138efe9 (diff)
downloadsamba-76213b06292e865d36c04f8e98e45105cf71e838.tar.gz
vfs_streams_xattr: fix and simplify streams_xattr_get_name()
streams_xattr_get_name() fails to chop off the stream type in case config->store_stream_type is false and the passed stream name contains a stream type. Eg when the passed in stream name is ":mystream:$DATA", but config->store_stream_type is false, we must generate a xattr name of "mystream" or "user.mystream". Bug: https://bugzilla.samba.org/show_bug.cgi?id=11466 Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Fri Oct 16 23:27:01 CEST 2015 on sn-devel-104 (cherry picked from commit 2881679e3ecbaf07cdd82ba65af8d55e5e3be800)
-rw-r--r--source3/modules/vfs_streams_xattr.c39
1 files changed, 19 insertions, 20 deletions
diff --git a/source3/modules/vfs_streams_xattr.c b/source3/modules/vfs_streams_xattr.c
index 5277741deb7..7ef42799819 100644
--- a/source3/modules/vfs_streams_xattr.c
+++ b/source3/modules/vfs_streams_xattr.c
@@ -106,12 +106,18 @@ static NTSTATUS streams_xattr_get_name(vfs_handle_struct *handle,
const char *stream_name,
char **xattr_name)
{
+ char *sname;
char *stype;
struct streams_xattr_config *config;
SMB_VFS_HANDLE_GET_DATA(handle, config, struct streams_xattr_config,
return NT_STATUS_UNSUCCESSFUL);
+ sname = talloc_strdup(ctx, stream_name + 1);
+ if (sname == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
/*
* With vfs_fruit option "fruit:encoding = native" we're
* already converting stream names that contain illegal NTFS
@@ -126,41 +132,34 @@ static NTSTATUS streams_xattr_get_name(vfs_handle_struct *handle,
* In check_path_syntax() we've already ensured the streamname
* we got from the client is valid.
*/
- stype = strrchr_m(stream_name + 1, ':');
+ stype = strrchr_m(sname, ':');
if (stype) {
+ /*
+ * We only support one stream type: "$DATA"
+ */
if (strcasecmp_m(stype, ":$DATA") != 0) {
+ talloc_free(sname);
return NT_STATUS_INVALID_PARAMETER;
}
+
+ /* Split name and type */
+ stype[0] = '\0';
}
- *xattr_name = talloc_asprintf(ctx, "%s%s",
+ *xattr_name = talloc_asprintf(ctx, "%s%s%s",
config->prefix,
- stream_name + 1);
+ sname,
+ config->store_stream_type ? ":$DATA" : "");
if (*xattr_name == NULL) {
+ talloc_free(sname);
return NT_STATUS_NO_MEMORY;
}
- if (stype != NULL) {
- /* Normalize the stream type to upercase. */
- if (!strupper_m(strrchr_m(*xattr_name, ':') + 1)) {
- return NT_STATUS_INVALID_PARAMETER;
- }
- } else if (config->store_stream_type) {
- /*
- * Append an explicit stream type if one wasn't
- * specified.
- */
- *xattr_name = talloc_asprintf(ctx, "%s%s",
- *xattr_name, ":$DATA");
- if (*xattr_name == NULL) {
- return NT_STATUS_NO_MEMORY;
- }
- }
-
DEBUG(10, ("xattr_name: %s, stream_name: %s\n", *xattr_name,
stream_name));
+ talloc_free(sname);
return NT_STATUS_OK;
}