[Dnsmasq-discuss] Extra Extra: regex patch buggy

Jan 'RedBully' Seiffert redbully at cc.hs-owl.de
Thu Feb 4 15:35:24 GMT 2010


dnsmasq received SIGSEGV!
Jan screwed up!
Simon says: `fortune`
New patch in attachment

reproducer:
set up a line like: server=/somedomain/$some_ip
add an regex address match
query for somedomain

Depending on order of config statements &&/|| if $some_ip could be reached
dnsmasq dies in forward.c because that part is not "regex ready" (NULL deref,
because regex do not have a domain string).
Jepp, i have totally overseen this interaction (like prop. many other).

Solution:
Let's also match server lines with a regex!

I also changed the order in which an "if" is evaluated, after a little run in my
brains logic evaluator this should be a NOP (besides doing a cheap flag test
before an expensive string compare/regex compare), but i could be wrong...
Regex matches on "server" do not try to find the longest match, this could give
you some funky problems if you use very elaborate matching rules.
Maybe i will take that server match out again, it's enough if dnsmasq does not
crash in that place...

Nearby, do never ever set a regex on "local", dragons be there...
Which reminds me to state:
Patch is only lightly tested in my small environment, there are prop. a million
bugs left (as before), this is just a quick fix for the problem at hand.
Take this incident is a friendly little remainder that this change is a deep
poke into dnsmasq's internals.

I better do not touch any source code ever again...

New patch against 2.52 attached. Apply with -p1.
Also with conditional compilation, so don't forget to set HAVE_REGEX to you
COPTS like:
make COPTS=-DHAVE_REGEX
or uncomment it in config.h

Greetings
	Jan

-- 
John encountered the following Zen-like line in his generated XML:
	<>There is no phenotype</>
He was enlightened.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dnsmasq-2.52-regex.patch
Type: text/x-patch
Size: 7355 bytes
Desc: not available
Url : http://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/attachments/20100204/f3528b56/attachment.bin 


More information about the Dnsmasq-discuss mailing list