From: Fabian Keil Date: Wed, 19 Aug 2009 16:00:07 +0000 (+0000) Subject: Subtract already buffered request bytes from the expected ones and throw away overrea... X-Git-Tag: v_3_0_15~95 X-Git-Url: http://www.privoxy.org/gitweb/%40user-manual%40%40actions-help-prefix%40HIDE-IF-MODIFIED-SINCE?a=commitdiff_plain;h=4c081739d7da44a66437925ecb4d2dc490b0ee65;hp=3043c7216d75378d643cc81ba5e17e197e33284f;p=privoxy.git Subtract already buffered request bytes from the expected ones and throw away overread bytes in pipelined requests with body to let the client retry on an untainted socket. --- diff --git a/jcc.c b/jcc.c index fad64da1..f87cfe81 100644 --- a/jcc.c +++ b/jcc.c @@ -1,4 +1,4 @@ -const char jcc_rcs[] = "$Id: jcc.c,v 1.276 2009/08/19 15:57:13 fabiankeil Exp $"; +const char jcc_rcs[] = "$Id: jcc.c,v 1.277 2009/08/19 15:59:02 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/jcc.c,v $ @@ -1458,8 +1458,39 @@ static jb_err parse_client_request(struct client_state *csp) #ifdef FEATURE_CONNECTION_KEEP_ALIVE if ((csp->flags & CSP_FLAG_CLIENT_CONNECTION_KEEP_ALIVE)) { - if ((csp->iob->cur[0] != '\0') - || (csp->expected_client_content_length != 0)) + unsigned long long buffered_request_bytes = + (unsigned long long)(csp->iob->eod - csp->iob->cur); + + if ((csp->expected_client_content_length != 0) + && (buffered_request_bytes != 0)) + { + if (csp->expected_client_content_length >= buffered_request_bytes) + { + csp->expected_client_content_length -= buffered_request_bytes; + log_error(LOG_LEVEL_CONNECT, "Reduced expected bytes to %llu " + "to account for the %llu ones we already got.", + csp->expected_client_content_length, buffered_request_bytes); + } + else + { + assert(csp->iob->eod > csp->iob->cur + csp->expected_client_content_length); + csp->iob->eod = csp->iob->cur + csp->expected_client_content_length; + log_error(LOG_LEVEL_CONNECT, "Reducing expected bytes to 0. " + "Marking the server socket tainted after throwing %llu bytes away.", + buffered_request_bytes - csp->expected_client_content_length); + csp->expected_client_content_length = 0; + csp->flags |= CSP_FLAG_SERVER_SOCKET_TAINTED; + } + + if (csp->expected_client_content_length == 0) + { + csp->flags |= CSP_FLAG_CLIENT_REQUEST_COMPLETELY_READ; + } + } + + if (!(csp->flags & CSP_FLAG_CLIENT_REQUEST_COMPLETELY_READ) + && ((csp->iob->cur[0] != '\0') + || (csp->expected_client_content_length != 0))) { csp->flags |= CSP_FLAG_SERVER_SOCKET_TAINTED; if (strcmpic(csp->http->gpc, "GET")