| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent f52bf62 commit cac9ca8
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1221,6 +1221,8 @@ def _proc_pax(self, tarfile): | |||
| 1221 | 1221 | ||
| 1222 | 1222 | length, keyword = match.groups() | |
| 1223 | 1223 | length = int(length) | |
| 1224 | + if length == 0: | ||
| 1225 | + raise InvalidHeaderError("invalid header") | ||
| 1224 | 1226 | value = buf[match.end(2) + 1:match.start(1) + length - 1] | |
| 1225 | 1227 | ||
| 1226 | 1228 | # Normally, we could just use "utf-8" as the encoding and "strict" | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -394,6 +394,13 @@ def test_premature_end_of_archive(self): | |||
| 394 | 394 | with self.assertRaisesRegex(tarfile.ReadError, "unexpected end of data"): | |
| 395 | 395 | tar.extractfile(t).read() | |
| 396 | 396 | ||
| 397 | + def test_length_zero_header(self): | ||
| 398 | + # bpo-39017 (CVE-2019-20907): reading a zero-length header should fail | ||
| 399 | + # with an exception | ||
| 400 | + with self.assertRaisesRegex(tarfile.ReadError, "file could not be opened successfully"): | ||
| 401 | + with tarfile.open(support.findfile('recursion.tar')) as tar: | ||
| 402 | + pass | ||
| 403 | + | ||
| 397 | 404 | class MiscReadTestBase(CommonReadTest): | |
| 398 | 405 | def requires_name_attribute(self): | |
| 399 | 406 | pass | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1 @@ | |||
| 1 | + Avoid infinite loop when reading specially crafted TAR files using the tarfile module (CVE-2019-20907). | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments