Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/test-internet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@ on:
paths:
- .github/workflows/test-internet.yml
- test/internet/**
- test/common/internet.js
- internal/dns/**
- lib/dns.js
- lib/internal/dns/**
- lib/net.js
- src/cares_wrap.cc
- src/cares_wrap.h
push:
branches:
- main
Expand All @@ -22,9 +26,13 @@ on:
paths:
- .github/workflows/test-internet.yml
- test/internet/**
- test/common/internet.js
- internal/dns/**
- lib/dns.js
- lib/internal/dns/**
- lib/net.js
- src/cares_wrap.cc
- src/cares_wrap.h

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
Expand Down
4 changes: 4 additions & 0 deletions test/common/internet.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ const addresses = {
DNS4_SERVER: '8.8.8.8',
// An accessible IPv4 DNS server
DNS6_SERVER: '2001:4860:4860::8888',
// A valid host with no records (except SOA)
NO_RECORD_HOST: 'void.example.com',
// A valid host with no TXT records, and a CNAME to a host with no TXT records
CNAME_TO_NO_TXT_HOST: 'www.microsoft.com',
};

for (const key of Object.keys(addresses)) {
Expand Down
16 changes: 9 additions & 7 deletions test/internet/test-dns-txt-sigsegv.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
'use strict';
const common = require('../common');
const { addresses } = require('../common/internet');
const assert = require('assert');
const dns = require('dns');
const dnsPromises = dns.promises;

(async function() {
const result = await dnsPromises.resolveTxt('www.microsoft.com');
assert.strictEqual(result.length, 0);
})().then(common.mustCall());
assert.rejects(
dnsPromises.resolveTxt(addresses.CNAME_TO_NO_TXT_HOST),
{ code: 'ENODATA' },
).then(common.mustCall());

dns.resolveTxt('www.microsoft.com', common.mustCall((err, records) => {
assert.strictEqual(err, null);
assert.strictEqual(records.length, 0);
dns.resolveTxt(addresses.CNAME_TO_NO_TXT_HOST, common.mustCall((err, records) => {
assert.ok(err instanceof Error);
assert.strictEqual(err.code, 'ENODATA');
assert.strictEqual(records, undefined);
}));
61 changes: 61 additions & 0 deletions test/internet/test-dns.js
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,67 @@ test(function test_resolve_failure(done) {
});


async function testEmptyRecords(method, done) {
await assert.rejects(
dnsPromises[method](addresses.NO_RECORD_HOST),
{ code: 'ENODATA' },
);

const req = dns[method](addresses.NO_RECORD_HOST, common.mustCall((err, result) => {
assert.ok(err instanceof Error);
assert.strictEqual(err.code, 'ENODATA');
assert.strictEqual(result, undefined);
done();
}));

checkWrap(req);
}

test(function test_empty_4_records(done) {
testEmptyRecords('resolve4', done);
});

test(function test_empty_6_records(done) {
testEmptyRecords('resolve6', done);
});

test(function test_empty_caa_records(done) {
testEmptyRecords('resolveCaa', done);
});

test(function test_empty_cname_records(done) {
testEmptyRecords('resolveCname', done);
});

test(function test_empty_mx_records(done) {
testEmptyRecords('resolveMx', done);
});

test(function test_empty_naptr_records(done) {
testEmptyRecords('resolveNaptr', done);
});

test(function test_empty_ns_records(done) {
testEmptyRecords('resolveNs', done);
});

test(function test_empty_ptr_records(done) {
testEmptyRecords('resolvePtr', done);
});

test(function test_empty_srv_records(done) {
testEmptyRecords('resolveSrv', done);
});

test(function test_empty_tlsa_records(done) {
testEmptyRecords('resolveTlsa', done);
});

test(function test_empty_txt_records(done) {
testEmptyRecords('resolveTxt', done);
});


let getaddrinfoCallbackCalled = false;

console.log(`looking up ${addresses.INET4_HOST}..`);
Expand Down
Loading