Update to 3.0.9

This commit is contained in:
Milan Crha 2021-01-18 12:26:32 +01:00
parent a2c5c2b378
commit 8ebcb15edf
4 changed files with 10 additions and 132 deletions

View File

@ -1,110 +0,0 @@
From e5f3df8ab02574d7edcce9ceef4622569edb6f92 Mon Sep 17 00:00:00 2001
From: Milan Crha <mcrha@redhat.com>
Date: Thu, 3 Jan 2019 12:53:04 +0100
Subject: [PATCH] Improve thread safety of icaltimezone_load_builtin_timezone()
Even the function does test whether the passed-in zone has set
the component, it doesn't retest it when it acquires the lock, but
other thread could already assign the component, which can cause
use-after-free in certain thread interleaving.
---
src/libical/icaltimezone.c | 6 ++++
src/test/builtin_timezones.c | 54 ++++++++++++++++++++++++++++++++++++
2 files changed, 60 insertions(+)
diff --git a/src/libical/icaltimezone.c b/src/libical/icaltimezone.c
index 12f6c291..3c4bf14d 100644
--- a/src/libical/icaltimezone.c
+++ b/src/libical/icaltimezone.c
@@ -1806,6 +1806,12 @@ static void icaltimezone_load_builtin_timezone(icaltimezone *zone)
icaltimezone_builtin_lock();
+ /* Try again, maybe it had been set by other thread while waiting for the lock */
+ if (zone->component) {
+ icaltimezone_builtin_unlock();
+ return;
+ }
+
/* If the location isn't set, it isn't a builtin timezone. */
if (!zone->location || !zone->location[0]) {
icaltimezone_builtin_unlock();
diff --git a/src/test/builtin_timezones.c b/src/test/builtin_timezones.c
index c2d36845..b0e472cb 100644
--- a/src/test/builtin_timezones.c
+++ b/src/test/builtin_timezones.c
@@ -20,10 +20,60 @@
#include <config.h>
#endif
+#ifdef HAVE_PTHREAD_H
+#include <pthread.h>
+#include <assert.h>
+#endif
+
#include "libical/ical.h"
#include <stdio.h>
+#if defined(HAVE_PTHREAD_H) && defined(HAVE_PTHREAD) && defined(HAVE_PTHREAD_CREATE)
+
+#define N_THREADS 20
+
+static const void *thread_comp = NULL;
+
+static void *
+thread_func(void *user_data)
+{
+ icaltimezone *zone = user_data;
+ icalcomponent *icalcomp;
+
+ if(!zone)
+ return NULL;
+
+ icalcomp = icaltimezone_get_component(zone);
+ if(!thread_comp)
+ thread_comp = icalcomp;
+ else
+ assert(thread_comp == icalcomp);
+ icalcomp = icalcomponent_new_clone(icalcomp);
+ icalcomponent_free(icalcomp);
+
+ return NULL;
+}
+
+static void
+test_get_component_threadsafety(void)
+{
+ pthread_t thread[N_THREADS];
+ icaltimezone *zone;
+ int ii;
+
+ zone = icaltimezone_get_builtin_timezone("Europe/London");
+
+ for(ii = 0; ii < N_THREADS; ii++) {
+ pthread_create(&thread[ii], NULL, thread_func, zone);
+ }
+
+ for(ii = 0; ii < N_THREADS; ii++) {
+ pthread_join(thread[ii], NULL);
+ }
+}
+#endif
+
int main()
{
icalarray *builtin_timezones;
@@ -34,6 +84,10 @@ int main()
set_zone_directory("../../zoneinfo");
icaltimezone_set_tzid_prefix("/softwarestudio.org/");
+ #if defined(HAVE_PTHREAD_H) && defined(HAVE_PTHREAD) && defined(HAVE_PTHREAD_CREATE)
+ test_get_component_threadsafety();
+ #endif
+
tt = icaltime_current_time_with_zone(icaltimezone_get_builtin_timezone("America/New_York"));
tt.year = 2038;
--
2.17.0

View File

@ -1,12 +0,0 @@
diff -up libical-3.0.8/src/test/libical-glib/CMakeLists.txt.test-patch libical-3.0.8/src/test/libical-glib/CMakeLists.txt
--- libical-3.0.8/src/test/libical-glib/CMakeLists.txt.test-patch 2020-03-07 15:42:42.000000000 +0100
+++ libical-3.0.8/src/test/libical-glib/CMakeLists.txt 2020-08-04 17:18:13.961171044 +0200
@@ -31,7 +31,7 @@ if(PYTHON3)
add_test(
NAME ${test_name}
- COMMAND ${PYTHON3} ${CMAKE_CURRENT_SOURCE_DIR}/${test_file}
+ COMMAND ${PYTHON3} -I ${CMAKE_CURRENT_SOURCE_DIR}/${test_file}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)

View File

@ -2,15 +2,12 @@
Summary: Reference implementation of the iCalendar data type and serialization format Summary: Reference implementation of the iCalendar data type and serialization format
Name: libical Name: libical
Version: 3.0.8 Version: 3.0.9
Release: 5%{?dist} Release: 1%{?dist}
License: LGPLv2 or MPLv2.0 License: LGPLv2 or MPLv2.0
URL: https://libical.github.io/libical/ URL: https://libical.github.io/libical/
Source: https://github.com/%{name}/%{name}/archive/v%{version}/%{name}-%{version}.tar.gz Source: https://github.com/%{name}/%{name}/archive/v%{version}/%{name}-%{version}.tar.gz
Patch01: libical-3.0.3-load-builtin-timezone.patch
Patch02: libical-3.0.8-invoke-python-tests.patch
BuildRequires: gcc BuildRequires: gcc
BuildRequires: gcc-c++ BuildRequires: gcc-c++
BuildRequires: cmake BuildRequires: cmake
@ -66,10 +63,7 @@ Requires: %{name}-glib%{?_isa} = %{version}-%{release}
Development files needed for building things which link against %{name}-glib. Development files needed for building things which link against %{name}-glib.
%prep %prep
%setup -q %autosetup -p1 -S gendiff
%patch01 -p1 -b .load-builtin-timezone
%patch02 -p1 -b .invoke-python-tests
%build %build
%{cmake} \ %{cmake} \
@ -86,6 +80,9 @@ Development files needed for building things which link against %{name}-glib.
%install %install
%cmake_install %cmake_install
# This is just a private build tool, not meant to be installed
rm %{buildroot}/%{_libexecdir}/libical/ical-glib-src-generator
%check %check
make test ARGS="-V" -C %{_target_platform} make test ARGS="-V" -C %{_target_platform}
@ -136,6 +133,9 @@ make test ARGS="-V" -C %{_target_platform}
%{_datadir}/gtk-doc/html/%{name}-glib %{_datadir}/gtk-doc/html/%{name}-glib
%changelog %changelog
* Mon Jan 18 2021 Milan Crha <mcrha@redhat.com> - 3.0.9-1
- Update to 3.0.9
* Tue Aug 04 2020 Milan Crha <mcrha@redhat.com> - 3.0.8-5 * Tue Aug 04 2020 Milan Crha <mcrha@redhat.com> - 3.0.8-5
- Use CMake macros for the build - Use CMake macros for the build
- Change how python tests are invoked (RH bug #1865924) - Change how python tests are invoked (RH bug #1865924)

View File

@ -1 +1 @@
SHA512 (libical-3.0.8.tar.gz) = ce015e6d4c1c7cb4af7b45748ce8251c663f80f6a4357ddff6a97796642619abe882f4cadeca10cabeb1b25577869f436da15bca882e032eb3ff0475f6010d8b SHA512 (libical-3.0.9.tar.gz) = 4a9894d82776437cb2ef16df70bffb52da7b4fd57b52a4f6941430b3b1f9830829f0775fb495411f67393581bda1304b54c9f0031bc3d4ada56d2204900cb268