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] rgmanager: reslist: another string related cleanup
Date: Fri, 6 Apr 2012 21:38:03 +0200	[thread overview]
Message-ID: <20120406193803.GA3610@redhat.com> (raw)
In-Reply-To: <20120406174420.GA660@redhat.com>

Signed-off-by: Jan Pokorn? <jpokorny@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);
 	}



      parent reply	other threads:[~2012-04-06 19:38 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-06 16:28 [Cluster-devel] [PATCH] rgmanager: various cleanups regarding string functions jpokorny
2012-04-06 17:44 ` [Cluster-devel] [PATCH] rgmanager: reslist: nothing avoids using size_t Jan Pokorný
2012-04-06 17:53   ` [Cluster-devel] [PATCH] rgmanager: reslist: sanitize act_dup Jan Pokorný
2012-04-06 19:38   ` Jan Pokorný [this message]

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=20120406193803.GA3610@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).