Handle extended attributes that contain NULL bytes correctly, rather
than treating everything as zero-terminated C strings.
Signed-off-by: Colin McCabe <colin.mccabe@dreamhost.com>
c_char_p(xattr_name), ret_buf, c_size_t(ret_length))
if ret < 0:
raise make_ex(ret, "Failed to get xattr %r" % xattr_name)
- return ret_buf.value
+ return ctypes.string_at(ret_buf, ret)
def get_xattrs(self, oid):
self.require_ioctx_open()
if (found["c"] != "3"):
raise RuntimeError("error: expected object abc to have c=3")
+foo3_ioctx.set_xattr("def", "zeroholder", "a\0b")
+ret = foo3_ioctx.get_xattr("def", "zeroholder")
+if (ret != "a\0b"):
+ raise RuntimeError("error: set_xattr/get_xattr failed with " +
+ "an extended attribute containing NULL")
+
# create some snapshots and do stuff with them
print "creating snap bjork"
foo3_ioctx.create_snap("bjork")