Skip to content

Commit f55aa54

Browse files
Merge pull request moby#5665 from jsternberg/clear-mode-irregular
contenthash: clear ModeIrregular before sending to archive/tar
2 parents f101ab5 + 45177da commit f55aa54

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

cache/contenthash/filehash.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,15 @@ func NewFileHash(path string, fi os.FileInfo) (hash.Hash, error) {
4141
}
4242

4343
func NewFromStat(stat *fstypes.Stat) (hash.Hash, error) {
44+
// Clear the irregular file bit if this is some kind of special
45+
// file. Pre-Go 1.23 behavior would only add the irregular file
46+
// bit to regular files with non-handled reparse points.
47+
// Current versions of Go now apply them to directories too.
48+
// archive/tar.FileInfoHeader does not handle the irregular bit.
49+
if stat.Mode&uint32(os.ModeType&^os.ModeIrregular) != 0 {
50+
stat.Mode &^= uint32(os.ModeIrregular)
51+
}
52+
4453
// Clear the socket bit since archive/tar.FileInfoHeader does not handle it
4554
stat.Mode &^= uint32(os.ModeSocket)
4655

0 commit comments

Comments
 (0)