From 6b406ac42f55233df474fa304dbb9e6fc447bd8f Mon Sep 17 00:00:00 2001 From: Raghavendra G Date: Fri, 6 May 2016 12:26:29 +0530 Subject: quotad: fix potential buffer overflows This converts sprintf to gf_asprintf in following components: * quotad.c * dht * afr * protocol/client * rpc/rpc-lib * rpc/rpc-transport This is a backport of http://review.gluster.org/#/c/14102/ > Change-Id: If8a267bab3d91003bdef3a92664077a0136745ee > BUG: 1332073 > Signed-off-by: Raghavendra G > Reviewed-on: http://review.gluster.org/14102 > Tested-by: Manikandan Selvaganesh > Smoke: Gluster Build System > NetBSD-regression: NetBSD Build System > CentOS-regression: Gluster Build System > Reviewed-by: Manikandan Selvaganesh Change-Id: If8a267bab3d91003bdef3a92664077a0136745ee BUG: 1366746 Signed-off-by: Raghavendra G Reviewed-on: http://review.gluster.org/15325 Smoke: Gluster Build System Tested-by: Manikandan Selvaganesh CentOS-regression: Gluster Build System NetBSD-regression: NetBSD Build System --- libglusterfs/src/graph.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'libglusterfs/src/graph.c') diff --git a/libglusterfs/src/graph.c b/libglusterfs/src/graph.c index 2e290bb20a1..04bb92c7c75 100644 --- a/libglusterfs/src/graph.c +++ b/libglusterfs/src/graph.c @@ -598,16 +598,19 @@ _glusterfs_reachable_leaves(xlator_t *base, xlator_t *xl, dict_t *leaves) xlator_list_t *list = NULL; int err = 1; int pos = 0; - char strpos[6]; + char *strpos = NULL; if (glusterfs_is_leaf(xl)) { pos = glusterfs_leaf_position(xl); if (pos < 0) goto out; - sprintf(strpos, "%d", pos); - err = dict_set_static_ptr(leaves, strpos, base); + err = gf_asprintf(&strpos, "%d", pos); + if (err >= 0) { + err = dict_set_static_ptr(leaves, strpos, base); + GF_FREE (strpos); + } } else { for (err = 0, list = xl->children; !err && list; -- cgit