Skip to content

Commit fd8ed64

Browse files
jukkarnashif
authored andcommitted
net: dns: Verify that response is not too short
Make sure that IP address information is found in the received message. Signed-off-by: Jukka Rissanen <[email protected]> Signed-off-by: Flavio Ceolin <[email protected]>
1 parent abbaca1 commit fd8ed64

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

subsys/net/lib/dns/resolve.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,13 @@ static int dns_read(struct dns_resolve_context *ctx,
434434
goto quit;
435435
}
436436

437+
if ((dns_msg.response_position + address_size) >
438+
dns_msg.msg_size) {
439+
/* Too short message */
440+
ret = DNS_EAI_FAIL;
441+
goto quit;
442+
}
443+
437444
src = dns_msg.msg + dns_msg.response_position;
438445

439446
memcpy(addr, src, address_size);

0 commit comments

Comments
 (0)