Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unknown command or malformed message should reply with reject to peer #102

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

akloboucnik
Copy link

If peer is unable to parse message for specific reasons it should not throw error but reply with a reject message.

I've stumble upon this in our code, we see exceptions like:

2018-05-11T11:47:34.663Z ERROR  <module> Uncaught exception: { stack:
   [ 'Error: Data still available after parsing',
     'at Object.checkFinished (/Users/adam/Work/blockcollider/bcnode/node_modules/bitcore-p2p/lib/messages/utils.js:20:13)',
     'at AddrMessage.setPayload (/Users/adam/Work/blockcollider/bcnode/node_modules/bitcore-p2p/lib/messages/commands/addr.js:48:9)',
     'at Function.exported.commands.(anonymous function).fromBuffer (/Users/adam/Work/blockcollider/bcnode/node_modules/bitcore-p2p/lib/messages/builder.js:75:15)',
     'at Messages._buildFromBuffer (/Users/adam/Work/blockcollider/bcnode/node_modules/bitcore-p2p/lib/messages/index.js:103:41)',
     'at Messages.parseBuffer (/Users/adam/Work/blockcollider/bcnode/node_modules/bitcore-p2p/lib/messages/index.js:74:15)',
     'at Peer._readMessage (/Users/adam/Work/blockcollider/bcnode/node_modules/bitcore-p2p/lib/peer.js:219:31)',
     'at Socket.<anonymous> (/Users/adam/Work/blockcollider/bcnode/node_modules/bitcore-p2p/lib/peer.js:167:10)',
     'at emitOne (events.js:116:13)',
     'at Socket.emit (events.js:211:7)',
     'at addChunk (_stream_readable.js:263:12)' ],
  message: 'Data still available after parsing' }

or

2018-05-11T11:01:30.571Z ERROR  <module> Uncaught exception: { stack:
   [ 'Error: Unsupported message command: encinit',
     'at Messages._buildFromBuffer (/Users/adam/Work/blockcollider/bcnode/node_modules/bitcore-p2p/lib/messages/index.js:101:11)',
     'at Messages.parseBuffer (/Users/adam/Work/blockcollider/bcnode/node_modules/bitcore-p2p/lib/messages/index.js:74:15)',
     'at Peer._readMessage (/Users/adam/Work/blockcollider/bcnode/node_modules/bitcore-p2p/lib/peer.js:219:31)',
     'at Socket.<anonymous> (/Users/adam/Work/blockcollider/bcnode/node_modules/bitcore-p2p/lib/peer.js:167:10)',
     'at emitOne (events.js:116:13)',
     'at Socket.emit (events.js:211:7)',
     'at addChunk (_stream_readable.js:263:12)',
     'at readableAddChunk (_stream_readable.js:250:11)',
     'at Socket.Readable.push (_stream_readable.js:208:10)',
     'at TCP.onread (net.js:594:20)' ],
  message: 'Unsupported message command: encinit' }

@coveralls
Copy link

coveralls commented May 14, 2018

Coverage Status

Coverage decreased (-0.09%) to 99.534% when pulling 5c56eb7 on akloboucnik:fix-unknown-message-or-malformed-payload into 10a2152 on bitpay:master.

@korczis
Copy link

korczis commented Jun 19, 2018

Hi @maraoz is there any plan to merge this? Or fix the issue mentioned by @akloboucnik ?

@akloboucnik
Copy link
Author

Hi @maraoz! Is there any chance of this getting merged?

@maraoz
Copy link
Contributor

maraoz commented Feb 15, 2019

I no longer have commit access to this repo, sorry!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants