bitpay / bitcore-p2p

Interface to the bitcoin P2P network for bitcore
MIT License
81 stars 275 forks source link

Handle malformed p2p messages #86

Open braydonf opened 8 years ago

braydonf commented 8 years ago

When parsing the buffer, the message itself may be malformed and unable to parse correctly, which will typically throw an error (as so it's clear why it's failing).

A try/catch around https://github.com/bitpay/bitcore-p2p/blob/master/lib/messages/index.js#L103 and sending back a reject message (https://en.bitcoin.it/wiki/Protocol_documentation#reject) to the peer with REJECT_MALFORMED, could be the best way to handle this case.

Related: https://github.com/bitpay/bitcore-p2p/issues/85

Fi3 commented 8 years ago

I have fix this this issue but I don't know how make a new pull request. I have done a repo on my account with this issue fixed (maybe :) ) https://github.com/Fi3/bitcore-p2p. I have try to follow your contibuting guideline. If you think that could be good add my code to your repo feel free to merge my branch.