Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b65917dd authored by Sage Weil's avatar Sage Weil
Browse files

ceph: fix listxattr handling for vxattrs



Only include vxattrs in the result if they are not hidden and exist
(as determined by the exists_cb callback).

Note that the buffer size we return when 0 is passed in always includes
vxattrs that *might* exist, forming an upper bound.

Signed-off-by: default avatarSage Weil <sage@inktank.com>
Reviewed-by: default avatarSam Lang <sam.lang@inktank.com>
parent 0bee82fb
Loading
Loading
Loading
Loading
+13 −6
Original line number Diff line number Diff line
@@ -657,22 +657,29 @@ list_xattr:
	vir_namelen = ceph_vxattrs_name_size(vxattrs);

	/* adding 1 byte per each variable due to the null termination */
	namelen = vir_namelen + ci->i_xattrs.names_size + ci->i_xattrs.count;
	namelen = ci->i_xattrs.names_size + ci->i_xattrs.count;
	err = -ERANGE;
	if (size && namelen > size)
	if (size && vir_namelen + namelen > size)
		goto out;

	err = namelen;
	err = namelen + vir_namelen;
	if (size == 0)
		goto out;

	names = __copy_xattr_names(ci, names);

	/* virtual xattr names, too */
	if (vxattrs)
	err = namelen;
	if (vxattrs) {
		for (i = 0; vxattrs[i].name; i++) {
			if (!vxattrs[i].hidden &&
			    !(vxattrs[i].exists_cb &&
			      !vxattrs[i].exists_cb(ci))) {
				len = sprintf(names, "%s", vxattrs[i].name);
				names += len + 1;
				err += len + 1;
			}
		}
	}

out: