cluster: STABLE32 - rgmanager: reslist: another string related cleanup

Ryan McCabe rmccabe at fedoraproject.org
Tue May 1 19:20:58 UTC 2012


Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=a14f3920a9a8c3be930a8b8958414768a0698240
Commit:        a14f3920a9a8c3be930a8b8958414768a0698240
Parent:        5b7c605ceb1b2d6686f63fe3f10e56d5ce4bd439
Author:        Jan Pokorný <jpokorny at redhat.com>
AuthorDate:    Fri Apr 6 21:38:03 2012 +0200
Committer:     Ryan McCabe <rmccabe at redhat.com>
CommitterDate: Tue May 1 15:20:48 2012 -0400

rgmanager: reslist: another string related cleanup

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

diff --git a/rgmanager/src/daemons/reslist.c b/rgmanager/src/daemons/reslist.c
index b75f4b0..43430cd 100644
--- a/rgmanager/src/daemons/reslist.c
+++ b/rgmanager/src/daemons/reslist.c
@@ -107,9 +107,12 @@ _attr_value(resource_node_t *node, const char *attrname, const char *ptype)
 		/* Difference guaranteed to be non-negative
 		   (for x >= 0: &ra->ra_value[x] >= &ra->ra_value[0]) */
 		len = (c - ra->ra_value);
-		memset(p_type, 0, sizeof(p_type));
+		if (len >= sizeof(p_type))
+			len = sizeof(p_type) - 1;
+
 		memcpy(p_type, ra->ra_value, len);
-		
+		p_type[sizeof(p_type)-1] = '\0';
+
 		/* Skip the "%" and recurse */
 		return _attr_value(node->rn_parent, ++c, p_type);
 	}


More information about the cluster-commits mailing list