Upstream patch depended unnecessarily on archiver_tests module, which is only in 3.11+ branches.
OBS-URL: https://build.opensuse.org/package/show/devel:languages:python:Factory/python39?expand=0&rev=241
This commit is contained in:
@@ -9,15 +9,15 @@ Co-authored-by: Alexander Urieles <aeurielesn@users.noreply.github.com>
|
||||
Co-authored-by: Gregory P. Smith <greg@krypto.org>
|
||||
---
|
||||
Lib/tarfile.py | 3
|
||||
Lib/test/test_tarfile.py | 188 ++++++++++
|
||||
Lib/test/test_tarfile.py | 156 ++++++++++
|
||||
Misc/NEWS.d/next/Library/2025-07-23-00-35-29.gh-issue-130577.c7EITy.rst | 3
|
||||
3 files changed, 194 insertions(+)
|
||||
3 files changed, 162 insertions(+)
|
||||
create mode 100644 Misc/NEWS.d/next/Library/2025-07-23-00-35-29.gh-issue-130577.c7EITy.rst
|
||||
|
||||
Index: Python-3.9.23/Lib/tarfile.py
|
||||
===================================================================
|
||||
--- Python-3.9.23.orig/Lib/tarfile.py 2025-08-01 22:24:30.059530574 +0200
|
||||
+++ Python-3.9.23/Lib/tarfile.py 2025-08-01 22:24:53.190281380 +0200
|
||||
--- Python-3.9.23.orig/Lib/tarfile.py 2025-08-02 17:56:38.706191816 +0200
|
||||
+++ Python-3.9.23/Lib/tarfile.py 2025-08-02 17:56:43.118456301 +0200
|
||||
@@ -1601,6 +1601,9 @@
|
||||
"""Round up a byte count by BLOCKSIZE and return it,
|
||||
e.g. _block(834) => 1024.
|
||||
@@ -30,8 +30,8 @@ Index: Python-3.9.23/Lib/tarfile.py
|
||||
blocks += 1
|
||||
Index: Python-3.9.23/Lib/test/test_tarfile.py
|
||||
===================================================================
|
||||
--- Python-3.9.23.orig/Lib/test/test_tarfile.py 2025-08-01 22:24:31.377177976 +0200
|
||||
+++ Python-3.9.23/Lib/test/test_tarfile.py 2025-08-01 22:24:53.191008224 +0200
|
||||
--- Python-3.9.23.orig/Lib/test/test_tarfile.py 2025-08-02 17:56:40.012303862 +0200
|
||||
+++ Python-3.9.23/Lib/test/test_tarfile.py 2025-08-02 17:56:56.856747140 +0200
|
||||
@@ -48,6 +48,7 @@
|
||||
xzname = os.path.join(TEMPDIR, "testtar.tar.xz")
|
||||
tmpname = os.path.join(TEMPDIR, "tmp.tar")
|
||||
@@ -40,42 +40,10 @@ Index: Python-3.9.23/Lib/test/test_tarfile.py
|
||||
|
||||
sha256_regtype = (
|
||||
"e09e4bc8b3c9d9177e77256353b36c159f5f040531bbd4b024a8f9b9196c71ce"
|
||||
@@ -4234,6 +4235,193 @@
|
||||
@@ -4234,6 +4235,161 @@
|
||||
self.expect_exception(TypeError) # errorlevel is not int
|
||||
|
||||
|
||||
+class OverwriteTests(archiver_tests.OverwriteTests, unittest.TestCase):
|
||||
+ testdir = os.path.join(TEMPDIR, "testoverwrite")
|
||||
+
|
||||
+ @classmethod
|
||||
+ def setUpClass(cls):
|
||||
+ p = cls.ar_with_file = os.path.join(TEMPDIR, 'tar-with-file.tar')
|
||||
+ cls.addClassCleanup(os_helper.unlink, p)
|
||||
+ with tarfile.open(p, 'w') as tar:
|
||||
+ t = tarfile.TarInfo('test')
|
||||
+ t.size = 10
|
||||
+ tar.addfile(t, io.BytesIO(b'newcontent'))
|
||||
+
|
||||
+ p = cls.ar_with_dir = os.path.join(TEMPDIR, 'tar-with-dir.tar')
|
||||
+ cls.addClassCleanup(os_helper.unlink, p)
|
||||
+ with tarfile.open(p, 'w') as tar:
|
||||
+ tar.addfile(tar.gettarinfo(os.curdir, 'test'))
|
||||
+
|
||||
+ p = os.path.join(TEMPDIR, 'tar-with-implicit-dir.tar')
|
||||
+ cls.ar_with_implicit_dir = p
|
||||
+ cls.addClassCleanup(os_helper.unlink, p)
|
||||
+ with tarfile.open(p, 'w') as tar:
|
||||
+ t = tarfile.TarInfo('test/file')
|
||||
+ t.size = 10
|
||||
+ tar.addfile(t, io.BytesIO(b'newcontent'))
|
||||
+
|
||||
+ def open(self, path):
|
||||
+ return tarfile.open(path, 'r')
|
||||
+
|
||||
+ def extractall(self, ar):
|
||||
+ ar.extractall(self.testdir, filter='fully_trusted')
|
||||
+
|
||||
+
|
||||
+class OffsetValidationTests(unittest.TestCase):
|
||||
+ tarname = tmpname
|
||||
+ invalid_posix_header = (
|
||||
@@ -237,7 +205,7 @@ Index: Python-3.9.23/Lib/test/test_tarfile.py
|
||||
Index: Python-3.9.23/Misc/NEWS.d/next/Library/2025-07-23-00-35-29.gh-issue-130577.c7EITy.rst
|
||||
===================================================================
|
||||
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
|
||||
+++ Python-3.9.23/Misc/NEWS.d/next/Library/2025-07-23-00-35-29.gh-issue-130577.c7EITy.rst 2025-08-01 22:24:53.191631842 +0200
|
||||
+++ Python-3.9.23/Misc/NEWS.d/next/Library/2025-07-23-00-35-29.gh-issue-130577.c7EITy.rst 2025-08-02 17:56:43.119864870 +0200
|
||||
@@ -0,0 +1,3 @@
|
||||
+:mod:`tarfile` now validates archives to ensure member offsets are
|
||||
+non-negative. (Contributed by Alexander Enrique Urieles Nieto in
|
||||
|
Reference in New Issue
Block a user