mirror of
https://github.com/lowRISC/ibex.git
synced 2025-04-22 21:07:34 -04:00
Merge 792f6a96e4
into 594ea976c9
This commit is contained in:
commit
9416616d4f
1 changed files with 20 additions and 1 deletions
21
vendor/lowrisc_ip/util/dvsim/LsfLauncher.py
vendored
21
vendor/lowrisc_ip/util/dvsim/LsfLauncher.py
vendored
|
@ -54,7 +54,26 @@ class LsfLauncher(Launcher):
|
|||
log.info("[prepare_workspace]: [pyvenv]: Extracting %s",
|
||||
Launcher.pyvenv)
|
||||
with tarfile.open(Launcher.pyvenv, mode='r') as tar:
|
||||
tar.extractall(args.scratch_root)
|
||||
def is_within_directory(directory, target):
|
||||
|
||||
abs_directory = os.path.abspath(directory)
|
||||
abs_target = os.path.abspath(target)
|
||||
|
||||
prefix = os.path.commonprefix([abs_directory, abs_target])
|
||||
|
||||
return prefix == abs_directory
|
||||
|
||||
def safe_extract(tar, path=".", members=None, *, numeric_owner=False):
|
||||
|
||||
for member in tar.getmembers():
|
||||
member_path = os.path.join(path, member.name)
|
||||
if not is_within_directory(path, member_path):
|
||||
raise Exception("Attempted Path Traversal in Tar File")
|
||||
|
||||
tar.extractall(path, members, numeric_owner=numeric_owner)
|
||||
|
||||
|
||||
safe_extract(tar, args.scratch_root)
|
||||
log.info("[prepare_workspace]: [pyvenv]: Done: %s", path)
|
||||
Launcher.pyvenv = path
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue