[Dnsmasq-discuss] dnsmasq sending truncated DHCPv6 packets

Simon Kelley simon at thekelleys.org.uk
Tue Dec 3 18:21:55 GMT 2019


On 03/12/2019 18:16, Simon Kelley wrote:
> 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,
> 			  sizeof(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
> 
> save_counter(-1)
> 
> I just checked, and this mistake only occurs here, and has been there
> since forever.
> 
> Good spot.
> 
> Simon.
> 

Patch committed:

http://thekelleys.org.uk/gitweb/?p=dnsmasq.git;a=commit;h=f73f7397d7e99f8412b7dc465061d20f642cdc85

Simon.



More information about the Dnsmasq-discuss mailing list