]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
proper handling of empty files and neater code.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Wed, 13 Aug 2008 15:18:39 +0000 (15:18 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Wed, 13 Aug 2008 15:18:39 +0000 (15:18 +0000)
git-svn-id: file:///svn/unbound/trunk@1189 be551aaa-1e26-0410-a405-d3ace91eadb9

smallapp/unbound-checkconf.c
validator/val_anchor.c

index c289226daae70a785f9971c841ff06b9f190e97a..5f5caee8ddb33967ca0baec070d1632ed04db887 100644 (file)
@@ -278,20 +278,18 @@ basedir(const char* fname, struct config_file* cfg)
 
 /** check chroot for a file string */
 static void
-check_chroot_string(const char* desc, char** str,
+check_chroot_string(const char* desc, char** ss,
        const char* chrootdir, struct config_file* cfg)
 {
-       char* old;
-       char* s = *str;
-       if(s && s[0]) {
-               if(!is_file(fname_after_chroot(s, cfg, 1))) {
+       char* str = *ss;
+       if(str && str[0]) {
+               if(!is_file(fname_after_chroot(str, cfg, 1))) {
                        fatal_exit("%s: \"%s\" does not exist in chrootdir %s", 
-                               desc, s, chrootdir);
+                               desc, str, chrootdir);
                }
-               old = s;
                /* put in a new full path for continued checking */
-               *str = strdup(fname_after_chroot(s, cfg, 1));
-               free(old);
+               *ss = strdup(fname_after_chroot(str, cfg, 1));
+               free(str);
        }
 }
 
index 3ad3c9c7924c1302e6d6374c1d1eb549fb071a39..b569d7b3d6843dd5bcffa14c0297522780db892a 100644 (file)
@@ -363,7 +363,10 @@ anchor_read_file(struct val_anchors* anchors, ldns_buffer* buffer,
        ldns_rdf_deep_free(origin);
        ldns_rdf_deep_free(prev);
        fclose(in);
-       return ok?ta:NULL;
+       if(!ok) return NULL;
+       /* empty file is OK when multiple anchors are allowed */
+       if(!onlyone && !ta) return (struct trust_anchor*)1;
+       return ta;
 }
 
 /** skip file to end of line */