about summary refs log tree commit diff
path: root/pkgs/development/interpreters/python/cpython
diff options
context:
space:
mode:
authorChristian Kauhaus <kc@flyingcircus.io>2020-08-04 15:11:59 +0200
committerFrederik Rietdijk <freddyrietdijk@fridh.nl>2020-08-11 16:05:43 +0200
commita14859c686da4a9c433aaa287a122519b4e97ca1 (patch)
treee6c17d7eb8f2d042fe912c41c4e446abfa28e9c1 /pkgs/development/interpreters/python/cpython
parent46ee7ddcad182f5d546d71b18fc908a49a853c08 (diff)
downloadnixlib-a14859c686da4a9c433aaa287a122519b4e97ca1.tar
nixlib-a14859c686da4a9c433aaa287a122519b4e97ca1.tar.gz
nixlib-a14859c686da4a9c433aaa287a122519b4e97ca1.tar.bz2
nixlib-a14859c686da4a9c433aaa287a122519b4e97ca1.tar.lz
nixlib-a14859c686da4a9c433aaa287a122519b4e97ca1.tar.xz
nixlib-a14859c686da4a9c433aaa287a122519b4e97ca1.tar.zst
nixlib-a14859c686da4a9c433aaa287a122519b4e97ca1.zip
python: Apply patch for CVE-2019-20907
Incluing the patch file in-tree because the upstream patch is not
intended to apply for Python 2.

Re #94004
Diffstat (limited to 'pkgs/development/interpreters/python/cpython')
-rw-r--r--pkgs/development/interpreters/python/cpython/2.7/CVE-2019-20907.patch24
-rw-r--r--pkgs/development/interpreters/python/cpython/2.7/default.nix3
2 files changed, 27 insertions, 0 deletions
diff --git a/pkgs/development/interpreters/python/cpython/2.7/CVE-2019-20907.patch b/pkgs/development/interpreters/python/cpython/2.7/CVE-2019-20907.patch
new file mode 100644
index 000000000000..cf67ae2b51be
--- /dev/null
+++ b/pkgs/development/interpreters/python/cpython/2.7/CVE-2019-20907.patch
@@ -0,0 +1,24 @@
+From 5a8d121a1f3ef5ad7c105ee378cc79a3eac0c7d4 Mon Sep 17 00:00:00 2001
+From: Rishi <rishi_devan@mail.com>
+Date: Wed, 15 Jul 2020 13:51:00 +0200
+Subject: [PATCH] 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).
+---
+ Lib/tarfile.py                                    |   2 ++
+
+diff --git a/Lib/tarfile.py b/Lib/tarfile.py
+index e2b60532f6..6769066cab 100755
+--- a/Lib/tarfile.py
++++ b/Lib/tarfile.py
+@@ -1249,6 +1249,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]
+ 
+             # Normally, we could just use "utf-8" as the encoding and "strict"
diff --git a/pkgs/development/interpreters/python/cpython/2.7/default.nix b/pkgs/development/interpreters/python/cpython/2.7/default.nix
index 62aae7b22129..2cfaa69a4c8b 100644
--- a/pkgs/development/interpreters/python/cpython/2.7/default.nix
+++ b/pkgs/development/interpreters/python/cpython/2.7/default.nix
@@ -90,6 +90,9 @@ let
 
       # Backport from CPython 3.8 of a good list of tests to run for PGO.
       ./profile-task.patch
+
+      # Patch is likely to go away in the next release (if there is any)
+      ./CVE-2019-20907.patch
     ] ++ optionals (x11Support && stdenv.isDarwin) [
       ./use-correct-tcl-tk-on-darwin.patch
     ] ++ optionals stdenv.isLinux [