Ignore:
Timestamp:
Sep 23, 2007, 11:38:39 PM (15 years ago)
Author:
charles
Message:
  • add sanity checks to incoming piece data requests. This may solve the inout.c:99 assertion failure.
  • rename the gtk client from transmission-gtk' to transmission' for parity with the mac client.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/peer-msgs.c

    r3148 r3155  
    608608
    609609static int
     610requestIsValid( const tr_peermsgs * msgs, struct peer_request * req )
     611{
     612    const tr_torrent * tor = msgs->torrent;
     613    assert( req != NULL );
     614    assert( req->index < (uint32_t)tor->info.pieceCount );
     615    assert( (int)req->offset < tr_torPieceCountBytes( tor, (int)req->index ) );
     616    assert( tr_pieceOffset( tor, req->index, req->offset, req->length ) <= tor->info.totalSize );
     617    return TRUE;
     618}
     619
     620static int
    610621readBtMessage( tr_peermsgs * msgs, struct evbuffer * inbuf )
    611622{
     
    683694            tr_peerIoReadUint32( msgs->io, inbuf, &req->offset );
    684695            tr_peerIoReadUint32( msgs->io, inbuf, &req->length );
    685             if( !msgs->info->peerIsChoked )
     696            if( !msgs->info->peerIsChoked && requestIsValid( msgs, req ) )
    686697                tr_list_append( &msgs->peerAskedFor, req );
     698            else
     699                tr_free( req );
    687700            break;
    688701        }
     
    690703        case BT_CANCEL: {
    691704            struct peer_request req;
    692             tr_list * node;
     705            void * data;
    693706            assert( msglen == 12 );
    694707            dbgmsg( msgs, "peer sent us a BT_CANCEL" );
     
    696709            tr_peerIoReadUint32( msgs->io, inbuf, &req.offset );
    697710            tr_peerIoReadUint32( msgs->io, inbuf, &req.length );
    698             node = tr_list_find( msgs->peerAskedFor, &req, peer_request_compare );
    699             if( node != NULL ) {
    700                 void * data = node->data;
    701                 tr_list_remove_data( &msgs->peerAskedFor, data );
    702                 tr_free( data );
    703                 dbgmsg( msgs, "found the req that peer is cancelling... cancelled." );
    704             }
     711            data = tr_list_remove( &msgs->peerAskedFor, &req, peer_request_compare );
     712            tr_free( data );
    705713            break;
    706714        }
Note: See TracChangeset for help on using the changeset viewer.