From: David Drysdale Date: Mon, 22 May 2017 09:54:10 +0000 (+0100) Subject: ares_parse_naptr_reply: check sufficient data X-Git-Tag: accepted/tizen/5.5/base/20191030.084059^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fheads%2Ftizen_5.5_tv;p=platform%2Fupstream%2Fc-ares.git 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. Bug: https://c-ares.haxx.se/adv_20170620.html Patch Link: https://c-ares.haxx.se/CVE-2017-1000381.patch Change-Id: I16056280817af5cd7a62ddc366280c73391cbc6a Signed-off-by: Nishant Chaprana --- diff --git a/ares_parse_naptr_reply.c b/ares_parse_naptr_reply.c index 0e37b02..6216ca7 100644 --- a/ares_parse_naptr_reply.c +++ b/ares_parse_naptr_reply.c @@ -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) @@ -192,4 +198,3 @@ ares_parse_naptr_reply (const unsigned char *abuf, int alen, return ARES_SUCCESS; } -