From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Pokorný Date: Fri, 6 Apr 2012 21:38:03 +0200 Subject: [Cluster-devel] [PATCH] rgmanager: reslist: another string related cleanup In-Reply-To: <20120406174420.GA660@redhat.com> Message-ID: <20120406193803.GA3610@redhat.com> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Signed-off-by: Jan Pokorn? --- reslist.c | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-) diff --git a/reslist.c b/reslist.c index b75f4b0..43430cd 100644 --- a/reslist.c +++ b/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); }