diff --git a/bpo34990-2038-problem-compileall.patch b/bpo34990-2038-problem-compileall.patch new file mode 100644 index 0000000..68d76e3 --- /dev/null +++ b/bpo34990-2038-problem-compileall.patch @@ -0,0 +1,142 @@ +From 9d3b6b2472f7c7ef841e652825de652bc8af85d7 Mon Sep 17 00:00:00 2001 +From: "Miss Islington (bot)" + <31488909+miss-islington@users.noreply.github.com> +Date: Tue, 24 Aug 2021 08:07:31 -0700 +Subject: [PATCH] [3.9] bpo-34990: Treat the pyc header's mtime in compileall + as an unsigned int (GH-19708) +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +(cherry picked from commit bb21e28fd08f894ceff2405544a2f257d42b1354) + +Co-authored-by: Ammar Askar +Co-authored-by: Stéphane Wirtel + +ported to python-2.7 by Bernhard M. Wiedemann + +diff --git a/Lib/compileall.py b/Lib/compileall.py +index 5cfa8be..193147e 100644 +--- a/Lib/compileall.py ++++ b/Lib/compileall.py +@@ -85,7 +85,7 @@ def compile_file(fullname, ddir=None, force=0, rx=None, quiet=0): + if not force: + try: + mtime = int(os.stat(fullname).st_mtime) +- expect = struct.pack('<4sl', imp.get_magic(), mtime) ++ expect = struct.pack('<4sL', imp.get_magic(), mtime & 0xFFFFFFFF) + cfile = fullname + (__debug__ and 'c' or 'o') + with open(cfile, 'rb') as chandle: + actual = chandle.read(8) +diff --git a/Lib/test/test_compileall.py b/Lib/test/test_compileall.py +index d3a26db..0907f59 100644 +--- a/Lib/test/test_compileall.py ++++ b/Lib/test/test_compileall.py +@@ -28,7 +28,7 @@ class CompileallTests(unittest.TestCase): + with open(self.bc_path, 'rb') as file: + data = file.read(8) + mtime = int(os.stat(self.source_path).st_mtime) +- compare = struct.pack('<4sl', imp.get_magic(), mtime) ++ compare = struct.pack('<4sL', imp.get_magic(), mtime & 0xFFFFFFFF) + return data, compare + + @unittest.skipUnless(hasattr(os, 'stat'), 'test needs os.stat()') +@@ -48,7 +48,7 @@ class CompileallTests(unittest.TestCase): + + def test_mtime(self): + # Test a change in mtime leads to a new .pyc. +- self.recreation_check(struct.pack('<4sl', imp.get_magic(), 1)) ++ self.recreation_check(struct.pack('<4sL', imp.get_magic(), 1)) + + def test_magic_number(self): + # Test a change in mtime leads to a new .pyc. +diff --git a/Lib/test/test_zipimport.py b/Lib/test/test_zipimport.py +index a66738a..e333582 100644 +--- a/Lib/test/test_zipimport.py ++++ b/Lib/test/test_zipimport.py +@@ -27,13 +27,7 @@ raise_src = 'def do_raise(): raise TypeError\n' + + def make_pyc(co, mtime): + data = marshal.dumps(co) +- if type(mtime) is type(0.0): +- # Mac mtimes need a bit of special casing +- if mtime < 0x7fffffff: +- mtime = int(mtime) +- else: +- mtime = int(-0x100000000L + long(mtime)) +- pyc = imp.get_magic() + struct.pack(" +Date: 2022-09-13 + +More y2038 fixes that are only needed for python2.7 + +diff --git a/Lib/compiler/pycodegen.py b/Lib/compiler/pycodegen.py +index 6515945..21d52bb 100644 +--- a/Lib/compiler/pycodegen.py ++++ b/Lib/compiler/pycodegen.py +@@ -128,7 +128,7 @@ class Module(AbstractCompileMode): + # to indicate the type of the value. simplest way to get the + # same effect is to call marshal and then skip the code. + mtime = os.path.getmtime(self.filename) +- mtime = struct.pack(' + +- Add bpo34990-2038-problem-compileall.patch making compileall.py + compliant with year 2038 (bsc#1202666, gh#python/cpython#79171), + backport of fix to Python 2.7. + ------------------------------------------------------------------- Wed Sep 7 04:46:44 UTC 2022 - Steve Kowalik diff --git a/python-base.spec b/python-base.spec index 3fa676f..1e4ca32 100644 --- a/python-base.spec +++ b/python-base.spec @@ -133,6 +133,7 @@ Patch70: CVE-2015-20107-mailcap-unsafe-filenames.patch # PATCH-FIX-UPSTREAM CVE-2021-28861 bsc#1202624 # Coerce // to / in Lib/BaseHTTPServer.py Patch71: CVE-2021-28861-double-slash-path.patch +Patch72: bpo34990-2038-problem-compileall.patch # COMMON-PATCH-END %define python_version %(echo %{tarversion} | head -c 3) BuildRequires: automake @@ -270,6 +271,7 @@ other applications. %patch69 -p1 %patch70 -p1 %patch71 -p1 +%patch72 -p1 # For patch 66 cp -v %{SOURCE66} Lib/test/recursion.tar diff --git a/python-doc.changes b/python-doc.changes index 8f30fd1..12d527b 100644 --- a/python-doc.changes +++ b/python-doc.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Tue Sep 13 04:06:02 UTC 2022 - Bernhard Wiedemann + +- Add bpo34990-2038-problem-compileall.patch making compileall.py + compliant with year 2038 (bsc#1202666, gh#python/cpython#79171), + backport of fix to Python 2.7. + ------------------------------------------------------------------- Wed Sep 7 04:46:44 UTC 2022 - Steve Kowalik diff --git a/python-doc.spec b/python-doc.spec index 0ac768b..6b67e16 100644 --- a/python-doc.spec +++ b/python-doc.spec @@ -132,6 +132,7 @@ Patch70: CVE-2015-20107-mailcap-unsafe-filenames.patch # PATCH-FIX-UPSTREAM CVE-2021-28861 bsc#1202624 # Coerce // to / in Lib/BaseHTTPServer.py Patch71: CVE-2021-28861-double-slash-path.patch +Patch72: bpo34990-2038-problem-compileall.patch # COMMON-PATCH-END Provides: pyth_doc = %{version} Provides: pyth_ps = %{version} @@ -207,6 +208,7 @@ Python, and Macintosh Module Reference in PDF format. %patch69 -p1 %patch70 -p1 %patch71 -p1 +%patch72 -p1 # For patch 66 cp -v %{SOURCE66} Lib/test/recursion.tar diff --git a/python.changes b/python.changes index 8f30fd1..12d527b 100644 --- a/python.changes +++ b/python.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Tue Sep 13 04:06:02 UTC 2022 - Bernhard Wiedemann + +- Add bpo34990-2038-problem-compileall.patch making compileall.py + compliant with year 2038 (bsc#1202666, gh#python/cpython#79171), + backport of fix to Python 2.7. + ------------------------------------------------------------------- Wed Sep 7 04:46:44 UTC 2022 - Steve Kowalik diff --git a/python.spec b/python.spec index eb4d3ee..d4b9228 100644 --- a/python.spec +++ b/python.spec @@ -132,6 +132,7 @@ Patch70: CVE-2015-20107-mailcap-unsafe-filenames.patch # PATCH-FIX-UPSTREAM CVE-2021-28861 bsc#1202624 # Coerce // to / in Lib/BaseHTTPServer.py Patch71: CVE-2021-28861-double-slash-path.patch +Patch72: bpo34990-2038-problem-compileall.patch # COMMON-PATCH-END BuildRequires: automake BuildRequires: db-devel @@ -323,6 +324,7 @@ that rely on earlier non-verification behavior. %patch69 -p1 %patch70 -p1 %patch71 -p1 +%patch72 -p1 # For patch 66 cp -v %{SOURCE66} Lib/test/recursion.tar