diff options
author | Ralph Boehme <slow@samba.org> | 2015-08-24 17:45:14 +0200 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2015-10-16 23:27:01 +0200 |
commit | 2881679e3ecbaf07cdd82ba65af8d55e5e3be800 (patch) | |
tree | 2ea544c044f7453dc20f5c60a14d8c704b4941d0 /source3/modules/vfs_streams_xattr.c | |
parent | fedd09662c889fb796135d86836c160171fac68d (diff) | |
download | samba-2881679e3ecbaf07cdd82ba65af8d55e5e3be800.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
Diffstat (limited to 'source3/modules/vfs_streams_xattr.c')
-rw-r--r-- | source3/modules/vfs_streams_xattr.c | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/source3/modules/vfs_streams_xattr.c b/source3/modules/vfs_streams_xattr.c index 92bd1c9bce7..b54809f134e 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; } |