[sheepdog] [PATCH 1/2] sheep: fix strlen in log_enqueue

Yunkai Zhang yunkai.me at gmail.com
Sat Jun 16 21:00:27 CEST 2012


From: Yunkai Zhang <qiushu.zyk at taobao.com>


Signed-off-by: Yunkai Zhang <qiushu.zyk at taobao.com>
---
 lib/logger.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/logger.c b/lib/logger.c
index 04ba933..c91bf3a 100644
--- a/lib/logger.c
+++ b/lib/logger.c
@@ -201,11 +201,11 @@ static notrace int log_enqueue(int prio, const char *func, int line, const char
 		p += strlen(p);
 	}
 
-	snprintf(p, MAX_MSG_SIZE, "%s(%d) ", func, line);
+	snprintf(p, MAX_MSG_SIZE - strlen(buff), "%s(%d) ", func, line);
 
 	p += strlen(p);
 
-	vsnprintf(p, MAX_MSG_SIZE - strlen(p), fmt, ap);
+	vsnprintf(p, MAX_MSG_SIZE - strlen(buff), fmt, ap);
 
 	len = strlen(buff) * sizeof(char) + 1;
 
-- 
1.7.10.2




More information about the sheepdog mailing list