diff --git a/pkg/rpm/cpio2tar.go b/pkg/rpm/cpio2tar.go index d9a3035..00b25b1 100644 --- a/pkg/rpm/cpio2tar.go +++ b/pkg/rpm/cpio2tar.go @@ -99,6 +99,7 @@ func Tar(rs io.Reader, tarfile *tar.Writer, noSymlinksAndDirs bool, capabilities continue } tarHeader.Typeflag = tar.TypeSymlink + tarHeader.Size = 0 buf, err := ioutil.ReadAll(entry.Payload) if err != nil { return err @@ -107,6 +108,7 @@ func Tar(rs io.Reader, tarfile *tar.Writer, noSymlinksAndDirs bool, capabilities case cpio.S_ISREG: if entry.Header.Nlink() > 1 && entry.Header.Filesize() == 0 { tarHeader.Typeflag = tar.TypeLink + tarHeader.Size = 0 hardLinks[entry.Header.Ino()] = append(hardLinks[entry.Header.Ino()], tarHeader) continue } diff --git a/pkg/rpm/tar.go b/pkg/rpm/tar.go index 1157cab..b40df43 100644 --- a/pkg/rpm/tar.go +++ b/pkg/rpm/tar.go @@ -208,6 +208,7 @@ func CPIOToTarHeader(entry *cpio.CpioEntry) (*tar.Header, error) { tarHeader.Typeflag = tar.TypeFifo case cpio.S_ISLNK: tarHeader.Typeflag = tar.TypeSymlink + tarHeader.Size = 0 buf, err := ioutil.ReadAll(entry.Payload) if err != nil { return nil, err @@ -218,6 +219,7 @@ func CPIOToTarHeader(entry *cpio.CpioEntry) (*tar.Header, error) { tarHeader.Typeflag = tar.TypeLink } tarHeader.Typeflag = tar.TypeReg + tarHeader.Size = 0 default: return nil, fmt.Errorf("unknown file mode 0%o for %s", entry.Header.Mode(), entry.Header.Filename()) diff --git a/pkg/rpm/tar_test.go b/pkg/rpm/tar_test.go index d4fa5e0..815ce18 100644 --- a/pkg/rpm/tar_test.go +++ b/pkg/rpm/tar_test.go @@ -28,7 +28,7 @@ func TestRPMToTar(t *testing.T) { expectedHeaders: []*tar.Header{ {Name: "./etc/libvirt/libvirt-admin.conf", Size: 450, Mode: 33188}, {Name: "./etc/libvirt/libvirt.conf", Size: 547, Mode: 33188}, - {Name: "./usr/lib64/libvirt.so.0", Size: 19, Mode: 41471}, + {Name: "./usr/lib64/libvirt.so.0", Size: 0, Mode: 41471}, }, prefix: "", stripPrefix: false,