We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see ourdocumentation.
There was an error while loading.Please reload this page.
1 parentd36d53c commit14038a1Copy full SHA for 14038a1
internal/fusefrontend/file.go
@@ -91,11 +91,20 @@ func (f *file) SetInode(n *nodefs.Inode) {
91
// readFileID loads the file header from disk and extracts the file ID.
92
// Returns io.EOF if the file is empty.
93
func (f*file)readFileID() ([]byte,error) {
94
-buf:=make([]byte,contentenc.HeaderLen)
95
-_,err:=f.fd.ReadAt(buf,0)
+// We read +1 byte to determine if the file has actual content
+// and not only the header. A header-only file will be considered empty.
96
+// This makes File ID poisoning more difficult.
97
+readLen:=contentenc.HeaderLen+1
98
+buf:=make([]byte,readLen)
99
+n,err:=f.fd.ReadAt(buf,0)
100
iferr!=nil {
101
+iferr==io.EOF&&n!=0 {
102
+tlog.Warn.Printf("ino%d: readFileID: incomplete file, got %d instead of %d bytes",
103
+f.devIno.ino,n,readLen)
104
+}
105
returnnil,err
106
}
107
+buf=buf[:contentenc.HeaderLen]
108
h,err:=contentenc.ParseHeader(buf)
109
110