summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/dht/src/dht-helper.c
diff options
context:
space:
mode:
authorRaghavendra G <rgowdapp@redhat.com>2016-05-06 12:26:29 +0530
committerRaghavendra G <rgowdapp@redhat.com>2016-08-25 05:18:09 -0700
commitc68b561f048a02f479819b1c9cb3b5b896db18a6 (patch)
tree08ebde402edbeab8af553d786ff70f112ba8e0ef /xlators/cluster/dht/src/dht-helper.c
parentafabb66f36b75db4d5aee46e694990b63f454133 (diff)
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 Change-Id: If8a267bab3d91003bdef3a92664077a0136745ee BUG: 1332073 Signed-off-by: Raghavendra G <rgowdapp@redhat.com> Reviewed-on: http://review.gluster.org/14102 Tested-by: Manikandan Selvaganesh <mselvaga@redhat.com> Smoke: Gluster Build System <jenkins@build.gluster.org> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Manikandan Selvaganesh <mselvaga@redhat.com>
Diffstat (limited to 'xlators/cluster/dht/src/dht-helper.c')
-rw-r--r--xlators/cluster/dht/src/dht-helper.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/xlators/cluster/dht/src/dht-helper.c b/xlators/cluster/dht/src/dht-helper.c
index 590d0043507..255c0823aac 100644
--- a/xlators/cluster/dht/src/dht-helper.c
+++ b/xlators/cluster/dht/src/dht-helper.c
@@ -353,17 +353,29 @@ out:
static xlator_t *
dht_get_subvol_from_id(xlator_t *this, int client_id)
{
- xlator_t *xl = NULL;
+ xlator_t *xl = NULL;
dht_conf_t *conf = NULL;
- char sid[6] = { 0 };
+ char *sid = NULL;
+ int32_t ret = -1;
conf = this->private;
- sprintf(sid, "%d", client_id);
+ ret = gf_asprintf(&sid, "%d", client_id);
+ if (ret == -1) {
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ DHT_MSG_ASPRINTF_FAILED, "asprintf failed while "
+ "fetching subvol from the id");
+ goto out;
+ }
+
if (dict_get_ptr(conf->leaf_to_subvol, sid, (void **) &xl))
xl = NULL;
+ GF_FREE (sid);
+
+out:
return xl;
+
}
int