Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid nil ptr panic in GetAttr() #300

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions fuse/pathfs/pathfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -603,17 +603,15 @@ func (n *pathInode) GetAttr(out *fuse.Attr, file nodefs.File, context *fuse.Cont
}
// If we don't have an open file, or fstat on it failed due to an internal
// error, stat by path.
if file == nil || code == fuse.ENOSYS || code == fuse.EBADF {
fi, code = n.fs.GetAttr(n.GetPath(), context)
if !code.Ok() {
return code
}
// This is a bug in the filesystem implementation, but let's not
// crash.
if fi == nil {
log.Printf("Bug: fs.GetAttr returned OK with nil data")
return fuse.EINVAL
}
fi, code = n.fs.GetAttr(n.GetPath(), context)
if !code.Ok() {
return code
}
// This is a bug in the filesystem implementation, but let's not
// crash.
if fi == nil {
log.Printf("Bug: fs.GetAttr returned OK with nil data")
return fuse.EINVAL
}
// Set inode number (unless already set or disabled).
n.setClientInode(fi.Ino)
Expand Down