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

fplay: Check minimum record size

For records in fdata smaller then 4 display error, because such record
is invalid.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Fabio M. Di Nitto <fdinitto@redhat.com>
Jan Friesse 13 лет назад
Родитель
Сommit
ef63aae139
1 измененных файлов с 10 добавлено и 0 удалено
  1. 10 0
      tools/corosync-fplay.c

+ 10 - 0
tools/corosync-fplay.c

@@ -343,6 +343,11 @@ static unsigned int printer_subsys_count =
 
 #define G_RECORD_SIZE	10000
 
+/*
+ * Record must have at least 4 bytes - size, indent, line and record_number
+ */
+#define MINIMUM_RECORD_SIZE	4
+
 static uint32_t g_record[G_RECORD_SIZE];
 
 /*
@@ -362,6 +367,11 @@ static int logsys_rec_get (int rec_idx) {
 		exit (EXIT_FAILURE);
 	}
 
+	if (rec_size < MINIMUM_RECORD_SIZE) {
+		fprintf (stderr, "rec_size too small. Input file is probably corrupted.\n");
+		exit (EXIT_FAILURE);
+	}
+
 	if (firstcopy + rec_idx > flt_data_size) {
 		firstcopy = flt_data_size - rec_idx;
 		secondcopy -= firstcopy - rec_size;