diff --git a/libdnf/conf/ConfigMain.cpp b/libdnf/conf/ConfigMain.cpp index 39ed4b1e15..37d9ca0d12 100644 --- a/libdnf/conf/ConfigMain.cpp +++ b/libdnf/conf/ConfigMain.cpp @@ -196,12 +196,18 @@ class ConfigMain::Impl { [](const std::string & value)->std::uint32_t{ if (value == "") return 0; + std::int32_t value_i; try { - return std::stoul(value); + value_i = std::stol(value); } catch (...) { - return 0; + throw Option::InvalidValue(tfm::format(_("invalid value"))); } + if (value_i == 1) + throw Option::InvalidValue(tfm::format(_("value 1 is not allowed"))); + if (value_i < 0) + throw Option::InvalidValue(tfm::format(_("negative value is not allowed"))); + return (std::uint32_t)value_i; } };