Ignore:
Timestamp:
Mar 5, 2007, 11:03:38 PM (15 years ago)
Author:
joshe
Message:

Do bounds checking on bitfields.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/peerutils.h

    r1425 r1534  
    105105static int isInteresting( tr_torrent_t * tor, tr_peer_t * peer )
    106106{
    107     tr_info_t * inf = &tor->info;
    108 
    109     int i;
    110     int bitfieldSize = ( inf->pieceCount + 7 ) / 8;
    111     uint8_t * bitfield = tr_cpPieceBitfield( tor->completion );
     107    int ii;
     108    tr_bitfield_t * bitfield = tr_cpPieceBitfield( tor->completion );
    112109
    113110    if( !peer->bitfield )
     
    117114    }
    118115
    119     for( i = 0; i < bitfieldSize; i++ )
    120     {
    121         if( ( peer->bitfield[i] & ~(bitfield[i]) ) & 0xFF )
     116    assert( bitfield->len == peer->bitfield->len );
     117    for( ii = 0; ii < bitfield->len; ii++ )
     118    {
     119        if( ( peer->bitfield->bits[ii] & ~(bitfield->bits[ii]) ) & 0xFF )
    122120        {
    123121            return 1;
     
    198196        /* All pieces in 'pool' have 'minMissing' missing blocks. Find
    199197           the rarest ones. */
    200         uint8_t * bitfield;
     198        tr_bitfield_t * bitfield;
    201199        int piece;
    202200        int min, foo, j;
Note: See TracChangeset for help on using the changeset viewer.