summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2018-12-22 21:18:13 +0100
committerAnna Henningsen <anna@addaleax.net>2018-12-26 14:45:16 +0100
commitd93f93aa99aead77fb52d16a0d8f7d9af047a69a (patch)
treeb6b4a132df3b1c042fe21bec08177917e5fb839b /test
parent79aab5dd7cfe30f807b5d197c95aea9dd59ecb40 (diff)
downloadandroid-node-v8-d93f93aa99aead77fb52d16a0d8f7d9af047a69a.tar.gz
android-node-v8-d93f93aa99aead77fb52d16a0d8f7d9af047a69a.tar.bz2
android-node-v8-d93f93aa99aead77fb52d16a0d8f7d9af047a69a.zip
dns: fix TTL value for AAAA replies to `resolveAny()`
We were previously reading from the wrong offset, namely the one into the final results array, not the one for the AAAA results itself, which could have lead to reading uninitialized or out-of-bounds data. Also, adjust the test accordingly; TTL values are not modified by c-ares, but are only exposed for a subset of all DNS record types. PR-URL: https://github.com/nodejs/node/pull/25187 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Khaidi Chu <i@2333.moe> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Diffstat (limited to 'test')
-rw-r--r--test/parallel/test-dns-resolveany.js13
1 files changed, 9 insertions, 4 deletions
diff --git a/test/parallel/test-dns-resolveany.js b/test/parallel/test-dns-resolveany.js
index 46694f2403..bb15b1a38b 100644
--- a/test/parallel/test-dns-resolveany.js
+++ b/test/parallel/test-dns-resolveany.js
@@ -53,8 +53,13 @@ server.bind(0, common.mustCall(async () => {
}));
function validateResults(res) {
- // Compare copies with ttl removed, c-ares fiddles with that value.
- assert.deepStrictEqual(
- res.map((r) => Object.assign({}, r, { ttl: null })),
- answers.map((r) => Object.assign({}, r, { ttl: null })));
+ // TTL values are only provided for A and AAAA entries.
+ assert.deepStrictEqual(res.map(maybeRedactTTL), answers.map(maybeRedactTTL));
+}
+
+function maybeRedactTTL(r) {
+ const ret = { ...r };
+ if (!['A', 'AAAA'].includes(r.type))
+ delete ret.ttl;
+ return ret;
}