From 0bf34de43b2fc4c9c3104b986eaea5c5cc856b83 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 13 Apr 2017 16:31:28 +0200 Subject: Validate Boolean settings better --- src/libutil/config.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/libutil/config.cc') diff --git a/src/libutil/config.cc b/src/libutil/config.cc index 2f9f988607ea..893cdccce344 100644 --- a/src/libutil/config.cc +++ b/src/libutil/config.cc @@ -90,7 +90,12 @@ template<> std::string Setting::to_string() template<> void Setting::set(const std::string & str) { - value = str == "true" || str == "1"; + if (str == "true" || str == "yes" || str == "1") + value = true; + else if (str == "false" || str == "no" || str == "0") + value = false; + else + throw UsageError("Boolean setting '%s' has invalid value '%s'", name, str); } template<> std::string Setting::to_string() -- cgit 1.4.1