From e7535ad313d08ec587311729f049397d3ed995ce Mon Sep 17 00:00:00 2001 From: Pranith Kumar K Date: Wed, 15 Sep 2010 08:35:42 +0000 Subject: mgmt/glusterd: gf_strdup the rsp msg and free xdr memory Signed-off-by: Pranith Kumar K Signed-off-by: Vijay Bellur BUG: 1613 (glusterd crash in create volume failure) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1613 --- xlators/mgmt/glusterd/src/glusterd3_1-mops.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/xlators/mgmt/glusterd/src/glusterd3_1-mops.c b/xlators/mgmt/glusterd/src/glusterd3_1-mops.c index 9435099906c..6adec5dfe62 100644 --- a/xlators/mgmt/glusterd/src/glusterd3_1-mops.c +++ b/xlators/mgmt/glusterd/src/glusterd3_1-mops.c @@ -530,7 +530,12 @@ glusterd3_1_stage_op_cbk (struct rpc_req *req, struct iovec *iov, if (op_ret) { event_type = GD_OP_EVENT_RCVD_RJT; opinfo.op_ret = op_ret; - opinfo.op_errstr = rsp.op_errstr; + opinfo.op_errstr = gf_strdup(rsp.op_errstr); + if (!opinfo.op_errstr) { + gf_log ("", GF_LOG_ERROR, "memory allocation failed"); + ret = -1; + goto out; + } } else { event_type = GD_OP_EVENT_RCVD_ACC; } @@ -543,6 +548,8 @@ glusterd3_1_stage_op_cbk (struct rpc_req *req, struct iovec *iov, } out: + if (rsp.op_errstr && strcmp (rsp.op_errstr, "")) + free (rsp.op_errstr); //malloced by xdr return ret; } @@ -650,7 +657,12 @@ glusterd3_1_commit_op_cbk (struct rpc_req *req, struct iovec *iov, if (op_ret) { event_type = GD_OP_EVENT_RCVD_RJT; opinfo.op_ret = op_ret; - opinfo.op_errstr = rsp.op_errstr; + opinfo.op_errstr = gf_strdup(rsp.op_errstr); + if (!opinfo.op_errstr) { + gf_log ("", GF_LOG_ERROR, "memory allocation failed"); + ret = -1; + goto out; + } } else { if (rsp.op == GD_OP_REPLACE_BRICK) { ret = glusterd_rb_use_rsp_dict (dict); @@ -673,6 +685,8 @@ glusterd3_1_commit_op_cbk (struct rpc_req *req, struct iovec *iov, out: if (dict) dict_unref (dict); + if (rsp.op_errstr && strcmp (rsp.op_errstr, "")) + free (rsp.op_errstr); //malloced by xdr return ret; } -- cgit