-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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 using dns.setServers after dns.resolve4
The callback function in cares_query is synchronous and called before closed. So dns.setServers in the synchronous callback before closed will occur crashing. Fixes: #894 Refs: https://github.com/nodejs/node/blob/v6.9.4/deps/cares/src/ares_process.c#L1332-L1333 Refs: https://github.com/OpenSIPS/opensips/blob/2.3.0/proxy.c
- Loading branch information
Showing
2 changed files
with
198 additions
and
9 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
17 changes: 17 additions & 0 deletions
17
test/internet/test-dns-setserver-in-callback-of-resolve4.js
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,17 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const dns = require('dns'); | ||
|
||
dns.resolve4('google.com', common.mustCall(function(/* err, nameServers */) { | ||
// do not care about `err` and `nameServers`, | ||
// both failed and succeeded would be OK. | ||
// | ||
// just to test crash | ||
|
||
dns.setServers([ '8.8.8.8' ]); | ||
|
||
// the test case shouldn't crash here | ||
// see https://github.com/nodejs/node/pull/13050 and | ||
// https://github.com/nodejs/node/issues/894 | ||
})); |