]> git.sesse.net Git - vlc/commitdiff
stream_ReadLine: correctly return an error on overflow (fixes #7361)
authorRémi Denis-Courmont <remi@remlab.net>
Thu, 25 Apr 2013 15:04:07 +0000 (18:04 +0300)
committerRémi Denis-Courmont <remi@remlab.net>
Thu, 25 Apr 2013 15:04:07 +0000 (18:04 +0300)
src/input/stream.c

index 4718f70a1e6c34e179445daa2b54fa0f1544b815..d3c4d9ec1132627879cb75c74ee9036528d9b9f9 100644 (file)
@@ -1472,7 +1472,7 @@ char *stream_ReadLine( stream_t *s )
     char *p_line = NULL;
     int i_line = 0, i_read = 0;
 
-    while( i_read < STREAM_LINE_MAX )
+    for( ;; )
     {
         char *psz_eol;
         const uint8_t *p_data;
@@ -1585,6 +1585,9 @@ char *stream_ReadLine( stream_t *s )
         if( i_data <= 0 ) break; /* Hmmm */
         i_line += i_data;
         i_read += i_data;
+
+        if( i_read >= STREAM_LINE_MAX )
+            goto error; /* line too long */
     }
 
     if( i_read > 0 )