From 34ddb1cb1423ff0e2bbe5f3045e6547f5401c492 Mon Sep 17 00:00:00 2001 From: Angus Salkeld Date: Sun, 22 Nov 2009 23:19:41 +0000 Subject: [PATCH] COVERITY 12: prevent overrun of logsys output buffers. git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2547 fd59a12c-fef9-0310-b244-a6a79926bd2f --- exec/logsys.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/exec/logsys.c b/exec/logsys.c index 978c1574..1471bcdf 100644 --- a/exec/logsys.c +++ b/exec/logsys.c @@ -527,8 +527,12 @@ static void log_printf_to_logs ( syslog_output_buffer_idx += syslog_len; format_buffer_idx += 1; } - if ((normal_output_buffer_idx == sizeof (normal_output_buffer)) || - (syslog_output_buffer_idx == sizeof (syslog_output_buffer))) { + if ((normal_output_buffer_idx >= sizeof (normal_output_buffer) - 2) || + (syslog_output_buffer_idx >= sizeof (syslog_output_buffer) - 1)) { + /* Note: we make allowance for '\0' at the end of + * both of these arrays and normal_output_buffer also + * needs a '\n'. + */ break; } }