X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fnetwork%2Facl.c;h=f10ec64152e87ec3a959825cd497a865a828d00a;hb=fa343f78a532b2cfe62c7ec456176fb77e1223b8;hp=89c33353c721792c9141d7f2ef47106a596cb74d;hpb=8821427110a1d353ed27eaef577a2057923f46a1;p=vlc diff --git a/src/network/acl.c b/src/network/acl.c index 89c33353c7..f10ec64152 100644 --- a/src/network/acl.c +++ b/src/network/acl.c @@ -33,10 +33,8 @@ #include #include -#include - #include -#include +#include /* FIXME: rwlock on acl, but libvlc doesn't implement rwlock */ typedef struct vlc_acl_entry_t @@ -201,7 +199,7 @@ int ACL_AddNet( vlc_acl_t *p_acl, const char *psz_ip, int i_len, return 0; } - +#undef ACL_Create /** * Creates an empty ACL. * @@ -210,7 +208,7 @@ int ACL_AddNet( vlc_acl_t *p_acl, const char *psz_ip, int i_len, * * @return an ACL object. NULL in case of error. */ -vlc_acl_t *__ACL_Create( vlc_object_t *p_this, bool b_allow ) +vlc_acl_t *ACL_Create( vlc_object_t *p_this, bool b_allow ) { vlc_acl_t *p_acl; @@ -227,7 +225,7 @@ vlc_acl_t *__ACL_Create( vlc_object_t *p_this, bool b_allow ) return p_acl; } - +#undef ACL_Duplicate /** * Perform a deep copy of an existing ACL. * @@ -236,7 +234,7 @@ vlc_acl_t *__ACL_Create( vlc_object_t *p_this, bool b_allow ) * * @return a new ACL object, or NULL on error. */ -vlc_acl_t *__ACL_Duplicate( vlc_object_t *p_this, const vlc_acl_t *p_acl ) +vlc_acl_t *ACL_Duplicate( vlc_object_t *p_this, const vlc_acl_t *p_acl ) { vlc_acl_t *p_dupacl; @@ -302,7 +300,7 @@ int ACL_LoadFile( vlc_acl_t *p_acl, const char *psz_path ) if( p_acl == NULL ) return -1; - file = utf8_fopen( psz_path, "r" ); + file = vlc_fopen( psz_path, "r" ); if( file == NULL ) return -1; @@ -333,7 +331,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 +352,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, '/' );