diff options
| -rw-r--r-- | ot_accesslist.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/ot_accesslist.c b/ot_accesslist.c index 4df7edb..85dd27a 100644 --- a/ot_accesslist.c +++ b/ot_accesslist.c | |||
| @@ -53,26 +53,29 @@ static void accesslist_readfile( void ) { | |||
| 53 | fprintf( stderr, "Warning: Not enough memory to allocate %zd bytes for accesslist buffer. May succeed later.\n", ( maplen / 41 ) * 20 ); | 53 | fprintf( stderr, "Warning: Not enough memory to allocate %zd bytes for accesslist buffer. May succeed later.\n", ( maplen / 41 ) * 20 ); |
| 54 | return; | 54 | return; |
| 55 | } | 55 | } |
| 56 | 56 | ||
| 57 | /* No use to scan if there's not enough room for another full info_hash */ | 57 | /* No use to scan if there's not enough room for another full info_hash */ |
| 58 | map_end = map + maplen - 40; | 58 | map_end = map + maplen - 40; |
| 59 | read_offs = map; | 59 | read_offs = map; |
| 60 | 60 | ||
| 61 | /* We do ignore anything that is not of the form "^[:xdigit:]{40}[^:xdigit:].*" */ | 61 | /* We do ignore anything that is not of the form "^[:xdigit:]{40}[^:xdigit:].*" */ |
| 62 | while( read_offs < map_end ) { | 62 | while( read_offs + 40 <= map_end ) { |
| 63 | int i; | 63 | int i; |
| 64 | for( i=0; i<(int)sizeof(ot_hash); ++i ) { | 64 | for( i=0; i<(int)sizeof(ot_hash); ++i ) { |
| 65 | int eger = 16 * scan_fromhex( read_offs[ 2*i ] ) + scan_fromhex( read_offs[ 1 + 2*i ] ); | 65 | int eger1 = scan_fromhex( read_offs[ 2*i ] ); |
| 66 | if( eger < 0 ) | 66 | int eger2 = scan_fromhex( read_offs[ 1 + 2*i ] ); |
| 67 | continue; | 67 | if( eger1 < 0 || eger2 < 0 ) |
| 68 | (*info_hash)[i] = eger; | 68 | break; |
| 69 | (*info_hash)[i] = eger1 * 16 + eger2; | ||
| 69 | } | 70 | } |
| 70 | 71 | ||
| 71 | read_offs += 40; | 72 | if( i == sizeof(ot_hash) ) { |
| 73 | read_offs += 40; | ||
| 72 | 74 | ||
| 73 | /* Append accesslist to accesslist vector */ | 75 | /* Append accesslist to accesslist vector */ |
| 74 | if( scan_fromhex( *read_offs ) < 0 ) | 76 | if( read_offs == map_end || scan_fromhex( *read_offs ) < 0 ) |
| 75 | ++info_hash; | 77 | ++info_hash; |
| 78 | } | ||
| 76 | 79 | ||
| 77 | /* Find start of next line */ | 80 | /* Find start of next line */ |
| 78 | while( read_offs < map_end && *(read_offs++) != '\n' ); | 81 | while( read_offs < map_end && *(read_offs++) != '\n' ); |
