diff options
-rw-r--r-- | proxy.c | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -412,7 +412,7 @@ close_socket: | |||
412 | static void handle_write( int64 peersocket ) { | 412 | static void handle_write( int64 peersocket ) { |
413 | proxy_peer *peer = io_getcookie( peersocket ); | 413 | proxy_peer *peer = io_getcookie( peersocket ); |
414 | 414 | ||
415 | if( !peer ) { | 415 | if( !peer ) { |
416 | /* Can't happen ;) */ | 416 | /* Can't happen ;) */ |
417 | io_close( peersocket ); | 417 | io_close( peersocket ); |
418 | return; | 418 | return; |
@@ -672,7 +672,7 @@ static void * streamsync_worker( void * args ) { | |||
672 | } | 672 | } |
673 | 673 | ||
674 | /* Copy tail of info_hash, advance pointer */ | 674 | /* Copy tail of info_hash, advance pointer */ |
675 | memcpy( *dst, torrent->hash + 1, sizeof( ot_hash ) - 1); | 675 | memcpy( *dst, ((uint8_t*)torrent->hash) + 1, sizeof( ot_hash ) - 1); |
676 | *dst += sizeof( ot_hash ) - 1; | 676 | *dst += sizeof( ot_hash ) - 1; |
677 | 677 | ||
678 | /* Encode peer count */ | 678 | /* Encode peer count */ |
@@ -764,7 +764,7 @@ static void livesync_proxytell( uint8_t prefix, uint8_t *info_hash, uint8_t *pee | |||
764 | } | 764 | } |
765 | 765 | ||
766 | static void process_indata( proxy_peer * peer ) { | 766 | static void process_indata( proxy_peer * peer ) { |
767 | int consumed, peers; | 767 | size_t consumed, peers; |
768 | uint8_t *data = peer->indata, *hash; | 768 | uint8_t *data = peer->indata, *hash; |
769 | uint8_t *dataend = data + peer->indata_length; | 769 | uint8_t *dataend = data + peer->indata_length; |
770 | 770 | ||
@@ -782,7 +782,7 @@ printf( "type: %hhu, prefix: %02X, torrentcount: %zd\n", peer->packet_type, peer | |||
782 | } | 782 | } |
783 | 783 | ||
784 | next_torrent: | 784 | next_torrent: |
785 | /* Ensure size for the complete torrent block */ | 785 | /* Ensure size for a minimal torrent block */ |
786 | if( data + sizeof(ot_hash) + OT_IP_SIZE + 3 > dataend ) break; | 786 | if( data + sizeof(ot_hash) + OT_IP_SIZE + 3 > dataend ) break; |
787 | 787 | ||
788 | /* Advance pointer to peer count or peers */ | 788 | /* Advance pointer to peer count or peers */ |
@@ -798,9 +798,9 @@ next_torrent: | |||
798 | } | 798 | } |
799 | 799 | ||
800 | /* Ensure enough data being read to hold all peers */ | 800 | /* Ensure enough data being read to hold all peers */ |
801 | if( data + 7 * peers > dataend ) break; | 801 | if( data + (OT_IP_SIZE + 3) * peers > dataend ) break; |
802 | 802 | ||
803 | printf( "peers: %d\n", peers ); | 803 | printf( "peers: %zd\n", peers ); |
804 | 804 | ||
805 | while( peers-- ) { | 805 | while( peers-- ) { |
806 | livesync_proxytell( peer->packet_tprefix, hash, data ); | 806 | livesync_proxytell( peer->packet_tprefix, hash, data ); |