From: Thomas Markwalder Date: Wed, 30 Apr 2025 11:21:08 +0000 (-0400) Subject: [#3837] Addressed review comments X-Git-Tag: Kea-2.4.2~17 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8254d451372c8749e800e8fd9af9fe177c9f1a9d;p=thirdparty%2Fkea.git [#3837] Addressed review comments --- diff --git a/src/lib/util/filesystem.cc b/src/lib/util/filesystem.cc index 6990c114ff..384835fa2b 100644 --- a/src/lib/util/filesystem.cc +++ b/src/lib/util/filesystem.cc @@ -14,7 +14,6 @@ #include #include #include -#include #include #include @@ -206,23 +205,23 @@ FileManager::validatePath(const std::string supported_path_str, const std::strin auto filename = input_path.filename(); if (filename.empty()) { isc_throw(BadValue, "path: '" << input_path.str() << "' has no filename"); - } - + } + auto parent_path = input_path.parentPath(); if (!parent_path.empty()) { - if (!enforce_path) { - // Security set to lax, let it fly. - return (input_path_str); - } - + if (!enforce_path) { + // Security set to lax, let it fly. + return (input_path_str); + } + // We only allow absolute path equal to default. Catch an invalid path. if (parent_path != supported_path_copy) { - isc_throw(BadValue, "invalid path specified: '" + isc_throw(BadValue, "invalid path specified: '" << parent_path << "', supported path is '" << supported_path_copy << "'"); - } - } - + } + } + std::string valid_path(supported_path_copy + "/" + filename); return (valid_path); }