diff options
author | erdgeist <> | 2007-10-21 04:13:53 +0000 |
---|---|---|
committer | erdgeist <> | 2007-10-21 04:13:53 +0000 |
commit | 886421d2d5c94c93204c6fc47e90ade492b6e114 (patch) | |
tree | bf82869d96bde67c6a9e219cddec1ab04266b109 | |
parent | 2b715b89f12de4c2ea11b23af6d9fd51b54a956c (diff) |
Work around more typos that might end up in torrent files as announce urls
-rw-r--r-- | opentracker.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/opentracker.c b/opentracker.c index bfb5c53..d916aa7 100644 --- a/opentracker.c +++ b/opentracker.c | |||
@@ -390,13 +390,14 @@ write( 2, debug_request, l ); | |||
390 | return sendmmapdata( s, reply, reply_size ); | 390 | return sendmmapdata( s, reply, reply_size ); |
391 | } | 391 | } |
392 | 392 | ||
393 | /* This is to hack around stupid clients that just replace | ||
394 | "announce ?info_hash" with "scrape ?info_hash". | ||
395 | We do not want to bomb them with full scrapes */ | ||
396 | if( !byte_diff( c, 2, " ?" ) ) c+=2; | ||
397 | |||
398 | SCRAPE_WORKAROUND: | 393 | SCRAPE_WORKAROUND: |
399 | 394 | ||
395 | /* This is to hack around stupid clients that send "announce ?info_hash" */ | ||
396 | if( c[-1] != '?' ) { | ||
397 | while( ( *c != '?' ) && ( *c != '\n' ) ) ++c; | ||
398 | if( *c == '\n' ) HTTPERROR_400_PARAM; | ||
399 | } | ||
400 | |||
400 | scanon = 1; | 401 | scanon = 1; |
401 | scrape_count = 0; | 402 | scrape_count = 0; |
402 | while( scanon ) { | 403 | while( scanon ) { |
@@ -429,15 +430,19 @@ SCRAPE_WORKAROUND: | |||
429 | * A N N O U N C E * | 430 | * A N N O U N C E * |
430 | ******************************/ | 431 | ******************************/ |
431 | case 7: | 432 | case 7: |
432 | if( byte_diff( data, 7, "announc" ) ) HTTPERROR_404; | 433 | if( !byte_diff( data, 7, "announc" ) ) goto ANNOUNCE_WORKAROUND; |
433 | goto ANNOUNCE_WORKAROUND; | 434 | if( !byte_diff( data, 7, "anounce" ) ) goto ANNOUNCE_WORKAROUND; |
435 | HTTPERROR_404; | ||
434 | case 8: | 436 | case 8: |
435 | if( byte_diff( data, 8, "announce" ) ) HTTPERROR_404; | 437 | if( byte_diff( data, 8, "announce" ) ) HTTPERROR_404; |
436 | 438 | ||
437 | ANNOUNCE_WORKAROUND: | 439 | ANNOUNCE_WORKAROUND: |
438 | 440 | ||
439 | /* This is to hack around stupid clients that send "announce ?info_hash" */ | 441 | /* This is to hack around stupid clients that send "announce ?info_hash" */ |
440 | if( !byte_diff( c+1, 5, "?info" ) ) c+=2; | 442 | if( c[-1] != '?' ) { |
443 | while( ( *c != '?' ) && ( *c != '\n' ) ) ++c; | ||
444 | if( *c == '\n' ) HTTPERROR_400_PARAM; | ||
445 | } | ||
441 | 446 | ||
442 | OT_SETIP( &peer, ((struct http_data*)io_getcookie( s ) )->ip ); | 447 | OT_SETIP( &peer, ((struct http_data*)io_getcookie( s ) )->ip ); |
443 | OT_SETPORT( &peer, &port ); | 448 | OT_SETPORT( &peer, &port ); |
@@ -525,6 +530,9 @@ ANNOUNCE_WORKAROUND: | |||
525 | } | 530 | } |
526 | ot_overall_tcp_successfulannounces++; | 531 | ot_overall_tcp_successfulannounces++; |
527 | break; | 532 | break; |
533 | case 9: | ||
534 | if( byte_diff( data, 9, "announce " ) ) HTTPERROR_404; | ||
535 | goto ANNOUNCE_WORKAROUND; | ||
528 | case 10: | 536 | case 10: |
529 | if( byte_diff( data, 10, "scrape.php" ) ) HTTPERROR_404; | 537 | if( byte_diff( data, 10, "scrape.php" ) ) HTTPERROR_404; |
530 | goto SCRAPE_WORKAROUND; | 538 | goto SCRAPE_WORKAROUND; |