Browse Source

Fix a pointer arithmetic issue leading to incorrect peer data being copied. Allocate correct size for debugbuffer. Expect exact values on find keywords, not only prefix match.

dynamic-accesslists
erdgeist 16 years ago
parent
commit
2d3718151d
  1. 2
      opentracker.c
  2. 4
      ot_http.c
  3. 2
      scan_urlencoded_query.c
  4. 5
      trackerlogic.c

2
opentracker.c

@ -201,7 +201,7 @@ static void server_mainloop( ) {
ws.inbuf = malloc( G_INBUF_SIZE ); ws.inbuf = malloc( G_INBUF_SIZE );
ws.outbuf = malloc( G_OUTBUF_SIZE ); ws.outbuf = malloc( G_OUTBUF_SIZE );
#ifdef _DEBUG_HTTPERROR #ifdef _DEBUG_HTTPERROR
ws.debugbuf= malloc( G_INBUF_SIZE ); ws.debugbuf= malloc( G_DEBUGBUF_SIZE );
#endif #endif
if( !ws.inbuf || !ws.outbuf ) if( !ws.inbuf || !ws.outbuf )
panic( "Initializing worker failed" ); panic( "Initializing worker failed" );

4
ot_http.c

@ -247,7 +247,7 @@ static ssize_t http_handle_fullscrape( const int64 sock, struct ot_workstruct *w
stats_issue_event( EVENT_FULLSCRAPE_REQUEST, 0, (uintptr_t)cookie->ip ); stats_issue_event( EVENT_FULLSCRAPE_REQUEST, 0, (uintptr_t)cookie->ip );
#ifdef _DEBUG_HTTPERROR #ifdef _DEBUG_HTTPERROR
write( 2, ws->debugbuf, G_DEBUGBUF_SIZE ); fprintf( stderr, "%s", ws->debugbuf );
#endif #endif
/* Pass this task to the worker thread */ /* Pass this task to the worker thread */
@ -299,7 +299,7 @@ static ssize_t http_handle_scrape( const int64 sock, struct ot_workstruct *ws, c
return ws->reply_size; return ws->reply_size;
} }
static ot_keywords keywords_announce[] = { { "port", 1 }, { "left", 2 }, { "event", 3 }, { "numwant", 4 }, { "compact", 5 }, { "info_hash", 6 }, static ot_keywords keywords_announce[] = { { "port", 1 }, { "left", 2 }, { "event", 3 }, { "numwant", 4 }, { "compact", 5 }, { "compact6", 5 }, { "info_hash", 6 },
#ifdef WANT_IP_FROM_QUERY_STRING #ifdef WANT_IP_FROM_QUERY_STRING
{ "ip", 7 }, { "ip", 7 },
#endif #endif

2
scan_urlencoded_query.c

@ -75,7 +75,7 @@ int scan_find_keywords( const ot_keywords * keywords, char **string, SCAN_SEARCH
if( match_length == 0 ) return -3; if( match_length == 0 ) return -3;
while( keywords->key ) { while( keywords->key ) {
if( !memcmp( keywords->key, deststring, match_length ) ) if( !memcmp( keywords->key, deststring, match_length ) && !keywords->key[match_length] )
return keywords->value; return keywords->value;
keywords++; keywords++;
} }

5
trackerlogic.c

@ -129,7 +129,7 @@ size_t add_peer_to_torrent_and_return_peers( ot_hash hash, ot_peer *peer, PROTO_
OT_PEERFLAG( peer ) |= PEER_FLAG_COMPLETED; OT_PEERFLAG( peer ) |= PEER_FLAG_COMPLETED;
} }
*peer_dest = *peer; memcpy( peer_dest, peer, sizeof(ot_peer) );
#ifdef WANT_SYNC #ifdef WANT_SYNC
if( proto == FLAG_MCA ) { if( proto == FLAG_MCA ) {
mutex_bucket_unlock_by_hash( hash, delta_torrentcount ); mutex_bucket_unlock_by_hash( hash, delta_torrentcount );
@ -156,8 +156,7 @@ static size_t return_peers_all( ot_peerlist *peer_list, char *reply ) {
ot_peer * peers = (ot_peer*)bucket_list[bucket].data; ot_peer * peers = (ot_peer*)bucket_list[bucket].data;
size_t peer_count = bucket_list[bucket].size; size_t peer_count = bucket_list[bucket].size;
while( peer_count-- ) { while( peer_count-- ) {
memcpy(r,peers,OT_PEER_COMPARE_SIZE); memcpy(r,peers++,OT_PEER_COMPARE_SIZE);
peers+=sizeof(ot_peer);
r+=OT_PEER_COMPARE_SIZE; r+=OT_PEER_COMPARE_SIZE;
} }
} }

Loading…
Cancel
Save