[sheepdog] [PATCH 5/7] logger: check the return value of vsnprintf
MORITA Kazutaka
morita.kazutaka at gmail.com
Tue Aug 13 12:09:29 CEST 2013
From: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
lib/logger.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/lib/logger.c b/lib/logger.c
index 3d05995..8b59265 100644
--- a/lib/logger.c
+++ b/lib/logger.c
@@ -343,7 +343,11 @@ static void dolog(int prio, const char *func, int line,
gettimeofday(&tv, NULL);
len = vsnprintf(str, MAX_MSG_SIZE, fmt, ap);
- msg->str_len = len;
+ if (len < 0) {
+ syslog(LOG_ERR, "vsnprintf failed");
+ return;
+ }
+ msg->str_len = min(len, MAX_MSG_SIZE - 1);
if (la) {
struct sembuf ops;
--
1.7.9.5
More information about the sheepdog
mailing list