Btrfs-progs: we need to have the string null terminated

Bug:
-------------
btrfs subvolume list / -a
ID 258 gen 4226 top level 384 path media/smbshare
::
btrfs subvolume list /home -a
ID 258 gen 4226 top level 5 path <FS_TREE>/__active/media/smbshare4.snap

In the first command's output, this path is printed correctly, however
in the second output it has "4.snap" appended, similar to the names of
the snapshots I made 22 hours ago.
------------

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reported-by: Brendan Hide <brendan@swiftspirit.co.za>
This commit is contained in:
Anand Jain 2013-01-24 18:05:14 +08:00 committed by David Sterba
parent af7c373fdf
commit bbb9e4b419

View File

@ -633,6 +633,7 @@ static int resolve_root(struct root_lookup *rl, struct root_info *ri,
len = strlen(full_path);
tmp = malloc(len + add_len + 2);
memcpy(tmp + add_len + 1, full_path, len);
tmp[len + add_len + 1] = '\0';
tmp[add_len] = '/';
memcpy(tmp, p, add_len);
free(full_path);