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.
This commit is contained in:
parent
0b6f30c847
commit
b73fc5042c
|
@ -2,7 +2,7 @@
|
|||
It is considered beerware. Prost. Skol. Cheers or whatever.
|
||||
Some of the stuff below is stolen from Fefes example libowfat httpd.
|
||||
|
||||
$Id: opentracker.c,v 1.214 2009/01/16 02:28:54 erdgeist Exp $ */
|
||||
$Id: opentracker.c,v 1.215 2009/01/16 04:17:22 erdgeist Exp $ */
|
||||
|
||||
/* System */
|
||||
#include <stdlib.h>
|
||||
|
@ -201,7 +201,7 @@ static void server_mainloop( ) {
|
|||
ws.inbuf = malloc( G_INBUF_SIZE );
|
||||
ws.outbuf = malloc( G_OUTBUF_SIZE );
|
||||
#ifdef _DEBUG_HTTPERROR
|
||||
ws.debugbuf= malloc( G_INBUF_SIZE );
|
||||
ws.debugbuf= malloc( G_DEBUGBUF_SIZE );
|
||||
#endif
|
||||
if( !ws.inbuf || !ws.outbuf )
|
||||
panic( "Initializing worker failed" );
|
||||
|
@ -523,4 +523,4 @@ while( scanon ) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
const char *g_version_opentracker_c = "$Source: /home/cvsroot/opentracker/opentracker.c,v $: $Revision: 1.214 $\n";
|
||||
const char *g_version_opentracker_c = "$Source: /home/cvsroot/opentracker/opentracker.c,v $: $Revision: 1.215 $\n";
|
||||
|
|
|
@ -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 );
|
||||
|
||||
#ifdef _DEBUG_HTTPERROR
|
||||
write( 2, ws->debugbuf, G_DEBUGBUF_SIZE );
|
||||
fprintf( stderr, "%s", ws->debugbuf );
|
||||
#endif
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
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
|
||||
{ "ip", 7 },
|
||||
#endif
|
||||
|
@ -473,4 +473,4 @@ ssize_t http_handle_request( const int64 sock, struct ot_workstruct *ws ) {
|
|||
return ws->reply_size;
|
||||
}
|
||||
|
||||
const char *g_version_http_c = "$Source: /home/cvsroot/opentracker/ot_http.c,v $: $Revision: 1.28 $\n";
|
||||
const char *g_version_http_c = "$Source: /home/cvsroot/opentracker/ot_http.c,v $: $Revision: 1.29 $\n";
|
||||
|
|
|
@ -75,7 +75,7 @@ int scan_find_keywords( const ot_keywords * keywords, char **string, SCAN_SEARCH
|
|||
if( match_length == 0 ) return -3;
|
||||
|
||||
while( keywords->key ) {
|
||||
if( !memcmp( keywords->key, deststring, match_length ) )
|
||||
if( !memcmp( keywords->key, deststring, match_length ) && !keywords->key[match_length] )
|
||||
return keywords->value;
|
||||
keywords++;
|
||||
}
|
||||
|
@ -140,4 +140,4 @@ ssize_t scan_fixed_int( char *data, size_t len, int *tmp ) {
|
|||
return len;
|
||||
}
|
||||
|
||||
const char *g_version_scan_urlencoded_query_c = "$Source: /home/cvsroot/opentracker/scan_urlencoded_query.c,v $: $Revision: 1.31 $\n";
|
||||
const char *g_version_scan_urlencoded_query_c = "$Source: /home/cvsroot/opentracker/scan_urlencoded_query.c,v $: $Revision: 1.32 $\n";
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
*peer_dest = *peer;
|
||||
memcpy( peer_dest, peer, sizeof(ot_peer) );
|
||||
#ifdef WANT_SYNC
|
||||
if( proto == FLAG_MCA ) {
|
||||
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;
|
||||
size_t peer_count = bucket_list[bucket].size;
|
||||
while( peer_count-- ) {
|
||||
memcpy(r,peers,OT_PEER_COMPARE_SIZE);
|
||||
peers+=sizeof(ot_peer);
|
||||
memcpy(r,peers++,OT_PEER_COMPARE_SIZE);
|
||||
r+=OT_PEER_COMPARE_SIZE;
|
||||
}
|
||||
}
|
||||
|
@ -384,4 +383,4 @@ void trackerlogic_deinit( void ) {
|
|||
mutex_deinit( );
|
||||
}
|
||||
|
||||
const char *g_version_trackerlogic_c = "$Source: /home/cvsroot/opentracker/trackerlogic.c,v $: $Revision: 1.122 $\n";
|
||||
const char *g_version_trackerlogic_c = "$Source: /home/cvsroot/opentracker/trackerlogic.c,v $: $Revision: 1.123 $\n";
|
||||
|
|
Loading…
Reference in New Issue