summaryrefslogtreecommitdiff
path: root/proxy.c
diff options
context:
space:
mode:
authorerdgeist <>2010-08-14 15:22:20 +0000
committererdgeist <>2010-08-14 15:22:20 +0000
commit4fe2f355950d0bc810e665a68ded157531c6a367 (patch)
treeaf46c911bd46232b0802ad1cbff42fce4861539d /proxy.c
parent9cfab8dbc6457d5eb5ead9c3a494b03a4cb6143c (diff)
Looking into pointer arithmetics issue
Diffstat (limited to 'proxy.c')
-rw-r--r--proxy.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/proxy.c b/proxy.c
index 9a143ed..6e39de7 100644
--- a/proxy.c
+++ b/proxy.c
@@ -412,7 +412,7 @@ close_socket:
412static void handle_write( int64 peersocket ) { 412static 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
766static void process_indata( proxy_peer * peer ) { 766static 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
784next_torrent: 784next_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
803printf( "peers: %d\n", peers ); 803printf( "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 );