diff options
author | erdgeist <> | 2007-10-19 21:00:57 +0000 |
---|---|---|
committer | erdgeist <> | 2007-10-19 21:00:57 +0000 |
commit | d5876ebb6b7f238411fc6dcab8d9637650c8727f (patch) | |
tree | 58f3d7a7f9503ea6a44950693046ac435a8b09b8 /opentracker.c | |
parent | 271ff156ecfd7a7638d694a71d3eb9e4b87b2dcb (diff) |
Prevent url-decoding for debug by using a temp buffer
Diffstat (limited to 'opentracker.c')
-rw-r--r-- | opentracker.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/opentracker.c b/opentracker.c index 1725cd2..81f5daa 100644 --- a/opentracker.c +++ b/opentracker.c | |||
@@ -59,6 +59,7 @@ static char *accesslist_filename = NULL; | |||
59 | 59 | ||
60 | static char static_inbuf[8192]; | 60 | static char static_inbuf[8192]; |
61 | static char static_outbuf[8192]; | 61 | static char static_outbuf[8192]; |
62 | static char static_tmpbuf[8192]; | ||
62 | 63 | ||
63 | static char *FLAG_TCP = "TCP"; | 64 | static char *FLAG_TCP = "TCP"; |
64 | static char *FLAG_UDP = "UDP"; | 65 | static char *FLAG_UDP = "UDP"; |
@@ -372,6 +373,9 @@ LOG_TO_STDERR( "stats: %d.%d.%d.%d - mode: s24s old\n", h->ip[0], h->ip[1], h->i | |||
372 | case 6: /* scrape ? */ | 373 | case 6: /* scrape ? */ |
373 | if( byte_diff( data, 6, "scrape") ) HTTPERROR_404; | 374 | if( byte_diff( data, 6, "scrape") ) HTTPERROR_404; |
374 | 375 | ||
376 | /* We want the pure plain un-unescaped text */ | ||
377 | memmove( static_tmpbuf, static_inbuf, 8192 ); | ||
378 | |||
375 | /* This is to hack around stupid clients that just replace | 379 | /* This is to hack around stupid clients that just replace |
376 | "announce ?info_hash" with "scrape ?info_hash". | 380 | "announce ?info_hash" with "scrape ?info_hash". |
377 | We do not want to bomb them with full scrapes */ | 381 | We do not want to bomb them with full scrapes */ |
@@ -400,9 +404,8 @@ SCRAPE_WORKAROUND: | |||
400 | /* Scanned whole query string, no hash means full scrape... you might want to limit that */ | 404 | /* Scanned whole query string, no hash means full scrape... you might want to limit that */ |
401 | if( !hash ) { | 405 | if( !hash ) { |
402 | LOG_TO_STDERR( "scrp: %d.%d.%d.%d - FULL SCRAPE\n", h->ip[0], h->ip[1], h->ip[2], h->ip[3] ); | 406 | LOG_TO_STDERR( "scrp: %d.%d.%d.%d - FULL SCRAPE\n", h->ip[0], h->ip[1], h->ip[2], h->ip[3] ); |
403 | LOG_TO_STDERR( "GET /scrape" ); | 407 | write( 2, static_tmpbuf, l ); |
404 | write( 2, data, l-12 ); | 408 | write( 2, "\n\n\n", 1 ); |
405 | write( 2, "\n", 1 ); | ||
406 | if( !( reply_size = return_fullscrape_for_tracker( &reply ) ) ) HTTPERROR_500; | 409 | if( !( reply_size = return_fullscrape_for_tracker( &reply ) ) ) HTTPERROR_500; |
407 | ot_overall_tcp_successfulannounces++; | 410 | ot_overall_tcp_successfulannounces++; |
408 | return sendmmapdata( s, reply, reply_size ); | 411 | return sendmmapdata( s, reply, reply_size ); |
@@ -623,8 +626,8 @@ static void handle_read( const int64 clientsocket ) { | |||
623 | if( ( array_bytes( &h->request ) > 8192 ) && NOTBLESSED( h ) ) | 626 | if( ( array_bytes( &h->request ) > 8192 ) && NOTBLESSED( h ) ) |
624 | return httperror( clientsocket, "500 request too long", "You sent too much headers"); | 627 | return httperror( clientsocket, "500 request too long", "You sent too much headers"); |
625 | 628 | ||
626 | if( memchr( array_start( &h->request ), '\n', array_length( &h->request, 1 ) ) ) | 629 | if( memchr( array_start( &h->request ), '\n', array_bytes( &h->request ) ) ) |
627 | return httpresponse( clientsocket, array_start( &h->request ), array_length( &h->request, 1 ) ); | 630 | return httpresponse( clientsocket, array_start( &h->request ), array_bytes( &h->request ) ); |
628 | } | 631 | } |
629 | 632 | ||
630 | static void handle_write( const int64 clientsocket ) { | 633 | static void handle_write( const int64 clientsocket ) { |