From 2902b6f325d4bbb6cd947cee0301bf75d9634196 Mon Sep 17 00:00:00 2001 From: Venky Shankar Date: Wed, 17 Aug 2011 15:19:05 +0530 Subject: allocate extra bytes (for \0) when calling realloc We use strcat to concat pathinfo strings. strcat appends a \0 at the end. Therefore allocate extra bytes for the same to avoid asserts being hit during gf_free call Change-Id: I582f5858e7375a5bacfc5c702c612ee09c3bb355 BUG: 3413 Reviewed-on: http://review.gluster.com/249 Tested-by: Gluster Build System Reviewed-by: Amar Tumballi --- xlators/cluster/dht/src/dht-common.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c index 3ccb89eccdd..db3b881b692 100644 --- a/xlators/cluster/dht/src/dht-common.c +++ b/xlators/cluster/dht/src/dht-common.c @@ -1720,7 +1720,8 @@ dht_pathinfo_getxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, if (local->pathinfo) { plen = strlen (local->pathinfo); if (plen) { - alloc_len += plen; + /* extra byte(s) for \0 to be safe */ + alloc_len += (plen + 2); local->pathinfo = GF_REALLOC (local->pathinfo, alloc_len); if (!local->pathinfo) -- cgit