[apr] 01/01: Upstream tarball 1.6.3

Stefan Fritsch sf at moszumanska.debian.org
Mon Nov 6 19:11:51 UTC 2017


This is an automated email from the git hooks/post-receive script.

sf pushed a commit to branch upstream
in repository apr.

commit 199399ebfa3fa517d4b73d38d2a04761bd68d750
Author: Stefan Fritsch <sf at sfritsch.de>
Date:   Mon Nov 6 19:50:48 2017 +0100

    Upstream tarball 1.6.3
---
 CHANGES                                   |  13 ++
 apr.spec                                  |   2 +-
 build/buildcheck.sh                       |  78 ++++-----
 build/config.guess                        |  62 +++-----
 build/config.sub                          |  20 +--
 build/fixwin32mak.pl                      |   2 +-
 configure                                 |  25 +++
 configure.in                              |   5 +
 docs/pool-design.html                     |   4 -
 file_io/unix/seek.c                       |   7 +
 file_io/win32/pipe.c                      |   2 +-
 file_io/win32/seek.c                      |  34 +++-
 include/apr_version.h                     |   4 +-
 include/arch/unix/apr_arch_poll_private.h |   4 +-
 network_io/unix/sockaddr.c                |  18 +--
 poll/unix/epoll.c                         |   8 +-
 poll/unix/kqueue.c                        |   8 +-
 poll/unix/poll.c                          |   8 +-
 poll/unix/pollcb.c                        |  14 +-
 poll/unix/pollset.c                       |  20 +--
 poll/unix/port.c                          |   8 +-
 poll/unix/select.c                        |   4 +-
 poll/unix/z_asio.c                        |   4 +-
 test/testfile.c                           | 252 ++++++++++++++++++++++++++++++
 test/testipsub.c                          |   1 +
 time/unix/time.c                          |   3 +
 time/win32/time.c                         |   6 +
 27 files changed, 466 insertions(+), 150 deletions(-)

diff --git a/CHANGES b/CHANGES
index d83cc35..69181f2 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,4 +1,17 @@
                                                      -*- coding: utf-8 -*-
+Changes for APR 1.6.3
+
+  *) apr_file_trunc: Truncating a buffered file could add unexpected
+     data after the truncate position. PR 51017.
+     [Evgeny Kotkov <evgeny.kotkov visualsvn.com>]
+
+  *) apr_file_trunc: Fix an issue where reading from a buffered file
+     after truncate could return stale data from the buffer.
+     [Evgeny Kotkov <evgeny.kotkov visualsvn.com>]
+
+  *) apr_ipsubnet_create() now fails for an empty input string.
+     [Joe Orton]
+
 Changes for APR 1.6.2
 
   *) Corrected non-Unix builds for APR_LOCK_DEFAULT.
diff --git a/apr.spec b/apr.spec
index cdc7da9..2b74600 100644
--- a/apr.spec
+++ b/apr.spec
@@ -3,7 +3,7 @@
 
 Summary: Apache Portable Runtime library
 Name: apr
-Version: 1.6.2
+Version: 1.6.3
 Release: 1
 License: Apache Software License
 Group: System Environment/Libraries
diff --git a/build/buildcheck.sh b/build/buildcheck.sh
index 532602e..ab5df44 100755
--- a/build/buildcheck.sh
+++ b/build/buildcheck.sh
@@ -1,35 +1,37 @@
 #! /bin/sh
 
 echo "buildconf: checking installation..."
+res=0
 
 # any python
 python=`build/PrintPath python`
 if test -z "$python"; then
-echo "buildconf: python not found."
-echo "           You need python installed"
-echo "           to build APR from SVN."
-exit 1
+  echo "buildconf: python not found."
+  echo "           You need python installed"
+  echo "           to build APR from SVN."
+  res=1
 else
-py_version=`python -c 'import sys; print sys.version' 2>&1|sed 's/ .*//;q'`
-echo "buildconf: python version $py_version (ok)"
+  py_version=`python -c 'import sys; print sys.version' 2>&1|sed 's/ .*//;q'`
+  echo "buildconf: python version $py_version (ok)"
 fi
 
 # autoconf 2.59 or newer
 ac_version=`${AUTOCONF:-autoconf} --version 2>/dev/null|sed -e 's/^[^0-9]*//;s/[a-z]* *$//;q'`
 if test -z "$ac_version"; then
-echo "buildconf: autoconf not found."
-echo "           You need autoconf version 2.59 or newer installed"
-echo "           to build APR from SVN."
-exit 1
-fi
-IFS=.; set $ac_version; IFS=' '
-if test "$1" = "2" -a "$2" -lt "59" || test "$1" -lt "2"; then
-echo "buildconf: autoconf version $ac_version found."
-echo "           You need autoconf version 2.59 or newer installed"
-echo "           to build APR from SVN."
-exit 1
+  echo "buildconf: autoconf not found."
+  echo "           You need autoconf version 2.59 or newer installed"
+  echo "           to build APR from SVN."
+  res=1
 else
-echo "buildconf: autoconf version $ac_version (ok)"
+  IFS=.; set $ac_version; IFS=' '
+  if test "$1" = "2" -a "$2" -lt "59" || test "$1" -lt "2"; then
+    echo "buildconf: autoconf version $ac_version found."
+    echo "           You need autoconf version 2.59 or newer installed"
+    echo "           to build APR from SVN."
+    res=1
+  else
+    echo "buildconf: autoconf version $ac_version (ok)"
+  fi
 fi
 
 # Sample libtool --version outputs:
@@ -41,26 +43,28 @@ fi
 libtool=`build/PrintPath glibtool1 glibtool libtool libtool15 libtool14`
 lt_pversion=`$libtool --version 2>/dev/null|sed -e 's/([^)]*)//g;s/^[^0-9]*//;s/[- ].*//g;q'`
 if test -z "$lt_pversion"; then
-echo "buildconf: libtool not found."
-echo "           You need libtool version 1.4 or newer installed"
-echo "           to build APR from SVN."
-exit 1
-fi
-lt_version=`echo $lt_pversion|sed -e 's/\([a-z]*\)$/.\1/'`
-IFS=.; set $lt_version; IFS=' '
-lt_status="good"
-if test "$1" = "1"; then
-   if test "$2" -lt "4"; then
+  echo "buildconf: libtool not found."
+  echo "           You need libtool version 1.4 or newer installed"
+  echo "           to build APR from SVN."
+  res=1
+else
+  lt_version=`echo $lt_pversion|sed -e 's/\([a-z]*\)$/.\1/'`
+  IFS=.; set $lt_version; IFS=' '
+  lt_status="good"
+  if test "$1" = "1"; then
+    if test "$2" -lt "4"; then
       lt_status="bad"
