]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
fix for bug 180
authorJelte Jansen <jelte@nlnetlabs.nl>
Wed, 28 May 2008 14:29:29 +0000 (14:29 +0000)
committerJelte Jansen <jelte@nlnetlabs.nl>
Wed, 28 May 2008 14:29:29 +0000 (14:29 +0000)
git-svn-id: file:///svn/unbound/trunk@1101 be551aaa-1e26-0410-a405-d3ace91eadb9

smallapp/unbound-checkconf.c

index 7acc0865b0944d7f4988acc9bbb89bc5f153b55d..83f84aafeab4487ea391363be8becb90c0b26932 100644 (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);