Skip to content

Commit

Permalink
net: dns: Check parsing error properly for response
Browse files Browse the repository at this point in the history
If the packet parsing fails in dns_unpack_response_query(), then
do not continue further but bail out early.

Signed-off-by: Jukka Rissanen <[email protected]>
  • Loading branch information
jukkar authored and kartben committed Nov 28, 2024
1 parent 3c59bd4 commit eb2550a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions subsys/net/lib/dns/resolve.c
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,11 @@ int dns_validate_msg(struct dns_resolve_context *ctx,

ret = dns_unpack_response_query(dns_msg);
if (ret < 0) {
if (ret == -ENOMEM) {
ret = DNS_EAI_FAIL;
goto quit;
}

/* Check mDNS like above */
if (*dns_id > 0) {
ret = DNS_EAI_FAIL;
Expand Down

0 comments on commit eb2550a

Please sign in to comment.