Skip to content

Files of type Symlink are not written correctly #15

@antoineco

Description

@antoineco

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions