[vlc-commits] demux: ts: prevent unwanted read at end of media

Francois Cartegnie git at videolan.org
Sun Feb 22 16:43:59 CET 2015


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Sun Feb 22 01:21:05 2015 +0100| [d454281feb3bbfe51f09711705a9febc3ae674dd] | committer: Francois Cartegnie

demux: ts: prevent unwanted read at end of media

Truncated packets at the end

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d454281feb3bbfe51f09711705a9febc3ae674dd
---

 modules/demux/ts.c |    7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/modules/demux/ts.c b/modules/demux/ts.c
index ea7e017..c69d604 100644
--- a/modules/demux/ts.c
+++ b/modules/demux/ts.c
@@ -460,6 +460,7 @@ static void SetPrgFilter( demux_t *, int i_prg, bool b_selected );
 #define TS_PACKET_SIZE_192 192
 #define TS_PACKET_SIZE_204 204
 #define TS_PACKET_SIZE_MAX 204
+#define TS_HEADER_SIZE 4
 
 static int DetectPacketSize( demux_t *p_demux, int *pi_header_size, int i_offset )
 {
@@ -2409,6 +2410,12 @@ static block_t* ReadTSPacket( demux_t *p_demux )
         return NULL;
     }
 
+    if( p_pkt->i_buffer < TS_HEADER_SIZE + p_sys->i_packet_header_size )
+    {
+        block_Release( p_pkt );
+        return NULL;
+    }
+
     /* Skip header (BluRay streams).
      * re-sync logic would do this (by adjusting packet start), but this would result in losing first and last ts packets.
      * First packet is usually PAT, and losing it means losing whole first GOP. This is fatal with still-image based menus.



More information about the vlc-commits mailing list