Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "pycpio"
version = "1.5.4"
version = "1.5.5"

authors = [
{ name="Desultory", email="[email protected]" },
Expand Down
6 changes: 6 additions & 0 deletions src/pycpio/header/cpioheader.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ def __setattr__(self, key, value):
If the filesize changes, log a warning.

Check the mode and set the mode_type and permissions attributes accordingly.
Check that the inode is < 0xFFFFFFFF, if not, set to 0 and log a warning.
When used in an archive, the inode will be set to a unique value.
If setting the name, add a null byte to the end and set the namesize attribute.
"""
if key in ["uid", "gid"] and not isinstance(value, bytes):
Expand Down Expand Up @@ -97,6 +99,10 @@ def __setattr__(self, key, value):
elif key == "filesize" and value == b"00000000":
if getattr(self, "filesize", b"00000000") != b"00000000":
self.logger.warning("[%s] Setting filesize to 0" % self.name)
elif key == "ino":
if int(value, 16) > 0xFFFFFFFF:
self.logger.warning("Inode too large, setting to 0: %s" % value)
value = b"00000000"

super().__setattr__(key, value)

Expand Down
7 changes: 7 additions & 0 deletions tests/test_cpio.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from pycpio import PyCPIO
from pycpio.header import CPIOHeader
from pycpio.cpio import CPIOData
from zenlib.logging import loggify

from cpio_test_headers import newc_test_headers, build_newc_header
Expand Down Expand Up @@ -145,5 +146,11 @@ def test_invalid_symlink_target(self):
test_symlink.symlink_to('/a/totally/nonexistent/path')
self.cpio.append_recursive(self.workdir.name)

def test_large_inode(self):
""" Tests handling of inode numbers larger than 0xFFFFFFFF """
entry = CPIOData.create_entry('large_inode_test', inode=0x1FFFFFFFF, logger=self.logger)
# Should be reset to 0
self.assertEqual(entry.header.ino, b'00000000')

if __name__ == '__main__':
main()