aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRishi <rishi_devan@mail.com>2020-07-15 13:51:00 +0200
committerMichał Górny <mgorny@gentoo.org>2020-09-13 10:17:34 +0200
commit893e6e3aee483d262df70656a68f63f601720fcd (patch)
tree3bb456c1bbd65b73535e9597329611d1ba38ac60
parentAdd empty 2.7.18 NEWS file. (diff)
downloadcpython-893e6e3aee483d262df70656a68f63f601720fcd.tar.gz
cpython-893e6e3aee483d262df70656a68f63f601720fcd.tar.bz2
cpython-893e6e3aee483d262df70656a68f63f601720fcd.zip
bpo-39017: Avoid infinite loop in the tarfile module (GH-21454)
Avoid infinite loop when reading specially crafted TAR files using the tarfile module (CVE-2019-20907). [stripped test to avoid binary patch]
-rw-r--r--Lib/tarfile.py2
-rw-r--r--Misc/NEWS.d/next/Library/2020-07-12-22-16-58.bpo-39017.x3Cg-9.rst1
2 files changed, 3 insertions, 0 deletions
diff --git a/Lib/tarfile.py b/Lib/tarfile.py
index adf91d53823..574a6bb279d 100644
--- a/Lib/tarfile.py
+++ b/Lib/tarfile.py
@@ -1400,6 +1400,8 @@ class TarInfo(object):
length, keyword = match.groups()
length = int(length)
+ if length == 0:
+ raise InvalidHeaderError("invalid header")
value = buf[match.end(2) + 1:match.start(1) + length - 1]
keyword = keyword.decode("utf8")
diff --git a/Misc/NEWS.d/next/Library/2020-07-12-22-16-58.bpo-39017.x3Cg-9.rst b/Misc/NEWS.d/next/Library/2020-07-12-22-16-58.bpo-39017.x3Cg-9.rst
new file mode 100644
index 00000000000..ad26676f8b8
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2020-07-12-22-16-58.bpo-39017.x3Cg-9.rst
@@ -0,0 +1 @@
+Avoid infinite loop when reading specially crafted TAR files using the tarfile module (CVE-2019-20907).