diff -u -r -N squid-3.1.14/ChangeLog squid-3.1.15/ChangeLog
--- squid-3.1.14/ChangeLog	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/ChangeLog	2011-08-28 19:53:14.000000000 +1200
@@ -1,3 +1,26 @@
+Changes to squid-3.1.15 (28 Aug 2011):
+
+	- Regression fix: vhost and defaultsite causing vport to be ignored
+	- Regression Bug 3295: broken escaping in rfc1738_do_escape
+	- Bug #3232: fails to compile with OpenSSL v1.0.0
+	- Bug #3222: cache_peer name is not logging on CONNECT
+	- Bug #3131: fd_table[fd].closing() assert from ConnStateData::noteMoreBodySpaceAvailable()
+	- Bug #3217: "!fd_table[fd].closing()" from ServerStateData::noteMoreBodySpaceAvailable
+	- Bug #3213: https sites (CONNECT) not open when using NTLM
+	- Bug #3114: Memory leak in SSL certificate verify code
+	- Bug #3107: ncsa_auth DES silently truncates passwords to 8 bytes
+	- Bug #2662: cf_gen failure when cross compiling
+	- Bug #2655: passing wrong the username to the url_rewrite_program
+	- Bug #2495: ignore whitespace prefix on config lines
+	- Bug #2051: 'default' cache_peer option does not match documentation
+	- Bug #1842: Optimize order of tests in peerWouldBePinged() and peerHTTPOkay()
+	- Bug #1791: timestampsSet does not validate Date: if server sends very old date
+	- Correct parsing of large Gopher indexes
+	- Enable negative cacheing on unknown or -1 expiry timestamp
+	- Remove hierarchy_stoplist default value
+	- Migrate cf_gen tool from C-style to C++
+	- ... and several documentation and compiler warning fixes
+
 Changes to squid-3.1.14 (04 Jul 2011):
 
 	- Regression Bug 3261: Could not create a DNS socket and exit
@@ -572,6 +595,21 @@
 	- Bug #2223: Follow XFF extensions added
 	- ... and many code and documentation cleanups
 
+Changes to squid-3.0.STABLE26 (28 Aug 2011):
+
+	- Regression: header_replace for reply headers
+	- Bug 3183: Invalid URL accepted with url host part of only '@'.
+	- Bug 3107: ncsa_auth DES silently truncates passwords to 8 bytes
+	- Bug 3056: comm.cc "!fd_table[fd].closing()" assertion from helperServerFree
+	- Bug 2991: Wrong parameters to fcntl() in commSetCloseOnExec()
+	- Bug 2933: Verification of the max. port number for WCCP2 dynamic service
+	- Bug 2922: Fix assertion failed: HttpHeader.cc: "Headers[id].stat.aliveCount"
+	- Regression Bug 2899: Restore lost rfc1738_unescape() data type
+	- Regression Bug 2879: headers end finding
+	- Bug 2876: FD_SETSIZE override not working on all linux distributions
+	- Check for NULL and empty strings before calling str*cmp().
+	- Correct parsing of large Gopher indexes
+
 Changes to squid-3.0.STABLE25 (14 Mar 2010):
 
 	- Bug 2845: Rework the http digest auth parser
diff -u -r -N squid-3.1.14/compat/compat_shared.h squid-3.1.15/compat/compat_shared.h
--- squid-3.1.14/compat/compat_shared.h	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/compat/compat_shared.h	2011-08-28 19:53:14.000000000 +1200
@@ -220,5 +220,9 @@
 #define SA_RESETHAND SA_ONESHOT
 #endif
 
+/* NULL is not always provided. */
+#ifndef NULL
+#define NULL ((void *)0)
+#endif
 
 #endif /* _SQUID_COMPAT_SHARED_H */
diff -u -r -N squid-3.1.14/compat/GnuRegex.c squid-3.1.15/compat/GnuRegex.c
--- squid-3.1.14/compat/GnuRegex.c	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/compat/GnuRegex.c	2011-08-28 19:53:14.000000000 +1200
@@ -3730,6 +3730,9 @@
             POP_FAILURE_POINT(sdummy, pdummy,
                               dummy_low_reg, dummy_high_reg,
                               reg_dummy, reg_dummy, reg_info_dummy);
+            /* avoid GCC 4.6 set but unused variables warning. Does not matter here. */
+            if (pdummy || sdummy)
+                (void)0;
         }
         /* Note fall through.  */
 
diff -u -r -N squid-3.1.14/compat/Makefile.in squid-3.1.15/compat/Makefile.in
--- squid-3.1.14/compat/Makefile.in	2011-07-04 16:39:35.000000000 +1200
+++ squid-3.1.15/compat/Makefile.in	2011-08-28 19:53:43.000000000 +1200
@@ -151,6 +151,7 @@
 FALSE = @FALSE@
 FGREP = @FGREP@
 GREP = @GREP@
+HOSTCXX = @HOSTCXX@
 ICAP_LIBS = @ICAP_LIBS@
 INCLTDL = @INCLTDL@
 INSTALL = @INSTALL@
diff -u -r -N squid-3.1.14/compat/os/mswin.h squid-3.1.15/compat/os/mswin.h
--- squid-3.1.14/compat/os/mswin.h	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/compat/os/mswin.h	2011-08-28 19:53:14.000000000 +1200
@@ -176,7 +176,6 @@
 #define SIGUSR1 30	/* user defined signal 1 */
 #define SIGUSR2 31	/* user defined signal 2 */
 
-typedef unsigned short int ushort;
 #if !_SQUID_CYGWIN_
 typedef int uid_t;
 typedef int gid_t;
diff -u -r -N squid-3.1.14/configure squid-3.1.15/configure
--- squid-3.1.14/configure	2011-07-04 16:40:34.000000000 +1200
+++ squid-3.1.15/configure	2011-08-28 19:54:06.000000000 +1200
@@ -1,7 +1,7 @@
 #! /bin/sh
 # From configure.ac Revision.
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.68 for Squid Web Proxy 3.1.14.
+# Generated by GNU Autoconf 2.68 for Squid Web Proxy 3.1.15.
 #
 # Report bugs to <http://www.squid-cache.org/bugs/>.
 #
@@ -575,8 +575,8 @@
 # Identity of this package.
 PACKAGE_NAME='Squid Web Proxy'
 PACKAGE_TARNAME='squid'
-PACKAGE_VERSION='3.1.14'
-PACKAGE_STRING='Squid Web Proxy 3.1.14'
+PACKAGE_VERSION='3.1.15'
+PACKAGE_STRING='Squid Web Proxy 3.1.15'
 PACKAGE_BUGREPORT='http://www.squid-cache.org/bugs/'
 PACKAGE_URL=''
 
@@ -786,6 +786,7 @@
 LIBTOOL
 USE_LOADABLE_MODULES_FALSE
 USE_LOADABLE_MODULES_TRUE
+HOSTCXX
 host_os
 host_vendor
 host_cpu