-   fi
-fi
-if test $lt_status = "good"; then
-   echo "buildconf: libtool version $lt_pversion (ok)"
-   exit 0
+    fi
+  fi
+  if test $lt_status = "good"; then
+    echo "buildconf: libtool version $lt_pversion (ok)"
+  else
+    echo "buildconf: libtool version $lt_pversion found."
+    echo "           You need libtool version 1.4 or newer installed"
+    echo "           to build APR from SVN."
+    res=1
+  fi
 fi
 
-echo "buildconf: libtool version $lt_pversion found."
-echo "           You need libtool version 1.4 or newer installed"
-echo "           to build APR from SVN."
+exit $res
 
-exit 1
diff --git a/build/config.guess b/build/config.guess
index 69ed3e5..8bd1095 100755
--- a/build/config.guess
+++ b/build/config.guess
@@ -2,7 +2,7 @@
 # Attempt to guess a canonical system name.
 #   Copyright 1992-2017 Free Software Foundation, Inc.
 
-timestamp='2017-03-05'
+timestamp='2017-09-16'
 
 # This file is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by
@@ -15,7 +15,7 @@ timestamp='2017-03-05'
 # General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
-# along with this program; if not, see <http://www.gnu.org/licenses/>.
+# along with this program; if not, see <https://www.gnu.org/licenses/>.
 #
 # As a special exception to the GNU General Public License, if you
 # distribute this file as part of a program that contains a
@@ -27,7 +27,7 @@ timestamp='2017-03-05'
 # Originally written by Per Bothner; maintained since 2000 by Ben Elliston.
 #
 # You can get the latest version of this script from:
-# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess
+# https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess
 #
 # Please send patches to <config-patches at gnu.org>.
 
@@ -259,6 +259,9 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
     *:Sortix:*:*)
 	echo ${UNAME_MACHINE}-unknown-sortix
 	exit ;;
+    *:Redox:*:*)
+	echo ${UNAME_MACHINE}-unknown-redox
+	exit ;;
     alpha:OSF1:*:*)
 	case $UNAME_RELEASE in
 	*4.0)
@@ -315,15 +318,6 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
 	exitcode=$?
 	trap '' 0
 	exit $exitcode ;;
-    Alpha\ *:Windows_NT*:*)
-	# How do we know it's Interix rather than the generic POSIX subsystem?
-	# Should we change UNAME_MACHINE based on the output of uname instead
-	# of the specific Alpha model?
-	echo alpha-pc-interix
-	exit ;;
-    21064:Windows_NT:50:3)
-	echo alpha-dec-winnt3.5
-	exit ;;
     Amiga*:UNIX_System_V:4.0:*)
 	echo m68k-unknown-sysv4
 	exit ;;
@@ -855,10 +849,6 @@ EOF
     *:MSYS*:*)
 	echo ${UNAME_MACHINE}-pc-msys
 	exit ;;
-    i*:windows32*:*)
-	# uname -m includes "-pc" on this system.
-	echo ${UNAME_MACHINE}-mingw32
-	exit ;;
     i*:PW*:*)
 	echo ${UNAME_MACHINE}-pc-pw32
 	exit ;;
@@ -874,27 +864,12 @@ EOF
 		echo ia64-unknown-interix${UNAME_RELEASE}
 		exit ;;
 	esac ;;
-    [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
-	echo i${UNAME_MACHINE}-pc-mks
-	exit ;;
-    8664:Windows_NT:*)
-	echo x86_64-pc-mks
-	exit ;;
-    i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
-	# How do we know it's Interix rather than the generic POSIX subsystem?
-	# It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
-	# UNAME_MACHINE based on the output of uname instead of i386?
-	echo i586-pc-interix
-	exit ;;
     i*:UWIN*:*)
 	echo ${UNAME_MACHINE}-pc-uwin
 	exit ;;
     amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
 	echo x86_64-unknown-cygwin
 	exit ;;
-    p*:CYGWIN*:*)
-	echo powerpcle-unknown-cygwin
-	exit ;;
     prep*:SunOS:5.*:*)
 	echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
 	exit ;;
@@ -1304,14 +1279,21 @@ EOF
 	if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then
 	    if [ "$CC_FOR_BUILD" != no_compiler_found ]; then
 		if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
-		    (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
-		    grep IS_64BIT_ARCH >/dev/null
+		       (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
+		       grep IS_64BIT_ARCH >/dev/null
 		then
 		    case $UNAME_PROCESSOR in
 			i386) UNAME_PROCESSOR=x86_64 ;;
 			powerpc) UNAME_PROCESSOR=powerpc64 ;;
 		    esac
 		fi
+		# On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc
+		if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \
+		       (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
+		       grep IS_PPC >/dev/null
+		then
+		    UNAME_PROCESSOR=powerpc
+		fi
 	    fi
 	elif test "$UNAME_PROCESSOR" = i386 ; then
 	    # Avoid executing cc on OS X 10.9, as it ships with a stub
@@ -1335,16 +1317,16 @@ EOF
     *:QNX:*:4*)
 	echo i386-pc-qnx
 	exit ;;
-    NEO-?:NONSTOP_KERNEL:*:*)
+    NEO-*:NONSTOP_KERNEL:*:*)
 	echo neo-tandem-nsk${UNAME_RELEASE}
 	exit ;;
     NSE-*:NONSTOP_KERNEL:*:*)
 	echo nse-tandem-nsk${UNAME_RELEASE}
 	exit ;;
-    NSR-?:NONSTOP_KERNEL:*:*)
+    NSR-*:NONSTOP_KERNEL:*:*)
 	echo nsr-tandem-nsk${UNAME_RELEASE}
 	exit ;;
-    NSX-?:NONSTOP_KERNEL:*:*)
+    NSX-*:NONSTOP_KERNEL:*:*)
 	echo nsx-tandem-nsk${UNAME_RELEASE}
 	exit ;;
     *:NonStop-UX:*:*)
@@ -1422,12 +1404,12 @@ cat >&2 <<EOF
 $0: unable to guess system type
 
 This script (version $timestamp), has failed to recognize the
-operating system you are using. If your script is old, overwrite
-config.guess and config.sub with the latest versions from:
+operating system you are using. If your script is old, overwrite *all*
+copies of config.guess and config.sub with the latest versions from:
 
-  http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess
+  https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess
 and
-  http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub
+  https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub
 
 If $0 has already been updated, send the following data and any
 information you think might be pertinent to config-patches at gnu.org to
