Skip to content
Browse files

net: mdns_resolver: Fix malformed MDNS response

The query->len does not take 'Terminator' into account, shift over
one byte to prevent overwriting it with next field (Type).

This fixes mdns_resolver sample.

Fixes: 87eb552 (net/dns: Switch mdns responder to new net_pkt API)

Signed-off-by: Loic Poulain <>
  • Loading branch information...
Loic Poulain authored and jukkar committed Jun 6, 2019
1 parent 4f4adae commit 3189da5cdca67172a1f227a0d42c418416de6c59
Showing with 3 additions and 0 deletions.
  1. +3 −0 subsys/net/lib/dns/mdns_responder.c
@@ -154,6 +154,9 @@ static void add_answer(struct net_buf *query, enum dns_rr_type qtype,
*prev = strlen(prev) - 1;

/* terminator byte (0x00) */
query->len += 1;

offset = DNS_MSG_HEADER_SIZE + query->len;
UNALIGNED_PUT(htons(qtype), (u16_t *)(query->data+offset));

0 comments on commit 3189da5

Please sign in to comment.
You can’t perform that action at this time.