From 7cc90f68ad18699fd25d311afc4e6dc48fb92469 Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Sun, 27 Dec 2015 12:49:29 +0000 Subject: [PATCH] get_destination_from_headers(): Additionally update the request line in proxy format This makes rewriting intercepted requests more convenient. Previously it was expected to fail unless $hostport was being used, but rewrites of intercepted requests without $hostport failed "the wrong way" and would result in an out-of-memory message (vanilla host patterns) or a crash (extended host patterns). Reported by "Guybrish Threepwood" in #1694. --- parsers.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/parsers.c b/parsers.c index eed559aa..7352e8c4 100644 --- a/parsers.c +++ b/parsers.c @@ -1,4 +1,4 @@ -const char parsers_rcs[] = "$Id: parsers.c,v 1.299 2015/03/27 12:39:44 fabiankeil Exp $"; +const char parsers_rcs[] = "$Id: parsers.c,v 1.300 2015/12/27 12:48:59 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/parsers.c,v $ @@ -4445,6 +4445,26 @@ jb_err get_destination_from_headers(const struct list *headers, struct http_requ log_error(LOG_LEVEL_HEADER, "Destination extracted from \"Host:\" header. New request URL: %s", http->url); + /* + * Regenerate request line in "proxy format" + * to make rewrites more convenient. + * XXX: Code duplication. + */ + assert(http->cmd != NULL); + freez(http->cmd); + http->cmd = strdup_or_die(http->gpc); + string_append(&http->cmd, " "); + string_append(&http->cmd, http->url); + string_append(&http->cmd, " "); + string_append(&http->cmd, http->ver); + if (http->cmd == NULL) + { + return JB_ERR_MEMORY; + } + + log_error(LOG_LEVEL_HEADER, "Faked request-Line: %s", + http->cmd); + return JB_ERR_OK; } -- 2.39.2