diff --git a/build/config.sub b/build/config.sub
index 40ea5df..95dc3d0 100755
--- a/build/config.sub
+++ b/build/config.sub
@@ -2,7 +2,7 @@
 # Configuration validation subroutine script.
 #   Copyright 1992-2017 Free Software Foundation, Inc.
 
-timestamp='2017-04-02'
+timestamp='2017-09-16'
 
 # This file is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by
@@ -15,7 +15,7 @@ timestamp='2017-04-02'
 # General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
-# along with this program; if not, see <http://www.gnu.org/licenses/>.
+# along with this program; if not, see <https://www.gnu.org/licenses/>.
 #
 # As a special exception to the GNU General Public License, if you
 # distribute this file as part of a program that contains a
@@ -33,7 +33,7 @@ timestamp='2017-04-02'
 # Otherwise, we print the canonical config type on stdout and succeed.
 
 # You can get the latest version of this script from:
-# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub
+# https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub
 
 # This file is supposed to be the same for all GNU packages
 # and recognize all the CPU types, system types and aliases
@@ -229,9 +229,6 @@ case $os in
 	-ptx*)
 		basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
 		;;
-	-windowsnt*)
-		os=`echo $os | sed -e 's/windowsnt/winnt/'`
-		;;
 	-psos*)
 		os=-psos
 		;;
@@ -1259,6 +1256,9 @@ case $basic_machine in
 		basic_machine=hppa1.1-winbond
 		os=-proelf
 		;;
+	x64)
+		basic_machine=x86_64-pc
+		;;
 	xbox)
 		basic_machine=i686-pc
 		os=-mingw32
@@ -1366,8 +1366,8 @@ esac
 if [ x"$os" != x"" ]
 then
 case $os in
-	# First match some system type aliases
-	# that might get confused with valid system types.
+	# First match some system type aliases that might get confused
+	# with valid system types.
 	# -solaris* is a basic system type, with this one exception.
 	-auroraux)
 		os=-auroraux
@@ -1387,9 +1387,9 @@ case $os in
 	-gnu/linux*)
 		os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
 		;;
-	# First accept the basic system types.
+	# Now accept the basic system types.
 	# The portable systems comes first.
-	# Each alternative MUST END IN A *, to match a version number.
+	# Each alternative MUST end in a * to match a version number.
 	# -sysv* is not here because it comes later, after sysvr4.
 	-gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
 	      | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\
