[MPlayer-cvslog] r37645 - trunk/libmpdemux/demux_ty.c

reimar subversion at mplayerhq.hu
Tue Feb 9 22:52:11 CET 2016


Author: reimar
Date: Tue Feb  9 22:52:11 2016
New Revision: 37645

Log:
demux_ty: change input validation so Coverity detects it.

Due to the limited possible range of the values,
the previous code should still have been
effective even though it is not the recommended
way to check.

Modified:
   trunk/libmpdemux/demux_ty.c

Modified: trunk/libmpdemux/demux_ty.c
==============================================================================
--- trunk/libmpdemux/demux_ty.c	Tue Feb  9 22:41:14 2016	(r37644)
+++ trunk/libmpdemux/demux_ty.c	Tue Feb  9 22:52:11 2016	(r37645)
@@ -524,7 +524,7 @@ static int demux_ty_fill_buffer( demuxer
       // ================================================================
       if ( type == 0xe0 )
       {
-         if ( size > 0 && size + offset <= CHUNKSIZE )
+         if ( size > 0 && size <= CHUNKSIZE - offset )
          {
             int esOffset1 = demux_ty_FindESHeader( VIDEO_NAL, &chunk[ offset ],
                size);
@@ -547,7 +547,7 @@ static int demux_ty_fill_buffer( demuxer
       // ================================================================
       else if ( type == 0xc0 )
       {
-         if ( size > 0 && size + offset <= CHUNKSIZE )
+         if ( size > 0 && size <= CHUNKSIZE - offset )
          {
             if( demux->audio->id == -1 )
             {
@@ -703,7 +703,7 @@ static int demux_ty_fill_buffer( demuxer
       // ================================================================
       else
       {
-         if ( size > 0 && size + offset <= CHUNKSIZE )
+         if ( size > 0 && size <= CHUNKSIZE - offset )
             offset += size;
          if (type != 3 && type != 5 && (type != 0 || size > 0)) {
          mp_msg( MSGT_DEMUX, MSGL_DBG3, "ty:Invalid Type %x\n", type );


More information about the MPlayer-cvslog mailing list