[vlc-commits] demux/asf: fix 17601: fix undesired integer underflow

Filip Roséen git at videolan.org
Fri Nov 4 10:11:56 CET 2016


vlc | branch: master | Filip Roséen <filip at atch.se> | Fri Nov  4 10:02:04 2016 +0100| [e2fb10438ae71913bf4f90834c305867329350fa] | committer: Thomas Guillem

demux/asf: fix 17601: fix undesired integer underflow

This commit shall be viewed as a fix-up of 86835f9.

The previous commit in question did not take into account that the
left-hand side expression can of course result in a negative value,
meaning that the value-promotion necessary for the comparison to take
place would result in a very large value (where we expect a very small
one).

fixes #17601

Signed-off-by: Thomas Guillem <thomas at gllm.fr>

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

 modules/demux/asf/asf.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/modules/demux/asf/asf.c b/modules/demux/asf/asf.c
index 5cbb800..b17e862 100644
--- a/modules/demux/asf/asf.c
+++ b/modules/demux/asf/asf.c
@@ -212,8 +212,9 @@ static int Demux( demux_t *p_demux )
             tk->b_selected = false;
     }
 
-    while( !p_sys->b_eos && ( ( p_sys->i_sendtime - p_sys->i_time - CHUNK ) /
-                                UINT64_C( 1000 ) < p_sys->p_fp->i_preroll ) )
+    while( !p_sys->b_eos && ( p_sys->i_sendtime - p_sys->i_time - CHUNK < 0 ||
+                            ( p_sys->i_sendtime - p_sys->i_time - CHUNK ) /
+                              UINT64_C( 1000 ) < p_sys->p_fp->i_preroll ) )
     {
         /* Read and demux a packet */
         if( DemuxASFPacket( &p_sys->packet_sys,
@@ -240,8 +241,9 @@ static int Demux( demux_t *p_demux )
             p_sys->i_time = p_sys->i_sendtime;
     }
 
-    if( p_sys->b_eos || ( ( p_sys->i_sendtime - p_sys->i_time - CHUNK ) /
-                          UINT64_C( 1000 ) >= p_sys->p_fp->i_preroll ) )
+    if( !p_sys->b_eos && ( p_sys->i_sendtime - p_sys->i_time - CHUNK >= 0 &&
+                         ( p_sys->i_sendtime - p_sys->i_time - CHUNK ) /
+                           UINT64_C( 1000 ) >= p_sys->p_fp->i_preroll ) )
     {
         bool b_data = Block_Dequeue( p_demux, p_sys->i_time + CHUNK );
 



More information about the vlc-commits mailing list