<HTML>
<HEAD>
<TITLE>Re: [Dnsmasq-discuss] Option 66 Bug?</TITLE>
</HEAD>
<BODY>
<FONT SIZE="4"><FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'>I am blown away not only by the explanation and fix/workaround, but that nobody has ever tried doing a dhcp option where the IP started with a 7! Quite Amazing.<BR>
<BR>
The workaround for me was to use a hostname, as all of the deployments that this matter to me in are inside of DD-WRT router firmware, and unfortunately I am unable to modify the code that produces the .conf file dnsmasq reads from, so I am unable to make the change in their GUI to put the “ in the new spot, but, at least the hostname workaround worked.<BR>
<BR>
Thanks again guys! I’ll alert the dd-wrt team of the new dnsmasq update, too :)<BR>
<BR>
<BR>
On 3/26/10 2:53 PM, "Simon Kelley" <simon@thekelleys.org.uk> wrote:<BR>
<BR>
</SPAN></FONT></FONT><BLOCKQUOTE><FONT SIZE="4"><FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'>Don Muller wrote:<BR>
> Have you tried it without the double quotes?<BR>
><BR>
> <BR>
><BR>
> dhcp-option=66,69.90.91.195<BR>
><BR>
<BR>
Without the quotes, dnsmasq will recognise a valid IP address and send<BR>
it as a four-byte "binary" value, which isn't what's wanted here, it<BR>
does need to be a string.<BR>
<BR>
This turns out to be a real bug, which is almost too bizarre to explain.<BR>
A workaround is to move the quotes:<BR>
<BR>
dhcp-option=66,7"4.114.208.195"<BR>
<BR>
Explanation: characters inside quotes get protected from acting as<BR>
themselves by being temporarily mapped to ASCII control characters: that<BR>
way the code which looks for dotted-quad IP addresses, etc and treats<BR>
them specially is disabled.<BR>
<BR>
There's also some code which handles extra spaces around the commas,<BR>
which used to use isspace() to look for characters to elide. That's<BR>
fine for spaces (spaces inside quotes have been mapped to something<BR>
else, so they don't get zapped) but is turns out that isspace() is also<BR>
true for tabs and vertical tabs. the digit "7" gets mapped to a vertical<BR>
tab, so it gets zapped by the "elide extra spaces" code. The fix is just<BR>
to elide spaces, rather than anything which matches isspace().<BR>
<BR>
The workaround works because it stops the '7' character from being<BR>
mapped to vertical tab, but the other characters are still protected, so<BR>
dnsmasq doesn't treat the argument as dotted-quad.<BR>
<BR>
That bug has been there for _years_. Wow.<BR>
<BR>
Thanks to Dayton for spotting it.<BR>
<BR>
The fixed code is at:<BR>
<BR>
<a href="http://www.thekelleys.org.uk/dnsmasq/test-releases/dnsmasq-2.53test13.tar.gz">http://www.thekelleys.org.uk/dnsmasq/test-releases/dnsmasq-2.53test13.tar.gz</a><BR>
<BR>
<BR>
Cheers,<BR>
<BR>
Simon.<BR>
<BR>
<BR>
</SPAN></FONT></FONT></BLOCKQUOTE>
</BODY>
</HTML>