]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
btrfs: fix wrong buffer size to append string
authorDonghwa Jeong <dh48.jeong@samsung.com>
Thu, 21 Jun 2018 01:58:31 +0000 (10:58 +0900)
committerDonghwa Jeong <dh48.jeong@samsung.com>
Fri, 22 Jun 2018 05:11:38 +0000 (14:11 +0900)
Signed-off-by: Donghwa Jeong <dh48.jeong@samsung.com>
src/lxc/storage/btrfs.c

index c83ddf4e8194ebb303cc5c582f962b3a38011fd7..0726b07c084c4ffc96705a608db51af93984bb21 100644 (file)
@@ -92,9 +92,10 @@ char *get_btrfs_subvol_path(int fd, u64 dir_id, u64 objid, char *name,
                retpath = malloc(len);
                if (!retpath)
                        return NULL;
+
                (void)strlcpy(retpath, args.name, len);
-               (void)strlcat(retpath, "/", 1);
-               (void)strlcat(retpath, name, name_len);
+               (void)strlcat(retpath, "/", len);
+               (void)strlcat(retpath, name, len);
        } else {
                /* we're at the root of ref_tree */
                len = name_len + 1;
@@ -102,7 +103,7 @@ char *get_btrfs_subvol_path(int fd, u64 dir_id, u64 objid, char *name,
                if (!retpath)
                        return NULL;
                *retpath = '\0';
-               (void)strlcat(retpath, name, name_len);
+               (void)strlcat(retpath, name, len);
        }
        return retpath;
 }