ctdb-common: Fix empty value handling in conf
authorAmitay Isaacs <amitay@gmail.com>
Thu, 25 Jul 2019 05:14:32 +0000 (15:14 +1000)
committerMartin Schwenke <martins@samba.org>
Fri, 26 Jul 2019 03:34:16 +0000 (03:34 +0000)
In tini, allow_empty_value=false causes the parser to ignore the lines
without '=' sign, but lines with nothing after '=' sign are allowed and
cause empty string ("") to be passed as a value.

This is counter-intuitive, so conf requires special handling for empty
values (which are treated as invalid).

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
ctdb/common/conf.c

index 3d668de3122ac4b71bcc70a2add5e8136e711dfa..e849ff4322f59ad91cde31c230a2bb856d6fec8f 100644 (file)
@@ -1130,6 +1130,14 @@ static bool conf_load_option(const char *name,
                }
        }
 
+       if (strlen(value_str) == 0) {
+               D_ERR("conf: empty value [%s] -> \"%s\"\n",
+                     state->s->name,
+                     name);
+               state->err = EINVAL;
+               return true;
+       }
+
        tmp_ctx = talloc_new(state->conf);
        if (tmp_ctx == NULL) {
                state->err = ENOMEM;