1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-05-04 17:57:47 +00:00

Path comparison is causing issues

- don't be too smart without running through some testing
This commit is contained in:
ShelbyZ 2017-10-24 10:51:51 -07:00
parent ca2691d45c
commit 5c1015fc2a

View file

@ -597,7 +597,7 @@ int main(int argc, char* argv[])
auto path = boost::filesystem::canonical( web_root_path / "news.xml" ); auto path = boost::filesystem::canonical( web_root_path / "news.xml" );
//Check if path is within web_root_path //Check if path is within web_root_path
if( distance( web_root_path.begin(), web_root_path.end() ) > distance( path.begin(), path.end() ) || 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" ); throw invalid_argument( "path must be within root path" );
if( !( boost::filesystem::exists( path ) && boost::filesystem::is_regular_file( path ) ) ) if( !( boost::filesystem::exists( path ) && boost::filesystem::is_regular_file( path ) ) )
throw invalid_argument( "file does not exist" ); 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" ); auto path = boost::filesystem::canonical( web_root_path / "headlines.xml" );
//Check if path is within web_root_path //Check if path is within web_root_path
if( distance( web_root_path.begin(), web_root_path.end() ) > distance( path.begin(), path.end() ) || 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" ); throw invalid_argument( "path must be within root path" );
if( !( boost::filesystem::exists( path ) && boost::filesystem::is_regular_file( path ) ) ) if( !( boost::filesystem::exists( path ) && boost::filesystem::is_regular_file( path ) ) )
throw invalid_argument( "file does not exist" ); 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 ); auto path = boost::filesystem::canonical( web_root_path / request->path );
//Check if path is within web_root_path //Check if path is within web_root_path
if( distance( web_root_path.begin(), web_root_path.end() ) > distance( path.begin(), path.end() ) || 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" ); throw invalid_argument( "path must be within root path" );
if( boost::filesystem::is_directory( path ) ) if( boost::filesystem::is_directory( path ) )
path /= "index.html"; path /= "index.html";