ares_parse_naptr_reply: check sufficient data 97/198597/1 accepted/tizen_5.5_base accepted/tizen_5.5_base_mobile_hotfix accepted/tizen_5.5_base_wearable_hotfix accepted/tizen_6.0_base accepted/tizen_6.0_base_hotfix tizen_5.5_base tizen_5.5_base_mobile_hotfix tizen_5.5_base_wearable_hotfix tizen_5.5_tv tizen_6.0_base tizen_6.0_base_hotfix accepted/tizen/5.5/base/20191030.084059 accepted/tizen/5.5/base/mobile/hotfix/20201023.085651 accepted/tizen/5.5/base/wearable/hotfix/20201023.081830 accepted/tizen/6.0/base/20201029.110307 accepted/tizen/6.0/base/hotfix/20201102.093258 accepted/tizen/base/20190316.131830 submit/tizen_5.5_base/20191030.000001 submit/tizen_5.5_base_mobile_hotfix/20201023.171501 submit/tizen_5.5_base_wearable_hotfix/20201023.155601 submit/tizen_6.0_base/20201029.184801 submit/tizen_6.0_base_hotfix/20201030.192501 submit/tizen_6.0_base_hotfix/20201102.162701 submit/tizen_base/20190311.051335 tizen_5.5.m2_release tizen_6.0.m2_release
authorDavid Drysdale <drysdale@google.com>
Mon, 22 May 2017 09:54:10 +0000 (10:54 +0100)
committerNishant Chaprana <n.chaprana@samsung.com>
Mon, 28 Jan 2019 03:29:44 +0000 (08:59 +0530)
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
Link: https://c-ares.haxx.se/CVE-2017-1000381.patch
Change-Id: I16056280817af5cd7a62ddc366280c73391cbc6a
Signed-off-by: Nishant Chaprana <n.chaprana@samsung.com>
ares_parse_naptr_reply.c

index 0e37b02..6216ca7 100644 (file)
@@ -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;
 }
-