[vlc-commits] commit: MP4: fix off-by-one genre metadata reading (Jean-Baptiste Kempf )

git at videolan.org git at videolan.org
Mon May 24 00:54:55 CEST 2010


vlc | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Mon May 24 00:42:04 2010 +0200| [99bf5aff5c87576eda3d9d2587242e31ea672a1c] | committer: Jean-Baptiste Kempf 

MP4: fix off-by-one genre metadata reading

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=99bf5aff5c87576eda3d9d2587242e31ea672a1c
---

 modules/demux/mp4/libmp4.c |    2 ++
 modules/demux/mp4/mp4.c    |    4 ++--
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/modules/demux/mp4/libmp4.c b/modules/demux/mp4/libmp4.c
index 11446e4..e8e10e5 100644
--- a/modules/demux/mp4/libmp4.c
+++ b/modules/demux/mp4/libmp4.c
@@ -1172,6 +1172,8 @@ static int MP4_ReadBox_gnre( stream_t *p_stream, MP4_Box_t *p_box )
     MP4_GET4BYTES( i_version );
     MP4_GET4BYTES( i_reserved );
     MP4_GET2BYTES( p_gnre->i_genre );
+    if( p_gnre->i_genre == 0 )
+        MP4_READBOX_EXIT( 0 );
 #ifdef MP4_VERBOSE
     msg_Dbg( p_stream, "read box: \"gnre\" genre=%i", p_gnre->i_genre );
 #endif
diff --git a/modules/demux/mp4/mp4.c b/modules/demux/mp4/mp4.c
index 24e09ef..b044ea9 100644
--- a/modules/demux/mp4/mp4.c
+++ b/modules/demux/mp4/mp4.c
@@ -905,8 +905,8 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
                     break;
 
                 case FOURCC_gnre:
-                    if( p_0xa9xxx->data.p_gnre->i_genre < NUM_GENRES )
-                        vlc_meta_SetGenre( p_meta, ppsz_genres[p_0xa9xxx->data.p_gnre->i_genre] );
+                    if( p_0xa9xxx->data.p_gnre->i_genre <= NUM_GENRES )
+                        vlc_meta_SetGenre( p_meta, ppsz_genres[p_0xa9xxx->data.p_gnre->i_genre - 1] );
                     break;
 
                 case FOURCC_0xa9alb: /* Album */



More information about the vlc-commits mailing list