From 023969d911b90420bd1733bae57d04e24dee5eda Mon Sep 17 00:00:00 2001 From: Venky Shankar Date: Tue, 16 Aug 2011 11:32:35 +0530 Subject: adjust allocated length to memory overrun fix size of the allocated length is incorrectly calculated which could cause memory overrun while filling the buffer Change-Id: I4fbdbd1fff937ca15bae9f634ef5757dda52caa8 BUG: 3413 Reviewed-on: http://review.gluster.com/236 Tested-by: Gluster Build System Reviewed-by: Anand Avati --- xlators/cluster/dht/src/dht-common.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'xlators/cluster/dht/src/dht-common.c') diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c index 9b8807f63d7..3ccb89eccdd 100644 --- a/xlators/cluster/dht/src/dht-common.c +++ b/xlators/cluster/dht/src/dht-common.c @@ -1712,9 +1712,10 @@ dht_pathinfo_getxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, * allocate the buffer:- we allocate 10 bytes extra in case we need to * append ' Link: ' in the buffer for another STACK_WIND */ - if (!local->pathinfo) - local->pathinfo = GF_CALLOC (alloc_len + strlen (DHT_PATHINFO_HEADER) + 10, - sizeof (char), gf_common_mt_char); + if (!local->pathinfo) { + alloc_len += (strlen (DHT_PATHINFO_HEADER) + 10); + local->pathinfo = GF_CALLOC (alloc_len, sizeof (char), gf_common_mt_char); + } if (local->pathinfo) { plen = strlen (local->pathinfo); -- cgit