[vlc-devel] commit: TTA: Sanity check to avoid overflow and typo (Jean-Baptiste Kempf )

git version control git at videolan.org
Wed Aug 20 22:55:13 CEST 2008


vlc | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Wed Aug 20 13:56:05 2008 -0700| [d487b81dde82b458dd6ffe6cb73aa798d6b0b855] | committer: Jean-Baptiste Kempf 

TTA: Sanity check to avoid overflow and typo

i_rate can go up to 2^32-1.
If you * 1.044 it is going to not fit in a int (_framelength)

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

 modules/demux/tta.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/modules/demux/tta.c b/modules/demux/tta.c
index 216f0d0..3121028 100644
--- a/modules/demux/tta.c
+++ b/modules/demux/tta.c
@@ -99,7 +99,7 @@ static int Open( vlc_object_t * p_this )
         if( !p_demux->b_force ) return VLC_EGENERIC;
 
         /* User forced */
-        msg_Err( p_demux, "this doesn't look like a flac stream, "
+        msg_Err( p_demux, "this doesn't look like a true-audio stream, "
                  "continuing anyway" );
     }
 
@@ -120,8 +120,12 @@ static int Open( vlc_object_t * p_this )
     fmt.audio.i_channels = GetWLE( &p_header[6] );
     fmt.audio.i_bitspersample = GetWLE( &p_header[8] );
     fmt.audio.i_rate = GetDWLE( &p_header[10] );
-    if( fmt.audio.i_rate == 0 )
+    if( fmt.audio.i_rate == 0 || /* Avoid divide by 0 */
+        fmt.audio.i_rate > ( 1 << 20 ) /* Avoid i_framelength overflow */ )
+    {
+        msg_Warn( p_demux, "Wrong sample rate" );
         goto error;
+    }
 
     p_sys->i_datalength = GetDWLE( &p_header[14] );
     p_sys->i_framelength = TTA_FRAMETIME * fmt.audio.i_rate;




More information about the vlc-devel mailing list