From bb88e0f7959fb46214ad49e3b70f0812c8770d8f Mon Sep 17 00:00:00 2001 From: David Drysdale Date: Mon, 22 May 2017 10:54:10 +0100 Subject: 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: I45f9d4916818b658bcec928f4bee2457ba2124b5 Signed-off-by: Nishant Chaprana --- ares_parse_naptr_reply.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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; } - -- cgit v1.2.3