Btrfs-progs: set string end sing '\0' for property
Set string "xattr_name" 's end with '\0' so that it won't be violated in memory. With this fix, xfstest/btrfs/048 can pass on my box. Signed-off-by: Liu Bo <bo.li.liu@oracle.com> Reviewed-by: Filipe Manana <fdmanana@gmail.com> Signed-off-by: David Sterba <dsterba@suse.cz>
This commit is contained in:
parent
9317400a67
commit
21a1ff8887
1 changed files with 2 additions and 1 deletions
3
props.c
3
props.c
|
@ -129,13 +129,14 @@ static int prop_compression(enum prop_object_type type,
|
|||
goto out;
|
||||
}
|
||||
|
||||
xattr_name = malloc(XATTR_BTRFS_PREFIX_LEN + strlen(name));
|
||||
xattr_name = malloc(XATTR_BTRFS_PREFIX_LEN + strlen(name) + 1);
|
||||
if (!xattr_name) {
|
||||
ret = -ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
memcpy(xattr_name, XATTR_BTRFS_PREFIX, XATTR_BTRFS_PREFIX_LEN);
|
||||
memcpy(xattr_name + XATTR_BTRFS_PREFIX_LEN, name, strlen(name));
|
||||
xattr_name[XATTR_BTRFS_PREFIX_LEN + strlen(name)] = '\0';
|
||||
|
||||
if (value)
|
||||
sret = fsetxattr(fd, xattr_name, value, strlen(value), 0);
|
||||
|
|
Loading…
Reference in a new issue