[Pdns-dev] Re: [patch] Zone2ldap fix + feature

bert hubert ahu at ds9a.nl
Wed Dec 31 15:08:49 CET 2003


On Wed, Dec 31, 2003 at 02:13:38PM +0100, Norbert Sendetzky wrote:

> > >> -       while( --j != subparts.begin() )
> > >> +       while( j-- && j != subparts.begin() )
> 
> Maybe, but then both statements should segfault, shouldn't they?
> I can't see a real difference between the two statements.

You might be saved that 'j' evaluates to zero in case of problems. This code
is rife with problems, I suggest rethinking it in a big way:

1	subnet = domain2.substr( 0, domain2.rfind( g_zonename ) );
2	subnet = ZoneParser::canonic( subnet );
3	stringtok( parts, g_zonename, "." );
4	stringtok( subparts, subnet, "." );
5	net = g_zonename;
6	j = subparts.end();

on line 1, rfind might not find g_zonename, for example. And indeed,
subparts might turn out to be empty then, which would lead to a crash.

I don't know enough about the LDAP backend, but I don't understand what this
code is trying to accomplish. Are you reinventing chopOff()?

Happy new year!

-- 
http://www.PowerDNS.com      Open source, database driven DNS Software 
http://lartc.org           Linux Advanced Routing & Traffic Control HOWTO


More information about the Pdns-dev mailing list