[vlc-devel] commit: input: Fix strtol usage. (Pierre d'Herbemont )

git version control git at videolan.org
Wed Aug 13 01:48:53 CEST 2008


vlc | branch: master | Pierre d'Herbemont <pdherbemont at videolan.org> | Wed Aug 13 01:51:40 2008 +0200| [427c9725d96b1a81f0ab9810e9352fb2213c354f] | committer: Pierre d'Herbemont 

input: Fix strtol usage.

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

 src/input/input.c |   28 +++++++++++++++++++++++++---
 1 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/src/input/input.c b/src/input/input.c
index 57f3cee..a39cf78 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -2710,6 +2710,20 @@ void MRLSplit( char *psz_dup, const char **ppsz_access, const char **ppsz_demux,
     *ppsz_path = psz_path ? psz_path : (char*)"";
 }
 
+static inline bool next(char ** src)
+{
+    char *end;
+    errno = 0;
+    long result = strtol( *src, &end, 0 );
+    if( errno != 0 || result >= LONG_MAX || result <= LONG_MIN ||
+        end == *src )
+    {
+        return false;
+    }
+    *src = end;
+    return true;
+}
+
 /*****************************************************************************
  * MRLSections: parse title and seekpoint info from the Media Resource Locator.
  *
@@ -2728,19 +2742,27 @@ static void MRLSections( input_thread_t *p_input, char *psz_source,
     /* Start by parsing titles and chapters */
     if( !psz_source || !( psz = strrchr( psz_source, '@' ) ) ) return;
 
+
     /* Check we are really dealing with a title/chapter section */
     psz_check = psz + 1;
     if( !*psz_check ) return;
-    if( isdigit(*psz_check) ) strtol( psz_check, &psz_check, 0 );
+    if( isdigit(*psz_check) )
+        if(!next(&psz_check)) return;
     if( *psz_check != ':' && *psz_check != '-' && *psz_check ) return;
     if( *psz_check == ':' && ++psz_check )
-        if( isdigit(*psz_check) ) strtol( psz_check, &psz_check, 0 );
+    {
+        if( isdigit(*psz_check) )
+            if(!next(&psz_check)) return;
+    }
     if( *psz_check != '-' && *psz_check ) return;
     if( *psz_check == '-' && ++psz_check )
         if( isdigit(*psz_check) ) strtol( psz_check, &psz_check, 0 );
     if( *psz_check != ':' && *psz_check ) return;
     if( *psz_check == ':' && ++psz_check )
-        if( isdigit(*psz_check) ) strtol( psz_check, &psz_check, 0 );
+    {
+        if( isdigit(*psz_check) )
+            if(!next(&psz_check)) return;
+    }
     if( *psz_check ) return;
 
     /* Separate start and end */




More information about the vlc-devel mailing list