Skip to content

Commit 2a44836

Browse files
mhdawsontargos
authored andcommitted
deps: cherry-pick 0d252eb from upstream c-ares
Original commit message: If there are more ttls returned than the maximum provided by the requestor, then the *naddrttls response would be larger than the actual number of elements in the addrttls array. This bug could lead to invalid memory accesses in applications using c-ares. This behavior appeared to break with PR c-ares/c-ares#257 Fixes: c-ares/c-ares#371 Reported By: Momtchil Momtchev (@mmomtchev) Fix By: Brad House (@bradh352) Refs: https://github.com/nodejs/node/issues/36063 Signed-off-by: Michael Dawson <mdawson@devrus.com> CVE-ID: CVE-2020-8277 PR-URL: nodejs-private/node-private#231 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Beth Griggs <bgriggs@redhat.com>
1 parent df21120 commit 2a44836

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

deps/cares/src/ares_parse_a_reply.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,8 @@ int ares_parse_a_reply(const unsigned char *abuf, int alen,
197197

198198
if (naddrttls)
199199
{
200-
*naddrttls = naddrs;
200+
/* Truncated to at most *naddrttls entries */
201+
*naddrttls = (naddrs > *naddrttls)?*naddrttls:naddrs;
201202
}
202203

203204
ares__freeaddrinfo_cnames(ai.cnames);

deps/cares/src/ares_parse_aaaa_reply.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,8 @@ int ares_parse_aaaa_reply(const unsigned char *abuf, int alen,
200200

201201
if (naddrttls)
202202
{
203-
*naddrttls = naddrs;
203+
/* Truncated to at most *naddrttls entries */
204+
*naddrttls = (naddrs > *naddrttls)?*naddrttls:naddrs;
204205
}
205206

206207
ares__freeaddrinfo_cnames(ai.cnames);

0 commit comments

Comments
 (0)