Commit d9a15489 authored by Andreas Gruenbacher's avatar Andreas Gruenbacher Committed by Al Viro

cifs: Fix xattr name checks

Use strcmp(str, name) instead of strncmp(str, name, strlen(name)) for
checking if str and name are the same (as opposed to name being a prefix
of str) in the gexattr and setxattr inode operations.
Signed-off-by: default avatarAndreas Gruenbacher <agruenba@redhat.com>
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent ce23e640
...@@ -129,7 +129,7 @@ int cifs_setxattr(struct dentry *direntry, const char *ea_name, ...@@ -129,7 +129,7 @@ int cifs_setxattr(struct dentry *direntry, const char *ea_name,
== 0) { == 0) {
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR) if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
goto set_ea_exit; goto set_ea_exit;
if (strncmp(ea_name, CIFS_XATTR_DOS_ATTRIB, 14) == 0) if (strcmp(ea_name, CIFS_XATTR_DOS_ATTRIB) == 0)
cifs_dbg(FYI, "attempt to set cifs inode metadata\n"); cifs_dbg(FYI, "attempt to set cifs inode metadata\n");
ea_name += XATTR_USER_PREFIX_LEN; /* skip past user. prefix */ ea_name += XATTR_USER_PREFIX_LEN; /* skip past user. prefix */
...@@ -147,8 +147,7 @@ int cifs_setxattr(struct dentry *direntry, const char *ea_name, ...@@ -147,8 +147,7 @@ int cifs_setxattr(struct dentry *direntry, const char *ea_name,
rc = pTcon->ses->server->ops->set_EA(xid, pTcon, rc = pTcon->ses->server->ops->set_EA(xid, pTcon,
full_path, ea_name, ea_value, (__u16)value_size, full_path, ea_name, ea_value, (__u16)value_size,
cifs_sb->local_nls, cifs_remap(cifs_sb)); cifs_sb->local_nls, cifs_remap(cifs_sb));
} else if (strncmp(ea_name, CIFS_XATTR_CIFS_ACL, } else if (strcmp(ea_name, CIFS_XATTR_CIFS_ACL) == 0) {
strlen(CIFS_XATTR_CIFS_ACL)) == 0) {
#ifdef CONFIG_CIFS_ACL #ifdef CONFIG_CIFS_ACL
struct cifs_ntsd *pacl; struct cifs_ntsd *pacl;
pacl = kmalloc(value_size, GFP_KERNEL); pacl = kmalloc(value_size, GFP_KERNEL);
...@@ -170,10 +169,7 @@ int cifs_setxattr(struct dentry *direntry, const char *ea_name, ...@@ -170,10 +169,7 @@ int cifs_setxattr(struct dentry *direntry, const char *ea_name,
cifs_dbg(FYI, "Set CIFS ACL not supported yet\n"); cifs_dbg(FYI, "Set CIFS ACL not supported yet\n");
#endif /* CONFIG_CIFS_ACL */ #endif /* CONFIG_CIFS_ACL */
} else { } else {
int temp; if (strcmp(ea_name, XATTR_NAME_POSIX_ACL_ACCESS) == 0) {
temp = strncmp(ea_name, XATTR_NAME_POSIX_ACL_ACCESS,
strlen(XATTR_NAME_POSIX_ACL_ACCESS));
if (temp == 0) {
#ifdef CONFIG_CIFS_POSIX #ifdef CONFIG_CIFS_POSIX
if (sb->s_flags & MS_POSIXACL) if (sb->s_flags & MS_POSIXACL)
rc = CIFSSMBSetPosixACL(xid, pTcon, full_path, rc = CIFSSMBSetPosixACL(xid, pTcon, full_path,
...@@ -184,8 +180,7 @@ int cifs_setxattr(struct dentry *direntry, const char *ea_name, ...@@ -184,8 +180,7 @@ int cifs_setxattr(struct dentry *direntry, const char *ea_name,
#else #else
cifs_dbg(FYI, "set POSIX ACL not supported\n"); cifs_dbg(FYI, "set POSIX ACL not supported\n");
#endif #endif
} else if (strncmp(ea_name, XATTR_NAME_POSIX_ACL_DEFAULT, } else if (strcmp(ea_name, XATTR_NAME_POSIX_ACL_DEFAULT) == 0) {
strlen(XATTR_NAME_POSIX_ACL_DEFAULT)) == 0) {
#ifdef CONFIG_CIFS_POSIX #ifdef CONFIG_CIFS_POSIX
if (sb->s_flags & MS_POSIXACL) if (sb->s_flags & MS_POSIXACL)
rc = CIFSSMBSetPosixACL(xid, pTcon, full_path, rc = CIFSSMBSetPosixACL(xid, pTcon, full_path,
...@@ -246,7 +241,7 @@ ssize_t cifs_getxattr(struct dentry *direntry, struct inode *inode, ...@@ -246,7 +241,7 @@ ssize_t cifs_getxattr(struct dentry *direntry, struct inode *inode,
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR) if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
goto get_ea_exit; goto get_ea_exit;
if (strncmp(ea_name, CIFS_XATTR_DOS_ATTRIB, 14) == 0) { if (strcmp(ea_name, CIFS_XATTR_DOS_ATTRIB) == 0) {
cifs_dbg(FYI, "attempt to query cifs inode metadata\n"); cifs_dbg(FYI, "attempt to query cifs inode metadata\n");
/* revalidate/getattr then populate from inode */ /* revalidate/getattr then populate from inode */
} /* BB add else when above is implemented */ } /* BB add else when above is implemented */
...@@ -264,8 +259,7 @@ ssize_t cifs_getxattr(struct dentry *direntry, struct inode *inode, ...@@ -264,8 +259,7 @@ ssize_t cifs_getxattr(struct dentry *direntry, struct inode *inode,
rc = pTcon->ses->server->ops->query_all_EAs(xid, pTcon, rc = pTcon->ses->server->ops->query_all_EAs(xid, pTcon,
full_path, ea_name, ea_value, buf_size, full_path, ea_name, ea_value, buf_size,
cifs_sb->local_nls, cifs_remap(cifs_sb)); cifs_sb->local_nls, cifs_remap(cifs_sb));
} else if (strncmp(ea_name, XATTR_NAME_POSIX_ACL_ACCESS, } else if (strcmp(ea_name, XATTR_NAME_POSIX_ACL_ACCESS) == 0) {
strlen(XATTR_NAME_POSIX_ACL_ACCESS)) == 0) {
#ifdef CONFIG_CIFS_POSIX #ifdef CONFIG_CIFS_POSIX
if (sb->s_flags & MS_POSIXACL) if (sb->s_flags & MS_POSIXACL)
rc = CIFSSMBGetPosixACL(xid, pTcon, full_path, rc = CIFSSMBGetPosixACL(xid, pTcon, full_path,
...@@ -275,8 +269,7 @@ ssize_t cifs_getxattr(struct dentry *direntry, struct inode *inode, ...@@ -275,8 +269,7 @@ ssize_t cifs_getxattr(struct dentry *direntry, struct inode *inode,
#else #else
cifs_dbg(FYI, "Query POSIX ACL not supported yet\n"); cifs_dbg(FYI, "Query POSIX ACL not supported yet\n");
#endif /* CONFIG_CIFS_POSIX */ #endif /* CONFIG_CIFS_POSIX */
} else if (strncmp(ea_name, XATTR_NAME_POSIX_ACL_DEFAULT, } else if (strcmp(ea_name, XATTR_NAME_POSIX_ACL_DEFAULT) == 0) {
strlen(XATTR_NAME_POSIX_ACL_DEFAULT)) == 0) {
#ifdef CONFIG_CIFS_POSIX #ifdef CONFIG_CIFS_POSIX
if (sb->s_flags & MS_POSIXACL) if (sb->s_flags & MS_POSIXACL)
rc = CIFSSMBGetPosixACL(xid, pTcon, full_path, rc = CIFSSMBGetPosixACL(xid, pTcon, full_path,
...@@ -286,8 +279,7 @@ ssize_t cifs_getxattr(struct dentry *direntry, struct inode *inode, ...@@ -286,8 +279,7 @@ ssize_t cifs_getxattr(struct dentry *direntry, struct inode *inode,
#else #else
cifs_dbg(FYI, "Query POSIX default ACL not supported yet\n"); cifs_dbg(FYI, "Query POSIX default ACL not supported yet\n");
#endif /* CONFIG_CIFS_POSIX */ #endif /* CONFIG_CIFS_POSIX */
} else if (strncmp(ea_name, CIFS_XATTR_CIFS_ACL, } else if (strcmp(ea_name, CIFS_XATTR_CIFS_ACL) == 0) {
strlen(CIFS_XATTR_CIFS_ACL)) == 0) {
#ifdef CONFIG_CIFS_ACL #ifdef CONFIG_CIFS_ACL
u32 acllen; u32 acllen;
struct cifs_ntsd *pacl; struct cifs_ntsd *pacl;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment