]> git.sesse.net Git - vlc/commitdiff
demux: ts: prevent unwanted read at end of media
authorFrancois Cartegnie <fcvlcdev@free.fr>
Sun, 22 Feb 2015 00:21:05 +0000 (01:21 +0100)
committerFrancois Cartegnie <fcvlcdev@free.fr>
Sun, 22 Feb 2015 15:38:21 +0000 (16:38 +0100)
Truncated packets at the end

modules/demux/ts.c

index ea7e017dee14bde7c506319501b808ece1296d36..c69d6043d970b8808a9b7eb0eba27e4b25d9cea9 100644 (file)
@@ -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.