python2:fix excessive memory usage when using regular expressions

This commit is contained in:
hanxinke 2020-02-29 10:59:54 +08:00
parent 710166c791
commit 4d27d5e543
2 changed files with 33 additions and 1 deletions

View File

@ -0,0 +1,25 @@
diff --git a/Lib/sre_compile.py b/Lib/sre_compile.py
index b6689fa..0063845 100644
--- a/Lib/sre_compile.py
+++ b/Lib/sre_compile.py
@@ -271,7 +271,7 @@ def _optimize_charset(charset, fixup, fixes, isunicode):
else:
charmap[av] = 1
elif op is RANGE:
- r = range(av[0], av[1]+1)
+ r = xrange(av[0], av[1]+1)
if fixup:
r = map(fixup, r)
if fixup and fixes:
@@ -374,7 +374,7 @@ def _optimize_charset(charset, fixup, fixes, isunicode):
mapping = bytearray(256)
block = 0
data = bytearray()
- for i in range(0, 65536, 256):
+ for i in xrange(0, 65536, 256):
chunk = charmap[i: i + 256]
if chunk in comps:
mapping[i // 256] = comps[chunk]
--
1.8.3.1

View File

@ -15,7 +15,7 @@
%undefine _debuginfo_subpackages
Name: python2
Version: 2.7.16
Release: 13
Release: 14
Summary: Python is an interpreted, interactive object-oriented programming language suitable
License: Python
URL: https://www.python.org/
@ -99,6 +99,7 @@ Patch6055: CVE-2018-20852.patch
Patch6056: CVE-2019-16935.patch
Patch6057: CVE-2019-17514.patch
Patch6058: CVE-2017-18207.patch
Patch6059: bugfix-excessive-memory-usage-when-using-regular-expressions.patch
BuildRequires: libdb-devel libffi-devel valgrind-devel ncurses-devel expat-devel readline-devel
BuildRequires: openssl-devel libtirpc-devel tcl-devel tk-devel glibc-devel libnsl2-devel
@ -633,6 +634,12 @@ sed -e "s|LIBRARY_PATH|%{_libdir}/%{py_INSTSONAME_debug}|" %{SOURCE1} \
%{dynload_dir}/_testcapimodule_d.so
%changelog
* Sat Feb 29 2020 hanxinke<hanxinke@huawei.com> - 2.7.16-14
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:fix excessive memory usage when using regular expressions
* Sat Feb 22 2020 openEuler Buildteam <buildteam@openeuler.org> - 2.7.16-13
- Type:bugfix
- Id:NA