From 84fd8ea4bda2a2ee73dfb4c8843b67f958eaa872 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Wed, 8 Feb 2012 11:31:29 +0000 Subject: [PATCH] Move done jump lower Since before 'goto done' is bufused zeroed, it would otherwise write 1 byte in front of buffer. --- WHATS_NEW | 2 ++ lib/log/log.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/WHATS_NEW b/WHATS_NEW index fce9abf53..7bff56768 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,7 @@ Version 2.02.91 - =================================== + Do not write in front of log buffer in print_log(). + Add boundary test for number of mirror devs and logs. Check that whole locking_dir fits _lock_dir buffer in init_file_locking(). Use list functions for label_exit(). Ensure strncpy() function always ends with '\0'. diff --git a/lib/log/log.c b/lib/log/log.c index fa20b1ea6..66ef76c56 100644 --- a/lib/log/log.c +++ b/lib/log/log.c @@ -388,8 +388,8 @@ void print_log(int level, const char *file, int line, int dm_errno, va_end(ap); bufused += n; - done: buf[bufused - 1] = '\n'; + done: buf[bufused] = '\n'; buf[sizeof(buf) - 1] = '\n'; /* FIXME real size bufused */