From e05fb77d336cbd335fd07ab1b53ee83857389761 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Wed, 25 Jan 2017 13:57:42 -0800 Subject: [PATCH] socks: more checks for tor resolve. --- lib/net/socks.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/net/socks.js b/lib/net/socks.js index f1e02008..36873ed8 100644 --- a/lib/net/socks.js +++ b/lib/net/socks.js @@ -497,8 +497,12 @@ SOCKS.prototype.handleResolve = function handleResolve(data) { return; } - this.state = SOCKS.states.RESOLVE_DONE; + if (addr.type === 0x03) { + this.error('Bad address type for tor resolve.'); + return; + } + this.state = SOCKS.states.RESOLVE_DONE; this.destroy(); this.emit('resolve', [addr.host]); @@ -697,7 +701,11 @@ function parseAddr(data, offset) { throw new Error('Unknown SOCKS address type: ' + type + '.'); } - return { host: host, port: port }; + return { + type: type, + host: host, + port: port + }; } /*