X-Git-Url: http://git.pld-linux.org/?a=blobdiff_plain;f=apache-ipv6-PLD.patch;h=13ab0b34cf4255b097d4b9a8cb0920ea581cc884;hb=7e18288880913b10e6b2b8a0a741b9f98c54d839;hp=aa30c934b729135dc914a6c9c79d8a0a4adc97e7;hpb=35b9807ce51c56423693284e2811814543815e9e;p=packages%2Fapache.git diff --git a/apache-ipv6-PLD.patch b/apache-ipv6-PLD.patch index aa30c93..13ab0b3 100644 --- a/apache-ipv6-PLD.patch +++ b/apache-ipv6-PLD.patch @@ -1,6 +1,6 @@ -diff -Nur apache_1.3.22.orig/README.v6 apache_1.3.22/README.v6 ---- apache_1.3.22.orig/README.v6 Thu Jan 1 01:00:00 1970 -+++ apache_1.3.22/README.v6 Fri Dec 7 17:27:28 2001 +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 @@ -163,14 +163,14 @@ diff -Nur apache_1.3.22.orig/README.v6 apache_1.3.22/README.v6 +Linux Port + Arkadiusz Miskiewicz, Polish Linux Distribution project (IPv6) + http://www.pld.org.pl/ -+ mailto:pld-list@pld.org.pl ++ mailto:feedback@pld.org.pl + Satoshi SHIDA, Linux IPv6 Users Group JP + http://www.v6.linux.or.jp/ + YOSHIFUJI Hideaki, USAGI Project + http://www.linux-ipv6.org/ -diff -Nur apache_1.3.22.orig/conf/httpd.conf-dist apache_1.3.22/conf/httpd.conf-dist ---- apache_1.3.22.orig/conf/httpd.conf-dist Sat Oct 6 05:40:04 2001 -+++ apache_1.3.22/conf/httpd.conf-dist Fri Dec 7 17:27:28 2001 +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.22.orig/conf/httpd.conf-dist apache_1.3.22/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.22.orig/configure.v6 apache_1.3.22/configure.v6 ---- apache_1.3.22.orig/configure.v6 Thu Jan 1 01:00:00 1970 -+++ apache_1.3.22/configure.v6 Fri Dec 7 17:27:28 2001 +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.22.orig/src/Configuration.tmpl apache_1.3.22/src/Configuration.tmpl ---- apache_1.3.22.orig/src/Configuration.tmpl Fri Dec 7 17:26:57 2001 -+++ apache_1.3.22/src/Configuration.tmpl Fri Dec 7 17:27:28 2001 +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 @@ -200,29 +200,29 @@ diff -Nur apache_1.3.22.orig/src/Configuration.tmpl apache_1.3.22/src/Configurat +# INET6: +# IPv6 support. +# - - Rule SOCKS4=no - Rule SOCKS5=no -@@ -198,6 +201,7 @@ + # + # CYGWIN_WINSOCK: + # Use Win32 API system calls for socket communication instead +@@ -205,6 +208,7 @@ Rule IRIXN32=yes Rule PARANOID=no Rule EXPAT=default +Rule INET6=no + Rule CYGWIN_WINSOCK=no # DEV_RANDOM: - # Note: this rule is only used when compiling mod_auth_digest. -diff -Nur apache_1.3.22.orig/src/Configure apache_1.3.22/src/Configure ---- apache_1.3.22.orig/src/Configure Fri Dec 7 17:26:57 2001 -+++ apache_1.3.22/src/Configure Fri Dec 7 17:27:28 2001 -@@ -237,6 +237,7 @@ - RULE_EXPAT=`./helpers/CutRule EXPAT $file` +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` RULE_SHARED_CHAIN=`./helpers/CutRule SHARED_CHAIN $file` +RULE_INET6=`./helpers/CutRule INET6 $file` #################################################################### ## Rule SHARED_CORE implies required DSO support -@@ -1692,6 +1693,124 @@ +@@ -1724,6 +1725,124 @@ esac fi @@ -347,7 +347,7 @@ diff -Nur apache_1.3.22.orig/src/Configure apache_1.3.22/src/Configure #################################################################### ## Find out what modules we want and try and configure things for them ## Module lines can look like this: -@@ -2287,6 +2406,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.22.orig/src/Configure apache_1.3.22/src/Configure #################################################################### ## More building ap_config_auto.h ## -diff -Nur apache_1.3.22.orig/src/ap/ap_snprintf.c apache_1.3.22/src/ap/ap_snprintf.c ---- apache_1.3.22.orig/src/ap/ap_snprintf.c Thu May 10 16:04:22 2001 -+++ apache_1.3.22/src/ap/ap_snprintf.c Fri Dec 7 17:27:28 2001 +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.22.orig/src/ap/ap_snprintf.c apache_1.3.22/src/ap/ap_snprin #ifdef WIN32 #include #endif -@@ -504,6 +505,42 @@ +@@ -510,6 +511,42 @@ @@ -440,1295 +440,35 @@ diff -Nur apache_1.3.22.orig/src/ap/ap_snprintf.c apache_1.3.22/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': - { -+#ifndef INET6 - struct sockaddr_in *si; - - si = va_arg(ap, struct sockaddr_in *); -@@ -1063,6 +1101,16 @@ - if (adjust_precision && precision < s_len) - s_len = precision; - } -+#else -+ struct sockaddr *sa; -+ -+ sa = va_arg(ap, struct sockaddr *); -+ if (sa != NULL) { -+ s = conv_sockaddr(sa, &num_buf[NUM_BUF_SIZE], &s_len); -+ if (adjust_precision && precision < s_len) -+ s_len = precision; -+ } -+#endif - else { - s = S_NULL; - s_len = S_NULL_LEN; -diff -Nur apache_1.3.22.orig/src/ap/ap_snprintf.c~ apache_1.3.22/src/ap/ap_snprintf.c~ ---- apache_1.3.22.orig/src/ap/ap_snprintf.c~ Thu Jan 1 01:00:00 1970 -+++ apache_1.3.22/src/ap/ap_snprintf.c~ Fri Dec 7 17:27:28 2001 -@@ -0,0 +1,1256 @@ -+/* ==================================================================== -+ * 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. -+ */ -+ -+/* -+ * This code is based on, and used with the permission of, the -+ * SIO stdio-replacement strx_* functions by Panos Tsirigotis -+ * for xinetd. -+ */ -+ -+#include "httpd.h" -+ -+#include -+#include -+#ifndef NETWARE -+#include -+#endif -+#include -+#include -+#include -+#include -+#ifdef WIN32 -+#include -+#endif -+ -+typedef enum { -+ NO = 0, YES = 1 -+} boolean_e; -+ -+#ifndef FALSE -+#define FALSE 0 -+#endif -+#ifndef TRUE -+#define TRUE 1 -+#endif -+#ifndef AP_LONGEST_LONG -+#define AP_LONGEST_LONG long -+#endif -+#define NUL '\0' -+#define WIDE_INT long -+#define WIDEST_INT AP_LONGEST_LONG -+ -+typedef WIDE_INT wide_int; -+typedef unsigned WIDE_INT u_wide_int; -+typedef WIDEST_INT widest_int; -+#ifdef __TANDEM -+/* Although Tandem supports "long long" there is no unsigned variant. */ -+typedef unsigned long u_widest_int; -+#else -+typedef unsigned WIDEST_INT u_widest_int; -+#endif -+typedef int bool_int; -+ -+#define S_NULL "(null)" -+#define S_NULL_LEN 6 -+ -+#define FLOAT_DIGITS 6 -+#define EXPONENT_LENGTH 10 -+ -+/* -+ * NUM_BUF_SIZE is the size of the buffer used for arithmetic conversions -+ * -+ * XXX: this is a magic number; do not decrease it -+ */ -+#define NUM_BUF_SIZE 512 -+ -+/* -+ * cvt.c - IEEE floating point formatting routines for FreeBSD -+ * from GNU libc-4.6.27. Modified to be thread safe. -+ */ -+ -+/* -+ * ap_ecvt converts to decimal -+ * the number of digits is specified by ndigit -+ * decpt is set to the position of the decimal point -+ * sign is set to 0 for positive, 1 for negative -+ */ -+ -+#define NDIG 80 -+ -+/* buf must have at least NDIG bytes */ -+static char *ap_cvt(double arg, int ndigits, int *decpt, int *sign, int eflag, char *buf) -+{ -+ register int r2; -+ double fi, fj; -+ register char *p, *p1; -+ -+ if (ndigits >= NDIG - 1) -+ ndigits = NDIG - 2; -+ r2 = 0; -+ *sign = 0; -+ p = &buf[0]; -+ if (arg < 0) { -+ *sign = 1; -+ arg = -arg; -+ } -+ arg = modf(arg, &fi); -+ p1 = &buf[NDIG]; -+ /* -+ * Do integer part -+ */ -+ if (fi != 0) { -+ p1 = &buf[NDIG]; -+ while (p1 > &buf[0] && fi != 0) { -+ fj = modf(fi / 10, &fi); -+ *--p1 = (int) ((fj + .03) * 10) + '0'; -+ r2++; -+ } -+ while (p1 < &buf[NDIG]) -+ *p++ = *p1++; -+ } -+ else if (arg > 0) { -+ while ((fj = arg * 10) < 1) { -+ arg = fj; -+ r2--; -+ } -+ } -+ p1 = &buf[ndigits]; -+ if (eflag == 0) -+ p1 += r2; -+ *decpt = r2; -+ if (p1 < &buf[0]) { -+ buf[0] = '\0'; -+ return (buf); -+ } -+ while (p <= p1 && p < &buf[NDIG]) { -+ arg *= 10; -+ arg = modf(arg, &fj); -+ *p++ = (int) fj + '0'; -+ } -+ if (p1 >= &buf[NDIG]) { -+ buf[NDIG - 1] = '\0'; -+ return (buf); -+ } -+ p = p1; -+ *p1 += 5; -+ while (*p1 > '9') { -+ *p1 = '0'; -+ if (p1 > buf) -+ ++ * --p1; -+ else { -+ *p1 = '1'; -+ (*decpt)++; -+ if (eflag == 0) { -+ if (p > buf) -+ *p = '0'; -+ p++; -+ } -+ } -+ } -+ *p = '\0'; -+ return (buf); -+} -+ -+static char *ap_ecvt(double arg, int ndigits, int *decpt, int *sign, char *buf) -+{ -+ return (ap_cvt(arg, ndigits, decpt, sign, 1, buf)); -+} -+ -+static char *ap_fcvt(double arg, int ndigits, int *decpt, int *sign, char *buf) -+{ -+ return (ap_cvt(arg, ndigits, decpt, sign, 0, buf)); -+} -+ -+/* -+ * ap_gcvt - Floating output conversion to -+ * minimal length string -+ */ -+ -+static char *ap_gcvt(double number, int ndigit, char *buf, boolean_e altform) -+{ -+ int sign, decpt; -+ register char *p1, *p2; -+ register int i; -+ char buf1[NDIG]; -+ -+ p1 = ap_ecvt(number, ndigit, &decpt, &sign, buf1); -+ p2 = buf; -+ if (sign) -+ *p2++ = '-'; -+ for (i = ndigit - 1; i > 0 && p1[i] == '0'; i--) -+ ndigit--; -+ if ((decpt >= 0 && decpt - ndigit > 4) -+ || (decpt < 0 && decpt < -3)) { /* use E-style */ -+ decpt--; -+ *p2++ = *p1++; -+ *p2++ = '.'; -+ for (i = 1; i < ndigit; i++) -+ *p2++ = *p1++; -+ *p2++ = 'e'; -+ if (decpt < 0) { -+ decpt = -decpt; -+ *p2++ = '-'; -+ } -+ else -+ *p2++ = '+'; -+ if (decpt / 100 > 0) -+ *p2++ = decpt / 100 + '0'; -+ if (decpt / 10 > 0) -+ *p2++ = (decpt % 100) / 10 + '0'; -+ *p2++ = decpt % 10 + '0'; -+ } -+ else { -+ if (decpt <= 0) { -+ if (*p1 != '0') -+ *p2++ = '.'; -+ while (decpt < 0) { -+ decpt++; -+ *p2++ = '0'; -+ } -+ } -+ for (i = 1; i <= ndigit; i++) { -+ *p2++ = *p1++; -+ if (i == decpt) -+ *p2++ = '.'; -+ } -+ if (ndigit < decpt) { -+ while (ndigit++ < decpt) -+ *p2++ = '0'; -+ *p2++ = '.'; -+ } -+ } -+ if (p2[-1] == '.' && !altform) -+ p2--; -+ *p2 = '\0'; -+ return (buf); -+} -+ -+/* -+ * The INS_CHAR macro inserts a character in the buffer and writes -+ * the buffer back to disk if necessary -+ * It uses the char pointers sp and bep: -+ * sp points to the next available character in the buffer -+ * bep points to the end-of-buffer+1 -+ * While using this macro, note that the nextb pointer is NOT updated. -+ * -+ * NOTE: Evaluation of the c argument should not have any side-effects -+ */ -+#define INS_CHAR(c, sp, bep, cc) \ -+ { \ -+ if (sp >= bep) { \ -+ vbuff->curpos = sp; \ -+ if (flush_func(vbuff)) \ -+ return -1; \ -+ sp = vbuff->curpos; \ -+ bep = vbuff->endpos; \ -+ } \ -+ *sp++ = (c); \ -+ cc++; \ -+ } -+ -+#define NUM( c ) ( c - '0' ) -+ -+#define STR_TO_DEC( str, num ) \ -+ num = NUM( *str++ ) ; \ -+ while ( ap_isdigit( *str ) ) \ -+ { \ -+ num *= 10 ; \ -+ num += NUM( *str++ ) ; \ -+ } -+ -+/* -+ * This macro does zero padding so that the precision -+ * requirement is satisfied. The padding is done by -+ * adding '0's to the left of the string that is going -+ * to be printed. -+ */ -+#define FIX_PRECISION( adjust, precision, s, s_len ) \ -+ if ( adjust ) \ -+ while ( s_len < precision ) \ -+ { \ -+ *--s = '0' ; \ -+ s_len++ ; \ -+ } -+ -+/* -+ * Macro that does padding. The padding is done by printing -+ * the character ch. -+ */ -+#define PAD( width, len, ch ) do \ -+ { \ -+ INS_CHAR( ch, sp, bep, cc ) ; \ -+ width-- ; \ -+ } \ -+ while ( width > len ) -+ -+/* -+ * Prefix the character ch to the string str -+ * Increase length -+ * Set the has_prefix flag -+ */ -+#define PREFIX( str, length, ch ) *--str = ch ; length++ ; has_prefix = YES -+ -+ -+/* -+ * Convert num to its decimal format. -+ * Return value: -+ * - a pointer to a string containing the number (no sign) -+ * - len contains the length of the string -+ * - is_negative is set to TRUE or FALSE depending on the sign -+ * of the number (always set to FALSE if is_unsigned is TRUE) -+ * -+ * The caller provides a buffer for the string: that is the buf_end argument -+ * which is a pointer to the END of the buffer + 1 (i.e. if the buffer -+ * is declared as buf[ 100 ], buf_end should be &buf[ 100 ]) -+ * -+ * Note: we have 2 versions. One is used when we need to use quads -+ * (conv_10_quad), the other when we don't (conv_10). We're assuming the -+ * latter is faster. -+ */ -+static char *conv_10(register wide_int num, register bool_int is_unsigned, -+ register bool_int *is_negative, char *buf_end, -+ register int *len) -+{ -+ register char *p = buf_end; -+ register u_wide_int magnitude; -+ -+ if (is_unsigned) { -+ magnitude = (u_wide_int) num; -+ *is_negative = FALSE; -+ } -+ else { -+ *is_negative = (num < 0); -+ -+ /* -+ * On a 2's complement machine, negating the most negative integer -+ * results in a number that cannot be represented as a signed integer. -+ * Here is what we do to obtain the number's magnitude: -+ * a. add 1 to the number -+ * b. negate it (becomes positive) -+ * c. convert it to unsigned -+ * d. add 1 -+ */ -+ if (*is_negative) { -+ wide_int t = num + 1; -+ -+ magnitude = ((u_wide_int) -t) + 1; -+ } -+ else -+ magnitude = (u_wide_int) num; -+ } -+ -+ /* -+ * We use a do-while loop so that we write at least 1 digit -+ */ -+ do { -+ register u_wide_int new_magnitude = magnitude / 10; -+ -+ *--p = (char) (magnitude - new_magnitude * 10 + '0'); -+ magnitude = new_magnitude; -+ } -+ while (magnitude); -+ -+ *len = buf_end - p; -+ return (p); -+} -+ -+static char *conv_10_quad(widest_int num, register bool_int is_unsigned, -+ register bool_int *is_negative, char *buf_end, -+ register int *len) -+{ -+ register char *p = buf_end; -+ u_widest_int magnitude; -+ -+ /* -+ * We see if we can use the faster non-quad version by checking the -+ * number against the largest long value it can be. If <=, we -+ * punt to the quicker version. -+ */ -+ if ((num <= ULONG_MAX && is_unsigned) || (num <= LONG_MAX && !is_unsigned)) -+ return(conv_10( (wide_int)num, is_unsigned, is_negative, -+ buf_end, len)); -+ -+ if (is_unsigned) { -+ magnitude = (u_widest_int) num; -+ *is_negative = FALSE; -+ } -+ else { -+ *is_negative = (num < 0); -+ -+ /* -+ * On a 2's complement machine, negating the most negative integer -+ * results in a number that cannot be represented as a signed integer. -+ * Here is what we do to obtain the number's magnitude: -+ * a. add 1 to the number -+ * b. negate it (becomes positive) -+ * c. convert it to unsigned -+ * d. add 1 -+ */ -+ if (*is_negative) { -+ widest_int t = num + 1; -+ -+ magnitude = ((u_widest_int) -t) + 1; -+ } -+ else -+ magnitude = (u_widest_int) num; -+ } -+ -+ /* -+ * We use a do-while loop so that we write at least 1 digit -+ */ -+ do { -+ u_widest_int new_magnitude = magnitude / 10; -+ -+ *--p = (char) (magnitude - new_magnitude * 10 + '0'); -+ magnitude = new_magnitude; -+ } -+ while (magnitude); -+ -+ *len = buf_end - p; -+ return (p); -+} -+ -+ -+ -+static char *conv_in_addr(struct in_addr *ia, char *buf_end, int *len) -+{ -+ unsigned addr = ntohl(ia->s_addr); -+ char *p = buf_end; -+ bool_int is_negative; -+ int sub_len; -+ -+ p = conv_10((addr & 0x000000FF) , TRUE, &is_negative, p, &sub_len); -+ *--p = '.'; -+ p = conv_10((addr & 0x0000FF00) >> 8, TRUE, &is_negative, p, &sub_len); -+ *--p = '.'; -+ p = conv_10((addr & 0x00FF0000) >> 16, TRUE, &is_negative, p, &sub_len); -+ *--p = '.'; -+ p = conv_10((addr & 0xFF000000) >> 24, TRUE, &is_negative, p, &sub_len); -+ -+ *len = buf_end - p; -+ return (p); -+} -+ -+ -+ -+static char *conv_sockaddr_in(struct sockaddr_in *si, char *buf_end, int *len) -+{ -+ char *p = buf_end; -+ bool_int is_negative; -+ int sub_len; -+ -+ p = conv_10(ntohs(si->sin_port), TRUE, &is_negative, p, &sub_len); -+ *--p = ':'; -+ p = conv_in_addr(&si->sin_addr, p, &sub_len); -+ -+ *len = buf_end - p; -+ return (p); -+} -+ -+ -+ -+#ifdef INET6 -+static char *conv_sockaddr(struct sockaddr *sa, char *buf_end, int *len) -+{ -+ char *p = buf_end; -+ char hostnamebuf[MAXHOSTNAMELEN]; -+ char portnamebuf[MAXHOSTNAMELEN]; -+ char *q; -+ int salen; -+ -+#ifndef SIN6_LEN -+ salen = SA_LEN(sa); -+#else -+ salen = sa->sa_len; -+#endif -+ if (getnameinfo(sa, salen, hostnamebuf, sizeof(hostnamebuf), -+ portnamebuf, sizeof(portnamebuf), NI_NUMERICHOST | NI_NUMERICSERV)) { -+ strcpy(hostnamebuf, "???"); -+ strcpy(portnamebuf, "???"); -+ } -+ if (strcmp(portnamebuf,"0") == 0) -+ strcpy(portnamebuf, "*"); -+ q = portnamebuf + strlen(portnamebuf); -+ while (portnamebuf < q) -+ *--p = *--q; -+ *--p = ':'; -+ q = hostnamebuf + strlen(hostnamebuf); -+ while (hostnamebuf < q) -+ *--p = *--q; -+ -+ *len = buf_end - p; -+ return (p); -+} -+#endif /*INET6*/ -+ -+ -+ -+/* -+ * 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 -+ * The sign is returned in the is_negative argument (and is not placed -+ * in buf). -+ */ -+static char *conv_fp(register char format, register double num, -+ boolean_e add_dp, int precision, bool_int *is_negative, -+ char *buf, int *len) -+{ -+ register char *s = buf; -+ register char *p; -+ int decimal_point; -+ char buf1[NDIG]; -+ -+ if (format == 'f') -+ p = ap_fcvt(num, precision, &decimal_point, is_negative, buf1); -+ else /* either e or E format */ -+ p = ap_ecvt(num, precision + 1, &decimal_point, is_negative, buf1); -+ -+ /* -+ * Check for Infinity and NaN -+ */ -+ if (ap_isalpha(*p)) { -+ *len = strlen(strcpy(buf, p)); -+ *is_negative = FALSE; -+ return (buf); -+ } -+ -+ if (format == 'f') { -+ if (decimal_point <= 0) { -+ *s++ = '0'; -+ if (precision > 0) { -+ *s++ = '.'; -+ while (decimal_point++ < 0) -+ *s++ = '0'; -+ } -+ else if (add_dp) -+ *s++ = '.'; -+ } -+ else { -+ while (decimal_point-- > 0) -+ *s++ = *p++; -+ if (precision > 0 || add_dp) -+ *s++ = '.'; -+ } -+ } -+ else { -+ *s++ = *p++; -+ if (precision > 0 || add_dp) -+ *s++ = '.'; -+ } -+ -+ /* -+ * copy the rest of p, the NUL is NOT copied -+ */ -+ while (*p) -+ *s++ = *p++; -+ -+ if (format != 'f') { -+ char temp[EXPONENT_LENGTH]; /* for exponent conversion */ -+ int t_len; -+ bool_int exponent_is_negative; -+ -+ *s++ = format; /* either e or E */ -+ decimal_point--; -+ if (decimal_point != 0) { -+ p = conv_10((wide_int) decimal_point, FALSE, &exponent_is_negative, -+ &temp[EXPONENT_LENGTH], &t_len); -+ *s++ = exponent_is_negative ? '-' : '+'; -+ -+ /* -+ * Make sure the exponent has at least 2 digits -+ */ -+ if (t_len == 1) -+ *s++ = '0'; -+ while (t_len--) -+ *s++ = *p++; -+ } -+ else { -+ *s++ = '+'; -+ *s++ = '0'; -+ *s++ = '0'; -+ } -+ } -+ -+ *len = s - buf; -+ return (buf); -+} -+ -+ -+/* -+ * Convert num to a base X number where X is a power of 2. nbits determines X. -+ * For example, if nbits is 3, we do base 8 conversion -+ * Return value: -+ * a pointer to a string containing the number -+ * -+ * The caller provides a buffer for the string: that is the buf_end argument -+ * which is a pointer to the END of the buffer + 1 (i.e. if the buffer -+ * is declared as buf[ 100 ], buf_end should be &buf[ 100 ]) -+ * -+ * As with conv_10, we have a faster version which is used when -+ * the number isn't quad size. -+ */ -+static char *conv_p2(register u_wide_int num, register int nbits, -+ char format, char *buf_end, register int *len) -+{ -+ register int mask = (1 << nbits) - 1; -+ register char *p = buf_end; -+ static const char low_digits[] = "0123456789abcdef"; -+ static const char upper_digits[] = "0123456789ABCDEF"; -+ register const char *digits = (format == 'X') ? upper_digits : low_digits; -+ -+ do { -+ *--p = digits[num & mask]; -+ num >>= nbits; -+ } -+ while (num); -+ -+ *len = buf_end - p; -+ return (p); -+} -+ -+static char *conv_p2_quad(u_widest_int num, register int nbits, -+ char format, char *buf_end, register int *len) -+{ -+ register int mask = (1 << nbits) - 1; -+ register char *p = buf_end; -+ static const char low_digits[] = "0123456789abcdef"; -+ static const char upper_digits[] = "0123456789ABCDEF"; -+ register const char *digits = (format == 'X') ? upper_digits : low_digits; -+ -+ if (num <= ULONG_MAX) -+ return(conv_p2( (u_wide_int)num, nbits, format, buf_end, len)); -+ -+ do { -+ *--p = digits[num & mask]; -+ num >>= nbits; -+ } -+ while (num); -+ -+ *len = buf_end - p; -+ return (p); -+} -+ -+ -+/* -+ * Do format conversion placing the output in buffer -+ */ -+API_EXPORT(int) ap_vformatter(int (*flush_func)(ap_vformatter_buff *), -+ ap_vformatter_buff *vbuff, const char *fmt, va_list ap) -+{ -+ register char *sp; -+ register char *bep; -+ register int cc = 0; -+ register int i; -+ -+ register char *s = NULL; -+ char *q; -+ int s_len; -+ -+ register int min_width = 0; -+ int precision = 0; -+ enum { -+ LEFT, RIGHT -+ } adjust; -+ char pad_char; -+ char prefix_char; -+ -+ double fp_num; -+ widest_int i_quad = (widest_int) 0; -+ u_widest_int ui_quad; -+ wide_int i_num = (wide_int) 0; -+ u_wide_int ui_num; -+ -+ char num_buf[NUM_BUF_SIZE]; -+ char char_buf[2]; /* for printing %% and % */ -+ -+ enum var_type_enum { -+ IS_QUAD, IS_LONG, IS_SHORT, IS_INT -+ }; -+ enum var_type_enum var_type = IS_INT; -+ -+ /* -+ * Flag variables -+ */ -+ boolean_e alternate_form; -+ boolean_e print_sign; -+ boolean_e print_blank; -+ boolean_e adjust_precision; -+ boolean_e adjust_width; -+ bool_int is_negative; -+ -+ sp = vbuff->curpos; -+ bep = vbuff->endpos; -+ -+ while (*fmt) { -+ if (*fmt != '%') { -+ INS_CHAR(*fmt, sp, bep, cc); -+ } -+ else { -+ /* -+ * Default variable settings -+ */ -+ adjust = RIGHT; -+ alternate_form = print_sign = print_blank = NO; -+ pad_char = ' '; -+ prefix_char = NUL; -+ -+ fmt++; -+ -+ /* -+ * Try to avoid checking for flags, width or precision -+ */ -+ if (!ap_islower(*fmt)) { -+ /* -+ * Recognize flags: -, #, BLANK, + -+ */ -+ for (;; fmt++) { -+ if (*fmt == '-') -+ adjust = LEFT; -+ else if (*fmt == '+') -+ print_sign = YES; -+ else if (*fmt == '#') -+ alternate_form = YES; -+ else if (*fmt == ' ') -+ print_blank = YES; -+ else if (*fmt == '0') -+ pad_char = '0'; -+ else -+ break; -+ } -+ -+ /* -+ * Check if a width was specified -+ */ -+ if (ap_isdigit(*fmt)) { -+ STR_TO_DEC(fmt, min_width); -+ adjust_width = YES; -+ } -+ else if (*fmt == '*') { -+ min_width = va_arg(ap, int); -+ fmt++; -+ adjust_width = YES; -+ if (min_width < 0) { -+ adjust = LEFT; -+ min_width = -min_width; -+ } -+ } -+ else -+ adjust_width = NO; -+ -+ /* -+ * Check if a precision was specified -+ * -+ * XXX: an unreasonable amount of precision may be specified -+ * resulting in overflow of num_buf. Currently we -+ * ignore this possibility. -+ */ -+ if (*fmt == '.') { -+ adjust_precision = YES; -+ fmt++; -+ if (ap_isdigit(*fmt)) { -+ STR_TO_DEC(fmt, precision); -+ } -+ else if (*fmt == '*') { -+ precision = va_arg(ap, int); -+ fmt++; -+ if (precision < 0) -+ precision = 0; -+ } -+ else -+ precision = 0; -+ } -+ else -+ adjust_precision = NO; -+ } -+ else -+ adjust_precision = adjust_width = NO; -+ -+ /* -+ * Modifier check -+ */ -+ if (*fmt == 'q') { -+ var_type = IS_QUAD; -+ fmt++; -+ } -+ else if (*fmt == 'l') { -+ var_type = IS_LONG; -+ fmt++; -+ } -+ else if (*fmt == 'h') { -+ var_type = IS_SHORT; -+ fmt++; -+ } -+ else { -+ var_type = IS_INT; -+ } -+ -+ /* -+ * Argument extraction and printing. -+ * First we determine the argument type. -+ * Then, we convert the argument to a string. -+ * On exit from the switch, s points to the string that -+ * must be printed, s_len has the length of the string -+ * The precision requirements, if any, are reflected in s_len. -+ * -+ * NOTE: pad_char may be set to '0' because of the 0 flag. -+ * It is reset to ' ' by non-numeric formats -+ */ -+ switch (*fmt) { -+ case 'u': -+ if (var_type == IS_QUAD) { -+ i_quad = va_arg(ap, u_widest_int); -+ s = conv_10_quad(i_quad, 1, &is_negative, -+ &num_buf[NUM_BUF_SIZE], &s_len); -+ } -+ else { -+ if (var_type == IS_LONG) -+ i_num = (wide_int) va_arg(ap, u_wide_int); -+ else if (var_type == IS_SHORT) -+ i_num = (wide_int) (unsigned short) va_arg(ap, unsigned int); -+ else -+ i_num = (wide_int) va_arg(ap, unsigned int); -+ s = conv_10(i_num, 1, &is_negative, -+ &num_buf[NUM_BUF_SIZE], &s_len); -+ } -+ FIX_PRECISION(adjust_precision, precision, s, s_len); -+ break; -+ -+ case 'd': -+ case 'i': -+ if (var_type == IS_QUAD) { -+ i_quad = va_arg(ap, widest_int); -+ s = conv_10_quad(i_quad, 0, &is_negative, -+ &num_buf[NUM_BUF_SIZE], &s_len); -+ } -+ else { -+ if (var_type == IS_LONG) -+ i_num = (wide_int) va_arg(ap, wide_int); -+ else if (var_type == IS_SHORT) -+ i_num = (wide_int) (short) va_arg(ap, int); -+ else -+ i_num = (wide_int) va_arg(ap, int); -+ s = conv_10(i_num, 0, &is_negative, -+ &num_buf[NUM_BUF_SIZE], &s_len); -+ } -+ FIX_PRECISION(adjust_precision, precision, s, s_len); -+ -+ if (is_negative) -+ prefix_char = '-'; -+ else if (print_sign) -+ prefix_char = '+'; -+ else if (print_blank) -+ prefix_char = ' '; -+ break; -+ -+ -+ case 'o': -+ if (var_type == IS_QUAD) { -+ ui_quad = va_arg(ap, u_widest_int); -+ s = conv_p2_quad(ui_quad, 3, *fmt, -+ &num_buf[NUM_BUF_SIZE], &s_len); -+ } -+ else { -+ if (var_type == IS_LONG) -+ ui_num = (u_wide_int) va_arg(ap, u_wide_int); -+ else if (var_type == IS_SHORT) -+ ui_num = (u_wide_int) (unsigned short) va_arg(ap, unsigned int); -+ else -+ ui_num = (u_wide_int) va_arg(ap, unsigned int); -+ s = conv_p2(ui_num, 3, *fmt, -+ &num_buf[NUM_BUF_SIZE], &s_len); -+ } -+ FIX_PRECISION(adjust_precision, precision, s, s_len); -+ if (alternate_form && *s != '0') { -+ *--s = '0'; -+ s_len++; -+ } -+ break; -+ -+ -+ case 'x': -+ case 'X': -+ if (var_type == IS_QUAD) { -+ ui_quad = va_arg(ap, u_widest_int); -+ s = conv_p2_quad(ui_quad, 4, *fmt, -+ &num_buf[NUM_BUF_SIZE], &s_len); -+ } -+ else { -+ if (var_type == IS_LONG) -+ ui_num = (u_wide_int) va_arg(ap, u_wide_int); -+ else if (var_type == IS_SHORT) -+ ui_num = (u_wide_int) (unsigned short) va_arg(ap, unsigned int); -+ else -+ ui_num = (u_wide_int) va_arg(ap, unsigned int); -+ s = conv_p2(ui_num, 4, *fmt, -+ &num_buf[NUM_BUF_SIZE], &s_len); -+ } -+ FIX_PRECISION(adjust_precision, precision, s, s_len); -+ if (alternate_form && i_num != 0) { -+ *--s = *fmt; /* 'x' or 'X' */ -+ *--s = '0'; -+ s_len += 2; -+ } -+ break; -+ -+ -+ case 's': -+ s = va_arg(ap, char *); -+ if (s != NULL) { -+ s_len = strlen(s); -+ if (adjust_precision && precision < s_len) -+ s_len = precision; -+ } -+ else { -+ s = S_NULL; -+ s_len = S_NULL_LEN; -+ } -+ pad_char = ' '; -+ break; -+ -+ -+ case 'f': -+ case 'e': -+ case 'E': -+ fp_num = va_arg(ap, double); -+ /* -+ * * We use &num_buf[ 1 ], so that we have room for the sign -+ */ -+#ifdef HAVE_ISNAN -+ if (isnan(fp_num)) { -+ s = "nan"; -+ s_len = 3; -+ } -+ else -+#endif -+#ifdef HAVE_ISINF -+ if (isinf(fp_num)) { -+ s = "inf"; -+ s_len = 3; -+ } -+ else -+#endif -+ { -+ s = conv_fp(*fmt, fp_num, alternate_form, -+ (adjust_precision == NO) ? FLOAT_DIGITS : precision, -+ &is_negative, &num_buf[1], &s_len); -+ if (is_negative) -+ prefix_char = '-'; -+ else if (print_sign) -+ prefix_char = '+'; -+ else if (print_blank) -+ prefix_char = ' '; -+ } -+ break; -+ -+ -+ case 'g': -+ case 'G': -+ if (adjust_precision == NO) -+ precision = FLOAT_DIGITS; -+ else if (precision == 0) -+ precision = 1; -+ /* -+ * * We use &num_buf[ 1 ], so that we have room for the sign -+ */ -+ s = ap_gcvt(va_arg(ap, double), precision, &num_buf[1], -+ alternate_form); -+ if (*s == '-') -+ prefix_char = *s++; -+ else if (print_sign) -+ prefix_char = '+'; -+ else if (print_blank) -+ prefix_char = ' '; -+ -+ s_len = strlen(s); -+ -+ if (alternate_form && (q = strchr(s, '.')) == NULL) { -+ s[s_len++] = '.'; -+ s[s_len] = '\0'; /* delimit for following strchr() */ -+ } -+ if (*fmt == 'G' && (q = strchr(s, 'e')) != NULL) -+ *q = 'E'; -+ break; -+ -+ -+ case 'c': -+ char_buf[0] = (char) (va_arg(ap, int)); -+ s = &char_buf[0]; -+ s_len = 1; -+ pad_char = ' '; -+ break; -+ -+ -+ case '%': -+ char_buf[0] = '%'; -+ s = &char_buf[0]; -+ s_len = 1; -+ pad_char = ' '; -+ break; -+ -+ -+ case 'n': -+ if (var_type == IS_QUAD) -+ *(va_arg(ap, widest_int *)) = cc; -+ else if (var_type == IS_LONG) -+ *(va_arg(ap, long *)) = cc; -+ else if (var_type == IS_SHORT) -+ *(va_arg(ap, short *)) = cc; -+ else -+ *(va_arg(ap, int *)) = cc; -+ break; -+ -+ /* -+ * This is where we extend the printf format, with a second -+ * type specifier -+ */ -+ case 'p': -+ switch(*++fmt) { -+ /* -+ * If the pointer size is equal to or smaller than the size -+ * of the largest unsigned int, we convert the pointer to a -+ * hex number, otherwise we print "%p" to indicate that we -+ * don't handle "%p". -+ */ -+ case 'p': -+#ifdef AP_VOID_P_IS_QUAD -+ if (sizeof(void *) <= sizeof(u_widest_int)) { -+ ui_quad = (u_widest_int) va_arg(ap, void *); -+ s = conv_p2_quad(ui_quad, 4, 'x', -+ &num_buf[NUM_BUF_SIZE], &s_len); -+ } -+#else -+ if (sizeof(void *) <= sizeof(u_wide_int)) { -+ ui_num = (u_wide_int) va_arg(ap, void *); -+ s = conv_p2(ui_num, 4, 'x', -+ &num_buf[NUM_BUF_SIZE], &s_len); -+ } -+#endif -+ else { -+ s = "%p"; -+ s_len = 2; -+ prefix_char = NUL; -+ } -+ pad_char = ' '; -+ break; -+ -+ /* print a struct sockaddr_in as a.b.c.d:port */ -+ case 'I': -+ { -+#ifndef INET6 -+ struct sockaddr_in *si; -+ -+ si = va_arg(ap, struct sockaddr_in *); -+ if (si != NULL) { -+ s = conv_sockaddr_in(si, &num_buf[NUM_BUF_SIZE], &s_len); -+ if (adjust_precision && precision < s_len) -+ s_len = precision; -+ } -+#else -+ struct sockaddr *sa; -+ -+ sa = va_arg(ap, struct sockaddr *); -+ if (sa != NULL) { -+ s = conv_sockaddr(sa, &num_buf[NUM_BUF_SIZE], &s_len); -+ if (adjust_precision && precision < s_len) -+ s_len = precision; -+ } -+#endif -+ else { -+ s = S_NULL; -+ s_len = S_NULL_LEN; -+ } -+ pad_char = ' '; -+ } -+ break; -+ -+ /* print a struct in_addr as a.b.c.d */ -+ case 'A': -+ { -+ struct in_addr *ia; -+ -+ ia = va_arg(ap, struct in_addr *); -+ if (ia != NULL) { -+ s = conv_in_addr(ia, &num_buf[NUM_BUF_SIZE], &s_len); -+ if (adjust_precision && precision < s_len) -+ s_len = precision; -+ } -+ else { -+ s = S_NULL; -+ s_len = S_NULL_LEN; -+ } -+ pad_char = ' '; -+ } -+ break; -+ -+ case NUL: -+ /* if %p ends the string, oh well ignore it */ -+ continue; -+ -+ default: -+ s = "bogus %p"; -+ s_len = 8; -+ prefix_char = NUL; -+ break; -+ } -+ break; -+ -+ case NUL: -+ /* -+ * The last character of the format string was %. -+ * We ignore it. -+ */ -+ continue; -+ -+ -+ /* -+ * The default case is for unrecognized %'s. -+ * We print % to help the user identify what -+ * option is not understood. -+ * This is also useful in case the user wants to pass -+ * the output of format_converter to another function -+ * that understands some other % (like syslog). -+ * Note that we can't point s inside fmt because the -+ * unknown could be preceded by width etc. -+ */ -+ default: -+ char_buf[0] = '%'; -+ char_buf[1] = *fmt; -+ s = char_buf; -+ s_len = 2; -+ pad_char = ' '; -+ break; -+ } -+ -+ if (prefix_char != NUL && s != S_NULL && s != char_buf) { -+ *--s = prefix_char; -+ s_len++; -+ } -+ -+ if (adjust_width && adjust == RIGHT && min_width > s_len) { -+ if (pad_char == '0' && prefix_char != NUL) { -+ INS_CHAR(*s, sp, bep, cc); -+ s++; -+ s_len--; -+ min_width--; -+ } -+ PAD(min_width, s_len, pad_char); -+ } -+ -+ /* -+ * Print the string s. -+ */ -+ for (i = s_len; i != 0; i--) { -+ INS_CHAR(*s, sp, bep, cc); -+ s++; -+ } -+ -+ if (adjust_width && adjust == LEFT && min_width > s_len) -+ PAD(min_width, s_len, pad_char); -+ } -+ fmt++; -+ } -+ vbuff->curpos = sp; -+ return cc; -+} -+ -+ -+static int snprintf_flush(ap_vformatter_buff *vbuff) -+{ -+ /* if the buffer fills we have to abort immediately, there is no way -+ * to "flush" an ap_snprintf... there's nowhere to flush it to. -+ */ -+ return -1; -+} -+ -+ -+API_EXPORT(int) ap_snprintf(char *buf, size_t len, const char *format,...) -+{ -+ int cc; -+ va_list ap; -+ ap_vformatter_buff vbuff; -+ -+ if (len == 0) -+ return 0; -+ -+ /* save one byte for nul terminator */ -+ vbuff.curpos = buf; -+ vbuff.endpos = buf + len - 1; -+ va_start(ap, format); -+ cc = ap_vformatter(snprintf_flush, &vbuff, format, ap); -+ va_end(ap); -+ *vbuff.curpos = '\0'; -+ return (cc == -1) ? len : cc; -+} -+ -+ -+API_EXPORT(int) ap_vsnprintf(char *buf, size_t len, const char *format, -+ va_list ap) -+{ -+ int cc; -+ ap_vformatter_buff vbuff; -+ -+ if (len == 0) -+ return 0; + { ++#ifndef INET6 + struct sockaddr_in *si; + + si = va_arg(ap, struct sockaddr_in *); +@@ -1065,6 +1103,16 @@ + if (adjust_precision && precision < s_len) + s_len = precision; + } ++#else ++ struct sockaddr *sa; + -+ /* save one byte for nul terminator */ -+ vbuff.curpos = buf; -+ vbuff.endpos = buf + len - 1; -+ cc = ap_vformatter(snprintf_flush, &vbuff, format, ap); -+ *vbuff.curpos = '\0'; -+ return (cc == -1) ? len : cc; -+} -diff -Nur apache_1.3.22.orig/src/include/ap.h apache_1.3.22/src/include/ap.h ---- apache_1.3.22.orig/src/include/ap.h Mon Jan 15 18:04:22 2001 -+++ apache_1.3.22/src/include/ap.h Fri Dec 7 17:27:28 2001 -@@ -91,7 +91,8 @@ ++ sa = va_arg(ap, struct sockaddr *); ++ if (sa != NULL) { ++ s = conv_sockaddr(sa, &num_buf[NUM_BUF_SIZE], &s_len); ++ if (adjust_precision && precision < s_len) ++ s_len = precision; ++ } ++#endif + else { + s = S_NULL; + s_len = S_NULL_LEN; +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 @@ -1738,10 +478,10 @@ diff -Nur apache_1.3.22.orig/src/include/ap.h apache_1.3.22/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.22.orig/src/include/ap_config.h apache_1.3.22/src/include/ap_config.h ---- apache_1.3.22.orig/src/include/ap_config.h Mon Oct 8 17:49:33 2001 -+++ apache_1.3.22/src/include/ap_config.h Fri Dec 7 17:27:28 2001 -@@ -405,6 +405,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 @@ -1752,7 +492,7 @@ diff -Nur apache_1.3.22.orig/src/include/ap_config.h apache_1.3.22/src/include/a #endif #define STDIN_FILENO 0 -@@ -1488,6 +1492,70 @@ +@@ -1523,6 +1527,70 @@ #define ap_wait_t int #endif @@ -1823,35 +563,35 @@ diff -Nur apache_1.3.22.orig/src/include/ap_config.h apache_1.3.22/src/include/a #ifdef __cplusplus } #endif -diff -Nur apache_1.3.22.orig/src/include/http_conf_globals.h apache_1.3.22/src/include/http_conf_globals.h ---- apache_1.3.22.orig/src/include/http_conf_globals.h Fri Dec 7 17:26:57 2001 -+++ apache_1.3.22/src/include/http_conf_globals.h Fri Dec 7 17:27:28 2001 +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; extern API_VAR_EXPORT int ap_excess_requests_per_child; --extern struct in_addr ap_bind_address; -+extern struct sockaddr_storage ap_bind_address; +-extern API_VAR_EXPORT struct in_addr ap_bind_address; ++extern API_VAR_EXPORT struct sockaddr_storage ap_bind_address; +extern API_VAR_EXPORT int ap_default_family; 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.22.orig/src/include/http_vhost.h apache_1.3.22/src/include/http_vhost.h ---- apache_1.3.22.orig/src/include/http_vhost.h Mon Jan 15 18:04:37 2001 -+++ apache_1.3.22/src/include/http_vhost.h Fri Dec 7 17:27:28 2001 +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 @@ - const char *ap_parse_vhost_addrs(pool *p, const char *hostname, server_rec *s); + API_EXPORT(const char *) ap_parse_vhost_addrs(pool *p, const char *hostname, server_rec *s); /* handle NameVirtualHost directive */ --const char *ap_set_name_virtual_host (cmd_parms *cmd, void *dummy, char *arg); -+const char *ap_set_name_virtual_host (cmd_parms *cmd, void *dummy, char *h, char *p); +-API_EXPORT_NONSTD(const char *) ap_set_name_virtual_host (cmd_parms *cmd, void *dummy, char *arg); ++API_EXPORT_NONSTD(const char *) ap_set_name_virtual_host (cmd_parms *cmd, void *dummy, char *h, char *p); /* given an ip address only, give our best guess as to what vhost it is */ - void ap_update_vhost_given_ip(conn_rec *conn); -diff -Nur apache_1.3.22.orig/src/include/httpd.h apache_1.3.22/src/include/httpd.h ---- apache_1.3.22.orig/src/include/httpd.h Fri Dec 7 17:26:57 2001 -+++ apache_1.3.22/src/include/httpd.h Fri Dec 7 17:27:28 2001 -@@ -912,8 +912,8 @@ + API_EXPORT(void) ap_update_vhost_given_ip(conn_rec *conn); +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? */ @@ -1862,7 +602,7 @@ diff -Nur apache_1.3.22.orig/src/include/httpd.h apache_1.3.22/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; @@ -1873,7 +613,7 @@ diff -Nur apache_1.3.22.orig/src/include/httpd.h apache_1.3.22/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; @@ -1885,15 +625,15 @@ diff -Nur apache_1.3.22.orig/src/include/httpd.h apache_1.3.22/src/include/httpd @@ -1184,7 +1184,7 @@ #endif /*#ifdef CHARSET_EBCDIC*/ - char *ap_get_local_host(pool *); --unsigned long ap_get_virthost_addr(char *hostname, unsigned short *port); -+struct sockaddr *ap_get_virthost_addr(char *hostname, unsigned short *port); + API_EXPORT(char *) ap_get_local_host(pool *); +-API_EXPORT(unsigned long) ap_get_virthost_addr(char *hostname, unsigned short *port); ++API_EXPORT(struct sockaddr *) ap_get_virthost_addr(char *hostname, unsigned short *port); extern API_VAR_EXPORT time_t ap_restart_time; -diff -Nur apache_1.3.22.orig/src/include/sa_len.h apache_1.3.22/src/include/sa_len.h ---- apache_1.3.22.orig/src/include/sa_len.h Thu Jan 1 01:00:00 1970 -+++ apache_1.3.22/src/include/sa_len.h Fri Dec 7 17:27:28 2001 +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 ) */ + @@ -1936,9 +676,9 @@ diff -Nur apache_1.3.22.orig/src/include/sa_len.h apache_1.3.22/src/include/sa_l +} +#endif /* SA_LEN */ +#endif /* HAVE_SOCKADDR_LEN */ -diff -Nur apache_1.3.22.orig/src/include/sockaddr_storage.h apache_1.3.22/src/include/sockaddr_storage.h ---- apache_1.3.22.orig/src/include/sockaddr_storage.h Thu Jan 1 01:00:00 1970 -+++ apache_1.3.22/src/include/sockaddr_storage.h Fri Dec 7 17:27:28 2001 +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 @@ -1993,9 +733,9 @@ diff -Nur apache_1.3.22.orig/src/include/sockaddr_storage.h apache_1.3.22/src/in +#define su_port su_si.si_port + +#endif /* NEED_SOCKADDR_STORAGE */ -diff -Nur apache_1.3.22.orig/src/main/getaddrinfo.c apache_1.3.22/src/main/getaddrinfo.c ---- apache_1.3.22.orig/src/main/getaddrinfo.c Thu Jan 1 01:00:00 1970 -+++ apache_1.3.22/src/main/getaddrinfo.c Fri Dec 7 17:27:28 2001 +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. @@ -2159,9 +899,9 @@ diff -Nur apache_1.3.22.orig/src/main/getaddrinfo.c apache_1.3.22/src/main/getad + } + return EAI_NODATA; +} -diff -Nur apache_1.3.22.orig/src/main/getnameinfo.c apache_1.3.22/src/main/getnameinfo.c ---- apache_1.3.22.orig/src/main/getnameinfo.c Thu Jan 1 01:00:00 1970 -+++ apache_1.3.22/src/main/getnameinfo.c Fri Dec 7 17:27:28 2001 +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. @@ -2258,10 +998,10 @@ diff -Nur apache_1.3.22.orig/src/main/getnameinfo.c apache_1.3.22/src/main/getna + return EAI_NODATA; + return 0; +} -diff -Nur apache_1.3.22.orig/src/main/http_config.c apache_1.3.22/src/main/http_config.c ---- apache_1.3.22.orig/src/main/http_config.c Fri Dec 7 17:26:57 2001 -+++ apache_1.3.22/src/main/http_config.c Fri Dec 7 17:27:28 2001 -@@ -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; @@ -2269,7 +1009,7 @@ diff -Nur apache_1.3.22.orig/src/main/http_config.c apache_1.3.22/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 */ @@ -2284,7 +1024,7 @@ diff -Nur apache_1.3.22.orig/src/main/http_config.c apache_1.3.22/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,19 +1621,33 @@ +@@ -1643,21 +1648,33 @@ static void default_listeners(pool *p, server_rec *s) { listen_rec *new; @@ -2310,7 +1050,9 @@ diff -Nur apache_1.3.22.orig/src/main/http_config.c apache_1.3.22/src/main/http_ new = ap_pcalloc(p, sizeof(listen_rec)); - new->local_addr.sin_family = AF_INET; - new->local_addr.sin_addr = ap_bind_address; -- new->local_addr.sin_port = htons(s->port ? s->port : DEFAULT_HTTP_PORT); +- /* Buck ugly cast to get around terniary op bug in some (MS) compilers */ +- new->local_addr.sin_port = htons((unsigned short)(s->port ? s->port +- : DEFAULT_HTTP_PORT)); + memcpy(&new->local_addr, res0->ai_addr, res0->ai_addrlen); new->fd = -1; new->used = 0; @@ -2321,10 +1063,9 @@ diff -Nur apache_1.3.22.orig/src/main/http_config.c apache_1.3.22/src/main/http_ } -diff -Nur apache_1.3.22.orig/src/main/http_core.c apache_1.3.22/src/main/http_core.c ---- apache_1.3.22.orig/src/main/http_core.c Tue Sep 4 20:15:15 2001 -+++ apache_1.3.22/src/main/http_core.c Fri Dec 7 17:27:28 2001 -@@ -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" @@ -2332,8 +1073,17 @@ diff -Nur apache_1.3.22.orig/src/main/http_core.c apache_1.3.22/src/main/http_co #ifdef USE_MMAP_FILES #include -@@ -594,7 +595,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; @@ -2343,8 +1093,8 @@ diff -Nur apache_1.3.22.orig/src/main/http_core.c apache_1.3.22/src/main/http_co if (conn->double_reverse) { /* already done */ -@@ -605,28 +608,51 @@ - conn->double_reverse = -1; +@@ -678,30 +681,54 @@ + conn->remote_host = ""; /* prevent another lookup */ return; } - hptr = gethostbyname(conn->remote_host); @@ -2395,6 +1145,10 @@ diff -Nur apache_1.3.22.orig/src/main/http_core.c apache_1.3.22/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, @@ -2408,7 +1162,7 @@ diff -Nur apache_1.3.22.orig/src/main/http_core.c apache_1.3.22/src/main/http_co /* If we haven't checked the host name, and we want to */ if (dir_config) { -@@ -648,10 +674,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); @@ -2427,7 +1181,7 @@ diff -Nur apache_1.3.22.orig/src/main/http_core.c apache_1.3.22/src/main/http_co ap_str_tolower(conn->remote_host); if (hostname_lookups == HOSTNAME_LOOKUP_DOUBLE) { -@@ -732,6 +762,7 @@ +@@ -804,6 +835,7 @@ { conn_rec *conn = r->connection; core_dir_config *d; @@ -2435,7 +1189,7 @@ diff -Nur apache_1.3.22.orig/src/main/http_core.c apache_1.3.22/src/main/http_co d = (core_dir_config *)ap_get_module_config(r->per_dir_config, &core_module); -@@ -741,23 +772,22 @@ +@@ -813,23 +845,22 @@ } if (d->use_canonical_name == USE_CANONICAL_NAME_DNS) { if (conn->local_host == NULL) { @@ -2471,26 +1225,16 @@ diff -Nur apache_1.3.22.orig/src/main/http_core.c apache_1.3.22/src/main/http_co (void) ap_update_child_status(conn->child_num, old_stat, r); } return conn->local_host; -@@ -776,11 +806,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, -@@ -2503,12 +2535,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) { @@ -2517,7 +1261,7 @@ diff -Nur apache_1.3.22.orig/src/main/http_core.c apache_1.3.22/src/main/http_co return NULL; } -@@ -2540,44 +2585,70 @@ +@@ -2684,48 +2728,71 @@ return NULL; } @@ -2525,8 +1269,8 @@ diff -Nur apache_1.3.22.orig/src/main/http_core.c apache_1.3.22/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; @@ -2545,18 +1289,19 @@ diff -Nur apache_1.3.22.orig/src/main/http_core.c apache_1.3.22/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; } @@ -2577,9 +1322,13 @@ diff -Nur apache_1.3.22.orig/src/main/http_core.c apache_1.3.22/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; + @@ -2607,14 +1356,14 @@ diff -Nur apache_1.3.22.orig/src/main/http_core.c apache_1.3.22/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; -@@ -3163,7 +3234,7 @@ +@@ -3650,7 +3717,7 @@ { "ThreadStackSize", set_threadstacksize, NULL, RSRC_CONF, TAKE1, "Stack size each created thread will use."}, #endif @@ -2623,7 +1372,7 @@ diff -Nur apache_1.3.22.orig/src/main/http_core.c apache_1.3.22/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"}, -@@ -3197,7 +3268,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" }, @@ -2632,9 +1381,9 @@ diff -Nur apache_1.3.22.orig/src/main/http_core.c apache_1.3.22/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.22.orig/src/main/http_main.c apache_1.3.22/src/main/http_main.c ---- apache_1.3.22.orig/src/main/http_main.c Fri Dec 7 17:26:57 2001 -+++ apache_1.3.22/src/main/http_main.c Fri Dec 7 17:27:28 2001 +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 @@ -2644,26 +1393,26 @@ diff -Nur apache_1.3.22.orig/src/main/http_main.c apache_1.3.22/src/main/http_ma #ifdef MULTITHREAD /* special debug stuff -- PCS */ -@@ -250,7 +252,12 @@ +@@ -249,7 +251,12 @@ API_VAR_EXPORT char *ap_scoreboard_fname=NULL; - char *ap_lock_fname; + API_VAR_EXPORT char *ap_lock_fname=NULL; API_VAR_EXPORT char *ap_server_argv0=NULL; --struct in_addr ap_bind_address; +-API_VAR_EXPORT struct in_addr ap_bind_address={0}; +#ifdef INET6 +API_VAR_EXPORT int ap_default_family = PF_INET6; +#else +API_VAR_EXPORT int ap_default_family = PF_INET; +#endif -+struct sockaddr_storage ap_bind_address; ++API_VAR_EXPORT struct sockaddr_storage ap_bind_address={0}; 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; -@@ -1310,7 +1317,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 @@ -2671,10 +1420,10 @@ diff -Nur apache_1.3.22.orig/src/main/http_main.c apache_1.3.22/src/main/http_ma fprintf(stderr, "Options:\n"); #ifdef SHARED_CORE fprintf(stderr, " -R directory : specify an alternate location for shared object files\n"); -@@ -1332,6 +1343,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"); @@ -2682,7 +1431,7 @@ diff -Nur apache_1.3.22.orig/src/main/http_main.c apache_1.3.22/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"); -@@ -3495,11 +3510,13 @@ +@@ -3630,11 +3645,13 @@ static conn_rec *new_connection(pool *p, server_rec *server, BUFF *inout, @@ -2698,7 +1447,7 @@ diff -Nur apache_1.3.22.orig/src/main/http_main.c apache_1.3.22/src/main/http_ma /* Got a connection structure, so initialize what fields we can * (the rest are zeroed out by pcalloc). -@@ -3508,17 +3525,29 @@ +@@ -3643,17 +3660,29 @@ conn->child_num = child_num; conn->pool = p; @@ -2734,8 +1483,8 @@ diff -Nur apache_1.3.22.orig/src/main/http_main.c apache_1.3.22/src/main/http_ma #ifdef EAPI conn->ctx = ap_ctx_new(conn->pool); #endif /* EAPI */ -@@ -3569,21 +3598,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) @@ -2790,7 +1539,7 @@ diff -Nur apache_1.3.22.orig/src/main/http_main.c apache_1.3.22/src/main/http_ma ap_log_error(APLOG_MARK, APLOG_CRIT, server_conf, "make_sock: failed to get a socket for %s", addr); -@@ -3686,15 +3741,19 @@ +@@ -3828,15 +3883,19 @@ #ifdef MPE /* MPE requires CAP=PM and GETPRIVMODE to bind to ports less than 1024 */ @@ -2814,7 +1563,7 @@ diff -Nur apache_1.3.22.orig/src/main/http_main.c apache_1.3.22/src/main/http_ma GETUSERMODE(); #endif -@@ -3707,7 +3766,7 @@ +@@ -3849,7 +3908,7 @@ exit(1); } #ifdef MPE @@ -2823,7 +1572,7 @@ diff -Nur apache_1.3.22.orig/src/main/http_main.c apache_1.3.22/src/main/http_ma GETUSERMODE(); #endif -@@ -3854,15 +3913,17 @@ +@@ -4002,15 +4061,17 @@ for (;;) { fd = find_listener(lr); if (fd < 0) { @@ -2831,7 +1580,7 @@ diff -Nur apache_1.3.22.orig/src/main/http_main.c apache_1.3.22/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); @@ -2840,12 +1589,12 @@ diff -Nur apache_1.3.22.orig/src/main/http_main.c apache_1.3.22/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; -@@ -4174,8 +4235,8 @@ +@@ -4327,8 +4388,8 @@ static void child_main(int child_num_arg) { NET_SIZE_T clen; @@ -2856,7 +1605,7 @@ diff -Nur apache_1.3.22.orig/src/main/http_main.c apache_1.3.22/src/main/http_ma listen_rec *lr; /* All of initialization is a critical section, we don't care if we're -@@ -4340,7 +4401,7 @@ +@@ -4505,7 +4566,7 @@ usr1_just_die = 0; for (;;) { clen = sizeof(sa_client); @@ -2865,16 +1614,16 @@ diff -Nur apache_1.3.22.orig/src/main/http_main.c apache_1.3.22/src/main/http_ma if (csd >= 0 || errno != EINTR) break; if (deferred_die) { -@@ -4490,7 +4551,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; - } -@@ -4535,8 +4596,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, @@ -2885,7 +1634,7 @@ diff -Nur apache_1.3.22.orig/src/main/http_main.c apache_1.3.22/src/main/http_ma my_child_num); /* -@@ -4680,12 +4741,13 @@ +@@ -4875,12 +4936,13 @@ #ifdef _OSD_POSIX /* BS2000 requires a "special" version of fork() before a setuid() call */ @@ -2902,19 +1651,19 @@ diff -Nur apache_1.3.22.orig/src/main/http_main.c apache_1.3.22/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 -@@ -5294,7 +5356,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 -@@ -5369,8 +5434,14 @@ +@@ -5575,8 +5640,14 @@ ap_configtestonly = 1; ap_docrootcheck = 0; break; @@ -2931,7 +1680,7 @@ diff -Nur apache_1.3.22.orig/src/main/http_main.c apache_1.3.22/src/main/http_ma case '?': usage(argv[0]); } -@@ -5450,9 +5521,10 @@ +@@ -5665,9 +5736,10 @@ else { conn_rec *conn; request_rec *r; @@ -2943,7 +1692,7 @@ diff -Nur apache_1.3.22.orig/src/main/http_main.c apache_1.3.22/src/main/http_ma ap_set_version(); /* Yes this is called twice. */ -@@ -5499,25 +5571,32 @@ +@@ -5722,25 +5794,32 @@ #endif l = sizeof(sa_client); @@ -2981,20 +1730,20 @@ diff -Nur apache_1.3.22.orig/src/main/http_main.c apache_1.3.22/src/main/http_ma while ((r = ap_read_request(conn)) != NULL) { -@@ -7696,7 +7775,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': -@@ -7713,6 +7796,10 @@ +@@ -7993,6 +8076,10 @@ case 't': case 'T': case 'h': @@ -3005,10 +1754,9 @@ diff -Nur apache_1.3.22.orig/src/main/http_main.c apache_1.3.22/src/main/http_ma case '?': break; case 'R': -diff -Nur apache_1.3.22.orig/src/main/http_vhost.c apache_1.3.22/src/main/http_vhost.c ---- apache_1.3.22.orig/src/main/http_vhost.c Sat Feb 24 11:09:46 2001 -+++ apache_1.3.22/src/main/http_vhost.c Fri Dec 7 17:27:28 2001 -@@ -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" @@ -3016,7 +1764,7 @@ diff -Nur apache_1.3.22.orig/src/main/http_vhost.c apache_1.3.22/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 */ @@ -3180,7 +1928,7 @@ diff -Nur apache_1.3.22.orig/src/main/http_vhost.c apache_1.3.22/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]) { @@ -3190,12 +1938,12 @@ diff -Nur apache_1.3.22.orig/src/main/http_vhost.c apache_1.3.22/src/main/http_v if (err) { *addrs = NULL; return err; -@@ -268,10 +306,11 @@ +@@ -225,10 +263,11 @@ } --const char *ap_set_name_virtual_host (cmd_parms *cmd, void *dummy, char *arg) -+const char *ap_set_name_virtual_host (cmd_parms *cmd, void *dummy, char *h, +-API_EXPORT_NONSTD(const char *) ap_set_name_virtual_host (cmd_parms *cmd, void *dummy, char *arg) ++API_EXPORT_NONSTD(const char *) ap_set_name_virtual_host (cmd_parms *cmd, void *dummy, char *h, + char *p) { /* use whatever port the main server has at this point */ @@ -3204,7 +1952,7 @@ diff -Nur apache_1.3.22.orig/src/main/http_vhost.c apache_1.3.22/src/main/http_v cmd->server->port); } -@@ -345,6 +384,19 @@ +@@ -302,6 +341,19 @@ return ((key >> 8) ^ key) % IPHASH_TABLE_SIZE; } @@ -3224,7 +1972,7 @@ diff -Nur apache_1.3.22.orig/src/main/http_vhost.c apache_1.3.22/src/main/http_v static ipaddr_chain *new_ipaddr_chain(pool *p, -@@ -372,25 +424,77 @@ +@@ -329,25 +381,77 @@ return new; } @@ -3312,7 +2060,7 @@ diff -Nur apache_1.3.22.orig/src/main/http_vhost.c apache_1.3.22/src/main/http_v return NULL; } -@@ -416,21 +520,7 @@ +@@ -373,21 +477,7 @@ int len; char buf[MAX_STRING_LEN]; @@ -3335,7 +2083,7 @@ diff -Nur apache_1.3.22.orig/src/main/http_vhost.c apache_1.3.22/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) { @@ -3343,7 +2091,8 @@ diff -Nur apache_1.3.22.orig/src/main/http_vhost.c apache_1.3.22/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: @@ -3369,18 +2118,22 @@ diff -Nur apache_1.3.22.orig/src/main/http_vhost.c apache_1.3.22/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: @@ -3408,12 +2161,7 @@ diff -Nur apache_1.3.22.orig/src/main/http_vhost.c apache_1.3.22/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 @@ -3426,7 +2174,7 @@ diff -Nur apache_1.3.22.orig/src/main/http_vhost.c apache_1.3.22/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 */ @@ -3440,7 +2188,7 @@ diff -Nur apache_1.3.22.orig/src/main/http_vhost.c apache_1.3.22/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; @@ -3479,11 +2227,11 @@ diff -Nur apache_1.3.22.orig/src/main/http_vhost.c apache_1.3.22/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; @@ -3502,67 +2250,93 @@ diff -Nur apache_1.3.22.orig/src/main/http_vhost.c apache_1.3.22/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, @@ -3571,7 +2345,7 @@ diff -Nur apache_1.3.22.orig/src/main/http_vhost.c apache_1.3.22/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; @@ -3598,7 +2372,7 @@ diff -Nur apache_1.3.22.orig/src/main/http_vhost.c apache_1.3.22/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; @@ -3622,8 +2396,8 @@ diff -Nur apache_1.3.22.orig/src/main/http_vhost.c apache_1.3.22/src/main/http_v /* * This is in conjunction with the ServerPath code in http_core, so we -@@ -970,10 +1187,22 @@ - void ap_update_vhost_given_ip(conn_rec *conn) +@@ -938,10 +1167,22 @@ + API_EXPORT(void) ap_update_vhost_given_ip(conn_rec *conn) { ipaddr_chain *trav; - unsigned port = ntohs(conn->local_addr.sin_port); @@ -3647,7 +2421,7 @@ diff -Nur apache_1.3.22.orig/src/main/http_vhost.c apache_1.3.22/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; } @@ -3655,9 +2429,9 @@ diff -Nur apache_1.3.22.orig/src/main/http_vhost.c apache_1.3.22/src/main/http_v /* otherwise we're stuck with just the main server * and no name-based vhosts */ -diff -Nur apache_1.3.22.orig/src/main/rfc1413.c apache_1.3.22/src/main/rfc1413.c ---- apache_1.3.22.orig/src/main/rfc1413.c Mon Jan 15 18:05:04 2001 -+++ apache_1.3.22/src/main/rfc1413.c Fri Dec 7 17:27:28 2001 +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" @@ -3778,8 +2552,8 @@ diff -Nur apache_1.3.22.orig/src/main/rfc1413.c apache_1.3.22/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"); @@ -3795,15 +2569,15 @@ diff -Nur apache_1.3.22.orig/src/main/rfc1413.c apache_1.3.22/src/main/rfc1413.c } ap_set_callback_and_alarm(NULL, 0); ap_pclosesocket(conn->pool, sock); -diff -Nur apache_1.3.22.orig/src/main/util.c apache_1.3.22/src/main/util.c ---- apache_1.3.22.orig/src/main/util.c Wed Jul 25 15:25:18 2001 -+++ apache_1.3.22/src/main/util.c Fri Dec 7 17:27:28 2001 -@@ -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 */ --unsigned long ap_get_virthost_addr(char *w, unsigned short *ports) -+struct sockaddr *ap_get_virthost_addr(char *w, unsigned short *ports) +-API_EXPORT(unsigned long) ap_get_virthost_addr(char *w, unsigned short *ports) ++API_EXPORT(struct sockaddr *) ap_get_virthost_addr(char *w, unsigned short *ports) { - struct hostent *hep; - unsigned long my_addr; @@ -3911,7 +2685,7 @@ diff -Nur apache_1.3.22.orig/src/main/util.c apache_1.3.22/src/main/util.c } -@@ -2035,7 +2070,8 @@ +@@ -2090,7 +2125,8 @@ #endif char str[MAXHOSTNAMELEN]; char *server_hostname = NULL; @@ -3921,7 +2695,7 @@ diff -Nur apache_1.3.22.orig/src/main/util.c apache_1.3.22/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 { @@ -3983,16 +2757,7 @@ diff -Nur apache_1.3.22.orig/src/main/util.c apache_1.3.22/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; } @@ -4004,9 +2769,9 @@ diff -Nur apache_1.3.22.orig/src/main/util.c apache_1.3.22/src/main/util.c +#ifdef NEED_GETNAMEINFO +#include "getnameinfo.c" +#endif -diff -Nur apache_1.3.22.orig/src/main/util_script.c apache_1.3.22/src/main/util_script.c ---- apache_1.3.22.orig/src/main/util_script.c Wed May 9 07:17:11 2001 -+++ apache_1.3.22/src/main/util_script.c Fri Dec 7 17:27:28 2001 +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" @@ -4015,7 +2780,7 @@ diff -Nur apache_1.3.22.orig/src/main/util_script.c apache_1.3.22/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; @@ -4023,7 +2788,7 @@ diff -Nur apache_1.3.22.orig/src/main/util_script.c apache_1.3.22/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 */ @@ -4042,10 +2807,10 @@ diff -Nur apache_1.3.22.orig/src/main/util_script.c apache_1.3.22/src/main/util_ if (c->user) { ap_table_addn(e, "REMOTE_USER", c->user); -diff -Nur apache_1.3.22.orig/src/main/util_uri.c apache_1.3.22/src/main/util_uri.c ---- apache_1.3.22.orig/src/main/util_uri.c Thu Aug 23 08:38:25 2001 -+++ apache_1.3.22/src/main/util_uri.c Fri Dec 7 17:27:28 2001 -@@ -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); @@ -4058,7 +2823,7 @@ diff -Nur apache_1.3.22.orig/src/main/util_uri.c apache_1.3.22/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 */ @@ -4072,10 +2837,10 @@ diff -Nur apache_1.3.22.orig/src/main/util_uri.c apache_1.3.22/src/main/util_uri if (s == NULL) { return HTTP_BAD_REQUEST; } -diff -Nur apache_1.3.22.orig/src/modules/proxy/mod_proxy.c apache_1.3.22/src/modules/proxy/mod_proxy.c ---- apache_1.3.22.orig/src/modules/proxy/mod_proxy.c Fri Dec 7 17:26:57 2001 -+++ apache_1.3.22/src/modules/proxy/mod_proxy.c Fri Dec 7 17:27:28 2001 -@@ -555,11 +555,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; @@ -4083,7 +2848,7 @@ diff -Nur apache_1.3.22.orig/src/modules/proxy/mod_proxy.c apache_1.3.22/src/mod p = strchr(r, ':'); if (p == NULL || p[1] != '/' || p[2] != '/' || p[3] == '\0') - return "ProxyRemote: Bad syntax for a remote proxy server"; + return "ProxyRemote: Bad syntax for a remote proxy server"; - q = strchr(p + 3, ':'); + bl = p + 3; + if (*bl == '['){ @@ -4106,18 +2871,18 @@ diff -Nur apache_1.3.22.orig/src/modules/proxy/mod_proxy.c apache_1.3.22/src/mod + else + q = strrchr(bl, ':'); if (q != NULL) { - if (sscanf(q + 1, "%u", &port) != 1 || port > 65535) - return "ProxyRemote: Bad syntax for a remote proxy server (bad port number)"; -@@ -570,7 +590,7 @@ + if (sscanf(q + 1, "%u", &port) != 1 || port > 65535) + return "ProxyRemote: Bad syntax for a remote proxy server (bad port number)"; +@@ -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; -@@ -583,7 +603,7 @@ + int i; +@@ -602,7 +622,7 @@ new = ap_push_array(conf->proxies); new->scheme = f; new->protocol = r; @@ -4126,10 +2891,10 @@ diff -Nur apache_1.3.22.orig/src/modules/proxy/mod_proxy.c apache_1.3.22/src/mod new->port = port; return NULL; } -diff -Nur apache_1.3.22.orig/src/modules/proxy/mod_proxy.h apache_1.3.22/src/modules/proxy/mod_proxy.h ---- apache_1.3.22.orig/src/modules/proxy/mod_proxy.h Fri Oct 5 10:19:15 2001 -+++ apache_1.3.22/src/modules/proxy/mod_proxy.h Fri Dec 7 17:27:28 2001 -@@ -316,7 +316,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); @@ -4138,11 +2903,11 @@ diff -Nur apache_1.3.22.orig/src/modules/proxy/mod_proxy.h apache_1.3.22/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.22.orig/src/modules/proxy/proxy_connect.c apache_1.3.22/src/modules/proxy/proxy_connect.c ---- apache_1.3.22.orig/src/modules/proxy/proxy_connect.c Fri Oct 5 10:19:15 2001 -+++ apache_1.3.22/src/modules/proxy/proxy_connect.c Fri Dec 7 17:27:28 2001 -@@ -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; @@ -4161,7 +2926,7 @@ diff -Nur apache_1.3.22.orig/src/modules/proxy/proxy_connect.c apache_1.3.22/src void *sconf = r->server->module_config; proxy_server_conf *conf = -@@ -129,26 +130,59 @@ +@@ -128,27 +129,59 @@ struct noproxy_entry *npent = (struct noproxy_entry *) conf->noproxies->elts; memset(&server, '\0', sizeof(server)); @@ -4176,16 +2941,16 @@ diff -Nur apache_1.3.22.orig/src/modules/proxy/proxy_connect.c apache_1.3.22/src + hoststr = url; p = strchr(url, ':'); - if (p == NULL) -- port = DEFAULT_HTTPS_PORT; +- port = DEFAULT_HTTPS_PORT; - else { -- port = atoi(p + 1); +- port = atoi(p + 1); + if (p == NULL) { + char pbuf[32]; + ap_snprintf(pbuf, sizeof(pbuf), "%d", DEFAULT_HTTPS_PORT); + portstr = pbuf; + } else { + portstr = p + 1; - *p = '\0'; + *p = '\0'; } + port = atoi(portstr); + @@ -4202,8 +2967,9 @@ diff -Nur apache_1.3.22.orig/src/modules/proxy/proxy_connect.c apache_1.3.22/src /* check if ProxyBlock directive on this host */ - destaddr.s_addr = ap_inet_addr(host); - for (i = 0; i < conf->noproxies->nelts; i++) { -- if ((npent[i].name != NULL && strstr(host, npent[i].name) != NULL) -- || destaddr.s_addr == npent[i].addr.s_addr || npent[i].name[0] == '*') +- if ((npent[i].name != NULL && strstr(host, npent[i].name) != NULL) +- || destaddr.s_addr == npent[i].addr.s_addr +- || npent[i].name[0] == '*') + for (res = res0; res; res = res = res->ai_next) { + struct sockaddr_in *sin; + int fail; @@ -4224,23 +2990,24 @@ diff -Nur apache_1.3.22.orig/src/modules/proxy/proxy_connect.c apache_1.3.22/src + } + if (fail) { + freeaddrinfo(res0); - return ap_proxyerror(r, HTTP_FORBIDDEN, - "Connect to remote machine blocked"); + return ap_proxyerror(r, HTTP_FORBIDDEN, + "Connect to remote machine blocked"); + } } /* Check if it is an allowed port */ -@@ -159,59 +193,64 @@ - case DEFAULT_SNEWS_PORT: - break; - default: -+ freeaddrinfo(res0); - return HTTP_FORBIDDEN; - } -- } else if(!allowed_port(conf, port)) -+ } else if(!allowed_port(conf, port)) { +@@ -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)) { + freeaddrinfo(res0); - return HTTP_FORBIDDEN; + return HTTP_FORBIDDEN; + } if (proxyhost) { @@ -4257,81 +3024,62 @@ diff -Nur apache_1.3.22.orig/src/modules/proxy/proxy_connect.c apache_1.3.22/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); -+ ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, r->server, "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); } -- server.sin_port = (proxyport ? htons(proxyport) : htons(port)); +- /* Nasty cast to work around broken terniary expressions on MSVC */ +- server.sin_port = htons((unsigned short)(proxyport ? proxyport : port)); - err = ap_proxy_host2addr(proxyhost ? proxyhost : host, &server_hp); - - if (err != NULL) -- return ap_proxyerror(r, -- proxyhost ? HTTP_BAD_GATEWAY : HTTP_INTERNAL_SERVER_ERROR, -- err); +- return ap_proxyerror(r, +- 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; +- 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) { -- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, r->server, -- "proxy_connect_handler: filedescriptor (%u) " -- "larger than FD_SETSIZE (%u) " -- "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; -- } -+ if (sock >= FD_SETSIZE) { -+ ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, NULL, -+ "proxy_connect_handler: filedescriptor (%u) " -+ "larger than FD_SETSIZE (%u) " -+ "found, you probably need to rebuild Apache with a " -+ "larger FD_SETSIZE. Anyway try to open next socket.", -+ sock, FD_SETSIZE); -+ ap_pclosesocket(r->pool, sock); -+ continue; -+ } + if (sock >= FD_SETSIZE) { +@@ -196,19 +237,15 @@ + "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; + } #endif - j = 0; - while (server_hp.h_addr_list[j] != NULL) { -- memcpy(&server.sin_addr, server_hp.h_addr_list[j], -- sizeof(struct in_addr)); -- i = ap_proxy_doconnect(sock, &server, r); +- 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); - if (i == 0) - break; -- j++; + if (i == 0) + break; +- j++; } + freeaddrinfo(res0); if (i == -1) { - ap_pclosesocket(r->pool, sock); -- return ap_proxyerror(r, HTTP_INTERNAL_SERVER_ERROR, ap_pstrcat(r->pool, -- "Could not connect to remote machine:
", -- strerror(errno), NULL)); -+ return ap_proxyerror(r, HTTP_INTERNAL_SERVER_ERROR, -+ ap_pstrcat(r->pool, -+ "Could not connect to remote machine:
", -+ strerror(errno), NULL)); - } - - /* If we are connecting through a remote proxy, we need to pass -diff -Nur apache_1.3.22.orig/src/modules/proxy/proxy_ftp.c apache_1.3.22/src/modules/proxy/proxy_ftp.c ---- apache_1.3.22.orig/src/modules/proxy/proxy_ftp.c Fri Oct 5 10:19:15 2001 -+++ apache_1.3.22/src/modules/proxy/proxy_ftp.c Fri Dec 7 17:27:28 2001 + ap_pclosesocket(r->pool, sock); + return ap_proxyerror(r, HTTP_INTERNAL_SERVER_ERROR, ap_pstrcat(r->pool, +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" @@ -4340,10 +3088,10 @@ diff -Nur apache_1.3.22.orig/src/modules/proxy/proxy_ftp.c apache_1.3.22/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; @@ -4352,8 +3100,8 @@ diff -Nur apache_1.3.22.orig/src/modules/proxy/proxy_ftp.c apache_1.3.22/src/mod + int error; struct in_addr destaddr; table *resp_hdrs; - BUFF *f; -@@ -473,11 +476,18 @@ + BUFF *ctrl = NULL; +@@ -577,11 +580,18 @@ unsigned int presult, h0, h1, h2, h3, p0, p1; unsigned int paddr; unsigned short pport; @@ -4373,120 +3121,117 @@ diff -Nur apache_1.3.22.orig/src/modules/proxy/proxy_ftp.c apache_1.3.22/src/mod /* stuff for responses */ char resp[MAX_STRING_LEN]; char *size = NULL; -@@ -547,62 +557,52 @@ +@@ -658,62 +668,50 @@ if (parms != NULL) - *(parms++) = '\0'; + *(parms++) = '\0'; - memset(&server, 0, sizeof(struct sockaddr_in)); - server.sin_family = AF_INET; -- server.sin_port = htons(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); +- 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"); -- return HTTP_INTERNAL_SERVER_ERROR; -- } -+ ap_snprintf(portbuf, sizeof(portbuf), "%d", port); +- ap_log_rerror(APLOG_MARK, APLOG_ERR, r, +- "proxy: error creating socket"); +- return HTTP_INTERNAL_SERVER_ERROR; ++ 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"); +- && 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"); -+ } ++ 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, -- sizeof(one)) == -1) { -+ 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)"); -- 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); +- 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" */ +- ap_log_rerror(APLOG_MARK, APLOG_ERR, r, +- "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); + 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)); -- i = ap_proxy_doconnect(sock, &server, r); -- if (i == 0) -- break; - } +- 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; + } - } -#else - j = 0; - while (server_hp.h_addr_list[j] != NULL) { -- memcpy(&server.sin_addr, server_hp.h_addr_list[j], -- 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){ +- memcpy(&server.sin_addr, server_hp.h_addr_list[j], +- 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) { + memcpy(&server, res->ai_addr, res->ai_addrlen); - break; -- j++; + break; +- j++; + } + ap_pclosesocket(p, sock); } -#endif + freeaddrinfo(res0); if (i == -1) { - ap_pclosesocket(p, sock); - return ap_proxyerror(r, HTTP_BAD_GATEWAY, ap_pstrcat(r->pool, -@@ -806,7 +806,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"); -@@ -825,11 +825,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"; @@ -4494,36 +3239,36 @@ diff -Nur apache_1.3.22.orig/src/modules/proxy/proxy_ftp.c apache_1.3.22/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"); -- /* possible results: 227, 421, 500, 501, 502, 530 */ -+ /* possible results: 227, 228, 229, 421, 500, 501, 502, 530 */ + 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 */ /* 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. */ -@@ -838,7 +849,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); -@@ -870,10 +881,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); -- data_addr.sin_family = AF_INET; -- data_addr.sin_addr.s_addr = htonl(paddr); -- data_addr.sin_port = htons(pport); -- i = ap_proxy_doconnect(dsock, &data_addr, r); +@@ -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); +- data_addr.sin_family = AF_INET; +- data_addr.sin_addr.s_addr = htonl(paddr); +- data_addr.sin_port = htons(pport); +- i = ap_proxy_doconnect(dsock, &data_addr, r); + sin = (struct sockaddr_in *)&data_addr; + sin->sin_family = AF_INET; +#ifdef SIN6_LEN @@ -4533,16 +3278,12 @@ diff -Nur apache_1.3.22.orig/src/modules/proxy/proxy_ftp.c apache_1.3.22/src/mod + sin->sin_port = htons(pport); + i = ap_proxy_doconnect(dsock, (struct sockaddr *)&data_addr, r); - if (i == -1) { - ap_kill_timeout(r); -@@ -881,17 +896,76 @@ - ap_pstrcat(r->pool, - "Could not connect to remote machine: ", - strerror(errno), NULL)); -+ } else { -+ pasvmode = 1; - } -- else { + if (i == -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", @@ -4562,14 +3303,13 @@ diff -Nur apache_1.3.22.orig/src/modules/proxy/proxy_ftp.c apache_1.3.22/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]) { @@ -4592,53 +3332,50 @@ diff -Nur apache_1.3.22.orig/src/modules/proxy/proxy_ftp.c apache_1.3.22/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 - ap_pclosesocket(p, dsock); /* and try the regular way */ + } + 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"); -@@ -900,7 +974,7 @@ - return HTTP_INTERNAL_SERVER_ERROR; - } + if (!pasvmode) { /* set up data connection */ +- clen = sizeof(struct sockaddr_in); ++ 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); - if (dsock == -1) { - ap_log_rerror(APLOG_MARK, APLOG_ERR, r, - "proxy: error creating socket"); -@@ -921,13 +995,26 @@ - #endif /*_OSD_POSIX*/ - } +- 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) { + 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, -- sizeof(struct sockaddr_in)) == -1) { -- char buff[22]; +- if (bind(dsock, (struct sockaddr *)&server, +- sizeof(struct sockaddr_in)) == -1) { +#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]; - -- ap_snprintf(buff, sizeof(buff), "%s:%d", inet_ntoa(server.sin_addr), server.sin_port); ++ + getnameinfo((struct sockaddr *)&server, +#ifndef SIN6_LEN + SA_LEN((struct sockaddr *)&server), @@ -4648,29 +3385,31 @@ diff -Nur apache_1.3.22.orig/src/modules/proxy/proxy_ftp.c apache_1.3.22/src/mod + hostnamebuf, sizeof(hostnamebuf), + portnamebuf, sizeof(portnamebuf), + NI_NUMERICHOST | NI_NUMERICSERV); - 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; -@@ -1186,7 +1273,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); - while (csd == -1 && errno == EINTR); -diff -Nur apache_1.3.22.orig/src/modules/proxy/proxy_http.c apache_1.3.22/src/modules/proxy/proxy_http.c ---- apache_1.3.22.orig/src/modules/proxy/proxy_http.c Fri Dec 7 17:26:57 2001 -+++ apache_1.3.22/src/modules/proxy/proxy_http.c Fri Dec 7 17:27:28 2001 -@@ -177,9 +177,8 @@ + + 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); + while (csd == -1 && errno == EINTR); +--- 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 *resp_hdrs; - table_entry *reqhdrs; + table_entry *reqhdrs_elts; - struct sockaddr_in server; - struct in_addr destaddr; - struct hostent server_hp; @@ -4679,18 +3418,18 @@ diff -Nur apache_1.3.22.orig/src/modules/proxy/proxy_http.c apache_1.3.22/src/mo BUFF *f; char buffer[HUGE_STRING_LEN]; char portstr[32]; -@@ -201,9 +200,6 @@ - struct nocache_entry *ncent = (struct nocache_entry *) conf->nocaches->elts; - int nocache = 0; +@@ -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 */ +- + /* We break the URL into host, port, path-search */ urlptr = strstr(url, "://"); -@@ -211,6 +207,8 @@ - return HTTP_BAD_REQUEST; +@@ -151,6 +147,8 @@ + return HTTP_BAD_REQUEST; urlptr += 3; destport = DEFAULT_HTTP_PORT; + ap_snprintf(portstr, sizeof(portstr), "%d", DEFAULT_HTTP_PORT); @@ -4698,9 +3437,9 @@ diff -Nur apache_1.3.22.orig/src/modules/proxy/proxy_http.c apache_1.3.22/src/mo #ifdef EAPI ap_hook_use("ap::mod_proxy::http::handler::set_destport", AP_HOOK_SIG2(int,ptr), -@@ -229,7 +227,20 @@ - urlptr = strp; - desthost = q; +@@ -169,7 +167,20 @@ + urlptr = strp; + desthost = q; } - + if (*desthost == '['){ @@ -4719,144 +3458,147 @@ diff -Nur apache_1.3.22.orig/src/modules/proxy/proxy_http.c apache_1.3.22/src/mo + } else strp2 = strchr(desthost, ':'); if (strp2 != NULL) { - *(strp2++) = '\0'; -@@ -240,41 +251,69 @@ + *(strp2++) = '\0'; +@@ -179,46 +190,71 @@ + } } - /* check if ProxyBlock directive on this host */ ++ 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) { -- server.sin_port = htons(proxyport); -- err = ap_proxy_host2addr(proxyhost, &server_hp); -- if (err != NULL) -- return DECLINED; /* try another */ --#ifdef EAPI -- peer = ap_psprintf(p, "%s:%u", proxyhost, proxyport); --#endif -- } ++ } + } + + if (proxyhost != NULL) { +- server.sin_port = htons((unsigned short)proxyport); +- err = ap_proxy_host2addr(proxyhost, &server_hp); +- if (err != 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) + return DECLINED; /* try another */ + #ifdef EAPI + peer = ap_psprintf(p, "%s:%u", proxyhost, proxyport); + #endif + } - else { -- server.sin_port = htons(destport); -- err = ap_proxy_host2addr(desthost, &server_hp); -- if (err != NULL) -- return ap_proxyerror(r, HTTP_INTERNAL_SERVER_ERROR, err); +- 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); -#ifdef EAPI - peer = ap_psprintf(p, "%s:%u", desthost, destport); -#endif - } - -- 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"); -- return HTTP_INTERNAL_SERVER_ERROR; +- ap_log_rerror(APLOG_MARK, APLOG_ERR, r, +- "proxy: error creating socket"); +- return HTTP_INTERNAL_SERVER_ERROR; - } -- -+ } -+ } -+ -+ 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) -+ return DECLINED; /* try another */ -+ #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, -@@ -286,28 +325,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; -- } +- 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 - j = 0; - while (server_hp.h_addr_list[j] != NULL) { -- 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); - if (i == 0) - break; -- j++; -+ ap_pclosesocket(p, sock); +- 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); + 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); ++ ap_pclosesocket(p, sock); + j++; } -#endif + freeaddrinfo(res0); if (i == -1) { - if (proxyhost != NULL) - return DECLINED; /* try again another way */ -@@ -527,17 +550,31 @@ - } + if (proxyhost != NULL) + return DECLINED; /* try again another way */ +@@ -591,17 +602,30 @@ + ap_table_set(resp_hdrs, "Content-Location", proxy_location_reverse_map(r, urlstr)); /* check if NoCache directive on this host */ + { @@ -4866,13 +3608,13 @@ diff -Nur apache_1.3.22.orig/src/modules/proxy/proxy_http.c apache_1.3.22/src/mo +#endif + if (nocache == 0) { - 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; + 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; + if (ncent[i].name != NULL && + (ncent[i].name[0] == '*' || + strstr(desthost, ncent[i].name) != NULL)) { @@ -4886,41 +3628,41 @@ diff -Nur apache_1.3.22.orig/src/modules/proxy/proxy_http.c apache_1.3.22/src/mo + nocache = 1; + break; + } - } - } - } -+ } - - i = ap_proxy_cache_update(c, resp_hdrs, !backasswards, nocache); - if (i != DECLINED) { -diff -Nur apache_1.3.22.orig/src/modules/proxy/proxy_util.c apache_1.3.22/src/modules/proxy/proxy_util.c ---- apache_1.3.22.orig/src/modules/proxy/proxy_util.c Mon Sep 24 22:14:27 2001 -+++ apache_1.3.22/src/modules/proxy/proxy_util.c Fri Dec 7 17:27:28 2001 + } + } +- ++ } + /* + * 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; + char *t = NULL, *u = NULL, *v = NULL; if (url[0] != '/' || url[1] != '/') - return "Malformed URL"; -@@ -256,11 +258,22 @@ - *passwordp = password; + return "Malformed URL"; +@@ -257,11 +259,22 @@ + *passwordp = password; } - strp = strrchr(host, ':'); - if (strp != NULL) { -- *(strp++) = '\0'; +- *(strp++) = '\0'; - -- for (i = 0; strp[i] != '\0'; i++) +- for (i = 0; strp[i] != '\0'; i++) + v = host; + if (*host == '['){ + u = strrchr(host, ']'); @@ -4935,18 +3677,18 @@ diff -Nur apache_1.3.22.orig/src/modules/proxy/proxy_util.c apache_1.3.22/src/mo + *t = '\0'; + strp = t + 1; + } -+ if (strp){ ++ if (strp) { + for (i=0; strp[i] != '\0'; i++) - if (!ap_isdigit(strp[i])) - break; + if (!ap_isdigit(strp[i])) + break; -@@ -278,17 +291,29 @@ - return "Missing host in URL"; +@@ -280,17 +293,29 @@ + return "Missing host in URL"; /* check hostname syntax */ for (i = 0; host[i] != '\0'; i++) -- if (!ap_isdigit(host[i]) && host[i] != '.') -+ if (!ap_isxdigit(host[i]) && host[i] != '.' && host[i] != ':') - break; +- if (!ap_isdigit(host[i]) && host[i] != '.') ++ if (!ap_isdigit(host[i]) && host[i] != '.' && host[i] != ':') + break; /* must be an IP address */ #if defined(WIN32) || defined(NETWARE) || defined(TPF) || defined(BEOS) if (host[i] == '\0' && (inet_addr(host) == -1)) @@ -4966,15 +3708,15 @@ diff -Nur apache_1.3.22.orig/src/modules/proxy/proxy_util.c apache_1.3.22/src/mo + return "Bad IP address in URL"; #endif - { -- return "Bad IP address in URL"; +- return "Bad IP address in URL"; + } + freeaddrinfo(res0); } +#endif - *urlp = url; - *hostp = host; -@@ -1237,22 +1262,45 @@ + /* if (strchr(host,'.') == NULL && domain != NULL) + host = pstrcat(p, host, domain, NULL); +@@ -1359,22 +1384,46 @@ return host != NULL && strstr(host, This->name) != NULL; } @@ -5004,12 +3746,12 @@ diff -Nur apache_1.3.22.orig/src/modules/proxy/proxy_util.c apache_1.3.22/src/mo + } +#endif do { -- i = connect(sock, (struct sockaddr *) addr, sizeof(struct sockaddr_in)); -+ i = connect(sock, addr, salen); +- 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 */ + if (i == SOCKET_ERROR) + errno = WSAGetLastError(); + #endif /* WIN32 */ } while (i == -1 && errno == EINTR); if (i == -1) { + if (getnameinfo(addr, salen, hbuf, sizeof(hbuf), pbuf, sizeof(pbuf), @@ -5017,17 +3759,16 @@ diff -Nur apache_1.3.22.orig/src/modules/proxy/proxy_util.c apache_1.3.22/src/mo + strcpy(hbuf, "?"); + 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 %s failed", hbuf, 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)); ++ hbuf, pbuf); } ap_kill_timeout(r); -diff -Nur apache_1.3.22.orig/src/modules/standard/mod_access.c apache_1.3.22/src/modules/standard/mod_access.c ---- apache_1.3.22.orig/src/modules/standard/mod_access.c Mon Jan 15 18:05:34 2001 -+++ apache_1.3.22/src/modules/standard/mod_access.c Fri Dec 7 17:27:28 2001 -@@ -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, @@ -5039,14 +3780,9 @@ diff -Nur apache_1.3.22.orig/src/modules/standard/mod_access.c apache_1.3.22/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 { @@ -5057,11 +3793,11 @@ diff -Nur apache_1.3.22.orig/src/modules/standard/mod_access.c apache_1.3.22/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; @@ -5074,7 +3810,7 @@ diff -Nur apache_1.3.22.orig/src/modules/standard/mod_access.c apache_1.3.22/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)) @@ -5097,16 +3833,25 @@ diff -Nur apache_1.3.22.orig/src/modules/standard/mod_access.c apache_1.3.22/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; @@ -5120,15 +3865,15 @@ diff -Nur apache_1.3.22.orig/src/modules/standard/mod_access.c apache_1.3.22/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; @@ -5142,21 +3887,14 @@ diff -Nur apache_1.3.22.orig/src/modules/standard/mod_access.c apache_1.3.22/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 */ @@ -5167,8 +3905,8 @@ diff -Nur apache_1.3.22.orig/src/modules/standard/mod_access.c apache_1.3.22/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; @@ -5177,14 +3915,14 @@ diff -Nur apache_1.3.22.orig/src/modules/standard/mod_access.c apache_1.3.22/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); @@ -5195,6 +3933,7 @@ diff -Nur apache_1.3.22.orig/src/modules/standard/mod_access.c apache_1.3.22/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) { @@ -5242,16 +3981,28 @@ diff -Nur apache_1.3.22.orig/src/modules/standard/mod_access.c apache_1.3.22/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; @@ -5295,7 +4046,7 @@ diff -Nur apache_1.3.22.orig/src/modules/standard/mod_access.c apache_1.3.22/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; @@ -5347,16 +4098,17 @@ diff -Nur apache_1.3.22.orig/src/modules/standard/mod_access.c apache_1.3.22/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; @@ -5377,9 +4129,9 @@ diff -Nur apache_1.3.22.orig/src/modules/standard/mod_access.c apache_1.3.22/src + } + break; +#endif -+ } -+ break; -+ + } + break; + +#ifdef INET6 + case T_IP6: + { @@ -5411,16 +4163,16 @@ diff -Nur apache_1.3.22.orig/src/modules/standard/mod_access.c apache_1.3.22/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.22.orig/src/modules/standard/mod_unique_id.c apache_1.3.22/src/modules/standard/mod_unique_id.c ---- apache_1.3.22.orig/src/modules/standard/mod_unique_id.c Tue Oct 2 18:11:13 2001 -+++ apache_1.3.22/src/modules/standard/mod_unique_id.c Fri Dec 7 17:27:28 2001 + 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" @@ -5471,7 +4223,7 @@ diff -Nur apache_1.3.22.orig/src/modules/standard/mod_unique_id.c apache_1.3.22/ - unique_id_rec_offset[1] = XtOffsetOf(unique_id_rec, in_addr); - unique_id_rec_size[1] = sizeof(cur_unique_id->in_addr); + unique_id_rec_offset[1] = XtOffsetOf(unique_id_rec, addr); -+ unique_id_rec_size[1] = sizeof(cur_unique_id.addr); ++ unique_id_rec_size[1] = sizeof(cur_unique_id->addr); unique_id_rec_offset[2] = XtOffsetOf(unique_id_rec, pid); unique_id_rec_size[2] = sizeof(cur_unique_id->pid); #ifdef MULTITHREAD @@ -5530,18 +4282,18 @@ diff -Nur apache_1.3.22.orig/src/modules/standard/mod_unique_id.c apache_1.3.22/ } - cur_unique_id->in_addr = global_in_addr; -+ memset(&cur_unique_id.addr, 0, sizeof(cur_unique_id.addr)); ++ memset(&cur_unique_id->addr, 0, sizeof(cur_unique_id->addr)); + switch (global_addr.ss_family) { + case AF_INET: -+ cur_unique_id.addr.in = ((struct sockaddr_in *)&global_addr)->sin_addr; ++ cur_unique_id->addr.in = ((struct sockaddr_in *)&global_addr)->sin_addr; + break; +#ifdef INET6 + case AF_INET6: +#ifdef SHORT_UNIQUE_ID -+ cur_unique_id.addr.in6 = ++ cur_unique_id->addr.in6 = + ((struct sockaddr_in6 *)&global_addr)->sin6_addr.s6_addr32[3]; +#else -+ cur_unique_id.addr.in6 = ++ cur_unique_id->addr.in6 = + ((struct sockaddr_in6 *)&global_addr)->sin6_addr; +#endif + break; @@ -5550,9 +4302,9 @@ diff -Nur apache_1.3.22.orig/src/modules/standard/mod_unique_id.c apache_1.3.22/ /* * If we use 0 as the initial counter we have a little less protection -diff -Nur apache_1.3.22.orig/src/support/ab.c apache_1.3.22/src/support/ab.c ---- apache_1.3.22.orig/src/support/ab.c Mon Oct 8 19:54:42 2001 -+++ apache_1.3.22/src/support/ab.c Fri Dec 7 17:41:39 2001 +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 @@ -5562,7 +4314,16 @@ diff -Nur apache_1.3.22.orig/src/support/ab.c apache_1.3.22/src/support/ab.c #endif /* NO_APACHE_INCLUDES */ #ifdef USE_SSL -@@ -261,7 +263,7 @@ +@@ -246,7 +248,7 @@ + char servername[1024]; /* name that server reports */ + char hostname[1024]; /* host name */ + char proxyhost[1024]; /* proxy host name */ +-int proxyport = 0; /* proxy port */ ++char *proxyport = NULL; /* proxy port */ + int isproxy = 0; + char path[1024]; /* path name */ + char postfile[1024]; /* name of file containing post data */ +@@ -262,7 +264,7 @@ auth[1024], /* optional (basic/uuencoded) * authentification */ hdrs[4096]; /* optional arbitrary headers */ @@ -5571,7 +4332,7 @@ diff -Nur apache_1.3.22.orig/src/support/ab.c apache_1.3.22/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 */ @@ -5580,7 +4341,7 @@ diff -Nur apache_1.3.22.orig/src/support/ab.c apache_1.3.22/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); @@ -5589,7 +4350,7 @@ diff -Nur apache_1.3.22.orig/src/support/ab.c apache_1.3.22/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; @@ -5597,8 +4358,8 @@ diff -Nur apache_1.3.22.orig/src/support/ab.c apache_1.3.22/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); @@ -5609,32 +4370,43 @@ diff -Nur apache_1.3.22.orig/src/support/ab.c apache_1.3.22/src/support/ab.c + if (connect(c->fd, (struct sockaddr *) & server, server.ss_len) < 0) +#endif + { - if (errno == EINPROGRESS) { - c->state = STATE_CONNECTING; - } -@@ -1209,16 +1216,20 @@ + 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 * connecthost; + char * url_on_request; + +@@ -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; -+ error = getaddrinfo(host, port, &hints, &res); ++ hints.ai_socktype = SOCK_STREAM; ++ 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); + } @@ -5643,16 +4415,45 @@ diff -Nur apache_1.3.22.orig/src/support/ab.c apache_1.3.22/src/support/ab.c } con = malloc(concurrency * sizeof(struct connection)); -@@ -1425,7 +1436,7 @@ +@@ -1430,7 +1441,7 @@ + if (strlen(purl) > 8 && strncmp(purl, "https://", 8) == 0) { + purl += 8; + ssl = 1; +- port = 443; ++ port = "443"; + } + #else + if (strlen(purl) > 8 && strncmp(purl, "https://", 8) == 0) { +@@ -1451,15 +1462,15 @@ *cp = '\0'; strcpy(hostname, h); if (p != NULL) - port = atoi(p); -+ port = strdup(p); - return 0; - } ++ port = strdup(p); -@@ -1668,3 +1679,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++; +- proxyport = atoi(p); ++ proxyport = strdup(p); + }; + strcpy(proxyhost, optarg); + isproxy = 1; +@@ -1705,3 +1716,7 @@ exit(0); } @@ -5660,9 +4461,9 @@ diff -Nur apache_1.3.22.orig/src/support/ab.c apache_1.3.22/src/support/ab.c +#ifdef NEED_GETADDRINFO +#include "../main/getaddrinfo.c" +#endif -diff -Nur apache_1.3.22.orig/src/support/logresolve.c apache_1.3.22/src/support/logresolve.c ---- apache_1.3.22.orig/src/support/logresolve.c Wed May 23 00:52:21 2001 -+++ apache_1.3.22/src/support/logresolve.c Fri Dec 7 17:27:28 2001 +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*/ @@ -5905,3 +4706,46 @@ diff -Nur apache_1.3.22.orig/src/support/logresolve.c apache_1.3.22/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,