From: JP Dinger Date: Tue, 8 Sep 2009 08:52:26 +0000 (+0200) Subject: Add support for last lines without newline in .hosts (untested). X-Git-Tag: 1.1.0-ff~3449 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=a4f7a49fdcbcaed4709b84a768afcd81b93a776f;p=vlc Add support for last lines without newline in .hosts (untested). --- diff --git a/src/network/acl.c b/src/network/acl.c index 89c33353c7..ee98e3b48b 100644 --- a/src/network/acl.c +++ b/src/network/acl.c @@ -333,7 +333,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); @@ -354,16 +354,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, '/' );