Fix bug where left = 0 would be converted to Infinity

Possibly fixes: https://github.com/feross/bittorrent-tracker/issues/196
This commit is contained in:
Feross Aboukhadijeh 2017-02-02 17:24:40 -08:00
parent 27ae148167
commit c2c8e36af7

View File

@ -28,7 +28,9 @@ function parseWebSocketRequest (socket, opts, params) {
params.to_peer_id = common.binaryToHex(params.to_peer_id) params.to_peer_id = common.binaryToHex(params.to_peer_id)
} }
params.left = Number(params.left) || Infinity params.left = Number(params.left)
if (Number.isNaN(params.left)) params.left = Infinity
params.numwant = Math.min( params.numwant = Math.min(
Number(params.offers && params.offers.length) || 0, // no default - explicit only Number(params.offers && params.offers.length) || 0, // no default - explicit only
common.MAX_ANNOUNCE_PEERS common.MAX_ANNOUNCE_PEERS