From 5c1015fc2ac30cc1c460e0ad56aad98cb32b9705 Mon Sep 17 00:00:00 2001 From: ShelbyZ Date: Tue, 24 Oct 2017 10:51:51 -0700 Subject: [PATCH] Path comparison is causing issues - don't be too smart without running through some testing --- src/servers/Server_REST/main.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/servers/Server_REST/main.cpp b/src/servers/Server_REST/main.cpp index a883a2d1..457bab48 100644 --- a/src/servers/Server_REST/main.cpp +++ b/src/servers/Server_REST/main.cpp @@ -597,7 +597,7 @@ int main(int argc, char* argv[]) auto path = boost::filesystem::canonical( web_root_path / "news.xml" ); //Check if path is within web_root_path if( distance( web_root_path.begin(), web_root_path.end() ) > distance( path.begin(), path.end() ) || - !std::equal( web_root_path.begin(), web_root_path.end(), path.begin(), path.end() ) ) + !std::equal( web_root_path.begin(), web_root_path.end(), path.begin() ) ) throw invalid_argument( "path must be within root path" ); if( !( boost::filesystem::exists( path ) && boost::filesystem::is_regular_file( path ) ) ) throw invalid_argument( "file does not exist" ); @@ -638,7 +638,7 @@ int main(int argc, char* argv[]) auto path = boost::filesystem::canonical( web_root_path / "headlines.xml" ); //Check if path is within web_root_path if( distance( web_root_path.begin(), web_root_path.end() ) > distance( path.begin(), path.end() ) || - !std::equal( web_root_path.begin(), web_root_path.end(), path.begin(), path.end() ) ) + !std::equal( web_root_path.begin(), web_root_path.end(), path.begin() ) ) throw invalid_argument( "path must be within root path" ); if( !( boost::filesystem::exists( path ) && boost::filesystem::is_regular_file( path ) ) ) throw invalid_argument( "file does not exist" ); @@ -683,7 +683,7 @@ int main(int argc, char* argv[]) auto path = boost::filesystem::canonical( web_root_path / request->path ); //Check if path is within web_root_path if( distance( web_root_path.begin(), web_root_path.end() ) > distance( path.begin(), path.end() ) || - !std::equal( web_root_path.begin(), web_root_path.end(), path.begin(), path.end() ) ) + !std::equal( web_root_path.begin(), web_root_path.end(), path.begin() ) ) throw invalid_argument( "path must be within root path" ); if( boost::filesystem::is_directory( path ) ) path /= "index.html";