config: accept "0" and "1" as XML boolean values
authorSimon Marchi <simon.marchi@efficios.com>
Fri, 2 Apr 2021 19:52:46 +0000 (15:52 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 13 Apr 2021 20:34:25 +0000 (16:34 -0400)
These are valid values when validating a "boolean" using a schema (XSD).
Somebody could therefore write a file with

    <started>0</started>

instead of

    <started>false</started>

The file would validate against session.xsd, but we would fail after
that:

    Warning: Invalid boolean value encoutered (0).
    Error: Invalid session configuration

Reference: https://www.w3.org/TR/xmlschema11-2/#boolean

Change-Id: Icea85b13233ec01aa09ef3b578906f4c0e482088
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/common/config/session-config.c

index 1b7d965fa8db1c3dc4f696a74df8a03a5cf18a18..b08f40a2e319155074b39d39ddcdf427eb333442 100644 (file)
@@ -843,9 +843,11 @@ int parse_bool(xmlChar *str, int *val)
                goto end;
        }
 
-       if (!strcmp((const char *) str, config_xml_true)) {
+       if (!strcmp((const char *) str, config_xml_true) ||
+                       !strcmp((const char *) str, "1")) {
                *val = 1;
-       } else if (!strcmp((const char *) str, config_xml_false)) {
+       } else if (!strcmp((const char *) str, config_xml_false) ||
+                       !strcmp((const char *) str, "0")) {
                *val = 0;
        } else {
                WARN("Invalid boolean value encountered (%s).",
This page took 0.036585 seconds and 4 git commands to generate.