1 From e0cf6d4b0c84da6273c127a8c87076aac3b51588 Mon Sep 17 00:00:00 2001
2 From: Daniel Egger <daniel.egger@sphairon.com>
3 Date: Mon, 16 Aug 2010 22:36:20 +0200
4 Subject: [PATCH 3/3] Pass a pointer to a char pointer to do_transparent_proxy so the reassembled URL
5 will actually end up back in the caller where it is needed for filtering
6 decisions. This fixes the problem that a tinyproxy configured with the
7 transparent proxy functionality and "FilterURLs Yes" would filter on everything
10 Signed-off-by: daniel.egger@sphairon.com
13 src/transparent-proxy.c | 20 ++++++++++----------
14 src/transparent-proxy.h | 2 +-
15 3 files changed, 12 insertions(+), 12 deletions(-)
19 @@ -418,7 +418,7 @@ BAD_REQUEST_ERROR:
21 #ifdef TRANSPARENT_PROXY
22 if (!do_transparent_proxy
23 - (connptr, hashofheaders, request, &config, url)) {
24 + (connptr, hashofheaders, request, &config, &url)) {
28 --- a/src/transparent-proxy.c
29 +++ b/src/transparent-proxy.c
30 @@ -55,11 +55,11 @@ static int build_url (char **url, const
32 do_transparent_proxy (struct conn_s *connptr, hashmap_t hashofheaders,
33 struct request_s *request, struct config_s *conf,
39 - size_t ulen = strlen (url);
40 + size_t ulen = strlen (*url);
42 length = hashmap_entry_by_key (hashofheaders, "host", (void **) &data);
44 @@ -73,7 +73,7 @@ do_transparent_proxy (struct conn_s *con
46 indicate_http_error (connptr, 400, "Bad Request",
47 "detail", "Unknown destination",
53 @@ -83,15 +83,15 @@ do_transparent_proxy (struct conn_s *con
54 request->port = ntohs (dest_addr.sin_port);
56 request->path = (char *) safemalloc (ulen + 1);
57 - strlcpy (request->path, url, ulen + 1);
58 + strlcpy (request->path, *url, ulen + 1);
60 /* url overwritten by the call below is the url passed
61 * to this function, and is not the url variable in the
63 - build_url (&url, request->host, request->port, request->path);
64 + build_url (url, request->host, request->port, request->path);
65 log_message (LOG_INFO,
66 "process_request: trans IP %s %s for %d",
67 - request->method, url, connptr->client_fd);
68 + request->method, *url, connptr->client_fd);
70 request->host = (char *) safemalloc (length + 1);
71 if (sscanf (data, "%[^:]:%hu", request->host, &request->port) !=
72 @@ -101,15 +101,15 @@ do_transparent_proxy (struct conn_s *con
75 request->path = (char *) safemalloc (ulen + 1);
76 - strlcpy (request->path, url, ulen + 1);
77 + strlcpy (request->path, *url, ulen + 1);
79 /* url overwritten by the call below is the url passed
80 * to this function, and is not the url variable in the
82 - build_url (&url, request->host, request->port, request->path);
83 + build_url (url, request->host, request->port, request->path);
84 log_message (LOG_INFO,
85 "process_request: trans Host %s %s for %d",
86 - request->method, url, connptr->client_fd);
87 + request->method, *url, connptr->client_fd);
89 if (conf->ipAddr && strcmp (request->host, conf->ipAddr) == 0) {
91 @@ -118,7 +118,7 @@ do_transparent_proxy (struct conn_s *con
92 indicate_http_error (connptr, 400, "Bad Request",
94 "You tried to connect to the machine "
95 - "the proxy is running on", "url", url,
96 + "the proxy is running on", "url", *url,
100 --- a/src/transparent-proxy.h
101 +++ b/src/transparent-proxy.h
103 extern int do_transparent_proxy (struct conn_s *connptr,
104 hashmap_t hashofheaders,
105 struct request_s *request,
106 - struct config_s *config, char *url);
107 + struct config_s *config, char **url);