From 4fc8dd75be7e511823d6ff529411896b1b5e1c7e Mon Sep 17 00:00:00 2001 From: denis <> Date: Wed, 24 Jan 2007 20:13:30 +0000 Subject: Copy request before expanding url-encoded bytes --- opentracker.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'opentracker.c') diff --git a/opentracker.c b/opentracker.c index 2299844..17584ab 100644 --- a/opentracker.c +++ b/opentracker.c @@ -40,6 +40,9 @@ static char static_scratch[8192]; #ifdef _DEBUG_FDS static char fd_debug_space[0x10000]; #endif +#ifdef _DEBUG_HTTPERROR +static char debug_request[8192]; +#endif static void carp(const char* routine) { buffer_puts(buffer_2,routine); @@ -135,7 +138,7 @@ void httperror(int64 s,struct http_data* h,const char* title,const char* message size_t reply_size = sprintf( static_scratch, "HTTP/1.0 %s\r\nContent-Type: text/html\r\nConnection: close\r\nContent-Length: %zd\r\n\r\n%s\n", title, strlen(message)+strlen(title)+16-4,title+4); #ifdef _DEBUG_HTTPERROR - fprintf( stderr, "DEBUG: invalid request was: %s\n", (char*)array_start( &h->r ) ); + fprintf( stderr, "DEBUG: invalid request was: %s\n", debug_request ); #endif senddata(s,h,static_scratch,reply_size); } @@ -169,6 +172,10 @@ void httpresponse(int64 s,struct http_data* h) array_cat0(&h->r); c = array_start(&h->r); +#ifdef _DEBUG_HTTPERROR + memcpy( debug_request, array_start(&h->r), array_bytes(&h->r) ); +#endif + if (byte_diff(c,4,"GET ")) { e400: return httperror(s,h,"400 Invalid Request","This server only understands GET."); @@ -481,6 +488,10 @@ void handle_read( int64 clientsocket ) { array_catb(&h->r,static_scratch,l); +#ifdef _DEBUG_HTTPERROR + memcpy( debug_request, "500!\0", 5 ); +#endif + if( array_failed(&h->r)) httperror(clientsocket,h,"500 Server Error","Request too long."); else if (array_bytes(&h->r)>8192) -- cgit v1.2.3