Commit d454281f authored by Francois Cartegnie's avatar Francois Cartegnie

demux: ts: prevent unwanted read at end of media

Truncated packets at the end
parent 29533737
...@@ -460,6 +460,7 @@ static void SetPrgFilter( demux_t *, int i_prg, bool b_selected ); ...@@ -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_192 192
#define TS_PACKET_SIZE_204 204 #define TS_PACKET_SIZE_204 204
#define TS_PACKET_SIZE_MAX 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 ) 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 ) ...@@ -2409,6 +2410,12 @@ static block_t* ReadTSPacket( demux_t *p_demux )
return NULL; 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). /* 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. * 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. * First packet is usually PAT, and losing it means losing whole first GOP. This is fatal with still-image based menus.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment