Changeset 10604


Ignore:
Timestamp:
May 1, 2010, 3:00:17 PM (8 years ago)
Author:
livings124
Message:

(1.9x) #3041 blocklist should not try to add invalid lines to the blocklist, and should not print those invalid lines to the message queue

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/1.9x/libtransmission/blocklist.c

    r9868 r10604  
    1212
    1313#include <stdio.h>
    14 #include <stdlib.h> /* free */
     14#include <stdlib.h> /* free() */
    1515#include <string.h>
    1616
     
    235235    FILE *       out;
    236236    char *       line;
    237     int          lineCount = 0;
     237    int          inCount = 0;
     238    int          outCount = 0;
    238239    const char * err_fmt = _( "Couldn't read \"%1$s\": %2$s" );
    239240
     
    269270        struct tr_ip_range range;
    270271
     272        ++inCount;
     273
    271274        rangeBegin = strrchr( line, ':' );
    272275        if( !rangeBegin ){ free( line ); continue; }
     
    280283
    281284        if( !tr_pton( rangeBegin, &addr ) )
    282             tr_err( "blocklist skipped invalid address [%s]\n", rangeBegin );
     285        {
     286            tr_err( _( "blocklist skipped invalid address at line %d" ), inCount );
     287            free( line );
     288            continue;
     289        }
    283290        range.begin = ntohl( addr.addr.addr4.s_addr );
    284291
    285292        if( !tr_pton( rangeEnd, &addr ) )
    286             tr_err( "blocklist skipped invalid address [%s]\n", rangeEnd );
     293        {
     294            tr_err( _( "blocklist skipped invalid address at line %d" ), inCount );
     295            free( line );
     296            continue;
     297        }
    287298        range.end = ntohl( addr.addr.addr4.s_addr );
    288299
     
    297308        }
    298309
    299         ++lineCount;
     310        ++outCount;
    300311    }
    301312
    302313    {
    303314        char * base = tr_basename( b->filename );
    304         tr_inf( _( "Blocklist \"%1$s\" updated with %2$'d entries" ), base, lineCount );
     315        tr_inf( _( "Blocklist \"%1$s\" updated with %2$'d entries" ), base, outCount );
    305316        tr_free( base );
    306317    }
    307 
    308318
    309319    fclose( out );
     
    312322    blocklistLoad( b );
    313323
    314     return lineCount;
    315 }
    316 
     324    return outCount;
     325}
     326
Note: See TracChangeset for help on using the changeset viewer.