simplify code

Co-authored-by: Andrew Murray <3112309+radarhere@users.noreply.github.com>
This commit is contained in:
Ondrej Baranovič 2022-11-04 07:31:00 +01:00 committed by GitHub
parent c10c6bf894
commit 8947cbf4d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -480,8 +480,8 @@ def extract_dep(url, filename):
zf.extractall(sources_dir)
elif filename.endswith(".tar.gz") or filename.endswith(".tgz"):
with tarfile.open(file, "r:gz") as tgz:
for member in tgz.getmembers():
member_abspath = os.path.abspath(os.path.join(sources_dir, member.name))
for member in tgz.getnames():
member_abspath = os.path.abspath(os.path.join(sources_dir, member))
member_prefix = os.path.commonpath([sources_dir_abs, member_abspath])
if sources_dir_abs != member_prefix:
raise RuntimeError("Attempted Path Traversal in Tar File")