Commit 17db143f authored by Sage Weil's avatar Sage Weil

ceph: fix xattr rbtree search

Fix xattr name comparison in rbtree search for strings that share a prefix.
The *name argument is null terminated, but the xattr name is not, so we
need to use strncmp, but that means adjusting for the case where name is
a prefix of xattr->name.

The corresponding case in __set_xattr() already handles this properly
(although in that case *name is also not null terminated).
Reported-by: default avatarSergiy Kibrik <sakib@meta.ua>
Signed-off-by: default avatarSage Weil <sage@newdream.net>
parent 1c1266bb
......@@ -219,6 +219,7 @@ static struct ceph_inode_xattr *__get_xattr(struct ceph_inode_info *ci,
struct rb_node **p;
struct rb_node *parent = NULL;
struct ceph_inode_xattr *xattr = NULL;
int name_len = strlen(name);
int c;
p = &ci->i_xattrs.index.rb_node;
......@@ -226,6 +227,8 @@ static struct ceph_inode_xattr *__get_xattr(struct ceph_inode_info *ci,
parent = *p;
xattr = rb_entry(parent, struct ceph_inode_xattr, node);
c = strncmp(name, xattr->name, xattr->name_len);
if (c == 0 && name_len > xattr->name_len)
c = 1;
if (c < 0)
p = &(*p)->rb_left;
else if (c > 0)
......
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