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).
diff --git a/Lib/tarfile.py b/Lib/tarfile.py
index e2b6053..6769066 100755
--- a/Lib/tarfile.py
+++ b/Lib/tarfile.py
@@ -1249,6 +1249,8 @@
 
             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"