From 7076bbd87e954834a2f8a44c39d16b30ff04ab1c Mon Sep 17 00:00:00 2001 From: Michi Henning Date: Mon, 21 Feb 2005 01:13:56 +0000 Subject: Added check to server to disallow absolute paths and paths containing "..". --- cpp/src/IcePatch2/Util.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'cpp/src/IcePatch2/Util.cpp') diff --git a/cpp/src/IcePatch2/Util.cpp b/cpp/src/IcePatch2/Util.cpp index 885d7fff797..49da0c2edba 100644 --- a/cpp/src/IcePatch2/Util.cpp +++ b/cpp/src/IcePatch2/Util.cpp @@ -263,12 +263,15 @@ IcePatch2::simplify(const string& path) bool IcePatch2::isAbsolute(const string& pa) { - const string path = simplify(pa); - + unsigned i = 0; + while(isspace(pa[i])) + { + ++i; + } #ifdef _WIN32 - return path[0] == '/' || path.size() > 1 && isalpha(path[0]) && path[1] == ':'; + return pa[i] == '\\' || pa[i] == '/' || pa.size() > i + 1 && isalpha(pa[i]) && pa[i + 1] == ':'; #else - return path[0] == '/'; + return pa[i] == '/'; #endif } -- cgit v1.2.3