From c41f59ffd61ad654178bc7d16122ad8b3ad28e17 Mon Sep 17 00:00:00 2001 From: Petr Machata Date: Thu, 7 Jun 2012 00:47:01 +0200 Subject: [PATCH 1/3] In Boost.Pool, be careful not to overflow allocated chunk size. - Resolves: #828857 --- boost-1.48.0-pool.patch | 122 ++++++++++++++++++++++++++++++++++++++++ boost.spec | 11 +++- 2 files changed, 132 insertions(+), 1 deletion(-) create mode 100644 boost-1.48.0-pool.patch diff --git a/boost-1.48.0-pool.patch b/boost-1.48.0-pool.patch new file mode 100644 index 0000000..5154027 --- /dev/null +++ b/boost-1.48.0-pool.patch @@ -0,0 +1,122 @@ +Index: boost/pool/pool.hpp +=================================================================== +--- boost/pool/pool.hpp (revision 78317) ++++ boost/pool/pool.hpp (revision 78326) +@@ -27,4 +27,6 @@ + #include + ++// std::numeric_limits ++#include + // boost::math::static_lcm + #include +@@ -358,4 +360,13 @@ + } + ++ size_type max_chunks() const ++ { //! Calculated maximum number of memory chunks that can be allocated in a single call by this Pool. ++ size_type partition_size = alloc_size(); ++ size_type POD_size = math::static_lcm::value + sizeof(size_type); ++ size_type max_chunks = (std::numeric_limits::max() - POD_size) / alloc_size(); ++ ++ return max_chunks; ++ } ++ + static void * & nextof(void * const ptr) + { //! \returns Pointer dereferenced. +@@ -377,5 +388,7 @@ + //! the first time that object needs to allocate system memory. + //! The default is 32. This parameter may not be 0. +- //! \param nmax_size is the maximum number of chunks to allocate in one block. ++ //! \param nmax_size is the maximum number of chunks to allocate in one block. ++ set_next_size(nnext_size); ++ set_max_size(nmax_size); + } + +@@ -400,7 +413,7 @@ + } + void set_next_size(const size_type nnext_size) +- { //! Set number of chunks to request from the system the next time that object needs to allocate system memory. This value should never be set to 0. +- //! \returns nnext_size. +- next_size = start_size = nnext_size; ++ { //! Set number of chunks to request from the system the next time that object needs to allocate system memory. This value should never be set to 0. ++ BOOST_USING_STD_MIN(); ++ next_size = start_size = min BOOST_PREVENT_MACRO_SUBSTITUTION(nnext_size, max_chunks()); + } + size_type get_max_size() const +@@ -410,5 +423,6 @@ + void set_max_size(const size_type nmax_size) + { //! Set max_size. +- max_size = nmax_size; ++ BOOST_USING_STD_MIN(); ++ max_size = min BOOST_PREVENT_MACRO_SUBSTITUTION(nmax_size, max_chunks()); + } + size_type get_requested_size() const +@@ -713,7 +727,7 @@ + BOOST_USING_STD_MIN(); + if(!max_size) +- next_size <<= 1; ++ set_next_size(next_size << 1); + else if( next_size*partition_size/requested_size < max_size) +- next_size = min BOOST_PREVENT_MACRO_SUBSTITUTION(next_size << 1, max_size*requested_size/ partition_size); ++ set_next_size(min BOOST_PREVENT_MACRO_SUBSTITUTION(next_size << 1, max_size * requested_size / partition_size)); + + // initialize it, +@@ -753,7 +767,7 @@ + BOOST_USING_STD_MIN(); + if(!max_size) +- next_size <<= 1; ++ set_next_size(next_size << 1); + else if( next_size*partition_size/requested_size < max_size) +- next_size = min BOOST_PREVENT_MACRO_SUBSTITUTION(next_size << 1, max_size*requested_size/ partition_size); ++ set_next_size(min BOOST_PREVENT_MACRO_SUBSTITUTION(next_size << 1, max_size * requested_size / partition_size)); + + // initialize it, +@@ -797,4 +811,6 @@ + //! \returns Address of chunk n if allocated ok. + //! \returns 0 if not enough memory for n chunks. ++ if (n > max_chunks()) ++ return 0; + + const size_type partition_size = alloc_size(); +@@ -845,7 +861,7 @@ + BOOST_USING_STD_MIN(); + if(!max_size) +- next_size <<= 1; ++ set_next_size(next_size << 1); + else if( next_size*partition_size/requested_size < max_size) +- next_size = min BOOST_PREVENT_MACRO_SUBSTITUTION(next_size << 1, max_size*requested_size/ partition_size); ++ set_next_size(min BOOST_PREVENT_MACRO_SUBSTITUTION(next_size << 1, max_size * requested_size / partition_size)); + + // insert it into the list, +Index: libs/pool/test/test_bug_6701.cpp +=================================================================== +--- libs/pool/test/test_bug_6701.cpp (revision 78326) ++++ libs/pool/test/test_bug_6701.cpp (revision 78326) +@@ -0,0 +1,27 @@ ++/* Copyright (C) 2012 Étienne Dupuis ++* ++* Use, modification and distribution is subject to the ++* Boost Software License, Version 1.0. (See accompanying ++* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) ++*/ ++ ++// Test of bug #6701 (https://svn.boost.org/trac/boost/ticket/6701) ++ ++#include ++#include ++ ++int main() ++{ ++ boost::pool<> p(1024, std::numeric_limits::max() / 768); ++ ++ void *x = p.malloc(); ++ BOOST_ASSERT(!x); ++ ++ BOOST_ASSERT(std::numeric_limits::max() / 1024 >= p.get_next_size()); ++ BOOST_ASSERT(std::numeric_limits::max() / 1024 >= p.get_max_size()); ++ ++ void *y = p.ordered_malloc(std::numeric_limits::max() / 768); ++ BOOST_ASSERT(!y); ++ ++ return 0; ++} diff --git a/boost.spec b/boost.spec index 98bc6ca..62b62d9 100644 --- a/boost.spec +++ b/boost.spec @@ -28,7 +28,7 @@ Name: boost Summary: The free peer-reviewed portable C++ source libraries Version: 1.48.0 %define version_enc 1_48_0 -Release: 11%{?dist} +Release: 12%{?dist} License: Boost and MIT and Python # The CMake build framework (set of CMakeLists.txt and module.cmake files) is @@ -136,6 +136,10 @@ Patch11: boost-1.48.0-long-double.patch # https://bugzilla.redhat.com/show_bug.cgi?id=784654 Patch12: boost-1.48.0-polygon.patch +# https://bugzilla.redhat.com/show_bug.cgi?id=828856 +# https://bugzilla.redhat.com/show_bug.cgi?id=828857 +Patch15: boost-1.48.0-pool.patch + %bcond_with tests %bcond_with docs_generated @@ -507,6 +511,7 @@ sed 's/_FEDORA_SONAME/%{sonamever}/' %{PATCH1} | %{__patch} -p0 --fuzz=0 %patch10 -p1 %patch11 -p1 %patch12 -p3 +%patch15 -p0 %build # Support for building tests. @@ -1010,6 +1015,10 @@ rm -rf $RPM_BUILD_ROOT %{_mandir}/man1/bjam.1* %changelog +* Wed Jun 6 2012 Petr Machata - 1.48.0-12 +- In Boost.Pool, be careful not to overflow allocated chunk size. +- Resolves: #828857 + * Fri Apr 20 2012 Petr Machata - 1.48.0-11 - Add hwloc-devel BR to work around a probable bug in openmpi-devel which fails to pull it in From 0fa3a498eb15bd3f1e250c1c05d22bf03d601b2c Mon Sep 17 00:00:00 2001 From: Petr Machata Date: Thu, 21 Jun 2012 22:56:22 +0200 Subject: [PATCH 2/3] Build Boost.Locale backends - Resolves: #832265 --- boost-1.48.0-locale.patch | 61 +++++++++++++++++++++++++++++++++++++++ boost.spec | 10 ++++++- 2 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 boost-1.48.0-locale.patch diff --git a/boost-1.48.0-locale.patch b/boost-1.48.0-locale.patch new file mode 100644 index 0000000..277fa56 --- /dev/null +++ b/boost-1.48.0-locale.patch @@ -0,0 +1,61 @@ +diff -up boost_1_48_0/libs/locale/src/CMakeLists.txt\~ boost_1_48_0/libs/locale/src/CMakeLists.txt +--- boost_1_48_0/libs/locale/src/CMakeLists.txt~ 2012-06-07 00:46:43.651884964 +0200 ++++ boost_1_48_0/libs/locale/src/CMakeLists.txt 2012-06-21 19:01:16.321372875 +0200 +@@ -10,6 +10,10 @@ if (ICU_FOUND AND ICU_I18N_FOUND) + set (BOOST_LOCALE_ICU_LIBRARIES ${ICU_LIBRARIES} ${ICU_I18N_LIBRARIES}) + colormsg (GREEN "+-- ICU (unicode) available for locale, enabling support.") +- set (NO_STATIC_IF_ICU_FOUND "NO_STATIC") ++ set (NO_STATIC_IF_ICU_FOUND NO_STATIC NO_SINGLE_THREADED) ++ set (ICU_SOURCES icu/boundary.cpp icu/codecvt.cpp icu/collator.cpp ++ icu/conversion.cpp icu/date_time.cpp icu/formatter.cpp ++ icu/icu_backend.cpp icu/numeric.cpp icu/time_zone.cpp ) ++ set (ICU_DEPENDS boost_thread) + else (ICU_FOUND AND ICU_I18N_FOUND) + colormsg (CYAN "+-- ICU (unicode) not available for locale, disabling support.") + endif (ICU_FOUND AND ICU_I18N_FOUND) +@@ -17,8 +17,9 @@ endif (ICU_FOUND AND ICU_I18N_FOUND) + if (WIN32) + add_definitions (-DBOOST_LOCALE_NO_POSIX_BACKEND=1) + set (WIN32_SOURCES win32/collate.cpp win32/converter.cpp win32/lcid.cpp +- win32/numeric.cpp win32/win_backend.cpp std/codecvt.cpp std/collate.cpp +- std/converter.cpp std/numeric.cpp std/std_backend.cpp util/gregorian.cpp) ++ win32/numeric.cpp win32/win_backend.cpp ) ++else (WIN32) ++ add_definitions (-DBOOST_LOCALE_NO_WINAPI_BACKEND=1) + endif (WIN32) + + add_definitions (-DBOOST_THREAD_NO_LIB=1) +@@ -33,12 +34,29 @@ boost_add_library ( + shared/localization_backend.cpp + shared/message.cpp + shared/mo_lambda.cpp +- ${WIN32_SOURCES} ++ + util/codecvt_converter.cpp + util/default_locale.cpp + util/info.cpp +- util/locale_data.cpp ++ util/locale_data.cpp ++ util/gregorian.cpp ++ ++ std/codecvt.cpp ++ std/collate.cpp ++ std/converter.cpp ++ std/numeric.cpp ++ std/std_backend.cpp ++ ++ posix/codecvt.cpp ++ posix/collate.cpp ++ posix/converter.cpp ++ posix/numeric.cpp ++ posix/posix_backend.cpp ++ ++ ${WIN32_SOURCES} ++ ${ICU_SOURCES} + ++ DEPENDS ${ICU_DEPENDS} + LINK_LIBS ${BOOST_LOCALE_ICU_LIBRARIES} + SHARED_COMPILE_FLAGS -DBOOST_LOCALE_DYN_LINK=1 + ${NO_STATIC_IF_ICU_FOUND} + +Diff finished. Thu Jun 21 19:05:54 2012 diff --git a/boost.spec b/boost.spec index 62b62d9..383c76a 100644 --- a/boost.spec +++ b/boost.spec @@ -28,7 +28,7 @@ Name: boost Summary: The free peer-reviewed portable C++ source libraries Version: 1.48.0 %define version_enc 1_48_0 -Release: 12%{?dist} +Release: 13%{?dist} License: Boost and MIT and Python # The CMake build framework (set of CMakeLists.txt and module.cmake files) is @@ -140,6 +140,9 @@ Patch12: boost-1.48.0-polygon.patch # https://bugzilla.redhat.com/show_bug.cgi?id=828857 Patch15: boost-1.48.0-pool.patch +# https://bugzilla.redhat.com/show_bug.cgi?id=832265 +Patch16: boost-1.48.0-locale.patch + %bcond_with tests %bcond_with docs_generated @@ -512,6 +515,7 @@ sed 's/_FEDORA_SONAME/%{sonamever}/' %{PATCH1} | %{__patch} -p0 --fuzz=0 %patch11 -p1 %patch12 -p3 %patch15 -p0 +%patch16 -p1 %build # Support for building tests. @@ -1015,6 +1019,10 @@ rm -rf $RPM_BUILD_ROOT %{_mandir}/man1/bjam.1* %changelog +* Thu Jun 21 2012 Petr Machata - 1.48.0-13 +- Build Boost.Locale backends +- Resolves: #832265 + * Wed Jun 6 2012 Petr Machata - 1.48.0-12 - In Boost.Pool, be careful not to overflow allocated chunk size. - Resolves: #828857 From 6b46fc2044c4ec69c3f9fff12118079a27137393 Mon Sep 17 00:00:00 2001 From: Petr Machata Date: Wed, 13 Feb 2013 13:26:13 +0100 Subject: [PATCH 3/3] Fix classifying incomplete UTF-8 sequences in Boost.Locale --- boost-1.48.0-invalid-utf8.patch | 52 +++++++++++++++++++++++++++++++++ boost.spec | 9 +++++- 2 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 boost-1.48.0-invalid-utf8.patch diff --git a/boost-1.48.0-invalid-utf8.patch b/boost-1.48.0-invalid-utf8.patch new file mode 100644 index 0000000..7ef51e9 --- /dev/null +++ b/boost-1.48.0-invalid-utf8.patch @@ -0,0 +1,52 @@ +Index: boost/locale/utf.hpp +=================================================================== +--- boost/locale/utf.hpp (revision 81589) ++++ boost/locale/utf.hpp (revision 81590) +@@ -219,16 +219,22 @@ + if(BOOST_LOCALE_UNLIKELY(p==e)) + return incomplete; + tmp = *p++; ++ if (!is_trail(tmp)) ++ return illegal; + c = (c << 6) | ( tmp & 0x3F); + case 2: + if(BOOST_LOCALE_UNLIKELY(p==e)) + return incomplete; + tmp = *p++; ++ if (!is_trail(tmp)) ++ return illegal; + c = (c << 6) | ( tmp & 0x3F); + case 1: + if(BOOST_LOCALE_UNLIKELY(p==e)) + return incomplete; + tmp = *p++; ++ if (!is_trail(tmp)) ++ return illegal; + c = (c << 6) | ( tmp & 0x3F); + } + +Index: libs/locale/test/test_codepage_converter.cpp +=================================================================== +--- libs/locale/test/test_codepage_converter.cpp (revision 81589) ++++ libs/locale/test/test_codepage_converter.cpp (revision 81590) +@@ -140,6 +140,20 @@ + TEST_TO("\xf8\x90\x80\x80\x80",illegal); // 400 0000 + TEST_TO("\xfd\xbf\xbf\xbf\xbf\xbf",illegal); // 7fff ffff + ++ std::cout << "-- Invalid trail" << std::endl; ++ TEST_TO("\xC2\x7F",illegal); ++ TEST_TO("\xdf\x7F",illegal); ++ TEST_TO("\xe0\x7F\x80",illegal); ++ TEST_TO("\xef\xbf\x7F",illegal); ++ TEST_TO("\xe0\x7F\x80",illegal); ++ TEST_TO("\xef\xbf\x7F",illegal); ++ TEST_TO("\xf0\x7F\x80\x80",illegal); ++ TEST_TO("\xf4\x7f\xbf\xbf",illegal); ++ TEST_TO("\xf0\x90\x7F\x80",illegal); ++ TEST_TO("\xf4\x8f\x7F\xbf",illegal); ++ TEST_TO("\xf0\x90\x80\x7F",illegal); ++ TEST_TO("\xf4\x8f\xbf\x7F",illegal); ++ + std::cout << "-- Invalid length" << std::endl; + + /// Test that this actually works diff --git a/boost.spec b/boost.spec index 383c76a..1124f95 100644 --- a/boost.spec +++ b/boost.spec @@ -28,7 +28,7 @@ Name: boost Summary: The free peer-reviewed portable C++ source libraries Version: 1.48.0 %define version_enc 1_48_0 -Release: 13%{?dist} +Release: 14%{?dist} License: Boost and MIT and Python # The CMake build framework (set of CMakeLists.txt and module.cmake files) is @@ -143,6 +143,9 @@ Patch15: boost-1.48.0-pool.patch # https://bugzilla.redhat.com/show_bug.cgi?id=832265 Patch16: boost-1.48.0-locale.patch +# https://bugzilla.redhat.com/show_bug.cgi?id=907481 +Patch17: boost-1.48.0-invalid-utf8.patch + %bcond_with tests %bcond_with docs_generated @@ -516,6 +519,7 @@ sed 's/_FEDORA_SONAME/%{sonamever}/' %{PATCH1} | %{__patch} -p0 --fuzz=0 %patch12 -p3 %patch15 -p0 %patch16 -p1 +%patch17 -p0 %build # Support for building tests. @@ -1019,6 +1023,9 @@ rm -rf $RPM_BUILD_ROOT %{_mandir}/man1/bjam.1* %changelog +* Wed Feb 13 2013 Petr Machata - 1.48.0-14 +- Fix classifying incomplete UTF-8 sequences in Boost.Locale (#907481) + * Thu Jun 21 2012 Petr Machata - 1.48.0-13 - Build Boost.Locale backends - Resolves: #832265