Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d9273ed

Browse filesBrowse files
committed
deps: cherry-pick 18ea996 from c-ares upstream
Original commit message: ares_parse_naptr_reply: make buffer length check more accurate 9478908a490a6bf009ba58d81de8c1d06d50a117 introduced a length check for records parsed by `ares_parse_naptr_reply()`. However, that function is designed to parse replies which also contain non-NAPTR records; for A records, the `rr_len > 7` check will fail as there are only 4 bytes of payload. In particular, parsing ANY replies for NAPTR records was broken by that patch. Fix that by moving the check into the case in which it is already known that the record is a NAPTR record. Ref: c-ares/c-ares@18ea996 PR-URL: #13883 Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 265f159 commit d9273ed
Copy full SHA for d9273ed

File tree

Expand file treeCollapse file tree

1 file changed

+7
-6
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+7
-6
lines changed
Open diff view settings
Collapse file

‎deps/cares/src/ares_parse_naptr_reply.c‎

Copy file name to clipboardExpand all lines: deps/cares/src/ares_parse_naptr_reply.c
+7-6Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,18 +110,19 @@ 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-
}
119113

120114
/* Check if we are really looking at a NAPTR record */
121115
if (rr_class == C_IN && rr_type == T_NAPTR)
122116
{
123117
/* parse the NAPTR record itself */
124118

119+
/* RR must contain at least 7 bytes = 2 x int16 + 3 x name */
120+
if (rr_len < 7)
121+
{
122+
status = ARES_EBADRESP;
123+
break;
124+
}
125+
125126
/* Allocate storage for this NAPTR answer appending it to the list */
126127
naptr_curr = ares_malloc_data(ARES_DATATYPE_NAPTR_REPLY);
127128
if (!naptr_curr)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.