From 2b715b89f12de4c2ea11b23af6d9fd51b54a956c Mon Sep 17 00:00:00 2001 From: erdgeist <> Date: Sun, 21 Oct 2007 03:37:26 +0000 Subject: [PATCH] Debug code sometimes copied too much data --- opentracker.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/opentracker.c b/opentracker.c index f29e076..bfb5c53 100644 --- a/opentracker.c +++ b/opentracker.c @@ -226,11 +226,10 @@ static void httpresponse( const int64 s, char *data, size_t l ) { size_t reply_size = 0, reply_off; #ifdef _DEBUG_HTTPERROR - memcpy( debug_request, data, sizeof( debug_request ) ); - if( l < sizeof( debug_request ) ) - debug_request[ l ] = 0; - else - debug_request[ sizeof( debug_request ) - 1 ] = 0; + if( l >= sizeof( debug_request ) ) + l = sizeof( debug_request) - 1; + memcpy( debug_request, data, l ); + debug_request[ l ] = 0; #endif /* This one implicitely tests strlen < 5, too -- remember, it is \n terminated */