[vlc-commits] ts: fix potential signed overflow

Rémi Denis-Courmont git at videolan.org
Thu Jun 29 22:35:46 CEST 2017


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu Jun 29 23:15:39 2017 +0300| [c41a0c94f42a86f279f9078bf139bd8212293d45] | committer: Rémi Denis-Courmont

ts: fix potential signed overflow

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

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

diff --git a/modules/demux/mpeg/ts_psi.c b/modules/demux/mpeg/ts_psi.c
index 61cd723347..dfef6f8df3 100644
--- a/modules/demux/mpeg/ts_psi.c
+++ b/modules/demux/mpeg/ts_psi.c
@@ -1919,14 +1919,13 @@ int UserPmt( demux_t *p_demux, const char *psz_fmt )
     demux_sys_t *p_sys = p_demux->p_sys;
     char *psz_dup = strdup( psz_fmt );
     char *psz = psz_dup;
-    int  i_pid;
     int  i_number;
 
     if( !psz_dup )
         return VLC_ENOMEM;
 
     /* Parse PID */
-    i_pid = strtol( psz, &psz, 0 );
+    unsigned long i_pid = strtoul( psz, &psz, 0 );
     if( i_pid < 2 || i_pid >= 8192 )
         goto error;
 
@@ -1938,7 +1937,7 @@ int UserPmt( demux_t *p_demux, const char *psz_fmt )
     /* */
     ts_pid_t *pmtpid = GetPID(p_sys, i_pid);
 
-    msg_Dbg( p_demux, "user pmt specified (pid=%d,number=%d)", i_pid, i_number );
+    msg_Dbg( p_demux, "user pmt specified (pid=%lu,number=%d)", i_pid, i_number );
     if ( !PIDSetup( p_demux, TYPE_PMT, pmtpid, GetPID(p_sys, 0) ) )
         goto error;
 
@@ -1961,12 +1960,11 @@ int UserPmt( demux_t *p_demux, const char *psz_fmt )
     while( psz && *psz )
     {
         char *psz_next = strchr( psz, ',' );
-        int i_pid;
 
         if( psz_next )
             *psz_next++ = '\0';
 
-        i_pid = strtol( psz, &psz, 0 );
+        i_pid = strtoul( psz, &psz, 0 );
         if( *psz != ':' || i_pid < 2 || i_pid >= 8192 )
             goto next;
 
@@ -2021,7 +2019,7 @@ int UserPmt( demux_t *p_demux, const char *psz_fmt )
 
             if( fmt->i_cat != UNKNOWN_ES )
             {
-                msg_Dbg( p_demux, "  * es pid=%d fcc=%4.4s", i_pid,
+                msg_Dbg( p_demux, "  * es pid=%lu fcc=%4.4s", i_pid,
                          (char*)&fmt->i_codec );
                 pid->u.p_stream->p_es->id = es_out_Add( p_demux->out, fmt );
                 p_sys->i_pmt_es++;



More information about the vlc-commits mailing list