diff options
author | Ruben Bridgewater <ruben@bridgewater.de> | 2019-03-18 19:35:59 +0100 |
---|---|---|
committer | Ruben Bridgewater <ruben@bridgewater.de> | 2019-03-25 16:13:33 +0100 |
commit | 96204c3c71f6cc571be56269ba9d584d615f0a06 (patch) | |
tree | c94b0df91cfb30602486ebd288d14aef57a2d021 /test | |
parent | bdea725bdcb299579547f66ebcc98af16f53cd16 (diff) | |
download | android-node-v8-96204c3c71f6cc571be56269ba9d584d615f0a06.tar.gz android-node-v8-96204c3c71f6cc571be56269ba9d584d615f0a06.tar.bz2 android-node-v8-96204c3c71f6cc571be56269ba9d584d615f0a06.zip |
net: do not manipulate potential user code
The error provided in this function could come from user code. Thus
the error should not be manipulated in any way. The added properties
do not seem to provide any actual value either as can not be part
of the error. The `hostname` is already set on the error and adding
the `host` property with the identical value does not seem right in
this case.
PR-URL: https://github.com/nodejs/node/pull/26751
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/parallel/test-net-better-error-messages-port-hostname.js | 10 | ||||
-rw-r--r-- | test/parallel/test-net-connect-immediate-finish.js | 16 |
2 files changed, 13 insertions, 13 deletions
diff --git a/test/parallel/test-net-better-error-messages-port-hostname.js b/test/parallel/test-net-better-error-messages-port-hostname.js index 1a8aa770b4..f8e997db33 100644 --- a/test/parallel/test-net-better-error-messages-port-hostname.js +++ b/test/parallel/test-net-better-error-messages-port-hostname.js @@ -6,7 +6,6 @@ const common = require('../common'); const net = require('net'); -const assert = require('assert'); const { addresses } = require('../common/internet'); const { @@ -23,8 +22,9 @@ const c = net.createConnection({ c.on('connect', common.mustNotCall()); -c.on('error', common.mustCall(function(e) { - assert.strictEqual(e.code, mockedErrorCode); - assert.strictEqual(e.port, 0); - assert.strictEqual(e.hostname, addresses.INVALID_HOST); +c.on('error', common.expectsError({ + code: mockedErrorCode, + hostname: addresses.INVALID_HOST, + port: undefined, + host: undefined })); diff --git a/test/parallel/test-net-connect-immediate-finish.js b/test/parallel/test-net-connect-immediate-finish.js index 29256ceb8d..cb430a5a8c 100644 --- a/test/parallel/test-net-connect-immediate-finish.js +++ b/test/parallel/test-net-connect-immediate-finish.js @@ -26,7 +26,6 @@ // 'connect' and defer the handling until the 'connect' event is handled. const common = require('../common'); -const assert = require('assert'); const net = require('net'); const { addresses } = require('../common/internet'); @@ -42,13 +41,14 @@ const client = net.connect({ lookup: common.mustCall(errorLookupMock()) }, common.mustNotCall()); -client.once('error', common.mustCall((err) => { - assert(err); - assert.strictEqual(err.code, err.errno); - assert.strictEqual(err.code, mockedErrorCode); - assert.strictEqual(err.host, err.hostname); - assert.strictEqual(err.host, addresses.INVALID_HOST); - assert.strictEqual(err.syscall, mockedSysCall); +client.once('error', common.expectsError({ + code: mockedErrorCode, + errno: mockedErrorCode, + syscall: mockedSysCall, + hostname: addresses.INVALID_HOST, + message: 'getaddrinfo ENOTFOUND something.invalid', + port: undefined, + host: undefined })); client.end(); |