[PATCH 4/7] log: Print truncated messages

Ian Jackson ijackson at chiark.greenend.org.uk
Thu Jun 14 01:38:34 BST 2012

If a message doesn't survive the vsnprintf in vMessage untruncated,
the result may be that its newline is lost.  After that, buff will
never manage to gain a newline and all further messages will be

Fix this by always putting "\n\0" at the end of buff.  That way a
truncated message is printed and the buffer will be cleared out for
the next call.

Signed-off-by: Ian Jackson <ijackson at chiark.greenend.org.uk>
 log.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/log.c b/log.c
index 4f1b651..9cd0572 100644
--- a/log.c
+++ b/log.c
@@ -38,6 +38,8 @@ static void vMessage(uint32_t class, const char *message, va_list args)
 	assert(bp < MESSAGE_BUFLEN);
+	buff[sizeof(buff)-2] = '\n';
+	buff[sizeof(buff)-1] = '\0';
 	/* Each line is sent separately */
 	while ((nlp=strchr(buff,'\n'))) {

More information about the sgo-software-discuss mailing list