Skip to content

Commit a731425

Browse files
daviddrysdaleMylesBorins
authored andcommitted
deps: cherry-pick 9478908a49 from cares upstream
Original commit message: ares_parse_naptr_reply: check sufficient data Check that there is enough data for the required elements of an NAPTR record (2 int16, 3 bytes for string lengths) before processing a record. This patch fixes CVE-2017-1000381 The c-ares function ares_parse_naptr_reply(), which is used for parsing NAPTR responses, could be triggered to read memory outside of the given input buffer if the passed in DNS response packet was crafted in a particular way. Refs: https://c-ares.haxx.se/adv_20170620.html Refs: https://c-ares.haxx.se/CVE-2017-1000381.patch PR-URL: https://github.com/nodejs/node-private/pull/88 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
1 parent 199ad1d commit a731425

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

deps/cares/src/ares_parse_naptr_reply.c

+6-1
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,12 @@ ares_parse_naptr_reply (const unsigned char *abuf, int alen,
110110
status = ARES_EBADRESP;
111111
break;
112112
}
113+
/* RR must contain at least 7 bytes = 2 x int16 + 3 x name */
114+
if (rr_len < 7)
115+
{
116+
status = ARES_EBADRESP;
117+
break;
118+
}
113119

114120
/* Check if we are really looking at a NAPTR record */
115121
if (rr_class == C_IN && rr_type == T_NAPTR)
@@ -185,4 +191,3 @@ ares_parse_naptr_reply (const unsigned char *abuf, int alen,
185191

186192
return ARES_SUCCESS;
187193
}
188-

0 commit comments

Comments
 (0)