From 47945b177017848c3c062ba2944df36265e29b71 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Fri, 2 Apr 2021 15:52:46 -0400 Subject: [PATCH] config: accept "0" and "1" as XML boolean values MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit These are valid values when validating a "boolean" using a schema (XSD). Somebody could therefore write a file with 0 instead of false 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 Signed-off-by: Jérémie Galarneau --- src/common/config/session-config.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/common/config/session-config.c b/src/common/config/session-config.c index 1b7d965fa..b08f40a2e 100644 --- a/src/common/config/session-config.c +++ b/src/common/config/session-config.c @@ -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).", -- 2.34.1