From 60f12dfbc87818831a65ac80ad8ba2fe166a29e2 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Thu, 21 Aug 2014 22:22:37 -0700 Subject: client: client3_3_readdir() - initialize ``local`` properly A crash is observed in the following scenario on OSX ~~~ (gdb) p readdir_rsp_size $1 = 1552 GLUSTERFS_RPC_REPLY_SIZE == 24 GLUSTERFS_RDMA_MAX_HEADER_SIZE == 228 ((1552 + 24 + 228)) == 1804 GLUSTERFS_RDMA_INLINE_THRESHOLD == 2048 if ((readdir_rsp_size + GLUSTERFS_RPC_REPLY_SIZE + GLUSTERFS_RDMA_MAX_HEADER_SIZE) > GLUSTERFS_RDMA_INLINE_THRESHOLD) ----> False ~~~ ``local`` is never initialized leads to NULL reference later. This patch makes sure that local is initialized, correctly as its done in client3_3_readdirp() call. Change-Id: I46931fc96900b7740ae71536c954bb9deda5c879 BUG: 1132796 Signed-off-by: Harshavardhana Reviewed-on: http://review.gluster.org/8511 Reviewed-by: Niels de Vos Tested-by: Gluster Build System Reviewed-by: Raghavendra G Tested-by: Raghavendra G --- xlators/protocol/client/src/client-rpc-fops.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'xlators') diff --git a/xlators/protocol/client/src/client-rpc-fops.c b/xlators/protocol/client/src/client-rpc-fops.c index 50ade5dc442..3bfa03fa2ed 100644 --- a/xlators/protocol/client/src/client-rpc-fops.c +++ b/xlators/protocol/client/src/client-rpc-fops.c @@ -5661,15 +5661,15 @@ client3_3_readdir (call_frame_t *frame, xlator_t *this, readdir_rsp_size = xdr_sizeof ((xdrproc_t) xdr_gfs3_readdir_rsp, &rsp) + args->size; + local = mem_get0 (this->local_pool); + if (!local) { + op_errno = ENOMEM; + goto unwind; + } + frame->local = local; + if ((readdir_rsp_size + GLUSTERFS_RPC_REPLY_SIZE + GLUSTERFS_RDMA_MAX_HEADER_SIZE) > (GLUSTERFS_RDMA_INLINE_THRESHOLD)) { - local = mem_get0 (this->local_pool); - if (!local) { - op_errno = ENOMEM; - goto unwind; - } - frame->local = local; - rsp_iobref = iobref_new (); if (rsp_iobref == NULL) { goto unwind; -- cgit