Add patch for Boost.Regex integer overflow (#1564252)

This commit is contained in:
Jonathan Wakely 2018-04-18 18:46:36 +01:00
parent 204b6db7df
commit 9b9c9106a8
2 changed files with 35 additions and 1 deletions

View File

@ -0,0 +1,26 @@
From bc9b25b5d3c3784543158510c6087d41739ab64a Mon Sep 17 00:00:00 2001
From: jzmaddock <john@johnmaddock.co.uk>
Date: Mon, 31 Jul 2017 19:18:10 +0100
Subject: [PATCH] Fix potential overflow in max_state_count calculation. Fixes:
https://svn.boost.org/trac10/ticket/13036.
---
include/boost/regex/v4/perl_matcher_common.hpp | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/include/boost/regex/v4/perl_matcher_common.hpp b/include/boost/regex/v4/perl_matcher_common.hpp
index 7974e7483..f08e9d434 100644
--- a/include/boost/regex/v4/perl_matcher_common.hpp
+++ b/include/boost/regex/v4/perl_matcher_common.hpp
@@ -113,6 +113,11 @@ void perl_matcher<BidiIterator, Allocator, traits>::estimate_max_state_count(std
std::ptrdiff_t states = re.size();
if(states == 0)
states = 1;
+ if ((std::numeric_limits<std::ptrdiff_t>::max)() / states < states)
+ {
+ max_state_count = (std::min)((std::ptrdiff_t)BOOST_REGEX_MAX_STATE_COUNT, (std::numeric_limits<std::ptrdiff_t>::max)() - 2);
+ return;
+ }
states *= states;
if((std::numeric_limits<std::ptrdiff_t>::max)() / dist < states)
{

View File

@ -35,7 +35,7 @@ Name: boost
Summary: The free peer-reviewed portable C++ source libraries
Version: 1.64.0
%global version_enc 1_64_0
Release: 5%{?dist}
Release: 6%{?dist}
License: Boost and MIT and Python
%global toplev_dirname %{name}_%{version_enc}
@ -151,6 +151,10 @@ Patch86: boost-1.64.0-icl-ttp-matching.patch
# https://github.com/boostorg/icl/pull/11
Patch87: boost-1.64.0-icl-undefined-shift.patch
# https://bugzilla.redhat.com/show_bug.cgi?id=1564252
# https://svn.boost.org/trac10/ticket/13036
Patch90: boost-1.64.0-regex-overflow.patch
%bcond_with tests
%bcond_with docs_generated
@ -768,6 +772,7 @@ find ./boost -name '*.hpp' -perm /111 | xargs chmod a-x
%patch85 -p2
%patch86 -p2
%patch87 -p2
%patch90 -p2
# At least python2_version needs to be a macro so that it's visible in
# %%install as well.
@ -1557,6 +1562,9 @@ fi
%{_mandir}/man1/bjam.1*
%changelog
* Wed Apr 18 2018 Jonathan Wakely <jwakely@redhat.com> - 1.64.0-6
- Add patch for Boost.Regex integer overflow (#1564252)
* Wed Feb 28 2018 Jonathan Wakely <jwakely@redhat.com> - 1.64.0-5
- Move Requires: boost-container out of conditional block.