Changeset 3155


Ignore:
Timestamp:
Sep 23, 2007, 11:38:39 PM (14 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.
Location:
trunk
Files:
4 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/gtk/Makefile.am

    r3154 r3155  
    2727    util.h
    2828
    29 bin_PROGRAMS = transmission-gtk
     29bin_PROGRAMS = transmission
    3030
    31 transmission_gtk_SOURCES = \
     31transmission_SOURCES = \
    3232    actions.c \
    3333    conf.c \
     
    4848    util.c
    4949
    50 transmission_gtk_LDADD = \
     50transmission_LDADD = \
    5151    $(top_builddir)/libtransmission/libtransmission.a \
    5252    $(top_builddir)/third-party/libevent/libevent.la \
  • trunk/gtk/transmission.desktop

    r3152 r3155  
    1414Comment[ru]=СвПбПЎМый, легкПвесМый BitTorrent клОеМт с прПстыЌ, ОМтуОтОвМыЌ ОМтерфейсПЌ
    1515Comment[sv]=En fri, lÀttviktig BitTorrent-klient med ett enkelt och intuitivt grÀnssnitt
    16 Exec=transmission-gtk %F
    17 TryExec=transmission-gtk
     16Exec=transmission %F
     17TryExec=transmission
    1818Icon=transmission.png
    1919MimeType=application/x-bittorrent;
  • trunk/libtransmission/internal.h

    r3147 r3155  
    9191int _tr_block( const tr_torrent * tor, int index, int begin );
    9292
     93uint64_t tr_pieceOffset( const tr_torrent * tor, int index, int begin, int length );
    9394
    9495typedef enum
  • 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        }
  • trunk/libtransmission/torrent.c

    r3152 r3155  
    12831283        begin / tor->blockSize;
    12841284}
     1285
     1286uint64_t
     1287tr_pieceOffset( const tr_torrent * tor, int index, int begin, int length )
     1288{
     1289    uint64_t ret;
     1290    ret = tor->info.pieceSize;
     1291    ret *= index;
     1292    ret += begin;
     1293    ret += length;
     1294    return ret;
     1295}
     1296
Note: See TracChangeset for help on using the changeset viewer.