mafintosh / dns-discovery

Discovery peers in a distributed system using regular dns and multicast dns.
MIT License
193 stars 18 forks source link

TypeError: "value" argument is out of bounds #4

Closed pfrazee closed 8 years ago

pfrazee commented 8 years ago

This exception occurred after I left Beaker open for a while, and was afk.

Uncaught Exception:
TypeError: "value" argument is out of bounds
    at checkInt (buffer.js:1028:11)
    at Buffer.writeUInt16BE (buffer.js:1097:5)
    at Object.header.encode (/Users/paulfrazee/my/beaker-plugin-dat/node_modules/dns-packet/index.js:107:7)
    at Object.exports.encode (/Users/paulfrazee/my/beaker-plugin-dat/node_modules/dns-packet/index.js:529:10)
    at DNS.query (/Users/paulfrazee/my/beaker-plugin-dat/node_modules/dns-socket/index.js:194:23)
    at DNSDiscovery._send (/Users/paulfrazee/my/beaker-plugin-dat/node_modules/dns-discovery/index.js:349:15)
    at DNSDiscovery._visit (/Users/paulfrazee/my/beaker-plugin-dat/node_modules/dns-discovery/index.js:378:33)
    at DNSDiscovery.announce (/Users/paulfrazee/my/beaker-plugin-dat/node_modules/dns-discovery/index.js:357:8)
    at Timeout.dns [as _onTimeout] (/Users/paulfrazee/my/beaker-plugin-dat/node_modules/discovery-channel/index.js:115:30)
    at tryOnTimeout (timers.js:224:11)
pfrazee commented 8 years ago

It looks like the id counter is overflowing 65535. I think this line is the culprit. It's meant to protect against the overflow, but it's checking this.id instead of this._id. I'll submit a PR after I finish a call.

mafintosh commented 8 years ago

Very nice find!! I fixed it in dns-socket 1.4.2 and force bumped the dependency here in 5.3.5