File gstreamer-mptssection-fix-pat-parsing.patch of Package gstreamer-plugins-bad.3891

From 7b12593cceaa0726d7fc370a7556a8e773ccf318 Mon Sep 17 00:00:00 2001
From: Edward Hervey <edward@centricular.com>
Date: Sat, 26 Nov 2016 10:23:01 +0100
Subject: [PATCH] mpegtssection: Fix PAT parsing

Use the estimated number of programs for parsing. Avoids over-reading.

https://bugzilla.gnome.org/show_bug.cgi?id=775120

Backported by Mike Gorse <mgorse@suse.com>
---
diff -urp gst-plugins-bad-1.2.4.orig/gst-libs/gst/mpegts/gstmpegtssection.c gst-plugins-bad-1.2.4/gst-libs/gst/mpegts/gstmpegtssection.c
--- gst-plugins-bad-1.2.4.orig/gst-libs/gst/mpegts/gstmpegtssection.c	2016-12-13 13:33:44.044016286 -0600
+++ gst-plugins-bad-1.2.4/gst-libs/gst/mpegts/gstmpegtssection.c	2016-12-13 13:40:29.788016615 -0600
@@ -337,7 +337,7 @@ static gpointer
 _parse_pat (GstMpegTsSection * section)
 {
   GPtrArray *pat;
-  guint16 i = 0, nb_programs;
+  guint16 i, nb_programs;
   GstMpegTsPatProgram *program;
   guint8 *data, *end;
 
@@ -353,7 +353,9 @@ _parse_pat (GstMpegTsSection * section)
       g_ptr_array_new_full (nb_programs,
       (GDestroyNotify) _mpegts_pat_program_free);
 
-  while (data < end - 4) {
+  GST_LOG ("nb_programs %u", nb_programs);
+
+  for (i = 0; i < nb_programs; i++) {
     program = g_slice_new0 (GstMpegTsPatProgram);
     program->program_number = GST_READ_UINT16_BE (data);
     data += 2;
@@ -362,8 +364,6 @@ _parse_pat (GstMpegTsSection * section)
     data += 2;
 
     g_ptr_array_index (pat, i) = program;
-
-    i++;
   }
   pat->len = nb_programs;
 
Only in gst-plugins-bad-1.2.4/gst-libs/gst/mpegts: gstmpegtssection.c.orig
Only in gst-plugins-bad-1.2.4/gst-libs/gst/mpegts: gstmpegtssection.c.rej