cluster: STABLE32 - resrules: fix free while passing the pointer to caller

Ryan McCabe rmccabe at fedoraproject.org
Tue May 1 19:10:31 UTC 2012


Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=215dd94070707fdb421197bfe625fb9d531ecbec
Commit:        215dd94070707fdb421197bfe625fb9d531ecbec
Parent:        1e6034e5d698192f48b2317065b10d61410ac824
Author:        Jan Pokorný <jpokorny at redhat.com>
AuthorDate:    Mon Apr 2 13:29:52 2012 +0200
Committer:     Ryan McCabe <rmccabe at redhat.com>
CommitterDate: Tue May 1 15:10:05 2012 -0400

resrules: fix free while passing the pointer to caller

(due to previously misconfigured MUA, sorry for inconvenience)

The version ("OCF API Version" as declared in the code) for resource
rules cannot be obtained correctly as the memory is being immediately
freed before passing up to the caller.  What's worse, the caller
could then access uninitialized memory through this pointer
(e.g., print_resource_rule).

The patch fixes this, making no difference between success
and failure in getting the version.  Both should be handled
correctly when either dumping resource rule or destroying it.

Aside: was this version field ever actively used of is this a legacy
       part not expected to be triggered?
[ I have no test case at hand, this was random spot, sorry. ]

Signed-off-by: Jan Pokorný <jpokorny at redhat.com>
Signed-off-by: Ryan McCabe <rmccabe at redhat.com>
---
 rgmanager/src/daemons/resrules.c |    7 ++-----
 1 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/rgmanager/src/daemons/resrules.c b/rgmanager/src/daemons/resrules.c
index cc59e30..581be9e 100644
--- a/rgmanager/src/daemons/resrules.c
+++ b/rgmanager/src/daemons/resrules.c
@@ -205,11 +205,8 @@ _get_version(xmlDocPtr doc, xmlXPathContextPtr ctx, char *base,
 
 	snprintf(xpath, sizeof(xpath), "%s/@version", base);
 	ret = xpath_get_one(doc, ctx, xpath);
-	if (ret) {
-		rr->rr_version = ret;
-		free(ret);
-	}
-	rr->rr_version = NULL;
+	/* NULL or actual result of the query */
+	rr->rr_version = ret;
 }
 
 


More information about the cluster-commits mailing list