Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit14038a1

Browse files
committed
fusefrontend: readFileID: reject files that consist only of a header
A header-only file will be considered empty (this is not supposed to happen).This makes File ID poisoning more difficult.
1 parentd36d53c commit14038a1

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

‎internal/fusefrontend/file.go‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,20 @@ func (f *file) SetInode(n *nodefs.Inode) {
9191
// readFileID loads the file header from disk and extracts the file ID.
9292
// Returns io.EOF if the file is empty.
9393
func (f*file)readFileID() ([]byte,error) {
94-
buf:=make([]byte,contentenc.HeaderLen)
95-
_,err:=f.fd.ReadAt(buf,0)
94+
// We read +1 byte to determine if the file has actual content
95+
// 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)
96100
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+
}
97105
returnnil,err
98106
}
107+
buf=buf[:contentenc.HeaderLen]
99108
h,err:=contentenc.ParseHeader(buf)
100109
iferr!=nil {
101110
returnnil,err

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp