* [Cluster-devel] [PATCH 0/2] rgmanager: spots in flattening-related parts
@ 2012-04-02 9:59 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 10:08 ` [Cluster-devel] [PATCH 2/2] resrules: print_resource_rule doc comment conformance Jan Pokorný
0 siblings, 2 replies; 7+ messages in thread
From: Jan Pokorný @ 2012-04-02 9:59 UTC (permalink / raw)
To: cluster-devel.redhat.com
Just two spots I discovered while running through the code for flattening
resource trees in cluster.conf. One cosmetic, one little more subtle.
Jan Pokorn? (2):
resrules: fix free while passing the pointer to caller
resrules: print_resource_rule doc comment conformance
resrules.c | 9 +++------
1 files changed, 3 insertions(+), 6 deletions(-)
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Cluster-devel] [PATCH 1/2] resrules: fix free while passing the pointer to caller
2012-04-02 9:59 [Cluster-devel] [PATCH 0/2] rgmanager: spots in flattening-related parts Jan Pokorný
@ 2012-04-02 10:06 ` Jan Pokorný
2012-04-02 11:29 ` [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ý
1 sibling, 1 reply; 7+ messages in thread
From: Jan Pokorný @ 2012-04-02 10:06 UTC (permalink / raw)
To: cluster-devel.redhat.com
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
(print_resource_rule and especially destroy_resource_rule which could
lead to crash easily, IMHO).
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 or 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;
}
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [Cluster-devel] [PATCH 2/2] resrules: print_resource_rule doc comment conformance
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 10:08 ` 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ý
1 sibling, 2 replies; 7+ messages in thread
From: Jan Pokorný @ 2012-04-02 10:08 UTC (permalink / raw)
To: cluster-devel.redhat.com
Signed-off-by: Jan Pokorn? <jpokorny@redhat.com>
---
resrules.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/resrules.c b/resrules.c
index 581be9e..4fcc4f1 100644
--- a/resrules.c
+++ b/resrules.c
@@ -556,7 +556,7 @@ store_childtype(resource_child_t **childp, char *name, int start,
/**
- Print a resource_t structure to stdout
+ Print a resource_t structure to specified stream
@param rr Resource rule to print.
*/
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [Cluster-devel] [PATCH 2b/2] resrules: print_resource_rule doc comment conformance
2012-04-02 10:08 ` [Cluster-devel] [PATCH 2/2] resrules: print_resource_rule doc comment conformance Jan Pokorný
@ 2012-04-02 10:24 ` Jan Pokorný
2012-04-02 11:37 ` [Cluster-devel] [PATCH 2c/2] " Jan Pokorný
1 sibling, 0 replies; 7+ messages in thread
From: Jan Pokorný @ 2012-04-02 10:24 UTC (permalink / raw)
To: cluster-devel.redhat.com
(when changing doc. comment, do it properly)
Signed-off-by: Jan Pokorn? <jpokorny@redhat.com>
---
resrules.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/resrules.c b/resrules.c
index 581be9e..353ead4 100644
--- a/resrules.c
+++ b/resrules.c
@@ -556,9 +556,10 @@ store_childtype(resource_child_t **childp, char *name, int start,
/**
- Print a resource_t structure to stdout
+ Print a resource_t structure to specified stream
@param rr Resource rule to print.
+ @param fp Destination stream.
*/
void
print_resource_rule(FILE *fp, resource_rule_t *rr)
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [Cluster-devel] [PATCH 1b/2] resrules: fix free while passing the pointer to caller
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ý
2012-04-02 15:46 ` Jan Pokorný
0 siblings, 1 reply; 7+ messages in thread
From: Jan Pokorný @ 2012-04-02 11:29 UTC (permalink / raw)
To: cluster-devel.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;
}
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [Cluster-devel] [PATCH 2c/2] resrules: print_resource_rule doc comment conformance
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 ` Jan Pokorný
1 sibling, 0 replies; 7+ messages in thread
From: Jan Pokorný @ 2012-04-02 11:37 UTC (permalink / raw)
To: cluster-devel.redhat.com
(when changing doc. comment, do it properly)
(due to previously misconfigured MUA, sorry for inconvenience)
Signed-off-by: Jan Pokorn? <jpokorny@redhat.com>
---
resrules.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/resrules.c b/resrules.c
index 581be9e..353ead4 100644
--- a/resrules.c
+++ b/resrules.c
@@ -556,9 +556,10 @@ store_childtype(resource_child_t **childp, char *name, int start,
/**
- Print a resource_t structure to stdout
+ Print a resource_t structure to specified stream
@param rr Resource rule to print.
+ @param fp Destination stream.
*/
void
print_resource_rule(FILE *fp, resource_rule_t *rr)
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [Cluster-devel] [PATCH 1b/2] resrules: fix free while passing the pointer to caller
2012-04-02 11:29 ` [Cluster-devel] [PATCH 1b/2] " Jan Pokorný
@ 2012-04-02 15:46 ` Jan Pokorný
0 siblings, 0 replies; 7+ messages in thread
From: Jan Pokorný @ 2012-04-02 15:46 UTC (permalink / raw)
To: cluster-devel.redhat.com
On 02/04/12 13:29 +0200, Jan Pokorn? wrote:
> What's worse, the caller could then access uninitialized memory
> through this pointer (e.g., print_resource_rule).
As Ryan noted, this is not true, as the pointer was always set to
NULL. So the patch only eliminates hidden NOOP.
-- Jan
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2012-04-02 15:46 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [Cluster-devel] [PATCH 1b/2] " Jan Pokorný
2012-04-02 15:46 ` 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ý
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).