-
Notifications
You must be signed in to change notification settings - Fork 30k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dns: fix crash while setting server during query
Fix this issue follow these two points: 1. Keep track of how many queries are currently open. If `setServers()` is called while there are open queries, error out. 2. For `Resolver` instances, use option 1. For dns.setServers(), just create a fresh new default channel every time it is called, and then set its servers list. Fixes: #14734 PR-URL: #14891 Backport-PR-URL: #17778 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Tobias Nießen <[email protected]>
- Loading branch information
Showing
4 changed files
with
93 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
|
||
const dns = require('dns'); | ||
|
||
const goog = [ | ||
'8.8.8.8', | ||
'8.8.4.4', | ||
]; | ||
|
||
{ | ||
// Fix https://github.com/nodejs/node/issues/14734 | ||
|
||
{ | ||
const resolver = new dns.Resolver(); | ||
resolver.resolve('localhost', common.mustCall()); | ||
|
||
common.expectsError(resolver.setServers.bind(resolver, goog), { | ||
message: /^c-ares failed to set servers: "There are pending queries\." \[.+\]$/g | ||
}); | ||
} | ||
|
||
{ | ||
dns.resolve('localhost', common.mustCall()); | ||
|
||
// should not throw | ||
dns.setServers(goog); | ||
} | ||
} |