From 108475decfde8fd30818c37604ef8db837220624 Mon Sep 17 00:00:00 2001 From: Vijay Bellur Date: Sun, 7 Apr 2013 21:39:18 +0530 Subject: cli: Address a double free with volume info. Crash is observed when volume info is performed on a non-exisiting volume name and the output format is xml. Change-Id: I88aa5d9dc954b1352f5cc3b5b38742c832bc1bb8 BUG: 949298 Signed-off-by: Vijay Bellur Reviewed-on: http://review.gluster.org/4785 Reviewed-by: Kaushal M Tested-by: Gluster Build System Reviewed-by: Anand Avati --- cli/src/cli-xml-output.c | 4 ++-- tests/bugs/bug-949298.t | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 tests/bugs/bug-949298.t diff --git a/cli/src/cli-xml-output.c b/cli/src/cli-xml-output.c index 543ea713d..72e1264f7 100644 --- a/cli/src/cli-xml-output.c +++ b/cli/src/cli-xml-output.c @@ -2495,12 +2495,12 @@ cli_xml_output_vol_info (cli_local_t *local, dict_t *dict) ret = xmlTextWriterEndElement (local->writer); XML_RET_CHECK_AND_GOTO (ret, out); } - GF_FREE (local->get_vol.volname); + if (volname) { + GF_FREE (local->get_vol.volname); local->get_vol.volname = gf_strdup (volname); local->vol_count += count; } - out: gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret); return ret; diff --git a/tests/bugs/bug-949298.t b/tests/bugs/bug-949298.t new file mode 100644 index 000000000..1394127ec --- /dev/null +++ b/tests/bugs/bug-949298.t @@ -0,0 +1,12 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc +. $(dirname $0)/../volume.rc + +cleanup; +TEST glusterd +TEST pidof glusterd + +TEST $CLI --xml volume info $V0 + +cleanup; -- cgit