[vlc-devel] commit: Add support for last lines without newline in .hosts (untested). ( JP Dinger )

git version control git at videolan.org
Sat Sep 12 10:56:26 CEST 2009


vlc | branch: 1.0-bugfix | JP Dinger <jpd at videolan.org> | Tue Sep  8 10:52:26 2009 +0200| [56c94f9c1dba240b9162d4d4a4a9b011b1304ab4] | committer: JP Dinger 

Add support for last lines without newline in .hosts (untested).
(cherry picked from commit a4f7a49fdcbcaed4709b84a768afcd81b93a776f)

Backported after Ken Dreyer reported the fix works as advertised. [vlc-devel]

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

 src/network/acl.c |   15 +++++++--------
 1 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/src/network/acl.c b/src/network/acl.c
index c177781..37f21bc 100644
--- a/src/network/acl.c
+++ b/src/network/acl.c
@@ -335,7 +335,7 @@ int ACL_LoadFile( vlc_acl_t *p_acl, const char *psz_path )
             continue;
 
         ptr = strchr( psz_ip, '\n' );
-        if( ptr == NULL )
+        if( ptr == NULL && !feof(file) )
         {
             msg_Warn( p_acl->p_owner, "skipping overly long line in %s",
                       psz_path);
@@ -356,16 +356,15 @@ int ACL_LoadFile( vlc_acl_t *p_acl, const char *psz_path )
             continue; /* skip unusable line */
         }
 
-        /* skips comment-only line */
-        if( *psz_ip == '#' )
-            continue;
-
-        /* looks for first space, CR, LF, etc. or end-of-line comment */
-        /* (there is at least a linefeed) */
-        for( ptr = psz_ip; ( *ptr != '#' ) && !isspace( *ptr ); ptr++ );
+        /* look for first space, CR, LF, etc. or comment character */
+        for( ptr = psz_ip; ( *ptr!='#' ) && !isspace( *ptr ) && *ptr; ++ptr );
 
         *ptr = '\0';
 
+        /* skip lines without usable information */
+        if( ptr == psz_ip )
+            continue;
+
         msg_Dbg( p_acl->p_owner, "restricted to %s", psz_ip );
 
         ptr = strchr( psz_ip, '/' );




More information about the vlc-devel mailing list