From: Donghwa Jeong Date: Thu, 21 Jun 2018 01:58:31 +0000 (+0900) Subject: btrfs: fix wrong buffer size to append string X-Git-Tag: lxc-3.1.0~235^2~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2df5f6bfe991a89c8c5d97f91b21218592ecd257;p=thirdparty%2Flxc.git btrfs: fix wrong buffer size to append string Signed-off-by: Donghwa Jeong --- diff --git a/src/lxc/storage/btrfs.c b/src/lxc/storage/btrfs.c index c83ddf4e8..0726b07c0 100644 --- a/src/lxc/storage/btrfs.c +++ b/src/lxc/storage/btrfs.c @@ -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; }