X-Git-Url: http://www.privoxy.org/gitweb/?p=privoxy.git;a=blobdiff_plain;f=filters.c;h=0450f5a7cc8c735699e22438b0ada91c3665c8a2;hp=e6dae10886bdeac3d5bf56a4e6dc38c4ffeaa3b5;hb=a2f1da2576306c55f97a25bdc05cb7745feb869e;hpb=d51ecc85d592ae919c8d114cd8c1eb82107d99c7 diff --git a/filters.c b/filters.c index e6dae108..0450f5a7 100644 --- a/filters.c +++ b/filters.c @@ -1,11 +1,11 @@ -const char filters_rcs[] = "$Id: filters.c,v 1.197 2016/01/16 12:29:17 fabiankeil Exp $"; +const char filters_rcs[] = "$Id: filters.c,v 1.202 2016/05/25 10:50:55 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/filters.c,v $ * * Purpose : Declares functions to parse/crunch headers and pages. * - * Copyright : Written by and Copyright (C) 2001-2014 the + * Copyright : Written by and Copyright (C) 2001-2016 the * Privoxy team. http://www.privoxy.org/ * * Based on the Internet Junkbuster originally written @@ -70,6 +70,9 @@ const char filters_rcs[] = "$Id: filters.c,v 1.197 2016/01/16 12:29:17 fabiankei #include "deanimate.h" #include "urlmatch.h" #include "loaders.h" +#ifdef FEATURE_CLIENT_TAGS +#include "client-tags.h" +#endif #ifdef _WIN32 #include "win32.h" @@ -79,8 +82,13 @@ const char filters_h_rcs[] = FILTERS_H_VERSION; typedef char *(*filter_function_ptr)(); static filter_function_ptr get_filter_function(const struct client_state *csp); -static jb_err remove_chunked_transfer_coding(char *buffer, size_t *size); static jb_err prepare_for_filtering(struct client_state *csp); +static void apply_url_actions(struct current_action_spec *action, + struct http_request *http, +#ifdef FEATURE_CLIENT_TAGS + const struct list *client_tags, +#endif + struct url_actions *b); #ifdef FEATURE_ACL #ifdef HAVE_RFC2553 @@ -926,6 +934,7 @@ pcrs_job *compile_dynamic_pcrs_job_list(const struct client_state *csp, const st {"path", csp->http->path, 1}, {"host", csp->http->host, 1}, {"origin", csp->ip_addr_str, 1}, + {"listen-address", csp->listen_addr_str, 1}, {NULL, NULL, 1} }; @@ -1762,6 +1771,7 @@ static void set_privoxy_variables(const struct client_state *csp) { "PRIVOXY_PATH", csp->http->path }, { "PRIVOXY_HOST", csp->http->host }, { "PRIVOXY_ORIGIN", csp->ip_addr_str }, + { "PRIVOXY_LISTEN_ADDRESS", csp->listen_addr_str }, }; for (i = 0; i < SZ(env); i++) @@ -1946,7 +1956,11 @@ static char *execute_external_filter(const struct client_state *csp, * or NULL in case something went wrong. * *********************************************************************/ +#ifdef FUZZ +char *gif_deanimate_response(struct client_state *csp) +#else static char *gif_deanimate_response(struct client_state *csp) +#endif { struct binbuffer *in, *out; char *p; @@ -1954,12 +1968,8 @@ static char *gif_deanimate_response(struct client_state *csp) size = (size_t)(csp->iob->eod - csp->iob->cur); - if ( (NULL == (in = (struct binbuffer *)zalloc(sizeof *in ))) - || (NULL == (out = (struct binbuffer *)zalloc(sizeof *out))) ) - { - log_error(LOG_LEVEL_DEANIMATE, "failed! (no mem)"); - return NULL; - } + in = zalloc_or_die(sizeof(*in)); + out = zalloc_or_die(sizeof(*out)); in->buffer = csp->iob->cur; in->size = size; @@ -2048,13 +2058,23 @@ static filter_function_ptr get_filter_function(const struct client_state *csp) * JB_ERR_PARSE otherwise * *********************************************************************/ +#ifdef FUZZ +extern jb_err remove_chunked_transfer_coding(char *buffer, size_t *size) +#else static jb_err remove_chunked_transfer_coding(char *buffer, size_t *size) +#endif { size_t newsize = 0; unsigned int chunksize = 0; char *from_p, *to_p; const char *end_of_buffer = buffer + *size; + if (*size == 0) + { + log_error(LOG_LEVEL_FATAL, "Invalid chunked input. Buffer is empty."); + return JB_ERR_PARSE; + } + assert(buffer); from_p = to_p = buffer; @@ -2326,13 +2346,16 @@ void get_url_actions(struct client_state *csp, struct http_request *http) return; } +#ifdef FEATURE_CLIENT_TAGS + apply_url_actions(csp->action, http, csp->client_tags, b); +#else apply_url_actions(csp->action, http, b); +#endif } return; } - /********************************************************************* * * Function : apply_url_actions @@ -2342,14 +2365,18 @@ void get_url_actions(struct client_state *csp, struct http_request *http) * Parameters : * 1 : action = Destination. * 2 : http = Current URL - * 3 : b = list of URL actions to apply + * 3 : client_tags = list of client tags + * 4 : b = list of URL actions to apply * * Returns : N/A * *********************************************************************/ -void apply_url_actions(struct current_action_spec *action, - struct http_request *http, - struct url_actions *b) +static void apply_url_actions(struct current_action_spec *action, + struct http_request *http, +#ifdef FEATURE_CLIENT_TAGS + const struct list *client_tags, +#endif + struct url_actions *b) { if (b == NULL) { @@ -2363,6 +2390,12 @@ void apply_url_actions(struct current_action_spec *action, { merge_current_action(action, b->action); } +#ifdef FEATURE_CLIENT_TAGS + if (client_tag_match(b->url, client_tags)) + { + merge_current_action(action, b->action); + } +#endif } } @@ -2424,14 +2457,7 @@ static const struct forward_spec *get_forward_override_settings(struct client_st * the lifetime of this request. Save its location * in csp as well, so sweep() can free it later on. */ - fwd = csp->fwd = zalloc(sizeof(*fwd)); - if (NULL == fwd) - { - log_error(LOG_LEVEL_FATAL, - "can't allocate memory for forward-override{%s}", forward_override_line); - /* Never get here - LOG_LEVEL_FATAL causes program exit */ - return NULL; - } + fwd = csp->fwd = zalloc_or_die(sizeof(*fwd)); vec_count = ssplit(forward_settings, " \t", vec, SZ(vec)); if ((vec_count == 2) && !strcasecmp(vec[0], "forward"))