Make whitelist parser more robust against comments. I assumed perfectly arranged white lists until now

dynamic-accesslists
erdgeist 15 years ago
parent d42bf5a031
commit 3636be6cc7

@ -59,20 +59,23 @@ static void accesslist_readfile( void ) {
read_offs = map; read_offs = map;
/* We do ignore anything that is not of the form "^[:xdigit:]{40}[^:xdigit:].*" */ /* We do ignore anything that is not of the form "^[:xdigit:]{40}[^:xdigit:].*" */
while( read_offs < map_end ) { while( read_offs + 40 <= map_end ) {
int i; int i;
for( i=0; i<(int)sizeof(ot_hash); ++i ) { for( i=0; i<(int)sizeof(ot_hash); ++i ) {
int eger = 16 * scan_fromhex( read_offs[ 2*i ] ) + scan_fromhex( read_offs[ 1 + 2*i ] ); int eger1 = scan_fromhex( read_offs[ 2*i ] );
if( eger < 0 ) int eger2 = scan_fromhex( read_offs[ 1 + 2*i ] );
continue; if( eger1 < 0 || eger2 < 0 )
(*info_hash)[i] = eger; break;
(*info_hash)[i] = eger1 * 16 + eger2;
} }
read_offs += 40; if( i == sizeof(ot_hash) ) {
read_offs += 40;
/* Append accesslist to accesslist vector */ /* Append accesslist to accesslist vector */
if( scan_fromhex( *read_offs ) < 0 ) if( read_offs == map_end || scan_fromhex( *read_offs ) < 0 )
++info_hash; ++info_hash;
}
/* Find start of next line */ /* Find start of next line */
while( read_offs < map_end && *(read_offs++) != '\n' ); while( read_offs < map_end && *(read_offs++) != '\n' );

Loading…
Cancel
Save