Commit 80f94155 authored by Gildas Bazin's avatar Gildas Bazin

* modules/demux/util/id3.c, modules/demux/util/id3tag.c: don't use input_Peek() to read an id3 tag as these tags can be bigger than what input_Peek() can read.
parent ae27f53b
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* id3.c: simple id3 tag skipper * id3.c: simple id3 tag skipper
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * Copyright (C) 2001 VideoLAN
* $Id: id3.c,v 1.5 2003/10/25 00:49:14 sam Exp $ * $Id: id3.c,v 1.6 2003/11/02 22:15:14 gbazin Exp $
* *
* Authors: Sigmund Augdal <sigmunau@idi.ntnu.no> * Authors: Sigmund Augdal <sigmunau@idi.ntnu.no>
* *
...@@ -30,6 +30,8 @@ ...@@ -30,6 +30,8 @@
#include <vlc/vlc.h> #include <vlc/vlc.h>
#include <vlc/input.h> #include <vlc/input.h>
#include "ninput.h"
#include <sys/types.h> #include <sys/types.h>
/***************************************************************************** /*****************************************************************************
...@@ -64,16 +66,17 @@ static int SkipID3Tag( vlc_object_t *p_this ) ...@@ -64,16 +66,17 @@ static int SkipID3Tag( vlc_object_t *p_this )
p_input = (input_thread_t *)p_this; p_input = (input_thread_t *)p_this;
msg_Dbg( p_input, "Checking for ID3 tag" ); msg_Dbg( p_input, "Checking for ID3 tag" );
/* get 10 byte id3 header */ /* get 10 byte id3 header */
if( input_Peek( p_input, &p_peek, 10 ) < 10 ) if( stream_Peek( p_input->s, &p_peek, 10 ) < 10 )
{ {
msg_Err( p_input, "cannot peek()" ); msg_Err( p_input, "cannot peek()" );
return( VLC_EGENERIC ); return VLC_EGENERIC;
} }
if ( !( (p_peek[0] == 0x49) && (p_peek[1] == 0x44) && (p_peek[2] == 0x33))) if( p_peek[0] != 'I' || p_peek[1] != 'D' || p_peek[2] != '3' )
{ {
return( VLC_SUCCESS ); return VLC_SUCCESS;
} }
version = p_peek[3]; /* These may become usfull later, */ version = p_peek[3]; /* These may become usfull later, */
...@@ -89,15 +92,11 @@ static int SkipID3Tag( vlc_object_t *p_this ) ...@@ -89,15 +92,11 @@ static int SkipID3Tag( vlc_object_t *p_this )
} }
i_size += 10; i_size += 10;
/* peek the entire tag */ /* Skip the entire tag */
if ( input_Peek( p_input, &p_peek, i_size ) < i_size ) stream_Read( p_input->s, NULL, i_size );
{
msg_Err( p_input, "cannot peek()" );
return( VLC_EGENERIC );
}
msg_Dbg( p_input, "ID3v2.%d revision %d tag found, skiping %d bytes", msg_Dbg( p_input, "ID3v2.%d revision %d tag found, skiping %d bytes",
version, revision, i_size ); version, revision, i_size );
p_input->p_current_data += i_size; /* seek passed end of ID3 tag */
return ( VLC_SUCCESS ); return VLC_SUCCESS;
} }
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* id3tag.c: id3 tag parser/skipper based on libid3tag * id3tag.c: id3 tag parser/skipper based on libid3tag
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * Copyright (C) 2001 VideoLAN
* $Id: id3tag.c,v 1.14 2003/10/29 17:32:54 zorglub Exp $ * $Id: id3tag.c,v 1.15 2003/11/02 22:15:14 gbazin Exp $
* *
* Authors: Sigmund Augdal <sigmunau@idi.ntnu.no> * Authors: Sigmund Augdal <sigmunau@idi.ntnu.no>
* *
...@@ -31,6 +31,8 @@ ...@@ -31,6 +31,8 @@
#include <vlc/intf.h> #include <vlc/intf.h>
#include <vlc/input.h> #include <vlc/input.h>
#include "ninput.h"
#include <sys/types.h> #include <sys/types.h>
#include <id3tag.h> #include <id3tag.h>
...@@ -178,17 +180,17 @@ static int ParseID3Tags( vlc_object_t *p_this ) ...@@ -178,17 +180,17 @@ static int ParseID3Tags( vlc_object_t *p_this )
if ( p_input->stream.b_seekable && if ( p_input->stream.b_seekable &&
p_input->stream.i_method != INPUT_METHOD_NETWORK ) p_input->stream.i_method != INPUT_METHOD_NETWORK )
{ {
stream_position_t pos; int64_t i_pos;
/*look for a id3v1 tag at the end of the file*/ /*look for a id3v1 tag at the end of the file*/
input_Tell( p_input, &pos ); i_pos = stream_Tell( p_input->s );
if ( pos.i_size >128 ) if ( i_pos >128 )
{ {
input_AccessReinit( p_input ); input_AccessReinit( p_input );
p_input->pf_seek( p_input, pos.i_size - 128 ); p_input->pf_seek( p_input, i_pos - 128 );
/* get 10 byte id3 header */ /* get 10 byte id3 header */
if( input_Peek( p_input, &p_peek, 10 ) < 10 ) if( stream_Peek( p_input->s, &p_peek, 10 ) < 10 )
{ {
msg_Err( p_input, "cannot peek()" ); msg_Err( p_input, "cannot peek()" );
return( VLC_EGENERIC ); return( VLC_EGENERIC );
...@@ -197,7 +199,7 @@ static int ParseID3Tags( vlc_object_t *p_this ) ...@@ -197,7 +199,7 @@ static int ParseID3Tags( vlc_object_t *p_this )
if ( i_size2 == 128 ) if ( i_size2 == 128 )
{ {
/* peek the entire tag */ /* peek the entire tag */
if ( input_Peek( p_input, &p_peek, i_size2 ) < i_size2 ) if ( stream_Peek( p_input->s, &p_peek, i_size2 ) < i_size2 )
{ {
msg_Err( p_input, "cannot peek()" ); msg_Err( p_input, "cannot peek()" );
return( VLC_EGENERIC ); return( VLC_EGENERIC );
...@@ -207,18 +209,18 @@ static int ParseID3Tags( vlc_object_t *p_this ) ...@@ -207,18 +209,18 @@ static int ParseID3Tags( vlc_object_t *p_this )
/* look for id3v2.4 tag at end of file */ /* look for id3v2.4 tag at end of file */
/* get 10 byte id3 footer */ /* get 10 byte id3 footer */
if( input_Peek( p_input, &p_peek, 128 ) < 128 ) if( stream_Peek( p_input->s, &p_peek, 128 ) < 128 )
{ {
msg_Err( p_input, "cannot peek()" ); msg_Err( p_input, "cannot peek()" );
return( VLC_EGENERIC ); return( VLC_EGENERIC );
} }
i_size2 = id3_tag_query( p_peek + 118, 10 ); i_size2 = id3_tag_query( p_peek + 118, 10 );
if ( i_size2 < 0 && pos.i_size > -i_size2 ) if ( i_size2 < 0 && i_pos > -i_size2 )
{ /* id3v2.4 footer found */ { /* id3v2.4 footer found */
input_AccessReinit( p_input ); input_AccessReinit( p_input );
p_input->pf_seek( p_input, pos.i_size + i_size2 ); p_input->pf_seek( p_input, i_pos + i_size2 );
/* peek the entire tag */ /* peek the entire tag */
if ( input_Peek( p_input, &p_peek, i_size2 ) < i_size2 ) if ( stream_Peek( p_input->s, &p_peek, i_size2 ) < i_size2 )
{ {
msg_Err( p_input, "cannot peek()" ); msg_Err( p_input, "cannot peek()" );
return( VLC_EGENERIC ); return( VLC_EGENERIC );
...@@ -230,7 +232,7 @@ static int ParseID3Tags( vlc_object_t *p_this ) ...@@ -230,7 +232,7 @@ static int ParseID3Tags( vlc_object_t *p_this )
p_input->pf_seek( p_input, 0 ); p_input->pf_seek( p_input, 0 );
} }
/* get 10 byte id3 header */ /* get 10 byte id3 header */
if( input_Peek( p_input, &p_peek, 10 ) < 10 ) if( stream_Peek( p_input->s, &p_peek, 10 ) < 10 )
{ {
msg_Err( p_input, "cannot peek()" ); msg_Err( p_input, "cannot peek()" );
return( VLC_EGENERIC ); return( VLC_EGENERIC );
...@@ -242,15 +244,18 @@ static int ParseID3Tags( vlc_object_t *p_this ) ...@@ -242,15 +244,18 @@ static int ParseID3Tags( vlc_object_t *p_this )
return( VLC_SUCCESS ); return( VLC_SUCCESS );
} }
/* peek the entire tag */ /* Read the entire tag */
if ( input_Peek( p_input, &p_peek, i_size ) < i_size ) p_peek = malloc( i_size );
if( !p_peek || stream_Read( p_input->s, p_peek, i_size ) < i_size )
{ {
msg_Err( p_input, "cannot peek()" ); msg_Err( p_input, "cannot read id3 tag" );
if( p_peek ) free( p_peek );
return( VLC_EGENERIC ); return( VLC_EGENERIC );
} }
ParseID3Tag( p_input, p_peek, i_size ); ParseID3Tag( p_input, p_peek, i_size );
msg_Dbg( p_input, "ID3 tag found, skiping %d bytes", i_size ); msg_Dbg( p_input, "ID3 tag found, skiping %d bytes", i_size );
p_input->p_current_data += i_size; /* seek passed end of ID3 tag */
free( p_peek );
return( VLC_SUCCESS ); return( VLC_SUCCESS );
} }
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