diff options
Diffstat (limited to 'resolv/res_init.c')
-rw-r--r-- | resolv/res_init.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/resolv/res_init.c b/resolv/res_init.c index 263263d474..243532b3ad 100644 --- a/resolv/res_init.c +++ b/resolv/res_init.c @@ -682,27 +682,29 @@ res_setoptions (struct resolv_conf_parser *parser, const char *options) { char str[22]; uint8_t len; - uint8_t clear; unsigned long int flag; } options[] = { #define STRnLEN(str) str, sizeof (str) - 1 - { STRnLEN ("rotate"), 0, RES_ROTATE }, - { STRnLEN ("edns0"), 0, RES_USE_EDNS0 }, - { STRnLEN ("single-request-reopen"), 0, RES_SNGLKUPREOP }, - { STRnLEN ("single-request"), 0, RES_SNGLKUP }, - { STRnLEN ("no_tld_query"), 0, RES_NOTLDQUERY }, - { STRnLEN ("no-tld-query"), 0, RES_NOTLDQUERY }, - { STRnLEN ("no-reload"), 0, RES_NORELOAD }, - { STRnLEN ("use-vc"), 0, RES_USEVC }, - { STRnLEN ("trust-ad"), 0, RES_TRUSTAD }, - { STRnLEN ("no-aaaa"), 0, RES_NOAAAA }, + { STRnLEN ("rotate"), RES_ROTATE }, + { STRnLEN ("edns0"), RES_USE_EDNS0 }, + { STRnLEN ("single-request-reopen"), RES_SNGLKUPREOP }, + { STRnLEN ("single-request"), RES_SNGLKUP }, + { STRnLEN ("no_tld_query"), RES_NOTLDQUERY }, + { STRnLEN ("no-tld-query"), RES_NOTLDQUERY }, + { STRnLEN ("no-reload"), RES_NORELOAD }, + { STRnLEN ("use-vc"), RES_USEVC }, + { STRnLEN ("trust-ad"), RES_TRUSTAD }, + { STRnLEN ("no-aaaa"), RES_NOAAAA }, }; #define noptions (sizeof (options) / sizeof (options[0])) + bool negate_option = *cp == '-'; + if (negate_option) + ++cp; for (int i = 0; i < noptions; ++i) if (strncmp (cp, options[i].str, options[i].len) == 0) { - if (options[i].clear) - parser->template.options &= options[i].flag; + if (negate_option) + parser->template.options &= ~options[i].flag; else parser->template.options |= options[i].flag; break; |