From: Fabian Keil Date: Sat, 25 Aug 2007 14:42:40 +0000 (+0000) Subject: Don't crash if a broken header filter wiped out the request line. X-Git-Tag: v_3_0_7~166 X-Git-Url: http://www.privoxy.org/gitweb/?p=privoxy.git;a=commitdiff_plain;h=cf47a535d5644f1a879b158622bc6f43d6649530 Don't crash if a broken header filter wiped out the request line. --- diff --git a/jcc.c b/jcc.c index 6835ce04..0708b7aa 100644 --- a/jcc.c +++ b/jcc.c @@ -1,4 +1,4 @@ -const char jcc_rcs[] = "$Id: jcc.c,v 1.145 2007/08/19 13:13:31 fabiankeil Exp $"; +const char jcc_rcs[] = "$Id: jcc.c,v 1.146 2007/08/20 17:09:32 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/jcc.c,v $ @@ -33,6 +33,10 @@ const char jcc_rcs[] = "$Id: jcc.c,v 1.145 2007/08/19 13:13:31 fabiankeil Exp $" * * Revisions : * $Log: jcc.c,v $ + * Revision 1.146 2007/08/20 17:09:32 fabiankeil + * Fix byte_count calculation in case of flushes + * and don't parse the server headers a second time. + * * Revision 1.145 2007/08/19 13:13:31 fabiankeil * - If there's a connection problem after we already forwarded * parts of the original content, just hang up. Fixes BR#1776724. @@ -2141,22 +2145,21 @@ static void chat(struct client_state *csp) } csp->flags |= CSP_FLAG_CLIENT_HEADER_PARSING_DONE; - if (strcmp(http->cmd, csp->headers->first->str)) + /* Check request line for rewrites. */ + if ((NULL == csp->headers->first->str) + || (strcmp(http->cmd, csp->headers->first->str) && + (JB_ERR_OK != change_request_destination(csp)))) { /* - * A header filter rewrote the request line, - * modify the http request accordingly. + * A header filter broke the request line - bail out. */ - if (JB_ERR_OK != change_request_destination(csp)) - { - write_socket(csp->cfd, MESSED_UP_REQUEST_RESPONSE, strlen(MESSED_UP_REQUEST_RESPONSE)); - /* XXX: Use correct size */ - log_error(LOG_LEVEL_CLF, "%s - - [%T] \"Invalid request generated\" 500 0", csp->ip_addr_str); - log_error(LOG_LEVEL_ERROR, "Invalid request line after applying header filters."); + write_socket(csp->cfd, MESSED_UP_REQUEST_RESPONSE, strlen(MESSED_UP_REQUEST_RESPONSE)); + /* XXX: Use correct size */ + log_error(LOG_LEVEL_CLF, "%s - - [%T] \"Invalid request generated\" 500 0", csp->ip_addr_str); + log_error(LOG_LEVEL_ERROR, "Invalid request line after applying header filters."); - free_http_request(http); - return; - } + free_http_request(http); + return; } /* decide how to route the HTTP request */