diff --git a/Bounds-check-human-readable-date-fields-credit-Stefa.patch b/Bounds-check-human-readable-date-fields-credit-Stefa.patch new file mode 100644 index 0000000000000000000000000000000000000000..f703ffdde3d3c25302fcc07d31c22060411bc462 --- /dev/null +++ b/Bounds-check-human-readable-date-fields-credit-Stefa.patch @@ -0,0 +1,53 @@ +From ad958385a4180d7a83d90589689fcd36e3bbc57a Mon Sep 17 00:00:00 2001 +From: Nick Kew +Date: Sun, 10 Sep 2017 22:30:14 +0000 +Subject: [PATCH] Bounds-check human-readable date fields (credit: Stefan + Sperling) + +git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1807975 13f79535-47bb-0310-9956-ffa450edef68 +--- + time/unix/time.c | 3 +++ + time/win32/time.c | 6 ++++++ + 2 files changed, 9 insertions(+) + +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) +-- +1.8.3.1 + diff --git a/Follow-up-to-r1675967-trunk-resp.-r1863202-1.7.x.patch b/Follow-up-to-r1675967-trunk-resp.-r1863202-1.7.x.patch new file mode 100644 index 0000000000000000000000000000000000000000..4d70108e575316a24dd3366f001590e5d58f605e --- /dev/null +++ b/Follow-up-to-r1675967-trunk-resp.-r1863202-1.7.x.patch @@ -0,0 +1,49 @@ +From 9032d8c633dbc0f6fe2cd3358f767f088ffbf1ef Mon Sep 17 00:00:00 2001 +From: Rainer Jung +Date: Wed, 17 Jul 2019 11:31:02 +0000 +Subject: [PATCH] Follow up to r1675967 (trunk) resp. r1863202 (1.7.x): When + pool debugging is enabled, make sure we don't try to emit any debug events + after the debug log file handle has been closed. + +Backport of r1675970 from trunk. + + +git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.7.x@1863203 13f79535-47bb-0310-9956-ffa450edef68 +--- + memory/unix/apr_pools.c | 13 +++++++++++++ + 1 file changed, 13 insertions(+) + +diff --git a/memory/unix/apr_pools.c b/memory/unix/apr_pools.c +index 9fdd001..eb173c8 100644 +--- a/memory/unix/apr_pools.c ++++ b/memory/unix/apr_pools.c +@@ -636,6 +636,12 @@ static apr_allocator_t *global_allocator = NULL; + + #if (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE_ALL) + static apr_file_t *file_stderr = NULL; ++static apr_status_t apr_pool_cleanup_file_stderr(void *data) ++{ ++ file_stderr = NULL; ++ return APR_SUCCESS; ++} ++ + #endif /* (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE_ALL) */ + + /* +@@ -1706,6 +1712,13 @@ APR_DECLARE(apr_status_t) apr_pool_initialize(void) + file_stderr = debug_log; + + if (file_stderr) { ++ /* Add a cleanup handler that sets the debug log file handle ++ * to NULL, otherwise we'll try to log the global pool ++ * destruction event with predictably disastrous results. */ ++ apr_pool_cleanup_register(global_pool, NULL, ++ apr_pool_cleanup_file_stderr, ++ apr_pool_cleanup_null); ++ + apr_file_printf(file_stderr, + "POOL DEBUG: [PID" + #if APR_HAS_THREADS +-- +1.8.3.1 + diff --git a/Register-the-pool-debug-log-cleanup-handler-after-em.patch b/Register-the-pool-debug-log-cleanup-handler-after-em.patch new file mode 100644 index 0000000000000000000000000000000000000000..4f5cfd972010fa47c0143a10c3c16bf4dd9956b7 --- /dev/null +++ b/Register-the-pool-debug-log-cleanup-handler-after-em.patch @@ -0,0 +1,50 @@ +From dfce87282409fcb9ca012bcc2db0061183bf91c8 Mon Sep 17 00:00:00 2001 +From: Rainer Jung +Date: Wed, 17 Jul 2019 11:32:12 +0000 +Subject: [PATCH] Register the pool debug log cleanup handler after emitting + the global pool creation event. This ensures that the allocation event from + the cleanup registration written after the creation event. + +Backport of r1675982 from trunk. + + +git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.7.x@1863204 13f79535-47bb-0310-9956-ffa450edef68 +--- + memory/unix/apr_pools.c | 14 +++++++------- + 1 file changed, 7 insertions(+), 7 deletions(-) + +diff --git a/memory/unix/apr_pools.c b/memory/unix/apr_pools.c +index eb173c8..a59d9da 100644 +--- a/memory/unix/apr_pools.c ++++ b/memory/unix/apr_pools.c +@@ -1712,13 +1712,6 @@ APR_DECLARE(apr_status_t) apr_pool_initialize(void) + file_stderr = debug_log; + + if (file_stderr) { +- /* Add a cleanup handler that sets the debug log file handle +- * to NULL, otherwise we'll try to log the global pool +- * destruction event with predictably disastrous results. */ +- apr_pool_cleanup_register(global_pool, NULL, +- apr_pool_cleanup_file_stderr, +- apr_pool_cleanup_null); +- + apr_file_printf(file_stderr, + "POOL DEBUG: [PID" + #if APR_HAS_THREADS +@@ -1728,6 +1721,13 @@ APR_DECLARE(apr_status_t) apr_pool_initialize(void) + "POOL \"TAG\" <__FILE__:__LINE__> (ALLOCS/TOTAL ALLOCS/CLEARS)\n"); + + apr_pool_log_event(global_pool, "GLOBAL", __FILE__ ":apr_pool_initialize", 0); ++ ++ /* Add a cleanup handler that sets the debug log file handle ++ * to NULL, otherwise we'll try to log the global pool ++ * destruction event with predictably disastrous results. */ ++ apr_pool_cleanup_register(global_pool, NULL, ++ apr_pool_cleanup_file_stderr, ++ apr_pool_cleanup_null); + } + #endif /* (APR_POOL_DEBUG & APR_POOL_DEBUG_VERBOSE_ALL) */ + +-- +1.8.3.1 + diff --git a/apr.spec b/apr.spec index 3409a1d4af4af5f27f45c15e4ba60b1c68e0ad2e..ecfa4360a398bf1a051a1b61cb8ac99b4ee7692b 100644 --- a/apr.spec +++ b/apr.spec @@ -2,7 +2,7 @@ Name: apr Version: 1.7.0 -Release: 1 +Release: 2 Summary: Apache Portable Runtime. License: ASL 2.0 and BSD with advertising and ISC and BSD URL: http://apr.apache.org @@ -11,10 +11,12 @@ Source1: apr-wrapper.h Patch0: apr-1.2.2-libdir.patch Patch1: apr-1.2.7-pkgconf.patch - -Patch6000: Split-apr_pool_check_integrity-into-two-parts.patch -Patch6001: Pool-debugging-fixes.patch -Patch6002: Fix-pool-debugging-output-so-that-creation-events-ar.patch +Patch2: Split-apr_pool_check_integrity-into-two-parts.patch +Patch3: Pool-debugging-fixes.patch +Patch4: Fix-pool-debugging-output-so-that-creation-events-ar.patch +Patch5: memory-unix-apr_pools.c-apr_pool_cleanup_register.patch +Patch6: Follow-up-to-r1675967-trunk-resp.-r1863202-1.7.x.patch +Patch7: Register-the-pool-debug-log-cleanup-handler-after-em.patch BuildRequires: gcc autoconf libtool libuuid-devel python3 lksctp-tools-devel @@ -98,6 +100,9 @@ make check %doc docs/incomplete_types docs/non_apr_programs %changelog +* Mon Jun 29 2020 linwei - 1.7.0-2 +- sync some patches from community + * Mon May 11 2020 openEuler Buildteam - 1.7.0-1 - update to 1.7.0-1 diff --git a/memory-unix-apr_pools.c-apr_pool_cleanup_register.patch b/memory-unix-apr_pools.c-apr_pool_cleanup_register.patch new file mode 100644 index 0000000000000000000000000000000000000000..ac45401f89f68d064cf372a72b53c0788ff9e102 --- /dev/null +++ b/memory-unix-apr_pools.c-apr_pool_cleanup_register.patch @@ -0,0 +1,33 @@ +From 54bc039ca9781c75b51ad39a01ae79d30efd6f09 Mon Sep 17 00:00:00 2001 +From: Rainer Jung +Date: Wed, 17 Jul 2019 11:15:08 +0000 +Subject: [PATCH] * memory/unix/apr_pools.c (apr_pool_cleanup_register): + [APR_POOL_DEBUG]: Catch NULL arguments which would lead to strange + segfaults later. + +Backport of r1082177 from trunk. + + +git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.7.x@1863198 13f79535-47bb-0310-9956-ffa450edef68 +--- + memory/unix/apr_pools.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/memory/unix/apr_pools.c b/memory/unix/apr_pools.c +index 524e9ac..3361f7a 100644 +--- a/memory/unix/apr_pools.c ++++ b/memory/unix/apr_pools.c +@@ -2484,6 +2484,10 @@ APR_DECLARE(void) apr_pool_cleanup_register(apr_pool_t *p, const void *data, + + #if APR_POOL_DEBUG + apr_pool_check_integrity(p); ++ ++ if (!p || !plain_cleanup_fn || !child_cleanup_fn) { ++ abort(); ++ } + #endif /* APR_POOL_DEBUG */ + + if (p != NULL) { +-- +1.8.3.1 +