@@ -1539,7 +1540,7 @@
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures Squid Web Proxy 3.1.14 to adapt to many kinds of systems.
+\`configure' configures Squid Web Proxy 3.1.15 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1609,7 +1610,7 @@
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of Squid Web Proxy 3.1.14:";;
+     short | recursive ) echo "Configuration of Squid Web Proxy 3.1.15:";;
    esac
   cat <<\_ACEOF
 
@@ -1722,8 +1723,8 @@
                           nothing; you also have to modify the source code to
                           use the leak finding functions. Probably Useful for
                           hackers only.
-  --enable-follow-x-forwarded-for
-                          Enable support for following the X-Forwarded-For
+  --disable-follow-x-forwarded-for
+                          Disable support for following the X-Forwarded-For
                           HTTP header to try to find the IP address of the
                           original or indirect client when a request has been
                           forwarded through other proxies.
@@ -1940,7 +1941,7 @@
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-Squid Web Proxy configure 3.1.14
+Squid Web Proxy configure 3.1.15
 generated by GNU Autoconf 2.68
 
 Copyright (C) 2010 Free Software Foundation, Inc.
@@ -2951,7 +2952,7 @@
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by Squid Web Proxy $as_me 3.1.14, which was
+It was created by Squid Web Proxy $as_me 3.1.15, which was
 generated by GNU Autoconf 2.68.  Invocation command line was
 
   $ $0 $@
@@ -3770,7 +3771,7 @@
 
 # Define the identity of the package.
  PACKAGE='squid'
- VERSION='3.1.14'
+ VERSION='3.1.15'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -5490,6 +5491,12 @@
 
 
 
+# might be cross-compiling
+if test "x$HOSTCXX" = "x"; then
+  HOSTCXX="$CXX"
+fi
+
+
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking simplified host os" >&5
 $as_echo_n "checking simplified host os... " >&6; }
 simple_host_os=`echo $host_os|sed 's/0-9.*//g;s/-.*//g'`
@@ -19416,10 +19423,10 @@
 follow_xff=1
 # Check whether --enable-follow-x-forwarded-for was given.
 if test "${enable_follow_x_forwarded_for+set}" = set; then :
-  enableval=$enable_follow_x_forwarded_for;  if test "$enableval" = "yes" ; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: follow X-Forwarded-For enabled" >&5
-$as_echo "$as_me: follow X-Forwarded-For enabled" >&6;}
-    follow_xff=1
+  enableval=$enable_follow_x_forwarded_for;  if test "$enableval" = "no" ; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: Disabling follow X-Forwarded-For" >&5
+$as_echo "$as_me: Disabling follow X-Forwarded-For" >&6;}
+    follow_xff=0
   fi
 
 fi
@@ -21147,6 +21154,7 @@
 	netinet/ip_fil_compat.h \
 	openssl/err.h \
 	openssl/md5.h \
+	openssl/opensslv.h \
 	openssl/ssl.h \
 	openssl/txt_db.h \
 	openssl/x509v3.h \
@@ -28135,7 +28143,7 @@
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by Squid Web Proxy $as_me 3.1.14, which was
+This file was extended by Squid Web Proxy $as_me 3.1.15, which was
 generated by GNU Autoconf 2.68.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -28201,7 +28209,7 @@
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-Squid Web Proxy config.status 3.1.14
+Squid Web Proxy config.status 3.1.15
 configured by $0, generated by GNU Autoconf 2.68,
   with options \\"\$ac_cs_config\\"
 
diff -u -r -N squid-3.1.14/configure.ac squid-3.1.15/configure.ac
--- squid-3.1.14/configure.ac	2011-07-04 16:40:34.000000000 +1200
+++ squid-3.1.15/configure.ac	2011-08-28 19:54:06.000000000 +1200
@@ -2,7 +2,7 @@
 dnl
 dnl  $Id$
 dnl
-AC_INIT([Squid Web Proxy],[3.1.14],[http://www.squid-cache.org/bugs/],[squid])
+AC_INIT([Squid Web Proxy],[3.1.15],[http://www.squid-cache.org/bugs/],[squid])
 AC_PREREQ(2.61)
 AC_CONFIG_HEADERS([include/autoconf.h])
 AC_CONFIG_AUX_DIR(cfgaux)
@@ -27,6 +27,12 @@
 AC_LANG([C++])
 AC_CANONICAL_HOST
 
+# might be cross-compiling
+if test "x$HOSTCXX" = "x"; then
+  HOSTCXX="$CXX"
+fi
+AC_SUBST(HOSTCXX)
+
 AC_MSG_CHECKING([simplified host os])
 simple_host_os=`echo $host_os|sed 's/[0-9].*//g;s/-.*//g'`
 squid_host_os_version=`echo $host_os|tr -d "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-"`
@@ -1634,13 +1640,13 @@
 
 follow_xff=1
 AC_ARG_ENABLE(follow-x-forwarded-for,
-  AS_HELP_STRING([--enable-follow-x-forwarded-for],[Enable support for following the X-Forwarded-For
+  AS_HELP_STRING([--disable-follow-x-forwarded-for],[Disable support for following the X-Forwarded-For
                  HTTP header to try to find the IP address of the
                  original or indirect client when a request has
                  been forwarded through other proxies.]),
-[ if test "$enableval" = "yes" ; then
-    AC_MSG_NOTICE([follow X-Forwarded-For enabled])
-    follow_xff=1
+[ if test "$enableval" = "no" ; then
+    AC_MSG_NOTICE([Disabling follow X-Forwarded-For])
+    follow_xff=0
   fi
 ])
 if test $follow_xff = 1; then
@@ -2310,6 +2316,7 @@
 	netinet/ip_fil_compat.h \
 	openssl/err.h \
 	openssl/md5.h \
+	openssl/opensslv.h \
 	openssl/ssl.h \
 	openssl/txt_db.h \
 	openssl/x509v3.h \
diff -u -r -N squid-3.1.14/contrib/Makefile.in squid-3.1.15/contrib/Makefile.in
--- squid-3.1.14/contrib/Makefile.in	2011-07-04 16:39:35.000000000 +1200
+++ squid-3.1.15/contrib/Makefile.in	2011-08-28 19:53:43.000000000 +1200
@@ -108,6 +108,7 @@
 FALSE = @FALSE@
 FGREP = @FGREP@
 GREP = @GREP@
+HOSTCXX = @HOSTCXX@
 ICAP_LIBS = @ICAP_LIBS@
 INCLTDL = @INCLTDL@
 INSTALL = @INSTALL@
diff -u -r -N squid-3.1.14/doc/Makefile.in squid-3.1.15/doc/Makefile.in
--- squid-3.1.14/doc/Makefile.in	2011-07-04 16:39:35.000000000 +1200
+++ squid-3.1.15/doc/Makefile.in	2011-08-28 19:53:44.000000000 +1200
@@ -136,6 +136,7 @@
 FALSE = @FALSE@
 FGREP = @FGREP@
 GREP = @GREP@
+HOSTCXX = @HOSTCXX@
 ICAP_LIBS = @ICAP_LIBS@
 INCLTDL = @INCLTDL@
 INSTALL = @INSTALL@
diff -u -r -N squid-3.1.14/errors/Makefile.in squid-3.1.15/errors/Makefile.in
--- squid-3.1.14/errors/Makefile.in	2011-07-04 16:39:36.000000000 +1200
+++ squid-3.1.15/errors/Makefile.in	2011-08-28 19:53:44.000000000 +1200
@@ -107,6 +107,7 @@
 FALSE = @FALSE@
 FGREP = @FGREP@
 GREP = @GREP@
+HOSTCXX = @HOSTCXX@
 ICAP_LIBS = @ICAP_LIBS@
 INCLTDL = @INCLTDL@
 INSTALL = @INSTALL@
diff -u -r -N squid-3.1.14/helpers/basic_auth/DB/Makefile.in squid-3.1.15/helpers/basic_auth/DB/Makefile.in
--- squid-3.1.14/helpers/basic_auth/DB/Makefile.in	2011-07-04 16:39:36.000000000 +1200
+++ squid-3.1.15/helpers/basic_auth/DB/Makefile.in	2011-08-28 19:53:44.000000000 +1200
@@ -138,6 +138,7 @@
 FALSE = @FALSE@
 FGREP = @FGREP@
 GREP = @GREP@
+HOSTCXX = @HOSTCXX@
 ICAP_LIBS = @ICAP_LIBS@
 INCLTDL = @INCLTDL@
 INSTALL = @INSTALL@
diff -u -r -N squid-3.1.14/helpers/basic_auth/getpwnam/Makefile.in squid-3.1.15/helpers/basic_auth/getpwnam/Makefile.in
--- squid-3.1.14/helpers/basic_auth/getpwnam/Makefile.in	2011-07-04 16:39:39.000000000 +1200
+++ squid-3.1.15/helpers/basic_auth/getpwnam/Makefile.in	2011-08-28 19:53:45.000000000 +1200
@@ -142,6 +142,7 @@
 FALSE = @FALSE@
 FGREP = @FGREP@
 GREP = @GREP@
+HOSTCXX = @HOSTCXX@
 ICAP_LIBS = @ICAP_LIBS@
 INCLTDL = @INCLTDL@
 INSTALL = @INSTALL@
diff -u -r -N squid-3.1.14/helpers/basic_auth/LDAP/Makefile.in squid-3.1.15/helpers/basic_auth/LDAP/Makefile.in
--- squid-3.1.14/helpers/basic_auth/LDAP/Makefile.in	2011-07-04 16:39:36.000000000 +1200
+++ squid-3.1.15/helpers/basic_auth/LDAP/Makefile.in	2011-08-28 19:53:44.000000000 +1200
@@ -167,6 +167,7 @@
 FALSE = @FALSE@
 FGREP = @FGREP@
 GREP = @GREP@
+HOSTCXX = @HOSTCXX@
 ICAP_LIBS = @ICAP_LIBS@
 INCLTDL = @INCLTDL@
 INSTALL = @INSTALL@
diff -u -r -N squid-3.1.14/helpers/basic_auth/Makefile.in squid-3.1.15/helpers/basic_auth/Makefile.in
--- squid-3.1.14/helpers/basic_auth/Makefile.in	2011-07-04 16:39:37.000000000 +1200
+++ squid-3.1.15/helpers/basic_auth/Makefile.in	2011-08-28 19:53:44.000000000 +1200
@@ -147,6 +147,7 @@
 FALSE = @FALSE@
 FGREP = @FGREP@
 GREP = @GREP@
+HOSTCXX = @HOSTCXX@
 ICAP_LIBS = @ICAP_LIBS@
 INCLTDL = @INCLTDL@
 INSTALL = @INSTALL@
diff -u -r -N squid-3.1.14/helpers/basic_auth/MSNT/Makefile.in squid-3.1.15/helpers/basic_auth/MSNT/Makefile.in
--- squid-3.1.14/helpers/basic_auth/MSNT/Makefile.in	2011-07-04 16:39:37.000000000 +1200
+++ squid-3.1.15/helpers/basic_auth/MSNT/Makefile.in	2011-08-28 19:53:44.000000000 +1200
@@ -161,6 +161,7 @@
 FALSE = @FALSE@
 FGREP = @FGREP@
 GREP = @GREP@
+HOSTCXX = @HOSTCXX@
 ICAP_LIBS = @ICAP_LIBS@
 INCLTDL = @INCLTDL@
 INSTALL = @INSTALL@
diff -u -r -N squid-3.1.14/helpers/basic_auth/mswin_sspi/Makefile.in squid-3.1.15/helpers/basic_auth/mswin_sspi/Makefile.in
--- squid-3.1.14/helpers/basic_auth/mswin_sspi/Makefile.in	2011-07-04 16:39:39.000000000 +1200
+++ squid-3.1.15/helpers/basic_auth/mswin_sspi/Makefile.in	2011-08-28 19:53:46.000000000 +1200
@@ -142,6 +142,7 @@
 FALSE = @FALSE@
 FGREP = @FGREP@
 GREP = @GREP@
+HOSTCXX = @HOSTCXX@
 ICAP_LIBS = @ICAP_LIBS@
 INCLTDL = @INCLTDL@
 INSTALL = @INSTALL@
diff -u -r -N squid-3.1.14/helpers/basic_auth/multi-domain-NTLM/Makefile.in squid-3.1.15/helpers/basic_auth/multi-domain-NTLM/Makefile.in
--- squid-3.1.14/helpers/basic_auth/multi-domain-NTLM/Makefile.in	2011-07-04 16:39:40.000000000 +1200
+++ squid-3.1.15/helpers/basic_auth/multi-domain-NTLM/Makefile.in	2011-08-28 19:53:46.000000000 +1200
@@ -135,6 +135,7 @@
 FALSE = @FALSE@
 FGREP = @FGREP@
 GREP = @GREP@
+HOSTCXX = @HOSTCXX@
 ICAP_LIBS = @ICAP_LIBS@
 INCLTDL = @INCLTDL@
 INSTALL = @INSTALL@
diff -u -r -N squid-3.1.14/helpers/basic_auth/NCSA/Makefile.in squid-3.1.15/helpers/basic_auth/NCSA/Makefile.in
--- squid-3.1.14/helpers/basic_auth/NCSA/Makefile.in	2011-07-04 16:39:37.000000000 +1200
+++ squid-3.1.15/helpers/basic_auth/NCSA/Makefile.in	2011-08-28 19:53:45.000000000 +1200
@@ -167,6 +167,7 @@
 FALSE = @FALSE@
 FGREP = @FGREP@
 GREP = @GREP@
+HOSTCXX = @HOSTCXX@
 ICAP_LIBS = @ICAP_LIBS@
 INCLTDL = @INCLTDL@
 INSTALL = @INSTALL@
diff -u -r -N squid-3.1.14/helpers/basic_auth/NCSA/ncsa_auth.8 squid-3.1.15/helpers/basic_auth/NCSA/ncsa_auth.8
--- squid-3.1.14/helpers/basic_auth/NCSA/ncsa_auth.8	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/helpers/basic_auth/NCSA/ncsa_auth.8	2011-08-28 19:53:14.000000000 +1200
@@ -26,13 +26,29 @@
 The only parameter is the password file.  It must have permissions to be read by the user that Squid is running as (cache_effective_user in squid.conf).
 .PP
 This password file can be manipulated using htpasswd.
+.
+.PP
+.This authenticator accepts:
+.BR
+* MD5 - with optional salt and magic strings
+.BR
+* DES - for passwords 8 characters or less in length
+.
 .SH OPTIONS
 Only specify the password file name.
 .SH EXAMPLE
 \fBncsa_auth\fP /etc/squid/squid.pass
 .SH SECURITY
 \fBncsa_auth\fP must have access to the password file to be executed.
+.
+.SH KNOWN ISSUES
+.PP
+DES functionality (used by htpasswd by default) silently truncates passwords to 8 characters.
+Allowing login with password values shorter than the one desired.
+This authenticator will reject login with long passwords when using DES.
+.
 .SH SEE ALSO
 \fBhtpasswd\fP(1), \fBsquid\fP(8)
+.
 .SH AUTHOR
 Manpage written by Rodrigo Rubira Branco <rrbranco@br.ibm.com>
diff -u -r -N squid-3.1.14/helpers/basic_auth/NCSA/ncsa_auth.c squid-3.1.15/helpers/basic_auth/NCSA/ncsa_auth.c
--- squid-3.1.14/helpers/basic_auth/NCSA/ncsa_auth.c	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/helpers/basic_auth/NCSA/ncsa_auth.c	2011-08-28 19:53:14.000000000 +1200
@@ -15,6 +15,7 @@
  * - extra fields in the password file are ignored; this makes it
  *   possible to use a Unix password file but I do not recommend that.
  *
+ *  MD5 without salt and magic strings - Added by Ramon de Carvalho and Rodrigo Rubira Branco
  */
 
 #include "config.h"
@@ -144,12 +145,18 @@
         if (u == NULL) {
             printf("ERR No such user\n");
 #if HAVE_CRYPT
-        } else if (strcmp(u->passwd, (char *) crypt(passwd, u->passwd)) == 0) {
+        } else if (strlen(passwd) <= 8 && strcmp(u->passwd, (char *) crypt(passwd, u->passwd)) == 0) {
+            // Bug 3107: crypt() DES functionality silently truncates long passwords.
+            printf("OK\n");
+        } else if (strlen(passwd) > 8 && strcmp(u->passwd, (char *) crypt(passwd, u->passwd)) == 0) {
+            // Bug 3107: crypt() DES functionality silently truncates long passwords.
+            fprintf(stderr, "SECURITY ALERT: NCSA DES algorithm truncating user %s password to 8 bytes. Upgrade to MD5.", user);
+            // Highly Unsafe: permit a transition period for admin to update passwords.
             printf("OK\n");
 #endif
         } else if (strcmp(u->passwd, (char *) crypt_md5(passwd, u->passwd)) == 0) {
             printf("OK\n");
-        } else if (strcmp(u->passwd, (char *) md5sum(passwd)) == 0) {	/* md5 without salt and magic strings - Added by Ramon de Carvalho and Rodrigo Rubira Branco */
+        } else if (strcmp(u->passwd, (char *) md5sum(passwd)) == 0) {
             printf("OK\n");
         } else {
             printf("ERR Wrong password\n");
diff -u -r -N squid-3.1.14/helpers/basic_auth/PAM/Makefile.in squid-3.1.15/helpers/basic_auth/PAM/Makefile.in
--- squid-3.1.14/helpers/basic_auth/PAM/Makefile.in	2011-07-04 16:39:38.000000000 +1200
+++ squid-3.1.15/helpers/basic_auth/PAM/Makefile.in	2011-08-28 19:53:45.000000000 +1200
@@ -166,6 +166,7 @@
 FALSE = @FALSE@
 FGREP = @FGREP@
 GREP = @GREP@
+HOSTCXX = @HOSTCXX@
 ICAP_LIBS = @ICAP_LIBS@
 INCLTDL = @INCLTDL@
 INSTALL = @INSTALL@
diff -u -r -N squid-3.1.14/helpers/basic_auth/POP3/Makefile.in squid-3.1.15/helpers/basic_auth/POP3/Makefile.in
--- squid-3.1.14/helpers/basic_auth/POP3/Makefile.in	2011-07-04 16:39:38.000000000 +1200
+++ squid-3.1.15/helpers/basic_auth/POP3/Makefile.in	2011-08-28 19:53:45.000000000 +1200
@@ -135,6 +135,7 @@
 FALSE = @FALSE@
 FGREP = @FGREP@
 GREP = @GREP@
+HOSTCXX = @HOSTCXX@
 ICAP_LIBS = @ICAP_LIBS@
 INCLTDL = @INCLTDL@
 INSTALL = @INSTALL@
diff -u -r -N squid-3.1.14/helpers/basic_auth/SASL/config.test squid-3.1.15/helpers/basic_auth/SASL/config.test
--- squid-3.1.14/helpers/basic_auth/SASL/config.test	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/helpers/basic_auth/SASL/config.test	2011-08-28 19:53:14.000000000 +1200
@@ -1,10 +1,8 @@
 #!/bin/sh
-if [ -f /usr/include/sasl.h -o -f /usr/include/sasl/sasl.h ]; then
-	if [ -f /usr/lib/libsasl.a -o -f /usr/lib/libsasl2.a ]; then
-		exit 0
-	fi
-	if [ -f /usr/lib/libsasl.la -o -f /usr/lib/libsasl2.la ]; then
-		exit 0
-	fi
+if [ -f /usr/include/sasl.h ]; then
+	exit 0
+fi
+if [ -f /usr/include/sasl/sasl.h ]; then
+	exit 0
 fi
 exit 1
diff -u -r -N squid-3.1.14/helpers/basic_auth/SASL/Makefile.in squid-3.1.15/helpers/basic_auth/SASL/Makefile.in
--- squid-3.1.14/helpers/basic_auth/SASL/Makefile.in	2011-07-04 16:39:38.000000000 +1200
+++ squid-3.1.15/helpers/basic_auth/SASL/Makefile.in	2011-08-28 19:53:45.000000000 +1200
@@ -142,6 +142,7 @@
 FALSE = @FALSE@
 FGREP = @FGREP@
 GREP = @GREP@
+HOSTCXX = @HOSTCXX@
 ICAP_LIBS = @ICAP_LIBS@
 INCLTDL = @INCLTDL@
 INSTALL = @INSTALL@
diff -u -r -N squid-3.1.14/helpers/basic_auth/SMB/Makefile.in squid-3.1.15/helpers/basic_auth/SMB/Makefile.in
--- squid-3.1.14/helpers/basic_auth/SMB/Makefile.in	2011-07-04 16:39:39.000000000 +1200
+++ squid-3.1.15/helpers/basic_auth/SMB/Makefile.in	2011-08-28 19:53:45.000000000 +1200
@@ -168,6 +168,7 @@
 FALSE = @FALSE@
 FGREP = @FGREP@
 GREP = @GREP@
+HOSTCXX = @HOSTCXX@
 ICAP_LIBS = @ICAP_LIBS@
 INCLTDL = @INCLTDL@
 INSTALL = @INSTALL@
diff -u -r -N squid-3.1.14/helpers/basic_auth/squid_radius_auth/Makefile.in squid-3.1.15/helpers/basic_auth/squid_radius_auth/Makefile.in
--- squid-3.1.14/helpers/basic_auth/squid_radius_auth/Makefile.in	2011-07-04 16:39:40.000000000 +1200
+++ squid-3.1.15/helpers/basic_auth/squid_radius_auth/Makefile.in	2011-08-28 19:53:46.000000000 +1200
@@ -167,6 +167,7 @@
 FALSE = @FALSE@
 FGREP = @FGREP@
 GREP = @GREP@
+HOSTCXX = @HOSTCXX@
 ICAP_LIBS = @ICAP_LIBS@
 INCLTDL = @INCLTDL@
 INSTALL = @INSTALL@
diff -u -r -N squid-3.1.14/helpers/basic_auth/squid_radius_auth/radius.h squid-3.1.15/helpers/basic_auth/squid_radius_auth/radius.h
--- squid-3.1.14/helpers/basic_auth/squid_radius_auth/radius.h	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/helpers/basic_auth/squid_radius_auth/radius.h	2011-08-28 19:53:14.000000000 +1200
@@ -37,7 +37,7 @@
 typedef struct pw_auth_hdr {
     u_char		code;
     u_char		id;
-    u_short		length;
+    uint16_t		length;
     u_char		vector[AUTH_VECTOR_LEN];
     u_char		data[2];
 } AUTH_HDR;
diff -u -r -N squid-3.1.14/helpers/basic_auth/squid_radius_auth/squid_rad_auth.c squid-3.1.15/helpers/basic_auth/squid_radius_auth/squid_rad_auth.c
--- squid-3.1.14/helpers/basic_auth/squid_radius_auth/squid_rad_auth.c	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/helpers/basic_auth/squid_radius_auth/squid_rad_auth.c	2011-08-28 19:53:14.000000000 +1200
@@ -175,7 +175,7 @@
  *    Receive and verify the result.
  */
 static int
-result_recv(u_int32_t host, u_short udp_port, char *buffer, int length)
+result_recv(uint32_t host, unsigned short udp_port, char *buffer, int length)
 {
     AUTH_HDR *auth;
     int totallen;
@@ -292,7 +292,7 @@
 authenticate(int socket_fd, const char *username, const char *passwd)
 {
     AUTH_HDR *auth;
-    u_short total_length;
+    unsigned short total_length;
     u_char *ptr;
     int length;
     char passbuf[MAXPASS];
@@ -457,7 +457,7 @@
     struct sockaddr_in salocal;
     struct sockaddr_in saremote;
     struct servent *svp;
-    u_short svc_port;
+    unsigned short svc_port;
     char username[MAXPWNAM];
     char passwd[MAXPASS];
     char *ptr;
@@ -519,7 +519,7 @@
      */
     svp = getservbyname(svc_name, "udp");
     if (svp != NULL)
-        svc_port = ntohs((u_short) svp->s_port);
+        svc_port = ntohs((unsigned short) svp->s_port);
     else
         svc_port = atoi(svc_name);
     if (svc_port == 0)
diff -u -r -N squid-3.1.14/helpers/basic_auth/YP/Makefile.in squid-3.1.15/helpers/basic_auth/YP/Makefile.in
--- squid-3.1.14/helpers/basic_auth/YP/Makefile.in	2011-07-04 16:39:39.000000000 +1200
+++ squid-3.1.15/helpers/basic_auth/YP/Makefile.in	2011-08-28 19:53:45.000000000 +1200
@@ -141,6 +141,7 @@
 FALSE = @FALSE@
 FGREP = @FGREP@
 GREP = @GREP@
+HOSTCXX = @HOSTCXX@
 ICAP_LIBS = @ICAP_LIBS@
 INCLTDL = @INCLTDL@
 INSTALL = @INSTALL@
diff -u -r -N squid-3.1.14/helpers/basic_auth/YP/nis_support.c squid-3.1.15/helpers/basic_auth/YP/nis_support.c
--- squid-3.1.14/helpers/basic_auth/YP/nis_support.c	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/helpers/basic_auth/YP/nis_support.c	2011-08-28 19:53:14.000000000 +1200
@@ -8,6 +8,12 @@
 #include <syslog.h>
 #include <sys/types.h>
 #include <rpc/rpc.h>
+
+#if _SQUID_FREEBSD_  && !defined(BOOL_DEFINED)
+// BUG: FreeBSD rpcsvc/yp_* headers try to redefine bool unless we match their non-standard hack.
+#define BOOL_DEFINED
+#endif
+
 #include <rpcsvc/ypclnt.h>
 #include <rpcsvc/yp_prot.h>
 
diff -u -r -N squid-3.1.14/helpers/digest_auth/eDirectory/Makefile.in squid-3.1.15/helpers/digest_auth/eDirectory/Makefile.in
--- squid-3.1.14/helpers/digest_auth/eDirectory/Makefile.in	2011-07-04 16:39:41.000000000 +1200
+++ squid-3.1.15/helpers/digest_auth/eDirectory/Makefile.in	2011-08-28 19:53:46.000000000 +1200
@@ -145,6 +145,7 @@
 FALSE = @FALSE@
 FGREP = @FGREP@
 GREP = @GREP@
+HOSTCXX = @HOSTCXX@
 ICAP_LIBS = @ICAP_LIBS@
 INCLTDL = @INCLTDL@
 INSTALL = @INSTALL@
diff -u -r -N squid-3.1.14/helpers/digest_auth/ldap/Makefile.in squid-3.1.15/helpers/digest_auth/ldap/Makefile.in
--- squid-3.1.14/helpers/digest_auth/ldap/Makefile.in	2011-07-04 16:39:41.000000000 +1200
+++ squid-3.1.15/helpers/digest_auth/ldap/Makefile.in	2011-08-28 19:53:46.000000000 +1200
@@ -145,6 +145,7 @@
 FALSE = @FALSE@
 FGREP = @FGREP@
 GREP = @GREP@
+HOSTCXX = @HOSTCXX@
 ICAP_LIBS = @ICAP_LIBS@
 INCLTDL = @INCLTDL@
 INSTALL = @INSTALL@
diff -u -r -N squid-3.1.14/helpers/digest_auth/Makefile.in squid-3.1.15/helpers/digest_auth/Makefile.in
--- squid-3.1.14/helpers/digest_auth/Makefile.in	2011-07-04 16:39:40.000000000 +1200
+++ squid-3.1.15/helpers/digest_auth/Makefile.in	2011-08-28 19:53:46.000000000 +1200
@@ -147,6 +147,7 @@
 FALSE = @FALSE@
 FGREP = @FGREP@
 GREP = @GREP@
+HOSTCXX = @HOSTCXX@
 ICAP_LIBS = @ICAP_LIBS@
 INCLTDL = @INCLTDL@
 INSTALL = @INSTALL@
diff -u -r -N squid-3.1.14/helpers/digest_auth/password/Makefile.in squid-3.1.15/helpers/digest_auth/password/Makefile.in
--- squid-3.1.14/helpers/digest_auth/password/Makefile.in	2011-07-04 16:39:41.000000000 +1200
+++ squid-3.1.15/helpers/digest_auth/password/Makefile.in	2011-08-28 19:53:47.000000000 +1200
@@ -144,6 +144,7 @@
 FALSE = @FALSE@
 FGREP = @FGREP@
 GREP = @GREP@
+HOSTCXX = @HOSTCXX@
 ICAP_LIBS = @ICAP_LIBS@
 INCLTDL = @INCLTDL@
 INSTALL = @INSTALL@
diff -u -r -N squid-3.1.14/helpers/external_acl/ip_user/Makefile.in squid-3.1.15/helpers/external_acl/ip_user/Makefile.in
--- squid-3.1.14/helpers/external_acl/ip_user/Makefile.in	2011-07-04 16:39:42.000000000 +1200
+++ squid-3.1.15/helpers/external_acl/ip_user/Makefile.in	2011-08-28 19:53:47.000000000 +1200
@@ -135,6 +135,7 @@
 FALSE = @FALSE@
 FGREP = @FGREP@
 GREP = @GREP@
+HOSTCXX = @HOSTCXX@
 ICAP_LIBS = @ICAP_LIBS@
 INCLTDL = @INCLTDL@
 INSTALL = @INSTALL@
diff -u -r -N squid-3.1.14/helpers/external_acl/ldap_group/Makefile.in squid-3.1.15/helpers/external_acl/ldap_group/Makefile.in
--- squid-3.1.14/helpers/external_acl/ldap_group/Makefile.in	2011-07-04 16:39:42.000000000 +1200
+++ squid-3.1.15/helpers/external_acl/ldap_group/Makefile.in	2011-08-28 19:53:47.000000000 +1200
@@ -159,6 +159,7 @@
 FALSE = @FALSE@
 FGREP = @FGREP@
 GREP = @GREP@
+HOSTCXX = @HOSTCXX@
 ICAP_LIBS = @ICAP_LIBS@
 INCLTDL = @INCLTDL@
 INSTALL = @INSTALL@
diff -u -r -N squid-3.1.14/helpers/external_acl/Makefile.in squid-3.1.15/helpers/external_acl/Makefile.in
--- squid-3.1.14/helpers/external_acl/Makefile.in	2011-07-04 16:39:41.000000000 +1200
+++ squid-3.1.15/helpers/external_acl/Makefile.in	2011-08-28 19:53:47.000000000 +1200
@@ -147,6 +147,7 @@
 FALSE = @FALSE@
 FGREP = @FGREP@
 GREP = @GREP@
+HOSTCXX = @HOSTCXX@
 ICAP_LIBS = @ICAP_LIBS@
 INCLTDL = @INCLTDL@
 INSTALL = @INSTALL@
diff -u -r -N squid-3.1.14/helpers/external_acl/mswin_ad_group/Makefile.in squid-3.1.15/helpers/external_acl/mswin_ad_group/Makefile.in
--- squid-3.1.14/helpers/external_acl/mswin_ad_group/Makefile.in	2011-07-04 16:39:42.000000000 +1200
+++ squid-3.1.15/helpers/external_acl/mswin_ad_group/Makefile.in	2011-08-28 19:53:47.000000000 +1200
@@ -128,6 +128,7 @@
 FALSE = @FALSE@
 FGREP = @FGREP@
 GREP = @GREP@
+HOSTCXX = @HOSTCXX@
 ICAP_LIBS = @ICAP_LIBS@
 INCLTDL = @INCLTDL@
 INSTALL = @INSTALL@
diff -u -r -N squid-3.1.14/helpers/external_acl/mswin_lm_group/Makefile.in squid-3.1.15/helpers/external_acl/mswin_lm_group/Makefile.in
--- squid-3.1.14/helpers/external_acl/mswin_lm_group/Makefile.in	2011-07-04 16:39:43.000000000 +1200
+++ squid-3.1.15/helpers/external_acl/mswin_lm_group/Makefile.in	2011-08-28 19:53:47.000000000 +1200
@@ -136,6 +136,7 @@
 FALSE = @FALSE@
 FGREP = @FGREP@
 GREP = @GREP@
+HOSTCXX = @HOSTCXX@
 ICAP_LIBS = @ICAP_LIBS@
 INCLTDL = @INCLTDL@
 INSTALL = @INSTALL@
diff -u -r -N squid-3.1.14/helpers/external_acl/session/Makefile.in squid-3.1.15/helpers/external_acl/session/Makefile.in
--- squid-3.1.14/helpers/external_acl/session/Makefile.in	2011-07-04 16:39:43.000000000 +1200
+++ squid-3.1.15/helpers/external_acl/session/Makefile.in	2011-08-28 19:53:47.000000000 +1200
@@ -158,6 +158,7 @@
 FALSE = @FALSE@
 FGREP = @FGREP@
 GREP = @GREP@
+HOSTCXX = @HOSTCXX@
 ICAP_LIBS = @ICAP_LIBS@
 INCLTDL = @INCLTDL@
 INSTALL = @INSTALL@
diff -u -r -N squid-3.1.14/helpers/external_acl/unix_group/Makefile.in squid-3.1.15/helpers/external_acl/unix_group/Makefile.in
--- squid-3.1.14/helpers/external_acl/unix_group/Makefile.in	2011-07-04 16:39:43.000000000 +1200
+++ squid-3.1.15/helpers/external_acl/unix_group/Makefile.in	2011-08-28 19:53:48.000000000 +1200
@@ -158,6 +158,7 @@
 FALSE = @FALSE@
 FGREP = @FGREP@
 GREP = @GREP@
+HOSTCXX = @HOSTCXX@
 ICAP_LIBS = @ICAP_LIBS@
 INCLTDL = @INCLTDL@
 INSTALL = @INSTALL@
diff -u -r -N squid-3.1.14/helpers/external_acl/wbinfo_group/Makefile.in squid-3.1.15/helpers/external_acl/wbinfo_group/Makefile.in
--- squid-3.1.14/helpers/external_acl/wbinfo_group/Makefile.in	2011-07-04 16:39:43.000000000 +1200
+++ squid-3.1.15/helpers/external_acl/wbinfo_group/Makefile.in	2011-08-28 19:53:48.000000000 +1200
@@ -127,6 +127,7 @@
 FALSE = @FALSE@
 FGREP = @FGREP@
 GREP = @GREP@
+HOSTCXX = @HOSTCXX@
 ICAP_LIBS = @ICAP_LIBS@
 INCLTDL = @INCLTDL@
 INSTALL = @INSTALL@
diff -u -r -N squid-3.1.14/helpers/Makefile.in squid-3.1.15/helpers/Makefile.in
--- squid-3.1.14/helpers/Makefile.in	2011-07-04 16:39:36.000000000 +1200
+++ squid-3.1.15/helpers/Makefile.in	2011-08-28 19:53:44.000000000 +1200
@@ -143,6 +143,7 @@
 FALSE = @FALSE@
 FGREP = @FGREP@
 GREP = @GREP@
+HOSTCXX = @HOSTCXX@
 ICAP_LIBS = @ICAP_LIBS@
 INCLTDL = @INCLTDL@
 INSTALL = @INSTALL@
diff -u -r -N squid-3.1.14/helpers/negotiate_auth/Makefile.in squid-3.1.15/helpers/negotiate_auth/Makefile.in
--- squid-3.1.14/helpers/negotiate_auth/Makefile.in	2011-07-04 16:39:44.000000000 +1200
+++ squid-3.1.15/helpers/negotiate_auth/Makefile.in	2011-08-28 19:53:48.000000000 +1200
@@ -147,6 +147,7 @@
 FALSE = @FALSE@
 FGREP = @FGREP@
 GREP = @GREP@
+HOSTCXX = @HOSTCXX@
 ICAP_LIBS = @ICAP_LIBS@
 INCLTDL = @INCLTDL@
 INSTALL = @INSTALL@
diff -u -r -N squid-3.1.14/helpers/negotiate_auth/mswin_sspi/Makefile.in squid-3.1.15/helpers/negotiate_auth/mswin_sspi/Makefile.in
--- squid-3.1.14/helpers/negotiate_auth/mswin_sspi/Makefile.in	2011-07-04 16:39:45.000000000 +1200
+++ squid-3.1.15/helpers/negotiate_auth/mswin_sspi/Makefile.in	2011-08-28 19:53:48.000000000 +1200
@@ -140,6 +140,7 @@
 FALSE = @FALSE@
 FGREP = @FGREP@
 GREP = @GREP@
+HOSTCXX = @HOSTCXX@
 ICAP_LIBS = @ICAP_LIBS@
 INCLTDL = @INCLTDL@
 INSTALL = @INSTALL@
diff -u -r -N squid-3.1.14/helpers/ntlm_auth/fakeauth/fakeauth_auth.c squid-3.1.15/helpers/ntlm_auth/fakeauth/fakeauth_auth.c
--- squid-3.1.14/helpers/ntlm_auth/fakeauth/fakeauth_auth.c	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/helpers/ntlm_auth/fakeauth/fakeauth_auth.c	2011-08-28 19:53:14.000000000 +1200
@@ -211,7 +211,7 @@
 ntlmGetString(ntlmhdr * hdr, strhdr * str, int flags)
 {
     static char buf[512];
-    u_short *s, c;
+    unsigned short *s, c;
     char *d, *sc;
     int l, o;
 
@@ -225,7 +225,7 @@
     }
     if ((flags & NEGOTIATE_ASCII) == 0) {
         /* UNICODE string */
-        s = (u_short *) ((char *) hdr + o);
+        s = (unsigned short *) ((char *) hdr + o);
         d = buf;
 
         for (l >>= 1; l; s++, l--) {
diff -u -r -N squid-3.1.14/helpers/ntlm_auth/fakeauth/Makefile.in squid-3.1.15/helpers/ntlm_auth/fakeauth/Makefile.in
--- squid-3.1.14/helpers/ntlm_auth/fakeauth/Makefile.in	2011-07-04 16:39:45.000000000 +1200
+++ squid-3.1.15/helpers/ntlm_auth/fakeauth/Makefile.in	2011-08-28 19:53:48.000000000 +1200
@@ -134,6 +134,7 @@
 FALSE = @FALSE@
 FGREP = @FGREP@
 GREP = @GREP@
+HOSTCXX = @HOSTCXX@
 ICAP_LIBS = @ICAP_LIBS@
 INCLTDL = @INCLTDL@
 INSTALL = @INSTALL@
diff -u -r -N squid-3.1.14/helpers/ntlm_auth/Makefile.in squid-3.1.15/helpers/ntlm_auth/Makefile.in
--- squid-3.1.14/helpers/ntlm_auth/Makefile.in	2011-07-04 16:39:45.000000000 +1200
+++ squid-3.1.15/helpers/ntlm_auth/Makefile.in	2011-08-28 19:53:48.000000000 +1200
@@ -147,6 +147,7 @@
 FALSE = @FALSE@
 FGREP = @FGREP@
 GREP = @GREP@
+HOSTCXX = @HOSTCXX@
 ICAP_LIBS = @ICAP_LIBS@
 INCLTDL = @INCLTDL@
 INSTALL = @INSTALL@
diff -u -r -N squid-3.1.14/helpers/ntlm_auth/mswin_sspi/Makefile.in squid-3.1.15/helpers/ntlm_auth/mswin_sspi/Makefile.in
--- squid-3.1.14/helpers/ntlm_auth/mswin_sspi/Makefile.in	2011-07-04 16:39:46.000000000 +1200
+++ squid-3.1.15/helpers/ntlm_auth/mswin_sspi/Makefile.in	2011-08-28 19:53:48.000000000 +1200
@@ -134,6 +134,7 @@
 FALSE = @FALSE@
 FGREP = @FGREP@
 GREP = @GREP@
+HOSTCXX = @HOSTCXX@
 ICAP_LIBS = @ICAP_LIBS@
 INCLTDL = @INCLTDL@
 INSTALL = @INSTALL@
diff -u -r -N squid-3.1.14/helpers/ntlm_auth/no_check/Makefile.in squid-3.1.15/helpers/ntlm_auth/no_check/Makefile.in
--- squid-3.1.14/helpers/ntlm_auth/no_check/Makefile.in	2011-07-04 16:39:46.000000000 +1200
+++ squid-3.1.15/helpers/ntlm_auth/no_check/Makefile.in	2011-08-28 19:53:49.000000000 +1200
@@ -135,6 +135,7 @@
 FALSE = @FALSE@
 FGREP = @FGREP@
 GREP = @GREP@
+HOSTCXX = @HOSTCXX@
 ICAP_LIBS = @ICAP_LIBS@
 INCLTDL = @INCLTDL@
 INSTALL = @INSTALL@
diff -u -r -N squid-3.1.14/helpers/ntlm_auth/smb_lm/Makefile.in squid-3.1.15/helpers/ntlm_auth/smb_lm/Makefile.in
--- squid-3.1.14/helpers/ntlm_auth/smb_lm/Makefile.in	2011-07-04 16:39:46.000000000 +1200
+++ squid-3.1.15/helpers/ntlm_auth/smb_lm/Makefile.in	2011-08-28 19:53:49.000000000 +1200
@@ -174,6 +174,7 @@
 FALSE = @FALSE@
 FGREP = @FGREP@
 GREP = @GREP@
+HOSTCXX = @HOSTCXX@
 ICAP_LIBS = @ICAP_LIBS@
 INCLTDL = @INCLTDL@
 INSTALL = @INSTALL@
diff -u -r -N squid-3.1.14/helpers/ntlm_auth/smb_lm/smbval/Makefile.in squid-3.1.15/helpers/ntlm_auth/smb_lm/smbval/Makefile.in
--- squid-3.1.14/helpers/ntlm_auth/smb_lm/smbval/Makefile.in	2011-07-04 16:39:47.000000000 +1200
+++ squid-3.1.15/helpers/ntlm_auth/smb_lm/smbval/Makefile.in	2011-08-28 19:53:49.000000000 +1200
@@ -136,6 +136,7 @@
 FALSE = @FALSE@
 FGREP = @FGREP@
 GREP = @GREP@
+HOSTCXX = @HOSTCXX@
 ICAP_LIBS = @ICAP_LIBS@
 INCLTDL = @INCLTDL@
 INSTALL = @INSTALL@
diff -u -r -N squid-3.1.14/icons/Makefile.in squid-3.1.15/icons/Makefile.in
--- squid-3.1.14/icons/Makefile.in	2011-07-04 16:39:47.000000000 +1200
+++ squid-3.1.15/icons/Makefile.in	2011-08-28 19:53:49.000000000 +1200
@@ -130,6 +130,7 @@
 FALSE = @FALSE@
 FGREP = @FGREP@
 GREP = @GREP@
+HOSTCXX = @HOSTCXX@
 ICAP_LIBS = @ICAP_LIBS@
 INCLTDL = @INCLTDL@
 INSTALL = @INSTALL@
diff -u -r -N squid-3.1.14/include/autoconf.h.in squid-3.1.15/include/autoconf.h.in
--- squid-3.1.14/include/autoconf.h.in	2011-07-04 16:39:25.000000000 +1200
+++ squid-3.1.15/include/autoconf.h.in	2011-08-28 19:53:41.000000000 +1200
@@ -532,6 +532,9 @@
 /* Define to 1 if you have the <openssl/md5.h> header file. */
 #undef HAVE_OPENSSL_MD5_H
 
+/* Define to 1 if you have the <openssl/opensslv.h> header file. */
+#undef HAVE_OPENSSL_OPENSSLV_H
+
 /* Define to 1 if you have the <openssl/ssl.h> header file. */
 #undef HAVE_OPENSSL_SSL_H
 
diff -u -r -N squid-3.1.14/include/MemPoolChunked.h squid-3.1.15/include/MemPoolChunked.h
--- squid-3.1.14/include/MemPoolChunked.h	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/include/MemPoolChunked.h	2011-08-28 19:53:14.000000000 +1200
@@ -12,7 +12,7 @@
 /// \ingroup MemPoolsAPI
 #define MEM_MIN_FREE  32
 /// \ingroup MemPoolsAPI
-#define MEM_MAX_FREE  65535	/* ushort is max number of items per chunk */
+#define MEM_MAX_FREE  65535	/* unsigned short is max number of items per chunk */
 
 class MemChunk;
 
diff -u -r -N squid-3.1.14/include/MemPool.h squid-3.1.15/include/MemPool.h
--- squid-3.1.14/include/MemPool.h	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/include/MemPool.h	2011-08-28 19:53:14.000000000 +1200
@@ -58,7 +58,7 @@
 /// \ingroup MemPoolsAPI
 #define MEM_MIN_FREE  32
 /// \ingroup MemPoolsAPI
-#define MEM_MAX_FREE  65535	/* ushort is max number of items per chunk */
+#define MEM_MAX_FREE  65535	/* unsigned short is max number of items per chunk */
 
 class MemImplementingAllocator;
 class MemPoolStats;
diff -u -r -N squid-3.1.14/include/snmp_session.h squid-3.1.15/include/snmp_session.h
--- squid-3.1.14/include/snmp_session.h	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/include/snmp_session.h	2011-08-28 19:53:14.000000000 +1200
@@ -38,8 +38,8 @@
     int retries;		/* Number of retries before timeout. */
     int timeout;		/* Number of uS until first timeout, then exponential backoff */
     char *peername;		/* Domain name or dotted IP address of default peer */
-    u_short remote_port;	/* UDP port number of peer. */
-    u_short local_port;		/* My UDP port number, 0 for default, picked randomly */
+    unsigned short remote_port;	/* UDP port number of peer. */
+    unsigned short local_port;		/* My UDP port number, 0 for default, picked randomly */
 };
 
 #define RECEIVED_MESSAGE   1
diff -u -r -N squid-3.1.14/include/version.h squid-3.1.15/include/version.h
--- squid-3.1.14/include/version.h	2011-07-04 16:40:34.000000000 +1200
+++ squid-3.1.15/include/version.h	2011-08-28 19:54:06.000000000 +1200
@@ -9,7 +9,7 @@
  */
 
 #ifndef SQUID_RELEASE_TIME
-#define SQUID_RELEASE_TIME 1309754312
+#define SQUID_RELEASE_TIME 1314517993
 #endif
 
 #ifndef APP_SHORTNAME
diff -u -r -N squid-3.1.14/lib/getaddrinfo.c squid-3.1.15/lib/getaddrinfo.c
--- squid-3.1.14/lib/getaddrinfo.c	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/lib/getaddrinfo.c	2011-08-28 19:53:14.000000000 +1200
@@ -74,10 +74,6 @@
 #if HAVE_NETDB_H
 #include <netdb.h>
 #endif
-#ifdef _SQUID_MSWIN_
-#undef IN_ADDR
-#include <ws2tcpip.h>
-#endif
 
 #include "getaddrinfo.h"
 #include "inet_pton.h"
@@ -189,7 +185,9 @@
         return (*res == NULL) ? EAI_MEMORY : 0;
     }
 
+#if HAVE_H_ERRNO
     h_errno = 0;
+#endif
     errno = 0;
     hp = gethostbyname(nodename);
     if (hp == NULL) {
diff -u -r -N squid-3.1.14/lib/getnameinfo.c squid-3.1.15/lib/getnameinfo.c
--- squid-3.1.14/lib/getnameinfo.c	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/lib/getnameinfo.c	2011-08-28 19:53:14.000000000 +1200
@@ -159,7 +159,7 @@
     const struct afd *afd;
     struct servent *sp;
     struct hostent *hp;
-    u_short port;
+    unsigned short port;
     int family, i;
     const char *addr;
     u_int32_t v4a;
diff -u -r -N squid-3.1.14/lib/inet_ntop.c squid-3.1.15/lib/inet_ntop.c
--- squid-3.1.14/lib/inet_ntop.c	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/lib/inet_ntop.c	2011-08-28 19:53:14.000000000 +1200
@@ -14,6 +14,8 @@
  *
  *    28-Oct-2007: drop some dead code. now tested working without.
  *
+ *    04-Nov-2010: drop SPRINTF casting macro
+ *
  * Squid CVS $Id$
  *
  *  Original License and code follows.
@@ -72,12 +74,6 @@
 #include <string.h>
 #endif
 
-#ifdef SPRINTF_CHAR
-# define SPRINTF(x) strlen(sprintf/**/x)
-#else
-# define SPRINTF(x) ((size_t)sprintf x)
-#endif
-
 #if ! defined(NS_INADDRSZ)
 #define NS_INADDRSZ      4
 #endif
@@ -143,7 +139,7 @@
     static const char fmt[] = "%u.%u.%u.%u";
     char tmp[sizeof "255.255.255.255"];
 
-    if (SPRINTF((tmp, fmt, src[0], src[1], src[2], src[3])) >= size) {
+    if (snprintf(tmp, min(sizeof("255.255.255.255"),size), fmt, src[0], src[1], src[2], src[3]) >= size) {
         errno = ENOSPC;
         return (NULL);
     }
@@ -232,7 +228,7 @@
             tp += strlen(tp);
             break;
         }
-        tp += SPRINTF((tp, "%x", words[i]));
+        tp += snprintf(tp, (tmp + sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255") - tp), "%x", words[i]);
     }
     /* Was it a trailing run of 0x00's? */
     if (best.base != -1 && (best.base + best.len) ==
diff -u -r -N squid-3.1.14/lib/Makefile.in squid-3.1.15/lib/Makefile.in
--- squid-3.1.14/lib/Makefile.in	2011-07-04 16:39:48.000000000 +1200
+++ squid-3.1.15/lib/Makefile.in	2011-08-28 19:53:49.000000000 +1200
@@ -228,6 +228,7 @@
 FALSE = @FALSE@
 FGREP = @FGREP@
 GREP = @GREP@
+HOSTCXX = @HOSTCXX@
 ICAP_LIBS = @ICAP_LIBS@
 INCLTDL = @INCLTDL@
 INSTALL = @INSTALL@
diff -u -r -N squid-3.1.14/lib/rfc1738.c squid-3.1.15/lib/rfc1738.c
--- squid-3.1.14/lib/rfc1738.c	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/lib/rfc1738.c	2011-08-28 19:53:14.000000000 +1200
@@ -87,8 +87,8 @@
 {
     static char *buf;
     static size_t bufsize = 0;
-    const char *p;
-    char *q;
+    const char *src;
+    char *dst;
     unsigned int i, do_escape;
 
     if (buf == NULL || strlen(url) * 3 > bufsize) {
@@ -96,11 +96,11 @@
         bufsize = strlen(url) * 3 + 1;
         buf = (char*)xcalloc(bufsize, 1);
     }
-    for (p = url, q = buf; *p != '\0' && q < (buf + bufsize - 1); p++, q++) {
+    for (src = url, dst = buf; *src != '\0' && dst < (buf + bufsize - 1); src++, dst++) {
 
         /* a-z, A-Z and 0-9 are SAFE. */
-        if ((*p >= 'a' && *p <= 'z') || (*p >= 'A' && *p <= 'Z') || (*p >= '0' && *p <= '9')) {
-            *q = *p;
+        if ((*src >= 'a' && *src <= 'z') || (*src >= 'A' && *src <= 'Z') || (*src >= '0' && *src <= '9')) {
+            *dst = *src;
             continue;
         }
 
@@ -109,22 +109,22 @@
         /* RFC 1738 defines these chars as unsafe */
         if ((flags & RFC1738_ESCAPE_UNSAFE)) {
             for (i = 0; i < sizeof(rfc1738_unsafe_chars); i++) {
-                if (*p == rfc1738_unsafe_chars[i]) {
+                if (*src == rfc1738_unsafe_chars[i]) {
                     do_escape = 1;
                     break;
                 }
             }
             /* Handle % separately */
-            if (!(flags & RFC1738_ESCAPE_NOPERCENT) && *p == '%')
+            if (!(flags & RFC1738_ESCAPE_NOPERCENT) && *src == '%')
                 do_escape = 1;
             /* Handle space separately */
-            else if (!(flags & RFC1738_ESCAPE_NOSPACE) && *p <= ' ')
+            else if (!(flags & RFC1738_ESCAPE_NOSPACE) && *src <= ' ')
                 do_escape = 1;
         }
         /* RFC 1738 defines these chars as reserved */
         if ((flags & RFC1738_ESCAPE_RESERVED) && do_escape == 0) {
             for (i = 0; i < sizeof(rfc1738_reserved_chars); i++) {
-                if (*p == rfc1738_reserved_chars[i]) {
+                if (*src == rfc1738_reserved_chars[i]) {
                     do_escape = 1;
                     break;
                 }
@@ -132,27 +132,24 @@
         }
         if ((flags & RFC1738_ESCAPE_CTRLS) && do_escape == 0) {
             /* RFC 1738 says any control chars (0x00-0x1F) are encoded */
-            if ((unsigned char) *p <= (unsigned char) 0x1F)
+            if ((unsigned char) *src <= (unsigned char) 0x1F)
                 do_escape = 1;
             /* RFC 1738 says 0x7f is encoded */
-            else if (*p == (char) 0x7F)
+            else if (*src == (char) 0x7F)
                 do_escape = 1;
             /* RFC 1738 says any non-US-ASCII are encoded */
-            else if (((unsigned char) *p >= (unsigned char) 0x80))
+            else if (((unsigned char) *src >= (unsigned char) 0x80))
                 do_escape = 1;
         }
         /* Do the triplet encoding, or just copy the char */
-        /* note: we do not need snprintf here as q is appropriately
-         * allocated - KA */
-
         if (do_escape == 1) {
-            (void) snprintf(q, (bufsize-(p-buf)), "%%%02X", (unsigned char) *p);
-            q += sizeof(char) * 2;
+            (void) snprintf(dst, (bufsize-(dst-buf)), "%%%02X", (unsigned char) *src);
+            dst += sizeof(char) * 2;
         } else {
-            *q = *p;
+            *dst = *src;
         }
     }
-    *q = '\0';
+    *dst = '\0';
     return (buf);
 }
 
diff -u -r -N squid-3.1.14/Makefile.in squid-3.1.15/Makefile.in
--- squid-3.1.14/Makefile.in	2011-07-04 16:39:59.000000000 +1200
+++ squid-3.1.15/Makefile.in	2011-08-28 19:53:54.000000000 +1200
@@ -162,6 +162,7 @@
 FALSE = @FALSE@
 FGREP = @FGREP@
 GREP = @GREP@
+HOSTCXX = @HOSTCXX@
 ICAP_LIBS = @ICAP_LIBS@
 INCLTDL = @INCLTDL@
 INSTALL = @INSTALL@
diff -u -r -N squid-3.1.14/RELEASENOTES.html squid-3.1.15/RELEASENOTES.html
--- squid-3.1.14/RELEASENOTES.html	2011-07-04 17:07:10.000000000 +1200
+++ squid-3.1.15/RELEASENOTES.html	2011-08-28 20:07:34.000000000 +1200
@@ -2,10 +2,10 @@
 <HTML>
 <HEAD>
  <META NAME="GENERATOR" CONTENT="LinuxDoc-Tools 0.9.66">
- <TITLE>Squid 3.1.14 release notes</TITLE>
+ <TITLE>Squid 3.1.15 release notes</TITLE>
 </HEAD>
 <BODY>
-<H1>Squid 3.1.14 release notes</H1>
+<H1>Squid 3.1.15 release notes</H1>
 
 <H2>Squid Developers</H2>
 <HR>
@@ -71,7 +71,7 @@
 <HR>
 <H2><A NAME="s1">1.</A> <A HREF="#toc1">Notice</A></H2>
 
-<P>The Squid Team are pleased to announce the release of Squid-3.1.14</P>
+<P>The Squid Team are pleased to announce the release of Squid-3.1.15</P>
 <P>This new release is available for download from 
 <A HREF="http://www.squid-cache.org/Versions/v3/3.1/">http://www.squid-cache.org/Versions/v3/3.1/</A> or the 
 <A HREF="http://www.squid-cache.org/Mirrors/http-mirrors.html">mirrors</A>.</P>
@@ -90,7 +90,7 @@
 <P>
 <UL>
 <LI>The lack of some features available in Squid-2.x series. See the regression sections below for full details.</LI>
-<LI>CVE-2009-0801 : NAT interception vulnerability to malicious clients.</LI>
+<LI>CVE-2009-0801 : NAT interception vulnerability to malicious clients. This is fixed in 3.2 series.</LI>
 </UL>
 </P>
 
@@ -1176,6 +1176,7 @@
 <DT><B>auth_param ntlm, basic, digest</B><DD>
 <P>BASIC, DIGEST:  New parameter option <EM>utf8 on|off</EM> to permit helpers to selectively process UTF-8 characters even though
 HTTP accepts only ISO-8859-1.</P>
+<P>NCSA authenticator updated in 3.1.15 to alert if passwords with more than 8 characters are used with DES encryption method.</P>
 <P>NTLM: The helper binary bundled with Squid under the name <EM>ntlm_auth</EM> has been renamed to accurately reflect
 its real behavior and to prevent confusion with the more useful Samba helper using the same name.</P>
 <P>Despite being used for NTLM, the helper does not in fact provide true NTLM function. What it does provide is
@@ -1320,6 +1321,9 @@
 <DT><B>header_replace</B><DD>
 <P>Deprecated. Use request_header_replace or reply_header_replace instead.</P>
 
+<DT><B>hierarchy_stoplist</B><DD>
+<P>Default value altered to no content, allowing dynamic websites to be fetched through peers.</P>
+
 <DT><B>http_port transparent intercept ssl-bump connection-auth[=on|off] ignore-cc</B><DD>
 <P>Option 'transparent' is being deprecated in favour of 'intercept' which more clearly identifies what the option does.
 For now option 'tproxy' remains with old behaviour meaning fully-invisible proxy using TPROXY support.</P>
diff -u -r -N squid-3.1.14/scripts/Makefile.in squid-3.1.15/scripts/Makefile.in
--- squid-3.1.14/scripts/Makefile.in	2011-07-04 16:39:48.000000000 +1200
+++ squid-3.1.15/scripts/Makefile.in	2011-08-28 19:53:49.000000000 +1200
@@ -106,6 +106,7 @@
 FALSE = @FALSE@
 FGREP = @FGREP@
 GREP = @GREP@
+HOSTCXX = @HOSTCXX@
 ICAP_LIBS = @ICAP_LIBS@
 INCLTDL = @INCLTDL@
 INSTALL = @INSTALL@
diff -u -r -N squid-3.1.14/snmplib/Makefile.in squid-3.1.15/snmplib/Makefile.in
--- squid-3.1.14/snmplib/Makefile.in	2011-07-04 16:39:48.000000000 +1200
+++ squid-3.1.15/snmplib/Makefile.in	2011-08-28 19:53:49.000000000 +1200
@@ -128,6 +128,7 @@
 FALSE = @FALSE@
 FGREP = @FGREP@
 GREP = @GREP@
+HOSTCXX = @HOSTCXX@
 ICAP_LIBS = @ICAP_LIBS@
 INCLTDL = @INCLTDL@
 INSTALL = @INSTALL@
diff -u -r -N squid-3.1.14/src/acl/Makefile.in squid-3.1.15/src/acl/Makefile.in
--- squid-3.1.14/src/acl/Makefile.in	2011-07-04 16:39:52.000000000 +1200
+++ squid-3.1.15/src/acl/Makefile.in	2011-08-28 19:53:51.000000000 +1200
@@ -181,6 +181,7 @@
 FALSE = @FALSE@
 FGREP = @FGREP@
 GREP = @GREP@
+HOSTCXX = @HOSTCXX@
 ICAP_LIBS = @ICAP_LIBS@
 INCLTDL = @INCLTDL@
 INSTALL = @INSTALL@
diff -u -r -N squid-3.1.14/src/adaptation/ecap/Makefile.in squid-3.1.15/src/adaptation/ecap/Makefile.in
--- squid-3.1.14/src/adaptation/ecap/Makefile.in	2011-07-04 16:39:53.000000000 +1200
+++ squid-3.1.15/src/adaptation/ecap/Makefile.in	2011-08-28 19:53:51.000000000 +1200
@@ -138,6 +138,7 @@
 FALSE = @FALSE@
 FGREP = @FGREP@
 GREP = @GREP@
+HOSTCXX = @HOSTCXX@
 ICAP_LIBS = @ICAP_LIBS@
 INCLTDL = @INCLTDL@
 INSTALL = @INSTALL@
diff -u -r -N squid-3.1.14/src/adaptation/icap/Makefile.in squid-3.1.15/src/adaptation/icap/Makefile.in
--- squid-3.1.14/src/adaptation/icap/Makefile.in	2011-07-04 16:39:53.000000000 +1200
+++ squid-3.1.15/src/adaptation/icap/Makefile.in	2011-08-28 19:53:51.000000000 +1200
@@ -139,6 +139,7 @@
 FALSE = @FALSE@
 FGREP = @FGREP@
 GREP = @GREP@
+HOSTCXX = @HOSTCXX@
 ICAP_LIBS = @ICAP_LIBS@
 INCLTDL = @INCLTDL@
 INSTALL = @INSTALL@
diff -u -r -N squid-3.1.14/src/adaptation/Makefile.in squid-3.1.15/src/adaptation/Makefile.in
--- squid-3.1.14/src/adaptation/Makefile.in	2011-07-04 16:39:52.000000000 +1200
+++ squid-3.1.15/src/adaptation/Makefile.in	2011-08-28 19:53:51.000000000 +1200
@@ -180,6 +180,7 @@
 FALSE = @FALSE@
 FGREP = @FGREP@
 GREP = @GREP@
+HOSTCXX = @HOSTCXX@
 ICAP_LIBS = @ICAP_LIBS@
 INCLTDL = @INCLTDL@
 INSTALL = @INSTALL@
diff -u -r -N squid-3.1.14/src/auth/Makefile.in squid-3.1.15/src/auth/Makefile.in
--- squid-3.1.14/src/auth/Makefile.in	2011-07-04 16:39:54.000000000 +1200
+++ squid-3.1.15/src/auth/Makefile.in	2011-08-28 19:53:52.000000000 +1200
@@ -157,6 +157,7 @@
 FALSE = @FALSE@
 FGREP = @FGREP@
 GREP = @GREP@
+HOSTCXX = @HOSTCXX@
 ICAP_LIBS = @ICAP_LIBS@
 INCLTDL = @INCLTDL@
 INSTALL = @INSTALL@
diff -u -r -N squid-3.1.14/src/base/Makefile.in squid-3.1.15/src/base/Makefile.in
--- squid-3.1.14/src/base/Makefile.in	2011-07-04 16:39:54.000000000 +1200
+++ squid-3.1.15/src/base/Makefile.in	2011-08-28 19:53:52.000000000 +1200
@@ -137,6 +137,7 @@
 FALSE = @FALSE@
 FGREP = @FGREP@
 GREP = @GREP@
+HOSTCXX = @HOSTCXX@
 ICAP_LIBS = @ICAP_LIBS@
 INCLTDL = @INCLTDL@
 INSTALL = @INSTALL@
diff -u -r -N squid-3.1.14/src/cache_cf.cc squid-3.1.15/src/cache_cf.cc
--- squid-3.1.14/src/cache_cf.cc	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/src/cache_cf.cc	2011-08-28 19:53:14.000000000 +1200
@@ -133,7 +133,7 @@
 static void parse_refreshpattern(refresh_t **);
 static int parseTimeUnits(const char *unit);
 static void parseTimeLine(time_t * tptr, const char *units);
-static void parse_ushort(u_short * var);
+static void parse_ushort(unsigned short * var);
 static void parse_string(char **);
 static void default_all(void);
 static void defaults_if_none(void);
@@ -317,6 +317,11 @@
         if ((token = strchr(config_input_line, '\r')))
             *token = '\0';
 
+        // strip any prefix whitespace off the line.
+        const char *p = skip_ws(config_input_line);
+        if (config_input_line != p)
+            memmove(config_input_line, p, strlen(p)+1);
+
         if (strncmp(config_input_line, "#line ", 6) == 0) {
             static char new_file_name[1024];
             static char *file;
@@ -1753,7 +1758,7 @@
  \param proto	'tcp' or 'udp' for protocol
  \returns       Port the named service is supposed to be listening on.
  */
-static u_short
+static unsigned short
 GetService(const char *proto)
 {
     struct servent *port = NULL;
@@ -1767,7 +1772,7 @@
     if ( !isUnsignedNumeric(token, strlen(token)) )
         port = getservbyname(token, proto);
     if (port != NULL) {
-        return ntohs((u_short)port->s_port);
+        return ntohs((unsigned short)port->s_port);
     }
     /** Or a numeric translation of the config text. */
     return xatos(token);
@@ -1777,7 +1782,7 @@
  \returns       Port the named TCP service is supposed to be listening on.
  \copydoc GetService(const char *proto)
  */
-inline u_short
+inline unsigned short
 GetTcpService(void)
 {
     return GetService("tcp");
@@ -1787,7 +1792,7 @@
  \returns       Port the named UDP service is supposed to be listening on.
  \copydoc GetService(const char *proto)
  */
-inline u_short
+inline unsigned short
 GetUdpService(void)
 {
     return GetService("udp");
@@ -2755,25 +2760,25 @@
 #define free_kb_int64_t free_b_int64_t
 
 static void
-dump_ushort(StoreEntry * entry, const char *name, u_short var)
+dump_ushort(StoreEntry * entry, const char *name, unsigned short var)
 {
     storeAppendPrintf(entry, "%s %d\n", name, var);
 }
 
 static void
-free_ushort(u_short * u)
+free_ushort(unsigned short * u)
 {
     *u = 0;
 }
 
 static void
-parse_ushort(u_short * var)
+parse_ushort(unsigned short * var)
 {
     ConfigParser::ParseUShort(var);
 }
 
 void
-ConfigParser::ParseUShort(u_short *var)
+ConfigParser::ParseUShort(unsigned short *var)
 {
     *var = GetShort();
 }
@@ -3107,7 +3112,7 @@
         if (!Ip::EnableIpv6)
             s->s.SetIPv4();
         debugs(3, 3, "http(s)_port: found Listen on wildcard address: *:" << s->s.GetPort() );
-    } else if ( s->s = host ) { /* check/parse numeric IPA */
+    } else if ( (s->s = host) ) { /* check/parse numeric IPA */
         s->s.SetPort(port);
         if (!Ip::EnableIpv6)
             s->s.SetIPv4();
@@ -3667,7 +3672,11 @@
 
     if (strcmp(filename, "none") == 0) {
         cl->type = CLF_NONE;
-        goto done;
+        aclParseAclList(LegacyParser, &cl->aclList);
+        while (*logs)
+            logs = &(*logs)->next;
+        *logs = cl;
+        return;
     }
 
     if ((logdef_name = strtok(NULL, w_space)) == NULL)
@@ -3708,7 +3717,6 @@
         return;
     }
 
-done:
     aclParseAclList(LegacyParser, &cl->aclList);
 
     while (*logs)
diff -u -r -N squid-3.1.14/src/cf.data.pre squid-3.1.15/src/cf.data.pre
--- squid-3.1.14/src/cf.data.pre	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/src/cf.data.pre	2011-08-28 19:53:14.000000000 +1200
@@ -1169,14 +1169,16 @@
 			accelerators should consider the default.
 			Implies accel.
 
-	   vhost	Accelerator mode using Host header for virtual
-			domain support. Implies accel.
+	   vhost	Accelerator mode using Host header for virtual domain support.
+			Also uses the port as specified in Host: header unless
+			overridden by the vport option. Implies accel.
 
-	   vport	Accelerator with IP based virtual host support.
-			Implies accel.
+	   vport	Virtual host port support. Using the http_port number
+			instead of the port passed on Host: headers. Implies accel.
 
-	   vport=NN	As above, but uses specified port number rather
-			than the http_port number. Implies accel.
+	   vport=NN	Virtual host port support. Using the specified port
+			number instead of the port passed on Host: headers.
+			Implies accel.
 
 	   protocol=	Protocol to reconstruct accelerated requests with.
 			Defaults to http.
@@ -2183,12 +2185,11 @@
 	be handled directly by this cache.  In other words, use this
 	to not query neighbor caches for certain objects.  You may
 	list this option multiple times.
-	Note: never_direct overrides this option.
-NOCOMMENT_START
 
-# We recommend you to use at least the following line.
-hierarchy_stoplist cgi-bin ?
-NOCOMMENT_END
+	Example:
+		hierarchy_stoplist cgi-bin ?
+
+	Note: never_direct overrides this option.
 DOC_END
 
 COMMENT_START
diff -u -r -N squid-3.1.14/src/cf_gen.cc squid-3.1.15/src/cf_gen.cc
--- squid-3.1.14/src/cf_gen.cc	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/src/cf_gen.cc	2011-08-28 19:53:14.000000000 +1200
@@ -1,6 +1,8 @@
 /*
  * DEBUG: none          Generate squid.conf.default and cf_parser.cci
  * AUTHOR: Max Okumoto
+ * AUTHOR: Francesco Chemolli
+ * AUTHOR: Amos Jeffries
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
  * ----------------------------------------------------------
@@ -45,18 +47,24 @@
  *			 administrator.
  *****************************************************************************/
 
-//#include "squid.h"
-#include "config.h"
-//#include "SquidTime.h"
-#include "util.h"
-
-#if HAVE_STRING_H
-#include <string.h>
-#endif
-#if HAVE_STRING_H
-#include <ctype.h>
+/*
+ * hack around a bug in intel's c++ compiler's libraries which do not
+ * correctly support 64-bit iostreams
+ */
+#if defined(__INTEL_COMPILER) && defined(_FILE_OFFSET_BITS) && \
+_FILE_OFFSET_BITS==64
+#undef _FILE_OFFSET_BITS
 #endif
 
+#include <cassert>
+#include <cctype>
+#include <cerrno>
+#include <cstdlib>
+#include <cstring>
+#include <fstream>
+#include <iostream>
+#include <list>
+
 #include "cf_gen_defines.cci"
 
 #define MAX_LINE	1024	/* longest configuration line */
@@ -73,125 +81,123 @@
     sEXIT
 };
 
-typedef struct Line {
-    char *data;
-
-    struct Line *next;
-} Line;
-
-typedef struct EntryAlias {
+typedef std::list<std::string> LineList;
+typedef std::list<std::string> TypeDepList;
+typedef std::list<std::string> EntryAliasList;
+
+class DefaultValues
+{
+public:
+    DefaultValues() : preset(), if_none(), docs() {}
+    ~DefaultValues() {}
+
+    /// Default config lines to be defined before parsing the config files.
+    LineList preset;
+
+    /// Default config lines to parse if the directive has no prior settings.
+    /// This is mutually exclusive with preset values.
+    /// An error will be printed during build if they clash.
+    LineList if_none;
+
+    /// Text description to use in documentation for the default.
+    /// If unset the preset or if-none values will be displayed.
+    LineList docs;
+};
 
-    struct EntryAlias *next;
-    char *name;
-} EntryAlias;
-
-typedef struct Entry {
-    char *name;
-    EntryAlias *alias;
-    char *type;
-    char *loc;
-    char *default_value;
-    Line *default_if_none;
-    char *comment;
-    char *ifdef;
-    Line *doc;
-    Line *nocomment;
+class Entry
+{
+public:
+    Entry(const char *str) :
+            name(str), alias(),type(), loc(),
+            defaults(), comment(), ifdef(), doc(), nocomment(),
+            array_flag(0) {}
+    ~Entry() {}
+
+    std::string name;
+    EntryAliasList alias;
+    std::string type;
+    std::string loc;
+    DefaultValues defaults;
+    std::string comment;
+    std::string ifdef;
+    LineList doc;
+    LineList nocomment;
     int array_flag;
 
-    struct Entry *next;
-} Entry;
-
-typedef struct TypeDep {
-    char *name;
-
-    TypeDep *next;
-} TypeDep;
+    void genParse(std::ostream &fout) const;
 
-typedef struct Type {
-    char *name;
-    TypeDep *depend;
-
-    struct Type *next;
-} Type;
-
-static const char WS[] = " \t\n";
-static int gen_default(Entry *, FILE *);
-static void gen_parse(Entry *, FILE *);
-static void gen_parse_entry(Entry *entry, FILE *fp);
-static void gen_parse_alias(char *, EntryAlias *, Entry *, FILE *);
-static void gen_dump(Entry *, FILE *);
-static void gen_free(Entry *, FILE *);
-static void gen_conf(Entry *, FILE *, bool verbose_output);
-static void gen_default_if_none(Entry *, FILE *);
+private:
+    void genParseAlias(const std::string &, std::ostream &) const;
+};
 
+typedef std::list<class Entry> EntryList;
 
-static void
-lineAdd(Line ** L, const char *str)
+class Type
 {
-    while (*L)
-        L = &(*L)->next;
+public:
+    Type(const char *str) : name(str) {}
+    ~Type() {}
 
-    *L = (Line *)xcalloc(1, sizeof(Line));
+    std::string name;
+    TypeDepList depend;
+};
 
-    (*L)->data = xstrdup(str);
-}
+typedef std::list<class Type> TypeList;
+
+static const char WS[] = " \t\n";
+static int gen_default(const EntryList &, std::ostream &);
+static void gen_parse(const EntryList &, std::ostream &);
+static void gen_dump(const EntryList &, std::ostream&);
+static void gen_free(const EntryList &, std::ostream&);
+static void gen_conf(const EntryList &, std::ostream&, bool verbose_output);
+static void gen_default_if_none(const EntryList &, std::ostream&);
 
 static void
-checkDepend(const char *directive, const char *name, const Type *types, const Entry *entries)
+checkDepend(const std::string &directive, const char *name, const TypeList &types, const EntryList &entries)
 {
-    const Type *type;
-    for (type = types; type; type = type->next) {
-        const TypeDep *dep;
-        if (strcmp(type->name, name) != 0)
-            continue;
-        for (dep = type->depend; dep; dep = dep->next) {
-            const Entry *entry;
-            for (entry = entries; entry; entry = entry->next) {
-                if (strcmp(entry->name, dep->name) == 0)
+    for (TypeList::const_iterator t = types.begin(); t != types.end(); ++t) {
+        if (t->name.compare(name) != 0)
+            continue;
+        for (TypeDepList::const_iterator dep = t->depend.begin(); dep != t->depend.end(); ++dep) {
+            EntryList::const_iterator entry = entries.begin();
+            for (; entry != entries.end(); ++entry) {
+                if (entry->name.compare(*dep) == 0)
                     break;
             }
-            if (!entry) {
-                fprintf(stderr, "ERROR: '%s' (%s) depends on '%s'\n", directive, name, dep->name);
+            if (entry == entries.end()) {
+                std::cerr << "ERROR: '" << directive << "' (" << name << ") depends on '" << *dep << "'\n";
                 exit(1);
             }
         }
         return;
     }
-    fprintf(stderr, "ERROR: Dependencies for cf.data type '%s' used in '%s' not defined\n", name, directive);
+    std::cerr << "ERROR: Dependencies for cf.data type '" << name << "' used in ' " << directive << "' not defined\n" ;
     exit(1);
 }
 
 static void
 usage(const char *program_name)
 {
-    fprintf(stderr, "Usage: %s cf.data cf.data.depend\n", program_name);
+    std::cerr << "Usage: " << program_name << " cf.data cf.data.depend\n";
     exit(1);
 }
 
 int
 main(int argc, char *argv[])
 {
-    FILE *fp;
     char *input_filename;
     const char *output_filename = _PATH_PARSER;
     const char *conf_filename = _PATH_SQUID_CONF;
     const char *conf_filename_short = _PATH_SQUID_CONF_SHORT;
     const char *type_depend;
     int linenum = 0;
-    Entry *entries = NULL;
-    Entry *curr = NULL;
-    Type *types = NULL;
+    EntryList entries;
+    TypeList types;
     enum State state;
     int rc = 0;
     char *ptr = NULL;
-#ifdef _SQUID_OS2_
-
-    const char *rmode = "rt";
-#else
-
-    const char *rmode = "r";
-#endif
     char buff[MAX_LINE];
+    std::ifstream fp;
 
     if (argc != 3)
         usage(argv[0]);
@@ -202,53 +208,45 @@
     /*-------------------------------------------------------------------*
      * Parse type dependencies
      *-------------------------------------------------------------------*/
-    if ((fp = fopen(type_depend, rmode)) == NULL) {
-        perror(input_filename);
+    fp.open(type_depend, std::ifstream::in);
+    if (fp.fail()) {
+        std::cerr << "error while opening type dependencies file '" <<
+                  type_depend << "': " << strerror(errno) << std::endl;
         exit(1);
     }
 
-    while ((NULL != fgets(buff, MAX_LINE, fp))) {
+    while (fp.good()) {
+        fp.getline(buff,MAX_LINE);
         const char *type = strtok(buff, WS);
         const char *dep;
         if (!type || type[0] == '#')
             continue;
-        Type *t = (Type *)xcalloc(1, sizeof(*t));
-        t->name = xstrdup(type);
+        Type t(type);
         while ((dep = strtok(NULL, WS)) != NULL) {
-            TypeDep *d = (TypeDep *)xcalloc(1, sizeof(*d));
-            d->name = xstrdup(dep);
-            d->next = t->depend;
-            t->depend = d;
+            t.depend.push_front(dep);
         }
-        t->next = types;
-        types = t;
+        types.push_front(t);
     }
-    fclose(fp);
+    fp.close();
+    fp.clear(); // BSD does not reset flags in close().
 
     /*-------------------------------------------------------------------*
      * Parse input file
      *-------------------------------------------------------------------*/
 
     /* Open input file */
-
-    if ((fp = fopen(input_filename, rmode)) == NULL) {
-        perror(input_filename);
+    fp.open(input_filename, std::ifstream::in);
+    if (fp.fail()) {
+        std::cerr << "error while opening input file '" <<
+                  input_filename << "': " << strerror(errno) << std::endl;
         exit(1);
     }
 
-#ifdef _SQUID_WIN32_
-    setmode(fileno(fp), O_TEXT);
-
-#endif
-
     state = sSTART;
 
-    while (feof(fp) == 0 && state != sEXIT) {
+    while (fp.getline(buff,MAX_LINE), fp.good() && state != sEXIT) {
         char *t;
 
-        if (NULL == fgets(buff, MAX_LINE, fp))
-            break;
-
         linenum++;
 
         if ((t = strchr(buff, '\n')))
@@ -265,37 +263,32 @@
                 char *name, *aliasname;
 
                 if ((name = strtok(buff + 5, WS)) == NULL) {
-                    printf("Error in input file\n");
+                    std::cerr << "Error in input file\n";
                     exit(1);
                 }
 
-                curr = (Entry *)xcalloc(1, sizeof(Entry));
-                curr->name = xstrdup(name);
+                entries.push_back(name);
 
-                while ((aliasname = strtok(NULL, WS)) != NULL) {
-                    EntryAlias *alias = (EntryAlias *)xcalloc(1, sizeof(EntryAlias));
-                    alias->next = curr->alias;
-                    alias->name = xstrdup(aliasname);
-                    curr->alias = alias;
-                }
+                while ((aliasname = strtok(NULL, WS)) != NULL)
+                    entries.back().alias.push_front(aliasname);
 
                 state = s1;
             } else if (!strcmp(buff, "EOF")) {
                 state = sEXIT;
             } else if (!strcmp(buff, "COMMENT_START")) {
-                curr = (Entry *)xcalloc(1, sizeof(Entry));
-                curr->name = xstrdup("comment");
-                curr->loc = xstrdup("none");
+                entries.push_back("comment");
+                entries.back().loc = "none";
                 state = sDOC;
             } else {
-                printf("Error on line %d\n", linenum);
-                printf("--> %s\n", buff);
+                std::cerr << "Error on line " << linenum << std::endl <<
+                          "--> " << buff << std::endl;
                 exit(1);
             }
 
             break;
 
-        case s1:
+        case s1: {
+            Entry &curr = entries.back();
 
             if ((strlen(buff) == 0) || (!strncmp(buff, "#", 1))) {
                 /* ignore empty and comment lines */
@@ -303,149 +296,103 @@
             } else if (!strncmp(buff, "COMMENT:", 8)) {
                 ptr = buff + 8;
 
-                while (xisspace(*ptr))
+                while (isspace((unsigned char)*ptr))
                     ptr++;
 
-                curr->comment = xstrdup(ptr);
+                curr.comment = ptr;
             } else if (!strncmp(buff, "DEFAULT:", 8)) {
                 ptr = buff + 8;
 
-                while (xisspace(*ptr))
+                while (isspace((unsigned char)*ptr))
                     ptr++;
 
-                curr->default_value = xstrdup(ptr);
+                curr.defaults.preset.push_back(ptr);
             } else if (!strncmp(buff, "DEFAULT_IF_NONE:", 16)) {
                 ptr = buff + 16;
 
-                while (xisspace(*ptr))
+                while (isspace((unsigned char)*ptr))
                     ptr++;
 
-                lineAdd(&curr->default_if_none, ptr);
+                curr.defaults.if_none.push_back(ptr);
+            } else if (!strncmp(buff, "DEFAULT_DOC:", 12)) {
+                ptr = buff + 12;
+
+                while (isspace((unsigned char)*ptr))
+                    ptr++;
+
+                curr.defaults.docs.push_back(ptr);
             } else if (!strncmp(buff, "LOC:", 4)) {
                 if ((ptr = strtok(buff + 4, WS)) == NULL) {
-                    printf("Error on line %d\n", linenum);
+                    std::cerr << "Error on line " << linenum << std::endl;
                     exit(1);
                 }
 
-                curr->loc = xstrdup(ptr);
+                curr.loc = ptr;
             } else if (!strncmp(buff, "TYPE:", 5)) {
                 if ((ptr = strtok(buff + 5, WS)) == NULL) {
-                    printf("Error on line %d\n", linenum);
+                    std::cerr << "Error on line " << linenum << std::endl;
                     exit(1);
                 }
 
                 /* hack to support arrays, rather than pointers */
                 if (0 == strcmp(ptr + strlen(ptr) - 2, "[]")) {
-                    curr->array_flag = 1;
+                    curr.array_flag = 1;
                     *(ptr + strlen(ptr) - 2) = '\0';
                 }
 
-                checkDepend(curr->name, ptr, types, entries);
-                curr->type = xstrdup(ptr);
+                checkDepend(curr.name, ptr, types, entries);
+                curr.type = ptr;
             } else if (!strncmp(buff, "IFDEF:", 6)) {
                 if ((ptr = strtok(buff + 6, WS)) == NULL) {
-                    printf("Error on line %d\n", linenum);
+                    std::cerr << "Error on line " << linenum << std::endl;
                     exit(1);
                 }
 
-                curr->ifdef = xstrdup(ptr);
+                curr.ifdef = ptr;
             } else if (!strcmp(buff, "DOC_START")) {
                 state = sDOC;
             } else if (!strcmp(buff, "DOC_NONE")) {
-                /* add to list of entries */
-                curr->next = entries;
-                entries = curr;
                 state = sSTART;
             } else {
-                printf("Error on line %d\n", linenum);
+                std::cerr << "Error on line " << linenum << std::endl;
                 exit(1);
             }
-
-            break;
+        }
+        break;
 
         case sDOC:
-
             if (!strcmp(buff, "DOC_END") || !strcmp(buff, "COMMENT_END")) {
-                Line *head = NULL;
-                Line *line = curr->doc;
-                /* reverse order of doc lines */
-
-                while (line != NULL) {
-                    Line *tmp;
-                    tmp = line->next;
-                    line->next = head;
-                    head = line;
-                    line = tmp;
-                }
-
-                curr->doc = head;
-                /* add to list of entries */
-                curr->next = entries;
-                entries = curr;
                 state = sSTART;
             } else if (!strcmp(buff, "NOCOMMENT_START")) {
                 state = sNOCOMMENT;
-            } else {
-                Line *line = (Line *)xcalloc(1, sizeof(Line));
-                line->data = xstrdup(buff);
-                line->next = curr->doc;
-                curr->doc = line;
+            } else { // if (buff != NULL) {
+                assert(buff != NULL);
+                entries.back().doc.push_back(buff);
             }
-
             break;
 
         case sNOCOMMENT:
-
             if (!strcmp(buff, "NOCOMMENT_END")) {
-                Line *head = NULL;
-                Line *line = curr->nocomment;
-                /* reverse order of lines */
-
-                while (line != NULL) {
-                    Line *tmp;
-                    tmp = line->next;
-                    line->next = head;
-                    head = line;
-                    line = tmp;
-                }
-
-                curr->nocomment = head;
                 state = sDOC;
-            } else {
-                Line *line = (Line *)xcalloc(1, sizeof(Line));
-                line->data = xstrdup(buff);
-                line->next = curr->nocomment;
-                curr->nocomment = line;
+            } else { // if (buff != NULL) {
+                assert(buff != NULL);
+                entries.back().nocomment.push_back(buff);
             }
-
             break;
 
         case sEXIT:
             assert(0);		/* should never get here */
             break;
         }
+
     }
 
     if (state != sEXIT) {
-        printf("Error unexpected EOF\n");
+        std::cerr << "Error: unexpected EOF\n";
         exit(1);
-    } else {
-        /* reverse order of entries */
-        Entry *head = NULL;
-
-        while (entries != NULL) {
-            Entry *tmp;
-
-            tmp = entries->next;
-            entries->next = head;
-            head = entries;
-            entries = tmp;
-        }
-
-        entries = head;
     }
 
-    fclose(fp);
+    fp.close();
 
     /*-------------------------------------------------------------------*
      * Generate default_all()
@@ -457,434 +404,385 @@
 
     /* Open output x.c file */
 
-    if ((fp = fopen(output_filename, "w")) == NULL) {
-        perror(output_filename);
+    std::ofstream fout(output_filename,std::ostream::out);
+    if (!fout.good()) {
+        std::cerr << "error while opening output .c file '" <<
+                  output_filename << "': " << strerror(errno) << std::endl;
         exit(1);
     }
 
-#ifdef _SQUID_WIN32_
-    setmode(fileno(fp), O_TEXT);
+    fout <<  "/*\n" <<
+    " * Generated automatically from " << input_filename << " by " <<
+    argv[0] << "\n"
+    " *\n"
+    " * Abstract: This file contains routines used to configure the\n"
+    " *           variables in the squid server.\n"
+    " */\n"
+    "\n";
 
-#endif
+    rc = gen_default(entries, fout);
 
-    fprintf(fp,
-            "/*\n"
-            " * Generated automatically from %s by %s\n"
-            " *\n"
-            " * Abstract: This file contains routines used to configure the\n"
-            " *           variables in the squid server.\n"
-            " */\n"
-            "\n"
-            "#include \"config.h\"\n"
-            "\n",
-            input_filename, argv[0]
-           );
-
-    rc = gen_default(entries, fp);
-
-    gen_default_if_none(entries, fp);
+    gen_default_if_none(entries, fout);
 
-    gen_parse(entries, fp);
+    gen_parse(entries, fout);
 
-    gen_dump(entries, fp);
+    gen_dump(entries, fout);
 
-    gen_free(entries, fp);
+    gen_free(entries, fout);
 
-    fclose(fp);
+    fout.close();
 
     /* Open output x.conf file */
-    if ((fp = fopen(conf_filename, "w")) == NULL) {
-        perror(conf_filename);
+    fout.open(conf_filename,std::ostream::out);
+    if (!fout.good()) {
+        std::cerr << "error while opening output conf file '" <<
+                  output_filename << "': " << strerror(errno) << std::endl;
         exit(1);
     }
 
-#ifdef _SQUID_WIN32_
-    setmode(fileno(fp), O_TEXT);
-
-#endif
-
-    gen_conf(entries, fp, 1);
+    gen_conf(entries, fout, 1);
 
-    fclose(fp);
+    fout.close();
 
-    if ((fp = fopen(conf_filename_short, "w")) == NULL) {
-        perror(conf_filename_short);
+    fout.open(conf_filename_short,std::ostream::out);
+    if (!fout.good()) {
+        std::cerr << "error while opening output short conf file '" <<
+                  output_filename << "': " << strerror(errno) << std::endl;
         exit(1);
     }
-#ifdef _SQUID_WIN32_
-    setmode(fileno(fp), O_TEXT);
-#endif
-    gen_conf(entries, fp, 0);
-    fclose(fp);
+    gen_conf(entries, fout, 0);
+    fout.close();
 
     return (rc);
 }
 
 static int
-gen_default(Entry * head, FILE * fp)
+gen_default(const EntryList &head, std::ostream &fout)
 {
-    Entry *entry;
     int rc = 0;
-    fprintf(fp,
-            "static void\n"
-            "default_line(const char *s)\n"
-            "{\n"
-            "\tLOCAL_ARRAY(char, tmp_line, BUFSIZ);\n"
-            "\txstrncpy(tmp_line, s, BUFSIZ);\n"
-            "\txstrncpy(config_input_line, s, BUFSIZ);\n"
-            "\tconfig_lineno++;\n"
-            "\tparse_line(tmp_line);\n"
-            "}\n"
-           );
-    fprintf(fp,
-            "static void\n"
-            "default_all(void)\n"
-            "{\n"
-            "\tcfg_filename = \"Default Configuration\";\n"
-            "\tconfig_lineno = 0;\n"
-           );
-
-    for (entry = head; entry != NULL; entry = entry->next) {
-        assert(entry->name);
-        assert(entry != entry->next);
+    fout << "static void" << std::endl <<
+    "default_line(const char *s)" << std::endl <<
+    "{" << std::endl <<
+    "    LOCAL_ARRAY(char, tmp_line, BUFSIZ);" << std::endl <<
+    "    xstrncpy(tmp_line, s, BUFSIZ);" << std::endl <<
+    "    xstrncpy(config_input_line, s, BUFSIZ);" << std::endl <<
+    "    config_lineno++;" << std::endl <<
+    "    parse_line(tmp_line);" << std::endl <<
+    "}" << std::endl << std::endl;
+    fout << "static void" << std::endl <<
+    "default_all(void)" << std::endl <<
+    "{" << std::endl <<
+    "    cfg_filename = \"Default Configuration\";" << std::endl <<
+    "    config_lineno = 0;" << std::endl;
+
+    for (EntryList::const_iterator entry = head.begin(); entry != head.end(); ++entry) {
+        assert(entry->name.size());
 
-        if (!strcmp(entry->name, "comment"))
+        if (!entry->name.compare("comment"))
             continue;
 
-        if (!strcmp(entry->type, "obsolete"))
+        if (!entry->type.compare("obsolete"))
             continue;
 
-        if (entry->loc == NULL) {
-            fprintf(stderr, "NO LOCATION FOR %s\n", entry->name);
+        if (!entry->loc.size()) {
+            std::cerr << "NO LOCATION FOR " << entry->name << std::endl;
             rc |= 1;
             continue;
         }
 
-        if (entry->default_value == NULL && entry->default_if_none == NULL) {
-            fprintf(stderr, "NO DEFAULT FOR %s\n", entry->name);
+        if (!entry->defaults.preset.size() && entry->defaults.if_none.empty()) {
+            std::cerr << "NO DEFAULT FOR " << entry->name << std::endl;
             rc |= 1;
             continue;
         }
 
-        if (entry->default_value == NULL || strcmp(entry->default_value, "none") == 0) {
-            fprintf(fp, "\t/* No default for %s */\n", entry->name);
+        if (!entry->defaults.preset.size() || entry->defaults.preset.front().compare("none") == 0) {
+            fout << "    // No default for " << entry->name << std::endl;
         } else {
-            if (entry->ifdef)
-                fprintf(fp, "#if %s\n", entry->ifdef);
+            if (entry->ifdef.size())
+                fout << "#if " << entry->ifdef << std::endl;
 
-            fprintf(fp, "\tdefault_line(\"%s %s\");\n",
-                    entry->name,
-                    entry->default_value);
+            for (LineList::const_iterator l = entry->defaults.preset.begin(); l != entry->defaults.preset.end(); ++l) {
+                fout << "    default_line(\"" << entry->name << " " << *l << "\");" << std::endl;
+            }
 
-            if (entry->ifdef)
-                fprintf(fp, "#endif\n");
+            if (entry->ifdef.size())
+                fout << "#endif" << std::endl;
         }
     }
 
-    fprintf(fp, "\tcfg_filename = NULL;\n");
-    fprintf(fp, "}\n\n");
+    fout << "    cfg_filename = NULL;" << std::endl <<
+    "}" << std::endl << std::endl;
     return rc;
 }
 
 static void
-gen_default_if_none(Entry * head, FILE * fp)
+gen_default_if_none(const EntryList &head, std::ostream &fout)
 {
-    Entry *entry;
-    Line *line;
-    fprintf(fp,
-            "static void\n"
-            "defaults_if_none(void)\n"
-            "{\n"
-           );
+    fout << "static void" << std::endl <<
+    "defaults_if_none(void)" << std::endl <<
+    "{" << std::endl;
 
-    for (entry = head; entry != NULL; entry = entry->next) {
-        assert(entry->name);
+    for (EntryList::const_iterator entry = head.begin(); entry != head.end(); ++entry) {
+        assert(entry->name.size());
 
-        if (!entry->loc)
+        if (!entry->loc.size())
             continue;
 
-        if (entry->default_if_none == NULL)
+        if (entry->defaults.if_none.empty())
             continue;
 
-        if (entry->ifdef)
-            fprintf(fp, "#if %s\n", entry->ifdef);
-
-        if (entry->default_if_none) {
-            fprintf(fp,
-                    "\tif (check_null_%s(%s)) {\n",
-                    entry->type,
-                    entry->loc);
+        if (!entry->defaults.preset.empty()) {
+            std::cerr << "ERROR: " << entry->name << " has preset defaults. DEFAULT_IF_NONE cannot be true." << std::endl;
+            exit(1);
+        }
 
-            for (line = entry->default_if_none; line; line = line->next)
-                fprintf(fp,
-                        "\t\tdefault_line(\"%s %s\");\n",
-                        entry->name,
-                        line->data);
+        if (entry->ifdef.size())
+            fout << "#if " << entry->ifdef << std::endl;
 
-            fprintf(fp, "\t}\n");
-        }
+        fout << "    if (check_null_" << entry->type << "(" << entry->loc << ")) {" << std::endl;
+        for (LineList::const_iterator l = entry->defaults.if_none.begin(); l != entry->defaults.if_none.end(); ++l)
+            fout << "        default_line(\"" << entry->name << " " << *l <<"\");" << std::endl;
+        fout << "    }" << std::endl;
 
-        if (entry->ifdef)
-            fprintf(fp, "#endif\n");
+        if (entry->ifdef.size())
+            fout << "#endif" << std::endl;
     }
 
-    fprintf(fp, "}\n\n");
+    fout << "}" << std::endl << std::endl;
 }
 
 void
-gen_parse_alias(char *name, EntryAlias *alias, Entry *entry, FILE *fp)
+Entry::genParseAlias(const std::string &aName, std::ostream &fout) const
 {
-    fprintf(fp, "\tif (!strcmp(token, \"%s\")) {\n", name);
-
-    if (strcmp(entry->type,"obsolete") == 0) {
-        fprintf(fp, "\t\tdebugs(0, DBG_CRITICAL, \"ERROR: Directive '%s' is obsolete.\");\n", name);
-        for (Line *line = entry->doc; line != NULL; line = line->next) {
+    fout << "    if (!strcmp(token, \"" << aName << "\")) {" << std::endl;
+    fout << "        ";
+    if (type.compare("obsolete") == 0) {
+        fout << "debugs(0, DBG_CRITICAL, \"ERROR: Directive '" << aName << "' is obsolete.\");\n";
+        for (LineList::const_iterator l = doc.begin(); l != doc.end(); ++l) {
             // offset line to strip initial whitespace tab byte
-            fprintf(fp, "\t\tdebugs(0, opt_parse_cfg_only?0:1, \"%s : %s\");\n", name, &line->data[1]);
+            fout << "        debugs(0, opt_parse_cfg_only?0:1, \"" << aName << " : " << &(*l)[1] << "\");" << std::endl;
         }
-        fprintf(fp, "\t\tparse_obsolete(token);\n");
-    } else if (!entry->loc || strcmp(entry->loc, "none") == 0) {
-        fprintf(fp,
-                "\t\tparse_%s();\n",
-                entry->type
-               );
+        fout << "        parse_obsolete(token);";
+    } else if (!loc.size() || loc.compare("none") == 0) {
+        fout << "parse_" << type << "();";
     } else {
-        fprintf(fp,
-                "\t\tparse_%s(&%s%s);\n",
-                entry->type, entry->loc,
-                entry->array_flag ? "[0]" : ""
-               );
+        fout << "parse_" << type << "(&" << loc << (array_flag ? "[0]" : "") << ");";
     }
-
-    fprintf(fp,"\t\treturn 1;\n");
-    fprintf(fp,"\t};\n");
+    fout << std::endl;
+    fout << "        return 1;" << std::endl;
+    fout << "    };" << std::endl;
 }
 
 void
-gen_parse_entry(Entry *entry, FILE *fp)
+Entry::genParse(std::ostream &fout) const
 {
-    if (strcmp(entry->name, "comment") == 0)
+    if (name.compare("comment") == 0)
         return;
 
-    if (entry->ifdef)
-        fprintf(fp, "#if %s\n", entry->ifdef);
-
-    char *name = entry->name;
-
-    EntryAlias *alias = entry->alias;
+    if (ifdef.size())
+        fout << "#if " << ifdef << std::endl;
 
-    bool more;
+    // Once for the current directive name
+    genParseAlias(name, fout);
 
-    do {
-        gen_parse_alias (name, alias,entry, fp);
-        more = false;
-
-        if (alias) {
-            name = alias->name;
-            alias = alias->next;
-            more = true;
-        }
-    } while (more);
+    // All accepted aliases
+    for (EntryAliasList::const_iterator a = alias.begin(); a != alias.end(); ++a) {
+        genParseAlias(*a, fout);
+    }
 
-    if (entry->ifdef)
-        fprintf(fp, "#endif\n");
+    if (ifdef.size())
+        fout << "#endif\n";
 }
 
 static void
-gen_parse(Entry * head, FILE * fp)
+gen_parse(const EntryList &head, std::ostream &fout)
 {
-    fprintf(fp,
-            "static int\n"
-            "parse_line(char *buff)\n"
-            "{\n"
-            "\tchar\t*token;\n"
-            "\tdebugs(0, 10, \"parse_line: \" << buff << \"\\n\" );\n"
-            "\tif ((token = strtok(buff, w_space)) == NULL) \n"
-            "\t\treturn 1;\t/* ignore empty lines */\n"
-           );
-
-    for (Entry *entry = head; entry != NULL; entry = entry->next)
-        gen_parse_entry (entry, fp);
-
-    fprintf(fp,
-            "\treturn 0; /* failure */\n"
-            "}\n\n"
-           );
+    fout <<
+    "static int\n"
+    "parse_line(char *buff)\n"
+    "{\n"
+    "\tchar\t*token;\n"
+    "\tif ((token = strtok(buff, w_space)) == NULL) \n"
+    "\t\treturn 1;\t/* ignore empty lines */\n";
+
+    for (EntryList::const_iterator e = head.begin(); e != head.end(); ++e)
+        e->genParse(fout);
+
+    fout << "\treturn 0; /* failure */\n"
+    "}\n\n";
+
 }
 
 static void
-gen_dump(Entry * head, FILE * fp)
+gen_dump(const EntryList &head, std::ostream &fout)
 {
-    Entry *entry;
-    fprintf(fp,
-            "static void\n"
-            "dump_config(StoreEntry *entry)\n"
-            "{\n"
-           );
+    fout <<
+    "static void" << std::endl <<
+    "dump_config(StoreEntry *entry)" << std::endl <<
+    "{" << std::endl <<
+    "    debugs(5, 4, HERE);" << std::endl;
 
-    for (entry = head; entry != NULL; entry = entry->next) {
+    for (EntryList::const_iterator e = head.begin(); e != head.end(); ++e) {
 
-        if (!entry->loc || strcmp(entry->loc, "none") == 0)
+        if (!e->loc.size() || e->loc.compare("none") == 0)
             continue;
 
-        if (strcmp(entry->name, "comment") == 0)
+        if (e->name.compare("comment") == 0)
             continue;
 
-        if (entry->ifdef)
-            fprintf(fp, "#if %s\n", entry->ifdef);
+        if (e->ifdef.size())
+            fout << "#if " << e->ifdef << std::endl;
 
-        fprintf(fp, "\tdump_%s(entry, \"%s\", %s);\n",
-                entry->type,
-                entry->name,
-                entry->loc);
+        fout << "    dump_" << e->type << "(entry, \"" << e->name << "\", " << e->loc << ");" << std::endl;
 
-        if (entry->ifdef)
-            fprintf(fp, "#endif\n");
+        if (e->ifdef.size())
+            fout << "#endif" << std::endl;
     }
 
-    fprintf(fp, "}\n\n");
+    fout << "}" << std::endl << std::endl;
 }
 
 static void
-gen_free(Entry * head, FILE * fp)
+gen_free(const EntryList &head, std::ostream &fout)
 {
-    Entry *entry;
-    fprintf(fp,
-            "static void\n"
-            "free_all(void)\n"
-            "{\n"
-           );
+    fout <<
+    "static void" << std::endl <<
+    "free_all(void)" << std::endl <<
+    "{" << std::endl <<
+    "    debugs(5, 4, HERE);" << std::endl;
 
-    for (entry = head; entry != NULL; entry = entry->next) {
-        if (!entry->loc || strcmp(entry->loc, "none") == 0)
+    for (EntryList::const_iterator e = head.begin(); e != head.end(); ++e) {
+        if (!e->loc.size() || e->loc.compare("none") == 0)
             continue;
 
-        if (strcmp(entry->name, "comment") == 0)
+        if (e->name.compare("comment") == 0)
             continue;
 
-        if (entry->ifdef)
-            fprintf(fp, "#if %s\n", entry->ifdef);
+        if (e->ifdef.size())
+            fout << "#if " << e->ifdef << std::endl;
 
-        fprintf(fp, "\tfree_%s(&%s%s);\n",
-                entry->type, entry->loc,
-                entry->array_flag ? "[0]" : "");
+        fout << "    free_" << e->type << "(&" << e->loc << (e->array_flag ? "[0]" : "") << ");" << std::endl;
 
-        if (entry->ifdef)
-            fprintf(fp, "#endif\n");
+        if (e->ifdef.size())
+            fout << "#endif" << std::endl;
     }
 
-    fprintf(fp, "}\n\n");
+    fout << "}" << std::endl << std::endl;
 }
 
-static int
-defined(char *name)
+static bool
+isDefined(const std::string &name)
 {
-    int i = 0;
-
-    if (!name)
-        return 1;
+    if (!name.size())
+        return true;
 
-    for (i = 0; strcmp(defines[i].name, name) != 0; i++) {
-        assert(defines[i].name);
+    for (int i = 0; defines[i].name; i++) {
+        if (name.compare(defines[i].name) == 0)
+            return defines[i].defined;
     }
 
-    return defines[i].defined;
+    return false;
 }
 
 static const char *
-available_if(char *name)
+available_if(const std::string &name)
 {
-    int i = 0;
-    assert(name);
+    assert(name.size());
 
-    for (i = 0; strcmp(defines[i].name, name) != 0; i++) {
-        assert(defines[i].name);
+    for (int i = 0; defines[i].name; i++) {
+        if (name.compare(defines[i].name) == 0)
+            return defines[i].enable;
     }
 
-    return defines[i].enable;
+    return name.c_str();
 }
 
 static void
-gen_conf(Entry * head, FILE * fp, bool verbose_output)
+gen_conf(const EntryList &head, std::ostream &fout, bool verbose_output)
 {
-    Entry *entry;
-    char buf[8192];
-    Line *def = NULL;
-
-    for (entry = head; entry != NULL; entry = entry->next) {
-        Line *line;
+    for (EntryList::const_iterator entry = head.begin(); entry != head.end(); ++entry) {
+        char buf[8192];
+        LineList def;
         int enabled = 1;
 
-        if (!strcmp(entry->name, "comment"))
+        // Display TAG: line
+        if (!entry->name.compare("comment"))
             (void) 0;
-        else if (!strcmp(entry->name, "obsolete"))
+        else if (!entry->name.compare("obsolete"))
             (void) 0;
         else if (verbose_output) {
-            fprintf(fp, "#  TAG: %s", entry->name);
+            fout << "#  TAG: " << entry->name;
 
-            if (entry->comment)
-                fprintf(fp, "\t%s", entry->comment);
+            if (entry->comment.size())
+                fout << "\t" << entry->comment;
 
-            fprintf(fp, "\n");
+            fout << std::endl;
         }
 
-        if (!defined(entry->ifdef)) {
+        // Display --enable/--disable disclaimer
+        if (!isDefined(entry->ifdef)) {
             if (verbose_output) {
-                fprintf(fp, "# Note: This option is only available if Squid is rebuilt with the\n");
-                fprintf(fp, "#       %s\n#\n", available_if(entry->ifdef));
+                fout << "# Note: This option is only available if Squid is rebuilt with the" << std::endl <<
+                "#       " << available_if(entry->ifdef) << std::endl <<
+                "#" << std::endl;
             }
             enabled = 0;
         }
 
-        if (verbose_output) {
-            for (line = entry->doc; line != NULL; line = line->next) {
-                fprintf(fp, "#%s\n", line->data);
+        // Display DOC_START section
+        if (verbose_output && entry->doc.size()) {
+            for (LineList::const_iterator line = entry->doc.begin(); line != entry->doc.end(); ++line) {
+                fout << "#" << *line << std::endl;
             }
         }
 
-        if (entry->default_value && strcmp(entry->default_value, "none") != 0) {
-            snprintf(buf, sizeof(buf), "%s %s", entry->name, entry->default_value);
-            lineAdd(&def, buf);
-        }
-
-        if (entry->default_if_none) {
-            for (line = entry->default_if_none; line; line = line->next) {
-                snprintf(buf, sizeof(buf), "%s %s", entry->name, line->data);
-                lineAdd(&def, buf);
+        if (entry->defaults.docs.size()) {
+            // Display the DEFAULT_DOC line(s)
+            def = entry->defaults.docs;
+        } else {
+            if (entry->defaults.preset.size() && entry->defaults.preset.front().compare("none") != 0) {
+                // Display DEFAULT: line(s)
+                for (LineList::const_iterator l = entry->defaults.preset.begin(); l != entry->defaults.preset.end(); ++l) {
+                    snprintf(buf, sizeof(buf), "%s %s", entry->name.c_str(), l->c_str());
+                    def.push_back(buf);
+                }
+            } else if (entry->defaults.if_none.size()) {
+                // Display DEFAULT_IF_NONE: line(s)
+                for (LineList::const_iterator l = entry->defaults.if_none.begin(); l != entry->defaults.if_none.end(); ++l) {
+                    snprintf(buf, sizeof(buf), "%s %s", entry->name.c_str(), l->c_str());
+                    def.push_back(buf);
+                }
             }
         }
 
-        if (!def && entry->doc && !entry->nocomment &&
-                strcmp(entry->name, "comment") != 0)
-            lineAdd(&def, "none");
-
-        if (verbose_output && def && (entry->doc || entry->nocomment)) {
-            fprintf(fp, "#Default:\n");
-            while (def != NULL) {
-                line = def;
-                def = line->next;
-                fprintf(fp, "# %s\n", line->data);
-                xfree(line->data);
-                xfree(line);
+        // Display "none" if no default is set or comments to display
+        if (def.empty() && entry->nocomment.empty() && entry->name.compare("comment") != 0)
+            def.push_back("none");
+
+        if (verbose_output && def.size()) {
+            fout << "#Default:\n";
+            while (def.size()) {
+                fout << "# " << def.front() << std::endl;
+                def.pop_front();
             }
+            if (entry->doc.empty() && entry->nocomment.empty())
+                fout << std::endl;
         }
 
-        if (verbose_output && entry->nocomment)
-            fprintf(fp, "#\n");
+        if (verbose_output && entry->nocomment.size())
+            fout << "#" << std::endl;
 
         if (enabled || verbose_output) {
-            for (line = entry->nocomment; line != NULL; line = line->next) {
-                if (!line->data)
-                    continue;
-                if (!enabled && line->data[0] != '#')
-                    fprintf(fp, "#%s\n", line->data);
-                else
-                    fprintf(fp, "%s\n", line->data);
+            for (LineList::const_iterator line = entry->nocomment.begin(); line != entry->nocomment.end(); ++line) {
+                if (!enabled && line->at(0) != '#')
+                    fout << "#";
+                fout << *line << std::endl;
             }
         }
 
-        if (verbose_output && entry->doc != NULL) {
-            fprintf(fp, "\n");
+        if (verbose_output && entry->doc.size()) {
+            fout << std::endl;
         }
     }
 }
diff -u -r -N squid-3.1.14/src/cf_gen_defines squid-3.1.15/src/cf_gen_defines
--- squid-3.1.14/src/cf_gen_defines	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/src/cf_gen_defines	2011-08-28 19:53:14.000000000 +1200
@@ -3,7 +3,7 @@
 	print "/* Generated automatically from cf.data.pre"
 	print " * DO NOT EDIT"
 	print "*/"
-	print "#include \"config.h\""
+	print "#include \"autoconf.h\""
 	print "static struct { const char *name; const char *enable; int defined;} defines[] = {"
 	define["DELAY_POOLS"]="--enable-delay-pools"
 	define["FOLLOW_X_FORWARDED_FOR"]="--enable-follow-x-forwarded-for"
diff -u -r -N squid-3.1.14/src/client_side.cc squid-3.1.15/src/client_side.cc
--- squid-3.1.14/src/client_side.cc	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/src/client_side.cc	2011-08-28 19:53:14.000000000 +1200
@@ -1874,9 +1874,26 @@
         return;
     }
 
+    if (vport < 0)
+        vport = http->getConn()->me.GetPort();
+
     const bool switchedToHttps = conn->switchedToHttps();
     const bool tryHostHeader = vhost || switchedToHttps;
     if (tryHostHeader && (host = mime_get_header(req_hdr, "Host")) != NULL) {
+        debugs(33, 5, "ACCEL VHOST REWRITE: vhost=" << host << " + vport=" << vport);
+        char thost[256];
+        if (vport > 0) {
+            thost[0] = '\0';
+            char *t = NULL;
+            if (host[strlen(host)] != ']' && (t = strrchr(host,':')) != NULL) {
+                strncpy(thost, host, (t-host));
+                snprintf(thost+(t-host), sizeof(thost)-(t-host), ":%d", vport);
+                host = thost;
+            } else if (!t) {
+                snprintf(thost, sizeof(thost), "%s:%d",host, vport);
+                host = thost;
+            }
+        } // else nothing to alter port-wise.
         int url_sz = strlen(url) + 32 + Config.appendDomainLen +
                      strlen(host);
         http->uri = (char *)xcalloc(url_sz, 1);
@@ -1884,24 +1901,22 @@
                                "https" : conn->port->protocol;
         snprintf(http->uri, url_sz, "%s://%s%s", protocol, host, url);
         debugs(33, 5, "ACCEL VHOST REWRITE: '" << http->uri << "'");
-    } else if (conn->port->defaultsite) {
+    } else if (conn->port->defaultsite /* && !vhost */) {
+        debugs(33, 5, "ACCEL DEFAULTSITE REWRITE: defaultsite=" << conn->port->defaultsite << " + vport=" << vport);
         int url_sz = strlen(url) + 32 + Config.appendDomainLen +
                      strlen(conn->port->defaultsite);
         http->uri = (char *)xcalloc(url_sz, 1);
-        snprintf(http->uri, url_sz, "%s://%s%s",
-                 conn->port->protocol, conn->port->defaultsite, url);
+        char vportStr[32];
+        vportStr[0] = '\0';
+        if (vport > 0) {
+            snprintf(vportStr, sizeof(vportStr),":%d",vport);
+        }
+        snprintf(http->uri, url_sz, "%s://%s%s%s",
+                 conn->port->protocol, conn->port->defaultsite, vportStr, url);
         debugs(33, 5, "ACCEL DEFAULTSITE REWRITE: '" << http->uri <<"'");
-    } else if (vport == -1) {
-        /* Put the local socket IP address as the hostname.  */
-        int url_sz = strlen(url) + 32 + Config.appendDomainLen;
-        http->uri = (char *)xcalloc(url_sz, 1);
-        http->getConn()->me.ToHostname(ipbuf,MAX_IPSTRLEN);
-        snprintf(http->uri, url_sz, "%s://%s:%d%s",
-                 http->getConn()->port->protocol,
-                 ipbuf, http->getConn()->me.GetPort(), url);
-        debugs(33, 5, "ACCEL VPORT REWRITE: '" << http->uri << "'");
-    } else if (vport > 0) {
-        /* Put the local socket IP address as the hostname, but static port  */
+    } else if (vport > 0 /* && (!vhost || no Host:) */) {
+        debugs(33, 5, "ACCEL VPORT REWRITE: http_port IP + vport=" << vport);
+        /* Put the local socket IP address as the hostname, with whatever vport we found  */
         int url_sz = strlen(url) + 32 + Config.appendDomainLen;
         http->uri = (char *)xcalloc(url_sz, 1);
         http->getConn()->me.ToHostname(ipbuf,MAX_IPSTRLEN);
@@ -2140,6 +2155,7 @@
 
 #endif
 
+    debugs(33,5, HERE << "repare absolute URL from " << (conn->transparent()?"intercept":(conn->port->accel ? "accel":"")));
     /* Rewrite the URL in transparent or accelerator mode */
     /* NP: there are several cases to traverse here:
      *  - standard mode (forward proxy)
@@ -2935,6 +2951,10 @@
     if (!handleRequestBodyData())
         return;
 
+    // too late to read more body
+    if (!isOpen() || closing())
+        return;
+
     readSomeData();
 }
 
diff -u -r -N squid-3.1.14/src/client_side_request.cc squid-3.1.15/src/client_side_request.cc
--- squid-3.1.14/src/client_side_request.cc	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/src/client_side_request.cc	2011-08-28 19:53:14.000000000 +1200
@@ -637,7 +637,7 @@
                                     NULL,
                                     http->getConn() != NULL && http->getConn()->auth_user_request ?
                                     http->getConn()->auth_user_request : http->request->auth_user_request);
-
+        http->getConn()->flags.readMoreRequests = true; // resume any pipeline reads.
         node = (clientStreamNode *)http->client_stream.tail->data;
         clientStreamRead(node, http, node->readBuffer);
         return;
@@ -1558,7 +1558,7 @@
                                 (c != NULL ? c->peer : noAddr), request, NULL,
                                 (c != NULL && c->auth_user_request ?
                                  c->auth_user_request : request->auth_user_request));
-
+    c->flags.readMoreRequests = true;
     node = (clientStreamNode *)client_stream.tail->data;
     clientStreamRead(node, this, node->readBuffer);
 }
diff -u -r -N squid-3.1.14/src/comm.cc squid-3.1.15/src/comm.cc
--- squid-3.1.14/src/comm.cc	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/src/comm.cc	2011-08-28 19:53:14.000000000 +1200
@@ -207,7 +207,7 @@
 
 // defaults given by client
     char *host;
-    u_short default_port;
+    unsigned short default_port;
     IpAddress default_addr;
     // NP: CANNOT store the default addr:port together as it gets set/reset differently.
 
@@ -546,7 +546,7 @@
  */
 
 /* Return the local port associated with fd. */
-u_short
+unsigned short
 comm_local_port(int fd)
 {
     IpAddress temp;
@@ -794,7 +794,7 @@
     if ((flags & COMM_REUSEADDR))
         commSetReuseAddr(new_socket);
 
-    if (addr.GetPort() > (u_short) 0) {
+    if (addr.GetPort() > (unsigned short) 0) {
 #ifdef _SQUID_MSWIN_
         if (sock_type != SOCK_DGRAM)
 #endif
@@ -863,7 +863,7 @@
 
 
 void
-commConnectStart(int fd, const char *host, u_short port, AsyncCall::Pointer &cb)
+commConnectStart(int fd, const char *host, unsigned short port, AsyncCall::Pointer &cb)
 {
     debugs(cb->debugSection, cb->debugLevel, "commConnectStart: FD " << fd <<
            ", cb " << cb << ", " << host << ":" << port); // TODO: just print *cb
@@ -884,7 +884,7 @@
 // a generic call name and debug level when creating an AsyncCall. This will
 // also cut the number of callback registration routines in half.
 void
-commConnectStart(int fd, const char *host, u_short port, CNCB * callback, void *data)
+commConnectStart(int fd, const char *host, unsigned short port, CNCB * callback, void *data)
 {
     debugs(5, 5, "commConnectStart: FD " << fd << ", data " << data << ", " << host << ":" << port);
     AsyncCall::Pointer call = commCbCall(5,3,
diff -u -r -N squid-3.1.14/src/comm.h squid-3.1.15/src/comm.h
--- squid-3.1.14/src/comm.h	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/src/comm.h	2011-08-28 19:53:14.000000000 +1200
@@ -46,8 +46,8 @@
 #if LINGERING_CLOSE
 SQUIDCEXTERN void comm_lingering_close(int fd);
 #endif
-SQUIDCEXTERN void commConnectStart(int fd, const char *, u_short, CNCB *, void *);
-void commConnectStart(int fd, const char *, u_short, AsyncCall::Pointer &cb);
+SQUIDCEXTERN void commConnectStart(int fd, const char *, unsigned short, CNCB *, void *);
+void commConnectStart(int fd, const char *, unsigned short, AsyncCall::Pointer &cb);
 
 SQUIDCEXTERN int comm_connect_addr(int sock, const IpAddress &addr);
 SQUIDCEXTERN void comm_init(void);
@@ -73,7 +73,7 @@
 SQUIDCEXTERN int comm_open_listener(int sock_type, int proto, IpAddress &addr, int flags, const char *note);
 
 SQUIDCEXTERN int comm_openex(int, int, IpAddress &, int, unsigned char TOS, const char *);
-SQUIDCEXTERN u_short comm_local_port(int fd);
+SQUIDCEXTERN unsigned short comm_local_port(int fd);
 SQUIDCEXTERN int comm_set_tos(int fd, int tos);
 
 SQUIDCEXTERN void commSetSelect(int, unsigned int, PF *, void *, time_t);
diff -u -r -N squid-3.1.14/src/ConfigParser.h squid-3.1.15/src/ConfigParser.h
--- squid-3.1.14/src/ConfigParser.h	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/src/ConfigParser.h	2011-08-28 19:53:14.000000000 +1200
@@ -63,7 +63,7 @@
 
 public:
     void destruct();
-    static void ParseUShort(u_short *var);
+    static void ParseUShort(unsigned short *var);
     static void ParseBool(bool *var);
     static void ParseString(char **var);
     static void ParseString(String *var);
diff -u -r -N squid-3.1.14/src/defines.h squid-3.1.15/src/defines.h
--- squid-3.1.14/src/defines.h	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/src/defines.h	2011-08-28 19:53:14.000000000 +1200
@@ -205,8 +205,8 @@
 #define SwapMetaType(x) (char)x[0]
 #define SwapMetaSize(x) &x[sizeof(char)]
 #define SwapMetaData(x) &x[STORE_META_TLD_START]
-#define STORE_HDR_METASIZE (4*sizeof(time_t)+2*sizeof(u_short)+sizeof(uint64_t))
-#define STORE_HDR_METASIZE_OLD (4*sizeof(time_t)+2*sizeof(u_short)+sizeof(size_t))
+#define STORE_HDR_METASIZE (4*sizeof(time_t)+2*sizeof(uint16_t)+sizeof(uint64_t))
+#define STORE_HDR_METASIZE_OLD (4*sizeof(time_t)+2*sizeof(uint16_t)+sizeof(size_t))
 
 #define COUNT_INTERVAL 60
 /*
diff -u -r -N squid-3.1.14/src/DelayConfig.cc squid-3.1.15/src/DelayConfig.cc
--- squid-3.1.14/src/DelayConfig.cc	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/src/DelayConfig.cc	2011-08-28 19:53:14.000000000 +1200
@@ -52,7 +52,7 @@
 void
 DelayConfig::parsePoolCount()
 {
-    u_short pools_;
+    unsigned short pools_;
     ConfigParser::ParseUShort(&pools_);
     DelayPools::pools(pools_);
 }
@@ -60,7 +60,7 @@
 void
 DelayConfig::parsePoolClass()
 {
-    ushort pool;
+    unsigned short pool;
 
     ConfigParser::ParseUShort(&pool);
 
@@ -69,7 +69,7 @@
         return;
     }
 
-    ushort delay_class_;
+    unsigned short delay_class_;
     ConfigParser::ParseUShort(&delay_class_);
 
     if (delay_class_ < 1 || delay_class_ > 5) {
@@ -85,7 +85,7 @@
 void
 DelayConfig::parsePoolRates()
 {
-    ushort pool;
+    unsigned short pool;
     ConfigParser::ParseUShort(&pool);
 
     if (pool < 1 || pool > DelayPools::pools()) {
@@ -106,7 +106,7 @@
 void
 DelayConfig::parsePoolAccess(ConfigParser &parser)
 {
-    ushort pool;
+    unsigned short pool;
 
     ConfigParser::ParseUShort(&pool);
 
diff -u -r -N squid-3.1.14/src/delay_pools.cc squid-3.1.15/src/delay_pools.cc
--- squid-3.1.14/src/delay_pools.cc	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/src/delay_pools.cc	2011-08-28 19:53:14.000000000 +1200
@@ -667,7 +667,7 @@
 }
 
 void
-DelayPools::pools (u_short newPools)
+DelayPools::pools(unsigned short newPools)
 {
     if (pools()) {
         debugs(3, 0, "parse_delay_pool_count: multiple delay_pools lines, aborting all previous delay_pools config");
diff -u -r -N squid-3.1.14/src/DelayPools.h squid-3.1.15/src/DelayPools.h
--- squid-3.1.14/src/DelayPools.h	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/src/DelayPools.h	2011-08-28 19:53:14.000000000 +1200
@@ -65,7 +65,7 @@
     static void Init();
     static void Update(void *);
     static unsigned short pools();
-    static void pools (u_short pools);
+    static void pools(unsigned short pools);
     static void FreePools();
     static unsigned char *DelayClasses();
     static void registerForUpdates(Updateable *);
diff -u -r -N squid-3.1.14/src/dns_internal.cc squid-3.1.15/src/dns_internal.cc
--- squid-3.1.14/src/dns_internal.cc	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/src/dns_internal.cc	2011-08-28 19:53:14.000000000 +1200
@@ -1386,7 +1386,7 @@
         IpAddress addrB = addrA;
         addrA.SetIPv4();
 
-        if (Ip::EnableIpv6 && (addrB.IsAnyAddr() || addrB.IsIPv6())) {
+        if (Ip::EnableIpv6 && addrB.IsIPv6()) {
             debugs(78, 2, "idnsInit: attempt open DNS socket to: " << addrB);
             DnsSocketB = comm_open_listener(SOCK_DGRAM,
                                             IPPROTO_UDP,
@@ -1395,7 +1395,7 @@
                                             "DNS Socket IPv6");
         }
 
-        if (addrA.IsAnyAddr() || addrA.IsIPv4()) {
+        if (addrA.IsIPv4()) {
             debugs(78, 2, "idnsInit: attempt open DNS socket to: " << addrA);
             DnsSocketA = comm_open_listener(SOCK_DGRAM,
                                             IPPROTO_UDP,
diff -u -r -N squid-3.1.14/src/errorpage.h squid-3.1.15/src/errorpage.h
--- squid-3.1.14/src/errorpage.h	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/src/errorpage.h	2011-08-28 19:53:14.000000000 +1200
@@ -132,7 +132,7 @@
     HttpRequest *request;
     char *url;
     int xerrno;
-    u_short port;
+    unsigned short port;
     String dnsError; ///< DNS lookup error message
     time_t ttl;
 
diff -u -r -N squid-3.1.14/src/esi/Makefile.in squid-3.1.15/src/esi/Makefile.in
--- squid-3.1.14/src/esi/Makefile.in	2011-07-04 16:39:54.000000000 +1200
+++ squid-3.1.15/src/esi/Makefile.in	2011-08-28 19:53:52.000000000 +1200
@@ -157,6 +157,7 @@
 FALSE = @FALSE@
 FGREP = @FGREP@
 GREP = @GREP@
+HOSTCXX = @HOSTCXX@
 ICAP_LIBS = @ICAP_LIBS@
 INCLTDL = @INCLTDL@
 INSTALL = @INSTALL@
diff -u -r -N squid-3.1.14/src/event.cc squid-3.1.15/src/event.cc
--- squid-3.1.14/src/event.cc	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/src/event.cc	2011-08-28 19:53:14.000000000 +1200
@@ -238,7 +238,7 @@
 EventScheduler::checkEvents(int timeout)
 {
 
-    struct ev_entry *event = NULL;
+    ev_entry *event = NULL;
 
     if (NULL == tasks)
         return checkDelay();
@@ -291,7 +291,7 @@
 EventScheduler::dump(StoreEntry * sentry)
 {
 
-    struct ev_entry *e = tasks;
+    ev_entry *e = tasks;
 
     if (last_event_ran)
         storeAppendPrintf(sentry, "Last event to run: %s\n\n", last_event_ran);
@@ -314,7 +314,7 @@
 EventScheduler::find(EVH * func, void * arg)
 {
 
-    struct ev_entry *event;
+    ev_entry *event;
 
     for (event = tasks; event != NULL; event = event->next) {
         if (event->func == func && event->arg == arg)
@@ -337,9 +337,9 @@
     // must fire in the submission order. We cannot use current_dtime for them
     // because it may decrease if system clock is adjusted backwards.
     const double timestamp = when > 0.0 ? current_dtime + when : 0;
-    struct ev_entry *event = new ev_entry(name, func, arg, timestamp, weight, cbdata);
+    ev_entry *event = new ev_entry(name, func, arg, timestamp, weight, cbdata);
 
-    struct ev_entry **E;
+    ev_entry **E;
     debugs(41, 7, HERE << "schedule: Adding '" << name << "', in " << when << " seconds");
     /* Insert after the last event with the same or earlier time */
 
diff -u -r -N squid-3.1.14/src/fde.h squid-3.1.15/src/fde.h
--- squid-3.1.14/src/fde.h	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/src/fde.h	2011-08-28 19:53:14.000000000 +1200
@@ -53,7 +53,7 @@
     void noteUse(PconnPool *);
 
     unsigned int type;
-    u_short remote_port;
+    unsigned short remote_port;
 
     IpAddress local_addr;
     unsigned char tos;
diff -u -r -N squid-3.1.14/src/fs/Makefile.in squid-3.1.15/src/fs/Makefile.in
--- squid-3.1.14/src/fs/Makefile.in	2011-07-04 16:39:55.000000000 +1200
+++ squid-3.1.15/src/fs/Makefile.in	2011-08-28 19:53:52.000000000 +1200
@@ -155,6 +155,7 @@
 FALSE = @FALSE@
 FGREP = @FGREP@
 GREP = @GREP@
+HOSTCXX = @HOSTCXX@
 ICAP_LIBS = @ICAP_LIBS@
 INCLTDL = @INCLTDL@
 INSTALL = @INSTALL@
diff -u -r -N squid-3.1.14/src/fs/ufs/ufscommon.cc squid-3.1.15/src/fs/ufs/ufscommon.cc
--- squid-3.1.14/src/fs/ufs/ufscommon.cc	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/src/fs/ufs/ufscommon.cc	2011-08-28 19:53:14.000000000 +1200
@@ -61,8 +61,8 @@
         time_t expires;
         time_t lastmod;
         uint32_t swap_file_sz;
-        u_short refcount;
-        u_short flags;
+        uint16_t refcount;
+        uint16_t flags;
         unsigned char key[SQUID_MD5_DIGEST_LENGTH];
     };
     UFSSwapLogParser_v1_32bs(FILE *fp):UFSSwapLogParser(fp) {
@@ -109,8 +109,8 @@
         int32_t expires;
         int32_t lastmod;
         uint32_t swap_file_sz;
-        u_short refcount;
-        u_short flags;
+        uint16_t refcount;
+        uint16_t flags;
         unsigned char key[SQUID_MD5_DIGEST_LENGTH];
     };
     UFSSwapLogParser_v1_32bst(FILE *fp):UFSSwapLogParser(fp) {
@@ -155,8 +155,8 @@
         time_t expires;
         time_t lastmod;
         uint64_t swap_file_sz;
-        u_short refcount;
-        u_short flags;
+        uint16_t refcount;
+        uint16_t flags;
         unsigned char key[SQUID_MD5_DIGEST_LENGTH];
     };
     UFSSwapLogParser_v1_64bfn(FILE *fp):UFSSwapLogParser(fp) {
@@ -378,8 +378,8 @@
                 time_t expires;
                 time_t lastmod;
                 size_t swap_file_sz;
-                u_short refcount;
-                u_short flags;
+                uint16_t refcount;
+                uint16_t flags;
             } *tmp;
             tmp = (struct old_metahdr *)x.value;
             assert(x.length == STORE_HDR_METASIZE_OLD);
diff -u -r -N squid-3.1.14/src/ftp.cc squid-3.1.15/src/ftp.cc
--- squid-3.1.14/src/ftp.cc	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/src/ftp.cc	2011-08-28 19:53:14.000000000 +1200
@@ -202,7 +202,7 @@
     struct DataChannel: public FtpChannel {
         MemBuf *readBuf;
         char *host;
-        u_short port;
+        unsigned short port;
         bool read_pending;
     } data;
 
@@ -1295,7 +1295,8 @@
 void
 FtpStateData::maybeReadVirginBody()
 {
-    if (data.fd < 0)
+    // too late to read
+    if (data.fd < 0 || fd_table[data.fd].closing())
         return;
 
     if (data.read_pending)
@@ -2451,7 +2452,7 @@
 {
     int code = ftpState->ctrl.replycode;
     char h1, h2, h3, h4;
-    u_short port;
+    unsigned short port;
     IpAddress ipa_remote;
     int fd = ftpState->data.fd;
     char *buf;
@@ -2755,7 +2756,7 @@
     int h1, h2, h3, h4;
     int p1, p2;
     int n;
-    u_short port;
+    unsigned short port;
     IpAddress ipa_remote;
     int fd = ftpState->data.fd;
     char *buf;
diff -u -r -N squid-3.1.14/src/gopher.cc squid-3.1.15/src/gopher.cc
--- squid-3.1.14/src/gopher.cc	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/src/gopher.cc	2011-08-28 19:53:14.000000000 +1200
@@ -425,7 +425,6 @@
         return;
     }
 
-    inbuf[len] = '\0';
     String outbuf;
 
     if (!gopherState->HTML_header_added) {
@@ -441,75 +440,48 @@
         gopherState->HTML_pre = 1;
     }
 
-    while ((pos != NULL) && (pos < inbuf + len)) {
-
+    while (pos < inbuf + len) {
+        int llen;
+        int left = len - (pos - inbuf);
+        lpos = (char *)memchr(pos, '\n', left);
+        if (lpos) {
+            lpos++;             /* Next line is after \n */
+            llen = lpos - pos;
+        } else {
+            llen = left;
+        }
+        if (gopherState->len + llen >= TEMP_BUF_SIZE) {
+            debugs(10, 1, "GopherHTML: Buffer overflow. Lost some data on URL: " << entry->url()  );
+            llen = TEMP_BUF_SIZE - gopherState->len - 1;
+        }
+        if (!lpos) {
+            /* there is no complete line in inbuf */
+            /* copy it to temp buffer */
+            /* note: llen is adjusted above */
+            xmemcpy(gopherState->buf + gopherState->len, pos, llen);
+            gopherState->len += llen;
+            break;
+        }
+        if (!lpos) {
+            /* there is no complete line in inbuf */
+            /* copy it to temp buffer */
+            /* note: llen is adjusted above */
+            xmemcpy(gopherState->buf + gopherState->len, pos, llen);
+            gopherState->len += llen;
+            break;
+        }
         if (gopherState->len != 0) {
             /* there is something left from last tx. */
-            xstrncpy(line, gopherState->buf, gopherState->len + 1);
-
-            if (gopherState->len + len > TEMP_BUF_SIZE) {
-                debugs(10, 1, "GopherHTML: Buffer overflow. Lost some data on URL: " << entry->url()  );
-                len = TEMP_BUF_SIZE - gopherState->len;
-            }
-
-            lpos = (char *) memccpy(line + gopherState->len, inbuf, '\n', len);
-
-            if (lpos)
-                *lpos = '\0';
-            else {
-                /* there is no complete line in inbuf */
-                /* copy it to temp buffer */
-
-                if (gopherState->len + len > TEMP_BUF_SIZE) {
-                    debugs(10, 1, "GopherHTML: Buffer overflow. Lost some data on URL: " << entry->url()  );
-                    len = TEMP_BUF_SIZE - gopherState->len;
-                }
-
-                xmemcpy(gopherState->buf + gopherState->len, inbuf, len);
-                gopherState->len += len;
-                return;
-            }
-
-            /* skip one line */
-            pos = (char *) memchr(pos, '\n', len);
-
-            if (pos)
-                pos++;
-
-            /* we're done with the remain from last tx. */
+            xmemcpy(line, gopherState->buf, gopherState->len);
+            xmemcpy(line + gopherState->len, pos, llen);
+            llen += gopherState->len;
             gopherState->len = 0;
-
-            *(gopherState->buf) = '\0';
         } else {
-
-            lpos = (char *) memccpy(line, pos, '\n', len - (pos - inbuf));
-
-            if (lpos)
-                *lpos = '\0';
-            else {
-                /* there is no complete line in inbuf */
-                /* copy it to temp buffer */
-
-                if ((len - (pos - inbuf)) > TEMP_BUF_SIZE) {
-                    debugs(10, 1, "GopherHTML: Buffer overflow. Lost some data on URL: " << entry->url()  );
-                    len = TEMP_BUF_SIZE;
-                }
-
-                if (len > (pos - inbuf)) {
-                    xmemcpy(gopherState->buf, pos, len - (pos - inbuf));
-                    gopherState->len = len - (pos - inbuf);
-                }
-
-                break;
-            }
-
-            /* skip one line */
-            pos = (char *) memchr(pos, '\n', len);
-
-            if (pos)
-                pos++;
-
+            xmemcpy(line, pos, llen);
         }
+        line[llen + 1] = '\0';
+        /* move input to next line */
+        pos = lpos;
 
         /* at this point. We should have one line in buffer to process */
 
diff -u -r -N squid-3.1.14/src/htcp.cc squid-3.1.15/src/htcp.cc
--- squid-3.1.14/src/htcp.cc	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/src/htcp.cc	2011-08-28 19:53:14.000000000 +1200
@@ -447,12 +447,12 @@
 static ssize_t
 htcpBuildClrOpData(char *buf, size_t buflen, htcpStuff * stuff)
 {
-    u_short reason;
+    unsigned short reason;
 
     switch (stuff->rr) {
     case RR_REQUEST:
         debugs(31, 3, "htcpBuildClrOpData: RR_REQUEST");
-        reason = htons((u_short)stuff->reason);
+        reason = htons((unsigned short)stuff->reason);
         xmemcpy(buf, &reason, 2);
         return htcpBuildSpecifier(buf + 2, buflen - 2, stuff) + 2;
     case RR_RESPONSE:
diff -u -r -N squid-3.1.14/src/http.cc squid-3.1.15/src/http.cc
--- squid-3.1.14/src/http.cc	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/src/http.cc	2011-08-28 19:53:14.000000000 +1200
@@ -1394,6 +1394,10 @@
 void
 HttpStateData::maybeReadVirginBody()
 {
+    // too late to read
+    if (fd >= 0 && fd_table[fd].closing())
+        return;
+
     // we may need to grow the buffer if headers do not fit
     const int minRead = flags.headers_parsed ? 0 :1024;
     const int read_size = replyBodySpace(*readBuf, minRead);
diff -u -r -N squid-3.1.14/src/HttpRequest.h squid-3.1.15/src/HttpRequest.h
--- squid-3.1.14/src/HttpRequest.h	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/src/HttpRequest.h	2011-08-28 19:53:14.000000000 +1200
@@ -151,7 +151,7 @@
 
     AuthUserRequest *auth_user_request;
 
-    u_short port;
+    unsigned short port;
 
     String urlpath;
 
diff -u -r -N squid-3.1.14/src/icmp/Icmp4.cc squid-3.1.15/src/icmp/Icmp4.cc
--- squid-3.1.14/src/icmp/Icmp4.cc	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/src/icmp/Icmp4.cc	2011-08-28 19:53:14.000000000 +1200
@@ -117,7 +117,7 @@
     icmp->icmp_code = 0;
     icmp->icmp_cksum = 0;
     icmp->icmp_id = icmp_ident;
-    icmp->icmp_seq = (u_short) icmp_pkts_sent++;
+    icmp->icmp_seq = (unsigned short) icmp_pkts_sent++;
 
     // Construct ICMP packet data content
     echo = (icmpEchoData *) (icmp + 1);
@@ -135,7 +135,7 @@
         icmp_pktsize += len;
     }
 
-    icmp->icmp_cksum = CheckSum((u_short *) icmp, icmp_pktsize);
+    icmp->icmp_cksum = CheckSum((unsigned short *) icmp, icmp_pktsize);
 
     to.GetAddrInfo(S);
     ((sockaddr_in*)S->ai_addr)->sin_port = 0;
diff -u -r -N squid-3.1.14/src/icmp/Icmp6.cc squid-3.1.15/src/icmp/Icmp6.cc
--- squid-3.1.14/src/icmp/Icmp6.cc	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/src/icmp/Icmp6.cc	2011-08-28 19:53:14.000000000 +1200
@@ -158,7 +158,7 @@
     icmp->icmp6_code = 0;
     icmp->icmp6_cksum = 0;
     icmp->icmp6_id = icmp_ident;
-    icmp->icmp6_seq = (u_short) icmp_pkts_sent++;
+    icmp->icmp6_seq = (unsigned short) icmp_pkts_sent++;
 
     icmp6_pktsize = sizeof(struct icmp6_hdr);
 
@@ -179,7 +179,7 @@
         icmp6_pktsize += len;
     }
 
-    icmp->icmp6_cksum = CheckSum((u_short *) icmp, icmp6_pktsize);
+    icmp->icmp6_cksum = CheckSum((unsigned short *) icmp, icmp6_pktsize);
 
     to.GetAddrInfo(S);
     ((sockaddr_in6*)S->ai_addr)->sin6_port = 0;
diff -u -r -N squid-3.1.14/src/icmp/Makefile.in squid-3.1.15/src/icmp/Makefile.in
--- squid-3.1.14/src/icmp/Makefile.in	2011-07-04 16:39:55.000000000 +1200
+++ squid-3.1.15/src/icmp/Makefile.in	2011-08-28 19:53:52.000000000 +1200
@@ -169,6 +169,7 @@
 FALSE = @FALSE@
 FGREP = @FGREP@
 GREP = @GREP@
+HOSTCXX = @HOSTCXX@
 ICAP_LIBS = @ICAP_LIBS@
 INCLTDL = @INCLTDL@
 INSTALL = @INSTALL@
diff -u -r -N squid-3.1.14/src/icmp/testIcmp.cc squid-3.1.15/src/icmp/testIcmp.cc
--- squid-3.1.14/src/icmp/testIcmp.cc	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/src/icmp/testIcmp.cc	2011-08-28 19:53:14.000000000 +1200
@@ -15,7 +15,9 @@
 testIcmp::testChecksum()
 {
     stubIcmp icmp;
-    short unsigned int buf[10] = {htons(1),htons(2),htons(3),htons(4),htons(5),htons(6),htons(7),htons(8),htons(9), htons(10)};
+    uint16_t buf[10], tmpval;
+    for (tmpval=0; tmpval < 10; ++tmpval)
+        buf[tmpval]=htons(1+tmpval);
 
     // NULL data
     CPPUNIT_ASSERT_EQUAL((int)htons(0xffff), icmp.testChecksum(NULL,0));
diff -u -r -N squid-3.1.14/src/ident/Makefile.in squid-3.1.15/src/ident/Makefile.in
--- squid-3.1.14/src/ident/Makefile.in	2011-07-04 16:39:56.000000000 +1200
+++ squid-3.1.15/src/ident/Makefile.in	2011-08-28 19:53:53.000000000 +1200
@@ -137,6 +137,7 @@
 FALSE = @FALSE@
 FGREP = @FGREP@
 GREP = @GREP@
+HOSTCXX = @HOSTCXX@
 ICAP_LIBS = @ICAP_LIBS@
 INCLTDL = @INCLTDL@
 INSTALL = @INSTALL@
diff -u -r -N squid-3.1.14/src/internal.cc squid-3.1.15/src/internal.cc
--- squid-3.1.14/src/internal.cc	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/src/internal.cc	2011-08-28 19:53:14.000000000 +1200
@@ -93,7 +93,7 @@
  * makes internal url with a given host and port (remote internal url)
  */
 char *
-internalRemoteUri(const char *host, u_short port, const char *dir, const char *name)
+internalRemoteUri(const char *host, unsigned short port, const char *dir, const char *name)
 {
     static char lc_host[SQUIDHOSTNAMELEN];
     assert(host && name);
diff -u -r -N squid-3.1.14/src/ip/IpAddress.cc squid-3.1.15/src/ip/IpAddress.cc
--- squid-3.1.14/src/ip/IpAddress.cc	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/src/ip/IpAddress.cc	2011-08-28 19:53:14.000000000 +1200
@@ -741,12 +741,14 @@
     return ( matchIPAddr(rhs) < 0);
 }
 
-u_short IpAddress::GetPort() const
+unsigned short
+IpAddress::GetPort() const
 {
     return ntohs( m_SocketAddr.sin6_port );
 }
 
-u_short IpAddress::SetPort(u_short prt)
+unsigned short
+IpAddress::SetPort(unsigned short prt)
 {
     m_SocketAddr.sin6_port = htons(prt);
 
diff -u -r -N squid-3.1.14/src/ip/IpAddress.h squid-3.1.15/src/ip/IpAddress.h
--- squid-3.1.14/src/ip/IpAddress.h	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/src/ip/IpAddress.h	2011-08-28 19:53:14.000000000 +1200
@@ -176,7 +176,7 @@
      \retval 0 Port is unset or an error occured.
      \retval n Port associated with this address in host native -endian.
      */
-    u_short GetPort() const;
+    unsigned short GetPort() const;
 
     /** Set the Port value for an address.
      *  Replaces any previously existing Port value.
@@ -184,7 +184,7 @@
      \retval 0 Port is unset or an error occured.
      \retval n Port associated with this address in host native -endian.
      */
-    u_short SetPort(u_short port);
+    unsigned short SetPort(unsigned short port);
 
     /// Set object to contain the specific IP case ANY_ADDR (format-neutral).
     /// see IsAnyAddr() for more detail.
diff -u -r -N squid-3.1.14/src/ip/Makefile.in squid-3.1.15/src/ip/Makefile.in
--- squid-3.1.14/src/ip/Makefile.in	2011-07-04 16:39:56.000000000 +1200
+++ squid-3.1.15/src/ip/Makefile.in	2011-08-28 19:53:53.000000000 +1200
@@ -151,6 +151,7 @@
 FALSE = @FALSE@
 FGREP = @FGREP@
 GREP = @GREP@
+HOSTCXX = @HOSTCXX@
 ICAP_LIBS = @ICAP_LIBS@
 INCLTDL = @INCLTDL@
 INSTALL = @INSTALL@
diff -u -r -N squid-3.1.14/src/ip/testIpAddress.cc squid-3.1.15/src/ip/testIpAddress.cc
--- squid-3.1.14/src/ip/testIpAddress.cc	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/src/ip/testIpAddress.cc	2011-08-28 19:53:14.000000000 +1200
@@ -41,7 +41,7 @@
     CPPUNIT_ASSERT( !anIPA.IsNoAddr() );
     CPPUNIT_ASSERT( anIPA.IsIPv4() );
     CPPUNIT_ASSERT( !anIPA.IsSockAddr() );
-    CPPUNIT_ASSERT_EQUAL( (u_short) 0 , anIPA.GetPort() );
+    CPPUNIT_ASSERT_EQUAL( (unsigned short) 0 , anIPA.GetPort() );
     CPPUNIT_ASSERT( anIPA.IsIPv6() );
 }
 
@@ -62,7 +62,7 @@
     CPPUNIT_ASSERT( anIPA.IsIPv4() );
     CPPUNIT_ASSERT( !anIPA.IsIPv6() );
     CPPUNIT_ASSERT( !anIPA.IsSockAddr() );
-    CPPUNIT_ASSERT_EQUAL( (u_short) 0 , anIPA.GetPort() );
+    CPPUNIT_ASSERT_EQUAL( (unsigned short) 0 , anIPA.GetPort() );
     anIPA.GetInAddr(outval);
     CPPUNIT_ASSERT( memcmp(&inval, &outval, sizeof(struct in_addr)) == 0 );
 }
@@ -86,7 +86,7 @@
     CPPUNIT_ASSERT( !anIPA.IsIPv4() );
     CPPUNIT_ASSERT( anIPA.IsIPv6() );
     CPPUNIT_ASSERT( !anIPA.IsSockAddr() );
-    CPPUNIT_ASSERT_EQUAL( (u_short) 0 , anIPA.GetPort() );
+    CPPUNIT_ASSERT_EQUAL( (unsigned short) 0 , anIPA.GetPort() );
     anIPA.GetInAddr(outval);
     CPPUNIT_ASSERT( memcmp( &inval, &outval, sizeof(struct in6_addr)) == 0 );
 }
@@ -115,7 +115,7 @@
     CPPUNIT_ASSERT( anIPA.IsIPv4() );
     CPPUNIT_ASSERT( !anIPA.IsIPv6() );
     CPPUNIT_ASSERT( anIPA.IsSockAddr() );
-    CPPUNIT_ASSERT_EQUAL( (u_short) 80 , anIPA.GetPort() );
+    CPPUNIT_ASSERT_EQUAL( (unsigned short) 80 , anIPA.GetPort() );
     anIPA.GetSockAddr(outsock);
     CPPUNIT_ASSERT( memcmp( &insock, &outsock, sizeof(struct sockaddr_in)) == 0 );
 }
@@ -147,7 +147,7 @@
     CPPUNIT_ASSERT( !anIPA.IsIPv4() );
     CPPUNIT_ASSERT( anIPA.IsIPv6() );
     CPPUNIT_ASSERT( anIPA.IsSockAddr() );
-    CPPUNIT_ASSERT_EQUAL( (u_short) 80 , anIPA.GetPort() );
+    CPPUNIT_ASSERT_EQUAL( (unsigned short) 80 , anIPA.GetPort() );
     anIPA.GetSockAddr(outsock);
     CPPUNIT_ASSERT( memcmp( &insock, &outsock, sizeof(struct sockaddr_in6)) == 0 );
 }
@@ -179,7 +179,7 @@
     CPPUNIT_ASSERT( outIPA.IsIPv4() );
     CPPUNIT_ASSERT( !outIPA.IsIPv6() );
     CPPUNIT_ASSERT( outIPA.IsSockAddr() );
-    CPPUNIT_ASSERT_EQUAL( (u_short) 80 , outIPA.GetPort() );
+    CPPUNIT_ASSERT_EQUAL( (unsigned short) 80 , outIPA.GetPort() );
     outIPA.GetSockAddr(outsock);
     CPPUNIT_ASSERT( memcmp( &insock, &outsock, sizeof(struct sockaddr_in)) == 0 );
 }
@@ -204,7 +204,7 @@
     CPPUNIT_ASSERT( anIPA.IsIPv4() );
     CPPUNIT_ASSERT( !anIPA.IsIPv6() );
     CPPUNIT_ASSERT( !anIPA.IsSockAddr() );
-    CPPUNIT_ASSERT_EQUAL( (u_short) 0 , anIPA.GetPort() );
+    CPPUNIT_ASSERT_EQUAL( (unsigned short) 0 , anIPA.GetPort() );
     anIPA.GetInAddr(outval);
     CPPUNIT_ASSERT( memcmp( &expectval, &outval, sizeof(struct in_addr)) == 0 );
 }
@@ -224,7 +224,7 @@
     CPPUNIT_ASSERT( !anIPA.IsNoAddr() );
     CPPUNIT_ASSERT( anIPA.IsIPv4() );
     CPPUNIT_ASSERT( !anIPA.IsIPv6() );
-    CPPUNIT_ASSERT_EQUAL( (u_short) 0 , anIPA.GetPort() );
+    CPPUNIT_ASSERT_EQUAL( (unsigned short) 0 , anIPA.GetPort() );
     CPPUNIT_ASSERT( !anIPA.IsSockAddr() );
     anIPA.GetInAddr(outval);
     CPPUNIT_ASSERT( memcmp( &expectval, &outval, sizeof(struct in_addr)) == 0 );
@@ -249,7 +249,7 @@
     CPPUNIT_ASSERT( !bnIPA.IsIPv4() );
     CPPUNIT_ASSERT(  bnIPA.IsIPv6() );
     CPPUNIT_ASSERT( !bnIPA.IsSockAddr() );
-    CPPUNIT_ASSERT_EQUAL( (u_short) 0 , bnIPA.GetPort() );
+    CPPUNIT_ASSERT_EQUAL( (unsigned short) 0 , bnIPA.GetPort() );
     bnIPA.GetInAddr(outval6);
     CPPUNIT_ASSERT( memcmp( &expectv6, &outval6, sizeof(struct in6_addr)) == 0 );
 
@@ -267,7 +267,7 @@
     CPPUNIT_ASSERT( !cnIPA.IsIPv4() );
     CPPUNIT_ASSERT( cnIPA.IsIPv6() );
     CPPUNIT_ASSERT( !cnIPA.IsSockAddr() );
-    CPPUNIT_ASSERT_EQUAL( (u_short) 0 , cnIPA.GetPort() );
+    CPPUNIT_ASSERT_EQUAL( (unsigned short) 0 , cnIPA.GetPort() );
     cnIPA.GetInAddr(outval6);
     CPPUNIT_ASSERT( memcmp( &expectv6, &outval6, sizeof(struct in6_addr)) == 0 );
 }
@@ -288,7 +288,7 @@
     CPPUNIT_ASSERT( anIPA.IsIPv4() );
     CPPUNIT_ASSERT( !anIPA.IsIPv6() );
     CPPUNIT_ASSERT( !anIPA.IsSockAddr() );
-    CPPUNIT_ASSERT_EQUAL( (u_short) 0 , anIPA.GetPort() );
+    CPPUNIT_ASSERT_EQUAL( (unsigned short) 0 , anIPA.GetPort() );
 
     anIPA.SetEmpty();
 
@@ -298,7 +298,7 @@
     CPPUNIT_ASSERT( anIPA.IsIPv4() );
     CPPUNIT_ASSERT( anIPA.IsIPv6() );
     CPPUNIT_ASSERT( !anIPA.IsSockAddr() );
-    CPPUNIT_ASSERT_EQUAL( (u_short) 0 , anIPA.GetPort() );
+    CPPUNIT_ASSERT_EQUAL( (unsigned short) 0 , anIPA.GetPort() );
 }
 
 void
@@ -722,7 +722,7 @@
     CPPUNIT_ASSERT( !anIPA.IsNoAddr() );
     CPPUNIT_ASSERT( anIPA.IsIPv4() );
     CPPUNIT_ASSERT( !anIPA.IsIPv6() );
-    CPPUNIT_ASSERT_EQUAL( (u_short) 0 , anIPA.GetPort() );
+    CPPUNIT_ASSERT_EQUAL( (unsigned short) 0 , anIPA.GetPort() );
     CPPUNIT_ASSERT( !anIPA.IsSockAddr() );
     anIPA.GetInAddr(outval);
     CPPUNIT_ASSERT( memcmp( &expectval, &outval, sizeof(struct in_addr)) == 0 );
@@ -736,7 +736,7 @@
     CPPUNIT_ASSERT( !anIPA.IsNoAddr() );
     CPPUNIT_ASSERT( anIPA.IsIPv4() );
     CPPUNIT_ASSERT( !anIPA.IsIPv6() );
-    CPPUNIT_ASSERT_EQUAL( (u_short) 0 , anIPA.GetPort() );
+    CPPUNIT_ASSERT_EQUAL( (unsigned short) 0 , anIPA.GetPort() );
     CPPUNIT_ASSERT( !anIPA.IsSockAddr() );
     anIPA.GetInAddr(outval);
     CPPUNIT_ASSERT( memcmp( &expectval, &outval, sizeof(struct in_addr)) == 0 );
@@ -751,7 +751,7 @@
     CPPUNIT_ASSERT( !anIPA.IsNoAddr() );
     CPPUNIT_ASSERT( anIPA.IsIPv4() );
     CPPUNIT_ASSERT( !anIPA.IsIPv6() );
-    CPPUNIT_ASSERT_EQUAL( (u_short) 0 , anIPA.GetPort() );
+    CPPUNIT_ASSERT_EQUAL( (unsigned short) 0 , anIPA.GetPort() );
     CPPUNIT_ASSERT( !anIPA.IsSockAddr() );
     anIPA.GetInAddr(outval);
     CPPUNIT_ASSERT( memcmp( &expectval, &outval, sizeof(struct in_addr)) == 0 );
@@ -765,7 +765,7 @@
     CPPUNIT_ASSERT( !anIPA.IsNoAddr() );
     CPPUNIT_ASSERT( anIPA.IsIPv4() );
     CPPUNIT_ASSERT( !anIPA.IsIPv6() );
-    CPPUNIT_ASSERT_EQUAL( (u_short) 0 , anIPA.GetPort() );
+    CPPUNIT_ASSERT_EQUAL( (unsigned short) 0 , anIPA.GetPort() );
     CPPUNIT_ASSERT( !anIPA.IsSockAddr() );
     anIPA.GetInAddr(outval);
     CPPUNIT_ASSERT( memcmp( &expectval, &outval, sizeof(struct in_addr)) == 0 );
diff -u -r -N squid-3.1.14/src/ipcache.cc squid-3.1.15/src/ipcache.cc
--- squid-3.1.14/src/ipcache.cc	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/src/ipcache.cc	2011-08-28 19:53:14.000000000 +1200
@@ -652,7 +652,6 @@
 ipcacheHandleReply(void *data, rfc1035_rr * answers, int na, const char *error_message)
 #endif
 {
-    int done;
     ipcache_entry *i;
     static_cast<generic_cbdata *>(data)->unwrap(&i);
     IpcacheStats.replies++;
@@ -660,11 +659,10 @@
     statHistCount(&statCounter.dns.svc_time, age);
 
 #if USE_DNSSERVERS
-
-    done = ipcacheParse(i, reply);
+    ipcacheParse(i, reply);
 #else
 
-    done = ipcacheParse(i, answers, na, error_message);
+    int done = ipcacheParse(i, answers, na, error_message);
 
     /* If we have not produced either IPs or Error immediately, wait for recursion to finish. */
     if (done != 0 || error_message != NULL)
diff -u -r -N squid-3.1.14/src/LoadableModule.cc squid-3.1.15/src/LoadableModule.cc
--- squid-3.1.14/src/LoadableModule.cc	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/src/LoadableModule.cc	2011-08-28 19:53:14.000000000 +1200
@@ -69,7 +69,7 @@
 #	if XSTD_USE_LIBLTDL
     return lt_dlopen(theName.termedBuf());
 #	else
-    return dlopen(theName.c_str(),
+    return dlopen(theName.termedBuf(),
                   mode == lmNow ? RTLD_NOW : RTLD_LAZY);
 #	endif
 }
diff -u -r -N squid-3.1.14/src/main.cc squid-3.1.15/src/main.cc
--- squid-3.1.14/src/main.cc	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/src/main.cc	2011-08-28 19:53:14.000000000 +1200
@@ -920,7 +920,7 @@
     setEffectiveUser();
 
     if (icpPortNumOverride != 1)
-        Config.Port.icp = (u_short) icpPortNumOverride;
+        Config.Port.icp = (unsigned short) icpPortNumOverride;
 
     _db_init(Debug::cache_log, Debug::debugOptions);
 
diff -u -r -N squid-3.1.14/src/Makefile.am squid-3.1.15/src/Makefile.am
--- squid-3.1.14/src/Makefile.am	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/src/Makefile.am	2011-08-28 19:53:14.000000000 +1200
@@ -199,12 +199,8 @@
 
 cf_gen_SOURCES = cf_gen.cc
 nodist_cf_gen_HEADER = cf_gen_defines.cci
-cf_gen_LDADD= \
-	../compat/libcompat.la \
-	-L../lib -lmiscutil \
-	$(EPOLL_LIBS) \
-	$(MINGW_LIBS) \
-	$(XTRA_LIBS)
+## cf_gen must be stand-alone executable. It is a purely build-time executable.
+cf_gen_LDADD=
 cf_gen.$(OBJEXT): cf_gen_defines.cci
 
 ## cf_gen.cc needs src/cf_gen_defines.cci
@@ -758,6 +754,10 @@
 ## If autodependency works well this is not needed anymore
 cache_cf.o: cf_parser.cci
 
+# cf_gen builds the configuration files.
+cf_gen$(EXEEXT): $(cf_gen_SOURCES) $(cf_gen_DEPENDENCIES)
+	$(HOSTCXX) -o $@ $(srcdir)/cf_gen.cc -I$(srcdir) -I$(top_builddir)/include/ -I$(top_builddir)/src
+
 # squid.conf.default is built by cf_gen when making cf_parser.cci
 squid.conf.default squid.conf.documented: cf_parser.cci
 	true
diff -u -r -N squid-3.1.14/src/Makefile.in squid-3.1.15/src/Makefile.in
--- squid-3.1.14/src/Makefile.in	2011-07-04 16:39:51.000000000 +1200
+++ squid-3.1.15/src/Makefile.in	2011-08-28 19:53:51.000000000 +1200
@@ -150,8 +150,7 @@
 	$(top_builddir)/lib/libmiscutil.a $(am__DEPENDENCIES_1)
 am_cf_gen_OBJECTS = cf_gen.$(OBJEXT)
 cf_gen_OBJECTS = $(am_cf_gen_OBJECTS)
-cf_gen_DEPENDENCIES = ../compat/libcompat.la $(am__DEPENDENCIES_1) \
-	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+cf_gen_DEPENDENCIES =
 am_dnsserver_OBJECTS = dnsserver.$(OBJEXT) SquidNew.$(OBJEXT)
 dnsserver_OBJECTS = $(am_dnsserver_OBJECTS)
 dnsserver_LDADD = $(LDADD)
@@ -1484,6 +1483,7 @@
 FALSE = @FALSE@
 FGREP = @FGREP@
 GREP = @GREP@
+HOSTCXX = @HOSTCXX@
 ICAP_LIBS = @ICAP_LIBS@
 INCLTDL = @INCLTDL@
 INSTALL = @INSTALL@
@@ -1748,13 +1748,7 @@
 
 cf_gen_SOURCES = cf_gen.cc
 nodist_cf_gen_HEADER = cf_gen_defines.cci
-cf_gen_LDADD = \
-	../compat/libcompat.la \
-	-L../lib -lmiscutil \
-	$(EPOLL_LIBS) \
-	$(MINGW_LIBS) \
-	$(XTRA_LIBS)
-
+cf_gen_LDADD = 
 ACL_REGISTRATION_SOURCES = AclRegs.cc AuthReg.cc
 DISKIO_SOURCE = \
 	DiskIO/DiskIOModule.cc \
@@ -3778,9 +3772,6 @@
 DiskIO/DiskDaemon/diskd$(EXEEXT): $(DiskIO_DiskDaemon_diskd_OBJECTS) $(DiskIO_DiskDaemon_diskd_DEPENDENCIES) DiskIO/DiskDaemon/$(am__dirstamp)
 	@rm -f DiskIO/DiskDaemon/diskd$(EXEEXT)
 	$(CXXLINK) $(DiskIO_DiskDaemon_diskd_OBJECTS) $(DiskIO_DiskDaemon_diskd_LDADD) $(LIBS)
-cf_gen$(EXEEXT): $(cf_gen_OBJECTS) $(cf_gen_DEPENDENCIES) 
-	@rm -f cf_gen$(EXEEXT)
-	$(CXXLINK) $(cf_gen_OBJECTS) $(cf_gen_LDADD) $(LIBS)
 dnsserver$(EXEEXT): $(dnsserver_OBJECTS) $(dnsserver_DEPENDENCIES) 
 	@rm -f dnsserver$(EXEEXT)
 	$(CXXLINK) $(dnsserver_OBJECTS) $(dnsserver_LDADD) $(LIBS)
@@ -4822,6 +4813,10 @@
 
 cache_cf.o: cf_parser.cci
 
+# cf_gen builds the configuration files.
+cf_gen$(EXEEXT): $(cf_gen_SOURCES) $(cf_gen_DEPENDENCIES)
+	$(HOSTCXX) -o $@ $(srcdir)/cf_gen.cc -I$(srcdir) -I$(top_builddir)/include/ -I$(top_builddir)/src
+
 # squid.conf.default is built by cf_gen when making cf_parser.cci
 squid.conf.default squid.conf.documented: cf_parser.cci
 	true
diff -u -r -N squid-3.1.14/src/neighbors.cc squid-3.1.15/src/neighbors.cc
--- squid-3.1.14/src/neighbors.cc	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/src/neighbors.cc	2011-08-28 19:53:14.000000000 +1200
@@ -74,7 +74,7 @@
 static void dump_peers(StoreEntry * sentry, peer * peers);
 
 static icp_common_t echo_hdr;
-static u_short echo_port;
+static unsigned short echo_port;
 
 static int NLateReplies = 0;
 static peer *first_ping = NULL;
@@ -214,22 +214,19 @@
 static int
 peerWouldBePinged(const peer * p, HttpRequest * request)
 {
-    if (!peerAllowedToUse(p, request))
+    if (p->icp.port == 0)
         return 0;
 
     if (p->options.no_query)
         return 0;
 
-    if (p->options.background_ping && (squid_curtime - p->stats.last_query < Config.backgroundPingRate))
-        return 0;
-
     if (p->options.mcast_responder)
         return 0;
 
     if (p->n_addresses == 0)
         return 0;
 
-    if (p->icp.port == 0)
+    if (p->options.background_ping && (squid_curtime - p->stats.last_query < Config.backgroundPingRate))
         return 0;
 
     /* the case below seems strange, but can happen if the
@@ -238,6 +235,9 @@
         if (!request->flags.hierarchical)
             return 0;
 
+    if (!peerAllowedToUse(p, request))
+        return 0;
+
     /* Ping dead peers every timeout interval */
     if (squid_curtime - p->stats.last_query > Config.Timeout.deadPeer)
         return 1;
@@ -252,16 +252,16 @@
 int
 peerHTTPOkay(const peer * p, HttpRequest * request)
 {
+    if (p->max_conn)
+        if (p->stats.conn_open >= p->max_conn)
+            return 0;
+
     if (!peerAllowedToUse(p, request))
         return 0;
 
     if (!neighborUp(p))
         return 0;
 
-    if (p->max_conn)
-        if (p->stats.conn_open >= p->max_conn)
-            return 0;
-
     return 1;
 }
 
@@ -477,33 +477,6 @@
     return NULL;
 }
 
-/*
- * XXX DW thinks this function is equivalent to/redundant with
- * getFirstUpParent().  peerHTTPOkay() only returns true if the
- * peer is UP anyway, so this function would not return a
- * DOWN parent.
- */
-peer *
-getAnyParent(HttpRequest * request)
-{
-    peer *p = NULL;
-
-    for (p = Config.peers; p; p = p->next) {
-        if (neighborType(p, request) != PEER_PARENT)
-            continue;
-
-        if (!peerHTTPOkay(p, request))
-            continue;
-
-        debugs(15, 3, "getAnyParent: returning " << p->host);
-
-        return p;
-    }
-
-    debugs(15, 3, "getAnyParent: returning NULL");
-    return NULL;
-}
-
 peer *
 getNextPeer(peer * p)
 {
@@ -613,7 +586,7 @@
         nul = *AI;
         nul.GetInAddr( *((struct in_addr*)&echo_hdr.shostid) );
         sep = getservbyname("echo", "udp");
-        echo_port = sep ? ntohs((u_short) sep->s_port) : 7;
+        echo_port = sep ? ntohs((unsigned short) sep->s_port) : 7;
     }
 
     first_ping = Config.peers;
diff -u -r -N squid-3.1.14/src/Parsing.cc squid-3.1.15/src/Parsing.cc
--- squid-3.1.14/src/Parsing.cc	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/src/Parsing.cc	2011-08-28 19:53:14.000000000 +1200
@@ -110,7 +110,7 @@
     return i;
 }
 
-u_short
+unsigned short
 GetShort(void)
 {
     char *token = strtok(NULL, w_space);
diff -u -r -N squid-3.1.14/src/Parsing.h squid-3.1.15/src/Parsing.h
--- squid-3.1.14/src/Parsing.h	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/src/Parsing.h	2011-08-28 19:53:14.000000000 +1200
@@ -54,7 +54,7 @@
  */
 extern int GetInteger(void);
 
-extern u_short GetShort(void);
+extern unsigned short GetShort(void);
 
 // on success, returns true and sets *p (if any) to the end of the integer
 extern bool StringToInt(const char *str, int &result, const char **p, int base);
diff -u -r -N squid-3.1.14/src/pconn.cc squid-3.1.15/src/pconn.cc
--- squid-3.1.14/src/pconn.cc	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/src/pconn.cc	2011-08-28 19:53:14.000000000 +1200
@@ -177,7 +177,7 @@
 /* ========== PconnPool PRIVATE FUNCTIONS ============================================ */
 
 const char *
-PconnPool::key(const char *host, u_short port, const char *domain, IpAddress &client_address)
+PconnPool::key(const char *host, unsigned short port, const char *domain, IpAddress &client_address)
 {
     LOCAL_ARRAY(char, buf, SQUIDHOSTNAMELEN * 3 + 10);
     char ntoabuf[MAX_IPSTRLEN];
@@ -248,7 +248,7 @@
 }
 
 void
-PconnPool::push(int fd, const char *host, u_short port, const char *domain, IpAddress &client_address)
+PconnPool::push(int fd, const char *host, unsigned short port, const char *domain, IpAddress &client_address)
 {
     IdleConnList *list;
     const char *aKey;
@@ -293,7 +293,7 @@
  * transactions create persistent connections but are not retriable.
  */
 int
-PconnPool::pop(const char *host, u_short port, const char *domain, IpAddress &client_address, bool isRetriable)
+PconnPool::pop(const char *host, unsigned short port, const char *domain, IpAddress &client_address, bool isRetriable)
 {
     const char * aKey = key(host, port, domain, client_address);
 
diff -u -r -N squid-3.1.14/src/pconn.h squid-3.1.15/src/pconn.h
--- squid-3.1.14/src/pconn.h	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/src/pconn.h	2011-08-28 19:53:14.000000000 +1200
@@ -73,8 +73,8 @@
     ~PconnPool();
 
     void moduleInit();
-    void push(int fd, const char *host, u_short port, const char *domain, IpAddress &client_address);
-    int pop(const char *host, u_short port, const char *domain, IpAddress &client_address, bool retriable);
+    void push(int fd, const char *host, unsigned short port, const char *domain, IpAddress &client_address);
+    int pop(const char *host, unsigned short port, const char *domain, IpAddress &client_address, bool retriable);
     void count(int uses);
     void dumpHist(StoreEntry *e);
     void dumpHash(StoreEntry *e);
@@ -82,7 +82,7 @@
 
 private:
 
-    static const char *key(const char *host, u_short port, const char *domain, IpAddress &client_address);
+    static const char *key(const char *host, unsigned short port, const char *domain, IpAddress &client_address);
 
     int hist[PCONN_HIST_SZ];
     hash_table *table;
diff -u -r -N squid-3.1.14/src/peer_select.cc squid-3.1.15/src/peer_select.cc
--- squid-3.1.14/src/peer_select.cc	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/src/peer_select.cc	2011-08-28 19:53:14.000000000 +1200
@@ -540,12 +540,10 @@
     if (ps->direct == DIRECT_YES)
         return;
 
-    if ((p = getDefaultParent(request))) {
-        code = DEFAULT_PARENT;
+    if ((p = peerSourceHashSelectParent(request))) {
+        code = SOURCEHASH_PARENT;
     } else if ((p = peerUserHashSelectParent(request))) {
         code = USERHASH_PARENT;
-    } else if ((p = peerSourceHashSelectParent(request))) {
-        code = SOURCEHASH_PARENT;
     } else if ((p = carpSelectParent(request))) {
         code = CARP;
     } else if ((p = getRoundRobinParent(request))) {
@@ -554,8 +552,8 @@
         code = ROUNDROBIN_PARENT;
     } else if ((p = getFirstUpParent(request))) {
         code = FIRSTUP_PARENT;
-    } else if ((p = getAnyParent(request))) {
-        code = ANY_OLD_PARENT;
+    } else if ((p = getDefaultParent(request))) {
+        code = DEFAULT_PARENT;
     }
 
     if (code != HIER_NONE) {
diff -u -r -N squid-3.1.14/src/protos.h squid-3.1.15/src/protos.h
--- squid-3.1.14/src/protos.h	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/src/protos.h	2011-08-28 19:53:14.000000000 +1200
@@ -388,7 +388,6 @@
 SQUIDCEXTERN peer *getWeightedRoundRobinParent(HttpRequest * request);
 SQUIDCEXTERN void peerClearRRStart(void);
 SQUIDCEXTERN void peerClearRR(void);
-SQUIDCEXTERN peer *getAnyParent(HttpRequest * request);
 SQUIDCEXTERN lookup_t peerDigestLookup(peer * p, HttpRequest * request);
 SQUIDCEXTERN peer *neighborsDigestSelect(HttpRequest * request);
 SQUIDCEXTERN void peerNoteDigestLookup(HttpRequest * request, peer * p, lookup_t lookup);
@@ -611,7 +610,7 @@
 SQUIDCEXTERN const char *urlCanonicalFakeHttps(const HttpRequest * request);
 SQUIDCEXTERN bool urlIsRelative(const char *);
 SQUIDCEXTERN char *urlMakeAbsolute(const HttpRequest *, const char *);
-SQUIDCEXTERN char *urlRInternal(const char *host, u_short port, const char *dir, const char *name);
+SQUIDCEXTERN char *urlRInternal(const char *host, unsigned short port, const char *dir, const char *name);
 SQUIDCEXTERN char *urlInternal(const char *dir, const char *name);
 SQUIDCEXTERN int matchDomainName(const char *host, const char *domain);
 SQUIDCEXTERN int urlCheckRequest(const HttpRequest *);
@@ -685,7 +684,7 @@
 SQUIDCEXTERN int internalCheck(const char *urlpath);
 SQUIDCEXTERN int internalStaticCheck(const char *urlpath);
 SQUIDCEXTERN char *internalLocalUri(const char *dir, const char *name);
-SQUIDCEXTERN char *internalRemoteUri(const char *, u_short, const char *, const char *);
+SQUIDCEXTERN char *internalRemoteUri(const char *, unsigned short, const char *, const char *);
 SQUIDCEXTERN const char *internalHostname(void);
 SQUIDCEXTERN int internalHostnameIs(const char *);
 
diff -u -r -N squid-3.1.14/src/redirect.cc squid-3.1.15/src/redirect.cc
--- squid-3.1.14/src/redirect.cc	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/src/redirect.cc	2011-08-28 19:53:14.000000000 +1200
@@ -141,21 +141,28 @@
     else
         r->client_addr.SetNoAddr();
     r->client_ident = NULL;
-
-    if (http->request->auth_user_request)
+    if (http->request->auth_user_request != NULL) {
         r->client_ident = http->request->auth_user_request->username();
-    else if (http->request->extacl_user.defined()) {
+        debugs(61, 5, HERE << "auth-user=" << (r->client_ident?r->client_ident:"NULL"));
+    }
+
+    // HttpRequest initializes with null_string. So we must check both defined() and size()
+    if (!r->client_ident && http->request->extacl_user.defined() && http->request->extacl_user.size()) {
         r->client_ident = http->request->extacl_user.termedBuf();
+        debugs(61, 5, HERE << "acl-user=" << (r->client_ident?r->client_ident:"NULL"));
     }
 
-    if (!r->client_ident && (conn != NULL && conn->rfc931[0]))
+    if (!r->client_ident && (conn != NULL && conn->rfc931[0])) {
         r->client_ident = conn->rfc931;
+        debugs(61, 5, HERE << "ident-user=" << (r->client_ident?r->client_ident:"NULL"));
+    }
 
 #if USE_SSL
 
-    if (!r->client_ident && conn != NULL)
+    if (!r->client_ident && conn != NULL) {
         r->client_ident = sslGetUserEmail(fd_table[conn->fd].ssl);
-
+        debugs(61, 5, HERE << "ssl-user=" << (r->client_ident?r->client_ident:"NULL"));
+    }
 #endif
 
     if (!r->client_ident)
diff -u -r -N squid-3.1.14/src/repl/Makefile.in squid-3.1.15/src/repl/Makefile.in
--- squid-3.1.14/src/repl/Makefile.in	2011-07-04 16:39:57.000000000 +1200
+++ squid-3.1.15/src/repl/Makefile.in	2011-08-28 19:53:53.000000000 +1200
@@ -150,6 +150,7 @@
 FALSE = @FALSE@
 FGREP = @FGREP@
 GREP = @GREP@
+HOSTCXX = @HOSTCXX@
 ICAP_LIBS = @ICAP_LIBS@
 INCLTDL = @INCLTDL@
 INSTALL = @INSTALL@
diff -u -r -N squid-3.1.14/src/send-announce.cc squid-3.1.15/src/send-announce.cc
--- squid-3.1.14/src/send-announce.cc	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/src/send-announce.cc	2011-08-28 19:53:14.000000000 +1200
@@ -63,7 +63,7 @@
     IpAddress S;
     char *host = Config.Announce.host;
     char *file = NULL;
-    u_short port = Config.Announce.port;
+    unsigned short port = Config.Announce.port;
     int l;
     int n;
     int fd;
diff -u -r -N squid-3.1.14/src/ssl/certificate_db.cc squid-3.1.15/src/ssl/certificate_db.cc
--- squid-3.1.14/src/ssl/certificate_db.cc	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/src/ssl/certificate_db.cc	2011-08-28 19:53:14.000000000 +1200
@@ -394,14 +394,22 @@
         corrupt = true;
 
     // Create indexes in db.
+#if OPENSSL_VERSION_NUMBER > 0x10000000L
+    if (!corrupt && !TXT_DB_create_index(temp_db.get(), cnlSerial, NULL, LHASH_HASH_FN(index_serial), LHASH_COMP_FN(index_serial)))
+        corrupt = true;
+
+    if (!corrupt && !TXT_DB_create_index(temp_db.get(), cnlName, NULL, LHASH_HASH_FN(index_name), LHASH_COMP_FN(index_name)))
+        corrupt = true;
+#else
     if (!corrupt && !TXT_DB_create_index(temp_db.get(), cnlSerial, NULL, LHASH_HASH_FN(index_serial_hash), LHASH_COMP_FN(index_serial_cmp)))
         corrupt = true;
 
     if (!corrupt && !TXT_DB_create_index(temp_db.get(), cnlName, NULL, LHASH_HASH_FN(index_name_hash), LHASH_COMP_FN(index_name_cmp)))
         corrupt = true;
+#endif
 
     if (corrupt)
-        throw std::runtime_error("The SSL certificate database " + db_path + " is curruted. Please rebuild");
+        throw std::runtime_error("The SSL certificate database " + db_path + " is corrupted. Please rebuild");
 
     db.reset(temp_db.release());
 }
@@ -426,13 +434,22 @@
         return false;
 
     bool removed_one = false;
+#if OPENSSL_VERSION_NUMBER > 0x10000000L
+    for (int i = 0; i < sk_OPENSSL_PSTRING_num(db.get()->data); i++) {
+        const char ** current_row = ((const char **)sk_OPENSSL_PSTRING_value(db.get()->data, i));
+#else
     for (int i = 0; i < sk_num(db.get()->data); i++) {
         const char ** current_row = ((const char **)sk_value(db.get()->data, i));
+#endif
 
         if (!sslDateIsInTheFuture(current_row[cnlExp_date])) {
             std::string filename(cert_full + "/" + current_row[cnlSerial] + ".pem");
             FileLocker cert_locker(filename);
+#if OPENSSL_VERSION_NUMBER > 0x10000000L
+            sk_OPENSSL_PSTRING_delete(db.get()->data, i);
+#else
             sk_delete(db.get()->data, i);
+#endif
             subSize(filename);
             remove(filename.c_str());
             removed_one = true;
@@ -450,12 +467,27 @@
     if (!db)
         return false;
 
+#if OPENSSL_VERSION_NUMBER > 0x10000000L
+    if (sk_OPENSSL_PSTRING_num(db.get()->data) == 0)
+#else
     if (sk_num(db.get()->data) == 0)
+#endif
         return false;
 
-    std::string filename(cert_full + "/" + ((const char **)sk_value(db.get()->data, 0))[cnlSerial] + ".pem");
+#if OPENSSL_VERSION_NUMBER > 0x10000000L
+    const char **row = (const char **)sk_OPENSSL_PSTRING_value(db.get()->data, 0);
+#else
+    const char **row = (const char **)sk_value(db.get()->data, 0);
+#endif
+    std::string filename(cert_full + "/" + row[cnlSerial] + ".pem");
     FileLocker cert_locker(filename);
+
+#if OPENSSL_VERSION_NUMBER > 0x10000000L
+    sk_OPENSSL_PSTRING_delete(db.get()->data, 0);
+#else
     sk_delete(db.get()->data, 0);
+#endif
+
     subSize(filename);
     remove(filename.c_str());
 
@@ -467,12 +499,21 @@
     if (!db)
         return false;
 
+#if OPENSSL_VERSION_NUMBER > 0x10000000L
+    for (int i = 0; i < sk_OPENSSL_PSTRING_num(db.get()->data); i++) {
+        const char ** current_row = ((const char **)sk_OPENSSL_PSTRING_value(db.get()->data, i));
+#else
     for (int i = 0; i < sk_num(db.get()->data); i++) {
         const char ** current_row = ((const char **)sk_value(db.get()->data, i));
+#endif
         if (host == current_row[cnlName]) {
             std::string filename(cert_full + "/" + current_row[cnlSerial] + ".pem");
             FileLocker cert_locker(filename);
+#if OPENSSL_VERSION_NUMBER > 0x10000000L
+            sk_OPENSSL_PSTRING_delete(db.get()->data, i);
+#else
             sk_delete(db.get()->data, i);
+#endif
             subSize(filename);
             remove(filename.c_str());
             return true;
diff -u -r -N squid-3.1.14/src/ssl/certificate_db.h squid-3.1.15/src/ssl/certificate_db.h
--- squid-3.1.14/src/ssl/certificate_db.h	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/src/ssl/certificate_db.h	2011-08-28 19:53:14.000000000 +1200
@@ -10,6 +10,9 @@
 #if HAVE_STRING
 #include <string>
 #endif
+#if HAVE_OPENSSL_OPENSSLV_H
+#include <openssl/opensslv.h>
+#endif
 
 namespace Ssl
 {
@@ -110,10 +113,25 @@
 
     /// Definitions required by openSSL, to use the index_* functions defined above
     ///with TXT_DB_create_index.
+#if OPENSSL_VERSION_NUMBER > 0x10000000L
+    static unsigned long index_serial_LHASH_HASH(const void *a) {
+        return index_serial_hash((const char **)a);
+    }
+    static int index_serial_LHASH_COMP(const void *arg1, const void *arg2) {
+        return index_serial_cmp((const char **)arg1, (const char **)arg2);
+    }
+    static unsigned long index_name_LHASH_HASH(const void *a) {
+        return index_name_hash((const char **)a);
+    }
+    static int index_name_LHASH_COMP(const void *arg1, const void *arg2) {
+        return index_name_cmp((const char **)arg1, (const char **)arg2);
+    }
+#else
     static IMPLEMENT_LHASH_HASH_FN(index_serial_hash,const char **)
     static IMPLEMENT_LHASH_COMP_FN(index_serial_cmp,const char **)
     static IMPLEMENT_LHASH_HASH_FN(index_name_hash,const char **)
     static IMPLEMENT_LHASH_COMP_FN(index_name_cmp,const char **)
+#endif
 
     static const std::string serial_file; ///< Base name of the file to store serial number.
     static const std::string db_file; ///< Base name of the database index file.
diff -u -r -N squid-3.1.14/src/ssl/Makefile.in squid-3.1.15/src/ssl/Makefile.in
--- squid-3.1.14/src/ssl/Makefile.in	2011-07-04 16:39:57.000000000 +1200
+++ squid-3.1.15/src/ssl/Makefile.in	2011-08-28 19:53:53.000000000 +1200
@@ -161,6 +161,7 @@
 FALSE = @FALSE@
 FGREP = @FGREP@
 GREP = @GREP@
+HOSTCXX = @HOSTCXX@
 ICAP_LIBS = @ICAP_LIBS@
 INCLTDL = @INCLTDL@
 INSTALL = @INSTALL@
diff -u -r -N squid-3.1.14/src/ssl_support.cc squid-3.1.15/src/ssl_support.cc
--- squid-3.1.14/src/ssl_support.cc	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/src/ssl_support.cc	2011-08-28 19:53:14.000000000 +1200
@@ -178,8 +178,10 @@
             }
             ASN1_STRING *cn_data = check->d.dNSName;
 
-            if ( (*check_func)(check_data, cn_data) == 0)
+            if ( (*check_func)(check_data, cn_data) == 0) {
+                sk_GENERAL_NAME_pop_free(altnames, GENERAL_NAME_free);
                 return 1;
+            }
         }
         sk_GENERAL_NAME_pop_free(altnames, GENERAL_NAME_free);
     }
diff -u -r -N squid-3.1.14/src/store.cc squid-3.1.15/src/store.cc
--- squid-3.1.14/src/store.cc	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/src/store.cc	2011-08-28 19:53:14.000000000 +1200
@@ -1431,7 +1431,9 @@
 void
 StoreEntry::negativeCache()
 {
-    if (expires == 0)
+    // XXX: should make the default for expires 0 instead of -1
+    //      so we can distinguish "Expires: -1" from nothing.
+    if (expires <= 0)
 #if HTTP_VIOLATIONS
         expires = squid_curtime + Config.negativeTtl;
 #else
@@ -1491,6 +1493,14 @@
     if (served_date < 0 || served_date > squid_curtime)
         served_date = squid_curtime;
 
+    /* Bug 1791:
+     * If the returned Date: is more than 24 hours older than
+     * the squid_curtime, then one of us needs to use NTP to set our
+     * clock.  We'll pretend that our clock is right.
+     */
+    else if (served_date < (squid_curtime - 24 * 60 * 60) )
+        served_date = squid_curtime;
+
     /*
      * Compensate with Age header if origin server clock is ahead
      * of us and there is a cache in between us and the origin
diff -u -r -N squid-3.1.14/src/Store.h squid-3.1.15/src/Store.h
--- squid-3.1.14/src/Store.h	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/src/Store.h	2011-08-28 19:53:14.000000000 +1200
@@ -139,15 +139,15 @@
     time_t expires;
     time_t lastmod;
     uint64_t swap_file_sz;
-    u_short refcount;
-    u_short flags;
+    uint16_t refcount;
+    uint16_t flags;
     /* END OF ON-DISK STORE_META_STD */
 
     sfileno swap_filen:25;
 
     sdirno swap_dirn:7;
 
-    u_short lock_count;		/* Assume < 65536! */
+    unsigned short lock_count;		/* Assume < 65536! */
 
     mem_status_t mem_status:3;
 
diff -u -r -N squid-3.1.14/src/StoreMeta.h squid-3.1.15/src/StoreMeta.h
--- squid-3.1.14/src/StoreMeta.h	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/src/StoreMeta.h	2011-08-28 19:53:14.000000000 +1200
@@ -101,9 +101,9 @@
         time_t lastref;
         time_t expires;
         time_t lastmod;
-        size_t swap_file_sz;
-        u_short refcount;
-        u_short flags;
+        uint64_t swap_file_sz;
+        uint16_t refcount;
+        uint16_t flags;
      \endcode
      */
     STORE_META_STD,
diff -u -r -N squid-3.1.14/src/StoreSwapLogData.h squid-3.1.15/src/StoreSwapLogData.h
--- squid-3.1.14/src/StoreSwapLogData.h	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/src/StoreSwapLogData.h	2011-08-28 19:53:14.000000000 +1200
@@ -146,14 +146,14 @@
      * Since its a 16-bit quantity, it is susceptible to overflow
      * if a single object is accessed 65,536 times before being replaced.
      */
-    u_short refcount;
+    uint16_t refcount;
 
     /**
      * A copy of the StoreEntry flags field. Used as a sanity
      * check when rebuilding the cache at startup. Objects that
      * have the KEY_PRIVATE flag set are not added back to the cache.
      */
-    u_short flags;
+    uint16_t flags;
 
     /**
      * The 128-bit MD5 hash for this object.
diff -u -r -N squid-3.1.14/src/structs.h squid-3.1.15/src/structs.h
--- squid-3.1.14/src/structs.h	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/src/structs.h	2011-08-28 19:53:14.000000000 +1200
@@ -105,7 +105,7 @@
 };
 
 struct ushortlist {
-    u_short i;
+    unsigned short i;
     ushortlist *next;
 };
 
@@ -192,14 +192,14 @@
     acl_size_t *ReplyBodySize;
 
     struct {
-        u_short icp;
+        unsigned short icp;
 #if USE_HTCP
 
-        u_short htcp;
+        unsigned short htcp;
 #endif
 #if SQUID_SNMP
 
-        u_short snmp;
+        unsigned short snmp;
 #endif
     } Port;
 
@@ -332,7 +332,7 @@
         char *host;
         char *file;
         time_t period;
-        u_short port;
+        unsigned short port;
     } Announce;
 
     struct {
@@ -848,18 +848,18 @@
     struct {
         int version;
         int counts[ICP_END+1];
-        u_short port;
+        unsigned short port;
     } icp;
 
 #if USE_HTCP
     struct {
         double version;
         int counts[2];
-        u_short port;
+        unsigned short port;
     } htcp;
 #endif
 
-    u_short http_port;
+    unsigned short http_port;
     domain_ping *peer_domain;
     domain_type *typelist;
     acl_access *access;
diff -u -r -N squid-3.1.14/src/tests/stub_cache_cf.cc squid-3.1.15/src/tests/stub_cache_cf.cc
--- squid-3.1.14/src/tests/stub_cache_cf.cc	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/src/tests/stub_cache_cf.cc	2011-08-28 19:53:14.000000000 +1200
@@ -104,7 +104,7 @@
 }
 
 void
-ConfigParser::ParseUShort(u_short *var)
+ConfigParser::ParseUShort(unsigned short *var)
 {
     fatal("not implemented 10");
 }
diff -u -r -N squid-3.1.14/src/tests/testHttpRequest.cc squid-3.1.15/src/tests/testHttpRequest.cc
--- squid-3.1.14/src/tests/testHttpRequest.cc	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/src/tests/testHttpRequest.cc	2011-08-28 19:53:14.000000000 +1200
@@ -43,7 +43,7 @@
 testHttpRequest::testCreateFromUrlAndMethod()
 {
     /* vanilla url */
-    ushort expected_port;
+    unsigned short expected_port;
     char * url = xstrdup("http://foo:90/bar");
     HttpRequest *aRequest = HttpRequest::CreateFromUrlAndMethod(url, METHOD_GET);
     expected_port = 90;
@@ -93,7 +93,7 @@
 testHttpRequest::testCreateFromUrl()
 {
     /* vanilla url */
-    ushort expected_port;
+    unsigned short expected_port;
     char * url = xstrdup("http://foo:90/bar");
     HttpRequest *aRequest = HttpRequest::CreateFromUrl(url);
     expected_port = 90;
@@ -112,7 +112,7 @@
 void
 testHttpRequest::testIPv6HostColonBug()
 {
-    ushort expected_port;
+    unsigned short expected_port;
     char * url = NULL;
     HttpRequest *aRequest = NULL;
 
diff -u -r -N squid-3.1.14/src/tunnel.cc squid-3.1.15/src/tunnel.cc
--- squid-3.1.14/src/tunnel.cc	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/src/tunnel.cc	2011-08-28 19:53:14.000000000 +1200
@@ -64,7 +64,7 @@
     bool noConnections() const;
     char *url;
     char *host;			/* either request->host or proxy host */
-    u_short port;
+    unsigned short port;
     HttpRequest *request;
     FwdServer *servers;
 
@@ -470,7 +470,7 @@
     if (tunnelState->servers) {
         if (tunnelState->servers->_peer)
             hierarchyNote(&tunnelState->request->hier, tunnelState->servers->code,
-                          tunnelState->servers->_peer->host);
+                          tunnelState->servers->_peer->name);
         else if (Config.onoff.log_ip_on_direct)
             hierarchyNote(&tunnelState->request->hier, tunnelState->servers->code,
                           fd_table[tunnelState->server.fd()].ipaddr);
@@ -560,7 +560,7 @@
 
     if (tunnelState->servers->_peer)
         hierarchyNote(&tunnelState->request->hier, tunnelState->servers->code,
-                      tunnelState->servers->_peer->host);
+                      tunnelState->servers->_peer->name);
     else if (Config.onoff.log_ip_on_direct)
         hierarchyNote(&tunnelState->request->hier, tunnelState->servers->code,
                       fd_table[tunnelState->server.fd()].ipaddr);
diff -u -r -N squid-3.1.14/src/ufsdump.cc squid-3.1.15/src/ufsdump.cc
--- squid-3.1.14/src/ufsdump.cc	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/src/ufsdump.cc	2011-08-28 19:53:14.000000000 +1200
@@ -104,8 +104,8 @@
     time_t expires;
     time_t lastmod;
     size_t swap_file_sz;
-    u_short refcount;
-    u_short flags;
+    uint16_t refcount;
+    uint16_t flags;
 };
 
 struct MetaStdLfs {
@@ -114,8 +114,8 @@
     time_t expires;
     time_t lastmod;
     uint64_t swap_file_sz;
-    u_short refcount;
-    u_short flags;
+    uint16_t refcount;
+    uint16_t flags;
 };
 
 struct DumpStoreMeta : public unary_function<StoreMeta, void> {
diff -u -r -N squid-3.1.14/src/url.cc squid-3.1.15/src/url.cc
--- squid-3.1.14/src/url.cc	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/src/url.cc	2011-08-28 19:53:14.000000000 +1200
@@ -446,7 +446,7 @@
 
     request->SetHost(host);
     xstrncpy(request->login, login, MAX_LOGIN_SZ);
-    request->port = (u_short) port;
+    request->port = (unsigned short) port;
     return request;
 }
 
diff -u -r -N squid-3.1.14/src/wccp2.cc squid-3.1.15/src/wccp2.cc
--- squid-3.1.14/src/wccp2.cc	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/src/wccp2.cc	2011-08-28 19:53:14.000000000 +1200
@@ -1633,7 +1633,7 @@
     int router_len;
     int bucket_counter;
     uint32_t service_flags;
-    u_short port = WCCP_PORT;
+    unsigned short port = WCCP_PORT;
 
     /* Packet segments */
 
diff -u -r -N squid-3.1.14/src/wccp.cc squid-3.1.15/src/wccp.cc
--- squid-3.1.14/src/wccp.cc	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/src/wccp.cc	2011-08-28 19:53:14.000000000 +1200
@@ -347,7 +347,7 @@
 
     buckets = buf + wab_len + cache_len;
 
-    memset(wccp_assign_bucket, '\0', sizeof(wccp_assign_bucket));
+    memset(wccp_assign_bucket, '\0', sizeof(*wccp_assign_bucket));
 
     memset(buckets, 0xFF, WCCP_BUCKETS);
 
diff -u -r -N squid-3.1.14/test-suite/Makefile.in squid-3.1.15/test-suite/Makefile.in
--- squid-3.1.14/test-suite/Makefile.in	2011-07-04 16:39:58.000000000 +1200
+++ squid-3.1.15/test-suite/Makefile.in	2011-08-28 19:53:53.000000000 +1200
@@ -218,6 +218,7 @@
 FALSE = @FALSE@
 FGREP = @FGREP@
 GREP = @GREP@
+HOSTCXX = @HOSTCXX@
 ICAP_LIBS = @ICAP_LIBS@
 INCLTDL = @INCLTDL@
 INSTALL = @INSTALL@
diff -u -r -N squid-3.1.14/test-suite/refcount.cc squid-3.1.15/test-suite/refcount.cc
--- squid-3.1.14/test-suite/refcount.cc	2011-07-04 16:38:34.000000000 +1200
+++ squid-3.1.15/test-suite/refcount.cc	2011-08-28 19:53:14.000000000 +1200
@@ -139,6 +139,8 @@
     {
         ToRefCount anObject (new _ToRefCount);
         _ToRefCount *aPointer = anObject.getRaw();
+        if (aPointer == NULL)
+            exit(3);
         aPointer = NULL;
     }
     /* Create a doubley inheriting refcount instance,
diff -u -r -N squid-3.1.14/tools/Makefile.in squid-3.1.15/tools/Makefile.in
--- squid-3.1.14/tools/Makefile.in	2011-07-04 16:39:59.000000000 +1200
+++ squid-3.1.15/tools/Makefile.in	2011-08-28 19:53:54.000000000 +1200
@@ -220,6 +220,7 @@
 FALSE = @FALSE@
 FGREP = @FGREP@
 GREP = @GREP@
+HOSTCXX = @HOSTCXX@
 ICAP_LIBS = @ICAP_LIBS@
 INCLTDL = @INCLTDL@
 INSTALL = @INSTALL@
