From 5b82d9720a09d3cbee17728b20a86f24a800b838 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Wed, 1 Nov 2017 18:35:47 +0100 Subject: [PATCH] Add build failure patches and a fix (no parallel build) No parallel build is for .gir file generation, which could fail on ppc64 and other architectures (more frequently) with an error about empty or incomplete .gir file during the parsing of it. --- ...t-size-in-libical-glib-array.py-test.patch | 30 ++++++++ ...-forgiveness-into-the-timezones-test.patch | 31 +++++++++ ...ble-use-after-free-in-timezones-test.patch | 69 +++++++++++++++++++ libical.spec | 9 ++- 4 files changed, 138 insertions(+), 1 deletion(-) create mode 100644 0001-Increase-element-size-in-libical-glib-array.py-test.patch create mode 100644 0002-Return-back-fail-forgiveness-into-the-timezones-test.patch create mode 100644 0003-Fix-possible-use-after-free-in-timezones-test.patch diff --git a/0001-Increase-element-size-in-libical-glib-array.py-test.patch b/0001-Increase-element-size-in-libical-glib-array.py-test.patch new file mode 100644 index 0000000..0fd4974 --- /dev/null +++ b/0001-Increase-element-size-in-libical-glib-array.py-test.patch @@ -0,0 +1,30 @@ +From eeeaeddd215a8b3796fa66473877629d697a7fcf Mon Sep 17 00:00:00 2001 +From: Milan Crha +Date: Wed, 1 Nov 2017 16:17:49 +0100 +Subject: [PATCH 1/3] Increase element size in libical-glib/array.py test + +The element size 100 was not enough to hold the whole object +on ppc64, ppc64le, aarch64 and s390x architectures, causing objects +breakages and later even crashes. Hence increase the element size. +The size 128 is enough, but use higher value, to have some room +for the future. +--- + src/test/libical-glib/array.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/test/libical-glib/array.py b/src/test/libical-glib/array.py +index 571d45a2..cc7cc758 100755 +--- a/src/test/libical-glib/array.py ++++ b/src/test/libical-glib/array.py +@@ -22,7 +22,7 @@ import sys + from gi.repository import ICalGLib + from sys import getsizeof + +-array = ICalGLib.Array.new(100, 100); ++array = ICalGLib.Array.new(256, 100); + + element1 = "hello"; + element2 = "world"; +-- +2.13.5 + diff --git a/0002-Return-back-fail-forgiveness-into-the-timezones-test.patch b/0002-Return-back-fail-forgiveness-into-the-timezones-test.patch new file mode 100644 index 0000000..a64ef72 --- /dev/null +++ b/0002-Return-back-fail-forgiveness-into-the-timezones-test.patch @@ -0,0 +1,31 @@ +From a84f1f97e995008657c19f931b6bf589e883e84c Mon Sep 17 00:00:00 2001 +From: Milan Crha +Date: Wed, 1 Nov 2017 17:45:49 +0100 +Subject: [PATCH 2/3] Return back fail-forgiveness into the 'timezones' test + +This returns a little part of commit 77f82ba88abbb633dc52335fcc050bec3b41c269, +to not fail the test when less than two percents of the test fail. +It stroke with tzdata-2017c. +--- + src/test/timezones.c | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/src/test/timezones.c b/src/test/timezones.c +index 661c008f..4ccfdea7 100644 +--- a/src/test/timezones.c ++++ b/src/test/timezones.c +@@ -159,6 +159,11 @@ int main() + percent_failed = total_failed * 100 / (total_failed + total_okay); + printf(" *** Summary: %lu zones tested, %u days failed, %u okay => %u%% failed ***\n", + (unsigned long)timezones->num_elements, total_failed, total_okay, percent_failed); ++ ++ if (percent_failed <= 1 && total_failed) { ++ ret = 0; ++ printf(" *** Expect some small error rate with inter-operable vtimezones *** \n"); ++ } + } + + icaltimezone_free_builtin_timezones(); +-- +2.13.5 + diff --git a/0003-Fix-possible-use-after-free-in-timezones-test.patch b/0003-Fix-possible-use-after-free-in-timezones-test.patch new file mode 100644 index 0000000..49f69bb --- /dev/null +++ b/0003-Fix-possible-use-after-free-in-timezones-test.patch @@ -0,0 +1,69 @@ +From c1485563af90468704d835a5f9af506ead1de861 Mon Sep 17 00:00:00 2001 +From: Milan Crha +Date: Wed, 1 Nov 2017 18:14:23 +0100 +Subject: [PATCH 3/3] Fix possible use-after-free in 'timezones' test + +valgrind report of the use-after-free: +Invalid read of size 1 + at 0x4C31B82: strlen (vg_replace_strmem.c:458) + by 0x510C484: vfprintf (in /usr/lib64/libc-2.25.so) + by 0x5113425: printf (in /usr/lib64/libc-2.25.so) + by 0x401116: main (timezones.c:116) + Address 0x8431930 is 0 bytes inside a block of size 19 free'd + at 0x4C2FD18: free (vg_replace_malloc.c:530) + by 0x4E87B27: icaltimezone_get_vtimezone_properties (icaltimezone.c:321) + by 0x4E8A6CA: icaltimezone_load_builtin_timezone (icaltimezone.c:1873) + by 0x4E88148: icaltimezone_ensure_coverage (icaltimezone.c:483) + by 0x4E88FAC: icaltimezone_get_utc_offset_of_utc_time (icaltimezone.c:1003) + by 0x4E88ACF: icaltimezone_convert_time (icaltimezone.c:813) + by 0x4E85548: icaltime_convert_to_zone (icaltime.c:981) + by 0x400F2C: main (timezones.c:98) + Block was alloc'd at + at 0x4C2EB6B: malloc (vg_replace_malloc.c:299) + by 0x514ECE9: strdup (in /usr/lib64/libc-2.25.so) + by 0x4E8A31F: icaltimezone_parse_zone_tab (icaltimezone.c:1761) + by 0x4E89C5F: icaltimezone_init_builtin_timezones (icaltimezone.c:1566) + by 0x4E89757: icaltimezone_get_builtin_timezones (icaltimezone.c:1347) + by 0x400DB4: main (timezones.c:53) + +Which means that the 'zone_location' variable holds freed memory +from time of icaltimezone_load_builtin_timezone() within +icaltimezone_ensure_coverage(). +--- + src/test/timezones.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/src/test/timezones.c b/src/test/timezones.c +index 4ccfdea7..98ba1c82 100644 +--- a/src/test/timezones.c ++++ b/src/test/timezones.c +@@ -26,7 +26,7 @@ int main() + { + icalarray *timezones; + icaltimezone *zone, *utc_zone; +- char *zone_location; ++ const char *zone_location; + size_t i; + int ret = 0; + unsigned int total_failed = 0; +@@ -56,7 +56,7 @@ int main() + /* for all known time zones... */ + for (i = 0; i < timezones->num_elements; i++) { + zone = (icaltimezone *)icalarray_element_at(timezones, i); +- zone_location = (char *)icaltimezone_get_location(zone); ++ zone_location = icaltimezone_get_location(zone); + zonedef_printed = 0; + if (!zone_location) + continue; +@@ -116,7 +116,7 @@ int main() + printf( + "%s: day %03d: %s: %04d-%02d-%02d %02d:%02d:%02d UTC = " + "libc %04d-%02d-%02d %02d:%02d:%02d dst %d", +- zone_location, day, ++ icaltimezone_get_location(zone), day, + verbose ? (curr_failed ? "failed" : "okay") : (curr_failed ? "first failed" : + "okay again"), + utc_tm.tm_year + 1900, utc_tm.tm_mon + 1, utc_tm.tm_mday, utc_tm.tm_hour, +-- +2.13.5 + diff --git a/libical.spec b/libical.spec index 18e6a64..8091b9a 100644 --- a/libical.spec +++ b/libical.spec @@ -6,6 +6,10 @@ License: LGPLv2 or MPLv2.0 URL: http://freeassociation.sourceforge.net/ Source: https://github.com/%{name}/%{name}/archive/v%{version}/%{name}-%{version}.tar.gz +Patch01: 0001-Increase-element-size-in-libical-glib-array.py-test.patch +Patch02: 0002-Return-back-fail-forgiveness-into-the-timezones-test.patch +Patch03: 0003-Fix-possible-use-after-free-in-timezones-test.patch + BuildRequires: bison, byacc, flex BuildRequires: cmake BuildRequires: gtk-doc @@ -70,6 +74,9 @@ Development files needed for building things which link against %{name}-glib. %prep %setup -q +%patch01 -p1 -b .array-py-test-fix +%patch02 -p1 -b .timezones-test-forgiveness +%patch03 -p1 -b .timezones-test-use-after-free %build mkdir -p %{_target_platform} @@ -83,7 +90,7 @@ pushd %{_target_platform} -DSHARED_ONLY:BOOL=true popd -make %{?_smp_mflags} -C %{_target_platform} +make %{?_smp_mflags} -C %{_target_platform} -j1 %install make install/fast DESTDIR=%{buildroot} -C %{_target_platform}