Skip to content

Commit

Permalink
test: fix dns test case failures after c-ares update to 1.21.0+
Browse files Browse the repository at this point in the history
c-ares has made intentional changes to the behavior of TXT records
to comply with RFC 7208, which concatenates multiple strings for
the same TXT record into a single string.  Multiple TXT records
are not concatenated.

Also, response handling has changed, such that a response which is
completely invalid in formatting is thrown away as a malicious
forged/spoofed packet rather than returning EBADRESP.  This is one
step toward RFC 9018 (EDNS COOKIES) which will require the message
to at least be structurally valid to validate against spoofed
records.

Fix By: Brad House (@bradh352)

PR-URL: nodejs#50743
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Fixes: nodejs#50741
Refs: nodejs#50444
  • Loading branch information
bradh352 authored and martenrichter committed Nov 26, 2023
1 parent 9027578 commit 467a44e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions test/parallel/test-dns-resolveany-bad-ancount.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@ server.bind(0, common.mustCall(async () => {
dnsPromises.resolveAny('example.org')
.then(common.mustNotCall())
.catch(common.expectsError({
code: 'EBADRESP',
// May return EBADRESP or ETIMEOUT
code: /^(?:EBADRESP|ETIMEOUT)$/,
syscall: 'queryAny',
hostname: 'example.org'
}));

dns.resolveAny('example.org', common.mustCall((err) => {
assert.strictEqual(err.code, 'EBADRESP');
assert.notStrictEqual(err.code, 'SUCCESS');
assert.strictEqual(err.syscall, 'queryAny');
assert.strictEqual(err.hostname, 'example.org');
const descriptor = Object.getOwnPropertyDescriptor(err, 'message');
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-dns-resolveany.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const answers = [
{ type: 'AAAA', address: '::42', ttl: 123 },
{ type: 'MX', priority: 42, exchange: 'foobar.com', ttl: 124 },
{ type: 'NS', value: 'foobar.org', ttl: 457 },
{ type: 'TXT', entries: [ 'v=spf1 ~all', 'xyz\0foo' ] },
{ type: 'TXT', entries: [ 'v=spf1 ~all xyz\0foo' ] },
{ type: 'PTR', value: 'baz.org', ttl: 987 },
{
type: 'SOA',
Expand Down

0 comments on commit 467a44e

Please sign in to comment.