fix possible infinite loop in intro.cpp thread

- it was possible to trigger an infinite loop in FreespaceChecker::check() by
  simply removing the drive letter on Windows (which leads to an infinite
  loop in the FreespaceChecker thread)
- this was caused by not checking if we make progress with
  parentDir.parent_path()
This commit is contained in:
Philip Kaufmann committed 2013-07-26 09:17:24 +02:00
1 parent 2b894bceac
commit 5bc6d8e580
2 files changed
+9

No files matched your search

+8
View File
@@ -25,6 +25,7 @@ static const uint64 BLOCK_CHAIN_SIZE = 10LL * GB_BYTES;
class FreespaceChecker : public QObject class FreespaceChecker : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
FreespaceChecker(Intro *intro); FreespaceChecker(Intro *intro);
@@ -61,9 +62,16 @@ void FreespaceChecker::check()
/* Find first parent that exists, so that fs::space does not fail */ /* Find first parent that exists, so that fs::space does not fail */
fs::path parentDir = dataDir; fs::path parentDir = dataDir;
fs::path parentDirOld = fs::path();
while(parentDir.has_parent_path() && !fs::exists(parentDir)) while(parentDir.has_parent_path() && !fs::exists(parentDir))
{ {
parentDir = parentDir.parent_path(); parentDir = parentDir.parent_path();
/* Check if we make any progress, break if not to prevent an infinite loop here */
if (parentDirOld == parentDir)
break;
parentDirOld = parentDir;
} }
try { try {
+1
View File
@@ -37,6 +37,7 @@ public:
* Determine default data directory for operating system. * Determine default data directory for operating system.
*/ */
static QString getDefaultDataDirectory(); static QString getDefaultDataDirectory();
signals: signals:
void requestCheck(); void requestCheck();
void stopThread(); void stopThread();