at 23.05-pre 888 B view raw
1From 5a8d121a1f3ef5ad7c105ee378cc79a3eac0c7d4 Mon Sep 17 00:00:00 2001 2From: Rishi <rishi_devan@mail.com> 3Date: Wed, 15 Jul 2020 13:51:00 +0200 4Subject: [PATCH] bpo-39017: Avoid infinite loop in the tarfile module 5 (GH-21454) 6 7Avoid infinite loop when reading specially crafted TAR files using the tarfile module 8(CVE-2019-20907). 9--- 10 Lib/tarfile.py | 2 ++ 11 12diff --git a/Lib/tarfile.py b/Lib/tarfile.py 13index e2b60532f6..6769066cab 100755 14--- a/Lib/tarfile.py 15+++ b/Lib/tarfile.py 16@@ -1249,6 +1249,8 @@ class TarInfo(object): 17 18 length, keyword = match.groups() 19 length = int(length) 20+ if length == 0: 21+ raise InvalidHeaderError("invalid header") 22 value = buf[match.end(2) + 1:match.start(1) + length - 1] 23 24 # Normally, we could just use "utf-8" as the encoding and "strict"