Skip to content

Commit

Permalink
net: mdns_resolver: Fix malformed MDNS response
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Loic Poulain authored and jukkar committed Jun 12, 2019
1 parent 4f4adae commit 3189da5
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions subsys/net/lib/dns/mdns_responder.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down

0 comments on commit 3189da5

Please sign in to comment.