summaryrefslogtreecommitdiff
path: root/cpp/src/IcePatch2/Util.cpp
diff options
context:
space:
mode:
authorMichi Henning <michi@zeroc.com>2005-02-21 01:13:56 +0000
committerMichi Henning <michi@zeroc.com>2005-02-21 01:13:56 +0000
commit7076bbd87e954834a2f8a44c39d16b30ff04ab1c (patch)
treeceb11cc53a522e8d0d2200b154eb2a9f2069fd58 /cpp/src/IcePatch2/Util.cpp
parentadding Ice version numbers (diff)
downloadice-7076bbd87e954834a2f8a44c39d16b30ff04ab1c.tar.bz2
ice-7076bbd87e954834a2f8a44c39d16b30ff04ab1c.tar.xz
ice-7076bbd87e954834a2f8a44c39d16b30ff04ab1c.zip
Added check to server to disallow absolute paths and paths containing "..".
Diffstat (limited to 'cpp/src/IcePatch2/Util.cpp')
-rw-r--r--cpp/src/IcePatch2/Util.cpp11
1 files changed, 7 insertions, 4 deletions
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
}