8000 gh-121285: Remove backtracking when parsing tarfile headers by sethmlarson · Pull Request #121286 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-121285: Remove backtracking when parsing tarfile headers #121286

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Aug 31, 2024
Merged
Prev Previous commit
Next Next commit
match up to 20 digits in _proc_gnusparse_00
this is used as an offset/length value, it doesn't need to be longer.  the \d+ prefix on the lines is not treated as an int so it's length bound is not important.
  • Loading branch information
gpshead authored Jul 3, 2024
commit 9a6cc59f6ddbeac7fc5de8b84e40dc8ccb58230e
2 changes: 1 addition & 1 deletion Lib/tarfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -1528,7 +1528,7 @@ def _proc_gnusparse_00(self, next, pax_headers, buf):
"""
def finditer_without_backtracking(buf, needle):
values = []
regex = re.compile(br"^\d{1,20}%s(\d+)\n" % (needle,))
regex = re.compile(br"^\d+%s(\d{1,20})\n" % (needle,))
while True:
if (
# Statement is both a contains check (!=-1) and a bounds check (>0)
Expand Down
Loading
0