diff --git a/build/fixwin32mak.pl b/build/fixwin32mak.pl
index 49853b3..76b7f00 100644
--- a/build/fixwin32mak.pl
+++ b/build/fixwin32mak.pl
@@ -140,7 +140,7 @@ sub fixcwd {
         $dstfl = new IO::File $tname, "w" || die;
         while ($src = <$srcfl>) {
             if (($src =~ m/^\t"(\.\.\\)+(apr|apr-util|apr-iconv)\\.*"\\/) || 
-                ($src =~ m/^\t{\$\(INCLUDE\)}".*"\\/)) {
+                ($src =~ m/^\t\{\$\(INCLUDE\)\}".*"\\/)) {
                 $verchg = -1;
             }
             else {
diff --git a/configure b/configure
index f2714d7..35a5838 100755
--- a/configure
+++ b/configure
@@ -18496,6 +18496,31 @@ if test "${enable_maintainer_mode+set}" = set; then :
     done
   fi
 
+      case `($CC --version) 2>/dev/null` in
+        *clang-900* | *"clang version 5.0.0"*)
+
+  if test "x$CFLAGS" = "x"; then
+    test "x$silent" != "xyes" && echo "  setting CFLAGS to \"-Wno-error=strict-prototypes\""
+    CFLAGS="-Wno-error=strict-prototypes"
+  else
+    apr_addto_bugger="-Wno-error=strict-prototypes"
+    for i in $apr_addto_bugger; do
+      apr_addto_duplicate="0"
+      for j in $CFLAGS; do
+        if test "x$i" = "x$j"; then
+          apr_addto_duplicate="1"
+          break
+        fi
+      done
+      if test $apr_addto_duplicate = "0"; then
+        test "x$silent" != "xyes" && echo "  adding \"$i\" to CFLAGS"
+        CFLAGS="$CFLAGS $i"
+      fi
+    done
+  fi
+
+          ;;
+      esac
    elif test "$AIX_XLC" = "yes"; then
 
   if test "x$CFLAGS" = "x"; then
diff --git a/configure.in b/configure.in
index 927e1e6..719f331 100644
--- a/configure.in
+++ b/configure.in
@@ -346,6 +346,11 @@ AC_ARG_ENABLE(maintainer-mode,[  --enable-maintainer-mode  Turn on debugging and
   [APR_ADDTO(CFLAGS,-g)
    if test "$GCC" = "yes"; then
      APR_ADDTO(CFLAGS,[-Wall -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations])
+      case `($CC --version) 2>/dev/null` in
+        *clang-900* | *"clang version 5.0.0"*)
+          APR_ADDTO(CFLAGS,[-Wno-error=strict-prototypes])
+          ;;
+      esac
    elif test "$AIX_XLC" = "yes"; then
      APR_ADDTO(CFLAGS,-qfullpath -qinitauto=FE -qcheck=all -qinfo=pro)
    fi
diff --git a/docs/pool-design.html b/docs/pool-design.html
index 907b789..46b63d6 100644
--- a/docs/pool-design.html
+++ b/docs/pool-design.html
@@ -3,10 +3,6 @@
     <title>Using APR Pools</title>
   </head>
   <body>
-    <div align="right">
-      Last modified at [$Date: 2017-04-04 08:09:00 -0500 (Tue, 04 Apr 2017) $]
-    </div>
-
     <h1>Using APR Pools</h1>
 
     <p>
diff --git a/file_io/unix/seek.c b/file_io/unix/seek.c
index 3f5aa00..2e97337 100644
--- a/file_io/unix/seek.c
+++ b/file_io/unix/seek.c
@@ -117,6 +117,13 @@ apr_status_t apr_file_trunc(apr_file_t *fp, apr_off_t offset)
             /* Reset buffer positions for write mode */
             fp->bufpos = fp->direction = fp->dataRead = 0;
         }
+        else if (fp->direction == 0) {
+            /* Discard the read buffer, as we are about to reposition
+             * ourselves to the end of file.
+             */
+            fp->bufpos = 0;
+            fp->dataRead = 0;
+        }
         file_unlock(fp);
         if (rc) {
             return rc;
diff --git a/file_io/win32/pipe.c b/file_io/win32/pipe.c
index 8087fe1..dd8ef13 100644
--- a/file_io/win32/pipe.c
+++ b/file_io/win32/pipe.c
@@ -76,7 +76,7 @@ APR_DECLARE(apr_status_t) apr_file_pipe_create_ex(apr_file_t **in,
                                                   apr_int32_t blocking,
                                                   apr_pool_t *p)
 {
-    return apr_file_pipe_create_pools(in, out, APR_FULL_BLOCK, p, p);
+    return apr_file_pipe_create_pools(in, out, blocking, p, p);
 }
 
 APR_DECLARE(apr_status_t) apr_file_pipe_create_pools(apr_file_t **in,
diff --git a/file_io/win32/seek.c b/file_io/win32/seek.c
index b412fd4..afe6edb 100644
--- a/file_io/win32/seek.c
+++ b/file_io/win32/seek.c
@@ -161,17 +161,43 @@ APR_DECLARE(apr_status_t) apr_file_trunc(apr_file_t *thefile, apr_off_t offset)
     LONG  offhi = (LONG)(offset >> 32);
     DWORD rc;
 
+    if (thefile->buffered) {
+        if (thefile->direction == 1) {
+            /* Figure out what needs to be flushed.  Don't flush the part
+             * of the write buffer that will get truncated anyway.
+             */
+            if (offset < thefile->filePtr) {
+                thefile->bufpos = 0;
+            }
+            else if (offset < thefile->filePtr + (apr_off_t)thefile->bufpos) {
+                thefile->bufpos = offset - thefile->filePtr;
+            }
+
+            if (thefile->bufpos != 0) {
+                rv = apr_file_flush(thefile);
+                if (rv != APR_SUCCESS)
+                    return rv;
+            }
+        }
+        else if (thefile->direction == 0) {
+            /* Discard the read buffer, as we are about to reposition
+             * ourselves to the end of file.
+             */
+            thefile->bufpos = 0;
+            thefile->dataRead = 0;
+        }
+    }
+
     rc = SetFilePointer(thefile->filehand, offlo, &offhi, FILE_BEGIN);
     if (rc == 0xFFFFFFFF)
         if ((rv = apr_get_os_error()) != APR_SUCCESS)
             return rv;
+    thefile->filePtr = offset;
+    /* Don't report EOF until the next read. */
+    thefile->eof_hit = 0;
 
     if (!SetEndOfFile(thefile->filehand))
         return apr_get_os_error();
 
-    if (thefile->buffered) {
-        return setptr(thefile, offset);
-    }
-
     return APR_SUCCESS;
 }
diff --git a/include/apr_version.h b/include/apr_version.h
index 1b33bb5..65935b3 100644
--- a/include/apr_version.h
+++ b/include/apr_version.h
@@ -62,14 +62,14 @@
  * The Patch Level never includes API changes, simply bug fixes.
  * Reset to 0 when upgrading APR_MINOR_VERSION
  */
-#define APR_PATCH_VERSION       2
+#define APR_PATCH_VERSION       3
 
 /** 
  * The symbol APR_IS_DEV_VERSION is only defined for internal,
  * "development" copies of APR.  It is undefined for released versions
  * of APR.
  */
-/* #define APR_IS_DEV_VERSION */
+/* #undef APR_IS_DEV_VERSION */
 
 /**
  * Check at compile time if the APR version is at least a certain
diff --git a/include/arch/unix/apr_arch_poll_private.h b/include/arch/unix/apr_arch_poll_private.h
index 5c50e98..ff81312 100644
--- a/include/arch/unix/apr_arch_poll_private.h
+++ b/include/arch/unix/apr_arch_poll_private.h
@@ -126,7 +126,7 @@ struct apr_pollset_t
     apr_file_t *wakeup_pipe[2];
     apr_pollfd_t wakeup_pfd;
     apr_pollset_private_t *p;
-    apr_pollset_provider_t *provider;
+    const apr_pollset_provider_t *provider;
 };
 
 typedef union {
@@ -156,7 +156,7 @@ struct apr_pollcb_t {
     int fd;
     apr_pollcb_pset pollset;
     apr_pollfd_t **copyset;
-    apr_pollcb_provider_t *provider;
+    const apr_pollcb_provider_t *provider;
 };
 
 struct apr_pollset_provider_t {
diff --git a/network_io/unix/sockaddr.c b/network_io/unix/sockaddr.c
index 1500861..8cfc0d7 100644
--- a/network_io/unix/sockaddr.c
+++ b/network_io/unix/sockaddr.c
@@ -277,19 +277,13 @@ APR_DECLARE(apr_status_t) apr_parse_addr_port(char **addr,
                 return APR_EINVAL;
             }
             addrlen = scope_delim - str - 1;
-            *scope_id = apr_palloc(p, end_bracket - scope_delim);
-            memcpy(*scope_id, scope_delim + 1, end_bracket - scope_delim - 1);
-            (*scope_id)[end_bracket - scope_delim - 1] = '\0';
+            *scope_id = apr_pstrmemdup(p, scope_delim, end_bracket - scope_delim - 1);
         }
         else {
             addrlen = addrlen - 2; /* minus 2 for '[' and ']' */
         }
 
-        *addr = apr_palloc(p, addrlen + 1);
-        memcpy(*addr,
-               str + 1,
-               addrlen);
-        (*addr)[addrlen] = '\0';
+        *addr = apr_pstrmemdup(p, str + 1, addrlen);
         if (apr_inet_pton(AF_INET6, *addr, &ipaddr) != 1) {
             *addr = NULL;
             *scope_id = NULL;
@@ -303,9 +297,7 @@ APR_DECLARE(apr_status_t) apr_parse_addr_port(char **addr,
         /* XXX If '%' is not a valid char in a DNS name, we *could* check 
          *     for bogus scope ids first.
          */
-        *addr = apr_palloc(p, addrlen + 1);
-        memcpy(*addr, str, addrlen);
-        (*addr)[addrlen] = '\0';
+        *addr = apr_pstrmemdup(p, str, addrlen);
     }
     return APR_SUCCESS;
 }
@@ -1062,6 +1054,10 @@ static apr_status_t parse_ip(apr_ipsubnet_t *ipsub, const char *ipstr, int netwo
 
 static int looks_like_ip(const char *ipstr)
 {
+    if (strlen(ipstr) == 0) {
+        return 0;
+    }
+    
     if (strchr(ipstr, ':')) {
         /* definitely not a hostname; assume it is intended to be an IPv6 address */
         return 1;
diff --git a/poll/unix/epoll.c b/poll/unix/epoll.c
index af10145..02db48a 100644
--- a/poll/unix/epoll.c
+++ b/poll/unix/epoll.c
@@ -320,7 +320,7 @@ static apr_status_t impl_pollset_poll(apr_pollset_t *pollset,
     return rv;
 }
 
-static apr_pollset_provider_t impl = {
+static const apr_pollset_provider_t impl = {
     impl_pollset_create,
     impl_pollset_add,
     impl_pollset_remove,
@@ -329,7 +329,7 @@ static apr_pollset_provider_t impl = {
     "epoll"
 };
 
-apr_pollset_provider_t *apr_pollset_provider_epoll = &impl;
+const apr_pollset_provider_t *const apr_pollset_provider_epoll = &impl;
 
 static apr_status_t impl_pollcb_cleanup(apr_pollcb_t *pollcb)
 {
@@ -476,7 +476,7 @@ static apr_status_t impl_pollcb_poll(apr_pollcb_t *pollcb,
     return rv;
 }
 
-static apr_pollcb_provider_t impl_cb = {
+static const apr_pollcb_provider_t impl_cb = {
     impl_pollcb_create,
     impl_pollcb_add,
     impl_pollcb_remove,
@@ -485,6 +485,6 @@ static apr_pollcb_provider_t impl_cb = {
     "epoll"
 };
 
-apr_pollcb_provider_t *apr_pollcb_provider_epoll = &impl_cb;
+const apr_pollcb_provider_t *const apr_pollcb_provider_epoll = &impl_cb;
 
 #endif /* HAVE_EPOLL */
diff --git a/poll/unix/kqueue.c b/poll/unix/kqueue.c
index d804349..6a0ae61 100644
--- a/poll/unix/kqueue.c
+++ b/poll/unix/kqueue.c
@@ -316,7 +316,7 @@ static apr_status_t impl_pollset_poll(apr_pollset_t *pollset,
     return rv;
 }
 
-static apr_pollset_provider_t impl = {
+static const apr_pollset_provider_t impl = {
     impl_pollset_create,
     impl_pollset_add,
     impl_pollset_remove,
@@ -325,7 +325,7 @@ static apr_pollset_provider_t impl = {
     "kqueue"
 };
 
-apr_pollset_provider_t *apr_pollset_provider_kqueue = &impl;
+const apr_pollset_provider_t *apr_pollset_provider_kqueue = &impl;
 
 static apr_status_t impl_pollcb_cleanup(apr_pollcb_t *pollcb)
 {
@@ -491,7 +491,7 @@ static apr_status_t impl_pollcb_poll(apr_pollcb_t *pollcb,
     return rv;
 }
 
-static apr_pollcb_provider_t impl_cb = {
+static const apr_pollcb_provider_t impl_cb = {
     impl_pollcb_create,
     impl_pollcb_add,
     impl_pollcb_remove,
@@ -500,6 +500,6 @@ static apr_pollcb_provider_t impl_cb = {
     "kqueue"
 };
 
-apr_pollcb_provider_t *apr_pollcb_provider_kqueue = &impl_cb;
+const apr_pollcb_provider_t *apr_pollcb_provider_kqueue = &impl_cb;
 
 #endif /* HAVE_KQUEUE */
diff --git a/poll/unix/poll.c b/poll/unix/poll.c
index d8989aa..f148f5e 100644
--- a/poll/unix/poll.c
+++ b/poll/unix/poll.c
@@ -299,7 +299,7 @@ static apr_status_t impl_pollset_poll(apr_pollset_t *pollset,
     return rv;
 }
 
-static apr_pollset_provider_t impl = {
+static const apr_pollset_provider_t impl = {
     impl_pollset_create,
     impl_pollset_add,
     impl_pollset_remove,
@@ -308,7 +308,7 @@ static apr_pollset_provider_t impl = {
     "poll"
 };
 
-apr_pollset_provider_t *apr_pollset_provider_poll = &impl;
+const apr_pollset_provider_t *apr_pollset_provider_poll = &impl;
 
 /* Poll method pollcb.
  * This is probably usable only for WIN32 having WSAPoll
@@ -446,7 +446,7 @@ static apr_status_t impl_pollcb_poll(apr_pollcb_t *pollcb,
     return rv;
 }
 
-static apr_pollcb_provider_t impl_cb = {
+static const apr_pollcb_provider_t impl_cb = {
     impl_pollcb_create,
     impl_pollcb_add,
     impl_pollcb_remove,
@@ -455,6 +455,6 @@ static apr_pollcb_provider_t impl_cb = {
     "poll"
 };
 
-apr_pollcb_provider_t *apr_pollcb_provider_poll = &impl_cb;
+const apr_pollcb_provider_t *apr_pollcb_provider_poll = &impl_cb;
 
 #endif /* HAVE_POLL */
diff --git a/poll/unix/pollcb.c b/poll/unix/pollcb.c
index ca98125..a63ad5c 100644
--- a/poll/unix/pollcb.c
+++ b/poll/unix/pollcb.c
@@ -29,21 +29,21 @@
 
 static apr_pollset_method_e pollset_default_method = POLLSET_DEFAULT_METHOD;
 #if defined(HAVE_KQUEUE)
-extern apr_pollcb_provider_t *apr_pollcb_provider_kqueue;
+extern const apr_pollcb_provider_t *apr_pollcb_provider_kqueue;
 #endif
 #if defined(HAVE_PORT_CREATE)
-extern apr_pollcb_provider_t *apr_pollcb_provider_port;
+extern const apr_pollcb_provider_t *apr_pollcb_provider_port;
 #endif
 #if defined(HAVE_EPOLL)
-extern apr_pollcb_provider_t *apr_pollcb_provider_epoll;
+extern const apr_pollcb_provider_t *apr_pollcb_provider_epoll;
 #endif
 #if defined(HAVE_POLL)
-extern apr_pollcb_provider_t *apr_pollcb_provider_poll;
+extern const apr_pollcb_provider_t *apr_pollcb_provider_poll;
 #endif
 
-static apr_pollcb_provider_t *pollcb_provider(apr_pollset_method_e method)
+static const apr_pollcb_provider_t *pollcb_provider(apr_pollset_method_e method)
 {
-    apr_pollcb_provider_t *provider = NULL;
+    const apr_pollcb_provider_t *provider = NULL;
     switch (method) {
         case APR_POLLSET_KQUEUE:
 #if defined(HAVE_KQUEUE)
@@ -95,7 +95,7 @@ APR_DECLARE(apr_status_t) apr_pollcb_create_ex(apr_pollcb_t **ret_pollcb,
 {
     apr_status_t rv;
     apr_pollcb_t *pollcb;
-    apr_pollcb_provider_t *provider = NULL;
+    const apr_pollcb_provider_t *provider = NULL;
 
     *ret_pollcb = NULL;
 
diff --git a/poll/unix/pollset.c b/poll/unix/pollset.c
index 4fa4ffa..8fa8173 100644
--- a/poll/unix/pollset.c
+++ b/poll/unix/pollset.c
@@ -44,25 +44,25 @@ static apr_status_t pollset_cleanup(void *p)
 }
 
 #if defined(HAVE_KQUEUE)
-extern apr_pollset_provider_t *apr_pollset_provider_kqueue;
+extern const apr_pollset_provider_t *apr_pollset_provider_kqueue;
 #endif
 #if defined(HAVE_PORT_CREATE)
-extern apr_pollset_provider_t *apr_pollset_provider_port;
+extern const apr_pollset_provider_t *apr_pollset_provider_port;
 #endif
 #if defined(HAVE_EPOLL)
-extern apr_pollset_provider_t *apr_pollset_provider_epoll;
+extern const apr_pollset_provider_t *apr_pollset_provider_epoll;
 #endif
 #if defined(HAVE_AIO_MSGQ)
-extern apr_pollset_provider_t *apr_pollset_provider_aio_msgq;
+extern const apr_pollset_provider_t *apr_pollset_provider_aio_msgq;
 #endif
 #if defined(HAVE_POLL)
-extern apr_pollset_provider_t *apr_pollset_provider_poll;
+extern const apr_pollset_provider_t *apr_pollset_provider_poll;
 #endif
-extern apr_pollset_provider_t *apr_pollset_provider_select;
+extern const apr_pollset_provider_t *apr_pollset_provider_select;
 
-static apr_pollset_provider_t *pollset_provider(apr_pollset_method_e method)
+static const apr_pollset_provider_t *pollset_provider(apr_pollset_method_e method)
 {
-    apr_pollset_provider_t *provider = NULL;
+    const apr_pollset_provider_t *provider = NULL;
     switch (method) {
         case APR_POLLSET_KQUEUE:
 #if defined(HAVE_KQUEUE)
@@ -106,7 +106,7 @@ APR_DECLARE(apr_status_t) apr_pollset_create_ex(apr_pollset_t **ret_pollset,
 {
     apr_status_t rv;
     apr_pollset_t *pollset;
-    apr_pollset_provider_t *provider = NULL;
+    const apr_pollset_provider_t *provider = NULL;
 
     *ret_pollset = NULL;
 
@@ -190,7 +190,7 @@ APR_DECLARE(const char *) apr_pollset_method_name(apr_pollset_t *pollset)
 
 APR_DECLARE(const char *) apr_poll_method_defname()
 {
-    apr_pollset_provider_t *provider = NULL;
+    const apr_pollset_provider_t *provider = NULL;
 
     provider = pollset_provider(pollset_default_method);
     if (provider)
diff --git a/poll/unix/port.c b/poll/unix/port.c
index 6743293..a436f62 100644
--- a/poll/unix/port.c
+++ b/poll/unix/port.c
@@ -455,7 +455,7 @@ static apr_status_t impl_pollset_poll(apr_pollset_t *pollset,
     return rv;
 }
 
-static apr_pollset_provider_t impl = {
+static const apr_pollset_provider_t impl = {
     impl_pollset_create,
     impl_pollset_add,
     impl_pollset_remove,
@@ -464,7 +464,7 @@ static apr_pollset_provider_t impl = {
     "port"
 };
 
-apr_pollset_provider_t *apr_pollset_provider_port = &impl;
+const apr_pollset_provider_t *apr_pollset_provider_port = &impl;
 
 static apr_status_t impl_pollcb_cleanup(apr_pollcb_t *pollcb)
 {
@@ -588,7 +588,7 @@ static apr_status_t impl_pollcb_poll(apr_pollcb_t *pollcb,
     return rv;
 }
 
-static apr_pollcb_provider_t impl_cb = {
+static const apr_pollcb_provider_t impl_cb = {
     impl_pollcb_create,
     impl_pollcb_add,
     impl_pollcb_remove,
@@ -597,6 +597,6 @@ static apr_pollcb_provider_t impl_cb = {
     "port"
 };
 
-apr_pollcb_provider_t *apr_pollcb_provider_port = &impl_cb;
+const apr_pollcb_provider_t *apr_pollcb_provider_port = &impl_cb;
 
 #endif /* HAVE_PORT_CREATE */
diff --git a/poll/unix/select.c b/poll/unix/select.c
index 214111a..51be3c1 100644
--- a/poll/unix/select.c
+++ b/poll/unix/select.c
@@ -437,7 +437,7 @@ static apr_status_t impl_pollset_poll(apr_pollset_t *pollset,
     return rv;
 }
 
-static apr_pollset_provider_t impl = {
+static const apr_pollset_provider_t impl = {
     impl_pollset_create,
     impl_pollset_add,
     impl_pollset_remove,
@@ -446,4 +446,4 @@ static apr_pollset_provider_t impl = {
     "select"
 };
 
-apr_pollset_provider_t *apr_pollset_provider_select = &impl;
+const apr_pollset_provider_t *apr_pollset_provider_select = &impl;
diff --git a/poll/unix/z_asio.c b/poll/unix/z_asio.c
index ae03079..48b531c 100644
--- a/poll/unix/z_asio.c
+++ b/poll/unix/z_asio.c
@@ -768,7 +768,7 @@ static apr_status_t asio_pollset_poll(apr_pollset_t *pollset,
     return rv;
 }  /* end of asio_pollset_poll */
 
-static apr_pollset_provider_t impl = {
+static const apr_pollset_provider_t impl = {
     asio_pollset_create,
     asio_pollset_add,
     asio_pollset_remove,
@@ -777,6 +777,6 @@ static apr_pollset_provider_t impl = {
     "asio"
 };
 
-apr_pollset_provider_t *apr_pollset_provider_aio_msgq = &impl;
+const apr_pollset_provider_t *apr_pollset_provider_aio_msgq = &impl;
 
 #endif /* HAVE_AIO_MSGQ */
diff --git a/test/testfile.c b/test/testfile.c
index 7b58006..36ab4f0 100644
--- a/test/testfile.c
+++ b/test/testfile.c
@@ -811,6 +811,253 @@ static void test_truncate(abts_case *tc, void *data)
     ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
 }
 
+static void test_file_trunc(abts_case *tc, void *data)
+{
+    apr_status_t rv;
+    apr_file_t *f;
+    const char *fname = "data/testtruncate.dat";
+    const char *s;
+    apr_size_t nbytes;
+    apr_finfo_t finfo;
+
+    apr_file_remove(fname, p);
+
+    /* Test unbuffered */
+    rv = apr_file_open(&f, fname,
+                        APR_FOPEN_CREATE | APR_FOPEN_READ |
+                        APR_FOPEN_WRITE,
+                        APR_FPROT_UREAD | APR_FPROT_UWRITE, p);
+    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+    s = "some data";
+    nbytes = strlen(s);
+    rv = apr_file_write(f, s, &nbytes);
+    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+    ABTS_SIZE_EQUAL(tc, strlen(s), nbytes);
+    rv = apr_file_trunc(f, 4);
+    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+    rv = apr_file_close(f);
+    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+    rv = apr_stat(&finfo, fname, APR_FINFO_SIZE, p);
+    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+    ABTS_ASSERT(tc, "File size mismatch, expected 4", finfo.size == 4);
+
+    rv = apr_file_remove(fname, p);
+    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+    /* Test buffered */
+    rv = apr_file_open(&f, fname,
+                        APR_FOPEN_CREATE | APR_FOPEN_READ |
+                        APR_FOPEN_WRITE | APR_FOPEN_BUFFERED,
+                        APR_FPROT_UREAD | APR_FPROT_UWRITE, p);
+    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+    nbytes = strlen(s);
+    rv = apr_file_write(f, s, &nbytes);
+    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+    ABTS_SIZE_EQUAL(tc, strlen(s), nbytes);
+    rv = apr_file_trunc(f, 4);
+    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+    rv = apr_file_close(f);
+    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+    rv = apr_stat(&finfo, fname, APR_FINFO_SIZE, p);
+    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+    ABTS_ASSERT(tc, "File size mismatch, expected 4", finfo.size == 4);
+
+    rv = apr_file_remove(fname, p);
+    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+}
+
+static void test_file_trunc2(abts_case *tc, void *data)
+{
+    apr_status_t rv;
+    apr_file_t *f;
+    const char *fname = "data/testtruncate.dat";
+    const char *s;
+    apr_size_t nbytes;
+    apr_finfo_t finfo;
+    char c;
+
+    apr_file_remove(fname, p);
+
+    rv = apr_file_open(&f, fname,
+                        APR_FOPEN_CREATE | APR_FOPEN_READ |
+                        APR_FOPEN_WRITE,
+                        APR_FPROT_UREAD | APR_FPROT_UWRITE, p);
+    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+    s = "some data";
+    nbytes = strlen(s);
+    rv = apr_file_write(f, s, &nbytes);
+    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+    ABTS_SIZE_EQUAL(tc, strlen(s), nbytes);
+    rv = apr_file_trunc(f, 4);
+    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+    /* Test apr_file_info_get(). */
+    rv = apr_file_info_get(&finfo, APR_FINFO_SIZE, f);
+    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+    ABTS_INT_EQUAL(tc, 4, (int)finfo.size);
+    /* EOF is not reported until the next read. */
+    rv = apr_file_eof(f);
+    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+    rv = apr_file_getc(&c, f);
+    ABTS_INT_EQUAL(tc, APR_EOF, rv);
+    rv = apr_file_eof(f);
+    ABTS_INT_EQUAL(tc, APR_EOF, rv);
+
+    rv = apr_file_close(f);
+    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+    rv = apr_stat(&finfo, fname, APR_FINFO_SIZE, p);
+    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+    ABTS_INT_EQUAL(tc, 4, (int)finfo.size);
+
+    rv = apr_file_remove(fname, p);
+    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+}
+
+static void test_file_trunc_buffered_write(abts_case *tc, void *data)
+{
+    apr_status_t rv;
+    apr_file_t *f;
+    const char *fname = "data/testtruncate_buffered_write.dat";
+    const char *s;
+    apr_size_t nbytes;
+    apr_finfo_t finfo;
+    char c;
+
+    apr_file_remove(fname, p);
+
+    rv = apr_file_open(&f, fname,
+                        APR_FOPEN_CREATE | APR_FOPEN_READ |
+                        APR_FOPEN_WRITE | APR_FOPEN_BUFFERED,
+                        APR_FPROT_UREAD | APR_FPROT_UWRITE, p);
+    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+    s = "some data";
+    nbytes = strlen(s);
+    rv = apr_file_write(f, s, &nbytes);
+    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+    ABTS_SIZE_EQUAL(tc, strlen(s), nbytes);
+    rv = apr_file_trunc(f, 4);
+    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+    /* Test apr_file_info_get(). */
+    rv = apr_file_info_get(&finfo, APR_FINFO_SIZE, f);
+    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+    ABTS_INT_EQUAL(tc, 4, (int)finfo.size);
+    /* EOF is not reported until the next read. */
+    rv = apr_file_eof(f);
+    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+    rv = apr_file_getc(&c, f);
+    ABTS_INT_EQUAL(tc, APR_EOF, rv);
+    rv = apr_file_eof(f);
+    ABTS_INT_EQUAL(tc, APR_EOF, rv);
+
+    rv = apr_file_close(f);
+    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+    rv = apr_stat(&finfo, fname, APR_FINFO_SIZE, p);
+    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+    ABTS_INT_EQUAL(tc, 4, (int)finfo.size);
+
+    rv = apr_file_remove(fname, p);
+    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+}
+
+static void test_file_trunc_buffered_write2(abts_case *tc, void *data)
+{
+    apr_status_t rv;
+    apr_file_t *f;
+    const char *fname = "data/testtruncate_buffered_write2.dat";
+    apr_finfo_t finfo;
+    char c;
+
+    apr_file_remove(fname, p);
+
+    rv = apr_file_open(&f, fname,
+                       APR_FOPEN_CREATE | APR_FOPEN_READ |
+                       APR_FOPEN_WRITE | APR_FOPEN_BUFFERED,
+                       APR_FPROT_OS_DEFAULT, p);
+    APR_ASSERT_SUCCESS(tc, "open test file", rv);
+
+    rv = apr_file_puts("abc", f);
+    APR_ASSERT_SUCCESS(tc, "write first string", rv);
+    rv = apr_file_flush(f);
+    APR_ASSERT_SUCCESS(tc, "flush", rv);
+    rv = apr_file_puts("def", f);
+    APR_ASSERT_SUCCESS(tc, "write second string", rv);
+    /* Truncate behind the write buffer. */
+    rv = apr_file_trunc(f, 2);
+    APR_ASSERT_SUCCESS(tc, "truncate the file", rv);
+    /* Test apr_file_info_get(). */
+    rv = apr_file_info_get(&finfo, APR_FINFO_SIZE, f);
+    APR_ASSERT_SUCCESS(tc, "get file info", rv);
+    ABTS_INT_EQUAL(tc, 2, (int)finfo.size);
+    /* EOF is not reported until the next read. */
+    rv = apr_file_eof(f);
+    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+    rv = apr_file_getc(&c, f);
+    ABTS_INT_EQUAL(tc, APR_EOF, rv);
+    rv = apr_file_eof(f);
+    ABTS_INT_EQUAL(tc, APR_EOF, rv);
+
+    apr_file_close(f);
+
+    rv = apr_stat(&finfo, fname, APR_FINFO_SIZE, p);
+    APR_ASSERT_SUCCESS(tc, "stat file", rv);
+    ABTS_INT_EQUAL(tc, 2, (int)finfo.size);
+
+    apr_file_remove(fname, p);
+}
+
+static void test_file_trunc_buffered_read(abts_case *tc, void *data)
+{
+    apr_status_t rv;
+    apr_file_t *f;
+    const char *fname = "data/testtruncate_buffered_read.dat";
+    apr_finfo_t finfo;
+    char c;
+
+    apr_file_remove(fname, p);
+
+    rv = apr_file_open(&f, fname,
+                       APR_FOPEN_CREATE | APR_FOPEN_READ |
+                       APR_FOPEN_WRITE, APR_FPROT_OS_DEFAULT, p);
+    APR_ASSERT_SUCCESS(tc, "open test file", rv);
+
+    rv = apr_file_puts("abc", f);
+    APR_ASSERT_SUCCESS(tc, "write test data", rv);
+    apr_file_close(f);
+
+    rv = apr_file_open(&f, fname,
+                       APR_FOPEN_READ | APR_FOPEN_WRITE |
+                       APR_FOPEN_BUFFERED, APR_FPROT_OS_DEFAULT, p);
+    APR_ASSERT_SUCCESS(tc, "re-open test file", rv);
+
+    /* Read to fill in the buffer. */
+    rv = apr_file_getc(&c, f);
+    APR_ASSERT_SUCCESS(tc, "read char", rv);
+    /* Truncate the file. */
+    rv = apr_file_trunc(f, 1);
+    APR_ASSERT_SUCCESS(tc, "truncate the file", rv);
+    /* Test apr_file_info_get(). */
+    rv = apr_file_info_get(&finfo, APR_FINFO_SIZE, f);
+    APR_ASSERT_SUCCESS(tc, "get file info", rv);
+    ABTS_INT_EQUAL(tc, 1, (int)finfo.size);
+    /* EOF is not reported until the next read. */
+    rv = apr_file_eof(f);
+    ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+    rv = apr_file_getc(&c, f);
+    ABTS_INT_EQUAL(tc, APR_EOF, rv);
+    rv = apr_file_eof(f);
+    ABTS_INT_EQUAL(tc, APR_EOF, rv);
+
+    apr_file_close(f);
+
+    rv = apr_stat(&finfo, fname, APR_FINFO_SIZE, p);
+    APR_ASSERT_SUCCESS(tc, "stat file", rv);
+    ABTS_INT_EQUAL(tc, 1, (int)finfo.size);
+
+    apr_file_remove(fname, p);
+}
+
 static void test_bigfprintf(abts_case *tc, void *data)
 {
     apr_file_t *f;
@@ -1006,6 +1253,11 @@ abts_suite *testfile(abts_suite *suite)
     abts_run_test(suite, test_bigread, NULL);
     abts_run_test(suite, test_mod_neg, NULL);
     abts_run_test(suite, test_truncate, NULL);
+    abts_run_test(suite, test_file_trunc, NULL);
+    abts_run_test(suite, test_file_trunc2, NULL);
+    abts_run_test(suite, test_file_trunc_buffered_write, NULL);
+    abts_run_test(suite, test_file_trunc_buffered_write2, NULL);
+    abts_run_test(suite, test_file_trunc_buffered_read, NULL);
     abts_run_test(suite, test_bigfprintf, NULL);
     abts_run_test(suite, test_fail_write_flush, NULL);
     abts_run_test(suite, test_fail_read_flush, NULL);
diff --git a/test/testipsub.c b/test/testipsub.c
index 804bb3d..342b5ca 100644
--- a/test/testipsub.c
+++ b/test/testipsub.c
@@ -45,6 +45,7 @@ static void test_bad_input(abts_case *tc, void *data)
         ,{"127.0.0.1.2",       NULL,               APR_EBADIP}
         ,{"127.0.0.1.2",       "8",                APR_EBADIP}
         ,{"127",               "255.0.0.0",        APR_EBADIP} /* either EBADIP or EBADMASK seems fine */
+        ,{"",                  NULL,               APR_EINVAL}
 #if APR_HAVE_IPV6
         ,{"::1",               NULL,               APR_SUCCESS}
         ,{"::1",               "20",               APR_SUCCESS}
diff --git a/time/unix/time.c b/time/unix/time.c
index dfa45e6..7f09581 100644
--- a/time/unix/time.c
+++ b/time/unix/time.c
@@ -142,6 +142,9 @@ APR_DECLARE(apr_status_t) apr_time_exp_get(apr_time_t *t, apr_time_exp_t *xt)
     static const int dayoffset[12] =
     {306, 337, 0, 31, 61, 92, 122, 153, 184, 214, 245, 275};
 
+    if (xt->tm_mon < 0 || xt->tm_mon >= 12)
+        return APR_EBADDATE;
+
     /* shift new year to 1st March in order to make leap year calc easy */
 
     if (xt->tm_mon < 2)
diff --git a/time/win32/time.c b/time/win32/time.c
index 2349799..1a70544 100644
--- a/time/win32/time.c
+++ b/time/win32/time.c
@@ -54,6 +54,9 @@ static void SystemTimeToAprExpTime(apr_time_exp_t *xt, SYSTEMTIME *tm)
     static const int dayoffset[12] =
     {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334};
 
+    if (tm->wMonth < 1 || tm->wMonth > 12)
+        return APR_EBADDATE;
+
     /* Note; the caller is responsible for filling in detailed tm_usec,
      * tm_gmtoff and tm_isdst data when applicable.
      */
@@ -224,6 +227,9 @@ APR_DECLARE(apr_status_t) apr_time_exp_get(apr_time_t *t,
     static const int dayoffset[12] =
     {306, 337, 0, 31, 61, 92, 122, 153, 184, 214, 245, 275};
 
+    if (xt->tm_mon < 0 || xt->tm_mon >= 12)
+        return APR_EBADDATE;
+
     /* shift new year to 1st March in order to make leap year calc easy */
 
     if (xt->tm_mon < 2)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-apache/apr.git



More information about the Pkg-apache-commits mailing list