btrfs: fix wrong buffer size to append string

parent 64e82f8b
...@@ -92,9 +92,10 @@ char *get_btrfs_subvol_path(int fd, u64 dir_id, u64 objid, char *name, ...@@ -92,9 +92,10 @@ char *get_btrfs_subvol_path(int fd, u64 dir_id, u64 objid, char *name,
retpath = malloc(len); retpath = malloc(len);
if (!retpath) if (!retpath)
return NULL; return NULL;
(void)strlcpy(retpath, args.name, len); (void)strlcpy(retpath, args.name, len);
(void)strlcat(retpath, "/", 1); (void)strlcat(retpath, "/", len);
(void)strlcat(retpath, name, name_len); (void)strlcat(retpath, name, len);
} else { } else {
/* we're at the root of ref_tree */ /* we're at the root of ref_tree */
len = name_len + 1; len = name_len + 1;
...@@ -102,7 +103,7 @@ char *get_btrfs_subvol_path(int fd, u64 dir_id, u64 objid, char *name, ...@@ -102,7 +103,7 @@ char *get_btrfs_subvol_path(int fd, u64 dir_id, u64 objid, char *name,
if (!retpath) if (!retpath)
return NULL; return NULL;
*retpath = '\0'; *retpath = '\0';
(void)strlcat(retpath, name, name_len); (void)strlcat(retpath, name, len);
} }
return retpath; return retpath;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment