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

COVERITY 12: prevent overrun of logsys output buffers.

git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2547 fd59a12c-fef9-0310-b244-a6a79926bd2f
Angus Salkeld 16 лет назад
Родитель
Сommit
34ddb1cb14
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;
 		}
 	}