Commit 00f78a1e authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

strncmp => memcmp (refs #258)

ogg.c : FIXME FIXME FIXME
I don't know Ogg format well, but don't we have a possible out-of-bound
read at line 1346 and following ??
parent 5585f98e
...@@ -78,13 +78,13 @@ static int Open( vlc_object_t * p_this ) ...@@ -78,13 +78,13 @@ static int Open( vlc_object_t * p_this )
/* Check if we are dealing with a WAV file */ /* Check if we are dealing with a WAV file */
if( stream_Peek( p_demux->s, &p_peek, 20 ) == 20 && if( stream_Peek( p_demux->s, &p_peek, 20 ) == 20 &&
!strncmp( p_peek, "RIFF", 4 ) && !strncmp( &p_peek[8], "WAVE", 4 ) ) !memcmp( p_peek, "RIFF", 4 ) && !memcmp( &p_peek[8], "WAVE", 4 ) )
{ {
int i_size; int i_size;
/* Find the wave format header */ /* Find the wave format header */
i_peek = 20; i_peek = 20;
while( strncmp( p_peek + i_peek - 8, "fmt ", 4 ) ) while( memcmp( p_peek + i_peek - 8, "fmt ", 4 ) )
{ {
i_size = GetDWLE( p_peek + i_peek - 4 ); i_size = GetDWLE( p_peek + i_peek - 4 );
if( i_size + i_peek > DTS_PROBE_SIZE ) return VLC_EGENERIC; if( i_size + i_peek > DTS_PROBE_SIZE ) return VLC_EGENERIC;
...@@ -110,7 +110,7 @@ static int Open( vlc_object_t * p_this ) ...@@ -110,7 +110,7 @@ static int Open( vlc_object_t * p_this )
return VLC_EGENERIC; return VLC_EGENERIC;
/* Skip the wave header */ /* Skip the wave header */
while( strncmp( p_peek + i_peek - 8, "data", 4 ) ) while( memcmp( p_peek + i_peek - 8, "data", 4 ) )
{ {
i_size = GetDWLE( p_peek + i_peek - 4 ); i_size = GetDWLE( p_peek + i_peek - 4 );
if( i_size + i_peek > DTS_PROBE_SIZE ) return VLC_EGENERIC; if( i_size + i_peek > DTS_PROBE_SIZE ) return VLC_EGENERIC;
......
...@@ -183,7 +183,7 @@ static int Open( vlc_object_t * p_this ) ...@@ -183,7 +183,7 @@ static int Open( vlc_object_t * p_this )
/* Check if we are dealing with an ogg stream */ /* Check if we are dealing with an ogg stream */
if( stream_Peek( p_demux->s, &p_peek, 4 ) < 4 ) return VLC_EGENERIC; if( stream_Peek( p_demux->s, &p_peek, 4 ) < 4 ) return VLC_EGENERIC;
if( strcmp( p_demux->psz_demux, "ogg" ) && strncmp( p_peek, "OggS", 4 ) ) if( strcmp( p_demux->psz_demux, "ogg" ) && memcmp( p_peek, "OggS", 4 ) )
{ {
return VLC_EGENERIC; return VLC_EGENERIC;
} }
...@@ -276,14 +276,14 @@ static int Demux( demux_t * p_demux ) ...@@ -276,14 +276,14 @@ static int Demux( demux_t * p_demux )
{ {
if( p_stream->fmt.i_codec == VLC_FOURCC('t','h','e','o') && if( p_stream->fmt.i_codec == VLC_FOURCC('t','h','e','o') &&
oggpacket.bytes >= 7 && oggpacket.bytes >= 7 &&
! strncmp( &oggpacket.packet[1], "theora", 6 ) ) ! memcmp( &oggpacket.packet[1], "theora", 6 ) )
{ {
Ogg_ReadTheoraHeader( p_stream, &oggpacket ); Ogg_ReadTheoraHeader( p_stream, &oggpacket );
p_stream->secondary_header_packets = 0; p_stream->secondary_header_packets = 0;
} }
else if( p_stream->fmt.i_codec == VLC_FOURCC('v','o','r','b') && else if( p_stream->fmt.i_codec == VLC_FOURCC('v','o','r','b') &&
oggpacket.bytes >= 7 && oggpacket.bytes >= 7 &&
! strncmp( &oggpacket.packet[1], "vorbis", 6 ) ) ! memcmp( &oggpacket.packet[1], "vorbis", 6 ) )
{ {
Ogg_ReadVorbisHeader( p_stream, &oggpacket ); Ogg_ReadVorbisHeader( p_stream, &oggpacket );
p_stream->secondary_header_packets = 0; p_stream->secondary_header_packets = 0;
...@@ -404,7 +404,7 @@ static int Ogg_ReadPage( demux_t *p_demux, ogg_page *p_oggpage ) ...@@ -404,7 +404,7 @@ static int Ogg_ReadPage( demux_t *p_demux, ogg_page *p_oggpage )
{ {
demux_sys_t *p_ogg = p_demux->p_sys ; demux_sys_t *p_ogg = p_demux->p_sys ;
int i_read = 0; int i_read = 0;
byte_t *p_buffer; char *p_buffer;
while( ogg_sync_pageout( &p_ogg->oy, p_oggpage ) != 1 ) while( ogg_sync_pageout( &p_ogg->oy, p_oggpage ) != 1 )
{ {
...@@ -484,13 +484,13 @@ static void Ogg_DecodePacket( demux_t *p_demux, ...@@ -484,13 +484,13 @@ static void Ogg_DecodePacket( demux_t *p_demux,
} }
if( p_oggpacket->bytes >= 7 && if( p_oggpacket->bytes >= 7 &&
! strncmp ( &p_oggpacket->packet[0], "Annodex", 7 ) ) ! memcmp ( &p_oggpacket->packet[0], "Annodex", 7 ) )
{ {
/* it's an Annodex packet -- skip it (do nothing) */ /* it's an Annodex packet -- skip it (do nothing) */
return; return;
} }
else if( p_oggpacket->bytes >= 7 && else if( p_oggpacket->bytes >= 7 &&
! strncmp ( &p_oggpacket->packet[0], "AnxData", 7 ) ) ! memcmp ( &p_oggpacket->packet[0], "AnxData", 7 ) )
{ {
/* it's an AnxData packet -- skip it (do nothing) */ /* it's an AnxData packet -- skip it (do nothing) */
return; return;
...@@ -756,14 +756,14 @@ static int Ogg_FindLogicalStreams( demux_t *p_demux ) ...@@ -756,14 +756,14 @@ static int Ogg_FindLogicalStreams( demux_t *p_demux )
/* Check for Vorbis header */ /* Check for Vorbis header */
if( oggpacket.bytes >= 7 && if( oggpacket.bytes >= 7 &&
! strncmp( &oggpacket.packet[1], "vorbis", 6 ) ) ! memcmp( &oggpacket.packet[1], "vorbis", 6 ) )
{ {
Ogg_ReadVorbisHeader( p_stream, &oggpacket ); Ogg_ReadVorbisHeader( p_stream, &oggpacket );
msg_Dbg( p_demux, "found vorbis header" ); msg_Dbg( p_demux, "found vorbis header" );
} }
/* Check for Speex header */ /* Check for Speex header */
else if( oggpacket.bytes >= 7 && else if( oggpacket.bytes >= 7 &&
! strncmp( &oggpacket.packet[0], "Speex", 5 ) ) ! memcmp( &oggpacket.packet[0], "Speex", 5 ) )
{ {
Ogg_ReadSpeexHeader( p_stream, &oggpacket ); Ogg_ReadSpeexHeader( p_stream, &oggpacket );
msg_Dbg( p_demux, "found speex header, channels: %i, " msg_Dbg( p_demux, "found speex header, channels: %i, "
...@@ -773,7 +773,7 @@ static int Ogg_FindLogicalStreams( demux_t *p_demux ) ...@@ -773,7 +773,7 @@ static int Ogg_FindLogicalStreams( demux_t *p_demux )
} }
/* Check for Flac header (< version 1.1.1) */ /* Check for Flac header (< version 1.1.1) */
else if( oggpacket.bytes >= 4 && else if( oggpacket.bytes >= 4 &&
! strncmp( &oggpacket.packet[0], "fLaC", 4 ) ) ! memcmp( &oggpacket.packet[0], "fLaC", 4 ) )
{ {
msg_Dbg( p_demux, "found FLAC header" ); msg_Dbg( p_demux, "found FLAC header" );
...@@ -787,8 +787,8 @@ static int Ogg_FindLogicalStreams( demux_t *p_demux ) ...@@ -787,8 +787,8 @@ static int Ogg_FindLogicalStreams( demux_t *p_demux )
} }
/* Check for Flac header (>= version 1.1.1) */ /* Check for Flac header (>= version 1.1.1) */
else if( oggpacket.bytes >= 13 && oggpacket.packet[0] ==0x7F && else if( oggpacket.bytes >= 13 && oggpacket.packet[0] ==0x7F &&
! strncmp( &oggpacket.packet[1], "FLAC", 4 ) && ! memcmp( &oggpacket.packet[1], "FLAC", 4 ) &&
! strncmp( &oggpacket.packet[9], "fLaC", 4 ) ) ! memcmp( &oggpacket.packet[9], "fLaC", 4 ) )
{ {
int i_packets = ((int)oggpacket.packet[7]) << 8 | int i_packets = ((int)oggpacket.packet[7]) << 8 |
oggpacket.packet[8]; oggpacket.packet[8];
...@@ -806,7 +806,7 @@ static int Ogg_FindLogicalStreams( demux_t *p_demux ) ...@@ -806,7 +806,7 @@ static int Ogg_FindLogicalStreams( demux_t *p_demux )
} }
/* Check for Theora header */ /* Check for Theora header */
else if( oggpacket.bytes >= 7 && else if( oggpacket.bytes >= 7 &&
! strncmp( &oggpacket.packet[1], "theora", 6 ) ) ! memcmp( &oggpacket.packet[1], "theora", 6 ) )
{ {
Ogg_ReadTheoraHeader( p_stream, &oggpacket ); Ogg_ReadTheoraHeader( p_stream, &oggpacket );
...@@ -816,7 +816,7 @@ static int Ogg_FindLogicalStreams( demux_t *p_demux ) ...@@ -816,7 +816,7 @@ static int Ogg_FindLogicalStreams( demux_t *p_demux )
} }
/* Check for Tarkin header */ /* Check for Tarkin header */
else if( oggpacket.bytes >= 7 && else if( oggpacket.bytes >= 7 &&
! strncmp( &oggpacket.packet[1], "tarkin", 6 ) ) ! memcmp( &oggpacket.packet[1], "tarkin", 6 ) )
{ {
oggpack_buffer opb; oggpack_buffer opb;
...@@ -836,7 +836,7 @@ static int Ogg_FindLogicalStreams( demux_t *p_demux ) ...@@ -836,7 +836,7 @@ static int Ogg_FindLogicalStreams( demux_t *p_demux )
} }
/* Check for Annodex header */ /* Check for Annodex header */
else if( oggpacket.bytes >= 7 && else if( oggpacket.bytes >= 7 &&
! strncmp( &oggpacket.packet[0], "Annodex", 7 ) ) ! memcmp( &oggpacket.packet[0], "Annodex", 7 ) )
{ {
Ogg_ReadAnnodexHeader( VLC_OBJECT(p_demux), p_stream, Ogg_ReadAnnodexHeader( VLC_OBJECT(p_demux), p_stream,
&oggpacket ); &oggpacket );
...@@ -846,13 +846,13 @@ static int Ogg_FindLogicalStreams( demux_t *p_demux ) ...@@ -846,13 +846,13 @@ static int Ogg_FindLogicalStreams( demux_t *p_demux )
} }
/* Check for Annodex header */ /* Check for Annodex header */
else if( oggpacket.bytes >= 7 && else if( oggpacket.bytes >= 7 &&
! strncmp( &oggpacket.packet[0], "AnxData", 7 ) ) ! memcmp( &oggpacket.packet[0], "AnxData", 7 ) )
{ {
Ogg_ReadAnnodexHeader( VLC_OBJECT(p_demux), p_stream, Ogg_ReadAnnodexHeader( VLC_OBJECT(p_demux), p_stream,
&oggpacket ); &oggpacket );
} }
else if( oggpacket.bytes >= 142 && else if( oggpacket.bytes >= 142 &&
!strncmp( &oggpacket.packet[1], !memcmp( &oggpacket.packet[1],
"Direct Show Samples embedded in Ogg", 35 )) "Direct Show Samples embedded in Ogg", 35 ))
{ {
/* Old header type */ /* Old header type */
...@@ -1310,7 +1310,7 @@ static void Ogg_ReadAnnodexHeader( vlc_object_t *p_this, ...@@ -1310,7 +1310,7 @@ static void Ogg_ReadAnnodexHeader( vlc_object_t *p_this,
logical_stream_t *p_stream, logical_stream_t *p_stream,
ogg_packet *p_oggpacket ) ogg_packet *p_oggpacket )
{ {
if( ! strncmp( &p_oggpacket->packet[0], "Annodex", 7 ) ) if( ! memcmp( &p_oggpacket->packet[0], "Annodex", 7 ) )
{ {
oggpack_buffer opb; oggpack_buffer opb;
...@@ -1328,7 +1328,7 @@ static void Ogg_ReadAnnodexHeader( vlc_object_t *p_this, ...@@ -1328,7 +1328,7 @@ static void Ogg_ReadAnnodexHeader( vlc_object_t *p_this,
timebase_numerator = GetQWLE( &p_oggpacket->packet[16] ); timebase_numerator = GetQWLE( &p_oggpacket->packet[16] );
timebase_denominator = GetQWLE( &p_oggpacket->packet[24] ); timebase_denominator = GetQWLE( &p_oggpacket->packet[24] );
} }
else if( ! strncmp( &p_oggpacket->packet[0], "AnxData", 7 ) ) else if( ! memcmp( &p_oggpacket->packet[0], "AnxData", 7 ) )
{ {
uint64_t granule_rate_numerator; uint64_t granule_rate_numerator;
uint64_t granule_rate_denominator; uint64_t granule_rate_denominator;
......
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