]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- Accept both option names with and without colon for get_option
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Mon, 9 Apr 2018 10:42:48 +0000 (10:42 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Mon, 9 Apr 2018 10:42:48 +0000 (10:42 +0000)
  and set_option.

git-svn-id: file:///svn/unbound/trunk@4611 be551aaa-1e26-0410-a405-d3ace91eadb9

doc/Changelog
util/config_file.c

index 2480d1394250b188062dd4cbb346ceb50c2e580f..d0536ac9bfce2eed37e3dfd6310b6a15c7c411f8 100644 (file)
@@ -4,6 +4,8 @@
        - num.query.authzone.up and num.query.authzone.down statistics counters.
        - Fix downstream auth zone, only fallback when auth zone fails to
          answer and fallback is enabled.
+       - Accept both option names with and without colon for get_option
+         and set_option.
 
 5 April 2018: Wouter
        - Combine write of tcp length and tcp query for dns over tls.
index c2cbe8121d0187c0f01f570136b72459e774e69e..8ca803c8f04ed65a40f7d6e31f49c676a3098d02 100644 (file)
@@ -386,6 +386,12 @@ struct config_file* config_create_forlib(void)
 int config_set_option(struct config_file* cfg, const char* opt,
        const char* val)
 {
+       char buf[64];
+       if(!opt) return 0;
+       if(opt[strlen(opt)-1] != ':' && strlen(opt)+2<sizeof(buf)) {
+               snprintf(buf, sizeof(buf), "%s:", opt);
+               opt = buf;
+       }
        S_NUMBER_OR_ZERO("verbosity:", verbosity)
        else if(strcmp(opt, "statistics-interval:") == 0) {
                if(strcmp(val, "0") == 0 || strcmp(val, "") == 0)
@@ -801,8 +807,13 @@ int
 config_get_option(struct config_file* cfg, const char* opt, 
        void (*func)(char*,void*), void* arg)
 {
-       char buf[1024];
+       char buf[1024], nopt[64];
        size_t len = sizeof(buf);
+       if(opt && opt[strlen(opt)-1] == ':' && strlen(opt)<sizeof(nopt)) {
+               memmove(nopt, opt, strlen(opt));
+               nopt[strlen(opt)-1] = 0;
+               opt = nopt;
+       }
        fptr_ok(fptr_whitelist_print_func(func));
        O_DEC(opt, "verbosity", verbosity)
        else O_DEC(opt, "statistics-interval", stat_interval)