summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVenky Shankar <venky@gluster.com>2011-08-16 11:32:35 +0530
committerAnand Avati <avati@gluster.com>2011-08-15 23:18:39 -0700
commit023969d911b90420bd1733bae57d04e24dee5eda (patch)
treefb27928e88a4dd5a18ec70c858cc37e62ab420a4
parenta0071bdf2a0f73fd17ac769298ed65b245f0607c (diff)
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 <jenkins@build.gluster.com> Reviewed-by: Anand Avati <avati@gluster.com>
-rw-r--r--xlators/cluster/dht/src/dht-common.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c
index 9b8807f63..3ccb89ecc 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);