mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-14 10:09:48 +00:00
Import Apache apr-1.4.8 to vendor staging area.
This commit is contained in:
parent
b641829dca
commit
f2be5817e9
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/vendor/apr/dist/; revision=253730 svn path=/vendor/apr/apr-1.4.8/; revision=253731; tag=vendor/apr/apr-1.4.8
66
CHANGES
66
CHANGES
@ -1,11 +1,73 @@
|
||||
-*- coding: utf-8 -*-
|
||||
Changes for APR 1.4.8
|
||||
|
||||
*) Fix compiltation with FreeBSD on ARM. [Olli Hauer <ohauer gmx.de>]
|
||||
|
||||
*) Fix 1.4.7 regression in apr_mcast_hops() and apr_mcast_loopback()
|
||||
for AF_INET (IPv4) sockets on most Unix platforms. [Joe Orton]
|
||||
|
||||
*) Fix the return value of apr_threadattr_detach_get() on some
|
||||
platforms like OS X and Solaris. [Rainer Jung, <dusanv gmail com>]
|
||||
|
||||
Changes for APR 1.4.7
|
||||
|
||||
*) Fix apr_sockaddr_info_get() not returning an error in some cases.
|
||||
PR 54779. [Jan Kaluža <jkaluza redhat com>]
|
||||
|
||||
*) Fix amd64 assembler version of apr_atomic_xchgptr(). PR 51851. [Mattias
|
||||
Engdegård <mattiase acm org>]
|
||||
|
||||
*) Fix PPC atomics to work with gcc 4.0. PR 54840. [Mattias Engdegård
|
||||
<mattiase acm org>]
|
||||
|
||||
*) configure: Fix detection of O_NONBLOCK inheritance on busy
|
||||
systems. [Rainer Jung]
|
||||
|
||||
*) Remove unused code, fix strict C compliance bug in SHA-256
|
||||
implementation. [Jan Kaluza <jkaluza redhat.com>]
|
||||
|
||||
*) Fix apr_ipsubnet_test() false positives when comparing IPv4
|
||||
subnet representation against an IPv6 address. PR 54047. [Joe Orton]
|
||||
|
||||
*) apr_socket_accept_filter: Return success when trying to again set
|
||||
the filter to the same value as before, avoiding an unhelpful
|
||||
APR_EINVAL. PR 37863. [Jeff Trawick]
|
||||
|
||||
*) configure: Fix Linux 3.x detection. PR 54001. [Gilles Espinasse
|
||||
<g esp free fr>]
|
||||
|
||||
*) apr_time_exp_*() on Windows: Fix error in the tm_yday field of
|
||||
apr_time_exp_t for times within leap years. PR 53175.
|
||||
[Jeff Trawick]
|
||||
|
||||
*) Improve platform detection by updating config.guess and config.sub.
|
||||
[Rainer Jung]
|
||||
|
||||
*) Add support for OSX Mountain Lion (10.8) [Jim Jagielski]
|
||||
|
||||
*) Add various gcc function attributes. [Stefan Fritsch]
|
||||
|
||||
*) Fix some problems in apr_sockaddr_info_get() when trying to resolve
|
||||
the loopback addresses of a protocol family that is not otherwise
|
||||
configured on the system. PR 52709. [Nirgal Vourgère
|
||||
<jmv_deb nirgal com>, Stefan Fritsch]
|
||||
|
||||
*) Fix file not being unlocked if truncate call on a file fails.
|
||||
[Mladen Turk]
|
||||
|
||||
*) apr_mcast_hops: Fix EINVAL for IPv6 sockets caused by using byte
|
||||
instead integer for setsockopt. [Mladen Turk]
|
||||
|
||||
*) Windows: Fix compile-time checks for 64-bit builds, resolving a
|
||||
crash in httpd's mod_rewrite. PR 49155. [<anindyabaruah gmail.com>]
|
||||
|
||||
Changes for APR 1.4.6
|
||||
|
||||
*) Flush write buffer before truncate call on a file.
|
||||
[Mladen Turk]
|
||||
|
||||
*) Security: oCERT-2011-003
|
||||
Randomise hashes by providing a seed.
|
||||
*) Randomise hashes by providing a seed.
|
||||
Assigned CVE-2012-0840, oCERT-2011-003, but not known to be exploitable.
|
||||
[Bojan Smojver, Branko Čibej, Ruediger Pluem et al.]
|
||||
|
||||
*) apr_random: Prevent segfault if pool used to initialize apr_random is
|
||||
|
@ -25,7 +25,7 @@
|
||||
#
|
||||
# For example;
|
||||
#
|
||||
# nmake -f Makefile.win PREFIX=C:\APR buildall checkall installall clean
|
||||
# nmake -f Makefile.win PREFIX=C:\APR buildall checkall install clean
|
||||
#
|
||||
|
||||
!IF EXIST("apr.sln") && ([devenv /help > NUL 2>&1] == 0) \
|
||||
|
2
apr.spec
2
apr.spec
@ -3,7 +3,7 @@
|
||||
|
||||
Summary: Apache Portable Runtime library
|
||||
Name: apr
|
||||
Version: 1.4.6
|
||||
Version: 1.4.8
|
||||
Release: 1
|
||||
License: Apache Software License
|
||||
Group: System Environment/Libraries
|
||||
|
@ -117,7 +117,7 @@ APR_DECLARE(void*) apr_atomic_xchgptr(volatile void **mem, void *with)
|
||||
#elif APR_SIZEOF_VOIDP == 8
|
||||
asm volatile ("xchgq %q2, %1"
|
||||
: "=a" (prev), "+m" (*mem)
|
||||
: "r" ((unsigned long)with));
|
||||
: "0" (with));
|
||||
#else
|
||||
#error APR_SIZEOF_VOIDP value not supported
|
||||
#endif
|
||||
|
@ -19,7 +19,7 @@
|
||||
#ifdef USE_ATOMICS_PPC
|
||||
|
||||
#ifdef PPC405_ERRATA
|
||||
# define PPC405_ERR77_SYNC " sync\n"
|
||||
# define PPC405_ERR77_SYNC " sync\n"
|
||||
#else
|
||||
# define PPC405_ERR77_SYNC
|
||||
#endif
|
||||
@ -43,12 +43,12 @@ APR_DECLARE(apr_uint32_t) apr_atomic_add32(volatile apr_uint32_t *mem, apr_uint3
|
||||
{
|
||||
apr_uint32_t prev, temp;
|
||||
|
||||
asm volatile ("loop_%=:\n" /* lost reservation */
|
||||
" lwarx %0,0,%3\n" /* load and reserve */
|
||||
" add %1,%0,%4\n" /* add val and prev */
|
||||
PPC405_ERR77_SYNC /* ppc405 Erratum 77 */
|
||||
" stwcx. %1,0,%3\n" /* store new value */
|
||||
" bne- loop_%=\n" /* loop if lost */
|
||||
asm volatile ("1:\n" /* lost reservation */
|
||||
" lwarx %0,0,%3\n" /* load and reserve */
|
||||
" add %1,%0,%4\n" /* add val and prev */
|
||||
PPC405_ERR77_SYNC /* ppc405 Erratum 77 */
|
||||
" stwcx. %1,0,%3\n" /* store new value */
|
||||
" bne- 1b\n" /* loop if lost */
|
||||
: "=&r" (prev), "=&r" (temp), "=m" (*mem)
|
||||
: "b" (mem), "r" (val)
|
||||
: "cc", "memory");
|
||||
@ -60,12 +60,12 @@ APR_DECLARE(void) apr_atomic_sub32(volatile apr_uint32_t *mem, apr_uint32_t val)
|
||||
{
|
||||
apr_uint32_t temp;
|
||||
|
||||
asm volatile ("loop_%=:\n" /* lost reservation */
|
||||
" lwarx %0,0,%2\n" /* load and reserve */
|
||||
" subf %0,%3,%0\n" /* subtract val */
|
||||
PPC405_ERR77_SYNC /* ppc405 Erratum 77 */
|
||||
" stwcx. %0,0,%2\n" /* store new value */
|
||||
" bne- loop_%=\n" /* loop if lost */
|
||||
asm volatile ("1:\n" /* lost reservation */
|
||||
" lwarx %0,0,%2\n" /* load and reserve */
|
||||
" subf %0,%3,%0\n" /* subtract val */
|
||||
PPC405_ERR77_SYNC /* ppc405 Erratum 77 */
|
||||
" stwcx. %0,0,%2\n" /* store new value */
|
||||
" bne- 1b\n" /* loop if lost */
|
||||
: "=&r" (temp), "=m" (*mem)
|
||||
: "b" (mem), "r" (val)
|
||||
: "cc", "memory");
|
||||
@ -75,13 +75,13 @@ APR_DECLARE(apr_uint32_t) apr_atomic_inc32(volatile apr_uint32_t *mem)
|
||||
{
|
||||
apr_uint32_t prev;
|
||||
|
||||
asm volatile ("loop_%=:\n" /* lost reservation */
|
||||
" lwarx %0,0,%2\n" /* load and reserve */
|
||||
" addi %0,%0,1\n" /* add immediate */
|
||||
PPC405_ERR77_SYNC /* ppc405 Erratum 77 */
|
||||
" stwcx. %0,0,%2\n" /* store new value */
|
||||
" bne- loop_%=\n" /* loop if lost */
|
||||
" subi %0,%0,1\n" /* return old value */
|
||||
asm volatile ("1:\n" /* lost reservation */
|
||||
" lwarx %0,0,%2\n" /* load and reserve */
|
||||
" addi %0,%0,1\n" /* add immediate */
|
||||
PPC405_ERR77_SYNC /* ppc405 Erratum 77 */
|
||||
" stwcx. %0,0,%2\n" /* store new value */
|
||||
" bne- 1b\n" /* loop if lost */
|
||||
" subi %0,%0,1\n" /* return old value */
|
||||
: "=&b" (prev), "=m" (*mem)
|
||||
: "b" (mem), "m" (*mem)
|
||||
: "cc", "memory");
|
||||
@ -93,12 +93,12 @@ APR_DECLARE(int) apr_atomic_dec32(volatile apr_uint32_t *mem)
|
||||
{
|
||||
apr_uint32_t prev;
|
||||
|
||||
asm volatile ("loop_%=:\n" /* lost reservation */
|
||||
" lwarx %0,0,%2\n" /* load and reserve */
|
||||
" subi %0,%0,1\n" /* subtract immediate */
|
||||
PPC405_ERR77_SYNC /* ppc405 Erratum 77 */
|
||||
" stwcx. %0,0,%2\n" /* store new value */
|
||||
" bne- loop_%=\n" /* loop if lost */
|
||||
asm volatile ("1:\n" /* lost reservation */
|
||||
" lwarx %0,0,%2\n" /* load and reserve */
|
||||
" subi %0,%0,1\n" /* subtract immediate */
|
||||
PPC405_ERR77_SYNC /* ppc405 Erratum 77 */
|
||||
" stwcx. %0,0,%2\n" /* store new value */
|
||||
" bne- 1b\n" /* loop if lost */
|
||||
: "=&b" (prev), "=m" (*mem)
|
||||
: "b" (mem), "m" (*mem)
|
||||
: "cc", "memory");
|
||||
@ -111,14 +111,14 @@ APR_DECLARE(apr_uint32_t) apr_atomic_cas32(volatile apr_uint32_t *mem, apr_uint3
|
||||
{
|
||||
apr_uint32_t prev;
|
||||
|
||||
asm volatile ("loop_%=:\n" /* lost reservation */
|
||||
" lwarx %0,0,%1\n" /* load and reserve */
|
||||
" cmpw %0,%3\n" /* compare operands */
|
||||
" bne- exit_%=\n" /* skip if not equal */
|
||||
PPC405_ERR77_SYNC /* ppc405 Erratum 77 */
|
||||
" stwcx. %2,0,%1\n" /* store new value */
|
||||
" bne- loop_%=\n" /* loop if lost */
|
||||
"exit_%=:\n" /* not equal */
|
||||
asm volatile ("1:\n" /* lost reservation */
|
||||
" lwarx %0,0,%1\n" /* load and reserve */
|
||||
" cmpw %0,%3\n" /* compare operands */
|
||||
" bne- exit_%=\n" /* skip if not equal */
|
||||
PPC405_ERR77_SYNC /* ppc405 Erratum 77 */
|
||||
" stwcx. %2,0,%1\n" /* store new value */
|
||||
" bne- 1b\n" /* loop if lost */
|
||||
"exit_%=:\n" /* not equal */
|
||||
: "=&r" (prev)
|
||||
: "b" (mem), "r" (with), "r" (cmp)
|
||||
: "cc", "memory");
|
||||
@ -130,11 +130,11 @@ APR_DECLARE(apr_uint32_t) apr_atomic_xchg32(volatile apr_uint32_t *mem, apr_uint
|
||||
{
|
||||
apr_uint32_t prev;
|
||||
|
||||
asm volatile ("loop_%=:\n" /* lost reservation */
|
||||
" lwarx %0,0,%1\n" /* load and reserve */
|
||||
PPC405_ERR77_SYNC /* ppc405 Erratum 77 */
|
||||
" stwcx. %2,0,%1\n" /* store new value */
|
||||
" bne- loop_%=" /* loop if lost */
|
||||
asm volatile ("1:\n" /* lost reservation */
|
||||
" lwarx %0,0,%1\n" /* load and reserve */
|
||||
PPC405_ERR77_SYNC /* ppc405 Erratum 77 */
|
||||
" stwcx. %2,0,%1\n" /* store new value */
|
||||
" bne- 1b" /* loop if lost */
|
||||
: "=&r" (prev)
|
||||
: "b" (mem), "r" (val)
|
||||
: "cc", "memory");
|
||||
@ -146,26 +146,26 @@ APR_DECLARE(void*) apr_atomic_casptr(volatile void **mem, void *with, const void
|
||||
{
|
||||
void *prev;
|
||||
#if APR_SIZEOF_VOIDP == 4
|
||||
asm volatile ("loop_%=:\n" /* lost reservation */
|
||||
" lwarx %0,0,%1\n" /* load and reserve */
|
||||
" cmpw %0,%3\n" /* compare operands */
|
||||
" bne- exit_%=\n" /* skip if not equal */
|
||||
PPC405_ERR77_SYNC /* ppc405 Erratum 77 */
|
||||
" stwcx. %2,0,%1\n" /* store new value */
|
||||
" bne- loop_%=\n" /* loop if lost */
|
||||
"exit_%=:\n" /* not equal */
|
||||
asm volatile ("1:\n" /* lost reservation */
|
||||
" lwarx %0,0,%1\n" /* load and reserve */
|
||||
" cmpw %0,%3\n" /* compare operands */
|
||||
" bne- 2f\n" /* skip if not equal */
|
||||
PPC405_ERR77_SYNC /* ppc405 Erratum 77 */
|
||||
" stwcx. %2,0,%1\n" /* store new value */
|
||||
" bne- 1b\n" /* loop if lost */
|
||||
"2:\n" /* not equal */
|
||||
: "=&r" (prev)
|
||||
: "b" (mem), "r" (with), "r" (cmp)
|
||||
: "cc", "memory");
|
||||
#elif APR_SIZEOF_VOIDP == 8
|
||||
asm volatile ("loop_%=:\n" /* lost reservation */
|
||||
" ldarx %0,0,%1\n" /* load and reserve */
|
||||
" cmpd %0,%3\n" /* compare operands */
|
||||
" bne- exit_%=\n" /* skip if not equal */
|
||||
PPC405_ERR77_SYNC /* ppc405 Erratum 77 */
|
||||
" stdcx. %2,0,%1\n" /* store new value */
|
||||
" bne- loop_%=\n" /* loop if lost */
|
||||
"exit_%=:\n" /* not equal */
|
||||
asm volatile ("1:\n" /* lost reservation */
|
||||
" ldarx %0,0,%1\n" /* load and reserve */
|
||||
" cmpd %0,%3\n" /* compare operands */
|
||||
" bne- 2f\n" /* skip if not equal */
|
||||
PPC405_ERR77_SYNC /* ppc405 Erratum 77 */
|
||||
" stdcx. %2,0,%1\n" /* store new value */
|
||||
" bne- 1b\n" /* loop if lost */
|
||||
"2:\n" /* not equal */
|
||||
: "=&r" (prev)
|
||||
: "b" (mem), "r" (with), "r" (cmp)
|
||||
: "cc", "memory");
|
||||
@ -179,22 +179,22 @@ APR_DECLARE(void*) apr_atomic_xchgptr(volatile void **mem, void *with)
|
||||
{
|
||||
void *prev;
|
||||
#if APR_SIZEOF_VOIDP == 4
|
||||
asm volatile ("loop_%=:\n" /* lost reservation */
|
||||
" lwarx %0,0,%1\n" /* load and reserve */
|
||||
PPC405_ERR77_SYNC /* ppc405 Erratum 77 */
|
||||
" stwcx. %2,0,%1\n" /* store new value */
|
||||
" bne- loop_%=\n" /* loop if lost */
|
||||
" isync\n" /* memory barrier */
|
||||
asm volatile ("1:\n" /* lost reservation */
|
||||
" lwarx %0,0,%1\n" /* load and reserve */
|
||||
PPC405_ERR77_SYNC /* ppc405 Erratum 77 */
|
||||
" stwcx. %2,0,%1\n" /* store new value */
|
||||
" bne- 1b\n" /* loop if lost */
|
||||
" isync\n" /* memory barrier */
|
||||
: "=&r" (prev)
|
||||
: "b" (mem), "r" (with)
|
||||
: "cc", "memory");
|
||||
#elif APR_SIZEOF_VOIDP == 8
|
||||
asm volatile ("loop_%=:\n" /* lost reservation */
|
||||
" ldarx %0,0,%1\n" /* load and reserve */
|
||||
PPC405_ERR77_SYNC /* ppc405 Erratum 77 */
|
||||
" stdcx. %2,0,%1\n" /* store new value */
|
||||
" bne- loop_%=\n" /* loop if lost */
|
||||
" isync\n" /* memory barrier */
|
||||
asm volatile ("1:\n" /* lost reservation */
|
||||
" ldarx %0,0,%1\n" /* load and reserve */
|
||||
PPC405_ERR77_SYNC /* ppc405 Erratum 77 */
|
||||
" stdcx. %2,0,%1\n" /* store new value */
|
||||
" bne- 1b\n" /* loop if lost */
|
||||
" isync\n" /* memory barrier */
|
||||
: "=&r" (prev)
|
||||
: "b" (mem), "r" (with)
|
||||
: "cc", "memory");
|
||||
|
@ -38,10 +38,10 @@ static APR_INLINE apr_uint32_t atomic_add(volatile apr_uint32_t *mem, apr_uint32
|
||||
apr_uint32_t prev = *mem, temp;
|
||||
|
||||
asm volatile ("loop_%=:\n"
|
||||
" lr %1,%0\n"
|
||||
" alr %1,%3\n"
|
||||
" cs %0,%1,%2\n"
|
||||
" jl loop_%=\n"
|
||||
" lr %1,%0\n"
|
||||
" alr %1,%3\n"
|
||||
" cs %0,%1,%2\n"
|
||||
" jl loop_%=\n"
|
||||
: "+d" (prev), "+d" (temp), "=Q" (*mem)
|
||||
: "d" (val), "m" (*mem)
|
||||
: "cc", "memory");
|
||||
@ -64,10 +64,10 @@ static APR_INLINE apr_uint32_t atomic_sub(volatile apr_uint32_t *mem, apr_uint32
|
||||
apr_uint32_t prev = *mem, temp;
|
||||
|
||||
asm volatile ("loop_%=:\n"
|
||||
" lr %1,%0\n"
|
||||
" slr %1,%3\n"
|
||||
" cs %0,%1,%2\n"
|
||||
" jl loop_%=\n"
|
||||
" lr %1,%0\n"
|
||||
" slr %1,%3\n"
|
||||
" cs %0,%1,%2\n"
|
||||
" jl loop_%=\n"
|
||||
: "+d" (prev), "+d" (temp), "=Q" (*mem)
|
||||
: "d" (val), "m" (*mem)
|
||||
: "cc", "memory");
|
||||
@ -88,7 +88,7 @@ APR_DECLARE(int) apr_atomic_dec32(volatile apr_uint32_t *mem)
|
||||
APR_DECLARE(apr_uint32_t) apr_atomic_cas32(volatile apr_uint32_t *mem, apr_uint32_t with,
|
||||
apr_uint32_t cmp)
|
||||
{
|
||||
asm volatile (" cs %0,%2,%1\n"
|
||||
asm volatile (" cs %0,%2,%1\n"
|
||||
: "+d" (cmp), "=Q" (*mem)
|
||||
: "d" (with), "m" (*mem)
|
||||
: "cc", "memory");
|
||||
@ -101,8 +101,8 @@ APR_DECLARE(apr_uint32_t) apr_atomic_xchg32(volatile apr_uint32_t *mem, apr_uint
|
||||
apr_uint32_t prev = *mem;
|
||||
|
||||
asm volatile ("loop_%=:\n"
|
||||
" cs %0,%2,%1\n"
|
||||
" jl loop_%=\n"
|
||||
" cs %0,%2,%1\n"
|
||||
" jl loop_%=\n"
|
||||
: "+d" (prev), "=Q" (*mem)
|
||||
: "d" (val), "m" (*mem)
|
||||
: "cc", "memory");
|
||||
@ -114,12 +114,12 @@ APR_DECLARE(void*) apr_atomic_casptr(volatile void **mem, void *with, const void
|
||||
{
|
||||
void *prev = (void *) cmp;
|
||||
#if APR_SIZEOF_VOIDP == 4
|
||||
asm volatile (" cs %0,%2,%1\n"
|
||||
asm volatile (" cs %0,%2,%1\n"
|
||||
: "+d" (prev), "=Q" (*mem)
|
||||
: "d" (with), "m" (*mem)
|
||||
: "cc", "memory");
|
||||
#elif APR_SIZEOF_VOIDP == 8
|
||||
asm volatile (" csg %0,%2,%1\n"
|
||||
asm volatile (" csg %0,%2,%1\n"
|
||||
: "+d" (prev), "=Q" (*mem)
|
||||
: "d" (with), "m" (*mem)
|
||||
: "cc", "memory");
|
||||
@ -134,15 +134,15 @@ APR_DECLARE(void*) apr_atomic_xchgptr(volatile void **mem, void *with)
|
||||
void *prev = (void *) *mem;
|
||||
#if APR_SIZEOF_VOIDP == 4
|
||||
asm volatile ("loop_%=:\n"
|
||||
" cs %0,%2,%1\n"
|
||||
" jl loop_%=\n"
|
||||
" cs %0,%2,%1\n"
|
||||
" jl loop_%=\n"
|
||||
: "+d" (prev), "=Q" (*mem)
|
||||
: "d" (with), "m" (*mem)
|
||||
: "cc", "memory");
|
||||
#elif APR_SIZEOF_VOIDP == 8
|
||||
asm volatile ("loop_%=:\n"
|
||||
" csg %0,%2,%1\n"
|
||||
" jl loop_%=\n"
|
||||
" csg %0,%2,%1\n"
|
||||
" jl loop_%=\n"
|
||||
: "+d" (prev), "=Q" (*mem)
|
||||
: "d" (with), "m" (*mem)
|
||||
: "cc", "memory");
|
||||
|
@ -4,7 +4,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<div align="right">
|
||||
Last modified at [$Date: 2004-11-25 09:51:51 +1100 (Thu, 25 Nov 2004) $]
|
||||
Last modified at [$Date: 2004-11-24 17:51:51 -0500 (Wed, 24 Nov 2004) $]
|
||||
</div>
|
||||
|
||||
<h1>Using APR Pools</h1>
|
||||
|
@ -117,10 +117,10 @@ 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;
|
||||
}
|
||||
file_unlock(fp);
|
||||
if (rc) {
|
||||
return rc;
|
||||
}
|
||||
file_unlock(fp);
|
||||
}
|
||||
if (ftruncate(fp->filedes, offset) == -1) {
|
||||
return errno;
|
||||
|
@ -36,6 +36,12 @@
|
||||
* for Win32 or Netware by those build environments, respectively.
|
||||
*/
|
||||
|
||||
/* Make sure we have our platform identifier macro defined we ask for later.
|
||||
*/
|
||||
#if defined(_WIN32) && !defined(WIN32)
|
||||
#define WIN32 1
|
||||
#endif
|
||||
|
||||
#if defined(WIN32) || defined(DOXYGEN)
|
||||
|
||||
/* Ignore most warnings (back down to /W3) for poorly constructed headers
|
||||
@ -377,7 +383,7 @@ typedef int apr_off_t;
|
||||
typedef int apr_socklen_t;
|
||||
typedef apr_uint64_t apr_ino_t;
|
||||
|
||||
#ifdef WIN64
|
||||
#ifdef _WIN64
|
||||
#define APR_SIZEOF_VOIDP 8
|
||||
#else
|
||||
#define APR_SIZEOF_VOIDP 4
|
||||
@ -552,7 +558,7 @@ typedef apr_uint32_t apr_uintptr_t;
|
||||
#define APR_DECLARE_DATA __declspec(dllimport)
|
||||
#endif
|
||||
|
||||
#ifdef WIN64
|
||||
#ifdef _WIN64
|
||||
#define APR_SSIZE_T_FMT "I64d"
|
||||
#define APR_SIZE_T_FMT "I64u"
|
||||
#else
|
||||
|
@ -71,7 +71,8 @@ struct apr_memnode_t {
|
||||
* @param allocator The allocator we have just created.
|
||||
*
|
||||
*/
|
||||
APR_DECLARE(apr_status_t) apr_allocator_create(apr_allocator_t **allocator);
|
||||
APR_DECLARE(apr_status_t) apr_allocator_create(apr_allocator_t **allocator)
|
||||
__attribute__((nonnull(1)));
|
||||
|
||||
/**
|
||||
* Destroy an allocator
|
||||
@ -79,7 +80,8 @@ APR_DECLARE(apr_status_t) apr_allocator_create(apr_allocator_t **allocator);
|
||||
* @remark Any memnodes not given back to the allocator prior to destroying
|
||||
* will _not_ be free()d.
|
||||
*/
|
||||
APR_DECLARE(void) apr_allocator_destroy(apr_allocator_t *allocator);
|
||||
APR_DECLARE(void) apr_allocator_destroy(apr_allocator_t *allocator)
|
||||
__attribute__((nonnull(1)));
|
||||
|
||||
/**
|
||||
* Allocate a block of mem from the allocator
|
||||
@ -88,7 +90,8 @@ APR_DECLARE(void) apr_allocator_destroy(apr_allocator_t *allocator);
|
||||
* memnode structure)
|
||||
*/
|
||||
APR_DECLARE(apr_memnode_t *) apr_allocator_alloc(apr_allocator_t *allocator,
|
||||
apr_size_t size);
|
||||
apr_size_t size)
|
||||
__attribute__((nonnull(1)));
|
||||
|
||||
/**
|
||||
* Free a list of blocks of mem, giving them back to the allocator.
|
||||
@ -98,7 +101,8 @@ APR_DECLARE(apr_memnode_t *) apr_allocator_alloc(apr_allocator_t *allocator,
|
||||
* @param memnode The memory node to return
|
||||
*/
|
||||
APR_DECLARE(void) apr_allocator_free(apr_allocator_t *allocator,
|
||||
apr_memnode_t *memnode);
|
||||
apr_memnode_t *memnode)
|
||||
__attribute__((nonnull(1,2)));
|
||||
|
||||
#include "apr_pools.h"
|
||||
|
||||
@ -114,13 +118,15 @@ APR_DECLARE(void) apr_allocator_free(apr_allocator_t *allocator,
|
||||
* the allocator will never be destroyed.
|
||||
*/
|
||||
APR_DECLARE(void) apr_allocator_owner_set(apr_allocator_t *allocator,
|
||||
apr_pool_t *pool);
|
||||
apr_pool_t *pool)
|
||||
__attribute__((nonnull(1)));
|
||||
|
||||
/**
|
||||
* Get the current owner of the allocator
|
||||
* @param allocator The allocator to get the owner from
|
||||
*/
|
||||
APR_DECLARE(apr_pool_t *) apr_allocator_owner_get(apr_allocator_t *allocator);
|
||||
APR_DECLARE(apr_pool_t *) apr_allocator_owner_get(apr_allocator_t *allocator)
|
||||
__attribute__((nonnull(1)));
|
||||
|
||||
/**
|
||||
* Set the current threshold at which the allocator should start
|
||||
@ -129,7 +135,8 @@ APR_DECLARE(apr_pool_t *) apr_allocator_owner_get(apr_allocator_t *allocator);
|
||||
* @param size The threshold. 0 == unlimited.
|
||||
*/
|
||||
APR_DECLARE(void) apr_allocator_max_free_set(apr_allocator_t *allocator,
|
||||
apr_size_t size);
|
||||
apr_size_t size)
|
||||
__attribute__((nonnull(1)));
|
||||
|
||||
#include "apr_thread_mutex.h"
|
||||
|
||||
@ -140,14 +147,16 @@ APR_DECLARE(void) apr_allocator_max_free_set(apr_allocator_t *allocator,
|
||||
* @param mutex The mutex
|
||||
*/
|
||||
APR_DECLARE(void) apr_allocator_mutex_set(apr_allocator_t *allocator,
|
||||
apr_thread_mutex_t *mutex);
|
||||
apr_thread_mutex_t *mutex)
|
||||
__attribute__((nonnull(1)));
|
||||
|
||||
/**
|
||||
* Get the mutex currently set for the allocator
|
||||
* @param allocator The allocator
|
||||
*/
|
||||
APR_DECLARE(apr_thread_mutex_t *) apr_allocator_mutex_get(
|
||||
apr_allocator_t *allocator);
|
||||
apr_allocator_t *allocator)
|
||||
__attribute__((nonnull(1)));
|
||||
|
||||
#endif /* APR_HAS_THREADS */
|
||||
|
||||
|
@ -76,7 +76,7 @@ typedef int apr_signum_t;
|
||||
* @return offset
|
||||
*/
|
||||
|
||||
#if defined(CRAY) || (defined(__arm) && !defined(LINUX))
|
||||
#if defined(CRAY) || (defined(__arm) && !(defined(LINUX) || defined(__FreeBSD__)))
|
||||
#ifdef __STDC__
|
||||
#define APR_OFFSET(p_type,field) _Offsetof(p_type,field)
|
||||
#else
|
||||
|
@ -756,6 +756,8 @@ APR_DECLARE(int) apr_ipsubnet_test(apr_ipsubnet_t *ipsub, apr_sockaddr_t *sa);
|
||||
* @param name The accept filter
|
||||
* @param args Any extra args to the accept filter. Passing NULL here removes
|
||||
* the accept filter.
|
||||
* @bug name and args should have been declared as const char *, as they are in
|
||||
* APR 2.0
|
||||
*/
|
||||
apr_status_t apr_socket_accept_filter(apr_socket_t *sock, char *name,
|
||||
char *args);
|
||||
|
@ -196,7 +196,8 @@ APR_DECLARE(void) apr_pool_terminate(void);
|
||||
APR_DECLARE(apr_status_t) apr_pool_create_ex(apr_pool_t **newpool,
|
||||
apr_pool_t *parent,
|
||||
apr_abortfunc_t abort_fn,
|
||||
apr_allocator_t *allocator);
|
||||
apr_allocator_t *allocator)
|
||||
__attribute__((nonnull(1)));
|
||||
|
||||
/**
|
||||
* Create a new pool.
|
||||
@ -220,7 +221,8 @@ APR_DECLARE(apr_status_t) apr_pool_create_core_ex(apr_pool_t **newpool,
|
||||
*/
|
||||
APR_DECLARE(apr_status_t) apr_pool_create_unmanaged_ex(apr_pool_t **newpool,
|
||||
apr_abortfunc_t abort_fn,
|
||||
apr_allocator_t *allocator);
|
||||
apr_allocator_t *allocator)
|
||||
__attribute__((nonnull(1)));
|
||||
|
||||
/**
|
||||
* Debug version of apr_pool_create_ex.
|
||||
@ -242,7 +244,8 @@ APR_DECLARE(apr_status_t) apr_pool_create_ex_debug(apr_pool_t **newpool,
|
||||
apr_pool_t *parent,
|
||||
apr_abortfunc_t abort_fn,
|
||||
apr_allocator_t *allocator,
|
||||
const char *file_line);
|
||||
const char *file_line)
|
||||
__attribute__((nonnull(1)));
|
||||
|
||||
#if APR_POOL_DEBUG
|
||||
#define apr_pool_create_ex(newpool, parent, abort_fn, allocator) \
|
||||
@ -277,7 +280,8 @@ APR_DECLARE(apr_status_t) apr_pool_create_core_ex_debug(apr_pool_t **newpool,
|
||||
APR_DECLARE(apr_status_t) apr_pool_create_unmanaged_ex_debug(apr_pool_t **newpool,
|
||||
apr_abortfunc_t abort_fn,
|
||||
apr_allocator_t *allocator,
|
||||
const char *file_line);
|
||||
const char *file_line)
|
||||
__attribute__((nonnull(1)));
|
||||
|
||||
#if APR_POOL_DEBUG
|
||||
#define apr_pool_create_core_ex(newpool, abort_fn, allocator) \
|
||||
@ -343,7 +347,8 @@ APR_DECLARE(apr_status_t) apr_pool_create_unmanaged(apr_pool_t **newpool);
|
||||
* Find the pool's allocator
|
||||
* @param pool The pool to get the allocator from.
|
||||
*/
|
||||
APR_DECLARE(apr_allocator_t *) apr_pool_allocator_get(apr_pool_t *pool);
|
||||
APR_DECLARE(apr_allocator_t *) apr_pool_allocator_get(apr_pool_t *pool)
|
||||
__attribute__((nonnull(1)));
|
||||
|
||||
/**
|
||||
* Clear all memory in the pool and run all the cleanups. This also destroys all
|
||||
@ -353,7 +358,7 @@ APR_DECLARE(apr_allocator_t *) apr_pool_allocator_get(apr_pool_t *pool);
|
||||
* to re-use this memory for the next allocation.
|
||||
* @see apr_pool_destroy()
|
||||
*/
|
||||
APR_DECLARE(void) apr_pool_clear(apr_pool_t *p);
|
||||
APR_DECLARE(void) apr_pool_clear(apr_pool_t *p) __attribute__((nonnull(1)));
|
||||
|
||||
/**
|
||||
* Debug version of apr_pool_clear.
|
||||
@ -369,7 +374,8 @@ APR_DECLARE(void) apr_pool_clear(apr_pool_t *p);
|
||||
* and don't call apr_pool_destroy_clear directly.
|
||||
*/
|
||||
APR_DECLARE(void) apr_pool_clear_debug(apr_pool_t *p,
|
||||
const char *file_line);
|
||||
const char *file_line)
|
||||
__attribute__((nonnull(1)));
|
||||
|
||||
#if APR_POOL_DEBUG
|
||||
#define apr_pool_clear(p) \
|
||||
@ -382,7 +388,7 @@ APR_DECLARE(void) apr_pool_clear_debug(apr_pool_t *p,
|
||||
* @param p The pool to destroy
|
||||
* @remark This will actually free the memory
|
||||
*/
|
||||
APR_DECLARE(void) apr_pool_destroy(apr_pool_t *p);
|
||||
APR_DECLARE(void) apr_pool_destroy(apr_pool_t *p) __attribute__((nonnull(1)));
|
||||
|
||||
/**
|
||||
* Debug version of apr_pool_destroy.
|
||||
@ -398,7 +404,8 @@ APR_DECLARE(void) apr_pool_destroy(apr_pool_t *p);
|
||||
* and don't call apr_pool_destroy_debug directly.
|
||||
*/
|
||||
APR_DECLARE(void) apr_pool_destroy_debug(apr_pool_t *p,
|
||||
const char *file_line);
|
||||
const char *file_line)
|
||||
__attribute__((nonnull(1)));
|
||||
|
||||
#if APR_POOL_DEBUG
|
||||
#define apr_pool_destroy(p) \
|
||||
@ -416,7 +423,11 @@ APR_DECLARE(void) apr_pool_destroy_debug(apr_pool_t *p,
|
||||
* @param size The amount of memory to allocate
|
||||
* @return The allocated memory
|
||||
*/
|
||||
APR_DECLARE(void *) apr_palloc(apr_pool_t *p, apr_size_t size);
|
||||
APR_DECLARE(void *) apr_palloc(apr_pool_t *p, apr_size_t size)
|
||||
#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
|
||||
__attribute__((alloc_size(2)))
|
||||
#endif
|
||||
__attribute__((nonnull(1)));
|
||||
|
||||
/**
|
||||
* Debug version of apr_palloc
|
||||
@ -427,7 +438,11 @@ APR_DECLARE(void *) apr_palloc(apr_pool_t *p, apr_size_t size);
|
||||
* @return See: apr_palloc
|
||||
*/
|
||||
APR_DECLARE(void *) apr_palloc_debug(apr_pool_t *p, apr_size_t size,
|
||||
const char *file_line);
|
||||
const char *file_line)
|
||||
#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
|
||||
__attribute__((alloc_size(2)))
|
||||
#endif
|
||||
__attribute__((nonnull(1)));
|
||||
|
||||
#if APR_POOL_DEBUG
|
||||
#define apr_palloc(p, size) \
|
||||
@ -455,7 +470,8 @@ APR_DECLARE(void *) apr_pcalloc(apr_pool_t *p, apr_size_t size);
|
||||
* @return See: apr_pcalloc
|
||||
*/
|
||||
APR_DECLARE(void *) apr_pcalloc_debug(apr_pool_t *p, apr_size_t size,
|
||||
const char *file_line);
|
||||
const char *file_line)
|
||||
__attribute__((nonnull(1)));
|
||||
|
||||
#if APR_POOL_DEBUG
|
||||
#define apr_pcalloc(p, size) \
|
||||
@ -476,21 +492,24 @@ APR_DECLARE(void *) apr_pcalloc_debug(apr_pool_t *p, apr_size_t size,
|
||||
* deal with the error accordingly.
|
||||
*/
|
||||
APR_DECLARE(void) apr_pool_abort_set(apr_abortfunc_t abortfunc,
|
||||
apr_pool_t *pool);
|
||||
apr_pool_t *pool)
|
||||
__attribute__((nonnull(2)));
|
||||
|
||||
/**
|
||||
* Get the abort function associated with the specified pool.
|
||||
* @param pool The pool for retrieving the abort function.
|
||||
* @return The abort function for the given pool.
|
||||
*/
|
||||
APR_DECLARE(apr_abortfunc_t) apr_pool_abort_get(apr_pool_t *pool);
|
||||
APR_DECLARE(apr_abortfunc_t) apr_pool_abort_get(apr_pool_t *pool)
|
||||
__attribute__((nonnull(1)));
|
||||
|
||||
/**
|
||||
* Get the parent pool of the specified pool.
|
||||
* @param pool The pool for retrieving the parent pool.
|
||||
* @return The parent of the given pool.
|
||||
*/
|
||||
APR_DECLARE(apr_pool_t *) apr_pool_parent_get(apr_pool_t *pool);
|
||||
APR_DECLARE(apr_pool_t *) apr_pool_parent_get(apr_pool_t *pool)
|
||||
__attribute__((nonnull(1)));
|
||||
|
||||
/**
|
||||
* Determine if pool a is an ancestor of pool b.
|
||||
@ -510,7 +529,8 @@ APR_DECLARE(int) apr_pool_is_ancestor(apr_pool_t *a, apr_pool_t *b);
|
||||
* @param pool The pool to tag
|
||||
* @param tag The tag
|
||||
*/
|
||||
APR_DECLARE(void) apr_pool_tag(apr_pool_t *pool, const char *tag);
|
||||
APR_DECLARE(void) apr_pool_tag(apr_pool_t *pool, const char *tag)
|
||||
__attribute__((nonnull(1)));
|
||||
|
||||
|
||||
/*
|
||||
@ -536,11 +556,11 @@ APR_DECLARE(void) apr_pool_tag(apr_pool_t *pool, const char *tag);
|
||||
* key names is a typical way to help ensure this uniqueness.
|
||||
*
|
||||
*/
|
||||
APR_DECLARE(apr_status_t) apr_pool_userdata_set(
|
||||
const void *data,
|
||||
const char *key,
|
||||
apr_status_t (*cleanup)(void *),
|
||||
apr_pool_t *pool);
|
||||
APR_DECLARE(apr_status_t) apr_pool_userdata_set(const void *data,
|
||||
const char *key,
|
||||
apr_status_t (*cleanup)(void *),
|
||||
apr_pool_t *pool)
|
||||
__attribute__((nonnull(2,4)));
|
||||
|
||||
/**
|
||||
* Set the data associated with the current pool
|
||||
@ -562,10 +582,10 @@ APR_DECLARE(apr_status_t) apr_pool_userdata_set(
|
||||
*
|
||||
*/
|
||||
APR_DECLARE(apr_status_t) apr_pool_userdata_setn(
|
||||
const void *data,
|
||||
const char *key,
|
||||
apr_status_t (*cleanup)(void *),
|
||||
apr_pool_t *pool);
|
||||
const void *data, const char *key,
|
||||
apr_status_t (*cleanup)(void *),
|
||||
apr_pool_t *pool)
|
||||
__attribute__((nonnull(2,4)));
|
||||
|
||||
/**
|
||||
* Return the data associated with the current pool.
|
||||
@ -574,7 +594,8 @@ APR_DECLARE(apr_status_t) apr_pool_userdata_setn(
|
||||
* @param pool The current pool.
|
||||
*/
|
||||
APR_DECLARE(apr_status_t) apr_pool_userdata_get(void **data, const char *key,
|
||||
apr_pool_t *pool);
|
||||
apr_pool_t *pool)
|
||||
__attribute__((nonnull(1,2,3)));
|
||||
|
||||
|
||||
/**
|
||||
@ -601,10 +622,10 @@ APR_DECLARE(apr_status_t) apr_pool_userdata_get(void **data, const char *key,
|
||||
* to exec - this function is called in the child, obviously!
|
||||
*/
|
||||
APR_DECLARE(void) apr_pool_cleanup_register(
|
||||
apr_pool_t *p,
|
||||
const void *data,
|
||||
apr_status_t (*plain_cleanup)(void *),
|
||||
apr_status_t (*child_cleanup)(void *));
|
||||
apr_pool_t *p, const void *data,
|
||||
apr_status_t (*plain_cleanup)(void *),
|
||||
apr_status_t (*child_cleanup)(void *))
|
||||
__attribute__((nonnull(3,4)));
|
||||
|
||||
/**
|
||||
* Register a function to be called when a pool is cleared or destroyed.
|
||||
@ -619,9 +640,9 @@ APR_DECLARE(void) apr_pool_cleanup_register(
|
||||
* or destroyed
|
||||
*/
|
||||
APR_DECLARE(void) apr_pool_pre_cleanup_register(
|
||||
apr_pool_t *p,
|
||||
const void *data,
|
||||
apr_status_t (*plain_cleanup)(void *));
|
||||
apr_pool_t *p, const void *data,
|
||||
apr_status_t (*plain_cleanup)(void *))
|
||||
__attribute__((nonnull(3)));
|
||||
|
||||
/**
|
||||
* Remove a previously registered cleanup function.
|
||||
@ -636,7 +657,8 @@ APR_DECLARE(void) apr_pool_pre_cleanup_register(
|
||||
* function
|
||||
*/
|
||||
APR_DECLARE(void) apr_pool_cleanup_kill(apr_pool_t *p, const void *data,
|
||||
apr_status_t (*cleanup)(void *));
|
||||
apr_status_t (*cleanup)(void *))
|
||||
__attribute__((nonnull(3)));
|
||||
|
||||
/**
|
||||
* Replace the child cleanup function of a previously registered cleanup.
|
||||
@ -651,10 +673,10 @@ APR_DECLARE(void) apr_pool_cleanup_kill(apr_pool_t *p, const void *data,
|
||||
* @param child_cleanup The function to register as the child cleanup
|
||||
*/
|
||||
APR_DECLARE(void) apr_pool_child_cleanup_set(
|
||||
apr_pool_t *p,
|
||||
const void *data,
|
||||
apr_status_t (*plain_cleanup)(void *),
|
||||
apr_status_t (*child_cleanup)(void *));
|
||||
apr_pool_t *p, const void *data,
|
||||
apr_status_t (*plain_cleanup)(void *),
|
||||
apr_status_t (*child_cleanup)(void *))
|
||||
__attribute__((nonnull(3,4)));
|
||||
|
||||
/**
|
||||
* Run the specified cleanup function immediately and unregister it.
|
||||
@ -667,10 +689,9 @@ APR_DECLARE(void) apr_pool_child_cleanup_set(
|
||||
* @param data The data to remove from cleanup
|
||||
* @param cleanup The function to remove from cleanup
|
||||
*/
|
||||
APR_DECLARE(apr_status_t) apr_pool_cleanup_run(
|
||||
apr_pool_t *p,
|
||||
void *data,
|
||||
apr_status_t (*cleanup)(void *));
|
||||
APR_DECLARE(apr_status_t) apr_pool_cleanup_run(apr_pool_t *p, void *data,
|
||||
apr_status_t (*cleanup)(void *))
|
||||
__attribute__((nonnull(3)));
|
||||
|
||||
/**
|
||||
* An empty cleanup function.
|
||||
@ -739,7 +760,8 @@ APR_DECLARE(void) apr_pool_cleanup_for_exec(void);
|
||||
* @param p The parent pool
|
||||
* @param sub The subpool
|
||||
*/
|
||||
APR_DECLARE(void) apr_pool_join(apr_pool_t *p, apr_pool_t *sub);
|
||||
APR_DECLARE(void) apr_pool_join(apr_pool_t *p, apr_pool_t *sub)
|
||||
__attribute__((nonnull(2)));
|
||||
|
||||
/**
|
||||
* Find a pool from something allocated in it.
|
||||
@ -754,7 +776,8 @@ APR_DECLARE(apr_pool_t *) apr_pool_find(const void *mem);
|
||||
* @param recurse Recurse/include the subpools' sizes
|
||||
* @return The number of bytes
|
||||
*/
|
||||
APR_DECLARE(apr_size_t) apr_pool_num_bytes(apr_pool_t *p, int recurse);
|
||||
APR_DECLARE(apr_size_t) apr_pool_num_bytes(apr_pool_t *p, int recurse)
|
||||
__attribute__((nonnull(1)));
|
||||
|
||||
/**
|
||||
* Lock a pool
|
||||
|
@ -106,7 +106,11 @@ APR_DECLARE(char *) apr_pstrdup(apr_pool_t *p, const char *s);
|
||||
* has 'n' or more characters. If the string might contain
|
||||
* fewer characters, use apr_pstrndup.
|
||||
*/
|
||||
APR_DECLARE(char *) apr_pstrmemdup(apr_pool_t *p, const char *s, apr_size_t n);
|
||||
APR_DECLARE(char *) apr_pstrmemdup(apr_pool_t *p, const char *s, apr_size_t n)
|
||||
#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
|
||||
__attribute__((alloc_size(3)))
|
||||
#endif
|
||||
;
|
||||
|
||||
/**
|
||||
* Duplicate at most n characters of a string into memory allocated
|
||||
@ -128,7 +132,11 @@ APR_DECLARE(char *) apr_pstrndup(apr_pool_t *p, const char *s, apr_size_t n);
|
||||
* @param n The number of bytes to duplicate
|
||||
* @return The new block of memory
|
||||
*/
|
||||
APR_DECLARE(void *) apr_pmemdup(apr_pool_t *p, const void *m, apr_size_t n);
|
||||
APR_DECLARE(void *) apr_pmemdup(apr_pool_t *p, const void *m, apr_size_t n)
|
||||
#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
|
||||
__attribute__((alloc_size(3)))
|
||||
#endif
|
||||
;
|
||||
|
||||
/**
|
||||
* Concatenate multiple strings, allocating memory out a pool
|
||||
|
@ -315,7 +315,7 @@ APR_DECLARE(apr_status_t) apr_thread_once(apr_thread_once_t *control,
|
||||
APR_DECLARE(apr_status_t) apr_thread_detach(apr_thread_t *thd);
|
||||
|
||||
/**
|
||||
* Return the pool associated with the current thread.
|
||||
* Return user data associated with the current thread.
|
||||
* @param data The user data associated with the thread.
|
||||
* @param key The key to associate with the data
|
||||
* @param thread The currently open thread.
|
||||
@ -324,7 +324,7 @@ APR_DECLARE(apr_status_t) apr_thread_data_get(void **data, const char *key,
|
||||
apr_thread_t *thread);
|
||||
|
||||
/**
|
||||
* Return the pool associated with the current thread.
|
||||
* Set user data associated with the current thread.
|
||||
* @param data The user data to associate with the thread.
|
||||
* @param key The key to use for associating the data with the thread
|
||||
* @param cleanup The cleanup routine to use when the thread is destroyed.
|
||||
|
@ -38,6 +38,9 @@
|
||||
*/
|
||||
|
||||
|
||||
#define APR_COPYRIGHT "Copyright (c) 2013 The Apache Software " \
|
||||
"Foundation or its licensors, as applicable."
|
||||
|
||||
/* The numeric compile-time version constants. These constants are the
|
||||
* authoritative version numbers for APR.
|
||||
*/
|
||||
@ -59,7 +62,7 @@
|
||||
* The Patch Level never includes API changes, simply bug fixes.
|
||||
* Reset to 0 when upgrading APR_MINOR_VERSION
|
||||
*/
|
||||
#define APR_PATCH_VERSION 6
|
||||
#define APR_PATCH_VERSION 8
|
||||
|
||||
/**
|
||||
* The symbol APR_IS_DEV_VERSION is only defined for internal,
|
||||
@ -87,7 +90,9 @@
|
||||
|
||||
#if defined(APR_IS_DEV_VERSION) || defined(DOXYGEN)
|
||||
/** Internal: string form of the "is dev" flag */
|
||||
#ifndef APR_IS_DEV_STRING
|
||||
#define APR_IS_DEV_STRING "-dev"
|
||||
#endif
|
||||
#else
|
||||
#define APR_IS_DEV_STRING ""
|
||||
#endif
|
||||
|
@ -1,8 +1,5 @@
|
||||
#include "apr_version.h"
|
||||
|
||||
#define APR_COPYRIGHT "Copyright (c) 2011 The Apache Software " \
|
||||
"Foundation or its licensors, as applicable."
|
||||
|
||||
#define APR_LICENSE \
|
||||
"Licensed to the Apache Software Foundation (ASF) under one or more " \
|
||||
"contributor license agreements. See the NOTICE file distributed with " \
|
||||
|
@ -193,36 +193,39 @@ static apr_status_t do_mcast(int type, apr_socket_t *sock,
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* Set the IP_MULTICAST_TTL or IP_MULTICAST_LOOP option, or IPv6
|
||||
* equivalents, for the socket, to the given value. Note that this
|
||||
* function *only works* for those particular option types. */
|
||||
static apr_status_t do_mcast_opt(int type, apr_socket_t *sock,
|
||||
apr_byte_t value)
|
||||
{
|
||||
apr_status_t rv = APR_SUCCESS;
|
||||
|
||||
if (sock_is_ipv4(sock)) {
|
||||
/* For the IP_MULTICAST_* options, this must be a (char *)
|
||||
* pointer. */
|
||||
if (setsockopt(sock->socketdes, IPPROTO_IP, type,
|
||||
(const void *) &value, sizeof(value)) == -1) {
|
||||
rv = errno;
|
||||
}
|
||||
}
|
||||
#if APR_HAVE_IPV6
|
||||
else if (sock_is_ipv6(sock) && type == IP_MULTICAST_LOOP) {
|
||||
unsigned int loopopt = value;
|
||||
type = IPV6_MULTICAST_LOOP;
|
||||
if (setsockopt(sock->socketdes, IPPROTO_IPV6, type,
|
||||
(const void *) &loopopt, sizeof(loopopt)) == -1) {
|
||||
rv = errno;
|
||||
}
|
||||
}
|
||||
else if (sock_is_ipv6(sock)) {
|
||||
/* For the IPV6_* options, an (int *) pointer must be used. */
|
||||
int ivalue = value;
|
||||
|
||||
if (type == IP_MULTICAST_TTL) {
|
||||
type = IPV6_MULTICAST_HOPS;
|
||||
}
|
||||
else if (type == IP_MULTICAST_LOOP) {
|
||||
type = IPV6_MULTICAST_LOOP;
|
||||
}
|
||||
else {
|
||||
return APR_ENOTIMPL;
|
||||
}
|
||||
|
||||
if (setsockopt(sock->socketdes, IPPROTO_IPV6, type,
|
||||
&value, sizeof(value)) == -1) {
|
||||
(const void *) &ivalue, sizeof(ivalue)) == -1) {
|
||||
rv = errno;
|
||||
}
|
||||
}
|
||||
|
@ -174,7 +174,14 @@ apr_status_t apr_socket_recvfrom(apr_sockaddr_t *from, apr_socket_t *sock,
|
||||
return errno;
|
||||
}
|
||||
|
||||
apr_sockaddr_vars_set(from, from->sa.sin.sin_family, ntohs(from->sa.sin.sin_port));
|
||||
/*
|
||||
* Check if we have a valid address. recvfrom() with MSG_PEEK may return
|
||||
* success without filling in the address.
|
||||
*/
|
||||
if (from->salen > APR_OFFSETOF(struct sockaddr_in, sin_port)) {
|
||||
apr_sockaddr_vars_set(from, from->sa.sin.sin_family,
|
||||
ntohs(from->sa.sin.sin_port));
|
||||
}
|
||||
|
||||
(*len) = rv;
|
||||
if (rv == 0 && sock->type == SOCK_STREAM) {
|
||||
@ -245,7 +252,7 @@ apr_status_t apr_socket_sendv(apr_socket_t * sock, const struct iovec *vec,
|
||||
/* Define a structure to pass in when we have a NULL header value */
|
||||
static apr_hdtr_t no_hdtr;
|
||||
|
||||
#if defined(__linux__) && defined(HAVE_WRITEV)
|
||||
#if (defined(__linux__) || defined(__GNU__)) && defined(HAVE_WRITEV)
|
||||
|
||||
apr_status_t apr_socket_sendfile(apr_socket_t *sock, apr_file_t *file,
|
||||
apr_hdtr_t *hdtr, apr_off_t *offset,
|
||||
@ -285,9 +292,6 @@ apr_status_t apr_socket_sendfile(apr_socket_t *sock, apr_file_t *file,
|
||||
hdtr = &no_hdtr;
|
||||
}
|
||||
|
||||
/* Ignore flags for now. */
|
||||
flags = 0;
|
||||
|
||||
if (hdtr->numheaders > 0) {
|
||||
apr_size_t hdrbytes;
|
||||
|
||||
|
@ -356,9 +356,27 @@ static apr_status_t call_resolver(apr_sockaddr_t **sa,
|
||||
}
|
||||
error = getaddrinfo(hostname, servname, &hints, &ai_list);
|
||||
#ifdef HAVE_GAI_ADDRCONFIG
|
||||
if (error == EAI_BADFLAGS && family == APR_UNSPEC) {
|
||||
/* Retry with no flags if AI_ADDRCONFIG was rejected. */
|
||||
hints.ai_flags = 0;
|
||||
/*
|
||||
* Using AI_ADDRCONFIG involves some unfortunate guesswork because it
|
||||
* does not consider loopback addresses when trying to determine if
|
||||
* IPv4 or IPv6 is configured on a system (see RFC 3493).
|
||||
* This is a problem if one actually wants to listen on or connect to
|
||||
* the loopback address of a protocol family that is not otherwise
|
||||
* configured on the system. See PR 52709.
|
||||
* To work around some of the problems, retry without AI_ADDRCONFIG
|
||||
* in case of EAI_ADDRFAMILY.
|
||||
* XXX: apr_sockaddr_info_get() should really accept a flag to determine
|
||||
* XXX: if AI_ADDRCONFIG's guesswork is wanted and if the address is
|
||||
* XXX: to be used for listen() or connect().
|
||||
*
|
||||
* In case of EAI_BADFLAGS, AI_ADDRCONFIG is not supported.
|
||||
*/
|
||||
if ((family == APR_UNSPEC) && (error == EAI_BADFLAGS
|
||||
#ifdef EAI_ADDRFAMILY
|
||||
|| error == EAI_ADDRFAMILY
|
||||
#endif
|
||||
)) {
|
||||
hints.ai_flags &= ~AI_ADDRCONFIG;
|
||||
error = getaddrinfo(hostname, servname, &hints, &ai_list);
|
||||
}
|
||||
#endif
|
||||
@ -367,7 +385,7 @@ static apr_status_t call_resolver(apr_sockaddr_t **sa,
|
||||
return apr_get_netos_error();
|
||||
#else
|
||||
if (error == EAI_SYSTEM) {
|
||||
return errno;
|
||||
return errno ? errno : APR_EGENERAL;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -422,6 +440,15 @@ static apr_status_t call_resolver(apr_sockaddr_t **sa,
|
||||
ai = ai->ai_next;
|
||||
}
|
||||
freeaddrinfo(ai_list);
|
||||
|
||||
if (prev_sa == NULL) {
|
||||
/*
|
||||
* getaddrinfo returned only useless entries and *sa is still empty.
|
||||
* This should be treated as an error.
|
||||
*/
|
||||
return APR_EGENERAL;
|
||||
}
|
||||
|
||||
return APR_SUCCESS;
|
||||
}
|
||||
|
||||
@ -555,6 +582,11 @@ static apr_status_t find_addresses(apr_sockaddr_t **sa,
|
||||
++curaddr;
|
||||
}
|
||||
|
||||
if (prev_sa == NULL) {
|
||||
/* this should not happen but no result should be treated as error */
|
||||
return APR_EGENERAL;
|
||||
}
|
||||
|
||||
return APR_SUCCESS;
|
||||
}
|
||||
|
||||
@ -1010,7 +1042,7 @@ APR_DECLARE(int) apr_ipsubnet_test(apr_ipsubnet_t *ipsub, apr_sockaddr_t *sa)
|
||||
/* XXX This line will segv on Win32 build with APR_HAVE_IPV6,
|
||||
* but without the IPV6 drivers installed.
|
||||
*/
|
||||
if (sa->sa.sin.sin_family == AF_INET) {
|
||||
if (sa->family == AF_INET) {
|
||||
if (ipsub->family == AF_INET &&
|
||||
((sa->sa.sin.sin_addr.s_addr & ipsub->mask[0]) == ipsub->sub[0])) {
|
||||
return 1;
|
||||
@ -1022,7 +1054,7 @@ APR_DECLARE(int) apr_ipsubnet_test(apr_ipsubnet_t *ipsub, apr_sockaddr_t *sa)
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
else if (sa->family == AF_INET6 && ipsub->family == AF_INET6) {
|
||||
apr_uint32_t *addr = (apr_uint32_t *)sa->ipaddr_ptr;
|
||||
|
||||
if ((addr[0] & ipsub->mask[0]) == ipsub->sub[0] &&
|
||||
|
@ -381,12 +381,33 @@ apr_status_t apr_gethostname(char *buf, apr_int32_t len, apr_pool_t *cont)
|
||||
}
|
||||
|
||||
#if APR_HAS_SO_ACCEPTFILTER
|
||||
apr_status_t apr_socket_accept_filter(apr_socket_t *sock, char *name,
|
||||
char *args)
|
||||
apr_status_t apr_socket_accept_filter(apr_socket_t *sock, char *nonconst_name,
|
||||
char *nonconst_args)
|
||||
{
|
||||
/* these should have been const; act like they are */
|
||||
const char *name = nonconst_name;
|
||||
const char *args = nonconst_args;
|
||||
|
||||
struct accept_filter_arg af;
|
||||
strncpy(af.af_name, name, 16);
|
||||
strncpy(af.af_arg, args, 256 - 16);
|
||||
socklen_t optlen = sizeof(af);
|
||||
|
||||
/* FreeBSD returns an error if the filter is already set; ignore
|
||||
* this call if we previously set it to the same value.
|
||||
*/
|
||||
if ((getsockopt(sock->socketdes, SOL_SOCKET, SO_ACCEPTFILTER,
|
||||
&af, &optlen)) == 0) {
|
||||
if (!strcmp(name, af.af_name) && !strcmp(args, af.af_arg)) {
|
||||
return APR_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
/* Uhh, at least in FreeBSD 9 the fields are declared as arrays of
|
||||
* these lengths; did sizeof not work in some ancient release?
|
||||
*
|
||||
* FreeBSD kernel sets the last byte to a '\0'.
|
||||
*/
|
||||
apr_cpystrn(af.af_name, name, 16);
|
||||
apr_cpystrn(af.af_arg, args, 256 - 16);
|
||||
|
||||
if ((setsockopt(sock->socketdes, SOL_SOCKET, SO_ACCEPTFILTER,
|
||||
&af, sizeof(af))) < 0) {
|
||||
|
@ -52,8 +52,6 @@ typedef apr_uint64_t sha2_word64; /* Exactly 8 bytes */
|
||||
/*** SHA-256/384/512 Various Length Definitions ***********************/
|
||||
/* NOTE: Most of these are in sha2.h */
|
||||
#define SHA256_SHORT_BLOCK_LENGTH (SHA256_BLOCK_LENGTH - 8)
|
||||
#define SHA384_SHORT_BLOCK_LENGTH (SHA384_BLOCK_LENGTH - 16)
|
||||
#define SHA512_SHORT_BLOCK_LENGTH (SHA512_BLOCK_LENGTH - 16)
|
||||
|
||||
|
||||
/*** ENDIAN REVERSAL MACROS *******************************************/
|
||||
@ -150,9 +148,7 @@ typedef apr_uint64_t sha2_word64; /* Exactly 8 bytes */
|
||||
* library -- they are intended for private internal visibility/use
|
||||
* only.
|
||||
*/
|
||||
void apr__SHA512_Last(SHA512_CTX*);
|
||||
void apr__SHA256_Transform(SHA256_CTX*, const sha2_word32*);
|
||||
void apr__SHA512_Transform(SHA512_CTX*, const sha2_word64*);
|
||||
|
||||
|
||||
/*** SHA-XYZ INITIAL HASH VALUES AND CONSTANTS ************************/
|
||||
@ -188,74 +184,6 @@ static const sha2_word32 sha256_initial_hash_value[8] = {
|
||||
0x5be0cd19UL
|
||||
};
|
||||
|
||||
/* Hash constant words K for SHA-384 and SHA-512: */
|
||||
static const sha2_word64 K512[80] = {
|
||||
APR_UINT64_C(0x428a2f98d728ae22), APR_UINT64_C(0x7137449123ef65cd),
|
||||
APR_UINT64_C(0xb5c0fbcfec4d3b2f), APR_UINT64_C(0xe9b5dba58189dbbc),
|
||||
APR_UINT64_C(0x3956c25bf348b538), APR_UINT64_C(0x59f111f1b605d019),
|
||||
APR_UINT64_C(0x923f82a4af194f9b), APR_UINT64_C(0xab1c5ed5da6d8118),
|
||||
APR_UINT64_C(0xd807aa98a3030242), APR_UINT64_C(0x12835b0145706fbe),
|
||||
APR_UINT64_C(0x243185be4ee4b28c), APR_UINT64_C(0x550c7dc3d5ffb4e2),
|
||||
APR_UINT64_C(0x72be5d74f27b896f), APR_UINT64_C(0x80deb1fe3b1696b1),
|
||||
APR_UINT64_C(0x9bdc06a725c71235), APR_UINT64_C(0xc19bf174cf692694),
|
||||
APR_UINT64_C(0xe49b69c19ef14ad2), APR_UINT64_C(0xefbe4786384f25e3),
|
||||
APR_UINT64_C(0x0fc19dc68b8cd5b5), APR_UINT64_C(0x240ca1cc77ac9c65),
|
||||
APR_UINT64_C(0x2de92c6f592b0275), APR_UINT64_C(0x4a7484aa6ea6e483),
|
||||
APR_UINT64_C(0x5cb0a9dcbd41fbd4), APR_UINT64_C(0x76f988da831153b5),
|
||||
APR_UINT64_C(0x983e5152ee66dfab), APR_UINT64_C(0xa831c66d2db43210),
|
||||
APR_UINT64_C(0xb00327c898fb213f), APR_UINT64_C(0xbf597fc7beef0ee4),
|
||||
APR_UINT64_C(0xc6e00bf33da88fc2), APR_UINT64_C(0xd5a79147930aa725),
|
||||
APR_UINT64_C(0x06ca6351e003826f), APR_UINT64_C(0x142929670a0e6e70),
|
||||
APR_UINT64_C(0x27b70a8546d22ffc), APR_UINT64_C(0x2e1b21385c26c926),
|
||||
APR_UINT64_C(0x4d2c6dfc5ac42aed), APR_UINT64_C(0x53380d139d95b3df),
|
||||
APR_UINT64_C(0x650a73548baf63de), APR_UINT64_C(0x766a0abb3c77b2a8),
|
||||
APR_UINT64_C(0x81c2c92e47edaee6), APR_UINT64_C(0x92722c851482353b),
|
||||
APR_UINT64_C(0xa2bfe8a14cf10364), APR_UINT64_C(0xa81a664bbc423001),
|
||||
APR_UINT64_C(0xc24b8b70d0f89791), APR_UINT64_C(0xc76c51a30654be30),
|
||||
APR_UINT64_C(0xd192e819d6ef5218), APR_UINT64_C(0xd69906245565a910),
|
||||
APR_UINT64_C(0xf40e35855771202a), APR_UINT64_C(0x106aa07032bbd1b8),
|
||||
APR_UINT64_C(0x19a4c116b8d2d0c8), APR_UINT64_C(0x1e376c085141ab53),
|
||||
APR_UINT64_C(0x2748774cdf8eeb99), APR_UINT64_C(0x34b0bcb5e19b48a8),
|
||||
APR_UINT64_C(0x391c0cb3c5c95a63), APR_UINT64_C(0x4ed8aa4ae3418acb),
|
||||
APR_UINT64_C(0x5b9cca4f7763e373), APR_UINT64_C(0x682e6ff3d6b2b8a3),
|
||||
APR_UINT64_C(0x748f82ee5defb2fc), APR_UINT64_C(0x78a5636f43172f60),
|
||||
APR_UINT64_C(0x84c87814a1f0ab72), APR_UINT64_C(0x8cc702081a6439ec),
|
||||
APR_UINT64_C(0x90befffa23631e28), APR_UINT64_C(0xa4506cebde82bde9),
|
||||
APR_UINT64_C(0xbef9a3f7b2c67915), APR_UINT64_C(0xc67178f2e372532b),
|
||||
APR_UINT64_C(0xca273eceea26619c), APR_UINT64_C(0xd186b8c721c0c207),
|
||||
APR_UINT64_C(0xeada7dd6cde0eb1e), APR_UINT64_C(0xf57d4f7fee6ed178),
|
||||
APR_UINT64_C(0x06f067aa72176fba), APR_UINT64_C(0x0a637dc5a2c898a6),
|
||||
APR_UINT64_C(0x113f9804bef90dae), APR_UINT64_C(0x1b710b35131c471b),
|
||||
APR_UINT64_C(0x28db77f523047d84), APR_UINT64_C(0x32caab7b40c72493),
|
||||
APR_UINT64_C(0x3c9ebe0a15c9bebc), APR_UINT64_C(0x431d67c49c100d4c),
|
||||
APR_UINT64_C(0x4cc5d4becb3e42b6), APR_UINT64_C(0x597f299cfc657e2a),
|
||||
APR_UINT64_C(0x5fcb6fab3ad6faec), APR_UINT64_C(0x6c44198c4a475817)
|
||||
};
|
||||
|
||||
/* Initial hash value H for SHA-384 */
|
||||
static const sha2_word64 sha384_initial_hash_value[8] = {
|
||||
APR_UINT64_C(0xcbbb9d5dc1059ed8),
|
||||
APR_UINT64_C(0x629a292a367cd507),
|
||||
APR_UINT64_C(0x9159015a3070dd17),
|
||||
APR_UINT64_C(0x152fecd8f70e5939),
|
||||
APR_UINT64_C(0x67332667ffc00b31),
|
||||
APR_UINT64_C(0x8eb44a8768581511),
|
||||
APR_UINT64_C(0xdb0c2e0d64f98fa7),
|
||||
APR_UINT64_C(0x47b5481dbefa4fa4)
|
||||
};
|
||||
|
||||
/* Initial hash value H for SHA-512 */
|
||||
static const sha2_word64 sha512_initial_hash_value[8] = {
|
||||
APR_UINT64_C(0x6a09e667f3bcc908),
|
||||
APR_UINT64_C(0xbb67ae8584caa73b),
|
||||
APR_UINT64_C(0x3c6ef372fe94f82b),
|
||||
APR_UINT64_C(0xa54ff53a5f1d36f1),
|
||||
APR_UINT64_C(0x510e527fade682d1),
|
||||
APR_UINT64_C(0x9b05688c2b3e6c1f),
|
||||
APR_UINT64_C(0x1f83d9abfb41bd6b),
|
||||
APR_UINT64_C(0x5be0cd19137e2179)
|
||||
};
|
||||
|
||||
/*
|
||||
* Constant used by SHA256/384/512_End() functions for converting the
|
||||
* digest to a readable hexadecimal character string:
|
||||
@ -537,7 +465,14 @@ void apr__SHA256_Final(sha2_byte digest[], SHA256_CTX* context) {
|
||||
*context->buffer = 0x80;
|
||||
}
|
||||
/* Set the bit count: */
|
||||
*(sha2_word64*)&context->buffer[SHA256_SHORT_BLOCK_LENGTH] = context->bitcount;
|
||||
{
|
||||
union dummy {
|
||||
apr_uint64_t bitcount;
|
||||
apr_byte_t bytes[8];
|
||||
} bitcount;
|
||||
bitcount.bitcount = context->bitcount;
|
||||
MEMCPY_BCOPY(&context->buffer[SHA256_SHORT_BLOCK_LENGTH], bitcount.bytes, 8);
|
||||
}
|
||||
|
||||
/* Final transform: */
|
||||
apr__SHA256_Transform(context, (sha2_word32*)context->buffer);
|
||||
@ -591,410 +526,3 @@ char* apr__SHA256_Data(const sha2_byte* data, size_t len, char digest[SHA256_DIG
|
||||
apr__SHA256_Update(&context, data, len);
|
||||
return apr__SHA256_End(&context, digest);
|
||||
}
|
||||
|
||||
|
||||
/*** SHA-512: *********************************************************/
|
||||
void apr__SHA512_Init(SHA512_CTX* context) {
|
||||
if (context == (SHA512_CTX*)0) {
|
||||
return;
|
||||
}
|
||||
MEMCPY_BCOPY(context->state, sha512_initial_hash_value, SHA512_DIGEST_LENGTH);
|
||||
MEMSET_BZERO(context->buffer, SHA512_BLOCK_LENGTH);
|
||||
context->bitcount[0] = context->bitcount[1] = 0;
|
||||
}
|
||||
|
||||
#ifdef SHA2_UNROLL_TRANSFORM
|
||||
|
||||
/* Unrolled SHA-512 round macros: */
|
||||
#if !APR_IS_BIGENDIAN
|
||||
|
||||
#define ROUND512_0_TO_15(a,b,c,d,e,f,g,h) \
|
||||
REVERSE64(*data++, W512[j]); \
|
||||
T1 = (h) + Sigma1_512(e) + Ch((e), (f), (g)) + \
|
||||
K512[j] + W512[j]; \
|
||||
(d) += T1, \
|
||||
(h) = T1 + Sigma0_512(a) + Maj((a), (b), (c)), \
|
||||
j++
|
||||
|
||||
|
||||
#else /* APR_IS_BIGENDIAN */
|
||||
|
||||
#define ROUND512_0_TO_15(a,b,c,d,e,f,g,h) \
|
||||
T1 = (h) + Sigma1_512(e) + Ch((e), (f), (g)) + \
|
||||
K512[j] + (W512[j] = *data++); \
|
||||
(d) += T1; \
|
||||
(h) = T1 + Sigma0_512(a) + Maj((a), (b), (c)); \
|
||||
j++
|
||||
|
||||
#endif /* APR_IS_BIGENDIAN */
|
||||
|
||||
#define ROUND512(a,b,c,d,e,f,g,h) \
|
||||
s0 = W512[(j+1)&0x0f]; \
|
||||
s0 = sigma0_512(s0); \
|
||||
s1 = W512[(j+14)&0x0f]; \
|
||||
s1 = sigma1_512(s1); \
|
||||
T1 = (h) + Sigma1_512(e) + Ch((e), (f), (g)) + K512[j] + \
|
||||
(W512[j&0x0f] += s1 + W512[(j+9)&0x0f] + s0); \
|
||||
(d) += T1; \
|
||||
(h) = T1 + Sigma0_512(a) + Maj((a), (b), (c)); \
|
||||
j++
|
||||
|
||||
void apr__SHA512_Transform(SHA512_CTX* context, const sha2_word64* data) {
|
||||
sha2_word64 a, b, c, d, e, f, g, h, s0, s1;
|
||||
sha2_word64 T1, *W512 = (sha2_word64*)context->buffer;
|
||||
int j;
|
||||
|
||||
/* Initialize registers with the prev. intermediate value */
|
||||
a = context->state[0];
|
||||
b = context->state[1];
|
||||
c = context->state[2];
|
||||
d = context->state[3];
|
||||
e = context->state[4];
|
||||
f = context->state[5];
|
||||
g = context->state[6];
|
||||
h = context->state[7];
|
||||
|
||||
j = 0;
|
||||
do {
|
||||
ROUND512_0_TO_15(a,b,c,d,e,f,g,h);
|
||||
ROUND512_0_TO_15(h,a,b,c,d,e,f,g);
|
||||
ROUND512_0_TO_15(g,h,a,b,c,d,e,f);
|
||||
ROUND512_0_TO_15(f,g,h,a,b,c,d,e);
|
||||
ROUND512_0_TO_15(e,f,g,h,a,b,c,d);
|
||||
ROUND512_0_TO_15(d,e,f,g,h,a,b,c);
|
||||
ROUND512_0_TO_15(c,d,e,f,g,h,a,b);
|
||||
ROUND512_0_TO_15(b,c,d,e,f,g,h,a);
|
||||
} while (j < 16);
|
||||
|
||||
/* Now for the remaining rounds up to 79: */
|
||||
do {
|
||||
ROUND512(a,b,c,d,e,f,g,h);
|
||||
ROUND512(h,a,b,c,d,e,f,g);
|
||||
ROUND512(g,h,a,b,c,d,e,f);
|
||||
ROUND512(f,g,h,a,b,c,d,e);
|
||||
ROUND512(e,f,g,h,a,b,c,d);
|
||||
ROUND512(d,e,f,g,h,a,b,c);
|
||||
ROUND512(c,d,e,f,g,h,a,b);
|
||||
ROUND512(b,c,d,e,f,g,h,a);
|
||||
} while (j < 80);
|
||||
|
||||
/* Compute the current intermediate hash value */
|
||||
context->state[0] += a;
|
||||
context->state[1] += b;
|
||||
context->state[2] += c;
|
||||
context->state[3] += d;
|
||||
context->state[4] += e;
|
||||
context->state[5] += f;
|
||||
context->state[6] += g;
|
||||
context->state[7] += h;
|
||||
|
||||
/* Clean up */
|
||||
a = b = c = d = e = f = g = h = T1 = 0;
|
||||
}
|
||||
|
||||
#else /* SHA2_UNROLL_TRANSFORM */
|
||||
|
||||
void apr__SHA512_Transform(SHA512_CTX* context, const sha2_word64* data) {
|
||||
sha2_word64 a, b, c, d, e, f, g, h, s0, s1;
|
||||
sha2_word64 T1, T2, *W512 = (sha2_word64*)context->buffer;
|
||||
int j;
|
||||
|
||||
/* Initialize registers with the prev. intermediate value */
|
||||
a = context->state[0];
|
||||
b = context->state[1];
|
||||
c = context->state[2];
|
||||
d = context->state[3];
|
||||
e = context->state[4];
|
||||
f = context->state[5];
|
||||
g = context->state[6];
|
||||
h = context->state[7];
|
||||
|
||||
j = 0;
|
||||
do {
|
||||
#if !APR_IS_BIGENDIAN
|
||||
/* Convert TO host byte order */
|
||||
REVERSE64(*data++, W512[j]);
|
||||
/* Apply the SHA-512 compression function to update a..h */
|
||||
T1 = h + Sigma1_512(e) + Ch(e, f, g) + K512[j] + W512[j];
|
||||
#else /* APR_IS_BIGENDIAN */
|
||||
/* Apply the SHA-512 compression function to update a..h with copy */
|
||||
T1 = h + Sigma1_512(e) + Ch(e, f, g) + K512[j] + (W512[j] = *data++);
|
||||
#endif /* APR_IS_BIGENDIAN */
|
||||
T2 = Sigma0_512(a) + Maj(a, b, c);
|
||||
h = g;
|
||||
g = f;
|
||||
f = e;
|
||||
e = d + T1;
|
||||
d = c;
|
||||
c = b;
|
||||
b = a;
|
||||
a = T1 + T2;
|
||||
|
||||
j++;
|
||||
} while (j < 16);
|
||||
|
||||
do {
|
||||
/* Part of the message block expansion: */
|
||||
s0 = W512[(j+1)&0x0f];
|
||||
s0 = sigma0_512(s0);
|
||||
s1 = W512[(j+14)&0x0f];
|
||||
s1 = sigma1_512(s1);
|
||||
|
||||
/* Apply the SHA-512 compression function to update a..h */
|
||||
T1 = h + Sigma1_512(e) + Ch(e, f, g) + K512[j] +
|
||||
(W512[j&0x0f] += s1 + W512[(j+9)&0x0f] + s0);
|
||||
T2 = Sigma0_512(a) + Maj(a, b, c);
|
||||
h = g;
|
||||
g = f;
|
||||
f = e;
|
||||
e = d + T1;
|
||||
d = c;
|
||||
c = b;
|
||||
b = a;
|
||||
a = T1 + T2;
|
||||
|
||||
j++;
|
||||
} while (j < 80);
|
||||
|
||||
/* Compute the current intermediate hash value */
|
||||
context->state[0] += a;
|
||||
context->state[1] += b;
|
||||
context->state[2] += c;
|
||||
context->state[3] += d;
|
||||
context->state[4] += e;
|
||||
context->state[5] += f;
|
||||
context->state[6] += g;
|
||||
context->state[7] += h;
|
||||
|
||||
/* Clean up */
|
||||
a = b = c = d = e = f = g = h = T1 = T2 = 0;
|
||||
}
|
||||
|
||||
#endif /* SHA2_UNROLL_TRANSFORM */
|
||||
|
||||
void apr__SHA512_Update(SHA512_CTX* context, const sha2_byte *data, size_t len) {
|
||||
unsigned int freespace, usedspace;
|
||||
|
||||
if (len == 0) {
|
||||
/* Calling with no data is valid - we do nothing */
|
||||
return;
|
||||
}
|
||||
|
||||
/* Sanity check: */
|
||||
assert(context != (SHA512_CTX*)0 && data != (sha2_byte*)0);
|
||||
|
||||
usedspace = (unsigned int)((context->bitcount[0] >> 3)
|
||||
% SHA512_BLOCK_LENGTH);
|
||||
if (usedspace > 0) {
|
||||
/* Calculate how much free space is available in the buffer */
|
||||
freespace = SHA512_BLOCK_LENGTH - usedspace;
|
||||
|
||||
if (len >= freespace) {
|
||||
/* Fill the buffer completely and process it */
|
||||
MEMCPY_BCOPY(&context->buffer[usedspace], data, freespace);
|
||||
ADDINC128(context->bitcount, freespace << 3);
|
||||
len -= freespace;
|
||||
data += freespace;
|
||||
apr__SHA512_Transform(context, (sha2_word64*)context->buffer);
|
||||
} else {
|
||||
/* The buffer is not yet full */
|
||||
MEMCPY_BCOPY(&context->buffer[usedspace], data, len);
|
||||
ADDINC128(context->bitcount, len << 3);
|
||||
/* Clean up: */
|
||||
usedspace = freespace = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
while (len >= SHA512_BLOCK_LENGTH) {
|
||||
/* Process as many complete blocks as we can */
|
||||
apr__SHA512_Transform(context, (sha2_word64*)data);
|
||||
ADDINC128(context->bitcount, SHA512_BLOCK_LENGTH << 3);
|
||||
len -= SHA512_BLOCK_LENGTH;
|
||||
data += SHA512_BLOCK_LENGTH;
|
||||
}
|
||||
if (len > 0) {
|
||||
/* There's left-overs, so save 'em */
|
||||
MEMCPY_BCOPY(context->buffer, data, len);
|
||||
ADDINC128(context->bitcount, len << 3);
|
||||
}
|
||||
/* Clean up: */
|
||||
usedspace = freespace = 0;
|
||||
}
|
||||
|
||||
void apr__SHA512_Last(SHA512_CTX* context) {
|
||||
unsigned int usedspace;
|
||||
|
||||
usedspace = (unsigned int)((context->bitcount[0] >> 3)
|
||||
% SHA512_BLOCK_LENGTH);
|
||||
#if !APR_IS_BIGENDIAN
|
||||
/* Convert FROM host byte order */
|
||||
REVERSE64(context->bitcount[0],context->bitcount[0]);
|
||||
REVERSE64(context->bitcount[1],context->bitcount[1]);
|
||||
#endif
|
||||
if (usedspace > 0) {
|
||||
/* Begin padding with a 1 bit: */
|
||||
context->buffer[usedspace++] = 0x80;
|
||||
|
||||
if (usedspace <= SHA512_SHORT_BLOCK_LENGTH) {
|
||||
/* Set-up for the last transform: */
|
||||
MEMSET_BZERO(&context->buffer[usedspace], SHA512_SHORT_BLOCK_LENGTH - usedspace);
|
||||
} else {
|
||||
if (usedspace < SHA512_BLOCK_LENGTH) {
|
||||
MEMSET_BZERO(&context->buffer[usedspace], SHA512_BLOCK_LENGTH - usedspace);
|
||||
}
|
||||
/* Do second-to-last transform: */
|
||||
apr__SHA512_Transform(context, (sha2_word64*)context->buffer);
|
||||
|
||||
/* And set-up for the last transform: */
|
||||
MEMSET_BZERO(context->buffer, SHA512_BLOCK_LENGTH - 2);
|
||||
}
|
||||
} else {
|
||||
/* Prepare for final transform: */
|
||||
MEMSET_BZERO(context->buffer, SHA512_SHORT_BLOCK_LENGTH);
|
||||
|
||||
/* Begin padding with a 1 bit: */
|
||||
*context->buffer = 0x80;
|
||||
}
|
||||
/* Store the length of input data (in bits): */
|
||||
*(sha2_word64*)&context->buffer[SHA512_SHORT_BLOCK_LENGTH] = context->bitcount[1];
|
||||
*(sha2_word64*)&context->buffer[SHA512_SHORT_BLOCK_LENGTH+8] = context->bitcount[0];
|
||||
|
||||
/* Final transform: */
|
||||
apr__SHA512_Transform(context, (sha2_word64*)context->buffer);
|
||||
}
|
||||
|
||||
void apr__SHA512_Final(sha2_byte digest[], SHA512_CTX* context) {
|
||||
sha2_word64 *d = (sha2_word64*)digest;
|
||||
|
||||
/* Sanity check: */
|
||||
assert(context != (SHA512_CTX*)0);
|
||||
|
||||
/* If no digest buffer is passed, we don't bother doing this: */
|
||||
if (digest != (sha2_byte*)0) {
|
||||
apr__SHA512_Last(context);
|
||||
|
||||
/* Save the hash data for output: */
|
||||
#if !APR_IS_BIGENDIAN
|
||||
{
|
||||
/* Convert TO host byte order */
|
||||
int j;
|
||||
for (j = 0; j < 8; j++) {
|
||||
REVERSE64(context->state[j],context->state[j]);
|
||||
*d++ = context->state[j];
|
||||
}
|
||||
}
|
||||
#else /* APR_IS_BIGENDIAN */
|
||||
MEMCPY_BCOPY(d, context->state, SHA512_DIGEST_LENGTH);
|
||||
#endif /* APR_IS_BIGENDIAN */
|
||||
}
|
||||
|
||||
/* Zero out state data */
|
||||
MEMSET_BZERO(context, sizeof(*context));
|
||||
}
|
||||
|
||||
char *apr__SHA512_End(SHA512_CTX* context, char buffer[]) {
|
||||
sha2_byte digest[SHA512_DIGEST_LENGTH], *d = digest;
|
||||
int i;
|
||||
|
||||
/* Sanity check: */
|
||||
assert(context != (SHA512_CTX*)0);
|
||||
|
||||
if (buffer != (char*)0) {
|
||||
apr__SHA512_Final(digest, context);
|
||||
|
||||
for (i = 0; i < SHA512_DIGEST_LENGTH; i++) {
|
||||
*buffer++ = sha2_hex_digits[(*d & 0xf0) >> 4];
|
||||
*buffer++ = sha2_hex_digits[*d & 0x0f];
|
||||
d++;
|
||||
}
|
||||
*buffer = (char)0;
|
||||
} else {
|
||||
MEMSET_BZERO(context, sizeof(*context));
|
||||
}
|
||||
MEMSET_BZERO(digest, SHA512_DIGEST_LENGTH);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
char* apr__SHA512_Data(const sha2_byte* data, size_t len, char digest[SHA512_DIGEST_STRING_LENGTH]) {
|
||||
SHA512_CTX context;
|
||||
|
||||
apr__SHA512_Init(&context);
|
||||
apr__SHA512_Update(&context, data, len);
|
||||
return apr__SHA512_End(&context, digest);
|
||||
}
|
||||
|
||||
|
||||
/*** SHA-384: *********************************************************/
|
||||
void apr__SHA384_Init(SHA384_CTX* context) {
|
||||
if (context == (SHA384_CTX*)0) {
|
||||
return;
|
||||
}
|
||||
MEMCPY_BCOPY(context->state, sha384_initial_hash_value, SHA512_DIGEST_LENGTH);
|
||||
MEMSET_BZERO(context->buffer, SHA384_BLOCK_LENGTH);
|
||||
context->bitcount[0] = context->bitcount[1] = 0;
|
||||
}
|
||||
|
||||
void apr__SHA384_Update(SHA384_CTX* context, const sha2_byte* data, size_t len) {
|
||||
apr__SHA512_Update((SHA512_CTX*)context, data, len);
|
||||
}
|
||||
|
||||
void apr__SHA384_Final(sha2_byte digest[], SHA384_CTX* context) {
|
||||
sha2_word64 *d = (sha2_word64*)digest;
|
||||
|
||||
/* Sanity check: */
|
||||
assert(context != (SHA384_CTX*)0);
|
||||
|
||||
/* If no digest buffer is passed, we don't bother doing this: */
|
||||
if (digest != (sha2_byte*)0) {
|
||||
apr__SHA512_Last((SHA512_CTX*)context);
|
||||
|
||||
/* Save the hash data for output: */
|
||||
#if !APR_IS_BIGENDIAN
|
||||
{
|
||||
/* Convert TO host byte order */
|
||||
int j;
|
||||
for (j = 0; j < 6; j++) {
|
||||
REVERSE64(context->state[j],context->state[j]);
|
||||
*d++ = context->state[j];
|
||||
}
|
||||
}
|
||||
#else /* APR_IS_BIGENDIAN */
|
||||
MEMCPY_BCOPY(d, context->state, SHA384_DIGEST_LENGTH);
|
||||
#endif /* APR_IS_BIGENDIAN */
|
||||
}
|
||||
|
||||
/* Zero out state data */
|
||||
MEMSET_BZERO(context, sizeof(*context));
|
||||
}
|
||||
|
||||
char *apr__SHA384_End(SHA384_CTX* context, char buffer[]) {
|
||||
sha2_byte digest[SHA384_DIGEST_LENGTH], *d = digest;
|
||||
int i;
|
||||
|
||||
/* Sanity check: */
|
||||
assert(context != (SHA384_CTX*)0);
|
||||
|
||||
if (buffer != (char*)0) {
|
||||
apr__SHA384_Final(digest, context);
|
||||
|
||||
for (i = 0; i < SHA384_DIGEST_LENGTH; i++) {
|
||||
*buffer++ = sha2_hex_digits[(*d & 0xf0) >> 4];
|
||||
*buffer++ = sha2_hex_digits[*d & 0x0f];
|
||||
d++;
|
||||
}
|
||||
*buffer = (char)0;
|
||||
} else {
|
||||
MEMSET_BZERO(context, sizeof(*context));
|
||||
}
|
||||
MEMSET_BZERO(digest, SHA384_DIGEST_LENGTH);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
char* apr__SHA384_Data(const sha2_byte* data, size_t len, char digest[SHA384_DIGEST_STRING_LENGTH]) {
|
||||
SHA384_CTX context;
|
||||
|
||||
apr__SHA384_Init(&context);
|
||||
apr__SHA384_Update(&context, data, len);
|
||||
return apr__SHA384_End(&context, digest);
|
||||
}
|
||||
|
||||
|
@ -29,16 +29,10 @@ extern "C" {
|
||||
|
||||
#include "apr.h"
|
||||
|
||||
/*** SHA-256/384/512 Various Length Definitions ***********************/
|
||||
/*** SHA-256 Various Length Definitions ***********************/
|
||||
#define SHA256_BLOCK_LENGTH 64
|
||||
#define SHA256_DIGEST_LENGTH 32
|
||||
#define SHA256_DIGEST_STRING_LENGTH (SHA256_DIGEST_LENGTH * 2 + 1)
|
||||
#define SHA384_BLOCK_LENGTH 128
|
||||
#define SHA384_DIGEST_LENGTH 48
|
||||
#define SHA384_DIGEST_STRING_LENGTH (SHA384_DIGEST_LENGTH * 2 + 1)
|
||||
#define SHA512_BLOCK_LENGTH 128
|
||||
#define SHA512_DIGEST_LENGTH 64
|
||||
#define SHA512_DIGEST_STRING_LENGTH (SHA512_DIGEST_LENGTH * 2 + 1)
|
||||
|
||||
|
||||
/*** SHA-256/384/512 Context Structures *******************************/
|
||||
@ -47,13 +41,6 @@ typedef struct _SHA256_CTX {
|
||||
apr_uint64_t bitcount;
|
||||
apr_byte_t buffer[SHA256_BLOCK_LENGTH];
|
||||
} SHA256_CTX;
|
||||
typedef struct _SHA512_CTX {
|
||||
apr_uint64_t state[8];
|
||||
apr_uint64_t bitcount[2];
|
||||
apr_byte_t buffer[SHA512_BLOCK_LENGTH];
|
||||
} SHA512_CTX;
|
||||
|
||||
typedef SHA512_CTX SHA384_CTX;
|
||||
|
||||
|
||||
/*** SHA-256/384/512 Function Prototypes ******************************/
|
||||
@ -63,21 +50,7 @@ void apr__SHA256_Final(apr_byte_t [SHA256_DIGEST_LENGTH], SHA256_CTX *);
|
||||
char* apr__SHA256_End(SHA256_CTX *, char [SHA256_DIGEST_STRING_LENGTH]);
|
||||
char* apr__SHA256_Data(const apr_byte_t *, size_t,
|
||||
char [SHA256_DIGEST_STRING_LENGTH]);
|
||||
|
||||
void apr__SHA384_Init(SHA384_CTX *);
|
||||
void apr__SHA384_Update(SHA384_CTX *, const apr_byte_t *, size_t);
|
||||
void apr__SHA384_Final(apr_byte_t [SHA384_DIGEST_LENGTH], SHA384_CTX *);
|
||||
char* apr__SHA384_End(SHA384_CTX *, char [SHA384_DIGEST_STRING_LENGTH]);
|
||||
char* apr__SHA384_Data(const apr_byte_t *, size_t,
|
||||
char [SHA384_DIGEST_STRING_LENGTH]);
|
||||
|
||||
void apr__SHA512_Init(SHA512_CTX *);
|
||||
void apr__SHA512_Update(SHA512_CTX *, const apr_byte_t *, size_t);
|
||||
void apr__SHA512_Final(apr_byte_t [SHA512_DIGEST_LENGTH], SHA512_CTX *);
|
||||
char* apr__SHA512_End(SHA512_CTX *, char [SHA512_DIGEST_STRING_LENGTH]);
|
||||
char* apr__SHA512_Data(const apr_byte_t *, size_t,
|
||||
char [SHA512_DIGEST_STRING_LENGTH]);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
@ -1,26 +1,42 @@
|
||||
/* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <apr.h>
|
||||
#include <apr_random.h>
|
||||
#include <apr_pools.h>
|
||||
#include "sha2.h"
|
||||
|
||||
static void sha256_init(apr_crypto_hash_t *h)
|
||||
{
|
||||
{
|
||||
apr__SHA256_Init(h->data);
|
||||
}
|
||||
}
|
||||
|
||||
static void sha256_add(apr_crypto_hash_t *h,const void *data,
|
||||
apr_size_t bytes)
|
||||
{
|
||||
apr_size_t bytes)
|
||||
{
|
||||
apr__SHA256_Update(h->data,data,bytes);
|
||||
}
|
||||
}
|
||||
|
||||
static void sha256_finish(apr_crypto_hash_t *h,unsigned char *result)
|
||||
{
|
||||
{
|
||||
apr__SHA256_Final(result,h->data);
|
||||
}
|
||||
}
|
||||
|
||||
APR_DECLARE(apr_crypto_hash_t *) apr_crypto_sha256_new(apr_pool_t *p)
|
||||
{
|
||||
{
|
||||
apr_crypto_hash_t *h=apr_palloc(p,sizeof *h);
|
||||
|
||||
h->data=apr_palloc(p,sizeof(SHA256_CTX));
|
||||
@ -30,4 +46,4 @@ APR_DECLARE(apr_crypto_hash_t *) apr_crypto_sha256_new(apr_pool_t *p)
|
||||
h->size=256/8;
|
||||
|
||||
return h;
|
||||
}
|
||||
}
|
||||
|
@ -734,11 +734,14 @@ APR_DECLARE(void) apr_table_mergen(apr_table_t *t, const char *key,
|
||||
|
||||
#if APR_POOL_DEBUG
|
||||
{
|
||||
if (!apr_pool_is_ancestor(apr_pool_find(key), t->a.pool)) {
|
||||
apr_pool_t *pool;
|
||||
pool = apr_pool_find(key);
|
||||
if ((pool != key) && (!apr_pool_is_ancestor(pool, t->a.pool))) {
|
||||
fprintf(stderr, "apr_table_mergen: key not in ancestor pool of t\n");
|
||||
abort();
|
||||
}
|
||||
if (!apr_pool_is_ancestor(apr_pool_find(val), t->a.pool)) {
|
||||
pool = apr_pool_find(val);
|
||||
if ((pool != val) && (!apr_pool_is_ancestor(pool, t->a.pool))) {
|
||||
fprintf(stderr, "apr_table_mergen: val not in ancestor pool of t\n");
|
||||
abort();
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ APR_DECLARE(apr_status_t) apr_threadattr_detach_get(apr_threadattr_t *attr)
|
||||
#else
|
||||
pthread_attr_getdetachstate(&attr->attr, &state);
|
||||
#endif
|
||||
if (state == 1)
|
||||
if (state == DETACH_ARG(1))
|
||||
return APR_DETACH;
|
||||
return APR_NOTDETACH;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user