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

Files of type Symlink are not written correctly #15

Open
antoineco opened this issue Sep 29, 2023 · 0 comments · May be fixed by #18
Open

Files of type Symlink are not written correctly #15

antoineco opened this issue Sep 29, 2023 · 0 comments · May be fixed by #18

Comments

@antoineco
Copy link

The library is able to deserialize Header structs from Symlink files:

cpio/svr4.go

Lines 90 to 101 in b4d3577

// read link name
if hdr.Mode&^ModePerm == ModeSymlink {
if hdr.Size < 1 || hdr.Size > svr4MaxNameSize {
return nil, ErrHeader
}
b := make([]byte, hdr.Size)
if _, err := io.ReadFull(r, b); err != nil {
return nil, err
}
hdr.Linkname = string(b)
hdr.Size = 0
}

However, it completely ignores the Linkname attribute while writing the header, resulting in zero-sized files without target.

Note that using writer.Write(target) as a workaround isn't an option because the method isn't supported for files other than Regular:

cpio/writer.go

Lines 103 to 105 in b4d3577

// Calling Write on special types like TypeLink, TypeSymlink, TypeChar,
// TypeBlock, TypeDir, and TypeFifo returns (0, ErrWriteTooLong) regardless of
// what the Header.Size claims.

@antoineco antoineco linked a pull request Oct 30, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant