Skip to content

Commit

Permalink
Merge pull request #5665 from jsternberg/clear-mode-irregular
Browse files Browse the repository at this point in the history
contenthash: clear ModeIrregular before sending to archive/tar
  • Loading branch information
thompson-shaun authored Jan 16, 2025
2 parents f101ab5 + 45177da commit f55aa54
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions cache/contenthash/filehash.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ func NewFileHash(path string, fi os.FileInfo) (hash.Hash, error) {
}

func NewFromStat(stat *fstypes.Stat) (hash.Hash, error) {
// Clear the irregular file bit if this is some kind of special
// file. Pre-Go 1.23 behavior would only add the irregular file
// bit to regular files with non-handled reparse points.
// Current versions of Go now apply them to directories too.
// archive/tar.FileInfoHeader does not handle the irregular bit.
if stat.Mode&uint32(os.ModeType&^os.ModeIrregular) != 0 {
stat.Mode &^= uint32(os.ModeIrregular)
}

// Clear the socket bit since archive/tar.FileInfoHeader does not handle it
stat.Mode &^= uint32(os.ModeSocket)

Expand Down

0 comments on commit f55aa54

Please sign in to comment.