Skip to content

Commit

Permalink
fix(cpio): Fix dupplicated CPIO entries by overwriting them.
Browse files Browse the repository at this point in the history
  • Loading branch information
nyuware committed Mar 21, 2024
1 parent 29b6636 commit 52af630
Show file tree
Hide file tree
Showing 43 changed files with 52 additions and 1 deletion.
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
2 changes: 1 addition & 1 deletion unblob/file_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ def open( # noqa: A003

def unlink(self, path):
"""Delete file within extraction path."""
logger.debug("unlink file", file_path=path)
logger.debug("unlink file", file_path=path, _verbosity=3)
safe_path = self._get_extraction_path(path, "unlink")

safe_path.unlink(missing_ok=True)
2 changes: 2 additions & 0 deletions unblob/handlers/archive/cpio.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ def dump_entries(self, fs: FileSystem):
continue

if stat.S_ISREG(entry.mode):
fs.unlink(entry.path)
fs.carve(entry.path, self.file, entry.start_offset, entry.size)
elif stat.S_ISDIR(entry.mode):
fs.mkdir(
Expand All @@ -222,6 +223,7 @@ def dump_entries(self, fs: FileSystem):
self.file[entry.start_offset : entry.start_offset + entry.size]
).decode("utf-8")
)
fs.unlink(entry.path)
fs.create_symlink(src=link_path, dst=entry.path)
elif (
stat.S_ISCHR(entry.mode)
Expand Down

0 comments on commit 52af630

Please sign in to comment.