Skip to content

Commit

Permalink
deps: cherry-pick 9478908a49 from cares upstream
Browse files Browse the repository at this point in the history
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 <info@bnoordhuis.nl>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
  • Loading branch information
daviddrysdale authored and MylesBorins committed Jul 10, 2017
1 parent b5bf5e8 commit 8a82960
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion deps/cares/src/ares_parse_naptr_reply.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@ ares_parse_naptr_reply (const unsigned char *abuf, int alen,
status = ARES_EBADRESP;
break;
}
/* RR must contain at least 7 bytes = 2 x int16 + 3 x name */
if (rr_len < 7)
{
status = ARES_EBADRESP;
break;
}

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

return ARES_SUCCESS;
}

0 comments on commit 8a82960

Please sign in to comment.