From a3bd7e73d38b78fbf86125077a916781dc4a77e4 Mon Sep 17 00:00:00 2001 From: Simon Kelley Date: Thu, 19 Jul 2018 22:00:08 +0100 Subject: [PATCH] Fix missing fatal errors when parsing some command-line/config options. --- CHANGELOG | 4 ++++ src/option.c | 28 +++++++++------------------- 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 3122300..3fe3e77 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -37,6 +37,10 @@ version 2.80 without DNSSEC RRs to queries with the do-bit set, but only when DNSSEC validation was not enabled. Thanks to Petr Menšík for spotting this. + + Fix missing fatal errors with some malformed options + (server, local, address, rebind-domain-ok, ipset, alias). + Thanks to Eugene Lozovoy for spotting the problem. version 2.79 diff --git a/src/option.c b/src/option.c index 5da5244..0cd39fd 100644 --- a/src/option.c +++ b/src/option.c @@ -2417,7 +2417,7 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma if (strcmp(arg, "#") == 0) domain = ""; else if (strlen (arg) != 0 && !(domain = canonicalise_opt(arg))) - option = '?'; + ret_err(gen_err); serv = opt_malloc(sizeof(struct server)); memset(serv, 0, sizeof(struct server)); serv->next = newlist; @@ -2549,7 +2549,7 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma if (strcmp(arg, "#") == 0 || !*arg) domain = ""; else if (strlen(arg) != 0 && !(domain = canonicalise_opt(arg))) - option = '?'; + ret_err(gen_err); ipsets->next = opt_malloc(sizeof(struct ipsets)); ipsets = ipsets->next; memset(ipsets, 0, sizeof(struct ipsets)); @@ -2564,13 +2564,11 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma memset(ipsets, 0, sizeof(struct ipsets)); ipsets->domain = ""; } + if (!arg || !*arg) - { - option = '?'; - break; - } - size = 2; - for (end = arg; *end; ++end) + ret_err(gen_err); + + for (size = 2, end = arg; *end; ++end) if (*end == ',') ++size; @@ -2798,12 +2796,6 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma memset (new, 0, sizeof(*new)); new->lease_time = DEFLEASE; - if (!arg) - { - option = '?'; - break; - } - while(1) { for (cp = arg; *cp; cp++) @@ -3805,11 +3797,9 @@ err: if ((k < 2) || (!(inet_pton(AF_INET, a[0], &new->in) > 0)) || - (!(inet_pton(AF_INET, a[1], &new->out) > 0))) - option = '?'; - - if (k == 3 && !inet_pton(AF_INET, a[2], &new->mask)) - option = '?'; + (!(inet_pton(AF_INET, a[1], &new->out) > 0)) || + (k == 3 && !inet_pton(AF_INET, a[2], &new->mask))) + ret_err(_("missing address in alias")); if (dash && (!(inet_pton(AF_INET, dash, &new->end) > 0) ||