summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMuthu-vigneshwaran <mvignesh@redhat.com>2016-12-01 15:59:26 +0530
committerAtin Mukherjee <amukherj@redhat.com>2016-12-06 04:26:09 -0800
commitb214b643d60cfb30c6578a570963ffc8f79073d8 (patch)
tree7d9b6f69d6cdcb95b4ed4f10859970aba0252cf1
parentca13525a5de8db745878c4cdf89a45b76a9e62c6 (diff)
glusterd : coverity fix for string overflow
CID : 1357872, 1357873, 1351695 BUG: 789278 Change-Id: I2ee01a6054326f35de621ee7a1f2afd09c5738fe Signed-off-by: Muthu-vigneshwaran <mvignesh@redhat.com> Reviewed-on: http://review.gluster.org/15989 Tested-by: Muthu Vigneshwaran Smoke: Gluster Build System <jenkins@build.gluster.org> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> Reviewed-by: Manikandan Selvaganesh <manikandancs333@gmail.com> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c6
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volume-ops.c2
2 files changed, 5 insertions, 3 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index e93bb39b3e8..fedfb746c50 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -735,7 +735,8 @@ glusterd_create_sub_tier_volinfo (glusterd_volinfo_t *volinfo,
memcpy (&(*dup_volinfo)->tier_info, &volinfo->tier_info,
sizeof (volinfo->tier_info));
- strcpy ((*dup_volinfo)->volname, new_volname);
+ strncpy ((*dup_volinfo)->volname, new_volname,
+ sizeof((*dup_volinfo)->volname)-1);
cds_list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) {
i++;
@@ -3463,7 +3464,8 @@ glusterd_import_volinfo (dict_t *peer_data, int count,
ret = glusterd_volinfo_new (&new_volinfo);
if (ret)
goto out;
- strncpy (new_volinfo->volname, volname, strlen (volname));
+ strncpy (new_volinfo->volname, volname,
+ sizeof(new_volinfo->volname) - 1);
memset (key, 0, sizeof (key));
snprintf (key, sizeof (key), "%s%d.type", prefix, count);
diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
index 90a165d498e..43bca49b808 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
@@ -2196,7 +2196,7 @@ glusterd_op_create_volume (dict_t *dict, char **op_errstr)
goto out;
}
- strncpy (volinfo->volname, volname, strlen (volname));
+ strncpy (volinfo->volname, volname, sizeof(volinfo->volname) - 1);
GF_ASSERT (volinfo->volname);
ret = dict_get_int32 (dict, "type", &volinfo->type);