cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: Jan Pokorný <jpokorny@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH 1b/2] resrules: fix free while passing the pointer to caller
Date: Mon, 2 Apr 2012 13:29:52 +0200	[thread overview]
Message-ID: <20120402112952.GA21558@redhat.com> (raw)
In-Reply-To: <20120402100618.GA19756@redhat.com>

(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@redhat.com>
---
 resrules.c |    7 ++-----
 1 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/resrules.c b/resrules.c
index cc59e30..581be9e 100644
--- a/resrules.c
+++ b/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;
 }
 
 



  reply	other threads:[~2012-04-02 11:29 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-02  9:59 [Cluster-devel] [PATCH 0/2] rgmanager: spots in flattening-related parts Jan Pokorný
2012-04-02 10:06 ` [Cluster-devel] [PATCH 1/2] resrules: fix free while passing the pointer to caller Jan Pokorný
2012-04-02 11:29   ` Jan Pokorný [this message]
2012-04-02 15:46     ` [Cluster-devel] [PATCH 1b/2] " Jan Pokorný
2012-04-02 10:08 ` [Cluster-devel] [PATCH 2/2] resrules: print_resource_rule doc comment conformance Jan Pokorný
2012-04-02 10:24   ` [Cluster-devel] [PATCH 2b/2] " Jan Pokorný
2012-04-02 11:37   ` [Cluster-devel] [PATCH 2c/2] " Jan Pokorný

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120402112952.GA21558@redhat.com \
    --to=jpokorny@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).