fix for bug 180

git-svn-id: file:///svn/unbound/trunk@1101 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
Jelte Jansen 2008-05-28 14:29:29 +00:00
parent 97854e6bc5
commit ef69508048

View file

@ -248,18 +248,18 @@ fname_after_chroot(const char* fname, struct config_file* cfg, int use_chdir)
} else if(cfg->directory && cfg->directory[0]) {
/* prepend chdir */
if(slashit && cfg->directory[0] != '/')
strncat(buf, "/", sizeof(buf)-1);
strncat(buf, "/", sizeof(buf)-strlen(buf)-1);
if(strncmp(cfg->chrootdir, cfg->directory,
strlen(cfg->chrootdir)) == 0)
strncat(buf, cfg->directory+strlen(cfg->chrootdir),
sizeof(buf)-1);
else strncat(buf, cfg->directory, sizeof(buf)-1);
sizeof(buf)-strlen(buf)-1);
else strncat(buf, cfg->directory, sizeof(buf)-strlen(buf)-1);
slashit = 1;
}
/* fname */
if(slashit && fname[0] != '/')
strncat(buf, "/", sizeof(buf)-1);
strncat(buf, fname, sizeof(buf)-1);
strncat(buf, "/", sizeof(buf)-strlen(buf)-1);
strncat(buf, fname, sizeof(buf)-strlen(buf)-1);
buf[sizeof(buf)-1] = 0;
return buf;
}
@ -329,9 +329,9 @@ morechecks(struct config_file* cfg, char* fname)
if(fname[0] != '/') {
if(getcwd(buf, sizeof(buf)) == NULL)
fatal_exit("getcwd: %s", strerror(errno));
strncat(buf, "/", sizeof(buf));
strncat(buf, "/", sizeof(buf)-strlen(buf)-1);
}
strncat(buf, fname, sizeof(buf));
strncat(buf, fname, sizeof(buf)-strlen(buf)-1);
if(strncmp(buf, cfg->chrootdir, strlen(cfg->chrootdir)) != 0)
fatal_exit("config file %s is not inside chroot %s",
buf, cfg->chrootdir);