Compare commits

...

3 Commits
master ... f17

Author SHA1 Message Date
Petr Machata 6b46fc2044 Fix classifying incomplete UTF-8 sequences in Boost.Locale 2013-02-13 13:26:13 +01:00
Petr Machata 0fa3a498eb Build Boost.Locale backends
- Resolves: #832265
2012-06-21 22:56:22 +02:00
Petr Machata c41f59ffd6 In Boost.Pool, be careful not to overflow allocated chunk size.
- Resolves: #828857
2012-06-07 00:47:01 +02:00
4 changed files with 260 additions and 1 deletions

View File

@ -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

61
boost-1.48.0-locale.patch Normal file
View File

@ -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

122
boost-1.48.0-pool.patch Normal file
View File

@ -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 <boost/pool/poolfwd.hpp>
+// std::numeric_limits
+#include <boost/limits.hpp>
// boost::math::static_lcm
#include <boost/math/common_factor_ct.hpp>
@@ -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<sizeof(size_type), sizeof(void *)>::value + sizeof(size_type);
+ size_type max_chunks = (std::numeric_limits<size_type>::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 <boost/pool/object_pool.hpp>
+#include <boost/limits.hpp>
+
+int main()
+{
+ boost::pool<> p(1024, std::numeric_limits<size_t>::max() / 768);
+
+ void *x = p.malloc();
+ BOOST_ASSERT(!x);
+
+ BOOST_ASSERT(std::numeric_limits<size_t>::max() / 1024 >= p.get_next_size());
+ BOOST_ASSERT(std::numeric_limits<size_t>::max() / 1024 >= p.get_max_size());
+
+ void *y = p.ordered_malloc(std::numeric_limits<size_t>::max() / 768);
+ BOOST_ASSERT(!y);
+
+ return 0;
+}

View File

@ -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: 14%{?dist}
License: Boost and MIT and Python
# The CMake build framework (set of CMakeLists.txt and module.cmake files) is
@ -136,6 +136,16 @@ 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
# 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
@ -507,6 +517,9 @@ sed 's/_FEDORA_SONAME/%{sonamever}/' %{PATCH1} | %{__patch} -p0 --fuzz=0
%patch10 -p1
%patch11 -p1
%patch12 -p3
%patch15 -p0
%patch16 -p1
%patch17 -p0
%build
# Support for building tests.
@ -1010,6 +1023,17 @@ rm -rf $RPM_BUILD_ROOT
%{_mandir}/man1/bjam.1*
%changelog
* Wed Feb 13 2013 Petr Machata <pmachata@redhat.com> - 1.48.0-14
- Fix classifying incomplete UTF-8 sequences in Boost.Locale (#907481)
* Thu Jun 21 2012 Petr Machata <pmachata@redhat.com> - 1.48.0-13
- Build Boost.Locale backends
- Resolves: #832265
* Wed Jun 6 2012 Petr Machata <pmachata@redhat.com> - 1.48.0-12
- In Boost.Pool, be careful not to overflow allocated chunk size.
- Resolves: #828857
* Fri Apr 20 2012 Petr Machata <pmachata@redhat.com> - 1.48.0-11
- Add hwloc-devel BR to work around a probable bug in openmpi-devel
which fails to pull it in