Commit bc17f6b7 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

fuse/nodefs: be resilient against bogus offset in readdir(plus).

parent 0d6f57fc
...@@ -27,6 +27,11 @@ func (d *connectorDir) ReadDir(input *fuse.ReadIn, out *fuse.DirEntryList) (code ...@@ -27,6 +27,11 @@ func (d *connectorDir) ReadDir(input *fuse.ReadIn, out *fuse.DirEntryList) (code
} }
} }
if input.Offset > uint64(len(d.stream)) {
// This shouldn't happen, but let's not crash.
return fuse.EINVAL
}
todo := d.stream[input.Offset:] todo := d.stream[input.Offset:]
for _, e := range todo { for _, e := range todo {
if e.Name == "" { if e.Name == "" {
...@@ -70,6 +75,10 @@ func (d *connectorDir) ReadDirPlus(input *fuse.ReadIn, out *fuse.DirEntryList) ( ...@@ -70,6 +75,10 @@ func (d *connectorDir) ReadDirPlus(input *fuse.ReadIn, out *fuse.DirEntryList) (
} }
} }
if input.Offset > uint64(len(d.stream)) {
// This shouldn't happen, but let's not crash.
return fuse.EINVAL
}
todo := d.stream[input.Offset:] todo := d.stream[input.Offset:]
for i, e := range todo { for i, e := range todo {
if e.Name == "" { if e.Name == "" {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment