diff options
author | Sage Weil <sage@newdream.net> | 2011-01-13 23:27:29 (GMT) |
---|---|---|
committer | Sage Weil <sage@newdream.net> | 2011-01-13 23:50:11 (GMT) |
commit | 17db143fc091238c43ab9f373974ca2224a4c3f8 (patch) | |
tree | d72df7c0d88e6e9176292a560e9e9fcac12848aa /fs/ceph/xattr.c | |
parent | 1c1266bb916e6a6b362d3be95f2cc7f3c41277a6 (diff) | |
download | linux-17db143fc091238c43ab9f373974ca2224a4c3f8.tar.xz |
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: Sergiy Kibrik <sakib@meta.ua>
Signed-off-by: Sage Weil <sage@newdream.net>
Diffstat (limited to 'fs/ceph/xattr.c')
-rw-r--r-- | fs/ceph/xattr.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/fs/ceph/xattr.c b/fs/ceph/xattr.c index 6e12a6b..8c9eba6 100644 --- a/fs/ceph/xattr.c +++ b/fs/ceph/xattr.c @@ -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) |