Skip to content

Commit

Permalink
net: dns: Check DNS answer properly
Browse files Browse the repository at this point in the history
The dns_unpack_answer() did not check the length of the message
properly which can cause out of bounds read.

Signed-off-by: Jukka Rissanen <[email protected]>
(cherry picked from commit 6e7fcff)
  • Loading branch information
jukkar authored and nashif committed Dec 4, 2024
1 parent 347ea04 commit 4556aa9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion subsys/net/lib/dns/dns_pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ int dns_unpack_answer(struct dns_msg_t *dns_msg, int dname_ptr, uint32_t *ttl,
*
* See RFC-1035 4.1.3. Resource record format
*/
rem_size = dns_msg->msg_size - dname_len;
rem_size = dns_msg->msg_size - dns_msg->answer_offset - dname_len;
if (rem_size < 2 + 2 + 4 + 2) {
return -EINVAL;
}
Expand Down

0 comments on commit 4556aa9

Please sign in to comment.