Commit faf9aa57 authored by Francois Cartegnie's avatar Francois Cartegnie Committed by Jean-Baptiste Kempf

demux: ogg: fix headers validation

refs #12270

(cherry picked from commit d65a02c1d5771faf431ba73e716be9e88adcee21)
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 05d94c9e
......@@ -108,6 +108,9 @@ typedef struct
#define VORBIS_HEADER_IDENTIFICATION 1
#define VORBIS_HEADER_COMMENT 2
#define VORBIS_HEADER_SETUP 3
#define VORBIS_HEADER_TO_FLAG(i) (1 << (i - 1))
#define VORBIS_HEADERS_VALID(p_stream) \
((p_stream->special.vorbis.i_headers_flags & 0b111) == 0b111)
/*****************************************************************************
* Local prototypes
......@@ -509,7 +512,7 @@ static int Demux( demux_t * p_demux )
#ifdef HAVE_LIBVORBIS
case VLC_CODEC_VORBIS:
{
if( p_stream->special.vorbis.b_invalid )
if( !VORBIS_HEADERS_VALID(p_stream) )
{
msg_Err( p_demux, "missing vorbis headers, can't compute block size" );
break;
......@@ -990,7 +993,7 @@ static void Ogg_UpdatePCR( demux_t *p_demux, logical_stream_t *p_stream,
#ifdef HAVE_LIBVORBIS
else if ( p_stream->fmt.i_codec == VLC_CODEC_VORBIS &&
p_stream->special.vorbis.p_info &&
!p_stream->special.vorbis.b_invalid &&
VORBIS_HEADERS_VALID(p_stream) &&
p_stream->i_previous_granulepos > 0 )
{
long i_blocksize = vorbis_packet_blocksize(
......@@ -2139,7 +2142,7 @@ static void Ogg_CleanSpecificData( logical_stream_t *p_stream )
{
FREENULL( p_stream->special.vorbis.p_info );
FREENULL( p_stream->special.vorbis.p_comment );
p_stream->special.vorbis.b_invalid = false;
p_stream->special.vorbis.i_headers_flags = 0;
}
#else
VLC_UNUSED( p_stream );
......@@ -2528,7 +2531,6 @@ static void Ogg_DecodeVorbisHeader( logical_stream_t *p_stream,
{
FREENULL( p_stream->special.vorbis.p_info );
FREENULL( p_stream->special.vorbis.p_comment );
p_stream->special.vorbis.b_invalid = true;
break;
}
vorbis_info_init( p_stream->special.vorbis.p_info );
......@@ -2537,12 +2539,13 @@ static void Ogg_DecodeVorbisHeader( logical_stream_t *p_stream,
case VORBIS_HEADER_COMMENT:
case VORBIS_HEADER_SETUP:
if ( p_stream->special.vorbis.p_info && ! p_stream->special.vorbis.b_invalid )
{
p_stream->special.vorbis.b_invalid = ( 0 != vorbis_synthesis_headerin(
if ( !p_stream->special.vorbis.p_info ||
vorbis_synthesis_headerin(
p_stream->special.vorbis.p_info,
p_stream->special.vorbis.p_comment, p_oggpacket ) );
}
p_stream->special.vorbis.p_comment, p_oggpacket ) )
break;
p_stream->special.vorbis.i_headers_flags |= VORBIS_HEADER_TO_FLAG(i_number);
// ft
default:
......
......@@ -127,7 +127,7 @@ typedef struct logical_stream_s
{
vorbis_info *p_info;
vorbis_comment *p_comment;
bool b_invalid;
int i_headers_flags;
int i_prev_blocksize;
} vorbis;
#endif
......
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