Skip to content

Commit

Permalink
fix server crash on invalid message length
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandre tiertant committed Sep 25, 2020
1 parent 1dfafbc commit bfe7d44
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 0 additions & 1 deletion lib/methods/send.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ send.prototype.send = function(msg) {

msg.allocation.sockets[0].send(data, dst.port, dst.address, function(err) {
if (err) {
throw new Error(JSON.stringify(dst));
return msg.debug('ERROR', err);
}
msg.debug('TRACE', 'relaying data from transactionID ' + msg.transactionID + ' to ' + dst);
Expand Down
8 changes: 6 additions & 2 deletions lib/network.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,12 @@ network.prototype.start = function() {
const src = new Address(rinfo.address, rinfo.port);
const transport = new Transport(CONSTANTS.TRANSPORT.PROTOCOL.UDP, src, dst, udpSocket);
var msg = new Message(self.server, transport);
if (msg.read(udpMessage)) {
self.server.emit('message', msg);
try {
if (msg.read(udpMessage)) {
self.server.emit('message', msg);
}
} catch(err) {
self.debug('ERROR', err);
}
});

Expand Down

0 comments on commit bfe7d44

Please sign in to comment.