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/peerparse.h

    r1442 r1534  
    105105    if( !peer->bitfield )
    106106    {
    107         peer->bitfield = calloc( ( tor->info.pieceCount + 7 ) / 8, 1 );
     107        peer->bitfield = tr_bitfieldNew( tor->info.pieceCount );
    108108    }
    109109    if( !tr_bitfieldHas( peer->bitfield, piece ) )
     
    155155    if( !peer->bitfield )
    156156    {
    157         peer->bitfield = malloc( bitfieldSize );
    158     }
    159     memcpy( peer->bitfield, p, bitfieldSize );
     157        peer->bitfield = tr_bitfieldNew( inf->pieceCount );
     158    }
     159    assert( bitfieldSize == peer->bitfield->len );
     160    memcpy( peer->bitfield->bits, p, bitfieldSize );
    160161
    161162    peer->pieceCount = 0;
     
    295296    if( !peer->blamefield )
    296297    {
    297         peer->blamefield = calloc( ( tor->info.pieceCount + 7 ) / 8, 1 );
     298        peer->blamefield = tr_bitfieldNew( tor->info.pieceCount );
    298299    }
    299300    tr_bitfieldAdd( peer->blamefield, index );
Note: See TracChangeset for help on using the changeset viewer.