source: packages/net/tinyproxy/patches/040-fix_url_filter_in_transparent_mode.patch @ 27135

Last change on this file since 27135 was 27135, checked in by jow, 6 years ago

[packages] tinyproxy: import fix for upstream bug #95 - fix url filters in transparent mode

File size: 5.0 KB
  • src/reqs.c

    From e0cf6d4b0c84da6273c127a8c87076aac3b51588 Mon Sep 17 00:00:00 2001
    From: Daniel Egger <daniel.egger@sphairon.com>
    Date: Mon, 16 Aug 2010 22:36:20 +0200
    Subject: [PATCH 3/3] Pass a pointer to a char pointer to do_transparent_proxy so the reassembled URL
     will actually end up back in the caller where it is needed for filtering
     decisions. This fixes the problem that a tinyproxy configured with the
     transparent proxy functionality and "FilterURLs Yes" would filter on everything
     but the domain.
    
    Signed-off-by: daniel.egger@sphairon.com
    ---
     src/reqs.c              |    2 +-
     src/transparent-proxy.c |   20 ++++++++++----------
     src/transparent-proxy.h |    2 +-
     3 files changed, 12 insertions(+), 12 deletions(-)
    
    a b BAD_REQUEST_ERROR: 
    418418        } else { 
    419419#ifdef TRANSPARENT_PROXY 
    420420                if (!do_transparent_proxy 
    421                     (connptr, hashofheaders, request, &config, url)) { 
     421                    (connptr, hashofheaders, request, &config, &url)) { 
    422422                        goto fail; 
    423423                } 
    424424#else 
  • src/transparent-proxy.c

    a b static int build_url (char **url, const  
    5555int 
    5656do_transparent_proxy (struct conn_s *connptr, hashmap_t hashofheaders, 
    5757                      struct request_s *request, struct config_s *conf, 
    58                       char *url) 
     58                      char **url) 
    5959{ 
    6060        socklen_t length; 
    6161        char *data; 
    62         size_t ulen = strlen (url); 
     62        size_t ulen = strlen (*url); 
    6363 
    6464        length = hashmap_entry_by_key (hashofheaders, "host", (void **) &data); 
    6565        if (length <= 0) { 
    do_transparent_proxy (struct conn_s *con 
    7373                                     connptr->client_fd); 
    7474                        indicate_http_error (connptr, 400, "Bad Request", 
    7575                                             "detail", "Unknown destination", 
    76                                              "url", url, NULL); 
     76                                             "url", *url, NULL); 
    7777                        return 0; 
    7878                } 
    7979 
    do_transparent_proxy (struct conn_s *con 
    8383                request->port = ntohs (dest_addr.sin_port); 
    8484 
    8585                request->path = (char *) safemalloc (ulen + 1); 
    86                 strlcpy (request->path, url, ulen + 1); 
     86                strlcpy (request->path, *url, ulen + 1); 
    8787 
    8888                /* url overwritten by the call below is the url passed 
    8989                 * to this function, and is not the url variable in the 
    9090                 * caller. */ 
    91                 build_url (&url, request->host, request->port, request->path); 
     91                build_url (url, request->host, request->port, request->path); 
    9292                log_message (LOG_INFO, 
    9393                             "process_request: trans IP %s %s for %d", 
    94                              request->method, url, connptr->client_fd); 
     94                             request->method, *url, connptr->client_fd); 
    9595        } else { 
    9696                request->host = (char *) safemalloc (length + 1); 
    9797                if (sscanf (data, "%[^:]:%hu", request->host, &request->port) != 
    do_transparent_proxy (struct conn_s *con 
    101101                } 
    102102 
    103103                request->path = (char *) safemalloc (ulen + 1); 
    104                 strlcpy (request->path, url, ulen + 1); 
     104                strlcpy (request->path, *url, ulen + 1); 
    105105 
    106106                /* url overwritten by the call below is the url passed 
    107107                 * to this function, and is not the url variable in the 
    108108                 * caller. */ 
    109                 build_url (&url, request->host, request->port, request->path); 
     109                build_url (url, request->host, request->port, request->path); 
    110110                log_message (LOG_INFO, 
    111111                             "process_request: trans Host %s %s for %d", 
    112                              request->method, url, connptr->client_fd); 
     112                             request->method, *url, connptr->client_fd); 
    113113        } 
    114114        if (conf->ipAddr && strcmp (request->host, conf->ipAddr) == 0) { 
    115115                log_message (LOG_ERR, 
    do_transparent_proxy (struct conn_s *con 
    118118                indicate_http_error (connptr, 400, "Bad Request", 
    119119                                     "detail", 
    120120                                     "You tried to connect to the machine " 
    121                                      "the proxy is running on", "url", url, 
     121                                     "the proxy is running on", "url", *url, 
    122122                                     NULL); 
    123123                return 0; 
    124124        } 
  • src/transparent-proxy.h

    a b  
    3232extern int do_transparent_proxy (struct conn_s *connptr, 
    3333                                 hashmap_t hashofheaders, 
    3434                                 struct request_s *request, 
    35                                  struct config_s *config, char *url); 
     35                                 struct config_s *config, char **url); 
    3636 
    3737#endif 
    3838 
Note: See TracBrowser for help on using the repository browser.