Merge pull request #2 from rapperskull/patch-1

Fix extraction with "." or ".." entries
This commit is contained in:
jakoblell 2022-05-30 09:45:13 +02:00 committed by GitHub
commit 5ceb668e8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

View File

@ -521,15 +521,15 @@ class DirInode(Inode):
for dirent in self.dirents:
out_path = os.path.join(output_dir, dirent.filename)
print("Extracting %r" % out_path.decode())
# Some versions of mkfs.erofs add entries for "." and ".."
if dirent.filename in (b'.', b'..'):
continue
if os.path.exists(out_path):
raise ValueError("Duplicate file %r" % out_path)
child_inode = self.erofs.get_inode(dirent.nid, dirent.file_type)
if dirent.file_type == FileType.EROFS_FT_SYMLINK:
os.symlink(child_inode.get_symlink_dest(), out_path)
elif dirent.file_type == FileType.EROFS_FT_DIR:
# Some versions of mkfs.erofs add entries for "." and ".."
if dirent.filename in (b'.', b'..'):
continue
os.mkdir(out_path)
# Always make directories mode 755
os.chmod(out_path, 0o755)