X-Git-Url: http://www.privoxy.org/gitweb/?a=blobdiff_plain;f=parsers.c;h=9b0fd4b19b826597c410afbe1299b55d4bc04d97;hb=9775a52f3c99fb826c2dcae1919a37cc53851b3a;hp=e89a64345b3dd77896e595212e589792bb4ef457;hpb=ac24a49d68bdbf5556b9a96957c1ab697e498ac0;p=privoxy.git diff --git a/parsers.c b/parsers.c index e89a6434..9b0fd4b1 100644 --- a/parsers.c +++ b/parsers.c @@ -1,4 +1,4 @@ -const char parsers_rcs[] = "$Id: parsers.c,v 1.114 2007/10/19 16:56:26 fabiankeil Exp $"; +const char parsers_rcs[] = "$Id: parsers.c,v 1.116 2007/12/01 13:04:22 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/parsers.c,v $ @@ -44,6 +44,13 @@ const char parsers_rcs[] = "$Id: parsers.c,v 1.114 2007/10/19 16:56:26 fabiankei * * Revisions : * $Log: parsers.c,v $ + * Revision 1.116 2007/12/01 13:04:22 fabiankeil + * Fix a crash on mingw32 with some Last Modified times in the future. + * + * Revision 1.115 2007/11/02 16:52:50 fabiankeil + * Remove a "can't happen" error block which, over + * time, mutated into a "guaranteed to happen" block. + * * Revision 1.114 2007/10/19 16:56:26 fabiankeil * - Downgrade "Buffer limit reached" message to LOG_LEVEL_INFO. * - Use shiny new content_filters_enabled() in client_range(). @@ -822,7 +829,6 @@ static jb_err server_content_disposition(struct client_state *csp, char **header static jb_err client_host_adder (struct client_state *csp); static jb_err client_cookie_adder (struct client_state *csp); static jb_err client_xtra_adder (struct client_state *csp); -static jb_err client_x_forwarded_adder(struct client_state *csp); static jb_err connection_close_adder (struct client_state *csp); static jb_err create_forged_referrer(char **header, const char *hostport); @@ -883,7 +889,6 @@ const struct parsers server_patterns_light[] = { const add_header_func_ptr add_client_headers[] = { client_host_adder, client_cookie_adder, - client_x_forwarded_adder, client_xtra_adder, /* Temporarily disabled: client_accept_encoding_adder, */ connection_close_adder, @@ -2595,7 +2600,16 @@ static jb_err server_last_modified(struct client_state *csp, char **header) rtime = (long int)difftime(now, last_modified); if (rtime) { + int negative = 0; + + if (rtime < 0) + { + rtime *= -1; + negative = 1; + log_error(LOG_LEVEL_HEADER, "Server time in the future."); + } rtime = pick_from_range(rtime); + if (negative) rtime *= -1; last_modified += rtime; #ifdef HAVE_GMTIME_R timeptr = gmtime_r(&last_modified, &gmt); @@ -3072,19 +3086,7 @@ static jb_err client_send_cookie(struct client_state *csp, char **header) *********************************************************************/ jb_err client_x_forwarded(struct client_state *csp, char **header) { - if ((csp->action->flags & ACTION_HIDE_FORWARDED) == 0) - { - /* Save it so we can re-add it later */ - freez(csp->x_forwarded); - csp->x_forwarded = *header; - - /* - * Always set *header = NULL, since this information - * will be sent at the end of the header. - */ - *header = NULL; - } - else + if ((csp->action->flags & ACTION_HIDE_FORWARDED) != 0) { freez(*header); log_error(LOG_LEVEL_HEADER, "crunched x-forwarded-for!"); @@ -3635,53 +3637,6 @@ static jb_err client_xtra_adder(struct client_state *csp) } -/********************************************************************* - * - * Function : client_x_forwarded_adder - * - * Description : Used in the add_client_headers list. Called from `sed'. - * - * Parameters : - * 1 : csp = Current client state (buffers, headers, etc...) - * - * Returns : JB_ERR_OK on success, or - * JB_ERR_MEMORY on out-of-memory error. - * - *********************************************************************/ -static jb_err client_x_forwarded_adder(struct client_state *csp) -{ - char *p = NULL; - jb_err err; - - if ((csp->action->flags & ACTION_HIDE_FORWARDED) != 0) - { - return JB_ERR_OK; - } - - if (csp->x_forwarded) - { - p = strdup(csp->x_forwarded); - string_append(&p, ", "); - } - else - { - p = strdup("X-Forwarded-For: "); - } - string_append(&p, csp->ip_addr_str); - - if (p == NULL) - { - return JB_ERR_MEMORY; - } - - log_error(LOG_LEVEL_HEADER, "addh: %s", p); - err = enlist(csp->headers, p); - free(p); - - return err; -} - - /********************************************************************* * * Function : connection_close_adder