summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRitt Konstantin <ritt.ks@gmail.com>2010-04-27 02:12:47 (GMT)
committerQt Commercial Integration <QtCommercial@digia.com>2012-01-31 10:24:53 (GMT)
commit313c0c388524891c3887a29344135c452c4c301a (patch)
tree408da3acd7ee8043eacc36dddae19191b9edda0f /src
parentd56db447348d7b641097bf146d188751ba8a76ae (diff)
downloadQt-313c0c388524891c3887a29344135c452c4c301a.zip
Qt-313c0c388524891c3887a29344135c452c4c301a.tar.gz
Qt-313c0c388524891c3887a29344135c452c4c301a.tar.bz2
avoid infinite recursion in canonicalized() if cwd is a symlink
if current directory is a symlink to another directory on the same drive (the simplest example; say, c:\current\dir is a symlink to c:\target) then the first valid prefix for "c:\target" in canonicalized() is "c:" (NOT "c:\") and would be treated like "c:\current\dir" again...and again... until stack overflow :) Merge-Request: 494 Task-number: QTBUG-7610 Reviewed-by: Zeno Albisser
Diffstat (limited to 'src')
-rw-r--r--src/corelib/io/qfsfileengine.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/corelib/io/qfsfileengine.cpp b/src/corelib/io/qfsfileengine.cpp
index 8689c57..d15b4a7 100644
--- a/src/corelib/io/qfsfileengine.cpp
+++ b/src/corelib/io/qfsfileengine.cpp
@@ -189,9 +189,15 @@ QString QFSFileEnginePrivate::canonicalized(const QString &path)
known.insert(path);
do {
#ifdef Q_OS_WIN
- // UNC, skip past the first two elements
- if (separatorPos == 0 && tmpPath.startsWith(QLatin1String("//")))
- separatorPos = tmpPath.indexOf(slash, 2);
+ if (separatorPos == 0) {
+ if (tmpPath.size() >= 2 && tmpPath.at(0) == slash && tmpPath.at(1) == slash) {
+ // UNC, skip past the first two elements
+ separatorPos = tmpPath.indexOf(slash, 2);
+ } else if (tmpPath.size() >= 3 && tmpPath.at(1) == QLatin1Char(':') && tmpPath.at(2) == slash) {
+ // volume root, skip since it can not be a symlink
+ separatorPos = 2;
+ }
+ }
if (separatorPos != -1)
#endif
separatorPos = tmpPath.indexOf(slash, separatorPos + 1);