Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

header: set entry_size() to 0 for hardlinks #314

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Commits on Mar 29, 2023

  1. header: set entry_size() to 0 for hardlinks

    Fix the error: "numeric field was not a number: t 'Regard' when getting cksum for
    'a text ...'. The error is caused by wrongly setting the `self.next`
    position due to accounting harlinks size.
    
    According to man 5 tar, the size of the hard-links should be set to 0.
    
    size    Size of file, as octal number in ASCII.  For regular files	only,
            this indicates the	amount of data that follows the	header.	 In
            particular, this field was	ignored	by early tar implementations
            when extracting hardlinks.	 Modern	writers	should always store a
            zero length for hardlink entries.
    
    But since the writer wasn't *modern*, the entry_size is 64700 which
    causes miscalculation of the `self.next`.
    
    [tar-rs/src/archive.rs:372] &entry.header() = UstarHeader {
        entry_size: 64700,
        size: 64700,
        path: "some/path",
        link_name: Some(
            "some/link",
        ),
        mode: 0o640,
        uid: 1058,
        gid: 1061,
        mtime: 1673424346,
        username: Some(
            "example",
        ),
        groupname: Some(
            "example",
        ),
        device_major: Some(
            9,
        ),
        device_minor: Some(
            2,
        ),
        cksum: 24700,
        cksum_valid: true,
    }
    [tar-rs/src/archive.rs:373] entry.header().entry_type() = Link
    
    Closes: alexcrichton#313
    
    Signed-off-by: Nikola Pajkovsky <nikola@enhance.com>
    Nikola Pajkovsky committed Mar 29, 2023
    Configuration menu
    Copy the full SHA
    bcf09e0 View commit details
    Browse the repository at this point in the history