From fe5fc91ab9b74b525d4979e09ce13766b3180381 Mon Sep 17 00:00:00 2001 From: Sanju Rakonde Date: Fri, 22 Sep 2017 18:17:03 +0530 Subject: glusterd/snapshot: Buffer Size Warning new_brickinfo->mnt_opts is allocated memory using calloc. So it is already zeroed out at allocation. we need not to add null character at the end. we pass one less than maximum size to the strncpy to make sure that destination string is terminated. Change-Id: I463dddd2171fb39a509bb75ffcc074d5b1cf7d62 BUG: 789278 Signed-off-by: Sanju Rakonde --- xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'xlators') diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c b/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c index 9e2a75f110f..38fea9dbaa4 100644 --- a/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c @@ -264,7 +264,7 @@ glusterd_snap_volinfo_restore (dict_t *dict, dict_t *rsp_dict, ret = dict_get_str (dict, key, &value); if (!ret) strncpy (new_brickinfo->mnt_opts, value, - sizeof(new_brickinfo->mnt_opts)); + sizeof(new_brickinfo->mnt_opts) - 1); /* If the brick is not of this peer, or snapshot is missed * * for the brick do not replace the xattr for it */ -- cgit