[Dnsmasq-discuss] Option 66 Bug?

Simon Kelley simon at thekelleys.org.uk
Fri Mar 26 21:53:19 GMT 2010


Don Muller wrote:
> Have you tried it without the double quotes?
> 
>  
> 
> dhcp-option=66,69.90.91.195
> 

Without the quotes, dnsmasq will recognise a valid IP address and send
it as a four-byte "binary" value, which isn't what's wanted here, it
does need to be a string.

This turns out to be a real bug, which is almost too bizarre to explain.
A workaround is to move the quotes:

 dhcp-option=66,7"4.114.208.195"

Explanation: characters inside quotes get protected from acting as
themselves by being temporarily mapped to ASCII control characters: that
way the code which looks for dotted-quad IP addresses, etc and treats
them specially is disabled.

There's also some code which handles extra spaces around the commas,
which used to  use isspace() to look for characters to elide. That's
fine for spaces (spaces inside quotes  have been mapped to something
else, so they don't get zapped) but is turns out that isspace() is also
true for tabs and vertical tabs. the digit "7" gets mapped to a vertical
tab, so it gets zapped by the "elide extra spaces" code. The fix is just
to elide spaces, rather than anything which matches isspace().

The workaround works because it stops the '7' character from being
mapped to vertical tab, but the other characters are still protected, so
dnsmasq doesn't treat the argument as dotted-quad.

That bug has been there for _years_. Wow.

Thanks to Dayton for spotting it.

The fixed code is at:

http://www.thekelleys.org.uk/dnsmasq/test-releases/dnsmasq-2.53test13.tar.gz


Cheers,

Simon.




More information about the Dnsmasq-discuss mailing list