Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2018-12-22 23:18:13 +0300
committerAnna Henningsen <anna@addaleax.net>2018-12-26 16:45:16 +0300
commitd93f93aa99aead77fb52d16a0d8f7d9af047a69a (patch)
treeb6b4a132df3b1c042fe21bec08177917e5fb839b /src/cares_wrap.cc
parent79aab5dd7cfe30f807b5d197c95aea9dd59ecb40 (diff)
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 'src/cares_wrap.cc')
-rw-r--r--src/cares_wrap.cc4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/cares_wrap.cc b/src/cares_wrap.cc
index a3bcdf89535..9d7af47dcdb 100644
--- a/src/cares_wrap.cc
+++ b/src/cares_wrap.cc
@@ -1265,6 +1265,7 @@ class QueryAnyWrap: public QueryWrap {
}
CHECK_EQ(aaaa_count, naddr6ttls);
+ CHECK_EQ(ret->Length(), a_count + aaaa_count);
for (uint32_t i = a_count; i < ret->Length(); i++) {
Local<Object> obj = Object::New(env()->isolate());
obj->Set(context,
@@ -1272,7 +1273,8 @@ class QueryAnyWrap: public QueryWrap {
ret->Get(context, i).ToLocalChecked()).FromJust();
obj->Set(context,
env()->ttl_string(),
- Integer::New(env()->isolate(), addr6ttls[i].ttl)).FromJust();
+ Integer::New(env()->isolate(), addr6ttls[i - a_count].ttl))
+ .FromJust();
obj->Set(context,
env()->type_string(),
env()->dns_aaaa_string()).FromJust();