From: Matt Joiner Date: Thu, 21 Aug 2014 17:42:00 +0000 (+1000) Subject: Fix crash in metadata requests beyond available info bytes X-Git-Tag: v1.0.0~1624 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=00a4e9bc1180cb8756ca5ac8689780b7e7261412;p=btrtrc.git Fix crash in metadata requests beyond available info bytes --- diff --git a/torrent.go b/torrent.go index 7257bb30..178f29ae 100644 --- a/torrent.go +++ b/torrent.go @@ -91,7 +91,11 @@ func (t *torrent) MetadataPieceCount() int { } func (t *torrent) HaveMetadataPiece(piece int) bool { - return t.haveInfo() || t.metadataHave[piece] + if t.haveInfo() { + return (1<<14)*piece < len(t.MetaData) + } else { + return t.metadataHave[piece] + } } func (t *torrent) metadataSizeKnown() bool {