Signed-off-by: Jan Pokorný <jpoko...@redhat.com>
---
 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);
        }

Reply via email to