From: Wouter Wijngaards Date: Wed, 13 Aug 2008 15:18:39 +0000 (+0000) Subject: proper handling of empty files and neater code. X-Git-Tag: release-1.1.0~162 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=44f5800da94d1951510db17b2b9d3c295721c2e9;p=thirdparty%2Funbound.git proper handling of empty files and neater code. git-svn-id: file:///svn/unbound/trunk@1189 be551aaa-1e26-0410-a405-d3ace91eadb9 --- diff --git a/smallapp/unbound-checkconf.c b/smallapp/unbound-checkconf.c index c289226da..5f5caee8d 100644 --- a/smallapp/unbound-checkconf.c +++ b/smallapp/unbound-checkconf.c @@ -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); } } diff --git a/validator/val_anchor.c b/validator/val_anchor.c index 3ad3c9c79..b569d7b3d 100644 --- a/validator/val_anchor.c +++ b/validator/val_anchor.c @@ -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 */