mirror of
git://erdgeist.org/opentracker
synced 2025-01-15 01:12:07 +00:00
Looking into pointer arithmetics issue
This commit is contained in:
parent
9cfab8dbc6
commit
4fe2f35595
12
proxy.c
12
proxy.c
@ -412,7 +412,7 @@ close_socket:
|
|||||||
static void handle_write( int64 peersocket ) {
|
static void handle_write( int64 peersocket ) {
|
||||||
proxy_peer *peer = io_getcookie( peersocket );
|
proxy_peer *peer = io_getcookie( peersocket );
|
||||||
|
|
||||||
if( !peer ) {
|
if( !peer ) {
|
||||||
/* Can't happen ;) */
|
/* Can't happen ;) */
|
||||||
io_close( peersocket );
|
io_close( peersocket );
|
||||||
return;
|
return;
|
||||||
@ -672,7 +672,7 @@ static void * streamsync_worker( void * args ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Copy tail of info_hash, advance pointer */
|
/* Copy tail of info_hash, advance pointer */
|
||||||
memcpy( *dst, torrent->hash + 1, sizeof( ot_hash ) - 1);
|
memcpy( *dst, ((uint8_t*)torrent->hash) + 1, sizeof( ot_hash ) - 1);
|
||||||
*dst += sizeof( ot_hash ) - 1;
|
*dst += sizeof( ot_hash ) - 1;
|
||||||
|
|
||||||
/* Encode peer count */
|
/* Encode peer count */
|
||||||
@ -764,7 +764,7 @@ static void livesync_proxytell( uint8_t prefix, uint8_t *info_hash, uint8_t *pee
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void process_indata( proxy_peer * peer ) {
|
static void process_indata( proxy_peer * peer ) {
|
||||||
int consumed, peers;
|
size_t consumed, peers;
|
||||||
uint8_t *data = peer->indata, *hash;
|
uint8_t *data = peer->indata, *hash;
|
||||||
uint8_t *dataend = data + peer->indata_length;
|
uint8_t *dataend = data + peer->indata_length;
|
||||||
|
|
||||||
@ -782,7 +782,7 @@ printf( "type: %hhu, prefix: %02X, torrentcount: %zd\n", peer->packet_type, peer
|
|||||||
}
|
}
|
||||||
|
|
||||||
next_torrent:
|
next_torrent:
|
||||||
/* Ensure size for the complete torrent block */
|
/* Ensure size for a minimal torrent block */
|
||||||
if( data + sizeof(ot_hash) + OT_IP_SIZE + 3 > dataend ) break;
|
if( data + sizeof(ot_hash) + OT_IP_SIZE + 3 > dataend ) break;
|
||||||
|
|
||||||
/* Advance pointer to peer count or peers */
|
/* Advance pointer to peer count or peers */
|
||||||
@ -798,9 +798,9 @@ next_torrent:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Ensure enough data being read to hold all peers */
|
/* Ensure enough data being read to hold all peers */
|
||||||
if( data + 7 * peers > dataend ) break;
|
if( data + (OT_IP_SIZE + 3) * peers > dataend ) break;
|
||||||
|
|
||||||
printf( "peers: %d\n", peers );
|
printf( "peers: %zd\n", peers );
|
||||||
|
|
||||||
while( peers-- ) {
|
while( peers-- ) {
|
||||||
livesync_proxytell( peer->packet_tprefix, hash, data );
|
livesync_proxytell( peer->packet_tprefix, hash, data );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user