Skip to content

Initialize Header::entry_type to EntryType::Regular #422

@e-nomem

Description

@e-nomem

When a header is initialized it currently sets all the underlying bytes to null. This happens to match the entry type AREGTYPE which is the 'legacy' regular file type. Any new/modern tar file should use entry type REGTYPE (b'0') instead though, which is supposed to be otherwise identical in every way.

This difference came up in maturin where some code paths were not explicitly setting the entry type and it uncovered a bug in the python standard library tarfile module that is triggered only for AREGTYPE entries. See PyO3/maturin#2855 and python/cpython#141707.

It seems to me that end users are most likely creating entries with the legacy type because of a failure to set the type explicitly rather than a conscious choice to use it.

Proposal: Initialize the headers to REGTYPE by default and expose AREGTYPE in the EntryType enum so that users that actually want that mode can explicitly set it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions