torrentfs: Reading an offset past the end of a file caused out of bounds panic

This commit is contained in:
Matt Joiner 2014-06-26 01:36:25 +10:00
parent e7cb8a138b
commit c509f0b1ea
1 changed files with 2 additions and 2 deletions

View File

@ -56,8 +56,8 @@ func (fn fileNode) Read(req *fuse.ReadRequest, resp *fuse.ReadResponse, intr fus
if int64(fn.size)-req.Offset < int64(size) {
size = int(int64(fn.size) - req.Offset)
}
if size == 0 {
return nil
if size < 0 {
size = 0
}
infoHash := torrent.BytesInfoHash(fn.metaInfo.InfoHash)
torrentOff := fn.TorrentOffset + req.Offset