Permalink
Browse files

Handle boundary conditions too.

  • Loading branch information...
1 parent cc1f1f2 commit 9eb1955afe122098d9ba916bb05b6e2e415a015c @hanwen committed Feb 19, 2013
Showing with 4 additions and 1 deletion.
  1. +4 −1 fs/android.go
View
@@ -80,11 +80,14 @@ type androidFile struct {
}
func (f *androidFile) Read(dest []byte, off int64) (fuse.ReadResult, fuse.Status) {
- if off > f.node.Size {
+ if off >= f.node.Size {
// ENXIO = no such address.
return nil, fuse.Status(int(syscall.ENXIO))
}
+ if off+int64(len(dest)) > f.node.Size {
+ dest = dest[:f.node.Size-off]
+ }
b := bytes.NewBuffer(dest[:0])
err := f.node.fs.dev.AndroidGetPartialObject64(f.node.Handle(), b, off, uint32(len(dest)))
if err != nil {

0 comments on commit 9eb1955

Please sign in to comment.