[Dnsmasq-discuss] dnsmasq sending truncated DHCPv6 packets

Simon Kelley simon at thekelleys.org.uk
Tue Dec 3 18:16:32 GMT 2019

Ignore previous suggestions, I think I see the problem.

The code to send a packet is

 while (retry_send(sendto(daemon->dhcp6fd, daemon->outpacket.iov_base,
			  save_counter(0), 0, (struct sockaddr *)&from,

where the length to send comes from the call to save_counter(0), which
does two things: 1) it returns the length of the packet in the buffer,
and 2) it zeros the length of the packet in the packet buffer.

99% of the time, the while() loop will only execute once, and this will
be fine. If the syscall gets interrupted, the while loop executes a
second time and a zero-length packet gets sent.

The patch to fix this is trivial: change the save_counter() call to


I just checked, and this mistake only occurs here, and has been there
since forever.

Good spot.


More information about the Dnsmasq-discuss mailing list