Apply some limits

dynamic-accesslists
erdgeist 18 years ago
parent e7532408b6
commit 17c21a0bc4

@ -233,6 +233,7 @@ e400:
if(!byte_diff(data,7,"numwant")) { if(!byte_diff(data,7,"numwant")) {
size_t len = scan_urlencoded_query( &c, data = c, SCAN_SEARCHPATH_VALUE ); size_t len = scan_urlencoded_query( &c, data = c, SCAN_SEARCHPATH_VALUE );
if( ( len <= 0 ) || scan_fixed_int( data, len, &numwant ) ) goto e404; if( ( len <= 0 ) || scan_fixed_int( data, len, &numwant ) ) goto e404;
if( numwant > 200 ) numwant = 200;
} else if(!byte_diff(data,7,"compact")) { } else if(!byte_diff(data,7,"compact")) {
size_t len = scan_urlencoded_query( &c, data = c, SCAN_SEARCHPATH_VALUE ); size_t len = scan_urlencoded_query( &c, data = c, SCAN_SEARCHPATH_VALUE );
if( ( len <= 0 ) || scan_fixed_int( data, len, &tmp ) ) goto e404; if( ( len <= 0 ) || scan_fixed_int( data, len, &tmp ) ) goto e404;

@ -246,7 +246,7 @@ size_t return_peers_for_torrent( ot_torrent *torrent, unsigned long amount, char
} }
if( peer_count < amount ) amount = peer_count; if( peer_count < amount ) amount = peer_count;
r += FORMAT_FORMAT_STRING( r, "d8:completei%lie10:incompletei%lie8:intervali60e5:peers%li:", seed_count, peer_count-seed_count, 6*amount ); r += FORMAT_FORMAT_STRING( r, "d8:completei%lie10:incompletei%lie8:intervali600e5:peers%li:", seed_count, peer_count-seed_count, 6*amount );
for( index = 0; index < amount; ++index ) { for( index = 0; index < amount; ++index ) {
double step = 1.8*((double)( peer_count - wert - 1 ))/((double)( amount - index )); double step = 1.8*((double)( peer_count - wert - 1 ))/((double)( amount - index ));
int off = random() % (int)floor( step ); int off = random() % (int)floor( step );

Loading…
Cancel
Save