From f0cc37ad3e1d2cf37e8264b81a68a2296dba09de Mon Sep 17 00:00:00 2001 From: jorton Date: Sep 09 2005 14:20:40 +0000 Subject: - add from 0.9.x branch: fix for apr_{uid,gid}_* error handling (r239592) fix for apr_file_ write flushing (r267192) - add backport for use of readdir64_r (r265032, r265681, r265684) --- diff --git a/apr-0.9.6-readdir64.patch b/apr-0.9.6-readdir64.patch new file mode 100644 index 0000000..b782988 --- /dev/null +++ b/apr-0.9.6-readdir64.patch @@ -0,0 +1,140 @@ +--- apr-0.9.6/file_io/unix/dir.c.readdir64 ++++ apr-0.9.6/file_io/unix/dir.c +@@ -77,24 +77,24 @@ + * one-byte array. Note: gcc evaluates this at compile time. + */ + apr_size_t dirent_size = +- (sizeof((*new)->entry->d_name) > 1 ? +- sizeof(struct dirent) : sizeof (struct dirent) + 255); ++ sizeof(*(*new)->entry) + ++ (sizeof((*new)->entry->d_name) > 1 ? 0 : 255); ++ DIR *dir = opendir(dirname); ++ ++ if (!dir) { ++ return errno; ++ } + + (*new) = (apr_dir_t *)apr_palloc(pool, sizeof(apr_dir_t)); + + (*new)->pool = pool; + (*new)->dirname = apr_pstrdup(pool, dirname); +- (*new)->dirstruct = opendir(dirname); ++ (*new)->dirstruct = dir; + (*new)->entry = apr_pcalloc(pool, dirent_size); + +- if ((*new)->dirstruct == NULL) { +- return errno; +- } +- else { +- apr_pool_cleanup_register((*new)->pool, (void *)(*new), dir_cleanup, +- apr_pool_cleanup_null); +- return APR_SUCCESS; +- } ++ apr_pool_cleanup_register((*new)->pool, *new, dir_cleanup, ++ apr_pool_cleanup_null); ++ return APR_SUCCESS; + } + + apr_status_t apr_dir_close(apr_dir_t *thedir) +@@ -139,9 +139,28 @@ + #endif + #if APR_HAS_THREADS && defined(_POSIX_THREAD_SAFE_FUNCTIONS) \ + && !defined(READDIR_IS_THREAD_SAFE) ++#ifdef HAVE_READDIR64_R ++ struct dirent64 *retent; ++ ++ /* If LFS is enabled and readdir64_r is available, readdir64_r is ++ * used in preference to readdir_r. This allows directories to be ++ * read which contain a (64-bit) inode number which doesn't fit ++ * into the 32-bit apr_ino_t, iff the caller doesn't actually care ++ * about the inode number (i.e. wanted & APR_FINFO_INODE == 0). ++ * (such inodes may be seen in some wonky NFS environments) ++ * ++ * Similarly, if the d_off field cannot be reprented in a 32-bit ++ * offset, the libc readdir_r() would barf; using readdir64_r ++ * bypasses that case entirely since APR does not care about ++ * d_off. */ ++ ++ ret = readdir64_r(thedir->dirstruct, thedir->entry, &retent); ++#else ++ + struct dirent *retent; + + ret = readdir_r(thedir->dirstruct, thedir->entry, &retent); ++#endif + + /* Avoid the Linux problem where at end-of-directory thedir->entry + * is set to NULL, but ret = APR_SUCCESS. +@@ -191,9 +210,22 @@ + #endif + #ifdef DIRENT_INODE + if (thedir->entry->DIRENT_INODE && thedir->entry->DIRENT_INODE != -1) { ++#ifdef HAVE_READDIR64_R ++ /* If readdir64_r is used, check for the overflow case of trying ++ * to fit a 64-bit integer into a 32-bit integer. */ ++ if (sizeof(apr_ino_t) >= sizeof(retent->DIRENT_INODE) ++ || (apr_ino_t)retent->DIRENT_INODE == retent->DIRENT_INODE) { ++ wanted &= ~APR_FINFO_INODE; ++ } else { ++ /* Prevent the fallback code below from filling in the ++ * inode if the stat call fails. */ ++ retent->DIRENT_INODE = 0; ++ } ++#else + wanted &= ~APR_FINFO_INODE; ++#endif /* HAVE_READDIR64_R */ + } +-#endif ++#endif /* DIRENT_INODE */ + + wanted &= ~APR_FINFO_NAME; + +--- apr-0.9.6/file_io/unix/filestat.c.readdir64 ++++ apr-0.9.6/file_io/unix/filestat.c +@@ -77,9 +77,18 @@ + finfo->user = info->st_uid; + finfo->group = info->st_gid; + finfo->size = info->st_size; +- finfo->inode = info->st_ino; + finfo->device = info->st_dev; + finfo->nlink = info->st_nlink; ++ ++ /* Check for overflow if storing a 64-bit st_ino in a 32-bit ++ * apr_ino_t for LFS builds: */ ++ if (sizeof(apr_ino_t) >= sizeof(info->st_ino) ++ || (apr_ino_t)info->st_ino == info->st_ino) { ++ finfo->inode = info->st_ino; ++ } else { ++ finfo->valid &= ~APR_FINFO_INODE; ++ } ++ + apr_time_ansi_put(&finfo->atime, info->st_atime); + apr_time_ansi_put(&finfo->mtime, info->st_mtime); + apr_time_ansi_put(&finfo->ctime, info->st_ctime); +--- apr-0.9.6/include/arch/unix/apr_arch_file_io.h.readdir64 ++++ apr-0.9.6/include/arch/unix/apr_arch_file_io.h +@@ -108,7 +108,11 @@ + apr_pool_t *pool; + char *dirname; + DIR *dirstruct; ++#ifdef HAVE_READDIR64_R ++ struct dirent64 *entry; ++#else + struct dirent *entry; ++#endif + }; + + apr_status_t apr_unix_file_cleanup(void *); +--- apr-0.9.6/configure.in.readdir64 ++++ apr-0.9.6/configure.in +@@ -1310,6 +1310,10 @@ + AC_CHECK_FUNCS(memchr, have_memchr="1", have_memchr="0") + AC_CHECK_FUNCS($int64_strfn, have_int64_strfn="1", have_int64_strfn="0") + ++if test "$ac_cv_sizeof_long" = "4"; then ++ AC_CHECK_FUNCS([readdir64_r]) ++fi ++ + dnl ----------------------------- We have a fallback position + if test "$have_int64_strfn" = "0" && test "$int64_strfn" = "strtoll"; then + int64_strfn="strtoq" diff --git a/apr.spec b/apr.spec index 56665bd..570453f 100644 --- a/apr.spec +++ b/apr.spec @@ -3,7 +3,7 @@ Summary: Apache Portable Runtime library Name: apr Version: 0.9.6 -Release: 4 +Release: 5 License: Apache Software License Group: System Environment/Libraries URL: http://apr.apache.org/ @@ -15,6 +15,9 @@ Patch10: apr-0.9.4-cflags.patch Patch18: apr-0.9.4-stacksize.patch Patch21: apr-0.9.4-lp64psem.patch Patch22: apr-0.9.4-attrerror.patch +Patch23: apr-0.9.6-readdir64.patch +Patch24: apr-0.9.6-uidgid.patch +Patch25: apr-0.9.6-flushbufs.patch BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot BuildPrereq: autoconf, libtool, doxygen Conflicts: subversion < 0.20.1-2 @@ -47,6 +50,9 @@ C data structures and routines. %patch18 -p1 -b .stacksize %patch21 -p1 -b .lp64psem %patch22 -p1 -b .attrerror +%patch23 -p1 -b .readdir64 +%patch24 -p1 -b .uidgid +%patch25 -p1 -b .flushbufs %build # regenerate configure script etc. @@ -119,6 +125,12 @@ rm -rf $RPM_BUILD_ROOT %{_includedir}/apr-%{aprver}/*.h %changelog +* Fri Sep 9 2005 Joe Orton 0.9.6-5 +- add from 0.9.x branch: + * fix for apr_{uid,gid}_* error handling (r239592) + * fix for apr_file_ write flushing (r267192) +- add backport for use of readdir64_r (r265032, r265681, r265684) + * Mon Jul 11 2005 Florian La Roche - rebuild