From: Matt Joiner Date: Wed, 25 Jun 2014 15:36:25 +0000 (+1000) Subject: torrentfs: Reading an offset past the end of a file caused out of bounds panic X-Git-Tag: v1.0.0~1711 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=c509f0b1eae93948111797a467ca3b5e6fac9c31;p=btrtrc.git torrentfs: Reading an offset past the end of a file caused out of bounds panic --- diff --git a/fs/torrentfs.go b/fs/torrentfs.go index 7a00f288..eb6c43f9 100644 --- a/fs/torrentfs.go +++ b/fs/torrentfs.go @@ -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