-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
dns: consistency; performance on malicious input #20445
Changes from 2 commits
cd73836
fc93b59
03451b4
ae34731
260ee07
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,6 +62,22 @@ assert(existing.length > 0); | |
]); | ||
} | ||
|
||
{ | ||
// Various invalidities, all of which should throw a clean error. | ||
const invalidServers = [ | ||
' ', | ||
'\n', | ||
'\0', | ||
'1'.repeat(3 * 4), | ||
':'.repeat(100000), | ||
'['.repeat(100000), | ||
'['.repeat(100000) + ']'.repeat(100000) + 'a' | ||
]; | ||
invalidServers.forEach((serv) => { | ||
assert.throws(() => dns.setServers([serv]), /TypeError.*ERR_INVALID_IP_ADDRESS/, `Unexpected error thrown for ${serv}`); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line is too long, but I'm not sure how best to format it. I tried the obvious indentation but eslint complained that the TypeError ought to be indented 18 spaces (??). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The correct error type is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should exceed the max line number :( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah yes I recall a comment about that earlier. I need to fix this. |
||
}); | ||
} | ||
|
||
const goog = [ | ||
'8.8.8.8', | ||
'8.8.4.4', | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain the default value here? That is something unexpected for me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addrSplitMatch[2]
might be undefined (see #20441), in which case I figured the port should be 53 (DNS port).I think this is consistent with existing cases where a default port is selected, e.g. here and here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bnoordhuis @apapirovski PTAL
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it should be fine.
parseInt('')
works out to 0 when coerced to int32 and c-ares uses the default port in that case. IOW, there should be no observable change in behavior, it'll use port 53 either way.