Fix classifying incomplete UTF-8 sequences in Boost.Locale

This commit is contained in:
Petr Machata 2013-02-13 13:18:54 +01:00
parent b5f76d5add
commit 6605c4a402
2 changed files with 59 additions and 2 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

View File

@ -25,7 +25,7 @@ Name: boost
Summary: The free peer-reviewed portable C++ source libraries
Version: 1.50.0
%define version_enc 1_50_0
Release: 4%{?dist}
Release: 5%{?dist}
License: Boost and MIT and Python
%define toplev_dirname %{name}_%{version_enc}
@ -108,6 +108,9 @@ Patch12: boost-1.50.0-polygon.patch
# https://bugzilla.redhat.com/show_bug.cgi?id=828857
Patch15: boost-1.50.0-pool.patch
# https://bugzilla.redhat.com/show_bug.cgi?id=907481
Patch17: boost-1.50.0-invalid-utf8.patch
%bcond_with tests
%bcond_with docs_generated
@ -485,6 +488,7 @@ a number of significant features and is now developed independently
%patch10 -p1
%patch12 -p3
%patch15 -p0
%patch17 -p0
# At least python2_version needs to be a macro so that it's visible in
# %%install as well.
@ -969,9 +973,10 @@ rm -rf $RPM_BUILD_ROOT
%{_mandir}/man1/bjam.1*
%changelog
* Thu Aug 16 2012 Petr Machata <pmachata@redhat.com> - 1.50.0-5
* Wed Feb 13 2013 Petr Machata <pmachata@redhat.com> - 1.50.0-5
- Update %%description to reflect current state of C++
standardization. Courtesy of Jonathan Wakely. (#837813)
- Fix classifying incomplete UTF-8 sequences in Boost.Locale (#907481)
* Wed Aug 15 2012 Petr Machata <pmachata@redhat.com> - 1.50.0-4
- Override boost_thread-mt.so with a linker script that brings in