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>

Sage Weil 17db143f 1c1266bb

+3
+3
fs/ceph/xattr.c
··· 219 219 struct rb_node **p; 220 220 struct rb_node *parent = NULL; 221 221 struct ceph_inode_xattr *xattr = NULL; 222 + int name_len = strlen(name); 222 223 int c; 223 224 224 225 p = &ci->i_xattrs.index.rb_node; ··· 227 226 parent = *p; 228 227 xattr = rb_entry(parent, struct ceph_inode_xattr, node); 229 228 c = strncmp(name, xattr->name, xattr->name_len); 229 + if (c == 0 && name_len > xattr->name_len) 230 + c = 1; 230 231 if (c < 0) 231 232 p = &(*p)->rb_left; 232 233 else if (c > 0)