Hi all,
we have discovered a segfault in nsd-patch when renaming slave zone in nsd
config file if some data for this zone still exists in the IXFR diff
database.
In my case, the zone "black" was renamed to "blackinwhite":
root@ggd115:/cage/nsd/var/nsd/zones#nsd-patch -c
/cage/nsd/etc/nsd-dns-slave.conf
reading database
reading updates to database
[1343043191] nsd-patch[10800]: error: xfr: zone black. not in config.
[1343043191] nsd-patch[10800]: error: no zone exists
writing changed zones
Segmentation fault (core dumped)
The problem is that on line 407 of nsd-patch it tries to printf() a
message "zone %s had not changed", where %s is zone->opts->name:
for(zone = db->zones; zone; zone = zone->next)
{
if(!force_write && !zone->updated) {
fprintf(stdout, "zone %s had not
changed.\n", zone->opts->name);
continue;
}
zone->opts is filled in in difffile.c around line 675:
zone->opts = zone_options_find(opt, domain_dname(zone->apex));
if(!zone->opts) {
log_msg(LOG_ERR, "xfr: zone %s not in config.",
dname_to_string(zone_name,0));
return 0;
}
As a result, nsd-patch tries to dereference a null pointer when trying to
print zone name.
I think the proper fix is to move the code that adds zone structure to the
linked list at the very end of find_zone(). Attached patch fixes the issue
described above. This patch is for nsd 3.2.11.
Please review and comment if you find it nessesary/useful/awful ![]()
(attachments)
difffile.c.diff (826 Bytes)