diff options
author | Amar Tumballi <amar@gluster.com> | 2010-09-02 01:22:15 +0000 |
---|---|---|
committer | Vijay Bellur <vijay@dev.gluster.com> | 2010-09-02 03:12:28 -0700 |
commit | e94814533da94fb936355cde924ef3a6f6c11f46 (patch) | |
tree | a663d6e70977fb9f6654037403747b2ab9804d1d | |
parent | 4c5e364c36baa92374eb0eac60dafb8da3786286 (diff) |
crash fixed in 'gluster volume log locate'
Signed-off-by: Amar Tumballi <amar@gluster.com>
Signed-off-by: Vijay Bellur <vijay@dev.gluster.com>
BUG: 1506 (crash in log locate..)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1506
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-handler.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c index fd90161f8..1c0d1ee6f 100644 --- a/xlators/mgmt/glusterd/src/glusterd-handler.c +++ b/xlators/mgmt/glusterd/src/glusterd-handler.c @@ -1743,12 +1743,15 @@ glusterd_handle_log_locate (rpcsvc_request_t *req) gf1_cli_log_locate_req cli_req = {0,}; gf1_cli_log_locate_rsp rsp = {0,}; dict_t *dict = NULL; + glusterd_conf_t *priv = NULL; glusterd_volinfo_t *volinfo = NULL; glusterd_brickinfo_t *brickinfo = NULL; - char *tmp_str = NULL; + char tmp_str[PATH_MAX] = {0,}; GF_ASSERT (req); + priv = THIS->private; + if (!gf_xdr_to_cli_log_locate_req (req->msg[0], &cli_req)) { //failed to decode msg; req->rpc_err = GARBAGE_ARGS; @@ -1775,8 +1778,13 @@ glusterd_handle_log_locate (rpcsvc_request_t *req) } list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) { - tmp_str = gf_strdup (brickinfo->logfile); - rsp.path = dirname (tmp_str); + if (brickinfo->logfile) { + strcpy (tmp_str, brickinfo->logfile); + rsp.path = dirname (tmp_str); + } else { + snprintf (tmp_str, PATH_MAX, "%s/logs/", priv->workdir); + rsp.path = tmp_str; + } break; } @@ -1789,9 +1797,6 @@ out: ret = glusterd_submit_reply (req, &rsp, NULL, 0, NULL, gf_xdr_serialize_cli_log_locate_rsp); - if (tmp_str) - GF_FREE (tmp_str); - return ret; } |