Skip to content

Commit 6e7fcff

Browse files
jukkarkartben
authored andcommitted
net: dns: Check DNS answer properly
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]>
1 parent 43c2b9c commit 6e7fcff

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

subsys/net/lib/dns/dns_pack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ int dns_unpack_answer(struct dns_msg_t *dns_msg, int dname_ptr, uint32_t *ttl,
134134
*
135135
* See RFC-1035 4.1.3. Resource record format
136136
*/
137-
rem_size = dns_msg->msg_size - dname_len;
137+
rem_size = dns_msg->msg_size - dns_msg->answer_offset - dname_len;
138138
if (rem_size < 2 + 2 + 4 + 2) {
139139
return -EINVAL;
140140
}

0 commit comments

Comments
 (0)