cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
* [Cluster-devel] [PATCH] dlm_controld: fix name printing error in logging
@ 2014-04-25  7:21 Lidong Zhong
  2014-04-25 11:25 ` Steven Whitehouse
  2014-04-25 15:59 ` David Teigland
  0 siblings, 2 replies; 3+ messages in thread
From: Lidong Zhong @ 2014-04-25  7:21 UTC (permalink / raw)
  To: cluster-devel.redhat.com

When the length of name_in is NAME_ID_SIZE, the last byte of the name
and a whitespace will get lost.

Signed-off-by: Lidong Zhong <lzhong@suse.com>
---
 dlm_controld/logging.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/dlm_controld/logging.c b/dlm_controld/logging.c
index 9347e43..ea879e8 100644
--- a/dlm_controld/logging.c
+++ b/dlm_controld/logging.c
@@ -122,7 +122,7 @@ static void log_save_str(int len, char *log_buf, unsigned int *point,
 void log_level(char *name_in, uint32_t level_in, const char *fmt, ...)
 {
 	va_list ap;
-	char name[NAME_ID_SIZE + 1];
+	char name[NAME_ID_SIZE + 2];
 	uint32_t level = level_in & 0x0000FFFF;
 	uint32_t extra = level_in & 0xFFFF0000;
 	int ret, pos = 0;
@@ -132,7 +132,7 @@ void log_level(char *name_in, uint32_t level_in, const char *fmt, ...)
 	memset(name, 0, sizeof(name));
 
 	if (name_in)
-		snprintf(name, NAME_ID_SIZE, "%s ", name_in);
+		snprintf(name, NAME_ID_SIZE + 2, "%s ", name_in);
 
 	ret = snprintf(log_str + pos, len - pos, "%llu %s",
 		       (unsigned long long)monotime(), name);
-- 
1.8.1.4



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-04-25 15:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-25  7:21 [Cluster-devel] [PATCH] dlm_controld: fix name printing error in logging Lidong Zhong
2014-04-25 11:25 ` Steven Whitehouse
2014-04-25 15:59 ` David Teigland

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).