cvs commit: apachen/src/modules/standard mod_negotiation.c
dgaudet 97/12/19 10:24:59 Modified:src CHANGES src/modules/standard mod_negotiation.c Log: Fix a potential SEGV -- the "hdr" variable was being incremented twice going past the \0 terminator. Reviewed by: Jim Jagielski, Martin Kraemer Revision ChangesPath 1.531 +3 -0 apachen/src/CHANGES Index: CHANGES === RCS file: /export/home/cvs/apachen/src/CHANGES,v retrieving revision 1.530 retrieving revision 1.531 diff -u -r1.530 -r1.531 --- CHANGES 1997/12/19 02:17:15 1.530 +++ CHANGES 1997/12/19 18:24:50 1.531 @@ -1,5 +1,8 @@ Changes with Apache 1.3b4 + *) Fix a potential SEGV problem in mod_negotiation when dealing + with type-maps. [Dean Gaudet] + *) Better glibc support under Linux. [Dean Gaudet] PR#1542 *) "RedirectMatch gone /" would cause a SIGSEGV. [Dean Gaudet] PR#1319 1.62 +5 -4 apachen/src/modules/standard/mod_negotiation.c Index: mod_negotiation.c === RCS file: /export/home/cvs/apachen/src/modules/standard/mod_negotiation.c,v retrieving revision 1.61 retrieving revision 1.62 diff -u -r1.61 -r1.62 --- mod_negotiation.c 1997/10/22 20:30:26 1.61 +++ mod_negotiation.c 1997/12/19 18:24:52 1.62 @@ -645,10 +645,11 @@ while (*hdr) { if (*hdr == '"') { -while (*++hdr && *hdr != '"') { -continue; -} -++hdr; + hdr = strchr(hdr, '"'); + if (hdr == NULL) { + return; + } + ++hdr; } else if (*hdr == '(') { while (*hdr && *hdr != ')') {
cvs commit: apachen/src/modules/standard mod_negotiation.c
martin 97/10/21 08:46:25 Modified:src/main http_protocol.c http_request.c httpd.h Log: Encapsulatte internal representation of HTTP protocol number with a HTTP_VERSION(major,minor) macro. Currently, this is backward compatible to the algorithm used now (1000*major+minor Reviewed by: Ken +1, Alexei +1, Jim +1 Revision ChangesPath 1.167 +9 -6 apachen/src/main/http_protocol.c Index: http_protocol.c === RCS file: /home/cvs/apachen/src/main/http_protocol.c,v retrieving revision 1.166 retrieving revision 1.167 diff -u -r1.166 -r1.167 --- http_protocol.c 1997/10/07 19:34:03 1.166 +++ http_protocol.c 1997/10/21 15:40:13 1.167 @@ -300,7 +300,7 @@ find_last_token(r->pool, table_get(r->headers_out, "Transfer-Encoding"), "chunked") || - ((r->proto_num >= 1001) && (r->chunked = 1))) && + ((r->proto_num >= HTTP_VERSION(1,1)) && (r->chunked = 1))) && r->server->keep_alive && (r->server->keep_alive_timeout > 0) && ((r->server->keep_alive_max == 0) || @@ -311,7 +311,7 @@ (!table_get(r->subprocess_env, "nokeepalive") || table_get(r->headers_in, "Via")) && ((ka_sent = find_token(r->pool, conn, "keep-alive")) || - (r->proto_num >= 1001)) + (r->proto_num >= HTTP_VERSION(1,1))) ) { char header[256]; int left = r->server->keep_alive_max - r->connection->keepalives; @@ -726,8 +726,11 @@ r->assbackwards = (ll[0] == '\0'); r->protocol = pstrdup(r->pool, ll[0] ? ll : "HTTP/0.9"); -sscanf(r->protocol, "HTTP/%d.%d", &major, &minor); -r->proto_num = 1000 * major + minor; +if (2 == sscanf(r->protocol, "HTTP/%u.%u", &major, &minor) + && minor < HTTP_VERSION(1,0)) /* don't allow HTTP/0.1000 */ + r->proto_num = HTTP_VERSION(major, minor); +else + r->proto_num = HTTP_VERSION(1,0); return 1; } @@ -1058,7 +1061,7 @@ * kluge around broken browsers when indicated by force-response-1.0 */ if (r->proxyreq -|| (r->proto_num == 1000 +|| (r->proto_num == HTTP_VERSION(1,0) && table_get(r->subprocess_env, "force-response-1.0"))) { protocol = "HTTP/1.0"; @@ -1385,7 +1388,7 @@ if (!r->read_chunked && (r->remaining <= 0)) return 0; -if (r->proto_num >= 1001) { /* sending 100 Continue interim response */ +if (r->proto_num >= HTTP_VERSION(1,1)) { /* sending 100 Continue interim response */ bvputs(r->connection->client, SERVER_PROTOCOL, " ", status_lines[0], "\015\012\015\012", NULL); 1.90 +4 -4 apachen/src/main/http_request.c Index: http_request.c === RCS file: /home/cvs/apachen/src/main/http_request.c,v retrieving revision 1.89 retrieving revision 1.90 diff -u -r1.89 -r1.90 --- http_request.c1997/10/15 00:15:13 1.89 +++ http_request.c1997/10/21 15:40:14 1.90 @@ -982,8 +982,8 @@ return; } -if ((!r->hostname && (r->proto_num >= 1001)) || -((r->proto_num == 1001) && !table_get(r->headers_in, "Host"))) { +if ((!r->hostname && (r->proto_num >= HTTP_VERSION(1,1))) || +((r->proto_num == HTTP_VERSION(1,1)) && !table_get(r->headers_in, "Host"))) { /* * Client sent us a HTTP/1.1 or later request without telling us the * hostname, either with a full URL or a Host: header. We therefore @@ -1027,8 +1027,8 @@ return; } -if (r->proto_num > 1000 && table_get(r->subprocess_env, "downgrade-1.0")) { -r->proto_num = 1000; +if (r->proto_num > HTTP_VERSION(1,0) && table_get(r->subprocess_env, "downgrade-1.0")) { +r->proto_num = HTTP_VERSION(1,0); } /* 1.161 +5 -0 apachen/src/main/httpd.h Index: httpd.h === RCS file: /home/cvs/apachen/src/main/httpd.h,v retrieving revision 1.160 retrieving revision 1.161 diff -u -r1.160 -r1.161 --- httpd.h 1997/10/17 13:37:28 1.160 +++ httpd.h 1997/10/21 15:40:15 1.161 @@ -104,6 +104,11 @@ */ +/* -- Internal representation for a HTTP protocol number, e.g., HTTP/1.1 -- */ + +#define HTTP_VERSION(major,minor) (1000*(major)+(minor)) + + /* -- Port number for server running standalone --- */ #define DEFAULT_PORT 80 Modified:src/modules/standard mod_negotiation.c Log: Encapsulate internal representation of HTTP protocol number with a HTTP_VERSION(major,minor) macro. Currently, this is backward com
cvs commit: apachen/src/modules/standard mod_negotiation.c
ben 97/10/17 12:26:57 Modified:src/modules/standard mod_negotiation.c Log: Fix undefined behaviour. (Note, this patch is also included in the Win32 1.3b2). Revision ChangesPath 1.59 +2 -2 apachen/src/modules/standard/mod_negotiation.c Index: mod_negotiation.c cvs diff: cannot exec /usr/local/bin/rcsdiff: No such file or directory
cvs commit: apachen/src/modules/standard mod_negotiation.c
randy 97/08/31 19:32:56 Modified:src/modules/standard mod_negotiation.c Log: Convert log_*() to aplog_error(). Revision ChangesPath 1.56 +13 -7 apachen/src/modules/standard/mod_negotiation.c Index: mod_negotiation.c === RCS file: /export/home/cvs/apachen/src/modules/standard/mod_negotiation.c,v retrieving revision 1.55 retrieving revision 1.56 diff -u -r1.55 -r1.56 --- mod_negotiation.c 1997/08/23 14:20:35 1.55 +++ mod_negotiation.c 1997/09/01 02:32:54 1.56 @@ -629,15 +629,17 @@ *cp++ = tolower(*cp); if (!*cp) { - log_reason ("Syntax error in type map --- no ':'", r->filename, r); + aplog_error(APLOG_MARK, APLOG_ERR, r->server, + "Syntax error in type map --- no ':': %s", r->filename); return NULL; } do ++cp; while (*cp && isspace (*cp)); if (!*cp) { - log_reason ("Syntax error in type map --- no header body", - r->filename, r); + aplog_error(APLOG_MARK, APLOG_ERR, r->server, + "Syntax error in type map --- no header body: %s", + r->filename); return NULL; } @@ -660,7 +662,8 @@ } map = pfopen (neg->pool, rr->filename, "r"); if (map == NULL) { -log_reason("cannot access type map file", rr->filename, r); +aplog_error(APLOG_MARK, APLOG_ERR, r->server, + "cannot access type map file", rr->filename); return FORBIDDEN; } @@ -745,7 +748,8 @@ dirp = popendir (neg->pool, neg->dir_name); if (dirp == NULL) { -log_reason("cannot read directory for multi", neg->dir_name, r); +aplog_error(APLOG_MARK, APLOG_ERR, r->server, + "cannot read directory for multi", neg->dir_name); return FORBIDDEN; } @@ -1887,7 +1891,8 @@ } if (!best) { - log_reason ("no acceptable variant", r->filename, r); + aplog_error(APLOG_MARK, APLOG_ERR, r->server, + "no acceptable variant", r->filename); set_neg_headers(r, neg, na_result); store_variant_list (r, neg); @@ -1966,7 +1971,8 @@ } if (!best) { - log_reason ("no acceptable variant", r->filename, r); + aplog_error(APLOG_MARK, APLOG_ERR, r->server, + "no acceptable variant", r->filename); set_neg_headers (r, neg, na_result); store_variant_list (r, neg);
cvs commit: apachen/src/modules/standard mod_negotiation.c
pcs 97/08/23 07:20:36 Modified:src/modules/standard mod_negotiation.c Log: mod_negotiation marks *all* responses (HTTP/1.0) browsers and proxies caching one variant which may not be the correct one for subsequent requests. The issue is that if you are using mod_negotiation in a trivial way to map (say) requests for index onto index.html *with no other variants*, Apache makes your responses non-cacheable when they probably are safely cacheable. This patch makes responses from mod_negotiation cacheable in the following circumstances: * Variants are found by multiviews (i.e. looking on the disk, rather than reading a .var file) AND * there was only one matching variant found on disk AND * request version is HTTP/1.0 or earlier Reviewed By: Roy Fielding, Dean Gaudet Revision ChangesPath 1.55 +9 -1 apachen/src/modules/standard/mod_negotiation.c Index: mod_negotiation.c === RCS file: /export/home/cvs/apachen/src/modules/standard/mod_negotiation.c,v retrieving revision 1.54 retrieving revision 1.55 diff -u -r1.54 -r1.55 --- mod_negotiation.c 1997/08/18 13:12:16 1.54 +++ mod_negotiation.c 1997/08/23 14:20:35 1.55 @@ -227,6 +227,8 @@ array_header *accept_langs; /* accept_recs */ array_header *avail_vars; /* available variants */ +int count_multiviews_variants; /* number of variants found on disk */ + int ua_can_negotiate; /* 1 if ua can do transparent negotiate */ int use_transparent_neg;/* 1 if we are using transparent neg */ int short_accept_headers; /* 1 if ua does trans neg & sent short accpt */ @@ -649,6 +651,9 @@ char buffer[MAX_STRING_LEN]; enum header_state hstate; struct var_rec mime_info; + +/* We are not using multiviews */ +neg->count_multiviews_variants = 0; if (rr->status != HTTP_OK) { return rr->status; @@ -809,6 +814,8 @@ new_var = push_array (neg->avail_vars); memcpy (new_var, (void *)&mime_info, sizeof (var_rec)); + + neg->count_multiviews_variants++; clean_var_rec(&mime_info); } @@ -1994,7 +2001,8 @@ /* Otherwise, use it. */ -if (!do_cache_negotiated_docs(r->server) && (r->proto_num < 1001)) +if ((!do_cache_negotiated_docs(r->server) && (r->proto_num < 1001)) + && neg->count_multiviews_variants != 1) r->no_cache = 1; if (na_result == na_not_applied)