fixed a bug that occurs when rLength is smaller than two (in fetcher)

This commit is contained in:
Bora Alper 2017-11-05 01:47:40 +00:00
parent ae691ada79
commit 3a399b056e

View File

@ -150,7 +150,15 @@ func (ms *MetadataSink) awaitMetadata(infoHash metainfo.Hash, peer Peer) {
) )
return return
} }
// The messages we are interested in have the length of AT LEAST two bytes
// (TODO: actually a bit more than that but SURELY when it's less than two bytes, the
// program panics)
rLength := bigEndianToInt(rLengthB) rLength := bigEndianToInt(rLengthB)
if rLength < 2 {
continue
}
rMessage, err := readExactly(conn, rLength) rMessage, err := readExactly(conn, rLength)
if err != nil { if err != nil {
zap.L().Debug( zap.L().Debug(