Commit 30ff7129 authored by Derk-Jan Hartman's avatar Derk-Jan Hartman

* prevent potential crashes on files with broken channelcount

parent 4e03ca06
...@@ -185,6 +185,14 @@ static int Open( vlc_object_t *p_this ) ...@@ -185,6 +185,14 @@ static int Open( vlc_object_t *p_this )
return VLC_EGENERIC; return VLC_EGENERIC;
} }
if( p_dec->fmt_in.audio.i_channels <= 0 ||
p_dec->fmt_in.audio.i_channels > 6 )
{
msg_Err( p_dec, "invalid number of channels (not between 1 and 6): %i",
p_dec->fmt_in.audio.i_channels );
return VLC_EGENERIC;
}
p_dec->p_sys = p_sys = malloc( sizeof( decoder_sys_t ) ); p_dec->p_sys = p_sys = malloc( sizeof( decoder_sys_t ) );
memset( p_sys, 0, sizeof(decoder_sys_t) ); memset( p_sys, 0, sizeof(decoder_sys_t) );
......
...@@ -383,6 +383,13 @@ static int ProcessInitialHeader( decoder_t *p_dec, ogg_packet *p_oggpacket ) ...@@ -383,6 +383,13 @@ static int ProcessInitialHeader( decoder_t *p_dec, ogg_packet *p_oggpacket )
callback.data = &p_sys->stereo; callback.data = &p_sys->stereo;
speex_decoder_ctl( p_state, SPEEX_SET_HANDLER, &callback ); speex_decoder_ctl( p_state, SPEEX_SET_HANDLER, &callback );
} }
if( p_header->nb_channels <= 0 ||
p_header->nb_channels > 5 )
{
msg_Err( p_dec, "invalid number of channels (not between 1 and 5): %i",
p_header->nb_channels );
return VLC_EGENERIC;
}
/* Setup the format */ /* Setup the format */
p_dec->fmt_out.audio.i_physical_channels = p_dec->fmt_out.audio.i_physical_channels =
......
...@@ -387,6 +387,15 @@ static int ProcessHeaders( decoder_t *p_dec ) ...@@ -387,6 +387,15 @@ static int ProcessHeaders( decoder_t *p_dec )
/* Setup the format */ /* Setup the format */
p_dec->fmt_out.audio.i_rate = p_sys->vi.rate; p_dec->fmt_out.audio.i_rate = p_sys->vi.rate;
p_dec->fmt_out.audio.i_channels = p_sys->vi.channels; p_dec->fmt_out.audio.i_channels = p_sys->vi.channels;
if( p_dec->fmt_out.audio.i_channels < 0 ||
p_dec->fmt_out.audio.i_channels > 6 )
{
msg_Err( p_dec, "invalid number of channels (not between 1 and 6): %i",
p_dec->fmt_out.audio.i_channels );
return VLC_EGENERIC;
}
p_dec->fmt_out.audio.i_physical_channels = p_dec->fmt_out.audio.i_physical_channels =
p_dec->fmt_out.audio.i_original_channels = p_dec->fmt_out.audio.i_original_channels =
pi_channels_maps[p_sys->vi.channels]; pi_channels_maps[p_sys->vi.channels];
......
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