[Openais] [PATCH 1/8] COVERITY 12: prevent overrun of output buffers.

Angus Salkeld angus.salkeld at gmail.com
Sat Oct 24 15:56:43 PDT 2009


Overrun of static array "normal_output_buffer" of size 2048
at position 2048 with index variable "normal_output_buffer_idx"

536  		normal_output_buffer[normal_output_buffer_idx] = '\0';
537  		syslog_output_buffer[syslog_output_buffer_idx] = '\0';
538

Signed-off-by: Angus Salkeld <angus.salkeld at gmail.com>
---
  exec/logsys.c |    4 ++--
  1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/exec/logsys.c b/exec/logsys.c
index 978c157..395a59d 100644
--- a/exec/logsys.c
+++ b/exec/logsys.c
@@ -527,8 +527,8 @@ 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))) {
  			break;
  		}
  	}
-- 
1.6.2.5


More information about the Openais mailing list