-const char filters_rcs[] = "$Id: filters.c,v 1.57 2002/04/08 20:38:34 swa Exp $";
+const char filters_rcs[] = "$Id: filters.c,v 1.58.2.2 2002/08/01 17:18:28 oes Exp $";
/*********************************************************************
*
- * File : $Source: /cvsroot/ijbswa/current/filters.c,v $
+ * File : $Source: /cvsroot/ijbswa//current/Attic/filters.c,v $
*
* Purpose : Declares functions to parse/crunch headers and pages.
* Functions declared include:
*
* Revisions :
* $Log: filters.c,v $
+ * Revision 1.58.2.2 2002/08/01 17:18:28 oes
+ * Fixed BR 537651 / SR 579724 (MSIE image detect improper for IE/Mac)
+ *
+ * Revision 1.58.2.1 2002/07/26 15:18:53 oes
+ * - Bugfix: Executing a filters without jobs no longer results in
+ * turing off *all* filters.
+ * - Security fix: Malicious web servers can't cause a seg fault
+ * through bogus chunk sizes anymore
+ *
+ * Revision 1.58 2002/04/24 02:11:17 oes
+ * Jon's multiple AF patch: url_actions now evaluates rules
+ * from all AFs.
+ *
* Revision 1.57 2002/04/08 20:38:34 swa
* fixed JB spelling
*
*
* Description : Given a URL, decide whether it is an image or not,
* using either the info from a previous +image action
- * or, #ifdef FEATURE_IMAGE_DETECT_MSIE, the info from
- * the browser's accept header.
+ * or, #ifdef FEATURE_IMAGE_DETECT_MSIE, and the browser
+ * is MSIE and not on a Mac, tell from the browser's accept
+ * header.
*
* Parameters :
* 1 : csp = Current client state (buffers, headers, etc...)
char *tmp;
tmp = get_header_value(csp->headers, "User-Agent:");
- if (tmp && strstr(tmp, "MSIE"))
+ if (tmp && strstr(tmp, "MSIE") && !strstr(tmp, "Mac_"))
{
tmp = get_header_value(csp->headers, "Accept:");
if (tmp && strstr(tmp, "image/gif"))
if ( NULL == b->joblist )
{
log_error(LOG_LEVEL_RE_FILTER, "Filter %s has empty joblist. Nothing to do.", b->name);
- return(NULL);
+ continue;
}
log_error(LOG_LEVEL_RE_FILTER, "re_filtering %s%s (size %d) with filter %s...",
log_error(LOG_LEVEL_ERROR, "Parse error while stripping \"chunked\" transfer coding");
return(0);
}
- newsize += chunksize;
+
+ if ((newsize += chunksize) >= size)
+ {
+ log_error(LOG_LEVEL_ERROR, "Chunksize exceeds buffer in \"chunked\" transfer coding");
+ return(0);
+ }
from_p += 2;
memmove(to_p, from_p, (size_t) chunksize);
}
+/*********************************************************************
+ *
+ * Function : direct_response
+ *
+ * Description : Check if Max-Forwards == 0 for an OPTIONS or TRACE
+ * request and if so, return a HTTP 501 to the client.
+ *
+ * FIXME: I have a stupid name and I should handle the
+ * requests properly. Still, what we do here is rfc-
+ * compliant, whereas ignoring or forwarding are not.
+ *
+ * Parameters :
+ * 1 : csp = Current client state (buffers, headers, etc...)
+ *
+ * Returns : http_response if , NULL if nonmatch or handler fail
+ *
+ *********************************************************************/
+struct http_response *direct_response(struct client_state *csp)
+{
+ struct http_response *rsp;
+ struct list_entry *p;
+
+ if ((0 == strcmpic(csp->http->gpc, "trace"))
+ || (0 == strcmpic(csp->http->gpc, "options")))
+ {
+ for (p = csp->headers->first; (p != NULL) ; p = p->next)
+ {
+ if (!strncmp("Max-Forwards:", p->str, 13)
+ && (*(p->str+13) != '\0') && (atoi(p->str+13) == 0))
+ {
+ /* FIXME: We could handle at least TRACE here,
+ but that would require a verbatim copy of
+ the request which we don't have anymore */
+
+ log_error(LOG_LEVEL_HEADER, "Found Max-Forwards:0 in OPTIONS or TRACE request -- Returning 501");
+
+ /* Get mem for response or fail*/
+ if (NULL == (rsp = alloc_http_response()))
+ {
+ return cgi_error_memory();
+ }
+
+ if (NULL == (rsp->status = strdup("501 Not Implemented")))
+ {
+ free_http_response(rsp);
+ return cgi_error_memory();
+ }
+
+ rsp->is_static = 1;
+ return(finish_http_response(rsp));
+ }
+ }
+ }
+ return NULL;
+}
+
+
/*
Local Variables:
tab-width: 3