Skip to content

Commit 4453ce5

Browse files
fix _decompress security problem (#61294)
1 parent 495c991 commit 4453ce5

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

python/paddle/utils/download.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,10 @@ def _decompress(fname):
313313

314314
def _uncompress_file_zip(filepath):
315315
with zipfile.ZipFile(filepath, 'r') as files:
316-
file_list = files.namelist()
316+
file_list_tmp = files.namelist()
317+
file_list = []
318+
for file in file_list_tmp:
319+
file_list.append(file.replace("../", ""))
317320

318321
file_dir = os.path.dirname(filepath)
319322

@@ -342,7 +345,10 @@ def _uncompress_file_zip(filepath):
342345

343346
def _uncompress_file_tar(filepath, mode="r:*"):
344347
with tarfile.open(filepath, mode) as files:
345-
file_list = files.getnames()
348+
file_list_tmp = files.getnames()
349+
file_list = []
350+
for file in file_list_tmp:
351+
file_list.append(file.replace("../", ""))
346352

347353
file_dir = os.path.dirname(filepath)
348354

0 commit comments

Comments
 (0)