X-Git-Url: http://git.pld-linux.org/?a=blobdiff_plain;f=apache-ipv6-PLD.patch;h=13ab0b34cf4255b097d4b9a8cb0920ea581cc884;hb=7e18288880913b10e6b2b8a0a741b9f98c54d839;hp=01957d9cd47b1a8dc363e89cc408b24d21891736;hpb=e48af0751db51236f946ff639b6f0ec5cd1dff8d;p=packages%2Fapache.git diff --git a/apache-ipv6-PLD.patch b/apache-ipv6-PLD.patch index 01957d9..13ab0b3 100644 --- a/apache-ipv6-PLD.patch +++ b/apache-ipv6-PLD.patch @@ -1,6 +1,6 @@ -diff -Nur apache_1.3.23.orig/README.v6 apache_1.3.23/README.v6 ---- apache_1.3.23.orig/README.v6 Thu Jan 1 01:00:00 1970 -+++ apache_1.3.23/README.v6 Wed Feb 6 20:20:48 2002 +diff -Nur apache_1.3.28.orig/README.v6 apache_1.3.28/README.v6 +--- apache_1.3.28.orig/README.v6 Thu Jan 1 01:00:00 1970 ++++ apache_1.3.28/README.v6 Fri Jul 25 11:01:55 2003 @@ -0,0 +1,166 @@ +IPv6-ready apache 1.3.x +KAME Project @@ -168,9 +168,9 @@ diff -Nur apache_1.3.23.orig/README.v6 apache_1.3.23/README.v6 + http://www.v6.linux.or.jp/ + YOSHIFUJI Hideaki, USAGI Project + http://www.linux-ipv6.org/ -diff -Nur apache_1.3.23.orig/conf/httpd.conf-dist apache_1.3.23/conf/httpd.conf-dist ---- apache_1.3.23.orig/conf/httpd.conf-dist Wed Jan 9 17:05:31 2002 -+++ apache_1.3.23/conf/httpd.conf-dist Wed Feb 6 20:20:48 2002 +diff -Nur apache_1.3.28.orig/conf/httpd.conf-dist apache_1.3.28/conf/httpd.conf-dist +--- apache_1.3.28.orig/conf/httpd.conf-dist Wed Jul 16 21:36:41 2003 ++++ apache_1.3.28/conf/httpd.conf-dist Fri Jul 25 11:01:55 2003 @@ -174,6 +174,11 @@ #Listen 3000 #Listen 12.34.56.78:80 @@ -183,16 +183,16 @@ diff -Nur apache_1.3.23.orig/conf/httpd.conf-dist apache_1.3.23/conf/httpd.conf- # # BindAddress: You can support virtual hosts with this option. This directive # is used to tell the server which IP address to listen to. It can either -diff -Nur apache_1.3.23.orig/configure.v6 apache_1.3.23/configure.v6 ---- apache_1.3.23.orig/configure.v6 Thu Jan 1 01:00:00 1970 -+++ apache_1.3.23/configure.v6 Wed Feb 6 20:20:48 2002 +diff -Nur apache_1.3.28.orig/configure.v6 apache_1.3.28/configure.v6 +--- apache_1.3.28.orig/configure.v6 Thu Jan 1 01:00:00 1970 ++++ apache_1.3.28/configure.v6 Fri Jul 25 11:01:55 2003 @@ -0,0 +1,3 @@ +#! /bin/sh + +./configure --enable-rule=INET6 --enable-module=proxy $* -diff -Nur apache_1.3.23.orig/src/Configuration.tmpl apache_1.3.23/src/Configuration.tmpl ---- apache_1.3.23.orig/src/Configuration.tmpl Wed Feb 6 20:17:43 2002 -+++ apache_1.3.23/src/Configuration.tmpl Wed Feb 6 20:21:56 2002 +diff -Nur apache_1.3.28.orig/src/Configuration.tmpl apache_1.3.28/src/Configuration.tmpl +--- apache_1.3.28.orig/src/Configuration.tmpl Fri Jul 25 11:00:49 2003 ++++ apache_1.3.28/src/Configuration.tmpl Fri Jul 25 11:01:55 2003 @@ -191,6 +191,9 @@ # Rule EXPAT=default : If Expat can be found at the system or # in lib/expat-lite, use it; otherwise @@ -211,9 +211,9 @@ diff -Nur apache_1.3.23.orig/src/Configuration.tmpl apache_1.3.23/src/Configurat Rule CYGWIN_WINSOCK=no # DEV_RANDOM: -diff -Nur apache_1.3.23.orig/src/Configure apache_1.3.23/src/Configure ---- apache_1.3.23.orig/src/Configure Wed Feb 6 20:17:43 2002 -+++ apache_1.3.23/src/Configure Wed Feb 6 20:20:48 2002 +diff -Nur apache_1.3.28.orig/src/Configure apache_1.3.28/src/Configure +--- apache_1.3.28.orig/src/Configure Fri Jul 25 11:00:49 2003 ++++ apache_1.3.28/src/Configure Fri Jul 25 11:01:55 2003 @@ -238,6 +238,7 @@ RULE_CYGWIN_WINSOCK=`./helpers/CutRule CYGWIN_WINSOCK $file` RULE_SHARED_CORE=`./helpers/CutRule SHARED_CORE $file` @@ -222,7 +222,7 @@ diff -Nur apache_1.3.23.orig/src/Configure apache_1.3.23/src/Configure #################################################################### ## Rule SHARED_CORE implies required DSO support -@@ -1698,6 +1699,124 @@ +@@ -1724,6 +1725,124 @@ esac fi @@ -347,7 +347,7 @@ diff -Nur apache_1.3.23.orig/src/Configure apache_1.3.23/src/Configure #################################################################### ## Find out what modules we want and try and configure things for them ## Module lines can look like this: -@@ -2293,6 +2412,38 @@ +@@ -2320,6 +2439,38 @@ echo "#define AP_LONGEST_LONG $AP_LONGEST_LONG" >>$AP_CONFIG_AUTO_H echo "#endif" >>$AP_CONFIG_AUTO_H @@ -386,9 +386,9 @@ diff -Nur apache_1.3.23.orig/src/Configure apache_1.3.23/src/Configure #################################################################### ## More building ap_config_auto.h ## -diff -Nur apache_1.3.23.orig/src/ap/ap_snprintf.c apache_1.3.23/src/ap/ap_snprintf.c ---- apache_1.3.23.orig/src/ap/ap_snprintf.c Mon Jan 21 22:56:43 2002 -+++ apache_1.3.23/src/ap/ap_snprintf.c Wed Feb 6 20:20:48 2002 +diff -Nur apache_1.3.28.orig/src/ap/ap_snprintf.c apache_1.3.28/src/ap/ap_snprintf.c +--- apache_1.3.28.orig/src/ap/ap_snprintf.c Mon Feb 3 18:13:17 2003 ++++ apache_1.3.28/src/ap/ap_snprintf.c Fri Jul 25 11:01:55 2003 @@ -73,6 +73,7 @@ #include #include @@ -397,7 +397,7 @@ diff -Nur apache_1.3.23.orig/src/ap/ap_snprintf.c apache_1.3.23/src/ap/ap_snprin #ifdef WIN32 #include #endif -@@ -504,6 +505,42 @@ +@@ -510,6 +511,42 @@ @@ -440,7 +440,7 @@ diff -Nur apache_1.3.23.orig/src/ap/ap_snprintf.c apache_1.3.23/src/ap/ap_snprin /* * Convert a floating point number to a string formats 'f', 'e' or 'E'. * The result is placed in buf, and len denotes the length of the string -@@ -1055,6 +1092,7 @@ +@@ -1057,6 +1094,7 @@ /* print a struct sockaddr_in as a.b.c.d:port */ case 'I': { @@ -448,7 +448,7 @@ diff -Nur apache_1.3.23.orig/src/ap/ap_snprintf.c apache_1.3.23/src/ap/ap_snprin struct sockaddr_in *si; si = va_arg(ap, struct sockaddr_in *); -@@ -1063,6 +1101,16 @@ +@@ -1065,6 +1103,16 @@ if (adjust_precision && precision < s_len) s_len = precision; } @@ -465,10 +465,10 @@ diff -Nur apache_1.3.23.orig/src/ap/ap_snprintf.c apache_1.3.23/src/ap/ap_snprin else { s = S_NULL; s_len = S_NULL_LEN; -diff -Nur apache_1.3.23.orig/src/include/ap.h apache_1.3.23/src/include/ap.h ---- apache_1.3.23.orig/src/include/ap.h Mon Jan 21 22:56:43 2002 -+++ apache_1.3.23/src/include/ap.h Wed Feb 6 20:20:48 2002 -@@ -91,7 +91,8 @@ +diff -Nur apache_1.3.28.orig/src/include/ap.h apache_1.3.28/src/include/ap.h +--- apache_1.3.28.orig/src/include/ap.h Mon Feb 3 18:13:17 2003 ++++ apache_1.3.28/src/include/ap.h Fri Jul 25 11:01:55 2003 +@@ -95,7 +95,8 @@ * with some extensions. The extensions are: * * %pA takes a struct in_addr *, and prints it as a.b.c.d @@ -478,10 +478,10 @@ diff -Nur apache_1.3.23.orig/src/include/ap.h apache_1.3.23/src/include/ap.h * %pp takes a void * and outputs it in hex * * The %p hacks are to force gcc's printf warning code to skip -diff -Nur apache_1.3.23.orig/src/include/ap_config.h apache_1.3.23/src/include/ap_config.h ---- apache_1.3.23.orig/src/include/ap_config.h Thu Jan 17 14:20:51 2002 -+++ apache_1.3.23/src/include/ap_config.h Wed Feb 6 20:20:48 2002 -@@ -407,6 +407,10 @@ +diff -Nur apache_1.3.28.orig/src/include/ap_config.h apache_1.3.28/src/include/ap_config.h +--- apache_1.3.28.orig/src/include/ap_config.h Mon May 5 13:45:49 2003 ++++ apache_1.3.28/src/include/ap_config.h Fri Jul 25 11:01:55 2003 +@@ -411,6 +411,10 @@ #endif #ifndef S_IWOTH #define S_IWOTH 000002 @@ -492,7 +492,7 @@ diff -Nur apache_1.3.23.orig/src/include/ap_config.h apache_1.3.23/src/include/a #endif #define STDIN_FILENO 0 -@@ -1507,6 +1511,70 @@ +@@ -1523,6 +1527,70 @@ #define ap_wait_t int #endif @@ -563,9 +563,9 @@ diff -Nur apache_1.3.23.orig/src/include/ap_config.h apache_1.3.23/src/include/a #ifdef __cplusplus } #endif -diff -Nur apache_1.3.23.orig/src/include/http_conf_globals.h apache_1.3.23/src/include/http_conf_globals.h ---- apache_1.3.23.orig/src/include/http_conf_globals.h Wed Feb 6 20:17:43 2002 -+++ apache_1.3.23/src/include/http_conf_globals.h Wed Feb 6 20:23:09 2002 +diff -Nur apache_1.3.28.orig/src/include/http_conf_globals.h apache_1.3.28/src/include/http_conf_globals.h +--- apache_1.3.28.orig/src/include/http_conf_globals.h Fri Jul 25 11:00:49 2003 ++++ apache_1.3.28/src/include/http_conf_globals.h Fri Jul 25 11:01:55 2003 @@ -82,7 +82,8 @@ extern API_VAR_EXPORT int ap_max_requests_per_child; extern API_VAR_EXPORT int ap_threads_per_child; @@ -576,9 +576,9 @@ diff -Nur apache_1.3.23.orig/src/include/http_conf_globals.h apache_1.3.23/src/i extern listen_rec *ap_listeners; extern API_VAR_EXPORT int ap_daemons_to_start; extern API_VAR_EXPORT int ap_daemons_min_free; -diff -Nur apache_1.3.23.orig/src/include/http_vhost.h apache_1.3.23/src/include/http_vhost.h ---- apache_1.3.23.orig/src/include/http_vhost.h Mon Jan 21 00:13:51 2002 -+++ apache_1.3.23/src/include/http_vhost.h Wed Feb 6 20:23:58 2002 +diff -Nur apache_1.3.28.orig/src/include/http_vhost.h apache_1.3.28/src/include/http_vhost.h +--- apache_1.3.28.orig/src/include/http_vhost.h Mon Feb 3 18:13:19 2003 ++++ apache_1.3.28/src/include/http_vhost.h Fri Jul 25 11:01:55 2003 @@ -73,7 +73,7 @@ API_EXPORT(const char *) ap_parse_vhost_addrs(pool *p, const char *hostname, server_rec *s); @@ -588,10 +588,10 @@ diff -Nur apache_1.3.23.orig/src/include/http_vhost.h apache_1.3.23/src/include/ /* given an ip address only, give our best guess as to what vhost it is */ API_EXPORT(void) ap_update_vhost_given_ip(conn_rec *conn); -diff -Nur apache_1.3.23.orig/src/include/httpd.h apache_1.3.23/src/include/httpd.h ---- apache_1.3.23.orig/src/include/httpd.h Wed Feb 6 20:17:43 2002 -+++ apache_1.3.23/src/include/httpd.h Wed Feb 6 20:24:49 2002 -@@ -912,8 +912,8 @@ +diff -Nur apache_1.3.28.orig/src/include/httpd.h apache_1.3.28/src/include/httpd.h +--- apache_1.3.28.orig/src/include/httpd.h Fri Jul 25 11:00:49 2003 ++++ apache_1.3.28/src/include/httpd.h Fri Jul 25 11:01:55 2003 +@@ -904,8 +904,8 @@ /* Who is the client? */ @@ -602,7 +602,7 @@ diff -Nur apache_1.3.23.orig/src/include/httpd.h apache_1.3.23/src/include/httpd char *remote_ip; /* Client's IP address */ char *remote_host; /* Client's DNS name, if known. * NULL if DNS hasn't been checked, -@@ -955,8 +955,8 @@ +@@ -947,8 +947,8 @@ typedef struct server_addr_rec server_addr_rec; struct server_addr_rec { server_addr_rec *next; @@ -613,7 +613,7 @@ diff -Nur apache_1.3.23.orig/src/include/httpd.h apache_1.3.23/src/include/httpd char *virthost; /* The name given in */ }; -@@ -1024,7 +1024,7 @@ +@@ -1016,7 +1016,7 @@ /* These are more like real hosts than virtual hosts */ struct listen_rec { listen_rec *next; @@ -631,9 +631,9 @@ diff -Nur apache_1.3.23.orig/src/include/httpd.h apache_1.3.23/src/include/httpd extern API_VAR_EXPORT time_t ap_restart_time; -diff -Nur apache_1.3.23.orig/src/include/sa_len.h apache_1.3.23/src/include/sa_len.h ---- apache_1.3.23.orig/src/include/sa_len.h Thu Jan 1 01:00:00 1970 -+++ apache_1.3.23/src/include/sa_len.h Wed Feb 6 20:20:48 2002 +diff -Nur apache_1.3.28.orig/src/include/sa_len.h apache_1.3.28/src/include/sa_len.h +--- apache_1.3.28.orig/src/include/sa_len.h Thu Jan 1 01:00:00 1970 ++++ apache_1.3.28/src/include/sa_len.h Fri Jul 25 11:01:55 2003 @@ -0,0 +1,41 @@ +/* sa_len.h : tiny version of SA_LEN (written by ) */ + @@ -676,9 +676,9 @@ diff -Nur apache_1.3.23.orig/src/include/sa_len.h apache_1.3.23/src/include/sa_l +} +#endif /* SA_LEN */ +#endif /* HAVE_SOCKADDR_LEN */ -diff -Nur apache_1.3.23.orig/src/include/sockaddr_storage.h apache_1.3.23/src/include/sockaddr_storage.h ---- apache_1.3.23.orig/src/include/sockaddr_storage.h Thu Jan 1 01:00:00 1970 -+++ apache_1.3.23/src/include/sockaddr_storage.h Wed Feb 6 20:20:48 2002 +diff -Nur apache_1.3.28.orig/src/include/sockaddr_storage.h apache_1.3.28/src/include/sockaddr_storage.h +--- apache_1.3.28.orig/src/include/sockaddr_storage.h Thu Jan 1 01:00:00 1970 ++++ apache_1.3.28/src/include/sockaddr_storage.h Fri Jul 25 11:01:55 2003 @@ -0,0 +1,53 @@ +/* +struct sockaddr_storage @@ -733,9 +733,9 @@ diff -Nur apache_1.3.23.orig/src/include/sockaddr_storage.h apache_1.3.23/src/in +#define su_port su_si.si_port + +#endif /* NEED_SOCKADDR_STORAGE */ -diff -Nur apache_1.3.23.orig/src/main/getaddrinfo.c apache_1.3.23/src/main/getaddrinfo.c ---- apache_1.3.23.orig/src/main/getaddrinfo.c Thu Jan 1 01:00:00 1970 -+++ apache_1.3.23/src/main/getaddrinfo.c Wed Feb 6 20:20:48 2002 +diff -Nur apache_1.3.28.orig/src/main/getaddrinfo.c apache_1.3.28/src/main/getaddrinfo.c +--- apache_1.3.28.orig/src/main/getaddrinfo.c Thu Jan 1 01:00:00 1970 ++++ apache_1.3.28/src/main/getaddrinfo.c Fri Jul 25 11:01:55 2003 @@ -0,0 +1,162 @@ +/* + * Copyright (C) 1995, 1996, 1997, 1998, and 1999 WIDE Project. @@ -899,9 +899,9 @@ diff -Nur apache_1.3.23.orig/src/main/getaddrinfo.c apache_1.3.23/src/main/getad + } + return EAI_NODATA; +} -diff -Nur apache_1.3.23.orig/src/main/getnameinfo.c apache_1.3.23/src/main/getnameinfo.c ---- apache_1.3.23.orig/src/main/getnameinfo.c Thu Jan 1 01:00:00 1970 -+++ apache_1.3.23/src/main/getnameinfo.c Wed Feb 6 20:20:48 2002 +diff -Nur apache_1.3.28.orig/src/main/getnameinfo.c apache_1.3.28/src/main/getnameinfo.c +--- apache_1.3.28.orig/src/main/getnameinfo.c Thu Jan 1 01:00:00 1970 ++++ apache_1.3.28/src/main/getnameinfo.c Fri Jul 25 11:01:55 2003 @@ -0,0 +1,95 @@ +/* + * Copyright (C) 1995, 1996, 1997, 1998, and 1999 WIDE Project. @@ -998,10 +998,10 @@ diff -Nur apache_1.3.23.orig/src/main/getnameinfo.c apache_1.3.23/src/main/getna + return EAI_NODATA; + return 0; +} -diff -Nur apache_1.3.23.orig/src/main/http_config.c apache_1.3.23/src/main/http_config.c ---- apache_1.3.23.orig/src/main/http_config.c Wed Feb 6 20:17:43 2002 -+++ apache_1.3.23/src/main/http_config.c Wed Feb 6 20:28:01 2002 -@@ -1564,7 +1564,6 @@ +diff -Nur apache_1.3.28.orig/src/main/http_config.c apache_1.3.28/src/main/http_config.c +--- apache_1.3.28.orig/src/main/http_config.c Fri Jul 25 11:00:49 2003 ++++ apache_1.3.28/src/main/http_config.c Fri Jul 25 11:01:55 2003 +@@ -1591,7 +1591,6 @@ ap_scoreboard_fname = DEFAULT_SCOREBOARD; ap_lock_fname = DEFAULT_LOCKFILE; ap_max_requests_per_child = DEFAULT_MAX_REQUESTS_PER_CHILD; @@ -1009,7 +1009,7 @@ diff -Nur apache_1.3.23.orig/src/main/http_config.c apache_1.3.23/src/main/http_ ap_listeners = NULL; ap_listenbacklog = DEFAULT_LISTENBACKLOG; ap_extended_status = 0; -@@ -1597,7 +1596,13 @@ +@@ -1624,7 +1623,13 @@ s->next = NULL; s->addrs = ap_pcalloc(p, sizeof(server_addr_rec)); /* NOT virtual host; don't match any real network interface */ @@ -1024,7 +1024,7 @@ diff -Nur apache_1.3.23.orig/src/main/http_config.c apache_1.3.23/src/main/http_ s->addrs->host_port = 0; /* matches any port */ s->addrs->virthost = ""; /* must be non-NULL */ s->names = s->wild_names = NULL; -@@ -1616,21 +1621,33 @@ +@@ -1643,21 +1648,33 @@ static void default_listeners(pool *p, server_rec *s) { listen_rec *new; @@ -1063,10 +1063,9 @@ diff -Nur apache_1.3.23.orig/src/main/http_config.c apache_1.3.23/src/main/http_ } -diff -Nur apache_1.3.23.orig/src/main/http_core.c apache_1.3.23/src/main/http_core.c ---- apache_1.3.23.orig/src/main/http_core.c Wed Jan 16 22:34:32 2002 -+++ apache_1.3.23/src/main/http_core.c Wed Feb 6 20:20:48 2002 -@@ -71,6 +71,7 @@ +--- apache_1.3.34/src/main/http_core.c.orig 2005-06-28 20:03:25.000000000 +0200 ++++ apache_1.3.34/src/main/http_core.c 2005-10-18 10:14:09.000000000 +0200 +@@ -28,6 +28,7 @@ #include "util_md5.h" #include "scoreboard.h" #include "fnmatch.h" @@ -1074,8 +1073,17 @@ diff -Nur apache_1.3.23.orig/src/main/http_core.c apache_1.3.23/src/main/http_co #ifdef USE_MMAP_FILES #include -@@ -621,7 +622,9 @@ - /* Code from Harald Hanche-Olsen */ +@@ -570,7 +571,7 @@ + * file if you care. So the adhoc value should do. + */ + return ap_psprintf(r->pool,"%pA%pp%pp%pp%pp", +- &r->connection->local_addr.sin_addr, ++ &((struct sockaddr_in *)&(r->connection->local_addr))->sin_addr, + (void *)ap_user_name, + (void *)ap_listeners, + (void *)ap_server_argv0, +@@ -666,7 +667,9 @@ + */ static ap_inline void do_double_reverse (conn_rec *conn) { - struct hostent *hptr; @@ -1085,8 +1093,8 @@ diff -Nur apache_1.3.23.orig/src/main/http_core.c apache_1.3.23/src/main/http_co if (conn->double_reverse) { /* already done */ -@@ -632,28 +635,51 @@ - conn->double_reverse = -1; +@@ -678,30 +681,54 @@ + conn->remote_host = ""; /* prevent another lookup */ return; } - hptr = gethostbyname(conn->remote_host); @@ -1137,6 +1145,10 @@ diff -Nur apache_1.3.23.orig/src/main/http_core.c apache_1.3.23/src/main/http_co - conn->double_reverse = -1; + conn->double_reverse = ok ? 1 : -1; + freeaddrinfo(res0); + /* invalidate possible reverse-resolved hostname if forward lookup fails */ +- conn->remote_host = ""; ++ if(!ok) ++ conn->remote_host = ""; } API_EXPORT(const char *) ap_get_remote_host(conn_rec *conn, void *dir_config, @@ -1150,7 +1162,7 @@ diff -Nur apache_1.3.23.orig/src/main/http_core.c apache_1.3.23/src/main/http_co /* If we haven't checked the host name, and we want to */ if (dir_config) { -@@ -675,10 +701,14 @@ +@@ -723,10 +750,14 @@ || hostname_lookups != HOSTNAME_LOOKUP_OFF)) { old_stat = ap_update_child_status(conn->child_num, SERVER_BUSY_DNS, (request_rec*)NULL); @@ -1169,7 +1181,7 @@ diff -Nur apache_1.3.23.orig/src/main/http_core.c apache_1.3.23/src/main/http_co ap_str_tolower(conn->remote_host); if (hostname_lookups == HOSTNAME_LOOKUP_DOUBLE) { -@@ -759,6 +789,7 @@ +@@ -804,6 +835,7 @@ { conn_rec *conn = r->connection; core_dir_config *d; @@ -1177,7 +1189,7 @@ diff -Nur apache_1.3.23.orig/src/main/http_core.c apache_1.3.23/src/main/http_co d = (core_dir_config *)ap_get_module_config(r->per_dir_config, &core_module); -@@ -768,23 +799,22 @@ +@@ -813,23 +845,22 @@ } if (d->use_canonical_name == USE_CANONICAL_NAME_DNS) { if (conn->local_host == NULL) { @@ -1213,26 +1225,16 @@ diff -Nur apache_1.3.23.orig/src/main/http_core.c apache_1.3.23/src/main/http_co (void) ap_update_child_status(conn->child_num, old_stat, r); } return conn->local_host; -@@ -803,11 +833,13 @@ - - if (d->use_canonical_name == USE_CANONICAL_NAME_OFF - || d->use_canonical_name == USE_CANONICAL_NAME_DNS) { -- return r->hostname ? ntohs(r->connection->local_addr.sin_port) -- : port; -- } -- /* default */ -- return port; -+ return r->hostname -+ ? ntohs(((struct sockaddr_in *)&r->connection->local_addr)->sin_port) -+ : port; -+ } -+ return r->hostname -+ ? ntohs(((struct sockaddr_in *)&r->connection->local_addr)->sin_port) -+ : port; - } - - API_EXPORT(char *) ap_construct_url(pool *p, const char *uri, -@@ -2539,12 +2571,25 @@ +@@ -841,7 +872,7 @@ + API_EXPORT(unsigned) ap_get_server_port(const request_rec *r) + { + unsigned port; +- unsigned cport = ntohs(r->connection->local_addr.sin_port); ++ unsigned cport = ntohs(((struct sockaddr_in *)&r->connection->local_addr)->sin_port); + core_dir_config *d = + (core_dir_config *)ap_get_module_config(r->per_dir_config, &core_module); + +@@ -2647,12 +2678,25 @@ static const char *set_bind_address(cmd_parms *cmd, void *dummy, char *arg) { @@ -1259,7 +1261,7 @@ diff -Nur apache_1.3.23.orig/src/main/http_core.c apache_1.3.23/src/main/http_co return NULL; } -@@ -2576,44 +2621,70 @@ +@@ -2684,48 +2728,71 @@ return NULL; } @@ -1267,8 +1269,8 @@ diff -Nur apache_1.3.23.orig/src/main/http_core.c apache_1.3.23/src/main/http_co +static const char *set_listener(cmd_parms *cmd, void *dummy, char *h, char *p) { listen_rec *new; -- char *ports; -- unsigned short port; +- char *ports, *endptr; +- long port; + char *host, *port; + struct addrinfo hints, *res; + int error; @@ -1287,18 +1289,19 @@ diff -Nur apache_1.3.23.orig/src/main/http_core.c apache_1.3.23/src/main/http_co - return "Address must end in :"; + host = port = NULL; + if (!p) { -+ port = strrchr(h, ':'); -+ if (port != NULL) { ++ port = strrchr(h, ':'); ++ if (port != NULL) { + if (port == h) { -+ return "Missing IP address"; ++ return "Missing IP address"; + } + else if (port[1] == '\0') { -+ return "Address must end in :"; ++ return "Address must end in :"; + } + *(port++) = '\0'; + if (*h) + host = h; -+ } else { ++ } ++ else { + host = NULL; + port = h; } @@ -1319,9 +1322,13 @@ diff -Nur apache_1.3.23.orig/src/main/http_core.c apache_1.3.23/src/main/http_co - else { - new->local_addr.sin_addr.s_addr = ap_get_virthost_addr(ips, NULL); - } -- port = atoi(ports); -- if (!port) { -- return "Port must be numeric"; +- errno = 0; /* clear errno before calling strtol */ +- port = ap_strtol(ports, &endptr, 10); +- if (errno /* some sort of error */ +- || (endptr && *endptr) /* make sure no trailing characters */ +- || port < 1 || port > 65535) /* underflow/overflow */ +- { +- return "Missing, invalid, or non-numeric port"; + if (host && strcmp(host, "*") == 0) + host = NULL; + @@ -1349,14 +1356,14 @@ diff -Nur apache_1.3.23.orig/src/main/http_core.c apache_1.3.23/src/main/http_co + fprintf(stderr, "resolved to multiple addresses, ambiguous.\n"); + exit(1); } -- new->local_addr.sin_port = htons(port); +- new->local_addr.sin_port = htons((unsigned short)port); + + memcpy(&new->local_addr, res->ai_addr, res->ai_addrlen); + new->fd = -1; new->used = 0; new->next = ap_listeners; -@@ -3328,7 +3399,7 @@ +@@ -3650,7 +3717,7 @@ { "ThreadStackSize", set_threadstacksize, NULL, RSRC_CONF, TAKE1, "Stack size each created thread will use."}, #endif @@ -1365,7 +1372,7 @@ diff -Nur apache_1.3.23.orig/src/main/http_core.c apache_1.3.23/src/main/http_co "A port number or a numeric IP address and a port number"}, { "SendBufferSize", set_send_buffer_size, NULL, RSRC_CONF, TAKE1, "Send buffer size in bytes"}, -@@ -3362,7 +3433,7 @@ +@@ -3684,7 +3751,7 @@ "Name of the config file to be included" }, { "LogLevel", set_loglevel, NULL, RSRC_CONF, TAKE1, "Level of verbosity in error logging" }, @@ -1374,9 +1381,9 @@ diff -Nur apache_1.3.23.orig/src/main/http_core.c apache_1.3.23/src/main/http_co "A numeric IP address:port, or the name of a host" }, #ifdef _OSD_POSIX { "BS2000Account", set_bs2000_account, NULL, RSRC_CONF, TAKE1, -diff -Nur apache_1.3.23.orig/src/main/http_main.c apache_1.3.23/src/main/http_main.c ---- apache_1.3.23.orig/src/main/http_main.c Wed Feb 6 20:17:43 2002 -+++ apache_1.3.23/src/main/http_main.c Wed Feb 6 20:29:52 2002 +diff -Nur apache_1.3.28.orig/src/main/http_main.c apache_1.3.28/src/main/http_main.c +--- apache_1.3.28.orig/src/main/http_main.c Fri Jul 25 11:00:49 2003 ++++ apache_1.3.28/src/main/http_main.c Fri Jul 25 12:13:12 2003 @@ -124,6 +124,8 @@ #include /* for IRIX, FD_SET calls bzero() */ #endif @@ -1400,12 +1407,12 @@ diff -Nur apache_1.3.23.orig/src/main/http_main.c apache_1.3.23/src/main/http_ma API_VAR_EXPORT int ap_daemons_to_start=0; API_VAR_EXPORT int ap_daemons_min_free=0; API_VAR_EXPORT int ap_daemons_max_free=0; -@@ -1384,7 +1391,11 @@ +@@ -1448,7 +1455,11 @@ fprintf(stderr, "Usage: %s [-D name] [-d directory] [-f file]\n", bin); #endif fprintf(stderr, " %s [-C \"directive\"] [-c \"directive\"]\n", pad); -- fprintf(stderr, " %s [-v] [-V] [-h] [-l] [-L] [-S] [-t] [-T]\n", pad); -+ fprintf(stderr, " %s [-v] [-V] [-h] [-l] [-L] [-S] [-t] [-T]" +- fprintf(stderr, " %s [-v] [-V] [-h] [-l] [-L] [-S] [-t] [-T] [-F]\n", pad); ++ fprintf(stderr, " %s [-v] [-V] [-h] [-l] [-L] [-S] [-t] [-T] [-F]" +#ifdef INET6 + " [-46]" +#endif @@ -1413,10 +1420,10 @@ diff -Nur apache_1.3.23.orig/src/main/http_main.c apache_1.3.23/src/main/http_ma fprintf(stderr, "Options:\n"); #ifdef SHARED_CORE fprintf(stderr, " -R directory : specify an alternate location for shared object files\n"); -@@ -1406,6 +1417,10 @@ +@@ -1474,6 +1485,10 @@ + #ifndef WIN32 + fprintf(stderr, " -F : run main process in foreground, for process supervisors\n"); #endif - fprintf(stderr, " -t : run syntax check for config files (with docroot check)\n"); - fprintf(stderr, " -T : run syntax check for config files (without docroot check)\n"); +#ifdef INET6 + fprintf(stderr, " -4 : assume IPv4 on parsing configuration file\n"); + fprintf(stderr, " -6 : assume IPv6 on parsing configuration file\n"); @@ -1424,7 +1431,7 @@ diff -Nur apache_1.3.23.orig/src/main/http_main.c apache_1.3.23/src/main/http_ma #ifdef WIN32 fprintf(stderr, " -n name : name the Apache service for -k options below;\n"); fprintf(stderr, " -k stop|shutdown : tell running Apache to shutdown\n"); -@@ -3566,11 +3581,13 @@ +@@ -3630,11 +3645,13 @@ static conn_rec *new_connection(pool *p, server_rec *server, BUFF *inout, @@ -1440,7 +1447,7 @@ diff -Nur apache_1.3.23.orig/src/main/http_main.c apache_1.3.23/src/main/http_ma /* Got a connection structure, so initialize what fields we can * (the rest are zeroed out by pcalloc). -@@ -3579,17 +3596,29 @@ +@@ -3643,17 +3660,29 @@ conn->child_num = child_num; conn->pool = p; @@ -1476,8 +1483,8 @@ diff -Nur apache_1.3.23.orig/src/main/http_main.c apache_1.3.23/src/main/http_ma #ifdef EAPI conn->ctx = ap_ctx_new(conn->pool); #endif /* EAPI */ -@@ -3640,21 +3669,47 @@ - #define sock_disable_nagle(s) /* NOOP */ +@@ -3711,21 +3740,47 @@ + #define sock_disable_nagle(s, c) /* NOOP */ #endif -static int make_sock(pool *p, const struct sockaddr_in *server) @@ -1532,7 +1539,7 @@ diff -Nur apache_1.3.23.orig/src/main/http_main.c apache_1.3.23/src/main/http_ma ap_log_error(APLOG_MARK, APLOG_CRIT, server_conf, "make_sock: failed to get a socket for %s", addr); -@@ -3757,15 +3812,19 @@ +@@ -3828,15 +3883,19 @@ #ifdef MPE /* MPE requires CAP=PM and GETPRIVMODE to bind to ports less than 1024 */ @@ -1556,7 +1563,7 @@ diff -Nur apache_1.3.23.orig/src/main/http_main.c apache_1.3.23/src/main/http_ma GETUSERMODE(); #endif -@@ -3778,7 +3837,7 @@ +@@ -3849,7 +3908,7 @@ exit(1); } #ifdef MPE @@ -1565,7 +1572,7 @@ diff -Nur apache_1.3.23.orig/src/main/http_main.c apache_1.3.23/src/main/http_ma GETUSERMODE(); #endif -@@ -3931,15 +3990,17 @@ +@@ -4002,15 +4061,17 @@ for (;;) { fd = find_listener(lr); if (fd < 0) { @@ -1573,7 +1580,7 @@ diff -Nur apache_1.3.23.orig/src/main/http_main.c apache_1.3.23/src/main/http_ma + fd = make_sock(p, (struct sockaddr *)&lr->local_addr); } else { - ap_note_cleanups_for_socket(p, fd); + ap_note_cleanups_for_socket_ex(p, fd, 1); } /* if we get here, (fd >= 0) && (fd < FD_SETSIZE) */ - FD_SET(fd, &listenfds); @@ -1582,12 +1589,12 @@ diff -Nur apache_1.3.23.orig/src/main/http_main.c apache_1.3.23/src/main/http_ma + if (fd > 0) { + FD_SET(fd, &listenfds); + if (fd > listenmaxfd) -+ listenmaxfd = fd; ++ listenmaxfd = fd; + } lr->fd = fd; if (lr->next == NULL) break; -@@ -4257,8 +4318,8 @@ +@@ -4327,8 +4388,8 @@ static void child_main(int child_num_arg) { NET_SIZE_T clen; @@ -1598,7 +1605,7 @@ diff -Nur apache_1.3.23.orig/src/main/http_main.c apache_1.3.23/src/main/http_ma listen_rec *lr; /* All of initialization is a critical section, we don't care if we're -@@ -4423,7 +4484,7 @@ +@@ -4505,7 +4566,7 @@ usr1_just_die = 0; for (;;) { clen = sizeof(sa_client); @@ -1607,16 +1614,16 @@ diff -Nur apache_1.3.23.orig/src/main/http_main.c apache_1.3.23/src/main/http_ma if (csd >= 0 || errno != EINTR) break; if (deferred_die) { -@@ -4586,7 +4647,7 @@ +@@ -4671,7 +4732,7 @@ */ clen = sizeof(sa_server); - if (getsockname(csd, &sa_server, &clen) < 0) { + if (getsockname(csd, (struct sockaddr *)&sa_server, &clen) < 0) { - ap_log_error(APLOG_MARK, APLOG_ERR, server_conf, "getsockname"); - continue; - } -@@ -4631,8 +4692,8 @@ + ap_log_error(APLOG_MARK, APLOG_DEBUG, server_conf, + "getsockname, client %pA probably dropped the " + "connection", +@@ -4719,8 +4780,8 @@ ap_bpushfd(conn_io, csd, dupped_csd); current_conn = new_connection(ptrans, server_conf, conn_io, @@ -1627,7 +1634,7 @@ diff -Nur apache_1.3.23.orig/src/main/http_main.c apache_1.3.23/src/main/http_ma my_child_num); /* -@@ -4776,12 +4837,13 @@ +@@ -4875,12 +4936,13 @@ #ifdef _OSD_POSIX /* BS2000 requires a "special" version of fork() before a setuid() call */ @@ -1644,19 +1651,19 @@ diff -Nur apache_1.3.23.orig/src/main/http_main.c apache_1.3.23/src/main/http_ma ap_log_error(APLOG_MARK, APLOG_ERR, s, "fork: Unable to fork new process"); /* fork didn't succeed. Fix the scoreboard or else -@@ -5390,7 +5452,10 @@ +@@ -5497,7 +5559,10 @@ ap_setup_prelinked_modules(); while ((c = getopt(argc, argv, -- "D:C:c:xXd:f:vVlLR:StTh" -+ "D:C:c:xXd:f:vVlLR:StTh4" +- "D:C:c:xXd:Ff:vVlLR:StTh" ++ "D:C:c:xXd:Ff:vVlLR:StTh4" +#ifdef INET6 + "6" +#endif #ifdef DEBUG_SIGSTOP "Z:" #endif -@@ -5465,8 +5530,14 @@ +@@ -5575,8 +5640,14 @@ ap_configtestonly = 1; ap_docrootcheck = 0; break; @@ -1673,7 +1680,7 @@ diff -Nur apache_1.3.23.orig/src/main/http_main.c apache_1.3.23/src/main/http_ma case '?': usage(argv[0]); } -@@ -5546,9 +5617,10 @@ +@@ -5665,9 +5736,10 @@ else { conn_rec *conn; request_rec *r; @@ -1685,7 +1692,7 @@ diff -Nur apache_1.3.23.orig/src/main/http_main.c apache_1.3.23/src/main/http_ma ap_set_version(); /* Yes this is called twice. */ -@@ -5595,25 +5667,32 @@ +@@ -5722,25 +5794,32 @@ #endif l = sizeof(sa_client); @@ -1723,20 +1730,20 @@ diff -Nur apache_1.3.23.orig/src/main/http_main.c apache_1.3.23/src/main/http_ma while ((r = ap_read_request(conn)) != NULL) { -@@ -7820,7 +7899,11 @@ - * but only handle the -L option - */ - llp_dir = SHARED_CORE_DIR; -- while ((c = getopt(argc, argv, "D:C:c:Xd:f:vVlLR:SZ:tTh")) != -1) { -+ while ((c = getopt(argc, argv, "D:C:c:Xd:f:vVlLR:SZ:tTh4" +@@ -7447,7 +7526,11 @@ + + while ((c = getopt(argc, argv, "D:C:c:Xd:f:vVlLz:Z:wiuStThk:n:W:")) != -1) { + #else /* !WIN32 */ +- while ((c = getopt(argc, argv, "D:C:c:Xd:Ff:vVlLesStTh")) != -1) { ++ while ((c = getopt(argc, argv, "D:C:c:Xd:Ff:vVlLesStTh4" +#ifdef INET6 + "6" +#endif + )) != -1) { + #endif + char **new; switch (c) { - case 'D': - case 'C': -@@ -7837,6 +7920,10 @@ +@@ -7993,6 +8076,10 @@ case 't': case 'T': case 'h': @@ -1747,10 +1754,9 @@ diff -Nur apache_1.3.23.orig/src/main/http_main.c apache_1.3.23/src/main/http_ma case '?': break; case 'R': -diff -Nur apache_1.3.23.orig/src/main/http_vhost.c apache_1.3.23/src/main/http_vhost.c ---- apache_1.3.23.orig/src/main/http_vhost.c Mon Jan 21 00:13:51 2002 -+++ apache_1.3.23/src/main/http_vhost.c Wed Feb 6 20:30:51 2002 -@@ -68,6 +68,7 @@ +--- apache_1.3.31/src/main/http_vhost.c.orig Mon Mar 29 23:03:25 2004 ++++ apache_1.3.31/src/main/http_vhost.c Wed May 12 13:49:13 2004 +@@ -25,6 +25,7 @@ #include "http_log.h" #include "http_vhost.h" #include "http_protocol.h" @@ -1758,7 +1764,7 @@ diff -Nur apache_1.3.23.orig/src/main/http_vhost.c apache_1.3.23/src/main/http_v /* * After all the definitions there's an explanation of how it's all put -@@ -165,78 +166,114 @@ +@@ -122,78 +123,114 @@ * *paddr is the variable used to keep track of **paddr between calls * port is the default port to assume */ @@ -1922,7 +1928,7 @@ diff -Nur apache_1.3.23.orig/src/main/http_vhost.c apache_1.3.23/src/main/http_v return NULL; } -@@ -250,7 +287,8 @@ +@@ -207,7 +244,8 @@ /* start the list of addreses */ addrs = &s->addrs; while (hostname[0]) { @@ -1932,7 +1938,7 @@ diff -Nur apache_1.3.23.orig/src/main/http_vhost.c apache_1.3.23/src/main/http_v if (err) { *addrs = NULL; return err; -@@ -268,10 +306,11 @@ +@@ -225,10 +263,11 @@ } @@ -1946,7 +1952,7 @@ diff -Nur apache_1.3.23.orig/src/main/http_vhost.c apache_1.3.23/src/main/http_v cmd->server->port); } -@@ -345,6 +384,19 @@ +@@ -302,6 +341,19 @@ return ((key >> 8) ^ key) % IPHASH_TABLE_SIZE; } @@ -1966,7 +1972,7 @@ diff -Nur apache_1.3.23.orig/src/main/http_vhost.c apache_1.3.23/src/main/http_v static ipaddr_chain *new_ipaddr_chain(pool *p, -@@ -372,25 +424,77 @@ +@@ -329,25 +381,77 @@ return new; } @@ -2054,7 +2060,7 @@ diff -Nur apache_1.3.23.orig/src/main/http_vhost.c apache_1.3.23/src/main/http_v return NULL; } -@@ -416,21 +520,7 @@ +@@ -373,21 +477,7 @@ int len; char buf[MAX_STRING_LEN]; @@ -2077,7 +2083,7 @@ diff -Nur apache_1.3.23.orig/src/main/http_vhost.c apache_1.3.23/src/main/http_v if (ic->names == NULL) { if (ic->server == NULL) fprintf(f, "%-22s WARNING: No defined for this NameVirtualHost!\n", buf); -@@ -558,10 +648,37 @@ +@@ -515,10 +605,37 @@ * occured in the config file, we'll copy it in that order. */ for (sar = name_vhost_list; sar; sar = sar->next) { @@ -2085,7 +2091,8 @@ diff -Nur apache_1.3.23.orig/src/main/http_vhost.c apache_1.3.23/src/main/http_v + unsigned bucket = hash_addr((struct sockaddr *)&sar->host_addr); ipaddr_chain *ic = new_ipaddr_chain(p, NULL, sar); + int wildcard; -+ + +- if (sar->host_addr.s_addr != INADDR_ANY) { + wildcard = 0; + switch (sar->host_addr.ss_family) { + case AF_INET: @@ -2111,18 +2118,22 @@ diff -Nur apache_1.3.23.orig/src/main/http_vhost.c apache_1.3.23/src/main/http_v + } +#endif + } - -- if (sar->host_addr.s_addr != INADDR_ANY) { ++ + if (!wildcard) { *iphash_table_tail[bucket] = ic; iphash_table_tail[bucket] = &ic->next; } -@@ -588,12 +705,45 @@ +@@ -545,12 +662,45 @@ has_default_vhost_addr = 0; for (sar = s->addrs; sar; sar = sar->next) { ipaddr_chain *ic; + int wildcard; -+ + +- if (sar->host_addr.s_addr == DEFAULT_VHOST_ADDR +- || sar->host_addr.s_addr == INADDR_ANY) { +- ic = find_default_server(sar->host_port); +- if (!ic || !add_name_vhost_config(p, main_s, s, sar, ic)) { +- if (ic && ic->sar->host_port != 0) { + wildcard = 0; + switch (sar->host_addr.ss_family) { + case AF_INET: @@ -2150,12 +2161,7 @@ diff -Nur apache_1.3.23.orig/src/main/http_vhost.c apache_1.3.23/src/main/http_v + } +#endif + } - -- if (sar->host_addr.s_addr == DEFAULT_VHOST_ADDR -- || sar->host_addr.s_addr == INADDR_ANY) { -- ic = find_default_server(sar->host_port); -- if (!ic || !add_name_vhost_config(p, main_s, s, sar, ic)) { -- if (ic && ic->sar->host_port != 0) { ++ + if (wildcard) { + /* add it to default bucket for each appropriate sar + * since we need to do a port test @@ -2168,7 +2174,7 @@ diff -Nur apache_1.3.23.orig/src/main/http_vhost.c apache_1.3.23/src/main/http_v ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, main_s, "_default_ VirtualHost overlap on port %u," " the first has precedence", sar->host_port); -@@ -606,10 +756,11 @@ +@@ -563,10 +713,11 @@ } else { /* see if it matches something we've already got */ @@ -2182,7 +2188,7 @@ diff -Nur apache_1.3.23.orig/src/main/http_vhost.c apache_1.3.23/src/main/http_v ic = new_ipaddr_chain(p, s, sar); ic->next = *iphash_table_tail[bucket]; -@@ -646,19 +797,33 @@ +@@ -603,19 +754,33 @@ } else { struct hostent *h; @@ -2221,11 +2227,11 @@ diff -Nur apache_1.3.23.orig/src/main/http_vhost.c apache_1.3.23/src/main/http_v s->server_hostname = ap_pstrdup(p, "bogus_host_without_reverse_dns"); } -@@ -705,35 +870,58 @@ - char *host = ap_palloc(r->pool, strlen(r->hostname) + 1); +@@ -663,45 +828,80 @@ const char *src; char *dst; -+ const char *u = NULL, *v = NULL; + const char *port_str; ++ const char *u, *v = NULL; /* check and copy the host part */ - src = r->hostname; @@ -2244,67 +2250,93 @@ diff -Nur apache_1.3.23.orig/src/main/http_vhost.c apache_1.3.23/src/main/http_v - goto bad; - } - if (*src == ':') { +- port_str = src + 1; - /* check the port part */ - while (*++src) { - if (!ap_isdigit(*src)) { -- goto bad; ++ if (*u == '[') { /* IPv6 numeral address in brackets */ ++ v = strchr(u, ']'); ++ if (v == NULL) { ++ /* missing closing bracket */ ++ goto bad; ++ } ++ if (v == (u + 1)) { ++ /* bad empty address */ ++ goto bad; ++ } ++ for (src = u+1; src < v; src++) /* copy IPv6 adress */ ++ *dst = *src; ++ v++; ++ if (*v == ':') { ++ port_str = v + 1; ++ v++; ++ while (*v) { /* check if portnum is correct */ ++ if (!ap_isdigit(*v++)) + goto bad; - } -- } + } - if (src[-1] == ':') -- goto bad; -- else ++ if (v[-1] == ':') ++ goto bad; ++ else { ++ /* a known "good" port value */ ++ int iport; ++ iport = atoi(port_str); ++ if (iport < 1 || iport > 65535) { ++ goto bad; ++ } ++ r->parsed_uri.port_str = ap_pstrdup(r->pool, port_str); ++ r->parsed_uri.port = iport; ++ } ++ } ++ } else { ++ while (*src) { ++ if (*src == '.') { ++ *dst++ = *src++; ++ if (*src == '.') ++ goto bad; ++ else ++ continue; ++ } ++ if (*src == '/' || *src == '\\') { + goto bad; +- else { +- /* a known "good" port value */ +- int iport; +- iport = atoi(port_str); +- if (iport < 1 || iport > 65535) { ++ } ++ if (*src == ':') { ++ port_str = src + 1; ++ /* sheck the port part */ ++ while (*++src) { ++ if (!ap_isdigit(*src)) { ++ goto bad; ++ } ++ } ++ if (src[-1] == ':') + goto bad; ++ else { ++ /* a known "good" port value */ ++ int iport; ++ iport = atoi(port_str); ++ if (iport < 1 || iport > 65535) { ++ goto bad; ++ } ++ r->parsed_uri.port_str = ap_pstrdup(r->pool, port_str); ++ r->parsed_uri.port = iport; + } +- r->parsed_uri.port_str = ap_pstrdup(r->pool, port_str); +- r->parsed_uri.port = iport; - break; -+ if (*u == '[') { /* IPv6 numeral address in brackets */ -+ v = strchr(u, ']'); -+ if (v == NULL) { -+ /* missing closing bracket */ -+ goto bad; -+ } -+ if (v == (u + 1)) { -+ /* bad empty address */ -+ goto bad; -+ } -+ for (src = u+1; src < v; src++) /* copy IPv6 adress */ -+ *dst = *src; -+ v++; -+ if (*v == ':') { -+ v++; -+ while (*v) { /* check if portnum is correct */ -+ if (!ap_isdigit(*v++)) -+ goto bad; -+ } + } ++ *dst++ = *src++; } - *dst++ = *src++; -+ } else { -+ while (*src) { -+ if (*src == '.') { -+ *dst++ = *src++; -+ if (*src == '.') -+ goto bad; -+ else -+ continue; -+ } -+ if (*src == '/' || *src == '\\') { -+ goto bad; -+ } -+ if (*src == ':') { -+ /* sheck the port part */ -+ while (*++src) { -+ if (!ap_isdigit(*src)) { -+ goto bad; -+ } -+ } -+ if (src[-1] == ':') -+ goto bad; -+ else -+ break; -+ } -+ *dst++ = *src++; -+ } } /* strip trailing gubbins */ if (dst > host && dst[-1] == '.') { -@@ -748,7 +936,7 @@ +@@ -716,7 +916,7 @@ bad: r->status = HTTP_BAD_REQUEST; ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, @@ -2313,7 +2345,7 @@ diff -Nur apache_1.3.23.orig/src/main/http_vhost.c apache_1.3.23/src/main/http_v return; } -@@ -851,11 +1039,25 @@ +@@ -819,11 +1019,25 @@ * names we'll match have ports associated with them */ const char *host = r->hostname; @@ -2340,7 +2372,7 @@ diff -Nur apache_1.3.23.orig/src/main/http_vhost.c apache_1.3.23/src/main/http_v last_s = NULL; /* Recall that the name_chain is a list of server_addr_recs, some of -@@ -910,7 +1112,22 @@ +@@ -878,7 +1092,22 @@ server_rec *s; server_rec *last_s; name_chain *src; @@ -2364,7 +2396,7 @@ diff -Nur apache_1.3.23.orig/src/main/http_vhost.c apache_1.3.23/src/main/http_v /* * This is in conjunction with the ServerPath code in http_core, so we -@@ -970,10 +1187,22 @@ +@@ -938,10 +1167,22 @@ API_EXPORT(void) ap_update_vhost_given_ip(conn_rec *conn) { ipaddr_chain *trav; @@ -2389,7 +2421,7 @@ diff -Nur apache_1.3.23.orig/src/main/http_vhost.c apache_1.3.23/src/main/http_v if (trav) { /* save the name_chain for later in case this is a name-vhost */ conn->vhost_lookup_data = trav->names; -@@ -991,6 +1220,7 @@ +@@ -959,6 +1200,7 @@ return; } @@ -2397,9 +2429,9 @@ diff -Nur apache_1.3.23.orig/src/main/http_vhost.c apache_1.3.23/src/main/http_v /* otherwise we're stuck with just the main server * and no name-based vhosts */ -diff -Nur apache_1.3.23.orig/src/main/rfc1413.c apache_1.3.23/src/main/rfc1413.c ---- apache_1.3.23.orig/src/main/rfc1413.c Sun Jan 20 21:14:37 2002 -+++ apache_1.3.23/src/main/rfc1413.c Wed Feb 6 20:20:48 2002 +diff -Nur apache_1.3.28.orig/src/main/rfc1413.c apache_1.3.28/src/main/rfc1413.c +--- apache_1.3.28.orig/src/main/rfc1413.c Mon Feb 3 18:13:23 2003 ++++ apache_1.3.28/src/main/rfc1413.c Fri Jul 25 12:15:05 2003 @@ -82,6 +82,7 @@ #include "http_log.h" /* for aplog_error */ #include "rfc1413.h" @@ -2520,8 +2552,8 @@ diff -Nur apache_1.3.23.orig/src/main/rfc1413.c apache_1.3.23/src/main/rfc1413.c result = FROM_UNKNOWN; -- sock = ap_psocket(conn->pool, AF_INET, SOCK_STREAM, IPPROTO_TCP); -+ sock = ap_psocket(conn->pool, conn->remote_addr.ss_family, SOCK_STREAM, IPPROTO_TCP); +- sock = ap_psocket_ex(conn->pool, AF_INET, SOCK_STREAM, IPPROTO_TCP, 1); ++ sock = ap_psocket_ex(conn->pool, conn->remote_addr.ss_family, SOCK_STREAM, IPPROTO_TCP, 1); if (sock < 0) { ap_log_error(APLOG_MARK, APLOG_CRIT, srv, "socket: rfc1413: error creating socket"); @@ -2537,10 +2569,10 @@ diff -Nur apache_1.3.23.orig/src/main/rfc1413.c apache_1.3.23/src/main/rfc1413.c } ap_set_callback_and_alarm(NULL, 0); ap_pclosesocket(conn->pool, sock); -diff -Nur apache_1.3.23.orig/src/main/util.c apache_1.3.23/src/main/util.c ---- apache_1.3.23.orig/src/main/util.c Fri Dec 28 06:03:07 2001 -+++ apache_1.3.23/src/main/util.c Wed Feb 6 20:36:21 2002 -@@ -1962,52 +1962,87 @@ +diff -Nur apache_1.3.28.orig/src/main/util.c apache_1.3.28/src/main/util.c +--- apache_1.3.28.orig/src/main/util.c Mon Feb 3 18:13:23 2003 ++++ apache_1.3.28/src/main/util.c Fri Jul 25 11:01:55 2003 +@@ -2017,52 +2017,87 @@ * Parses a host of the form
[:port] * :port is permitted if 'port' is not NULL */ @@ -2653,7 +2685,7 @@ diff -Nur apache_1.3.23.orig/src/main/util.c apache_1.3.23/src/main/util.c } -@@ -2035,7 +2070,8 @@ +@@ -2090,7 +2125,8 @@ #endif char str[MAXHOSTNAMELEN]; char *server_hostname = NULL; @@ -2663,7 +2695,7 @@ diff -Nur apache_1.3.23.orig/src/main/util.c apache_1.3.23/src/main/util.c #ifdef BEOS /* BeOS returns zero as an error for gethostname */ if (gethostname(str, sizeof(str) - 1) == 0) { -@@ -2048,29 +2084,38 @@ +@@ -2103,29 +2139,38 @@ } else { @@ -2725,16 +2757,7 @@ diff -Nur apache_1.3.23.orig/src/main/util.c apache_1.3.23/src/main/util.c return server_hostname; } -@@ -2149,7 +2194,7 @@ - char *quote_doubled_str, *dest; - - while (str[len]) { -- num_quotes += str[len++] == '\"'; -+ num_quotes += str[len++] == '\"'; - } - - quote_doubled_str = ap_palloc(p, len + num_quotes + 1); -@@ -2274,3 +2319,11 @@ +@@ -2369,3 +2414,11 @@ } *dest = 0; } @@ -2746,9 +2769,9 @@ diff -Nur apache_1.3.23.orig/src/main/util.c apache_1.3.23/src/main/util.c +#ifdef NEED_GETNAMEINFO +#include "getnameinfo.c" +#endif -diff -Nur apache_1.3.23.orig/src/main/util_script.c apache_1.3.23/src/main/util_script.c ---- apache_1.3.23.orig/src/main/util_script.c Fri Oct 12 01:37:39 2001 -+++ apache_1.3.23/src/main/util_script.c Wed Feb 6 20:20:48 2002 +diff -Nur apache_1.3.28.orig/src/main/util_script.c apache_1.3.28/src/main/util_script.c +--- apache_1.3.28.orig/src/main/util_script.c Mon Feb 3 18:13:23 2003 ++++ apache_1.3.28/src/main/util_script.c Fri Jul 25 11:01:55 2003 @@ -67,6 +67,7 @@ #include "http_request.h" /* for sub_req_lookup_uri() */ #include "util_script.h" @@ -2757,7 +2780,7 @@ diff -Nur apache_1.3.23.orig/src/main/util_script.c apache_1.3.23/src/main/util_ #ifdef OS2 #define INCL_DOS -@@ -208,6 +209,7 @@ +@@ -203,6 +204,7 @@ array_header *hdrs_arr = ap_table_elts(r->headers_in); table_entry *hdrs = (table_entry *) hdrs_arr->elts; int i; @@ -2765,7 +2788,7 @@ diff -Nur apache_1.3.23.orig/src/main/util_script.c apache_1.3.23/src/main/util_ /* use a temporary table which we'll overlap onto * r->subprocess_env later -@@ -298,8 +300,16 @@ +@@ -294,8 +296,16 @@ ap_table_addn(e, "SERVER_ADMIN", s->server_admin); /* Apache */ ap_table_addn(e, "SCRIPT_FILENAME", r->filename); /* Apache */ @@ -2784,10 +2807,10 @@ diff -Nur apache_1.3.23.orig/src/main/util_script.c apache_1.3.23/src/main/util_ if (c->user) { ap_table_addn(e, "REMOTE_USER", c->user); -diff -Nur apache_1.3.23.orig/src/main/util_uri.c apache_1.3.23/src/main/util_uri.c ---- apache_1.3.23.orig/src/main/util_uri.c Sun Jan 20 21:14:37 2002 -+++ apache_1.3.23/src/main/util_uri.c Wed Feb 6 20:20:48 2002 -@@ -419,6 +419,12 @@ +diff -Nur apache_1.3.28.orig/src/main/util_uri.c apache_1.3.28/src/main/util_uri.c +--- apache_1.3.28.orig/src/main/util_uri.c Mon Feb 3 18:13:24 2003 ++++ apache_1.3.28/src/main/util_uri.c Fri Jul 25 11:01:55 2003 +@@ -424,6 +424,12 @@ * the hostname. If there's a port it is the first colon. */ s = memchr(hostinfo, ':', uri - hostinfo); @@ -2800,7 +2823,7 @@ diff -Nur apache_1.3.23.orig/src/main/util_uri.c apache_1.3.23/src/main/util_uri if (s == NULL) { /* we expect the common case to have no port */ uptr->hostname = ap_pstrndup(p, hostinfo, uri - hostinfo); -@@ -475,7 +481,12 @@ +@@ -480,7 +486,12 @@ /* We expect hostinfo to point to the first character of * the hostname. There must be a port, separated by a colon */ @@ -2814,10 +2837,10 @@ diff -Nur apache_1.3.23.orig/src/main/util_uri.c apache_1.3.23/src/main/util_uri if (s == NULL) { return HTTP_BAD_REQUEST; } -diff -Nur apache_1.3.23.orig/src/modules/proxy/mod_proxy.c apache_1.3.23/src/modules/proxy/mod_proxy.c ---- apache_1.3.23.orig/src/modules/proxy/mod_proxy.c Wed Feb 6 20:17:43 2002 -+++ apache_1.3.23/src/modules/proxy/mod_proxy.c Wed Feb 6 20:38:49 2002 -@@ -556,11 +556,31 @@ +diff -Nur apache_1.3.28.orig/src/modules/proxy/mod_proxy.c apache_1.3.28/src/modules/proxy/mod_proxy.c +--- apache_1.3.28.orig/src/modules/proxy/mod_proxy.c Fri Jul 25 11:00:49 2003 ++++ apache_1.3.28/src/modules/proxy/mod_proxy.c Fri Jul 25 11:01:55 2003 +@@ -574,11 +574,31 @@ struct proxy_remote *new; char *p, *q; int port; @@ -2850,16 +2873,16 @@ diff -Nur apache_1.3.23.orig/src/modules/proxy/mod_proxy.c apache_1.3.23/src/mod if (q != NULL) { if (sscanf(q + 1, "%u", &port) != 1 || port > 65535) return "ProxyRemote: Bad syntax for a remote proxy server (bad port number)"; -@@ -571,7 +591,7 @@ +@@ -589,7 +609,7 @@ *p = '\0'; if (strchr(f, ':') == NULL) - ap_str_tolower(f); /* lowercase scheme */ -- ap_str_tolower(p + 3); /* lowercase hostname */ -+ ap_str_tolower(bl); /* lowercase hostname */ + ap_str_tolower(f); /* lowercase scheme */ +- ap_str_tolower(p + 3); /* lowercase hostname */ ++ ap_str_tolower(bl); /* lowercase hostname */ if (port == -1) { int i; -@@ -584,7 +604,7 @@ +@@ -602,7 +622,7 @@ new = ap_push_array(conf->proxies); new->scheme = f; new->protocol = r; @@ -2868,10 +2891,10 @@ diff -Nur apache_1.3.23.orig/src/modules/proxy/mod_proxy.c apache_1.3.23/src/mod new->port = port; return NULL; } -diff -Nur apache_1.3.23.orig/src/modules/proxy/mod_proxy.h apache_1.3.23/src/modules/proxy/mod_proxy.h ---- apache_1.3.23.orig/src/modules/proxy/mod_proxy.h Fri Jan 18 21:26:58 2002 -+++ apache_1.3.23/src/modules/proxy/mod_proxy.h Wed Feb 6 20:20:48 2002 -@@ -308,7 +308,7 @@ +diff -Nur apache_1.3.28.orig/src/modules/proxy/mod_proxy.h apache_1.3.28/src/modules/proxy/mod_proxy.h +--- apache_1.3.28.orig/src/modules/proxy/mod_proxy.h Mon Feb 3 18:13:26 2003 ++++ apache_1.3.28/src/modules/proxy/mod_proxy.h Fri Jul 25 11:01:55 2003 +@@ -310,7 +310,7 @@ int ap_proxy_is_domainname(struct dirconn_entry *This, pool *p); int ap_proxy_is_hostname(struct dirconn_entry *This, pool *p); int ap_proxy_is_word(struct dirconn_entry *This, pool *p); @@ -2880,357 +2903,11 @@ diff -Nur apache_1.3.23.orig/src/modules/proxy/mod_proxy.h apache_1.3.23/src/mod int ap_proxy_garbage_init(server_rec *, pool *); /* This function is called by ap_table_do() for all header lines */ int ap_proxy_send_hdr_line(void *p, const char *key, const char *value); -diff -Nur apache_1.3.23.orig/src/modules/proxy/mod_proxy.h.orig apache_1.3.23/src/modules/proxy/mod_proxy.h.orig ---- apache_1.3.23.orig/src/modules/proxy/mod_proxy.h.orig Thu Jan 1 01:00:00 1970 -+++ apache_1.3.23/src/modules/proxy/mod_proxy.h.orig Fri Jan 18 21:26:58 2002 -@@ -0,0 +1,342 @@ -+/* ==================================================================== -+ * The Apache Software License, Version 1.1 -+ * -+ * Copyright (c) 2000 The Apache Software Foundation. All rights -+ * reserved. -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * 3. The end-user documentation included with the redistribution, -+ * if any, must include the following acknowledgment: -+ * "This product includes software developed by the -+ * Apache Software Foundation (http://www.apache.org/)." -+ * Alternately, this acknowledgment may appear in the software itself, -+ * if and wherever such third-party acknowledgments normally appear. -+ * -+ * 4. The names "Apache" and "Apache Software Foundation" must -+ * not be used to endorse or promote products derived from this -+ * software without prior written permission. For written -+ * permission, please contact apache@apache.org. -+ * -+ * 5. Products derived from this software may not be called "Apache", -+ * nor may "Apache" appear in their name, without prior written -+ * permission of the Apache Software Foundation. -+ * -+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED -+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR -+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -+ * SUCH DAMAGE. -+ * ==================================================================== -+ * -+ * This software consists of voluntary contributions made by many -+ * individuals on behalf of the Apache Software Foundation. For more -+ * information on the Apache Software Foundation, please see -+ * . -+ * -+ * Portions of this software are based upon public domain software -+ * originally written at the National Center for Supercomputing Applications, -+ * University of Illinois, Urbana-Champaign. -+ */ -+ -+#ifndef MOD_PROXY_H -+#define MOD_PROXY_H -+ -+/* -+ * Main include file for the Apache proxy -+ */ -+ -+/* -+ -+ Note numerous FIXMEs and CHECKMEs which should be eliminated. -+ -+ If TESTING is set, then garbage collection doesn't delete ... probably a good -+ idea when hacking. -+ -+ */ -+ -+#define TESTING 0 -+ -+#include "httpd.h" -+#include "http_config.h" -+#include "http_protocol.h" -+ -+#include "explain.h" -+ -+extern module MODULE_VAR_EXPORT proxy_module; -+ -+ -+/* for proxy_canonenc() */ -+enum enctype { -+ enc_path, enc_search, enc_user, enc_fpath, enc_parm -+}; -+ -+#define HDR_APP (0) /* append header, for proxy_add_header() */ -+#define HDR_REP (1) /* replace header, for proxy_add_header() */ -+ -+/* number of characters in the hash */ -+#define HASH_LEN (22*2) -+ -+/* maximum 'CacheDirLevels*CacheDirLength' value */ -+#define CACHEFILE_LEN 20 /* must be less than HASH_LEN/2 */ -+ -+#define SEC_ONE_DAY 86400 /* one day, in seconds */ -+#define SEC_ONE_HR 3600 /* one hour, in seconds */ -+ -+#define DEFAULT_FTP_DATA_PORT 20 -+#define DEFAULT_FTP_PORT 21 -+#define DEFAULT_GOPHER_PORT 70 -+#define DEFAULT_NNTP_PORT 119 -+#define DEFAULT_WAIS_PORT 210 -+#define DEFAULT_HTTPS_PORT 443 -+#define DEFAULT_SNEWS_PORT 563 -+#define DEFAULT_PROSPERO_PORT 1525 /* WARNING: conflict w/Oracle */ -+ -+/* Some WWW schemes and their default ports; this is basically /etc/services */ -+struct proxy_services { -+ const char *scheme; -+ int port; -+}; -+ -+/* static information about a remote proxy */ -+struct proxy_remote { -+ const char *scheme; /* the schemes handled by this proxy, or '*' */ -+ const char *protocol; /* the scheme used to talk to this proxy */ -+ const char *hostname; /* the hostname of this proxy */ -+ int port; /* the port for this proxy */ -+}; -+ -+struct proxy_alias { -+ char *real; -+ char *fake; -+}; -+ -+struct dirconn_entry { -+ char *name; -+ struct in_addr addr, mask; -+ struct hostent *hostentry; -+ int (*matcher) (struct dirconn_entry * This, request_rec *r); -+}; -+ -+struct noproxy_entry { -+ char *name; -+ struct in_addr addr; -+}; -+ -+struct nocache_entry { -+ char *name; -+ struct in_addr addr; -+}; -+ -+#define DEFAULT_CACHE_SPACE 5 -+#define DEFAULT_CACHE_MAXEXPIRE SEC_ONE_DAY -+#define DEFAULT_CACHE_EXPIRE SEC_ONE_HR -+#define DEFAULT_CACHE_LMFACTOR (0.1) -+#define DEFAULT_CACHE_COMPLETION (0.9) -+#define DEFAULT_CACHE_GCINTERVAL SEC_ONE_HR -+ -+#ifndef MAX -+#define MAX(a,b) ((a) > (b) ? (a) : (b)) -+#endif -+#ifndef MIN -+#define MIN(a,b) ((a) < (b) ? (a) : (b)) -+#endif -+ -+/* static information about the local cache */ -+struct cache_conf { -+ const char *root; /* the location of the cache directory */ -+ off_t space; /* Maximum cache size (in 1024 bytes) */ -+ char space_set; -+ time_t maxexpire; /* Maximum time to keep cached files in secs */ -+ char maxexpire_set; -+ time_t defaultexpire; /* default time to keep cached file in secs */ -+ char defaultexpire_set; -+ double lmfactor; /* factor for estimating expires date */ -+ char lmfactor_set; -+ time_t gcinterval; /* garbage collection interval, in seconds */ -+ char gcinterval_set; -+ int dirlevels; /* Number of levels of subdirectories */ -+ char dirlevels_set; -+ int dirlength; /* Length of subdirectory names */ -+ char dirlength_set; -+ float cache_completion; /* Force cache completion after this point */ -+ char cache_completion_set; -+}; -+ -+typedef struct { -+ struct cache_conf cache; /* cache configuration */ -+ array_header *proxies; -+ array_header *aliases; -+ array_header *raliases; -+ array_header *noproxies; -+ array_header *dirconn; -+ array_header *nocaches; -+ array_header *allowed_connect_ports; -+ char *domain; /* domain name to use in absence of a domain name in the request */ -+ int req; /* true if proxy requests are enabled */ -+ char req_set; -+ enum { -+ via_off, -+ via_on, -+ via_block, -+ via_full -+ } viaopt; /* how to deal with proxy Via: headers */ -+ char viaopt_set; -+ size_t recv_buffer_size; -+ char recv_buffer_size_set; -+} proxy_server_conf; -+ -+struct hdr_entry { -+ const char *field; -+ const char *value; -+}; -+ -+/* caching information about a request */ -+typedef struct { -+ request_rec *req; /* the request */ -+ char *url; /* the URL requested */ -+ char *filename; /* name of the cache file, -+ or NULL if no cache */ -+ char *tempfile; /* name of the temporary file, -+ or NULL if not caching */ -+ time_t ims; /* if-Modified-Since date of request, -+ -1 if no header */ -+ time_t ius; /* if-Unmodified-Since date of request, -+ -1 if no header */ -+ const char *im; /* if-Match etag of request, -+ NULL if no header */ -+ const char *inm; /* if-None-Match etag of request, -+ NULL if no header */ -+ BUFF *fp; /* the cache file descriptor if the file -+ is cached and may be returned, -+ or NULL if the file is not cached -+ (or must be reloaded) */ -+ BUFF *origfp; /* the old cache file descriptor if the file has -+ been revalidated and is being rewritten to -+ disk */ -+ time_t expire; /* calculated expire date of cached entity */ -+ time_t lmod; /* last-modified date of cached entity */ -+ time_t date; /* the date the cached file was last touched */ -+ time_t req_time; /* the time the request started */ -+ time_t resp_time; /* the time the response was received */ -+ int version; /* update count of the file */ -+ off_t len; /* content length */ -+ char *protocol; /* Protocol, and major/minor number, -+ e.g. HTTP/1.1 */ -+ int status; /* the status of the cached file */ -+ unsigned int written; /* total *content* bytes written to cache */ -+ float cache_completion; /* specific to this request */ -+ char *resp_line; /* the whole status line -+ (protocol, code + message) */ -+ table *req_hdrs; /* the original request headers */ -+ table *hdrs; /* the original HTTP response headers -+ of the file */ -+ char *xcache; /* the X-Cache header value -+ to be sent to client */ -+} cache_req; -+ -+struct per_thread_data { -+ struct hostent hpbuf; -+ u_long ipaddr; -+ char *charpbuf[2]; -+}; -+/* Function prototypes */ -+ -+/* proxy_cache.c */ -+ -+void ap_proxy_cache_tidy(cache_req *c); -+int ap_proxy_cache_check(request_rec *r, char *url, struct cache_conf *conf, -+ cache_req **cr); -+int ap_proxy_cache_update(cache_req *c, table *resp_hdrs, -+ const int is_HTTP1, int nocache); -+void ap_proxy_garbage_coll(request_rec *r); -+ -+/* proxy_connect.c */ -+ -+int ap_proxy_connect_handler(request_rec *r, cache_req *c, char *url, -+ const char *proxyhost, int proxyport); -+ -+/* proxy_ftp.c */ -+ -+int ap_proxy_ftp_canon(request_rec *r, char *url); -+int ap_proxy_ftp_handler(request_rec *r, cache_req *c, char *url); -+ -+/* proxy_http.c */ -+ -+int ap_proxy_http_canon(request_rec *r, char *url, const char *scheme, -+ int def_port); -+int ap_proxy_http_handler(request_rec *r, cache_req *c, char *url, -+ const char *proxyhost, int proxyport); -+ -+/* proxy_util.c */ -+ -+int ap_proxy_hex2c(const char *x); -+void ap_proxy_c2hex(int ch, char *x); -+char *ap_proxy_canonenc(pool *p, const char *x, int len, enum enctype t, -+ enum proxyreqtype isenc); -+char *ap_proxy_canon_netloc(pool *p, char **const urlp, char **userp, -+ char **passwordp, char **hostp, int *port); -+const char *ap_proxy_date_canon(pool *p, const char *x); -+table *ap_proxy_read_headers(request_rec *r, char *buffer, int size, BUFF *f); -+long int ap_proxy_send_fb(BUFF *f, request_rec *r, cache_req *c, off_t len, int nowrite); -+void ap_proxy_write_headers(cache_req *c, const char *respline, table *t); -+int ap_proxy_liststr(const char *list, const char *key, char **val); -+void ap_proxy_hash(const char *it, char *val, int ndepth, int nlength); -+int ap_proxy_hex2sec(const char *x); -+void ap_proxy_sec2hex(int t, char *y); -+cache_req *ap_proxy_cache_error(cache_req *r); -+int ap_proxyerror(request_rec *r, int statuscode, const char *message); -+const char *ap_proxy_host2addr(const char *host, struct hostent *reqhp); -+int ap_proxy_is_ipaddr(struct dirconn_entry *This, pool *p); -+int ap_proxy_is_domainname(struct dirconn_entry *This, pool *p); -+int ap_proxy_is_hostname(struct dirconn_entry *This, pool *p); -+int ap_proxy_is_word(struct dirconn_entry *This, pool *p); -+int ap_proxy_doconnect(int sock, struct sockaddr_in *addr, request_rec *r); -+int ap_proxy_garbage_init(server_rec *, pool *); -+/* This function is called by ap_table_do() for all header lines */ -+int ap_proxy_send_hdr_line(void *p, const char *key, const char *value); -+unsigned ap_proxy_bputs2(const char *data, BUFF *client, cache_req *cache); -+time_t ap_proxy_current_age(cache_req *c, const time_t age_value); -+BUFF *ap_proxy_open_cachefile(request_rec *r, char *filename); -+BUFF *ap_proxy_create_cachefile(request_rec *r, char *filename); -+void ap_proxy_clear_connection(pool *p, table *headers); -+int ap_proxy_table_replace(table *base, table *overlay); -+ -+/* WARNING - PRIVATE DEFINITION BELOW */ -+ -+/* XXX: if you tweak this you should look at is_empty_table() and table_elts() -+ * in ap_alloc.h -+ * -+ * NOTE: this private definition is a duplicate of the one in alloc.c -+ * It's here for ap_proxy_table_replace() to avoid breaking binary compat -+ */ -+struct table { -+ /* This has to be first to promote backwards compatibility with -+ * older modules which cast a table * to an array_header *... -+ * they should use the table_elts() function for most of the -+ * cases they do this for. -+ */ -+ array_header a; -+#ifdef MAKE_TABLE_PROFILE -+ void *creator; -+#endif -+}; -+ -+#endif /*MOD_PROXY_H*/ -diff -Nur apache_1.3.23.orig/src/modules/proxy/proxy_connect.c apache_1.3.23/src/modules/proxy/proxy_connect.c ---- apache_1.3.23.orig/src/modules/proxy/proxy_connect.c Sun Jan 20 21:14:37 2002 -+++ apache_1.3.23/src/modules/proxy/proxy_connect.c Wed Feb 6 20:49:52 2002 -@@ -114,14 +114,15 @@ - const char *proxyhost, int proxyport) +diff -Nur apache_1.3.28.orig/src/modules/proxy/proxy_connect.c apache_1.3.28/src/modules/proxy/proxy_connect.c +--- apache_1.3.28.orig/src/modules/proxy/proxy_connect.c Mon Feb 3 18:13:26 2003 ++++ apache_1.3.28/src/modules/proxy/proxy_connect.c Fri Jul 25 11:27:12 2003 +@@ -113,14 +113,15 @@ + const char *proxyhost, int proxyport) { struct sockaddr_in server; - struct in_addr destaddr; @@ -3249,8 +2926,8 @@ diff -Nur apache_1.3.23.orig/src/modules/proxy/proxy_connect.c apache_1.3.23/src void *sconf = r->server->module_config; proxy_server_conf *conf = -@@ -129,27 +130,59 @@ - struct noproxy_entry *npent = (struct noproxy_entry *)conf->noproxies->elts; +@@ -128,27 +129,59 @@ + struct noproxy_entry *npent = (struct noproxy_entry *) conf->noproxies->elts; memset(&server, '\0', sizeof(server)); +#ifdef HAVE_SOCKADDR_LEN @@ -3319,15 +2996,16 @@ diff -Nur apache_1.3.23.orig/src/modules/proxy/proxy_connect.c apache_1.3.23/src } /* Check if it is an allowed port */ -@@ -160,33 +193,41 @@ - case DEFAULT_SNEWS_PORT: - break; - default: -+ freeaddrinfo(res0); - return HTTP_FORBIDDEN; +@@ -159,34 +192,42 @@ + case DEFAULT_SNEWS_PORT: + break; + default: ++ freeaddrinfo(res0); + return HTTP_FORBIDDEN; } -- } else if(!allowed_port(conf, port)) -+ } else if(!allowed_port(conf, port)) { + } +- else if (!allowed_port(conf, port)) ++ else if (!allowed_port(conf, port)) { + freeaddrinfo(res0); return HTTP_FORBIDDEN; + } @@ -3346,13 +3024,13 @@ diff -Nur apache_1.3.23.orig/src/modules/proxy/proxy_connect.c apache_1.3.23/src + if (error) + return HTTP_INTERNAL_SERVER_ERROR; /* XXX */ + - ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, r->server, - "CONNECT to remote proxy %s on port %d", proxyhost, proxyport); + ap_log_error(APLOG_MARK, APLOG_DEBUG | APLOG_NOERRNO, r->server, + "CONNECT to remote proxy %s on port %d", proxyhost, proxyport); } else { - ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, r->server, -- "CONNECT to %s on port %d", host, port); -+ "CONNECT to %s on port %d", hoststr, port); + ap_log_error(APLOG_MARK, APLOG_DEBUG | APLOG_NOERRNO, r->server, +- "CONNECT to %s on port %d", host, port); ++ "CONNECT to %s on port %d", hoststr, port); } - /* Nasty cast to work around broken terniary expressions on MSVC */ @@ -3361,24 +3039,24 @@ diff -Nur apache_1.3.23.orig/src/modules/proxy/proxy_connect.c apache_1.3.23/src - - if (err != NULL) - return ap_proxyerror(r, -- proxyhost ? HTTP_BAD_GATEWAY : HTTP_INTERNAL_SERVER_ERROR, err); +- proxyhost ? HTTP_BAD_GATEWAY : HTTP_INTERNAL_SERVER_ERROR, err); - -- sock = ap_psocket(r->pool, PF_INET, SOCK_STREAM, IPPROTO_TCP); +- sock = ap_psocket_ex(r->pool, PF_INET, SOCK_STREAM, IPPROTO_TCP, 1); - if (sock == -1) { - ap_log_rerror(APLOG_MARK, APLOG_ERR, r, "proxy: error creating socket"); - return HTTP_INTERNAL_SERVER_ERROR; - } + sock = i = -1; + for (res = res0; res; res = res->ai_next) { -+ sock = ap_psocket(r->pool, res->ai_family, res->ai_socktype, res->ai_protocol); ++ sock = ap_psocket_ex(r->pool, res->ai_family, res->ai_socktype, res->ai_protocol, 1); + if (sock == -1) + continue; #ifdef CHECK_FD_SETSIZE if (sock >= FD_SETSIZE) { @@ -196,19 +237,15 @@ - "found, you probably need to rebuild Apache with a " - "larger FD_SETSIZE", sock, FD_SETSIZE); + "found, you probably need to rebuild Apache with a " + "larger FD_SETSIZE", sock, FD_SETSIZE); ap_pclosesocket(r->pool, sock); - return HTTP_INTERNAL_SERVER_ERROR; + continue; @@ -3399,9 +3077,9 @@ diff -Nur apache_1.3.23.orig/src/modules/proxy/proxy_connect.c apache_1.3.23/src if (i == -1) { ap_pclosesocket(r->pool, sock); return ap_proxyerror(r, HTTP_INTERNAL_SERVER_ERROR, ap_pstrcat(r->pool, -diff -Nur apache_1.3.23.orig/src/modules/proxy/proxy_ftp.c apache_1.3.23/src/modules/proxy/proxy_ftp.c ---- apache_1.3.23.orig/src/modules/proxy/proxy_ftp.c Sun Jan 20 21:14:37 2002 -+++ apache_1.3.23/src/modules/proxy/proxy_ftp.c Wed Feb 6 21:08:39 2002 +diff -Nur apache_1.3.28.orig/src/modules/proxy/proxy_ftp.c apache_1.3.28/src/modules/proxy/proxy_ftp.c +--- apache_1.3.28.orig/src/modules/proxy/proxy_ftp.c Mon Feb 3 18:13:26 2003 ++++ apache_1.3.28/src/modules/proxy/proxy_ftp.c Fri Jul 25 11:18:38 2003 @@ -62,6 +62,7 @@ #include "http_main.h" #include "http_log.h" @@ -3410,10 +3088,10 @@ diff -Nur apache_1.3.23.orig/src/modules/proxy/proxy_ftp.c apache_1.3.23/src/mod #define AUTODETECT_PWD -@@ -451,8 +452,10 @@ +@@ -555,8 +556,10 @@ const char *err; - int port, i, j, len, sock, dsock, rc, nocache = 0; - int csd = 0; + int port, i, j, len, rc, nocache = 0; + int csd = 0, sock = -1, dsock = -1; - struct sockaddr_in server; - struct hostent server_hp; + struct sockaddr_storage server; @@ -3422,8 +3100,8 @@ diff -Nur apache_1.3.23.orig/src/modules/proxy/proxy_ftp.c apache_1.3.23/src/mod + int error; struct in_addr destaddr; table *resp_hdrs; - BUFF *f; -@@ -471,11 +474,18 @@ + BUFF *ctrl = NULL; +@@ -577,11 +580,18 @@ unsigned int presult, h0, h1, h2, h3, p0, p1; unsigned int paddr; unsigned short pport; @@ -3443,77 +3121,75 @@ diff -Nur apache_1.3.23.orig/src/modules/proxy/proxy_ftp.c apache_1.3.23/src/mod /* stuff for responses */ char resp[MAX_STRING_LEN]; char *size = NULL; -@@ -545,62 +555,52 @@ +@@ -658,62 +668,50 @@ if (parms != NULL) *(parms++) = '\0'; - memset(&server, 0, sizeof(struct sockaddr_in)); - server.sin_family = AF_INET; -- server.sin_port = htons((unsigned short)port); -- err = ap_proxy_host2addr(host, &server_hp); +- server.sin_port = htons((unsigned short)destport); +- err = ap_proxy_host2addr(desthost, &server_hp); - if (err != NULL) - return ap_proxyerror(r, HTTP_INTERNAL_SERVER_ERROR, err); - -- sock = ap_psocket(p, PF_INET, SOCK_STREAM, IPPROTO_TCP); +- sock = ap_psocket_ex(p, PF_INET, SOCK_STREAM, IPPROTO_TCP, 1); - if (sock == -1) { - ap_log_rerror(APLOG_MARK, APLOG_ERR, r, -- "proxy: error creating socket"); +- "proxy: error creating socket"); - return HTTP_INTERNAL_SERVER_ERROR; -- } -+ ap_snprintf(portbuf, sizeof(portbuf), "%d", port); ++ ap_snprintf(portbuf, sizeof(portbuf), "%d", destport); + memset(&hints, 0, sizeof(hints)); + hints.ai_family = PF_UNSPEC; + hints.ai_socktype = SOCK_STREAM; -+ error = getaddrinfo(host, portbuf, &hints, &res0); ++ error = getaddrinfo(desthost, portbuf, &hints, &res0); + if (error) { -+ return ap_proxyerror(r, HTTP_INTERNAL_SERVER_ERROR, -+ gai_strerror(error)); -+ } -+ ++ return ap_proxyerror(r, HTTP_INTERNAL_SERVER_ERROR, gai_strerror(error)); + } + + i = -1; + for (res = res0; res; res = res->ai_next) { -+ sock = ap_psocket(p, res->ai_family, res->ai_socktype, -+ res->ai_protocol); ++ sock = ap_psocket_ex(p, res->ai_family, res->ai_socktype, ++ res->ai_protocol, 1); + if (sock == -1) + continue; - ++ #if !defined(TPF) && !defined(BEOS) - if (conf->recv_buffer_size > 0 - && setsockopt(sock, SOL_SOCKET, SO_RCVBUF, -- (const char *) &conf->recv_buffer_size, sizeof(int)) -- == -1) { -- ap_log_rerror(APLOG_MARK, APLOG_ERR, r, -- "setsockopt(SO_RCVBUF): Failed to set ProxyReceiveBufferSize, using default"); +- (const char *)&conf->recv_buffer_size, sizeof(int)) +- == -1) { +- ap_log_rerror(APLOG_MARK, APLOG_ERR, r, +- "setsockopt(SO_RCVBUF): Failed to set ProxyReceiveBufferSize, using default"); - } -+ if (conf->recv_buffer_size > 0 -+ && setsockopt(sock, SOL_SOCKET, SO_RCVBUF, -+ (const char *) &conf->recv_buffer_size, sizeof(int)) -+ == -1) { -+ ap_log_rerror(APLOG_MARK, APLOG_ERR, r, -+ "setsockopt(SO_RCVBUF): Failed to set ProxyReceiveBufferSize, using default"); -+ } ++ if (conf->recv_buffer_size > 0 ++ && setsockopt(sock, SOL_SOCKET, SO_RCVBUF, ++ (const char *)&conf->recv_buffer_size, sizeof(int)) ++ == -1) { ++ ap_log_rerror(APLOG_MARK, APLOG_ERR, r, ++ "setsockopt(SO_RCVBUF): Failed to set ProxyReceiveBufferSize, using default"); ++ } #endif -- if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void *) &one, +- if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void *)&one, - sizeof(one)) == -1) { -+ if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void *) &one, -+ sizeof(one)) == -1) { - #ifndef _OSD_POSIX /* BS2000 has this option "always on" */ ++ if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void *)&one, ++ sizeof(one)) == -1) { + #ifndef _OSD_POSIX /* BS2000 has this option "always on" */ - ap_log_rerror(APLOG_MARK, APLOG_ERR, r, -- "proxy: error setting reuseaddr option: setsockopt(SO_REUSEADDR)"); +- "proxy: error setting reuseaddr option: setsockopt(SO_REUSEADDR)"); - ap_pclosesocket(p, sock); - return HTTP_INTERNAL_SERVER_ERROR; -+ ap_log_rerror(APLOG_MARK, APLOG_ERR, r, -+ "proxy: error setting reuseaddr option: setsockopt(SO_REUSEADDR)"); -+ ap_pclosesocket(p, sock); ++ ap_log_rerror(APLOG_MARK, APLOG_ERR, r, ++ "proxy: error setting reuseaddr option: setsockopt(SO_REUSEADDR)"); ++ ap_pclosesocket(p, sock); + freeaddrinfo(res0); -+ return HTTP_INTERNAL_SERVER_ERROR; - #endif /*_OSD_POSIX*/ ++ return HTTP_INTERNAL_SERVER_ERROR; + #endif /* _OSD_POSIX */ - } - -#ifdef SINIX_D_RESOLVER_BUG - { -- struct in_addr *ip_addr = (struct in_addr *) *server_hp.h_addr_list; +- struct in_addr *ip_addr = (struct in_addr *)*server_hp.h_addr_list; - - for (; ip_addr->s_addr != 0; ++ip_addr) { - memcpy(&server.sin_addr, ip_addr, sizeof(struct in_addr)); @@ -3529,9 +3205,8 @@ diff -Nur apache_1.3.23.orig/src/modules/proxy/proxy_ftp.c apache_1.3.23/src/mod - sizeof(struct in_addr)); - i = ap_proxy_doconnect(sock, &server, r); - if (i == 0) -+ -+ i = ap_proxy_doconnect(sock, res->ai_addr, r); -+ if (i == 0){ ++ i = ap_proxy_doconnect(sock, res->ai_addr, r); ++ if (i == 0) { + memcpy(&server, res->ai_addr, res->ai_addrlen); break; - j++; @@ -3541,22 +3216,22 @@ diff -Nur apache_1.3.23.orig/src/modules/proxy/proxy_ftp.c apache_1.3.23/src/mod -#endif + freeaddrinfo(res0); if (i == -1) { - ap_pclosesocket(p, sock); - return ap_proxyerror(r, HTTP_BAD_GATEWAY, ap_pstrcat(r->pool, -@@ -807,7 +807,7 @@ + return ftp_cleanup_and_return(r, ctrl, data, sock, dsock, + ap_proxyerror(r, HTTP_BAD_GATEWAY, ap_pstrcat(r->pool, +@@ -944,7 +942,7 @@ } /* try to set up PASV data connection first */ -- dsock = ap_psocket(p, PF_INET, SOCK_STREAM, IPPROTO_TCP); -+ dsock = ap_psocket(p, server.ss_family, SOCK_STREAM, IPPROTO_TCP); +- dsock = ap_psocket_ex(p, PF_INET, SOCK_STREAM, IPPROTO_TCP, 1); ++ dsock = ap_psocket_ex(p, server.ss_family, SOCK_STREAM, IPPROTO_TCP, 1); if (dsock == -1) { - ap_log_rerror(APLOG_MARK, APLOG_ERR, r, - "proxy: error creating PASV socket"); -@@ -826,11 +826,22 @@ + return ftp_cleanup_and_return(r, ctrl, data, sock, dsock, + ap_proxyerror(r, HTTP_INTERNAL_SERVER_ERROR, +@@ -961,11 +959,22 @@ } #endif -- ap_bputs("PASV" CRLF, f); +- ap_bputs("PASV" CRLF, ctrl); +lpsvagain: + if (server.ss_family == AF_INET) + cmd = "PASV"; @@ -3564,32 +3239,32 @@ diff -Nur apache_1.3.23.orig/src/modules/proxy/proxy_ftp.c apache_1.3.23/src/mod + cmd = "LPSV"; + else + cmd = "EPSV"; -+ ap_bputs(cmd, f); -+ ap_bputs(CRLF, f); - ap_bflush(f); ++ ap_bputs(cmd, ctrl); ++ ap_bputs(CRLF, ctrl); + ap_bflush(ctrl); + Explain0("FTP: passive command issued"); - ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, r->server, "FTP: PASV command issued"); + ap_log_error(APLOG_MARK, APLOG_DEBUG | APLOG_NOERRNO, r->server, "FTP: PASV command issued"); -/* possible results: 227, 421, 500, 501, 502, 530 */ -+ /* possible results: 227, 228, 229, 421, 500, 501, 502, 530 */ ++/* possible results: 227, 228, 229, 421, 500, 501, 502, 530 */ /* 227 Entering Passive Mode (h1,h2,h3,h4,p1,p2). */ + /* 228 Entering Long Passive Mode (...). */ + /* 229 Entering Extended Passive Mode (...). */ /* 421 Service not available, closing control connection. */ /* 500 Syntax error, command unrecognized. */ /* 501 Syntax error in parameters or arguments. */ -@@ -839,7 +850,7 @@ - i = ap_bgets(pasv, sizeof(pasv), f); - if (i == -1) { - ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, r, -- "PASV: control connection is toast"); -+ "%s: control connection is toast", cmd); - ap_pclosesocket(p, dsock); - ap_bclose(f); - ap_kill_timeout(r); -@@ -871,10 +882,14 @@ +@@ -976,7 +985,7 @@ + if (i == -1 || i == 421) { + return ftp_cleanup_and_return(r, ctrl, data, sock, dsock, + ap_proxyerror(r, HTTP_INTERNAL_SERVER_ERROR, +- "proxy: PASV: control connection is toast")); ++ ap_psprintf(p, "proxy: %s: control connection is toast", cmd))); + } + else { + pasv[i - 1] = '\0'; +@@ -1004,10 +1013,14 @@ pport = (p1 << 8) + p0; - ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, r->server, "FTP: contacting host %d.%d.%d.%d:%d", - h3, h2, h1, h0, pport); + ap_log_error(APLOG_MARK, APLOG_DEBUG | APLOG_NOERRNO, r->server, "FTP: contacting host %d.%d.%d.%d:%d", + h3, h2, h1, h0, pport); - data_addr.sin_family = AF_INET; - data_addr.sin_addr.s_addr = htonl(paddr); - data_addr.sin_port = htons(pport); @@ -3604,11 +3279,11 @@ diff -Nur apache_1.3.23.orig/src/modules/proxy/proxy_ftp.c apache_1.3.23/src/mod + i = ap_proxy_doconnect(dsock, (struct sockaddr *)&data_addr, r); if (i == -1) { - ap_kill_timeout(r); -@@ -886,13 +901,73 @@ - else { - pasvmode = 1; + return ftp_cleanup_and_return(r, ctrl, data, sock, dsock, +@@ -1017,6 +1030,64 @@ + strerror(errno), NULL))); } + pasvmode = 1; + } else if (presult == 228 && pstr != NULL + && sscanf(pstr, +"%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u", @@ -3628,14 +3303,13 @@ diff -Nur apache_1.3.23.orig/src/modules/proxy/proxy_ftp.c apache_1.3.23/src/mod + i = ap_proxy_doconnect(dsock, (struct sockaddr *)&data_addr, r); + + if (i == -1) { -+ ap_kill_timeout(r); -+ return ap_proxyerror(r, HTTP_BAD_GATEWAY, -+ ap_pstrcat(r->pool, -+ "Could not connect to remote machine: ", -+ strerror(errno), NULL)); -+ } else { -+ pasvmode = 1; ++ return ftp_cleanup_and_return(r, ctrl, data, sock, dsock, ++ ap_proxyerror(r, HTTP_BAD_GATEWAY, ++ ap_pstrcat(r->pool, ++ "Could not connect to remote machine: ", ++ strerror(errno), NULL))); + } ++ pasvmode = 1; + } else if (presult == 229 && pstr != NULL + && pstr[0] == pstr[1] && pstr[0] == pstr[2] + && pstr[0] == pstr[strlen(pstr) - 1]) { @@ -3658,52 +3332,50 @@ diff -Nur apache_1.3.23.orig/src/modules/proxy/proxy_ftp.c apache_1.3.23/src/mod + i = ap_proxy_doconnect(dsock, (struct sockaddr *)&data_addr, r); + + if (i == -1) { -+ ap_kill_timeout(r); -+ return ap_proxyerror(r, HTTP_BAD_GATEWAY, -+ ap_pstrcat(r->pool, -+ "Could not connect to remote machine: ", -+ strerror(errno), NULL)); -+ } else { -+ pasvmode = 1; ++ return ftp_cleanup_and_return(r, ctrl, data, sock, dsock, ++ ap_proxyerror(r, HTTP_BAD_GATEWAY, ++ ap_pstrcat(r->pool, ++ "Could not connect to remote machine: ", ++ strerror(errno), NULL))); + } ++ pasvmode = 1; + } else if (!lpsvmode && strcmp(cmd, "EPSV") == 0) { + lpsvmode = 1; + goto lpsvagain; } - else + else { ap_pclosesocket(p, dsock); /* and try the regular way */ +@@ -1025,14 +1096,14 @@ } if (!pasvmode) { /* set up data connection */ - clen = sizeof(struct sockaddr_in); -+ clen = sizeof(server); - if (getsockname(sock, (struct sockaddr *) &server, &clen) < 0) { - ap_log_rerror(APLOG_MARK, APLOG_ERR, r, - "proxy: error getting socket address"); -@@ -901,7 +976,7 @@ - return HTTP_INTERNAL_SERVER_ERROR; ++ clen = sizeof(server); + if (getsockname(sock, (struct sockaddr *)&server, &clen) < 0) { + return ftp_cleanup_and_return(r, ctrl, data, sock, dsock, + ap_proxyerror(r, HTTP_INTERNAL_SERVER_ERROR, + "proxy: error getting socket address")); } -- dsock = ap_psocket(p, PF_INET, SOCK_STREAM, IPPROTO_TCP); -+ dsock = ap_psocket(p, server.ss_family, SOCK_STREAM, IPPROTO_TCP); +- dsock = ap_psocket_ex(p, PF_INET, SOCK_STREAM, IPPROTO_TCP, 1); ++ dsock = ap_psocket_ex(p, server.ss_family, SOCK_STREAM, IPPROTO_TCP, 1); if (dsock == -1) { - ap_log_rerror(APLOG_MARK, APLOG_ERR, r, - "proxy: error creating socket"); -@@ -922,13 +997,26 @@ - #endif /*_OSD_POSIX*/ + return ftp_cleanup_and_return(r, ctrl, data, sock, dsock, + ap_proxyerror(r, HTTP_INTERNAL_SERVER_ERROR, +@@ -1048,13 +1119,28 @@ + #endif /* _OSD_POSIX */ } -- if (bind(dsock, (struct sockaddr *) &server, +- if (bind(dsock, (struct sockaddr *)&server, - sizeof(struct sockaddr_in)) == -1) { -- char buff[22]; +#ifndef SIN6_LEN -+ if (bind(dsock, (struct sockaddr *) &server, SA_LEN((struct sockaddr *)&server)) == -1) ++ if (bind(dsock, (struct sockaddr *)&server, SA_LEN((struct sockaddr *)&server)) == -1) +#else -+ if (bind(dsock, (struct sockaddr *) &server, server.ss_len) == -1) ++ if (bind(dsock, (struct sockaddr *)&server, server.ss_len) == -1) +#endif -+ { ++ { + char hostnamebuf[MAXHOSTNAMELEN], portnamebuf[MAXHOSTNAMELEN]; - ++ + getnameinfo((struct sockaddr *)&server, +#ifndef SIN6_LEN + SA_LEN((struct sockaddr *)&server), @@ -3713,27 +3385,28 @@ diff -Nur apache_1.3.23.orig/src/modules/proxy/proxy_ftp.c apache_1.3.23/src/mod + hostnamebuf, sizeof(hostnamebuf), + portnamebuf, sizeof(portnamebuf), + NI_NUMERICHOST | NI_NUMERICSERV); -- ap_snprintf(buff, sizeof(buff), "%s:%d", inet_ntoa(server.sin_addr), server.sin_port); - ap_log_rerror(APLOG_MARK, APLOG_ERR, r, -- "proxy: error binding to ftp data socket %s", buff); -+ "proxy: error binding to ftp data socket %s:%s", -+ hostnamebuf, portnamebuf); - ap_bclose(f); - ap_pclosesocket(p, dsock); - return HTTP_INTERNAL_SERVER_ERROR; -@@ -1187,7 +1276,7 @@ + + return ftp_cleanup_and_return(r, ctrl, data, sock, dsock, + ap_proxyerror(r, HTTP_INTERNAL_SERVER_ERROR, +- ap_psprintf(p, "proxy: error binding to ftp data socket %s:%d", +- inet_ntoa(server.sin_addr), server.sin_port))); ++ ap_psprintf(p, "proxy: error binding to ftp data socket %s:%s", ++ hostnamebuf, portnamebuf))); + } + listen(dsock, 2); /* only need a short queue */ + } +@@ -1308,7 +1394,7 @@ if (!pasvmode) { /* wait for connection */ ap_hard_timeout("proxy ftp data connect", r); - clen = sizeof(struct sockaddr_in); + clen = sizeof(server); do - csd = accept(dsock, (struct sockaddr *) &server, &clen); + csd = accept(dsock, (struct sockaddr *)&server, &clen); while (csd == -1 && errno == EINTR); -diff -Nur apache_1.3.23.orig/src/modules/proxy/proxy_http.c apache_1.3.23/src/modules/proxy/proxy_http.c ---- apache_1.3.23.orig/src/modules/proxy/proxy_http.c Wed Feb 6 20:17:43 2002 -+++ apache_1.3.23/src/modules/proxy/proxy_http.c Wed Feb 6 21:18:32 2002 -@@ -155,9 +155,8 @@ +--- apache_1.3.34/src/modules/proxy/proxy_http.c.orig 2005-10-18 09:56:15.000000000 +0200 ++++ apache_1.3.34/src/modules/proxy/proxy_http.c 2005-10-18 10:15:06.000000000 +0200 +@@ -113,9 +113,8 @@ table *req_hdrs, *resp_hdrs; array_header *reqhdrs_arr; table_entry *reqhdrs_elts; @@ -3745,17 +3418,17 @@ diff -Nur apache_1.3.23.orig/src/modules/proxy/proxy_http.c apache_1.3.23/src/mo BUFF *f; char buffer[HUGE_STRING_LEN]; char portstr[32]; -@@ -179,9 +178,6 @@ - - if (conf->cache.root == NULL) nocache = 1; +@@ -141,9 +140,6 @@ + if (conf->cache.root == NULL) + nocache = 1; - memset(&server, '\0', sizeof(server)); - server.sin_family = AF_INET; -- +- /* We break the URL into host, port, path-search */ urlptr = strstr(url, "://"); -@@ -189,6 +185,8 @@ +@@ -151,6 +147,8 @@ return HTTP_BAD_REQUEST; urlptr += 3; destport = DEFAULT_HTTP_PORT; @@ -3764,7 +3437,7 @@ diff -Nur apache_1.3.23.orig/src/modules/proxy/proxy_http.c apache_1.3.23/src/mo #ifdef EAPI ap_hook_use("ap::mod_proxy::http::handler::set_destport", AP_HOOK_SIG2(int,ptr), -@@ -207,7 +205,20 @@ +@@ -169,7 +167,20 @@ urlptr = strp; desthost = q; } @@ -3786,76 +3459,73 @@ diff -Nur apache_1.3.23.orig/src/modules/proxy/proxy_http.c apache_1.3.23/src/mo strp2 = strchr(desthost, ':'); if (strp2 != NULL) { *(strp2++) = '\0'; -@@ -218,45 +229,69 @@ +@@ -179,46 +190,71 @@ + } } ++ memset(&hints, 0, sizeof(hints)); ++ hints.ai_family = PF_UNSPEC; ++ hints.ai_socktype = SOCK_STREAM; ++ hints.ai_protocol = IPPROTO_TCP; ++ error = getaddrinfo(desthost, destportstr, &hints, &res0); ++ if (error) { ++ return ap_proxyerror(r, HTTP_INTERNAL_SERVER_ERROR, ++ gai_strerror(error)); /* give up */ ++ } ++ /* check if ProxyBlock directive on this host */ - destaddr.s_addr = ap_inet_addr(desthost); - for (i = 0; i < conf->noproxies->nelts; i++) { - if (destaddr.s_addr == npent[i].addr.s_addr || - (npent[i].name != NULL && -- (npent[i].name[0] == '*' || strstr(desthost, npent[i].name) != NULL))) -+ memset(&hints, 0, sizeof(hints)); -+ hints.ai_family = PF_UNSPEC; -+ hints.ai_socktype = SOCK_STREAM; -+ hints.ai_protocol = IPPROTO_TCP; -+ error = getaddrinfo(desthost, destportstr, &hints, &res0); -+ if (error) { -+ return ap_proxyerror(r, HTTP_INTERNAL_SERVER_ERROR, -+ gai_strerror(error)); /* give up */ -+ } -+ -+ /* check if ProxyBlock directive on this host */ -+ for (res = res0; res; res = res->ai_next) { -+ struct sockaddr_in *sin; -+ #ifdef INET6 -+ struct sockaddr_in6 *sin6; -+ #endif -+ int fail; -+ -+ fail = 0; -+ for (i = 0; i < conf->noproxies->nelts; i++) { -+ if (npent[i].name != NULL && strstr(desthost, npent[i].name)) -+ fail++; -+ if (npent[i].name != NULL && strcmp(npent[i].name, "*") == 0) -+ fail++; -+ switch (res->ai_family) { -+ case AF_INET: -+ sin = (struct sockaddr_in *)res->ai_addr; -+ if (sin->sin_addr.s_addr == npent[i].addr.s_addr) -+ fail++; -+ break; -+ } +- (npent[i].name[0] == '*' || strstr(desthost, npent[i].name) != NULL))) ++ for (res = res0; res; res = res->ai_next) { ++ struct sockaddr_in *sin; ++#ifdef INET6 ++ struct sockaddr_in6 *sin6; ++#endif ++ int fail; ++ ++ fail = 0; ++ for (i = 0; i < conf->noproxies->nelts; i++) { ++ if (npent[i].name != NULL && strstr(desthost, npent[i].name)) ++ fail++; ++ if (npent[i].name != NULL && strcmp(npent[i].name, "*") == 0) ++ fail++; ++ switch (res->ai_family) { ++ case AF_INET: ++ sin = (struct sockaddr_in *)res->ai_addr; ++ if (sin->sin_addr.s_addr == npent[i].addr.s_addr) ++ fail++; ++ break; + } -+ if (fail) { -+ freeaddrinfo(res0); ++ } ++ if (fail) { ++ freeaddrinfo(res0); return ap_proxyerror(r, HTTP_FORBIDDEN, "Connect to remote machine blocked"); -- } -- -- if (proxyhost != NULL) { ++ } + } + + if (proxyhost != NULL) { - server.sin_port = htons((unsigned short)proxyport); - err = ap_proxy_host2addr(proxyhost, &server_hp); - if (err != NULL) -+ } -+ } -+ -+ if (proxyhost != NULL) { -+ char pbuf[10]; -+ -+ freeaddrinfo(res0); -+ ap_snprintf(pbuf, sizeof(pbuf), "%d", proxyport); -+ memset(&hints, 0, sizeof(hints)); -+ hints.ai_family = PF_UNSPEC; -+ hints.ai_socktype = SOCK_STREAM; -+ hints.ai_protocol = IPPROTO_TCP; -+ error = getaddrinfo(proxyhost, pbuf, &hints, &res0); -+ if (error) ++ char pbuf[10]; ++ ++ freeaddrinfo(res0); ++ ap_snprintf(pbuf, sizeof(pbuf), "%d", proxyport); ++ memset(&hints, 0, sizeof(hints)); ++ hints.ai_family = PF_UNSPEC; ++ hints.ai_socktype = SOCK_STREAM; ++ hints.ai_protocol = IPPROTO_TCP; ++ error = getaddrinfo(proxyhost, pbuf, &hints, &res0); ++ if (error) return DECLINED; /* try another */ --#ifdef EAPI -- peer = ap_psprintf(p, "%s:%u", proxyhost, proxyport); --#endif -- } + #ifdef EAPI + peer = ap_psprintf(p, "%s:%u", proxyhost, proxyport); + #endif + } - else { - server.sin_port = htons((unsigned short)destport); - err = ap_proxy_host2addr(desthost, &server_hp); @@ -3866,45 +3536,43 @@ diff -Nur apache_1.3.23.orig/src/modules/proxy/proxy_http.c apache_1.3.23/src/mo -#endif - } - -- -- /* we have worked out who exactly we are going to connect to, now -- * make that connection... -- */ -- sock = ap_psocket(p, PF_INET, SOCK_STREAM, IPPROTO_TCP); + + /* + * we have worked out who exactly we are going to connect to, now make + * that connection... + */ +- sock = ap_psocket_ex(p, PF_INET, SOCK_STREAM, IPPROTO_TCP, 1); - if (sock == -1) { - ap_log_rerror(APLOG_MARK, APLOG_ERR, r, -- "proxy: error creating socket"); +- "proxy: error creating socket"); - return HTTP_INTERNAL_SERVER_ERROR; - } -- -+ #ifdef EAPI -+ peer = ap_psprintf(p, "%s:%u", proxyhost, proxyport); -+ #endif -+ } -+ -+ sock = i = -1; -+ for (res = res0; res; res = res->ai_next) { -+ sock = ap_psocket(p, res->ai_family, res->ai_socktype, -+ res->ai_protocol); -+ if (sock < 0) -+ continue; -+ ++ sock = i = -1; ++ for (res = res0; res; res = res->ai_next) { ++ sock = ap_psocket_ex(p, res->ai_family, res->ai_socktype, res->ai_protocol, 1); ++ if (sock < 0) ++ continue; + #if !defined(TPF) && !defined(BEOS) if (conf->recv_buffer_size) { - if (setsockopt(sock, SOL_SOCKET, SO_RCVBUF, -@@ -268,28 +303,12 @@ +@@ -231,38 +267,13 @@ } #endif -#ifdef SINIX_D_RESOLVER_BUG - { -- struct in_addr *ip_addr = (struct in_addr *) *server_hp.h_addr_list; +- struct in_addr *ip_addr = (struct in_addr *)*server_hp.h_addr_list; - - for (; ip_addr->s_addr != 0; ++ip_addr) { - memcpy(&server.sin_addr, ip_addr, sizeof(struct in_addr)); - i = ap_proxy_doconnect(sock, &server, r); - if (i == 0) - break; +- /* +- * Even if the connection was unsuccesful we should +- * reinit the socket +- */ +- sock = ap_psocket_ex(p, PF_INET, SOCK_STREAM, IPPROTO_TCP, 1); - } - } -#else @@ -3913,19 +3581,24 @@ diff -Nur apache_1.3.23.orig/src/modules/proxy/proxy_http.c apache_1.3.23/src/mo - memcpy(&server.sin_addr, server_hp.h_addr_list[j], - sizeof(struct in_addr)); - i = ap_proxy_doconnect(sock, &server, r); -+ i = ap_proxy_doconnect(sock, res->ai_addr, r); ++ i = ap_proxy_doconnect(sock, res->ai_addr, r); if (i == 0) break; -- j++; -+ ap_pclosesocket(p, sock); +- /* +- * Even if the connection was unsuccesful we should +- * reinit the socket +- */ +- sock = ap_psocket_ex(p, PF_INET, SOCK_STREAM, IPPROTO_TCP, 1); ++ ap_pclosesocket(p, sock); + j++; } -#endif + freeaddrinfo(res0); if (i == -1) { if (proxyhost != NULL) return DECLINED; /* try again another way */ -@@ -544,16 +563,30 @@ - ap_table_set(resp_hdrs, "Content-Location", proxy_location_reverse_map(r , urlstr)); +@@ -591,17 +602,30 @@ + ap_table_set(resp_hdrs, "Content-Location", proxy_location_reverse_map(r, urlstr)); /* check if NoCache directive on this host */ + { @@ -3938,10 +3611,10 @@ diff -Nur apache_1.3.23.orig/src/modules/proxy/proxy_http.c apache_1.3.23/src/mo for (i = 0; i < conf->nocaches->nelts; i++) { - if (destaddr.s_addr == ncent[i].addr.s_addr || - (ncent[i].name != NULL && -- (ncent[i].name[0] == '*' || -- strstr(desthost, ncent[i].name) != NULL))) { -- nocache = 1; -- break; +- (ncent[i].name[0] == '*' || +- strstr(desthost, ncent[i].name) != NULL))) { +- nocache = 1; +- break; + if (ncent[i].name != NULL && + (ncent[i].name[0] == '*' || + strstr(desthost, ncent[i].name) != NULL)) { @@ -3957,22 +3630,23 @@ diff -Nur apache_1.3.23.orig/src/modules/proxy/proxy_http.c apache_1.3.23/src/mo + } } } -+ } - - /* update the cache file, possibly even fulfilling the request if - * it turns out a conditional allowed us to serve the object from the -diff -Nur apache_1.3.23.orig/src/modules/proxy/proxy_util.c apache_1.3.23/src/modules/proxy/proxy_util.c ---- apache_1.3.23.orig/src/modules/proxy/proxy_util.c Fri Jan 18 21:26:58 2002 -+++ apache_1.3.23/src/modules/proxy/proxy_util.c Wed Feb 6 21:25:17 2002 +- ++ } + /* + * update the cache file, possibly even fulfilling the request if it + * turns out a conditional allowed us to serve the object from the +diff -Nur apache_1.3.28.orig/src/modules/proxy/proxy_util.c apache_1.3.28/src/modules/proxy/proxy_util.c +--- apache_1.3.28.orig/src/modules/proxy/proxy_util.c Mon Feb 3 18:13:26 2003 ++++ apache_1.3.28/src/modules/proxy/proxy_util.c Fri Jul 25 11:01:55 2003 @@ -64,6 +64,7 @@ #include "http_log.h" #include "util_uri.h" - #include "util_date.h" /* get ap_checkmask() decl. */ + #include "util_date.h" /* get ap_checkmask() decl. */ +#include "sa_len.h" static int proxy_match_ipaddr(struct dirconn_entry *This, request_rec *r); static int proxy_match_domainname(struct dirconn_entry *This, request_rec *r); -@@ -218,6 +219,7 @@ +@@ -219,6 +220,7 @@ int i; char *strp, *host, *url = *urlp; char *user = NULL, *password = NULL; @@ -3980,7 +3654,7 @@ diff -Nur apache_1.3.23.orig/src/modules/proxy/proxy_util.c apache_1.3.23/src/mo if (url[0] != '/' || url[1] != '/') return "Malformed URL"; -@@ -256,11 +258,22 @@ +@@ -257,11 +259,22 @@ *passwordp = password; } @@ -4008,7 +3682,7 @@ diff -Nur apache_1.3.23.orig/src/modules/proxy/proxy_util.c apache_1.3.23/src/mo if (!ap_isdigit(strp[i])) break; -@@ -278,17 +291,29 @@ +@@ -280,17 +293,29 @@ return "Missing host in URL"; /* check hostname syntax */ for (i = 0; host[i] != '\0'; i++) @@ -4042,7 +3716,7 @@ diff -Nur apache_1.3.23.orig/src/modules/proxy/proxy_util.c apache_1.3.23/src/mo /* if (strchr(host,'.') == NULL && domain != NULL) host = pstrcat(p, host, domain, NULL); -@@ -1284,22 +1309,45 @@ +@@ -1359,22 +1384,46 @@ return host != NULL && strstr(host, This->name) != NULL; } @@ -4072,12 +3746,12 @@ diff -Nur apache_1.3.23.orig/src/modules/proxy/proxy_util.c apache_1.3.23/src/mo + } +#endif do { -- i = connect(sock, (struct sockaddr *) addr, sizeof(struct sockaddr_in)); +- i = connect(sock, (struct sockaddr *)addr, sizeof(struct sockaddr_in)); + i = connect(sock, addr, salen); #if defined(WIN32) || defined(NETWARE) if (i == SOCKET_ERROR) errno = WSAGetLastError(); - #endif /* WIN32 */ + #endif /* WIN32 */ } while (i == -1 && errno == EINTR); if (i == -1) { + if (getnameinfo(addr, salen, hbuf, sizeof(hbuf), pbuf, sizeof(pbuf), @@ -4086,16 +3760,15 @@ diff -Nur apache_1.3.23.orig/src/modules/proxy/proxy_util.c apache_1.3.23/src/mo + strcpy(pbuf, "?"); + } ap_log_rerror(APLOG_MARK, APLOG_ERR, r, -- "proxy connect to %s port %d failed", -- inet_ntoa(addr->sin_addr), ntohs(addr->sin_port)); -+ "proxy connect to %s port %d failed", hbuf, pbuf); + "proxy connect to %s port %d failed", +- inet_ntoa(addr->sin_addr), ntohs(addr->sin_port)); ++ hbuf, pbuf); } ap_kill_timeout(r); -diff -Nur apache_1.3.23.orig/src/modules/standard/mod_access.c apache_1.3.23/src/modules/standard/mod_access.c ---- apache_1.3.23.orig/src/modules/standard/mod_access.c Mon Jan 15 18:05:34 2001 -+++ apache_1.3.23/src/modules/standard/mod_access.c Wed Feb 6 20:20:48 2002 -@@ -74,7 +74,10 @@ +--- apache_1.3.31/src/modules/standard/mod_access.c.orig Sun Mar 7 22:47:14 2004 ++++ apache_1.3.31/src/modules/standard/mod_access.c Sat May 15 00:05:40 2004 +@@ -31,7 +31,10 @@ T_ALL, T_IP, T_HOST, @@ -4107,14 +3780,9 @@ diff -Nur apache_1.3.23.orig/src/modules/standard/mod_access.c apache_1.3.23/src }; typedef struct { -@@ -82,9 +85,15 @@ - union { - char *from; - struct { -- unsigned long net; -- unsigned long mask; -+ struct in_addr net; -+ struct in_addr mask; +@@ -42,6 +45,12 @@ + struct in_addr net; + struct in_addr mask; } ip; +#ifdef INET6 + struct { @@ -4125,11 +3793,11 @@ diff -Nur apache_1.3.23.orig/src/modules/standard/mod_access.c apache_1.3.23/src } x; enum allowdeny_type type; } allowdeny; -@@ -167,90 +176,230 @@ +@@ -124,94 +133,242 @@ } else if ((s = strchr(where, '/'))) { -- unsigned long mask; +- struct in_addr mask; + struct addrinfo hints, *resnet, *resmask; + struct sockaddr_storage net, mask; + int error; @@ -4142,7 +3810,7 @@ diff -Nur apache_1.3.23.orig/src/modules/standard/mod_access.c apache_1.3.23/src *s++ = '\0'; - if (!is_ip(where) -- || (a->x.ip.net = ap_inet_addr(where)) == INADDR_NONE) { +- || (a->x.ip.net.s_addr = ap_inet_addr(where)) == INADDR_NONE) { + justdigits = 0; + for (p = s; *p; p++) { + if (!isdigit(*p)) @@ -4165,16 +3833,25 @@ diff -Nur apache_1.3.23.orig/src/modules/standard/mod_access.c apache_1.3.23/src a->type = T_FAIL; return "syntax error in network portion of network/netmask"; } +- +- /* is_ip just tests if it matches [\d.]+ */ +- if (!is_ip(s)) { + if (resnet->ai_next) { + freeaddrinfo(resnet); -+ a->type = T_FAIL; + a->type = T_FAIL; +- return "syntax error in mask portion of network/netmask"; + return "network/netmask resolved to multiple addresses"; -+ } + } +- /* is it in /a.b.c.d form? */ +- if (strchr(s, '.')) { +- mask.s_addr = ap_inet_addr(s); +- if (mask.s_addr == INADDR_NONE) { +- a->type = T_FAIL; +- return "syntax error in mask portion of network/netmask"; +- } + memcpy(&net, resnet->ai_addr, resnet->ai_addrlen); + freeaddrinfo(resnet); - -- /* is_ip just tests if it matches [\d.]+ */ -- if (!is_ip(s)) { ++ + switch (net.ss_family) { + case AF_INET: + a->type = T_IP; @@ -4188,15 +3865,15 @@ diff -Nur apache_1.3.23.orig/src/modules/standard/mod_access.c apache_1.3.23/src + break; +#endif + default: - a->type = T_FAIL; -- return "syntax error in mask portion of network/netmask"; ++ a->type = T_FAIL; + return "unknown address family for network"; } -- /* is it in /a.b.c.d form? */ -- if (strchr(s, '.')) { -- mask = ap_inet_addr(s); -- if (mask == INADDR_NONE) { -+ +- else { +- int i; + +- /* assume it's in /nnn form */ +- i = atoi(s); +- if (i > 32 || i <= 0) { + if (!justdigits) { + memset(&hints, 0, sizeof(hints)); + hints.ai_family = PF_UNSPEC; @@ -4210,21 +3887,14 @@ diff -Nur apache_1.3.23.orig/src/modules/standard/mod_access.c apache_1.3.23/src + if (resmask) + freeaddrinfo(resmask); a->type = T_FAIL; - return "syntax error in mask portion of network/netmask"; - } -- } -- else { -- /* assume it's in /nnn form */ -- mask = atoi(s); -- if (mask > 32 || mask <= 0) { -- a->type = T_FAIL; - return "invalid mask in network/netmask"; -- } -- mask = 0xFFFFFFFFUL << (32 - mask); -- mask = htonl(mask); ++ return "syntax error in mask portion of network/netmask"; + } +- mask.s_addr = 0xFFFFFFFFUL << (32 - i); +- mask.s_addr = htonl(mask.s_addr); - } - a->x.ip.mask = mask; -- a->x.ip.net = (a->x.ip.net & mask); /* pjr - This fixes PR 4770 */ +- a->x.ip.net.s_addr = (a->x.ip.net.s_addr & mask.s_addr); /* pjr - This fixes PR 4770 */ - } - else if (ap_isdigit(*where) && is_ip(where)) { - /* legacy syntax for ip addrs: a.b.c. ==> a.b.c.0/24 for example */ @@ -4235,8 +3905,8 @@ diff -Nur apache_1.3.23.orig/src/modules/standard/mod_access.c apache_1.3.23/src - a->type = T_IP; - /* parse components */ - s = where; -- a->x.ip.net = 0; -- a->x.ip.mask = 0; +- a->x.ip.net.s_addr = 0; +- a->x.ip.mask.s_addr = 0; - shift = 24; - while (*s) { - t = s; @@ -4245,14 +3915,14 @@ diff -Nur apache_1.3.23.orig/src/modules/standard/mod_access.c apache_1.3.23/src + freeaddrinfo(resmask); a->type = T_FAIL; - return "invalid ip address"; -+ return "network/netmask resolved to multiple addresses"; - } +- } - while (ap_isdigit(*t)) { - ++t; - } - if (*t == '.') { - *t++ = 0; -- } ++ return "network/netmask resolved to multiple addresses"; + } - else if (*t) { + memcpy(&mask, resmask->ai_addr, resmask->ai_addrlen); + freeaddrinfo(resmask); @@ -4263,6 +3933,7 @@ diff -Nur apache_1.3.23.orig/src/modules/standard/mod_access.c apache_1.3.23/src + return "network/netmask resolved to different address family"; } - if (shift < 0) { +- a->type = T_FAIL; - return "invalid ip address, only 4 octets allowed"; + + switch (a->type) { @@ -4310,16 +3981,28 @@ diff -Nur apache_1.3.23.orig/src/modules/standard/mod_access.c apache_1.3.23/src + } +#endif } -- a->x.ip.net |= octet << shift; -- a->x.ip.mask |= 0xFFUL << shift; +- a->x.ip.net.s_addr |= (unsigned int)octet << shift; +- a->x.ip.mask.s_addr |= 0xFFUL << shift; - s = t; - shift -= 8; } -- a->x.ip.net = ntohl(a->x.ip.net); -- a->x.ip.mask = ntohl(a->x.ip.mask); +- a->x.ip.net.s_addr = ntohl(a->x.ip.net.s_addr); +- a->x.ip.mask.s_addr = ntohl(a->x.ip.mask.s_addr); ++ /* mask network address */ ++ switch (a->type) { ++ case T_IP: ++ a->x.ip.net.s_addr &= a->x.ip.mask.s_addr; ++ break; ++ case T_IP6: ++ a->x.ip6.net6.s6_addr32[0] &= a->x.ip6.mask6.s6_addr32[0]; ++ a->x.ip6.net6.s6_addr32[1] &= a->x.ip6.mask6.s6_addr32[1]; ++ a->x.ip6.net6.s6_addr32[2] &= a->x.ip6.mask6.s6_addr32[2]; ++ a->x.ip6.net6.s6_addr32[3] &= a->x.ip6.mask6.s6_addr32[3]; ++ } } else { - a->type = T_HOST; +- } + struct addrinfo hints, *res; + struct sockaddr_storage ss; + int error; @@ -4363,7 +4046,7 @@ diff -Nur apache_1.3.23.orig/src/modules/standard/mod_access.c apache_1.3.23/src + a->type = T_FAIL; + return "each octet must be between 0 and 255 inclusive"; + } -+ a->x.ip.net.s_addr |= octet << shift; ++ a->x.ip.net.s_addr |= (unsigned int)octet << shift; + a->x.ip.mask.s_addr |= 0xFFUL << shift; + s = t; + shift -= 8; @@ -4415,16 +4098,17 @@ diff -Nur apache_1.3.23.orig/src/modules/standard/mod_access.c apache_1.3.23/src + a->type = T_FAIL; + return "unknown address family for network"; + } - } ++ } return NULL; -@@ -315,12 +464,63 @@ + } +@@ -275,13 +432,63 @@ return 1; case T_IP: -- if (ap[i].x.ip.net != INADDR_NONE +- if (ap[i].x.ip.net.s_addr != INADDR_NONE - && (r->connection->remote_addr.sin_addr.s_addr -- & ap[i].x.ip.mask) == ap[i].x.ip.net) { +- & ap[i].x.ip.mask.s_addr) == ap[i].x.ip.net.s_addr) { - return 1; + if (ap[i].x.ip.net.s_addr == INADDR_NONE) + break; @@ -4445,9 +4129,9 @@ diff -Nur apache_1.3.23.orig/src/modules/standard/mod_access.c apache_1.3.23/src + } + break; +#endif -+ } -+ break; -+ + } + break; + +#ifdef INET6 + case T_IP6: + { @@ -4479,16 +4163,16 @@ diff -Nur apache_1.3.23.orig/src/modules/standard/mod_access.c apache_1.3.23/src + if (memcmp(&masked, &ap[i].x.ip6.net6, sizeof(masked)) == 0) + return 1; + break; - } - break; ++ } ++ break; + } +#endif - case T_HOST: if (!gothost) { -diff -Nur apache_1.3.23.orig/src/modules/standard/mod_unique_id.c apache_1.3.23/src/modules/standard/mod_unique_id.c ---- apache_1.3.23.orig/src/modules/standard/mod_unique_id.c Tue Oct 2 18:11:13 2001 -+++ apache_1.3.23/src/modules/standard/mod_unique_id.c Wed Feb 6 20:20:48 2002 + remotehost = ap_get_remote_host(r->connection, r->per_dir_config, +diff -Nur apache_1.3.28.orig/src/modules/standard/mod_unique_id.c apache_1.3.28/src/modules/standard/mod_unique_id.c +--- apache_1.3.28.orig/src/modules/standard/mod_unique_id.c Mon Feb 3 18:13:30 2003 ++++ apache_1.3.28/src/modules/standard/mod_unique_id.c Fri Jul 25 11:01:55 2003 @@ -67,10 +67,22 @@ #include "http_config.h" #include "http_log.h" @@ -4618,9 +4302,9 @@ diff -Nur apache_1.3.23.orig/src/modules/standard/mod_unique_id.c apache_1.3.23/ /* * If we use 0 as the initial counter we have a little less protection -diff -Nur apache_1.3.23.orig/src/support/ab.c apache_1.3.23/src/support/ab.c ---- apache_1.3.23.orig/src/support/ab.c Mon Oct 8 19:54:42 2001 -+++ apache_1.3.23/src/support/ab.c Wed Feb 6 20:20:48 2002 +diff -Nur apache_1.3.28.orig/src/support/ab.c apache_1.3.28/src/support/ab.c +--- apache_1.3.28.orig/src/support/ab.c Sun Jul 6 19:52:27 2003 ++++ apache_1.3.28/src/support/ab.c Fri Jul 25 11:01:55 2003 @@ -158,6 +158,8 @@ #include #endif @@ -4639,7 +4323,7 @@ diff -Nur apache_1.3.23.orig/src/support/ab.c apache_1.3.23/src/support/ab.c int isproxy = 0; char path[1024]; /* path name */ char postfile[1024]; /* name of file containing post data */ -@@ -261,7 +263,7 @@ +@@ -262,7 +264,7 @@ auth[1024], /* optional (basic/uuencoded) * authentification */ hdrs[4096]; /* optional arbitrary headers */ @@ -4648,7 +4332,7 @@ diff -Nur apache_1.3.23.orig/src/support/ab.c apache_1.3.23/src/support/ab.c int use_html = 0; /* use html in the report */ char *tablestring; -@@ -298,7 +300,7 @@ +@@ -299,7 +301,7 @@ struct data *stats; /* date for each request */ fd_set readbits, writebits; /* bits for select */ @@ -4657,7 +4341,7 @@ diff -Nur apache_1.3.23.orig/src/support/ab.c apache_1.3.23/src/support/ab.c #ifndef BEOS #define ab_close(s) close(s) -@@ -509,7 +511,7 @@ +@@ -525,7 +527,7 @@ printf("\r \r"); printf("Server Software: %s\n", servername); printf("Server Hostname: %s\n", hostname); @@ -4666,7 +4350,7 @@ diff -Nur apache_1.3.23.orig/src/support/ab.c apache_1.3.23/src/support/ab.c printf("\n"); printf("Document Path: %s\n", path); printf("Document Length: %d bytes\n", doclen); -@@ -862,7 +864,7 @@ +@@ -878,7 +880,7 @@ c->cbx = 0; c->gotheader = 0; @@ -4674,8 +4358,8 @@ diff -Nur apache_1.3.23.orig/src/support/ab.c apache_1.3.23/src/support/ab.c + c->fd = socket(server.ss_family, SOCK_STREAM, 0); if (c->fd < 0) { what = "SOCKET"; - goto bad; -@@ -879,7 +881,12 @@ + goto _bad; +@@ -895,7 +897,12 @@ again: gettimeofday(&c->start, 0); @@ -4686,42 +4370,43 @@ diff -Nur apache_1.3.23.orig/src/support/ab.c apache_1.3.23/src/support/ab.c + if (connect(c->fd, (struct sockaddr *) & server, server.ss_len) < 0) +#endif + { - if (errno == EINPROGRESS) { - c->state = STATE_CONNECTING; - } -@@ -1171,7 +1178,7 @@ + if (errno != EINPROGRESS) { + what = "CONNECT"; + goto _bad; +@@ -1189,7 +1196,7 @@ struct timeval timeout, now; fd_set sel_read, sel_except, sel_write; long i; - int connectport; + char * connectport; - char * url_on_request, * host; + char * connecthost; + char * url_on_request; - /* There are four hostname's involved: -@@ -1209,16 +1216,21 @@ +@@ -1232,17 +1239,21 @@ } { /* get server information */ - struct hostent *he; -- he = gethostbyname(host); +- he = gethostbyname(connecthost); - if (!he) { - char theerror[1024]; -- sprintf(theerror, "Bad hostname: %s\n", host); +- ap_snprintf(theerror, sizeof(theerror), +- "Bad hostname: %s\n", connecthost); - err(theerror); - } - server.sin_family = he->h_addrtype; - server.sin_port = htons(connectport); - server.sin_addr.s_addr = ((unsigned long *) (he->h_addr_list[0]))[0]; -+ struct addrinfo hints, *res; ++ struct addrinfo hints, *res; + int error; + + memset(&hints, 0, sizeof(hints)); + hints.ai_family = PF_UNSPEC; + hints.ai_socktype = SOCK_STREAM; -+ error = getaddrinfo(host, connectport, &hints, &res); ++ error = getaddrinfo(connecthost, connectport, &hints, &res); + if (error) { -+ char *theerror=malloc(strlen(host)+16); -+ sprintf(theerror, "Bad hostname: %s\n", host); ++ char *theerror=malloc(strlen(connecthost)+16); ++ sprintf(theerror, "Bad hostname: %s\n", connecthost); + err(theerror); + free(theerror); + } @@ -4730,7 +4415,7 @@ diff -Nur apache_1.3.23.orig/src/support/ab.c apache_1.3.23/src/support/ab.c } con = malloc(concurrency * sizeof(struct connection)); -@@ -1404,7 +1416,7 @@ +@@ -1430,7 +1441,7 @@ if (strlen(purl) > 8 && strncmp(purl, "https://", 8) == 0) { purl += 8; ssl = 1; @@ -4739,16 +4424,27 @@ diff -Nur apache_1.3.23.orig/src/support/ab.c apache_1.3.23/src/support/ab.c } #else if (strlen(purl) > 8 && strncmp(purl, "https://", 8) == 0) { -@@ -1425,7 +1437,7 @@ +@@ -1451,15 +1462,15 @@ *cp = '\0'; strcpy(hostname, h); if (p != NULL) - port = atoi(p); -+ port = strdup(p); - return 0; - } ++ port = strdup(p); -@@ -1585,7 +1597,7 @@ + if (( + #ifdef USE_SSL +- (ssl != 0) && (port != 443)) || ((ssl == 0) && ++ (ssl != 0) && (strcmp(port, "443"))) || ((ssl == 0) && + #endif +- (port != 80))) ++ (strcmp(port, "80")))) + { +- ap_snprintf(colonport,sizeof(colonport),":%d",port); ++ ap_snprintf(colonport,sizeof(colonport),":%s",port); + } else { + colonport[0] = '\0'; + } +@@ -1622,7 +1633,7 @@ if ((p = strchr(optarg, ':'))) { *p = '\0'; p++; @@ -4757,7 +4453,7 @@ diff -Nur apache_1.3.23.orig/src/support/ab.c apache_1.3.23/src/support/ab.c }; strcpy(proxyhost, optarg); isproxy = 1; -@@ -1668,3 +1680,7 @@ +@@ -1705,3 +1716,7 @@ exit(0); } @@ -4765,9 +4461,9 @@ diff -Nur apache_1.3.23.orig/src/support/ab.c apache_1.3.23/src/support/ab.c +#ifdef NEED_GETADDRINFO +#include "../main/getaddrinfo.c" +#endif -diff -Nur apache_1.3.23.orig/src/support/logresolve.c apache_1.3.23/src/support/logresolve.c ---- apache_1.3.23.orig/src/support/logresolve.c Wed May 23 00:52:21 2001 -+++ apache_1.3.23/src/support/logresolve.c Wed Feb 6 20:20:48 2002 +diff -Nur apache_1.3.28.orig/src/support/logresolve.c apache_1.3.28/src/support/logresolve.c +--- apache_1.3.28.orig/src/support/logresolve.c Wed May 23 00:52:21 2001 ++++ apache_1.3.28/src/support/logresolve.c Fri Jul 25 11:01:55 2003 @@ -54,7 +54,9 @@ #endif /* BEOS */ #endif /* !MPE && !WIN32*/ @@ -5010,3 +4706,46 @@ diff -Nur apache_1.3.23.orig/src/support/logresolve.c apache_1.3.23/src/support/ +#ifdef NEED_GETNAMEINFO +#include "../main/getnameinfo.c" +#endif +--- apache_1.3.28/src/modules/standard/mod_usertrack.c.orig Mon Feb 3 18:13:30 2003 ++++ apache_1.3.28/src/modules/standard/mod_usertrack.c Fri Jul 25 13:13:43 2003 +@@ -162,7 +162,7 @@ + long reqtime = (long) r->request_time; + long clocktime; + +- unsigned long ipaddr = ntohl(r->connection->remote_addr.sin_addr.s_addr); ++ unsigned long ipaddr = ntohl(((struct sockaddr_in*)&r->connection->remote_addr)->sin_addr.s_addr); + const char *rname = ap_get_remote_host(r->connection, r->per_dir_config, + REMOTE_NAME); + dcfg = ap_get_module_config(r->per_dir_config, &usertrack_module); +--- apache_1.3.31/src/modules/standard/mod_rewrite.c.orig Wed May 12 14:57:09 2004 ++++ apache_1.3.31/src/modules/standard/mod_rewrite.c Wed May 12 15:40:04 2004 +@@ -48,6 +48,7 @@ + + + #include "mod_rewrite.h" ++#include "sa_len.h" + + #ifndef NO_WRITEV + #ifndef NETWARE +@@ -3651,8 +3652,19 @@ + result = r->connection->remote_ip; + } + else if (strcasecmp(var, "REMOTE_PORT") == 0) { +- return ap_psprintf(r->pool, "%d", +- ntohs(r->connection->remote_addr.sin_port)); ++ char servbuf[NI_MAXSERV]; ++ servbuf[0] = '\0'; ++ if (!getnameinfo((struct sockaddr *)&r->connection->remote_addr, ++#ifndef HAVE_SOCKADDR_LEN ++ SA_LEN((struct sockaddr *)&r->connection->remote_addr), ++#else ++ r->connection->remote_addr.ss_len, ++#endif ++ NULL, 0, servbuf, sizeof(servbuf), NI_NUMERICSERV)) { ++ return ap_pstrdup(r->pool, servbuf); ++ } else { ++ return ap_pstrdup(r->pool, ""); ++ } + } + else if (strcasecmp(var, "REMOTE_HOST") == 0) { + result = (char *)ap_get_remote_host(r->connection,