Просмотр исходного кода

Merge trunk revision 2547:
r2547 | asalkeld | 2009-11-22 16:19:41 -0700 (Sun, 22 Nov 2009) | 1 line

COVERITY 12: prevent overrun of logsys output buffers.



git-svn-id: http://svn.fedorahosted.org/svn/corosync/branches/flatiron@2602 fd59a12c-fef9-0310-b244-a6a79926bd2f

Steven Dake 16 лет назад
Родитель
Сommit
06d4b81a20
1 измененных файлов с 6 добавлено и 2 удалено
  1. 6 2
      exec/logsys.c

+ 6 - 2
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;
 		}
 	}