net: fix abort on bad address input#13726
Conversation
lib/net.js
Outdated
There was a problem hiding this comment.
because this is introducing a new error, it should use internal/errors
|
Defensively marking as semver-major due to the new throw. Am argument could be made for patch tho because it would abort previously |
|
@jasnell I’m surprised … we tag error changes as semver-major because we know people might rely non-throwing behaviour, or existing errors and their messages, but I find it hard to believe people actively rely on processes aborting? |
|
It's not likely at all. As I said, an argument can be made that it's a patch, just need to make sure folks agree |
|
I agree that it is very unlikely that anyone would rely on that. It's actually already rare to trigger this in the first place and I think it would be good to backport this, if it's accepted as semver-patch. |
lib/net.js
Outdated
|
|
||
| var err; | ||
|
|
||
| if (typeof address !== 'string') { |
There was a problem hiding this comment.
Can we move this to .connect() instead, under the if (pipe) check? internalConnect() is also called for non-pipe connections and so it would be an unnecessary/redundant check in those cases (since the address would be validated at time of lookup() there).
refack
left a comment
There was a problem hiding this comment.
Error messages need assertion
lib/internal/errors.js
Outdated
There was a problem hiding this comment.
This makes this a semver-major. Is it worth it?
There was a problem hiding this comment.
Re: asserting error messages, Could you use expectsError
|
3 tests fail 917 parallel/test-process-cpuUsage
duration_ms 0.58
severity fail
stack |-
assert.js:60
throw new errors.AssertionError({
^
AssertionError [ERR_ASSERTION]: 'The "preValue.user" property must be of type Number' === 'The "preValue.user" argument must be of type Number'
at Object.<anonymous> (/data/iojs/build/workspace/node-test-commit-linuxone/nodes/rhel72-s390x/test/common/index.js:703:14)
at expectedException (assert.js:520:19)
at _throws (assert.js:568:8)
at Function.throws (assert.js:577:3)
at Object.<anonymous> (/data/iojs/build/workspace/node-test-commit-linuxone/nodes/rhel72-s390x/test/parallel/test-process-cpuUsage.js:48:8)
at Module._compile (module.js:569:30)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3) |
|
I see 3 CTC approvals, but still think it would be nice to have this as |
|
There's no -0.1 from me at all. I marked it as a semver-major because of our policy, but I'm fine with it being a patch as long as there is consensus for doing so. |
Cool! I see consensus. |
PR-URL: nodejs#13726 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
|
Landed in f40caf7 |
|
Quick extra sanity: https://ci.nodejs.org/job/node-test-commit-linuxone/6756/ ✔️ |
PR-URL: #13726 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
PR-URL: #13726 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
|
This does not land cleanly in LTS. Please feel free to manually backport. Please also feel free to replace the backport request label with do-not-land if it shouldn't land |
PR-URL: nodejs#13726 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
|
I opened a PR with a backport for 6.x |
Calling
net.createConnectionwith a bad path results in a segfault. This fixes this by checking for the type and by throwing a TypeError in case it's not a string.Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passesAffected core subsystem(s)
net