Commit 6e7fcff5 authored by Jukka Rissanen's avatar Jukka Rissanen Committed by Benjamin Cabé
Browse files

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: default avatarJukka Rissanen <jukka.rissanen@nordicsemi.no>
parent 43c2b9cf
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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;
	}