Browse Source

Revert "core: correctly parse boolean configuration values."

This reverts commit 8dd1c2d4af.

Introduced a security bug: since CCAN/opt is used to parse the JSON
config (something it is not meant to do), it was possible to specify
the default of

    "api-listen":false

in .conf and expect the API to be disabled. However, since CCAN/opt
does not check for parameters to OPT_WITHOUT_ARG, this got set to
true anyway, and enabled the API on a (possibly unfirewalled) network.

For this reason, configuration options are not named uniformly.

This should have been reverted as soon as it became known:

4c4b909be6 (Fri Feb 28)

Sorry for that.
build-mingw
Noel Maersk 11 years ago
parent
commit
ac3d13880c
  1. 8
      sgminer.c

8
sgminer.c

@ -1452,20 +1452,18 @@ static char *parse_config(json_t *config, bool fileconf, int parent_iteration) @@ -1452,20 +1452,18 @@ static char *parse_config(json_t *config, bool fileconf, int parent_iteration)
int n, size = json_array_size(val);
for (n = 0; n < size && !err; n++) {
if (json_is_string(json_array_get(val, n))) {
if (json_is_string(json_array_get(val, n)))
err = opt->cb_arg(json_string_value(json_array_get(val, n)), opt->u.arg);
}
else if (json_is_object(json_array_get(val, n)))
{
err = parse_config(json_array_get(val, n), false, n);
json_array_index = parent_iteration;
}
}
} else if ((opt->type & OPT_NOARG) && json_is_boolean(val)) {
} else if ((opt->type & OPT_NOARG) && json_is_true(val))
err = opt->cb(opt->u.arg);
} else {
else
err = "Invalid value";
}
if (err) {
/* Allow invalid values to be in configuration

Loading…
Cancel
Save